@tamagui/theme 2.0.0-rc.4 → 2.0.0-rc.40
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 +68 -63
- package/dist/cjs/_mutateTheme.native.js +73 -94
- package/dist/cjs/_mutateTheme.native.js.map +1 -1
- package/dist/cjs/addTheme.cjs +13 -11
- package/dist/cjs/addTheme.native.js +13 -11
- package/dist/cjs/addTheme.native.js.map +1 -1
- package/dist/cjs/index.cjs +13 -11
- package/dist/cjs/index.native.js +13 -11
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/replaceTheme.cjs +15 -12
- package/dist/cjs/replaceTheme.native.js +21 -19
- package/dist/cjs/replaceTheme.native.js.map +1 -1
- package/dist/cjs/updateTheme.cjs +13 -11
- package/dist/cjs/updateTheme.native.js +13 -11
- package/dist/cjs/updateTheme.native.js.map +1 -1
- package/dist/esm/_mutateTheme.mjs +53 -50
- package/dist/esm/_mutateTheme.mjs.map +1 -1
- package/dist/esm/_mutateTheme.native.js +58 -81
- package/dist/esm/_mutateTheme.native.js.map +1 -1
- package/dist/esm/addTheme.mjs +1 -1
- package/dist/esm/addTheme.native.js +1 -1
- package/dist/esm/index.js +5 -7
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/replaceTheme.mjs +3 -2
- package/dist/esm/replaceTheme.mjs.map +1 -1
- package/dist/esm/replaceTheme.native.js +9 -9
- package/dist/esm/replaceTheme.native.js.map +1 -1
- package/dist/esm/updateTheme.mjs +1 -1
- package/dist/esm/updateTheme.native.js +1 -1
- package/package.json +8 -11
- package/dist/cjs/_mutateTheme.js +0 -121
- package/dist/cjs/_mutateTheme.js.map +0 -6
- package/dist/cjs/addTheme.js +0 -24
- package/dist/cjs/addTheme.js.map +0 -6
- package/dist/cjs/index.js +0 -24
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/replaceTheme.js +0 -27
- package/dist/cjs/replaceTheme.js.map +0 -6
- package/dist/cjs/updateTheme.js +0 -27
- package/dist/cjs/updateTheme.js.map +0 -6
- package/dist/esm/_mutateTheme.js +0 -116
- package/dist/esm/_mutateTheme.js.map +0 -6
- package/dist/esm/addTheme.js +0 -8
- package/dist/esm/addTheme.js.map +0 -6
- package/dist/esm/replaceTheme.js +0 -11
- package/dist/esm/replaceTheme.js.map +0 -6
- package/dist/esm/updateTheme.js +0 -11
- package/dist/esm/updateTheme.js.map +0 -6
|
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var replaceTheme_exports = {};
|
|
22
24
|
__export(replaceTheme_exports, {
|
|
@@ -28,10 +30,11 @@ function replaceTheme({
|
|
|
28
30
|
name,
|
|
29
31
|
theme
|
|
30
32
|
}) {
|
|
31
|
-
|
|
33
|
+
const next = (0, import_mutateTheme._mutateTheme)({
|
|
32
34
|
name,
|
|
33
35
|
theme,
|
|
34
|
-
insertCSS:
|
|
36
|
+
insertCSS: true,
|
|
35
37
|
mutationType: "replace"
|
|
36
38
|
});
|
|
39
|
+
return next;
|
|
37
40
|
}
|
|
@@ -5,20 +5,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value:
|
|
23
|
+
value: true
|
|
22
24
|
}), mod);
|
|
23
25
|
var replaceTheme_exports = {};
|
|
24
26
|
__export(replaceTheme_exports, {
|
|
@@ -28,15 +30,15 @@ module.exports = __toCommonJS(replaceTheme_exports);
|
|
|
28
30
|
var import_mutateTheme = require("./_mutateTheme.native.js");
|
|
29
31
|
function replaceTheme(param) {
|
|
30
32
|
var {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
name,
|
|
34
|
+
theme
|
|
35
|
+
} = param;
|
|
36
|
+
var next = (0, import_mutateTheme._mutateTheme)({
|
|
37
|
+
name,
|
|
38
|
+
theme,
|
|
39
|
+
insertCSS: true,
|
|
40
|
+
mutationType: "replace"
|
|
41
|
+
});
|
|
40
42
|
return next;
|
|
41
43
|
}
|
|
42
44
|
//# sourceMappingURL=replaceTheme.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","replaceTheme_exports","__export","replaceTheme","module","exports","import_mutateTheme","require","param","name","theme","next","_mutateTheme","insertCSS"],"sources":["../../src/replaceTheme.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","replaceTheme_exports","__export","replaceTheme","module","exports","import_mutateTheme","require","param","name","theme","next","_mutateTheme","insertCSS"],"sources":["../../src/replaceTheme.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,oBAAA;AAAAC,QAAA,CAAAD,oBAAA;EAAAE,YAAA,EAAAA,CAAA,KAAAA;AAAA;AAEAC,MAAA,CAAAC,OAAA,GAAAT,YAA6B,CAAAK,oBAAA;AAEtB,IAAAK,kBAAsB,GAAAC,OAAA;AAAA,SAC3BJ,aAAAK,KAAA;EACA;IAAAC,IAAA;IAAAC;EAAA,IAAAF,KAAA;EACF,IAGGG,IAAA,OAAAL,kBAAA,CAAAM,YAAA;IACDH,IAAM;IACNC,KAAO;IACTG,SAAA","ignoreList":[]}
|
package/dist/cjs/updateTheme.cjs
CHANGED
|
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var updateTheme_exports = {};
|
|
22
24
|
__export(updateTheme_exports, {
|
|
@@ -31,7 +33,7 @@ function updateTheme({
|
|
|
31
33
|
return (0, import_mutateTheme._mutateTheme)({
|
|
32
34
|
name,
|
|
33
35
|
theme,
|
|
34
|
-
insertCSS:
|
|
36
|
+
insertCSS: true,
|
|
35
37
|
mutationType: "update"
|
|
36
38
|
});
|
|
37
39
|
}
|
|
@@ -5,20 +5,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value:
|
|
23
|
+
value: true
|
|
22
24
|
}), mod);
|
|
23
25
|
var updateTheme_exports = {};
|
|
24
26
|
__export(updateTheme_exports, {
|
|
@@ -34,7 +36,7 @@ function updateTheme(param) {
|
|
|
34
36
|
return (0, import_mutateTheme._mutateTheme)({
|
|
35
37
|
name,
|
|
36
38
|
theme,
|
|
37
|
-
insertCSS:
|
|
39
|
+
insertCSS: true,
|
|
38
40
|
mutationType: "update"
|
|
39
41
|
});
|
|
40
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","updateTheme_exports","__export","updateTheme","module","exports","import_mutateTheme","require","param","name","theme","_mutateTheme"],"sources":["../../src/updateTheme.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","updateTheme_exports","__export","updateTheme","module","exports","import_mutateTheme","require","param","name","theme","_mutateTheme"],"sources":["../../src/updateTheme.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,mBAAA;AAAAC,QAAA,CAAAD,mBAAA;EAAAE,WAAA,EAAAA,CAAA,KAAAA;AAAA;AAEAC,MAAA,CAAAC,OAAA,GAAAT,YAA6B,CAAAK,mBAAA;AAEtB,IAAAK,kBAAqB,GAAAC,OAAA;AAAA,SAC1BJ,YAAAK,KAAA;EACA;IAAAC,IAAA;IAAAC;EAAA,IAAAF,KAAA;EACF,OAGG,IAAAF,kBAAA,CAAAK,YAAA;IACDF,IAAA;IACFC,KAAA","ignoreList":[]}
|
|
@@ -4,11 +4,11 @@ import { ensureThemeVariable, forceUpdateThemes, getConfig, getThemeCSSRules, mu
|
|
|
4
4
|
function mutateThemes({
|
|
5
5
|
themes,
|
|
6
6
|
batch,
|
|
7
|
-
insertCSS =
|
|
7
|
+
insertCSS = true,
|
|
8
8
|
...props
|
|
9
9
|
}) {
|
|
10
|
-
const allThemesProxied = {}
|
|
11
|
-
|
|
10
|
+
const allThemesProxied = {};
|
|
11
|
+
const allThemesRaw = {};
|
|
12
12
|
for (const {
|
|
13
13
|
name,
|
|
14
14
|
theme
|
|
@@ -17,21 +17,23 @@ function mutateThemes({
|
|
|
17
17
|
...props,
|
|
18
18
|
name,
|
|
19
19
|
theme,
|
|
20
|
-
|
|
21
|
-
avoidUpdate: !0,
|
|
22
|
-
// always add which also replaces but doesnt fail first time
|
|
20
|
+
avoidUpdate: true,
|
|
23
21
|
mutationType: "add"
|
|
24
22
|
});
|
|
25
|
-
|
|
23
|
+
if (res) {
|
|
24
|
+
allThemesProxied[name] = res.theme;
|
|
25
|
+
allThemesRaw[name] = res.themeRaw;
|
|
26
|
+
}
|
|
26
27
|
}
|
|
27
28
|
const cssRules = insertCSS ? insertThemeCSS(allThemesRaw, batch) : [];
|
|
28
|
-
|
|
29
|
+
startTransition(() => {
|
|
29
30
|
for (const themeName in allThemesProxied) {
|
|
30
31
|
const theme = allThemesProxied[themeName];
|
|
31
32
|
updateThemeConfig(themeName, theme);
|
|
32
33
|
}
|
|
33
34
|
updateThemeStates();
|
|
34
|
-
})
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
35
37
|
themes: allThemesProxied,
|
|
36
38
|
themesRaw: allThemesRaw,
|
|
37
39
|
cssRules
|
|
@@ -39,16 +41,16 @@ function mutateThemes({
|
|
|
39
41
|
}
|
|
40
42
|
function _mutateTheme(props) {
|
|
41
43
|
if (isServer) {
|
|
42
|
-
process.env.NODE_ENV === "development"
|
|
44
|
+
if (process.env.NODE_ENV === "development") console.warn("Theme mutation is not supported on server side");
|
|
43
45
|
return;
|
|
44
46
|
}
|
|
45
|
-
const config = getConfig()
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
const config = getConfig();
|
|
48
|
+
const {
|
|
49
|
+
name: themeName,
|
|
50
|
+
theme: themeIn,
|
|
51
|
+
insertCSS,
|
|
52
|
+
mutationType
|
|
53
|
+
} = props;
|
|
52
54
|
if (process.env.NODE_ENV === "development") {
|
|
53
55
|
if (!config) throw new Error("No config");
|
|
54
56
|
const theme2 = config.themes[props.name];
|
|
@@ -59,54 +61,55 @@ function _mutateTheme(props) {
|
|
|
59
61
|
...themeIn
|
|
60
62
|
};
|
|
61
63
|
for (const key in theme) ensureThemeVariable(theme, key);
|
|
62
|
-
const themeProxied = proxyThemeToParents(themeName, theme)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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({
|
|
69
72
|
[themeName]: theme
|
|
70
|
-
})
|
|
73
|
+
});
|
|
74
|
+
updateThemeConfig(themeName, themeProxied);
|
|
75
|
+
updateThemeStates();
|
|
76
|
+
return response;
|
|
71
77
|
}
|
|
72
78
|
function updateThemeConfig(themeName, theme) {
|
|
73
79
|
const config = getConfig();
|
|
74
|
-
config.themes[themeName] = theme
|
|
80
|
+
config.themes[themeName] = theme;
|
|
81
|
+
updateConfig("themes", config.themes);
|
|
75
82
|
}
|
|
76
83
|
function updateThemeStates() {
|
|
77
84
|
forceUpdateThemes();
|
|
78
85
|
}
|
|
79
|
-
function insertThemeCSS(themes, batch =
|
|
86
|
+
function insertThemeCSS(themes, batch = false) {
|
|
80
87
|
const config = getConfig();
|
|
81
88
|
let cssRules = [];
|
|
82
89
|
for (const themeName in themes) {
|
|
83
|
-
const theme = themes[themeName]
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
if (mutatedAutoVariables.length > 0) {
|
|
96
|
-
const autoVarCSS = `:root{${mutatedAutoVariables.map(v => `--${v.name}:${v.val}`).join(";")}}`;
|
|
97
|
-
updateStyle("t_mutate_vars", [autoVarCSS]);
|
|
98
|
-
}
|
|
99
|
-
if (batch) {
|
|
100
|
-
const id = typeof batch == "string" ? batch : simpleHash(Object.keys(themes).join(""));
|
|
101
|
-
updateStyle(`t_theme_style_${id}`, cssRules);
|
|
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);
|
|
102
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);
|
|
103
104
|
return cssRules;
|
|
104
105
|
}
|
|
105
106
|
function updateStyle(id, rules) {
|
|
106
|
-
const existing = document.querySelector(`#${id}`)
|
|
107
|
-
|
|
108
|
-
style.id = id
|
|
109
|
-
|
|
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);
|
|
110
113
|
}
|
|
111
114
|
export { _mutateTheme, mutateThemes };
|
|
112
115
|
//# sourceMappingURL=_mutateTheme.mjs.map
|
|
@@ -1 +1 @@
|
|
|
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","
|
|
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":["../../src/_mutateTheme.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,QAAA,QAAgB;AACzB,SAASC,eAAA,QAAuB;AAEhC,SAAAC,mBAAA,EAAAC,iBAAA,EAAAC,SAAA,EAAAC,gBAAA,EAAAC,oBAAA,EAAAC,mBAAA,EAAAC,UAAA,EAAAC,YAAA;AAAA,SACEC,aAAA;EAAAC,MAAA;EAAAC,KAAA;EAAAC,SAAA;EAAA,GAAAC;AAAA;EAAA,MACAC,gBAAA;EAAA,MACAC,YAAA;EAAA,KACA;IAAAC,IAAA;IAAAC;EAAA,KAAAP,MAAA;IACA,MAAAQ,GAAA,GAAAC,YAAA;MACA,GAAAN,KAAA;MACAG,IAAA;MACAC,KAAA;MAAAG,WACK;MAmBAC,YAAS;IACd;IACA,IAAAH,GAAA;MACAJ,gBAAY,CAAAE,IAAA,IAAAE,GAAA,CAAAD,KAAA;MACZF,YAAG,CAAAC,IAAA,IAAAE,GAAA,CAAAI,QAAA;IACL;EAME;EACA,MAAAC,QAAM,GAAAX,SAA6C,GAAAY,cAAA,CAAAT,YAAA,EAAAJ,KAAA;EACnDX,eAAa,OAAM;IACjB,WAAMyB,SAAM,IAAAX,gBAAa;MAAA,MACpBG,KAAA,GAAAH,gBAAA,CAAAW,SAAA;MAAAC,iBACH,CAAAD,SAAA,EAAAR,KAAA;IAAA;IACAU,iBAAA;EAAA;EAEa;IAAAjB,MAEb,EAAAI,gBAAc;IAAAc,SACf,EAAAb,YAAA;IACDQ;EACE;AACA;AAAyB,SAC3BJ,aAAAN,KAAA;EAAA,IACFd,QAAA;IAEA,IAAA8B,OAAM,CAAAC,GAAA,CAAAC,QAAW,KAAY,eAAeC,OAAA,CAAAC,IAAA,iDAAwB;IAEpE;EACE;EACE,MAAAC,MAAM,GAAA/B,SAAQ;EACd;IAAAa,IAAA,EAAAS,SAAkB;IAAAR,KAAA,EAAAkB,OAAgB;IAAA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AAAO,KAAA,GAAAP,MAAA,CAAAe,SAA2B;IAC7B,MAAAgB,KAAA,GAAArC,gBAAA;MAEA8B,MAAM;MAENT,SAAM;MAAWiB,KACf,GAAAjB,SAAU;MAAAkB,YACH;MAAA1B,KACP;MACF2B,mBAAA;IAEA;IACErB,QAAA,GAAO,IAAAA,QAAA,KAAAkB,KAAA;IACT,KAAA9B,KAAA,EAAAkC,WAAA,kBAAApB,SAAA,IAAAgB,KAAA;EAEA;EACE,IAAApC,oBAAoB,CAAAyC,MAAA,MAAAD,WAAe,4BAAAxC,oBAAA,CAAA0C,GAAA,CAAAC,CAAA,SAAAA,CAAA,CAAAhC,IAAA,IAAAgC,CAAA,CAAAC,GAAA,IAAAC,IAAA;EAAA,IAAAvC,KAChC,EAAAkC,WAAY,yBAAAlC,KAAA,eAAAA,KAAA,GAAAJ,UAAA,CAAA4C,MAAA,CAAAC,IAAA,CAAA1C,MAAA,EAAAwC,IAAA,SAAA3B,QAAA;EAAA,OACdA,QAAA;AAAA;AAGH,SAAAsB,WAAkBA,CAAAQ,EAAA,EAAAZ,KAAA,EAAW;EAC7B,MAAAa,QAAA,GAAAC,QAAkB,CAAAC,aAAA,KAAAH,EAAA;EAElB,MAAAI,KAAO,GAAAF,QAAA,CAAAG,aAAA;EACTD,KAAA,CAAAJ,EAAA,GAAAA,EAAA;EAEAI,KAAA,CAAAE,WAAS,CAAAJ,QAAkB,CAAAK,cAAmB,CAAAnB,KAAoB,CAAAS,IAAA;EAChEK,QAAM,CAAAM,IAAA,CAAAF,WAAS,CAAUF,KAAA;EACzB,IAAAH,QAAO,EAAAA,QAAO,CAAAQ,aAAa,EAAAC,WAAA,CAAAT,QAAA;AAC3B;AACF,SAAAnC,YAAA,EAAAV,YAAA","ignoreList":[]}
|
|
@@ -3,50 +3,53 @@ import { startTransition } from "@tamagui/start-transition";
|
|
|
3
3
|
import { ensureThemeVariable, forceUpdateThemes, getConfig, getThemeCSSRules, mutatedAutoVariables, proxyThemeToParents, simpleHash, updateConfig } from "@tamagui/web";
|
|
4
4
|
function mutateThemes(param) {
|
|
5
5
|
var {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
_didIteratorError =
|
|
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
15
|
_iteratorError = void 0;
|
|
16
16
|
try {
|
|
17
|
-
for (var _iterator = themes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion =
|
|
17
|
+
for (var _iterator = themes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
18
18
|
var {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
+
}
|
|
32
33
|
}
|
|
33
34
|
} catch (err) {
|
|
34
|
-
_didIteratorError =
|
|
35
|
+
_didIteratorError = true;
|
|
36
|
+
_iteratorError = err;
|
|
35
37
|
} finally {
|
|
36
38
|
try {
|
|
37
|
-
!_iteratorNormalCompletion && _iterator.return != null
|
|
39
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
|
|
38
40
|
} finally {
|
|
39
41
|
if (_didIteratorError) throw _iteratorError;
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
var cssRules = insertCSS ? insertThemeCSS(allThemesRaw, batch) : [];
|
|
43
|
-
|
|
45
|
+
startTransition(function () {
|
|
44
46
|
for (var themeName in allThemesProxied) {
|
|
45
47
|
var theme2 = allThemesProxied[themeName];
|
|
46
48
|
updateThemeConfig(themeName, theme2);
|
|
47
49
|
}
|
|
48
50
|
updateThemeStates();
|
|
49
|
-
})
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
50
53
|
themes: allThemesProxied,
|
|
51
54
|
themesRaw: allThemesRaw,
|
|
52
55
|
cssRules
|
|
@@ -54,78 +57,52 @@ function mutateThemes(param) {
|
|
|
54
57
|
}
|
|
55
58
|
function _mutateTheme(props) {
|
|
56
59
|
if (isServer) {
|
|
57
|
-
process.env.NODE_ENV === "development"
|
|
60
|
+
if (process.env.NODE_ENV === "development") console.warn("Theme mutation is not supported on server side");
|
|
58
61
|
return;
|
|
59
62
|
}
|
|
60
|
-
var config = getConfig()
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
var config = getConfig();
|
|
64
|
+
var {
|
|
65
|
+
name: themeName,
|
|
66
|
+
theme: themeIn,
|
|
67
|
+
insertCSS,
|
|
68
|
+
mutationType
|
|
69
|
+
} = props;
|
|
67
70
|
if (process.env.NODE_ENV === "development") {
|
|
68
71
|
if (!config) throw new Error("No config");
|
|
69
72
|
var theme = config.themes[props.name];
|
|
70
73
|
if (mutationType !== "add" && !theme) throw new Error(`${mutationType === "replace" ? "Replace" : "Update"} theme failed! Theme ${props.name} does not exist`);
|
|
71
74
|
}
|
|
72
|
-
var _config_themes_themeName
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
+
};
|
|
77
80
|
for (var key in theme1) ensureThemeVariable(theme1, key);
|
|
78
|
-
var themeProxied = proxyThemeToParents(themeName, theme1)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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({
|
|
85
89
|
[themeName]: theme1
|
|
86
|
-
})
|
|
90
|
+
});
|
|
91
|
+
updateThemeConfig(themeName, themeProxied);
|
|
92
|
+
updateThemeStates();
|
|
93
|
+
return response;
|
|
87
94
|
}
|
|
88
95
|
function updateThemeConfig(themeName, theme) {
|
|
89
96
|
var config = getConfig();
|
|
90
|
-
config.themes[themeName] = theme
|
|
97
|
+
config.themes[themeName] = theme;
|
|
98
|
+
updateConfig("themes", config.themes);
|
|
91
99
|
}
|
|
92
100
|
function updateThemeStates() {
|
|
93
101
|
forceUpdateThemes();
|
|
94
102
|
}
|
|
95
103
|
function insertThemeCSS(themes) {
|
|
96
|
-
|
|
104
|
+
arguments.length > 1 && arguments[1] !== void 0 && arguments[1];
|
|
97
105
|
return [];
|
|
98
|
-
var config, cssRules;
|
|
99
|
-
for (var themeName in themes) {
|
|
100
|
-
var theme = themes[themeName],
|
|
101
|
-
rules = getThemeCSSRules({
|
|
102
|
-
config,
|
|
103
|
-
themeName,
|
|
104
|
-
names: [themeName],
|
|
105
|
-
hasDarkLight: !0,
|
|
106
|
-
theme,
|
|
107
|
-
// Use mutated variable creator which starts from high index to avoid conflicts
|
|
108
|
-
useMutatedVariables: !0
|
|
109
|
-
});
|
|
110
|
-
cssRules = [...cssRules, ...rules], batch || updateStyle(`t_theme_style_${themeName}`, rules);
|
|
111
|
-
}
|
|
112
|
-
if (mutatedAutoVariables.length > 0) {
|
|
113
|
-
var autoVarCSS;
|
|
114
|
-
updateStyle("t_mutate_vars", [autoVarCSS]);
|
|
115
|
-
}
|
|
116
|
-
if (batch) {
|
|
117
|
-
var id;
|
|
118
|
-
updateStyle(`t_theme_style_${id}`, cssRules);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
function updateStyle(id, rules) {
|
|
122
|
-
var existing = document.querySelector(`#${id}`),
|
|
123
|
-
style = document.createElement("style");
|
|
124
|
-
if (style.id = id, style.appendChild(document.createTextNode(rules.join(`
|
|
125
|
-
`))), document.head.appendChild(style), existing) {
|
|
126
|
-
var _existing_parentElement;
|
|
127
|
-
(_existing_parentElement = existing.parentElement) === null || _existing_parentElement === void 0 || _existing_parentElement.removeChild(existing);
|
|
128
|
-
}
|
|
129
106
|
}
|
|
130
107
|
export { _mutateTheme, mutateThemes };
|
|
131
108
|
//# sourceMappingURL=_mutateTheme.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isServer","startTransition","ensureThemeVariable","forceUpdateThemes","getConfig","getThemeCSSRules","mutatedAutoVariables","proxyThemeToParents","simpleHash","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"
|
|
1
|
+
{"version":3,"names":["isServer","startTransition","ensureThemeVariable","forceUpdateThemes","getConfig","getThemeCSSRules","mutatedAutoVariables","proxyThemeToParents","simpleHash","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":["../../src/_mutateTheme.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,QAAA,QAAgB;AACzB,SAASC,eAAA,QAAuB;AAEhC,SAAAC,mBAAA,EAAAC,iBAAA,EAAAC,SAAA,EAAAC,gBAAA,EAAAC,oBAAA,EAAAC,mBAAA,EAAAC,UAAA,EAAAC,YAAA;AAAA,SACEC,aAAAC,KAAA;EAAA,IACA;IAAAC,MAAA;IAAAC,KAAA;IAAAC,SAAA;IAAA,GAAAC;EAAA,IAAAJ,KAAA;EAAA,IACAK,gBAAA;EAAA,IACAC,YAAA;EAAA,IACAC,yBAAA;IAAAC,iBAAA;IAAAC,cAAA;EAAA,IACA;IACA,SAAAC,SAAA,GAAAT,MAAA,CAAAU,MAAA,CAAAC,QAAA,KAAAC,KAAA,IAAAN,yBAAA,IAAAM,KAAA,GAAAH,SAAA,CAAAI,IAAA,IAAAC,IAAA,GAAAR,yBAAA;MACA;QAAAS,IAAA;QAAAC;MAAA,IAAAJ,KAAA,CAAAK,KAAA;MAAA,IACKC,GAAA,GAAAC,YAAA;QAmBA,GAAAhB,KAAS;QACdY,IAAA;QACAC,KAAA;QACAI,WAAY;QACZC,YAAG;MAMF;MACD,IAAAH,GAAM;QACNd,gBAAM,CAAAW,IAA6C,IAAAG,GAAA,CAAAF,KAAA;QACnDX,YAAa,CAAAU,IAAM,IAAAG,GAAM,CAAAI,QAAK;MAC5B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