@oxyhq/bloom 0.7.5 → 0.7.7

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 (66) hide show
  1. package/lib/commonjs/theme/apply-dark-class.js +28 -10
  2. package/lib/commonjs/theme/apply-dark-class.js.map +1 -1
  3. package/lib/commonjs/theme/color-presets.js +10 -4
  4. package/lib/commonjs/theme/color-presets.js.map +1 -1
  5. package/lib/commonjs/theme/color-scope/index.web.js +19 -2
  6. package/lib/commonjs/theme/color-scope/index.web.js.map +1 -1
  7. package/lib/commonjs/theme/index.js +6 -0
  8. package/lib/commonjs/theme/index.js.map +1 -1
  9. package/lib/commonjs/theme/native-root-vars.js +32 -117
  10. package/lib/commonjs/theme/native-root-vars.js.map +1 -1
  11. package/lib/commonjs/theme/native-root-vars.native.js +127 -0
  12. package/lib/commonjs/theme/native-root-vars.native.js.map +1 -0
  13. package/lib/commonjs/theme/preset-vars.js +54 -1
  14. package/lib/commonjs/theme/preset-vars.js.map +1 -1
  15. package/lib/module/theme/apply-dark-class.js +24 -11
  16. package/lib/module/theme/apply-dark-class.js.map +1 -1
  17. package/lib/module/theme/color-presets.js +10 -4
  18. package/lib/module/theme/color-presets.js.map +1 -1
  19. package/lib/module/theme/color-scope/index.web.js +22 -3
  20. package/lib/module/theme/color-scope/index.web.js.map +1 -1
  21. package/lib/module/theme/index.js +1 -1
  22. package/lib/module/theme/index.js.map +1 -1
  23. package/lib/module/theme/native-root-vars.js +32 -116
  24. package/lib/module/theme/native-root-vars.js.map +1 -1
  25. package/lib/module/theme/native-root-vars.native.js +122 -0
  26. package/lib/module/theme/native-root-vars.native.js.map +1 -0
  27. package/lib/module/theme/preset-vars.js +53 -1
  28. package/lib/module/theme/preset-vars.js.map +1 -1
  29. package/lib/typescript/commonjs/theme/apply-dark-class.d.ts +18 -9
  30. package/lib/typescript/commonjs/theme/apply-dark-class.d.ts.map +1 -1
  31. package/lib/typescript/commonjs/theme/color-presets.d.ts +10 -4
  32. package/lib/typescript/commonjs/theme/color-presets.d.ts.map +1 -1
  33. package/lib/typescript/commonjs/theme/color-scope/index.web.d.ts.map +1 -1
  34. package/lib/typescript/commonjs/theme/index.d.ts +1 -1
  35. package/lib/typescript/commonjs/theme/index.d.ts.map +1 -1
  36. package/lib/typescript/commonjs/theme/native-root-vars.d.ts +30 -90
  37. package/lib/typescript/commonjs/theme/native-root-vars.d.ts.map +1 -1
  38. package/lib/typescript/commonjs/theme/native-root-vars.native.d.ts +94 -0
  39. package/lib/typescript/commonjs/theme/native-root-vars.native.d.ts.map +1 -0
  40. package/lib/typescript/commonjs/theme/preset-vars.d.ts +30 -0
  41. package/lib/typescript/commonjs/theme/preset-vars.d.ts.map +1 -1
  42. package/lib/typescript/module/theme/apply-dark-class.d.ts +18 -9
  43. package/lib/typescript/module/theme/apply-dark-class.d.ts.map +1 -1
  44. package/lib/typescript/module/theme/color-presets.d.ts +10 -4
  45. package/lib/typescript/module/theme/color-presets.d.ts.map +1 -1
  46. package/lib/typescript/module/theme/color-scope/index.web.d.ts.map +1 -1
  47. package/lib/typescript/module/theme/index.d.ts +1 -1
  48. package/lib/typescript/module/theme/index.d.ts.map +1 -1
  49. package/lib/typescript/module/theme/native-root-vars.d.ts +30 -90
  50. package/lib/typescript/module/theme/native-root-vars.d.ts.map +1 -1
  51. package/lib/typescript/module/theme/native-root-vars.native.d.ts +94 -0
  52. package/lib/typescript/module/theme/native-root-vars.native.d.ts.map +1 -0
  53. package/lib/typescript/module/theme/preset-vars.d.ts +30 -0
  54. package/lib/typescript/module/theme/preset-vars.d.ts.map +1 -1
  55. package/package.json +1 -1
  56. package/src/__tests__/BloomColorScope.test.tsx +14 -0
  57. package/src/__tests__/apply-dark-class.test.ts +65 -0
  58. package/src/__tests__/native-root-vars.test.ts +30 -4
  59. package/src/__tests__/preset-vars.test.ts +47 -1
  60. package/src/theme/apply-dark-class.ts +24 -11
  61. package/src/theme/color-presets.ts +10 -4
  62. package/src/theme/color-scope/index.web.tsx +23 -2
  63. package/src/theme/index.ts +1 -0
  64. package/src/theme/native-root-vars.native.ts +123 -0
  65. package/src/theme/native-root-vars.ts +32 -118
  66. package/src/theme/preset-vars.ts +53 -1
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+
3
+ /// <reference path="../react-native-css.d.ts" />
4
+ // The triple-slash reference above pins Bloom's ambient declaration for
5
+ // `react-native-css/native-internal` (`src/react-native-css.d.ts`) into the
6
+ // compilation graph of EVERY program that compiles THIS file — including
7
+ // downstream consumers that resolve Bloom's `"react-native"` source export
8
+ // condition (`./src/theme/index.ts` → `BloomThemeProvider` → this file). Without
9
+ // it the ambient decl is only auto-loaded inside Bloom's own tsconfig
10
+ // (`include: ["src"]`); a consumer's tsconfig never includes
11
+ // `node_modules/@oxyhq/bloom/src/**`, and TypeScript does NOT auto-pick-up
12
+ // ambient `.d.ts` files that live under `node_modules`, so
13
+ // `react-native-css/native-internal` is unresolved (TS2307) unless the reference
14
+ // travels with the source. react-native-css is intentionally NOT a Bloom
15
+ // dependency — it arrives transitively via a host's NativeWind 5 install, or is
16
+ // absent entirely for NativeWind 4 consumers — so the ambient declaration is the
17
+ // only thing that can type this import, and it MUST reach the consumer. The
18
+ // directive ships raw in `src/` (Bloom publishes `files: ["src", "lib"]`).
19
+ import { rootVariables } from 'react-native-css/native-internal';
20
+ import { buildScopeVars } from "./color-scope/style-builder.js";
21
+ /**
22
+ * Publish the active color preset's CSS custom properties into react-native-css's
23
+ * GLOBAL root-variable family so they reach the ENTIRE native app tree — including
24
+ * content rendered outside the React subtree of `BloomThemeProvider`: expo-router
25
+ * navigator screens, `Portal`s, `Dialog`/`BottomSheet` overlays, and any other host
26
+ * that paints through a separate React root.
27
+ *
28
+ * Why a global write is required (native only)
29
+ * --------------------------------------------
30
+ * react-native-css resolves a `var(--x)` reference (its `varResolver`) in this order:
31
+ * 1. `name in inheritedVariables` — the React-context-inherited vars. This is what
32
+ * `VariableContextProvider` populates, but it is React-context-scoped, so it only
33
+ * reaches *direct descendants* of the provider in the React tree.
34
+ * 2. `inlineVariables[name]` — same-component inline vars.
35
+ * 3. `variables[name]` — resolved inherited vars.
36
+ * 4. `universalVariables(name)` — a GLOBAL observable family.
37
+ * 5. `rootVariables(name)` — a GLOBAL observable family.
38
+ * 6. the declared fallback.
39
+ *
40
+ * `BloomThemeProvider`'s `VariableContextProvider` only feeds path #1, so the navigator
41
+ * host and every portal/modal — which render outside that subtree — never see the
42
+ * preset vars and fall through to `rootVariables`/`universalVariables`. By default those
43
+ * families hold only react-native-css's own `__rn-css-rem`/`__rn-css-color` entries
44
+ * (Bloom's `global.css` defines the `hsl(var(--primary))` indirection but not the HSL
45
+ * triples themselves — those are injected at runtime), so the whole tree below the
46
+ * navigator renders monochrome. Writing the vars into `rootVariables` here is the
47
+ * exact same mechanism react-native-css uses for compiled `:root {}` / `@theme` vars
48
+ * (`StyleCollection.inject` does `rootVariables(name).set(valueArray)`), so portaled
49
+ * content resolves the palette identically regardless of React-tree position.
50
+ *
51
+ * The raw tokens are written as HSL triples (`primary: '205 87% 53%'`) and the
52
+ * resolved Tailwind v4 `--color-*` vars as sRGB `rgb(...)` (`color-primary:
53
+ * 'rgb(31 153 239)'`) — the latter so `color-mix`-based alpha utilities resolve
54
+ * on native (see `getPresetVars` / `hslTripletToRgb`).
55
+ *
56
+ * Why a STATIC `import`, not a runtime `require` (critical)
57
+ * ---------------------------------------------------------
58
+ * react-native-css@3.0.7 ships both a `dist/commonjs` and a `dist/module` build, and
59
+ * Metro bundles BOTH. In `native-internal/root.js` the variable families are plain
60
+ * module-local consts — NOT `globalThis`-guarded the way `StyleCollection` is — so the
61
+ * commonjs `root.js` and the module `root.js` each instantiate their OWN separate
62
+ * `rootVariables` family. The react-native-css renderer (`react-native-css/src/components/View.tsx`
63
+ * → `varResolver`) imports its `root.js` via ESM `import`, i.e. the MODULE build. A
64
+ * runtime `require('react-native-css/native-internal')` resolves the package's `require`
65
+ * export condition → the COMMONJS build → a DIFFERENT family the renderer never
66
+ * subscribes to, so the writes are a silent no-op on device. A static top-level
67
+ * `import` resolves the `import` condition → the MODULE build → the renderer's instance.
68
+ *
69
+ * This plain file is the NATIVE/default variant (Metro selects it on iOS/Android,
70
+ * which have no `.native` override here); the web variant lives in the sibling
71
+ * `native-root-vars.web.ts` no-op, which web bundlers pick over this one. So the
72
+ * static `react-native-css/native-internal` import below is never pulled into a web
73
+ * bundle — only into native. This mirrors Bloom's existing platform-split convention
74
+ * (`color-scope/index.tsx` + `color-scope/index.web.tsx`, `FontLoader.native.tsx`).
75
+ *
76
+ * Keying contract (verified against react-native-css@3.0.7)
77
+ * ---------------------------------------------------------
78
+ * The `rootVariables` family is keyed by the BARE variable name, WITHOUT the leading
79
+ * `--`. The compiler strips it uniformly: a `:root { --primary: ... }` declaration is
80
+ * stored via `rule.v.push([property.slice(2), value])` then routed into
81
+ * `shared.rootVariables[name]`, and `@property --x` goes through
82
+ * `name.startsWith("--") ? name.slice(2) : name`. The lookup side matches: a `var(--x)`
83
+ * reference compiles to `[{}, "var", ident.slice(2)]`, so `varResolver` looks up the
84
+ * bare name. `buildScopeVars` returns keys WITH the `--` prefix, so we strip it before
85
+ * writing each entry.
86
+ *
87
+ * Value shape
88
+ * -----------
89
+ * Each entry is a `VariableValue[]` — an array of `[value, mediaCondition?]` tuples.
90
+ * Bloom's preset vars are unconditional, so each is a single-element `[[value]]`, e.g.
91
+ * `rootVariables('primary').set([['205 87% 53%']])`. This is the same shape the compiler
92
+ * emits for unconditional `:root` vars.
93
+ *
94
+ * This is native-only and additive: the `VariableContextProvider` wrapper stays (it is
95
+ * the correct, scoped mechanism for `BloomColorScope` subtree overrides and harmlessly
96
+ * covers direct descendants). The web fork (`native-root-vars.web.ts`) no-ops — web
97
+ * writes the same vars to `document.documentElement` via `applyColorPresetVars`.
98
+ */
99
+
100
+ /**
101
+ * Write the preset's CSS vars to react-native-css's global `rootVariables` family
102
+ * so the whole native tree (navigator screens + portals/modals/bottom-sheets)
103
+ * resolves the active palette.
104
+ *
105
+ * Each `.set` notifies its own observers synchronously (react-native-css only
106
+ * batches notifications inside its own `StyleCollection.inject`; outside it,
107
+ * `observableBatch.current` is unset so every `.set` runs observers immediately),
108
+ * so sequential writes correctly trigger a re-render when the preset/mode changes.
109
+ *
110
+ * Defensive guard: if a host ships a react-native-css build that doesn't expose
111
+ * `rootVariables` as a callable (it always does on @3), we bail rather than throw.
112
+ */
113
+ export function applyNativeRootVars(colorPreset, mode) {
114
+ if (typeof rootVariables !== 'function') return;
115
+ const vars = buildScopeVars(colorPreset, mode);
116
+ for (const [key, value] of Object.entries(vars)) {
117
+ // The family is keyed by the bare name; `buildScopeVars` keys include `--`.
118
+ const name = key.startsWith('--') ? key.slice(2) : key;
119
+ rootVariables(name).set([[value]]);
120
+ }
121
+ }
122
+ //# sourceMappingURL=native-root-vars.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["rootVariables","buildScopeVars","applyNativeRootVars","colorPreset","mode","vars","key","value","Object","entries","name","startsWith","slice","set"],"sourceRoot":"../../../src","sources":["theme/native-root-vars.native.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,kCAAkC;AAEhE,SAASC,cAAc,QAAQ,gCAA6B;AAG5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAACC,WAAyB,EAAEC,IAAsB,EAAQ;EAC3F,IAAI,OAAOJ,aAAa,KAAK,UAAU,EAAE;EAEzC,MAAMK,IAAI,GAAGJ,cAAc,CAACE,WAAW,EAAEC,IAAI,CAAC;EAC9C,KAAK,MAAM,CAACE,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACJ,IAAI,CAAC,EAAE;IAC/C;IACA,MAAMK,IAAI,GAAGJ,GAAG,CAACK,UAAU,CAAC,IAAI,CAAC,GAAGL,GAAG,CAACM,KAAK,CAAC,CAAC,CAAC,GAAGN,GAAG;IACtDN,aAAa,CAACU,IAAI,CAAC,CAACG,GAAG,CAAC,CAAC,CAACN,KAAK,CAAC,CAAC,CAAC;EACpC;AACF","ignoreList":[]}
@@ -73,6 +73,53 @@ export function hslTripletToRgb(triplet) {
73
73
  }
74
74
  return `rgb(${red} ${green} ${blue})`;
75
75
  }
76
+
77
+ /**
78
+ * Prefix that marks a Tailwind v4 resolved color var (`--color-primary`). These
79
+ * are already emitted as full `rgb(...)` colors by `getPresetVars` and must be
80
+ * written to web verbatim — wrapping them would corrupt the value.
81
+ */
82
+ const RESOLVED_COLOR_VAR_PREFIX = '--color-';
83
+
84
+ /**
85
+ * Matches a shadcn-style raw HSL triple — `H S% L%`, optionally with an alpha
86
+ * tail `H S% L% / A`. The value starts with a digit (or a leading `-`) and
87
+ * carries at least one `%` (the saturation/lightness units), which together
88
+ * distinguish a bare triple from an already-resolved CSS color (`rgb(...)`,
89
+ * `hsl(...)`, `#fff`, named colors) or a unitless/length token (`--radius`).
90
+ * Mirrors the triple shape parsed by `hslTripletToRgb`.
91
+ */
92
+ const RAW_HSL_TRIPLE = /^-?\d[\d.]*\s+[\d.]+%/;
93
+
94
+ /**
95
+ * Transform a single preset var into the value to write to a WEB element
96
+ * (`document.documentElement` or a `BloomColorScope` subtree element).
97
+ *
98
+ * The web apps (Vite + Tailwind v4 + shadcn) compile their `@theme inline`
99
+ * block so the color utilities reference the BASE token directly — e.g.
100
+ * `.bg-background { background-color: var(--background) }`. So on web the base
101
+ * `--x` tokens MUST resolve to a COMPLETE CSS color; a bare HSL triple
102
+ * (`185 50% 5%`) is invalid as a `background-color` value and renders
103
+ * transparent (the production incident this fixes). We therefore wrap raw
104
+ * triples in `hsl(...)`, preserving the exact preset color math (and any `/ A`
105
+ * alpha tail, valid in modern `hsl(H S% L% / A)` syntax) with zero rounding
106
+ * drift.
107
+ *
108
+ * Values that are already full colors pass through unchanged:
109
+ * - `--color-*` resolved vars (already `rgb(...)` from `getPresetVars`),
110
+ * - any value not shaped like a raw HSL triple (`--radius: 0.5rem`,
111
+ * pre-resolved `rgb(...)`/`hsl(...)`, etc.).
112
+ *
113
+ * NATIVE never calls this — `getPresetVars` returns raw triples verbatim and
114
+ * `native-root-vars.native.ts` writes them through bloom's `hsl(var(--x))`
115
+ * native `global.css` indirection. Pure function — no side effects — so it is
116
+ * unit-testable in isolation.
117
+ */
118
+ export function toWebColorValue(key, value) {
119
+ if (key.startsWith(RESOLVED_COLOR_VAR_PREFIX)) return value;
120
+ if (!RAW_HSL_TRIPLE.test(value)) return value;
121
+ return `hsl(${value})`;
122
+ }
76
123
  const RESOLVED_COLOR_MAP = {
77
124
  '--background': '--color-background',
78
125
  '--foreground': '--color-foreground',
@@ -149,13 +196,18 @@ export function getPresetVars(colorName, mode, options = {}) {
149
196
  * on native. `BloomThemeProvider` already writes the base preset vars on web;
150
197
  * call this only when an app needs the extended (card/chart/sidebar) tokens on
151
198
  * the document root.
199
+ *
200
+ * The base raw-HSL-triple tokens are wrapped to full `hsl(...)` colors via
201
+ * `toWebColorValue` so `var(--x)` (the form Tailwind v4 `@theme inline`
202
+ * compiles to) resolves directly on web; `--color-*` rgb vars pass through. See
203
+ * `toWebColorValue` for the web var contract.
152
204
  */
153
205
  export function applyPresetVarsToDocument(colorName, mode, options) {
154
206
  if (Platform.OS !== 'web' || typeof document === 'undefined') return;
155
207
  const vars = getPresetVars(colorName, mode, options);
156
208
  const root = document.documentElement.style;
157
209
  for (const [key, value] of Object.entries(vars)) {
158
- root.setProperty(key, value);
210
+ root.setProperty(key, toWebColorValue(key, value));
159
211
  }
160
212
  }
161
213
  //# sourceMappingURL=preset-vars.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Platform","APP_COLOR_PRESETS","extractHue","hslVar","parseInt","split","extractSat","hslTripletToRgb","triplet","colorPart","alphaPart","map","part","trim","channels","filter","Boolean","hue","parseFloat","replace","sat","light","h","Number","isFinite","s","l","chroma","Math","abs","huePrime","second","r","g","b","match","red","round","green","blue","undefined","alpha","endsWith","safeAlpha","RESOLVED_COLOR_MAP","getPresetVars","colorName","mode","options","preset","base","dark","get","key","primary","foreground","min","isDark","extended","includeResolvedColorVars","resolved","rawKey","colorKey","Object","entries","value","applyPresetVarsToDocument","OS","document","vars","root","documentElement","style","setProperty"],"sourceRoot":"../../../src","sources":["theme/preset-vars.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,iBAAiB,QAA8C,oBAAiB;AAEzF,SAASC,UAAUA,CAACC,MAAc,EAAU;EAC1C,OAAOC,QAAQ,CAACD,MAAM,CAACE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,EAAE,CAAC;AAClD;AAEA,SAASC,UAAUA,CAACH,MAAc,EAAU;EAC1C,OAAOC,QAAQ,CAACD,MAAM,CAACE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,EAAE,CAAC;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,eAAeA,CAACC,OAAe,EAAU;EACvD,MAAM,CAACC,SAAS,EAAEC,SAAS,CAA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Int","split","extractSat","hslTripletToRgb","triplet","colorPart","alphaPart","map","part","trim","channels","filter","Boolean","hue","parseFloat","replace","sat","light","h","Number","isFinite","s","l","chroma","Math","abs","huePrime","second","r","g","b","match","red","round","green","blue","undefined","alpha","endsWith","safeAlpha","RESOLVED_COLOR_VAR_PREFIX","RAW_HSL_TRIPLE","toWebColorValue","key","value","startsWith","test","RESOLVED_COLOR_MAP","getPresetVars","colorName","mode","options","preset","base","dark","get","primary","foreground","min","isDark","extended","includeResolvedColorVars","resolved","rawKey","colorKey","Object","entries","applyPresetVarsToDocument","OS","document","vars","root","documentElement","style","setProperty"],"sourceRoot":"../../../src","sources":["theme/preset-vars.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,iBAAiB,QAA8C,oBAAiB;AAEzF,SAASC,UAAUA,CAACC,MAAc,EAAU;EAC1C,OAAOC,QAAQ,CAACD,MAAM,CAACE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,EAAE,CAAC;AAClD;AAEA,SAASC,UAAUA,CAACH,MAAc,EAAU;EAC1C,OAAOC,QAAQ,CAACD,MAAM,CAACE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,EAAE,CAAC;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,eAAeA,CAACC,OAAe,EAAU;EACvD,MAAM,CAACC,SAAS,EAAEC,SAAS,CAAC,GAAGF,OAAO,CAACH,KAAK,CAAC,GAAG,CAAC,CAACM,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACC,IAAI,CAAC,CAAC,CAAC;EAC5E,MAAMC,QAAQ,GAAG,CAACL,SAAS,IAAI,EAAE,EAAEJ,KAAK,CAAC,KAAK,CAAC,CAACU,MAAM,CAACC,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;EACpD,MAAMoB,IAAI,GAAGF,QAAQ,CAACG,eAAe,CAACC,KAAK;EAC3C,KAAK,MAAM,CAAC9B,GAAG,EAAEC,KAAK,CAAC,IAAIqB,MAAM,CAACC,OAAO,CAACI,IAAI,CAAC,EAAE;IAC/CC,IAAI,CAACG,WAAW,CAAC/B,GAAG,EAAED,eAAe,CAACC,GAAG,EAAEC,KAAK,CAAC,CAAC;EACpD;AACF","ignoreList":[]}
@@ -1,17 +1,26 @@
1
1
  import { type AppColorName } from './color-presets';
2
+ export { toWebColorValue } from './preset-vars';
2
3
  export declare function applyDarkClass(resolved: 'light' | 'dark'): void;
3
4
  /**
4
5
  * Apply a color preset's CSS custom properties to the document root.
5
- * No-op on native — only affects web.
6
+ * No-op on native — only affects web (early-returns on `Platform.OS !== 'web'`).
6
7
  *
7
- * Writes both the raw HSL triples (e.g. `--primary: 185 100% 20%`) and the
8
- * resolved `--color-*` vars (`--color-primary: rgb(0 94 102)`) so both
9
- * shadcn-style `hsl(var(--primary))` plumbing and Tailwind v4 `@theme`
10
- * utilities resolve consistently. The resolved vars are emitted as `rgb(...)`
11
- * (not `hsl(...)`) so the alpha utilities (`bg-primary/10`) resolve on native
12
- * see `getPresetVars` / `hslTripletToRgb`. Includes extended tokens (card,
13
- * chart-*, content-area, sidebar-*) so consumer apps don't need to synthesize
14
- * them.
8
+ * Web var contract (the form Tailwind v4 `@theme inline` compiles to)
9
+ * -------------------------------------------------------------------
10
+ * The shadcn/Tailwind-v4 web apps compile their color utilities to reference the
11
+ * BASE token directly (`.bg-background { background-color: var(--background) }`),
12
+ * so on web the base `--x` tokens MUST be FULL CSS colors. We therefore write
13
+ * them as `hsl(...)` (e.g. `--primary: hsl(185 100% 20%)`) — `var(--primary)`
14
+ * then resolves to a valid color. The resolved `--color-*` vars are written
15
+ * verbatim as `rgb(...)` (already full colors, used by native `color-mix` alpha
16
+ * utilities; harmless on web). Non-color tokens (`--radius`, etc.) pass through
17
+ * unchanged. See `toWebColorValue`.
18
+ *
19
+ * NATIVE writes the SAME tokens as RAW HSL triples (no `hsl()` wrapper) via
20
+ * `rootVariables` (`native-root-vars.native.ts`), consumed through bloom's
21
+ * native `global.css` `hsl(var(--x))` indirection — that path is untouched here.
22
+ * Includes extended tokens (card, chart-*, content-area, sidebar-*) so consumer
23
+ * apps don't need to synthesize them.
15
24
  */
16
25
  export declare function applyColorPresetVars(preset: AppColorName, resolved: 'light' | 'dark'): void;
17
26
  //# sourceMappingURL=apply-dark-class.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"apply-dark-class.d.ts","sourceRoot":"","sources":["../../../../src/theme/apply-dark-class.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGvE,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,QAIxD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,QAUpF"}
1
+ {"version":3,"file":"apply-dark-class.d.ts","sourceRoot":"","sources":["../../../../src/theme/apply-dark-class.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAMvE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,QAIxD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,QAUpF"}
@@ -6,10 +6,16 @@ export type AppColorName = 'teal' | 'blue' | 'green' | 'amber' | 'yellow' | 'red
6
6
  * names) — keep in mind the values are platform-agnostic **raw HSL triples**
7
7
  * (e.g. `'185 100% 20%'` or `'185 100% 20% / 0.5'`), not CSS-resolved colors.
8
8
  * The same map drives both:
9
- * - the web layer (written verbatim into `document.documentElement.style`
10
- * so Tailwind's `hsl(var(--primary))` plumbing picks them up), and
11
- * - the native layer (`buildTheme` resolves them into `hsl(...)` strings
12
- * consumable by React Native styles).
9
+ * - the web layer: the base `--x` tokens are wrapped to full `hsl(...)` colors
10
+ * (via `toWebColorValue`) before being written to `document.documentElement`
11
+ * / a `BloomColorScope` element, so `var(--x)` — the form Tailwind v4
12
+ * `@theme inline` compiles its color utilities to — resolves to a valid
13
+ * color directly; the resolved `--color-*` companions are written as
14
+ * `rgb(...)`, and
15
+ * - the native layer (`buildTheme` resolves the raw triples into `hsl(...)`
16
+ * strings consumable by React Native styles; `native-root-vars.native.ts`
17
+ * writes the raw triples through bloom's `hsl(var(--x))` `global.css`
18
+ * indirection).
13
19
  *
14
20
  * The `--` prefix is an implementation detail we will drop in a future major.
15
21
  */
@@ -1 +1 @@
1
- {"version":3,"file":"color-presets.d.ts","sourceRoot":"","sources":["../../../../src/theme/color-presets.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,UAAU,CAAC;AAEvJ;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAElD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,YAAY,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,eAAO,MAAM,eAAe,EAAE,SAAS,YAAY,EAAsH,CAAC;AAE1K,wEAAwE;AACxE,eAAO,MAAM,mBAAmB,EAAE,SAAS,YAAY,EAAwB,CAAC;AAEhF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAczD,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAE3D;AAED,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,YAAY,EAAE,cAAc,CAkmBlE,CAAC"}
1
+ {"version":3,"file":"color-presets.d.ts","sourceRoot":"","sources":["../../../../src/theme/color-presets.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,UAAU,CAAC;AAEvJ;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAElD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,YAAY,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,eAAO,MAAM,eAAe,EAAE,SAAS,YAAY,EAAsH,CAAC;AAE1K,wEAAwE;AACxE,eAAO,MAAM,mBAAmB,EAAE,SAAS,YAAY,EAAwB,CAAC;AAEhF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAczD,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAE3D;AAED,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,YAAY,EAAE,cAAc,CAkmBlE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../../src/theme/color-scope/index.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsE,MAAM,OAAO,CAAC;AAI3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGrD,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,WAAW,EAAE,YAAY,GAAG,SAAS,CAAC;IACtC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yGAAyG;IACzG,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAuBD,wBAAgB,eAAe,CAAC,EAC9B,WAAW,EACX,OAAe,EACf,KAAK,EACL,QAAQ,GACT,EAAE,oBAAoB,2CA4CtB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,YAAY,GAAG,KAAK,CAAC,aAAa,CAUjF"}
1
+ {"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../../src/theme/color-scope/index.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsE,MAAM,OAAO,CAAC;AAI3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAwBrD,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,WAAW,EAAE,YAAY,GAAG,SAAS,CAAC;IACtC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yGAAyG;IACzG,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAuBD,wBAAgB,eAAe,CAAC,EAC9B,WAAW,EACX,OAAe,EACf,KAAK,EACL,QAAQ,GACT,EAAE,oBAAoB,2CA4CtB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,YAAY,GAAG,KAAK,CAAC,aAAa,CAUjF"}
@@ -7,7 +7,7 @@ export { useTheme, useThemeColor, useBloomTheme } from './use-theme';
7
7
  export type { Theme, ThemeColors, ThemeMode } from './types';
8
8
  export type { AppColorName, AppColorPreset, PresetTokens } from './color-presets';
9
9
  export { APP_COLOR_NAMES, PREMIUM_COLOR_NAMES, APP_COLOR_PRESETS, HEX_TO_APP_COLOR, hexToAppColorName, } from './color-presets';
10
- export { getPresetVars, applyPresetVarsToDocument, } from './preset-vars';
10
+ export { getPresetVars, applyPresetVarsToDocument, toWebColorValue, } from './preset-vars';
11
11
  export type { PresetVarsOptions } from './preset-vars';
12
12
  export { applyDarkClass } from './apply-dark-class';
13
13
  export { setColorSchemeSafe } from './set-color-scheme-safe';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/theme/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EACV,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACpE,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACrE,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7D,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,aAAa,EACb,yBAAyB,GAC1B,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,sB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AAe,CAAC"}
@@ -1,94 +1,34 @@
1
1
  import { type AppColorName } from './color-presets';
2
2
  /**
3
- * Publish the active color preset's CSS custom properties into react-native-css's
4
- * GLOBAL root-variable family so they reach the ENTIRE native app tree — including
5
- * content rendered outside the React subtree of `BloomThemeProvider`: expo-router
6
- * navigator screens, `Portal`s, `Dialog`/`BottomSheet` overlays, and any other host
7
- * that paints through a separate React root.
8
- *
9
- * Why a global write is required (native only)
10
- * --------------------------------------------
11
- * react-native-css resolves a `var(--x)` reference (its `varResolver`) in this order:
12
- * 1. `name in inheritedVariables` — the React-context-inherited vars. This is what
13
- * `VariableContextProvider` populates, but it is React-context-scoped, so it only
14
- * reaches *direct descendants* of the provider in the React tree.
15
- * 2. `inlineVariables[name]` — same-component inline vars.
16
- * 3. `variables[name]` — resolved inherited vars.
17
- * 4. `universalVariables(name)` a GLOBAL observable family.
18
- * 5. `rootVariables(name)` — a GLOBAL observable family.
19
- * 6. the declared fallback.
20
- *
21
- * `BloomThemeProvider`'s `VariableContextProvider` only feeds path #1, so the navigator
22
- * host and every portal/modal which render outside that subtree — never see the
23
- * preset vars and fall through to `rootVariables`/`universalVariables`. By default those
24
- * families hold only react-native-css's own `__rn-css-rem`/`__rn-css-color` entries
25
- * (Bloom's `global.css` defines the `hsl(var(--primary))` indirection but not the HSL
26
- * triples themselves those are injected at runtime), so the whole tree below the
27
- * navigator renders monochrome. Writing the vars into `rootVariables` here is the
28
- * exact same mechanism react-native-css uses for compiled `:root {}` / `@theme` vars
29
- * (`StyleCollection.inject` does `rootVariables(name).set(valueArray)`), so portaled
30
- * content resolves the palette identically regardless of React-tree position.
31
- *
32
- * The raw tokens are written as HSL triples (`primary: '205 87% 53%'`) and the
33
- * resolved Tailwind v4 `--color-*` vars as sRGB `rgb(...)` (`color-primary:
34
- * 'rgb(31 153 239)'`) — the latter so `color-mix`-based alpha utilities resolve
35
- * on native (see `getPresetVars` / `hslTripletToRgb`).
36
- *
37
- * Why a STATIC `import`, not a runtime `require` (critical)
38
- * ---------------------------------------------------------
39
- * react-native-css@3.0.7 ships both a `dist/commonjs` and a `dist/module` build, and
40
- * Metro bundles BOTH. In `native-internal/root.js` the variable families are plain
41
- * module-local consts — NOT `globalThis`-guarded the way `StyleCollection` is — so the
42
- * commonjs `root.js` and the module `root.js` each instantiate their OWN separate
43
- * `rootVariables` family. The react-native-css renderer (`react-native-css/src/components/View.tsx`
44
- * → `varResolver`) imports its `root.js` via ESM `import`, i.e. the MODULE build. A
45
- * runtime `require('react-native-css/native-internal')` resolves the package's `require`
46
- * export condition → the COMMONJS build → a DIFFERENT family the renderer never
47
- * subscribes to, so the writes are a silent no-op on device. A static top-level
48
- * `import` resolves the `import` condition → the MODULE build → the renderer's instance.
49
- *
50
- * This plain file is the NATIVE/default variant (Metro selects it on iOS/Android,
51
- * which have no `.native` override here); the web variant lives in the sibling
52
- * `native-root-vars.web.ts` no-op, which web bundlers pick over this one. So the
53
- * static `react-native-css/native-internal` import below is never pulled into a web
54
- * bundle — only into native. This mirrors Bloom's existing platform-split convention
55
- * (`color-scope/index.tsx` + `color-scope/index.web.tsx`, `FontLoader.native.tsx`).
56
- *
57
- * Keying contract (verified against react-native-css@3.0.7)
58
- * ---------------------------------------------------------
59
- * The `rootVariables` family is keyed by the BARE variable name, WITHOUT the leading
60
- * `--`. The compiler strips it uniformly: a `:root { --primary: ... }` declaration is
61
- * stored via `rule.v.push([property.slice(2), value])` then routed into
62
- * `shared.rootVariables[name]`, and `@property --x` goes through
63
- * `name.startsWith("--") ? name.slice(2) : name`. The lookup side matches: a `var(--x)`
64
- * reference compiles to `[{}, "var", ident.slice(2)]`, so `varResolver` looks up the
65
- * bare name. `buildScopeVars` returns keys WITH the `--` prefix, so we strip it before
66
- * writing each entry.
67
- *
68
- * Value shape
69
- * -----------
70
- * Each entry is a `VariableValue[]` — an array of `[value, mediaCondition?]` tuples.
71
- * Bloom's preset vars are unconditional, so each is a single-element `[[value]]`, e.g.
72
- * `rootVariables('primary').set([['205 87% 53%']])`. This is the same shape the compiler
73
- * emits for unconditional `:root` vars.
74
- *
75
- * This is native-only and additive: the `VariableContextProvider` wrapper stays (it is
76
- * the correct, scoped mechanism for `BloomColorScope` subtree overrides and harmlessly
77
- * covers direct descendants). The web fork (`native-root-vars.web.ts`) no-ops — web
78
- * writes the same vars to `document.documentElement` via `applyColorPresetVars`.
79
- */
80
- /**
81
- * Write the preset's CSS vars to react-native-css's global `rootVariables` family
82
- * so the whole native tree (navigator screens + portals/modals/bottom-sheets)
83
- * resolves the active palette.
84
- *
85
- * Each `.set` notifies its own observers synchronously (react-native-css only
86
- * batches notifications inside its own `StyleCollection.inject`; outside it,
87
- * `observableBatch.current` is unset so every `.set` runs observers immediately),
88
- * so sequential writes correctly trigger a re-render when the preset/mode changes.
89
- *
90
- * Defensive guard: if a host ships a react-native-css build that doesn't expose
91
- * `rootVariables` as a callable (it always does on @3), we bail rather than throw.
3
+ * Platform-neutral DEFAULT variant of `applyNativeRootVars` a no-op.
4
+ *
5
+ * This is the file resolved by every bundler / type-checker that does NOT do
6
+ * React Native's platform-extension resolution:
7
+ * - a consumer's `tsc` (resolving Bloom's `"react-native"` -> `./src/...` source
8
+ * export condition: `theme/index.ts` -> `BloomThemeProvider` -> this import);
9
+ * - non-Metro web bundlers (Vite/Rolldown, webpack) resolving the package
10
+ * `exports` `import`/`require` conditions to `lib/.../native-root-vars.js`.
11
+ *
12
+ * It deliberately does NOT import `react-native-css/native-internal`. That subpath
13
+ * is native-only: it has no web build, and react-native-css is not even a Bloom
14
+ * dependency. Statically importing it from a file a web bundler resolves breaks
15
+ * module resolution outright (the original report: `Rolldown failed to resolve
16
+ * import "react-native-css/native-internal" from .../native-root-vars.js`).
17
+ * Importing it from a file a consumer's `tsc` resolves breaks type-check (TS2307).
18
+ *
19
+ * Confining the real implementation (and that import) to the `.native` sibling —
20
+ * `native-root-vars.native.ts`, which ONLY Metro selects — keeps both web bundling
21
+ * AND downstream `tsc` green, while native still publishes the preset vars into
22
+ * react-native-css's GLOBAL `rootVariables` family so the whole native tree
23
+ * (navigator screens + portals/modals) resolves the palette.
24
+ *
25
+ * The other variants:
26
+ * - `native-root-vars.native.ts`iOS/Android (Metro), the real implementation;
27
+ * - `native-root-vars.web.ts` web, also a no-op (web writes the same vars to
28
+ * `document.documentElement` via `applyColorPresetVars` instead).
29
+ *
30
+ * The signature is intentionally identical to those variants so the import site in
31
+ * `BloomThemeProvider` is platform-agnostic.
92
32
  */
93
- export declare function applyNativeRootVars(colorPreset: AppColorName, mode: 'light' | 'dark'): void;
33
+ export declare function applyNativeRootVars(_colorPreset: AppColorName, _mode: 'light' | 'dark'): void;
94
34
  //# sourceMappingURL=native-root-vars.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"native-root-vars.d.ts","sourceRoot":"","sources":["../../../../src/theme/native-root-vars.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AAEH;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAS3F"}
1
+ {"version":3,"file":"native-root-vars.d.ts","sourceRoot":"","sources":["../../../../src/theme/native-root-vars.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAG7F"}
@@ -0,0 +1,94 @@
1
+ import { type AppColorName } from './color-presets';
2
+ /**
3
+ * Publish the active color preset's CSS custom properties into react-native-css's
4
+ * GLOBAL root-variable family so they reach the ENTIRE native app tree — including
5
+ * content rendered outside the React subtree of `BloomThemeProvider`: expo-router
6
+ * navigator screens, `Portal`s, `Dialog`/`BottomSheet` overlays, and any other host
7
+ * that paints through a separate React root.
8
+ *
9
+ * Why a global write is required (native only)
10
+ * --------------------------------------------
11
+ * react-native-css resolves a `var(--x)` reference (its `varResolver`) in this order:
12
+ * 1. `name in inheritedVariables` — the React-context-inherited vars. This is what
13
+ * `VariableContextProvider` populates, but it is React-context-scoped, so it only
14
+ * reaches *direct descendants* of the provider in the React tree.
15
+ * 2. `inlineVariables[name]` — same-component inline vars.
16
+ * 3. `variables[name]` — resolved inherited vars.
17
+ * 4. `universalVariables(name)` — a GLOBAL observable family.
18
+ * 5. `rootVariables(name)` — a GLOBAL observable family.
19
+ * 6. the declared fallback.
20
+ *
21
+ * `BloomThemeProvider`'s `VariableContextProvider` only feeds path #1, so the navigator
22
+ * host and every portal/modal — which render outside that subtree — never see the
23
+ * preset vars and fall through to `rootVariables`/`universalVariables`. By default those
24
+ * families hold only react-native-css's own `__rn-css-rem`/`__rn-css-color` entries
25
+ * (Bloom's `global.css` defines the `hsl(var(--primary))` indirection but not the HSL
26
+ * triples themselves — those are injected at runtime), so the whole tree below the
27
+ * navigator renders monochrome. Writing the vars into `rootVariables` here is the
28
+ * exact same mechanism react-native-css uses for compiled `:root {}` / `@theme` vars
29
+ * (`StyleCollection.inject` does `rootVariables(name).set(valueArray)`), so portaled
30
+ * content resolves the palette identically regardless of React-tree position.
31
+ *
32
+ * The raw tokens are written as HSL triples (`primary: '205 87% 53%'`) and the
33
+ * resolved Tailwind v4 `--color-*` vars as sRGB `rgb(...)` (`color-primary:
34
+ * 'rgb(31 153 239)'`) — the latter so `color-mix`-based alpha utilities resolve
35
+ * on native (see `getPresetVars` / `hslTripletToRgb`).
36
+ *
37
+ * Why a STATIC `import`, not a runtime `require` (critical)
38
+ * ---------------------------------------------------------
39
+ * react-native-css@3.0.7 ships both a `dist/commonjs` and a `dist/module` build, and
40
+ * Metro bundles BOTH. In `native-internal/root.js` the variable families are plain
41
+ * module-local consts — NOT `globalThis`-guarded the way `StyleCollection` is — so the
42
+ * commonjs `root.js` and the module `root.js` each instantiate their OWN separate
43
+ * `rootVariables` family. The react-native-css renderer (`react-native-css/src/components/View.tsx`
44
+ * → `varResolver`) imports its `root.js` via ESM `import`, i.e. the MODULE build. A
45
+ * runtime `require('react-native-css/native-internal')` resolves the package's `require`
46
+ * export condition → the COMMONJS build → a DIFFERENT family the renderer never
47
+ * subscribes to, so the writes are a silent no-op on device. A static top-level
48
+ * `import` resolves the `import` condition → the MODULE build → the renderer's instance.
49
+ *
50
+ * This plain file is the NATIVE/default variant (Metro selects it on iOS/Android,
51
+ * which have no `.native` override here); the web variant lives in the sibling
52
+ * `native-root-vars.web.ts` no-op, which web bundlers pick over this one. So the
53
+ * static `react-native-css/native-internal` import below is never pulled into a web
54
+ * bundle — only into native. This mirrors Bloom's existing platform-split convention
55
+ * (`color-scope/index.tsx` + `color-scope/index.web.tsx`, `FontLoader.native.tsx`).
56
+ *
57
+ * Keying contract (verified against react-native-css@3.0.7)
58
+ * ---------------------------------------------------------
59
+ * The `rootVariables` family is keyed by the BARE variable name, WITHOUT the leading
60
+ * `--`. The compiler strips it uniformly: a `:root { --primary: ... }` declaration is
61
+ * stored via `rule.v.push([property.slice(2), value])` then routed into
62
+ * `shared.rootVariables[name]`, and `@property --x` goes through
63
+ * `name.startsWith("--") ? name.slice(2) : name`. The lookup side matches: a `var(--x)`
64
+ * reference compiles to `[{}, "var", ident.slice(2)]`, so `varResolver` looks up the
65
+ * bare name. `buildScopeVars` returns keys WITH the `--` prefix, so we strip it before
66
+ * writing each entry.
67
+ *
68
+ * Value shape
69
+ * -----------
70
+ * Each entry is a `VariableValue[]` — an array of `[value, mediaCondition?]` tuples.
71
+ * Bloom's preset vars are unconditional, so each is a single-element `[[value]]`, e.g.
72
+ * `rootVariables('primary').set([['205 87% 53%']])`. This is the same shape the compiler
73
+ * emits for unconditional `:root` vars.
74
+ *
75
+ * This is native-only and additive: the `VariableContextProvider` wrapper stays (it is
76
+ * the correct, scoped mechanism for `BloomColorScope` subtree overrides and harmlessly
77
+ * covers direct descendants). The web fork (`native-root-vars.web.ts`) no-ops — web
78
+ * writes the same vars to `document.documentElement` via `applyColorPresetVars`.
79
+ */
80
+ /**
81
+ * Write the preset's CSS vars to react-native-css's global `rootVariables` family
82
+ * so the whole native tree (navigator screens + portals/modals/bottom-sheets)
83
+ * resolves the active palette.
84
+ *
85
+ * Each `.set` notifies its own observers synchronously (react-native-css only
86
+ * batches notifications inside its own `StyleCollection.inject`; outside it,
87
+ * `observableBatch.current` is unset so every `.set` runs observers immediately),
88
+ * so sequential writes correctly trigger a re-render when the preset/mode changes.
89
+ *
90
+ * Defensive guard: if a host ships a react-native-css build that doesn't expose
91
+ * `rootVariables` as a callable (it always does on @3), we bail rather than throw.
92
+ */
93
+ export declare function applyNativeRootVars(colorPreset: AppColorName, mode: 'light' | 'dark'): void;
94
+ //# sourceMappingURL=native-root-vars.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-root-vars.native.d.ts","sourceRoot":"","sources":["../../../../src/theme/native-root-vars.native.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AAEH;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAS3F"}
@@ -25,6 +25,31 @@ import { type AppColorName, type PresetTokens } from './color-presets';
25
25
  * Tolerates a `deg` suffix on the hue and `%` suffixes on saturation/lightness.
26
26
  */
27
27
  export declare function hslTripletToRgb(triplet: string): string;
28
+ /**
29
+ * Transform a single preset var into the value to write to a WEB element
30
+ * (`document.documentElement` or a `BloomColorScope` subtree element).
31
+ *
32
+ * The web apps (Vite + Tailwind v4 + shadcn) compile their `@theme inline`
33
+ * block so the color utilities reference the BASE token directly — e.g.
34
+ * `.bg-background { background-color: var(--background) }`. So on web the base
35
+ * `--x` tokens MUST resolve to a COMPLETE CSS color; a bare HSL triple
36
+ * (`185 50% 5%`) is invalid as a `background-color` value and renders
37
+ * transparent (the production incident this fixes). We therefore wrap raw
38
+ * triples in `hsl(...)`, preserving the exact preset color math (and any `/ A`
39
+ * alpha tail, valid in modern `hsl(H S% L% / A)` syntax) with zero rounding
40
+ * drift.
41
+ *
42
+ * Values that are already full colors pass through unchanged:
43
+ * - `--color-*` resolved vars (already `rgb(...)` from `getPresetVars`),
44
+ * - any value not shaped like a raw HSL triple (`--radius: 0.5rem`,
45
+ * pre-resolved `rgb(...)`/`hsl(...)`, etc.).
46
+ *
47
+ * NATIVE never calls this — `getPresetVars` returns raw triples verbatim and
48
+ * `native-root-vars.native.ts` writes them through bloom's `hsl(var(--x))`
49
+ * native `global.css` indirection. Pure function — no side effects — so it is
50
+ * unit-testable in isolation.
51
+ */
52
+ export declare function toWebColorValue(key: string, value: string): string;
28
53
  export interface PresetVarsOptions {
29
54
  /**
30
55
  * Also emit Tailwind v4 resolved `--color-*` vars (as sRGB `rgb(...)` strings)
@@ -56,6 +81,11 @@ export declare function getPresetVars(colorName: AppColorName, mode: 'light' | '
56
81
  * on native. `BloomThemeProvider` already writes the base preset vars on web;
57
82
  * call this only when an app needs the extended (card/chart/sidebar) tokens on
58
83
  * the document root.
84
+ *
85
+ * The base raw-HSL-triple tokens are wrapped to full `hsl(...)` colors via
86
+ * `toWebColorValue` so `var(--x)` (the form Tailwind v4 `@theme inline`
87
+ * compiles to) resolves directly on web; `--color-*` rgb vars pass through. See
88
+ * `toWebColorValue` for the web var contract.
59
89
  */
60
90
  export declare function applyPresetVarsToDocument(colorName: AppColorName, mode: 'light' | 'dark', options?: PresetVarsOptions): void;
61
91
  //# sourceMappingURL=preset-vars.d.ts.map