@tamagui/theme 1.61.3 → 1.62.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.
Files changed (47) hide show
  1. package/dist/cjs/_mutateTheme.js +36 -79
  2. package/dist/cjs/_mutateTheme.js.map +1 -1
  3. package/dist/cjs/_mutateTheme.native.js +112 -0
  4. package/dist/cjs/_mutateTheme.native.js.map +6 -0
  5. package/dist/cjs/addTheme.js +6 -10
  6. package/dist/cjs/addTheme.js.map +1 -1
  7. package/dist/cjs/addTheme.native.js +29 -0
  8. package/dist/cjs/addTheme.native.js.map +6 -0
  9. package/dist/cjs/index.js +6 -11
  10. package/dist/cjs/index.js.map +1 -1
  11. package/dist/cjs/index.native.js +32 -0
  12. package/dist/cjs/index.native.js.map +6 -0
  13. package/dist/cjs/replaceTheme.js +6 -11
  14. package/dist/cjs/replaceTheme.js.map +1 -1
  15. package/dist/cjs/replaceTheme.native.js +32 -0
  16. package/dist/cjs/replaceTheme.native.js.map +6 -0
  17. package/dist/cjs/updateTheme.js +6 -10
  18. package/dist/cjs/updateTheme.js.map +1 -1
  19. package/dist/cjs/updateTheme.native.js +32 -0
  20. package/dist/cjs/updateTheme.native.js.map +6 -0
  21. package/dist/esm/_mutateTheme.js +30 -67
  22. package/dist/esm/_mutateTheme.js.map +1 -1
  23. package/dist/esm/addTheme.js +1 -1
  24. package/dist/esm/addTheme.js.map +1 -1
  25. package/dist/esm/replaceTheme.js +1 -2
  26. package/dist/esm/replaceTheme.js.map +1 -1
  27. package/dist/esm/updateTheme.js +1 -1
  28. package/dist/esm/updateTheme.js.map +1 -1
  29. package/dist/jsx/_mutateTheme.js +30 -66
  30. package/dist/jsx/_mutateTheme.js.map +1 -1
  31. package/dist/jsx/_mutateTheme.native.js +100 -0
  32. package/dist/jsx/_mutateTheme.native.js.map +6 -0
  33. package/dist/jsx/addTheme.js +1 -1
  34. package/dist/jsx/addTheme.js.map +1 -1
  35. package/dist/jsx/addTheme.native.js +8 -0
  36. package/dist/jsx/addTheme.native.js.map +6 -0
  37. package/dist/jsx/index.native.js +8 -0
  38. package/dist/jsx/index.native.js.map +6 -0
  39. package/dist/jsx/replaceTheme.js +1 -2
  40. package/dist/jsx/replaceTheme.js.map +1 -1
  41. package/dist/jsx/replaceTheme.native.js +11 -0
  42. package/dist/jsx/replaceTheme.native.js.map +6 -0
  43. package/dist/jsx/updateTheme.js +1 -1
  44. package/dist/jsx/updateTheme.js.map +1 -1
  45. package/dist/jsx/updateTheme.native.js +11 -0
  46. package/dist/jsx/updateTheme.native.js.map +6 -0
  47. package/package.json +4 -4
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
16
+ var updateTheme_exports = {};
17
+ __export(updateTheme_exports, {
18
+ updateTheme: () => updateTheme
19
+ });
20
+ module.exports = __toCommonJS(updateTheme_exports);
21
+ var import_mutateTheme = require("./_mutateTheme");
22
+ function updateTheme({
23
+ name,
24
+ theme
25
+ }) {
26
+ return (0, import_mutateTheme._mutateTheme)({ name, theme, insertCSS: !0, mutationType: "update" });
27
+ }
28
+ // Annotate the CommonJS export names for ESM import in node:
29
+ 0 && (module.exports = {
30
+ updateTheme
31
+ });
32
+ //# sourceMappingURL=updateTheme.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/updateTheme.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,yBAA6B;AAEtB,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AACF,GAGG;AACD,aAAO,iCAAa,EAAE,MAAM,OAAO,WAAW,IAAM,cAAc,SAAS,CAAC;AAC9E;",
5
+ "names": []
6
+ }
@@ -12,35 +12,29 @@ import { startTransition } from "react";
12
12
  function mutateThemes({
13
13
  themes,
14
14
  batch,
15
- insertCSS = true,
15
+ insertCSS = !0,
16
16
  ...props
17
17
  }) {
18
- const allThemesProxied = {};
19
- const allThemesRaw = {};
18
+ const allThemesProxied = {}, allThemesRaw = {};
20
19
  for (const { name, theme } of themes) {
21
20
  const res = _mutateTheme({
22
21
  ...props,
23
22
  name,
24
23
  theme,
25
24
  // we'll do one update at the end
26
- avoidUpdate: true,
25
+ avoidUpdate: !0,
27
26
  // always add which also replaces but doesnt fail first time
28
27
  mutationType: "add"
29
28
  });
30
- if (res) {
31
- allThemesProxied[name] = res.theme;
32
- allThemesRaw[name] = res.themeRaw;
33
- }
29
+ res && (allThemesProxied[name] = res.theme, allThemesRaw[name] = res.themeRaw);
34
30
  }
35
31
  const cssRules = insertCSS ? insertThemeCSS(allThemesRaw, batch) : [];
36
- startTransition(() => {
32
+ return startTransition(() => {
37
33
  for (const themeName in allThemesProxied) {
38
34
  const theme = allThemesProxied[themeName];
39
- updateThemeConfig(themeName, theme);
40
- notifyThemeManagersOfUpdate(themeName, theme);
35
+ updateThemeConfig(themeName, theme), notifyThemeManagersOfUpdate(themeName, theme);
41
36
  }
42
- });
43
- return {
37
+ }), {
44
38
  themes: allThemesProxied,
45
39
  themesRaw: allThemesRaw,
46
40
  cssRules
@@ -48,86 +42,61 @@ function mutateThemes({
48
42
  }
49
43
  function _mutateTheme(props) {
50
44
  if (isServer) {
51
- if (process.env.NODE_ENV === "development") {
52
- console.warn("Theme mutation is not supported on server side");
53
- }
45
+ process.env.NODE_ENV === "development" && console.warn("Theme mutation is not supported on server side");
54
46
  return;
55
47
  }
56
- const config = getConfig();
57
- const { name: themeName, theme: themeIn, insertCSS, mutationType } = props;
48
+ const config = getConfig(), { name: themeName, theme: themeIn, insertCSS, mutationType } = props;
58
49
  if (process.env.NODE_ENV === "development") {
59
- if (!config) {
50
+ if (!config)
60
51
  throw new Error("No config");
61
- }
62
52
  const theme2 = config.themes[props.name];
63
- if (mutationType !== "add" && !theme2) {
53
+ if (mutationType !== "add" && !theme2)
64
54
  throw new Error(
65
55
  `${mutationType === "replace" ? "Replace" : "Update"} theme failed! Theme ${props.name} does not exist`
66
56
  );
67
- }
68
57
  }
69
58
  const theme = {
70
59
  ...mutationType === "update" ? config.themes[themeName] ?? {} : {},
71
60
  ...themeIn
72
61
  };
73
- for (const key in theme) {
62
+ for (const key in theme)
74
63
  ensureThemeVariable(theme, key);
75
- }
76
- const themeProxied = proxyThemeToParents(themeName, theme);
77
- const response = {
64
+ const themeProxied = proxyThemeToParents(themeName, theme), response = {
78
65
  themeRaw: theme,
79
66
  theme: themeProxied,
80
67
  cssRules: []
81
68
  };
82
- if (props.avoidUpdate) {
83
- return response;
84
- }
85
- if (insertCSS) {
86
- response.cssRules = insertThemeCSS({
87
- [themeName]: theme
88
- });
89
- }
90
- updateThemeConfig(themeName, themeProxied);
91
- notifyThemeManagersOfUpdate(themeName, themeProxied);
92
- return response;
69
+ return props.avoidUpdate || (insertCSS && (response.cssRules = insertThemeCSS({
70
+ [themeName]: theme
71
+ })), updateThemeConfig(themeName, themeProxied), notifyThemeManagersOfUpdate(themeName, themeProxied)), response;
93
72
  }
94
73
  function updateThemeConfig(themeName, theme) {
95
74
  const config = getConfig();
96
- config.themes[themeName] = theme;
97
- updateConfig("themes", config.themes);
75
+ config.themes[themeName] = theme, updateConfig("themes", config.themes);
98
76
  }
99
77
  function notifyThemeManagersOfUpdate(themeName, theme) {
100
78
  activeThemeManagers.forEach((manager) => {
101
- if (manager.state.name === themeName) {
102
- manager.updateStateFromProps(
103
- {
104
- name: themeName,
105
- forceTheme: theme
106
- },
107
- true
108
- );
109
- }
79
+ manager.state.name === themeName && manager.updateStateFromProps(
80
+ {
81
+ name: themeName,
82
+ forceTheme: theme
83
+ },
84
+ !0
85
+ );
110
86
  });
111
87
  }
112
- function insertThemeCSS(themes, batch = false) {
113
- if (process.env.TAMAGUI_TARGET !== "web") {
114
- return [];
115
- }
88
+ function insertThemeCSS(themes, batch = !1) {
116
89
  const config = getConfig();
117
90
  let cssRules = [];
118
91
  for (const themeName in themes) {
119
- const theme = themes[themeName];
120
- const rules = getThemeCSSRules({
92
+ const theme = themes[themeName], rules = getThemeCSSRules({
121
93
  // @ts-ignore this works but should be fixed types
122
94
  config,
123
95
  themeName,
124
96
  names: [themeName],
125
97
  theme
126
98
  });
127
- cssRules = [...cssRules, ...rules];
128
- if (!batch) {
129
- updateStyle(`t_theme_style_${themeName}`, rules);
130
- }
99
+ cssRules = [...cssRules, ...rules], batch || updateStyle(`t_theme_style_${themeName}`, rules);
131
100
  }
132
101
  if (batch) {
133
102
  const id = simpleHash(Object.keys(themes).join(","));
@@ -136,15 +105,9 @@ function insertThemeCSS(themes, batch = false) {
136
105
  return cssRules;
137
106
  }
138
107
  function updateStyle(id, rules) {
139
- var _a;
140
- const existing = document.querySelector(`#${id}`);
141
- const style = document.createElement("style");
142
- style.id = id;
143
- style.appendChild(document.createTextNode(rules.join("\n")));
144
- document.head.appendChild(style);
145
- if (existing) {
146
- (_a = existing.parentElement) == null ? void 0 : _a.removeChild(existing);
147
- }
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);
148
111
  }
149
112
  export {
150
113
  _mutateTheme,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/_mutateTheme.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
3
- return _mutateTheme({ ...props, insertCSS: true, mutationType: "add" });
3
+ return _mutateTheme({ ...props, insertCSS: !0, mutationType: "add" });
4
4
  }
5
5
  export {
6
6
  addTheme
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/addTheme.ts"],
4
- "mappings": "AAEA,SAAS,oBAAoB;AAEtB,SAAS,SAAS,OAItB;AACD,SAAO,aAAa,EAAE,GAAG,OAAO,WAAW,MAAM,cAAc,MAAM,CAAC;AACxE;",
4
+ "mappings": "AAEA,SAAS,oBAAoB;AAEtB,SAAS,SAAS,OAItB;AACD,SAAO,aAAa,EAAE,GAAG,OAAO,WAAW,IAAM,cAAc,MAAM,CAAC;AACxE;",
5
5
  "names": []
6
6
  }
@@ -3,8 +3,7 @@ function replaceTheme({
3
3
  name,
4
4
  theme
5
5
  }) {
6
- const next = _mutateTheme({ name, theme, insertCSS: true, mutationType: "replace" });
7
- return next;
6
+ return _mutateTheme({ name, theme, insertCSS: !0, mutationType: "replace" });
8
7
  }
9
8
  export {
10
9
  replaceTheme
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/replaceTheme.ts"],
4
- "mappings": "AAEA,SAAS,oBAAoB;AAEtB,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AACF,GAGG;AACD,QAAM,OAAO,aAAa,EAAE,MAAM,OAAO,WAAW,MAAM,cAAc,UAAU,CAAC;AACnF,SAAO;AACT;",
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
5
  "names": []
6
6
  }
@@ -3,7 +3,7 @@ function updateTheme({
3
3
  name,
4
4
  theme
5
5
  }) {
6
- return _mutateTheme({ name, theme, insertCSS: true, mutationType: "update" });
6
+ return _mutateTheme({ name, theme, insertCSS: !0, mutationType: "update" });
7
7
  }
8
8
  export {
9
9
  updateTheme
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
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,MAAM,cAAc,SAAS,CAAC;AAC9E;",
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
5
  "names": []
6
6
  }
@@ -12,35 +12,29 @@ import { startTransition } from "react";
12
12
  function mutateThemes({
13
13
  themes,
14
14
  batch,
15
- insertCSS = true,
15
+ insertCSS = !0,
16
16
  ...props
17
17
  }) {
18
- const allThemesProxied = {};
19
- const allThemesRaw = {};
18
+ const allThemesProxied = {}, allThemesRaw = {};
20
19
  for (const { name, theme } of themes) {
21
20
  const res = _mutateTheme({
22
21
  ...props,
23
22
  name,
24
23
  theme,
25
24
  // we'll do one update at the end
26
- avoidUpdate: true,
25
+ avoidUpdate: !0,
27
26
  // always add which also replaces but doesnt fail first time
28
27
  mutationType: "add"
29
28
  });
30
- if (res) {
31
- allThemesProxied[name] = res.theme;
32
- allThemesRaw[name] = res.themeRaw;
33
- }
29
+ res && (allThemesProxied[name] = res.theme, allThemesRaw[name] = res.themeRaw);
34
30
  }
35
31
  const cssRules = insertCSS ? insertThemeCSS(allThemesRaw, batch) : [];
36
- startTransition(() => {
32
+ return startTransition(() => {
37
33
  for (const themeName in allThemesProxied) {
38
34
  const theme = allThemesProxied[themeName];
39
- updateThemeConfig(themeName, theme);
40
- notifyThemeManagersOfUpdate(themeName, theme);
35
+ updateThemeConfig(themeName, theme), notifyThemeManagersOfUpdate(themeName, theme);
41
36
  }
42
- });
43
- return {
37
+ }), {
44
38
  themes: allThemesProxied,
45
39
  themesRaw: allThemesRaw,
46
40
  cssRules
@@ -48,86 +42,61 @@ function mutateThemes({
48
42
  }
49
43
  function _mutateTheme(props) {
50
44
  if (isServer) {
51
- if (process.env.NODE_ENV === "development") {
52
- console.warn("Theme mutation is not supported on server side");
53
- }
45
+ process.env.NODE_ENV === "development" && console.warn("Theme mutation is not supported on server side");
54
46
  return;
55
47
  }
56
- const config = getConfig();
57
- const { name: themeName, theme: themeIn, insertCSS, mutationType } = props;
48
+ const config = getConfig(), { name: themeName, theme: themeIn, insertCSS, mutationType } = props;
58
49
  if (process.env.NODE_ENV === "development") {
59
- if (!config) {
50
+ if (!config)
60
51
  throw new Error("No config");
61
- }
62
52
  const theme2 = config.themes[props.name];
63
- if (mutationType !== "add" && !theme2) {
53
+ if (mutationType !== "add" && !theme2)
64
54
  throw new Error(
65
55
  `${mutationType === "replace" ? "Replace" : "Update"} theme failed! Theme ${props.name} does not exist`
66
56
  );
67
- }
68
57
  }
69
58
  const theme = {
70
59
  ...mutationType === "update" ? config.themes[themeName] ?? {} : {},
71
60
  ...themeIn
72
61
  };
73
- for (const key in theme) {
62
+ for (const key in theme)
74
63
  ensureThemeVariable(theme, key);
75
- }
76
- const themeProxied = proxyThemeToParents(themeName, theme);
77
- const response = {
64
+ const themeProxied = proxyThemeToParents(themeName, theme), response = {
78
65
  themeRaw: theme,
79
66
  theme: themeProxied,
80
67
  cssRules: []
81
68
  };
82
- if (props.avoidUpdate) {
83
- return response;
84
- }
85
- if (insertCSS) {
86
- response.cssRules = insertThemeCSS({
87
- [themeName]: theme
88
- });
89
- }
90
- updateThemeConfig(themeName, themeProxied);
91
- notifyThemeManagersOfUpdate(themeName, themeProxied);
92
- return response;
69
+ return props.avoidUpdate || (insertCSS && (response.cssRules = insertThemeCSS({
70
+ [themeName]: theme
71
+ })), updateThemeConfig(themeName, themeProxied), notifyThemeManagersOfUpdate(themeName, themeProxied)), response;
93
72
  }
94
73
  function updateThemeConfig(themeName, theme) {
95
74
  const config = getConfig();
96
- config.themes[themeName] = theme;
97
- updateConfig("themes", config.themes);
75
+ config.themes[themeName] = theme, updateConfig("themes", config.themes);
98
76
  }
99
77
  function notifyThemeManagersOfUpdate(themeName, theme) {
100
78
  activeThemeManagers.forEach((manager) => {
101
- if (manager.state.name === themeName) {
102
- manager.updateStateFromProps(
103
- {
104
- name: themeName,
105
- forceTheme: theme
106
- },
107
- true
108
- );
109
- }
79
+ manager.state.name === themeName && manager.updateStateFromProps(
80
+ {
81
+ name: themeName,
82
+ forceTheme: theme
83
+ },
84
+ !0
85
+ );
110
86
  });
111
87
  }
112
- function insertThemeCSS(themes, batch = false) {
113
- if (process.env.TAMAGUI_TARGET !== "web") {
114
- return [];
115
- }
88
+ function insertThemeCSS(themes, batch = !1) {
116
89
  const config = getConfig();
117
90
  let cssRules = [];
118
91
  for (const themeName in themes) {
119
- const theme = themes[themeName];
120
- const rules = getThemeCSSRules({
92
+ const theme = themes[themeName], rules = getThemeCSSRules({
121
93
  // @ts-ignore this works but should be fixed types
122
94
  config,
123
95
  themeName,
124
96
  names: [themeName],
125
97
  theme
126
98
  });
127
- cssRules = [...cssRules, ...rules];
128
- if (!batch) {
129
- updateStyle(`t_theme_style_${themeName}`, rules);
130
- }
99
+ cssRules = [...cssRules, ...rules], batch || updateStyle(`t_theme_style_${themeName}`, rules);
131
100
  }
132
101
  if (batch) {
133
102
  const id = simpleHash(Object.keys(themes).join(","));
@@ -136,14 +105,9 @@ function insertThemeCSS(themes, batch = false) {
136
105
  return cssRules;
137
106
  }
138
107
  function updateStyle(id, rules) {
139
- const existing = document.querySelector(`#${id}`);
140
- const style = document.createElement("style");
141
- style.id = id;
142
- style.appendChild(document.createTextNode(rules.join("\n")));
143
- document.head.appendChild(style);
144
- if (existing) {
145
- existing.parentElement?.removeChild(existing);
146
- }
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);
147
111
  }
148
112
  export {
149
113
  _mutateTheme,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/_mutateTheme.ts"],
4
- "mappings": "AAAA,SAAS,gBAAgB;AAEzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAgBzB,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,GAAG;AACL,GAMG;AACD,QAAM,mBAAgD,CAAC;AACvD,QAAM,eAA4C,CAAC;AAEnD,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,QAAI,KAAK;AACP,uBAAiB,IAAI,IAAI,IAAI;AAC7B,mBAAa,IAAI,IAAI,IAAI;AAAA,IAC3B;AAAA,EACF;AAEA,QAAM,WAAW,YAAY,eAAe,cAAc,KAAK,IAAI,CAAC;AAEpE,kBAAgB,MAAM;AACpB,eAAW,aAAa,kBAAkB;AACxC,YAAM,QAAQ,iBAAiB,SAAS;AACxC,wBAAkB,WAAW,KAAK;AAClC,kCAA4B,WAAW,KAAK;AAAA,IAC9C;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL,QAAQ;AAAA,IACR,WAAW;AAAA,IACX;AAAA,EACF;AACF;AAEO,SAAS,aAAa,OAAiD;AAC5E,MAAI,UAAU;AACZ,QAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,cAAQ,KAAK,gDAAgD;AAAA,IAC/D;AACA;AAAA,EACF;AACA,QAAM,SAAS,UAAU;AACzB,QAAM,EAAE,MAAM,WAAW,OAAO,SAAS,WAAW,aAAa,IAAI;AA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YACF,SAAS,eAAe,YAAY,QAAQ;AAEhD;",
5
5
  "names": ["theme"]
6
6
  }
@@ -0,0 +1,100 @@
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 "react";
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
+ return [];
90
+ }
91
+ function updateStyle(id, rules) {
92
+ const existing = document.querySelector(`#${id}`), style = document.createElement("style");
93
+ style.id = id, style.appendChild(document.createTextNode(rules.join(`
94
+ `))), document.head.appendChild(style), existing && existing.parentElement?.removeChild(existing);
95
+ }
96
+ export {
97
+ _mutateTheme,
98
+ mutateThemes
99
+ };
100
+ //# sourceMappingURL=_mutateTheme.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/_mutateTheme.ts"],
4
+ "mappings": "AAAA,SAAS,gBAAgB;AAEzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAgBzB,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,GAAG;AACL,GAMG;AACD,QAAM,mBAAgD,CAAC,GACjD,eAA4C,CAAC;AAEnD,aAAW,EAAE,MAAM,MAAM,KAAK,QAAQ;AAC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IACP,UAAU,CAAC;AAAA,EACb;AAEA,SAAI,MAAM,gBAIN,cACF,SAAS,WAAW,eAAe;AAAA,IACjC,CAAC,SAAS,GAAG;AAAA,EACf,CAAC,IAGH,kBAAkB,WAAW,YAAY,GACzC,4BAA4B,WAAW,YAAY,IAE5C;AACT;AAEA,SAAS,kBAAkB,WAAmB,OAAoB;AAChE,QAAM,SAAS,UAAU;AACzB,SAAO,OAAO,SAAS,IAAI,OAC3B,aAAa,UAAU,OAAO,MAAM;AACtC;AAEA,SAAS,4BAA4B,WAAmB,OAAoB;AAC1E,sBAAoB,QAAQ,CAAC,YAAY;AACvC,IAAI,QAAQ,MAAM,SAAS,aACzB,QAAQ;AAAA,MACN;AAAA,QACE,MAAM;AAAA,QACN,YAAY;AAAA,MACd;AAAA,MACA;AAAA,IACF;AAAA,EAEJ,CAAC;AACH;AAEA,SAAS,eAAe,QAAsC,QAAQ,IAAO;AAEzE,SAAO,CAAC;AA8BZ;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,6 +1,6 @@
1
1
  import { _mutateTheme } from "./_mutateTheme";
2
2
  function addTheme(props) {
3
- return _mutateTheme({ ...props, insertCSS: true, mutationType: "add" });
3
+ return _mutateTheme({ ...props, insertCSS: !0, mutationType: "add" });
4
4
  }
5
5
  export {
6
6
  addTheme
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/addTheme.ts"],
4
- "mappings": "AAEA,SAAS,oBAAoB;AAEtB,SAAS,SAAS,OAItB;AACD,SAAO,aAAa,EAAE,GAAG,OAAO,WAAW,MAAM,cAAc,MAAM,CAAC;AACxE;",
4
+ "mappings": "AAEA,SAAS,oBAAoB;AAEtB,SAAS,SAAS,OAItB;AACD,SAAO,aAAa,EAAE,GAAG,OAAO,WAAW,IAAM,cAAc,MAAM,CAAC;AACxE;",
5
5
  "names": []
6
6
  }
@@ -0,0 +1,8 @@
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
@@ -0,0 +1,6 @@
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
+ }
@@ -0,0 +1,8 @@
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
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,oBAAoB;",
5
+ "names": []
6
+ }
@@ -3,8 +3,7 @@ function replaceTheme({
3
3
  name,
4
4
  theme
5
5
  }) {
6
- const next = _mutateTheme({ name, theme, insertCSS: true, mutationType: "replace" });
7
- return next;
6
+ return _mutateTheme({ name, theme, insertCSS: !0, mutationType: "replace" });
8
7
  }
9
8
  export {
10
9
  replaceTheme