@tamagui/cli 1.2.9 → 1.2.11
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/esm/build.mjs +49 -0
- package/dist/esm/build.mjs.map +7 -0
- package/dist/esm/cli.mjs +138 -0
- package/dist/esm/cli.mjs.map +7 -0
- package/dist/esm/create.mjs +1 -0
- package/dist/esm/create.mjs.map +7 -0
- package/dist/esm/dev/createDevServer.mjs +141 -0
- package/dist/esm/dev/createDevServer.mjs.map +7 -0
- package/dist/esm/dev.mjs +151 -0
- package/dist/esm/dev.mjs.map +7 -0
- package/dist/esm/generate.mjs +49 -0
- package/dist/esm/generate.mjs.map +7 -0
- package/dist/esm/index.mjs +9 -0
- package/dist/esm/index.mjs.map +7 -0
- package/dist/esm/studio.mjs +61 -0
- package/dist/esm/studio.mjs.map +7 -0
- package/dist/esm/tamaguiConfigUtils.mjs +52 -0
- package/dist/esm/tamaguiConfigUtils.mjs.map +7 -0
- package/dist/esm/test.mjs +9 -0
- package/dist/esm/test.mjs.map +7 -0
- package/dist/esm/types.mjs +1 -0
- package/dist/esm/types.mjs.map +7 -0
- package/dist/esm/update.mjs +6 -0
- package/dist/esm/update.mjs.map +7 -0
- package/dist/esm/utils/constants.mjs +5 -0
- package/dist/esm/utils/constants.mjs.map +7 -0
- package/dist/esm/utils.mjs +78 -0
- package/dist/esm/utils.mjs.map +7 -0
- package/dist/esm/vendor/debugger-app/index.mjs +6 -0
- package/dist/esm/vendor/debugger-app/index.mjs.map +7 -0
- package/dist/esm/vendor/debugger-app/src/debuggerWorker.mjs +63 -0
- package/dist/esm/vendor/debugger-app/src/debuggerWorker.mjs.map +7 -0
- package/dist/esm/vendor/debugger-app/src/index.mjs +142 -0
- package/dist/esm/vendor/debugger-app/src/index.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/createServer.mjs +95 -0
- package/dist/esm/vendor/repack/dev-server/src/createServer.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/index.mjs +3 -0
- package/dist/esm/vendor/repack/dev-server/src/index.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/api/apiPlugin.mjs +37 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/api/apiPlugin.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/api/index.mjs +5 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/api/index.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/compiler/compilerPlugin.mjs +67 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/compiler/compilerPlugin.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/compiler/index.mjs +6 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/compiler/index.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/compiler/types.mjs +1 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/compiler/types.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/devtools/devtoolsPlugin.mjs +87 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/devtools/devtoolsPlugin.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/devtools/index.mjs +5 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/devtools/index.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/favicon/faviconPlugin.mjs +13 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/favicon/faviconPlugin.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/favicon/index.mjs +5 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/favicon/index.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/multipart/index.mjs +6 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/multipart/index.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/multipart/multipartPlugin.mjs +50 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/multipart/multipartPlugin.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/multipart/types.mjs +1 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/multipart/types.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/symbolicate/Symbolicator.mjs +186 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/symbolicate/Symbolicator.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/symbolicate/index.mjs +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/symbolicate/index.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/symbolicate/sybmolicatePlugin.mjs +35 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/symbolicate/sybmolicatePlugin.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/symbolicate/types.mjs +1 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/symbolicate/types.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/WebSocketRouter.mjs +50 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/WebSocketRouter.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/WebSocketServer.mjs +32 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/WebSocketServer.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/index.mjs +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/index.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/servers/HermesInspectorProxy.mjs +110 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/servers/HermesInspectorProxy.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketApiServer.mjs +52 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketApiServer.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketDebuggerServer.mjs +106 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketDebuggerServer.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketDevClientServer.mjs +62 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketDevClientServer.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketEventsServer.mjs +154 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketEventsServer.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketHMRServer.mjs +76 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketHMRServer.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketMessageServer.mjs +330 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketMessageServer.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/types.mjs +1 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/types.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/wssPlugin.mjs +47 -0
- package/dist/esm/vendor/repack/dev-server/src/plugins/wss/wssPlugin.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/src/types.mjs +13 -0
- package/dist/esm/vendor/repack/dev-server/src/types.mjs.map +7 -0
- package/dist/esm/vendor/repack/dev-server/vendor/metro-inspector-proxy/src/Device.mjs +5 -0
- package/dist/esm/vendor/repack/dev-server/vendor/metro-inspector-proxy/src/Device.mjs.map +7 -0
- package/package.json +6 -6
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { dirname, resolve } from "path";
|
|
2
|
+
import { createExtractor, extractToClassNames } from "@tamagui/static";
|
|
3
|
+
import chokidar from "chokidar";
|
|
4
|
+
import { readFile } from "fs-extra";
|
|
5
|
+
const build = async (options) => {
|
|
6
|
+
const entry = options.pkgJson.source;
|
|
7
|
+
if (!entry) {
|
|
8
|
+
throw new Error(`Must add "source" to package.json pointing to your source directory`);
|
|
9
|
+
}
|
|
10
|
+
const sourceDir = dirname(entry);
|
|
11
|
+
const promises = [];
|
|
12
|
+
const targets = ["web"];
|
|
13
|
+
console.log("sourceDir", sourceDir, targets);
|
|
14
|
+
await new Promise((res) => {
|
|
15
|
+
chokidar.watch(sourceDir, {
|
|
16
|
+
// persistent: true,
|
|
17
|
+
}).on("add", (relativePath) => {
|
|
18
|
+
const sourcePath = resolve(process.cwd(), relativePath);
|
|
19
|
+
promises.push(
|
|
20
|
+
(async () => {
|
|
21
|
+
await Promise.all(
|
|
22
|
+
targets.map(async (target) => {
|
|
23
|
+
process.env.TAMAGUI_TARGET = target;
|
|
24
|
+
if (options.debug) {
|
|
25
|
+
process.env.NODE_ENV ||= "development";
|
|
26
|
+
}
|
|
27
|
+
const source = await readFile(sourcePath, "utf-8");
|
|
28
|
+
const extractor = createExtractor();
|
|
29
|
+
const out = await extractToClassNames({
|
|
30
|
+
extractor,
|
|
31
|
+
source,
|
|
32
|
+
sourcePath,
|
|
33
|
+
options: options.tamaguiOptions,
|
|
34
|
+
shouldPrintDebug: options.debug || false
|
|
35
|
+
});
|
|
36
|
+
})
|
|
37
|
+
);
|
|
38
|
+
})()
|
|
39
|
+
);
|
|
40
|
+
}).on("ready", () => {
|
|
41
|
+
res();
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
await Promise.all(promises);
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
build
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=build.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/build.ts"],
|
|
4
|
+
"sourcesContent": ["import { writeFile } from 'fs'\nimport { 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 console.log('sourceDir', sourceDir, targets)\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 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 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 // await writeFile()\n })\n )\n })()\n )\n })\n .on('ready', () => {\n res()\n })\n })\n\n await Promise.all(promises)\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAmB,SAAe,eAAe;AAEjD,SAAS,iBAAiB,2BAAwC;AAClE,OAAO,cAAc;AACrB,SAAS,gBAAgB;AAIlB,MAAM,QAAQ,OAAO,YAA6B;AAGvD,QAAM,QAAQ,QAAQ,QAAQ;AAC9B,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,MAAM,qEAAqE;AAAA,EACvF;AACA,QAAM,YAAY,QAAQ,KAAK;AAC/B,QAAM,WAA4B,CAAC;AACnC,QAAM,UAAU,CAAC,KAAK;AAEtB,UAAQ,IAAI,aAAa,WAAW,OAAO;AAE3C,QAAM,IAAI,QAAc,CAAC,QAAQ;AAC/B,aAEG,MAAM,WAAW;AAAA;AAAA,IAElB,CAAC,EACA,GAAG,OAAO,CAAC,iBAAiB;AAC3B,YAAM,aAAa,QAAQ,QAAQ,IAAI,GAAG,YAAY;AAEtD,eAAS;AAAA,SACN,YAAY;AACX,gBAAM,QAAQ;AAAA,YACZ,QAAQ,IAAI,OAAO,WAAW;AAC5B,sBAAQ,IAAI,iBAAiB;AAC7B,kBAAI,QAAQ,OAAO;AACjB,wBAAQ,IAAI,aAAa;AAAA,cAC3B;AACA,oBAAM,SAAS,MAAM,SAAS,YAAY,OAAO;AACjD,oBAAM,YAAY,gBAAgB;AAClC,oBAAM,MAAM,MAAM,oBAAoB;AAAA,gBACpC;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA,SAAS,QAAQ;AAAA,gBACjB,kBAAkB,QAAQ,SAAS;AAAA,cACrC,CAAC;AAAA,YAGH,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": []
|
|
7
|
+
}
|
package/dist/esm/cli.mjs
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import arg from "arg";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { disposeAll, getOptions } from "./utils.js";
|
|
4
|
+
["exit", "SIGINT"].forEach((_) => {
|
|
5
|
+
process.on(_, () => {
|
|
6
|
+
process.stdout.write(`bye
|
|
7
|
+
`);
|
|
8
|
+
disposeAll();
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
const COMMAND_MAP = {
|
|
12
|
+
build: {
|
|
13
|
+
shorthands: ["b"],
|
|
14
|
+
description: `Use to pre-build a Tamagui component directory`,
|
|
15
|
+
flags: {
|
|
16
|
+
"--help": Boolean,
|
|
17
|
+
"--debug": Boolean,
|
|
18
|
+
"--verbose": Boolean
|
|
19
|
+
},
|
|
20
|
+
async run() {
|
|
21
|
+
const { _, ...flags2 } = arg(this.flags);
|
|
22
|
+
const { build } = await import("./build.js");
|
|
23
|
+
const options = await getOptions({
|
|
24
|
+
debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : true : false
|
|
25
|
+
});
|
|
26
|
+
await build(options);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
update: {
|
|
30
|
+
shorthands: [],
|
|
31
|
+
description: `Update all tamagui packages within a monorepo`,
|
|
32
|
+
flags: {},
|
|
33
|
+
async run() {
|
|
34
|
+
const { update } = await import("./update.js");
|
|
35
|
+
await update();
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
dev: {
|
|
39
|
+
shorthands: ["d"],
|
|
40
|
+
description: `Run tamagui vite`,
|
|
41
|
+
flags: {
|
|
42
|
+
"--help": Boolean,
|
|
43
|
+
"--debug": Boolean,
|
|
44
|
+
"--verbose": Boolean
|
|
45
|
+
},
|
|
46
|
+
async run() {
|
|
47
|
+
const { _, ...flags2 } = arg(this.flags);
|
|
48
|
+
const { dev } = await import("./dev.js");
|
|
49
|
+
const options = await getOptions({
|
|
50
|
+
debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : true : false
|
|
51
|
+
});
|
|
52
|
+
await dev(options);
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
studio: {
|
|
56
|
+
shorthands: ["s"],
|
|
57
|
+
description: `Studio`,
|
|
58
|
+
flags: {},
|
|
59
|
+
async run() {
|
|
60
|
+
const { _, ...flags2 } = arg(this.flags);
|
|
61
|
+
const { studio } = await import("./studio.js");
|
|
62
|
+
const options = await getOptions({
|
|
63
|
+
debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : true : false
|
|
64
|
+
});
|
|
65
|
+
await studio(options);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const commandEntries = Object.keys(COMMAND_MAP).flatMap((command2) => {
|
|
70
|
+
const definition2 = COMMAND_MAP[command2];
|
|
71
|
+
const entries = [command2, ...definition2.shorthands].map((cmd) => {
|
|
72
|
+
return [cmd, definition2];
|
|
73
|
+
});
|
|
74
|
+
return entries;
|
|
75
|
+
});
|
|
76
|
+
const commands = Object.fromEntries(commandEntries);
|
|
77
|
+
const {
|
|
78
|
+
_: [command],
|
|
79
|
+
...flags
|
|
80
|
+
} = arg(
|
|
81
|
+
{
|
|
82
|
+
"--help": Boolean,
|
|
83
|
+
"--version": Boolean
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
permissive: true
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
if (flags["--version"]) {
|
|
90
|
+
console.log(require("../package.json").version);
|
|
91
|
+
process.exit(0);
|
|
92
|
+
}
|
|
93
|
+
if (!command && flags["--help"]) {
|
|
94
|
+
console.log(`$ tamagui
|
|
95
|
+
|
|
96
|
+
commands:
|
|
97
|
+
|
|
98
|
+
${Object.keys(COMMAND_MAP).map((key) => {
|
|
99
|
+
return ` ${key}`;
|
|
100
|
+
}).join("\n")}`);
|
|
101
|
+
process.exit(0);
|
|
102
|
+
}
|
|
103
|
+
if (!(command in commands)) {
|
|
104
|
+
console.error();
|
|
105
|
+
console.warn(chalk.yellow(`Not a valid command: ${command}`));
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
const definition = commands[command];
|
|
109
|
+
main();
|
|
110
|
+
async function main() {
|
|
111
|
+
if (flags["--help"]) {
|
|
112
|
+
console.log(`
|
|
113
|
+
$ tamagui ${command}: ${definition.description}
|
|
114
|
+
`);
|
|
115
|
+
console.log(
|
|
116
|
+
`Flags: ${Object.entries(definition.flags).map(([k, v]) => `${k} (${v.name})`)}`
|
|
117
|
+
);
|
|
118
|
+
process.exit(0);
|
|
119
|
+
}
|
|
120
|
+
const { _, ...cmdFlags } = arg(definition.flags);
|
|
121
|
+
if (cmdFlags["--help"]) {
|
|
122
|
+
console.log(`$ tamagui ${_}
|
|
123
|
+
|
|
124
|
+
Flags: ${JSON.stringify(cmdFlags, null, 2)}
|
|
125
|
+
|
|
126
|
+
`);
|
|
127
|
+
process.exit(0);
|
|
128
|
+
}
|
|
129
|
+
await definition.run();
|
|
130
|
+
console.log(`done`);
|
|
131
|
+
process.exit(0);
|
|
132
|
+
}
|
|
133
|
+
function showHelp(definition2, flags2) {
|
|
134
|
+
if (flags2["--help"]) {
|
|
135
|
+
console.log(`$ ${definition2}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=cli.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/cli.ts"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable no-console */\nimport arg, { flag } from 'arg'\nimport chalk from 'chalk'\n\nimport { disposeAll, getOptions } from './utils.js'\n\n;['exit', 'SIGINT'].forEach((_) => {\n process.on(_, () => {\n process.stdout.write(`bye\\n`)\n disposeAll()\n })\n})\n\nconst COMMAND_MAP = {\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 update: {\n shorthands: [],\n description: `Update all tamagui packages within a monorepo`,\n flags: {},\n async run() {\n const { update } = await import('./update.js')\n await update()\n },\n },\n\n dev: {\n shorthands: ['d'],\n description: `Run tamagui vite`,\n flags: {\n '--help': Boolean,\n '--debug': Boolean,\n '--verbose': Boolean,\n },\n async run() {\n const { _, ...flags } = arg(this.flags)\n const { dev } = await import('./dev.js')\n const options = await getOptions({\n debug: flags['--debug'] ? (flags['--verbose'] ? 'verbose' : true) : false,\n })\n await dev(options)\n },\n },\n\n studio: {\n shorthands: ['s'],\n description: `Studio`,\n flags: {},\n async run() {\n const { _, ...flags } = arg(this.flags)\n const { studio } = await import('./studio.js')\n const options = await getOptions({\n debug: flags['--debug'] ? (flags['--verbose'] ? 'verbose' : true) : false,\n })\n await studio(options)\n },\n },\n}\n\ntype CommandDefinitions = typeof COMMAND_MAP\ntype CommandKey = keyof typeof COMMAND_MAP\ntype CommandDefinition = CommandDefinitions[CommandKey]\n\nconst commandEntries = Object.keys(COMMAND_MAP).flatMap((command) => {\n const definition = COMMAND_MAP[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<\n CommandKey,\n CommandDefinition\n>\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(COMMAND_MAP)\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(\n `Flags: ${Object.entries(definition.flags).map(([k, v]) => `${k} (${v.name})`)}`\n )\n process.exit(0)\n }\n\n const { _, ...cmdFlags } = arg(definition.flags)\n\n // help for any command\n if (cmdFlags['--help']) {\n console.log(`$ tamagui ${_}\n\n Flags: ${JSON.stringify(cmdFlags, null, 2)}\n\n`)\n process.exit(0)\n }\n\n await definition.run()\n console.log(`done`)\n process.exit(0)\n}\n\nfunction showHelp(definition: CommandDefinition, flags: { '--help'?: boolean }) {\n if (flags['--help']) {\n console.log(`$ ${definition}`)\n }\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// // 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,OAAO,SAAmB;AAC1B,OAAO,WAAW;AAElB,SAAS,YAAY,kBAAkB;AAEtC,CAAC,QAAQ,QAAQ,EAAE,QAAQ,CAAC,MAAM;AACjC,UAAQ,GAAG,GAAG,MAAM;AAClB,YAAQ,OAAO,MAAM;AAAA,CAAO;AAC5B,eAAW;AAAA,EACb,CAAC;AACH,CAAC;AAED,MAAM,cAAc;AAAA,EAClB,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,MAAM;AACV,YAAM,EAAE,GAAG,GAAGA,OAAM,IAAI,IAAI,KAAK,KAAK;AACtC,YAAM,EAAE,MAAM,IAAI,MAAM,OAAO,YAAY;AAC3C,YAAM,UAAU,MAAM,WAAW;AAAA,QAC/B,OAAOA,OAAM,SAAS,IAAKA,OAAM,WAAW,IAAI,YAAY,OAAQ;AAAA,MACtE,CAAC;AACD,YAAM,MAAM,OAAO;AAAA,IACrB;A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Q,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,WAAW,IAAI;AACrB,UAAQ,IAAI,MAAM;AAClB,UAAQ,KAAK,CAAC;AAChB;AAEA,SAAS,SAASA,aAA+BF,QAA+B;AAC9E,MAAIA,OAAM,QAAQ,GAAG;AACnB,YAAQ,IAAI,KAAKE,aAAY;AAAA,EAC/B;AACF;",
|
|
6
|
+
"names": ["flags", "command", "definition"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=create.mjs.map
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { DEFAULT_PORT } from "../utils/constants.js";
|
|
2
|
+
import { createServer } from "../vendor/repack/dev-server/src";
|
|
3
|
+
async function createDevServer(options, {
|
|
4
|
+
indexJson,
|
|
5
|
+
getIndexBundle
|
|
6
|
+
}) {
|
|
7
|
+
const { start, stop } = await createServer({
|
|
8
|
+
options: {
|
|
9
|
+
rootDir: options.root,
|
|
10
|
+
host: options.host,
|
|
11
|
+
port: options.port ?? DEFAULT_PORT
|
|
12
|
+
// https: args.https
|
|
13
|
+
// ? {
|
|
14
|
+
// cert: args.cert,
|
|
15
|
+
// key: args.key,
|
|
16
|
+
// }
|
|
17
|
+
// : undefined,
|
|
18
|
+
},
|
|
19
|
+
delegate: (ctx) => {
|
|
20
|
+
return {
|
|
21
|
+
compiler: {
|
|
22
|
+
getAsset: async (filename, platform, sendProgress) => {
|
|
23
|
+
console.log("get asset", filename);
|
|
24
|
+
if (filename === "index.bundle") {
|
|
25
|
+
return await getIndexBundle();
|
|
26
|
+
}
|
|
27
|
+
return "";
|
|
28
|
+
},
|
|
29
|
+
getMimeType: (filename) => {
|
|
30
|
+
console.log("getMimeType", filename);
|
|
31
|
+
return "application/javascript";
|
|
32
|
+
},
|
|
33
|
+
inferPlatform: (uri) => {
|
|
34
|
+
return "ios";
|
|
35
|
+
const url = new URL(uri, "protocol://domain");
|
|
36
|
+
if (!url.searchParams.get("platform")) {
|
|
37
|
+
const [, platform] = /^\/(.+)\/.+$/.exec(url.pathname) ?? [];
|
|
38
|
+
return platform;
|
|
39
|
+
}
|
|
40
|
+
return void 0;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
symbolicator: {
|
|
44
|
+
getSource: async (fileUrl) => {
|
|
45
|
+
console.log("get source", fileUrl);
|
|
46
|
+
return "";
|
|
47
|
+
},
|
|
48
|
+
getSourceMap: async (fileUrl) => {
|
|
49
|
+
console.log("get source map", fileUrl);
|
|
50
|
+
return "";
|
|
51
|
+
},
|
|
52
|
+
shouldIncludeFrame: (frame) => {
|
|
53
|
+
return !/webpack[/\\]runtime[/\\].+\s/.test(frame.file);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
hmr: {
|
|
57
|
+
getUriPath: () => "/__hmr",
|
|
58
|
+
onClientConnected: (platform, clientId) => {
|
|
59
|
+
const lastStats = {};
|
|
60
|
+
ctx.broadcastToHmrClients(
|
|
61
|
+
{ action: "sync", body: createHmrBody(lastStats) },
|
|
62
|
+
platform,
|
|
63
|
+
[clientId]
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
messages: {
|
|
68
|
+
getHello: () => indexJson,
|
|
69
|
+
getStatus: () => "packager-status:running"
|
|
70
|
+
},
|
|
71
|
+
logger: {
|
|
72
|
+
onMessage: (log) => {
|
|
73
|
+
const logEntry = makeLogEntryFromFastifyLog(log);
|
|
74
|
+
logEntry.issuer = "DevServer";
|
|
75
|
+
console.log(
|
|
76
|
+
logEntry.type,
|
|
77
|
+
logEntry.issuer,
|
|
78
|
+
JSON.stringify(logEntry.message, null, 2)
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
api: {
|
|
83
|
+
// getPlatforms: async () => Object.keys(compiler.workers),
|
|
84
|
+
getPlatforms: async () => ["ios"],
|
|
85
|
+
getAssets: async (platform) => {
|
|
86
|
+
console.log("get assets", platform);
|
|
87
|
+
return [];
|
|
88
|
+
},
|
|
89
|
+
getCompilationStats: async (platform) => {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
await start();
|
|
97
|
+
return async () => {
|
|
98
|
+
await stop();
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function createHmrBody(stats) {
|
|
102
|
+
if (!stats) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
const modules = {};
|
|
106
|
+
for (const module of stats.modules ?? []) {
|
|
107
|
+
const { identifier, name } = module;
|
|
108
|
+
if (identifier !== void 0 && name) {
|
|
109
|
+
modules[identifier] = name;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
name: stats.name ?? "",
|
|
114
|
+
time: stats.time ?? 0,
|
|
115
|
+
hash: stats.hash ?? "",
|
|
116
|
+
warnings: stats.warnings || [],
|
|
117
|
+
errors: stats.errors || [],
|
|
118
|
+
modules
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function makeLogEntryFromFastifyLog(data) {
|
|
122
|
+
const { level, time, pid, hostname, ...rest } = data;
|
|
123
|
+
const levelToTypeMapping = {
|
|
124
|
+
10: "debug",
|
|
125
|
+
20: "debug",
|
|
126
|
+
30: "info",
|
|
127
|
+
40: "warn",
|
|
128
|
+
50: "error",
|
|
129
|
+
60: "error"
|
|
130
|
+
};
|
|
131
|
+
return {
|
|
132
|
+
type: levelToTypeMapping[level],
|
|
133
|
+
timestamp: time,
|
|
134
|
+
issuer: "",
|
|
135
|
+
message: [rest]
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
export {
|
|
139
|
+
createDevServer
|
|
140
|
+
};
|
|
141
|
+
//# sourceMappingURL=createDevServer.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/dev/createDevServer.ts"],
|
|
4
|
+
"sourcesContent": ["import { readFile } from 'fs/promises'\n\nimport { ResolvedOptions } from '../types.js'\nimport { DEFAULT_PORT } from '../utils/constants.js'\nimport { Server, createServer } from '../vendor/repack/dev-server/src'\n\nexport async function createDevServer(\n options: ResolvedOptions,\n {\n indexJson,\n getIndexBundle,\n }: { indexJson: Object; getIndexBundle: () => Promise<string> }\n) {\n const { start, stop } = await createServer({\n options: {\n rootDir: options.root,\n host: options.host,\n port: options.port ?? DEFAULT_PORT,\n // https: args.https\n // ? {\n // cert: args.cert,\n // key: args.key,\n // }\n // : undefined,\n },\n\n delegate: (ctx): Server.Delegate => {\n // if (args.interactive) {\n // bindKeypressInput(ctx)\n // }\n\n // if (reversePort && args.port) {\n // runAdbReverse(ctx, args.port)\n // }\n\n // let lastStats: webpack.StatsCompilation | undefined\n\n // compiler.on('watchRun', ({ platform }) => {\n // ctx.notifyBuildStart(platform)\n // if (platform === 'android') {\n // runAdbReverse(ctx, args.port ?? DEFAULT_PORT)\n // }\n // })\n\n // compiler.on('invalid', ({ platform }) => {\n // ctx.notifyBuildStart(platform)\n // ctx.broadcastToHmrClients({ action: 'building' }, platform)\n // })\n\n // compiler.on(\n // 'done',\n // ({ platform, stats }: { platform: string; stats: webpack.StatsCompilation }) => {\n // ctx.notifyBuildEnd(platform)\n // lastStats = stats\n // ctx.broadcastToHmrClients(\n // { action: 'built', body: createHmrBody(stats) },\n // platform\n // )\n // }\n // )\n\n return {\n compiler: {\n getAsset: async (filename, platform, sendProgress) => {\n console.log('get asset', filename)\n if (filename === 'index.bundle') {\n return await getIndexBundle()\n }\n return ''\n // return (await compiler.getAsset(filename, platform, sendProgress)).data\n },\n\n getMimeType: (filename) => {\n console.log('getMimeType', filename)\n return 'application/javascript'\n // return compiler.getMimeType(filename)\n },\n\n inferPlatform: (uri) => {\n return 'ios'\n\n const url = new URL(uri, 'protocol://domain')\n if (!url.searchParams.get('platform')) {\n const [, platform] = /^\\/(.+)\\/.+$/.exec(url.pathname) ?? []\n return platform\n }\n\n return undefined\n },\n },\n\n symbolicator: {\n getSource: async (fileUrl) => {\n console.log('get source', fileUrl)\n // const { filename, platform } = parseFileUrl(fileUrl)\n // return compiler.getSource(filename, platform)\n return ''\n },\n getSourceMap: async (fileUrl) => {\n console.log('get source map', fileUrl)\n // const { filename, platform } = parseFileUrl(fileUrl)\n // if (!platform) {\n // throw new Error('Cannot infer platform for file URL')\n // }\n\n // return compiler.getSourceMap(filename, platform)\n return ''\n },\n shouldIncludeFrame: (frame) => {\n // If the frame points to internal bootstrap/module system logic, skip the code frame.\n return !/webpack[/\\\\]runtime[/\\\\].+\\s/.test(frame.file)\n },\n },\n\n hmr: {\n getUriPath: () => '/__hmr',\n onClientConnected: (platform, clientId) => {\n // todo\n const lastStats = {}\n\n ctx.broadcastToHmrClients(\n { action: 'sync', body: createHmrBody(lastStats) },\n platform,\n [clientId]\n )\n },\n },\n\n messages: {\n getHello: () => indexJson,\n getStatus: () => 'packager-status:running',\n },\n\n logger: {\n onMessage: (log) => {\n const logEntry = makeLogEntryFromFastifyLog(log)\n logEntry.issuer = 'DevServer'\n console.log(\n logEntry.type,\n logEntry.issuer,\n JSON.stringify(logEntry.message, null, 2)\n )\n // reporter.process(logEntry)\n },\n },\n\n api: {\n // getPlatforms: async () => Object.keys(compiler.workers),\n getPlatforms: async () => ['ios'],\n getAssets: async (platform) => {\n console.log('get assets', platform)\n return []\n // return Object.entries(compiler.assetsCache[platform] ?? {}).map(([name, asset]) => ({\n // name,\n // size: asset.info.size,\n // })),\n },\n getCompilationStats: async (platform) => {\n return null\n // return compiler.statsCache[platform] ?? null\n },\n },\n }\n },\n })\n\n await start()\n\n return async () => {\n await stop()\n }\n}\n\nfunction createHmrBody(stats?: any): HMRMessageBody | null {\n if (!stats) {\n return null\n }\n\n const modules: Record<string, string> = {}\n for (const module of stats.modules ?? []) {\n const { identifier, name } = module\n if (identifier !== undefined && name) {\n modules[identifier] = name\n }\n }\n\n return {\n name: stats.name ?? '',\n time: stats.time ?? 0,\n hash: stats.hash ?? '',\n warnings: stats.warnings || [],\n errors: stats.errors || [],\n modules,\n }\n}\n\n/**\n * Represent Hot Module Replacement Update body.\n *\n * @internal\n */\nexport interface HMRMessageBody {\n name: string\n time: number\n hash: string\n warnings: any\n errors: any\n modules: Record<string, string>\n}\n\n/**\n * Represent Hot Module Replacement Update message.\n *\n * @internal\n */\nexport interface HMRMessage {\n action: 'building' | 'built' | 'sync'\n body: HMRMessageBody | null\n}\n\nfunction makeLogEntryFromFastifyLog(data: any): any {\n const { level, time, pid, hostname, ...rest } = data\n\n const levelToTypeMapping: Record<number, any> = {\n 10: 'debug',\n 20: 'debug',\n 30: 'info',\n 40: 'warn',\n 50: 'error',\n 60: 'error',\n }\n\n return {\n type: levelToTypeMapping[level],\n timestamp: time,\n issuer: '',\n message: [rest],\n }\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,oBAAoB;AAC7B,SAAiB,oBAAoB;AAErC,eAAsB,gBACpB,SACA;AAAA,EACE;AAAA,EACA;AACF,GACA;AACA,QAAM,EAAE,OAAO,KAAK,IAAI,MAAM,aAAa;AAAA,IACzC,SAAS;AAAA,MACP,SAAS,QAAQ;AAAA,MACjB,MAAM,QAAQ;AAAA,MACd,MAAM,QAAQ,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOxB;AAAA,IAEA,UAAU,CAAC,QAAyB;AAmClC,aAAO;AAAA,QACL,UAAU;AAAA,UACR,UAAU,OAAO,UAAU,UAAU,iBAAiB;AACpD,oBAAQ,IAAI,aAAa,QAAQ;AACjC,gBAAI,aAAa,gBAAgB;AAC/B,qBAAO,MAAM,eAAe;AAAA,YAC9B;AACA,mBAAO;AAAA,UAET;AAAA,UAEA,aAAa,CAAC,aAAa;AACzB,oBAAQ,IAAI,eAAe,QAAQ;AACnC,mBAAO;AAAA,UAET;AAAA,UAEA,eAAe,CAAC,QAAQ;AACtB,mBAAO;AAEP,kBAAM,MAAM,IAAI,IAAI,KAAK,mBAAm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ACvC,mBAAO;AAAA,UAET;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AAED,QAAM,MAAM;AAEZ,SAAO,YAAY;AACjB,UAAM,KAAK;AAAA,EACb;AACF;AAEA,SAAS,cAAc,OAAoC;AACzD,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,QAAM,UAAkC,CAAC;AACzC,aAAW,UAAU,MAAM,WAAW,CAAC,GAAG;AACxC,UAAM,EAAE,YAAY,KAAK,IAAI;AAC7B,QAAI,eAAe,UAAa,MAAM;AACpC,cAAQ,UAAU,IAAI;AAAA,IACxB;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM,MAAM,QAAQ;AAAA,IACpB,MAAM,MAAM,QAAQ;AAAA,IACpB,MAAM,MAAM,QAAQ;AAAA,IACpB,UAAU,MAAM,YAAY,CAAC;AAAA,IAC7B,QAAQ,MAAM,UAAU,CAAC;AAAA,IACzB;AAAA,EACF;AACF;AA0BA,SAAS,2BAA2B,MAAgB;AAClD,QAAM,EAAE,OAAO,MAAM,KAAK,UAAU,GAAG,KAAK,IAAI;AAEhD,QAAM,qBAA0C;AAAA,IAC9C,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,EACN;AAEA,SAAO;AAAA,IACL,MAAM,mBAAmB,KAAK;AAAA,IAC9B,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,SAAS,CAAC,IAAI;AAAA,EAChB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/esm/dev.mjs
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { readFile } from "fs/promises";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import fs from "fs-extra";
|
|
5
|
+
import { build, createServer } from "vite";
|
|
6
|
+
import { createDevServer } from "./dev/createDevServer.js";
|
|
7
|
+
import { watchTamaguiConfig } from "./tamaguiConfigUtils.js";
|
|
8
|
+
import { registerDispose } from "./utils.js";
|
|
9
|
+
const dev = async (options) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const { root, mode, paths } = options;
|
|
12
|
+
process.chdir(process.cwd());
|
|
13
|
+
const { tamaguiPlugin, nativePlugin, nativePrebuild } = await import("@tamagui/vite-plugin");
|
|
14
|
+
await nativePrebuild();
|
|
15
|
+
const plugins = [
|
|
16
|
+
tamaguiPlugin({
|
|
17
|
+
components: ["tamagui"]
|
|
18
|
+
}),
|
|
19
|
+
nativePlugin()
|
|
20
|
+
];
|
|
21
|
+
async function getBundle() {
|
|
22
|
+
const outputJsPath = join(process.cwd(), ".tamagui", "bundle.js");
|
|
23
|
+
const outputCode = await getBundleCode();
|
|
24
|
+
fs.writeFile(outputJsPath, outputCode);
|
|
25
|
+
return outputCode;
|
|
26
|
+
}
|
|
27
|
+
async function getBundleCode() {
|
|
28
|
+
const buildOutput = await build({
|
|
29
|
+
plugins,
|
|
30
|
+
appType: "custom",
|
|
31
|
+
root: join(root, "src/index.ts"),
|
|
32
|
+
build: {
|
|
33
|
+
ssr: true
|
|
34
|
+
},
|
|
35
|
+
ssr: {
|
|
36
|
+
format: "cjs",
|
|
37
|
+
target: "node"
|
|
38
|
+
},
|
|
39
|
+
mode: "development",
|
|
40
|
+
define: {
|
|
41
|
+
__DEV__: "true",
|
|
42
|
+
"process.env.NODE_ENV": `"development"`
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
const appCode = "output" in buildOutput ? buildOutput.output[0].code : null;
|
|
46
|
+
if (!appCode) {
|
|
47
|
+
throw `\u274C`;
|
|
48
|
+
}
|
|
49
|
+
const [react, reactJsxRuntime, reactNative] = await Promise.all([
|
|
50
|
+
readFile(join(process.cwd(), "react.js"), "utf-8"),
|
|
51
|
+
readFile(join(process.cwd(), "react-jsx-runtime.js"), "utf-8"),
|
|
52
|
+
readFile(join(process.cwd(), "react-native.js"), "utf-8")
|
|
53
|
+
]);
|
|
54
|
+
const reactCode = react.replace(
|
|
55
|
+
`module.exports = require_react_development();`,
|
|
56
|
+
`return require_react_development()`
|
|
57
|
+
);
|
|
58
|
+
const reactJSXRuntimeCode = reactJsxRuntime.replace(
|
|
59
|
+
`module.exports = require_react_jsx_runtime_production_min();`,
|
|
60
|
+
`return require_react_jsx_runtime_production_min()`
|
|
61
|
+
);
|
|
62
|
+
const reactNativeCode = reactNative.replace(
|
|
63
|
+
`module.exports = require_react_native();`,
|
|
64
|
+
`return require_react_native()`
|
|
65
|
+
).replace(
|
|
66
|
+
`renderable = /* @__PURE__ */ react(RootComponentWithMeaningfulName, null, renderable);`,
|
|
67
|
+
``
|
|
68
|
+
);
|
|
69
|
+
return (await readFile("template.js", "utf-8")).replace(`// -- react --`, reactCode).replace(`// -- react-native --`, reactNativeCode).replace(`// -- react/jsx-runtime --`, reactJSXRuntimeCode).replace(`// -- app --`, appCode);
|
|
70
|
+
}
|
|
71
|
+
const server = await createServer({
|
|
72
|
+
root,
|
|
73
|
+
mode: "development",
|
|
74
|
+
plugins,
|
|
75
|
+
server: {
|
|
76
|
+
port: options.port,
|
|
77
|
+
host: options.host || "localhost"
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
await server.listen();
|
|
81
|
+
await watchTamaguiConfig(options);
|
|
82
|
+
const info = (_a = server.httpServer) == null ? void 0 : _a.address();
|
|
83
|
+
const port = 8081;
|
|
84
|
+
const defaultResponse = {
|
|
85
|
+
name: "myapp",
|
|
86
|
+
slug: "myapp",
|
|
87
|
+
scheme: "myapp",
|
|
88
|
+
version: "1.0.0",
|
|
89
|
+
jsEngine: "jsc",
|
|
90
|
+
orientation: "portrait",
|
|
91
|
+
icon: "./assets/icon.png",
|
|
92
|
+
userInterfaceStyle: "light",
|
|
93
|
+
splash: {
|
|
94
|
+
image: "./assets/splash.png",
|
|
95
|
+
resizeMode: "contain",
|
|
96
|
+
backgroundColor: "#ffffff",
|
|
97
|
+
imageUrl: "http://127.0.0.1:8081/assets/./assets/splash.png"
|
|
98
|
+
},
|
|
99
|
+
updates: { fallbackToCacheTimeout: 0 },
|
|
100
|
+
assetBundlePatterns: ["**/*"],
|
|
101
|
+
ios: { supportsTablet: true, bundleIdentifier: "com.natew.myapp" },
|
|
102
|
+
android: {
|
|
103
|
+
package: "com.tamagui.myapp",
|
|
104
|
+
adaptiveIcon: {
|
|
105
|
+
foregroundImage: "./assets/adaptive-icon.png",
|
|
106
|
+
backgroundColor: "#FFFFFF",
|
|
107
|
+
foregroundImageUrl: "http://127.0.0.1:8081/assets/./assets/adaptive-icon.png"
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
web: { favicon: "./assets/favicon.png" },
|
|
111
|
+
extra: { eas: { projectId: "061b4470-78c7-4d6a-b850-8167fb0a3434" } },
|
|
112
|
+
_internal: {
|
|
113
|
+
isDebug: false,
|
|
114
|
+
projectRoot: "/Users/n8/tamagui/apps/kitchen-sink",
|
|
115
|
+
dynamicConfigPath: null,
|
|
116
|
+
staticConfigPath: "/Users/n8/tamagui/apps/kitchen-sink/app.json",
|
|
117
|
+
packageJsonPath: "/Users/n8/tamagui/apps/kitchen-sink/package.json"
|
|
118
|
+
},
|
|
119
|
+
sdkVersion: "47.0.0",
|
|
120
|
+
platforms: ["ios", "android", "web"],
|
|
121
|
+
iconUrl: `http://127.0.0.1:${port}/assets/./assets/icon.png`,
|
|
122
|
+
debuggerHost: `127.0.0.1:${port}`,
|
|
123
|
+
logUrl: `http://127.0.0.1:${port}/logs`,
|
|
124
|
+
developer: { tool: "expo-cli", projectRoot: "/Users/n8/tamagui/apps/kitchen-sink" },
|
|
125
|
+
packagerOpts: { dev: true },
|
|
126
|
+
mainModuleName: "index",
|
|
127
|
+
__flipperHack: "React Native packager is running",
|
|
128
|
+
hostUri: `127.0.0.1:${port}`,
|
|
129
|
+
bundleUrl: `http://127.0.0.1:${port}/index.bundle?platform=ios&dev=true&hot=false`,
|
|
130
|
+
id: "@anonymous/myapp-473c4543-3c36-4786-9db1-c66a62ac9b78"
|
|
131
|
+
};
|
|
132
|
+
const dispose = await createDevServer(options, {
|
|
133
|
+
getIndexBundle: getBundle,
|
|
134
|
+
indexJson: defaultResponse
|
|
135
|
+
});
|
|
136
|
+
console.log(`Listening on:`, chalk.green(`http://localhost:${port}`));
|
|
137
|
+
server.printUrls();
|
|
138
|
+
registerDispose(() => {
|
|
139
|
+
dispose();
|
|
140
|
+
server.close();
|
|
141
|
+
});
|
|
142
|
+
await new Promise((res) => {
|
|
143
|
+
var _a2;
|
|
144
|
+
return (_a2 = server.httpServer) == null ? void 0 : _a2.on("close", res);
|
|
145
|
+
});
|
|
146
|
+
console.log("closed");
|
|
147
|
+
};
|
|
148
|
+
export {
|
|
149
|
+
dev
|
|
150
|
+
};
|
|
151
|
+
//# sourceMappingURL=dev.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/dev.ts"],
|
|
4
|
+
"sourcesContent": ["import { readFile } from 'fs/promises'\nimport { AddressInfo } from 'net'\nimport { join } from 'path'\n\nimport chalk from 'chalk'\nimport fs from 'fs-extra'\nimport { build, createServer } from 'vite'\n\nimport { createDevServer } from './dev/createDevServer.js'\nimport { watchTamaguiConfig } from './tamaguiConfigUtils.js'\nimport { ResolvedOptions } from './types.js'\nimport { registerDispose } from './utils.js'\n\nexport const dev = async (options: ResolvedOptions) => {\n const { root, mode, paths } = options\n\n process.chdir(process.cwd())\n\n const { tamaguiPlugin, nativePlugin, nativePrebuild } = await import(\n '@tamagui/vite-plugin'\n )\n\n // build react-native\n await nativePrebuild()\n\n const plugins = [\n tamaguiPlugin({\n components: ['tamagui'],\n }),\n nativePlugin(),\n ]\n\n async function getBundle() {\n const outputJsPath = join(process.cwd(), '.tamagui', 'bundle.js')\n const outputCode = await getBundleCode()\n // debug out each time\n fs.writeFile(outputJsPath, outputCode)\n return outputCode\n }\n\n async function getBundleCode() {\n // build app\n const buildOutput = await build({\n plugins,\n appType: 'custom',\n root: join(root, 'src/index.ts'),\n build: {\n ssr: true,\n },\n ssr: {\n format: 'cjs',\n target: 'node',\n },\n mode: 'development',\n define: {\n __DEV__: 'true',\n 'process.env.NODE_ENV': `\"development\"`,\n },\n })\n\n const appCode = 'output' in buildOutput ? buildOutput.output[0].code : null\n\n if (!appCode) {\n throw `\u274C`\n }\n\n const [react, reactJsxRuntime, reactNative] = await Promise.all([\n readFile(join(process.cwd(), 'react.js'), 'utf-8'),\n readFile(join(process.cwd(), 'react-jsx-runtime.js'), 'utf-8'),\n readFile(join(process.cwd(), 'react-native.js'), 'utf-8'),\n ])\n\n const reactCode = react.replace(\n `module.exports = require_react_development();`,\n `return require_react_development()`\n )\n\n const reactJSXRuntimeCode = reactJsxRuntime.replace(\n `module.exports = require_react_jsx_runtime_production_min();`,\n `return require_react_jsx_runtime_production_min()`\n )\n\n const reactNativeCode = reactNative\n .replace(\n `module.exports = require_react_native();`,\n `return require_react_native()`\n )\n .replace(\n `renderable = /* @__PURE__ */ react(RootComponentWithMeaningfulName, null, renderable);`,\n ``\n )\n\n return (await readFile('template.js', 'utf-8'))\n .replace(`// -- react --`, reactCode)\n .replace(`// -- react-native --`, reactNativeCode)\n .replace(`// -- react/jsx-runtime --`, reactJSXRuntimeCode)\n .replace(`// -- app --`, appCode)\n }\n\n const server = await createServer({\n root: root,\n mode: 'development',\n plugins,\n server: {\n port: options.port,\n host: options.host || 'localhost',\n },\n })\n\n await server.listen()\n await watchTamaguiConfig(options)\n\n const info = server.httpServer?.address() as AddressInfo\n\n // react native port (it scans 19000 +5)\n const port = 8081\n\n const defaultResponse = {\n name: 'myapp',\n slug: 'myapp',\n scheme: 'myapp',\n version: '1.0.0',\n jsEngine: 'jsc',\n orientation: 'portrait',\n icon: './assets/icon.png',\n userInterfaceStyle: 'light',\n splash: {\n image: './assets/splash.png',\n resizeMode: 'contain',\n backgroundColor: '#ffffff',\n imageUrl: 'http://127.0.0.1:8081/assets/./assets/splash.png',\n },\n updates: { fallbackToCacheTimeout: 0 },\n assetBundlePatterns: ['**/*'],\n ios: { supportsTablet: true, bundleIdentifier: 'com.natew.myapp' },\n android: {\n package: 'com.tamagui.myapp',\n adaptiveIcon: {\n foregroundImage: './assets/adaptive-icon.png',\n backgroundColor: '#FFFFFF',\n foregroundImageUrl: 'http://127.0.0.1:8081/assets/./assets/adaptive-icon.png',\n },\n },\n web: { favicon: './assets/favicon.png' },\n extra: { eas: { projectId: '061b4470-78c7-4d6a-b850-8167fb0a3434' } },\n _internal: {\n isDebug: false,\n projectRoot: '/Users/n8/tamagui/apps/kitchen-sink',\n dynamicConfigPath: null,\n staticConfigPath: '/Users/n8/tamagui/apps/kitchen-sink/app.json',\n packageJsonPath: '/Users/n8/tamagui/apps/kitchen-sink/package.json',\n },\n sdkVersion: '47.0.0',\n platforms: ['ios', 'android', 'web'],\n iconUrl: `http://127.0.0.1:${port}/assets/./assets/icon.png`,\n debuggerHost: `127.0.0.1:${port}`,\n logUrl: `http://127.0.0.1:${port}/logs`,\n developer: { tool: 'expo-cli', projectRoot: '/Users/n8/tamagui/apps/kitchen-sink' },\n packagerOpts: { dev: true },\n mainModuleName: 'index',\n __flipperHack: 'React Native packager is running',\n hostUri: `127.0.0.1:${port}`,\n bundleUrl: `http://127.0.0.1:${port}/index.bundle?platform=ios&dev=true&hot=false`,\n id: '@anonymous/myapp-473c4543-3c36-4786-9db1-c66a62ac9b78',\n }\n\n // new server\n const dispose = await createDevServer(options, {\n getIndexBundle: getBundle,\n indexJson: defaultResponse,\n })\n\n // eslint-disable-next-line no-console\n console.log(`Listening on:`, chalk.green(`http://localhost:${port}`))\n server.printUrls()\n\n registerDispose(() => {\n dispose()\n server.close()\n })\n\n await new Promise((res) => server.httpServer?.on('close', res))\n\n console.log('closed')\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,gBAAgB;AAEzB,SAAS,YAAY;AAErB,OAAO,WAAW;AAClB,OAAO,QAAQ;AACf,SA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AK,EAAE,SAAS,uBAAuB;AAAA,IACvC,OAAO,EAAE,KAAK,EAAE,WAAW,uCAAuC,EAAE;AAAA,IACpE,WAAW;AAAA,MACT,SAAS;AAAA,MACT,aAAa;AAAA,MACb,mBAAmB;AAAA,MACnB,kBAAkB;AAAA,MAClB,iBAAiB;AAAA,IACnB;AAAA,IACA,YAAY;AAAA,IACZ,WAAW,CAAC,OAAO,WAAW,KAAK;AAAA,IACnC,SAAS,oBAAoB;AAAA,IAC7B,cAAc,aAAa;AAAA,IAC3B,QAAQ,oBAAoB;AAAA,IAC5B,WAAW,EAAE,MAAM,YAAY,aAAa,sCAAsC;AAAA,IAClF,cAAc,EAAE,KAAK,KAAK;AAAA,IAC1B,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,SAAS,aAAa;AAAA,IACtB,WAAW,oBAAoB;AAAA,IAC/B,IAAI;AAAA,EACN;AAGA,QAAM,UAAU,MAAM,gBAAgB,SAAS;AAAA,IAC7C,gBAAgB;AAAA,IAChB,WAAW;AAAA,EACb,CAAC;AAGD,UAAQ,IAAI,iBAAiB,MAAM,MAAM,oBAAoB,MAAM,CAAC;AACpE,SAAO,UAAU;AAEjB,kBAAgB,MAAM;AACpB,YAAQ;AACR,WAAO,MAAM;AAAA,EACf,CAAC;AAED,QAAM,IAAI,QAAQ,CAAC,QAAK;AArL1B,QAAAA;AAqL6B,YAAAA,MAAA,OAAO,eAAP,gBAAAA,IAAmB,GAAG,SAAS;AAAA,GAAI;AAE9D,UAAQ,IAAI,QAAQ;AACtB;",
|
|
6
|
+
"names": ["_a"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import { Project } from "ts-morph";
|
|
4
|
+
import { loadTamagui } from "./utils.js";
|
|
5
|
+
async function generateTypes(options) {
|
|
6
|
+
const types = await getTypes(options);
|
|
7
|
+
await fs.writeJSON(options.paths.types, types, {
|
|
8
|
+
spaces: 2
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
async function getTypes(options) {
|
|
12
|
+
const tamagui = await loadTamagui(options.tamaguiOptions);
|
|
13
|
+
const uniqueViewExportingPaths = new Set(
|
|
14
|
+
Object.keys(tamagui.nameToPaths).map((name) => {
|
|
15
|
+
return `${[...tamagui.nameToPaths[name]][0]}.ts*`;
|
|
16
|
+
})
|
|
17
|
+
);
|
|
18
|
+
const project = new Project({
|
|
19
|
+
compilerOptions: {
|
|
20
|
+
noEmit: false,
|
|
21
|
+
declaration: true,
|
|
22
|
+
emitDeclarationOnly: true
|
|
23
|
+
},
|
|
24
|
+
skipAddingFilesFromTsConfig: true,
|
|
25
|
+
tsConfigFilePath: options.tsconfigPath
|
|
26
|
+
});
|
|
27
|
+
const files = project.addSourceFilesAtPaths([...uniqueViewExportingPaths]);
|
|
28
|
+
return Object.fromEntries(
|
|
29
|
+
files.flatMap((x) => {
|
|
30
|
+
return [...x.getExportedDeclarations()].map(([k, v]) => {
|
|
31
|
+
return [
|
|
32
|
+
k,
|
|
33
|
+
v[0].getType().getApparentType().getProperties().map((prop) => {
|
|
34
|
+
var _a;
|
|
35
|
+
return [
|
|
36
|
+
prop.getEscapedName(),
|
|
37
|
+
(_a = prop.getValueDeclaration()) == null ? void 0 : _a.getType().getText()
|
|
38
|
+
];
|
|
39
|
+
})
|
|
40
|
+
];
|
|
41
|
+
});
|
|
42
|
+
})
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
generateTypes,
|
|
47
|
+
getTypes
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=generate.mjs.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 [\n prop.getEscapedName(),\n prop.getValueDeclaration()?.getType().getText(),\n ]\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": ";AAEA,OAAO,QAAQ;AACf,SAAS,eAAe;AAGxB,SAAS,mBAAmB;AAE5B,eAAsB,cAAc,SAA0B;AAC5D,QAAM,QAAQ,MAAM,SAAS,OAAO;AACpC,QAAM,GAAG,UAAU,QAAQ,MAAM,OAAO,OAAO;AAAA,IAC7C,QAAQ;AAAA,EACV,CAAC;AACH;AAEA,eAAsB,SAAS,SAA0B;AACvD,QAAM,UAAU,MAAM,YAAY,QAAQ,cAAc;AAExD,QAAM,2BAA2B,IAAI;AAAA,IACnC,OAAO,KAAK,QAAQ,WAAW,EA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