@sketch-hq/sketch-assistant-utils
Version:
Utility functions and types for Sketch Assistants.
39 lines • 2.27 kB
TypeScript
import { FileFormat, Violation, RuleUtilsCreator, GetImageMetadata, AssistantDefinition, ProcessedSketchFile, GeneratorIterable, ObjectCache, IterableObjectCache, IgnoreConfig, CancelToken, TimeoutToken } 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 generator based iterable that can be cancelled by a RunOperation.
*/
export declare const createIterable: <T>(src: T[], cancelToken: CancelToken, timeoutToken: TimeoutToken, ignoredIds: string[]) => GeneratorIterable<T>;
/**
* Returns an IterableObjectCache for any given ObjectCache. We want 100% type safety here so
* when iterating objects we get the real object type back, and don't have to add any guards
* or checks to rule logic. If there's a more concise way to do this and retain the correct
* types I'm all ears.
*/
export declare const createIterableObjectCache: (o: ObjectCache, r: CancelToken, t: TimeoutToken, i: string[]) => IterableObjectCache;
/**
* Returns a RuleUtilsCreator function, which can be used to build util objects
* scoped to a specific rule.
*/
declare const createRuleUtilsCreator: (processedFile: ProcessedSketchFile, violations: Violation[], assistant: AssistantDefinition, cancelToken: CancelToken, getImageMetadata: GetImageMetadata, ignoreConfig: IgnoreConfig) => RuleUtilsCreator;
export { styleHash, styleEq, textStyleHash, textStyleEq, createRuleUtilsCreator };
//# sourceMappingURL=index.d.ts.map