@terrazzo/parser 0.7.2 → 0.8.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 (105) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/index.d.ts +707 -12
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +4598 -12
  5. package/dist/index.js.map +1 -1
  6. package/package.json +11 -7
  7. package/rolldown.config.ts +24 -0
  8. package/src/build/index.ts +2 -2
  9. package/src/index.ts +76 -1
  10. package/src/parse/index.ts +72 -13
  11. package/src/parse/json.ts +35 -29
  12. package/src/parse/normalize.ts +4 -14
  13. package/src/parse/validate.ts +81 -68
  14. package/dist/build/index.d.ts +0 -20
  15. package/dist/build/index.d.ts.map +0 -1
  16. package/dist/build/index.js +0 -166
  17. package/dist/build/index.js.map +0 -1
  18. package/dist/config.d.ts +0 -8
  19. package/dist/config.d.ts.map +0 -1
  20. package/dist/config.js +0 -290
  21. package/dist/config.js.map +0 -1
  22. package/dist/lib/code-frame.d.ts +0 -31
  23. package/dist/lib/code-frame.d.ts.map +0 -1
  24. package/dist/lib/code-frame.js +0 -108
  25. package/dist/lib/code-frame.js.map +0 -1
  26. package/dist/lint/index.d.ts +0 -12
  27. package/dist/lint/index.d.ts.map +0 -1
  28. package/dist/lint/index.js +0 -105
  29. package/dist/lint/index.js.map +0 -1
  30. package/dist/lint/plugin-core/index.d.ts +0 -13
  31. package/dist/lint/plugin-core/index.d.ts.map +0 -1
  32. package/dist/lint/plugin-core/index.js +0 -40
  33. package/dist/lint/plugin-core/index.js.map +0 -1
  34. package/dist/lint/plugin-core/lib/docs.d.ts +0 -2
  35. package/dist/lint/plugin-core/lib/docs.d.ts.map +0 -1
  36. package/dist/lint/plugin-core/lib/docs.js +0 -4
  37. package/dist/lint/plugin-core/lib/docs.js.map +0 -1
  38. package/dist/lint/plugin-core/rules/a11y-min-contrast.d.ts +0 -40
  39. package/dist/lint/plugin-core/rules/a11y-min-contrast.d.ts.map +0 -1
  40. package/dist/lint/plugin-core/rules/a11y-min-contrast.js +0 -58
  41. package/dist/lint/plugin-core/rules/a11y-min-contrast.js.map +0 -1
  42. package/dist/lint/plugin-core/rules/a11y-min-font-size.d.ts +0 -14
  43. package/dist/lint/plugin-core/rules/a11y-min-font-size.d.ts.map +0 -1
  44. package/dist/lint/plugin-core/rules/a11y-min-font-size.js +0 -45
  45. package/dist/lint/plugin-core/rules/a11y-min-font-size.js.map +0 -1
  46. package/dist/lint/plugin-core/rules/colorspace.d.ts +0 -15
  47. package/dist/lint/plugin-core/rules/colorspace.d.ts.map +0 -1
  48. package/dist/lint/plugin-core/rules/colorspace.js +0 -85
  49. package/dist/lint/plugin-core/rules/colorspace.js.map +0 -1
  50. package/dist/lint/plugin-core/rules/consistent-naming.d.ts +0 -12
  51. package/dist/lint/plugin-core/rules/consistent-naming.d.ts.map +0 -1
  52. package/dist/lint/plugin-core/rules/consistent-naming.js +0 -49
  53. package/dist/lint/plugin-core/rules/consistent-naming.js.map +0 -1
  54. package/dist/lint/plugin-core/rules/descriptions.d.ts +0 -10
  55. package/dist/lint/plugin-core/rules/descriptions.d.ts.map +0 -1
  56. package/dist/lint/plugin-core/rules/descriptions.js +0 -32
  57. package/dist/lint/plugin-core/rules/descriptions.js.map +0 -1
  58. package/dist/lint/plugin-core/rules/duplicate-values.d.ts +0 -10
  59. package/dist/lint/plugin-core/rules/duplicate-values.d.ts.map +0 -1
  60. package/dist/lint/plugin-core/rules/duplicate-values.js +0 -65
  61. package/dist/lint/plugin-core/rules/duplicate-values.js.map +0 -1
  62. package/dist/lint/plugin-core/rules/max-gamut.d.ts +0 -15
  63. package/dist/lint/plugin-core/rules/max-gamut.d.ts.map +0 -1
  64. package/dist/lint/plugin-core/rules/max-gamut.js +0 -101
  65. package/dist/lint/plugin-core/rules/max-gamut.js.map +0 -1
  66. package/dist/lint/plugin-core/rules/required-children.d.ts +0 -19
  67. package/dist/lint/plugin-core/rules/required-children.d.ts.map +0 -1
  68. package/dist/lint/plugin-core/rules/required-children.js +0 -78
  69. package/dist/lint/plugin-core/rules/required-children.js.map +0 -1
  70. package/dist/lint/plugin-core/rules/required-modes.d.ts +0 -14
  71. package/dist/lint/plugin-core/rules/required-modes.d.ts.map +0 -1
  72. package/dist/lint/plugin-core/rules/required-modes.js +0 -52
  73. package/dist/lint/plugin-core/rules/required-modes.js.map +0 -1
  74. package/dist/lint/plugin-core/rules/required-typography-properties.d.ts +0 -11
  75. package/dist/lint/plugin-core/rules/required-typography-properties.d.ts.map +0 -1
  76. package/dist/lint/plugin-core/rules/required-typography-properties.js +0 -38
  77. package/dist/lint/plugin-core/rules/required-typography-properties.js.map +0 -1
  78. package/dist/logger.d.ts +0 -77
  79. package/dist/logger.d.ts.map +0 -1
  80. package/dist/logger.js +0 -136
  81. package/dist/logger.js.map +0 -1
  82. package/dist/parse/alias.d.ts +0 -34
  83. package/dist/parse/alias.d.ts.map +0 -1
  84. package/dist/parse/alias.js +0 -302
  85. package/dist/parse/alias.js.map +0 -1
  86. package/dist/parse/index.d.ts +0 -36
  87. package/dist/parse/index.d.ts.map +0 -1
  88. package/dist/parse/index.js +0 -226
  89. package/dist/parse/index.js.map +0 -1
  90. package/dist/parse/json.d.ts +0 -52
  91. package/dist/parse/json.d.ts.map +0 -1
  92. package/dist/parse/json.js +0 -161
  93. package/dist/parse/json.js.map +0 -1
  94. package/dist/parse/normalize.d.ts +0 -24
  95. package/dist/parse/normalize.d.ts.map +0 -1
  96. package/dist/parse/normalize.js +0 -185
  97. package/dist/parse/normalize.js.map +0 -1
  98. package/dist/parse/validate.d.ts +0 -63
  99. package/dist/parse/validate.d.ts.map +0 -1
  100. package/dist/parse/validate.js +0 -798
  101. package/dist/parse/validate.js.map +0 -1
  102. package/dist/types.d.ts +0 -265
  103. package/dist/types.d.ts.map +0 -1
  104. package/dist/types.js +0 -2
  105. package/dist/types.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,13 +1,708 @@
1
- export { default as build } from './build/index.js';
2
- export * from './build/index.js';
3
- export { default as defineConfig } from './config.js';
4
- export * from './config.js';
5
- export { default as lintRunner } from './lint/index.js';
6
- export * from './lint/index.js';
7
- export { default as Logger } from './logger.js';
8
- export * from './logger.js';
9
- export { default as parse } from './parse/index.js';
10
- export * from './parse/index.js';
11
- export * from './types.js';
12
- export * from '@terrazzo/token-tools/dist/types.js';
1
+ import { AliasToken, AliasValue, BooleanToken, BooleanTokenNormalized, BooleanValue, BorderToken, BorderTokenNormalized, BorderValue, BorderValueNormalized, ColorSpace, ColorToken, ColorTokenNormalized, ColorValue, ColorValueNormalized, CubicBezierToken, CubicBezierTokenNormalized, CubicBezierValue, CustomTransformOptions, DimensionToken, DimensionTokenNormalized, DimensionValue, DurationToken, DurationTokenNormalized, DurationValue, FontFamilyToken, FontFamilyTokenNormalized, FontFamilyValue, FontFamilyValueNormalized, FontWeightToken, FontWeightTokenNormalized, FontWeightValue, FontWeightValueNormalized, GradientStop, GradientStopNormalized, GradientToken, GradientTokenNormalized, GradientValue, GradientValueNormalized, Group, GroupCore, GroupOrToken, LinkToken, LinkTokenNormalized, LinkValue, ModeMap, NumberToken, NumberTokenNormalized, NumberValue, ShadowToken, ShadowTokenNormalized, ShadowValue, ShadowValueNormalized, StringToken, StringTokenNormalized, StringValue, StrokeStyleToken, StrokeStyleTokenNormalized, StrokeStyleValue, StrokeStyleValueExpanded, Token, Token as Token$1, TokenCore, TokenMode, TokenNormalized, TokenNormalized as TokenNormalized$1, TokenNormalizedCore, TokenNormalizedSet, TokenNormalizedSet as TokenNormalizedSet$1, TokensSet, TransitionToken, TransitionTokenNormalized, TransitionValue, TransitionValueNormalized, TypographyToken, TypographyTokenNormalized, TypographyValue, TypographyValueNormalized } from "@terrazzo/token-tools";
2
+ import { AnyNode, DocumentNode, MemberNode, ObjectNode, ParseOptions as ParseOptions$1, ValueNode } from "@humanwhocodes/momoa";
3
+ import ytm from "yaml-to-momoa";
4
+
5
+ //#region src/logger.d.ts
6
+ declare const LOG_ORDER: readonly ["error", "warn", "info", "debug"];
7
+ type LogSeverity = 'error' | 'warn' | 'info' | 'debug';
8
+ type LogLevel = LogSeverity | 'silent';
9
+ type LogGroup = 'config' | 'parser' | 'lint' | 'plugin' | 'server';
10
+ interface LogEntry {
11
+ /** Originator of log message */
12
+ group: LogGroup;
13
+ /** Error message to be logged */
14
+ message: string;
15
+ /** Prefix message with label */
16
+ label?: string;
17
+ /** File in disk */
18
+ filename?: URL;
19
+ /**
20
+ * Continue on error?
21
+ * @default false
22
+ */
23
+ continueOnError?: boolean;
24
+ /** Show a code frame for the erring node */
25
+ node?: AnyNode;
26
+ /** To show a code frame, provide the original source code */
27
+ src?: string;
28
+ }
29
+ interface DebugEntry {
30
+ group: LogGroup;
31
+ /** Error message to be logged */
32
+ message: string;
33
+ /** Current subtask or submodule */
34
+ label?: string;
35
+ /** Show code below message */
36
+ codeFrame?: {
37
+ src: string;
38
+ line: number;
39
+ column: number;
40
+ };
41
+ /** Display performance timing */
42
+ timing?: number;
43
+ }
44
+ /**
45
+ * @param {Entry} entry
46
+ * @param {Severity} severity
47
+ * @return {string}
48
+ */
49
+ declare function formatMessage(entry: LogEntry, severity: LogSeverity): string;
50
+ declare class Logger {
51
+ level: LogLevel;
52
+ debugScope: string;
53
+ errorCount: number;
54
+ warnCount: number;
55
+ infoCount: number;
56
+ debugCount: number;
57
+ constructor(options?: {
58
+ level?: LogLevel;
59
+ debugScope?: string;
60
+ });
61
+ setLevel(level: LogLevel): void;
62
+ /** Log an error message (always; can’t be silenced) */
63
+ error(entry: LogEntry): void;
64
+ /** Log an info message (if logging level permits) */
65
+ info(entry: LogEntry): void;
66
+ /** Log a warning message (if logging level permits) */
67
+ warn(entry: LogEntry): void;
68
+ /** Log a diagnostics message (if logging level permits) */
69
+ debug(entry: DebugEntry): void;
70
+ /** Get stats for current logger instance */
71
+ stats(): {
72
+ errorCount: number;
73
+ warnCount: number;
74
+ infoCount: number;
75
+ debugCount: number;
76
+ };
77
+ }
78
+ declare class TokensJSONError extends Error {
79
+ constructor(message: string);
80
+ }
81
+ //# sourceMappingURL=logger.d.ts.map
82
+ //#endregion
83
+ //#region src/types.d.ts
84
+ interface BuildHookOptions {
85
+ /** Map of tokens */
86
+ tokens: Record<string, TokenNormalized$1>;
87
+ /** Query transformed values */
88
+ getTransforms(params: TransformParams): TokenTransformed[];
89
+ /** Momoa documents */
90
+ sources: InputSource[];
91
+ outputFile: (/** Filename to output (relative to outDir) */
92
+ filename: string, /** Contents to write to file */
93
+ contents: string | Buffer) => void;
94
+ }
95
+ interface BuildRunnerResult {
96
+ outputFiles: OutputFile[];
97
+ }
98
+ interface BuildEndHookOptions {
99
+ /** Map of tokens */
100
+ tokens: Record<string, TokenNormalized$1>;
101
+ /** Query transformed values */
102
+ getTransforms(params: TransformParams): TokenTransformed[];
103
+ /** Momoa documents */
104
+ sources: InputSource[];
105
+ /** Final files to be written */
106
+ outputFiles: OutputFileExpanded[];
107
+ }
108
+ interface Config {
109
+ /**
110
+ * Path to tokens.json
111
+ * @default "./tokens.json"
112
+ */
113
+ tokens?: string | string[];
114
+ /**
115
+ * Output directory
116
+ * @default "./tokens/"
117
+ */
118
+ outDir?: string;
119
+ /** Specify plugins */
120
+ plugins?: Plugin[];
121
+ /** Specify linting settings */
122
+ lint?: {
123
+ /** Configure build behavior */
124
+ build?: {
125
+ /**
126
+ * Should linters run with `tz build`?
127
+ * @default true
128
+ */
129
+ enabled?: boolean;
130
+ };
131
+ /** Configure lint rules */
132
+ rules?: Record<string, LintRuleShorthand | LintRuleLonghand>;
133
+ };
134
+ /** Ignore token groups */
135
+ ignore?: {
136
+ /** Token patterns to ignore. Accepts globs. */
137
+ tokens?: string[];
138
+ /** Ignore deprecated tokens */
139
+ deprecated?: boolean;
140
+ };
141
+ }
142
+ interface ConfigInit {
143
+ tokens: URL[];
144
+ outDir: URL;
145
+ plugins: Plugin[];
146
+ lint: {
147
+ build: NonNullable<NonNullable<Config['lint']>['build']>;
148
+ rules: Record<string, LintRuleLonghand>;
149
+ };
150
+ ignore: {
151
+ tokens: NonNullable<NonNullable<Config['ignore']>['tokens']>;
152
+ deprecated: NonNullable<NonNullable<Config['ignore']>['deprecated']>;
153
+ };
154
+ }
155
+ interface ConfigOptions {
156
+ logger?: Logger;
157
+ /** @terrazzo/parser needs cwd so this can be run without Node.js. Importing defineConfig from @terrazzo/cli doesn’t need this. */
158
+ cwd: URL;
159
+ }
160
+ interface InputSource {
161
+ filename?: URL;
162
+ src: any;
163
+ document: DocumentNode;
164
+ }
165
+ interface LintNotice {
166
+ /** Lint message shown to the user */
167
+ message: string;
168
+ /** Erring node (used to point to a specific line) */
169
+ node?: AnyNode;
170
+ }
171
+ type LintRuleSeverity = 'error' | 'warn' | 'off';
172
+ type LintRuleShorthand = LintRuleSeverity | 0 | 1 | 2;
173
+ type LintRuleLonghand = [LintRuleSeverity | 0 | 1 | 2, any];
174
+ interface LintRuleNormalized<O = any> {
175
+ id: string;
176
+ severity: LintRuleSeverity;
177
+ options?: O;
178
+ }
179
+ type LintReportDescriptor<MessageIds extends string> = {
180
+ /** To error on a specific token source file, provide an erring node */
181
+ node?: AnyNode;
182
+ /** To error on a specific token source file, also provide the source */
183
+ source?: InputSource;
184
+ /** Provide data for messages */
185
+ data?: Record<string, unknown>;
186
+ } & ({
187
+ /** Provide the error message to display */
188
+ message: string;
189
+ messageId?: never;
190
+ } | {
191
+ message?: never;
192
+ /** Provide the error message ID */
193
+ messageId: MessageIds;
194
+ });
195
+ interface LintRule<MessageIds extends string, LintRuleOptions extends object | undefined = undefined, LintRuleDocs = unknown> {
196
+ meta?: LintRuleMetaData<MessageIds, LintRuleOptions, LintRuleDocs>;
197
+ /**
198
+ * Function which returns an object with methods that ESLint calls to “visit”
199
+ * nodes while traversing the abstract syntax tree.
200
+ */
201
+ create(context: Readonly<LintRuleContext<MessageIds, LintRuleOptions>>): void | Promise<void>;
202
+ /**
203
+ * Default options the rule will be run with
204
+ */
205
+ defaultOptions: LintRuleOptions;
206
+ }
207
+ interface LintRuleContext<MessageIds extends string, LintRuleOptions extends object | undefined = undefined> {
208
+ /** The rule ID. */
209
+ id: string;
210
+ /**
211
+ * An array of the configured options for this rule. This array does not
212
+ * include the rule severity.
213
+ */
214
+ options: LintRuleOptions;
215
+ /** The current working directory. */
216
+ cwd?: URL;
217
+ /** Source file the token came from. */
218
+ src: string;
219
+ /** Source file location. */
220
+ filename?: URL;
221
+ /** ID:Token map of all tokens. */
222
+ tokens: Record<string, TokenNormalized$1>;
223
+ /** Reports a problem in the code. */
224
+ report(descriptor: LintReportDescriptor<MessageIds>): void;
225
+ }
226
+ interface LintRuleMetaData<MessageIds extends string, LintRuleOptions extends object | undefined = undefined, LintRuleDocs = unknown> {
227
+ /**
228
+ * Documentation for the rule
229
+ */
230
+ docs?: LintRuleDocs & LintRuleMetaDataDocs;
231
+ /**
232
+ * A map of messages which the rule can report. The key is the messageId, and
233
+ * the string is the parameterised error string.
234
+ */
235
+ messages?: Record<MessageIds, string>;
236
+ /**
237
+ * Specifies default options for the rule. If present, any user-provided
238
+ * options in their config will be merged on top of them recursively. This
239
+ * merging will be applied directly to `context.options`.
240
+ */
241
+ defaultOptions?: LintRuleOptions;
242
+ }
243
+ interface LintRuleMetaDataDocs {
244
+ /** Concise description of the rule. */
245
+ description: string;
246
+ /** The URL of the rule's docs. */
247
+ url?: string;
248
+ }
249
+ interface OutputFile {
250
+ /** Filename, relative to outDir */
251
+ filename: string;
252
+ /** File contents */
253
+ contents: string | Buffer;
254
+ /** Plugin name that generated the file */
255
+ plugin?: string;
256
+ /** Time taken to generate file */
257
+ time?: number;
258
+ }
259
+ interface OutputFileExpanded extends OutputFile {
260
+ /** The `name` of the plugin that produced this file. */
261
+ plugin: string;
262
+ /** How long this output took to make. */
263
+ time: number;
264
+ }
265
+ interface Plugin {
266
+ name: string;
267
+ /** Read config, and optionally modify */
268
+ config?(config: ConfigInit): void | ConfigInit | undefined;
269
+ /**
270
+ * Declare:
271
+ * - `"pre"`: run this plugin BEFORE all others
272
+ * - `"post"`: run this plugin AFTER all others
273
+ * - (default) run this plugin in default order (array order)
274
+ */
275
+ enforce?: 'pre' | 'post';
276
+ /** Throw lint errors/warnings */
277
+ lint?(): Record<string, LintRule<any, any, any>>;
278
+ transform?(options: TransformHookOptions): Promise<void>;
279
+ build?(options: BuildHookOptions): Promise<void>;
280
+ buildEnd?(result: BuildRunnerResult): Promise<void>;
281
+ }
282
+ /** Transformed token with a single value. Note that this may be any type! */
283
+ interface TokenTransformedSingleValue {
284
+ /** Original Token ID */
285
+ id: string;
286
+ /** ID unique to this format. */
287
+ localID?: string;
288
+ type: 'SINGLE_VALUE';
289
+ value: string;
290
+ /**
291
+ * The mode of this value
292
+ * @default "."
293
+ */
294
+ mode: string;
295
+ /** The original token. */
296
+ token: TokenNormalized$1;
297
+ }
298
+ /** Transformed token with multiple values. Note that this may be any type! */
299
+ interface TokenTransformedMultiValue {
300
+ /** Original Token ID */
301
+ id: string;
302
+ /** ID unique to this format.*/
303
+ localID?: string;
304
+ type: 'MULTI_VALUE';
305
+ value: Record<string, string>;
306
+ /**
307
+ * The mode of this value
308
+ * @default "."
309
+ */
310
+ mode: string;
311
+ /** The original token */
312
+ token: TokenNormalized$1;
313
+ }
314
+ type TokenTransformed = TokenTransformedSingleValue | TokenTransformedMultiValue;
315
+ interface TransformParams {
316
+ /** ID of an existing format */
317
+ format: string;
318
+ /** Glob of tokens to select (e.g. `"color.*"` to select all tokens starting with `"color."`) */
319
+ id?: string | string[];
320
+ /** $type(s) to filter for */
321
+ $type?: string | string[];
322
+ /**
323
+ * Mode name, if selecting a mode
324
+ * @default "."
325
+ */
326
+ mode?: string | string[];
327
+ }
328
+ interface TransformHookOptions {
329
+ /** Map of tokens */
330
+ tokens: Record<string, TokenNormalized$1>;
331
+ /** Query transformed values */
332
+ getTransforms(params: TransformParams): TokenTransformed[];
333
+ /** Update transformed values */
334
+ setTransform(id: string, params: {
335
+ format: string;
336
+ localID?: string;
337
+ value: string | Record<string, string>;
338
+ mode?: string;
339
+ }): void;
340
+ /** Momoa documents */
341
+ sources: InputSource[];
342
+ }
343
+ //# sourceMappingURL=types.d.ts.map
344
+ //#endregion
345
+ //#region src/build/index.d.ts
346
+ interface BuildRunnerOptions {
347
+ sources: {
348
+ filename?: URL;
349
+ src: string;
350
+ document: DocumentNode;
351
+ }[];
352
+ config: ConfigInit;
353
+ logger?: Logger;
354
+ }
355
+ declare const SINGLE_VALUE = "SINGLE_VALUE";
356
+ declare const MULTI_VALUE = "MULTI_VALUE";
357
+ /**
358
+ * Run build stage
359
+ */
360
+ declare function build(tokens: Record<string, TokenNormalized$1>, {
361
+ sources,
362
+ logger,
363
+ config
364
+ }: BuildRunnerOptions): Promise<BuildRunnerResult>;
365
+ //# sourceMappingURL=index.d.ts.map
366
+ //#endregion
367
+ //#region src/config.d.ts
368
+ /**
369
+ * Validate and normalize a config
370
+ */
371
+ declare function defineConfig(rawConfig: Config, {
372
+ logger,
373
+ cwd
374
+ }?: ConfigOptions): ConfigInit;
375
+ /** Merge configs */
376
+ declare function mergeConfigs(a: Config, b: Config): Config;
377
+ //# sourceMappingURL=config.d.ts.map
378
+ //#endregion
379
+ //#region src/lint/index.d.ts
380
+ interface LintRunnerOptions {
381
+ tokens: Record<string, TokenNormalized$1>;
382
+ filename?: URL;
383
+ config: ConfigInit;
384
+ src: string;
385
+ logger: Logger;
386
+ }
387
+ declare function lintRunner({
388
+ tokens,
389
+ filename,
390
+ config,
391
+ src,
392
+ logger
393
+ }: LintRunnerOptions): Promise<void>;
394
+ //# sourceMappingURL=index.d.ts.map
395
+ //#endregion
396
+ //#region src/parse/normalize.d.ts
397
+ declare const FONT_WEIGHT_MAP: {
398
+ thin: number;
399
+ hairline: number;
400
+ 'extra-light': number;
401
+ 'ultra-light': number;
402
+ light: number;
403
+ normal: number;
404
+ regular: number;
405
+ book: number;
406
+ medium: number;
407
+ 'semi-bold': number;
408
+ 'demi-bold': number;
409
+ bold: number;
410
+ 'extra-bold': number;
411
+ 'ultra-bold': number;
412
+ black: number;
413
+ heavy: number;
414
+ 'extra-black': number;
415
+ 'ultra-black': number;
416
+ };
417
+ /** Fill in defaults, and return predictable shapes for tokens */
418
+ declare function normalizeValue<T extends Token$1>(token: T): T['$value'];
419
+ //# sourceMappingURL=normalize.d.ts.map
420
+ //#endregion
421
+ //#region src/parse/validate.d.ts
422
+ interface ValidateOptions {
423
+ filename?: URL;
424
+ src: string;
425
+ logger: Logger;
426
+ }
427
+ interface Visitors {
428
+ color?: Visitor;
429
+ dimension?: Visitor;
430
+ fontFamily?: Visitor;
431
+ fontWeight?: Visitor;
432
+ duration?: Visitor;
433
+ cubicBezier?: Visitor;
434
+ number?: Visitor;
435
+ link?: Visitor;
436
+ boolean?: Visitor;
437
+ strokeStyle?: Visitor;
438
+ border?: Visitor;
439
+ transition?: Visitor;
440
+ shadow?: Visitor;
441
+ gradient?: Visitor;
442
+ typography?: Visitor;
443
+ root?: Visitor;
444
+ group?: Visitor;
445
+ [key: string]: Visitor | undefined;
446
+ }
447
+ type Visitor = (json: any, path: string, ast: AnyNode) => any | undefined | null;
448
+ declare const VALID_COLORSPACES: Set<string>;
449
+ declare const FONT_WEIGHT_VALUES: Set<string>;
450
+ declare const STROKE_STYLE_VALUES: Set<string>;
451
+ declare const STROKE_STYLE_LINE_CAP_VALUES: Set<string>;
452
+ /** Verify an Alias $value is formatted correctly */
453
+ declare function validateAliasSyntax($value: ValueNode, _node: AnyNode, {
454
+ filename,
455
+ src,
456
+ logger
457
+ }: ValidateOptions): void;
458
+ /** Verify a Border token is valid */
459
+ declare function validateBorder($value: ValueNode, node: AnyNode, {
460
+ filename,
461
+ src,
462
+ logger
463
+ }: ValidateOptions): void;
464
+ /** Verify a Color token is valid */
465
+ declare function validateColor($value: ValueNode, node: AnyNode, {
466
+ filename,
467
+ src,
468
+ logger
469
+ }: ValidateOptions): void;
470
+ /** Verify a Cubic Bézier token is valid */
471
+ declare function validateCubicBezier($value: ValueNode, _node: AnyNode, {
472
+ filename,
473
+ src,
474
+ logger
475
+ }: ValidateOptions): void;
476
+ /** Verify a Dimension token is valid */
477
+ declare function validateDimension($value: ValueNode, _node: AnyNode, {
478
+ filename,
479
+ src,
480
+ logger
481
+ }: ValidateOptions): void;
482
+ /** Verify a Duration token is valid */
483
+ declare function validateDuration($value: ValueNode, _node: AnyNode, {
484
+ filename,
485
+ src,
486
+ logger
487
+ }: ValidateOptions): void;
488
+ /** Verify a Font Family token is valid */
489
+ declare function validateFontFamily($value: ValueNode, _node: AnyNode, {
490
+ filename,
491
+ src,
492
+ logger
493
+ }: ValidateOptions): void;
494
+ /** Verify a Font Weight token is valid */
495
+ declare function validateFontWeight($value: ValueNode, _node: AnyNode, {
496
+ filename,
497
+ src,
498
+ logger
499
+ }: ValidateOptions): void;
500
+ /** Verify a Gradient token is valid */
501
+ declare function validateGradient($value: ValueNode, _node: AnyNode, {
502
+ filename,
503
+ src,
504
+ logger
505
+ }: ValidateOptions): void;
506
+ /** Verify a Number token is valid */
507
+ declare function validateNumber($value: ValueNode, _node: AnyNode, {
508
+ filename,
509
+ src,
510
+ logger
511
+ }: ValidateOptions): void;
512
+ /** Verify a Boolean token is valid */
513
+ declare function validateBoolean($value: ValueNode, _node: AnyNode, {
514
+ filename,
515
+ src,
516
+ logger
517
+ }: ValidateOptions): void;
518
+ /** Verify a Shadow token’s value is valid */
519
+ declare function validateShadowLayer($value: ValueNode, node: AnyNode, {
520
+ filename,
521
+ src,
522
+ logger
523
+ }: ValidateOptions): void;
524
+ /** Verify a Stroke Style token is valid. */
525
+ declare function validateStrokeStyle($value: ValueNode, node: AnyNode, {
526
+ filename,
527
+ src,
528
+ logger
529
+ }: ValidateOptions): void;
530
+ /** Verify a Transition token is valid */
531
+ declare function validateTransition($value: ValueNode, node: AnyNode, {
532
+ filename,
533
+ src,
534
+ logger
535
+ }: ValidateOptions): void;
536
+ /**
537
+ * Validate a MemberNode (the entire token object, plus its key in the parent
538
+ * object) to see if it’s a valid DTCG token or not. Keeping the parent key
539
+ * really helps in debug messages.
540
+ */
541
+ declare function validateTokenMemberNode(node: MemberNode, {
542
+ filename,
543
+ src,
544
+ logger
545
+ }: ValidateOptions): void;
546
+ /** Return any token node with its inherited $type */
547
+ declare function getInheritedType(node: MemberNode, {
548
+ subpath,
549
+ $typeInheritance
550
+ }: {
551
+ subpath: string[];
552
+ $typeInheritance?: Record<string, MemberNode>;
553
+ }): MemberNode | undefined;
554
+ interface ValidateTokenNodeOptions {
555
+ subpath: string[];
556
+ src: string;
557
+ filename: URL;
558
+ config: ConfigInit;
559
+ logger: Logger;
560
+ parent: AnyNode | undefined;
561
+ transform?: Visitors;
562
+ inheritedTypeNode?: MemberNode;
563
+ }
564
+ /**
565
+ * Validate does a little more than validate; it also converts to TokenNormalized
566
+ * and sets up the basic data structure. But aliases are unresolved, and we need
567
+ * a 2nd normalization pass afterward.
568
+ */
569
+ declare function validateTokenNode(node: MemberNode, {
570
+ config,
571
+ filename,
572
+ logger,
573
+ parent,
574
+ inheritedTypeNode,
575
+ src,
576
+ subpath
577
+ }: ValidateTokenNodeOptions): TokenNormalized$1 | undefined;
578
+ //# sourceMappingURL=validate.d.ts.map
579
+ //#endregion
580
+ //#region src/parse/alias.d.ts
581
+ interface ApplyAliasOptions {
582
+ tokensSet: TokenNormalizedSet$1;
583
+ filename: URL;
584
+ src: string;
585
+ node: ObjectNode;
586
+ logger: Logger;
587
+ }
588
+ type PreAliased<T extends TokenNormalized$1> = {
589
+ $value: T['$value'] | string;
590
+ mode: Record<string, T['mode'][string] & {
591
+ $value: T['$value'] | string;
592
+ }>;
593
+ };
594
+ /**
595
+ * Resolve aliases and update the token nodes.
596
+ *
597
+ * Data structures are in an awkward in-between phase, where they have
598
+ * placeholders for data but we still need to resolve everything. As such,
599
+ * TypeScript will raise errors expecting the final shape.
600
+ *
601
+ * This is also a bit tricky because different token types alias slightly
602
+ * differently. For example, color tokens and other “primitive” tokens behave
603
+ * as-expected. But composite tokens like Typography, Gradient, Border, etc. can
604
+ * either fully- or partially-alias their values. Then we add modes to the mix,
605
+ * and we have to do the work all over again for each mode declared.
606
+ *
607
+ * All that to say, there are a generous amount of TypeScript overrides here rather
608
+ * than try to codify indeterminate shapes.
609
+ */
610
+ //#endregion
611
+ //#region src/parse/json.d.ts
612
+ interface JSONVisitor {
613
+ enter?: (node: AnyNode, parent: AnyNode | undefined, path: string[]) => void;
614
+ exit?: (node: AnyNode, parent: AnyNode | undefined, path: string[]) => void;
615
+ }
616
+ declare const CHILD_KEYS: {
617
+ Document: readonly ["body"];
618
+ Object: readonly ["members"];
619
+ Member: readonly ["name", "value"];
620
+ Element: readonly ["value"];
621
+ Array: readonly ["elements"];
622
+ String: readonly [];
623
+ Number: readonly [];
624
+ Boolean: readonly [];
625
+ Null: readonly [];
626
+ Identifier: readonly [];
627
+ NaN: readonly [];
628
+ Infinity: readonly [];
629
+ };
630
+ /** Determines if a given value is an AST node. */
631
+ declare function isNode(value: unknown): boolean;
632
+ type ValueNodeWithIndex = ValueNode & {
633
+ index: number;
634
+ };
635
+ /** Get ObjectNode members as object */
636
+ declare function getObjMembers(node: ObjectNode): Record<string | number, ValueNodeWithIndex>;
637
+ /** Inject members to ObjectNode */
638
+ declare function injectObjMembers(node: ObjectNode, members?: MemberNode[]): void;
639
+ /** Replace an ObjectNode’s contents outright with another */
640
+ declare function replaceObjMembers(a: ObjectNode, b: DocumentNode | ObjectNode): void;
641
+ /**
642
+ * Variation of Momoa’s traverse(), which keeps track of global path.
643
+ * Allows mutation of AST (along with any consequences)
644
+ */
645
+ declare function traverse(root: AnyNode, visitor: JSONVisitor): void;
646
+ /** Determine if an input is likely a JSON string */
647
+ declare function maybeRawJSON(input: string): boolean;
648
+ /** Find Momoa node by traversing paths */
649
+ declare function findNode<T = AnyNode>(node: AnyNode, path: string[]): T | undefined;
650
+ interface ToMomoaOptions {
651
+ filename?: URL;
652
+ continueOnError?: boolean;
653
+ logger: Logger;
654
+ yamlToMomoa?: typeof ytm;
655
+ }
656
+ declare function toMomoa(input: string | Record<string, any>, {
657
+ continueOnError,
658
+ filename,
659
+ logger,
660
+ yamlToMomoa: ytm
661
+ }: ToMomoaOptions): InputSource;
662
+ /** Momoa, just with default options pre-set */
663
+ declare function parseJSON(input: string | Record<string, any>, options?: ParseOptions$1): any;
664
+ //# sourceMappingURL=json.d.ts.map
665
+ //#endregion
666
+ //#region src/parse/index.d.ts
667
+ interface ParseOptions {
668
+ logger?: Logger;
669
+ config: ConfigInit;
670
+ /**
671
+ * Skip lint step
672
+ * @default false
673
+ */
674
+ skipLint?: boolean;
675
+ /**
676
+ * Continue on error? (Useful for `tz check`)
677
+ * @default false
678
+ */
679
+ continueOnError?: boolean;
680
+ /** Provide yamlToMomoa module to parse YAML (by default, this isn’t shipped to cut down on package weight) */
681
+ yamlToMomoa?: typeof ytm;
682
+ /**
683
+ * Transform API
684
+ * @see https://terrazzo.app/docs/api/js#transform-api
685
+ */
686
+ transform?: Visitors;
687
+ /** (internal cache; do not use) */
688
+ _sources?: Record<string, InputSource>;
689
+ }
690
+ interface ParseResult {
691
+ tokens: Record<string, TokenNormalized$1>;
692
+ sources: InputSource[];
693
+ }
694
+ /** Parse */
695
+ declare function parse(_input: Omit<InputSource, 'document'> | Omit<InputSource, 'document'>[], {
696
+ logger,
697
+ skipLint,
698
+ config,
699
+ continueOnError,
700
+ yamlToMomoa,
701
+ transform,
702
+ _sources
703
+ }?: ParseOptions): Promise<ParseResult>;
704
+ //# sourceMappingURL=index.d.ts.map
705
+
706
+ //#endregion
707
+ export { AliasToken, AliasValue, ApplyAliasOptions, BooleanToken, BooleanTokenNormalized, BooleanValue, BorderToken, BorderTokenNormalized, BorderValue, BorderValueNormalized, BuildEndHookOptions, BuildHookOptions, BuildRunnerOptions, BuildRunnerResult, CHILD_KEYS, ColorSpace, ColorToken, ColorTokenNormalized, ColorValue, ColorValueNormalized, Config, ConfigInit, ConfigOptions, CubicBezierToken, CubicBezierTokenNormalized, CubicBezierValue, CustomTransformOptions, DebugEntry, DimensionToken, DimensionTokenNormalized, DimensionValue, DurationToken, DurationTokenNormalized, DurationValue, FONT_WEIGHT_MAP, FONT_WEIGHT_VALUES, FontFamilyToken, FontFamilyTokenNormalized, FontFamilyValue, FontFamilyValueNormalized, FontWeightToken, FontWeightTokenNormalized, FontWeightValue, FontWeightValueNormalized, GradientStop, GradientStopNormalized, GradientToken, GradientTokenNormalized, GradientValue, GradientValueNormalized, Group, GroupCore, GroupOrToken, InputSource, JSONVisitor, LOG_ORDER, LinkToken, LinkTokenNormalized, LinkValue, LintNotice, LintReportDescriptor, LintRule, LintRuleContext, LintRuleLonghand, LintRuleMetaData, LintRuleMetaDataDocs, LintRuleNormalized, LintRuleSeverity, LintRuleShorthand, LintRunnerOptions, LogEntry, LogGroup, LogLevel, LogSeverity, Logger, MULTI_VALUE, ModeMap, NumberToken, NumberTokenNormalized, NumberValue, OutputFile, OutputFileExpanded, ParseOptions, ParseResult, Plugin, PreAliased, SINGLE_VALUE, STROKE_STYLE_LINE_CAP_VALUES, STROKE_STYLE_VALUES, ShadowToken, ShadowTokenNormalized, ShadowValue, ShadowValueNormalized, StringToken, StringTokenNormalized, StringValue, StrokeStyleToken, StrokeStyleTokenNormalized, StrokeStyleValue, StrokeStyleValueExpanded, ToMomoaOptions, Token, TokenCore, TokenMode, TokenNormalized, TokenNormalizedCore, TokenNormalizedSet, TokenTransformed, TokenTransformedMultiValue, TokenTransformedSingleValue, TokensJSONError, TokensSet, TransformHookOptions, TransformParams, TransitionToken, TransitionTokenNormalized, TransitionValue, TransitionValueNormalized, TypographyToken, TypographyTokenNormalized, TypographyValue, TypographyValueNormalized, VALID_COLORSPACES, ValidateOptions, ValidateTokenNodeOptions, ValueNodeWithIndex, Visitor, Visitors, build, defineConfig, findNode, formatMessage, getInheritedType, getObjMembers, injectObjMembers, isNode, lintRunner, maybeRawJSON, mergeConfigs, normalizeValue as normalize, parse, parseJSON, replaceObjMembers, toMomoa, traverse, validateAliasSyntax, validateBoolean, validateBorder, validateColor, validateCubicBezier, validateDimension, validateDuration, validateFontFamily, validateFontWeight, validateGradient, validateNumber, validateShadowLayer, validateStrokeStyle, validateTokenMemberNode, validateTokenNode, validateTransition };
13
708
  //# sourceMappingURL=index.d.ts.map