@lytjs/cli 4.0.1 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +99 -98
- package/dist/index.mjs +99 -98
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var rt=Object.create;var E=Object.defineProperty;var st=Object.getOwnPropertyDescriptor;var it=Object.getOwnPropertyNames;var at=Object.getPrototypeOf,lt=Object.prototype.hasOwnProperty;var ct=(t,o)=>{for(var n in o)E(t,n,{get:o[n],enumerable:!0})},z=(t,o,n,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of it(o))!lt.call(t,s)&&s!==n&&E(t,s,{get:()=>o[s],enumerable:!(r=st(o,s))||r.enumerable});return t};var h=(t,o,n)=>(n=t!=null?rt(at(t)):{},z(o||!t||!t.__esModule?E(n,"default",{value:t,enumerable:!0}):n,t)),pt=t=>z(E({},"__esModule",{value:!0}),t);var Qt={};ct(Qt,{createHMREndpoint:()=>I,createHMRServer:()=>V,createProject:()=>D,getHMRClientScript:()=>B});module.exports=pt(Qt);var et=h(require("fs")),ot=h(require("path"));var v=h(require("fs")),W=h(require("path")),ut="\x1B[0m",ft={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",strikethrough:"\x1B[9m"};function e(t,o){let n=ft[o];return n?`${n}${t}${ut}`:t}function Y(t){let o=t.slice(2),n={command:"",args:[],options:{},raw:o},r=0;for(;r<o.length;){let s=o[r];if(s==="--help"||s==="-h")n.options.help=!0,r++;else if(s==="--version"||s==="-v")n.options.version=!0,r++;else if(s.startsWith("--")){let l=s.indexOf("=");if(l!==-1){let f=s.slice(2,l),p=s.slice(l+1);n.options[f]=p}else{let f=s.slice(2),p=o[r+1];p&&!p.startsWith("-")?(n.options[f]=p,r++):n.options[f]=!0}r++}else if(s.startsWith("-")&&s.length>1){let l=s.slice(1),f=o[r+1];f&&!f.startsWith("-")?(n.options[l]=f,r++):n.options[l]=!0,r++}else n.command?(n.args.push(s),r++):(n.command=s,r++)}return n}function S(t){v.existsSync(t)||v.mkdirSync(t,{recursive:!0})}function T(t){return v.existsSync(t)}function R(t){return v.readFileSync(t,"utf-8")}function j(t,o){let n=W.dirname(t);S(n),v.writeFileSync(t,o,"utf-8")}var i={info(t){console.log(`${e("[INFO]","blue")} ${t}`)},warn(t){console.log(`${e("[WARN]","yellow")} ${t}`)},error(t){console.error(`${e("[ERROR]","red")} ${t}`)},success(t){console.log(`${e("[SUCCESS]","green")} ${t}`)}};var O=h(require("path"));function dt(){return`<!DOCTYPE html>
|
|
3
3
|
<html lang="zh-CN">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>Lyt App</title>
|
|
8
|
+
<link rel="stylesheet" href="/src/style.css" />
|
|
8
9
|
</head>
|
|
9
10
|
<body>
|
|
10
11
|
<div id="app"></div>
|
|
11
12
|
<script type="module" src="/src/main.ts"></script>
|
|
12
13
|
</body>
|
|
13
14
|
</html>
|
|
14
|
-
`}function
|
|
15
|
+
`}function gt(){return`import { createApp } from '@lytjs/lytjs';
|
|
15
16
|
import App from './App';
|
|
16
17
|
|
|
17
18
|
// \u521B\u5EFA\u5E94\u7528\u5B9E\u4F8B
|
|
@@ -19,7 +20,7 @@ const app = createApp(App);
|
|
|
19
20
|
|
|
20
21
|
// \u5C06\u5E94\u7528\u6302\u8F7D\u5230 #app \u5143\u7D20
|
|
21
22
|
app.mount('#app');
|
|
22
|
-
`}function
|
|
23
|
+
`}function mt(){return`import { defineComponent } from '@lytjs/lytjs';
|
|
23
24
|
|
|
24
25
|
// \u5B9A\u4E49\u6839\u7EC4\u4EF6
|
|
25
26
|
const App = defineComponent({
|
|
@@ -44,7 +45,7 @@ const App = defineComponent({
|
|
|
44
45
|
});
|
|
45
46
|
|
|
46
47
|
export default App;
|
|
47
|
-
`}function
|
|
48
|
+
`}function ht(){return`/* Lyt \u5168\u5C40\u6837\u5F0F */
|
|
48
49
|
|
|
49
50
|
* {
|
|
50
51
|
margin: 0;
|
|
@@ -75,9 +76,9 @@ body {
|
|
|
75
76
|
font-size: 1.2rem;
|
|
76
77
|
color: #666;
|
|
77
78
|
}
|
|
78
|
-
`}function
|
|
79
|
-
`}function
|
|
80
|
-
`}function
|
|
79
|
+
`}function yt(t){return JSON.stringify({name:t,version:"0.1.0",private:!0,type:"module",scripts:{dev:"lyt dev",build:"lyt build",preview:"lyt preview"},dependencies:{"@lytjs/lytjs":"latest"},devDependencies:{"@lytjs/cli":"latest",typescript:"^5.0.0"}},null,2)+`
|
|
80
|
+
`}function bt(){return JSON.stringify({compilerOptions:{target:"ES2020",module:"ESNext",moduleResolution:"bundler",strict:!0,jsx:"preserve",resolveJsonModule:!0,isolatedModules:!0,esModuleInterop:!0,lib:["ES2020","DOM","DOM.Iterable"],skipLibCheck:!0,noEmit:!0,paths:{"@/*":["./src/*"]}},include:["src/**/*.ts","src/**/*.tsx"],exclude:["node_modules","dist"]},null,2)+`
|
|
81
|
+
`}function xt(){return`# \u4F9D\u8D56
|
|
81
82
|
node_modules/
|
|
82
83
|
|
|
83
84
|
# \u6784\u5EFA\u8F93\u51FA
|
|
@@ -100,25 +101,25 @@ Thumbs.db
|
|
|
100
101
|
# \u65E5\u5FD7
|
|
101
102
|
*.log
|
|
102
103
|
npm-debug.log*
|
|
103
|
-
`}async function
|
|
104
|
-
`}function
|
|
105
|
-
`}function
|
|
104
|
+
`}async function _(t,o={}){let n=o.template||"spa",r=O.resolve(process.cwd(),t);i.info(`\u6B63\u5728\u521B\u5EFA Lyt \u9879\u76EE: ${e(t,"brightCyan")}`),i.info(`\u4F7F\u7528\u6A21\u677F: ${e(n,"brightCyan")}`),T(r)&&(i.error(`\u76EE\u5F55 "${t}" \u5DF2\u5B58\u5728\uFF0C\u8BF7\u9009\u62E9\u5176\u4ED6\u540D\u79F0\u6216\u5220\u9664\u5DF2\u6709\u76EE\u5F55`),process.exit(1)),S(r);let s=[{filePath:"index.html",content:dt()},{filePath:"src/main.ts",content:gt()},{filePath:"src/App.ts",content:mt()},{filePath:"src/style.css",content:ht()},{filePath:"package.json",content:yt(t)},{filePath:"tsconfig.json",content:bt()},{filePath:".gitignore",content:xt()}];for(let l of s){let f=O.join(r,l.filePath);j(f,l.content),i.success(` \u521B\u5EFA ${l.filePath}`)}console.log(""),i.success(`\u9879\u76EE ${e(t,"brightCyan")} \u521B\u5EFA\u6210\u529F\uFF01`),console.log(""),console.log(" \u8BF7\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u542F\u52A8\u9879\u76EE\uFF1A"),console.log(""),console.log(` ${e("cd","brightGreen")} ${t}`),console.log(` ${e("npm install","brightGreen")}`),console.log(` ${e("npm run dev","brightGreen")}`),console.log("")}var L=h(require("path"));function vt(t){let o={name:t.name,version:"0.1.0",private:!0,type:"module",scripts:{dev:"lytx dev",build:"lytx build",preview:"lytx preview"},dependencies:{"@lytjs/lytjs":"latest"}};return t.ts&&(o.devDependencies={"@lytjs/cli":"latest",typescript:"^5.0.0"}),t.eslint&&(o.devDependencies=o.devDependencies||{},o.devDependencies.eslint="^8.0.0",o.scripts=o.scripts||{},o.scripts.lint="eslint src --ext .ts,.js"),t.router&&(o.dependencies["@lytjs/router"]="latest"),t.store&&(o.dependencies["@lytjs/store"]="latest"),JSON.stringify(o,null,2)+`
|
|
105
|
+
`}function $t(t){let o={compilerOptions:{target:"ES2020",module:"ESNext",moduleResolution:"bundler",strict:!0,jsx:"preserve",resolveJsonModule:!0,isolatedModules:!0,esModuleInterop:!0,lib:["ES2020","DOM","DOM.Iterable"],skipLibCheck:!0,noEmit:!0,paths:{"@/*":["./src/*"]}},include:["src/**/*.ts","src/**/*.tsx"],exclude:["node_modules","dist"]};return t.template==="ssr"&&(o.compilerOptions.types=["node"]),JSON.stringify(o,null,2)+`
|
|
106
|
+
`}function wt(t){let o=t.ts?".ts":".js";return`<!DOCTYPE html>
|
|
106
107
|
<html lang="zh-CN">
|
|
107
108
|
<head>
|
|
108
109
|
<meta charset="UTF-8" />
|
|
109
110
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
110
111
|
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
|
|
111
|
-
<title>${
|
|
112
|
+
<title>${t.name}</title>
|
|
112
113
|
</head>
|
|
113
114
|
<body>
|
|
114
115
|
<div id="app"></div>
|
|
115
|
-
<script type="module" src="/src/main${
|
|
116
|
+
<script type="module" src="/src/main${o}"></script>
|
|
116
117
|
</body>
|
|
117
118
|
</html>
|
|
118
|
-
`}function
|
|
119
|
-
`)}function
|
|
119
|
+
`}function St(t){let o=["// Lytx \u914D\u7F6E\u6587\u4EF6","import { defineConfig } from '@lytjs/lytjs'","","export default defineConfig({"," // \u6784\u5EFA\u6A21\u5F0F",` mode: '${t.template}',`];return t.router&&(o.push(" // \u8DEF\u7531\u914D\u7F6E"),o.push(" router: {"),o.push(" historyMode: true,"),o.push(" },")),t.store&&(o.push(" // \u72B6\u6001\u7BA1\u7406\u914D\u7F6E"),o.push(" store: {"),o.push(" strict: true,"),o.push(" },")),o.push("})"),o.push(""),o.join(`
|
|
120
|
+
`)}function Ct(t){let o=t.ts?".ts":".js",n=["import { createApp } from '@lytjs/lytjs'","import App from './App.lyt'","import './styles/main.css'"];return t.router&&n.push("import { router } from './router'"),t.store&&n.push("import { store } from './store'"),n.push(""),n.push("// \u521B\u5EFA\u5E94\u7528\u5B9E\u4F8B"),n.push("const app = createApp(App)"),t.router&&n.push("app.use(router)"),t.store&&n.push("app.use(store)"),n.push(""),n.push("// \u5C06\u5E94\u7528\u6302\u8F7D\u5230 #app \u5143\u7D20"),n.push("app.mount('#app')"),n.join(`
|
|
120
121
|
`)+`
|
|
121
|
-
`}function
|
|
122
|
+
`}function jt(){return`<template>
|
|
122
123
|
<div class="app">
|
|
123
124
|
<Header />
|
|
124
125
|
<main>
|
|
@@ -146,7 +147,7 @@ export default defineComponent({
|
|
|
146
147
|
padding: 20px;
|
|
147
148
|
}
|
|
148
149
|
</style>
|
|
149
|
-
`}function
|
|
150
|
+
`}function Pt(){return`import { defineComponent } from '@lytjs/lytjs'
|
|
150
151
|
|
|
151
152
|
export default defineComponent({
|
|
152
153
|
name: 'HomePage',
|
|
@@ -158,7 +159,7 @@ export default defineComponent({
|
|
|
158
159
|
</div>
|
|
159
160
|
\`,
|
|
160
161
|
})
|
|
161
|
-
`}function
|
|
162
|
+
`}function Mt(){return`import { defineComponent } from '@lytjs/lytjs'
|
|
162
163
|
|
|
163
164
|
export default defineComponent({
|
|
164
165
|
name: 'AboutPage',
|
|
@@ -170,7 +171,7 @@ export default defineComponent({
|
|
|
170
171
|
</div>
|
|
171
172
|
\`,
|
|
172
173
|
})
|
|
173
|
-
`}function
|
|
174
|
+
`}function Rt(){return`import { defineComponent } from '@lytjs/lytjs'
|
|
174
175
|
|
|
175
176
|
export default defineComponent({
|
|
176
177
|
name: 'Header',
|
|
@@ -184,7 +185,7 @@ export default defineComponent({
|
|
|
184
185
|
</header>
|
|
185
186
|
\`,
|
|
186
187
|
})
|
|
187
|
-
`}function
|
|
188
|
+
`}function Ht(){return`import { createRouter, createWebHistory } from '@lytjs/router'
|
|
188
189
|
import HomePage from '../pages/index'
|
|
189
190
|
import AboutPage from '../pages/about'
|
|
190
191
|
|
|
@@ -201,7 +202,7 @@ export const router = createRouter({
|
|
|
201
202
|
},
|
|
202
203
|
],
|
|
203
204
|
})
|
|
204
|
-
`}function
|
|
205
|
+
`}function At(){return`import { createStore } from '@lytjs/store'
|
|
205
206
|
|
|
206
207
|
export const store = createStore({
|
|
207
208
|
state: {
|
|
@@ -229,7 +230,7 @@ export const store = createStore({
|
|
|
229
230
|
doubleCount: (state: any) => state.count * 2,
|
|
230
231
|
},
|
|
231
232
|
})
|
|
232
|
-
`}function
|
|
233
|
+
`}function kt(){return`/* \u5168\u5C40\u6837\u5F0F */
|
|
233
234
|
|
|
234
235
|
* {
|
|
235
236
|
margin: 0;
|
|
@@ -253,17 +254,17 @@ a {
|
|
|
253
254
|
a:hover {
|
|
254
255
|
text-decoration: underline;
|
|
255
256
|
}
|
|
256
|
-
`}function
|
|
257
|
+
`}function Ft(){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
|
|
257
258
|
<rect width="32" height="32" rx="6" fill="#42b883"/>
|
|
258
259
|
<text x="16" y="22" text-anchor="middle" fill="white" font-size="18" font-weight="bold">L</text>
|
|
259
260
|
</svg>
|
|
260
|
-
`}function
|
|
261
|
-
`}async function D(
|
|
261
|
+
`}function Et(){return JSON.stringify({root:!0,env:{browser:!0,es2021:!0,node:!0},extends:["eslint:recommended"],parserOptions:{ecmaVersion:"latest",sourceType:"module"},rules:{"no-unused-vars":"warn","no-console":"warn"}},null,2)+`
|
|
262
|
+
`}async function D(t){let{name:o,template:n,ts:r,router:s,store:l,eslint:f}=t,p=L.resolve(process.cwd(),o);if(i.info(`\u6B63\u5728\u521B\u5EFA Lyt \u9879\u76EE: ${e(o,"brightCyan")}`),i.info(`\u4F7F\u7528\u6A21\u677F: ${e(n,"brightCyan")}`),T(p))throw i.error(`\u76EE\u5F55 "${o}" \u5DF2\u5B58\u5728\uFF0C\u8BF7\u9009\u62E9\u5176\u4ED6\u540D\u79F0\u6216\u5220\u9664\u5DF2\u6709\u76EE\u5F55`),new Error(`Directory "${o}" already exists`);S(p);let u=[{filePath:"package.json",content:vt(t)},{filePath:"index.html",content:wt(t)},{filePath:"lytx.config.ts",content:St(t)},{filePath:"src/main.ts",content:Ct(t)},{filePath:"src/App.lyt",content:jt()},{filePath:"src/pages/index.ts",content:Pt()},{filePath:"src/pages/about.ts",content:Mt()},{filePath:"src/components/Header.ts",content:Rt()},{filePath:"src/styles/main.css",content:kt()},{filePath:"public/favicon.svg",content:Ft()}];r&&u.push({filePath:"tsconfig.json",content:$t(t)}),s&&u.push({filePath:"src/router/index.ts",content:Ht()}),l&&u.push({filePath:"src/store/index.ts",content:At()}),f&&u.push({filePath:".eslintrc.json",content:Et()});for(let c of u){let d=L.join(p,c.filePath);j(d,c.content),i.success(` \u521B\u5EFA ${c.filePath}`)}console.log(""),i.success(`\u9879\u76EE ${e(o,"brightCyan")} \u521B\u5EFA\u6210\u529F\uFF01`),console.log(""),console.log(" \u8BF7\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u542F\u52A8\u9879\u76EE\uFF1A"),console.log(""),console.log(` ${e("cd","brightGreen")} ${o}`),console.log(` ${e("npm install","brightGreen")}`),console.log(` ${e("npm run dev","brightGreen")}`),console.log("")}var K=h(require("http")),P=h(require("fs")),b=h(require("path"));var J=h(require("http")),H=h(require("fs")),$=h(require("path")),q=h(require("crypto")),G=class{constructor(){this.clients=[]}handleUpgrade(o,n,r){let s=o.headers["sec-websocket-key"];if(!s){n.destroy();return}let l=q.createHash("sha1").update(s+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");n.write(`HTTP/1.1 101 Switching Protocols\r
|
|
262
263
|
Upgrade: websocket\r
|
|
263
264
|
Connection: Upgrade\r
|
|
264
265
|
Sec-WebSocket-Accept: ${l}\r
|
|
265
266
|
\r
|
|
266
|
-
`);let
|
|
267
|
+
`);let f={socket:n,isAlive:!0};n.on("close",()=>{this.clients=this.clients.filter(p=>p!==f)}),n.on("error",()=>{this.clients=this.clients.filter(p=>p!==f)}),this.clients.push(f)}broadcast(o){let n=[];for(let r of this.clients)try{if(!r.isAlive){n.push(r);continue}let s=Buffer.from(o,"utf-8"),l=this.createFrame(129,s);r.socket.write(l)}catch(s){n.push(r)}for(let r of n){this.clients=this.clients.filter(s=>s!==r);try{r.socket.destroy()}catch(s){}}}createFrame(o,n){let r=n.length,s;r<126?s=2:r<65536?s=4:s=10;let l=Buffer.alloc(s+r);return l[0]=o,r<126?l[1]=r:r<65536?(l[1]=126,l.writeUInt16BE(r,2)):(l[1]=127,l.writeUInt32BE(0,2),l.writeUInt32BE(r,6)),n.copy(l,s),l}getClientCount(){return this.clients.length}closeAll(){for(let o of this.clients)try{o.socket.destroy()}catch(n){}this.clients=[]}};function V(t){let o=new G,n=[],r=[],s=null,l=!1;function f(u){let c=$.extname(u).toLowerCase();if(c===".css")return"css";let d=$.basename(u);return d.startsWith("lytx.config")||d==="tsconfig.json"||d==="package.json"?"reload":c===".ts"||c===".tsx"||c===".lyt"||c===".js"||c===".jsx"?"update":"reload"}function p(u){try{let c=H.readdirSync(u,{withFileTypes:!0});for(let d of c){let a=$.join(u,d.name);if(d.isDirectory()){if(d.name==="node_modules"||d.name===".git"||d.name==="dist")continue;p(a)}else if(d.isFile()){let m=$.extname(d.name).toLowerCase();if(new Set([".ts",".tsx",".js",".jsx",".css",".html",".json",".lyt"]).has(m))try{let A=H.watch(a,{persistent:!1},N=>{if(N==="change"){let k=$.relative(t,a);for(let C of n)try{C(k)}catch(F){}let M=f(a),w={type:M,path:`/${k}`};if(M==="css")try{w.content=H.readFileSync(a,"utf-8")}catch(C){}o.broadcast(JSON.stringify(w))}});r.push(A)}catch(A){}}}}catch(c){}}return{start(u){l||(l=!0,s=J.createServer((c,d)=>{d.writeHead(426,{"Content-Type":"text/plain"}),d.end("Upgrade Required")}),s.on("upgrade",(c,d,a)=>{o.handleUpgrade(c,d,a)}),s.listen(u,()=>{}),p(t))},stop(){l=!1;for(let u of r)try{u.close()}catch(c){}if(r.length=0,o.closeAll(),s){try{s.close()}catch(u){}s=null}},onFileChange(u){n.push(u)},notifyClient(u){o.broadcast(JSON.stringify(u))}}}function I(t){let o=new G;return t.on("upgrade",(n,r,s)=>{o.handleUpgrade(n,r,s)}),{broadcast(n){o.broadcast(n)},getClientCount(){return o.getClientCount()}}}function B(){return`(function() {
|
|
267
268
|
'use strict';
|
|
268
269
|
|
|
269
270
|
var ws = null;
|
|
@@ -361,112 +362,112 @@ Sec-WebSocket-Accept: ${l}\r
|
|
|
361
362
|
|
|
362
363
|
// \u542F\u52A8\u8FDE\u63A5
|
|
363
364
|
connect();
|
|
364
|
-
})();`}var
|
|
365
|
-
</head>`)),{statusCode:200,headers:{"Content-Type":
|
|
366
|
-
${
|
|
365
|
+
})();`}var X;try{X=require("esbuild")}catch(t){i.error("\u7F3A\u5C11\u4F9D\u8D56: esbuild"),i.error(""),i.error(" Lyt CLI \u7684\u5F00\u53D1\u670D\u52A1\u5668\u9700\u8981 esbuild \u6765\u5B9E\u65F6\u7F16\u8BD1 TypeScript\u3002"),i.error(""),i.error(" \u8BF7\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u5B89\u88C5:"),i.error(` ${e("npm install esbuild --save-dev","brightGreen")}`),i.error(""),i.error(" \u5982\u679C\u60A8\u4F7F\u7528 pnpm:"),i.error(` ${e("pnpm add esbuild -D","brightGreen")}`),i.error(""),process.exit(1)}function Tt(t,o){try{return X.transformSync(t,{loader:"ts",target:"es2018",format:"esm",sourcemap:"inline"}).code}catch(n){let r=n instanceof Error?n.message:String(n);return console.error(`[Lyt CLI] \u7F16\u8BD1\u9519\u8BEF ${o||""}:`,r),t}}function Ot(t,o){var u;let n=((u=t.url)==null?void 0:u.split("?")[0])||"/";if(n==="/"&&(n="/index.html"),n.startsWith("/node_modules/")||n.startsWith("/@")){let c;if(n.startsWith("/@")&&!n.startsWith("/node_modules/")?c=b.join(o,"node_modules",n.slice(1)):c=b.join(o,n.slice(1)),n.match(/^\/(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/)&&!n.includes(".")){let d=b.join(c,"package.json");if(P.existsSync(d))try{let a=JSON.parse(R(d)),m=a.module||a.main||"index.js";a.exports&&(typeof a.exports=="string"?m=a.exports:typeof a.exports=="object"&&a.exports["."]&&(typeof a.exports["."]=="string"?m=a.exports["."]:a.exports["."].import?m=a.exports["."].import:a.exports["."].default?m=a.exports["."].default:Object.values(a.exports["."])[0]&&(m=Object.values(a.exports["."])[0]))),m.startsWith("./")&&(m=m.slice(2)),c=b.join(c,m)}catch(a){}}if(P.existsSync(c)&&P.statSync(c).isFile()){let d=b.extname(c).toLowerCase(),m={".js":"application/javascript; charset=utf-8",".mjs":"application/javascript; charset=utf-8",".json":"application/json; charset=utf-8"}[d]||"application/octet-stream",x=R(c);return{statusCode:200,headers:{"Content-Type":m},body:x}}}let r=b.join(o,n);if(!r.startsWith(o))return{statusCode:403,headers:{"Content-Type":"text/plain; charset=utf-8"},body:"403 Forbidden"};if(!P.existsSync(r)||!P.statSync(r).isFile())return{statusCode:404,headers:{"Content-Type":"text/plain; charset=utf-8"},body:"404 Not Found"};let s=b.extname(r).toLowerCase(),f={".html":"text/html; charset=utf-8",".css":"text/css; charset=utf-8",".js":"application/javascript; charset=utf-8",".mjs":"application/javascript; charset=utf-8",".ts":"application/typescript; charset=utf-8",".json":"application/json; charset=utf-8",".svg":"image/svg+xml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".txt":"text/plain; charset=utf-8"}[s]||"application/octet-stream",p=R(r);return(s===".ts"||s===".tsx")&&(p=Tt(p,n)),s===".html"&&(p=p.replace("</head>",`<script>${B()}</script>
|
|
366
|
+
</head>`)),{statusCode:200,headers:{"Content-Type":f},body:p}}function U(t={}){let o=t.port||3e3,n=b.resolve(t.root||process.cwd()),r=t.hmr!==!1,s=K.createServer((p,u)=>{let c=Ot(p,n);u.writeHead(c.statusCode,c.headers),u.end(c.body)}),l=r?I(s):null;s.listen(o,()=>{console.log(""),console.log(e(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557","brightCyan")),console.log(e(" \u2551","brightCyan")+e(" Lyt \u5F00\u53D1\u670D\u52A1\u5668\u5DF2\u542F\u52A8 ","brightWhite")+e("\u2551","brightCyan")),console.log(e(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D","brightCyan")),console.log(""),console.log(` ${e("\u279C","brightGreen")} \u672C\u5730\u8BBF\u95EE: ${e(`http://localhost:${o}`,"brightBlue")}`),console.log(` ${e("\u279C","brightGreen")} \u7F51\u7EDC\u8BBF\u95EE: ${e(`http://127.0.0.1:${o}`,"brightBlue")}`),console.log(` ${e("\u279C","brightGreen")} \u9879\u76EE\u76EE\u5F55: ${e(n,"brightBlue")}`),console.log(` ${e("\u279C","brightGreen")} \u70ED\u66F4\u65B0: ${e(r?"\u5DF2\u5F00\u542F":"\u5DF2\u5173\u95ED",r?"brightGreen":"brightRed")}`),console.log(""),console.log(` ${e("\u6309 Ctrl+C \u505C\u6B62\u670D\u52A1\u5668","dim")}`),console.log("")}),s.on("error",p=>{p.code==="EADDRINUSE"?(i.error(`\u7AEF\u53E3 ${o} \u5DF2\u88AB\u5360\u7528\uFF0C\u8BF7\u4F7F\u7528 --port \u6307\u5B9A\u5176\u4ED6\u7AEF\u53E3`),process.exit(1)):(i.error(`\u670D\u52A1\u5668\u542F\u52A8\u5931\u8D25: ${p.message}`),process.exit(1))});let f=()=>{i.info("\u6B63\u5728\u5173\u95ED\u5F00\u53D1\u670D\u52A1\u5668..."),s.close(()=>{i.success("\u670D\u52A1\u5668\u5DF2\u5173\u95ED"),process.exit(0)}),setTimeout(()=>{i.warn("\u670D\u52A1\u5668\u5173\u95ED\u8D85\u65F6\uFF0C\u5F3A\u5236\u9000\u51FA"),process.exit(1)},5e3)};process.on("SIGINT",f),process.on("SIGTERM",f)}var y=h(require("fs")),g=h(require("path"));var Q;try{Q=require("esbuild")}catch(t){i.error("\u7F3A\u5C11\u4F9D\u8D56: esbuild"),i.error(""),i.error(" Lyt CLI \u7684\u6784\u5EFA\u529F\u80FD\u9700\u8981 esbuild\u3002"),i.error(""),i.error(" \u8BF7\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u5B89\u88C5:"),i.error(` ${e("npm install esbuild --save-dev","brightGreen")}`),i.error(""),i.error(" \u5982\u679C\u60A8\u4F7F\u7528 pnpm:"),i.error(` ${e("pnpm add esbuild -D","brightGreen")}`),i.error(""),process.exit(1)}async function Z(t={}){let o=Date.now(),n=g.resolve(t.root||process.cwd()),r=g.resolve(n,t.outDir||"dist"),s=t.entry||"index.html",l=t.minify||!1;i.info("\u5F00\u59CB\u6784\u5EFA\u9879\u76EE..."),i.info(` \u6839\u76EE\u5F55: ${e(n,"brightCyan")}`),i.info(` \u8F93\u51FA\u76EE\u5F55: ${e(r,"brightCyan")}`),i.info(` \u538B\u7F29: ${e(l?"\u5F00\u542F":"\u5173\u95ED",l?"brightGreen":"brightYellow")}`);let f=g.join(n,s);y.existsSync(f)||(i.error(`\u5165\u53E3\u6587\u4EF6\u4E0D\u5B58\u5728: ${f}`),process.exit(1));let p=R(f),u=/<script\s+type="module"\s+src="([^"]+)"\s*><\/script>/g,c,d=[];for(;(c=u.exec(p))!==null;)d.push(c[1]);d.length===0&&i.warn("\u672A\u5728\u5165\u53E3 HTML \u4E2D\u627E\u5230\u6A21\u5757\u811A\u672C\u5F15\u7528");let a={inputFiles:0,outputFiles:0,totalSize:0,buildTime:0};S(r),S(g.join(r,"assets"));for(let x of d){let A=g.join(n,x);if(!y.existsSync(A)){i.warn(`\u811A\u672C\u6587\u4EF6\u4E0D\u5B58\u5728: ${x}`);continue}i.info(`\u6B63\u5728\u6253\u5305: ${e(x,"brightYellow")}`);let k=`${g.basename(x,g.extname(x))}.bundle.js`,M=g.join(r,"assets",k);try{await Q.build({entryPoints:[A],bundle:!0,minify:l,target:"es2018",format:"esm",outfile:M,sourcemap:!0,external:F=>F.startsWith("@lytjs/"),drop:l?["console"]:[],metafile:!0});let w=y.readFileSync(M,"utf-8");a.totalSize+=Buffer.byteLength(w,"utf-8"),a.outputFiles++;let C=M+".map";if(y.existsSync(C)){let F=y.readFileSync(C,"utf-8");a.totalSize+=Buffer.byteLength(F,"utf-8"),a.outputFiles++}p=p.replace(`<script type="module" src="${x}"></script>`,`<script src="/assets/${k}"></script>`),a.inputFiles++}catch(w){let C=w instanceof Error?w.message:String(w);i.error(`\u6253\u5305\u5931\u8D25 ${x}: ${C}`),process.exit(1)}}Lt(n,r,a);let m=g.join(r,"index.html");j(m,p),a.outputFiles++,a.totalSize+=Buffer.byteLength(p,"utf-8"),a.buildTime=Date.now()-o,console.log(""),i.success("\u6784\u5EFA\u5B8C\u6210\uFF01"),console.log(""),console.log(` ${e("\u8F93\u5165\u6587\u4EF6:","brightWhite")} ${a.inputFiles} \u4E2A`),console.log(` ${e("\u8F93\u51FA\u6587\u4EF6:","brightWhite")} ${a.outputFiles} \u4E2A`),console.log(` ${e("\u603B\u5927\u5C0F:","brightWhite")} ${Dt(a.totalSize)}`),console.log(` ${e("\u6784\u5EFA\u8017\u65F6:","brightWhite")} ${a.buildTime}ms`),console.log(` ${e("\u8F93\u51FA\u76EE\u5F55:","brightWhite")} ${e(r,"brightCyan")}`),console.log("")}function Lt(t,o,n){let r=g.join(t,"src");if(!y.existsSync(r))return;function s(l,f){let p=y.readdirSync(l,{withFileTypes:!0});for(let u of p){let c=g.join(l,u.name);if(u.isDirectory()){if(u.name==="node_modules")continue;s(c,f)}else if(u.isFile()){let d=g.extname(u.name);if([".ts",".tsx",".js",".jsx"].includes(d))continue;let a=g.relative(f,c),m=g.join(o,a);j(m,y.readFileSync(c).toString("utf-8")),n.outputFiles++,n.totalSize+=y.statSync(c).size}}}s(r,r)}function Dt(t){if(t===0)return"0 B";let o=["B","KB","MB","GB"],n=1024,r=Math.floor(Math.log(t)/Math.log(n));return`${(t/Math.pow(n,r)).toFixed(2)} ${o[r]}`}var Gt="0.2.0",nt="lytx",It="Lyt.js \u6846\u67B6\u547D\u4EE4\u884C\u5DE5\u5177\uFF08\u589E\u5F3A\u7248\uFF09",tt=`
|
|
367
|
+
${e(nt,"brightCyan")} - ${It}
|
|
367
368
|
|
|
368
|
-
${
|
|
369
|
+
${e("\u7528\u6CD5:","brightGreen")}
|
|
369
370
|
lytx <command> [options] [args]
|
|
370
371
|
|
|
371
|
-
${
|
|
372
|
-
${
|
|
373
|
-
${
|
|
374
|
-
${
|
|
375
|
-
${
|
|
376
|
-
|
|
377
|
-
${
|
|
378
|
-
${
|
|
379
|
-
${
|
|
380
|
-
|
|
381
|
-
${
|
|
382
|
-
${
|
|
383
|
-
${
|
|
384
|
-
${
|
|
385
|
-
${
|
|
386
|
-
${
|
|
387
|
-
${
|
|
388
|
-
${
|
|
389
|
-
|
|
390
|
-
`,
|
|
391
|
-
${
|
|
392
|
-
|
|
393
|
-
${
|
|
372
|
+
${e("\u547D\u4EE4:","brightGreen")}
|
|
373
|
+
${e("create","brightYellow")} <name> \u521B\u5EFA\u4E00\u4E2A\u65B0\u7684 Lyt \u9879\u76EE
|
|
374
|
+
${e("dev","brightYellow")} \u542F\u52A8\u672C\u5730\u5F00\u53D1\u670D\u52A1\u5668
|
|
375
|
+
${e("build","brightYellow")} \u6784\u5EFA\u751F\u4EA7\u7248\u672C
|
|
376
|
+
${e("preview","brightYellow")} \u9884\u89C8\u6784\u5EFA\u7ED3\u679C
|
|
377
|
+
|
|
378
|
+
${e("\u5168\u5C40\u9009\u9879:","brightGreen")}
|
|
379
|
+
${e("-h, --help","brightYellow")} \u663E\u793A\u5E2E\u52A9\u4FE1\u606F
|
|
380
|
+
${e("-v, --version","brightYellow")} \u663E\u793A\u7248\u672C\u53F7
|
|
381
|
+
|
|
382
|
+
${e("\u793A\u4F8B:","brightGreen")}
|
|
383
|
+
${e("$","dim")} lytx create my-app
|
|
384
|
+
${e("$","dim")} lytx create my-app --template spa --ts --router --store
|
|
385
|
+
${e("$","dim")} lytx dev
|
|
386
|
+
${e("$","dim")} lytx dev --port 8080 --hmr
|
|
387
|
+
${e("$","dim")} lytx build
|
|
388
|
+
${e("$","dim")} lytx build --mode ssr
|
|
389
|
+
${e("$","dim")} lytx preview --port 4173
|
|
390
|
+
|
|
391
|
+
`,Bt=`
|
|
392
|
+
${e("lytx create","brightCyan")} - \u521B\u5EFA\u65B0\u7684 Lyt \u9879\u76EE
|
|
393
|
+
|
|
394
|
+
${e("\u7528\u6CD5:","brightGreen")}
|
|
394
395
|
lytx create <name> [options]
|
|
395
396
|
|
|
396
|
-
${
|
|
397
|
-
${
|
|
397
|
+
${e("\u53C2\u6570:","brightGreen")}
|
|
398
|
+
${e("<name>","brightYellow")} \u9879\u76EE\u540D\u79F0\uFF08\u540C\u65F6\u4F5C\u4E3A\u76EE\u5F55\u540D\uFF09
|
|
398
399
|
|
|
399
|
-
${
|
|
400
|
-
${
|
|
400
|
+
${e("\u9009\u9879:","brightGreen")}
|
|
401
|
+
${e("--template <tpl>","brightYellow")} \u9879\u76EE\u6A21\u677F\uFF08\u9ED8\u8BA4: spa\uFF09
|
|
401
402
|
\u53EF\u9009\u503C: spa, ssr, ssg
|
|
402
|
-
${
|
|
403
|
-
${
|
|
404
|
-
${
|
|
405
|
-
${
|
|
403
|
+
${e("--ts","brightYellow")} \u4F7F\u7528 TypeScript
|
|
404
|
+
${e("--router","brightYellow")} \u5305\u542B\u8DEF\u7531
|
|
405
|
+
${e("--store","brightYellow")} \u5305\u542B\u72B6\u6001\u7BA1\u7406
|
|
406
|
+
${e("--eslint","brightYellow")} \u5305\u542B ESLint \u914D\u7F6E
|
|
406
407
|
|
|
407
|
-
${
|
|
408
|
-
${
|
|
409
|
-
${
|
|
410
|
-
${
|
|
408
|
+
${e("\u793A\u4F8B:","brightGreen")}
|
|
409
|
+
${e("$","dim")} lytx create my-app
|
|
410
|
+
${e("$","dim")} lytx create my-app --template spa --ts --router --store
|
|
411
|
+
${e("$","dim")} lytx create my-app --template ssr --ts
|
|
411
412
|
|
|
412
|
-
`,
|
|
413
|
-
${
|
|
413
|
+
`,Wt=`
|
|
414
|
+
${e("lytx dev","brightCyan")} - \u542F\u52A8\u672C\u5730\u5F00\u53D1\u670D\u52A1\u5668
|
|
414
415
|
|
|
415
|
-
${
|
|
416
|
+
${e("\u7528\u6CD5:","brightGreen")}
|
|
416
417
|
lytx dev [options]
|
|
417
418
|
|
|
418
|
-
${
|
|
419
|
-
${
|
|
420
|
-
${
|
|
421
|
-
${
|
|
419
|
+
${e("\u9009\u9879:","brightGreen")}
|
|
420
|
+
${e("-p, --port <port>","brightYellow")} \u670D\u52A1\u7AEF\u53E3\uFF08\u9ED8\u8BA4: 3000\uFF09
|
|
421
|
+
${e("--hmr","brightYellow")} \u5F00\u542F\u70ED\u66F4\u65B0\uFF08\u9ED8\u8BA4: \u5F00\u542F\uFF09
|
|
422
|
+
${e("--no-hmr","brightYellow")} \u5173\u95ED\u70ED\u66F4\u65B0
|
|
422
423
|
|
|
423
|
-
${
|
|
424
|
+
${e("\u529F\u80FD:","brightGreen")}
|
|
424
425
|
- \u9759\u6001\u6587\u4EF6\u670D\u52A1
|
|
425
426
|
- TypeScript \u5373\u65F6\u7F16\u8BD1
|
|
426
427
|
- \u70ED\u6A21\u5757\u66FF\u6362\uFF08HMR\uFF09
|
|
427
428
|
- WebSocket \u5B9E\u65F6\u901A\u4FE1
|
|
428
429
|
|
|
429
|
-
${
|
|
430
|
-
${
|
|
431
|
-
${
|
|
432
|
-
${
|
|
430
|
+
${e("\u793A\u4F8B:","brightGreen")}
|
|
431
|
+
${e("$","dim")} lytx dev
|
|
432
|
+
${e("$","dim")} lytx dev --port 8080
|
|
433
|
+
${e("$","dim")} lytx dev --no-hmr
|
|
433
434
|
|
|
434
|
-
`,
|
|
435
|
-
${
|
|
435
|
+
`,Ut=`
|
|
436
|
+
${e("lytx build","brightCyan")} - \u6784\u5EFA\u751F\u4EA7\u7248\u672C
|
|
436
437
|
|
|
437
|
-
${
|
|
438
|
+
${e("\u7528\u6CD5:","brightGreen")}
|
|
438
439
|
lytx build [options]
|
|
439
440
|
|
|
440
|
-
${
|
|
441
|
-
${
|
|
441
|
+
${e("\u9009\u9879:","brightGreen")}
|
|
442
|
+
${e("--mode <mode>","brightYellow")} \u6784\u5EFA\u6A21\u5F0F\uFF08\u9ED8\u8BA4: spa\uFF09
|
|
442
443
|
\u53EF\u9009\u503C: spa, ssr, ssg
|
|
443
|
-
${
|
|
444
|
-
${
|
|
445
|
-
${
|
|
444
|
+
${e("--minify","brightYellow")} \u538B\u7F29\u4EE3\u7801\uFF08\u53BB\u9664\u7A7A\u767D\u548C\u6CE8\u91CA\uFF09
|
|
445
|
+
${e("-o, --outDir <dir>","brightYellow")} \u8F93\u51FA\u76EE\u5F55\uFF08\u9ED8\u8BA4: dist\uFF09
|
|
446
|
+
${e("--entry <file>","brightYellow")} \u5165\u53E3\u6587\u4EF6\uFF08\u9ED8\u8BA4: index.html\uFF09
|
|
446
447
|
|
|
447
|
-
${
|
|
448
|
+
${e("\u529F\u80FD:","brightGreen")}
|
|
448
449
|
- TypeScript \u7F16\u8BD1
|
|
449
450
|
- \u6A21\u5757\u6253\u5305\uFF08\u5185\u8054\u4F9D\u8D56\uFF09
|
|
450
451
|
- \u53BB\u9664 console.log
|
|
451
452
|
- Source Map \u751F\u6210
|
|
452
453
|
- \u9759\u6001\u8D44\u6E90\u590D\u5236
|
|
453
454
|
|
|
454
|
-
${
|
|
455
|
-
${
|
|
456
|
-
${
|
|
457
|
-
${
|
|
455
|
+
${e("\u793A\u4F8B:","brightGreen")}
|
|
456
|
+
${e("$","dim")} lytx build
|
|
457
|
+
${e("$","dim")} lytx build --mode ssr
|
|
458
|
+
${e("$","dim")} lytx build --minify --outDir ./output
|
|
458
459
|
|
|
459
|
-
`,
|
|
460
|
-
${
|
|
460
|
+
`,Nt=`
|
|
461
|
+
${e("lytx preview","brightCyan")} - \u9884\u89C8\u6784\u5EFA\u7ED3\u679C
|
|
461
462
|
|
|
462
|
-
${
|
|
463
|
+
${e("\u7528\u6CD5:","brightGreen")}
|
|
463
464
|
lytx preview [options]
|
|
464
465
|
|
|
465
|
-
${
|
|
466
|
-
${
|
|
466
|
+
${e("\u9009\u9879:","brightGreen")}
|
|
467
|
+
${e("-p, --port <port>","brightYellow")} \u670D\u52A1\u7AEF\u53E3\uFF08\u9ED8\u8BA4: 4173\uFF09
|
|
467
468
|
|
|
468
|
-
${
|
|
469
|
-
${
|
|
470
|
-
${
|
|
469
|
+
${e("\u793A\u4F8B:","brightGreen")}
|
|
470
|
+
${e("$","dim")} lytx preview
|
|
471
|
+
${e("$","dim")} lytx preview --port 5000
|
|
471
472
|
|
|
472
|
-
`;function
|
|
473
|
+
`;function zt(){console.log(""),console.log(` ${e(nt,"brightCyan")} v${e(Gt,"brightWhite")}`),console.log("")}function Yt(t){i.error(`\u672A\u77E5\u547D\u4EE4: ${e(t,"brightRed")}`),console.log(""),console.log(` \u8FD0\u884C ${e("lytx --help","brightCyan")} \u67E5\u770B\u53EF\u7528\u547D\u4EE4`),console.log("")}function _t(t){return typeof t=="string"&&["spa","ssr","ssg"].includes(t)?t:"spa"}async function Jt(t){if(t.options.help){console.log(Bt);return}t.args.length===0&&(i.error("\u8BF7\u63D0\u4F9B\u9879\u76EE\u540D\u79F0"),console.log(""),console.log(` \u7528\u6CD5: ${e("lytx create <name>","brightCyan")}`),console.log(""),console.log(` \u8FD0\u884C ${e("lytx create --help","brightCyan")} \u67E5\u770B\u66F4\u591A\u9009\u9879`),console.log(""),process.exit(1));let o=t.args[0];if(t.options.ts===!0||t.options.router===!0||t.options.store===!0||t.options.eslint===!0||typeof t.options.template=="string"&&["ssr","ssg"].includes(t.options.template)){let r={name:o,template:_t(t.options.template),ts:t.options.ts===!0,router:t.options.router===!0,store:t.options.store===!0,eslint:t.options.eslint===!0};await D(r)}else{let r={template:typeof t.options.template=="string"?t.options.template:"spa"};await _(o,r)}}function qt(t){if(t.options.help){console.log(Wt);return}let o={port:typeof t.options.port=="string"?parseInt(t.options.port,10):typeof t.options.p=="string"?parseInt(t.options.p,10):3e3,hmr:t.options["no-hmr"]!==!0};(isNaN(o.port)||o.port<1||o.port>65535)&&(i.error(`\u65E0\u6548\u7684\u7AEF\u53E3\u53F7: ${t.options.port||t.options.p}`),process.exit(1)),U(o)}async function Vt(t){if(t.options.help){console.log(Ut);return}let o={minify:t.options.minify===!0,outDir:typeof t.options.outDir=="string"?t.options.outDir:typeof t.options.o=="string"?t.options.o:"dist",entry:typeof t.options.entry=="string"?t.options.entry:"index.html"};await Z(o)}function Kt(t){if(t.options.help){console.log(Nt);return}let o=typeof t.options.port=="string"?parseInt(t.options.port,10):typeof t.options.p=="string"?parseInt(t.options.p,10):4173;(isNaN(o)||o<1||o>65535)&&(i.error(`\u65E0\u6548\u7684\u7AEF\u53E3\u53F7: ${t.options.port||t.options.p}`),process.exit(1));let n=ot.resolve(process.cwd(),"dist");et.existsSync(n)||(i.error("\u672A\u627E\u5230\u6784\u5EFA\u8F93\u51FA\u76EE\u5F55 dist/\uFF0C\u8BF7\u5148\u8FD0\u884C lytx build"),process.exit(1)),U({port:o,root:n,hmr:!1})}async function Xt(){let t=Y(process.argv);if(t.options.version){zt();return}if(t.options.help&&!t.command){console.log(tt);return}t.command||(console.log(tt),process.exit(1));try{switch(t.command){case"create":await Jt(t);break;case"dev":qt(t);break;case"build":await Vt(t);break;case"preview":Kt(t);break;default:Yt(t.command),process.exit(1)}}catch(o){let n=o instanceof Error?o.message:String(o);i.error(`\u6267\u884C\u5931\u8D25: ${n}`),console.log(""),console.log(` ${e("\u63D0\u793A:","brightYellow")} \u8BF7\u68C0\u67E5\u8F93\u5165\u53C2\u6570\u6216\u8FD0\u884C ${e("lytx --help","brightCyan")} \u67E5\u770B\u5E2E\u52A9`),console.log(""),process.exit(1)}}Xt();0&&(module.exports={createHMREndpoint,createHMRServer,createProject,getHMRClientScript});
|
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
2
|
+
var U=(t=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(t,{get:(o,n)=>(typeof require!="undefined"?require:o)[n]}):t)(function(t){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});import*as Q from"fs";import*as Z from"path";import*as x from"fs";import*as L from"path";var et="\x1B[0m",ot={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",strikethrough:"\x1B[9m"};function e(t,o){let n=ot[o];return n?`${n}${t}${et}`:t}function N(t){let o=t.slice(2),n={command:"",args:[],options:{},raw:o},r=0;for(;r<o.length;){let s=o[r];if(s==="--help"||s==="-h")n.options.help=!0,r++;else if(s==="--version"||s==="-v")n.options.version=!0,r++;else if(s.startsWith("--")){let l=s.indexOf("=");if(l!==-1){let f=s.slice(2,l),p=s.slice(l+1);n.options[f]=p}else{let f=s.slice(2),p=o[r+1];p&&!p.startsWith("-")?(n.options[f]=p,r++):n.options[f]=!0}r++}else if(s.startsWith("-")&&s.length>1){let l=s.slice(1),f=o[r+1];f&&!f.startsWith("-")?(n.options[l]=f,r++):n.options[l]=!0,r++}else n.command?(n.args.push(s),r++):(n.command=s,r++)}return n}function w(t){x.existsSync(t)||x.mkdirSync(t,{recursive:!0})}function F(t){return x.existsSync(t)}function M(t){return x.readFileSync(t,"utf-8")}function C(t,o){let n=L.dirname(t);w(n),x.writeFileSync(t,o,"utf-8")}var i={info(t){console.log(`${e("[INFO]","blue")} ${t}`)},warn(t){console.log(`${e("[WARN]","yellow")} ${t}`)},error(t){console.error(`${e("[ERROR]","red")} ${t}`)},success(t){console.log(`${e("[SUCCESS]","green")} ${t}`)}};import*as E from"path";function nt(){return`<!DOCTYPE html>
|
|
3
3
|
<html lang="zh-CN">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>Lyt App</title>
|
|
8
|
+
<link rel="stylesheet" href="/src/style.css" />
|
|
8
9
|
</head>
|
|
9
10
|
<body>
|
|
10
11
|
<div id="app"></div>
|
|
11
12
|
<script type="module" src="/src/main.ts"></script>
|
|
12
13
|
</body>
|
|
13
14
|
</html>
|
|
14
|
-
`}function
|
|
15
|
+
`}function rt(){return`import { createApp } from '@lytjs/lytjs';
|
|
15
16
|
import App from './App';
|
|
16
17
|
|
|
17
18
|
// \u521B\u5EFA\u5E94\u7528\u5B9E\u4F8B
|
|
@@ -19,7 +20,7 @@ const app = createApp(App);
|
|
|
19
20
|
|
|
20
21
|
// \u5C06\u5E94\u7528\u6302\u8F7D\u5230 #app \u5143\u7D20
|
|
21
22
|
app.mount('#app');
|
|
22
|
-
`}function
|
|
23
|
+
`}function st(){return`import { defineComponent } from '@lytjs/lytjs';
|
|
23
24
|
|
|
24
25
|
// \u5B9A\u4E49\u6839\u7EC4\u4EF6
|
|
25
26
|
const App = defineComponent({
|
|
@@ -44,7 +45,7 @@ const App = defineComponent({
|
|
|
44
45
|
});
|
|
45
46
|
|
|
46
47
|
export default App;
|
|
47
|
-
`}function
|
|
48
|
+
`}function it(){return`/* Lyt \u5168\u5C40\u6837\u5F0F */
|
|
48
49
|
|
|
49
50
|
* {
|
|
50
51
|
margin: 0;
|
|
@@ -75,9 +76,9 @@ body {
|
|
|
75
76
|
font-size: 1.2rem;
|
|
76
77
|
color: #666;
|
|
77
78
|
}
|
|
78
|
-
`}function
|
|
79
|
-
`}function
|
|
80
|
-
`}function
|
|
79
|
+
`}function at(t){return JSON.stringify({name:t,version:"0.1.0",private:!0,type:"module",scripts:{dev:"lyt dev",build:"lyt build",preview:"lyt preview"},dependencies:{"@lytjs/lytjs":"latest"},devDependencies:{"@lytjs/cli":"latest",typescript:"^5.0.0"}},null,2)+`
|
|
80
|
+
`}function lt(){return JSON.stringify({compilerOptions:{target:"ES2020",module:"ESNext",moduleResolution:"bundler",strict:!0,jsx:"preserve",resolveJsonModule:!0,isolatedModules:!0,esModuleInterop:!0,lib:["ES2020","DOM","DOM.Iterable"],skipLibCheck:!0,noEmit:!0,paths:{"@/*":["./src/*"]}},include:["src/**/*.ts","src/**/*.tsx"],exclude:["node_modules","dist"]},null,2)+`
|
|
81
|
+
`}function ct(){return`# \u4F9D\u8D56
|
|
81
82
|
node_modules/
|
|
82
83
|
|
|
83
84
|
# \u6784\u5EFA\u8F93\u51FA
|
|
@@ -100,25 +101,25 @@ Thumbs.db
|
|
|
100
101
|
# \u65E5\u5FD7
|
|
101
102
|
*.log
|
|
102
103
|
npm-debug.log*
|
|
103
|
-
`}async function
|
|
104
|
-
`}function
|
|
105
|
-
`}function
|
|
104
|
+
`}async function z(t,o={}){let n=o.template||"spa",r=E.resolve(process.cwd(),t);i.info(`\u6B63\u5728\u521B\u5EFA Lyt \u9879\u76EE: ${e(t,"brightCyan")}`),i.info(`\u4F7F\u7528\u6A21\u677F: ${e(n,"brightCyan")}`),F(r)&&(i.error(`\u76EE\u5F55 "${t}" \u5DF2\u5B58\u5728\uFF0C\u8BF7\u9009\u62E9\u5176\u4ED6\u540D\u79F0\u6216\u5220\u9664\u5DF2\u6709\u76EE\u5F55`),process.exit(1)),w(r);let s=[{filePath:"index.html",content:nt()},{filePath:"src/main.ts",content:rt()},{filePath:"src/App.ts",content:st()},{filePath:"src/style.css",content:it()},{filePath:"package.json",content:at(t)},{filePath:"tsconfig.json",content:lt()},{filePath:".gitignore",content:ct()}];for(let l of s){let f=E.join(r,l.filePath);C(f,l.content),i.success(` \u521B\u5EFA ${l.filePath}`)}console.log(""),i.success(`\u9879\u76EE ${e(t,"brightCyan")} \u521B\u5EFA\u6210\u529F\uFF01`),console.log(""),console.log(" \u8BF7\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u542F\u52A8\u9879\u76EE\uFF1A"),console.log(""),console.log(` ${e("cd","brightGreen")} ${t}`),console.log(` ${e("npm install","brightGreen")}`),console.log(` ${e("npm run dev","brightGreen")}`),console.log("")}import*as T from"path";function pt(t){let o={name:t.name,version:"0.1.0",private:!0,type:"module",scripts:{dev:"lytx dev",build:"lytx build",preview:"lytx preview"},dependencies:{"@lytjs/lytjs":"latest"}};return t.ts&&(o.devDependencies={"@lytjs/cli":"latest",typescript:"^5.0.0"}),t.eslint&&(o.devDependencies=o.devDependencies||{},o.devDependencies.eslint="^8.0.0",o.scripts=o.scripts||{},o.scripts.lint="eslint src --ext .ts,.js"),t.router&&(o.dependencies["@lytjs/router"]="latest"),t.store&&(o.dependencies["@lytjs/store"]="latest"),JSON.stringify(o,null,2)+`
|
|
105
|
+
`}function ut(t){let o={compilerOptions:{target:"ES2020",module:"ESNext",moduleResolution:"bundler",strict:!0,jsx:"preserve",resolveJsonModule:!0,isolatedModules:!0,esModuleInterop:!0,lib:["ES2020","DOM","DOM.Iterable"],skipLibCheck:!0,noEmit:!0,paths:{"@/*":["./src/*"]}},include:["src/**/*.ts","src/**/*.tsx"],exclude:["node_modules","dist"]};return t.template==="ssr"&&(o.compilerOptions.types=["node"]),JSON.stringify(o,null,2)+`
|
|
106
|
+
`}function ft(t){let o=t.ts?".ts":".js";return`<!DOCTYPE html>
|
|
106
107
|
<html lang="zh-CN">
|
|
107
108
|
<head>
|
|
108
109
|
<meta charset="UTF-8" />
|
|
109
110
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
110
111
|
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
|
|
111
|
-
<title>${
|
|
112
|
+
<title>${t.name}</title>
|
|
112
113
|
</head>
|
|
113
114
|
<body>
|
|
114
115
|
<div id="app"></div>
|
|
115
|
-
<script type="module" src="/src/main${
|
|
116
|
+
<script type="module" src="/src/main${o}"></script>
|
|
116
117
|
</body>
|
|
117
118
|
</html>
|
|
118
|
-
`}function
|
|
119
|
-
`)}function
|
|
119
|
+
`}function dt(t){let o=["// Lytx \u914D\u7F6E\u6587\u4EF6","import { defineConfig } from '@lytjs/lytjs'","","export default defineConfig({"," // \u6784\u5EFA\u6A21\u5F0F",` mode: '${t.template}',`];return t.router&&(o.push(" // \u8DEF\u7531\u914D\u7F6E"),o.push(" router: {"),o.push(" historyMode: true,"),o.push(" },")),t.store&&(o.push(" // \u72B6\u6001\u7BA1\u7406\u914D\u7F6E"),o.push(" store: {"),o.push(" strict: true,"),o.push(" },")),o.push("})"),o.push(""),o.join(`
|
|
120
|
+
`)}function gt(t){let o=t.ts?".ts":".js",n=["import { createApp } from '@lytjs/lytjs'","import App from './App.lyt'","import './styles/main.css'"];return t.router&&n.push("import { router } from './router'"),t.store&&n.push("import { store } from './store'"),n.push(""),n.push("// \u521B\u5EFA\u5E94\u7528\u5B9E\u4F8B"),n.push("const app = createApp(App)"),t.router&&n.push("app.use(router)"),t.store&&n.push("app.use(store)"),n.push(""),n.push("// \u5C06\u5E94\u7528\u6302\u8F7D\u5230 #app \u5143\u7D20"),n.push("app.mount('#app')"),n.join(`
|
|
120
121
|
`)+`
|
|
121
|
-
`}function
|
|
122
|
+
`}function mt(){return`<template>
|
|
122
123
|
<div class="app">
|
|
123
124
|
<Header />
|
|
124
125
|
<main>
|
|
@@ -146,7 +147,7 @@ export default defineComponent({
|
|
|
146
147
|
padding: 20px;
|
|
147
148
|
}
|
|
148
149
|
</style>
|
|
149
|
-
`}function
|
|
150
|
+
`}function ht(){return`import { defineComponent } from '@lytjs/lytjs'
|
|
150
151
|
|
|
151
152
|
export default defineComponent({
|
|
152
153
|
name: 'HomePage',
|
|
@@ -158,7 +159,7 @@ export default defineComponent({
|
|
|
158
159
|
</div>
|
|
159
160
|
\`,
|
|
160
161
|
})
|
|
161
|
-
`}function
|
|
162
|
+
`}function yt(){return`import { defineComponent } from '@lytjs/lytjs'
|
|
162
163
|
|
|
163
164
|
export default defineComponent({
|
|
164
165
|
name: 'AboutPage',
|
|
@@ -170,7 +171,7 @@ export default defineComponent({
|
|
|
170
171
|
</div>
|
|
171
172
|
\`,
|
|
172
173
|
})
|
|
173
|
-
`}function
|
|
174
|
+
`}function bt(){return`import { defineComponent } from '@lytjs/lytjs'
|
|
174
175
|
|
|
175
176
|
export default defineComponent({
|
|
176
177
|
name: 'Header',
|
|
@@ -184,7 +185,7 @@ export default defineComponent({
|
|
|
184
185
|
</header>
|
|
185
186
|
\`,
|
|
186
187
|
})
|
|
187
|
-
`}function
|
|
188
|
+
`}function xt(){return`import { createRouter, createWebHistory } from '@lytjs/router'
|
|
188
189
|
import HomePage from '../pages/index'
|
|
189
190
|
import AboutPage from '../pages/about'
|
|
190
191
|
|
|
@@ -201,7 +202,7 @@ export const router = createRouter({
|
|
|
201
202
|
},
|
|
202
203
|
],
|
|
203
204
|
})
|
|
204
|
-
`}function
|
|
205
|
+
`}function vt(){return`import { createStore } from '@lytjs/store'
|
|
205
206
|
|
|
206
207
|
export const store = createStore({
|
|
207
208
|
state: {
|
|
@@ -229,7 +230,7 @@ export const store = createStore({
|
|
|
229
230
|
doubleCount: (state: any) => state.count * 2,
|
|
230
231
|
},
|
|
231
232
|
})
|
|
232
|
-
`}function
|
|
233
|
+
`}function $t(){return`/* \u5168\u5C40\u6837\u5F0F */
|
|
233
234
|
|
|
234
235
|
* {
|
|
235
236
|
margin: 0;
|
|
@@ -253,17 +254,17 @@ a {
|
|
|
253
254
|
a:hover {
|
|
254
255
|
text-decoration: underline;
|
|
255
256
|
}
|
|
256
|
-
`}function
|
|
257
|
+
`}function wt(){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
|
|
257
258
|
<rect width="32" height="32" rx="6" fill="#42b883"/>
|
|
258
259
|
<text x="16" y="22" text-anchor="middle" fill="white" font-size="18" font-weight="bold">L</text>
|
|
259
260
|
</svg>
|
|
260
|
-
`}function
|
|
261
|
-
`}async function
|
|
261
|
+
`}function St(){return JSON.stringify({root:!0,env:{browser:!0,es2021:!0,node:!0},extends:["eslint:recommended"],parserOptions:{ecmaVersion:"latest",sourceType:"module"},rules:{"no-unused-vars":"warn","no-console":"warn"}},null,2)+`
|
|
262
|
+
`}async function D(t){let{name:o,template:n,ts:r,router:s,store:l,eslint:f}=t,p=T.resolve(process.cwd(),o);if(i.info(`\u6B63\u5728\u521B\u5EFA Lyt \u9879\u76EE: ${e(o,"brightCyan")}`),i.info(`\u4F7F\u7528\u6A21\u677F: ${e(n,"brightCyan")}`),F(p))throw i.error(`\u76EE\u5F55 "${o}" \u5DF2\u5B58\u5728\uFF0C\u8BF7\u9009\u62E9\u5176\u4ED6\u540D\u79F0\u6216\u5220\u9664\u5DF2\u6709\u76EE\u5F55`),new Error(`Directory "${o}" already exists`);w(p);let u=[{filePath:"package.json",content:pt(t)},{filePath:"index.html",content:ft(t)},{filePath:"lytx.config.ts",content:dt(t)},{filePath:"src/main.ts",content:gt(t)},{filePath:"src/App.lyt",content:mt()},{filePath:"src/pages/index.ts",content:ht()},{filePath:"src/pages/about.ts",content:yt()},{filePath:"src/components/Header.ts",content:bt()},{filePath:"src/styles/main.css",content:$t()},{filePath:"public/favicon.svg",content:wt()}];r&&u.push({filePath:"tsconfig.json",content:ut(t)}),s&&u.push({filePath:"src/router/index.ts",content:xt()}),l&&u.push({filePath:"src/store/index.ts",content:vt()}),f&&u.push({filePath:".eslintrc.json",content:St()});for(let c of u){let d=T.join(p,c.filePath);C(d,c.content),i.success(` \u521B\u5EFA ${c.filePath}`)}console.log(""),i.success(`\u9879\u76EE ${e(o,"brightCyan")} \u521B\u5EFA\u6210\u529F\uFF01`),console.log(""),console.log(" \u8BF7\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u542F\u52A8\u9879\u76EE\uFF1A"),console.log(""),console.log(` ${e("cd","brightGreen")} ${o}`),console.log(` ${e("npm install","brightGreen")}`),console.log(` ${e("npm run dev","brightGreen")}`),console.log("")}import*as J from"http";import*as j from"fs";import*as y from"path";import*as Y from"http";import*as R from"fs";import*as v from"path";import*as _ from"crypto";var O=class{constructor(){this.clients=[]}handleUpgrade(o,n,r){let s=o.headers["sec-websocket-key"];if(!s){n.destroy();return}let l=_.createHash("sha1").update(s+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");n.write(`HTTP/1.1 101 Switching Protocols\r
|
|
262
263
|
Upgrade: websocket\r
|
|
263
264
|
Connection: Upgrade\r
|
|
264
265
|
Sec-WebSocket-Accept: ${l}\r
|
|
265
266
|
\r
|
|
266
|
-
`);let
|
|
267
|
+
`);let f={socket:n,isAlive:!0};n.on("close",()=>{this.clients=this.clients.filter(p=>p!==f)}),n.on("error",()=>{this.clients=this.clients.filter(p=>p!==f)}),this.clients.push(f)}broadcast(o){let n=[];for(let r of this.clients)try{if(!r.isAlive){n.push(r);continue}let s=Buffer.from(o,"utf-8"),l=this.createFrame(129,s);r.socket.write(l)}catch(s){n.push(r)}for(let r of n){this.clients=this.clients.filter(s=>s!==r);try{r.socket.destroy()}catch(s){}}}createFrame(o,n){let r=n.length,s;r<126?s=2:r<65536?s=4:s=10;let l=Buffer.alloc(s+r);return l[0]=o,r<126?l[1]=r:r<65536?(l[1]=126,l.writeUInt16BE(r,2)):(l[1]=127,l.writeUInt32BE(0,2),l.writeUInt32BE(r,6)),n.copy(l,s),l}getClientCount(){return this.clients.length}closeAll(){for(let o of this.clients)try{o.socket.destroy()}catch(n){}this.clients=[]}};function Ct(t){let o=new O,n=[],r=[],s=null,l=!1;function f(u){let c=v.extname(u).toLowerCase();if(c===".css")return"css";let d=v.basename(u);return d.startsWith("lytx.config")||d==="tsconfig.json"||d==="package.json"?"reload":c===".ts"||c===".tsx"||c===".lyt"||c===".js"||c===".jsx"?"update":"reload"}function p(u){try{let c=R.readdirSync(u,{withFileTypes:!0});for(let d of c){let a=v.join(u,d.name);if(d.isDirectory()){if(d.name==="node_modules"||d.name===".git"||d.name==="dist")continue;p(a)}else if(d.isFile()){let m=v.extname(d.name).toLowerCase();if(new Set([".ts",".tsx",".js",".jsx",".css",".html",".json",".lyt"]).has(m))try{let H=R.watch(a,{persistent:!1},W=>{if(W==="change"){let A=v.relative(t,a);for(let S of n)try{S(A)}catch(k){}let P=f(a),$={type:P,path:`/${A}`};if(P==="css")try{$.content=R.readFileSync(a,"utf-8")}catch(S){}o.broadcast(JSON.stringify($))}});r.push(H)}catch(H){}}}}catch(c){}}return{start(u){l||(l=!0,s=Y.createServer((c,d)=>{d.writeHead(426,{"Content-Type":"text/plain"}),d.end("Upgrade Required")}),s.on("upgrade",(c,d,a)=>{o.handleUpgrade(c,d,a)}),s.listen(u,()=>{}),p(t))},stop(){l=!1;for(let u of r)try{u.close()}catch(c){}if(r.length=0,o.closeAll(),s){try{s.close()}catch(u){}s=null}},onFileChange(u){n.push(u)},notifyClient(u){o.broadcast(JSON.stringify(u))}}}function G(t){let o=new O;return t.on("upgrade",(n,r,s)=>{o.handleUpgrade(n,r,s)}),{broadcast(n){o.broadcast(n)},getClientCount(){return o.getClientCount()}}}function I(){return`(function() {
|
|
267
268
|
'use strict';
|
|
268
269
|
|
|
269
270
|
var ws = null;
|
|
@@ -361,112 +362,112 @@ Sec-WebSocket-Accept: ${l}\r
|
|
|
361
362
|
|
|
362
363
|
// \u542F\u52A8\u8FDE\u63A5
|
|
363
364
|
connect();
|
|
364
|
-
})();`}var
|
|
365
|
-
</head>`)),{statusCode:200,headers:{"Content-Type":
|
|
366
|
-
${
|
|
365
|
+
})();`}var q;try{q=U("esbuild")}catch(t){i.error("\u7F3A\u5C11\u4F9D\u8D56: esbuild"),i.error(""),i.error(" Lyt CLI \u7684\u5F00\u53D1\u670D\u52A1\u5668\u9700\u8981 esbuild \u6765\u5B9E\u65F6\u7F16\u8BD1 TypeScript\u3002"),i.error(""),i.error(" \u8BF7\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u5B89\u88C5:"),i.error(` ${e("npm install esbuild --save-dev","brightGreen")}`),i.error(""),i.error(" \u5982\u679C\u60A8\u4F7F\u7528 pnpm:"),i.error(` ${e("pnpm add esbuild -D","brightGreen")}`),i.error(""),process.exit(1)}function jt(t,o){try{return q.transformSync(t,{loader:"ts",target:"es2018",format:"esm",sourcemap:"inline"}).code}catch(n){let r=n instanceof Error?n.message:String(n);return console.error(`[Lyt CLI] \u7F16\u8BD1\u9519\u8BEF ${o||""}:`,r),t}}function Pt(t,o){var u;let n=((u=t.url)==null?void 0:u.split("?")[0])||"/";if(n==="/"&&(n="/index.html"),n.startsWith("/node_modules/")||n.startsWith("/@")){let c;if(n.startsWith("/@")&&!n.startsWith("/node_modules/")?c=y.join(o,"node_modules",n.slice(1)):c=y.join(o,n.slice(1)),n.match(/^\/(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/)&&!n.includes(".")){let d=y.join(c,"package.json");if(j.existsSync(d))try{let a=JSON.parse(M(d)),m=a.module||a.main||"index.js";a.exports&&(typeof a.exports=="string"?m=a.exports:typeof a.exports=="object"&&a.exports["."]&&(typeof a.exports["."]=="string"?m=a.exports["."]:a.exports["."].import?m=a.exports["."].import:a.exports["."].default?m=a.exports["."].default:Object.values(a.exports["."])[0]&&(m=Object.values(a.exports["."])[0]))),m.startsWith("./")&&(m=m.slice(2)),c=y.join(c,m)}catch(a){}}if(j.existsSync(c)&&j.statSync(c).isFile()){let d=y.extname(c).toLowerCase(),m={".js":"application/javascript; charset=utf-8",".mjs":"application/javascript; charset=utf-8",".json":"application/json; charset=utf-8"}[d]||"application/octet-stream",b=M(c);return{statusCode:200,headers:{"Content-Type":m},body:b}}}let r=y.join(o,n);if(!r.startsWith(o))return{statusCode:403,headers:{"Content-Type":"text/plain; charset=utf-8"},body:"403 Forbidden"};if(!j.existsSync(r)||!j.statSync(r).isFile())return{statusCode:404,headers:{"Content-Type":"text/plain; charset=utf-8"},body:"404 Not Found"};let s=y.extname(r).toLowerCase(),f={".html":"text/html; charset=utf-8",".css":"text/css; charset=utf-8",".js":"application/javascript; charset=utf-8",".mjs":"application/javascript; charset=utf-8",".ts":"application/typescript; charset=utf-8",".json":"application/json; charset=utf-8",".svg":"image/svg+xml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".txt":"text/plain; charset=utf-8"}[s]||"application/octet-stream",p=M(r);return(s===".ts"||s===".tsx")&&(p=jt(p,n)),s===".html"&&(p=p.replace("</head>",`<script>${I()}</script>
|
|
366
|
+
</head>`)),{statusCode:200,headers:{"Content-Type":f},body:p}}function B(t={}){let o=t.port||3e3,n=y.resolve(t.root||process.cwd()),r=t.hmr!==!1,s=J.createServer((p,u)=>{let c=Pt(p,n);u.writeHead(c.statusCode,c.headers),u.end(c.body)}),l=r?G(s):null;s.listen(o,()=>{console.log(""),console.log(e(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557","brightCyan")),console.log(e(" \u2551","brightCyan")+e(" Lyt \u5F00\u53D1\u670D\u52A1\u5668\u5DF2\u542F\u52A8 ","brightWhite")+e("\u2551","brightCyan")),console.log(e(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D","brightCyan")),console.log(""),console.log(` ${e("\u279C","brightGreen")} \u672C\u5730\u8BBF\u95EE: ${e(`http://localhost:${o}`,"brightBlue")}`),console.log(` ${e("\u279C","brightGreen")} \u7F51\u7EDC\u8BBF\u95EE: ${e(`http://127.0.0.1:${o}`,"brightBlue")}`),console.log(` ${e("\u279C","brightGreen")} \u9879\u76EE\u76EE\u5F55: ${e(n,"brightBlue")}`),console.log(` ${e("\u279C","brightGreen")} \u70ED\u66F4\u65B0: ${e(r?"\u5DF2\u5F00\u542F":"\u5DF2\u5173\u95ED",r?"brightGreen":"brightRed")}`),console.log(""),console.log(` ${e("\u6309 Ctrl+C \u505C\u6B62\u670D\u52A1\u5668","dim")}`),console.log("")}),s.on("error",p=>{p.code==="EADDRINUSE"?(i.error(`\u7AEF\u53E3 ${o} \u5DF2\u88AB\u5360\u7528\uFF0C\u8BF7\u4F7F\u7528 --port \u6307\u5B9A\u5176\u4ED6\u7AEF\u53E3`),process.exit(1)):(i.error(`\u670D\u52A1\u5668\u542F\u52A8\u5931\u8D25: ${p.message}`),process.exit(1))});let f=()=>{i.info("\u6B63\u5728\u5173\u95ED\u5F00\u53D1\u670D\u52A1\u5668..."),s.close(()=>{i.success("\u670D\u52A1\u5668\u5DF2\u5173\u95ED"),process.exit(0)}),setTimeout(()=>{i.warn("\u670D\u52A1\u5668\u5173\u95ED\u8D85\u65F6\uFF0C\u5F3A\u5236\u9000\u51FA"),process.exit(1)},5e3)};process.on("SIGINT",f),process.on("SIGTERM",f)}import*as h from"fs";import*as g from"path";var V;try{V=U("esbuild")}catch(t){i.error("\u7F3A\u5C11\u4F9D\u8D56: esbuild"),i.error(""),i.error(" Lyt CLI \u7684\u6784\u5EFA\u529F\u80FD\u9700\u8981 esbuild\u3002"),i.error(""),i.error(" \u8BF7\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u5B89\u88C5:"),i.error(` ${e("npm install esbuild --save-dev","brightGreen")}`),i.error(""),i.error(" \u5982\u679C\u60A8\u4F7F\u7528 pnpm:"),i.error(` ${e("pnpm add esbuild -D","brightGreen")}`),i.error(""),process.exit(1)}async function K(t={}){let o=Date.now(),n=g.resolve(t.root||process.cwd()),r=g.resolve(n,t.outDir||"dist"),s=t.entry||"index.html",l=t.minify||!1;i.info("\u5F00\u59CB\u6784\u5EFA\u9879\u76EE..."),i.info(` \u6839\u76EE\u5F55: ${e(n,"brightCyan")}`),i.info(` \u8F93\u51FA\u76EE\u5F55: ${e(r,"brightCyan")}`),i.info(` \u538B\u7F29: ${e(l?"\u5F00\u542F":"\u5173\u95ED",l?"brightGreen":"brightYellow")}`);let f=g.join(n,s);h.existsSync(f)||(i.error(`\u5165\u53E3\u6587\u4EF6\u4E0D\u5B58\u5728: ${f}`),process.exit(1));let p=M(f),u=/<script\s+type="module"\s+src="([^"]+)"\s*><\/script>/g,c,d=[];for(;(c=u.exec(p))!==null;)d.push(c[1]);d.length===0&&i.warn("\u672A\u5728\u5165\u53E3 HTML \u4E2D\u627E\u5230\u6A21\u5757\u811A\u672C\u5F15\u7528");let a={inputFiles:0,outputFiles:0,totalSize:0,buildTime:0};w(r),w(g.join(r,"assets"));for(let b of d){let H=g.join(n,b);if(!h.existsSync(H)){i.warn(`\u811A\u672C\u6587\u4EF6\u4E0D\u5B58\u5728: ${b}`);continue}i.info(`\u6B63\u5728\u6253\u5305: ${e(b,"brightYellow")}`);let A=`${g.basename(b,g.extname(b))}.bundle.js`,P=g.join(r,"assets",A);try{await V.build({entryPoints:[H],bundle:!0,minify:l,target:"es2018",format:"esm",outfile:P,sourcemap:!0,external:k=>k.startsWith("@lytjs/"),drop:l?["console"]:[],metafile:!0});let $=h.readFileSync(P,"utf-8");a.totalSize+=Buffer.byteLength($,"utf-8"),a.outputFiles++;let S=P+".map";if(h.existsSync(S)){let k=h.readFileSync(S,"utf-8");a.totalSize+=Buffer.byteLength(k,"utf-8"),a.outputFiles++}p=p.replace(`<script type="module" src="${b}"></script>`,`<script src="/assets/${A}"></script>`),a.inputFiles++}catch($){let S=$ instanceof Error?$.message:String($);i.error(`\u6253\u5305\u5931\u8D25 ${b}: ${S}`),process.exit(1)}}Mt(n,r,a);let m=g.join(r,"index.html");C(m,p),a.outputFiles++,a.totalSize+=Buffer.byteLength(p,"utf-8"),a.buildTime=Date.now()-o,console.log(""),i.success("\u6784\u5EFA\u5B8C\u6210\uFF01"),console.log(""),console.log(` ${e("\u8F93\u5165\u6587\u4EF6:","brightWhite")} ${a.inputFiles} \u4E2A`),console.log(` ${e("\u8F93\u51FA\u6587\u4EF6:","brightWhite")} ${a.outputFiles} \u4E2A`),console.log(` ${e("\u603B\u5927\u5C0F:","brightWhite")} ${Rt(a.totalSize)}`),console.log(` ${e("\u6784\u5EFA\u8017\u65F6:","brightWhite")} ${a.buildTime}ms`),console.log(` ${e("\u8F93\u51FA\u76EE\u5F55:","brightWhite")} ${e(r,"brightCyan")}`),console.log("")}function Mt(t,o,n){let r=g.join(t,"src");if(!h.existsSync(r))return;function s(l,f){let p=h.readdirSync(l,{withFileTypes:!0});for(let u of p){let c=g.join(l,u.name);if(u.isDirectory()){if(u.name==="node_modules")continue;s(c,f)}else if(u.isFile()){let d=g.extname(u.name);if([".ts",".tsx",".js",".jsx"].includes(d))continue;let a=g.relative(f,c),m=g.join(o,a);C(m,h.readFileSync(c).toString("utf-8")),n.outputFiles++,n.totalSize+=h.statSync(c).size}}}s(r,r)}function Rt(t){if(t===0)return"0 B";let o=["B","KB","MB","GB"],n=1024,r=Math.floor(Math.log(t)/Math.log(n));return`${(t/Math.pow(n,r)).toFixed(2)} ${o[r]}`}var Ht="0.2.0",tt="lytx",At="Lyt.js \u6846\u67B6\u547D\u4EE4\u884C\u5DE5\u5177\uFF08\u589E\u5F3A\u7248\uFF09",X=`
|
|
367
|
+
${e(tt,"brightCyan")} - ${At}
|
|
367
368
|
|
|
368
|
-
${
|
|
369
|
+
${e("\u7528\u6CD5:","brightGreen")}
|
|
369
370
|
lytx <command> [options] [args]
|
|
370
371
|
|
|
371
|
-
${
|
|
372
|
-
${
|
|
373
|
-
${
|
|
374
|
-
${
|
|
375
|
-
${
|
|
376
|
-
|
|
377
|
-
${
|
|
378
|
-
${
|
|
379
|
-
${
|
|
380
|
-
|
|
381
|
-
${
|
|
382
|
-
${
|
|
383
|
-
${
|
|
384
|
-
${
|
|
385
|
-
${
|
|
386
|
-
${
|
|
387
|
-
${
|
|
388
|
-
${
|
|
389
|
-
|
|
390
|
-
`,
|
|
391
|
-
${
|
|
392
|
-
|
|
393
|
-
${
|
|
372
|
+
${e("\u547D\u4EE4:","brightGreen")}
|
|
373
|
+
${e("create","brightYellow")} <name> \u521B\u5EFA\u4E00\u4E2A\u65B0\u7684 Lyt \u9879\u76EE
|
|
374
|
+
${e("dev","brightYellow")} \u542F\u52A8\u672C\u5730\u5F00\u53D1\u670D\u52A1\u5668
|
|
375
|
+
${e("build","brightYellow")} \u6784\u5EFA\u751F\u4EA7\u7248\u672C
|
|
376
|
+
${e("preview","brightYellow")} \u9884\u89C8\u6784\u5EFA\u7ED3\u679C
|
|
377
|
+
|
|
378
|
+
${e("\u5168\u5C40\u9009\u9879:","brightGreen")}
|
|
379
|
+
${e("-h, --help","brightYellow")} \u663E\u793A\u5E2E\u52A9\u4FE1\u606F
|
|
380
|
+
${e("-v, --version","brightYellow")} \u663E\u793A\u7248\u672C\u53F7
|
|
381
|
+
|
|
382
|
+
${e("\u793A\u4F8B:","brightGreen")}
|
|
383
|
+
${e("$","dim")} lytx create my-app
|
|
384
|
+
${e("$","dim")} lytx create my-app --template spa --ts --router --store
|
|
385
|
+
${e("$","dim")} lytx dev
|
|
386
|
+
${e("$","dim")} lytx dev --port 8080 --hmr
|
|
387
|
+
${e("$","dim")} lytx build
|
|
388
|
+
${e("$","dim")} lytx build --mode ssr
|
|
389
|
+
${e("$","dim")} lytx preview --port 4173
|
|
390
|
+
|
|
391
|
+
`,kt=`
|
|
392
|
+
${e("lytx create","brightCyan")} - \u521B\u5EFA\u65B0\u7684 Lyt \u9879\u76EE
|
|
393
|
+
|
|
394
|
+
${e("\u7528\u6CD5:","brightGreen")}
|
|
394
395
|
lytx create <name> [options]
|
|
395
396
|
|
|
396
|
-
${
|
|
397
|
-
${
|
|
397
|
+
${e("\u53C2\u6570:","brightGreen")}
|
|
398
|
+
${e("<name>","brightYellow")} \u9879\u76EE\u540D\u79F0\uFF08\u540C\u65F6\u4F5C\u4E3A\u76EE\u5F55\u540D\uFF09
|
|
398
399
|
|
|
399
|
-
${
|
|
400
|
-
${
|
|
400
|
+
${e("\u9009\u9879:","brightGreen")}
|
|
401
|
+
${e("--template <tpl>","brightYellow")} \u9879\u76EE\u6A21\u677F\uFF08\u9ED8\u8BA4: spa\uFF09
|
|
401
402
|
\u53EF\u9009\u503C: spa, ssr, ssg
|
|
402
|
-
${
|
|
403
|
-
${
|
|
404
|
-
${
|
|
405
|
-
${
|
|
403
|
+
${e("--ts","brightYellow")} \u4F7F\u7528 TypeScript
|
|
404
|
+
${e("--router","brightYellow")} \u5305\u542B\u8DEF\u7531
|
|
405
|
+
${e("--store","brightYellow")} \u5305\u542B\u72B6\u6001\u7BA1\u7406
|
|
406
|
+
${e("--eslint","brightYellow")} \u5305\u542B ESLint \u914D\u7F6E
|
|
406
407
|
|
|
407
|
-
${
|
|
408
|
-
${
|
|
409
|
-
${
|
|
410
|
-
${
|
|
408
|
+
${e("\u793A\u4F8B:","brightGreen")}
|
|
409
|
+
${e("$","dim")} lytx create my-app
|
|
410
|
+
${e("$","dim")} lytx create my-app --template spa --ts --router --store
|
|
411
|
+
${e("$","dim")} lytx create my-app --template ssr --ts
|
|
411
412
|
|
|
412
|
-
`,
|
|
413
|
-
${
|
|
413
|
+
`,Ft=`
|
|
414
|
+
${e("lytx dev","brightCyan")} - \u542F\u52A8\u672C\u5730\u5F00\u53D1\u670D\u52A1\u5668
|
|
414
415
|
|
|
415
|
-
${
|
|
416
|
+
${e("\u7528\u6CD5:","brightGreen")}
|
|
416
417
|
lytx dev [options]
|
|
417
418
|
|
|
418
|
-
${
|
|
419
|
-
${
|
|
420
|
-
${
|
|
421
|
-
${
|
|
419
|
+
${e("\u9009\u9879:","brightGreen")}
|
|
420
|
+
${e("-p, --port <port>","brightYellow")} \u670D\u52A1\u7AEF\u53E3\uFF08\u9ED8\u8BA4: 3000\uFF09
|
|
421
|
+
${e("--hmr","brightYellow")} \u5F00\u542F\u70ED\u66F4\u65B0\uFF08\u9ED8\u8BA4: \u5F00\u542F\uFF09
|
|
422
|
+
${e("--no-hmr","brightYellow")} \u5173\u95ED\u70ED\u66F4\u65B0
|
|
422
423
|
|
|
423
|
-
${
|
|
424
|
+
${e("\u529F\u80FD:","brightGreen")}
|
|
424
425
|
- \u9759\u6001\u6587\u4EF6\u670D\u52A1
|
|
425
426
|
- TypeScript \u5373\u65F6\u7F16\u8BD1
|
|
426
427
|
- \u70ED\u6A21\u5757\u66FF\u6362\uFF08HMR\uFF09
|
|
427
428
|
- WebSocket \u5B9E\u65F6\u901A\u4FE1
|
|
428
429
|
|
|
429
|
-
${
|
|
430
|
-
${
|
|
431
|
-
${
|
|
432
|
-
${
|
|
430
|
+
${e("\u793A\u4F8B:","brightGreen")}
|
|
431
|
+
${e("$","dim")} lytx dev
|
|
432
|
+
${e("$","dim")} lytx dev --port 8080
|
|
433
|
+
${e("$","dim")} lytx dev --no-hmr
|
|
433
434
|
|
|
434
|
-
`,
|
|
435
|
-
${
|
|
435
|
+
`,Et=`
|
|
436
|
+
${e("lytx build","brightCyan")} - \u6784\u5EFA\u751F\u4EA7\u7248\u672C
|
|
436
437
|
|
|
437
|
-
${
|
|
438
|
+
${e("\u7528\u6CD5:","brightGreen")}
|
|
438
439
|
lytx build [options]
|
|
439
440
|
|
|
440
|
-
${
|
|
441
|
-
${
|
|
441
|
+
${e("\u9009\u9879:","brightGreen")}
|
|
442
|
+
${e("--mode <mode>","brightYellow")} \u6784\u5EFA\u6A21\u5F0F\uFF08\u9ED8\u8BA4: spa\uFF09
|
|
442
443
|
\u53EF\u9009\u503C: spa, ssr, ssg
|
|
443
|
-
${
|
|
444
|
-
${
|
|
445
|
-
${
|
|
444
|
+
${e("--minify","brightYellow")} \u538B\u7F29\u4EE3\u7801\uFF08\u53BB\u9664\u7A7A\u767D\u548C\u6CE8\u91CA\uFF09
|
|
445
|
+
${e("-o, --outDir <dir>","brightYellow")} \u8F93\u51FA\u76EE\u5F55\uFF08\u9ED8\u8BA4: dist\uFF09
|
|
446
|
+
${e("--entry <file>","brightYellow")} \u5165\u53E3\u6587\u4EF6\uFF08\u9ED8\u8BA4: index.html\uFF09
|
|
446
447
|
|
|
447
|
-
${
|
|
448
|
+
${e("\u529F\u80FD:","brightGreen")}
|
|
448
449
|
- TypeScript \u7F16\u8BD1
|
|
449
450
|
- \u6A21\u5757\u6253\u5305\uFF08\u5185\u8054\u4F9D\u8D56\uFF09
|
|
450
451
|
- \u53BB\u9664 console.log
|
|
451
452
|
- Source Map \u751F\u6210
|
|
452
453
|
- \u9759\u6001\u8D44\u6E90\u590D\u5236
|
|
453
454
|
|
|
454
|
-
${
|
|
455
|
-
${
|
|
456
|
-
${
|
|
457
|
-
${
|
|
455
|
+
${e("\u793A\u4F8B:","brightGreen")}
|
|
456
|
+
${e("$","dim")} lytx build
|
|
457
|
+
${e("$","dim")} lytx build --mode ssr
|
|
458
|
+
${e("$","dim")} lytx build --minify --outDir ./output
|
|
458
459
|
|
|
459
|
-
`,
|
|
460
|
-
${
|
|
460
|
+
`,Tt=`
|
|
461
|
+
${e("lytx preview","brightCyan")} - \u9884\u89C8\u6784\u5EFA\u7ED3\u679C
|
|
461
462
|
|
|
462
|
-
${
|
|
463
|
+
${e("\u7528\u6CD5:","brightGreen")}
|
|
463
464
|
lytx preview [options]
|
|
464
465
|
|
|
465
|
-
${
|
|
466
|
-
${
|
|
466
|
+
${e("\u9009\u9879:","brightGreen")}
|
|
467
|
+
${e("-p, --port <port>","brightYellow")} \u670D\u52A1\u7AEF\u53E3\uFF08\u9ED8\u8BA4: 4173\uFF09
|
|
467
468
|
|
|
468
|
-
${
|
|
469
|
-
${
|
|
470
|
-
${
|
|
469
|
+
${e("\u793A\u4F8B:","brightGreen")}
|
|
470
|
+
${e("$","dim")} lytx preview
|
|
471
|
+
${e("$","dim")} lytx preview --port 5000
|
|
471
472
|
|
|
472
|
-
`;function
|
|
473
|
+
`;function Ot(){console.log(""),console.log(` ${e(tt,"brightCyan")} v${e(Ht,"brightWhite")}`),console.log("")}function Lt(t){i.error(`\u672A\u77E5\u547D\u4EE4: ${e(t,"brightRed")}`),console.log(""),console.log(` \u8FD0\u884C ${e("lytx --help","brightCyan")} \u67E5\u770B\u53EF\u7528\u547D\u4EE4`),console.log("")}function Dt(t){return typeof t=="string"&&["spa","ssr","ssg"].includes(t)?t:"spa"}async function Gt(t){if(t.options.help){console.log(kt);return}t.args.length===0&&(i.error("\u8BF7\u63D0\u4F9B\u9879\u76EE\u540D\u79F0"),console.log(""),console.log(` \u7528\u6CD5: ${e("lytx create <name>","brightCyan")}`),console.log(""),console.log(` \u8FD0\u884C ${e("lytx create --help","brightCyan")} \u67E5\u770B\u66F4\u591A\u9009\u9879`),console.log(""),process.exit(1));let o=t.args[0];if(t.options.ts===!0||t.options.router===!0||t.options.store===!0||t.options.eslint===!0||typeof t.options.template=="string"&&["ssr","ssg"].includes(t.options.template)){let r={name:o,template:Dt(t.options.template),ts:t.options.ts===!0,router:t.options.router===!0,store:t.options.store===!0,eslint:t.options.eslint===!0};await D(r)}else{let r={template:typeof t.options.template=="string"?t.options.template:"spa"};await z(o,r)}}function It(t){if(t.options.help){console.log(Ft);return}let o={port:typeof t.options.port=="string"?parseInt(t.options.port,10):typeof t.options.p=="string"?parseInt(t.options.p,10):3e3,hmr:t.options["no-hmr"]!==!0};(isNaN(o.port)||o.port<1||o.port>65535)&&(i.error(`\u65E0\u6548\u7684\u7AEF\u53E3\u53F7: ${t.options.port||t.options.p}`),process.exit(1)),B(o)}async function Bt(t){if(t.options.help){console.log(Et);return}let o={minify:t.options.minify===!0,outDir:typeof t.options.outDir=="string"?t.options.outDir:typeof t.options.o=="string"?t.options.o:"dist",entry:typeof t.options.entry=="string"?t.options.entry:"index.html"};await K(o)}function Wt(t){if(t.options.help){console.log(Tt);return}let o=typeof t.options.port=="string"?parseInt(t.options.port,10):typeof t.options.p=="string"?parseInt(t.options.p,10):4173;(isNaN(o)||o<1||o>65535)&&(i.error(`\u65E0\u6548\u7684\u7AEF\u53E3\u53F7: ${t.options.port||t.options.p}`),process.exit(1));let n=Z.resolve(process.cwd(),"dist");Q.existsSync(n)||(i.error("\u672A\u627E\u5230\u6784\u5EFA\u8F93\u51FA\u76EE\u5F55 dist/\uFF0C\u8BF7\u5148\u8FD0\u884C lytx build"),process.exit(1)),B({port:o,root:n,hmr:!1})}async function Ut(){let t=N(process.argv);if(t.options.version){Ot();return}if(t.options.help&&!t.command){console.log(X);return}t.command||(console.log(X),process.exit(1));try{switch(t.command){case"create":await Gt(t);break;case"dev":It(t);break;case"build":await Bt(t);break;case"preview":Wt(t);break;default:Lt(t.command),process.exit(1)}}catch(o){let n=o instanceof Error?o.message:String(o);i.error(`\u6267\u884C\u5931\u8D25: ${n}`),console.log(""),console.log(` ${e("\u63D0\u793A:","brightYellow")} \u8BF7\u68C0\u67E5\u8F93\u5165\u53C2\u6570\u6216\u8FD0\u884C ${e("lytx --help","brightCyan")} \u67E5\u770B\u5E2E\u52A9`),console.log(""),process.exit(1)}}Ut();export{G as createHMREndpoint,Ct as createHMRServer,D as createProject,I as getHMRClientScript};
|