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
@@ -1,101 +1,258 @@
1
- import { Ft as relative, Nt as join, it as glob } from "../_build/common.mjs";
2
- import { withBase, withLeadingSlash, withoutTrailingSlash } from "ufo";
1
+ import { n as __require, r as __toESM, t as __commonJSMin } from "./nitro.mjs";
2
+ import { l as relative, n as dirname, u as resolve } from "../_libs/pathe.mjs";
3
+ import { a as readGitConfig, c as resolvePackageJSON, i as parseGitConfig, n as findNearestFile, o as readPackageJSON, r as findWorkspaceDir, s as resolveGitConfig, t as findFile } from "../_libs/confbox+exsolve+pkg-types.mjs";
4
+ import { i as a } from "../_libs/std-env.mjs";
5
+ import { t as glob } from "../_libs/fdir+picomatch+tinyglobby.mjs";
6
+ import { t as runParallel } from "./nitro5.mjs";
7
+ import fs, { promises } from "node:fs";
8
+ import { promisify } from "node:util";
9
+ import { colors } from "consola/utils";
10
+ import zlib from "node:zlib";
11
+ import "node:stream";
3
12
 
4
- //#region src/scan.ts
5
- const GLOB_SCAN_PATTERN = "**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}";
6
- const suffixRegex = /(\.(?<method>connect|delete|get|head|options|patch|post|put|trace))?(\.(?<env>dev|prod|prerender))?$/;
7
- async function scanAndSyncOptions(nitro) {
8
- const scannedPlugins = await scanPlugins(nitro);
9
- for (const plugin of scannedPlugins) if (!nitro.options.plugins.includes(plugin)) nitro.options.plugins.push(plugin);
10
- if (nitro.options.experimental.tasks) {
11
- const scannedTasks = await scanTasks(nitro);
12
- for (const scannedTask of scannedTasks) if (scannedTask.name in nitro.options.tasks) {
13
- if (!nitro.options.tasks[scannedTask.name].handler) nitro.options.tasks[scannedTask.name].handler = scannedTask.handler;
14
- } else nitro.options.tasks[scannedTask.name] = {
15
- handler: scannedTask.handler,
16
- description: ""
17
- };
13
+ //#region node_modules/.pnpm/duplexer@0.1.2/node_modules/duplexer/index.js
14
+ var require_duplexer = /* @__PURE__ */ __commonJSMin(((exports, module) => {
15
+ var Stream = __require("stream");
16
+ var writeMethods = [
17
+ "write",
18
+ "end",
19
+ "destroy"
20
+ ];
21
+ var readMethods = ["resume", "pause"];
22
+ var readEvents = ["data", "close"];
23
+ var slice = Array.prototype.slice;
24
+ module.exports = duplex;
25
+ function forEach(arr, fn) {
26
+ if (arr.forEach) return arr.forEach(fn);
27
+ for (var i = 0; i < arr.length; i++) fn(arr[i], i);
18
28
  }
19
- const scannedModules = await scanModules(nitro);
20
- nitro.options.modules = nitro.options.modules || [];
21
- for (const modPath of scannedModules) if (!nitro.options.modules.includes(modPath)) nitro.options.modules.push(modPath);
22
- }
23
- async function scanHandlers(nitro) {
24
- const middleware = await scanMiddleware(nitro);
25
- const handlers = await Promise.all([scanServerRoutes(nitro, nitro.options.apiDir || "api", nitro.options.apiBaseURL || "/api"), scanServerRoutes(nitro, nitro.options.routesDir || "routes")]).then((r) => r.flat());
26
- nitro.scannedHandlers = [...middleware, ...handlers.filter((h, index, array) => {
27
- return array.findIndex((h2) => h.route === h2.route && h.method === h2.method && h.env === h2.env) === index;
28
- })];
29
- return handlers;
30
- }
31
- async function scanMiddleware(nitro) {
32
- return (await scanFiles(nitro, "middleware")).map((file) => {
33
- return {
34
- route: "/**",
35
- middleware: true,
36
- handler: file.fullPath
37
- };
38
- });
39
- }
40
- async function scanServerRoutes(nitro, dir, prefix = "/") {
41
- return (await scanFiles(nitro, dir)).map((file) => {
42
- let route = file.path.replace(/\.[A-Za-z]+$/, "").replace(/\(([^(/\\]+)\)[/\\]/g, "").replace(/\[\.{3}]/g, "**").replace(/\[\.{3}(\w+)]/g, "**:$1").replace(/\[([^/\]]+)]/g, ":$1");
43
- route = withLeadingSlash(withoutTrailingSlash(withBase(route, prefix)));
44
- const suffixMatch = route.match(suffixRegex);
45
- let method;
46
- let env;
47
- if (suffixMatch?.index && suffixMatch?.index >= 0) {
48
- route = route.slice(0, suffixMatch.index);
49
- method = suffixMatch.groups?.method;
50
- env = suffixMatch.groups?.env;
29
+ function duplex(writer, reader) {
30
+ var stream = new Stream();
31
+ var ended = false;
32
+ forEach(writeMethods, proxyWriter);
33
+ forEach(readMethods, proxyReader);
34
+ forEach(readEvents, proxyStream);
35
+ reader.on("end", handleEnd);
36
+ writer.on("drain", function() {
37
+ stream.emit("drain");
38
+ });
39
+ writer.on("error", reemit);
40
+ reader.on("error", reemit);
41
+ stream.writable = writer.writable;
42
+ stream.readable = reader.readable;
43
+ return stream;
44
+ function proxyWriter(methodName) {
45
+ stream[methodName] = method;
46
+ function method() {
47
+ return writer[methodName].apply(writer, arguments);
48
+ }
51
49
  }
52
- route = route.replace(/\/index$/, "") || "/";
53
- return {
54
- handler: file.fullPath,
55
- lazy: true,
56
- middleware: false,
57
- route,
58
- method,
59
- env
60
- };
61
- });
62
- }
63
- async function scanPlugins(nitro) {
64
- return (await scanFiles(nitro, "plugins")).map((f) => f.fullPath);
65
- }
66
- async function scanTasks(nitro) {
67
- return (await scanFiles(nitro, "tasks")).map((f) => {
68
- return {
69
- name: f.path.replace(/\/index$/, "").replace(/\.[A-Za-z]+$/, "").replace(/\//g, ":"),
70
- handler: f.fullPath
71
- };
72
- });
73
- }
74
- async function scanModules(nitro) {
75
- return (await scanFiles(nitro, "modules")).map((f) => f.fullPath);
50
+ function proxyReader(methodName) {
51
+ stream[methodName] = method;
52
+ function method() {
53
+ stream.emit(methodName);
54
+ var func = reader[methodName];
55
+ if (func) return func.apply(reader, arguments);
56
+ reader.emit(methodName);
57
+ }
58
+ }
59
+ function proxyStream(methodName) {
60
+ reader.on(methodName, reemit$1);
61
+ function reemit$1() {
62
+ var args = slice.call(arguments);
63
+ args.unshift(methodName);
64
+ stream.emit.apply(stream, args);
65
+ }
66
+ }
67
+ function handleEnd() {
68
+ if (ended) return;
69
+ ended = true;
70
+ var args = slice.call(arguments);
71
+ args.unshift("end");
72
+ stream.emit.apply(stream, args);
73
+ }
74
+ function reemit(err) {
75
+ stream.emit("error", err);
76
+ }
77
+ }
78
+ }));
79
+
80
+ //#endregion
81
+ //#region node_modules/.pnpm/gzip-size@7.0.0/node_modules/gzip-size/index.js
82
+ var import_duplexer = /* @__PURE__ */ __toESM(require_duplexer(), 1);
83
+ const getOptions = (options) => ({
84
+ level: 9,
85
+ ...options
86
+ });
87
+ const gzip = promisify(zlib.gzip);
88
+ async function gzipSize(input, options) {
89
+ if (!input) return 0;
90
+ return (await gzip(input, getOptions(options))).length;
76
91
  }
77
- async function scanFiles(nitro, name) {
78
- return await Promise.all(nitro.options.scanDirs.map((dir) => scanDir(nitro, dir, name))).then((r) => r.flat());
92
+
93
+ //#endregion
94
+ //#region node_modules/.pnpm/pretty-bytes@7.1.0/node_modules/pretty-bytes/index.js
95
+ const BYTE_UNITS = [
96
+ "B",
97
+ "kB",
98
+ "MB",
99
+ "GB",
100
+ "TB",
101
+ "PB",
102
+ "EB",
103
+ "ZB",
104
+ "YB"
105
+ ];
106
+ const BIBYTE_UNITS = [
107
+ "B",
108
+ "KiB",
109
+ "MiB",
110
+ "GiB",
111
+ "TiB",
112
+ "PiB",
113
+ "EiB",
114
+ "ZiB",
115
+ "YiB"
116
+ ];
117
+ const BIT_UNITS = [
118
+ "b",
119
+ "kbit",
120
+ "Mbit",
121
+ "Gbit",
122
+ "Tbit",
123
+ "Pbit",
124
+ "Ebit",
125
+ "Zbit",
126
+ "Ybit"
127
+ ];
128
+ const BIBIT_UNITS = [
129
+ "b",
130
+ "kibit",
131
+ "Mibit",
132
+ "Gibit",
133
+ "Tibit",
134
+ "Pibit",
135
+ "Eibit",
136
+ "Zibit",
137
+ "Yibit"
138
+ ];
139
+ const toLocaleString = (number, locale, options) => {
140
+ let result = number;
141
+ if (typeof locale === "string" || Array.isArray(locale)) result = number.toLocaleString(locale, options);
142
+ else if (locale === true || options !== void 0) result = number.toLocaleString(void 0, options);
143
+ return result;
144
+ };
145
+ const log10 = (numberOrBigInt) => {
146
+ if (typeof numberOrBigInt === "number") return Math.log10(numberOrBigInt);
147
+ const string = numberOrBigInt.toString(10);
148
+ return string.length + Math.log10(`0.${string.slice(0, 15)}`);
149
+ };
150
+ const log = (numberOrBigInt) => {
151
+ if (typeof numberOrBigInt === "number") return Math.log(numberOrBigInt);
152
+ return log10(numberOrBigInt) * Math.log(10);
153
+ };
154
+ const divide = (numberOrBigInt, divisor) => {
155
+ if (typeof numberOrBigInt === "number") return numberOrBigInt / divisor;
156
+ const integerPart = numberOrBigInt / BigInt(divisor);
157
+ const remainder = numberOrBigInt % BigInt(divisor);
158
+ return Number(integerPart) + Number(remainder) / divisor;
159
+ };
160
+ const applyFixedWidth = (result, fixedWidth) => {
161
+ if (fixedWidth === void 0) return result;
162
+ if (typeof fixedWidth !== "number" || !Number.isSafeInteger(fixedWidth) || fixedWidth < 0) throw new TypeError(`Expected fixedWidth to be a non-negative integer, got ${typeof fixedWidth}: ${fixedWidth}`);
163
+ if (fixedWidth === 0) return result;
164
+ return result.length < fixedWidth ? result.padStart(fixedWidth, " ") : result;
165
+ };
166
+ const buildLocaleOptions = (options) => {
167
+ const { minimumFractionDigits, maximumFractionDigits } = options;
168
+ if (minimumFractionDigits === void 0 && maximumFractionDigits === void 0) return;
169
+ return {
170
+ ...minimumFractionDigits !== void 0 && { minimumFractionDigits },
171
+ ...maximumFractionDigits !== void 0 && { maximumFractionDigits },
172
+ roundingMode: "trunc"
173
+ };
174
+ };
175
+ function prettyBytes(number, options) {
176
+ if (typeof number !== "bigint" && !Number.isFinite(number)) throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
177
+ options = {
178
+ bits: false,
179
+ binary: false,
180
+ space: true,
181
+ nonBreakingSpace: false,
182
+ ...options
183
+ };
184
+ const UNITS = options.bits ? options.binary ? BIBIT_UNITS : BIT_UNITS : options.binary ? BIBYTE_UNITS : BYTE_UNITS;
185
+ const separator = options.space ? options.nonBreakingSpace ? "\xA0" : " " : "";
186
+ const isZero = typeof number === "number" ? number === 0 : number === 0n;
187
+ if (options.signed && isZero) return applyFixedWidth(` 0${separator}${UNITS[0]}`, options.fixedWidth);
188
+ const isNegative = number < 0;
189
+ const prefix = isNegative ? "-" : options.signed ? "+" : "";
190
+ if (isNegative) number = -number;
191
+ const localeOptions = buildLocaleOptions(options);
192
+ let result;
193
+ if (number < 1) result = prefix + toLocaleString(number, options.locale, localeOptions) + separator + UNITS[0];
194
+ else {
195
+ const exponent = Math.min(Math.floor(options.binary ? log(number) / Math.log(1024) : log10(number) / 3), UNITS.length - 1);
196
+ number = divide(number, (options.binary ? 1024 : 1e3) ** exponent);
197
+ if (!localeOptions) {
198
+ const minPrecision = Math.max(3, Math.floor(number).toString().length);
199
+ number = number.toPrecision(minPrecision);
200
+ }
201
+ const numberString = toLocaleString(Number(number), options.locale, localeOptions);
202
+ const unit = UNITS[exponent];
203
+ result = prefix + numberString + separator + unit;
204
+ }
205
+ return applyFixedWidth(result, options.fixedWidth);
79
206
  }
80
- async function scanDir(nitro, dir, name) {
81
- return (await glob(join(name, GLOB_SCAN_PATTERN), {
207
+
208
+ //#endregion
209
+ //#region src/utils/fs-tree.ts
210
+ async function generateFSTree(dir, options = {}) {
211
+ if (a) return;
212
+ const files = await glob("**/*.*", {
82
213
  cwd: dir,
83
- dot: true,
84
- ignore: nitro.options.ignore,
85
- absolute: true
86
- }).catch((error) => {
87
- if (error?.code === "ENOTDIR") {
88
- nitro.logger.warn(`Ignoring \`${join(dir, name)}\`. It must be a directory.`);
89
- return [];
214
+ ignore: ["*.map"]
215
+ });
216
+ const items = [];
217
+ await runParallel(new Set(files), async (file) => {
218
+ const path = resolve(dir, file);
219
+ const src = await promises.readFile(path);
220
+ const size = src.byteLength;
221
+ const gzip$1 = options.compressedSizes ? await gzipSize(src) : 0;
222
+ items.push({
223
+ file,
224
+ path,
225
+ size,
226
+ gzip: gzip$1
227
+ });
228
+ }, { concurrency: 10 });
229
+ items.sort((a$1, b) => a$1.path.localeCompare(b.path));
230
+ let totalSize = 0;
231
+ let totalGzip = 0;
232
+ let totalNodeModulesSize = 0;
233
+ let totalNodeModulesGzip = 0;
234
+ let treeText = "";
235
+ for (const [index, item] of items.entries()) {
236
+ let dir$1 = dirname(item.file);
237
+ if (dir$1 === ".") dir$1 = "";
238
+ const rpath = relative(process.cwd(), item.path);
239
+ const treeChar = index === items.length - 1 ? "└─" : "├─";
240
+ if (item.file.includes("node_modules")) {
241
+ totalNodeModulesSize += item.size;
242
+ totalNodeModulesGzip += item.gzip;
243
+ continue;
90
244
  }
91
- throw error;
92
- })).map((fullPath) => {
93
- return {
94
- fullPath,
95
- path: relative(join(dir, name), fullPath)
96
- };
97
- }).sort((a, b) => a.path.localeCompare(b.path));
245
+ treeText += colors.gray(` ${treeChar} ${rpath} (${prettyBytes(item.size)})`);
246
+ if (options.compressedSizes) treeText += colors.gray(` (${prettyBytes(item.gzip)} gzip)`);
247
+ treeText += "\n";
248
+ totalSize += item.size;
249
+ totalGzip += item.gzip;
250
+ }
251
+ treeText += `${colors.cyan( Total size:")} ${prettyBytes(totalSize + totalNodeModulesSize)}`;
252
+ if (options.compressedSizes) treeText += ` (${prettyBytes(totalGzip + totalNodeModulesGzip)} gzip)`;
253
+ treeText += "\n";
254
+ return treeText;
98
255
  }
99
256
 
100
257
  //#endregion
101
- export { scanHandlers as n, scanAndSyncOptions as t };
258
+ export { readPackageJSON, generateFSTree as t };