@hanzogui/theme 3.0.6 → 4.3.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 +91 -58
- package/dist/cjs/_mutateTheme.native.js +128 -89
- 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 +76 -45
- package/dist/esm/_mutateTheme.mjs.map +1 -1
- package/dist/esm/_mutateTheme.native.js +113 -76
- 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/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 +1 -1
- package/src/_mutateTheme.ts +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -3,21 +3,23 @@ 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
|
-
|
|
18
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
21
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
20
|
-
value:
|
|
22
|
+
value: true
|
|
21
23
|
}), mod);
|
|
22
24
|
var index_exports = {};
|
|
23
25
|
__export(index_exports, {
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -5,21 +5,23 @@ 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
|
-
|
|
20
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
23
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
22
|
-
value:
|
|
24
|
+
value: true
|
|
23
25
|
}), mod);
|
|
24
26
|
var index_exports = {};
|
|
25
27
|
__export(index_exports, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","mutateThemes","import_mutateTheme","module","exports","__reExport","require"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","mutateThemes","import_mutateTheme","module","exports","__reExport","require"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,YAAA,EAAAA,CAAA,KAAAC,kBAAA,CAAAD;AAAA;AAAAE,MAAA,CAAAC,OAAA,GAAAV,YAAc,CAAAK,aAAA;AACdM,UAAA,CAAAN,aAAA,EAAcO,OAAA,0BAAAH,MADd,CAAAC,OAAA;AAEAC,UAAA,CAAAN,aAAA,EAAcO,OAAA,6BAAAH,MAFd,CAAAC,OAAA;AAGAC,UAAA,CAAAN,aAAA,EAA6BO,OAAA,8BAAAH,MAAA,CAAAC,OAAA","ignoreList":[]}
|
|
@@ -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
|
|
@@ -18,20 +18,24 @@ function mutateThemes({
|
|
|
18
18
|
name,
|
|
19
19
|
theme,
|
|
20
20
|
// we'll do one update at the end
|
|
21
|
-
avoidUpdate:
|
|
21
|
+
avoidUpdate: true,
|
|
22
22
|
// always add which also replaces but doesnt fail first time
|
|
23
23
|
mutationType: "add"
|
|
24
24
|
});
|
|
25
|
-
|
|
25
|
+
if (res) {
|
|
26
|
+
allThemesProxied[name] = res.theme;
|
|
27
|
+
allThemesRaw[name] = res.themeRaw;
|
|
28
|
+
}
|
|
26
29
|
}
|
|
27
30
|
const cssRules = insertCSS ? insertThemeCSS(allThemesRaw, batch) : [];
|
|
28
|
-
|
|
31
|
+
startTransition(() => {
|
|
29
32
|
for (const themeName in allThemesProxied) {
|
|
30
33
|
const theme = allThemesProxied[themeName];
|
|
31
34
|
updateThemeConfig(themeName, theme);
|
|
32
35
|
}
|
|
33
36
|
updateThemeStates();
|
|
34
|
-
})
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
35
39
|
themes: allThemesProxied,
|
|
36
40
|
themesRaw: allThemesRaw,
|
|
37
41
|
cssRules
|
|
@@ -39,62 +43,85 @@ function mutateThemes({
|
|
|
39
43
|
}
|
|
40
44
|
function _mutateTheme(props) {
|
|
41
45
|
if (isServer) {
|
|
42
|
-
process.env.NODE_ENV === "development"
|
|
46
|
+
if (process.env.NODE_ENV === "development") {
|
|
47
|
+
console.warn("Theme mutation is not supported on server side");
|
|
48
|
+
}
|
|
43
49
|
return;
|
|
44
50
|
}
|
|
45
|
-
const config = getConfig()
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
const config = getConfig();
|
|
52
|
+
const {
|
|
53
|
+
name: themeName,
|
|
54
|
+
theme: themeIn,
|
|
55
|
+
insertCSS,
|
|
56
|
+
mutationType
|
|
57
|
+
} = props;
|
|
52
58
|
if (process.env.NODE_ENV === "development") {
|
|
53
|
-
if (!config)
|
|
59
|
+
if (!config) {
|
|
60
|
+
throw new Error("No config");
|
|
61
|
+
}
|
|
54
62
|
const theme2 = config.themes[props.name];
|
|
55
|
-
if (mutationType !== "add" && !theme2)
|
|
63
|
+
if (mutationType !== "add" && !theme2) {
|
|
64
|
+
throw new Error(`${mutationType === "replace" ? "Replace" : "Update"} theme failed! Theme ${props.name} does not exist`);
|
|
65
|
+
}
|
|
56
66
|
}
|
|
57
67
|
const theme = {
|
|
58
68
|
...(mutationType === "update" ? config.themes[themeName] ?? {} : {}),
|
|
59
69
|
...themeIn
|
|
60
70
|
};
|
|
61
|
-
for (const key in theme)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
for (const key in theme) {
|
|
72
|
+
ensureThemeVariable(theme, key);
|
|
73
|
+
}
|
|
74
|
+
const themeProxied = proxyThemeToParents(themeName, theme);
|
|
75
|
+
const response = {
|
|
76
|
+
themeRaw: theme,
|
|
77
|
+
theme: themeProxied,
|
|
78
|
+
cssRules: []
|
|
79
|
+
};
|
|
80
|
+
if (props.avoidUpdate) {
|
|
81
|
+
return response;
|
|
82
|
+
}
|
|
83
|
+
if (insertCSS) {
|
|
84
|
+
response.cssRules = insertThemeCSS({
|
|
85
|
+
[themeName]: theme
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
updateThemeConfig(themeName, themeProxied);
|
|
89
|
+
updateThemeStates();
|
|
90
|
+
return response;
|
|
71
91
|
}
|
|
72
92
|
function updateThemeConfig(themeName, theme) {
|
|
73
93
|
const config = getConfig();
|
|
74
|
-
config.themes[themeName] = theme
|
|
94
|
+
config.themes[themeName] = theme;
|
|
95
|
+
updateConfig("themes", config.themes);
|
|
75
96
|
}
|
|
76
97
|
function updateThemeStates() {
|
|
77
98
|
forceUpdateThemes();
|
|
78
99
|
}
|
|
79
|
-
function insertThemeCSS(themes, batch =
|
|
100
|
+
function insertThemeCSS(themes, batch = false) {
|
|
101
|
+
if (false) {
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
80
104
|
const config = getConfig();
|
|
81
105
|
let cssRules = [];
|
|
82
106
|
for (const themeName in themes) {
|
|
83
|
-
const theme = themes[themeName]
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
cssRules = [...cssRules, ...rules]
|
|
107
|
+
const theme = themes[themeName];
|
|
108
|
+
const rules = getThemeCSSRules({
|
|
109
|
+
config,
|
|
110
|
+
themeName,
|
|
111
|
+
names: [themeName],
|
|
112
|
+
hasDarkLight: true,
|
|
113
|
+
theme,
|
|
114
|
+
// Use mutated variable creator which starts from high index to avoid conflicts
|
|
115
|
+
useMutatedVariables: true
|
|
116
|
+
});
|
|
117
|
+
cssRules = [...cssRules, ...rules];
|
|
118
|
+
if (!batch) {
|
|
119
|
+
updateStyle(`t_theme_style_${themeName}`, rules);
|
|
120
|
+
}
|
|
94
121
|
}
|
|
95
122
|
if (mutatedAutoVariables.length > 0) {
|
|
96
123
|
const autoVarCSS = `:root{${mutatedAutoVariables.map(v => `--${v.name}:${v.val}`).join(";")}}`;
|
|
97
|
-
updateStyle(
|
|
124
|
+
updateStyle(`t_mutate_vars`, [autoVarCSS]);
|
|
98
125
|
}
|
|
99
126
|
if (batch) {
|
|
100
127
|
const id = typeof batch == "string" ? batch : simpleHash(Object.keys(themes).join(""));
|
|
@@ -103,10 +130,14 @@ function insertThemeCSS(themes, batch = !1) {
|
|
|
103
130
|
return cssRules;
|
|
104
131
|
}
|
|
105
132
|
function updateStyle(id, rules) {
|
|
106
|
-
const existing = document.querySelector(`#${id}`)
|
|
107
|
-
|
|
108
|
-
style.id = id
|
|
109
|
-
|
|
133
|
+
const existing = document.querySelector(`#${id}`);
|
|
134
|
+
const style = document.createElement("style");
|
|
135
|
+
style.id = id;
|
|
136
|
+
style.appendChild(document.createTextNode(rules.join("\n")));
|
|
137
|
+
document.head.appendChild(style);
|
|
138
|
+
if (existing) {
|
|
139
|
+
existing.parentElement?.removeChild(existing);
|
|
140
|
+
}
|
|
110
141
|
}
|
|
111
142
|
export { _mutateTheme, mutateThemes };
|
|
112
143
|
//# 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","autoVarCSS","map","v","val","join","id","Object","keys","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,SACEC,mBAAA,EACAC,iBAAA,EACAC,SAAA,EACAC,gBAAA,EACAC,oBAAA,EACAC,mBAAA,EACAC,UAAA,EACAC,YAAA,QACK;AAmBA,SAASC,aAAa;EAC3BC,MAAA;EACAC,KAAA;EACAC,SAAA,GAAY;EACZ,GAAGC;AACL,GAKG;EACD,MAAMC,gBAAA,GAAgD,CAAC;
|
|
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","autoVarCSS","map","v","val","join","id","Object","keys","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,SACEC,mBAAA,EACAC,iBAAA,EACAC,SAAA,EACAC,gBAAA,EACAC,oBAAA,EACAC,mBAAA,EACAC,UAAA,EACAC,YAAA,QACK;AAmBA,SAASC,aAAa;EAC3BC,MAAA;EACAC,KAAA;EACAC,SAAA,GAAY;EACZ,GAAGC;AACL,GAKG;EACD,MAAMC,gBAAA,GAAgD,CAAC;EACvD,MAAMC,YAAA,GAA4C,CAAC;EACnD,WAAW;IAAEC,IAAA;IAAMC;EAAM,KAAKP,MAAA,EAAQ;IACpC,MAAMQ,GAAA,GAAMC,YAAA,CAAa;MACvB,GAAGN,KAAA;MACHG,IAAA;MACAC,KAAA;MAAA;MAEAG,WAAA,EAAa;MAAA;MAEbC,YAAA,EAAc;IAChB,CAAC;IACD,IAAIH,GAAA,EAAK;MACPJ,gBAAA,CAAiBE,IAAI,IAAIE,GAAA,CAAID,KAAA;MAC7BF,YAAA,CAAaC,IAAI,IAAIE,GAAA,CAAII,QAAA;IAC3B;EACF;EAEA,MAAMC,QAAA,GAAWX,SAAA,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