@tamagui/cli 1.31.1 → 1.31.3
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.
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var generate_themes_exports = {};
|
|
31
|
+
__export(generate_themes_exports, {
|
|
32
|
+
generateThemes: () => generateThemes
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(generate_themes_exports);
|
|
35
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
36
|
+
async function generateThemes(options) {
|
|
37
|
+
require("esbuild-register/dist/node").register();
|
|
38
|
+
const requiredThemes = require(options.inPath);
|
|
39
|
+
const themes = requiredThemes["default"] || requiredThemes["themes"];
|
|
40
|
+
const generatedThemes = generatedThemesToTypescript(themes);
|
|
41
|
+
await import_fs_extra.default.writeFile(options.outPath, generatedThemes);
|
|
42
|
+
}
|
|
43
|
+
function generatedThemesToTypescript(themes) {
|
|
44
|
+
const deduped = /* @__PURE__ */ new Map();
|
|
45
|
+
const dedupedToNames = /* @__PURE__ */ new Map();
|
|
46
|
+
for (const name in themes) {
|
|
47
|
+
const theme = themes[name];
|
|
48
|
+
const key = JSON.stringify(theme);
|
|
49
|
+
if (deduped.has(key)) {
|
|
50
|
+
dedupedToNames.set(key, [...dedupedToNames.get(key), name]);
|
|
51
|
+
} else {
|
|
52
|
+
deduped.set(key, theme);
|
|
53
|
+
dedupedToNames.set(key, [name]);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const baseTypeString = `type Theme = {
|
|
57
|
+
${Object.entries(themes.light || themes[Object.keys(themes)[0]]).map(([k]) => {
|
|
58
|
+
return ` ${k}: string;
|
|
59
|
+
`;
|
|
60
|
+
}).join("")}
|
|
61
|
+
}`;
|
|
62
|
+
let themesString = `${baseTypeString}
|
|
63
|
+
`;
|
|
64
|
+
deduped.forEach((theme) => {
|
|
65
|
+
const key = JSON.stringify(theme);
|
|
66
|
+
const [baseName, ...restNames] = dedupedToNames.get(key);
|
|
67
|
+
const baseTheme = `export const ${baseName} = ${objectToJsString(theme)} as Theme`;
|
|
68
|
+
themesString += `
|
|
69
|
+
${baseTheme}`;
|
|
70
|
+
if (restNames.length) {
|
|
71
|
+
const duplicateThemes = restNames.map(
|
|
72
|
+
(name) => `export const ${name} = ${baseName} as Theme`
|
|
73
|
+
);
|
|
74
|
+
themesString += `
|
|
75
|
+
|
|
76
|
+
` + duplicateThemes.join("\n");
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return themesString;
|
|
80
|
+
}
|
|
81
|
+
function objectToJsString(obj, indent = 4) {
|
|
82
|
+
const whitespace = new Array(indent).fill(" ").join("");
|
|
83
|
+
return `{
|
|
84
|
+
${Object.entries(obj).map(([k, v]) => `${whitespace}${k}: '${v}'`).join(",\n")}
|
|
85
|
+
}`;
|
|
86
|
+
}
|
|
87
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
88
|
+
0 && (module.exports = {
|
|
89
|
+
generateThemes
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=generate-themes.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/generate-themes.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAe;AAEf,eAAsB,eACpB,SAIA;AACA,UAAQ,4BAA4B,EAAE,SAAS;AAC/C,QAAM,iBAAiB,QAAQ,QAAQ,MAAM;AAC7C,QAAM,SAAS,eAAe,SAAS,KAAK,eAAe,QAAQ;AACnE,QAAM,kBAAkB,4BAA4B,MAAM;AAC1D,QAAM,gBAAAA,QAAG,UAAU,QAAQ,SAAS,eAAe;AACrD;AAEA,SAAS,4BAA4B,QAA6B;AAChE,QAAM,UAAU,oBAAI,IAAoB;AACxC,QAAM,iBAAiB,oBAAI,IAAsB;AAEjD,aAAW,QAAQ,QAAQ;AACzB,UAAM,QAAQ,OAAO,IAAI;AACzB,UAAM,MAAM,KAAK,UAAU,KAAK;AAChC,QAAI,QAAQ,IAAI,GAAG,GAAG;AACpB,qBAAe,IAAI,KAAK,CAAC,GAAG,eAAe,IAAI,GAAG,GAAI,IAAI,CAAC;AAAA,IAC7D,OAAO;AACL,cAAQ,IAAI,KAAK,KAAK;AACtB,qBAAe,IAAI,KAAK,CAAC,IAAI,CAAC;AAAA,IAChC;AAAA,EACF;AAEA,QAAM,iBAAiB;AAAA,EACvB,OAAO,QAAQ,OAAO,SAAS,OAAO,OAAO,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,EAC5D,IAAI,CAAC,CAAC,CAAC,MAAM;AACZ,WAAO,KAAK;AAAA;AAAA,EACd,CAAC,EACA,KAAK,EAAE;AAAA;AAGR,MAAI,eAAe,GAAG;AAAA;AAEtB,UAAQ,QAAQ,CAAC,UAAU;AACzB,UAAM,MAAM,KAAK,UAAU,KAAK;AAChC,UAAM,CAAC,UAAU,GAAG,SAAS,IAAI,eAAe,IAAI,GAAG;AACvD,UAAM,YAAY,gBAAgB,cAAc,iBAAiB,KAAK;AACtE,oBAAgB;AAAA,EAAK;AAErB,QAAI,UAAU,QAAQ;AACpB,YAAM,kBAAkB,UAAU;AAAA,QAChC,CAAC,SAAS,gBAAgB,UAAU;AAAA,MACtC;AACA,sBAAgB;AAAA;AAAA,IAAS,gBAAgB,KAAK,IAAI;AAAA,IACpD;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAEA,SAAS,iBAAiB,KAAa,SAAS,GAAG;AACjD,QAAM,aAAa,IAAI,MAAM,MAAM,EAAE,KAAK,GAAG,EAAE,KAAK,EAAE;AACtD,SAAO;AAAA,EACP,OAAO,QAAQ,GAAG,EACjB,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,aAAa,OAAO,IAAI,EAC3C,KAAK,KAAK;AAAA;AAEb;",
|
|
5
|
+
"names": ["fs"]
|
|
6
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
async function generateThemes(options) {
|
|
4
|
+
require("esbuild-register/dist/node").register();
|
|
5
|
+
const requiredThemes = require(options.inPath);
|
|
6
|
+
const themes = requiredThemes["default"] || requiredThemes["themes"];
|
|
7
|
+
const generatedThemes = generatedThemesToTypescript(themes);
|
|
8
|
+
await fs.writeFile(options.outPath, generatedThemes);
|
|
9
|
+
}
|
|
10
|
+
function generatedThemesToTypescript(themes) {
|
|
11
|
+
const deduped = /* @__PURE__ */ new Map();
|
|
12
|
+
const dedupedToNames = /* @__PURE__ */ new Map();
|
|
13
|
+
for (const name in themes) {
|
|
14
|
+
const theme = themes[name];
|
|
15
|
+
const key = JSON.stringify(theme);
|
|
16
|
+
if (deduped.has(key)) {
|
|
17
|
+
dedupedToNames.set(key, [...dedupedToNames.get(key), name]);
|
|
18
|
+
} else {
|
|
19
|
+
deduped.set(key, theme);
|
|
20
|
+
dedupedToNames.set(key, [name]);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const baseTypeString = `type Theme = {
|
|
24
|
+
${Object.entries(themes.light || themes[Object.keys(themes)[0]]).map(([k]) => {
|
|
25
|
+
return ` ${k}: string;
|
|
26
|
+
`;
|
|
27
|
+
}).join("")}
|
|
28
|
+
}`;
|
|
29
|
+
let themesString = `${baseTypeString}
|
|
30
|
+
`;
|
|
31
|
+
deduped.forEach((theme) => {
|
|
32
|
+
const key = JSON.stringify(theme);
|
|
33
|
+
const [baseName, ...restNames] = dedupedToNames.get(key);
|
|
34
|
+
const baseTheme = `export const ${baseName} = ${objectToJsString(theme)} as Theme`;
|
|
35
|
+
themesString += `
|
|
36
|
+
${baseTheme}`;
|
|
37
|
+
if (restNames.length) {
|
|
38
|
+
const duplicateThemes = restNames.map(
|
|
39
|
+
(name) => `export const ${name} = ${baseName} as Theme`
|
|
40
|
+
);
|
|
41
|
+
themesString += `
|
|
42
|
+
|
|
43
|
+
` + duplicateThemes.join("\n");
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return themesString;
|
|
47
|
+
}
|
|
48
|
+
function objectToJsString(obj, indent = 4) {
|
|
49
|
+
const whitespace = new Array(indent).fill(" ").join("");
|
|
50
|
+
return `{
|
|
51
|
+
${Object.entries(obj).map(([k, v]) => `${whitespace}${k}: '${v}'`).join(",\n")}
|
|
52
|
+
}`;
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
generateThemes
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=generate-themes.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/generate-themes.ts"],
|
|
4
|
+
"mappings": ";AAGA,OAAO,QAAQ;AAEf,eAAsB,eACpB,SAIA;AACA,UAAQ,4BAA4B,EAAE,SAAS;AAC/C,QAAM,iBAAiB,QAAQ,QAAQ,MAAM;AAC7C,QAAM,SAAS,eAAe,SAAS,KAAK,eAAe,QAAQ;AACnE,QAAM,kBAAkB,4BAA4B,MAAM;AAC1D,QAAM,GAAG,UAAU,QAAQ,SAAS,eAAe;AACrD;AAEA,SAAS,4BAA4B,QAA6B;AAChE,QAAM,UAAU,oBAAI,IAAoB;AACxC,QAAM,iBAAiB,oBAAI,IAAsB;AAEjD,aAAW,QAAQ,QAAQ;AACzB,UAAM,QAAQ,OAAO,IAAI;AACzB,UAAM,MAAM,KAAK,UAAU,KAAK;AAChC,QAAI,QAAQ,IAAI,GAAG,GAAG;AACpB,qBAAe,IAAI,KAAK,CAAC,GAAG,eAAe,IAAI,GAAG,GAAI,IAAI,CAAC;AAAA,IAC7D,OAAO;AACL,cAAQ,IAAI,KAAK,KAAK;AACtB,qBAAe,IAAI,KAAK,CAAC,IAAI,CAAC;AAAA,IAChC;AAAA,EACF;AAEA,QAAM,iBAAiB;AAAA,EACvB,OAAO,QAAQ,OAAO,SAAS,OAAO,OAAO,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,EAC5D,IAAI,CAAC,CAAC,CAAC,MAAM;AACZ,WAAO,KAAK;AAAA;AAAA,EACd,CAAC,EACA,KAAK,EAAE;AAAA;AAGR,MAAI,eAAe,GAAG;AAAA;AAEtB,UAAQ,QAAQ,CAAC,UAAU;AACzB,UAAM,MAAM,KAAK,UAAU,KAAK;AAChC,UAAM,CAAC,UAAU,GAAG,SAAS,IAAI,eAAe,IAAI,GAAG;AACvD,UAAM,YAAY,gBAAgB,cAAc,iBAAiB,KAAK;AACtE,oBAAgB;AAAA,EAAK;AAErB,QAAI,UAAU,QAAQ;AACpB,YAAM,kBAAkB,UAAU;AAAA,QAChC,CAAC,SAAS,gBAAgB,UAAU;AAAA,MACtC;AACA,sBAAgB;AAAA;AAAA,IAAS,gBAAgB,KAAK,IAAI;AAAA,IACpD;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAEA,SAAS,iBAAiB,KAAa,SAAS,GAAG;AACjD,QAAM,aAAa,IAAI,MAAM,MAAM,EAAE,KAAK,GAAG,EAAE,KAAK,EAAE;AACtD,SAAO;AAAA,EACP,OAAO,QAAQ,GAAG,EACjB,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,aAAa,OAAO,IAAI,EAC3C,KAAK,KAAK;AAAA;AAEb;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/cli",
|
|
3
|
-
"version": "1.31.
|
|
3
|
+
"version": "1.31.3",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"@callstack/repack-debugger-app": "^1.0.0",
|
|
37
37
|
"@fastify/sensible": "^4.1.0",
|
|
38
38
|
"@fastify/static": "^5.0.2",
|
|
39
|
-
"@tamagui/build": "1.31.
|
|
40
|
-
"@tamagui/static": "1.31.
|
|
41
|
-
"@tamagui/types": "1.31.
|
|
42
|
-
"@tamagui/vite-plugin": "1.31.
|
|
39
|
+
"@tamagui/build": "1.31.3",
|
|
40
|
+
"@tamagui/static": "1.31.3",
|
|
41
|
+
"@tamagui/types": "1.31.3",
|
|
42
|
+
"@tamagui/vite-plugin": "1.31.3",
|
|
43
43
|
"@types/compression": "^1.7.2",
|
|
44
44
|
"@types/morgan": "^1.9.3",
|
|
45
45
|
"@vitejs/plugin-react-swc": "^3.3.0",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-themes.d.ts","sourceRoot":"","sources":["../src/generate-themes.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAGnD,wBAAsB,cAAc,CAClC,OAAO,EAAE,kBAAkB,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;CAChB,iBAOF"}
|