@tamagui/web 3.0.13 → 3.0.15
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/createComponent.tsx +6 -10
- 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/createComponent.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
|
@@ -30,15 +30,12 @@ var import_config = require("../config.cjs");
|
|
|
30
30
|
var import_createVariable = require("../createVariable.cjs");
|
|
31
31
|
var import_resolveSizing = require("./resolveSizing.cjs");
|
|
32
32
|
var import_types = require("../types.cjs");
|
|
33
|
-
const fontLanguageCache = /* @__PURE__ */ new WeakMap();
|
|
34
33
|
function getFontsForLanguage(fonts, language) {
|
|
35
|
-
if (fontLanguageCache.has(language)) return fontLanguageCache.get(language);
|
|
36
34
|
const next = { ...fonts };
|
|
37
35
|
for (const name in language) {
|
|
38
36
|
const lang = language[name];
|
|
39
|
-
if (lang !== "default") next[name] = fonts[`${name}_${lang}`];
|
|
37
|
+
if (lang !== "default") next[name] = fonts[`${name}_${lang}`] ?? fonts[name];
|
|
40
38
|
}
|
|
41
|
-
fontLanguageCache.set(language, next);
|
|
42
39
|
return next;
|
|
43
40
|
}
|
|
44
41
|
function isStyledDynamic(value) {
|
|
@@ -32,15 +32,13 @@ var import_config = require("../config.native.js");
|
|
|
32
32
|
var import_createVariable = require("../createVariable.native.js");
|
|
33
33
|
var import_resolveSizing = require("./resolveSizing.native.js");
|
|
34
34
|
var import_types = require("../types.native.js");
|
|
35
|
-
var fontLanguageCache = /* @__PURE__ */ new WeakMap();
|
|
36
35
|
function getFontsForLanguage(fonts, language) {
|
|
37
|
-
if (fontLanguageCache.has(language)) return fontLanguageCache.get(language);
|
|
38
36
|
var next = { ...fonts };
|
|
39
37
|
for (var name in language) {
|
|
38
|
+
var _fonts_;
|
|
40
39
|
var lang = language[name];
|
|
41
|
-
if (lang !== "default") next[name] = fonts[`${name}_${lang}`];
|
|
40
|
+
if (lang !== "default") next[name] = (_fonts_ = fonts[`${name}_${lang}`]) !== null && _fonts_ !== void 0 ? _fonts_ : fonts[name];
|
|
42
41
|
}
|
|
43
|
-
fontLanguageCache.set(language, next);
|
|
44
42
|
return next;
|
|
45
43
|
}
|
|
46
44
|
function isStyledDynamic(value) {
|
|
@@ -32,15 +32,13 @@ var import_config = require("../config.native.js");
|
|
|
32
32
|
var import_createVariable = require("../createVariable.native.js");
|
|
33
33
|
var import_resolveSizing = require("./resolveSizing.native.js");
|
|
34
34
|
var import_types = require("../types.native.js");
|
|
35
|
-
var fontLanguageCache = /* @__PURE__ */ new WeakMap();
|
|
36
35
|
function getFontsForLanguage(fonts, language) {
|
|
37
|
-
if (fontLanguageCache.has(language)) return fontLanguageCache.get(language);
|
|
38
36
|
var next = { ...fonts };
|
|
39
37
|
for (var name in language) {
|
|
38
|
+
var _fonts_;
|
|
40
39
|
var lang = language[name];
|
|
41
|
-
if (lang !== "default") next[name] = fonts[`${name}_${lang}`];
|
|
40
|
+
if (lang !== "default") next[name] = (_fonts_ = fonts[`${name}_${lang}`]) !== null && _fonts_ !== void 0 ? _fonts_ : fonts[name];
|
|
42
41
|
}
|
|
43
|
-
fontLanguageCache.set(language, next);
|
|
44
42
|
return next;
|
|
45
43
|
}
|
|
46
44
|
function isStyledDynamic(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styledDynamic.native.js","names":[],"sources":["cjs/helpers/styledDynamic.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar styledDynamic_exports = {};\n__export(styledDynamic_exports, {\n getDynamicEnv: () => getDynamicEnv,\n getFontsForLanguage: () => getFontsForLanguage,\n isStyledDynamic: () => isStyledDynamic,\n styledDynamic: () => styledDynamic\n});\nmodule.exports = __toCommonJS(styledDynamic_exports);\nvar import_config = require(\"../config\");\nvar import_createVariable = require(\"../createVariable\");\nvar import_resolveSizing = require(\"./resolveSizing\");\nvar import_types = require(\"../types\");\nvar fontLanguageCache = /* @__PURE__ */ new WeakMap();\nfunction getFontsForLanguage(fonts, language) {\n if (fontLanguageCache.has(language)) return fontLanguageCache.get(language);\n var next = {\n ...fonts\n };\n for (var name in language) {\n var lang = language[name];\n if (lang !== \"default\") next[name] = fonts[`${name}_${lang}`];\n }\n fontLanguageCache.set(language, next);\n return next;\n}\nfunction isStyledDynamic(value) {\n return !!value && (typeof value === \"function\" || typeof value === \"object\") && import_types.styledDynamicSymbol in value;\n}\nvar bareStyledDynamic = {\n [import_types.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[import_types.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 ...import_resolveSizing.defaultSizing,\n ...conf.sizing\n },\n get fontFamily() {\n return (0, import_createVariable.getVariableValue)(styleState.fontFamily || props.fontFamily) || props.fontFamily || (0, import_createVariable.getVariableValue)((0, import_config.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}\n//# sourceMappingURL=styledDynamic.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,m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M,KAAK;EACpB;CACF;CACA,OAAO,WAAW,iBAAiB;AACrC"}
|
|
1
|
+
{"version":3,"file":"styledDynamic.native.js","names":[],"sources":["cjs/helpers/styledDynamic.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar styledDynamic_exports = {};\n__export(styledDynamic_exports, {\n getDynamicEnv: () => getDynamicEnv,\n getFontsForLanguage: () => getFontsForLanguage,\n isStyledDynamic: () => isStyledDynamic,\n styledDynamic: () => styledDynamic\n});\nmodule.exports = __toCommonJS(styledDynamic_exports);\nvar import_config = require(\"../config\");\nvar import_createVariable = require(\"../createVariable\");\nvar import_resolveSizing = require(\"./resolveSizing\");\nvar import_types = require(\"../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\") && import_types.styledDynamicSymbol in value;\n}\nvar bareStyledDynamic = {\n [import_types.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[import_types.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 ...import_resolveSizing.defaultSizing,\n ...conf.sizing\n },\n get fontFamily() {\n return (0, import_createVariable.getVariableValue)(styleState.fontFamily || props.fontFamily) || props.fontFamily || (0, import_createVariable.getVariableValue)((0, import_config.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}\n//# sourceMappingURL=styledDynamic.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,wBAAwB,CAAC;AAC7B,SAAS,uBAAuB;CAC9B,qBAAqB;CACrB,2BAA2B;CAC3B,uBAAuB;CACvB,qBAAqB;AACvB,CAAC;AACD,OAAO,UAAU,aAAa,qBAAqB;AACnD,IAAI,gBAAgB,QAAQ,qBAAW;AACvC,IAAI,wBAAwB,QAAQ,6BAAmB;AACvD,IAAI,uBAAuB,QAAQ,2BAAiB;AACpD,IAAI,eAAe,QAAQ,oBAAU;AACrC,SAAS,oBAAoB,OAAO,UAAU;CAC5C,IAAI,OAAO,EACT,GAAG,MACL;CACA,KAAK,IAAI,QAAQ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,IAAI,QAAQ,QAAQ,qBAAqB,KAAK,SAAS,OAAO,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM;IACxG,IAAI,QAAQ,MAAM,OAAO,OAAO,MAAM;GACxC;GACA,OAAO,MAAM,KAAK;EACpB;CACF;CACA,OAAO,WAAW,iBAAiB;AACrC"}
|
|
@@ -27,6 +27,7 @@ __export(useThemeState_exports, {
|
|
|
27
27
|
getThemeNameCacheSize: () => getThemeNameCacheSize,
|
|
28
28
|
getThemeProviderChainSizes: () => getThemeProviderChainSizes,
|
|
29
29
|
getThemeProviderParent: () => getThemeProviderParent,
|
|
30
|
+
getThemeProviderScope: () => getThemeProviderScope,
|
|
30
31
|
getThemeState: () => getThemeState,
|
|
31
32
|
getThemeUpdateLayer: () => getThemeUpdateLayer,
|
|
32
33
|
hasThemeUpdatingProps: () => hasThemeUpdatingProps,
|
|
@@ -58,13 +59,19 @@ const getThemeState = (id) => states.get(id);
|
|
|
58
59
|
const themeUpdateLayers = /* @__PURE__ */ new Map();
|
|
59
60
|
const themeProviderParents = /* @__PURE__ */ new Map();
|
|
60
61
|
const getThemeUpdateLayer = (id) => themeUpdateLayers.get(id);
|
|
61
|
-
const getThemeProviderParent = (id) => themeProviderParents.get(id);
|
|
62
|
+
const getThemeProviderParent = (id) => themeProviderParents.get(id)?.parentId;
|
|
63
|
+
const getThemeProviderScope = (id) => themeProviderParents.get(id)?.keys;
|
|
62
64
|
const getThemeProviderChainSizes = () => ({
|
|
63
65
|
layers: themeUpdateLayers.size,
|
|
64
66
|
parents: themeProviderParents.size
|
|
65
67
|
});
|
|
66
|
-
const registerThemeProviderChain = (id, parentId, props) => {
|
|
67
|
-
themeProviderParents.
|
|
68
|
+
const registerThemeProviderChain = (id, parentId, props, keys) => {
|
|
69
|
+
const scope = themeProviderParents.get(id);
|
|
70
|
+
if (scope) scope.parentId = parentId;
|
|
71
|
+
else themeProviderParents.set(id, {
|
|
72
|
+
parentId,
|
|
73
|
+
keys
|
|
74
|
+
});
|
|
68
75
|
if (props._themeUpdate) themeUpdateLayers.set(id, props._themeUpdate);
|
|
69
76
|
else themeUpdateLayers.delete(id);
|
|
70
77
|
};
|
|
@@ -89,7 +96,7 @@ Looked for theme${props.name ? ` "${props.name}"` : ""}, but no parent theme con
|
|
|
89
96
|
};
|
|
90
97
|
const id = (0, import_react.useId)();
|
|
91
98
|
const propsKey = `${props.name || ""}${props.forceClassName || ""}${props._themeUpdate?.key || ""}`;
|
|
92
|
-
if (cascadeOnChange) registerThemeProviderChain(id, parentId, props);
|
|
99
|
+
if (cascadeOnChange) registerThemeProviderChain(id, parentId, props, keys);
|
|
93
100
|
const ref = (0, import_react.useRef)(null);
|
|
94
101
|
const r = ref.current ||= {
|
|
95
102
|
id,
|
|
@@ -111,7 +118,7 @@ Looked for theme${props.name ? ` "${props.name}"` : ""}, but no parent theme con
|
|
|
111
118
|
states.set(r.id, r.lastSnap);
|
|
112
119
|
r.state = r.lastSnap;
|
|
113
120
|
}
|
|
114
|
-
if (cascadeOnChange && !themeProviderParents.has(r.id)) registerThemeProviderChain(r.id, r.parentId, r.props);
|
|
121
|
+
if (cascadeOnChange && !themeProviderParents.has(r.id)) registerThemeProviderChain(r.id, r.parentId, r.props, r.keys);
|
|
115
122
|
if (r.unsubscribe && r.subscribedTo !== r.parentId) r.unsubscribe?.();
|
|
116
123
|
if (shouldSubscribeToTheme(r, cascadeOnChange)) {
|
|
117
124
|
if (!r.unsubscribe) {
|
|
@@ -29,6 +29,7 @@ __export(useThemeState_exports, {
|
|
|
29
29
|
getThemeNameCacheSize: () => getThemeNameCacheSize,
|
|
30
30
|
getThemeProviderChainSizes: () => getThemeProviderChainSizes,
|
|
31
31
|
getThemeProviderParent: () => getThemeProviderParent,
|
|
32
|
+
getThemeProviderScope: () => getThemeProviderScope,
|
|
32
33
|
getThemeState: () => getThemeState,
|
|
33
34
|
getThemeUpdateLayer: () => getThemeUpdateLayer,
|
|
34
35
|
hasThemeUpdatingProps: () => hasThemeUpdatingProps,
|
|
@@ -67,7 +68,12 @@ var getThemeUpdateLayer = function getThemeUpdateLayer2(id) {
|
|
|
67
68
|
return themeUpdateLayers.get(id);
|
|
68
69
|
};
|
|
69
70
|
var getThemeProviderParent = function getThemeProviderParent2(id) {
|
|
70
|
-
|
|
71
|
+
var _themeProviderParents_get;
|
|
72
|
+
return (_themeProviderParents_get = themeProviderParents.get(id)) === null || _themeProviderParents_get === void 0 ? void 0 : _themeProviderParents_get.parentId;
|
|
73
|
+
};
|
|
74
|
+
var getThemeProviderScope = function getThemeProviderScope2(id) {
|
|
75
|
+
var _themeProviderParents_get;
|
|
76
|
+
return (_themeProviderParents_get = themeProviderParents.get(id)) === null || _themeProviderParents_get === void 0 ? void 0 : _themeProviderParents_get.keys;
|
|
71
77
|
};
|
|
72
78
|
var getThemeProviderChainSizes = function getThemeProviderChainSizes2() {
|
|
73
79
|
return {
|
|
@@ -75,8 +81,13 @@ var getThemeProviderChainSizes = function getThemeProviderChainSizes2() {
|
|
|
75
81
|
parents: themeProviderParents.size
|
|
76
82
|
};
|
|
77
83
|
};
|
|
78
|
-
var registerThemeProviderChain = function registerThemeProviderChain2(id, parentId, props) {
|
|
79
|
-
themeProviderParents.
|
|
84
|
+
var registerThemeProviderChain = function registerThemeProviderChain2(id, parentId, props, keys) {
|
|
85
|
+
var scope = themeProviderParents.get(id);
|
|
86
|
+
if (scope) scope.parentId = parentId;
|
|
87
|
+
else themeProviderParents.set(id, {
|
|
88
|
+
parentId,
|
|
89
|
+
keys
|
|
90
|
+
});
|
|
80
91
|
if (props._themeUpdate) themeUpdateLayers.set(id, props._themeUpdate);
|
|
81
92
|
else themeUpdateLayers.delete(id);
|
|
82
93
|
};
|
|
@@ -111,7 +122,7 @@ Looked for theme${props.name ? ` "${props.name}"` : ""}, but no parent theme con
|
|
|
111
122
|
};
|
|
112
123
|
var id = (0, import_react.useId)();
|
|
113
124
|
var propsKey = `${props.name || ""}${props.forceClassName || ""}${((_props__themeUpdate = props._themeUpdate) === null || _props__themeUpdate === void 0 ? void 0 : _props__themeUpdate.key) || ""}`;
|
|
114
|
-
if (cascadeOnChange) registerThemeProviderChain(id, parentId, props);
|
|
125
|
+
if (cascadeOnChange) registerThemeProviderChain(id, parentId, props, keys);
|
|
115
126
|
var r = (_ref = (0, import_react.useRef)(null)).current || (_ref.current = {
|
|
116
127
|
id,
|
|
117
128
|
optimizeForFirstRender,
|
|
@@ -133,7 +144,7 @@ Looked for theme${props.name ? ` "${props.name}"` : ""}, but no parent theme con
|
|
|
133
144
|
states.set(r.id, r.lastSnap);
|
|
134
145
|
r.state = r.lastSnap;
|
|
135
146
|
}
|
|
136
|
-
if (cascadeOnChange && !themeProviderParents.has(r.id)) registerThemeProviderChain(r.id, r.parentId, r.props);
|
|
147
|
+
if (cascadeOnChange && !themeProviderParents.has(r.id)) registerThemeProviderChain(r.id, r.parentId, r.props, r.keys);
|
|
137
148
|
if (r.unsubscribe && r.subscribedTo !== r.parentId) {
|
|
138
149
|
var _r_unsubscribe;
|
|
139
150
|
(_r_unsubscribe = r.unsubscribe) === null || _r_unsubscribe === void 0 || _r_unsubscribe.call(r);
|
|
@@ -29,6 +29,7 @@ __export(useThemeState_exports, {
|
|
|
29
29
|
getThemeNameCacheSize: () => getThemeNameCacheSize,
|
|
30
30
|
getThemeProviderChainSizes: () => getThemeProviderChainSizes,
|
|
31
31
|
getThemeProviderParent: () => getThemeProviderParent,
|
|
32
|
+
getThemeProviderScope: () => getThemeProviderScope,
|
|
32
33
|
getThemeState: () => getThemeState,
|
|
33
34
|
getThemeUpdateLayer: () => getThemeUpdateLayer,
|
|
34
35
|
hasThemeUpdatingProps: () => hasThemeUpdatingProps,
|
|
@@ -67,7 +68,12 @@ var getThemeUpdateLayer = function getThemeUpdateLayer2(id) {
|
|
|
67
68
|
return themeUpdateLayers.get(id);
|
|
68
69
|
};
|
|
69
70
|
var getThemeProviderParent = function getThemeProviderParent2(id) {
|
|
70
|
-
|
|
71
|
+
var _themeProviderParents_get;
|
|
72
|
+
return (_themeProviderParents_get = themeProviderParents.get(id)) === null || _themeProviderParents_get === void 0 ? void 0 : _themeProviderParents_get.parentId;
|
|
73
|
+
};
|
|
74
|
+
var getThemeProviderScope = function getThemeProviderScope2(id) {
|
|
75
|
+
var _themeProviderParents_get;
|
|
76
|
+
return (_themeProviderParents_get = themeProviderParents.get(id)) === null || _themeProviderParents_get === void 0 ? void 0 : _themeProviderParents_get.keys;
|
|
71
77
|
};
|
|
72
78
|
var getThemeProviderChainSizes = function getThemeProviderChainSizes2() {
|
|
73
79
|
return {
|
|
@@ -75,8 +81,13 @@ var getThemeProviderChainSizes = function getThemeProviderChainSizes2() {
|
|
|
75
81
|
parents: themeProviderParents.size
|
|
76
82
|
};
|
|
77
83
|
};
|
|
78
|
-
var registerThemeProviderChain = function registerThemeProviderChain2(id, parentId, props) {
|
|
79
|
-
themeProviderParents.
|
|
84
|
+
var registerThemeProviderChain = function registerThemeProviderChain2(id, parentId, props, keys) {
|
|
85
|
+
var scope = themeProviderParents.get(id);
|
|
86
|
+
if (scope) scope.parentId = parentId;
|
|
87
|
+
else themeProviderParents.set(id, {
|
|
88
|
+
parentId,
|
|
89
|
+
keys
|
|
90
|
+
});
|
|
80
91
|
if (props._themeUpdate) themeUpdateLayers.set(id, props._themeUpdate);
|
|
81
92
|
else themeUpdateLayers.delete(id);
|
|
82
93
|
};
|
|
@@ -111,7 +122,7 @@ Looked for theme${props.name ? ` "${props.name}"` : ""}, but no parent theme con
|
|
|
111
122
|
};
|
|
112
123
|
var id = (0, import_react.useId)();
|
|
113
124
|
var propsKey = `${props.name || ""}${props.forceClassName || ""}${((_props__themeUpdate = props._themeUpdate) === null || _props__themeUpdate === void 0 ? void 0 : _props__themeUpdate.key) || ""}`;
|
|
114
|
-
if (cascadeOnChange) registerThemeProviderChain(id, parentId, props);
|
|
125
|
+
if (cascadeOnChange) registerThemeProviderChain(id, parentId, props, keys);
|
|
115
126
|
var r = (_ref = (0, import_react.useRef)(null)).current || (_ref.current = {
|
|
116
127
|
id,
|
|
117
128
|
optimizeForFirstRender,
|
|
@@ -133,7 +144,7 @@ Looked for theme${props.name ? ` "${props.name}"` : ""}, but no parent theme con
|
|
|
133
144
|
states.set(r.id, r.lastSnap);
|
|
134
145
|
r.state = r.lastSnap;
|
|
135
146
|
}
|
|
136
|
-
if (cascadeOnChange && !themeProviderParents.has(r.id)) registerThemeProviderChain(r.id, r.parentId, r.props);
|
|
147
|
+
if (cascadeOnChange && !themeProviderParents.has(r.id)) registerThemeProviderChain(r.id, r.parentId, r.props, r.keys);
|
|
137
148
|
if (r.unsubscribe && r.subscribedTo !== r.parentId) {
|
|
138
149
|
var _r_unsubscribe;
|
|
139
150
|
(_r_unsubscribe = r.unsubscribe) === null || _r_unsubscribe === void 0 || _r_unsubscribe.call(r);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useThemeState.native.js","names":[],"sources":["cjs/hooks/useThemeState.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n\tfor (var name in all) __defProp(target, name, {\n\t\tget: all[name],\n\t\tenumerable: true\n\t});\n};\nvar __copyProps = (to, from, except, desc) => {\n\tif (from && typeof from === \"object\" || typeof from === \"function\") {\n\t\tfor (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {\n\t\t\tget: () => from[key],\n\t\t\tenumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable\n\t\t});\n\t}\n\treturn to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar useThemeState_exports = {};\n__export(useThemeState_exports, {\n\tThemeStateContext: () => ThemeStateContext,\n\tforceUpdateThemes: () => forceUpdateThemes,\n\tgetNewThemeName: () => getNewThemeName,\n\tgetRootThemeState: () => getRootThemeState,\n\tgetThemeNameCacheSize: () => getThemeNameCacheSize,\n\tgetThemeProviderChainSizes: () => getThemeProviderChainSizes,\n\tgetThemeProviderParent: () => getThemeProviderParent,\n\tgetThemeState: () => getThemeState,\n\tgetThemeUpdateLayer: () => getThemeUpdateLayer,\n\thasThemeUpdatingProps: () => hasThemeUpdatingProps,\n\tresolveThemeName: () => resolveThemeName,\n\tuseThemeState: () => useThemeState\n});\nmodule.exports = __toCommonJS(useThemeState_exports);\nvar import_constants = require(\"@tamagui/constants\");\nvar import_react = require(\"react\");\nvar import_helpers = require(\"@tamagui/helpers\");\nvar import_config = require(\"../config\");\nvar import_constants2 = require(\"../constants/constants\");\nvar import_themes = require(\"../helpers/themes\");\nvar ThemeStateContext = (0, import_react.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 = (0, import_react.useContext)(ThemeStateContext);\n\tif (!parentId && !isRoot) throw new Error(process.env.NODE_ENV === \"development\" ? `${import_constants2.MISSING_THEME_MESSAGE}\n\nLooked for theme${props.name ? ` \"${props.name}\"` : \"\"}, but no parent theme context was found (parentId: ${parentId}).` : import_constants2.MISSING_THEME_MESSAGE);\n\tif (disable) return states.get(parentId) || {\n\t\tid: \"\",\n\t\tname: \"light\",\n\t\ttheme: (0, import_config.getConfig)().themes.light\n\t};\n\tvar id = (0, import_react.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 = (0, import_react.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] = (0, import_react.useReducer)(incReducer, 0);\n\tvar state = getSnapshotImpl(r);\n\tr.lastSnap = state;\n\t(0, import_react.useEffect)(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) (0, import_constants.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 && import_constants.supportsDynamicColorIOS && (0, import_config.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, (0, import_config.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 = (0, import_config.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 && (0, import_helpers.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: (0, import_config.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 = (0, import_themes.getAuthoredThemeScheme)(themes[resolvedName]) || (0, import_helpers.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, (0, import_config.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 = (0, import_helpers.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//# sourceMappingURL=useThemeState.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC/B,KAAK,IAAI,QAAQ,KAAK,UAAU,QAAQ,MAAM;EAC7C,KAAK,IAAI;EACT,YAAY;CACb,CAAC;AACF;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC7C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EACnE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GAAG,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QAAQ,UAAU,IAAI,KAAK;G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AAQ,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":["cjs/hooks/useThemeState.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n\tfor (var name in all) __defProp(target, name, {\n\t\tget: all[name],\n\t\tenumerable: true\n\t});\n};\nvar __copyProps = (to, from, except, desc) => {\n\tif (from && typeof from === \"object\" || typeof from === \"function\") {\n\t\tfor (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {\n\t\t\tget: () => from[key],\n\t\t\tenumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable\n\t\t});\n\t}\n\treturn to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar useThemeState_exports = {};\n__export(useThemeState_exports, {\n\tThemeStateContext: () => ThemeStateContext,\n\tforceUpdateThemes: () => forceUpdateThemes,\n\tgetNewThemeName: () => getNewThemeName,\n\tgetRootThemeState: () => getRootThemeState,\n\tgetThemeNameCacheSize: () => getThemeNameCacheSize,\n\tgetThemeProviderChainSizes: () => getThemeProviderChainSizes,\n\tgetThemeProviderParent: () => getThemeProviderParent,\n\tgetThemeProviderScope: () => getThemeProviderScope,\n\tgetThemeState: () => getThemeState,\n\tgetThemeUpdateLayer: () => getThemeUpdateLayer,\n\thasThemeUpdatingProps: () => hasThemeUpdatingProps,\n\tresolveThemeName: () => resolveThemeName,\n\tuseThemeState: () => useThemeState\n});\nmodule.exports = __toCommonJS(useThemeState_exports);\nvar import_constants = require(\"@tamagui/constants\");\nvar import_react = require(\"react\");\nvar import_helpers = require(\"@tamagui/helpers\");\nvar import_config = require(\"../config\");\nvar import_constants2 = require(\"../constants/constants\");\nvar import_themes = require(\"../helpers/themes\");\nvar ThemeStateContext = (0, import_react.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 = (0, import_react.useContext)(ThemeStateContext);\n\tif (!parentId && !isRoot) throw new Error(process.env.NODE_ENV === \"development\" ? `${import_constants2.MISSING_THEME_MESSAGE}\n\nLooked for theme${props.name ? ` \"${props.name}\"` : \"\"}, but no parent theme context was found (parentId: ${parentId}).` : import_constants2.MISSING_THEME_MESSAGE);\n\tif (disable) return states.get(parentId) || {\n\t\tid: \"\",\n\t\tname: \"light\",\n\t\ttheme: (0, import_config.getConfig)().themes.light\n\t};\n\tvar id = (0, import_react.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 = (0, import_react.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] = (0, import_react.useReducer)(incReducer, 0);\n\tvar state = getSnapshotImpl(r);\n\tr.lastSnap = state;\n\t(0, import_react.useEffect)(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) (0, import_constants.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 && import_constants.supportsDynamicColorIOS && (0, import_config.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, (0, import_config.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 = (0, import_config.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 && (0, import_helpers.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: (0, import_config.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 = (0, import_themes.getAuthoredThemeScheme)(themes[resolvedName]) || (0, import_helpers.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, (0, import_config.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 = (0, import_helpers.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//# sourceMappingURL=useThemeState.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC/B,KAAK,IAAI,QAAQ,KAAK,UAAU,QAAQ,MAAM;EAC7C,KAAK,IAAI;EACT,YAAY;CACb,CAAC;AACF;AACA,IAAI,e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IAAI,GAAG,cAAc,UAAS,CAAE,CAAC,CAAC,QAAQ,WAAW;CAC9I,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,iBAAiB,GAAG,eAAe,eAAc,CAAE,IAAI;EAC3D,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"}
|
|
@@ -3,7 +3,7 @@ import { isAndroid, isIos } from "@tamagui/constants";
|
|
|
3
3
|
import { use } from "react";
|
|
4
4
|
import { _withStableStyle } from "./_withStableStyle.mjs";
|
|
5
5
|
import { captureNativeStyleRoot, createNativeStyleLinkState, getNativeStyleEngine, linkNativeStyleHost, nativeStyleMountMode, registerNativeStyle, resolveNativeStyleMapping } from "./helpers/nativeStyleEngine.mjs";
|
|
6
|
-
import { ThemeStateContext, getThemeState } from "./hooks/useThemeState.mjs";
|
|
6
|
+
import { ThemeStateContext, getThemeProviderScope, getThemeState } from "./hooks/useThemeState.mjs";
|
|
7
7
|
import { hooks } from "./setupHooks.mjs";
|
|
8
8
|
import { jsx } from "react/jsx-runtime";
|
|
9
9
|
|
|
@@ -29,7 +29,7 @@ const _withNativeStyle = (Component, baseStyle, themeStyleKeys, host) => {
|
|
|
29
29
|
...baseStyle,
|
|
30
30
|
...typeof baseStyle.fontWeight === "number" && { fontWeight: String(baseStyle.fontWeight) }
|
|
31
31
|
} : baseStyle;
|
|
32
|
-
const entries = /* @__PURE__ */ new
|
|
32
|
+
const entries = /* @__PURE__ */ new WeakMap();
|
|
33
33
|
const createEntry = () => {
|
|
34
34
|
const entry = {
|
|
35
35
|
style: [baseStyle, null],
|
|
@@ -48,6 +48,7 @@ const _withNativeStyle = (Component, baseStyle, themeStyleKeys, host) => {
|
|
|
48
48
|
const ScopeContext = ThemeStateContext;
|
|
49
49
|
const engineOf = getNativeStyleEngine;
|
|
50
50
|
const scopeState = getThemeState;
|
|
51
|
+
const scopeOwner = getThemeProviderScope;
|
|
51
52
|
const resolve = resolveNativeStyleMapping;
|
|
52
53
|
const linkState = createNativeStyleLinkState;
|
|
53
54
|
const linkHost = linkNativeStyleHost;
|
|
@@ -59,8 +60,9 @@ const _withNativeStyle = (Component, baseStyle, themeStyleKeys, host) => {
|
|
|
59
60
|
const scopeId = use(ScopeContext);
|
|
60
61
|
const inText = TextAncestor ? use(TextAncestor) : false;
|
|
61
62
|
const themeState = scopeId && engineOf() ? scopeState(scopeId) : void 0;
|
|
63
|
+
const owner = scopeOwner(scopeId);
|
|
62
64
|
const resetsText = inText && host === "view";
|
|
63
|
-
if (!themeState) {
|
|
65
|
+
if (!themeState || !owner) {
|
|
64
66
|
return resetsText ? /* @__PURE__ */ jsx(TextAncestorProvider, {
|
|
65
67
|
value: false,
|
|
66
68
|
children: /* @__PURE__ */ jsx(Fallback, { ...props })
|
|
@@ -75,10 +77,10 @@ const _withNativeStyle = (Component, baseStyle, themeStyleKeys, host) => {
|
|
|
75
77
|
const { name, theme } = themeState;
|
|
76
78
|
const asHostText = HostText && !inText;
|
|
77
79
|
const Rendered = asHostText ? HostText : Component;
|
|
78
|
-
let entry = entries.get(
|
|
80
|
+
let entry = entries.get(owner);
|
|
79
81
|
if (!entry) {
|
|
80
82
|
entry = createEntry();
|
|
81
|
-
entries.set(
|
|
83
|
+
entries.set(owner, entry);
|
|
82
84
|
}
|
|
83
85
|
if (entry.stateName !== name || entry.theme !== theme) {
|
|
84
86
|
const themed = resolve(themeStyleKeys, name, theme);
|
|
@@ -114,7 +116,7 @@ const _withNativeStyle = (Component, baseStyle, themeStyleKeys, host) => {
|
|
|
114
116
|
}, key);
|
|
115
117
|
};
|
|
116
118
|
const NativeStyleView = (props) => render(props);
|
|
117
|
-
NativeStyleView.inline = (element) => render(element.props, element.key);
|
|
119
|
+
NativeStyleView.inline = (element) => render(element.props, element.key ?? void 0);
|
|
118
120
|
return NativeStyleView;
|
|
119
121
|
};
|
|
120
122
|
function omitRef(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_withNativeStyle.js","names":[],"sources":["esm/_withNativeStyle.js"],"sourcesContent":["import { setRef } from \"@tamagui/compose-refs\";\nimport { isAndroid, isIos } from \"@tamagui/constants\";\nimport { use } from \"react\";\nimport { _withStableStyle } from \"./_withStableStyle\";\nimport {\n captureNativeStyleRoot,\n createNativeStyleLinkState,\n getNativeStyleEngine,\n linkNativeStyleHost,\n nativeStyleMountMode,\n registerNativeStyle,\n resolveNativeStyleMapping\n} from \"./helpers/nativeStyleEngine\";\nimport {
|
|
1
|
+
{"version":3,"file":"_withNativeStyle.js","names":[],"sources":["esm/_withNativeStyle.js"],"sourcesContent":["import { setRef } from \"@tamagui/compose-refs\";\nimport { isAndroid, isIos } from \"@tamagui/constants\";\nimport { use } from \"react\";\nimport { _withStableStyle } from \"./_withStableStyle\";\nimport {\n captureNativeStyleRoot,\n createNativeStyleLinkState,\n getNativeStyleEngine,\n linkNativeStyleHost,\n nativeStyleMountMode,\n registerNativeStyle,\n resolveNativeStyleMapping\n} from \"./helpers/nativeStyleEngine\";\nimport {\n getThemeProviderScope,\n getThemeState,\n ThemeStateContext\n} from \"./hooks/useThemeState\";\nimport { hooks } from \"./setupHooks\";\nimport { jsx } from \"react/jsx-runtime\";\nconst hostTextProps = {\n accessible: isAndroid ? false : isIos ? true : void 0,\n allowFontScaling: true,\n ellipsizeMode: \"tail\"\n};\nconst _withNativeStyle = (Component, baseStyle, themeStyleKeys, host) => {\n const Fallback = _withStableStyle(\n Component,\n (theme) => {\n const themedStyle = {};\n for (const styleKey in themeStyleKeys) {\n themedStyle[styleKey] = theme[themeStyleKeys[styleKey]]?.get();\n }\n return [baseStyle, themedStyle];\n },\n true,\n false\n );\n const baseViews = host ? hooks.getBaseViews?.() : void 0;\n const TextAncestor = baseViews?.TextAncestor;\n const TextAncestorProvider = TextAncestor?.Provider;\n const HostText = host === \"text\" && !(\"userSelect\" in baseStyle) && !(\"verticalAlign\" in baseStyle) ? baseViews?.NativeText : void 0;\n const hostTextBase = HostText ? {\n overflow: \"hidden\",\n ...baseStyle,\n ...typeof baseStyle.fontWeight === \"number\" && {\n fontWeight: String(baseStyle.fontWeight)\n }\n } : baseStyle;\n const entries = /* @__PURE__ */ new WeakMap();\n const createEntry = () => {\n const entry = {\n style: [baseStyle, null],\n hostTextStyle: [hostTextBase, null],\n stateName: \"\",\n theme: null,\n state: null,\n ref: (node) => {\n if (!node) return;\n captureRoot(node);\n linkHost(node, entry.state);\n }\n };\n return entry;\n };\n const ScopeContext = ThemeStateContext;\n const engineOf = getNativeStyleEngine;\n const scopeState = getThemeState;\n const scopeOwner = getThemeProviderScope;\n const resolve = resolveNativeStyleMapping;\n const linkState = createNativeStyleLinkState;\n const linkHost = linkNativeStyleHost;\n const registerStyle = registerNativeStyle;\n const mountMode = nativeStyleMountMode;\n const captureRoot = captureNativeStyleRoot;\n const assignRef = setRef;\n const render = (props, key) => {\n const scopeId = use(ScopeContext);\n const inText = TextAncestor ? use(TextAncestor) : false;\n const themeState = scopeId && engineOf() ? scopeState(scopeId) : void 0;\n const owner = scopeOwner(scopeId);\n const resetsText = inText && host === \"view\";\n if (!themeState || !owner) {\n return resetsText ? /* @__PURE__ */ jsx(TextAncestorProvider, { value: false, children: /* @__PURE__ */ jsx(Fallback, { ...props }) }, key) : /* @__PURE__ */ jsx(Fallback, { ...props }, key);\n }\n let rest = props;\n if (props._expressions !== void 0) {\n const { _expressions: _ignoredExpressions, ...withoutExpressions } = props;\n rest = withoutExpressions;\n }\n const ref = props.ref;\n const { name, theme } = themeState;\n const asHostText = HostText && !inText;\n const Rendered = asHostText ? HostText : Component;\n let entry = entries.get(owner);\n if (!entry) {\n entry = createEntry();\n entries.set(owner, entry);\n }\n if (entry.stateName !== name || entry.theme !== theme) {\n const themed = resolve(themeStyleKeys, name, theme);\n entry.style = [baseStyle, themed];\n entry.hostTextStyle = [hostTextBase, themed];\n entry.stateName = name;\n entry.theme = theme;\n entry.state = linkState(themeStyleKeys, scopeId, name, theme);\n registerStyle(entry.style, entry.state);\n registerStyle(entry.hostTextStyle, entry.state);\n }\n const style = asHostText ? entry.hostTextStyle : entry.style;\n const wrapped = resetsText || asHostText && mayRenderText(rest.children);\n const state = entry.state;\n const discover = mountMode() === \"discover\";\n const passedRef = discover ? ref ?? null : ref == null ? entry.ref : (node) => {\n if (!node) return assignRef(ref, null);\n captureRoot(node);\n linkHost(node, state);\n if (typeof ref === \"function\") return ref(node);\n assignRef(ref, node);\n };\n const element = /* @__PURE__ */ jsx(\n Rendered,\n {\n ...asHostText && hostTextProps,\n ...passedRef == null ? omitRef(rest) : rest,\n ...passedRef != null ? { ref: passedRef } : null,\n style\n },\n wrapped ? void 0 : key\n );\n if (!wrapped) return element;\n return /* @__PURE__ */ jsx(TextAncestorProvider, { value: !resetsText, children: element }, key);\n };\n const NativeStyleView = (props) => render(props);\n NativeStyleView.inline = (element) => render(element.props, element.key ?? void 0);\n return NativeStyleView;\n};\nfunction omitRef(props) {\n if (!Object.prototype.hasOwnProperty.call(props, \"ref\")) return props;\n const { ref: _ref, ...rest } = props;\n return rest;\n}\nfunction mayRenderText(children) {\n if (children == null) return false;\n if (Array.isArray(children) && children.length <= 3) {\n return children.some((child) => child != null && typeof child === \"object\");\n }\n return typeof children === \"object\";\n}\nexport {\n _withNativeStyle\n};\n//# sourceMappingURL=_withNativeStyle.js.map\n"],"mappings":";;;;;;;;;;AAoBA,MAAM,gBAAgB;CACpB,YAAY,YAAY,QAAQ,QAAQ,OAAO,KAAK;CACpD,kBAAkB;CAClB,eAAe;AACjB;AACA,MAAM,oBAAoB,WAAW,WAAW,gBAAgB,SAAS;CACvE,MAAM,WAAW,iBACf,YACC,UAAU;EACT,MAAM,cAAc,CAAC;EACrB,KAAK,MAAM,YAAY,gBAAgB;GACrC,YAAY,YAAY,MAAM,eAAe,UAAU,EAAE,IAAI;EAC/D;EACA,OAAO,CAAC,WAAW,WAAW;CAChC,GACA,MACA,KACF;CACA,MAAM,YAAY,OAAO,MAAM,eAAe,IAAI,KAAK;CACvD,MAAM,eAAe,WAAW;CAChC,MAAM,uBAAuB,cAAc;CAC3C,MAAM,WAAW,SAAS,UAAU,EAAE,gBAAgB,cAAc,EAAE,mBAAmB,aAAa,WAAW,aAAa,KAAK;CACnI,MAAM,eAAe,WAAW;EAC9B,UAAU;EACV,GAAG;EACH,GAAG,OAAO,UAAU,eAAe,YAAY,EAC7C,YAAY,OAAO,UAAU,UAAU,EACzC;CACF,IAAI;CACJ,MAAM,0BAA0B,IAAI,QAAQ;CAC5C,MAAM,oBAAoB;EACxB,MAAM,QAAQ;GACZ,OAAO,CAAC,WAAW,IAAI;GACvB,eAAe,CAAC,cAAc,IAAI;GAClC,WAAW;GACX,OAAO;GACP,OAAO;GACP,MAAM,SAAS;IACb,IAAI,CAAC,MAAM;IACX,YAAY,IAAI;IAChB,SAAS,MAAM,MAAM,KAAK;GAC5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O,UAAU,QAAQ;CAC5E;CACA,OAAO,OAAO,aAAa;AAC7B"}
|
|
@@ -4,7 +4,7 @@ import { isAndroid, isIos } from "@tamagui/constants";
|
|
|
4
4
|
import { use } from "react";
|
|
5
5
|
import { _withStableStyle } from "./_withStableStyle.native.js";
|
|
6
6
|
import { captureNativeStyleRoot, createNativeStyleLinkState, getNativeStyleEngine, linkNativeStyleHost, nativeStyleMountMode, registerNativeStyle, resolveNativeStyleMapping } from "./helpers/nativeStyleEngine.native.js";
|
|
7
|
-
import { ThemeStateContext, getThemeState } from "./hooks/useThemeState.native.js";
|
|
7
|
+
import { ThemeStateContext, getThemeProviderScope, getThemeState } from "./hooks/useThemeState.native.js";
|
|
8
8
|
import { hooks } from "./setupHooks.native.js";
|
|
9
9
|
|
|
10
10
|
var hostTextProps = {
|
|
@@ -31,7 +31,7 @@ var _withNativeStyle = function _withNativeStyle2(Component, baseStyle, themeSty
|
|
|
31
31
|
...baseStyle,
|
|
32
32
|
...typeof baseStyle.fontWeight === "number" && { fontWeight: String(baseStyle.fontWeight) }
|
|
33
33
|
} : baseStyle;
|
|
34
|
-
var entries = /* @__PURE__ */ new
|
|
34
|
+
var entries = /* @__PURE__ */ new WeakMap();
|
|
35
35
|
var createEntry = function createEntry2() {
|
|
36
36
|
var entry = {
|
|
37
37
|
style: [baseStyle, null],
|
|
@@ -50,6 +50,7 @@ var _withNativeStyle = function _withNativeStyle2(Component, baseStyle, themeSty
|
|
|
50
50
|
var ScopeContext = ThemeStateContext;
|
|
51
51
|
var engineOf = getNativeStyleEngine;
|
|
52
52
|
var scopeState = getThemeState;
|
|
53
|
+
var scopeOwner = getThemeProviderScope;
|
|
53
54
|
var resolve = resolveNativeStyleMapping;
|
|
54
55
|
var linkState = createNativeStyleLinkState;
|
|
55
56
|
var linkHost = linkNativeStyleHost;
|
|
@@ -61,8 +62,9 @@ var _withNativeStyle = function _withNativeStyle2(Component, baseStyle, themeSty
|
|
|
61
62
|
var scopeId = use(ScopeContext);
|
|
62
63
|
var inText = TextAncestor ? use(TextAncestor) : false;
|
|
63
64
|
var themeState = scopeId && engineOf() ? scopeState(scopeId) : void 0;
|
|
65
|
+
var owner = scopeOwner(scopeId);
|
|
64
66
|
var resetsText = inText && host === "view";
|
|
65
|
-
if (!themeState) {
|
|
67
|
+
if (!themeState || !owner) {
|
|
66
68
|
return resetsText ? /* @__PURE__ */ jsx(TextAncestorProvider, {
|
|
67
69
|
value: false,
|
|
68
70
|
children: /* @__PURE__ */ jsx(Fallback, { ...props })
|
|
@@ -77,10 +79,10 @@ var _withNativeStyle = function _withNativeStyle2(Component, baseStyle, themeSty
|
|
|
77
79
|
var { name, theme } = themeState;
|
|
78
80
|
var asHostText = HostText && !inText;
|
|
79
81
|
var Rendered = asHostText ? HostText : Component;
|
|
80
|
-
var entry = entries.get(
|
|
82
|
+
var entry = entries.get(owner);
|
|
81
83
|
if (!entry) {
|
|
82
84
|
entry = createEntry();
|
|
83
|
-
entries.set(
|
|
85
|
+
entries.set(owner, entry);
|
|
84
86
|
}
|
|
85
87
|
if (entry.stateName !== name || entry.theme !== theme) {
|
|
86
88
|
var themed = resolve(themeStyleKeys, name, theme);
|
|
@@ -119,7 +121,8 @@ var _withNativeStyle = function _withNativeStyle2(Component, baseStyle, themeSty
|
|
|
119
121
|
return render(props);
|
|
120
122
|
};
|
|
121
123
|
NativeStyleView.inline = function(element) {
|
|
122
|
-
|
|
124
|
+
var _element_key;
|
|
125
|
+
return render(element.props, (_element_key = element.key) !== null && _element_key !== void 0 ? _element_key : void 0);
|
|
123
126
|
};
|
|
124
127
|
return NativeStyleView;
|
|
125
128
|
};
|