nitro-nightly 3.0.1-20260120-020848-6786d069 → 3.0.1-20260120-133205-cbfce96c
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/_build/common.mjs +24931 -0
- package/dist/_build/rolldown.mjs +6 -11
- package/dist/_build/rollup.mjs +201 -0
- package/dist/_build/vite.build.mjs +1 -1
- package/dist/_chunks/dev.mjs +4 -6
- package/dist/_chunks/nitro.mjs +1183 -24
- package/dist/_chunks/nitro2.mjs +91 -248
- package/dist/_chunks/utils.mjs +254 -0
- package/dist/_common.mjs +45 -0
- package/dist/_libs/@hiogawa/vite-plugin-fullstack.mjs +652 -0
- package/dist/_libs/@jridgewell/gen-mapping.mjs +448 -0
- package/dist/_libs/@jridgewell/remapping.mjs +117 -0
- package/dist/_libs/@rollup/plugin-alias.mjs +64 -0
- package/dist/_libs/@rollup/plugin-commonjs.d.mts +241 -0
- package/dist/_libs/@rollup/plugin-commonjs.mjs +1300 -0
- package/dist/_libs/{plugin-alias+plugin-inject.mjs → @rollup/plugin-inject.mjs} +2 -65
- package/dist/_libs/@rollup/plugin-json.mjs +36 -0
- package/dist/_libs/@rollup/plugin-node-resolve.mjs +1972 -0
- package/dist/_libs/c12.d.mts +214 -0
- package/dist/_libs/{c12+dotenv+rc9.mjs → c12.mjs} +105 -12
- package/dist/_libs/{chokidar+readdirp.mjs → chokidar.mjs} +8 -1
- package/dist/_libs/compatx.d.mts +47 -0
- package/dist/_libs/confbox.mjs +2488 -70
- package/dist/_libs/esbuild.d.mts +20 -0
- package/dist/_libs/escape-string-regexp.mjs +8 -0
- package/dist/_libs/estree-walker.mjs +187 -0
- package/dist/_libs/giget.mjs +3550 -0
- package/dist/_libs/httpxy.d.mts +79 -0
- package/dist/_libs/httpxy.mjs +6 -1
- package/dist/_libs/klona.mjs +38 -0
- package/dist/_libs/magic-string.d.mts +220 -0
- package/dist/_libs/mlly.d.mts +57 -0
- package/dist/_libs/pkg-types.d.mts +23 -0
- package/dist/_libs/rou3.d.mts +43 -0
- package/dist/_libs/rou3.mjs +322 -0
- package/dist/_libs/std-env.d.mts +4 -0
- package/dist/_libs/tsconfck.mjs +832 -0
- package/dist/_libs/ultrahtml.mjs +138 -0
- package/dist/_libs/unimport.d.mts +426 -0
- package/dist/_libs/unimport.mjs +1781 -5
- package/dist/_libs/unwasm.d.mts +29 -0
- package/dist/_presets.mjs +3 -8
- package/dist/builder.mjs +6 -8
- package/dist/cli/_chunks/build.mjs +1 -1
- package/dist/cli/_chunks/dev.mjs +2 -3
- package/dist/cli/_chunks/list.mjs +1 -1
- package/dist/cli/_chunks/prepare.mjs +1 -1
- package/dist/cli/_chunks/run.mjs +1 -1
- package/dist/cli/_chunks/task.mjs +16 -0
- package/dist/cli/index.mjs +1 -1
- package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -5
- package/dist/presets/netlify/runtime/netlify-edge.d.mts +0 -1
- package/dist/presets/winterjs/runtime/winterjs.d.mts +0 -1
- package/dist/runtime/internal/error/dev.d.mts +0 -1
- package/dist/runtime/internal/route-rules.d.mts +0 -4
- package/dist/runtime/internal/routes/openapi.d.mts +0 -1
- package/dist/runtime/internal/routes/scalar.d.mts +0 -1
- package/dist/runtime/internal/routes/swagger.d.mts +0 -1
- package/dist/runtime/internal/runtime-config.d.mts +0 -1
- package/dist/runtime/nitro.d.mts +0 -3
- package/dist/runtime/virtual/renderer-template.d.mts +0 -1
- package/dist/types/index.d.mts +36 -1405
- package/dist/vite.mjs +18 -641
- package/package.json +2 -2
- package/dist/_chunks/nitro3.mjs +0 -2696
- package/dist/_chunks/nitro4.mjs +0 -176
- package/dist/_chunks/nitro5.mjs +0 -733
- package/dist/_chunks/nitro6.mjs +0 -1458
- package/dist/_chunks/nitro7.mjs +0 -7561
- package/dist/_chunks/nitro8.mjs +0 -3524
- package/dist/_chunks/nitro9.mjs +0 -1729
- package/dist/_libs/_.mjs +0 -3
- package/dist/_libs/_2.mjs +0 -3
- package/dist/_libs/_3.mjs +0 -4
- package/dist/_libs/_4.mjs +0 -6
- package/dist/_libs/_5.mjs +0 -3
- package/dist/_libs/_6.mjs +0 -3
- package/dist/_libs/acorn+confbox+js-tokens+magic-string+mlly+pkg-types+sourcemap-codec+strip-literal+unimport.mjs +0 -8900
- package/dist/_libs/confbox+exsolve+pkg-types.mjs +0 -1249
- package/dist/_libs/confbox2.mjs +0 -786
- package/dist/_libs/confbox3.mjs +0 -404
- package/dist/_libs/confbox4.mjs +0 -3
- package/dist/_libs/estree-walker+unimport.mjs +0 -378
- package/dist/_libs/fdir+picomatch+tinyglobby.mjs +0 -2471
- package/dist/_libs/gen-mapping+remapping+resolve-uri+trace-mapping+unimport+unplugin+unplugin-utils+webpack-virtual-modules.mjs +0 -2150
- package/dist/_libs/giget+node-fetch-native.mjs +0 -2692
- package/dist/_libs/local-pkg+quansync+unimport.mjs +0 -1526
- package/dist/_libs/nypm+tinyexec.mjs +0 -858
- package/dist/_libs/pathe.mjs +0 -164
- package/dist/_libs/perfect-debounce.mjs +0 -89
- package/dist/_libs/std-env.mjs +0 -158
- package/dist/_libs/vite-plugin-fullstack.mjs +0 -26
package/dist/_chunks/nitro2.mjs
CHANGED
|
@@ -1,258 +1,101 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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";
|
|
1
|
+
import { N as glob, at as join, st as relative } from "../_build/common.mjs";
|
|
2
|
+
import { withBase, withLeadingSlash, withoutTrailingSlash } from "ufo";
|
|
12
3
|
|
|
13
|
-
//#region
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
for (var i = 0; i < arr.length; i++) fn(arr[i], i);
|
|
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
|
+
};
|
|
28
18
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
}
|
|
49
|
-
}
|
|
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;
|
|
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);
|
|
91
22
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
"
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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);
|
|
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;
|
|
200
51
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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
|
+
});
|
|
206
62
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
async function
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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
|
+
};
|
|
215
72
|
});
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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;
|
|
73
|
+
}
|
|
74
|
+
async function scanModules(nitro) {
|
|
75
|
+
return (await scanFiles(nitro, "modules")).map((f) => f.fullPath);
|
|
76
|
+
}
|
|
77
|
+
async function scanFiles(nitro, name) {
|
|
78
|
+
return await Promise.all(nitro.options.scanDirs.map((dir) => scanDir(nitro, dir, name))).then((r) => r.flat());
|
|
79
|
+
}
|
|
80
|
+
async function scanDir(nitro, dir, name) {
|
|
81
|
+
return (await glob(join(name, GLOB_SCAN_PATTERN), {
|
|
82
|
+
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 [];
|
|
244
90
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
if (options.compressedSizes) treeText += ` (${prettyBytes(totalGzip + totalNodeModulesGzip)} gzip)`;
|
|
253
|
-
treeText += "\n";
|
|
254
|
-
return treeText;
|
|
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));
|
|
255
98
|
}
|
|
256
99
|
|
|
257
100
|
//#endregion
|
|
258
|
-
export {
|
|
101
|
+
export { scanHandlers as n, scanAndSyncOptions as t };
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { i as __toESM, r as __require, t as __commonJSMin } from "../_common.mjs";
|
|
2
|
+
import { N as glob, V as a, ct as resolve, nt as dirname, p as runParallel, st as relative } from "../_build/common.mjs";
|
|
3
|
+
import fs, { promises } from "node:fs";
|
|
4
|
+
import { promisify } from "node:util";
|
|
5
|
+
import { colors } from "consola/utils";
|
|
6
|
+
import zlib from "node:zlib";
|
|
7
|
+
import "node:stream";
|
|
8
|
+
|
|
9
|
+
//#region node_modules/.pnpm/duplexer@0.1.2/node_modules/duplexer/index.js
|
|
10
|
+
var require_duplexer = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
11
|
+
var Stream = __require("stream");
|
|
12
|
+
var writeMethods = [
|
|
13
|
+
"write",
|
|
14
|
+
"end",
|
|
15
|
+
"destroy"
|
|
16
|
+
];
|
|
17
|
+
var readMethods = ["resume", "pause"];
|
|
18
|
+
var readEvents = ["data", "close"];
|
|
19
|
+
var slice = Array.prototype.slice;
|
|
20
|
+
module.exports = duplex;
|
|
21
|
+
function forEach(arr, fn) {
|
|
22
|
+
if (arr.forEach) return arr.forEach(fn);
|
|
23
|
+
for (var i = 0; i < arr.length; i++) fn(arr[i], i);
|
|
24
|
+
}
|
|
25
|
+
function duplex(writer, reader) {
|
|
26
|
+
var stream = new Stream();
|
|
27
|
+
var ended = false;
|
|
28
|
+
forEach(writeMethods, proxyWriter);
|
|
29
|
+
forEach(readMethods, proxyReader);
|
|
30
|
+
forEach(readEvents, proxyStream);
|
|
31
|
+
reader.on("end", handleEnd);
|
|
32
|
+
writer.on("drain", function() {
|
|
33
|
+
stream.emit("drain");
|
|
34
|
+
});
|
|
35
|
+
writer.on("error", reemit);
|
|
36
|
+
reader.on("error", reemit);
|
|
37
|
+
stream.writable = writer.writable;
|
|
38
|
+
stream.readable = reader.readable;
|
|
39
|
+
return stream;
|
|
40
|
+
function proxyWriter(methodName) {
|
|
41
|
+
stream[methodName] = method;
|
|
42
|
+
function method() {
|
|
43
|
+
return writer[methodName].apply(writer, arguments);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function proxyReader(methodName) {
|
|
47
|
+
stream[methodName] = method;
|
|
48
|
+
function method() {
|
|
49
|
+
stream.emit(methodName);
|
|
50
|
+
var func = reader[methodName];
|
|
51
|
+
if (func) return func.apply(reader, arguments);
|
|
52
|
+
reader.emit(methodName);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function proxyStream(methodName) {
|
|
56
|
+
reader.on(methodName, reemit$1);
|
|
57
|
+
function reemit$1() {
|
|
58
|
+
var args = slice.call(arguments);
|
|
59
|
+
args.unshift(methodName);
|
|
60
|
+
stream.emit.apply(stream, args);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function handleEnd() {
|
|
64
|
+
if (ended) return;
|
|
65
|
+
ended = true;
|
|
66
|
+
var args = slice.call(arguments);
|
|
67
|
+
args.unshift("end");
|
|
68
|
+
stream.emit.apply(stream, args);
|
|
69
|
+
}
|
|
70
|
+
function reemit(err) {
|
|
71
|
+
stream.emit("error", err);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}));
|
|
75
|
+
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region node_modules/.pnpm/gzip-size@7.0.0/node_modules/gzip-size/index.js
|
|
78
|
+
var import_duplexer = /* @__PURE__ */ __toESM(require_duplexer(), 1);
|
|
79
|
+
const getOptions = (options) => ({
|
|
80
|
+
level: 9,
|
|
81
|
+
...options
|
|
82
|
+
});
|
|
83
|
+
const gzip = promisify(zlib.gzip);
|
|
84
|
+
async function gzipSize(input, options) {
|
|
85
|
+
if (!input) return 0;
|
|
86
|
+
return (await gzip(input, getOptions(options))).length;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region node_modules/.pnpm/pretty-bytes@7.1.0/node_modules/pretty-bytes/index.js
|
|
91
|
+
const BYTE_UNITS = [
|
|
92
|
+
"B",
|
|
93
|
+
"kB",
|
|
94
|
+
"MB",
|
|
95
|
+
"GB",
|
|
96
|
+
"TB",
|
|
97
|
+
"PB",
|
|
98
|
+
"EB",
|
|
99
|
+
"ZB",
|
|
100
|
+
"YB"
|
|
101
|
+
];
|
|
102
|
+
const BIBYTE_UNITS = [
|
|
103
|
+
"B",
|
|
104
|
+
"KiB",
|
|
105
|
+
"MiB",
|
|
106
|
+
"GiB",
|
|
107
|
+
"TiB",
|
|
108
|
+
"PiB",
|
|
109
|
+
"EiB",
|
|
110
|
+
"ZiB",
|
|
111
|
+
"YiB"
|
|
112
|
+
];
|
|
113
|
+
const BIT_UNITS = [
|
|
114
|
+
"b",
|
|
115
|
+
"kbit",
|
|
116
|
+
"Mbit",
|
|
117
|
+
"Gbit",
|
|
118
|
+
"Tbit",
|
|
119
|
+
"Pbit",
|
|
120
|
+
"Ebit",
|
|
121
|
+
"Zbit",
|
|
122
|
+
"Ybit"
|
|
123
|
+
];
|
|
124
|
+
const BIBIT_UNITS = [
|
|
125
|
+
"b",
|
|
126
|
+
"kibit",
|
|
127
|
+
"Mibit",
|
|
128
|
+
"Gibit",
|
|
129
|
+
"Tibit",
|
|
130
|
+
"Pibit",
|
|
131
|
+
"Eibit",
|
|
132
|
+
"Zibit",
|
|
133
|
+
"Yibit"
|
|
134
|
+
];
|
|
135
|
+
const toLocaleString = (number, locale, options) => {
|
|
136
|
+
let result = number;
|
|
137
|
+
if (typeof locale === "string" || Array.isArray(locale)) result = number.toLocaleString(locale, options);
|
|
138
|
+
else if (locale === true || options !== void 0) result = number.toLocaleString(void 0, options);
|
|
139
|
+
return result;
|
|
140
|
+
};
|
|
141
|
+
const log10 = (numberOrBigInt) => {
|
|
142
|
+
if (typeof numberOrBigInt === "number") return Math.log10(numberOrBigInt);
|
|
143
|
+
const string = numberOrBigInt.toString(10);
|
|
144
|
+
return string.length + Math.log10(`0.${string.slice(0, 15)}`);
|
|
145
|
+
};
|
|
146
|
+
const log = (numberOrBigInt) => {
|
|
147
|
+
if (typeof numberOrBigInt === "number") return Math.log(numberOrBigInt);
|
|
148
|
+
return log10(numberOrBigInt) * Math.log(10);
|
|
149
|
+
};
|
|
150
|
+
const divide = (numberOrBigInt, divisor) => {
|
|
151
|
+
if (typeof numberOrBigInt === "number") return numberOrBigInt / divisor;
|
|
152
|
+
const integerPart = numberOrBigInt / BigInt(divisor);
|
|
153
|
+
const remainder = numberOrBigInt % BigInt(divisor);
|
|
154
|
+
return Number(integerPart) + Number(remainder) / divisor;
|
|
155
|
+
};
|
|
156
|
+
const applyFixedWidth = (result, fixedWidth) => {
|
|
157
|
+
if (fixedWidth === void 0) return result;
|
|
158
|
+
if (typeof fixedWidth !== "number" || !Number.isSafeInteger(fixedWidth) || fixedWidth < 0) throw new TypeError(`Expected fixedWidth to be a non-negative integer, got ${typeof fixedWidth}: ${fixedWidth}`);
|
|
159
|
+
if (fixedWidth === 0) return result;
|
|
160
|
+
return result.length < fixedWidth ? result.padStart(fixedWidth, " ") : result;
|
|
161
|
+
};
|
|
162
|
+
const buildLocaleOptions = (options) => {
|
|
163
|
+
const { minimumFractionDigits, maximumFractionDigits } = options;
|
|
164
|
+
if (minimumFractionDigits === void 0 && maximumFractionDigits === void 0) return;
|
|
165
|
+
return {
|
|
166
|
+
...minimumFractionDigits !== void 0 && { minimumFractionDigits },
|
|
167
|
+
...maximumFractionDigits !== void 0 && { maximumFractionDigits },
|
|
168
|
+
roundingMode: "trunc"
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
function prettyBytes(number, options) {
|
|
172
|
+
if (typeof number !== "bigint" && !Number.isFinite(number)) throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
|
|
173
|
+
options = {
|
|
174
|
+
bits: false,
|
|
175
|
+
binary: false,
|
|
176
|
+
space: true,
|
|
177
|
+
nonBreakingSpace: false,
|
|
178
|
+
...options
|
|
179
|
+
};
|
|
180
|
+
const UNITS = options.bits ? options.binary ? BIBIT_UNITS : BIT_UNITS : options.binary ? BIBYTE_UNITS : BYTE_UNITS;
|
|
181
|
+
const separator = options.space ? options.nonBreakingSpace ? "\xA0" : " " : "";
|
|
182
|
+
const isZero = typeof number === "number" ? number === 0 : number === 0n;
|
|
183
|
+
if (options.signed && isZero) return applyFixedWidth(` 0${separator}${UNITS[0]}`, options.fixedWidth);
|
|
184
|
+
const isNegative = number < 0;
|
|
185
|
+
const prefix = isNegative ? "-" : options.signed ? "+" : "";
|
|
186
|
+
if (isNegative) number = -number;
|
|
187
|
+
const localeOptions = buildLocaleOptions(options);
|
|
188
|
+
let result;
|
|
189
|
+
if (number < 1) result = prefix + toLocaleString(number, options.locale, localeOptions) + separator + UNITS[0];
|
|
190
|
+
else {
|
|
191
|
+
const exponent = Math.min(Math.floor(options.binary ? log(number) / Math.log(1024) : log10(number) / 3), UNITS.length - 1);
|
|
192
|
+
number = divide(number, (options.binary ? 1024 : 1e3) ** exponent);
|
|
193
|
+
if (!localeOptions) {
|
|
194
|
+
const minPrecision = Math.max(3, Math.floor(number).toString().length);
|
|
195
|
+
number = number.toPrecision(minPrecision);
|
|
196
|
+
}
|
|
197
|
+
const numberString = toLocaleString(Number(number), options.locale, localeOptions);
|
|
198
|
+
const unit = UNITS[exponent];
|
|
199
|
+
result = prefix + numberString + separator + unit;
|
|
200
|
+
}
|
|
201
|
+
return applyFixedWidth(result, options.fixedWidth);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region src/utils/fs-tree.ts
|
|
206
|
+
async function generateFSTree(dir, options = {}) {
|
|
207
|
+
if (a) return;
|
|
208
|
+
const files = await glob("**/*.*", {
|
|
209
|
+
cwd: dir,
|
|
210
|
+
ignore: ["*.map"]
|
|
211
|
+
});
|
|
212
|
+
const items = [];
|
|
213
|
+
await runParallel(new Set(files), async (file) => {
|
|
214
|
+
const path = resolve(dir, file);
|
|
215
|
+
const src = await promises.readFile(path);
|
|
216
|
+
const size = src.byteLength;
|
|
217
|
+
const gzip$1 = options.compressedSizes ? await gzipSize(src) : 0;
|
|
218
|
+
items.push({
|
|
219
|
+
file,
|
|
220
|
+
path,
|
|
221
|
+
size,
|
|
222
|
+
gzip: gzip$1
|
|
223
|
+
});
|
|
224
|
+
}, { concurrency: 10 });
|
|
225
|
+
items.sort((a$1, b) => a$1.path.localeCompare(b.path));
|
|
226
|
+
let totalSize = 0;
|
|
227
|
+
let totalGzip = 0;
|
|
228
|
+
let totalNodeModulesSize = 0;
|
|
229
|
+
let totalNodeModulesGzip = 0;
|
|
230
|
+
let treeText = "";
|
|
231
|
+
for (const [index, item] of items.entries()) {
|
|
232
|
+
let dir$1 = dirname(item.file);
|
|
233
|
+
if (dir$1 === ".") dir$1 = "";
|
|
234
|
+
const rpath = relative(process.cwd(), item.path);
|
|
235
|
+
const treeChar = index === items.length - 1 ? "└─" : "├─";
|
|
236
|
+
if (item.file.includes("node_modules")) {
|
|
237
|
+
totalNodeModulesSize += item.size;
|
|
238
|
+
totalNodeModulesGzip += item.gzip;
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
treeText += colors.gray(` ${treeChar} ${rpath} (${prettyBytes(item.size)})`);
|
|
242
|
+
if (options.compressedSizes) treeText += colors.gray(` (${prettyBytes(item.gzip)} gzip)`);
|
|
243
|
+
treeText += "\n";
|
|
244
|
+
totalSize += item.size;
|
|
245
|
+
totalGzip += item.gzip;
|
|
246
|
+
}
|
|
247
|
+
treeText += `${colors.cyan("Σ Total size:")} ${prettyBytes(totalSize + totalNodeModulesSize)}`;
|
|
248
|
+
if (options.compressedSizes) treeText += ` (${prettyBytes(totalGzip + totalNodeModulesGzip)} gzip)`;
|
|
249
|
+
treeText += "\n";
|
|
250
|
+
return treeText;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
//#endregion
|
|
254
|
+
export { generateFSTree as t };
|
package/dist/_common.mjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
11
|
+
var __exportAll = (all, symbols) => {
|
|
12
|
+
let target = {};
|
|
13
|
+
for (var name in all) {
|
|
14
|
+
__defProp(target, name, {
|
|
15
|
+
get: all[name],
|
|
16
|
+
enumerable: true
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
if (symbols) {
|
|
20
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
21
|
+
}
|
|
22
|
+
return target;
|
|
23
|
+
};
|
|
24
|
+
var __copyProps = (to, from, except, desc) => {
|
|
25
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
26
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
27
|
+
key = keys[i];
|
|
28
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
29
|
+
__defProp(to, key, {
|
|
30
|
+
get: ((k) => from[k]).bind(null, key),
|
|
31
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return to;
|
|
37
|
+
};
|
|
38
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
39
|
+
value: mod,
|
|
40
|
+
enumerable: true
|
|
41
|
+
}) : target, mod));
|
|
42
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { __toESM as i, __exportAll as n, __require as r, __commonJSMin as t };
|