@tamagui/generate-themes 2.7.7 → 3.0.0-beta.643.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.
@@ -1,3 +1,4 @@
1
+
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -5,51 +6,40 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
5
6
  var __getProtoOf = Object.getPrototypeOf;
6
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
8
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
11
- });
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
12
13
  };
13
14
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
- get: () => from[key],
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- return to;
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
21
22
  };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
- // If the importer is in node compatibility mode or this is not an ESM
24
- // file that has been converted to a CommonJS file using a Babel-
25
- // compatible transform (i.e. "__esModule" has not been set), then set
26
- // "default" to the CommonJS "module.exports" for node compatibility.
27
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
- value: mod,
29
- enumerable: true
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
30
26
  }) : target, mod));
31
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
- value: true
33
- }), mod);
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
28
  var write_generate_themes_exports = {};
35
- __export(write_generate_themes_exports, {
36
- writeGeneratedThemes: () => writeGeneratedThemes
37
- });
29
+ __export(write_generate_themes_exports, { writeGeneratedThemes: () => writeGeneratedThemes });
38
30
  module.exports = __toCommonJS(write_generate_themes_exports);
39
31
  var fs = __toESM(require("fs-extra"), 1);
40
32
  async function writeGeneratedThemes(tamaguiDotDir, outPath, generatedOutput) {
41
- if (!generatedOutput) return;
42
- const {
43
- generated
44
- } = generatedOutput;
45
- if (process.env.DEBUG === "tamagui") {
46
- console.info(`Generated themes:`, JSON.stringify(generatedOutput, null, 2));
47
- }
48
- const newContent = `// @ts-nocheck
33
+ if (!generatedOutput) return;
34
+ const { generated } = generatedOutput;
35
+ if (process.env.DEBUG === "tamagui") {
36
+ console.info(`Generated themes:`, JSON.stringify(generatedOutput, null, 2));
37
+ }
38
+ const newContent = `// @ts-nocheck
49
39
  ` + generated;
50
- const existingContent = await fs.readFile(outPath, "utf-8").catch(() => null);
51
- if (existingContent === newContent) {
52
- return;
53
- }
54
- await fs.writeFile(outPath, newContent);
55
- }
40
+ const existingContent = await fs.readFile(outPath, "utf-8").catch(() => null);
41
+ if (existingContent === newContent) {
42
+ return;
43
+ }
44
+ await fs.writeFile(outPath, newContent);
45
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
19
+ get: () => from[key],
20
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
21
+ });
22
+ }
23
+ return to;
24
+ };
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: true
28
+ }) : target, mod));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var write_generate_themes_exports = {};
31
+ __export(write_generate_themes_exports, { writeGeneratedThemes: () => writeGeneratedThemes });
32
+ module.exports = __toCommonJS(write_generate_themes_exports);
33
+ var fs = __toESM(require("fs-extra"), 1);
34
+ async function writeGeneratedThemes(tamaguiDotDir, outPath, generatedOutput) {
35
+ if (!generatedOutput) return;
36
+ var { generated } = generatedOutput;
37
+ if (process.env.DEBUG === "tamagui") {
38
+ console.info(`Generated themes:`, JSON.stringify(generatedOutput, null, 2));
39
+ }
40
+ var newContent = `// @ts-nocheck
41
+ ` + generated;
42
+ var existingContent = await fs.readFile(outPath, "utf-8").catch(function() {
43
+ return null;
44
+ });
45
+ if (existingContent === newContent) {
46
+ return;
47
+ }
48
+ await fs.writeFile(outPath, newContent);
49
+ }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -7,54 +8,44 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
7
8
  var __getProtoOf = Object.getPrototypeOf;
8
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
10
  var __export = (target, all) => {
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: true
13
- });
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
14
15
  };
15
16
  var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
18
- get: () => from[key],
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
- });
21
- }
22
- return to;
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
19
+ get: () => from[key],
20
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
21
+ });
22
+ }
23
+ return to;
23
24
  };
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
- // If the importer is in node compatibility mode or this is not an ESM
26
- // file that has been converted to a CommonJS file using a Babel-
27
- // compatible transform (i.e. "__esModule" has not been set), then set
28
- // "default" to the CommonJS "module.exports" for node compatibility.
29
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
30
- value: mod,
31
- enumerable: true
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: true
32
28
  }) : target, mod));
33
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
34
- value: true
35
- }), mod);
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
30
  var write_generate_themes_exports = {};
37
- __export(write_generate_themes_exports, {
38
- writeGeneratedThemes: () => writeGeneratedThemes
39
- });
31
+ __export(write_generate_themes_exports, { writeGeneratedThemes: () => writeGeneratedThemes });
40
32
  module.exports = __toCommonJS(write_generate_themes_exports);
41
33
  var fs = __toESM(require("fs-extra"), 1);
42
34
  async function writeGeneratedThemes(tamaguiDotDir, outPath, generatedOutput) {
43
- if (!generatedOutput) return;
44
- var {
45
- generated
46
- } = generatedOutput;
47
- if (process.env.DEBUG === "tamagui") {
48
- console.info(`Generated themes:`, JSON.stringify(generatedOutput, null, 2));
49
- }
50
- var newContent = `// @ts-nocheck
35
+ if (!generatedOutput) return;
36
+ var { generated } = generatedOutput;
37
+ if (process.env.DEBUG === "tamagui") {
38
+ console.info(`Generated themes:`, JSON.stringify(generatedOutput, null, 2));
39
+ }
40
+ var newContent = `// @ts-nocheck
51
41
  ` + generated;
52
- var existingContent = await fs.readFile(outPath, "utf-8").catch(function () {
53
- return null;
54
- });
55
- if (existingContent === newContent) {
56
- return;
57
- }
58
- await fs.writeFile(outPath, newContent);
42
+ var existingContent = await fs.readFile(outPath, "utf-8").catch(function() {
43
+ return null;
44
+ });
45
+ if (existingContent === newContent) {
46
+ return;
47
+ }
48
+ await fs.writeFile(outPath, newContent);
59
49
  }
50
+
60
51
  //# sourceMappingURL=write-generate-themes.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","write_generate_themes_exports","writeGeneratedThemes","module","exports","fs","require","tamaguiDotDir","outPath","generatedOutput","generated","process","env","DEBUG","console","info","JSON","stringify","newContent","existingContent","readFile","catch","writeFile"],"sources":["write-generate-themes.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar write_generate_themes_exports = {};\n__export(write_generate_themes_exports, {\n writeGeneratedThemes: () => writeGeneratedThemes\n});\nmodule.exports = __toCommonJS(write_generate_themes_exports);\nvar fs = __toESM(require(\"fs-extra\"), 1);\nasync function writeGeneratedThemes(tamaguiDotDir, outPath, generatedOutput) {\n if (!generatedOutput) return;\n var { generated } = generatedOutput;\n if (process.env.DEBUG === \"tamagui\") {\n console.info(`Generated themes:`, JSON.stringify(generatedOutput, null, 2));\n }\n var newContent = `// @ts-nocheck\n` + generated;\n var existingContent = await fs.readFile(outPath, \"utf-8\").catch(function() {\n return null;\n });\n if (existingContent === newContent) {\n return;\n }\n await fs.writeFile(outPath, newContent);\n}\n//# sourceMappingURL=write-generate-themes.js.map\n"],"mappings":"AAAA,YAAY;;AACZ,IAAIA,QAAQ,GAAGC,MAAM,CAACC,MAAM;AAC5B,IAAIC,SAAS,GAAGF,MAAM,CAACG,cAAc;AACrC,IAAIC,gBAAgB,GAAGJ,MAAM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zC","ignoreList":[]}
1
+ {"version":3,"file":"write-generate-themes.native.js","names":[],"sources":["cjs/write-generate-themes.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar write_generate_themes_exports = {};\n__export(write_generate_themes_exports, {\n writeGeneratedThemes: () => writeGeneratedThemes\n});\nmodule.exports = __toCommonJS(write_generate_themes_exports);\nvar fs = __toESM(require(\"fs-extra\"), 1);\nasync function writeGeneratedThemes(tamaguiDotDir, outPath, generatedOutput) {\n if (!generatedOutput) return;\n var { generated } = generatedOutput;\n if (process.env.DEBUG === \"tamagui\") {\n console.info(`Generated themes:`, JSON.stringify(generatedOutput, null, 2));\n }\n var newContent = `// @ts-nocheck\n` + generated;\n var existingContent = await fs.readFile(outPath, \"utf-8\").catch(function() {\n return null;\n });\n if (existingContent ===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tB,IAAI,EAAE,cAAc;CACpB,IAAI,QAAQ,IAAI,UAAU,WAAW;EACnC,QAAQ,KAAK,qBAAqB,KAAK,UAAU,iBAAiB,MAAM,CAAC,CAAC;CAC5E;CACA,IAAI,aAAa;IACf;CACF,IAAI,kBAAkB,MAAM,GAAG,SAAS,SAAS,OAAO,EAAE,MAAM,WAAW;EACzE,OAAO;CACT,CAAC;CACD,IAAI,oBAAoB,YAAY;EAClC;CACF;CACA,MAAM,GAAG,UAAU,SAAS,UAAU;AACxC"}
@@ -1,69 +1,82 @@
1
+ import Module from "node:module";
1
2
  import { join } from "node:path";
3
+
4
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
5
+ if (typeof require !== "undefined") return require.apply(this, arguments);
6
+ throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
7
+ });
8
+
9
+ const ModuleInternals = Module;
2
10
  let didRegisterOnce = false;
3
11
  async function generateThemes(inputFile) {
4
- const inputFilePath = inputFile[0] === "." ? join(process.cwd(), inputFile) : inputFile;
5
- if (!didRegisterOnce) {
6
- didRegisterOnce = true;
7
- require("esbuild-register/dist/node").register({
8
- hookIgnoreNodeModules: false
9
- });
10
- } else {
11
- purgeCache(inputFilePath);
12
- }
13
- let og = process.env.TAMAGUI_KEEP_THEMES;
14
- process.env.TAMAGUI_KEEP_THEMES = "1";
15
- process.env.TAMAGUI_RUN_THEMEBUILDER = "1";
16
- try {
17
- const requiredThemes = require(inputFilePath);
18
- const themes = requiredThemes["default"] || requiredThemes["themes"] || requiredThemes[Object.keys(requiredThemes)[0]];
19
- const generatedThemes = generatedThemesToTypescript(themes);
20
- return {
21
- generated: generatedThemes
22
- };
23
- } catch (err) {
24
- console.warn(` \u26A0\uFE0F Error running theme builder:
12
+ const inputFilePath = inputFile[0] === "." ? join(process.cwd(), inputFile) : inputFile;
13
+ if (!didRegisterOnce) {
14
+ didRegisterOnce = true;
15
+ const nodeResolve = ModuleInternals._resolveFilename;
16
+ __require("esbuild-register/dist/node").register({ hookIgnoreNodeModules: false });
17
+ const chained = ModuleInternals._resolveFilename;
18
+ ModuleInternals._resolveFilename = function(request, ...args) {
19
+ if (request[0] !== "." && !request.startsWith("/")) {
20
+ try {
21
+ return nodeResolve.call(this, request, ...args);
22
+ } catch {}
23
+ }
24
+ return chained.call(this, request, ...args);
25
+ };
26
+ } else {
27
+ purgeCache(inputFilePath);
28
+ }
29
+ let og = process.env.TAMAGUI_KEEP_THEMES;
30
+ process.env.TAMAGUI_KEEP_THEMES = "1";
31
+ try {
32
+ const requiredThemes = __require(inputFilePath);
33
+ const themes = requiredThemes["default"] || requiredThemes["themes"] || requiredThemes[Object.keys(requiredThemes)[0]];
34
+ const generatedThemes = generatedThemesToTypescript(themes);
35
+ return { generated: generatedThemes };
36
+ } catch (err) {
37
+ console.warn(` \u26A0\uFE0F Error running theme builder:
25
38
  `, err?.["stack"] || err);
26
- } finally {
27
- process.env.TAMAGUI_KEEP_THEMES = og;
28
- }
39
+ } finally {
40
+ process.env.TAMAGUI_KEEP_THEMES = og;
41
+ }
29
42
  }
30
- const dedupedTokens = /* @__PURE__ */new Map();
31
43
  function generatedThemesToTypescript(themes) {
32
- const dedupedThemes = /* @__PURE__ */new Map();
33
- const dedupedThemeToNames = /* @__PURE__ */new Map();
34
- let i = 0;
35
- for (const name in themes) {
36
- i++;
37
- const theme = themes[name];
38
- let j = 0;
39
- for (const [key2, value] of Object.entries(theme)) {
40
- i++;
41
- const uniqueKey = `t${i}${j}`;
42
- if (!dedupedTokens.has(value)) {
43
- dedupedTokens.set(value, uniqueKey);
44
- }
45
- }
46
- const key = JSON.stringify(theme);
47
- if (dedupedThemes.has(key)) {
48
- dedupedThemeToNames.set(key, [...dedupedThemeToNames.get(key), name]);
49
- } else {
50
- dedupedThemes.set(key, theme);
51
- dedupedThemeToNames.set(key, [name]);
52
- }
53
- }
54
- if (!themes) {
55
- throw new Error(`Didn't find any themes exported or returned`);
56
- }
57
- const baseKeys = Object.entries(themes.light || themes[Object.keys(themes)[0]]);
58
- const baseTypeString = `export type Theme = {
44
+ const dedupedTokens = /* @__PURE__ */ new Map();
45
+ const dedupedThemes = /* @__PURE__ */ new Map();
46
+ const dedupedThemeToNames = /* @__PURE__ */ new Map();
47
+ let i = 0;
48
+ for (const name in themes) {
49
+ i++;
50
+ const theme = themes[name];
51
+ let j = 0;
52
+ for (const [key2, value] of Object.entries(theme)) {
53
+ i++;
54
+ const uniqueKey = `t${i}${j}`;
55
+ if (!dedupedTokens.has(value)) {
56
+ dedupedTokens.set(value, uniqueKey);
57
+ }
58
+ }
59
+ const key = JSON.stringify(theme);
60
+ if (dedupedThemes.has(key)) {
61
+ dedupedThemeToNames.set(key, [...dedupedThemeToNames.get(key), name]);
62
+ } else {
63
+ dedupedThemes.set(key, theme);
64
+ dedupedThemeToNames.set(key, [name]);
65
+ }
66
+ }
67
+ if (!themes) {
68
+ throw new Error(`Didn't find any themes exported or returned`);
69
+ }
70
+ const baseKeys = Object.entries(themes.light || themes[Object.keys(themes)[0]]);
71
+ const baseTypeString = `export type Theme = {
59
72
  ${baseKeys.map(([k]) => {
60
- return ` ${k}: string;
73
+ return ` ${JSON.stringify(k)}: string;
61
74
  `;
62
- }).join("")}
75
+ }).join("")}
63
76
  }`;
64
- let out = `${baseTypeString}
77
+ let out = `${baseTypeString}
65
78
  `;
66
- out += `
79
+ out += `
67
80
  function t(a: [number, number][]) {
68
81
  let res: Record<string,string> = {}
69
82
  for (const [ki, vi] of a) {
@@ -72,89 +85,91 @@ function t(a: [number, number][]) {
72
85
  return res as Theme
73
86
  }
74
87
  `;
75
- out += `export const colors = [
88
+ out += `export const colors = [
76
89
  `;
77
- let index = 0;
78
- const valueToIndex = {};
79
- dedupedTokens.forEach((name, value) => {
80
- valueToIndex[value] = index;
81
- index++;
82
- out += ` '${value}',
90
+ let index = 0;
91
+ const valueToIndex = {};
92
+ dedupedTokens.forEach((name, value) => {
93
+ valueToIndex[value] = index;
94
+ index++;
95
+ out += ` '${value}',
83
96
  `;
84
- });
85
- out += "]\n\n";
86
- const keys = baseKeys.map(([k]) => k);
87
- out += `const ks = [
97
+ });
98
+ out += "]\n\n";
99
+ const keys = baseKeys.map(([k]) => k);
100
+ out += `const ks = [
88
101
  `;
89
- out += keys.map(k => `'${k}'`).join(",\n");
90
- out += `]
102
+ out += keys.map((k) => JSON.stringify(k)).join(",\n");
103
+ out += `]
91
104
 
92
105
  `;
93
- let nameI = 0;
94
- let themeTypes = `export type ThemeNames =`;
95
- let exported = `export type Themes = Record<ThemeNames, Theme>
106
+ let nameI = 0;
107
+ let themeTypes = `export type ThemeNames =`;
108
+ let exported = `export type Themes = Record<ThemeNames, Theme>
96
109
 
97
110
  export const themes: Themes = {`;
98
- dedupedThemes.forEach(theme => {
99
- nameI++;
100
- const key = JSON.stringify(theme);
101
- const names = dedupedThemeToNames.get(key);
102
- const name = `n${nameI}`;
103
- const baseTheme = `const ${name} = ${objectToJsString(theme, keys, valueToIndex)}`;
104
- out += `
111
+ dedupedThemes.forEach((theme) => {
112
+ nameI++;
113
+ const key = JSON.stringify(theme);
114
+ const names = dedupedThemeToNames.get(key);
115
+ const name = `n${nameI}`;
116
+ const baseTheme = `const ${name} = ${objectToJsString(theme, keys, valueToIndex)}`;
117
+ out += `
105
118
  ${baseTheme}`;
106
- names.forEach(n => {
107
- exported += `
119
+ names.forEach((n) => {
120
+ exported += `
108
121
  ${n}: ${name},`;
109
- if (n.toLowerCase() === n) {
110
- themeTypes += `
122
+ if (n.toLowerCase() === n) {
123
+ themeTypes += `
111
124
  | '${n}'`;
112
- }
113
- });
114
- });
115
- out += `
125
+ }
126
+ });
127
+ });
128
+ out += `
116
129
 
117
130
  ${themeTypes}
118
131
 
119
132
  ${exported}
120
133
  }
121
134
  `;
122
- return out;
135
+ return out;
123
136
  }
124
137
  function objectToJsString(obj, keys, valueToIndex) {
125
- let arrItems = [];
126
- for (const key in obj) {
127
- const ki = keys.indexOf(key);
128
- const vi = valueToIndex[obj[key]];
129
- arrItems.push(`[${ki}, ${vi}]`);
130
- }
131
- return `t([${arrItems.join(",")}])`;
138
+ let arrItems = [];
139
+ for (const key in obj) {
140
+ const ki = keys.indexOf(key);
141
+ const vi = valueToIndex[obj[key]];
142
+ arrItems.push(`[${ki}, ${vi}]`);
143
+ }
144
+ return `t([${arrItems.join(",")}])`;
132
145
  }
133
146
  function purgeCache(moduleName) {
134
- searchCache(moduleName, mod => {
135
- delete require.cache[mod.id];
136
- });
137
- if (!module.constructor || !module.constructor._pathCache) {
138
- return;
139
- }
140
- Object.keys(module.constructor._pathCache).forEach(cacheKey => {
141
- if (cacheKey.indexOf(moduleName) > 0) {
142
- delete module.constructor._pathCache[cacheKey];
143
- }
144
- });
147
+ searchCache(moduleName, (mod) => {
148
+ delete __require.cache[mod.id];
149
+ });
150
+ const pathCache = ModuleInternals._pathCache;
151
+ if (!pathCache) {
152
+ return;
153
+ }
154
+ Object.keys(pathCache).forEach((cacheKey) => {
155
+ if (cacheKey.indexOf(moduleName) > 0) {
156
+ delete pathCache[cacheKey];
157
+ }
158
+ });
145
159
  }
146
160
  function searchCache(moduleName, callback) {
147
- let mod = require.resolve(moduleName);
148
- if (mod && (mod = require.cache[mod]) !== void 0) {
149
- ;
150
- (function traverse(mod2, depth = 0) {
151
- if (depth > 10) return;
152
- mod2.children.forEach(child => {
153
- traverse(child, depth + 1);
154
- });
155
- callback(mod2);
156
- })(mod);
157
- }
161
+ let mod = __require.resolve(moduleName);
162
+ if (mod && (mod = __require.cache[mod]) !== void 0) {
163
+ ;
164
+ (function traverse(mod2, depth = 0) {
165
+ if (depth > 10) return;
166
+ mod2.children.forEach((child) => {
167
+ traverse(child, depth + 1);
168
+ });
169
+ callback(mod2);
170
+ })(mod);
171
+ }
158
172
  }
173
+
159
174
  export { generateThemes };
160
175
  //# sourceMappingURL=generate-themes.mjs.map
@@ -1 +1 @@
1
- {"version":3,"names":["join","didRegisterOnce","generateThemes","inputFile","inputFilePath","process","cwd","require","register","hookIgnoreNodeModules","purgeCache","og","env","TAMAGUI_KEEP_THEMES","TAMAGUI_RUN_THEMEBUILDER","requiredThemes","themes","Object","keys","generatedThemes","generatedThemesToTypescript","generated","err","console","warn","dedupedTokens","Map","dedupedThemes","dedupedThemeToNames","i","name","theme","j","key","value","entries","uniqueKey","has","set","JSON","stringify","get","Error","baseKeys","light","baseTypeString","map","k","out","index","valueToIndex","forEach","nameI","themeTypes","exported","names","baseTheme","objectToJsString","n","toLowerCase","obj","arrItems","ki","indexOf","vi","push","moduleName","searchCache","mod","cache","id","module","constructor","_pathCache","cacheKey","callback","resolve","traverse","mod2","depth","children","child"],"sources":["../../src/generate-themes.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,IAAA,QAAY;AAMrB,IAAIC,eAAA,GAAkB;AAEtB,eAAsBC,eAAeC,SAAA,EAAmB;EACtD,MAAMC,aAAA,GAAgBD,SAAA,CAAU,CAAC,MAAM,MAAMH,IAAA,CAAKK,OAAA,CAAQC,GAAA,CAAI,GAAGH,SAAS,IAAIA,SAAA;EAE9E,IAAI,CAACF,eAAA,EAAiB;IACpBA,eAAA,GAAkB;IAElBM,OAAA,CAAQ,4BAA4B,EAAEC,QAAA,CAAS;MAC7CC,qBAAA,EAAuB;IACzB,CAAC;EACH,OAAO;IACLC,UAAA,CAAWN,aAAa;EAC1B;EAEA,IAAIO,EAAA,GAAKN,OAAA,CAAQO,GAAA,CAAIC,mBAAA;EACrBR,OAAA,CAAQO,GAAA,CAAIC,mBAAA,GAAsB;EAClCR,OAAA,CAAQO,GAAA,CAAIE,wBAAA,GAA2B;EAEvC,IAAI;IACF,MAAMC,cAAA,GAAiBR,OAAA,CAAQH,aAAa;IAE5C,MAAMY,MAAA,GACJD,cAAA,CAAe,SAAS,KACxBA,cAAA,CAAe,QAAQ,KACvBA,cAAA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AI,CAACC,MAAA,CAAOC,WAAA,IAAe,CAACD,MAAA,CAAOC,WAAA,CAAYC,UAAA,EAAY;IAEzD;EACF;EAKAxD,MAAA,CAAOC,IAAA,CAAKqD,MAAA,CAAOC,WAAA,CAAYC,UAAU,EAAEtB,OAAA,CAASuB,QAAA,IAAa;IAC/D,IAAIA,QAAA,CAASX,OAAA,CAAQG,UAAU,IAAI,GAAG;MAEpC,OAAOK,MAAA,CAAOC,WAAA,CAAYC,UAAA,CAAWC,QAAQ;IAC/C;EACF,CAAC;AACH;AAMA,SAASP,YAAYD,UAAA,EAAYS,QAAA,EAAU;EAEzC,IAAIP,GAAA,GAAM7D,OAAA,CAAQqE,OAAA,CAAQV,UAAU;EAKpC,IAAIE,GAAA,KAAQA,GAAA,GAAM7D,OAAA,CAAQ8D,KAAA,CAAMD,GAAG,OAAO,QAAW;IAEnD;IAAC,CAAC,SAASS,SAASC,IAAA,EAAKC,KAAA,GAAQ,GAAG;MAElC,IAAIA,KAAA,GAAQ,IAAI;MAKhBX,IAAA,CAAIY,QAAA,CAAS7B,OAAA,CAAS8B,KAAA,IAAU;QAC9BJ,QAAA,CAASI,KAAA,EAAOF,KAAA,GAAQ,CAAC;MAC3B,CAAC;MAIDJ,QAAA,CAASP,IAAG;IACd,GAAGA,GAAG;EACR;AACF","ignoreList":[]}
1
+ {"version":3,"file":"generate-themes.js","names":[],"sources":["esm/generate-themes.js"],"sourcesContent":["import Module from \"node:module\";\nimport { join } from \"node:path\";\nconst ModuleInternals = Module;\nlet didRegisterOnce = false;\nasync function generateThemes(inputFile) {\n const inputFilePath = inputFile[0] === \".\" ? join(process.cwd(), inputFile) : inputFile;\n if (!didRegisterOnce) {\n didRegisterOnce = true;\n const nodeResolve = ModuleInternals._resolveFilename;\n require(\"esbuild-register/dist/node\").register({\n hookIgnoreNodeModules: false\n });\n const chained = ModuleInternals._resolveFilename;\n ModuleInternals._resolveFilename = function(request, ...args) {\n if (request[0] !== \".\" && !request.startsWith(\"/\")) {\n try {\n return nodeResolve.call(this, request, ...args);\n } catch {\n }\n }\n return chained.call(this, request, ...args);\n };\n } else {\n purgeCache(inputFilePath);\n }\n let og = process.env.TAMAGUI_KEEP_THEMES;\n process.env.TAMAGUI_KEEP_THEMES = \"1\";\n try {\n const requiredThemes = require(inputFilePath);\n const themes = requiredThemes[\"default\"] || requiredThemes[\"themes\"] || requiredThemes[Object.keys(requiredThemes)[0]];\n const generatedThemes = generatedThemesToTypescript(themes);\n return {\n generated: generatedThemes\n };\n } catch (err) {\n console.warn(` \\u26A0\\uFE0F Error running theme builder:\n`, err?.[\"stack\"] || err);\n } finally {\n process.env.TAMAGUI_KEEP_THEMES = og;\n }\n}\nfunction generatedThemesToTypescript(themes) {\n const dedupedTokens = /* @__PURE__ */ new Map();\n const dedupedThemes = /* @__PURE__ */ new Map();\n const dedupedThemeToNames = /* @__PURE__ */ new Map();\n let i = 0;\n for (const name in themes) {\n i++;\n const theme = themes[name];\n let j = 0;\n for (const [key2, value] of Object.entries(theme)) {\n i++;\n const uniqueKey = `t${i}${j}`;\n if (!dedupedTokens.has(value)) {\n dedupedTokens.set(value, uniqueKey);\n }\n }\n const key = JSON.stringify(theme);\n if (dedupedThemes.has(key)) {\n dedupedThemeToNames.set(key, [...dedupedThemeToNames.get(key), name]);\n } else {\n dedupedThemes.set(key, theme);\n dedupedThemeToNames.set(key, [name]);\n }\n }\n if (!themes) {\n throw new Error(`Didn't find any themes exported or returned`);\n }\n const baseKeys = Object.entries(themes.light || themes[Object.keys(themes)[0]]);\n const baseTypeString = `export type Theme = {\n${baseKeys.map(([k]) => {\n return ` ${JSON.stringify(k)}: string;\n`;\n }).join(\"\")}\n}`;\n let out = `${baseTypeString}\n`;\n out += `\nfunction t(a: [number, number][]) {\n let res: Record<string,string> = {}\n for (const [ki, vi] of a) {\n res[ks[ki] as string] = colors[vi] as string\n }\n return res as Theme\n}\n`;\n out += `export const colors = [\n`;\n let index = 0;\n const valueToIndex = {};\n dedupedTokens.forEach((name, value) => {\n valueToIndex[value] = index;\n index++;\n out += ` '${value}',\n`;\n });\n out += \"]\\n\\n\";\n const keys = baseKeys.map(([k]) => k);\n out += `const ks = [\n`;\n out += keys.map((k) => JSON.stringify(k)).join(\",\\n\");\n out += `]\n\n`;\n let nameI = 0;\n let themeTypes = `export type ThemeNames =`;\n let exported = `export type Themes = Record<ThemeNames, Theme>\n\nexport const themes: Themes = {`;\n dedupedThemes.forEach((theme) => {\n nameI++;\n const key = JSON.stringify(theme);\n const names = dedupedThemeToNames.get(key);\n const name = `n${nameI}`;\n const baseTheme = `const ${name} = ${objectToJsString(theme, keys, valueToIndex)}`;\n out += `\n${baseTheme}`;\n names.forEach((n) => {\n exported += `\n ${n}: ${name},`;\n if (n.toLowerCase() === n) {\n themeTypes += `\n | '${n}'`;\n }\n });\n });\n out += `\n\n${themeTypes}\n\n${exported}\n}\n`;\n return out;\n}\nfunction objectToJsString(obj, keys, valueToIndex) {\n let arrItems = [];\n for (const key in obj) {\n const ki = keys.indexOf(key);\n const vi = valueToIndex[obj[key]];\n arrItems.push(`[${ki}, ${vi}]`);\n }\n return `t([${arrItems.join(\",\")}])`;\n}\nfunction purgeCache(moduleName) {\n searchCache(moduleName, (mod) => {\n delete require.cache[mod.id];\n });\n const pathCache = ModuleInternals._pathCache;\n if (!pathCache) {\n return;\n }\n Object.keys(pathCache).forEach((cacheKey) => {\n if (cacheKey.indexOf(moduleName) > 0) {\n delete pathCache[cacheKey];\n }\n });\n}\nfunction searchCache(moduleName, callback) {\n let mod = require.resolve(moduleName);\n if (mod && (mod = require.cache[mod]) !== void 0) {\n ;\n (function traverse(mod2, depth = 0) {\n if (depth > 10) return;\n mod2.children.forEach((child) => {\n traverse(child, depth + 1);\n });\n callback(mod2);\n })(mod);\n }\n}\nexport {\n generateThemes\n};\n//# sourceMappingURL=generate-themes.js.map\n"],"mappings":";;;;;;;;;;;AAEA,MAAM,kBAAkB;AACxB,IAAI,kBAAkB;AACtB,eAAe,eAAe,WAAW;CACvC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