@tamagui/theme 1.14.1 → 1.14.2

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.
@@ -1,3 +1,76 @@
1
- "use strict";var f=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var y=(t,e)=>{for(var n in e)f(t,n,{get:e[n],enumerable:!0})},C=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of g(e))!T.call(t,m)&&m!==n&&f(t,m,{get:()=>e[m],enumerable:!(r=p(e,m))||r.enumerable});return t};var S=t=>C(f({},"__esModule",{value:!0}),t);var x={};y(x,{addTheme:()=>b});module.exports=S(x);var u=require("@tamagui/constants"),o=require("@tamagui/web");function b(t){var l;const e=(0,o.getConfig)();if(process.env.NODE_ENV==="development"){if(!e)throw new Error("No config");const i=e.themes[t.name];if(!t.update&&i)return{theme:i}}const{name:n,theme:r,insertCSS:m}=t,s={...r};for(const i in s)(0,o.ensureThemeVariable)(s,i);const a=(0,o.proxyThemeToParents)(n,s,e.themes);e.themes[n]=a;let h=[];if(u.isWeb&&m){h=(0,o.getThemeCSSRules)({config:e,themeName:n,names:[n],theme:s});const i=`t_theme_style_${n}`,d=document.querySelector(`#${i}`),c=document.createElement("style");c.id=i,c.appendChild(document.createTextNode(h.join(`
2
- `))),document.head.appendChild(c),d&&((l=d.parentElement)==null||l.removeChild(d))}return(0,o.updateConfig)("themes",{...e.themes,[n]:a}),{theme:a,cssRules:h}}0&&(module.exports={addTheme});
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: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var addTheme_exports = {};
20
+ __export(addTheme_exports, {
21
+ addTheme: () => addTheme
22
+ });
23
+ module.exports = __toCommonJS(addTheme_exports);
24
+ var import_constants = require("@tamagui/constants");
25
+ var import_web = require("@tamagui/web");
26
+ function addTheme(props) {
27
+ var _a;
28
+ const config = (0, import_web.getConfig)();
29
+ if (process.env.NODE_ENV === "development") {
30
+ if (!config) {
31
+ throw new Error("No config");
32
+ }
33
+ const theme2 = config.themes[props.name];
34
+ if (!props.update && theme2) {
35
+ return { theme: theme2 };
36
+ }
37
+ }
38
+ const { name: themeName, theme: themeIn, insertCSS } = props;
39
+ const theme = { ...themeIn };
40
+ for (const key in theme) {
41
+ (0, import_web.ensureThemeVariable)(theme, key);
42
+ }
43
+ const themeProxied = (0, import_web.proxyThemeToParents)(themeName, theme, config.themes);
44
+ config.themes[themeName] = themeProxied;
45
+ let cssRules = [];
46
+ if (import_constants.isWeb) {
47
+ if (insertCSS) {
48
+ cssRules = (0, import_web.getThemeCSSRules)({
49
+ // @ts-ignore this works but should be fixed types
50
+ config,
51
+ themeName,
52
+ names: [themeName],
53
+ theme
54
+ });
55
+ const id = `t_theme_style_${themeName}`;
56
+ const existing = document.querySelector(`#${id}`);
57
+ const style = document.createElement("style");
58
+ style.id = id;
59
+ style.appendChild(document.createTextNode(cssRules.join("\n")));
60
+ document.head.appendChild(style);
61
+ if (existing) {
62
+ (_a = existing.parentElement) == null ? void 0 : _a.removeChild(existing);
63
+ }
64
+ }
65
+ }
66
+ (0, import_web.updateConfig)("themes", { ...config.themes, [themeName]: themeProxied });
67
+ return {
68
+ theme: themeProxied,
69
+ cssRules
70
+ };
71
+ }
72
+ // Annotate the CommonJS export names for ESM import in node:
73
+ 0 && (module.exports = {
74
+ addTheme
75
+ });
3
76
  //# sourceMappingURL=addTheme.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/addTheme.ts"],
4
4
  "sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport {\n ensureThemeVariable,\n getConfig,\n getThemeCSSRules,\n proxyThemeToParents,\n updateConfig,\n} from '@tamagui/web'\nimport type { ThemeDefinition, ThemeParsed } from '@tamagui/web'\n\nexport function addTheme(props: {\n name: string\n theme: Partial<Record<keyof ThemeDefinition, any>>\n insertCSS?: boolean\n update?: boolean\n}) {\n const config = getConfig()\n\n if (process.env.NODE_ENV === 'development') {\n if (!config) {\n throw new Error('No config')\n }\n const theme = config.themes[props.name]\n if (!props.update && theme) {\n return { theme }\n }\n }\n\n const { name: themeName, theme: themeIn, insertCSS } = props\n const theme = { ...themeIn } as ThemeParsed\n for (const key in theme) {\n ensureThemeVariable(theme, key)\n }\n\n const themeProxied = proxyThemeToParents(themeName, theme, config.themes)\n config.themes[themeName] = themeProxied\n\n let cssRules: string[] = []\n\n if (isWeb) {\n if (insertCSS) {\n cssRules = getThemeCSSRules({\n // @ts-ignore this works but should be fixed types\n config,\n themeName,\n names: [themeName],\n theme,\n })\n const id = `t_theme_style_${themeName}`\n const existing = document.querySelector(`#${id}`)\n const style = document.createElement('style')\n style.id = id\n style.appendChild(document.createTextNode(cssRules.join('\\n')))\n document.head.appendChild(style)\n if (existing) {\n existing.parentElement?.removeChild(existing)\n }\n }\n }\n\n updateConfig('themes', { ...config.themes, [themeName]: themeProxied })\n\n // trigger updates in components\n return {\n theme: themeProxied,\n cssRules,\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAsB,8BACtBC,EAMO,wBAGA,SAASH,EAASI,EAKtB,CAfH,IAAAC,EAgBE,MAAMC,KAAS,aAAU,EAEzB,GAAI,QAAQ,IAAI,WAAa,cAAe,CAC1C,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,WAAW,EAE7B,MAAMC,EAAQD,EAAO,OAAOF,EAAM,IAAI,EACtC,GAAI,CAACA,EAAM,QAAUG,EACnB,MAAO,CAAE,MAAAA,CAAM,CAEnB,CAEA,KAAM,CAAE,KAAMC,EAAW,MAAOC,EAAS,UAAAC,CAAU,EAAIN,EACjDG,EAAQ,CAAE,GAAGE,CAAQ,EAC3B,UAAWE,KAAOJ,KAChB,uBAAoBA,EAAOI,CAAG,EAGhC,MAAMC,KAAe,uBAAoBJ,EAAWD,EAAOD,EAAO,MAAM,EACxEA,EAAO,OAAOE,CAAS,EAAII,EAE3B,IAAIC,EAAqB,CAAC,EAE1B,GAAI,SACEH,EAAW,CACbG,KAAW,oBAAiB,CAE1B,OAAAP,EACA,UAAAE,EACA,MAAO,CAACA,CAAS,EACjB,MAAAD,CACF,CAAC,EACD,MAAMO,EAAK,iBAAiBN,IACtBO,EAAW,SAAS,cAAc,IAAID,GAAI,EAC1CE,EAAQ,SAAS,cAAc,OAAO,EAC5CA,EAAM,GAAKF,EACXE,EAAM,YAAY,SAAS,eAAeH,EAAS,KAAK;AAAA,CAAI,CAAC,CAAC,EAC9D,SAAS,KAAK,YAAYG,CAAK,EAC3BD,KACFV,EAAAU,EAAS,gBAAT,MAAAV,EAAwB,YAAYU,GAExC,CAGF,yBAAa,SAAU,CAAE,GAAGT,EAAO,OAAQ,CAACE,CAAS,EAAGI,CAAa,CAAC,EAG/D,CACL,MAAOA,EACP,SAAAC,CACF,CACF",
6
- "names": ["addTheme_exports", "__export", "addTheme", "__toCommonJS", "import_constants", "import_web", "props", "_a", "config", "theme", "themeName", "themeIn", "insertCSS", "key", "themeProxied", "cssRules", "id", "existing", "style"]
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAsB;AACtB,iBAMO;AAGA,SAAS,SAAS,OAKtB;AAfH;AAgBE,QAAM,aAAS,sBAAU;AAEzB,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,MAAM,WAAW;AAAA,IAC7B;AACA,UAAMA,SAAQ,OAAO,OAAO,MAAM,IAAI;AACtC,QAAI,CAAC,MAAM,UAAUA,QAAO;AAC1B,aAAO,EAAE,OAAAA,OAAM;AAAA,IACjB;AAAA,EACF;AAEA,QAAM,EAAE,MAAM,WAAW,OAAO,SAAS,UAAU,IAAI;AACvD,QAAM,QAAQ,EAAE,GAAG,QAAQ;AAC3B,aAAW,OAAO,OAAO;AACvB,wCAAoB,OAAO,GAAG;AAAA,EAChC;AAEA,QAAM,mBAAe,gCAAoB,WAAW,OAAO,OAAO,MAAM;AACxE,SAAO,OAAO,SAAS,IAAI;AAE3B,MAAI,WAAqB,CAAC;AAE1B,MAAI,wBAAO;AACT,QAAI,WAAW;AACb,qBAAW,6BAAiB;AAAA;AAAA,QAE1B;AAAA,QACA;AAAA,QACA,OAAO,CAAC,SAAS;AAAA,QACjB;AAAA,MACF,CAAC;AACD,YAAM,KAAK,iBAAiB;AAC5B,YAAM,WAAW,SAAS,cAAc,IAAI,IAAI;AAChD,YAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,YAAM,KAAK;AACX,YAAM,YAAY,SAAS,eAAe,SAAS,KAAK,IAAI,CAAC,CAAC;AAC9D,eAAS,KAAK,YAAY,KAAK;AAC/B,UAAI,UAAU;AACZ,uBAAS,kBAAT,mBAAwB,YAAY;AAAA,MACtC;AAAA,IACF;AAAA,EACF;AAEA,+BAAa,UAAU,EAAE,GAAG,OAAO,QAAQ,CAAC,SAAS,GAAG,aAAa,CAAC;AAGtE,SAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,EACF;AACF;",
6
+ "names": ["theme"]
7
7
  }
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,20 @@
1
- "use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(r,o,p,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let m of c(o))!d.call(r,m)&&m!==p&&a(r,m,{get:()=>o[m],enumerable:!(x=b(o,m))||x.enumerable});return r},f=(r,o,p)=>(t(r,o,"default"),p&&t(p,o,"default"));var g=r=>t(a({},"__esModule",{value:!0}),r);var e={};module.exports=g(e);f(e,require("./addTheme"),module.exports);f(e,require("./updateTheme"),module.exports);
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var src_exports = {};
17
+ module.exports = __toCommonJS(src_exports);
18
+ __reExport(src_exports, require("./addTheme"), module.exports);
19
+ __reExport(src_exports, require("./updateTheme"), module.exports);
2
20
  //# sourceMappingURL=index.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
4
  "sourcesContent": ["export * from './addTheme'\nexport * from './updateTheme'\n"],
5
- "mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,sBAAd,gBACAE,EAAAF,EAAc,yBADd",
6
- "names": ["src_exports", "__toCommonJS", "__reExport"]
5
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,uBAAd;AACA,wBAAc,0BADd;",
6
+ "names": []
7
7
  }
@@ -1,2 +1,47 @@
1
- "use strict";var a=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var T=(e,t)=>{for(var i in t)a(e,i,{get:t[i],enumerable:!0})},u=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of h(t))!p.call(e,o)&&o!==i&&a(e,o,{get:()=>t[o],enumerable:!(r=f(t,o))||r.enumerable});return e};var c=e=>u(a({},"__esModule",{value:!0}),e);var d={};T(d,{updateTheme:()=>s});module.exports=c(d);var m=require("@tamagui/web"),n=require("./addTheme.js");function s({name:e,theme:t}){const i=(0,n.addTheme)({name:e,theme:t,insertCSS:!0,update:!0});return process.env.TAMAGUI_TARGET==="native"&&m.activeThemeManagers.forEach(r=>{r.state.name===e&&r.updateState({name:e,forceTheme:i.theme})}),i}0&&(module.exports={updateTheme});
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: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var updateTheme_exports = {};
20
+ __export(updateTheme_exports, {
21
+ updateTheme: () => updateTheme
22
+ });
23
+ module.exports = __toCommonJS(updateTheme_exports);
24
+ var import_web = require("@tamagui/web");
25
+ var import_addTheme = require("./addTheme.js");
26
+ function updateTheme({
27
+ name,
28
+ theme
29
+ }) {
30
+ const next = (0, import_addTheme.addTheme)({ name, theme, insertCSS: true, update: true });
31
+ if (process.env.TAMAGUI_TARGET === "native") {
32
+ import_web.activeThemeManagers.forEach((manager) => {
33
+ if (manager.state.name === name) {
34
+ manager.updateState({
35
+ name,
36
+ forceTheme: next.theme
37
+ });
38
+ }
39
+ });
40
+ }
41
+ return next;
42
+ }
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ updateTheme
46
+ });
2
47
  //# sourceMappingURL=updateTheme.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/updateTheme.ts"],
4
4
  "sourcesContent": ["import { activeThemeManagers } from '@tamagui/web'\nimport type { ThemeDefinition } from '@tamagui/web'\n\nimport { addTheme } from './addTheme.js'\n\nexport function updateTheme({\n name,\n theme,\n}: {\n name: string\n theme: Partial<Record<keyof ThemeDefinition, any>>\n}) {\n const next = addTheme({ name, theme, insertCSS: true, update: true })\n\n if (process.env.TAMAGUI_TARGET === 'native') {\n activeThemeManagers.forEach((manager) => {\n if (manager.state.name === name) {\n manager.updateState({\n name,\n forceTheme: next.theme,\n })\n }\n })\n }\n\n return next\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAoC,wBAGpCC,EAAyB,yBAElB,SAASH,EAAY,CAC1B,KAAAI,EACA,MAAAC,CACF,EAGG,CACD,MAAMC,KAAO,YAAS,CAAE,KAAAF,EAAM,MAAAC,EAAO,UAAW,GAAM,OAAQ,EAAK,CAAC,EAEpE,OAAI,QAAQ,IAAI,iBAAmB,UACjC,sBAAoB,QAASE,GAAY,CACnCA,EAAQ,MAAM,OAASH,GACzBG,EAAQ,YAAY,CAClB,KAAAH,EACA,WAAYE,EAAK,KACnB,CAAC,CAEL,CAAC,EAGIA,CACT",
6
- "names": ["updateTheme_exports", "__export", "updateTheme", "__toCommonJS", "import_web", "import_addTheme", "name", "theme", "next", "manager"]
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAoC;AAGpC,sBAAyB;AAElB,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AACF,GAGG;AACD,QAAM,WAAO,0BAAS,EAAE,MAAM,OAAO,WAAW,MAAM,QAAQ,KAAK,CAAC;AAEpE,MAAI,QAAQ,IAAI,mBAAmB,UAAU;AAC3C,mCAAoB,QAAQ,CAAC,YAAY;AACvC,UAAI,QAAQ,MAAM,SAAS,MAAM;AAC/B,gBAAQ,YAAY;AAAA,UAClB;AAAA,UACA,YAAY,KAAK;AAAA,QACnB,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;",
6
+ "names": []
7
7
  }
@@ -1,3 +1,58 @@
1
- import{isWeb as f}from"@tamagui/constants";import{ensureThemeVariable as l,getConfig as u,getThemeCSSRules as p,proxyThemeToParents as g,updateConfig as T}from"@tamagui/web";function S(m){var h;const t=u();if(process.env.NODE_ENV==="development"){if(!t)throw new Error("No config");const e=t.themes[m.name];if(!m.update&&e)return{theme:e}}const{name:n,theme:d,insertCSS:c}=m,o={...d};for(const e in o)l(o,e);const i=g(n,o,t.themes);t.themes[n]=i;let r=[];if(f&&c){r=p({config:t,themeName:n,names:[n],theme:o});const e=`t_theme_style_${n}`,s=document.querySelector(`#${e}`),a=document.createElement("style");a.id=e,a.appendChild(document.createTextNode(r.join(`
2
- `))),document.head.appendChild(a),s&&((h=s.parentElement)==null||h.removeChild(s))}return T("themes",{...t.themes,[n]:i}),{theme:i,cssRules:r}}export{S as addTheme};
1
+ import { isWeb } from "@tamagui/constants";
2
+ import {
3
+ ensureThemeVariable,
4
+ getConfig,
5
+ getThemeCSSRules,
6
+ proxyThemeToParents,
7
+ updateConfig
8
+ } from "@tamagui/web";
9
+ function addTheme(props) {
10
+ var _a;
11
+ const config = getConfig();
12
+ if (process.env.NODE_ENV === "development") {
13
+ if (!config) {
14
+ throw new Error("No config");
15
+ }
16
+ const theme2 = config.themes[props.name];
17
+ if (!props.update && theme2) {
18
+ return { theme: theme2 };
19
+ }
20
+ }
21
+ const { name: themeName, theme: themeIn, insertCSS } = props;
22
+ const theme = { ...themeIn };
23
+ for (const key in theme) {
24
+ ensureThemeVariable(theme, key);
25
+ }
26
+ const themeProxied = proxyThemeToParents(themeName, theme, config.themes);
27
+ config.themes[themeName] = themeProxied;
28
+ let cssRules = [];
29
+ if (isWeb) {
30
+ if (insertCSS) {
31
+ cssRules = getThemeCSSRules({
32
+ // @ts-ignore this works but should be fixed types
33
+ config,
34
+ themeName,
35
+ names: [themeName],
36
+ theme
37
+ });
38
+ const id = `t_theme_style_${themeName}`;
39
+ const existing = document.querySelector(`#${id}`);
40
+ const style = document.createElement("style");
41
+ style.id = id;
42
+ style.appendChild(document.createTextNode(cssRules.join("\n")));
43
+ document.head.appendChild(style);
44
+ if (existing) {
45
+ (_a = existing.parentElement) == null ? void 0 : _a.removeChild(existing);
46
+ }
47
+ }
48
+ }
49
+ updateConfig("themes", { ...config.themes, [themeName]: themeProxied });
50
+ return {
51
+ theme: themeProxied,
52
+ cssRules
53
+ };
54
+ }
55
+ export {
56
+ addTheme
57
+ };
3
58
  //# sourceMappingURL=addTheme.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/addTheme.ts"],
4
4
  "sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport {\n ensureThemeVariable,\n getConfig,\n getThemeCSSRules,\n proxyThemeToParents,\n updateConfig,\n} from '@tamagui/web'\nimport type { ThemeDefinition, ThemeParsed } from '@tamagui/web'\n\nexport function addTheme(props: {\n name: string\n theme: Partial<Record<keyof ThemeDefinition, any>>\n insertCSS?: boolean\n update?: boolean\n}) {\n const config = getConfig()\n\n if (process.env.NODE_ENV === 'development') {\n if (!config) {\n throw new Error('No config')\n }\n const theme = config.themes[props.name]\n if (!props.update && theme) {\n return { theme }\n }\n }\n\n const { name: themeName, theme: themeIn, insertCSS } = props\n const theme = { ...themeIn } as ThemeParsed\n for (const key in theme) {\n ensureThemeVariable(theme, key)\n }\n\n const themeProxied = proxyThemeToParents(themeName, theme, config.themes)\n config.themes[themeName] = themeProxied\n\n let cssRules: string[] = []\n\n if (isWeb) {\n if (insertCSS) {\n cssRules = getThemeCSSRules({\n // @ts-ignore this works but should be fixed types\n config,\n themeName,\n names: [themeName],\n theme,\n })\n const id = `t_theme_style_${themeName}`\n const existing = document.querySelector(`#${id}`)\n const style = document.createElement('style')\n style.id = id\n style.appendChild(document.createTextNode(cssRules.join('\\n')))\n document.head.appendChild(style)\n if (existing) {\n existing.parentElement?.removeChild(existing)\n }\n }\n }\n\n updateConfig('themes', { ...config.themes, [themeName]: themeProxied })\n\n // trigger updates in components\n return {\n theme: themeProxied,\n cssRules,\n }\n}\n"],
5
- "mappings": "AAAA,OAAS,SAAAA,MAAa,qBACtB,OACE,uBAAAC,EACA,aAAAC,EACA,oBAAAC,EACA,uBAAAC,EACA,gBAAAC,MACK,eAGA,SAASC,EAASC,EAKtB,CAfH,IAAAC,EAgBE,MAAMC,EAASP,EAAU,EAEzB,GAAI,QAAQ,IAAI,WAAa,cAAe,CAC1C,GAAI,CAACO,EACH,MAAM,IAAI,MAAM,WAAW,EAE7B,MAAMC,EAAQD,EAAO,OAAOF,EAAM,IAAI,EACtC,GAAI,CAACA,EAAM,QAAUG,EACnB,MAAO,CAAE,MAAAA,CAAM,CAEnB,CAEA,KAAM,CAAE,KAAMC,EAAW,MAAOC,EAAS,UAAAC,CAAU,EAAIN,EACjDG,EAAQ,CAAE,GAAGE,CAAQ,EAC3B,UAAWE,KAAOJ,EAChBT,EAAoBS,EAAOI,CAAG,EAGhC,MAAMC,EAAeX,EAAoBO,EAAWD,EAAOD,EAAO,MAAM,EACxEA,EAAO,OAAOE,CAAS,EAAII,EAE3B,IAAIC,EAAqB,CAAC,EAE1B,GAAIhB,GACEa,EAAW,CACbG,EAAWb,EAAiB,CAE1B,OAAAM,EACA,UAAAE,EACA,MAAO,CAACA,CAAS,EACjB,MAAAD,CACF,CAAC,EACD,MAAMO,EAAK,iBAAiBN,IACtBO,EAAW,SAAS,cAAc,IAAID,GAAI,EAC1CE,EAAQ,SAAS,cAAc,OAAO,EAC5CA,EAAM,GAAKF,EACXE,EAAM,YAAY,SAAS,eAAeH,EAAS,KAAK;AAAA,CAAI,CAAC,CAAC,EAC9D,SAAS,KAAK,YAAYG,CAAK,EAC3BD,KACFV,EAAAU,EAAS,gBAAT,MAAAV,EAAwB,YAAYU,GAExC,CAGF,OAAAb,EAAa,SAAU,CAAE,GAAGI,EAAO,OAAQ,CAACE,CAAS,EAAGI,CAAa,CAAC,EAG/D,CACL,MAAOA,EACP,SAAAC,CACF,CACF",
6
- "names": ["isWeb", "ensureThemeVariable", "getConfig", "getThemeCSSRules", "proxyThemeToParents", "updateConfig", "addTheme", "props", "_a", "config", "theme", "themeName", "themeIn", "insertCSS", "key", "themeProxied", "cssRules", "id", "existing", "style"]
5
+ "mappings": "AAAA,SAAS,aAAa;AACtB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGA,SAAS,SAAS,OAKtB;AAfH;AAgBE,QAAM,SAAS,UAAU;AAEzB,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,MAAM,WAAW;AAAA,IAC7B;AACA,UAAMA,SAAQ,OAAO,OAAO,MAAM,IAAI;AACtC,QAAI,CAAC,MAAM,UAAUA,QAAO;AAC1B,aAAO,EAAE,OAAAA,OAAM;AAAA,IACjB;AAAA,EACF;AAEA,QAAM,EAAE,MAAM,WAAW,OAAO,SAAS,UAAU,IAAI;AACvD,QAAM,QAAQ,EAAE,GAAG,QAAQ;AAC3B,aAAW,OAAO,OAAO;AACvB,wBAAoB,OAAO,GAAG;AAAA,EAChC;AAEA,QAAM,eAAe,oBAAoB,WAAW,OAAO,OAAO,MAAM;AACxE,SAAO,OAAO,SAAS,IAAI;AAE3B,MAAI,WAAqB,CAAC;AAE1B,MAAI,OAAO;AACT,QAAI,WAAW;AACb,iBAAW,iBAAiB;AAAA;AAAA,QAE1B;AAAA,QACA;AAAA,QACA,OAAO,CAAC,SAAS;AAAA,QACjB;AAAA,MACF,CAAC;AACD,YAAM,KAAK,iBAAiB;AAC5B,YAAM,WAAW,SAAS,cAAc,IAAI,IAAI;AAChD,YAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,YAAM,KAAK;AACX,YAAM,YAAY,SAAS,eAAe,SAAS,KAAK,IAAI,CAAC,CAAC;AAC9D,eAAS,KAAK,YAAY,KAAK;AAC/B,UAAI,UAAU;AACZ,uBAAS,kBAAT,mBAAwB,YAAY;AAAA,MACtC;AAAA,IACF;AAAA,EACF;AAEA,eAAa,UAAU,EAAE,GAAG,OAAO,QAAQ,CAAC,SAAS,GAAG,aAAa,CAAC;AAGtE,SAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,EACF;AACF;",
6
+ "names": ["theme"]
7
7
  }
@@ -1,3 +1,58 @@
1
- import{isWeb as f}from"@tamagui/constants";import{ensureThemeVariable as l,getConfig as u,getThemeCSSRules as p,proxyThemeToParents as g,updateConfig as T}from"@tamagui/web";function S(m){var h;const t=u();if(process.env.NODE_ENV==="development"){if(!t)throw new Error("No config");const e=t.themes[m.name];if(!m.update&&e)return{theme:e}}const{name:n,theme:d,insertCSS:c}=m,o={...d};for(const e in o)l(o,e);const i=g(n,o,t.themes);t.themes[n]=i;let r=[];if(f&&c){r=p({config:t,themeName:n,names:[n],theme:o});const e=`t_theme_style_${n}`,s=document.querySelector(`#${e}`),a=document.createElement("style");a.id=e,a.appendChild(document.createTextNode(r.join(`
2
- `))),document.head.appendChild(a),s&&((h=s.parentElement)==null||h.removeChild(s))}return T("themes",{...t.themes,[n]:i}),{theme:i,cssRules:r}}export{S as addTheme};
1
+ import { isWeb } from "@tamagui/constants";
2
+ import {
3
+ ensureThemeVariable,
4
+ getConfig,
5
+ getThemeCSSRules,
6
+ proxyThemeToParents,
7
+ updateConfig
8
+ } from "@tamagui/web";
9
+ function addTheme(props) {
10
+ var _a;
11
+ const config = getConfig();
12
+ if (process.env.NODE_ENV === "development") {
13
+ if (!config) {
14
+ throw new Error("No config");
15
+ }
16
+ const theme2 = config.themes[props.name];
17
+ if (!props.update && theme2) {
18
+ return { theme: theme2 };
19
+ }
20
+ }
21
+ const { name: themeName, theme: themeIn, insertCSS } = props;
22
+ const theme = { ...themeIn };
23
+ for (const key in theme) {
24
+ ensureThemeVariable(theme, key);
25
+ }
26
+ const themeProxied = proxyThemeToParents(themeName, theme, config.themes);
27
+ config.themes[themeName] = themeProxied;
28
+ let cssRules = [];
29
+ if (isWeb) {
30
+ if (insertCSS) {
31
+ cssRules = getThemeCSSRules({
32
+ // @ts-ignore this works but should be fixed types
33
+ config,
34
+ themeName,
35
+ names: [themeName],
36
+ theme
37
+ });
38
+ const id = `t_theme_style_${themeName}`;
39
+ const existing = document.querySelector(`#${id}`);
40
+ const style = document.createElement("style");
41
+ style.id = id;
42
+ style.appendChild(document.createTextNode(cssRules.join("\n")));
43
+ document.head.appendChild(style);
44
+ if (existing) {
45
+ (_a = existing.parentElement) == null ? void 0 : _a.removeChild(existing);
46
+ }
47
+ }
48
+ }
49
+ updateConfig("themes", { ...config.themes, [themeName]: themeProxied });
50
+ return {
51
+ theme: themeProxied,
52
+ cssRules
53
+ };
54
+ }
55
+ export {
56
+ addTheme
57
+ };
3
58
  //# sourceMappingURL=addTheme.mjs.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/addTheme.ts"],
4
4
  "sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport {\n ensureThemeVariable,\n getConfig,\n getThemeCSSRules,\n proxyThemeToParents,\n updateConfig,\n} from '@tamagui/web'\nimport type { ThemeDefinition, ThemeParsed } from '@tamagui/web'\n\nexport function addTheme(props: {\n name: string\n theme: Partial<Record<keyof ThemeDefinition, any>>\n insertCSS?: boolean\n update?: boolean\n}) {\n const config = getConfig()\n\n if (process.env.NODE_ENV === 'development') {\n if (!config) {\n throw new Error('No config')\n }\n const theme = config.themes[props.name]\n if (!props.update && theme) {\n return { theme }\n }\n }\n\n const { name: themeName, theme: themeIn, insertCSS } = props\n const theme = { ...themeIn } as ThemeParsed\n for (const key in theme) {\n ensureThemeVariable(theme, key)\n }\n\n const themeProxied = proxyThemeToParents(themeName, theme, config.themes)\n config.themes[themeName] = themeProxied\n\n let cssRules: string[] = []\n\n if (isWeb) {\n if (insertCSS) {\n cssRules = getThemeCSSRules({\n // @ts-ignore this works but should be fixed types\n config,\n themeName,\n names: [themeName],\n theme,\n })\n const id = `t_theme_style_${themeName}`\n const existing = document.querySelector(`#${id}`)\n const style = document.createElement('style')\n style.id = id\n style.appendChild(document.createTextNode(cssRules.join('\\n')))\n document.head.appendChild(style)\n if (existing) {\n existing.parentElement?.removeChild(existing)\n }\n }\n }\n\n updateConfig('themes', { ...config.themes, [themeName]: themeProxied })\n\n // trigger updates in components\n return {\n theme: themeProxied,\n cssRules,\n }\n}\n"],
5
- "mappings": "AAAA,OAAS,SAAAA,MAAa,qBACtB,OACE,uBAAAC,EACA,aAAAC,EACA,oBAAAC,EACA,uBAAAC,EACA,gBAAAC,MACK,eAGA,SAASC,EAASC,EAKtB,CAfH,IAAAC,EAgBE,MAAMC,EAASP,EAAU,EAEzB,GAAI,QAAQ,IAAI,WAAa,cAAe,CAC1C,GAAI,CAACO,EACH,MAAM,IAAI,MAAM,WAAW,EAE7B,MAAMC,EAAQD,EAAO,OAAOF,EAAM,IAAI,EACtC,GAAI,CAACA,EAAM,QAAUG,EACnB,MAAO,CAAE,MAAAA,CAAM,CAEnB,CAEA,KAAM,CAAE,KAAMC,EAAW,MAAOC,EAAS,UAAAC,CAAU,EAAIN,EACjDG,EAAQ,CAAE,GAAGE,CAAQ,EAC3B,UAAWE,KAAOJ,EAChBT,EAAoBS,EAAOI,CAAG,EAGhC,MAAMC,EAAeX,EAAoBO,EAAWD,EAAOD,EAAO,MAAM,EACxEA,EAAO,OAAOE,CAAS,EAAII,EAE3B,IAAIC,EAAqB,CAAC,EAE1B,GAAIhB,GACEa,EAAW,CACbG,EAAWb,EAAiB,CAE1B,OAAAM,EACA,UAAAE,EACA,MAAO,CAACA,CAAS,EACjB,MAAAD,CACF,CAAC,EACD,MAAMO,EAAK,iBAAiBN,IACtBO,EAAW,SAAS,cAAc,IAAID,GAAI,EAC1CE,EAAQ,SAAS,cAAc,OAAO,EAC5CA,EAAM,GAAKF,EACXE,EAAM,YAAY,SAAS,eAAeH,EAAS,KAAK;AAAA,CAAI,CAAC,CAAC,EAC9D,SAAS,KAAK,YAAYG,CAAK,EAC3BD,KACFV,EAAAU,EAAS,gBAAT,MAAAV,EAAwB,YAAYU,GAExC,CAGF,OAAAb,EAAa,SAAU,CAAE,GAAGI,EAAO,OAAQ,CAACE,CAAS,EAAGI,CAAa,CAAC,EAG/D,CACL,MAAOA,EACP,SAAAC,CACF,CACF",
6
- "names": ["isWeb", "ensureThemeVariable", "getConfig", "getThemeCSSRules", "proxyThemeToParents", "updateConfig", "addTheme", "props", "_a", "config", "theme", "themeName", "themeIn", "insertCSS", "key", "themeProxied", "cssRules", "id", "existing", "style"]
5
+ "mappings": "AAAA,SAAS,aAAa;AACtB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGA,SAAS,SAAS,OAKtB;AAfH;AAgBE,QAAM,SAAS,UAAU;AAEzB,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,MAAM,WAAW;AAAA,IAC7B;AACA,UAAMA,SAAQ,OAAO,OAAO,MAAM,IAAI;AACtC,QAAI,CAAC,MAAM,UAAUA,QAAO;AAC1B,aAAO,EAAE,OAAAA,OAAM;AAAA,IACjB;AAAA,EACF;AAEA,QAAM,EAAE,MAAM,WAAW,OAAO,SAAS,UAAU,IAAI;AACvD,QAAM,QAAQ,EAAE,GAAG,QAAQ;AAC3B,aAAW,OAAO,OAAO;AACvB,wBAAoB,OAAO,GAAG;AAAA,EAChC;AAEA,QAAM,eAAe,oBAAoB,WAAW,OAAO,OAAO,MAAM;AACxE,SAAO,OAAO,SAAS,IAAI;AAE3B,MAAI,WAAqB,CAAC;AAE1B,MAAI,OAAO;AACT,QAAI,WAAW;AACb,iBAAW,iBAAiB;AAAA;AAAA,QAE1B;AAAA,QACA;AAAA,QACA,OAAO,CAAC,SAAS;AAAA,QACjB;AAAA,MACF,CAAC;AACD,YAAM,KAAK,iBAAiB;AAC5B,YAAM,WAAW,SAAS,cAAc,IAAI,IAAI;AAChD,YAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,YAAM,KAAK;AACX,YAAM,YAAY,SAAS,eAAe,SAAS,KAAK,IAAI,CAAC,CAAC;AAC9D,eAAS,KAAK,YAAY,KAAK;AAC/B,UAAI,UAAU;AACZ,uBAAS,kBAAT,mBAAwB,YAAY;AAAA,MACtC;AAAA,IACF;AAAA,EACF;AAEA,eAAa,UAAU,EAAE,GAAG,OAAO,QAAQ,CAAC,SAAS,GAAG,aAAa,CAAC;AAGtE,SAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,EACF;AACF;",
6
+ "names": ["theme"]
7
7
  }
package/dist/esm/index.js CHANGED
@@ -1,2 +1,3 @@
1
- export*from"./addTheme";export*from"./updateTheme";
1
+ export * from "./addTheme";
2
+ export * from "./updateTheme";
2
3
  //# sourceMappingURL=index.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
4
  "sourcesContent": ["export * from './addTheme'\nexport * from './updateTheme'\n"],
5
- "mappings": "AAAA,WAAc,aACd,WAAc",
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,3 @@
1
- export*from"./addTheme";export*from"./updateTheme";
1
+ export * from "./addTheme";
2
+ export * from "./updateTheme";
2
3
  //# sourceMappingURL=index.mjs.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
4
  "sourcesContent": ["export * from './addTheme'\nexport * from './updateTheme'\n"],
5
- "mappings": "AAAA,WAAc,aACd,WAAc",
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,23 @@
1
- import{activeThemeManagers as o}from"@tamagui/web";import{addTheme as a}from"./addTheme.js";function f({name:e,theme:r}){const t=a({name:e,theme:r,insertCSS:!0,update:!0});return process.env.TAMAGUI_TARGET==="native"&&o.forEach(i=>{i.state.name===e&&i.updateState({name:e,forceTheme:t.theme})}),t}export{f as updateTheme};
1
+ import { activeThemeManagers } from "@tamagui/web";
2
+ import { addTheme } from "./addTheme.js";
3
+ function updateTheme({
4
+ name,
5
+ theme
6
+ }) {
7
+ const next = addTheme({ name, theme, insertCSS: true, update: true });
8
+ if (process.env.TAMAGUI_TARGET === "native") {
9
+ activeThemeManagers.forEach((manager) => {
10
+ if (manager.state.name === name) {
11
+ manager.updateState({
12
+ name,
13
+ forceTheme: next.theme
14
+ });
15
+ }
16
+ });
17
+ }
18
+ return next;
19
+ }
20
+ export {
21
+ updateTheme
22
+ };
2
23
  //# sourceMappingURL=updateTheme.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/updateTheme.ts"],
4
4
  "sourcesContent": ["import { activeThemeManagers } from '@tamagui/web'\nimport type { ThemeDefinition } from '@tamagui/web'\n\nimport { addTheme } from './addTheme.js'\n\nexport function updateTheme({\n name,\n theme,\n}: {\n name: string\n theme: Partial<Record<keyof ThemeDefinition, any>>\n}) {\n const next = addTheme({ name, theme, insertCSS: true, update: true })\n\n if (process.env.TAMAGUI_TARGET === 'native') {\n activeThemeManagers.forEach((manager) => {\n if (manager.state.name === name) {\n manager.updateState({\n name,\n forceTheme: next.theme,\n })\n }\n })\n }\n\n return next\n}\n"],
5
- "mappings": "AAAA,OAAS,uBAAAA,MAA2B,eAGpC,OAAS,YAAAC,MAAgB,gBAElB,SAASC,EAAY,CAC1B,KAAAC,EACA,MAAAC,CACF,EAGG,CACD,MAAMC,EAAOJ,EAAS,CAAE,KAAAE,EAAM,MAAAC,EAAO,UAAW,GAAM,OAAQ,EAAK,CAAC,EAEpE,OAAI,QAAQ,IAAI,iBAAmB,UACjCJ,EAAoB,QAASM,GAAY,CACnCA,EAAQ,MAAM,OAASH,GACzBG,EAAQ,YAAY,CAClB,KAAAH,EACA,WAAYE,EAAK,KACnB,CAAC,CAEL,CAAC,EAGIA,CACT",
6
- "names": ["activeThemeManagers", "addTheme", "updateTheme", "name", "theme", "next", "manager"]
5
+ "mappings": "AAAA,SAAS,2BAA2B;AAGpC,SAAS,gBAAgB;AAElB,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AACF,GAGG;AACD,QAAM,OAAO,SAAS,EAAE,MAAM,OAAO,WAAW,MAAM,QAAQ,KAAK,CAAC;AAEpE,MAAI,QAAQ,IAAI,mBAAmB,UAAU;AAC3C,wBAAoB,QAAQ,CAAC,YAAY;AACvC,UAAI,QAAQ,MAAM,SAAS,MAAM;AAC/B,gBAAQ,YAAY;AAAA,UAClB;AAAA,UACA,YAAY,KAAK;AAAA,QACnB,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;",
6
+ "names": []
7
7
  }
@@ -1,2 +1,23 @@
1
- import{activeThemeManagers as o}from"@tamagui/web";import{addTheme as a}from"./addTheme.js";function f({name:e,theme:r}){const t=a({name:e,theme:r,insertCSS:!0,update:!0});return process.env.TAMAGUI_TARGET==="native"&&o.forEach(i=>{i.state.name===e&&i.updateState({name:e,forceTheme:t.theme})}),t}export{f as updateTheme};
1
+ import { activeThemeManagers } from "@tamagui/web";
2
+ import { addTheme } from "./addTheme.js";
3
+ function updateTheme({
4
+ name,
5
+ theme
6
+ }) {
7
+ const next = addTheme({ name, theme, insertCSS: true, update: true });
8
+ if (process.env.TAMAGUI_TARGET === "native") {
9
+ activeThemeManagers.forEach((manager) => {
10
+ if (manager.state.name === name) {
11
+ manager.updateState({
12
+ name,
13
+ forceTheme: next.theme
14
+ });
15
+ }
16
+ });
17
+ }
18
+ return next;
19
+ }
20
+ export {
21
+ updateTheme
22
+ };
2
23
  //# sourceMappingURL=updateTheme.mjs.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/updateTheme.ts"],
4
4
  "sourcesContent": ["import { activeThemeManagers } from '@tamagui/web'\nimport type { ThemeDefinition } from '@tamagui/web'\n\nimport { addTheme } from './addTheme.js'\n\nexport function updateTheme({\n name,\n theme,\n}: {\n name: string\n theme: Partial<Record<keyof ThemeDefinition, any>>\n}) {\n const next = addTheme({ name, theme, insertCSS: true, update: true })\n\n if (process.env.TAMAGUI_TARGET === 'native') {\n activeThemeManagers.forEach((manager) => {\n if (manager.state.name === name) {\n manager.updateState({\n name,\n forceTheme: next.theme,\n })\n }\n })\n }\n\n return next\n}\n"],
5
- "mappings": "AAAA,OAAS,uBAAAA,MAA2B,eAGpC,OAAS,YAAAC,MAAgB,gBAElB,SAASC,EAAY,CAC1B,KAAAC,EACA,MAAAC,CACF,EAGG,CACD,MAAMC,EAAOJ,EAAS,CAAE,KAAAE,EAAM,MAAAC,EAAO,UAAW,GAAM,OAAQ,EAAK,CAAC,EAEpE,OAAI,QAAQ,IAAI,iBAAmB,UACjCJ,EAAoB,QAASM,GAAY,CACnCA,EAAQ,MAAM,OAASH,GACzBG,EAAQ,YAAY,CAClB,KAAAH,EACA,WAAYE,EAAK,KACnB,CAAC,CAEL,CAAC,EAGIA,CACT",
6
- "names": ["activeThemeManagers", "addTheme", "updateTheme", "name", "theme", "next", "manager"]
5
+ "mappings": "AAAA,SAAS,2BAA2B;AAGpC,SAAS,gBAAgB;AAElB,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AACF,GAGG;AACD,QAAM,OAAO,SAAS,EAAE,MAAM,OAAO,WAAW,MAAM,QAAQ,KAAK,CAAC;AAEpE,MAAI,QAAQ,IAAI,mBAAmB,UAAU;AAC3C,wBAAoB,QAAQ,CAAC,YAAY;AACvC,UAAI,QAAQ,MAAM,SAAS,MAAM;AAC/B,gBAAQ,YAAY;AAAA,UAClB;AAAA,UACA,YAAY,KAAK;AAAA,QACnB,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;",
6
+ "names": []
7
7
  }
@@ -1,3 +1,57 @@
1
- import{isWeb as c}from"@tamagui/constants";import{ensureThemeVariable as f,getConfig as l,getThemeCSSRules as u,proxyThemeToParents as p,updateConfig as g}from"@tamagui/web";function C(m){const t=l();if(process.env.NODE_ENV==="development"){if(!t)throw new Error("No config");const e=t.themes[m.name];if(!m.update&&e)return{theme:e}}const{name:n,theme:h,insertCSS:d}=m,o={...h};for(const e in o)f(o,e);const i=p(n,o,t.themes);t.themes[n]=i;let r=[];if(c&&d){r=u({config:t,themeName:n,names:[n],theme:o});const e=`t_theme_style_${n}`,s=document.querySelector(`#${e}`),a=document.createElement("style");a.id=e,a.appendChild(document.createTextNode(r.join(`
2
- `))),document.head.appendChild(a),s&&s.parentElement?.removeChild(s)}return g("themes",{...t.themes,[n]:i}),{theme:i,cssRules:r}}export{C as addTheme};
1
+ import { isWeb } from "@tamagui/constants";
2
+ import {
3
+ ensureThemeVariable,
4
+ getConfig,
5
+ getThemeCSSRules,
6
+ proxyThemeToParents,
7
+ updateConfig
8
+ } from "@tamagui/web";
9
+ function addTheme(props) {
10
+ const config = getConfig();
11
+ if (process.env.NODE_ENV === "development") {
12
+ if (!config) {
13
+ throw new Error("No config");
14
+ }
15
+ const theme2 = config.themes[props.name];
16
+ if (!props.update && theme2) {
17
+ return { theme: theme2 };
18
+ }
19
+ }
20
+ const { name: themeName, theme: themeIn, insertCSS } = props;
21
+ const theme = { ...themeIn };
22
+ for (const key in theme) {
23
+ ensureThemeVariable(theme, key);
24
+ }
25
+ const themeProxied = proxyThemeToParents(themeName, theme, config.themes);
26
+ config.themes[themeName] = themeProxied;
27
+ let cssRules = [];
28
+ if (isWeb) {
29
+ if (insertCSS) {
30
+ cssRules = getThemeCSSRules({
31
+ // @ts-ignore this works but should be fixed types
32
+ config,
33
+ themeName,
34
+ names: [themeName],
35
+ theme
36
+ });
37
+ const id = `t_theme_style_${themeName}`;
38
+ const existing = document.querySelector(`#${id}`);
39
+ const style = document.createElement("style");
40
+ style.id = id;
41
+ style.appendChild(document.createTextNode(cssRules.join("\n")));
42
+ document.head.appendChild(style);
43
+ if (existing) {
44
+ existing.parentElement?.removeChild(existing);
45
+ }
46
+ }
47
+ }
48
+ updateConfig("themes", { ...config.themes, [themeName]: themeProxied });
49
+ return {
50
+ theme: themeProxied,
51
+ cssRules
52
+ };
53
+ }
54
+ export {
55
+ addTheme
56
+ };
3
57
  //# sourceMappingURL=addTheme.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/addTheme.ts"],
4
4
  "sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport {\n ensureThemeVariable,\n getConfig,\n getThemeCSSRules,\n proxyThemeToParents,\n updateConfig,\n} from '@tamagui/web'\nimport type { ThemeDefinition, ThemeParsed } from '@tamagui/web'\n\nexport function addTheme(props: {\n name: string\n theme: Partial<Record<keyof ThemeDefinition, any>>\n insertCSS?: boolean\n update?: boolean\n}) {\n const config = getConfig()\n\n if (process.env.NODE_ENV === 'development') {\n if (!config) {\n throw new Error('No config')\n }\n const theme = config.themes[props.name]\n if (!props.update && theme) {\n return { theme }\n }\n }\n\n const { name: themeName, theme: themeIn, insertCSS } = props\n const theme = { ...themeIn } as ThemeParsed\n for (const key in theme) {\n ensureThemeVariable(theme, key)\n }\n\n const themeProxied = proxyThemeToParents(themeName, theme, config.themes)\n config.themes[themeName] = themeProxied\n\n let cssRules: string[] = []\n\n if (isWeb) {\n if (insertCSS) {\n cssRules = getThemeCSSRules({\n // @ts-ignore this works but should be fixed types\n config,\n themeName,\n names: [themeName],\n theme,\n })\n const id = `t_theme_style_${themeName}`\n const existing = document.querySelector(`#${id}`)\n const style = document.createElement('style')\n style.id = id\n style.appendChild(document.createTextNode(cssRules.join('\\n')))\n document.head.appendChild(style)\n if (existing) {\n existing.parentElement?.removeChild(existing)\n }\n }\n }\n\n updateConfig('themes', { ...config.themes, [themeName]: themeProxied })\n\n // trigger updates in components\n return {\n theme: themeProxied,\n cssRules,\n }\n}\n"],
5
- "mappings": "AAAA,OAAS,SAAAA,MAAa,qBACtB,OACE,uBAAAC,EACA,aAAAC,EACA,oBAAAC,EACA,uBAAAC,EACA,gBAAAC,MACK,eAGA,SAASC,EAASC,EAKtB,CACD,MAAMC,EAASN,EAAU,EAEzB,GAAI,QAAQ,IAAI,WAAa,cAAe,CAC1C,GAAI,CAACM,EACH,MAAM,IAAI,MAAM,WAAW,EAE7B,MAAMC,EAAQD,EAAO,OAAOD,EAAM,IAAI,EACtC,GAAI,CAACA,EAAM,QAAUE,EACnB,MAAO,CAAE,MAAAA,CAAM,CAEnB,CAEA,KAAM,CAAE,KAAMC,EAAW,MAAOC,EAAS,UAAAC,CAAU,EAAIL,EACjDE,EAAQ,CAAE,GAAGE,CAAQ,EAC3B,UAAWE,KAAOJ,EAChBR,EAAoBQ,EAAOI,CAAG,EAGhC,MAAMC,EAAeV,EAAoBM,EAAWD,EAAOD,EAAO,MAAM,EACxEA,EAAO,OAAOE,CAAS,EAAII,EAE3B,IAAIC,EAAqB,CAAC,EAE1B,GAAIf,GACEY,EAAW,CACbG,EAAWZ,EAAiB,CAE1B,OAAAK,EACA,UAAAE,EACA,MAAO,CAACA,CAAS,EACjB,MAAAD,CACF,CAAC,EACD,MAAMO,EAAK,iBAAiBN,IACtBO,EAAW,SAAS,cAAc,IAAID,GAAI,EAC1CE,EAAQ,SAAS,cAAc,OAAO,EAC5CA,EAAM,GAAKF,EACXE,EAAM,YAAY,SAAS,eAAeH,EAAS,KAAK;AAAA,CAAI,CAAC,CAAC,EAC9D,SAAS,KAAK,YAAYG,CAAK,EAC3BD,GACFA,EAAS,eAAe,YAAYA,CAAQ,CAEhD,CAGF,OAAAZ,EAAa,SAAU,CAAE,GAAGG,EAAO,OAAQ,CAACE,CAAS,EAAGI,CAAa,CAAC,EAG/D,CACL,MAAOA,EACP,SAAAC,CACF,CACF",
6
- "names": ["isWeb", "ensureThemeVariable", "getConfig", "getThemeCSSRules", "proxyThemeToParents", "updateConfig", "addTheme", "props", "config", "theme", "themeName", "themeIn", "insertCSS", "key", "themeProxied", "cssRules", "id", "existing", "style"]
5
+ "mappings": "AAAA,SAAS,aAAa;AACtB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGA,SAAS,SAAS,OAKtB;AACD,QAAM,SAAS,UAAU;AAEzB,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,MAAM,WAAW;AAAA,IAC7B;AACA,UAAMA,SAAQ,OAAO,OAAO,MAAM,IAAI;AACtC,QAAI,CAAC,MAAM,UAAUA,QAAO;AAC1B,aAAO,EAAE,OAAAA,OAAM;AAAA,IACjB;AAAA,EACF;AAEA,QAAM,EAAE,MAAM,WAAW,OAAO,SAAS,UAAU,IAAI;AACvD,QAAM,QAAQ,EAAE,GAAG,QAAQ;AAC3B,aAAW,OAAO,OAAO;AACvB,wBAAoB,OAAO,GAAG;AAAA,EAChC;AAEA,QAAM,eAAe,oBAAoB,WAAW,OAAO,OAAO,MAAM;AACxE,SAAO,OAAO,SAAS,IAAI;AAE3B,MAAI,WAAqB,CAAC;AAE1B,MAAI,OAAO;AACT,QAAI,WAAW;AACb,iBAAW,iBAAiB;AAAA;AAAA,QAE1B;AAAA,QACA;AAAA,QACA,OAAO,CAAC,SAAS;AAAA,QACjB;AAAA,MACF,CAAC;AACD,YAAM,KAAK,iBAAiB;AAC5B,YAAM,WAAW,SAAS,cAAc,IAAI,IAAI;AAChD,YAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,YAAM,KAAK;AACX,YAAM,YAAY,SAAS,eAAe,SAAS,KAAK,IAAI,CAAC,CAAC;AAC9D,eAAS,KAAK,YAAY,KAAK;AAC/B,UAAI,UAAU;AACZ,iBAAS,eAAe,YAAY,QAAQ;AAAA,MAC9C;AAAA,IACF;AAAA,EACF;AAEA,eAAa,UAAU,EAAE,GAAG,OAAO,QAAQ,CAAC,SAAS,GAAG,aAAa,CAAC;AAGtE,SAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,EACF;AACF;",
6
+ "names": ["theme"]
7
7
  }
@@ -1,3 +1,57 @@
1
- import{isWeb as c}from"@tamagui/constants";import{ensureThemeVariable as f,getConfig as l,getThemeCSSRules as u,proxyThemeToParents as p,updateConfig as g}from"@tamagui/web";function C(m){const t=l();if(process.env.NODE_ENV==="development"){if(!t)throw new Error("No config");const e=t.themes[m.name];if(!m.update&&e)return{theme:e}}const{name:n,theme:h,insertCSS:d}=m,o={...h};for(const e in o)f(o,e);const i=p(n,o,t.themes);t.themes[n]=i;let r=[];if(c&&d){r=u({config:t,themeName:n,names:[n],theme:o});const e=`t_theme_style_${n}`,s=document.querySelector(`#${e}`),a=document.createElement("style");a.id=e,a.appendChild(document.createTextNode(r.join(`
2
- `))),document.head.appendChild(a),s&&s.parentElement?.removeChild(s)}return g("themes",{...t.themes,[n]:i}),{theme:i,cssRules:r}}export{C as addTheme};
1
+ import { isWeb } from "@tamagui/constants";
2
+ import {
3
+ ensureThemeVariable,
4
+ getConfig,
5
+ getThemeCSSRules,
6
+ proxyThemeToParents,
7
+ updateConfig
8
+ } from "@tamagui/web";
9
+ function addTheme(props) {
10
+ const config = getConfig();
11
+ if (process.env.NODE_ENV === "development") {
12
+ if (!config) {
13
+ throw new Error("No config");
14
+ }
15
+ const theme2 = config.themes[props.name];
16
+ if (!props.update && theme2) {
17
+ return { theme: theme2 };
18
+ }
19
+ }
20
+ const { name: themeName, theme: themeIn, insertCSS } = props;
21
+ const theme = { ...themeIn };
22
+ for (const key in theme) {
23
+ ensureThemeVariable(theme, key);
24
+ }
25
+ const themeProxied = proxyThemeToParents(themeName, theme, config.themes);
26
+ config.themes[themeName] = themeProxied;
27
+ let cssRules = [];
28
+ if (isWeb) {
29
+ if (insertCSS) {
30
+ cssRules = getThemeCSSRules({
31
+ // @ts-ignore this works but should be fixed types
32
+ config,
33
+ themeName,
34
+ names: [themeName],
35
+ theme
36
+ });
37
+ const id = `t_theme_style_${themeName}`;
38
+ const existing = document.querySelector(`#${id}`);
39
+ const style = document.createElement("style");
40
+ style.id = id;
41
+ style.appendChild(document.createTextNode(cssRules.join("\n")));
42
+ document.head.appendChild(style);
43
+ if (existing) {
44
+ existing.parentElement?.removeChild(existing);
45
+ }
46
+ }
47
+ }
48
+ updateConfig("themes", { ...config.themes, [themeName]: themeProxied });
49
+ return {
50
+ theme: themeProxied,
51
+ cssRules
52
+ };
53
+ }
54
+ export {
55
+ addTheme
56
+ };
3
57
  //# sourceMappingURL=addTheme.mjs.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/addTheme.ts"],
4
4
  "sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport {\n ensureThemeVariable,\n getConfig,\n getThemeCSSRules,\n proxyThemeToParents,\n updateConfig,\n} from '@tamagui/web'\nimport type { ThemeDefinition, ThemeParsed } from '@tamagui/web'\n\nexport function addTheme(props: {\n name: string\n theme: Partial<Record<keyof ThemeDefinition, any>>\n insertCSS?: boolean\n update?: boolean\n}) {\n const config = getConfig()\n\n if (process.env.NODE_ENV === 'development') {\n if (!config) {\n throw new Error('No config')\n }\n const theme = config.themes[props.name]\n if (!props.update && theme) {\n return { theme }\n }\n }\n\n const { name: themeName, theme: themeIn, insertCSS } = props\n const theme = { ...themeIn } as ThemeParsed\n for (const key in theme) {\n ensureThemeVariable(theme, key)\n }\n\n const themeProxied = proxyThemeToParents(themeName, theme, config.themes)\n config.themes[themeName] = themeProxied\n\n let cssRules: string[] = []\n\n if (isWeb) {\n if (insertCSS) {\n cssRules = getThemeCSSRules({\n // @ts-ignore this works but should be fixed types\n config,\n themeName,\n names: [themeName],\n theme,\n })\n const id = `t_theme_style_${themeName}`\n const existing = document.querySelector(`#${id}`)\n const style = document.createElement('style')\n style.id = id\n style.appendChild(document.createTextNode(cssRules.join('\\n')))\n document.head.appendChild(style)\n if (existing) {\n existing.parentElement?.removeChild(existing)\n }\n }\n }\n\n updateConfig('themes', { ...config.themes, [themeName]: themeProxied })\n\n // trigger updates in components\n return {\n theme: themeProxied,\n cssRules,\n }\n}\n"],
5
- "mappings": "AAAA,OAAS,SAAAA,MAAa,qBACtB,OACE,uBAAAC,EACA,aAAAC,EACA,oBAAAC,EACA,uBAAAC,EACA,gBAAAC,MACK,eAGA,SAASC,EAASC,EAKtB,CACD,MAAMC,EAASN,EAAU,EAEzB,GAAI,QAAQ,IAAI,WAAa,cAAe,CAC1C,GAAI,CAACM,EACH,MAAM,IAAI,MAAM,WAAW,EAE7B,MAAMC,EAAQD,EAAO,OAAOD,EAAM,IAAI,EACtC,GAAI,CAACA,EAAM,QAAUE,EACnB,MAAO,CAAE,MAAAA,CAAM,CAEnB,CAEA,KAAM,CAAE,KAAMC,EAAW,MAAOC,EAAS,UAAAC,CAAU,EAAIL,EACjDE,EAAQ,CAAE,GAAGE,CAAQ,EAC3B,UAAWE,KAAOJ,EAChBR,EAAoBQ,EAAOI,CAAG,EAGhC,MAAMC,EAAeV,EAAoBM,EAAWD,EAAOD,EAAO,MAAM,EACxEA,EAAO,OAAOE,CAAS,EAAII,EAE3B,IAAIC,EAAqB,CAAC,EAE1B,GAAIf,GACEY,EAAW,CACbG,EAAWZ,EAAiB,CAE1B,OAAAK,EACA,UAAAE,EACA,MAAO,CAACA,CAAS,EACjB,MAAAD,CACF,CAAC,EACD,MAAMO,EAAK,iBAAiBN,IACtBO,EAAW,SAAS,cAAc,IAAID,GAAI,EAC1CE,EAAQ,SAAS,cAAc,OAAO,EAC5CA,EAAM,GAAKF,EACXE,EAAM,YAAY,SAAS,eAAeH,EAAS,KAAK;AAAA,CAAI,CAAC,CAAC,EAC9D,SAAS,KAAK,YAAYG,CAAK,EAC3BD,GACFA,EAAS,eAAe,YAAYA,CAAQ,CAEhD,CAGF,OAAAZ,EAAa,SAAU,CAAE,GAAGG,EAAO,OAAQ,CAACE,CAAS,EAAGI,CAAa,CAAC,EAG/D,CACL,MAAOA,EACP,SAAAC,CACF,CACF",
6
- "names": ["isWeb", "ensureThemeVariable", "getConfig", "getThemeCSSRules", "proxyThemeToParents", "updateConfig", "addTheme", "props", "config", "theme", "themeName", "themeIn", "insertCSS", "key", "themeProxied", "cssRules", "id", "existing", "style"]
5
+ "mappings": "AAAA,SAAS,aAAa;AACtB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGA,SAAS,SAAS,OAKtB;AACD,QAAM,SAAS,UAAU;AAEzB,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,MAAM,WAAW;AAAA,IAC7B;AACA,UAAMA,SAAQ,OAAO,OAAO,MAAM,IAAI;AACtC,QAAI,CAAC,MAAM,UAAUA,QAAO;AAC1B,aAAO,EAAE,OAAAA,OAAM;AAAA,IACjB;AAAA,EACF;AAEA,QAAM,EAAE,MAAM,WAAW,OAAO,SAAS,UAAU,IAAI;AACvD,QAAM,QAAQ,EAAE,GAAG,QAAQ;AAC3B,aAAW,OAAO,OAAO;AACvB,wBAAoB,OAAO,GAAG;AAAA,EAChC;AAEA,QAAM,eAAe,oBAAoB,WAAW,OAAO,OAAO,MAAM;AACxE,SAAO,OAAO,SAAS,IAAI;AAE3B,MAAI,WAAqB,CAAC;AAE1B,MAAI,OAAO;AACT,QAAI,WAAW;AACb,iBAAW,iBAAiB;AAAA;AAAA,QAE1B;AAAA,QACA;AAAA,QACA,OAAO,CAAC,SAAS;AAAA,QACjB;AAAA,MACF,CAAC;AACD,YAAM,KAAK,iBAAiB;AAC5B,YAAM,WAAW,SAAS,cAAc,IAAI,IAAI;AAChD,YAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,YAAM,KAAK;AACX,YAAM,YAAY,SAAS,eAAe,SAAS,KAAK,IAAI,CAAC,CAAC;AAC9D,eAAS,KAAK,YAAY,KAAK;AAC/B,UAAI,UAAU;AACZ,iBAAS,eAAe,YAAY,QAAQ;AAAA,MAC9C;AAAA,IACF;AAAA,EACF;AAEA,eAAa,UAAU,EAAE,GAAG,OAAO,QAAQ,CAAC,SAAS,GAAG,aAAa,CAAC;AAGtE,SAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,EACF;AACF;",
6
+ "names": ["theme"]
7
7
  }
package/dist/jsx/index.js CHANGED
@@ -1,2 +1,3 @@
1
- export*from"./addTheme";export*from"./updateTheme";
1
+ export * from "./addTheme";
2
+ export * from "./updateTheme";
2
3
  //# sourceMappingURL=index.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
4
  "sourcesContent": ["export * from './addTheme'\nexport * from './updateTheme'\n"],
5
- "mappings": "AAAA,WAAc,aACd,WAAc",
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,3 @@
1
- export*from"./addTheme";export*from"./updateTheme";
1
+ export * from "./addTheme";
2
+ export * from "./updateTheme";
2
3
  //# sourceMappingURL=index.mjs.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
4
  "sourcesContent": ["export * from './addTheme'\nexport * from './updateTheme'\n"],
5
- "mappings": "AAAA,WAAc,aACd,WAAc",
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,23 @@
1
- import{activeThemeManagers as o}from"@tamagui/web";import{addTheme as a}from"./addTheme.js";function f({name:e,theme:r}){const t=a({name:e,theme:r,insertCSS:!0,update:!0});return process.env.TAMAGUI_TARGET==="native"&&o.forEach(i=>{i.state.name===e&&i.updateState({name:e,forceTheme:t.theme})}),t}export{f as updateTheme};
1
+ import { activeThemeManagers } from "@tamagui/web";
2
+ import { addTheme } from "./addTheme.js";
3
+ function updateTheme({
4
+ name,
5
+ theme
6
+ }) {
7
+ const next = addTheme({ name, theme, insertCSS: true, update: true });
8
+ if (process.env.TAMAGUI_TARGET === "native") {
9
+ activeThemeManagers.forEach((manager) => {
10
+ if (manager.state.name === name) {
11
+ manager.updateState({
12
+ name,
13
+ forceTheme: next.theme
14
+ });
15
+ }
16
+ });
17
+ }
18
+ return next;
19
+ }
20
+ export {
21
+ updateTheme
22
+ };
2
23
  //# sourceMappingURL=updateTheme.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/updateTheme.ts"],
4
4
  "sourcesContent": ["import { activeThemeManagers } from '@tamagui/web'\nimport type { ThemeDefinition } from '@tamagui/web'\n\nimport { addTheme } from './addTheme.js'\n\nexport function updateTheme({\n name,\n theme,\n}: {\n name: string\n theme: Partial<Record<keyof ThemeDefinition, any>>\n}) {\n const next = addTheme({ name, theme, insertCSS: true, update: true })\n\n if (process.env.TAMAGUI_TARGET === 'native') {\n activeThemeManagers.forEach((manager) => {\n if (manager.state.name === name) {\n manager.updateState({\n name,\n forceTheme: next.theme,\n })\n }\n })\n }\n\n return next\n}\n"],
5
- "mappings": "AAAA,OAAS,uBAAAA,MAA2B,eAGpC,OAAS,YAAAC,MAAgB,gBAElB,SAASC,EAAY,CAC1B,KAAAC,EACA,MAAAC,CACF,EAGG,CACD,MAAMC,EAAOJ,EAAS,CAAE,KAAAE,EAAM,MAAAC,EAAO,UAAW,GAAM,OAAQ,EAAK,CAAC,EAEpE,OAAI,QAAQ,IAAI,iBAAmB,UACjCJ,EAAoB,QAASM,GAAY,CACnCA,EAAQ,MAAM,OAASH,GACzBG,EAAQ,YAAY,CAClB,KAAAH,EACA,WAAYE,EAAK,KACnB,CAAC,CAEL,CAAC,EAGIA,CACT",
6
- "names": ["activeThemeManagers", "addTheme", "updateTheme", "name", "theme", "next", "manager"]
5
+ "mappings": "AAAA,SAAS,2BAA2B;AAGpC,SAAS,gBAAgB;AAElB,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AACF,GAGG;AACD,QAAM,OAAO,SAAS,EAAE,MAAM,OAAO,WAAW,MAAM,QAAQ,KAAK,CAAC;AAEpE,MAAI,QAAQ,IAAI,mBAAmB,UAAU;AAC3C,wBAAoB,QAAQ,CAAC,YAAY;AACvC,UAAI,QAAQ,MAAM,SAAS,MAAM;AAC/B,gBAAQ,YAAY;AAAA,UAClB;AAAA,UACA,YAAY,KAAK;AAAA,QACnB,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;",
6
+ "names": []
7
7
  }
@@ -1,2 +1,23 @@
1
- import{activeThemeManagers as o}from"@tamagui/web";import{addTheme as a}from"./addTheme.js";function f({name:e,theme:r}){const t=a({name:e,theme:r,insertCSS:!0,update:!0});return process.env.TAMAGUI_TARGET==="native"&&o.forEach(i=>{i.state.name===e&&i.updateState({name:e,forceTheme:t.theme})}),t}export{f as updateTheme};
1
+ import { activeThemeManagers } from "@tamagui/web";
2
+ import { addTheme } from "./addTheme.js";
3
+ function updateTheme({
4
+ name,
5
+ theme
6
+ }) {
7
+ const next = addTheme({ name, theme, insertCSS: true, update: true });
8
+ if (process.env.TAMAGUI_TARGET === "native") {
9
+ activeThemeManagers.forEach((manager) => {
10
+ if (manager.state.name === name) {
11
+ manager.updateState({
12
+ name,
13
+ forceTheme: next.theme
14
+ });
15
+ }
16
+ });
17
+ }
18
+ return next;
19
+ }
20
+ export {
21
+ updateTheme
22
+ };
2
23
  //# sourceMappingURL=updateTheme.mjs.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/updateTheme.ts"],
4
4
  "sourcesContent": ["import { activeThemeManagers } from '@tamagui/web'\nimport type { ThemeDefinition } from '@tamagui/web'\n\nimport { addTheme } from './addTheme.js'\n\nexport function updateTheme({\n name,\n theme,\n}: {\n name: string\n theme: Partial<Record<keyof ThemeDefinition, any>>\n}) {\n const next = addTheme({ name, theme, insertCSS: true, update: true })\n\n if (process.env.TAMAGUI_TARGET === 'native') {\n activeThemeManagers.forEach((manager) => {\n if (manager.state.name === name) {\n manager.updateState({\n name,\n forceTheme: next.theme,\n })\n }\n })\n }\n\n return next\n}\n"],
5
- "mappings": "AAAA,OAAS,uBAAAA,MAA2B,eAGpC,OAAS,YAAAC,MAAgB,gBAElB,SAASC,EAAY,CAC1B,KAAAC,EACA,MAAAC,CACF,EAGG,CACD,MAAMC,EAAOJ,EAAS,CAAE,KAAAE,EAAM,MAAAC,EAAO,UAAW,GAAM,OAAQ,EAAK,CAAC,EAEpE,OAAI,QAAQ,IAAI,iBAAmB,UACjCJ,EAAoB,QAASM,GAAY,CACnCA,EAAQ,MAAM,OAASH,GACzBG,EAAQ,YAAY,CAClB,KAAAH,EACA,WAAYE,EAAK,KACnB,CAAC,CAEL,CAAC,EAGIA,CACT",
6
- "names": ["activeThemeManagers", "addTheme", "updateTheme", "name", "theme", "next", "manager"]
5
+ "mappings": "AAAA,SAAS,2BAA2B;AAGpC,SAAS,gBAAgB;AAElB,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AACF,GAGG;AACD,QAAM,OAAO,SAAS,EAAE,MAAM,OAAO,WAAW,MAAM,QAAQ,KAAK,CAAC;AAEpE,MAAI,QAAQ,IAAI,mBAAmB,UAAU;AAC3C,wBAAoB,QAAQ,CAAC,YAAY;AACvC,UAAI,QAAQ,MAAM,SAAS,MAAM;AAC/B,gBAAQ,YAAY;AAAA,UAClB;AAAA,UACA,YAAY,KAAK;AAAA,QACnB,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;",
6
+ "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/theme",
3
- "version": "1.14.1",
3
+ "version": "1.14.2",
4
4
  "sideEffects": false,
5
5
  "source": "src/index.ts",
6
6
  "types": "./types/index.d.ts",
@@ -17,14 +17,14 @@
17
17
  "watch": "tamagui-build --watch"
18
18
  },
19
19
  "dependencies": {
20
- "@tamagui/constants": "1.14.1",
21
- "@tamagui/web": "1.14.1"
20
+ "@tamagui/constants": "1.14.2",
21
+ "@tamagui/web": "1.14.2"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": "*"
25
25
  },
26
26
  "devDependencies": {
27
- "@tamagui/build": "1.14.1",
27
+ "@tamagui/build": "1.14.2",
28
28
  "react": "^18.2.0"
29
29
  },
30
30
  "publishConfig": {