An open source design system that's fully customizable and agent ready
TypeScript
fix(core): provide dataVars defaults in prebuilt CSS (#7694)
EJ Hammondb1e1936bbab1
diff --git a/.changeset/define-the-canonical-datavars-defaults-in-prebui-6x0i.md b/.changeset/define-the-canonical-datavars-defaults-in-prebui-6x0i.mdnew file mode 100644index 0000000000..4cb2a22d68--- /dev/null+++ b/.changeset/define-the-canonical-datavars-defaults-in-prebui-6x0i.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+'@astryxdesign/cli': patch+---++[fix] Define the canonical dataVars defaults in prebuilt Core CSS so compiled imports and raw CSS references paint correctly without a StyleX build step.+@ejhammonddiff --git a/.github/scripts/prebuilt-data-routing.test.mjs b/.github/scripts/prebuilt-data-routing.test.mjsnew file mode 100644index 0000000000..cd9a909608--- /dev/null+++ b/.github/scripts/prebuilt-data-routing.test.mjs@@ -0,0 +1,31 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/** Pins the prebuilt data-variable browser proof to the existing cascade owner. */+import fs from 'node:fs';+import path from 'node:path';+import {describe, expect, it} from 'vitest';+import yaml from 'yaml';++const ROOT = path.resolve(import.meta.dirname, '../..');+const read = file => fs.readFileSync(path.join(ROOT, file), 'utf8');++describe('prebuilt data-variable browser routing', () => {+ it('runs through the existing Build cascade guard after Chromium is installed', () => {+ const steps = yaml.parse(read('.github/workflows/ci.yml')).jobs[+ 'test-build'+ ].steps;+ const install = steps.findIndex(+ step => step.run === 'npx playwright install chromium',+ );+ const guard = steps.findIndex(+ step => step.run === 'node .github/scripts/theme-layer-cascade.js',+ );+ expect(install).toBeGreaterThanOrEqual(0);+ expect(guard).toBeGreaterThan(install);+ const source = read('.github/scripts/theme-layer-cascade.js');+ expect(source).toContain('scripts/build-css.data-tokens.browser.test.mjs');+ expect(source).toContain("ASTRYX_PREBUILT_DATA_BROWSER: '1'");+ expect(source).toContain('execFileSync(');+ expect(source).not.toContain('continue-on-error');+ });+});diff --git a/.github/scripts/theme-layer-cascade.js b/.github/scripts/theme-layer-cascade.jsindex 981f42b6d0..7e0a647fba 100644--- a/.github/scripts/theme-layer-cascade.js+++ b/.github/scripts/theme-layer-cascade.js@@ -2,7 +2,7 @@// Copyright (c) Meta Platforms, Inc. and affiliates./**- * @description Asserts a production build puts Astryx, theme and product styles in the right cascade order+ * @description Asserts production source and prebuilt CSS put Astryx, theme and product styles in the right cascade order* @input [--port <n>]* @output One line per case; exit 1 if any layer loses to the wrong one*@@ -26,6 +26,7 @@*/const {chromium} = require('playwright');+const {execFileSync} = require('node:child_process');const fs = require('node:fs');const path = require('node:path');const http = require('node:http');@@ -239,9 +240,29 @@ async function run() {);return 1;}+ // This existing CI owner already installs Chromium. Also prove the prebuilt+ // public entry's defaults and both load orders without consumer compilation.+ // Keep the opt-in suite out of the ordinary Node lane, which has no browser.+ execFileSync(+ process.execPath,+ [+ path.join(REPO_ROOT, 'node_modules/vitest/vitest.mjs'),+ 'run',+ '--project',+ 'node',+ 'scripts/build-css.data-tokens.browser.test.mjs',+ '--maxWorkers=1',+ ],+ {+ cwd: REPO_ROOT,+ env: {...process.env, ASTRYX_PREBUILT_DATA_BROWSER: '1'},+ stdio: 'inherit',+ timeout: 240_000,+ },+ );console.log(- '\nAstryx < theme < product holds in a production build, and the ' +- 'data token defaults sit under a theme override.',+ '\nAstryx < theme < product holds in production source and prebuilt CSS, ' ++ 'and the data token defaults sit under a theme override.',);return 0;}diff --git a/docs/specs/AST-066-theme-data-boundary/spec.md b/docs/specs/AST-066-theme-data-boundary/spec.mdindex 16dd912014..7b59576c30 100644--- a/docs/specs/AST-066-theme-data-boundary/spec.md+++ b/docs/specs/AST-066-theme-data-boundary/spec.md@@ -7,7 +7,7 @@ authority: currentarchive_reason: nullsuperseded_by: nullapproved_by: cixzhang-approved_at: 2026-10-01+approved_at: 2026-10-20phase: acceptedowners: [cixzhang]affects_architecture:@@ -23,13 +23,22 @@ affects_consumer_docs: [theme]# StyleX data-token ownership system spec+## Prebuilt Core CSS carries the data-token defaults++The public `dataVars` entry in prebuilt mode contains compiled `var()` references,+not a `defineVars()` call. An application using that entry and the shipped Core+CSS has no StyleX extraction step that can materialize the referenced defaults.+Core's prebuilt stylesheet therefore carries the group as part of its public+CSS contract; theme presence does not control its availability.+## IntentAstryx owns one canonical 56-token data palette in the same public StyleX tokensystem as its other design tokens. Components import the public StyleX variableobject instead of constructing literal `var(--color-data-*)` strings. The-StyleX compiler emits the canonical group when a compiled consumer uses it and-omits the group from builds that do not use it.+StyleX compiler emits the canonical group when a source-compiled consumer uses it+and omits the group from source graphs that do not use it. Core's prebuilt+`astryx.css` includes the group for consumers of the compiled public entry.A concrete theme emits only data-token values that the theme explicitly authors,inside its existing theme donut. It never carries the canonical defaults or a@@ -41,10 +50,10 @@ JavaScript marker, and three existing global `color-scheme` rules remain stable.Runtime and built theme compilation produce the same sparse scoped override.StyleX 0.19 tree-shakes `defineVars` at the module/group boundary, not per-property. The 56 data variables intentionally form one semantic group: a build-emits zero data defaults when the module is unused and all 56 when any member is-used. The contract does not claim token-granular pruning that the compiler does-not provide.+property. The 56 data variables intentionally form one semantic group: a source+build emits zero data defaults when the module is unused and all 56 when any member+is used. The prebuilt Core stylesheet always includes the complete group. The+contract does not claim token-granular pruning that the compiler does not provide.## Non-goals@@ -98,22 +107,31 @@ not provide.shape as `@astryxdesign/core/theme/tokens.stylex`; the existing StyleX`sideEffects` declaration continues to cover the source module. The focusedsubpath prevents ordinary Theme, token-resolution, or non-data component- imports from retaining the StyleX variable group as a side effect.+ imports from retaining the StyleX variable group as a side effect in source+ compilation. In prebuilt mode the same public entry provides compiled `var()`+ references; loading `@astryxdesign/core/astryx.css` MUST supply their defaults+ without requiring a consumer StyleX compilation step.-- **FR3 — Tree-shaking is truthful at the group boundary.** A compiled graph- with no value import from the data StyleX subpath MUST emit no+- **FR3 — Tree-shaking is truthful at the group boundary.** A source-compiled+ graph with no value import from the data StyleX subpath MUST emit no`--color-data-*` default declarations. A graph that retains any `dataVars`value import MUST emit one canonical StyleX variable group containing all 56defaults. Importing one member is not required to prune the other 55.- Distribution extraction MUST become dependency-aware as part of this- implementation. Starting from a package's public entries, it MUST exclude an- unreferenced variable-definition module and include a referenced cross-package- StyleX variable dependency exactly once. Therefore an all-component Core CSS- build with no data consumer omits the group, while a Lab package CSS build that- contains `ChartCandlestick` includes it. The existing isolated file scan is not- sufficient evidence for either result. Bundle evidence MUST report the raw and- compressed cost of the retained group.+ Core's prebuilt `@astryxdesign/core/astryx.css` MUST contain exactly one+ canonical 56-variable group even when no Core component consumes it. The+ package's compiled public `dataVars` entry exposes CSS references that this+ stylesheet MUST define; consumer imports cannot trigger extraction from the+ already-compiled entry. This exception applies only to the prebuilt Core+ stylesheet, not to source-compiled graphs or concrete themes.++ Distribution output MUST remain dependency-aware: referenced cross-package+ StyleX variable dependencies appear exactly once across a satellite stylesheet+ and its required provider stylesheet. A data-consumer package whose provider+ already declares the group MUST NOT repeat it; without that provider, a+ retained group MUST be emitted. Unreferenced groups other than the explicit+ Core distribution exception remain absent. Bundle evidence MUST report the raw+ and compressed cost of the retained group.Supported source and distribution integrations MUST place the emitted variablegroup in `@layer astryx-base`, like other Astryx StyleX output. An unlayered@@ -136,14 +154,16 @@ not provide.Raw CSS and generated examples that cannot consume a TypeScript object MAYreference the same stable custom-property names only when their setup already- guarantees that a compiled data-variable consumer retained the group, or when- they provide an explicit local fallback. Documentation MUST not imply that a- theme stylesheet itself materializes the defaults.+ guarantees that a source-compiled data-variable consumer retained the group or+ that the prebuilt Core stylesheet is loaded, or when they provide an explicit+ local fallback. Documentation MUST not imply that a theme stylesheet itself+ materializes the defaults.- **FR5 — Direct SVG and DOM values paint correctly.** A `dataVars` value passeddirectly to an SVG presentation attribute or DOM style MUST compile to the- stable `var(--color-data-*)` reference and retain the variable-definition- module in the build graph. Default and theme-overridden values MUST paint the+ stable `var(--color-data-*)` reference. In source compilation the import MUST+ retain the variable-definition module; in prebuilt mode Core's stylesheet MUST+ provide the group under FR3. Default and theme-overridden values MUST paint theexpected fill and stroke. An undeclared data variable paints a candlestickbody black and drops its wick stroke; that state MUST NOT recur.@@ -172,8 +192,9 @@ not provide.`<Theme>` injection nor standalone, multi-file, or family `theme build` outputmay emit canonical data defaults on `:root`, `html`, `body`, or anotherout-of-donut selector. Theme compilation MUST not call, inline, or retain a- raw `generateDataTokenDefaultsCSS()` equivalent. The StyleX consumer graph is- the only CSS-default owner.+ raw `generateDataTokenDefaultsCSS()` equivalent. The canonical StyleX group,+ retained by source consumers or Core distribution under FR3, is the only+ CSS-default owner.Removing the old defaults block MUST NOT remove its layer-order side effect.Every standalone, multi-file, family, and runtime theme output MUST retain an@@ -216,13 +237,15 @@ not provide.### Availability and JavaScript compatibility-- **FR12 — Availability follows actual StyleX use, not Theme presence.** If no- compiled consumer retains `dataVars`, the output contains no data-variable- defaults. When one consumer retains the group, standard StyleX 0.19 output- declares the complete group on `:root` plus its variable-group class, exactly- like existing canonical StyleX token groups. This global declaration is an- accepted compiler consequence of the chosen canonical token system; it MUST- NOT be attributed to or duplicated by theme build.+- **FR12 — Availability follows the compilation mode, not Theme presence.** A+ source graph without a compiled consumer retaining `dataVars` contains no+ data-variable defaults. Core's prebuilt stylesheet always retains the group+ under FR3, because the compiled public entry alone cannot emit definitions.+ In either mode, standard StyleX 0.19 output declares the complete group on+ `:root` plus its variable-group class, exactly like existing canonical StyleX+ token groups. This global declaration is an accepted compiler consequence of+ the chosen canonical token system; it MUST NOT be attributed to or duplicated+ by theme build.In supported Astryx source and distribution integrations, the emitted groupMUST be wrapped in `@layer astryx-base`. A bare StyleX transform emits the same@@ -324,46 +347,33 @@ not provide.## Current-state impact-Theme compilation currently owns the canonical data defaults. Runtime `<Theme>`-injection and every `theme build` mode emit one unconditional-`@layer astryx-base { :root { ...56 defaults... } }` block generated from the-plain `dataTokenDefaults` JavaScript object, while authored data values already-stay sparse inside the theme donut. Core StyleX CSS declares no data custom-property, and Astryx components that need a data color construct literal-`var(--color-data-*)` strings.--When this contract ships:--- the canonical palette becomes one public StyleX `dataVars` group;-- the compatibility defaults, types, validation, and docs derive from the same- canonical record;-- unused compiled graphs emit zero data defaults and a retained group emits all- 56, matching StyleX's real grouping behavior;-- Astryx TSX consumers use the public object rather than literal strings;-- concrete standalone and family themes emit only authored scoped overrides;-- runtime and built theme paths emit no raw root data block;-- nested themes inherit omitted values and siblings isolate authored overrides;-- JavaScript resolution APIs and stable CSS names remain compatible;-- the three global `color-scheme` rules remain unchanged where emitted;-- generated JavaScript keeps `__built: true`; and-- CLI output filenames and the CSS/JS/type trio remain unchanged.--`architecture:theme-compilation` continues to own runtime/static sparse theme-output. `architecture:theme-application` continues to own provider nesting and-style lifetime. `architecture:theme-tokens` owns the shared token vocabulary and-derived compatibility views; the public StyleX data-token module owns canonical-CSS defaults. This record does not govern `@astryxdesign/build`.+The public StyleX data group owns canonical CSS defaults; the compatibility,+type, validation, and documentation views derive from it. Source compilation+retains whole-group tree-shaking. Core's prebuilt stylesheet supplies the same+group for the compiled public `dataVars` entry, without a consumer compilation+step or runtime Theme injection.++Concrete standalone and family themes contain only authored scoped overrides.+Nested themes inherit omissions, JavaScript resolution remains compatible, and+the global `color-scheme` rules, built marker, filenames, and paired CSS/JS/type+outputs are unchanged.++`architecture:theme-compilation` owns runtime/static sparse theme output.+`architecture:theme-application` owns provider nesting and style lifetime.+`architecture:theme-tokens` owns the shared vocabulary and derived compatibility+views; this record's FR3 owns the prebuilt data-group availability guarantee.+This record does not govern `@astryxdesign/build`.## Verification-| Contract | Verification | Representative states | Mutation or failure expectation |-| --------- | --------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |-| FR1–FR3 | generator drift, public export, graph-aware compiler, and package CSS tests | all 56 names; unused graph; one retained member; cross-package dependency; source and precompiled builds; raw/gzip size | plain defaults drift; public key changes; unused build emits data vars; referenced package omits them; one use emits fewer/more than the complete group; duplicate group |-| FR4–FR5 | source audit, compiler fixture, component tests, real Chromium | direct SVG fill/stroke; DOM style; Canvas concrete resolution; explicit props; canonical green/red; authored override | literal construction remains; direct CSS value does not retain definitions; Canvas receives `var()`; body paints black or wick disappears |-| FR6–FR7 | runtime/static/family structure and layer-order tests | zero/one/many authored names; all 56 canonical names; `:root`/html/body scan; theme CSS before/after component CSS | omitted default serialized; authored value outside donut; raw defaults remain; layer order flips |-| FR8–FR11 | real-browser cascade matrix | same/different nesting; parent/child subsets; siblings; dynamic switch; light/dark/system/MediaTheme; portals; layered and unlayered source CSS | omission resets; sibling leaks; order/mode changes winner; unlayered root silently claims override parity |-| FR12–FR16 | compiler/runtime/build parity and environment-policy tests | no data consumer; retained layered group; runtime and built themes; standalone and family color-scheme composition | Theme presence emits defaults; built/runtime differ; family repeats defaults; global policy diverges |-| FR17–FR20 | Changeset, codemod, CLI check, docs, and regeneration fixtures | literal component/fixture use; raw CSS with/without fallback; old root artifact; ordinary/family build | no breaking note; unsafe auto-rewrite; stale artifact passes; docs claim theme CSS supplies defaults or token-granular pruning |+| Contract | Verification | Representative states | Mutation or failure expectation |+| --------- | --------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |+| FR1–FR3 | generator drift, public export, graph-aware compiler, and package CSS tests | source graphs without imports; prebuilt Core; one retained member; cross-package provider pair; raw/gzip size | plain defaults drift; public key changes; unused source graph emits data vars; prebuilt Core omits any; one use emits fewer/more than 56; duplicate group |+| FR4–FR5 | source audit, compiler fixture, component tests, real Chromium | direct SVG fill/stroke; DOM style; Canvas concrete resolution; explicit props; canonical green/red; authored override | literal construction remains; direct CSS value does not retain definitions; Canvas receives `var()`; body paints black or wick disappears |+| FR6–FR7 | runtime/static/family structure and layer-order tests | zero/one/many authored names; all 56 canonical names; `:root`/html/body scan; theme CSS before/after component CSS | omitted default serialized; authored value outside donut; raw defaults remain; layer order flips |+| FR8–FR11 | real-browser cascade matrix | same/different nesting; parent/child subsets; siblings; dynamic switch; light/dark/system/MediaTheme; portals; layered and unlayered source CSS | omission resets; sibling leaks; order/mode changes winner; unlayered root silently claims override parity |+| FR12–FR16 | compiler/runtime/build parity and environment-policy tests | no data consumer; retained layered group; runtime and built themes; standalone and family color-scheme composition | Theme presence emits defaults; built/runtime differ; family repeats defaults; global policy diverges |+| FR17–FR20 | Changeset, codemod, CLI check, docs, and regeneration fixtures | literal component/fixture use; raw CSS with/without fallback; old root artifact; ordinary/family build | no breaking note; unsafe auto-rewrite; stale artifact passes; docs claim theme CSS supplies defaults or token-granular pruning |Real-browser verification MUST independently assert canonical and authored values,not reuse generator output as the oracle. It MUST reproduce the@@ -380,10 +390,12 @@ canonical defaults in `astryx-base` rather than being reported as equivalent.Compiler verification MUST compile an unused entry and a one-member consumer.The unused output contains zero `--color-data-*` defaults; the retained outputcontains every canonical name exactly once in the StyleX variable group. It MUST-not claim per-property pruning. Distribution verification MUST start from real-package entries, resolve the cross-package StyleX variable dependency, prove Core-omits an unreferenced group and Lab retains a referenced group, and report raw and-gzip deltas.+not claim per-property pruning. Distribution verification MUST prove Core's+prebuilt stylesheet defines all 56 canonical values exactly once and a+satellite/provider pair does not duplicate the group. A production application+using only the prebuilt CSS and the compiled public `dataVars` entry MUST paint+canonical and authored values in both light/dark modes and both stylesheet load+orders. Report raw and gzip deltas for the retained group.Theme-output verification MUST enumerate all 56 canonical names and fail if anun-authored canonical value appears in standalone, multi-file, family, or runtime@@ -396,13 +408,12 @@ family composition.### Completion criteria-This accepted specification remains incomplete until the implementation stack-proves:+Conformance requires:- one canonical `.stylex.ts` source, a public `dataVars` export, and generatedcompatibility/type/validation views;-- truthful whole-group StyleX tree-shaking through graph-aware source and- precompiled extraction;+- truthful whole-group source tree-shaking and the explicit prebuilt-Core+ availability guarantee, with dependency-aware satellite deduplication;- migrated Astryx consumers with no constructible raw data-var strings;- sparse donut overrides and zero theme-build raw defaults across runtime,standalone, multi-file, and family modes;@@ -436,9 +447,9 @@ to disagree.StyleX 0.19 emits a complete `defineVars` group when its module is retained andcannot prune individual object properties. One data palette group matches theexisting `colorVars` model, keeps the public API coherent, and gives an honest-zero-or-56 boundary. Precompiled package CSS must become graph-aware so this-module boundary remains truthful across packages rather than degenerating into a-repository file scan.+source-compiled zero-or-56 boundary. Precompiled package CSS remains graph-aware+across packages, with the explicit Core distribution exception in FR3; it does+not use a repository-wide file scan.Rejected: claiming token-granular pruning, or splitting the palette across manyfiles solely to simulate it. Both would make the API and maintenance cost exceed@@ -476,8 +487,9 @@ default.`stylex.defineVars(defaults)` emits its group on `:root` plus a variable-groupclass. This is the same canonical mechanism as existing token groups. The strict-boundary in this decision is therefore ownership: unused graphs emit nothing and-theme build never emits data defaults globally.+boundary in this decision is therefore ownership: unused source graphs emit+nothing, Core distribution retains the group under FR3, and theme build never+emits data defaults globally.Rejected: promising that retained canonical StyleX variables are absent fromunthemed DOM. Standard `defineVars` cannot make that promise; a manually scoped@@ -519,6 +531,21 @@ The release uses a breaking 0.x minor with regeneration and consumer diagnosticsRejected: a legacy global-data mode. It would keep new artifacts on the behaviorthis decision removes and make runtime/static ownership mode-dependent.+### DEC-9 — Prebuilt Core CSS defines the public data-variable entry++**Reference:** `spec:AST-066/DEC-9`+**Decider:** `cixzhang`, `2026-10-20`++The prebuilt public `dataVars` entry contains CSS `var()` references with no+surviving `defineVars()` call. A prebuilt-CSS consumer cannot retain defaults by+importing that already-compiled object. Core's stylesheet therefore includes the+single canonical group, like its other public token defaults. Source-compiled+graphs retain the zero-or-56 rule; themes contain only authored deltas. The fixed+cost is one group of 56 declarations, not a second source or a new runtime mode.++Rejected: requiring prebuilt consumers to compile the source token entry, because+it defeats the prebuilt-CSS contract and its documented import path.+## Deprecation and cleanup records### IFIX-0009 — Themes stop emitting raw global data-color defaults@@ -529,11 +556,11 @@ this decision removes and make runtime/static ownership mode-dependent.| cleanup | `CLN-0016` || package | `@astryxdesign/core`, `@astryxdesign/cli` || surface | The unscoped raw `:root` block of canonical data-color defaults that `Theme` runtime and `theme build` (standalone and family) emit for every theme |-| authority | FR6 (concrete themes emit only explicitly authored data values), FR7 (theme build never emits raw global data defaults), and FR12 (availability follows StyleX use). Owners: `spec:AST-066`: `cixzhang` |+| authority | FR6 (concrete themes emit only explicitly authored data values), FR7 (theme build never emits raw global data defaults), and FR12 (availability follows compilation mode, not Theme presence). Owners: `spec:AST-066`: `cixzhang` || reproducer | With the latest stable packages, a theme that authors no data colors emits every canonical data default in an unscoped root block, in runtime CSS and in `theme build` output || affected | CSS that reads a raw data-color custom property directly, relying on a theme to define it, without compiling a `dataVars` consumer; and stale generated theme CSS checked into an app || matrix | Theme with no authored data colors: every canonical default before; none after. Authored override: emitted before and after, scoped to its theme. StyleX `dataVars` consumers: same painted values before and after. Global `color-scheme` rules: unchanged |-| coexistence | The public `dataVars` group carries the canonical values before and after, so a consumer that reads `dataVars` gets the same values on both |+| coexistence | The public `dataVars` group supplies canonical values through retained source compilation or the prebuilt Core stylesheet; a compiled import alone does not emit CSS. || migration | Read data colors through the public `dataVars` group, or author the needed values in the theme. Regenerate built theme CSS || codemod | `astryx upgrade` runs a validator that reports direct raw consumers and stale generated CSS; the rewrite depends on whether the consumer compiles StyleX || downstream | Maintained docs and templates read data colors through `dataVars` |diff --git a/docs/specs/AST-080-package-stylesheets/spec.md b/docs/specs/AST-080-package-stylesheets/spec.mdindex 65920d94de..be11e4a958 100644--- a/docs/specs/AST-080-package-stylesheets/spec.md+++ b/docs/specs/AST-080-package-stylesheets/spec.md@@ -149,8 +149,9 @@ first.- Core, Lab, Rich Text, and Charts already export one stylesheet each with everyrule inside `@layer astryx-base`. Non-Core stylesheets omit the Core variable- groups `astryx.css` declares; Lab's keeps Core's data-token group, which- `astryx.css` omits under `spec:AST-066` FR3.+ groups `astryx.css` declares. Core's prebuilt stylesheet carries the canonical+ data-token group; Lab relies on that stylesheet and adds no copy, under+ `spec:AST-066` FR3.- No package stylesheet and not `reset.css` carries the FR3 order registrationtoday. The order holds only when the product writes the registration lineitself; a product that loads `reset.css` after a package stylesheet without itdiff --git a/packages/charts/docs/CHARTV2_READINESS.md b/packages/charts/docs/CHARTV2_READINESS.mdindex 81264e9a30..6a2493fc86 100644--- a/packages/charts/docs/CHARTV2_READINESS.md+++ b/packages/charts/docs/CHARTV2_READINESS.md@@ -46,11 +46,11 @@ has a story. (Not full stable/a11y bar — that's later.)## Utilities-| Util | Readiness | Notes |-| ------------------------------------------------------- | -------------- | ----------------------------------------------------------------------------- |-| `useChartColors` / `getChartColors` (palette) | **Ship-ready** | Solid; resolves the `--color-data-*` tokens (which are JS-only, not CSS vars) |-| `currency` formatter | **Ship-ready** | Verified on an axis |-| `percent` / `compactNumber` / `shortDate` / `monthYear` | Minor polish | Not yet verified in a story |+| Util | Readiness | Notes |+| ------------------------------------------------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| `useChartColors` / `getChartColors` (palette) | **Ship-ready** | Solid; resolves concrete palette colors for Canvas/non-CSS paths. CSS-capable `dataVars` consumers get `--color-data-*` variables from Core CSS in prebuilt mode. Concrete resolution uses `resolveThemeToken()` / `useTheme().token()`. |+| `currency` formatter | **Ship-ready** | Verified on an axis |+| `percent` / `compactNumber` / `shortDate` / `monthYear` | Minor polish | Not yet verified in a story |---diff --git a/packages/charts/src/marks/candlestick.tsx b/packages/charts/src/marks/candlestick.tsxindex 881a259e40..e4147ef673 100644--- a/packages/charts/src/marks/candlestick.tsx+++ b/packages/charts/src/marks/candlestick.tsx@@ -49,7 +49,9 @@ function candleSlot(resolved: ResolvedPoint[], ctx: SeriesContext): number {}export function candlestick(options: CandlestickOptions): SeriesDef {- // Emitted core semantic tokens (data-viz --color-data-* tokens aren't CSS vars).+ // Keep the semantic success/error defaults. CSS-capable dataVars consumers+ // use Core's data CSS variables (astryx.css in prebuilt mode); Canvas and other+ // non-CSS paths need resolveThemeToken() or useTheme().token() concrete colors.const upColor = options.upColor ?? 'var(--color-success)';const downColor = options.downColor ?? 'var(--color-error)';diff --git a/packages/charts/src/types.ts b/packages/charts/src/types.tsindex f9db666f3a..1e506510ce 100644--- a/packages/charts/src/types.ts+++ b/packages/charts/src/types.ts@@ -20,11 +20,12 @@ export type ColorAccessor =/*** Fallback series color used when a mark has neither an explicit color nor a- * palette color assigned by the chart root. Uses an EMITTED core token- * (`--color-accent`) — the data-viz `--color-data-*` tokens are JS-only values- * (resolved via useChartColors), not CSS custom properties, so `var(--color-data-*)`- * would render nothing. The chart root normally assigns a resolved palette color,- * so this is only a last-resort fallback.+ * palette color assigned by the chart root. Keeps `--color-accent` as its+ * semantic fallback. CSS-capable code can also use the public `dataVars` group;+ * Core's prebuilt stylesheet defines its `--color-data-*` custom properties.+ * Canvas and other non-CSS paths need concrete colors from resolveThemeToken()+ * or useTheme().token(). The chart root normally assigns a resolved palette+ * color, so this is only a last-resort fallback.*/export const DEFAULT_SERIES_COLOR = 'var(--color-accent)';diff --git a/packages/cli/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs b/packages/cli/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjsindex ffc31eafa0..99e9e1b4dd 100644--- a/packages/cli/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs+++ b/packages/cli/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs@@ -29,6 +29,17 @@ describe('validate-data-token-ownership', () => {}});+ it('reports prebuilt CSS availability without requiring a source compile step', async () => {+ await expect(+ run('const fill = "var(--color-data-categorical-blue)";'),+ ).rejects.toThrow(+ /in prebuilt mode, loads @astryxdesign\/core\/astryx\.css/,+ );+ await expect(+ run('.bar { fill: var(--color-data-categorical-blue); }', 'chart.css'),+ ).rejects.toThrow(/load @astryxdesign\/core\/astryx\.css in prebuilt mode/);+ });+it('leaves fallbacks, dataVars access, and comments unchanged', async () => {const source = `// var(--color-data-categorical-green)diff --git a/packages/cli/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs b/packages/cli/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjsindex 9164f6fedd..51a5fd5541 100644--- a/packages/cli/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs+++ b/packages/cli/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs@@ -56,7 +56,7 @@ export default function validateDataTokenOwnership(file, api) {ROOT_DATA_DECLARATION.test(file.source)) {throw new Error(- 'This generated theme CSS still emits canonical data defaults at :root. Rebuild it with `astryx theme build`; defaults now come from compiled dataVars consumers.',+ 'This generated theme CSS still emits canonical data defaults at :root. Rebuild it with `astryx theme build`; defaults come from source-compiled dataVars consumers or @astryxdesign/core/astryx.css in prebuilt mode.',);}const uncommented = file.source.replace(CSS_COMMENT, comment =>@@ -66,7 +66,7 @@ export default function validateDataTokenOwnership(file, api) {if (cssMatch) {const line = uncommented.slice(0, cssMatch.index).split('\n').length;throw new Error(- `Raw var(${cssMatch[1]}) without a fallback at line ${line} needs manual migration: compiled dataVars output is not guaranteed in this stylesheet, so add an explicit fallback or style the element from code that imports dataVars from @astryxdesign/core/theme/dataTokens.stylex.`,+ `Raw var(${cssMatch[1]}) without a fallback at line ${line} needs an availability check: load @astryxdesign/core/astryx.css in prebuilt mode, ensure a source-compiled dataVars consumer retains the group, or add an explicit fallback. CSS-capable code imports dataVars from @astryxdesign/core/theme/dataTokens.stylex.`,);}return undefined;@@ -95,7 +95,7 @@ export default function validateDataTokenOwnership(file, api) {if (found) {const {token, line} = found;throw new Error(- `Direct var(${token})${line == null ? '' : ` at line ${line}`} needs manual migration: CSS-capable code imports dataVars from @astryxdesign/core/theme/dataTokens.stylex; Canvas and other non-CSS APIs use resolveThemeToken() or useTheme().token().`,+ `Direct var(${token})${line == null ? '' : ` at line ${line}`} needs manual migration: CSS-capable code imports dataVars from @astryxdesign/core/theme/dataTokens.stylex and, in prebuilt mode, loads @astryxdesign/core/astryx.css; Canvas and other non-CSS APIs use resolveThemeToken() or useTheme().token().`,);}return undefined;diff --git a/packages/cli/assets/docs/tree/tokens-data.doc.mjs b/packages/cli/assets/docs/tree/tokens-data.doc.mjsindex afc0d0c656..ace3e11ef2 100644--- a/packages/cli/assets/docs/tree/tokens-data.doc.mjs+++ b/packages/cli/assets/docs/tree/tokens-data.doc.mjs@@ -17,14 +17,14 @@ export const docs = {"order": 20},"category": "foundations",- "description": "Colors for charts and graphs: one categorical accent per series, a neutral for labels and reference lines, and sequential ramps from 5 (darkest) to 1 (lightest) for ordered scales and heatmaps. Import dataVars from @astryxdesign/core/theme/dataTokens.stylex for CSS-capable code. Retaining any member emits the complete 56-variable group; an unused graph emits none.",+ "description": "Colors for charts and graphs: one categorical accent per series, a neutral for labels and reference lines, and sequential ramps from 5 (darkest) to 1 (lightest) for ordered scales and heatmaps. Import dataVars from @astryxdesign/core/theme/dataTokens.stylex for CSS-capable code. Source compilation emits the complete 56-variable group when any member is retained and none for an unused graph. Prebuilt CSS consumers load @astryxdesign/core/astryx.css, which defines the complete group for the already-compiled dataVars entry.","sections": [{"title": "Data Visualization Tokens","content": [{"type": "prose",- "text": "Colors for charts and graphs: one categorical accent per series, a neutral for labels and reference lines, and sequential ramps from 5 (darkest) to 1 (lightest) for ordered scales and heatmaps. Import dataVars from @astryxdesign/core/theme/dataTokens.stylex for CSS-capable code. Retaining any member emits the complete 56-variable group; an unused graph emits none."+ "text": "Colors for charts and graphs: one categorical accent per series, a neutral for labels and reference lines, and sequential ramps from 5 (darkest) to 1 (lightest) for ordered scales and heatmaps. Import dataVars from @astryxdesign/core/theme/dataTokens.stylex for CSS-capable code. Source compilation emits the complete 56-variable group when any member is retained and none for an unused graph. Prebuilt CSS consumers load @astryxdesign/core/astryx.css, which defines the complete group for the already-compiled dataVars entry."},{"type": "table",diff --git a/scripts/build-css.data-tokens.browser.test.mjs b/scripts/build-css.data-tokens.browser.test.mjsnew file mode 100644index 0000000000..5c6de73227--- /dev/null+++ b/scripts/build-css.data-tokens.browser.test.mjs@@ -0,0 +1,130 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file build-css.data-tokens.browser.test.mjs+ * @input Built Core CSS, compiled dataVars, and a standalone CLI-built theme;+ * run with ASTRYX_PREBUILT_DATA_BROWSER=1 after installing Chromium+ * @output Real-browser defaults, sparse overrides, nesting, and load-order proof+ * @position Prebuilt-CSS cascade guard for spec:AST-066 FR3/FR8/FR11/FR12+ */++import fs from 'node:fs/promises';+import os from 'node:os';+import path from 'node:path';+import {afterAll, beforeAll, describe, expect, it} from 'vitest';+import {chromium} from 'playwright';+import {ensureCoreBuilt} from '../packages/cli/clients/cli/commands/ensure-core-built.mjs';+import {runCli} from '../packages/cli/test-utils/run-cli.mjs';++const ROOT = path.resolve(new URL('..', import.meta.url).pathname);+let browser;+let dir;+let coreCSS;+let themeCSS;+let dataVars;++beforeAll(async () => {+ ensureCoreBuilt();+ coreCSS = await fs.readFile(+ path.join(ROOT, 'packages/core/dist/astryx.css'),+ 'utf8',+ );+ ({dataVars} =+ await import('../packages/core/dist/theme/dataTokens.stylex.js'));+ dir = await fs.mkdtemp(path.join(os.tmpdir(), 'astryx-prebuilt-data-'));+ await fs.writeFile(+ path.join(dir, 'override.mjs'),+ `export default ${JSON.stringify({+ name: 'data-override',+ tokens: {'--color-data-categorical-blue': 'light-dark(#010203, #040506)'},+ })};`,+ );+ const result = await runCli(+ ['theme', 'build', 'override.mjs', '-o', 'override.css'],+ dir,+ );+ expect(result.code, `${result.stdout}\n${result.stderr}`).toBe(0);+ themeCSS = await fs.readFile(path.join(dir, 'override.css'), 'utf8');+ expect(themeCSS.match(/--color-data-[\w-]+:/g)).toHaveLength(1);+ expect(themeCSS).not.toMatch(/:root\s*\{[^}]*--color-data-/s);+ browser = await chromium.launch({args: ['--no-sandbox']});+}, 200_000);++afterAll(async () => {+ await browser?.close();+ if (dir) await fs.rm(dir, {recursive: true, force: true});+});++async function colors(styles, mode, rootTheme = false) {+ const page = await browser.newPage();+ try {+ await page.setContent(`<html style="color-scheme:${mode}" ${rootTheme ? 'data-astryx-theme="data-override"' : ''}><head>${styles.map(css => `<style>${css}</style>`).join('')}</head><body>+ <div id="raw" style="background-color:var(--color-data-categorical-blue)"></div>+ <div id="compiled" style="background-color:${dataVars['--color-data-categorical-blue']}"></div>+ <div id="neutral" style="background-color:${dataVars['--color-data-neutral']}"></div>+ <div data-astryx-theme="data-override"><div id="override" style="background-color:${dataVars['--color-data-categorical-blue']}"></div>+ <div data-astryx-theme="child"><div id="nested" style="background-color:${dataVars['--color-data-categorical-blue']}"></div></div>+ </div>+ </body></html>`);+ return await page.evaluate(() =>+ Object.fromEntries(+ ['raw', 'compiled', 'neutral', 'override', 'nested'].map(id => [+ id,+ getComputedStyle(document.getElementById(id)).backgroundColor,+ ]),+ ),+ );+ } finally {+ await page.close();+ }+}++describe.runIf(process.env.ASTRYX_PREBUILT_DATA_BROWSER === '1')(+ 'prebuilt data variables paint without a consumer StyleX compile step',+ () => {+ for (const mode of ['light', 'dark']) {+ it(`paints defaults and authored overrides in both load orders (${mode})`, async () => {+ const expected = {+ raw: 'rgb(1, 113, 227)',+ compiled: 'rgb(1, 113, 227)',+ neutral:+ mode === 'light' ? 'rgb(132, 148, 163)' : 'rgb(140, 147, 155)',+ override: mode === 'light' ? 'rgb(1, 2, 3)' : 'rgb(4, 5, 6)',+ nested: mode === 'light' ? 'rgb(1, 2, 3)' : 'rgb(4, 5, 6)',+ };+ expect(await colors([coreCSS, themeCSS], mode)).toEqual(expected);+ expect(await colors([themeCSS, coreCSS], mode)).toEqual(expected);+ // On the document root the two declarations compete directly, not just+ // through inheritance. This catches unlayered defaults/layer inversions.+ const rootExpected = {+ ...expected,+ raw: expected.override,+ compiled: expected.override,+ };+ expect(await colors([coreCSS, themeCSS], mode, true)).toEqual(+ rootExpected,+ );+ expect(await colors([themeCSS, coreCSS], mode, true)).toEqual(+ rootExpected,+ );+ });+ it(`rejects unlayered defaults at a themed document root (${mode})`, async () => {+ const block = coreCSS.match(+ /:root,\s*\.\w+\{[^}]*--color-data-categorical-blue:[^}]+\}/,+ )[0];+ const unlayered = await colors([themeCSS, block], mode, true);+ expect(unlayered.raw).toBe('rgb(1, 113, 227)');+ expect(unlayered.compiled).toBe('rgb(1, 113, 227)');+ expect(unlayered.raw).not.toBe(+ mode === 'light' ? 'rgb(1, 2, 3)' : 'rgb(4, 5, 6)',+ );+ });+ it(`reproduces transparent raw and compiled swatches without definitions (${mode})`, async () => {+ const missing = await colors([themeCSS], mode);+ expect(missing.raw).toBe('rgba(0, 0, 0, 0)');+ expect(missing.compiled).toBe('rgba(0, 0, 0, 0)');+ expect(missing.neutral).toBe('rgba(0, 0, 0, 0)');+ });+ }+ },+);diff --git a/scripts/build-css.data-tokens.test.mjs b/scripts/build-css.data-tokens.test.mjsnew file mode 100644index 0000000000..fa8dd10f6c--- /dev/null+++ b/scripts/build-css.data-tokens.test.mjs@@ -0,0 +1,61 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file build-css.data-tokens.test.mjs+ * @input Built Core CSS and the generated compatibility view of dataVars+ * @output Proves the prebuilt stylesheet owns exactly one canonical data group+ * @position Distribution regression guard for spec:AST-066 FR3/FR12+ */++import fs from 'node:fs/promises';+import path from 'node:path';+import {fileURLToPath} from 'node:url';+import {beforeAll, describe, expect, it} from 'vitest';+import {dataTokenDefaults} from '../packages/core/src/theme/domainTokens/dataTokens';+import {ensureCoreBuilt} from '../packages/cli/clients/cli/commands/ensure-core-built.mjs';++const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');+const normalize = value => value.replace(/\s+/g, '').toLowerCase();++describe('prebuilt Core data variables (spec:AST-066)', () => {+ let css;+ beforeAll(async () => {+ ensureCoreBuilt();+ css = await fs.readFile(+ path.join(ROOT, 'packages/core/dist/astryx.css'),+ 'utf8',+ );+ }, 180_000);++ it('defines all 56 defaults exactly once with canonical values', () => {+ expect(Object.keys(dataTokenDefaults)).toHaveLength(56);+ const declarations = [...css.matchAll(/(--color-data-[\w-]+):([^;}]+)/g)];+ expect(declarations).toHaveLength(56);+ for (const [name, value] of Object.entries(dataTokenDefaults)) {+ const matches = declarations.filter(match => match[1] === name);+ expect(matches, name).toHaveLength(1);+ expect(normalize(matches[0][2]), name).toBe(normalize(value));+ }+ });++ it('uses the same layered root-plus-group-class shape as other defineVars defaults', () => {+ const layer = css.indexOf('@layer astryx-base {');+ expect(layer).toBeGreaterThan(0);+ const blocks = [...css.matchAll(/([^{}]+)\{([^{}]+)\}/g)];+ const data = blocks.find(match =>+ match[2].includes('--color-data-categorical-blue:'),+ );+ const colors = blocks.find(match => match[2].includes('--color-accent:'));+ expect(data).toBeDefined();+ expect(colors).toBeDefined();+ expect(data.index).toBeGreaterThan(layer);+ expect(data[1].trim()).toMatch(/^:root,\s*\.\w+$/);+ expect(colors[1].trim()).toMatch(/^:root,\s*\.\w+$/);+ expect(+ css+ .slice(data.index + data[0].length)+ .trim()+ .endsWith('}'),+ ).toBe(true);+ });+});diff --git a/scripts/build-css.graph.test.mjs b/scripts/build-css.graph.test.mjsindex 884e06e828..9c5ead6897 100644--- a/scripts/build-css.graph.test.mjs+++ b/scripts/build-css.graph.test.mjs@@ -73,6 +73,68 @@ describe('build-css dependency extraction', () => {expect(rules).toEqual([]);});+ it('retains the complete explicit distribution group and deduplicates satellite imports', async () => {+ const {root, src} = await fixture();+ const provider = path.join(root, 'provider');+ await fs.mkdir(provider, {recursive: true});+ const dataSource = await fs.readFile(+ new URL(+ '../packages/core/src/theme/dataTokens.stylex.ts',+ import.meta.url,+ ),+ 'utf8',+ );+ await fs.writeFile(path.join(provider, 'data.stylex.ts'), dataSource);+ await fs.writeFile(+ path.join(provider, 'Component.ts'),+ 'export const value = 1;\n',+ );+ await fs.writeFile(+ path.join(src, 'Consumer.ts'),+ `import {dataVars} from '@probe/data.stylex';\nexport const color = dataVars['--color-data-categorical-blue'];\n`,+ );+ const providerTarget = {+ src: provider,+ aliases: {},+ stylexEntries: ['data.stylex.ts'],+ };+ const providerCSS = stylexBabelPlugin.processStylexRules(+ await collectStyleXCSS(providerTarget),+ false,+ );+ const satelliteCSS = stylexBabelPlugin.processStylexRules(+ await collectStyleXCSS({+ src,+ aliases: {'@probe/*': [path.join(provider, '*')]},+ provider: providerTarget,+ }),+ false,+ );+ expect(providerCSS.match(/--color-data-[\w-]+:/g)).toHaveLength(56);+ expect(satelliteCSS).not.toContain('--color-data-');+ // Without the provider, a one-member consumer still owns the full group.+ const standaloneCSS = stylexBabelPlugin.processStylexRules(+ await collectStyleXCSS({+ src,+ aliases: {'@probe/*': [path.join(provider, '*')]},+ }),+ false,+ );+ expect(standaloneCSS.match(/--color-data-[\w-]+:/g)).toHaveLength(56);+ expect(standaloneCSS).toBe(providerCSS);+ });++ it('fails closed when an explicit distribution entry is missing', async () => {+ const {src} = await fixture();+ await expect(+ collectStyleXCSS({+ src,+ aliases: {},+ stylexEntries: ['missing.stylex.ts'],+ }),+ ).rejects.toThrow('ENOENT');+ });+it('ignores type-only imports and re-exports', async () => {const {src, external} = await fixture();await fs.writeFile(diff --git a/scripts/build-css.mjs b/scripts/build-css.mjsindex 1b7e71b9d5..5bc9fec867 100644--- a/scripts/build-css.mjs+++ b/scripts/build-css.mjs@@ -10,8 +10,8 @@* node scripts/build-css.mjs --package lab # lab → packages/lab/dist/lab.css** This script:- * 1. Runs Babel with the StyleX plugin over the target package's source files- * 2. Collects all StyleX rules+ * 1. Walks component sources and explicit distribution entries through StyleX imports+ * 2. Runs Babel over the reachable modules and collects their StyleX rules* 3. Fails when the stylesheet reads a StyleX-generated variable that nothing* declares (see undefinedStyleXVariables)* 4. Outputs a combined stylesheet that registers the Astryx layer order and@@ -42,6 +42,10 @@ const TARGETS = {outFile: 'astryx.css',banner: 'Astryx Pre-compiled StyleX CSS — all components',aliases: {},+ // The public dist dataVars entry is already compiled to var() references.+ // Dist consumers cannot retain its defineVars call, so astryx.css provides+ // this group even without a Core component import (spec:AST-066 FR3).+ stylexEntries: ['theme/dataTokens.stylex.ts'],},lab: {src: path.resolve(ROOT, 'packages/lab/src'),@@ -193,10 +197,10 @@ const STYLEX_MODULE = /\.stylex\.[cm]?[jt]sx?$/;/*** Walks a package from its all-component entry set through static `.stylex`- * imports. Non-StyleX source files are the entries; a variable module joins- * only when a reachable file imports it, so a public defineVars module stays- * absent from packages that never consume it. Modules in `provided` are left- * to the stylesheet that already emits them.+ * imports. Non-StyleX source files and explicitly retained distribution modules+ * are the entries; other variable modules join only through reachable imports.+ * This keeps source-like graphs selective without omitting Core's public dist+ * defaults. Modules in `provided` are left to the stylesheet that emits them.*/async function reachableSourceFiles(target, provided = new Set()) {const files = await glob('**/*.{ts,tsx}', {@@ -205,7 +209,12 @@ async function reachableSourceFiles(target, provided = new Set()) {ignore: ['**/*.test.*', '**/*.d.ts', '**/node_modules/**'],});- const queue = files.filter(file => !STYLEX_MODULE.test(file));+ const queue = [+ ...files.filter(file => !STYLEX_MODULE.test(file)),+ ...(target.stylexEntries ?? []).map(entry =>+ path.resolve(target.src, entry),+ ),+ ].filter(file => !provided.has(file));const reachable = new Map();while (queue.length > 0) {diff --git a/scripts/generate-token-docs.mjs b/scripts/generate-token-docs.mjsindex c71fc2198b..a0316fc77f 100644--- a/scripts/generate-token-docs.mjs+++ b/scripts/generate-token-docs.mjs@@ -130,7 +130,7 @@ const groups = [file: DATA_TOKENS_SRC,title: 'Data Visualization Tokens',description:- 'Colors for charts and graphs: one categorical accent per series, a neutral for labels and reference lines, and sequential ramps from 5 (darkest) to 1 (lightest) for ordered scales and heatmaps. Import dataVars from @astryxdesign/core/theme/dataTokens.stylex for CSS-capable code. Retaining any member emits the complete 56-variable group; an unused graph emits none.',+ 'Colors for charts and graphs: one categorical accent per series, a neutral for labels and reference lines, and sequential ramps from 5 (darkest) to 1 (lightest) for ordered scales and heatmaps. Import dataVars from @astryxdesign/core/theme/dataTokens.stylex for CSS-capable code. Source compilation emits the complete 56-variable group when any member is retained and none for an unused graph. Prebuilt CSS consumers load @astryxdesign/core/astryx.css, which defines the complete group for the already-compiled dataVars entry.',headers: ['Token', 'Light', 'Dark'],formatRow: lightDarkRow,},@@ -364,8 +364,7 @@ const usageDoc = {title: 'Usage in StyleX',placement: {parent: 'namespace:tokens', slot: 'guides', order},category: 'foundations',- description:- 'How to import and use token variables in StyleX styles.',+ description: 'How to import and use token variables in StyleX styles.',sections: [{title: 'Usage in StyleX',@@ -422,13 +421,21 @@ const isCheck = process.argv.includes('--check');/** @type {Array<{path: string, output: string, label: string}>} */const allFiles = [- {path: namespacePath, output: namespaceOutput, label: 'tree/tokens.doc.mjs (namespace)'},+ {+ path: namespacePath,+ output: namespaceOutput,+ label: 'tree/tokens.doc.mjs (namespace)',+ },...childFiles.map(f => ({path: f.path,output: f.output,label: `tree/${f.slug}.doc.mjs (${f.tokenCount} tokens)`,})),- {path: usagePath, output: usageOutput, label: `tree/${usageSlug}.doc.mjs (usage)`},+ {+ path: usagePath,+ output: usageOutput,+ label: `tree/${usageSlug}.doc.mjs (usage)`,+ },];// A generated tokens guide no category writes any more (a renamed or removed@@ -453,7 +460,10 @@ const orphans = [.map(file => resolve(TREE_DIR, file)).filter(filePath => {const base = filePath.replace(/\.doc\.(?:dense|zh)\.mjs$/, '.doc.mjs');- return orphanGuides.includes(base) || !treeFiles.includes(base.slice(TREE_DIR.length + 1));+ return (+ orphanGuides.includes(base) ||+ !treeFiles.includes(base.slice(TREE_DIR.length + 1))+ );}),];@@ -470,17 +480,23 @@ if (isCheck) {try {existing = readFileSync(filePath, 'utf-8');} catch {- console.error(`✗ ${label} does not exist. Run: node scripts/generate-token-docs.mjs`);+ console.error(+ `✗ ${label} does not exist. Run: node scripts/generate-token-docs.mjs`,+ );failed = true;continue;}if (existing !== output) {- console.error(`✗ ${label} is out of date. Run: node scripts/generate-token-docs.mjs`);+ console.error(+ `✗ ${label} is out of date. Run: node scripts/generate-token-docs.mjs`,+ );failed = true;}}if (failed) process.exit(1);- console.log(`✓ All token docs are up to date (${totalTokens} tokens, ${allFiles.length} files)`);+ console.log(+ `✓ All token docs are up to date (${totalTokens} tokens, ${allFiles.length} files)`,+ );} else {for (const {path: filePath, output} of allFiles) {writeFileSync(filePath, output);