@tamagui/cli 1.0.1-rc.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/build.js +81 -0
- package/dist/cjs/build.js.map +7 -0
- package/dist/cjs/cli.js +94 -0
- package/dist/cjs/cli.js.map +7 -0
- package/dist/cjs/create.js +2 -0
- package/dist/cjs/create.js.map +7 -0
- package/dist/cjs/dev.js +75 -0
- package/dist/cjs/dev.js.map +7 -0
- package/dist/cjs/generate.js +77 -0
- package/dist/cjs/generate.js.map +7 -0
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/studio.js +85 -0
- package/dist/cjs/studio.js.map +7 -0
- package/dist/cjs/tamaguiConfigUtils.js +95 -0
- package/dist/cjs/tamaguiConfigUtils.js.map +7 -0
- package/dist/cjs/test.js +39 -0
- package/dist/cjs/test.js.map +7 -0
- package/dist/cjs/types.js +17 -0
- package/dist/cjs/types.js.map +7 -0
- package/dist/cjs/utils.js +110 -0
- package/dist/cjs/utils.js.map +7 -0
- package/dist/esm/build.js +50 -0
- package/dist/esm/build.js.map +7 -0
- package/dist/esm/cli.js +75 -0
- package/dist/esm/cli.js.map +7 -0
- package/dist/esm/create.js +1 -0
- package/dist/esm/create.js.map +7 -0
- package/dist/esm/dev.js +45 -0
- package/dist/esm/dev.js.map +7 -0
- package/dist/esm/generate.js +46 -0
- package/dist/esm/generate.js.map +7 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/studio.js +54 -0
- package/dist/esm/studio.js.map +7 -0
- package/dist/esm/tamaguiConfigUtils.js +64 -0
- package/dist/esm/tamaguiConfigUtils.js.map +7 -0
- package/dist/esm/test.js +9 -0
- package/dist/esm/test.js.map +7 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +7 -0
- package/dist/esm/utils.js +77 -0
- package/dist/esm/utils.js.map +7 -0
- package/package.json +62 -0
- package/src/build.ts +63 -0
- package/src/cli.ts +153 -0
- package/src/create.ts +0 -0
- package/src/dev.ts +60 -0
- package/src/generate.ts +69 -0
- package/src/index.ts +3 -0
- package/src/studio.ts +69 -0
- package/src/tamaguiConfigUtils.ts +85 -0
- package/src/test.ts +12 -0
- package/src/types.ts +30 -0
- package/src/utils.ts +80 -0
- package/types/build.d.ts +3 -0
- package/types/cli.d.ts +2 -0
- package/types/create.d.ts +1 -0
- package/types/dev.d.ts +3 -0
- package/types/generate.d.ts +7 -0
- package/types/index.d.ts +3 -0
- package/types/studio.d.ts +3 -0
- package/types/tamagui-config.d.ts +5 -0
- package/types/tamaguiConfigUtils.d.ts +5 -0
- package/types/test.d.ts +3 -0
- package/types/types.d.ts +29 -0
- package/types/utils.d.ts +8 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var build_exports = {};
|
|
26
|
+
__export(build_exports, {
|
|
27
|
+
build: () => build
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(build_exports);
|
|
30
|
+
var import_path = require("path");
|
|
31
|
+
var import_static = require("@tamagui/static");
|
|
32
|
+
var import_chokidar = __toESM(require("chokidar"));
|
|
33
|
+
var import_fs_extra = require("fs-extra");
|
|
34
|
+
const build = async (options) => {
|
|
35
|
+
const entry = options.pkgJson.source;
|
|
36
|
+
if (!entry) {
|
|
37
|
+
throw new Error(`Must add "source" to package.json pointing to your source directory`);
|
|
38
|
+
}
|
|
39
|
+
const sourceDir = (0, import_path.dirname)(entry);
|
|
40
|
+
const promises = [];
|
|
41
|
+
const targets = ["web"];
|
|
42
|
+
await new Promise((res) => {
|
|
43
|
+
import_chokidar.default.watch(sourceDir, {}).on("add", (relativePath) => {
|
|
44
|
+
const sourcePath = (0, import_path.resolve)(process.cwd(), relativePath);
|
|
45
|
+
if (!sourcePath.endsWith("Layouts.tsx"))
|
|
46
|
+
return;
|
|
47
|
+
promises.push(
|
|
48
|
+
(async () => {
|
|
49
|
+
await Promise.all(
|
|
50
|
+
targets.map(async (target) => {
|
|
51
|
+
var _a;
|
|
52
|
+
process.env.TAMAGUI_TARGET = target;
|
|
53
|
+
if (options.debug) {
|
|
54
|
+
(_a = process.env).NODE_ENV || (_a.NODE_ENV = "development");
|
|
55
|
+
}
|
|
56
|
+
console.log("go", sourcePath);
|
|
57
|
+
const source = await (0, import_fs_extra.readFile)(sourcePath, "utf-8");
|
|
58
|
+
const extractor = (0, import_static.createExtractor)();
|
|
59
|
+
const out = await (0, import_static.extractToClassNames)({
|
|
60
|
+
extractor,
|
|
61
|
+
source,
|
|
62
|
+
sourcePath,
|
|
63
|
+
options: options.tamaguiOptions,
|
|
64
|
+
shouldPrintDebug: options.debug || false
|
|
65
|
+
});
|
|
66
|
+
console.log("gotem", out == null ? void 0 : out.js);
|
|
67
|
+
})
|
|
68
|
+
);
|
|
69
|
+
})()
|
|
70
|
+
);
|
|
71
|
+
}).on("ready", () => {
|
|
72
|
+
res();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
await Promise.all(promises);
|
|
76
|
+
};
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
build
|
|
80
|
+
});
|
|
81
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/build.ts"],
|
|
4
|
+
"sourcesContent": ["import { basename, dirname, join, resolve } from 'path'\n\nimport { createExtractor, extractToClassNames, loadTamagui } from '@tamagui/static'\nimport chokidar from 'chokidar'\nimport { readFile } from 'fs-extra'\n\nimport { ResolvedOptions } from './types.js'\n\nexport const build = async (options: ResolvedOptions) => {\n // const tamagui = await loadTamagui(options.tamaguiOptions)\n\n const entry = options.pkgJson.source\n if (!entry) {\n throw new Error(`Must add \"source\" to package.json pointing to your source directory`)\n }\n const sourceDir = dirname(entry)\n const promises: Promise<void>[] = []\n const targets = ['web']\n\n await new Promise<void>((res) => {\n chokidar\n // prevent infinite loop but cause race condition if you just build directly\n .watch(sourceDir, {\n // persistent: true,\n })\n .on('add', (relativePath) => {\n const sourcePath = resolve(process.cwd(), relativePath)\n\n // testing..\n if (!sourcePath.endsWith('Layouts.tsx')) return\n\n promises.push(\n (async () => {\n await Promise.all(\n targets.map(async (target) => {\n process.env.TAMAGUI_TARGET = target\n if (options.debug) {\n process.env.NODE_ENV ||= 'development'\n }\n console.log('go', sourcePath)\n const source = await readFile(sourcePath, 'utf-8')\n const extractor = createExtractor()\n const out = await extractToClassNames({\n extractor,\n source,\n sourcePath,\n options: options.tamaguiOptions,\n shouldPrintDebug: options.debug || false,\n })\n\n console.log('gotem', out?.js)\n })\n )\n })()\n )\n })\n .on('ready', () => {\n res()\n })\n })\n\n await Promise.all(promises)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiD;AAEjD,oBAAkE;AAClE,sBAAqB;AACrB,sBAAyB;AAIlB,MAAM,QAAQ,OAAO,YAA6B;AAGvD,QAAM,QAAQ,QAAQ,QAAQ;AAC9B,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,MAAM,qEAAqE;AAAA,EACvF;AACA,QAAM,gBAAY,qBAAQ,KAAK;AAC/B,QAAM,WAA4B,CAAC;AACnC,QAAM,UAAU,CAAC,KAAK;AAEtB,QAAM,IAAI,QAAc,CAAC,QAAQ;AAC/B,oBAAAA,QAEG,MAAM,WAAW,CAElB,CAAC,EACA,GAAG,OAAO,CAAC,iBAAiB;AAC3B,YAAM,iBAAa,qBAAQ,QAAQ,IAAI,GAAG,YAAY;AAGtD,UAAI,CAAC,WAAW,SAAS,aAAa;AAAG;AAEzC,eAAS;AAAA,SACN,YAAY;AACX,gBAAM,QAAQ;AAAA,YACZ,QAAQ,IAAI,OAAO,WAAW;AAlC5C;AAmCgB,sBAAQ,IAAI,iBAAiB;AAC7B,kBAAI,QAAQ,OAAO;AACjB,8BAAQ,KAAI,aAAZ,GAAY,WAAa;AAAA,cAC3B;AACA,sBAAQ,IAAI,MAAM,UAAU;AAC5B,oBAAM,SAAS,UAAM,0BAAS,YAAY,OAAO;AACjD,oBAAM,gBAAY,+BAAgB;AAClC,oBAAM,MAAM,UAAM,mCAAoB;AAAA,gBACpC;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA,SAAS,QAAQ;AAAA,gBACjB,kBAAkB,QAAQ,SAAS;AAAA,cACrC,CAAC;AAED,sBAAQ,IAAI,SAAS,2BAAK,EAAE;AAAA,YAC9B,CAAC;AAAA,UACH;AAAA,QACF,GAAG;AAAA,MACL;AAAA,IACF,CAAC,EACA,GAAG,SAAS,MAAM;AACjB,UAAI;AAAA,IACN,CAAC;AAAA,EACL,CAAC;AAED,QAAM,QAAQ,IAAI,QAAQ;AAC5B;",
|
|
6
|
+
"names": ["chokidar"]
|
|
7
|
+
}
|
package/dist/cjs/cli.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
18
|
+
mod
|
|
19
|
+
));
|
|
20
|
+
var import_arg = __toESM(require("arg"));
|
|
21
|
+
var import_chalk = __toESM(require("chalk"));
|
|
22
|
+
var import_utils = require("./utils.js");
|
|
23
|
+
const commandMap = {
|
|
24
|
+
build: {
|
|
25
|
+
shorthands: ["b"],
|
|
26
|
+
description: `Use to pre-build a Tamagui component directory`,
|
|
27
|
+
flags: {
|
|
28
|
+
"--help": Boolean,
|
|
29
|
+
"--debug": Boolean,
|
|
30
|
+
"--verbose": Boolean
|
|
31
|
+
},
|
|
32
|
+
async run() {
|
|
33
|
+
const { _, ...flags2 } = (0, import_arg.default)(this.flags);
|
|
34
|
+
const { build } = await import("./build.js");
|
|
35
|
+
const options = await (0, import_utils.getOptions)({
|
|
36
|
+
debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : true : false
|
|
37
|
+
});
|
|
38
|
+
await build(options);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const commandEntries = Object.keys(commandMap).flatMap((command2) => {
|
|
43
|
+
const definition2 = commandMap[command2];
|
|
44
|
+
const entries = [command2, ...definition2.shorthands].map((cmd) => {
|
|
45
|
+
return [cmd, definition2];
|
|
46
|
+
});
|
|
47
|
+
return entries;
|
|
48
|
+
});
|
|
49
|
+
const commands = Object.fromEntries(commandEntries);
|
|
50
|
+
const {
|
|
51
|
+
_: [command],
|
|
52
|
+
...flags
|
|
53
|
+
} = (0, import_arg.default)(
|
|
54
|
+
{
|
|
55
|
+
"--help": Boolean,
|
|
56
|
+
"--version": Boolean
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
permissive: true
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
if (flags["--version"]) {
|
|
63
|
+
console.log(require("../package.json").version);
|
|
64
|
+
process.exit(0);
|
|
65
|
+
}
|
|
66
|
+
if (!command && flags["--help"]) {
|
|
67
|
+
console.log(`$ tamagui
|
|
68
|
+
|
|
69
|
+
commands:
|
|
70
|
+
|
|
71
|
+
${Object.keys(commandMap).map((key) => {
|
|
72
|
+
return ` ${key}`;
|
|
73
|
+
}).join("\n")}`);
|
|
74
|
+
process.exit(0);
|
|
75
|
+
}
|
|
76
|
+
if (!(command in commands)) {
|
|
77
|
+
console.error();
|
|
78
|
+
console.warn(import_chalk.default.yellow(`Not a valid command: ${command}`));
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
const definition = commands[command];
|
|
82
|
+
main();
|
|
83
|
+
async function main() {
|
|
84
|
+
if (flags["--help"]) {
|
|
85
|
+
console.log(`
|
|
86
|
+
$ tamagui ${command}: ${definition.description}
|
|
87
|
+
`);
|
|
88
|
+
console.log(`Flags: ${Object.entries(definition.flags).map(([k, v]) => `${k} (${v.name})`)}`);
|
|
89
|
+
process.exit(0);
|
|
90
|
+
}
|
|
91
|
+
await definition.run();
|
|
92
|
+
process.exit(0);
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/cli.ts"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable no-console */\nimport arg from 'arg'\nimport chalk from 'chalk'\n\nimport { getOptions } from './utils.js'\n\nconst commandMap = {\n build: {\n shorthands: ['b'],\n description: `Use to pre-build a Tamagui component directory`,\n flags: {\n '--help': Boolean,\n '--debug': Boolean,\n '--verbose': Boolean,\n },\n async run() {\n const { _, ...flags } = arg(this.flags)\n const { build } = await import('./build.js')\n const options = await getOptions({\n debug: flags['--debug'] ? (flags['--verbose'] ? 'verbose' : true) : false,\n })\n await build(options)\n },\n },\n}\n\ntype CommandDefinitions = typeof commandMap\ntype CommandKey = keyof typeof commandMap\ntype CommandDefinition = CommandDefinitions[CommandKey]\n\nconst commandEntries = Object.keys(commandMap).flatMap((command) => {\n const definition = commandMap[command as CommandKey]\n const entries = [command, ...definition.shorthands].map((cmd) => {\n return [cmd, definition] as const\n })\n return entries\n})\n\nconst commands = Object.fromEntries(commandEntries) as any as Record<CommandKey, CommandDefinition>\n\nconst {\n _: [command],\n ...flags\n} = arg(\n {\n '--help': Boolean,\n '--version': Boolean,\n },\n {\n permissive: true,\n }\n)\n\nif (flags['--version']) {\n console.log(require('../package.json').version)\n process.exit(0)\n}\n\nif (!command && flags['--help']) {\n console.log(`$ tamagui\n\ncommands:\n\n${Object.keys(commandMap)\n .map((key) => {\n return ` ${key}`\n })\n .join('\\n')}`)\n process.exit(0)\n}\n\nif (!(command in commands)) {\n console.error()\n console.warn(chalk.yellow(`Not a valid command: ${command}`))\n process.exit(1)\n}\n\nconst definition = commands[command] as CommandDefinition\n\nmain()\n\nasync function main() {\n if (flags['--help']) {\n console.log(`\\n$ tamagui ${command}: ${definition.description}\\n`)\n console.log(`Flags: ${Object.entries(definition.flags).map(([k, v]) => `${k} (${v.name})`)}`)\n process.exit(0)\n }\n\n await definition.run()\n process.exit(0)\n}\n\n// async function main() {\n// const options = await getOptions({\n// host: flags['--host'],\n// })\n\n// switch (command) {\n// // build\n// case 'b':\n// case 'build': {\n// const { build } = await import('./build.js')\n// break\n// }\n\n// // generate\n// case 'generate':\n// case 'gen': {\n// const { generateTamaguiConfig: generateTamgauiConfig } = await import(\n// './tamaguiConfigUtils.js'\n// )\n// const { generateTypes } = await import('./generate.js')\n\n// if (props[0] === 'types') {\n// await generateTypes(options)\n// return\n// }\n// if (props[0] === 'config') {\n// await generateTamgauiConfig(options)\n// return\n// }\n\n// await Promise.all([\n// // all\n// generateTypes(options),\n// generateTamgauiConfig(options),\n// ])\n// break\n// }\n\n// // studio\n// case 'studio': {\n// const { studio } = await import('./studio.js')\n// await studio(options)\n// break\n// }\n\n// // for now, dev === serve, eventually serve can be just prod mode\n// case 'dev': {\n// const { dev } = await import('./dev.js')\n// await dev(options)\n// break\n// }\n\n// default: {\n// if (!command || flags['--help']) {\n// }\n// // eslint-disable-next-line no-console\n// console.warn(chalk.yellow(`No command found ${command}`))\n// process.exit(1)\n// }\n// }\n// }\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AACA,iBAAgB;AAChB,mBAAkB;AAElB,mBAA2B;AAE3B,MAAM,aAAa;AAAA,EACjB,OAAO;AAAA,IACL,YAAY,CAAC,GAAG;AAAA,IAChB,aAAa;AAAA,IACb,OAAO;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,MACX,aAAa;AAAA,IACf;AAAA,IACA,MAAM,MAA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,MAAI,MAAM,WAAW;AACnB,YAAQ,IAAI;AAAA,YAAe,YAAY,WAAW;AAAA,CAAe;AACjE,YAAQ,IAAI,UAAU,OAAO,QAAQ,WAAW,KAAK,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,GAAG;AAC5F,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,WAAW,IAAI;AACrB,UAAQ,KAAK,CAAC;AAChB;",
|
|
6
|
+
"names": ["flags", "arg", "command", "definition", "chalk"]
|
|
7
|
+
}
|
package/dist/cjs/dev.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var dev_exports = {};
|
|
26
|
+
__export(dev_exports, {
|
|
27
|
+
dev: () => dev
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(dev_exports);
|
|
30
|
+
var import_chalk = __toESM(require("chalk"));
|
|
31
|
+
var import_express = __toESM(require("express"));
|
|
32
|
+
var import_express_http_proxy = __toESM(require("express-http-proxy"));
|
|
33
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
34
|
+
var import_morgan = __toESM(require("morgan"));
|
|
35
|
+
var import_vite = require("vite");
|
|
36
|
+
var import_tamaguiConfigUtils = require("./tamaguiConfigUtils.js");
|
|
37
|
+
var import_utils = require("./utils.js");
|
|
38
|
+
const dev = async (options) => {
|
|
39
|
+
var _a;
|
|
40
|
+
const { default: getPort } = await import("get-port");
|
|
41
|
+
const { root, mode, paths } = options;
|
|
42
|
+
const server = await (0, import_vite.createServer)({
|
|
43
|
+
root,
|
|
44
|
+
server: {
|
|
45
|
+
open: true,
|
|
46
|
+
host: options.host
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
await Promise.all([
|
|
50
|
+
server.listen(),
|
|
51
|
+
(0, import_tamaguiConfigUtils.watchTamaguiConfig)(options)
|
|
52
|
+
]);
|
|
53
|
+
const info = (_a = server.httpServer) == null ? void 0 : _a.address();
|
|
54
|
+
const port = await getPort({
|
|
55
|
+
port: info.port + 1
|
|
56
|
+
});
|
|
57
|
+
const app = (0, import_express.default)();
|
|
58
|
+
app.disable("x-powered-by");
|
|
59
|
+
app.use(import_express.default.static(paths.dotDir, { maxAge: "2h" }));
|
|
60
|
+
app.use((0, import_morgan.default)("tiny"));
|
|
61
|
+
app.get("/conf", async (req, res) => {
|
|
62
|
+
const conf = await import_fs_extra.default.readJSON(paths.conf);
|
|
63
|
+
res.status(200).json(conf);
|
|
64
|
+
});
|
|
65
|
+
app.use("/", (0, import_express_http_proxy.default)(`${info.address}:${info.port}`));
|
|
66
|
+
app.listen(port);
|
|
67
|
+
console.log(`Listening on`, import_chalk.default.green(`http://localhost:${port}`));
|
|
68
|
+
server.printUrls();
|
|
69
|
+
await (0, import_utils.closeEvent)(server);
|
|
70
|
+
};
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
dev
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/dev.ts"],
|
|
4
|
+
"sourcesContent": ["import { AddressInfo } from 'net'\n\nimport chalk from 'chalk'\nimport express from 'express'\nimport proxy from 'express-http-proxy'\nimport fs from 'fs-extra'\nimport morgan from 'morgan'\nimport { createServer } from 'vite'\n\nimport { watchTamaguiConfig } from './tamaguiConfigUtils.js'\nimport { ResolvedOptions } from './types.js'\nimport { closeEvent } from './utils.js'\n\nexport const dev = async (options: ResolvedOptions) => {\n const { default: getPort } = await import('get-port')\n const { root, mode, paths } = options\n const server = await createServer({\n root,\n server: {\n open: true,\n host: options.host,\n },\n })\n\n // these can be lazy loaded (eventually should put in own process)\n await Promise.all([\n server.listen(),\n //\n watchTamaguiConfig(options),\n // generateTypes(options),\n ])\n\n const info = server.httpServer?.address() as AddressInfo\n\n const port = await getPort({\n port: info.port + 1,\n })\n\n const app = express()\n\n app.disable('x-powered-by')\n app.use(express.static(paths.dotDir, { maxAge: '2h' }))\n app.use(morgan('tiny'))\n\n // studio specific - move out eventually to studioPlugin\n\n app.get('/conf', async (req, res) => {\n const conf = await fs.readJSON(paths.conf)\n res.status(200).json(conf)\n })\n\n app.use('/', proxy(`${info.address}:${info.port}`))\n\n app.listen(port)\n\n console.log(`Listening on`, chalk.green(`http://localhost:${port}`))\n server.printUrls()\n\n await closeEvent(server)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA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
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
|
+
var generate_exports = {};
|
|
27
|
+
__export(generate_exports, {
|
|
28
|
+
generateTypes: () => generateTypes,
|
|
29
|
+
getTypes: () => getTypes
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(generate_exports);
|
|
32
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
33
|
+
var import_ts_morph = require("ts-morph");
|
|
34
|
+
var import_utils = require("./utils.js");
|
|
35
|
+
async function generateTypes(options) {
|
|
36
|
+
const types = await getTypes(options);
|
|
37
|
+
await import_fs_extra.default.writeJSON(options.paths.types, types, {
|
|
38
|
+
spaces: 2
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async function getTypes(options) {
|
|
42
|
+
const tamagui = await (0, import_utils.loadTamagui)(options.tamaguiOptions);
|
|
43
|
+
const uniqueViewExportingPaths = new Set(
|
|
44
|
+
Object.keys(tamagui.nameToPaths).map((name) => {
|
|
45
|
+
return `${[...tamagui.nameToPaths[name]][0]}.ts*`;
|
|
46
|
+
})
|
|
47
|
+
);
|
|
48
|
+
const project = new import_ts_morph.Project({
|
|
49
|
+
compilerOptions: {
|
|
50
|
+
noEmit: false,
|
|
51
|
+
declaration: true,
|
|
52
|
+
emitDeclarationOnly: true
|
|
53
|
+
},
|
|
54
|
+
skipAddingFilesFromTsConfig: true,
|
|
55
|
+
tsConfigFilePath: options.tsconfigPath
|
|
56
|
+
});
|
|
57
|
+
const files = project.addSourceFilesAtPaths([...uniqueViewExportingPaths]);
|
|
58
|
+
return Object.fromEntries(
|
|
59
|
+
files.flatMap((x) => {
|
|
60
|
+
return [...x.getExportedDeclarations()].map(([k, v]) => {
|
|
61
|
+
return [
|
|
62
|
+
k,
|
|
63
|
+
v[0].getType().getApparentType().getProperties().map((prop) => {
|
|
64
|
+
var _a;
|
|
65
|
+
return [prop.getEscapedName(), (_a = prop.getValueDeclaration()) == null ? void 0 : _a.getType().getText()];
|
|
66
|
+
})
|
|
67
|
+
];
|
|
68
|
+
});
|
|
69
|
+
})
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
generateTypes,
|
|
75
|
+
getTypes
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/generate.ts"],
|
|
4
|
+
"sourcesContent": ["#!/usr/bin/env node\n\nimport fs from 'fs-extra'\nimport { Project } from 'ts-morph'\n\nimport { ResolvedOptions } from './types.js'\nimport { loadTamagui } from './utils.js'\n\nexport async function generateTypes(options: ResolvedOptions) {\n const types = await getTypes(options)\n await fs.writeJSON(options.paths.types, types, {\n spaces: 2,\n })\n}\n\nexport async function getTypes(options: ResolvedOptions) {\n const tamagui = await loadTamagui(options.tamaguiOptions)\n\n const uniqueViewExportingPaths = new Set(\n Object.keys(tamagui.nameToPaths).map((name) => {\n return `${[...tamagui.nameToPaths[name]][0]}.ts*`\n })\n )\n\n const project = new Project({\n compilerOptions: {\n noEmit: false,\n declaration: true,\n emitDeclarationOnly: true,\n },\n skipAddingFilesFromTsConfig: true,\n tsConfigFilePath: options.tsconfigPath,\n })\n\n const files = project.addSourceFilesAtPaths([...uniqueViewExportingPaths])\n\n return Object.fromEntries(\n files.flatMap((x) => {\n return [...x.getExportedDeclarations()].map(([k, v]) => {\n return [\n k,\n v[0]\n .getType()\n .getApparentType()\n .getProperties()\n .map((prop) => {\n return [prop.getEscapedName(), prop.getValueDeclaration()?.getType().getText()]\n }),\n ]\n })\n })\n )\n\n // console.log(\n // 'project',\n // files.map((x) => x.getFilePath()),\n // files.map((x) => {\n // return x.getExportedDeclarations()\n // }),\n // Object.fromEntries(\n // files.flatMap((x) => {\n // return [...x.getExportedDeclarations()].map(([k, v]) => {\n // return [k, v[0].getType().getApparentType().getText()]\n // })\n // })\n // ),\n\n // // files.map((f) => f.getExportSymbols())\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,sBAAe;AACf,sBAAwB;AAGxB,mBAA4B;AAE5B,eAAsB,cAAc,SAA0B;AAC5D,QAAM,QAAQ,MAAM,SAAS,OAAO;AACpC,QAAM,gBAAAA,QAAG,UAAU,QAAQ,MAAM,OAAO,OAAO;AAAA,IAC7C,QAAQ;AAAA,EACV,CAAC;AACH;AAEA,eAAsB,SAAS,SAA0B;AACvD,QAAM,UAAU,UAAM,0BAAY,QAAQ,cAAc;AAExD,QAAM,2BAA2B,IAAI;AAAA,IACnC,OAAO,KAAK,QAAQ,WAAW,EAAE,IAAI,CAAC,SAAS;AAC7C,aAAO,GAAG,CAAC,GAAG,QAAQ,YAAY,KAAK,EAAE;AAAA,IAC3C,CAAC;AAAA,EACH;AAEA,QAAM,UAAU,IAAI,wBAAQ;AAAA,IAC1B,iBAAiB;AAAA,MACf,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,qBAAqB;AAAA,IACvB;AAAA,IACA,6BAA6B;AAAA,IAC7B,kBAAkB,QAAQ;AAAA,EAC5B,CAAC;AAED,QAAM,QAAQ,QAAQ,sBAAsB,CAAC,GAAG,wBAAwB,CAAC;AAEzE,SAAO,OAAO;AAAA,IACZ,MAAM,QAAQ,CAAC,MAAM;AACnB,aAAO,CAAC,GAAG,EAAE,wBAAwB,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM;AACtD,eAAO;AAAA,UACL;AAAA,UACA,EAAE,GACC,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,IAAI,CAAC,SAAS;AA7C3B;AA8Cc,mBAAO,CAAC,KAAK,eAAe,IAAG,UAAK,oBAAoB,MAAzB,mBAA4B,UAAU,SAAS;AAAA,UAChF,CAAC;AAAA,QACL;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAiBF;",
|
|
6
|
+
"names": ["fs"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var studio_exports = {};
|
|
26
|
+
__export(studio_exports, {
|
|
27
|
+
studio: () => studio
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(studio_exports);
|
|
30
|
+
var import_module = require("module");
|
|
31
|
+
var import_path = require("path");
|
|
32
|
+
var import_vite_plugin = require("@tamagui/vite-plugin");
|
|
33
|
+
var import_chalk = __toESM(require("chalk"));
|
|
34
|
+
var import_express = __toESM(require("express"));
|
|
35
|
+
var import_express_http_proxy = __toESM(require("express-http-proxy"));
|
|
36
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
37
|
+
var import_morgan = __toESM(require("morgan"));
|
|
38
|
+
var import_vite = require("vite");
|
|
39
|
+
var import_tamaguiConfigUtils = require("./tamaguiConfigUtils.js");
|
|
40
|
+
var import_utils = require("./utils.js");
|
|
41
|
+
const import_meta = {};
|
|
42
|
+
const resolve = "url" in import_meta ? (0, import_module.createRequire)(import_meta.url).resolve : require.resolve;
|
|
43
|
+
const studio = async (options) => {
|
|
44
|
+
var _a;
|
|
45
|
+
const { default: getPort } = await import("get-port");
|
|
46
|
+
const { paths } = options;
|
|
47
|
+
const root = (0, import_path.dirname)(resolve("@takeout/studio/entry"));
|
|
48
|
+
const server = await (0, import_vite.createServer)({
|
|
49
|
+
root,
|
|
50
|
+
server: {
|
|
51
|
+
host: options.host
|
|
52
|
+
},
|
|
53
|
+
plugins: [
|
|
54
|
+
(0, import_vite_plugin.tamaguiPlugin)({
|
|
55
|
+
components: ["tamagui"]
|
|
56
|
+
})
|
|
57
|
+
]
|
|
58
|
+
});
|
|
59
|
+
await Promise.all([
|
|
60
|
+
server.listen(),
|
|
61
|
+
(0, import_tamaguiConfigUtils.watchTamaguiConfig)(options)
|
|
62
|
+
]);
|
|
63
|
+
const info = (_a = server.httpServer) == null ? void 0 : _a.address();
|
|
64
|
+
console.log("devServerInfo", info);
|
|
65
|
+
const port = await getPort({
|
|
66
|
+
port: info.port + 1
|
|
67
|
+
});
|
|
68
|
+
const app = (0, import_express.default)();
|
|
69
|
+
app.disable("x-powered-by");
|
|
70
|
+
app.use(import_express.default.static(paths.dotDir, { maxAge: "2h" }));
|
|
71
|
+
app.use((0, import_morgan.default)("tiny"));
|
|
72
|
+
app.get("/conf", async (req, res) => {
|
|
73
|
+
const conf = await import_fs_extra.default.readJSON(paths.conf);
|
|
74
|
+
res.status(200).json(conf);
|
|
75
|
+
});
|
|
76
|
+
app.use("/", (0, import_express_http_proxy.default)(`${info.address}:${info.port}`));
|
|
77
|
+
app.listen(port);
|
|
78
|
+
console.log(`Listening on`, import_chalk.default.green(`http://localhost:${port}`));
|
|
79
|
+
await (0, import_utils.closeEvent)(server);
|
|
80
|
+
};
|
|
81
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
82
|
+
0 && (module.exports = {
|
|
83
|
+
studio
|
|
84
|
+
});
|
|
85
|
+
//# sourceMappingURL=studio.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/studio.ts"],
|
|
4
|
+
"sourcesContent": ["import { createRequire } from 'module'\nimport { AddressInfo } from 'net'\nimport { dirname } from 'path'\n\nimport { tamaguiPlugin } from '@tamagui/vite-plugin'\nimport chalk from 'chalk'\nimport express from 'express'\nimport proxy from 'express-http-proxy'\nimport fs from 'fs-extra'\nimport morgan from 'morgan'\nimport { createServer } from 'vite'\n\nimport { watchTamaguiConfig } from './tamaguiConfigUtils.js'\nimport { ResolvedOptions } from './types.js'\nimport { closeEvent } from './utils.js'\n\nconst resolve = 'url' in import.meta ? createRequire(import.meta.url).resolve : require.resolve\n\nexport const studio = async (options: ResolvedOptions) => {\n const { default: getPort } = await import('get-port')\n const { paths } = options\n const root = dirname(resolve('@takeout/studio/entry'))\n const server = await createServer({\n root,\n server: {\n // open: true,\n host: options.host,\n },\n plugins: [\n tamaguiPlugin({\n components: ['tamagui'],\n }),\n ],\n })\n\n // these can be lazy loaded (eventually should put in own process)\n await Promise.all([\n server.listen(),\n //\n watchTamaguiConfig(options),\n // generateTypes(options),\n ])\n\n const info = server.httpServer?.address() as AddressInfo\n console.log('devServerInfo', info)\n\n const port = await getPort({\n port: info.port + 1,\n })\n\n const app = express()\n\n app.disable('x-powered-by')\n app.use(express.static(paths.dotDir, { maxAge: '2h' }))\n app.use(morgan('tiny'))\n\n app.get('/conf', async (req, res) => {\n const conf = await fs.readJSON(paths.conf)\n res.status(200).json(conf)\n })\n\n app.use('/', proxy(`${info.address}:${info.port}`))\n\n app.listen(port)\n\n console.log(`Listening on`, chalk.green(`http://localhost:${port}`))\n\n await closeEvent(server)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA8B;AAE9B,kBAAwB;AAExB,yBAA8B;AAC9B,mBAAkB;AAClB,qBAAoB;AACpB,gCAAkB;AAClB,sBAAe;AACf,oBAAmB;AACnB,kBAA6B;AAE7B,gCAAmC;A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AAEnE,YAAM,yBAAW,MAAM;AACzB;",
|
|
6
|
+
"names": ["express", "morgan", "fs", "proxy", "chalk"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
|
+
var tamaguiConfigUtils_exports = {};
|
|
27
|
+
__export(tamaguiConfigUtils_exports, {
|
|
28
|
+
generateTamaguiConfig: () => generateTamaguiConfig,
|
|
29
|
+
watchTamaguiConfig: () => watchTamaguiConfig
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(tamaguiConfigUtils_exports);
|
|
32
|
+
var import_core_node = require("@tamagui/core-node");
|
|
33
|
+
var import_esbuild = __toESM(require("esbuild"));
|
|
34
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
35
|
+
var import_utils = require("./utils.js");
|
|
36
|
+
async function generateTamaguiConfig(options) {
|
|
37
|
+
await (0, import_fs_extra.ensureDir)(options.paths.dotDir);
|
|
38
|
+
const config = await getTamaguiConfig(options);
|
|
39
|
+
const { components, nameToPaths } = config;
|
|
40
|
+
const { themes, tokens } = config.tamaguiConfig;
|
|
41
|
+
for (const key in themes) {
|
|
42
|
+
const theme = themes[key];
|
|
43
|
+
theme.id = key;
|
|
44
|
+
for (const tkey in theme) {
|
|
45
|
+
theme[tkey] = (0, import_core_node.getVariableValue)(theme[tkey]);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
for (const key in tokens) {
|
|
49
|
+
const token = tokens[key];
|
|
50
|
+
for (const tkey in token) {
|
|
51
|
+
token[tkey] = (0, import_core_node.getVariableValue)(token[tkey]);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
for (const key in components) {
|
|
55
|
+
const component = components[key];
|
|
56
|
+
for (const _ in component.nameToInfo) {
|
|
57
|
+
delete component.nameToInfo[_].staticConfig["validStyles"];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
for (const key in nameToPaths) {
|
|
61
|
+
nameToPaths[key] = [...nameToPaths[key]];
|
|
62
|
+
}
|
|
63
|
+
delete config.tamaguiConfig["Provider"];
|
|
64
|
+
delete config.tamaguiConfig["fontsParsed"];
|
|
65
|
+
delete config.tamaguiConfig["getCSS"];
|
|
66
|
+
delete config.tamaguiConfig["tokensParsed"];
|
|
67
|
+
delete config.tamaguiConfig["themeConfig"];
|
|
68
|
+
await import_fs_extra.default.writeJSON(options.paths.conf, config, {
|
|
69
|
+
spaces: 2
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
async function getTamaguiConfig(options) {
|
|
73
|
+
return (0, import_utils.loadTamagui)(options.tamaguiOptions);
|
|
74
|
+
}
|
|
75
|
+
async function watchTamaguiConfig(options) {
|
|
76
|
+
if (!options.tamaguiOptions.config)
|
|
77
|
+
return;
|
|
78
|
+
await generateTamaguiConfig(options);
|
|
79
|
+
await import_esbuild.default.build({
|
|
80
|
+
entryPoints: [options.tamaguiOptions.config],
|
|
81
|
+
sourcemap: false,
|
|
82
|
+
write: false,
|
|
83
|
+
watch: {
|
|
84
|
+
onRebuild(err, result) {
|
|
85
|
+
generateTamaguiConfig(options);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
+
0 && (module.exports = {
|
|
92
|
+
generateTamaguiConfig,
|
|
93
|
+
watchTamaguiConfig
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=tamaguiConfigUtils.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/tamaguiConfigUtils.ts"],
|
|
4
|
+
"sourcesContent": ["#!/usr/bin/env node\n\nimport { getVariableValue } from '@tamagui/core-node'\nimport esbuild from 'esbuild'\nimport fs, { ensureDir } from 'fs-extra'\n\nimport { ResolvedOptions } from './types.js'\nimport { loadTamagui } from './utils.js'\n\nexport async function generateTamaguiConfig(options: ResolvedOptions) {\n await ensureDir(options.paths.dotDir)\n const config = await getTamaguiConfig(options)\n const { components, nameToPaths } = config\n const { themes, tokens } = config.tamaguiConfig\n\n // reduce down to usable, smaller json\n\n // slim themes, add name\n for (const key in themes) {\n const theme = themes[key]\n // @ts-ignore\n theme.id = key\n for (const tkey in theme) {\n theme[tkey] = getVariableValue(theme[tkey])\n }\n }\n\n // flatten variables\n for (const key in tokens) {\n const token = tokens[key]\n for (const tkey in token) {\n token[tkey] = getVariableValue(token[tkey])\n }\n }\n\n // remove bulky stuff in components\n for (const key in components) {\n const component = components[key]\n for (const _ in component.nameToInfo) {\n delete component.nameToInfo[_].staticConfig['validStyles']\n }\n }\n\n // set to array\n for (const key in nameToPaths) {\n // @ts-ignore\n nameToPaths[key] = [...nameToPaths[key]]\n }\n\n // cleanup other stuff\n // @ts-ignore\n delete config.tamaguiConfig['Provider']\n // @ts-ignore\n delete config.tamaguiConfig['fontsParsed']\n // @ts-ignore\n delete config.tamaguiConfig['getCSS']\n // @ts-ignore\n delete config.tamaguiConfig['tokensParsed']\n // @ts-ignore\n delete config.tamaguiConfig['themeConfig']\n\n await fs.writeJSON(options.paths.conf, config, {\n spaces: 2,\n })\n}\n\nasync function getTamaguiConfig(options: ResolvedOptions) {\n return loadTamagui(options.tamaguiOptions)\n}\n\nexport async function watchTamaguiConfig(options: ResolvedOptions) {\n if (!options.tamaguiOptions.config) return\n await generateTamaguiConfig(options)\n await esbuild.build({\n entryPoints: [options.tamaguiOptions.config],\n sourcemap: false,\n // dont output just use esbuild as a watcher\n write: false,\n watch: {\n onRebuild(err, result) {\n generateTamaguiConfig(options)\n },\n },\n })\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,uBAAiC;AACjC,qBAAoB;AACpB,sBAA8B;AAG9B,mBAA4B;AAE5B,eAAsB,sBAAsB,SAA0B;AACpE,YAAM,2BAAU,QAAQ,MAAM,MAAM;AACpC,QAAM,SAAS,MAAM,iBAAiB,OAAO;AAC7C,QAAM,EAAE,YAAY,YAAY,IAAI;AACpC,QAAM,EAAE,QAAQ,OAAO,IAAI,OAAO;AAKlC,aAAW,OAAO,QAAQ;AACxB,UAAM,QAAQ,OAAO;AAErB,UAAM,KAAK;AACX,eAAW,QAAQ,OAAO;AACxB,YAAM,YAAQ,mCAAiB,MAAM,KAAK;AAAA,IAC5C;AAAA,EACF;AAGA,aAAW,OAAO,QAAQ;AACxB,UAAM,QAAQ,OAAO;AACrB,eAAW,QAAQ,OAAO;AACxB,YAAM,YAAQ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