rnwind 0.0.4 → 0.0.6

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 (127) hide show
  1. package/lib/cjs/core/normalize-classname.cjs +25 -0
  2. package/lib/cjs/core/normalize-classname.cjs.map +1 -0
  3. package/lib/cjs/core/normalize-classname.d.ts +10 -0
  4. package/lib/cjs/core/style-builder/build-style.cjs +258 -58
  5. package/lib/cjs/core/style-builder/build-style.cjs.map +1 -1
  6. package/lib/cjs/core/style-builder/build-style.d.ts +6 -1
  7. package/lib/cjs/core/style-builder/union-builder.cjs +37 -3
  8. package/lib/cjs/core/style-builder/union-builder.cjs.map +1 -1
  9. package/lib/cjs/core/style-builder/union-builder.d.ts +21 -1
  10. package/lib/cjs/metro/dts.cjs +7 -16
  11. package/lib/cjs/metro/dts.cjs.map +1 -1
  12. package/lib/cjs/metro/dts.d.ts +2 -4
  13. package/lib/cjs/metro/state.cjs +30 -78
  14. package/lib/cjs/metro/state.cjs.map +1 -1
  15. package/lib/cjs/metro/state.d.ts +8 -25
  16. package/lib/cjs/metro/transformer.cjs +193 -34
  17. package/lib/cjs/metro/transformer.cjs.map +1 -1
  18. package/lib/cjs/metro/with-config.cjs +2 -2
  19. package/lib/cjs/metro/with-config.cjs.map +1 -1
  20. package/lib/cjs/metro/with-config.d.ts +11 -26
  21. package/lib/cjs/metro/wrap-imports.cjs +273 -0
  22. package/lib/cjs/metro/wrap-imports.cjs.map +1 -0
  23. package/lib/cjs/metro/wrap-imports.d.ts +26 -0
  24. package/lib/cjs/runtime/components/rnwind-provider.cjs +0 -17
  25. package/lib/cjs/runtime/components/rnwind-provider.cjs.map +1 -1
  26. package/lib/cjs/runtime/components/rnwind-provider.d.ts +0 -14
  27. package/lib/cjs/runtime/hooks/use-css.cjs +16 -10
  28. package/lib/cjs/runtime/hooks/use-css.cjs.map +1 -1
  29. package/lib/cjs/runtime/hooks/use-css.d.ts +15 -9
  30. package/lib/cjs/runtime/index.cjs +11 -13
  31. package/lib/cjs/runtime/index.cjs.map +1 -1
  32. package/lib/cjs/runtime/index.d.ts +4 -9
  33. package/lib/cjs/runtime/lookup-css.cjs +10 -0
  34. package/lib/cjs/runtime/lookup-css.cjs.map +1 -1
  35. package/lib/cjs/runtime/lookup-css.d.ts +7 -0
  36. package/lib/cjs/runtime/resolve.cjs +400 -0
  37. package/lib/cjs/runtime/resolve.cjs.map +1 -0
  38. package/lib/cjs/runtime/resolve.d.ts +66 -0
  39. package/lib/cjs/runtime/wrap.cjs +254 -0
  40. package/lib/cjs/runtime/wrap.cjs.map +1 -0
  41. package/lib/cjs/runtime/wrap.d.ts +37 -0
  42. package/lib/cjs/testing/index.cjs +81 -50
  43. package/lib/cjs/testing/index.cjs.map +1 -1
  44. package/lib/esm/core/normalize-classname.d.ts +10 -0
  45. package/lib/esm/core/normalize-classname.mjs +23 -0
  46. package/lib/esm/core/normalize-classname.mjs.map +1 -0
  47. package/lib/esm/core/style-builder/build-style.d.ts +6 -1
  48. package/lib/esm/core/style-builder/build-style.mjs +258 -58
  49. package/lib/esm/core/style-builder/build-style.mjs.map +1 -1
  50. package/lib/esm/core/style-builder/union-builder.d.ts +21 -1
  51. package/lib/esm/core/style-builder/union-builder.mjs +37 -3
  52. package/lib/esm/core/style-builder/union-builder.mjs.map +1 -1
  53. package/lib/esm/metro/dts.d.ts +2 -4
  54. package/lib/esm/metro/dts.mjs +7 -16
  55. package/lib/esm/metro/dts.mjs.map +1 -1
  56. package/lib/esm/metro/state.d.ts +8 -25
  57. package/lib/esm/metro/state.mjs +30 -76
  58. package/lib/esm/metro/state.mjs.map +1 -1
  59. package/lib/esm/metro/transformer.mjs +194 -35
  60. package/lib/esm/metro/transformer.mjs.map +1 -1
  61. package/lib/esm/metro/with-config.d.ts +11 -26
  62. package/lib/esm/metro/with-config.mjs +2 -2
  63. package/lib/esm/metro/with-config.mjs.map +1 -1
  64. package/lib/esm/metro/wrap-imports.d.ts +26 -0
  65. package/lib/esm/metro/wrap-imports.mjs +250 -0
  66. package/lib/esm/metro/wrap-imports.mjs.map +1 -0
  67. package/lib/esm/runtime/components/rnwind-provider.d.ts +0 -14
  68. package/lib/esm/runtime/components/rnwind-provider.mjs +1 -17
  69. package/lib/esm/runtime/components/rnwind-provider.mjs.map +1 -1
  70. package/lib/esm/runtime/hooks/use-css.d.ts +15 -9
  71. package/lib/esm/runtime/hooks/use-css.mjs +16 -10
  72. package/lib/esm/runtime/hooks/use-css.mjs.map +1 -1
  73. package/lib/esm/runtime/index.d.ts +4 -9
  74. package/lib/esm/runtime/index.mjs +4 -4
  75. package/lib/esm/runtime/index.mjs.map +1 -1
  76. package/lib/esm/runtime/lookup-css.d.ts +7 -0
  77. package/lib/esm/runtime/lookup-css.mjs +10 -1
  78. package/lib/esm/runtime/lookup-css.mjs.map +1 -1
  79. package/lib/esm/runtime/resolve.d.ts +66 -0
  80. package/lib/esm/runtime/resolve.mjs +393 -0
  81. package/lib/esm/runtime/resolve.mjs.map +1 -0
  82. package/lib/esm/runtime/wrap.d.ts +37 -0
  83. package/lib/esm/runtime/wrap.mjs +251 -0
  84. package/lib/esm/runtime/wrap.mjs.map +1 -0
  85. package/lib/esm/testing/index.mjs +84 -53
  86. package/lib/esm/testing/index.mjs.map +1 -1
  87. package/package.json +2 -1
  88. package/src/core/normalize-classname.ts +19 -0
  89. package/src/core/style-builder/build-style.ts +286 -55
  90. package/src/core/style-builder/union-builder.ts +36 -3
  91. package/src/metro/dts.ts +7 -19
  92. package/src/metro/state.ts +29 -74
  93. package/src/metro/transformer.ts +190 -34
  94. package/src/metro/with-config.ts +13 -28
  95. package/src/metro/wrap-imports.ts +260 -0
  96. package/src/runtime/components/rnwind-provider.tsx +0 -17
  97. package/src/runtime/hooks/use-css.ts +17 -11
  98. package/src/runtime/index.ts +3 -26
  99. package/src/runtime/lookup-css.ts +10 -0
  100. package/src/runtime/resolve.ts +438 -0
  101. package/src/runtime/wrap.tsx +267 -0
  102. package/src/testing/index.ts +106 -56
  103. package/lib/cjs/core/parser/text-truncate.cjs +0 -78
  104. package/lib/cjs/core/parser/text-truncate.cjs.map +0 -1
  105. package/lib/cjs/metro/transform-ast.cjs +0 -1472
  106. package/lib/cjs/metro/transform-ast.cjs.map +0 -1
  107. package/lib/cjs/metro/transform-ast.d.ts +0 -88
  108. package/lib/cjs/runtime/haptics.cjs +0 -113
  109. package/lib/cjs/runtime/haptics.cjs.map +0 -1
  110. package/lib/cjs/runtime/haptics.d.ts +0 -48
  111. package/lib/cjs/runtime/interactive-box.cjs +0 -35
  112. package/lib/cjs/runtime/interactive-box.cjs.map +0 -1
  113. package/lib/cjs/runtime/interactive-box.d.ts +0 -40
  114. package/lib/esm/core/parser/text-truncate.mjs +0 -75
  115. package/lib/esm/core/parser/text-truncate.mjs.map +0 -1
  116. package/lib/esm/metro/transform-ast.d.ts +0 -88
  117. package/lib/esm/metro/transform-ast.mjs +0 -1451
  118. package/lib/esm/metro/transform-ast.mjs.map +0 -1
  119. package/lib/esm/runtime/haptics.d.ts +0 -48
  120. package/lib/esm/runtime/haptics.mjs +0 -110
  121. package/lib/esm/runtime/haptics.mjs.map +0 -1
  122. package/lib/esm/runtime/interactive-box.d.ts +0 -40
  123. package/lib/esm/runtime/interactive-box.mjs +0 -33
  124. package/lib/esm/runtime/interactive-box.mjs.map +0 -1
  125. package/src/metro/transform-ast.ts +0 -1729
  126. package/src/runtime/haptics.ts +0 -120
  127. package/src/runtime/interactive-box.tsx +0 -57
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Normalize a className for molecule keying: trim, collapse runs of
5
+ * whitespace, and drop exact-duplicate tokens — but PRESERVE ORDER.
6
+ * Tailwind is last-wins for conflicting utilities (`p-4 p-2` ≠ `p-2 p-4`),
7
+ * so sorting would corrupt the merge. Build-time (molecule keys) and
8
+ * runtime (lookup) call the identical function so their keys always match.
9
+ * @param className Raw className string.
10
+ * @returns Normalized, order-preserving className.
11
+ */
12
+ function normalizeClassName(className) {
13
+ const seen = new Set();
14
+ const out = [];
15
+ for (const token of className.trim().split(/\s+/)) {
16
+ if (token.length === 0 || seen.has(token))
17
+ continue;
18
+ seen.add(token);
19
+ out.push(token);
20
+ }
21
+ return out.join(' ');
22
+ }
23
+
24
+ exports.normalizeClassName = normalizeClassName;
25
+ //# sourceMappingURL=normalize-classname.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-classname.cjs","sources":["../../../../src/core/normalize-classname.ts"],"sourcesContent":["/**\n * Normalize a className for molecule keying: trim, collapse runs of\n * whitespace, and drop exact-duplicate tokens — but PRESERVE ORDER.\n * Tailwind is last-wins for conflicting utilities (`p-4 p-2` ≠ `p-2 p-4`),\n * so sorting would corrupt the merge. Build-time (molecule keys) and\n * runtime (lookup) call the identical function so their keys always match.\n * @param className Raw className string.\n * @returns Normalized, order-preserving className.\n */\nexport function normalizeClassName(className: string): string {\n const seen = new Set<string>()\n const out: string[] = []\n for (const token of className.trim().split(/\\s+/)) {\n if (token.length === 0 || seen.has(token)) continue\n seen.add(token)\n out.push(token)\n }\n return out.join(' ')\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;AAQG;AACG,SAAU,kBAAkB,CAAC,SAAiB,EAAA;AAClD,IAAA,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU;IAC9B,MAAM,GAAG,GAAa,EAAE;AACxB,IAAA,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QACjD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE;AAC3C,QAAA,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;AACf,QAAA,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;IACjB;AACA,IAAA,OAAO,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;AACtB;;;;"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Normalize a className for molecule keying: trim, collapse runs of
3
+ * whitespace, and drop exact-duplicate tokens — but PRESERVE ORDER.
4
+ * Tailwind is last-wins for conflicting utilities (`p-4 p-2` ≠ `p-2 p-4`),
5
+ * so sorting would corrupt the merge. Build-time (molecule keys) and
6
+ * runtime (lookup) call the identical function so their keys always match.
7
+ * @param className Raw className string.
8
+ * @returns Normalized, order-preserving className.
9
+ */
10
+ export declare function normalizeClassName(className: string): string;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var normalizeClassname = require('../normalize-classname.cjs');
4
+
3
5
  /** Match atom names like `border-hairline`, `h-hairline`, `border-t-hairline`, etc. */
4
6
  const HAIRLINE_ATOM = /-hairline$/;
5
7
  /** Parser's synthetic "no variant" scheme — provides the canonical fallback. */
@@ -178,59 +180,92 @@ function prepareAtomValue(atomName, style, keyframes) {
178
180
  return serializeAtomValue(atomName, enveloped);
179
181
  }
180
182
  /**
181
- * Per-file value deduplicator interns each unique serialized atom
182
- * value once and emits `const _s<N> = <value>` at module scope. Scheme
183
- * entries reference the const instead of inlining the literal.
184
- *
185
- * Wins: (1) smaller bundle bytes for themes with many atoms sharing a
186
- * style shape; (2) stable `===` inside one scheme so two atoms
187
- * resolving to the same value yield the same object reference.
183
+ * Decide which serialized atom values get hoisted to a shared `const`.
184
+ * A value is hoisted ONLY when ≥2 atoms share it then one
185
+ * `const _s<N> = <value>` saves the repeated bytes AND gives those atoms
186
+ * one shared object (reference identity). A value used once is inlined
187
+ * directly at its atom (`"-m-2": {"margin":-8}`) hoisting a singleton
188
+ * would only add bytes. First-seen order keeps the const indices stable
189
+ * across workers.
190
+ * @param entries `[atomName, serializedValue]` pairs (atom-sorted).
191
+ * @returns `{ constFor }` value→const-name map + `decls` source lines.
188
192
  */
189
- class ValueDeduper {
190
- byText = new Map();
191
- decls = [];
192
- intern(serialized) {
193
- const existing = this.byText.get(serialized);
194
- if (existing)
195
- return existing;
196
- const name = `_s${this.decls.length}`;
197
- this.decls.push(`const ${name} = ${serialized}`);
198
- this.byText.set(serialized, name);
199
- return name;
200
- }
201
- get declarations() {
202
- return this.decls;
193
+ function planValueConsts(entries) {
194
+ const counts = new Map();
195
+ for (const [, value] of entries)
196
+ counts.set(value, (counts.get(value) ?? 0) + 1);
197
+ const constFor = new Map();
198
+ const decls = [];
199
+ for (const [value, count] of counts) {
200
+ if (count < 2)
201
+ continue;
202
+ const name = `_s${decls.length}`;
203
+ constFor.set(value, name);
204
+ decls.push(`const ${name} = ${value}`);
203
205
  }
206
+ return { constFor, decls };
207
+ }
208
+ /**
209
+ * Serialize a scheme's molecule map into a `registerMolecules(...)` object
210
+ * literal, sorted by className for byte-deterministic output.
211
+ * @param molecules normalized className → pre-merged style object.
212
+ * @returns Object-literal source (`null` when empty).
213
+ */
214
+ function serializeMolecules(molecules) {
215
+ if (!molecules)
216
+ return null;
217
+ const keys = Object.keys(molecules).toSorted((a, b) => a.localeCompare(b));
218
+ if (keys.length === 0)
219
+ return null;
220
+ const body = keys.map((cn) => ` ${JSON.stringify(cn)}: ${JSON.stringify(molecules[cn])},`);
221
+ return ['{', ...body, '}'].join('\n');
204
222
  }
205
223
  /**
206
224
  * Render one scheme file's source. `entries` is the list of atoms this
207
225
  * scheme contributes — for `common` every atom's canonical value; for
208
226
  * a variant only atoms whose value differs from canonical. Hairline
209
- * atoms in this file trigger the `StyleSheet` import.
227
+ * atoms in this file trigger the `StyleSheet` import. Pre-merged
228
+ * molecules (when present) are registered alongside the atoms so the
229
+ * runtime resolver's molecule-first path is populated.
210
230
  * @param schemeName Registry key (`'common'` or the variant name).
211
231
  * @param entries `[atomName, serializedValue]` pairs to emit.
232
+ * @param molecules Pre-merged className → style map for this scheme.
212
233
  * @returns JS source text.
213
234
  */
214
- function renderSchemeFile(schemeName, entries) {
235
+ function renderSchemeFile(schemeName, entries, molecules) {
215
236
  const needsStyleSheet = entries.some(([atom]) => isHairlineAtom(atom));
216
- const deduper = new ValueDeduper();
217
- const recordLines = [];
218
- for (const [atom, value] of entries) {
219
- const ref = deduper.intern(value);
220
- recordLines.push(` ${JSON.stringify(atom)}: ${ref},`);
221
- }
237
+ const { constFor, decls } = planValueConsts(entries);
238
+ const recordLines = entries.map(([atom, value]) => ` ${JSON.stringify(atom)}: ${constFor.get(value) ?? value},`);
239
+ const moleculeLiteral = serializeMolecules(molecules);
240
+ const imports = ['registerAtoms'];
241
+ if (moleculeLiteral)
242
+ imports.push('registerMolecules');
222
243
  const lines = [];
223
244
  if (needsStyleSheet)
224
245
  lines.push(`import { StyleSheet } from 'react-native'`);
225
- lines.push(`import { registerAtoms } from 'rnwind'`, ``);
226
- if (deduper.declarations.length > 0) {
227
- for (const decl of deduper.declarations)
246
+ lines.push(`import { ${imports.join(', ')} } from 'rnwind'`, ``);
247
+ if (decls.length > 0) {
248
+ for (const decl of decls)
228
249
  lines.push(decl);
229
250
  lines.push(``);
230
251
  }
231
252
  lines.push(`registerAtoms(${JSON.stringify(schemeName)}, {`, ...recordLines, `})`, ``);
253
+ if (moleculeLiteral)
254
+ lines.push(`registerMolecules(${JSON.stringify(schemeName)}, ${moleculeLiteral})`, ``);
232
255
  return lines.join('\n');
233
256
  }
257
+ /**
258
+ * Serialize a feature map (atom name → JSON-able value: gradient info or
259
+ * haptic request) into a stable JS object literal for the manifest.
260
+ * Sorted by key so the output is byte-deterministic across workers.
261
+ * @param map Atom name → feature value.
262
+ * @returns Object-literal source.
263
+ */
264
+ function serializeFeatureMap(map) {
265
+ const entries = [...map.entries()].toSorted((a, b) => a[0].localeCompare(b[0]));
266
+ const body = entries.map(([key, value]) => `${JSON.stringify(key)}: ${JSON.stringify(value)}`).join(', ');
267
+ return `{ ${body} }`;
268
+ }
234
269
  /**
235
270
  * Render the JS-object literal for the responsive-breakpoint table the
236
271
  * runtime registers at manifest-load time. Sorted by ascending px
@@ -247,35 +282,190 @@ function serializeBreakpoints(breakpoints) {
247
282
  return `{ ${inner} }`;
248
283
  }
249
284
  /**
250
- * Render the manifest module. Eager-imports `common.style.js` (every
251
- * rewritten source file pulls this via a transitive side-effect
252
- * import), registers the responsive-breakpoint table once, and lazy-
253
- * requires every variant scheme's file through an inline require —
254
- * first call in `ensureSchemeLoaded(name)` triggers the scheme
255
- * module's evaluation; Metro's module cache makes subsequent calls
256
- * no-ops.
285
+ * Render the manifest module. EAGER-imports `common.style.js` AND every
286
+ * variant scheme file so every scheme's atoms register the moment the
287
+ * manifest evaluates no lazy `require`. Lazy loading raced the cold
288
+ * start: `RnwindProvider` calls `loadScheme(scheme)` on its first render,
289
+ * but on a cold boot the manifest (hence `registerSchemeLoader`) may not
290
+ * have evaluated yet, so that call no-ops and the active variant's atoms
291
+ * never load — scheme-dependent styles fall back to `common` (the light
292
+ * default) until a reload. Eager imports remove the race entirely; the
293
+ * variant files are small diffs, so the upfront cost is negligible.
294
+ * `ensureSchemeLoaded` stays exported as a no-op for API compatibility.
257
295
  * @param variants Variant scheme names (no `base`, no `common`).
258
296
  * @param breakpoints Responsive breakpoint name → px-threshold map.
297
+ * @param gradients Atom → gradient info for `registerGradients`.
298
+ * @param haptics Atom → haptic request for `registerHaptics`.
259
299
  * @returns JS source text.
260
300
  */
261
- function renderManifest(variants, breakpoints) {
262
- const lines = [
263
- `import { registerSchemeLoader, registerBreakpoints } from 'rnwind'`,
264
- `import './common.style'`,
265
- ``,
266
- `registerBreakpoints(${serializeBreakpoints(breakpoints)})`,
267
- ``,
268
- ];
269
- if (variants.length === 0) {
270
- lines.push(`function ensureSchemeLoaded(_name) {}`, ``, `registerSchemeLoader(ensureSchemeLoaded)`, ``, `export { ensureSchemeLoaded }`, ``);
271
- return lines.join('\n');
301
+ function renderManifest(variants, breakpoints, gradients, haptics) {
302
+ const imports = ['registerSchemeLoader', 'registerBreakpoints'];
303
+ if (gradients.size > 0)
304
+ imports.push('registerGradients');
305
+ if (haptics.size > 0)
306
+ imports.push('registerHaptics');
307
+ const lines = [`import { ${imports.join(', ')} } from 'rnwind'`, `import './common.style'`];
308
+ for (const variant of variants)
309
+ lines.push(`import ${JSON.stringify(`./${variant}.style`)}`);
310
+ lines.push(``, `registerBreakpoints(${serializeBreakpoints(breakpoints)})`);
311
+ if (gradients.size > 0)
312
+ lines.push(`registerGradients(${serializeFeatureMap(gradients)})`);
313
+ if (haptics.size > 0)
314
+ lines.push(`registerHaptics(${serializeFeatureMap(haptics)})`);
315
+ lines.push(``, `function ensureSchemeLoaded(_name) {}`, ``, `registerSchemeLoader(ensureSchemeLoaded)`, ``, `export { ensureSchemeLoaded }`, ``);
316
+ return lines.join('\n');
317
+ }
318
+ /**
319
+ * Whether a resolved style carries a nested safe-area marker — molecules
320
+ * can't pre-bake these because the inset value is per-render.
321
+ * @param style Raw resolved RN style (pre-envelope).
322
+ * @returns True when any value is a `{__safe: ...}` marker.
323
+ */
324
+ function hasSafeMarker(style) {
325
+ for (const key of Object.keys(style)) {
326
+ const value = style[key];
327
+ if (typeof value !== 'object' || !value)
328
+ continue;
329
+ if ('__safe' in value)
330
+ return true;
331
+ }
332
+ return false;
333
+ }
334
+ /**
335
+ * Whether a resolved style has font-scale-sensitive props. Molecules
336
+ * can't pre-bake these because `fontSize`/`lineHeight` scale per-render
337
+ * with `useWindowDimensions().fontScale`.
338
+ * @param style Resolved RN style.
339
+ * @returns True when `fontSize` or `lineHeight` is present.
340
+ */
341
+ function hasFontScaleProperty(style) {
342
+ return 'fontSize' in style || 'lineHeight' in style;
343
+ }
344
+ /**
345
+ * Whether a token is a feature-only utility (gradient stop/direction,
346
+ * haptic, or text-truncate) that contributes NO RN `style` — the runtime
347
+ * resolver folds these in via `attachFeatures`, so they don't disqualify
348
+ * a molecule, they just merge nothing.
349
+ * @param token Atom name.
350
+ * @param gradients Gradient feature map.
351
+ * @param haptics Haptic feature map.
352
+ * @returns True when the token is a non-style feature.
353
+ */
354
+ function isFeatureToken(token, gradients, haptics) {
355
+ if (gradients.has(token) || haptics.has(token))
356
+ return true;
357
+ return token === 'truncate' || token === 'text-ellipsis' || token === 'text-clip' || token.startsWith('line-clamp-');
358
+ }
359
+ /**
360
+ * Resolve one atom's value under a scheme: the scheme's own non-empty
361
+ * bucket, falling back to canonical. `common` always reads canonical.
362
+ * @param schemed Parser-produced per-scheme bucket.
363
+ * @param scheme Scheme key (`'common'` or a variant name).
364
+ * @returns The atom's RN style for that scheme, or undefined.
365
+ */
366
+ function schemeValueOf(schemed, scheme) {
367
+ if (scheme === COMMON_SCHEME)
368
+ return canonicalValue(schemed);
369
+ const own = schemed[scheme];
370
+ return isNonEmptyStyle(own) ? own : canonicalValue(schemed);
371
+ }
372
+ /**
373
+ * Pre-merge a normalized className's atoms into ONE RN style object for a
374
+ * scheme, or null when the className is NOT molecule-eligible. A
375
+ * className is eligible only when every token is context-independent:
376
+ * - no variant prefix (`active:` / `focus:` / `md:` / `dark:` — anything
377
+ * with a `:`), so scheme/state/breakpoint gating never applies,
378
+ * - no `*-hairline`, `*-safe`, or font-scale (`fontSize`/`lineHeight`)
379
+ * atom, whose value is resolved per-render.
380
+ * Feature-only tokens (gradient / haptic / truncate) are skipped, not
381
+ * disqualifying — the runtime folds them in via `attachFeatures`. Unknown
382
+ * tokens disqualify so the atom path still surfaces the dev warning.
383
+ * @param tokens Normalized className tokens (order preserved).
384
+ * @param scheme Scheme key to resolve each atom under.
385
+ * @param resolved Per-atom schemed styles.
386
+ * @param keyframes Keyframes to inline into `animationName`.
387
+ * @param gradients Gradient feature map.
388
+ * @param haptics Haptic feature map.
389
+ * @returns Merged style object, or null when not eligible.
390
+ */
391
+ function mergeMolecule(tokens, scheme, resolved, keyframes, gradients, haptics) {
392
+ const merged = {};
393
+ for (const token of tokens) {
394
+ if (token.includes(':'))
395
+ return null;
396
+ if (isFeatureToken(token, gradients, haptics))
397
+ continue;
398
+ if (isHairlineAtom(token))
399
+ return null;
400
+ const schemed = resolved.get(token);
401
+ if (!schemed)
402
+ return null;
403
+ const raw = schemeValueOf(schemed, scheme);
404
+ if (!raw)
405
+ continue;
406
+ if (hasSafeMarker(raw) || hasFontScaleProperty(raw))
407
+ return null;
408
+ Object.assign(merged, inlineAnimationName(raw, keyframes));
409
+ }
410
+ return merged;
411
+ }
412
+ /**
413
+ * Emit each variant's molecule for one className — but only when the
414
+ * variant's merge DIFFERS from common (runtime falls back to common).
415
+ * @param normalized Normalized className key.
416
+ * @param tokens Normalized className tokens.
417
+ * @param commonText Serialized common-scheme merge for the diff check.
418
+ * @param variants Variant scheme names.
419
+ * @param variantMaps Mutable per-variant molecule collectors.
420
+ * @param resolved Per-atom schemed styles.
421
+ * @param keyframes Keyframes to inline.
422
+ * @param gradients Gradient feature map.
423
+ * @param haptics Haptic feature map.
424
+ */
425
+ function addVariantMolecules(normalized, tokens, commonText, variants, variantMaps, resolved, keyframes, gradients, haptics) {
426
+ for (const variant of variants) {
427
+ const variantMerged = mergeMolecule(tokens, variant, resolved, keyframes, gradients, haptics);
428
+ if (variantMerged === null)
429
+ continue;
430
+ if (JSON.stringify(variantMerged) !== commonText)
431
+ variantMaps[variant][normalized] = variantMerged;
272
432
  }
273
- lines.push(`const LOADERS = {`);
433
+ }
434
+ /**
435
+ * Build per-scheme molecules for every literal className the project
436
+ * uses. Each eligible className gets a pre-merged style object under
437
+ * `common`; a variant only carries an entry when its merge DIFFERS from
438
+ * common (runtime falls back `molecules[scheme] ?? molecules.common`).
439
+ * @param literals Distinct literal className strings (raw).
440
+ * @param resolved Per-atom schemed styles.
441
+ * @param keyframes Keyframes to inline.
442
+ * @param variants Variant scheme names.
443
+ * @param gradients Gradient feature map.
444
+ * @param haptics Haptic feature map.
445
+ * @returns scheme → (normalized className → merged style).
446
+ */
447
+ function buildMolecules(literals, resolved, keyframes, variants, gradients, haptics) {
448
+ const common = {};
449
+ const variantMaps = {};
450
+ for (const variant of variants)
451
+ variantMaps[variant] = {};
452
+ for (const literal of literals) {
453
+ const normalized = normalizeClassname.normalizeClassName(literal);
454
+ if (normalized.length === 0)
455
+ continue;
456
+ const tokens = normalized.split(' ');
457
+ const commonMerged = mergeMolecule(tokens, COMMON_SCHEME, resolved, keyframes, gradients, haptics);
458
+ if (commonMerged === null)
459
+ continue;
460
+ common[normalized] = commonMerged;
461
+ addVariantMolecules(normalized, tokens, JSON.stringify(commonMerged), variants, variantMaps, resolved, keyframes, gradients, haptics);
462
+ }
463
+ const out = { [COMMON_SCHEME]: common };
274
464
  for (const variant of variants) {
275
- lines.push(` ${JSON.stringify(variant)}: () => require(${JSON.stringify(`./${variant}.style`)}),`);
465
+ if (Object.keys(variantMaps[variant]).length > 0)
466
+ out[variant] = variantMaps[variant];
276
467
  }
277
- lines.push(`}`, ``, `function ensureSchemeLoaded(name) {`, ` const loader = LOADERS[name]`, ` if (loader) loader()`, `}`, ``, `registerSchemeLoader(ensureSchemeLoaded)`, ``, `export { ensureSchemeLoaded }`, ``);
278
- return lines.join('\n');
468
+ return out;
279
469
  }
280
470
  /**
281
471
  * Pre-serialize every non-empty variant value, reusing the per-atom
@@ -408,9 +598,14 @@ const EMPTY_BREAKPOINTS = new Map();
408
598
  * manifest emits `registerBreakpoints({...})` so the runtime can gate
409
599
  * `md:*` / `lg:*` atoms on `windowWidth`. Optional — empty when the
410
600
  * theme declares no breakpoints (legacy/test callers).
601
+ * @param gradients Gradient feature map (atom → role/colour) for the manifest + molecule eligibility.
602
+ * @param haptics Haptic feature map (atom → request) for the manifest + molecule eligibility.
603
+ * @param literals Distinct literal className strings — pre-merged into
604
+ * per-scheme molecules so the runtime resolver's O(1) molecule-first
605
+ * path is populated. Empty for legacy/test callers (atom path only).
411
606
  * @returns Per-scheme sources, manifest source, variant list.
412
607
  */
413
- function buildSchemeSources(atomNames, resolved, keyframes, cache, breakpoints = EMPTY_BREAKPOINTS) {
608
+ function buildSchemeSources(atomNames, resolved, keyframes, cache, breakpoints = EMPTY_BREAKPOINTS, gradients = EMPTY_FEATURE_MAP, haptics = EMPTY_FEATURE_MAP, literals = EMPTY_LITERALS) {
414
609
  const variants = collectVariantSchemes(resolved);
415
610
  const commonEntries = [];
416
611
  const variantEntries = {};
@@ -426,19 +621,24 @@ function buildSchemeSources(atomNames, resolved, keyframes, cache, breakpoints =
426
621
  continue;
427
622
  misses += collectAtomEntries(atom, schemed, canonical, variants, keyframes, commonEntries, variantEntries, cache);
428
623
  }
624
+ const molecules = buildMolecules(literals, resolved, keyframes, variants, gradients, haptics);
429
625
  const schemeSources = {
430
- [COMMON_SCHEME]: renderSchemeFile(COMMON_SCHEME, commonEntries),
626
+ [COMMON_SCHEME]: renderSchemeFile(COMMON_SCHEME, commonEntries, molecules[COMMON_SCHEME]),
431
627
  };
432
628
  for (const variant of variants) {
433
- schemeSources[variant] = renderSchemeFile(variant, variantEntries[variant]);
629
+ schemeSources[variant] = renderSchemeFile(variant, variantEntries[variant], molecules[variant]);
434
630
  }
435
631
  return {
436
632
  schemeSources,
437
- manifestSource: renderManifest(variants, breakpoints),
633
+ manifestSource: renderManifest(variants, breakpoints, gradients, haptics),
438
634
  variants,
439
635
  serializedMisses: misses,
440
636
  };
441
637
  }
638
+ /** Shared empty feature map default. */
639
+ const EMPTY_FEATURE_MAP = new Map();
640
+ /** Shared empty literal-list default (atom-only callers). */
641
+ const EMPTY_LITERALS = [];
442
642
 
443
643
  exports.buildSchemeSources = buildSchemeSources;
444
644
  //# 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'\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 * Per-file value deduplicator — interns each unique serialized atom\n * value once and emits `const _s<N> = <value>` at module scope. Scheme\n * entries reference the const instead of inlining the literal.\n *\n * Wins: (1) smaller bundle bytes for themes with many atoms sharing a\n * style shape; (2) stable `===` inside one scheme so two atoms\n * resolving to the same value yield the same object reference.\n */\nclass ValueDeduper {\n private readonly byText = new Map<string, string>()\n private readonly decls: string[] = []\n\n intern(serialized: string): string {\n const existing = this.byText.get(serialized)\n if (existing) return existing\n const name = `_s${this.decls.length}`\n this.decls.push(`const ${name} = ${serialized}`)\n this.byText.set(serialized, name)\n return name\n }\n\n get declarations(): readonly string[] {\n return this.decls\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.\n * @param schemeName Registry key (`'common'` or the variant name).\n * @param entries `[atomName, serializedValue]` pairs to emit.\n * @returns JS source text.\n */\nfunction renderSchemeFile(schemeName: string, entries: readonly (readonly [string, string])[]): string {\n const needsStyleSheet = entries.some(([atom]) => isHairlineAtom(atom))\n const deduper = new ValueDeduper()\n const recordLines: string[] = []\n for (const [atom, value] of entries) {\n const ref = deduper.intern(value)\n recordLines.push(` ${JSON.stringify(atom)}: ${ref},`)\n }\n\n const lines: string[] = []\n if (needsStyleSheet) lines.push(`import { StyleSheet } from 'react-native'`)\n lines.push(`import { registerAtoms } from 'rnwind'`, ``)\n if (deduper.declarations.length > 0) {\n for (const decl of deduper.declarations) lines.push(decl)\n lines.push(``)\n }\n lines.push(`registerAtoms(${JSON.stringify(schemeName)}, {`, ...recordLines, `})`, ``)\n return lines.join('\\n')\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` (every\n * rewritten source file pulls this via a transitive side-effect\n * import), registers the responsive-breakpoint table once, and lazy-\n * requires every variant scheme's file through an inline require —\n * first call in `ensureSchemeLoaded(name)` triggers the scheme\n * module's evaluation; Metro's module cache makes subsequent calls\n * no-ops.\n * @param variants Variant scheme names (no `base`, no `common`).\n * @param breakpoints Responsive breakpoint name → px-threshold map.\n * @returns JS source text.\n */\nfunction renderManifest(variants: readonly string[], breakpoints: ReadonlyMap<string, number>): string {\n const lines: string[] = [\n `import { registerSchemeLoader, registerBreakpoints } from 'rnwind'`,\n `import './common.style'`,\n ``,\n `registerBreakpoints(${serializeBreakpoints(breakpoints)})`,\n ``,\n ]\n if (variants.length === 0) {\n lines.push(`function ensureSchemeLoaded(_name) {}`, ``, `registerSchemeLoader(ensureSchemeLoaded)`, ``, `export { ensureSchemeLoaded }`, ``)\n return lines.join('\\n')\n }\n lines.push(`const LOADERS = {`)\n for (const variant of variants) {\n lines.push(` ${JSON.stringify(variant)}: () => require(${JSON.stringify(`./${variant}.style`)}),`)\n }\n lines.push(`}`, ``, `function ensureSchemeLoaded(name) {`, ` const loader = LOADERS[name]`, ` if (loader) loader()`, `}`, ``, `registerSchemeLoader(ensureSchemeLoaded)`, ``, `export { ensureSchemeLoaded }`, ``)\n return lines.join('\\n')\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 * @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): 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 schemeSources: Record<string, string> = {\n [COMMON_SCHEME]: renderSchemeFile(COMMON_SCHEME, commonEntries),\n }\n for (const variant of variants) {\n schemeSources[variant] = renderSchemeFile(variant, variantEntries[variant])\n }\n\n return {\n schemeSources,\n manifestSource: renderManifest(variants, breakpoints),\n variants,\n serializedMisses: misses,\n }\n}\n\n/** Registry key the runtime uses for the always-loaded fallback. */\nexport const COMMON_SCHEME_NAME: string = COMMON_SCHEME\n"],"names":[],"mappings":";;AAEA;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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C;IACnH;AAEA,IAAA,MAAM,aAAa,GAA2B;QAC5C,CAAC,aAAa,GAAG,gBAAgB,CAAC,aAAa,EAAE,aAAa,CAAC;KAChE;AACD,IAAA,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;AAC9B,QAAA,aAAa,CAAC,OAAO,CAAC,GAAG,gBAAgB,CAAC,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IAC7E;IAEA,OAAO;QACL,aAAa;AACb,QAAA,cAAc,EAAE,cAAc,CAAC,QAAQ,EAAE,WAAW,CAAC;QACrD,QAAQ;AACR,QAAA,gBAAgB,EAAE,MAAM;KACzB;AACH;;;;"}
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;IACl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