@tamagui/theme 1.110.4 → 1.111.0
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.native.js +20 -91
- package/dist/cjs/_mutateTheme.native.js.map +1 -1
- package/dist/cjs/addTheme.native.js +3 -36
- package/dist/cjs/addTheme.native.js.map +1 -1
- package/dist/cjs/replaceTheme.native.js +1 -1
- package/dist/cjs/replaceTheme.native.js.map +1 -1
- package/dist/cjs/updateTheme.native.js +1 -1
- package/dist/cjs/updateTheme.native.js.map +1 -1
- package/dist/esm/_mutateTheme.native.js +20 -91
- package/dist/esm/_mutateTheme.native.js.map +1 -1
- package/dist/esm/_mutateTheme.native.mjs +130 -0
- package/dist/esm/_mutateTheme.native.mjs.map +1 -0
- package/dist/esm/addTheme.native.js +3 -36
- package/dist/esm/addTheme.native.js.map +1 -1
- package/dist/esm/addTheme.native.mjs +10 -0
- package/dist/esm/addTheme.native.mjs.map +1 -0
- package/dist/esm/index.native.mjs +6 -0
- package/dist/esm/index.native.mjs.map +1 -0
- package/dist/esm/replaceTheme.native.js +1 -1
- package/dist/esm/replaceTheme.native.js.map +1 -1
- package/dist/esm/replaceTheme.native.mjs +16 -0
- package/dist/esm/replaceTheme.native.mjs.map +1 -0
- package/dist/esm/updateTheme.native.js +1 -1
- package/dist/esm/updateTheme.native.js.map +1 -1
- package/dist/esm/updateTheme.native.mjs +15 -0
- package/dist/esm/updateTheme.native.mjs.map +1 -0
- package/dist/jsx/_mutateTheme.native.js +20 -91
- package/dist/jsx/_mutateTheme.native.js.map +1 -1
- package/dist/jsx/addTheme.native.js +3 -36
- package/dist/jsx/addTheme.native.js.map +1 -1
- package/dist/jsx/replaceTheme.native.js +1 -1
- package/dist/jsx/replaceTheme.native.js.map +1 -1
- package/dist/jsx/updateTheme.native.js +1 -1
- package/dist/jsx/updateTheme.native.js.map +1 -1
- package/package.json +4 -4
|
@@ -20,98 +20,19 @@ __export(mutateTheme_exports, {
|
|
|
20
20
|
});
|
|
21
21
|
module.exports = __toCommonJS(mutateTheme_exports);
|
|
22
22
|
var import_react = require("react"), import_constants = require("@tamagui/constants"), import_web = require("@tamagui/web"), import_start_transition = require("@tamagui/start-transition");
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
26
|
-
return arr2;
|
|
27
|
-
}
|
|
28
|
-
function _array_without_holes(arr) {
|
|
29
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
30
|
-
}
|
|
31
|
-
function _define_property(obj, key, value) {
|
|
32
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
33
|
-
value,
|
|
34
|
-
enumerable: !0,
|
|
35
|
-
configurable: !0,
|
|
36
|
-
writable: !0
|
|
37
|
-
}) : obj[key] = value, obj;
|
|
38
|
-
}
|
|
39
|
-
function _iterable_to_array(iter) {
|
|
40
|
-
if (typeof Symbol < "u" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
41
|
-
}
|
|
42
|
-
function _non_iterable_spread() {
|
|
43
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
44
|
-
}
|
|
45
|
-
function _object_spread(target) {
|
|
46
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
47
|
-
var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
|
|
48
|
-
typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
49
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
50
|
-
}))), ownKeys2.forEach(function(key) {
|
|
51
|
-
_define_property(target, key, source[key]);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return target;
|
|
55
|
-
}
|
|
56
|
-
function ownKeys(object, enumerableOnly) {
|
|
57
|
-
var keys = Object.keys(object);
|
|
58
|
-
if (Object.getOwnPropertySymbols) {
|
|
59
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
60
|
-
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
61
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
62
|
-
})), keys.push.apply(keys, symbols);
|
|
63
|
-
}
|
|
64
|
-
return keys;
|
|
65
|
-
}
|
|
66
|
-
function _object_spread_props(target, source) {
|
|
67
|
-
return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
68
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
69
|
-
}), target;
|
|
70
|
-
}
|
|
71
|
-
function _object_without_properties(source, excluded) {
|
|
72
|
-
if (source == null) return {};
|
|
73
|
-
var target = _object_without_properties_loose(source, excluded), key, i;
|
|
74
|
-
if (Object.getOwnPropertySymbols) {
|
|
75
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
76
|
-
for (i = 0; i < sourceSymbolKeys.length; i++)
|
|
77
|
-
key = sourceSymbolKeys[i], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
|
|
78
|
-
}
|
|
79
|
-
return target;
|
|
80
|
-
}
|
|
81
|
-
function _object_without_properties_loose(source, excluded) {
|
|
82
|
-
if (source == null) return {};
|
|
83
|
-
var target = {}, sourceKeys = Object.keys(source), key, i;
|
|
84
|
-
for (i = 0; i < sourceKeys.length; i++)
|
|
85
|
-
key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
|
|
86
|
-
return target;
|
|
87
|
-
}
|
|
88
|
-
function _to_consumable_array(arr) {
|
|
89
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
90
|
-
}
|
|
91
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
92
|
-
if (o) {
|
|
93
|
-
if (typeof o == "string") return _array_like_to_array(o, minLen);
|
|
94
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
95
|
-
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
|
|
96
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
function mutateThemes(_param) {
|
|
100
|
-
var themes = _param.themes, batch = _param.batch, _param_insertCSS = _param.insertCSS, insertCSS = _param_insertCSS === void 0 ? !0 : _param_insertCSS, props = _object_without_properties(_param, [
|
|
101
|
-
"themes",
|
|
102
|
-
"batch",
|
|
103
|
-
"insertCSS"
|
|
104
|
-
]), allThemesProxied = {}, allThemesRaw = {}, _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
|
23
|
+
function mutateThemes(param) {
|
|
24
|
+
var { themes, batch, insertCSS = !0, ...props } = param, allThemesProxied = {}, allThemesRaw = {}, _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
|
105
25
|
try {
|
|
106
26
|
for (var _iterator = themes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
107
|
-
var
|
|
27
|
+
var { name, theme } = _step.value, res = _mutateTheme({
|
|
28
|
+
...props,
|
|
108
29
|
name,
|
|
109
30
|
theme,
|
|
110
31
|
// we'll do one update at the end
|
|
111
32
|
avoidUpdate: !0,
|
|
112
33
|
// always add which also replaces but doesnt fail first time
|
|
113
34
|
mutationType: "add"
|
|
114
|
-
})
|
|
35
|
+
});
|
|
115
36
|
res && (allThemesProxied[name] = res.theme, allThemesRaw[name] = res.themeRaw);
|
|
116
37
|
}
|
|
117
38
|
} catch (err) {
|
|
@@ -141,15 +62,18 @@ function _mutateTheme(props) {
|
|
|
141
62
|
process.env.NODE_ENV === "development" && console.warn("Theme mutation is not supported on server side");
|
|
142
63
|
return;
|
|
143
64
|
}
|
|
144
|
-
var config = (0, import_web.getConfig)(),
|
|
65
|
+
var config = (0, import_web.getConfig)(), { name: themeName, theme: themeIn, insertCSS, mutationType } = props;
|
|
145
66
|
if (process.env.NODE_ENV === "development") {
|
|
146
67
|
if (!config)
|
|
147
68
|
throw new Error("No config");
|
|
148
69
|
var theme = config.themes[props.name];
|
|
149
70
|
if (mutationType !== "add" && !theme)
|
|
150
|
-
throw new Error(
|
|
71
|
+
throw new Error(`${mutationType === "replace" ? "Replace" : "Update"} theme failed! Theme ${props.name} does not exist`);
|
|
151
72
|
}
|
|
152
|
-
var _config_themes_themeName, theme1 =
|
|
73
|
+
var _config_themes_themeName, theme1 = {
|
|
74
|
+
...mutationType === "update" ? (_config_themes_themeName = config.themes[themeName]) !== null && _config_themes_themeName !== void 0 ? _config_themes_themeName : {} : {},
|
|
75
|
+
...themeIn
|
|
76
|
+
};
|
|
153
77
|
for (var key in theme1)
|
|
154
78
|
(0, import_web.ensureThemeVariable)(theme1, key);
|
|
155
79
|
var themeProxied = (0, import_web.proxyThemeToParents)(themeName, theme1), response = {
|
|
@@ -157,7 +81,9 @@ function _mutateTheme(props) {
|
|
|
157
81
|
theme: themeProxied,
|
|
158
82
|
cssRules: []
|
|
159
83
|
};
|
|
160
|
-
return props.avoidUpdate || (insertCSS && (response.cssRules = insertThemeCSS(
|
|
84
|
+
return props.avoidUpdate || (insertCSS && (response.cssRules = insertThemeCSS({
|
|
85
|
+
[themeName]: theme1
|
|
86
|
+
})), updateThemeConfig(themeName, themeProxied), notifyThemeManagersOfUpdate(themeName, themeProxied)), response;
|
|
161
87
|
}
|
|
162
88
|
function updateThemeConfig(themeName, theme) {
|
|
163
89
|
var config = (0, import_web.getConfig)();
|
|
@@ -185,15 +111,18 @@ function insertThemeCSS(themes) {
|
|
|
185
111
|
hasDarkLight: !0,
|
|
186
112
|
theme
|
|
187
113
|
});
|
|
188
|
-
cssRules =
|
|
114
|
+
cssRules = [
|
|
115
|
+
...cssRules,
|
|
116
|
+
...rules
|
|
117
|
+
], batch || updateStyle(`t_theme_style_${themeName}`, rules);
|
|
189
118
|
}
|
|
190
119
|
if (batch) {
|
|
191
120
|
var id;
|
|
192
|
-
updateStyle(
|
|
121
|
+
updateStyle(`t_theme_style_${id}`, cssRules);
|
|
193
122
|
}
|
|
194
123
|
}
|
|
195
124
|
function updateStyle(id, rules) {
|
|
196
|
-
var existing = document.querySelector(
|
|
125
|
+
var existing = document.querySelector(`#${id}`), style = document.createElement("style");
|
|
197
126
|
if (style.id = id, style.appendChild(document.createTextNode(rules.join(`
|
|
198
127
|
`))), document.head.appendChild(style), existing) {
|
|
199
128
|
var _existing_parentElement;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/core/theme/src/_mutateTheme.ts"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;;;;;;mBAAkB,kBAClB,mBAAyB,+BAEzB,aAQO,yBACP,0BAAgC;AAmBzB,SAASA,aAAa;MAAA,EAC3BC,QACAC,OACAC,YAAY,IACZ,GAAGC,MAAAA,IAJwB,OAWrBC,mBAAgD,CAAC,GACjDC,eAA4C,CAAC,GAC9C,4BAAA,IAAA,oBAAA,IAAA,iBAAA;;AAAL,aAAK,YAAyBL,OAAAA,OAAAA,QAAAA,EAAAA,GAAzB,OAAA,EAAA,6BAAA,QAAA,UAAA,KAAA,GAAA,OAAA,4BAAA,IAAiC;AAAjC,UAAM,EAAEM,MAAMC,MAAK,IAAnB,MAAA,OACGC,MAAMC,aAAa;QACvB,GAAGN;QACHG;QACAC;;QAEAG,aAAa;;QAEbC,cAAc;MAChB,CAAA;AACA,MAAIH,QACFJ,iBAAiBE,IAAAA,IAAQE,IAAID,OAC7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AA,GACrDN,SAASO,KAAKH,YAAYF,KAAAA,GACtBH,UAAU;QACZA;KAAAA,0BAAAA,SAASS,mBAAa,QAAtBT,4BAAAA,UAAAA,wBAAwBU,YAAYV,QAAAA;EACtC;AACF;",
|
|
5
5
|
"names": ["mutateThemes", "themes", "batch", "insertCSS", "props", "allThemesProxied", "allThemesRaw", "name", "theme", "res", "_mutateTheme", "avoidUpdate", "mutationType", "themeRaw", "cssRules", "insertThemeCSS", "startTransition", "themeName", "updateThemeConfig", "notifyThemeManagersOfUpdate", "themesRaw", "isServer", "process", "env", "NODE_ENV", "console", "warn", "config", "getConfig", "themeIn", "Error", "key", "ensureThemeVariable", "themeProxied", "proxyThemeToParents", "response", "updateConfig", "activeThemeManagers", "forEach", "manager", "state", "updateStateFromProps", "forceTheme", "rules", "getThemeCSSRules", "names", "hasDarkLight", "updateStyle", "id", "existing", "document", "querySelector", "style", "createElement", "appendChild", "createTextNode", "join", "head", "parentElement", "removeChild"]
|
|
6
6
|
}
|
|
@@ -19,45 +19,12 @@ __export(addTheme_exports, {
|
|
|
19
19
|
});
|
|
20
20
|
module.exports = __toCommonJS(addTheme_exports);
|
|
21
21
|
var import_mutateTheme = require("./_mutateTheme");
|
|
22
|
-
function _define_property(obj, key, value) {
|
|
23
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
24
|
-
value,
|
|
25
|
-
enumerable: !0,
|
|
26
|
-
configurable: !0,
|
|
27
|
-
writable: !0
|
|
28
|
-
}) : obj[key] = value, obj;
|
|
29
|
-
}
|
|
30
|
-
function _object_spread(target) {
|
|
31
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
32
|
-
var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
|
|
33
|
-
typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
34
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
35
|
-
}))), ownKeys2.forEach(function(key) {
|
|
36
|
-
_define_property(target, key, source[key]);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
return target;
|
|
40
|
-
}
|
|
41
|
-
function ownKeys(object, enumerableOnly) {
|
|
42
|
-
var keys = Object.keys(object);
|
|
43
|
-
if (Object.getOwnPropertySymbols) {
|
|
44
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
45
|
-
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
46
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
47
|
-
})), keys.push.apply(keys, symbols);
|
|
48
|
-
}
|
|
49
|
-
return keys;
|
|
50
|
-
}
|
|
51
|
-
function _object_spread_props(target, source) {
|
|
52
|
-
return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
53
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
54
|
-
}), target;
|
|
55
|
-
}
|
|
56
22
|
function addTheme(props) {
|
|
57
|
-
return (0, import_mutateTheme._mutateTheme)(
|
|
23
|
+
return (0, import_mutateTheme._mutateTheme)({
|
|
24
|
+
...props,
|
|
58
25
|
insertCSS: !0,
|
|
59
26
|
mutationType: "add"
|
|
60
|
-
})
|
|
27
|
+
});
|
|
61
28
|
}
|
|
62
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
63
30
|
0 && (module.exports = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/core/theme/src/addTheme.ts"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AAEA;;;;;yBAA6B;AAEtB,SAASA,SAASC,OAIxB;AACC,aAAOC,iCAAa;IAAE,GAAGD;IAAOE,WAAW;IAAMC,cAAc;EAAM,CAAA;AACvE;",
|
|
5
5
|
"names": ["addTheme", "props", "_mutateTheme", "insertCSS", "mutationType"]
|
|
6
6
|
}
|
|
@@ -20,7 +20,7 @@ __export(replaceTheme_exports, {
|
|
|
20
20
|
module.exports = __toCommonJS(replaceTheme_exports);
|
|
21
21
|
var import_mutateTheme = require("./_mutateTheme");
|
|
22
22
|
function replaceTheme(param) {
|
|
23
|
-
var
|
|
23
|
+
var { name, theme } = param, next = (0, import_mutateTheme._mutateTheme)({
|
|
24
24
|
name,
|
|
25
25
|
theme,
|
|
26
26
|
insertCSS: !0,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/core/theme/src/replaceTheme.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;AAEA;;;;;yBAA6B;AAEtB,SAASA,aAAa,OAM5B;
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AAEA;;;;;yBAA6B;AAEtB,SAASA,aAAa,OAM5B;MAN4B,EAC3BC,MACAC,MAAK,IAFsB,OAOrBC,WAAOC,iCAAa;IAAEH;IAAMC;IAAOG,WAAW;IAAMC,cAAc;EAAU,CAAA;AAClF,SAAOH;AACT;",
|
|
5
5
|
"names": ["replaceTheme", "name", "theme", "next", "_mutateTheme", "insertCSS", "mutationType"]
|
|
6
6
|
}
|
|
@@ -20,7 +20,7 @@ __export(updateTheme_exports, {
|
|
|
20
20
|
module.exports = __toCommonJS(updateTheme_exports);
|
|
21
21
|
var import_mutateTheme = require("./_mutateTheme");
|
|
22
22
|
function updateTheme(param) {
|
|
23
|
-
var
|
|
23
|
+
var { name, theme } = param;
|
|
24
24
|
return (0, import_mutateTheme._mutateTheme)({
|
|
25
25
|
name,
|
|
26
26
|
theme,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/core/theme/src/updateTheme.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;AAEA;;;;;yBAA6B;AAEtB,SAASA,YAAY,OAM3B;
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AAEA;;;;;yBAA6B;AAEtB,SAASA,YAAY,OAM3B;MAN2B,EAC1BC,MACAC,MAAK,IAFqB;AAO1B,aAAOC,iCAAa;IAAEF;IAAMC;IAAOE,WAAW;IAAMC,cAAc;EAAS,CAAA;AAC7E;",
|
|
5
5
|
"names": ["updateTheme", "name", "theme", "_mutateTheme", "insertCSS", "mutationType"]
|
|
6
6
|
}
|
|
@@ -2,98 +2,19 @@ import "react";
|
|
|
2
2
|
import { isServer } from "@tamagui/constants";
|
|
3
3
|
import { activeThemeManagers, ensureThemeVariable, getConfig, getThemeCSSRules, proxyThemeToParents, simpleHash, updateConfig } from "@tamagui/web";
|
|
4
4
|
import { startTransition } from "@tamagui/start-transition";
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
8
|
-
return arr2;
|
|
9
|
-
}
|
|
10
|
-
function _array_without_holes(arr) {
|
|
11
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
12
|
-
}
|
|
13
|
-
function _define_property(obj, key, value) {
|
|
14
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
15
|
-
value,
|
|
16
|
-
enumerable: !0,
|
|
17
|
-
configurable: !0,
|
|
18
|
-
writable: !0
|
|
19
|
-
}) : obj[key] = value, obj;
|
|
20
|
-
}
|
|
21
|
-
function _iterable_to_array(iter) {
|
|
22
|
-
if (typeof Symbol < "u" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
23
|
-
}
|
|
24
|
-
function _non_iterable_spread() {
|
|
25
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
26
|
-
}
|
|
27
|
-
function _object_spread(target) {
|
|
28
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
29
|
-
var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
|
|
30
|
-
typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
31
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
32
|
-
}))), ownKeys2.forEach(function(key) {
|
|
33
|
-
_define_property(target, key, source[key]);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return target;
|
|
37
|
-
}
|
|
38
|
-
function ownKeys(object, enumerableOnly) {
|
|
39
|
-
var keys = Object.keys(object);
|
|
40
|
-
if (Object.getOwnPropertySymbols) {
|
|
41
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
42
|
-
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
43
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
44
|
-
})), keys.push.apply(keys, symbols);
|
|
45
|
-
}
|
|
46
|
-
return keys;
|
|
47
|
-
}
|
|
48
|
-
function _object_spread_props(target, source) {
|
|
49
|
-
return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
50
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
51
|
-
}), target;
|
|
52
|
-
}
|
|
53
|
-
function _object_without_properties(source, excluded) {
|
|
54
|
-
if (source == null) return {};
|
|
55
|
-
var target = _object_without_properties_loose(source, excluded), key, i;
|
|
56
|
-
if (Object.getOwnPropertySymbols) {
|
|
57
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
58
|
-
for (i = 0; i < sourceSymbolKeys.length; i++)
|
|
59
|
-
key = sourceSymbolKeys[i], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
|
|
60
|
-
}
|
|
61
|
-
return target;
|
|
62
|
-
}
|
|
63
|
-
function _object_without_properties_loose(source, excluded) {
|
|
64
|
-
if (source == null) return {};
|
|
65
|
-
var target = {}, sourceKeys = Object.keys(source), key, i;
|
|
66
|
-
for (i = 0; i < sourceKeys.length; i++)
|
|
67
|
-
key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
|
|
68
|
-
return target;
|
|
69
|
-
}
|
|
70
|
-
function _to_consumable_array(arr) {
|
|
71
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
72
|
-
}
|
|
73
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
74
|
-
if (o) {
|
|
75
|
-
if (typeof o == "string") return _array_like_to_array(o, minLen);
|
|
76
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
77
|
-
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
|
|
78
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
function mutateThemes(_param) {
|
|
82
|
-
var themes = _param.themes, batch = _param.batch, _param_insertCSS = _param.insertCSS, insertCSS = _param_insertCSS === void 0 ? !0 : _param_insertCSS, props = _object_without_properties(_param, [
|
|
83
|
-
"themes",
|
|
84
|
-
"batch",
|
|
85
|
-
"insertCSS"
|
|
86
|
-
]), allThemesProxied = {}, allThemesRaw = {}, _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
|
5
|
+
function mutateThemes(param) {
|
|
6
|
+
var { themes, batch, insertCSS = !0, ...props } = param, allThemesProxied = {}, allThemesRaw = {}, _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
|
87
7
|
try {
|
|
88
8
|
for (var _iterator = themes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
89
|
-
var
|
|
9
|
+
var { name, theme } = _step.value, res = _mutateTheme({
|
|
10
|
+
...props,
|
|
90
11
|
name,
|
|
91
12
|
theme,
|
|
92
13
|
// we'll do one update at the end
|
|
93
14
|
avoidUpdate: !0,
|
|
94
15
|
// always add which also replaces but doesnt fail first time
|
|
95
16
|
mutationType: "add"
|
|
96
|
-
})
|
|
17
|
+
});
|
|
97
18
|
res && (allThemesProxied[name] = res.theme, allThemesRaw[name] = res.themeRaw);
|
|
98
19
|
}
|
|
99
20
|
} catch (err) {
|
|
@@ -123,15 +44,18 @@ function _mutateTheme(props) {
|
|
|
123
44
|
process.env.NODE_ENV === "development" && console.warn("Theme mutation is not supported on server side");
|
|
124
45
|
return;
|
|
125
46
|
}
|
|
126
|
-
var config = getConfig(),
|
|
47
|
+
var config = getConfig(), { name: themeName, theme: themeIn, insertCSS, mutationType } = props;
|
|
127
48
|
if (process.env.NODE_ENV === "development") {
|
|
128
49
|
if (!config)
|
|
129
50
|
throw new Error("No config");
|
|
130
51
|
var theme = config.themes[props.name];
|
|
131
52
|
if (mutationType !== "add" && !theme)
|
|
132
|
-
throw new Error(
|
|
53
|
+
throw new Error(`${mutationType === "replace" ? "Replace" : "Update"} theme failed! Theme ${props.name} does not exist`);
|
|
133
54
|
}
|
|
134
|
-
var _config_themes_themeName, theme1 =
|
|
55
|
+
var _config_themes_themeName, theme1 = {
|
|
56
|
+
...mutationType === "update" ? (_config_themes_themeName = config.themes[themeName]) !== null && _config_themes_themeName !== void 0 ? _config_themes_themeName : {} : {},
|
|
57
|
+
...themeIn
|
|
58
|
+
};
|
|
135
59
|
for (var key in theme1)
|
|
136
60
|
ensureThemeVariable(theme1, key);
|
|
137
61
|
var themeProxied = proxyThemeToParents(themeName, theme1), response = {
|
|
@@ -139,7 +63,9 @@ function _mutateTheme(props) {
|
|
|
139
63
|
theme: themeProxied,
|
|
140
64
|
cssRules: []
|
|
141
65
|
};
|
|
142
|
-
return props.avoidUpdate || (insertCSS && (response.cssRules = insertThemeCSS(
|
|
66
|
+
return props.avoidUpdate || (insertCSS && (response.cssRules = insertThemeCSS({
|
|
67
|
+
[themeName]: theme1
|
|
68
|
+
})), updateThemeConfig(themeName, themeProxied), notifyThemeManagersOfUpdate(themeName, themeProxied)), response;
|
|
143
69
|
}
|
|
144
70
|
function updateThemeConfig(themeName, theme) {
|
|
145
71
|
var config = getConfig();
|
|
@@ -167,15 +93,18 @@ function insertThemeCSS(themes) {
|
|
|
167
93
|
hasDarkLight: !0,
|
|
168
94
|
theme
|
|
169
95
|
});
|
|
170
|
-
cssRules =
|
|
96
|
+
cssRules = [
|
|
97
|
+
...cssRules,
|
|
98
|
+
...rules
|
|
99
|
+
], batch || updateStyle(`t_theme_style_${themeName}`, rules);
|
|
171
100
|
}
|
|
172
101
|
if (batch) {
|
|
173
102
|
var id;
|
|
174
|
-
updateStyle(
|
|
103
|
+
updateStyle(`t_theme_style_${id}`, cssRules);
|
|
175
104
|
}
|
|
176
105
|
}
|
|
177
106
|
function updateStyle(id, rules) {
|
|
178
|
-
var existing = document.querySelector(
|
|
107
|
+
var existing = document.querySelector(`#${id}`), style = document.createElement("style");
|
|
179
108
|
if (style.id = id, style.appendChild(document.createTextNode(rules.join(`
|
|
180
109
|
`))), document.head.appendChild(style), existing) {
|
|
181
110
|
var _existing_parentElement;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/core/theme/src/_mutateTheme.ts"],
|
|
4
|
-
"mappings": "AAAA,OAAkB;AAClB,SAASA,gBAAgB;AAEzB,SACEC,qBACAC,qBACAC,WACAC,kBACAC,qBACAC,YACAC,oBACK;AACP,SAASC,uBAAuB
|
|
4
|
+
"mappings": "AAAA,OAAkB;AAClB,SAASA,gBAAgB;AAEzB,SACEC,qBACAC,qBACAC,WACAC,kBACAC,qBACAC,YACAC,oBACK;AACP,SAASC,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AiB;MAC7B8B;MACAT;MACAqB,OAAO;QAACrB;;MACRsB,cAAc;MACd9B;IACF,CAAA;AAEAM,eAAW;SAAIA;SAAasB;OAEvBlC,SACHqC,YAAY,iBAAiBvB,SAAAA,IAAaoB,KAAAA;EAE9C;AAEA,MAAIlC,OAAO;AACT,QAAMsC;AACND,gBAAY,iBAAiBC,EAAAA,IAAM1B,QAAAA;EACrC;AAGF;AAEA,SAASyB,YAAYC,IAAYJ,OAAe;AAC9C,MAAMK,WAAWC,SAASC,cAAc,IAAIH,EAAAA,EAAI,GAC1CI,QAAQF,SAASG,cAAc,OAAA;AAIrC,MAHAD,MAAMJ,KAAKA,IACXI,MAAME,YAAYJ,SAASK,eAAeX,MAAMY,KAAK;CAAA,CAAA,CAAA,GACrDN,SAASO,KAAKH,YAAYF,KAAAA,GACtBH,UAAU;QACZA;KAAAA,0BAAAA,SAASS,mBAAa,QAAtBT,4BAAAA,UAAAA,wBAAwBU,YAAYV,QAAAA;EACtC;AACF;",
|
|
5
5
|
"names": ["isServer", "activeThemeManagers", "ensureThemeVariable", "getConfig", "getThemeCSSRules", "proxyThemeToParents", "simpleHash", "updateConfig", "startTransition", "mutateThemes", "themes", "batch", "insertCSS", "props", "allThemesProxied", "allThemesRaw", "name", "theme", "res", "_mutateTheme", "avoidUpdate", "mutationType", "themeRaw", "cssRules", "insertThemeCSS", "themeName", "updateThemeConfig", "notifyThemeManagersOfUpdate", "themesRaw", "process", "env", "NODE_ENV", "console", "warn", "config", "themeIn", "Error", "key", "themeProxied", "response", "forEach", "manager", "state", "updateStateFromProps", "forceTheme", "rules", "names", "hasDarkLight", "updateStyle", "id", "existing", "document", "querySelector", "style", "createElement", "appendChild", "createTextNode", "join", "head", "parentElement", "removeChild"]
|
|
6
6
|
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import "react";
|
|
2
|
+
import { isServer } from "@tamagui/constants";
|
|
3
|
+
import { activeThemeManagers, ensureThemeVariable, getConfig, getThemeCSSRules, proxyThemeToParents, simpleHash, updateConfig } from "@tamagui/web";
|
|
4
|
+
import { startTransition } from "@tamagui/start-transition";
|
|
5
|
+
function mutateThemes(param) {
|
|
6
|
+
var {
|
|
7
|
+
themes,
|
|
8
|
+
batch,
|
|
9
|
+
insertCSS = !0,
|
|
10
|
+
...props
|
|
11
|
+
} = param,
|
|
12
|
+
allThemesProxied = {},
|
|
13
|
+
allThemesRaw = {},
|
|
14
|
+
_iteratorNormalCompletion = !0,
|
|
15
|
+
_didIteratorError = !1,
|
|
16
|
+
_iteratorError = void 0;
|
|
17
|
+
try {
|
|
18
|
+
for (var _iterator = themes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
19
|
+
var {
|
|
20
|
+
name,
|
|
21
|
+
theme
|
|
22
|
+
} = _step.value,
|
|
23
|
+
res = _mutateTheme({
|
|
24
|
+
...props,
|
|
25
|
+
name,
|
|
26
|
+
theme,
|
|
27
|
+
// we'll do one update at the end
|
|
28
|
+
avoidUpdate: !0,
|
|
29
|
+
// always add which also replaces but doesnt fail first time
|
|
30
|
+
mutationType: "add"
|
|
31
|
+
});
|
|
32
|
+
res && (allThemesProxied[name] = res.theme, allThemesRaw[name] = res.themeRaw);
|
|
33
|
+
}
|
|
34
|
+
} catch (err) {
|
|
35
|
+
_didIteratorError = !0, _iteratorError = err;
|
|
36
|
+
} finally {
|
|
37
|
+
try {
|
|
38
|
+
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
|
39
|
+
} finally {
|
|
40
|
+
if (_didIteratorError) throw _iteratorError;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
var cssRules = insertCSS ? insertThemeCSS(allThemesRaw, batch) : [];
|
|
44
|
+
return startTransition(function () {
|
|
45
|
+
for (var themeName in allThemesProxied) {
|
|
46
|
+
var theme2 = allThemesProxied[themeName];
|
|
47
|
+
updateThemeConfig(themeName, theme2), notifyThemeManagersOfUpdate(themeName, theme2);
|
|
48
|
+
}
|
|
49
|
+
}), {
|
|
50
|
+
themes: allThemesProxied,
|
|
51
|
+
themesRaw: allThemesRaw,
|
|
52
|
+
cssRules
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function _mutateTheme(props) {
|
|
56
|
+
if (isServer) {
|
|
57
|
+
process.env.NODE_ENV === "development" && console.warn("Theme mutation is not supported on server side");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
var config = getConfig(),
|
|
61
|
+
{
|
|
62
|
+
name: themeName,
|
|
63
|
+
theme: themeIn,
|
|
64
|
+
insertCSS,
|
|
65
|
+
mutationType
|
|
66
|
+
} = props;
|
|
67
|
+
if (process.env.NODE_ENV === "development") {
|
|
68
|
+
if (!config) throw new Error("No config");
|
|
69
|
+
var theme = config.themes[props.name];
|
|
70
|
+
if (mutationType !== "add" && !theme) throw new Error(`${mutationType === "replace" ? "Replace" : "Update"} theme failed! Theme ${props.name} does not exist`);
|
|
71
|
+
}
|
|
72
|
+
var _config_themes_themeName,
|
|
73
|
+
theme1 = {
|
|
74
|
+
...(mutationType === "update" ? (_config_themes_themeName = config.themes[themeName]) !== null && _config_themes_themeName !== void 0 ? _config_themes_themeName : {} : {}),
|
|
75
|
+
...themeIn
|
|
76
|
+
};
|
|
77
|
+
for (var key in theme1) ensureThemeVariable(theme1, key);
|
|
78
|
+
var themeProxied = proxyThemeToParents(themeName, theme1),
|
|
79
|
+
response = {
|
|
80
|
+
themeRaw: theme1,
|
|
81
|
+
theme: themeProxied,
|
|
82
|
+
cssRules: []
|
|
83
|
+
};
|
|
84
|
+
return props.avoidUpdate || (insertCSS && (response.cssRules = insertThemeCSS({
|
|
85
|
+
[themeName]: theme1
|
|
86
|
+
})), updateThemeConfig(themeName, themeProxied), notifyThemeManagersOfUpdate(themeName, themeProxied)), response;
|
|
87
|
+
}
|
|
88
|
+
function updateThemeConfig(themeName, theme) {
|
|
89
|
+
var config = getConfig();
|
|
90
|
+
config.themes[themeName] = theme, updateConfig("themes", config.themes);
|
|
91
|
+
}
|
|
92
|
+
function notifyThemeManagersOfUpdate(themeName, theme) {
|
|
93
|
+
activeThemeManagers.forEach(function (manager) {
|
|
94
|
+
manager.state.name === themeName && manager.updateStateFromProps({
|
|
95
|
+
name: themeName,
|
|
96
|
+
forceTheme: theme
|
|
97
|
+
}, !0);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
function insertThemeCSS(themes) {
|
|
101
|
+
var batch = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
|
|
102
|
+
return [];
|
|
103
|
+
var config, cssRules;
|
|
104
|
+
for (var themeName in themes) {
|
|
105
|
+
var theme = themes[themeName],
|
|
106
|
+
rules = getThemeCSSRules({
|
|
107
|
+
config,
|
|
108
|
+
themeName,
|
|
109
|
+
names: [themeName],
|
|
110
|
+
hasDarkLight: !0,
|
|
111
|
+
theme
|
|
112
|
+
});
|
|
113
|
+
cssRules = [...cssRules, ...rules], batch || updateStyle(`t_theme_style_${themeName}`, rules);
|
|
114
|
+
}
|
|
115
|
+
if (batch) {
|
|
116
|
+
var id;
|
|
117
|
+
updateStyle(`t_theme_style_${id}`, cssRules);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function updateStyle(id, rules) {
|
|
121
|
+
var existing = document.querySelector(`#${id}`),
|
|
122
|
+
style = document.createElement("style");
|
|
123
|
+
if (style.id = id, style.appendChild(document.createTextNode(rules.join(`
|
|
124
|
+
`))), document.head.appendChild(style), existing) {
|
|
125
|
+
var _existing_parentElement;
|
|
126
|
+
(_existing_parentElement = existing.parentElement) === null || _existing_parentElement === void 0 || _existing_parentElement.removeChild(existing);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
export { _mutateTheme, mutateThemes };
|
|
130
|
+
//# sourceMappingURL=_mutateTheme.native.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isServer","activeThemeManagers","ensureThemeVariable","getConfig","getThemeCSSRules","proxyThemeToParents","simpleHash","updateConfig","startTransition","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","notifyThemeManagersOfUpdate","themesRaw","process","env","NODE_ENV","console","warn","config","themeIn","Error","_config_themes_themeName","theme1","key","themeProxied","response","forEach","manager","state","updateStateFromProps","forceTheme","arguments","length","rules","names","hasDarkLight","updateStyle","id","existing","document","querySelector","style","createElement","appendChild","createTextNode","join","head","_existing_parentElement","parentElement","removeChild"],"sources":["../../src/_mutateTheme.ts"],"sourcesContent":[null],"mappings":"AACA,cAAS;AAET,SAAAA,QAAA;AAAA,SACEC,mBAAA,EAAAC,mBAAA,EAAAC,SAAA,EAAAC,gBAAA,EAAAC,mBAAA,EAAAC,UAAA,EAAAC,YAAA;AAAA,SACAC,eAAA;AAAA,SACAC,aAAAC,KAAA;EACA;MAAAC,MAAA;MAAAC,KAAA;MAAAC,SAAA;MAAA,GAAAC;IAAA,IAAAJ,KAAA;IAAAK,gBAAA;IAAAC,YAAA;IAAAC,yBAAA;IAAAC,iBAAA;IAAAC,cAAA;EACA;IACA,SAAAC,SAAA,GAAAT,MAAA,CAAAU,MAAA,CAAAC,QAAA,KAAAC,KAAA,IAAAN,yBAAA,IAAAM,KAAA,GAAAH,SAAA,CAAAI,IAAA,IAAAC,IAAA,GAAAR,yBAAA;MACA;UAAAS,IAAA;UAAAC;QAAA,IAAAJ,KAAA,CAAAK,KAAA;QAAAC,GAAA,GAAAC,YAAA;UACK,GAAAhB,KAAA;UACPY,IAAS;UAmBFC,KAAS;UACd;UACAI,WAAA;UACA;UACGC,YAAA;QAMF;MACDH,GAAM,KAAAd,gBAAiD,CACjDW,IAAA,IAAAG,GAAA,CAAAF,KAA6C,EAAAX,YAAA,CAAAU,IAAA,IAAAG,GAAA,C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,MAAA,CAAA2B,SAAA;MAAAyB,KAAA,GAAA3D,gBAAA;QAEA4C,MAAS;QAKPV,SAAM;QACF0B,KAAA,GAEJ1B,SAAW,CACT;QAGE2B,YAAA;QACAtC;MAAA,EACA;IAAiBS,QACjB,IACA,GAAAA,QAAA,EACD,GAAA2B,KAAA,CAED,EAAAnD,KAAA,IAAYsD,WAAG,kBAEV5B,SACH,IAAAyB,KAAY;EAEhB;EAEA,IAAInD,KAAA,EAAO;IACT,IAAAuD,EAAM;IACND,WAAA,CAAY,iBAAiBC,EAAE,IAAI/B,QAAQ;EAC7C;AAEA;AACF,SAAA8B,YAAAC,EAAA,EAAAJ,KAAA;EAEA,IAAAK,QAAS,GAAAC,QAAwB,CAAAC,aAAiB,KAAAH,EAAA;IAAAI,KAAA,GAAAF,QAAA,CAAAG,aAAA;EAChD,IAAAD,KAAM,CAAAJ,EAAA,GAAAA,EAAW,EAAAI,KAAA,CAAAE,WAAS,CAAAJ,QAAkB,CAAEK,cAChC,CAAAX,KAAA,CAAAY,IAAS;AACvB,MAAAN,QAAW,CAAAO,IACX,CAAAH,WAAM,CAAAF,KAAY,GAAAH,QAAS;IAAgC,IAC3DS,uBAAc;IAIhB,CAAAA,uBAAA,GAAAT,QAAA,CAAAU,aAAA,cAAAD,uBAAA,eAAAA,uBAAA,CAAAE,WAAA,CAAAX,QAAA","ignoreList":[]}
|
|
@@ -1,43 +1,10 @@
|
|
|
1
1
|
import { _mutateTheme } from "./_mutateTheme";
|
|
2
|
-
function _define_property(obj, key, value) {
|
|
3
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
4
|
-
value,
|
|
5
|
-
enumerable: !0,
|
|
6
|
-
configurable: !0,
|
|
7
|
-
writable: !0
|
|
8
|
-
}) : obj[key] = value, obj;
|
|
9
|
-
}
|
|
10
|
-
function _object_spread(target) {
|
|
11
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
12
|
-
var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
|
|
13
|
-
typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
14
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
15
|
-
}))), ownKeys2.forEach(function(key) {
|
|
16
|
-
_define_property(target, key, source[key]);
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
return target;
|
|
20
|
-
}
|
|
21
|
-
function ownKeys(object, enumerableOnly) {
|
|
22
|
-
var keys = Object.keys(object);
|
|
23
|
-
if (Object.getOwnPropertySymbols) {
|
|
24
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
25
|
-
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
26
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
27
|
-
})), keys.push.apply(keys, symbols);
|
|
28
|
-
}
|
|
29
|
-
return keys;
|
|
30
|
-
}
|
|
31
|
-
function _object_spread_props(target, source) {
|
|
32
|
-
return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
33
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
34
|
-
}), target;
|
|
35
|
-
}
|
|
36
2
|
function addTheme(props) {
|
|
37
|
-
return _mutateTheme(
|
|
3
|
+
return _mutateTheme({
|
|
4
|
+
...props,
|
|
38
5
|
insertCSS: !0,
|
|
39
6
|
mutationType: "add"
|
|
40
|
-
})
|
|
7
|
+
});
|
|
41
8
|
}
|
|
42
9
|
export {
|
|
43
10
|
addTheme
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/core/theme/src/addTheme.ts"],
|
|
4
|
-
"mappings": "AAEA,SAASA,oBAAoB
|
|
4
|
+
"mappings": "AAEA,SAASA,oBAAoB;AAEtB,SAASC,SAASC,OAIxB;AACC,SAAOF,aAAa;IAAE,GAAGE;IAAOC,WAAW;IAAMC,cAAc;EAAM,CAAA;AACvE;",
|
|
5
5
|
"names": ["_mutateTheme", "addTheme", "props", "insertCSS", "mutationType"]
|
|
6
6
|
}
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
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 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/core/theme/src/replaceTheme.ts"],
|
|
4
|
-
"mappings": "AAEA,SAASA,oBAAoB;AAEtB,SAASC,aAAa,OAM5B;
|
|
4
|
+
"mappings": "AAEA,SAASA,oBAAoB;AAEtB,SAASC,aAAa,OAM5B;MAN4B,EAC3BC,MACAC,MAAK,IAFsB,OAOrBC,OAAOJ,aAAa;IAAEE;IAAMC;IAAOE,WAAW;IAAMC,cAAc;EAAU,CAAA;AAClF,SAAOF;AACT;",
|
|
5
5
|
"names": ["_mutateTheme", "replaceTheme", "name", "theme", "next", "insertCSS", "mutationType"]
|
|
6
6
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { _mutateTheme } from "./_mutateTheme.mjs";
|
|
2
|
+
function replaceTheme(param) {
|
|
3
|
+
var {
|
|
4
|
+
name,
|
|
5
|
+
theme
|
|
6
|
+
} = param,
|
|
7
|
+
next = _mutateTheme({
|
|
8
|
+
name,
|
|
9
|
+
theme,
|
|
10
|
+
insertCSS: !0,
|
|
11
|
+
mutationType: "replace"
|
|
12
|
+
});
|
|
13
|
+
return next;
|
|
14
|
+
}
|
|
15
|
+
export { replaceTheme };
|
|
16
|
+
//# sourceMappingURL=replaceTheme.native.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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;MAAAC,IAAA;MAAAC;IAAA,IAAAF,KAAA;IAAAG,IAAA,GAAAL,YAAA;MACAG,IAAA;MAICC,KAAA;MAEDE,SADa;MAEfC,YAAA","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/core/theme/src/updateTheme.ts"],
|
|
4
|
-
"mappings": "AAEA,SAASA,oBAAoB;AAEtB,SAASC,YAAY,OAM3B;
|
|
4
|
+
"mappings": "AAEA,SAASA,oBAAoB;AAEtB,SAASC,YAAY,OAM3B;MAN2B,EAC1BC,MACAC,MAAK,IAFqB;AAO1B,SAAOH,aAAa;IAAEE;IAAMC;IAAOC,WAAW;IAAMC,cAAc;EAAS,CAAA;AAC7E;",
|
|
5
5
|
"names": ["_mutateTheme", "updateTheme", "name", "theme", "insertCSS", "mutationType"]
|
|
6
6
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { _mutateTheme } from "./_mutateTheme.mjs";
|
|
2
|
+
function updateTheme(param) {
|
|
3
|
+
var {
|
|
4
|
+
name,
|
|
5
|
+
theme
|
|
6
|
+
} = param;
|
|
7
|
+
return _mutateTheme({
|
|
8
|
+
name,
|
|
9
|
+
theme,
|
|
10
|
+
insertCSS: !0,
|
|
11
|
+
mutationType: "update"
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export { updateTheme };
|
|
15
|
+
//# sourceMappingURL=updateTheme.native.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -2,98 +2,19 @@ import "react";
|
|
|
2
2
|
import { isServer } from "@tamagui/constants";
|
|
3
3
|
import { activeThemeManagers, ensureThemeVariable, getConfig, getThemeCSSRules, proxyThemeToParents, simpleHash, updateConfig } from "@tamagui/web";
|
|
4
4
|
import { startTransition } from "@tamagui/start-transition";
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
8
|
-
return arr2;
|
|
9
|
-
}
|
|
10
|
-
function _array_without_holes(arr) {
|
|
11
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
12
|
-
}
|
|
13
|
-
function _define_property(obj, key, value) {
|
|
14
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
15
|
-
value,
|
|
16
|
-
enumerable: !0,
|
|
17
|
-
configurable: !0,
|
|
18
|
-
writable: !0
|
|
19
|
-
}) : obj[key] = value, obj;
|
|
20
|
-
}
|
|
21
|
-
function _iterable_to_array(iter) {
|
|
22
|
-
if (typeof Symbol < "u" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
23
|
-
}
|
|
24
|
-
function _non_iterable_spread() {
|
|
25
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
26
|
-
}
|
|
27
|
-
function _object_spread(target) {
|
|
28
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
29
|
-
var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
|
|
30
|
-
typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
31
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
32
|
-
}))), ownKeys2.forEach(function(key) {
|
|
33
|
-
_define_property(target, key, source[key]);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return target;
|
|
37
|
-
}
|
|
38
|
-
function ownKeys(object, enumerableOnly) {
|
|
39
|
-
var keys = Object.keys(object);
|
|
40
|
-
if (Object.getOwnPropertySymbols) {
|
|
41
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
42
|
-
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
43
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
44
|
-
})), keys.push.apply(keys, symbols);
|
|
45
|
-
}
|
|
46
|
-
return keys;
|
|
47
|
-
}
|
|
48
|
-
function _object_spread_props(target, source) {
|
|
49
|
-
return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
50
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
51
|
-
}), target;
|
|
52
|
-
}
|
|
53
|
-
function _object_without_properties(source, excluded) {
|
|
54
|
-
if (source == null) return {};
|
|
55
|
-
var target = _object_without_properties_loose(source, excluded), key, i;
|
|
56
|
-
if (Object.getOwnPropertySymbols) {
|
|
57
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
58
|
-
for (i = 0; i < sourceSymbolKeys.length; i++)
|
|
59
|
-
key = sourceSymbolKeys[i], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
|
|
60
|
-
}
|
|
61
|
-
return target;
|
|
62
|
-
}
|
|
63
|
-
function _object_without_properties_loose(source, excluded) {
|
|
64
|
-
if (source == null) return {};
|
|
65
|
-
var target = {}, sourceKeys = Object.keys(source), key, i;
|
|
66
|
-
for (i = 0; i < sourceKeys.length; i++)
|
|
67
|
-
key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
|
|
68
|
-
return target;
|
|
69
|
-
}
|
|
70
|
-
function _to_consumable_array(arr) {
|
|
71
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
72
|
-
}
|
|
73
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
74
|
-
if (o) {
|
|
75
|
-
if (typeof o == "string") return _array_like_to_array(o, minLen);
|
|
76
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
77
|
-
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
|
|
78
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
function mutateThemes(_param) {
|
|
82
|
-
var themes = _param.themes, batch = _param.batch, _param_insertCSS = _param.insertCSS, insertCSS = _param_insertCSS === void 0 ? !0 : _param_insertCSS, props = _object_without_properties(_param, [
|
|
83
|
-
"themes",
|
|
84
|
-
"batch",
|
|
85
|
-
"insertCSS"
|
|
86
|
-
]), allThemesProxied = {}, allThemesRaw = {}, _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
|
5
|
+
function mutateThemes(param) {
|
|
6
|
+
var { themes, batch, insertCSS = !0, ...props } = param, allThemesProxied = {}, allThemesRaw = {}, _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
|
87
7
|
try {
|
|
88
8
|
for (var _iterator = themes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
89
|
-
var
|
|
9
|
+
var { name, theme } = _step.value, res = _mutateTheme({
|
|
10
|
+
...props,
|
|
90
11
|
name,
|
|
91
12
|
theme,
|
|
92
13
|
// we'll do one update at the end
|
|
93
14
|
avoidUpdate: !0,
|
|
94
15
|
// always add which also replaces but doesnt fail first time
|
|
95
16
|
mutationType: "add"
|
|
96
|
-
})
|
|
17
|
+
});
|
|
97
18
|
res && (allThemesProxied[name] = res.theme, allThemesRaw[name] = res.themeRaw);
|
|
98
19
|
}
|
|
99
20
|
} catch (err) {
|
|
@@ -123,15 +44,18 @@ function _mutateTheme(props) {
|
|
|
123
44
|
process.env.NODE_ENV === "development" && console.warn("Theme mutation is not supported on server side");
|
|
124
45
|
return;
|
|
125
46
|
}
|
|
126
|
-
var config = getConfig(),
|
|
47
|
+
var config = getConfig(), { name: themeName, theme: themeIn, insertCSS, mutationType } = props;
|
|
127
48
|
if (process.env.NODE_ENV === "development") {
|
|
128
49
|
if (!config)
|
|
129
50
|
throw new Error("No config");
|
|
130
51
|
var theme = config.themes[props.name];
|
|
131
52
|
if (mutationType !== "add" && !theme)
|
|
132
|
-
throw new Error(
|
|
53
|
+
throw new Error(`${mutationType === "replace" ? "Replace" : "Update"} theme failed! Theme ${props.name} does not exist`);
|
|
133
54
|
}
|
|
134
|
-
var _config_themes_themeName, theme1 =
|
|
55
|
+
var _config_themes_themeName, theme1 = {
|
|
56
|
+
...mutationType === "update" ? (_config_themes_themeName = config.themes[themeName]) !== null && _config_themes_themeName !== void 0 ? _config_themes_themeName : {} : {},
|
|
57
|
+
...themeIn
|
|
58
|
+
};
|
|
135
59
|
for (var key in theme1)
|
|
136
60
|
ensureThemeVariable(theme1, key);
|
|
137
61
|
var themeProxied = proxyThemeToParents(themeName, theme1), response = {
|
|
@@ -139,7 +63,9 @@ function _mutateTheme(props) {
|
|
|
139
63
|
theme: themeProxied,
|
|
140
64
|
cssRules: []
|
|
141
65
|
};
|
|
142
|
-
return props.avoidUpdate || (insertCSS && (response.cssRules = insertThemeCSS(
|
|
66
|
+
return props.avoidUpdate || (insertCSS && (response.cssRules = insertThemeCSS({
|
|
67
|
+
[themeName]: theme1
|
|
68
|
+
})), updateThemeConfig(themeName, themeProxied), notifyThemeManagersOfUpdate(themeName, themeProxied)), response;
|
|
143
69
|
}
|
|
144
70
|
function updateThemeConfig(themeName, theme) {
|
|
145
71
|
var config = getConfig();
|
|
@@ -167,15 +93,18 @@ function insertThemeCSS(themes) {
|
|
|
167
93
|
hasDarkLight: !0,
|
|
168
94
|
theme
|
|
169
95
|
});
|
|
170
|
-
cssRules =
|
|
96
|
+
cssRules = [
|
|
97
|
+
...cssRules,
|
|
98
|
+
...rules
|
|
99
|
+
], batch || updateStyle(`t_theme_style_${themeName}`, rules);
|
|
171
100
|
}
|
|
172
101
|
if (batch) {
|
|
173
102
|
var id;
|
|
174
|
-
updateStyle(
|
|
103
|
+
updateStyle(`t_theme_style_${id}`, cssRules);
|
|
175
104
|
}
|
|
176
105
|
}
|
|
177
106
|
function updateStyle(id, rules) {
|
|
178
|
-
var existing = document.querySelector(
|
|
107
|
+
var existing = document.querySelector(`#${id}`), style = document.createElement("style");
|
|
179
108
|
if (style.id = id, style.appendChild(document.createTextNode(rules.join(`
|
|
180
109
|
`))), document.head.appendChild(style), existing) {
|
|
181
110
|
var _existing_parentElement;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/core/theme/src/_mutateTheme.ts"],
|
|
4
|
-
"mappings": "AAAA,OAAkB;AAClB,SAASA,gBAAgB;AAEzB,SACEC,qBACAC,qBACAC,WACAC,kBACAC,qBACAC,YACAC,oBACK;AACP,SAASC,uBAAuB
|
|
4
|
+
"mappings": "AAAA,OAAkB;AAClB,SAASA,gBAAgB;AAEzB,SACEC,qBACAC,qBACAC,WACAC,kBACAC,qBACAC,YACAC,o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oB,QAAQzC,iBAAiB;MAC7B8B;MACAT;MACAqB,OAAO;QAACrB;;MACRsB,cAAc;MACd9B;IACF,CAAA;AAEAM,eAAW;SAAIA;SAAasB;OAEvBlC,SACHqC,YAAY,iBAAiBvB,SAAAA,IAAaoB,KAAAA;EAE9C;AAEA,MAAIlC,OAAO;AACT,QAAMsC;AACND,gBAAY,iBAAiBC,EAAAA,IAAM1B,QAAAA;EACrC;AAGF;AAEA,SAASyB,YAAYC,IAAYJ,OAAe;AAC9C,MAAMK,WAAWC,SAASC,cAAc,IAAIH,EAAAA,EAAI,GAC1CI,QAAQF,SAASG,cAAc,OAAA;AAIrC,MAHAD,MAAMJ,KAAKA,IACXI,MAAME,YAAYJ,SAASK,eAAeX,MAAMY,KAAK;CAAA,CAAA,CAAA,GACrDN,SAASO,KAAKH,YAAYF,KAAAA,GACtBH,UAAU;QACZA;KAAAA,0BAAAA,SAASS,mBAAa,QAAtBT,4BAAAA,UAAAA,wBAAwBU,YAAYV,QAAAA;EACtC;AACF;",
|
|
5
5
|
"names": ["isServer", "activeThemeManagers", "ensureThemeVariable", "getConfig", "getThemeCSSRules", "proxyThemeToParents", "simpleHash", "updateConfig", "startTransition", "mutateThemes", "themes", "batch", "insertCSS", "props", "allThemesProxied", "allThemesRaw", "name", "theme", "res", "_mutateTheme", "avoidUpdate", "mutationType", "themeRaw", "cssRules", "insertThemeCSS", "themeName", "updateThemeConfig", "notifyThemeManagersOfUpdate", "themesRaw", "process", "env", "NODE_ENV", "console", "warn", "config", "themeIn", "Error", "key", "themeProxied", "response", "forEach", "manager", "state", "updateStateFromProps", "forceTheme", "rules", "names", "hasDarkLight", "updateStyle", "id", "existing", "document", "querySelector", "style", "createElement", "appendChild", "createTextNode", "join", "head", "parentElement", "removeChild"]
|
|
6
6
|
}
|
|
@@ -1,43 +1,10 @@
|
|
|
1
1
|
import { _mutateTheme } from "./_mutateTheme";
|
|
2
|
-
function _define_property(obj, key, value) {
|
|
3
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
4
|
-
value,
|
|
5
|
-
enumerable: !0,
|
|
6
|
-
configurable: !0,
|
|
7
|
-
writable: !0
|
|
8
|
-
}) : obj[key] = value, obj;
|
|
9
|
-
}
|
|
10
|
-
function _object_spread(target) {
|
|
11
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
12
|
-
var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
|
|
13
|
-
typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
14
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
15
|
-
}))), ownKeys2.forEach(function(key) {
|
|
16
|
-
_define_property(target, key, source[key]);
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
return target;
|
|
20
|
-
}
|
|
21
|
-
function ownKeys(object, enumerableOnly) {
|
|
22
|
-
var keys = Object.keys(object);
|
|
23
|
-
if (Object.getOwnPropertySymbols) {
|
|
24
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
25
|
-
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
26
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
27
|
-
})), keys.push.apply(keys, symbols);
|
|
28
|
-
}
|
|
29
|
-
return keys;
|
|
30
|
-
}
|
|
31
|
-
function _object_spread_props(target, source) {
|
|
32
|
-
return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
33
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
34
|
-
}), target;
|
|
35
|
-
}
|
|
36
2
|
function addTheme(props) {
|
|
37
|
-
return _mutateTheme(
|
|
3
|
+
return _mutateTheme({
|
|
4
|
+
...props,
|
|
38
5
|
insertCSS: !0,
|
|
39
6
|
mutationType: "add"
|
|
40
|
-
})
|
|
7
|
+
});
|
|
41
8
|
}
|
|
42
9
|
export {
|
|
43
10
|
addTheme
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/core/theme/src/addTheme.ts"],
|
|
4
|
-
"mappings": "AAEA,SAASA,oBAAoB
|
|
4
|
+
"mappings": "AAEA,SAASA,oBAAoB;AAEtB,SAASC,SAASC,OAIxB;AACC,SAAOF,aAAa;IAAE,GAAGE;IAAOC,WAAW;IAAMC,cAAc;EAAM,CAAA;AACvE;",
|
|
5
5
|
"names": ["_mutateTheme", "addTheme", "props", "insertCSS", "mutationType"]
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/core/theme/src/replaceTheme.ts"],
|
|
4
|
-
"mappings": "AAEA,SAASA,oBAAoB;AAEtB,SAASC,aAAa,OAM5B;
|
|
4
|
+
"mappings": "AAEA,SAASA,oBAAoB;AAEtB,SAASC,aAAa,OAM5B;MAN4B,EAC3BC,MACAC,MAAK,IAFsB,OAOrBC,OAAOJ,aAAa;IAAEE;IAAMC;IAAOE,WAAW;IAAMC,cAAc;EAAU,CAAA;AAClF,SAAOF;AACT;",
|
|
5
5
|
"names": ["_mutateTheme", "replaceTheme", "name", "theme", "next", "insertCSS", "mutationType"]
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/core/theme/src/updateTheme.ts"],
|
|
4
|
-
"mappings": "AAEA,SAASA,oBAAoB;AAEtB,SAASC,YAAY,OAM3B;
|
|
4
|
+
"mappings": "AAEA,SAASA,oBAAoB;AAEtB,SAASC,YAAY,OAM3B;MAN2B,EAC1BC,MACAC,MAAK,IAFqB;AAO1B,SAAOH,aAAa;IAAEE;IAAMC;IAAOC,WAAW;IAAMC,cAAc;EAAS,CAAA;AAC7E;",
|
|
5
5
|
"names": ["_mutateTheme", "updateTheme", "name", "theme", "insertCSS", "mutationType"]
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/theme",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.111.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"clean:build": "tamagui-build clean:build"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@tamagui/constants": "1.
|
|
25
|
-
"@tamagui/web": "1.
|
|
24
|
+
"@tamagui/constants": "1.111.0",
|
|
25
|
+
"@tamagui/web": "1.111.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@tamagui/build": "1.
|
|
28
|
+
"@tamagui/build": "1.111.0",
|
|
29
29
|
"react": "^18.2.0 || ^19.0.0"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|