diff --git a/.changeset/fix-token-references.md b/.changeset/fix-token-references.md new file mode 100644 index 0000000..84e1cc2 --- /dev/null +++ b/.changeset/fix-token-references.md @@ -0,0 +1,5 @@ +--- +"@hebilicious/cssforge": patch +--- + +Preserve comments when substituting CSS variable aliases. Resolve explicit token references in Style Dictionary exports by their configuration path, including when themes share a CSS variable name. diff --git a/packages/cssforge/oracles/aliases.oracle.test.ts b/packages/cssforge/oracles/aliases.oracle.test.ts new file mode 100644 index 0000000..a837a72 --- /dev/null +++ b/packages/cssforge/oracles/aliases.oracle.test.ts @@ -0,0 +1,129 @@ +/** + * This oracle owns CSS alias substitution through `generateCSS` at the generated + * declaration. It covers `src/lib.ts#resolveValue` and its reference parser. + * + * ```ts + * generateCSS(config) // → var(--spacing-size-base, 0) for the mapped gap + * ``` + * + * An alias name can also appear in a comment next to the reference. Only the + * name CSS reads as the argument should change. + * + * For every valid generated var() call with a mapped alias, the declaration + * substitutes its name and preserves the rest. The resolveValue JSDoc says + * “keeping any fallback and surrounding whitespace intact” and the comment + * test in tests/lib.test.ts says it “ignores comments and whitespace around + * the alias name.” + * + * The model renders the named argument separately from its surrounding text. + * The driver reads the generated custom-property value and the check compares + * the whole value. The grammar covers comments around a mapped name and + * unchanged external fallbacks. It leaves escaped identifiers, malformed CSS, + * and substitution outside this shape to separate properties. + */ + +import { differs, oracleProperty, pass } from "@tanstack/oracles"; +import fc from "fast-check"; +import { generateCSS } from "../src/mod.ts"; + +const law = "substitutes only the mapped argument"; +const checkpoint = "generated declaration"; +const source = "spacing.custom.size.base"; +const target = "--spacing-size-base"; + +const arbitrary = fc.record({ + alias: fc.constantFrom("a", "gap", "button-space"), + before: fc.constantFrom("", "plain", "alias", "(", ")", '"'), + after: fc.constantFrom("", " ", "/**/", " /**/"), + fallback: fc.constantFrom("", ", 0", ", var(--external, 0)"), +}); + +type History = ReturnType["value"]; + +function declarationValue(history: History, name: string) { + const comment = history.before === "alias" ? `--${history.alias}` : history.before; + const before = comment ? `/*${comment}*/ ` : ""; + return `var(${before}${name}${history.after}${history.fallback})`; +} + +oracleProperty({ + id: "css-alias-substitution", + owns: ["src/lib.ts#resolveValue"], + law: { + statement: + "For every valid generated var() call with a mapped alias, the declaration substitutes its name and preserves the rest.", + authority: "src/lib.ts resolveValue JSDoc and tests/lib.test.ts comment cases", + limits: "Generated comments and external fallbacks around one mapped argument.", + }, + histories: { + arbitrary, + runs: 100, + fixedSeeds: [47], + states: ["comment names alias", "comment contains delimiter", "comment touches name"], + constructed: [ + { + name: "alias in comment", + enters: ["comment names alias"], + build: (base): History => ({ ...base, before: "alias" }), + }, + { + name: "parenthesis in comment", + enters: ["comment contains delimiter"], + build: (base): History => ({ ...base, before: ")" }), + }, + { + name: "comment immediately after name", + enters: ["comment touches name"], + build: (base): History => ({ ...base, after: "/**/" }), + }, + ], + fixed: [ + { + name: "plain substitution with fallback", + history: { alias: "gap", before: "", after: "", fallback: ", 0" }, + }, + ], + }, + reached(history) { + const states = []; + if (history.before === "alias") states.push("comment names alias"); + if (["(", ")", '"'].includes(history.before)) + states.push("comment contains delimiter"); + if (history.after === "/**/") states.push("comment touches name"); + return states; + }, + model: (history) => declarationValue(history, target), + driver(history, observe) { + try { + const css = generateCSS({ + spacing: { custom: { size: { value: { base: "1rem" } } } }, + primitives: { + button: { + value: { + base: { + value: { gap: declarationValue(history, `--${history.alias}`) }, + variables: { [history.alias]: source }, + settings: { pxToRem: false }, + }, + }, + }, + }, + }); + observe(checkpoint, css.match(/^--button-base-gap: (.*);$/mu)?.[1]); + } catch (error) { + observe(checkpoint, error); + } + }, + check: (_history, trace, expected) => + differs(checkpoint, law, trace[0]?.value, expected) ?? pass, + calibrations: [ + { + name: "leaves a mapped name unchanged", + law, + history: { fixed: "plain substitution with fallback" }, + corrupt: (_trace, history) => [ + { checkpoint, value: declarationValue(history, `--${history.alias}`) }, + ], + }, + ], +}); diff --git a/packages/cssforge/oracles/collisions.oracle.test.ts b/packages/cssforge/oracles/collisions.oracle.test.ts new file mode 100644 index 0000000..4f910d1 --- /dev/null +++ b/packages/cssforge/oracles/collisions.oracle.test.ts @@ -0,0 +1,146 @@ +/** + * This oracle owns repeated generated CSS names across theme scopes. Both + * public generators accept scoped reuse and reject same-scope duplicates. + * It covers src/generator.ts#assertNoKeyCollisions and src/modules/colors.ts#describeScope. + * + * ```ts + * generateCSS(config) // → two --accent declarations for distinct theme scopes + * generateStyleDictionaryJSON(config) // → collision error when both land at :root + * ``` + * + * An explicit `:root` and an implicit root are the same scope, including + * under a common media rule. For every generated pair of themes sharing a + * custom-property name, both generators reject equal scopes and keep both + * declarations for distinct scopes. The collision contract in src/generator.ts + * states “Tokens that share a name but target different scopes are not a collision.” + * + * Each history specifies the effective CSS scope and how to spell it in the + * config. The model compares the scopes. The driver observes declarations or + * the collision diagnostic. Arbitrary selector equivalence is outside this grammar. + */ + +import { differs, oracleProperty, pass } from "@tanstack/oracles"; +import fc from "fast-check"; +import { generateCSS, generateStyleDictionaryJSON } from "../src/mod.ts"; + +const law = "rejects duplicate names exactly when scopes match"; +const checkpoint = "generator results"; +const scope = fc.record({ + selector: fc.constantFrom(":root", ".one", ".two"), + condition: fc.constantFrom("", "@media (width > 600px)", "@media (width < 400px)"), + explicitRoot: fc.boolean(), +}); +const arbitrary = fc.tuple(scope, scope); +type History = ReturnType["value"]; +type Scope = History[number]; + +const sameScope = ([left, right]: History) => + left.selector === right.selector && left.condition === right.condition; + +function theme(scope: Scope) { + const selector = + scope.selector === ":root" && !scope.explicitRoot ? undefined : scope.selector; + return { + value: { ink: { value: { accent: "red" }, settings: { variantNameOnly: true } } }, + settings: { selector, atRule: scope.condition || undefined }, + }; +} + +const collisionMessage = + 'Token key collision: "theme.left.ink.accent" and "theme.right.ink.accent" both generate "--accent". Rename one of the configuration paths.'; + +oracleProperty({ + id: "theme-name-collisions", + owns: ["src/generator.ts#assertNoKeyCollisions", "src/modules/colors.ts#describeScope"], + law: { + statement: + "For every generated pair of themes sharing a custom-property name, both generators reject equal scopes and keep both declarations for distinct scopes.", + authority: + "src/generator.ts assertNoKeyCollisions contract and tests/key-collision.test.ts", + limits: "Two variantNameOnly themes in root, class, and media-rule scopes.", + }, + histories: { + arbitrary, + runs: 100, + fixedSeeds: [47], + states: ["same scope", "distinct scopes", "explicit and implicit root"], + constructed: [ + { + name: "root spelled two ways", + enters: ["same scope", "explicit and implicit root"], + build: ([left]): History => [ + { ...left, selector: ":root", explicitRoot: true }, + { ...left, selector: ":root", explicitRoot: false }, + ], + }, + { + name: "two selectors in one condition", + enters: ["distinct scopes"], + build: ([left]): History => [ + { ...left, selector: ".one" }, + { ...left, selector: ".two" }, + ], + }, + ], + }, + reached(history) { + const [left, right] = history; + const states = [sameScope(history) ? "same scope" : "distinct scopes"]; + if ( + left.selector === ":root" && + right.selector === ":root" && + left.explicitRoot !== right.explicitRoot + ) { + states.push("explicit and implicit root"); + } + return states; + }, + model: (history) => + sameScope(history) + ? [collisionMessage, collisionMessage] + : [2, ["--accent", "--accent"]], + driver([left, right], observe) { + const config = { + colors: { + palette: { value: {} }, + theme: { left: theme(left), right: theme(right) }, + }, + }; + + const outputs = [ + () => generateCSS(config).match(/--accent:/gu)?.length, + () => { + const result: { + theme: Record< + string, + { ink: { accent: { attributes: { cssVariable: string } } } } + >; + } = JSON.parse(generateStyleDictionaryJSON(config)); + return ["left", "right"].map( + (name) => result.theme[name]?.ink.accent.attributes.cssVariable, + ); + }, + ]; + + observe( + checkpoint, + outputs.map((output) => { + try { + return output(); + } catch (error) { + return error instanceof Error ? error.message : String(error); + } + }), + ); + }, + check: (_history, trace, expected) => + differs(checkpoint, law, trace[0]?.value, expected) ?? pass, + calibrations: [ + { + name: "accepts two declarations in the same scope", + law, + history: { constructed: "root spelled two ways" }, + corrupt: () => [{ checkpoint, value: [2, ["--accent", "--accent"]] }], + }, + ], +}); diff --git a/packages/cssforge/oracles/reference-chains.oracle.test.ts b/packages/cssforge/oracles/reference-chains.oracle.test.ts new file mode 100644 index 0000000..66ea835 --- /dev/null +++ b/packages/cssforge/oracles/reference-chains.oracle.test.ts @@ -0,0 +1,109 @@ +/** + * This oracle owns Style Dictionary's resolved values for chains of CSS + * custom-property references. It checks the values returned by + * `generateStyleDictionaryJSON` and covers src/generator.ts#resolveTokenValue. + * + * ```ts + * generateStyleDictionaryJSON(config) // → 1rem for a chain ending in 1rem + * generateStyleDictionaryJSON(config) // → var(...) for a cycle or an external name + * ``` + * + * For every generated chain, all tokens resolve to the terminal literal or + * external reference. For every generated cycle, all tokens remain references + * to a member of that cycle. The README says resolved mode “recursively + * resolves references to other CSS Forge tokens” and that “Cycles and unknown + * CSS variables remain as var(...) instead of causing generation to fail.” + * + * A history specifies the chain length and the end directly. The model + * reads that end without following edges. The driver reads every token value. + * This grammar covers chains and simple cycles with one outgoing reference + * per token. It leaves compound values and CSS scope selection to other checks. + */ + +import { differs, oracleProperty, pass } from "@tanstack/oracles"; +import { generateStyleDictionaryJSON } from "../src/mod.ts"; + +const law = "resolves chains while preserving external references and cycles"; +const checkpoint = "resolved chain"; +const ends = ["literal", "external", "cycle"] as const; +const lengths = Array.from({ length: 8 }, (_, index) => index + 1); +const tokenName = (index: number) => `step-${index}`; +const reference = (index: number) => `var(--${tokenName(index)})`; +const terminalValue = { + literal: "1rem", + external: "var(--external)", + cycle: reference(0), +}; + +oracleProperty({ + id: "style-dictionary-reference-chains", + owns: ["src/generator.ts#resolveTokenValue"], + law: { + statement: + "For every generated chain, all tokens resolve to the terminal literal or external reference. For every generated cycle, all tokens remain references to a member of that cycle.", + authority: "README.md, Style Dictionary JSON, Choose the value mode", + limits: + "Chains and simple cycles of one to eight nodes with a single outgoing reference.", + }, + histories: { + enumerated: ends.flatMap((end) => lengths.map((length) => ({ length, end }))), + states: ends, + }, + label: ({ length, end }) => `${end} with ${length} tokens`, + reached: ({ end }) => [end], + model({ length, end }) { + return end === "cycle" + ? lengths.slice(0, length).map((index) => reference(index - 1)) + : [terminalValue[end]]; + }, + driver({ length, end }, observe) { + const names = lengths.slice(0, length).map((index) => tokenName(index - 1)); + const value = Object.fromEntries( + names.map((name, index) => [ + name, + index + 1 === length ? terminalValue[end] : reference(index + 1), + ]), + ); + + try { + const output: { theme: { base: { tokens: Record } } } = + JSON.parse( + generateStyleDictionaryJSON({ + colors: { + palette: { value: {} }, + theme: { + base: { + value: { tokens: { value, settings: { variantNameOnly: true } } }, + }, + }, + }, + }), + ); + observe( + checkpoint, + names.map((name) => output.theme.base.tokens[name]?.value), + ); + } catch (error) { + observe(checkpoint, error); + } + }, + check({ length }, trace, allowed) { + const observed = trace[0]?.value; + if ( + Array.isArray(observed) && + observed.length === length && + observed.every((value) => allowed.includes(value)) + ) { + return pass; + } + return differs(checkpoint, law, observed, { length, allowed }) ?? pass; + }, + calibrations: [ + { + name: "leaves a reference to a known literal unresolved", + law, + history: { enumerated: "literal with 2 tokens" }, + corrupt: () => [{ checkpoint, value: [reference(1), "1rem"] }], + }, + ], +}); diff --git a/packages/cssforge/oracles/scoped-references.oracle.test.ts b/packages/cssforge/oracles/scoped-references.oracle.test.ts new file mode 100644 index 0000000..2a154f1 --- /dev/null +++ b/packages/cssforge/oracles/scoped-references.oracle.test.ts @@ -0,0 +1,167 @@ +/** + * This oracle owns the agreement between a Style Dictionary token's explicit + * source path and its resolved value. It observes both value modes at + * `generateStyleDictionaryJSON` and covers src/generator.ts#resolveTokenValue and the alias targets recorded in src/lib.ts. + * + * ```ts + * generateStyleDictionaryJSON(config) // → red for a token referencing theme.light.ink.accent + * ``` + * + * Two scoped themes can share `--accent`. An explicit source path still names + * exactly one token, regardless of the order of the theme entries. + * + * For every generated explicit reference to a scoped theme token with a + * literal value, both modes retain that path and report its literal as the + * resolved value. The README's Style Dictionary section describes + * `$reference` as “The token path this token was built from” and + * `attributes.resolvedValue` as “The final value, even in css-reference mode.” + * + * The model reads the literal and path from the chosen source. The driver + * reads the exported reference and value fields. Unqualified references to + * a variable shared across scopes require a separate contract. + */ + +import { differs, oracleProperty, pass } from "@tanstack/oracles"; +import fc from "fast-check"; +import { generateStyleDictionaryJSON } from "../src/mod.ts"; + +const law = "resolves the explicitly named theme token"; +const checkpoint = "Style Dictionary token"; +const arbitrary = fc.record({ + light: fc.constantFrom("red", "green"), + dark: fc.constantFrom("blue", "black"), + source: fc.constantFrom("light", "dark"), + reverse: fc.boolean(), +}); + +type History = ReturnType["value"]; + +function theme(value: string, selector: string) { + return { + value: { ink: { value: { accent: value }, settings: { variantNameOnly: true } } }, + settings: { selector }, + }; +} + +interface Token { + value: string; + $reference: string; + $resolvedValue: string; + attributes: { resolvedValue: string; referencePaths: string[] }; +} + +oracleProperty({ + id: "style-dictionary-scoped-source", + owns: [ + "src/generator.ts#resolveTokenValue", + "src/lib.ts#resolveTokenAliases", + "src/lib.ts#withReferenceTargets", + ], + law: { + statement: + "For every generated explicit reference to a scoped theme token with a literal value, both modes retain that path and report its literal as the resolved value.", + authority: "README.md, Style Dictionary JSON, Token fields and Choose the value mode", + limits: + "Literal theme tokens with two selectors. Unqualified names and fallback selection are outside the grammar.", + }, + histories: { + arbitrary, + runs: 100, + fixedSeeds: [47], + states: ["source first", "source last"], + constructed: [ + { + name: "source before other theme", + enters: ["source first"], + build: (base): History => ({ ...base, source: "light", reverse: false }), + }, + { + name: "source after other theme", + enters: ["source last"], + build: (base): History => ({ ...base, source: "light", reverse: true }), + }, + ], + }, + reached: ({ source, reverse }) => [ + (source === "light") !== reverse ? "source first" : "source last", + ], + model(history) { + const path = `theme.${history.source}.ink.accent`; + const resolved = history[history.source]; + const other = history.source === "light" ? history.dark : history.light; + return [resolved, "var(--button-base-ink)"].map((value) => ({ + value, + source: path, + references: [path], + resolved, + resolvedAttribute: resolved, + blend: `linear-gradient(${resolved}, ${other}, ${resolved})`, + })); + }, + driver(history, observe) { + const light = theme(history.light, ".light"); + const dark = theme(history.dark, ".dark"); + const config = { + colors: { + palette: { value: {} }, + theme: history.reverse ? { dark, light } : { light, dark }, + }, + primitives: { + button: { + value: { + base: { + value: { + ink: "var(--accent)", + blend: "linear-gradient(var(--accent), var(--other), var(--accent))", + }, + variables: { + accent: `theme.${history.source}.ink.accent`, + other: `theme.${history.source === "light" ? "dark" : "light"}.ink.accent`, + }, + }, + }, + }, + }, + }; + try { + const modes = ["resolved", "css-reference"] as const; + observe( + checkpoint, + modes.map((valueMode) => { + const tokens: { + primitives: { button: { base: { ink: Token; blend: Token } } }; + } = JSON.parse(generateStyleDictionaryJSON(config, { valueMode })); + const token = tokens.primitives.button.base.ink; + return { + value: token.value, + source: token.$reference, + references: token.attributes.referencePaths, + resolved: token.$resolvedValue, + resolvedAttribute: token.attributes.resolvedValue, + blend: tokens.primitives.button.base.blend.$resolvedValue, + }; + }), + ); + } catch (error) { + observe(checkpoint, error); + } + }, + check: (_history, trace, expected) => + differs(checkpoint, law, trace[0]?.value, expected) ?? pass, + calibrations: [ + { + name: "reports the other theme as the source", + law, + history: { constructed: "source after other theme" }, + corrupt: (trace) => { + const rows: unknown = trace[0]?.value; + if (!Array.isArray(rows)) return undefined; + const first: unknown = rows[0]; + if (typeof first !== "object" || first === null) return undefined; + return [ + { checkpoint, value: [{ ...first, source: "theme.dark.ink.accent" }, rows[1]] }, + ]; + }, + }, + ], +}); diff --git a/packages/cssforge/package.json b/packages/cssforge/package.json index dd5deb5..cca1e74 100644 --- a/packages/cssforge/package.json +++ b/packages/cssforge/package.json @@ -60,11 +60,13 @@ "devDependencies": { "@acid-cat/cli": "0.13.0", "@biomejs/biome": "2.4.2", + "@tanstack/oracles": "0.0.1", "@types/node": "24.3.0", + "fast-check": "4.11.0", "mdbox": "0.1.1", "tsup": "8.5.0", "tsx": "4.20.6", "typescript": "5.9.3", - "vitest": "4.0.18" + "vitest": "4.1.12" } } diff --git a/packages/cssforge/src/generator.ts b/packages/cssforge/src/generator.ts index 94a0677..2b971f4 100644 --- a/packages/cssforge/src/generator.ts +++ b/packages/cssforge/src/generator.ts @@ -6,6 +6,7 @@ import type { TokenColorFormats, } from "./lib.ts"; import { + getReferenceTargets, getTokenScope, type Output, type ResolvedToken, @@ -329,21 +330,26 @@ const createNestedStyleDictionaryObject = ( const resolveTokenValue = ( token: ResolvedToken, + tokensByPath: ResolveMap, tokensByCssVariable: Map, - seen: Set = new Set(), -): string => - replaceCssVariableReferences(token.value, (cssVariable, match) => { - if (seen.has(cssVariable)) return match; - - const referencedToken = tokensByCssVariable.get(cssVariable); - if (!referencedToken) return match; + seen: ReadonlySet = new Set(), +): string => { + const targets = getReferenceTargets(token); + let referenceIndex = 0; + return replaceCssVariableReferences(token.value, (cssVariable, match) => { + const path = targets?.[referenceIndex++]; + const referencedToken = + (path && tokensByPath.get(path)) || tokensByCssVariable.get(cssVariable); + if (!referencedToken || seen.has(referencedToken.sourcePath)) return match; return resolveTokenValue( referencedToken, + tokensByPath, tokensByCssVariable, - new Set([...seen, cssVariable]), + new Set([...seen, referencedToken.sourcePath]), ); }); +}; const tokenLeafName = (sourcePath: string) => sourcePath.replaceAll("@", ".").split(".").at(-1)?.toLowerCase() ?? ""; @@ -475,7 +481,7 @@ export function generateStyleDictionaryJSON( }); const styleDictionaryValues = outputTokens.reduce((acc, { outputPath, token }) => { - const resolvedValue = resolveTokenValue(token, tokensByCssVariable); + const resolvedValue = resolveTokenValue(token, resolveMap, tokensByCssVariable); const cssVariableReference = `var(${token.key})`; const referencePaths = token.referencePaths?.map(toStyleDictionaryPath); const tier = token.tier ?? (referencePaths?.length ? "semantic" : "primitive"); diff --git a/packages/cssforge/src/lib.ts b/packages/cssforge/src/lib.ts index d553ea8..fb0333d 100644 --- a/packages/cssforge/src/lib.ts +++ b/packages/cssforge/src/lib.ts @@ -122,6 +122,19 @@ export const withTokenScope = ( */ export type ResolveMap = Map; +// Each slot follows the parser's callback order, including native CSS references. +const referenceTargets = new WeakMap(); + +export function withReferenceTargets( + token: T, + targets: readonly (string | undefined)[] | undefined, +): T { + if (targets?.some(Boolean)) referenceTargets.set(token, targets); + return token; +} + +export const getReferenceTargets = (token: ResolvedToken) => referenceTargets.get(token); + /** Every {@link DiagnosticCode}, for the schema of a report. */ export const diagnosticCodes = [ "typography-static-scale", @@ -193,6 +206,13 @@ const findClosingParen = (value: string, openParenIndex: number): number => { continue; } + if (value.startsWith("/*", index)) { + const end = value.indexOf("*/", index + 2); + if (end === -1) return -1; + index = end + 1; + continue; + } + if (character === "(") depth += 1; else if (character === ")") { depth -= 1; @@ -255,7 +275,7 @@ const skipTrivia = (value: string, start: number, end: number): number => { * Rewrites CSS custom-property references using the canonical CSSForge parser. * * The replacer receives the custom property name, the full `var(...)` match, - * and its index, and must return the replacement for that whole match. `match` + * and the name offset within the match, and returns the replacement for that match. `match` * arrives nested-resolved, so `resolveValue` can substitute only the name token * and keep a fallback intact. Malformed, unbalanced, unnamed, and quoted `var(` * text keeps its original value and is never reported to the replacer; unmapped @@ -263,7 +283,7 @@ const skipTrivia = (value: string, start: number, end: number): number => { */ export const replaceCssVariableReferences = ( value: string, - replacer: (cssVariable: string, match: string, index: number) => string, + replacer: (cssVariable: string, match: string, nameOffset: number) => string, ): string => { let result = ""; let cursor = 0; @@ -312,18 +332,25 @@ export const replaceCssVariableReferences = ( const nameOffset = openParenIndex + 1; const nameStart = skipTrivia(value, nameOffset, closeParenIndex); - const nameMatch = /^(--[^\s(),"']+)/.exec(value.slice(nameStart, closeParenIndex)); + const nameMatch = /^(--(?:(?!\/\*)[^\s(),"'])+)/.exec( + value.slice(nameStart, closeParenIndex), + ); const cssVariable = nameMatch?.[1]; if (cssVariable && cssVariableNamePattern.test(cssVariable)) { const nameEnd = nameStart + cssVariable.length; + const delimiter = skipTrivia(value, nameEnd, closeParenIndex); + if (delimiter !== closeParenIndex && value[delimiter] !== ",") { + index = closeParenIndex + 1; + continue; + } const closed = value.slice(nameEnd, closeParenIndex + 1); result += value.slice(cursor, index); result += replacer( cssVariable, value.slice(index, nameEnd) + replaceCssVariableReferences(closed, replacer), - index, + nameStart - index, ); cursor = closeParenIndex + 1; } @@ -534,10 +561,46 @@ export const getReferencePaths = ({ export const resolveValue = ({ map, value, + onReference, }: { map: Map; value: string; + onReference?: (name: string) => void; }) => - replaceCssVariableReferences(value, (cssVariable, match) => - match.replace(cssVariable, map.get(cssVariable) ?? cssVariable), - ); + replaceCssVariableReferences(value, (cssVariable, match, nameOffset) => { + onReference?.(cssVariable.slice(2)); + const replacement = map.get(cssVariable); + if (replacement === undefined) return match; + return ( + match.slice(0, nameOffset) + + replacement + + match.slice(nameOffset + cssVariable.length) + ); + }); + +/** Resolves authored aliases and preserves the explicit source of each reference. */ +export function resolveTokenAliases( + value: string, + map: Map, + variables: Variables | undefined, +) { + const targets: (string | undefined)[] = []; + const referencePaths = new Set(); + const resolved = resolveValue({ + map, + value, + onReference(name) { + const path = + variables && Object.hasOwn(variables, name) + ? normalizeTokenPath(variables[name]) + : undefined; + targets.push(path); + if (path) referencePaths.add(path); + }, + }); + return { + value: resolved, + referencePaths: referencePaths.size ? [...referencePaths] : undefined, + targets, + }; +} diff --git a/packages/cssforge/src/modules/colors.ts b/packages/cssforge/src/modules/colors.ts index 7536898..55256ff 100644 --- a/packages/cssforge/src/modules/colors.ts +++ b/packages/cssforge/src/modules/colors.ts @@ -16,14 +16,14 @@ import type { Variables, } from "../lib.ts"; import { - getReferencePaths, getResolvedVariablesMap, normalizeTokenPath, type Output, type ResolveMap, ROOT_SCOPE, - resolveValue, + resolveTokenAliases, resolveVariable, + withReferenceTargets, withTokenScope, } from "../lib.ts"; @@ -1008,6 +1008,7 @@ interface MixContext { /** A color value as it is emitted, with its static color when one can be computed. */ interface EmittedColor { + targets?: readonly (string | undefined)[]; value: string; referencePaths?: string[]; color?: Color; @@ -1130,7 +1131,7 @@ const readColorMix = ( return { value: `color-mix(in ${space}, ${from.css}, ${other.css} ${amount}%)`, ...(referencePaths.length > 0 - ? { referencePaths: [...new Set(referencePaths)] } + ? { referencePaths: [...new Set(referencePaths)], targets: referencePaths } : {}), ...(from.color && other.color ? { color: mixInOklch(from.color, other.color, amount / 100) } @@ -1314,7 +1315,7 @@ export function processColors( validateName(variantId, `palette.${colorName}.${variantId}`); const key = `--${moduleKey}-${colorName}-${variantId}`; const path = `palette.${colorName}.${variantId}`; - const { value, color, referencePaths } = readPaletteVariant( + const { value, color, referencePaths, targets } = readPaletteVariant( colorValue, path, mixContext, @@ -1342,17 +1343,20 @@ export function processColors( resolveMap.set( `${moduleKey}.${colorName}.${variantId}`, withTokenScope( - { - key, - value, - variable, - ...(generated ? { color: generated.values } : {}), - ...(generated?.gamutMapped ? { gamutMapped: true } : {}), - sourcePath: `${moduleKey}.${colorName}.${variantId}`, - ...(referencePaths ? { referencePaths } : {}), - type: "color", - tier: referencePaths ? "semantic" : "primitive", - }, + withReferenceTargets( + { + key, + value, + variable, + ...(generated ? { color: generated.values } : {}), + ...(generated?.gamutMapped ? { gamutMapped: true } : {}), + sourcePath: `${moduleKey}.${colorName}.${variantId}`, + ...(referencePaths ? { referencePaths } : {}), + type: "color", + tier: referencePaths ? "semantic" : "primitive", + }, + targets, + ), handler.scope, ), ); @@ -1413,8 +1417,11 @@ export function processColors( colors: palette, }); - const gradientValue = resolveValue({ map: resolvedMapForGradient, value }); - const referencePaths = getReferencePaths({ value, variables }); + const { + value: gradientValue, + referencePaths, + targets, + } = resolveTokenAliases(value, resolvedMapForGradient, variables); const key = `--${moduleKey}-${gradientName}-${variantName}`; const variable = `${key}: ${gradientValue};`; @@ -1424,15 +1431,18 @@ export function processColors( resolveMap.set( `${moduleKey}.${gradientName}.${variantName}`, withTokenScope( - { - variable, - key, - value: gradientValue, - sourcePath: `${moduleKey}.${gradientName}.${variantName}`, - ...(referencePaths ? { referencePaths } : {}), - type: "gradient", - tier: referencePaths ? "semantic" : "primitive", - }, + withReferenceTargets( + { + variable, + key, + value: gradientValue, + sourcePath: `${moduleKey}.${gradientName}.${variantName}`, + ...(referencePaths ? { referencePaths } : {}), + type: "gradient", + tier: referencePaths ? "semantic" : "primitive", + }, + targets, + ), handler.scope, ), ); @@ -1506,13 +1516,7 @@ export function processColors( const variantValue = colorInTheme.value[variantName]; return isColorMix(variantValue) ? readColorMix(variantValue, variantPath, mixContext) - : { - value: resolveValue({ map: resolvedMap, value: variantValue }), - referencePaths: getReferencePaths({ - value: variantValue, - variables: colorInTheme.variables, - }), - }; + : resolveTokenAliases(variantValue, resolvedMap, colorInTheme.variables); }; }; @@ -1521,21 +1525,25 @@ export function processColors( key: string, value: string, referencePaths: string[] | undefined, + targets: readonly (string | undefined)[] | undefined, scope: string, ) => { const variable = `${key}: ${value};`; resolveMap.set( path, withTokenScope( - { - key, - value, - variable, - sourcePath: path, - ...(referencePaths ? { referencePaths } : {}), - type: "color", - tier: referencePaths ? "semantic" : "primitive", - }, + withReferenceTargets( + { + key, + value, + variable, + sourcePath: path, + ...(referencePaths ? { referencePaths } : {}), + type: "color", + tier: referencePaths ? "semantic" : "primitive", + }, + targets, + ), scope, ), ); @@ -1599,6 +1607,7 @@ export function processColors( key, `light-dark(${lightVariant.value}, ${darkVariant.value})`, references.length > 0 ? [...new Set(references)] : undefined, + [...(lightVariant.targets ?? []), ...(darkVariant.targets ?? [])], ROOT_SCOPE, ), ); @@ -1633,7 +1642,7 @@ export function processColors( const variantNameOnly = colorInTheme.settings?.variantNameOnly ?? false; const readVariant = themeColorReader(themeName, colorName, colorInTheme); for (const variantName of Object.keys(colorInTheme.value)) { - const { value, referencePaths } = readVariant(variantName); + const { value, referencePaths, targets } = readVariant(variantName); const key = variantNameOnly ? `--${variantName}` : `--${moduleKey}-${themeName}-${colorName}-${variantName}`; @@ -1643,6 +1652,7 @@ export function processColors( key, value, referencePaths, + targets, handler.scope, ), ); diff --git a/packages/cssforge/src/modules/primitive.ts b/packages/cssforge/src/modules/primitive.ts index a151da1..9bb8335 100644 --- a/packages/cssforge/src/modules/primitive.ts +++ b/packages/cssforge/src/modules/primitive.ts @@ -6,11 +6,11 @@ import { validateVariableAliases, } from "../helpers.ts"; import { - getReferencePaths, getResolvedVariablesMap, type Output, - resolveValue, + resolveTokenAliases, type Variables, + withReferenceTargets, } from "../lib.ts"; import type { ColorConfig } from "./colors.ts"; import { processColors } from "./colors.ts"; @@ -140,21 +140,30 @@ export function processPrimitives(config: { ? pxToRem({ value: propValue, rem: settings.rem }) : propValue; - const resolvedValue = resolveValue({ map: resolvedMap, value: convertedValue }); - const referencePaths = getReferencePaths({ value: convertedValue, variables }); + const { + value: resolvedValue, + referencePaths, + targets, + } = resolveTokenAliases(convertedValue, resolvedMap, variables); const key = `--${primitiveName}-${variantName}-${propName}`; const variable = `${key}: ${resolvedValue};`; cssOutput.push(variable); - resolveMap.set(`${moduleKey}.${primitiveName}.${variantName}.${propName}`, { - key, - value: resolvedValue, - variable, - sourcePath: `${moduleKey}.${primitiveName}.${variantName}.${propName}`, - ...(referencePaths ? { referencePaths } : {}), - type: "component", - tier: referencePaths ? "semantic" : "primitive", - }); + resolveMap.set( + `${moduleKey}.${primitiveName}.${variantName}.${propName}`, + withReferenceTargets( + { + key, + value: resolvedValue, + variable, + sourcePath: `${moduleKey}.${primitiveName}.${variantName}.${propName}`, + ...(referencePaths ? { referencePaths } : {}), + type: "component", + tier: referencePaths ? "semantic" : "primitive", + }, + targets, + ), + ); } } catch (error) { console.error( diff --git a/packages/cssforge/tests/lib.test.ts b/packages/cssforge/tests/lib.test.ts index 22e8210..dee46a3 100644 --- a/packages/cssforge/tests/lib.test.ts +++ b/packages/cssforge/tests/lib.test.ts @@ -68,6 +68,7 @@ test("resolveValue - leaves malformed var() text unchanged", () => { expect(resolve("var(--bg")).toEqual("var(--bg"); expect(resolve("var()")).toEqual("var()"); expect(resolve("var(--)")).toEqual("var(--)"); + expect(resolve("var(--bg/**/junk)")).toEqual("var(--bg/**/junk)"); expect(resolve("var(--bg, red")).toEqual("var(--bg, red"); // An unbalanced call must not rewrite references inside it. expect(resolve("var(--ext, var(--surface-muted)")).toEqual( diff --git a/packages/cssforge/vitest.oracles.config.ts b/packages/cssforge/vitest.oracles.config.ts new file mode 100644 index 0000000..5ca46ed --- /dev/null +++ b/packages/cssforge/vitest.oracles.config.ts @@ -0,0 +1,7 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + include: ["oracles/*.oracle.test.ts"], + }, +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 699d64d..81b9c5a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -309,9 +309,15 @@ importers: '@biomejs/biome': specifier: 2.4.2 version: 2.4.2 + '@tanstack/oracles': + specifier: 0.0.1 + version: 0.0.1(fast-check@4.11.0)(vitest@4.1.12(@types/node@24.3.0)(vite@7.3.1(@types/node@24.3.0)(jiti@2.6.1)(lightningcss@1.31.1)(terser@5.46.0)(tsx@4.20.6)(yaml@2.8.2))) '@types/node': specifier: 24.3.0 version: 24.3.0 + fast-check: + specifier: 4.11.0 + version: 4.11.0 mdbox: specifier: 0.1.1 version: 0.1.1 @@ -325,8 +331,8 @@ importers: specifier: 5.9.3 version: 5.9.3 vitest: - specifier: 4.0.18 - version: 4.0.18(@types/node@24.3.0)(jiti@2.6.1)(lightningcss@1.31.1)(terser@5.46.0)(tsx@4.20.6)(yaml@2.8.2) + specifier: 4.1.12 + version: 4.1.12(@types/node@24.3.0)(vite@7.3.1(@types/node@24.3.0)(jiti@2.6.1)(lightningcss@1.31.1)(terser@5.46.0)(tsx@4.20.6)(yaml@2.8.2)) packages/docs: devDependencies: @@ -3029,6 +3035,14 @@ packages: peerDependencies: vite: '>=6.0.0' + '@tanstack/oracles@0.0.1': + resolution: {integrity: sha512-oXfwt6sh9jbdlacoOJQ0lEyvwuIGXparZ9YBwwvIjsAIu9eNpBImGb4TI/kO7MwEJaFrqwHgHuKiPtqRCNFXCw==} + engines: {node: '>=20'} + hasBin: true + peerDependencies: + fast-check: ^4.0.0 + vitest: ^4.1.0 || ^5.0.0 + '@tanstack/router-utils@1.158.0': resolution: {integrity: sha512-qZ76eaLKU6Ae9iI/mc5zizBX149DXXZkBVVO3/QRIll79uKLJZHQlMKR++2ba7JsciBWz1pgpIBcCJPE9S0LVg==} engines: {node: '>=12'} @@ -3355,6 +3369,9 @@ packages: '@vitest/expect@4.0.18': resolution: {integrity: sha512-8sCWUyckXXYvx4opfzVY03EOiYVxyNrHS5QxX3DAIi5dpJAAkyJezHCP77VMX4HKA2LDT/Jpfo8i2r5BE3GnQQ==} + '@vitest/expect@4.1.12': + resolution: {integrity: sha512-vFlTt+YEu9WBpNjdGayNmlMVzrWPi1+sv853/7t2FU7hpO5gAFBKHzQmkCq5Xjpr+evegF2994LQT3hF3mRlqQ==} + '@vitest/mocker@4.0.18': resolution: {integrity: sha512-HhVd0MDnzzsgevnOWCBj5Otnzobjy5wLBe4EdeeFGv8luMsGcYqDuFRMcttKWZA5vVO8RFjexVovXvAM4JoJDQ==} peerDependencies: @@ -3366,21 +3383,47 @@ packages: vite: optional: true + '@vitest/mocker@4.1.12': + resolution: {integrity: sha512-fKShNpKZzupWZuY0z7egydvL0sqW4INEZBEExMBMAa6izlENEVHwoXgdaTCaBZ5fwlr4xf2o1wXC83n9RpO+NA==} + peerDependencies: + msw: ^2.4.9 + vite: ^6.0.0 || ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + msw: + optional: true + vite: + optional: true + '@vitest/pretty-format@4.0.18': resolution: {integrity: sha512-P24GK3GulZWC5tz87ux0m8OADrQIUVDPIjjj65vBXYG17ZeU3qD7r+MNZ1RNv4l8CGU2vtTRqixrOi9fYk/yKw==} + '@vitest/pretty-format@4.1.12': + resolution: {integrity: sha512-XW9O8+Mxx4VpCtkYdMJLZQQwsVryP9wk7cPKDxtXFfwSak6yRh5+2fep/Y0XF/ElBvJHq8bcYdi6aeuai0opZA==} + '@vitest/runner@4.0.18': resolution: {integrity: sha512-rpk9y12PGa22Jg6g5M3UVVnTS7+zycIGk9ZNGN+m6tZHKQb7jrP7/77WfZy13Y/EUDd52NDsLRQhYKtv7XfPQw==} + '@vitest/runner@4.1.12': + resolution: {integrity: sha512-NKlVKCr5QnCe8jijdMnmkpHHU+WTqiLFR6G0pHji9uRjXK9xJl1k1nTw6F3pOOj2PDcsDt2GKQMI7wIsaT491w==} + '@vitest/snapshot@4.0.18': resolution: {integrity: sha512-PCiV0rcl7jKQjbgYqjtakly6T1uwv/5BQ9SwBLekVg/EaYeQFPiXcgrC2Y7vDMA8dM1SUEAEV82kgSQIlXNMvA==} + '@vitest/snapshot@4.1.12': + resolution: {integrity: sha512-ko1y1Qgb/slzQ9mr+b89Cuqud8WG1TKtsPD8r7ZUBdvVOGt85Af2HwCqHujrhwJq95hs/9RM7fcAPg57o1vlzw==} + '@vitest/spy@4.0.18': resolution: {integrity: sha512-cbQt3PTSD7P2OARdVW3qWER5EGq7PHlvE+QfzSC0lbwO+xnt7+XH06ZzFjFRgzUX//JmpxrCu92VdwvEPlWSNw==} + '@vitest/spy@4.1.12': + resolution: {integrity: sha512-RGq9x4JNGNTZHEJxvN0oSiJjeSCExm0n2gZKKJZHY9cX5AVA6M7VJILBT3ZJ/tJ/0J9uWT7fETV9/btoi//vSg==} + '@vitest/utils@4.0.18': resolution: {integrity: sha512-msMRKLMVLWygpK3u2Hybgi4MNjcYJvwTb0Ru09+fOyCXIgT5raYP041DRRdiJiI3k/2U6SEbAETB3YtBrUkCFA==} + '@vitest/utils@4.1.12': + resolution: {integrity: sha512-Q3awXrwOfEV+qc3WmO5ONyE0yO7Q1gQ9/oyHxGLZ/pl7N3NO/ZztqQwKLuwMkV+CA1JYSIeO3gkHnRDIo4AVaA==} + '@volar/language-core@2.4.27': resolution: {integrity: sha512-DjmjBWZ4tJKxfNC1F6HyYERNHPYS7L7OPFyCrestykNdUZMFYzI9WTyvwPcaNaHlrEUwESHYsfEw3isInncZxQ==} @@ -4589,6 +4632,10 @@ packages: resolution: {integrity: sha512-iK2f+YrcmoeGqk6fA0ea2bptcu/itMIm4NfEozq6N25+aG6h7s5HZbB/k1aV7b5w5sFLMCbbtRUsTVR+BgC3xw==} engines: {node: '>=12.17.0'} + fast-check@4.11.0: + resolution: {integrity: sha512-V4Uc238rhQOdQlc+Gz7JG6SGBtrWnWL8d/6RyiBeCMcNKMhF6DZ0KkAVHJSyNV5r4lA0PmIpZ6iRpTVoz4qjoA==} + engines: {node: '>=12.17.0'} + fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} @@ -6668,6 +6715,9 @@ packages: std-env@3.10.0: resolution: {integrity: sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==} + std-env@4.3.0: + resolution: {integrity: sha512-OtU/EgQ1kIm5KwqQpBC6ZEMXrZRui11w8zgfTWp8cdO9B8OaPsbA8bTHO2P+HNo1VlUTGMVBwPhydu6poeXiag==} + stop-iteration-iterator@1.1.0: resolution: {integrity: sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==} engines: {node: '>= 0.4'} @@ -6869,8 +6919,8 @@ packages: resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==} engines: {node: '>=12.0.0'} - tinyrainbow@3.0.3: - resolution: {integrity: sha512-PSkbLUoxOFRzJYjjxHJt9xro7D+iilgMX/C9lawzVuYiIdcihh9DXmVibBe8lmcFrRi/VzlPjBxbN7rH24q8/Q==} + tinyrainbow@3.2.0: + resolution: {integrity: sha512-LgO3D9yZJjApUiuUfl9iFAwrtaX4+lok3wJIqttGoKCHlWUqHqbQpnxCf82L8FjgKsh4iGo78hqJwgL8F6To2A==} engines: {node: '>=14.0.0'} to-regex-range@5.0.1: @@ -7480,6 +7530,47 @@ packages: jsdom: optional: true + vitest@4.1.12: + resolution: {integrity: sha512-5eWdz2yb3ajxWF3C8C4TjkXl7FGm3n2E/VlazALrQHzK7nYMSGFnCZto0bbPNl77AwkOZVLk0YnBAejUu0NiWA==} + engines: {node: ^20.0.0 || ^22.0.0 || >=24.0.0} + hasBin: true + peerDependencies: + '@edge-runtime/vm': '*' + '@opentelemetry/api': ^1.9.0 + '@types/node': ^20.0.0 || ^22.0.0 || >=24.0.0 + '@vitest/browser-playwright': 4.1.12 + '@vitest/browser-preview': 4.1.12 + '@vitest/browser-webdriverio': ^4.1.11 + '@vitest/coverage-istanbul': 4.1.12 + '@vitest/coverage-v8': 4.1.12 + '@vitest/ui': 4.1.12 + happy-dom: '*' + jsdom: '*' + vite: ^6.0.0 || ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + '@edge-runtime/vm': + optional: true + '@opentelemetry/api': + optional: true + '@types/node': + optional: true + '@vitest/browser-playwright': + optional: true + '@vitest/browser-preview': + optional: true + '@vitest/browser-webdriverio': + optional: true + '@vitest/coverage-istanbul': + optional: true + '@vitest/coverage-v8': + optional: true + '@vitest/ui': + optional: true + happy-dom: + optional: true + jsdom: + optional: true + vscode-uri@3.1.0: resolution: {integrity: sha512-/BpdSx+yCQGnCvecbyXdxHDkuk55/G3xwnC0GqY4gmQ3j+A+g8kzzgB4Nk/SINjqn6+waqw3EgbVF2QKExkRxQ==} @@ -9999,6 +10090,12 @@ snapshots: transitivePeerDependencies: - supports-color + '@tanstack/oracles@0.0.1(fast-check@4.11.0)(vitest@4.1.12(@types/node@24.3.0)(vite@7.3.1(@types/node@24.3.0)(jiti@2.6.1)(lightningcss@1.31.1)(terser@5.46.0)(tsx@4.20.6)(yaml@2.8.2)))': + dependencies: + fast-check: 4.11.0 + typescript-for-tanstack-oracles: typescript@5.9.3 + vitest: 4.1.12(@types/node@24.3.0)(vite@7.3.1(@types/node@24.3.0)(jiti@2.6.1)(lightningcss@1.31.1)(terser@5.46.0)(tsx@4.20.6)(yaml@2.8.2)) + '@tanstack/router-utils@1.158.0': dependencies: '@babel/core': 7.29.0 @@ -10398,7 +10495,16 @@ snapshots: '@vitest/spy': 4.0.18 '@vitest/utils': 4.0.18 chai: 6.2.2 - tinyrainbow: 3.0.3 + tinyrainbow: 3.2.0 + + '@vitest/expect@4.1.12': + dependencies: + '@standard-schema/spec': 1.1.0 + '@types/chai': 5.2.3 + '@vitest/spy': 4.1.12 + '@vitest/utils': 4.1.12 + chai: 6.2.2 + tinyrainbow: 3.2.0 '@vitest/mocker@4.0.18(vite@7.3.1(@types/node@24.10.13)(jiti@2.6.1)(lightningcss@1.31.1)(terser@5.46.0)(tsx@4.20.6)(yaml@2.8.2))': dependencies: @@ -10408,9 +10514,9 @@ snapshots: optionalDependencies: vite: 7.3.1(@types/node@24.10.13)(jiti@2.6.1)(lightningcss@1.31.1)(terser@5.46.0)(tsx@4.20.6)(yaml@2.8.2) - '@vitest/mocker@4.0.18(vite@7.3.1(@types/node@24.3.0)(jiti@2.6.1)(lightningcss@1.31.1)(terser@5.46.0)(tsx@4.20.6)(yaml@2.8.2))': + '@vitest/mocker@4.1.12(vite@7.3.1(@types/node@24.3.0)(jiti@2.6.1)(lightningcss@1.31.1)(terser@5.46.0)(tsx@4.20.6)(yaml@2.8.2))': dependencies: - '@vitest/spy': 4.0.18 + '@vitest/spy': 4.1.12 estree-walker: 3.0.3 magic-string: 0.30.21 optionalDependencies: @@ -10418,25 +10524,49 @@ snapshots: '@vitest/pretty-format@4.0.18': dependencies: - tinyrainbow: 3.0.3 + tinyrainbow: 3.2.0 + + '@vitest/pretty-format@4.1.12': + dependencies: + tinyrainbow: 3.2.0 '@vitest/runner@4.0.18': dependencies: '@vitest/utils': 4.0.18 pathe: 2.0.3 + '@vitest/runner@4.1.12': + dependencies: + '@vitest/utils': 4.1.12 + pathe: 2.0.3 + '@vitest/snapshot@4.0.18': dependencies: '@vitest/pretty-format': 4.0.18 magic-string: 0.30.21 pathe: 2.0.3 + '@vitest/snapshot@4.1.12': + dependencies: + '@vitest/pretty-format': 4.1.12 + '@vitest/utils': 4.1.12 + magic-string: 0.30.21 + pathe: 2.0.3 + '@vitest/spy@4.0.18': {} + '@vitest/spy@4.1.12': {} + '@vitest/utils@4.0.18': dependencies: '@vitest/pretty-format': 4.0.18 - tinyrainbow: 3.0.3 + tinyrainbow: 3.2.0 + + '@vitest/utils@4.1.12': + dependencies: + '@vitest/pretty-format': 4.1.12 + convert-source-map: 2.0.0 + tinyrainbow: 3.2.0 '@volar/language-core@2.4.27': dependencies: @@ -11890,6 +12020,10 @@ snapshots: dependencies: pure-rand: 8.4.2 + fast-check@4.11.0: + dependencies: + pure-rand: 8.4.2 + fast-deep-equal@3.1.3: {} fast-fifo@1.3.2: {} @@ -14452,6 +14586,8 @@ snapshots: std-env@3.10.0: {} + std-env@4.3.0: {} + stop-iteration-iterator@1.1.0: dependencies: es-errors: 1.3.0 @@ -14709,7 +14845,7 @@ snapshots: fdir: 6.5.0(picomatch@4.0.7) picomatch: 4.0.7 - tinyrainbow@3.0.3: {} + tinyrainbow@3.2.0: {} to-regex-range@5.0.1: dependencies: @@ -15414,7 +15550,7 @@ snapshots: tinybench: 2.9.0 tinyexec: 1.0.2 tinyglobby: 0.2.15 - tinyrainbow: 3.0.3 + tinyrainbow: 3.2.0 vite: 7.3.1(@types/node@24.10.13)(jiti@2.6.1)(lightningcss@1.31.1)(terser@5.46.0)(tsx@4.20.6)(yaml@2.8.2) why-is-node-running: 2.3.0 optionalDependencies: @@ -15432,42 +15568,32 @@ snapshots: - tsx - yaml - vitest@4.0.18(@types/node@24.3.0)(jiti@2.6.1)(lightningcss@1.31.1)(terser@5.46.0)(tsx@4.20.6)(yaml@2.8.2): + vitest@4.1.12(@types/node@24.3.0)(vite@7.3.1(@types/node@24.3.0)(jiti@2.6.1)(lightningcss@1.31.1)(terser@5.46.0)(tsx@4.20.6)(yaml@2.8.2)): dependencies: - '@vitest/expect': 4.0.18 - '@vitest/mocker': 4.0.18(vite@7.3.1(@types/node@24.3.0)(jiti@2.6.1)(lightningcss@1.31.1)(terser@5.46.0)(tsx@4.20.6)(yaml@2.8.2)) - '@vitest/pretty-format': 4.0.18 - '@vitest/runner': 4.0.18 - '@vitest/snapshot': 4.0.18 - '@vitest/spy': 4.0.18 - '@vitest/utils': 4.0.18 - es-module-lexer: 1.7.0 + '@vitest/expect': 4.1.12 + '@vitest/mocker': 4.1.12(vite@7.3.1(@types/node@24.3.0)(jiti@2.6.1)(lightningcss@1.31.1)(terser@5.46.0)(tsx@4.20.6)(yaml@2.8.2)) + '@vitest/pretty-format': 4.1.12 + '@vitest/runner': 4.1.12 + '@vitest/snapshot': 4.1.12 + '@vitest/spy': 4.1.12 + '@vitest/utils': 4.1.12 + es-module-lexer: 2.0.0 expect-type: 1.3.0 magic-string: 0.30.21 obug: 2.1.1 pathe: 2.0.3 picomatch: 4.0.7 - std-env: 3.10.0 + std-env: 4.3.0 tinybench: 2.9.0 tinyexec: 1.0.2 tinyglobby: 0.2.15 - tinyrainbow: 3.0.3 + tinyrainbow: 3.2.0 vite: 7.3.1(@types/node@24.3.0)(jiti@2.6.1)(lightningcss@1.31.1)(terser@5.46.0)(tsx@4.20.6)(yaml@2.8.2) why-is-node-running: 2.3.0 optionalDependencies: '@types/node': 24.3.0 transitivePeerDependencies: - - jiti - - less - - lightningcss - msw - - sass - - sass-embedded - - stylus - - sugarss - - terser - - tsx - - yaml vscode-uri@3.1.0: {}