nitro-nightly 3.0.1-20260119-145349-d0c4950f → 3.0.1-20260120-020848-6786d069

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.
Files changed (70) hide show
  1. package/dist/_build/rolldown.mjs +13 -8
  2. package/dist/_build/vite.build.mjs +1 -1
  3. package/dist/_chunks/dev.mjs +5 -3
  4. package/dist/_chunks/nitro.mjs +24 -1183
  5. package/dist/_chunks/nitro2.mjs +248 -91
  6. package/dist/_chunks/nitro3.mjs +2696 -0
  7. package/dist/_chunks/nitro4.mjs +176 -0
  8. package/dist/_chunks/nitro5.mjs +733 -0
  9. package/dist/_chunks/nitro6.mjs +1458 -0
  10. package/dist/_chunks/nitro7.mjs +7561 -0
  11. package/dist/_chunks/nitro8.mjs +3524 -0
  12. package/dist/_chunks/nitro9.mjs +1729 -0
  13. package/dist/_libs/_.mjs +3 -0
  14. package/dist/_libs/_2.mjs +3 -0
  15. package/dist/_libs/_3.mjs +4 -0
  16. package/dist/_libs/_4.mjs +6 -0
  17. package/dist/_libs/_5.mjs +3 -0
  18. package/dist/_libs/_6.mjs +3 -0
  19. package/dist/_libs/acorn+confbox+js-tokens+magic-string+mlly+pkg-types+sourcemap-codec+strip-literal+unimport.mjs +8900 -0
  20. package/dist/_libs/{c12.mjs → c12+dotenv+rc9.mjs} +12 -105
  21. package/dist/_libs/{chokidar.mjs → chokidar+readdirp.mjs} +2 -9
  22. package/dist/_libs/confbox+exsolve+pkg-types.mjs +1249 -0
  23. package/dist/_libs/confbox.mjs +70 -2488
  24. package/dist/_libs/confbox2.mjs +786 -0
  25. package/dist/_libs/confbox3.mjs +404 -0
  26. package/dist/_libs/confbox4.mjs +3 -0
  27. package/dist/_libs/estree-walker+unimport.mjs +378 -0
  28. package/dist/_libs/fdir+picomatch+tinyglobby.mjs +2471 -0
  29. package/dist/_libs/gen-mapping+remapping+resolve-uri+trace-mapping+unimport+unplugin+unplugin-utils+webpack-virtual-modules.mjs +2150 -0
  30. package/dist/_libs/giget+node-fetch-native.mjs +2692 -0
  31. package/dist/_libs/httpxy.mjs +1 -6
  32. package/dist/_libs/local-pkg+quansync+unimport.mjs +1526 -0
  33. package/dist/_libs/nypm+tinyexec.mjs +858 -0
  34. package/dist/_libs/pathe.mjs +164 -0
  35. package/dist/_libs/perfect-debounce.mjs +89 -0
  36. package/dist/_libs/{@rollup/plugin-inject.mjs → plugin-alias+plugin-inject.mjs} +65 -2
  37. package/dist/_libs/std-env.mjs +158 -0
  38. package/dist/_libs/unimport.mjs +5 -1781
  39. package/dist/_libs/vite-plugin-fullstack.mjs +26 -0
  40. package/dist/_presets.mjs +8 -3
  41. package/dist/builder.mjs +8 -6
  42. package/dist/cli/_chunks/build.mjs +1 -1
  43. package/dist/cli/_chunks/dev.mjs +3 -2
  44. package/dist/cli/_chunks/list.mjs +1 -1
  45. package/dist/cli/_chunks/prepare.mjs +1 -1
  46. package/dist/cli/_chunks/run.mjs +1 -1
  47. package/dist/cli/index.mjs +1 -1
  48. package/dist/types/index.d.mts +2410 -1174
  49. package/dist/vite.d.mts +13 -13
  50. package/dist/vite.mjs +640 -16
  51. package/package.json +9 -9
  52. package/dist/_build/common.mjs +0 -24931
  53. package/dist/_build/rollup.mjs +0 -201
  54. package/dist/_chunks/utils.mjs +0 -254
  55. package/dist/_common.mjs +0 -45
  56. package/dist/_libs/@hiogawa/vite-plugin-fullstack.mjs +0 -652
  57. package/dist/_libs/@jridgewell/gen-mapping.mjs +0 -448
  58. package/dist/_libs/@jridgewell/remapping.mjs +0 -117
  59. package/dist/_libs/@rollup/plugin-alias.mjs +0 -64
  60. package/dist/_libs/@rollup/plugin-commonjs.mjs +0 -1300
  61. package/dist/_libs/@rollup/plugin-json.mjs +0 -36
  62. package/dist/_libs/@rollup/plugin-node-resolve.mjs +0 -1972
  63. package/dist/_libs/escape-string-regexp.mjs +0 -8
  64. package/dist/_libs/estree-walker.mjs +0 -187
  65. package/dist/_libs/giget.mjs +0 -3550
  66. package/dist/_libs/klona.mjs +0 -38
  67. package/dist/_libs/rou3.mjs +0 -322
  68. package/dist/_libs/tsconfck.mjs +0 -832
  69. package/dist/_libs/ultrahtml.mjs +0 -138
  70. package/dist/cli/_chunks/task.mjs +0 -16
@@ -0,0 +1,858 @@
1
+ import { a as join$1, o as normalize$1, u as resolve$1 } from "./pathe.mjs";
2
+ import { o as readPackageJSON } from "./confbox+exsolve+pkg-types.mjs";
3
+ import { createRequire } from "node:module";
4
+ import { existsSync } from "node:fs";
5
+ import { readFile } from "node:fs/promises";
6
+ import { delimiter, dirname, normalize, resolve } from "node:path";
7
+ import { cwd } from "node:process";
8
+ import { createRequire as createRequire$1 } from "module";
9
+ import { PassThrough } from "node:stream";
10
+ import { spawn } from "node:child_process";
11
+ import c from "node:readline";
12
+
13
+ //#region node_modules/.pnpm/tinyexec@1.0.2/node_modules/tinyexec/dist/main.js
14
+ var l = Object.create;
15
+ var u = Object.defineProperty;
16
+ var d = Object.getOwnPropertyDescriptor;
17
+ var f = Object.getOwnPropertyNames;
18
+ var p = Object.getPrototypeOf;
19
+ var m = Object.prototype.hasOwnProperty;
20
+ var h = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports);
21
+ var g = (e, t, n, r) => {
22
+ if (t && typeof t === "object" || typeof t === "function") for (var i = f(t), a = 0, o = i.length, s; a < o; a++) {
23
+ s = i[a];
24
+ if (!m.call(e, s) && s !== n) u(e, s, {
25
+ get: ((e$1) => t[e$1]).bind(null, s),
26
+ enumerable: !(r = d(t, s)) || r.enumerable
27
+ });
28
+ }
29
+ return e;
30
+ };
31
+ var _ = (e, t, n) => (n = e != null ? l(p(e)) : {}, g(t || !e || !e.__esModule ? u(n, "default", {
32
+ value: e,
33
+ enumerable: true
34
+ }) : n, e));
35
+ var v = /* @__PURE__ */ createRequire$1(import.meta.url);
36
+ const y = /^path$/i;
37
+ const b = {
38
+ key: "PATH",
39
+ value: ""
40
+ };
41
+ function x(e) {
42
+ for (const t in e) {
43
+ if (!Object.prototype.hasOwnProperty.call(e, t) || !y.test(t)) continue;
44
+ const n = e[t];
45
+ if (!n) return b;
46
+ return {
47
+ key: t,
48
+ value: n
49
+ };
50
+ }
51
+ return b;
52
+ }
53
+ function S(e, t) {
54
+ const i = t.value.split(delimiter);
55
+ let o = e;
56
+ let s;
57
+ do {
58
+ i.push(resolve(o, "node_modules", ".bin"));
59
+ s = o;
60
+ o = dirname(o);
61
+ } while (o !== s);
62
+ return {
63
+ key: t.key,
64
+ value: i.join(delimiter)
65
+ };
66
+ }
67
+ function C(e, t) {
68
+ const n = {
69
+ ...process.env,
70
+ ...t
71
+ };
72
+ const r = S(e, x(n));
73
+ n[r.key] = r.value;
74
+ return n;
75
+ }
76
+ const w = (e) => {
77
+ let t = e.length;
78
+ const n = new PassThrough();
79
+ const r = () => {
80
+ if (--t === 0) n.emit("end");
81
+ };
82
+ for (const t$1 of e) {
83
+ t$1.pipe(n, { end: false });
84
+ t$1.on("end", r);
85
+ }
86
+ return n;
87
+ };
88
+ var T = h((exports, t) => {
89
+ t.exports = a;
90
+ a.sync = o;
91
+ var n = v("fs");
92
+ function r(e, t$1) {
93
+ var n$1 = t$1.pathExt !== void 0 ? t$1.pathExt : process.env.PATHEXT;
94
+ if (!n$1) return true;
95
+ n$1 = n$1.split(";");
96
+ if (n$1.indexOf("") !== -1) return true;
97
+ for (var r$1 = 0; r$1 < n$1.length; r$1++) {
98
+ var i$1 = n$1[r$1].toLowerCase();
99
+ if (i$1 && e.substr(-i$1.length).toLowerCase() === i$1) return true;
100
+ }
101
+ return false;
102
+ }
103
+ function i(e, t$1, n$1) {
104
+ if (!e.isSymbolicLink() && !e.isFile()) return false;
105
+ return r(t$1, n$1);
106
+ }
107
+ function a(e, t$1, r$1) {
108
+ n.stat(e, function(n$1, a$1) {
109
+ r$1(n$1, n$1 ? false : i(a$1, e, t$1));
110
+ });
111
+ }
112
+ function o(e, t$1) {
113
+ return i(n.statSync(e), e, t$1);
114
+ }
115
+ });
116
+ var E = h((exports, t) => {
117
+ t.exports = r;
118
+ r.sync = i;
119
+ var n = v("fs");
120
+ function r(e, t$1, r$1) {
121
+ n.stat(e, function(e$1, n$1) {
122
+ r$1(e$1, e$1 ? false : a(n$1, t$1));
123
+ });
124
+ }
125
+ function i(e, t$1) {
126
+ return a(n.statSync(e), t$1);
127
+ }
128
+ function a(e, t$1) {
129
+ return e.isFile() && o(e, t$1);
130
+ }
131
+ function o(e, t$1) {
132
+ var n$1 = e.mode;
133
+ var r$1 = e.uid;
134
+ var i$1 = e.gid;
135
+ var a$1 = t$1.uid !== void 0 ? t$1.uid : process.getuid && process.getuid();
136
+ var o$1 = t$1.gid !== void 0 ? t$1.gid : process.getgid && process.getgid();
137
+ var s = parseInt("100", 8);
138
+ var c$1 = parseInt("010", 8);
139
+ var l$1 = parseInt("001", 8);
140
+ var u$1 = s | c$1;
141
+ return n$1 & l$1 || n$1 & c$1 && i$1 === o$1 || n$1 & s && r$1 === a$1 || n$1 & u$1 && a$1 === 0;
142
+ }
143
+ });
144
+ var D = h((exports, t) => {
145
+ v("fs");
146
+ var r;
147
+ if (process.platform === "win32" || global.TESTING_WINDOWS) r = T();
148
+ else r = E();
149
+ t.exports = i;
150
+ i.sync = a;
151
+ function i(e, t$1, n) {
152
+ if (typeof t$1 === "function") {
153
+ n = t$1;
154
+ t$1 = {};
155
+ }
156
+ if (!n) {
157
+ if (typeof Promise !== "function") throw new TypeError("callback not provided");
158
+ return new Promise(function(n$1, r$1) {
159
+ i(e, t$1 || {}, function(e$1, t$2) {
160
+ if (e$1) r$1(e$1);
161
+ else n$1(t$2);
162
+ });
163
+ });
164
+ }
165
+ r(e, t$1 || {}, function(e$1, r$1) {
166
+ if (e$1) {
167
+ if (e$1.code === "EACCES" || t$1 && t$1.ignoreErrors) {
168
+ e$1 = null;
169
+ r$1 = false;
170
+ }
171
+ }
172
+ n(e$1, r$1);
173
+ });
174
+ }
175
+ function a(e, t$1) {
176
+ try {
177
+ return r.sync(e, t$1 || {});
178
+ } catch (e$1) {
179
+ if (t$1 && t$1.ignoreErrors || e$1.code === "EACCES") return false;
180
+ else throw e$1;
181
+ }
182
+ }
183
+ });
184
+ var O = h((exports, t) => {
185
+ const n = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
186
+ const r = v("path");
187
+ const i = n ? ";" : ":";
188
+ const a = D();
189
+ const o = (e) => Object.assign(/* @__PURE__ */ new Error(`not found: ${e}`), { code: "ENOENT" });
190
+ const s = (e, t$1) => {
191
+ const r$1 = t$1.colon || i;
192
+ const a$1 = e.match(/\//) || n && e.match(/\\/) ? [""] : [...n ? [process.cwd()] : [], ...(t$1.path || process.env.PATH || "").split(r$1)];
193
+ const o$1 = n ? t$1.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
194
+ const s$1 = n ? o$1.split(r$1) : [""];
195
+ if (n) {
196
+ if (e.indexOf(".") !== -1 && s$1[0] !== "") s$1.unshift("");
197
+ }
198
+ return {
199
+ pathEnv: a$1,
200
+ pathExt: s$1,
201
+ pathExtExe: o$1
202
+ };
203
+ };
204
+ const c$1 = (e, t$1, n$1) => {
205
+ if (typeof t$1 === "function") {
206
+ n$1 = t$1;
207
+ t$1 = {};
208
+ }
209
+ if (!t$1) t$1 = {};
210
+ const { pathEnv: i$1, pathExt: c$2, pathExtExe: l$2 } = s(e, t$1);
211
+ const u$1 = [];
212
+ const d$1 = (n$2) => new Promise((a$1, s$1) => {
213
+ if (n$2 === i$1.length) return t$1.all && u$1.length ? a$1(u$1) : s$1(o(e));
214
+ const c$3 = i$1[n$2];
215
+ const l$3 = /^".*"$/.test(c$3) ? c$3.slice(1, -1) : c$3;
216
+ const d$2 = r.join(l$3, e);
217
+ a$1(f$1(!l$3 && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d$2 : d$2, n$2, 0));
218
+ });
219
+ const f$1 = (e$1, n$2, r$1) => new Promise((i$2, o$1) => {
220
+ if (r$1 === c$2.length) return i$2(d$1(n$2 + 1));
221
+ const s$1 = c$2[r$1];
222
+ a(e$1 + s$1, { pathExt: l$2 }, (a$1, o$2) => {
223
+ if (!a$1 && o$2) if (t$1.all) u$1.push(e$1 + s$1);
224
+ else return i$2(e$1 + s$1);
225
+ return i$2(f$1(e$1, n$2, r$1 + 1));
226
+ });
227
+ });
228
+ return n$1 ? d$1(0).then((e$1) => n$1(null, e$1), n$1) : d$1(0);
229
+ };
230
+ const l$1 = (e, t$1) => {
231
+ t$1 = t$1 || {};
232
+ const { pathEnv: n$1, pathExt: i$1, pathExtExe: c$2 } = s(e, t$1);
233
+ const l$2 = [];
234
+ for (let o$1 = 0; o$1 < n$1.length; o$1++) {
235
+ const s$1 = n$1[o$1];
236
+ const u$1 = /^".*"$/.test(s$1) ? s$1.slice(1, -1) : s$1;
237
+ const d$1 = r.join(u$1, e);
238
+ const f$1 = !u$1 && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d$1 : d$1;
239
+ for (let e$1 = 0; e$1 < i$1.length; e$1++) {
240
+ const n$2 = f$1 + i$1[e$1];
241
+ try {
242
+ if (a.sync(n$2, { pathExt: c$2 })) if (t$1.all) l$2.push(n$2);
243
+ else return n$2;
244
+ } catch (e$2) {}
245
+ }
246
+ }
247
+ if (t$1.all && l$2.length) return l$2;
248
+ if (t$1.nothrow) return null;
249
+ throw o(e);
250
+ };
251
+ t.exports = c$1;
252
+ c$1.sync = l$1;
253
+ });
254
+ var k = h((exports, t) => {
255
+ const n = (e = {}) => {
256
+ const t$1 = e.env || process.env;
257
+ if ((e.platform || process.platform) !== "win32") return "PATH";
258
+ return Object.keys(t$1).reverse().find((e$1) => e$1.toUpperCase() === "PATH") || "Path";
259
+ };
260
+ t.exports = n;
261
+ t.exports.default = n;
262
+ });
263
+ var A = h((exports, t) => {
264
+ const n = v("path");
265
+ const r = O();
266
+ const i = k();
267
+ function a(e, t$1) {
268
+ const a$1 = e.options.env || process.env;
269
+ const o$1 = process.cwd();
270
+ const s = e.options.cwd != null;
271
+ const c$1 = s && process.chdir !== void 0 && !process.chdir.disabled;
272
+ if (c$1) try {
273
+ process.chdir(e.options.cwd);
274
+ } catch (e$1) {}
275
+ let l$1;
276
+ try {
277
+ l$1 = r.sync(e.command, {
278
+ path: a$1[i({ env: a$1 })],
279
+ pathExt: t$1 ? n.delimiter : void 0
280
+ });
281
+ } catch (e$1) {} finally {
282
+ if (c$1) process.chdir(o$1);
283
+ }
284
+ if (l$1) l$1 = n.resolve(s ? e.options.cwd : "", l$1);
285
+ return l$1;
286
+ }
287
+ function o(e) {
288
+ return a(e) || a(e, true);
289
+ }
290
+ t.exports = o;
291
+ });
292
+ var j = h((exports, t) => {
293
+ const n = /([()\][%!^"`<>&|;, *?])/g;
294
+ function r(e) {
295
+ e = e.replace(n, "^$1");
296
+ return e;
297
+ }
298
+ function i(e, t$1) {
299
+ e = `${e}`;
300
+ e = e.replace(/(\\*)"/g, "$1$1\\\"");
301
+ e = e.replace(/(\\*)$/, "$1$1");
302
+ e = `"${e}"`;
303
+ e = e.replace(n, "^$1");
304
+ if (t$1) e = e.replace(n, "^$1");
305
+ return e;
306
+ }
307
+ t.exports.command = r;
308
+ t.exports.argument = i;
309
+ });
310
+ var M = h((exports, t) => {
311
+ t.exports = /^#!(.*)/;
312
+ });
313
+ var N = h((exports, t) => {
314
+ const n = M();
315
+ t.exports = (e = "") => {
316
+ const t$1 = e.match(n);
317
+ if (!t$1) return null;
318
+ const [r, i] = t$1[0].replace(/#! ?/, "").split(" ");
319
+ const a = r.split("/").pop();
320
+ if (a === "env") return i;
321
+ return i ? `${a} ${i}` : a;
322
+ };
323
+ });
324
+ var P = h((exports, t) => {
325
+ const n = v("fs");
326
+ const r = N();
327
+ function i(e) {
328
+ const t$1 = 150;
329
+ const i$1 = Buffer.alloc(t$1);
330
+ let a;
331
+ try {
332
+ a = n.openSync(e, "r");
333
+ n.readSync(a, i$1, 0, t$1, 0);
334
+ n.closeSync(a);
335
+ } catch (e$1) {}
336
+ return r(i$1.toString());
337
+ }
338
+ t.exports = i;
339
+ });
340
+ var F = h((exports, t) => {
341
+ const n = v("path");
342
+ const r = A();
343
+ const i = j();
344
+ const a = P();
345
+ const o = process.platform === "win32";
346
+ const s = /\.(?:com|exe)$/i;
347
+ const c$1 = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
348
+ function l$1(e) {
349
+ e.file = r(e);
350
+ const t$1 = e.file && a(e.file);
351
+ if (t$1) {
352
+ e.args.unshift(e.file);
353
+ e.command = t$1;
354
+ return r(e);
355
+ }
356
+ return e.file;
357
+ }
358
+ function u$1(e) {
359
+ if (!o) return e;
360
+ const t$1 = l$1(e);
361
+ const r$1 = !s.test(t$1);
362
+ if (e.options.forceShell || r$1) {
363
+ const r$2 = c$1.test(t$1);
364
+ e.command = n.normalize(e.command);
365
+ e.command = i.command(e.command);
366
+ e.args = e.args.map((e$1) => i.argument(e$1, r$2));
367
+ e.args = [
368
+ "/d",
369
+ "/s",
370
+ "/c",
371
+ `"${[e.command].concat(e.args).join(" ")}"`
372
+ ];
373
+ e.command = process.env.comspec || "cmd.exe";
374
+ e.options.windowsVerbatimArguments = true;
375
+ }
376
+ return e;
377
+ }
378
+ function d$1(e, t$1, n$1) {
379
+ if (t$1 && !Array.isArray(t$1)) {
380
+ n$1 = t$1;
381
+ t$1 = null;
382
+ }
383
+ t$1 = t$1 ? t$1.slice(0) : [];
384
+ n$1 = Object.assign({}, n$1);
385
+ const r$1 = {
386
+ command: e,
387
+ args: t$1,
388
+ options: n$1,
389
+ file: void 0,
390
+ original: {
391
+ command: e,
392
+ args: t$1
393
+ }
394
+ };
395
+ return n$1.shell ? r$1 : u$1(r$1);
396
+ }
397
+ t.exports = d$1;
398
+ });
399
+ var I = h((exports, t) => {
400
+ const n = process.platform === "win32";
401
+ function r(e, t$1) {
402
+ return Object.assign(/* @__PURE__ */ new Error(`${t$1} ${e.command} ENOENT`), {
403
+ code: "ENOENT",
404
+ errno: "ENOENT",
405
+ syscall: `${t$1} ${e.command}`,
406
+ path: e.command,
407
+ spawnargs: e.args
408
+ });
409
+ }
410
+ function i(e, t$1) {
411
+ if (!n) return;
412
+ const r$1 = e.emit;
413
+ e.emit = function(n$1, i$1) {
414
+ if (n$1 === "exit") {
415
+ const n$2 = a(i$1, t$1, "spawn");
416
+ if (n$2) return r$1.call(e, "error", n$2);
417
+ }
418
+ return r$1.apply(e, arguments);
419
+ };
420
+ }
421
+ function a(e, t$1) {
422
+ if (n && e === 1 && !t$1.file) return r(t$1.original, "spawn");
423
+ return null;
424
+ }
425
+ function o(e, t$1) {
426
+ if (n && e === 1 && !t$1.file) return r(t$1.original, "spawnSync");
427
+ return null;
428
+ }
429
+ t.exports = {
430
+ hookChildProcess: i,
431
+ verifyENOENT: a,
432
+ verifyENOENTSync: o,
433
+ notFoundError: r
434
+ };
435
+ });
436
+ var R = _(h((exports, t) => {
437
+ const n = v("child_process");
438
+ const r = F();
439
+ const i = I();
440
+ function a(e, t$1, a$1) {
441
+ const o$1 = r(e, t$1, a$1);
442
+ const s = n.spawn(o$1.command, o$1.args, o$1.options);
443
+ i.hookChildProcess(s, o$1);
444
+ return s;
445
+ }
446
+ function o(e, t$1, a$1) {
447
+ const o$1 = r(e, t$1, a$1);
448
+ const s = n.spawnSync(o$1.command, o$1.args, o$1.options);
449
+ s.error = s.error || i.verifyENOENTSync(s.status, o$1);
450
+ return s;
451
+ }
452
+ t.exports = a;
453
+ t.exports.spawn = a;
454
+ t.exports.sync = o;
455
+ t.exports._parse = r;
456
+ t.exports._enoent = i;
457
+ })(), 1);
458
+ var z = class extends Error {
459
+ result;
460
+ output;
461
+ get exitCode() {
462
+ if (this.result.exitCode !== null) return this.result.exitCode;
463
+ }
464
+ constructor(e, t) {
465
+ super(`Process exited with non-zero status (${e.exitCode})`);
466
+ this.result = e;
467
+ this.output = t;
468
+ }
469
+ };
470
+ const B = {
471
+ timeout: void 0,
472
+ persist: false
473
+ };
474
+ const V = { windowsHide: true };
475
+ function H(e, t) {
476
+ return {
477
+ command: normalize(e),
478
+ args: t ?? []
479
+ };
480
+ }
481
+ function U(e) {
482
+ const t = new AbortController();
483
+ for (const n of e) {
484
+ if (n.aborted) {
485
+ t.abort();
486
+ return n;
487
+ }
488
+ const e$1 = () => {
489
+ t.abort(n.reason);
490
+ };
491
+ n.addEventListener("abort", e$1, { signal: t.signal });
492
+ }
493
+ return t.signal;
494
+ }
495
+ async function W(e) {
496
+ let t = "";
497
+ for await (const n of e) t += n.toString();
498
+ return t;
499
+ }
500
+ var G = class {
501
+ _process;
502
+ _aborted = false;
503
+ _options;
504
+ _command;
505
+ _args;
506
+ _resolveClose;
507
+ _processClosed;
508
+ _thrownError;
509
+ get process() {
510
+ return this._process;
511
+ }
512
+ get pid() {
513
+ return this._process?.pid;
514
+ }
515
+ get exitCode() {
516
+ if (this._process && this._process.exitCode !== null) return this._process.exitCode;
517
+ }
518
+ constructor(e, t, n) {
519
+ this._options = {
520
+ ...B,
521
+ ...n
522
+ };
523
+ this._command = e;
524
+ this._args = t ?? [];
525
+ this._processClosed = new Promise((e$1) => {
526
+ this._resolveClose = e$1;
527
+ });
528
+ }
529
+ kill(e) {
530
+ return this._process?.kill(e) === true;
531
+ }
532
+ get aborted() {
533
+ return this._aborted;
534
+ }
535
+ get killed() {
536
+ return this._process?.killed === true;
537
+ }
538
+ pipe(e, t, n) {
539
+ return q(e, t, {
540
+ ...n,
541
+ stdin: this
542
+ });
543
+ }
544
+ async *[Symbol.asyncIterator]() {
545
+ const e = this._process;
546
+ if (!e) return;
547
+ const t = [];
548
+ if (this._streamErr) t.push(this._streamErr);
549
+ if (this._streamOut) t.push(this._streamOut);
550
+ const n = w(t);
551
+ const r = c.createInterface({ input: n });
552
+ for await (const e$1 of r) yield e$1.toString();
553
+ await this._processClosed;
554
+ e.removeAllListeners();
555
+ if (this._thrownError) throw this._thrownError;
556
+ if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new z(this);
557
+ }
558
+ async _waitForOutput() {
559
+ const e = this._process;
560
+ if (!e) throw new Error("No process was started");
561
+ const [t, n] = await Promise.all([this._streamOut ? W(this._streamOut) : "", this._streamErr ? W(this._streamErr) : ""]);
562
+ await this._processClosed;
563
+ if (this._options?.stdin) await this._options.stdin;
564
+ e.removeAllListeners();
565
+ if (this._thrownError) throw this._thrownError;
566
+ const r = {
567
+ stderr: n,
568
+ stdout: t,
569
+ exitCode: this.exitCode
570
+ };
571
+ if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new z(this, r);
572
+ return r;
573
+ }
574
+ then(e, t) {
575
+ return this._waitForOutput().then(e, t);
576
+ }
577
+ _streamOut;
578
+ _streamErr;
579
+ spawn() {
580
+ const e = cwd();
581
+ const n = this._options;
582
+ const r = {
583
+ ...V,
584
+ ...n.nodeOptions
585
+ };
586
+ const i = [];
587
+ this._resetState();
588
+ if (n.timeout !== void 0) i.push(AbortSignal.timeout(n.timeout));
589
+ if (n.signal !== void 0) i.push(n.signal);
590
+ if (n.persist === true) r.detached = true;
591
+ if (i.length > 0) r.signal = U(i);
592
+ r.env = C(e, r.env);
593
+ const { command: a, args: s } = H(this._command, this._args);
594
+ const c$1 = (0, R._parse)(a, s, r);
595
+ const l$1 = spawn(c$1.command, c$1.args, c$1.options);
596
+ if (l$1.stderr) this._streamErr = l$1.stderr;
597
+ if (l$1.stdout) this._streamOut = l$1.stdout;
598
+ this._process = l$1;
599
+ l$1.once("error", this._onError);
600
+ l$1.once("close", this._onClose);
601
+ if (n.stdin !== void 0 && l$1.stdin && n.stdin.process) {
602
+ const { stdout: e$1 } = n.stdin.process;
603
+ if (e$1) e$1.pipe(l$1.stdin);
604
+ }
605
+ }
606
+ _resetState() {
607
+ this._aborted = false;
608
+ this._processClosed = new Promise((e) => {
609
+ this._resolveClose = e;
610
+ });
611
+ this._thrownError = void 0;
612
+ }
613
+ _onError = (e) => {
614
+ if (e.name === "AbortError" && (!(e.cause instanceof Error) || e.cause.name !== "TimeoutError")) {
615
+ this._aborted = true;
616
+ return;
617
+ }
618
+ this._thrownError = e;
619
+ };
620
+ _onClose = () => {
621
+ if (this._resolveClose) this._resolveClose();
622
+ };
623
+ };
624
+ const K = (e, t, n) => {
625
+ const r = new G(e, t, n);
626
+ r.spawn();
627
+ return r;
628
+ };
629
+ const q = K;
630
+
631
+ //#endregion
632
+ //#region node_modules/.pnpm/nypm@0.6.2/node_modules/nypm/dist/shared/nypm.CLjaS_sz.mjs
633
+ async function findup(cwd$1, match, options = {}) {
634
+ const segments = normalize$1(cwd$1).split("/");
635
+ while (segments.length > 0) {
636
+ const result = await match(segments.join("/") || "/");
637
+ if (result || !options.includeParentDirs) return result;
638
+ segments.pop();
639
+ }
640
+ }
641
+ function cached(fn) {
642
+ let v$1;
643
+ return () => {
644
+ if (v$1 === void 0) v$1 = fn().then((r) => {
645
+ v$1 = r;
646
+ return v$1;
647
+ });
648
+ return v$1;
649
+ };
650
+ }
651
+ const hasCorepack = cached(async () => {
652
+ if (globalThis.process?.versions?.webcontainer) return false;
653
+ try {
654
+ const { exitCode } = await K("corepack", ["--version"]);
655
+ return exitCode === 0;
656
+ } catch {
657
+ return false;
658
+ }
659
+ });
660
+ async function executeCommand(command, args, options = {}) {
661
+ const xArgs = command === "npm" || command === "bun" || command === "deno" || !await hasCorepack() ? [command, args] : ["corepack", [command, ...args]];
662
+ const { exitCode, stdout, stderr } = await K(xArgs[0], xArgs[1], { nodeOptions: {
663
+ cwd: resolve$1(options.cwd || process.cwd()),
664
+ env: options.env,
665
+ stdio: options.silent ? "pipe" : "inherit"
666
+ } });
667
+ if (exitCode !== 0) throw new Error(`\`${xArgs.flat().join(" ")}\` failed.${options.silent ? [
668
+ "",
669
+ stdout,
670
+ stderr
671
+ ].join("\n") : ""}`);
672
+ }
673
+ const NO_PACKAGE_MANAGER_DETECTED_ERROR_MSG = "No package manager auto-detected.";
674
+ async function resolveOperationOptions(options = {}) {
675
+ const cwd$1 = options.cwd || process.cwd();
676
+ const env = {
677
+ ...process.env,
678
+ ...options.env
679
+ };
680
+ const packageManager = (typeof options.packageManager === "string" ? packageManagers.find((pm) => pm.name === options.packageManager) : options.packageManager) || await detectPackageManager(options.cwd || process.cwd());
681
+ if (!packageManager) throw new Error(NO_PACKAGE_MANAGER_DETECTED_ERROR_MSG);
682
+ return {
683
+ cwd: cwd$1,
684
+ env,
685
+ silent: options.silent ?? false,
686
+ packageManager,
687
+ dev: options.dev ?? false,
688
+ workspace: options.workspace,
689
+ global: options.global ?? false,
690
+ dry: options.dry ?? false
691
+ };
692
+ }
693
+ function getWorkspaceArgs(options) {
694
+ if (!options.workspace) return [];
695
+ const workspacePkg = typeof options.workspace === "string" && options.workspace !== "" ? options.workspace : void 0;
696
+ if (options.packageManager.name === "pnpm") return workspacePkg ? ["--filter", workspacePkg] : ["--workspace-root"];
697
+ if (options.packageManager.name === "npm") return workspacePkg ? ["-w", workspacePkg] : ["--workspaces"];
698
+ if (options.packageManager.name === "yarn") if (!options.packageManager.majorVersion || options.packageManager.majorVersion === "1") return workspacePkg ? ["--cwd", workspacePkg] : ["-W"];
699
+ else return workspacePkg ? ["workspace", workspacePkg] : [];
700
+ return [];
701
+ }
702
+ function parsePackageManagerField(packageManager) {
703
+ const [name, _version] = (packageManager || "").split("@");
704
+ const [version, buildMeta] = _version?.split("+") || [];
705
+ if (name && name !== "-" && /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(name)) return {
706
+ name,
707
+ version,
708
+ buildMeta
709
+ };
710
+ const sanitized = name.replace(/\W+/g, "");
711
+ return {
712
+ name: sanitized,
713
+ version,
714
+ buildMeta,
715
+ warnings: [`Abnormal characters found in \`packageManager\` field, sanitizing from \`${name}\` to \`${sanitized}\``]
716
+ };
717
+ }
718
+ const packageManagers = [
719
+ {
720
+ name: "npm",
721
+ command: "npm",
722
+ lockFile: "package-lock.json"
723
+ },
724
+ {
725
+ name: "pnpm",
726
+ command: "pnpm",
727
+ lockFile: "pnpm-lock.yaml",
728
+ files: ["pnpm-workspace.yaml"]
729
+ },
730
+ {
731
+ name: "bun",
732
+ command: "bun",
733
+ lockFile: ["bun.lockb", "bun.lock"]
734
+ },
735
+ {
736
+ name: "yarn",
737
+ command: "yarn",
738
+ lockFile: "yarn.lock",
739
+ files: [".yarnrc.yml"]
740
+ },
741
+ {
742
+ name: "deno",
743
+ command: "deno",
744
+ lockFile: "deno.lock",
745
+ files: ["deno.json"]
746
+ }
747
+ ];
748
+ async function detectPackageManager(cwd$1, options = {}) {
749
+ const detected = await findup(resolve$1(cwd$1 || "."), async (path$1) => {
750
+ if (!options.ignorePackageJSON) {
751
+ const packageJSONPath = join$1(path$1, "package.json");
752
+ if (existsSync(packageJSONPath)) {
753
+ const packageJSON = JSON.parse(await readFile(packageJSONPath, "utf8"));
754
+ if (packageJSON?.packageManager) {
755
+ const { name, version = "0.0.0", buildMeta, warnings } = parsePackageManagerField(packageJSON.packageManager);
756
+ if (name) {
757
+ const majorVersion = version.split(".")[0];
758
+ const packageManager = packageManagers.find((pm) => pm.name === name && pm.majorVersion === majorVersion) || packageManagers.find((pm) => pm.name === name);
759
+ return {
760
+ name,
761
+ command: name,
762
+ version,
763
+ majorVersion,
764
+ buildMeta,
765
+ warnings,
766
+ files: packageManager?.files,
767
+ lockFile: packageManager?.lockFile
768
+ };
769
+ }
770
+ }
771
+ }
772
+ if (existsSync(join$1(path$1, "deno.json"))) return packageManagers.find((pm) => pm.name === "deno");
773
+ }
774
+ if (!options.ignoreLockFile) {
775
+ for (const packageManager of packageManagers) if ([packageManager.lockFile, packageManager.files].flat().filter(Boolean).some((file) => existsSync(resolve$1(path$1, file)))) return { ...packageManager };
776
+ }
777
+ }, { includeParentDirs: options.includeParentDirs ?? true });
778
+ if (!detected && !options.ignoreArgv) {
779
+ const scriptArg = process.argv[1];
780
+ if (scriptArg) {
781
+ for (const packageManager of packageManagers) if ((/* @__PURE__ */ new RegExp(`[/\\\\]\\.?${packageManager.command}`)).test(scriptArg)) return packageManager;
782
+ }
783
+ }
784
+ return detected;
785
+ }
786
+ async function installDependencies(options = {}) {
787
+ const resolvedOptions = await resolveOperationOptions(options);
788
+ const commandArgs = options.frozenLockFile ? {
789
+ npm: ["ci"],
790
+ yarn: ["install", "--immutable"],
791
+ bun: ["install", "--frozen-lockfile"],
792
+ pnpm: ["install", "--frozen-lockfile"],
793
+ deno: ["install", "--frozen"]
794
+ }[resolvedOptions.packageManager.name] : ["install"];
795
+ if (!resolvedOptions.dry) await executeCommand(resolvedOptions.packageManager.command, commandArgs, {
796
+ cwd: resolvedOptions.cwd,
797
+ silent: resolvedOptions.silent
798
+ });
799
+ return { exec: {
800
+ command: resolvedOptions.packageManager.command,
801
+ args: commandArgs
802
+ } };
803
+ }
804
+ async function addDependency(name, options = {}) {
805
+ const resolvedOptions = await resolveOperationOptions(options);
806
+ const names = Array.isArray(name) ? name : [name];
807
+ if (resolvedOptions.packageManager.name === "deno") {
808
+ for (let i = 0; i < names.length; i++) if (!/^(npm|jsr|file):.+$/.test(names[i])) names[i] = `npm:${names[i]}`;
809
+ }
810
+ if (names.length === 0) return {};
811
+ const args = (resolvedOptions.packageManager.name === "yarn" ? [
812
+ ...getWorkspaceArgs(resolvedOptions),
813
+ resolvedOptions.global && resolvedOptions.packageManager.majorVersion === "1" ? "global" : "",
814
+ "add",
815
+ resolvedOptions.dev ? "-D" : "",
816
+ ...names
817
+ ] : [
818
+ resolvedOptions.packageManager.name === "npm" ? "install" : "add",
819
+ ...getWorkspaceArgs(resolvedOptions),
820
+ resolvedOptions.dev ? "-D" : "",
821
+ resolvedOptions.global ? "-g" : "",
822
+ ...names
823
+ ]).filter(Boolean);
824
+ if (!resolvedOptions.dry) await executeCommand(resolvedOptions.packageManager.command, args, {
825
+ cwd: resolvedOptions.cwd,
826
+ silent: resolvedOptions.silent
827
+ });
828
+ if (!resolvedOptions.dry && options.installPeerDependencies) {
829
+ const existingPkg = await readPackageJSON(resolvedOptions.cwd);
830
+ const peerDeps = [];
831
+ const peerDevDeps = [];
832
+ for (const _name of names) {
833
+ const pkgName = _name.match(/^(.[^@]+)/)?.[0];
834
+ const pkg = await readPackageJSON(pkgName, { url: resolvedOptions.cwd }).catch(() => ({}));
835
+ if (!pkg.peerDependencies || pkg.name !== pkgName) continue;
836
+ for (const [peerDependency, version] of Object.entries(pkg.peerDependencies)) {
837
+ if (pkg.peerDependenciesMeta?.[peerDependency]?.optional) continue;
838
+ if (existingPkg.dependencies?.[peerDependency] || existingPkg.devDependencies?.[peerDependency]) continue;
839
+ (pkg.peerDependenciesMeta?.[peerDependency]?.dev ? peerDevDeps : peerDeps).push(`${peerDependency}@${version}`);
840
+ }
841
+ }
842
+ if (peerDeps.length > 0) await addDependency(peerDeps, { ...resolvedOptions });
843
+ if (peerDevDeps.length > 0) await addDevDependency(peerDevDeps, { ...resolvedOptions });
844
+ }
845
+ return { exec: {
846
+ command: resolvedOptions.packageManager.command,
847
+ args
848
+ } };
849
+ }
850
+ async function addDevDependency(name, options = {}) {
851
+ return await addDependency(name, {
852
+ ...options,
853
+ dev: true
854
+ });
855
+ }
856
+
857
+ //#endregion
858
+ export { addDevDependency, installDependencies as t };