@tokens-studio/tokenscript-interpreter 0.36.3 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/dist/chunk-2EEKBDOX.js +5308 -0
  2. package/dist/chunk-2EEKBDOX.js.map +1 -0
  3. package/dist/chunk-2NMUBWBX.js +5861 -0
  4. package/dist/chunk-2NMUBWBX.js.map +1 -0
  5. package/dist/chunk-2OHE65GL.js +5779 -0
  6. package/dist/chunk-2OHE65GL.js.map +1 -0
  7. package/dist/chunk-2PZR6BQ6.js +5773 -0
  8. package/dist/chunk-2PZR6BQ6.js.map +1 -0
  9. package/dist/chunk-2QDDLPUW.js +5858 -0
  10. package/dist/chunk-2QDDLPUW.js.map +1 -0
  11. package/dist/chunk-4DUQBXYY.js +5762 -0
  12. package/dist/chunk-4DUQBXYY.js.map +1 -0
  13. package/dist/chunk-4SLJE4IW.js +5322 -0
  14. package/dist/chunk-4SLJE4IW.js.map +1 -0
  15. package/dist/chunk-6ABZOYUP.js +5802 -0
  16. package/dist/chunk-6ABZOYUP.js.map +1 -0
  17. package/dist/chunk-6HQZVWXZ.js +5341 -0
  18. package/dist/chunk-6HQZVWXZ.js.map +1 -0
  19. package/dist/chunk-6UY773C4.js +5292 -0
  20. package/dist/chunk-6UY773C4.js.map +1 -0
  21. package/dist/chunk-75Z55XEZ.js +5681 -0
  22. package/dist/chunk-75Z55XEZ.js.map +1 -0
  23. package/dist/chunk-7IWYKR22.js +5778 -0
  24. package/dist/chunk-7IWYKR22.js.map +1 -0
  25. package/dist/chunk-AVZUAMNS.js +5757 -0
  26. package/dist/chunk-AVZUAMNS.js.map +1 -0
  27. package/dist/chunk-BL7GZSRR.js +5724 -0
  28. package/dist/chunk-BL7GZSRR.js.map +1 -0
  29. package/dist/chunk-BMZ5NY7J.js +93 -0
  30. package/dist/chunk-BMZ5NY7J.js.map +1 -0
  31. package/dist/{chunk-AXH5N7KV.js → chunk-BNLQ6GCU.js} +2 -6
  32. package/dist/chunk-BNLQ6GCU.js.map +1 -0
  33. package/dist/chunk-BSJBGMCX.js +93 -0
  34. package/dist/{chunk-RI2BWY7D.js.map → chunk-BSJBGMCX.js.map} +1 -1
  35. package/dist/chunk-BUJRELXW.js +5342 -0
  36. package/dist/chunk-BUJRELXW.js.map +1 -0
  37. package/dist/chunk-DCOIGXSK.js +5763 -0
  38. package/dist/chunk-DCOIGXSK.js.map +1 -0
  39. package/dist/chunk-DZDZDYPO.js +5654 -0
  40. package/dist/chunk-DZDZDYPO.js.map +1 -0
  41. package/dist/{chunk-5S3H4SYX.js → chunk-GAE7SZLZ.js} +154 -9
  42. package/dist/chunk-GAE7SZLZ.js.map +1 -0
  43. package/dist/chunk-HFLLWRRV.js +5791 -0
  44. package/dist/chunk-HFLLWRRV.js.map +1 -0
  45. package/dist/{lib/chunk-ODVWXGOM.js → chunk-JL4UU4PY.js} +2 -8
  46. package/dist/chunk-JL4UU4PY.js.map +1 -0
  47. package/dist/{chunk-CKLFRLH7.js → chunk-JUGNHFDN.js} +220 -338
  48. package/dist/chunk-JUGNHFDN.js.map +1 -0
  49. package/dist/{chunk-RI2BWY7D.js → chunk-K2OUSWUX.js} +2 -3
  50. package/dist/chunk-K2OUSWUX.js.map +1 -0
  51. package/dist/chunk-KOLA6XR5.js +5770 -0
  52. package/dist/chunk-KOLA6XR5.js.map +1 -0
  53. package/dist/{chunk-3ZOUTFP5.js → chunk-L77CTMYP.js} +169 -296
  54. package/dist/chunk-L77CTMYP.js.map +1 -0
  55. package/dist/chunk-LIXBSHBJ.js +99 -0
  56. package/dist/chunk-LIXBSHBJ.js.map +1 -0
  57. package/dist/chunk-LM5SZQV5.js +5763 -0
  58. package/dist/chunk-LM5SZQV5.js.map +1 -0
  59. package/dist/chunk-M76AGXPG.js +5772 -0
  60. package/dist/chunk-M76AGXPG.js.map +1 -0
  61. package/dist/{chunk-QP7M6WUR.js → chunk-OV2GMYVM.js} +221 -341
  62. package/dist/chunk-OV2GMYVM.js.map +1 -0
  63. package/dist/{chunk-33CDF4L4.js → chunk-P4VLJQEI.js} +235 -838
  64. package/dist/chunk-P4VLJQEI.js.map +1 -0
  65. package/dist/chunk-QLSMLF5S.js +5302 -0
  66. package/dist/chunk-QLSMLF5S.js.map +1 -0
  67. package/dist/chunk-QYTZHMUN.js +5831 -0
  68. package/dist/chunk-QYTZHMUN.js.map +1 -0
  69. package/dist/chunk-SBM4WTQW.js +5771 -0
  70. package/dist/chunk-SBM4WTQW.js.map +1 -0
  71. package/dist/chunk-UAQCLV6Y.js +5816 -0
  72. package/dist/chunk-UAQCLV6Y.js.map +1 -0
  73. package/dist/chunk-YIZGWYGL.js +5300 -0
  74. package/dist/chunk-YIZGWYGL.js.map +1 -0
  75. package/dist/chunk-Z437BNC5.js +107 -0
  76. package/dist/chunk-Z437BNC5.js.map +1 -0
  77. package/dist/cli.js +182 -17
  78. package/dist/cli.js.map +1 -1
  79. package/dist/compliance-suite.js +3 -5
  80. package/dist/compliance-suite.js.map +1 -1
  81. package/dist/config-Bb9I9K-y.d.ts +1005 -0
  82. package/dist/config-Be-GTPYh.d.ts +976 -0
  83. package/dist/config-BkIqJNxv.d.ts +1009 -0
  84. package/dist/config-Cp5BqDfR.d.ts +731 -0
  85. package/dist/config-D36YRJGj.d.ts +1007 -0
  86. package/dist/{config-CFhN7-6U.d.ts → config-DB5rZBMx.d.ts} +109 -17
  87. package/dist/config-DQj8LHMT.d.ts +995 -0
  88. package/dist/{config-DtbN3iyg.d.ts → config-Mw_Iq324.d.ts} +5 -2
  89. package/dist/config-P6Ivo_zY.d.ts +997 -0
  90. package/dist/config-RCpZF46f.d.ts +960 -0
  91. package/dist/lib/{chunk-PXS4WZYB.cjs → chunk-EMRAAGPR.cjs} +102 -100
  92. package/dist/lib/chunk-EMRAAGPR.cjs.map +1 -0
  93. package/dist/lib/{chunk-XHA2RNU7.cjs → chunk-JQKYSUJJ.cjs} +728 -568
  94. package/dist/lib/chunk-JQKYSUJJ.cjs.map +1 -0
  95. package/dist/lib/{chunk-73YLAUUC.js → chunk-MD2DETZV.js} +5 -3
  96. package/dist/lib/chunk-MD2DETZV.js.map +1 -0
  97. package/dist/lib/chunk-SLITBMFB.js +114 -0
  98. package/dist/lib/chunk-SLITBMFB.js.map +1 -0
  99. package/dist/lib/{chunk-F5SBEZH2.js → chunk-VXZQQBEA.js} +175 -16
  100. package/dist/lib/chunk-VXZQQBEA.js.map +1 -0
  101. package/dist/lib/{chunk-LEYHQJTL.cjs → chunk-ZMMIYWFF.cjs} +11 -2
  102. package/dist/lib/chunk-ZMMIYWFF.cjs.map +1 -0
  103. package/dist/lib/index.cjs +99 -91
  104. package/dist/lib/index.d.cts +4 -4
  105. package/dist/lib/index.d.ts +4 -4
  106. package/dist/lib/index.js +3 -3
  107. package/dist/lib/{interpreter-6QwMkUqD.d.cts → interpreter-ByrEtz7T.d.ts} +54 -4
  108. package/dist/lib/{interpreter-v7WiwSP9.d.ts → interpreter-CG0Jw_k-.d.cts} +54 -4
  109. package/dist/lib/interpreter.cjs +81 -73
  110. package/dist/lib/interpreter.d.cts +7 -6
  111. package/dist/lib/interpreter.d.ts +7 -6
  112. package/dist/lib/interpreter.js +3 -3
  113. package/dist/lib/processor-node.cjs +12 -12
  114. package/dist/lib/processor-node.d.cts +3 -3
  115. package/dist/lib/processor-node.d.ts +3 -3
  116. package/dist/lib/processor-node.js +3 -3
  117. package/dist/lib/processor.cjs +17 -17
  118. package/dist/lib/processor.d.cts +4 -4
  119. package/dist/lib/processor.d.ts +4 -4
  120. package/dist/lib/processor.js +3 -3
  121. package/dist/lib/schema.cjs +5 -5
  122. package/dist/lib/schema.d.cts +1 -1
  123. package/dist/lib/schema.d.ts +1 -1
  124. package/dist/lib/schema.js +3 -3
  125. package/dist/lib/syntax-highlighting.cjs +15 -15
  126. package/dist/lib/syntax-highlighting.d.cts +1 -1
  127. package/dist/lib/syntax-highlighting.d.ts +1 -1
  128. package/dist/lib/syntax-highlighting.js +2 -2
  129. package/dist/lib/{types-BI0AZ4Ej.d.ts → types-BZAWM2oN.d.ts} +2 -2
  130. package/dist/lib/{types-cFwP43uv.d.cts → types-BhyJ6plH.d.cts} +2 -2
  131. package/dist/lib/{types-EB8V9c46.d.cts → types-DA9_CC7p.d.cts} +5 -2
  132. package/dist/lib/{types-EB8V9c46.d.ts → types-DA9_CC7p.d.ts} +5 -2
  133. package/dist/lib/types.cjs +10 -6
  134. package/dist/lib/types.d.cts +1 -1
  135. package/dist/lib/types.d.ts +1 -1
  136. package/dist/lib/types.js +1 -1
  137. package/dist/processor/index.d.ts +1 -1
  138. package/dist/processor/index.js +18 -2
  139. package/dist/processor/index.js.map +1 -1
  140. package/dist/repl.d.ts +15 -3
  141. package/dist/repl.js +6 -8
  142. package/dist/repl.js.map +1 -1
  143. package/dist/token-schemas.js +414 -0
  144. package/dist/types.d.ts +1 -1
  145. package/dist/types.js +1 -1
  146. package/package.json +1 -1
  147. package/dist/chunk-33CDF4L4.js.map +0 -1
  148. package/dist/chunk-3ZOUTFP5.js.map +0 -1
  149. package/dist/chunk-5S3H4SYX.js.map +0 -1
  150. package/dist/chunk-AXH5N7KV.js.map +0 -1
  151. package/dist/chunk-CKLFRLH7.js.map +0 -1
  152. package/dist/chunk-GJIOYGP6.js +0 -6446
  153. package/dist/chunk-GJIOYGP6.js.map +0 -1
  154. package/dist/chunk-HHCPY4WI.js +0 -6456
  155. package/dist/chunk-HHCPY4WI.js.map +0 -1
  156. package/dist/chunk-MXKGYBE4.js +0 -6457
  157. package/dist/chunk-MXKGYBE4.js.map +0 -1
  158. package/dist/chunk-NGG6MBER.js +0 -6452
  159. package/dist/chunk-NGG6MBER.js.map +0 -1
  160. package/dist/chunk-QP7M6WUR.js.map +0 -1
  161. package/dist/lib/chunk-73YLAUUC.js.map +0 -1
  162. package/dist/lib/chunk-F5SBEZH2.js.map +0 -1
  163. package/dist/lib/chunk-LEYHQJTL.cjs.map +0 -1
  164. package/dist/lib/chunk-ODVWXGOM.js.map +0 -1
  165. package/dist/lib/chunk-PXS4WZYB.cjs.map +0 -1
  166. package/dist/lib/chunk-XHA2RNU7.cjs.map +0 -1
@@ -0,0 +1,997 @@
1
+ declare enum Operations {
2
+ SUBTRACT = "-",
3
+ ADD = "+",
4
+ MULTIPLY = "*",
5
+ DIVIDE = "/",
6
+ POWER = "^",
7
+ LOGIC_AND = "&&",
8
+ LOGIC_OR = "||",
9
+ LOGIC_NOT = "!"
10
+ }
11
+ declare enum SupportedFormats {
12
+ PX = "px",
13
+ EM = "em",
14
+ REM = "rem",
15
+ VW = "vw",
16
+ VH = "vh",
17
+ PT = "pt",
18
+ IN = "in",
19
+ CM = "cm",
20
+ MM = "mm",
21
+ DEG = "deg",
22
+ PERCENTAGE = "%",
23
+ S = "s",
24
+ MS = "ms"
25
+ }
26
+ declare enum ReservedKeyword {
27
+ TRUE = "true",
28
+ FALSE = "false",
29
+ NULL = "null",
30
+ UNDEFINED = "undefined",
31
+ WHILE = "while",
32
+ IF = "if",
33
+ ELSE = "else",
34
+ ELIF = "elif",
35
+ RETURN = "return",
36
+ VARIABLE = "variable"
37
+ }
38
+ declare enum TokenType {
39
+ REFERENCE = "REFERENCE",
40
+ NUMBER = "NUMBER",
41
+ OPERATION = "OPERATION",
42
+ FORMAT = "FORMAT",
43
+ LPAREN = "LPAREN",
44
+ RPAREN = "RPAREN",
45
+ EOF = "EOF",
46
+ COMMA = "COMMA",
47
+ HEX_COLOR = "HEX_COLOR",
48
+ STRING = "STRING",
49
+ EXPLICIT_STRING = "EXPLICIT_STRING",
50
+ ASSIGN = "ASSIGN",
51
+ IS_EQ = "IS_EQ",
52
+ IS_GT = "GT",
53
+ IS_LT = "LT",
54
+ IS_GT_EQ = "IS_GT_EQ",
55
+ IS_LT_EQ = "IS_LT_EQ",
56
+ IS_NOT_EQ = "IS_NOT_EQ",
57
+ RESERVED_KEYWORD = "RESERVED_KEYWORD",
58
+ SEMICOLON = "SEMICOLON",
59
+ LOGIC_NOT = "LOGIC_NOT",
60
+ COLON = "COLON",
61
+ DOT = "DOT",
62
+ LOGIC_AND = "LOGIC_AND",
63
+ LOGIC_OR = "LOGIC_OR",
64
+ LBLOCK = "LBLOCK",
65
+ RBLOCK = "RBLOCK"
66
+ }
67
+ interface Token {
68
+ type: TokenType;
69
+ value: any;
70
+ line: number;
71
+ pos: number;
72
+ endPos: number;
73
+ }
74
+ interface ASTNode {
75
+ token?: Token;
76
+ nodeType: string;
77
+ }
78
+ /**
79
+ * Metadata attached to a symbol that is preserved across cloning operations.
80
+ * This data is not accessible to the tokenscript language itself and is intended
81
+ * for external use (e.g., storing token IDs for tracing).
82
+ */
83
+ type SymbolMetadata = Record<string, unknown>;
84
+ interface ISymbolType {
85
+ type: string;
86
+ value: any;
87
+ /**
88
+ * Optional metadata attached to this symbol.
89
+ * This is a reference that is preserved (not cloned) during deepCopy/cloneIfMutable operations.
90
+ * It is not accessible to the tokenscript language and is intended for external use.
91
+ */
92
+ metadata?: SymbolMetadata;
93
+ cloneIfMutable(): ISymbolType;
94
+ deepCopy(): ISymbolType;
95
+ typeEquals(other: ISymbolType): boolean;
96
+ equals(other: ISymbolType): boolean;
97
+ validValue(value: any): boolean;
98
+ toJSON?(): any;
99
+ toString(): string;
100
+ getTypeName(): string;
101
+ toJs(options?: {
102
+ recursive?: boolean;
103
+ stringify?: boolean;
104
+ }): any;
105
+ hasMethod?(methodName: string, args: ISymbolType[]): boolean;
106
+ callMethod?(methodName: string, args: ISymbolType[]): ISymbolType | null | undefined;
107
+ hasAttribute?(attributeName: string): boolean;
108
+ getAttribute?(attributeName: string): ISymbolType | null;
109
+ setAttribute?(attributeName: string, value: ISymbolType, config?: Config): void;
110
+ }
111
+ declare const UNINTERPRETED_KEYWORDS: string[];
112
+ type ReferenceRecordValue = string | number | ISymbolType;
113
+ type ReferenceRecord = Record<string, ReferenceRecordValue | Array<ReferenceRecordValue>>;
114
+
115
+ declare class IdentifierNode implements ASTNode {
116
+ token: Token;
117
+ nodeType: string;
118
+ name: string;
119
+ constructor(token: Token);
120
+ }
121
+ declare class ReassignNode implements ASTNode {
122
+ identifier: IdentifierNode | IdentifierNode[];
123
+ value: ASTNode;
124
+ token?: Token | undefined;
125
+ nodeType: string;
126
+ constructor(identifier: IdentifierNode | IdentifierNode[], value: ASTNode, token?: Token | undefined);
127
+ baseIdentifier(): IdentifierNode;
128
+ isAttributeAssignment(): boolean;
129
+ identifierToString(): string;
130
+ attributesChain(): IdentifierNode[];
131
+ attributesStringChain(): string[];
132
+ }
133
+
134
+ interface ToJsOptions {
135
+ /** Whether to recursively convert nested values (default: true) */
136
+ recursive?: boolean;
137
+ /** Whether to use toString() for structured types (default: false) */
138
+ stringify?: boolean;
139
+ }
140
+ type SupportedMethods = Record<string, MethodDefinitionDef>;
141
+ interface MethodArgumentDef {
142
+ name: string;
143
+ type: any;
144
+ optional?: boolean;
145
+ }
146
+ interface MethodDefinitionDef {
147
+ name?: string;
148
+ function: (...args: any[]) => ISymbolType | null | undefined;
149
+ args: MethodArgumentDef[];
150
+ returnType: any;
151
+ }
152
+ declare abstract class BaseSymbolType implements ISymbolType {
153
+ abstract type: string;
154
+ value: any | null;
155
+ config?: Config;
156
+ static _SUPPORTED_METHODS?: SupportedMethods;
157
+ constructor(value: any, config?: Config);
158
+ abstract validValue(value: any): boolean;
159
+ /**
160
+ * Forces creating a deepCopy of provided symbol no matter if it's immutable or not.
161
+ */
162
+ abstract deepCopy(): ISymbolType;
163
+ /**
164
+ * Returns a copy of the symbol if it's mutable, otherwise returns the same instance.
165
+ *
166
+ * This method is used to prevent reference sharing issues when storing symbols in
167
+ * containers like lists and dictionaries. Immutable symbols (Number, String, Boolean,
168
+ * NumberWithUnit, Null, hex ColorSymbol) can safely share references since they
169
+ * cannot be modified after creation. Mutable symbols (List, Dictionary, dynamic
170
+ * ColorSymbol) need to be deep copied to prevent unintended mutations.
171
+ *
172
+ * @returns For immutable symbols: returns `this` (same reference)
173
+ * For mutable symbols: returns `this.deepCopy()` (new instance)
174
+ */
175
+ abstract cloneIfMutable(): ISymbolType;
176
+ abstract toJs(options?: ToJsOptions): JsValue;
177
+ toString(): string;
178
+ getTypeName(): string;
179
+ typeEquals(other: ISymbolType): boolean;
180
+ equals(other: ISymbolType): boolean;
181
+ hasMethod?(methodName: string, args: ISymbolType[]): boolean;
182
+ callMethod?(methodName: string, args: ISymbolType[]): ISymbolType | null | undefined;
183
+ hasAttribute?(_attributeName: string): boolean;
184
+ getAttribute?(attributeName: string): ISymbolType | null;
185
+ setAttribute?(attributeName: string, _value: ISymbolType): void;
186
+ }
187
+ type NumberValue = number | null;
188
+ declare class NumberSymbol extends BaseSymbolType {
189
+ type: string;
190
+ static readonly type = "Number";
191
+ static _SUPPORTED_METHODS: {
192
+ to_string: {
193
+ name: string;
194
+ function: (this: NumberSymbol, radix?: NumberSymbol) => StringSymbol;
195
+ args: {
196
+ name: string;
197
+ type: string;
198
+ optional: boolean;
199
+ }[];
200
+ returnType: string;
201
+ };
202
+ };
203
+ value: NumberValue;
204
+ constructor(value: number | NumberSymbol | NumberWithUnitSymbol | null, config?: Config);
205
+ validValue(val: any): boolean;
206
+ expectSafeValue(val: any): asserts val is number;
207
+ toString(): string;
208
+ deepCopy(): NumberSymbol;
209
+ cloneIfMutable(): NumberSymbol;
210
+ static empty(): NumberSymbol;
211
+ hasAttribute(attributeName: string): boolean;
212
+ getAttribute(attributeName: string): ISymbolType | null;
213
+ toStringSymbol(radix?: NumberSymbol): StringSymbol;
214
+ toJs(_options?: ToJsOptions): NumberValue;
215
+ }
216
+ type StringValue = string | null;
217
+ declare class StringSymbol extends BaseSymbolType {
218
+ type: string;
219
+ static readonly type = "String";
220
+ static _SUPPORTED_METHODS: {
221
+ upper: {
222
+ function: (this: StringSymbol) => StringSymbol;
223
+ args: never[];
224
+ returnType: string;
225
+ };
226
+ lower: {
227
+ function: (this: StringSymbol) => StringSymbol;
228
+ args: never[];
229
+ returnType: string;
230
+ };
231
+ length: {
232
+ function: (this: StringSymbol) => NumberSymbol;
233
+ args: never[];
234
+ returnType: string;
235
+ };
236
+ concat: {
237
+ function: (this: StringSymbol, other: StringSymbol) => StringSymbol;
238
+ args: {
239
+ name: string;
240
+ type: string;
241
+ }[];
242
+ returnType: string;
243
+ };
244
+ split: {
245
+ function: (this: StringSymbol, delimiter?: StringSymbol) => ListSymbol;
246
+ args: {
247
+ name: string;
248
+ type: string;
249
+ optional: boolean;
250
+ }[];
251
+ returnType: string;
252
+ };
253
+ };
254
+ value: StringValue;
255
+ constructor(value: string | StringSymbol | null, config?: Config);
256
+ validValue(val: any): boolean;
257
+ expectSafeValue(val: any): asserts val is string;
258
+ upper(): StringSymbol;
259
+ deepCopy(): StringSymbol;
260
+ cloneIfMutable(): StringSymbol;
261
+ static empty(): StringSymbol;
262
+ lower(): StringSymbol;
263
+ length(): NumberSymbol;
264
+ concat(other: StringSymbol): StringSymbol;
265
+ split(delimiter?: StringSymbol): ListSymbol;
266
+ toJs(_options?: ToJsOptions): StringValue;
267
+ }
268
+ declare class ListSymbol extends BaseSymbolType {
269
+ type: string;
270
+ static readonly type = "List";
271
+ static _SUPPORTED_METHODS: {
272
+ append: {
273
+ function: (this: ListSymbol, item: ISymbolType) => ListSymbol;
274
+ args: {
275
+ name: string;
276
+ type: string;
277
+ }[];
278
+ returnType: string;
279
+ };
280
+ extend: {
281
+ function: (this: ListSymbol, ...items: ISymbolType[]) => ListSymbol;
282
+ args: never[];
283
+ returnType: string;
284
+ };
285
+ insert: {
286
+ function: (this: ListSymbol, index: NumberSymbol, item: ISymbolType) => ListSymbol;
287
+ args: {
288
+ name: string;
289
+ type: string;
290
+ }[];
291
+ returnType: string;
292
+ };
293
+ delete: {
294
+ function: (this: ListSymbol, index: NumberSymbol) => ListSymbol;
295
+ args: {
296
+ name: string;
297
+ type: string;
298
+ }[];
299
+ returnType: string;
300
+ };
301
+ length: {
302
+ function: (this: ListSymbol) => NumberSymbol;
303
+ args: never[];
304
+ returnType: string;
305
+ };
306
+ index: {
307
+ function: (this: ListSymbol, item: ISymbolType) => NumberSymbol;
308
+ args: {
309
+ name: string;
310
+ type: string;
311
+ }[];
312
+ returnType: string;
313
+ };
314
+ get: {
315
+ function: (this: ListSymbol, index: NumberSymbol) => ISymbolType;
316
+ args: {
317
+ name: string;
318
+ type: string;
319
+ }[];
320
+ returnType: string;
321
+ };
322
+ update: {
323
+ function: (this: ListSymbol, index: NumberSymbol, item: ISymbolType) => ListSymbol;
324
+ args: {
325
+ name: string;
326
+ type: string;
327
+ }[];
328
+ returnType: string;
329
+ };
330
+ join: {
331
+ function: (this: ListSymbol, separator?: StringSymbol) => StringSymbol;
332
+ args: {
333
+ name: string;
334
+ type: string;
335
+ optional: boolean;
336
+ }[];
337
+ returnType: string;
338
+ };
339
+ };
340
+ value: ISymbolType[];
341
+ isImplicit: boolean;
342
+ constructor(elements: ISymbolType[] | null, isImplicit?: boolean, config?: Config);
343
+ validValue(val: any): boolean;
344
+ toString(): string;
345
+ append(item: ISymbolType): ListSymbol;
346
+ extend(...items: ISymbolType[]): ListSymbol;
347
+ insert(indexSymbol: NumberSymbol, item: ISymbolType): ListSymbol;
348
+ delete(indexSymbol: NumberSymbol): ListSymbol;
349
+ length(): NumberSymbol;
350
+ index(item: ISymbolType): NumberSymbol;
351
+ get(indexSymbol: NumberSymbol): ISymbolType;
352
+ update(indexSymbol: NumberSymbol, item: ISymbolType): ListSymbol;
353
+ join(separator?: StringSymbol): StringSymbol;
354
+ deepCopy(): ListSymbol;
355
+ cloneIfMutable(): ListSymbol;
356
+ static empty(): ListSymbol;
357
+ getTypeName(): string;
358
+ toJs(options?: ToJsOptions): JsValue[];
359
+ }
360
+ type NumberWithUnitValue = number | null;
361
+ declare class NumberWithUnitSymbol extends BaseSymbolType {
362
+ type: string;
363
+ static readonly type = "NumberWithUnit";
364
+ static _SUPPORTED_METHODS: {
365
+ to_string: {
366
+ name: string;
367
+ function: (this: NumberWithUnitSymbol) => StringSymbol;
368
+ args: {
369
+ name: string;
370
+ type: string;
371
+ optional: boolean;
372
+ }[];
373
+ returnType: string;
374
+ };
375
+ to_number: {
376
+ function: (this: NumberWithUnitSymbol) => NumberSymbol;
377
+ args: never[];
378
+ returnType: string;
379
+ };
380
+ };
381
+ value: NumberWithUnitValue;
382
+ unit: SupportedFormats;
383
+ constructor(value: number | NumberSymbol | null, unit: SupportedFormats | string, config?: Config);
384
+ validValue(val: any): boolean;
385
+ static fromRecord(record: {
386
+ value: number | string;
387
+ unit: string;
388
+ type?: string;
389
+ }, config?: Config): NumberWithUnitSymbol | undefined;
390
+ toString(): string;
391
+ expectSafeValue(val: any): asserts val is number;
392
+ toStringSymbol(): StringSymbol;
393
+ to_number(): NumberSymbol;
394
+ equals(other: ISymbolType): boolean;
395
+ deepCopy(): NumberWithUnitSymbol;
396
+ cloneIfMutable(): NumberWithUnitSymbol;
397
+ static empty(): NumberWithUnitSymbol;
398
+ hasAttribute(attributeName: string): boolean;
399
+ getAttribute(attributeName: string): ISymbolType | null;
400
+ getTypeName(): string;
401
+ toJs(options?: ToJsOptions): string | {
402
+ value: number | null;
403
+ unit: string;
404
+ };
405
+ }
406
+ type TokenValue = Map<string, ISymbolType> | ISymbolType[];
407
+ declare class TokenSymbol extends BaseSymbolType {
408
+ type: string;
409
+ static readonly type = "Token";
410
+ static _SUPPORTED_METHODS: {
411
+ get: {
412
+ function: (this: TokenSymbol, keyOrIndex: StringSymbol | NumberSymbol) => ISymbolType;
413
+ args: {
414
+ name: string;
415
+ type: string;
416
+ optional: boolean;
417
+ }[];
418
+ returnType: string;
419
+ };
420
+ set: {
421
+ function: (this: TokenSymbol, key: StringSymbol, value: ISymbolType) => TokenSymbol;
422
+ args: {
423
+ name: string;
424
+ type: string;
425
+ optional: boolean;
426
+ }[];
427
+ returnType: string;
428
+ };
429
+ keys: {
430
+ function: (this: TokenSymbol) => ListSymbol;
431
+ args: never[];
432
+ returnType: string;
433
+ };
434
+ values: {
435
+ function: (this: TokenSymbol) => ListSymbol;
436
+ args: never[];
437
+ returnType: string;
438
+ };
439
+ length: {
440
+ function: (this: TokenSymbol) => NumberSymbol;
441
+ args: never[];
442
+ returnType: string;
443
+ };
444
+ append: {
445
+ function: (this: TokenSymbol, item: ISymbolType) => TokenSymbol;
446
+ args: {
447
+ name: string;
448
+ type: string;
449
+ }[];
450
+ returnType: string;
451
+ };
452
+ extend: {
453
+ function: (this: TokenSymbol, ...items: ISymbolType[]) => TokenSymbol;
454
+ args: never[];
455
+ returnType: string;
456
+ };
457
+ insert: {
458
+ function: (this: TokenSymbol, index: NumberSymbol, item: ISymbolType) => TokenSymbol;
459
+ args: {
460
+ name: string;
461
+ type: string;
462
+ }[];
463
+ returnType: string;
464
+ };
465
+ delete: {
466
+ function: (this: TokenSymbol, index: NumberSymbol) => TokenSymbol;
467
+ args: {
468
+ name: string;
469
+ type: string;
470
+ }[];
471
+ returnType: string;
472
+ };
473
+ index: {
474
+ function: (this: TokenSymbol, item: ISymbolType) => NumberSymbol;
475
+ args: {
476
+ name: string;
477
+ type: string;
478
+ }[];
479
+ returnType: string;
480
+ };
481
+ update: {
482
+ function: (this: TokenSymbol, index: NumberSymbol, item: ISymbolType) => TokenSymbol;
483
+ args: {
484
+ name: string;
485
+ type: string;
486
+ }[];
487
+ returnType: string;
488
+ };
489
+ join: {
490
+ function: (this: TokenSymbol, separator?: StringSymbol) => StringSymbol;
491
+ args: {
492
+ name: string;
493
+ type: string;
494
+ optional: boolean;
495
+ }[];
496
+ returnType: string;
497
+ };
498
+ };
499
+ subType: string;
500
+ value: TokenValue;
501
+ /**
502
+ * Optional metadata attached to this token.
503
+ * This is a reference that is preserved (not cloned) during deepCopy/cloneIfMutable operations.
504
+ * It is not accessible to the tokenscript language and is intended for external use
505
+ * (e.g., storing token IDs for tracing).
506
+ */
507
+ metadata?: SymbolMetadata;
508
+ constructor(subType: string, value: TokenValue | Record<string, ISymbolType> | TokenSymbol | null, config?: Config, metadata?: SymbolMetadata);
509
+ validValue(val: any): boolean;
510
+ toString(): string;
511
+ get(keyOrIndex: StringSymbol | NumberSymbol | string | number): ISymbolType;
512
+ set(key: StringSymbol, value: ISymbolType): TokenSymbol;
513
+ keys(): ListSymbol;
514
+ values(): ListSymbol;
515
+ length(): NumberSymbol;
516
+ append(item: ISymbolType): TokenSymbol;
517
+ extend(...items: ISymbolType[]): TokenSymbol;
518
+ insert(indexSymbol: NumberSymbol, item: ISymbolType): TokenSymbol;
519
+ delete(indexSymbol: NumberSymbol): TokenSymbol;
520
+ index(item: ISymbolType): NumberSymbol;
521
+ update(indexSymbol: NumberSymbol, item: ISymbolType): TokenSymbol;
522
+ join(separator?: StringSymbol): StringSymbol;
523
+ deepCopy(): TokenSymbol;
524
+ cloneIfMutable(): TokenSymbol;
525
+ static empty(): TokenSymbol;
526
+ hasAttribute(attributeName: string): boolean;
527
+ getAttribute(attributeName: string): ISymbolType | null;
528
+ getTypeName(): string;
529
+ toJs(options?: ToJsOptions): JsValue[] | Record<string, JsValue>;
530
+ }
531
+ type dynamicColorValue = Record<string, ISymbolType>;
532
+ type ColorValue = string | dynamicColorValue | null;
533
+ declare class ColorSymbol extends BaseSymbolType {
534
+ type: string;
535
+ static readonly type = "Color";
536
+ static _SUPPORTED_METHODS: {
537
+ to_string: {
538
+ name: string;
539
+ function: (this: ColorSymbol) => StringSymbol;
540
+ args: never[];
541
+ returnType: string;
542
+ };
543
+ };
544
+ subType: string | null;
545
+ value: ColorValue;
546
+ alpha: number | null;
547
+ static empty(): ColorSymbol;
548
+ constructor(value: ColorValue, subType?: string, alpha?: number | null, config?: Config);
549
+ toStringSymbol(): StringSymbol;
550
+ toString(): string;
551
+ to(targetType: string): ColorSymbol;
552
+ typeEquals(other: ISymbolType): boolean;
553
+ isHex(): boolean;
554
+ validValue(val: any): boolean;
555
+ equals(other: ISymbolType): boolean;
556
+ deepCopy(): ColorSymbol;
557
+ cloneIfMutable(): ColorSymbol;
558
+ hasAttribute(attributeName: string): boolean;
559
+ getAttribute(attributeName: string): ISymbolType | null;
560
+ hasMethod(methodName: string, args: ISymbolType[]): boolean;
561
+ callMethod(methodName: string, args: ISymbolType[]): ISymbolType | null | undefined;
562
+ getTypeName(): string;
563
+ toJs(options?: ToJsOptions): string | Record<string, JsValue>;
564
+ }
565
+ /**
566
+ * Represents a JavaScript value that can be produced from a TokenScript symbol.
567
+ * This includes primitives, arrays, and plain objects (recursively).
568
+ */
569
+ type JsValue = string | number | boolean | null | JsValue[] | {
570
+ [key: string]: JsValue;
571
+ };
572
+
573
+ /**
574
+ * Utilities for working with TokenScript schema URIs
575
+ *
576
+ * Handles URI construction, parsing, and manipulation for the TokenScript schema registry.
577
+ */
578
+ type SemanticVersion = {
579
+ major: number;
580
+ } | {
581
+ major: number;
582
+ minor: number;
583
+ } | {
584
+ major: number;
585
+ minor: number;
586
+ patch: number;
587
+ };
588
+
589
+ type uri = string;
590
+ type specType = string;
591
+ /**
592
+ * Base manager class that provides common functionality for managing specifications,
593
+ * conversions, and BFS-based conversion path resolution.
594
+ */
595
+ declare abstract class BaseManager<TSpec, TInput, TOutput> {
596
+ protected specs: Map<uri, TSpec>;
597
+ protected specTypes: Map<uri, specType>;
598
+ protected conversions: Map<uri, Map<uri, (input: TInput) => TOutput>>;
599
+ protected parentConfig?: Config;
600
+ protected removeVersionFromUri(uri: uri): uri;
601
+ /**
602
+ * Check if two URIs point to the same schema (ignoring version)
603
+ */
604
+ protected isSameSchemaUri(uri1: uri, uri2: uri): boolean;
605
+ /**
606
+ * Parse semantic version from URI
607
+ * Example: "/api/v1/schema/srgb-color/0.0.1/" -> { major: 0, minor: 0, patch: 1 }
608
+ */
609
+ protected parseSemverFromUri(uri: uri): SemanticVersion | null;
610
+ /**
611
+ * Get base URI without version
612
+ * Example: "/api/v1/schema/srgb-color/0.0.1/" -> "/api/v1/schema/srgb-color/"
613
+ */
614
+ protected getBaseUri(uri: uri): uri;
615
+ /**
616
+ * Generate version resolution candidates from most specific to least specific
617
+ * Example: "0.0.1" -> ["0.0.1", "0.0", "0", "latest"]
618
+ */
619
+ protected generateVersionCandidates(uri: uri): uri[];
620
+ /**
621
+ * Find the latest (highest) semantic version for a URI
622
+ */
623
+ protected findLatestVersion(uri: uri): uri | null;
624
+ /**
625
+ * Resolve URI by trying version candidates from most specific to least specific
626
+ */
627
+ protected resolveVersionUri(uri: uri): uri | null;
628
+ /**
629
+ * Find a conversion path from source to target format using BFS with version resolution
630
+ */
631
+ protected findConversionPath(sourceUri: uri, targetUri: uri): uri[];
632
+ /**
633
+ * Check if a conversion path exists between source and target URIs with version resolution
634
+ */
635
+ hasConversion(sourceUri: uri, targetUri: uri): boolean;
636
+ /**
637
+ * Get a specification by its URI with version resolution
638
+ */
639
+ getSpec(uri: uri): TSpec | undefined;
640
+ /**
641
+ * Convert input through a chain of conversions to reach the target URI with version resolution
642
+ */
643
+ protected convertThroughPath(input: TInput, sourceUri: uri, targetUri: uri): TOutput;
644
+ /**
645
+ * Register a conversion function between two URIs
646
+ */
647
+ protected registerConversionFunction(sourceUri: uri, targetUri: uri, conversionFn: (input: TInput) => TOutput): void;
648
+ abstract register(uri: uri, spec: TSpec | specType): TSpec;
649
+ protected abstract getSpecName(spec: TSpec): string;
650
+ /**
651
+ * Abstract method for creating a clone of the manager
652
+ */
653
+ abstract clone(): this;
654
+ /**
655
+ * Set the parent config reference
656
+ */
657
+ setParentConfig(config: Config): void;
658
+ /**
659
+ * Get the parent config reference
660
+ */
661
+ getParentConfig(): Config | undefined;
662
+ /**
663
+ * Creates interpreter configuration with full context for conversion functions and initializers.
664
+ * Uses parent config if available to provide access to all managers and registrations.
665
+ */
666
+ protected createInterpreterConfig(references: Record<string, any>): {
667
+ references: Record<string, any>;
668
+ config?: Config;
669
+ };
670
+ }
671
+
672
+ interface SpecProperty$1 {
673
+ type: "number" | "string" | "color";
674
+ }
675
+ interface SpecSchemaType$1 {
676
+ type: "object";
677
+ properties: Record<string, SpecProperty$1>;
678
+ required?: string[];
679
+ order?: string[];
680
+ additionalProperties?: boolean;
681
+ }
682
+ interface ColorSpecification {
683
+ name: string;
684
+ type: "color";
685
+ description?: string;
686
+ schema?: SpecSchemaType$1;
687
+ initializers: Array<{
688
+ title?: string;
689
+ keyword: string;
690
+ description?: string;
691
+ script: {
692
+ type: string;
693
+ script: string;
694
+ };
695
+ }>;
696
+ conversions: Array<{
697
+ source: string;
698
+ target: string;
699
+ description?: string;
700
+ lossless: boolean;
701
+ script: {
702
+ type: string;
703
+ script: string;
704
+ };
705
+ }>;
706
+ }
707
+
708
+ type uriType$2 = string;
709
+ type Specs$1 = Map<uriType$2, ColorSpecification>;
710
+ interface FormatColorOptions {
711
+ decimalPlaces?: number;
712
+ removeTrailingZeros?: boolean;
713
+ }
714
+ declare class ColorManager extends BaseManager<ColorSpecification, ColorSymbol, ColorSymbol> {
715
+ private initializers;
716
+ constructor(defaultSpecs?: Specs$1);
717
+ protected getSpecName(spec: ColorSpecification): string;
718
+ /**
719
+ * Creates a clone of this class to be passed down to initializers and conversion functions
720
+ * Links properties to the parent config.
721
+ */
722
+ clone(): this;
723
+ registerRootInitializers(_uri: uriType$2, spec: ColorSpecification): void;
724
+ registerConversions(uri: uriType$2, spec: ColorSpecification): void;
725
+ register(uri: uriType$2, spec: ColorSpecification | string): ColorSpecification;
726
+ getSpecByType(type: string): ColorSpecification | undefined;
727
+ getSpecFromColor(color: ColorSymbol): ColorSpecification | undefined;
728
+ hasInitializer(keyword: string): boolean;
729
+ executeInitializer(keyword: string, args: Array<ISymbolType>): ColorSymbol;
730
+ hasConversionByType(sourceType: string, targetType: string): boolean;
731
+ convertTo(color: ColorSymbol, targetUri: string): ColorSymbol;
732
+ convertToByType(color: ColorSymbol, targetType: string): ColorSymbol;
733
+ setAttribute(color: ColorSymbol, node: ReassignNode, attributeValue: ISymbolType): ColorSymbol;
734
+ /**
735
+ * Formats a number value, rounding to specified decimal places and optionally removing trailing zeros.
736
+ *
737
+ * @param value - The numeric value to format
738
+ * @param decimalPlaces - Number of decimal places to round to
739
+ * @param removeTrailingZeros - Whether to remove trailing zeros
740
+ * @returns Formatted number string
741
+ */
742
+ private formatNumber;
743
+ /**
744
+ * Formats a ColorSymbol as a string representation using the appropriate schema-defined format.
745
+ *
746
+ * For hex colors (string values), returns the hex string as-is.
747
+ * For dynamic colors (object values), uses the schema's `order` property to determine
748
+ * parameter order and formats as a function call (e.g., "hsl(0, 100, 50.0)").
749
+ * If alpha is set and less than 1, it is included as the fourth parameter.
750
+ *
751
+ * @param color - The ColorSymbol to format
752
+ * @param opts - Formatting options for numeric values
753
+ * @returns Formatted string representation of the color, or empty string if formatting fails
754
+ *
755
+ * @example
756
+ * ```typescript
757
+ * // Hex color
758
+ * const hexColor = new ColorSymbol("#ff0000", "Hex");
759
+ * manager.formatColorMethod(hexColor); // "#ff0000"
760
+ *
761
+ * // HSL color with schema order ["h", "s", "l"]
762
+ * const hslColor = new ColorSymbol({ h: 0, s: 100, l: 50.123456 }, "HSL");
763
+ * manager.formatColorMethod(hslColor); // "hsl(0, 100, 50.12)"
764
+ *
765
+ * // RGB color with alpha
766
+ * const rgbColor = new ColorSymbol({ r: 255, g: 0, b: 0 }, "RGB", undefined, 0.5);
767
+ * manager.formatColorMethod(rgbColor); // "rgb(255, 0, 0, 0.5)"
768
+ * ```
769
+ */
770
+ formatColorMethod(color: ColorSymbol, opts?: FormatColorOptions): string;
771
+ }
772
+
773
+ interface FunctionSpecification {
774
+ name: string;
775
+ type: "function";
776
+ input?: {
777
+ type: "object";
778
+ properties?: Record<string, unknown>;
779
+ };
780
+ script: {
781
+ type: string;
782
+ script: string;
783
+ };
784
+ keyword: string;
785
+ description?: string;
786
+ requirements?: string[];
787
+ }
788
+
789
+ type functionName = string;
790
+ type FunctionImpl = (...args: ISymbolType[]) => ISymbolType;
791
+ declare class FunctionsManager extends BaseManager<FunctionSpecification, ISymbolType[], ISymbolType> {
792
+ private functionMap;
793
+ constructor();
794
+ protected getSpecName(spec: FunctionSpecification): string;
795
+ clone(): this;
796
+ register(name: functionName, spec: FunctionSpecification | string): FunctionSpecification;
797
+ private setupBuiltinFunctions;
798
+ private registerFunction;
799
+ private registerDynamicFunction;
800
+ getFunction(name: string): FunctionImpl | undefined;
801
+ hasFunction(name: string): boolean;
802
+ getFunctionNames(): string[];
803
+ }
804
+
805
+ interface SpecProperty {
806
+ type: "number" | "string" | "token" | "object" | "list";
807
+ url?: string;
808
+ properties?: Record<string, SpecProperty>;
809
+ validations?: Record<string, string>;
810
+ items?: SpecItemsType;
811
+ }
812
+ interface SpecItemsType {
813
+ type: "object" | "token";
814
+ url?: string;
815
+ properties?: Record<string, SpecProperty>;
816
+ }
817
+ interface SpecSchemaType {
818
+ type: "object" | "number" | "string" | "list";
819
+ properties?: Record<string, SpecProperty>;
820
+ validations?: Record<string, string>;
821
+ required?: string[];
822
+ order?: string[];
823
+ additionalProperties?: boolean;
824
+ items?: SpecItemsType;
825
+ }
826
+ interface TokenSpecification {
827
+ name: string;
828
+ type: "token";
829
+ description?: string;
830
+ url?: string;
831
+ schema?: SpecSchemaType;
832
+ /** TokenScript validation script. Receives {input} and should return true or error string. Can be a string (direct script) or object with type and script (built schema). */
833
+ validation?: string | {
834
+ type: string;
835
+ script: string;
836
+ };
837
+ }
838
+
839
+ type uriType$1 = string;
840
+ /**
841
+ * Result of validating a token value.
842
+ * For nested validation failures, path indicates where the error occurred.
843
+ */
844
+ interface ValidationResult {
845
+ valid: boolean;
846
+ error?: string;
847
+ tokenType?: string;
848
+ path?: (string | number)[];
849
+ }
850
+ declare class TokenManager extends BaseManager<TokenSpecification, TokenSymbol, TokenSymbol> {
851
+ /**
852
+ * TokenScript validation scripts by token type.
853
+ * The script receives {input} as the value to validate.
854
+ * Should return true if valid, or a string error code if invalid.
855
+ */
856
+ private validationScripts;
857
+ /**
858
+ * Cached parsed ASTs for validation scripts.
859
+ * Avoids re-parsing the same script on every validation call.
860
+ */
861
+ private validationAstCache;
862
+ /**
863
+ * Cached Interpreter instances for validation scripts.
864
+ * Reusing interpreters avoids recreating Config, SymbolTable, etc.
865
+ */
866
+ private validationInterpreterCache;
867
+ protected getSpecName(spec: TokenSpecification): string;
868
+ getSpecByType(type: string): TokenSpecification | undefined;
869
+ clone(): this;
870
+ register(uri: uriType$1, spec: TokenSpecification | string): TokenSpecification;
871
+ /**
872
+ * Register a TokenScript validation script for a token type.
873
+ * The script receives {input} as the value to validate.
874
+ * Accepts either a string (direct script) or an object with type and script properties (built schema).
875
+ */
876
+ registerValidation(tokenType: string, validation: string | {
877
+ type: string;
878
+ script: string;
879
+ }): void;
880
+ /**
881
+ * Get validation script for a token type.
882
+ */
883
+ getValidation(tokenType: string): string | undefined;
884
+ /**
885
+ * Get possible error codes from validation scripts by walking the AST.
886
+ * Finds all return statements that return string literals (error codes).
887
+ *
888
+ * @param tokenType - Optional token type to get errors for. If omitted, returns all error types.
889
+ * @returns Array of error code strings
890
+ */
891
+ validationErrorTypes(tokenType?: string): string[];
892
+ /**
893
+ * Extract error codes from a validation script's AST.
894
+ * Walks the tree and returns string values from return statements.
895
+ */
896
+ private extractErrorTypesFromAST;
897
+ /**
898
+ * Validate a token value against its type using TokenScript.
899
+ * Automatically performs deep validation for nested token properties.
900
+ * Returns an array of validation results (empty or single valid result if all pass).
901
+ *
902
+ * @param tokenType - The token type name (e.g., "typography", "color")
903
+ * @param value - The symbol value to validate
904
+ * @param visitedUrls - Set of URLs already visited (for circular reference detection)
905
+ * @param basePath - Path prefix for nested validation errors
906
+ * @param depth - Current nesting depth (for max depth protection)
907
+ */
908
+ validate(tokenType: string, value: ISymbolType, visitedUrls?: Set<string>, basePath?: (string | number)[], depth?: number): ValidationResult[];
909
+ /**
910
+ * Validate items in a list against an items schema.
911
+ * Each item is validated and errors include the index in the path.
912
+ */
913
+ private validateListItems;
914
+ /**
915
+ * Validate properties of an object against a properties schema.
916
+ */
917
+ private validateObjectProperties;
918
+ /**
919
+ * Run the validation script for a token type.
920
+ * Internal method used by validate().
921
+ * Uses cached Interpreter when available to avoid recreation overhead.
922
+ */
923
+ private runValidationScript;
924
+ /**
925
+ * Extract a Map from various symbol types that can contain key-value pairs.
926
+ */
927
+ private getValueMap;
928
+ }
929
+
930
+ interface ScriptBlock {
931
+ type?: string;
932
+ script: string;
933
+ }
934
+ interface Conversion {
935
+ source: string;
936
+ target: string;
937
+ script: ScriptBlock;
938
+ description?: string;
939
+ }
940
+ interface UnitSpecification {
941
+ name: string;
942
+ type: "absolute" | "relative";
943
+ keyword: string;
944
+ description?: string;
945
+ conversions?: Conversion[];
946
+ to_absolute?: ScriptBlock;
947
+ }
948
+
949
+ type uriType = string;
950
+ type unitKey = string;
951
+ type Specs = Map<uriType, UnitSpecification>;
952
+ declare class UnitManager extends BaseManager<UnitSpecification, NumberWithUnitSymbol, NumberWithUnitSymbol> {
953
+ private unitKeywords;
954
+ constructor(defaultSpecs?: Specs);
955
+ protected getSpecName(spec: UnitSpecification): string;
956
+ /**
957
+ * Creates a clone of this class to be passed down to initializers and conversion functions
958
+ * Links properties to the parent config.
959
+ */
960
+ clone(): this;
961
+ registerConversions(uri: uriType, spec: UnitSpecification): void;
962
+ register(uri: uriType, spec: UnitSpecification | string): UnitSpecification;
963
+ getSpecByKeyword(keyword: unitKey): UnitSpecification | undefined;
964
+ getUriByKeyword(keyword: unitKey): string | undefined;
965
+ convertTo(unit: NumberWithUnitSymbol, targetUri: uriType): NumberWithUnitSymbol;
966
+ private isOneNumberRelative;
967
+ private convertRelative;
968
+ convertToCommonFormat(inputs: Array<NumberSymbol | NumberWithUnitSymbol>): Array<NumberSymbol | NumberWithUnitSymbol>;
969
+ }
970
+
971
+ interface LanguageOptions {
972
+ MAX_ITERATIONS: number;
973
+ }
974
+ interface ConfigOptions {
975
+ languageOptions?: LanguageOptions;
976
+ colorManager?: ColorManager;
977
+ unitManager?: UnitManager;
978
+ functionsManager?: FunctionsManager;
979
+ tokenManager?: TokenManager;
980
+ }
981
+ declare class Config {
982
+ languageOptions: LanguageOptions;
983
+ colorManager: ColorManager;
984
+ unitManager: UnitManager;
985
+ functionsManager: FunctionsManager;
986
+ tokenManager: TokenManager;
987
+ constructor(options?: ConfigOptions);
988
+ getType(baseType: string, subType?: string): ISymbolType;
989
+ isTypeDefined(baseType: string, subType?: string): boolean;
990
+ clone(): Config;
991
+ registerSchemas(schemas: Array<{
992
+ uri: string;
993
+ schema: ColorSpecification | FunctionSpecification | TokenSpecification;
994
+ }>): Config;
995
+ }
996
+
997
+ export { type ASTNode as A, Config as C, type ISymbolType as I, Operations as O, type ReferenceRecord as R, type SymbolMetadata as S, type Token as T, UNINTERPRETED_KEYWORDS as U, SupportedFormats as a, ReservedKeyword as b, TokenType as c, type ReferenceRecordValue as d };