@lytjs/cli 4.0.2 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,17 +1,18 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var re=Object.create;var E=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var ae=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var ce=(e,o)=>{for(var n in o)E(e,n,{get:o[n],enumerable:!0})},Y=(e,o,n,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of ie(o))!le.call(e,s)&&s!==n&&E(e,s,{get:()=>o[s],enumerable:!(r=se(o,s))||r.enumerable});return e};var m=(e,o,n)=>(n=e!=null?re(ae(e)):{},Y(o||!e||!e.__esModule?E(n,"default",{value:e,enumerable:!0}):n,e)),pe=e=>Y(E({},"__esModule",{value:!0}),e);var Qe={};ce(Qe,{createHMREndpoint:()=>G,createHMRServer:()=>V,createProject:()=>L,getHMRClientScript:()=>I});module.exports=pe(Qe);var te=m(require("fs")),oe=m(require("path"));var y=m(require("fs")),U=m(require("path")),ue="\x1B[0m",de={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 t(e,o){let n=de[o];return n?`${n}${e}${ue}`:e}function z(e){let o=e.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 a=s.indexOf("=");if(a!==-1){let p=s.slice(2,a),l=s.slice(a+1);n.options[p]=l}else{let p=s.slice(2),l=o[r+1];l&&!l.startsWith("-")?(n.options[p]=l,r++):n.options[p]=!0}r++}else if(s.startsWith("-")&&s.length>1){let a=s.slice(1),p=o[r+1];p&&!p.startsWith("-")?(n.options[a]=p,r++):n.options[a]=!0,r++}else n.command?(n.args.push(s),r++):(n.command=s,r++)}return n}function $(e){y.existsSync(e)||y.mkdirSync(e,{recursive:!0})}function F(e){return y.existsSync(e)}function k(e){return y.readFileSync(e,"utf-8")}function S(e,o){let n=U.dirname(e);$(n),y.writeFileSync(e,o,"utf-8")}var i={info(e){console.log(`${t("[INFO]","blue")} ${e}`)},warn(e){console.log(`${t("[WARN]","yellow")} ${e}`)},error(e){console.error(`${t("[ERROR]","red")} ${e}`)},success(e){console.log(`${t("[SUCCESS]","green")} ${e}`)}};var T=m(require("path"));function fe(){return`<!DOCTYPE html>
2
+ "use strict";var ne=Object.create;var F=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var ae=Object.getPrototypeOf,ce=Object.prototype.hasOwnProperty;var le=(e,o)=>{for(var r in o)F(e,r,{get:o[r],enumerable:!0})},N=(e,o,r,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of ie(o))!ce.call(e,s)&&s!==r&&F(e,s,{get:()=>o[s],enumerable:!(n=se(o,s))||n.enumerable});return e};var h=(e,o,r)=>(r=e!=null?ne(ae(e)):{},N(o||!e||!e.__esModule?F(r,"default",{value:e,enumerable:!0}):r,e)),pe=e=>N(F({},"__esModule",{value:!0}),e);var Ze={};le(Ze,{createHMREndpoint:()=>G,createHMRServer:()=>V,createProject:()=>O,getHMRClientScript:()=>B});module.exports=pe(Ze);var te=h(require("fs")),oe=h(require("path"));var v=h(require("fs")),U=h(require("path")),ue="\x1B[0m",de={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 t(e,o){let r=de[o];return r?`${r}${e}${ue}`:e}function Y(e){let o=e.slice(2),r={command:"",args:[],options:{},raw:o},n=0;for(;n<o.length;){let s=o[n];if(s==="--help"||s==="-h")r.options.help=!0,n++;else if(s==="--version"||s==="-v")r.options.version=!0,n++;else if(s.startsWith("--")){let c=s.indexOf("=");if(c!==-1){let d=s.slice(2,c),p=s.slice(c+1);r.options[d]=p}else{let d=s.slice(2),p=o[n+1];p&&!p.startsWith("-")?(r.options[d]=p,n++):r.options[d]=!0}n++}else if(s.startsWith("-")&&s.length>1){let c=s.slice(1),d=o[n+1];d&&!d.startsWith("-")?(r.options[c]=d,n++):r.options[c]=!0,n++}else r.command?(r.args.push(s),n++):(r.command=s,n++)}return r}function j(e){v.existsSync(e)||v.mkdirSync(e,{recursive:!0})}function H(e){return v.existsSync(e)}function R(e){return v.readFileSync(e,"utf-8")}function C(e,o){let r=U.dirname(e);j(r),v.writeFileSync(e,o,"utf-8")}var i={info(e){console.log(`${t("[INFO]","blue")} ${e}`)},warn(e){console.log(`${t("[WARN]","yellow")} ${e}`)},error(e){console.error(`${t("[ERROR]","red")} ${e}`)},success(e){console.log(`${t("[SUCCESS]","green")} ${e}`)}};var D=h(require("path"));function fe(){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 ge(){return`import { createApp } from '@lytjs/lytjs';
15
+ `}function me(){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 me(){return`import { defineComponent } from '@lytjs/lytjs';
23
+ `}function ge(){return`import { defineComponent, ref, computed } from '@lytjs/lytjs';
23
24
 
24
25
  // \u5B9A\u4E49\u6839\u7EC4\u4EF6
25
26
  const App = defineComponent({
@@ -28,23 +29,105 @@ const App = defineComponent({
28
29
  // \u7EC4\u4EF6\u6A21\u677F
29
30
  template: \`
30
31
  <div class="app">
31
- <h1>Hello Lyt!</h1>
32
- <p>\u6B22\u8FCE\u4F7F\u7528 Lyt \u6846\u67B6</p>
32
+ <header class="app-header">
33
+ <div class="logo">
34
+ <span class="logo-text">Lyt</span>
35
+ </div>
36
+ </header>
37
+
38
+ <main class="app-main">
39
+ <div class="welcome-section">
40
+ <h1>\u6B22\u8FCE\u4F7F\u7528 Lyt.js!</h1>
41
+ <p>\u8F7B\u5199\u8F7B\u8DD1\uFF0C\u6240\u89C1\u5373\u4EE3\u7801</p>
42
+
43
+ <div class="counter-section">
44
+ <h2>\u8BA1\u6570\u5668\u793A\u4F8B</h2>
45
+ <p class="count-display">
46
+ \u5F53\u524D\u8BA1\u6570: <strong>{{ count }}</strong>
47
+ </p>
48
+ <p class="double-display">
49
+ \u53CC\u500D: <strong>{{ double }}</strong>
50
+ </p>
51
+
52
+ <div class="button-group">
53
+ <button class="btn btn-primary" on-click="increment">+1</button>
54
+ <button class="btn btn-secondary" on-click="decrement">-1</button>
55
+ <button class="btn btn-success" on-click="reset">\u91CD\u7F6E</button>
56
+ </div>
57
+ </div>
58
+
59
+ <div class="features-section">
60
+ <h2>\u6838\u5FC3\u529F\u80FD</h2>
61
+ <ul>
62
+ <li v-for="feature in features" :key="feature">
63
+ {{ feature }}
64
+ </li>
65
+ </ul>
66
+ </div>
67
+ </div>
68
+ </main>
69
+
70
+ <footer class="app-footer">
71
+ <p>
72
+ \u7528 \u2764\uFE0F \u6253\u9020
73
+ </p>
74
+ </footer>
33
75
  </div>
34
76
  \`,
35
77
 
36
- // \u7EC4\u4EF6\u72B6\u6001
78
+ // \u54CD\u5E94\u5F0F\u6570\u636E
37
79
  setup() {
38
- const message: string = 'Hello World';
80
+ const count = ref(0);
81
+ const double = computed(() => count.value * 2);
82
+
83
+ const features = [
84
+ '\u54CD\u5E94\u5F0F\u7CFB\u7EDF\uFF08Proxy + Signal\uFF09',
85
+ '\u865A\u62DF DOM + Patch Flag \u4F18\u5316',
86
+ '\u7EC4\u4EF6\u7CFB\u7EDF\uFF08Options + Composition API\uFF09',
87
+ '\u5185\u7F6E\u8DEF\u7531',
88
+ '\u72B6\u6001\u7BA1\u7406',
89
+ 'CLI \u5DE5\u5177\u94FE',
90
+ '\u6D4F\u89C8\u5668 DevTools',
91
+ '28+ UI \u7EC4\u4EF6',
92
+ ];
93
+
94
+ const increment = () => {
95
+ count.value++;
96
+ };
97
+
98
+ const decrement = () => {
99
+ count.value--;
100
+ };
101
+
102
+ const reset = () => {
103
+ count.value = 0;
104
+ };
39
105
 
40
106
  return {
41
- message,
107
+ count,
108
+ double,
109
+ features,
110
+ increment,
111
+ decrement,
112
+ reset,
42
113
  };
43
114
  },
44
115
  });
45
116
 
46
117
  export default App;
47
- `}function he(){return`/* Lyt \u5168\u5C40\u6837\u5F0F */
118
+ `}function he(){return`/* Lyt.js \u5E94\u7528\u6837\u5F0F */
119
+
120
+ :root {
121
+ --primary-color: #42b883;
122
+ --primary-hover: #35a06f;
123
+ --secondary-color: #747b88;
124
+ --success-color: #10b981;
125
+ --danger-color: #ef4444;
126
+ --text-color: #333;
127
+ --bg-color: #f9fafb;
128
+ --card-bg: #ffffff;
129
+ --border-color: #e5e7eb;
130
+ }
48
131
 
49
132
  * {
50
133
  margin: 0;
@@ -53,56 +136,266 @@ export default App;
53
136
  }
54
137
 
55
138
  body {
56
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
57
- 'Helvetica Neue', Arial, sans-serif;
58
- -webkit-font-smoothing: antialiased;
59
- -moz-osx-font-smoothing: grayscale;
60
- color: #2c3e50;
139
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
140
+ color: var(--text-color);
141
+ background-color: var(--bg-color);
142
+ line-height: 1.6;
61
143
  }
62
144
 
63
145
  .app {
146
+ min-height: 100vh;
147
+ display: flex;
148
+ flex-direction: column;
149
+ }
150
+
151
+ .app-header {
152
+ background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
153
+ padding: 1.5rem 2rem;
154
+ color: white;
155
+ box-shadow: 0 2px 10px rgba(66, 184, 131, 0.2);
156
+ }
157
+
158
+ .logo {
159
+ font-size: 1.8rem;
160
+ font-weight: 700;
161
+ }
162
+
163
+ .logo-text {
164
+ letter-spacing: 2px;
165
+ }
166
+
167
+ .app-main {
168
+ flex: 1;
169
+ padding: 3rem 2rem;
170
+ max-width: 900px;
171
+ margin: 0 auto;
172
+ width: 100%;
173
+ }
174
+
175
+ .welcome-section {
64
176
  text-align: center;
65
- padding: 40px 20px;
66
177
  }
67
178
 
68
- .app h1 {
179
+ .welcome-section h1 {
69
180
  font-size: 2.5rem;
70
- color: #42b883;
71
- margin-bottom: 10px;
181
+ margin-bottom: 0.5rem;
182
+ color: var(--primary-color);
72
183
  }
73
184
 
74
- .app p {
185
+ .welcome-section p {
75
186
  font-size: 1.2rem;
76
- color: #666;
187
+ color: var(--secondary-color);
188
+ margin-bottom: 2rem;
189
+ }
190
+
191
+ .counter-section {
192
+ background: var(--card-bg);
193
+ border-radius: 12px;
194
+ padding: 2rem;
195
+ margin: 2rem 0;
196
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
197
+ border: 1px solid var(--border-color);
198
+ }
199
+
200
+ .counter-section h2 {
201
+ margin-bottom: 1rem;
202
+ color: var(--text-color);
203
+ }
204
+
205
+ .count-display,
206
+ .double-display {
207
+ font-size: 1.25rem;
208
+ margin: 0.75rem 0;
209
+ }
210
+
211
+ .button-group {
212
+ display: flex;
213
+ justify-content: center;
214
+ gap: 1rem;
215
+ margin-top: 1.5rem;
216
+ flex-wrap: wrap;
217
+ }
218
+
219
+ .btn {
220
+ padding: 0.75rem 1.5rem;
221
+ border: none;
222
+ border-radius: 8px;
223
+ font-size: 1rem;
224
+ font-weight: 500;
225
+ cursor: pointer;
226
+ transition: all 0.2s ease;
227
+ color: white;
228
+ }
229
+
230
+ .btn:hover {
231
+ transform: translateY(-2px);
232
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
233
+ }
234
+
235
+ .btn:active {
236
+ transform: translateY(0);
237
+ }
238
+
239
+ .btn-primary {
240
+ background: var(--primary-color);
241
+ }
242
+
243
+ .btn-primary:hover {
244
+ background: var(--primary-hover);
245
+ }
246
+
247
+ .btn-secondary {
248
+ background: var(--secondary-color);
249
+ }
250
+
251
+ .btn-secondary:hover {
252
+ background: #5d6470;
253
+ }
254
+
255
+ .btn-success {
256
+ background: var(--success-color);
257
+ }
258
+
259
+ .btn-success:hover {
260
+ background: #059669;
77
261
  }
78
- `}function ye(e){return JSON.stringify({name:e,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)+`
262
+
263
+ .features-section {
264
+ margin-top: 2rem;
265
+ text-align: left;
266
+ }
267
+
268
+ .features-section h2 {
269
+ text-align: center;
270
+ margin-bottom: 1.5rem;
271
+ color: var(--text-color);
272
+ }
273
+
274
+ .features-section ul {
275
+ list-style: none;
276
+ padding: 0;
277
+ max-width: 600px;
278
+ margin: 0 auto;
279
+ }
280
+
281
+ .features-section li {
282
+ padding: 0.75rem 1rem;
283
+ margin: 0.5rem 0;
284
+ background: var(--card-bg);
285
+ border-radius: 8px;
286
+ border-left: 4px solid var(--primary-color);
287
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
288
+ }
289
+
290
+ .app-footer {
291
+ padding: 1.5rem 2rem;
292
+ text-align: center;
293
+ color: var(--secondary-color);
294
+ border-top: 1px solid var(--border-color);
295
+ background: var(--card-bg);
296
+ }
297
+
298
+ @media (max-width: 640px) {
299
+ .welcome-section h1 {
300
+ font-size: 2rem;
301
+ }
302
+
303
+ .app-main {
304
+ padding: 2rem 1rem;
305
+ }
306
+ }
307
+ `}function ye(e){return JSON.stringify({name:e,version:"0.1.0",type:"module",private:!0,scripts:{dev:"lytx dev",build:"lytx build",preview:"lytx preview"},dependencies:{"@lytjs/lytjs":"latest"},devDependencies:{"@lytjs/cli":"latest"}},null,2)+`
79
308
  `}function be(){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)+`
80
- `}function xe(){return`# \u4F9D\u8D56
309
+ `}function xe(){return`# Dependencies
81
310
  node_modules/
311
+ .pnp
312
+ .pnp.js
82
313
 
83
- # \u6784\u5EFA\u8F93\u51FA
314
+ # Build outputs
84
315
  dist/
316
+ build/
317
+ *.log
318
+ npm-debug.log*
85
319
 
86
- # \u7F16\u8F91\u5668\u914D\u7F6E
320
+ # IDE
87
321
  .vscode/
88
322
  .idea/
89
323
  *.swp
90
324
  *.swo
91
325
 
92
- # \u7CFB\u7EDF\u6587\u4EF6
326
+ # OS
93
327
  .DS_Store
94
328
  Thumbs.db
95
329
 
96
- # \u73AF\u5883\u53D8\u91CF
330
+ # Environment
97
331
  .env.local
98
332
  .env.*.local
99
333
 
100
- # \u65E5\u5FD7
101
- *.log
102
- npm-debug.log*
103
- `}async function _(e,o={}){let n=o.template||"spa",r=T.resolve(process.cwd(),e);i.info(`\u6B63\u5728\u521B\u5EFA Lyt \u9879\u76EE: ${t(e,"brightCyan")}`),i.info(`\u4F7F\u7528\u6A21\u677F: ${t(n,"brightCyan")}`),F(r)&&(i.error(`\u76EE\u5F55 "${e}" \u5DF2\u5B58\u5728\uFF0C\u8BF7\u9009\u62E9\u5176\u4ED6\u540D\u79F0\u6216\u5220\u9664\u5DF2\u6709\u76EE\u5F55`),process.exit(1)),$(r);let s=[{filePath:"index.html",content:fe()},{filePath:"src/main.ts",content:ge()},{filePath:"src/App.ts",content:me()},{filePath:"src/style.css",content:he()},{filePath:"package.json",content:ye(e)},{filePath:"tsconfig.json",content:be()},{filePath:".gitignore",content:xe()}];for(let a of s){let p=T.join(r,a.filePath);S(p,a.content),i.success(` \u521B\u5EFA ${a.filePath}`)}console.log(""),i.success(`\u9879\u76EE ${t(e,"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(` ${t("cd","brightGreen")} ${e}`),console.log(` ${t("npm install","brightGreen")}`),console.log(` ${t("npm run dev","brightGreen")}`),console.log("")}var D=m(require("path"));function ve(e){let o={name:e.name,version:"0.1.0",private:!0,type:"module",scripts:{dev:"lytx dev",build:"lytx build",preview:"lytx preview"},dependencies:{"@lytjs/lytjs":"latest"}};return e.ts&&(o.devDependencies={"@lytjs/cli":"latest",typescript:"^5.0.0"}),e.eslint&&(o.devDependencies=o.devDependencies||{},o.devDependencies.eslint="^8.0.0",o.scripts=o.scripts||{},o.scripts.lint="eslint src --ext .ts,.js"),e.router&&(o.dependencies["@lytjs/router"]="latest"),e.store&&(o.dependencies["@lytjs/store"]="latest"),JSON.stringify(o,null,2)+`
334
+ # Cache
335
+ *.cache
336
+ .cache/
337
+ `}function ve(e){return`# ${e}
338
+
339
+ \u8FD9\u662F\u4E00\u4E2A\u4F7F\u7528 [Lyt.js](https://gitee.com/lytjs/lytjs) \u6846\u67B6\u521B\u5EFA\u7684\u9879\u76EE\u3002
340
+
341
+ ## \u7279\u6027
342
+
343
+ - \u26A1 **\u96F6\u4F9D\u8D56** - \u7EAF\u539F\u751F\u5B9E\u73B0\uFF0C\u4E0D\u4F9D\u8D56\u4EFB\u4F55\u7B2C\u4E09\u65B9\u5E93
344
+ - \u{1F680} **\u8D85\u8F7B\u91CF** - \u6838\u5FC3\u4EC5 34.56KB\uFF0C\u6781\u901F\u52A0\u8F7D
345
+ - \u{1F3A8} **Vue 3 \u517C\u5BB9** - API \u9AD8\u5EA6\u517C\u5BB9\uFF0C\u8FC1\u79FB\u6210\u672C\u4F4E
346
+ - \u{1F527} **\u5F00\u7BB1\u5373\u7528** - \u5185\u7F6E\u8DEF\u7531\u3001\u72B6\u6001\u7BA1\u7406\u3001\u7EC4\u4EF6\u5E93
347
+
348
+ ## \u5FEB\u901F\u5F00\u59CB
349
+
350
+ ### \u5B89\u88C5\u4F9D\u8D56
351
+
352
+ \`\`\`bash
353
+ npm install
354
+ \`\`\`
355
+
356
+ ### \u542F\u52A8\u5F00\u53D1\u670D\u52A1\u5668
357
+
358
+ \`\`\`bash
359
+ npm run dev
360
+ \`\`\`
361
+
362
+ ### \u6784\u5EFA\u751F\u4EA7\u7248\u672C
363
+
364
+ \`\`\`bash
365
+ npm run build
366
+ \`\`\`
367
+
368
+ ## \u9879\u76EE\u7ED3\u6784
369
+
370
+ \`\`\`
371
+ ${e}/
372
+ \u251C\u2500\u2500 index.html # HTML \u5165\u53E3
373
+ \u251C\u2500\u2500 package.json # \u9879\u76EE\u914D\u7F6E
374
+ \u251C\u2500\u2500 tsconfig.json # TypeScript \u914D\u7F6E
375
+ \u251C\u2500\u2500 src/
376
+ \u2502 \u251C\u2500\u2500 main.ts # \u5E94\u7528\u5165\u53E3
377
+ \u2502 \u251C\u2500\u2500 App.ts # \u6839\u7EC4\u4EF6
378
+ \u2502 \u2514\u2500\u2500 style.css # \u5168\u5C40\u6837\u5F0F
379
+ \u2514\u2500\u2500 README.md # \u9879\u76EE\u6587\u6863
380
+ \`\`\`
381
+
382
+ ## \u5B66\u4E60\u8D44\u6E90
383
+
384
+ - \u{1F4D6} [Lyt.js \u5B98\u65B9\u6587\u6863](https://gitee.com/lytjs/lytjs)
385
+ - \u{1F4A1} [\u5FEB\u901F\u5F00\u59CB\u6307\u5357](https://gitee.com/lytjs/lytjs)
386
+ - \u{1F527} [API \u53C2\u8003](https://gitee.com/lytjs/lytjs)
387
+
388
+ ## \u793E\u533A\u652F\u6301
389
+
390
+ - \u{1F310} Gitee: [https://gitee.com/lytjs/lytjs](https://gitee.com/lytjs/lytjs)
391
+ - \u{1F4AC} Issues: [https://gitee.com/lytjs/lytjs/issues](https://gitee.com/lytjs/lytjs/issues)
392
+
393
+ ## License
394
+
395
+ MIT
396
+ `}async function _(e,o={}){let r=o.template||"spa",n=D.resolve(process.cwd(),e);i.info(`\u6B63\u5728\u521B\u5EFA Lyt \u9879\u76EE: ${t(e,"brightCyan")}`),i.info(`\u4F7F\u7528\u6A21\u677F: ${t(r,"brightCyan")}`),H(n)&&(i.error(`\u76EE\u5F55 "${e}" \u5DF2\u5B58\u5728\uFF0C\u8BF7\u9009\u62E9\u5176\u4ED6\u540D\u79F0\u6216\u5220\u9664\u5DF2\u6709\u76EE\u5F55`),process.exit(1)),j(n);let s=[{filePath:"index.html",content:fe()},{filePath:"src/main.ts",content:me()},{filePath:"src/App.ts",content:ge()},{filePath:"src/style.css",content:he()},{filePath:"package.json",content:ye(e)},{filePath:"tsconfig.json",content:be()},{filePath:".gitignore",content:xe()},{filePath:"README.md",content:ve(e)}];for(let c of s){let d=D.join(n,c.filePath);C(d,c.content),i.success(` \u521B\u5EFA ${c.filePath}`)}console.log(""),i.success(`\u9879\u76EE ${t(e,"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(` ${t("cd","brightGreen")} ${e}`),console.log(` ${t("npm install","brightGreen")}`),console.log(` ${t("npm run dev","brightGreen")}`),console.log("")}var L=h(require("path"));function we(e){let o={name:e.name,version:"0.1.0",private:!0,type:"module",scripts:{dev:"lytx dev",build:"lytx build",preview:"lytx preview"},dependencies:{"@lytjs/lytjs":"latest"}};return e.ts&&(o.devDependencies={"@lytjs/cli":"latest",typescript:"^5.0.0"}),e.eslint&&(o.devDependencies=o.devDependencies||{},o.devDependencies.eslint="^8.0.0",o.scripts=o.scripts||{},o.scripts.lint="eslint src --ext .ts,.js"),e.router&&(o.dependencies["@lytjs/router"]="latest"),e.store&&(o.dependencies["@lytjs/store"]="latest"),JSON.stringify(o,null,2)+`
104
397
  `}function $e(e){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 e.template==="ssr"&&(o.compilerOptions.types=["node"]),JSON.stringify(o,null,2)+`
105
- `}function we(e){let o=e.ts?".ts":".js";return`<!DOCTYPE html>
398
+ `}function je(e){let o=e.ts?".ts":".js";return`<!DOCTYPE html>
106
399
  <html lang="zh-CN">
107
400
  <head>
108
401
  <meta charset="UTF-8" />
@@ -116,9 +409,9 @@ npm-debug.log*
116
409
  </body>
117
410
  </html>
118
411
  `}function Se(e){let o=["// Lytx \u914D\u7F6E\u6587\u4EF6","import { defineConfig } from '@lytjs/lytjs'","","export default defineConfig({"," // \u6784\u5EFA\u6A21\u5F0F",` mode: '${e.template}',`];return e.router&&(o.push(" // \u8DEF\u7531\u914D\u7F6E"),o.push(" router: {"),o.push(" historyMode: true,"),o.push(" },")),e.store&&(o.push(" // \u72B6\u6001\u7BA1\u7406\u914D\u7F6E"),o.push(" store: {"),o.push(" strict: true,"),o.push(" },")),o.push("})"),o.push(""),o.join(`
119
- `)}function Ce(e){let o=e.ts?".ts":".js",n=["import { createApp } from '@lytjs/lytjs'","import App from './App.lyt'","import './styles/main.css'"];return e.router&&n.push("import { router } from './router'"),e.store&&n.push("import { store } from './store'"),n.push(""),n.push("// \u521B\u5EFA\u5E94\u7528\u5B9E\u4F8B"),n.push("const app = createApp(App)"),e.router&&n.push("app.use(router)"),e.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(`
412
+ `)}function Ce(e){let o=e.ts?".ts":".js",r=["import { createApp } from '@lytjs/lytjs'","import App from './App.lyt'","import './styles/main.css'"];return e.router&&r.push("import { router } from './router'"),e.store&&r.push("import { store } from './store'"),r.push(""),r.push("// \u521B\u5EFA\u5E94\u7528\u5B9E\u4F8B"),r.push("const app = createApp(App)"),e.router&&r.push("app.use(router)"),e.store&&r.push("app.use(store)"),r.push(""),r.push("// \u5C06\u5E94\u7528\u6302\u8F7D\u5230 #app \u5143\u7D20"),r.push("app.mount('#app')"),r.join(`
120
413
  `)+`
121
- `}function je(){return`<template>
414
+ `}function Pe(){return`<template>
122
415
  <div class="app">
123
416
  <Header />
124
417
  <main>
@@ -146,7 +439,7 @@ export default defineComponent({
146
439
  padding: 20px;
147
440
  }
148
441
  </style>
149
- `}function Pe(){return`import { defineComponent } from '@lytjs/lytjs'
442
+ `}function Me(){return`import { defineComponent } from '@lytjs/lytjs'
150
443
 
151
444
  export default defineComponent({
152
445
  name: 'HomePage',
@@ -158,7 +451,7 @@ export default defineComponent({
158
451
  </div>
159
452
  \`,
160
453
  })
161
- `}function Me(){return`import { defineComponent } from '@lytjs/lytjs'
454
+ `}function Re(){return`import { defineComponent } from '@lytjs/lytjs'
162
455
 
163
456
  export default defineComponent({
164
457
  name: 'AboutPage',
@@ -170,7 +463,7 @@ export default defineComponent({
170
463
  </div>
171
464
  \`,
172
465
  })
173
- `}function Re(){return`import { defineComponent } from '@lytjs/lytjs'
466
+ `}function ke(){return`import { defineComponent } from '@lytjs/lytjs'
174
467
 
175
468
  export default defineComponent({
176
469
  name: 'Header',
@@ -184,7 +477,7 @@ export default defineComponent({
184
477
  </header>
185
478
  \`,
186
479
  })
187
- `}function He(){return`import { createRouter, createWebHistory } from '@lytjs/router'
480
+ `}function Ae(){return`import { createRouter, createWebHistory } from '@lytjs/router'
188
481
  import HomePage from '../pages/index'
189
482
  import AboutPage from '../pages/about'
190
483
 
@@ -201,7 +494,7 @@ export const router = createRouter({
201
494
  },
202
495
  ],
203
496
  })
204
- `}function Ae(){return`import { createStore } from '@lytjs/store'
497
+ `}function Ee(){return`import { createStore } from '@lytjs/store'
205
498
 
206
499
  export const store = createStore({
207
500
  state: {
@@ -229,7 +522,7 @@ export const store = createStore({
229
522
  doubleCount: (state: any) => state.count * 2,
230
523
  },
231
524
  })
232
- `}function Ee(){return`/* \u5168\u5C40\u6837\u5F0F */
525
+ `}function Te(){return`/* \u5168\u5C40\u6837\u5F0F */
233
526
 
234
527
  * {
235
528
  margin: 0;
@@ -257,13 +550,13 @@ a:hover {
257
550
  <rect width="32" height="32" rx="6" fill="#42b883"/>
258
551
  <text x="16" y="22" text-anchor="middle" fill="white" font-size="18" font-weight="bold">L</text>
259
552
  </svg>
260
- `}function ke(){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)+`
261
- `}async function L(e){let{name:o,template:n,ts:r,router:s,store:a,eslint:p}=e,l=D.resolve(process.cwd(),o);if(i.info(`\u6B63\u5728\u521B\u5EFA Lyt \u9879\u76EE: ${t(o,"brightCyan")}`),i.info(`\u4F7F\u7528\u6A21\u677F: ${t(n,"brightCyan")}`),F(l))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`);$(l);let c=[{filePath:"package.json",content:ve(e)},{filePath:"index.html",content:we(e)},{filePath:"lytx.config.ts",content:Se(e)},{filePath:"src/main.ts",content:Ce(e)},{filePath:"src/App.lyt",content:je()},{filePath:"src/pages/index.ts",content:Pe()},{filePath:"src/pages/about.ts",content:Me()},{filePath:"src/components/Header.ts",content:Re()},{filePath:"src/styles/main.css",content:Ee()},{filePath:"public/favicon.svg",content:Fe()}];r&&c.push({filePath:"tsconfig.json",content:$e(e)}),s&&c.push({filePath:"src/router/index.ts",content:He()}),a&&c.push({filePath:"src/store/index.ts",content:Ae()}),p&&c.push({filePath:".eslintrc.json",content:ke()});for(let u of c){let d=D.join(l,u.filePath);S(d,u.content),i.success(` \u521B\u5EFA ${u.filePath}`)}console.log(""),i.success(`\u9879\u76EE ${t(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(` ${t("cd","brightGreen")} ${o}`),console.log(` ${t("npm install","brightGreen")}`),console.log(` ${t("npm run dev","brightGreen")}`),console.log("")}var K=m(require("http")),B=m(require("fs")),P=m(require("path"));var J=m(require("http")),j=m(require("fs")),b=m(require("path")),q=m(require("crypto")),O=class{constructor(){this.clients=[]}handleUpgrade(o,n,r){let s=o.headers["sec-websocket-key"];if(!s){n.destroy();return}let a=q.createHash("sha1").update(s+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");n.write(`HTTP/1.1 101 Switching Protocols\r
553
+ `}function He(){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)+`
554
+ `}async function O(e){let{name:o,template:r,ts:n,router:s,store:c,eslint:d}=e,p=L.resolve(process.cwd(),o);if(i.info(`\u6B63\u5728\u521B\u5EFA Lyt \u9879\u76EE: ${t(o,"brightCyan")}`),i.info(`\u4F7F\u7528\u6A21\u677F: ${t(r,"brightCyan")}`),H(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`);j(p);let u=[{filePath:"package.json",content:we(e)},{filePath:"index.html",content:je(e)},{filePath:"lytx.config.ts",content:Se(e)},{filePath:"src/main.ts",content:Ce(e)},{filePath:"src/App.lyt",content:Pe()},{filePath:"src/pages/index.ts",content:Me()},{filePath:"src/pages/about.ts",content:Re()},{filePath:"src/components/Header.ts",content:ke()},{filePath:"src/styles/main.css",content:Te()},{filePath:"public/favicon.svg",content:Fe()}];n&&u.push({filePath:"tsconfig.json",content:$e(e)}),s&&u.push({filePath:"src/router/index.ts",content:Ae()}),c&&u.push({filePath:"src/store/index.ts",content:Ee()}),d&&u.push({filePath:".eslintrc.json",content:He()});for(let l of u){let f=L.join(p,l.filePath);C(f,l.content),i.success(` \u521B\u5EFA ${l.filePath}`)}console.log(""),i.success(`\u9879\u76EE ${t(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(` ${t("cd","brightGreen")} ${o}`),console.log(` ${t("npm install","brightGreen")}`),console.log(` ${t("npm run dev","brightGreen")}`),console.log("")}var K=h(require("http")),P=h(require("fs")),b=h(require("path"));var J=h(require("http")),k=h(require("fs")),w=h(require("path")),q=h(require("crypto")),I=class{constructor(){this.clients=[]}handleUpgrade(o,r,n){let s=o.headers["sec-websocket-key"];if(!s){r.destroy();return}let c=q.createHash("sha1").update(s+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");r.write(`HTTP/1.1 101 Switching Protocols\r
262
555
  Upgrade: websocket\r
263
556
  Connection: Upgrade\r
264
- Sec-WebSocket-Accept: ${a}\r
557
+ Sec-WebSocket-Accept: ${c}\r
265
558
  \r
266
- `);let p={socket:n,isAlive:!0};n.on("close",()=>{this.clients=this.clients.filter(l=>l!==p)}),n.on("error",()=>{this.clients=this.clients.filter(l=>l!==p)}),this.clients.push(p)}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"),a=this.createFrame(129,s);r.socket.write(a)}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 a=Buffer.alloc(s+r);return a[0]=o,r<126?a[1]=r:r<65536?(a[1]=126,a.writeUInt16BE(r,2)):(a[1]=127,a.writeUInt32BE(0,2),a.writeUInt32BE(r,6)),n.copy(a,s),a}getClientCount(){return this.clients.length}closeAll(){for(let o of this.clients)try{o.socket.destroy()}catch(n){}this.clients=[]}};function V(e){let o=new O,n=[],r=[],s=null,a=!1;function p(c){let u=b.extname(c).toLowerCase();if(u===".css")return"css";let d=b.basename(c);return d.startsWith("lytx.config")||d==="tsconfig.json"||d==="package.json"?"reload":u===".ts"||u===".tsx"||u===".lyt"||u===".js"||u===".jsx"?"update":"reload"}function l(c){try{let u=j.readdirSync(c,{withFileTypes:!0});for(let d of u){let f=b.join(c,d.name);if(d.isDirectory()){if(d.name==="node_modules"||d.name===".git"||d.name==="dist")continue;l(f)}else if(d.isFile()){let M=b.extname(d.name).toLowerCase();if(new Set([".ts",".tsx",".js",".jsx",".css",".html",".json",".lyt"]).has(M))try{let R=j.watch(f,{persistent:!1},W=>{if(W==="change"){let H=b.relative(e,f);for(let w of n)try{w(H)}catch(A){}let C=p(f),v={type:C,path:`/${H}`};if(C==="css")try{v.content=j.readFileSync(f,"utf-8")}catch(w){}o.broadcast(JSON.stringify(v))}});r.push(R)}catch(R){}}}}catch(u){}}return{start(c){a||(a=!0,s=J.createServer((u,d)=>{d.writeHead(426,{"Content-Type":"text/plain"}),d.end("Upgrade Required")}),s.on("upgrade",(u,d,f)=>{o.handleUpgrade(u,d,f)}),s.listen(c,()=>{}),l(e))},stop(){a=!1;for(let c of r)try{c.close()}catch(u){}if(r.length=0,o.closeAll(),s){try{s.close()}catch(c){}s=null}},onFileChange(c){n.push(c)},notifyClient(c){o.broadcast(JSON.stringify(c))}}}function G(e){let o=new O;return e.on("upgrade",(n,r,s)=>{o.handleUpgrade(n,r,s)}),{broadcast(n){o.broadcast(n)},getClientCount(){return o.getClientCount()}}}function I(){return`(function() {
559
+ `);let d={socket:r,isAlive:!0};r.on("close",()=>{this.clients=this.clients.filter(p=>p!==d)}),r.on("error",()=>{this.clients=this.clients.filter(p=>p!==d)}),this.clients.push(d)}broadcast(o){let r=[];for(let n of this.clients)try{if(!n.isAlive){r.push(n);continue}let s=Buffer.from(o,"utf-8"),c=this.createFrame(129,s);n.socket.write(c)}catch(s){r.push(n)}for(let n of r){this.clients=this.clients.filter(s=>s!==n);try{n.socket.destroy()}catch(s){}}}createFrame(o,r){let n=r.length,s;n<126?s=2:n<65536?s=4:s=10;let c=Buffer.alloc(s+n);return c[0]=o,n<126?c[1]=n:n<65536?(c[1]=126,c.writeUInt16BE(n,2)):(c[1]=127,c.writeUInt32BE(0,2),c.writeUInt32BE(n,6)),r.copy(c,s),c}getClientCount(){return this.clients.length}closeAll(){for(let o of this.clients)try{o.socket.destroy()}catch(r){}this.clients=[]}};function V(e){let o=new I,r=[],n=[],s=null,c=!1;function d(u){let l=w.extname(u).toLowerCase();if(l===".css")return"css";let f=w.basename(u);return f.startsWith("lytx.config")||f==="tsconfig.json"||f==="package.json"?"reload":l===".ts"||l===".tsx"||l===".lyt"||l===".js"||l===".jsx"?"update":"reload"}function p(u){try{let l=k.readdirSync(u,{withFileTypes:!0});for(let f of l){let a=w.join(u,f.name);if(f.isDirectory()){if(f.name==="node_modules"||f.name===".git"||f.name==="dist")continue;p(a)}else if(f.isFile()){let g=w.extname(f.name).toLowerCase();if(new Set([".ts",".tsx",".js",".jsx",".css",".html",".json",".lyt"]).has(g))try{let A=k.watch(a,{persistent:!1},z=>{if(z==="change"){let E=w.relative(e,a);for(let S of r)try{S(E)}catch(T){}let M=d(a),$={type:M,path:`/${E}`};if(M==="css")try{$.content=k.readFileSync(a,"utf-8")}catch(S){}o.broadcast(JSON.stringify($))}});n.push(A)}catch(A){}}}}catch(l){}}return{start(u){c||(c=!0,s=J.createServer((l,f)=>{f.writeHead(426,{"Content-Type":"text/plain"}),f.end("Upgrade Required")}),s.on("upgrade",(l,f,a)=>{o.handleUpgrade(l,f,a)}),s.listen(u,()=>{}),p(e))},stop(){c=!1;for(let u of n)try{u.close()}catch(l){}if(n.length=0,o.closeAll(),s){try{s.close()}catch(u){}s=null}},onFileChange(u){r.push(u)},notifyClient(u){o.broadcast(JSON.stringify(u))}}}function G(e){let o=new I;return e.on("upgrade",(r,n,s)=>{o.handleUpgrade(r,n,s)}),{broadcast(r){o.broadcast(r)},getClientCount(){return o.getClientCount()}}}function B(){return`(function() {
267
560
  'use strict';
268
561
 
269
562
  var ws = null;
@@ -361,9 +654,9 @@ Sec-WebSocket-Accept: ${a}\r
361
654
 
362
655
  // \u542F\u52A8\u8FDE\u63A5
363
656
  connect();
364
- })();`}var X;try{X=require("esbuild")}catch(e){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(` ${t("npm install esbuild --save-dev","brightGreen")}`),i.error(""),i.error(" \u5982\u679C\u60A8\u4F7F\u7528 pnpm:"),i.error(` ${t("pnpm add esbuild -D","brightGreen")}`),i.error(""),process.exit(1)}function Te(e,o){try{return X.transformSync(e,{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),e}}function De(e,o){var c;let n=((c=e.url)==null?void 0:c.split("?")[0])||"/";n==="/"&&(n="/index.html");let r=P.join(o,n);if(!r.startsWith(o))return{statusCode:403,headers:{"Content-Type":"text/plain; charset=utf-8"},body:"403 Forbidden"};if(!B.existsSync(r)||!B.statSync(r).isFile())return{statusCode:404,headers:{"Content-Type":"text/plain; charset=utf-8"},body:"404 Not Found"};let s=P.extname(r).toLowerCase(),p={".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",l=k(r);return(s===".ts"||s===".tsx")&&(l=Te(l,n)),s===".html"&&(l=l.replace("</head>",`<script>${I()}</script>
365
- </head>`)),{statusCode:200,headers:{"Content-Type":p},body:l}}function N(e={}){let o=e.port||3e3,n=P.resolve(e.root||process.cwd()),r=e.hmr!==!1,s=K.createServer((l,c)=>{let u=De(l,n);c.writeHead(u.statusCode,u.headers),c.end(u.body)}),a=r?G(s):null;s.listen(o,()=>{console.log(""),console.log(t(" \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(t(" \u2551","brightCyan")+t(" Lyt \u5F00\u53D1\u670D\u52A1\u5668\u5DF2\u542F\u52A8 ","brightWhite")+t("\u2551","brightCyan")),console.log(t(" \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(` ${t("\u279C","brightGreen")} \u672C\u5730\u8BBF\u95EE: ${t(`http://localhost:${o}`,"brightBlue")}`),console.log(` ${t("\u279C","brightGreen")} \u7F51\u7EDC\u8BBF\u95EE: ${t(`http://127.0.0.1:${o}`,"brightBlue")}`),console.log(` ${t("\u279C","brightGreen")} \u9879\u76EE\u76EE\u5F55: ${t(n,"brightBlue")}`),console.log(` ${t("\u279C","brightGreen")} \u70ED\u66F4\u65B0: ${t(r?"\u5DF2\u5F00\u542F":"\u5DF2\u5173\u95ED",r?"brightGreen":"brightRed")}`),console.log(""),console.log(` ${t("\u6309 Ctrl+C \u505C\u6B62\u670D\u52A1\u5668","dim")}`),console.log("")}),s.on("error",l=>{l.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: ${l.message}`),process.exit(1))});let p=()=>{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",p),process.on("SIGTERM",p)}var h=m(require("fs")),g=m(require("path"));var Q;try{Q=require("esbuild")}catch(e){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(` ${t("npm install esbuild --save-dev","brightGreen")}`),i.error(""),i.error(" \u5982\u679C\u60A8\u4F7F\u7528 pnpm:"),i.error(` ${t("pnpm add esbuild -D","brightGreen")}`),i.error(""),process.exit(1)}async function Z(e={}){let o=Date.now(),n=g.resolve(e.root||process.cwd()),r=g.resolve(n,e.outDir||"dist"),s=e.entry||"index.html",a=e.minify||!1;i.info("\u5F00\u59CB\u6784\u5EFA\u9879\u76EE..."),i.info(` \u6839\u76EE\u5F55: ${t(n,"brightCyan")}`),i.info(` \u8F93\u51FA\u76EE\u5F55: ${t(r,"brightCyan")}`),i.info(` \u538B\u7F29: ${t(a?"\u5F00\u542F":"\u5173\u95ED",a?"brightGreen":"brightYellow")}`);let p=g.join(n,s);h.existsSync(p)||(i.error(`\u5165\u53E3\u6587\u4EF6\u4E0D\u5B58\u5728: ${p}`),process.exit(1));let l=k(p),c=/<script\s+type="module"\s+src="([^"]+)"\s*><\/script>/g,u,d=[];for(;(u=c.exec(l))!==null;)d.push(u[1]);d.length===0&&i.warn("\u672A\u5728\u5165\u53E3 HTML \u4E2D\u627E\u5230\u6A21\u5757\u811A\u672C\u5F15\u7528");let f={inputFiles:0,outputFiles:0,totalSize:0,buildTime:0};$(r),$(g.join(r,"assets"));for(let x of d){let R=g.join(n,x);if(!h.existsSync(R)){i.warn(`\u811A\u672C\u6587\u4EF6\u4E0D\u5B58\u5728: ${x}`);continue}i.info(`\u6B63\u5728\u6253\u5305: ${t(x,"brightYellow")}`);let H=`${g.basename(x,g.extname(x))}.bundle.js`,C=g.join(r,"assets",H);try{await Q.build({entryPoints:[R],bundle:!0,minify:a,target:"es2018",format:"esm",outfile:C,sourcemap:!0,external:A=>A.startsWith("@lytjs/"),drop:a?["console"]:[],metafile:!0});let v=h.readFileSync(C,"utf-8");f.totalSize+=Buffer.byteLength(v,"utf-8"),f.outputFiles++;let w=C+".map";if(h.existsSync(w)){let A=h.readFileSync(w,"utf-8");f.totalSize+=Buffer.byteLength(A,"utf-8"),f.outputFiles++}l=l.replace(`<script type="module" src="${x}"></script>`,`<script src="/assets/${H}"></script>`),f.inputFiles++}catch(v){let w=v instanceof Error?v.message:String(v);i.error(`\u6253\u5305\u5931\u8D25 ${x}: ${w}`),process.exit(1)}}Le(n,r,f);let M=g.join(r,"index.html");S(M,l),f.outputFiles++,f.totalSize+=Buffer.byteLength(l,"utf-8"),f.buildTime=Date.now()-o,console.log(""),i.success("\u6784\u5EFA\u5B8C\u6210\uFF01"),console.log(""),console.log(` ${t("\u8F93\u5165\u6587\u4EF6:","brightWhite")} ${f.inputFiles} \u4E2A`),console.log(` ${t("\u8F93\u51FA\u6587\u4EF6:","brightWhite")} ${f.outputFiles} \u4E2A`),console.log(` ${t("\u603B\u5927\u5C0F:","brightWhite")} ${Oe(f.totalSize)}`),console.log(` ${t("\u6784\u5EFA\u8017\u65F6:","brightWhite")} ${f.buildTime}ms`),console.log(` ${t("\u8F93\u51FA\u76EE\u5F55:","brightWhite")} ${t(r,"brightCyan")}`),console.log("")}function Le(e,o,n){let r=g.join(e,"src");if(!h.existsSync(r))return;function s(a,p){let l=h.readdirSync(a,{withFileTypes:!0});for(let c of l){let u=g.join(a,c.name);if(c.isDirectory()){if(c.name==="node_modules")continue;s(u,p)}else if(c.isFile()){let d=g.extname(c.name);if([".ts",".tsx",".js",".jsx"].includes(d))continue;let f=g.relative(p,u),M=g.join(o,f);S(M,h.readFileSync(u).toString("utf-8")),n.outputFiles++,n.totalSize+=h.statSync(u).size}}}s(r,r)}function Oe(e){if(e===0)return"0 B";let o=["B","KB","MB","GB"],n=1024,r=Math.floor(Math.log(e)/Math.log(n));return`${(e/Math.pow(n,r)).toFixed(2)} ${o[r]}`}var Ge="0.2.0",ne="lytx",Ie="Lyt.js \u6846\u67B6\u547D\u4EE4\u884C\u5DE5\u5177\uFF08\u589E\u5F3A\u7248\uFF09",ee=`
366
- ${t(ne,"brightCyan")} - ${Ie}
657
+ })();`}var X;try{X=require("esbuild")}catch(e){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(` ${t("npm install esbuild --save-dev","brightGreen")}`),i.error(""),i.error(" \u5982\u679C\u60A8\u4F7F\u7528 pnpm:"),i.error(` ${t("pnpm add esbuild -D","brightGreen")}`),i.error(""),process.exit(1)}function De(e,o){try{return X.transformSync(e,{loader:"ts",target:"es2018",format:"esm",sourcemap:"inline"}).code}catch(r){let n=r instanceof Error?r.message:String(r);return console.error(`[Lyt CLI] \u7F16\u8BD1\u9519\u8BEF ${o||""}:`,n),e}}function Le(e,o){var u;let r=((u=e.url)==null?void 0:u.split("?")[0])||"/";if(r==="/"&&(r="/index.html"),r.startsWith("/node_modules/")||r.startsWith("/@")){let l;if(r.startsWith("/@")&&!r.startsWith("/node_modules/")?l=b.join(o,"node_modules",r.slice(1)):l=b.join(o,r.slice(1)),r.match(/^\/(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/)&&!r.includes(".")){let f=b.join(l,"package.json");if(P.existsSync(f))try{let a=JSON.parse(R(f)),g=a.module||a.main||"index.js";a.exports&&(typeof a.exports=="string"?g=a.exports:typeof a.exports=="object"&&a.exports["."]&&(typeof a.exports["."]=="string"?g=a.exports["."]:a.exports["."].import?g=a.exports["."].import:a.exports["."].default?g=a.exports["."].default:Object.values(a.exports["."])[0]&&(g=Object.values(a.exports["."])[0]))),g.startsWith("./")&&(g=g.slice(2)),l=b.join(l,g)}catch(a){}}if(P.existsSync(l)&&P.statSync(l).isFile()){let f=b.extname(l).toLowerCase(),g={".js":"application/javascript; charset=utf-8",".mjs":"application/javascript; charset=utf-8",".json":"application/json; charset=utf-8"}[f]||"application/octet-stream",x=R(l);return{statusCode:200,headers:{"Content-Type":g},body:x}}}let n=b.join(o,r);if(!n.startsWith(o))return{statusCode:403,headers:{"Content-Type":"text/plain; charset=utf-8"},body:"403 Forbidden"};if(!P.existsSync(n)||!P.statSync(n).isFile())return{statusCode:404,headers:{"Content-Type":"text/plain; charset=utf-8"},body:"404 Not Found"};let s=b.extname(n).toLowerCase(),d={".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(n);return(s===".ts"||s===".tsx")&&(p=De(p,r)),s===".html"&&(p=p.replace("</head>",`<script>${B()}</script>
658
+ </head>`)),{statusCode:200,headers:{"Content-Type":d},body:p}}function W(e={}){let o=e.port||3e3,r=b.resolve(e.root||process.cwd()),n=e.hmr!==!1,s=K.createServer((p,u)=>{let l=Le(p,r);u.writeHead(l.statusCode,l.headers),u.end(l.body)}),c=n?G(s):null;s.listen(o,()=>{console.log(""),console.log(t(" \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(t(" \u2551","brightCyan")+t(" Lyt \u5F00\u53D1\u670D\u52A1\u5668\u5DF2\u542F\u52A8 ","brightWhite")+t("\u2551","brightCyan")),console.log(t(" \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(` ${t("\u279C","brightGreen")} \u672C\u5730\u8BBF\u95EE: ${t(`http://localhost:${o}`,"brightBlue")}`),console.log(` ${t("\u279C","brightGreen")} \u7F51\u7EDC\u8BBF\u95EE: ${t(`http://127.0.0.1:${o}`,"brightBlue")}`),console.log(` ${t("\u279C","brightGreen")} \u9879\u76EE\u76EE\u5F55: ${t(r,"brightBlue")}`),console.log(` ${t("\u279C","brightGreen")} \u70ED\u66F4\u65B0: ${t(n?"\u5DF2\u5F00\u542F":"\u5DF2\u5173\u95ED",n?"brightGreen":"brightRed")}`),console.log(""),console.log(` ${t("\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 d=()=>{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",d),process.on("SIGTERM",d)}var y=h(require("fs")),m=h(require("path"));var Q;try{Q=require("esbuild")}catch(e){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(` ${t("npm install esbuild --save-dev","brightGreen")}`),i.error(""),i.error(" \u5982\u679C\u60A8\u4F7F\u7528 pnpm:"),i.error(` ${t("pnpm add esbuild -D","brightGreen")}`),i.error(""),process.exit(1)}async function Z(e={}){let o=Date.now(),r=m.resolve(e.root||process.cwd()),n=m.resolve(r,e.outDir||"dist"),s=e.entry||"index.html",c=e.minify||!1;i.info("\u5F00\u59CB\u6784\u5EFA\u9879\u76EE..."),i.info(` \u6839\u76EE\u5F55: ${t(r,"brightCyan")}`),i.info(` \u8F93\u51FA\u76EE\u5F55: ${t(n,"brightCyan")}`),i.info(` \u538B\u7F29: ${t(c?"\u5F00\u542F":"\u5173\u95ED",c?"brightGreen":"brightYellow")}`);let d=m.join(r,s);y.existsSync(d)||(i.error(`\u5165\u53E3\u6587\u4EF6\u4E0D\u5B58\u5728: ${d}`),process.exit(1));let p=R(d),u=/<script\s+type="module"\s+src="([^"]+)"\s*><\/script>/g,l,f=[];for(;(l=u.exec(p))!==null;)f.push(l[1]);f.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};j(n),j(m.join(n,"assets"));for(let x of f){let A=m.join(r,x);if(!y.existsSync(A)){i.warn(`\u811A\u672C\u6587\u4EF6\u4E0D\u5B58\u5728: ${x}`);continue}i.info(`\u6B63\u5728\u6253\u5305: ${t(x,"brightYellow")}`);let E=`${m.basename(x,m.extname(x))}.bundle.js`,M=m.join(n,"assets",E);try{await Q.build({entryPoints:[A],bundle:!0,minify:c,target:"es2018",format:"esm",outfile:M,sourcemap:!0,external:T=>T.startsWith("@lytjs/"),drop:c?["console"]:[],metafile:!0});let $=y.readFileSync(M,"utf-8");a.totalSize+=Buffer.byteLength($,"utf-8"),a.outputFiles++;let S=M+".map";if(y.existsSync(S)){let T=y.readFileSync(S,"utf-8");a.totalSize+=Buffer.byteLength(T,"utf-8"),a.outputFiles++}p=p.replace(`<script type="module" src="${x}"></script>`,`<script src="/assets/${E}"></script>`),a.inputFiles++}catch($){let S=$ instanceof Error?$.message:String($);i.error(`\u6253\u5305\u5931\u8D25 ${x}: ${S}`),process.exit(1)}}Oe(r,n,a);let g=m.join(n,"index.html");C(g,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(` ${t("\u8F93\u5165\u6587\u4EF6:","brightWhite")} ${a.inputFiles} \u4E2A`),console.log(` ${t("\u8F93\u51FA\u6587\u4EF6:","brightWhite")} ${a.outputFiles} \u4E2A`),console.log(` ${t("\u603B\u5927\u5C0F:","brightWhite")} ${Ie(a.totalSize)}`),console.log(` ${t("\u6784\u5EFA\u8017\u65F6:","brightWhite")} ${a.buildTime}ms`),console.log(` ${t("\u8F93\u51FA\u76EE\u5F55:","brightWhite")} ${t(n,"brightCyan")}`),console.log("")}function Oe(e,o,r){let n=m.join(e,"src");if(!y.existsSync(n))return;function s(c,d){let p=y.readdirSync(c,{withFileTypes:!0});for(let u of p){let l=m.join(c,u.name);if(u.isDirectory()){if(u.name==="node_modules")continue;s(l,d)}else if(u.isFile()){let f=m.extname(u.name);if([".ts",".tsx",".js",".jsx"].includes(f))continue;let a=m.relative(d,l),g=m.join(o,a);C(g,y.readFileSync(l).toString("utf-8")),r.outputFiles++,r.totalSize+=y.statSync(l).size}}}s(n,n)}function Ie(e){if(e===0)return"0 B";let o=["B","KB","MB","GB"],r=1024,n=Math.floor(Math.log(e)/Math.log(r));return`${(e/Math.pow(r,n)).toFixed(2)} ${o[n]}`}var Ge="0.2.0",re="lytx",Be="Lyt.js \u6846\u67B6\u547D\u4EE4\u884C\u5DE5\u5177\uFF08\u589E\u5F3A\u7248\uFF09",ee=`
659
+ ${t(re,"brightCyan")} - ${Be}
367
660
 
368
661
  ${t("\u7528\u6CD5:","brightGreen")}
369
662
  lytx <command> [options] [args]
@@ -387,7 +680,7 @@ ${t("\u793A\u4F8B:","brightGreen")}
387
680
  ${t("$","dim")} lytx build --mode ssr
388
681
  ${t("$","dim")} lytx preview --port 4173
389
682
 
390
- `,Be=`
683
+ `,Ue=`
391
684
  ${t("lytx create","brightCyan")} - \u521B\u5EFA\u65B0\u7684 Lyt \u9879\u76EE
392
685
 
393
686
  ${t("\u7528\u6CD5:","brightGreen")}
@@ -409,7 +702,7 @@ ${t("\u793A\u4F8B:","brightGreen")}
409
702
  ${t("$","dim")} lytx create my-app --template spa --ts --router --store
410
703
  ${t("$","dim")} lytx create my-app --template ssr --ts
411
704
 
412
- `,Ue=`
705
+ `,We=`
413
706
  ${t("lytx dev","brightCyan")} - \u542F\u52A8\u672C\u5730\u5F00\u53D1\u670D\u52A1\u5668
414
707
 
415
708
  ${t("\u7528\u6CD5:","brightGreen")}
@@ -431,7 +724,7 @@ ${t("\u793A\u4F8B:","brightGreen")}
431
724
  ${t("$","dim")} lytx dev --port 8080
432
725
  ${t("$","dim")} lytx dev --no-hmr
433
726
 
434
- `,Ne=`
727
+ `,ze=`
435
728
  ${t("lytx build","brightCyan")} - \u6784\u5EFA\u751F\u4EA7\u7248\u672C
436
729
 
437
730
  ${t("\u7528\u6CD5:","brightGreen")}
@@ -456,7 +749,7 @@ ${t("\u793A\u4F8B:","brightGreen")}
456
749
  ${t("$","dim")} lytx build --mode ssr
457
750
  ${t("$","dim")} lytx build --minify --outDir ./output
458
751
 
459
- `,We=`
752
+ `,Ne=`
460
753
  ${t("lytx preview","brightCyan")} - \u9884\u89C8\u6784\u5EFA\u7ED3\u679C
461
754
 
462
755
  ${t("\u7528\u6CD5:","brightGreen")}
@@ -469,4 +762,4 @@ ${t("\u793A\u4F8B:","brightGreen")}
469
762
  ${t("$","dim")} lytx preview
470
763
  ${t("$","dim")} lytx preview --port 5000
471
764
 
472
- `;function Ye(){console.log(""),console.log(` ${t(ne,"brightCyan")} v${t(Ge,"brightWhite")}`),console.log("")}function ze(e){i.error(`\u672A\u77E5\u547D\u4EE4: ${t(e,"brightRed")}`),console.log(""),console.log(` \u8FD0\u884C ${t("lytx --help","brightCyan")} \u67E5\u770B\u53EF\u7528\u547D\u4EE4`),console.log("")}function _e(e){return typeof e=="string"&&["spa","ssr","ssg"].includes(e)?e:"spa"}async function Je(e){if(e.options.help){console.log(Be);return}e.args.length===0&&(i.error("\u8BF7\u63D0\u4F9B\u9879\u76EE\u540D\u79F0"),console.log(""),console.log(` \u7528\u6CD5: ${t("lytx create <name>","brightCyan")}`),console.log(""),console.log(` \u8FD0\u884C ${t("lytx create --help","brightCyan")} \u67E5\u770B\u66F4\u591A\u9009\u9879`),console.log(""),process.exit(1));let o=e.args[0];if(e.options.ts===!0||e.options.router===!0||e.options.store===!0||e.options.eslint===!0||typeof e.options.template=="string"&&["ssr","ssg"].includes(e.options.template)){let r={name:o,template:_e(e.options.template),ts:e.options.ts===!0,router:e.options.router===!0,store:e.options.store===!0,eslint:e.options.eslint===!0};await L(r)}else{let r={template:typeof e.options.template=="string"?e.options.template:"spa"};await _(o,r)}}function qe(e){if(e.options.help){console.log(Ue);return}let o={port:typeof e.options.port=="string"?parseInt(e.options.port,10):typeof e.options.p=="string"?parseInt(e.options.p,10):3e3,hmr:e.options["no-hmr"]!==!0};(isNaN(o.port)||o.port<1||o.port>65535)&&(i.error(`\u65E0\u6548\u7684\u7AEF\u53E3\u53F7: ${e.options.port||e.options.p}`),process.exit(1)),N(o)}async function Ve(e){if(e.options.help){console.log(Ne);return}let o={minify:e.options.minify===!0,outDir:typeof e.options.outDir=="string"?e.options.outDir:typeof e.options.o=="string"?e.options.o:"dist",entry:typeof e.options.entry=="string"?e.options.entry:"index.html"};await Z(o)}function Ke(e){if(e.options.help){console.log(We);return}let o=typeof e.options.port=="string"?parseInt(e.options.port,10):typeof e.options.p=="string"?parseInt(e.options.p,10):4173;(isNaN(o)||o<1||o>65535)&&(i.error(`\u65E0\u6548\u7684\u7AEF\u53E3\u53F7: ${e.options.port||e.options.p}`),process.exit(1));let n=oe.resolve(process.cwd(),"dist");te.existsSync(n)||(i.error("\u672A\u627E\u5230\u6784\u5EFA\u8F93\u51FA\u76EE\u5F55 dist/\uFF0C\u8BF7\u5148\u8FD0\u884C lytx build"),process.exit(1)),N({port:o,root:n,hmr:!1})}async function Xe(){let e=z(process.argv);if(e.options.version){Ye();return}if(e.options.help&&!e.command){console.log(ee);return}e.command||(console.log(ee),process.exit(1));try{switch(e.command){case"create":await Je(e);break;case"dev":qe(e);break;case"build":await Ve(e);break;case"preview":Ke(e);break;default:ze(e.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(` ${t("\u63D0\u793A:","brightYellow")} \u8BF7\u68C0\u67E5\u8F93\u5165\u53C2\u6570\u6216\u8FD0\u884C ${t("lytx --help","brightCyan")} \u67E5\u770B\u5E2E\u52A9`),console.log(""),process.exit(1)}}Xe();0&&(module.exports={createHMREndpoint,createHMRServer,createProject,getHMRClientScript});
765
+ `;function Ye(){console.log(""),console.log(` ${t(re,"brightCyan")} v${t(Ge,"brightWhite")}`),console.log("")}function _e(e){i.error(`\u672A\u77E5\u547D\u4EE4: ${t(e,"brightRed")}`),console.log(""),console.log(` \u8FD0\u884C ${t("lytx --help","brightCyan")} \u67E5\u770B\u53EF\u7528\u547D\u4EE4`),console.log("")}function Je(e){return typeof e=="string"&&["spa","ssr","ssg"].includes(e)?e:"spa"}async function qe(e){if(e.options.help){console.log(Ue);return}e.args.length===0&&(i.error("\u8BF7\u63D0\u4F9B\u9879\u76EE\u540D\u79F0"),console.log(""),console.log(` \u7528\u6CD5: ${t("lytx create <name>","brightCyan")}`),console.log(""),console.log(` \u8FD0\u884C ${t("lytx create --help","brightCyan")} \u67E5\u770B\u66F4\u591A\u9009\u9879`),console.log(""),process.exit(1));let o=e.args[0];if(e.options.ts===!0||e.options.router===!0||e.options.store===!0||e.options.eslint===!0||typeof e.options.template=="string"&&["ssr","ssg"].includes(e.options.template)){let n={name:o,template:Je(e.options.template),ts:e.options.ts===!0,router:e.options.router===!0,store:e.options.store===!0,eslint:e.options.eslint===!0};await O(n)}else{let n={template:typeof e.options.template=="string"?e.options.template:"spa"};await _(o,n)}}function Ve(e){if(e.options.help){console.log(We);return}let o={port:typeof e.options.port=="string"?parseInt(e.options.port,10):typeof e.options.p=="string"?parseInt(e.options.p,10):3e3,hmr:e.options["no-hmr"]!==!0};(isNaN(o.port)||o.port<1||o.port>65535)&&(i.error(`\u65E0\u6548\u7684\u7AEF\u53E3\u53F7: ${e.options.port||e.options.p}`),process.exit(1)),W(o)}async function Ke(e){if(e.options.help){console.log(ze);return}let o={minify:e.options.minify===!0,outDir:typeof e.options.outDir=="string"?e.options.outDir:typeof e.options.o=="string"?e.options.o:"dist",entry:typeof e.options.entry=="string"?e.options.entry:"index.html"};await Z(o)}function Xe(e){if(e.options.help){console.log(Ne);return}let o=typeof e.options.port=="string"?parseInt(e.options.port,10):typeof e.options.p=="string"?parseInt(e.options.p,10):4173;(isNaN(o)||o<1||o>65535)&&(i.error(`\u65E0\u6548\u7684\u7AEF\u53E3\u53F7: ${e.options.port||e.options.p}`),process.exit(1));let r=oe.resolve(process.cwd(),"dist");te.existsSync(r)||(i.error("\u672A\u627E\u5230\u6784\u5EFA\u8F93\u51FA\u76EE\u5F55 dist/\uFF0C\u8BF7\u5148\u8FD0\u884C lytx build"),process.exit(1)),W({port:o,root:r,hmr:!1})}async function Qe(){let e=Y(process.argv);if(e.options.version){Ye();return}if(e.options.help&&!e.command){console.log(ee);return}e.command||(console.log(ee),process.exit(1));try{switch(e.command){case"create":await qe(e);break;case"dev":Ve(e);break;case"build":await Ke(e);break;case"preview":Xe(e);break;default:_e(e.command),process.exit(1)}}catch(o){let r=o instanceof Error?o.message:String(o);i.error(`\u6267\u884C\u5931\u8D25: ${r}`),console.log(""),console.log(` ${t("\u63D0\u793A:","brightYellow")} \u8BF7\u68C0\u67E5\u8F93\u5165\u53C2\u6570\u6216\u8FD0\u884C ${t("lytx --help","brightCyan")} \u67E5\u770B\u5E2E\u52A9`),console.log(""),process.exit(1)}}Qe();0&&(module.exports={createHMREndpoint,createHMRServer,createProject,getHMRClientScript});