@terrazzo/parser 2.0.0-beta.2 → 2.0.0-beta.4

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.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["rule","rule","ERROR_COLOR","ERROR_BORDER","ERROR_GRADIENT","ERROR_SHADOW","rule","rule","rule","rule","rule","rule","rule","ERROR","rule","rule","ERROR","rule","ERROR","rule","ERROR_MISSING","ERROR_INVALID_PROP","rule","ERROR","rule","rule","ERROR","ERROR_INVALID_PROP","rule","ERROR","rule","ERROR_INVALID_PROP","rule","ERROR","ERROR_INVALID_PROP","rule","ERROR","rule","ERROR","rule","ERROR","ERROR_INVALID_PROP","rule","ERROR_INVALID_PROP","rule","rule","ERROR_FORMAT","ERROR_INVALID_PROP","ERROR_LEGACY","ERROR_UNIT","ERROR_VALUE","rule","validColor","validDimension","validFontFamily","validFontWeight","validDuration","validCubicBezier","validNumber","validLink","validBoolean","validString","validStrokeStyle","validBorder","validTransition","validShadow","validGradient","validTypography","colorspace","consistentNaming","descriptions","duplicateValues","maxGamut","requiredChildren","requiredModes","requiredType","requiredTypographyProperties","a11yMinContrast","a11yMinFontSize"],"sources":["../src/lib/code-frame.ts","../src/logger.ts","../src/build/index.ts","../src/lint/plugin-core/lib/docs.ts","../src/lint/plugin-core/rules/a11y-min-contrast.ts","../src/lint/plugin-core/rules/a11y-min-font-size.ts","../src/lint/plugin-core/rules/colorspace.ts","../src/lint/plugin-core/rules/consistent-naming.ts","../src/lint/plugin-core/rules/descriptions.ts","../src/lint/plugin-core/rules/duplicate-values.ts","../src/lint/plugin-core/rules/max-gamut.ts","../src/lint/plugin-core/rules/required-children.ts","../src/lint/plugin-core/rules/required-modes.ts","../src/lint/plugin-core/rules/required-type.ts","../src/lint/plugin-core/rules/required-typography-properties.ts","../src/lint/plugin-core/rules/valid-font-family.ts","../src/lint/plugin-core/rules/valid-font-weight.ts","../src/lint/plugin-core/rules/valid-gradient.ts","../src/lint/plugin-core/rules/valid-link.ts","../src/lint/plugin-core/rules/valid-number.ts","../src/lint/plugin-core/rules/valid-shadow.ts","../src/lint/plugin-core/rules/valid-string.ts","../src/lint/plugin-core/rules/valid-stroke-style.ts","../src/lint/plugin-core/rules/valid-transition.ts","../src/lint/plugin-core/rules/valid-typography.ts","../src/lint/plugin-core/rules/valid-boolean.ts","../src/lint/plugin-core/rules/valid-border.ts","../src/lint/plugin-core/rules/valid-color.ts","../src/lint/plugin-core/rules/valid-cubic-bezier.ts","../src/lint/plugin-core/rules/valid-dimension.ts","../src/lint/plugin-core/rules/valid-duration.ts","../src/lint/plugin-core/index.ts","../src/config.ts","../src/lint/index.ts","../src/lib/momoa.ts","../src/lib/resolver-utils.ts","../src/parse/assert.ts","../src/parse/normalize.ts","../src/parse/token.ts","../src/parse/process.ts","../src/resolver/normalize.ts","../src/resolver/validate.ts","../src/resolver/load.ts","../src/resolver/create-synthetic-resolver.ts","../src/parse/load.ts","../src/parse/index.ts"],"sourcesContent":["// This is copied from @babel/code-frame package but without the heavyweight color highlighting\n// (note: Babel loads both chalk AND picocolors, and doesn’t treeshake well)\n// Babel is MIT-licensed and unaffiliated with this project.\n\n// MIT License\n//\n// Copyright (c) 2014-present Sebastian McKenzie and other contributors\n//\n// Permission is hereby granted, free of charge, to any person obtaining\n// a copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to\n// permit persons to whom the Software is furnished to do so, subject to\n// the following conditions:\n//\n// The above copyright notice and this permission notice shall be\n// included in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nexport interface Location {\n line: number;\n column: number;\n}\n\nexport interface NodeLocation {\n end?: Location;\n start: Location;\n}\n\nexport interface Options {\n /** Syntax highlight the code as JavaScript for terminals. default: false */\n highlightCode?: boolean;\n /** The number of lines to show above the error. default: 2 */\n linesAbove?: number;\n /** The number of lines to show below the error. default: 3 */\n linesBelow?: number;\n /**\n * Forcibly syntax highlight the code as JavaScript (for non-terminals);\n * overrides highlightCode.\n * default: false\n */\n forceColor?: boolean;\n /**\n * Pass in a string to be displayed inline (if possible) next to the\n * highlighted location in the code. If it can't be positioned inline,\n * it will be placed above the code frame.\n * default: nothing\n */\n message?: string;\n}\n\n/**\n * Extract what lines should be marked and highlighted.\n */\nfunction getMarkerLines(loc: NodeLocation, source: string[], opts: Options = {} as Options) {\n const startLoc = {\n // @ts-expect-error this is fine\n column: 0,\n // @ts-expect-error this is fine\n line: -1,\n ...loc.start,\n } as Location;\n const endLoc: Location = {\n ...startLoc,\n ...loc.end,\n };\n const { linesAbove = 2, linesBelow = 3 } = opts || {};\n const startLine = startLoc.line;\n const startColumn = startLoc.column;\n const endLine = endLoc.line;\n const endColumn = endLoc.column;\n\n let start = Math.max(startLine - (linesAbove + 1), 0);\n let end = Math.min(source.length, endLine + linesBelow);\n\n if (startLine === -1) {\n start = 0;\n }\n\n if (endLine === -1) {\n end = source.length;\n }\n\n const lineDiff = endLine - startLine;\n const markerLines: Record<string, any> = {};\n\n if (lineDiff) {\n for (let i = 0; i <= lineDiff; i++) {\n const lineNumber = i + startLine;\n\n if (!startColumn) {\n markerLines[lineNumber] = true;\n } else if (i === 0) {\n const sourceLength = source[lineNumber - 1]!.length;\n\n markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];\n } else if (i === lineDiff) {\n markerLines[lineNumber] = [0, endColumn];\n } else {\n const sourceLength = source[lineNumber - i]!.length;\n\n markerLines[lineNumber] = [0, sourceLength];\n }\n }\n } else {\n if (startColumn === endColumn) {\n if (startColumn) {\n markerLines[startLine] = [startColumn, 0];\n } else {\n markerLines[startLine] = true;\n }\n } else {\n markerLines[startLine] = [startColumn, endColumn - startColumn];\n }\n }\n\n return { start, end, markerLines };\n}\n\n/**\n * RegExp to test for newlines in terminal.\n */\n\nconst NEWLINE = /\\r\\n|[\\n\\r\\u2028\\u2029]/;\n\nexport function codeFrameColumns(rawLines: string, loc: NodeLocation, opts: Options = {} as Options) {\n if (typeof rawLines !== 'string') {\n throw new Error(`Expected string, got ${rawLines}`);\n }\n const lines = rawLines.split(NEWLINE);\n const { start, end, markerLines } = getMarkerLines(loc, lines, opts);\n const hasColumns = loc.start && typeof loc.start.column === 'number';\n\n const numberMaxWidth = String(end).length;\n\n let frame = rawLines\n .split(NEWLINE, end)\n .slice(start, end)\n .map((line, index) => {\n const number = start + 1 + index;\n const paddedNumber = ` ${number}`.slice(-numberMaxWidth);\n const gutter = ` ${paddedNumber} |`;\n const hasMarker = markerLines[number];\n const lastMarkerLine = !markerLines[number + 1];\n if (hasMarker) {\n let markerLine = '';\n if (Array.isArray(hasMarker)) {\n const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\\t]/g, ' ');\n const numberOfMarkers = hasMarker[1] || 1;\n\n markerLine = ['\\n ', gutter.replace(/\\d/g, ' '), ' ', markerSpacing, '^'.repeat(numberOfMarkers)].join('');\n\n if (lastMarkerLine && opts.message) {\n markerLine += ` ${opts.message}`;\n }\n }\n return ['>', gutter, line.length > 0 ? ` ${line}` : '', markerLine].join('');\n } else {\n return ` ${gutter}${line.length > 0 ? ` ${line}` : ''}`;\n }\n })\n .join('\\n');\n\n if (opts.message && !hasColumns) {\n frame = `${' '.repeat(numberMaxWidth + 1)}${opts.message}\\n${frame}`;\n }\n\n return frame;\n}\n","import * as momoa from '@humanwhocodes/momoa';\nimport pc from 'picocolors';\nimport wcmatch from 'wildcard-match';\nimport { codeFrameColumns } from './lib/code-frame.js';\n\nexport const LOG_ORDER = ['error', 'warn', 'info', 'debug'] as const;\nexport type LogSeverity = 'error' | 'warn' | 'info' | 'debug';\nexport type LogLevel = LogSeverity | 'silent';\nexport type LogGroup = 'config' | 'parser' | 'resolver' | 'lint' | 'plugin' | 'server';\n\nexport interface LogEntry {\n /** Originator of log message */\n group: LogGroup;\n /** Error message to be logged */\n message: string;\n /** Prefix message with label */\n label?: string;\n /** File in disk */\n filename?: URL;\n /**\n * Continue on error?\n * @default false\n */\n continueOnError?: boolean;\n /** Show a code frame for the erring node */\n node?: momoa.AnyNode;\n /** To show a code frame, provide the original source code */\n src?: string;\n /** Display performance timing */\n timing?: number;\n}\n\nexport interface DebugEntry {\n group: LogGroup;\n /** Error message to be logged */\n message: string;\n /** Current subtask or submodule */\n label?: string;\n /** Show code below message */\n codeFrame?: { src: string; line: number; column: number };\n /** Display performance timing */\n timing?: number;\n}\n\nconst MESSAGE_COLOR: Record<string, typeof pc.red | undefined> = { error: pc.red, warn: pc.yellow };\n\nconst timeFormatter = new Intl.DateTimeFormat('en-us', {\n hour: 'numeric',\n hour12: false,\n minute: 'numeric',\n second: 'numeric',\n fractionalSecondDigits: 3,\n});\n\n/**\n * @param {Entry} entry\n * @param {Severity} severity\n * @return {string}\n */\nexport function formatMessage(entry: LogEntry, severity: LogSeverity) {\n let message = entry.message;\n message = `[${entry.group}${entry.label ? `:${entry.label}` : ''}] ${message}`;\n if (severity in MESSAGE_COLOR) {\n message = MESSAGE_COLOR[severity]!(message);\n }\n if (typeof entry.timing === 'number') {\n message = `${message} ${formatTiming(entry.timing)}`;\n }\n if (entry.node) {\n const start = entry.node?.loc?.start ?? { line: 0, column: 0 };\n // strip \"file://\" protocol, but not href\n const loc = entry.filename\n ? `${entry.filename?.href.replace(/^file:\\/\\//, '')}:${start?.line ?? 0}:${start?.column ?? 0}\\n\\n`\n : '';\n const codeFrame = codeFrameColumns(\n entry.src ?? momoa.print(entry.node, { indent: 2 }),\n { start },\n { highlightCode: false },\n );\n message = `${message}\\n\\n${loc}${codeFrame}`;\n }\n return message;\n}\n\nexport default class Logger {\n level = 'info' as LogLevel;\n debugScope = '*';\n errorCount = 0;\n warnCount = 0;\n infoCount = 0;\n debugCount = 0;\n\n constructor(options?: { level?: LogLevel; debugScope?: string }) {\n if (options?.level) {\n this.level = options.level;\n }\n if (options?.debugScope) {\n this.debugScope = options.debugScope;\n }\n }\n\n setLevel(level: LogLevel) {\n this.level = level;\n }\n\n /** Log an error message (always; can’t be silenced) */\n error(...entries: LogEntry[]) {\n const message: string[] = [];\n let firstNode: momoa.AnyNode | undefined;\n for (const entry of entries) {\n this.errorCount++;\n message.push(formatMessage(entry, 'error'));\n if (entry.node) {\n firstNode = entry.node;\n }\n }\n if (entries.every((e) => e.continueOnError)) {\n // biome-ignore lint/suspicious/noConsole: this is a logger\n console.error(message.join('\\n\\n'));\n } else {\n const e = firstNode ? new TokensJSONError(message.join('\\n\\n')) : new Error(message.join('\\n\\n'));\n throw e;\n }\n }\n\n /** Log an info message (if logging level permits) */\n info(...entries: LogEntry[]) {\n for (const entry of entries) {\n this.infoCount++;\n if (this.level === 'silent' || LOG_ORDER.indexOf(this.level) < LOG_ORDER.indexOf('info')) {\n return;\n }\n const message = formatMessage(entry, 'info');\n // biome-ignore lint/suspicious/noConsole: this is a logger\n console.log(message);\n }\n }\n\n /** Log a warning message (if logging level permits) */\n warn(...entries: LogEntry[]) {\n for (const entry of entries) {\n this.warnCount++;\n if (this.level === 'silent' || LOG_ORDER.indexOf(this.level) < LOG_ORDER.indexOf('warn')) {\n return;\n }\n const message = formatMessage(entry, 'warn');\n\n // biome-ignore lint/suspicious/noConsole: this is a logger\n console.warn(message);\n }\n }\n\n /** Log a diagnostics message (if logging level permits) */\n debug(...entries: DebugEntry[]) {\n for (const entry of entries) {\n if (this.level === 'silent' || LOG_ORDER.indexOf(this.level) < LOG_ORDER.indexOf('debug')) {\n return;\n }\n this.debugCount++;\n\n let message = formatMessage(entry, 'debug');\n\n const debugPrefix = entry.label ? `${entry.group}:${entry.label}` : entry.group;\n if (this.debugScope !== '*' && !wcmatch(this.debugScope)(debugPrefix)) {\n return;\n }\n\n // debug color\n message\n .replace(/\\[config[^\\]]+\\]/, (match) => pc.green(match))\n .replace(/\\[parser[^\\]]+\\]/, (match) => pc.magenta(match))\n .replace(/\\[lint[^\\]]+\\]/, (match) => pc.yellow(match))\n .replace(/\\[plugin[^\\]]+\\]/, (match) => pc.cyan(match));\n\n message = `${pc.dim(timeFormatter.format(performance.now()))} ${message}`;\n if (typeof entry.timing === 'number') {\n message = `${message} ${formatTiming(entry.timing)}`;\n }\n\n // biome-ignore lint/suspicious/noConsole: this is a logger\n console.log(message);\n }\n }\n\n /** Get stats for current logger instance */\n stats() {\n return {\n errorCount: this.errorCount,\n warnCount: this.warnCount,\n infoCount: this.infoCount,\n debugCount: this.debugCount,\n };\n }\n}\n\nfunction formatTiming(timing: number): string {\n let output = '';\n if (timing < 1_000) {\n output = `${Math.round(timing * 100) / 100}ms`;\n } else if (timing < 60_000) {\n output = `${Math.round(timing) / 1_000}s`;\n } else {\n output = `${Math.round(timing / 1_000) / 60}m`;\n }\n return pc.dim(`[${output}]`);\n}\n\nexport class TokensJSONError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'TokensJSONError';\n }\n}\n","import type { InputSourceWithDocument } from '@terrazzo/json-schema-tools';\nimport type { TokenNormalized } from '@terrazzo/token-tools';\nimport wcmatch from 'wildcard-match';\nimport Logger, { type LogEntry } from '../logger.js';\nimport type { BuildRunnerResult, ConfigInit, Resolver, TokenTransformed, TransformParams } from '../types.js';\n\nexport interface BuildRunnerOptions {\n sources: InputSourceWithDocument[];\n config: ConfigInit;\n resolver: Resolver;\n logger?: Logger;\n}\nexport const SINGLE_VALUE = 'SINGLE_VALUE';\nexport const MULTI_VALUE = 'MULTI_VALUE';\n\n/** Validate plugin setTransform() calls for immediate feedback */\nfunction validateTransformParams({\n params,\n logger,\n pluginName,\n}: {\n params: TokenTransformed;\n logger: Logger;\n pluginName: string;\n}): void {\n const baseMessage: LogEntry = { group: 'plugin', label: pluginName, message: '' };\n\n // validate value is valid for SINGLE_VALUE or MULTI_VALUE\n if (\n !params.value ||\n (typeof params.value !== 'string' && typeof params.value !== 'object') ||\n Array.isArray(params.value)\n ) {\n logger.error({\n ...baseMessage,\n message: `setTransform() value expected string or object of strings, received ${\n Array.isArray(params.value) ? 'Array' : typeof params.value\n }`,\n });\n }\n if (typeof params.value === 'object' && Object.values(params.value).some((v) => typeof v !== 'string')) {\n logger.error({\n ...baseMessage,\n message: 'setTransform() value expected object of strings, received some non-string values',\n });\n }\n}\n\nconst FALLBACK_PERMUTATION_ID = JSON.stringify({ tzMode: '*' });\n\n/** Run build stage */\nexport default async function build(\n tokens: Record<string, TokenNormalized>,\n { resolver, sources, logger = new Logger(), config }: BuildRunnerOptions,\n): Promise<BuildRunnerResult> {\n const formats: Record<string, { [permutationID: string]: TokenTransformed[] }> = {};\n const result: BuildRunnerResult = { outputFiles: [] };\n\n function getTransforms(plugin: string) {\n return function getTransforms(params: TransformParams) {\n if (!params?.format) {\n logger.warn({\n group: 'plugin',\n label: plugin,\n message: '\"format\" missing from getTransforms(), no tokens returned.',\n });\n return [];\n }\n\n const tokenMatcher = params.id && params.id !== '*' ? wcmatch(params.id) : null;\n const modeMatcher = params.mode ? wcmatch(params.mode) : null;\n const permutationID = params.input ? resolver.getPermutationID(params.input) : JSON.stringify({ tzMode: '*' });\n\n return (formats[params.format!]?.[permutationID] ?? []).filter((token) => {\n if (params.$type) {\n if (typeof params.$type === 'string' && token.token.$type !== params.$type) {\n return false;\n } else if (Array.isArray(params.$type) && !params.$type.some(($type) => token.token.$type === $type)) {\n return false;\n }\n }\n if (tokenMatcher && !tokenMatcher(token.token.id)) {\n return false;\n }\n if (params.input && token.permutationID !== resolver.getPermutationID(params.input)) {\n return false;\n }\n if (modeMatcher && !modeMatcher(token.mode)) {\n return false;\n }\n return true;\n });\n };\n }\n\n // transform()\n let transformsLocked = false; // prevent plugins from transforming after stage has ended\n const startTransform = performance.now();\n for (const plugin of config.plugins) {\n if (typeof plugin.transform === 'function') {\n await plugin.transform({\n context: { logger },\n tokens,\n sources,\n getTransforms: getTransforms(plugin.name),\n setTransform(id, params) {\n if (transformsLocked) {\n logger.warn({\n message: 'Attempted to call setTransform() after transform step has completed.',\n group: 'plugin',\n label: plugin.name,\n });\n return;\n }\n const token = tokens[id]!;\n const permutationID = params.input ? resolver.getPermutationID(params.input) : FALLBACK_PERMUTATION_ID;\n const cleanValue: TokenTransformed['value'] =\n typeof params.value === 'string' ? params.value : { ...(params.value as Record<string, string>) };\n validateTransformParams({\n logger,\n params: { ...(params as any), value: cleanValue },\n pluginName: plugin.name,\n });\n\n // upsert\n if (!formats[params.format]) {\n formats[params.format] = {};\n }\n if (!formats[params.format]![permutationID]) {\n formats[params.format]![permutationID] = [];\n }\n let foundTokenI = -1;\n if (params.mode) {\n foundTokenI = formats[params.format]![permutationID]!.findIndex(\n (t) => id === t.id && (!params.localID || params.localID === t.localID) && params.mode === t.mode,\n );\n } else if (params.input) {\n if (!formats[params.format]![permutationID]) {\n formats[params.format]![permutationID] = [];\n }\n foundTokenI = formats[params.format]![permutationID]!.findIndex(\n (t) =>\n id === t.id && (!params.localID || params.localID === t.localID) && permutationID === t.permutationID,\n );\n } else {\n foundTokenI = formats[params.format]![permutationID]!.findIndex(\n (t) => id === t.id && (!params.localID || params.localID === t.localID),\n );\n }\n if (foundTokenI === -1) {\n // backwards compat: upconvert mode into \"tzMode\" modifier. This\n // allows newer plugins to use resolver syntax without disrupting\n // older plugins.\n formats[params.format]![permutationID]!.push({\n ...params,\n id,\n value: cleanValue,\n type: typeof cleanValue === 'string' ? SINGLE_VALUE : MULTI_VALUE,\n mode: params.mode || '.',\n token: structuredClone(token),\n permutationID,\n input: JSON.parse(permutationID),\n } as TokenTransformed);\n } else {\n formats[params.format]![permutationID]![foundTokenI]!.value = cleanValue;\n formats[params.format]![permutationID]![foundTokenI]!.type =\n typeof cleanValue === 'string' ? SINGLE_VALUE : MULTI_VALUE;\n }\n },\n resolver,\n });\n }\n }\n transformsLocked = true;\n logger.debug({\n group: 'parser',\n label: 'transform',\n message: 'transform() step',\n timing: performance.now() - startTransform,\n });\n\n // build()\n const startBuild = performance.now();\n await Promise.all(\n config.plugins.map(async (plugin) => {\n if (typeof plugin.build === 'function') {\n const pluginBuildStart = performance.now();\n await plugin.build({\n context: { logger },\n tokens,\n sources,\n getTransforms: getTransforms(plugin.name),\n resolver,\n outputFile(filename, contents) {\n const resolved = new URL(filename, config.outDir);\n if (result.outputFiles.some((f) => new URL(f.filename, config.outDir).href === resolved.href)) {\n logger.error({\n group: 'plugin',\n message: `Can’t overwrite file \"${filename}\"`,\n label: plugin.name,\n });\n }\n result.outputFiles.push({\n filename,\n contents,\n plugin: plugin.name,\n time: performance.now() - pluginBuildStart,\n });\n },\n });\n }\n }),\n );\n logger.debug({\n group: 'parser',\n label: 'build',\n message: 'build() step',\n timing: performance.now() - startBuild,\n });\n\n // buildEnd()\n const startBuildEnd = performance.now();\n await Promise.all(\n config.plugins.map(async (plugin) =>\n plugin.buildEnd?.({\n context: { logger },\n tokens,\n getTransforms: getTransforms(plugin.name),\n sources,\n outputFiles: structuredClone(result.outputFiles),\n }),\n ),\n );\n logger.debug({\n group: 'parser',\n label: 'build',\n message: 'buildEnd() step',\n timing: performance.now() - startBuildEnd,\n });\n\n return result;\n}\n","export function docsLink(ruleName: string): string {\n return `https://terrazzo.app/docs/linting#${ruleName.replaceAll('/', '')}`;\n}\n","import { tokenToColor } from '@terrazzo/token-tools';\nimport { contrastWCAG21 } from 'colorjs.io/fn';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const A11Y_MIN_CONTRAST = 'a11y/min-contrast';\n\nexport interface RuleA11yMinContrastOptions {\n /**\n * Whether to adhere to AA (minimum) or AAA (enhanced) contrast levels.\n * @default \"AA\"\n */\n level?: 'AA' | 'AAA';\n /** Pairs of color tokens (and optionally typography) to test */\n pairs: ContrastPair[];\n}\n\nexport interface ContrastPair {\n /** The foreground color token ID */\n foreground: string;\n /** The background color token ID */\n background: string;\n /**\n * Is this pair for large text? Large text allows a smaller contrast ratio.\n *\n * Note: while WCAG has _suggested_ sizes and weights, those are merely\n * suggestions. It’s always more reliable to determine what constitutes “large\n * text” for your designs yourself, based on your typographic stack.\n * @see https://www.w3.org/WAI/WCAG22/quickref/#contrast-minimum\n */\n largeText?: boolean;\n}\n\nexport const WCAG2_MIN_CONTRAST = {\n AA: { default: 4.5, large: 3 },\n AAA: { default: 7, large: 4.5 },\n};\n\nexport const ERROR_INSUFFICIENT_CONTRAST = 'INSUFFICIENT_CONTRAST';\n\nconst rule: LintRule<typeof ERROR_INSUFFICIENT_CONTRAST, RuleA11yMinContrastOptions> = {\n meta: {\n messages: {\n [ERROR_INSUFFICIENT_CONTRAST]: 'Pair {{ index }} failed; expected {{ expected }}, got {{ actual }} ({{ level }})',\n },\n docs: {\n description: 'Enforce colors meet minimum contrast checks for WCAG 2.',\n url: docsLink(A11Y_MIN_CONTRAST),\n },\n },\n defaultOptions: { level: 'AA', pairs: [] },\n create({ tokens, options, report }) {\n for (let i = 0; i < options.pairs.length; i++) {\n const { foreground, background, largeText } = options.pairs[i]!;\n if (!tokens[foreground]) {\n throw new Error(`Token ${foreground} does not exist`);\n }\n if (tokens[foreground].$type !== 'color') {\n throw new Error(`Token ${foreground} isn’t a color`);\n }\n if (!tokens[background]) {\n throw new Error(`Token ${background} does not exist`);\n }\n if (tokens[background].$type !== 'color') {\n throw new Error(`Token ${background} isn’t a color`);\n }\n\n // Note: if these culors were unparseable, they would have already thrown an error before the linter\n const a = tokenToColor(tokens[foreground].$value)!;\n const b = tokenToColor(tokens[background].$value)!;\n\n // Note: for the purposes of WCAG 2, foreground and background don’t\n // matter. But in other contrast algorithms, they do.\n const contrast = contrastWCAG21(a, b);\n const min = WCAG2_MIN_CONTRAST[options.level ?? 'AA'][largeText ? 'large' : 'default'];\n if (contrast < min) {\n report({\n messageId: ERROR_INSUFFICIENT_CONTRAST,\n data: {\n index: i + 1,\n expected: min,\n actual: Math.round(contrast * 100) / 100,\n level: options.level,\n },\n });\n }\n }\n },\n};\n\nexport default rule;\n","import wcmatch from 'wildcard-match';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const A11Y_MIN_FONT_SIZE = 'a11y/min-font-size';\n\nexport interface RuleA11yMinFontSizeOptions {\n /** Minimum font size (pixels) */\n minSizePx?: number;\n /** Minimum font size (rems) */\n minSizeRem?: number;\n /** Token IDs to ignore. Accepts globs. */\n ignore?: string[];\n}\n\nexport const ERROR_TOO_SMALL = 'TOO_SMALL';\n\nconst rule: LintRule<typeof ERROR_TOO_SMALL, RuleA11yMinFontSizeOptions> = {\n meta: {\n messages: {\n [ERROR_TOO_SMALL]: '{{ id }} font size too small. Expected minimum of {{ min }}',\n },\n docs: {\n description: 'Enforce font sizes are no smaller than the given value.',\n url: docsLink(A11Y_MIN_FONT_SIZE),\n },\n },\n defaultOptions: {},\n create({ tokens, options, report }) {\n if (!options.minSizePx && !options.minSizeRem) {\n throw new Error('Must specify at least one of minSizePx or minSizeRem');\n }\n\n const shouldIgnore = options.ignore ? wcmatch(options.ignore) : null;\n\n for (const t of Object.values(tokens)) {\n if (shouldIgnore?.(t.id)) {\n continue;\n }\n\n // skip aliases\n if (t.aliasOf) {\n continue;\n }\n\n if (t.$type === 'typography' && 'fontSize' in t.$value) {\n const fontSize = t.$value.fontSize!;\n\n if (\n (fontSize.unit === 'px' && options.minSizePx && fontSize.value < options.minSizePx) ||\n (fontSize.unit === 'rem' && options.minSizeRem && fontSize.value < options.minSizeRem)\n ) {\n report({\n messageId: ERROR_TOO_SMALL,\n data: {\n id: t.id,\n min: options.minSizePx ? `${options.minSizePx}px` : `${options.minSizeRem}rem`,\n },\n });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type { ColorValueNormalized } from '@terrazzo/token-tools';\nimport wcmatch from 'wildcard-match';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const COLORSPACE = 'core/colorspace';\n\nexport interface RuleColorspaceOptions {\n colorSpace: ColorValueNormalized['colorSpace'];\n /** (optional) Token IDs to ignore. Supports globs (`*`). */\n ignore?: string[];\n}\n\nconst ERROR_COLOR = 'COLOR';\nconst ERROR_BORDER = 'BORDER';\nconst ERROR_GRADIENT = 'GRADIENT';\nconst ERROR_SHADOW = 'SHADOW';\n\nconst rule: LintRule<\n typeof ERROR_COLOR | typeof ERROR_BORDER | typeof ERROR_GRADIENT | typeof ERROR_SHADOW,\n RuleColorspaceOptions\n> = {\n meta: {\n messages: {\n [ERROR_COLOR]: 'Color {{ id }} not in colorspace {{ colorSpace }}',\n [ERROR_BORDER]: 'Border {{ id }} not in colorspace {{ colorSpace }}',\n [ERROR_GRADIENT]: 'Gradient {{ id }} not in colorspace {{ colorSpace }}',\n [ERROR_SHADOW]: 'Shadow {{ id }} not in colorspace {{ colorSpace }}',\n },\n docs: {\n description: 'Enforce that all colors are in a specific colorspace.',\n url: docsLink(COLORSPACE),\n },\n },\n defaultOptions: { colorSpace: 'srgb' },\n create({ tokens, options, report }) {\n if (!options.colorSpace) {\n return;\n }\n\n const shouldIgnore = options.ignore ? wcmatch(options.ignore) : null;\n\n for (const t of Object.values(tokens)) {\n // skip ignored tokens\n if (shouldIgnore?.(t.id)) {\n continue;\n }\n\n // skip aliases\n if (t.aliasOf) {\n continue;\n }\n\n switch (t.$type) {\n case 'color': {\n if (t.$value.colorSpace !== options.colorSpace) {\n report({\n messageId: ERROR_COLOR,\n data: { id: t.id, colorSpace: options.colorSpace },\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n break;\n }\n case 'border': {\n if (!t.partialAliasOf?.color && t.$value.color.colorSpace !== options.colorSpace) {\n report({\n messageId: ERROR_BORDER,\n data: { id: t.id, colorSpace: options.colorSpace },\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n break;\n }\n case 'gradient': {\n for (let stopI = 0; stopI < t.$value.length; stopI++) {\n if (!t.partialAliasOf?.[stopI]?.color && t.$value[stopI]!.color.colorSpace !== options.colorSpace) {\n report({\n messageId: ERROR_GRADIENT,\n data: { id: t.id, colorSpace: options.colorSpace },\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n }\n break;\n }\n case 'shadow': {\n for (let shadowI = 0; shadowI < t.$value.length; shadowI++) {\n if (!t.partialAliasOf?.[shadowI]?.color && t.$value[shadowI]!.color.colorSpace !== options.colorSpace) {\n report({\n messageId: ERROR_SHADOW,\n data: { id: t.id, colorSpace: options.colorSpace },\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n }\n break;\n }\n }\n }\n },\n};\n\nexport default rule;\n","import { camelCase, kebabCase, pascalCase, snakeCase } from 'scule';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const CONSISTENT_NAMING = 'core/consistent-naming';\nexport const ERROR_WRONG_FORMAT = 'ERROR_WRONG_FORMAT';\n\nexport interface RuleConsistentNamingOptions {\n /** Specify format, or custom naming validator */\n format:\n | 'kebab-case'\n | 'camelCase'\n | 'PascalCase'\n | 'snake_case'\n | 'SCREAMING_SNAKE_CASE'\n | ((tokenID: string) => boolean);\n /** Token IDs to ignore. Supports globs (`*`). */\n ignore?: string[];\n}\n\nconst rule: LintRule<typeof ERROR_WRONG_FORMAT, RuleConsistentNamingOptions> = {\n meta: {\n messages: {\n [ERROR_WRONG_FORMAT]: '{{ id }} doesn’t match format {{ format }}',\n },\n docs: {\n description: 'Enforce consistent naming for tokens.',\n url: docsLink(CONSISTENT_NAMING),\n },\n },\n defaultOptions: { format: 'kebab-case' },\n create({ tokens, options, report }) {\n const basicFormatter = {\n 'kebab-case': kebabCase,\n camelCase,\n PascalCase: pascalCase,\n snake_case: snakeCase,\n SCREAMING_SNAKE_CASE: (name: string) => snakeCase(name).toLocaleUpperCase(),\n }[String(options.format)];\n\n for (const t of Object.values(tokens)) {\n if (basicFormatter) {\n const parts = t.id.split('.');\n if (!parts.every((part) => basicFormatter(part) === part)) {\n report({\n messageId: ERROR_WRONG_FORMAT,\n data: { id: t.id, format: options.format },\n node: t.source.node,\n });\n }\n } else if (typeof options.format === 'function') {\n const result = options.format(t.id);\n if (result) {\n report({\n messageId: ERROR_WRONG_FORMAT,\n data: { id: t.id, format: '(custom)' },\n node: t.source.node,\n });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import wcmatch from 'wildcard-match';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const DESCRIPTIONS = 'core/descriptions';\n\nexport interface RuleDescriptionsOptions {\n /** Token IDs to ignore. Supports globs (`*`). */\n ignore?: string[];\n}\n\nconst ERROR_MISSING_DESCRIPTION = 'MISSING_DESCRIPTION';\n\nconst rule: LintRule<typeof ERROR_MISSING_DESCRIPTION, RuleDescriptionsOptions> = {\n meta: {\n messages: {\n [ERROR_MISSING_DESCRIPTION]: '{{ id }} missing description',\n },\n docs: {\n description: 'Enforce tokens have descriptions.',\n url: docsLink(DESCRIPTIONS),\n },\n },\n defaultOptions: {},\n create({ tokens, options, report }) {\n const shouldIgnore = options.ignore ? wcmatch(options.ignore) : null;\n\n for (const t of Object.values(tokens)) {\n if (shouldIgnore?.(t.id)) {\n continue;\n }\n if (!t.$description) {\n report({\n messageId: ERROR_MISSING_DESCRIPTION,\n data: { id: t.id },\n node: t.source.node,\n });\n }\n }\n },\n};\n\nexport default rule;\n","import { isAlias } from '@terrazzo/token-tools';\nimport wcmatch from 'wildcard-match';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const DUPLICATE_VALUES = 'core/duplicate-values';\n\nexport interface RuleDuplicateValueOptions {\n /** Token IDs to ignore. Supports globs (`*`). */\n ignore?: string[];\n}\n\nconst ERROR_DUPLICATE_VALUE = 'ERROR_DUPLICATE_VALUE';\n\nconst rule: LintRule<typeof ERROR_DUPLICATE_VALUE, RuleDuplicateValueOptions> = {\n meta: {\n messages: {\n [ERROR_DUPLICATE_VALUE]: '{{ id }} declared a duplicate value',\n },\n docs: {\n description: 'Enforce tokens can’t redeclare the same value (excludes aliases).',\n url: docsLink(DUPLICATE_VALUES),\n },\n },\n defaultOptions: {},\n create({ report, tokens, options }) {\n const values: Record<string, Set<any>> = {};\n\n const shouldIgnore = options.ignore ? wcmatch(options.ignore) : null;\n\n for (const t of Object.values(tokens)) {\n // skip ignored tokens\n if (shouldIgnore?.(t.id)) {\n continue;\n }\n\n if (!values[t.$type]) {\n values[t.$type] = new Set();\n }\n\n // primitives: direct comparison is easy\n if (\n t.$type === 'boolean' ||\n t.$type === 'duration' ||\n t.$type === 'fontWeight' ||\n t.$type === 'link' ||\n t.$type === 'number' ||\n t.$type === 'string'\n ) {\n // skip aliases (note: $value will be resolved)\n if (typeof t.aliasOf === 'string' && isAlias(t.aliasOf)) {\n continue;\n }\n\n if (values[t.$type]?.has(t.$value)) {\n report({\n messageId: ERROR_DUPLICATE_VALUE,\n data: { id: t.id },\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n\n values[t.$type]?.add(t.$value);\n } else {\n // everything else: use deepEqual\n for (const v of values[t.$type]!.values() ?? []) {\n // TODO: don’t JSON.stringify\n if (JSON.stringify(t.$value) === JSON.stringify(v)) {\n report({\n messageId: ERROR_DUPLICATE_VALUE,\n data: { id: t.id },\n node: t.source.node,\n filename: t.source.filename,\n });\n break;\n }\n }\n values[t.$type]!.add(t.$value);\n }\n }\n },\n};\n\nexport default rule;\n","import { tokenToColor } from '@terrazzo/token-tools';\nimport { inGamut } from 'colorjs.io/fn';\nimport wcmatch from 'wildcard-match';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const MAX_GAMUT = 'core/max-gamut';\n\nexport interface RuleMaxGamutOptions {\n /** Gamut to constrain color tokens to. */\n gamut: 'srgb' | 'p3' | 'rec2020';\n /** (optional) Token IDs to ignore. Supports globs (`*`). */\n ignore?: string[];\n}\n\nconst ERROR_COLOR = 'COLOR';\nconst ERROR_BORDER = 'BORDER';\nconst ERROR_GRADIENT = 'GRADIENT';\nconst ERROR_SHADOW = 'SHADOW';\n\nconst rule: LintRule<\n typeof ERROR_COLOR | typeof ERROR_BORDER | typeof ERROR_GRADIENT | typeof ERROR_SHADOW,\n RuleMaxGamutOptions\n> = {\n meta: {\n messages: {\n [ERROR_COLOR]: 'Color {{ id }} is outside {{ gamut }} gamut',\n [ERROR_BORDER]: 'Border {{ id }} is outside {{ gamut }} gamut',\n [ERROR_GRADIENT]: 'Gradient {{ id }} is outside {{ gamut }} gamut',\n [ERROR_SHADOW]: 'Shadow {{ id }} is outside {{ gamut }} gamut',\n },\n docs: {\n description: 'Enforce colors are within the specified gamut.',\n url: docsLink(MAX_GAMUT),\n },\n },\n defaultOptions: { gamut: 'rec2020' },\n create({ tokens, options, report }) {\n if (!options?.gamut) {\n return;\n }\n if (options.gamut !== 'srgb' && options.gamut !== 'p3' && options.gamut !== 'rec2020') {\n throw new Error(`Unknown gamut \"${options.gamut}\". Options are \"srgb\", \"p3\", or \"rec2020\"`);\n }\n\n const shouldIgnore = options.ignore ? wcmatch(options.ignore) : null;\n\n for (const t of Object.values(tokens)) {\n // skip ignored tokens\n if (shouldIgnore?.(t.id)) {\n continue;\n }\n\n // skip aliases\n if (t.aliasOf) {\n continue;\n }\n\n switch (t.$type) {\n case 'color': {\n if (!inGamut(tokenToColor(t.$value), options.gamut)) {\n report({\n messageId: ERROR_COLOR,\n data: { id: t.id, gamut: options.gamut },\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n break;\n }\n case 'border': {\n if (!t.partialAliasOf?.color && !inGamut(tokenToColor(t.$value.color), options.gamut)) {\n report({\n messageId: ERROR_BORDER,\n data: { id: t.id, gamut: options.gamut },\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n break;\n }\n case 'gradient': {\n for (let stopI = 0; stopI < t.$value.length; stopI++) {\n if (!t.partialAliasOf?.[stopI]?.color && !inGamut(tokenToColor(t.$value[stopI]!.color), options.gamut)) {\n report({\n messageId: ERROR_GRADIENT,\n data: { id: t.id, gamut: options.gamut },\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n }\n break;\n }\n case 'shadow': {\n for (let shadowI = 0; shadowI < t.$value.length; shadowI++) {\n if (\n !t.partialAliasOf?.[shadowI]?.color &&\n !inGamut(tokenToColor(t.$value[shadowI]!.color), options.gamut)\n ) {\n report({\n messageId: ERROR_SHADOW,\n data: { id: t.id, gamut: options.gamut },\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n }\n break;\n }\n }\n }\n },\n};\n\nexport default rule;\n","import wcmatch from 'wildcard-match';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const REQUIRED_CHILDREN = 'core/required-children';\n\nexport interface RequiredChildrenMatch {\n /** Glob of tokens/groups to match */\n match: string[];\n /** Required token IDs to match (this only looks at the very last segment of a token ID!) */\n requiredTokens?: string[];\n /** Required groups to match (this only looks at the beginning/middle segments of a token ID!) */\n requiredGroups?: string[];\n}\n\nexport interface RuleRequiredChildrenOptions {\n matches: RequiredChildrenMatch[];\n}\n\nexport const ERROR_EMPTY_MATCH = 'EMPTY_MATCH';\nexport const ERROR_MISSING_REQUIRED_TOKENS = 'MISSING_REQUIRED_TOKENS';\nexport const ERROR_MISSING_REQUIRED_GROUP = 'MISSING_REQUIRED_GROUP';\n\nconst rule: LintRule<\n typeof ERROR_EMPTY_MATCH | typeof ERROR_MISSING_REQUIRED_TOKENS | typeof ERROR_MISSING_REQUIRED_GROUP,\n RuleRequiredChildrenOptions\n> = {\n meta: {\n messages: {\n [ERROR_EMPTY_MATCH]: 'No tokens matched {{ matcher }}',\n [ERROR_MISSING_REQUIRED_TOKENS]: 'Match {{ index }}: some groups missing required token \"{{ token }}\"',\n [ERROR_MISSING_REQUIRED_GROUP]: 'Match {{ index }}: some tokens missing required group \"{{ group }}\"',\n },\n docs: {\n description: 'Enforce token groups have specific children, whether tokens and/or groups.',\n url: docsLink(REQUIRED_CHILDREN),\n },\n },\n defaultOptions: { matches: [] },\n create({ tokens, options, report }) {\n if (!options.matches?.length) {\n throw new Error('Invalid config. Missing `matches: […]`');\n }\n\n // note: in many other rules, the operation can be completed in one iteration through all tokens\n // in this rule, however, we have to scan all tokens every time per-match, because they may overlap\n\n for (let matchI = 0; matchI < options.matches.length; matchI++) {\n const { match, requiredTokens, requiredGroups } = options.matches[matchI]!;\n\n // validate\n if (!match.length) {\n throw new Error(`Match ${matchI}: must declare \\`match: […]\\``);\n }\n if (!requiredTokens?.length && !requiredGroups?.length) {\n throw new Error(`Match ${matchI}: must declare either \\`requiredTokens: […]\\` or \\`requiredGroups: […]\\``);\n }\n\n const matcher = wcmatch(match);\n\n const matchGroups: string[] = [];\n const matchTokens: string[] = [];\n let tokensMatched = false;\n for (const t of Object.values(tokens)) {\n if (!matcher(t.id)) {\n continue;\n }\n tokensMatched = true;\n const groups = t.id.split('.');\n matchTokens.push(groups.pop()!);\n matchGroups.push(...groups);\n }\n\n if (!tokensMatched) {\n report({\n messageId: ERROR_EMPTY_MATCH,\n data: { matcher: JSON.stringify(match) },\n });\n continue;\n }\n\n if (requiredTokens) {\n for (const id of requiredTokens) {\n if (!matchTokens.includes(id)) {\n report({\n messageId: ERROR_MISSING_REQUIRED_TOKENS,\n data: { index: matchI, token: id },\n });\n }\n }\n }\n if (requiredGroups) {\n for (const groupName of requiredGroups) {\n if (!matchGroups.includes(groupName)) {\n report({\n messageId: ERROR_MISSING_REQUIRED_GROUP,\n data: { index: matchI, group: groupName },\n });\n }\n }\n }\n }\n },\n};\n\nexport default rule;\n","import wcmatch from 'wildcard-match';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const REQUIRED_MODES = 'core/required-modes';\n\nexport type RequiredModesMatch = {\n /** Glob of tokens/groups to match */\n match: string[];\n /** Required modes */\n modes: string[];\n};\n\nexport interface RuleRequiredModesOptions {\n matches: RequiredModesMatch[];\n}\n\nconst rule: LintRule<never, RuleRequiredModesOptions> = {\n meta: {\n docs: {\n description: 'Enforce certain tokens have specific modes.',\n url: docsLink(REQUIRED_MODES),\n },\n },\n defaultOptions: { matches: [] },\n create({ tokens, options, report }) {\n if (!options?.matches?.length) {\n throw new Error('Invalid config. Missing `matches: […]`');\n }\n\n // note: in many other rules, the operation can be completed in one iteration through all tokens\n // in this rule, however, we have to scan all tokens every time per-match, because they may overlap\n for (let matchI = 0; matchI < options.matches.length; matchI++) {\n const { match, modes } = options.matches[matchI]!;\n\n // validate\n if (!match.length) {\n throw new Error(`Match ${matchI}: must declare \\`match: […]\\``);\n }\n if (!modes?.length) {\n throw new Error(`Match ${matchI}: must declare \\`modes: […]\\``);\n }\n\n const matcher = wcmatch(match);\n\n let tokensMatched = false;\n for (const t of Object.values(tokens)) {\n if (!matcher(t.id)) {\n continue;\n }\n tokensMatched = true;\n\n for (const mode of modes) {\n if (!t.mode?.[mode]) {\n report({\n message: `Token ${t.id}: missing required mode \"${mode}\"`,\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n }\n\n if (!tokensMatched) {\n report({\n message: `Match \"${matchI}\": no tokens matched ${JSON.stringify(match)}`,\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const REQUIRED_TYPE = 'core/required-type';\n\nexport const ERROR = 'ERROR';\n\nconst rule: LintRule<typeof ERROR> = {\n meta: {\n messages: {\n [ERROR]: 'Token missing $type.',\n },\n docs: {\n description: 'Requiring every token to have $type, even aliases, simplifies computation.',\n url: docsLink(REQUIRED_TYPE),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (!t.originalValue?.$type) {\n report({ messageId: ERROR, node: t.source.node, filename: t.source.filename });\n }\n }\n },\n};\n\nexport default rule;\n","import wcmatch from 'wildcard-match';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const REQUIRED_TYPOGRAPHY_PROPERTIES = 'core/required-typography-properties';\n\nexport interface RuleRequiredTypographyPropertiesOptions {\n /**\n * Required typography properties.\n * @default [\"fontFamily\", \"fontWeight\", \"fontSize\", \"letterSpacing\", \"lineHeight\"]\n */\n properties: string[];\n /** Token globs to ignore */\n ignore?: string[];\n}\n\n/** @deprecated Use core/valid-typography instead */\nconst rule: LintRule<never, RuleRequiredTypographyPropertiesOptions> = {\n meta: {\n docs: {\n description: 'Enforce typography tokens have required properties.',\n url: docsLink(REQUIRED_TYPOGRAPHY_PROPERTIES),\n },\n },\n defaultOptions: {\n properties: ['fontFamily', 'fontSize', 'fontWeight', 'letterSpacing', 'lineHeight'],\n },\n create({ tokens, options, report }) {\n if (!options) {\n return;\n }\n\n if (!options.properties.length) {\n throw new Error(`\"properties\" can’t be empty`);\n }\n\n const shouldIgnore = options.ignore ? wcmatch(options.ignore) : null;\n\n for (const t of Object.values(tokens)) {\n if (shouldIgnore?.(t.id)) {\n continue;\n }\n\n if (t.$type !== 'typography') {\n continue;\n }\n\n if (t.aliasOf) {\n continue;\n }\n\n for (const p of options.properties) {\n if (!t.partialAliasOf?.[p] && !(p in t.$value)) {\n report({\n message: `This rule is deprecated. Use core/valid-typography. Missing required typographic property \"${p}\"`,\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember, getObjMembers } from '@terrazzo/json-schema-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_FONT_FAMILY = 'core/valid-font-family';\n\nconst ERROR = 'ERROR';\n\nconst rule: LintRule<typeof ERROR> = {\n meta: {\n messages: {\n [ERROR]: 'Must be a string, or array of strings.',\n },\n docs: {\n description: 'Require fontFamily tokens to follow the format.',\n url: docsLink(VALID_FONT_FAMILY),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue) {\n continue;\n }\n\n switch (t.$type) {\n case 'fontFamily': {\n validateFontFamily(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value') as momoa.ArrayNode,\n filename: t.source.filename,\n });\n break;\n }\n case 'typography': {\n if (typeof t.originalValue.$value === 'object' && t.originalValue.$value.fontFamily) {\n if (t.partialAliasOf?.fontFamily) {\n continue;\n }\n const $value = getObjMember(t.source.node, '$value');\n const properties = getObjMembers($value as momoa.ObjectNode);\n validateFontFamily(t.originalValue.$value.fontFamily, {\n node: properties.fontFamily as momoa.ArrayNode,\n filename: t.source.filename,\n });\n }\n break;\n }\n }\n\n function validateFontFamily(value: unknown, { node, filename }: { node: momoa.ArrayNode; filename?: string }) {\n if (typeof value === 'string') {\n if (!value) {\n report({ messageId: ERROR, node, filename });\n }\n } else if (Array.isArray(value)) {\n if (!value.every((v) => v && typeof v === 'string')) {\n report({ messageId: ERROR, node, filename });\n }\n } else {\n report({ messageId: ERROR, node, filename });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember, getObjMembers } from '@terrazzo/json-schema-tools';\nimport { FONT_WEIGHTS } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_FONT_WEIGHT = 'core/valid-font-weight';\n\nconst ERROR = 'ERROR';\nconst ERROR_STYLE = 'ERROR_STYLE';\n\nexport interface RuleFontWeightOptions {\n /**\n * Enforce either:\n * - \"numbers\" (0-999)\n * - \"names\" (\"light\", \"medium\", \"bold\", etc.)\n */\n style?: 'numbers' | 'names';\n}\n\nconst rule: LintRule<typeof ERROR | typeof ERROR_STYLE, RuleFontWeightOptions> = {\n meta: {\n messages: {\n [ERROR]: `Must either be a valid number (0 - 999) or a valid font weight: ${new Intl.ListFormat('en-us', { type: 'disjunction' }).format(Object.keys(FONT_WEIGHTS))}.`,\n [ERROR_STYLE]: 'Expected style {{ style }}, received {{ value }}.',\n },\n docs: {\n description: 'Require number tokens to follow the format.',\n url: docsLink(VALID_FONT_WEIGHT),\n },\n },\n defaultOptions: {\n style: undefined,\n },\n create({ tokens, options, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue) {\n continue;\n }\n\n switch (t.$type) {\n case 'fontWeight': {\n validateFontWeight(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value') as momoa.StringNode,\n filename: t.source.filename,\n });\n break;\n }\n case 'typography': {\n if (typeof t.originalValue.$value === 'object' && t.originalValue.$value.fontWeight) {\n if (t.partialAliasOf?.fontWeight) {\n continue;\n }\n const $value = getObjMember(t.source.node, '$value');\n const properties = getObjMembers($value as momoa.ObjectNode);\n validateFontWeight(t.originalValue.$value.fontWeight, {\n node: properties.fontWeight as momoa.StringNode,\n filename: t.source.filename,\n });\n }\n break;\n }\n }\n\n function validateFontWeight(\n value: unknown,\n { node, filename }: { node: momoa.StringNode | momoa.NumberNode; filename?: string },\n ) {\n if (typeof value === 'string') {\n if (options.style === 'numbers') {\n report({ messageId: ERROR_STYLE, data: { style: 'numbers', value }, node, filename });\n } else if (!(value in FONT_WEIGHTS)) {\n report({ messageId: ERROR, node, filename });\n }\n } else if (typeof value === 'number') {\n if (options.style === 'names') {\n report({ messageId: ERROR_STYLE, data: { style: 'names', value }, node, filename });\n } else if (!(value >= 0 && value < 1000)) {\n report({ messageId: ERROR, node, filename });\n }\n } else {\n report({ messageId: ERROR, node, filename });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport { GRADIENT_REQUIRED_STOP_PROPERTIES, isAlias } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_GRADIENT = 'core/valid-gradient';\n\nconst ERROR_MISSING = 'ERROR_MISSING';\nconst ERROR_POSITION = 'ERROR_POSITION';\nconst ERROR_INVALID_PROP = 'ERROR_INVALID_PROP';\n\nconst rule: LintRule<typeof ERROR_MISSING | typeof ERROR_POSITION | typeof ERROR_INVALID_PROP> = {\n meta: {\n messages: {\n [ERROR_MISSING]: 'Must be an array of { color, position } objects.',\n [ERROR_POSITION]: 'Expected number 0-1, received {{ value }}.',\n [ERROR_INVALID_PROP]: 'Unknown property {{ key }}.',\n },\n docs: {\n description: 'Require gradient tokens to follow the format.',\n url: docsLink(VALID_GRADIENT),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue || t.$type !== 'gradient') {\n continue;\n }\n\n validateGradient(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value') as momoa.ArrayNode,\n filename: t.source.filename,\n });\n\n function validateGradient(value: unknown, { node, filename }: { node: momoa.ArrayNode; filename?: string }) {\n if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) {\n const stop = value[i]!;\n if (!stop || typeof stop !== 'object') {\n report({ messageId: ERROR_MISSING, node, filename });\n continue;\n }\n for (const property of GRADIENT_REQUIRED_STOP_PROPERTIES) {\n if (!(property in stop)) {\n report({ messageId: ERROR_MISSING, node: node.elements[i], filename });\n }\n }\n for (const key of Object.keys(stop)) {\n if (\n !GRADIENT_REQUIRED_STOP_PROPERTIES.includes(key as (typeof GRADIENT_REQUIRED_STOP_PROPERTIES)[number])\n ) {\n report({\n messageId: ERROR_INVALID_PROP,\n data: { key: JSON.stringify(key) },\n node: node.elements[i],\n filename,\n });\n }\n }\n if ('position' in stop && typeof stop.position !== 'number' && !isAlias(stop.position as string)) {\n report({\n messageId: ERROR_POSITION,\n data: { value: stop.position },\n node: getObjMember(node.elements[i]!.value as momoa.ObjectNode, 'position'),\n filename,\n });\n }\n }\n } else {\n report({ messageId: ERROR_MISSING, node, filename });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_LINK = 'core/valid-link';\n\nconst ERROR = 'ERROR';\n\nconst rule: LintRule<typeof ERROR, {}> = {\n meta: {\n messages: {\n [ERROR]: 'Must be a string.',\n },\n docs: {\n description: 'Require link tokens to follow the Terrazzo extension.',\n url: docsLink(VALID_LINK),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue || t.$type !== 'link') {\n continue;\n }\n\n validateLink(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value') as momoa.StringNode,\n filename: t.source.filename,\n });\n\n function validateLink(value: unknown, { node, filename }: { node: momoa.StringNode; filename?: string }) {\n if (!value || typeof value !== 'string') {\n report({ messageId: ERROR, node, filename });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport { isAlias } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_NUMBER = 'core/valid-number';\n\nconst ERROR_NAN = 'ERROR_NAN';\n\nconst rule: LintRule<typeof ERROR_NAN> = {\n meta: {\n messages: {\n [ERROR_NAN]: 'Must be a number.',\n },\n docs: {\n description: 'Require number tokens to follow the format.',\n url: docsLink(VALID_NUMBER),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue) {\n continue;\n }\n\n switch (t.$type) {\n case 'number': {\n validateNumber(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value') as momoa.NumberNode,\n filename: t.source.filename,\n });\n break;\n }\n // Note: gradient not needed, validated in gradient\n case 'typography': {\n const $valueNode = getObjMember(t.source.node, '$value') as momoa.ObjectNode;\n if (typeof t.originalValue.$value === 'object') {\n if (\n t.originalValue.$value.lineHeight &&\n !isAlias(t.originalValue.$value.lineHeight as string) &&\n typeof t.originalValue.$value.lineHeight !== 'object'\n ) {\n validateNumber(t.originalValue.$value.lineHeight, {\n node: getObjMember($valueNode, 'lineHeight') as momoa.NumberNode,\n filename: t.source.filename,\n });\n }\n }\n }\n }\n\n function validateNumber(value: unknown, { node, filename }: { node: momoa.NumberNode; filename?: string }) {\n if (typeof value !== 'number' || Number.isNaN(value)) {\n report({ messageId: ERROR_NAN, node, filename });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport { SHADOW_REQUIRED_PROPERTIES } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_SHADOW = 'core/valid-shadow';\n\nconst ERROR = 'ERROR';\nconst ERROR_INVALID_PROP = 'ERROR_INVALID_PROP';\n\nconst rule: LintRule<typeof ERROR | typeof ERROR_INVALID_PROP> = {\n meta: {\n messages: {\n [ERROR]: `Missing required properties: ${new Intl.ListFormat('en-us', { type: 'conjunction' }).format(SHADOW_REQUIRED_PROPERTIES)}.`,\n [ERROR_INVALID_PROP]: 'Unknown property {{ key }}.',\n },\n docs: {\n description: 'Require shadow tokens to follow the format.',\n url: docsLink(VALID_SHADOW),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue || t.$type !== 'shadow') {\n continue;\n }\n\n validateShadow(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value') as momoa.ObjectNode,\n filename: t.source.filename,\n });\n\n // Note: we validate sub-properties using other checks like valid-dimension, valid-font-family, etc.\n // The only thing remaining is to check that all properties exist (since missing properties won’t appear as invalid)\n function validateShadow(\n value: unknown,\n { node, filename }: { node: momoa.ObjectNode | momoa.ArrayNode; filename?: string },\n ) {\n const wrappedValue = Array.isArray(value) ? value : [value];\n for (let i = 0; i < wrappedValue.length; i++) {\n if (\n !wrappedValue[i] ||\n typeof wrappedValue[i] !== 'object' ||\n !SHADOW_REQUIRED_PROPERTIES.every((property) => property in wrappedValue[i])\n ) {\n report({ messageId: ERROR, node, filename });\n } else {\n for (const key of Object.keys(wrappedValue[i])) {\n if (![...SHADOW_REQUIRED_PROPERTIES, 'inset'].includes(key)) {\n report({\n messageId: ERROR_INVALID_PROP,\n data: { key: JSON.stringify(key) },\n node: getObjMember(node.type === 'Array' ? (node.elements[i]!.value as momoa.ObjectNode) : node, key),\n filename,\n });\n }\n }\n }\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_STRING = 'core/valid-string';\n\nconst ERROR = 'ERROR';\n\nconst rule: LintRule<typeof ERROR> = {\n meta: {\n messages: {\n [ERROR]: 'Must be a string.',\n },\n docs: {\n description: 'Require string tokens to follow the Terrazzo extension.',\n url: docsLink(VALID_STRING),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue || t.$type !== 'string') {\n continue;\n }\n\n validateString(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value') as momoa.StringNode,\n filename: t.source.filename,\n });\n\n function validateString(value: unknown, { node, filename }: { node: momoa.StringNode; filename?: string }) {\n if (typeof value !== 'string') {\n report({ messageId: ERROR, node, filename });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport {\n isAlias,\n STROKE_STYLE_LINE_CAP_VALUES,\n STROKE_STYLE_OBJECT_REQUIRED_PROPERTIES,\n STROKE_STYLE_STRING_VALUES,\n TRANSITION_REQUIRED_PROPERTIES,\n} from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_STROKE_STYLE = 'core/valid-stroke-style';\n\nconst ERROR_STR = 'ERROR_STR';\nconst ERROR_OBJ = 'ERROR_OBJ';\nconst ERROR_LINE_CAP = 'ERROR_LINE_CAP';\nconst ERROR_INVALID_PROP = 'ERROR_INVALID_PROP';\n\nconst rule: LintRule<typeof ERROR_STR | typeof ERROR_OBJ | typeof ERROR_LINE_CAP | typeof ERROR_INVALID_PROP> = {\n meta: {\n messages: {\n [ERROR_STR]: `Value most be one of ${new Intl.ListFormat('en-us', { type: 'disjunction' }).format(STROKE_STYLE_STRING_VALUES)}.`,\n [ERROR_OBJ]: `Missing required properties: ${new Intl.ListFormat('en-us', { type: 'conjunction' }).format(TRANSITION_REQUIRED_PROPERTIES)}.`,\n [ERROR_LINE_CAP]: `lineCap must be one of ${new Intl.ListFormat('en-us', { type: 'disjunction' }).format(STROKE_STYLE_LINE_CAP_VALUES)}.`,\n [ERROR_INVALID_PROP]: 'Unknown property: {{ key }}.',\n },\n docs: {\n description: 'Require strokeStyle tokens to follow the format.',\n url: docsLink(VALID_STROKE_STYLE),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue) {\n continue;\n }\n\n switch (t.$type) {\n case 'strokeStyle': {\n validateStrokeStyle(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value') as momoa.ObjectNode,\n filename: t.source.filename,\n });\n break;\n }\n case 'border': {\n if (t.originalValue.$value && typeof t.originalValue.$value === 'object') {\n const $valueNode = getObjMember(t.source.node, '$value') as momoa.ObjectNode;\n if (t.originalValue.$value.style) {\n validateStrokeStyle(t.originalValue.$value.style, {\n node: getObjMember($valueNode, 'style') as momoa.ObjectNode,\n filename: t.source.filename,\n });\n }\n }\n break;\n }\n }\n\n // Note: we validate sub-properties using other checks like valid-dimension, valid-font-family, etc.\n // The only thing remaining is to check that all properties exist (since missing properties won’t appear as invalid)\n function validateStrokeStyle(\n value: unknown,\n { node, filename }: { node: momoa.StringNode | momoa.ObjectNode; filename?: string },\n ) {\n if (typeof value === 'string') {\n if (\n !isAlias(value) &&\n !STROKE_STYLE_STRING_VALUES.includes(value as (typeof STROKE_STYLE_STRING_VALUES)[number])\n ) {\n report({ messageId: ERROR_STR, node, filename });\n return;\n }\n } else if (value && typeof value === 'object') {\n if (!STROKE_STYLE_OBJECT_REQUIRED_PROPERTIES.every((property) => property in value)) {\n report({ messageId: ERROR_OBJ, node, filename });\n }\n if (!Array.isArray((value as any).dashArray)) {\n report({ messageId: ERROR_OBJ, node: getObjMember(node as momoa.ObjectNode, 'dashArray'), filename });\n }\n if (!STROKE_STYLE_LINE_CAP_VALUES.includes((value as any).lineCap)) {\n report({ messageId: ERROR_OBJ, node: getObjMember(node as momoa.ObjectNode, 'lineCap'), filename });\n }\n for (const key of Object.keys(value)) {\n if (!['dashArray', 'lineCap'].includes(key)) {\n report({\n messageId: ERROR_INVALID_PROP,\n data: { key: JSON.stringify(key) },\n node: getObjMember(node as momoa.ObjectNode, key),\n filename,\n });\n }\n }\n } else {\n report({ messageId: ERROR_OBJ, node, filename });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport { TRANSITION_REQUIRED_PROPERTIES } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_TRANSITION = 'core/valid-transition';\n\nconst ERROR = 'ERROR';\nconst ERROR_INVALID_PROP = 'ERROR_INVALID_PROP';\n\nconst rule: LintRule<typeof ERROR | typeof ERROR_INVALID_PROP> = {\n meta: {\n messages: {\n [ERROR]: `Missing required properties: ${new Intl.ListFormat('en-us', { type: 'conjunction' }).format(TRANSITION_REQUIRED_PROPERTIES)}.`,\n [ERROR_INVALID_PROP]: 'Unknown property: {{ key }}.',\n },\n docs: {\n description: 'Require transition tokens to follow the format.',\n url: docsLink(VALID_TRANSITION),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue || t.$type !== 'transition') {\n continue;\n }\n\n validateTransition(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value') as momoa.ObjectNode,\n filename: t.source.filename,\n });\n }\n\n // Note: we validate sub-properties using other checks like valid-dimension, valid-font-family, etc.\n // The only thing remaining is to check that all properties exist (since missing properties won’t appear as invalid)\n function validateTransition(value: unknown, { node, filename }: { node: momoa.ObjectNode; filename?: string }) {\n if (\n !value ||\n typeof value !== 'object' ||\n !TRANSITION_REQUIRED_PROPERTIES.every((property) => property in value)\n ) {\n report({ messageId: ERROR, node, filename });\n } else {\n for (const key of Object.keys(value)) {\n if (!TRANSITION_REQUIRED_PROPERTIES.includes(key as (typeof TRANSITION_REQUIRED_PROPERTIES)[number])) {\n report({\n messageId: ERROR_INVALID_PROP,\n data: { key: JSON.stringify(key) },\n node: getObjMember(node, key),\n filename,\n });\n }\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport wcmatch from 'wildcard-match';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_TYPOGRAPHY = 'core/valid-typography';\n\nconst ERROR = 'ERROR';\nconst ERROR_MISSING = 'ERROR_MISSING';\n\nexport interface RuleValidTypographyOptions {\n /** Required typography properties */\n requiredProperties: string[];\n /** Token globs to ignore */\n ignore?: string[];\n}\n\nconst rule: LintRule<typeof ERROR | typeof ERROR_MISSING, RuleValidTypographyOptions> = {\n meta: {\n messages: {\n [ERROR]: `Expected object, received {{ value }}.`,\n [ERROR_MISSING]: `Missing required property \"{{ property }}\".`,\n },\n docs: {\n description: 'Require typography tokens to follow the format.',\n url: docsLink(VALID_TYPOGRAPHY),\n },\n },\n defaultOptions: {\n requiredProperties: ['fontFamily', 'fontSize', 'fontWeight', 'letterSpacing', 'lineHeight'],\n },\n create({ tokens, options, report }) {\n const isIgnored = options.ignore ? wcmatch(options.ignore) : () => false;\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue || t.$type !== 'typography' || isIgnored(t.id)) {\n continue;\n }\n\n validateTypography(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value') as momoa.ObjectNode,\n filename: t.source.filename,\n });\n\n // Note: we validate sub-properties using other checks like valid-dimension, valid-font-family, etc.\n // The only thing remaining is to check that all properties exist (since missing properties won’t appear as invalid)\n function validateTypography(value: unknown, { node, filename }: { node: momoa.ObjectNode; filename?: string }) {\n if (value && typeof value === 'object') {\n for (const property of options.requiredProperties) {\n if (!(property in value)) {\n report({ messageId: ERROR_MISSING, data: { property }, node, filename });\n }\n }\n } else {\n report({\n messageId: ERROR,\n data: { value: JSON.stringify(value) },\n node,\n filename,\n });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_BOOLEAN = 'core/valid-boolean';\n\nconst ERROR = 'ERROR';\n\nconst rule: LintRule<typeof ERROR, {}> = {\n meta: {\n messages: {\n [ERROR]: 'Must be a boolean.',\n },\n docs: {\n description: 'Require boolean tokens to follow the Terrazzo extension.',\n url: docsLink(VALID_BOOLEAN),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue || t.$type !== 'boolean') {\n continue;\n }\n\n validateBoolean(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value'),\n filename: t.source.filename,\n });\n\n function validateBoolean(value: unknown, { node, filename }: { node?: momoa.AnyNode; filename?: string }) {\n if (typeof value !== 'boolean') {\n report({ messageId: ERROR, filename, node });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport { BORDER_REQUIRED_PROPERTIES } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_BORDER = 'core/valid-border';\n\nconst ERROR = 'ERROR';\nconst ERROR_INVALID_PROP = 'ERROR_INVALID_PROP';\n\nconst rule: LintRule<typeof ERROR | typeof ERROR_INVALID_PROP, {}> = {\n meta: {\n messages: {\n [ERROR]: `Border token missing required properties: ${new Intl.ListFormat('en-us', { type: 'conjunction' }).format(BORDER_REQUIRED_PROPERTIES)}.`,\n [ERROR_INVALID_PROP]: 'Unknown property: {{ key }}.',\n },\n docs: {\n description: 'Require border tokens to follow the format.',\n url: docsLink(VALID_BORDER),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue || t.$type !== 'border') {\n continue;\n }\n\n validateBorder(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value'),\n filename: t.source.filename,\n });\n }\n\n // Note: we validate sub-properties using other checks like valid-dimension, valid-font-family, etc.\n // The only thing remaining is to check that all properties exist (since missing properties won’t appear as invalid)\n function validateBorder(value: unknown, { node, filename }: { node?: momoa.AnyNode; filename?: string }) {\n if (!value || typeof value !== 'object' || !BORDER_REQUIRED_PROPERTIES.every((property) => property in value)) {\n report({ messageId: ERROR, filename, node });\n } else {\n for (const key of Object.keys(value)) {\n if (!BORDER_REQUIRED_PROPERTIES.includes(key as (typeof BORDER_REQUIRED_PROPERTIES)[number])) {\n report({\n messageId: ERROR_INVALID_PROP,\n data: { key: JSON.stringify(key) },\n node: getObjMember(node as momoa.ObjectNode, key) ?? node,\n filename,\n });\n }\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport {\n type BorderValue,\n COLOR_SPACE,\n type ColorSpace,\n type ColorValueNormalized,\n type GradientStopNormalized,\n type GradientValueNormalized,\n isAlias,\n parseColor,\n type ShadowValue,\n} from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_COLOR = 'core/valid-color';\n\nexport const VALID_COLORSPACES = new Set([\n 'a98-rgb',\n 'display-p3',\n 'hsl',\n 'hwb',\n 'lab',\n 'lab-d65',\n 'lab',\n 'lch',\n 'okhsv',\n 'oklab',\n 'oklch',\n 'prophoto-rgb',\n 'rec2020',\n 'srgb',\n 'srgb-linear',\n 'xyz',\n 'xyz-d50',\n 'xyz-d65',\n] satisfies ColorSpace[]);\n\nconst ERROR_ALPHA = 'ERROR_ALPHA';\nconst ERROR_INVALID_COLOR = 'ERROR_INVALID_COLOR';\nconst ERROR_INVALID_COLOR_SPACE = 'ERROR_INVALID_COLOR_SPACE';\nconst ERROR_INVALID_COMPONENT_LENGTH = 'ERROR_INVALID_COMPONENT_LENGTH';\nconst ERROR_INVALID_HEX8 = 'ERROR_INVALID_HEX8';\nconst ERROR_INVALID_PROP = 'ERROR_INVALID_PROP';\nconst ERROR_MISSING_COMPONENTS = 'ERROR_MISSING_COMPONENTS';\nconst ERROR_OBJ_FORMAT = 'ERROR_OBJ_FORMAT';\nconst ERROR_OUT_OF_RANGE = 'ERROR_OUT_OF_RANGE';\n\nexport interface RuleValidColorOptions {\n /**\n * Allow the legacy format of only a string sRGB hex code\n * @default false\n */\n legacyFormat?: boolean;\n /**\n * Allow colors to be defined out of the expected ranges.\n * @default false\n */\n ignoreRanges?: boolean;\n}\n\nconst rule: LintRule<\n | typeof ERROR_ALPHA\n | typeof ERROR_INVALID_COLOR\n | typeof ERROR_INVALID_COLOR_SPACE\n | typeof ERROR_INVALID_COMPONENT_LENGTH\n | typeof ERROR_INVALID_HEX8\n | typeof ERROR_INVALID_PROP\n | typeof ERROR_MISSING_COMPONENTS\n | typeof ERROR_OBJ_FORMAT\n | typeof ERROR_OUT_OF_RANGE,\n RuleValidColorOptions\n> = {\n meta: {\n messages: {\n [ERROR_ALPHA]: `Alpha {{ alpha }} not in range 0 – 1.`,\n [ERROR_INVALID_COLOR_SPACE]: `Invalid color space: {{ colorSpace }}. Expected ${new Intl.ListFormat('en-us', { type: 'disjunction' }).format(Object.keys(COLOR_SPACE))}.`,\n [ERROR_INVALID_COLOR]: `Could not parse color {{ color }}.`,\n [ERROR_INVALID_COMPONENT_LENGTH]: 'Expected {{ expected }} components, received {{ got }}.',\n [ERROR_INVALID_HEX8]: `Hex value can’t be semi-transparent.`,\n [ERROR_INVALID_PROP]: `Unknown property {{ key }}.`,\n [ERROR_MISSING_COMPONENTS]: 'Expected components to be array of numbers, received {{ got }}.',\n [ERROR_OBJ_FORMAT]:\n 'Migrate to the new object format, e.g. \"#ff0000\" → { \"colorSpace\": \"srgb\", \"components\": [1, 0, 0] } }',\n [ERROR_OUT_OF_RANGE]: `Invalid range for color space {{ colorSpace }}. Expected {{ range }}.`,\n },\n docs: {\n description: 'Require color tokens to follow the format.',\n url: docsLink(VALID_COLOR),\n },\n },\n defaultOptions: {\n legacyFormat: false,\n ignoreRanges: false,\n },\n create({ tokens, options, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue) {\n continue;\n }\n\n switch (t.$type) {\n case 'color': {\n validateColor(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value'),\n filename: t.source.filename,\n });\n break;\n }\n case 'border': {\n if ((t.originalValue.$value as any).color && !isAlias((t.originalValue.$value as any).color)) {\n validateColor((t.originalValue.$value as BorderValue).color, {\n node: getObjMember(getObjMember(t.source.node, '$value') as momoa.ObjectNode, 'color'),\n filename: t.source.filename,\n });\n }\n break;\n }\n case 'gradient': {\n const $valueNode = getObjMember(t.source.node, '$value') as momoa.ArrayNode;\n for (let i = 0; i < (t.originalValue.$value as GradientValueNormalized).length; i++) {\n const stop = t.originalValue.$value[i] as GradientStopNormalized;\n if (!stop.color || isAlias(stop.color as any)) {\n continue;\n }\n validateColor(stop.color, {\n node: getObjMember($valueNode.elements[i]!.value as momoa.ObjectNode, 'color'),\n filename: t.source.filename,\n });\n }\n break;\n }\n case 'shadow': {\n const $value = (\n Array.isArray(t.originalValue.$value) ? t.originalValue.$value : [t.originalValue.$value]\n ) as ShadowValue[];\n const $valueNode = getObjMember(t.source.node, '$value') as momoa.ObjectNode | momoa.ArrayNode;\n for (let i = 0; i < $value.length; i++) {\n const layer = $value[i]!;\n if (!layer.color || isAlias(layer.color as any)) {\n continue;\n }\n validateColor(layer.color, {\n node:\n $valueNode.type === 'Object'\n ? getObjMember($valueNode, 'color')\n : getObjMember($valueNode.elements[i]!.value as momoa.ObjectNode, 'color'),\n filename: t.source.filename,\n });\n }\n break;\n }\n }\n\n function validateColor(value: unknown, { node, filename }: { node?: momoa.AnyNode; filename?: string }) {\n if (!value) {\n report({ messageId: ERROR_INVALID_COLOR, data: { color: JSON.stringify(value) }, node, filename });\n } else if (typeof value === 'object') {\n for (const key of Object.keys(value)) {\n if (!['colorSpace', 'components', 'channels' /* TODO: remove */, 'hex', 'alpha'].includes(key)) {\n report({\n messageId: ERROR_INVALID_PROP,\n data: { key: JSON.stringify(key) },\n node: getObjMember(node as momoa.ObjectNode, key) ?? node,\n filename,\n });\n }\n }\n\n // Color space\n const colorSpace =\n 'colorSpace' in value && typeof value.colorSpace === 'string' ? value.colorSpace : undefined;\n const csData = COLOR_SPACE[colorSpace as keyof typeof COLOR_SPACE] || undefined;\n if (!('colorSpace' in value) || !csData) {\n report({\n messageId: ERROR_INVALID_COLOR_SPACE,\n data: { colorSpace },\n node: getObjMember(node as momoa.ObjectNode, 'colorSpace') ?? node,\n filename,\n });\n return;\n }\n\n // Component ranges\n const components = 'components' in value ? value.components : undefined;\n if (Array.isArray(components)) {\n const coords = Object.values(csData.coords);\n if (components?.length === coords.length) {\n for (let i = 0; i < components.length; i++) {\n const range = coords[i]?.range ?? coords[i]?.refRange;\n if (\n !Number.isFinite(components[i]) ||\n components[i]! < (range?.[0] ?? -Infinity) ||\n components[i]! > (range?.[1] ?? Infinity)\n ) {\n // special case for any hue-based components: allow null\n if (\n !(colorSpace === 'hsl' && components[0]! === null) &&\n !(colorSpace === 'hwb' && components[0]! === null) &&\n !(colorSpace === 'lch' && components[2]! === null) &&\n !(colorSpace === 'oklch' && components[2]! === null)\n ) {\n report({\n messageId: ERROR_OUT_OF_RANGE,\n data: { colorSpace, range: `[${range?.[0]}–${range?.[1]}]` },\n node: getObjMember(node as momoa.ObjectNode, 'components') ?? node,\n filename,\n });\n }\n }\n }\n } else {\n report({\n messageId: ERROR_INVALID_COMPONENT_LENGTH,\n data: { expected: coords.length ?? 0, got: components?.length },\n node: getObjMember(node as momoa.ObjectNode, 'components') ?? node,\n filename,\n });\n }\n } else {\n report({\n messageId: ERROR_MISSING_COMPONENTS,\n data: { got: JSON.stringify(components) },\n node: getObjMember(node as momoa.ObjectNode, 'components') ?? node,\n filename,\n });\n }\n\n // Alpha\n const alpha = 'alpha' in value ? value.alpha : undefined;\n if (alpha !== undefined && (typeof alpha !== 'number' || alpha < 0 || alpha > 1)) {\n report({\n messageId: ERROR_ALPHA,\n data: { alpha },\n node: getObjMember(node as momoa.ObjectNode, 'alpha') ?? node,\n filename,\n });\n }\n\n // Hex\n const hex = 'hex' in value ? value.hex : undefined;\n if (hex) {\n let color: ColorValueNormalized;\n try {\n color = parseColor(hex as string);\n } catch {\n report({\n messageId: ERROR_INVALID_COLOR,\n data: { color: hex },\n node: getObjMember(node as momoa.ObjectNode, 'hex') ?? node,\n filename,\n });\n return;\n }\n // since we’re only parsing hex, this should always have alpha: 1\n if (color.alpha !== 1) {\n report({\n messageId: ERROR_INVALID_HEX8,\n data: { color: hex },\n node: getObjMember(node as momoa.ObjectNode, 'hex') ?? node,\n filename,\n });\n }\n }\n } else if (typeof value === 'string') {\n if (isAlias(value)) {\n return;\n }\n if (!options.legacyFormat) {\n report({ messageId: ERROR_OBJ_FORMAT, data: { color: JSON.stringify(value) }, node, filename });\n } else {\n // Legacy format\n try {\n parseColor(value as string);\n } catch {\n report({ messageId: ERROR_INVALID_COLOR, data: { color: JSON.stringify(value) }, node, filename });\n }\n }\n } else {\n report({ messageId: ERROR_INVALID_COLOR, node, filename });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember, isPure$ref } from '@terrazzo/json-schema-tools';\nimport { isAlias } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_CUBIC_BEZIER = 'core/valid-cubic-bezier';\n\nconst ERROR = 'ERROR';\nconst ERROR_X = 'ERROR_X';\nconst ERROR_Y = 'ERROR_Y';\n\nconst rule: LintRule<typeof ERROR | typeof ERROR_X | typeof ERROR_Y> = {\n meta: {\n messages: {\n [ERROR]: 'Expected [number, number, number, number].',\n [ERROR_X]: 'x values must be between 0-1.',\n [ERROR_Y]: 'y values must be a valid number.',\n },\n docs: {\n description: 'Require cubicBezier tokens to follow the format.',\n url: docsLink(VALID_CUBIC_BEZIER),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue) {\n continue;\n }\n\n switch (t.$type) {\n case 'cubicBezier': {\n validateCubicBezier(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value') as momoa.ArrayNode,\n filename: t.source.filename,\n });\n break;\n }\n case 'transition': {\n if (\n typeof t.originalValue.$value === 'object' &&\n t.originalValue.$value.timingFunction &&\n !isAlias(t.originalValue.$value.timingFunction as string)\n ) {\n const $valueNode = getObjMember(t.source.node, '$value') as momoa.ObjectNode;\n validateCubicBezier(t.originalValue.$value.timingFunction, {\n node: getObjMember($valueNode, 'timingFunction') as momoa.ArrayNode,\n filename: t.source.filename,\n });\n }\n }\n }\n\n function validateCubicBezier(value: unknown, { node, filename }: { node: momoa.ArrayNode; filename?: string }) {\n if (Array.isArray(value) && value.length === 4) {\n // validate x values\n for (const pos of [0, 2]) {\n if (isAlias(value[pos]) || isPure$ref(value[pos])) {\n continue;\n }\n if (!(value[pos] >= 0 && value[pos] <= 1)) {\n report({ messageId: ERROR_X, node: (node as momoa.ArrayNode).elements[pos], filename });\n }\n }\n // validate y values\n for (const pos of [1, 3]) {\n if (isAlias(value[pos]) || isPure$ref(value[pos])) {\n continue;\n }\n if (typeof value[pos] !== 'number') {\n report({ messageId: ERROR_Y, node: (node as momoa.ArrayNode).elements[pos], filename });\n }\n }\n } else {\n report({ messageId: ERROR, node, filename });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport { isAlias } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_DIMENSION = 'core/valid-dimension';\n\nconst ERROR_FORMAT = 'ERROR_FORMAT';\nconst ERROR_INVALID_PROP = 'ERROR_INVALID_PROP';\nconst ERROR_LEGACY = 'ERROR_LEGACY';\nconst ERROR_UNIT = 'ERROR_UNIT';\nconst ERROR_VALUE = 'ERROR_VALUE';\n\nexport interface RuleValidDimension {\n /**\n * Allow the use of unknown \"unit\" values\n * @default false\n */\n legacyFormat?: boolean;\n /**\n * Only allow the following units.\n * @default [\"px\", \"rem\"]\n */\n allowedUnits?: string[];\n}\n\nconst rule: LintRule<\n typeof ERROR_FORMAT | typeof ERROR_LEGACY | typeof ERROR_UNIT | typeof ERROR_VALUE | typeof ERROR_INVALID_PROP,\n RuleValidDimension\n> = {\n meta: {\n messages: {\n [ERROR_FORMAT]: 'Invalid dimension: {{ value }}. Expected object with \"value\" and \"unit\".',\n [ERROR_LEGACY]: 'Migrate to the new object format: { \"value\": 10, \"unit\": \"px\" }.',\n [ERROR_UNIT]: 'Unit {{ unit }} not allowed. Expected {{ allowed }}.',\n [ERROR_INVALID_PROP]: 'Unknown property {{ key }}.',\n [ERROR_VALUE]: 'Expected number, received {{ value }}.',\n },\n docs: {\n description: 'Require dimension tokens to follow the format',\n url: docsLink(VALID_DIMENSION),\n },\n },\n defaultOptions: {\n legacyFormat: false,\n allowedUnits: ['px', 'em', 'rem'],\n },\n create({ tokens, options, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue) {\n continue;\n }\n\n switch (t.$type) {\n case 'dimension': {\n validateDimension(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value'),\n filename: t.source.filename,\n });\n break;\n }\n case 'strokeStyle': {\n if (typeof t.originalValue.$value === 'object' && Array.isArray(t.originalValue.$value.dashArray)) {\n const $valueNode = getObjMember(t.source.node, '$value') as momoa.ObjectNode;\n const dashArray = getObjMember($valueNode, 'dashArray') as momoa.ArrayNode;\n for (let i = 0; i < t.originalValue.$value.dashArray.length; i++) {\n if (isAlias(t.originalValue.$value.dashArray[i] as string)) {\n continue;\n }\n validateDimension(t.originalValue.$value.dashArray[i], {\n node: dashArray.elements[i]!.value,\n filename: t.source.filename,\n });\n }\n }\n break;\n }\n case 'border': {\n const $valueNode = getObjMember(t.source.node, '$value') as momoa.ObjectNode;\n if (typeof t.originalValue.$value === 'object') {\n if (t.originalValue.$value.width && !isAlias(t.originalValue.$value.width as string)) {\n validateDimension(t.originalValue.$value.width, {\n node: getObjMember($valueNode, 'width'),\n filename: t.source.filename,\n });\n }\n if (\n typeof t.originalValue.$value.style === 'object' &&\n Array.isArray(t.originalValue.$value.style.dashArray)\n ) {\n const style = getObjMember($valueNode, 'style') as momoa.ObjectNode;\n const dashArray = getObjMember(style, 'dashArray') as momoa.ArrayNode;\n for (let i = 0; i < t.originalValue.$value.style.dashArray.length; i++) {\n if (isAlias(t.originalValue.$value.style.dashArray[i] as string)) {\n continue;\n }\n validateDimension(t.originalValue.$value.style.dashArray[i], {\n node: dashArray.elements[i]!.value,\n filename: t.source.filename,\n });\n }\n }\n }\n break;\n }\n case 'shadow': {\n if (t.originalValue.$value && typeof t.originalValue.$value === 'object') {\n const $valueNode = getObjMember(t.source.node, '$value') as momoa.ObjectNode | momoa.ArrayNode;\n const valueArray = Array.isArray(t.originalValue.$value)\n ? t.originalValue.$value\n : [t.originalValue.$value];\n for (let i = 0; i < valueArray.length; i++) {\n const node =\n $valueNode.type === 'Array' ? ($valueNode.elements[i]!.value as momoa.ObjectNode) : $valueNode;\n for (const property of ['offsetX', 'offsetY', 'blur', 'spread'] as const) {\n if (isAlias(valueArray[i]![property] as string)) {\n continue;\n }\n validateDimension(valueArray[i]![property], {\n node: getObjMember(node, property),\n filename: t.source.filename,\n });\n }\n }\n }\n break;\n }\n case 'typography': {\n const $valueNode = getObjMember(t.source.node, '$value') as momoa.ObjectNode;\n if (typeof t.originalValue.$value === 'object') {\n for (const property of ['fontSize', 'lineHeight', 'letterSpacing'] as const) {\n if (property in t.originalValue.$value) {\n if (\n isAlias(t.originalValue.$value[property] as string) ||\n // special case: lineHeight may be a number\n (property === 'lineHeight' && typeof t.originalValue.$value[property] === 'number')\n ) {\n continue;\n }\n validateDimension(t.originalValue.$value[property], {\n node: getObjMember($valueNode, property),\n filename: t.source.filename,\n });\n }\n }\n }\n break;\n }\n }\n\n function validateDimension(value: unknown, { node, filename }: { node?: momoa.AnyNode; filename?: string }) {\n if (value && typeof value === 'object') {\n for (const key of Object.keys(value)) {\n if (!['value', 'unit'].includes(key)) {\n report({\n messageId: ERROR_INVALID_PROP,\n data: { key: JSON.stringify(key) },\n node: getObjMember(node as momoa.ObjectNode, key) ?? node,\n filename,\n });\n }\n }\n\n const { unit, value: numValue } = value as Record<string, any>;\n if (!('value' in value || 'unit' in value)) {\n report({ messageId: ERROR_FORMAT, data: { value }, node, filename });\n return;\n }\n if (!options.allowedUnits!.includes(unit)) {\n report({\n messageId: ERROR_UNIT,\n data: {\n unit,\n allowed: new Intl.ListFormat('en-us', { type: 'disjunction' }).format(options.allowedUnits!),\n },\n node: getObjMember(node as momoa.ObjectNode, 'unit') ?? node,\n filename,\n });\n }\n if (!Number.isFinite(numValue)) {\n report({\n messageId: ERROR_VALUE,\n data: { value },\n node: getObjMember(node as momoa.ObjectNode, 'value') ?? node,\n filename,\n });\n }\n } else if (typeof value === 'string' && !options.legacyFormat) {\n report({ messageId: ERROR_LEGACY, node, filename });\n } else {\n report({ messageId: ERROR_FORMAT, data: { value }, node, filename });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport { isAlias } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_DURATION = 'core/valid-duration';\n\nconst ERROR_FORMAT = 'ERROR_FORMAT';\nconst ERROR_INVALID_PROP = 'ERROR_INVALID_PROP';\nconst ERROR_LEGACY = 'ERROR_LEGACY';\nconst ERROR_UNIT = 'ERROR_UNIT';\nconst ERROR_VALUE = 'ERROR_VALUE';\n\nexport interface RuleValidDimension {\n /**\n * Allow the use of unknown \"unit\" values\n * @default false\n */\n legacyFormat?: boolean;\n /**\n * Allow the use of unknown \"unit\" values\n * @default false\n */\n unknownUnits?: boolean;\n}\n\nconst rule: LintRule<\n typeof ERROR_FORMAT | typeof ERROR_LEGACY | typeof ERROR_UNIT | typeof ERROR_VALUE | typeof ERROR_INVALID_PROP,\n RuleValidDimension\n> = {\n meta: {\n messages: {\n [ERROR_FORMAT]: 'Migrate to the new object format: { \"value\": 2, \"unit\": \"ms\" }.',\n [ERROR_LEGACY]: 'Migrate to the new object format: { \"value\": 10, \"unit\": \"px\" }.',\n [ERROR_INVALID_PROP]: 'Unknown property: {{ key }}.',\n [ERROR_UNIT]: 'Unknown unit {{ unit }}. Expected \"ms\" or \"s\".',\n [ERROR_VALUE]: 'Expected number, received {{ value }}.',\n },\n docs: {\n description: 'Require duration tokens to follow the format',\n url: docsLink(VALID_DURATION),\n },\n },\n defaultOptions: {\n legacyFormat: false,\n unknownUnits: false,\n },\n create({ tokens, options, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue) {\n continue;\n }\n\n switch (t.$type) {\n case 'duration': {\n validateDuration(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value')!,\n filename: t.source.filename,\n });\n break;\n }\n case 'transition': {\n if (typeof t.originalValue.$value === 'object') {\n const $valueNode = getObjMember(t.source.node, '$value');\n for (const property of ['duration', 'delay'] as const) {\n if (t.originalValue.$value[property] && !isAlias(t.originalValue.$value[property] as string)) {\n validateDuration(t.originalValue.$value[property], {\n node: getObjMember($valueNode as momoa.ObjectNode, property)!,\n filename: t.source.filename,\n });\n }\n }\n }\n break;\n }\n }\n\n function validateDuration(value: unknown, { node, filename }: { node: momoa.AnyNode; filename?: string }) {\n if (value && typeof value === 'object') {\n for (const key of Object.keys(value)) {\n if (!['value', 'unit'].includes(key)) {\n report({\n messageId: ERROR_INVALID_PROP,\n data: { key: JSON.stringify(key) },\n node: getObjMember(node as momoa.ObjectNode, key) ?? node,\n filename,\n });\n }\n }\n\n const { unit, value: numValue } = value as Record<string, any>;\n if (!('value' in value || 'unit' in value)) {\n report({ messageId: ERROR_FORMAT, data: { value }, node, filename });\n return;\n }\n if (!options.unknownUnits && !['ms', 's'].includes(unit)) {\n report({\n messageId: ERROR_UNIT,\n data: { unit },\n node: getObjMember(node as momoa.ObjectNode, 'unit') ?? node,\n filename,\n });\n }\n if (!Number.isFinite(numValue)) {\n report({\n messageId: ERROR_VALUE,\n data: { value },\n node: getObjMember(node as momoa.ObjectNode, 'value') ?? node,\n filename,\n });\n }\n } else if (typeof value === 'string' && !options.legacyFormat) {\n report({ messageId: ERROR_FORMAT, node, filename });\n } else {\n report({ messageId: ERROR_FORMAT, data: { value }, node, filename });\n }\n }\n }\n },\n};\n\nexport default rule;\n","// Terrazzo internal plugin that powers lint rules. Always enabled.\nimport type { LintRuleLonghand, Plugin } from '../../types.js';\n\nexport * from './rules/a11y-min-contrast.js';\nexport * from './rules/a11y-min-font-size.js';\nexport * from './rules/colorspace.js';\nexport * from './rules/consistent-naming.js';\nexport * from './rules/descriptions.js';\nexport * from './rules/duplicate-values.js';\nexport * from './rules/max-gamut.js';\nexport * from './rules/required-children.js';\nexport * from './rules/required-modes.js';\nexport * from './rules/required-type.js';\nexport * from './rules/required-typography-properties.js';\nexport * from './rules/valid-font-family.js';\nexport * from './rules/valid-font-weight.js';\nexport * from './rules/valid-gradient.js';\nexport * from './rules/valid-link.js';\nexport * from './rules/valid-number.js';\nexport * from './rules/valid-shadow.js';\nexport * from './rules/valid-string.js';\nexport * from './rules/valid-stroke-style.js';\nexport * from './rules/valid-transition.js';\nexport * from './rules/valid-typography.js';\n\nimport a11yMinContrast, { A11Y_MIN_CONTRAST } from './rules/a11y-min-contrast.js';\nimport a11yMinFontSize, { A11Y_MIN_FONT_SIZE } from './rules/a11y-min-font-size.js';\nimport colorspace, { COLORSPACE } from './rules/colorspace.js';\nimport consistentNaming, { CONSISTENT_NAMING } from './rules/consistent-naming.js';\nimport descriptions, { DESCRIPTIONS } from './rules/descriptions.js';\nimport duplicateValues, { DUPLICATE_VALUES } from './rules/duplicate-values.js';\nimport maxGamut, { MAX_GAMUT } from './rules/max-gamut.js';\nimport requiredChildren, { REQUIRED_CHILDREN } from './rules/required-children.js';\nimport requiredModes, { REQUIRED_MODES } from './rules/required-modes.js';\nimport requiredType, { REQUIRED_TYPE } from './rules/required-type.js';\nimport requiredTypographyProperties, {\n REQUIRED_TYPOGRAPHY_PROPERTIES,\n} from './rules/required-typography-properties.js';\nimport validBoolean, { VALID_BOOLEAN } from './rules/valid-boolean.js';\nimport validBorder, { VALID_BORDER } from './rules/valid-border.js';\nimport validColor, { VALID_COLOR } from './rules/valid-color.js';\nimport validCubicBezier, { VALID_CUBIC_BEZIER } from './rules/valid-cubic-bezier.js';\nimport validDimension, { VALID_DIMENSION } from './rules/valid-dimension.js';\nimport validDuration, { VALID_DURATION } from './rules/valid-duration.js';\nimport validFontFamily, { VALID_FONT_FAMILY } from './rules/valid-font-family.js';\nimport validFontWeight, { VALID_FONT_WEIGHT } from './rules/valid-font-weight.js';\nimport validGradient, { VALID_GRADIENT } from './rules/valid-gradient.js';\nimport validLink, { VALID_LINK } from './rules/valid-link.js';\nimport validNumber, { VALID_NUMBER } from './rules/valid-number.js';\nimport validShadow, { VALID_SHADOW } from './rules/valid-shadow.js';\nimport validString, { VALID_STRING } from './rules/valid-string.js';\nimport validStrokeStyle, { VALID_STROKE_STYLE } from './rules/valid-stroke-style.js';\nimport validTransition, { VALID_TRANSITION } from './rules/valid-transition.js';\nimport validTypography, { VALID_TYPOGRAPHY } from './rules/valid-typography.js';\n\nconst ALL_RULES = {\n [VALID_COLOR]: validColor,\n [VALID_DIMENSION]: validDimension,\n [VALID_FONT_FAMILY]: validFontFamily,\n [VALID_FONT_WEIGHT]: validFontWeight,\n [VALID_DURATION]: validDuration,\n [VALID_CUBIC_BEZIER]: validCubicBezier,\n [VALID_NUMBER]: validNumber,\n [VALID_LINK]: validLink,\n [VALID_BOOLEAN]: validBoolean,\n [VALID_STRING]: validString,\n [VALID_STROKE_STYLE]: validStrokeStyle,\n [VALID_BORDER]: validBorder,\n [VALID_TRANSITION]: validTransition,\n [VALID_SHADOW]: validShadow,\n [VALID_GRADIENT]: validGradient,\n [VALID_TYPOGRAPHY]: validTypography,\n [COLORSPACE]: colorspace,\n [CONSISTENT_NAMING]: consistentNaming,\n [DESCRIPTIONS]: descriptions,\n [DUPLICATE_VALUES]: duplicateValues,\n [MAX_GAMUT]: maxGamut,\n [REQUIRED_CHILDREN]: requiredChildren,\n [REQUIRED_MODES]: requiredModes,\n [REQUIRED_TYPE]: requiredType,\n [REQUIRED_TYPOGRAPHY_PROPERTIES]: requiredTypographyProperties,\n [A11Y_MIN_CONTRAST]: a11yMinContrast,\n [A11Y_MIN_FONT_SIZE]: a11yMinFontSize,\n};\n\nexport default function coreLintPlugin(): Plugin {\n return {\n name: '@terrazzo/plugin-lint-core',\n lint() {\n return ALL_RULES;\n },\n };\n}\n\nexport const RECOMMENDED_CONFIG: Record<string, LintRuleLonghand> = {\n [VALID_COLOR]: ['error', {}],\n [VALID_DIMENSION]: ['error', {}],\n [VALID_FONT_FAMILY]: ['error', {}],\n [VALID_FONT_WEIGHT]: ['error', {}],\n [VALID_DURATION]: ['error', {}],\n [VALID_CUBIC_BEZIER]: ['error', {}],\n [VALID_NUMBER]: ['error', {}],\n [VALID_LINK]: ['error', {}],\n [VALID_BOOLEAN]: ['error', {}],\n [VALID_STRING]: ['error', {}],\n [VALID_STROKE_STYLE]: ['error', {}],\n [VALID_BORDER]: ['error', {}],\n [VALID_TRANSITION]: ['error', {}],\n [VALID_SHADOW]: ['error', {}],\n [VALID_GRADIENT]: ['error', {}],\n [VALID_TYPOGRAPHY]: ['error', {}],\n [CONSISTENT_NAMING]: ['warn', { format: 'kebab-case' }],\n};\n","import { merge } from 'merge-anything';\nimport coreLintPlugin, { RECOMMENDED_CONFIG } from './lint/plugin-core/index.js';\nimport Logger from './logger.js';\nimport type { Config, ConfigInit, ConfigOptions, LintRuleSeverity } from './types.js';\n\nconst TRAILING_SLASH_RE = /\\/*$/;\n\n/**\n * Validate and normalize a config\n */\nexport default function defineConfig(\n rawConfig: Config,\n { logger = new Logger(), cwd }: ConfigOptions = {} as ConfigOptions,\n): ConfigInit {\n const configStart = performance.now();\n\n if (!cwd) {\n logger.error({ group: 'config', label: 'core', message: 'defineConfig() missing `cwd` for JS API' });\n }\n\n const config = merge({}, rawConfig) as unknown as ConfigInit;\n\n // 1. normalize and init\n normalizeTokens({ rawConfig, config, logger, cwd });\n normalizeOutDir({ config, cwd, logger });\n normalizePlugins({ config, logger });\n normalizeLint({ config, logger });\n normalizeIgnore({ config, logger });\n\n // 2. Start build by calling config()\n for (const plugin of config.plugins) {\n plugin.config?.({ ...config }, { logger });\n }\n\n // 3. finish\n logger.debug({\n group: 'parser',\n label: 'config',\n message: 'Finish config validation',\n timing: performance.now() - configStart,\n });\n return config;\n}\n\n/** Normalize config.tokens */\nfunction normalizeTokens({\n rawConfig,\n config,\n logger,\n cwd,\n}: {\n rawConfig: Config;\n config: ConfigInit;\n logger: Logger;\n cwd: URL;\n}) {\n if (rawConfig.tokens === undefined) {\n config.tokens = [\n // @ts-expect-error we’ll normalize in next step\n './tokens.json',\n ];\n } else if (typeof rawConfig.tokens === 'string') {\n config.tokens = [\n // @ts-expect-error we’ll normalize in next step\n rawConfig.tokens,\n ];\n } else if (Array.isArray(rawConfig.tokens)) {\n config.tokens = [];\n for (const file of rawConfig.tokens) {\n if (typeof file === 'string' || (file as URL) instanceof URL) {\n config.tokens.push(\n // @ts-expect-error we’ll normalize in next step\n file,\n );\n } else {\n logger.error({\n group: 'config',\n label: 'tokens',\n message: `Expected array of strings, encountered ${JSON.stringify(file)}`,\n });\n }\n }\n } else {\n logger.error({\n group: 'config',\n label: 'tokens',\n message: `Expected string or array of strings, received ${typeof rawConfig.tokens}`,\n });\n }\n for (let i = 0; i < config.tokens!.length; i++) {\n const filepath = config.tokens[i]!;\n if (filepath instanceof URL) {\n continue; // skip if already resolved\n }\n try {\n config.tokens[i] = new URL(filepath, cwd);\n } catch {\n logger.error({ group: 'config', label: 'tokens', message: `Invalid URL ${filepath}` });\n }\n }\n\n config.alphabetize = rawConfig.alphabetize ?? true;\n}\n\n/** Normalize config.outDir */\nfunction normalizeOutDir({ config, cwd, logger }: { config: ConfigInit; logger: Logger; cwd: URL }) {\n if (config.outDir instanceof URL) {\n // noop\n } else if (typeof config.outDir === 'undefined') {\n config.outDir = new URL('./tokens/', cwd);\n } else if (typeof config.outDir !== 'string') {\n logger.error({\n group: 'config',\n label: 'outDir',\n message: `Expected string, received ${JSON.stringify(config.outDir)}`,\n });\n } else {\n config.outDir = new URL(config.outDir, cwd);\n // always add trailing slash so URL treats it as a directory.\n // do AFTER it has been normalized to POSIX paths with `href` (don’t use Node internals here! This may run in the browser)\n config.outDir = new URL(config.outDir.href.replace(TRAILING_SLASH_RE, '/'));\n }\n}\n\n/** Normalize config.plugins */\nfunction normalizePlugins({ config, logger }: { config: ConfigInit; logger: Logger }) {\n if (typeof config.plugins === 'undefined') {\n config.plugins = [];\n }\n if (!Array.isArray(config.plugins)) {\n logger.error({\n group: 'config',\n label: 'plugins',\n message: `Expected array of plugins, received ${JSON.stringify(config.plugins)}`,\n });\n }\n config.plugins.push(coreLintPlugin());\n for (let n = 0; n < config.plugins.length; n++) {\n const plugin = config.plugins[n];\n if (typeof plugin !== 'object') {\n logger.error({\n group: 'config',\n label: `plugin[${n}]`,\n message: `Expected output plugin, received ${JSON.stringify(plugin)}`,\n });\n } else if (!plugin.name) {\n logger.error({ group: 'config', label: `plugin[${n}]`, message: `Missing \"name\"` });\n }\n }\n // order plugins with \"enforce\"\n config.plugins.sort((a, b) => {\n if (a.enforce === 'pre' && b.enforce !== 'pre') {\n return -1;\n } else if (a.enforce === 'post' && b.enforce !== 'post') {\n return 1;\n }\n return 0;\n });\n}\n\nfunction normalizeLint({ config, logger }: { config: ConfigInit; logger: Logger }) {\n if (config.lint !== undefined) {\n if (config.lint === null || typeof config.lint !== 'object' || Array.isArray(config.lint)) {\n logger.error({ group: 'config', label: 'lint', message: 'Must be an object' });\n }\n if (!config.lint.build) {\n config.lint.build = { enabled: true };\n }\n if (config.lint.build.enabled !== undefined) {\n if (typeof config.lint.build.enabled !== 'boolean') {\n logger.error({\n group: 'config',\n label: 'lint › build › enabled',\n message: `Expected boolean, received ${JSON.stringify(config.lint.build)}`,\n });\n }\n } else {\n config.lint.build.enabled = true;\n }\n\n if (config.lint.rules === undefined) {\n config.lint.rules = { ...RECOMMENDED_CONFIG };\n } else {\n if (config.lint.rules === null || typeof config.lint.rules !== 'object' || Array.isArray(config.lint.rules)) {\n logger.error({\n group: 'config',\n label: 'lint › rules',\n message: `Expected object, received ${JSON.stringify(config.lint.rules)}`,\n });\n return;\n }\n\n const allRules = new Map<string, string>();\n for (const plugin of config.plugins) {\n if (typeof plugin.lint !== 'function') {\n continue;\n }\n const pluginRules = plugin.lint();\n if (!pluginRules || Array.isArray(pluginRules) || typeof pluginRules !== 'object') {\n logger.error({\n group: 'config',\n label: `plugin › ${plugin.name}`,\n message: `Expected object for lint() received ${JSON.stringify(pluginRules)}`,\n });\n continue;\n }\n for (const rule of Object.keys(pluginRules)) {\n // Note: sometimes plugins will be loaded multiple times, in which case it’s expected\n // they’re register rules again for lint(). Only throw an error if plugin A and plugin B’s\n // rules conflict.\n if (allRules.get(rule) && allRules.get(rule) !== plugin.name) {\n logger.error({\n group: 'config',\n label: `plugin › ${plugin.name}`,\n message: `Duplicate rule ${rule} already registered by plugin ${allRules.get(rule)}`,\n });\n }\n allRules.set(rule, plugin.name);\n }\n }\n\n for (const id of Object.keys(config.lint.rules)) {\n if (!allRules.has(id)) {\n logger.error({\n group: 'config',\n label: `lint › rule › ${id}`,\n message: 'Unknown rule. Is the plugin installed?',\n });\n }\n\n const value = config.lint.rules[id];\n let severity: LintRuleSeverity = 'off';\n let options: any = {};\n if (typeof value === 'number' || typeof value === 'string') {\n severity = value;\n } else if (Array.isArray(value)) {\n severity = value[0] as LintRuleSeverity;\n options = value[1];\n } else if (value !== undefined) {\n logger.error({\n group: 'config',\n label: `lint › rule › ${id}`,\n message: `Invalid eyntax. Expected \\`string | number | Array\\`, received ${JSON.stringify(value)}}`,\n });\n }\n config.lint.rules[id] = [severity, options];\n if (typeof severity === 'number') {\n if (severity !== 0 && severity !== 1 && severity !== 2) {\n logger.error({\n group: 'config',\n label: `lint › rule › ${id}`,\n message: `Invalid number ${severity}. Specify 0 (off), 1 (warn), or 2 (error).`,\n });\n }\n config.lint.rules[id]![0] = (['off', 'warn', 'error'] as const)[severity]!;\n } else if (typeof severity === 'string') {\n if (severity !== 'off' && severity !== 'warn' && severity !== 'error') {\n logger.error({\n group: 'config',\n label: `lint › rule › ${id}`,\n message: `Invalid string ${JSON.stringify(severity)}. Specify \"off\", \"warn\", or \"error\".`,\n });\n }\n } else if (value !== null) {\n logger.error({\n group: 'config',\n label: `lint › rule › ${id}`,\n message: `Expected string or number, received ${JSON.stringify(value)}`,\n });\n }\n }\n }\n } else {\n config.lint = {\n build: { enabled: true },\n rules: { ...RECOMMENDED_CONFIG },\n };\n }\n}\n\nfunction normalizeIgnore({ config, logger }: { config: ConfigInit; logger: Logger }) {\n if (!config.ignore) {\n config.ignore = {} as typeof config.ignore;\n }\n config.ignore.tokens ??= [];\n config.ignore.deprecated ??= false;\n if (!Array.isArray(config.ignore.tokens) || config.ignore.tokens.some((x) => typeof x !== 'string')) {\n logger.error({\n group: 'config',\n label: 'ignore › tokens',\n message: `Expected array of strings, received ${JSON.stringify(config.ignore.tokens)}`,\n });\n }\n if (typeof config.ignore.deprecated !== 'boolean') {\n logger.error({\n group: 'config',\n label: 'ignore › deprecated',\n message: `Expected boolean, received ${JSON.stringify(config.ignore.deprecated)}`,\n });\n }\n}\n\n/** Merge configs */\nexport function mergeConfigs(a: Config, b: Config): Config {\n return merge(a, b);\n}\n","import type { InputSourceWithDocument } from '@terrazzo/json-schema-tools';\nimport { pluralize, type TokenNormalizedSet } from '@terrazzo/token-tools';\nimport { merge } from 'merge-anything';\nimport type { LogEntry, default as Logger } from '../logger.js';\nimport type { ConfigInit } from '../types.js';\n\nexport { RECOMMENDED_CONFIG } from './plugin-core/index.js';\n\nexport interface LintRunnerOptions {\n tokens: TokenNormalizedSet;\n filename?: URL;\n config: ConfigInit;\n sources: InputSourceWithDocument[];\n logger: Logger;\n}\n\nexport default async function lintRunner({\n tokens,\n filename,\n config = {} as ConfigInit,\n sources,\n logger,\n}: LintRunnerOptions): Promise<void> {\n const { plugins = [], lint } = config;\n const sourceByFilename: Record<string, InputSourceWithDocument> = {};\n for (const source of sources) {\n sourceByFilename[source.filename!.href] = source;\n }\n const unusedLintRules = Object.keys(lint?.rules ?? {});\n\n const errors: LogEntry[] = [];\n const warnings: LogEntry[] = [];\n for (const plugin of plugins) {\n if (typeof plugin.lint === 'function') {\n const s = performance.now();\n\n const linter = plugin.lint();\n\n await Promise.all(\n Object.entries(linter).map(async ([id, rule]) => {\n if (!(id in lint.rules) || lint.rules[id] === null) {\n return;\n }\n\n // tick off used rule\n const unusedLintRuleI = unusedLintRules.indexOf(id);\n if (unusedLintRuleI !== -1) {\n unusedLintRules.splice(unusedLintRuleI, 1);\n }\n\n const [severity, options] = lint.rules[id]!;\n\n if (severity === 'off') {\n return;\n }\n // note: this usually isn’t a Promise, but it _might_ be!\n await rule.create({\n id,\n report(descriptor) {\n let message = '';\n if (!descriptor.message && !descriptor.messageId) {\n logger.error({\n group: 'lint',\n label: `${plugin.name} › lint › ${id}`,\n message: 'Unable to report error: missing message or messageId',\n });\n }\n\n // handle message or messageId\n if (descriptor.message) {\n message = descriptor.message;\n } else {\n if (!(descriptor.messageId! in (rule.meta?.messages ?? {}))) {\n logger.error({\n group: 'lint',\n label: `${plugin.name} › lint › ${id}`,\n message: `messageId \"${descriptor.messageId}\" does not exist`,\n });\n }\n message = rule.meta?.messages?.[descriptor.messageId as keyof typeof rule.meta.messages] ?? '';\n }\n\n // replace with descriptor.data (if any)\n if (descriptor.data && typeof descriptor.data === 'object') {\n for (const [k, v] of Object.entries(descriptor.data)) {\n // lazy formatting\n const formatted = ['string', 'number', 'boolean'].includes(typeof v) ? String(v) : JSON.stringify(v);\n message = message.replace(/{{[^}]+}}/g, (inner) => {\n const key = inner.substring(2, inner.length - 2).trim();\n return key === k ? formatted : inner;\n });\n }\n }\n\n (severity === 'error' ? errors : warnings).push({\n group: 'lint',\n label: id,\n message,\n filename,\n node: descriptor.node,\n src: sourceByFilename[descriptor.filename!]?.src,\n });\n },\n tokens,\n filename,\n sources,\n options: merge(\n rule.meta?.defaultOptions ?? [],\n rule.defaultOptions ?? [], // Note: is this the correct order to merge in?\n options,\n ),\n });\n }),\n );\n\n logger.debug({\n group: 'lint',\n label: plugin.name,\n message: 'Finished',\n timing: performance.now() - s,\n });\n }\n }\n\n const errCount = errors.length ? `${errors.length} ${pluralize(errors.length, 'error', 'errors')}` : '';\n const warnCount = warnings.length ? `${warnings.length} ${pluralize(warnings.length, 'warning', 'warnings')}` : '';\n if (errors.length > 0) {\n logger.error(...errors, {\n group: 'lint',\n label: 'lint',\n message: [errCount, warnCount].filter(Boolean).join(', '),\n });\n }\n if (warnings.length > 0) {\n logger.warn(...warnings, { group: 'lint', label: 'lint', message: warnCount });\n }\n\n // warn user if they have unused lint rules (they might have meant to configure something!)\n for (const unusedRule of unusedLintRules) {\n logger.warn({ group: 'lint', label: 'lint', message: `Unknown lint rule \"${unusedRule}\"` });\n }\n}\n","import * as momoa from '@humanwhocodes/momoa';\n\n/** Momoa’s default parser, with preferred settings. */\nexport function toMomoa(srcRaw: any): momoa.DocumentNode {\n return momoa.parse(typeof srcRaw === 'string' ? srcRaw : JSON.stringify(srcRaw, undefined, 2), {\n mode: 'jsonc',\n ranges: true,\n tokens: true,\n });\n}\n","/**\n * If tokens are found inside a resolver, strip out the resolver paths (don’t\n * include \"sets\"/\"modifiers\" in the token ID etc.)\n */\nexport function filterResolverPaths(path: string[]): string[] {\n switch (path[0]) {\n case 'sets': {\n return path.slice(4);\n }\n case 'modifiers': {\n return path.slice(5);\n }\n case 'resolutionOrder': {\n switch (path[2]) {\n case 'sources': {\n return path.slice(4);\n }\n case 'contexts': {\n return path.slice(5);\n }\n }\n break;\n }\n }\n return path;\n}\n\n/** Make a deterministic string from an object */\nexport function getPermutationID(input: Record<string, string | undefined>): string {\n const keys = Object.keys(input).sort((a, b) => a.localeCompare(b, 'en-us', { numeric: true }));\n return JSON.stringify(Object.fromEntries(keys.map((k) => [k, input[k]])));\n}\n","import type * as momoa from '@humanwhocodes/momoa';\n\nimport type Logger from '../logger.js';\nimport type { LogEntry } from '../logger.js';\n\ninterface FatalLogEntry extends Omit<LogEntry, 'continueOnError'> {}\n\nexport function assert(value: unknown, logger: Logger, entry: FatalLogEntry): asserts value {\n if (!value) {\n logger.error(entry);\n }\n}\n\nexport function assertStringNode(\n value: momoa.AnyNode | undefined,\n logger: Logger,\n entry: FatalLogEntry,\n): asserts value is momoa.StringNode {\n assert(value?.type === 'String', logger, entry);\n}\n\nexport function assertObjectNode(\n value: momoa.AnyNode | undefined,\n logger: Logger,\n entry: FatalLogEntry,\n): asserts value is momoa.ObjectNode {\n assert(value?.type === 'Object', logger, entry);\n}\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport { FONT_WEIGHTS, isAlias, parseColor } from '@terrazzo/token-tools';\nimport type Logger from '../logger.js';\n\ninterface PreValidatedToken {\n id: string;\n $type: string;\n $value: unknown;\n mode: {\n '.': { $value: unknown; source: { node: any; filename: string | undefined } };\n [mode: string]: { $value: unknown; source: { node: any; filename: string | undefined } };\n };\n}\n\n/**\n * Normalize token value.\n * The reason for the “any” typing is this aligns various user-provided inputs to the type\n */\nexport function normalize(token: PreValidatedToken, { logger, src }: { logger: Logger; src: string }) {\n const entry = { group: 'parser' as const, label: 'init', src };\n\n function normalizeFontFamily(value: unknown): string[] {\n return typeof value === 'string' ? [value] : (value as string[]);\n }\n\n function normalizeFontWeight(value: unknown): number {\n return (typeof value === 'string' && FONT_WEIGHTS[value as keyof typeof FONT_WEIGHTS]) || (value as number);\n }\n\n function normalizeColor(value: unknown, node: momoa.AnyNode | undefined) {\n if (typeof value === 'string' && !isAlias(value)) {\n logger.warn({\n ...entry,\n node,\n message: `${token.id}: string colors will be deprecated in a future version. Please update to object notation`,\n });\n try {\n return parseColor(value);\n } catch {\n return { colorSpace: 'srgb', components: [0, 0, 0], alpha: 1 };\n }\n } else if (value && typeof value === 'object') {\n if ((value as any).alpha === undefined) {\n (value as any).alpha = 1;\n }\n }\n return value;\n }\n\n switch (token.$type) {\n case 'color': {\n for (const mode of Object.keys(token.mode)) {\n token.mode[mode]!.$value = normalizeColor(token.mode[mode]!.$value, token.mode[mode]!.source.node);\n }\n token.$value = token.mode['.'].$value;\n break;\n }\n\n case 'fontFamily': {\n for (const mode of Object.keys(token.mode)) {\n token.mode[mode]!.$value = normalizeFontFamily(token.mode[mode]!.$value);\n }\n token.$value = token.mode['.'].$value;\n break;\n }\n\n case 'fontWeight': {\n for (const mode of Object.keys(token.mode)) {\n token.mode[mode]!.$value = normalizeFontWeight(token.mode[mode]!.$value);\n }\n token.$value = token.mode['.'].$value;\n break;\n }\n\n case 'border': {\n for (const mode of Object.keys(token.mode)) {\n const border = token.mode[mode]!.$value as any;\n if (!border || typeof border !== 'object') {\n continue;\n }\n if (border.color) {\n border.color = normalizeColor(\n border.color,\n getObjMember(token.mode[mode]!.source.node as momoa.ObjectNode, 'color'),\n );\n }\n }\n token.$value = token.mode['.'].$value;\n break;\n }\n\n case 'shadow': {\n for (const mode of Object.keys(token.mode)) {\n // normalize to array\n if (!Array.isArray(token.mode[mode]!.$value)) {\n token.mode[mode]!.$value = [token.mode[mode]!.$value];\n }\n const $value = token.mode[mode]!.$value as any[];\n for (let i = 0; i < $value.length; i++) {\n const shadow = $value[i]!;\n if (!shadow || typeof shadow !== 'object') {\n continue;\n }\n const shadowNode = (\n token.mode[mode]!.source.node.type === 'Array'\n ? token.mode[mode]!.source.node.elements[i]!.value\n : token.mode[mode]!.source.node\n ) as momoa.ObjectNode;\n if (shadow.color) {\n shadow.color = normalizeColor(shadow.color, getObjMember(shadowNode, 'color'));\n }\n if (!('inset' in shadow)) {\n shadow.inset = false;\n }\n }\n }\n token.$value = token.mode['.'].$value;\n break;\n }\n\n case 'gradient': {\n for (const mode of Object.keys(token.mode)) {\n if (!Array.isArray(token.mode[mode]!.$value)) {\n continue;\n }\n const $value = token.mode[mode]!.$value as any[];\n for (let i = 0; i < $value.length; i++) {\n const stop = $value[i]!;\n if (!stop || typeof stop !== 'object') {\n continue;\n }\n const stopNode = (token.mode[mode]!.source.node as momoa.ArrayNode)?.elements?.[i]?.value as momoa.ObjectNode;\n if (stop.color) {\n stop.color = normalizeColor(stop.color, getObjMember(stopNode, 'color'));\n }\n }\n }\n token.$value = token.mode['.'].$value;\n break;\n }\n\n case 'typography': {\n for (const mode of Object.keys(token.mode)) {\n const $value = token.mode[mode]!.$value as any;\n if (typeof $value !== 'object') {\n return;\n }\n for (const [k, v] of Object.entries($value)) {\n switch (k) {\n case 'fontFamily': {\n $value[k] = normalizeFontFamily(v);\n break;\n }\n case 'fontWeight': {\n $value[k] = normalizeFontWeight(v);\n break;\n }\n }\n }\n }\n token.$value = token.mode['.'].$value;\n break;\n }\n }\n}\n","import * as momoa from '@humanwhocodes/momoa';\nimport { encodeFragment, getObjMember, type InputSourceWithDocument, parseRef } from '@terrazzo/json-schema-tools';\nimport {\n type GroupNormalized,\n isAlias,\n parseAlias,\n type TokenNormalized,\n type TokenNormalizedSet,\n} from '@terrazzo/token-tools';\nimport wcmatch from 'wildcard-match';\nimport type { default as Logger } from '../logger.js';\nimport type { Config, ReferenceObject, RefMap } from '../types.js';\n\n/** Convert valid DTCG alias to $ref */\nexport function aliasToGroupRef(alias: string): ReferenceObject | undefined {\n const id = parseAlias(alias);\n // if this is invalid, stop\n if (id === alias) {\n return;\n }\n return { $ref: `#/${id.replace(/~/g, '~0').replace(/\\//g, '~1').replace(/\\./g, '/')}` };\n}\n\n/** Convert valid DTCG alias to $ref */\nexport function aliasToTokenRef(alias: string, mode?: string): ReferenceObject | undefined {\n const id = parseAlias(alias);\n // if this is invalid, stop\n if (id === alias) {\n return;\n }\n return {\n $ref: `#/${id.replace(/~/g, '~0').replace(/\\//g, '~1').replace(/\\./g, '/')}${mode && mode !== '.' ? `/$extensions/mode/${mode}` : ''}/$value`,\n };\n}\n\nexport interface TokenFromNodeOptions {\n groups: Record<string, GroupNormalized>;\n path: string[];\n source: InputSourceWithDocument;\n ignore: Config['ignore'];\n}\n\n/** Generate a TokenNormalized from a Momoa node */\nexport function tokenFromNode(\n node: momoa.AnyNode,\n { groups, path, source, ignore }: TokenFromNodeOptions,\n): TokenNormalized | undefined {\n const isToken = node.type === 'Object' && !!getObjMember(node, '$value') && !path.includes('$extensions');\n if (!isToken) {\n return undefined;\n }\n\n const jsonID = encodeFragment(path);\n const id = path.join('.').replace(/\\.\\$root$/, '');\n\n const originalToken = momoa.evaluate(node) as any;\n\n const groupID = encodeFragment(path.slice(0, -1));\n const group = groups[groupID]!;\n if (group?.tokens && !group.tokens.includes(id)) {\n group.tokens.push(id);\n }\n\n const nodeSource = { filename: source.filename.href, node };\n const token: TokenNormalized = {\n id,\n $type: originalToken.$type || group.$type,\n $description: originalToken.$description || undefined,\n $deprecated: originalToken.$deprecated ?? group.$deprecated ?? undefined, // ⚠️ MUST use ?? here to inherit false correctly\n $value: originalToken.$value,\n $extensions: originalToken.$extensions || undefined,\n $extends: originalToken.$extends || undefined,\n aliasChain: undefined,\n aliasedBy: undefined,\n aliasOf: undefined,\n partialAliasOf: undefined,\n dependencies: undefined,\n group,\n originalValue: undefined, // undefined because we are not sure if the value has been modified or not\n source: nodeSource,\n jsonID,\n mode: {\n '.': {\n $value: originalToken.$value,\n aliasOf: undefined,\n aliasChain: undefined,\n partialAliasOf: undefined,\n aliasedBy: undefined,\n originalValue: undefined,\n dependencies: undefined,\n source: {\n ...nodeSource,\n node: (getObjMember(nodeSource.node, '$value') ?? nodeSource.node) as momoa.ObjectNode,\n },\n },\n },\n };\n\n // after assembling token, handle ignores to see if the final result should be ignored or not\n // filter out ignored\n if ((ignore?.deprecated && token.$deprecated) || (ignore?.tokens && wcmatch(ignore.tokens)(token.id))) {\n return;\n }\n\n const $extensions = getObjMember(node, '$extensions');\n if ($extensions) {\n const modeNode = getObjMember($extensions as momoa.ObjectNode, 'mode') as momoa.ObjectNode;\n for (const mode of Object.keys((token.$extensions as any).mode ?? {})) {\n const modeValue = (token.$extensions as any).mode[mode];\n token.mode[mode] = {\n $value: modeValue,\n aliasOf: undefined,\n aliasChain: undefined,\n partialAliasOf: undefined,\n aliasedBy: undefined,\n originalValue: undefined,\n dependencies: undefined,\n source: {\n ...nodeSource,\n node: getObjMember(modeNode, mode) as any,\n },\n };\n }\n }\n return token;\n}\n\nexport interface TokenRawValues {\n jsonID: string;\n originalValue: any;\n source: TokenNormalized['source'];\n mode: Record<string, { originalValue: any; source: TokenNormalized['source'] }>;\n}\n\n/** Generate originalValue and source from node */\nexport function tokenRawValuesFromNode(\n node: momoa.AnyNode,\n { filename, path }: { filename: string; path: string[] },\n): TokenRawValues | undefined {\n const isToken = node.type === 'Object' && getObjMember(node, '$value') && !path.includes('$extensions');\n if (!isToken) {\n return undefined;\n }\n\n const jsonID = encodeFragment(path);\n const rawValues: TokenRawValues = {\n jsonID,\n originalValue: momoa.evaluate(node),\n source: { loc: filename, filename, node: node as momoa.ObjectNode },\n mode: {},\n };\n rawValues.mode['.'] = {\n originalValue: rawValues.originalValue.$value,\n source: { ...rawValues.source, node: getObjMember(node as momoa.ObjectNode, '$value') as momoa.ObjectNode },\n };\n const $extensions = getObjMember(node, '$extensions');\n if ($extensions) {\n const modes = getObjMember($extensions as momoa.ObjectNode, 'mode');\n if (modes) {\n for (const modeMember of (modes as momoa.ObjectNode).members) {\n const mode = (modeMember.name as momoa.StringNode).value;\n rawValues.mode[mode] = {\n originalValue: momoa.evaluate(modeMember.value),\n source: { loc: filename, filename, node: modeMember.value as momoa.ObjectNode },\n };\n }\n }\n }\n\n return rawValues;\n}\n\n/** Arbitrary keys that should be associated with a token group */\nconst GROUP_PROPERTIES = ['$deprecated', '$description', '$extensions', '$type'];\n\n/**\n * Generate a group from a node.\n * This method mutates the groups index as it goes because of group inheritance.\n * As it encounters new groups it may have to update other groups.\n */\nexport function groupFromNode(\n node: momoa.ObjectNode,\n { path, groups }: { path: string[]; groups: Record<string, GroupNormalized> },\n): GroupNormalized {\n const id = path.join('.');\n const jsonID = encodeFragment(path);\n\n // group\n if (!groups[jsonID]) {\n groups[jsonID] = {\n id,\n $deprecated: undefined,\n $description: undefined,\n $extensions: undefined,\n $type: undefined,\n tokens: [],\n };\n }\n\n // first, copy all parent groups’ properties into local, since they cascade\n const groupIDs = Object.keys(groups);\n groupIDs.sort(); // these may not be sorted; re-sort just in case (order determines final values)\n for (const groupID of groupIDs) {\n const isParentGroup = jsonID.startsWith(groupID) && groupID !== jsonID;\n if (isParentGroup) {\n groups[jsonID].$deprecated = groups[groupID]?.$deprecated ?? groups[jsonID].$deprecated;\n groups[jsonID].$description = groups[groupID]?.$description ?? groups[jsonID].$description;\n groups[jsonID].$type = groups[groupID]?.$type ?? groups[jsonID].$type;\n }\n }\n\n // next, override cascading values with local\n for (const m of node.members) {\n if (m.name.type !== 'String' || !GROUP_PROPERTIES.includes(m.name.value)) {\n continue;\n }\n (groups as any)[jsonID]![m.name.value] = momoa.evaluate(m.value);\n }\n\n return groups[jsonID]!;\n}\n\nexport interface GraphAliasesOptions {\n tokens: TokenNormalizedSet;\n sources: Record<string, InputSourceWithDocument>;\n logger: Logger;\n}\n\n/**\n * Link and reverse-link tokens in one pass.\n */\nexport function graphAliases(refMap: RefMap, { tokens, logger, sources }: GraphAliasesOptions) {\n // mini-helper that probably shouldn’t be used outside this function\n const getTokenRef = (ref: string) => ref.replace(/\\/(\\$value|\\$extensions)\\/?.*/, '');\n\n for (const [jsonID, { refChain }] of Object.entries(refMap)) {\n if (!refChain.length) {\n continue;\n }\n\n const mode = jsonID.match(/\\/\\$extensions\\/mode\\/([^/]+)/)?.[1] || '.';\n const rootRef = getTokenRef(jsonID);\n const modeValue = tokens[rootRef]?.mode[mode];\n if (!modeValue) {\n continue;\n }\n\n // aliasChain + dependencies\n if (!modeValue.dependencies) {\n modeValue.dependencies = [];\n }\n modeValue.dependencies.push(...refChain.filter((r) => !modeValue.dependencies!.includes(r)));\n modeValue.dependencies.sort((a, b) => a.localeCompare(b, 'en-us', { numeric: true }));\n\n // Top alias\n const isTopLevelAlias = jsonID.endsWith('/$value') || tokens[jsonID];\n if (isTopLevelAlias) {\n modeValue.aliasOf = refToTokenID(refChain.at(-1)!);\n const aliasChain = refChain.map(refToTokenID) as string[];\n modeValue.aliasChain = [...aliasChain];\n }\n\n // Partial alias\n const partial = jsonID\n .replace(/.*\\/\\$value\\/?/, '')\n .split('/')\n .filter(Boolean);\n if (partial.length && modeValue.$value && typeof modeValue.$value === 'object') {\n let node: any = modeValue.$value;\n let sourceNode = modeValue.source.node as momoa.AnyNode;\n if (!modeValue.partialAliasOf) {\n modeValue.partialAliasOf = Array.isArray(modeValue.$value) || tokens[rootRef]?.$type === 'shadow' ? [] : {};\n }\n let partialAliasOf = modeValue.partialAliasOf as any;\n // special case: for shadows, normalize object to array\n if (tokens[rootRef]?.$type === 'shadow' && !Array.isArray(node)) {\n if (Array.isArray(modeValue.partialAliasOf) && !modeValue.partialAliasOf.length) {\n modeValue.partialAliasOf.push({} as any);\n }\n partialAliasOf = (modeValue.partialAliasOf as any)[0]!;\n }\n\n for (let i = 0; i < partial.length; i++) {\n let key = partial[i] as string | number;\n if (String(Number(key)) === key) {\n key = Number(key);\n }\n if (key in node && typeof node[key] !== 'undefined') {\n node = node[key];\n if (sourceNode.type === 'Object') {\n sourceNode = getObjMember(sourceNode, key as string) ?? sourceNode;\n } else if (sourceNode.type === 'Array') {\n sourceNode = sourceNode.elements[key as number]?.value ?? sourceNode;\n }\n }\n // last node: apply partial alias\n if (i === partial.length - 1) {\n // important: we want to get only the immediate alias [0], not the final one [.length - 1].\n // if we resolve this too far, we could get incorrect values especially in plugin-css if a\n // user is applying cascades to the intermediate aliases but not the final one\n const aliasedID = getTokenRef(refChain[0]!);\n if (!(aliasedID in tokens)) {\n logger.error({\n group: 'parser',\n label: 'init',\n message: `Invalid alias: ${aliasedID}`,\n node: sourceNode,\n src: sources[tokens[rootRef]!.source.filename!]?.src,\n });\n break;\n }\n partialAliasOf[key] = refToTokenID(aliasedID);\n }\n // otherwise, create deeper structure and continue traversing\n if (!(key in partialAliasOf)) {\n partialAliasOf[key] = Array.isArray(node) ? [] : {};\n }\n partialAliasOf = partialAliasOf[key];\n }\n }\n\n // aliasedBy (reversed)\n const aliasedByRefs = [jsonID, ...refChain].reverse();\n for (let i = 0; i < aliasedByRefs.length; i++) {\n const baseRef = getTokenRef(aliasedByRefs[i]!);\n const baseToken = tokens[baseRef]?.mode[mode] || tokens[baseRef];\n if (!baseToken) {\n continue;\n }\n const upstream = aliasedByRefs.slice(i + 1);\n if (!upstream.length) {\n break;\n }\n if (!baseToken.aliasedBy) {\n baseToken.aliasedBy = [];\n }\n for (let j = 0; j < upstream.length; j++) {\n const downstream = refToTokenID(upstream[j]!)!;\n if (!baseToken.aliasedBy.includes(downstream)) {\n baseToken.aliasedBy.push(downstream);\n if (mode === '.') {\n tokens[baseRef]!.aliasedBy = baseToken.aliasedBy;\n }\n }\n }\n baseToken.aliasedBy.sort((a, b) => a.localeCompare(b, 'en-us', { numeric: true })); // sort, because the ordering is arbitrary and flaky\n }\n\n if (mode === '.') {\n tokens[rootRef]!.aliasChain = modeValue.aliasChain;\n tokens[rootRef]!.aliasedBy = modeValue.aliasedBy;\n tokens[rootRef]!.aliasOf = modeValue.aliasOf;\n tokens[rootRef]!.dependencies = modeValue.dependencies;\n tokens[rootRef]!.partialAliasOf = modeValue.partialAliasOf;\n }\n }\n}\n\n/** Convert valid DTCG alias to $ref Momoa Node */\nexport function aliasToMomoa(\n alias: string,\n loc: momoa.ObjectNode['loc'] = {\n start: { line: -1, column: -1, offset: 0 },\n end: { line: -1, column: -1, offset: 0 },\n },\n): momoa.ObjectNode | undefined {\n const $ref = aliasToTokenRef(alias);\n if (!$ref) {\n return;\n }\n return {\n type: 'Object',\n members: [\n {\n type: 'Member',\n name: { type: 'String', value: '$ref', loc },\n value: { type: 'String', value: $ref.$ref, loc },\n loc,\n },\n ],\n loc,\n };\n}\n\n/**\n * Convert Reference Object to token ID.\n * This can then be turned into an alias by surrounding with { … }\n * ⚠️ This is not mode-aware. This will flatten multiple modes into the same root token.\n */\nexport function refToTokenID($ref: ReferenceObject | string): string | undefined {\n const path = typeof $ref === 'object' ? $ref.$ref : $ref;\n if (typeof path !== 'string') {\n return;\n }\n const { subpath } = parseRef(path);\n // if this ID comes from #/$defs/…, strip the first 2 segments to get the global ID\n if (subpath?.[0] === '$defs') {\n subpath.splice(0, 2);\n }\n return (subpath?.length && subpath.join('.').replace(/\\.(\\$root|\\$value|\\$extensions).*$/, '')) || undefined;\n}\n\nconst EXPECTED_NESTED_ALIAS: Record<string, Record<string, string[]>> = {\n border: {\n color: ['color'],\n stroke: ['strokeStyle'],\n width: ['dimension'],\n },\n gradient: {\n color: ['color'],\n position: ['number'],\n },\n shadow: {\n color: ['color'],\n offsetX: ['dimension'],\n offsetY: ['dimension'],\n blur: ['dimension'],\n spread: ['dimension'],\n inset: ['boolean'],\n },\n strokeStyle: {\n dashArray: ['dimension'],\n },\n transition: {\n duration: ['duration'],\n delay: ['duration'],\n timingFunction: ['cubicBezier'],\n },\n typography: {\n fontFamily: ['fontFamily'],\n fontWeight: ['fontWeight'],\n fontSize: ['dimension'],\n lineHeight: ['dimension', 'number'],\n letterSpacing: ['dimension'],\n\n // CSS extensions (that aren’t \"string\")\n paragraphSpacing: ['dimension', 'string'],\n wordSpacing: ['dimension', 'string'],\n },\n};\n\n/**\n * Resolve DTCG aliases, $extends, and $ref\n */\nexport function resolveAliases(\n tokens: TokenNormalizedSet,\n { logger, refMap, sources }: { logger: Logger; refMap: RefMap; sources: Record<string, InputSourceWithDocument> },\n): void {\n for (const token of Object.values(tokens)) {\n const aliasEntry = {\n group: 'parser' as const,\n label: 'init',\n src: sources[token.source.filename!]?.src,\n node: getObjMember(token.source.node, '$value'),\n };\n\n for (const mode of Object.keys(token.mode)) {\n function resolveInner(alias: string, refChain: string[]): string {\n const nextRef = aliasToTokenRef(alias, mode)?.$ref;\n if (!nextRef) {\n logger.error({ ...aliasEntry, message: `Internal error resolving ${JSON.stringify(refChain)}` });\n throw new Error('Internal error');\n }\n if (refChain.includes(nextRef)) {\n logger.error({ ...aliasEntry, message: 'Circular alias detected.' });\n }\n const nextJSONID = nextRef.replace(/\\/(\\$value|\\$extensions).*/, '');\n const nextToken = tokens[nextJSONID]?.mode[mode] || tokens[nextJSONID]?.mode['.'];\n if (!nextToken) {\n logger.error({ ...aliasEntry, message: `Could not resolve alias ${alias}.` });\n }\n refChain.push(nextRef);\n if (isAlias(nextToken!.originalValue! as string)) {\n return resolveInner(nextToken!.originalValue! as string, refChain);\n }\n return nextJSONID;\n }\n\n function traverseAndResolve(\n value: any,\n { node, expectedTypes, path }: { node: momoa.AnyNode; expectedTypes?: string[]; path: (string | number)[] },\n ): any {\n if (typeof value !== 'string') {\n if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) {\n if (!value[i]) {\n continue;\n }\n value[i] = traverseAndResolve(value[i], {\n // biome-ignore lint/suspicious/noNonNullAssertedOptionalChain: we checked for this earlier\n node: (node as momoa.ArrayNode).elements?.[i]?.value!,\n // special case: cubicBezier\n expectedTypes: expectedTypes?.includes('cubicBezier') ? ['number'] : expectedTypes,\n path: [...path, i],\n }).$value;\n }\n } else if (typeof value === 'object') {\n for (const key of Object.keys(value)) {\n if (!expectedTypes?.length || !EXPECTED_NESTED_ALIAS[expectedTypes[0]!]) {\n continue;\n }\n value[key] = traverseAndResolve(value[key], {\n node: getObjMember(node as momoa.ObjectNode, key)!,\n expectedTypes: EXPECTED_NESTED_ALIAS[expectedTypes[0]!]![key],\n path: [...path, key],\n }).$value;\n }\n }\n return { $value: value };\n }\n\n if (!isAlias(value)) {\n if (!expectedTypes?.includes('string') && (value.includes('{') || value.includes('}'))) {\n logger.error({ ...aliasEntry, message: 'Invalid alias syntax.', node });\n }\n return { $value: value };\n }\n\n const refChain: string[] = [];\n const resolvedID = resolveInner(value, refChain);\n if (expectedTypes?.length && !expectedTypes.includes(tokens[resolvedID]!.$type)) {\n logger.error({\n ...aliasEntry,\n message: `Cannot alias to $type \"${tokens[resolvedID]!.$type}\" from $type \"${expectedTypes.join(' / ')}\".`,\n node,\n });\n }\n\n refMap[path.join('/')] = { filename: token.source.filename!, refChain };\n\n return {\n $type: tokens[resolvedID]!.$type,\n $value: tokens[resolvedID]!.mode[mode]?.$value || tokens[resolvedID]!.$value,\n };\n }\n\n // resolve DTCG aliases without\n const pathBase = mode === '.' ? token.jsonID : `${token.jsonID}/$extensions/mode/${mode}`;\n const { $type, $value } = traverseAndResolve(token.mode[mode]!.$value, {\n node: aliasEntry.node!,\n expectedTypes: token.$type ? [token.$type] : undefined,\n path: [pathBase, '$value'],\n });\n if (!token.$type) {\n (token as any).$type = $type;\n }\n if ($value) {\n token.mode[mode]!.$value = $value;\n }\n\n // fill in $type and $value\n if (mode === '.') {\n token.$value = token.mode[mode]!.$value;\n }\n }\n }\n}\n","import type * as momoa from '@humanwhocodes/momoa';\nimport {\n encodeFragment,\n findNode,\n getObjMember,\n type InputSourceWithDocument,\n mergeObjects,\n parseRef,\n replaceNode,\n traverse,\n} from '@terrazzo/json-schema-tools';\nimport { type GroupNormalized, isAlias, type TokenNormalizedSet } from '@terrazzo/token-tools';\nimport { filterResolverPaths } from '../lib/resolver-utils.js';\nimport type Logger from '../logger.js';\nimport type { ConfigInit, RefMap } from '../types.js';\nimport { assert, assertObjectNode, assertStringNode } from './assert.js';\nimport { normalize } from './normalize.js';\nimport {\n aliasToGroupRef,\n graphAliases,\n groupFromNode,\n refToTokenID,\n resolveAliases,\n tokenFromNode,\n tokenRawValuesFromNode,\n} from './token.js';\n\nexport interface ProcessTokensOptions {\n config: ConfigInit;\n logger: Logger;\n sourceByFilename: Record<string, InputSourceWithDocument>;\n sources: InputSourceWithDocument[];\n isResolver?: boolean;\n}\n\nexport function processTokens(\n rootSource: InputSourceWithDocument,\n { config, logger, sourceByFilename, isResolver }: ProcessTokensOptions,\n): TokenNormalizedSet {\n const entry = { group: 'parser' as const, label: 'init' };\n\n // 1. Inline $refs to discover any additional tokens\n const refMap: RefMap = {};\n function resolveRef(node: momoa.StringNode, chain: string[]): momoa.AnyNode {\n const { subpath } = parseRef(node.value);\n assert(subpath, logger, { ...entry, message: 'Can’t resolve $ref', node, src: rootSource.src });\n const next = findNode(rootSource.document, subpath);\n assert(next, logger, {\n ...entry,\n message: \"Can't find $ref\",\n node,\n src: rootSource.src,\n });\n if (next?.type === 'Object') {\n const next$ref = getObjMember(next, '$ref');\n if (next$ref && next$ref.type === 'String') {\n if (chain.includes(next$ref.value)) {\n logger.error({\n ...entry,\n message: `Circular $ref detected: ${JSON.stringify(next$ref.value)}`,\n node: next$ref,\n src: rootSource.src,\n });\n }\n chain.push(next$ref.value);\n return resolveRef(next$ref, chain);\n }\n }\n return next;\n }\n const inlineStart = performance.now();\n traverse(rootSource.document, {\n enter(node, _parent, rawPath) {\n if (rawPath.includes('$extensions') || node.type !== 'Object') {\n return;\n }\n const $ref = node.type === 'Object' ? getObjMember(node, '$ref') : undefined;\n if (!$ref) {\n return;\n }\n assertStringNode($ref, logger, {\n ...entry,\n message: 'Invalid $ref. Expected string.',\n node: $ref,\n src: rootSource.src,\n });\n const jsonID = encodeFragment(rawPath);\n refMap[jsonID] = { filename: rootSource.filename.href, refChain: [$ref.value] };\n const resolved = resolveRef($ref, refMap[jsonID]!.refChain);\n if (resolved.type === 'Object') {\n node.members.splice(\n node.members.findIndex((m) => m.name.type === 'String' && m.name.value === '$ref'),\n 1,\n );\n replaceNode(node, mergeObjects(resolved, node));\n } else {\n replaceNode(node, resolved);\n }\n },\n });\n logger.debug({ ...entry, message: 'Inline aliases', timing: performance.now() - inlineStart });\n\n // 2. Resolve $extends to discover any more additional tokens\n function flatten$extends(node: momoa.ObjectNode, chain: string[]) {\n const memberKeys = node.members.map((m) => m.name.type === 'String' && m.name.value).filter(Boolean) as string[];\n\n if (memberKeys.includes('$extends')) {\n const $extends = getObjMember(node, '$extends');\n assertStringNode($extends, logger, {\n ...entry,\n message: '$extends must be a string',\n node: $extends,\n src: rootSource.src,\n });\n\n if (memberKeys.includes('$value')) {\n logger.error({ ...entry, message: '$extends can’t exist within a token', node: $extends, src: rootSource.src });\n }\n const next = isAlias($extends.value) ? aliasToGroupRef($extends.value) : undefined;\n\n assert(next, logger, {\n ...entry,\n message: '$extends must be a valid alias',\n node: $extends,\n src: rootSource.src,\n });\n\n if (\n chain.includes(next.$ref) ||\n // Check that $extends is not importing from higher up (could go in either direction, which is why we check both ways)\n chain.some((value) => value.startsWith(next.$ref) || next.$ref.startsWith(value))\n ) {\n logger.error({ ...entry, message: 'Circular $extends detected', node: $extends, src: rootSource.src });\n }\n\n chain.push(next.$ref);\n const extended = findNode(rootSource.document, parseRef(next.$ref).subpath ?? []);\n assert(extended, logger, {\n ...entry,\n message: 'Could not resolve $extends',\n node: $extends,\n src: rootSource.src,\n });\n assertObjectNode(extended, logger, { ...entry, message: '$extends must resolve to a group of tokens', node });\n\n // To ensure this is resolvable, try and flatten this node first (will catch circular refs)\n flatten$extends(extended, chain);\n\n replaceNode(node, mergeObjects(extended, node));\n }\n\n // Deeply-traverse for any interior $extends (even if it wasn’t at the top level)\n for (const member of node.members) {\n if (\n member.value.type === 'Object' &&\n member.name.type === 'String' &&\n !['$value', '$extensions'].includes(member.name.value)\n ) {\n traverse(member.value, {\n enter(subnode, _parent) {\n if (subnode.type === 'Object') {\n flatten$extends(subnode, chain);\n }\n },\n });\n }\n }\n }\n\n const extendsStart = performance.now();\n const extendsChain: string[] = [];\n flatten$extends(rootSource.document.body as momoa.ObjectNode, extendsChain);\n logger.debug({ ...entry, message: 'Resolving $extends', timing: performance.now() - extendsStart });\n\n // 3. Parse discovered tokens\n const firstPass = performance.now();\n const tokens: TokenNormalizedSet = {};\n // micro-optimization: while we’re iterating over tokens, keeping a “hot”\n // array in memory saves recreating arrays from object keys over and over again.\n // it does produce a noticeable speedup > 1,000 tokens.\n const tokenIDs: string[] = [];\n const groups: Record<string, GroupNormalized> = {};\n\n // 3a. Token & group population\n traverse(rootSource.document, {\n enter(node, _parent, rawPath) {\n if (node.type !== 'Object') {\n return;\n }\n groupFromNode(node, { path: isResolver ? filterResolverPaths(rawPath) : rawPath, groups });\n const token = tokenFromNode(node, {\n groups,\n ignore: config.ignore,\n path: isResolver ? filterResolverPaths(rawPath) : rawPath,\n source: rootSource,\n });\n if (token) {\n tokenIDs.push(token.jsonID);\n tokens[token.jsonID] = token;\n }\n },\n });\n\n logger.debug({ ...entry, message: 'Parsing: 1st pass', timing: performance.now() - firstPass });\n const secondPass = performance.now();\n\n // 3b. Resolve originalValue and original sources\n for (const source of Object.values(sourceByFilename)) {\n traverse(source.document, {\n enter(node, _parent, path) {\n if (node.type !== 'Object') {\n return;\n }\n\n const tokenRawValues = tokenRawValuesFromNode(node, { filename: source.filename!.href, path });\n if (tokenRawValues && tokens[tokenRawValues?.jsonID]) {\n tokens[tokenRawValues.jsonID]!.originalValue = tokenRawValues.originalValue;\n tokens[tokenRawValues.jsonID]!.source = tokenRawValues.source;\n for (const mode of Object.keys(tokenRawValues.mode)) {\n tokens[tokenRawValues.jsonID]!.mode[mode]!.originalValue = tokenRawValues.mode[mode]!.originalValue;\n tokens[tokenRawValues.jsonID]!.mode[mode]!.source = tokenRawValues.mode[mode]!.source;\n }\n }\n },\n });\n }\n\n // 3c. DTCG alias resolution\n // Unlike $refs which can be resolved as we go, these can’t happen until the final, flattened set\n resolveAliases(tokens, { logger, sources: sourceByFilename, refMap });\n logger.debug({ ...entry, message: 'Parsing: 2nd pass', timing: performance.now() - secondPass });\n\n // 4. Alias graph\n // We’ve resolved aliases, but we need this pass for reverse linking i.e. “aliasedBy”\n const aliasStart = performance.now();\n graphAliases(refMap, { tokens, logger, sources: sourceByFilename });\n logger.debug({ ...entry, message: 'Alias graph built', timing: performance.now() - aliasStart });\n\n // 5. normalize\n // Allow for some minor variance in inputs, and be nice to folks.\n const normalizeStart = performance.now();\n for (const id of tokenIDs) {\n const token = tokens[id]!;\n normalize(token as any, { logger, src: sourceByFilename[token.source.filename!]?.src });\n }\n logger.debug({ ...entry, message: 'Normalized values', timing: performance.now() - normalizeStart });\n\n // 6. alphabetize & filter\n // This can’t happen until the last step, where we’re 100% sure we’ve resolved everything.\n if (config.alphabetize === false) {\n return tokens;\n }\n\n const sortStart = performance.now();\n const tokensSorted: TokenNormalizedSet = {};\n tokenIDs.sort((a, b) => a.localeCompare(b, 'en-us', { numeric: true }));\n for (const path of tokenIDs) {\n const id = refToTokenID(path)!;\n tokensSorted[id] = tokens[path]!;\n }\n // Sort group IDs once, too\n for (const group of Object.values(groups)) {\n group.tokens.sort((a, b) => a.localeCompare(b, 'en-us', { numeric: true }));\n }\n logger.debug({ ...entry, message: 'Sorted tokens', timing: performance.now() - sortStart });\n\n return tokensSorted;\n}\n","import * as momoa from '@humanwhocodes/momoa';\nimport { bundle, encodeFragment, parseRef, replaceNode } from '@terrazzo/json-schema-tools';\nimport type yamlToMomoa from 'yaml-to-momoa';\nimport type Logger from '../logger.js';\nimport type { Group, ReferenceObject, ResolverSourceNormalized } from '../types.js';\n\nexport interface NormalizeResolverOptions {\n logger: Logger;\n yamlToMomoa?: typeof yamlToMomoa;\n filename: URL;\n req: (url: URL, origin: URL) => Promise<string>;\n src?: any;\n}\n\n/** Normalize resolver (assuming it’s been validated) */\nexport async function normalizeResolver(\n document: momoa.DocumentNode,\n { logger, filename, req, src, yamlToMomoa }: NormalizeResolverOptions,\n): Promise<ResolverSourceNormalized> {\n // Important note: think about sets, modifiers, and resolutionOrder all\n // containing their own partial tokens documents. Now think about JSON $refs\n // inside those. Because we want to treat them all as one _eventual_ document,\n // we defer resolving $refs until the very last step. In most setups, this has\n // no effect on the final result, however, in the scenario where remote\n // documents are loaded and they conflict in unexpected ways, resolving too\n // early will produce incorrect results.\n //\n // To prevent this, we bundle ONCE at the very top level, with the `$defs` at\n // the top level now containing all partial documents (as opposed to bundling\n // every sub document individually). So all that said, we are deciding to\n // choose the “all-in-one“ method for closer support with DTCG aliases, but at\n // the expense of some edge cases of $refs behaving unexpectedly.\n const resolverBundle = await bundle([{ filename, src }], { req, yamlToMomoa });\n const resolverSource = momoa.evaluate(resolverBundle.document) as unknown as ResolverSourceNormalized;\n\n // Resolve $refs, but in a very different way than everywhere else These are\n // all _evaluated_, meaning initialized in JS memory. Unlike in the AST, when\n // we resolve these they’ll share memory points (which isn’t possible in the\n // AST—values must be duplicated). This code is unique because it’s the only\n // place where we’re dealing with shared, initialized JS memory.\n replaceNode(document, resolverBundle.document); // inject $defs into the root document\n for (const set of Object.values(resolverSource.sets ?? {})) {\n for (const source of set.sources) {\n resolvePartials(source, { resolver: resolverSource, logger });\n }\n }\n for (const modifier of Object.values(resolverSource.modifiers ?? {})) {\n for (const context of Object.values(modifier.contexts)) {\n for (const source of context) {\n resolvePartials(source, { resolver: resolverSource, logger });\n }\n }\n }\n for (const item of resolverSource.resolutionOrder ?? []) {\n resolvePartials(item, { resolver: resolverSource, logger });\n }\n\n return {\n name: resolverSource.name,\n version: resolverSource.version,\n description: resolverSource.description,\n sets: resolverSource.sets,\n modifiers: resolverSource.modifiers,\n resolutionOrder: resolverSource.resolutionOrder,\n _source: {\n filename,\n document,\n },\n };\n}\n\n/** Resolve $refs for already-initialized JS */\nfunction resolvePartials(\n source: Group | ReferenceObject,\n {\n resolver,\n logger,\n }: {\n resolver: any;\n logger: Logger;\n },\n) {\n if (!source) {\n return;\n }\n const entry = { group: 'parser' as const, label: 'resolver' };\n if (Array.isArray(source)) {\n for (const item of source) {\n resolvePartials(item, { resolver, logger });\n }\n } else if (typeof source === 'object') {\n for (const k of Object.keys(source)) {\n if (k === '$ref') {\n const $ref = (source as any)[k] as string;\n const { url, subpath = [] } = parseRef($ref);\n if (url !== '.' || !subpath.length) {\n logger.error({ ...entry, message: `Could not load $ref ${JSON.stringify($ref)}` });\n }\n const found = findObject(resolver, subpath ?? [], logger);\n if (subpath[0] === 'sets' || subpath[0] === 'modifiers') {\n found.type = subpath[0].replace(/s$/, '');\n found.name = subpath[1];\n }\n if (found) {\n for (const k2 of Object.keys(found)) {\n (source as any)[k2] = found[k2];\n }\n delete (source as any).$ref;\n } else {\n logger.error({ ...entry, message: `Could not find ${JSON.stringify($ref)}` });\n }\n } else {\n resolvePartials((source as any)[k], { resolver, logger });\n }\n }\n }\n}\n\nfunction findObject(dict: Record<string, any>, path: string[], logger: Logger): any {\n let node = dict;\n for (const idRaw of path) {\n const id = idRaw.replace(/~/g, '~0').replace(/\\//g, '~1');\n if (!(id in node)) {\n logger.error({\n group: 'parser',\n label: 'resolver',\n message: `Could not load $ref ${encodeFragment(path)}`,\n });\n }\n node = node[id];\n }\n return node;\n}\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember, getObjMembers } from '@terrazzo/json-schema-tools';\nimport type { LogEntry, default as Logger } from '../logger.js';\n\n/**\n * Determine whether this is likely a resolver\n * We use terms the word “likely” because this occurs before validation. Since\n * we may be dealing with a doc _intended_ to be a resolver, but may be lacking\n * some critical information, how can we determine intent? There’s a bit of\n * guesswork here, but we try and find a reasonable edge case where we sniff out\n * invalid DTCG syntax that a resolver doc would have.\n */\nexport function isLikelyResolver(doc: momoa.DocumentNode): boolean {\n if (doc.body.type !== 'Object') {\n return false;\n }\n // This is a resolver if…\n for (const member of doc.body.members) {\n if (member.name.type !== 'String') {\n continue;\n }\n switch (member.name.value) {\n case 'name':\n case 'description':\n case 'version': {\n // 1. name, description, or version are a string\n if (member.value.type === 'String') {\n return true;\n }\n break;\n }\n case 'sets':\n case 'modifiers': {\n if (member.value.type !== 'Object') {\n continue;\n }\n // 2. sets.description or modifiers.description is a string\n if (getObjMember(member.value, 'description')?.type === 'String') {\n return true;\n }\n // 3. sets.sources is an array\n if (member.name.value === 'sets' && getObjMember(member.value, 'sources')?.type === 'Array') {\n return true;\n } else if (member.name.value === 'modifiers') {\n const contexts = getObjMember(member.value, 'contexts');\n if (contexts?.type === 'Object' && contexts.members.some((m) => m.value.type === 'Array')) {\n // 4. contexts[key] is an array\n // (note: modifiers.contexts as an object is technically valid token format! We need to check for the array)\n return true;\n }\n }\n break;\n }\n case 'resolutionOrder': {\n // 4. resolutionOrder is an array\n if (member.value.type === 'Array') {\n return true;\n }\n break;\n }\n }\n }\n\n return false;\n}\n\nexport interface ValidateResolverOptions {\n logger: Logger;\n src: string;\n}\n\nconst MESSAGE_EXPECTED = {\n STRING: 'Expected string.',\n OBJECT: 'Expected object.',\n ARRAY: 'Expected array.',\n};\n\n/**\n * Validate a resolver document.\n * There’s a ton of boilerplate here, only to surface detailed code frames. Is there a better abstraction?\n */\nexport function validateResolver(node: momoa.DocumentNode, { logger, src }: ValidateResolverOptions) {\n const entry = { group: 'parser', label: 'resolver', src } as const;\n if (node.body.type !== 'Object') {\n logger.error({ ...entry, message: MESSAGE_EXPECTED.OBJECT, node });\n }\n const errors: LogEntry[] = [];\n\n let hasVersion = false;\n let hasResolutionOrder = false;\n\n for (const member of (node.body as momoa.ObjectNode).members) {\n if (member.name.type !== 'String') {\n continue; // IDK, don’t ask\n }\n\n switch (member.name.value) {\n case 'name':\n case 'description': {\n if (member.value.type !== 'String') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.STRING });\n }\n break;\n }\n\n case 'version': {\n hasVersion = true;\n if (member.value.type !== 'String' || member.value.value !== '2025.10') {\n errors.push({ ...entry, message: `Expected \"version\" to be \"2025.10\".`, node: member.value });\n }\n break;\n }\n\n case 'sets':\n case 'modifiers': {\n if (member.value.type !== 'Object') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.OBJECT, node: member.value });\n } else {\n for (const item of member.value.members) {\n if (item.value.type !== 'Object') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.OBJECT, node: item.value });\n } else {\n const validator = member.name.value === 'sets' ? validateSet : validateModifier;\n errors.push(...validator(item.value, false, { logger, src }));\n }\n }\n }\n break;\n }\n\n case 'resolutionOrder': {\n hasResolutionOrder = true;\n if (member.value.type !== 'Array') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.ARRAY, node: member.value });\n } else if (member.value.elements.length === 0) {\n errors.push({ ...entry, message: `\"resolutionOrder\" can’t be empty array.`, node: member.value });\n } else {\n for (const item of member.value.elements) {\n if (item.value.type !== 'Object') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.OBJECT, node: item.value });\n } else {\n const itemMembers = getObjMembers(item.value);\n if (itemMembers.$ref?.type === 'String') {\n continue; // we can’t validate this just yet, assume it’s correct\n }\n // Validate \"type\"\n if (itemMembers.type?.type === 'String') {\n if (itemMembers.type.value === 'set') {\n validateSet(item.value, true, { logger, src });\n } else if (itemMembers.type.value === 'modifier') {\n validateModifier(item.value, true, { logger, src });\n } else {\n errors.push({\n ...entry,\n message: `Unknown type ${JSON.stringify(itemMembers.type.value)}`,\n node: itemMembers.type,\n });\n }\n }\n // validate sets & modifiers if they’re missing \"type\"\n if (itemMembers.sources?.type === 'Array') {\n validateSet(item.value, true, { logger, src });\n } else if (itemMembers.contexts?.type === 'Object') {\n validateModifier(item.value, true, { logger, src });\n } else if (itemMembers.name?.type === 'String' || itemMembers.description?.type === 'String') {\n validateSet(item.value, true, { logger, src }); // if this has a \"name\" or \"description\", guess set\n }\n }\n }\n }\n break;\n }\n case '$defs':\n case '$extensions':\n if (member.value.type !== 'Object') {\n errors.push({ ...entry, message: `Expected object`, node: member.value });\n }\n break;\n case '$schema':\n case '$ref': {\n if (member.value.type !== 'String') {\n errors.push({ ...entry, message: `Expected string`, node: member.value });\n }\n break;\n }\n default: {\n errors.push({ ...entry, message: `Unknown key ${JSON.stringify(member.name.value)}`, node: member.name, src });\n break;\n }\n }\n }\n\n // handle required keys\n if (!hasVersion) {\n errors.push({ ...entry, message: `Missing \"version\".`, node, src });\n }\n if (!hasResolutionOrder) {\n errors.push({ ...entry, message: `Missing \"resolutionOrder\".`, node, src });\n }\n\n if (errors.length) {\n logger.error(...errors);\n }\n}\n\nexport function validateSet(node: momoa.ObjectNode, isInline = false, { src }: ValidateResolverOptions): LogEntry[] {\n const entry = { group: 'parser', label: 'resolver', src } as const;\n const errors: LogEntry[] = [];\n let hasName = !isInline;\n let hasType = !isInline;\n let hasSources = false;\n for (const member of node.members) {\n if (member.name.type !== 'String') {\n continue;\n }\n switch (member.name.value) {\n case 'name': {\n hasName = true;\n if (member.value.type !== 'String') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.STRING, node: member.value });\n }\n break;\n }\n case 'description': {\n if (member.value.type !== 'String') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.STRING, node: member.value });\n }\n break;\n }\n case 'type': {\n hasType = true;\n if (member.value.type !== 'String') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.STRING, node: member.value });\n } else if (member.value.value !== 'set') {\n errors.push({ ...entry, message: '\"type\" must be \"set\".' });\n }\n break;\n }\n case 'sources': {\n hasSources = true;\n if (member.value.type !== 'Array') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.ARRAY, node: member.value });\n } else if (member.value.elements.length === 0) {\n errors.push({ ...entry, message: `\"sources\" can’t be empty array.`, node: member.value });\n } else {\n for (const source of member.value.elements) {\n if (source.value.type !== 'Object') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.OBJECT, node: source.value });\n }\n }\n }\n break;\n }\n case '$defs':\n case '$extensions':\n if (member.value.type !== 'Object') {\n errors.push({ ...entry, message: `Expected object`, node: member.value });\n }\n break;\n case '$ref': {\n if (member.value.type !== 'String') {\n errors.push({ ...entry, message: `Expected string`, node: member.value });\n }\n break;\n }\n default: {\n errors.push({ ...entry, message: `Unknown key ${JSON.stringify(member.name.value)}`, node: member.name });\n break;\n }\n }\n }\n\n // handle required keys\n if (!hasName) {\n errors.push({ ...entry, message: `Missing \"name\".`, node });\n }\n if (!hasType) {\n errors.push({ ...entry, message: `\"type\": \"set\" missing.`, node });\n }\n if (!hasSources) {\n errors.push({ ...entry, message: `Missing \"sources\".`, node });\n }\n\n return errors;\n}\n\nexport function validateModifier(\n node: momoa.ObjectNode,\n isInline = false,\n { src }: ValidateResolverOptions,\n): LogEntry[] {\n const errors: LogEntry[] = [];\n const entry = { group: 'parser', label: 'resolver', src } as const;\n let hasName = !isInline;\n let hasType = !isInline;\n let hasContexts = false;\n for (const member of node.members) {\n if (member.name.type !== 'String') {\n continue;\n }\n switch (member.name.value) {\n case 'name': {\n hasName = true;\n if (member.value.type !== 'String') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.STRING, node: member.value });\n }\n break;\n }\n case 'description': {\n if (member.value.type !== 'String') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.STRING, node: member.value });\n }\n break;\n }\n case 'type': {\n hasType = true;\n if (member.value.type !== 'String') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.STRING, node: member.value });\n } else if (member.value.value !== 'modifier') {\n errors.push({ ...entry, message: '\"type\" must be \"modifier\".' });\n }\n break;\n }\n case 'contexts': {\n hasContexts = true;\n if (member.value.type !== 'Object') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.OBJECT, node: member.value });\n } else if (member.value.members.length === 0) {\n errors.push({ ...entry, message: `\"contexts\" can’t be empty object.`, node: member.value });\n } else {\n for (const context of member.value.members) {\n if (context.value.type !== 'Array') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.ARRAY, node: context.value });\n } else {\n for (const source of context.value.elements) {\n if (source.value.type !== 'Object') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.OBJECT, node: source.value });\n }\n }\n }\n }\n }\n break;\n }\n case 'default': {\n if (member.value.type !== 'String') {\n errors.push({ ...entry, message: `Expected string`, node: member.value });\n } else {\n const contexts = getObjMember(node, 'contexts') as momoa.ObjectNode | undefined;\n if (!contexts || !getObjMember(contexts, member.value.value)) {\n errors.push({ ...entry, message: 'Invalid default context', node: member.value });\n }\n }\n break;\n }\n case '$defs':\n case '$extensions':\n if (member.value.type !== 'Object') {\n errors.push({ ...entry, message: `Expected object`, node: member.value });\n }\n break;\n case '$ref': {\n if (member.value.type !== 'String') {\n errors.push({ ...entry, message: `Expected string`, node: member.value });\n }\n break;\n }\n default: {\n errors.push({ ...entry, message: `Unknown key ${JSON.stringify(member.name.value)}`, node: member.name });\n break;\n }\n }\n }\n\n // handle required keys\n if (!hasName) {\n errors.push({ ...entry, message: `Missing \"name\".`, node });\n }\n if (!hasType) {\n errors.push({ ...entry, message: `\"type\": \"modifier\" missing.`, node });\n }\n if (!hasContexts) {\n errors.push({ ...entry, message: `Missing \"contexts\".`, node });\n }\n\n return errors;\n}\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { type InputSource, type InputSourceWithDocument, maybeRawJSON } from '@terrazzo/json-schema-tools';\nimport type { TokenNormalizedSet } from '@terrazzo/token-tools';\nimport { merge } from 'merge-anything';\nimport type yamlToMomoa from 'yaml-to-momoa';\nimport { toMomoa } from '../lib/momoa.js';\nimport { getPermutationID } from '../lib/resolver-utils.js';\nimport type Logger from '../logger.js';\nimport { processTokens } from '../parse/process.js';\nimport type { ConfigInit, Resolver, ResolverSourceNormalized } from '../types.js';\nimport { normalizeResolver } from './normalize.js';\nimport { isLikelyResolver, validateResolver } from './validate.js';\n\nexport interface LoadResolverOptions {\n config: ConfigInit;\n logger: Logger;\n req: (url: URL, origin: URL) => Promise<string>;\n yamlToMomoa?: typeof yamlToMomoa;\n}\n\n/** Quick-parse input sources and find a resolver */\nexport async function loadResolver(\n inputs: InputSource[],\n { config, logger, req, yamlToMomoa }: LoadResolverOptions,\n): Promise<{ resolver: Resolver | undefined; tokens: TokenNormalizedSet; sources: InputSourceWithDocument[] }> {\n let resolverDoc: momoa.DocumentNode | undefined;\n let tokens: TokenNormalizedSet = {};\n const entry = {\n group: 'parser',\n label: 'init',\n } as const;\n\n for (const input of inputs) {\n let document: momoa.DocumentNode | undefined;\n if (typeof input.src === 'string') {\n if (maybeRawJSON(input.src)) {\n document = toMomoa(input.src);\n } else if (yamlToMomoa) {\n document = yamlToMomoa(input.src);\n } else {\n logger.error({\n ...entry,\n message: `Install yaml-to-momoa package to parse YAML, and pass in as option, e.g.:\n\n import { bundle } from '@terrazzo/json-schema-tools';\n import yamlToMomoa from 'yaml-to-momoa';\n\n bundle(yamlString, { yamlToMomoa });`,\n });\n }\n } else if (input.src && typeof input.src === 'object') {\n document = toMomoa(JSON.stringify(input.src, undefined, 2));\n } else {\n logger.error({ ...entry, message: `Could not parse ${input.filename}. Is this valid JSON or YAML?` });\n }\n if (!document || !isLikelyResolver(document)) {\n continue;\n }\n if (inputs.length > 1) {\n logger.error({ ...entry, message: `Resolver must be the only input, found ${inputs.length} sources.` });\n }\n resolverDoc = document;\n break;\n }\n\n let resolver: Resolver | undefined;\n if (resolverDoc) {\n validateResolver(resolverDoc, { logger, src: inputs[0]!.src });\n const normalized = await normalizeResolver(resolverDoc, {\n filename: inputs[0]!.filename!,\n logger,\n req,\n src: inputs[0]!.src,\n yamlToMomoa,\n });\n resolver = createResolver(normalized, { config, logger, sources: [{ ...inputs[0]!, document: resolverDoc }] });\n\n // If a resolver is present, load a single permutation to get a base token set.\n const firstInput: Record<string, string> = {};\n for (const m of resolver.source.resolutionOrder) {\n if (m.type !== 'modifier') {\n continue;\n }\n firstInput[m.name] = typeof m.default === 'string' ? m.default : Object.keys(m.contexts)[0]!;\n }\n tokens = resolver.apply(firstInput);\n }\n\n return {\n resolver,\n tokens,\n sources: [{ ...inputs[0]!, document: resolverDoc! }],\n };\n}\n\nexport interface CreateResolverOptions {\n config: ConfigInit;\n logger: Logger;\n sources: InputSourceWithDocument[];\n}\n\n/** Create an interface to resolve permutations */\nexport function createResolver(\n resolverSource: ResolverSourceNormalized,\n { config, logger, sources }: CreateResolverOptions,\n): Resolver {\n const inputDefaults: Record<string, string> = {};\n const validContexts: Record<string, string[]> = {};\n const allPermutations: Record<string, string>[] = [];\n\n const resolverCache: Record<string, any> = {};\n\n // Important: by iterating over resolutionOrder, we\n // filter out unused modifiers/irrelevant contexts.\n for (const m of resolverSource.resolutionOrder) {\n if (m.type === 'modifier') {\n if (typeof m.default === 'string') {\n inputDefaults[m.name] = m.default!;\n }\n validContexts[m.name] = Object.keys(m.contexts);\n }\n }\n\n return {\n apply(inputRaw) {\n let tokensRaw: TokenNormalizedSet = {};\n const input = { ...inputDefaults, ...inputRaw };\n const permutationID = getPermutationID(input);\n\n if (resolverCache[permutationID]) {\n return resolverCache[permutationID];\n }\n\n for (const item of resolverSource.resolutionOrder) {\n switch (item.type) {\n case 'set': {\n for (const s of item.sources) {\n tokensRaw = merge(tokensRaw, s) as TokenNormalizedSet;\n }\n break;\n }\n case 'modifier': {\n const context = input[item.name]!;\n const sources = item.contexts[context];\n if (!sources) {\n logger.error({\n group: 'resolver',\n message: `Modifier ${item.name} has no context ${JSON.stringify(context)}.`,\n });\n }\n for (const s of sources ?? []) {\n tokensRaw = merge(tokensRaw, s) as TokenNormalizedSet;\n }\n break;\n }\n }\n }\n\n const src = JSON.stringify(tokensRaw, undefined, 2);\n const rootSource = { filename: resolverSource._source.filename!, document: toMomoa(src), src };\n const tokens = processTokens(rootSource, {\n config,\n logger,\n sourceByFilename: { [resolverSource._source.filename!.href]: rootSource },\n isResolver: true,\n sources,\n });\n resolverCache[permutationID] = tokens;\n return tokens;\n },\n source: resolverSource,\n listPermutations() {\n // only do work on first call, then cache subsequent work. this could be thousands of possible values!\n if (!allPermutations.length) {\n allPermutations.push(...calculatePermutations(Object.entries(validContexts)));\n }\n return allPermutations;\n },\n isValidInput(input, throwError = false) {\n if (!input || typeof input !== 'object') {\n logger.error({ group: 'resolver', message: `Invalid input: ${JSON.stringify(input)}.` });\n }\n for (const k of Object.keys(input)) {\n if (!(k in validContexts)) {\n if (throwError) {\n logger.error({ group: 'resolver', message: `No such modifier ${JSON.stringify(k)}` });\n }\n return false; // 1. invalid if unknown modifier name\n }\n }\n for (const [name, contexts] of Object.entries(validContexts)) {\n // Note: empty strings are valid! Don’t check for truthiness.\n if (name in input) {\n if (!contexts.includes(input[name]!)) {\n if (throwError) {\n logger.error({\n group: 'resolver',\n message: `Modifier \"${name}\" has no context ${JSON.stringify(input[name])}.`,\n });\n }\n return false; // 2. invalid if unknown context\n }\n } else if (!(name in inputDefaults)) {\n if (throwError) {\n logger.error({\n group: 'resolver',\n message: `Modifier \"${name}\" missing value (no default set).`,\n });\n }\n return false; // 3. invalid if omitted, and no default\n }\n }\n return true;\n },\n getPermutationID(input) {\n this.isValidInput(input, true);\n return getPermutationID({ ...inputDefaults, ...input });\n },\n };\n}\n\n/** Calculate all permutations */\nexport function calculatePermutations(options: [string, string[]][]) {\n const permutationCount = [1];\n for (const [_name, contexts] of options) {\n permutationCount.push(contexts.length * (permutationCount.at(-1) || 1));\n }\n const permutations: Record<string, string>[] = [];\n for (let i = 0; i < permutationCount.at(-1)!; i++) {\n const input: Record<string, string> = {};\n for (let j = 0; j < options.length; j++) {\n const [name, contexts] = options[j]!;\n input[name] = contexts[Math.floor(i / permutationCount[j]!) % contexts.length]!;\n }\n permutations.push(input);\n }\n return permutations.length ? permutations : [{}];\n}\n","import * as momoa from '@humanwhocodes/momoa';\nimport type { InputSourceWithDocument } from '@terrazzo/json-schema-tools';\nimport type Logger from '../logger.js';\nimport type { ConfigInit, Group, Resolver, TokenNormalized, TokenNormalizedSet } from '../types.js';\nimport { createResolver } from './load.js';\nimport { normalizeResolver } from './normalize.js';\n\nexport interface CreateSyntheticResolverOptions {\n config: ConfigInit;\n logger: Logger;\n req: (url: URL, origin: URL) => Promise<string>;\n sources: InputSourceWithDocument[];\n}\n\n/**\n * Interop layer upgrading legacy Terrazzo modes to resolvers\n */\nexport async function createSyntheticResolver(\n tokens: TokenNormalizedSet,\n { config, logger, req, sources }: CreateSyntheticResolverOptions,\n): Promise<Resolver> {\n const contexts: Record<string, any[]> = {};\n for (const token of Object.values(tokens)) {\n for (const [mode, value] of Object.entries(token.mode)) {\n if (mode === '.') {\n continue;\n }\n if (!(mode in contexts)) {\n contexts[mode] = [{}];\n }\n addToken(contexts[mode]![0], { ...token, $value: value.$value }, { logger });\n }\n }\n\n const src = JSON.stringify(\n {\n name: 'Terrazzo',\n version: '2025.10',\n resolutionOrder: [{ $ref: '#/sets/allTokens' }, { $ref: '#/modifiers/tzMode' }],\n sets: {\n allTokens: { sources: [simpleFlatten(tokens, { logger })] },\n },\n modifiers: {\n tzMode: {\n description: 'Automatically built from $extensions.mode',\n contexts,\n },\n },\n },\n undefined,\n 2,\n );\n const normalized = await normalizeResolver(momoa.parse(src), {\n filename: new URL('file:///virtual:resolver.json'),\n logger,\n req,\n src,\n });\n return createResolver(normalized, { config, logger, sources });\n}\n\n/** Add a normalized token back into an arbitrary, hierarchial structure */\nfunction addToken(structure: any, token: TokenNormalized, { logger }: { logger: Logger }): void {\n let node = structure;\n const parts = token.id.split('.');\n const localID = parts.pop()!;\n for (const part of parts) {\n if (!(part in node)) {\n node[part] = {};\n }\n node = node[part];\n }\n if (localID in node) {\n logger.error({ group: 'parser', label: 'resolver', message: `${localID} already exists!` });\n }\n node[localID] = { $type: token.$type, $value: token.$value };\n}\n\n/** Downconvert normalized tokens back into a simplified, hierarchial shape. This is extremely lossy, and only done to build a resolver. */\nfunction simpleFlatten(tokens: TokenNormalizedSet, { logger }: { logger: Logger }): Group {\n const group: Group = {};\n for (const token of Object.values(tokens)) {\n addToken(group, token, { logger });\n }\n return group;\n}\n","import * as momoa from '@humanwhocodes/momoa';\nimport {\n type BundleOptions,\n bundle,\n encodeFragment,\n getObjMember,\n type InputSource,\n type InputSourceWithDocument,\n replaceNode,\n traverse,\n} from '@terrazzo/json-schema-tools';\nimport type { TokenNormalized, TokenNormalizedSet } from '@terrazzo/token-tools';\nimport { toMomoa } from '../lib/momoa.js';\nimport { filterResolverPaths } from '../lib/resolver-utils.js';\nimport type Logger from '../logger.js';\nimport { isLikelyResolver } from '../resolver/validate.js';\nimport type { ParseOptions, TransformVisitors } from '../types.js';\nimport { processTokens } from './process.js';\n\n/** Ephemeral format that only exists while parsing the document. This is not confirmed to be DTCG yet. */\nexport interface IntermediaryToken {\n id: string;\n /** Was this token aliasing another? */\n $ref?: string;\n $type?: string;\n $description?: string;\n $deprecated?: string | boolean;\n $value: unknown;\n $extensions?: Record<string, unknown>;\n group: TokenNormalized['group'];\n aliasOf?: string;\n partialAliasOf?: Record<string, any> | any[];\n mode: Record<\n string,\n {\n $type?: string;\n $value: unknown;\n aliasOf?: string;\n partialAliasOf?: Record<string, any> | any[];\n source?: { filename?: URL; node: momoa.ObjectNode };\n }\n >;\n source: {\n filename?: URL;\n node: momoa.ObjectNode;\n };\n}\n\nexport interface LoadOptions extends Pick<ParseOptions, 'config' | 'continueOnError' | 'yamlToMomoa' | 'transform'> {\n req: NonNullable<ParseOptions['req']>;\n logger: Logger;\n}\n\nexport interface LoadSourcesResult {\n tokens: TokenNormalizedSet;\n sources: InputSourceWithDocument[];\n}\n\n/** Load from multiple entries, while resolving remote files */\nexport async function loadSources(\n inputs: InputSource[],\n { config, logger, req, continueOnError, yamlToMomoa, transform }: LoadOptions,\n): Promise<LoadSourcesResult> {\n const entry = { group: 'parser' as const, label: 'init' };\n\n // 1. Bundle root documents together\n const firstLoad = performance.now();\n let document = {} as momoa.DocumentNode;\n\n /** The original user inputs, in original order, with parsed ASTs */\n const sources = inputs.map((input, i) => ({\n ...input,\n document: {} as momoa.DocumentNode,\n filename: input.filename || new URL(`virtual:${i}`), // for objects created in memory, an index-based ID helps associate tokens with these\n }));\n /** The sources array, indexed by filename */\n let sourceByFilename: Record<string, InputSourceWithDocument> = {};\n try {\n const result = await bundle(sources, {\n req,\n parse: transform ? transformer(transform) : undefined,\n yamlToMomoa,\n });\n document = result.document;\n sourceByFilename = result.sources;\n for (const [filename, source] of Object.entries(result.sources)) {\n const i = sources.findIndex((s) => s.filename.href === filename);\n if (i === -1) {\n sources.push(source);\n } else {\n sources[i]!.src = source.src; // this is a sanitized source that is easier to work with\n sources[i]!.document = source.document;\n }\n }\n } catch (err) {\n let src = sources.find((s) => s.filename.href === (err as any).filename)?.src;\n if (src && typeof src !== 'string') {\n src = JSON.stringify(src, undefined, 2);\n }\n logger.error({\n ...entry,\n continueOnError,\n message: (err as Error).message,\n node: (err as any).node,\n src,\n });\n }\n logger.debug({ ...entry, message: `JSON loaded`, timing: performance.now() - firstLoad });\n\n const rootSource = {\n filename: sources[0]!.filename!,\n document,\n src: momoa.print(document, { indent: 2 }).replace(/\\\\\\//g, '/'),\n };\n\n return {\n tokens: processTokens(rootSource, { config, logger, sources, sourceByFilename }),\n sources,\n };\n}\n\nfunction transformer(transform: TransformVisitors): BundleOptions['parse'] {\n return async (src, filename) => {\n let document = toMomoa(src);\n let lastPath = '#/';\n let last$type: string | undefined;\n\n if (transform.root) {\n const result = transform.root(document, { filename, parent: undefined, path: [] });\n if (result) {\n document = result as momoa.DocumentNode;\n }\n }\n\n const isResolver = isLikelyResolver(document);\n traverse(document, {\n enter(node, parent, rawPath) {\n const path = isResolver ? filterResolverPaths(rawPath) : rawPath;\n if (node.type !== 'Object' || !path.length) {\n return;\n }\n const ctx = { filename, parent, path };\n const next$type = getObjMember(node, '$type');\n if (next$type?.type === 'String') {\n const jsonPath = encodeFragment(path);\n if (jsonPath.startsWith(lastPath)) {\n last$type = next$type.value;\n }\n lastPath = jsonPath;\n }\n if (getObjMember(node, '$value')) {\n let result: any = transform.token?.(structuredClone(node), ctx);\n if (result) {\n replaceNode(node, result);\n result = undefined;\n }\n result = transform[last$type as keyof typeof transform]?.(structuredClone(node as any), ctx);\n if (result) {\n replaceNode(node, result);\n }\n } else if (!path.includes('$value')) {\n const result = transform.group?.(structuredClone(node), ctx);\n if (result) {\n replaceNode(node, result);\n }\n }\n },\n });\n\n return document;\n };\n}\n","import type fsType from 'node:fs/promises';\nimport type { InputSource, InputSourceWithDocument } from '@terrazzo/json-schema-tools';\nimport { pluralize, type TokenNormalizedSet } from '@terrazzo/token-tools';\nimport lintRunner from '../lint/index.js';\nimport Logger from '../logger.js';\nimport { createSyntheticResolver } from '../resolver/create-synthetic-resolver.js';\nimport { loadResolver } from '../resolver/load.js';\nimport type { ConfigInit, ParseOptions, Resolver } from '../types.js';\nimport { loadSources } from './load.js';\n\nexport interface ParseResult {\n tokens: TokenNormalizedSet;\n sources: InputSourceWithDocument[];\n resolver: Resolver;\n}\n\n/** Parse */\nexport default async function parse(\n _input: InputSource | InputSource[],\n {\n logger = new Logger(),\n req = defaultReq,\n skipLint = false,\n config = {} as ConfigInit,\n continueOnError = false,\n yamlToMomoa,\n transform,\n }: ParseOptions = {} as ParseOptions,\n): Promise<ParseResult> {\n const inputs = Array.isArray(_input) ? _input : [_input];\n let tokens: TokenNormalizedSet = {};\n let resolver: Resolver | undefined;\n let sources: InputSourceWithDocument[] = [];\n\n const totalStart = performance.now();\n\n // 1. Load tokens\n const initStart = performance.now();\n const resolverResult = await loadResolver(inputs, { config, logger, req, yamlToMomoa });\n // 1a. Resolver\n if (resolverResult.resolver) {\n tokens = resolverResult.tokens;\n sources = resolverResult.sources;\n resolver = resolverResult.resolver;\n } else {\n // 1b. No resolver\n const tokenResult = await loadSources(inputs, {\n req,\n logger,\n config,\n continueOnError,\n yamlToMomoa,\n transform,\n });\n tokens = tokenResult.tokens;\n sources = tokenResult.sources;\n }\n logger.debug({\n message: 'Loaded tokens',\n group: 'parser',\n label: 'core',\n timing: performance.now() - initStart,\n });\n\n if (skipLint !== true && config?.plugins?.length) {\n const lintStart = performance.now();\n await lintRunner({ tokens, sources, config, logger });\n logger.debug({\n message: 'Lint finished',\n group: 'plugin',\n label: 'lint',\n timing: performance.now() - lintStart,\n });\n }\n\n const resolverTiming = performance.now();\n const finalResolver = resolver || (await createSyntheticResolver(tokens, { config, logger, req, sources }));\n logger.debug({\n message: 'Resolver finalized',\n group: 'parser',\n label: 'core',\n timing: performance.now() - resolverTiming,\n });\n\n logger.debug({\n message: 'Finish all parser tasks',\n group: 'parser',\n label: 'core',\n timing: performance.now() - totalStart,\n });\n\n if (continueOnError) {\n const { errorCount } = logger.stats();\n if (errorCount > 0) {\n logger.error({\n group: 'parser',\n message: `Parser encountered ${errorCount} ${pluralize(errorCount, 'error', 'errors')}. Exiting.`,\n });\n }\n }\n\n return {\n tokens,\n sources,\n resolver: finalResolver,\n };\n}\n\nlet fs: typeof fsType | undefined;\n\n/** Fallback req */\nasync function defaultReq(src: URL, _origin: URL) {\n if (src.protocol === 'file:') {\n if (!fs) {\n fs = await import('node:fs/promises');\n }\n return await fs.readFile(src, 'utf8');\n }\n const res = await fetch(src);\n if (!res.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AGJ,eAAe,WAAW,KAAU,SAAc;AAChD,KAAI,IAAI,aAAa,SAAS;AAC5B,MAAI,CAAC,GACH,MAAK,MAAM,OAAO;AAEpB,SAAO,MAAM,GAAG,SAAS,KAAK,OAAO;;CAEvC,MAAM,MAAM,MAAM,MAAM,IAAI;AAC5B,KAAI,CAAC,IAAI,GACP,OAAM,IAAI,MAAM,GAAG,IAAI,kBAAkB,IAAI,OAAO,IAAI,MAAM,IAAI,MAAM,GAAG;AAE7E,QAAO,MAAM,IAAI,MAAM"}
1
+ {"version":3,"file":"index.js","names":["rule","rule","ERROR_COLOR","ERROR_BORDER","ERROR_GRADIENT","ERROR_SHADOW","rule","rule","rule","rule","rule","rule","rule","ERROR","rule","rule","ERROR","rule","ERROR","rule","ERROR_MISSING","ERROR_INVALID_PROP","rule","ERROR","rule","rule","ERROR","ERROR_INVALID_PROP","rule","ERROR","rule","ERROR_INVALID_PROP","rule","ERROR","ERROR_INVALID_PROP","rule","ERROR","rule","ERROR","rule","ERROR","ERROR_INVALID_PROP","rule","ERROR_INVALID_PROP","rule","rule","ERROR_FORMAT","ERROR_INVALID_PROP","ERROR_LEGACY","ERROR_UNIT","ERROR_VALUE","rule","validColor","validDimension","validFontFamily","validFontWeight","validDuration","validCubicBezier","validNumber","validLink","validBoolean","validString","validStrokeStyle","validBorder","validTransition","validShadow","validGradient","validTypography","colorspace","consistentNaming","descriptions","duplicateValues","maxGamut","requiredChildren","requiredModes","requiredType","requiredTypographyProperties","a11yMinContrast","a11yMinFontSize"],"sources":["../src/lib/code-frame.ts","../src/logger.ts","../src/build/index.ts","../src/lint/plugin-core/lib/docs.ts","../src/lint/plugin-core/rules/a11y-min-contrast.ts","../src/lint/plugin-core/rules/a11y-min-font-size.ts","../src/lint/plugin-core/rules/colorspace.ts","../src/lint/plugin-core/rules/consistent-naming.ts","../src/lint/plugin-core/rules/descriptions.ts","../src/lint/plugin-core/rules/duplicate-values.ts","../src/lint/plugin-core/rules/max-gamut.ts","../src/lint/plugin-core/rules/required-children.ts","../src/lint/plugin-core/rules/required-modes.ts","../src/lint/plugin-core/rules/required-type.ts","../src/lint/plugin-core/rules/required-typography-properties.ts","../src/lint/plugin-core/rules/valid-font-family.ts","../src/lint/plugin-core/rules/valid-font-weight.ts","../src/lint/plugin-core/rules/valid-gradient.ts","../src/lint/plugin-core/rules/valid-link.ts","../src/lint/plugin-core/rules/valid-number.ts","../src/lint/plugin-core/rules/valid-shadow.ts","../src/lint/plugin-core/rules/valid-string.ts","../src/lint/plugin-core/rules/valid-stroke-style.ts","../src/lint/plugin-core/rules/valid-transition.ts","../src/lint/plugin-core/rules/valid-typography.ts","../src/lint/plugin-core/rules/valid-boolean.ts","../src/lint/plugin-core/rules/valid-border.ts","../src/lint/plugin-core/rules/valid-color.ts","../src/lint/plugin-core/rules/valid-cubic-bezier.ts","../src/lint/plugin-core/rules/valid-dimension.ts","../src/lint/plugin-core/rules/valid-duration.ts","../src/lint/plugin-core/index.ts","../src/config.ts","../src/lint/index.ts","../src/lib/momoa.ts","../src/lib/resolver-utils.ts","../src/parse/assert.ts","../src/parse/normalize.ts","../src/parse/token.ts","../src/parse/process.ts","../src/resolver/normalize.ts","../src/resolver/validate.ts","../src/resolver/load.ts","../src/resolver/create-synthetic-resolver.ts","../src/parse/load.ts","../src/parse/index.ts"],"sourcesContent":["// This is copied from @babel/code-frame package but without the heavyweight color highlighting\n// (note: Babel loads both chalk AND picocolors, and doesn’t treeshake well)\n// Babel is MIT-licensed and unaffiliated with this project.\n\n// MIT License\n//\n// Copyright (c) 2014-present Sebastian McKenzie and other contributors\n//\n// Permission is hereby granted, free of charge, to any person obtaining\n// a copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to\n// permit persons to whom the Software is furnished to do so, subject to\n// the following conditions:\n//\n// The above copyright notice and this permission notice shall be\n// included in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nexport interface Location {\n line: number;\n column: number;\n}\n\nexport interface NodeLocation {\n end?: Location;\n start: Location;\n}\n\nexport interface Options {\n /** Syntax highlight the code as JavaScript for terminals. default: false */\n highlightCode?: boolean;\n /** The number of lines to show above the error. default: 2 */\n linesAbove?: number;\n /** The number of lines to show below the error. default: 3 */\n linesBelow?: number;\n /**\n * Forcibly syntax highlight the code as JavaScript (for non-terminals);\n * overrides highlightCode.\n * default: false\n */\n forceColor?: boolean;\n /**\n * Pass in a string to be displayed inline (if possible) next to the\n * highlighted location in the code. If it can't be positioned inline,\n * it will be placed above the code frame.\n * default: nothing\n */\n message?: string;\n}\n\n/**\n * Extract what lines should be marked and highlighted.\n */\nfunction getMarkerLines(loc: NodeLocation, source: string[], opts: Options = {} as Options) {\n const startLoc = {\n // @ts-expect-error this is fine\n column: 0,\n // @ts-expect-error this is fine\n line: -1,\n ...loc.start,\n } as Location;\n const endLoc: Location = {\n ...startLoc,\n ...loc.end,\n };\n const { linesAbove = 2, linesBelow = 3 } = opts || {};\n const startLine = startLoc.line;\n const startColumn = startLoc.column;\n const endLine = endLoc.line;\n const endColumn = endLoc.column;\n\n let start = Math.max(startLine - (linesAbove + 1), 0);\n let end = Math.min(source.length, endLine + linesBelow);\n\n if (startLine === -1) {\n start = 0;\n }\n\n if (endLine === -1) {\n end = source.length;\n }\n\n const lineDiff = endLine - startLine;\n const markerLines: Record<string, any> = {};\n\n if (lineDiff) {\n for (let i = 0; i <= lineDiff; i++) {\n const lineNumber = i + startLine;\n\n if (!startColumn) {\n markerLines[lineNumber] = true;\n } else if (i === 0) {\n const sourceLength = source[lineNumber - 1]!.length;\n\n markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];\n } else if (i === lineDiff) {\n markerLines[lineNumber] = [0, endColumn];\n } else {\n const sourceLength = source[lineNumber - i]!.length;\n\n markerLines[lineNumber] = [0, sourceLength];\n }\n }\n } else {\n if (startColumn === endColumn) {\n if (startColumn) {\n markerLines[startLine] = [startColumn, 0];\n } else {\n markerLines[startLine] = true;\n }\n } else {\n markerLines[startLine] = [startColumn, endColumn - startColumn];\n }\n }\n\n return { start, end, markerLines };\n}\n\n/**\n * RegExp to test for newlines in terminal.\n */\n\nconst NEWLINE = /\\r\\n|[\\n\\r\\u2028\\u2029]/;\n\nexport function codeFrameColumns(rawLines: string, loc: NodeLocation, opts: Options = {} as Options) {\n if (typeof rawLines !== 'string') {\n throw new Error(`Expected string, got ${rawLines}`);\n }\n const lines = rawLines.split(NEWLINE);\n const { start, end, markerLines } = getMarkerLines(loc, lines, opts);\n const hasColumns = loc.start && typeof loc.start.column === 'number';\n\n const numberMaxWidth = String(end).length;\n\n let frame = rawLines\n .split(NEWLINE, end)\n .slice(start, end)\n .map((line, index) => {\n const number = start + 1 + index;\n const paddedNumber = ` ${number}`.slice(-numberMaxWidth);\n const gutter = ` ${paddedNumber} |`;\n const hasMarker = markerLines[number];\n const lastMarkerLine = !markerLines[number + 1];\n if (hasMarker) {\n let markerLine = '';\n if (Array.isArray(hasMarker)) {\n const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\\t]/g, ' ');\n const numberOfMarkers = hasMarker[1] || 1;\n\n markerLine = ['\\n ', gutter.replace(/\\d/g, ' '), ' ', markerSpacing, '^'.repeat(numberOfMarkers)].join('');\n\n if (lastMarkerLine && opts.message) {\n markerLine += ` ${opts.message}`;\n }\n }\n return ['>', gutter, line.length > 0 ? ` ${line}` : '', markerLine].join('');\n } else {\n return ` ${gutter}${line.length > 0 ? ` ${line}` : ''}`;\n }\n })\n .join('\\n');\n\n if (opts.message && !hasColumns) {\n frame = `${' '.repeat(numberMaxWidth + 1)}${opts.message}\\n${frame}`;\n }\n\n return frame;\n}\n","import * as momoa from '@humanwhocodes/momoa';\nimport pc from 'picocolors';\nimport wcmatch from 'wildcard-match';\nimport { codeFrameColumns } from './lib/code-frame.js';\n\nexport const LOG_ORDER = ['error', 'warn', 'info', 'debug'] as const;\nexport type LogSeverity = 'error' | 'warn' | 'info' | 'debug';\nexport type LogLevel = LogSeverity | 'silent';\nexport type LogGroup = 'config' | 'import' | 'lint' | 'parser' | 'plugin' | 'resolver' | 'server';\n\nexport interface LogEntry {\n /** Originator of log message */\n group: LogGroup;\n /** Error message to be logged */\n message: string;\n /** Prefix message with label */\n label?: string;\n /** File in disk */\n filename?: URL;\n /**\n * Continue on error?\n * @default false\n */\n continueOnError?: boolean;\n /** Show a code frame for the erring node */\n node?: momoa.AnyNode;\n /** To show a code frame, provide the original source code */\n src?: string;\n /** Display performance timing */\n timing?: number;\n}\n\nexport interface DebugEntry {\n group: LogGroup;\n /** Error message to be logged */\n message: string;\n /** Current subtask or submodule */\n label?: string;\n /** Show code below message */\n codeFrame?: { src: string; line: number; column: number };\n /** Display performance timing */\n timing?: number;\n}\n\nconst GROUP_COLOR = {\n config: pc.cyan,\n import: pc.green,\n lint: pc.yellowBright,\n parser: pc.magenta,\n plugin: pc.greenBright,\n resolver: pc.magentaBright,\n server: pc.gray,\n};\n\nconst MESSAGE_COLOR = {\n error: pc.red,\n warn: pc.yellow,\n info: (msg: string) => msg,\n debug: pc.gray,\n};\n\nconst timeFormatter = new Intl.DateTimeFormat('en-us', {\n hour: 'numeric',\n hour12: false,\n minute: 'numeric',\n second: 'numeric',\n fractionalSecondDigits: 3,\n});\n\n/**\n * @param {Entry} entry\n * @param {Severity} severity\n * @return {string}\n */\nexport function formatMessage(entry: LogEntry, severity: LogSeverity) {\n const groupColor = GROUP_COLOR[entry.group];\n const messageColor = MESSAGE_COLOR[severity];\n let message = entry.message;\n message = `${groupColor(`${entry.group}${entry.label ? `:${entry.label}` : ''}:`)} ${messageColor(message)}`;\n if (typeof entry.timing === 'number') {\n message = `${message} ${formatTiming(entry.timing)}`;\n }\n if (entry.node) {\n const start = entry.node?.loc?.start ?? { line: 0, column: 0 };\n // strip \"file://\" protocol, but not href\n const loc = entry.filename\n ? `${entry.filename?.href.replace(/^file:\\/\\//, '')}:${start?.line ?? 0}:${start?.column ?? 0}\\n\\n`\n : '';\n const codeFrame = codeFrameColumns(\n entry.src ?? momoa.print(entry.node, { indent: 2 }),\n { start },\n { highlightCode: false },\n );\n message = `${message}\\n\\n${loc}${codeFrame}`;\n }\n return message;\n}\n\nexport default class Logger {\n level = 'info' as LogLevel;\n debugScope = '*';\n errorCount = 0;\n warnCount = 0;\n infoCount = 0;\n debugCount = 0;\n\n constructor(options?: { level?: LogLevel; debugScope?: string }) {\n if (options?.level) {\n this.level = options.level;\n }\n if (options?.debugScope) {\n this.debugScope = options.debugScope;\n }\n }\n\n setLevel(level: LogLevel) {\n this.level = level;\n }\n\n /** Log an error message (always; can’t be silenced) */\n error(...entries: LogEntry[]) {\n const message: string[] = [];\n let firstNode: momoa.AnyNode | undefined;\n for (const entry of entries) {\n this.errorCount++;\n message.push(formatMessage(entry, 'error'));\n if (entry.node) {\n firstNode = entry.node;\n }\n }\n if (entries.every((e) => e.continueOnError)) {\n // biome-ignore lint/suspicious/noConsole: this is a logger\n console.error(message.join('\\n\\n'));\n } else {\n const e = firstNode ? new TokensJSONError(message.join('\\n\\n')) : new Error(message.join('\\n\\n'));\n throw e;\n }\n }\n\n /** Log an info message (if logging level permits) */\n info(...entries: LogEntry[]) {\n for (const entry of entries) {\n this.infoCount++;\n if (this.level === 'silent' || LOG_ORDER.indexOf(this.level) < LOG_ORDER.indexOf('info')) {\n return;\n }\n const message = formatMessage(entry, 'info');\n // biome-ignore lint/suspicious/noConsole: this is a logger\n console.log(message);\n }\n }\n\n /** Log a warning message (if logging level permits) */\n warn(...entries: LogEntry[]) {\n for (const entry of entries) {\n this.warnCount++;\n if (this.level === 'silent' || LOG_ORDER.indexOf(this.level) < LOG_ORDER.indexOf('warn')) {\n return;\n }\n const message = formatMessage(entry, 'warn');\n\n // biome-ignore lint/suspicious/noConsole: this is a logger\n console.warn(message);\n }\n }\n\n /** Log a diagnostics message (if logging level permits) */\n debug(...entries: DebugEntry[]) {\n for (const entry of entries) {\n if (this.level === 'silent' || LOG_ORDER.indexOf(this.level) < LOG_ORDER.indexOf('debug')) {\n return;\n }\n this.debugCount++;\n\n let message = formatMessage(entry, 'debug');\n\n const debugPrefix = entry.label ? `${entry.group}:${entry.label}` : entry.group;\n if (this.debugScope !== '*' && !wcmatch(this.debugScope)(debugPrefix)) {\n return;\n }\n\n // debug color\n message\n .replace(/\\[config[^\\]]+\\]/, (match) => pc.green(match))\n .replace(/\\[parser[^\\]]+\\]/, (match) => pc.magenta(match))\n .replace(/\\[lint[^\\]]+\\]/, (match) => pc.yellow(match))\n .replace(/\\[plugin[^\\]]+\\]/, (match) => pc.cyan(match));\n\n message = `${pc.dim(timeFormatter.format(performance.now()))} ${message}`;\n if (typeof entry.timing === 'number') {\n message = `${message} ${formatTiming(entry.timing)}`;\n }\n\n // biome-ignore lint/suspicious/noConsole: this is a logger\n console.log(message);\n }\n }\n\n /** Get stats for current logger instance */\n stats() {\n return {\n errorCount: this.errorCount,\n warnCount: this.warnCount,\n infoCount: this.infoCount,\n debugCount: this.debugCount,\n };\n }\n}\n\nfunction formatTiming(timing: number): string {\n let output = '';\n if (timing < 1_000) {\n output = `${Math.round(timing * 100) / 100}ms`;\n } else if (timing < 60_000) {\n output = `${Math.round(timing) / 1_000}s`;\n } else {\n output = `${Math.round(timing / 1_000) / 60}m`;\n }\n return pc.dim(`[${output}]`);\n}\n\nexport class TokensJSONError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'TokensJSONError';\n }\n}\n","import type { InputSourceWithDocument } from '@terrazzo/json-schema-tools';\nimport type { TokenNormalized } from '@terrazzo/token-tools';\nimport { getTokenMatcher } from '@terrazzo/token-tools';\nimport wcmatch from 'wildcard-match';\nimport Logger, { type LogEntry } from '../logger.js';\nimport type { BuildRunnerResult, ConfigInit, Resolver, TokenTransformed, TransformParams } from '../types.js';\n\nexport interface BuildRunnerOptions {\n sources: InputSourceWithDocument[];\n config: ConfigInit;\n resolver: Resolver;\n logger?: Logger;\n}\nexport const SINGLE_VALUE = 'SINGLE_VALUE';\nexport const MULTI_VALUE = 'MULTI_VALUE';\n\n/** Validate plugin setTransform() calls for immediate feedback */\nfunction validateTransformParams({\n params,\n logger,\n pluginName,\n}: {\n params: TokenTransformed;\n logger: Logger;\n pluginName: string;\n}): void {\n const baseMessage: LogEntry = { group: 'plugin', label: pluginName, message: '' };\n\n // validate value is valid for SINGLE_VALUE or MULTI_VALUE\n if (\n !params.value ||\n (typeof params.value !== 'string' && typeof params.value !== 'object') ||\n Array.isArray(params.value)\n ) {\n logger.error({\n ...baseMessage,\n message: `setTransform() value expected string or object of strings, received ${\n Array.isArray(params.value) ? 'Array' : typeof params.value\n }`,\n });\n }\n if (typeof params.value === 'object' && Object.values(params.value).some((v) => typeof v !== 'string')) {\n logger.error({\n ...baseMessage,\n message: 'setTransform() value expected object of strings, received some non-string values',\n });\n }\n}\n\nconst FALLBACK_PERMUTATION_ID = JSON.stringify({ tzMode: '*' });\n\n/** Run build stage */\nexport default async function build(\n tokens: Record<string, TokenNormalized>,\n { resolver, sources, logger = new Logger(), config }: BuildRunnerOptions,\n): Promise<BuildRunnerResult> {\n const formats: Record<string, { [permutationID: string]: TokenTransformed[] }> = {};\n const result: BuildRunnerResult = { outputFiles: [] };\n\n function getTransforms(plugin: string) {\n return function getTransforms(params: TransformParams) {\n if (!params?.format) {\n logger.warn({\n group: 'plugin',\n label: plugin,\n message: '\"format\" missing from getTransforms(), no tokens returned.',\n });\n return [];\n }\n\n const tokenMatcher = params.id && params.id !== '*' ? getTokenMatcher(params.id) : null;\n const modeMatcher = params.mode ? wcmatch(params.mode) : null;\n const permutationID = params.input ? resolver.getPermutationID(params.input) : JSON.stringify({ tzMode: '*' });\n\n return (formats[params.format!]?.[permutationID] ?? []).filter((token) => {\n if (params.$type) {\n if (typeof params.$type === 'string' && token.token.$type !== params.$type) {\n return false;\n } else if (Array.isArray(params.$type) && !params.$type.some(($type) => token.token.$type === $type)) {\n return false;\n }\n }\n if (tokenMatcher && !tokenMatcher(token.token.id)) {\n return false;\n }\n if (params.input && token.permutationID !== resolver.getPermutationID(params.input)) {\n return false;\n }\n if (modeMatcher && !modeMatcher(token.mode)) {\n return false;\n }\n return true;\n });\n };\n }\n\n // transform()\n let transformsLocked = false; // prevent plugins from transforming after stage has ended\n const startTransform = performance.now();\n for (const plugin of config.plugins) {\n if (typeof plugin.transform === 'function') {\n await plugin.transform({\n context: { logger },\n tokens,\n sources,\n getTransforms: getTransforms(plugin.name),\n setTransform(id, params) {\n if (transformsLocked) {\n logger.warn({\n message: 'Attempted to call setTransform() after transform step has completed.',\n group: 'plugin',\n label: plugin.name,\n });\n return;\n }\n const token = tokens[id]!;\n const permutationID = params.input ? resolver.getPermutationID(params.input) : FALLBACK_PERMUTATION_ID;\n const cleanValue: TokenTransformed['value'] =\n typeof params.value === 'string' ? params.value : { ...(params.value as Record<string, string>) };\n validateTransformParams({\n logger,\n params: { ...(params as any), value: cleanValue },\n pluginName: plugin.name,\n });\n\n // upsert\n if (!formats[params.format]) {\n formats[params.format] = {};\n }\n if (!formats[params.format]![permutationID]) {\n formats[params.format]![permutationID] = [];\n }\n let foundTokenI = -1;\n if (params.mode) {\n foundTokenI = formats[params.format]![permutationID]!.findIndex(\n (t) => id === t.id && (!params.localID || params.localID === t.localID) && params.mode === t.mode,\n );\n } else if (params.input) {\n if (!formats[params.format]![permutationID]) {\n formats[params.format]![permutationID] = [];\n }\n foundTokenI = formats[params.format]![permutationID]!.findIndex(\n (t) =>\n id === t.id && (!params.localID || params.localID === t.localID) && permutationID === t.permutationID,\n );\n } else {\n foundTokenI = formats[params.format]![permutationID]!.findIndex(\n (t) => id === t.id && (!params.localID || params.localID === t.localID),\n );\n }\n if (foundTokenI === -1) {\n // backwards compat: upconvert mode into \"tzMode\" modifier. This\n // allows newer plugins to use resolver syntax without disrupting\n // older plugins.\n formats[params.format]![permutationID]!.push({\n ...params,\n id,\n value: cleanValue,\n type: typeof cleanValue === 'string' ? SINGLE_VALUE : MULTI_VALUE,\n mode: params.mode || '.',\n token: structuredClone(token),\n permutationID,\n input: JSON.parse(permutationID),\n } as TokenTransformed);\n } else {\n formats[params.format]![permutationID]![foundTokenI]!.value = cleanValue;\n formats[params.format]![permutationID]![foundTokenI]!.type =\n typeof cleanValue === 'string' ? SINGLE_VALUE : MULTI_VALUE;\n }\n },\n resolver,\n });\n }\n }\n transformsLocked = true;\n logger.debug({\n group: 'parser',\n label: 'transform',\n message: 'transform() step',\n timing: performance.now() - startTransform,\n });\n\n // build()\n const startBuild = performance.now();\n await Promise.all(\n config.plugins.map(async (plugin) => {\n if (typeof plugin.build === 'function') {\n const pluginBuildStart = performance.now();\n await plugin.build({\n context: { logger },\n tokens,\n sources,\n getTransforms: getTransforms(plugin.name),\n resolver,\n outputFile(filename, contents) {\n const resolved = new URL(filename, config.outDir);\n if (result.outputFiles.some((f) => new URL(f.filename, config.outDir).href === resolved.href)) {\n logger.error({\n group: 'plugin',\n message: `Can’t overwrite file \"${filename}\"`,\n label: plugin.name,\n });\n }\n result.outputFiles.push({\n filename,\n contents,\n plugin: plugin.name,\n time: performance.now() - pluginBuildStart,\n });\n },\n });\n }\n }),\n );\n logger.debug({\n group: 'parser',\n label: 'build',\n message: 'build() step',\n timing: performance.now() - startBuild,\n });\n\n // buildEnd()\n const startBuildEnd = performance.now();\n await Promise.all(\n config.plugins.map(async (plugin) =>\n plugin.buildEnd?.({\n context: { logger },\n tokens,\n getTransforms: getTransforms(plugin.name),\n sources,\n outputFiles: structuredClone(result.outputFiles),\n }),\n ),\n );\n logger.debug({\n group: 'parser',\n label: 'build',\n message: 'buildEnd() step',\n timing: performance.now() - startBuildEnd,\n });\n\n return result;\n}\n","export function docsLink(ruleName: string): string {\n return `https://terrazzo.app/docs/linting#${ruleName.replaceAll('/', '')}`;\n}\n","import { tokenToColor } from '@terrazzo/token-tools';\nimport { contrastWCAG21 } from 'colorjs.io/fn';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const A11Y_MIN_CONTRAST = 'a11y/min-contrast';\n\nexport interface RuleA11yMinContrastOptions {\n /**\n * Whether to adhere to AA (minimum) or AAA (enhanced) contrast levels.\n * @default \"AA\"\n */\n level?: 'AA' | 'AAA';\n /** Pairs of color tokens (and optionally typography) to test */\n pairs: ContrastPair[];\n}\n\nexport interface ContrastPair {\n /** The foreground color token ID */\n foreground: string;\n /** The background color token ID */\n background: string;\n /**\n * Is this pair for large text? Large text allows a smaller contrast ratio.\n *\n * Note: while WCAG has _suggested_ sizes and weights, those are merely\n * suggestions. It’s always more reliable to determine what constitutes “large\n * text” for your designs yourself, based on your typographic stack.\n * @see https://www.w3.org/WAI/WCAG22/quickref/#contrast-minimum\n */\n largeText?: boolean;\n}\n\nexport const WCAG2_MIN_CONTRAST = {\n AA: { default: 4.5, large: 3 },\n AAA: { default: 7, large: 4.5 },\n};\n\nexport const ERROR_INSUFFICIENT_CONTRAST = 'INSUFFICIENT_CONTRAST';\n\nconst rule: LintRule<typeof ERROR_INSUFFICIENT_CONTRAST, RuleA11yMinContrastOptions> = {\n meta: {\n messages: {\n [ERROR_INSUFFICIENT_CONTRAST]: 'Pair {{ index }} failed; expected {{ expected }}, got {{ actual }} ({{ level }})',\n },\n docs: {\n description: 'Enforce colors meet minimum contrast checks for WCAG 2.',\n url: docsLink(A11Y_MIN_CONTRAST),\n },\n },\n defaultOptions: { level: 'AA', pairs: [] },\n create({ tokens, options, report }) {\n for (let i = 0; i < options.pairs.length; i++) {\n const { foreground, background, largeText } = options.pairs[i]!;\n if (!tokens[foreground]) {\n throw new Error(`Token ${foreground} does not exist`);\n }\n if (tokens[foreground].$type !== 'color') {\n throw new Error(`Token ${foreground} isn’t a color`);\n }\n if (!tokens[background]) {\n throw new Error(`Token ${background} does not exist`);\n }\n if (tokens[background].$type !== 'color') {\n throw new Error(`Token ${background} isn’t a color`);\n }\n\n // Note: if these culors were unparseable, they would have already thrown an error before the linter\n const a = tokenToColor(tokens[foreground].$value)!;\n const b = tokenToColor(tokens[background].$value)!;\n\n // Note: for the purposes of WCAG 2, foreground and background don’t\n // matter. But in other contrast algorithms, they do.\n const contrast = contrastWCAG21(a, b);\n const min = WCAG2_MIN_CONTRAST[options.level ?? 'AA'][largeText ? 'large' : 'default'];\n if (contrast < min) {\n report({\n messageId: ERROR_INSUFFICIENT_CONTRAST,\n data: {\n index: i + 1,\n expected: min,\n actual: Math.round(contrast * 100) / 100,\n level: options.level,\n },\n });\n }\n }\n },\n};\n\nexport default rule;\n","import { getTokenMatcher } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const A11Y_MIN_FONT_SIZE = 'a11y/min-font-size';\n\nexport interface RuleA11yMinFontSizeOptions {\n /** Minimum font size (pixels) */\n minSizePx?: number;\n /** Minimum font size (rems) */\n minSizeRem?: number;\n /** Token IDs to ignore. Accepts globs. */\n ignore?: string[];\n}\n\nexport const ERROR_TOO_SMALL = 'TOO_SMALL';\n\nconst rule: LintRule<typeof ERROR_TOO_SMALL, RuleA11yMinFontSizeOptions> = {\n meta: {\n messages: {\n [ERROR_TOO_SMALL]: '{{ id }} font size too small. Expected minimum of {{ min }}',\n },\n docs: {\n description: 'Enforce font sizes are no smaller than the given value.',\n url: docsLink(A11Y_MIN_FONT_SIZE),\n },\n },\n defaultOptions: {},\n create({ tokens, options, report }) {\n if (!options.minSizePx && !options.minSizeRem) {\n throw new Error('Must specify at least one of minSizePx or minSizeRem');\n }\n\n const shouldIgnore = options.ignore ? getTokenMatcher(options.ignore) : null;\n\n for (const t of Object.values(tokens)) {\n if (shouldIgnore?.(t.id)) {\n continue;\n }\n\n // skip aliases\n if (t.aliasOf) {\n continue;\n }\n\n if (t.$type === 'typography' && 'fontSize' in t.$value) {\n const fontSize = t.$value.fontSize!;\n\n if (\n (fontSize.unit === 'px' && options.minSizePx && fontSize.value < options.minSizePx) ||\n (fontSize.unit === 'rem' && options.minSizeRem && fontSize.value < options.minSizeRem)\n ) {\n report({\n messageId: ERROR_TOO_SMALL,\n data: {\n id: t.id,\n min: options.minSizePx ? `${options.minSizePx}px` : `${options.minSizeRem}rem`,\n },\n });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import { type ColorValueNormalized, getTokenMatcher } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const COLORSPACE = 'core/colorspace';\n\nexport interface RuleColorspaceOptions {\n colorSpace: ColorValueNormalized['colorSpace'];\n /** (optional) Token IDs to ignore. Supports globs (`*`). */\n ignore?: string[];\n}\n\nconst ERROR_COLOR = 'COLOR';\nconst ERROR_BORDER = 'BORDER';\nconst ERROR_GRADIENT = 'GRADIENT';\nconst ERROR_SHADOW = 'SHADOW';\n\nconst rule: LintRule<\n typeof ERROR_COLOR | typeof ERROR_BORDER | typeof ERROR_GRADIENT | typeof ERROR_SHADOW,\n RuleColorspaceOptions\n> = {\n meta: {\n messages: {\n [ERROR_COLOR]: 'Color {{ id }} not in colorspace {{ colorSpace }}',\n [ERROR_BORDER]: 'Border {{ id }} not in colorspace {{ colorSpace }}',\n [ERROR_GRADIENT]: 'Gradient {{ id }} not in colorspace {{ colorSpace }}',\n [ERROR_SHADOW]: 'Shadow {{ id }} not in colorspace {{ colorSpace }}',\n },\n docs: {\n description: 'Enforce that all colors are in a specific colorspace.',\n url: docsLink(COLORSPACE),\n },\n },\n defaultOptions: { colorSpace: 'srgb' },\n create({ tokens, options, report }) {\n if (!options.colorSpace) {\n return;\n }\n\n const shouldIgnore = options.ignore ? getTokenMatcher(options.ignore) : null;\n\n for (const t of Object.values(tokens)) {\n // skip ignored tokens\n if (shouldIgnore?.(t.id)) {\n continue;\n }\n\n // skip aliases\n if (t.aliasOf) {\n continue;\n }\n\n switch (t.$type) {\n case 'color': {\n if (t.$value.colorSpace !== options.colorSpace) {\n report({\n messageId: ERROR_COLOR,\n data: { id: t.id, colorSpace: options.colorSpace },\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n break;\n }\n case 'border': {\n if (!t.partialAliasOf?.color && t.$value.color.colorSpace !== options.colorSpace) {\n report({\n messageId: ERROR_BORDER,\n data: { id: t.id, colorSpace: options.colorSpace },\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n break;\n }\n case 'gradient': {\n for (let stopI = 0; stopI < t.$value.length; stopI++) {\n if (!t.partialAliasOf?.[stopI]?.color && t.$value[stopI]!.color.colorSpace !== options.colorSpace) {\n report({\n messageId: ERROR_GRADIENT,\n data: { id: t.id, colorSpace: options.colorSpace },\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n }\n break;\n }\n case 'shadow': {\n for (let shadowI = 0; shadowI < t.$value.length; shadowI++) {\n if (!t.partialAliasOf?.[shadowI]?.color && t.$value[shadowI]!.color.colorSpace !== options.colorSpace) {\n report({\n messageId: ERROR_SHADOW,\n data: { id: t.id, colorSpace: options.colorSpace },\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n }\n break;\n }\n }\n }\n },\n};\n\nexport default rule;\n","import { camelCase, kebabCase, pascalCase, snakeCase } from 'scule';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const CONSISTENT_NAMING = 'core/consistent-naming';\nexport const ERROR_WRONG_FORMAT = 'ERROR_WRONG_FORMAT';\n\nexport interface RuleConsistentNamingOptions {\n /** Specify format, or custom naming validator */\n format:\n | 'kebab-case'\n | 'camelCase'\n | 'PascalCase'\n | 'snake_case'\n | 'SCREAMING_SNAKE_CASE'\n | ((tokenID: string) => boolean);\n /** Token IDs to ignore. Supports globs (`*`). */\n ignore?: string[];\n}\n\nconst rule: LintRule<typeof ERROR_WRONG_FORMAT, RuleConsistentNamingOptions> = {\n meta: {\n messages: {\n [ERROR_WRONG_FORMAT]: '{{ id }} doesn’t match format {{ format }}',\n },\n docs: {\n description: 'Enforce consistent naming for tokens.',\n url: docsLink(CONSISTENT_NAMING),\n },\n },\n defaultOptions: { format: 'kebab-case' },\n create({ tokens, options, report }) {\n const basicFormatter = {\n 'kebab-case': kebabCase,\n camelCase,\n PascalCase: pascalCase,\n snake_case: snakeCase,\n SCREAMING_SNAKE_CASE: (name: string) => snakeCase(name).toLocaleUpperCase(),\n }[String(options.format)];\n\n for (const t of Object.values(tokens)) {\n if (basicFormatter) {\n const parts = t.id.split('.');\n if (!parts.every((part) => basicFormatter(part) === part)) {\n report({\n messageId: ERROR_WRONG_FORMAT,\n data: { id: t.id, format: options.format },\n node: t.source.node,\n });\n }\n } else if (typeof options.format === 'function') {\n const result = options.format(t.id);\n if (result) {\n report({\n messageId: ERROR_WRONG_FORMAT,\n data: { id: t.id, format: '(custom)' },\n node: t.source.node,\n });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import { getTokenMatcher } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const DESCRIPTIONS = 'core/descriptions';\n\nexport interface RuleDescriptionsOptions {\n /** Token IDs to ignore. Supports globs (`*`). */\n ignore?: string[];\n}\n\nconst ERROR_MISSING_DESCRIPTION = 'MISSING_DESCRIPTION';\n\nconst rule: LintRule<typeof ERROR_MISSING_DESCRIPTION, RuleDescriptionsOptions> = {\n meta: {\n messages: {\n [ERROR_MISSING_DESCRIPTION]: '{{ id }} missing description',\n },\n docs: {\n description: 'Enforce tokens have descriptions.',\n url: docsLink(DESCRIPTIONS),\n },\n },\n defaultOptions: {},\n create({ tokens, options, report }) {\n const shouldIgnore = options.ignore ? getTokenMatcher(options.ignore) : null;\n\n for (const t of Object.values(tokens)) {\n if (shouldIgnore?.(t.id)) {\n continue;\n }\n if (!t.$description) {\n report({\n messageId: ERROR_MISSING_DESCRIPTION,\n data: { id: t.id },\n node: t.source.node,\n });\n }\n }\n },\n};\n\nexport default rule;\n","import { getTokenMatcher, isAlias } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const DUPLICATE_VALUES = 'core/duplicate-values';\n\nexport interface RuleDuplicateValueOptions {\n /** Token IDs to ignore. Supports globs (`*`). */\n ignore?: string[];\n}\n\nconst ERROR_DUPLICATE_VALUE = 'ERROR_DUPLICATE_VALUE';\n\nconst rule: LintRule<typeof ERROR_DUPLICATE_VALUE, RuleDuplicateValueOptions> = {\n meta: {\n messages: {\n [ERROR_DUPLICATE_VALUE]: '{{ id }} declared a duplicate value',\n },\n docs: {\n description: 'Enforce tokens can’t redeclare the same value (excludes aliases).',\n url: docsLink(DUPLICATE_VALUES),\n },\n },\n defaultOptions: {},\n create({ report, tokens, options }) {\n const values: Record<string, Set<any>> = {};\n\n const shouldIgnore = options.ignore ? getTokenMatcher(options.ignore) : null;\n\n for (const t of Object.values(tokens)) {\n // skip ignored tokens\n if (shouldIgnore?.(t.id)) {\n continue;\n }\n\n if (!values[t.$type]) {\n values[t.$type] = new Set();\n }\n\n // primitives: direct comparison is easy\n if (\n t.$type === 'boolean' ||\n t.$type === 'duration' ||\n t.$type === 'fontWeight' ||\n t.$type === 'link' ||\n t.$type === 'number' ||\n t.$type === 'string'\n ) {\n // skip aliases (note: $value will be resolved)\n if (typeof t.aliasOf === 'string' && isAlias(t.aliasOf)) {\n continue;\n }\n\n if (values[t.$type]?.has(t.$value)) {\n report({\n messageId: ERROR_DUPLICATE_VALUE,\n data: { id: t.id },\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n\n values[t.$type]?.add(t.$value);\n } else {\n // everything else: use deepEqual\n for (const v of values[t.$type]!.values() ?? []) {\n // TODO: don’t JSON.stringify\n if (JSON.stringify(t.$value) === JSON.stringify(v)) {\n report({\n messageId: ERROR_DUPLICATE_VALUE,\n data: { id: t.id },\n node: t.source.node,\n filename: t.source.filename,\n });\n break;\n }\n }\n values[t.$type]!.add(t.$value);\n }\n }\n },\n};\n\nexport default rule;\n","import { getTokenMatcher, tokenToColor } from '@terrazzo/token-tools';\nimport { inGamut } from 'colorjs.io/fn';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const MAX_GAMUT = 'core/max-gamut';\n\nexport interface RuleMaxGamutOptions {\n /** Gamut to constrain color tokens to. */\n gamut: 'srgb' | 'p3' | 'rec2020';\n /** (optional) Token IDs to ignore. Supports globs (`*`). */\n ignore?: string[];\n}\n\nconst ERROR_COLOR = 'COLOR';\nconst ERROR_BORDER = 'BORDER';\nconst ERROR_GRADIENT = 'GRADIENT';\nconst ERROR_SHADOW = 'SHADOW';\n\nconst rule: LintRule<\n typeof ERROR_COLOR | typeof ERROR_BORDER | typeof ERROR_GRADIENT | typeof ERROR_SHADOW,\n RuleMaxGamutOptions\n> = {\n meta: {\n messages: {\n [ERROR_COLOR]: 'Color {{ id }} is outside {{ gamut }} gamut',\n [ERROR_BORDER]: 'Border {{ id }} is outside {{ gamut }} gamut',\n [ERROR_GRADIENT]: 'Gradient {{ id }} is outside {{ gamut }} gamut',\n [ERROR_SHADOW]: 'Shadow {{ id }} is outside {{ gamut }} gamut',\n },\n docs: {\n description: 'Enforce colors are within the specified gamut.',\n url: docsLink(MAX_GAMUT),\n },\n },\n defaultOptions: { gamut: 'rec2020' },\n create({ tokens, options, report }) {\n if (!options?.gamut) {\n return;\n }\n if (options.gamut !== 'srgb' && options.gamut !== 'p3' && options.gamut !== 'rec2020') {\n throw new Error(`Unknown gamut \"${options.gamut}\". Options are \"srgb\", \"p3\", or \"rec2020\"`);\n }\n\n const shouldIgnore = options.ignore ? getTokenMatcher(options.ignore) : null;\n\n for (const t of Object.values(tokens)) {\n // skip ignored tokens\n if (shouldIgnore?.(t.id)) {\n continue;\n }\n\n // skip aliases\n if (t.aliasOf) {\n continue;\n }\n\n switch (t.$type) {\n case 'color': {\n if (!inGamut(tokenToColor(t.$value), options.gamut)) {\n report({\n messageId: ERROR_COLOR,\n data: { id: t.id, gamut: options.gamut },\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n break;\n }\n case 'border': {\n if (!t.partialAliasOf?.color && !inGamut(tokenToColor(t.$value.color), options.gamut)) {\n report({\n messageId: ERROR_BORDER,\n data: { id: t.id, gamut: options.gamut },\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n break;\n }\n case 'gradient': {\n for (let stopI = 0; stopI < t.$value.length; stopI++) {\n if (!t.partialAliasOf?.[stopI]?.color && !inGamut(tokenToColor(t.$value[stopI]!.color), options.gamut)) {\n report({\n messageId: ERROR_GRADIENT,\n data: { id: t.id, gamut: options.gamut },\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n }\n break;\n }\n case 'shadow': {\n for (let shadowI = 0; shadowI < t.$value.length; shadowI++) {\n if (\n !t.partialAliasOf?.[shadowI]?.color &&\n !inGamut(tokenToColor(t.$value[shadowI]!.color), options.gamut)\n ) {\n report({\n messageId: ERROR_SHADOW,\n data: { id: t.id, gamut: options.gamut },\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n }\n break;\n }\n }\n }\n },\n};\n\nexport default rule;\n","import { getTokenMatcher } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const REQUIRED_CHILDREN = 'core/required-children';\n\nexport interface RequiredChildrenMatch {\n /** Glob of tokens/groups to match */\n match: string[];\n /** Required token IDs to match (this only looks at the very last segment of a token ID!) */\n requiredTokens?: string[];\n /** Required groups to match (this only looks at the beginning/middle segments of a token ID!) */\n requiredGroups?: string[];\n}\n\nexport interface RuleRequiredChildrenOptions {\n matches: RequiredChildrenMatch[];\n}\n\nexport const ERROR_EMPTY_MATCH = 'EMPTY_MATCH';\nexport const ERROR_MISSING_REQUIRED_TOKENS = 'MISSING_REQUIRED_TOKENS';\nexport const ERROR_MISSING_REQUIRED_GROUP = 'MISSING_REQUIRED_GROUP';\n\nconst rule: LintRule<\n typeof ERROR_EMPTY_MATCH | typeof ERROR_MISSING_REQUIRED_TOKENS | typeof ERROR_MISSING_REQUIRED_GROUP,\n RuleRequiredChildrenOptions\n> = {\n meta: {\n messages: {\n [ERROR_EMPTY_MATCH]: 'No tokens matched {{ matcher }}',\n [ERROR_MISSING_REQUIRED_TOKENS]: 'Match {{ index }}: some groups missing required token \"{{ token }}\"',\n [ERROR_MISSING_REQUIRED_GROUP]: 'Match {{ index }}: some tokens missing required group \"{{ group }}\"',\n },\n docs: {\n description: 'Enforce token groups have specific children, whether tokens and/or groups.',\n url: docsLink(REQUIRED_CHILDREN),\n },\n },\n defaultOptions: { matches: [] },\n create({ tokens, options, report }) {\n if (!options.matches?.length) {\n throw new Error('Invalid config. Missing `matches: […]`');\n }\n\n // note: in many other rules, the operation can be completed in one iteration through all tokens\n // in this rule, however, we have to scan all tokens every time per-match, because they may overlap\n\n for (let matchI = 0; matchI < options.matches.length; matchI++) {\n const { match, requiredTokens, requiredGroups } = options.matches[matchI]!;\n\n // validate\n if (!match.length) {\n throw new Error(`Match ${matchI}: must declare \\`match: […]\\``);\n }\n if (!requiredTokens?.length && !requiredGroups?.length) {\n throw new Error(`Match ${matchI}: must declare either \\`requiredTokens: […]\\` or \\`requiredGroups: […]\\``);\n }\n\n const matcher = getTokenMatcher(match);\n\n const matchGroups: string[] = [];\n const matchTokens: string[] = [];\n let tokensMatched = false;\n for (const t of Object.values(tokens)) {\n if (!matcher(t.id)) {\n continue;\n }\n tokensMatched = true;\n const groups = t.id.split('.');\n matchTokens.push(groups.pop()!);\n matchGroups.push(...groups);\n }\n\n if (!tokensMatched) {\n report({\n messageId: ERROR_EMPTY_MATCH,\n data: { matcher: JSON.stringify(match) },\n });\n continue;\n }\n\n if (requiredTokens) {\n for (const id of requiredTokens) {\n if (!matchTokens.includes(id)) {\n report({\n messageId: ERROR_MISSING_REQUIRED_TOKENS,\n data: { index: matchI, token: id },\n });\n }\n }\n }\n if (requiredGroups) {\n for (const groupName of requiredGroups) {\n if (!matchGroups.includes(groupName)) {\n report({\n messageId: ERROR_MISSING_REQUIRED_GROUP,\n data: { index: matchI, group: groupName },\n });\n }\n }\n }\n }\n },\n};\n\nexport default rule;\n","import { getTokenMatcher } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const REQUIRED_MODES = 'core/required-modes';\n\nexport type RequiredModesMatch = {\n /** Glob of tokens/groups to match */\n match: string[];\n /** Required modes */\n modes: string[];\n};\n\nexport interface RuleRequiredModesOptions {\n matches: RequiredModesMatch[];\n}\n\nconst rule: LintRule<never, RuleRequiredModesOptions> = {\n meta: {\n docs: {\n description: 'Enforce certain tokens have specific modes.',\n url: docsLink(REQUIRED_MODES),\n },\n },\n defaultOptions: { matches: [] },\n create({ tokens, options, report }) {\n if (!options?.matches?.length) {\n throw new Error('Invalid config. Missing `matches: […]`');\n }\n\n // note: in many other rules, the operation can be completed in one iteration through all tokens\n // in this rule, however, we have to scan all tokens every time per-match, because they may overlap\n for (let matchI = 0; matchI < options.matches.length; matchI++) {\n const { match, modes } = options.matches[matchI]!;\n\n // validate\n if (!match.length) {\n throw new Error(`Match ${matchI}: must declare \\`match: […]\\``);\n }\n if (!modes?.length) {\n throw new Error(`Match ${matchI}: must declare \\`modes: […]\\``);\n }\n\n const matcher = getTokenMatcher(match);\n\n let tokensMatched = false;\n for (const t of Object.values(tokens)) {\n if (!matcher(t.id)) {\n continue;\n }\n tokensMatched = true;\n\n for (const mode of modes) {\n if (!t.mode?.[mode]) {\n report({\n message: `Token ${t.id}: missing required mode \"${mode}\"`,\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n }\n\n if (!tokensMatched) {\n report({\n message: `Match \"${matchI}\": no tokens matched ${JSON.stringify(match)}`,\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const REQUIRED_TYPE = 'core/required-type';\n\nexport const ERROR = 'ERROR';\n\nconst rule: LintRule<typeof ERROR> = {\n meta: {\n messages: {\n [ERROR]: 'Token missing $type.',\n },\n docs: {\n description: 'Requiring every token to have $type, even aliases, simplifies computation.',\n url: docsLink(REQUIRED_TYPE),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (!t.originalValue?.$type) {\n report({ messageId: ERROR, node: t.source.node, filename: t.source.filename });\n }\n }\n },\n};\n\nexport default rule;\n","import { getTokenMatcher } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const REQUIRED_TYPOGRAPHY_PROPERTIES = 'core/required-typography-properties';\n\nexport interface RuleRequiredTypographyPropertiesOptions {\n /**\n * Required typography properties.\n * @default [\"fontFamily\", \"fontWeight\", \"fontSize\", \"letterSpacing\", \"lineHeight\"]\n */\n properties: string[];\n /** Token globs to ignore */\n ignore?: string[];\n}\n\n/** @deprecated Use core/valid-typography instead */\nconst rule: LintRule<never, RuleRequiredTypographyPropertiesOptions> = {\n meta: {\n docs: {\n description: 'Enforce typography tokens have required properties.',\n url: docsLink(REQUIRED_TYPOGRAPHY_PROPERTIES),\n },\n },\n defaultOptions: {\n properties: ['fontFamily', 'fontSize', 'fontWeight', 'letterSpacing', 'lineHeight'],\n },\n create({ tokens, options, report }) {\n if (!options) {\n return;\n }\n\n if (!options.properties.length) {\n throw new Error(`\"properties\" can’t be empty`);\n }\n\n const shouldIgnore = options.ignore ? getTokenMatcher(options.ignore) : null;\n\n for (const t of Object.values(tokens)) {\n if (shouldIgnore?.(t.id)) {\n continue;\n }\n\n if (t.$type !== 'typography') {\n continue;\n }\n\n if (t.aliasOf) {\n continue;\n }\n\n for (const p of options.properties) {\n if (!t.partialAliasOf?.[p] && !(p in t.$value)) {\n report({\n message: `This rule is deprecated. Use core/valid-typography. Missing required typographic property \"${p}\"`,\n node: t.source.node,\n filename: t.source.filename,\n });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember, getObjMembers } from '@terrazzo/json-schema-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_FONT_FAMILY = 'core/valid-font-family';\n\nconst ERROR = 'ERROR';\n\nconst rule: LintRule<typeof ERROR> = {\n meta: {\n messages: {\n [ERROR]: 'Must be a string, or array of strings.',\n },\n docs: {\n description: 'Require fontFamily tokens to follow the format.',\n url: docsLink(VALID_FONT_FAMILY),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue) {\n continue;\n }\n\n switch (t.$type) {\n case 'fontFamily': {\n validateFontFamily(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value') as momoa.ArrayNode,\n filename: t.source.filename,\n });\n break;\n }\n case 'typography': {\n if (typeof t.originalValue.$value === 'object' && t.originalValue.$value.fontFamily) {\n if (t.partialAliasOf?.fontFamily) {\n continue;\n }\n const $value = getObjMember(t.source.node, '$value');\n const properties = getObjMembers($value as momoa.ObjectNode);\n validateFontFamily(t.originalValue.$value.fontFamily, {\n node: properties.fontFamily as momoa.ArrayNode,\n filename: t.source.filename,\n });\n }\n break;\n }\n }\n\n function validateFontFamily(value: unknown, { node, filename }: { node: momoa.ArrayNode; filename?: string }) {\n if (typeof value === 'string') {\n if (!value) {\n report({ messageId: ERROR, node, filename });\n }\n } else if (Array.isArray(value)) {\n if (!value.every((v) => v && typeof v === 'string')) {\n report({ messageId: ERROR, node, filename });\n }\n } else {\n report({ messageId: ERROR, node, filename });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember, getObjMembers } from '@terrazzo/json-schema-tools';\nimport { FONT_WEIGHTS } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_FONT_WEIGHT = 'core/valid-font-weight';\n\nconst ERROR = 'ERROR';\nconst ERROR_STYLE = 'ERROR_STYLE';\n\nexport interface RuleFontWeightOptions {\n /**\n * Enforce either:\n * - \"numbers\" (0-999)\n * - \"names\" (\"light\", \"medium\", \"bold\", etc.)\n */\n style?: 'numbers' | 'names';\n}\n\nconst rule: LintRule<typeof ERROR | typeof ERROR_STYLE, RuleFontWeightOptions> = {\n meta: {\n messages: {\n [ERROR]: `Must either be a valid number (0 - 999) or a valid font weight: ${new Intl.ListFormat('en-us', { type: 'disjunction' }).format(Object.keys(FONT_WEIGHTS))}.`,\n [ERROR_STYLE]: 'Expected style {{ style }}, received {{ value }}.',\n },\n docs: {\n description: 'Require number tokens to follow the format.',\n url: docsLink(VALID_FONT_WEIGHT),\n },\n },\n defaultOptions: {\n style: undefined,\n },\n create({ tokens, options, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue) {\n continue;\n }\n\n switch (t.$type) {\n case 'fontWeight': {\n validateFontWeight(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value') as momoa.StringNode,\n filename: t.source.filename,\n });\n break;\n }\n case 'typography': {\n if (typeof t.originalValue.$value === 'object' && t.originalValue.$value.fontWeight) {\n if (t.partialAliasOf?.fontWeight) {\n continue;\n }\n const $value = getObjMember(t.source.node, '$value');\n const properties = getObjMembers($value as momoa.ObjectNode);\n validateFontWeight(t.originalValue.$value.fontWeight, {\n node: properties.fontWeight as momoa.StringNode,\n filename: t.source.filename,\n });\n }\n break;\n }\n }\n\n function validateFontWeight(\n value: unknown,\n { node, filename }: { node: momoa.StringNode | momoa.NumberNode; filename?: string },\n ) {\n if (typeof value === 'string') {\n if (options.style === 'numbers') {\n report({ messageId: ERROR_STYLE, data: { style: 'numbers', value }, node, filename });\n } else if (!(value in FONT_WEIGHTS)) {\n report({ messageId: ERROR, node, filename });\n }\n } else if (typeof value === 'number') {\n if (options.style === 'names') {\n report({ messageId: ERROR_STYLE, data: { style: 'names', value }, node, filename });\n } else if (!(value >= 0 && value < 1000)) {\n report({ messageId: ERROR, node, filename });\n }\n } else {\n report({ messageId: ERROR, node, filename });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport { GRADIENT_REQUIRED_STOP_PROPERTIES, isAlias } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_GRADIENT = 'core/valid-gradient';\n\nconst ERROR_MISSING = 'ERROR_MISSING';\nconst ERROR_POSITION = 'ERROR_POSITION';\nconst ERROR_INVALID_PROP = 'ERROR_INVALID_PROP';\n\nconst rule: LintRule<typeof ERROR_MISSING | typeof ERROR_POSITION | typeof ERROR_INVALID_PROP> = {\n meta: {\n messages: {\n [ERROR_MISSING]: 'Must be an array of { color, position } objects.',\n [ERROR_POSITION]: 'Expected number 0-1, received {{ value }}.',\n [ERROR_INVALID_PROP]: 'Unknown property {{ key }}.',\n },\n docs: {\n description: 'Require gradient tokens to follow the format.',\n url: docsLink(VALID_GRADIENT),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue || t.$type !== 'gradient') {\n continue;\n }\n\n validateGradient(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value') as momoa.ArrayNode,\n filename: t.source.filename,\n });\n\n function validateGradient(value: unknown, { node, filename }: { node: momoa.ArrayNode; filename?: string }) {\n if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) {\n const stop = value[i]!;\n if (!stop || typeof stop !== 'object') {\n report({ messageId: ERROR_MISSING, node, filename });\n continue;\n }\n for (const property of GRADIENT_REQUIRED_STOP_PROPERTIES) {\n if (!(property in stop)) {\n report({ messageId: ERROR_MISSING, node: node.elements[i], filename });\n }\n }\n for (const key of Object.keys(stop)) {\n if (\n !GRADIENT_REQUIRED_STOP_PROPERTIES.includes(key as (typeof GRADIENT_REQUIRED_STOP_PROPERTIES)[number])\n ) {\n report({\n messageId: ERROR_INVALID_PROP,\n data: { key: JSON.stringify(key) },\n node: node.elements[i],\n filename,\n });\n }\n }\n if ('position' in stop && typeof stop.position !== 'number' && !isAlias(stop.position as string)) {\n report({\n messageId: ERROR_POSITION,\n data: { value: stop.position },\n node: getObjMember(node.elements[i]!.value as momoa.ObjectNode, 'position'),\n filename,\n });\n }\n }\n } else {\n report({ messageId: ERROR_MISSING, node, filename });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_LINK = 'core/valid-link';\n\nconst ERROR = 'ERROR';\n\nconst rule: LintRule<typeof ERROR, {}> = {\n meta: {\n messages: {\n [ERROR]: 'Must be a string.',\n },\n docs: {\n description: 'Require link tokens to follow the Terrazzo extension.',\n url: docsLink(VALID_LINK),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue || t.$type !== 'link') {\n continue;\n }\n\n validateLink(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value') as momoa.StringNode,\n filename: t.source.filename,\n });\n\n function validateLink(value: unknown, { node, filename }: { node: momoa.StringNode; filename?: string }) {\n if (!value || typeof value !== 'string') {\n report({ messageId: ERROR, node, filename });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport { isAlias } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_NUMBER = 'core/valid-number';\n\nconst ERROR_NAN = 'ERROR_NAN';\n\nconst rule: LintRule<typeof ERROR_NAN> = {\n meta: {\n messages: {\n [ERROR_NAN]: 'Must be a number.',\n },\n docs: {\n description: 'Require number tokens to follow the format.',\n url: docsLink(VALID_NUMBER),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue) {\n continue;\n }\n\n switch (t.$type) {\n case 'number': {\n validateNumber(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value') as momoa.NumberNode,\n filename: t.source.filename,\n });\n break;\n }\n // Note: gradient not needed, validated in gradient\n case 'typography': {\n const $valueNode = getObjMember(t.source.node, '$value') as momoa.ObjectNode;\n if (typeof t.originalValue.$value === 'object') {\n if (\n t.originalValue.$value.lineHeight &&\n !isAlias(t.originalValue.$value.lineHeight as string) &&\n typeof t.originalValue.$value.lineHeight !== 'object'\n ) {\n validateNumber(t.originalValue.$value.lineHeight, {\n node: getObjMember($valueNode, 'lineHeight') as momoa.NumberNode,\n filename: t.source.filename,\n });\n }\n }\n }\n }\n\n function validateNumber(value: unknown, { node, filename }: { node: momoa.NumberNode; filename?: string }) {\n if (typeof value !== 'number' || Number.isNaN(value)) {\n report({ messageId: ERROR_NAN, node, filename });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport { SHADOW_REQUIRED_PROPERTIES } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_SHADOW = 'core/valid-shadow';\n\nconst ERROR = 'ERROR';\nconst ERROR_INVALID_PROP = 'ERROR_INVALID_PROP';\n\nconst rule: LintRule<typeof ERROR | typeof ERROR_INVALID_PROP> = {\n meta: {\n messages: {\n [ERROR]: `Missing required properties: ${new Intl.ListFormat('en-us', { type: 'conjunction' }).format(SHADOW_REQUIRED_PROPERTIES)}.`,\n [ERROR_INVALID_PROP]: 'Unknown property {{ key }}.',\n },\n docs: {\n description: 'Require shadow tokens to follow the format.',\n url: docsLink(VALID_SHADOW),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue || t.$type !== 'shadow') {\n continue;\n }\n\n validateShadow(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value') as momoa.ObjectNode,\n filename: t.source.filename,\n });\n\n // Note: we validate sub-properties using other checks like valid-dimension, valid-font-family, etc.\n // The only thing remaining is to check that all properties exist (since missing properties won’t appear as invalid)\n function validateShadow(\n value: unknown,\n { node, filename }: { node: momoa.ObjectNode | momoa.ArrayNode; filename?: string },\n ) {\n const wrappedValue = Array.isArray(value) ? value : [value];\n for (let i = 0; i < wrappedValue.length; i++) {\n if (\n !wrappedValue[i] ||\n typeof wrappedValue[i] !== 'object' ||\n !SHADOW_REQUIRED_PROPERTIES.every((property) => property in wrappedValue[i])\n ) {\n report({ messageId: ERROR, node, filename });\n } else {\n for (const key of Object.keys(wrappedValue[i])) {\n if (![...SHADOW_REQUIRED_PROPERTIES, 'inset'].includes(key)) {\n report({\n messageId: ERROR_INVALID_PROP,\n data: { key: JSON.stringify(key) },\n node: getObjMember(node.type === 'Array' ? (node.elements[i]!.value as momoa.ObjectNode) : node, key),\n filename,\n });\n }\n }\n }\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_STRING = 'core/valid-string';\n\nconst ERROR = 'ERROR';\n\nconst rule: LintRule<typeof ERROR> = {\n meta: {\n messages: {\n [ERROR]: 'Must be a string.',\n },\n docs: {\n description: 'Require string tokens to follow the Terrazzo extension.',\n url: docsLink(VALID_STRING),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue || t.$type !== 'string') {\n continue;\n }\n\n validateString(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value') as momoa.StringNode,\n filename: t.source.filename,\n });\n\n function validateString(value: unknown, { node, filename }: { node: momoa.StringNode; filename?: string }) {\n if (typeof value !== 'string') {\n report({ messageId: ERROR, node, filename });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport {\n isAlias,\n STROKE_STYLE_LINE_CAP_VALUES,\n STROKE_STYLE_OBJECT_REQUIRED_PROPERTIES,\n STROKE_STYLE_STRING_VALUES,\n TRANSITION_REQUIRED_PROPERTIES,\n} from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_STROKE_STYLE = 'core/valid-stroke-style';\n\nconst ERROR_STR = 'ERROR_STR';\nconst ERROR_OBJ = 'ERROR_OBJ';\nconst ERROR_LINE_CAP = 'ERROR_LINE_CAP';\nconst ERROR_INVALID_PROP = 'ERROR_INVALID_PROP';\n\nconst rule: LintRule<typeof ERROR_STR | typeof ERROR_OBJ | typeof ERROR_LINE_CAP | typeof ERROR_INVALID_PROP> = {\n meta: {\n messages: {\n [ERROR_STR]: `Value most be one of ${new Intl.ListFormat('en-us', { type: 'disjunction' }).format(STROKE_STYLE_STRING_VALUES)}.`,\n [ERROR_OBJ]: `Missing required properties: ${new Intl.ListFormat('en-us', { type: 'conjunction' }).format(TRANSITION_REQUIRED_PROPERTIES)}.`,\n [ERROR_LINE_CAP]: `lineCap must be one of ${new Intl.ListFormat('en-us', { type: 'disjunction' }).format(STROKE_STYLE_LINE_CAP_VALUES)}.`,\n [ERROR_INVALID_PROP]: 'Unknown property: {{ key }}.',\n },\n docs: {\n description: 'Require strokeStyle tokens to follow the format.',\n url: docsLink(VALID_STROKE_STYLE),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue) {\n continue;\n }\n\n switch (t.$type) {\n case 'strokeStyle': {\n validateStrokeStyle(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value') as momoa.ObjectNode,\n filename: t.source.filename,\n });\n break;\n }\n case 'border': {\n if (t.originalValue.$value && typeof t.originalValue.$value === 'object') {\n const $valueNode = getObjMember(t.source.node, '$value') as momoa.ObjectNode;\n if (t.originalValue.$value.style) {\n validateStrokeStyle(t.originalValue.$value.style, {\n node: getObjMember($valueNode, 'style') as momoa.ObjectNode,\n filename: t.source.filename,\n });\n }\n }\n break;\n }\n }\n\n // Note: we validate sub-properties using other checks like valid-dimension, valid-font-family, etc.\n // The only thing remaining is to check that all properties exist (since missing properties won’t appear as invalid)\n function validateStrokeStyle(\n value: unknown,\n { node, filename }: { node: momoa.StringNode | momoa.ObjectNode; filename?: string },\n ) {\n if (typeof value === 'string') {\n if (\n !isAlias(value) &&\n !STROKE_STYLE_STRING_VALUES.includes(value as (typeof STROKE_STYLE_STRING_VALUES)[number])\n ) {\n report({ messageId: ERROR_STR, node, filename });\n return;\n }\n } else if (value && typeof value === 'object') {\n if (!STROKE_STYLE_OBJECT_REQUIRED_PROPERTIES.every((property) => property in value)) {\n report({ messageId: ERROR_OBJ, node, filename });\n }\n if (!Array.isArray((value as any).dashArray)) {\n report({ messageId: ERROR_OBJ, node: getObjMember(node as momoa.ObjectNode, 'dashArray'), filename });\n }\n if (!STROKE_STYLE_LINE_CAP_VALUES.includes((value as any).lineCap)) {\n report({ messageId: ERROR_OBJ, node: getObjMember(node as momoa.ObjectNode, 'lineCap'), filename });\n }\n for (const key of Object.keys(value)) {\n if (!['dashArray', 'lineCap'].includes(key)) {\n report({\n messageId: ERROR_INVALID_PROP,\n data: { key: JSON.stringify(key) },\n node: getObjMember(node as momoa.ObjectNode, key),\n filename,\n });\n }\n }\n } else {\n report({ messageId: ERROR_OBJ, node, filename });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport { TRANSITION_REQUIRED_PROPERTIES } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_TRANSITION = 'core/valid-transition';\n\nconst ERROR = 'ERROR';\nconst ERROR_INVALID_PROP = 'ERROR_INVALID_PROP';\n\nconst rule: LintRule<typeof ERROR | typeof ERROR_INVALID_PROP> = {\n meta: {\n messages: {\n [ERROR]: `Missing required properties: ${new Intl.ListFormat('en-us', { type: 'conjunction' }).format(TRANSITION_REQUIRED_PROPERTIES)}.`,\n [ERROR_INVALID_PROP]: 'Unknown property: {{ key }}.',\n },\n docs: {\n description: 'Require transition tokens to follow the format.',\n url: docsLink(VALID_TRANSITION),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue || t.$type !== 'transition') {\n continue;\n }\n\n validateTransition(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value') as momoa.ObjectNode,\n filename: t.source.filename,\n });\n }\n\n // Note: we validate sub-properties using other checks like valid-dimension, valid-font-family, etc.\n // The only thing remaining is to check that all properties exist (since missing properties won’t appear as invalid)\n function validateTransition(value: unknown, { node, filename }: { node: momoa.ObjectNode; filename?: string }) {\n if (\n !value ||\n typeof value !== 'object' ||\n !TRANSITION_REQUIRED_PROPERTIES.every((property) => property in value)\n ) {\n report({ messageId: ERROR, node, filename });\n } else {\n for (const key of Object.keys(value)) {\n if (!TRANSITION_REQUIRED_PROPERTIES.includes(key as (typeof TRANSITION_REQUIRED_PROPERTIES)[number])) {\n report({\n messageId: ERROR_INVALID_PROP,\n data: { key: JSON.stringify(key) },\n node: getObjMember(node, key),\n filename,\n });\n }\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport { getTokenMatcher } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_TYPOGRAPHY = 'core/valid-typography';\n\nconst ERROR = 'ERROR';\nconst ERROR_MISSING = 'ERROR_MISSING';\n\nexport interface RuleValidTypographyOptions {\n /** Required typography properties */\n requiredProperties: string[];\n /** Token globs to ignore */\n ignore?: string[];\n}\n\nconst rule: LintRule<typeof ERROR | typeof ERROR_MISSING, RuleValidTypographyOptions> = {\n meta: {\n messages: {\n [ERROR]: `Expected object, received {{ value }}.`,\n [ERROR_MISSING]: `Missing required property \"{{ property }}\".`,\n },\n docs: {\n description: 'Require typography tokens to follow the format.',\n url: docsLink(VALID_TYPOGRAPHY),\n },\n },\n defaultOptions: {\n requiredProperties: ['fontFamily', 'fontSize', 'fontWeight', 'letterSpacing', 'lineHeight'],\n },\n create({ tokens, options, report }) {\n const isIgnored = options.ignore ? getTokenMatcher(options.ignore) : () => false;\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue || t.$type !== 'typography' || isIgnored(t.id)) {\n continue;\n }\n\n validateTypography(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value') as momoa.ObjectNode,\n filename: t.source.filename,\n });\n\n // Note: we validate sub-properties using other checks like valid-dimension, valid-font-family, etc.\n // The only thing remaining is to check that all properties exist (since missing properties won’t appear as invalid)\n function validateTypography(value: unknown, { node, filename }: { node: momoa.ObjectNode; filename?: string }) {\n if (value && typeof value === 'object') {\n for (const property of options.requiredProperties) {\n if (!(property in value)) {\n report({ messageId: ERROR_MISSING, data: { property }, node, filename });\n }\n }\n } else {\n report({\n messageId: ERROR,\n data: { value: JSON.stringify(value) },\n node,\n filename,\n });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_BOOLEAN = 'core/valid-boolean';\n\nconst ERROR = 'ERROR';\n\nconst rule: LintRule<typeof ERROR, {}> = {\n meta: {\n messages: {\n [ERROR]: 'Must be a boolean.',\n },\n docs: {\n description: 'Require boolean tokens to follow the Terrazzo extension.',\n url: docsLink(VALID_BOOLEAN),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue || t.$type !== 'boolean') {\n continue;\n }\n\n validateBoolean(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value'),\n filename: t.source.filename,\n });\n\n function validateBoolean(value: unknown, { node, filename }: { node?: momoa.AnyNode; filename?: string }) {\n if (typeof value !== 'boolean') {\n report({ messageId: ERROR, filename, node });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport { BORDER_REQUIRED_PROPERTIES } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_BORDER = 'core/valid-border';\n\nconst ERROR = 'ERROR';\nconst ERROR_INVALID_PROP = 'ERROR_INVALID_PROP';\n\nconst rule: LintRule<typeof ERROR | typeof ERROR_INVALID_PROP, {}> = {\n meta: {\n messages: {\n [ERROR]: `Border token missing required properties: ${new Intl.ListFormat('en-us', { type: 'conjunction' }).format(BORDER_REQUIRED_PROPERTIES)}.`,\n [ERROR_INVALID_PROP]: 'Unknown property: {{ key }}.',\n },\n docs: {\n description: 'Require border tokens to follow the format.',\n url: docsLink(VALID_BORDER),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue || t.$type !== 'border') {\n continue;\n }\n\n validateBorder(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value'),\n filename: t.source.filename,\n });\n }\n\n // Note: we validate sub-properties using other checks like valid-dimension, valid-font-family, etc.\n // The only thing remaining is to check that all properties exist (since missing properties won’t appear as invalid)\n function validateBorder(value: unknown, { node, filename }: { node?: momoa.AnyNode; filename?: string }) {\n if (!value || typeof value !== 'object' || !BORDER_REQUIRED_PROPERTIES.every((property) => property in value)) {\n report({ messageId: ERROR, filename, node });\n } else {\n for (const key of Object.keys(value)) {\n if (!BORDER_REQUIRED_PROPERTIES.includes(key as (typeof BORDER_REQUIRED_PROPERTIES)[number])) {\n report({\n messageId: ERROR_INVALID_PROP,\n data: { key: JSON.stringify(key) },\n node: getObjMember(node as momoa.ObjectNode, key) ?? node,\n filename,\n });\n }\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport {\n type BorderValue,\n COLOR_SPACE,\n type ColorSpace,\n type ColorValueNormalized,\n type GradientStopNormalized,\n type GradientValueNormalized,\n isAlias,\n parseColor,\n type ShadowValue,\n} from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_COLOR = 'core/valid-color';\n\nexport const VALID_COLORSPACES = new Set([\n 'a98-rgb',\n 'display-p3',\n 'hsl',\n 'hwb',\n 'lab',\n 'lab-d65',\n 'lab',\n 'lch',\n 'okhsv',\n 'oklab',\n 'oklch',\n 'prophoto-rgb',\n 'rec2020',\n 'srgb',\n 'srgb-linear',\n 'xyz',\n 'xyz-d50',\n 'xyz-d65',\n] satisfies ColorSpace[]);\n\nconst ERROR_ALPHA = 'ERROR_ALPHA';\nconst ERROR_INVALID_COLOR = 'ERROR_INVALID_COLOR';\nconst ERROR_INVALID_COLOR_SPACE = 'ERROR_INVALID_COLOR_SPACE';\nconst ERROR_INVALID_COMPONENT_LENGTH = 'ERROR_INVALID_COMPONENT_LENGTH';\nconst ERROR_INVALID_HEX8 = 'ERROR_INVALID_HEX8';\nconst ERROR_INVALID_PROP = 'ERROR_INVALID_PROP';\nconst ERROR_MISSING_COMPONENTS = 'ERROR_MISSING_COMPONENTS';\nconst ERROR_OBJ_FORMAT = 'ERROR_OBJ_FORMAT';\nconst ERROR_OUT_OF_RANGE = 'ERROR_OUT_OF_RANGE';\n\nexport interface RuleValidColorOptions {\n /**\n * Allow the legacy format of only a string sRGB hex code\n * @default false\n */\n legacyFormat?: boolean;\n /**\n * Allow colors to be defined out of the expected ranges.\n * @default false\n */\n ignoreRanges?: boolean;\n}\n\nconst rule: LintRule<\n | typeof ERROR_ALPHA\n | typeof ERROR_INVALID_COLOR\n | typeof ERROR_INVALID_COLOR_SPACE\n | typeof ERROR_INVALID_COMPONENT_LENGTH\n | typeof ERROR_INVALID_HEX8\n | typeof ERROR_INVALID_PROP\n | typeof ERROR_MISSING_COMPONENTS\n | typeof ERROR_OBJ_FORMAT\n | typeof ERROR_OUT_OF_RANGE,\n RuleValidColorOptions\n> = {\n meta: {\n messages: {\n [ERROR_ALPHA]: `Alpha {{ alpha }} not in range 0 – 1.`,\n [ERROR_INVALID_COLOR_SPACE]: `Invalid color space: {{ colorSpace }}. Expected ${new Intl.ListFormat('en-us', { type: 'disjunction' }).format(Object.keys(COLOR_SPACE))}.`,\n [ERROR_INVALID_COLOR]: `Could not parse color {{ color }}.`,\n [ERROR_INVALID_COMPONENT_LENGTH]: 'Expected {{ expected }} components, received {{ got }}.',\n [ERROR_INVALID_HEX8]: `Hex value can’t be semi-transparent.`,\n [ERROR_INVALID_PROP]: `Unknown property {{ key }}.`,\n [ERROR_MISSING_COMPONENTS]: 'Expected components to be array of numbers, received {{ got }}.',\n [ERROR_OBJ_FORMAT]:\n 'Migrate to the new object format, e.g. \"#ff0000\" → { \"colorSpace\": \"srgb\", \"components\": [1, 0, 0] } }',\n [ERROR_OUT_OF_RANGE]: `Invalid range for color space {{ colorSpace }}. Expected {{ range }}.`,\n },\n docs: {\n description: 'Require color tokens to follow the format.',\n url: docsLink(VALID_COLOR),\n },\n },\n defaultOptions: {\n legacyFormat: false,\n ignoreRanges: false,\n },\n create({ tokens, options, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue) {\n continue;\n }\n\n switch (t.$type) {\n case 'color': {\n validateColor(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value'),\n filename: t.source.filename,\n });\n break;\n }\n case 'border': {\n if ((t.originalValue.$value as any).color && !isAlias((t.originalValue.$value as any).color)) {\n validateColor((t.originalValue.$value as BorderValue).color, {\n node: getObjMember(getObjMember(t.source.node, '$value') as momoa.ObjectNode, 'color'),\n filename: t.source.filename,\n });\n }\n break;\n }\n case 'gradient': {\n const $valueNode = getObjMember(t.source.node, '$value') as momoa.ArrayNode;\n for (let i = 0; i < (t.originalValue.$value as GradientValueNormalized).length; i++) {\n const stop = t.originalValue.$value[i] as GradientStopNormalized;\n if (!stop.color || isAlias(stop.color as any)) {\n continue;\n }\n validateColor(stop.color, {\n node: getObjMember($valueNode.elements[i]!.value as momoa.ObjectNode, 'color'),\n filename: t.source.filename,\n });\n }\n break;\n }\n case 'shadow': {\n const $value = (\n Array.isArray(t.originalValue.$value) ? t.originalValue.$value : [t.originalValue.$value]\n ) as ShadowValue[];\n const $valueNode = getObjMember(t.source.node, '$value') as momoa.ObjectNode | momoa.ArrayNode;\n for (let i = 0; i < $value.length; i++) {\n const layer = $value[i]!;\n if (!layer.color || isAlias(layer.color as any)) {\n continue;\n }\n validateColor(layer.color, {\n node:\n $valueNode.type === 'Object'\n ? getObjMember($valueNode, 'color')\n : getObjMember($valueNode.elements[i]!.value as momoa.ObjectNode, 'color'),\n filename: t.source.filename,\n });\n }\n break;\n }\n }\n\n function validateColor(value: unknown, { node, filename }: { node?: momoa.AnyNode; filename?: string }) {\n if (!value) {\n report({ messageId: ERROR_INVALID_COLOR, data: { color: JSON.stringify(value) }, node, filename });\n } else if (typeof value === 'object') {\n for (const key of Object.keys(value)) {\n if (!['colorSpace', 'components', 'channels' /* TODO: remove */, 'hex', 'alpha'].includes(key)) {\n report({\n messageId: ERROR_INVALID_PROP,\n data: { key: JSON.stringify(key) },\n node: getObjMember(node as momoa.ObjectNode, key) ?? node,\n filename,\n });\n }\n }\n\n // Color space\n const colorSpace =\n 'colorSpace' in value && typeof value.colorSpace === 'string' ? value.colorSpace : undefined;\n const csData = COLOR_SPACE[colorSpace as keyof typeof COLOR_SPACE] || undefined;\n if (!('colorSpace' in value) || !csData) {\n report({\n messageId: ERROR_INVALID_COLOR_SPACE,\n data: { colorSpace },\n node: getObjMember(node as momoa.ObjectNode, 'colorSpace') ?? node,\n filename,\n });\n return;\n }\n\n // Component ranges\n const components = 'components' in value ? value.components : undefined;\n if (Array.isArray(components)) {\n const coords = Object.values(csData.coords);\n if (components?.length === coords.length) {\n for (let i = 0; i < components.length; i++) {\n const range = coords[i]?.range ?? coords[i]?.refRange;\n if (\n !Number.isFinite(components[i]) ||\n components[i]! < (range?.[0] ?? -Infinity) ||\n components[i]! > (range?.[1] ?? Infinity)\n ) {\n // special case for any hue-based components: allow null\n if (\n !(colorSpace === 'hsl' && components[0]! === null) &&\n !(colorSpace === 'hwb' && components[0]! === null) &&\n !(colorSpace === 'lch' && components[2]! === null) &&\n !(colorSpace === 'oklch' && components[2]! === null)\n ) {\n report({\n messageId: ERROR_OUT_OF_RANGE,\n data: { colorSpace, range: `[${range?.[0]}–${range?.[1]}]` },\n node: getObjMember(node as momoa.ObjectNode, 'components') ?? node,\n filename,\n });\n }\n }\n }\n } else {\n report({\n messageId: ERROR_INVALID_COMPONENT_LENGTH,\n data: { expected: coords.length ?? 0, got: components?.length },\n node: getObjMember(node as momoa.ObjectNode, 'components') ?? node,\n filename,\n });\n }\n } else {\n report({\n messageId: ERROR_MISSING_COMPONENTS,\n data: { got: JSON.stringify(components) },\n node: getObjMember(node as momoa.ObjectNode, 'components') ?? node,\n filename,\n });\n }\n\n // Alpha\n const alpha = 'alpha' in value ? value.alpha : undefined;\n if (alpha !== undefined && (typeof alpha !== 'number' || alpha < 0 || alpha > 1)) {\n report({\n messageId: ERROR_ALPHA,\n data: { alpha },\n node: getObjMember(node as momoa.ObjectNode, 'alpha') ?? node,\n filename,\n });\n }\n\n // Hex\n const hex = 'hex' in value ? value.hex : undefined;\n if (hex) {\n let color: ColorValueNormalized;\n try {\n color = parseColor(hex as string);\n } catch {\n report({\n messageId: ERROR_INVALID_COLOR,\n data: { color: hex },\n node: getObjMember(node as momoa.ObjectNode, 'hex') ?? node,\n filename,\n });\n return;\n }\n // since we’re only parsing hex, this should always have alpha: 1\n if (color.alpha !== 1) {\n report({\n messageId: ERROR_INVALID_HEX8,\n data: { color: hex },\n node: getObjMember(node as momoa.ObjectNode, 'hex') ?? node,\n filename,\n });\n }\n }\n } else if (typeof value === 'string') {\n if (isAlias(value)) {\n return;\n }\n if (!options.legacyFormat) {\n report({ messageId: ERROR_OBJ_FORMAT, data: { color: JSON.stringify(value) }, node, filename });\n } else {\n // Legacy format\n try {\n parseColor(value as string);\n } catch {\n report({ messageId: ERROR_INVALID_COLOR, data: { color: JSON.stringify(value) }, node, filename });\n }\n }\n } else {\n report({ messageId: ERROR_INVALID_COLOR, node, filename });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember, isPure$ref } from '@terrazzo/json-schema-tools';\nimport { isAlias } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_CUBIC_BEZIER = 'core/valid-cubic-bezier';\n\nconst ERROR = 'ERROR';\nconst ERROR_X = 'ERROR_X';\nconst ERROR_Y = 'ERROR_Y';\n\nconst rule: LintRule<typeof ERROR | typeof ERROR_X | typeof ERROR_Y> = {\n meta: {\n messages: {\n [ERROR]: 'Expected [number, number, number, number].',\n [ERROR_X]: 'x values must be between 0-1.',\n [ERROR_Y]: 'y values must be a valid number.',\n },\n docs: {\n description: 'Require cubicBezier tokens to follow the format.',\n url: docsLink(VALID_CUBIC_BEZIER),\n },\n },\n defaultOptions: {},\n create({ tokens, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue) {\n continue;\n }\n\n switch (t.$type) {\n case 'cubicBezier': {\n validateCubicBezier(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value') as momoa.ArrayNode,\n filename: t.source.filename,\n });\n break;\n }\n case 'transition': {\n if (\n typeof t.originalValue.$value === 'object' &&\n t.originalValue.$value.timingFunction &&\n !isAlias(t.originalValue.$value.timingFunction as string)\n ) {\n const $valueNode = getObjMember(t.source.node, '$value') as momoa.ObjectNode;\n validateCubicBezier(t.originalValue.$value.timingFunction, {\n node: getObjMember($valueNode, 'timingFunction') as momoa.ArrayNode,\n filename: t.source.filename,\n });\n }\n }\n }\n\n function validateCubicBezier(value: unknown, { node, filename }: { node: momoa.ArrayNode; filename?: string }) {\n if (Array.isArray(value) && value.length === 4) {\n // validate x values\n for (const pos of [0, 2]) {\n if (isAlias(value[pos]) || isPure$ref(value[pos])) {\n continue;\n }\n if (!(value[pos] >= 0 && value[pos] <= 1)) {\n report({ messageId: ERROR_X, node: (node as momoa.ArrayNode).elements[pos], filename });\n }\n }\n // validate y values\n for (const pos of [1, 3]) {\n if (isAlias(value[pos]) || isPure$ref(value[pos])) {\n continue;\n }\n if (typeof value[pos] !== 'number') {\n report({ messageId: ERROR_Y, node: (node as momoa.ArrayNode).elements[pos], filename });\n }\n }\n } else {\n report({ messageId: ERROR, node, filename });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport { isAlias } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_DIMENSION = 'core/valid-dimension';\n\nconst ERROR_FORMAT = 'ERROR_FORMAT';\nconst ERROR_INVALID_PROP = 'ERROR_INVALID_PROP';\nconst ERROR_LEGACY = 'ERROR_LEGACY';\nconst ERROR_UNIT = 'ERROR_UNIT';\nconst ERROR_VALUE = 'ERROR_VALUE';\n\nexport interface RuleValidDimension {\n /**\n * Allow the use of unknown \"unit\" values\n * @default false\n */\n legacyFormat?: boolean;\n /**\n * Only allow the following units.\n * @default [\"px\", \"rem\"]\n */\n allowedUnits?: string[];\n}\n\nconst rule: LintRule<\n typeof ERROR_FORMAT | typeof ERROR_LEGACY | typeof ERROR_UNIT | typeof ERROR_VALUE | typeof ERROR_INVALID_PROP,\n RuleValidDimension\n> = {\n meta: {\n messages: {\n [ERROR_FORMAT]: 'Invalid dimension: {{ value }}. Expected object with \"value\" and \"unit\".',\n [ERROR_LEGACY]: 'Migrate to the new object format: { \"value\": 10, \"unit\": \"px\" }.',\n [ERROR_UNIT]: 'Unit {{ unit }} not allowed. Expected {{ allowed }}.',\n [ERROR_INVALID_PROP]: 'Unknown property {{ key }}.',\n [ERROR_VALUE]: 'Expected number, received {{ value }}.',\n },\n docs: {\n description: 'Require dimension tokens to follow the format',\n url: docsLink(VALID_DIMENSION),\n },\n },\n defaultOptions: {\n legacyFormat: false,\n allowedUnits: ['px', 'em', 'rem'],\n },\n create({ tokens, options, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue) {\n continue;\n }\n\n switch (t.$type) {\n case 'dimension': {\n validateDimension(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value'),\n filename: t.source.filename,\n });\n break;\n }\n case 'strokeStyle': {\n if (typeof t.originalValue.$value === 'object' && Array.isArray(t.originalValue.$value.dashArray)) {\n const $valueNode = getObjMember(t.source.node, '$value') as momoa.ObjectNode;\n const dashArray = getObjMember($valueNode, 'dashArray') as momoa.ArrayNode;\n for (let i = 0; i < t.originalValue.$value.dashArray.length; i++) {\n if (isAlias(t.originalValue.$value.dashArray[i] as string)) {\n continue;\n }\n validateDimension(t.originalValue.$value.dashArray[i], {\n node: dashArray.elements[i]!.value,\n filename: t.source.filename,\n });\n }\n }\n break;\n }\n case 'border': {\n const $valueNode = getObjMember(t.source.node, '$value') as momoa.ObjectNode;\n if (typeof t.originalValue.$value === 'object') {\n if (t.originalValue.$value.width && !isAlias(t.originalValue.$value.width as string)) {\n validateDimension(t.originalValue.$value.width, {\n node: getObjMember($valueNode, 'width'),\n filename: t.source.filename,\n });\n }\n if (\n typeof t.originalValue.$value.style === 'object' &&\n Array.isArray(t.originalValue.$value.style.dashArray)\n ) {\n const style = getObjMember($valueNode, 'style') as momoa.ObjectNode;\n const dashArray = getObjMember(style, 'dashArray') as momoa.ArrayNode;\n for (let i = 0; i < t.originalValue.$value.style.dashArray.length; i++) {\n if (isAlias(t.originalValue.$value.style.dashArray[i] as string)) {\n continue;\n }\n validateDimension(t.originalValue.$value.style.dashArray[i], {\n node: dashArray.elements[i]!.value,\n filename: t.source.filename,\n });\n }\n }\n }\n break;\n }\n case 'shadow': {\n if (t.originalValue.$value && typeof t.originalValue.$value === 'object') {\n const $valueNode = getObjMember(t.source.node, '$value') as momoa.ObjectNode | momoa.ArrayNode;\n const valueArray = Array.isArray(t.originalValue.$value)\n ? t.originalValue.$value\n : [t.originalValue.$value];\n for (let i = 0; i < valueArray.length; i++) {\n const node =\n $valueNode.type === 'Array' ? ($valueNode.elements[i]!.value as momoa.ObjectNode) : $valueNode;\n for (const property of ['offsetX', 'offsetY', 'blur', 'spread'] as const) {\n if (isAlias(valueArray[i]![property] as string)) {\n continue;\n }\n validateDimension(valueArray[i]![property], {\n node: getObjMember(node, property),\n filename: t.source.filename,\n });\n }\n }\n }\n break;\n }\n case 'typography': {\n const $valueNode = getObjMember(t.source.node, '$value') as momoa.ObjectNode;\n if (typeof t.originalValue.$value === 'object') {\n for (const property of ['fontSize', 'lineHeight', 'letterSpacing'] as const) {\n if (property in t.originalValue.$value) {\n if (\n isAlias(t.originalValue.$value[property] as string) ||\n // special case: lineHeight may be a number\n (property === 'lineHeight' && typeof t.originalValue.$value[property] === 'number')\n ) {\n continue;\n }\n validateDimension(t.originalValue.$value[property], {\n node: getObjMember($valueNode, property),\n filename: t.source.filename,\n });\n }\n }\n }\n break;\n }\n }\n\n function validateDimension(value: unknown, { node, filename }: { node?: momoa.AnyNode; filename?: string }) {\n if (value && typeof value === 'object') {\n for (const key of Object.keys(value)) {\n if (!['value', 'unit'].includes(key)) {\n report({\n messageId: ERROR_INVALID_PROP,\n data: { key: JSON.stringify(key) },\n node: getObjMember(node as momoa.ObjectNode, key) ?? node,\n filename,\n });\n }\n }\n\n const { unit, value: numValue } = value as Record<string, any>;\n if (!('value' in value || 'unit' in value)) {\n report({ messageId: ERROR_FORMAT, data: { value }, node, filename });\n return;\n }\n if (!options.allowedUnits!.includes(unit)) {\n report({\n messageId: ERROR_UNIT,\n data: {\n unit,\n allowed: new Intl.ListFormat('en-us', { type: 'disjunction' }).format(options.allowedUnits!),\n },\n node: getObjMember(node as momoa.ObjectNode, 'unit') ?? node,\n filename,\n });\n }\n if (!Number.isFinite(numValue)) {\n report({\n messageId: ERROR_VALUE,\n data: { value },\n node: getObjMember(node as momoa.ObjectNode, 'value') ?? node,\n filename,\n });\n }\n } else if (typeof value === 'string' && !options.legacyFormat) {\n report({ messageId: ERROR_LEGACY, node, filename });\n } else {\n report({ messageId: ERROR_FORMAT, data: { value }, node, filename });\n }\n }\n }\n },\n};\n\nexport default rule;\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport { isAlias } from '@terrazzo/token-tools';\nimport type { LintRule } from '../../../types.js';\nimport { docsLink } from '../lib/docs.js';\n\nexport const VALID_DURATION = 'core/valid-duration';\n\nconst ERROR_FORMAT = 'ERROR_FORMAT';\nconst ERROR_INVALID_PROP = 'ERROR_INVALID_PROP';\nconst ERROR_LEGACY = 'ERROR_LEGACY';\nconst ERROR_UNIT = 'ERROR_UNIT';\nconst ERROR_VALUE = 'ERROR_VALUE';\n\nexport interface RuleValidDimension {\n /**\n * Allow the use of unknown \"unit\" values\n * @default false\n */\n legacyFormat?: boolean;\n /**\n * Allow the use of unknown \"unit\" values\n * @default false\n */\n unknownUnits?: boolean;\n}\n\nconst rule: LintRule<\n typeof ERROR_FORMAT | typeof ERROR_LEGACY | typeof ERROR_UNIT | typeof ERROR_VALUE | typeof ERROR_INVALID_PROP,\n RuleValidDimension\n> = {\n meta: {\n messages: {\n [ERROR_FORMAT]: 'Migrate to the new object format: { \"value\": 2, \"unit\": \"ms\" }.',\n [ERROR_LEGACY]: 'Migrate to the new object format: { \"value\": 10, \"unit\": \"px\" }.',\n [ERROR_INVALID_PROP]: 'Unknown property: {{ key }}.',\n [ERROR_UNIT]: 'Unknown unit {{ unit }}. Expected \"ms\" or \"s\".',\n [ERROR_VALUE]: 'Expected number, received {{ value }}.',\n },\n docs: {\n description: 'Require duration tokens to follow the format',\n url: docsLink(VALID_DURATION),\n },\n },\n defaultOptions: {\n legacyFormat: false,\n unknownUnits: false,\n },\n create({ tokens, options, report }) {\n for (const t of Object.values(tokens)) {\n if (t.aliasOf || !t.originalValue) {\n continue;\n }\n\n switch (t.$type) {\n case 'duration': {\n validateDuration(t.originalValue.$value, {\n node: getObjMember(t.source.node, '$value')!,\n filename: t.source.filename,\n });\n break;\n }\n case 'transition': {\n if (typeof t.originalValue.$value === 'object') {\n const $valueNode = getObjMember(t.source.node, '$value');\n for (const property of ['duration', 'delay'] as const) {\n if (t.originalValue.$value[property] && !isAlias(t.originalValue.$value[property] as string)) {\n validateDuration(t.originalValue.$value[property], {\n node: getObjMember($valueNode as momoa.ObjectNode, property)!,\n filename: t.source.filename,\n });\n }\n }\n }\n break;\n }\n }\n\n function validateDuration(value: unknown, { node, filename }: { node: momoa.AnyNode; filename?: string }) {\n if (value && typeof value === 'object') {\n for (const key of Object.keys(value)) {\n if (!['value', 'unit'].includes(key)) {\n report({\n messageId: ERROR_INVALID_PROP,\n data: { key: JSON.stringify(key) },\n node: getObjMember(node as momoa.ObjectNode, key) ?? node,\n filename,\n });\n }\n }\n\n const { unit, value: numValue } = value as Record<string, any>;\n if (!('value' in value || 'unit' in value)) {\n report({ messageId: ERROR_FORMAT, data: { value }, node, filename });\n return;\n }\n if (!options.unknownUnits && !['ms', 's'].includes(unit)) {\n report({\n messageId: ERROR_UNIT,\n data: { unit },\n node: getObjMember(node as momoa.ObjectNode, 'unit') ?? node,\n filename,\n });\n }\n if (!Number.isFinite(numValue)) {\n report({\n messageId: ERROR_VALUE,\n data: { value },\n node: getObjMember(node as momoa.ObjectNode, 'value') ?? node,\n filename,\n });\n }\n } else if (typeof value === 'string' && !options.legacyFormat) {\n report({ messageId: ERROR_FORMAT, node, filename });\n } else {\n report({ messageId: ERROR_FORMAT, data: { value }, node, filename });\n }\n }\n }\n },\n};\n\nexport default rule;\n","// Terrazzo internal plugin that powers lint rules. Always enabled.\nimport type { LintRuleLonghand, Plugin } from '../../types.js';\n\nexport * from './rules/a11y-min-contrast.js';\nexport * from './rules/a11y-min-font-size.js';\nexport * from './rules/colorspace.js';\nexport * from './rules/consistent-naming.js';\nexport * from './rules/descriptions.js';\nexport * from './rules/duplicate-values.js';\nexport * from './rules/max-gamut.js';\nexport * from './rules/required-children.js';\nexport * from './rules/required-modes.js';\nexport * from './rules/required-type.js';\nexport * from './rules/required-typography-properties.js';\nexport * from './rules/valid-font-family.js';\nexport * from './rules/valid-font-weight.js';\nexport * from './rules/valid-gradient.js';\nexport * from './rules/valid-link.js';\nexport * from './rules/valid-number.js';\nexport * from './rules/valid-shadow.js';\nexport * from './rules/valid-string.js';\nexport * from './rules/valid-stroke-style.js';\nexport * from './rules/valid-transition.js';\nexport * from './rules/valid-typography.js';\n\nimport a11yMinContrast, { A11Y_MIN_CONTRAST } from './rules/a11y-min-contrast.js';\nimport a11yMinFontSize, { A11Y_MIN_FONT_SIZE } from './rules/a11y-min-font-size.js';\nimport colorspace, { COLORSPACE } from './rules/colorspace.js';\nimport consistentNaming, { CONSISTENT_NAMING } from './rules/consistent-naming.js';\nimport descriptions, { DESCRIPTIONS } from './rules/descriptions.js';\nimport duplicateValues, { DUPLICATE_VALUES } from './rules/duplicate-values.js';\nimport maxGamut, { MAX_GAMUT } from './rules/max-gamut.js';\nimport requiredChildren, { REQUIRED_CHILDREN } from './rules/required-children.js';\nimport requiredModes, { REQUIRED_MODES } from './rules/required-modes.js';\nimport requiredType, { REQUIRED_TYPE } from './rules/required-type.js';\nimport requiredTypographyProperties, {\n REQUIRED_TYPOGRAPHY_PROPERTIES,\n} from './rules/required-typography-properties.js';\nimport validBoolean, { VALID_BOOLEAN } from './rules/valid-boolean.js';\nimport validBorder, { VALID_BORDER } from './rules/valid-border.js';\nimport validColor, { VALID_COLOR } from './rules/valid-color.js';\nimport validCubicBezier, { VALID_CUBIC_BEZIER } from './rules/valid-cubic-bezier.js';\nimport validDimension, { VALID_DIMENSION } from './rules/valid-dimension.js';\nimport validDuration, { VALID_DURATION } from './rules/valid-duration.js';\nimport validFontFamily, { VALID_FONT_FAMILY } from './rules/valid-font-family.js';\nimport validFontWeight, { VALID_FONT_WEIGHT } from './rules/valid-font-weight.js';\nimport validGradient, { VALID_GRADIENT } from './rules/valid-gradient.js';\nimport validLink, { VALID_LINK } from './rules/valid-link.js';\nimport validNumber, { VALID_NUMBER } from './rules/valid-number.js';\nimport validShadow, { VALID_SHADOW } from './rules/valid-shadow.js';\nimport validString, { VALID_STRING } from './rules/valid-string.js';\nimport validStrokeStyle, { VALID_STROKE_STYLE } from './rules/valid-stroke-style.js';\nimport validTransition, { VALID_TRANSITION } from './rules/valid-transition.js';\nimport validTypography, { VALID_TYPOGRAPHY } from './rules/valid-typography.js';\n\nconst ALL_RULES = {\n [VALID_COLOR]: validColor,\n [VALID_DIMENSION]: validDimension,\n [VALID_FONT_FAMILY]: validFontFamily,\n [VALID_FONT_WEIGHT]: validFontWeight,\n [VALID_DURATION]: validDuration,\n [VALID_CUBIC_BEZIER]: validCubicBezier,\n [VALID_NUMBER]: validNumber,\n [VALID_LINK]: validLink,\n [VALID_BOOLEAN]: validBoolean,\n [VALID_STRING]: validString,\n [VALID_STROKE_STYLE]: validStrokeStyle,\n [VALID_BORDER]: validBorder,\n [VALID_TRANSITION]: validTransition,\n [VALID_SHADOW]: validShadow,\n [VALID_GRADIENT]: validGradient,\n [VALID_TYPOGRAPHY]: validTypography,\n [COLORSPACE]: colorspace,\n [CONSISTENT_NAMING]: consistentNaming,\n [DESCRIPTIONS]: descriptions,\n [DUPLICATE_VALUES]: duplicateValues,\n [MAX_GAMUT]: maxGamut,\n [REQUIRED_CHILDREN]: requiredChildren,\n [REQUIRED_MODES]: requiredModes,\n [REQUIRED_TYPE]: requiredType,\n [REQUIRED_TYPOGRAPHY_PROPERTIES]: requiredTypographyProperties,\n [A11Y_MIN_CONTRAST]: a11yMinContrast,\n [A11Y_MIN_FONT_SIZE]: a11yMinFontSize,\n};\n\nexport default function coreLintPlugin(): Plugin {\n return {\n name: '@terrazzo/plugin-lint-core',\n lint() {\n return ALL_RULES;\n },\n };\n}\n\nexport const RECOMMENDED_CONFIG: Record<string, LintRuleLonghand> = {\n [VALID_COLOR]: ['error', {}],\n [VALID_DIMENSION]: ['error', {}],\n [VALID_FONT_FAMILY]: ['error', {}],\n [VALID_FONT_WEIGHT]: ['error', {}],\n [VALID_DURATION]: ['error', {}],\n [VALID_CUBIC_BEZIER]: ['error', {}],\n [VALID_NUMBER]: ['error', {}],\n [VALID_LINK]: ['error', {}],\n [VALID_BOOLEAN]: ['error', {}],\n [VALID_STRING]: ['error', {}],\n [VALID_STROKE_STYLE]: ['error', {}],\n [VALID_BORDER]: ['error', {}],\n [VALID_TRANSITION]: ['error', {}],\n [VALID_SHADOW]: ['error', {}],\n [VALID_GRADIENT]: ['error', {}],\n [VALID_TYPOGRAPHY]: ['error', {}],\n [CONSISTENT_NAMING]: ['warn', { format: 'kebab-case' }],\n};\n","import { merge } from 'merge-anything';\nimport coreLintPlugin, { RECOMMENDED_CONFIG } from './lint/plugin-core/index.js';\nimport Logger from './logger.js';\nimport type { Config, ConfigInit, ConfigOptions, LintRuleSeverity } from './types.js';\n\nconst TRAILING_SLASH_RE = /\\/*$/;\n\n/**\n * Validate and normalize a config\n */\nexport default function defineConfig(\n rawConfig: Config,\n { logger = new Logger(), cwd }: ConfigOptions = {} as ConfigOptions,\n): ConfigInit {\n const configStart = performance.now();\n\n if (!cwd) {\n logger.error({ group: 'config', label: 'core', message: 'defineConfig() missing `cwd` for JS API' });\n }\n\n const config = merge({}, rawConfig) as unknown as ConfigInit;\n\n // 1. normalize and init\n normalizeTokens({ rawConfig, config, logger, cwd });\n normalizeOutDir({ config, cwd, logger });\n normalizePlugins({ config, logger });\n normalizeLint({ config, logger });\n normalizeIgnore({ config, logger });\n\n // 2. Start build by calling config()\n for (const plugin of config.plugins) {\n plugin.config?.({ ...config }, { logger });\n }\n\n // 3. finish\n logger.debug({\n group: 'parser',\n label: 'config',\n message: 'Finish config validation',\n timing: performance.now() - configStart,\n });\n return config;\n}\n\n/** Normalize config.tokens */\nfunction normalizeTokens({\n rawConfig,\n config,\n logger,\n cwd,\n}: {\n rawConfig: Config;\n config: ConfigInit;\n logger: Logger;\n cwd: URL;\n}) {\n if (rawConfig.tokens === undefined) {\n config.tokens = [\n // @ts-expect-error we’ll normalize in next step\n './tokens.json',\n ];\n } else if (typeof rawConfig.tokens === 'string') {\n config.tokens = [\n // @ts-expect-error we’ll normalize in next step\n rawConfig.tokens,\n ];\n } else if (Array.isArray(rawConfig.tokens)) {\n config.tokens = [];\n for (const file of rawConfig.tokens) {\n if (typeof file === 'string' || (file as URL) instanceof URL) {\n config.tokens.push(\n // @ts-expect-error we’ll normalize in next step\n file,\n );\n } else {\n logger.error({\n group: 'config',\n message: `tokens: Expected array of strings, encountered ${JSON.stringify(file)}`,\n });\n }\n }\n } else {\n logger.error({\n group: 'config',\n message: `tokens: Expected string or array of strings, received ${typeof rawConfig.tokens}`,\n });\n }\n for (let i = 0; i < config.tokens!.length; i++) {\n const filepath = config.tokens[i]!;\n if (filepath instanceof URL) {\n continue; // skip if already resolved\n }\n try {\n config.tokens[i] = new URL(filepath, cwd);\n } catch {\n logger.error({ group: 'config', label: 'tokens', message: `Invalid URL ${filepath}` });\n }\n }\n\n config.alphabetize = rawConfig.alphabetize ?? true;\n}\n\n/** Normalize config.outDir */\nfunction normalizeOutDir({ config, cwd, logger }: { config: ConfigInit; logger: Logger; cwd: URL }) {\n if (config.outDir instanceof URL) {\n // noop\n } else if (typeof config.outDir === 'undefined') {\n config.outDir = new URL('./tokens/', cwd);\n } else if (typeof config.outDir !== 'string') {\n logger.error({\n group: 'config',\n message: `outDir: Expected string, received ${JSON.stringify(config.outDir)}`,\n });\n } else {\n config.outDir = new URL(config.outDir, cwd);\n // always add trailing slash so URL treats it as a directory.\n // do AFTER it has been normalized to POSIX paths with `href` (don’t use Node internals here! This may run in the browser)\n config.outDir = new URL(config.outDir.href.replace(TRAILING_SLASH_RE, '/'));\n }\n}\n\n/** Normalize config.plugins */\nfunction normalizePlugins({ config, logger }: { config: ConfigInit; logger: Logger }) {\n if (typeof config.plugins === 'undefined') {\n config.plugins = [];\n }\n if (!Array.isArray(config.plugins)) {\n logger.error({\n group: 'config',\n message: `plugins: Expected array of plugins, received ${JSON.stringify(config.plugins)}`,\n });\n }\n config.plugins.push(coreLintPlugin());\n for (let n = 0; n < config.plugins.length; n++) {\n const plugin = config.plugins[n];\n if (typeof plugin !== 'object') {\n logger.error({\n group: 'config',\n message: `plugin#${n}: Expected output plugin, received ${JSON.stringify(plugin)}`,\n });\n } else if (!plugin.name) {\n logger.error({ group: 'config', label: `plugin[${n}]`, message: `Missing \"name\"` });\n }\n }\n // order plugins with \"enforce\"\n config.plugins.sort((a, b) => {\n if (a.enforce === 'pre' && b.enforce !== 'pre') {\n return -1;\n } else if (a.enforce === 'post' && b.enforce !== 'post') {\n return 1;\n }\n return 0;\n });\n}\n\nfunction normalizeLint({ config, logger }: { config: ConfigInit; logger: Logger }) {\n if (config.lint !== undefined) {\n if (config.lint === null || typeof config.lint !== 'object' || Array.isArray(config.lint)) {\n logger.error({ group: 'config', label: 'lint', message: 'Must be an object' });\n }\n if (!config.lint.build) {\n config.lint.build = { enabled: true };\n }\n if (config.lint.build.enabled !== undefined) {\n if (typeof config.lint.build.enabled !== 'boolean') {\n logger.error({\n group: 'config',\n message: `lint.build.enabled: Expected boolean, received ${JSON.stringify(config.lint.build)}`,\n });\n }\n } else {\n config.lint.build.enabled = true;\n }\n\n if (config.lint.rules === undefined) {\n config.lint.rules = { ...RECOMMENDED_CONFIG };\n } else {\n if (config.lint.rules === null || typeof config.lint.rules !== 'object' || Array.isArray(config.lint.rules)) {\n logger.error({\n group: 'config',\n message: `lint.rules: Expected object, received ${JSON.stringify(config.lint.rules)}`,\n });\n return;\n }\n\n const allRules = new Map<string, string>();\n for (const plugin of config.plugins) {\n if (typeof plugin.lint !== 'function') {\n continue;\n }\n const pluginRules = plugin.lint();\n if (!pluginRules || Array.isArray(pluginRules) || typeof pluginRules !== 'object') {\n logger.error({\n group: 'config',\n message: `${plugin.name}: Expected object for lint() received ${JSON.stringify(pluginRules)}`,\n });\n continue;\n }\n for (const rule of Object.keys(pluginRules)) {\n // Note: sometimes plugins will be loaded multiple times, in which case it’s expected\n // they’re register rules again for lint(). Only throw an error if plugin A and plugin B’s\n // rules conflict.\n if (allRules.get(rule) && allRules.get(rule) !== plugin.name) {\n logger.error({\n group: 'config',\n message: `${plugin.name}: Duplicate rule ${rule} already registered by plugin ${allRules.get(rule)}`,\n });\n }\n allRules.set(rule, plugin.name);\n }\n }\n\n for (const id of Object.keys(config.lint.rules)) {\n if (!allRules.has(id)) {\n logger.error({\n group: 'config',\n message: `lint.rules.${id}: Unknown rule. Is the plugin installed?`,\n });\n }\n\n const value = config.lint.rules[id];\n let severity: LintRuleSeverity = 'off';\n let options: any = {};\n if (typeof value === 'number' || typeof value === 'string') {\n severity = value;\n } else if (Array.isArray(value)) {\n severity = value[0] as LintRuleSeverity;\n options = value[1];\n } else if (value !== undefined) {\n logger.error({\n group: 'config',\n message: `lint.rules.${id}: Invalid syntax. Expected \\`string | number | Array\\`, received ${JSON.stringify(value)}}`,\n });\n }\n config.lint.rules[id] = [severity, options];\n if (typeof severity === 'number') {\n if (severity !== 0 && severity !== 1 && severity !== 2) {\n logger.error({\n group: 'config',\n message: `lint.rules.${id}: Invalid number ${severity}. Specify 0 (off), 1 (warn), or 2 (error).`,\n });\n }\n config.lint.rules[id]![0] = (['off', 'warn', 'error'] as const)[severity]!;\n } else if (typeof severity === 'string') {\n if (severity !== 'off' && severity !== 'warn' && severity !== 'error') {\n logger.error({\n group: 'config',\n message: `lint.rules.${id}: Invalid string ${JSON.stringify(severity)}. Specify \"off\", \"warn\", or \"error\".`,\n });\n }\n } else if (value !== null) {\n logger.error({\n group: 'config',\n message: `lint.rules.${id}: Expected string or number, received ${JSON.stringify(value)}`,\n });\n }\n }\n }\n } else {\n config.lint = {\n build: { enabled: true },\n rules: { ...RECOMMENDED_CONFIG },\n };\n }\n}\n\nfunction normalizeIgnore({ config, logger }: { config: ConfigInit; logger: Logger }) {\n if (!config.ignore) {\n config.ignore = {} as typeof config.ignore;\n }\n config.ignore.tokens ??= [];\n config.ignore.deprecated ??= false;\n if (!Array.isArray(config.ignore.tokens) || config.ignore.tokens.some((x) => typeof x !== 'string')) {\n logger.error({\n group: 'config',\n message: `ignore.tokens: Expected array of strings, received ${JSON.stringify(config.ignore.tokens)}`,\n });\n }\n if (typeof config.ignore.deprecated !== 'boolean') {\n logger.error({\n group: 'config',\n message: `ignore.deprecated: Expected boolean, received ${JSON.stringify(config.ignore.deprecated)}`,\n });\n }\n}\n\n/** Merge configs */\nexport function mergeConfigs(a: Config, b: Config): Config {\n return merge(a, b);\n}\n","import type { InputSourceWithDocument } from '@terrazzo/json-schema-tools';\nimport { pluralize, type TokenNormalizedSet } from '@terrazzo/token-tools';\nimport { merge } from 'merge-anything';\nimport type { LogEntry, default as Logger } from '../logger.js';\nimport type { ConfigInit } from '../types.js';\n\nexport { RECOMMENDED_CONFIG } from './plugin-core/index.js';\n\nexport interface LintRunnerOptions {\n tokens: TokenNormalizedSet;\n filename?: URL;\n config: ConfigInit;\n sources: InputSourceWithDocument[];\n logger: Logger;\n}\n\nexport default async function lintRunner({\n tokens,\n filename,\n config = {} as ConfigInit,\n sources,\n logger,\n}: LintRunnerOptions): Promise<void> {\n const { plugins = [], lint } = config;\n const sourceByFilename: Record<string, InputSourceWithDocument> = {};\n for (const source of sources) {\n sourceByFilename[source.filename!.href] = source;\n }\n const unusedLintRules = Object.keys(lint?.rules ?? {});\n\n const errors: LogEntry[] = [];\n const warnings: LogEntry[] = [];\n for (const plugin of plugins) {\n if (typeof plugin.lint === 'function') {\n const s = performance.now();\n\n const linter = plugin.lint();\n\n await Promise.all(\n Object.entries(linter).map(async ([id, rule]) => {\n if (!(id in lint.rules) || lint.rules[id] === null) {\n return;\n }\n\n // tick off used rule\n const unusedLintRuleI = unusedLintRules.indexOf(id);\n if (unusedLintRuleI !== -1) {\n unusedLintRules.splice(unusedLintRuleI, 1);\n }\n\n const [severity, options] = lint.rules[id]!;\n\n if (severity === 'off') {\n return;\n }\n // note: this usually isn’t a Promise, but it _might_ be!\n await rule.create({\n id,\n report(descriptor) {\n let message = '';\n if (!descriptor.message && !descriptor.messageId) {\n logger.error({\n group: 'lint',\n label: `${plugin.name} › lint › ${id}`,\n message: 'Unable to report error: missing message or messageId',\n });\n }\n\n // handle message or messageId\n if (descriptor.message) {\n message = descriptor.message;\n } else {\n if (!(descriptor.messageId! in (rule.meta?.messages ?? {}))) {\n logger.error({\n group: 'lint',\n label: `${plugin.name} › lint › ${id}`,\n message: `messageId \"${descriptor.messageId}\" does not exist`,\n });\n }\n message = rule.meta?.messages?.[descriptor.messageId as keyof typeof rule.meta.messages] ?? '';\n }\n\n // replace with descriptor.data (if any)\n if (descriptor.data && typeof descriptor.data === 'object') {\n for (const [k, v] of Object.entries(descriptor.data)) {\n // lazy formatting\n const formatted = ['string', 'number', 'boolean'].includes(typeof v) ? String(v) : JSON.stringify(v);\n message = message.replace(/{{[^}]+}}/g, (inner) => {\n const key = inner.substring(2, inner.length - 2).trim();\n return key === k ? formatted : inner;\n });\n }\n }\n\n (severity === 'error' ? errors : warnings).push({\n group: 'lint',\n label: id,\n message,\n filename,\n node: descriptor.node,\n src: sourceByFilename[descriptor.filename!]?.src,\n });\n },\n tokens,\n filename,\n sources,\n options: merge(\n rule.meta?.defaultOptions ?? [],\n rule.defaultOptions ?? [], // Note: is this the correct order to merge in?\n options,\n ),\n });\n }),\n );\n\n logger.debug({\n group: 'lint',\n label: plugin.name,\n message: 'Finished',\n timing: performance.now() - s,\n });\n }\n }\n\n const errCount = errors.length ? `${errors.length} ${pluralize(errors.length, 'error', 'errors')}` : '';\n const warnCount = warnings.length ? `${warnings.length} ${pluralize(warnings.length, 'warning', 'warnings')}` : '';\n if (errors.length > 0) {\n logger.error(...errors, {\n group: 'lint',\n label: 'lint',\n message: [errCount, warnCount].filter(Boolean).join(', '),\n });\n }\n if (warnings.length > 0) {\n logger.warn(...warnings, { group: 'lint', label: 'lint', message: warnCount });\n }\n\n // warn user if they have unused lint rules (they might have meant to configure something!)\n for (const unusedRule of unusedLintRules) {\n logger.warn({ group: 'lint', label: 'lint', message: `Unknown lint rule \"${unusedRule}\"` });\n }\n}\n","import * as momoa from '@humanwhocodes/momoa';\n\n/** Momoa’s default parser, with preferred settings. */\nexport function toMomoa(srcRaw: any): momoa.DocumentNode {\n return momoa.parse(typeof srcRaw === 'string' ? srcRaw : JSON.stringify(srcRaw, undefined, 2), {\n mode: 'jsonc',\n ranges: true,\n tokens: true,\n });\n}\n","/**\n * If tokens are found inside a resolver, strip out the resolver paths (don’t\n * include \"sets\"/\"modifiers\" in the token ID etc.)\n */\nexport function filterResolverPaths(path: string[]): string[] {\n switch (path[0]) {\n case 'sets': {\n return path.slice(4);\n }\n case 'modifiers': {\n return path.slice(5);\n }\n case 'resolutionOrder': {\n switch (path[2]) {\n case 'sources': {\n return path.slice(4);\n }\n case 'contexts': {\n return path.slice(5);\n }\n }\n break;\n }\n }\n return path;\n}\n\n/** Make a deterministic string from an object */\nexport function getPermutationID(input: Record<string, string | undefined>): string {\n const keys = Object.keys(input).sort((a, b) => a.localeCompare(b, 'en-us', { numeric: true }));\n return JSON.stringify(Object.fromEntries(keys.map((k) => [k, input[k]])));\n}\n","import type * as momoa from '@humanwhocodes/momoa';\n\nimport type Logger from '../logger.js';\nimport type { LogEntry } from '../logger.js';\n\ninterface FatalLogEntry extends Omit<LogEntry, 'continueOnError'> {}\n\nexport function assert(value: unknown, logger: Logger, entry: FatalLogEntry): asserts value {\n if (!value) {\n logger.error(entry);\n }\n}\n\nexport function assertStringNode(\n value: momoa.AnyNode | undefined,\n logger: Logger,\n entry: FatalLogEntry,\n): asserts value is momoa.StringNode {\n assert(value?.type === 'String', logger, entry);\n}\n\nexport function assertObjectNode(\n value: momoa.AnyNode | undefined,\n logger: Logger,\n entry: FatalLogEntry,\n): asserts value is momoa.ObjectNode {\n assert(value?.type === 'Object', logger, entry);\n}\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember } from '@terrazzo/json-schema-tools';\nimport { FONT_WEIGHTS, isAlias, parseColor } from '@terrazzo/token-tools';\nimport type Logger from '../logger.js';\n\ninterface PreValidatedToken {\n id: string;\n $type: string;\n $value: unknown;\n mode: {\n '.': { $value: unknown; source: { node: any; filename: string | undefined } };\n [mode: string]: { $value: unknown; source: { node: any; filename: string | undefined } };\n };\n}\n\n/**\n * Normalize token value.\n * The reason for the “any” typing is this aligns various user-provided inputs to the type\n */\nexport function normalize(token: PreValidatedToken, { logger, src }: { logger: Logger; src: string }) {\n const entry = { group: 'parser' as const, label: 'init', src };\n\n function normalizeFontFamily(value: unknown): string[] {\n return typeof value === 'string' ? [value] : (value as string[]);\n }\n\n function normalizeFontWeight(value: unknown): number {\n return (typeof value === 'string' && FONT_WEIGHTS[value as keyof typeof FONT_WEIGHTS]) || (value as number);\n }\n\n function normalizeColor(value: unknown, node: momoa.AnyNode | undefined) {\n if (typeof value === 'string' && !isAlias(value)) {\n logger.warn({\n ...entry,\n node,\n message: `${token.id}: string colors will be deprecated in a future version. Please update to object notation`,\n });\n try {\n return parseColor(value);\n } catch {\n return { colorSpace: 'srgb', components: [0, 0, 0], alpha: 1 };\n }\n } else if (value && typeof value === 'object') {\n if ((value as any).alpha === undefined) {\n (value as any).alpha = 1;\n }\n }\n return value;\n }\n\n switch (token.$type) {\n case 'color': {\n for (const mode of Object.keys(token.mode)) {\n token.mode[mode]!.$value = normalizeColor(token.mode[mode]!.$value, token.mode[mode]!.source.node);\n }\n token.$value = token.mode['.'].$value;\n break;\n }\n\n case 'fontFamily': {\n for (const mode of Object.keys(token.mode)) {\n token.mode[mode]!.$value = normalizeFontFamily(token.mode[mode]!.$value);\n }\n token.$value = token.mode['.'].$value;\n break;\n }\n\n case 'fontWeight': {\n for (const mode of Object.keys(token.mode)) {\n token.mode[mode]!.$value = normalizeFontWeight(token.mode[mode]!.$value);\n }\n token.$value = token.mode['.'].$value;\n break;\n }\n\n case 'border': {\n for (const mode of Object.keys(token.mode)) {\n const border = token.mode[mode]!.$value as any;\n if (!border || typeof border !== 'object') {\n continue;\n }\n if (border.color) {\n border.color = normalizeColor(\n border.color,\n getObjMember(token.mode[mode]!.source.node as momoa.ObjectNode, 'color'),\n );\n }\n }\n token.$value = token.mode['.'].$value;\n break;\n }\n\n case 'shadow': {\n for (const mode of Object.keys(token.mode)) {\n // normalize to array\n if (!Array.isArray(token.mode[mode]!.$value)) {\n token.mode[mode]!.$value = [token.mode[mode]!.$value];\n }\n const $value = token.mode[mode]!.$value as any[];\n for (let i = 0; i < $value.length; i++) {\n const shadow = $value[i]!;\n if (!shadow || typeof shadow !== 'object') {\n continue;\n }\n const shadowNode = (\n token.mode[mode]!.source.node.type === 'Array'\n ? token.mode[mode]!.source.node.elements[i]!.value\n : token.mode[mode]!.source.node\n ) as momoa.ObjectNode;\n if (shadow.color) {\n shadow.color = normalizeColor(shadow.color, getObjMember(shadowNode, 'color'));\n }\n if (!('inset' in shadow)) {\n shadow.inset = false;\n }\n }\n }\n token.$value = token.mode['.'].$value;\n break;\n }\n\n case 'gradient': {\n for (const mode of Object.keys(token.mode)) {\n if (!Array.isArray(token.mode[mode]!.$value)) {\n continue;\n }\n const $value = token.mode[mode]!.$value as any[];\n for (let i = 0; i < $value.length; i++) {\n const stop = $value[i]!;\n if (!stop || typeof stop !== 'object') {\n continue;\n }\n const stopNode = (token.mode[mode]!.source.node as momoa.ArrayNode)?.elements?.[i]?.value as momoa.ObjectNode;\n if (stop.color) {\n stop.color = normalizeColor(stop.color, getObjMember(stopNode, 'color'));\n }\n }\n }\n token.$value = token.mode['.'].$value;\n break;\n }\n\n case 'typography': {\n for (const mode of Object.keys(token.mode)) {\n const $value = token.mode[mode]!.$value as any;\n if (typeof $value !== 'object') {\n return;\n }\n for (const [k, v] of Object.entries($value)) {\n switch (k) {\n case 'fontFamily': {\n $value[k] = normalizeFontFamily(v);\n break;\n }\n case 'fontWeight': {\n $value[k] = normalizeFontWeight(v);\n break;\n }\n }\n }\n }\n token.$value = token.mode['.'].$value;\n break;\n }\n }\n}\n","import * as momoa from '@humanwhocodes/momoa';\nimport { encodeFragment, getObjMember, type InputSourceWithDocument, parseRef } from '@terrazzo/json-schema-tools';\nimport {\n type GroupNormalized,\n getTokenMatcher,\n isAlias,\n parseAlias,\n type TokenNormalized,\n type TokenNormalizedSet,\n} from '@terrazzo/token-tools';\nimport type { default as Logger } from '../logger.js';\nimport type { Config, ReferenceObject, RefMap } from '../types.js';\n\n/** Convert valid DTCG alias to $ref */\nexport function aliasToGroupRef(alias: string): ReferenceObject | undefined {\n const id = parseAlias(alias);\n // if this is invalid, stop\n if (id === alias) {\n return;\n }\n return { $ref: `#/${id.replace(/~/g, '~0').replace(/\\//g, '~1').replace(/\\./g, '/')}` };\n}\n\n/** Convert valid DTCG alias to $ref */\nexport function aliasToTokenRef(alias: string, mode?: string): ReferenceObject | undefined {\n const id = parseAlias(alias);\n // if this is invalid, stop\n if (id === alias) {\n return;\n }\n return {\n $ref: `#/${id.replace(/~/g, '~0').replace(/\\//g, '~1').replace(/\\./g, '/')}${mode && mode !== '.' ? `/$extensions/mode/${mode}` : ''}/$value`,\n };\n}\n\nexport interface TokenFromNodeOptions {\n groups: Record<string, GroupNormalized>;\n path: string[];\n source: InputSourceWithDocument;\n ignore: Config['ignore'];\n}\n\n/** Generate a TokenNormalized from a Momoa node */\nexport function tokenFromNode(\n node: momoa.AnyNode,\n { groups, path, source, ignore }: TokenFromNodeOptions,\n): TokenNormalized | undefined {\n const isToken = node.type === 'Object' && !!getObjMember(node, '$value') && !path.includes('$extensions');\n if (!isToken) {\n return undefined;\n }\n\n const jsonID = encodeFragment(path);\n const id = path.join('.').replace(/\\.\\$root$/, '');\n\n const originalToken = momoa.evaluate(node) as any;\n\n const groupID = encodeFragment(path.slice(0, -1));\n const group = groups[groupID]!;\n if (group?.tokens && !group.tokens.includes(id)) {\n group.tokens.push(id);\n }\n\n const nodeSource = { filename: source.filename.href, node };\n const token: TokenNormalized = {\n id,\n $type: originalToken.$type || group.$type,\n $description: originalToken.$description || undefined,\n $deprecated: originalToken.$deprecated ?? group.$deprecated ?? undefined, // ⚠️ MUST use ?? here to inherit false correctly\n $value: originalToken.$value,\n $extensions: originalToken.$extensions || undefined,\n $extends: originalToken.$extends || undefined,\n aliasChain: undefined,\n aliasedBy: undefined,\n aliasOf: undefined,\n partialAliasOf: undefined,\n dependencies: undefined,\n group,\n originalValue: undefined, // undefined because we are not sure if the value has been modified or not\n source: nodeSource,\n jsonID,\n mode: {\n '.': {\n $value: originalToken.$value,\n aliasOf: undefined,\n aliasChain: undefined,\n partialAliasOf: undefined,\n aliasedBy: undefined,\n originalValue: undefined,\n dependencies: undefined,\n source: {\n ...nodeSource,\n node: (getObjMember(nodeSource.node, '$value') ?? nodeSource.node) as momoa.ObjectNode,\n },\n },\n },\n };\n\n // after assembling token, handle ignores to see if the final result should be ignored or not\n // filter out ignored\n if ((ignore?.deprecated && token.$deprecated) || (ignore?.tokens && getTokenMatcher(ignore.tokens)(token.id))) {\n return;\n }\n\n const $extensions = getObjMember(node, '$extensions');\n if ($extensions) {\n const modeNode = getObjMember($extensions as momoa.ObjectNode, 'mode') as momoa.ObjectNode;\n for (const mode of Object.keys((token.$extensions as any).mode ?? {})) {\n const modeValue = (token.$extensions as any).mode[mode];\n token.mode[mode] = {\n $value: modeValue,\n aliasOf: undefined,\n aliasChain: undefined,\n partialAliasOf: undefined,\n aliasedBy: undefined,\n originalValue: undefined,\n dependencies: undefined,\n source: {\n ...nodeSource,\n node: getObjMember(modeNode, mode) as any,\n },\n };\n }\n }\n return token;\n}\n\nexport interface TokenRawValues {\n jsonID: string;\n originalValue: any;\n source: TokenNormalized['source'];\n mode: Record<string, { originalValue: any; source: TokenNormalized['source'] }>;\n}\n\n/** Generate originalValue and source from node */\nexport function tokenRawValuesFromNode(\n node: momoa.AnyNode,\n { filename, path }: { filename: string; path: string[] },\n): TokenRawValues | undefined {\n const isToken = node.type === 'Object' && getObjMember(node, '$value') && !path.includes('$extensions');\n if (!isToken) {\n return undefined;\n }\n\n const jsonID = encodeFragment(path);\n const rawValues: TokenRawValues = {\n jsonID,\n originalValue: momoa.evaluate(node),\n source: { loc: filename, filename, node: node as momoa.ObjectNode },\n mode: {},\n };\n rawValues.mode['.'] = {\n originalValue: rawValues.originalValue.$value,\n source: { ...rawValues.source, node: getObjMember(node as momoa.ObjectNode, '$value') as momoa.ObjectNode },\n };\n const $extensions = getObjMember(node, '$extensions');\n if ($extensions) {\n const modes = getObjMember($extensions as momoa.ObjectNode, 'mode');\n if (modes) {\n for (const modeMember of (modes as momoa.ObjectNode).members) {\n const mode = (modeMember.name as momoa.StringNode).value;\n rawValues.mode[mode] = {\n originalValue: momoa.evaluate(modeMember.value),\n source: { loc: filename, filename, node: modeMember.value as momoa.ObjectNode },\n };\n }\n }\n }\n\n return rawValues;\n}\n\n/** Arbitrary keys that should be associated with a token group */\nconst GROUP_PROPERTIES = ['$deprecated', '$description', '$extensions', '$type'];\n\n/**\n * Generate a group from a node.\n * This method mutates the groups index as it goes because of group inheritance.\n * As it encounters new groups it may have to update other groups.\n */\nexport function groupFromNode(\n node: momoa.ObjectNode,\n { path, groups }: { path: string[]; groups: Record<string, GroupNormalized> },\n): GroupNormalized {\n const id = path.join('.');\n const jsonID = encodeFragment(path);\n\n // group\n if (!groups[jsonID]) {\n groups[jsonID] = {\n id,\n $deprecated: undefined,\n $description: undefined,\n $extensions: undefined,\n $type: undefined,\n tokens: [],\n };\n }\n\n // first, copy all parent groups’ properties into local, since they cascade\n const groupIDs = Object.keys(groups);\n groupIDs.sort(); // these may not be sorted; re-sort just in case (order determines final values)\n for (const groupID of groupIDs) {\n const isParentGroup = jsonID.startsWith(groupID) && groupID !== jsonID;\n if (isParentGroup) {\n groups[jsonID].$deprecated = groups[groupID]?.$deprecated ?? groups[jsonID].$deprecated;\n groups[jsonID].$description = groups[groupID]?.$description ?? groups[jsonID].$description;\n groups[jsonID].$type = groups[groupID]?.$type ?? groups[jsonID].$type;\n }\n }\n\n // next, override cascading values with local\n for (const m of node.members) {\n if (m.name.type !== 'String' || !GROUP_PROPERTIES.includes(m.name.value)) {\n continue;\n }\n (groups as any)[jsonID]![m.name.value] = momoa.evaluate(m.value);\n }\n\n return groups[jsonID]!;\n}\n\nexport interface GraphAliasesOptions {\n tokens: TokenNormalizedSet;\n sources: Record<string, InputSourceWithDocument>;\n logger: Logger;\n}\n\n/**\n * Link and reverse-link tokens in one pass.\n */\nexport function graphAliases(refMap: RefMap, { tokens, logger, sources }: GraphAliasesOptions) {\n // mini-helper that probably shouldn’t be used outside this function\n const getTokenRef = (ref: string) => ref.replace(/\\/(\\$value|\\$extensions)\\/?.*/, '');\n\n for (const [jsonID, { refChain }] of Object.entries(refMap)) {\n if (!refChain.length) {\n continue;\n }\n\n const mode = jsonID.match(/\\/\\$extensions\\/mode\\/([^/]+)/)?.[1] || '.';\n const rootRef = getTokenRef(jsonID);\n const modeValue = tokens[rootRef]?.mode[mode];\n if (!modeValue) {\n continue;\n }\n\n // aliasChain + dependencies\n if (!modeValue.dependencies) {\n modeValue.dependencies = [];\n }\n modeValue.dependencies.push(...refChain.filter((r) => !modeValue.dependencies!.includes(r)));\n modeValue.dependencies.sort((a, b) => a.localeCompare(b, 'en-us', { numeric: true }));\n\n // Top alias\n const isTopLevelAlias = jsonID.endsWith('/$value') || tokens[jsonID];\n if (isTopLevelAlias) {\n modeValue.aliasOf = refToTokenID(refChain.at(-1)!);\n const aliasChain = refChain.map(refToTokenID) as string[];\n modeValue.aliasChain = [...aliasChain];\n }\n\n // Partial alias\n const partial = jsonID\n .replace(/.*\\/\\$value\\/?/, '')\n .split('/')\n .filter(Boolean);\n if (partial.length && modeValue.$value && typeof modeValue.$value === 'object') {\n let node: any = modeValue.$value;\n let sourceNode = modeValue.source.node as momoa.AnyNode;\n if (!modeValue.partialAliasOf) {\n modeValue.partialAliasOf = Array.isArray(modeValue.$value) || tokens[rootRef]?.$type === 'shadow' ? [] : {};\n }\n let partialAliasOf = modeValue.partialAliasOf as any;\n // special case: for shadows, normalize object to array\n if (tokens[rootRef]?.$type === 'shadow' && !Array.isArray(node)) {\n if (Array.isArray(modeValue.partialAliasOf) && !modeValue.partialAliasOf.length) {\n modeValue.partialAliasOf.push({} as any);\n }\n partialAliasOf = (modeValue.partialAliasOf as any)[0]!;\n }\n\n for (let i = 0; i < partial.length; i++) {\n let key = partial[i] as string | number;\n if (String(Number(key)) === key) {\n key = Number(key);\n }\n if (key in node && typeof node[key] !== 'undefined') {\n node = node[key];\n if (sourceNode.type === 'Object') {\n sourceNode = getObjMember(sourceNode, key as string) ?? sourceNode;\n } else if (sourceNode.type === 'Array') {\n sourceNode = sourceNode.elements[key as number]?.value ?? sourceNode;\n }\n }\n // last node: apply partial alias\n if (i === partial.length - 1) {\n // important: we want to get only the immediate alias [0], not the final one [.length - 1].\n // if we resolve this too far, we could get incorrect values especially in plugin-css if a\n // user is applying cascades to the intermediate aliases but not the final one\n const aliasedID = getTokenRef(refChain[0]!);\n if (!(aliasedID in tokens)) {\n logger.error({\n group: 'parser',\n label: 'init',\n message: `Invalid alias: ${aliasedID}`,\n node: sourceNode,\n src: sources[tokens[rootRef]!.source.filename!]?.src,\n });\n break;\n }\n partialAliasOf[key] = refToTokenID(aliasedID);\n }\n // otherwise, create deeper structure and continue traversing\n if (!(key in partialAliasOf)) {\n partialAliasOf[key] = Array.isArray(node) ? [] : {};\n }\n partialAliasOf = partialAliasOf[key];\n }\n }\n\n // aliasedBy (reversed)\n const aliasedByRefs = [jsonID, ...refChain].reverse();\n for (let i = 0; i < aliasedByRefs.length; i++) {\n const baseRef = getTokenRef(aliasedByRefs[i]!);\n const baseToken = tokens[baseRef]?.mode[mode] || tokens[baseRef];\n if (!baseToken) {\n continue;\n }\n const upstream = aliasedByRefs.slice(i + 1);\n if (!upstream.length) {\n break;\n }\n if (!baseToken.aliasedBy) {\n baseToken.aliasedBy = [];\n }\n for (let j = 0; j < upstream.length; j++) {\n const downstream = refToTokenID(upstream[j]!)!;\n if (!baseToken.aliasedBy.includes(downstream)) {\n baseToken.aliasedBy.push(downstream);\n if (mode === '.') {\n tokens[baseRef]!.aliasedBy = baseToken.aliasedBy;\n }\n }\n }\n baseToken.aliasedBy.sort((a, b) => a.localeCompare(b, 'en-us', { numeric: true })); // sort, because the ordering is arbitrary and flaky\n }\n\n if (mode === '.') {\n tokens[rootRef]!.aliasChain = modeValue.aliasChain;\n tokens[rootRef]!.aliasedBy = modeValue.aliasedBy;\n tokens[rootRef]!.aliasOf = modeValue.aliasOf;\n tokens[rootRef]!.dependencies = modeValue.dependencies;\n tokens[rootRef]!.partialAliasOf = modeValue.partialAliasOf;\n }\n }\n}\n\n/** Convert valid DTCG alias to $ref Momoa Node */\nexport function aliasToMomoa(\n alias: string,\n loc: momoa.ObjectNode['loc'] = {\n start: { line: -1, column: -1, offset: 0 },\n end: { line: -1, column: -1, offset: 0 },\n },\n): momoa.ObjectNode | undefined {\n const $ref = aliasToTokenRef(alias);\n if (!$ref) {\n return;\n }\n return {\n type: 'Object',\n members: [\n {\n type: 'Member',\n name: { type: 'String', value: '$ref', loc },\n value: { type: 'String', value: $ref.$ref, loc },\n loc,\n },\n ],\n loc,\n };\n}\n\n/**\n * Convert Reference Object to token ID.\n * This can then be turned into an alias by surrounding with { … }\n * ⚠️ This is not mode-aware. This will flatten multiple modes into the same root token.\n */\nexport function refToTokenID($ref: ReferenceObject | string): string | undefined {\n const path = typeof $ref === 'object' ? $ref.$ref : $ref;\n if (typeof path !== 'string') {\n return;\n }\n const { subpath } = parseRef(path);\n // if this ID comes from #/$defs/…, strip the first 2 segments to get the global ID\n if (subpath?.[0] === '$defs') {\n subpath.splice(0, 2);\n }\n return (subpath?.length && subpath.join('.').replace(/\\.(\\$root|\\$value|\\$extensions).*$/, '')) || undefined;\n}\n\nconst EXPECTED_NESTED_ALIAS: Record<string, Record<string, string[]>> = {\n border: {\n color: ['color'],\n stroke: ['strokeStyle'],\n width: ['dimension'],\n },\n gradient: {\n color: ['color'],\n position: ['number'],\n },\n shadow: {\n color: ['color'],\n offsetX: ['dimension'],\n offsetY: ['dimension'],\n blur: ['dimension'],\n spread: ['dimension'],\n inset: ['boolean'],\n },\n strokeStyle: {\n dashArray: ['dimension'],\n },\n transition: {\n duration: ['duration'],\n delay: ['duration'],\n timingFunction: ['cubicBezier'],\n },\n typography: {\n fontFamily: ['fontFamily'],\n fontWeight: ['fontWeight'],\n fontSize: ['dimension'],\n lineHeight: ['dimension', 'number'],\n letterSpacing: ['dimension'],\n\n // CSS extensions (that aren’t \"string\")\n paragraphSpacing: ['dimension', 'string'],\n wordSpacing: ['dimension', 'string'],\n },\n};\n\n/**\n * Resolve DTCG aliases, $extends, and $ref\n */\nexport function resolveAliases(\n tokens: TokenNormalizedSet,\n { logger, refMap, sources }: { logger: Logger; refMap: RefMap; sources: Record<string, InputSourceWithDocument> },\n): void {\n for (const token of Object.values(tokens)) {\n const aliasEntry = {\n group: 'parser' as const,\n label: 'init',\n src: sources[token.source.filename!]?.src,\n node: getObjMember(token.source.node, '$value'),\n };\n\n for (const mode of Object.keys(token.mode)) {\n function resolveInner(alias: string, refChain: string[]): string {\n const nextRef = aliasToTokenRef(alias, mode)?.$ref;\n if (!nextRef) {\n logger.error({ ...aliasEntry, message: `Internal error resolving ${JSON.stringify(refChain)}` });\n throw new Error('Internal error');\n }\n if (refChain.includes(nextRef)) {\n logger.error({ ...aliasEntry, message: 'Circular alias detected.' });\n }\n const nextJSONID = nextRef.replace(/\\/(\\$value|\\$extensions).*/, '');\n const nextToken = tokens[nextJSONID]?.mode[mode] || tokens[nextJSONID]?.mode['.'];\n if (!nextToken) {\n logger.error({ ...aliasEntry, message: `Could not resolve alias ${alias}.` });\n }\n refChain.push(nextRef);\n if (isAlias(nextToken!.originalValue! as string)) {\n return resolveInner(nextToken!.originalValue! as string, refChain);\n }\n return nextJSONID;\n }\n\n function traverseAndResolve(\n value: any,\n { node, expectedTypes, path }: { node: momoa.AnyNode; expectedTypes?: string[]; path: (string | number)[] },\n ): any {\n if (typeof value !== 'string') {\n if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) {\n if (!value[i]) {\n continue;\n }\n value[i] = traverseAndResolve(value[i], {\n // biome-ignore lint/suspicious/noNonNullAssertedOptionalChain: we checked for this earlier\n node: (node as momoa.ArrayNode).elements?.[i]?.value!,\n // special case: cubicBezier\n expectedTypes: expectedTypes?.includes('cubicBezier') ? ['number'] : expectedTypes,\n path: [...path, i],\n }).$value;\n }\n } else if (typeof value === 'object') {\n for (const key of Object.keys(value)) {\n if (!expectedTypes?.length || !EXPECTED_NESTED_ALIAS[expectedTypes[0]!]) {\n continue;\n }\n value[key] = traverseAndResolve(value[key], {\n node: getObjMember(node as momoa.ObjectNode, key)!,\n expectedTypes: EXPECTED_NESTED_ALIAS[expectedTypes[0]!]![key],\n path: [...path, key],\n }).$value;\n }\n }\n return { $value: value };\n }\n\n if (!isAlias(value)) {\n if (!expectedTypes?.includes('string') && (value.includes('{') || value.includes('}'))) {\n logger.error({ ...aliasEntry, message: 'Invalid alias syntax.', node });\n }\n return { $value: value };\n }\n\n const refChain: string[] = [];\n const resolvedID = resolveInner(value, refChain);\n if (expectedTypes?.length && !expectedTypes.includes(tokens[resolvedID]!.$type)) {\n logger.error({\n ...aliasEntry,\n message: `Cannot alias to $type \"${tokens[resolvedID]!.$type}\" from $type \"${expectedTypes.join(' / ')}\".`,\n node,\n });\n }\n\n refMap[path.join('/')] = { filename: token.source.filename!, refChain };\n\n return {\n $type: tokens[resolvedID]!.$type,\n $value: tokens[resolvedID]!.mode[mode]?.$value || tokens[resolvedID]!.$value,\n };\n }\n\n // resolve DTCG aliases without\n const pathBase = mode === '.' ? token.jsonID : `${token.jsonID}/$extensions/mode/${mode}`;\n const { $type, $value } = traverseAndResolve(token.mode[mode]!.$value, {\n node: aliasEntry.node!,\n expectedTypes: token.$type ? [token.$type] : undefined,\n path: [pathBase, '$value'],\n });\n if (!token.$type) {\n (token as any).$type = $type;\n }\n if ($value) {\n token.mode[mode]!.$value = $value;\n }\n\n // fill in $type and $value\n if (mode === '.') {\n token.$value = token.mode[mode]!.$value;\n }\n }\n }\n}\n","import type * as momoa from '@humanwhocodes/momoa';\nimport {\n encodeFragment,\n findNode,\n getObjMember,\n type InputSourceWithDocument,\n mergeObjects,\n parseRef,\n replaceNode,\n traverse,\n} from '@terrazzo/json-schema-tools';\nimport { type GroupNormalized, isAlias, type TokenNormalizedSet } from '@terrazzo/token-tools';\nimport { filterResolverPaths } from '../lib/resolver-utils.js';\nimport type Logger from '../logger.js';\nimport type { ConfigInit, RefMap } from '../types.js';\nimport { assert, assertObjectNode, assertStringNode } from './assert.js';\nimport { normalize } from './normalize.js';\nimport {\n aliasToGroupRef,\n graphAliases,\n groupFromNode,\n refToTokenID,\n resolveAliases,\n tokenFromNode,\n tokenRawValuesFromNode,\n} from './token.js';\n\nexport interface ProcessTokensOptions {\n config: ConfigInit;\n logger: Logger;\n sourceByFilename: Record<string, InputSourceWithDocument>;\n sources: InputSourceWithDocument[];\n isResolver?: boolean;\n}\n\nexport function processTokens(\n rootSource: InputSourceWithDocument,\n { config, logger, sourceByFilename, isResolver }: ProcessTokensOptions,\n): TokenNormalizedSet {\n const entry = { group: 'parser' as const, label: 'init' };\n\n // 1. Inline $refs to discover any additional tokens\n const refMap: RefMap = {};\n function resolveRef(node: momoa.StringNode, chain: string[]): momoa.AnyNode {\n const { subpath } = parseRef(node.value);\n assert(subpath, logger, { ...entry, message: 'Can’t resolve $ref', node, src: rootSource.src });\n const next = findNode(rootSource.document, subpath);\n assert(next, logger, {\n ...entry,\n message: \"Can't find $ref\",\n node,\n src: rootSource.src,\n });\n if (next?.type === 'Object') {\n const next$ref = getObjMember(next, '$ref');\n if (next$ref && next$ref.type === 'String') {\n if (chain.includes(next$ref.value)) {\n logger.error({\n ...entry,\n message: `Circular $ref detected: ${JSON.stringify(next$ref.value)}`,\n node: next$ref,\n src: rootSource.src,\n });\n }\n chain.push(next$ref.value);\n return resolveRef(next$ref, chain);\n }\n }\n return next;\n }\n const inlineStart = performance.now();\n traverse(rootSource.document, {\n enter(node, _parent, rawPath) {\n if (rawPath.includes('$extensions') || node.type !== 'Object') {\n return;\n }\n const $ref = node.type === 'Object' ? getObjMember(node, '$ref') : undefined;\n if (!$ref) {\n return;\n }\n assertStringNode($ref, logger, {\n ...entry,\n message: 'Invalid $ref. Expected string.',\n node: $ref,\n src: rootSource.src,\n });\n const jsonID = encodeFragment(rawPath);\n refMap[jsonID] = { filename: rootSource.filename.href, refChain: [$ref.value] };\n const resolved = resolveRef($ref, refMap[jsonID]!.refChain);\n if (resolved.type === 'Object') {\n node.members.splice(\n node.members.findIndex((m) => m.name.type === 'String' && m.name.value === '$ref'),\n 1,\n );\n replaceNode(node, mergeObjects(resolved, node));\n } else {\n replaceNode(node, resolved);\n }\n },\n });\n logger.debug({ ...entry, message: 'Inline aliases', timing: performance.now() - inlineStart });\n\n // 2. Resolve $extends to discover any more additional tokens\n function flatten$extends(node: momoa.ObjectNode, chain: string[]) {\n const memberKeys = node.members.map((m) => m.name.type === 'String' && m.name.value).filter(Boolean) as string[];\n\n if (memberKeys.includes('$extends')) {\n const $extends = getObjMember(node, '$extends');\n assertStringNode($extends, logger, {\n ...entry,\n message: '$extends must be a string',\n node: $extends,\n src: rootSource.src,\n });\n\n if (memberKeys.includes('$value')) {\n logger.error({ ...entry, message: '$extends can’t exist within a token', node: $extends, src: rootSource.src });\n }\n const next = isAlias($extends.value) ? aliasToGroupRef($extends.value) : undefined;\n\n assert(next, logger, {\n ...entry,\n message: '$extends must be a valid alias',\n node: $extends,\n src: rootSource.src,\n });\n\n if (\n chain.includes(next.$ref) ||\n // Check that $extends is not importing from higher up (could go in either direction, which is why we check both ways)\n chain.some((value) => value.startsWith(next.$ref) || next.$ref.startsWith(value))\n ) {\n logger.error({ ...entry, message: 'Circular $extends detected', node: $extends, src: rootSource.src });\n }\n\n chain.push(next.$ref);\n const extended = findNode(rootSource.document, parseRef(next.$ref).subpath ?? []);\n assert(extended, logger, {\n ...entry,\n message: 'Could not resolve $extends',\n node: $extends,\n src: rootSource.src,\n });\n assertObjectNode(extended, logger, { ...entry, message: '$extends must resolve to a group of tokens', node });\n\n // To ensure this is resolvable, try and flatten this node first (will catch circular refs)\n flatten$extends(extended, chain);\n\n replaceNode(node, mergeObjects(extended, node));\n }\n\n // Deeply-traverse for any interior $extends (even if it wasn’t at the top level)\n for (const member of node.members) {\n if (\n member.value.type === 'Object' &&\n member.name.type === 'String' &&\n !['$value', '$extensions'].includes(member.name.value)\n ) {\n traverse(member.value, {\n enter(subnode, _parent) {\n if (subnode.type === 'Object') {\n flatten$extends(subnode, chain);\n }\n },\n });\n }\n }\n }\n\n const extendsStart = performance.now();\n const extendsChain: string[] = [];\n flatten$extends(rootSource.document.body as momoa.ObjectNode, extendsChain);\n logger.debug({ ...entry, message: 'Resolving $extends', timing: performance.now() - extendsStart });\n\n // 3. Parse discovered tokens\n const firstPass = performance.now();\n const tokens: TokenNormalizedSet = {};\n // micro-optimization: while we’re iterating over tokens, keeping a “hot”\n // array in memory saves recreating arrays from object keys over and over again.\n // it does produce a noticeable speedup > 1,000 tokens.\n const tokenIDs: string[] = [];\n const groups: Record<string, GroupNormalized> = {};\n\n // 3a. Token & group population\n traverse(rootSource.document, {\n enter(node, _parent, rawPath) {\n if (node.type !== 'Object') {\n return;\n }\n groupFromNode(node, { path: isResolver ? filterResolverPaths(rawPath) : rawPath, groups });\n const token = tokenFromNode(node, {\n groups,\n ignore: config.ignore,\n path: isResolver ? filterResolverPaths(rawPath) : rawPath,\n source: rootSource,\n });\n if (token) {\n tokenIDs.push(token.jsonID);\n tokens[token.jsonID] = token;\n }\n },\n });\n\n logger.debug({ ...entry, message: 'Parsing: 1st pass', timing: performance.now() - firstPass });\n const secondPass = performance.now();\n\n // 3b. Resolve originalValue and original sources\n for (const source of Object.values(sourceByFilename)) {\n traverse(source.document, {\n enter(node, _parent, path) {\n if (node.type !== 'Object') {\n return;\n }\n\n const tokenRawValues = tokenRawValuesFromNode(node, { filename: source.filename!.href, path });\n if (tokenRawValues && tokens[tokenRawValues?.jsonID]) {\n tokens[tokenRawValues.jsonID]!.originalValue = tokenRawValues.originalValue;\n tokens[tokenRawValues.jsonID]!.source = tokenRawValues.source;\n for (const mode of Object.keys(tokenRawValues.mode)) {\n tokens[tokenRawValues.jsonID]!.mode[mode]!.originalValue = tokenRawValues.mode[mode]!.originalValue;\n tokens[tokenRawValues.jsonID]!.mode[mode]!.source = tokenRawValues.mode[mode]!.source;\n }\n }\n },\n });\n }\n\n // 3c. DTCG alias resolution\n // Unlike $refs which can be resolved as we go, these can’t happen until the final, flattened set\n resolveAliases(tokens, { logger, sources: sourceByFilename, refMap });\n logger.debug({ ...entry, message: 'Parsing: 2nd pass', timing: performance.now() - secondPass });\n\n // 4. Alias graph\n // We’ve resolved aliases, but we need this pass for reverse linking i.e. “aliasedBy”\n const aliasStart = performance.now();\n graphAliases(refMap, { tokens, logger, sources: sourceByFilename });\n logger.debug({ ...entry, message: 'Alias graph built', timing: performance.now() - aliasStart });\n\n // 5. normalize\n // Allow for some minor variance in inputs, and be nice to folks.\n const normalizeStart = performance.now();\n for (const id of tokenIDs) {\n const token = tokens[id]!;\n normalize(token as any, { logger, src: sourceByFilename[token.source.filename!]?.src });\n }\n logger.debug({ ...entry, message: 'Normalized values', timing: performance.now() - normalizeStart });\n\n // 6. alphabetize & filter\n // This can’t happen until the last step, where we’re 100% sure we’ve resolved everything.\n if (config.alphabetize === false) {\n return tokens;\n }\n\n const sortStart = performance.now();\n const tokensSorted: TokenNormalizedSet = {};\n tokenIDs.sort((a, b) => a.localeCompare(b, 'en-us', { numeric: true }));\n for (const path of tokenIDs) {\n const id = refToTokenID(path)!;\n tokensSorted[id] = tokens[path]!;\n }\n // Sort group IDs once, too\n for (const group of Object.values(groups)) {\n group.tokens.sort((a, b) => a.localeCompare(b, 'en-us', { numeric: true }));\n }\n logger.debug({ ...entry, message: 'Sorted tokens', timing: performance.now() - sortStart });\n\n return tokensSorted;\n}\n","import * as momoa from '@humanwhocodes/momoa';\nimport { bundle, encodeFragment, parseRef, replaceNode } from '@terrazzo/json-schema-tools';\nimport type yamlToMomoa from 'yaml-to-momoa';\nimport type Logger from '../logger.js';\nimport type { Group, ReferenceObject, ResolverSourceNormalized } from '../types.js';\n\nexport interface NormalizeResolverOptions {\n logger: Logger;\n yamlToMomoa?: typeof yamlToMomoa;\n filename: URL;\n req: (url: URL, origin: URL) => Promise<string>;\n src?: any;\n}\n\n/** Normalize resolver (assuming it’s been validated) */\nexport async function normalizeResolver(\n document: momoa.DocumentNode,\n { logger, filename, req, src, yamlToMomoa }: NormalizeResolverOptions,\n): Promise<ResolverSourceNormalized> {\n // Important note: think about sets, modifiers, and resolutionOrder all\n // containing their own partial tokens documents. Now think about JSON $refs\n // inside those. Because we want to treat them all as one _eventual_ document,\n // we defer resolving $refs until the very last step. In most setups, this has\n // no effect on the final result, however, in the scenario where remote\n // documents are loaded and they conflict in unexpected ways, resolving too\n // early will produce incorrect results.\n //\n // To prevent this, we bundle ONCE at the very top level, with the `$defs` at\n // the top level now containing all partial documents (as opposed to bundling\n // every sub document individually). So all that said, we are deciding to\n // choose the “all-in-one“ method for closer support with DTCG aliases, but at\n // the expense of some edge cases of $refs behaving unexpectedly.\n const resolverBundle = await bundle([{ filename, src }], { req, yamlToMomoa });\n const resolverSource = momoa.evaluate(resolverBundle.document) as unknown as ResolverSourceNormalized;\n\n // Resolve $refs, but in a very different way than everywhere else These are\n // all _evaluated_, meaning initialized in JS memory. Unlike in the AST, when\n // we resolve these they’ll share memory points (which isn’t possible in the\n // AST—values must be duplicated). This code is unique because it’s the only\n // place where we’re dealing with shared, initialized JS memory.\n replaceNode(document, resolverBundle.document); // inject $defs into the root document\n for (const set of Object.values(resolverSource.sets ?? {})) {\n for (const source of set.sources) {\n resolvePartials(source, { resolver: resolverSource, logger });\n }\n }\n for (const modifier of Object.values(resolverSource.modifiers ?? {})) {\n for (const context of Object.values(modifier.contexts)) {\n for (const source of context) {\n resolvePartials(source, { resolver: resolverSource, logger });\n }\n }\n }\n for (const item of resolverSource.resolutionOrder ?? []) {\n resolvePartials(item, { resolver: resolverSource, logger });\n }\n\n return {\n name: resolverSource.name,\n version: resolverSource.version,\n description: resolverSource.description,\n sets: resolverSource.sets,\n modifiers: resolverSource.modifiers,\n resolutionOrder: resolverSource.resolutionOrder,\n _source: {\n filename,\n document,\n },\n };\n}\n\n/** Resolve $refs for already-initialized JS */\nfunction resolvePartials(\n source: Group | ReferenceObject,\n {\n resolver,\n logger,\n }: {\n resolver: any;\n logger: Logger;\n },\n) {\n if (!source) {\n return;\n }\n const entry = { group: 'parser' as const, label: 'resolver' };\n if (Array.isArray(source)) {\n for (const item of source) {\n resolvePartials(item, { resolver, logger });\n }\n } else if (typeof source === 'object') {\n for (const k of Object.keys(source)) {\n if (k === '$ref') {\n const $ref = (source as any)[k] as string;\n const { url, subpath = [] } = parseRef($ref);\n if (url !== '.' || !subpath.length) {\n logger.error({ ...entry, message: `Could not load $ref ${JSON.stringify($ref)}` });\n }\n const found = findObject(resolver, subpath ?? [], logger);\n if (subpath[0] === 'sets' || subpath[0] === 'modifiers') {\n found.type = subpath[0].replace(/s$/, '');\n found.name = subpath[1];\n }\n if (found) {\n for (const k2 of Object.keys(found)) {\n (source as any)[k2] = found[k2];\n }\n delete (source as any).$ref;\n } else {\n logger.error({ ...entry, message: `Could not find ${JSON.stringify($ref)}` });\n }\n } else {\n resolvePartials((source as any)[k], { resolver, logger });\n }\n }\n }\n}\n\nfunction findObject(dict: Record<string, any>, path: string[], logger: Logger): any {\n let node = dict;\n for (const idRaw of path) {\n const id = idRaw.replace(/~/g, '~0').replace(/\\//g, '~1');\n if (!(id in node)) {\n logger.error({\n group: 'parser',\n label: 'resolver',\n message: `Could not load $ref ${encodeFragment(path)}`,\n });\n }\n node = node[id];\n }\n return node;\n}\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { getObjMember, getObjMembers } from '@terrazzo/json-schema-tools';\nimport type { LogEntry, default as Logger } from '../logger.js';\n\n/**\n * Determine whether this is likely a resolver\n * We use terms the word “likely” because this occurs before validation. Since\n * we may be dealing with a doc _intended_ to be a resolver, but may be lacking\n * some critical information, how can we determine intent? There’s a bit of\n * guesswork here, but we try and find a reasonable edge case where we sniff out\n * invalid DTCG syntax that a resolver doc would have.\n */\nexport function isLikelyResolver(doc: momoa.DocumentNode): boolean {\n if (doc.body.type !== 'Object') {\n return false;\n }\n // This is a resolver if…\n for (const member of doc.body.members) {\n if (member.name.type !== 'String') {\n continue;\n }\n switch (member.name.value) {\n case 'name':\n case 'description':\n case 'version': {\n // 1. name, description, or version are a string\n if (member.value.type === 'String') {\n return true;\n }\n break;\n }\n case 'sets':\n case 'modifiers': {\n if (member.value.type !== 'Object') {\n continue;\n }\n // 2. sets.description or modifiers.description is a string\n if (getObjMember(member.value, 'description')?.type === 'String') {\n return true;\n }\n // 3. sets.sources is an array\n if (member.name.value === 'sets' && getObjMember(member.value, 'sources')?.type === 'Array') {\n return true;\n } else if (member.name.value === 'modifiers') {\n const contexts = getObjMember(member.value, 'contexts');\n if (contexts?.type === 'Object' && contexts.members.some((m) => m.value.type === 'Array')) {\n // 4. contexts[key] is an array\n // (note: modifiers.contexts as an object is technically valid token format! We need to check for the array)\n return true;\n }\n }\n break;\n }\n case 'resolutionOrder': {\n // 4. resolutionOrder is an array\n if (member.value.type === 'Array') {\n return true;\n }\n break;\n }\n }\n }\n\n return false;\n}\n\nexport interface ValidateResolverOptions {\n logger: Logger;\n src: string;\n}\n\nconst MESSAGE_EXPECTED = {\n STRING: 'Expected string.',\n OBJECT: 'Expected object.',\n ARRAY: 'Expected array.',\n};\n\n/**\n * Validate a resolver document.\n * There’s a ton of boilerplate here, only to surface detailed code frames. Is there a better abstraction?\n */\nexport function validateResolver(node: momoa.DocumentNode, { logger, src }: ValidateResolverOptions) {\n const entry = { group: 'parser', label: 'resolver', src } as const;\n if (node.body.type !== 'Object') {\n logger.error({ ...entry, message: MESSAGE_EXPECTED.OBJECT, node });\n }\n const errors: LogEntry[] = [];\n\n let hasVersion = false;\n let hasResolutionOrder = false;\n\n for (const member of (node.body as momoa.ObjectNode).members) {\n if (member.name.type !== 'String') {\n continue; // IDK, don’t ask\n }\n\n switch (member.name.value) {\n case 'name':\n case 'description': {\n if (member.value.type !== 'String') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.STRING });\n }\n break;\n }\n\n case 'version': {\n hasVersion = true;\n if (member.value.type !== 'String' || member.value.value !== '2025.10') {\n errors.push({ ...entry, message: `Expected \"version\" to be \"2025.10\".`, node: member.value });\n }\n break;\n }\n\n case 'sets':\n case 'modifiers': {\n if (member.value.type !== 'Object') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.OBJECT, node: member.value });\n } else {\n for (const item of member.value.members) {\n if (item.value.type !== 'Object') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.OBJECT, node: item.value });\n } else {\n const validator = member.name.value === 'sets' ? validateSet : validateModifier;\n errors.push(...validator(item.value, false, { logger, src }));\n }\n }\n }\n break;\n }\n\n case 'resolutionOrder': {\n hasResolutionOrder = true;\n if (member.value.type !== 'Array') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.ARRAY, node: member.value });\n } else if (member.value.elements.length === 0) {\n errors.push({ ...entry, message: `\"resolutionOrder\" can’t be empty array.`, node: member.value });\n } else {\n for (const item of member.value.elements) {\n if (item.value.type !== 'Object') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.OBJECT, node: item.value });\n } else {\n const itemMembers = getObjMembers(item.value);\n if (itemMembers.$ref?.type === 'String') {\n continue; // we can’t validate this just yet, assume it’s correct\n }\n // Validate \"type\"\n if (itemMembers.type?.type === 'String') {\n if (itemMembers.type.value === 'set') {\n validateSet(item.value, true, { logger, src });\n } else if (itemMembers.type.value === 'modifier') {\n validateModifier(item.value, true, { logger, src });\n } else {\n errors.push({\n ...entry,\n message: `Unknown type ${JSON.stringify(itemMembers.type.value)}`,\n node: itemMembers.type,\n });\n }\n }\n // validate sets & modifiers if they’re missing \"type\"\n if (itemMembers.sources?.type === 'Array') {\n validateSet(item.value, true, { logger, src });\n } else if (itemMembers.contexts?.type === 'Object') {\n validateModifier(item.value, true, { logger, src });\n } else if (itemMembers.name?.type === 'String' || itemMembers.description?.type === 'String') {\n validateSet(item.value, true, { logger, src }); // if this has a \"name\" or \"description\", guess set\n }\n }\n }\n }\n break;\n }\n case '$defs':\n case '$extensions':\n if (member.value.type !== 'Object') {\n errors.push({ ...entry, message: `Expected object`, node: member.value });\n }\n break;\n case '$schema':\n case '$ref': {\n if (member.value.type !== 'String') {\n errors.push({ ...entry, message: `Expected string`, node: member.value });\n }\n break;\n }\n default: {\n errors.push({ ...entry, message: `Unknown key ${JSON.stringify(member.name.value)}`, node: member.name, src });\n break;\n }\n }\n }\n\n // handle required keys\n if (!hasVersion) {\n errors.push({ ...entry, message: `Missing \"version\".`, node, src });\n }\n if (!hasResolutionOrder) {\n errors.push({ ...entry, message: `Missing \"resolutionOrder\".`, node, src });\n }\n\n if (errors.length) {\n logger.error(...errors);\n }\n}\n\nexport function validateSet(node: momoa.ObjectNode, isInline = false, { src }: ValidateResolverOptions): LogEntry[] {\n const entry = { group: 'parser', label: 'resolver', src } as const;\n const errors: LogEntry[] = [];\n let hasName = !isInline;\n let hasType = !isInline;\n let hasSources = false;\n for (const member of node.members) {\n if (member.name.type !== 'String') {\n continue;\n }\n switch (member.name.value) {\n case 'name': {\n hasName = true;\n if (member.value.type !== 'String') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.STRING, node: member.value });\n }\n break;\n }\n case 'description': {\n if (member.value.type !== 'String') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.STRING, node: member.value });\n }\n break;\n }\n case 'type': {\n hasType = true;\n if (member.value.type !== 'String') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.STRING, node: member.value });\n } else if (member.value.value !== 'set') {\n errors.push({ ...entry, message: '\"type\" must be \"set\".' });\n }\n break;\n }\n case 'sources': {\n hasSources = true;\n if (member.value.type !== 'Array') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.ARRAY, node: member.value });\n } else if (member.value.elements.length === 0) {\n errors.push({ ...entry, message: `\"sources\" can’t be empty array.`, node: member.value });\n } else {\n for (const source of member.value.elements) {\n if (source.value.type !== 'Object') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.OBJECT, node: source.value });\n }\n }\n }\n break;\n }\n case '$defs':\n case '$extensions':\n if (member.value.type !== 'Object') {\n errors.push({ ...entry, message: `Expected object`, node: member.value });\n }\n break;\n case '$ref': {\n if (member.value.type !== 'String') {\n errors.push({ ...entry, message: `Expected string`, node: member.value });\n }\n break;\n }\n default: {\n errors.push({ ...entry, message: `Unknown key ${JSON.stringify(member.name.value)}`, node: member.name });\n break;\n }\n }\n }\n\n // handle required keys\n if (!hasName) {\n errors.push({ ...entry, message: `Missing \"name\".`, node });\n }\n if (!hasType) {\n errors.push({ ...entry, message: `\"type\": \"set\" missing.`, node });\n }\n if (!hasSources) {\n errors.push({ ...entry, message: `Missing \"sources\".`, node });\n }\n\n return errors;\n}\n\nexport function validateModifier(\n node: momoa.ObjectNode,\n isInline = false,\n { src }: ValidateResolverOptions,\n): LogEntry[] {\n const errors: LogEntry[] = [];\n const entry = { group: 'parser', label: 'resolver', src } as const;\n let hasName = !isInline;\n let hasType = !isInline;\n let hasContexts = false;\n for (const member of node.members) {\n if (member.name.type !== 'String') {\n continue;\n }\n switch (member.name.value) {\n case 'name': {\n hasName = true;\n if (member.value.type !== 'String') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.STRING, node: member.value });\n }\n break;\n }\n case 'description': {\n if (member.value.type !== 'String') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.STRING, node: member.value });\n }\n break;\n }\n case 'type': {\n hasType = true;\n if (member.value.type !== 'String') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.STRING, node: member.value });\n } else if (member.value.value !== 'modifier') {\n errors.push({ ...entry, message: '\"type\" must be \"modifier\".' });\n }\n break;\n }\n case 'contexts': {\n hasContexts = true;\n if (member.value.type !== 'Object') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.OBJECT, node: member.value });\n } else if (member.value.members.length === 0) {\n errors.push({ ...entry, message: `\"contexts\" can’t be empty object.`, node: member.value });\n } else {\n for (const context of member.value.members) {\n if (context.value.type !== 'Array') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.ARRAY, node: context.value });\n } else {\n for (const source of context.value.elements) {\n if (source.value.type !== 'Object') {\n errors.push({ ...entry, message: MESSAGE_EXPECTED.OBJECT, node: source.value });\n }\n }\n }\n }\n }\n break;\n }\n case 'default': {\n if (member.value.type !== 'String') {\n errors.push({ ...entry, message: `Expected string`, node: member.value });\n } else {\n const contexts = getObjMember(node, 'contexts') as momoa.ObjectNode | undefined;\n if (!contexts || !getObjMember(contexts, member.value.value)) {\n errors.push({ ...entry, message: 'Invalid default context', node: member.value });\n }\n }\n break;\n }\n case '$defs':\n case '$extensions':\n if (member.value.type !== 'Object') {\n errors.push({ ...entry, message: `Expected object`, node: member.value });\n }\n break;\n case '$ref': {\n if (member.value.type !== 'String') {\n errors.push({ ...entry, message: `Expected string`, node: member.value });\n }\n break;\n }\n default: {\n errors.push({ ...entry, message: `Unknown key ${JSON.stringify(member.name.value)}`, node: member.name });\n break;\n }\n }\n }\n\n // handle required keys\n if (!hasName) {\n errors.push({ ...entry, message: `Missing \"name\".`, node });\n }\n if (!hasType) {\n errors.push({ ...entry, message: `\"type\": \"modifier\" missing.`, node });\n }\n if (!hasContexts) {\n errors.push({ ...entry, message: `Missing \"contexts\".`, node });\n }\n\n return errors;\n}\n","import type * as momoa from '@humanwhocodes/momoa';\nimport { type InputSource, type InputSourceWithDocument, maybeRawJSON } from '@terrazzo/json-schema-tools';\nimport type { TokenNormalizedSet } from '@terrazzo/token-tools';\nimport { merge } from 'merge-anything';\nimport type yamlToMomoa from 'yaml-to-momoa';\nimport { toMomoa } from '../lib/momoa.js';\nimport { getPermutationID } from '../lib/resolver-utils.js';\nimport type Logger from '../logger.js';\nimport { processTokens } from '../parse/process.js';\nimport type { ConfigInit, Resolver, ResolverSourceNormalized } from '../types.js';\nimport { normalizeResolver } from './normalize.js';\nimport { isLikelyResolver, validateResolver } from './validate.js';\n\nexport interface LoadResolverOptions {\n config: ConfigInit;\n logger: Logger;\n req: (url: URL, origin: URL) => Promise<string>;\n yamlToMomoa?: typeof yamlToMomoa;\n}\n\n/** Quick-parse input sources and find a resolver */\nexport async function loadResolver(\n inputs: InputSource[],\n { config, logger, req, yamlToMomoa }: LoadResolverOptions,\n): Promise<{ resolver: Resolver | undefined; tokens: TokenNormalizedSet; sources: InputSourceWithDocument[] }> {\n let resolverDoc: momoa.DocumentNode | undefined;\n let tokens: TokenNormalizedSet = {};\n const entry = {\n group: 'parser',\n label: 'init',\n } as const;\n\n for (const input of inputs) {\n let document: momoa.DocumentNode | undefined;\n if (typeof input.src === 'string') {\n if (maybeRawJSON(input.src)) {\n document = toMomoa(input.src);\n } else if (yamlToMomoa) {\n document = yamlToMomoa(input.src);\n } else {\n logger.error({\n ...entry,\n message: `Install yaml-to-momoa package to parse YAML, and pass in as option, e.g.:\n\n import { bundle } from '@terrazzo/json-schema-tools';\n import yamlToMomoa from 'yaml-to-momoa';\n\n bundle(yamlString, { yamlToMomoa });`,\n });\n }\n } else if (input.src && typeof input.src === 'object') {\n document = toMomoa(JSON.stringify(input.src, undefined, 2));\n } else {\n logger.error({ ...entry, message: `Could not parse ${input.filename}. Is this valid JSON or YAML?` });\n }\n if (!document || !isLikelyResolver(document)) {\n continue;\n }\n if (inputs.length > 1) {\n logger.error({ ...entry, message: `Resolver must be the only input, found ${inputs.length} sources.` });\n }\n resolverDoc = document;\n break;\n }\n\n let resolver: Resolver | undefined;\n if (resolverDoc) {\n validateResolver(resolverDoc, { logger, src: inputs[0]!.src });\n const normalized = await normalizeResolver(resolverDoc, {\n filename: inputs[0]!.filename!,\n logger,\n req,\n src: inputs[0]!.src,\n yamlToMomoa,\n });\n resolver = createResolver(normalized, { config, logger, sources: [{ ...inputs[0]!, document: resolverDoc }] });\n\n // If a resolver is present, load a single permutation to get a base token set.\n const firstInput: Record<string, string> = {};\n for (const m of resolver.source.resolutionOrder) {\n if (m.type !== 'modifier') {\n continue;\n }\n firstInput[m.name] = typeof m.default === 'string' ? m.default : Object.keys(m.contexts)[0]!;\n }\n tokens = resolver.apply(firstInput);\n }\n\n return {\n resolver,\n tokens,\n sources: [{ ...inputs[0]!, document: resolverDoc! }],\n };\n}\n\nexport interface CreateResolverOptions {\n config: ConfigInit;\n logger: Logger;\n sources: InputSourceWithDocument[];\n}\n\n/** Create an interface to resolve permutations */\nexport function createResolver(\n resolverSource: ResolverSourceNormalized,\n { config, logger, sources }: CreateResolverOptions,\n): Resolver {\n const inputDefaults: Record<string, string> = {};\n const validContexts: Record<string, string[]> = {};\n const allPermutations: Record<string, string>[] = [];\n\n const resolverCache: Record<string, any> = {};\n\n // Important: by iterating over resolutionOrder, we\n // filter out unused modifiers/irrelevant contexts.\n for (const m of resolverSource.resolutionOrder) {\n if (m.type === 'modifier') {\n if (typeof m.default === 'string') {\n inputDefaults[m.name] = m.default!;\n }\n validContexts[m.name] = Object.keys(m.contexts);\n }\n }\n\n return {\n apply(inputRaw) {\n let tokensRaw: TokenNormalizedSet = {};\n const input = { ...inputDefaults, ...inputRaw };\n const permutationID = getPermutationID(input);\n\n if (resolverCache[permutationID]) {\n return resolverCache[permutationID];\n }\n\n for (const item of resolverSource.resolutionOrder) {\n switch (item.type) {\n case 'set': {\n for (const s of item.sources) {\n tokensRaw = merge(tokensRaw, s) as TokenNormalizedSet;\n }\n break;\n }\n case 'modifier': {\n const context = input[item.name]!;\n const sources = item.contexts[context];\n if (!sources) {\n logger.error({\n group: 'resolver',\n message: `Modifier ${item.name} has no context ${JSON.stringify(context)}.`,\n });\n }\n for (const s of sources ?? []) {\n tokensRaw = merge(tokensRaw, s) as TokenNormalizedSet;\n }\n break;\n }\n }\n }\n\n const src = JSON.stringify(tokensRaw, undefined, 2);\n const rootSource = { filename: resolverSource._source.filename!, document: toMomoa(src), src };\n const tokens = processTokens(rootSource, {\n config,\n logger,\n sourceByFilename: { [resolverSource._source.filename!.href]: rootSource },\n isResolver: true,\n sources,\n });\n resolverCache[permutationID] = tokens;\n return tokens;\n },\n source: resolverSource,\n listPermutations() {\n // only do work on first call, then cache subsequent work. this could be thousands of possible values!\n if (!allPermutations.length) {\n allPermutations.push(...calculatePermutations(Object.entries(validContexts)));\n }\n return allPermutations;\n },\n isValidInput(input, throwError = false) {\n if (!input || typeof input !== 'object') {\n logger.error({ group: 'resolver', message: `Invalid input: ${JSON.stringify(input)}.` });\n }\n for (const k of Object.keys(input)) {\n if (!(k in validContexts)) {\n if (throwError) {\n logger.error({ group: 'resolver', message: `No such modifier ${JSON.stringify(k)}` });\n }\n return false; // 1. invalid if unknown modifier name\n }\n }\n for (const [name, contexts] of Object.entries(validContexts)) {\n // Note: empty strings are valid! Don’t check for truthiness.\n if (name in input) {\n if (!contexts.includes(input[name]!)) {\n if (throwError) {\n logger.error({\n group: 'resolver',\n message: `Modifier \"${name}\" has no context ${JSON.stringify(input[name])}.`,\n });\n }\n return false; // 2. invalid if unknown context\n }\n } else if (!(name in inputDefaults)) {\n if (throwError) {\n logger.error({\n group: 'resolver',\n message: `Modifier \"${name}\" missing value (no default set).`,\n });\n }\n return false; // 3. invalid if omitted, and no default\n }\n }\n return true;\n },\n getPermutationID(input) {\n this.isValidInput(input, true);\n return getPermutationID({ ...inputDefaults, ...input });\n },\n };\n}\n\n/** Calculate all permutations */\nexport function calculatePermutations(options: [string, string[]][]) {\n const permutationCount = [1];\n for (const [_name, contexts] of options) {\n permutationCount.push(contexts.length * (permutationCount.at(-1) || 1));\n }\n const permutations: Record<string, string>[] = [];\n for (let i = 0; i < permutationCount.at(-1)!; i++) {\n const input: Record<string, string> = {};\n for (let j = 0; j < options.length; j++) {\n const [name, contexts] = options[j]!;\n input[name] = contexts[Math.floor(i / permutationCount[j]!) % contexts.length]!;\n }\n permutations.push(input);\n }\n return permutations.length ? permutations : [{}];\n}\n","import * as momoa from '@humanwhocodes/momoa';\nimport type { InputSourceWithDocument } from '@terrazzo/json-schema-tools';\nimport type Logger from '../logger.js';\nimport type { ConfigInit, Group, Resolver, TokenNormalized, TokenNormalizedSet } from '../types.js';\nimport { createResolver } from './load.js';\nimport { normalizeResolver } from './normalize.js';\n\nexport interface CreateSyntheticResolverOptions {\n config: ConfigInit;\n logger: Logger;\n req: (url: URL, origin: URL) => Promise<string>;\n sources: InputSourceWithDocument[];\n}\n\n/**\n * Interop layer upgrading legacy Terrazzo modes to resolvers\n */\nexport async function createSyntheticResolver(\n tokens: TokenNormalizedSet,\n { config, logger, req, sources }: CreateSyntheticResolverOptions,\n): Promise<Resolver> {\n const contexts: Record<string, any[]> = {};\n for (const token of Object.values(tokens)) {\n for (const [mode, value] of Object.entries(token.mode)) {\n if (mode === '.') {\n continue;\n }\n if (!(mode in contexts)) {\n contexts[mode] = [{}];\n }\n addToken(contexts[mode]![0], { ...token, $value: value.$value }, { logger });\n }\n }\n\n const src = JSON.stringify(\n {\n name: 'Terrazzo',\n version: '2025.10',\n resolutionOrder: [{ $ref: '#/sets/allTokens' }, { $ref: '#/modifiers/tzMode' }],\n sets: {\n allTokens: { sources: [simpleFlatten(tokens, { logger })] },\n },\n modifiers: {\n tzMode: {\n description: 'Automatically built from $extensions.mode',\n contexts,\n },\n },\n },\n undefined,\n 2,\n );\n const normalized = await normalizeResolver(momoa.parse(src), {\n filename: new URL('file:///virtual:resolver.json'),\n logger,\n req,\n src,\n });\n return createResolver(normalized, { config, logger, sources });\n}\n\n/** Add a normalized token back into an arbitrary, hierarchial structure */\nfunction addToken(structure: any, token: TokenNormalized, { logger }: { logger: Logger }): void {\n let node = structure;\n const parts = token.id.split('.');\n const localID = parts.pop()!;\n for (const part of parts) {\n if (!(part in node)) {\n node[part] = {};\n }\n node = node[part];\n }\n if (localID in node) {\n logger.error({ group: 'parser', label: 'resolver', message: `${localID} already exists!` });\n }\n node[localID] = { $type: token.$type, $value: token.$value };\n}\n\n/** Downconvert normalized tokens back into a simplified, hierarchial shape. This is extremely lossy, and only done to build a resolver. */\nfunction simpleFlatten(tokens: TokenNormalizedSet, { logger }: { logger: Logger }): Group {\n const group: Group = {};\n for (const token of Object.values(tokens)) {\n addToken(group, token, { logger });\n }\n return group;\n}\n","import * as momoa from '@humanwhocodes/momoa';\nimport {\n type BundleOptions,\n bundle,\n encodeFragment,\n getObjMember,\n type InputSource,\n type InputSourceWithDocument,\n replaceNode,\n traverse,\n} from '@terrazzo/json-schema-tools';\nimport type { TokenNormalized, TokenNormalizedSet } from '@terrazzo/token-tools';\nimport { toMomoa } from '../lib/momoa.js';\nimport { filterResolverPaths } from '../lib/resolver-utils.js';\nimport type Logger from '../logger.js';\nimport { isLikelyResolver } from '../resolver/validate.js';\nimport type { ParseOptions, TransformVisitors } from '../types.js';\nimport { processTokens } from './process.js';\n\n/** Ephemeral format that only exists while parsing the document. This is not confirmed to be DTCG yet. */\nexport interface IntermediaryToken {\n id: string;\n /** Was this token aliasing another? */\n $ref?: string;\n $type?: string;\n $description?: string;\n $deprecated?: string | boolean;\n $value: unknown;\n $extensions?: Record<string, unknown>;\n group: TokenNormalized['group'];\n aliasOf?: string;\n partialAliasOf?: Record<string, any> | any[];\n mode: Record<\n string,\n {\n $type?: string;\n $value: unknown;\n aliasOf?: string;\n partialAliasOf?: Record<string, any> | any[];\n source?: { filename?: URL; node: momoa.ObjectNode };\n }\n >;\n source: {\n filename?: URL;\n node: momoa.ObjectNode;\n };\n}\n\nexport interface LoadOptions extends Pick<ParseOptions, 'config' | 'continueOnError' | 'yamlToMomoa' | 'transform'> {\n req: NonNullable<ParseOptions['req']>;\n logger: Logger;\n}\n\nexport interface LoadSourcesResult {\n tokens: TokenNormalizedSet;\n sources: InputSourceWithDocument[];\n}\n\n/** Load from multiple entries, while resolving remote files */\nexport async function loadSources(\n inputs: InputSource[],\n { config, logger, req, continueOnError, yamlToMomoa, transform }: LoadOptions,\n): Promise<LoadSourcesResult> {\n const entry = { group: 'parser' as const, label: 'init' };\n\n // 1. Bundle root documents together\n const firstLoad = performance.now();\n let document = {} as momoa.DocumentNode;\n\n /** The original user inputs, in original order, with parsed ASTs */\n const sources = inputs.map((input, i) => ({\n ...input,\n document: {} as momoa.DocumentNode,\n filename: input.filename || new URL(`virtual:${i}`), // for objects created in memory, an index-based ID helps associate tokens with these\n }));\n /** The sources array, indexed by filename */\n let sourceByFilename: Record<string, InputSourceWithDocument> = {};\n try {\n const result = await bundle(sources, {\n req,\n parse: transform ? transformer(transform) : undefined,\n yamlToMomoa,\n });\n document = result.document;\n sourceByFilename = result.sources;\n for (const [filename, source] of Object.entries(result.sources)) {\n const i = sources.findIndex((s) => s.filename.href === filename);\n if (i === -1) {\n sources.push(source);\n } else {\n sources[i]!.src = source.src; // this is a sanitized source that is easier to work with\n sources[i]!.document = source.document;\n }\n }\n } catch (err) {\n let src = sources.find((s) => s.filename.href === (err as any).filename)?.src;\n if (src && typeof src !== 'string') {\n src = JSON.stringify(src, undefined, 2);\n }\n logger.error({\n ...entry,\n continueOnError,\n message: (err as Error).message,\n node: (err as any).node,\n src,\n });\n }\n logger.debug({ ...entry, message: `JSON loaded`, timing: performance.now() - firstLoad });\n\n const rootSource = {\n filename: sources[0]!.filename!,\n document,\n src: momoa.print(document, { indent: 2 }).replace(/\\\\\\//g, '/'),\n };\n\n return {\n tokens: processTokens(rootSource, { config, logger, sources, sourceByFilename }),\n sources,\n };\n}\n\nfunction transformer(transform: TransformVisitors): BundleOptions['parse'] {\n return async (src, filename) => {\n let document = toMomoa(src);\n let lastPath = '#/';\n let last$type: string | undefined;\n\n if (transform.root) {\n const result = transform.root(document, { filename, parent: undefined, path: [] });\n if (result) {\n document = result as momoa.DocumentNode;\n }\n }\n\n const isResolver = isLikelyResolver(document);\n traverse(document, {\n enter(node, parent, rawPath) {\n const path = isResolver ? filterResolverPaths(rawPath) : rawPath;\n if (node.type !== 'Object' || !path.length) {\n return;\n }\n const ctx = { filename, parent, path };\n const next$type = getObjMember(node, '$type');\n if (next$type?.type === 'String') {\n const jsonPath = encodeFragment(path);\n if (jsonPath.startsWith(lastPath)) {\n last$type = next$type.value;\n }\n lastPath = jsonPath;\n }\n if (getObjMember(node, '$value')) {\n let result: any = transform.token?.(structuredClone(node), ctx);\n if (result) {\n replaceNode(node, result);\n result = undefined;\n }\n result = transform[last$type as keyof typeof transform]?.(structuredClone(node as any), ctx);\n if (result) {\n replaceNode(node, result);\n }\n } else if (!path.includes('$value')) {\n const result = transform.group?.(structuredClone(node), ctx);\n if (result) {\n replaceNode(node, result);\n }\n }\n },\n });\n\n return document;\n };\n}\n","import type fsType from 'node:fs/promises';\nimport type { InputSource, InputSourceWithDocument } from '@terrazzo/json-schema-tools';\nimport { pluralize, type TokenNormalizedSet } from '@terrazzo/token-tools';\nimport lintRunner from '../lint/index.js';\nimport Logger from '../logger.js';\nimport { createSyntheticResolver } from '../resolver/create-synthetic-resolver.js';\nimport { loadResolver } from '../resolver/load.js';\nimport type { ConfigInit, ParseOptions, Resolver } from '../types.js';\nimport { loadSources } from './load.js';\n\nexport interface ParseResult {\n tokens: TokenNormalizedSet;\n sources: InputSourceWithDocument[];\n resolver: Resolver;\n}\n\n/** Parse */\nexport default async function parse(\n _input: InputSource | InputSource[],\n {\n logger = new Logger(),\n req = defaultReq,\n skipLint = false,\n config = {} as ConfigInit,\n continueOnError = false,\n yamlToMomoa,\n transform,\n }: ParseOptions = {} as ParseOptions,\n): Promise<ParseResult> {\n const inputs = Array.isArray(_input) ? _input : [_input];\n let tokens: TokenNormalizedSet = {};\n let resolver: Resolver | undefined;\n let sources: InputSourceWithDocument[] = [];\n\n const totalStart = performance.now();\n\n // 1. Load tokens\n const initStart = performance.now();\n const resolverResult = await loadResolver(inputs, { config, logger, req, yamlToMomoa });\n // 1a. Resolver\n if (resolverResult.resolver) {\n tokens = resolverResult.tokens;\n sources = resolverResult.sources;\n resolver = resolverResult.resolver;\n } else {\n // 1b. No resolver\n const tokenResult = await loadSources(inputs, {\n req,\n logger,\n config,\n continueOnError,\n yamlToMomoa,\n transform,\n });\n tokens = tokenResult.tokens;\n sources = tokenResult.sources;\n }\n logger.debug({\n message: 'Loaded tokens',\n group: 'parser',\n label: 'core',\n timing: performance.now() - initStart,\n });\n\n if (skipLint !== true && config?.plugins?.length) {\n const lintStart = performance.now();\n await lintRunner({ tokens, sources, config, logger });\n logger.debug({\n message: 'Lint finished',\n group: 'plugin',\n label: 'lint',\n timing: performance.now() - lintStart,\n });\n }\n\n const resolverTiming = performance.now();\n const finalResolver = resolver || (await createSyntheticResolver(tokens, { config, logger, req, sources }));\n logger.debug({\n message: 'Resolver finalized',\n group: 'parser',\n label: 'core',\n timing: performance.now() - resolverTiming,\n });\n\n logger.debug({\n message: 'Finish all parser tasks',\n group: 'parser',\n label: 'core',\n timing: performance.now() - totalStart,\n });\n\n if (continueOnError) {\n const { errorCount } = logger.stats();\n if (errorCount > 0) {\n logger.error({\n group: 'parser',\n message: `Parser encountered ${errorCount} ${pluralize(errorCount, 'error', 'errors')}. Exiting.`,\n });\n }\n }\n\n return {\n tokens,\n sources,\n resolver: finalResolver,\n };\n}\n\nlet fs: typeof fsType | undefined;\n\n/** Fallback req */\nasync function defaultReq(src: URL, _origin: URL) {\n if (src.protocol === 'file:') {\n if (!fs) {\n fs = await import('node:fs/promises');\n }\n return await fs.readFile(src, 'utf8');\n }\n const res = await fetch(src);\n if (!res.ok) {\n throw new Error(`${src} responded with ${res.status}\\n${await res.text()}`);\n }\n return await res.text();\n}\n"],"mappings":";;;;;;;;;;;;;AA8DA,SAAS,eAAe,KAAmB,QAAkB,OAAgB,EAAE,EAAa;CAC1F,MAAM,WAAW;EAEf,QAAQ;EAER,MAAM;EACN,GAAG,IAAI;EACR;CACD,MAAM,SAAmB;EACvB,GAAG;EACH,GAAG,IAAI;EACR;CACD,MAAM,EAAE,aAAa,GAAG,aAAa,MAAM,QAAQ,EAAE;CACrD,MAAM,YAAY,SAAS;CAC3B,MAAM,cAAc,SAAS;CAC7B,MAAM,UAAU,OAAO;CACvB,MAAM,YAAY,OAAO;CAEzB,IAAI,QAAQ,KAAK,IAAI,aAAa,aAAa,IAAI,EAAE;CACrD,IAAI,MAAM,KAAK,IAAI,OAAO,QAAQ,UAAU,WAAW;AAEvD,KAAI,cAAc,GAChB,SAAQ;AAGV,KAAI,YAAY,GACd,OAAM,OAAO;CAGf,MAAM,WAAW,UAAU;CAC3B,MAAM,cAAmC,EAAE;AAE3C,KAAI,SACF,MAAK,IAAI,IAAI,GAAG,KAAK,UAAU,KAAK;EAClC,MAAM,aAAa,IAAI;AAEvB,MAAI,CAAC,YACH,aAAY,cAAc;WACjB,MAAM,EAGf,aAAY,cAAc,CAAC,aAFN,OAAO,aAAa,GAAI,SAEU,cAAc,EAAE;WAC9D,MAAM,SACf,aAAY,cAAc,CAAC,GAAG,UAAU;MAIxC,aAAY,cAAc,CAAC,GAFN,OAAO,aAAa,GAAI,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