@terrazzo/parser 0.7.3 → 0.8.1

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 (100) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/index.d.ts +705 -12
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +4603 -12
  5. package/dist/index.js.map +1 -1
  6. package/package.json +11 -7
  7. package/src/build/index.ts +8 -6
  8. package/src/index.ts +76 -1
  9. package/dist/build/index.d.ts +0 -20
  10. package/dist/build/index.d.ts.map +0 -1
  11. package/dist/build/index.js +0 -166
  12. package/dist/build/index.js.map +0 -1
  13. package/dist/config.d.ts +0 -8
  14. package/dist/config.d.ts.map +0 -1
  15. package/dist/config.js +0 -290
  16. package/dist/config.js.map +0 -1
  17. package/dist/lib/code-frame.d.ts +0 -31
  18. package/dist/lib/code-frame.d.ts.map +0 -1
  19. package/dist/lib/code-frame.js +0 -108
  20. package/dist/lib/code-frame.js.map +0 -1
  21. package/dist/lint/index.d.ts +0 -12
  22. package/dist/lint/index.d.ts.map +0 -1
  23. package/dist/lint/index.js +0 -105
  24. package/dist/lint/index.js.map +0 -1
  25. package/dist/lint/plugin-core/index.d.ts +0 -13
  26. package/dist/lint/plugin-core/index.d.ts.map +0 -1
  27. package/dist/lint/plugin-core/index.js +0 -40
  28. package/dist/lint/plugin-core/index.js.map +0 -1
  29. package/dist/lint/plugin-core/lib/docs.d.ts +0 -2
  30. package/dist/lint/plugin-core/lib/docs.d.ts.map +0 -1
  31. package/dist/lint/plugin-core/lib/docs.js +0 -4
  32. package/dist/lint/plugin-core/lib/docs.js.map +0 -1
  33. package/dist/lint/plugin-core/rules/a11y-min-contrast.d.ts +0 -40
  34. package/dist/lint/plugin-core/rules/a11y-min-contrast.d.ts.map +0 -1
  35. package/dist/lint/plugin-core/rules/a11y-min-contrast.js +0 -58
  36. package/dist/lint/plugin-core/rules/a11y-min-contrast.js.map +0 -1
  37. package/dist/lint/plugin-core/rules/a11y-min-font-size.d.ts +0 -14
  38. package/dist/lint/plugin-core/rules/a11y-min-font-size.d.ts.map +0 -1
  39. package/dist/lint/plugin-core/rules/a11y-min-font-size.js +0 -45
  40. package/dist/lint/plugin-core/rules/a11y-min-font-size.js.map +0 -1
  41. package/dist/lint/plugin-core/rules/colorspace.d.ts +0 -15
  42. package/dist/lint/plugin-core/rules/colorspace.d.ts.map +0 -1
  43. package/dist/lint/plugin-core/rules/colorspace.js +0 -85
  44. package/dist/lint/plugin-core/rules/colorspace.js.map +0 -1
  45. package/dist/lint/plugin-core/rules/consistent-naming.d.ts +0 -12
  46. package/dist/lint/plugin-core/rules/consistent-naming.d.ts.map +0 -1
  47. package/dist/lint/plugin-core/rules/consistent-naming.js +0 -49
  48. package/dist/lint/plugin-core/rules/consistent-naming.js.map +0 -1
  49. package/dist/lint/plugin-core/rules/descriptions.d.ts +0 -10
  50. package/dist/lint/plugin-core/rules/descriptions.d.ts.map +0 -1
  51. package/dist/lint/plugin-core/rules/descriptions.js +0 -32
  52. package/dist/lint/plugin-core/rules/descriptions.js.map +0 -1
  53. package/dist/lint/plugin-core/rules/duplicate-values.d.ts +0 -10
  54. package/dist/lint/plugin-core/rules/duplicate-values.d.ts.map +0 -1
  55. package/dist/lint/plugin-core/rules/duplicate-values.js +0 -65
  56. package/dist/lint/plugin-core/rules/duplicate-values.js.map +0 -1
  57. package/dist/lint/plugin-core/rules/max-gamut.d.ts +0 -15
  58. package/dist/lint/plugin-core/rules/max-gamut.d.ts.map +0 -1
  59. package/dist/lint/plugin-core/rules/max-gamut.js +0 -101
  60. package/dist/lint/plugin-core/rules/max-gamut.js.map +0 -1
  61. package/dist/lint/plugin-core/rules/required-children.d.ts +0 -19
  62. package/dist/lint/plugin-core/rules/required-children.d.ts.map +0 -1
  63. package/dist/lint/plugin-core/rules/required-children.js +0 -78
  64. package/dist/lint/plugin-core/rules/required-children.js.map +0 -1
  65. package/dist/lint/plugin-core/rules/required-modes.d.ts +0 -14
  66. package/dist/lint/plugin-core/rules/required-modes.d.ts.map +0 -1
  67. package/dist/lint/plugin-core/rules/required-modes.js +0 -52
  68. package/dist/lint/plugin-core/rules/required-modes.js.map +0 -1
  69. package/dist/lint/plugin-core/rules/required-typography-properties.d.ts +0 -11
  70. package/dist/lint/plugin-core/rules/required-typography-properties.d.ts.map +0 -1
  71. package/dist/lint/plugin-core/rules/required-typography-properties.js +0 -38
  72. package/dist/lint/plugin-core/rules/required-typography-properties.js.map +0 -1
  73. package/dist/logger.d.ts +0 -77
  74. package/dist/logger.d.ts.map +0 -1
  75. package/dist/logger.js +0 -136
  76. package/dist/logger.js.map +0 -1
  77. package/dist/parse/alias.d.ts +0 -34
  78. package/dist/parse/alias.d.ts.map +0 -1
  79. package/dist/parse/alias.js +0 -302
  80. package/dist/parse/alias.js.map +0 -1
  81. package/dist/parse/index.d.ts +0 -41
  82. package/dist/parse/index.d.ts.map +0 -1
  83. package/dist/parse/index.js +0 -273
  84. package/dist/parse/index.js.map +0 -1
  85. package/dist/parse/json.d.ts +0 -52
  86. package/dist/parse/json.d.ts.map +0 -1
  87. package/dist/parse/json.js +0 -168
  88. package/dist/parse/json.js.map +0 -1
  89. package/dist/parse/normalize.d.ts +0 -24
  90. package/dist/parse/normalize.d.ts.map +0 -1
  91. package/dist/parse/normalize.js +0 -176
  92. package/dist/parse/normalize.js.map +0 -1
  93. package/dist/parse/validate.d.ts +0 -90
  94. package/dist/parse/validate.d.ts.map +0 -1
  95. package/dist/parse/validate.js +0 -787
  96. package/dist/parse/validate.js.map +0 -1
  97. package/dist/types.d.ts +0 -265
  98. package/dist/types.d.ts.map +0 -1
  99. package/dist/types.js +0 -2
  100. package/dist/types.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,13 +1,706 @@
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
+ /** Run build stage */
358
+ declare function build(tokens: Record<string, TokenNormalized$1>, {
359
+ sources,
360
+ logger,
361
+ config
362
+ }: BuildRunnerOptions): Promise<BuildRunnerResult>;
363
+ //# sourceMappingURL=index.d.ts.map
364
+ //#endregion
365
+ //#region src/config.d.ts
366
+ /**
367
+ * Validate and normalize a config
368
+ */
369
+ declare function defineConfig(rawConfig: Config, {
370
+ logger,
371
+ cwd
372
+ }?: ConfigOptions): ConfigInit;
373
+ /** Merge configs */
374
+ declare function mergeConfigs(a: Config, b: Config): Config;
375
+ //# sourceMappingURL=config.d.ts.map
376
+ //#endregion
377
+ //#region src/lint/index.d.ts
378
+ interface LintRunnerOptions {
379
+ tokens: Record<string, TokenNormalized$1>;
380
+ filename?: URL;
381
+ config: ConfigInit;
382
+ src: string;
383
+ logger: Logger;
384
+ }
385
+ declare function lintRunner({
386
+ tokens,
387
+ filename,
388
+ config,
389
+ src,
390
+ logger
391
+ }: LintRunnerOptions): Promise<void>;
392
+ //# sourceMappingURL=index.d.ts.map
393
+ //#endregion
394
+ //#region src/parse/normalize.d.ts
395
+ declare const FONT_WEIGHT_MAP: {
396
+ thin: number;
397
+ hairline: number;
398
+ 'extra-light': number;
399
+ 'ultra-light': number;
400
+ light: number;
401
+ normal: number;
402
+ regular: number;
403
+ book: number;
404
+ medium: number;
405
+ 'semi-bold': number;
406
+ 'demi-bold': number;
407
+ bold: number;
408
+ 'extra-bold': number;
409
+ 'ultra-bold': number;
410
+ black: number;
411
+ heavy: number;
412
+ 'extra-black': number;
413
+ 'ultra-black': number;
414
+ };
415
+ /** Fill in defaults, and return predictable shapes for tokens */
416
+ declare function normalizeValue<T extends Token$1>(token: T): T['$value'];
417
+ //# sourceMappingURL=normalize.d.ts.map
418
+ //#endregion
419
+ //#region src/parse/validate.d.ts
420
+ interface ValidateOptions {
421
+ filename?: URL;
422
+ src: string;
423
+ logger: Logger;
424
+ }
425
+ interface Visitors {
426
+ color?: Visitor;
427
+ dimension?: Visitor;
428
+ fontFamily?: Visitor;
429
+ fontWeight?: Visitor;
430
+ duration?: Visitor;
431
+ cubicBezier?: Visitor;
432
+ number?: Visitor;
433
+ link?: Visitor;
434
+ boolean?: Visitor;
435
+ strokeStyle?: Visitor;
436
+ border?: Visitor;
437
+ transition?: Visitor;
438
+ shadow?: Visitor;
439
+ gradient?: Visitor;
440
+ typography?: Visitor;
441
+ root?: Visitor;
442
+ group?: Visitor;
443
+ [key: string]: Visitor | undefined;
444
+ }
445
+ type Visitor = (json: any, path: string, ast: AnyNode) => any | undefined | null;
446
+ declare const VALID_COLORSPACES: Set<string>;
447
+ declare const FONT_WEIGHT_VALUES: Set<string>;
448
+ declare const STROKE_STYLE_VALUES: Set<string>;
449
+ declare const STROKE_STYLE_LINE_CAP_VALUES: Set<string>;
450
+ /** Verify an Alias $value is formatted correctly */
451
+ declare function validateAliasSyntax($value: ValueNode, _node: AnyNode, {
452
+ filename,
453
+ src,
454
+ logger
455
+ }: ValidateOptions): void;
456
+ /** Verify a Border token is valid */
457
+ declare function validateBorder($value: ValueNode, node: AnyNode, {
458
+ filename,
459
+ src,
460
+ logger
461
+ }: ValidateOptions): void;
462
+ /** Verify a Color token is valid */
463
+ declare function validateColor($value: ValueNode, node: AnyNode, {
464
+ filename,
465
+ src,
466
+ logger
467
+ }: ValidateOptions): void;
468
+ /** Verify a Cubic Bézier token is valid */
469
+ declare function validateCubicBezier($value: ValueNode, _node: AnyNode, {
470
+ filename,
471
+ src,
472
+ logger
473
+ }: ValidateOptions): void;
474
+ /** Verify a Dimension token is valid */
475
+ declare function validateDimension($value: ValueNode, _node: AnyNode, {
476
+ filename,
477
+ src,
478
+ logger
479
+ }: ValidateOptions): void;
480
+ /** Verify a Duration token is valid */
481
+ declare function validateDuration($value: ValueNode, _node: AnyNode, {
482
+ filename,
483
+ src,
484
+ logger
485
+ }: ValidateOptions): void;
486
+ /** Verify a Font Family token is valid */
487
+ declare function validateFontFamily($value: ValueNode, _node: AnyNode, {
488
+ filename,
489
+ src,
490
+ logger
491
+ }: ValidateOptions): void;
492
+ /** Verify a Font Weight token is valid */
493
+ declare function validateFontWeight($value: ValueNode, _node: AnyNode, {
494
+ filename,
495
+ src,
496
+ logger
497
+ }: ValidateOptions): void;
498
+ /** Verify a Gradient token is valid */
499
+ declare function validateGradient($value: ValueNode, _node: AnyNode, {
500
+ filename,
501
+ src,
502
+ logger
503
+ }: ValidateOptions): void;
504
+ /** Verify a Number token is valid */
505
+ declare function validateNumber($value: ValueNode, _node: AnyNode, {
506
+ filename,
507
+ src,
508
+ logger
509
+ }: ValidateOptions): void;
510
+ /** Verify a Boolean token is valid */
511
+ declare function validateBoolean($value: ValueNode, _node: AnyNode, {
512
+ filename,
513
+ src,
514
+ logger
515
+ }: ValidateOptions): void;
516
+ /** Verify a Shadow token’s value is valid */
517
+ declare function validateShadowLayer($value: ValueNode, node: AnyNode, {
518
+ filename,
519
+ src,
520
+ logger
521
+ }: ValidateOptions): void;
522
+ /** Verify a Stroke Style token is valid. */
523
+ declare function validateStrokeStyle($value: ValueNode, node: AnyNode, {
524
+ filename,
525
+ src,
526
+ logger
527
+ }: ValidateOptions): void;
528
+ /** Verify a Transition token is valid */
529
+ declare function validateTransition($value: ValueNode, node: AnyNode, {
530
+ filename,
531
+ src,
532
+ logger
533
+ }: ValidateOptions): void;
534
+ /**
535
+ * Validate a MemberNode (the entire token object, plus its key in the parent
536
+ * object) to see if it’s a valid DTCG token or not. Keeping the parent key
537
+ * really helps in debug messages.
538
+ */
539
+ declare function validateTokenMemberNode(node: MemberNode, {
540
+ filename,
541
+ src,
542
+ logger
543
+ }: ValidateOptions): void;
544
+ /** Return any token node with its inherited $type */
545
+ declare function getInheritedType(node: MemberNode, {
546
+ subpath,
547
+ $typeInheritance
548
+ }: {
549
+ subpath: string[];
550
+ $typeInheritance?: Record<string, MemberNode>;
551
+ }): MemberNode | undefined;
552
+ interface ValidateTokenNodeOptions {
553
+ subpath: string[];
554
+ src: string;
555
+ filename: URL;
556
+ config: ConfigInit;
557
+ logger: Logger;
558
+ parent: AnyNode | undefined;
559
+ transform?: Visitors;
560
+ inheritedTypeNode?: MemberNode;
561
+ }
562
+ /**
563
+ * Validate does a little more than validate; it also converts to TokenNormalized
564
+ * and sets up the basic data structure. But aliases are unresolved, and we need
565
+ * a 2nd normalization pass afterward.
566
+ */
567
+ declare function validateTokenNode(node: MemberNode, {
568
+ config,
569
+ filename,
570
+ logger,
571
+ parent,
572
+ inheritedTypeNode,
573
+ src,
574
+ subpath
575
+ }: ValidateTokenNodeOptions): TokenNormalized$1 | undefined;
576
+ //# sourceMappingURL=validate.d.ts.map
577
+ //#endregion
578
+ //#region src/parse/alias.d.ts
579
+ interface ApplyAliasOptions {
580
+ tokensSet: TokenNormalizedSet$1;
581
+ filename: URL;
582
+ src: string;
583
+ node: ObjectNode;
584
+ logger: Logger;
585
+ }
586
+ type PreAliased<T extends TokenNormalized$1> = {
587
+ $value: T['$value'] | string;
588
+ mode: Record<string, T['mode'][string] & {
589
+ $value: T['$value'] | string;
590
+ }>;
591
+ };
592
+ /**
593
+ * Resolve aliases and update the token nodes.
594
+ *
595
+ * Data structures are in an awkward in-between phase, where they have
596
+ * placeholders for data but we still need to resolve everything. As such,
597
+ * TypeScript will raise errors expecting the final shape.
598
+ *
599
+ * This is also a bit tricky because different token types alias slightly
600
+ * differently. For example, color tokens and other “primitive” tokens behave
601
+ * as-expected. But composite tokens like Typography, Gradient, Border, etc. can
602
+ * either fully- or partially-alias their values. Then we add modes to the mix,
603
+ * and we have to do the work all over again for each mode declared.
604
+ *
605
+ * All that to say, there are a generous amount of TypeScript overrides here rather
606
+ * than try to codify indeterminate shapes.
607
+ */
608
+ //#endregion
609
+ //#region src/parse/json.d.ts
610
+ interface JSONVisitor {
611
+ enter?: (node: AnyNode, parent: AnyNode | undefined, path: string[]) => void;
612
+ exit?: (node: AnyNode, parent: AnyNode | undefined, path: string[]) => void;
613
+ }
614
+ declare const CHILD_KEYS: {
615
+ Document: readonly ["body"];
616
+ Object: readonly ["members"];
617
+ Member: readonly ["name", "value"];
618
+ Element: readonly ["value"];
619
+ Array: readonly ["elements"];
620
+ String: readonly [];
621
+ Number: readonly [];
622
+ Boolean: readonly [];
623
+ Null: readonly [];
624
+ Identifier: readonly [];
625
+ NaN: readonly [];
626
+ Infinity: readonly [];
627
+ };
628
+ /** Determines if a given value is an AST node. */
629
+ declare function isNode(value: unknown): boolean;
630
+ type ValueNodeWithIndex = ValueNode & {
631
+ index: number;
632
+ };
633
+ /** Get ObjectNode members as object */
634
+ declare function getObjMembers(node: ObjectNode): Record<string | number, ValueNodeWithIndex>;
635
+ /** Inject members to ObjectNode */
636
+ declare function injectObjMembers(node: ObjectNode, members?: MemberNode[]): void;
637
+ /** Replace an ObjectNode’s contents outright with another */
638
+ declare function replaceObjMembers(a: ObjectNode, b: DocumentNode | ObjectNode): void;
639
+ /**
640
+ * Variation of Momoa’s traverse(), which keeps track of global path.
641
+ * Allows mutation of AST (along with any consequences)
642
+ */
643
+ declare function traverse(root: AnyNode, visitor: JSONVisitor): void;
644
+ /** Determine if an input is likely a JSON string */
645
+ declare function maybeRawJSON(input: string): boolean;
646
+ /** Find Momoa node by traversing paths */
647
+ declare function findNode<T = AnyNode>(node: AnyNode, path: string[]): T | undefined;
648
+ interface ToMomoaOptions {
649
+ filename?: URL;
650
+ continueOnError?: boolean;
651
+ logger: Logger;
652
+ yamlToMomoa?: typeof ytm;
653
+ }
654
+ declare function toMomoa(input: string | Record<string, any>, {
655
+ continueOnError,
656
+ filename,
657
+ logger,
658
+ yamlToMomoa: ytm
659
+ }: ToMomoaOptions): InputSource;
660
+ /** Momoa, just with default options pre-set */
661
+ declare function parseJSON(input: string | Record<string, any>, options?: ParseOptions$1): any;
662
+ //# sourceMappingURL=json.d.ts.map
663
+ //#endregion
664
+ //#region src/parse/index.d.ts
665
+ interface ParseOptions {
666
+ logger?: Logger;
667
+ config: ConfigInit;
668
+ /**
669
+ * Skip lint step
670
+ * @default false
671
+ */
672
+ skipLint?: boolean;
673
+ /**
674
+ * Continue on error? (Useful for `tz check`)
675
+ * @default false
676
+ */
677
+ continueOnError?: boolean;
678
+ /** Provide yamlToMomoa module to parse YAML (by default, this isn’t shipped to cut down on package weight) */
679
+ yamlToMomoa?: typeof ytm;
680
+ /**
681
+ * Transform API
682
+ * @see https://terrazzo.app/docs/api/js#transform-api
683
+ */
684
+ transform?: Visitors;
685
+ /** (internal cache; do not use) */
686
+ _sources?: Record<string, InputSource>;
687
+ }
688
+ interface ParseResult {
689
+ tokens: Record<string, TokenNormalized$1>;
690
+ sources: InputSource[];
691
+ }
692
+ /** Parse */
693
+ declare function parse(_input: Omit<InputSource, 'document'> | Omit<InputSource, 'document'>[], {
694
+ logger,
695
+ skipLint,
696
+ config,
697
+ continueOnError,
698
+ yamlToMomoa,
699
+ transform,
700
+ _sources
701
+ }?: ParseOptions): Promise<ParseResult>;
702
+ //# sourceMappingURL=index.d.ts.map
703
+
704
+ //#endregion
705
+ 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
706
  //# sourceMappingURL=index.d.ts.map