@hanzogui/theme 8.3.1 → 8.3.2

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.
Files changed (63) hide show
  1. package/dist/cjs/_mutateTheme.js +135 -0
  2. package/dist/cjs/_mutateTheme.js.map +1 -0
  3. package/dist/cjs/addTheme.js +8 -0
  4. package/dist/cjs/addTheme.js.map +1 -0
  5. package/dist/cjs/index.js +10 -0
  6. package/dist/cjs/index.js.map +1 -0
  7. package/dist/cjs/package.json +1 -0
  8. package/dist/cjs/replaceTheme.js +9 -0
  9. package/dist/cjs/replaceTheme.js.map +1 -0
  10. package/dist/cjs/updateTheme.js +8 -0
  11. package/dist/cjs/updateTheme.js.map +1 -0
  12. package/dist/esm/_mutateTheme.js +131 -0
  13. package/dist/esm/_mutateTheme.js.map +1 -0
  14. package/dist/esm/addTheme.js +5 -0
  15. package/dist/esm/addTheme.js.map +1 -0
  16. package/dist/esm/index.js +5 -6
  17. package/dist/esm/index.js.map +1 -1
  18. package/dist/esm/replaceTheme.js +6 -0
  19. package/dist/esm/replaceTheme.js.map +1 -0
  20. package/dist/esm/updateTheme.js +5 -0
  21. package/dist/esm/updateTheme.js.map +1 -0
  22. package/package.json +21 -16
  23. package/src/addTheme.ts +1 -1
  24. package/src/index.ts +5 -5
  25. package/src/replaceTheme.ts +1 -1
  26. package/src/updateTheme.ts +1 -1
  27. package/types/index.d.ts +5 -5
  28. package/types/index.d.ts.map +1 -1
  29. package/dist/cjs/_mutateTheme.cjs +0 -141
  30. package/dist/cjs/_mutateTheme.native.js +0 -137
  31. package/dist/cjs/_mutateTheme.native.js.map +0 -1
  32. package/dist/cjs/addTheme.cjs +0 -35
  33. package/dist/cjs/addTheme.native.js +0 -38
  34. package/dist/cjs/addTheme.native.js.map +0 -1
  35. package/dist/cjs/index.cjs +0 -32
  36. package/dist/cjs/index.native.js +0 -35
  37. package/dist/cjs/index.native.js.map +0 -1
  38. package/dist/cjs/replaceTheme.cjs +0 -40
  39. package/dist/cjs/replaceTheme.native.js +0 -44
  40. package/dist/cjs/replaceTheme.native.js.map +0 -1
  41. package/dist/cjs/updateTheme.cjs +0 -39
  42. package/dist/cjs/updateTheme.native.js +0 -43
  43. package/dist/cjs/updateTheme.native.js.map +0 -1
  44. package/dist/esm/_mutateTheme.mjs +0 -115
  45. package/dist/esm/_mutateTheme.mjs.map +0 -1
  46. package/dist/esm/_mutateTheme.native.js +0 -108
  47. package/dist/esm/_mutateTheme.native.js.map +0 -1
  48. package/dist/esm/addTheme.mjs +0 -10
  49. package/dist/esm/addTheme.mjs.map +0 -1
  50. package/dist/esm/addTheme.native.js +0 -10
  51. package/dist/esm/addTheme.native.js.map +0 -1
  52. package/dist/esm/index.mjs +0 -6
  53. package/dist/esm/index.mjs.map +0 -1
  54. package/dist/esm/index.native.js +0 -6
  55. package/dist/esm/index.native.js.map +0 -1
  56. package/dist/esm/replaceTheme.mjs +0 -15
  57. package/dist/esm/replaceTheme.mjs.map +0 -1
  58. package/dist/esm/replaceTheme.native.js +0 -16
  59. package/dist/esm/replaceTheme.native.js.map +0 -1
  60. package/dist/esm/updateTheme.mjs +0 -14
  61. package/dist/esm/updateTheme.mjs.map +0 -1
  62. package/dist/esm/updateTheme.native.js +0 -15
  63. package/dist/esm/updateTheme.native.js.map +0 -1
@@ -1,115 +0,0 @@
1
- import { isServer } from "@hanzogui/constants";
2
- import { startTransition } from "@hanzogui/start-transition";
3
- import { ensureThemeVariable, forceUpdateThemes, getConfig, getThemeCSSRules, mutatedAutoVariables, proxyThemeToParents, simpleHash, updateConfig } from "@hanzogui/web";
4
- function mutateThemes({
5
- themes,
6
- batch,
7
- insertCSS = true,
8
- ...props
9
- }) {
10
- const allThemesProxied = {};
11
- const allThemesRaw = {};
12
- for (const {
13
- name,
14
- theme
15
- } of themes) {
16
- const res = _mutateTheme({
17
- ...props,
18
- name,
19
- theme,
20
- avoidUpdate: true,
21
- mutationType: "add"
22
- });
23
- if (res) {
24
- allThemesProxied[name] = res.theme;
25
- allThemesRaw[name] = res.themeRaw;
26
- }
27
- }
28
- const cssRules = insertCSS ? insertThemeCSS(allThemesRaw, batch) : [];
29
- startTransition(() => {
30
- for (const themeName in allThemesProxied) {
31
- const theme = allThemesProxied[themeName];
32
- updateThemeConfig(themeName, theme);
33
- }
34
- updateThemeStates();
35
- });
36
- return {
37
- themes: allThemesProxied,
38
- themesRaw: allThemesRaw,
39
- cssRules
40
- };
41
- }
42
- function _mutateTheme(props) {
43
- if (isServer) {
44
- if (process.env.NODE_ENV === "development") console.warn("Theme mutation is not supported on server side");
45
- return;
46
- }
47
- const config = getConfig();
48
- const {
49
- name: themeName,
50
- theme: themeIn,
51
- insertCSS,
52
- mutationType
53
- } = props;
54
- if (process.env.NODE_ENV === "development") {
55
- if (!config) throw new Error("No config");
56
- const theme2 = config.themes[props.name];
57
- if (mutationType !== "add" && !theme2) throw new Error(`${mutationType === "replace" ? "Replace" : "Update"} theme failed! Theme ${props.name} does not exist`);
58
- }
59
- const theme = {
60
- ...(mutationType === "update" ? config.themes[themeName] ?? {} : {}),
61
- ...themeIn
62
- };
63
- for (const key in theme) ensureThemeVariable(theme, key);
64
- const themeProxied = proxyThemeToParents(themeName, theme);
65
- const response = {
66
- themeRaw: theme,
67
- theme: themeProxied,
68
- cssRules: []
69
- };
70
- if (props.avoidUpdate) return response;
71
- if (insertCSS) response.cssRules = insertThemeCSS({
72
- [themeName]: theme
73
- });
74
- updateThemeConfig(themeName, themeProxied);
75
- updateThemeStates();
76
- return response;
77
- }
78
- function updateThemeConfig(themeName, theme) {
79
- const config = getConfig();
80
- config.themes[themeName] = theme;
81
- updateConfig("themes", config.themes);
82
- }
83
- function updateThemeStates() {
84
- forceUpdateThemes();
85
- }
86
- function insertThemeCSS(themes, batch = false) {
87
- const config = getConfig();
88
- let cssRules = [];
89
- for (const themeName in themes) {
90
- const theme = themes[themeName];
91
- const rules = getThemeCSSRules({
92
- config,
93
- themeName,
94
- names: [themeName],
95
- hasDarkLight: true,
96
- theme,
97
- useMutatedVariables: true
98
- });
99
- cssRules = [...cssRules, ...rules];
100
- if (!batch) updateStyle(`t_theme_style_${themeName}`, rules);
101
- }
102
- if (mutatedAutoVariables.length > 0) updateStyle(`t_mutate_vars`, [`:root{${mutatedAutoVariables.map(v => `--${v.name}:${v.val}`).join(";")}}`]);
103
- if (batch) updateStyle(`t_theme_style_${typeof batch == "string" ? batch : simpleHash(Object.keys(themes).join(""))}`, cssRules);
104
- return cssRules;
105
- }
106
- function updateStyle(id, rules) {
107
- const existing = document.querySelector(`#${id}`);
108
- const style = document.createElement("style");
109
- style.id = id;
110
- style.appendChild(document.createTextNode(rules.join("\n")));
111
- document.head.appendChild(style);
112
- if (existing) existing.parentElement?.removeChild(existing);
113
- }
114
- export { _mutateTheme, mutateThemes };
115
- //# sourceMappingURL=_mutateTheme.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["isServer","startTransition","ensureThemeVariable","forceUpdateThemes","getConfig","getThemeCSSRules","mutatedAutoVariables","proxyThemeToParents","simpleHash","updateConfig","mutateThemes","themes","batch","insertCSS","props","allThemesProxied","allThemesRaw","name","theme","res","_mutateTheme","avoidUpdate","mutationType","themeRaw","cssRules","insertThemeCSS","themeName","updateThemeConfig","updateThemeStates","themesRaw","process","env","NODE_ENV","console","warn","config","themeIn","Error","theme2","key","themeProxied","response","rules","names","hasDarkLight","useMutatedVariables","updateStyle","length","map","v","val","join","Object","keys","id","existing","document","querySelector","style","createElement","appendChild","createTextNode","head","parentElement","removeChild"],"sources":["_mutateTheme.mjs"],"sourcesContent":["import { isServer } from \"@hanzogui/constants\";\nimport { startTransition } from \"@hanzogui/start-transition\";\nimport { ensureThemeVariable, forceUpdateThemes, getConfig, getThemeCSSRules, mutatedAutoVariables, proxyThemeToParents, simpleHash, updateConfig } from \"@hanzogui/web\";\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\tfor (const themeName in allThemesProxied) {\n\t\t\tconst theme = allThemesProxied[themeName];\n\t\t\tupdateThemeConfig(themeName, theme);\n\t\t}\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\tconst config = getConfig();\n\tconfig.themes[themeName] = theme;\n\tupdateConfig(\"themes\", config.themes);\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\tif (mutatedAutoVariables.length > 0) updateStyle(`t_mutate_vars`, [`:root{${mutatedAutoVariables.map((v) => `--${v.name}:${v.val}`).join(\";\")}}`]);\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":"AAAA,SAASA,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,SAASC,mBAAmB,EAAEC,iBAAiB,EAAEC,SAAS,EAAEC,gBAAgB,EAAEC,oBAAoB,EAAEC,mBAAmB,EAAEC,UAAU,EAAEC,YAAY,QAAQ,eAAe;AAExK,SAASC,YAAYA,CAAC;EAAEC,MAAM;EAAEC,KAAK;EAAEC,SAAS,GAAG,IAAI;EAAE,GAAGC;AAAM,CAAC,EAAE;EACpE,MAAMC,gBAAgB,GAAG,CAAC,CAAC;EAC3B,MAAMC,YAAY,GAAG,CAAC,CAAC;EACvB,KAAK,MAAM;IAAEC,IAAI;IAAEC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AQ,CAACG,aAAa,CAAC,OAAO,CAAC;EAC7CD,KAAK,CAACJ,EAAE,GAAGA,EAAE;EACbI,KAAK,CAACE,WAAW,CAACJ,QAAQ,CAACK,cAAc,CAACnB,KAAK,CAACS,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;EAC5DK,QAAQ,CAACM,IAAI,CAACF,WAAW,CAACF,KAAK,CAAC;EAChC,IAAIH,QAAQ,EAAEA,QAAQ,CAACQ,aAAa,EAAEC,WAAW,CAACT,QAAQ,CAAC;AAC5D;AAEA,SAASnC,YAAY,EAAEV,YAAY","ignoreList":[]}
@@ -1,108 +0,0 @@
1
- import { isServer } from "@hanzogui/constants";
2
- import { startTransition } from "@hanzogui/start-transition";
3
- import { ensureThemeVariable, forceUpdateThemes, getConfig, proxyThemeToParents, updateConfig } from "@hanzogui/web";
4
- function mutateThemes(param) {
5
- var {
6
- themes,
7
- batch,
8
- insertCSS = true,
9
- ...props
10
- } = param;
11
- var allThemesProxied = {};
12
- var allThemesRaw = {};
13
- var _iteratorNormalCompletion = true,
14
- _didIteratorError = false,
15
- _iteratorError = void 0;
16
- try {
17
- for (var _iterator = themes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
18
- var {
19
- name,
20
- theme
21
- } = _step.value;
22
- var res = _mutateTheme({
23
- ...props,
24
- name,
25
- theme,
26
- avoidUpdate: true,
27
- mutationType: "add"
28
- });
29
- if (res) {
30
- allThemesProxied[name] = res.theme;
31
- allThemesRaw[name] = res.themeRaw;
32
- }
33
- }
34
- } catch (err) {
35
- _didIteratorError = true;
36
- _iteratorError = err;
37
- } finally {
38
- try {
39
- if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
40
- } finally {
41
- if (_didIteratorError) throw _iteratorError;
42
- }
43
- }
44
- var cssRules = insertCSS ? insertThemeCSS(allThemesRaw, batch) : [];
45
- startTransition(function () {
46
- for (var themeName in allThemesProxied) {
47
- var theme2 = allThemesProxied[themeName];
48
- updateThemeConfig(themeName, theme2);
49
- }
50
- updateThemeStates();
51
- });
52
- return {
53
- themes: allThemesProxied,
54
- themesRaw: allThemesRaw,
55
- cssRules
56
- };
57
- }
58
- function _mutateTheme(props) {
59
- if (isServer) {
60
- if (process.env.NODE_ENV === "development") console.warn("Theme mutation is not supported on server side");
61
- return;
62
- }
63
- var config = getConfig();
64
- var {
65
- name: themeName,
66
- theme: themeIn,
67
- insertCSS,
68
- mutationType
69
- } = props;
70
- if (process.env.NODE_ENV === "development") {
71
- if (!config) throw new Error("No config");
72
- var theme = config.themes[props.name];
73
- if (mutationType !== "add" && !theme) throw new Error(`${mutationType === "replace" ? "Replace" : "Update"} theme failed! Theme ${props.name} does not exist`);
74
- }
75
- var _config_themes_themeName;
76
- var theme1 = {
77
- ...(mutationType === "update" ? (_config_themes_themeName = config.themes[themeName]) !== null && _config_themes_themeName !== void 0 ? _config_themes_themeName : {} : {}),
78
- ...themeIn
79
- };
80
- for (var key in theme1) ensureThemeVariable(theme1, key);
81
- var themeProxied = proxyThemeToParents(themeName, theme1);
82
- var response = {
83
- themeRaw: theme1,
84
- theme: themeProxied,
85
- cssRules: []
86
- };
87
- if (props.avoidUpdate) return response;
88
- if (insertCSS) response.cssRules = insertThemeCSS({
89
- [themeName]: theme1
90
- });
91
- updateThemeConfig(themeName, themeProxied);
92
- updateThemeStates();
93
- return response;
94
- }
95
- function updateThemeConfig(themeName, theme) {
96
- var config = getConfig();
97
- config.themes[themeName] = theme;
98
- updateConfig("themes", config.themes);
99
- }
100
- function updateThemeStates() {
101
- forceUpdateThemes();
102
- }
103
- function insertThemeCSS(themes) {
104
- arguments.length > 1 && arguments[1] !== void 0 && arguments[1];
105
- return [];
106
- }
107
- export { _mutateTheme, mutateThemes };
108
- //# sourceMappingURL=_mutateTheme.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["isServer","startTransition","ensureThemeVariable","forceUpdateThemes","getConfig","proxyThemeToParents","updateConfig","mutateThemes","param","themes","batch","insertCSS","props","allThemesProxied","allThemesRaw","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","Symbol","iterator","_step","next","done","name","theme","value","res","_mutateTheme","avoidUpdate","mutationType","themeRaw","err","return","cssRules","insertThemeCSS","themeName","theme2","updateThemeConfig","updateThemeStates","themesRaw","process","env","NODE_ENV","console","warn","config","themeIn","Error","_config_themes_themeName","theme1","key","themeProxied","response","arguments","length"],"sources":["_mutateTheme.native.js"],"sourcesContent":["import { isServer } from \"@hanzogui/constants\";\nimport { startTransition } from \"@hanzogui/start-transition\";\nimport { ensureThemeVariable, forceUpdateThemes, getConfig, proxyThemeToParents, updateConfig } from \"@hanzogui/web\";\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\tfor (var themeName in allThemesProxied) {\n\t\t\tvar theme2 = allThemesProxied[themeName];\n\t\t\tupdateThemeConfig(themeName, theme2);\n\t\t}\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\tvar config = getConfig();\n\tconfig.themes[themeName] = theme;\n\tupdateConfig(\"themes\", config.themes);\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":"AAAA,SAASA,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,SAASC,mBAAm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C,CAAC;EAC/D,OAAO,EAAE;AACV;AAEA,SAAS1B,YAAY,EAAErB,YAAY","ignoreList":[]}
@@ -1,10 +0,0 @@
1
- import { _mutateTheme } from "./_mutateTheme.mjs";
2
- function addTheme(props) {
3
- return _mutateTheme({
4
- ...props,
5
- insertCSS: true,
6
- mutationType: "add"
7
- });
8
- }
9
- export { addTheme };
10
- //# sourceMappingURL=addTheme.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_mutateTheme","addTheme","props","insertCSS","mutationType"],"sources":["../../src/addTheme.ts"],"sourcesContent":[null],"mappings":"AAEA,SAASA,YAAA,QAAoB;AAEtB,SAASC,SAASC,KAAA,EAItB;EACD,OAAOF,YAAA,CAAa;IAAE,GAAGE,KAAA;IAAOC,SAAA,EAAW;IAAMC,YAAA,EAAc;EAAM,CAAC;AACxE","ignoreList":[]}
@@ -1,10 +0,0 @@
1
- import { _mutateTheme } from "./_mutateTheme.native.js";
2
- function addTheme(props) {
3
- return _mutateTheme({
4
- ...props,
5
- insertCSS: true,
6
- mutationType: "add"
7
- });
8
- }
9
- export { addTheme };
10
- //# sourceMappingURL=addTheme.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_mutateTheme","addTheme","props"],"sources":["../../src/addTheme.ts"],"sourcesContent":[null],"mappings":"AAEA,SAASA,YAAA,QAAoB;AAEtB,SAASC,SAASC,KAAA,EAItB;EACD,OAAOF,YAAA,CAAa;IACtB,GAAAE,KAAA","ignoreList":[]}
@@ -1,6 +0,0 @@
1
- export * from "./addTheme.mjs";
2
- export * from "./updateTheme.mjs";
3
- export * from "./replaceTheme.mjs";
4
- import { mutateThemes } from "./_mutateTheme.mjs";
5
- export { mutateThemes };
6
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["mutateThemes"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAASA,YAAA,QAAoB","ignoreList":[]}
@@ -1,6 +0,0 @@
1
- export * from "./addTheme.native.js";
2
- export * from "./updateTheme.native.js";
3
- export * from "./replaceTheme.native.js";
4
- import { mutateThemes } from "./_mutateTheme.native.js";
5
- export { mutateThemes };
6
- //# sourceMappingURL=index.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["mutateThemes"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAASA,YAAA,QAAoB","ignoreList":[]}
@@ -1,15 +0,0 @@
1
- import { _mutateTheme } from "./_mutateTheme.mjs";
2
- function replaceTheme({
3
- name,
4
- theme
5
- }) {
6
- const next = _mutateTheme({
7
- name,
8
- theme,
9
- insertCSS: true,
10
- mutationType: "replace"
11
- });
12
- return next;
13
- }
14
- export { replaceTheme };
15
- //# sourceMappingURL=replaceTheme.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_mutateTheme","replaceTheme","name","theme","next","insertCSS","mutationType"],"sources":["../../src/replaceTheme.ts"],"sourcesContent":[null],"mappings":"AAEA,SAASA,YAAA,QAAoB;AAEtB,SAASC,aAAa;EAC3BC,IAAA;EACAC;AACF,GAGG;EACD,MAAMC,IAAA,GAAOJ,YAAA,CAAa;IAAEE,IAAA;IAAMC,KAAA;IAAOE,SAAA,EAAW;IAAMC,YAAA,EAAc;EAAU,CAAC;EACnF,OAAOF,IAAA;AACT","ignoreList":[]}
@@ -1,16 +0,0 @@
1
- import { _mutateTheme } from "./_mutateTheme.native.js";
2
- function replaceTheme(param) {
3
- var {
4
- name,
5
- theme
6
- } = param;
7
- var next = _mutateTheme({
8
- name,
9
- theme,
10
- insertCSS: true,
11
- mutationType: "replace"
12
- });
13
- return next;
14
- }
15
- export { replaceTheme };
16
- //# sourceMappingURL=replaceTheme.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_mutateTheme","replaceTheme","param","name","theme","next","insertCSS","mutationType"],"sources":["../../src/replaceTheme.ts"],"sourcesContent":[null],"mappings":"AAEA,SAASA,YAAA,QAAoB;AAEtB,SAASC,aAAaC,KAAA;EAC3B;IAAAC,IAAA;IAAAC;EAAA,IAAAF,KAAA;EACA,IAAAG,IAAA,GAAAL,YAAA;IAICG,IAAA;IACDC,KAAM;IACNE,SAAO;IACTC,YAAA","ignoreList":[]}
@@ -1,14 +0,0 @@
1
- import { _mutateTheme } from "./_mutateTheme.mjs";
2
- function updateTheme({
3
- name,
4
- theme
5
- }) {
6
- return _mutateTheme({
7
- name,
8
- theme,
9
- insertCSS: true,
10
- mutationType: "update"
11
- });
12
- }
13
- export { updateTheme };
14
- //# sourceMappingURL=updateTheme.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_mutateTheme","updateTheme","name","theme","insertCSS","mutationType"],"sources":["../../src/updateTheme.ts"],"sourcesContent":[null],"mappings":"AAEA,SAASA,YAAA,QAAoB;AAEtB,SAASC,YAAY;EAC1BC,IAAA;EACAC;AACF,GAGG;EACD,OAAOH,YAAA,CAAa;IAAEE,IAAA;IAAMC,KAAA;IAAOC,SAAA,EAAW;IAAMC,YAAA,EAAc;EAAS,CAAC;AAC9E","ignoreList":[]}
@@ -1,15 +0,0 @@
1
- import { _mutateTheme } from "./_mutateTheme.native.js";
2
- function updateTheme(param) {
3
- var {
4
- name,
5
- theme
6
- } = param;
7
- return _mutateTheme({
8
- name,
9
- theme,
10
- insertCSS: true,
11
- mutationType: "update"
12
- });
13
- }
14
- export { updateTheme };
15
- //# sourceMappingURL=updateTheme.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_mutateTheme","updateTheme","param","name","theme","insertCSS"],"sources":["../../src/updateTheme.ts"],"sourcesContent":[null],"mappings":"AAEA,SAASA,YAAA,QAAoB;AAEtB,SAASC,YAAYC,KAAA;EAC1B;IAAAC,IAAA;IAAAC;EAAA,IAAAF,KAAA;EACA,OAAAF,YAAA;IAICG,IAAA;IACDC,KAAO;IACTC,SAAA","ignoreList":[]}