@tamagui/theme 1.123.0 → 1.123.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/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "@tamagui/theme",
3
- "version": "1.123.0",
3
+ "version": "1.123.1",
4
4
  "sideEffects": false,
5
5
  "source": "src/index.ts",
6
6
  "types": "./types/index.d.ts",
7
7
  "main": "dist/cjs",
8
8
  "module": "dist/esm",
9
- "module:jsx": "dist/jsx",
10
9
  "files": [
11
10
  "src",
12
11
  "types",
@@ -34,11 +33,11 @@
34
33
  }
35
34
  },
36
35
  "dependencies": {
37
- "@tamagui/constants": "1.123.0",
38
- "@tamagui/web": "1.123.0"
36
+ "@tamagui/constants": "1.123.1",
37
+ "@tamagui/web": "1.123.1"
39
38
  },
40
39
  "devDependencies": {
41
- "@tamagui/build": "1.123.0",
40
+ "@tamagui/build": "1.123.1",
42
41
  "react": "*"
43
42
  },
44
43
  "publishConfig": {
@@ -1,116 +0,0 @@
1
- import { isServer } from "@tamagui/constants";
2
- import {
3
- activeThemeManagers,
4
- ensureThemeVariable,
5
- getConfig,
6
- getThemeCSSRules,
7
- proxyThemeToParents,
8
- simpleHash,
9
- updateConfig
10
- } from "@tamagui/web";
11
- import { startTransition } from "@tamagui/start-transition";
12
- function mutateThemes({
13
- themes,
14
- batch,
15
- insertCSS = !0,
16
- ...props
17
- }) {
18
- const allThemesProxied = {}, allThemesRaw = {};
19
- for (const { name, theme } of themes) {
20
- const res = _mutateTheme({
21
- ...props,
22
- name,
23
- theme,
24
- // we'll do one update at the end
25
- avoidUpdate: !0,
26
- // always add which also replaces but doesnt fail first time
27
- mutationType: "add"
28
- });
29
- res && (allThemesProxied[name] = res.theme, allThemesRaw[name] = res.themeRaw);
30
- }
31
- const cssRules = insertCSS ? insertThemeCSS(allThemesRaw, batch) : [];
32
- return startTransition(() => {
33
- for (const themeName in allThemesProxied) {
34
- const theme = allThemesProxied[themeName];
35
- updateThemeConfig(themeName, theme), notifyThemeManagersOfUpdate(themeName, theme);
36
- }
37
- }), {
38
- themes: allThemesProxied,
39
- themesRaw: allThemesRaw,
40
- cssRules
41
- };
42
- }
43
- function _mutateTheme(props) {
44
- if (isServer) {
45
- process.env.NODE_ENV === "development" && console.warn("Theme mutation is not supported on server side");
46
- return;
47
- }
48
- const config = getConfig(), { name: themeName, theme: themeIn, insertCSS, mutationType } = props;
49
- if (process.env.NODE_ENV === "development") {
50
- if (!config)
51
- throw new Error("No config");
52
- const theme2 = config.themes[props.name];
53
- if (mutationType !== "add" && !theme2)
54
- throw new Error(
55
- `${mutationType === "replace" ? "Replace" : "Update"} theme failed! Theme ${props.name} does not exist`
56
- );
57
- }
58
- const theme = {
59
- ...mutationType === "update" ? config.themes[themeName] ?? {} : {},
60
- ...themeIn
61
- };
62
- for (const key in theme)
63
- ensureThemeVariable(theme, key);
64
- const themeProxied = proxyThemeToParents(themeName, theme), response = {
65
- themeRaw: theme,
66
- theme: themeProxied,
67
- cssRules: []
68
- };
69
- return props.avoidUpdate || (insertCSS && (response.cssRules = insertThemeCSS({
70
- [themeName]: theme
71
- })), updateThemeConfig(themeName, themeProxied), notifyThemeManagersOfUpdate(themeName, themeProxied)), response;
72
- }
73
- function updateThemeConfig(themeName, theme) {
74
- const config = getConfig();
75
- config.themes[themeName] = theme, updateConfig("themes", config.themes);
76
- }
77
- function notifyThemeManagersOfUpdate(themeName, theme) {
78
- activeThemeManagers.forEach((manager) => {
79
- manager.state.name === themeName && manager.updateStateFromProps(
80
- {
81
- name: themeName,
82
- forceTheme: theme
83
- },
84
- !0
85
- );
86
- });
87
- }
88
- function insertThemeCSS(themes, batch = !1) {
89
- const config = getConfig();
90
- let cssRules = [];
91
- for (const themeName in themes) {
92
- const theme = themes[themeName], rules = getThemeCSSRules({
93
- config,
94
- themeName,
95
- names: [themeName],
96
- hasDarkLight: !0,
97
- theme
98
- });
99
- cssRules = [...cssRules, ...rules], batch || updateStyle(`t_theme_style_${themeName}`, rules);
100
- }
101
- if (batch) {
102
- const id = simpleHash(typeof batch == "string" ? batch : Object.keys(themes).join(""));
103
- updateStyle(`t_theme_style_${id}`, cssRules);
104
- }
105
- return cssRules;
106
- }
107
- function updateStyle(id, rules) {
108
- const existing = document.querySelector(`#${id}`), style = document.createElement("style");
109
- style.id = id, style.appendChild(document.createTextNode(rules.join(`
110
- `))), document.head.appendChild(style), existing && existing.parentElement?.removeChild(existing);
111
- }
112
- export {
113
- _mutateTheme,
114
- mutateThemes
115
- };
116
- //# sourceMappingURL=_mutateTheme.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/_mutateTheme.ts"],
4
- "mappings": "AACA,SAAS,gBAAgB;AAEzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAmBzB,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,GAAG;AACL,GAKG;AACD,QAAM,mBAAgD,CAAC,GACjD,eAA4C,CAAC;AACnD,aAAW,EAAE,MAAM,MAAM,KAAK,QAAQ;AACpC,UAAM,MAAM,aAAa;AAAA,MACvB,GAAG;AAAA,MACH;AAAA,MACA;AAAA;AAAA,MAEA,aAAa;AAAA;AAAA,MAEb,cAAc;AAAA,IAChB,CAAC;AACD,IAAI,QACF,iBAAiB,IAAI,IAAI,IAAI,OAC7B,aAAa,IAAI,IAAI,IAAI;AAAA,EAE7B;AAEA,QAAM,WAAW,YAAY,eAAe,cAAc,KAAK,IAAI,CAAC;AAEpE,yBAAgB,MAAM;AACpB,eAAW,aAAa,kBAAkB;AACxC,YAAM,QAAQ,iBAAiB,SAAS;AACxC,wBAAkB,WAAW,KAAK,GAClC,4BAA4B,WAAW,KAAK;AAAA,IAC9C;AAAA,EACF,CAAC,GAEM;AAAA,IACL,QAAQ;AAAA,IACR,WA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Y;AAAA,MACd;AAAA,MACA;AAAA,IACF;AAAA,EAEJ,CAAC;AACH;AAEA,SAAS,eAAe,QAAsC,QAAe,IAAO;AAKlF,QAAM,SAAS,UAAU;AACzB,MAAI,WAAqB,CAAC;AAE1B,aAAW,aAAa,QAAQ;AAC9B,UAAM,QAAQ,OAAO,SAAS,GAExB,QAAQ,iBAAiB;AAAA,MAC7B;AAAA,MACA;AAAA,MACA,OAAO,CAAC,SAAS;AAAA,MACjB,cAAc;AAAA,MACd;AAAA,IACF,CAAC;AAED,eAAW,CAAC,GAAG,UAAU,GAAG,KAAK,GAE5B,SACH,YAAY,iBAAiB,SAAS,IAAI,KAAK;AAAA,EAEnD;AAEA,MAAI,OAAO;AACT,UAAM,KAAK,WAAW,OAAO,SAAS,WAAW,QAAQ,OAAO,KAAK,MAAM,EAAE,KAAK,EAAE,CAAC;AACrF,gBAAY,iBAAiB,EAAE,IAAI,QAAQ;AAAA,EAC7C;AAEA,SAAO;AACT;AAEA,SAAS,YAAY,IAAY,OAAiB;AAChD,QAAM,WAAW,SAAS,cAAc,IAAI,EAAE,EAAE,GAC1C,QAAQ,SAAS,cAAc,OAAO;AAC5C,QAAM,KAAK,IACX,MAAM,YAAY,SAAS,eAAe,MAAM,KAAK;AAAA,CAAI,CAAC,CAAC,GAC3D,SAAS,KAAK,YAAY,KAAK,GAC3B,YACF,SAAS,eAAe,YAAY,QAAQ;AAEhD;",
5
- "names": ["theme"]
6
- }
@@ -1,110 +0,0 @@
1
- import { isServer } from "@tamagui/constants";
2
- import { activeThemeManagers, ensureThemeVariable, getConfig, getThemeCSSRules, proxyThemeToParents, simpleHash, updateConfig } from "@tamagui/web";
3
- import { startTransition } from "@tamagui/start-transition";
4
- function mutateThemes({
5
- themes,
6
- batch,
7
- insertCSS = !0,
8
- ...props
9
- }) {
10
- const allThemesProxied = {},
11
- allThemesRaw = {};
12
- for (const {
13
- name,
14
- theme
15
- } of themes) {
16
- const res = _mutateTheme({
17
- ...props,
18
- name,
19
- theme,
20
- // we'll do one update at the end
21
- avoidUpdate: !0,
22
- // always add which also replaces but doesnt fail first time
23
- mutationType: "add"
24
- });
25
- res && (allThemesProxied[name] = res.theme, allThemesRaw[name] = res.themeRaw);
26
- }
27
- const cssRules = insertCSS ? insertThemeCSS(allThemesRaw, batch) : [];
28
- return startTransition(() => {
29
- for (const themeName in allThemesProxied) {
30
- const theme = allThemesProxied[themeName];
31
- updateThemeConfig(themeName, theme), notifyThemeManagersOfUpdate(themeName, theme);
32
- }
33
- }), {
34
- themes: allThemesProxied,
35
- themesRaw: allThemesRaw,
36
- cssRules
37
- };
38
- }
39
- function _mutateTheme(props) {
40
- if (isServer) {
41
- process.env.NODE_ENV === "development" && console.warn("Theme mutation is not supported on server side");
42
- return;
43
- }
44
- const config = getConfig(),
45
- {
46
- name: themeName,
47
- theme: themeIn,
48
- insertCSS,
49
- mutationType
50
- } = props;
51
- if (process.env.NODE_ENV === "development") {
52
- if (!config) throw new Error("No config");
53
- const theme2 = config.themes[props.name];
54
- if (mutationType !== "add" && !theme2) throw new Error(`${mutationType === "replace" ? "Replace" : "Update"} theme failed! Theme ${props.name} does not exist`);
55
- }
56
- const theme = {
57
- ...(mutationType === "update" ? config.themes[themeName] ?? {} : {}),
58
- ...themeIn
59
- };
60
- for (const key in theme) ensureThemeVariable(theme, key);
61
- const themeProxied = proxyThemeToParents(themeName, theme),
62
- response = {
63
- themeRaw: theme,
64
- theme: themeProxied,
65
- cssRules: []
66
- };
67
- return props.avoidUpdate || (insertCSS && (response.cssRules = insertThemeCSS({
68
- [themeName]: theme
69
- })), updateThemeConfig(themeName, themeProxied), notifyThemeManagersOfUpdate(themeName, themeProxied)), response;
70
- }
71
- function updateThemeConfig(themeName, theme) {
72
- const config = getConfig();
73
- config.themes[themeName] = theme, updateConfig("themes", config.themes);
74
- }
75
- function notifyThemeManagersOfUpdate(themeName, theme) {
76
- activeThemeManagers.forEach(manager => {
77
- manager.state.name === themeName && manager.updateStateFromProps({
78
- name: themeName,
79
- forceTheme: theme
80
- }, !0);
81
- });
82
- }
83
- function insertThemeCSS(themes, batch = !1) {
84
- const config = getConfig();
85
- let cssRules = [];
86
- for (const themeName in themes) {
87
- const theme = themes[themeName],
88
- rules = getThemeCSSRules({
89
- config,
90
- themeName,
91
- names: [themeName],
92
- hasDarkLight: !0,
93
- theme
94
- });
95
- cssRules = [...cssRules, ...rules], batch || updateStyle(`t_theme_style_${themeName}`, rules);
96
- }
97
- if (batch) {
98
- const id = simpleHash(typeof batch == "string" ? batch : Object.keys(themes).join(""));
99
- updateStyle(`t_theme_style_${id}`, cssRules);
100
- }
101
- return cssRules;
102
- }
103
- function updateStyle(id, rules) {
104
- const existing = document.querySelector(`#${id}`),
105
- style = document.createElement("style");
106
- style.id = id, style.appendChild(document.createTextNode(rules.join(`
107
- `))), document.head.appendChild(style), existing && existing.parentElement?.removeChild(existing);
108
- }
109
- export { _mutateTheme, mutateThemes };
110
- //# sourceMappingURL=_mutateTheme.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"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","theme2","key","themeProxied","response","forEach","manager","state","updateStateFromProps","forceTheme","rules","names","hasDarkLight","updateStyle","id","Object","keys","join","existing","document","querySelector","style","createElement","appendChild","createTextNode","head","parentElement","removeChild"],"sources":["../../src/_mutateTheme.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,QAAA,QAAgB;AAEzB,SACEC,mBAAA,EACAC,mBAAA,EACAC,SAAA,EACAC,gBAAA,EACAC,mBAAA,EACAC,UAAA,EACAC,YAAA,QACK;AACP,SAASC,eAAA,QAAuB;AAmBzB,SAASC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QAAA,IACFA,QAAA,CAASQ,aAAA,EAAeC,WAAA,CAAYT,QAAQ;AAEhD","ignoreList":[]}
@@ -1,118 +0,0 @@
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 { themes, batch, insertCSS = !0, ...props } = param, allThemesProxied = {}, allThemesRaw = {}, _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
7
- try {
8
- for (var _iterator = themes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
9
- var { name, theme } = _step.value, res = _mutateTheme({
10
- ...props,
11
- name,
12
- theme,
13
- // we'll do one update at the end
14
- avoidUpdate: !0,
15
- // always add which also replaces but doesnt fail first time
16
- mutationType: "add"
17
- });
18
- res && (allThemesProxied[name] = res.theme, allThemesRaw[name] = res.themeRaw);
19
- }
20
- } catch (err) {
21
- _didIteratorError = !0, _iteratorError = err;
22
- } finally {
23
- try {
24
- !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
25
- } finally {
26
- if (_didIteratorError)
27
- throw _iteratorError;
28
- }
29
- }
30
- var cssRules = insertCSS ? insertThemeCSS(allThemesRaw, batch) : [];
31
- return startTransition(function() {
32
- for (var themeName in allThemesProxied) {
33
- var theme2 = allThemesProxied[themeName];
34
- updateThemeConfig(themeName, theme2), notifyThemeManagersOfUpdate(themeName, theme2);
35
- }
36
- }), {
37
- themes: allThemesProxied,
38
- themesRaw: allThemesRaw,
39
- cssRules
40
- };
41
- }
42
- function _mutateTheme(props) {
43
- if (isServer) {
44
- process.env.NODE_ENV === "development" && console.warn("Theme mutation is not supported on server side");
45
- return;
46
- }
47
- var config = getConfig(), { name: themeName, theme: themeIn, insertCSS, mutationType } = props;
48
- if (process.env.NODE_ENV === "development") {
49
- if (!config)
50
- throw new Error("No config");
51
- var theme = config.themes[props.name];
52
- if (mutationType !== "add" && !theme)
53
- throw new Error(`${mutationType === "replace" ? "Replace" : "Update"} theme failed! Theme ${props.name} does not exist`);
54
- }
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
- };
59
- for (var key in theme1)
60
- ensureThemeVariable(theme1, key);
61
- var themeProxied = proxyThemeToParents(themeName, theme1), response = {
62
- themeRaw: theme1,
63
- theme: themeProxied,
64
- cssRules: []
65
- };
66
- return props.avoidUpdate || (insertCSS && (response.cssRules = insertThemeCSS({
67
- [themeName]: theme1
68
- })), updateThemeConfig(themeName, themeProxied), notifyThemeManagersOfUpdate(themeName, themeProxied)), response;
69
- }
70
- function updateThemeConfig(themeName, theme) {
71
- var config = getConfig();
72
- config.themes[themeName] = theme, updateConfig("themes", config.themes);
73
- }
74
- function notifyThemeManagersOfUpdate(themeName, theme) {
75
- activeThemeManagers.forEach(function(manager) {
76
- manager.state.name === themeName && manager.updateStateFromProps({
77
- name: themeName,
78
- forceTheme: theme
79
- }, !0);
80
- });
81
- }
82
- function insertThemeCSS(themes) {
83
- var batch = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
84
- return [];
85
- var config, cssRules;
86
- for (var themeName in themes) {
87
- var theme = themes[themeName], rules = getThemeCSSRules({
88
- config,
89
- themeName,
90
- names: [
91
- themeName
92
- ],
93
- hasDarkLight: !0,
94
- theme
95
- });
96
- cssRules = [
97
- ...cssRules,
98
- ...rules
99
- ], batch || updateStyle(`t_theme_style_${themeName}`, rules);
100
- }
101
- if (batch) {
102
- var id;
103
- updateStyle(`t_theme_style_${id}`, cssRules);
104
- }
105
- }
106
- function updateStyle(id, rules) {
107
- var existing = document.querySelector(`#${id}`), style = document.createElement("style");
108
- if (style.id = id, style.appendChild(document.createTextNode(rules.join(`
109
- `))), document.head.appendChild(style), existing) {
110
- var _existing_parentElement;
111
- (_existing_parentElement = existing.parentElement) === null || _existing_parentElement === void 0 || _existing_parentElement.removeChild(existing);
112
- }
113
- }
114
- export {
115
- _mutateTheme,
116
- mutateThemes
117
- };
118
- //# sourceMappingURL=_mutateTheme.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 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;AAmBzB,SAASC,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,OAC7BF,aAAaC,IAAAA,IAAQE,IAAII;IAE7B;;AAdK,wBAAA,IAAA,iBAAA;;;OAAA,6BAAA,UAAA,UAAA,QAAA,UAAA,OAAA;;UAAA;cAAA;;;AAgBL,MAAMC,WAAWX,YAAYY,eAAeT,cAAcJ,KAAAA,IAAS,CAAA;AAEnEH,yBAAgB,WAAA;AACd,aAAWiB,aAAaX,kBAAkB;AACxC,UAAMG,SAAQH,iBAAiBW,SAAAA;AAC/BC,wBAAkBD,WAAWR,MAAAA,GAC7BU,4BAA4BF,WAAWR,MAAAA;IACzC;EAC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;AACxEhB,sBAAoBuC,QAAQ,SAACC,SAAAA;AAC3B,IAAIA,QAAQC,MAAM1B,SAASS,aACzBgB,QAAQE,qBACN;MACE3B,MAAMS;MACNmB,YAAY3B;IACd,GACA,EAAA;EAGN,CAAA;AACF;AAEA,SAASO,eAAed,QAAoC;MAAEC,QAAAA,UAAAA,SAAAA,KAAAA,UAAAA,CAAAA,MAAAA,SAAAA,UAAAA,CAAAA,IAAe;AAEzE,SAAO,CAAA;AAGT,MAAMuB,QACFX;AAEJ,WAAWE,aAAaf,QAAQ;AAC9B,QAAMO,QAAQP,OAAOe,SAAAA,GAEfoB,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
- "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
- }
@@ -1,8 +0,0 @@
1
- import { _mutateTheme } from "./_mutateTheme";
2
- function addTheme(props) {
3
- return _mutateTheme({ ...props, insertCSS: !0, mutationType: "add" });
4
- }
5
- export {
6
- addTheme
7
- };
8
- //# sourceMappingURL=addTheme.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/addTheme.ts"],
4
- "mappings": "AAEA,SAAS,oBAAoB;AAEtB,SAAS,SAAS,OAItB;AACD,SAAO,aAAa,EAAE,GAAG,OAAO,WAAW,IAAM,cAAc,MAAM,CAAC;AACxE;",
5
- "names": []
6
- }
@@ -1,10 +0,0 @@
1
- import { _mutateTheme } from "./_mutateTheme.mjs";
2
- function addTheme(props) {
3
- return _mutateTheme({
4
- ...props,
5
- insertCSS: !0,
6
- mutationType: "add"
7
- });
8
- }
9
- export { addTheme };
10
- //# sourceMappingURL=addTheme.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_mutateTheme","addTheme","props","insertCSS","mutationType"],"sources":["../../src/addTheme.ts"],"sourcesContent":[null],"mappings":"AAEA,SAASA,YAAA,QAAoB;AAEtB,SAASC,SAASC,KAAA,EAItB;EACD,OAAOF,YAAA,CAAa;IAAE,GAAGE,KAAA;IAAOC,SAAA,EAAW;IAAMC,YAAA,EAAc;EAAM,CAAC;AACxE","ignoreList":[]}
@@ -1,12 +0,0 @@
1
- import { _mutateTheme } from "./_mutateTheme";
2
- function addTheme(props) {
3
- return _mutateTheme({
4
- ...props,
5
- insertCSS: !0,
6
- mutationType: "add"
7
- });
8
- }
9
- export {
10
- addTheme
11
- };
12
- //# sourceMappingURL=addTheme.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/Users/n8/tamagui/code/core/theme/src/addTheme.ts"],
4
- "mappings": "AAEA,SAASA,oBAAoB;AAEtB,SAASC,SAASC,OAIxB;AACC,SAAOF,aAAa;IAAE,GAAGE;IAAOC,WAAW;IAAMC,cAAc;EAAM,CAAA;AACvE;",
5
- "names": ["_mutateTheme", "addTheme", "props", "insertCSS", "mutationType"]
6
- }
package/dist/jsx/index.js DELETED
@@ -1,8 +0,0 @@
1
- export * from "./addTheme";
2
- export * from "./updateTheme";
3
- export * from "./replaceTheme";
4
- import { mutateThemes } from "./_mutateTheme";
5
- export {
6
- mutateThemes
7
- };
8
- //# sourceMappingURL=index.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/index.ts"],
4
- "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,oBAAoB;",
5
- "names": []
6
- }
@@ -1,6 +0,0 @@
1
- export * from "./addTheme.mjs";
2
- export * from "./updateTheme.mjs";
3
- export * from "./replaceTheme.mjs";
4
- import { mutateThemes } from "./_mutateTheme.mjs";
5
- export { mutateThemes };
6
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["mutateThemes"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAASA,YAAA,QAAoB","ignoreList":[]}
@@ -1,8 +0,0 @@
1
- export * from "./addTheme";
2
- export * from "./updateTheme";
3
- export * from "./replaceTheme";
4
- import { mutateThemes } from "./_mutateTheme";
5
- export {
6
- mutateThemes
7
- };
8
- //# sourceMappingURL=index.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/Users/n8/tamagui/code/core/theme/src/index.ts"],
4
- "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAASA,oBAAoB;",
5
- "names": ["mutateThemes"]
6
- }
@@ -1,11 +0,0 @@
1
- import { _mutateTheme } from "./_mutateTheme";
2
- function replaceTheme({
3
- name,
4
- theme
5
- }) {
6
- return _mutateTheme({ name, theme, insertCSS: !0, mutationType: "replace" });
7
- }
8
- export {
9
- replaceTheme
10
- };
11
- //# sourceMappingURL=replaceTheme.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/replaceTheme.ts"],
4
- "mappings": "AAEA,SAAS,oBAAoB;AAEtB,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AACF,GAGG;AAED,SADa,aAAa,EAAE,MAAM,OAAO,WAAW,IAAM,cAAc,UAAU,CAAC;AAErF;",
5
- "names": []
6
- }
@@ -1,14 +0,0 @@
1
- import { _mutateTheme } from "./_mutateTheme.mjs";
2
- function replaceTheme({
3
- name,
4
- theme
5
- }) {
6
- return _mutateTheme({
7
- name,
8
- theme,
9
- insertCSS: !0,
10
- mutationType: "replace"
11
- });
12
- }
13
- export { replaceTheme };
14
- //# sourceMappingURL=replaceTheme.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_mutateTheme","replaceTheme","name","theme","insertCSS","mutationType"],"sources":["../../src/replaceTheme.ts"],"sourcesContent":[null],"mappings":"AAEA,SAASA,YAAA,QAAoB;AAEtB,SAASC,aAAa;EAC3BC,IAAA;EACAC;AACF,GAGG;EAED,OADaH,YAAA,CAAa;IAAEE,IAAA;IAAMC,KAAA;IAAOC,SAAA,EAAW;IAAMC,YAAA,EAAc;EAAU,CAAC;AAErF","ignoreList":[]}
@@ -1,14 +0,0 @@
1
- import { _mutateTheme } from "./_mutateTheme";
2
- function replaceTheme(param) {
3
- var { name, theme } = param, next = _mutateTheme({
4
- name,
5
- theme,
6
- insertCSS: !0,
7
- mutationType: "replace"
8
- });
9
- return next;
10
- }
11
- export {
12
- replaceTheme
13
- };
14
- //# sourceMappingURL=replaceTheme.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/Users/n8/tamagui/code/core/theme/src/replaceTheme.ts"],
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
- "names": ["_mutateTheme", "replaceTheme", "name", "theme", "next", "insertCSS", "mutationType"]
6
- }
@@ -1,11 +0,0 @@
1
- import { _mutateTheme } from "./_mutateTheme";
2
- function updateTheme({
3
- name,
4
- theme
5
- }) {
6
- return _mutateTheme({ name, theme, insertCSS: !0, mutationType: "update" });
7
- }
8
- export {
9
- updateTheme
10
- };
11
- //# sourceMappingURL=updateTheme.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/updateTheme.ts"],
4
- "mappings": "AAEA,SAAS,oBAAoB;AAEtB,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AACF,GAGG;AACD,SAAO,aAAa,EAAE,MAAM,OAAO,WAAW,IAAM,cAAc,SAAS,CAAC;AAC9E;",
5
- "names": []
6
- }
@@ -1,14 +0,0 @@
1
- import { _mutateTheme } from "./_mutateTheme.mjs";
2
- function updateTheme({
3
- name,
4
- theme
5
- }) {
6
- return _mutateTheme({
7
- name,
8
- theme,
9
- insertCSS: !0,
10
- mutationType: "update"
11
- });
12
- }
13
- export { updateTheme };
14
- //# sourceMappingURL=updateTheme.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_mutateTheme","updateTheme","name","theme","insertCSS","mutationType"],"sources":["../../src/updateTheme.ts"],"sourcesContent":[null],"mappings":"AAEA,SAASA,YAAA,QAAoB;AAEtB,SAASC,YAAY;EAC1BC,IAAA;EACAC;AACF,GAGG;EACD,OAAOH,YAAA,CAAa;IAAEE,IAAA;IAAMC,KAAA;IAAOC,SAAA,EAAW;IAAMC,YAAA,EAAc;EAAS,CAAC;AAC9E","ignoreList":[]}
@@ -1,14 +0,0 @@
1
- import { _mutateTheme } from "./_mutateTheme";
2
- function updateTheme(param) {
3
- var { name, theme } = param;
4
- return _mutateTheme({
5
- name,
6
- theme,
7
- insertCSS: !0,
8
- mutationType: "update"
9
- });
10
- }
11
- export {
12
- updateTheme
13
- };
14
- //# sourceMappingURL=updateTheme.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/Users/n8/tamagui/code/core/theme/src/updateTheme.ts"],
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
- "names": ["_mutateTheme", "updateTheme", "name", "theme", "insertCSS", "mutationType"]
6
- }