@tamagui/theme 3.0.0-beta.765.1 → 3.0.0-beta.804.1
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/_mutateTheme.cjs +4 -3
- package/dist/cjs/_mutateTheme.native.cjs +3 -2
- package/dist/cjs/_mutateTheme.native.js +3 -2
- package/dist/cjs/_mutateTheme.native.js.map +1 -1
- package/dist/esm/_mutateTheme.mjs +2 -1
- package/dist/esm/_mutateTheme.mjs.map +1 -1
- package/dist/esm/_mutateTheme.native.js +2 -1
- package/dist/esm/_mutateTheme.native.js.map +1 -1
- package/package.json +5 -5
- package/src/_mutateTheme.ts +10 -4
- package/types/_mutateTheme.d.ts +1 -1
- package/types/_mutateTheme.d.ts.map +1 -1
- package/types/addTheme.d.ts +1 -1
- package/types/replaceTheme.d.ts +1 -1
- package/types/updateTheme.d.ts +1 -1
|
@@ -27,6 +27,7 @@ module.exports = __toCommonJS(mutateTheme_exports);
|
|
|
27
27
|
var import_constants = require("@tamagui/constants");
|
|
28
28
|
var import_start_transition = require("@tamagui/start-transition");
|
|
29
29
|
var import_web = require("@tamagui/web");
|
|
30
|
+
var import_internal_runtime = require("@tamagui/web/internal-runtime");
|
|
30
31
|
function mutateThemes({ themes, batch, insertCSS = true, ...props }) {
|
|
31
32
|
const allThemesProxied = {};
|
|
32
33
|
const allThemesRaw = {};
|
|
@@ -70,8 +71,8 @@ function _mutateTheme(props) {
|
|
|
70
71
|
...mutationType === "update" ? config.themes[themeName] ?? {} : {},
|
|
71
72
|
...themeIn
|
|
72
73
|
};
|
|
73
|
-
for (const key in theme) (0,
|
|
74
|
-
const themeProxied = (0,
|
|
74
|
+
for (const key in theme) (0, import_internal_runtime.ensureThemeVariable)(theme, key);
|
|
75
|
+
const themeProxied = (0, import_internal_runtime.proxyThemeToParents)(themeName, theme);
|
|
75
76
|
const response = {
|
|
76
77
|
themeRaw: theme,
|
|
77
78
|
theme: themeProxied,
|
|
@@ -94,7 +95,7 @@ function insertThemeCSS(themes, batch = false) {
|
|
|
94
95
|
let cssRules = [];
|
|
95
96
|
for (const themeName in themes) {
|
|
96
97
|
const theme = themes[themeName];
|
|
97
|
-
const rules = (0,
|
|
98
|
+
const rules = (0, import_internal_runtime.getThemeCSSRules)({
|
|
98
99
|
config,
|
|
99
100
|
themeName,
|
|
100
101
|
names: [themeName],
|
|
@@ -29,6 +29,7 @@ module.exports = __toCommonJS(mutateTheme_exports);
|
|
|
29
29
|
var import_constants = require("@tamagui/constants");
|
|
30
30
|
var import_start_transition = require("@tamagui/start-transition");
|
|
31
31
|
var import_web = require("@tamagui/web");
|
|
32
|
+
var import_internal_runtime = require("@tamagui/web/internal-runtime");
|
|
32
33
|
function mutateThemes(param) {
|
|
33
34
|
var { themes, batch, insertCSS = true, ...props } = param;
|
|
34
35
|
var allThemesProxied = {};
|
|
@@ -87,8 +88,8 @@ function _mutateTheme(props) {
|
|
|
87
88
|
...mutationType === "update" ? (_config_themes_themeName = config.themes[themeName]) !== null && _config_themes_themeName !== void 0 ? _config_themes_themeName : {} : {},
|
|
88
89
|
...themeIn
|
|
89
90
|
};
|
|
90
|
-
for (var key in theme1) (0,
|
|
91
|
-
var themeProxied = (0,
|
|
91
|
+
for (var key in theme1) (0, import_internal_runtime.ensureThemeVariable)(theme1, key);
|
|
92
|
+
var themeProxied = (0, import_internal_runtime.proxyThemeToParents)(themeName, theme1);
|
|
92
93
|
var response = {
|
|
93
94
|
themeRaw: theme1,
|
|
94
95
|
theme: themeProxied,
|
|
@@ -29,6 +29,7 @@ module.exports = __toCommonJS(mutateTheme_exports);
|
|
|
29
29
|
var import_constants = require("@tamagui/constants");
|
|
30
30
|
var import_start_transition = require("@tamagui/start-transition");
|
|
31
31
|
var import_web = require("@tamagui/web");
|
|
32
|
+
var import_internal_runtime = require("@tamagui/web/internal-runtime");
|
|
32
33
|
function mutateThemes(param) {
|
|
33
34
|
var { themes, batch, insertCSS = true, ...props } = param;
|
|
34
35
|
var allThemesProxied = {};
|
|
@@ -87,8 +88,8 @@ function _mutateTheme(props) {
|
|
|
87
88
|
...mutationType === "update" ? (_config_themes_themeName = config.themes[themeName]) !== null && _config_themes_themeName !== void 0 ? _config_themes_themeName : {} : {},
|
|
88
89
|
...themeIn
|
|
89
90
|
};
|
|
90
|
-
for (var key in theme1) (0,
|
|
91
|
-
var themeProxied = (0,
|
|
91
|
+
for (var key in theme1) (0, import_internal_runtime.ensureThemeVariable)(theme1, key);
|
|
92
|
+
var themeProxied = (0, import_internal_runtime.proxyThemeToParents)(themeName, theme1);
|
|
92
93
|
var response = {
|
|
93
94
|
themeRaw: theme1,
|
|
94
95
|
theme: themeProxied,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_mutateTheme.native.js","names":[],"sources":["cjs/_mutateTheme.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 mutateTheme_exports = {};\n__export(mutateTheme_exports, {\n\t_mutateTheme: () => _mutateTheme,\n\tmutateThemes: () => mutateThemes\n});\nmodule.exports = __toCommonJS(mutateTheme_exports);\nvar import_constants = require(\"@tamagui/constants\");\nvar import_start_transition = require(\"@tamagui/start-transition\");\nvar import_web = require(\"@tamagui/web\");\nfunction mutateThemes(param) {\n\tvar { themes, batch, insertCSS = true, ...props } = param;\n\tvar allThemesProxied = {};\n\tvar allThemesRaw = {};\n\tvar _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n\ttry {\n\t\tfor (var _iterator = themes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n\t\t\tvar { name, theme } = _step.value;\n\t\t\tvar res = _mutateTheme({\n\t\t\t\t...props,\n\t\t\t\tname,\n\t\t\t\ttheme,\n\t\t\t\tavoidUpdate: true,\n\t\t\t\tmutationType: \"add\"\n\t\t\t});\n\t\t\tif (res) {\n\t\t\t\tallThemesProxied[name] = res.theme;\n\t\t\t\tallThemesRaw[name] = res.themeRaw;\n\t\t\t}\n\t\t}\n\t} catch (err) {\n\t\t_didIteratorError = true;\n\t\t_iteratorError = err;\n\t} finally {\n\t\ttry {\n\t\t\tif (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();\n\t\t} finally {\n\t\t\tif (_didIteratorError) throw _iteratorError;\n\t\t}\n\t}\n\tvar cssRules = insertCSS ? insertThemeCSS(allThemesRaw, batch) : [];\n\t(0, import_start_transition.startTransition)(function() {\n\t\t(0, import_web.updateConfig)(\"themes\", allThemesProxied);\n\t\tupdateThemeStates();\n\t});\n\treturn {\n\t\tthemes: allThemesProxied,\n\t\tthemesRaw: allThemesRaw,\n\t\tcssRules\n\t};\n}\nfunction _mutateTheme(props) {\n\tif (import_constants.isServer) {\n\t\tif (process.env.NODE_ENV === \"development\") console.warn(\"Theme mutation is not supported on server side\");\n\t\treturn;\n\t}\n\tvar config = (0, import_web.getConfig)();\n\tvar { name: themeName, theme: themeIn, insertCSS, mutationType } = props;\n\tif (process.env.NODE_ENV === \"development\") {\n\t\tif (!config) throw new Error(\"No config\");\n\t\tvar theme = config.themes[props.name];\n\t\tif (mutationType !== \"add\" && !theme) throw new Error(`${mutationType === \"replace\" ? \"Replace\" : \"Update\"} theme failed! Theme ${props.name} does not exist`);\n\t}\n\tvar _config_themes_themeName;\n\tvar theme1 = {\n\t\t...mutationType === \"update\" ? (_config_themes_themeName = config.themes[themeName]) !== null && _config_themes_themeName !== void 0 ? _config_themes_themeName : {} : {},\n\t\t...themeIn\n\t};\n\tfor (var key in theme1) (0,
|
|
1
|
+
{"version":3,"file":"_mutateTheme.native.js","names":[],"sources":["cjs/_mutateTheme.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 mutateTheme_exports = {};\n__export(mutateTheme_exports, {\n\t_mutateTheme: () => _mutateTheme,\n\tmutateThemes: () => mutateThemes\n});\nmodule.exports = __toCommonJS(mutateTheme_exports);\nvar import_constants = require(\"@tamagui/constants\");\nvar import_start_transition = require(\"@tamagui/start-transition\");\nvar import_web = require(\"@tamagui/web\");\nvar import_internal_runtime = require(\"@tamagui/web/internal-runtime\");\nfunction mutateThemes(param) {\n\tvar { themes, batch, insertCSS = true, ...props } = param;\n\tvar allThemesProxied = {};\n\tvar allThemesRaw = {};\n\tvar _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n\ttry {\n\t\tfor (var _iterator = themes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n\t\t\tvar { name, theme } = _step.value;\n\t\t\tvar res = _mutateTheme({\n\t\t\t\t...props,\n\t\t\t\tname,\n\t\t\t\ttheme,\n\t\t\t\tavoidUpdate: true,\n\t\t\t\tmutationType: \"add\"\n\t\t\t});\n\t\t\tif (res) {\n\t\t\t\tallThemesProxied[name] = res.theme;\n\t\t\t\tallThemesRaw[name] = res.themeRaw;\n\t\t\t}\n\t\t}\n\t} catch (err) {\n\t\t_didIteratorError = true;\n\t\t_iteratorError = err;\n\t} finally {\n\t\ttry {\n\t\t\tif (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();\n\t\t} finally {\n\t\t\tif (_didIteratorError) throw _iteratorError;\n\t\t}\n\t}\n\tvar cssRules = insertCSS ? insertThemeCSS(allThemesRaw, batch) : [];\n\t(0, import_start_transition.startTransition)(function() {\n\t\t(0, import_web.updateConfig)(\"themes\", allThemesProxied);\n\t\tupdateThemeStates();\n\t});\n\treturn {\n\t\tthemes: allThemesProxied,\n\t\tthemesRaw: allThemesRaw,\n\t\tcssRules\n\t};\n}\nfunction _mutateTheme(props) {\n\tif (import_constants.isServer) {\n\t\tif (process.env.NODE_ENV === \"development\") console.warn(\"Theme mutation is not supported on server side\");\n\t\treturn;\n\t}\n\tvar config = (0, import_web.getConfig)();\n\tvar { name: themeName, theme: themeIn, insertCSS, mutationType } = props;\n\tif (process.env.NODE_ENV === \"development\") {\n\t\tif (!config) throw new Error(\"No config\");\n\t\tvar theme = config.themes[props.name];\n\t\tif (mutationType !== \"add\" && !theme) throw new Error(`${mutationType === \"replace\" ? \"Replace\" : \"Update\"} theme failed! Theme ${props.name} does not exist`);\n\t}\n\tvar _config_themes_themeName;\n\tvar theme1 = {\n\t\t...mutationType === \"update\" ? (_config_themes_themeName = config.themes[themeName]) !== null && _config_themes_themeName !== void 0 ? _config_themes_themeName : {} : {},\n\t\t...themeIn\n\t};\n\tfor (var key in theme1) (0, import_internal_runtime.ensureThemeVariable)(theme1, key);\n\tvar themeProxied = (0, import_internal_runtime.proxyThemeToParents)(themeName, theme1);\n\tvar response = {\n\t\tthemeRaw: theme1,\n\t\ttheme: themeProxied,\n\t\tcssRules: []\n\t};\n\tif (props.avoidUpdate) return response;\n\tif (insertCSS) response.cssRules = insertThemeCSS({ [themeName]: theme1 });\n\tupdateThemeConfig(themeName, themeProxied);\n\tupdateThemeStates();\n\treturn response;\n}\nfunction updateThemeConfig(themeName, theme) {\n\t(0, import_web.updateConfig)(\"themes\", { [themeName]: theme });\n}\nfunction updateThemeStates() {\n\t(0, import_web.forceUpdateThemes)();\n}\nfunction insertThemeCSS(themes) {\n\targuments.length > 1 && arguments[1] !== void 0 && arguments[1];\n\treturn [];\n}\n//# sourceMappingURL=_mutateTheme.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;GAC9G,WAAW,KAAK;GAChB,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAC3D,CAAC;CACF;CACA,OAAO;AACR;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,sBAAsB,CAAC;AAC3B,SAAS,qBAAqB;CAC7B,oBAAo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transition";
|
|
3
|
-
import {
|
|
3
|
+
import { forceUpdateThemes, getConfig, getMutatedAutoVariableCSS, simpleHash, updateConfig } from "@tamagui/web";
|
|
4
|
+
import { ensureThemeVariable, getThemeCSSRules, proxyThemeToParents } from "@tamagui/web/internal-runtime";
|
|
4
5
|
|
|
5
6
|
function mutateThemes({ themes, batch, insertCSS = true, ...props }) {
|
|
6
7
|
const allThemesProxied = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_mutateTheme.js","names":[],"sources":["esm/_mutateTheme.js"],"sourcesContent":["import { isServer } from \"@tamagui/constants\";\nimport { startTransition } from \"@tamagui/start-transition\";\nimport {
|
|
1
|
+
{"version":3,"file":"_mutateTheme.js","names":[],"sources":["esm/_mutateTheme.js"],"sourcesContent":["import { isServer } from \"@tamagui/constants\";\nimport { startTransition } from \"@tamagui/start-transition\";\nimport { forceUpdateThemes, getConfig, getMutatedAutoVariableCSS, simpleHash, updateConfig } from \"@tamagui/web\";\nimport { ensureThemeVariable, getThemeCSSRules, proxyThemeToParents } from \"@tamagui/web/internal-runtime\";\n\nfunction mutateThemes({ themes, batch, insertCSS = true, ...props }) {\n\tconst allThemesProxied = {};\n\tconst allThemesRaw = {};\n\tfor (const { name, theme } of themes) {\n\t\tconst res = _mutateTheme({\n\t\t\t...props,\n\t\t\tname,\n\t\t\ttheme,\n\t\t\tavoidUpdate: true,\n\t\t\tmutationType: \"add\"\n\t\t});\n\t\tif (res) {\n\t\t\tallThemesProxied[name] = res.theme;\n\t\t\tallThemesRaw[name] = res.themeRaw;\n\t\t}\n\t}\n\tconst cssRules = insertCSS ? insertThemeCSS(allThemesRaw, batch) : [];\n\tstartTransition(() => {\n\t\tupdateConfig(\"themes\", allThemesProxied);\n\t\tupdateThemeStates();\n\t});\n\treturn {\n\t\tthemes: allThemesProxied,\n\t\tthemesRaw: allThemesRaw,\n\t\tcssRules\n\t};\n}\nfunction _mutateTheme(props) {\n\tif (isServer) {\n\t\tif (process.env.NODE_ENV === \"development\") console.warn(\"Theme mutation is not supported on server side\");\n\t\treturn;\n\t}\n\tconst config = getConfig();\n\tconst { name: themeName, theme: themeIn, insertCSS, mutationType } = props;\n\tif (process.env.NODE_ENV === \"development\") {\n\t\tif (!config) throw new Error(\"No config\");\n\t\tconst theme2 = config.themes[props.name];\n\t\tif (mutationType !== \"add\" && !theme2) throw new Error(`${mutationType === \"replace\" ? \"Replace\" : \"Update\"} theme failed! Theme ${props.name} does not exist`);\n\t}\n\tconst theme = {\n\t\t...mutationType === \"update\" ? config.themes[themeName] ?? {} : {},\n\t\t...themeIn\n\t};\n\tfor (const key in theme) ensureThemeVariable(theme, key);\n\tconst themeProxied = proxyThemeToParents(themeName, theme);\n\tconst response = {\n\t\tthemeRaw: theme,\n\t\ttheme: themeProxied,\n\t\tcssRules: []\n\t};\n\tif (props.avoidUpdate) return response;\n\tif (insertCSS) response.cssRules = insertThemeCSS({ [themeName]: theme });\n\tupdateThemeConfig(themeName, themeProxied);\n\tupdateThemeStates();\n\treturn response;\n}\nfunction updateThemeConfig(themeName, theme) {\n\tupdateConfig(\"themes\", { [themeName]: theme });\n}\nfunction updateThemeStates() {\n\tforceUpdateThemes();\n}\nfunction insertThemeCSS(themes, batch = false) {\n\tconst config = getConfig();\n\tlet cssRules = [];\n\tfor (const themeName in themes) {\n\t\tconst theme = themes[themeName];\n\t\tconst rules = getThemeCSSRules({\n\t\t\tconfig,\n\t\t\tthemeName,\n\t\t\tnames: [themeName],\n\t\t\thasDarkLight: true,\n\t\t\ttheme,\n\t\t\tuseMutatedVariables: true\n\t\t});\n\t\tcssRules = [...cssRules, ...rules];\n\t\tif (!batch) updateStyle(`t_theme_style_${themeName}`, rules);\n\t}\n\tconst mutatedAutoVariableCSS = getMutatedAutoVariableCSS();\n\tif (mutatedAutoVariableCSS) updateStyle(`t_mutate_vars`, [`:root{${mutatedAutoVariableCSS}}`]);\n\tif (batch) updateStyle(`t_theme_style_${typeof batch == \"string\" ? batch : simpleHash(Object.keys(themes).join(\"\"))}`, cssRules);\n\treturn cssRules;\n}\nfunction updateStyle(id, rules) {\n\tconst existing = document.querySelector(`#${id}`);\n\tconst style = document.createElement(\"style\");\n\tstyle.id = id;\n\tstyle.appendChild(document.createTextNode(rules.join(\"\\n\")));\n\tdocument.head.appendChild(style);\n\tif (existing) existing.parentElement?.removeChild(existing);\n}\n\nexport { _mutateTheme, mutateThemes };"],"mappings":";;;;;;AAKA,SAAS,aAAa,EAAE,QAAQ,OAAO,YAAY,MAAM,GAAG,SAAS;CACpE,MAAM,mBAAmB,CAAC;CAC1B,MAAM,eAAe,CAAC;CACtB,KAAK,MAAM,EAAE,MAAM,WAAW,QAAQ;EACrC,MAAM,MAAM,aAAa;GACxB,GAAG;GACH;GACA;GACA,aAAa;GACb,cAAc;EACf,CAAC;EACD,IAAI,KAAK;GACR,iBAAiB,QAAQ,IAAI;GAC7B,aAAa,QAAQ,IAAI;EAC1B;CACD;CACA,MAAM,WAAW,YAAY,eAAe,cAAc,KAAK,IAAI,CAAC;CACpE,sBAAsB;EACrB,aAAa,UAAU,gBAAgB;EACvC,kBAAkB;CACnB,CAAC;CACD,OAAO;EACN,QAAQ;EACR,WAAW;EACX;CACD;AACD;AACA,SAAS,aAAa,OAAO;CAC5B,IAAI,UAAU;EACb,IAAI,QAAQ,IAAI,aAAa,eAAe,QAAQ,KAAK,gDAAgD;EACzG;CACD;CACA,MAAM,SAAS,UAAU;CACzB,MAAM,EAAE,MAAM,WAAW,OAAO,SAAS,WAAW,iBAAiB;CACrE,IAAI,QAAQ,IAAI,aAAa,eAAe;EAC3C,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,WAAW;EACxC,MAAM,SAAS,OAAO,OAAO,MAAM;EACnC,IAAI,iBAAiB,SAAS,CAAC,QAAQ,MAAM,IAAI,MAAM,GAAG,iBAAiB,YAAY,YAAY,SAAS,uBAAuB,MAAM,KAAK,gBAAgB;CAC/J;CACA,MAAM,QAAQ;EACb,GAAG,iBAAiB,WAAW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K,IAAI,CAAC,CAAC;CAC3D,SAAS,KAAK,YAAY,KAAK;CAC/B,IAAI,UAAU,SAAS,eAAe,YAAY,QAAQ;AAC3D"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isServer } from "@tamagui/constants";
|
|
2
2
|
import { startTransition } from "@tamagui/start-transition";
|
|
3
|
-
import {
|
|
3
|
+
import { forceUpdateThemes, getConfig, updateConfig } from "@tamagui/web";
|
|
4
|
+
import { ensureThemeVariable, proxyThemeToParents } from "@tamagui/web/internal-runtime";
|
|
4
5
|
|
|
5
6
|
function mutateThemes(param) {
|
|
6
7
|
var { themes, batch, insertCSS = true, ...props } = param;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_mutateTheme.native.js","names":[],"sources":["esm/_mutateTheme.native.js"],"sourcesContent":["import { isServer } from \"@tamagui/constants\";\nimport { startTransition } from \"@tamagui/start-transition\";\nimport {
|
|
1
|
+
{"version":3,"file":"_mutateTheme.native.js","names":[],"sources":["esm/_mutateTheme.native.js"],"sourcesContent":["import { isServer } from \"@tamagui/constants\";\nimport { startTransition } from \"@tamagui/start-transition\";\nimport { forceUpdateThemes, getConfig, updateConfig } from \"@tamagui/web\";\nimport { ensureThemeVariable, proxyThemeToParents } from \"@tamagui/web/internal-runtime\";\n\nfunction mutateThemes(param) {\n\tvar { themes, batch, insertCSS = true, ...props } = param;\n\tvar allThemesProxied = {};\n\tvar allThemesRaw = {};\n\tvar _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n\ttry {\n\t\tfor (var _iterator = themes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n\t\t\tvar { name, theme } = _step.value;\n\t\t\tvar res = _mutateTheme({\n\t\t\t\t...props,\n\t\t\t\tname,\n\t\t\t\ttheme,\n\t\t\t\tavoidUpdate: true,\n\t\t\t\tmutationType: \"add\"\n\t\t\t});\n\t\t\tif (res) {\n\t\t\t\tallThemesProxied[name] = res.theme;\n\t\t\t\tallThemesRaw[name] = res.themeRaw;\n\t\t\t}\n\t\t}\n\t} catch (err) {\n\t\t_didIteratorError = true;\n\t\t_iteratorError = err;\n\t} finally {\n\t\ttry {\n\t\t\tif (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();\n\t\t} finally {\n\t\t\tif (_didIteratorError) throw _iteratorError;\n\t\t}\n\t}\n\tvar cssRules = insertCSS ? insertThemeCSS(allThemesRaw, batch) : [];\n\tstartTransition(function() {\n\t\tupdateConfig(\"themes\", allThemesProxied);\n\t\tupdateThemeStates();\n\t});\n\treturn {\n\t\tthemes: allThemesProxied,\n\t\tthemesRaw: allThemesRaw,\n\t\tcssRules\n\t};\n}\nfunction _mutateTheme(props) {\n\tif (isServer) {\n\t\tif (process.env.NODE_ENV === \"development\") console.warn(\"Theme mutation is not supported on server side\");\n\t\treturn;\n\t}\n\tvar config = getConfig();\n\tvar { name: themeName, theme: themeIn, insertCSS, mutationType } = props;\n\tif (process.env.NODE_ENV === \"development\") {\n\t\tif (!config) throw new Error(\"No config\");\n\t\tvar theme = config.themes[props.name];\n\t\tif (mutationType !== \"add\" && !theme) throw new Error(`${mutationType === \"replace\" ? \"Replace\" : \"Update\"} theme failed! Theme ${props.name} does not exist`);\n\t}\n\tvar _config_themes_themeName;\n\tvar theme1 = {\n\t\t...mutationType === \"update\" ? (_config_themes_themeName = config.themes[themeName]) !== null && _config_themes_themeName !== void 0 ? _config_themes_themeName : {} : {},\n\t\t...themeIn\n\t};\n\tfor (var key in theme1) ensureThemeVariable(theme1, key);\n\tvar themeProxied = proxyThemeToParents(themeName, theme1);\n\tvar response = {\n\t\tthemeRaw: theme1,\n\t\ttheme: themeProxied,\n\t\tcssRules: []\n\t};\n\tif (props.avoidUpdate) return response;\n\tif (insertCSS) response.cssRules = insertThemeCSS({ [themeName]: theme1 });\n\tupdateThemeConfig(themeName, themeProxied);\n\tupdateThemeStates();\n\treturn response;\n}\nfunction updateThemeConfig(themeName, theme) {\n\tupdateConfig(\"themes\", { [themeName]: theme });\n}\nfunction updateThemeStates() {\n\tforceUpdateThemes();\n}\nfunction insertThemeCSS(themes) {\n\targuments.length > 1 && arguments[1] !== void 0 && arguments[1];\n\treturn [];\n}\n\nexport { _mutateTheme, mutateThemes };"],"mappings":";;;;;;AAKA,SAAS,aAAa,OAAO;CAC5B,IAAI,EAAE,QAAQ,OAAO,YAAY,MAAM,GAAG,UAAU;CACpD,IAAI,mBAAmB,CAAC;CACxB,IAAI,eAAe,CAAC;CACpB,IAAI,4BAA4B,MAAM,oBAAoB,OAAO,iBAAiB,KAAK;CACvF,IAAI;EACH,KAAK,IAAI,YAAY,OAAO,OAAO,SAAS,CAAC,GAAG,OAAO,EAAE,6BAA6B,QAAQ,UAAU,KAAK,EAAC,CAAE,OAAO,4BAA4B,MAAM;GACxJ,IAAI,EAAE,MAAM,UAAU,MAAM;GAC5B,IAAI,MAAM,aAAa;IACtB,GAAG;IACH;IACA;IACA,aAAa;IACb,cAAc;GACf,CAAC;GACD,IAAI,KAAK;IACR,iBAAiB,QAAQ,IAAI;IAC7B,aAAa,QAAQ,IAAI;GAC1B;EACD;CACD,SAAS,KAAK;EACb,oBAAoB;EACpB,iBAAiB;CAClB,UAAU;EACT,IAAI;GACH,IAAI,CAAC,6BAA6B,UAAU,UAAU,MAAM,UAAU,OAAO;EAC9E,UAAU;GACT,IAAI,mBAAmB,MAAM;EAC9B;CACD;CACA,IAAI,WAAW,YAAY,eAAe,cAAc,KAAK,IAAI,CAAC;CAClE,gBAAgB,WAAW;EAC1B,aAAa,UAAU,gBAAgB;EACvC,kBAAkB;CACnB,CAAC;CACD,OAAO;EACN,QAAQ;EACR,WAAW;EACX;CACD;AACD;AACA,SAAS,aAAa,OAAO;CAC5B,IAAI,UAAU;EACb,IAAI,QAAQ,IAAI,aAAa,eAAe,QAAQ,KAAK,gDAAgD;EACzG;CACD;CACA,IAAI,SAAS,UAAU;CACvB,IAAI,EAAE,MAAM,WAAW,OAAO,SAAS,WAAW,iBAAiB;CACnE,IAAI,QAAQ,IAAI,aAAa,eAAe;EAC3C,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,WAAW;EACxC,IAAI,QAAQ,OAAO,OAAO,MAAM;EAChC,IAAI,iBAAiB,SAAS,CAAC,OAAO,MAAM,IAAI,MAAM,GAAG,iBAAiB,YAAY,YAAY,SAAS,uBAAuB,MAAM,KAAK,gBAAgB;CAC9J;CACA,IAAI;CACJ,IAAI,SAAS;EACZ,GAAG,iBAAiB,YAAY,2BAA2B,OAAO,OAAO,gBAAgB,QAAQ,6BAA6B,KAAK,IAAI,2BAA2B,CAAC,IAAI,CAAC;EACxK,GAAG;CACJ;CACA,KAAK,IAAI,OAAO,QAAQ,oBAAoB,QAAQ,GAAG;CACvD,IAAI,eAAe,oBAAoB,WAAW,MAAM;CACxD,IAAI,WAAW;EACd,UAAU;EACV,OAAO;EACP,UAAU,CAAC;CACZ;CACA,IAAI,MAAM,aAAa,OAAO;CAC9B,IAAI,WAAW,SAAS,WAAW,eAAe,GAAG,YAAY,OAAO,CAAC;CACzE,kBAAkB,WAAW,YAAY;CACzC,kBAAkB;CAClB,OAAO;AACR;AACA,SAAS,kBAAkB,WAAW,OAAO;CAC5C,aAAa,UAAU,GAAG,YAAY,MAAM,CAAC;AAC9C;AACA,SAAS,oBAAoB;CAC5B,kBAAkB;AACnB;AACA,SAAS,eAAe,QAAQ;CAC/B,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,KAAK,UAAU;CAC7D,OAAO,CAAC;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/theme",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.804.1",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
"clean:build": "tamagui-build clean:build"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@tamagui/constants": "3.0.0-beta.
|
|
38
|
-
"@tamagui/start-transition": "3.0.0-beta.
|
|
39
|
-
"@tamagui/web": "3.0.0-beta.
|
|
37
|
+
"@tamagui/constants": "3.0.0-beta.804.1",
|
|
38
|
+
"@tamagui/start-transition": "3.0.0-beta.804.1",
|
|
39
|
+
"@tamagui/web": "3.0.0-beta.804.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@tamagui/build": "3.0.0-beta.
|
|
42
|
+
"@tamagui/build": "3.0.0-beta.804.1",
|
|
43
43
|
"react": "19.2.3"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
package/src/_mutateTheme.ts
CHANGED
|
@@ -2,15 +2,17 @@ import { isServer } from '@tamagui/constants'
|
|
|
2
2
|
import { startTransition } from '@tamagui/start-transition'
|
|
3
3
|
import type { ThemeDefinition, ThemeParsed } from '@tamagui/web'
|
|
4
4
|
import {
|
|
5
|
-
ensureThemeVariable,
|
|
6
5
|
forceUpdateThemes,
|
|
7
6
|
getConfig,
|
|
8
|
-
getThemeCSSRules,
|
|
9
7
|
getMutatedAutoVariableCSS,
|
|
10
|
-
proxyThemeToParents,
|
|
11
8
|
simpleHash,
|
|
12
9
|
updateConfig,
|
|
13
10
|
} from '@tamagui/web'
|
|
11
|
+
import {
|
|
12
|
+
ensureThemeVariable,
|
|
13
|
+
getThemeCSSRules,
|
|
14
|
+
proxyThemeToParents,
|
|
15
|
+
} from '@tamagui/web/internal-runtime'
|
|
14
16
|
|
|
15
17
|
type MutateThemeOptions = {
|
|
16
18
|
mutationType: 'replace' | 'update' | 'add'
|
|
@@ -108,7 +110,11 @@ export function _mutateTheme(props: MutateThemeOptions & MutateOneThemeProps) {
|
|
|
108
110
|
|
|
109
111
|
const themeProxied = proxyThemeToParents(themeName, theme)
|
|
110
112
|
|
|
111
|
-
const response
|
|
113
|
+
const response: {
|
|
114
|
+
themeRaw: ThemeParsed
|
|
115
|
+
theme: ThemeParsed
|
|
116
|
+
cssRules: string[]
|
|
117
|
+
} = {
|
|
112
118
|
themeRaw: theme,
|
|
113
119
|
theme: themeProxied,
|
|
114
120
|
cssRules: [] as string[],
|
package/types/_mutateTheme.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare function mutateThemes({ themes, batch, insertCSS, ...props }: Omi
|
|
|
20
20
|
};
|
|
21
21
|
export declare function _mutateTheme(props: MutateThemeOptions & MutateOneThemeProps): {
|
|
22
22
|
themeRaw: ThemeParsed;
|
|
23
|
-
theme:
|
|
23
|
+
theme: ThemeParsed;
|
|
24
24
|
cssRules: string[];
|
|
25
25
|
} | undefined;
|
|
26
26
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_mutateTheme.d.ts","sourceRoot":"","sources":["../src/_mutateTheme.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"_mutateTheme.d.ts","sourceRoot":"","sources":["../src/_mutateTheme.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAchE,KAAK,kBAAkB,GAAG;IACxB,YAAY,EAAE,SAAS,GAAG,QAAQ,GAAG,KAAK,CAAA;IAC1C,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,KAAK,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,eAAe,EAAE,GAAG,CAAC,CAAC,CAAA;AAE/D,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,YAAY,CAAA;CACpB,CAAA;AAGD,KAAK,KAAK,GAAG,OAAO,GAAG,MAAM,CAAA;AAG7B,wBAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,KAAK,EACL,SAAgB,EAChB,GAAG,KAAK,EACT,EAAE,IAAI,CAAC,kBAAkB,EAAE,cAAc,CAAC,GAAG;IAC5C,MAAM,EAAE,mBAAmB,EAAE,CAAA;IAG7B,KAAK,CAAC,EAAE,KAAK,CAAA;CACd;;;;EA+BA;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,kBAAkB,GAAG,mBAAmB;cAqC9D,WAAW;WACd,WAAW;cACR,MAAM,EAAE;cAqBrB"}
|
package/types/addTheme.d.ts
CHANGED
package/types/replaceTheme.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare function replaceTheme({ name, theme, }: {
|
|
|
4
4
|
theme: Partial<Record<keyof ThemeDefinition, any>>;
|
|
5
5
|
}): {
|
|
6
6
|
themeRaw: import("@tamagui/web").ThemeParsed;
|
|
7
|
-
theme:
|
|
7
|
+
theme: import("@tamagui/web").ThemeParsed;
|
|
8
8
|
cssRules: string[];
|
|
9
9
|
} | undefined;
|
|
10
10
|
//# sourceMappingURL=replaceTheme.d.ts.map
|
package/types/updateTheme.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare function updateTheme({ name, theme, }: {
|
|
|
4
4
|
theme: Partial<Record<keyof ThemeDefinition, any>>;
|
|
5
5
|
}): {
|
|
6
6
|
themeRaw: import("@tamagui/web").ThemeParsed;
|
|
7
|
-
theme:
|
|
7
|
+
theme: import("@tamagui/web").ThemeParsed;
|
|
8
8
|
cssRules: string[];
|
|
9
9
|
} | undefined;
|
|
10
10
|
//# sourceMappingURL=updateTheme.d.ts.map
|