@sketch-hq/sketch-assistant-utils
Advanced tools
Comparing version 5.0.0-next.5 to 5.0.0-next.6
# @sketch-hq/sketch-assistant-utils | ||
## 5.0.0-next.6 | ||
### Minor Changes | ||
- 02f4b7e: Style equality functions added to rule-utils | ||
## 5.0.0-next.5 | ||
@@ -4,0 +10,0 @@ |
@@ -1,3 +0,23 @@ | ||
import { Violation, RunOperation, RuleUtilsCreator, GetImageMetadata, AssistantDefinition, ProcessedSketchFile } from '@sketch-hq/sketch-assistant-types'; | ||
import { FileFormat, Violation, RunOperation, RuleUtilsCreator, GetImageMetadata, AssistantDefinition, ProcessedSketchFile } from '@sketch-hq/sketch-assistant-types'; | ||
/** | ||
* Helper function that creates a string hash from a set of attributes of a style | ||
* object. | ||
*/ | ||
declare const styleHash: (style: Partial<FileFormat.Style> | undefined) => string; | ||
/** | ||
* Returns a boolean from the equality comparison between two style objects. Useful when | ||
* comparing two layer styles. | ||
*/ | ||
declare const styleEq: (s1: FileFormat.Style | undefined, s2: FileFormat.Style | undefined) => boolean; | ||
/** | ||
* Helper function that creates a string hash from a set of attributes of a text style | ||
* object. | ||
*/ | ||
declare const textStyleHash: (style: Partial<FileFormat.Style> | undefined) => string; | ||
/** | ||
* Returns a boolean from the equality comparison between two text style objects. Useful when | ||
* comparing two text layer styles. | ||
*/ | ||
declare const textStyleEq: (s1: FileFormat.Style | undefined, s2: FileFormat.Style | undefined) => boolean; | ||
/** | ||
* Returns a RuleUtilsCreator function, which can be used to build util objects | ||
@@ -7,3 +27,3 @@ * scoped to a specific rule. | ||
declare const createRuleUtilsCreator: (processedFile: ProcessedSketchFile, violations: Violation[], assistant: AssistantDefinition, operation: RunOperation, getImageMetadata: GetImageMetadata) => RuleUtilsCreator; | ||
export { createRuleUtilsCreator }; | ||
export { styleHash, styleEq, textStyleHash, textStyleEq, createRuleUtilsCreator }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -19,2 +19,41 @@ "use strict"; | ||
const assistant_1 = require("../assistant"); | ||
/** | ||
* Helper function that creates a string hash from a set of attributes of a style | ||
* object. | ||
*/ | ||
const styleHash = (style) => object_utils_1.objectHash({ | ||
borders: style === null || style === void 0 ? void 0 : style.borders, | ||
borderOptions: style === null || style === void 0 ? void 0 : style.borderOptions, | ||
blur: style === null || style === void 0 ? void 0 : style.blur, | ||
fills: style === null || style === void 0 ? void 0 : style.fills, | ||
shadows: style === null || style === void 0 ? void 0 : style.shadows, | ||
innerShadows: style === null || style === void 0 ? void 0 : style.innerShadows, | ||
}); | ||
exports.styleHash = styleHash; | ||
/** | ||
* Returns a boolean from the equality comparison between two style objects. Useful when | ||
* comparing two layer styles. | ||
*/ | ||
const styleEq = (s1, s2) => styleHash(s1) === styleHash(s2); | ||
exports.styleEq = styleEq; | ||
/** | ||
* Helper function that creates a string hash from a set of attributes of a text style | ||
* object. | ||
*/ | ||
const textStyleHash = (style) => object_utils_1.objectHash({ | ||
borders: style === null || style === void 0 ? void 0 : style.borders, | ||
borderOptions: style === null || style === void 0 ? void 0 : style.borderOptions, | ||
blur: style === null || style === void 0 ? void 0 : style.blur, | ||
fills: style === null || style === void 0 ? void 0 : style.fills, | ||
shadows: style === null || style === void 0 ? void 0 : style.shadows, | ||
innerShadows: style === null || style === void 0 ? void 0 : style.innerShadows, | ||
textStyle: style && style.textStyle ? object_utils_1.objectHash(style === null || style === void 0 ? void 0 : style.textStyle) : null, | ||
}); | ||
exports.textStyleHash = textStyleHash; | ||
/** | ||
* Returns a boolean from the equality comparison between two text style objects. Useful when | ||
* comparing two text layer styles. | ||
*/ | ||
const textStyleEq = (s1, s2) => textStyleHash(s1) === textStyleHash(s2); | ||
exports.textStyleEq = textStyleEq; | ||
class RuleNotFoundError extends Error { | ||
@@ -149,2 +188,6 @@ constructor(assistant, ruleName) { | ||
}, | ||
styleEq, | ||
textStyleEq, | ||
styleHash, | ||
textStyleHash, | ||
}; | ||
@@ -151,0 +194,0 @@ }; |
@@ -1,3 +0,23 @@ | ||
import { Violation, RunOperation, RuleUtilsCreator, GetImageMetadata, AssistantDefinition, ProcessedSketchFile } from '@sketch-hq/sketch-assistant-types'; | ||
import { FileFormat, Violation, RunOperation, RuleUtilsCreator, GetImageMetadata, AssistantDefinition, ProcessedSketchFile } from '@sketch-hq/sketch-assistant-types'; | ||
/** | ||
* Helper function that creates a string hash from a set of attributes of a style | ||
* object. | ||
*/ | ||
declare const styleHash: (style: Partial<FileFormat.Style> | undefined) => string; | ||
/** | ||
* Returns a boolean from the equality comparison between two style objects. Useful when | ||
* comparing two layer styles. | ||
*/ | ||
declare const styleEq: (s1: FileFormat.Style | undefined, s2: FileFormat.Style | undefined) => boolean; | ||
/** | ||
* Helper function that creates a string hash from a set of attributes of a text style | ||
* object. | ||
*/ | ||
declare const textStyleHash: (style: Partial<FileFormat.Style> | undefined) => string; | ||
/** | ||
* Returns a boolean from the equality comparison between two text style objects. Useful when | ||
* comparing two text layer styles. | ||
*/ | ||
declare const textStyleEq: (s1: FileFormat.Style | undefined, s2: FileFormat.Style | undefined) => boolean; | ||
/** | ||
* Returns a RuleUtilsCreator function, which can be used to build util objects | ||
@@ -7,3 +27,3 @@ * scoped to a specific rule. | ||
declare const createRuleUtilsCreator: (processedFile: ProcessedSketchFile, violations: Violation[], assistant: AssistantDefinition, operation: RunOperation, getImageMetadata: GetImageMetadata) => RuleUtilsCreator; | ||
export { createRuleUtilsCreator }; | ||
export { styleHash, styleEq, textStyleHash, textStyleEq, createRuleUtilsCreator }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -7,2 +7,37 @@ import mem from 'mem'; | ||
import { getRuleDefinition } from '../assistant'; | ||
/** | ||
* Helper function that creates a string hash from a set of attributes of a style | ||
* object. | ||
*/ | ||
const styleHash = (style) => objectHash({ | ||
borders: style === null || style === void 0 ? void 0 : style.borders, | ||
borderOptions: style === null || style === void 0 ? void 0 : style.borderOptions, | ||
blur: style === null || style === void 0 ? void 0 : style.blur, | ||
fills: style === null || style === void 0 ? void 0 : style.fills, | ||
shadows: style === null || style === void 0 ? void 0 : style.shadows, | ||
innerShadows: style === null || style === void 0 ? void 0 : style.innerShadows, | ||
}); | ||
/** | ||
* Returns a boolean from the equality comparison between two style objects. Useful when | ||
* comparing two layer styles. | ||
*/ | ||
const styleEq = (s1, s2) => styleHash(s1) === styleHash(s2); | ||
/** | ||
* Helper function that creates a string hash from a set of attributes of a text style | ||
* object. | ||
*/ | ||
const textStyleHash = (style) => objectHash({ | ||
borders: style === null || style === void 0 ? void 0 : style.borders, | ||
borderOptions: style === null || style === void 0 ? void 0 : style.borderOptions, | ||
blur: style === null || style === void 0 ? void 0 : style.blur, | ||
fills: style === null || style === void 0 ? void 0 : style.fills, | ||
shadows: style === null || style === void 0 ? void 0 : style.shadows, | ||
innerShadows: style === null || style === void 0 ? void 0 : style.innerShadows, | ||
textStyle: style && style.textStyle ? objectHash(style === null || style === void 0 ? void 0 : style.textStyle) : null, | ||
}); | ||
/** | ||
* Returns a boolean from the equality comparison between two text style objects. Useful when | ||
* comparing two text layer styles. | ||
*/ | ||
const textStyleEq = (s1, s2) => textStyleHash(s1) === textStyleHash(s2); | ||
class RuleNotFoundError extends Error { | ||
@@ -137,2 +172,6 @@ constructor(assistant, ruleName) { | ||
}, | ||
styleEq, | ||
textStyleEq, | ||
styleHash, | ||
textStyleHash, | ||
}; | ||
@@ -142,3 +181,3 @@ }; | ||
}; | ||
export { createRuleUtilsCreator }; | ||
export { styleHash, styleEq, textStyleHash, textStyleEq, createRuleUtilsCreator }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@sketch-hq/sketch-assistant-utils", | ||
"version": "5.0.0-next.5", | ||
"version": "5.0.0-next.6", | ||
"module": "dist/esm/index", | ||
@@ -30,3 +30,3 @@ "main": "dist/cjs/index", | ||
"@json-schema-spec/json-pointer": "0.1.2", | ||
"@sketch-hq/sketch-assistant-types": "3.0.0-next.4", | ||
"@sketch-hq/sketch-assistant-types": "3.0.0-next.5", | ||
"ajv": "6.12.0", | ||
@@ -33,0 +33,0 @@ "humps": "2.0.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
172828
2288
+ Added@sketch-hq/sketch-assistant-types@3.0.0-next.5(transitive)
- Removed@sketch-hq/sketch-assistant-types@3.0.0-next.4(transitive)