import { Color, Constants, Fn, Token as Token$1, Unit } from '@tokens-studio/schema-validation'; declare class BinOpNode implements ASTNode { left: ASTNode; opToken: Token; right: ASTNode; token?: Token | undefined; nodeType: string; constructor(left: ASTNode, opToken: Token, right: ASTNode, token?: Token | undefined); get op(): Operations | TokenType; } declare class NumNode implements ASTNode { token: Token; nodeType: string; value: number; constructor(token: Token); } declare class StringNode implements ASTNode { token: Token; nodeType: string; value: string; constructor(token: Token); } declare class UnaryOpNode implements ASTNode { opToken: Token; expr: ASTNode; token?: Token | undefined; nodeType: string; constructor(opToken: Token, expr: ASTNode, token?: Token | undefined); get op(): Operations; } declare class ListNode implements ASTNode { elements: ASTNode[]; token?: Token | undefined; nodeType: string; constructor(elements: ASTNode[], token?: Token | undefined); } declare class ImplicitListNode extends ListNode { elements: ASTNode[]; token?: Token | undefined; nodeType: string; isImplicit: boolean; constructor(elements: ASTNode[], token?: Token | undefined); } declare class FunctionCallNode implements ASTNode { args: ASTNode[]; token?: Token | undefined; nodeType: string; name: string; constructor(nameTokenValue: string, args: ASTNode[], token?: Token | undefined); } declare class NoOpNode implements ASTNode { token?: Token | undefined; nodeType: string; constructor(token?: Token | undefined); } declare class ReferenceNode implements ASTNode { token: Token; nodeType: string; value: string; constructor(token: Token); } declare class IdentifierNode implements ASTNode { token: Token; nodeType: string; name: string; constructor(token: Token); } declare class ReassignNode implements ASTNode { identifier: IdentifierNode | IdentifierNode[]; value: ASTNode; token?: Token | undefined; nodeType: string; constructor(identifier: IdentifierNode | IdentifierNode[], value: ASTNode, token?: Token | undefined); baseIdentifier(): IdentifierNode; isAttributeAssignment(): boolean; identifierToString(): string; attributesChain(): IdentifierNode[]; attributesStringChain(): string[]; } /** * Walk the AST and call the visit function on each node * * @param node - The AST node to traverse * @param onVisit - Function called for each node during traversal * * @example * // Print all node types * walk(ast, (node) => console.log(node.nodeType)); * * @example * // Collect all reference nodes * const refs: ReferenceNode[] = []; * walk(ast, (node) => { * if (node instanceof ReferenceNode) refs.push(node); * }); */ declare function walkAST(node: ASTNode, onVisit: (node: ASTNode) => void): void; /** * Walk the AST and collect all nodes that match the predicate into a flat list * * @param ast - The AST node to traverse * @param predicate - Function to test each node * @returns Flat array of matching nodes * * @example * // Find all reference nodes * const refs = filterAST(ast, (node) => node instanceof ReferenceNode); * * @example * // Find references to a specific token * const refs = filterAST(ast, (node) => * node instanceof ReferenceNode && node.value === "color.primary" * ); */ declare function filterAST(ast: ASTNode, predicate: (node: ASTNode) => boolean): T[]; /** * Collect all reference nodes from the AST * * @param ast - The AST node to traverse * @param targetName - Optional: only collect references matching this name * @returns Array of reference nodes * * @example * // Get all references * const refs = collectReferenceNodes(ast); * * @example * // Get references to a specific token * const refs = collectReferenceNodes(ast, "color.primary"); */ declare function collectReferenceNodes(ast: ASTNode, targetName?: string): ReferenceNode[]; interface ToJsOptions { /** Whether to recursively convert nested values (default: true) */ recursive?: boolean; /** Whether to use toString() for structured types (default: false) */ stringify?: boolean; } declare const getResultTypeName: (result: unknown) => string; type SupportedMethods = Record; interface MethodArgumentDef { name: string; type: any; optional?: boolean; } interface MethodDefinitionDef { name?: string; function: (...args: any[]) => ISymbolType | null | undefined; args: MethodArgumentDef[]; returnType: any; } declare abstract class BaseSymbolType implements ISymbolType { abstract type: string; value: any | null; config?: Config; static _SUPPORTED_METHODS?: SupportedMethods; constructor(value: any, config?: Config); abstract validValue(value: any): boolean; /** * Forces creating a deepCopy of provided symbol no matter if it's immutable or not. */ abstract deepCopy(): ISymbolType; /** * Returns a copy of the symbol if it's mutable, otherwise returns the same instance. * * This method is used to prevent reference sharing issues when storing symbols in * containers like lists and dictionaries. Immutable symbols (Number, String, Boolean, * NumberWithUnit, Null, hex ColorSymbol) can safely share references since they * cannot be modified after creation. Mutable symbols (List, Dictionary, dynamic * ColorSymbol) need to be deep copied to prevent unintended mutations. * * @returns For immutable symbols: returns `this` (same reference) * For mutable symbols: returns `this.deepCopy()` (new instance) */ abstract cloneIfMutable(): ISymbolType; abstract toJs(options?: ToJsOptions): JsValue; toString(): string; getTypeName(): string; typeEquals(other: ISymbolType): boolean; equals(other: ISymbolType): boolean; hasMethod?(methodName: string, args: ISymbolType[]): boolean; callMethod?(methodName: string, args: ISymbolType[]): ISymbolType | null | undefined; hasAttribute?(_attributeName: string): boolean; getAttribute?(attributeName: string): ISymbolType | null; setAttribute?(attributeName: string, _value: ISymbolType): void; } /** * Null type to differentiate from null values from the host language * Methods returning `null` should return this type, also as empty variables should keep this. * Host language `null` or `undefined` will crash when used as values during intepretation. */ declare class NullSymbol extends BaseSymbolType { type: string; static readonly type = "Null"; constructor(config?: Config); validValue(val: any): boolean; toString(): string; deepCopy(): NullSymbol; cloneIfMutable(): NullSymbol; equals(other: ISymbolType): boolean; static empty(): NullSymbol; toJs(_options?: ToJsOptions): null; } type NumberValue = number | null; declare class NumberSymbol extends BaseSymbolType { type: string; static readonly type = "Number"; static _SUPPORTED_METHODS: { to_string: { name: string; function: (this: NumberSymbol, radix?: NumberSymbol) => StringSymbol; args: { name: string; type: string; optional: boolean; }[]; returnType: string; }; }; value: NumberValue; constructor(value: number | NumberSymbol | NumberWithUnitSymbol | null, config?: Config); validValue(val: any): boolean; expectSafeValue(val: any): asserts val is number; toString(): string; deepCopy(): NumberSymbol; cloneIfMutable(): NumberSymbol; static empty(): NumberSymbol; hasAttribute(attributeName: string): boolean; getAttribute(attributeName: string): ISymbolType | null; toStringSymbol(radix?: NumberSymbol): StringSymbol; toJs(_options?: ToJsOptions): NumberValue; } type StringValue = string | null; declare class StringSymbol extends BaseSymbolType { type: string; static readonly type = "String"; static _SUPPORTED_METHODS: { upper: { function: (this: StringSymbol) => StringSymbol; args: never[]; returnType: string; }; lower: { function: (this: StringSymbol) => StringSymbol; args: never[]; returnType: string; }; length: { function: (this: StringSymbol) => NumberSymbol; args: never[]; returnType: string; }; concat: { function: (this: StringSymbol, other: StringSymbol) => StringSymbol; args: { name: string; type: string; }[]; returnType: string; }; split: { function: (this: StringSymbol, delimiter?: StringSymbol) => ListSymbol; args: { name: string; type: string; optional: boolean; }[]; returnType: string; }; trim: { function: (this: StringSymbol) => StringSymbol; args: never[]; returnType: string; }; }; value: StringValue; constructor(value: string | StringSymbol | null, config?: Config); validValue(val: any): boolean; expectSafeValue(val: any): asserts val is string; upper(): StringSymbol; deepCopy(): StringSymbol; cloneIfMutable(): StringSymbol; static empty(): StringSymbol; lower(): StringSymbol; length(): NumberSymbol; concat(other: StringSymbol): StringSymbol; split(delimiter?: StringSymbol): ListSymbol; trim(): StringSymbol; toJs(_options?: ToJsOptions): StringValue; } type BooleanValue = boolean | null; declare class BooleanSymbol extends BaseSymbolType { type: string; static readonly type = "Boolean"; value: BooleanValue; constructor(value: boolean | BooleanSymbol | null, config?: Config); validValue(val: any): boolean; expectSafeValue(val: any): asserts val is boolean; deepCopy(): BooleanSymbol; cloneIfMutable(): BooleanSymbol; static empty(): BooleanSymbol; toJs(_options?: ToJsOptions): BooleanValue; } declare class ListSymbol extends BaseSymbolType { type: string; static readonly type = "List"; static _SUPPORTED_METHODS: { append: { function: (this: ListSymbol, item: ISymbolType) => ListSymbol; args: { name: string; type: string; }[]; returnType: string; }; extend: { function: (this: ListSymbol, ...items: ISymbolType[]) => ListSymbol; args: never[]; returnType: string; }; insert: { function: (this: ListSymbol, index: NumberSymbol, item: ISymbolType) => ListSymbol; args: { name: string; type: string; }[]; returnType: string; }; delete: { function: (this: ListSymbol, index: NumberSymbol) => ListSymbol; args: { name: string; type: string; }[]; returnType: string; }; length: { function: (this: ListSymbol) => NumberSymbol; args: never[]; returnType: string; }; index: { function: (this: ListSymbol, item: ISymbolType) => NumberSymbol; args: { name: string; type: string; }[]; returnType: string; }; get: { function: (this: ListSymbol, index: NumberSymbol) => ISymbolType; args: { name: string; type: string; }[]; returnType: string; }; update: { function: (this: ListSymbol, index: NumberSymbol, item: ISymbolType) => ListSymbol; args: { name: string; type: string; }[]; returnType: string; }; join: { function: (this: ListSymbol, separator?: StringSymbol) => StringSymbol; args: { name: string; type: string; optional: boolean; }[]; returnType: string; }; }; value: ISymbolType[]; isImplicit: boolean; constructor(elements: ISymbolType[] | null, isImplicit?: boolean, config?: Config); validValue(val: any): boolean; toString(): string; append(item: ISymbolType): ListSymbol; extend(...items: ISymbolType[]): ListSymbol; insert(indexSymbol: NumberSymbol, item: ISymbolType): ListSymbol; delete(indexSymbol: NumberSymbol): ListSymbol; length(): NumberSymbol; index(item: ISymbolType): NumberSymbol; get(indexSymbol: NumberSymbol): ISymbolType; update(indexSymbol: NumberSymbol, item: ISymbolType): ListSymbol; join(separator?: StringSymbol): StringSymbol; deepCopy(): ListSymbol; cloneIfMutable(): ListSymbol; static empty(): ListSymbol; getTypeName(): string; toJs(options?: ToJsOptions): JsValue[]; } type NumberWithUnitValue = number | null; declare class NumberWithUnitSymbol extends BaseSymbolType { type: string; static readonly type = "NumberWithUnit"; static _SUPPORTED_METHODS: { to_string: { name: string; function: (this: NumberWithUnitSymbol) => StringSymbol; args: { name: string; type: string; optional: boolean; }[]; returnType: string; }; to_number: { function: (this: NumberWithUnitSymbol) => NumberSymbol; args: never[]; returnType: string; }; }; value: NumberWithUnitValue; unit: SupportedFormats; constructor(value: number | NumberSymbol | null, unit: SupportedFormats | string, config?: Config); validValue(val: any): boolean; static fromRecord(record: { value: number | string; unit: string; type?: string; }, config?: Config): NumberWithUnitSymbol | undefined; toString(): string; expectSafeValue(val: any): asserts val is number; toStringSymbol(): StringSymbol; to_number(): NumberSymbol; equals(other: ISymbolType): boolean; deepCopy(): NumberWithUnitSymbol; cloneIfMutable(): NumberWithUnitSymbol; static empty(): NumberWithUnitSymbol; hasAttribute(attributeName: string): boolean; getAttribute(attributeName: string): ISymbolType | null; getTypeName(): string; toJs(options?: ToJsOptions): string | { value: number | null; unit: string; }; } declare class DictionarySymbol extends BaseSymbolType { type: string; static readonly type = "Dictionary"; static _SUPPORTED_METHODS: { get: { function: (this: DictionarySymbol, key: StringSymbol) => ISymbolType; args: { name: string; type: string; optional: boolean; }[]; returnType: string; }; set: { function: (this: DictionarySymbol, key: StringSymbol, value: ISymbolType) => DictionarySymbol; args: { name: string; type: string; optional: boolean; }[]; returnType: string; }; delete: { function: (this: DictionarySymbol, key: StringSymbol) => DictionarySymbol; args: { name: string; type: string; optional: boolean; }[]; returnType: string; }; keys: { function: (this: DictionarySymbol) => ListSymbol; args: never[]; returnType: string; }; values: { function: (this: DictionarySymbol) => ListSymbol; args: never[]; returnType: string; }; key_exists: { function: (this: DictionarySymbol, key: StringSymbol) => BooleanSymbol; args: { name: string; type: string; optional: boolean; }[]; returnType: string; }; length: { function: (this: DictionarySymbol) => NumberSymbol; args: never[]; returnType: string; }; clear: { function: (this: DictionarySymbol) => DictionarySymbol; args: never[]; returnType: string; }; }; value: Map; constructor(value: Map | Record | DictionarySymbol | null, config?: Config); validValue(val: any): boolean; toString(): string; get(key: StringSymbol): ISymbolType; set(key: StringSymbol, value: ISymbolType): DictionarySymbol; delete(key: StringSymbol): DictionarySymbol; keys(): ListSymbol; values(): ListSymbol; keyExists(key: StringSymbol): BooleanSymbol; length(): NumberSymbol; clear(): DictionarySymbol; deepCopy(): DictionarySymbol; cloneIfMutable(): DictionarySymbol; static empty(): DictionarySymbol; hasAttribute(attributeName: string): boolean; getAttribute(attributeName: string): ISymbolType | null; toJs(options?: ToJsOptions): Record; } type TokenValue = Map | ISymbolType[]; declare class TokenSymbol extends BaseSymbolType { type: string; static readonly type = "Token"; static _SUPPORTED_METHODS: { get: { function: (this: TokenSymbol, keyOrIndex: StringSymbol | NumberSymbol) => ISymbolType; args: { name: string; type: string; optional: boolean; }[]; returnType: string; }; set: { function: (this: TokenSymbol, key: StringSymbol, value: ISymbolType) => TokenSymbol; args: { name: string; type: string; optional: boolean; }[]; returnType: string; }; keys: { function: (this: TokenSymbol) => ListSymbol; args: never[]; returnType: string; }; values: { function: (this: TokenSymbol) => ListSymbol; args: never[]; returnType: string; }; length: { function: (this: TokenSymbol) => NumberSymbol; args: never[]; returnType: string; }; append: { function: (this: TokenSymbol, item: ISymbolType) => TokenSymbol; args: { name: string; type: string; }[]; returnType: string; }; extend: { function: (this: TokenSymbol, ...items: ISymbolType[]) => TokenSymbol; args: never[]; returnType: string; }; insert: { function: (this: TokenSymbol, index: NumberSymbol, item: ISymbolType) => TokenSymbol; args: { name: string; type: string; }[]; returnType: string; }; delete: { function: (this: TokenSymbol, index: NumberSymbol) => TokenSymbol; args: { name: string; type: string; }[]; returnType: string; }; index: { function: (this: TokenSymbol, item: ISymbolType) => NumberSymbol; args: { name: string; type: string; }[]; returnType: string; }; update: { function: (this: TokenSymbol, index: NumberSymbol, item: ISymbolType) => TokenSymbol; args: { name: string; type: string; }[]; returnType: string; }; join: { function: (this: TokenSymbol, separator?: StringSymbol) => StringSymbol; args: { name: string; type: string; optional: boolean; }[]; returnType: string; }; }; subType: string; value: TokenValue; /** * Optional metadata attached to this token. * This is a reference that is preserved (not cloned) during deepCopy/cloneIfMutable operations. * It is not accessible to the tokenscript language and is intended for external use * (e.g., storing token IDs for tracing). */ metadata?: SymbolMetadata; constructor(subType: string, value: TokenValue | Record | TokenSymbol | null, config?: Config, metadata?: SymbolMetadata); validValue(val: any): boolean; toString(): string; get(keyOrIndex: StringSymbol | NumberSymbol | string | number): ISymbolType; set(key: StringSymbol, value: ISymbolType): TokenSymbol; keys(): ListSymbol; values(): ListSymbol; length(): NumberSymbol; append(item: ISymbolType): TokenSymbol; extend(...items: ISymbolType[]): TokenSymbol; insert(indexSymbol: NumberSymbol, item: ISymbolType): TokenSymbol; delete(indexSymbol: NumberSymbol): TokenSymbol; index(item: ISymbolType): NumberSymbol; update(indexSymbol: NumberSymbol, item: ISymbolType): TokenSymbol; join(separator?: StringSymbol): StringSymbol; deepCopy(): TokenSymbol; cloneIfMutable(): TokenSymbol; static empty(): TokenSymbol; hasAttribute(attributeName: string): boolean; getAttribute(attributeName: string): ISymbolType | null; getTypeName(): string; toJs(options?: ToJsOptions): JsValue[] | Record; } type dynamicColorValue = Record; type ColorValue = string | dynamicColorValue | null; declare class ColorSymbol extends BaseSymbolType { type: string; static readonly type = "Color"; static _SUPPORTED_METHODS: { to_string: { name: string; function: (this: ColorSymbol) => StringSymbol; args: never[]; returnType: string; }; }; subType: string | null; value: ColorValue; alpha: number | null; static empty(): ColorSymbol; constructor(value: ColorValue, subType?: string, alpha?: number | null, config?: Config); toStringSymbol(): StringSymbol; toString(): string; to(targetType: string): ColorSymbol; typeEquals(other: ISymbolType): boolean; isHex(): boolean; validValue(val: any): boolean; equals(other: ISymbolType): boolean; deepCopy(): ColorSymbol; cloneIfMutable(): ColorSymbol; hasAttribute(attributeName: string): boolean; getAttribute(attributeName: string): ISymbolType | null; hasMethod(methodName: string, args: ISymbolType[]): boolean; callMethod(methodName: string, args: ISymbolType[]): ISymbolType | null | undefined; getTypeName(): string; toJs(options?: ToJsOptions): string | Record; } declare const jsValueToSymbolType: (value: any, config?: Config) => ISymbolType; /** * Represents a JavaScript value that can be produced from a TokenScript symbol. * This includes primitives, arrays, and plain objects (recursively). */ type JsValue = string | number | boolean | null | JsValue[] | { [key: string]: JsValue; }; /** * Utilities for working with TokenScript schema URIs * * Handles URI construction, parsing, and manipulation for the TokenScript schema registry. */ type SemanticVersion = { major: number; } | { major: number; minor: number; } | { major: number; minor: number; patch: number; }; type uri = string; type specType = string; /** * Base manager class that provides common functionality for managing specifications, * conversions, and BFS-based conversion path resolution. */ declare abstract class BaseManager { protected specs: Map; protected specTypes: Map; protected conversions: Map TOutput>>; protected parentConfig?: Config; protected removeVersionFromUri(uri: uri): uri; /** * Check if two URIs point to the same schema (ignoring version) */ protected isSameSchemaUri(uri1: uri, uri2: uri): boolean; /** * Parse semantic version from URI * Example: "/api/v1/schema/srgb-color/0.0.1/" -> { major: 0, minor: 0, patch: 1 } */ protected parseSemverFromUri(uri: uri): SemanticVersion | null; /** * Get base URI without version * Example: "/api/v1/schema/srgb-color/0.0.1/" -> "/api/v1/schema/srgb-color/" */ protected getBaseUri(uri: uri): uri; /** * Generate version resolution candidates from most specific to least specific * Example: "0.0.1" -> ["0.0.1", "0.0", "0", "latest"] */ protected generateVersionCandidates(uri: uri): uri[]; /** * Find the latest (highest) semantic version for a URI */ protected findLatestVersion(uri: uri): uri | null; /** * Resolve URI by trying version candidates from most specific to least specific */ protected resolveVersionUri(uri: uri): uri | null; /** * Find a conversion path from source to target format using BFS with version resolution */ protected findConversionPath(sourceUri: uri, targetUri: uri): uri[]; /** * Check if a conversion path exists between source and target URIs with version resolution */ hasConversion(sourceUri: uri, targetUri: uri): boolean; /** * Get a specification by its URI with version resolution */ getSpec(uri: uri): TSpec | undefined; /** * Convert input through a chain of conversions to reach the target URI with version resolution */ protected convertThroughPath(input: TInput, sourceUri: uri, targetUri: uri): TOutput; /** * Register a conversion function between two URIs */ protected registerConversionFunction(sourceUri: uri, targetUri: uri, conversionFn: (input: TInput) => TOutput): void; abstract register(uri: uri, spec: TSpec | specType): TSpec; protected abstract getSpecName(spec: TSpec): string; /** * Abstract method for creating a clone of the manager */ abstract clone(): this; /** * Set the parent config reference */ setParentConfig(config: Config): void; /** * Get the parent config reference */ getParentConfig(): Config | undefined; /** * Creates interpreter configuration with full context for conversion functions and initializers. * Uses parent config if available to provide access to all managers and registrations. */ protected createInterpreterConfig(references: Record): { references: Record; config?: Config; }; } type ColorSpecification = Color.ColorSpecification; /** * Historical compatibility alias for `parseColorSpec`. Wrap a call in a * `try { ... } catch (err) { ... }` to handle validation failures. * * @deprecated Prefer `parseColorSpec` / `safeParseColorSpec`. */ declare const ColorSpecificationSchema: (json: unknown) => ColorSpecification; type uriType$2 = string; type Specs$1 = Map; interface FormatColorOptions { decimalPlaces?: number; removeTrailingZeros?: boolean; } declare class ColorManager extends BaseManager { private initializers; constructor(defaultSpecs?: Specs$1); protected getSpecName(spec: ColorSpecification): string; /** * Creates a clone of this class to be passed down to initializers and conversion functions * Links properties to the parent config. */ clone(): this; registerRootInitializers(_uri: uriType$2, spec: ColorSpecification): void; registerConversions(uri: uriType$2, spec: ColorSpecification): void; register(uri: uriType$2, spec: ColorSpecification | string): ColorSpecification; getSpecByType(type: string): ColorSpecification | undefined; getSpecFromColor(color: ColorSymbol): ColorSpecification | undefined; hasInitializer(keyword: string): boolean; executeInitializer(keyword: string, args: Array): ColorSymbol; hasConversionByType(sourceType: string, targetType: string): boolean; convertTo(color: ColorSymbol, targetUri: string): ColorSymbol; convertToByType(color: ColorSymbol, targetType: string): ColorSymbol; setAttribute(color: ColorSymbol, node: ReassignNode, attributeValue: ISymbolType): ColorSymbol; /** * Formats a number value, rounding to specified decimal places and optionally removing trailing zeros. * * @param value - The numeric value to format * @param decimalPlaces - Number of decimal places to round to * @param removeTrailingZeros - Whether to remove trailing zeros * @returns Formatted number string */ private formatNumber; /** * Formats a ColorSymbol as a string representation using the appropriate schema-defined format. * * For hex colors (string values), returns the hex string as-is. * For dynamic colors (object values), uses the schema's `order` property to determine * parameter order and formats as a function call (e.g., "hsl(0, 100, 50.0)"). * If alpha is set and less than 1, it is included as the fourth parameter. * * @param color - The ColorSymbol to format * @param opts - Formatting options for numeric values * @returns Formatted string representation of the color, or empty string if formatting fails * * @example * ```typescript * // Hex color * const hexColor = new ColorSymbol("#ff0000", "Hex"); * manager.formatColorMethod(hexColor); // "#ff0000" * * // HSL color with schema order ["h", "s", "l"] * const hslColor = new ColorSymbol({ h: 0, s: 100, l: 50.123456 }, "HSL"); * manager.formatColorMethod(hslColor); // "hsl(0, 100, 50.12)" * * // RGB color with alpha * const rgbColor = new ColorSymbol({ r: 255, g: 0, b: 0 }, "RGB", undefined, 0.5); * manager.formatColorMethod(rgbColor); // "rgb(255, 0, 0, 0.5)" * ``` */ formatColorMethod(color: ColorSymbol, opts?: FormatColorOptions): string; getColorSchemas(): Map; } type ConstantsSpecification = Constants.ConstantsSpecification; /** * Historical compatibility alias for `parseConstantsSpec`. Wrap a call * in a `try { ... } catch (err) { ... }` to handle validation failures. * * @deprecated Prefer `parseConstantsSpec` / `safeParseConstantsSpec`. */ declare const ConstantsSpecificationSchema: (json: unknown) => ConstantsSpecification; type FunctionSpecification = Fn.FunctionSpecification; /** * Historical compatibility alias for `parseFunctionSpec`. Wrap a call in * a `try { ... } catch (err) { ... }` to handle validation failures. * * @deprecated Prefer `parseFunctionSpec` / `safeParseFunctionSpec`. */ declare const FunctionSpecificationSchema: (json: unknown) => FunctionSpecification; type functionName = string; type FunctionImpl = (...args: ISymbolType[]) => ISymbolType; declare class FunctionsManager extends BaseManager { private functionMap; constructor(); protected getSpecName(spec: FunctionSpecification): string; clone(): this; register(name: functionName, spec: FunctionSpecification | string): FunctionSpecification; private setupBuiltinFunctions; private registerFunction; private registerDynamicFunction; getFunction(name: string): FunctionImpl | undefined; hasFunction(name: string): boolean; getFunctionNames(): string[]; getFunctionSchemas(): Map; /** * Validate that a function call has the correct number of arguments * based on its schema spec. Only validates schema-registered functions * (not builtins which handle their own argument validation). */ validateFunctionArgs(name: string, args: ISymbolType[], token?: Token): void; } type TokenSpecification = Token$1.TokenSpecification; type uriType$1 = string; /** * Result of validating a token value. * For nested validation failures, path indicates where the error occurred. */ interface ValidationResult { valid: boolean; error?: string; tokenType?: string; path?: (string | number)[]; } declare class TokenManager extends BaseManager { /** * TokenScript validation scripts by token type. * The script receives {input} as the value to validate. * Should return true if valid, or a string error code if invalid. */ private validationScripts; /** * Cached parsed ASTs for validation scripts. * Avoids re-parsing the same script on every validation call. */ private validationAstCache; /** * Cached Interpreter instances for validation scripts. * Reusing interpreters avoids recreating Config, SymbolTable, etc. */ private validationInterpreterCache; protected getSpecName(spec: TokenSpecification): string; getSpecByType(type: string): TokenSpecification | undefined; clone(): this; register(uri: uriType$1, spec: TokenSpecification | string): TokenSpecification; /** * Register a TokenScript validation script for a token type. * The script receives {input} as the value to validate. * Accepts either a string (direct script) or an object with type and script properties (built schema). */ registerValidation(tokenType: string, validation: string | { type: string; script: string; }): void; /** * Get validation script for a token type. */ getValidation(tokenType: string): string | undefined; /** * Get possible error codes from validation scripts by walking the AST. * Finds all return statements that return string literals (error codes). * * @param tokenType - Optional token type to get errors for. If omitted, returns all error types. * @returns Array of error code strings */ validationErrorTypes(tokenType?: string): string[]; /** * Extract error codes from a validation script's AST. * Walks the tree and returns string values from return statements. */ private extractErrorTypesFromAST; /** * Validate a token value against its type using TokenScript. * Automatically performs deep validation for nested token properties. * Returns an array of validation results (empty or single valid result if all pass). * * @param tokenType - The token type name (e.g., "typography", "color") * @param value - The symbol value to validate * @param visitedUrls - Set of URLs already visited (for circular reference detection) * @param basePath - Path prefix for nested validation errors * @param depth - Current nesting depth (for max depth protection) */ validate(tokenType: string, value: ISymbolType, visitedUrls?: Set, basePath?: (string | number)[], depth?: number): ValidationResult[]; /** * Validate items in a list against an items schema. * Each item is validated and errors include the index in the path. */ private validateListItems; /** * Validate properties of an object against a properties schema. */ private validateObjectProperties; /** * Run the validation script for a token type. * Internal method used by validate(). * Uses cached Interpreter when available to avoid recreation overhead. */ private runValidationScript; /** * Extract a Map from various symbol types that can contain key-value pairs. */ private getValueMap; } type UnitSpecification = Unit.UnitSpecification; /** * Historical compatibility alias for `parseUnitSpec`. Wrap a call in a * `try { ... } catch (err) { ... }` to handle validation failures. * * @deprecated Prefer `parseUnitSpec` / `safeParseUnitSpec`. */ declare const UnitSpecificationSchema: (json: unknown) => UnitSpecification; type uriType = string; type unitKey = string; type Specs = Map; declare class UnitManager extends BaseManager { private unitKeywords; constructor(defaultSpecs?: Specs); protected getSpecName(spec: UnitSpecification): string; /** * Creates a clone of this class to be passed down to initializers and conversion functions * Links properties to the parent config. */ clone(): this; registerConversions(uri: uriType, spec: UnitSpecification): void; register(uri: uriType, spec: UnitSpecification | string): UnitSpecification; getSpecByKeyword(keyword: unitKey): UnitSpecification | undefined; getUriByKeyword(keyword: unitKey): string | undefined; convertTo(unit: NumberWithUnitSymbol, targetUri: uriType): NumberWithUnitSymbol; private isOneNumberRelative; private convertRelative; convertToCommonFormat(inputs: Array): Array; } interface LanguageOptions { MAX_ITERATIONS: number; } interface ConfigOptions { languageOptions?: LanguageOptions; colorManager?: ColorManager; unitManager?: UnitManager; functionsManager?: FunctionsManager; tokenManager?: TokenManager; } declare const DEFAULT_LANGUAGE_OPTIONS: LanguageOptions; declare class Config { languageOptions: LanguageOptions; colorManager: ColorManager; unitManager: UnitManager; functionsManager: FunctionsManager; tokenManager: TokenManager; private _inlineConstants; constructor(options?: ConfigOptions); getType(baseType: string, subType?: string): ISymbolType; isTypeDefined(baseType: string, subType?: string): boolean; get inlineConstants(): Map; clone(): Config; registerSchemas(schemas: Array<{ uri: string; schema: ColorSpecification | FunctionSpecification | TokenSpecification | ConstantsSpecification; }>): Config; } declare enum Operations { SUBTRACT = "-", ADD = "+", MULTIPLY = "*", DIVIDE = "/", POWER = "^", LOGIC_AND = "&&", LOGIC_OR = "||", LOGIC_NOT = "!" } declare enum SupportedFormats { PX = "px", EM = "em", REM = "rem", VW = "vw", VH = "vh", PT = "pt", IN = "in", CM = "cm", MM = "mm", DEG = "deg", PERCENTAGE = "%", S = "s", MS = "ms", CH = "ch" } declare enum ReservedKeyword { TRUE = "true", FALSE = "false", NULL = "null", UNDEFINED = "undefined", WHILE = "while", IF = "if", ELSE = "else", ELIF = "elif", RETURN = "return", VARIABLE = "variable", FOR = "for" } declare enum TokenType { REFERENCE = "REFERENCE", NUMBER = "NUMBER", OPERATION = "OPERATION", FORMAT = "FORMAT", LPAREN = "LPAREN", RPAREN = "RPAREN", EOF = "EOF", COMMA = "COMMA", HEX_COLOR = "HEX_COLOR", STRING = "STRING", EXPLICIT_STRING = "EXPLICIT_STRING", TEMPLATE_STRING = "TEMPLATE_STRING", ASSIGN = "ASSIGN", IS_EQ = "IS_EQ", IS_GT = "GT", IS_LT = "LT", IS_GT_EQ = "IS_GT_EQ", IS_LT_EQ = "IS_LT_EQ", IS_NOT_EQ = "IS_NOT_EQ", RESERVED_KEYWORD = "RESERVED_KEYWORD", SEMICOLON = "SEMICOLON", LOGIC_NOT = "LOGIC_NOT", COLON = "COLON", DOT = "DOT", LOGIC_AND = "LOGIC_AND", LOGIC_OR = "LOGIC_OR", LBLOCK = "LBLOCK", RBLOCK = "RBLOCK", PARTIAL_REFERENCE = "PARTIAL_REFERENCE", PARTIAL_STRING = "PARTIAL_STRING" } interface Token { type: TokenType; value: any; line: number; pos: number; endPos: number; } interface ASTNode { token?: Token; nodeType: string; } /** * Metadata attached to a symbol that is preserved across cloning operations. * This data is not accessible to the tokenscript language itself and is intended * for external use (e.g., storing token IDs for tracing). */ type SymbolMetadata = Record; interface ISymbolType { type: string; value: any; /** * Optional metadata attached to this symbol. * This is a reference that is preserved (not cloned) during deepCopy/cloneIfMutable operations. * It is not accessible to the tokenscript language and is intended for external use. */ metadata?: SymbolMetadata; cloneIfMutable(): ISymbolType; deepCopy(): ISymbolType; typeEquals(other: ISymbolType): boolean; equals(other: ISymbolType): boolean; validValue(value: any): boolean; toJSON?(): any; toString(): string; getTypeName(): string; toJs(options?: { recursive?: boolean; stringify?: boolean; }): any; hasMethod?(methodName: string, args: ISymbolType[]): boolean; callMethod?(methodName: string, args: ISymbolType[]): ISymbolType | null | undefined; hasAttribute?(attributeName: string): boolean; getAttribute?(attributeName: string): ISymbolType | null; setAttribute?(attributeName: string, value: ISymbolType, config?: Config): void; } /** Reserved keywords that introduce statements — only valid in script mode, not inline mode. */ declare const SCRIPT_ONLY_STATEMENT_KEYWORDS: ReadonlySet; declare const UNINTERPRETED_KEYWORDS: string[]; type ReferenceRecordValue = string | number | ISymbolType; type ReferenceRecord = Record>; export { type ASTNode as A, BaseSymbolType as B, ColorManager as C, DEFAULT_LANGUAGE_OPTIONS as D, getResultTypeName as E, type FunctionSpecification as F, jsValueToSymbolType as G, walkAST as H, type ISymbolType as I, type JsValue as J, ReferenceNode as K, type LanguageOptions as L, BinOpNode as M, NullSymbol as N, Operations as O, FunctionCallNode as P, ImplicitListNode as Q, type ReferenceRecord as R, SCRIPT_ONLY_STATEMENT_KEYWORDS as S, type Token as T, UNINTERPRETED_KEYWORDS as U, ListNode as V, NoOpNode as W, NumNode as X, StringNode as Y, UnaryOpNode as Z, BooleanSymbol as a, type ColorSpecification as b, ColorSpecificationSchema as c, ColorSymbol as d, Config as e, type ConfigOptions as f, type ConstantsSpecification as g, ConstantsSpecificationSchema as h, DictionarySymbol as i, FunctionSpecificationSchema as j, FunctionsManager as k, ListSymbol as l, NumberSymbol as m, NumberWithUnitSymbol as n, type ReferenceRecordValue as o, ReservedKeyword as p, StringSymbol as q, SupportedFormats as r, type SymbolMetadata as s, TokenSymbol as t, TokenType as u, UnitManager as v, type UnitSpecification as w, UnitSpecificationSchema as x, collectReferenceNodes as y, filterAST as z };