@oxyhq/bloom 0.7.5 → 0.7.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.
@@ -4,124 +4,39 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.applyNativeRootVars = applyNativeRootVars;
7
- var _nativeInternal = require("react-native-css/native-internal");
8
- var _styleBuilder = require("./color-scope/style-builder.js");
9
- /// <reference path="../react-native-css.d.ts" />
10
- // The triple-slash reference above pins Bloom's ambient declaration for
11
- // `react-native-css/native-internal` (`src/react-native-css.d.ts`) into the
12
- // compilation graph of EVERY program that compiles THIS file — including
13
- // downstream consumers that resolve Bloom's `"react-native"` source export
14
- // condition (`./src/theme/index.ts` → `BloomThemeProvider` → this file). Without
15
- // it the ambient decl is only auto-loaded inside Bloom's own tsconfig
16
- // (`include: ["src"]`); a consumer's tsconfig never includes
17
- // `node_modules/@oxyhq/bloom/src/**`, and TypeScript does NOT auto-pick-up
18
- // ambient `.d.ts` files that live under `node_modules`, so
19
- // `react-native-css/native-internal` is unresolved (TS2307) unless the reference
20
- // travels with the source. react-native-css is intentionally NOT a Bloom
21
- // dependency — it arrives transitively via a host's NativeWind 5 install, or is
22
- // absent entirely for NativeWind 4 consumers — so the ambient declaration is the
23
- // only thing that can type this import, and it MUST reach the consumer. The
24
- // directive ships raw in `src/` (Bloom publishes `files: ["src", "lib"]`).
25
-
26
- /**
27
- * Publish the active color preset's CSS custom properties into react-native-css's
28
- * GLOBAL root-variable family so they reach the ENTIRE native app tree — including
29
- * content rendered outside the React subtree of `BloomThemeProvider`: expo-router
30
- * navigator screens, `Portal`s, `Dialog`/`BottomSheet` overlays, and any other host
31
- * that paints through a separate React root.
32
- *
33
- * Why a global write is required (native only)
34
- * --------------------------------------------
35
- * react-native-css resolves a `var(--x)` reference (its `varResolver`) in this order:
36
- * 1. `name in inheritedVariables` — the React-context-inherited vars. This is what
37
- * `VariableContextProvider` populates, but it is React-context-scoped, so it only
38
- * reaches *direct descendants* of the provider in the React tree.
39
- * 2. `inlineVariables[name]` — same-component inline vars.
40
- * 3. `variables[name]` — resolved inherited vars.
41
- * 4. `universalVariables(name)` — a GLOBAL observable family.
42
- * 5. `rootVariables(name)` — a GLOBAL observable family.
43
- * 6. the declared fallback.
44
- *
45
- * `BloomThemeProvider`'s `VariableContextProvider` only feeds path #1, so the navigator
46
- * host and every portal/modal — which render outside that subtree — never see the
47
- * preset vars and fall through to `rootVariables`/`universalVariables`. By default those
48
- * families hold only react-native-css's own `__rn-css-rem`/`__rn-css-color` entries
49
- * (Bloom's `global.css` defines the `hsl(var(--primary))` indirection but not the HSL
50
- * triples themselves — those are injected at runtime), so the whole tree below the
51
- * navigator renders monochrome. Writing the vars into `rootVariables` here is the
52
- * exact same mechanism react-native-css uses for compiled `:root {}` / `@theme` vars
53
- * (`StyleCollection.inject` does `rootVariables(name).set(valueArray)`), so portaled
54
- * content resolves the palette identically regardless of React-tree position.
55
- *
56
- * The raw tokens are written as HSL triples (`primary: '205 87% 53%'`) and the
57
- * resolved Tailwind v4 `--color-*` vars as sRGB `rgb(...)` (`color-primary:
58
- * 'rgb(31 153 239)'`) — the latter so `color-mix`-based alpha utilities resolve
59
- * on native (see `getPresetVars` / `hslTripletToRgb`).
60
- *
61
- * Why a STATIC `import`, not a runtime `require` (critical)
62
- * ---------------------------------------------------------
63
- * react-native-css@3.0.7 ships both a `dist/commonjs` and a `dist/module` build, and
64
- * Metro bundles BOTH. In `native-internal/root.js` the variable families are plain
65
- * module-local consts — NOT `globalThis`-guarded the way `StyleCollection` is — so the
66
- * commonjs `root.js` and the module `root.js` each instantiate their OWN separate
67
- * `rootVariables` family. The react-native-css renderer (`react-native-css/src/components/View.tsx`
68
- * → `varResolver`) imports its `root.js` via ESM `import`, i.e. the MODULE build. A
69
- * runtime `require('react-native-css/native-internal')` resolves the package's `require`
70
- * export condition → the COMMONJS build → a DIFFERENT family the renderer never
71
- * subscribes to, so the writes are a silent no-op on device. A static top-level
72
- * `import` resolves the `import` condition → the MODULE build → the renderer's instance.
73
- *
74
- * This plain file is the NATIVE/default variant (Metro selects it on iOS/Android,
75
- * which have no `.native` override here); the web variant lives in the sibling
76
- * `native-root-vars.web.ts` no-op, which web bundlers pick over this one. So the
77
- * static `react-native-css/native-internal` import below is never pulled into a web
78
- * bundle — only into native. This mirrors Bloom's existing platform-split convention
79
- * (`color-scope/index.tsx` + `color-scope/index.web.tsx`, `FontLoader.native.tsx`).
80
- *
81
- * Keying contract (verified against react-native-css@3.0.7)
82
- * ---------------------------------------------------------
83
- * The `rootVariables` family is keyed by the BARE variable name, WITHOUT the leading
84
- * `--`. The compiler strips it uniformly: a `:root { --primary: ... }` declaration is
85
- * stored via `rule.v.push([property.slice(2), value])` then routed into
86
- * `shared.rootVariables[name]`, and `@property --x` goes through
87
- * `name.startsWith("--") ? name.slice(2) : name`. The lookup side matches: a `var(--x)`
88
- * reference compiles to `[{}, "var", ident.slice(2)]`, so `varResolver` looks up the
89
- * bare name. `buildScopeVars` returns keys WITH the `--` prefix, so we strip it before
90
- * writing each entry.
91
- *
92
- * Value shape
93
- * -----------
94
- * Each entry is a `VariableValue[]` — an array of `[value, mediaCondition?]` tuples.
95
- * Bloom's preset vars are unconditional, so each is a single-element `[[value]]`, e.g.
96
- * `rootVariables('primary').set([['205 87% 53%']])`. This is the same shape the compiler
97
- * emits for unconditional `:root` vars.
98
- *
99
- * This is native-only and additive: the `VariableContextProvider` wrapper stays (it is
100
- * the correct, scoped mechanism for `BloomColorScope` subtree overrides and harmlessly
101
- * covers direct descendants). The web fork (`native-root-vars.web.ts`) no-ops — web
102
- * writes the same vars to `document.documentElement` via `applyColorPresetVars`.
103
- */
104
-
105
7
  /**
106
- * Write the preset's CSS vars to react-native-css's global `rootVariables` family
107
- * so the whole native tree (navigator screens + portals/modals/bottom-sheets)
108
- * resolves the active palette.
109
- *
110
- * Each `.set` notifies its own observers synchronously (react-native-css only
111
- * batches notifications inside its own `StyleCollection.inject`; outside it,
112
- * `observableBatch.current` is unset so every `.set` runs observers immediately),
113
- * so sequential writes correctly trigger a re-render when the preset/mode changes.
114
- *
115
- * Defensive guard: if a host ships a react-native-css build that doesn't expose
116
- * `rootVariables` as a callable (it always does on @3), we bail rather than throw.
8
+ * Platform-neutral DEFAULT variant of `applyNativeRootVars` a no-op.
9
+ *
10
+ * This is the file resolved by every bundler / type-checker that does NOT do
11
+ * React Native's platform-extension resolution:
12
+ * - a consumer's `tsc` (resolving Bloom's `"react-native"` -> `./src/...` source
13
+ * export condition: `theme/index.ts` -> `BloomThemeProvider` -> this import);
14
+ * - non-Metro web bundlers (Vite/Rolldown, webpack) resolving the package
15
+ * `exports` `import`/`require` conditions to `lib/.../native-root-vars.js`.
16
+ *
17
+ * It deliberately does NOT import `react-native-css/native-internal`. That subpath
18
+ * is native-only: it has no web build, and react-native-css is not even a Bloom
19
+ * dependency. Statically importing it from a file a web bundler resolves breaks
20
+ * module resolution outright (the original report: `Rolldown failed to resolve
21
+ * import "react-native-css/native-internal" from .../native-root-vars.js`).
22
+ * Importing it from a file a consumer's `tsc` resolves breaks type-check (TS2307).
23
+ *
24
+ * Confining the real implementation (and that import) to the `.native` sibling —
25
+ * `native-root-vars.native.ts`, which ONLY Metro selects — keeps both web bundling
26
+ * AND downstream `tsc` green, while native still publishes the preset vars into
27
+ * react-native-css's GLOBAL `rootVariables` family so the whole native tree
28
+ * (navigator screens + portals/modals) resolves the palette.
29
+ *
30
+ * The other variants:
31
+ * - `native-root-vars.native.ts` — iOS/Android (Metro), the real implementation;
32
+ * - `native-root-vars.web.ts` — web, also a no-op (web writes the same vars to
33
+ * `document.documentElement` via `applyColorPresetVars` instead).
34
+ *
35
+ * The signature is intentionally identical to those variants so the import site in
36
+ * `BloomThemeProvider` is platform-agnostic.
117
37
  */
118
- function applyNativeRootVars(colorPreset, mode) {
119
- if (typeof _nativeInternal.rootVariables !== 'function') return;
120
- const vars = (0, _styleBuilder.buildScopeVars)(colorPreset, mode);
121
- for (const [key, value] of Object.entries(vars)) {
122
- // The family is keyed by the bare name; `buildScopeVars` keys include `--`.
123
- const name = key.startsWith('--') ? key.slice(2) : key;
124
- (0, _nativeInternal.rootVariables)(name).set([[value]]);
125
- }
38
+ function applyNativeRootVars(_colorPreset, _mode) {
39
+ // Intentionally empty the native variant (`native-root-vars.native.ts`) does
40
+ // the real work; this neutral default and the web fork are inert.
126
41
  }
127
42
  //# sourceMappingURL=native-root-vars.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_nativeInternal","require","_styleBuilder","applyNativeRootVars","colorPreset","mode","rootVariables","vars","buildScopeVars","key","value","Object","entries","name","startsWith","slice","set"],"sourceRoot":"../../../src","sources":["theme/native-root-vars.ts"],"mappings":";;;;;;AAgBA,IAAAA,eAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AAlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;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;AACO,SAASE,mBAAmBA,CAACC,WAAyB,EAAEC,IAAsB,EAAQ;EAC3F,IAAI,OAAOC,6BAAa,KAAK,UAAU,EAAE;EAEzC,MAAMC,IAAI,GAAG,IAAAC,4BAAc,EAACJ,WAAW,EAAEC,IAAI,CAAC;EAC9C,KAAK,MAAM,CAACI,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACL,IAAI,CAAC,EAAE;IAC/C;IACA,MAAMM,IAAI,GAAGJ,GAAG,CAACK,UAAU,CAAC,IAAI,CAAC,GAAGL,GAAG,CAACM,KAAK,CAAC,CAAC,CAAC,GAAGN,GAAG;IACtD,IAAAH,6BAAa,EAACO,IAAI,CAAC,CAACG,GAAG,CAAC,CAAC,CAACN,KAAK,CAAC,CAAC,CAAC;EACpC;AACF","ignoreList":[]}
1
+ {"version":3,"names":["applyNativeRootVars","_colorPreset","_mode"],"sourceRoot":"../../../src","sources":["theme/native-root-vars.ts"],"mappings":";;;;;;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;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,mBAAmBA,CAACC,YAA0B,EAAEC,KAAuB,EAAQ;EAC7F;EACA;AAAA","ignoreList":[]}
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.applyNativeRootVars = applyNativeRootVars;
7
+ var _nativeInternal = require("react-native-css/native-internal");
8
+ var _styleBuilder = require("./color-scope/style-builder.js");
9
+ /// <reference path="../react-native-css.d.ts" />
10
+ // The triple-slash reference above pins Bloom's ambient declaration for
11
+ // `react-native-css/native-internal` (`src/react-native-css.d.ts`) into the
12
+ // compilation graph of EVERY program that compiles THIS file — including
13
+ // downstream consumers that resolve Bloom's `"react-native"` source export
14
+ // condition (`./src/theme/index.ts` → `BloomThemeProvider` → this file). Without
15
+ // it the ambient decl is only auto-loaded inside Bloom's own tsconfig
16
+ // (`include: ["src"]`); a consumer's tsconfig never includes
17
+ // `node_modules/@oxyhq/bloom/src/**`, and TypeScript does NOT auto-pick-up
18
+ // ambient `.d.ts` files that live under `node_modules`, so
19
+ // `react-native-css/native-internal` is unresolved (TS2307) unless the reference
20
+ // travels with the source. react-native-css is intentionally NOT a Bloom
21
+ // dependency — it arrives transitively via a host's NativeWind 5 install, or is
22
+ // absent entirely for NativeWind 4 consumers — so the ambient declaration is the
23
+ // only thing that can type this import, and it MUST reach the consumer. The
24
+ // directive ships raw in `src/` (Bloom publishes `files: ["src", "lib"]`).
25
+
26
+ /**
27
+ * Publish the active color preset's CSS custom properties into react-native-css's
28
+ * GLOBAL root-variable family so they reach the ENTIRE native app tree — including
29
+ * content rendered outside the React subtree of `BloomThemeProvider`: expo-router
30
+ * navigator screens, `Portal`s, `Dialog`/`BottomSheet` overlays, and any other host
31
+ * that paints through a separate React root.
32
+ *
33
+ * Why a global write is required (native only)
34
+ * --------------------------------------------
35
+ * react-native-css resolves a `var(--x)` reference (its `varResolver`) in this order:
36
+ * 1. `name in inheritedVariables` — the React-context-inherited vars. This is what
37
+ * `VariableContextProvider` populates, but it is React-context-scoped, so it only
38
+ * reaches *direct descendants* of the provider in the React tree.
39
+ * 2. `inlineVariables[name]` — same-component inline vars.
40
+ * 3. `variables[name]` — resolved inherited vars.
41
+ * 4. `universalVariables(name)` — a GLOBAL observable family.
42
+ * 5. `rootVariables(name)` — a GLOBAL observable family.
43
+ * 6. the declared fallback.
44
+ *
45
+ * `BloomThemeProvider`'s `VariableContextProvider` only feeds path #1, so the navigator
46
+ * host and every portal/modal — which render outside that subtree — never see the
47
+ * preset vars and fall through to `rootVariables`/`universalVariables`. By default those
48
+ * families hold only react-native-css's own `__rn-css-rem`/`__rn-css-color` entries
49
+ * (Bloom's `global.css` defines the `hsl(var(--primary))` indirection but not the HSL
50
+ * triples themselves — those are injected at runtime), so the whole tree below the
51
+ * navigator renders monochrome. Writing the vars into `rootVariables` here is the
52
+ * exact same mechanism react-native-css uses for compiled `:root {}` / `@theme` vars
53
+ * (`StyleCollection.inject` does `rootVariables(name).set(valueArray)`), so portaled
54
+ * content resolves the palette identically regardless of React-tree position.
55
+ *
56
+ * The raw tokens are written as HSL triples (`primary: '205 87% 53%'`) and the
57
+ * resolved Tailwind v4 `--color-*` vars as sRGB `rgb(...)` (`color-primary:
58
+ * 'rgb(31 153 239)'`) — the latter so `color-mix`-based alpha utilities resolve
59
+ * on native (see `getPresetVars` / `hslTripletToRgb`).
60
+ *
61
+ * Why a STATIC `import`, not a runtime `require` (critical)
62
+ * ---------------------------------------------------------
63
+ * react-native-css@3.0.7 ships both a `dist/commonjs` and a `dist/module` build, and
64
+ * Metro bundles BOTH. In `native-internal/root.js` the variable families are plain
65
+ * module-local consts — NOT `globalThis`-guarded the way `StyleCollection` is — so the
66
+ * commonjs `root.js` and the module `root.js` each instantiate their OWN separate
67
+ * `rootVariables` family. The react-native-css renderer (`react-native-css/src/components/View.tsx`
68
+ * → `varResolver`) imports its `root.js` via ESM `import`, i.e. the MODULE build. A
69
+ * runtime `require('react-native-css/native-internal')` resolves the package's `require`
70
+ * export condition → the COMMONJS build → a DIFFERENT family the renderer never
71
+ * subscribes to, so the writes are a silent no-op on device. A static top-level
72
+ * `import` resolves the `import` condition → the MODULE build → the renderer's instance.
73
+ *
74
+ * This plain file is the NATIVE/default variant (Metro selects it on iOS/Android,
75
+ * which have no `.native` override here); the web variant lives in the sibling
76
+ * `native-root-vars.web.ts` no-op, which web bundlers pick over this one. So the
77
+ * static `react-native-css/native-internal` import below is never pulled into a web
78
+ * bundle — only into native. This mirrors Bloom's existing platform-split convention
79
+ * (`color-scope/index.tsx` + `color-scope/index.web.tsx`, `FontLoader.native.tsx`).
80
+ *
81
+ * Keying contract (verified against react-native-css@3.0.7)
82
+ * ---------------------------------------------------------
83
+ * The `rootVariables` family is keyed by the BARE variable name, WITHOUT the leading
84
+ * `--`. The compiler strips it uniformly: a `:root { --primary: ... }` declaration is
85
+ * stored via `rule.v.push([property.slice(2), value])` then routed into
86
+ * `shared.rootVariables[name]`, and `@property --x` goes through
87
+ * `name.startsWith("--") ? name.slice(2) : name`. The lookup side matches: a `var(--x)`
88
+ * reference compiles to `[{}, "var", ident.slice(2)]`, so `varResolver` looks up the
89
+ * bare name. `buildScopeVars` returns keys WITH the `--` prefix, so we strip it before
90
+ * writing each entry.
91
+ *
92
+ * Value shape
93
+ * -----------
94
+ * Each entry is a `VariableValue[]` — an array of `[value, mediaCondition?]` tuples.
95
+ * Bloom's preset vars are unconditional, so each is a single-element `[[value]]`, e.g.
96
+ * `rootVariables('primary').set([['205 87% 53%']])`. This is the same shape the compiler
97
+ * emits for unconditional `:root` vars.
98
+ *
99
+ * This is native-only and additive: the `VariableContextProvider` wrapper stays (it is
100
+ * the correct, scoped mechanism for `BloomColorScope` subtree overrides and harmlessly
101
+ * covers direct descendants). The web fork (`native-root-vars.web.ts`) no-ops — web
102
+ * writes the same vars to `document.documentElement` via `applyColorPresetVars`.
103
+ */
104
+
105
+ /**
106
+ * Write the preset's CSS vars to react-native-css's global `rootVariables` family
107
+ * so the whole native tree (navigator screens + portals/modals/bottom-sheets)
108
+ * resolves the active palette.
109
+ *
110
+ * Each `.set` notifies its own observers synchronously (react-native-css only
111
+ * batches notifications inside its own `StyleCollection.inject`; outside it,
112
+ * `observableBatch.current` is unset so every `.set` runs observers immediately),
113
+ * so sequential writes correctly trigger a re-render when the preset/mode changes.
114
+ *
115
+ * Defensive guard: if a host ships a react-native-css build that doesn't expose
116
+ * `rootVariables` as a callable (it always does on @3), we bail rather than throw.
117
+ */
118
+ function applyNativeRootVars(colorPreset, mode) {
119
+ if (typeof _nativeInternal.rootVariables !== 'function') return;
120
+ const vars = (0, _styleBuilder.buildScopeVars)(colorPreset, mode);
121
+ for (const [key, value] of Object.entries(vars)) {
122
+ // The family is keyed by the bare name; `buildScopeVars` keys include `--`.
123
+ const name = key.startsWith('--') ? key.slice(2) : key;
124
+ (0, _nativeInternal.rootVariables)(name).set([[value]]);
125
+ }
126
+ }
127
+ //# sourceMappingURL=native-root-vars.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_nativeInternal","require","_styleBuilder","applyNativeRootVars","colorPreset","mode","rootVariables","vars","buildScopeVars","key","value","Object","entries","name","startsWith","slice","set"],"sourceRoot":"../../../src","sources":["theme/native-root-vars.native.ts"],"mappings":";;;;;;AAgBA,IAAAA,eAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AAlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;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;AACO,SAASE,mBAAmBA,CAACC,WAAyB,EAAEC,IAAsB,EAAQ;EAC3F,IAAI,OAAOC,6BAAa,KAAK,UAAU,EAAE;EAEzC,MAAMC,IAAI,GAAG,IAAAC,4BAAc,EAACJ,WAAW,EAAEC,IAAI,CAAC;EAC9C,KAAK,MAAM,CAACI,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACL,IAAI,CAAC,EAAE;IAC/C;IACA,MAAMM,IAAI,GAAGJ,GAAG,CAACK,UAAU,CAAC,IAAI,CAAC,GAAGL,GAAG,CAACM,KAAK,CAAC,CAAC,CAAC,GAAGN,GAAG;IACtD,IAAAH,6BAAa,EAACO,IAAI,CAAC,CAACG,GAAG,CAAC,CAAC,CAACN,KAAK,CAAC,CAAC,CAAC;EACpC;AACF","ignoreList":[]}
@@ -1,122 +1,38 @@
1
1
  "use strict";
2
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
3
  /**
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.
4
+ * Platform-neutral DEFAULT variant of `applyNativeRootVars` a no-op.
5
+ *
6
+ * This is the file resolved by every bundler / type-checker that does NOT do
7
+ * React Native's platform-extension resolution:
8
+ * - a consumer's `tsc` (resolving Bloom's `"react-native"` -> `./src/...` source
9
+ * export condition: `theme/index.ts` -> `BloomThemeProvider` -> this import);
10
+ * - non-Metro web bundlers (Vite/Rolldown, webpack) resolving the package
11
+ * `exports` `import`/`require` conditions to `lib/.../native-root-vars.js`.
12
+ *
13
+ * It deliberately does NOT import `react-native-css/native-internal`. That subpath
14
+ * is native-only: it has no web build, and react-native-css is not even a Bloom
15
+ * dependency. Statically importing it from a file a web bundler resolves breaks
16
+ * module resolution outright (the original report: `Rolldown failed to resolve
17
+ * import "react-native-css/native-internal" from .../native-root-vars.js`).
18
+ * Importing it from a file a consumer's `tsc` resolves breaks type-check (TS2307).
19
+ *
20
+ * Confining the real implementation (and that import) to the `.native` sibling —
21
+ * `native-root-vars.native.ts`, which ONLY Metro selects — keeps both web bundling
22
+ * AND downstream `tsc` green, while native still publishes the preset vars into
23
+ * react-native-css's GLOBAL `rootVariables` family so the whole native tree
24
+ * (navigator screens + portals/modals) resolves the palette.
25
+ *
26
+ * The other variants:
27
+ * - `native-root-vars.native.ts`iOS/Android (Metro), the real implementation;
28
+ * - `native-root-vars.web.ts` web, also a no-op (web writes the same vars to
29
+ * `document.documentElement` via `applyColorPresetVars` instead).
30
+ *
31
+ * The signature is intentionally identical to those variants so the import site in
32
+ * `BloomThemeProvider` is platform-agnostic.
112
33
  */
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
- }
34
+ export function applyNativeRootVars(_colorPreset, _mode) {
35
+ // Intentionally empty the native variant (`native-root-vars.native.ts`) does
36
+ // the real work; this neutral default and the web fork are inert.
121
37
  }
122
38
  //# sourceMappingURL=native-root-vars.js.map
@@ -1 +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.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":[]}
1
+ {"version":3,"names":["applyNativeRootVars","_colorPreset","_mode"],"sourceRoot":"../../../src","sources":["theme/native-root-vars.ts"],"mappings":";;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;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,mBAAmBA,CAACC,YAA0B,EAAEC,KAAuB,EAAQ;EAC7F;EACA;AAAA","ignoreList":[]}
@@ -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":[]}