@tamagui/web 3.0.12 → 3.0.14
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/dist/cjs/_withNativeStyle.cjs +7 -5
- package/dist/cjs/_withNativeStyle.native.cjs +8 -5
- package/dist/cjs/_withNativeStyle.native.js +8 -5
- package/dist/cjs/_withNativeStyle.native.js.map +1 -1
- package/dist/cjs/helpers/getSplitStyles.cjs +3 -2
- package/dist/cjs/helpers/getSplitStyles.native.cjs +5 -3
- package/dist/cjs/helpers/getSplitStyles.native.js +5 -3
- package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/cjs/helpers/styledDynamic.cjs +1 -4
- package/dist/cjs/helpers/styledDynamic.native.cjs +2 -4
- package/dist/cjs/helpers/styledDynamic.native.js +2 -4
- package/dist/cjs/helpers/styledDynamic.native.js.map +1 -1
- package/dist/cjs/hooks/useThemeState.cjs +12 -5
- package/dist/cjs/hooks/useThemeState.native.cjs +16 -5
- package/dist/cjs/hooks/useThemeState.native.js +16 -5
- package/dist/cjs/hooks/useThemeState.native.js.map +1 -1
- package/dist/esm/_withNativeStyle.mjs +8 -6
- package/dist/esm/_withNativeStyle.mjs.map +1 -1
- package/dist/esm/_withNativeStyle.native.js +9 -6
- package/dist/esm/_withNativeStyle.native.js.map +1 -1
- package/dist/esm/helpers/getSplitStyles.mjs +3 -2
- package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
- package/dist/esm/helpers/getSplitStyles.native.js +5 -3
- package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/esm/helpers/styledDynamic.mjs +1 -4
- package/dist/esm/helpers/styledDynamic.mjs.map +1 -1
- package/dist/esm/helpers/styledDynamic.native.js +2 -4
- package/dist/esm/helpers/styledDynamic.native.js.map +1 -1
- package/dist/esm/hooks/useThemeState.mjs +12 -6
- package/dist/esm/hooks/useThemeState.mjs.map +1 -1
- package/dist/esm/hooks/useThemeState.native.js +16 -6
- package/dist/esm/hooks/useThemeState.native.js.map +1 -1
- package/package.json +17 -17
- package/src/_withNativeStyle.tsx +14 -7
- package/src/helpers/getSplitStyles.tsx +8 -3
- package/src/helpers/styledDynamic.ts +3 -5
- package/src/hooks/useThemeState.ts +17 -6
- package/types/_withNativeStyle.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/styledDynamic.d.ts +3 -1
- package/types/helpers/styledDynamic.d.ts.map +1 -1
- package/types/hooks/useThemeState.d.ts +1 -0
- package/types/hooks/useThemeState.d.ts.map +1 -1
|
@@ -3,15 +3,12 @@ import { getVariableValue } from "../createVariable.mjs";
|
|
|
3
3
|
import { defaultSizing } from "./resolveSizing.mjs";
|
|
4
4
|
import { styledDynamicSymbol } from "../types.mjs";
|
|
5
5
|
|
|
6
|
-
const fontLanguageCache = /* @__PURE__ */ new WeakMap();
|
|
7
6
|
function getFontsForLanguage(fonts, language) {
|
|
8
|
-
if (fontLanguageCache.has(language)) return fontLanguageCache.get(language);
|
|
9
7
|
const next = { ...fonts };
|
|
10
8
|
for (const name in language) {
|
|
11
9
|
const lang = language[name];
|
|
12
|
-
if (lang !== "default") next[name] = fonts[`${name}_${lang}`];
|
|
10
|
+
if (lang !== "default") next[name] = fonts[`${name}_${lang}`] ?? fonts[name];
|
|
13
11
|
}
|
|
14
|
-
fontLanguageCache.set(language, next);
|
|
15
12
|
return next;
|
|
16
13
|
}
|
|
17
14
|
function isStyledDynamic(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styledDynamic.js","names":[],"sources":["esm/helpers/styledDynamic.js"],"sourcesContent":["import { getSetting } from \"../config\";\nimport { getVariableValue } from \"../createVariable\";\nimport { defaultSizing } from \"./resolveSizing\";\nimport { styledDynamicSymbol } from \"../types\";\
|
|
1
|
+
{"version":3,"file":"styledDynamic.js","names":[],"sources":["esm/helpers/styledDynamic.js"],"sourcesContent":["import { getSetting } from \"../config\";\nimport { getVariableValue } from \"../createVariable\";\nimport { defaultSizing } from \"./resolveSizing\";\nimport { styledDynamicSymbol } from \"../types\";\nfunction getFontsForLanguage(fonts, language) {\n const next = { ...fonts };\n for (const name in language) {\n const lang = language[name];\n if (lang !== \"default\") next[name] = fonts[`${name}_${lang}`] ?? fonts[name];\n }\n return next;\n}\nfunction isStyledDynamic(value) {\n return !!value && (typeof value === \"function\" || typeof value === \"object\") && styledDynamicSymbol in value;\n}\nconst bareStyledDynamic = { [styledDynamicSymbol]: true };\nconst dynamicSpreadProbe = /* @__PURE__ */ Symbol(\"tamagui.dynamicSpreadProbe\");\nconst dynamicComputedProbe = \"__tamagui_dynamic_computed_key__\";\nconst dynamicComputedNumberProbe = 712367821;\nconst dynamicShapeProbeValues = /* @__PURE__ */ new WeakSet();\nfunction createDynamicShapeProbe() {\n const target = function() {\n };\n let probe;\n probe = new Proxy(target, {\n apply: () => probe,\n construct: () => probe,\n get: (_target, key) => {\n if (key === Symbol.toPrimitive) {\n return (hint) => hint === \"number\" ? dynamicComputedNumberProbe : dynamicComputedProbe;\n }\n if (key === Symbol.iterator) {\n return function* () {\n yield dynamicComputedProbe;\n };\n }\n if (key === dynamicSpreadProbe) return true;\n return probe;\n },\n getOwnPropertyDescriptor: (target2, key) => key === dynamicSpreadProbe ? { configurable: true, enumerable: true, value: true } : Reflect.getOwnPropertyDescriptor(target2, key),\n ownKeys: (target2) => [...Reflect.ownKeys(target2), dynamicSpreadProbe]\n });\n dynamicShapeProbeValues.add(probe);\n return probe;\n}\nfunction findDynamicShapeViolation(value) {\n if (!value || typeof value !== \"object\" && typeof value !== \"function\") return;\n const seen = /* @__PURE__ */ new WeakSet();\n let spread = false;\n let computed = false;\n const visit = (current) => {\n if (dynamicShapeProbeValues.has(current) || seen.has(current)) return;\n seen.add(current);\n let descriptors;\n try {\n descriptors = Object.getOwnPropertyDescriptors(current);\n } catch {\n return;\n }\n for (const key of Reflect.ownKeys(descriptors)) {\n if (key === dynamicSpreadProbe) spread = true;\n if (typeof key === \"string\" && (key.includes(dynamicComputedProbe) || key === String(dynamicComputedNumberProbe))) {\n computed = true;\n }\n const nested = descriptors[key]?.value;\n if (nested && (typeof nested === \"object\" || typeof nested === \"function\")) {\n visit(nested);\n }\n }\n };\n visit(value);\n if (spread || computed) return { spread, computed };\n}\nfunction validateDynamicShape(fn) {\n try {\n const probe = createDynamicShapeProbe();\n const warn = console.warn;\n let output;\n try {\n console.warn = () => {\n };\n output = fn(probe, probe);\n } finally {\n console.warn = warn;\n }\n const violation = findDynamicShapeViolation(output);\n if (!violation) return;\n const reasons = [\n violation.spread ? \"a spread from a dynamic input\" : \"\",\n violation.computed ? \"a computed key from a dynamic input\" : \"\"\n ].filter(Boolean);\n console.warn(\n `[tamagui] styled.dynamic${fn.name ? ` (${fn.name})` : \"\"} returned ${reasons.join(\" and \")} during its development shape check. Dynamic style bodies require static object keys for extraction; this definition will deopt instead.`\n );\n } catch {\n }\n}\nfunction styledDynamic(fn) {\n if (!fn) return bareStyledDynamic;\n if (process.env.NODE_ENV === \"development\") validateDynamicShape(fn);\n fn[styledDynamicSymbol] = true;\n return fn;\n}\nfunction getDynamicEnv(styleState) {\n const cached = styleState.flatDynamicEnv;\n if (cached) return cached;\n const { props, conf, context, theme } = styleState;\n let fonts = conf.fontsParsed;\n if (context?.language) {\n fonts = getFontsForLanguage(conf.fontsParsed, context.language);\n }\n const next = {\n fonts,\n tokens: conf.tokensParsed,\n theme,\n sizing: { ...defaultSizing, ...conf.sizing },\n get fontFamily() {\n return getVariableValue(styleState.fontFamily || props.fontFamily) || props.fontFamily || getVariableValue(getSetting(\"defaultFont\"));\n },\n get font() {\n const found = fonts[this.fontFamily];\n if (found) return found;\n const className = props.className;\n if (typeof className === \"string\") {\n const name = /(?:^|\\s)font_(\\S+)/.exec(className)?.[1];\n if (name && fonts[name]) return fonts[name];\n }\n return fonts[conf.defaultFontToken];\n }\n };\n return styleState.flatDynamicEnv = next;\n}\nexport {\n getDynamicEnv,\n getFontsForLanguage,\n isStyledDynam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CAC1B,OAAO;AACT;AACA,SAAS,cAAc,YAAY;CACjC,MAAM,SAAS,WAAW;CAC1B,IAAI,QAAQ,OAAO;CACnB,MAAM,EAAE,OAAO,MAAM,SAAS,UAAU;CACxC,IAAI,QAAQ,KAAK;CACjB,IAAI,SAAS,UAAU;EACrB,QAAQ,oBAAoB,KAAK,aAAa,QAAQ,QAAQ;CAChE;CACA,MAAM,OAAO;EACX;EACA,QAAQ,KAAK;EACb;EACA,QAAQ;GAAE,GAAG;GAAe,GAAG,KAAK;EAAO;EAC3C,IAAI,aAAa;GACf,OAAO,iBAAiB,WAAW,cAAc,MAAM,UAAU,KAAK,MAAM,cAAc,iBAAiB,WAAW,aAAa,CAAC;EACtI;EACA,IAAI,OAAO;GACT,MAAM,QAAQ,MAAM,KAAK;GACzB,IAAI,OAAO,OAAO;GAClB,MAAM,YAAY,MAAM;GACxB,IAAI,OAAO,cAAc,UAAU;IACjC,MAAM,OAAO,qBAAqB,KAAK,SAAS,CAAC,GAAG;IACpD,IAAI,QAAQ,MAAM,OAAO,OAAO,MAAM;GACxC;GACA,OAAO,MAAM,KAAK;EACpB;CACF;CACA,OAAO,WAAW,iBAAiB;AACrC"}
|
|
@@ -3,15 +3,13 @@ import { getVariableValue } from "../createVariable.native.js";
|
|
|
3
3
|
import { defaultSizing } from "./resolveSizing.native.js";
|
|
4
4
|
import { styledDynamicSymbol } from "../types.native.js";
|
|
5
5
|
|
|
6
|
-
var fontLanguageCache = /* @__PURE__ */ new WeakMap();
|
|
7
6
|
function getFontsForLanguage(fonts, language) {
|
|
8
|
-
if (fontLanguageCache.has(language)) return fontLanguageCache.get(language);
|
|
9
7
|
var next = { ...fonts };
|
|
10
8
|
for (var name in language) {
|
|
9
|
+
var _fonts_;
|
|
11
10
|
var lang = language[name];
|
|
12
|
-
if (lang !== "default") next[name] = fonts[`${name}_${lang}`];
|
|
11
|
+
if (lang !== "default") next[name] = (_fonts_ = fonts[`${name}_${lang}`]) !== null && _fonts_ !== void 0 ? _fonts_ : fonts[name];
|
|
13
12
|
}
|
|
14
|
-
fontLanguageCache.set(language, next);
|
|
15
13
|
return next;
|
|
16
14
|
}
|
|
17
15
|
function isStyledDynamic(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styledDynamic.native.js","names":[],"sources":["esm/helpers/styledDynamic.native.js"],"sourcesContent":["import { getSetting } from \"../config\";\nimport { getVariableValue } from \"../createVariable\";\nimport { defaultSizing } from \"./resolveSizing\";\nimport { styledDynamicSymbol } from \"../types\";\
|
|
1
|
+
{"version":3,"file":"styledDynamic.native.js","names":[],"sources":["esm/helpers/styledDynamic.native.js"],"sourcesContent":["import { getSetting } from \"../config\";\nimport { getVariableValue } from \"../createVariable\";\nimport { defaultSizing } from \"./resolveSizing\";\nimport { styledDynamicSymbol } from \"../types\";\nfunction getFontsForLanguage(fonts, language) {\n var next = {\n ...fonts\n };\n for (var name in language) {\n var _fonts_;\n var lang = language[name];\n if (lang !== \"default\") next[name] = (_fonts_ = fonts[`${name}_${lang}`]) !== null && _fonts_ !== void 0 ? _fonts_ : fonts[name];\n }\n return next;\n}\nfunction isStyledDynamic(value) {\n return !!value && (typeof value === \"function\" || typeof value === \"object\") && styledDynamicSymbol in value;\n}\nvar bareStyledDynamic = {\n [styledDynamicSymbol]: true\n};\nvar dynamicSpreadProbe = /* @__PURE__ */ Symbol(\"tamagui.dynamicSpreadProbe\");\nvar dynamicComputedProbe = \"__tamagui_dynamic_computed_key__\";\nvar dynamicComputedNumberProbe = 712367821;\nvar dynamicShapeProbeValues = /* @__PURE__ */ new WeakSet();\nfunction createDynamicShapeProbe() {\n var target = function target2() {\n };\n var probe;\n probe = new Proxy(target, {\n apply: function apply() {\n return probe;\n },\n construct: function construct() {\n return probe;\n },\n get: function get(_target, key) {\n if (key === Symbol.toPrimitive) {\n return function(hint) {\n return hint === \"number\" ? dynamicComputedNumberProbe : dynamicComputedProbe;\n };\n }\n if (key === Symbol.iterator) {\n return function* () {\n yield dynamicComputedProbe;\n };\n }\n if (key === dynamicSpreadProbe) return true;\n return probe;\n },\n getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target2, key) {\n return key === dynamicSpreadProbe ? {\n configurable: true,\n enumerable: true,\n value: true\n } : Reflect.getOwnPropertyDescriptor(target2, key);\n },\n ownKeys: function ownKeys(target2) {\n return [\n ...Reflect.ownKeys(target2),\n dynamicSpreadProbe\n ];\n }\n });\n dynamicShapeProbeValues.add(probe);\n return probe;\n}\nfunction findDynamicShapeViolation(value) {\n if (!value || typeof value !== \"object\" && typeof value !== \"function\") return;\n var seen = /* @__PURE__ */ new WeakSet();\n var spread = false;\n var computed = false;\n var visit = function visit1(current) {\n if (dynamicShapeProbeValues.has(current) || seen.has(current)) return;\n seen.add(current);\n var descriptors;\n try {\n descriptors = Object.getOwnPropertyDescriptors(current);\n } catch (unused) {\n return;\n }\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = Reflect.ownKeys(descriptors)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var key = _step.value;\n var _descriptors_key;\n if (key === dynamicSpreadProbe) spread = true;\n if (typeof key === \"string\" && (key.includes(dynamicComputedProbe) || key === String(dynamicComputedNumberProbe))) {\n computed = true;\n }\n var nested = (_descriptors_key = descriptors[key]) === null || _descriptors_key === void 0 ? void 0 : _descriptors_key.value;\n if (nested && (typeof nested === \"object\" || typeof nested === \"function\")) {\n visit(nested);\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n };\n visit(value);\n if (spread || computed) return {\n spread,\n computed\n };\n}\nfunction validateDynamicShape(fn) {\n try {\n var probe = createDynamicShapeProbe();\n var warn = console.warn;\n var output;\n try {\n console.warn = function() {\n };\n output = fn(probe, probe);\n } finally {\n console.warn = warn;\n }\n var violation = findDynamicShapeViolation(output);\n if (!violation) return;\n var reasons = [\n violation.spread ? \"a spread from a dynamic input\" : \"\",\n violation.computed ? \"a computed key from a dynamic input\" : \"\"\n ].filter(Boolean);\n console.warn(`[tamagui] styled.dynamic${fn.name ? ` (${fn.name})` : \"\"} returned ${reasons.join(\" and \")} during its development shape check. Dynamic style bodies require static object keys for extraction; this definition will deopt instead.`);\n } catch (unused) {\n }\n}\nfunction styledDynamic(fn) {\n if (!fn) return bareStyledDynamic;\n if (process.env.NODE_ENV === \"development\") validateDynamicShape(fn);\n fn[styledDynamicSymbol] = true;\n return fn;\n}\nfunction getDynamicEnv(styleState) {\n var cached = styleState.flatDynamicEnv;\n if (cached) return cached;\n var { props, conf, context, theme } = styleState;\n var fonts = conf.fontsParsed;\n if (context === null || context === void 0 ? void 0 : context.language) {\n fonts = getFontsForLanguage(conf.fontsParsed, context.language);\n }\n var next = {\n fonts,\n tokens: conf.tokensParsed,\n theme,\n sizing: {\n ...defaultSizing,\n ...conf.sizing\n },\n get fontFamily() {\n return getVariableValue(styleState.fontFamily || props.fontFamily) || props.fontFamily || getVariableValue(getSetting(\"defaultFont\"));\n },\n get font() {\n var found = fonts[this.fontFamily];\n if (found) return found;\n var className = props.className;\n if (typeof className === \"string\") {\n var _exec;\n var name = (_exec = /(?:^|\\s)font_(\\S+)/.exec(className)) === null || _exec === void 0 ? void 0 : _exec[1];\n if (name && fonts[name]) return fonts[name];\n }\n return fonts[conf.defaultFontToken];\n }\n };\n return styleState.flatDynamicEnv = next;\n}\nexport {\n getDynamicEnv,\n getFontsForLanguage,\n isStyledDynamic,\n styledDynamic\n};\n//# sourceMappingURL=styledDynamic.js.map\n"],"mappings":";;;;;;AAIA,SAAS,oBAAoB,OAAO,UAAU;CAC5C,IAAI,OAAO,EACT,GAAG,MACL;CACA,KAAK,IAAI,QAAQ,UAAU;EACzB,IAAI;EACJ,IAAI,OAAO,SAAS;EACpB,IAAI,SAAS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AAO,MAAM,KAAK;EACpB;CACF;CACA,OAAO,WAAW,iBAAiB;AACrC"}
|
|
@@ -23,13 +23,19 @@ const getThemeState = (id) => states.get(id);
|
|
|
23
23
|
const themeUpdateLayers = /* @__PURE__ */ new Map();
|
|
24
24
|
const themeProviderParents = /* @__PURE__ */ new Map();
|
|
25
25
|
const getThemeUpdateLayer = (id) => themeUpdateLayers.get(id);
|
|
26
|
-
const getThemeProviderParent = (id) => themeProviderParents.get(id);
|
|
26
|
+
const getThemeProviderParent = (id) => themeProviderParents.get(id)?.parentId;
|
|
27
|
+
const getThemeProviderScope = (id) => themeProviderParents.get(id)?.keys;
|
|
27
28
|
const getThemeProviderChainSizes = () => ({
|
|
28
29
|
layers: themeUpdateLayers.size,
|
|
29
30
|
parents: themeProviderParents.size
|
|
30
31
|
});
|
|
31
|
-
const registerThemeProviderChain = (id, parentId, props) => {
|
|
32
|
-
themeProviderParents.
|
|
32
|
+
const registerThemeProviderChain = (id, parentId, props, keys) => {
|
|
33
|
+
const scope = themeProviderParents.get(id);
|
|
34
|
+
if (scope) scope.parentId = parentId;
|
|
35
|
+
else themeProviderParents.set(id, {
|
|
36
|
+
parentId,
|
|
37
|
+
keys
|
|
38
|
+
});
|
|
33
39
|
if (props._themeUpdate) themeUpdateLayers.set(id, props._themeUpdate);
|
|
34
40
|
else themeUpdateLayers.delete(id);
|
|
35
41
|
};
|
|
@@ -54,7 +60,7 @@ Looked for theme${props.name ? ` "${props.name}"` : ""}, but no parent theme con
|
|
|
54
60
|
};
|
|
55
61
|
const id = useId();
|
|
56
62
|
const propsKey = `${props.name || ""}${props.forceClassName || ""}${props._themeUpdate?.key || ""}`;
|
|
57
|
-
if (cascadeOnChange) registerThemeProviderChain(id, parentId, props);
|
|
63
|
+
if (cascadeOnChange) registerThemeProviderChain(id, parentId, props, keys);
|
|
58
64
|
const ref = useRef(null);
|
|
59
65
|
const r = ref.current ||= {
|
|
60
66
|
id,
|
|
@@ -76,7 +82,7 @@ Looked for theme${props.name ? ` "${props.name}"` : ""}, but no parent theme con
|
|
|
76
82
|
states.set(r.id, r.lastSnap);
|
|
77
83
|
r.state = r.lastSnap;
|
|
78
84
|
}
|
|
79
|
-
if (cascadeOnChange && !themeProviderParents.has(r.id)) registerThemeProviderChain(r.id, r.parentId, r.props);
|
|
85
|
+
if (cascadeOnChange && !themeProviderParents.has(r.id)) registerThemeProviderChain(r.id, r.parentId, r.props, r.keys);
|
|
80
86
|
if (r.unsubscribe && r.subscribedTo !== r.parentId) r.unsubscribe?.();
|
|
81
87
|
if (shouldSubscribeToTheme(r, cascadeOnChange)) {
|
|
82
88
|
if (!r.unsubscribe) {
|
|
@@ -272,5 +278,5 @@ function resolveThemeName(parentName, name, themes2, forceUpdate = false) {
|
|
|
272
278
|
}
|
|
273
279
|
const hasThemeUpdatingProps = (props) => "name" in props || "forceClassName" in props || "_themeUpdate" in props;
|
|
274
280
|
|
|
275
|
-
export { ThemeStateContext, forceUpdateThemes, getNewThemeName, getRootThemeState, getThemeNameCacheSize, getThemeProviderChainSizes, getThemeProviderParent, getThemeState, getThemeUpdateLayer, hasThemeUpdatingProps, resolveThemeName, useThemeState };
|
|
281
|
+
export { ThemeStateContext, forceUpdateThemes, getNewThemeName, getRootThemeState, getThemeNameCacheSize, getThemeProviderChainSizes, getThemeProviderParent, getThemeProviderScope, getThemeState, getThemeUpdateLayer, hasThemeUpdatingProps, resolveThemeName, useThemeState };
|
|
276
282
|
//# sourceMappingURL=useThemeState.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useThemeState.js","names":[],"sources":["esm/hooks/useThemeState.js"],"sourcesContent":["import { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createContext, useContext, useEffect, useId, useReducer, useRef } from \"react\";\nimport { getThemeScheme } from \"@tamagui/helpers\";\nimport { getConfig } from \"../config\";\nimport { MISSING_THEME_MESSAGE } from \"../constants/constants\";\nimport { getAuthoredThemeScheme } from \"../helpers/themes\";\n\nconst ThemeStateContext = createContext(\"\");\nconst allListeners = /* @__PURE__ */ new Map();\nconst listenersByParent = {};\nconst HasRenderedOnce = /* @__PURE__ */ new WeakMap();\nconst HadTheme = /* @__PURE__ */ new WeakMap();\nconst PendingUpdate = /* @__PURE__ */ new Map();\nconst states = /* @__PURE__ */ new Map();\nlet shouldForce = false;\nconst forceUpdateThemes = () => {\n\tcacheVersion++;\n\tshouldForce = true;\n\tallListeners.forEach((cb) => cb());\n\tshouldForce = false;\n};\nconst getThemeState = (id) => states.get(id);\nconst themeUpdateLayers = /* @__PURE__ */ new Map();\nconst themeProviderParents = /* @__PURE__ */ new Map();\nconst getThemeUpdateLayer = (id) => themeUpdateLayers.get(id);\nconst getThemeProviderParent = (id) => themeProviderParents.get(id);\nconst getThemeProviderChainSizes = () => ({\n\tlayers: themeUpdateLayers.size,\n\tparents: themeProviderParents.size\n});\nconst registerThemeProviderChain = (id, parentId, props) => {\n\tthemeProviderParents.set(id, parentId);\n\tif (props._themeUpdate) themeUpdateLayers.set(id, props._themeUpdate);\n\telse themeUpdateLayers.delete(id);\n};\nlet cacheVersion = 0;\nconst themeNameCache = /* @__PURE__ */ new Map();\nlet themeNameCacheVer = -1;\nlet themes = null;\nlet rootThemeState = null;\nconst getRootThemeState = () => rootThemeState;\nconst incReducer = (c) => c + 1;\nconst useThemeState = (props, isRoot = false, keys, schemeKeys, cascadeOnChange = false, optimizeForFirstRender = false) => {\n\t\"use no memo\";\n\tconst { disable } = props;\n\tconst parentId = useContext(ThemeStateContext);\n\tif (!parentId && !isRoot) throw new Error(process.env.NODE_ENV === \"development\" ? `${MISSING_THEME_MESSAGE}\n\nLooked for theme${props.name ? ` \"${props.name}\"` : \"\"}, but no parent theme context was found (parentId: ${parentId}).` : MISSING_THEME_MESSAGE);\n\tif (disable) return states.get(parentId) || {\n\t\tid: \"\",\n\t\tname: \"light\",\n\t\ttheme: getConfig().themes.light\n\t};\n\tconst id = useId();\n\tconst propsKey = `${props.name || \"\"}${props.forceClassName || \"\"}${props._themeUpdate?.key || \"\"}`;\n\tif (cascadeOnChange) registerThemeProviderChain(id, parentId, props);\n\tconst ref = useRef(null);\n\tconst r = ref.current ||= {\n\t\tid,\n\t\toptimizeForFirstRender,\n\t\trenderVersion: 0\n\t};\n\tr.props = props;\n\tr.propsKey = propsKey;\n\tr.isRoot = isRoot;\n\tr.keys = keys;\n\tr.parentId = parentId;\n\tr.renderVersion++;\n\tconst [, forceUpdate] = useReducer(incReducer, 0);\n\tconst state = getSnapshotImpl(r);\n\tr.lastSnap = state;\n\tuseEffect(() => {\n\t\tconst renderVersion = r.renderVersion;\n\t\tif (r.lastSnap && !states.has(r.id)) {\n\t\t\tstates.set(r.id, r.lastSnap);\n\t\t\tr.state = r.lastSnap;\n\t\t}\n\t\tif (cascadeOnChange && !themeProviderParents.has(r.id)) registerThemeProviderChain(r.id, r.parentId, r.props);\n\t\tif (r.unsubscribe && r.subscribedTo !== r.parentId) r.unsubscribe?.();\n\t\tif (shouldSubscribeToTheme(r, cascadeOnChange)) {\n\t\t\tif (!r.unsubscribe) {\n\t\t\t\tconst pid = r.parentId;\n\t\t\t\tconst sid = r.id;\n\t\t\t\tconst cb = (forced) => {\n\t\t\t\t\tconst next = getSnapshotImpl(r);\n\t\t\t\t\tif (next !== r.lastSnap) {\n\t\t\t\t\t\tr.lastSnap = next;\n\t\t\t\t\t\tif (!forced && r.props.nativeUpdate?.(next)) return;\n\t\t\t\t\t\tforceUpdate();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\t(listenersByParent[pid] ||= /* @__PURE__ */ new Set()).add(sid);\n\t\t\t\tallListeners.set(sid, () => {\n\t\t\t\t\tconst forced = shouldForce;\n\t\t\t\t\tPendingUpdate.set(sid, forced ? \"force\" : true);\n\t\t\t\t\tcb(forced);\n\t\t\t\t});\n\t\t\t\tr.subscribedTo = pid;\n\t\t\t\tr.unsubscribe = () => {\n\t\t\t\t\tallListeners.delete(sid);\n\t\t\t\t\tlistenersByParent[pid]?.delete(sid);\n\t\t\t\t\tr.state = void 0;\n\t\t\t\t\tstates.delete(sid);\n\t\t\t\t\tPendingUpdate.delete(sid);\n\t\t\t\t\tr.unsubscribe = void 0;\n\t\t\t\t\tr.subscribedTo = void 0;\n\t\t\t\t};\n\t\t\t}\n\t\t} else if (r.unsubscribe) r.unsubscribe?.();\n\t\treturn () => {\n\t\t\tif (r.renderVersion === renderVersion) cleanupThemeState(r);\n\t\t};\n\t});\n\tif (cascadeOnChange) useIsomorphicLayoutEffect(() => {\n\t\tif (!HasRenderedOnce.get(keys)) {\n\t\t\tHasRenderedOnce.set(keys, true);\n\t\t\treturn;\n\t\t}\n\t\tif (!propsKey) {\n\t\t\tif (HadTheme.get(keys)) scheduleUpdate(id);\n\t\t\tHadTheme.set(keys, false);\n\t\t\treturn;\n\t\t}\n\t\tscheduleUpdate(id);\n\t\tHadTheme.set(keys, true);\n\t}, [keys, propsKey]);\n\treturn state;\n};\nconst shouldSubscribeToTheme = (r, cascadeOnChange) => Boolean(r.optimizeForFirstRender || r.isRoot || cascadeOnChange || hasThemeUpdatingProps(r.props) || r.keys.current?.size || r.props.needsUpdate?.());\nfunction cleanupThemeState(r) {\n\tif (r.unsubscribe) r.unsubscribe();\n\telse {\n\t\tr.state = void 0;\n\t\tstates.delete(r.id);\n\t\tPendingUpdate.delete(r.id);\n\t}\n\tthemeUpdateLayers.delete(r.id);\n\tthemeProviderParents.delete(r.id);\n}\nconst getSnapshotImpl = (r) => {\n\tconst { id, parentId, props, propsKey, isRoot, keys, optimizeForFirstRender } = r;\n\tlet local = r.state;\n\tconst parentState = states.get(parentId);\n\tif (local && !PendingUpdate.has(id)) {\n\t\tif (parentState && local._parentName === parentState.name && local._parentSchemeAuthored === parentState.schemeAuthored && local._propsKey === propsKey) return local;\n\t}\n\tconst canSkipForSchemeChange = Boolean(!optimizeForFirstRender && false);\n\tconst needsUpdate = props.passThrough ? false : optimizeForFirstRender ? true : isRoot || props.forceClassName || props.name === \"light\" || props.name === \"dark\" || props.name === null ? true : !HasRenderedOnce.get(keys) ? true : canSkipForSchemeChange ? false : keys?.current?.size ? true : props.needsUpdate?.();\n\tconst [rerender, nextRaw] = getNextState(local, props, propsKey, isRoot, id, parentId, needsUpdate, PendingUpdate.get(id));\n\tlet next = nextRaw;\n\tif (props._themeUpdate && nextRaw?.theme) {\n\t\tconst parentTheme = states.get(parentId)?.theme || nextRaw.theme;\n\t\tconst merged = props._themeUpdate.getTheme(parentTheme, nextRaw.name, getConfig());\n\t\tif (merged !== nextRaw.theme) next = {\n\t\t\t...nextRaw,\n\t\t\ttheme: merged\n\t\t};\n\t}\n\tPendingUpdate.delete(id);\n\tif (!local || rerender) {\n\t\tlocal = { ...next };\n\t\tr.state = local;\n\t}\n\tif (next !== local) {\n\t\tObject.assign(local, next);\n\t\tlocal.id = id;\n\t}\n\tlocal._parentName = parentState?.name;\n\tlocal._parentSchemeAuthored = parentState?.schemeAuthored;\n\tlocal._propsKey = propsKey;\n\tstates.set(id, next);\n\treturn local;\n};\nconst getNextState = (lastState, props, propsKey, isRoot = false, id, parentId, needsUpdate, pendingUpdate) => {\n\tconst parentState = states.get(parentId);\n\tif (props.passThrough) return [false, parentState || lastState || { name: \"\" }];\n\tthemes ||= getConfig().themes;\n\tconst name = !propsKey && (!lastState || !lastState.isNew) ? null : getNewThemeName(parentState?.name, props, pendingUpdate === \"force\" ? true : !!needsUpdate);\n\tconst authoredName = props.name;\n\tconst parentSchemeAuthored = !!parentState?.schemeAuthored;\n\tconst schemeAuthored = isRoot ? !!props.forceClassName : parentSchemeAuthored || !!(authoredName && getThemeScheme(authoredName) && authoredName in themes);\n\tconst intentChanged = schemeAuthored !== parentSchemeAuthored;\n\tconst resolvedName = name || parentState?.name;\n\tconst sameAsLast = lastState && lastState.name === resolvedName && !!lastState.schemeAuthored === schemeAuthored;\n\tconst isSameAsParent = Boolean(parentState && resolvedName === parentState.name && !intentChanged);\n\tconst shouldRerender = Boolean(pendingUpdate === \"force\" || needsUpdate && (pendingUpdate || lastState?.name !== parentState?.name || !!lastState?.schemeAuthored !== schemeAuthored));\n\tif (isSameAsParent) {\n\t\tif (!shouldRerender && sameAsLast) return [false, lastState];\n\t\treturn [shouldRerender, {\n\t\t\t...parentState,\n\t\t\tisNew: false\n\t\t}];\n\t}\n\tif (!resolvedName) {\n\t\tconst next = lastState ?? parentState ?? rootThemeState ?? {\n\t\t\tid,\n\t\t\tname: \"light\",\n\t\t\ttheme: getConfig().themes.light\n\t\t};\n\t\tif (shouldRerender) return [true, { ...parentState || lastState || next }];\n\t\treturn [false, next];\n\t}\n\tconst scheme = getAuthoredThemeScheme(themes[resolvedName]) || getThemeScheme(resolvedName);\n\tconst parentInverses = parentState?.inverses ?? 0;\n\tconst isInverse = Boolean(parentState && scheme !== parentState.scheme);\n\tconst inverses = parentInverses + (isInverse ? 1 : 0);\n\tconst nextState = {\n\t\tid,\n\t\tname: resolvedName,\n\t\ttheme: themes[resolvedName],\n\t\tscheme,\n\t\tparentId,\n\t\tparentName: parentState?.name,\n\t\tinverses,\n\t\tisInverse,\n\t\tschemeAuthored,\n\t\tisNew: true\n\t};\n\tif (isRoot) rootThemeState = nextState;\n\treturn [pendingUpdate === \"force\" || !sameAsLast, nextState];\n};\nfunction scheduleUpdate(id) {\n\tconst queue = [id];\n\tconst visited = /* @__PURE__ */ new Set();\n\twhile (queue.length) {\n\t\tconst children = listenersByParent[queue.shift()];\n\t\tif (children) {\n\t\t\tfor (const childId of children) if (!visited.has(childId)) {\n\t\t\t\tvisited.add(childId);\n\t\t\t\tqueue.push(childId);\n\t\t\t}\n\t\t}\n\t}\n\tvisited.forEach((childId) => {\n\t\tallListeners.get(childId)?.();\n\t});\n}\nfunction getNewThemeName(parentName = \"\", props, forceUpdate = false) {\n\tconst { name } = props;\n\tconst cacheKey = `${parentName}|${name || \"\"}|${forceUpdate ? 1 : 0}`;\n\tif (themeNameCacheVer !== cacheVersion) {\n\t\tthemeNameCache.clear();\n\t\tthemeNameCacheVer = cacheVersion;\n\t} else {\n\t\tconst cached = themeNameCache.get(cacheKey);\n\t\tif (cached !== void 0) return cached;\n\t}\n\tconst result = resolveThemeName(parentName, name ?? void 0, getConfig().themes, forceUpdate);\n\tif (themeNameCache.size >= 1e4) themeNameCache.clear();\n\tthemeNameCache.set(cacheKey, result);\n\treturn result;\n}\nconst getThemeNameCacheSize = () => themeNameCache.size;\nfunction resolveThemeName(parentName, name, themes2, forceUpdate = false) {\n\tconst parentParts = parentName ? parentName.split(\"_\") : [];\n\tlet found = null;\n\tif (name) {\n\t\tconst nameHasScheme = getThemeScheme(name);\n\t\tif (nameHasScheme && name in themes2) found = name;\n\t\tif (!found && !nameHasScheme) for (let i = parentParts.length; i >= 0; i--) {\n\t\t\tconst base = parentParts.slice(0, i).join(\"_\");\n\t\t\tconst potential = base ? `${base}_${name}` : name;\n\t\t\tif (potential in themes2) {\n\t\t\t\tfound = potential;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tif (!forceUpdate && found === parentName && found !== \"light\" && found !== \"dark\") return null;\n\treturn found;\n}\nconst hasThemeUpdatingProps = (props) => \"name\" in props || \"forceClassName\" in props || \"_themeUpdate\" in props;\n\nexport { ThemeStateContext, forceUpdateThemes, getNewThemeName, getRootThemeState, getThemeNameCacheSize, getThemeProviderChainSizes, getThemeProviderParent, getThemeState, getThemeUpdateLayer, hasThemeUpdatingProps, resolveThemeName, useThemeState };"],"mappings":";;;;;;;;AAOA,MAAM,oBAAoB,cAAc,EAAE;AAC1C,MAAM,+BAA+B,IAAI,IAAI;AAC7C,MAAM,oBAAoB,CAAC;AAC3B,MAAM,kCAAkC,IAAI,QAAQ;AACpD,MAAM,2BAA2B,IAAI,QAAQ;AAC7C,MAAM,gCAAgC,IAAI,IAAI;AAC9C,MAAM,yBAAyB,IAAI,IAAI;AACvC,IAAI,cAAc;AAClB,MAAM,0BAA0B;CAC/B;CACA,cAAc;CACd,aAAa,SAAS,OAAO,GAAG,CAAC;CACjC,cAAc;AACf;AACA,MAAM,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AAC,CAAC,KAAK,GAAG;GAC7C,MAAM,YAAY,OAAO,GAAG,KAAK,GAAG,SAAS;GAC7C,IAAI,aAAa,SAAS;IACzB,QAAQ;IACR;GACD;EACD;CACD;CACA,IAAI,CAAC,eAAe,UAAU,cAAc,UAAU,WAAW,UAAU,QAAQ,OAAO;CAC1F,OAAO;AACR;AACA,MAAM,yBAAyB,UAAU,UAAU,SAAS,oBAAoB,SAAS,kBAAkB"}
|
|
1
|
+
{"version":3,"file":"useThemeState.js","names":[],"sources":["esm/hooks/useThemeState.js"],"sourcesContent":["import { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createContext, useContext, useEffect, useId, useReducer, useRef } from \"react\";\nimport { getThemeScheme } from \"@tamagui/helpers\";\nimport { getConfig } from \"../config\";\nimport { MISSING_THEME_MESSAGE } from \"../constants/constants\";\nimport { getAuthoredThemeScheme } from \"../helpers/themes\";\n\nconst ThemeStateContext = createContext(\"\");\nconst allListeners = /* @__PURE__ */ new Map();\nconst listenersByParent = {};\nconst HasRenderedOnce = /* @__PURE__ */ new WeakMap();\nconst HadTheme = /* @__PURE__ */ new WeakMap();\nconst PendingUpdate = /* @__PURE__ */ new Map();\nconst states = /* @__PURE__ */ new Map();\nlet shouldForce = false;\nconst forceUpdateThemes = () => {\n\tcacheVersion++;\n\tshouldForce = true;\n\tallListeners.forEach((cb) => cb());\n\tshouldForce = false;\n};\nconst getThemeState = (id) => states.get(id);\nconst themeUpdateLayers = /* @__PURE__ */ new Map();\nconst themeProviderParents = /* @__PURE__ */ new Map();\nconst getThemeUpdateLayer = (id) => themeUpdateLayers.get(id);\nconst getThemeProviderParent = (id) => themeProviderParents.get(id)?.parentId;\nconst getThemeProviderScope = (id) => themeProviderParents.get(id)?.keys;\nconst getThemeProviderChainSizes = () => ({\n\tlayers: themeUpdateLayers.size,\n\tparents: themeProviderParents.size\n});\nconst registerThemeProviderChain = (id, parentId, props, keys) => {\n\tconst scope = themeProviderParents.get(id);\n\tif (scope) scope.parentId = parentId;\n\telse themeProviderParents.set(id, {\n\t\tparentId,\n\t\tkeys\n\t});\n\tif (props._themeUpdate) themeUpdateLayers.set(id, props._themeUpdate);\n\telse themeUpdateLayers.delete(id);\n};\nlet cacheVersion = 0;\nconst themeNameCache = /* @__PURE__ */ new Map();\nlet themeNameCacheVer = -1;\nlet themes = null;\nlet rootThemeState = null;\nconst getRootThemeState = () => rootThemeState;\nconst incReducer = (c) => c + 1;\nconst useThemeState = (props, isRoot = false, keys, schemeKeys, cascadeOnChange = false, optimizeForFirstRender = false) => {\n\t\"use no memo\";\n\tconst { disable } = props;\n\tconst parentId = useContext(ThemeStateContext);\n\tif (!parentId && !isRoot) throw new Error(process.env.NODE_ENV === \"development\" ? `${MISSING_THEME_MESSAGE}\n\nLooked for theme${props.name ? ` \"${props.name}\"` : \"\"}, but no parent theme context was found (parentId: ${parentId}).` : MISSING_THEME_MESSAGE);\n\tif (disable) return states.get(parentId) || {\n\t\tid: \"\",\n\t\tname: \"light\",\n\t\ttheme: getConfig().themes.light\n\t};\n\tconst id = useId();\n\tconst propsKey = `${props.name || \"\"}${props.forceClassName || \"\"}${props._themeUpdate?.key || \"\"}`;\n\tif (cascadeOnChange) registerThemeProviderChain(id, parentId, props, keys);\n\tconst ref = useRef(null);\n\tconst r = ref.current ||= {\n\t\tid,\n\t\toptimizeForFirstRender,\n\t\trenderVersion: 0\n\t};\n\tr.props = props;\n\tr.propsKey = propsKey;\n\tr.isRoot = isRoot;\n\tr.keys = keys;\n\tr.parentId = parentId;\n\tr.renderVersion++;\n\tconst [, forceUpdate] = useReducer(incReducer, 0);\n\tconst state = getSnapshotImpl(r);\n\tr.lastSnap = state;\n\tuseEffect(() => {\n\t\tconst renderVersion = r.renderVersion;\n\t\tif (r.lastSnap && !states.has(r.id)) {\n\t\t\tstates.set(r.id, r.lastSnap);\n\t\t\tr.state = r.lastSnap;\n\t\t}\n\t\tif (cascadeOnChange && !themeProviderParents.has(r.id)) registerThemeProviderChain(r.id, r.parentId, r.props, r.keys);\n\t\tif (r.unsubscribe && r.subscribedTo !== r.parentId) r.unsubscribe?.();\n\t\tif (shouldSubscribeToTheme(r, cascadeOnChange)) {\n\t\t\tif (!r.unsubscribe) {\n\t\t\t\tconst pid = r.parentId;\n\t\t\t\tconst sid = r.id;\n\t\t\t\tconst cb = (forced) => {\n\t\t\t\t\tconst next = getSnapshotImpl(r);\n\t\t\t\t\tif (next !== r.lastSnap) {\n\t\t\t\t\t\tr.lastSnap = next;\n\t\t\t\t\t\tif (!forced && r.props.nativeUpdate?.(next)) return;\n\t\t\t\t\t\tforceUpdate();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\t(listenersByParent[pid] ||= /* @__PURE__ */ new Set()).add(sid);\n\t\t\t\tallListeners.set(sid, () => {\n\t\t\t\t\tconst forced = shouldForce;\n\t\t\t\t\tPendingUpdate.set(sid, forced ? \"force\" : true);\n\t\t\t\t\tcb(forced);\n\t\t\t\t});\n\t\t\t\tr.subscribedTo = pid;\n\t\t\t\tr.unsubscribe = () => {\n\t\t\t\t\tallListeners.delete(sid);\n\t\t\t\t\tlistenersByParent[pid]?.delete(sid);\n\t\t\t\t\tr.state = void 0;\n\t\t\t\t\tstates.delete(sid);\n\t\t\t\t\tPendingUpdate.delete(sid);\n\t\t\t\t\tr.unsubscribe = void 0;\n\t\t\t\t\tr.subscribedTo = void 0;\n\t\t\t\t};\n\t\t\t}\n\t\t} else if (r.unsubscribe) r.unsubscribe?.();\n\t\treturn () => {\n\t\t\tif (r.renderVersion === renderVersion) cleanupThemeState(r);\n\t\t};\n\t});\n\tif (cascadeOnChange) useIsomorphicLayoutEffect(() => {\n\t\tif (!HasRenderedOnce.get(keys)) {\n\t\t\tHasRenderedOnce.set(keys, true);\n\t\t\treturn;\n\t\t}\n\t\tif (!propsKey) {\n\t\t\tif (HadTheme.get(keys)) scheduleUpdate(id);\n\t\t\tHadTheme.set(keys, false);\n\t\t\treturn;\n\t\t}\n\t\tscheduleUpdate(id);\n\t\tHadTheme.set(keys, true);\n\t}, [keys, propsKey]);\n\treturn state;\n};\nconst shouldSubscribeToTheme = (r, cascadeOnChange) => Boolean(r.optimizeForFirstRender || r.isRoot || cascadeOnChange || hasThemeUpdatingProps(r.props) || r.keys.current?.size || r.props.needsUpdate?.());\nfunction cleanupThemeState(r) {\n\tif (r.unsubscribe) r.unsubscribe();\n\telse {\n\t\tr.state = void 0;\n\t\tstates.delete(r.id);\n\t\tPendingUpdate.delete(r.id);\n\t}\n\tthemeUpdateLayers.delete(r.id);\n\tthemeProviderParents.delete(r.id);\n}\nconst getSnapshotImpl = (r) => {\n\tconst { id, parentId, props, propsKey, isRoot, keys, optimizeForFirstRender } = r;\n\tlet local = r.state;\n\tconst parentState = states.get(parentId);\n\tif (local && !PendingUpdate.has(id)) {\n\t\tif (parentState && local._parentName === parentState.name && local._parentSchemeAuthored === parentState.schemeAuthored && local._propsKey === propsKey) return local;\n\t}\n\tconst canSkipForSchemeChange = Boolean(!optimizeForFirstRender && false);\n\tconst needsUpdate = props.passThrough ? false : optimizeForFirstRender ? true : isRoot || props.forceClassName || props.name === \"light\" || props.name === \"dark\" || props.name === null ? true : !HasRenderedOnce.get(keys) ? true : canSkipForSchemeChange ? false : keys?.current?.size ? true : props.needsUpdate?.();\n\tconst [rerender, nextRaw] = getNextState(local, props, propsKey, isRoot, id, parentId, needsUpdate, PendingUpdate.get(id));\n\tlet next = nextRaw;\n\tif (props._themeUpdate && nextRaw?.theme) {\n\t\tconst parentTheme = states.get(parentId)?.theme || nextRaw.theme;\n\t\tconst merged = props._themeUpdate.getTheme(parentTheme, nextRaw.name, getConfig());\n\t\tif (merged !== nextRaw.theme) next = {\n\t\t\t...nextRaw,\n\t\t\ttheme: merged\n\t\t};\n\t}\n\tPendingUpdate.delete(id);\n\tif (!local || rerender) {\n\t\tlocal = { ...next };\n\t\tr.state = local;\n\t}\n\tif (next !== local) {\n\t\tObject.assign(local, next);\n\t\tlocal.id = id;\n\t}\n\tlocal._parentName = parentState?.name;\n\tlocal._parentSchemeAuthored = parentState?.schemeAuthored;\n\tlocal._propsKey = propsKey;\n\tstates.set(id, next);\n\treturn local;\n};\nconst getNextState = (lastState, props, propsKey, isRoot = false, id, parentId, needsUpdate, pendingUpdate) => {\n\tconst parentState = states.get(parentId);\n\tif (props.passThrough) return [false, parentState || lastState || { name: \"\" }];\n\tthemes ||= getConfig().themes;\n\tconst name = !propsKey && (!lastState || !lastState.isNew) ? null : getNewThemeName(parentState?.name, props, pendingUpdate === \"force\" ? true : !!needsUpdate);\n\tconst authoredName = props.name;\n\tconst parentSchemeAuthored = !!parentState?.schemeAuthored;\n\tconst schemeAuthored = isRoot ? !!props.forceClassName : parentSchemeAuthored || !!(authoredName && getThemeScheme(authoredName) && authoredName in themes);\n\tconst intentChanged = schemeAuthored !== parentSchemeAuthored;\n\tconst resolvedName = name || parentState?.name;\n\tconst sameAsLast = lastState && lastState.name === resolvedName && !!lastState.schemeAuthored === schemeAuthored;\n\tconst isSameAsParent = Boolean(parentState && resolvedName === parentState.name && !intentChanged);\n\tconst shouldRerender = Boolean(pendingUpdate === \"force\" || needsUpdate && (pendingUpdate || lastState?.name !== parentState?.name || !!lastState?.schemeAuthored !== schemeAuthored));\n\tif (isSameAsParent) {\n\t\tif (!shouldRerender && sameAsLast) return [false, lastState];\n\t\treturn [shouldRerender, {\n\t\t\t...parentState,\n\t\t\tisNew: false\n\t\t}];\n\t}\n\tif (!resolvedName) {\n\t\tconst next = lastState ?? parentState ?? rootThemeState ?? {\n\t\t\tid,\n\t\t\tname: \"light\",\n\t\t\ttheme: getConfig().themes.light\n\t\t};\n\t\tif (shouldRerender) return [true, { ...parentState || lastState || next }];\n\t\treturn [false, next];\n\t}\n\tconst scheme = getAuthoredThemeScheme(themes[resolvedName]) || getThemeScheme(resolvedName);\n\tconst parentInverses = parentState?.inverses ?? 0;\n\tconst isInverse = Boolean(parentState && scheme !== parentState.scheme);\n\tconst inverses = parentInverses + (isInverse ? 1 : 0);\n\tconst nextState = {\n\t\tid,\n\t\tname: resolvedName,\n\t\ttheme: themes[resolvedName],\n\t\tscheme,\n\t\tparentId,\n\t\tparentName: parentState?.name,\n\t\tinverses,\n\t\tisInverse,\n\t\tschemeAuthored,\n\t\tisNew: true\n\t};\n\tif (isRoot) rootThemeState = nextState;\n\treturn [pendingUpdate === \"force\" || !sameAsLast, nextState];\n};\nfunction scheduleUpdate(id) {\n\tconst queue = [id];\n\tconst visited = /* @__PURE__ */ new Set();\n\twhile (queue.length) {\n\t\tconst children = listenersByParent[queue.shift()];\n\t\tif (children) {\n\t\t\tfor (const childId of children) if (!visited.has(childId)) {\n\t\t\t\tvisited.add(childId);\n\t\t\t\tqueue.push(childId);\n\t\t\t}\n\t\t}\n\t}\n\tvisited.forEach((childId) => {\n\t\tallListeners.get(childId)?.();\n\t});\n}\nfunction getNewThemeName(parentName = \"\", props, forceUpdate = false) {\n\tconst { name } = props;\n\tconst cacheKey = `${parentName}|${name || \"\"}|${forceUpdate ? 1 : 0}`;\n\tif (themeNameCacheVer !== cacheVersion) {\n\t\tthemeNameCache.clear();\n\t\tthemeNameCacheVer = cacheVersion;\n\t} else {\n\t\tconst cached = themeNameCache.get(cacheKey);\n\t\tif (cached !== void 0) return cached;\n\t}\n\tconst result = resolveThemeName(parentName, name ?? void 0, getConfig().themes, forceUpdate);\n\tif (themeNameCache.size >= 1e4) themeNameCache.clear();\n\tthemeNameCache.set(cacheKey, result);\n\treturn result;\n}\nconst getThemeNameCacheSize = () => themeNameCache.size;\nfunction resolveThemeName(parentName, name, themes2, forceUpdate = false) {\n\tconst parentParts = parentName ? parentName.split(\"_\") : [];\n\tlet found = null;\n\tif (name) {\n\t\tconst nameHasScheme = getThemeScheme(name);\n\t\tif (nameHasScheme && name in themes2) found = name;\n\t\tif (!found && !nameHasScheme) for (let i = parentParts.length; i >= 0; i--) {\n\t\t\tconst base = parentParts.slice(0, i).join(\"_\");\n\t\t\tconst potential = base ? `${base}_${name}` : name;\n\t\t\tif (potential in themes2) {\n\t\t\t\tfound = potential;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tif (!forceUpdate && found === parentName && found !== \"light\" && found !== \"dark\") return null;\n\treturn found;\n}\nconst hasThemeUpdatingProps = (props) => \"name\" in props || \"forceClassName\" in props || \"_themeUpdate\" in props;\n\nexport { ThemeStateContext, forceUpdateThemes, getNewThemeName, getRootThemeState, getThemeNameCacheSize, getThemeProviderChainSizes, getThemeProviderParent, getThemeProviderScope, getThemeState, getThemeUpdateLayer, hasThemeUpdatingProps, resolveThemeName, useThemeState };"],"mappings":";;;;;;;;AAOA,MAAM,oBAAoB,cAAc,EAAE;AAC1C,MAAM,+BAA+B,IAAI,IAAI;AAC7C,MAAM,oBAAoB,CAAC;AAC3B,MAAM,kCAAkC,IAAI,QAAQ;AACpD,MAAM,2BAA2B,IAAI,QAAQ;AAC7C,MAAM,gCAAgC,IAAI,IAAI;AAC9C,MAAM,yBAAyB,IAAI,IAAI;AACvC,IAAI,cAAc;AAClB,MAAM,0BAA0B;CAC/B;CACA,cAAc;CACd,aAAa,SAAS,OAAO,GAAG,CAAC;CACjC,cAAc;AACf;AACA,MAAM,iBAAiB,OAAO,OAAO,IAAI,EAAE;AAC3C,MAAM,oCAAoC,IAAI,IAAI;AAClD,MAAM,uCAAuC,IAAI,IAAI;AACrD,MAAM,uBAAuB,OAAO,kBAAkB,IAAI,EAAE;AAC5D,MAAM,0BAA0B,OAAO,qBAAqB,IAAI,EAAE,CAAC,EAAE;AACrE,MAAM,yBAAyB,OAAO,qBAAqB,IAAI,EAAE,CAAC,EAAE;AACpE,MAAM,oCAAoC;CACzC,QAAQ,kBAAkB;CAC1B,SAAS,qBAAqB;AAC/B;AACA,MAAM,8BAA8B,IAAI,UAAU,OAAO,SAAS;CACjE,MAAM,QAAQ,qBAAqB,IAAI,EAAE;CACzC,IAAI,OAAO,MAAM,WAAW;MACvB,qBAAqB,IAAI,IAAI;EACjC;EACA;CACD,CAAC;CACD,IAAI,MAAM,c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
|
|
30
30
|
return themeUpdateLayers.get(id);
|
|
31
31
|
};
|
|
32
32
|
var getThemeProviderParent = function getThemeProviderParent2(id) {
|
|
33
|
-
|
|
33
|
+
var _themeProviderParents_get;
|
|
34
|
+
return (_themeProviderParents_get = themeProviderParents.get(id)) === null || _themeProviderParents_get === void 0 ? void 0 : _themeProviderParents_get.parentId;
|
|
35
|
+
};
|
|
36
|
+
var getThemeProviderScope = function getThemeProviderScope2(id) {
|
|
37
|
+
var _themeProviderParents_get;
|
|
38
|
+
return (_themeProviderParents_get = themeProviderParents.get(id)) === null || _themeProviderParents_get === void 0 ? void 0 : _themeProviderParents_get.keys;
|
|
34
39
|
};
|
|
35
40
|
var getThemeProviderChainSizes = function getThemeProviderChainSizes2() {
|
|
36
41
|
return {
|
|
@@ -38,8 +43,13 @@ var getThemeProviderChainSizes = function getThemeProviderChainSizes2() {
|
|
|
38
43
|
parents: themeProviderParents.size
|
|
39
44
|
};
|
|
40
45
|
};
|
|
41
|
-
var registerThemeProviderChain = function registerThemeProviderChain2(id, parentId, props) {
|
|
42
|
-
themeProviderParents.
|
|
46
|
+
var registerThemeProviderChain = function registerThemeProviderChain2(id, parentId, props, keys) {
|
|
47
|
+
var scope = themeProviderParents.get(id);
|
|
48
|
+
if (scope) scope.parentId = parentId;
|
|
49
|
+
else themeProviderParents.set(id, {
|
|
50
|
+
parentId,
|
|
51
|
+
keys
|
|
52
|
+
});
|
|
43
53
|
if (props._themeUpdate) themeUpdateLayers.set(id, props._themeUpdate);
|
|
44
54
|
else themeUpdateLayers.delete(id);
|
|
45
55
|
};
|
|
@@ -74,7 +84,7 @@ Looked for theme${props.name ? ` "${props.name}"` : ""}, but no parent theme con
|
|
|
74
84
|
};
|
|
75
85
|
var id = useId();
|
|
76
86
|
var propsKey = `${props.name || ""}${props.forceClassName || ""}${((_props__themeUpdate = props._themeUpdate) === null || _props__themeUpdate === void 0 ? void 0 : _props__themeUpdate.key) || ""}`;
|
|
77
|
-
if (cascadeOnChange) registerThemeProviderChain(id, parentId, props);
|
|
87
|
+
if (cascadeOnChange) registerThemeProviderChain(id, parentId, props, keys);
|
|
78
88
|
var r = (_ref = useRef(null)).current || (_ref.current = {
|
|
79
89
|
id,
|
|
80
90
|
optimizeForFirstRender,
|
|
@@ -96,7 +106,7 @@ Looked for theme${props.name ? ` "${props.name}"` : ""}, but no parent theme con
|
|
|
96
106
|
states.set(r.id, r.lastSnap);
|
|
97
107
|
r.state = r.lastSnap;
|
|
98
108
|
}
|
|
99
|
-
if (cascadeOnChange && !themeProviderParents.has(r.id)) registerThemeProviderChain(r.id, r.parentId, r.props);
|
|
109
|
+
if (cascadeOnChange && !themeProviderParents.has(r.id)) registerThemeProviderChain(r.id, r.parentId, r.props, r.keys);
|
|
100
110
|
if (r.unsubscribe && r.subscribedTo !== r.parentId) {
|
|
101
111
|
var _r_unsubscribe;
|
|
102
112
|
(_r_unsubscribe = r.unsubscribe) === null || _r_unsubscribe === void 0 || _r_unsubscribe.call(r);
|
|
@@ -333,5 +343,5 @@ var hasThemeUpdatingProps = function hasThemeUpdatingProps2(props) {
|
|
|
333
343
|
return "name" in props || "forceClassName" in props || "_themeUpdate" in props;
|
|
334
344
|
};
|
|
335
345
|
|
|
336
|
-
export { ThemeStateContext, forceUpdateThemes, getNewThemeName, getRootThemeState, getThemeNameCacheSize, getThemeProviderChainSizes, getThemeProviderParent, getThemeState, getThemeUpdateLayer, hasThemeUpdatingProps, resolveThemeName, useThemeState };
|
|
346
|
+
export { ThemeStateContext, forceUpdateThemes, getNewThemeName, getRootThemeState, getThemeNameCacheSize, getThemeProviderChainSizes, getThemeProviderParent, getThemeProviderScope, getThemeState, getThemeUpdateLayer, hasThemeUpdatingProps, resolveThemeName, useThemeState };
|
|
337
347
|
//# sourceMappingURL=useThemeState.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useThemeState.native.js","names":[],"sources":["esm/hooks/useThemeState.native.js"],"sourcesContent":["import { supportsDynamicColorIOS, useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createContext, useContext, useEffect, useId, useReducer, useRef } from \"react\";\nimport { getThemeScheme } from \"@tamagui/helpers\";\nimport { getConfig, getSetting } from \"../config\";\nimport { MISSING_THEME_MESSAGE } from \"../constants/constants\";\nimport { getAuthoredThemeScheme } from \"../helpers/themes\";\n\nvar ThemeStateContext = createContext(\"\");\nvar allListeners = /* @__PURE__ */ new Map();\nvar listenersByParent = {};\nvar HasRenderedOnce = /* @__PURE__ */ new WeakMap();\nvar HadTheme = /* @__PURE__ */ new WeakMap();\nvar PendingUpdate = /* @__PURE__ */ new Map();\nvar states = /* @__PURE__ */ new Map();\nvar shouldForce = false;\nvar forceUpdateThemes = function forceUpdateThemes2() {\n\tcacheVersion++;\n\tshouldForce = true;\n\tallListeners.forEach(function(cb) {\n\t\treturn cb();\n\t});\n\tshouldForce = false;\n};\nvar getThemeState = function getThemeState2(id) {\n\treturn states.get(id);\n};\nvar themeUpdateLayers = /* @__PURE__ */ new Map();\nvar themeProviderParents = /* @__PURE__ */ new Map();\nvar getThemeUpdateLayer = function getThemeUpdateLayer2(id) {\n\treturn themeUpdateLayers.get(id);\n};\nvar getThemeProviderParent = function getThemeProviderParent2(id) {\n\treturn themeProviderParents.get(id);\n};\nvar getThemeProviderChainSizes = function getThemeProviderChainSizes2() {\n\treturn {\n\t\tlayers: themeUpdateLayers.size,\n\t\tparents: themeProviderParents.size\n\t};\n};\nvar registerThemeProviderChain = function registerThemeProviderChain2(id, parentId, props) {\n\tthemeProviderParents.set(id, parentId);\n\tif (props._themeUpdate) themeUpdateLayers.set(id, props._themeUpdate);\n\telse themeUpdateLayers.delete(id);\n};\nvar cacheVersion = 0;\nvar themeNameCache = /* @__PURE__ */ new Map();\nvar themeNameCacheVer = -1;\nvar themes = null;\nvar rootThemeState = null;\nvar getRootThemeState = function getRootThemeState2() {\n\treturn rootThemeState;\n};\nvar getThemeBaseName = function getThemeBaseName2(name) {\n\treturn name.replace(/^(light|dark)_/, \"\");\n};\nvar incReducer = function incReducer2(c) {\n\treturn c + 1;\n};\nvar useThemeState = function useThemeState2(props) {\n\t\"use no memo\";\n\tvar isRoot = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, keys = arguments.length > 2 ? arguments[2] : void 0, schemeKeys = arguments.length > 3 ? arguments[3] : void 0, cascadeOnChange = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : false, optimizeForFirstRender = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : false;\n\tvar _ref;\n\tvar _props__themeUpdate;\n\tvar { disable } = props;\n\tvar parentId = useContext(ThemeStateContext);\n\tif (!parentId && !isRoot) throw new Error(process.env.NODE_ENV === \"development\" ? `${MISSING_THEME_MESSAGE}\n\nLooked for theme${props.name ? ` \"${props.name}\"` : \"\"}, but no parent theme context was found (parentId: ${parentId}).` : MISSING_THEME_MESSAGE);\n\tif (disable) return states.get(parentId) || {\n\t\tid: \"\",\n\t\tname: \"light\",\n\t\ttheme: getConfig().themes.light\n\t};\n\tvar id = useId();\n\tvar propsKey = `${props.name || \"\"}${props.forceClassName || \"\"}${((_props__themeUpdate = props._themeUpdate) === null || _props__themeUpdate === void 0 ? void 0 : _props__themeUpdate.key) || \"\"}`;\n\tif (cascadeOnChange) registerThemeProviderChain(id, parentId, props);\n\tvar r = (_ref = useRef(null)).current || (_ref.current = {\n\t\tid,\n\t\toptimizeForFirstRender,\n\t\trenderVersion: 0\n\t});\n\tr.props = props;\n\tr.propsKey = propsKey;\n\tr.isRoot = isRoot;\n\tr.keys = keys;\n\tr.schemeKeys = schemeKeys;\n\tr.parentId = parentId;\n\tr.renderVersion++;\n\tvar [, forceUpdate] = useReducer(incReducer, 0);\n\tvar state = getSnapshotImpl(r);\n\tr.lastSnap = state;\n\tuseEffect(function() {\n\t\tvar renderVersion = r.renderVersion;\n\t\tif (r.lastSnap && !states.has(r.id)) {\n\t\t\tstates.set(r.id, r.lastSnap);\n\t\t\tr.state = r.lastSnap;\n\t\t}\n\t\tif (cascadeOnChange && !themeProviderParents.has(r.id)) registerThemeProviderChain(r.id, r.parentId, r.props);\n\t\tif (r.unsubscribe && r.subscribedTo !== r.parentId) {\n\t\t\tvar _r_unsubscribe;\n\t\t\t(_r_unsubscribe = r.unsubscribe) === null || _r_unsubscribe === void 0 || _r_unsubscribe.call(r);\n\t\t}\n\t\tif (shouldSubscribeToTheme(r, cascadeOnChange)) {\n\t\t\tif (!r.unsubscribe) {\n\t\t\t\tvar _listenersByParent, _pid;\n\t\t\t\tvar pid = r.parentId;\n\t\t\t\tvar sid = r.id;\n\t\t\t\tvar cb = function cb2(forced) {\n\t\t\t\t\tvar next = getSnapshotImpl(r);\n\t\t\t\t\tif (next !== r.lastSnap) {\n\t\t\t\t\t\tvar _r_props_nativeUpdate, _r_props;\n\t\t\t\t\t\tr.lastSnap = next;\n\t\t\t\t\t\tif (!forced && ((_r_props_nativeUpdate = (_r_props = r.props).nativeUpdate) === null || _r_props_nativeUpdate === void 0 ? void 0 : _r_props_nativeUpdate.call(_r_props, next))) return;\n\t\t\t\t\t\tforceUpdate();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\t((_listenersByParent = listenersByParent)[_pid = pid] || (_listenersByParent[_pid] = /* @__PURE__ */ new Set())).add(sid);\n\t\t\t\tallListeners.set(sid, function() {\n\t\t\t\t\tvar forced = shouldForce;\n\t\t\t\t\tPendingUpdate.set(sid, forced ? \"force\" : true);\n\t\t\t\t\tcb(forced);\n\t\t\t\t});\n\t\t\t\tr.subscribedTo = pid;\n\t\t\t\tr.unsubscribe = function() {\n\t\t\t\t\tvar _listenersByParent_pid;\n\t\t\t\t\tallListeners.delete(sid);\n\t\t\t\t\t(_listenersByParent_pid = listenersByParent[pid]) === null || _listenersByParent_pid === void 0 || _listenersByParent_pid.delete(sid);\n\t\t\t\t\tr.state = void 0;\n\t\t\t\t\tstates.delete(sid);\n\t\t\t\t\tPendingUpdate.delete(sid);\n\t\t\t\t\tr.unsubscribe = void 0;\n\t\t\t\t\tr.subscribedTo = void 0;\n\t\t\t\t};\n\t\t\t}\n\t\t} else if (r.unsubscribe) {\n\t\t\tvar _r_unsubscribe1;\n\t\t\t(_r_unsubscribe1 = r.unsubscribe) === null || _r_unsubscribe1 === void 0 || _r_unsubscribe1.call(r);\n\t\t}\n\t\treturn function() {\n\t\t\tif (r.renderVersion === renderVersion) cleanupThemeState(r);\n\t\t};\n\t});\n\tif (cascadeOnChange) useIsomorphicLayoutEffect(function() {\n\t\tif (!HasRenderedOnce.get(keys)) {\n\t\t\tHasRenderedOnce.set(keys, true);\n\t\t\treturn;\n\t\t}\n\t\tif (!propsKey) {\n\t\t\tif (HadTheme.get(keys)) scheduleUpdate(id);\n\t\t\tHadTheme.set(keys, false);\n\t\t\treturn;\n\t\t}\n\t\tscheduleUpdate(id);\n\t\tHadTheme.set(keys, true);\n\t}, [keys, propsKey]);\n\treturn state;\n};\nvar shouldSubscribeToTheme = function shouldSubscribeToTheme2(r, cascadeOnChange) {\n\tvar _r_keys_current, _r_props_needsUpdate, _r_props;\n\treturn Boolean(r.optimizeForFirstRender || r.isRoot || cascadeOnChange || hasThemeUpdatingProps(r.props) || ((_r_keys_current = r.keys.current) === null || _r_keys_current === void 0 ? void 0 : _r_keys_current.size) || ((_r_props_needsUpdate = (_r_props = r.props).needsUpdate) === null || _r_props_needsUpdate === void 0 ? void 0 : _r_props_needsUpdate.call(_r_props)));\n};\nfunction cleanupThemeState(r) {\n\tif (r.unsubscribe) r.unsubscribe();\n\telse {\n\t\tr.state = void 0;\n\t\tstates.delete(r.id);\n\t\tPendingUpdate.delete(r.id);\n\t}\n\tthemeUpdateLayers.delete(r.id);\n\tthemeProviderParents.delete(r.id);\n}\nvar getSnapshotImpl = function getSnapshotImpl2(r) {\n\tvar _keys_current, _schemeKeys_current, _keys_current1, _props_needsUpdate;\n\tvar { id, parentId, props, propsKey, isRoot, keys, optimizeForFirstRender } = r;\n\tvar schemeKeys = r.schemeKeys;\n\tvar local = r.state;\n\tvar parentState = states.get(parentId);\n\tif (local && !PendingUpdate.has(id)) {\n\t\tif (parentState && local._parentName === parentState.name && local._parentSchemeAuthored === parentState.schemeAuthored && local._propsKey === propsKey) return local;\n\t}\n\tvar isSchemeOnlyChange = !optimizeForFirstRender && supportsDynamicColorIOS && getSetting(\"fastSchemeChange\") && local && parentState && local.scheme !== parentState.scheme && getThemeBaseName(local.name) === getThemeBaseName(parentState.name);\n\tvar canSkipForSchemeChange = Boolean(isSchemeOnlyChange && ((_keys_current = keys.current) === null || _keys_current === void 0 ? void 0 : _keys_current.size) && (schemeKeys === null || schemeKeys === void 0 ? void 0 : (_schemeKeys_current = schemeKeys.current) === null || _schemeKeys_current === void 0 ? void 0 : _schemeKeys_current.size) === keys.current.size);\n\tvar needsUpdate = props.passThrough ? false : optimizeForFirstRender ? true : isRoot || props.forceClassName || props.name === \"light\" || props.name === \"dark\" || props.name === null ? true : !HasRenderedOnce.get(keys) ? true : canSkipForSchemeChange ? false : (keys === null || keys === void 0 ? void 0 : (_keys_current1 = keys.current) === null || _keys_current1 === void 0 ? void 0 : _keys_current1.size) ? true : (_props_needsUpdate = props.needsUpdate) === null || _props_needsUpdate === void 0 ? void 0 : _props_needsUpdate.call(props);\n\tvar [rerender, nextRaw] = getNextState(local, props, propsKey, isRoot, id, parentId, needsUpdate, PendingUpdate.get(id));\n\tvar next = nextRaw;\n\tif (props._themeUpdate && (nextRaw === null || nextRaw === void 0 ? void 0 : nextRaw.theme)) {\n\t\tvar _states_get;\n\t\tvar parentTheme = ((_states_get = states.get(parentId)) === null || _states_get === void 0 ? void 0 : _states_get.theme) || nextRaw.theme;\n\t\tvar merged = props._themeUpdate.getTheme(parentTheme, nextRaw.name, getConfig());\n\t\tif (merged !== nextRaw.theme) next = {\n\t\t\t...nextRaw,\n\t\t\ttheme: merged\n\t\t};\n\t}\n\tPendingUpdate.delete(id);\n\tif (!local || rerender) {\n\t\tlocal = { ...next };\n\t\tr.state = local;\n\t}\n\tif (next !== local) {\n\t\tObject.assign(local, next);\n\t\tlocal.id = id;\n\t}\n\tlocal._parentName = parentState === null || parentState === void 0 ? void 0 : parentState.name;\n\tlocal._parentSchemeAuthored = parentState === null || parentState === void 0 ? void 0 : parentState.schemeAuthored;\n\tlocal._propsKey = propsKey;\n\tstates.set(id, next);\n\treturn local;\n};\nvar getNextState = function getNextState2(lastState, props, propsKey) {\n\tvar isRoot = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false, id = arguments.length > 4 ? arguments[4] : void 0, parentId = arguments.length > 5 ? arguments[5] : void 0, needsUpdate = arguments.length > 6 ? arguments[6] : void 0, pendingUpdate = arguments.length > 7 ? arguments[7] : void 0;\n\tvar _ref;\n\tvar parentState = states.get(parentId);\n\tif (props.passThrough) return [false, parentState || lastState || { name: \"\" }];\n\tthemes || (themes = getConfig().themes);\n\tvar name = !propsKey && (!lastState || !lastState.isNew) ? null : getNewThemeName(parentState === null || parentState === void 0 ? void 0 : parentState.name, props, pendingUpdate === \"force\" ? true : !!needsUpdate);\n\tvar authoredName = props.name;\n\tvar parentSchemeAuthored = !!(parentState === null || parentState === void 0 ? void 0 : parentState.schemeAuthored);\n\tvar schemeAuthored = isRoot ? !!props.forceClassName : parentSchemeAuthored || !!(authoredName && getThemeScheme(authoredName) && authoredName in themes);\n\tvar intentChanged = schemeAuthored !== parentSchemeAuthored;\n\tvar resolvedName = name || (parentState === null || parentState === void 0 ? void 0 : parentState.name);\n\tvar sameAsLast = lastState && lastState.name === resolvedName && !!lastState.schemeAuthored === schemeAuthored;\n\tvar isSameAsParent = Boolean(parentState && resolvedName === parentState.name && !intentChanged);\n\tvar shouldRerender = Boolean(pendingUpdate === \"force\" || needsUpdate && (pendingUpdate || (lastState === null || lastState === void 0 ? void 0 : lastState.name) !== (parentState === null || parentState === void 0 ? void 0 : parentState.name) || !!(lastState === null || lastState === void 0 ? void 0 : lastState.schemeAuthored) !== schemeAuthored));\n\tif (isSameAsParent) {\n\t\tif (!shouldRerender && sameAsLast) return [false, lastState];\n\t\treturn [shouldRerender, {\n\t\t\t...parentState,\n\t\t\tisNew: false\n\t\t}];\n\t}\n\tif (!resolvedName) {\n\t\tvar _ref1, _ref2;\n\t\tvar next = (_ref1 = (_ref2 = lastState !== null && lastState !== void 0 ? lastState : parentState) !== null && _ref2 !== void 0 ? _ref2 : rootThemeState) !== null && _ref1 !== void 0 ? _ref1 : {\n\t\t\tid,\n\t\t\tname: \"light\",\n\t\t\ttheme: getConfig().themes.light\n\t\t};\n\t\tif (shouldRerender) return [true, { ...parentState || lastState || next }];\n\t\treturn [false, next];\n\t}\n\tvar scheme = getAuthoredThemeScheme(themes[resolvedName]) || getThemeScheme(resolvedName);\n\tvar parentInverses = (_ref = parentState === null || parentState === void 0 ? void 0 : parentState.inverses) !== null && _ref !== void 0 ? _ref : 0;\n\tvar isInverse = Boolean(parentState && scheme !== parentState.scheme);\n\tvar inverses = parentInverses + (isInverse ? 1 : 0);\n\tvar nextState = {\n\t\tid,\n\t\tname: resolvedName,\n\t\ttheme: themes[resolvedName],\n\t\tscheme,\n\t\tparentId,\n\t\tparentName: parentState === null || parentState === void 0 ? void 0 : parentState.name,\n\t\tinverses,\n\t\tisInverse,\n\t\tschemeAuthored,\n\t\tisNew: true\n\t};\n\tif (isRoot) rootThemeState = nextState;\n\treturn [pendingUpdate === \"force\" || !sameAsLast, nextState];\n};\nfunction scheduleUpdate(id) {\n\tvar queue = [id];\n\tvar visited = /* @__PURE__ */ new Set();\n\twhile (queue.length) {\n\t\tvar children = listenersByParent[queue.shift()];\n\t\tif (children) {\n\t\t\tvar _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n\t\t\ttry {\n\t\t\t\tfor (var _iterator = children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n\t\t\t\t\tvar childId = _step.value;\n\t\t\t\t\tif (!visited.has(childId)) {\n\t\t\t\t\t\tvisited.add(childId);\n\t\t\t\t\t\tqueue.push(childId);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\t_didIteratorError = true;\n\t\t\t\t_iteratorError = err;\n\t\t\t} finally {\n\t\t\t\ttry {\n\t\t\t\t\tif (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();\n\t\t\t\t} finally {\n\t\t\t\t\tif (_didIteratorError) throw _iteratorError;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tvisited.forEach(function(childId2) {\n\t\tvar _allListeners_get;\n\t\t(_allListeners_get = allListeners.get(childId2)) === null || _allListeners_get === void 0 || _allListeners_get();\n\t});\n}\nfunction getNewThemeName() {\n\tvar parentName = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : \"\", props = arguments.length > 1 ? arguments[1] : void 0, forceUpdate = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;\n\tvar { name } = props;\n\tvar cacheKey = `${parentName}|${name || \"\"}|${forceUpdate ? 1 : 0}`;\n\tif (themeNameCacheVer !== cacheVersion) {\n\t\tthemeNameCache.clear();\n\t\tthemeNameCacheVer = cacheVersion;\n\t} else {\n\t\tvar cached = themeNameCache.get(cacheKey);\n\t\tif (cached !== void 0) return cached;\n\t}\n\tvar result = resolveThemeName(parentName, name !== null && name !== void 0 ? name : void 0, getConfig().themes, forceUpdate);\n\tif (themeNameCache.size >= 1e4) themeNameCache.clear();\n\tthemeNameCache.set(cacheKey, result);\n\treturn result;\n}\nvar getThemeNameCacheSize = function getThemeNameCacheSize2() {\n\treturn themeNameCache.size;\n};\nfunction resolveThemeName(parentName, name, themes2) {\n\tvar forceUpdate = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false;\n\tvar parentParts = parentName ? parentName.split(\"_\") : [];\n\tvar found = null;\n\tif (name) {\n\t\tvar nameHasScheme = getThemeScheme(name);\n\t\tif (nameHasScheme && name in themes2) found = name;\n\t\tif (!found && !nameHasScheme) for (var i = parentParts.length; i >= 0; i--) {\n\t\t\tvar base = parentParts.slice(0, i).join(\"_\");\n\t\t\tvar potential = base ? `${base}_${name}` : name;\n\t\t\tif (potential in themes2) {\n\t\t\t\tfound = potential;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tif (!forceUpdate && found === parentName && found !== \"light\" && found !== \"dark\") return null;\n\treturn found;\n}\nvar hasThemeUpdatingProps = function hasThemeUpdatingProps2(props) {\n\treturn \"name\" in props || \"forceClassName\" in props || \"_themeUpdate\" in props;\n};\n\nexport { ThemeStateContext, forceUpdateThemes, getNewThemeName, getRootThemeState, getThemeNameCacheSize, getThemeProviderChainSizes, getThemeProviderParent, getThemeState, getThemeUpdateLayer, hasThemeUpdatingProps, resolveThemeName, useThemeState };"],"mappings":";;;;;;;;AAOA,IAAI,oBAAoB,cAAc,EAAE;AACxC,IAAI,+BAA+B,IAAI,IAAI;AAC3C,IAAI,oBAAoB,CAAC;AACzB,IAAI,kCAAkC,IAAI,QAAQ;AAClD,IAAI,2BAA2B,IAAI,QAAQ;AAC3C,IAAI,gCAAgC,IAAI,IAAI;AAC5C,IAAI,yBAAyB,IAAI,IAAI;AACrC,IAAI,cAAc;AAClB,IAAI,oBAAoB,SAAS,qBAAqB;CACrD;CACA,cAAc;CACd,aAAa,QAAQ,SAAS,IAAI;EACjC,OAAO,GAAG;CACX,CAAC;CACD,cAAc;AACf;AACA,IAAI,gBAAgB,SAAS,eAAe,IAAI;CAC/C,OAAO,OAAO,IAAI,EAAE;AACrB;AACA,IAAI,oCAAoC,IAAI,IAAI;AAChD,IAAI,uCAAuC,IAAI,IAAI;AACnD,IAAI,sBAAsB,SAAS,qBAAqB,IAAI;CAC3D,OAAO,kBAAkB,IAAI,EAAE;AAChC;AACA,IAAI,yBAAyB,SAAS,wBAAwB,IAAI;CACjE,OAAO,qBAAqB,IAAI,EAAE;AACnC;AACA,IAAI,6BAA6B,SAAS,8BAA8B;CACvE,OAAO;EACN,QAAQ,kBAAkB;EAC1B,SAAS,qBAAqB;CAC/B;AACD;AACA,IAAI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AQ;EACxC,IAAI,WAAW,KAAK,GAAG,OAAO;CAC/B;CACA,IAAI,SAAS,iBAAiB,YAAY,SAAS,QAAQ,SAAS,KAAK,IAAI,OAAO,KAAK,GAAG,UAAU,CAAC,CAAC,QAAQ,WAAW;CAC3H,IAAI,eAAe,QAAQ,KAAK,eAAe,MAAM;CACrD,eAAe,IAAI,UAAU,MAAM;CACnC,OAAO;AACR;AACA,IAAI,wBAAwB,SAAS,yBAAyB;CAC7D,OAAO,eAAe;AACvB;AACA,SAAS,iBAAiB,YAAY,MAAM,SAAS;CACpD,IAAI,cAAc,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK;CACnF,IAAI,cAAc,aAAa,WAAW,MAAM,GAAG,IAAI,CAAC;CACxD,IAAI,QAAQ;CACZ,IAAI,MAAM;EACT,IAAI,gBAAgB,eAAe,IAAI;EACvC,IAAI,iBAAiB,QAAQ,SAAS,QAAQ;EAC9C,IAAI,CAAC,SAAS,CAAC,eAAe,KAAK,IAAI,IAAI,YAAY,QAAQ,KAAK,GAAG,KAAK;GAC3E,IAAI,OAAO,YAAY,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG;GAC3C,IAAI,YAAY,OAAO,GAAG,KAAK,GAAG,SAAS;GAC3C,IAAI,aAAa,SAAS;IACzB,QAAQ;IACR;GACD;EACD;CACD;CACA,IAAI,CAAC,eAAe,UAAU,cAAc,UAAU,WAAW,UAAU,QAAQ,OAAO;CAC1F,OAAO;AACR;AACA,IAAI,wBAAwB,SAAS,uBAAuB,OAAO;CAClE,OAAO,UAAU,SAAS,oBAAoB,SAAS,kBAAkB;AAC1E"}
|
|
1
|
+
{"version":3,"file":"useThemeState.native.js","names":[],"sources":["esm/hooks/useThemeState.native.js"],"sourcesContent":["import { supportsDynamicColorIOS, useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createContext, useContext, useEffect, useId, useReducer, useRef } from \"react\";\nimport { getThemeScheme } from \"@tamagui/helpers\";\nimport { getConfig, getSetting } from \"../config\";\nimport { MISSING_THEME_MESSAGE } from \"../constants/constants\";\nimport { getAuthoredThemeScheme } from \"../helpers/themes\";\n\nvar ThemeStateContext = createContext(\"\");\nvar allListeners = /* @__PURE__ */ new Map();\nvar listenersByParent = {};\nvar HasRenderedOnce = /* @__PURE__ */ new WeakMap();\nvar HadTheme = /* @__PURE__ */ new WeakMap();\nvar PendingUpdate = /* @__PURE__ */ new Map();\nvar states = /* @__PURE__ */ new Map();\nvar shouldForce = false;\nvar forceUpdateThemes = function forceUpdateThemes2() {\n\tcacheVersion++;\n\tshouldForce = true;\n\tallListeners.forEach(function(cb) {\n\t\treturn cb();\n\t});\n\tshouldForce = false;\n};\nvar getThemeState = function getThemeState2(id) {\n\treturn states.get(id);\n};\nvar themeUpdateLayers = /* @__PURE__ */ new Map();\nvar themeProviderParents = /* @__PURE__ */ new Map();\nvar getThemeUpdateLayer = function getThemeUpdateLayer2(id) {\n\treturn themeUpdateLayers.get(id);\n};\nvar getThemeProviderParent = function getThemeProviderParent2(id) {\n\tvar _themeProviderParents_get;\n\treturn (_themeProviderParents_get = themeProviderParents.get(id)) === null || _themeProviderParents_get === void 0 ? void 0 : _themeProviderParents_get.parentId;\n};\nvar getThemeProviderScope = function getThemeProviderScope2(id) {\n\tvar _themeProviderParents_get;\n\treturn (_themeProviderParents_get = themeProviderParents.get(id)) === null || _themeProviderParents_get === void 0 ? void 0 : _themeProviderParents_get.keys;\n};\nvar getThemeProviderChainSizes = function getThemeProviderChainSizes2() {\n\treturn {\n\t\tlayers: themeUpdateLayers.size,\n\t\tparents: themeProviderParents.size\n\t};\n};\nvar registerThemeProviderChain = function registerThemeProviderChain2(id, parentId, props, keys) {\n\tvar scope = themeProviderParents.get(id);\n\tif (scope) scope.parentId = parentId;\n\telse themeProviderParents.set(id, {\n\t\tparentId,\n\t\tkeys\n\t});\n\tif (props._themeUpdate) themeUpdateLayers.set(id, props._themeUpdate);\n\telse themeUpdateLayers.delete(id);\n};\nvar cacheVersion = 0;\nvar themeNameCache = /* @__PURE__ */ new Map();\nvar themeNameCacheVer = -1;\nvar themes = null;\nvar rootThemeState = null;\nvar getRootThemeState = function getRootThemeState2() {\n\treturn rootThemeState;\n};\nvar getThemeBaseName = function getThemeBaseName2(name) {\n\treturn name.replace(/^(light|dark)_/, \"\");\n};\nvar incReducer = function incReducer2(c) {\n\treturn c + 1;\n};\nvar useThemeState = function useThemeState2(props) {\n\t\"use no memo\";\n\tvar isRoot = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, keys = arguments.length > 2 ? arguments[2] : void 0, schemeKeys = arguments.length > 3 ? arguments[3] : void 0, cascadeOnChange = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : false, optimizeForFirstRender = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : false;\n\tvar _ref;\n\tvar _props__themeUpdate;\n\tvar { disable } = props;\n\tvar parentId = useContext(ThemeStateContext);\n\tif (!parentId && !isRoot) throw new Error(process.env.NODE_ENV === \"development\" ? `${MISSING_THEME_MESSAGE}\n\nLooked for theme${props.name ? ` \"${props.name}\"` : \"\"}, but no parent theme context was found (parentId: ${parentId}).` : MISSING_THEME_MESSAGE);\n\tif (disable) return states.get(parentId) || {\n\t\tid: \"\",\n\t\tname: \"light\",\n\t\ttheme: getConfig().themes.light\n\t};\n\tvar id = useId();\n\tvar propsKey = `${props.name || \"\"}${props.forceClassName || \"\"}${((_props__themeUpdate = props._themeUpdate) === null || _props__themeUpdate === void 0 ? void 0 : _props__themeUpdate.key) || \"\"}`;\n\tif (cascadeOnChange) registerThemeProviderChain(id, parentId, props, keys);\n\tvar r = (_ref = useRef(null)).current || (_ref.current = {\n\t\tid,\n\t\toptimizeForFirstRender,\n\t\trenderVersion: 0\n\t});\n\tr.props = props;\n\tr.propsKey = propsKey;\n\tr.isRoot = isRoot;\n\tr.keys = keys;\n\tr.schemeKeys = schemeKeys;\n\tr.parentId = parentId;\n\tr.renderVersion++;\n\tvar [, forceUpdate] = useReducer(incReducer, 0);\n\tvar state = getSnapshotImpl(r);\n\tr.lastSnap = state;\n\tuseEffect(function() {\n\t\tvar renderVersion = r.renderVersion;\n\t\tif (r.lastSnap && !states.has(r.id)) {\n\t\t\tstates.set(r.id, r.lastSnap);\n\t\t\tr.state = r.lastSnap;\n\t\t}\n\t\tif (cascadeOnChange && !themeProviderParents.has(r.id)) registerThemeProviderChain(r.id, r.parentId, r.props, r.keys);\n\t\tif (r.unsubscribe && r.subscribedTo !== r.parentId) {\n\t\t\tvar _r_unsubscribe;\n\t\t\t(_r_unsubscribe = r.unsubscribe) === null || _r_unsubscribe === void 0 || _r_unsubscribe.call(r);\n\t\t}\n\t\tif (shouldSubscribeToTheme(r, cascadeOnChange)) {\n\t\t\tif (!r.unsubscribe) {\n\t\t\t\tvar _listenersByParent, _pid;\n\t\t\t\tvar pid = r.parentId;\n\t\t\t\tvar sid = r.id;\n\t\t\t\tvar cb = function cb2(forced) {\n\t\t\t\t\tvar next = getSnapshotImpl(r);\n\t\t\t\t\tif (next !== r.lastSnap) {\n\t\t\t\t\t\tvar _r_props_nativeUpdate, _r_props;\n\t\t\t\t\t\tr.lastSnap = next;\n\t\t\t\t\t\tif (!forced && ((_r_props_nativeUpdate = (_r_props = r.props).nativeUpdate) === null || _r_props_nativeUpdate === void 0 ? void 0 : _r_props_nativeUpdate.call(_r_props, next))) return;\n\t\t\t\t\t\tforceUpdate();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\t((_listenersByParent = listenersByParent)[_pid = pid] || (_listenersByParent[_pid] = /* @__PURE__ */ new Set())).add(sid);\n\t\t\t\tallListeners.set(sid, function() {\n\t\t\t\t\tvar forced = shouldForce;\n\t\t\t\t\tPendingUpdate.set(sid, forced ? \"force\" : true);\n\t\t\t\t\tcb(forced);\n\t\t\t\t});\n\t\t\t\tr.subscribedTo = pid;\n\t\t\t\tr.unsubscribe = function() {\n\t\t\t\t\tvar _listenersByParent_pid;\n\t\t\t\t\tallListeners.delete(sid);\n\t\t\t\t\t(_listenersByParent_pid = listenersByParent[pid]) === null || _listenersByParent_pid === void 0 || _listenersByParent_pid.delete(sid);\n\t\t\t\t\tr.state = void 0;\n\t\t\t\t\tstates.delete(sid);\n\t\t\t\t\tPendingUpdate.delete(sid);\n\t\t\t\t\tr.unsubscribe = void 0;\n\t\t\t\t\tr.subscribedTo = void 0;\n\t\t\t\t};\n\t\t\t}\n\t\t} else if (r.unsubscribe) {\n\t\t\tvar _r_unsubscribe1;\n\t\t\t(_r_unsubscribe1 = r.unsubscribe) === null || _r_unsubscribe1 === void 0 || _r_unsubscribe1.call(r);\n\t\t}\n\t\treturn function() {\n\t\t\tif (r.renderVersion === renderVersion) cleanupThemeState(r);\n\t\t};\n\t});\n\tif (cascadeOnChange) useIsomorphicLayoutEffect(function() {\n\t\tif (!HasRenderedOnce.get(keys)) {\n\t\t\tHasRenderedOnce.set(keys, true);\n\t\t\treturn;\n\t\t}\n\t\tif (!propsKey) {\n\t\t\tif (HadTheme.get(keys)) scheduleUpdate(id);\n\t\t\tHadTheme.set(keys, false);\n\t\t\treturn;\n\t\t}\n\t\tscheduleUpdate(id);\n\t\tHadTheme.set(keys, true);\n\t}, [keys, propsKey]);\n\treturn state;\n};\nvar shouldSubscribeToTheme = function shouldSubscribeToTheme2(r, cascadeOnChange) {\n\tvar _r_keys_current, _r_props_needsUpdate, _r_props;\n\treturn Boolean(r.optimizeForFirstRender || r.isRoot || cascadeOnChange || hasThemeUpdatingProps(r.props) || ((_r_keys_current = r.keys.current) === null || _r_keys_current === void 0 ? void 0 : _r_keys_current.size) || ((_r_props_needsUpdate = (_r_props = r.props).needsUpdate) === null || _r_props_needsUpdate === void 0 ? void 0 : _r_props_needsUpdate.call(_r_props)));\n};\nfunction cleanupThemeState(r) {\n\tif (r.unsubscribe) r.unsubscribe();\n\telse {\n\t\tr.state = void 0;\n\t\tstates.delete(r.id);\n\t\tPendingUpdate.delete(r.id);\n\t}\n\tthemeUpdateLayers.delete(r.id);\n\tthemeProviderParents.delete(r.id);\n}\nvar getSnapshotImpl = function getSnapshotImpl2(r) {\n\tvar _keys_current, _schemeKeys_current, _keys_current1, _props_needsUpdate;\n\tvar { id, parentId, props, propsKey, isRoot, keys, optimizeForFirstRender } = r;\n\tvar schemeKeys = r.schemeKeys;\n\tvar local = r.state;\n\tvar parentState = states.get(parentId);\n\tif (local && !PendingUpdate.has(id)) {\n\t\tif (parentState && local._parentName === parentState.name && local._parentSchemeAuthored === parentState.schemeAuthored && local._propsKey === propsKey) return local;\n\t}\n\tvar isSchemeOnlyChange = !optimizeForFirstRender && supportsDynamicColorIOS && getSetting(\"fastSchemeChange\") && local && parentState && local.scheme !== parentState.scheme && getThemeBaseName(local.name) === getThemeBaseName(parentState.name);\n\tvar canSkipForSchemeChange = Boolean(isSchemeOnlyChange && ((_keys_current = keys.current) === null || _keys_current === void 0 ? void 0 : _keys_current.size) && (schemeKeys === null || schemeKeys === void 0 ? void 0 : (_schemeKeys_current = schemeKeys.current) === null || _schemeKeys_current === void 0 ? void 0 : _schemeKeys_current.size) === keys.current.size);\n\tvar needsUpdate = props.passThrough ? false : optimizeForFirstRender ? true : isRoot || props.forceClassName || props.name === \"light\" || props.name === \"dark\" || props.name === null ? true : !HasRenderedOnce.get(keys) ? true : canSkipForSchemeChange ? false : (keys === null || keys === void 0 ? void 0 : (_keys_current1 = keys.current) === null || _keys_current1 === void 0 ? void 0 : _keys_current1.size) ? true : (_props_needsUpdate = props.needsUpdate) === null || _props_needsUpdate === void 0 ? void 0 : _props_needsUpdate.call(props);\n\tvar [rerender, nextRaw] = getNextState(local, props, propsKey, isRoot, id, parentId, needsUpdate, PendingUpdate.get(id));\n\tvar next = nextRaw;\n\tif (props._themeUpdate && (nextRaw === null || nextRaw === void 0 ? void 0 : nextRaw.theme)) {\n\t\tvar _states_get;\n\t\tvar parentTheme = ((_states_get = states.get(parentId)) === null || _states_get === void 0 ? void 0 : _states_get.theme) || nextRaw.theme;\n\t\tvar merged = props._themeUpdate.getTheme(parentTheme, nextRaw.name, getConfig());\n\t\tif (merged !== nextRaw.theme) next = {\n\t\t\t...nextRaw,\n\t\t\ttheme: merged\n\t\t};\n\t}\n\tPendingUpdate.delete(id);\n\tif (!local || rerender) {\n\t\tlocal = { ...next };\n\t\tr.state = local;\n\t}\n\tif (next !== local) {\n\t\tObject.assign(local, next);\n\t\tlocal.id = id;\n\t}\n\tlocal._parentName = parentState === null || parentState === void 0 ? void 0 : parentState.name;\n\tlocal._parentSchemeAuthored = parentState === null || parentState === void 0 ? void 0 : parentState.schemeAuthored;\n\tlocal._propsKey = propsKey;\n\tstates.set(id, next);\n\treturn local;\n};\nvar getNextState = function getNextState2(lastState, props, propsKey) {\n\tvar isRoot = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false, id = arguments.length > 4 ? arguments[4] : void 0, parentId = arguments.length > 5 ? arguments[5] : void 0, needsUpdate = arguments.length > 6 ? arguments[6] : void 0, pendingUpdate = arguments.length > 7 ? arguments[7] : void 0;\n\tvar _ref;\n\tvar parentState = states.get(parentId);\n\tif (props.passThrough) return [false, parentState || lastState || { name: \"\" }];\n\tthemes || (themes = getConfig().themes);\n\tvar name = !propsKey && (!lastState || !lastState.isNew) ? null : getNewThemeName(parentState === null || parentState === void 0 ? void 0 : parentState.name, props, pendingUpdate === \"force\" ? true : !!needsUpdate);\n\tvar authoredName = props.name;\n\tvar parentSchemeAuthored = !!(parentState === null || parentState === void 0 ? void 0 : parentState.schemeAuthored);\n\tvar schemeAuthored = isRoot ? !!props.forceClassName : parentSchemeAuthored || !!(authoredName && getThemeScheme(authoredName) && authoredName in themes);\n\tvar intentChanged = schemeAuthored !== parentSchemeAuthored;\n\tvar resolvedName = name || (parentState === null || parentState === void 0 ? void 0 : parentState.name);\n\tvar sameAsLast = lastState && lastState.name === resolvedName && !!lastState.schemeAuthored === schemeAuthored;\n\tvar isSameAsParent = Boolean(parentState && resolvedName === parentState.name && !intentChanged);\n\tvar shouldRerender = Boolean(pendingUpdate === \"force\" || needsUpdate && (pendingUpdate || (lastState === null || lastState === void 0 ? void 0 : lastState.name) !== (parentState === null || parentState === void 0 ? void 0 : parentState.name) || !!(lastState === null || lastState === void 0 ? void 0 : lastState.schemeAuthored) !== schemeAuthored));\n\tif (isSameAsParent) {\n\t\tif (!shouldRerender && sameAsLast) return [false, lastState];\n\t\treturn [shouldRerender, {\n\t\t\t...parentState,\n\t\t\tisNew: false\n\t\t}];\n\t}\n\tif (!resolvedName) {\n\t\tvar _ref1, _ref2;\n\t\tvar next = (_ref1 = (_ref2 = lastState !== null && lastState !== void 0 ? lastState : parentState) !== null && _ref2 !== void 0 ? _ref2 : rootThemeState) !== null && _ref1 !== void 0 ? _ref1 : {\n\t\t\tid,\n\t\t\tname: \"light\",\n\t\t\ttheme: getConfig().themes.light\n\t\t};\n\t\tif (shouldRerender) return [true, { ...parentState || lastState || next }];\n\t\treturn [false, next];\n\t}\n\tvar scheme = getAuthoredThemeScheme(themes[resolvedName]) || getThemeScheme(resolvedName);\n\tvar parentInverses = (_ref = parentState === null || parentState === void 0 ? void 0 : parentState.inverses) !== null && _ref !== void 0 ? _ref : 0;\n\tvar isInverse = Boolean(parentState && scheme !== parentState.scheme);\n\tvar inverses = parentInverses + (isInverse ? 1 : 0);\n\tvar nextState = {\n\t\tid,\n\t\tname: resolvedName,\n\t\ttheme: themes[resolvedName],\n\t\tscheme,\n\t\tparentId,\n\t\tparentName: parentState === null || parentState === void 0 ? void 0 : parentState.name,\n\t\tinverses,\n\t\tisInverse,\n\t\tschemeAuthored,\n\t\tisNew: true\n\t};\n\tif (isRoot) rootThemeState = nextState;\n\treturn [pendingUpdate === \"force\" || !sameAsLast, nextState];\n};\nfunction scheduleUpdate(id) {\n\tvar queue = [id];\n\tvar visited = /* @__PURE__ */ new Set();\n\twhile (queue.length) {\n\t\tvar children = listenersByParent[queue.shift()];\n\t\tif (children) {\n\t\t\tvar _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n\t\t\ttry {\n\t\t\t\tfor (var _iterator = children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n\t\t\t\t\tvar childId = _step.value;\n\t\t\t\t\tif (!visited.has(childId)) {\n\t\t\t\t\t\tvisited.add(childId);\n\t\t\t\t\t\tqueue.push(childId);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\t_didIteratorError = true;\n\t\t\t\t_iteratorError = err;\n\t\t\t} finally {\n\t\t\t\ttry {\n\t\t\t\t\tif (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();\n\t\t\t\t} finally {\n\t\t\t\t\tif (_didIteratorError) throw _iteratorError;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tvisited.forEach(function(childId2) {\n\t\tvar _allListeners_get;\n\t\t(_allListeners_get = allListeners.get(childId2)) === null || _allListeners_get === void 0 || _allListeners_get();\n\t});\n}\nfunction getNewThemeName() {\n\tvar parentName = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : \"\", props = arguments.length > 1 ? arguments[1] : void 0, forceUpdate = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;\n\tvar { name } = props;\n\tvar cacheKey = `${parentName}|${name || \"\"}|${forceUpdate ? 1 : 0}`;\n\tif (themeNameCacheVer !== cacheVersion) {\n\t\tthemeNameCache.clear();\n\t\tthemeNameCacheVer = cacheVersion;\n\t} else {\n\t\tvar cached = themeNameCache.get(cacheKey);\n\t\tif (cached !== void 0) return cached;\n\t}\n\tvar result = resolveThemeName(parentName, name !== null && name !== void 0 ? name : void 0, getConfig().themes, forceUpdate);\n\tif (themeNameCache.size >= 1e4) themeNameCache.clear();\n\tthemeNameCache.set(cacheKey, result);\n\treturn result;\n}\nvar getThemeNameCacheSize = function getThemeNameCacheSize2() {\n\treturn themeNameCache.size;\n};\nfunction resolveThemeName(parentName, name, themes2) {\n\tvar forceUpdate = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false;\n\tvar parentParts = parentName ? parentName.split(\"_\") : [];\n\tvar found = null;\n\tif (name) {\n\t\tvar nameHasScheme = getThemeScheme(name);\n\t\tif (nameHasScheme && name in themes2) found = name;\n\t\tif (!found && !nameHasScheme) for (var i = parentParts.length; i >= 0; i--) {\n\t\t\tvar base = parentParts.slice(0, i).join(\"_\");\n\t\t\tvar potential = base ? `${base}_${name}` : name;\n\t\t\tif (potential in themes2) {\n\t\t\t\tfound = potential;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tif (!forceUpdate && found === parentName && found !== \"light\" && found !== \"dark\") return null;\n\treturn found;\n}\nvar hasThemeUpdatingProps = function hasThemeUpdatingProps2(props) {\n\treturn \"name\" in props || \"forceClassName\" in props || \"_themeUpdate\" in props;\n};\n\nexport { ThemeStateContext, forceUpdateThemes, getNewThemeName, getRootThemeState, getThemeNameCacheSize, getThemeProviderChainSizes, getThemeProviderParent, getThemeProviderScope, getThemeState, getThemeUpdateLayer, hasThemeUpdatingProps, resolveThemeName, useThemeState };"],"mappings":";;;;;;;;AAOA,IAAI,oBAAoB,cAAc,EAAE;AACxC,IAAI,+BAA+B,IAAI,IAAI;AAC3C,IAAI,oBAAoB,CAAC;AACzB,IAAI,kCAAkC,IAAI,QAAQ;AAClD,IAAI,2BAA2B,IAAI,QAAQ;AAC3C,IAAI,gCAAgC,IAAI,IAAI;AAC5C,IAAI,yBAAyB,IAAI,IAAI;AACrC,IAAI,cAAc;AAClB,IAAI,oBAAoB,SAAS,qBAAqB;CACrD;CACA,cAAc;CACd,aAAa,QAAQ,SAAS,IAAI;EACjC,OAAO,GAAG;CACX,CAAC;CACD,cAAc;AACf;AACA,IAAI,gBAAgB,SAAS,eAAe,IAAI;CAC/C,OAAO,OAAO,IAAI,EAAE;AACrB;AACA,IAAI,oCAAoC,IAAI,IAAI;AAChD,IAAI,uCAAuC,IAAI,IAAI;AACnD,IAAI,sBAAsB,SAAS,qBAAqB,IAAI;CAC3D,O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E,IAAI,OAAO,YAAY,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG;GAC3C,IAAI,YAAY,OAAO,GAAG,KAAK,GAAG,SAAS;GAC3C,IAAI,aAAa,SAAS;IACzB,QAAQ;IACR;GACD;EACD;CACD;CACA,IAAI,CAAC,eAAe,UAAU,cAAc,UAAU,WAAW,UAAU,QAAQ,OAAO;CAC1F,OAAO;AACR;AACA,IAAI,wBAAwB,SAAS,uBAAuB,OAAO;CAClE,OAAO,UAAU,SAAS,oBAAoB,SAAS,kBAAkB;AAC1E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/web",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.14",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Nate Wienert"
|
|
@@ -100,23 +100,23 @@
|
|
|
100
100
|
"test:web": "vitest --typecheck --run"
|
|
101
101
|
},
|
|
102
102
|
"dependencies": {
|
|
103
|
-
"@tamagui/animation-helpers": "3.0.
|
|
104
|
-
"@tamagui/compose-refs": "3.0.
|
|
105
|
-
"@tamagui/constants": "3.0.
|
|
106
|
-
"@tamagui/dom": "3.0.
|
|
107
|
-
"@tamagui/helpers": "3.0.
|
|
108
|
-
"@tamagui/is-equal-shallow": "3.0.
|
|
109
|
-
"@tamagui/native": "3.0.
|
|
110
|
-
"@tamagui/normalize-css-color": "3.0.
|
|
111
|
-
"@tamagui/react-native-types": "3.0.
|
|
112
|
-
"@tamagui/style-grammar": "3.0.
|
|
113
|
-
"@tamagui/types": "3.0.
|
|
114
|
-
"@tamagui/use-did-finish-ssr": "3.0.
|
|
115
|
-
"@tamagui/use-event": "3.0.
|
|
116
|
-
"@tamagui/use-force-update": "3.0.
|
|
103
|
+
"@tamagui/animation-helpers": "3.0.14",
|
|
104
|
+
"@tamagui/compose-refs": "3.0.14",
|
|
105
|
+
"@tamagui/constants": "3.0.14",
|
|
106
|
+
"@tamagui/dom": "3.0.14",
|
|
107
|
+
"@tamagui/helpers": "3.0.14",
|
|
108
|
+
"@tamagui/is-equal-shallow": "3.0.14",
|
|
109
|
+
"@tamagui/native": "3.0.14",
|
|
110
|
+
"@tamagui/normalize-css-color": "3.0.14",
|
|
111
|
+
"@tamagui/react-native-types": "3.0.14",
|
|
112
|
+
"@tamagui/style-grammar": "3.0.14",
|
|
113
|
+
"@tamagui/types": "3.0.14",
|
|
114
|
+
"@tamagui/use-did-finish-ssr": "3.0.14",
|
|
115
|
+
"@tamagui/use-event": "3.0.14",
|
|
116
|
+
"@tamagui/use-force-update": "3.0.14"
|
|
117
117
|
},
|
|
118
118
|
"devDependencies": {
|
|
119
|
-
"@tamagui/build": "3.0.
|
|
119
|
+
"@tamagui/build": "3.0.14",
|
|
120
120
|
"@testing-library/react": "^16.1.0",
|
|
121
121
|
"csstype": "^3.0.10",
|
|
122
122
|
"react": "19.2.3",
|
|
@@ -133,5 +133,5 @@
|
|
|
133
133
|
"./dist/cjs": "./dist/esm/index.native.js",
|
|
134
134
|
"./theme-update": "./dist/esm/theme-update.native.js"
|
|
135
135
|
},
|
|
136
|
-
"releaseSourceCommit": "
|
|
136
|
+
"releaseSourceCommit": "61a8bd09550319d14c141581a8e4bb286a9795a6"
|
|
137
137
|
}
|
package/src/_withNativeStyle.tsx
CHANGED
|
@@ -13,7 +13,11 @@ import {
|
|
|
13
13
|
type NativeStyleLinkState,
|
|
14
14
|
type NativeStyleThemeMapping,
|
|
15
15
|
} from './helpers/nativeStyleEngine'
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
getThemeProviderScope,
|
|
18
|
+
getThemeState,
|
|
19
|
+
ThemeStateContext,
|
|
20
|
+
} from './hooks/useThemeState'
|
|
17
21
|
import { hooks } from './setupHooks'
|
|
18
22
|
|
|
19
23
|
// the host props RN's <Text> passes for a non-pressable text outside a text
|
|
@@ -79,12 +83,13 @@ export const _withNativeStyle = (
|
|
|
79
83
|
}),
|
|
80
84
|
}
|
|
81
85
|
: baseStyle
|
|
82
|
-
// one entry per
|
|
86
|
+
// one weak entry per live provider scope, released with its provider chain
|
|
87
|
+
// record. its style arrays (one per host mode) keep their
|
|
83
88
|
// identity until the scope's state changes, then are rebuilt: a style handed
|
|
84
89
|
// to a host is a prop, which react native freezes in development, so a theme
|
|
85
90
|
// switch never writes into one. the ref stays off once the react root is
|
|
86
91
|
// known, so a remount does not pay a callback ref per host
|
|
87
|
-
const entries = new
|
|
92
|
+
const entries = new WeakMap<object, ScopeEntry>()
|
|
88
93
|
const createEntry = (): ScopeEntry => {
|
|
89
94
|
const entry: ScopeEntry = {
|
|
90
95
|
style: [baseStyle, null],
|
|
@@ -105,6 +110,7 @@ export const _withNativeStyle = (
|
|
|
105
110
|
const ScopeContext = ThemeStateContext
|
|
106
111
|
const engineOf = getNativeStyleEngine
|
|
107
112
|
const scopeState = getThemeState
|
|
113
|
+
const scopeOwner = getThemeProviderScope
|
|
108
114
|
const resolve = resolveNativeStyleMapping
|
|
109
115
|
const linkState = createNativeStyleLinkState
|
|
110
116
|
const linkHost = linkNativeStyleHost
|
|
@@ -119,9 +125,10 @@ export const _withNativeStyle = (
|
|
|
119
125
|
const scopeId = use(ScopeContext)
|
|
120
126
|
const inText = TextAncestor ? use(TextAncestor) : false
|
|
121
127
|
const themeState = scopeId && engineOf() ? scopeState(scopeId) : undefined
|
|
128
|
+
const owner = scopeOwner(scopeId)
|
|
122
129
|
const resetsText = inText && host === 'view'
|
|
123
130
|
|
|
124
|
-
if (!themeState) {
|
|
131
|
+
if (!themeState || !owner) {
|
|
125
132
|
return resetsText ? (
|
|
126
133
|
<TextAncestorProvider key={key} value={false}>
|
|
127
134
|
<Fallback {...props} />
|
|
@@ -142,10 +149,10 @@ export const _withNativeStyle = (
|
|
|
142
149
|
const { name, theme } = themeState
|
|
143
150
|
const asHostText = HostText && !inText
|
|
144
151
|
const Rendered = asHostText ? HostText : Component
|
|
145
|
-
let entry = entries.get(
|
|
152
|
+
let entry = entries.get(owner)
|
|
146
153
|
if (!entry) {
|
|
147
154
|
entry = createEntry()
|
|
148
|
-
entries.set(
|
|
155
|
+
entries.set(owner, entry)
|
|
149
156
|
}
|
|
150
157
|
if (entry.stateName !== name || entry.theme !== theme) {
|
|
151
158
|
const themed = resolve(themeStyleKeys, name, theme)
|
|
@@ -200,7 +207,7 @@ export const _withNativeStyle = (
|
|
|
200
207
|
// component's theme scope is provably the element's own: the element is
|
|
201
208
|
// only built, never mounted, and its host renders in the caller's place
|
|
202
209
|
NativeStyleView.inline = (element: React.ReactElement<any>) =>
|
|
203
|
-
render(element.props, element.key)
|
|
210
|
+
render(element.props, element.key ?? undefined)
|
|
204
211
|
return NativeStyleView
|
|
205
212
|
}
|
|
206
213
|
|
|
@@ -2853,8 +2853,13 @@ function configuredValue(
|
|
|
2853
2853
|
let lookupName = name.charCodeAt(0) === 36 ? name.slice(1) : name
|
|
2854
2854
|
let value: any
|
|
2855
2855
|
let fromTheme = false
|
|
2856
|
+
// native FontLanguage swaps fonts through context, web swaps css variables
|
|
2857
|
+
const fonts =
|
|
2858
|
+
fontProperty && state.context?.language
|
|
2859
|
+
? getDynamicEnv(state).fonts
|
|
2860
|
+
: state.conf.fontsParsed
|
|
2856
2861
|
if (property === 'fontFamily') {
|
|
2857
|
-
value =
|
|
2862
|
+
value = fonts[lookupName]?.family
|
|
2858
2863
|
} else {
|
|
2859
2864
|
const fontKey =
|
|
2860
2865
|
property === 'fontSize'
|
|
@@ -2866,8 +2871,8 @@ function configuredValue(
|
|
|
2866
2871
|
: ''
|
|
2867
2872
|
if (fontKey) {
|
|
2868
2873
|
const font =
|
|
2869
|
-
|
|
2870
|
-
|
|
2874
|
+
fonts[state.fontFamily || state.conf.defaultFontToken] ||
|
|
2875
|
+
fonts[state.conf.defaultFontToken]
|
|
2871
2876
|
value = font?.[fontKey]?.[lookupName]
|
|
2872
2877
|
} else {
|
|
2873
2878
|
const category = grammar.tokenCategory(property)
|