@nasti-toolchain/nasti 2.4.4 → 2.5.1
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/README.md +76 -0
- package/dist/cli.cjs +1716 -215
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1707 -206
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +2160 -318
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +85 -1
- package/dist/index.d.ts +85 -1
- package/dist/index.js +2158 -317
- package/dist/index.js.map +1 -1
- package/package.json +18 -1
package/dist/cli.cjs
CHANGED
|
@@ -5,16 +5,25 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __glob = (map) => (
|
|
9
|
-
var fn = map[
|
|
8
|
+
var __glob = (map) => (path21) => {
|
|
9
|
+
var fn = map[path21];
|
|
10
10
|
if (fn) return fn();
|
|
11
|
-
throw new Error("Module not found in bundle: " +
|
|
11
|
+
throw new Error("Module not found in bundle: " + path21);
|
|
12
12
|
};
|
|
13
|
-
var __esm = (fn, res) => function __init() {
|
|
14
|
-
|
|
13
|
+
var __esm = (fn, res, err) => function __init() {
|
|
14
|
+
if (err) throw err[0];
|
|
15
|
+
try {
|
|
16
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
17
|
+
} catch (e) {
|
|
18
|
+
throw err = [e], e;
|
|
19
|
+
}
|
|
15
20
|
};
|
|
16
21
|
var __commonJS = (cb, mod) => function __require2() {
|
|
17
|
-
|
|
22
|
+
try {
|
|
23
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
24
|
+
} catch (e) {
|
|
25
|
+
throw mod = 0, e;
|
|
26
|
+
}
|
|
18
27
|
};
|
|
19
28
|
var __export = (target, all) => {
|
|
20
29
|
for (var name in all)
|
|
@@ -62,7 +71,7 @@ function createLogger(level = "info", options = {}) {
|
|
|
62
71
|
const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI;
|
|
63
72
|
const clear = canClearScreen ? clearScreen : () => {
|
|
64
73
|
};
|
|
65
|
-
function
|
|
74
|
+
function format2(type, msg, options2 = {}) {
|
|
66
75
|
if (options2.timestamp) {
|
|
67
76
|
const tag = type === "info" ? import_picocolors.default.cyan(import_picocolors.default.bold(prefix)) : type === "warn" ? import_picocolors.default.yellow(import_picocolors.default.bold(prefix)) : import_picocolors.default.red(import_picocolors.default.bold(prefix));
|
|
68
77
|
return `${import_picocolors.default.dim(timeFormatter.format(/* @__PURE__ */ new Date()))} ${tag} ${msg}`;
|
|
@@ -79,16 +88,16 @@ function createLogger(level = "info", options = {}) {
|
|
|
79
88
|
if (type === lastType && msg === lastMsg) {
|
|
80
89
|
sameCount++;
|
|
81
90
|
clear();
|
|
82
|
-
console_[method](
|
|
91
|
+
console_[method](format2(type, msg, options2), import_picocolors.default.yellow(`(x${sameCount + 1})`));
|
|
83
92
|
} else {
|
|
84
93
|
sameCount = 0;
|
|
85
94
|
lastMsg = msg;
|
|
86
95
|
lastType = type;
|
|
87
96
|
if (options2.clear) clear();
|
|
88
|
-
console_[method](
|
|
97
|
+
console_[method](format2(type, msg, options2));
|
|
89
98
|
}
|
|
90
99
|
} else {
|
|
91
|
-
console_[method](
|
|
100
|
+
console_[method](format2(type, msg, options2));
|
|
92
101
|
}
|
|
93
102
|
}
|
|
94
103
|
const warnedMessages = /* @__PURE__ */ new Set();
|
|
@@ -157,7 +166,7 @@ var init_logger = __esm({
|
|
|
157
166
|
});
|
|
158
167
|
|
|
159
168
|
// src/config/defaults.ts
|
|
160
|
-
var defaultResolve, defaultServer, defaultBuild, defaultElectron, defaultExperimental, defaults;
|
|
169
|
+
var defaultResolve, defaultServer, defaultBuild, defaultElectron, defaultExperimental, defaultReact, defaults;
|
|
161
170
|
var init_defaults = __esm({
|
|
162
171
|
"src/config/defaults.ts"() {
|
|
163
172
|
"use strict";
|
|
@@ -210,12 +219,20 @@ var init_defaults = __esm({
|
|
|
210
219
|
defaultExperimental = {
|
|
211
220
|
bundledDev: false
|
|
212
221
|
};
|
|
222
|
+
defaultReact = {
|
|
223
|
+
include: /\.[tj]sx?$/,
|
|
224
|
+
exclude: /node_modules/,
|
|
225
|
+
jsxImportSource: "react",
|
|
226
|
+
jsxRuntime: "automatic",
|
|
227
|
+
compiler: false
|
|
228
|
+
};
|
|
213
229
|
defaults = {
|
|
214
230
|
root: ".",
|
|
215
231
|
base: "/",
|
|
216
232
|
mode: "development",
|
|
217
233
|
target: "web",
|
|
218
234
|
framework: "auto",
|
|
235
|
+
react: defaultReact,
|
|
219
236
|
resolve: defaultResolve,
|
|
220
237
|
server: defaultServer,
|
|
221
238
|
build: defaultBuild,
|
|
@@ -437,6 +454,13 @@ async function resolveConfig(inlineConfig = {}, command) {
|
|
|
437
454
|
mode,
|
|
438
455
|
target: merged.target ?? defaults.target,
|
|
439
456
|
framework: (merged.framework ?? defaults.framework) === "auto" ? detectFramework(root) : merged.framework,
|
|
457
|
+
react: {
|
|
458
|
+
include: merged.react?.include ?? defaultReact.include,
|
|
459
|
+
exclude: merged.react?.exclude ?? defaultReact.exclude,
|
|
460
|
+
jsxImportSource: merged.react?.jsxImportSource ?? defaultReact.jsxImportSource,
|
|
461
|
+
jsxRuntime: merged.react?.jsxRuntime ?? defaultReact.jsxRuntime,
|
|
462
|
+
compiler: merged.react?.compiler === true ? {} : merged.react?.compiler ?? defaultReact.compiler
|
|
463
|
+
},
|
|
440
464
|
command,
|
|
441
465
|
resolve: {
|
|
442
466
|
// tsconfig paths 优先级最低:tsconfig < defaults < user config
|
|
@@ -1354,7 +1378,81 @@ ${msg}`);
|
|
|
1354
1378
|
map: result.map ? JSON.stringify(result.map) : null
|
|
1355
1379
|
};
|
|
1356
1380
|
}
|
|
1357
|
-
|
|
1381
|
+
async function transformReactCode(filename, code, options) {
|
|
1382
|
+
if (!matchesReactFilter(filename, options.react.include, options.react.exclude)) {
|
|
1383
|
+
return null;
|
|
1384
|
+
}
|
|
1385
|
+
if (!options.react.compiler) {
|
|
1386
|
+
if (!shouldTransform(filename)) return null;
|
|
1387
|
+
return transformCode(filename, code, {
|
|
1388
|
+
sourcemap: options.sourcemap,
|
|
1389
|
+
jsxRuntime: options.react.jsxRuntime,
|
|
1390
|
+
jsxImportSource: options.react.jsxImportSource,
|
|
1391
|
+
reactRefresh: options.reactRefresh,
|
|
1392
|
+
target: options.target
|
|
1393
|
+
});
|
|
1394
|
+
}
|
|
1395
|
+
if (!shouldTransform(filename)) return null;
|
|
1396
|
+
const compiler2 = await loadReactCompiler();
|
|
1397
|
+
const compilerOptions = options.react.compiler;
|
|
1398
|
+
const shouldCompile = options.consumer === "client" && (compilerOptions.compilationMode === "annotation" ? /['"]use memo['"]/.test(code) : defaultReactCompilerCodeFilter.test(code));
|
|
1399
|
+
const result = await compiler2.transform(cleanTransformId(filename), code, {
|
|
1400
|
+
jsx: {
|
|
1401
|
+
runtime: options.react.jsxRuntime,
|
|
1402
|
+
development: options.development,
|
|
1403
|
+
importSource: options.react.jsxImportSource,
|
|
1404
|
+
refresh: options.consumer === "client" && !!options.reactRefresh
|
|
1405
|
+
},
|
|
1406
|
+
reactCompiler: shouldCompile ? compilerOptions : false,
|
|
1407
|
+
sourcemap: options.sourcemap ?? true
|
|
1408
|
+
});
|
|
1409
|
+
const diagnostics = result.errors.map(
|
|
1410
|
+
(error) => `${error.message}${error.codeframe ? `
|
|
1411
|
+
${error.codeframe}` : ""}`
|
|
1412
|
+
);
|
|
1413
|
+
if (result.fatal) {
|
|
1414
|
+
throw new Error(
|
|
1415
|
+
diagnostics.join("\n\n") || `React Compiler transform failed for ${filename}`
|
|
1416
|
+
);
|
|
1417
|
+
}
|
|
1418
|
+
for (const diagnostic of diagnostics) options.onWarning?.(diagnostic);
|
|
1419
|
+
return {
|
|
1420
|
+
code: result.code,
|
|
1421
|
+
map: result.map ? JSON.stringify(result.map) : null
|
|
1422
|
+
};
|
|
1423
|
+
}
|
|
1424
|
+
function matchesReactFilter(id, include, exclude) {
|
|
1425
|
+
const cleanId = cleanTransformId(id);
|
|
1426
|
+
return matchesFilter(cleanId, include) && !matchesFilter(cleanId, exclude);
|
|
1427
|
+
}
|
|
1428
|
+
function matchesFilter(id, filter2) {
|
|
1429
|
+
const patterns = Array.isArray(filter2) ? filter2 : [filter2];
|
|
1430
|
+
return patterns.some((pattern) => {
|
|
1431
|
+
if (pattern instanceof RegExp) {
|
|
1432
|
+
pattern.lastIndex = 0;
|
|
1433
|
+
return pattern.test(id);
|
|
1434
|
+
}
|
|
1435
|
+
if (!pattern.includes("*")) return id.includes(pattern);
|
|
1436
|
+
const expression = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, "\0").replace(/\*/g, "[^/]*").replace(/\0/g, ".*");
|
|
1437
|
+
return new RegExp(`^${expression}$`).test(id);
|
|
1438
|
+
});
|
|
1439
|
+
}
|
|
1440
|
+
function cleanTransformId(id) {
|
|
1441
|
+
return id.split(/[?#]/, 1)[0];
|
|
1442
|
+
}
|
|
1443
|
+
async function loadReactCompiler() {
|
|
1444
|
+
if (reactCompilerImplementation) return reactCompilerImplementation;
|
|
1445
|
+
try {
|
|
1446
|
+
reactCompilerImplementation = await import("oxc-transform-react");
|
|
1447
|
+
return reactCompilerImplementation;
|
|
1448
|
+
} catch (error) {
|
|
1449
|
+
throw new Error(
|
|
1450
|
+
'[nasti] React Compiler requires the optional "oxc-transform-react" package. Install it before setting react.compiler.' + (error instanceof Error ? `
|
|
1451
|
+
${error.message}` : "")
|
|
1452
|
+
);
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
var import_oxc_transform, JS_EXTENSIONS, TS_EXTENSIONS, JSX_EXTENSIONS, defaultReactCompilerCodeFilter, reactCompilerImplementation;
|
|
1358
1456
|
var init_transformer = __esm({
|
|
1359
1457
|
"src/core/transformer.ts"() {
|
|
1360
1458
|
"use strict";
|
|
@@ -1362,6 +1460,7 @@ var init_transformer = __esm({
|
|
|
1362
1460
|
JS_EXTENSIONS = /\.(js|mjs|cjs)$/;
|
|
1363
1461
|
TS_EXTENSIONS = /\.(ts|mts|cts)$/;
|
|
1364
1462
|
JSX_EXTENSIONS = /\.(jsx|tsx)$/;
|
|
1463
|
+
defaultReactCompilerCodeFilter = /forwardRef|memo|\b(?:[A-Z]|use[A-Z0-9])/;
|
|
1365
1464
|
}
|
|
1366
1465
|
});
|
|
1367
1466
|
|
|
@@ -1993,22 +2092,35 @@ async function transformRequest(url, ctx) {
|
|
|
1993
2092
|
}
|
|
1994
2093
|
const stableUrl = cleanReqUrl;
|
|
1995
2094
|
let wrappedWithRefresh = false;
|
|
1996
|
-
if (
|
|
1997
|
-
const
|
|
1998
|
-
const useRefresh =
|
|
2095
|
+
if (config.framework === "react") {
|
|
2096
|
+
const refreshEnabled = (ctx.environment?.consumer ?? "client") === "client" && config.server.hmr !== false;
|
|
2097
|
+
const useRefresh = refreshEnabled && (!!config.react.compiler || /\.[jt]sx$/.test(filePath));
|
|
2098
|
+
const result = await transformReactCode(filePath, code, {
|
|
2099
|
+
react: config.react,
|
|
2100
|
+
consumer: ctx.environment?.consumer ?? "client",
|
|
2101
|
+
development: true,
|
|
2102
|
+
reactRefresh: useRefresh,
|
|
2103
|
+
sourcemap: true,
|
|
2104
|
+
target: ctx.environment?.options.build.target ?? config.build.target,
|
|
2105
|
+
onWarning: (message) => config.logger.warn(`[nasti:react] ${message}`)
|
|
2106
|
+
});
|
|
2107
|
+
if (result) {
|
|
2108
|
+
code = result.code;
|
|
2109
|
+
if (result.map) map = JSON.parse(result.map);
|
|
2110
|
+
if (useRefresh) {
|
|
2111
|
+
code = buildReactRefreshWrapper(stableUrl, code);
|
|
2112
|
+
wrappedWithRefresh = true;
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
} else if (shouldTransform(filePath)) {
|
|
1999
2116
|
const result = transformCode(filePath, code, {
|
|
2000
2117
|
sourcemap: true,
|
|
2001
2118
|
jsxRuntime: "automatic",
|
|
2002
|
-
jsxImportSource:
|
|
2003
|
-
reactRefresh: useRefresh,
|
|
2119
|
+
jsxImportSource: "vue",
|
|
2004
2120
|
target: ctx.environment?.options.build.target ?? config.build.target
|
|
2005
2121
|
});
|
|
2006
2122
|
code = result.code;
|
|
2007
2123
|
if (result.map) map = JSON.parse(result.map);
|
|
2008
|
-
if (useRefresh) {
|
|
2009
|
-
code = buildReactRefreshWrapper(stableUrl, code);
|
|
2010
|
-
wrappedWithRefresh = true;
|
|
2011
|
-
}
|
|
2012
2124
|
}
|
|
2013
2125
|
const hotInfo = rewriteHotAcceptDeps(code, config, filePath);
|
|
2014
2126
|
code = hotInfo.code;
|
|
@@ -2219,8 +2331,8 @@ function rewriteExternalRequires(code, baseDir, root) {
|
|
|
2219
2331
|
}
|
|
2220
2332
|
async function injectCjsNamedExports(code, entryFile) {
|
|
2221
2333
|
try {
|
|
2222
|
-
const { createRequire:
|
|
2223
|
-
const req =
|
|
2334
|
+
const { createRequire: createRequire6 } = await import("module");
|
|
2335
|
+
const req = createRequire6(entryFile);
|
|
2224
2336
|
const cjsExports = req(entryFile);
|
|
2225
2337
|
if (!cjsExports || typeof cjsExports !== "object" && typeof cjsExports !== "function" || Array.isArray(cjsExports)) return code;
|
|
2226
2338
|
const namedKeys = Object.keys(cjsExports).filter(
|
|
@@ -3220,27 +3332,27 @@ var require_process = __commonJS({
|
|
|
3220
3332
|
var require_filesystem = __commonJS({
|
|
3221
3333
|
"node_modules/detect-libc/lib/filesystem.js"(exports2, module2) {
|
|
3222
3334
|
"use strict";
|
|
3223
|
-
var
|
|
3335
|
+
var fs15 = require("fs");
|
|
3224
3336
|
var LDD_PATH = "/usr/bin/ldd";
|
|
3225
3337
|
var SELF_PATH = "/proc/self/exe";
|
|
3226
3338
|
var MAX_LENGTH = 2048;
|
|
3227
|
-
var readFileSync = (
|
|
3228
|
-
const fd =
|
|
3339
|
+
var readFileSync = (path21) => {
|
|
3340
|
+
const fd = fs15.openSync(path21, "r");
|
|
3229
3341
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
3230
|
-
const bytesRead =
|
|
3231
|
-
|
|
3342
|
+
const bytesRead = fs15.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
3343
|
+
fs15.close(fd, () => {
|
|
3232
3344
|
});
|
|
3233
3345
|
return buffer.subarray(0, bytesRead);
|
|
3234
3346
|
};
|
|
3235
|
-
var readFile = (
|
|
3236
|
-
|
|
3347
|
+
var readFile = (path21) => new Promise((resolve, reject) => {
|
|
3348
|
+
fs15.open(path21, "r", (err, fd) => {
|
|
3237
3349
|
if (err) {
|
|
3238
3350
|
reject(err);
|
|
3239
3351
|
} else {
|
|
3240
3352
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
3241
|
-
|
|
3353
|
+
fs15.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
|
|
3242
3354
|
resolve(buffer.subarray(0, bytesRead));
|
|
3243
|
-
|
|
3355
|
+
fs15.close(fd, () => {
|
|
3244
3356
|
});
|
|
3245
3357
|
});
|
|
3246
3358
|
}
|
|
@@ -3352,11 +3464,11 @@ var require_detect_libc = __commonJS({
|
|
|
3352
3464
|
}
|
|
3353
3465
|
return null;
|
|
3354
3466
|
};
|
|
3355
|
-
var familyFromInterpreterPath = (
|
|
3356
|
-
if (
|
|
3357
|
-
if (
|
|
3467
|
+
var familyFromInterpreterPath = (path21) => {
|
|
3468
|
+
if (path21) {
|
|
3469
|
+
if (path21.includes("/ld-musl-")) {
|
|
3358
3470
|
return MUSL;
|
|
3359
|
-
} else if (
|
|
3471
|
+
} else if (path21.includes("/ld-linux-")) {
|
|
3360
3472
|
return GLIBC;
|
|
3361
3473
|
}
|
|
3362
3474
|
}
|
|
@@ -3403,8 +3515,8 @@ var require_detect_libc = __commonJS({
|
|
|
3403
3515
|
cachedFamilyInterpreter = null;
|
|
3404
3516
|
try {
|
|
3405
3517
|
const selfContent = await readFile(SELF_PATH);
|
|
3406
|
-
const
|
|
3407
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
3518
|
+
const path21 = interpreterPath(selfContent);
|
|
3519
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path21);
|
|
3408
3520
|
} catch (e) {
|
|
3409
3521
|
}
|
|
3410
3522
|
return cachedFamilyInterpreter;
|
|
@@ -3416,8 +3528,8 @@ var require_detect_libc = __commonJS({
|
|
|
3416
3528
|
cachedFamilyInterpreter = null;
|
|
3417
3529
|
try {
|
|
3418
3530
|
const selfContent = readFileSync(SELF_PATH);
|
|
3419
|
-
const
|
|
3420
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
3531
|
+
const path21 = interpreterPath(selfContent);
|
|
3532
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path21);
|
|
3421
3533
|
} catch (e) {
|
|
3422
3534
|
}
|
|
3423
3535
|
return cachedFamilyInterpreter;
|
|
@@ -4439,8 +4551,8 @@ function vuePlugin(config, environmentName = "client") {
|
|
|
4439
4551
|
let cached2 = descriptorCache.get(filePath);
|
|
4440
4552
|
if (!cached2) {
|
|
4441
4553
|
try {
|
|
4442
|
-
const
|
|
4443
|
-
const rawSource =
|
|
4554
|
+
const fs15 = await import("fs");
|
|
4555
|
+
const rawSource = fs15.readFileSync(filePath, "utf-8");
|
|
4444
4556
|
const transformedSfc = await applySourceTransform(
|
|
4445
4557
|
vueOptions.transformSfc,
|
|
4446
4558
|
rawSource,
|
|
@@ -4864,6 +4976,1310 @@ var init_builtins = __esm({
|
|
|
4864
4976
|
}
|
|
4865
4977
|
});
|
|
4866
4978
|
|
|
4979
|
+
// node_modules/import-meta-resolve/lib/errors.js
|
|
4980
|
+
function formatList(array, type = "and") {
|
|
4981
|
+
return array.length < 3 ? array.join(` ${type} `) : `${array.slice(0, -1).join(", ")}, ${type} ${array[array.length - 1]}`;
|
|
4982
|
+
}
|
|
4983
|
+
function createError(sym, value, constructor) {
|
|
4984
|
+
messages.set(sym, value);
|
|
4985
|
+
return makeNodeErrorWithCode(constructor, sym);
|
|
4986
|
+
}
|
|
4987
|
+
function makeNodeErrorWithCode(Base, key) {
|
|
4988
|
+
return NodeError;
|
|
4989
|
+
function NodeError(...parameters) {
|
|
4990
|
+
const limit = Error.stackTraceLimit;
|
|
4991
|
+
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
|
|
4992
|
+
const error = new Base();
|
|
4993
|
+
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
|
|
4994
|
+
const message = getMessage(key, parameters, error);
|
|
4995
|
+
Object.defineProperties(error, {
|
|
4996
|
+
// Note: no need to implement `kIsNodeError` symbol, would be hard,
|
|
4997
|
+
// probably.
|
|
4998
|
+
message: {
|
|
4999
|
+
value: message,
|
|
5000
|
+
enumerable: false,
|
|
5001
|
+
writable: true,
|
|
5002
|
+
configurable: true
|
|
5003
|
+
},
|
|
5004
|
+
toString: {
|
|
5005
|
+
/** @this {Error} */
|
|
5006
|
+
value() {
|
|
5007
|
+
return `${this.name} [${key}]: ${this.message}`;
|
|
5008
|
+
},
|
|
5009
|
+
enumerable: false,
|
|
5010
|
+
writable: true,
|
|
5011
|
+
configurable: true
|
|
5012
|
+
}
|
|
5013
|
+
});
|
|
5014
|
+
captureLargerStackTrace(error);
|
|
5015
|
+
error.code = key;
|
|
5016
|
+
return error;
|
|
5017
|
+
}
|
|
5018
|
+
}
|
|
5019
|
+
function isErrorStackTraceLimitWritable() {
|
|
5020
|
+
try {
|
|
5021
|
+
if (import_node_v8.default.startupSnapshot.isBuildingSnapshot()) {
|
|
5022
|
+
return false;
|
|
5023
|
+
}
|
|
5024
|
+
} catch {
|
|
5025
|
+
}
|
|
5026
|
+
const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
|
|
5027
|
+
if (desc === void 0) {
|
|
5028
|
+
return Object.isExtensible(Error);
|
|
5029
|
+
}
|
|
5030
|
+
return own.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
|
|
5031
|
+
}
|
|
5032
|
+
function hideStackFrames(wrappedFunction) {
|
|
5033
|
+
const hidden = nodeInternalPrefix + wrappedFunction.name;
|
|
5034
|
+
Object.defineProperty(wrappedFunction, "name", { value: hidden });
|
|
5035
|
+
return wrappedFunction;
|
|
5036
|
+
}
|
|
5037
|
+
function getMessage(key, parameters, self) {
|
|
5038
|
+
const message = messages.get(key);
|
|
5039
|
+
import_node_assert.default.ok(message !== void 0, "expected `message` to be found");
|
|
5040
|
+
if (typeof message === "function") {
|
|
5041
|
+
import_node_assert.default.ok(
|
|
5042
|
+
message.length <= parameters.length,
|
|
5043
|
+
// Default options do not count.
|
|
5044
|
+
`Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`
|
|
5045
|
+
);
|
|
5046
|
+
return Reflect.apply(message, self, parameters);
|
|
5047
|
+
}
|
|
5048
|
+
const regex = /%[dfijoOs]/g;
|
|
5049
|
+
let expectedLength = 0;
|
|
5050
|
+
while (regex.exec(message) !== null) expectedLength++;
|
|
5051
|
+
import_node_assert.default.ok(
|
|
5052
|
+
expectedLength === parameters.length,
|
|
5053
|
+
`Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`
|
|
5054
|
+
);
|
|
5055
|
+
if (parameters.length === 0) return message;
|
|
5056
|
+
parameters.unshift(message);
|
|
5057
|
+
return Reflect.apply(import_node_util.format, null, parameters);
|
|
5058
|
+
}
|
|
5059
|
+
function determineSpecificType(value) {
|
|
5060
|
+
if (value === null || value === void 0) {
|
|
5061
|
+
return String(value);
|
|
5062
|
+
}
|
|
5063
|
+
if (typeof value === "function" && value.name) {
|
|
5064
|
+
return `function ${value.name}`;
|
|
5065
|
+
}
|
|
5066
|
+
if (typeof value === "object") {
|
|
5067
|
+
if (value.constructor && value.constructor.name) {
|
|
5068
|
+
return `an instance of ${value.constructor.name}`;
|
|
5069
|
+
}
|
|
5070
|
+
return `${(0, import_node_util.inspect)(value, { depth: -1 })}`;
|
|
5071
|
+
}
|
|
5072
|
+
let inspected = (0, import_node_util.inspect)(value, { colors: false });
|
|
5073
|
+
if (inspected.length > 28) {
|
|
5074
|
+
inspected = `${inspected.slice(0, 25)}...`;
|
|
5075
|
+
}
|
|
5076
|
+
return `type ${typeof value} (${inspected})`;
|
|
5077
|
+
}
|
|
5078
|
+
var import_node_v8, import_node_assert, import_node_util, own, classRegExp, kTypes, codes, messages, nodeInternalPrefix, userStackTraceLimit, captureLargerStackTrace;
|
|
5079
|
+
var init_errors = __esm({
|
|
5080
|
+
"node_modules/import-meta-resolve/lib/errors.js"() {
|
|
5081
|
+
"use strict";
|
|
5082
|
+
import_node_v8 = __toESM(require("v8"), 1);
|
|
5083
|
+
import_node_assert = __toESM(require("assert"), 1);
|
|
5084
|
+
import_node_util = require("util");
|
|
5085
|
+
own = {}.hasOwnProperty;
|
|
5086
|
+
classRegExp = /^([A-Z][a-z\d]*)+$/;
|
|
5087
|
+
kTypes = /* @__PURE__ */ new Set([
|
|
5088
|
+
"string",
|
|
5089
|
+
"function",
|
|
5090
|
+
"number",
|
|
5091
|
+
"object",
|
|
5092
|
+
// Accept 'Function' and 'Object' as alternative to the lower cased version.
|
|
5093
|
+
"Function",
|
|
5094
|
+
"Object",
|
|
5095
|
+
"boolean",
|
|
5096
|
+
"bigint",
|
|
5097
|
+
"symbol"
|
|
5098
|
+
]);
|
|
5099
|
+
codes = {};
|
|
5100
|
+
messages = /* @__PURE__ */ new Map();
|
|
5101
|
+
nodeInternalPrefix = "__node_internal_";
|
|
5102
|
+
codes.ERR_INVALID_ARG_TYPE = createError(
|
|
5103
|
+
"ERR_INVALID_ARG_TYPE",
|
|
5104
|
+
/**
|
|
5105
|
+
* @param {string} name
|
|
5106
|
+
* @param {Array<string> | string} expected
|
|
5107
|
+
* @param {unknown} actual
|
|
5108
|
+
*/
|
|
5109
|
+
(name, expected, actual) => {
|
|
5110
|
+
import_node_assert.default.ok(typeof name === "string", "'name' must be a string");
|
|
5111
|
+
if (!Array.isArray(expected)) {
|
|
5112
|
+
expected = [expected];
|
|
5113
|
+
}
|
|
5114
|
+
let message = "The ";
|
|
5115
|
+
if (name.endsWith(" argument")) {
|
|
5116
|
+
message += `${name} `;
|
|
5117
|
+
} else {
|
|
5118
|
+
const type = name.includes(".") ? "property" : "argument";
|
|
5119
|
+
message += `"${name}" ${type} `;
|
|
5120
|
+
}
|
|
5121
|
+
message += "must be ";
|
|
5122
|
+
const types = [];
|
|
5123
|
+
const instances = [];
|
|
5124
|
+
const other = [];
|
|
5125
|
+
for (const value of expected) {
|
|
5126
|
+
import_node_assert.default.ok(
|
|
5127
|
+
typeof value === "string",
|
|
5128
|
+
"All expected entries have to be of type string"
|
|
5129
|
+
);
|
|
5130
|
+
if (kTypes.has(value)) {
|
|
5131
|
+
types.push(value.toLowerCase());
|
|
5132
|
+
} else if (classRegExp.exec(value) === null) {
|
|
5133
|
+
import_node_assert.default.ok(
|
|
5134
|
+
value !== "object",
|
|
5135
|
+
'The value "object" should be written as "Object"'
|
|
5136
|
+
);
|
|
5137
|
+
other.push(value);
|
|
5138
|
+
} else {
|
|
5139
|
+
instances.push(value);
|
|
5140
|
+
}
|
|
5141
|
+
}
|
|
5142
|
+
if (instances.length > 0) {
|
|
5143
|
+
const pos = types.indexOf("object");
|
|
5144
|
+
if (pos !== -1) {
|
|
5145
|
+
types.slice(pos, 1);
|
|
5146
|
+
instances.push("Object");
|
|
5147
|
+
}
|
|
5148
|
+
}
|
|
5149
|
+
if (types.length > 0) {
|
|
5150
|
+
message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(
|
|
5151
|
+
types,
|
|
5152
|
+
"or"
|
|
5153
|
+
)}`;
|
|
5154
|
+
if (instances.length > 0 || other.length > 0) message += " or ";
|
|
5155
|
+
}
|
|
5156
|
+
if (instances.length > 0) {
|
|
5157
|
+
message += `an instance of ${formatList(instances, "or")}`;
|
|
5158
|
+
if (other.length > 0) message += " or ";
|
|
5159
|
+
}
|
|
5160
|
+
if (other.length > 0) {
|
|
5161
|
+
if (other.length > 1) {
|
|
5162
|
+
message += `one of ${formatList(other, "or")}`;
|
|
5163
|
+
} else {
|
|
5164
|
+
if (other[0].toLowerCase() !== other[0]) message += "an ";
|
|
5165
|
+
message += `${other[0]}`;
|
|
5166
|
+
}
|
|
5167
|
+
}
|
|
5168
|
+
message += `. Received ${determineSpecificType(actual)}`;
|
|
5169
|
+
return message;
|
|
5170
|
+
},
|
|
5171
|
+
TypeError
|
|
5172
|
+
);
|
|
5173
|
+
codes.ERR_INVALID_MODULE_SPECIFIER = createError(
|
|
5174
|
+
"ERR_INVALID_MODULE_SPECIFIER",
|
|
5175
|
+
/**
|
|
5176
|
+
* @param {string} request
|
|
5177
|
+
* @param {string} reason
|
|
5178
|
+
* @param {string} [base]
|
|
5179
|
+
*/
|
|
5180
|
+
(request, reason, base = void 0) => {
|
|
5181
|
+
return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
|
|
5182
|
+
},
|
|
5183
|
+
TypeError
|
|
5184
|
+
);
|
|
5185
|
+
codes.ERR_INVALID_PACKAGE_CONFIG = createError(
|
|
5186
|
+
"ERR_INVALID_PACKAGE_CONFIG",
|
|
5187
|
+
/**
|
|
5188
|
+
* @param {string} path
|
|
5189
|
+
* @param {string} [base]
|
|
5190
|
+
* @param {string} [message]
|
|
5191
|
+
*/
|
|
5192
|
+
(path21, base, message) => {
|
|
5193
|
+
return `Invalid package config ${path21}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
|
|
5194
|
+
},
|
|
5195
|
+
Error
|
|
5196
|
+
);
|
|
5197
|
+
codes.ERR_INVALID_PACKAGE_TARGET = createError(
|
|
5198
|
+
"ERR_INVALID_PACKAGE_TARGET",
|
|
5199
|
+
/**
|
|
5200
|
+
* @param {string} packagePath
|
|
5201
|
+
* @param {string} key
|
|
5202
|
+
* @param {unknown} target
|
|
5203
|
+
* @param {boolean} [isImport=false]
|
|
5204
|
+
* @param {string} [base]
|
|
5205
|
+
*/
|
|
5206
|
+
(packagePath, key, target, isImport = false, base = void 0) => {
|
|
5207
|
+
const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
|
|
5208
|
+
if (key === ".") {
|
|
5209
|
+
import_node_assert.default.ok(isImport === false);
|
|
5210
|
+
return `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
|
|
5211
|
+
}
|
|
5212
|
+
return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(
|
|
5213
|
+
target
|
|
5214
|
+
)} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
|
|
5215
|
+
},
|
|
5216
|
+
Error
|
|
5217
|
+
);
|
|
5218
|
+
codes.ERR_MODULE_NOT_FOUND = createError(
|
|
5219
|
+
"ERR_MODULE_NOT_FOUND",
|
|
5220
|
+
/**
|
|
5221
|
+
* @param {string} path
|
|
5222
|
+
* @param {string} base
|
|
5223
|
+
* @param {boolean} [exactUrl]
|
|
5224
|
+
*/
|
|
5225
|
+
(path21, base, exactUrl = false) => {
|
|
5226
|
+
return `Cannot find ${exactUrl ? "module" : "package"} '${path21}' imported from ${base}`;
|
|
5227
|
+
},
|
|
5228
|
+
Error
|
|
5229
|
+
);
|
|
5230
|
+
codes.ERR_NETWORK_IMPORT_DISALLOWED = createError(
|
|
5231
|
+
"ERR_NETWORK_IMPORT_DISALLOWED",
|
|
5232
|
+
"import of '%s' by %s is not supported: %s",
|
|
5233
|
+
Error
|
|
5234
|
+
);
|
|
5235
|
+
codes.ERR_PACKAGE_IMPORT_NOT_DEFINED = createError(
|
|
5236
|
+
"ERR_PACKAGE_IMPORT_NOT_DEFINED",
|
|
5237
|
+
/**
|
|
5238
|
+
* @param {string} specifier
|
|
5239
|
+
* @param {string} packagePath
|
|
5240
|
+
* @param {string} base
|
|
5241
|
+
*/
|
|
5242
|
+
(specifier, packagePath, base) => {
|
|
5243
|
+
return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ""} imported from ${base}`;
|
|
5244
|
+
},
|
|
5245
|
+
TypeError
|
|
5246
|
+
);
|
|
5247
|
+
codes.ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
|
|
5248
|
+
"ERR_PACKAGE_PATH_NOT_EXPORTED",
|
|
5249
|
+
/**
|
|
5250
|
+
* @param {string} packagePath
|
|
5251
|
+
* @param {string} subpath
|
|
5252
|
+
* @param {string} [base]
|
|
5253
|
+
*/
|
|
5254
|
+
(packagePath, subpath, base = void 0) => {
|
|
5255
|
+
if (subpath === ".")
|
|
5256
|
+
return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
5257
|
+
return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
5258
|
+
},
|
|
5259
|
+
Error
|
|
5260
|
+
);
|
|
5261
|
+
codes.ERR_UNSUPPORTED_DIR_IMPORT = createError(
|
|
5262
|
+
"ERR_UNSUPPORTED_DIR_IMPORT",
|
|
5263
|
+
"Directory import '%s' is not supported resolving ES modules imported from %s",
|
|
5264
|
+
Error
|
|
5265
|
+
);
|
|
5266
|
+
codes.ERR_UNSUPPORTED_RESOLVE_REQUEST = createError(
|
|
5267
|
+
"ERR_UNSUPPORTED_RESOLVE_REQUEST",
|
|
5268
|
+
'Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.',
|
|
5269
|
+
TypeError
|
|
5270
|
+
);
|
|
5271
|
+
codes.ERR_UNKNOWN_FILE_EXTENSION = createError(
|
|
5272
|
+
"ERR_UNKNOWN_FILE_EXTENSION",
|
|
5273
|
+
/**
|
|
5274
|
+
* @param {string} extension
|
|
5275
|
+
* @param {string} path
|
|
5276
|
+
*/
|
|
5277
|
+
(extension, path21) => {
|
|
5278
|
+
return `Unknown file extension "${extension}" for ${path21}`;
|
|
5279
|
+
},
|
|
5280
|
+
TypeError
|
|
5281
|
+
);
|
|
5282
|
+
codes.ERR_INVALID_ARG_VALUE = createError(
|
|
5283
|
+
"ERR_INVALID_ARG_VALUE",
|
|
5284
|
+
/**
|
|
5285
|
+
* @param {string} name
|
|
5286
|
+
* @param {unknown} value
|
|
5287
|
+
* @param {string} [reason='is invalid']
|
|
5288
|
+
*/
|
|
5289
|
+
(name, value, reason = "is invalid") => {
|
|
5290
|
+
let inspected = (0, import_node_util.inspect)(value);
|
|
5291
|
+
if (inspected.length > 128) {
|
|
5292
|
+
inspected = `${inspected.slice(0, 128)}...`;
|
|
5293
|
+
}
|
|
5294
|
+
const type = name.includes(".") ? "property" : "argument";
|
|
5295
|
+
return `The ${type} '${name}' ${reason}. Received ${inspected}`;
|
|
5296
|
+
},
|
|
5297
|
+
TypeError
|
|
5298
|
+
// Note: extra classes have been shaken out.
|
|
5299
|
+
// , RangeError
|
|
5300
|
+
);
|
|
5301
|
+
captureLargerStackTrace = hideStackFrames(
|
|
5302
|
+
/**
|
|
5303
|
+
* @param {Error} error
|
|
5304
|
+
* @returns {Error}
|
|
5305
|
+
*/
|
|
5306
|
+
// @ts-expect-error: fine
|
|
5307
|
+
function(error) {
|
|
5308
|
+
const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
|
|
5309
|
+
if (stackTraceLimitIsWritable) {
|
|
5310
|
+
userStackTraceLimit = Error.stackTraceLimit;
|
|
5311
|
+
Error.stackTraceLimit = Number.POSITIVE_INFINITY;
|
|
5312
|
+
}
|
|
5313
|
+
Error.captureStackTrace(error);
|
|
5314
|
+
if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
|
|
5315
|
+
return error;
|
|
5316
|
+
}
|
|
5317
|
+
);
|
|
5318
|
+
}
|
|
5319
|
+
});
|
|
5320
|
+
|
|
5321
|
+
// node_modules/import-meta-resolve/lib/package-json-reader.js
|
|
5322
|
+
function read(jsonPath, { base, specifier }) {
|
|
5323
|
+
const existing = cache.get(jsonPath);
|
|
5324
|
+
if (existing) {
|
|
5325
|
+
return existing;
|
|
5326
|
+
}
|
|
5327
|
+
let string;
|
|
5328
|
+
try {
|
|
5329
|
+
string = import_node_fs9.default.readFileSync(import_node_path11.default.toNamespacedPath(jsonPath), "utf8");
|
|
5330
|
+
} catch (error) {
|
|
5331
|
+
const exception = (
|
|
5332
|
+
/** @type {ErrnoException} */
|
|
5333
|
+
error
|
|
5334
|
+
);
|
|
5335
|
+
if (exception.code !== "ENOENT") {
|
|
5336
|
+
throw exception;
|
|
5337
|
+
}
|
|
5338
|
+
}
|
|
5339
|
+
const result = {
|
|
5340
|
+
exists: false,
|
|
5341
|
+
pjsonPath: jsonPath,
|
|
5342
|
+
main: void 0,
|
|
5343
|
+
name: void 0,
|
|
5344
|
+
type: "none",
|
|
5345
|
+
// Ignore unknown types for forwards compatibility
|
|
5346
|
+
exports: void 0,
|
|
5347
|
+
imports: void 0
|
|
5348
|
+
};
|
|
5349
|
+
if (string !== void 0) {
|
|
5350
|
+
let parsed;
|
|
5351
|
+
try {
|
|
5352
|
+
parsed = JSON.parse(string);
|
|
5353
|
+
} catch (error_) {
|
|
5354
|
+
const cause = (
|
|
5355
|
+
/** @type {ErrnoException} */
|
|
5356
|
+
error_
|
|
5357
|
+
);
|
|
5358
|
+
const error = new ERR_INVALID_PACKAGE_CONFIG(
|
|
5359
|
+
jsonPath,
|
|
5360
|
+
(base ? `"${specifier}" from ` : "") + (0, import_node_url4.fileURLToPath)(base || specifier),
|
|
5361
|
+
cause.message
|
|
5362
|
+
);
|
|
5363
|
+
error.cause = cause;
|
|
5364
|
+
throw error;
|
|
5365
|
+
}
|
|
5366
|
+
result.exists = true;
|
|
5367
|
+
if (hasOwnProperty.call(parsed, "name") && typeof parsed.name === "string") {
|
|
5368
|
+
result.name = parsed.name;
|
|
5369
|
+
}
|
|
5370
|
+
if (hasOwnProperty.call(parsed, "main") && typeof parsed.main === "string") {
|
|
5371
|
+
result.main = parsed.main;
|
|
5372
|
+
}
|
|
5373
|
+
if (hasOwnProperty.call(parsed, "exports")) {
|
|
5374
|
+
result.exports = parsed.exports;
|
|
5375
|
+
}
|
|
5376
|
+
if (hasOwnProperty.call(parsed, "imports")) {
|
|
5377
|
+
result.imports = parsed.imports;
|
|
5378
|
+
}
|
|
5379
|
+
if (hasOwnProperty.call(parsed, "type") && (parsed.type === "commonjs" || parsed.type === "module")) {
|
|
5380
|
+
result.type = parsed.type;
|
|
5381
|
+
}
|
|
5382
|
+
}
|
|
5383
|
+
cache.set(jsonPath, result);
|
|
5384
|
+
return result;
|
|
5385
|
+
}
|
|
5386
|
+
function getPackageScopeConfig(resolved) {
|
|
5387
|
+
let packageJSONUrl = new URL("package.json", resolved);
|
|
5388
|
+
while (true) {
|
|
5389
|
+
const packageJSONPath2 = packageJSONUrl.pathname;
|
|
5390
|
+
if (packageJSONPath2.endsWith("node_modules/package.json")) {
|
|
5391
|
+
break;
|
|
5392
|
+
}
|
|
5393
|
+
const packageConfig = read((0, import_node_url4.fileURLToPath)(packageJSONUrl), {
|
|
5394
|
+
specifier: resolved
|
|
5395
|
+
});
|
|
5396
|
+
if (packageConfig.exists) {
|
|
5397
|
+
return packageConfig;
|
|
5398
|
+
}
|
|
5399
|
+
const lastPackageJSONUrl = packageJSONUrl;
|
|
5400
|
+
packageJSONUrl = new URL("../package.json", packageJSONUrl);
|
|
5401
|
+
if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) {
|
|
5402
|
+
break;
|
|
5403
|
+
}
|
|
5404
|
+
}
|
|
5405
|
+
const packageJSONPath = (0, import_node_url4.fileURLToPath)(packageJSONUrl);
|
|
5406
|
+
return {
|
|
5407
|
+
pjsonPath: packageJSONPath,
|
|
5408
|
+
exists: false,
|
|
5409
|
+
type: "none"
|
|
5410
|
+
};
|
|
5411
|
+
}
|
|
5412
|
+
function getPackageType(url) {
|
|
5413
|
+
return getPackageScopeConfig(url).type;
|
|
5414
|
+
}
|
|
5415
|
+
var import_node_fs9, import_node_path11, import_node_url4, hasOwnProperty, ERR_INVALID_PACKAGE_CONFIG, cache;
|
|
5416
|
+
var init_package_json_reader = __esm({
|
|
5417
|
+
"node_modules/import-meta-resolve/lib/package-json-reader.js"() {
|
|
5418
|
+
"use strict";
|
|
5419
|
+
import_node_fs9 = __toESM(require("fs"), 1);
|
|
5420
|
+
import_node_path11 = __toESM(require("path"), 1);
|
|
5421
|
+
import_node_url4 = require("url");
|
|
5422
|
+
init_errors();
|
|
5423
|
+
hasOwnProperty = {}.hasOwnProperty;
|
|
5424
|
+
({ ERR_INVALID_PACKAGE_CONFIG } = codes);
|
|
5425
|
+
cache = /* @__PURE__ */ new Map();
|
|
5426
|
+
}
|
|
5427
|
+
});
|
|
5428
|
+
|
|
5429
|
+
// node_modules/import-meta-resolve/lib/get-format.js
|
|
5430
|
+
function mimeToFormat(mime) {
|
|
5431
|
+
if (mime && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime))
|
|
5432
|
+
return "module";
|
|
5433
|
+
if (mime === "application/json") return "json";
|
|
5434
|
+
return null;
|
|
5435
|
+
}
|
|
5436
|
+
function getDataProtocolModuleFormat(parsed) {
|
|
5437
|
+
const { 1: mime } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(
|
|
5438
|
+
parsed.pathname
|
|
5439
|
+
) || [null, null, null];
|
|
5440
|
+
return mimeToFormat(mime);
|
|
5441
|
+
}
|
|
5442
|
+
function extname(url) {
|
|
5443
|
+
const pathname = url.pathname;
|
|
5444
|
+
let index2 = pathname.length;
|
|
5445
|
+
while (index2--) {
|
|
5446
|
+
const code = pathname.codePointAt(index2);
|
|
5447
|
+
if (code === 47) {
|
|
5448
|
+
return "";
|
|
5449
|
+
}
|
|
5450
|
+
if (code === 46) {
|
|
5451
|
+
return pathname.codePointAt(index2 - 1) === 47 ? "" : pathname.slice(index2);
|
|
5452
|
+
}
|
|
5453
|
+
}
|
|
5454
|
+
return "";
|
|
5455
|
+
}
|
|
5456
|
+
function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
|
|
5457
|
+
const value = extname(url);
|
|
5458
|
+
if (value === ".js") {
|
|
5459
|
+
const packageType = getPackageType(url);
|
|
5460
|
+
if (packageType !== "none") {
|
|
5461
|
+
return packageType;
|
|
5462
|
+
}
|
|
5463
|
+
return "commonjs";
|
|
5464
|
+
}
|
|
5465
|
+
if (value === "") {
|
|
5466
|
+
const packageType = getPackageType(url);
|
|
5467
|
+
if (packageType === "none" || packageType === "commonjs") {
|
|
5468
|
+
return "commonjs";
|
|
5469
|
+
}
|
|
5470
|
+
return "module";
|
|
5471
|
+
}
|
|
5472
|
+
const format2 = extensionFormatMap[value];
|
|
5473
|
+
if (format2) return format2;
|
|
5474
|
+
if (ignoreErrors) {
|
|
5475
|
+
return void 0;
|
|
5476
|
+
}
|
|
5477
|
+
const filepath = (0, import_node_url5.fileURLToPath)(url);
|
|
5478
|
+
throw new ERR_UNKNOWN_FILE_EXTENSION(value, filepath);
|
|
5479
|
+
}
|
|
5480
|
+
function getHttpProtocolModuleFormat() {
|
|
5481
|
+
}
|
|
5482
|
+
function defaultGetFormatWithoutErrors(url, context) {
|
|
5483
|
+
const protocol = url.protocol;
|
|
5484
|
+
if (!hasOwnProperty2.call(protocolHandlers, protocol)) {
|
|
5485
|
+
return null;
|
|
5486
|
+
}
|
|
5487
|
+
return protocolHandlers[protocol](url, context, true) || null;
|
|
5488
|
+
}
|
|
5489
|
+
var import_node_url5, ERR_UNKNOWN_FILE_EXTENSION, hasOwnProperty2, extensionFormatMap, protocolHandlers;
|
|
5490
|
+
var init_get_format = __esm({
|
|
5491
|
+
"node_modules/import-meta-resolve/lib/get-format.js"() {
|
|
5492
|
+
"use strict";
|
|
5493
|
+
import_node_url5 = require("url");
|
|
5494
|
+
init_package_json_reader();
|
|
5495
|
+
init_errors();
|
|
5496
|
+
({ ERR_UNKNOWN_FILE_EXTENSION } = codes);
|
|
5497
|
+
hasOwnProperty2 = {}.hasOwnProperty;
|
|
5498
|
+
extensionFormatMap = {
|
|
5499
|
+
// @ts-expect-error: hush.
|
|
5500
|
+
__proto__: null,
|
|
5501
|
+
".cjs": "commonjs",
|
|
5502
|
+
".js": "module",
|
|
5503
|
+
".json": "json",
|
|
5504
|
+
".mjs": "module"
|
|
5505
|
+
};
|
|
5506
|
+
protocolHandlers = {
|
|
5507
|
+
// @ts-expect-error: hush.
|
|
5508
|
+
__proto__: null,
|
|
5509
|
+
"data:": getDataProtocolModuleFormat,
|
|
5510
|
+
"file:": getFileProtocolModuleFormat,
|
|
5511
|
+
"http:": getHttpProtocolModuleFormat,
|
|
5512
|
+
"https:": getHttpProtocolModuleFormat,
|
|
5513
|
+
"node:"() {
|
|
5514
|
+
return "builtin";
|
|
5515
|
+
}
|
|
5516
|
+
};
|
|
5517
|
+
}
|
|
5518
|
+
});
|
|
5519
|
+
|
|
5520
|
+
// node_modules/import-meta-resolve/lib/utils.js
|
|
5521
|
+
function getDefaultConditions() {
|
|
5522
|
+
return DEFAULT_CONDITIONS;
|
|
5523
|
+
}
|
|
5524
|
+
function getDefaultConditionsSet() {
|
|
5525
|
+
return DEFAULT_CONDITIONS_SET;
|
|
5526
|
+
}
|
|
5527
|
+
function getConditionsSet(conditions) {
|
|
5528
|
+
if (conditions !== void 0 && conditions !== getDefaultConditions()) {
|
|
5529
|
+
if (!Array.isArray(conditions)) {
|
|
5530
|
+
throw new ERR_INVALID_ARG_VALUE(
|
|
5531
|
+
"conditions",
|
|
5532
|
+
conditions,
|
|
5533
|
+
"expected an array"
|
|
5534
|
+
);
|
|
5535
|
+
}
|
|
5536
|
+
return new Set(conditions);
|
|
5537
|
+
}
|
|
5538
|
+
return getDefaultConditionsSet();
|
|
5539
|
+
}
|
|
5540
|
+
var ERR_INVALID_ARG_VALUE, DEFAULT_CONDITIONS, DEFAULT_CONDITIONS_SET;
|
|
5541
|
+
var init_utils = __esm({
|
|
5542
|
+
"node_modules/import-meta-resolve/lib/utils.js"() {
|
|
5543
|
+
"use strict";
|
|
5544
|
+
init_errors();
|
|
5545
|
+
({ ERR_INVALID_ARG_VALUE } = codes);
|
|
5546
|
+
DEFAULT_CONDITIONS = Object.freeze(["node", "import"]);
|
|
5547
|
+
DEFAULT_CONDITIONS_SET = new Set(DEFAULT_CONDITIONS);
|
|
5548
|
+
}
|
|
5549
|
+
});
|
|
5550
|
+
|
|
5551
|
+
// node_modules/import-meta-resolve/lib/resolve.js
|
|
5552
|
+
function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, internal, base, isTarget) {
|
|
5553
|
+
if (import_node_process.default.noDeprecation) {
|
|
5554
|
+
return;
|
|
5555
|
+
}
|
|
5556
|
+
const pjsonPath = (0, import_node_url6.fileURLToPath)(packageJsonUrl);
|
|
5557
|
+
const double = doubleSlashRegEx.exec(isTarget ? target : request) !== null;
|
|
5558
|
+
import_node_process.default.emitWarning(
|
|
5559
|
+
`Use of deprecated ${double ? "double slash" : "leading or trailing slash matching"} resolving "${target}" for module request "${request}" ${request === match ? "" : `matched to "${match}" `}in the "${internal ? "imports" : "exports"}" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${(0, import_node_url6.fileURLToPath)(base)}` : ""}.`,
|
|
5560
|
+
"DeprecationWarning",
|
|
5561
|
+
"DEP0166"
|
|
5562
|
+
);
|
|
5563
|
+
}
|
|
5564
|
+
function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
|
|
5565
|
+
if (import_node_process.default.noDeprecation) {
|
|
5566
|
+
return;
|
|
5567
|
+
}
|
|
5568
|
+
const format2 = defaultGetFormatWithoutErrors(url, { parentURL: base.href });
|
|
5569
|
+
if (format2 !== "module") return;
|
|
5570
|
+
const urlPath = (0, import_node_url6.fileURLToPath)(url.href);
|
|
5571
|
+
const packagePath = (0, import_node_url6.fileURLToPath)(new URL(".", packageJsonUrl));
|
|
5572
|
+
const basePath = (0, import_node_url6.fileURLToPath)(base);
|
|
5573
|
+
if (!main) {
|
|
5574
|
+
import_node_process.default.emitWarning(
|
|
5575
|
+
`No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(
|
|
5576
|
+
packagePath.length
|
|
5577
|
+
)}", imported from ${basePath}.
|
|
5578
|
+
Default "index" lookups for the main are deprecated for ES modules.`,
|
|
5579
|
+
"DeprecationWarning",
|
|
5580
|
+
"DEP0151"
|
|
5581
|
+
);
|
|
5582
|
+
} else if (import_node_path12.default.resolve(packagePath, main) !== urlPath) {
|
|
5583
|
+
import_node_process.default.emitWarning(
|
|
5584
|
+
`Package ${packagePath} has a "main" field set to "${main}", excluding the full filename and extension to the resolved file at "${urlPath.slice(
|
|
5585
|
+
packagePath.length
|
|
5586
|
+
)}", imported from ${basePath}.
|
|
5587
|
+
Automatic extension resolution of the "main" field is deprecated for ES modules.`,
|
|
5588
|
+
"DeprecationWarning",
|
|
5589
|
+
"DEP0151"
|
|
5590
|
+
);
|
|
5591
|
+
}
|
|
5592
|
+
}
|
|
5593
|
+
function tryStatSync(path21) {
|
|
5594
|
+
try {
|
|
5595
|
+
return (0, import_node_fs10.statSync)(path21);
|
|
5596
|
+
} catch {
|
|
5597
|
+
}
|
|
5598
|
+
}
|
|
5599
|
+
function fileExists(url) {
|
|
5600
|
+
const stats = (0, import_node_fs10.statSync)(url, { throwIfNoEntry: false });
|
|
5601
|
+
const isFile = stats ? stats.isFile() : void 0;
|
|
5602
|
+
return isFile === null || isFile === void 0 ? false : isFile;
|
|
5603
|
+
}
|
|
5604
|
+
function legacyMainResolve(packageJsonUrl, packageConfig, base) {
|
|
5605
|
+
let guess;
|
|
5606
|
+
if (packageConfig.main !== void 0) {
|
|
5607
|
+
guess = new URL(packageConfig.main, packageJsonUrl);
|
|
5608
|
+
if (fileExists(guess)) return guess;
|
|
5609
|
+
const tries2 = [
|
|
5610
|
+
`./${packageConfig.main}.js`,
|
|
5611
|
+
`./${packageConfig.main}.json`,
|
|
5612
|
+
`./${packageConfig.main}.node`,
|
|
5613
|
+
`./${packageConfig.main}/index.js`,
|
|
5614
|
+
`./${packageConfig.main}/index.json`,
|
|
5615
|
+
`./${packageConfig.main}/index.node`
|
|
5616
|
+
];
|
|
5617
|
+
let i2 = -1;
|
|
5618
|
+
while (++i2 < tries2.length) {
|
|
5619
|
+
guess = new URL(tries2[i2], packageJsonUrl);
|
|
5620
|
+
if (fileExists(guess)) break;
|
|
5621
|
+
guess = void 0;
|
|
5622
|
+
}
|
|
5623
|
+
if (guess) {
|
|
5624
|
+
emitLegacyIndexDeprecation(
|
|
5625
|
+
guess,
|
|
5626
|
+
packageJsonUrl,
|
|
5627
|
+
base,
|
|
5628
|
+
packageConfig.main
|
|
5629
|
+
);
|
|
5630
|
+
return guess;
|
|
5631
|
+
}
|
|
5632
|
+
}
|
|
5633
|
+
const tries = ["./index.js", "./index.json", "./index.node"];
|
|
5634
|
+
let i = -1;
|
|
5635
|
+
while (++i < tries.length) {
|
|
5636
|
+
guess = new URL(tries[i], packageJsonUrl);
|
|
5637
|
+
if (fileExists(guess)) break;
|
|
5638
|
+
guess = void 0;
|
|
5639
|
+
}
|
|
5640
|
+
if (guess) {
|
|
5641
|
+
emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
|
|
5642
|
+
return guess;
|
|
5643
|
+
}
|
|
5644
|
+
throw new ERR_MODULE_NOT_FOUND(
|
|
5645
|
+
(0, import_node_url6.fileURLToPath)(new URL(".", packageJsonUrl)),
|
|
5646
|
+
(0, import_node_url6.fileURLToPath)(base)
|
|
5647
|
+
);
|
|
5648
|
+
}
|
|
5649
|
+
function finalizeResolution(resolved, base, preserveSymlinks) {
|
|
5650
|
+
if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) {
|
|
5651
|
+
throw new ERR_INVALID_MODULE_SPECIFIER(
|
|
5652
|
+
resolved.pathname,
|
|
5653
|
+
'must not include encoded "/" or "\\" characters',
|
|
5654
|
+
(0, import_node_url6.fileURLToPath)(base)
|
|
5655
|
+
);
|
|
5656
|
+
}
|
|
5657
|
+
let filePath;
|
|
5658
|
+
try {
|
|
5659
|
+
filePath = (0, import_node_url6.fileURLToPath)(resolved);
|
|
5660
|
+
} catch (error) {
|
|
5661
|
+
const cause = (
|
|
5662
|
+
/** @type {ErrnoException} */
|
|
5663
|
+
error
|
|
5664
|
+
);
|
|
5665
|
+
Object.defineProperty(cause, "input", { value: String(resolved) });
|
|
5666
|
+
Object.defineProperty(cause, "module", { value: String(base) });
|
|
5667
|
+
throw cause;
|
|
5668
|
+
}
|
|
5669
|
+
const stats = tryStatSync(
|
|
5670
|
+
filePath.endsWith("/") ? filePath.slice(-1) : filePath
|
|
5671
|
+
);
|
|
5672
|
+
if (stats && stats.isDirectory()) {
|
|
5673
|
+
const error = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, (0, import_node_url6.fileURLToPath)(base));
|
|
5674
|
+
error.url = String(resolved);
|
|
5675
|
+
throw error;
|
|
5676
|
+
}
|
|
5677
|
+
if (!stats || !stats.isFile()) {
|
|
5678
|
+
const error = new ERR_MODULE_NOT_FOUND(
|
|
5679
|
+
filePath || resolved.pathname,
|
|
5680
|
+
base && (0, import_node_url6.fileURLToPath)(base),
|
|
5681
|
+
true
|
|
5682
|
+
);
|
|
5683
|
+
error.url = String(resolved);
|
|
5684
|
+
throw error;
|
|
5685
|
+
}
|
|
5686
|
+
if (!preserveSymlinks) {
|
|
5687
|
+
const real = (0, import_node_fs10.realpathSync)(filePath);
|
|
5688
|
+
const { search, hash } = resolved;
|
|
5689
|
+
resolved = (0, import_node_url6.pathToFileURL)(real + (filePath.endsWith(import_node_path12.default.sep) ? "/" : ""));
|
|
5690
|
+
resolved.search = search;
|
|
5691
|
+
resolved.hash = hash;
|
|
5692
|
+
}
|
|
5693
|
+
return resolved;
|
|
5694
|
+
}
|
|
5695
|
+
function importNotDefined(specifier, packageJsonUrl, base) {
|
|
5696
|
+
return new ERR_PACKAGE_IMPORT_NOT_DEFINED(
|
|
5697
|
+
specifier,
|
|
5698
|
+
packageJsonUrl && (0, import_node_url6.fileURLToPath)(new URL(".", packageJsonUrl)),
|
|
5699
|
+
(0, import_node_url6.fileURLToPath)(base)
|
|
5700
|
+
);
|
|
5701
|
+
}
|
|
5702
|
+
function exportsNotFound(subpath, packageJsonUrl, base) {
|
|
5703
|
+
return new ERR_PACKAGE_PATH_NOT_EXPORTED(
|
|
5704
|
+
(0, import_node_url6.fileURLToPath)(new URL(".", packageJsonUrl)),
|
|
5705
|
+
subpath,
|
|
5706
|
+
base && (0, import_node_url6.fileURLToPath)(base)
|
|
5707
|
+
);
|
|
5708
|
+
}
|
|
5709
|
+
function throwInvalidSubpath(request, match, packageJsonUrl, internal, base) {
|
|
5710
|
+
const reason = `request is not a valid match in pattern "${match}" for the "${internal ? "imports" : "exports"}" resolution of ${(0, import_node_url6.fileURLToPath)(packageJsonUrl)}`;
|
|
5711
|
+
throw new ERR_INVALID_MODULE_SPECIFIER(
|
|
5712
|
+
request,
|
|
5713
|
+
reason,
|
|
5714
|
+
base && (0, import_node_url6.fileURLToPath)(base)
|
|
5715
|
+
);
|
|
5716
|
+
}
|
|
5717
|
+
function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
|
|
5718
|
+
target = typeof target === "object" && target !== null ? JSON.stringify(target, null, "") : `${target}`;
|
|
5719
|
+
return new ERR_INVALID_PACKAGE_TARGET(
|
|
5720
|
+
(0, import_node_url6.fileURLToPath)(new URL(".", packageJsonUrl)),
|
|
5721
|
+
subpath,
|
|
5722
|
+
target,
|
|
5723
|
+
internal,
|
|
5724
|
+
base && (0, import_node_url6.fileURLToPath)(base)
|
|
5725
|
+
);
|
|
5726
|
+
}
|
|
5727
|
+
function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base, pattern, internal, isPathMap, conditions) {
|
|
5728
|
+
if (subpath !== "" && !pattern && target[target.length - 1] !== "/")
|
|
5729
|
+
throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
5730
|
+
if (!target.startsWith("./")) {
|
|
5731
|
+
if (internal && !target.startsWith("../") && !target.startsWith("/")) {
|
|
5732
|
+
let isURL = false;
|
|
5733
|
+
try {
|
|
5734
|
+
new URL(target);
|
|
5735
|
+
isURL = true;
|
|
5736
|
+
} catch {
|
|
5737
|
+
}
|
|
5738
|
+
if (!isURL) {
|
|
5739
|
+
const exportTarget = pattern ? RegExpPrototypeSymbolReplace.call(
|
|
5740
|
+
patternRegEx,
|
|
5741
|
+
target,
|
|
5742
|
+
() => subpath
|
|
5743
|
+
) : target + subpath;
|
|
5744
|
+
return packageResolve(exportTarget, packageJsonUrl, conditions);
|
|
5745
|
+
}
|
|
5746
|
+
}
|
|
5747
|
+
throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
5748
|
+
}
|
|
5749
|
+
if (invalidSegmentRegEx.exec(target.slice(2)) !== null) {
|
|
5750
|
+
if (deprecatedInvalidSegmentRegEx.exec(target.slice(2)) === null) {
|
|
5751
|
+
if (!isPathMap) {
|
|
5752
|
+
const request = pattern ? match.replace("*", () => subpath) : match + subpath;
|
|
5753
|
+
const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(
|
|
5754
|
+
patternRegEx,
|
|
5755
|
+
target,
|
|
5756
|
+
() => subpath
|
|
5757
|
+
) : target;
|
|
5758
|
+
emitInvalidSegmentDeprecation(
|
|
5759
|
+
resolvedTarget,
|
|
5760
|
+
request,
|
|
5761
|
+
match,
|
|
5762
|
+
packageJsonUrl,
|
|
5763
|
+
internal,
|
|
5764
|
+
base,
|
|
5765
|
+
true
|
|
5766
|
+
);
|
|
5767
|
+
}
|
|
5768
|
+
} else {
|
|
5769
|
+
throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
5770
|
+
}
|
|
5771
|
+
}
|
|
5772
|
+
const resolved = new URL(target, packageJsonUrl);
|
|
5773
|
+
const resolvedPath = resolved.pathname;
|
|
5774
|
+
const packagePath = new URL(".", packageJsonUrl).pathname;
|
|
5775
|
+
if (!resolvedPath.startsWith(packagePath))
|
|
5776
|
+
throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
5777
|
+
if (subpath === "") return resolved;
|
|
5778
|
+
if (invalidSegmentRegEx.exec(subpath) !== null) {
|
|
5779
|
+
const request = pattern ? match.replace("*", () => subpath) : match + subpath;
|
|
5780
|
+
if (deprecatedInvalidSegmentRegEx.exec(subpath) === null) {
|
|
5781
|
+
if (!isPathMap) {
|
|
5782
|
+
const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(
|
|
5783
|
+
patternRegEx,
|
|
5784
|
+
target,
|
|
5785
|
+
() => subpath
|
|
5786
|
+
) : target;
|
|
5787
|
+
emitInvalidSegmentDeprecation(
|
|
5788
|
+
resolvedTarget,
|
|
5789
|
+
request,
|
|
5790
|
+
match,
|
|
5791
|
+
packageJsonUrl,
|
|
5792
|
+
internal,
|
|
5793
|
+
base,
|
|
5794
|
+
false
|
|
5795
|
+
);
|
|
5796
|
+
}
|
|
5797
|
+
} else {
|
|
5798
|
+
throwInvalidSubpath(request, match, packageJsonUrl, internal, base);
|
|
5799
|
+
}
|
|
5800
|
+
}
|
|
5801
|
+
if (pattern) {
|
|
5802
|
+
return new URL(
|
|
5803
|
+
RegExpPrototypeSymbolReplace.call(
|
|
5804
|
+
patternRegEx,
|
|
5805
|
+
resolved.href,
|
|
5806
|
+
() => subpath
|
|
5807
|
+
)
|
|
5808
|
+
);
|
|
5809
|
+
}
|
|
5810
|
+
return new URL(subpath, resolved);
|
|
5811
|
+
}
|
|
5812
|
+
function isArrayIndex(key) {
|
|
5813
|
+
const keyNumber = Number(key);
|
|
5814
|
+
if (`${keyNumber}` !== key) return false;
|
|
5815
|
+
return keyNumber >= 0 && keyNumber < 4294967295;
|
|
5816
|
+
}
|
|
5817
|
+
function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions) {
|
|
5818
|
+
if (typeof target === "string") {
|
|
5819
|
+
return resolvePackageTargetString(
|
|
5820
|
+
target,
|
|
5821
|
+
subpath,
|
|
5822
|
+
packageSubpath,
|
|
5823
|
+
packageJsonUrl,
|
|
5824
|
+
base,
|
|
5825
|
+
pattern,
|
|
5826
|
+
internal,
|
|
5827
|
+
isPathMap,
|
|
5828
|
+
conditions
|
|
5829
|
+
);
|
|
5830
|
+
}
|
|
5831
|
+
if (Array.isArray(target)) {
|
|
5832
|
+
const targetList = target;
|
|
5833
|
+
if (targetList.length === 0) return null;
|
|
5834
|
+
let lastException;
|
|
5835
|
+
let i = -1;
|
|
5836
|
+
while (++i < targetList.length) {
|
|
5837
|
+
const targetItem = targetList[i];
|
|
5838
|
+
let resolveResult;
|
|
5839
|
+
try {
|
|
5840
|
+
resolveResult = resolvePackageTarget(
|
|
5841
|
+
packageJsonUrl,
|
|
5842
|
+
targetItem,
|
|
5843
|
+
subpath,
|
|
5844
|
+
packageSubpath,
|
|
5845
|
+
base,
|
|
5846
|
+
pattern,
|
|
5847
|
+
internal,
|
|
5848
|
+
isPathMap,
|
|
5849
|
+
conditions
|
|
5850
|
+
);
|
|
5851
|
+
} catch (error) {
|
|
5852
|
+
const exception = (
|
|
5853
|
+
/** @type {ErrnoException} */
|
|
5854
|
+
error
|
|
5855
|
+
);
|
|
5856
|
+
lastException = exception;
|
|
5857
|
+
if (exception.code === "ERR_INVALID_PACKAGE_TARGET") continue;
|
|
5858
|
+
throw error;
|
|
5859
|
+
}
|
|
5860
|
+
if (resolveResult === void 0) continue;
|
|
5861
|
+
if (resolveResult === null) {
|
|
5862
|
+
lastException = null;
|
|
5863
|
+
continue;
|
|
5864
|
+
}
|
|
5865
|
+
return resolveResult;
|
|
5866
|
+
}
|
|
5867
|
+
if (lastException === void 0 || lastException === null) {
|
|
5868
|
+
return null;
|
|
5869
|
+
}
|
|
5870
|
+
throw lastException;
|
|
5871
|
+
}
|
|
5872
|
+
if (typeof target === "object" && target !== null) {
|
|
5873
|
+
const keys = Object.getOwnPropertyNames(target);
|
|
5874
|
+
let i = -1;
|
|
5875
|
+
while (++i < keys.length) {
|
|
5876
|
+
const key = keys[i];
|
|
5877
|
+
if (isArrayIndex(key)) {
|
|
5878
|
+
throw new ERR_INVALID_PACKAGE_CONFIG2(
|
|
5879
|
+
(0, import_node_url6.fileURLToPath)(packageJsonUrl),
|
|
5880
|
+
base,
|
|
5881
|
+
'"exports" cannot contain numeric property keys.'
|
|
5882
|
+
);
|
|
5883
|
+
}
|
|
5884
|
+
}
|
|
5885
|
+
i = -1;
|
|
5886
|
+
while (++i < keys.length) {
|
|
5887
|
+
const key = keys[i];
|
|
5888
|
+
if (key === "default" || conditions && conditions.has(key)) {
|
|
5889
|
+
const conditionalTarget = (
|
|
5890
|
+
/** @type {unknown} */
|
|
5891
|
+
target[key]
|
|
5892
|
+
);
|
|
5893
|
+
const resolveResult = resolvePackageTarget(
|
|
5894
|
+
packageJsonUrl,
|
|
5895
|
+
conditionalTarget,
|
|
5896
|
+
subpath,
|
|
5897
|
+
packageSubpath,
|
|
5898
|
+
base,
|
|
5899
|
+
pattern,
|
|
5900
|
+
internal,
|
|
5901
|
+
isPathMap,
|
|
5902
|
+
conditions
|
|
5903
|
+
);
|
|
5904
|
+
if (resolveResult === void 0) continue;
|
|
5905
|
+
return resolveResult;
|
|
5906
|
+
}
|
|
5907
|
+
}
|
|
5908
|
+
return null;
|
|
5909
|
+
}
|
|
5910
|
+
if (target === null) {
|
|
5911
|
+
return null;
|
|
5912
|
+
}
|
|
5913
|
+
throw invalidPackageTarget(
|
|
5914
|
+
packageSubpath,
|
|
5915
|
+
target,
|
|
5916
|
+
packageJsonUrl,
|
|
5917
|
+
internal,
|
|
5918
|
+
base
|
|
5919
|
+
);
|
|
5920
|
+
}
|
|
5921
|
+
function isConditionalExportsMainSugar(exports2, packageJsonUrl, base) {
|
|
5922
|
+
if (typeof exports2 === "string" || Array.isArray(exports2)) return true;
|
|
5923
|
+
if (typeof exports2 !== "object" || exports2 === null) return false;
|
|
5924
|
+
const keys = Object.getOwnPropertyNames(exports2);
|
|
5925
|
+
let isConditionalSugar = false;
|
|
5926
|
+
let i = 0;
|
|
5927
|
+
let keyIndex = -1;
|
|
5928
|
+
while (++keyIndex < keys.length) {
|
|
5929
|
+
const key = keys[keyIndex];
|
|
5930
|
+
const currentIsConditionalSugar = key === "" || key[0] !== ".";
|
|
5931
|
+
if (i++ === 0) {
|
|
5932
|
+
isConditionalSugar = currentIsConditionalSugar;
|
|
5933
|
+
} else if (isConditionalSugar !== currentIsConditionalSugar) {
|
|
5934
|
+
throw new ERR_INVALID_PACKAGE_CONFIG2(
|
|
5935
|
+
(0, import_node_url6.fileURLToPath)(packageJsonUrl),
|
|
5936
|
+
base,
|
|
5937
|
+
`"exports" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.`
|
|
5938
|
+
);
|
|
5939
|
+
}
|
|
5940
|
+
}
|
|
5941
|
+
return isConditionalSugar;
|
|
5942
|
+
}
|
|
5943
|
+
function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
|
|
5944
|
+
if (import_node_process.default.noDeprecation) {
|
|
5945
|
+
return;
|
|
5946
|
+
}
|
|
5947
|
+
const pjsonPath = (0, import_node_url6.fileURLToPath)(pjsonUrl);
|
|
5948
|
+
if (emittedPackageWarnings.has(pjsonPath + "|" + match)) return;
|
|
5949
|
+
emittedPackageWarnings.add(pjsonPath + "|" + match);
|
|
5950
|
+
import_node_process.default.emitWarning(
|
|
5951
|
+
`Use of deprecated trailing slash pattern mapping "${match}" in the "exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${(0, import_node_url6.fileURLToPath)(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`,
|
|
5952
|
+
"DeprecationWarning",
|
|
5953
|
+
"DEP0155"
|
|
5954
|
+
);
|
|
5955
|
+
}
|
|
5956
|
+
function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions) {
|
|
5957
|
+
let exports2 = packageConfig.exports;
|
|
5958
|
+
if (isConditionalExportsMainSugar(exports2, packageJsonUrl, base)) {
|
|
5959
|
+
exports2 = { ".": exports2 };
|
|
5960
|
+
}
|
|
5961
|
+
if (own2.call(exports2, packageSubpath) && !packageSubpath.includes("*") && !packageSubpath.endsWith("/")) {
|
|
5962
|
+
const target = exports2[packageSubpath];
|
|
5963
|
+
const resolveResult = resolvePackageTarget(
|
|
5964
|
+
packageJsonUrl,
|
|
5965
|
+
target,
|
|
5966
|
+
"",
|
|
5967
|
+
packageSubpath,
|
|
5968
|
+
base,
|
|
5969
|
+
false,
|
|
5970
|
+
false,
|
|
5971
|
+
false,
|
|
5972
|
+
conditions
|
|
5973
|
+
);
|
|
5974
|
+
if (resolveResult === null || resolveResult === void 0) {
|
|
5975
|
+
throw exportsNotFound(packageSubpath, packageJsonUrl, base);
|
|
5976
|
+
}
|
|
5977
|
+
return resolveResult;
|
|
5978
|
+
}
|
|
5979
|
+
let bestMatch = "";
|
|
5980
|
+
let bestMatchSubpath = "";
|
|
5981
|
+
const keys = Object.getOwnPropertyNames(exports2);
|
|
5982
|
+
let i = -1;
|
|
5983
|
+
while (++i < keys.length) {
|
|
5984
|
+
const key = keys[i];
|
|
5985
|
+
const patternIndex = key.indexOf("*");
|
|
5986
|
+
if (patternIndex !== -1 && packageSubpath.startsWith(key.slice(0, patternIndex))) {
|
|
5987
|
+
if (packageSubpath.endsWith("/")) {
|
|
5988
|
+
emitTrailingSlashPatternDeprecation(
|
|
5989
|
+
packageSubpath,
|
|
5990
|
+
packageJsonUrl,
|
|
5991
|
+
base
|
|
5992
|
+
);
|
|
5993
|
+
}
|
|
5994
|
+
const patternTrailer = key.slice(patternIndex + 1);
|
|
5995
|
+
if (packageSubpath.length >= key.length && packageSubpath.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
|
|
5996
|
+
bestMatch = key;
|
|
5997
|
+
bestMatchSubpath = packageSubpath.slice(
|
|
5998
|
+
patternIndex,
|
|
5999
|
+
packageSubpath.length - patternTrailer.length
|
|
6000
|
+
);
|
|
6001
|
+
}
|
|
6002
|
+
}
|
|
6003
|
+
}
|
|
6004
|
+
if (bestMatch) {
|
|
6005
|
+
const target = (
|
|
6006
|
+
/** @type {unknown} */
|
|
6007
|
+
exports2[bestMatch]
|
|
6008
|
+
);
|
|
6009
|
+
const resolveResult = resolvePackageTarget(
|
|
6010
|
+
packageJsonUrl,
|
|
6011
|
+
target,
|
|
6012
|
+
bestMatchSubpath,
|
|
6013
|
+
bestMatch,
|
|
6014
|
+
base,
|
|
6015
|
+
true,
|
|
6016
|
+
false,
|
|
6017
|
+
packageSubpath.endsWith("/"),
|
|
6018
|
+
conditions
|
|
6019
|
+
);
|
|
6020
|
+
if (resolveResult === null || resolveResult === void 0) {
|
|
6021
|
+
throw exportsNotFound(packageSubpath, packageJsonUrl, base);
|
|
6022
|
+
}
|
|
6023
|
+
return resolveResult;
|
|
6024
|
+
}
|
|
6025
|
+
throw exportsNotFound(packageSubpath, packageJsonUrl, base);
|
|
6026
|
+
}
|
|
6027
|
+
function patternKeyCompare(a, b) {
|
|
6028
|
+
const aPatternIndex = a.indexOf("*");
|
|
6029
|
+
const bPatternIndex = b.indexOf("*");
|
|
6030
|
+
const baseLengthA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
|
|
6031
|
+
const baseLengthB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
|
|
6032
|
+
if (baseLengthA > baseLengthB) return -1;
|
|
6033
|
+
if (baseLengthB > baseLengthA) return 1;
|
|
6034
|
+
if (aPatternIndex === -1) return 1;
|
|
6035
|
+
if (bPatternIndex === -1) return -1;
|
|
6036
|
+
if (a.length > b.length) return -1;
|
|
6037
|
+
if (b.length > a.length) return 1;
|
|
6038
|
+
return 0;
|
|
6039
|
+
}
|
|
6040
|
+
function packageImportsResolve(name, base, conditions) {
|
|
6041
|
+
if (name === "#" || name.startsWith("#/") || name.endsWith("/")) {
|
|
6042
|
+
const reason = "is not a valid internal imports specifier name";
|
|
6043
|
+
throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, (0, import_node_url6.fileURLToPath)(base));
|
|
6044
|
+
}
|
|
6045
|
+
let packageJsonUrl;
|
|
6046
|
+
const packageConfig = getPackageScopeConfig(base);
|
|
6047
|
+
if (packageConfig.exists) {
|
|
6048
|
+
packageJsonUrl = (0, import_node_url6.pathToFileURL)(packageConfig.pjsonPath);
|
|
6049
|
+
const imports = packageConfig.imports;
|
|
6050
|
+
if (imports) {
|
|
6051
|
+
if (own2.call(imports, name) && !name.includes("*")) {
|
|
6052
|
+
const resolveResult = resolvePackageTarget(
|
|
6053
|
+
packageJsonUrl,
|
|
6054
|
+
imports[name],
|
|
6055
|
+
"",
|
|
6056
|
+
name,
|
|
6057
|
+
base,
|
|
6058
|
+
false,
|
|
6059
|
+
true,
|
|
6060
|
+
false,
|
|
6061
|
+
conditions
|
|
6062
|
+
);
|
|
6063
|
+
if (resolveResult !== null && resolveResult !== void 0) {
|
|
6064
|
+
return resolveResult;
|
|
6065
|
+
}
|
|
6066
|
+
} else {
|
|
6067
|
+
let bestMatch = "";
|
|
6068
|
+
let bestMatchSubpath = "";
|
|
6069
|
+
const keys = Object.getOwnPropertyNames(imports);
|
|
6070
|
+
let i = -1;
|
|
6071
|
+
while (++i < keys.length) {
|
|
6072
|
+
const key = keys[i];
|
|
6073
|
+
const patternIndex = key.indexOf("*");
|
|
6074
|
+
if (patternIndex !== -1 && name.startsWith(key.slice(0, -1))) {
|
|
6075
|
+
const patternTrailer = key.slice(patternIndex + 1);
|
|
6076
|
+
if (name.length >= key.length && name.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
|
|
6077
|
+
bestMatch = key;
|
|
6078
|
+
bestMatchSubpath = name.slice(
|
|
6079
|
+
patternIndex,
|
|
6080
|
+
name.length - patternTrailer.length
|
|
6081
|
+
);
|
|
6082
|
+
}
|
|
6083
|
+
}
|
|
6084
|
+
}
|
|
6085
|
+
if (bestMatch) {
|
|
6086
|
+
const target = imports[bestMatch];
|
|
6087
|
+
const resolveResult = resolvePackageTarget(
|
|
6088
|
+
packageJsonUrl,
|
|
6089
|
+
target,
|
|
6090
|
+
bestMatchSubpath,
|
|
6091
|
+
bestMatch,
|
|
6092
|
+
base,
|
|
6093
|
+
true,
|
|
6094
|
+
true,
|
|
6095
|
+
false,
|
|
6096
|
+
conditions
|
|
6097
|
+
);
|
|
6098
|
+
if (resolveResult !== null && resolveResult !== void 0) {
|
|
6099
|
+
return resolveResult;
|
|
6100
|
+
}
|
|
6101
|
+
}
|
|
6102
|
+
}
|
|
6103
|
+
}
|
|
6104
|
+
}
|
|
6105
|
+
throw importNotDefined(name, packageJsonUrl, base);
|
|
6106
|
+
}
|
|
6107
|
+
function parsePackageName(specifier, base) {
|
|
6108
|
+
let separatorIndex = specifier.indexOf("/");
|
|
6109
|
+
let validPackageName = true;
|
|
6110
|
+
let isScoped = false;
|
|
6111
|
+
if (specifier[0] === "@") {
|
|
6112
|
+
isScoped = true;
|
|
6113
|
+
if (separatorIndex === -1 || specifier.length === 0) {
|
|
6114
|
+
validPackageName = false;
|
|
6115
|
+
} else {
|
|
6116
|
+
separatorIndex = specifier.indexOf("/", separatorIndex + 1);
|
|
6117
|
+
}
|
|
6118
|
+
}
|
|
6119
|
+
const packageName = separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
|
|
6120
|
+
if (invalidPackageNameRegEx.exec(packageName) !== null) {
|
|
6121
|
+
validPackageName = false;
|
|
6122
|
+
}
|
|
6123
|
+
if (!validPackageName) {
|
|
6124
|
+
throw new ERR_INVALID_MODULE_SPECIFIER(
|
|
6125
|
+
specifier,
|
|
6126
|
+
"is not a valid package name",
|
|
6127
|
+
(0, import_node_url6.fileURLToPath)(base)
|
|
6128
|
+
);
|
|
6129
|
+
}
|
|
6130
|
+
const packageSubpath = "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex));
|
|
6131
|
+
return { packageName, packageSubpath, isScoped };
|
|
6132
|
+
}
|
|
6133
|
+
function packageResolve(specifier, base, conditions) {
|
|
6134
|
+
if (import_node_module4.builtinModules.includes(specifier)) {
|
|
6135
|
+
return new URL("node:" + specifier);
|
|
6136
|
+
}
|
|
6137
|
+
const { packageName, packageSubpath, isScoped } = parsePackageName(
|
|
6138
|
+
specifier,
|
|
6139
|
+
base
|
|
6140
|
+
);
|
|
6141
|
+
const packageConfig = getPackageScopeConfig(base);
|
|
6142
|
+
if (packageConfig.exists) {
|
|
6143
|
+
const packageJsonUrl2 = (0, import_node_url6.pathToFileURL)(packageConfig.pjsonPath);
|
|
6144
|
+
if (packageConfig.name === packageName && packageConfig.exports !== void 0 && packageConfig.exports !== null) {
|
|
6145
|
+
return packageExportsResolve(
|
|
6146
|
+
packageJsonUrl2,
|
|
6147
|
+
packageSubpath,
|
|
6148
|
+
packageConfig,
|
|
6149
|
+
base,
|
|
6150
|
+
conditions
|
|
6151
|
+
);
|
|
6152
|
+
}
|
|
6153
|
+
}
|
|
6154
|
+
let packageJsonUrl = new URL(
|
|
6155
|
+
"./node_modules/" + packageName + "/package.json",
|
|
6156
|
+
base
|
|
6157
|
+
);
|
|
6158
|
+
let packageJsonPath = (0, import_node_url6.fileURLToPath)(packageJsonUrl);
|
|
6159
|
+
let lastPath;
|
|
6160
|
+
do {
|
|
6161
|
+
const stat = tryStatSync(packageJsonPath.slice(0, -13));
|
|
6162
|
+
if (!stat || !stat.isDirectory()) {
|
|
6163
|
+
lastPath = packageJsonPath;
|
|
6164
|
+
packageJsonUrl = new URL(
|
|
6165
|
+
(isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json",
|
|
6166
|
+
packageJsonUrl
|
|
6167
|
+
);
|
|
6168
|
+
packageJsonPath = (0, import_node_url6.fileURLToPath)(packageJsonUrl);
|
|
6169
|
+
continue;
|
|
6170
|
+
}
|
|
6171
|
+
const packageConfig2 = read(packageJsonPath, { base, specifier });
|
|
6172
|
+
if (packageConfig2.exports !== void 0 && packageConfig2.exports !== null) {
|
|
6173
|
+
return packageExportsResolve(
|
|
6174
|
+
packageJsonUrl,
|
|
6175
|
+
packageSubpath,
|
|
6176
|
+
packageConfig2,
|
|
6177
|
+
base,
|
|
6178
|
+
conditions
|
|
6179
|
+
);
|
|
6180
|
+
}
|
|
6181
|
+
if (packageSubpath === ".") {
|
|
6182
|
+
return legacyMainResolve(packageJsonUrl, packageConfig2, base);
|
|
6183
|
+
}
|
|
6184
|
+
return new URL(packageSubpath, packageJsonUrl);
|
|
6185
|
+
} while (packageJsonPath.length !== lastPath.length);
|
|
6186
|
+
throw new ERR_MODULE_NOT_FOUND(packageName, (0, import_node_url6.fileURLToPath)(base), false);
|
|
6187
|
+
}
|
|
6188
|
+
function isRelativeSpecifier(specifier) {
|
|
6189
|
+
if (specifier[0] === ".") {
|
|
6190
|
+
if (specifier.length === 1 || specifier[1] === "/") return true;
|
|
6191
|
+
if (specifier[1] === "." && (specifier.length === 2 || specifier[2] === "/")) {
|
|
6192
|
+
return true;
|
|
6193
|
+
}
|
|
6194
|
+
}
|
|
6195
|
+
return false;
|
|
6196
|
+
}
|
|
6197
|
+
function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) {
|
|
6198
|
+
if (specifier === "") return false;
|
|
6199
|
+
if (specifier[0] === "/") return true;
|
|
6200
|
+
return isRelativeSpecifier(specifier);
|
|
6201
|
+
}
|
|
6202
|
+
function moduleResolve(specifier, base, conditions, preserveSymlinks) {
|
|
6203
|
+
if (conditions === void 0) {
|
|
6204
|
+
conditions = getConditionsSet();
|
|
6205
|
+
}
|
|
6206
|
+
const protocol = base.protocol;
|
|
6207
|
+
const isData = protocol === "data:";
|
|
6208
|
+
const isRemote = isData || protocol === "http:" || protocol === "https:";
|
|
6209
|
+
let resolved;
|
|
6210
|
+
if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) {
|
|
6211
|
+
try {
|
|
6212
|
+
resolved = new URL(specifier, base);
|
|
6213
|
+
} catch (error_) {
|
|
6214
|
+
const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
|
|
6215
|
+
error.cause = error_;
|
|
6216
|
+
throw error;
|
|
6217
|
+
}
|
|
6218
|
+
} else if (protocol === "file:" && specifier[0] === "#") {
|
|
6219
|
+
resolved = packageImportsResolve(specifier, base, conditions);
|
|
6220
|
+
} else {
|
|
6221
|
+
try {
|
|
6222
|
+
resolved = new URL(specifier);
|
|
6223
|
+
} catch (error_) {
|
|
6224
|
+
if (isRemote && !import_node_module4.builtinModules.includes(specifier)) {
|
|
6225
|
+
const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
|
|
6226
|
+
error.cause = error_;
|
|
6227
|
+
throw error;
|
|
6228
|
+
}
|
|
6229
|
+
resolved = packageResolve(specifier, base, conditions);
|
|
6230
|
+
}
|
|
6231
|
+
}
|
|
6232
|
+
import_node_assert2.default.ok(resolved !== void 0, "expected to be defined");
|
|
6233
|
+
if (resolved.protocol !== "file:") {
|
|
6234
|
+
return resolved;
|
|
6235
|
+
}
|
|
6236
|
+
return finalizeResolution(resolved, base, preserveSymlinks);
|
|
6237
|
+
}
|
|
6238
|
+
var import_node_assert2, import_node_fs10, import_node_process, import_node_url6, import_node_path12, import_node_module4, RegExpPrototypeSymbolReplace, ERR_NETWORK_IMPORT_DISALLOWED, ERR_INVALID_MODULE_SPECIFIER, ERR_INVALID_PACKAGE_CONFIG2, ERR_INVALID_PACKAGE_TARGET, ERR_MODULE_NOT_FOUND, ERR_PACKAGE_IMPORT_NOT_DEFINED, ERR_PACKAGE_PATH_NOT_EXPORTED, ERR_UNSUPPORTED_DIR_IMPORT, ERR_UNSUPPORTED_RESOLVE_REQUEST, own2, invalidSegmentRegEx, deprecatedInvalidSegmentRegEx, invalidPackageNameRegEx, patternRegEx, encodedSeparatorRegEx, emittedPackageWarnings, doubleSlashRegEx;
|
|
6239
|
+
var init_resolve2 = __esm({
|
|
6240
|
+
"node_modules/import-meta-resolve/lib/resolve.js"() {
|
|
6241
|
+
"use strict";
|
|
6242
|
+
import_node_assert2 = __toESM(require("assert"), 1);
|
|
6243
|
+
import_node_fs10 = require("fs");
|
|
6244
|
+
import_node_process = __toESM(require("process"), 1);
|
|
6245
|
+
import_node_url6 = require("url");
|
|
6246
|
+
import_node_path12 = __toESM(require("path"), 1);
|
|
6247
|
+
import_node_module4 = require("module");
|
|
6248
|
+
init_get_format();
|
|
6249
|
+
init_errors();
|
|
6250
|
+
init_package_json_reader();
|
|
6251
|
+
init_utils();
|
|
6252
|
+
RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
|
|
6253
|
+
({
|
|
6254
|
+
ERR_NETWORK_IMPORT_DISALLOWED,
|
|
6255
|
+
ERR_INVALID_MODULE_SPECIFIER,
|
|
6256
|
+
ERR_INVALID_PACKAGE_CONFIG: ERR_INVALID_PACKAGE_CONFIG2,
|
|
6257
|
+
ERR_INVALID_PACKAGE_TARGET,
|
|
6258
|
+
ERR_MODULE_NOT_FOUND,
|
|
6259
|
+
ERR_PACKAGE_IMPORT_NOT_DEFINED,
|
|
6260
|
+
ERR_PACKAGE_PATH_NOT_EXPORTED,
|
|
6261
|
+
ERR_UNSUPPORTED_DIR_IMPORT,
|
|
6262
|
+
ERR_UNSUPPORTED_RESOLVE_REQUEST
|
|
6263
|
+
} = codes);
|
|
6264
|
+
own2 = {}.hasOwnProperty;
|
|
6265
|
+
invalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i;
|
|
6266
|
+
deprecatedInvalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i;
|
|
6267
|
+
invalidPackageNameRegEx = /^\.|%|\\/;
|
|
6268
|
+
patternRegEx = /\*/g;
|
|
6269
|
+
encodedSeparatorRegEx = /%2f|%5c/i;
|
|
6270
|
+
emittedPackageWarnings = /* @__PURE__ */ new Set();
|
|
6271
|
+
doubleSlashRegEx = /[/\\]{2}/;
|
|
6272
|
+
}
|
|
6273
|
+
});
|
|
6274
|
+
|
|
6275
|
+
// node_modules/import-meta-resolve/index.js
|
|
6276
|
+
var init_import_meta_resolve = __esm({
|
|
6277
|
+
"node_modules/import-meta-resolve/index.js"() {
|
|
6278
|
+
"use strict";
|
|
6279
|
+
init_resolve2();
|
|
6280
|
+
}
|
|
6281
|
+
});
|
|
6282
|
+
|
|
4867
6283
|
// src/server/runnable-environment.ts
|
|
4868
6284
|
var runnable_environment_exports = {};
|
|
4869
6285
|
__export(runnable_environment_exports, {
|
|
@@ -4878,25 +6294,27 @@ function createModuleRunner(environment) {
|
|
|
4878
6294
|
}
|
|
4879
6295
|
return new NastiModuleRunner(environment);
|
|
4880
6296
|
}
|
|
4881
|
-
var
|
|
6297
|
+
var import_node_path13, import_node_fs11, import_node_module5, import_node_url7, debug4, NODE_BUILTINS, NastiModuleRunner, AsyncFunction;
|
|
4882
6298
|
var init_runnable_environment = __esm({
|
|
4883
6299
|
"src/server/runnable-environment.ts"() {
|
|
4884
6300
|
"use strict";
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
6301
|
+
import_node_path13 = __toESM(require("path"), 1);
|
|
6302
|
+
import_node_fs11 = __toESM(require("fs"), 1);
|
|
6303
|
+
import_node_module5 = require("module");
|
|
6304
|
+
import_node_url7 = require("url");
|
|
6305
|
+
init_import_meta_resolve();
|
|
4889
6306
|
init_transformer();
|
|
4890
6307
|
init_env();
|
|
4891
6308
|
init_debug();
|
|
4892
6309
|
debug4 = createDebugger("nasti:ssr");
|
|
4893
|
-
NODE_BUILTINS = /* @__PURE__ */ new Set([...
|
|
6310
|
+
NODE_BUILTINS = /* @__PURE__ */ new Set([...import_node_module5.builtinModules, ...import_node_module5.builtinModules.map((m) => `node:${m}`)]);
|
|
4894
6311
|
NastiModuleRunner = class {
|
|
4895
6312
|
environment;
|
|
4896
6313
|
config;
|
|
4897
6314
|
cache = /* @__PURE__ */ new Map();
|
|
4898
6315
|
envDefine;
|
|
4899
|
-
|
|
6316
|
+
externalImportParent;
|
|
6317
|
+
externalImportConditions;
|
|
4900
6318
|
constructor(environment) {
|
|
4901
6319
|
this.environment = environment;
|
|
4902
6320
|
this.config = environment.config;
|
|
@@ -4905,10 +6323,15 @@ var init_runnable_environment = __esm({
|
|
|
4905
6323
|
this.config.mode,
|
|
4906
6324
|
ssrDefineOverrides(environment.consumer)
|
|
4907
6325
|
);
|
|
4908
|
-
this.
|
|
6326
|
+
this.externalImportParent = (0, import_node_url7.pathToFileURL)(import_node_path13.default.join(this.config.root, "package.json"));
|
|
6327
|
+
this.externalImportConditions = /* @__PURE__ */ new Set([
|
|
6328
|
+
...environment.options.resolve.conditions.filter((condition) => condition !== "require"),
|
|
6329
|
+
"node",
|
|
6330
|
+
"import"
|
|
6331
|
+
]);
|
|
4909
6332
|
const handlers = {
|
|
4910
6333
|
fetchModule: async (id, importer) => this.fetchModule(id, importer),
|
|
4911
|
-
getBuiltins: () => [/^node:/, ...
|
|
6334
|
+
getBuiltins: () => [/^node:/, ...import_node_module5.builtinModules]
|
|
4912
6335
|
};
|
|
4913
6336
|
environment.hot.setInvokeHandler?.(handlers);
|
|
4914
6337
|
}
|
|
@@ -4929,9 +6352,9 @@ var init_runnable_environment = __esm({
|
|
|
4929
6352
|
this.cache.clear();
|
|
4930
6353
|
}
|
|
4931
6354
|
resolveToId(rawUrl) {
|
|
4932
|
-
if (
|
|
6355
|
+
if (import_node_path13.default.isAbsolute(rawUrl) && import_node_fs11.default.existsSync(rawUrl.split("?")[0])) return rawUrl;
|
|
4933
6356
|
const clean = rawUrl.replace(/^\//, "");
|
|
4934
|
-
return
|
|
6357
|
+
return import_node_path13.default.resolve(this.config.root, clean);
|
|
4935
6358
|
}
|
|
4936
6359
|
/**
|
|
4937
6360
|
* fetchModule(invoke 契约方法):环境管线产出 runner 可执行代码。
|
|
@@ -4940,14 +6363,14 @@ var init_runnable_environment = __esm({
|
|
|
4940
6363
|
*/
|
|
4941
6364
|
async fetchModule(id, importer) {
|
|
4942
6365
|
if (NODE_BUILTINS.has(id)) return { externalize: id };
|
|
4943
|
-
if (!id.startsWith(".") && !
|
|
6366
|
+
if (!id.startsWith(".") && !import_node_path13.default.isAbsolute(id) && !id.startsWith("\0")) {
|
|
4944
6367
|
return { externalize: id };
|
|
4945
6368
|
}
|
|
4946
6369
|
const container = this.environment.pluginContainer;
|
|
4947
6370
|
let resolvedId = id;
|
|
4948
6371
|
if (id.startsWith(".") && importer) {
|
|
4949
6372
|
const resolved = await container.resolveId(id, importer);
|
|
4950
|
-
resolvedId = resolved ? typeof resolved === "string" ? resolved : resolved.id :
|
|
6373
|
+
resolvedId = resolved ? typeof resolved === "string" ? resolved : resolved.id : import_node_path13.default.resolve(import_node_path13.default.dirname(importer.split("?")[0]), id);
|
|
4951
6374
|
}
|
|
4952
6375
|
resolvedId = this.completeExtension(resolvedId);
|
|
4953
6376
|
const cleanId = resolvedId.split("?")[0];
|
|
@@ -4955,8 +6378,8 @@ var init_runnable_environment = __esm({
|
|
|
4955
6378
|
const loaded = await container.load(resolvedId);
|
|
4956
6379
|
if (loaded != null) {
|
|
4957
6380
|
code = typeof loaded === "string" ? loaded : loaded.code;
|
|
4958
|
-
} else if (
|
|
4959
|
-
code =
|
|
6381
|
+
} else if (import_node_fs11.default.existsSync(cleanId)) {
|
|
6382
|
+
code = import_node_fs11.default.readFileSync(cleanId, "utf-8");
|
|
4960
6383
|
} else {
|
|
4961
6384
|
throw new Error(`[nasti:ssr] cannot load module: ${resolvedId}`);
|
|
4962
6385
|
}
|
|
@@ -4964,12 +6387,32 @@ var init_runnable_environment = __esm({
|
|
|
4964
6387
|
if (transformed != null) {
|
|
4965
6388
|
code = typeof transformed === "string" ? transformed : transformed.code;
|
|
4966
6389
|
}
|
|
4967
|
-
if (
|
|
6390
|
+
if (this.config.framework === "react") {
|
|
6391
|
+
const result = await transformReactCode(cleanId, code, {
|
|
6392
|
+
react: this.config.react,
|
|
6393
|
+
consumer: this.environment.consumer,
|
|
6394
|
+
development: true,
|
|
6395
|
+
sourcemap: false,
|
|
6396
|
+
target: this.environment.options.build.target,
|
|
6397
|
+
onWarning: (message) => this.config.logger.warn(`[nasti:react] ${message}`)
|
|
6398
|
+
});
|
|
6399
|
+
if (result) {
|
|
6400
|
+
code = result.code;
|
|
6401
|
+
} else if (shouldTransform(cleanId)) {
|
|
6402
|
+
const fallback = transformCode(cleanId, code, {
|
|
6403
|
+
sourcemap: false,
|
|
6404
|
+
jsxRuntime: this.config.react.jsxRuntime,
|
|
6405
|
+
jsxImportSource: this.config.react.jsxImportSource,
|
|
6406
|
+
target: this.environment.options.build.target
|
|
6407
|
+
});
|
|
6408
|
+
code = fallback.code;
|
|
6409
|
+
}
|
|
6410
|
+
} else if (shouldTransform(cleanId)) {
|
|
4968
6411
|
const result = transformCode(cleanId, code, {
|
|
4969
6412
|
sourcemap: false,
|
|
4970
6413
|
target: this.environment.options.build.target,
|
|
4971
6414
|
jsxRuntime: "automatic",
|
|
4972
|
-
jsxImportSource:
|
|
6415
|
+
jsxImportSource: "vue"
|
|
4973
6416
|
});
|
|
4974
6417
|
code = result.code;
|
|
4975
6418
|
}
|
|
@@ -4990,19 +6433,19 @@ var init_runnable_environment = __esm({
|
|
|
4990
6433
|
completeExtension(id) {
|
|
4991
6434
|
const clean = id.split("?")[0];
|
|
4992
6435
|
const query = id.includes("?") ? id.slice(id.indexOf("?")) : "";
|
|
4993
|
-
if (
|
|
6436
|
+
if (import_node_fs11.default.existsSync(clean) && import_node_fs11.default.statSync(clean).isFile()) return id;
|
|
4994
6437
|
const jsMatch = clean.match(/^(.*)\.([mc]?)jsx?$/);
|
|
4995
6438
|
if (jsMatch) {
|
|
4996
6439
|
for (const tsExt of [`.${jsMatch[2]}ts`, `.${jsMatch[2]}tsx`]) {
|
|
4997
|
-
if (
|
|
6440
|
+
if (import_node_fs11.default.existsSync(jsMatch[1] + tsExt)) return jsMatch[1] + tsExt + query;
|
|
4998
6441
|
}
|
|
4999
6442
|
}
|
|
5000
6443
|
for (const ext of this.config.resolve.extensions) {
|
|
5001
|
-
if (
|
|
6444
|
+
if (import_node_fs11.default.existsSync(clean + ext)) return clean + ext + query;
|
|
5002
6445
|
}
|
|
5003
6446
|
for (const ext of this.config.resolve.extensions) {
|
|
5004
|
-
const indexPath =
|
|
5005
|
-
if (
|
|
6447
|
+
const indexPath = import_node_path13.default.join(clean, `index${ext}`);
|
|
6448
|
+
if (import_node_fs11.default.existsSync(indexPath)) return indexPath;
|
|
5006
6449
|
}
|
|
5007
6450
|
return id;
|
|
5008
6451
|
}
|
|
@@ -5029,10 +6472,10 @@ var init_runnable_environment = __esm({
|
|
|
5029
6472
|
return;
|
|
5030
6473
|
}
|
|
5031
6474
|
const ssrImport = async (dep) => {
|
|
5032
|
-
if (NODE_BUILTINS.has(dep) || !dep.startsWith(".") && !
|
|
6475
|
+
if (NODE_BUILTINS.has(dep) || !dep.startsWith(".") && !import_node_path13.default.isAbsolute(dep) && !dep.startsWith("\0")) {
|
|
5033
6476
|
return this.importExternal(dep);
|
|
5034
6477
|
}
|
|
5035
|
-
const depId = dep.startsWith(".") ? this.completeExtension(
|
|
6478
|
+
const depId = dep.startsWith(".") ? this.completeExtension(import_node_path13.default.resolve(import_node_path13.default.dirname(fetched.id.split("?")[0]), dep)) : this.completeExtension(dep);
|
|
5036
6479
|
return this.instantiate(depId);
|
|
5037
6480
|
};
|
|
5038
6481
|
const ssrExportAll = (sourceModule) => {
|
|
@@ -5047,7 +6490,7 @@ var init_runnable_environment = __esm({
|
|
|
5047
6490
|
}
|
|
5048
6491
|
};
|
|
5049
6492
|
const importMeta = {
|
|
5050
|
-
url: (0,
|
|
6493
|
+
url: (0, import_node_url7.pathToFileURL)(fetched.id.split("?")[0]).href,
|
|
5051
6494
|
env: { SSR: true, MODE: this.config.mode, DEV: this.config.mode !== "production", PROD: this.config.mode === "production" },
|
|
5052
6495
|
hot: void 0
|
|
5053
6496
|
};
|
|
@@ -5064,20 +6507,21 @@ var init_runnable_environment = __esm({
|
|
|
5064
6507
|
}
|
|
5065
6508
|
async importExternal(spec) {
|
|
5066
6509
|
try {
|
|
5067
|
-
return await (spec.startsWith("node:") || !
|
|
6510
|
+
return await (spec.startsWith("node:") || !import_node_path13.default.isAbsolute(spec) ? import(this.resolveExternalSpecifier(spec)) : import((0, import_node_url7.pathToFileURL)(spec).href));
|
|
5068
6511
|
} catch (err) {
|
|
5069
6512
|
throw new Error(`[nasti:ssr] failed to import external "${spec}": ${err.message}`);
|
|
5070
6513
|
}
|
|
5071
6514
|
}
|
|
5072
|
-
/** bare specifier → 项目 node_modules
|
|
6515
|
+
/** bare specifier → 项目 node_modules 的 ESM URL(避免相对 Nasti 自身解析) */
|
|
5073
6516
|
resolveExternalSpecifier(spec) {
|
|
5074
6517
|
if (spec.startsWith("node:")) return spec;
|
|
5075
6518
|
if (NODE_BUILTINS.has(spec)) return `node:${spec}`;
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
6519
|
+
return moduleResolve(
|
|
6520
|
+
spec,
|
|
6521
|
+
this.externalImportParent,
|
|
6522
|
+
this.externalImportConditions,
|
|
6523
|
+
false
|
|
6524
|
+
).href;
|
|
5081
6525
|
}
|
|
5082
6526
|
};
|
|
5083
6527
|
AsyncFunction = Object.getPrototypeOf(async function() {
|
|
@@ -5085,6 +6529,44 @@ var init_runnable_environment = __esm({
|
|
|
5085
6529
|
}
|
|
5086
6530
|
});
|
|
5087
6531
|
|
|
6532
|
+
// src/plugins/react.ts
|
|
6533
|
+
function reactPlugin(config, environment) {
|
|
6534
|
+
return {
|
|
6535
|
+
name: "nasti:oxc-transform",
|
|
6536
|
+
async transform(code, id) {
|
|
6537
|
+
const result = await transformReactCode(id, code, {
|
|
6538
|
+
react: config.react,
|
|
6539
|
+
consumer: environment.consumer,
|
|
6540
|
+
development: config.mode === "development",
|
|
6541
|
+
sourcemap: !!environment.options.build.sourcemap,
|
|
6542
|
+
target: environment.options.build.target,
|
|
6543
|
+
onWarning: (message) => config.logger.warn(`[nasti:react] ${message}`)
|
|
6544
|
+
});
|
|
6545
|
+
if (!result) return null;
|
|
6546
|
+
return {
|
|
6547
|
+
code: result.code,
|
|
6548
|
+
map: result.map ? JSON.parse(result.map) : void 0
|
|
6549
|
+
};
|
|
6550
|
+
},
|
|
6551
|
+
handleHotUpdate(ctx) {
|
|
6552
|
+
for (const mod of ctx.modules) {
|
|
6553
|
+
if (REACT_FILE_RE.test(mod.url) && matchesReactFilter(mod.url, config.react.include, config.react.exclude)) {
|
|
6554
|
+
mod.isSelfAccepting = true;
|
|
6555
|
+
}
|
|
6556
|
+
}
|
|
6557
|
+
return ctx.modules;
|
|
6558
|
+
}
|
|
6559
|
+
};
|
|
6560
|
+
}
|
|
6561
|
+
var REACT_FILE_RE;
|
|
6562
|
+
var init_react = __esm({
|
|
6563
|
+
"src/plugins/react.ts"() {
|
|
6564
|
+
"use strict";
|
|
6565
|
+
init_transformer();
|
|
6566
|
+
REACT_FILE_RE = /\.[jt]sx(?:[?#].*)?$/;
|
|
6567
|
+
}
|
|
6568
|
+
});
|
|
6569
|
+
|
|
5088
6570
|
// src/build/reporter.ts
|
|
5089
6571
|
async function tryNativeReporterPlugin(config, logger) {
|
|
5090
6572
|
try {
|
|
@@ -5124,7 +6606,7 @@ function reportBuildOutput(output, config, logger) {
|
|
|
5124
6606
|
if (compressed && content != null) {
|
|
5125
6607
|
gzip = (0, import_node_zlib.gzipSync)(typeof content === "string" ? Buffer.from(content) : content).byteLength;
|
|
5126
6608
|
}
|
|
5127
|
-
const ext =
|
|
6609
|
+
const ext = import_node_path14.default.extname(file.fileName);
|
|
5128
6610
|
const group = file.type === "chunk" ? "js" : ext === ".css" ? "css" : "assets";
|
|
5129
6611
|
entries.push({ name: file.fileName, size, gzip, group });
|
|
5130
6612
|
}
|
|
@@ -5158,11 +6640,11 @@ function warnLargeChunks(output, config, logger) {
|
|
|
5158
6640
|
)
|
|
5159
6641
|
);
|
|
5160
6642
|
}
|
|
5161
|
-
var
|
|
6643
|
+
var import_node_path14, import_node_zlib, import_picocolors5, debug5, numberFormatter;
|
|
5162
6644
|
var init_reporter = __esm({
|
|
5163
6645
|
"src/build/reporter.ts"() {
|
|
5164
6646
|
"use strict";
|
|
5165
|
-
|
|
6647
|
+
import_node_path14 = __toESM(require("path"), 1);
|
|
5166
6648
|
import_node_zlib = require("zlib");
|
|
5167
6649
|
import_picocolors5 = __toESM(require("picocolors"), 1);
|
|
5168
6650
|
init_debug();
|
|
@@ -5178,7 +6660,7 @@ var init_reporter = __esm({
|
|
|
5178
6660
|
function createBuildAppContext(config, results) {
|
|
5179
6661
|
const output = [];
|
|
5180
6662
|
const emitted = /* @__PURE__ */ new Set();
|
|
5181
|
-
const outDir =
|
|
6663
|
+
const outDir = import_node_path15.default.resolve(config.root, config.build.outDir);
|
|
5182
6664
|
let environmentArtifacts;
|
|
5183
6665
|
return {
|
|
5184
6666
|
config,
|
|
@@ -5234,14 +6716,14 @@ function createBuildAppContext(config, results) {
|
|
|
5234
6716
|
if (environmentArtifacts.has(collisionKey)) {
|
|
5235
6717
|
throw new Error(`[nasti] app artifact conflicts with environment output: ${fileName}`);
|
|
5236
6718
|
}
|
|
5237
|
-
const target =
|
|
5238
|
-
const relative =
|
|
5239
|
-
if (relative.startsWith("..") ||
|
|
6719
|
+
const target = import_node_path15.default.resolve(outDir, ...fileName.split("/"));
|
|
6720
|
+
const relative = import_node_path15.default.relative(outDir, target);
|
|
6721
|
+
if (relative.startsWith("..") || import_node_path15.default.isAbsolute(relative)) {
|
|
5240
6722
|
throw new Error(`[nasti] app artifact must stay inside build.outDir: ${file.fileName}`);
|
|
5241
6723
|
}
|
|
5242
6724
|
assertNoSymlinkComponents(outDir, fileName);
|
|
5243
|
-
|
|
5244
|
-
|
|
6725
|
+
import_node_fs12.default.mkdirSync(import_node_path15.default.dirname(target), { recursive: true });
|
|
6726
|
+
import_node_fs12.default.writeFileSync(target, file.source);
|
|
5245
6727
|
const artifact = {
|
|
5246
6728
|
...file,
|
|
5247
6729
|
fileName,
|
|
@@ -5257,10 +6739,10 @@ function joinPublicPath(base, fileName) {
|
|
|
5257
6739
|
return `${base.endsWith("/") ? base : `${base}/`}${fileName.replace(/^\//, "")}`;
|
|
5258
6740
|
}
|
|
5259
6741
|
function normalizeEnvironmentFileName(fileName) {
|
|
5260
|
-
return
|
|
6742
|
+
return import_node_path15.default.posix.normalize(fileName.replace(/\\/g, "/").replace(/^\.\//, ""));
|
|
5261
6743
|
}
|
|
5262
6744
|
function isInvalidEnvironmentFileName(fileName) {
|
|
5263
|
-
return !fileName || fileName === "." || fileName === ".." || fileName.startsWith("../") ||
|
|
6745
|
+
return !fileName || fileName === "." || fileName === ".." || fileName.startsWith("../") || import_node_path15.default.posix.isAbsolute(fileName) || /^[A-Za-z]:\//.test(fileName);
|
|
5264
6746
|
}
|
|
5265
6747
|
function normalizeAppFileName(fileName) {
|
|
5266
6748
|
const normalized = normalizeEnvironmentFileName(fileName);
|
|
@@ -5277,14 +6759,14 @@ function collectEnvironmentArtifacts(config, results, appOutDir) {
|
|
|
5277
6759
|
for (const [environmentName, result] of Object.entries(results)) {
|
|
5278
6760
|
const environment = config.environments[environmentName];
|
|
5279
6761
|
if (!environment) continue;
|
|
5280
|
-
const environmentOutDir =
|
|
6762
|
+
const environmentOutDir = import_node_path15.default.resolve(config.root, environment.build.outDir);
|
|
5281
6763
|
for (const artifact of result.output) {
|
|
5282
|
-
const artifactPath =
|
|
6764
|
+
const artifactPath = import_node_path15.default.resolve(
|
|
5283
6765
|
environmentOutDir,
|
|
5284
6766
|
...normalizeEnvironmentFileName(artifact.fileName).split("/")
|
|
5285
6767
|
);
|
|
5286
|
-
const relative =
|
|
5287
|
-
if (!relative.startsWith("..") && !
|
|
6768
|
+
const relative = import_node_path15.default.relative(appOutDir, artifactPath);
|
|
6769
|
+
if (!relative.startsWith("..") && !import_node_path15.default.isAbsolute(relative)) {
|
|
5288
6770
|
occupied.add(artifactCollisionKey(relative));
|
|
5289
6771
|
}
|
|
5290
6772
|
}
|
|
@@ -5294,10 +6776,10 @@ function collectEnvironmentArtifacts(config, results, appOutDir) {
|
|
|
5294
6776
|
function assertNoSymlinkComponents(outDir, fileName) {
|
|
5295
6777
|
let current = outDir;
|
|
5296
6778
|
for (const segment of fileName.split("/")) {
|
|
5297
|
-
current =
|
|
6779
|
+
current = import_node_path15.default.join(current, segment);
|
|
5298
6780
|
let stats;
|
|
5299
6781
|
try {
|
|
5300
|
-
stats =
|
|
6782
|
+
stats = import_node_fs12.default.lstatSync(current);
|
|
5301
6783
|
} catch (error) {
|
|
5302
6784
|
if (error.code === "ENOENT") continue;
|
|
5303
6785
|
throw error;
|
|
@@ -5315,12 +6797,12 @@ function inferEnvironmentEntries(output) {
|
|
|
5315
6797
|
}
|
|
5316
6798
|
return Object.keys(entries).length > 0 ? entries : void 0;
|
|
5317
6799
|
}
|
|
5318
|
-
var
|
|
6800
|
+
var import_node_fs12, import_node_path15;
|
|
5319
6801
|
var init_build_app_context = __esm({
|
|
5320
6802
|
"src/core/build-app-context.ts"() {
|
|
5321
6803
|
"use strict";
|
|
5322
|
-
|
|
5323
|
-
|
|
6804
|
+
import_node_fs12 = __toESM(require("fs"), 1);
|
|
6805
|
+
import_node_path15 = __toESM(require("path"), 1);
|
|
5324
6806
|
}
|
|
5325
6807
|
});
|
|
5326
6808
|
|
|
@@ -5337,7 +6819,7 @@ function getRolldownOptions(environment, entryPoints, rolldownPlugins) {
|
|
|
5337
6819
|
const config = environment.config;
|
|
5338
6820
|
const envOptions = environment.options;
|
|
5339
6821
|
const isServer = environment.consumer === "server";
|
|
5340
|
-
const outDir =
|
|
6822
|
+
const outDir = import_node_path16.default.resolve(config.root, envOptions.build.outDir);
|
|
5341
6823
|
const assetsDir = envOptions.build.assetsDir;
|
|
5342
6824
|
const {
|
|
5343
6825
|
output: userOutput,
|
|
@@ -5377,7 +6859,7 @@ function getRolldownOptions(environment, entryPoints, rolldownPlugins) {
|
|
|
5377
6859
|
// 相对/绝对/虚拟模块照常打包。需要内联依赖时经 rolldownOptions.external 覆盖。
|
|
5378
6860
|
external: restInputOptions.external ?? ((id) => {
|
|
5379
6861
|
if (NODE_BUILTINS2.has(id)) return true;
|
|
5380
|
-
return !id.startsWith(".") && !
|
|
6862
|
+
return !id.startsWith(".") && !import_node_path16.default.isAbsolute(id) && !id.startsWith("\0") && !id.startsWith("virtual:");
|
|
5381
6863
|
})
|
|
5382
6864
|
} : {}
|
|
5383
6865
|
};
|
|
@@ -5534,11 +7016,11 @@ function prepareBuildOutputDirectories(config, buildableNames) {
|
|
|
5534
7016
|
const protectedPaths = /* @__PURE__ */ new Set();
|
|
5535
7017
|
const clientIsBuilt = buildableNames.includes("client");
|
|
5536
7018
|
if (!clientIsBuilt && config.build.emptyOutDir) {
|
|
5537
|
-
directories.add(
|
|
7019
|
+
directories.add(import_node_path16.default.resolve(config.root, config.build.outDir));
|
|
5538
7020
|
}
|
|
5539
7021
|
for (const name of buildableNames) {
|
|
5540
7022
|
const environment = config.environments[name];
|
|
5541
|
-
const outDir =
|
|
7023
|
+
const outDir = import_node_path16.default.resolve(config.root, environment.build.outDir);
|
|
5542
7024
|
if (!environment.build.emptyOutDir) {
|
|
5543
7025
|
protectedPaths.add(outDir);
|
|
5544
7026
|
continue;
|
|
@@ -5546,8 +7028,8 @@ function prepareBuildOutputDirectories(config, buildableNames) {
|
|
|
5546
7028
|
if (!environment.driver) directories.add(outDir);
|
|
5547
7029
|
}
|
|
5548
7030
|
const containsPath = (parent, child) => {
|
|
5549
|
-
const relative =
|
|
5550
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
7031
|
+
const relative = import_node_path16.default.relative(parent, child);
|
|
7032
|
+
return relative === "" || !relative.startsWith("..") && !import_node_path16.default.isAbsolute(relative);
|
|
5551
7033
|
};
|
|
5552
7034
|
const roots = [...directories].filter(
|
|
5553
7035
|
(directory) => ![...protectedPaths].some((protectedPath) => containsPath(directory, protectedPath))
|
|
@@ -5555,7 +7037,7 @@ function prepareBuildOutputDirectories(config, buildableNames) {
|
|
|
5555
7037
|
(directory, index2, all) => !all.slice(0, index2).some((parent) => containsPath(parent, directory))
|
|
5556
7038
|
);
|
|
5557
7039
|
for (const directory of roots) {
|
|
5558
|
-
if (
|
|
7040
|
+
if (import_node_fs13.default.existsSync(directory)) import_node_fs13.default.rmSync(directory, { recursive: true, force: true });
|
|
5559
7041
|
}
|
|
5560
7042
|
}
|
|
5561
7043
|
function assertDriverBuildResult(environment, result) {
|
|
@@ -5574,7 +7056,7 @@ function resolveClientEntries(config, html) {
|
|
|
5574
7056
|
if (configuredEntries.length > 0) return configuredEntries;
|
|
5575
7057
|
const entryPoints = [];
|
|
5576
7058
|
const htmlFile = config.environments.client?.html;
|
|
5577
|
-
const htmlDir = htmlFile ?
|
|
7059
|
+
const htmlDir = htmlFile ? import_node_path16.default.dirname(htmlFile) : config.root;
|
|
5578
7060
|
if (html) {
|
|
5579
7061
|
const scriptMatches = html.matchAll(/<script[^>]+src=["']([^"']+)["'][^>]*>/gi);
|
|
5580
7062
|
for (const match of scriptMatches) {
|
|
@@ -5582,7 +7064,7 @@ function resolveClientEntries(config, html) {
|
|
|
5582
7064
|
if (src && !src.startsWith("http")) {
|
|
5583
7065
|
const cleanSrc = src.split(/[?#]/, 1)[0];
|
|
5584
7066
|
entryPoints.push(
|
|
5585
|
-
cleanSrc.startsWith("/") ?
|
|
7067
|
+
cleanSrc.startsWith("/") ? import_node_path16.default.resolve(config.root, cleanSrc.replace(/^\//, "")) : import_node_path16.default.resolve(htmlDir, cleanSrc)
|
|
5586
7068
|
);
|
|
5587
7069
|
}
|
|
5588
7070
|
}
|
|
@@ -5590,8 +7072,8 @@ function resolveClientEntries(config, html) {
|
|
|
5590
7072
|
if (entryPoints.length === 0) {
|
|
5591
7073
|
const fallbackEntries = ["src/main.ts", "src/main.tsx", "src/main.js", "src/index.ts", "src/index.tsx", "src/index.js"];
|
|
5592
7074
|
for (const entry of fallbackEntries) {
|
|
5593
|
-
const fullPath =
|
|
5594
|
-
if (
|
|
7075
|
+
const fullPath = import_node_path16.default.resolve(config.root, entry);
|
|
7076
|
+
if (import_node_fs13.default.existsSync(fullPath)) {
|
|
5595
7077
|
entryPoints.push(fullPath);
|
|
5596
7078
|
break;
|
|
5597
7079
|
}
|
|
@@ -5600,6 +7082,7 @@ function resolveClientEntries(config, html) {
|
|
|
5600
7082
|
return entryPoints;
|
|
5601
7083
|
}
|
|
5602
7084
|
function createOxcTransformPlugin(config, environment) {
|
|
7085
|
+
if (config.framework === "react") return reactPlugin(config, environment);
|
|
5603
7086
|
return {
|
|
5604
7087
|
name: "nasti:oxc-transform",
|
|
5605
7088
|
transform(code, id) {
|
|
@@ -5620,7 +7103,7 @@ async function build(inlineConfig = {}) {
|
|
|
5620
7103
|
const startTime = performance.now();
|
|
5621
7104
|
logger.info(
|
|
5622
7105
|
import_picocolors6.default.cyan(`
|
|
5623
|
-
nasti v${"2.
|
|
7106
|
+
nasti v${"2.5.1"} `) + import_picocolors6.default.green(`building for ${config.mode}...`)
|
|
5624
7107
|
);
|
|
5625
7108
|
debug6?.(`root: ${config.root}`);
|
|
5626
7109
|
const buildableNames = Object.keys(config.environments).filter((name) => {
|
|
@@ -5695,7 +7178,7 @@ nasti v${"2.4.4"} `) + import_picocolors6.default.green(`building for ${config.m
|
|
|
5695
7178
|
}
|
|
5696
7179
|
async function buildClientEnvironment(config) {
|
|
5697
7180
|
const logger = config.logger;
|
|
5698
|
-
const outDir =
|
|
7181
|
+
const outDir = import_node_path16.default.resolve(config.root, config.build.outDir);
|
|
5699
7182
|
const cssEngine = createCssEngine();
|
|
5700
7183
|
const pluginList = resolvePluginList(config, config.plugins, {
|
|
5701
7184
|
cssEngine,
|
|
@@ -5718,8 +7201,8 @@ async function buildClientEnvironment(config) {
|
|
|
5718
7201
|
assertDriverBuildResult(clientEnv, result);
|
|
5719
7202
|
return { environment: clientEnv, result: finalizeEnvironmentResult(clientEnv, result) };
|
|
5720
7203
|
}
|
|
5721
|
-
|
|
5722
|
-
const htmlFile = config.environments.client.html ??
|
|
7204
|
+
import_node_fs13.default.mkdirSync(outDir, { recursive: true });
|
|
7205
|
+
const htmlFile = config.environments.client.html ?? import_node_path16.default.resolve(config.root, "index.html");
|
|
5723
7206
|
const html = await readHtmlFile(config.root, htmlFile);
|
|
5724
7207
|
const entryPoints = resolveClientEntries(config, html);
|
|
5725
7208
|
if (entryPoints.length === 0) {
|
|
@@ -5769,7 +7252,7 @@ async function buildClientEnvironment(config) {
|
|
|
5769
7252
|
);
|
|
5770
7253
|
}
|
|
5771
7254
|
}
|
|
5772
|
-
|
|
7255
|
+
import_node_fs13.default.writeFileSync(import_node_path16.default.resolve(outDir, "index.html"), processedHtml);
|
|
5773
7256
|
}
|
|
5774
7257
|
if (!nativeReporter && config.logLevel !== "silent") {
|
|
5775
7258
|
reportBuildOutput(output, config, logger);
|
|
@@ -5823,7 +7306,7 @@ async function buildServerEnvironment(config, name) {
|
|
|
5823
7306
|
}
|
|
5824
7307
|
}
|
|
5825
7308
|
for (const entry of envOptions.entry) {
|
|
5826
|
-
if (!
|
|
7309
|
+
if (!import_node_fs13.default.existsSync(entry)) {
|
|
5827
7310
|
await environment.close();
|
|
5828
7311
|
throw new Error(`[nasti] environment "${name}" entry not found: ${entry}`);
|
|
5829
7312
|
}
|
|
@@ -5837,13 +7320,13 @@ async function buildServerEnvironment(config, name) {
|
|
|
5837
7320
|
envOptions.entry,
|
|
5838
7321
|
rolldownPlugins
|
|
5839
7322
|
);
|
|
5840
|
-
|
|
7323
|
+
import_node_fs13.default.mkdirSync(outDir, { recursive: true });
|
|
5841
7324
|
const bundle2 = await (0, import_rolldown.rolldown)(inputOptions);
|
|
5842
7325
|
const { output } = await bundle2.write(outputOptions);
|
|
5843
7326
|
await bundle2.close();
|
|
5844
7327
|
if (cssEngine) environment.setBuildMetadata({ css: getCssMetadata(cssEngine) });
|
|
5845
7328
|
logger.info(
|
|
5846
|
-
import_picocolors6.default.dim(` [${name}] `) + output.map((o) =>
|
|
7329
|
+
import_picocolors6.default.dim(` [${name}] `) + output.map((o) => import_node_path16.default.join(envOptions.build.outDir, o.fileName)).join(import_picocolors6.default.dim(", "))
|
|
5847
7330
|
);
|
|
5848
7331
|
return {
|
|
5849
7332
|
environment,
|
|
@@ -5875,9 +7358,9 @@ function escapeRegExp(string) {
|
|
|
5875
7358
|
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5876
7359
|
}
|
|
5877
7360
|
function replaceEntryScript(html, facadeModuleId, fileName, config, htmlFile, urlPrefix) {
|
|
5878
|
-
const rootRelative =
|
|
5879
|
-
const resolvedHtmlFile =
|
|
5880
|
-
const htmlRelative =
|
|
7361
|
+
const rootRelative = import_node_path16.default.relative(config.root, facadeModuleId).split(import_node_path16.default.sep).join("/");
|
|
7362
|
+
const resolvedHtmlFile = import_node_path16.default.resolve(config.root, htmlFile);
|
|
7363
|
+
const htmlRelative = import_node_path16.default.relative(import_node_path16.default.dirname(resolvedHtmlFile), facadeModuleId).split(import_node_path16.default.sep).join("/");
|
|
5881
7364
|
const candidates = /* @__PURE__ */ new Set([
|
|
5882
7365
|
rootRelative,
|
|
5883
7366
|
`/${rootRelative}`,
|
|
@@ -5893,19 +7376,20 @@ function replaceEntryScript(html, facadeModuleId, fileName, config, htmlFile, ur
|
|
|
5893
7376
|
}
|
|
5894
7377
|
return processed;
|
|
5895
7378
|
}
|
|
5896
|
-
var
|
|
7379
|
+
var import_node_path16, import_node_fs13, import_node_module6, import_rolldown, import_picocolors6, debug6, NODE_BUILTINS2;
|
|
5897
7380
|
var init_build = __esm({
|
|
5898
7381
|
"src/build/index.ts"() {
|
|
5899
7382
|
"use strict";
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
7383
|
+
import_node_path16 = __toESM(require("path"), 1);
|
|
7384
|
+
import_node_fs13 = __toESM(require("fs"), 1);
|
|
7385
|
+
import_node_module6 = require("module");
|
|
5903
7386
|
import_rolldown = require("rolldown");
|
|
5904
7387
|
init_config();
|
|
5905
7388
|
init_builtins();
|
|
5906
7389
|
init_environment();
|
|
5907
7390
|
init_css_engine();
|
|
5908
7391
|
init_html();
|
|
7392
|
+
init_react();
|
|
5909
7393
|
init_transformer();
|
|
5910
7394
|
init_env();
|
|
5911
7395
|
init_reporter();
|
|
@@ -5914,7 +7398,7 @@ var init_build = __esm({
|
|
|
5914
7398
|
init_build_app_context();
|
|
5915
7399
|
import_picocolors6 = __toESM(require("picocolors"), 1);
|
|
5916
7400
|
debug6 = createDebugger("nasti:build");
|
|
5917
|
-
NODE_BUILTINS2 = /* @__PURE__ */ new Set([...
|
|
7401
|
+
NODE_BUILTINS2 = /* @__PURE__ */ new Set([...import_node_module6.builtinModules, ...import_node_module6.builtinModules.map((m) => `node:${m}`)]);
|
|
5918
7402
|
}
|
|
5919
7403
|
});
|
|
5920
7404
|
|
|
@@ -5949,11 +7433,11 @@ async function createBundledDevServer(opts) {
|
|
|
5949
7433
|
const patches = new MemoryFiles();
|
|
5950
7434
|
const entryFileNames = /* @__PURE__ */ new Map();
|
|
5951
7435
|
const bundledClients = /* @__PURE__ */ new Map();
|
|
5952
|
-
const useReactRefresh = config.framework
|
|
7436
|
+
const useReactRefresh = config.framework === "react" && config.server.hmr !== false && refreshWrapperFn != null;
|
|
5953
7437
|
const rolldownPlugins = [
|
|
5954
7438
|
...useReactRefresh ? [
|
|
5955
7439
|
createReactRefreshRuntimePlugin(entryPoints),
|
|
5956
|
-
createBundledOxcRefreshPlugin()
|
|
7440
|
+
createBundledOxcRefreshPlugin(config)
|
|
5957
7441
|
] : [],
|
|
5958
7442
|
...stripCatchAllLoad(toRolldownPlugins(clientEnv.plugins, clientEnv)),
|
|
5959
7443
|
...useReactRefresh ? [
|
|
@@ -6004,7 +7488,7 @@ async function createBundledDevServer(opts) {
|
|
|
6004
7488
|
}
|
|
6005
7489
|
const url = `/${patchPath}`;
|
|
6006
7490
|
logger.info(
|
|
6007
|
-
import_picocolors7.default.green("hmr update ") + import_picocolors7.default.dim(changedFiles.map((f) =>
|
|
7491
|
+
import_picocolors7.default.green("hmr update ") + import_picocolors7.default.dim(changedFiles.map((f) => import_node_path17.default.relative(config.root, f)).join(", ")),
|
|
6008
7492
|
{ timestamp: true }
|
|
6009
7493
|
);
|
|
6010
7494
|
sendTo(clientId, { type: "hmr:update", path: url, url });
|
|
@@ -6159,7 +7643,7 @@ async function createBundledDevServer(opts) {
|
|
|
6159
7643
|
return;
|
|
6160
7644
|
}
|
|
6161
7645
|
res.setHeader("ETag", hit.etag);
|
|
6162
|
-
res.setHeader("Content-Type", MIME_TYPES[
|
|
7646
|
+
res.setHeader("Content-Type", MIME_TYPES[import_node_path17.default.extname(fileName)] ?? "application/octet-stream");
|
|
6163
7647
|
res.setHeader("Cache-Control", "no-cache");
|
|
6164
7648
|
res.once("finish", () => {
|
|
6165
7649
|
void engine.notifyPayloadDelivered(fileName).catch(
|
|
@@ -6200,7 +7684,7 @@ function stripCatchAllLoad(plugins) {
|
|
|
6200
7684
|
);
|
|
6201
7685
|
}
|
|
6202
7686
|
function createReactRefreshRuntimePlugin(entryPoints) {
|
|
6203
|
-
const entryIds = new Set(entryPoints.map((p) =>
|
|
7687
|
+
const entryIds = new Set(entryPoints.map((p) => import_node_path17.default.resolve(p)));
|
|
6204
7688
|
return {
|
|
6205
7689
|
name: "nasti:bundled-react-refresh",
|
|
6206
7690
|
resolveId(source) {
|
|
@@ -6218,24 +7702,27 @@ function createReactRefreshRuntimePlugin(entryPoints) {
|
|
|
6218
7702
|
return null;
|
|
6219
7703
|
},
|
|
6220
7704
|
transform(code, id) {
|
|
6221
|
-
if (!entryIds.has(
|
|
7705
|
+
if (!entryIds.has(import_node_path17.default.resolve(id.split("?")[0]))) return null;
|
|
6222
7706
|
return { code: `import ${JSON.stringify(PREAMBLE_SPEC)};
|
|
6223
7707
|
${code}`, map: null };
|
|
6224
7708
|
}
|
|
6225
7709
|
};
|
|
6226
7710
|
}
|
|
6227
|
-
function createBundledOxcRefreshPlugin() {
|
|
7711
|
+
function createBundledOxcRefreshPlugin(config) {
|
|
6228
7712
|
return {
|
|
6229
7713
|
name: "nasti:bundled-oxc-refresh",
|
|
6230
|
-
transform(code, id) {
|
|
7714
|
+
async transform(code, id) {
|
|
6231
7715
|
const clean = id.split("?")[0];
|
|
6232
|
-
|
|
6233
|
-
|
|
7716
|
+
const result = await transformReactCode(clean, code, {
|
|
7717
|
+
react: config.react,
|
|
7718
|
+
consumer: "client",
|
|
7719
|
+
development: true,
|
|
7720
|
+
reactRefresh: true,
|
|
6234
7721
|
sourcemap: true,
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
reactRefresh: true
|
|
7722
|
+
target: config.build.target,
|
|
7723
|
+
onWarning: (message) => config.logger.warn(`[nasti:react] ${message}`)
|
|
6238
7724
|
});
|
|
7725
|
+
if (!result) return null;
|
|
6239
7726
|
return { code: result.code, map: result.map ? JSON.parse(result.map) : void 0 };
|
|
6240
7727
|
}
|
|
6241
7728
|
};
|
|
@@ -6265,11 +7752,11 @@ async function renderBundledIndexHtml(html, config, entryFileNames) {
|
|
|
6265
7752
|
}
|
|
6266
7753
|
return processed;
|
|
6267
7754
|
}
|
|
6268
|
-
var
|
|
7755
|
+
var import_node_path17, import_node_crypto3, import_ws2, import_picocolors7, debug7, MIME_TYPES, MemoryFiles, PREAMBLE_SPEC, RESOLVED_PREAMBLE_ID, REFRESH_RUNTIME_URL, BUNDLED_PREAMBLE_CODE, WRAPPER_RUNTIME_HELPERS;
|
|
6269
7756
|
var init_dev_engine = __esm({
|
|
6270
7757
|
"src/server/bundled/dev-engine.ts"() {
|
|
6271
7758
|
"use strict";
|
|
6272
|
-
|
|
7759
|
+
import_node_path17 = __toESM(require("path"), 1);
|
|
6273
7760
|
import_node_crypto3 = __toESM(require("crypto"), 1);
|
|
6274
7761
|
import_ws2 = require("ws");
|
|
6275
7762
|
import_picocolors7 = __toESM(require("picocolors"), 1);
|
|
@@ -6479,19 +7966,19 @@ async function createServer(inlineConfig = {}) {
|
|
|
6479
7966
|
app.use(bundledServer.middleware);
|
|
6480
7967
|
}
|
|
6481
7968
|
const ignoredSegments = /* @__PURE__ */ new Set(["node_modules", ".git", ".nasti"]);
|
|
6482
|
-
const outDirAbs =
|
|
7969
|
+
const outDirAbs = import_node_path18.default.resolve(config.root, config.build.outDir);
|
|
6483
7970
|
const linkedPackageRoots = getLinkedPackageRoots(config.root).filter(
|
|
6484
7971
|
(r) => r !== config.root && !isUnderRoot(config.root, r)
|
|
6485
7972
|
);
|
|
6486
7973
|
const watchTargets = [config.root, ...linkedPackageRoots];
|
|
6487
7974
|
const watcher = (0, import_chokidar.watch)(watchTargets, {
|
|
6488
7975
|
ignored: (filePath) => {
|
|
6489
|
-
if (filePath === outDirAbs || filePath.startsWith(outDirAbs +
|
|
7976
|
+
if (filePath === outDirAbs || filePath.startsWith(outDirAbs + import_node_path18.default.sep)) return true;
|
|
6490
7977
|
for (const watchRoot of watchTargets) {
|
|
6491
7978
|
if (filePath === watchRoot) return false;
|
|
6492
|
-
const rel =
|
|
6493
|
-
if (!rel || rel.startsWith("..") ||
|
|
6494
|
-
for (const seg of rel.split(
|
|
7979
|
+
const rel = import_node_path18.default.relative(watchRoot, filePath);
|
|
7980
|
+
if (!rel || rel.startsWith("..") || import_node_path18.default.isAbsolute(rel)) continue;
|
|
7981
|
+
for (const seg of rel.split(import_node_path18.default.sep)) {
|
|
6495
7982
|
if (ignoredSegments.has(seg)) return true;
|
|
6496
7983
|
}
|
|
6497
7984
|
return false;
|
|
@@ -6623,7 +8110,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
6623
8110
|
});
|
|
6624
8111
|
};
|
|
6625
8112
|
watcher.on("change", (file) => {
|
|
6626
|
-
if (file.includes(`${
|
|
8113
|
+
if (file.includes(`${import_node_path18.default.sep}node_modules${import_node_path18.default.sep}`) || file.endsWith(`${import_node_path18.default.sep}node_modules`)) {
|
|
6627
8114
|
clearLinkedPackageRootsCache();
|
|
6628
8115
|
}
|
|
6629
8116
|
ssrRunner?.invalidateFile(file);
|
|
@@ -6631,7 +8118,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
6631
8118
|
notifyEnvironmentDrivers(file, "change");
|
|
6632
8119
|
});
|
|
6633
8120
|
watcher.on("add", (file) => {
|
|
6634
|
-
if (file.includes(`${
|
|
8121
|
+
if (file.includes(`${import_node_path18.default.sep}node_modules${import_node_path18.default.sep}`) || file.endsWith(`${import_node_path18.default.sep}node_modules`)) {
|
|
6635
8122
|
clearLinkedPackageRootsCache();
|
|
6636
8123
|
}
|
|
6637
8124
|
ssrRunner?.invalidateFile(file);
|
|
@@ -6639,7 +8126,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
6639
8126
|
notifyEnvironmentDrivers(file, "add");
|
|
6640
8127
|
});
|
|
6641
8128
|
watcher.on("unlink", (file) => {
|
|
6642
|
-
if (file.includes(`${
|
|
8129
|
+
if (file.includes(`${import_node_path18.default.sep}node_modules${import_node_path18.default.sep}`) || file.endsWith(`${import_node_path18.default.sep}node_modules`)) {
|
|
6643
8130
|
clearLinkedPackageRootsCache();
|
|
6644
8131
|
}
|
|
6645
8132
|
ssrRunner?.invalidateFile(file);
|
|
@@ -6671,7 +8158,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
6671
8158
|
const readyIn = Math.ceil(performance.now() - startTime);
|
|
6672
8159
|
logger.info(
|
|
6673
8160
|
`
|
|
6674
|
-
${import_picocolors8.default.cyan(import_picocolors8.default.bold("NASTI"))} ${import_picocolors8.default.cyan(`v${"2.
|
|
8161
|
+
${import_picocolors8.default.cyan(import_picocolors8.default.bold("NASTI"))} ${import_picocolors8.default.cyan(`v${"2.5.1"}`)} ${import_picocolors8.default.dim("ready in")} ${import_picocolors8.default.bold(readyIn)} ${import_picocolors8.default.dim("ms")}
|
|
6675
8162
|
`
|
|
6676
8163
|
);
|
|
6677
8164
|
printServerUrls(
|
|
@@ -6768,7 +8255,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
6768
8255
|
throw error;
|
|
6769
8256
|
}
|
|
6770
8257
|
app.use(transformMiddleware(transformContexts.get("client")));
|
|
6771
|
-
const publicDir =
|
|
8258
|
+
const publicDir = import_node_path18.default.resolve(config.root, "public");
|
|
6772
8259
|
app.use((0, import_sirv.default)(publicDir, { dev: true, etag: true }));
|
|
6773
8260
|
app.use((0, import_sirv.default)(config.root, { dev: true, etag: true }));
|
|
6774
8261
|
const postMiddlewares = [];
|
|
@@ -6794,12 +8281,12 @@ function getNetworkAddress() {
|
|
|
6794
8281
|
}
|
|
6795
8282
|
return "localhost";
|
|
6796
8283
|
}
|
|
6797
|
-
var import_node_http,
|
|
8284
|
+
var import_node_http, import_node_path18, import_node_os, import_connect, import_sirv, import_chokidar, import_picocolors8;
|
|
6798
8285
|
var init_server = __esm({
|
|
6799
8286
|
"src/server/index.ts"() {
|
|
6800
8287
|
"use strict";
|
|
6801
8288
|
import_node_http = __toESM(require("http"), 1);
|
|
6802
|
-
|
|
8289
|
+
import_node_path18 = __toESM(require("path"), 1);
|
|
6803
8290
|
import_node_os = __toESM(require("os"), 1);
|
|
6804
8291
|
import_connect = __toESM(require("connect"), 1);
|
|
6805
8292
|
import_sirv = __toESM(require("sirv"), 1);
|
|
@@ -6840,14 +8327,14 @@ function electronPlugin(config) {
|
|
|
6840
8327
|
}
|
|
6841
8328
|
};
|
|
6842
8329
|
}
|
|
6843
|
-
var
|
|
8330
|
+
var import_node_module7, NODE_BUILTINS3, ELECTRON_MODULES;
|
|
6844
8331
|
var init_electron = __esm({
|
|
6845
8332
|
"src/plugins/electron.ts"() {
|
|
6846
8333
|
"use strict";
|
|
6847
|
-
|
|
8334
|
+
import_node_module7 = require("module");
|
|
6848
8335
|
NODE_BUILTINS3 = /* @__PURE__ */ new Set([
|
|
6849
|
-
...
|
|
6850
|
-
...
|
|
8336
|
+
...import_node_module7.builtinModules,
|
|
8337
|
+
...import_node_module7.builtinModules.map((m) => `node:${m}`)
|
|
6851
8338
|
]);
|
|
6852
8339
|
ELECTRON_MODULES = /* @__PURE__ */ new Set([
|
|
6853
8340
|
"electron",
|
|
@@ -6870,16 +8357,16 @@ async function buildElectron(inlineConfig = {}) {
|
|
|
6870
8357
|
const config = await resolveConfig({ ...inlineConfig, target: "electron" }, "build");
|
|
6871
8358
|
const startTime = performance.now();
|
|
6872
8359
|
assertElectronVersion(config);
|
|
6873
|
-
console.log(import_picocolors9.default.cyan("\n\u26A1 nasti build (electron)") + import_picocolors9.default.dim(` v${"2.
|
|
8360
|
+
console.log(import_picocolors9.default.cyan("\n\u26A1 nasti build (electron)") + import_picocolors9.default.dim(` v${"2.5.1"}`));
|
|
6874
8361
|
console.log(import_picocolors9.default.dim(` root: ${config.root}`));
|
|
6875
8362
|
console.log(import_picocolors9.default.dim(` mode: ${config.mode}`));
|
|
6876
8363
|
console.log(import_picocolors9.default.dim(` target: electron (\u2265 ${config.electron.minVersion})`));
|
|
6877
|
-
const outDir =
|
|
6878
|
-
if (config.build.emptyOutDir &&
|
|
6879
|
-
|
|
8364
|
+
const outDir = import_node_path19.default.resolve(config.root, config.build.outDir);
|
|
8365
|
+
if (config.build.emptyOutDir && import_node_fs14.default.existsSync(outDir)) {
|
|
8366
|
+
import_node_fs14.default.rmSync(outDir, { recursive: true, force: true });
|
|
6880
8367
|
}
|
|
6881
|
-
|
|
6882
|
-
const rendererOutDir =
|
|
8368
|
+
import_node_fs14.default.mkdirSync(outDir, { recursive: true });
|
|
8369
|
+
const rendererOutDir = import_node_path19.default.join(outDir, "renderer");
|
|
6883
8370
|
const { build: build2 } = await Promise.resolve().then(() => (init_build(), build_exports));
|
|
6884
8371
|
await build2(createElectronRendererConfig(config, inlineConfig, {
|
|
6885
8372
|
build: {
|
|
@@ -6888,8 +8375,8 @@ async function buildElectron(inlineConfig = {}) {
|
|
|
6888
8375
|
emptyOutDir: false
|
|
6889
8376
|
}
|
|
6890
8377
|
}));
|
|
6891
|
-
const mainEntry =
|
|
6892
|
-
if (!
|
|
8378
|
+
const mainEntry = import_node_path19.default.resolve(config.root, config.electron.main);
|
|
8379
|
+
if (!import_node_fs14.default.existsSync(mainEntry)) {
|
|
6893
8380
|
throw new Error(
|
|
6894
8381
|
`Electron main entry not found: ${config.electron.main}
|
|
6895
8382
|
\u5728 nasti.config.ts \u7684 electron.main \u6307\u5B9A\u4E3B\u8FDB\u7A0B\u5165\u53E3\u6587\u4EF6\u3002`
|
|
@@ -6903,11 +8390,11 @@ async function buildElectron(inlineConfig = {}) {
|
|
|
6903
8390
|
const preloadEntries = normalizePreload(config.electron.preload, config.root);
|
|
6904
8391
|
const preloadFiles = [];
|
|
6905
8392
|
for (const entry of preloadEntries) {
|
|
6906
|
-
if (!
|
|
8393
|
+
if (!import_node_fs14.default.existsSync(entry)) {
|
|
6907
8394
|
console.warn(import_picocolors9.default.yellow(` \u26A0 preload entry not found, skipped: ${entry}`));
|
|
6908
8395
|
continue;
|
|
6909
8396
|
}
|
|
6910
|
-
const base =
|
|
8397
|
+
const base = import_node_path19.default.basename(entry).replace(/\.[^.]+$/, "");
|
|
6911
8398
|
const out = outFileName(outDir, base, config.electron.preloadFormat);
|
|
6912
8399
|
await bundleNode(config, entry, {
|
|
6913
8400
|
outFile: out,
|
|
@@ -6919,10 +8406,10 @@ async function buildElectron(inlineConfig = {}) {
|
|
|
6919
8406
|
const elapsed = ((performance.now() - startTime) / 1e3).toFixed(2);
|
|
6920
8407
|
console.log(import_picocolors9.default.green(`
|
|
6921
8408
|
\u2713 Electron build complete in ${elapsed}s`));
|
|
6922
|
-
console.log(import_picocolors9.default.dim(` renderer: ${
|
|
6923
|
-
console.log(import_picocolors9.default.dim(` main: ${
|
|
8409
|
+
console.log(import_picocolors9.default.dim(` renderer: ${import_node_path19.default.relative(config.root, rendererOutDir)}/`));
|
|
8410
|
+
console.log(import_picocolors9.default.dim(` main: ${import_node_path19.default.relative(config.root, mainFile)}`));
|
|
6924
8411
|
for (const pf of preloadFiles) {
|
|
6925
|
-
console.log(import_picocolors9.default.dim(` preload: ${
|
|
8412
|
+
console.log(import_picocolors9.default.dim(` preload: ${import_node_path19.default.relative(config.root, pf)}`));
|
|
6926
8413
|
}
|
|
6927
8414
|
console.log();
|
|
6928
8415
|
return { rendererOutDir, mainFile, preloadFiles };
|
|
@@ -6936,14 +8423,21 @@ async function bundleNode(config, entry, opts) {
|
|
|
6936
8423
|
};
|
|
6937
8424
|
const oxcTransformPlugin = {
|
|
6938
8425
|
name: "nasti:oxc-transform",
|
|
6939
|
-
transform(code, id) {
|
|
6940
|
-
|
|
6941
|
-
|
|
8426
|
+
async transform(code, id) {
|
|
8427
|
+
const result = config.framework === "react" ? await transformReactCode(id, code, {
|
|
8428
|
+
react: config.react,
|
|
8429
|
+
consumer: "server",
|
|
8430
|
+
development: config.mode === "development",
|
|
8431
|
+
sourcemap: !!config.build.sourcemap,
|
|
8432
|
+
target: config.electron.nodeTarget,
|
|
8433
|
+
onWarning: (message) => config.logger.warn(`[nasti:react] ${message}`)
|
|
8434
|
+
}) : shouldTransform(id) ? transformCode(id, code, {
|
|
6942
8435
|
sourcemap: !!config.build.sourcemap,
|
|
6943
8436
|
jsxRuntime: "automatic",
|
|
6944
|
-
jsxImportSource:
|
|
8437
|
+
jsxImportSource: "vue",
|
|
6945
8438
|
target: config.electron.nodeTarget
|
|
6946
|
-
});
|
|
8439
|
+
}) : null;
|
|
8440
|
+
if (!result) return null;
|
|
6947
8441
|
return { code: result.code, map: result.map ? JSON.parse(result.map) : void 0 };
|
|
6948
8442
|
}
|
|
6949
8443
|
};
|
|
@@ -6960,7 +8454,7 @@ async function bundleNode(config, entry, opts) {
|
|
|
6960
8454
|
},
|
|
6961
8455
|
plugins: [oxcTransformPlugin, electronPlugin(config), resolvePlugin(config)]
|
|
6962
8456
|
});
|
|
6963
|
-
|
|
8457
|
+
import_node_fs14.default.mkdirSync(import_node_path19.default.dirname(opts.outFile), { recursive: true });
|
|
6964
8458
|
await bundle2.write({
|
|
6965
8459
|
sourcemap: !!config.build.sourcemap,
|
|
6966
8460
|
minify: !!config.build.minify,
|
|
@@ -6971,7 +8465,7 @@ async function bundleNode(config, entry, opts) {
|
|
|
6971
8465
|
codeSplitting: false
|
|
6972
8466
|
});
|
|
6973
8467
|
await bundle2.close();
|
|
6974
|
-
console.log(import_picocolors9.default.dim(` \u2713 ${opts.label} \u2192 ${
|
|
8468
|
+
console.log(import_picocolors9.default.dim(` \u2713 ${opts.label} \u2192 ${import_node_path19.default.relative(config.root, opts.outFile)}`));
|
|
6975
8469
|
return opts.outFile;
|
|
6976
8470
|
}
|
|
6977
8471
|
function createElectronRendererConfig(config, inlineConfig = {}, overrides = {}) {
|
|
@@ -6993,13 +8487,13 @@ function createElectronRendererConfig(config, inlineConfig = {}, overrides = {})
|
|
|
6993
8487
|
}
|
|
6994
8488
|
};
|
|
6995
8489
|
}
|
|
6996
|
-
function outFileName(outDir, base,
|
|
6997
|
-
const ext =
|
|
6998
|
-
return
|
|
8490
|
+
function outFileName(outDir, base, format2) {
|
|
8491
|
+
const ext = format2 === "cjs" ? ".cjs" : ".mjs";
|
|
8492
|
+
return import_node_path19.default.join(outDir, base + ext);
|
|
6999
8493
|
}
|
|
7000
8494
|
function normalizePreload(preload, root) {
|
|
7001
8495
|
const list = Array.isArray(preload) ? preload : preload ? [preload] : [];
|
|
7002
|
-
return list.map((p) =>
|
|
8496
|
+
return list.map((p) => import_node_path19.default.resolve(root, p));
|
|
7003
8497
|
}
|
|
7004
8498
|
function assertElectronVersion(config) {
|
|
7005
8499
|
const min = config.electron.minVersion;
|
|
@@ -7014,16 +8508,16 @@ function assertElectronVersion(config) {
|
|
|
7014
8508
|
}
|
|
7015
8509
|
function detectInstalledElectron(root) {
|
|
7016
8510
|
try {
|
|
7017
|
-
const require2 = (0,
|
|
8511
|
+
const require2 = (0, import_node_module8.createRequire)(import_node_path19.default.resolve(root, "package.json"));
|
|
7018
8512
|
const pkgPath = require2.resolve("electron/package.json");
|
|
7019
|
-
const pkg = JSON.parse(
|
|
8513
|
+
const pkg = JSON.parse(import_node_fs14.default.readFileSync(pkgPath, "utf-8"));
|
|
7020
8514
|
const major = parseInt(String(pkg.version).split(".")[0], 10);
|
|
7021
8515
|
return Number.isFinite(major) ? major : null;
|
|
7022
8516
|
} catch {
|
|
7023
8517
|
try {
|
|
7024
|
-
const pkgPath =
|
|
7025
|
-
if (!
|
|
7026
|
-
const pkg = JSON.parse(
|
|
8518
|
+
const pkgPath = import_node_path19.default.resolve(root, "node_modules/electron/package.json");
|
|
8519
|
+
if (!import_node_fs14.default.existsSync(pkgPath)) return null;
|
|
8520
|
+
const pkg = JSON.parse(import_node_fs14.default.readFileSync(pkgPath, "utf-8"));
|
|
7027
8521
|
const major = parseInt(String(pkg.version).split(".")[0], 10);
|
|
7028
8522
|
return Number.isFinite(major) ? major : null;
|
|
7029
8523
|
} catch {
|
|
@@ -7031,13 +8525,13 @@ function detectInstalledElectron(root) {
|
|
|
7031
8525
|
}
|
|
7032
8526
|
}
|
|
7033
8527
|
}
|
|
7034
|
-
var
|
|
8528
|
+
var import_node_path19, import_node_fs14, import_node_module8, import_rolldown2, import_picocolors9;
|
|
7035
8529
|
var init_electron2 = __esm({
|
|
7036
8530
|
"src/build/electron.ts"() {
|
|
7037
8531
|
"use strict";
|
|
7038
|
-
|
|
7039
|
-
|
|
7040
|
-
|
|
8532
|
+
import_node_path19 = __toESM(require("path"), 1);
|
|
8533
|
+
import_node_fs14 = __toESM(require("fs"), 1);
|
|
8534
|
+
import_node_module8 = require("module");
|
|
7041
8535
|
import_rolldown2 = require("rolldown");
|
|
7042
8536
|
import_picocolors9 = __toESM(require("picocolors"), 1);
|
|
7043
8537
|
init_config();
|
|
@@ -7058,7 +8552,7 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
7058
8552
|
const { noSpawn, ...rest } = inlineConfig;
|
|
7059
8553
|
const config = await resolveConfig({ ...rest, target: "electron" }, "serve");
|
|
7060
8554
|
warnElectronVersion(config);
|
|
7061
|
-
console.log(import_picocolors10.default.cyan("\n\u26A1 nasti electron dev") + import_picocolors10.default.dim(` v${"2.
|
|
8555
|
+
console.log(import_picocolors10.default.cyan("\n\u26A1 nasti electron dev") + import_picocolors10.default.dim(` v${"2.5.1"}`));
|
|
7062
8556
|
const { createServer: createServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
|
|
7063
8557
|
const server = await createServer2({
|
|
7064
8558
|
...rest,
|
|
@@ -7068,11 +8562,11 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
7068
8562
|
await server.listen();
|
|
7069
8563
|
const devUrl = `http://localhost:${server.config.server.port}` + electronRendererDevPath(config.electron.renderer);
|
|
7070
8564
|
console.log(import_picocolors10.default.dim(` renderer: ${devUrl}`));
|
|
7071
|
-
const stageDir =
|
|
7072
|
-
|
|
7073
|
-
const mainEntry =
|
|
8565
|
+
const stageDir = import_node_path20.default.resolve(config.root, ".nasti");
|
|
8566
|
+
import_node_fs15.default.mkdirSync(stageDir, { recursive: true });
|
|
8567
|
+
const mainEntry = import_node_path20.default.resolve(config.root, config.electron.main);
|
|
7074
8568
|
const preloadEntries = normalizePreload(config.electron.preload, config.root);
|
|
7075
|
-
const builtMainFile =
|
|
8569
|
+
const builtMainFile = import_node_path20.default.join(stageDir, "main" + extFor(config.electron.mainFormat));
|
|
7076
8570
|
const builtPreloadFiles = [];
|
|
7077
8571
|
const compileAll = async () => {
|
|
7078
8572
|
await compileNode(config, mainEntry, {
|
|
@@ -7082,9 +8576,9 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
7082
8576
|
});
|
|
7083
8577
|
builtPreloadFiles.length = 0;
|
|
7084
8578
|
for (const entry of preloadEntries) {
|
|
7085
|
-
if (!
|
|
7086
|
-
const base =
|
|
7087
|
-
const out =
|
|
8579
|
+
if (!import_node_fs15.default.existsSync(entry)) continue;
|
|
8580
|
+
const base = import_node_path20.default.basename(entry).replace(/\.[^.]+$/, "");
|
|
8581
|
+
const out = import_node_path20.default.join(stageDir, base + extFor(config.electron.preloadFormat));
|
|
7088
8582
|
await compileNode(config, entry, {
|
|
7089
8583
|
outFile: out,
|
|
7090
8584
|
format: config.electron.preloadFormat,
|
|
@@ -7123,7 +8617,7 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
7123
8617
|
};
|
|
7124
8618
|
spawnElectron();
|
|
7125
8619
|
if (config.electron.autoRestart) {
|
|
7126
|
-
const watchTargets = [mainEntry, ...preloadEntries].filter(
|
|
8620
|
+
const watchTargets = [mainEntry, ...preloadEntries].filter(import_node_fs15.default.existsSync);
|
|
7127
8621
|
const watcher = import_chokidar2.default.watch(watchTargets, { ignoreInitial: true });
|
|
7128
8622
|
let restarting = null;
|
|
7129
8623
|
let pending = false;
|
|
@@ -7170,8 +8664,8 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
7170
8664
|
});
|
|
7171
8665
|
}
|
|
7172
8666
|
}
|
|
7173
|
-
function extFor(
|
|
7174
|
-
return
|
|
8667
|
+
function extFor(format2) {
|
|
8668
|
+
return format2 === "cjs" ? ".cjs" : ".mjs";
|
|
7175
8669
|
}
|
|
7176
8670
|
async function compileNode(config, entry, opts) {
|
|
7177
8671
|
const env = loadEnv(config.mode, config.root, config.envPrefix);
|
|
@@ -7183,14 +8677,21 @@ async function compileNode(config, entry, opts) {
|
|
|
7183
8677
|
};
|
|
7184
8678
|
const oxcTransformPlugin = {
|
|
7185
8679
|
name: "nasti:oxc-transform",
|
|
7186
|
-
transform(code, id) {
|
|
7187
|
-
|
|
7188
|
-
|
|
8680
|
+
async transform(code, id) {
|
|
8681
|
+
const result = config.framework === "react" ? await transformReactCode(id, code, {
|
|
8682
|
+
react: config.react,
|
|
8683
|
+
consumer: "server",
|
|
8684
|
+
development: true,
|
|
8685
|
+
sourcemap: true,
|
|
8686
|
+
target: config.electron.nodeTarget,
|
|
8687
|
+
onWarning: (message) => config.logger.warn(`[nasti:react] ${message}`)
|
|
8688
|
+
}) : shouldTransform(id) ? transformCode(id, code, {
|
|
7189
8689
|
sourcemap: true,
|
|
7190
8690
|
jsxRuntime: "automatic",
|
|
7191
|
-
jsxImportSource:
|
|
8691
|
+
jsxImportSource: "vue",
|
|
7192
8692
|
target: config.electron.nodeTarget
|
|
7193
|
-
});
|
|
8693
|
+
}) : null;
|
|
8694
|
+
if (!result) return null;
|
|
7194
8695
|
return { code: result.code, map: result.map ? JSON.parse(result.map) : void 0 };
|
|
7195
8696
|
}
|
|
7196
8697
|
};
|
|
@@ -7203,7 +8704,7 @@ async function compileNode(config, entry, opts) {
|
|
|
7203
8704
|
platform: "node",
|
|
7204
8705
|
plugins: [oxcTransformPlugin, electronPlugin(config), resolvePlugin(config)]
|
|
7205
8706
|
});
|
|
7206
|
-
|
|
8707
|
+
import_node_fs15.default.mkdirSync(import_node_path20.default.dirname(opts.outFile), { recursive: true });
|
|
7207
8708
|
await bundle2.write({
|
|
7208
8709
|
file: opts.outFile,
|
|
7209
8710
|
format: opts.format === "cjs" ? "cjs" : "esm",
|
|
@@ -7216,18 +8717,18 @@ async function compileNode(config, entry, opts) {
|
|
|
7216
8717
|
await bundle2.close();
|
|
7217
8718
|
}
|
|
7218
8719
|
function electronRendererDevPath(renderer) {
|
|
7219
|
-
const normalized = renderer.split(
|
|
8720
|
+
const normalized = renderer.split(import_node_path20.default.sep).join("/").replace(/^\.?\//, "");
|
|
7220
8721
|
return normalized === "index.html" ? "/" : `/${normalized}`;
|
|
7221
8722
|
}
|
|
7222
8723
|
function resolveElectronBinary(config) {
|
|
7223
|
-
if (config.electron.electronPath &&
|
|
8724
|
+
if (config.electron.electronPath && import_node_fs15.default.existsSync(config.electron.electronPath)) {
|
|
7224
8725
|
return config.electron.electronPath;
|
|
7225
8726
|
}
|
|
7226
8727
|
try {
|
|
7227
|
-
const require2 = (0,
|
|
8728
|
+
const require2 = (0, import_node_module9.createRequire)(import_node_path20.default.resolve(config.root, "package.json"));
|
|
7228
8729
|
const pathFile = require2.resolve("electron");
|
|
7229
8730
|
const electronModule = require2(pathFile);
|
|
7230
|
-
if (typeof electronModule === "string" &&
|
|
8731
|
+
if (typeof electronModule === "string" && import_node_fs15.default.existsSync(electronModule)) {
|
|
7231
8732
|
return electronModule;
|
|
7232
8733
|
}
|
|
7233
8734
|
} catch {
|
|
@@ -7252,13 +8753,13 @@ function warnElectronVersion(config) {
|
|
|
7252
8753
|
);
|
|
7253
8754
|
}
|
|
7254
8755
|
}
|
|
7255
|
-
var
|
|
8756
|
+
var import_node_path20, import_node_fs15, import_node_module9, import_node_child_process, import_chokidar2, import_picocolors10, import_rolldown3;
|
|
7256
8757
|
var init_electron_dev = __esm({
|
|
7257
8758
|
"src/server/electron-dev.ts"() {
|
|
7258
8759
|
"use strict";
|
|
7259
|
-
|
|
7260
|
-
|
|
7261
|
-
|
|
8760
|
+
import_node_path20 = __toESM(require("path"), 1);
|
|
8761
|
+
import_node_fs15 = __toESM(require("fs"), 1);
|
|
8762
|
+
import_node_module9 = require("module");
|
|
7262
8763
|
import_node_child_process = require("child_process");
|
|
7263
8764
|
import_chokidar2 = __toESM(require("chokidar"), 1);
|
|
7264
8765
|
import_picocolors10 = __toESM(require("picocolors"), 1);
|
|
@@ -7410,20 +8911,20 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
|
|
|
7410
8911
|
const logger = createCliLogger(options);
|
|
7411
8912
|
try {
|
|
7412
8913
|
const http2 = await import("http");
|
|
7413
|
-
const
|
|
8914
|
+
const path21 = await import("path");
|
|
7414
8915
|
const os2 = await import("os");
|
|
7415
8916
|
const sirv2 = (await import("sirv")).default;
|
|
7416
8917
|
const connect2 = (await import("connect")).default;
|
|
7417
8918
|
const { printServerUrls: printServerUrls2 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
|
|
7418
|
-
const resolvedRoot =
|
|
7419
|
-
const outDir =
|
|
8919
|
+
const resolvedRoot = path21.resolve(root ?? ".");
|
|
8920
|
+
const outDir = path21.resolve(resolvedRoot, options.outDir);
|
|
7420
8921
|
const app = connect2();
|
|
7421
8922
|
app.use(sirv2(outDir, { single: true, etag: true, gzip: true, brotli: true }));
|
|
7422
8923
|
const port = options.port;
|
|
7423
8924
|
const host = options.host === true ? "0.0.0.0" : options.host ?? "localhost";
|
|
7424
8925
|
http2.createServer(app).listen(port, host, () => {
|
|
7425
8926
|
logger.info(`
|
|
7426
|
-
${import_picocolors11.default.cyan(import_picocolors11.default.bold("NASTI"))} ${import_picocolors11.default.cyan(`v${"2.
|
|
8927
|
+
${import_picocolors11.default.cyan(import_picocolors11.default.bold("NASTI"))} ${import_picocolors11.default.cyan(`v${"2.5.1"}`)} ${import_picocolors11.default.dim("preview")}
|
|
7427
8928
|
`);
|
|
7428
8929
|
printServerUrls2(
|
|
7429
8930
|
{
|
|
@@ -7440,6 +8941,6 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
|
|
|
7440
8941
|
}
|
|
7441
8942
|
});
|
|
7442
8943
|
cli.help();
|
|
7443
|
-
cli.version("2.
|
|
8944
|
+
cli.version("2.5.1");
|
|
7444
8945
|
cli.parse();
|
|
7445
8946
|
//# sourceMappingURL=cli.cjs.map
|