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.
- package/dist/_build/rolldown.mjs +13 -8
- package/dist/_build/vite.build.mjs +1 -1
- package/dist/_chunks/dev.mjs +5 -3
- package/dist/_chunks/nitro.mjs +24 -1183
- package/dist/_chunks/nitro2.mjs +248 -91
- package/dist/_chunks/nitro3.mjs +2696 -0
- package/dist/_chunks/nitro4.mjs +176 -0
- package/dist/_chunks/nitro5.mjs +733 -0
- package/dist/_chunks/nitro6.mjs +1458 -0
- package/dist/_chunks/nitro7.mjs +7561 -0
- package/dist/_chunks/nitro8.mjs +3524 -0
- package/dist/_chunks/nitro9.mjs +1729 -0
- package/dist/_libs/_.mjs +3 -0
- package/dist/_libs/_2.mjs +3 -0
- package/dist/_libs/_3.mjs +4 -0
- package/dist/_libs/_4.mjs +6 -0
- package/dist/_libs/_5.mjs +3 -0
- package/dist/_libs/_6.mjs +3 -0
- package/dist/_libs/acorn+confbox+js-tokens+magic-string+mlly+pkg-types+sourcemap-codec+strip-literal+unimport.mjs +8900 -0
- package/dist/_libs/{c12.mjs → c12+dotenv+rc9.mjs} +12 -105
- package/dist/_libs/{chokidar.mjs → chokidar+readdirp.mjs} +2 -9
- package/dist/_libs/confbox+exsolve+pkg-types.mjs +1249 -0
- package/dist/_libs/confbox.mjs +70 -2488
- package/dist/_libs/confbox2.mjs +786 -0
- package/dist/_libs/confbox3.mjs +404 -0
- package/dist/_libs/confbox4.mjs +3 -0
- package/dist/_libs/estree-walker+unimport.mjs +378 -0
- package/dist/_libs/fdir+picomatch+tinyglobby.mjs +2471 -0
- package/dist/_libs/gen-mapping+remapping+resolve-uri+trace-mapping+unimport+unplugin+unplugin-utils+webpack-virtual-modules.mjs +2150 -0
- package/dist/_libs/giget+node-fetch-native.mjs +2692 -0
- package/dist/_libs/httpxy.mjs +1 -6
- package/dist/_libs/local-pkg+quansync+unimport.mjs +1526 -0
- package/dist/_libs/nypm+tinyexec.mjs +858 -0
- package/dist/_libs/pathe.mjs +164 -0
- package/dist/_libs/perfect-debounce.mjs +89 -0
- package/dist/_libs/{@rollup/plugin-inject.mjs → plugin-alias+plugin-inject.mjs} +65 -2
- package/dist/_libs/std-env.mjs +158 -0
- package/dist/_libs/unimport.mjs +5 -1781
- package/dist/_libs/vite-plugin-fullstack.mjs +26 -0
- package/dist/_presets.mjs +8 -3
- package/dist/builder.mjs +8 -6
- package/dist/cli/_chunks/build.mjs +1 -1
- package/dist/cli/_chunks/dev.mjs +3 -2
- 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/index.mjs +1 -1
- package/dist/types/index.d.mts +2410 -1174
- package/dist/vite.d.mts +13 -13
- package/dist/vite.mjs +640 -16
- package/package.json +9 -9
- package/dist/_build/common.mjs +0 -24931
- package/dist/_build/rollup.mjs +0 -201
- package/dist/_chunks/utils.mjs +0 -254
- package/dist/_common.mjs +0 -45
- package/dist/_libs/@hiogawa/vite-plugin-fullstack.mjs +0 -652
- package/dist/_libs/@jridgewell/gen-mapping.mjs +0 -448
- package/dist/_libs/@jridgewell/remapping.mjs +0 -117
- package/dist/_libs/@rollup/plugin-alias.mjs +0 -64
- package/dist/_libs/@rollup/plugin-commonjs.mjs +0 -1300
- package/dist/_libs/@rollup/plugin-json.mjs +0 -36
- package/dist/_libs/@rollup/plugin-node-resolve.mjs +0 -1972
- package/dist/_libs/escape-string-regexp.mjs +0 -8
- package/dist/_libs/estree-walker.mjs +0 -187
- package/dist/_libs/giget.mjs +0 -3550
- package/dist/_libs/klona.mjs +0 -38
- package/dist/_libs/rou3.mjs +0 -322
- package/dist/_libs/tsconfck.mjs +0 -832
- package/dist/_libs/ultrahtml.mjs +0 -138
- package/dist/cli/_chunks/task.mjs +0 -16
package/dist/_build/rollup.mjs
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import "../_common.mjs";
|
|
2
|
-
import { Ft as relative, Mt as isAbsolute, Nt as join, _ as writeTypes, a as libChunkName, h as writeBuildInfo, i as getChunkName, n as baseBuildPlugins, o as baseBuildConfig, r as NODE_MODULES_RE, t as oxc } from "./common.mjs";
|
|
3
|
-
import { s as debounce } from "../_libs/c12.mjs";
|
|
4
|
-
import { t as formatCompatibilityDate } from "../_libs/compatx.mjs";
|
|
5
|
-
import { n as scanHandlers } from "../_chunks/nitro2.mjs";
|
|
6
|
-
import { a as watch$1 } from "../_libs/chokidar.mjs";
|
|
7
|
-
import { t as alias } from "../_libs/@rollup/plugin-alias.mjs";
|
|
8
|
-
import { t as inject } from "../_libs/@rollup/plugin-inject.mjs";
|
|
9
|
-
import { t as generateFSTree } from "../_chunks/utils.mjs";
|
|
10
|
-
import { t as commonjs } from "../_libs/@rollup/plugin-commonjs.mjs";
|
|
11
|
-
import { t as json } from "../_libs/@rollup/plugin-json.mjs";
|
|
12
|
-
import { t as nodeResolve } from "../_libs/@rollup/plugin-node-resolve.mjs";
|
|
13
|
-
import { watch } from "node:fs";
|
|
14
|
-
import { defu } from "defu";
|
|
15
|
-
|
|
16
|
-
//#region src/build/rollup/config.ts
|
|
17
|
-
const getRollupConfig = async (nitro) => {
|
|
18
|
-
const base = baseBuildConfig(nitro);
|
|
19
|
-
const tsc = nitro.options.typescript.tsConfig?.compilerOptions;
|
|
20
|
-
let config = {
|
|
21
|
-
input: nitro.options.entry,
|
|
22
|
-
external: [...base.env.external],
|
|
23
|
-
plugins: [
|
|
24
|
-
...await baseBuildPlugins(nitro, base),
|
|
25
|
-
oxc({
|
|
26
|
-
sourcemap: !!nitro.options.sourcemap,
|
|
27
|
-
minify: nitro.options.minify ? { ...nitro.options.oxc?.minify } : false,
|
|
28
|
-
transform: {
|
|
29
|
-
target: "esnext",
|
|
30
|
-
cwd: nitro.options.rootDir,
|
|
31
|
-
...nitro.options.oxc?.transform,
|
|
32
|
-
jsx: {
|
|
33
|
-
runtime: tsc?.jsx === "react" ? "classic" : "automatic",
|
|
34
|
-
pragma: tsc?.jsxFactory,
|
|
35
|
-
pragmaFrag: tsc?.jsxFragmentFactory,
|
|
36
|
-
importSource: tsc?.jsxImportSource,
|
|
37
|
-
development: nitro.options.dev,
|
|
38
|
-
...nitro.options.oxc?.transform?.jsx
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}),
|
|
42
|
-
alias({ entries: base.aliases }),
|
|
43
|
-
nodeResolve({
|
|
44
|
-
extensions: base.extensions,
|
|
45
|
-
preferBuiltins: !!nitro.options.node,
|
|
46
|
-
rootDir: nitro.options.rootDir,
|
|
47
|
-
exportConditions: nitro.options.exportConditions
|
|
48
|
-
}),
|
|
49
|
-
commonjs({ ...nitro.options.commonJS }),
|
|
50
|
-
json(),
|
|
51
|
-
inject(base.env.inject)
|
|
52
|
-
],
|
|
53
|
-
onwarn(warning, rollupWarn) {
|
|
54
|
-
if (!base.ignoreWarningCodes.has(warning.code || "")) rollupWarn(warning);
|
|
55
|
-
},
|
|
56
|
-
treeshake: { moduleSideEffects(id) {
|
|
57
|
-
return nitro.options.moduleSideEffects.some((p) => id.startsWith(p));
|
|
58
|
-
} },
|
|
59
|
-
output: {
|
|
60
|
-
format: "esm",
|
|
61
|
-
entryFileNames: "index.mjs",
|
|
62
|
-
chunkFileNames: (chunk) => getChunkName(chunk, nitro),
|
|
63
|
-
dir: nitro.options.output.serverDir,
|
|
64
|
-
inlineDynamicImports: nitro.options.inlineDynamicImports,
|
|
65
|
-
generatedCode: { constBindings: true },
|
|
66
|
-
sourcemap: nitro.options.sourcemap,
|
|
67
|
-
sourcemapExcludeSources: true,
|
|
68
|
-
sourcemapIgnoreList: (id) => id.includes("node_modules"),
|
|
69
|
-
manualChunks(id) {
|
|
70
|
-
if (NODE_MODULES_RE.test(id)) return libChunkName(id);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
config = defu(nitro.options.rollupConfig, config);
|
|
75
|
-
const outputConfig = config.output;
|
|
76
|
-
if (outputConfig.inlineDynamicImports || outputConfig.format === "iife") delete outputConfig.manualChunks;
|
|
77
|
-
return config;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region src/build/rollup/error.ts
|
|
82
|
-
function formatRollupError(_error) {
|
|
83
|
-
try {
|
|
84
|
-
const logs = [_error.toString()];
|
|
85
|
-
const errors = _error?.errors || [_error];
|
|
86
|
-
for (const error of errors) {
|
|
87
|
-
const id = error.path || error.id || _error.id;
|
|
88
|
-
let path = isAbsolute(id) ? relative(process.cwd(), id) : id;
|
|
89
|
-
const location = error.loc;
|
|
90
|
-
if (location) path += `:${location.line}:${location.column}`;
|
|
91
|
-
const text = error.frame;
|
|
92
|
-
logs.push(`Rollup error while processing \`${path}\`` + text ? "\n\n" + text : "");
|
|
93
|
-
}
|
|
94
|
-
return logs.join("\n");
|
|
95
|
-
} catch {
|
|
96
|
-
return _error?.toString();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
//#endregion
|
|
101
|
-
//#region src/build/rollup/dev.ts
|
|
102
|
-
async function watchDev(nitro, rollupConfig) {
|
|
103
|
-
const rollup = await import("rollup");
|
|
104
|
-
let rollupWatcher;
|
|
105
|
-
async function load() {
|
|
106
|
-
if (rollupWatcher) await rollupWatcher.close();
|
|
107
|
-
await scanHandlers(nitro);
|
|
108
|
-
nitro.routing.sync();
|
|
109
|
-
rollupWatcher = startRollupWatcher(nitro, rollupConfig);
|
|
110
|
-
await writeTypes(nitro);
|
|
111
|
-
}
|
|
112
|
-
const reload = debounce(load);
|
|
113
|
-
const scanDirs = nitro.options.scanDirs.flatMap((dir) => [
|
|
114
|
-
join(dir, nitro.options.apiDir || "api"),
|
|
115
|
-
join(dir, nitro.options.routesDir || "routes"),
|
|
116
|
-
join(dir, "middleware"),
|
|
117
|
-
join(dir, "plugins"),
|
|
118
|
-
join(dir, "modules")
|
|
119
|
-
]);
|
|
120
|
-
const watchReloadEvents = new Set([
|
|
121
|
-
"add",
|
|
122
|
-
"addDir",
|
|
123
|
-
"unlink",
|
|
124
|
-
"unlinkDir"
|
|
125
|
-
]);
|
|
126
|
-
const scanDirsWatcher = watch$1(scanDirs, { ignoreInitial: true }).on("all", (event, path, stat$1) => {
|
|
127
|
-
if (watchReloadEvents.has(event)) reload();
|
|
128
|
-
});
|
|
129
|
-
const rootDirWatcher = watch(nitro.options.rootDir, { persistent: false }, (_event, filename) => {
|
|
130
|
-
if (filename && /^server\.[mc]?[jt]sx?$/.test(filename)) reload();
|
|
131
|
-
});
|
|
132
|
-
nitro.hooks.hook("close", () => {
|
|
133
|
-
rollupWatcher.close();
|
|
134
|
-
scanDirsWatcher.close();
|
|
135
|
-
rootDirWatcher.close();
|
|
136
|
-
});
|
|
137
|
-
nitro.hooks.hook("rollup:reload", () => reload());
|
|
138
|
-
await load();
|
|
139
|
-
function startRollupWatcher(nitro$1, rollupConfig$1) {
|
|
140
|
-
const watcher = rollup.watch(defu(rollupConfig$1, { watch: { chokidar: nitro$1.options.watchOptions } }));
|
|
141
|
-
let start;
|
|
142
|
-
watcher.on("event", (event) => {
|
|
143
|
-
switch (event.code) {
|
|
144
|
-
case "START":
|
|
145
|
-
start = Date.now();
|
|
146
|
-
nitro$1.logger.info(`Starting dev watcher (builder: \`rollup\`, preset: \`${nitro$1.options.preset}\`, compatibility date: \`${formatCompatibilityDate(nitro$1.options.compatibilityDate)}\`)`);
|
|
147
|
-
nitro$1.hooks.callHook("dev:start");
|
|
148
|
-
break;
|
|
149
|
-
case "BUNDLE_END":
|
|
150
|
-
nitro$1.hooks.callHook("compiled", nitro$1);
|
|
151
|
-
if (nitro$1.options.logging.buildSuccess) nitro$1.logger.success(`Server built`, start ? `in ${Date.now() - start}ms` : "");
|
|
152
|
-
nitro$1.hooks.callHook("dev:reload");
|
|
153
|
-
break;
|
|
154
|
-
case "ERROR":
|
|
155
|
-
nitro$1.logger.error(formatRollupError(event.error));
|
|
156
|
-
nitro$1.hooks.callHook("dev:error", event.error);
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
return watcher;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
//#endregion
|
|
164
|
-
//#region src/build/rollup/prod.ts
|
|
165
|
-
async function buildProduction(nitro, rollupConfig) {
|
|
166
|
-
const rollup = await import("rollup");
|
|
167
|
-
const buildStartTime = Date.now();
|
|
168
|
-
await scanHandlers(nitro);
|
|
169
|
-
await writeTypes(nitro);
|
|
170
|
-
if (!nitro.options.static) {
|
|
171
|
-
nitro.logger.info(`Building server (builder: \`rollup\`, preset: \`${nitro.options.preset}\`, compatibility date: \`${formatCompatibilityDate(nitro.options.compatibilityDate)}\`)`);
|
|
172
|
-
await (await rollup.rollup(rollupConfig).catch((error) => {
|
|
173
|
-
nitro.logger.error(formatRollupError(error));
|
|
174
|
-
throw error;
|
|
175
|
-
})).write(rollupConfig.output);
|
|
176
|
-
}
|
|
177
|
-
const buildInfo = await writeBuildInfo(nitro);
|
|
178
|
-
if (!nitro.options.static) {
|
|
179
|
-
if (nitro.options.logging.buildSuccess) nitro.logger.success(`Server built in ${Date.now() - buildStartTime}ms`);
|
|
180
|
-
if (nitro.options.logLevel > 1) process.stdout.write(await generateFSTree(nitro.options.output.serverDir, { compressedSizes: nitro.options.logging.compressedSizes }) || "");
|
|
181
|
-
}
|
|
182
|
-
await nitro.hooks.callHook("compiled", nitro);
|
|
183
|
-
const rOutput = relative(process.cwd(), nitro.options.output.dir);
|
|
184
|
-
const rewriteRelativePaths = (input) => {
|
|
185
|
-
return input.replace(/([\s:])\.\/(\S*)/g, `$1${rOutput}/$2`);
|
|
186
|
-
};
|
|
187
|
-
if (buildInfo.commands.preview) nitro.logger.success(`You can preview this build using \`${rewriteRelativePaths(buildInfo.commands.preview)}\``);
|
|
188
|
-
if (buildInfo.commands.deploy) nitro.logger.success(`You can deploy this build using \`${rewriteRelativePaths(buildInfo.commands.deploy)}\``);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
//#endregion
|
|
192
|
-
//#region src/build/rollup/build.ts
|
|
193
|
-
async function rollupBuild(nitro) {
|
|
194
|
-
await nitro.hooks.callHook("build:before", nitro);
|
|
195
|
-
const config = await getRollupConfig(nitro);
|
|
196
|
-
await nitro.hooks.callHook("rollup:before", nitro, config);
|
|
197
|
-
return nitro.options.dev ? watchDev(nitro, config) : buildProduction(nitro, config);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
//#endregion
|
|
201
|
-
export { rollupBuild };
|
package/dist/_chunks/utils.mjs
DELETED
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import { i as __toESM, r as __require, t as __commonJSMin } from "../_common.mjs";
|
|
2
|
-
import { At as dirname, Ft as relative, It as resolve, ft as a, it as glob, p as runParallel } 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
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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 };
|