@oxyhq/bloom 0.43.0 → 0.44.0
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.
- package/lib/commonjs/theme/BloomThemeProvider.js +31 -14
- package/lib/commonjs/theme/BloomThemeProvider.js.map +1 -1
- package/lib/commonjs/theme/apply-dark-class.js +12 -3
- package/lib/commonjs/theme/apply-dark-class.js.map +1 -1
- package/lib/commonjs/theme/native-root-vars.js +5 -0
- package/lib/commonjs/theme/native-root-vars.js.map +1 -1
- package/lib/commonjs/theme/native-root-vars.native.js +13 -3
- package/lib/commonjs/theme/native-root-vars.native.js.map +1 -1
- package/lib/commonjs/theme/native-root-vars.web.js +5 -0
- package/lib/commonjs/theme/native-root-vars.web.js.map +1 -1
- package/lib/module/theme/BloomThemeProvider.js +33 -16
- package/lib/module/theme/BloomThemeProvider.js.map +1 -1
- package/lib/module/theme/apply-dark-class.js +11 -3
- package/lib/module/theme/apply-dark-class.js.map +1 -1
- package/lib/module/theme/native-root-vars.js +4 -0
- package/lib/module/theme/native-root-vars.js.map +1 -1
- package/lib/module/theme/native-root-vars.native.js +12 -3
- package/lib/module/theme/native-root-vars.native.js.map +1 -1
- package/lib/module/theme/native-root-vars.web.js +4 -0
- package/lib/module/theme/native-root-vars.web.js.map +1 -1
- package/lib/typescript/commonjs/theme/BloomThemeProvider.d.ts +11 -1
- package/lib/typescript/commonjs/theme/BloomThemeProvider.d.ts.map +1 -1
- package/lib/typescript/commonjs/theme/apply-dark-class.d.ts +7 -0
- package/lib/typescript/commonjs/theme/apply-dark-class.d.ts.map +1 -1
- package/lib/typescript/commonjs/theme/native-root-vars.d.ts +2 -0
- package/lib/typescript/commonjs/theme/native-root-vars.d.ts.map +1 -1
- package/lib/typescript/commonjs/theme/native-root-vars.native.d.ts +8 -0
- package/lib/typescript/commonjs/theme/native-root-vars.native.d.ts.map +1 -1
- package/lib/typescript/commonjs/theme/native-root-vars.web.d.ts +2 -0
- package/lib/typescript/commonjs/theme/native-root-vars.web.d.ts.map +1 -1
- package/lib/typescript/module/theme/BloomThemeProvider.d.ts +11 -1
- package/lib/typescript/module/theme/BloomThemeProvider.d.ts.map +1 -1
- package/lib/typescript/module/theme/apply-dark-class.d.ts +7 -0
- package/lib/typescript/module/theme/apply-dark-class.d.ts.map +1 -1
- package/lib/typescript/module/theme/native-root-vars.d.ts +2 -0
- package/lib/typescript/module/theme/native-root-vars.d.ts.map +1 -1
- package/lib/typescript/module/theme/native-root-vars.native.d.ts +8 -0
- package/lib/typescript/module/theme/native-root-vars.native.d.ts.map +1 -1
- package/lib/typescript/module/theme/native-root-vars.web.d.ts +2 -0
- package/lib/typescript/module/theme/native-root-vars.web.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/theme/BloomThemeProvider.tsx +53 -17
- package/src/theme/apply-dark-class.ts +15 -8
- package/src/theme/native-root-vars.native.ts +17 -8
- package/src/theme/native-root-vars.ts +5 -0
- package/src/theme/native-root-vars.web.ts +5 -0
|
@@ -12,6 +12,8 @@ var _useControllableState = require("../hooks/useControllableState.js");
|
|
|
12
12
|
var _FontLoader = require("../fonts/FontLoader");
|
|
13
13
|
var _applyDarkClass = require("./apply-dark-class.js");
|
|
14
14
|
var _buildTheme = require("./build-theme.js");
|
|
15
|
+
var _buildThemeFromSeed = require("./build-theme-from-seed.js");
|
|
16
|
+
var _seedScope = require("./color-scope/seed-scope.js");
|
|
15
17
|
var _styleBuilder = require("./color-scope/style-builder.js");
|
|
16
18
|
var _nativeRootVars = require("./native-root-vars");
|
|
17
19
|
var _persistence = require("./persistence.js");
|
|
@@ -166,6 +168,7 @@ function BloomThemeProvider({
|
|
|
166
168
|
nativeWrapperStyle,
|
|
167
169
|
secondaryColor,
|
|
168
170
|
tertiaryColor,
|
|
171
|
+
seed,
|
|
169
172
|
children
|
|
170
173
|
}) {
|
|
171
174
|
const rnScheme = (0, _reactNative.useColorScheme)();
|
|
@@ -202,38 +205,52 @@ function BloomThemeProvider({
|
|
|
202
205
|
// Apply native color scheme, dark class, and CSS vars whenever the resolved
|
|
203
206
|
// mode or preset changes. `useIsomorphicLayoutEffect` runs before paint on
|
|
204
207
|
// both native and web, eliminating the previous render-time side effect.
|
|
208
|
+
// The single `--x -> value` record + JS theme for the ACTIVE source, computed
|
|
209
|
+
// ONCE and applied identically to web (document), native (rootVariables +
|
|
210
|
+
// VariableContext), and the JS `theme` context. The source is a DYNAMIC seed
|
|
211
|
+
// (whole-app dynamic theming — `secondaryColor`/`tertiaryColor` pin this seed's
|
|
212
|
+
// accents) when `seed` is set, else the named preset. Both go through the same
|
|
213
|
+
// colour engine, so there is one code path — no seed/preset duplication.
|
|
214
|
+
const themeVars = (0, _react.useMemo)(() => seed ? (0, _seedScope.buildSeedScopeVars)({
|
|
215
|
+
seed,
|
|
216
|
+
mode: resolved,
|
|
217
|
+
secondarySeed: secondaryColor,
|
|
218
|
+
tertiarySeed: tertiaryColor
|
|
219
|
+
}) : (0, _styleBuilder.buildScopeVars)(colorPreset, resolved, explicitAccents), [seed, secondaryColor, tertiaryColor, colorPreset, resolved, explicitAccents]);
|
|
220
|
+
const themeColors = (0, _react.useMemo)(() => seed ? (0, _buildThemeFromSeed.buildThemeFromSeed)(seed, resolved, undefined, undefined, {
|
|
221
|
+
secondarySeed: secondaryColor,
|
|
222
|
+
tertiarySeed: tertiaryColor
|
|
223
|
+
}) : (0, _buildTheme.buildTheme)(colorPreset, resolved, isAdaptive, explicitAccents), [seed, secondaryColor, tertiaryColor, colorPreset, resolved, isAdaptive, explicitAccents]);
|
|
205
224
|
(0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(() => {
|
|
206
225
|
(0, _setColorSchemeSafe.setColorSchemeSafe)(effectiveMode);
|
|
207
226
|
(0, _applyDarkClass.applyDarkClass)(resolved);
|
|
208
|
-
(0, _applyDarkClass.
|
|
209
|
-
}, [effectiveMode, resolved,
|
|
227
|
+
(0, _applyDarkClass.applyVarsToDocument)(themeVars);
|
|
228
|
+
}, [effectiveMode, resolved, themeVars]);
|
|
210
229
|
|
|
211
|
-
// Native only: publish the
|
|
230
|
+
// Native only: publish the same vars into react-native-css's GLOBAL root
|
|
212
231
|
// variable family so they reach the ENTIRE app tree — navigator screens and
|
|
213
232
|
// every portal/modal/bottom-sheet that paints outside the provider's React
|
|
214
233
|
// subtree (and therefore never sees the `VariableContextProvider` vars below).
|
|
215
234
|
// Web writes the same vars to `document.documentElement` above, so this no-ops
|
|
216
|
-
// there. Runs before paint via `useIsomorphicLayoutEffect
|
|
217
|
-
// sibling `applyColorPresetVars` side effect.
|
|
235
|
+
// there. Runs before paint via `useIsomorphicLayoutEffect`.
|
|
218
236
|
(0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(() => {
|
|
219
|
-
(0, _nativeRootVars.
|
|
220
|
-
}, [
|
|
237
|
+
(0, _nativeRootVars.applyVarsToRootVariables)(themeVars);
|
|
238
|
+
}, [themeVars]);
|
|
221
239
|
const contextValue = (0, _react.useMemo)(() => ({
|
|
222
|
-
theme:
|
|
240
|
+
theme: themeColors,
|
|
223
241
|
mode,
|
|
224
242
|
colorPreset,
|
|
225
243
|
setMode,
|
|
226
244
|
setColorPreset,
|
|
227
245
|
resetTheme
|
|
228
|
-
}), [
|
|
246
|
+
}), [themeColors, mode, colorPreset, setMode, setColorPreset, resetTheme]);
|
|
229
247
|
const shouldAwait = awaitHydration ?? Boolean(persistKey && storage);
|
|
230
248
|
const isGated = shouldAwait && !hydrated;
|
|
231
249
|
|
|
232
|
-
//
|
|
233
|
-
//
|
|
234
|
-
//
|
|
235
|
-
|
|
236
|
-
const nativeVars = (0, _react.useMemo)(() => _reactNative.Platform.OS === 'web' ? null : (0, _styleBuilder.buildScopeVars)(colorPreset, resolved, explicitAccents), [colorPreset, resolved, explicitAccents]);
|
|
250
|
+
// On native, the same record is handed to `VariableContextProvider` so
|
|
251
|
+
// descendants resolve `var(--primary)` etc. through react-native-css's real
|
|
252
|
+
// VariableContext. Web writes them to `document.documentElement` above.
|
|
253
|
+
const nativeVars = (0, _react.useMemo)(() => _reactNative.Platform.OS === 'web' ? null : themeVars, [themeVars]);
|
|
237
254
|
const VariableProvider = (0, _styleBuilder.getVariableContextProvider)();
|
|
238
255
|
const content = /*#__PURE__*/(0, _jsxRuntime.jsx)(_FontLoader.FontLoader, {
|
|
239
256
|
enabled: fonts,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["require","_react","_interopRequireWildcard","_reactNative","_useControllableState","_FontLoader","_applyDarkClass","_buildTheme","_styleBuilder","_nativeRootVars","_persistence","_setColorSchemeSafe","_useIsomorphicLayoutEffect","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DEFAULT_PRESET","DEFAULT_MODE","BloomThemeContext","exports","globalThis","__oxyhq_bloom_theme_context__","createContext","useThemeState","controlledMode","controlledPreset","defaultMode","defaultPreset","persistKey","storage","onModeChange","onColorPresetChange","syncResult","useState","readPersistedThemeSync","syncState","kind","state","initialMode","mode","initialPreset","colorPreset","hydrated","setHydrated","setModeInternal","useControllableState","value","defaultValue","setPresetInternal","modeRef","useRef","current","presetRef","useEffect","cancelled","readPersistedTheme","then","undefined","setMode","useCallback","next","writePersistedTheme","setColorPreset","resetTheme","removePersistedTheme","BloomThemeProvider","defaultColorPreset","awaitHydration","onHydrating","fonts","onFontsLoading","nativeWrapperStyle","secondaryColor","tertiaryColor","children","rnScheme","useRNColorScheme","explicitAccents","useMemo","secondaryHex","tertiaryHex","isAdaptive","effectiveMode","resolved","useIsomorphicLayoutEffect","setColorSchemeSafe","applyDarkClass","
|
|
1
|
+
{"version":3,"names":["require","_react","_interopRequireWildcard","_reactNative","_useControllableState","_FontLoader","_applyDarkClass","_buildTheme","_buildThemeFromSeed","_seedScope","_styleBuilder","_nativeRootVars","_persistence","_setColorSchemeSafe","_useIsomorphicLayoutEffect","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DEFAULT_PRESET","DEFAULT_MODE","BloomThemeContext","exports","globalThis","__oxyhq_bloom_theme_context__","createContext","useThemeState","controlledMode","controlledPreset","defaultMode","defaultPreset","persistKey","storage","onModeChange","onColorPresetChange","syncResult","useState","readPersistedThemeSync","syncState","kind","state","initialMode","mode","initialPreset","colorPreset","hydrated","setHydrated","setModeInternal","useControllableState","value","defaultValue","setPresetInternal","modeRef","useRef","current","presetRef","useEffect","cancelled","readPersistedTheme","then","undefined","setMode","useCallback","next","writePersistedTheme","setColorPreset","resetTheme","removePersistedTheme","BloomThemeProvider","defaultColorPreset","awaitHydration","onHydrating","fonts","onFontsLoading","nativeWrapperStyle","secondaryColor","tertiaryColor","seed","children","rnScheme","useRNColorScheme","explicitAccents","useMemo","secondaryHex","tertiaryHex","isAdaptive","effectiveMode","resolved","themeVars","buildSeedScopeVars","secondarySeed","tertiarySeed","buildScopeVars","themeColors","buildThemeFromSeed","buildTheme","useIsomorphicLayoutEffect","setColorSchemeSafe","applyDarkClass","applyVarsToDocument","applyVarsToRootVariables","contextValue","theme","shouldAwait","Boolean","isGated","nativeVars","Platform","OS","VariableProvider","getVariableContextProvider","content","jsx","FontLoader","enabled","fallback","Provider","nativeTree","View","style","flex"],"sourceRoot":"../../../src","sources":["theme/BloomThemeProvider.tsx"],"mappings":";;;;;;;AAIAA,OAAA;AAEA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AASA,IAAAG,YAAA,GAAAH,OAAA;AAQA,IAAAI,qBAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AAEA,IAAAM,eAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AACA,IAAAQ,mBAAA,GAAAR,OAAA;AACA,IAAAS,UAAA,GAAAT,OAAA;AAEA,IAAAU,aAAA,GAAAV,OAAA;AACA,IAAAW,eAAA,GAAAX,OAAA;AACA,I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AACC,EAAE,KAAK,KAAK,GAAG,IAAI,GAAGpB,SAAU,EAChD,CAACA,SAAS,CACZ,CAAC;EACD,MAAMqB,gBAAgB,GAAG,IAAAC,wCAA0B,EAAC,CAAC;EAErD,MAAMC,OAAO,gBACX,IAAAhH,WAAA,CAAAiH,GAAA,EAAC3H,WAAA,CAAA4H,UAAU;IAACC,OAAO,EAAE1C,KAAM;IAAC2C,QAAQ,EAAE1C,cAAe;IAAAK,QAAA,EAClD2B,OAAO,GAAGlC,WAAW,IAAI,IAAI,GAAGO;EAAQ,CAC/B,CACb;EAED,IAAI6B,qBAAQ,CAACC,EAAE,KAAK,KAAK,EAAE;IACzB,oBAAO,IAAA7G,WAAA,CAAAiH,GAAA,EAAC3F,iBAAiB,CAAC+F,QAAQ;MAACnE,KAAK,EAAEoD,YAAa;MAAAvB,QAAA,EAAEiC;IAAO,CAA6B,CAAC;EAChG;;EAEA;EACA;EACA;EACA,MAAMM,UAAU,gBAAG,IAAAtH,WAAA,CAAAiH,GAAA,EAAC7H,YAAA,CAAAmI,IAAI;IAACC,KAAK,EAAE,CAAC;MAAEC,IAAI,EAAE;IAAE,CAAC,EAAE9C,kBAAkB,CAAE;IAAAI,QAAA,EAAEiC;EAAO,CAAO,CAAC;EAEnF,oBACE,IAAAhH,WAAA,CAAAiH,GAAA,EAAC3F,iBAAiB,CAAC+F,QAAQ;IAACnE,KAAK,EAAEoD,YAAa;IAAAvB,QAAA,EAC7C+B,gBAAgB,IAAIH,UAAU,gBAC7B,IAAA3G,WAAA,CAAAiH,GAAA,EAACH,gBAAgB;MAAC5D,KAAK,EAAEyD,UAAW;MAAA5B,QAAA,EAAEuC;IAAU,CAAmB,CAAC,GAEpEA;EACD,CACyB,CAAC;AAEjC","ignoreList":[]}
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.applyColorPresetVars = applyColorPresetVars;
|
|
7
7
|
exports.applyDarkClass = applyDarkClass;
|
|
8
|
+
exports.applyVarsToDocument = applyVarsToDocument;
|
|
8
9
|
var _reactNative = require("react-native");
|
|
9
10
|
var _colorPresets = require("./color-presets.js");
|
|
10
11
|
var _tokenRegistry = require("./token-registry.js");
|
|
@@ -31,13 +32,21 @@ function applyDarkClass(resolved) {
|
|
|
31
32
|
* Includes extended tokens (card, chart-*, content-area, sidebar-*) so consumer
|
|
32
33
|
* apps don't need to synthesize them.
|
|
33
34
|
*/
|
|
34
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Write a pre-computed `--x -> value` record to the document root (web only).
|
|
37
|
+
* The single web writer primitive: both the preset path (`applyColorPresetVars`)
|
|
38
|
+
* and `BloomThemeProvider`'s dynamic-seed path feed their already-resolved vars
|
|
39
|
+
* through here, so the "write to document" logic lives in exactly one place.
|
|
40
|
+
*/
|
|
41
|
+
function applyVarsToDocument(vars) {
|
|
35
42
|
if (_reactNative.Platform.OS !== 'web' || typeof document === 'undefined') return;
|
|
36
|
-
if (!_colorPresets.APP_COLOR_PRESETS[preset]) return;
|
|
37
|
-
const vars = (0, _tokenRegistry.getResolvedTokens)(preset, resolved, accents);
|
|
38
43
|
const root = document.documentElement.style;
|
|
39
44
|
for (const [key, value] of Object.entries(vars)) {
|
|
40
45
|
root.setProperty(key, value);
|
|
41
46
|
}
|
|
42
47
|
}
|
|
48
|
+
function applyColorPresetVars(preset, resolved, accents) {
|
|
49
|
+
if (!_colorPresets.APP_COLOR_PRESETS[preset]) return;
|
|
50
|
+
applyVarsToDocument((0, _tokenRegistry.getResolvedTokens)(preset, resolved, accents));
|
|
51
|
+
}
|
|
43
52
|
//# sourceMappingURL=apply-dark-class.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_colorPresets","_tokenRegistry","applyDarkClass","resolved","Platform","OS","document","documentElement","classList","toggle","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_colorPresets","_tokenRegistry","applyDarkClass","resolved","Platform","OS","document","documentElement","classList","toggle","applyVarsToDocument","vars","root","style","key","value","Object","entries","setProperty","applyColorPresetVars","preset","accents","APP_COLOR_PRESETS","getResolvedTokens"],"sourceRoot":"../../../src","sources":["theme/apply-dark-class.ts"],"mappings":";;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAEA,IAAAE,cAAA,GAAAF,OAAA;AAEO,SAASG,cAAcA,CAACC,QAA0B,EAAE;EACzD,IAAIC,qBAAQ,CAACC,EAAE,KAAK,KAAK,IAAI,OAAOC,QAAQ,KAAK,WAAW,EAAE;IAC5DA,QAAQ,CAACC,eAAe,CAACC,SAAS,CAACC,MAAM,CAAC,MAAM,EAAEN,QAAQ,KAAK,MAAM,CAAC;EACxE;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASO,mBAAmBA,CAACC,IAA4B,EAAE;EAChE,IAAIP,qBAAQ,CAACC,EAAE,KAAK,KAAK,IAAI,OAAOC,QAAQ,KAAK,WAAW,EAAE;EAC9D,MAAMM,IAAI,GAAGN,QAAQ,CAACC,eAAe,CAACM,KAAK;EAC3C,KAAK,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACN,IAAI,CAAC,EAAE;IAC/CC,IAAI,CAACM,WAAW,CAACJ,GAAG,EAAEC,KAAK,CAAC;EAC9B;AACF;AAEO,SAASI,oBAAoBA,CAClCC,MAAoB,EACpBjB,QAA0B,EAC1BkB,OAAyB,EACzB;EACA,IAAI,CAACC,+BAAiB,CAACF,MAAM,CAAC,EAAE;EAChCV,mBAAmB,CAAC,IAAAa,gCAAiB,EAACH,MAAM,EAAEjB,QAAQ,EAAEkB,OAAO,CAAC,CAAC;AACnE","ignoreList":[]}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.applyNativeRootVars = applyNativeRootVars;
|
|
7
|
+
exports.applyVarsToRootVariables = applyVarsToRootVariables;
|
|
7
8
|
/**
|
|
8
9
|
* Platform-neutral DEFAULT variant of `applyNativeRootVars` — a no-op.
|
|
9
10
|
*
|
|
@@ -34,6 +35,10 @@ exports.applyNativeRootVars = applyNativeRootVars;
|
|
|
34
35
|
* The signature is intentionally identical to those variants so the import site in
|
|
35
36
|
* `BloomThemeProvider` is platform-agnostic.
|
|
36
37
|
*/
|
|
38
|
+
/** Neutral-default no-op of the native root-vars writer primitive. */
|
|
39
|
+
function applyVarsToRootVariables(_vars) {
|
|
40
|
+
// Intentionally empty — the native variant does the real work.
|
|
41
|
+
}
|
|
37
42
|
function applyNativeRootVars(_colorPreset, _mode, _accents) {
|
|
38
43
|
// Intentionally empty — the native variant (`native-root-vars.native.ts`) does
|
|
39
44
|
// the real work; this neutral default and the web fork are inert.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["applyNativeRootVars","_colorPreset","_mode","_accents"],"sourceRoot":"../../../src","sources":["theme/native-root-vars.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["applyVarsToRootVariables","_vars","applyNativeRootVars","_colorPreset","_mode","_accents"],"sourceRoot":"../../../src","sources":["theme/native-root-vars.ts"],"mappings":";;;;;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;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,wBAAwBA,CAACC,KAA6B,EAAQ;EAC5E;AAAA;AAGK,SAASC,mBAAmBA,CACjCC,YAA0B,EAC1BC,KAAuB,EACvBC,QAA0B,EACpB;EACN;EACA;AAAA","ignoreList":[]}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.applyNativeRootVars = applyNativeRootVars;
|
|
7
|
+
exports.applyVarsToRootVariables = applyVarsToRootVariables;
|
|
7
8
|
var _nativeInternal = require("react-native-css/native-internal");
|
|
8
9
|
var _tokenRegistry = require("./token-registry.js");
|
|
9
10
|
/// <reference path="../react-native-css.d.ts" />
|
|
@@ -125,13 +126,22 @@ var _tokenRegistry = require("./token-registry.js");
|
|
|
125
126
|
* Defensive guard: if a host ships a react-native-css build that doesn't expose
|
|
126
127
|
* `rootVariables` as a callable (it always does on @3), we bail rather than throw.
|
|
127
128
|
*/
|
|
128
|
-
|
|
129
|
+
/**
|
|
130
|
+
* Write a pre-computed `--x -> value` record into react-native-css's global
|
|
131
|
+
* `rootVariables` family. The single native writer primitive: both the preset
|
|
132
|
+
* path (`applyNativeRootVars`) and `BloomThemeProvider`'s dynamic-seed path feed
|
|
133
|
+
* their already-resolved vars through here, so the global-write logic lives in
|
|
134
|
+
* exactly one place.
|
|
135
|
+
*/
|
|
136
|
+
function applyVarsToRootVariables(vars) {
|
|
129
137
|
if (typeof _nativeInternal.rootVariables !== 'function') return;
|
|
130
|
-
const vars = (0, _tokenRegistry.getResolvedTokens)(colorPreset, mode, accents);
|
|
131
138
|
for (const [key, value] of Object.entries(vars)) {
|
|
132
|
-
// The family is keyed by the bare name;
|
|
139
|
+
// The family is keyed by the bare name; the var keys include `--`.
|
|
133
140
|
const name = key.startsWith('--') ? key.slice(2) : key;
|
|
134
141
|
(0, _nativeInternal.rootVariables)(name).set([[value]]);
|
|
135
142
|
}
|
|
136
143
|
}
|
|
144
|
+
function applyNativeRootVars(colorPreset, mode, accents) {
|
|
145
|
+
applyVarsToRootVariables((0, _tokenRegistry.getResolvedTokens)(colorPreset, mode, accents));
|
|
146
|
+
}
|
|
137
147
|
//# sourceMappingURL=native-root-vars.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_nativeInternal","require","_tokenRegistry","
|
|
1
|
+
{"version":3,"names":["_nativeInternal","require","_tokenRegistry","applyVarsToRootVariables","vars","rootVariables","key","value","Object","entries","name","startsWith","slice","set","applyNativeRootVars","colorPreset","mode","accents","getResolvedTokens"],"sourceRoot":"../../../src","sources":["theme/native-root-vars.native.ts"],"mappings":";;;;;;;AAgBA,IAAAA,eAAA,GAAAC,OAAA;AAIA,IAAAC,cAAA,GAAAD,OAAA;AApBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,wBAAwBA,CAACC,IAA4B,EAAQ;EAC3E,IAAI,OAAOC,6BAAa,KAAK,UAAU,EAAE;EACzC,KAAK,MAAM,CAACC,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,IAAAD,6BAAa,EAACK,IAAI,CAAC,CAACG,GAAG,CAAC,CAAC,CAACN,KAAK,CAAC,CAAC,CAAC;EACpC;AACF;AAEO,SAASO,mBAAmBA,CACjCC,WAAyB,EACzBC,IAAsB,EACtBC,OAAyB,EACnB;EACNd,wBAAwB,CAAC,IAAAe,gCAAiB,EAACH,WAAW,EAAEC,IAAI,EAAEC,OAAO,CAAC,CAAC;AACzE","ignoreList":[]}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.applyNativeRootVars = applyNativeRootVars;
|
|
7
|
+
exports.applyVarsToRootVariables = applyVarsToRootVariables;
|
|
7
8
|
/**
|
|
8
9
|
* Web fork of `applyNativeRootVars` — a no-op.
|
|
9
10
|
*
|
|
@@ -21,6 +22,10 @@ exports.applyNativeRootVars = applyNativeRootVars;
|
|
|
21
22
|
* The signature is intentionally identical to the plain variant so the import
|
|
22
23
|
* site in `BloomThemeProvider` is platform-agnostic.
|
|
23
24
|
*/
|
|
25
|
+
/** Web no-op of the native root-vars writer primitive (web writes to the document). */
|
|
26
|
+
function applyVarsToRootVariables(_vars) {
|
|
27
|
+
// Intentionally empty — web applies vars to `document.documentElement`.
|
|
28
|
+
}
|
|
24
29
|
function applyNativeRootVars(_colorPreset, _mode, _accents) {
|
|
25
30
|
// Intentionally empty — web applies preset vars to `document.documentElement`.
|
|
26
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["applyNativeRootVars","_colorPreset","_mode","_accents"],"sourceRoot":"../../../src","sources":["theme/native-root-vars.web.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["applyVarsToRootVariables","_vars","applyNativeRootVars","_colorPreset","_mode","_accents"],"sourceRoot":"../../../src","sources":["theme/native-root-vars.web.ts"],"mappings":";;;;;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,wBAAwBA,CAACC,KAA6B,EAAQ;EAC5E;AAAA;AAGK,SAASC,mBAAmBA,CACjCC,YAA0B,EAC1BC,KAAuB,EACvBC,QAA0B,EACpB;EACN;AAAA","ignoreList":[]}
|
|
@@ -9,10 +9,12 @@ import React, { createContext, useCallback, useEffect, useMemo, useRef, useState
|
|
|
9
9
|
import { Platform, View, useColorScheme as useRNColorScheme } from 'react-native';
|
|
10
10
|
import { useControllableState } from "../hooks/useControllableState.js";
|
|
11
11
|
import { FontLoader } from '../fonts/FontLoader';
|
|
12
|
-
import { applyDarkClass,
|
|
12
|
+
import { applyDarkClass, applyVarsToDocument } from "./apply-dark-class.js";
|
|
13
13
|
import { buildTheme } from "./build-theme.js";
|
|
14
|
+
import { buildThemeFromSeed } from "./build-theme-from-seed.js";
|
|
15
|
+
import { buildSeedScopeVars } from "./color-scope/seed-scope.js";
|
|
14
16
|
import { buildScopeVars, getVariableContextProvider } from "./color-scope/style-builder.js";
|
|
15
|
-
import {
|
|
17
|
+
import { applyVarsToRootVariables } from './native-root-vars';
|
|
16
18
|
import { readPersistedTheme, readPersistedThemeSync, removePersistedTheme, writePersistedTheme } from "./persistence.js";
|
|
17
19
|
import { setColorSchemeSafe } from "./set-color-scheme-safe.js";
|
|
18
20
|
import { useIsomorphicLayoutEffect } from "./use-isomorphic-layout-effect.js";
|
|
@@ -159,6 +161,7 @@ export function BloomThemeProvider({
|
|
|
159
161
|
nativeWrapperStyle,
|
|
160
162
|
secondaryColor,
|
|
161
163
|
tertiaryColor,
|
|
164
|
+
seed,
|
|
162
165
|
children
|
|
163
166
|
}) {
|
|
164
167
|
const rnScheme = useRNColorScheme();
|
|
@@ -195,38 +198,52 @@ export function BloomThemeProvider({
|
|
|
195
198
|
// Apply native color scheme, dark class, and CSS vars whenever the resolved
|
|
196
199
|
// mode or preset changes. `useIsomorphicLayoutEffect` runs before paint on
|
|
197
200
|
// both native and web, eliminating the previous render-time side effect.
|
|
201
|
+
// The single `--x -> value` record + JS theme for the ACTIVE source, computed
|
|
202
|
+
// ONCE and applied identically to web (document), native (rootVariables +
|
|
203
|
+
// VariableContext), and the JS `theme` context. The source is a DYNAMIC seed
|
|
204
|
+
// (whole-app dynamic theming — `secondaryColor`/`tertiaryColor` pin this seed's
|
|
205
|
+
// accents) when `seed` is set, else the named preset. Both go through the same
|
|
206
|
+
// colour engine, so there is one code path — no seed/preset duplication.
|
|
207
|
+
const themeVars = useMemo(() => seed ? buildSeedScopeVars({
|
|
208
|
+
seed,
|
|
209
|
+
mode: resolved,
|
|
210
|
+
secondarySeed: secondaryColor,
|
|
211
|
+
tertiarySeed: tertiaryColor
|
|
212
|
+
}) : buildScopeVars(colorPreset, resolved, explicitAccents), [seed, secondaryColor, tertiaryColor, colorPreset, resolved, explicitAccents]);
|
|
213
|
+
const themeColors = useMemo(() => seed ? buildThemeFromSeed(seed, resolved, undefined, undefined, {
|
|
214
|
+
secondarySeed: secondaryColor,
|
|
215
|
+
tertiarySeed: tertiaryColor
|
|
216
|
+
}) : buildTheme(colorPreset, resolved, isAdaptive, explicitAccents), [seed, secondaryColor, tertiaryColor, colorPreset, resolved, isAdaptive, explicitAccents]);
|
|
198
217
|
useIsomorphicLayoutEffect(() => {
|
|
199
218
|
setColorSchemeSafe(effectiveMode);
|
|
200
219
|
applyDarkClass(resolved);
|
|
201
|
-
|
|
202
|
-
}, [effectiveMode, resolved,
|
|
220
|
+
applyVarsToDocument(themeVars);
|
|
221
|
+
}, [effectiveMode, resolved, themeVars]);
|
|
203
222
|
|
|
204
|
-
// Native only: publish the
|
|
223
|
+
// Native only: publish the same vars into react-native-css's GLOBAL root
|
|
205
224
|
// variable family so they reach the ENTIRE app tree — navigator screens and
|
|
206
225
|
// every portal/modal/bottom-sheet that paints outside the provider's React
|
|
207
226
|
// subtree (and therefore never sees the `VariableContextProvider` vars below).
|
|
208
227
|
// Web writes the same vars to `document.documentElement` above, so this no-ops
|
|
209
|
-
// there. Runs before paint via `useIsomorphicLayoutEffect
|
|
210
|
-
// sibling `applyColorPresetVars` side effect.
|
|
228
|
+
// there. Runs before paint via `useIsomorphicLayoutEffect`.
|
|
211
229
|
useIsomorphicLayoutEffect(() => {
|
|
212
|
-
|
|
213
|
-
}, [
|
|
230
|
+
applyVarsToRootVariables(themeVars);
|
|
231
|
+
}, [themeVars]);
|
|
214
232
|
const contextValue = useMemo(() => ({
|
|
215
|
-
theme:
|
|
233
|
+
theme: themeColors,
|
|
216
234
|
mode,
|
|
217
235
|
colorPreset,
|
|
218
236
|
setMode,
|
|
219
237
|
setColorPreset,
|
|
220
238
|
resetTheme
|
|
221
|
-
}), [
|
|
239
|
+
}), [themeColors, mode, colorPreset, setMode, setColorPreset, resetTheme]);
|
|
222
240
|
const shouldAwait = awaitHydration ?? Boolean(persistKey && storage);
|
|
223
241
|
const isGated = shouldAwait && !hydrated;
|
|
224
242
|
|
|
225
|
-
//
|
|
226
|
-
//
|
|
227
|
-
//
|
|
228
|
-
|
|
229
|
-
const nativeVars = useMemo(() => Platform.OS === 'web' ? null : buildScopeVars(colorPreset, resolved, explicitAccents), [colorPreset, resolved, explicitAccents]);
|
|
243
|
+
// On native, the same record is handed to `VariableContextProvider` so
|
|
244
|
+
// descendants resolve `var(--primary)` etc. through react-native-css's real
|
|
245
|
+
// VariableContext. Web writes them to `document.documentElement` above.
|
|
246
|
+
const nativeVars = useMemo(() => Platform.OS === 'web' ? null : themeVars, [themeVars]);
|
|
230
247
|
const VariableProvider = getVariableContextProvider();
|
|
231
248
|
const content = /*#__PURE__*/_jsx(FontLoader, {
|
|
232
249
|
enabled: fonts,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","createContext","useCallback","useEffect","useMemo","useRef","useState","Platform","View","useColorScheme","useRNColorScheme","useControllableState","FontLoader","applyDarkClass","
|
|
1
|
+
{"version":3,"names":["React","createContext","useCallback","useEffect","useMemo","useRef","useState","Platform","View","useColorScheme","useRNColorScheme","useControllableState","FontLoader","applyDarkClass","applyVarsToDocument","buildTheme","buildThemeFromSeed","buildSeedScopeVars","buildScopeVars","getVariableContextProvider","applyVarsToRootVariables","readPersistedTheme","readPersistedThemeSync","removePersistedTheme","writePersistedTheme","setColorSchemeSafe","useIsomorphicLayoutEffect","jsx","_jsx","DEFAULT_PRESET","DEFAULT_MODE","BloomThemeContext","globalThis","__oxyhq_bloom_theme_context__","useThemeState","controlledMode","controlledPreset","defaultMode","defaultPreset","persistKey","storage","onModeChange","onColorPresetChange","syncResult","syncState","kind","state","initialMode","mode","initialPreset","colorPreset","hydrated","setHydrated","setModeInternal","value","defaultValue","setPresetInternal","modeRef","current","presetRef","cancelled","then","undefined","setMode","next","setColorPreset","resetTheme","BloomThemeProvider","defaultColorPreset","awaitHydration","onHydrating","fonts","onFontsLoading","nativeWrapperStyle","secondaryColor","tertiaryColor","seed","children","rnScheme","explicitAccents","secondaryHex","tertiaryHex","isAdaptive","effectiveMode","resolved","themeVars","secondarySeed","tertiarySeed","themeColors","contextValue","theme","shouldAwait","Boolean","isGated","nativeVars","OS","VariableProvider","content","enabled","fallback","Provider","nativeTree","style","flex"],"sourceRoot":"../../../src","sources":["theme/BloomThemeProvider.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA,OAAO,uBAAoB;AAE3B,OAAOA,KAAK,IACVC,aAAa,EACbC,WAAW,EAEXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AACd,SACEC,QAAQ,EACRC,IAAI,EACJC,cAAc,IAAIC,gBAAgB,QAG7B,cAAc;AAErB,SAASC,oBAAoB,QAAQ,kCAA+B;AACpE,SAASC,UAAU,QAAQ,qBAAqB;AAEhD,SAASC,cAAc,EAAEC,mBAAmB,QAAQ,uBAAoB;AACxE,SAASC,UAAU,QAAQ,kBAAe;AAC1C,SAASC,kBAAkB,QAAQ,4BAAyB;AAC5D,SAASC,kBAAkB,QAAQ,6BAA0B;AAE7D,SAASC,cAAc,EAAEC,0BAA0B,QAAQ,gCAA6B;AACxF,SAASC,wBAAwB,QAAQ,oBAAoB;AAC7D,SACEC,kBAAkB,EAClBC,sB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AW,IAAI,CAACxC,QAAQ;;EAExC;EACA;EACA;EACA,MAAM2C,UAAU,GAAG1F,OAAO,CACxB,MAAOG,QAAQ,CAACwF,EAAE,KAAK,KAAK,GAAG,IAAI,GAAGV,SAAU,EAChD,CAACA,SAAS,CACZ,CAAC;EACD,MAAMW,gBAAgB,GAAG7E,0BAA0B,CAAC,CAAC;EAErD,MAAM8E,OAAO,gBACXrE,IAAA,CAAChB,UAAU;IAACsF,OAAO,EAAE3B,KAAM;IAAC4B,QAAQ,EAAE3B,cAAe;IAAAK,QAAA,EAClDgB,OAAO,GAAGvB,WAAW,IAAI,IAAI,GAAGO;EAAQ,CAC/B,CACb;EAED,IAAItE,QAAQ,CAACwF,EAAE,KAAK,KAAK,EAAE;IACzB,oBAAOnE,IAAA,CAACG,iBAAiB,CAACqE,QAAQ;MAAC9C,KAAK,EAAEmC,YAAa;MAAAZ,QAAA,EAAEoB;IAAO,CAA6B,CAAC;EAChG;;EAEA;EACA;EACA;EACA,MAAMI,UAAU,gBAAGzE,IAAA,CAACpB,IAAI;IAAC8F,KAAK,EAAE,CAAC;MAAEC,IAAI,EAAE;IAAE,CAAC,EAAE9B,kBAAkB,CAAE;IAAAI,QAAA,EAAEoB;EAAO,CAAO,CAAC;EAEnF,oBACErE,IAAA,CAACG,iBAAiB,CAACqE,QAAQ;IAAC9C,KAAK,EAAEmC,YAAa;IAAAZ,QAAA,EAC7CmB,gBAAgB,IAAIF,UAAU,gBAC7BlE,IAAA,CAACoE,gBAAgB;MAAC1C,KAAK,EAAEwC,UAAW;MAAAjB,QAAA,EAAEwB;IAAU,CAAmB,CAAC,GAEpEA;EACD,CACyB,CAAC;AAEjC","ignoreList":[]}
|
|
@@ -26,13 +26,21 @@ export function applyDarkClass(resolved) {
|
|
|
26
26
|
* Includes extended tokens (card, chart-*, content-area, sidebar-*) so consumer
|
|
27
27
|
* apps don't need to synthesize them.
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Write a pre-computed `--x -> value` record to the document root (web only).
|
|
31
|
+
* The single web writer primitive: both the preset path (`applyColorPresetVars`)
|
|
32
|
+
* and `BloomThemeProvider`'s dynamic-seed path feed their already-resolved vars
|
|
33
|
+
* through here, so the "write to document" logic lives in exactly one place.
|
|
34
|
+
*/
|
|
35
|
+
export function applyVarsToDocument(vars) {
|
|
30
36
|
if (Platform.OS !== 'web' || typeof document === 'undefined') return;
|
|
31
|
-
if (!APP_COLOR_PRESETS[preset]) return;
|
|
32
|
-
const vars = getResolvedTokens(preset, resolved, accents);
|
|
33
37
|
const root = document.documentElement.style;
|
|
34
38
|
for (const [key, value] of Object.entries(vars)) {
|
|
35
39
|
root.setProperty(key, value);
|
|
36
40
|
}
|
|
37
41
|
}
|
|
42
|
+
export function applyColorPresetVars(preset, resolved, accents) {
|
|
43
|
+
if (!APP_COLOR_PRESETS[preset]) return;
|
|
44
|
+
applyVarsToDocument(getResolvedTokens(preset, resolved, accents));
|
|
45
|
+
}
|
|
38
46
|
//# sourceMappingURL=apply-dark-class.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","APP_COLOR_PRESETS","getResolvedTokens","applyDarkClass","resolved","OS","document","documentElement","classList","toggle","
|
|
1
|
+
{"version":3,"names":["Platform","APP_COLOR_PRESETS","getResolvedTokens","applyDarkClass","resolved","OS","document","documentElement","classList","toggle","applyVarsToDocument","vars","root","style","key","value","Object","entries","setProperty","applyColorPresetVars","preset","accents"],"sourceRoot":"../../../src","sources":["theme/apply-dark-class.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,iBAAiB,QAA2B,oBAAiB;AAEtE,SAASC,iBAAiB,QAAQ,qBAAkB;AAEpD,OAAO,SAASC,cAAcA,CAACC,QAA0B,EAAE;EACzD,IAAIJ,QAAQ,CAACK,EAAE,KAAK,KAAK,IAAI,OAAOC,QAAQ,KAAK,WAAW,EAAE;IAC5DA,QAAQ,CAACC,eAAe,CAACC,SAAS,CAACC,MAAM,CAAC,MAAM,EAAEL,QAAQ,KAAK,MAAM,CAAC;EACxE;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASM,mBAAmBA,CAACC,IAA4B,EAAE;EAChE,IAAIX,QAAQ,CAACK,EAAE,KAAK,KAAK,IAAI,OAAOC,QAAQ,KAAK,WAAW,EAAE;EAC9D,MAAMM,IAAI,GAAGN,QAAQ,CAACC,eAAe,CAACM,KAAK;EAC3C,KAAK,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACN,IAAI,CAAC,EAAE;IAC/CC,IAAI,CAACM,WAAW,CAACJ,GAAG,EAAEC,KAAK,CAAC;EAC9B;AACF;AAEA,OAAO,SAASI,oBAAoBA,CAClCC,MAAoB,EACpBhB,QAA0B,EAC1BiB,OAAyB,EACzB;EACA,IAAI,CAACpB,iBAAiB,CAACmB,MAAM,CAAC,EAAE;EAChCV,mBAAmB,CAACR,iBAAiB,CAACkB,MAAM,EAAEhB,QAAQ,EAAEiB,OAAO,CAAC,CAAC;AACnE","ignoreList":[]}
|
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
* The signature is intentionally identical to those variants so the import site in
|
|
31
31
|
* `BloomThemeProvider` is platform-agnostic.
|
|
32
32
|
*/
|
|
33
|
+
/** Neutral-default no-op of the native root-vars writer primitive. */
|
|
34
|
+
export function applyVarsToRootVariables(_vars) {
|
|
35
|
+
// Intentionally empty — the native variant does the real work.
|
|
36
|
+
}
|
|
33
37
|
export function applyNativeRootVars(_colorPreset, _mode, _accents) {
|
|
34
38
|
// Intentionally empty — the native variant (`native-root-vars.native.ts`) does
|
|
35
39
|
// the real work; this neutral default and the web fork are inert.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["applyNativeRootVars","_colorPreset","_mode","_accents"],"sourceRoot":"../../../src","sources":["theme/native-root-vars.ts"],"mappings":";;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;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,CACjCC,YAA0B,EAC1BC,KAAuB,EACvBC,QAA0B,EACpB;EACN;EACA;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["applyVarsToRootVariables","_vars","applyNativeRootVars","_colorPreset","_mode","_accents"],"sourceRoot":"../../../src","sources":["theme/native-root-vars.ts"],"mappings":";;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,wBAAwBA,CAACC,KAA6B,EAAQ;EAC5E;AAAA;AAGF,OAAO,SAASC,mBAAmBA,CACjCC,YAA0B,EAC1BC,KAAuB,EACvBC,QAA0B,EACpB;EACN;EACA;AAAA","ignoreList":[]}
|
|
@@ -121,13 +121,22 @@ import { getResolvedTokens } from "./token-registry.js";
|
|
|
121
121
|
* Defensive guard: if a host ships a react-native-css build that doesn't expose
|
|
122
122
|
* `rootVariables` as a callable (it always does on @3), we bail rather than throw.
|
|
123
123
|
*/
|
|
124
|
-
|
|
124
|
+
/**
|
|
125
|
+
* Write a pre-computed `--x -> value` record into react-native-css's global
|
|
126
|
+
* `rootVariables` family. The single native writer primitive: both the preset
|
|
127
|
+
* path (`applyNativeRootVars`) and `BloomThemeProvider`'s dynamic-seed path feed
|
|
128
|
+
* their already-resolved vars through here, so the global-write logic lives in
|
|
129
|
+
* exactly one place.
|
|
130
|
+
*/
|
|
131
|
+
export function applyVarsToRootVariables(vars) {
|
|
125
132
|
if (typeof rootVariables !== 'function') return;
|
|
126
|
-
const vars = getResolvedTokens(colorPreset, mode, accents);
|
|
127
133
|
for (const [key, value] of Object.entries(vars)) {
|
|
128
|
-
// The family is keyed by the bare name;
|
|
134
|
+
// The family is keyed by the bare name; the var keys include `--`.
|
|
129
135
|
const name = key.startsWith('--') ? key.slice(2) : key;
|
|
130
136
|
rootVariables(name).set([[value]]);
|
|
131
137
|
}
|
|
132
138
|
}
|
|
139
|
+
export function applyNativeRootVars(colorPreset, mode, accents) {
|
|
140
|
+
applyVarsToRootVariables(getResolvedTokens(colorPreset, mode, accents));
|
|
141
|
+
}
|
|
133
142
|
//# sourceMappingURL=native-root-vars.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["rootVariables","getResolvedTokens","
|
|
1
|
+
{"version":3,"names":["rootVariables","getResolvedTokens","applyVarsToRootVariables","vars","key","value","Object","entries","name","startsWith","slice","set","applyNativeRootVars","colorPreset","mode","accents"],"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;AAIhE,SAASC,iBAAiB,QAAQ,qBAAkB;;AAEpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,wBAAwBA,CAACC,IAA4B,EAAQ;EAC3E,IAAI,OAAOH,aAAa,KAAK,UAAU,EAAE;EACzC,KAAK,MAAM,CAACI,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;IACtDJ,aAAa,CAACQ,IAAI,CAAC,CAACG,GAAG,CAAC,CAAC,CAACN,KAAK,CAAC,CAAC,CAAC;EACpC;AACF;AAEA,OAAO,SAASO,mBAAmBA,CACjCC,WAAyB,EACzBC,IAAsB,EACtBC,OAAyB,EACnB;EACNb,wBAAwB,CAACD,iBAAiB,CAACY,WAAW,EAAEC,IAAI,EAAEC,OAAO,CAAC,CAAC;AACzE","ignoreList":[]}
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
* The signature is intentionally identical to the plain variant so the import
|
|
18
18
|
* site in `BloomThemeProvider` is platform-agnostic.
|
|
19
19
|
*/
|
|
20
|
+
/** Web no-op of the native root-vars writer primitive (web writes to the document). */
|
|
21
|
+
export function applyVarsToRootVariables(_vars) {
|
|
22
|
+
// Intentionally empty — web applies vars to `document.documentElement`.
|
|
23
|
+
}
|
|
20
24
|
export function applyNativeRootVars(_colorPreset, _mode, _accents) {
|
|
21
25
|
// Intentionally empty — web applies preset vars to `document.documentElement`.
|
|
22
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["applyNativeRootVars","_colorPreset","_mode","_accents"],"sourceRoot":"../../../src","sources":["theme/native-root-vars.web.ts"],"mappings":";;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,mBAAmBA,CACjCC,YAA0B,EAC1BC,KAAuB,EACvBC,QAA0B,EACpB;EACN;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["applyVarsToRootVariables","_vars","applyNativeRootVars","_colorPreset","_mode","_accents"],"sourceRoot":"../../../src","sources":["theme/native-root-vars.web.ts"],"mappings":";;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,wBAAwBA,CAACC,KAA6B,EAAQ;EAC5E;AAAA;AAGF,OAAO,SAASC,mBAAmBA,CACjCC,YAA0B,EAC1BC,KAAuB,EACvBC,QAA0B,EACpB;EACN;AAAA","ignoreList":[]}
|
|
@@ -96,7 +96,17 @@ export interface BloomThemeProviderProps {
|
|
|
96
96
|
* {@link BloomThemeProviderProps.secondaryColor} for the tertiary family.
|
|
97
97
|
*/
|
|
98
98
|
tertiaryColor?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Optional DYNAMIC seed colour, `#rrggbb`. When set, the WHOLE app themes from
|
|
101
|
+
* this seed instead of the named `colorPreset` (via the same colour engine the
|
|
102
|
+
* preset path uses) — driving app-wide dynamic theming (e.g. tint everything to
|
|
103
|
+
* the artwork the user is viewing/hovering). `secondaryColor`/`tertiaryColor`
|
|
104
|
+
* act as this seed's pinned secondary/tertiary accents (e.g. the 2nd/3rd colours
|
|
105
|
+
* extracted from that artwork). Omit / pass `undefined` to fall back to the
|
|
106
|
+
* preset — so clearing it restores the app's default theme.
|
|
107
|
+
*/
|
|
108
|
+
seed?: string;
|
|
99
109
|
children: React.ReactNode;
|
|
100
110
|
}
|
|
101
|
-
export declare function BloomThemeProvider({ mode: controlledMode, colorPreset: controlledPreset, defaultMode, defaultColorPreset, onModeChange, onColorPresetChange, persistKey, storage, awaitHydration, onHydrating, fonts, onFontsLoading, nativeWrapperStyle, secondaryColor, tertiaryColor, children, }: BloomThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
111
|
+
export declare function BloomThemeProvider({ mode: controlledMode, colorPreset: controlledPreset, defaultMode, defaultColorPreset, onModeChange, onColorPresetChange, persistKey, storage, awaitHydration, onHydrating, fonts, onFontsLoading, nativeWrapperStyle, secondaryColor, tertiaryColor, seed, children, }: BloomThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
102
112
|
//# sourceMappingURL=BloomThemeProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BloomThemeProvider.d.ts","sourceRoot":"","sources":["../../../../src/theme/BloomThemeProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,oBAAoB,CAAC;AAE5B,OAAO,KAQN,MAAM,OAAO,CAAC;AACf,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"BloomThemeProvider.d.ts","sourceRoot":"","sources":["../../../../src/theme/BloomThemeProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,oBAAoB,CAAC;AAE5B,OAAO,KAQN,MAAM,OAAO,CAAC;AACf,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAStB,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpD,OAAO,EAKL,KAAK,iBAAiB,EAEvB,MAAM,eAAe,CAAC;AAIvB,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKhD,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;IAChB,WAAW,EAAE,YAAY,CAAC;IAC1B,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IACnC,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC/C;;;;OAIG;IACH,UAAU,EAAE,MAAM,IAAI,CAAC;CAC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AC;CAC3B;AAkJD,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EAAE,cAAc,EACpB,WAAW,EAAE,gBAAgB,EAC7B,WAA0B,EAC1B,kBAAmC,EACnC,YAAY,EACZ,mBAAmB,EACnB,UAAU,EACV,OAAO,EACP,cAAc,EACd,WAAW,EACX,KAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,IAAI,EACJ,QAAQ,GACT,EAAE,uBAAuB,2CA0HzB"}
|
|
@@ -18,5 +18,12 @@ export declare function applyDarkClass(resolved: 'light' | 'dark'): void;
|
|
|
18
18
|
* Includes extended tokens (card, chart-*, content-area, sidebar-*) so consumer
|
|
19
19
|
* apps don't need to synthesize them.
|
|
20
20
|
*/
|
|
21
|
+
/**
|
|
22
|
+
* Write a pre-computed `--x -> value` record to the document root (web only).
|
|
23
|
+
* The single web writer primitive: both the preset path (`applyColorPresetVars`)
|
|
24
|
+
* and `BloomThemeProvider`'s dynamic-seed path feed their already-resolved vars
|
|
25
|
+
* through here, so the "write to document" logic lives in exactly one place.
|
|
26
|
+
*/
|
|
27
|
+
export declare function applyVarsToDocument(vars: Record<string, string>): void;
|
|
21
28
|
export declare function applyColorPresetVars(preset: AppColorName, resolved: 'light' | 'dark', accents?: ExplicitAccents): void;
|
|
22
29
|
//# 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;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGrD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,QAIxD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,OAAO,GAAG,MAAM,EAC1B,OAAO,CAAC,EAAE,eAAe,
|
|
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;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGrD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,QAIxD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAM/D;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,OAAO,GAAG,MAAM,EAC1B,OAAO,CAAC,EAAE,eAAe,QAI1B"}
|
|
@@ -30,5 +30,7 @@ import type { ExplicitAccents } from './preset-vars';
|
|
|
30
30
|
* The signature is intentionally identical to those variants so the import site in
|
|
31
31
|
* `BloomThemeProvider` is platform-agnostic.
|
|
32
32
|
*/
|
|
33
|
+
/** Neutral-default no-op of the native root-vars writer primitive. */
|
|
34
|
+
export declare function applyVarsToRootVariables(_vars: Record<string, string>): void;
|
|
33
35
|
export declare function applyNativeRootVars(_colorPreset: AppColorName, _mode: 'light' | 'dark', _accents?: ExplicitAccents): void;
|
|
34
36
|
//# 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":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,OAAO,GAAG,MAAM,EACvB,QAAQ,CAAC,EAAE,eAAe,GACzB,IAAI,CAGN"}
|
|
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;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,sEAAsE;AACtE,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAE5E;AAED,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,OAAO,GAAG,MAAM,EACvB,QAAQ,CAAC,EAAE,eAAe,GACzB,IAAI,CAGN"}
|
|
@@ -101,5 +101,13 @@ import type { ExplicitAccents } from './preset-vars';
|
|
|
101
101
|
* Defensive guard: if a host ships a react-native-css build that doesn't expose
|
|
102
102
|
* `rootVariables` as a callable (it always does on @3), we bail rather than throw.
|
|
103
103
|
*/
|
|
104
|
+
/**
|
|
105
|
+
* Write a pre-computed `--x -> value` record into react-native-css's global
|
|
106
|
+
* `rootVariables` family. The single native writer primitive: both the preset
|
|
107
|
+
* path (`applyNativeRootVars`) and `BloomThemeProvider`'s dynamic-seed path feed
|
|
108
|
+
* their already-resolved vars through here, so the global-write logic lives in
|
|
109
|
+
* exactly one place.
|
|
110
|
+
*/
|
|
111
|
+
export declare function applyVarsToRootVariables(vars: Record<string, string>): void;
|
|
104
112
|
export declare function applyNativeRootVars(colorPreset: AppColorName, mode: 'light' | 'dark', accents?: ExplicitAccents): void;
|
|
105
113
|
//# sourceMappingURL=native-root-vars.native.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-root-vars.native.d.ts","sourceRoot":"","sources":["../../../../src/theme/native-root-vars.native.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuFG;AAEH;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,YAAY,EACzB,IAAI,EAAE,OAAO,GAAG,MAAM,EACtB,OAAO,CAAC,EAAE,eAAe,GACxB,IAAI,
|
|
1
|
+
{"version":3,"file":"native-root-vars.native.d.ts","sourceRoot":"","sources":["../../../../src/theme/native-root-vars.native.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuFG;AAEH;;;;;;;;;;;;GAYG;AACH;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAO3E;AAED,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,YAAY,EACzB,IAAI,EAAE,OAAO,GAAG,MAAM,EACtB,OAAO,CAAC,EAAE,eAAe,GACxB,IAAI,CAEN"}
|
|
@@ -17,5 +17,7 @@ import type { ExplicitAccents } from './preset-vars';
|
|
|
17
17
|
* The signature is intentionally identical to the plain variant so the import
|
|
18
18
|
* site in `BloomThemeProvider` is platform-agnostic.
|
|
19
19
|
*/
|
|
20
|
+
/** Web no-op of the native root-vars writer primitive (web writes to the document). */
|
|
21
|
+
export declare function applyVarsToRootVariables(_vars: Record<string, string>): void;
|
|
20
22
|
export declare function applyNativeRootVars(_colorPreset: AppColorName, _mode: 'light' | 'dark', _accents?: ExplicitAccents): void;
|
|
21
23
|
//# sourceMappingURL=native-root-vars.web.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-root-vars.web.d.ts","sourceRoot":"","sources":["../../../../src/theme/native-root-vars.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,OAAO,GAAG,MAAM,EACvB,QAAQ,CAAC,EAAE,eAAe,GACzB,IAAI,CAEN"}
|
|
1
|
+
{"version":3,"file":"native-root-vars.web.d.ts","sourceRoot":"","sources":["../../../../src/theme/native-root-vars.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;;;;;;;;;;;;;;GAgBG;AACH,uFAAuF;AACvF,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAE5E;AAED,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,OAAO,GAAG,MAAM,EACvB,QAAQ,CAAC,EAAE,eAAe,GACzB,IAAI,CAEN"}
|
|
@@ -96,7 +96,17 @@ export interface BloomThemeProviderProps {
|
|
|
96
96
|
* {@link BloomThemeProviderProps.secondaryColor} for the tertiary family.
|
|
97
97
|
*/
|
|
98
98
|
tertiaryColor?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Optional DYNAMIC seed colour, `#rrggbb`. When set, the WHOLE app themes from
|
|
101
|
+
* this seed instead of the named `colorPreset` (via the same colour engine the
|
|
102
|
+
* preset path uses) — driving app-wide dynamic theming (e.g. tint everything to
|
|
103
|
+
* the artwork the user is viewing/hovering). `secondaryColor`/`tertiaryColor`
|
|
104
|
+
* act as this seed's pinned secondary/tertiary accents (e.g. the 2nd/3rd colours
|
|
105
|
+
* extracted from that artwork). Omit / pass `undefined` to fall back to the
|
|
106
|
+
* preset — so clearing it restores the app's default theme.
|
|
107
|
+
*/
|
|
108
|
+
seed?: string;
|
|
99
109
|
children: React.ReactNode;
|
|
100
110
|
}
|
|
101
|
-
export declare function BloomThemeProvider({ mode: controlledMode, colorPreset: controlledPreset, defaultMode, defaultColorPreset, onModeChange, onColorPresetChange, persistKey, storage, awaitHydration, onHydrating, fonts, onFontsLoading, nativeWrapperStyle, secondaryColor, tertiaryColor, children, }: BloomThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
111
|
+
export declare function BloomThemeProvider({ mode: controlledMode, colorPreset: controlledPreset, defaultMode, defaultColorPreset, onModeChange, onColorPresetChange, persistKey, storage, awaitHydration, onHydrating, fonts, onFontsLoading, nativeWrapperStyle, secondaryColor, tertiaryColor, seed, children, }: BloomThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
102
112
|
//# sourceMappingURL=BloomThemeProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BloomThemeProvider.d.ts","sourceRoot":"","sources":["../../../../src/theme/BloomThemeProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,oBAAoB,CAAC;AAE5B,OAAO,KAQN,MAAM,OAAO,CAAC;AACf,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"BloomThemeProvider.d.ts","sourceRoot":"","sources":["../../../../src/theme/BloomThemeProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,oBAAoB,CAAC;AA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AAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B;;;;;OAKG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iDAAiD;IACjD,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE9B,2DAA2D;IAC3D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,wDAAwD;IACxD,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAEjC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAE1C;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAkJD,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EAAE,cAAc,EACpB,WAAW,EAAE,gBAAgB,EAC7B,WAA0B,EAC1B,kBAAmC,EACnC,YAAY,EACZ,mBAAmB,EACnB,UAAU,EACV,OAAO,EACP,cAAc,EACd,WAAW,EACX,KAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,IAAI,EACJ,QAAQ,GACT,EAAE,uBAAuB,2CA0HzB"}
|
|
@@ -18,5 +18,12 @@ export declare function applyDarkClass(resolved: 'light' | 'dark'): void;
|
|
|
18
18
|
* Includes extended tokens (card, chart-*, content-area, sidebar-*) so consumer
|
|
19
19
|
* apps don't need to synthesize them.
|
|
20
20
|
*/
|
|
21
|
+
/**
|
|
22
|
+
* Write a pre-computed `--x -> value` record to the document root (web only).
|
|
23
|
+
* The single web writer primitive: both the preset path (`applyColorPresetVars`)
|
|
24
|
+
* and `BloomThemeProvider`'s dynamic-seed path feed their already-resolved vars
|
|
25
|
+
* through here, so the "write to document" logic lives in exactly one place.
|
|
26
|
+
*/
|
|
27
|
+
export declare function applyVarsToDocument(vars: Record<string, string>): void;
|
|
21
28
|
export declare function applyColorPresetVars(preset: AppColorName, resolved: 'light' | 'dark', accents?: ExplicitAccents): void;
|
|
22
29
|
//# 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;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGrD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,QAIxD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,OAAO,GAAG,MAAM,EAC1B,OAAO,CAAC,EAAE,eAAe,
|
|
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;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGrD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,QAIxD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAM/D;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,OAAO,GAAG,MAAM,EAC1B,OAAO,CAAC,EAAE,eAAe,QAI1B"}
|
|
@@ -30,5 +30,7 @@ import type { ExplicitAccents } from './preset-vars';
|
|
|
30
30
|
* The signature is intentionally identical to those variants so the import site in
|
|
31
31
|
* `BloomThemeProvider` is platform-agnostic.
|
|
32
32
|
*/
|
|
33
|
+
/** Neutral-default no-op of the native root-vars writer primitive. */
|
|
34
|
+
export declare function applyVarsToRootVariables(_vars: Record<string, string>): void;
|
|
33
35
|
export declare function applyNativeRootVars(_colorPreset: AppColorName, _mode: 'light' | 'dark', _accents?: ExplicitAccents): void;
|
|
34
36
|
//# 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":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,OAAO,GAAG,MAAM,EACvB,QAAQ,CAAC,EAAE,eAAe,GACzB,IAAI,CAGN"}
|
|
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;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,sEAAsE;AACtE,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAE5E;AAED,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,OAAO,GAAG,MAAM,EACvB,QAAQ,CAAC,EAAE,eAAe,GACzB,IAAI,CAGN"}
|
|
@@ -101,5 +101,13 @@ import type { ExplicitAccents } from './preset-vars';
|
|
|
101
101
|
* Defensive guard: if a host ships a react-native-css build that doesn't expose
|
|
102
102
|
* `rootVariables` as a callable (it always does on @3), we bail rather than throw.
|
|
103
103
|
*/
|
|
104
|
+
/**
|
|
105
|
+
* Write a pre-computed `--x -> value` record into react-native-css's global
|
|
106
|
+
* `rootVariables` family. The single native writer primitive: both the preset
|
|
107
|
+
* path (`applyNativeRootVars`) and `BloomThemeProvider`'s dynamic-seed path feed
|
|
108
|
+
* their already-resolved vars through here, so the global-write logic lives in
|
|
109
|
+
* exactly one place.
|
|
110
|
+
*/
|
|
111
|
+
export declare function applyVarsToRootVariables(vars: Record<string, string>): void;
|
|
104
112
|
export declare function applyNativeRootVars(colorPreset: AppColorName, mode: 'light' | 'dark', accents?: ExplicitAccents): void;
|
|
105
113
|
//# sourceMappingURL=native-root-vars.native.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-root-vars.native.d.ts","sourceRoot":"","sources":["../../../../src/theme/native-root-vars.native.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuFG;AAEH;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,YAAY,EACzB,IAAI,EAAE,OAAO,GAAG,MAAM,EACtB,OAAO,CAAC,EAAE,eAAe,GACxB,IAAI,
|
|
1
|
+
{"version":3,"file":"native-root-vars.native.d.ts","sourceRoot":"","sources":["../../../../src/theme/native-root-vars.native.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuFG;AAEH;;;;;;;;;;;;GAYG;AACH;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAO3E;AAED,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,YAAY,EACzB,IAAI,EAAE,OAAO,GAAG,MAAM,EACtB,OAAO,CAAC,EAAE,eAAe,GACxB,IAAI,CAEN"}
|
|
@@ -17,5 +17,7 @@ import type { ExplicitAccents } from './preset-vars';
|
|
|
17
17
|
* The signature is intentionally identical to the plain variant so the import
|
|
18
18
|
* site in `BloomThemeProvider` is platform-agnostic.
|
|
19
19
|
*/
|
|
20
|
+
/** Web no-op of the native root-vars writer primitive (web writes to the document). */
|
|
21
|
+
export declare function applyVarsToRootVariables(_vars: Record<string, string>): void;
|
|
20
22
|
export declare function applyNativeRootVars(_colorPreset: AppColorName, _mode: 'light' | 'dark', _accents?: ExplicitAccents): void;
|
|
21
23
|
//# sourceMappingURL=native-root-vars.web.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-root-vars.web.d.ts","sourceRoot":"","sources":["../../../../src/theme/native-root-vars.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,OAAO,GAAG,MAAM,EACvB,QAAQ,CAAC,EAAE,eAAe,GACzB,IAAI,CAEN"}
|
|
1
|
+
{"version":3,"file":"native-root-vars.web.d.ts","sourceRoot":"","sources":["../../../../src/theme/native-root-vars.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;;;;;;;;;;;;;;GAgBG;AACH,uFAAuF;AACvF,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAE5E;AAED,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,OAAO,GAAG,MAAM,EACvB,QAAQ,CAAC,EAAE,eAAe,GACzB,IAAI,CAEN"}
|
package/package.json
CHANGED
|
@@ -24,11 +24,13 @@ import {
|
|
|
24
24
|
import { useControllableState } from '../hooks/useControllableState';
|
|
25
25
|
import { FontLoader } from '../fonts/FontLoader';
|
|
26
26
|
|
|
27
|
-
import { applyDarkClass,
|
|
27
|
+
import { applyDarkClass, applyVarsToDocument } from './apply-dark-class';
|
|
28
28
|
import { buildTheme } from './build-theme';
|
|
29
|
+
import { buildThemeFromSeed } from './build-theme-from-seed';
|
|
30
|
+
import { buildSeedScopeVars } from './color-scope/seed-scope';
|
|
29
31
|
import { type AppColorName } from './color-presets';
|
|
30
32
|
import { buildScopeVars, getVariableContextProvider } from './color-scope/style-builder';
|
|
31
|
-
import {
|
|
33
|
+
import { applyVarsToRootVariables } from './native-root-vars';
|
|
32
34
|
import {
|
|
33
35
|
readPersistedTheme,
|
|
34
36
|
readPersistedThemeSync,
|
|
@@ -151,6 +153,17 @@ export interface BloomThemeProviderProps {
|
|
|
151
153
|
*/
|
|
152
154
|
tertiaryColor?: string;
|
|
153
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Optional DYNAMIC seed colour, `#rrggbb`. When set, the WHOLE app themes from
|
|
158
|
+
* this seed instead of the named `colorPreset` (via the same colour engine the
|
|
159
|
+
* preset path uses) — driving app-wide dynamic theming (e.g. tint everything to
|
|
160
|
+
* the artwork the user is viewing/hovering). `secondaryColor`/`tertiaryColor`
|
|
161
|
+
* act as this seed's pinned secondary/tertiary accents (e.g. the 2nd/3rd colours
|
|
162
|
+
* extracted from that artwork). Omit / pass `undefined` to fall back to the
|
|
163
|
+
* preset — so clearing it restores the app's default theme.
|
|
164
|
+
*/
|
|
165
|
+
seed?: string;
|
|
166
|
+
|
|
154
167
|
children: React.ReactNode;
|
|
155
168
|
}
|
|
156
169
|
|
|
@@ -314,6 +327,7 @@ export function BloomThemeProvider({
|
|
|
314
327
|
nativeWrapperStyle,
|
|
315
328
|
secondaryColor,
|
|
316
329
|
tertiaryColor,
|
|
330
|
+
seed,
|
|
317
331
|
children,
|
|
318
332
|
}: BloomThemeProviderProps) {
|
|
319
333
|
const rnScheme = useRNColorScheme();
|
|
@@ -349,45 +363,67 @@ export function BloomThemeProvider({
|
|
|
349
363
|
// Apply native color scheme, dark class, and CSS vars whenever the resolved
|
|
350
364
|
// mode or preset changes. `useIsomorphicLayoutEffect` runs before paint on
|
|
351
365
|
// both native and web, eliminating the previous render-time side effect.
|
|
366
|
+
// The single `--x -> value` record + JS theme for the ACTIVE source, computed
|
|
367
|
+
// ONCE and applied identically to web (document), native (rootVariables +
|
|
368
|
+
// VariableContext), and the JS `theme` context. The source is a DYNAMIC seed
|
|
369
|
+
// (whole-app dynamic theming — `secondaryColor`/`tertiaryColor` pin this seed's
|
|
370
|
+
// accents) when `seed` is set, else the named preset. Both go through the same
|
|
371
|
+
// colour engine, so there is one code path — no seed/preset duplication.
|
|
372
|
+
const themeVars = useMemo(
|
|
373
|
+
() =>
|
|
374
|
+
seed
|
|
375
|
+
? buildSeedScopeVars({ seed, mode: resolved, secondarySeed: secondaryColor, tertiarySeed: tertiaryColor })
|
|
376
|
+
: buildScopeVars(colorPreset, resolved, explicitAccents),
|
|
377
|
+
[seed, secondaryColor, tertiaryColor, colorPreset, resolved, explicitAccents],
|
|
378
|
+
);
|
|
379
|
+
const themeColors = useMemo(
|
|
380
|
+
() =>
|
|
381
|
+
seed
|
|
382
|
+
? buildThemeFromSeed(seed, resolved, undefined, undefined, {
|
|
383
|
+
secondarySeed: secondaryColor,
|
|
384
|
+
tertiarySeed: tertiaryColor,
|
|
385
|
+
})
|
|
386
|
+
: buildTheme(colorPreset, resolved, isAdaptive, explicitAccents),
|
|
387
|
+
[seed, secondaryColor, tertiaryColor, colorPreset, resolved, isAdaptive, explicitAccents],
|
|
388
|
+
);
|
|
389
|
+
|
|
352
390
|
useIsomorphicLayoutEffect(() => {
|
|
353
391
|
setColorSchemeSafe(effectiveMode);
|
|
354
392
|
applyDarkClass(resolved);
|
|
355
|
-
|
|
356
|
-
}, [effectiveMode, resolved,
|
|
393
|
+
applyVarsToDocument(themeVars);
|
|
394
|
+
}, [effectiveMode, resolved, themeVars]);
|
|
357
395
|
|
|
358
|
-
// Native only: publish the
|
|
396
|
+
// Native only: publish the same vars into react-native-css's GLOBAL root
|
|
359
397
|
// variable family so they reach the ENTIRE app tree — navigator screens and
|
|
360
398
|
// every portal/modal/bottom-sheet that paints outside the provider's React
|
|
361
399
|
// subtree (and therefore never sees the `VariableContextProvider` vars below).
|
|
362
400
|
// Web writes the same vars to `document.documentElement` above, so this no-ops
|
|
363
|
-
// there. Runs before paint via `useIsomorphicLayoutEffect
|
|
364
|
-
// sibling `applyColorPresetVars` side effect.
|
|
401
|
+
// there. Runs before paint via `useIsomorphicLayoutEffect`.
|
|
365
402
|
useIsomorphicLayoutEffect(() => {
|
|
366
|
-
|
|
367
|
-
}, [
|
|
403
|
+
applyVarsToRootVariables(themeVars);
|
|
404
|
+
}, [themeVars]);
|
|
368
405
|
|
|
369
406
|
const contextValue = useMemo<BloomThemeContextValue>(
|
|
370
407
|
() => ({
|
|
371
|
-
theme:
|
|
408
|
+
theme: themeColors,
|
|
372
409
|
mode,
|
|
373
410
|
colorPreset,
|
|
374
411
|
setMode,
|
|
375
412
|
setColorPreset,
|
|
376
413
|
resetTheme,
|
|
377
414
|
}),
|
|
378
|
-
[
|
|
415
|
+
[themeColors, mode, colorPreset, setMode, setColorPreset, resetTheme],
|
|
379
416
|
);
|
|
380
417
|
|
|
381
418
|
const shouldAwait = awaitHydration ?? Boolean(persistKey && storage);
|
|
382
419
|
const isGated = shouldAwait && !hydrated;
|
|
383
420
|
|
|
384
|
-
//
|
|
385
|
-
//
|
|
386
|
-
//
|
|
387
|
-
// `document.documentElement` via `applyColorPresetVars`, so it's unused there.
|
|
421
|
+
// On native, the same record is handed to `VariableContextProvider` so
|
|
422
|
+
// descendants resolve `var(--primary)` etc. through react-native-css's real
|
|
423
|
+
// VariableContext. Web writes them to `document.documentElement` above.
|
|
388
424
|
const nativeVars = useMemo(
|
|
389
|
-
() => (Platform.OS === 'web' ? null :
|
|
390
|
-
[
|
|
425
|
+
() => (Platform.OS === 'web' ? null : themeVars),
|
|
426
|
+
[themeVars],
|
|
391
427
|
);
|
|
392
428
|
const VariableProvider = getVariableContextProvider();
|
|
393
429
|
|
|
@@ -26,18 +26,25 @@ export function applyDarkClass(resolved: 'light' | 'dark') {
|
|
|
26
26
|
* Includes extended tokens (card, chart-*, content-area, sidebar-*) so consumer
|
|
27
27
|
* apps don't need to synthesize them.
|
|
28
28
|
*/
|
|
29
|
+
/**
|
|
30
|
+
* Write a pre-computed `--x -> value` record to the document root (web only).
|
|
31
|
+
* The single web writer primitive: both the preset path (`applyColorPresetVars`)
|
|
32
|
+
* and `BloomThemeProvider`'s dynamic-seed path feed their already-resolved vars
|
|
33
|
+
* through here, so the "write to document" logic lives in exactly one place.
|
|
34
|
+
*/
|
|
35
|
+
export function applyVarsToDocument(vars: Record<string, string>) {
|
|
36
|
+
if (Platform.OS !== 'web' || typeof document === 'undefined') return;
|
|
37
|
+
const root = document.documentElement.style;
|
|
38
|
+
for (const [key, value] of Object.entries(vars)) {
|
|
39
|
+
root.setProperty(key, value);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
29
43
|
export function applyColorPresetVars(
|
|
30
44
|
preset: AppColorName,
|
|
31
45
|
resolved: 'light' | 'dark',
|
|
32
46
|
accents?: ExplicitAccents,
|
|
33
47
|
) {
|
|
34
|
-
if (Platform.OS !== 'web' || typeof document === 'undefined') return;
|
|
35
48
|
if (!APP_COLOR_PRESETS[preset]) return;
|
|
36
|
-
|
|
37
|
-
const vars = getResolvedTokens(preset, resolved, accents);
|
|
38
|
-
const root = document.documentElement.style;
|
|
39
|
-
|
|
40
|
-
for (const [key, value] of Object.entries(vars)) {
|
|
41
|
-
root.setProperty(key, value);
|
|
42
|
-
}
|
|
49
|
+
applyVarsToDocument(getResolvedTokens(preset, resolved, accents));
|
|
43
50
|
}
|
|
@@ -122,17 +122,26 @@ import { getResolvedTokens } from './token-registry';
|
|
|
122
122
|
* Defensive guard: if a host ships a react-native-css build that doesn't expose
|
|
123
123
|
* `rootVariables` as a callable (it always does on @3), we bail rather than throw.
|
|
124
124
|
*/
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Write a pre-computed `--x -> value` record into react-native-css's global
|
|
127
|
+
* `rootVariables` family. The single native writer primitive: both the preset
|
|
128
|
+
* path (`applyNativeRootVars`) and `BloomThemeProvider`'s dynamic-seed path feed
|
|
129
|
+
* their already-resolved vars through here, so the global-write logic lives in
|
|
130
|
+
* exactly one place.
|
|
131
|
+
*/
|
|
132
|
+
export function applyVarsToRootVariables(vars: Record<string, string>): void {
|
|
130
133
|
if (typeof rootVariables !== 'function') return;
|
|
131
|
-
|
|
132
|
-
const vars = getResolvedTokens(colorPreset, mode, accents);
|
|
133
134
|
for (const [key, value] of Object.entries(vars)) {
|
|
134
|
-
// The family is keyed by the bare name;
|
|
135
|
+
// The family is keyed by the bare name; the var keys include `--`.
|
|
135
136
|
const name = key.startsWith('--') ? key.slice(2) : key;
|
|
136
137
|
rootVariables(name).set([[value]]);
|
|
137
138
|
}
|
|
138
139
|
}
|
|
140
|
+
|
|
141
|
+
export function applyNativeRootVars(
|
|
142
|
+
colorPreset: AppColorName,
|
|
143
|
+
mode: 'light' | 'dark',
|
|
144
|
+
accents?: ExplicitAccents,
|
|
145
|
+
): void {
|
|
146
|
+
applyVarsToRootVariables(getResolvedTokens(colorPreset, mode, accents));
|
|
147
|
+
}
|
|
@@ -31,6 +31,11 @@ import type { ExplicitAccents } from './preset-vars';
|
|
|
31
31
|
* The signature is intentionally identical to those variants so the import site in
|
|
32
32
|
* `BloomThemeProvider` is platform-agnostic.
|
|
33
33
|
*/
|
|
34
|
+
/** Neutral-default no-op of the native root-vars writer primitive. */
|
|
35
|
+
export function applyVarsToRootVariables(_vars: Record<string, string>): void {
|
|
36
|
+
// Intentionally empty — the native variant does the real work.
|
|
37
|
+
}
|
|
38
|
+
|
|
34
39
|
export function applyNativeRootVars(
|
|
35
40
|
_colorPreset: AppColorName,
|
|
36
41
|
_mode: 'light' | 'dark',
|
|
@@ -18,6 +18,11 @@ import type { ExplicitAccents } from './preset-vars';
|
|
|
18
18
|
* The signature is intentionally identical to the plain variant so the import
|
|
19
19
|
* site in `BloomThemeProvider` is platform-agnostic.
|
|
20
20
|
*/
|
|
21
|
+
/** Web no-op of the native root-vars writer primitive (web writes to the document). */
|
|
22
|
+
export function applyVarsToRootVariables(_vars: Record<string, string>): void {
|
|
23
|
+
// Intentionally empty — web applies vars to `document.documentElement`.
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
export function applyNativeRootVars(
|
|
22
27
|
_colorPreset: AppColorName,
|
|
23
28
|
_mode: 'light' | 'dark',
|