rnwind 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/lib/cjs/core/parser/tw-parser.cjs +43 -1
  2. package/lib/cjs/core/parser/tw-parser.cjs.map +1 -1
  3. package/lib/cjs/core/parser/tw-parser.d.ts +20 -0
  4. package/lib/cjs/core/style-builder/build-style.cjs +12 -3
  5. package/lib/cjs/core/style-builder/build-style.cjs.map +1 -1
  6. package/lib/cjs/core/style-builder/build-style.d.ts +3 -1
  7. package/lib/cjs/core/style-builder/union-builder.cjs +9 -1
  8. package/lib/cjs/core/style-builder/union-builder.cjs.map +1 -1
  9. package/lib/cjs/core/style-builder/union-builder.d.ts +7 -0
  10. package/lib/cjs/runtime/hooks/use-scheme.cjs +8 -5
  11. package/lib/cjs/runtime/hooks/use-scheme.cjs.map +1 -1
  12. package/lib/cjs/runtime/index.cjs +1 -0
  13. package/lib/cjs/runtime/index.cjs.map +1 -1
  14. package/lib/cjs/runtime/index.d.ts +1 -1
  15. package/lib/cjs/runtime/lookup-css.cjs +27 -0
  16. package/lib/cjs/runtime/lookup-css.cjs.map +1 -1
  17. package/lib/cjs/runtime/lookup-css.d.ts +18 -0
  18. package/lib/cjs/testing/index.cjs +1 -1
  19. package/lib/cjs/testing/index.cjs.map +1 -1
  20. package/lib/esm/core/parser/color.mjs +1 -1
  21. package/lib/esm/core/parser/tw-parser.d.ts +20 -0
  22. package/lib/esm/core/parser/tw-parser.mjs +44 -2
  23. package/lib/esm/core/parser/tw-parser.mjs.map +1 -1
  24. package/lib/esm/core/style-builder/build-style.d.ts +3 -1
  25. package/lib/esm/core/style-builder/build-style.mjs +12 -3
  26. package/lib/esm/core/style-builder/build-style.mjs.map +1 -1
  27. package/lib/esm/core/style-builder/union-builder.d.ts +7 -0
  28. package/lib/esm/core/style-builder/union-builder.mjs +9 -1
  29. package/lib/esm/core/style-builder/union-builder.mjs.map +1 -1
  30. package/lib/esm/runtime/hooks/use-scheme.mjs +8 -5
  31. package/lib/esm/runtime/hooks/use-scheme.mjs.map +1 -1
  32. package/lib/esm/runtime/index.d.ts +1 -1
  33. package/lib/esm/runtime/index.mjs +1 -1
  34. package/lib/esm/runtime/index.mjs.map +1 -1
  35. package/lib/esm/runtime/lookup-css.d.ts +18 -0
  36. package/lib/esm/runtime/lookup-css.mjs +26 -1
  37. package/lib/esm/runtime/lookup-css.mjs.map +1 -1
  38. package/lib/esm/testing/index.mjs +2 -2
  39. package/lib/esm/testing/index.mjs.map +1 -1
  40. package/package.json +1 -1
  41. package/src/core/parser/tw-parser.ts +53 -1
  42. package/src/core/style-builder/build-style.ts +12 -1
  43. package/src/core/style-builder/union-builder.ts +10 -1
  44. package/src/runtime/hooks/use-scheme.ts +8 -4
  45. package/src/runtime/index.ts +1 -0
  46. package/src/runtime/lookup-css.ts +28 -0
  47. package/src/testing/index.ts +3 -0
@@ -2,6 +2,7 @@ import { type SourceEntry } from '@tailwindcss/oxide';
2
2
  import { type GradientAtomInfo } from './gradient';
3
3
  import { type HapticRequest } from './haptics';
4
4
  import type { RNStyle } from './types';
5
+ import type { ThemeTables } from '../types';
5
6
  /** Parser configuration — one instance per Metro session, theme CSS fixed. */
6
7
  export interface TailwindParserConfig {
7
8
  /**
@@ -94,6 +95,14 @@ export interface ParsedOutput {
94
95
  * provider's `windowWidth`.
95
96
  */
96
97
  breakpoints: ReadonlyMap<string, number>;
98
+ /**
99
+ * Per-scheme user theme token tables (`--color-*`, `--spacing-*`, …) with
100
+ * `--color-*` values lowered to sRGB. The style-builder emits these as
101
+ * `registerThemeTokens({...})` in the manifest so `useColor` / `useToken` /
102
+ * `useSize` resolve out of the box, without the user threading a `tables`
103
+ * prop on the provider. Keyed by scheme (`base` + each declared variant).
104
+ */
105
+ themeTokens: ThemeTables;
97
106
  }
98
107
  /**
99
108
  * Parses one source file's Tailwind usage into RN-ready style objects.
@@ -170,6 +179,17 @@ export declare class TailwindParser {
170
179
  * @returns Effective var name → value lookup for the scheme.
171
180
  */
172
181
  private effectiveVars;
182
+ /**
183
+ * Build the per-scheme theme token tables for `registerThemeTokens` —
184
+ * the data source for `useColor` / `useToken` / `useSize`. Emits one table
185
+ * per scheme the user wrote tokens under (`base` + each variant block /
186
+ * `.dark` override). `--color-*` values are lowered to sRGB (matching the
187
+ * className path) using `resolver` so a wide-gamut or `var()`-referencing
188
+ * token resolves to an RN-renderable string; other tokens pass through.
189
+ * @param resolver Full compiled `:root` table, for resolving `var()` refs.
190
+ * @returns Scheme → (token name → value) map.
191
+ */
192
+ private buildThemeTokens;
173
193
  /**
174
194
  * Build the Tailwind compiler on first use and cache it. The theme CSS
175
195
  * gets a `theme(inline)` modifier on its `@import 'tailwindcss'` so
@@ -296,14 +296,18 @@ function serializeBreakpoints(breakpoints) {
296
296
  * @param breakpoints Responsive breakpoint name → px-threshold map.
297
297
  * @param gradients Atom → gradient info for `registerGradients`.
298
298
  * @param haptics Atom → haptic request for `registerHaptics`.
299
+ * @param themeTokens
299
300
  * @returns JS source text.
300
301
  */
301
- function renderManifest(variants, breakpoints, gradients, haptics) {
302
+ function renderManifest(variants, breakpoints, gradients, haptics, themeTokens) {
303
+ const hasTokens = Object.keys(themeTokens).length > 0;
302
304
  const imports = ['registerSchemeLoader', 'registerBreakpoints'];
303
305
  if (gradients.size > 0)
304
306
  imports.push('registerGradients');
305
307
  if (haptics.size > 0)
306
308
  imports.push('registerHaptics');
309
+ if (hasTokens)
310
+ imports.push('registerThemeTokens');
307
311
  const lines = [`import { ${imports.join(', ')} } from 'rnwind'`, `import './common.style'`];
308
312
  for (const variant of variants)
309
313
  lines.push(`import ${JSON.stringify(`./${variant}.style`)}`);
@@ -312,6 +316,8 @@ function renderManifest(variants, breakpoints, gradients, haptics) {
312
316
  lines.push(`registerGradients(${serializeFeatureMap(gradients)})`);
313
317
  if (haptics.size > 0)
314
318
  lines.push(`registerHaptics(${serializeFeatureMap(haptics)})`);
319
+ if (hasTokens)
320
+ lines.push(`registerThemeTokens(${JSON.stringify(themeTokens)})`);
315
321
  lines.push(``, `function ensureSchemeLoaded(_name) {}`, ``, `registerSchemeLoader(ensureSchemeLoaded)`, ``, `export { ensureSchemeLoaded }`, ``);
316
322
  return lines.join('\n');
317
323
  }
@@ -603,9 +609,10 @@ const EMPTY_BREAKPOINTS = new Map();
603
609
  * @param literals Distinct literal className strings — pre-merged into
604
610
  * per-scheme molecules so the runtime resolver's O(1) molecule-first
605
611
  * path is populated. Empty for legacy/test callers (atom path only).
612
+ * @param themeTokens
606
613
  * @returns Per-scheme sources, manifest source, variant list.
607
614
  */
608
- function buildSchemeSources(atomNames, resolved, keyframes, cache, breakpoints = EMPTY_BREAKPOINTS, gradients = EMPTY_FEATURE_MAP, haptics = EMPTY_FEATURE_MAP, literals = EMPTY_LITERALS) {
615
+ function buildSchemeSources(atomNames, resolved, keyframes, cache, breakpoints = EMPTY_BREAKPOINTS, gradients = EMPTY_FEATURE_MAP, haptics = EMPTY_FEATURE_MAP, literals = EMPTY_LITERALS, themeTokens = EMPTY_THEME_TOKENS) {
609
616
  const variants = collectVariantSchemes(resolved);
610
617
  const commonEntries = [];
611
618
  const variantEntries = {};
@@ -630,7 +637,7 @@ function buildSchemeSources(atomNames, resolved, keyframes, cache, breakpoints =
630
637
  }
631
638
  return {
632
639
  schemeSources,
633
- manifestSource: renderManifest(variants, breakpoints, gradients, haptics),
640
+ manifestSource: renderManifest(variants, breakpoints, gradients, haptics, themeTokens),
634
641
  variants,
635
642
  serializedMisses: misses,
636
643
  };
@@ -639,6 +646,8 @@ function buildSchemeSources(atomNames, resolved, keyframes, cache, breakpoints =
639
646
  const EMPTY_FEATURE_MAP = new Map();
640
647
  /** Shared empty literal-list default (atom-only callers). */
641
648
  const EMPTY_LITERALS = [];
649
+ /** Shared empty theme-token default (callers without theme tokens). */
650
+ const EMPTY_THEME_TOKENS = {};
642
651
 
643
652
  exports.buildSchemeSources = buildSchemeSources;
644
653
  //# sourceMappingURL=build-style.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-style.cjs","sources":["../../../../../src/core/style-builder/build-style.ts"],"sourcesContent":["import type { KeyframeBlock, RNStyle, SchemedStyle } from '../parser'\nimport { normalizeClassName } from '../normalize-classname'\n\n/** Match atom names like `border-hairline`, `h-hairline`, `border-t-hairline`, etc. */\nconst HAIRLINE_ATOM = /-hairline$/\n\n/** Parser's synthetic \"no variant\" scheme — provides the canonical fallback. */\nconst BASE_SCHEME = 'base'\n\n/** Runtime registry key for the always-loaded fallback scheme. */\nconst COMMON_SCHEME = 'common'\n\n/** Sentinel key the parser sets on interactive (`active:`/`focus:`) atoms. */\nconst STATE_KEY = '__state'\n\n/**\n * Whether an atom is a `*-hairline` utility — its numeric value must be\n * rewritten as `StyleSheet.hairlineWidth` at runtime.\n * @param atomName Class name.\n * @returns True when the atom is a hairline utility.\n */\nfunction isHairlineAtom(atomName: string): boolean {\n return HAIRLINE_ATOM.test(atomName)\n}\n\n/**\n * Whether an RN style object carries any own key. The parser emits\n * empty `{}` for schemes an atom doesn't apply to; we treat those as\n * \"inherit canonical\" and don't emit an entry for that scheme.\n * @param style RN style object.\n * @returns Whether the style has content.\n */\nfunction isNonEmptyStyle(style: RNStyle | undefined): style is RNStyle {\n if (!style) return false\n return Object.keys(style).length > 0\n}\n\n/**\n * Iterate per-scheme entries from a parser-produced schemed bucket,\n * skipping the reserved `__state` metadata key.\n * @param schemed Parser output for one atom.\n * @yields `[scheme, style]` pairs in object-key order.\n */\nfunction* iterScheme(schemed: SchemedStyle): IterableIterator<[string, RNStyle]> {\n const raw = schemed as Readonly<Record<string, RNStyle | string>>\n for (const key in raw) {\n if (key === STATE_KEY) continue\n yield [key, raw[key] as RNStyle]\n }\n}\n\n/**\n * Pick the canonical style for an atom — the value that goes into\n * `common.style.js`. Prefers the parser's `base` entry (the \"default\n * when no variant matches\"); falls back to the first non-empty per-\n * scheme entry when the atom has no explicit base.\n * @param schemed Parser-produced per-scheme bucket.\n * @returns Canonical style, or undefined when every scheme is empty.\n */\nfunction canonicalValue(schemed: SchemedStyle): RNStyle | undefined {\n const baseEntry = (schemed as Readonly<Record<string, RNStyle>>)[BASE_SCHEME]\n if (isNonEmptyStyle(baseEntry)) return baseEntry\n for (const [, style] of iterScheme(schemed)) {\n if (isNonEmptyStyle(style)) return style\n }\n return undefined\n}\n\n/**\n * Collect every variant scheme name across the project's atoms. The\n * synthetic `base` scheme is excluded — it's folded into the `common`\n * output. Returns variants in sorted order for deterministic output.\n * @param resolved Parser-produced atom map.\n * @returns Variant scheme names (no `base`, no `common`).\n */\nfunction collectVariantSchemes(resolved: ReadonlyMap<string, SchemedStyle>): readonly string[] {\n const set = new Set<string>()\n for (const schemed of resolved.values()) {\n for (const [scheme] of iterScheme(schemed)) {\n if (scheme !== BASE_SCHEME) set.add(scheme)\n }\n }\n return [...set].toSorted((a, b) => a.localeCompare(b))\n}\n\n/**\n * Normalize a CSS keyframe selector to the percentage form Reanimated\n * v4 keyframes objects use.\n * @param offset Selector text (`'from'`, `'to'`, `'50%'`).\n * @returns Percentage string.\n */\nfunction offsetToPercent(offset: string): string {\n if (offset === 'from') return '0%'\n if (offset === 'to') return '100%'\n return offset\n}\n\n/**\n * Replace a string `animationName` with the inline keyframes object\n * Reanimated v4's CSS engine expects. Atoms whose `animationName`\n * doesn't match any registered keyframe keep the original string.\n * @param style RN style object (possibly carrying `animationName`).\n * @param keyframes Keyframes available to this build.\n * @returns Style with `animationName` inlined when matched.\n */\nfunction inlineAnimationName(style: RNStyle, keyframes: ReadonlyMap<string, KeyframeBlock>): RNStyle {\n const name = style.animationName\n if (typeof name !== 'string') return style\n const block = keyframes.get(name)\n if (!block) return style\n const out: RNStyle = { ...style }\n const inline: Record<string, Record<string, string | number>> = {}\n for (const step of block.steps) inline[offsetToPercent(step.offset)] = step.style as Record<string, string | number>\n out.animationName = inline as unknown as RNStyle[string]\n return out\n}\n\n/**\n * Convert any safe-area markers in the style into a precomputed spec\n * envelope. Atoms with `__safe` markers become\n * `{__safeStyle: [[cssKey, sideTag, or, offset], ...]}` — the runtime\n * resolver reads `value.__safeStyle` as a single property access and\n * resolves against live insets without walking the value's keys.\n * @param style RN style as resolved by the parser.\n * @returns Original style OR the safe-style envelope.\n */\nfunction envelopeSafeMarkers(\n style: RNStyle,\n): RNStyle | { __safeStyle: readonly (readonly [string, string, number | undefined, number | undefined])[] } {\n let specs: [string, string, number | undefined, number | undefined][] | null = null\n for (const key of Object.keys(style)) {\n const value = style[key]\n if (typeof value !== 'object' || !value) continue\n const marker = value as { __safe?: string; or?: number; offset?: number }\n if (typeof marker.__safe !== 'string') continue\n if (!specs) specs = []\n specs.push([key, marker.__safe, marker.or, marker.offset])\n }\n if (!specs) return style\n return { __safeStyle: specs }\n}\n\n/**\n * Serialise a single atom's RN style to a JS object literal. Honors\n * the `*-hairline` sentinel: numeric values get rewritten to\n * `StyleSheet.hairlineWidth` so device-density differences land in the\n * rendered border.\n * @param atomName The atom's class name (used to detect hairline).\n * @param style The atom's RN style object.\n * @returns JS object-literal source.\n */\nfunction serializeStyle(atomName: string, style: RNStyle): string {\n const json = JSON.stringify(style)\n if (!isHairlineAtom(atomName)) return json\n return json.replaceAll(/:(-?\\d+(?:\\.\\d+)?)/g, ': StyleSheet.hairlineWidth')\n}\n\n/**\n * Serialise an atom's resolved value — bare RN style object or an\n * already-enveloped safe-style value.\n * @param atomName Atom name (controls hairline rewrite).\n * @param value Atom value (bare style or `{__safeStyle: spec[]}`).\n * @returns JS source for the value.\n */\nfunction serializeAtomValue(atomName: string, value: unknown): string {\n if (typeof value === 'object' && value !== null && '__safeStyle' in value) return JSON.stringify(value)\n return serializeStyle(atomName, value as RNStyle)\n}\n\n/**\n * Resolve + envelope + serialize an atom's value under one scheme.\n * @param atomName Atom name.\n * @param style Raw RN style for this scheme.\n * @param keyframes Keyframes available to this build.\n * @returns Serialized text ready to emit.\n */\nfunction prepareAtomValue(atomName: string, style: RNStyle, keyframes: ReadonlyMap<string, KeyframeBlock>): string {\n const enveloped = envelopeSafeMarkers(inlineAnimationName(style, keyframes))\n return serializeAtomValue(atomName, enveloped)\n}\n\n/**\n * Decide which serialized atom values get hoisted to a shared `const`.\n * A value is hoisted ONLY when ≥2 atoms share it — then one\n * `const _s<N> = <value>` saves the repeated bytes AND gives those atoms\n * one shared object (reference identity). A value used once is inlined\n * directly at its atom (`\"-m-2\": {\"margin\":-8}`) — hoisting a singleton\n * would only add bytes. First-seen order keeps the const indices stable\n * across workers.\n * @param entries `[atomName, serializedValue]` pairs (atom-sorted).\n * @returns `{ constFor }` value→const-name map + `decls` source lines.\n */\nfunction planValueConsts(entries: readonly (readonly [string, string])[]): {\n constFor: ReadonlyMap<string, string>\n decls: readonly string[]\n} {\n const counts = new Map<string, number>()\n for (const [, value] of entries) counts.set(value, (counts.get(value) ?? 0) + 1)\n const constFor = new Map<string, string>()\n const decls: string[] = []\n for (const [value, count] of counts) {\n if (count < 2) continue\n const name = `_s${decls.length}`\n constFor.set(value, name)\n decls.push(`const ${name} = ${value}`)\n }\n return { constFor, decls }\n}\n\n/**\n * Serialize a scheme's molecule map into a `registerMolecules(...)` object\n * literal, sorted by className for byte-deterministic output.\n * @param molecules normalized className → pre-merged style object.\n * @returns Object-literal source (`null` when empty).\n */\nfunction serializeMolecules(molecules: Record<string, RNStyle> | undefined): string | null {\n if (!molecules) return null\n const keys = Object.keys(molecules).toSorted((a, b) => a.localeCompare(b))\n if (keys.length === 0) return null\n const body = keys.map((cn) => ` ${JSON.stringify(cn)}: ${JSON.stringify(molecules[cn])},`)\n return ['{', ...body, '}'].join('\\n')\n}\n\n/**\n * Render one scheme file's source. `entries` is the list of atoms this\n * scheme contributes — for `common` every atom's canonical value; for\n * a variant only atoms whose value differs from canonical. Hairline\n * atoms in this file trigger the `StyleSheet` import. Pre-merged\n * molecules (when present) are registered alongside the atoms so the\n * runtime resolver's molecule-first path is populated.\n * @param schemeName Registry key (`'common'` or the variant name).\n * @param entries `[atomName, serializedValue]` pairs to emit.\n * @param molecules Pre-merged className → style map for this scheme.\n * @returns JS source text.\n */\nfunction renderSchemeFile(\n schemeName: string,\n entries: readonly (readonly [string, string])[],\n molecules?: Record<string, RNStyle>,\n): string {\n const needsStyleSheet = entries.some(([atom]) => isHairlineAtom(atom))\n const { constFor, decls } = planValueConsts(entries)\n const recordLines = entries.map(([atom, value]) => ` ${JSON.stringify(atom)}: ${constFor.get(value) ?? value},`)\n const moleculeLiteral = serializeMolecules(molecules)\n\n const imports = ['registerAtoms']\n if (moleculeLiteral) imports.push('registerMolecules')\n const lines: string[] = []\n if (needsStyleSheet) lines.push(`import { StyleSheet } from 'react-native'`)\n lines.push(`import { ${imports.join(', ')} } from 'rnwind'`, ``)\n if (decls.length > 0) {\n for (const decl of decls) lines.push(decl)\n lines.push(``)\n }\n lines.push(`registerAtoms(${JSON.stringify(schemeName)}, {`, ...recordLines, `})`, ``)\n if (moleculeLiteral) lines.push(`registerMolecules(${JSON.stringify(schemeName)}, ${moleculeLiteral})`, ``)\n return lines.join('\\n')\n}\n\n/**\n * Serialize a feature map (atom name → JSON-able value: gradient info or\n * haptic request) into a stable JS object literal for the manifest.\n * Sorted by key so the output is byte-deterministic across workers.\n * @param map Atom name → feature value.\n * @returns Object-literal source.\n */\nfunction serializeFeatureMap(map: ReadonlyMap<string, unknown>): string {\n const entries = [...map.entries()].toSorted((a, b) => a[0].localeCompare(b[0]))\n const body = entries.map(([key, value]) => `${JSON.stringify(key)}: ${JSON.stringify(value)}`).join(', ')\n return `{ ${body} }`\n}\n\n/**\n * Render the JS-object literal for the responsive-breakpoint table the\n * runtime registers at manifest-load time. Sorted by ascending px\n * threshold so the runtime can build a deterministic \"tier index\" for\n * its style cache.\n * @param breakpoints Breakpoint name → px-threshold map.\n * @returns Object-literal source (`{}` when empty).\n */\nfunction serializeBreakpoints(breakpoints: ReadonlyMap<string, number>): string {\n if (breakpoints.size === 0) return '{}'\n const entries = [...breakpoints].toSorted((a, b) => a[1] - b[1] || a[0].localeCompare(b[0]))\n const inner = entries.map(([name, px]) => `${JSON.stringify(name)}: ${px}`).join(', ')\n return `{ ${inner} }`\n}\n\n/**\n * Render the manifest module. EAGER-imports `common.style.js` AND every\n * variant scheme file so every scheme's atoms register the moment the\n * manifest evaluates — no lazy `require`. Lazy loading raced the cold\n * start: `RnwindProvider` calls `loadScheme(scheme)` on its first render,\n * but on a cold boot the manifest (hence `registerSchemeLoader`) may not\n * have evaluated yet, so that call no-ops and the active variant's atoms\n * never load — scheme-dependent styles fall back to `common` (the light\n * default) until a reload. Eager imports remove the race entirely; the\n * variant files are small diffs, so the upfront cost is negligible.\n * `ensureSchemeLoaded` stays exported as a no-op for API compatibility.\n * @param variants Variant scheme names (no `base`, no `common`).\n * @param breakpoints Responsive breakpoint name → px-threshold map.\n * @param gradients Atom → gradient info for `registerGradients`.\n * @param haptics Atom → haptic request for `registerHaptics`.\n * @returns JS source text.\n */\nfunction renderManifest(\n variants: readonly string[],\n breakpoints: ReadonlyMap<string, number>,\n gradients: ReadonlyMap<string, unknown>,\n haptics: ReadonlyMap<string, unknown>,\n): string {\n const imports = ['registerSchemeLoader', 'registerBreakpoints']\n if (gradients.size > 0) imports.push('registerGradients')\n if (haptics.size > 0) imports.push('registerHaptics')\n const lines: string[] = [`import { ${imports.join(', ')} } from 'rnwind'`, `import './common.style'`]\n for (const variant of variants) lines.push(`import ${JSON.stringify(`./${variant}.style`)}`)\n lines.push(``, `registerBreakpoints(${serializeBreakpoints(breakpoints)})`)\n if (gradients.size > 0) lines.push(`registerGradients(${serializeFeatureMap(gradients)})`)\n if (haptics.size > 0) lines.push(`registerHaptics(${serializeFeatureMap(haptics)})`)\n lines.push(\n ``,\n `function ensureSchemeLoaded(_name) {}`,\n ``,\n `registerSchemeLoader(ensureSchemeLoaded)`,\n ``,\n `export { ensureSchemeLoaded }`,\n ``,\n )\n return lines.join('\\n')\n}\n\n/**\n * Whether a resolved style carries a nested safe-area marker — molecules\n * can't pre-bake these because the inset value is per-render.\n * @param style Raw resolved RN style (pre-envelope).\n * @returns True when any value is a `{__safe: ...}` marker.\n */\nfunction hasSafeMarker(style: RNStyle): boolean {\n for (const key of Object.keys(style)) {\n const value = style[key]\n if (typeof value !== 'object' || !value) continue\n if ('__safe' in value) return true\n }\n return false\n}\n\n/**\n * Whether a resolved style has font-scale-sensitive props. Molecules\n * can't pre-bake these because `fontSize`/`lineHeight` scale per-render\n * with `useWindowDimensions().fontScale`.\n * @param style Resolved RN style.\n * @returns True when `fontSize` or `lineHeight` is present.\n */\nfunction hasFontScaleProperty(style: RNStyle): boolean {\n return 'fontSize' in style || 'lineHeight' in style\n}\n\n/**\n * Whether a token is a feature-only utility (gradient stop/direction,\n * haptic, or text-truncate) that contributes NO RN `style` — the runtime\n * resolver folds these in via `attachFeatures`, so they don't disqualify\n * a molecule, they just merge nothing.\n * @param token Atom name.\n * @param gradients Gradient feature map.\n * @param haptics Haptic feature map.\n * @returns True when the token is a non-style feature.\n */\nfunction isFeatureToken(token: string, gradients: ReadonlyMap<string, unknown>, haptics: ReadonlyMap<string, unknown>): boolean {\n if (gradients.has(token) || haptics.has(token)) return true\n return token === 'truncate' || token === 'text-ellipsis' || token === 'text-clip' || token.startsWith('line-clamp-')\n}\n\n/**\n * Resolve one atom's value under a scheme: the scheme's own non-empty\n * bucket, falling back to canonical. `common` always reads canonical.\n * @param schemed Parser-produced per-scheme bucket.\n * @param scheme Scheme key (`'common'` or a variant name).\n * @returns The atom's RN style for that scheme, or undefined.\n */\nfunction schemeValueOf(schemed: SchemedStyle, scheme: string): RNStyle | undefined {\n if (scheme === COMMON_SCHEME) return canonicalValue(schemed)\n const own = (schemed as Readonly<Record<string, RNStyle>>)[scheme]\n return isNonEmptyStyle(own) ? own : canonicalValue(schemed)\n}\n\n/**\n * Pre-merge a normalized className's atoms into ONE RN style object for a\n * scheme, or null when the className is NOT molecule-eligible. A\n * className is eligible only when every token is context-independent:\n * - no variant prefix (`active:` / `focus:` / `md:` / `dark:` — anything\n * with a `:`), so scheme/state/breakpoint gating never applies,\n * - no `*-hairline`, `*-safe`, or font-scale (`fontSize`/`lineHeight`)\n * atom, whose value is resolved per-render.\n * Feature-only tokens (gradient / haptic / truncate) are skipped, not\n * disqualifying — the runtime folds them in via `attachFeatures`. Unknown\n * tokens disqualify so the atom path still surfaces the dev warning.\n * @param tokens Normalized className tokens (order preserved).\n * @param scheme Scheme key to resolve each atom under.\n * @param resolved Per-atom schemed styles.\n * @param keyframes Keyframes to inline into `animationName`.\n * @param gradients Gradient feature map.\n * @param haptics Haptic feature map.\n * @returns Merged style object, or null when not eligible.\n */\nfunction mergeMolecule(\n tokens: readonly string[],\n scheme: string,\n resolved: ReadonlyMap<string, SchemedStyle>,\n keyframes: ReadonlyMap<string, KeyframeBlock>,\n gradients: ReadonlyMap<string, unknown>,\n haptics: ReadonlyMap<string, unknown>,\n): RNStyle | null {\n const merged: RNStyle = {}\n for (const token of tokens) {\n if (token.includes(':')) return null\n if (isFeatureToken(token, gradients, haptics)) continue\n if (isHairlineAtom(token)) return null\n const schemed = resolved.get(token)\n if (!schemed) return null\n const raw = schemeValueOf(schemed, scheme)\n if (!raw) continue\n if (hasSafeMarker(raw) || hasFontScaleProperty(raw)) return null\n Object.assign(merged, inlineAnimationName(raw, keyframes))\n }\n return merged\n}\n\n/**\n * Emit each variant's molecule for one className — but only when the\n * variant's merge DIFFERS from common (runtime falls back to common).\n * @param normalized Normalized className key.\n * @param tokens Normalized className tokens.\n * @param commonText Serialized common-scheme merge for the diff check.\n * @param variants Variant scheme names.\n * @param variantMaps Mutable per-variant molecule collectors.\n * @param resolved Per-atom schemed styles.\n * @param keyframes Keyframes to inline.\n * @param gradients Gradient feature map.\n * @param haptics Haptic feature map.\n */\nfunction addVariantMolecules(\n normalized: string,\n tokens: readonly string[],\n commonText: string,\n variants: readonly string[],\n variantMaps: Record<string, Record<string, RNStyle>>,\n resolved: ReadonlyMap<string, SchemedStyle>,\n keyframes: ReadonlyMap<string, KeyframeBlock>,\n gradients: ReadonlyMap<string, unknown>,\n haptics: ReadonlyMap<string, unknown>,\n): void {\n for (const variant of variants) {\n const variantMerged = mergeMolecule(tokens, variant, resolved, keyframes, gradients, haptics)\n if (variantMerged === null) continue\n if (JSON.stringify(variantMerged) !== commonText) variantMaps[variant][normalized] = variantMerged\n }\n}\n\n/**\n * Build per-scheme molecules for every literal className the project\n * uses. Each eligible className gets a pre-merged style object under\n * `common`; a variant only carries an entry when its merge DIFFERS from\n * common (runtime falls back `molecules[scheme] ?? molecules.common`).\n * @param literals Distinct literal className strings (raw).\n * @param resolved Per-atom schemed styles.\n * @param keyframes Keyframes to inline.\n * @param variants Variant scheme names.\n * @param gradients Gradient feature map.\n * @param haptics Haptic feature map.\n * @returns scheme → (normalized className → merged style).\n */\nfunction buildMolecules(\n literals: readonly string[],\n resolved: ReadonlyMap<string, SchemedStyle>,\n keyframes: ReadonlyMap<string, KeyframeBlock>,\n variants: readonly string[],\n gradients: ReadonlyMap<string, unknown>,\n haptics: ReadonlyMap<string, unknown>,\n): Record<string, Record<string, RNStyle>> {\n const common: Record<string, RNStyle> = {}\n const variantMaps: Record<string, Record<string, RNStyle>> = {}\n for (const variant of variants) variantMaps[variant] = {}\n\n for (const literal of literals) {\n const normalized = normalizeClassName(literal)\n if (normalized.length === 0) continue\n const tokens = normalized.split(' ')\n const commonMerged = mergeMolecule(tokens, COMMON_SCHEME, resolved, keyframes, gradients, haptics)\n if (commonMerged === null) continue\n common[normalized] = commonMerged\n addVariantMolecules(normalized, tokens, JSON.stringify(commonMerged), variants, variantMaps, resolved, keyframes, gradients, haptics)\n }\n\n const out: Record<string, Record<string, RNStyle>> = { [COMMON_SCHEME]: common }\n for (const variant of variants) {\n if (Object.keys(variantMaps[variant]).length > 0) out[variant] = variantMaps[variant]\n }\n return out\n}\n\n/** Output of one build pass — one source per scheme plus the manifest. */\nexport interface BuildSchemeSourcesOutput {\n /** `<schemeName>.style.js` source per scheme. Always contains `common`. */\n readonly schemeSources: Readonly<Record<string, string>>\n /** Manifest module source (`schemes.js`). */\n readonly manifestSource: string\n /** Variant scheme names this build covers (sorted; excludes `common`). */\n readonly variants: readonly string[]\n /** Number of `prepareAtomValue` / JSON.stringify passes (cache MISSES) this call did — test telemetry. */\n readonly serializedMisses: number\n}\n\n/**\n * Per-atom cached serialized value. Canonical (common) string plus a\n * map of variant → own-serialized-string. `styleRef` is an identity\n * guard against the resolved SchemedStyle — when callers replace an\n * atom's value the ref diverges and the cache rebuilds that entry.\n */\nexport interface AtomSerializedEntry {\n styleRef: SchemedStyle\n canonical: string\n variants: Map<string, string>\n}\n\n/** Cache UnionBuilder owns across repeated writeSchemes calls. */\nexport type AtomSerializedCache = Map<string, AtomSerializedEntry>\n\n/**\n * Pre-serialize every non-empty variant value, reusing the per-atom\n * cache where present. Result drives both the scheme-uniform check\n * AND the per-variant emission loop downstream.\n * @param atom Atom name.\n * @param schemed Parser-produced schemed bucket.\n * @param variants Variant scheme names in deterministic order.\n * @param keyframes Keyframes available to inline.\n * @param cached Cached entry for this atom (when ref-stable).\n * @returns variantName → serialized text.\n */\nfunction buildVariantTexts(\n atom: string,\n schemed: SchemedStyle,\n variants: readonly string[],\n keyframes: ReadonlyMap<string, KeyframeBlock>,\n cached: AtomSerializedEntry | undefined,\n): Map<string, string> {\n const out = new Map<string, string>()\n for (const variant of variants) {\n const own = (schemed as Readonly<Record<string, RNStyle>>)[variant]\n if (!isNonEmptyStyle(own)) continue\n const text = cached?.variants.get(variant) ?? prepareAtomValue(atom, own, keyframes)\n out.set(variant, text)\n }\n return out\n}\n\n/**\n * Decide whether a (no-base) atom should be promoted to common because\n * every declared variant resolves to the same value. This is the\n * scheme-uniform case: `flex`, `p-4`, `absolute` all carry no theme\n * variables, so Phase-1 fills every variant bucket identically and\n * leaves `base` empty — without this collapse they'd be duplicated\n * across every scheme file.\n *\n * The variant-prefix check is what keeps a real scheme-gated atom\n * (`dark:bg-indigo-800`) out of common in a single-variant project\n * (where its 1 bucket would otherwise look \"uniform\" by definition).\n * @param atom Atom name (checked for `<variant>:` prefix).\n * @param variants Declared variant scheme names.\n * @param variantTexts Serialized variant values.\n * @param canonicalText Serialized canonical (common) value.\n * @returns Whether the atom is uniform across every declared variant.\n */\nfunction isSchemeUniform(\n atom: string,\n variants: readonly string[],\n variantTexts: ReadonlyMap<string, string>,\n canonicalText: string,\n): boolean {\n if (variants.length === 0 || variantTexts.size !== variants.length) return false\n if (variants.some((variant) => atom.startsWith(`${variant}:`))) return false\n for (const text of variantTexts.values()) {\n if (text !== canonicalText) return false\n }\n return true\n}\n\n/**\n * Serialize one atom's canonical + variant-diff entries, honouring the\n * per-atom cache. Returns the number of cache MISSES this atom incurred\n * (0 when canonical was cached AND every needed variant was cached;\n * 1 when anything had to be re-stringified).\n *\n * Three paths gated on whether the parser produced a non-empty `base`\n * bucket and whether the variants converge:\n * - **Themed atom (base present)**: canonical goes to `common`, each\n * variant whose own value diverges from canonical writes the diff\n * into its own scheme file. `lookupAtom` finds the variant's\n * override or falls through to common.\n * - **Scheme-uniform atom (base empty, every variant identical)**:\n * promoted to `common` once — the parser's Phase-1 fills every\n * variant bucket with the same value for utilities like `flex` /\n * `p-4` / `absolute` that don't reference theme variables.\n * - **Scheme-gated atom (base empty, prefixed name like `dark:foo`,\n * or variants diverge)**: each populated variant writes the value\n * into its own scheme file directly; common stays empty so the\n * runtime fallback can't leak the variant style into other schemes.\n * @param atom Atom name.\n * @param schemed Parser-produced schemed bucket for the atom.\n * @param canonical Canonical RN style for `common`.\n * @param variants Variant scheme names in deterministic order.\n * @param keyframes Keyframes available to inline.\n * @param commonEntries Mutable collector for `common`'s `[atom, text]` pairs.\n * @param variantEntries Mutable collector keyed by variant name.\n * @param cache Optional shared serialized-value cache.\n * @returns Number of JSON.stringify passes triggered for this atom.\n */\nfunction collectAtomEntries(\n atom: string,\n schemed: SchemedStyle,\n canonical: RNStyle,\n variants: readonly string[],\n keyframes: ReadonlyMap<string, KeyframeBlock>,\n commonEntries: (readonly [string, string])[],\n variantEntries: Record<string, (readonly [string, string])[]>,\n cache?: AtomSerializedCache,\n): number {\n const cached = cache?.get(atom)\n const hit = cached?.styleRef === schemed\n const baseEntry = (schemed as Readonly<Record<string, RNStyle>>)[BASE_SCHEME]\n const hasBase = isNonEmptyStyle(baseEntry)\n const canonicalText = hit ? cached.canonical : prepareAtomValue(atom, canonical, keyframes)\n const variantTexts = buildVariantTexts(atom, schemed, variants, keyframes, hit ? cached : undefined)\n const goesToCommon = hasBase || isSchemeUniform(atom, variants, variantTexts, canonicalText)\n\n if (goesToCommon) commonEntries.push([atom, canonicalText])\n\n const entry: AtomSerializedEntry = hit\n ? cached\n : { styleRef: schemed, canonical: canonicalText, variants: new Map(variantTexts) }\n if (!hit) cache?.set(atom, entry)\n\n for (const variant of variants) {\n const ownText = variantTexts.get(variant)\n if (ownText === undefined) continue\n if (goesToCommon && ownText === canonicalText) continue\n variantEntries[variant].push([atom, ownText])\n }\n return hit ? 0 : 1\n}\n\n/** Empty fallback when the caller didn't supply breakpoints (legacy callers, tests). */\nconst EMPTY_BREAKPOINTS: ReadonlyMap<string, number> = new Map()\n\n/**\n * Build the per-scheme style files + manifest source.\n *\n * Dedup rule (the thing that shrinks scheme files to their diff):\n * - Every atom's canonical value goes into `common.style.js`.\n * - Each variant's file emits an entry for an atom ONLY when the\n * variant's own resolved value differs from canonical. When the\n * variant inherits (parser emits an empty `{}` for that scheme) or\n * the variant's resolved value serializes identically to canonical,\n * the atom is omitted — at runtime the lookup falls through via\n * `cache.atoms[scheme]?.[atom] ?? cache.atoms.common[atom]`.\n *\n * Keyframes are inlined directly into atom values via `animationName`\n * ({@link inlineAnimationName}). Safe-area markers get pre-enveloped\n * via {@link envelopeSafeMarkers}. Hairline utilities stay bound to\n * `StyleSheet.hairlineWidth` at runtime.\n * @param atomNames All atom names (sorted).\n * @param resolved Per-atom schemed styles from the parser.\n * @param keyframes Keyframe blocks referenced by any atom.\n * @param cache Optional shared serialized-value cache.\n * @param breakpoints Responsive breakpoint name → px-threshold map. The\n * manifest emits `registerBreakpoints({...})` so the runtime can gate\n * `md:*` / `lg:*` atoms on `windowWidth`. Optional — empty when the\n * theme declares no breakpoints (legacy/test callers).\n * @param gradients Gradient feature map (atom → role/colour) for the manifest + molecule eligibility.\n * @param haptics Haptic feature map (atom → request) for the manifest + molecule eligibility.\n * @param literals Distinct literal className strings — pre-merged into\n * per-scheme molecules so the runtime resolver's O(1) molecule-first\n * path is populated. Empty for legacy/test callers (atom path only).\n * @returns Per-scheme sources, manifest source, variant list.\n */\nexport function buildSchemeSources(\n atomNames: readonly string[],\n resolved: ReadonlyMap<string, SchemedStyle>,\n keyframes: ReadonlyMap<string, KeyframeBlock>,\n cache?: AtomSerializedCache,\n breakpoints: ReadonlyMap<string, number> = EMPTY_BREAKPOINTS,\n gradients: ReadonlyMap<string, unknown> = EMPTY_FEATURE_MAP,\n haptics: ReadonlyMap<string, unknown> = EMPTY_FEATURE_MAP,\n literals: readonly string[] = EMPTY_LITERALS,\n): BuildSchemeSourcesOutput {\n const variants = collectVariantSchemes(resolved)\n const commonEntries: (readonly [string, string])[] = []\n const variantEntries: Record<string, (readonly [string, string])[]> = {}\n for (const variant of variants) variantEntries[variant] = []\n let misses = 0\n\n for (const atom of atomNames) {\n const schemed = resolved.get(atom)\n if (!schemed) continue\n const canonical = canonicalValue(schemed)\n if (!canonical) continue\n misses += collectAtomEntries(atom, schemed, canonical, variants, keyframes, commonEntries, variantEntries, cache)\n }\n\n const molecules = buildMolecules(literals, resolved, keyframes, variants, gradients, haptics)\n const schemeSources: Record<string, string> = {\n [COMMON_SCHEME]: renderSchemeFile(COMMON_SCHEME, commonEntries, molecules[COMMON_SCHEME]),\n }\n for (const variant of variants) {\n schemeSources[variant] = renderSchemeFile(variant, variantEntries[variant], molecules[variant])\n }\n\n return {\n schemeSources,\n manifestSource: renderManifest(variants, breakpoints, gradients, haptics),\n variants,\n serializedMisses: misses,\n }\n}\n\n/** Shared empty feature map default. */\nconst EMPTY_FEATURE_MAP: ReadonlyMap<string, unknown> = new Map()\n\n/** Shared empty literal-list default (atom-only callers). */\nconst EMPTY_LITERALS: readonly string[] = []\n\n/** Registry key the runtime uses for the always-loaded fallback. */\nexport const COMMON_SCHEME_NAME: string = COMMON_SCHEME\n"],"names":["normalizeClassName"],"mappings":";;;;AAGA;AACA,MAAM,aAAa,GAAG,YAAY;AAElC;AACA,MAAM,WAAW,GAAG,MAAM;AAE1B;AACA,MAAM,aAAa,GAAG,QAAQ;AAE9B;AACA,MAAM,SAAS,GAAG,SAAS;AAE3B;;;;;AAKG;AACH,SAAS,cAAc,CAAC,QAAgB,EAAA;AACtC,IAAA,OAAO,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC;AACrC;AAEA;;;;;;AAMG;AACH,SAAS,eAAe,CAAC,KAA0B,EAAA;AACjD,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,KAAK;IACxB,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC;AACtC;AAEA;;;;;AAKG;AACH,UAAU,UAAU,CAAC,OAAqB,EAAA;IACxC,MAAM,GAAG,GAAG,OAAqD;AACjE,IAAA,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE;QACrB,IAAI,GAAG,KAAK,SAAS;YAAE;QACvB,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAY,CAAC;IAClC;AACF;AAEA;;;;;;;AAOG;AACH,SAAS,cAAc,CAAC,OAAqB,EAAA;AAC3C,IAAA,MAAM,SAAS,GAAI,OAA6C,CAAC,WAAW,CAAC;IAC7E,IAAI,eAAe,CAAC,SAAS,CAAC;AAAE,QAAA,OAAO,SAAS;IAChD,KAAK,MAAM,GAAG,KAAK,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,EAAE;QAC3C,IAAI,eAAe,CAAC,KAAK,CAAC;AAAE,YAAA,OAAO,KAAK;IAC1C;AACA,IAAA,OAAO,SAAS;AAClB;AAEA;;;;;;AAMG;AACH,SAAS,qBAAqB,C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eyframeBlock, RNStyle, SchemedStyle } from '../parser'\nimport type { ThemeTables } from '../types'\nimport { normalizeClassName } from '../normalize-classname'\n\n/** Match atom names like `border-hairline`, `h-hairline`, `border-t-hairline`, etc. */\nconst HAIRLINE_ATOM = /-hairline$/\n\n/** Parser's synthetic \"no variant\" scheme — provides the canonical fallback. */\nconst BASE_SCHEME = 'base'\n\n/** Runtime registry key for the always-loaded fallback scheme. */\nconst COMMON_SCHEME = 'common'\n\n/** Sentinel key the parser sets on interactive (`active:`/`focus:`) atoms. */\nconst STATE_KEY = '__state'\n\n/**\n * Whether an atom is a `*-hairline` utility — its numeric value must be\n * rewritten as `StyleSheet.hairlineWidth` at runtime.\n * @param atomName Class name.\n * @returns True when the atom is a hairline utility.\n */\nfunction isHairlineAtom(atomName: string): boolean {\n return HAIRLINE_ATOM.test(atomName)\n}\n\n/**\n * Whether an RN style object carries any own key. The parser emits\n * empty `{}` for schemes an atom doesn't apply to; we treat those as\n * \"inherit canonical\" and don't emit an entry for that scheme.\n * @param style RN style object.\n * @returns Whether the style has content.\n */\nfunction isNonEmptyStyle(style: RNStyle | undefined): style is RNStyle {\n if (!style) return false\n return Object.keys(style).length > 0\n}\n\n/**\n * Iterate per-scheme entries from a parser-produced schemed bucket,\n * skipping the reserved `__state` metadata key.\n * @param schemed Parser output for one atom.\n * @yields `[scheme, style]` pairs in object-key order.\n */\nfunction* iterScheme(schemed: SchemedStyle): IterableIterator<[string, RNStyle]> {\n const raw = schemed as Readonly<Record<string, RNStyle | string>>\n for (const key in raw) {\n if (key === STATE_KEY) continue\n yield [key, raw[key] as RNStyle]\n }\n}\n\n/**\n * Pick the canonical style for an atom — the value that goes into\n * `common.style.js`. Prefers the parser's `base` entry (the \"default\n * when no variant matches\"); falls back to the first non-empty per-\n * scheme entry when the atom has no explicit base.\n * @param schemed Parser-produced per-scheme bucket.\n * @returns Canonical style, or undefined when every scheme is empty.\n */\nfunction canonicalValue(schemed: SchemedStyle): RNStyle | undefined {\n const baseEntry = (schemed as Readonly<Record<string, RNStyle>>)[BASE_SCHEME]\n if (isNonEmptyStyle(baseEntry)) return baseEntry\n for (const [, style] of iterScheme(schemed)) {\n if (isNonEmptyStyle(style)) return style\n }\n return undefined\n}\n\n/**\n * Collect every variant scheme name across the project's atoms. The\n * synthetic `base` scheme is excluded — it's folded into the `common`\n * output. Returns variants in sorted order for deterministic output.\n * @param resolved Parser-produced atom map.\n * @returns Variant scheme names (no `base`, no `common`).\n */\nfunction collectVariantSchemes(resolved: ReadonlyMap<string, SchemedStyle>): readonly string[] {\n const set = new Set<string>()\n for (const schemed of resolved.values()) {\n for (const [scheme] of iterScheme(schemed)) {\n if (scheme !== BASE_SCHEME) set.add(scheme)\n }\n }\n return [...set].toSorted((a, b) => a.localeCompare(b))\n}\n\n/**\n * Normalize a CSS keyframe selector to the percentage form Reanimated\n * v4 keyframes objects use.\n * @param offset Selector text (`'from'`, `'to'`, `'50%'`).\n * @returns Percentage string.\n */\nfunction offsetToPercent(offset: string): string {\n if (offset === 'from') return '0%'\n if (offset === 'to') return '100%'\n return offset\n}\n\n/**\n * Replace a string `animationName` with the inline keyframes object\n * Reanimated v4's CSS engine expects. Atoms whose `animationName`\n * doesn't match any registered keyframe keep the original string.\n * @param style RN style object (possibly carrying `animationName`).\n * @param keyframes Keyframes available to this build.\n * @returns Style with `animationName` inlined when matched.\n */\nfunction inlineAnimationName(style: RNStyle, keyframes: ReadonlyMap<string, KeyframeBlock>): RNStyle {\n const name = style.animationName\n if (typeof name !== 'string') return style\n const block = keyframes.get(name)\n if (!block) return style\n const out: RNStyle = { ...style }\n const inline: Record<string, Record<string, string | number>> = {}\n for (const step of block.steps) inline[offsetToPercent(step.offset)] = step.style as Record<string, string | number>\n out.animationName = inline as unknown as RNStyle[string]\n return out\n}\n\n/**\n * Convert any safe-area markers in the style into a precomputed spec\n * envelope. Atoms with `__safe` markers become\n * `{__safeStyle: [[cssKey, sideTag, or, offset], ...]}` — the runtime\n * resolver reads `value.__safeStyle` as a single property access and\n * resolves against live insets without walking the value's keys.\n * @param style RN style as resolved by the parser.\n * @returns Original style OR the safe-style envelope.\n */\nfunction envelopeSafeMarkers(\n style: RNStyle,\n): RNStyle | { __safeStyle: readonly (readonly [string, string, number | undefined, number | undefined])[] } {\n let specs: [string, string, number | undefined, number | undefined][] | null = null\n for (const key of Object.keys(style)) {\n const value = style[key]\n if (typeof value !== 'object' || !value) continue\n const marker = value as { __safe?: string; or?: number; offset?: number }\n if (typeof marker.__safe !== 'string') continue\n if (!specs) specs = []\n specs.push([key, marker.__safe, marker.or, marker.offset])\n }\n if (!specs) return style\n return { __safeStyle: specs }\n}\n\n/**\n * Serialise a single atom's RN style to a JS object literal. Honors\n * the `*-hairline` sentinel: numeric values get rewritten to\n * `StyleSheet.hairlineWidth` so device-density differences land in the\n * rendered border.\n * @param atomName The atom's class name (used to detect hairline).\n * @param style The atom's RN style object.\n * @returns JS object-literal source.\n */\nfunction serializeStyle(atomName: string, style: RNStyle): string {\n const json = JSON.stringify(style)\n if (!isHairlineAtom(atomName)) return json\n return json.replaceAll(/:(-?\\d+(?:\\.\\d+)?)/g, ': StyleSheet.hairlineWidth')\n}\n\n/**\n * Serialise an atom's resolved value — bare RN style object or an\n * already-enveloped safe-style value.\n * @param atomName Atom name (controls hairline rewrite).\n * @param value Atom value (bare style or `{__safeStyle: spec[]}`).\n * @returns JS source for the value.\n */\nfunction serializeAtomValue(atomName: string, value: unknown): string {\n if (typeof value === 'object' && value !== null && '__safeStyle' in value) return JSON.stringify(value)\n return serializeStyle(atomName, value as RNStyle)\n}\n\n/**\n * Resolve + envelope + serialize an atom's value under one scheme.\n * @param atomName Atom name.\n * @param style Raw RN style for this scheme.\n * @param keyframes Keyframes available to this build.\n * @returns Serialized text ready to emit.\n */\nfunction prepareAtomValue(atomName: string, style: RNStyle, keyframes: ReadonlyMap<string, KeyframeBlock>): string {\n const enveloped = envelopeSafeMarkers(inlineAnimationName(style, keyframes))\n return serializeAtomValue(atomName, enveloped)\n}\n\n/**\n * Decide which serialized atom values get hoisted to a shared `const`.\n * A value is hoisted ONLY when ≥2 atoms share it — then one\n * `const _s<N> = <value>` saves the repeated bytes AND gives those atoms\n * one shared object (reference identity). A value used once is inlined\n * directly at its atom (`\"-m-2\": {\"margin\":-8}`) — hoisting a singleton\n * would only add bytes. First-seen order keeps the const indices stable\n * across workers.\n * @param entries `[atomName, serializedValue]` pairs (atom-sorted).\n * @returns `{ constFor }` value→const-name map + `decls` source lines.\n */\nfunction planValueConsts(entries: readonly (readonly [string, string])[]): {\n constFor: ReadonlyMap<string, string>\n decls: readonly string[]\n} {\n const counts = new Map<string, number>()\n for (const [, value] of entries) counts.set(value, (counts.get(value) ?? 0) + 1)\n const constFor = new Map<string, string>()\n const decls: string[] = []\n for (const [value, count] of counts) {\n if (count < 2) continue\n const name = `_s${decls.length}`\n constFor.set(value, name)\n decls.push(`const ${name} = ${value}`)\n }\n return { constFor, decls }\n}\n\n/**\n * Serialize a scheme's molecule map into a `registerMolecules(...)` object\n * literal, sorted by className for byte-deterministic output.\n * @param molecules normalized className → pre-merged style object.\n * @returns Object-literal source (`null` when empty).\n */\nfunction serializeMolecules(molecules: Record<string, RNStyle> | undefined): string | null {\n if (!molecules) return null\n const keys = Object.keys(molecules).toSorted((a, b) => a.localeCompare(b))\n if (keys.length === 0) return null\n const body = keys.map((cn) => ` ${JSON.stringify(cn)}: ${JSON.stringify(molecules[cn])},`)\n return ['{', ...body, '}'].join('\\n')\n}\n\n/**\n * Render one scheme file's source. `entries` is the list of atoms this\n * scheme contributes — for `common` every atom's canonical value; for\n * a variant only atoms whose value differs from canonical. Hairline\n * atoms in this file trigger the `StyleSheet` import. Pre-merged\n * molecules (when present) are registered alongside the atoms so the\n * runtime resolver's molecule-first path is populated.\n * @param schemeName Registry key (`'common'` or the variant name).\n * @param entries `[atomName, serializedValue]` pairs to emit.\n * @param molecules Pre-merged className → style map for this scheme.\n * @returns JS source text.\n */\nfunction renderSchemeFile(\n schemeName: string,\n entries: readonly (readonly [string, string])[],\n molecules?: Record<string, RNStyle>,\n): string {\n const needsStyleSheet = entries.some(([atom]) => isHairlineAtom(atom))\n const { constFor, decls } = planValueConsts(entries)\n const recordLines = entries.map(([atom, value]) => ` ${JSON.stringify(atom)}: ${constFor.get(value) ?? value},`)\n const moleculeLiteral = serializeMolecules(molecules)\n\n const imports = ['registerAtoms']\n if (moleculeLiteral) imports.push('registerMolecules')\n const lines: string[] = []\n if (needsStyleSheet) lines.push(`import { StyleSheet } from 'react-native'`)\n lines.push(`import { ${imports.join(', ')} } from 'rnwind'`, ``)\n if (decls.length > 0) {\n for (const decl of decls) lines.push(decl)\n lines.push(``)\n }\n lines.push(`registerAtoms(${JSON.stringify(schemeName)}, {`, ...recordLines, `})`, ``)\n if (moleculeLiteral) lines.push(`registerMolecules(${JSON.stringify(schemeName)}, ${moleculeLiteral})`, ``)\n return lines.join('\\n')\n}\n\n/**\n * Serialize a feature map (atom name → JSON-able value: gradient info or\n * haptic request) into a stable JS object literal for the manifest.\n * Sorted by key so the output is byte-deterministic across workers.\n * @param map Atom name → feature value.\n * @returns Object-literal source.\n */\nfunction serializeFeatureMap(map: ReadonlyMap<string, unknown>): string {\n const entries = [...map.entries()].toSorted((a, b) => a[0].localeCompare(b[0]))\n const body = entries.map(([key, value]) => `${JSON.stringify(key)}: ${JSON.stringify(value)}`).join(', ')\n return `{ ${body} }`\n}\n\n/**\n * Render the JS-object literal for the responsive-breakpoint table the\n * runtime registers at manifest-load time. Sorted by ascending px\n * threshold so the runtime can build a deterministic \"tier index\" for\n * its style cache.\n * @param breakpoints Breakpoint name → px-threshold map.\n * @returns Object-literal source (`{}` when empty).\n */\nfunction serializeBreakpoints(breakpoints: ReadonlyMap<string, number>): string {\n if (breakpoints.size === 0) return '{}'\n const entries = [...breakpoints].toSorted((a, b) => a[1] - b[1] || a[0].localeCompare(b[0]))\n const inner = entries.map(([name, px]) => `${JSON.stringify(name)}: ${px}`).join(', ')\n return `{ ${inner} }`\n}\n\n/**\n * Render the manifest module. EAGER-imports `common.style.js` AND every\n * variant scheme file so every scheme's atoms register the moment the\n * manifest evaluates — no lazy `require`. Lazy loading raced the cold\n * start: `RnwindProvider` calls `loadScheme(scheme)` on its first render,\n * but on a cold boot the manifest (hence `registerSchemeLoader`) may not\n * have evaluated yet, so that call no-ops and the active variant's atoms\n * never load — scheme-dependent styles fall back to `common` (the light\n * default) until a reload. Eager imports remove the race entirely; the\n * variant files are small diffs, so the upfront cost is negligible.\n * `ensureSchemeLoaded` stays exported as a no-op for API compatibility.\n * @param variants Variant scheme names (no `base`, no `common`).\n * @param breakpoints Responsive breakpoint name → px-threshold map.\n * @param gradients Atom → gradient info for `registerGradients`.\n * @param haptics Atom → haptic request for `registerHaptics`.\n * @param themeTokens\n * @returns JS source text.\n */\nfunction renderManifest(\n variants: readonly string[],\n breakpoints: ReadonlyMap<string, number>,\n gradients: ReadonlyMap<string, unknown>,\n haptics: ReadonlyMap<string, unknown>,\n themeTokens: ThemeTables,\n): string {\n const hasTokens = Object.keys(themeTokens).length > 0\n const imports = ['registerSchemeLoader', 'registerBreakpoints']\n if (gradients.size > 0) imports.push('registerGradients')\n if (haptics.size > 0) imports.push('registerHaptics')\n if (hasTokens) imports.push('registerThemeTokens')\n const lines: string[] = [`import { ${imports.join(', ')} } from 'rnwind'`, `import './common.style'`]\n for (const variant of variants) lines.push(`import ${JSON.stringify(`./${variant}.style`)}`)\n lines.push(``, `registerBreakpoints(${serializeBreakpoints(breakpoints)})`)\n if (gradients.size > 0) lines.push(`registerGradients(${serializeFeatureMap(gradients)})`)\n if (haptics.size > 0) lines.push(`registerHaptics(${serializeFeatureMap(haptics)})`)\n if (hasTokens) lines.push(`registerThemeTokens(${JSON.stringify(themeTokens)})`)\n lines.push(\n ``,\n `function ensureSchemeLoaded(_name) {}`,\n ``,\n `registerSchemeLoader(ensureSchemeLoaded)`,\n ``,\n `export { ensureSchemeLoaded }`,\n ``,\n )\n return lines.join('\\n')\n}\n\n/**\n * Whether a resolved style carries a nested safe-area marker — molecules\n * can't pre-bake these because the inset value is per-render.\n * @param style Raw resolved RN style (pre-envelope).\n * @returns True when any value is a `{__safe: ...}` marker.\n */\nfunction hasSafeMarker(style: RNStyle): boolean {\n for (const key of Object.keys(style)) {\n const value = style[key]\n if (typeof value !== 'object' || !value) continue\n if ('__safe' in value) return true\n }\n return false\n}\n\n/**\n * Whether a resolved style has font-scale-sensitive props. Molecules\n * can't pre-bake these because `fontSize`/`lineHeight` scale per-render\n * with `useWindowDimensions().fontScale`.\n * @param style Resolved RN style.\n * @returns True when `fontSize` or `lineHeight` is present.\n */\nfunction hasFontScaleProperty(style: RNStyle): boolean {\n return 'fontSize' in style || 'lineHeight' in style\n}\n\n/**\n * Whether a token is a feature-only utility (gradient stop/direction,\n * haptic, or text-truncate) that contributes NO RN `style` — the runtime\n * resolver folds these in via `attachFeatures`, so they don't disqualify\n * a molecule, they just merge nothing.\n * @param token Atom name.\n * @param gradients Gradient feature map.\n * @param haptics Haptic feature map.\n * @returns True when the token is a non-style feature.\n */\nfunction isFeatureToken(token: string, gradients: ReadonlyMap<string, unknown>, haptics: ReadonlyMap<string, unknown>): boolean {\n if (gradients.has(token) || haptics.has(token)) return true\n return token === 'truncate' || token === 'text-ellipsis' || token === 'text-clip' || token.startsWith('line-clamp-')\n}\n\n/**\n * Resolve one atom's value under a scheme: the scheme's own non-empty\n * bucket, falling back to canonical. `common` always reads canonical.\n * @param schemed Parser-produced per-scheme bucket.\n * @param scheme Scheme key (`'common'` or a variant name).\n * @returns The atom's RN style for that scheme, or undefined.\n */\nfunction schemeValueOf(schemed: SchemedStyle, scheme: string): RNStyle | undefined {\n if (scheme === COMMON_SCHEME) return canonicalValue(schemed)\n const own = (schemed as Readonly<Record<string, RNStyle>>)[scheme]\n return isNonEmptyStyle(own) ? own : canonicalValue(schemed)\n}\n\n/**\n * Pre-merge a normalized className's atoms into ONE RN style object for a\n * scheme, or null when the className is NOT molecule-eligible. A\n * className is eligible only when every token is context-independent:\n * - no variant prefix (`active:` / `focus:` / `md:` / `dark:` — anything\n * with a `:`), so scheme/state/breakpoint gating never applies,\n * - no `*-hairline`, `*-safe`, or font-scale (`fontSize`/`lineHeight`)\n * atom, whose value is resolved per-render.\n * Feature-only tokens (gradient / haptic / truncate) are skipped, not\n * disqualifying — the runtime folds them in via `attachFeatures`. Unknown\n * tokens disqualify so the atom path still surfaces the dev warning.\n * @param tokens Normalized className tokens (order preserved).\n * @param scheme Scheme key to resolve each atom under.\n * @param resolved Per-atom schemed styles.\n * @param keyframes Keyframes to inline into `animationName`.\n * @param gradients Gradient feature map.\n * @param haptics Haptic feature map.\n * @returns Merged style object, or null when not eligible.\n */\nfunction mergeMolecule(\n tokens: readonly string[],\n scheme: string,\n resolved: ReadonlyMap<string, SchemedStyle>,\n keyframes: ReadonlyMap<string, KeyframeBlock>,\n gradients: ReadonlyMap<string, unknown>,\n haptics: ReadonlyMap<string, unknown>,\n): RNStyle | null {\n const merged: RNStyle = {}\n for (const token of tokens) {\n if (token.includes(':')) return null\n if (isFeatureToken(token, gradients, haptics)) continue\n if (isHairlineAtom(token)) return null\n const schemed = resolved.get(token)\n if (!schemed) return null\n const raw = schemeValueOf(schemed, scheme)\n if (!raw) continue\n if (hasSafeMarker(raw) || hasFontScaleProperty(raw)) return null\n Object.assign(merged, inlineAnimationName(raw, keyframes))\n }\n return merged\n}\n\n/**\n * Emit each variant's molecule for one className — but only when the\n * variant's merge DIFFERS from common (runtime falls back to common).\n * @param normalized Normalized className key.\n * @param tokens Normalized className tokens.\n * @param commonText Serialized common-scheme merge for the diff check.\n * @param variants Variant scheme names.\n * @param variantMaps Mutable per-variant molecule collectors.\n * @param resolved Per-atom schemed styles.\n * @param keyframes Keyframes to inline.\n * @param gradients Gradient feature map.\n * @param haptics Haptic feature map.\n */\nfunction addVariantMolecules(\n normalized: string,\n tokens: readonly string[],\n commonText: string,\n variants: readonly string[],\n variantMaps: Record<string, Record<string, RNStyle>>,\n resolved: ReadonlyMap<string, SchemedStyle>,\n keyframes: ReadonlyMap<string, KeyframeBlock>,\n gradients: ReadonlyMap<string, unknown>,\n haptics: ReadonlyMap<string, unknown>,\n): void {\n for (const variant of variants) {\n const variantMerged = mergeMolecule(tokens, variant, resolved, keyframes, gradients, haptics)\n if (variantMerged === null) continue\n if (JSON.stringify(variantMerged) !== commonText) variantMaps[variant][normalized] = variantMerged\n }\n}\n\n/**\n * Build per-scheme molecules for every literal className the project\n * uses. Each eligible className gets a pre-merged style object under\n * `common`; a variant only carries an entry when its merge DIFFERS from\n * common (runtime falls back `molecules[scheme] ?? molecules.common`).\n * @param literals Distinct literal className strings (raw).\n * @param resolved Per-atom schemed styles.\n * @param keyframes Keyframes to inline.\n * @param variants Variant scheme names.\n * @param gradients Gradient feature map.\n * @param haptics Haptic feature map.\n * @returns scheme → (normalized className → merged style).\n */\nfunction buildMolecules(\n literals: readonly string[],\n resolved: ReadonlyMap<string, SchemedStyle>,\n keyframes: ReadonlyMap<string, KeyframeBlock>,\n variants: readonly string[],\n gradients: ReadonlyMap<string, unknown>,\n haptics: ReadonlyMap<string, unknown>,\n): Record<string, Record<string, RNStyle>> {\n const common: Record<string, RNStyle> = {}\n const variantMaps: Record<string, Record<string, RNStyle>> = {}\n for (const variant of variants) variantMaps[variant] = {}\n\n for (const literal of literals) {\n const normalized = normalizeClassName(literal)\n if (normalized.length === 0) continue\n const tokens = normalized.split(' ')\n const commonMerged = mergeMolecule(tokens, COMMON_SCHEME, resolved, keyframes, gradients, haptics)\n if (commonMerged === null) continue\n common[normalized] = commonMerged\n addVariantMolecules(normalized, tokens, JSON.stringify(commonMerged), variants, variantMaps, resolved, keyframes, gradients, haptics)\n }\n\n const out: Record<string, Record<string, RNStyle>> = { [COMMON_SCHEME]: common }\n for (const variant of variants) {\n if (Object.keys(variantMaps[variant]).length > 0) out[variant] = variantMaps[variant]\n }\n return out\n}\n\n/** Output of one build pass — one source per scheme plus the manifest. */\nexport interface BuildSchemeSourcesOutput {\n /** `<schemeName>.style.js` source per scheme. Always contains `common`. */\n readonly schemeSources: Readonly<Record<string, string>>\n /** Manifest module source (`schemes.js`). */\n readonly manifestSource: string\n /** Variant scheme names this build covers (sorted; excludes `common`). */\n readonly variants: readonly string[]\n /** Number of `prepareAtomValue` / JSON.stringify passes (cache MISSES) this call did — test telemetry. */\n readonly serializedMisses: number\n}\n\n/**\n * Per-atom cached serialized value. Canonical (common) string plus a\n * map of variant → own-serialized-string. `styleRef` is an identity\n * guard against the resolved SchemedStyle — when callers replace an\n * atom's value the ref diverges and the cache rebuilds that entry.\n */\nexport interface AtomSerializedEntry {\n styleRef: SchemedStyle\n canonical: string\n variants: Map<string, string>\n}\n\n/** Cache UnionBuilder owns across repeated writeSchemes calls. */\nexport type AtomSerializedCache = Map<string, AtomSerializedEntry>\n\n/**\n * Pre-serialize every non-empty variant value, reusing the per-atom\n * cache where present. Result drives both the scheme-uniform check\n * AND the per-variant emission loop downstream.\n * @param atom Atom name.\n * @param schemed Parser-produced schemed bucket.\n * @param variants Variant scheme names in deterministic order.\n * @param keyframes Keyframes available to inline.\n * @param cached Cached entry for this atom (when ref-stable).\n * @returns variantName → serialized text.\n */\nfunction buildVariantTexts(\n atom: string,\n schemed: SchemedStyle,\n variants: readonly string[],\n keyframes: ReadonlyMap<string, KeyframeBlock>,\n cached: AtomSerializedEntry | undefined,\n): Map<string, string> {\n const out = new Map<string, string>()\n for (const variant of variants) {\n const own = (schemed as Readonly<Record<string, RNStyle>>)[variant]\n if (!isNonEmptyStyle(own)) continue\n const text = cached?.variants.get(variant) ?? prepareAtomValue(atom, own, keyframes)\n out.set(variant, text)\n }\n return out\n}\n\n/**\n * Decide whether a (no-base) atom should be promoted to common because\n * every declared variant resolves to the same value. This is the\n * scheme-uniform case: `flex`, `p-4`, `absolute` all carry no theme\n * variables, so Phase-1 fills every variant bucket identically and\n * leaves `base` empty — without this collapse they'd be duplicated\n * across every scheme file.\n *\n * The variant-prefix check is what keeps a real scheme-gated atom\n * (`dark:bg-indigo-800`) out of common in a single-variant project\n * (where its 1 bucket would otherwise look \"uniform\" by definition).\n * @param atom Atom name (checked for `<variant>:` prefix).\n * @param variants Declared variant scheme names.\n * @param variantTexts Serialized variant values.\n * @param canonicalText Serialized canonical (common) value.\n * @returns Whether the atom is uniform across every declared variant.\n */\nfunction isSchemeUniform(\n atom: string,\n variants: readonly string[],\n variantTexts: ReadonlyMap<string, string>,\n canonicalText: string,\n): boolean {\n if (variants.length === 0 || variantTexts.size !== variants.length) return false\n if (variants.some((variant) => atom.startsWith(`${variant}:`))) return false\n for (const text of variantTexts.values()) {\n if (text !== canonicalText) return false\n }\n return true\n}\n\n/**\n * Serialize one atom's canonical + variant-diff entries, honouring the\n * per-atom cache. Returns the number of cache MISSES this atom incurred\n * (0 when canonical was cached AND every needed variant was cached;\n * 1 when anything had to be re-stringified).\n *\n * Three paths gated on whether the parser produced a non-empty `base`\n * bucket and whether the variants converge:\n * - **Themed atom (base present)**: canonical goes to `common`, each\n * variant whose own value diverges from canonical writes the diff\n * into its own scheme file. `lookupAtom` finds the variant's\n * override or falls through to common.\n * - **Scheme-uniform atom (base empty, every variant identical)**:\n * promoted to `common` once — the parser's Phase-1 fills every\n * variant bucket with the same value for utilities like `flex` /\n * `p-4` / `absolute` that don't reference theme variables.\n * - **Scheme-gated atom (base empty, prefixed name like `dark:foo`,\n * or variants diverge)**: each populated variant writes the value\n * into its own scheme file directly; common stays empty so the\n * runtime fallback can't leak the variant style into other schemes.\n * @param atom Atom name.\n * @param schemed Parser-produced schemed bucket for the atom.\n * @param canonical Canonical RN style for `common`.\n * @param variants Variant scheme names in deterministic order.\n * @param keyframes Keyframes available to inline.\n * @param commonEntries Mutable collector for `common`'s `[atom, text]` pairs.\n * @param variantEntries Mutable collector keyed by variant name.\n * @param cache Optional shared serialized-value cache.\n * @returns Number of JSON.stringify passes triggered for this atom.\n */\nfunction collectAtomEntries(\n atom: string,\n schemed: SchemedStyle,\n canonical: RNStyle,\n variants: readonly string[],\n keyframes: ReadonlyMap<string, KeyframeBlock>,\n commonEntries: (readonly [string, string])[],\n variantEntries: Record<string, (readonly [string, string])[]>,\n cache?: AtomSerializedCache,\n): number {\n const cached = cache?.get(atom)\n const hit = cached?.styleRef === schemed\n const baseEntry = (schemed as Readonly<Record<string, RNStyle>>)[BASE_SCHEME]\n const hasBase = isNonEmptyStyle(baseEntry)\n const canonicalText = hit ? cached.canonical : prepareAtomValue(atom, canonical, keyframes)\n const variantTexts = buildVariantTexts(atom, schemed, variants, keyframes, hit ? cached : undefined)\n const goesToCommon = hasBase || isSchemeUniform(atom, variants, variantTexts, canonicalText)\n\n if (goesToCommon) commonEntries.push([atom, canonicalText])\n\n const entry: AtomSerializedEntry = hit\n ? cached\n : { styleRef: schemed, canonical: canonicalText, variants: new Map(variantTexts) }\n if (!hit) cache?.set(atom, entry)\n\n for (const variant of variants) {\n const ownText = variantTexts.get(variant)\n if (ownText === undefined) continue\n if (goesToCommon && ownText === canonicalText) continue\n variantEntries[variant].push([atom, ownText])\n }\n return hit ? 0 : 1\n}\n\n/** Empty fallback when the caller didn't supply breakpoints (legacy callers, tests). */\nconst EMPTY_BREAKPOINTS: ReadonlyMap<string, number> = new Map()\n\n/**\n * Build the per-scheme style files + manifest source.\n *\n * Dedup rule (the thing that shrinks scheme files to their diff):\n * - Every atom's canonical value goes into `common.style.js`.\n * - Each variant's file emits an entry for an atom ONLY when the\n * variant's own resolved value differs from canonical. When the\n * variant inherits (parser emits an empty `{}` for that scheme) or\n * the variant's resolved value serializes identically to canonical,\n * the atom is omitted — at runtime the lookup falls through via\n * `cache.atoms[scheme]?.[atom] ?? cache.atoms.common[atom]`.\n *\n * Keyframes are inlined directly into atom values via `animationName`\n * ({@link inlineAnimationName}). Safe-area markers get pre-enveloped\n * via {@link envelopeSafeMarkers}. Hairline utilities stay bound to\n * `StyleSheet.hairlineWidth` at runtime.\n * @param atomNames All atom names (sorted).\n * @param resolved Per-atom schemed styles from the parser.\n * @param keyframes Keyframe blocks referenced by any atom.\n * @param cache Optional shared serialized-value cache.\n * @param breakpoints Responsive breakpoint name → px-threshold map. The\n * manifest emits `registerBreakpoints({...})` so the runtime can gate\n * `md:*` / `lg:*` atoms on `windowWidth`. Optional — empty when the\n * theme declares no breakpoints (legacy/test callers).\n * @param gradients Gradient feature map (atom → role/colour) for the manifest + molecule eligibility.\n * @param haptics Haptic feature map (atom → request) for the manifest + molecule eligibility.\n * @param literals Distinct literal className strings — pre-merged into\n * per-scheme molecules so the runtime resolver's O(1) molecule-first\n * path is populated. Empty for legacy/test callers (atom path only).\n * @param themeTokens\n * @returns Per-scheme sources, manifest source, variant list.\n */\nexport function buildSchemeSources(\n atomNames: readonly string[],\n resolved: ReadonlyMap<string, SchemedStyle>,\n keyframes: ReadonlyMap<string, KeyframeBlock>,\n cache?: AtomSerializedCache,\n breakpoints: ReadonlyMap<string, number> = EMPTY_BREAKPOINTS,\n gradients: ReadonlyMap<string, unknown> = EMPTY_FEATURE_MAP,\n haptics: ReadonlyMap<string, unknown> = EMPTY_FEATURE_MAP,\n literals: readonly string[] = EMPTY_LITERALS,\n themeTokens: ThemeTables = EMPTY_THEME_TOKENS,\n): BuildSchemeSourcesOutput {\n const variants = collectVariantSchemes(resolved)\n const commonEntries: (readonly [string, string])[] = []\n const variantEntries: Record<string, (readonly [string, string])[]> = {}\n for (const variant of variants) variantEntries[variant] = []\n let misses = 0\n\n for (const atom of atomNames) {\n const schemed = resolved.get(atom)\n if (!schemed) continue\n const canonical = canonicalValue(schemed)\n if (!canonical) continue\n misses += collectAtomEntries(atom, schemed, canonical, variants, keyframes, commonEntries, variantEntries, cache)\n }\n\n const molecules = buildMolecules(literals, resolved, keyframes, variants, gradients, haptics)\n const schemeSources: Record<string, string> = {\n [COMMON_SCHEME]: renderSchemeFile(COMMON_SCHEME, commonEntries, molecules[COMMON_SCHEME]),\n }\n for (const variant of variants) {\n schemeSources[variant] = renderSchemeFile(variant, variantEntries[variant], molecules[variant])\n }\n\n return {\n schemeSources,\n manifestSource: renderManifest(variants, breakpoints, gradients, haptics, themeTokens),\n variants,\n serializedMisses: misses,\n }\n}\n\n/** Shared empty feature map default. */\nconst EMPTY_FEATURE_MAP: ReadonlyMap<string, unknown> = new Map()\n\n/** Shared empty literal-list default (atom-only callers). */\nconst EMPTY_LITERALS: readonly string[] = []\n\n/** Shared empty theme-token default (callers without theme tokens). */\nconst EMPTY_THEME_TOKENS: ThemeTables = {}\n\n/** Registry key the runtime uses for the always-loaded fallback. */\nexport const COMMON_SCHEME_NAME: string = COMMON_SCHEME\n"],"names":["normalizeClassName"],"mappings":";;;;AAIA;AACA,MAAM,aAAa,GAAG,YAAY;AAElC;AACA,MAAM,WAAW,GAAG,MAAM;AAE1B;AACA,MAAM,aAAa,GAAG,QAAQ;AAE9B;AACA,MAAM,SAAS,GAAG,SAAS;AAE3B;;;;;AAKG;AACH,SAAS,cAAc,CAAC,QAAgB,EAAA;AACtC,IAAA,OAAO,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC;AACrC;AAEA;;;;;;AAMG;AACH,SAAS,eAAe,CAAC,KAA0B,EAAA;AACjD,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,KAAK;IACxB,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC;AACtC;AAEA;;;;;AAKG;AACH,UAAU,UAAU,CAAC,OAAqB,EAAA;IACxC,MAAM,GAAG,GAAG,OAAqD;AACjE,IAAA,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE;QACrB,IAAI,GAAG,KAAK,SAAS;YAAE;QACvB,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAY,CAAC;IAClC;AACF;AAEA;;;;;;;AAOG;AACH,SAAS,cAAc,CAAC,OAAqB,EAAA;AAC3C,IAAA,MAAM,SAAS,GAAI,OAA6C,CAAC,WAAW,CAAC;IAC7E,IAAI,eAAe,CAAC,SAAS,CAAC;AAAE,QAAA,OAAO,SAAS;IAChD,KAAK,MAAM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,CAAC,aAAa,CAAC,CAAC;KAC1F;AACD,IAAA,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;AAC9B,QAAA,aAAa,CAAC,OAAO,CAAC,GAAG,gBAAgB,CAAC,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IACjG;IAEA,OAAO;QACL,aAAa;AACb,QAAA,cAAc,EAAE,cAAc,CAAC,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,CAAC;QACtF,QAAQ;AACR,QAAA,gBAAgB,EAAE,MAAM;KACzB;AACH;AAEA;AACA,MAAM,iBAAiB,GAAiC,IAAI,GAAG,EAAE;AAEjE;AACA,MAAM,cAAc,GAAsB,EAAE;AAE5C;AACA,MAAM,kBAAkB,GAAgB,EAAE;;;;"}
@@ -1,4 +1,5 @@
1
1
  import type { KeyframeBlock, SchemedStyle } from '../parser';
2
+ import type { ThemeTables } from '../types';
2
3
  /** Output of one build pass — one source per scheme plus the manifest. */
3
4
  export interface BuildSchemeSourcesOutput {
4
5
  /** `<schemeName>.style.js` source per scheme. Always contains `common`. */
@@ -52,8 +53,9 @@ export type AtomSerializedCache = Map<string, AtomSerializedEntry>;
52
53
  * @param literals Distinct literal className strings — pre-merged into
53
54
  * per-scheme molecules so the runtime resolver's O(1) molecule-first
54
55
  * path is populated. Empty for legacy/test callers (atom path only).
56
+ * @param themeTokens
55
57
  * @returns Per-scheme sources, manifest source, variant list.
56
58
  */
57
- export declare function buildSchemeSources(atomNames: readonly string[], resolved: ReadonlyMap<string, SchemedStyle>, keyframes: ReadonlyMap<string, KeyframeBlock>, cache?: AtomSerializedCache, breakpoints?: ReadonlyMap<string, number>, gradients?: ReadonlyMap<string, unknown>, haptics?: ReadonlyMap<string, unknown>, literals?: readonly string[]): BuildSchemeSourcesOutput;
59
+ export declare function buildSchemeSources(atomNames: readonly string[], resolved: ReadonlyMap<string, SchemedStyle>, keyframes: ReadonlyMap<string, KeyframeBlock>, cache?: AtomSerializedCache, breakpoints?: ReadonlyMap<string, number>, gradients?: ReadonlyMap<string, unknown>, haptics?: ReadonlyMap<string, unknown>, literals?: readonly string[], themeTokens?: ThemeTables): BuildSchemeSourcesOutput;
58
60
  /** Registry key the runtime uses for the always-loaded fallback. */
59
61
  export declare const COMMON_SCHEME_NAME: string;
@@ -112,6 +112,13 @@ class UnionBuilder {
112
112
  * snapshot is sufficient.
113
113
  */
114
114
  breakpoints = new Map();
115
+ /**
116
+ * Per-scheme theme token tables captured from the parser. Refreshed on
117
+ * every `recordFile` / `ensureProjectScanned` so theme-token edits land in
118
+ * the manifest's `registerThemeTokens({...})` — the data source for
119
+ * `useColor` / `useToken` / `useSize`.
120
+ */
121
+ themeTokens = {};
115
122
  /** file → set of atom names this file currently contributes. */
116
123
  fileAtomSets = new Map();
117
124
  /** atom name → how many files currently contribute it (refcount). */
@@ -175,6 +182,7 @@ class UnionBuilder {
175
182
  for (const [name, haptic] of parsed.hapticAtoms)
176
183
  this.unionHaptics.set(name, haptic);
177
184
  this.breakpoints = parsed.breakpoints;
185
+ this.themeTokens = parsed.themeTokens;
178
186
  this.projectScanned = true;
179
187
  })();
180
188
  try {
@@ -268,7 +276,7 @@ class UnionBuilder {
268
276
  async writeSchemes() {
269
277
  await this.ensureProjectScanned();
270
278
  const sortedAtomNames = [...this.unionAtoms.keys()].toSorted((a, b) => a.localeCompare(b));
271
- const result = buildStyle.buildSchemeSources(sortedAtomNames, this.unionAtoms, this.unionKeyframes, this.serializedCache, this.breakpoints, this.unionGradients, this.unionHaptics, [...this.unionLiterals]);
279
+ const result = buildStyle.buildSchemeSources(sortedAtomNames, this.unionAtoms, this.unionKeyframes, this.serializedCache, this.breakpoints, this.unionGradients, this.unionHaptics, [...this.unionLiterals], this.themeTokens);
272
280
  this.serializedMissesCount += result.serializedMisses;
273
281
  const { schemeSources, manifestSource } = result;
274
282
  const changed = [];
@@ -1 +1 @@
1
- {"version":3,"file":"union-builder.cjs","sources":["../../../../../src/core/style-builder/union-builder.ts"],"sourcesContent":["import { createHash, randomBytes } from 'node:crypto'\nimport { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs'\nimport path from 'node:path'\nimport type { GradientAtomInfo, HapticRequest, KeyframeBlock, SchemedStyle, TailwindParser } from '../parser'\nimport { buildSchemeSources, type AtomSerializedCache } from './build-style'\n\n/** Manifest module basename — the file SchemeProvider imports via the resolver. */\nconst MANIFEST_BASENAME = 'schemes.js'\n\n/**\n * Atomic file write — stage to a `.tmp.<pid>.<nonce>` sibling, then\n * `rename()` into place. Skips the write entirely when the existing\n * content matches.\n * @param target Final destination path.\n * @param content Bytes to write.\n * @returns Whether the file was actually rewritten.\n */\nfunction writeIfChanged(target: string, content: string): boolean {\n if (existsSync(target)) {\n try {\n if (readFileSync(target, 'utf8') === content) return false\n } catch {\n // Unreadable — fall through to rewrite.\n }\n }\n mkdirSync(path.dirname(target), { recursive: true })\n const temporary = `${target}.${process.pid}.${randomBytes(4).toString('hex')}.tmp`\n try {\n writeFileSync(temporary, content, 'utf8')\n renameSync(temporary, target)\n return true\n } catch (error) {\n rmSync(temporary, { force: true })\n throw error\n }\n}\n\n/**\n * SHA-256 prefix of a string — cheap signature used to detect whether a\n * per-scheme file's source has changed since the last write.\n * @param text Input text.\n * @returns 16-char hex digest.\n */\nfunction signatureOf(text: string): string {\n return createHash('sha256').update(text).digest('hex').slice(0, 16)\n}\n\n/**\n * Compare two `Set<string>`s for equality — same size + every element\n * of `a` present in `b`.\n * @param a First set.\n * @param b Second set.\n * @returns Whether the two sets contain identical values.\n */\nfunction setsEqual(a: ReadonlySet<string>, b: ReadonlySet<string>): boolean {\n if (a.size !== b.size) return false\n for (const v of a) if (!b.has(v)) return false\n return true\n}\n\n/**\n * Compute the absolute path of a per-scheme style file under the cache dir.\n * @param cacheDir Absolute cache directory.\n * @param scheme Registry key (`'common'` or a variant name).\n * @returns Absolute path, e.g. `<cacheDir>/dark.style.js`.\n */\nfunction schemeFilePath(cacheDir: string, scheme: string): string {\n return path.join(cacheDir, `${scheme}.style.js`)\n}\n\n/**\n * In-memory atom union + per-scheme style-file emitter.\n *\n * Correctness under multi-worker Metro relies on `ensureProjectScanned`:\n * the FIRST `recordFile` / `writeSchemes` call in every worker drives\n * the oxide Scanner across ALL project sources and hydrates the union\n * with the complete set of candidates. Subsequent per-file\n * `recordFile` calls only layer in atoms the scan already knew about,\n * so writes are idempotent — different workers can't clobber each\n * other's scheme files with partial views.\n *\n * Per-file deltas (atom set unchanged → early return) skip\n * serialization entirely. On a theme-CSS change, `getRnwindState`\n * builds a fresh parser + builder; the next call re-runs\n * `ensureProjectScanned` against the new parser, producing scheme\n * files with the new theme values.\n */\nclass UnionBuilder {\n private readonly cacheDir: string\n private readonly parser: TailwindParser\n private readonly unionAtoms = new Map<string, SchemedStyle>()\n private readonly unionKeyframes = new Map<string, KeyframeBlock>()\n /** atom name → gradient role/colour, surfaced into the manifest's `registerGradients`. */\n private readonly unionGradients = new Map<string, GradientAtomInfo>()\n /** atom name → haptic request, surfaced into the manifest's `registerHaptics`. */\n private readonly unionHaptics = new Map<string, HapticRequest>()\n /**\n * Distinct literal className strings seen across all files, pre-merged\n * into per-scheme molecules at write time. Accumulate-only (like\n * `unionAtoms`): orphaned literals just yield unused molecules and get\n * reaped on the next cold start, so no refcount is needed.\n */\n private readonly unionLiterals = new Set<string>()\n /**\n * Responsive breakpoints captured from the parser. Refreshed on every\n * `recordFile` / `ensureProjectScanned` so user-defined\n * `--breakpoint-*` overrides land in the manifest the next time it's\n * written. Identical for every parser call within one parser instance\n * (theme is fixed for the parser's lifetime), so storing the latest\n * snapshot is sufficient.\n */\n private breakpoints: ReadonlyMap<string, number> = new Map()\n /** file → set of atom names this file currently contributes. */\n private readonly fileAtomSets = new Map<string, Set<string>>()\n /** atom name → how many files currently contribute it (refcount). */\n private readonly atomRefCount = new Map<string, number>()\n /** scheme → last-written source SHA. Skips re-writing unchanged schemes. */\n private readonly schemeSignatures = new Map<string, string>()\n /**\n * Per-atom serialized-value cache — identity-keyed on each atom's\n * SchemedStyle reference. Carried across `writeSchemes` calls so the\n * typical \"user added one className\" FR case re-stringifies ONE atom\n * instead of all 175+. Cleared on `ensureProjectScanned` (full\n * rescan replaces every reference) and individually invalidated for\n * any atom `applyDiff` mutates.\n */\n private readonly serializedCache: AtomSerializedCache = new Map()\n /** Running count of stringify passes (cache misses). Test telemetry. */\n private serializedMissesCount = 0\n /** Set after `ensureProjectScanned` completes. */\n private projectScanned = false\n /** Promise guard so concurrent first-calls await ONE scan. */\n private pendingScan: Promise<void> | null = null\n\n constructor(cacheDir: string, parser: TailwindParser) {\n this.cacheDir = cacheDir\n this.parser = parser\n mkdirSync(this.cacheDir, { recursive: true })\n }\n\n /** Absolute path of the manifest module (`rnwind/__generated/schemes`). */\n public get manifestPath(): string {\n return path.join(this.cacheDir, MANIFEST_BASENAME)\n }\n\n /** Cumulative cache-miss count — exposed for tests to assert cache behaviour. */\n public get serializedMisses(): number {\n return this.serializedMissesCount\n }\n\n /**\n * Absolute path of one scheme's style file.\n * @param scheme Registry key.\n * @returns Absolute path.\n */\n public schemePath(scheme: string): string {\n return schemeFilePath(this.cacheDir, scheme)\n }\n\n /**\n * One-shot oxide scan + compile across every source the parser was\n * configured with. Idempotent — safe to call from any entry point.\n * Concurrent callers share the same in-flight promise.\n */\n public async ensureProjectScanned(): Promise<void> {\n if (this.projectScanned) return\n if (this.pendingScan) return this.pendingScan\n this.pendingScan = (async () => {\n const parsed = await this.parser.parseProject()\n for (const [name, style] of parsed.atoms) this.unionAtoms.set(name, style)\n for (const [name, kf] of parsed.keyframes) this.unionKeyframes.set(name, kf)\n for (const [name, gradient] of parsed.gradientAtoms) this.unionGradients.set(name, gradient)\n for (const [name, haptic] of parsed.hapticAtoms) this.unionHaptics.set(name, haptic)\n this.breakpoints = parsed.breakpoints\n this.projectScanned = true\n })()\n try {\n await this.pendingScan\n } finally {\n this.pendingScan = null\n }\n }\n\n /**\n * Record one source file's resolved atoms + keyframes. Short-circuits\n * when the file's atom name set hasn't changed — the common case on\n * every Fast Refresh save of a file whose className literals are\n * unchanged.\n * @param file Absolute source file path.\n * @param atoms Per-atom resolved schemed styles from this transform.\n * @param keyframes Keyframe blocks referenced by this file's atoms.\n * @param literals\n * @returns `{ changed: true }` when the union shifted (new atom name,\n * removed atom name, or new keyframe) — the transformer uses this\n * to skip the serializer + `writeSchemes` when nothing changed.\n */\n public async recordFile(\n file: string,\n atoms: ReadonlyMap<string, SchemedStyle>,\n keyframes: ReadonlyMap<string, KeyframeBlock>,\n literals: readonly string[] = [],\n ): Promise<{ changed: boolean }> {\n await this.ensureProjectScanned()\n const literalAdded = this.recordLiterals(literals)\n const newAtomNames = new Set(atoms.keys())\n const previous = this.fileAtomSets.get(file)\n if (previous && setsEqual(previous, newAtomNames)) {\n // Atom set unchanged — skip the unionAtoms update entirely. The\n // project scan already populated them, and re-setting a fresh\n // object ref here would invalidate the per-atom serialization\n // cache on every FR save for no gain (values are identical).\n // Theme edits go through `getRnwindState` → new builder → fresh\n // scan, so stale cache is impossible.\n let keyframeAdded = false\n for (const [name, kf] of keyframes) {\n if (!this.unionKeyframes.has(name)) keyframeAdded = true\n this.unionKeyframes.set(name, kf)\n }\n return { changed: keyframeAdded || literalAdded }\n }\n this.applyDiff(file, newAtomNames, atoms, keyframes)\n return { changed: true }\n }\n\n /**\n * Merge a file's literal classNames into the union. A literal the\n * union hasn't seen flips `changed` so `writeSchemes` re-emits the\n * scheme files with the new molecule.\n * @param literals Distinct literal className strings.\n * @returns Whether any literal was new to the union.\n */\n private recordLiterals(literals: readonly string[]): boolean {\n let added = false\n for (const literal of literals) {\n if (this.unionLiterals.has(literal)) continue\n this.unionLiterals.add(literal)\n added = true\n }\n return added\n }\n\n /**\n * Forget one source file's contribution. Idempotent — repeated calls\n * for a file that's already dropped are no-ops. Does NOT remove the\n * atom from the union when another file (or the project scan) still\n * references it.\n * @param file Absolute source file path.\n */\n public dropFile(file: string): void {\n const previous = this.fileAtomSets.get(file)\n if (!previous) return\n for (const name of previous) {\n const count = (this.atomRefCount.get(name) ?? 0) - 1\n if (count <= 0) this.atomRefCount.delete(name)\n else this.atomRefCount.set(name, count)\n }\n this.fileAtomSets.delete(file)\n }\n\n /**\n * Serialize the union into per-scheme files + manifest, writing only\n * files whose source bytes changed. Called after every `recordFile`\n * from the transformer — and once at Metro startup via\n * `ensureFilesExist` to seed disk from the project scan alone.\n * @returns List of scheme keys whose files were rewritten (empty\n * when the union is byte-identical to the last flush).\n */\n public async writeSchemes(): Promise<{ changedSchemes: readonly string[] }> {\n await this.ensureProjectScanned()\n const sortedAtomNames = [...this.unionAtoms.keys()].toSorted((a, b) => a.localeCompare(b))\n const result = buildSchemeSources(sortedAtomNames, this.unionAtoms, this.unionKeyframes, this.serializedCache, this.breakpoints, this.unionGradients, this.unionHaptics, [...this.unionLiterals])\n this.serializedMissesCount += result.serializedMisses\n const { schemeSources, manifestSource } = result\n\n const changed: string[] = []\n for (const [scheme, source] of Object.entries(schemeSources)) {\n const signature = signatureOf(source)\n const target = schemeFilePath(this.cacheDir, scheme)\n if (this.schemeSignatures.get(scheme) === signature && existsSync(target)) continue\n if (writeIfChanged(target, source)) changed.push(scheme)\n this.schemeSignatures.set(scheme, signature)\n }\n\n const manifestSignature = signatureOf(manifestSource)\n const manifestTarget = path.join(this.cacheDir, MANIFEST_BASENAME)\n if (this.schemeSignatures.get('__manifest') !== manifestSignature || !existsSync(manifestTarget)) {\n if (writeIfChanged(manifestTarget, manifestSource)) changed.push('__manifest')\n this.schemeSignatures.set('__manifest', manifestSignature)\n }\n\n return { changedSchemes: changed }\n }\n\n /**\n * Ensure the manifest + common scheme files exist on disk so Metro's\n * resolver can SHA1 them at boot before the first transform runs.\n */\n public async ensureFilesExist(): Promise<void> {\n if (existsSync(this.manifestPath) && existsSync(schemeFilePath(this.cacheDir, 'common'))) {\n // Still trigger the scan so the in-memory union is complete; file\n // bytes may already be authoritative from a prior Metro run.\n await this.ensureProjectScanned()\n return\n }\n await this.writeSchemes()\n }\n\n /**\n * Apply one file's atom-name diff to the in-memory refcount + union.\n * @param file Source file path.\n * @param newAtoms New atom-name set for the file.\n * @param resolvedAtoms Fresh parser output — carries the resolved\n * styles for every entry in `newAtoms`.\n * @param newKeyframes Keyframes this file's atoms reference.\n */\n private applyDiff(\n file: string,\n newAtoms: ReadonlySet<string>,\n resolvedAtoms: ReadonlyMap<string, SchemedStyle>,\n newKeyframes: ReadonlyMap<string, KeyframeBlock>,\n ): void {\n const previous = this.fileAtomSets.get(file) ?? new Set<string>()\n for (const name of previous) {\n if (newAtoms.has(name)) continue\n const count = (this.atomRefCount.get(name) ?? 0) - 1\n if (count <= 0) this.atomRefCount.delete(name)\n else this.atomRefCount.set(name, count)\n // Do NOT remove `name` from `unionAtoms` — the project scan still\n // references it (orphaned atoms get reaped on the next Metro\n // cold start when the scanner re-walks disk).\n }\n for (const name of newAtoms) {\n if (!previous.has(name)) this.atomRefCount.set(name, (this.atomRefCount.get(name) ?? 0) + 1)\n // Only install the resolved style when the atom is new to the\n // union. Replacing an existing entry with a fresh parser-\n // produced object would swap the identity guard the per-atom\n // serialization cache uses and force a re-stringify for every\n // atom on every FR save. CSS edits rebuild the whole builder\n // (via `getRnwindState`) so stale values aren't possible.\n if (!this.unionAtoms.has(name)) {\n const style = resolvedAtoms.get(name)\n if (style) this.unionAtoms.set(name, style)\n }\n }\n this.fileAtomSets.set(file, new Set(newAtoms))\n for (const [name, kf] of newKeyframes) this.unionKeyframes.set(name, kf)\n }\n}\n\nexport { UnionBuilder }\n"],"names":["existsSync","readFileSync","mkdirSync","randomBytes","writeFileSync","renameSync","rmSync","createHash","buildSchemeSources"],"mappings":";;;;;;;AAMA;AACA,MAAM,iBAAiB,GAAG,YAAY;AAEtC;;;;;;;AAOG;AACH,SAAS,cAAc,CAAC,MAAc,EAAE,OAAe,EAAA;AACrD,IAAA,IAAIA,kBAAU,CAAC,MAAM,CAAC,EAAE;AACtB,Q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EAAE,EAAE,CAAC,IAAI,YAAY;YAAE,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;IAC1E;AACD;;;;"}
1
+ {"version":3,"file":"union-builder.cjs","sources":["../../../../../src/core/style-builder/union-builder.ts"],"sourcesContent":["import { createHash, randomBytes } from 'node:crypto'\nimport { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs'\nimport path from 'node:path'\nimport type { GradientAtomInfo, HapticRequest, KeyframeBlock, SchemedStyle, TailwindParser } from '../parser'\nimport type { ThemeTables } from '../types'\nimport { buildSchemeSources, type AtomSerializedCache } from './build-style'\n\n/** Manifest module basename — the file SchemeProvider imports via the resolver. */\nconst MANIFEST_BASENAME = 'schemes.js'\n\n/**\n * Atomic file write — stage to a `.tmp.<pid>.<nonce>` sibling, then\n * `rename()` into place. Skips the write entirely when the existing\n * content matches.\n * @param target Final destination path.\n * @param content Bytes to write.\n * @returns Whether the file was actually rewritten.\n */\nfunction writeIfChanged(target: string, content: string): boolean {\n if (existsSync(target)) {\n try {\n if (readFileSync(target, 'utf8') === content) return false\n } catch {\n // Unreadable — fall through to rewrite.\n }\n }\n mkdirSync(path.dirname(target), { recursive: true })\n const temporary = `${target}.${process.pid}.${randomBytes(4).toString('hex')}.tmp`\n try {\n writeFileSync(temporary, content, 'utf8')\n renameSync(temporary, target)\n return true\n } catch (error) {\n rmSync(temporary, { force: true })\n throw error\n }\n}\n\n/**\n * SHA-256 prefix of a string — cheap signature used to detect whether a\n * per-scheme file's source has changed since the last write.\n * @param text Input text.\n * @returns 16-char hex digest.\n */\nfunction signatureOf(text: string): string {\n return createHash('sha256').update(text).digest('hex').slice(0, 16)\n}\n\n/**\n * Compare two `Set<string>`s for equality — same size + every element\n * of `a` present in `b`.\n * @param a First set.\n * @param b Second set.\n * @returns Whether the two sets contain identical values.\n */\nfunction setsEqual(a: ReadonlySet<string>, b: ReadonlySet<string>): boolean {\n if (a.size !== b.size) return false\n for (const v of a) if (!b.has(v)) return false\n return true\n}\n\n/**\n * Compute the absolute path of a per-scheme style file under the cache dir.\n * @param cacheDir Absolute cache directory.\n * @param scheme Registry key (`'common'` or a variant name).\n * @returns Absolute path, e.g. `<cacheDir>/dark.style.js`.\n */\nfunction schemeFilePath(cacheDir: string, scheme: string): string {\n return path.join(cacheDir, `${scheme}.style.js`)\n}\n\n/**\n * In-memory atom union + per-scheme style-file emitter.\n *\n * Correctness under multi-worker Metro relies on `ensureProjectScanned`:\n * the FIRST `recordFile` / `writeSchemes` call in every worker drives\n * the oxide Scanner across ALL project sources and hydrates the union\n * with the complete set of candidates. Subsequent per-file\n * `recordFile` calls only layer in atoms the scan already knew about,\n * so writes are idempotent — different workers can't clobber each\n * other's scheme files with partial views.\n *\n * Per-file deltas (atom set unchanged → early return) skip\n * serialization entirely. On a theme-CSS change, `getRnwindState`\n * builds a fresh parser + builder; the next call re-runs\n * `ensureProjectScanned` against the new parser, producing scheme\n * files with the new theme values.\n */\nclass UnionBuilder {\n private readonly cacheDir: string\n private readonly parser: TailwindParser\n private readonly unionAtoms = new Map<string, SchemedStyle>()\n private readonly unionKeyframes = new Map<string, KeyframeBlock>()\n /** atom name → gradient role/colour, surfaced into the manifest's `registerGradients`. */\n private readonly unionGradients = new Map<string, GradientAtomInfo>()\n /** atom name → haptic request, surfaced into the manifest's `registerHaptics`. */\n private readonly unionHaptics = new Map<string, HapticRequest>()\n /**\n * Distinct literal className strings seen across all files, pre-merged\n * into per-scheme molecules at write time. Accumulate-only (like\n * `unionAtoms`): orphaned literals just yield unused molecules and get\n * reaped on the next cold start, so no refcount is needed.\n */\n private readonly unionLiterals = new Set<string>()\n /**\n * Responsive breakpoints captured from the parser. Refreshed on every\n * `recordFile` / `ensureProjectScanned` so user-defined\n * `--breakpoint-*` overrides land in the manifest the next time it's\n * written. Identical for every parser call within one parser instance\n * (theme is fixed for the parser's lifetime), so storing the latest\n * snapshot is sufficient.\n */\n private breakpoints: ReadonlyMap<string, number> = new Map()\n /**\n * Per-scheme theme token tables captured from the parser. Refreshed on\n * every `recordFile` / `ensureProjectScanned` so theme-token edits land in\n * the manifest's `registerThemeTokens({...})` — the data source for\n * `useColor` / `useToken` / `useSize`.\n */\n private themeTokens: ThemeTables = {}\n /** file → set of atom names this file currently contributes. */\n private readonly fileAtomSets = new Map<string, Set<string>>()\n /** atom name → how many files currently contribute it (refcount). */\n private readonly atomRefCount = new Map<string, number>()\n /** scheme → last-written source SHA. Skips re-writing unchanged schemes. */\n private readonly schemeSignatures = new Map<string, string>()\n /**\n * Per-atom serialized-value cache — identity-keyed on each atom's\n * SchemedStyle reference. Carried across `writeSchemes` calls so the\n * typical \"user added one className\" FR case re-stringifies ONE atom\n * instead of all 175+. Cleared on `ensureProjectScanned` (full\n * rescan replaces every reference) and individually invalidated for\n * any atom `applyDiff` mutates.\n */\n private readonly serializedCache: AtomSerializedCache = new Map()\n /** Running count of stringify passes (cache misses). Test telemetry. */\n private serializedMissesCount = 0\n /** Set after `ensureProjectScanned` completes. */\n private projectScanned = false\n /** Promise guard so concurrent first-calls await ONE scan. */\n private pendingScan: Promise<void> | null = null\n\n constructor(cacheDir: string, parser: TailwindParser) {\n this.cacheDir = cacheDir\n this.parser = parser\n mkdirSync(this.cacheDir, { recursive: true })\n }\n\n /** Absolute path of the manifest module (`rnwind/__generated/schemes`). */\n public get manifestPath(): string {\n return path.join(this.cacheDir, MANIFEST_BASENAME)\n }\n\n /** Cumulative cache-miss count — exposed for tests to assert cache behaviour. */\n public get serializedMisses(): number {\n return this.serializedMissesCount\n }\n\n /**\n * Absolute path of one scheme's style file.\n * @param scheme Registry key.\n * @returns Absolute path.\n */\n public schemePath(scheme: string): string {\n return schemeFilePath(this.cacheDir, scheme)\n }\n\n /**\n * One-shot oxide scan + compile across every source the parser was\n * configured with. Idempotent — safe to call from any entry point.\n * Concurrent callers share the same in-flight promise.\n */\n public async ensureProjectScanned(): Promise<void> {\n if (this.projectScanned) return\n if (this.pendingScan) return this.pendingScan\n this.pendingScan = (async () => {\n const parsed = await this.parser.parseProject()\n for (const [name, style] of parsed.atoms) this.unionAtoms.set(name, style)\n for (const [name, kf] of parsed.keyframes) this.unionKeyframes.set(name, kf)\n for (const [name, gradient] of parsed.gradientAtoms) this.unionGradients.set(name, gradient)\n for (const [name, haptic] of parsed.hapticAtoms) this.unionHaptics.set(name, haptic)\n this.breakpoints = parsed.breakpoints\n this.themeTokens = parsed.themeTokens\n this.projectScanned = true\n })()\n try {\n await this.pendingScan\n } finally {\n this.pendingScan = null\n }\n }\n\n /**\n * Record one source file's resolved atoms + keyframes. Short-circuits\n * when the file's atom name set hasn't changed — the common case on\n * every Fast Refresh save of a file whose className literals are\n * unchanged.\n * @param file Absolute source file path.\n * @param atoms Per-atom resolved schemed styles from this transform.\n * @param keyframes Keyframe blocks referenced by this file's atoms.\n * @param literals\n * @returns `{ changed: true }` when the union shifted (new atom name,\n * removed atom name, or new keyframe) — the transformer uses this\n * to skip the serializer + `writeSchemes` when nothing changed.\n */\n public async recordFile(\n file: string,\n atoms: ReadonlyMap<string, SchemedStyle>,\n keyframes: ReadonlyMap<string, KeyframeBlock>,\n literals: readonly string[] = [],\n ): Promise<{ changed: boolean }> {\n await this.ensureProjectScanned()\n const literalAdded = this.recordLiterals(literals)\n const newAtomNames = new Set(atoms.keys())\n const previous = this.fileAtomSets.get(file)\n if (previous && setsEqual(previous, newAtomNames)) {\n // Atom set unchanged — skip the unionAtoms update entirely. The\n // project scan already populated them, and re-setting a fresh\n // object ref here would invalidate the per-atom serialization\n // cache on every FR save for no gain (values are identical).\n // Theme edits go through `getRnwindState` → new builder → fresh\n // scan, so stale cache is impossible.\n let keyframeAdded = false\n for (const [name, kf] of keyframes) {\n if (!this.unionKeyframes.has(name)) keyframeAdded = true\n this.unionKeyframes.set(name, kf)\n }\n return { changed: keyframeAdded || literalAdded }\n }\n this.applyDiff(file, newAtomNames, atoms, keyframes)\n return { changed: true }\n }\n\n /**\n * Merge a file's literal classNames into the union. A literal the\n * union hasn't seen flips `changed` so `writeSchemes` re-emits the\n * scheme files with the new molecule.\n * @param literals Distinct literal className strings.\n * @returns Whether any literal was new to the union.\n */\n private recordLiterals(literals: readonly string[]): boolean {\n let added = false\n for (const literal of literals) {\n if (this.unionLiterals.has(literal)) continue\n this.unionLiterals.add(literal)\n added = true\n }\n return added\n }\n\n /**\n * Forget one source file's contribution. Idempotent — repeated calls\n * for a file that's already dropped are no-ops. Does NOT remove the\n * atom from the union when another file (or the project scan) still\n * references it.\n * @param file Absolute source file path.\n */\n public dropFile(file: string): void {\n const previous = this.fileAtomSets.get(file)\n if (!previous) return\n for (const name of previous) {\n const count = (this.atomRefCount.get(name) ?? 0) - 1\n if (count <= 0) this.atomRefCount.delete(name)\n else this.atomRefCount.set(name, count)\n }\n this.fileAtomSets.delete(file)\n }\n\n /**\n * Serialize the union into per-scheme files + manifest, writing only\n * files whose source bytes changed. Called after every `recordFile`\n * from the transformer — and once at Metro startup via\n * `ensureFilesExist` to seed disk from the project scan alone.\n * @returns List of scheme keys whose files were rewritten (empty\n * when the union is byte-identical to the last flush).\n */\n public async writeSchemes(): Promise<{ changedSchemes: readonly string[] }> {\n await this.ensureProjectScanned()\n const sortedAtomNames = [...this.unionAtoms.keys()].toSorted((a, b) => a.localeCompare(b))\n const result = buildSchemeSources(sortedAtomNames, this.unionAtoms, this.unionKeyframes, this.serializedCache, this.breakpoints, this.unionGradients, this.unionHaptics, [...this.unionLiterals], this.themeTokens)\n this.serializedMissesCount += result.serializedMisses\n const { schemeSources, manifestSource } = result\n\n const changed: string[] = []\n for (const [scheme, source] of Object.entries(schemeSources)) {\n const signature = signatureOf(source)\n const target = schemeFilePath(this.cacheDir, scheme)\n if (this.schemeSignatures.get(scheme) === signature && existsSync(target)) continue\n if (writeIfChanged(target, source)) changed.push(scheme)\n this.schemeSignatures.set(scheme, signature)\n }\n\n const manifestSignature = signatureOf(manifestSource)\n const manifestTarget = path.join(this.cacheDir, MANIFEST_BASENAME)\n if (this.schemeSignatures.get('__manifest') !== manifestSignature || !existsSync(manifestTarget)) {\n if (writeIfChanged(manifestTarget, manifestSource)) changed.push('__manifest')\n this.schemeSignatures.set('__manifest', manifestSignature)\n }\n\n return { changedSchemes: changed }\n }\n\n /**\n * Ensure the manifest + common scheme files exist on disk so Metro's\n * resolver can SHA1 them at boot before the first transform runs.\n */\n public async ensureFilesExist(): Promise<void> {\n if (existsSync(this.manifestPath) && existsSync(schemeFilePath(this.cacheDir, 'common'))) {\n // Still trigger the scan so the in-memory union is complete; file\n // bytes may already be authoritative from a prior Metro run.\n await this.ensureProjectScanned()\n return\n }\n await this.writeSchemes()\n }\n\n /**\n * Apply one file's atom-name diff to the in-memory refcount + union.\n * @param file Source file path.\n * @param newAtoms New atom-name set for the file.\n * @param resolvedAtoms Fresh parser output — carries the resolved\n * styles for every entry in `newAtoms`.\n * @param newKeyframes Keyframes this file's atoms reference.\n */\n private applyDiff(\n file: string,\n newAtoms: ReadonlySet<string>,\n resolvedAtoms: ReadonlyMap<string, SchemedStyle>,\n newKeyframes: ReadonlyMap<string, KeyframeBlock>,\n ): void {\n const previous = this.fileAtomSets.get(file) ?? new Set<string>()\n for (const name of previous) {\n if (newAtoms.has(name)) continue\n const count = (this.atomRefCount.get(name) ?? 0) - 1\n if (count <= 0) this.atomRefCount.delete(name)\n else this.atomRefCount.set(name, count)\n // Do NOT remove `name` from `unionAtoms` — the project scan still\n // references it (orphaned atoms get reaped on the next Metro\n // cold start when the scanner re-walks disk).\n }\n for (const name of newAtoms) {\n if (!previous.has(name)) this.atomRefCount.set(name, (this.atomRefCount.get(name) ?? 0) + 1)\n // Only install the resolved style when the atom is new to the\n // union. Replacing an existing entry with a fresh parser-\n // produced object would swap the identity guard the per-atom\n // serialization cache uses and force a re-stringify for every\n // atom on every FR save. CSS edits rebuild the whole builder\n // (via `getRnwindState`) so stale values aren't possible.\n if (!this.unionAtoms.has(name)) {\n const style = resolvedAtoms.get(name)\n if (style) this.unionAtoms.set(name, style)\n }\n }\n this.fileAtomSets.set(file, new Set(newAtoms))\n for (const [name, kf] of newKeyframes) this.unionKeyframes.set(name, kf)\n }\n}\n\nexport { UnionBuilder }\n"],"names":["existsSync","readFileSync","mkdirSync","randomBytes","writeFileSync","renameSync","rmSync","createHash","buildSchemeSources"],"mappings":";;;;;;;AAOA;AACA,MAAM,iBAAiB,GAAG,YAAY;AAEtC;;;;;;;AAOG;AACH,SAAS,cAAc,CAAC,MAAc,EAAE,OAAe,EAAA;AACrD,IAAA,IAAIA,kBAAU,CAAC,MAAM,CAAC,EAAE;AACtB,QAAA,IAAI;AACF,YAAA,IAAIC,oBAAY,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,OAAO;AAAE,gBAAA,OAAO,KAAK;QAC5D;AAAE,QAAA,MAAM;;QAER;IACF;AACA,IAAAC,iBAAS,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACpD,IAAA,MAAM,SAAS,GAAG,CAAA,EAAG,MAAM,CAAA,CAAA,EAAI,OAAO,CAAC,GAAG,CAAA,CAAA,EAAIC,uBAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM;AAClF,IAAA,IAAI;AACF,QAAAC,qBAAa,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC;AACzC,QAAAC,kBAAU,CAAC,SAAS,EAAE,MAAM,CAAC;AAC7B,QAAA,OAAO,IAAI;IACb;IAAE,OAAO,KAAK,EAAE;QACdC,cAAM,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAClC,QAAA,MAAM,KAAK;IACb;AACF;AAEA;;;;;AAKG;AACH,SAAS,WAAW,CAAC,IAAY,EAAA;IAC/B,OAAOC,sBAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAA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,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;;;;;;YAO5F,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;gBAC9B,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC;AACrC,gBAAA,IAAI,KAAK;oBAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC;YAC7C;QACF;AACA,QAAA,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC9C,QAAA,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,YAAY;YAAE,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;IAC1E;AACD;;;;"}
@@ -41,6 +41,13 @@ declare class UnionBuilder {
41
41
  * snapshot is sufficient.
42
42
  */
43
43
  private breakpoints;
44
+ /**
45
+ * Per-scheme theme token tables captured from the parser. Refreshed on
46
+ * every `recordFile` / `ensureProjectScanned` so theme-token edits land in
47
+ * the manifest's `registerThemeTokens({...})` — the data source for
48
+ * `useColor` / `useToken` / `useSize`.
49
+ */
50
+ private themeTokens;
44
51
  /** file → set of atom names this file currently contributes. */
45
52
  private readonly fileAtomSets;
46
53
  /** atom name → how many files currently contribute it (refcount). */
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var rnwindProvider = require('../components/rnwind-provider.cjs');
4
+ var lookupCss = require('../lookup-css.cjs');
4
5
 
5
6
  /**
6
7
  * Synthetic scheme name applied when tokens aren't declared under any
@@ -20,11 +21,13 @@ const BASE_SCHEME = 'base';
20
21
  */
21
22
  function useTheme() {
22
23
  const { scheme, tables } = rnwindProvider.useRnwind();
23
- const base = tables[BASE_SCHEME] ?? {};
24
- const schemeTable = tables[scheme];
25
- if (!schemeTable)
26
- return base;
27
- // Fast path: nothing to merge when the scheme table is empty.
24
+ // The build registers token tables on the manifest so `useColor` works out
25
+ // of the box; an explicit `tables` prop layers on top (the prop wins).
26
+ const registered = lookupCss.getThemeTokens();
27
+ const base = { ...registered[BASE_SCHEME], ...tables[BASE_SCHEME] };
28
+ const schemeTable = { ...registered[scheme], ...tables[scheme] };
29
+ // Base tokens apply everywhere (CSS `:root` cascade); the active scheme's
30
+ // own entries override on overlap.
28
31
  if (Object.keys(schemeTable).length === 0)
29
32
  return base;
30
33
  return { ...base, ...schemeTable };
@@ -1 +1 @@
1
- {"version":3,"file":"use-scheme.cjs","sources":["../../../../../src/runtime/hooks/use-scheme.ts"],"sourcesContent":["import type { ThemeTable } from '../../core/types'\nimport { useRnwind } from '../components/rnwind-provider'\n\n/**\n * Synthetic scheme name applied when tokens aren't declared under any\n * `@variant` block — the \"no active variant\" fallback every theme table\n * inherits from.\n */\nconst BASE_SCHEME = 'base'\n\n/**\n * Access the resolved theme table for the active scheme.\n *\n * Tokens declared outside any `@variant` block live in the `base` table and\n * should apply everywhere — just like the CSS cascade treats `:root` as a\n * default for every ancestor-scoped override. We merge `base` under the\n * active scheme so a scheme that doesn't declare a token still sees the\n * base default, while the scheme's own entries win on overlap.\n * @returns Token table for the active scheme.\n */\nexport function useTheme(): ThemeTable {\n const { scheme, tables } = useRnwind()\n const base = tables[BASE_SCHEME] ?? {}\n const schemeTable = tables[scheme]\n if (!schemeTable) return base\n // Fast path: nothing to merge when the scheme table is empty.\n if (Object.keys(schemeTable).length === 0) return base\n return { ...base, ...schemeTable }\n}\n\n/**\n * Read a raw CSS custom property's value for the active scheme. Accepts\n * either `--foo` or the bare `foo` form for convenience.\n * @param cssVariable CSS custom property name (with or without the leading `--`).\n * @returns The resolved value, or undefined when the token is missing.\n */\nexport function useToken(cssVariable: string): string | number | undefined {\n const table = useTheme()\n const name = cssVariable.startsWith('--') ? cssVariable : `--${cssVariable}`\n return table[name]\n}\n\n/**\n * Read a color token by shorthand name — `useColor('primary')` resolves\n * `--color-primary` for the active scheme. A fully-qualified name\n * (`--color-primary`) is accepted as-is, so the call doesn't silently miss by\n * double-prefixing into `--color---color-primary`.\n * @param name Token suffix after `--color-`, or the full `--color-*` name.\n * @returns Resolved color string, or undefined when the token is missing\n * or its value isn't a string.\n */\nexport function useColor(name: string): string | undefined {\n const value = useToken(name.startsWith('--') ? name : `--color-${name}`)\n return typeof value === 'string' ? value : undefined\n}\n\n/**\n * Read a spacing token by shorthand name — `useSize('4')` resolves\n * `--spacing-4` for the active scheme. A fully-qualified `--spacing-*` name is\n * accepted as-is (no double-prefix miss).\n * @param name Token suffix after `--spacing-`, or the full `--spacing-*` name.\n * @returns Resolved spacing value, or undefined when the token is missing.\n */\nexport function useSize(name: string): number | string | undefined {\n return useToken(name.startsWith('--') ? name : `--spacing-${name}`)\n}\n"],"names":["useRnwind"],"mappings":";;;;AAGA;;;;AAIG;AACH,MAAM,WAAW,GAAG,MAAM;AAE1B;;;;;;;;;AASG;SACa,QAAQ,GAAA;IACtB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAGA,wBAAS,EAAE;IACtC,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE;AACtC,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;AAClC,IAAA,IAAI,CAAC,WAAW;AAAE,QAAA,OAAO,IAAI;;IAE7B,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,IAAI;AACtD,IAAA,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,WAAW,EAAE;AACpC;AAEA;;;;;AAKG;AACG,SAAU,QAAQ,CAAC,WAAmB,EAAA;AAC1C,IAAA,MAAM,KAAK,GAAG,QAAQ,EAAE;AACxB,IAAA,MAAM,IAAI,GAAG,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,WAAW,GAAG,CAAA,EAAA,EAAK,WAAW,EAAE;AAC5E,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC;AACpB;AAEA;;;;;;;;AAQG;AACG,SAAU,QAAQ,CAAC,IAAY,EAAA;IACnC,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAA,QAAA,EAAW,IAAI,CAAA,CAAE,CAAC;AACxE,IAAA,OAAO,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,GAAG,SAAS;AACtD;AAEA;;;;;;AAMG;AACG,SAAU,OAAO,CAAC,IAAY,EAAA;AAClC,IAAA,OAAO,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,aAAa,IAAI,CAAA,CAAE,CAAC;AACrE;;;;;;;"}
1
+ {"version":3,"file":"use-scheme.cjs","sources":["../../../../../src/runtime/hooks/use-scheme.ts"],"sourcesContent":["import type { ThemeTable } from '../../core/types'\nimport { useRnwind } from '../components/rnwind-provider'\nimport { getThemeTokens } from '../lookup-css'\n\n/**\n * Synthetic scheme name applied when tokens aren't declared under any\n * `@variant` block — the \"no active variant\" fallback every theme table\n * inherits from.\n */\nconst BASE_SCHEME = 'base'\n\n/**\n * Access the resolved theme table for the active scheme.\n *\n * Tokens declared outside any `@variant` block live in the `base` table and\n * should apply everywhere — just like the CSS cascade treats `:root` as a\n * default for every ancestor-scoped override. We merge `base` under the\n * active scheme so a scheme that doesn't declare a token still sees the\n * base default, while the scheme's own entries win on overlap.\n * @returns Token table for the active scheme.\n */\nexport function useTheme(): ThemeTable {\n const { scheme, tables } = useRnwind()\n // The build registers token tables on the manifest so `useColor` works out\n // of the box; an explicit `tables` prop layers on top (the prop wins).\n const registered = getThemeTokens()\n const base = { ...registered[BASE_SCHEME], ...tables[BASE_SCHEME] }\n const schemeTable = { ...registered[scheme], ...tables[scheme] }\n // Base tokens apply everywhere (CSS `:root` cascade); the active scheme's\n // own entries override on overlap.\n if (Object.keys(schemeTable).length === 0) return base\n return { ...base, ...schemeTable }\n}\n\n/**\n * Read a raw CSS custom property's value for the active scheme. Accepts\n * either `--foo` or the bare `foo` form for convenience.\n * @param cssVariable CSS custom property name (with or without the leading `--`).\n * @returns The resolved value, or undefined when the token is missing.\n */\nexport function useToken(cssVariable: string): string | number | undefined {\n const table = useTheme()\n const name = cssVariable.startsWith('--') ? cssVariable : `--${cssVariable}`\n return table[name]\n}\n\n/**\n * Read a color token by shorthand name — `useColor('primary')` resolves\n * `--color-primary` for the active scheme. A fully-qualified name\n * (`--color-primary`) is accepted as-is, so the call doesn't silently miss by\n * double-prefixing into `--color---color-primary`.\n * @param name Token suffix after `--color-`, or the full `--color-*` name.\n * @returns Resolved color string, or undefined when the token is missing\n * or its value isn't a string.\n */\nexport function useColor(name: string): string | undefined {\n const value = useToken(name.startsWith('--') ? name : `--color-${name}`)\n return typeof value === 'string' ? value : undefined\n}\n\n/**\n * Read a spacing token by shorthand name — `useSize('4')` resolves\n * `--spacing-4` for the active scheme. A fully-qualified `--spacing-*` name is\n * accepted as-is (no double-prefix miss).\n * @param name Token suffix after `--spacing-`, or the full `--spacing-*` name.\n * @returns Resolved spacing value, or undefined when the token is missing.\n */\nexport function useSize(name: string): number | string | undefined {\n return useToken(name.startsWith('--') ? name : `--spacing-${name}`)\n}\n"],"names":["useRnwind","getThemeTokens"],"mappings":";;;;;AAIA;;;;AAIG;AACH,MAAM,WAAW,GAAG,MAAM;AAE1B;;;;;;;;;AASG;SACa,QAAQ,GAAA;IACtB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAGA,wBAAS,EAAE;;;AAGtC,IAAA,MAAM,UAAU,GAAGC,wBAAc,EAAE;AACnC,IAAA,MAAM,IAAI,GAAG,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,EAAE,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE;AACnE,IAAA,MAAM,WAAW,GAAG,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE;;;IAGhE,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,IAAI;AACtD,IAAA,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,WAAW,EAAE;AACpC;AAEA;;;;;AAKG;AACG,SAAU,QAAQ,CAAC,WAAmB,EAAA;AAC1C,IAAA,MAAM,KAAK,GAAG,QAAQ,EAAE;AACxB,IAAA,MAAM,IAAI,GAAG,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,WAAW,GAAG,CAAA,EAAA,EAAK,WAAW,EAAE;AAC5E,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC;AACpB;AAEA;;;;;;;;AAQG;AACG,SAAU,QAAQ,CAAC,IAAY,EAAA;IACnC,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAA,QAAA,EAAW,IAAI,CAAA,CAAE,CAAC;AACxE,IAAA,OAAO,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,GAAG,SAAS;AACtD;AAEA;;;;;;AAMG;AACG,SAAU,OAAO,CAAC,IAAY,EAAA;AAClC,IAAA,OAAO,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,aAAa,IAAI,CAAA,CAAE,CAAC;AACrE;;;;;;;"}
@@ -22,6 +22,7 @@ exports.lookupCss = lookupCss.lookupCss;
22
22
  exports.registerAtoms = lookupCss.registerAtoms;
23
23
  exports.registerBreakpoints = lookupCss.registerBreakpoints;
24
24
  exports.registerSchemeLoader = lookupCss.registerSchemeLoader;
25
+ exports.registerThemeTokens = lookupCss.registerThemeTokens;
25
26
  exports.setWindowHeightProvider = lookupCss.setWindowHeightProvider;
26
27
  exports.wrap = wrap.wrap;
27
28
  exports.wrapNamespace = wrap.wrapNamespace;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../../src/runtime/index.ts"],"sourcesContent":["export {\n lookupCss,\n registerAtoms,\n registerBreakpoints,\n registerSchemeLoader,\n setWindowHeightProvider,\n getBreakpoints,\n activeBreakpointFor,\n} from './lookup-css'\nexport type { HoistedClassName, InteractState, LookupInsets, SafeMarkerSpec } from './lookup-css'\nexport { wrap, wrapNamespace } from './wrap'\nexport { resolve, registerMolecules, registerGradients, registerHaptics } from './resolve'\nexport type { ResolvedCss } from './resolve'\nexport { useCss } from './hooks/use-css'\nexport { useInteract } from './hooks/use-interact'\nexport type { UseInteractResult } from './hooks/use-interact'\nexport { chainPress, chainFocus } from './chain-handlers'\nexport { RnwindProvider, useRnwind } from './components/rnwind-provider'\nexport type { RnwindProviderProps, RnwindState, Insets } from './components/rnwind-provider'\nexport type { HapticRequest, HapticTrigger, OnHaptics } from '../core/parser/haptics'\nexport type { AsLinearGradientProps, LinearGradientPoint } from './gradient-types'\nexport type { ThemeTable, ThemeTables } from '../core/types'\nexport { useTheme, useToken, useColor, useSize } from './hooks/use-scheme'\nexport type { Scheme, RnwindConfig } from './types'\n\n/**\n * Installed rnwind version, inlined at publish time. Compare against a pinned\n * string when integrating with build tooling that may see multiple rnwind\n * copies (e.g. workspace overrides).\n */\nexport const VERSION = '0.0.8' as const\n"],"names":[],"mappings":";;;;;;;;;;;AAyBA;;;;AAIG;AACI,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../../src/runtime/index.ts"],"sourcesContent":["export {\n lookupCss,\n registerAtoms,\n registerBreakpoints,\n registerThemeTokens,\n registerSchemeLoader,\n setWindowHeightProvider,\n getBreakpoints,\n activeBreakpointFor,\n} from './lookup-css'\nexport type { HoistedClassName, InteractState, LookupInsets, SafeMarkerSpec } from './lookup-css'\nexport { wrap, wrapNamespace } from './wrap'\nexport { resolve, registerMolecules, registerGradients, registerHaptics } from './resolve'\nexport type { ResolvedCss } from './resolve'\nexport { useCss } from './hooks/use-css'\nexport { useInteract } from './hooks/use-interact'\nexport type { UseInteractResult } from './hooks/use-interact'\nexport { chainPress, chainFocus } from './chain-handlers'\nexport { RnwindProvider, useRnwind } from './components/rnwind-provider'\nexport type { RnwindProviderProps, RnwindState, Insets } from './components/rnwind-provider'\nexport type { HapticRequest, HapticTrigger, OnHaptics } from '../core/parser/haptics'\nexport type { AsLinearGradientProps, LinearGradientPoint } from './gradient-types'\nexport type { ThemeTable, ThemeTables } from '../core/types'\nexport { useTheme, useToken, useColor, useSize } from './hooks/use-scheme'\nexport type { Scheme, RnwindConfig } from './types'\n\n/**\n * Installed rnwind version, inlined at publish time. Compare against a pinned\n * string when integrating with build tooling that may see multiple rnwind\n * copies (e.g. workspace overrides).\n */\nexport const VERSION = '0.0.8' as const\n"],"names":[],"mappings":";;;;;;;;;;;AA0BA;;;;AAIG;AACI,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- export { lookupCss, registerAtoms, registerBreakpoints, registerSchemeLoader, setWindowHeightProvider, getBreakpoints, activeBreakpointFor, } from './lookup-css';
1
+ export { lookupCss, registerAtoms, registerBreakpoints, registerThemeTokens, registerSchemeLoader, setWindowHeightProvider, getBreakpoints, activeBreakpointFor, } from './lookup-css';
2
2
  export type { HoistedClassName, InteractState, LookupInsets, SafeMarkerSpec } from './lookup-css';
3
3
  export { wrap, wrapNamespace } from './wrap';
4
4
  export { resolve, registerMolecules, registerGradients, registerHaptics } from './resolve';