@nasti-toolchain/nasti 2.5.0 → 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/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) => (path19) => {
9
- var fn = map[path19];
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: " + path19);
11
+ throw new Error("Module not found in bundle: " + path21);
12
12
  };
13
- var __esm = (fn, res) => function __init() {
14
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
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
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
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 format(type, msg, options2 = {}) {
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](format(type, msg, options2), import_picocolors.default.yellow(`(x${sameCount + 1})`));
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](format(type, msg, options2));
97
+ console_[method](format2(type, msg, options2));
89
98
  }
90
99
  } else {
91
- console_[method](format(type, msg, options2));
100
+ console_[method](format2(type, msg, options2));
92
101
  }
93
102
  }
94
103
  const warnedMessages = /* @__PURE__ */ new Set();
@@ -2322,8 +2331,8 @@ function rewriteExternalRequires(code, baseDir, root) {
2322
2331
  }
2323
2332
  async function injectCjsNamedExports(code, entryFile) {
2324
2333
  try {
2325
- const { createRequire: createRequire7 } = await import("module");
2326
- const req = createRequire7(entryFile);
2334
+ const { createRequire: createRequire6 } = await import("module");
2335
+ const req = createRequire6(entryFile);
2327
2336
  const cjsExports = req(entryFile);
2328
2337
  if (!cjsExports || typeof cjsExports !== "object" && typeof cjsExports !== "function" || Array.isArray(cjsExports)) return code;
2329
2338
  const namedKeys = Object.keys(cjsExports).filter(
@@ -3323,27 +3332,27 @@ var require_process = __commonJS({
3323
3332
  var require_filesystem = __commonJS({
3324
3333
  "node_modules/detect-libc/lib/filesystem.js"(exports2, module2) {
3325
3334
  "use strict";
3326
- var fs14 = require("fs");
3335
+ var fs15 = require("fs");
3327
3336
  var LDD_PATH = "/usr/bin/ldd";
3328
3337
  var SELF_PATH = "/proc/self/exe";
3329
3338
  var MAX_LENGTH = 2048;
3330
- var readFileSync = (path19) => {
3331
- const fd = fs14.openSync(path19, "r");
3339
+ var readFileSync = (path21) => {
3340
+ const fd = fs15.openSync(path21, "r");
3332
3341
  const buffer = Buffer.alloc(MAX_LENGTH);
3333
- const bytesRead = fs14.readSync(fd, buffer, 0, MAX_LENGTH, 0);
3334
- fs14.close(fd, () => {
3342
+ const bytesRead = fs15.readSync(fd, buffer, 0, MAX_LENGTH, 0);
3343
+ fs15.close(fd, () => {
3335
3344
  });
3336
3345
  return buffer.subarray(0, bytesRead);
3337
3346
  };
3338
- var readFile = (path19) => new Promise((resolve, reject) => {
3339
- fs14.open(path19, "r", (err, fd) => {
3347
+ var readFile = (path21) => new Promise((resolve, reject) => {
3348
+ fs15.open(path21, "r", (err, fd) => {
3340
3349
  if (err) {
3341
3350
  reject(err);
3342
3351
  } else {
3343
3352
  const buffer = Buffer.alloc(MAX_LENGTH);
3344
- fs14.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
3353
+ fs15.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
3345
3354
  resolve(buffer.subarray(0, bytesRead));
3346
- fs14.close(fd, () => {
3355
+ fs15.close(fd, () => {
3347
3356
  });
3348
3357
  });
3349
3358
  }
@@ -3455,11 +3464,11 @@ var require_detect_libc = __commonJS({
3455
3464
  }
3456
3465
  return null;
3457
3466
  };
3458
- var familyFromInterpreterPath = (path19) => {
3459
- if (path19) {
3460
- if (path19.includes("/ld-musl-")) {
3467
+ var familyFromInterpreterPath = (path21) => {
3468
+ if (path21) {
3469
+ if (path21.includes("/ld-musl-")) {
3461
3470
  return MUSL;
3462
- } else if (path19.includes("/ld-linux-")) {
3471
+ } else if (path21.includes("/ld-linux-")) {
3463
3472
  return GLIBC;
3464
3473
  }
3465
3474
  }
@@ -3506,8 +3515,8 @@ var require_detect_libc = __commonJS({
3506
3515
  cachedFamilyInterpreter = null;
3507
3516
  try {
3508
3517
  const selfContent = await readFile(SELF_PATH);
3509
- const path19 = interpreterPath(selfContent);
3510
- cachedFamilyInterpreter = familyFromInterpreterPath(path19);
3518
+ const path21 = interpreterPath(selfContent);
3519
+ cachedFamilyInterpreter = familyFromInterpreterPath(path21);
3511
3520
  } catch (e) {
3512
3521
  }
3513
3522
  return cachedFamilyInterpreter;
@@ -3519,8 +3528,8 @@ var require_detect_libc = __commonJS({
3519
3528
  cachedFamilyInterpreter = null;
3520
3529
  try {
3521
3530
  const selfContent = readFileSync(SELF_PATH);
3522
- const path19 = interpreterPath(selfContent);
3523
- cachedFamilyInterpreter = familyFromInterpreterPath(path19);
3531
+ const path21 = interpreterPath(selfContent);
3532
+ cachedFamilyInterpreter = familyFromInterpreterPath(path21);
3524
3533
  } catch (e) {
3525
3534
  }
3526
3535
  return cachedFamilyInterpreter;
@@ -4542,8 +4551,8 @@ function vuePlugin(config, environmentName = "client") {
4542
4551
  let cached2 = descriptorCache.get(filePath);
4543
4552
  if (!cached2) {
4544
4553
  try {
4545
- const fs14 = await import("fs");
4546
- const rawSource = fs14.readFileSync(filePath, "utf-8");
4554
+ const fs15 = await import("fs");
4555
+ const rawSource = fs15.readFileSync(filePath, "utf-8");
4547
4556
  const transformedSfc = await applySourceTransform(
4548
4557
  vueOptions.transformSfc,
4549
4558
  rawSource,
@@ -4967,6 +4976,1310 @@ var init_builtins = __esm({
4967
4976
  }
4968
4977
  });
4969
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
+
4970
6283
  // src/server/runnable-environment.ts
4971
6284
  var runnable_environment_exports = {};
4972
6285
  __export(runnable_environment_exports, {
@@ -4981,25 +6294,27 @@ function createModuleRunner(environment) {
4981
6294
  }
4982
6295
  return new NastiModuleRunner(environment);
4983
6296
  }
4984
- var import_node_path11, import_node_fs9, import_node_module4, import_node_url4, debug4, NODE_BUILTINS, NastiModuleRunner, AsyncFunction;
6297
+ var import_node_path13, import_node_fs11, import_node_module5, import_node_url7, debug4, NODE_BUILTINS, NastiModuleRunner, AsyncFunction;
4985
6298
  var init_runnable_environment = __esm({
4986
6299
  "src/server/runnable-environment.ts"() {
4987
6300
  "use strict";
4988
- import_node_path11 = __toESM(require("path"), 1);
4989
- import_node_fs9 = __toESM(require("fs"), 1);
4990
- import_node_module4 = require("module");
4991
- import_node_url4 = require("url");
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();
4992
6306
  init_transformer();
4993
6307
  init_env();
4994
6308
  init_debug();
4995
6309
  debug4 = createDebugger("nasti:ssr");
4996
- NODE_BUILTINS = /* @__PURE__ */ new Set([...import_node_module4.builtinModules, ...import_node_module4.builtinModules.map((m) => `node:${m}`)]);
6310
+ NODE_BUILTINS = /* @__PURE__ */ new Set([...import_node_module5.builtinModules, ...import_node_module5.builtinModules.map((m) => `node:${m}`)]);
4997
6311
  NastiModuleRunner = class {
4998
6312
  environment;
4999
6313
  config;
5000
6314
  cache = /* @__PURE__ */ new Map();
5001
6315
  envDefine;
5002
- require;
6316
+ externalImportParent;
6317
+ externalImportConditions;
5003
6318
  constructor(environment) {
5004
6319
  this.environment = environment;
5005
6320
  this.config = environment.config;
@@ -5008,10 +6323,15 @@ var init_runnable_environment = __esm({
5008
6323
  this.config.mode,
5009
6324
  ssrDefineOverrides(environment.consumer)
5010
6325
  );
5011
- this.require = (0, import_node_module4.createRequire)(import_node_path11.default.join(this.config.root, "package.json"));
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
+ ]);
5012
6332
  const handlers = {
5013
6333
  fetchModule: async (id, importer) => this.fetchModule(id, importer),
5014
- getBuiltins: () => [/^node:/, ...import_node_module4.builtinModules]
6334
+ getBuiltins: () => [/^node:/, ...import_node_module5.builtinModules]
5015
6335
  };
5016
6336
  environment.hot.setInvokeHandler?.(handlers);
5017
6337
  }
@@ -5032,9 +6352,9 @@ var init_runnable_environment = __esm({
5032
6352
  this.cache.clear();
5033
6353
  }
5034
6354
  resolveToId(rawUrl) {
5035
- if (import_node_path11.default.isAbsolute(rawUrl) && import_node_fs9.default.existsSync(rawUrl.split("?")[0])) return rawUrl;
6355
+ if (import_node_path13.default.isAbsolute(rawUrl) && import_node_fs11.default.existsSync(rawUrl.split("?")[0])) return rawUrl;
5036
6356
  const clean = rawUrl.replace(/^\//, "");
5037
- return import_node_path11.default.resolve(this.config.root, clean);
6357
+ return import_node_path13.default.resolve(this.config.root, clean);
5038
6358
  }
5039
6359
  /**
5040
6360
  * fetchModule(invoke 契约方法):环境管线产出 runner 可执行代码。
@@ -5043,14 +6363,14 @@ var init_runnable_environment = __esm({
5043
6363
  */
5044
6364
  async fetchModule(id, importer) {
5045
6365
  if (NODE_BUILTINS.has(id)) return { externalize: id };
5046
- if (!id.startsWith(".") && !import_node_path11.default.isAbsolute(id) && !id.startsWith("\0")) {
6366
+ if (!id.startsWith(".") && !import_node_path13.default.isAbsolute(id) && !id.startsWith("\0")) {
5047
6367
  return { externalize: id };
5048
6368
  }
5049
6369
  const container = this.environment.pluginContainer;
5050
6370
  let resolvedId = id;
5051
6371
  if (id.startsWith(".") && importer) {
5052
6372
  const resolved = await container.resolveId(id, importer);
5053
- resolvedId = resolved ? typeof resolved === "string" ? resolved : resolved.id : import_node_path11.default.resolve(import_node_path11.default.dirname(importer.split("?")[0]), id);
6373
+ resolvedId = resolved ? typeof resolved === "string" ? resolved : resolved.id : import_node_path13.default.resolve(import_node_path13.default.dirname(importer.split("?")[0]), id);
5054
6374
  }
5055
6375
  resolvedId = this.completeExtension(resolvedId);
5056
6376
  const cleanId = resolvedId.split("?")[0];
@@ -5058,8 +6378,8 @@ var init_runnable_environment = __esm({
5058
6378
  const loaded = await container.load(resolvedId);
5059
6379
  if (loaded != null) {
5060
6380
  code = typeof loaded === "string" ? loaded : loaded.code;
5061
- } else if (import_node_fs9.default.existsSync(cleanId)) {
5062
- code = import_node_fs9.default.readFileSync(cleanId, "utf-8");
6381
+ } else if (import_node_fs11.default.existsSync(cleanId)) {
6382
+ code = import_node_fs11.default.readFileSync(cleanId, "utf-8");
5063
6383
  } else {
5064
6384
  throw new Error(`[nasti:ssr] cannot load module: ${resolvedId}`);
5065
6385
  }
@@ -5113,19 +6433,19 @@ var init_runnable_environment = __esm({
5113
6433
  completeExtension(id) {
5114
6434
  const clean = id.split("?")[0];
5115
6435
  const query = id.includes("?") ? id.slice(id.indexOf("?")) : "";
5116
- if (import_node_fs9.default.existsSync(clean) && import_node_fs9.default.statSync(clean).isFile()) return id;
6436
+ if (import_node_fs11.default.existsSync(clean) && import_node_fs11.default.statSync(clean).isFile()) return id;
5117
6437
  const jsMatch = clean.match(/^(.*)\.([mc]?)jsx?$/);
5118
6438
  if (jsMatch) {
5119
6439
  for (const tsExt of [`.${jsMatch[2]}ts`, `.${jsMatch[2]}tsx`]) {
5120
- if (import_node_fs9.default.existsSync(jsMatch[1] + tsExt)) return jsMatch[1] + tsExt + query;
6440
+ if (import_node_fs11.default.existsSync(jsMatch[1] + tsExt)) return jsMatch[1] + tsExt + query;
5121
6441
  }
5122
6442
  }
5123
6443
  for (const ext of this.config.resolve.extensions) {
5124
- if (import_node_fs9.default.existsSync(clean + ext)) return clean + ext + query;
6444
+ if (import_node_fs11.default.existsSync(clean + ext)) return clean + ext + query;
5125
6445
  }
5126
6446
  for (const ext of this.config.resolve.extensions) {
5127
- const indexPath = import_node_path11.default.join(clean, `index${ext}`);
5128
- if (import_node_fs9.default.existsSync(indexPath)) return indexPath;
6447
+ const indexPath = import_node_path13.default.join(clean, `index${ext}`);
6448
+ if (import_node_fs11.default.existsSync(indexPath)) return indexPath;
5129
6449
  }
5130
6450
  return id;
5131
6451
  }
@@ -5152,10 +6472,10 @@ var init_runnable_environment = __esm({
5152
6472
  return;
5153
6473
  }
5154
6474
  const ssrImport = async (dep) => {
5155
- if (NODE_BUILTINS.has(dep) || !dep.startsWith(".") && !import_node_path11.default.isAbsolute(dep) && !dep.startsWith("\0")) {
6475
+ if (NODE_BUILTINS.has(dep) || !dep.startsWith(".") && !import_node_path13.default.isAbsolute(dep) && !dep.startsWith("\0")) {
5156
6476
  return this.importExternal(dep);
5157
6477
  }
5158
- const depId = dep.startsWith(".") ? this.completeExtension(import_node_path11.default.resolve(import_node_path11.default.dirname(fetched.id.split("?")[0]), dep)) : this.completeExtension(dep);
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);
5159
6479
  return this.instantiate(depId);
5160
6480
  };
5161
6481
  const ssrExportAll = (sourceModule) => {
@@ -5170,7 +6490,7 @@ var init_runnable_environment = __esm({
5170
6490
  }
5171
6491
  };
5172
6492
  const importMeta = {
5173
- url: (0, import_node_url4.pathToFileURL)(fetched.id.split("?")[0]).href,
6493
+ url: (0, import_node_url7.pathToFileURL)(fetched.id.split("?")[0]).href,
5174
6494
  env: { SSR: true, MODE: this.config.mode, DEV: this.config.mode !== "production", PROD: this.config.mode === "production" },
5175
6495
  hot: void 0
5176
6496
  };
@@ -5187,20 +6507,21 @@ var init_runnable_environment = __esm({
5187
6507
  }
5188
6508
  async importExternal(spec) {
5189
6509
  try {
5190
- return await (spec.startsWith("node:") || !import_node_path11.default.isAbsolute(spec) ? import(this.resolveExternalSpecifier(spec)) : import((0, import_node_url4.pathToFileURL)(spec).href));
6510
+ return await (spec.startsWith("node:") || !import_node_path13.default.isAbsolute(spec) ? import(this.resolveExternalSpecifier(spec)) : import((0, import_node_url7.pathToFileURL)(spec).href));
5191
6511
  } catch (err) {
5192
6512
  throw new Error(`[nasti:ssr] failed to import external "${spec}": ${err.message}`);
5193
6513
  }
5194
6514
  }
5195
- /** bare specifier → 项目 node_modules 的绝对 URL(避免相对 Nasti 自身解析) */
6515
+ /** bare specifier → 项目 node_modules ESM URL(避免相对 Nasti 自身解析) */
5196
6516
  resolveExternalSpecifier(spec) {
5197
6517
  if (spec.startsWith("node:")) return spec;
5198
6518
  if (NODE_BUILTINS.has(spec)) return `node:${spec}`;
5199
- try {
5200
- return (0, import_node_url4.pathToFileURL)(this.require.resolve(spec)).href;
5201
- } catch {
5202
- return spec;
5203
- }
6519
+ return moduleResolve(
6520
+ spec,
6521
+ this.externalImportParent,
6522
+ this.externalImportConditions,
6523
+ false
6524
+ ).href;
5204
6525
  }
5205
6526
  };
5206
6527
  AsyncFunction = Object.getPrototypeOf(async function() {
@@ -5285,7 +6606,7 @@ function reportBuildOutput(output, config, logger) {
5285
6606
  if (compressed && content != null) {
5286
6607
  gzip = (0, import_node_zlib.gzipSync)(typeof content === "string" ? Buffer.from(content) : content).byteLength;
5287
6608
  }
5288
- const ext = import_node_path12.default.extname(file.fileName);
6609
+ const ext = import_node_path14.default.extname(file.fileName);
5289
6610
  const group = file.type === "chunk" ? "js" : ext === ".css" ? "css" : "assets";
5290
6611
  entries.push({ name: file.fileName, size, gzip, group });
5291
6612
  }
@@ -5319,11 +6640,11 @@ function warnLargeChunks(output, config, logger) {
5319
6640
  )
5320
6641
  );
5321
6642
  }
5322
- var import_node_path12, import_node_zlib, import_picocolors5, debug5, numberFormatter;
6643
+ var import_node_path14, import_node_zlib, import_picocolors5, debug5, numberFormatter;
5323
6644
  var init_reporter = __esm({
5324
6645
  "src/build/reporter.ts"() {
5325
6646
  "use strict";
5326
- import_node_path12 = __toESM(require("path"), 1);
6647
+ import_node_path14 = __toESM(require("path"), 1);
5327
6648
  import_node_zlib = require("zlib");
5328
6649
  import_picocolors5 = __toESM(require("picocolors"), 1);
5329
6650
  init_debug();
@@ -5339,7 +6660,7 @@ var init_reporter = __esm({
5339
6660
  function createBuildAppContext(config, results) {
5340
6661
  const output = [];
5341
6662
  const emitted = /* @__PURE__ */ new Set();
5342
- const outDir = import_node_path13.default.resolve(config.root, config.build.outDir);
6663
+ const outDir = import_node_path15.default.resolve(config.root, config.build.outDir);
5343
6664
  let environmentArtifacts;
5344
6665
  return {
5345
6666
  config,
@@ -5395,14 +6716,14 @@ function createBuildAppContext(config, results) {
5395
6716
  if (environmentArtifacts.has(collisionKey)) {
5396
6717
  throw new Error(`[nasti] app artifact conflicts with environment output: ${fileName}`);
5397
6718
  }
5398
- const target = import_node_path13.default.resolve(outDir, ...fileName.split("/"));
5399
- const relative = import_node_path13.default.relative(outDir, target);
5400
- if (relative.startsWith("..") || import_node_path13.default.isAbsolute(relative)) {
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)) {
5401
6722
  throw new Error(`[nasti] app artifact must stay inside build.outDir: ${file.fileName}`);
5402
6723
  }
5403
6724
  assertNoSymlinkComponents(outDir, fileName);
5404
- import_node_fs10.default.mkdirSync(import_node_path13.default.dirname(target), { recursive: true });
5405
- import_node_fs10.default.writeFileSync(target, file.source);
6725
+ import_node_fs12.default.mkdirSync(import_node_path15.default.dirname(target), { recursive: true });
6726
+ import_node_fs12.default.writeFileSync(target, file.source);
5406
6727
  const artifact = {
5407
6728
  ...file,
5408
6729
  fileName,
@@ -5418,10 +6739,10 @@ function joinPublicPath(base, fileName) {
5418
6739
  return `${base.endsWith("/") ? base : `${base}/`}${fileName.replace(/^\//, "")}`;
5419
6740
  }
5420
6741
  function normalizeEnvironmentFileName(fileName) {
5421
- return import_node_path13.default.posix.normalize(fileName.replace(/\\/g, "/").replace(/^\.\//, ""));
6742
+ return import_node_path15.default.posix.normalize(fileName.replace(/\\/g, "/").replace(/^\.\//, ""));
5422
6743
  }
5423
6744
  function isInvalidEnvironmentFileName(fileName) {
5424
- return !fileName || fileName === "." || fileName === ".." || fileName.startsWith("../") || import_node_path13.default.posix.isAbsolute(fileName) || /^[A-Za-z]:\//.test(fileName);
6745
+ return !fileName || fileName === "." || fileName === ".." || fileName.startsWith("../") || import_node_path15.default.posix.isAbsolute(fileName) || /^[A-Za-z]:\//.test(fileName);
5425
6746
  }
5426
6747
  function normalizeAppFileName(fileName) {
5427
6748
  const normalized = normalizeEnvironmentFileName(fileName);
@@ -5438,14 +6759,14 @@ function collectEnvironmentArtifacts(config, results, appOutDir) {
5438
6759
  for (const [environmentName, result] of Object.entries(results)) {
5439
6760
  const environment = config.environments[environmentName];
5440
6761
  if (!environment) continue;
5441
- const environmentOutDir = import_node_path13.default.resolve(config.root, environment.build.outDir);
6762
+ const environmentOutDir = import_node_path15.default.resolve(config.root, environment.build.outDir);
5442
6763
  for (const artifact of result.output) {
5443
- const artifactPath = import_node_path13.default.resolve(
6764
+ const artifactPath = import_node_path15.default.resolve(
5444
6765
  environmentOutDir,
5445
6766
  ...normalizeEnvironmentFileName(artifact.fileName).split("/")
5446
6767
  );
5447
- const relative = import_node_path13.default.relative(appOutDir, artifactPath);
5448
- if (!relative.startsWith("..") && !import_node_path13.default.isAbsolute(relative)) {
6768
+ const relative = import_node_path15.default.relative(appOutDir, artifactPath);
6769
+ if (!relative.startsWith("..") && !import_node_path15.default.isAbsolute(relative)) {
5449
6770
  occupied.add(artifactCollisionKey(relative));
5450
6771
  }
5451
6772
  }
@@ -5455,10 +6776,10 @@ function collectEnvironmentArtifacts(config, results, appOutDir) {
5455
6776
  function assertNoSymlinkComponents(outDir, fileName) {
5456
6777
  let current = outDir;
5457
6778
  for (const segment of fileName.split("/")) {
5458
- current = import_node_path13.default.join(current, segment);
6779
+ current = import_node_path15.default.join(current, segment);
5459
6780
  let stats;
5460
6781
  try {
5461
- stats = import_node_fs10.default.lstatSync(current);
6782
+ stats = import_node_fs12.default.lstatSync(current);
5462
6783
  } catch (error) {
5463
6784
  if (error.code === "ENOENT") continue;
5464
6785
  throw error;
@@ -5476,12 +6797,12 @@ function inferEnvironmentEntries(output) {
5476
6797
  }
5477
6798
  return Object.keys(entries).length > 0 ? entries : void 0;
5478
6799
  }
5479
- var import_node_fs10, import_node_path13;
6800
+ var import_node_fs12, import_node_path15;
5480
6801
  var init_build_app_context = __esm({
5481
6802
  "src/core/build-app-context.ts"() {
5482
6803
  "use strict";
5483
- import_node_fs10 = __toESM(require("fs"), 1);
5484
- import_node_path13 = __toESM(require("path"), 1);
6804
+ import_node_fs12 = __toESM(require("fs"), 1);
6805
+ import_node_path15 = __toESM(require("path"), 1);
5485
6806
  }
5486
6807
  });
5487
6808
 
@@ -5498,7 +6819,7 @@ function getRolldownOptions(environment, entryPoints, rolldownPlugins) {
5498
6819
  const config = environment.config;
5499
6820
  const envOptions = environment.options;
5500
6821
  const isServer = environment.consumer === "server";
5501
- const outDir = import_node_path14.default.resolve(config.root, envOptions.build.outDir);
6822
+ const outDir = import_node_path16.default.resolve(config.root, envOptions.build.outDir);
5502
6823
  const assetsDir = envOptions.build.assetsDir;
5503
6824
  const {
5504
6825
  output: userOutput,
@@ -5538,7 +6859,7 @@ function getRolldownOptions(environment, entryPoints, rolldownPlugins) {
5538
6859
  // 相对/绝对/虚拟模块照常打包。需要内联依赖时经 rolldownOptions.external 覆盖。
5539
6860
  external: restInputOptions.external ?? ((id) => {
5540
6861
  if (NODE_BUILTINS2.has(id)) return true;
5541
- return !id.startsWith(".") && !import_node_path14.default.isAbsolute(id) && !id.startsWith("\0") && !id.startsWith("virtual:");
6862
+ return !id.startsWith(".") && !import_node_path16.default.isAbsolute(id) && !id.startsWith("\0") && !id.startsWith("virtual:");
5542
6863
  })
5543
6864
  } : {}
5544
6865
  };
@@ -5695,11 +7016,11 @@ function prepareBuildOutputDirectories(config, buildableNames) {
5695
7016
  const protectedPaths = /* @__PURE__ */ new Set();
5696
7017
  const clientIsBuilt = buildableNames.includes("client");
5697
7018
  if (!clientIsBuilt && config.build.emptyOutDir) {
5698
- directories.add(import_node_path14.default.resolve(config.root, config.build.outDir));
7019
+ directories.add(import_node_path16.default.resolve(config.root, config.build.outDir));
5699
7020
  }
5700
7021
  for (const name of buildableNames) {
5701
7022
  const environment = config.environments[name];
5702
- const outDir = import_node_path14.default.resolve(config.root, environment.build.outDir);
7023
+ const outDir = import_node_path16.default.resolve(config.root, environment.build.outDir);
5703
7024
  if (!environment.build.emptyOutDir) {
5704
7025
  protectedPaths.add(outDir);
5705
7026
  continue;
@@ -5707,8 +7028,8 @@ function prepareBuildOutputDirectories(config, buildableNames) {
5707
7028
  if (!environment.driver) directories.add(outDir);
5708
7029
  }
5709
7030
  const containsPath = (parent, child) => {
5710
- const relative = import_node_path14.default.relative(parent, child);
5711
- return relative === "" || !relative.startsWith("..") && !import_node_path14.default.isAbsolute(relative);
7031
+ const relative = import_node_path16.default.relative(parent, child);
7032
+ return relative === "" || !relative.startsWith("..") && !import_node_path16.default.isAbsolute(relative);
5712
7033
  };
5713
7034
  const roots = [...directories].filter(
5714
7035
  (directory) => ![...protectedPaths].some((protectedPath) => containsPath(directory, protectedPath))
@@ -5716,7 +7037,7 @@ function prepareBuildOutputDirectories(config, buildableNames) {
5716
7037
  (directory, index2, all) => !all.slice(0, index2).some((parent) => containsPath(parent, directory))
5717
7038
  );
5718
7039
  for (const directory of roots) {
5719
- if (import_node_fs11.default.existsSync(directory)) import_node_fs11.default.rmSync(directory, { recursive: true, force: true });
7040
+ if (import_node_fs13.default.existsSync(directory)) import_node_fs13.default.rmSync(directory, { recursive: true, force: true });
5720
7041
  }
5721
7042
  }
5722
7043
  function assertDriverBuildResult(environment, result) {
@@ -5735,7 +7056,7 @@ function resolveClientEntries(config, html) {
5735
7056
  if (configuredEntries.length > 0) return configuredEntries;
5736
7057
  const entryPoints = [];
5737
7058
  const htmlFile = config.environments.client?.html;
5738
- const htmlDir = htmlFile ? import_node_path14.default.dirname(htmlFile) : config.root;
7059
+ const htmlDir = htmlFile ? import_node_path16.default.dirname(htmlFile) : config.root;
5739
7060
  if (html) {
5740
7061
  const scriptMatches = html.matchAll(/<script[^>]+src=["']([^"']+)["'][^>]*>/gi);
5741
7062
  for (const match of scriptMatches) {
@@ -5743,7 +7064,7 @@ function resolveClientEntries(config, html) {
5743
7064
  if (src && !src.startsWith("http")) {
5744
7065
  const cleanSrc = src.split(/[?#]/, 1)[0];
5745
7066
  entryPoints.push(
5746
- cleanSrc.startsWith("/") ? import_node_path14.default.resolve(config.root, cleanSrc.replace(/^\//, "")) : import_node_path14.default.resolve(htmlDir, cleanSrc)
7067
+ cleanSrc.startsWith("/") ? import_node_path16.default.resolve(config.root, cleanSrc.replace(/^\//, "")) : import_node_path16.default.resolve(htmlDir, cleanSrc)
5747
7068
  );
5748
7069
  }
5749
7070
  }
@@ -5751,8 +7072,8 @@ function resolveClientEntries(config, html) {
5751
7072
  if (entryPoints.length === 0) {
5752
7073
  const fallbackEntries = ["src/main.ts", "src/main.tsx", "src/main.js", "src/index.ts", "src/index.tsx", "src/index.js"];
5753
7074
  for (const entry of fallbackEntries) {
5754
- const fullPath = import_node_path14.default.resolve(config.root, entry);
5755
- if (import_node_fs11.default.existsSync(fullPath)) {
7075
+ const fullPath = import_node_path16.default.resolve(config.root, entry);
7076
+ if (import_node_fs13.default.existsSync(fullPath)) {
5756
7077
  entryPoints.push(fullPath);
5757
7078
  break;
5758
7079
  }
@@ -5782,7 +7103,7 @@ async function build(inlineConfig = {}) {
5782
7103
  const startTime = performance.now();
5783
7104
  logger.info(
5784
7105
  import_picocolors6.default.cyan(`
5785
- nasti v${"2.5.0"} `) + import_picocolors6.default.green(`building for ${config.mode}...`)
7106
+ nasti v${"2.5.1"} `) + import_picocolors6.default.green(`building for ${config.mode}...`)
5786
7107
  );
5787
7108
  debug6?.(`root: ${config.root}`);
5788
7109
  const buildableNames = Object.keys(config.environments).filter((name) => {
@@ -5857,7 +7178,7 @@ nasti v${"2.5.0"} `) + import_picocolors6.default.green(`building for ${config.m
5857
7178
  }
5858
7179
  async function buildClientEnvironment(config) {
5859
7180
  const logger = config.logger;
5860
- const outDir = import_node_path14.default.resolve(config.root, config.build.outDir);
7181
+ const outDir = import_node_path16.default.resolve(config.root, config.build.outDir);
5861
7182
  const cssEngine = createCssEngine();
5862
7183
  const pluginList = resolvePluginList(config, config.plugins, {
5863
7184
  cssEngine,
@@ -5880,8 +7201,8 @@ async function buildClientEnvironment(config) {
5880
7201
  assertDriverBuildResult(clientEnv, result);
5881
7202
  return { environment: clientEnv, result: finalizeEnvironmentResult(clientEnv, result) };
5882
7203
  }
5883
- import_node_fs11.default.mkdirSync(outDir, { recursive: true });
5884
- const htmlFile = config.environments.client.html ?? import_node_path14.default.resolve(config.root, "index.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");
5885
7206
  const html = await readHtmlFile(config.root, htmlFile);
5886
7207
  const entryPoints = resolveClientEntries(config, html);
5887
7208
  if (entryPoints.length === 0) {
@@ -5931,7 +7252,7 @@ async function buildClientEnvironment(config) {
5931
7252
  );
5932
7253
  }
5933
7254
  }
5934
- import_node_fs11.default.writeFileSync(import_node_path14.default.resolve(outDir, "index.html"), processedHtml);
7255
+ import_node_fs13.default.writeFileSync(import_node_path16.default.resolve(outDir, "index.html"), processedHtml);
5935
7256
  }
5936
7257
  if (!nativeReporter && config.logLevel !== "silent") {
5937
7258
  reportBuildOutput(output, config, logger);
@@ -5985,7 +7306,7 @@ async function buildServerEnvironment(config, name) {
5985
7306
  }
5986
7307
  }
5987
7308
  for (const entry of envOptions.entry) {
5988
- if (!import_node_fs11.default.existsSync(entry)) {
7309
+ if (!import_node_fs13.default.existsSync(entry)) {
5989
7310
  await environment.close();
5990
7311
  throw new Error(`[nasti] environment "${name}" entry not found: ${entry}`);
5991
7312
  }
@@ -5999,13 +7320,13 @@ async function buildServerEnvironment(config, name) {
5999
7320
  envOptions.entry,
6000
7321
  rolldownPlugins
6001
7322
  );
6002
- import_node_fs11.default.mkdirSync(outDir, { recursive: true });
7323
+ import_node_fs13.default.mkdirSync(outDir, { recursive: true });
6003
7324
  const bundle2 = await (0, import_rolldown.rolldown)(inputOptions);
6004
7325
  const { output } = await bundle2.write(outputOptions);
6005
7326
  await bundle2.close();
6006
7327
  if (cssEngine) environment.setBuildMetadata({ css: getCssMetadata(cssEngine) });
6007
7328
  logger.info(
6008
- import_picocolors6.default.dim(` [${name}] `) + output.map((o) => import_node_path14.default.join(envOptions.build.outDir, o.fileName)).join(import_picocolors6.default.dim(", "))
7329
+ import_picocolors6.default.dim(` [${name}] `) + output.map((o) => import_node_path16.default.join(envOptions.build.outDir, o.fileName)).join(import_picocolors6.default.dim(", "))
6009
7330
  );
6010
7331
  return {
6011
7332
  environment,
@@ -6037,9 +7358,9 @@ function escapeRegExp(string) {
6037
7358
  return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
6038
7359
  }
6039
7360
  function replaceEntryScript(html, facadeModuleId, fileName, config, htmlFile, urlPrefix) {
6040
- const rootRelative = import_node_path14.default.relative(config.root, facadeModuleId).split(import_node_path14.default.sep).join("/");
6041
- const resolvedHtmlFile = import_node_path14.default.resolve(config.root, htmlFile);
6042
- const htmlRelative = import_node_path14.default.relative(import_node_path14.default.dirname(resolvedHtmlFile), facadeModuleId).split(import_node_path14.default.sep).join("/");
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("/");
6043
7364
  const candidates = /* @__PURE__ */ new Set([
6044
7365
  rootRelative,
6045
7366
  `/${rootRelative}`,
@@ -6055,13 +7376,13 @@ function replaceEntryScript(html, facadeModuleId, fileName, config, htmlFile, ur
6055
7376
  }
6056
7377
  return processed;
6057
7378
  }
6058
- var import_node_path14, import_node_fs11, import_node_module5, import_rolldown, import_picocolors6, debug6, NODE_BUILTINS2;
7379
+ var import_node_path16, import_node_fs13, import_node_module6, import_rolldown, import_picocolors6, debug6, NODE_BUILTINS2;
6059
7380
  var init_build = __esm({
6060
7381
  "src/build/index.ts"() {
6061
7382
  "use strict";
6062
- import_node_path14 = __toESM(require("path"), 1);
6063
- import_node_fs11 = __toESM(require("fs"), 1);
6064
- import_node_module5 = require("module");
7383
+ import_node_path16 = __toESM(require("path"), 1);
7384
+ import_node_fs13 = __toESM(require("fs"), 1);
7385
+ import_node_module6 = require("module");
6065
7386
  import_rolldown = require("rolldown");
6066
7387
  init_config();
6067
7388
  init_builtins();
@@ -6077,7 +7398,7 @@ var init_build = __esm({
6077
7398
  init_build_app_context();
6078
7399
  import_picocolors6 = __toESM(require("picocolors"), 1);
6079
7400
  debug6 = createDebugger("nasti:build");
6080
- NODE_BUILTINS2 = /* @__PURE__ */ new Set([...import_node_module5.builtinModules, ...import_node_module5.builtinModules.map((m) => `node:${m}`)]);
7401
+ NODE_BUILTINS2 = /* @__PURE__ */ new Set([...import_node_module6.builtinModules, ...import_node_module6.builtinModules.map((m) => `node:${m}`)]);
6081
7402
  }
6082
7403
  });
6083
7404
 
@@ -6167,7 +7488,7 @@ async function createBundledDevServer(opts) {
6167
7488
  }
6168
7489
  const url = `/${patchPath}`;
6169
7490
  logger.info(
6170
- import_picocolors7.default.green("hmr update ") + import_picocolors7.default.dim(changedFiles.map((f) => import_node_path15.default.relative(config.root, f)).join(", ")),
7491
+ import_picocolors7.default.green("hmr update ") + import_picocolors7.default.dim(changedFiles.map((f) => import_node_path17.default.relative(config.root, f)).join(", ")),
6171
7492
  { timestamp: true }
6172
7493
  );
6173
7494
  sendTo(clientId, { type: "hmr:update", path: url, url });
@@ -6322,7 +7643,7 @@ async function createBundledDevServer(opts) {
6322
7643
  return;
6323
7644
  }
6324
7645
  res.setHeader("ETag", hit.etag);
6325
- res.setHeader("Content-Type", MIME_TYPES[import_node_path15.default.extname(fileName)] ?? "application/octet-stream");
7646
+ res.setHeader("Content-Type", MIME_TYPES[import_node_path17.default.extname(fileName)] ?? "application/octet-stream");
6326
7647
  res.setHeader("Cache-Control", "no-cache");
6327
7648
  res.once("finish", () => {
6328
7649
  void engine.notifyPayloadDelivered(fileName).catch(
@@ -6363,7 +7684,7 @@ function stripCatchAllLoad(plugins) {
6363
7684
  );
6364
7685
  }
6365
7686
  function createReactRefreshRuntimePlugin(entryPoints) {
6366
- const entryIds = new Set(entryPoints.map((p) => import_node_path15.default.resolve(p)));
7687
+ const entryIds = new Set(entryPoints.map((p) => import_node_path17.default.resolve(p)));
6367
7688
  return {
6368
7689
  name: "nasti:bundled-react-refresh",
6369
7690
  resolveId(source) {
@@ -6381,7 +7702,7 @@ function createReactRefreshRuntimePlugin(entryPoints) {
6381
7702
  return null;
6382
7703
  },
6383
7704
  transform(code, id) {
6384
- if (!entryIds.has(import_node_path15.default.resolve(id.split("?")[0]))) return null;
7705
+ if (!entryIds.has(import_node_path17.default.resolve(id.split("?")[0]))) return null;
6385
7706
  return { code: `import ${JSON.stringify(PREAMBLE_SPEC)};
6386
7707
  ${code}`, map: null };
6387
7708
  }
@@ -6431,11 +7752,11 @@ async function renderBundledIndexHtml(html, config, entryFileNames) {
6431
7752
  }
6432
7753
  return processed;
6433
7754
  }
6434
- var import_node_path15, 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;
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;
6435
7756
  var init_dev_engine = __esm({
6436
7757
  "src/server/bundled/dev-engine.ts"() {
6437
7758
  "use strict";
6438
- import_node_path15 = __toESM(require("path"), 1);
7759
+ import_node_path17 = __toESM(require("path"), 1);
6439
7760
  import_node_crypto3 = __toESM(require("crypto"), 1);
6440
7761
  import_ws2 = require("ws");
6441
7762
  import_picocolors7 = __toESM(require("picocolors"), 1);
@@ -6645,19 +7966,19 @@ async function createServer(inlineConfig = {}) {
6645
7966
  app.use(bundledServer.middleware);
6646
7967
  }
6647
7968
  const ignoredSegments = /* @__PURE__ */ new Set(["node_modules", ".git", ".nasti"]);
6648
- const outDirAbs = import_node_path16.default.resolve(config.root, config.build.outDir);
7969
+ const outDirAbs = import_node_path18.default.resolve(config.root, config.build.outDir);
6649
7970
  const linkedPackageRoots = getLinkedPackageRoots(config.root).filter(
6650
7971
  (r) => r !== config.root && !isUnderRoot(config.root, r)
6651
7972
  );
6652
7973
  const watchTargets = [config.root, ...linkedPackageRoots];
6653
7974
  const watcher = (0, import_chokidar.watch)(watchTargets, {
6654
7975
  ignored: (filePath) => {
6655
- if (filePath === outDirAbs || filePath.startsWith(outDirAbs + import_node_path16.default.sep)) return true;
7976
+ if (filePath === outDirAbs || filePath.startsWith(outDirAbs + import_node_path18.default.sep)) return true;
6656
7977
  for (const watchRoot of watchTargets) {
6657
7978
  if (filePath === watchRoot) return false;
6658
- const rel = import_node_path16.default.relative(watchRoot, filePath);
6659
- if (!rel || rel.startsWith("..") || import_node_path16.default.isAbsolute(rel)) continue;
6660
- for (const seg of rel.split(import_node_path16.default.sep)) {
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)) {
6661
7982
  if (ignoredSegments.has(seg)) return true;
6662
7983
  }
6663
7984
  return false;
@@ -6789,7 +8110,7 @@ async function createServer(inlineConfig = {}) {
6789
8110
  });
6790
8111
  };
6791
8112
  watcher.on("change", (file) => {
6792
- if (file.includes(`${import_node_path16.default.sep}node_modules${import_node_path16.default.sep}`) || file.endsWith(`${import_node_path16.default.sep}node_modules`)) {
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`)) {
6793
8114
  clearLinkedPackageRootsCache();
6794
8115
  }
6795
8116
  ssrRunner?.invalidateFile(file);
@@ -6797,7 +8118,7 @@ async function createServer(inlineConfig = {}) {
6797
8118
  notifyEnvironmentDrivers(file, "change");
6798
8119
  });
6799
8120
  watcher.on("add", (file) => {
6800
- if (file.includes(`${import_node_path16.default.sep}node_modules${import_node_path16.default.sep}`) || file.endsWith(`${import_node_path16.default.sep}node_modules`)) {
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`)) {
6801
8122
  clearLinkedPackageRootsCache();
6802
8123
  }
6803
8124
  ssrRunner?.invalidateFile(file);
@@ -6805,7 +8126,7 @@ async function createServer(inlineConfig = {}) {
6805
8126
  notifyEnvironmentDrivers(file, "add");
6806
8127
  });
6807
8128
  watcher.on("unlink", (file) => {
6808
- if (file.includes(`${import_node_path16.default.sep}node_modules${import_node_path16.default.sep}`) || file.endsWith(`${import_node_path16.default.sep}node_modules`)) {
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`)) {
6809
8130
  clearLinkedPackageRootsCache();
6810
8131
  }
6811
8132
  ssrRunner?.invalidateFile(file);
@@ -6837,7 +8158,7 @@ async function createServer(inlineConfig = {}) {
6837
8158
  const readyIn = Math.ceil(performance.now() - startTime);
6838
8159
  logger.info(
6839
8160
  `
6840
- ${import_picocolors8.default.cyan(import_picocolors8.default.bold("NASTI"))} ${import_picocolors8.default.cyan(`v${"2.5.0"}`)} ${import_picocolors8.default.dim("ready in")} ${import_picocolors8.default.bold(readyIn)} ${import_picocolors8.default.dim("ms")}
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")}
6841
8162
  `
6842
8163
  );
6843
8164
  printServerUrls(
@@ -6934,7 +8255,7 @@ async function createServer(inlineConfig = {}) {
6934
8255
  throw error;
6935
8256
  }
6936
8257
  app.use(transformMiddleware(transformContexts.get("client")));
6937
- const publicDir = import_node_path16.default.resolve(config.root, "public");
8258
+ const publicDir = import_node_path18.default.resolve(config.root, "public");
6938
8259
  app.use((0, import_sirv.default)(publicDir, { dev: true, etag: true }));
6939
8260
  app.use((0, import_sirv.default)(config.root, { dev: true, etag: true }));
6940
8261
  const postMiddlewares = [];
@@ -6960,12 +8281,12 @@ function getNetworkAddress() {
6960
8281
  }
6961
8282
  return "localhost";
6962
8283
  }
6963
- var import_node_http, import_node_path16, import_node_os, import_connect, import_sirv, import_chokidar, import_picocolors8;
8284
+ var import_node_http, import_node_path18, import_node_os, import_connect, import_sirv, import_chokidar, import_picocolors8;
6964
8285
  var init_server = __esm({
6965
8286
  "src/server/index.ts"() {
6966
8287
  "use strict";
6967
8288
  import_node_http = __toESM(require("http"), 1);
6968
- import_node_path16 = __toESM(require("path"), 1);
8289
+ import_node_path18 = __toESM(require("path"), 1);
6969
8290
  import_node_os = __toESM(require("os"), 1);
6970
8291
  import_connect = __toESM(require("connect"), 1);
6971
8292
  import_sirv = __toESM(require("sirv"), 1);
@@ -7006,14 +8327,14 @@ function electronPlugin(config) {
7006
8327
  }
7007
8328
  };
7008
8329
  }
7009
- var import_node_module6, NODE_BUILTINS3, ELECTRON_MODULES;
8330
+ var import_node_module7, NODE_BUILTINS3, ELECTRON_MODULES;
7010
8331
  var init_electron = __esm({
7011
8332
  "src/plugins/electron.ts"() {
7012
8333
  "use strict";
7013
- import_node_module6 = require("module");
8334
+ import_node_module7 = require("module");
7014
8335
  NODE_BUILTINS3 = /* @__PURE__ */ new Set([
7015
- ...import_node_module6.builtinModules,
7016
- ...import_node_module6.builtinModules.map((m) => `node:${m}`)
8336
+ ...import_node_module7.builtinModules,
8337
+ ...import_node_module7.builtinModules.map((m) => `node:${m}`)
7017
8338
  ]);
7018
8339
  ELECTRON_MODULES = /* @__PURE__ */ new Set([
7019
8340
  "electron",
@@ -7036,16 +8357,16 @@ async function buildElectron(inlineConfig = {}) {
7036
8357
  const config = await resolveConfig({ ...inlineConfig, target: "electron" }, "build");
7037
8358
  const startTime = performance.now();
7038
8359
  assertElectronVersion(config);
7039
- console.log(import_picocolors9.default.cyan("\n\u26A1 nasti build (electron)") + import_picocolors9.default.dim(` v${"2.5.0"}`));
8360
+ console.log(import_picocolors9.default.cyan("\n\u26A1 nasti build (electron)") + import_picocolors9.default.dim(` v${"2.5.1"}`));
7040
8361
  console.log(import_picocolors9.default.dim(` root: ${config.root}`));
7041
8362
  console.log(import_picocolors9.default.dim(` mode: ${config.mode}`));
7042
8363
  console.log(import_picocolors9.default.dim(` target: electron (\u2265 ${config.electron.minVersion})`));
7043
- const outDir = import_node_path17.default.resolve(config.root, config.build.outDir);
7044
- if (config.build.emptyOutDir && import_node_fs12.default.existsSync(outDir)) {
7045
- import_node_fs12.default.rmSync(outDir, { recursive: true, force: true });
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 });
7046
8367
  }
7047
- import_node_fs12.default.mkdirSync(outDir, { recursive: true });
7048
- const rendererOutDir = import_node_path17.default.join(outDir, "renderer");
8368
+ import_node_fs14.default.mkdirSync(outDir, { recursive: true });
8369
+ const rendererOutDir = import_node_path19.default.join(outDir, "renderer");
7049
8370
  const { build: build2 } = await Promise.resolve().then(() => (init_build(), build_exports));
7050
8371
  await build2(createElectronRendererConfig(config, inlineConfig, {
7051
8372
  build: {
@@ -7054,8 +8375,8 @@ async function buildElectron(inlineConfig = {}) {
7054
8375
  emptyOutDir: false
7055
8376
  }
7056
8377
  }));
7057
- const mainEntry = import_node_path17.default.resolve(config.root, config.electron.main);
7058
- if (!import_node_fs12.default.existsSync(mainEntry)) {
8378
+ const mainEntry = import_node_path19.default.resolve(config.root, config.electron.main);
8379
+ if (!import_node_fs14.default.existsSync(mainEntry)) {
7059
8380
  throw new Error(
7060
8381
  `Electron main entry not found: ${config.electron.main}
7061
8382
  \u5728 nasti.config.ts \u7684 electron.main \u6307\u5B9A\u4E3B\u8FDB\u7A0B\u5165\u53E3\u6587\u4EF6\u3002`
@@ -7069,11 +8390,11 @@ async function buildElectron(inlineConfig = {}) {
7069
8390
  const preloadEntries = normalizePreload(config.electron.preload, config.root);
7070
8391
  const preloadFiles = [];
7071
8392
  for (const entry of preloadEntries) {
7072
- if (!import_node_fs12.default.existsSync(entry)) {
8393
+ if (!import_node_fs14.default.existsSync(entry)) {
7073
8394
  console.warn(import_picocolors9.default.yellow(` \u26A0 preload entry not found, skipped: ${entry}`));
7074
8395
  continue;
7075
8396
  }
7076
- const base = import_node_path17.default.basename(entry).replace(/\.[^.]+$/, "");
8397
+ const base = import_node_path19.default.basename(entry).replace(/\.[^.]+$/, "");
7077
8398
  const out = outFileName(outDir, base, config.electron.preloadFormat);
7078
8399
  await bundleNode(config, entry, {
7079
8400
  outFile: out,
@@ -7085,10 +8406,10 @@ async function buildElectron(inlineConfig = {}) {
7085
8406
  const elapsed = ((performance.now() - startTime) / 1e3).toFixed(2);
7086
8407
  console.log(import_picocolors9.default.green(`
7087
8408
  \u2713 Electron build complete in ${elapsed}s`));
7088
- console.log(import_picocolors9.default.dim(` renderer: ${import_node_path17.default.relative(config.root, rendererOutDir)}/`));
7089
- console.log(import_picocolors9.default.dim(` main: ${import_node_path17.default.relative(config.root, mainFile)}`));
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)}`));
7090
8411
  for (const pf of preloadFiles) {
7091
- console.log(import_picocolors9.default.dim(` preload: ${import_node_path17.default.relative(config.root, pf)}`));
8412
+ console.log(import_picocolors9.default.dim(` preload: ${import_node_path19.default.relative(config.root, pf)}`));
7092
8413
  }
7093
8414
  console.log();
7094
8415
  return { rendererOutDir, mainFile, preloadFiles };
@@ -7133,7 +8454,7 @@ async function bundleNode(config, entry, opts) {
7133
8454
  },
7134
8455
  plugins: [oxcTransformPlugin, electronPlugin(config), resolvePlugin(config)]
7135
8456
  });
7136
- import_node_fs12.default.mkdirSync(import_node_path17.default.dirname(opts.outFile), { recursive: true });
8457
+ import_node_fs14.default.mkdirSync(import_node_path19.default.dirname(opts.outFile), { recursive: true });
7137
8458
  await bundle2.write({
7138
8459
  sourcemap: !!config.build.sourcemap,
7139
8460
  minify: !!config.build.minify,
@@ -7144,7 +8465,7 @@ async function bundleNode(config, entry, opts) {
7144
8465
  codeSplitting: false
7145
8466
  });
7146
8467
  await bundle2.close();
7147
- console.log(import_picocolors9.default.dim(` \u2713 ${opts.label} \u2192 ${import_node_path17.default.relative(config.root, opts.outFile)}`));
8468
+ console.log(import_picocolors9.default.dim(` \u2713 ${opts.label} \u2192 ${import_node_path19.default.relative(config.root, opts.outFile)}`));
7148
8469
  return opts.outFile;
7149
8470
  }
7150
8471
  function createElectronRendererConfig(config, inlineConfig = {}, overrides = {}) {
@@ -7166,13 +8487,13 @@ function createElectronRendererConfig(config, inlineConfig = {}, overrides = {})
7166
8487
  }
7167
8488
  };
7168
8489
  }
7169
- function outFileName(outDir, base, format) {
7170
- const ext = format === "cjs" ? ".cjs" : ".mjs";
7171
- return import_node_path17.default.join(outDir, base + ext);
8490
+ function outFileName(outDir, base, format2) {
8491
+ const ext = format2 === "cjs" ? ".cjs" : ".mjs";
8492
+ return import_node_path19.default.join(outDir, base + ext);
7172
8493
  }
7173
8494
  function normalizePreload(preload, root) {
7174
8495
  const list = Array.isArray(preload) ? preload : preload ? [preload] : [];
7175
- return list.map((p) => import_node_path17.default.resolve(root, p));
8496
+ return list.map((p) => import_node_path19.default.resolve(root, p));
7176
8497
  }
7177
8498
  function assertElectronVersion(config) {
7178
8499
  const min = config.electron.minVersion;
@@ -7187,16 +8508,16 @@ function assertElectronVersion(config) {
7187
8508
  }
7188
8509
  function detectInstalledElectron(root) {
7189
8510
  try {
7190
- const require2 = (0, import_node_module7.createRequire)(import_node_path17.default.resolve(root, "package.json"));
8511
+ const require2 = (0, import_node_module8.createRequire)(import_node_path19.default.resolve(root, "package.json"));
7191
8512
  const pkgPath = require2.resolve("electron/package.json");
7192
- const pkg = JSON.parse(import_node_fs12.default.readFileSync(pkgPath, "utf-8"));
8513
+ const pkg = JSON.parse(import_node_fs14.default.readFileSync(pkgPath, "utf-8"));
7193
8514
  const major = parseInt(String(pkg.version).split(".")[0], 10);
7194
8515
  return Number.isFinite(major) ? major : null;
7195
8516
  } catch {
7196
8517
  try {
7197
- const pkgPath = import_node_path17.default.resolve(root, "node_modules/electron/package.json");
7198
- if (!import_node_fs12.default.existsSync(pkgPath)) return null;
7199
- const pkg = JSON.parse(import_node_fs12.default.readFileSync(pkgPath, "utf-8"));
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"));
7200
8521
  const major = parseInt(String(pkg.version).split(".")[0], 10);
7201
8522
  return Number.isFinite(major) ? major : null;
7202
8523
  } catch {
@@ -7204,13 +8525,13 @@ function detectInstalledElectron(root) {
7204
8525
  }
7205
8526
  }
7206
8527
  }
7207
- var import_node_path17, import_node_fs12, import_node_module7, import_rolldown2, import_picocolors9;
8528
+ var import_node_path19, import_node_fs14, import_node_module8, import_rolldown2, import_picocolors9;
7208
8529
  var init_electron2 = __esm({
7209
8530
  "src/build/electron.ts"() {
7210
8531
  "use strict";
7211
- import_node_path17 = __toESM(require("path"), 1);
7212
- import_node_fs12 = __toESM(require("fs"), 1);
7213
- import_node_module7 = require("module");
8532
+ import_node_path19 = __toESM(require("path"), 1);
8533
+ import_node_fs14 = __toESM(require("fs"), 1);
8534
+ import_node_module8 = require("module");
7214
8535
  import_rolldown2 = require("rolldown");
7215
8536
  import_picocolors9 = __toESM(require("picocolors"), 1);
7216
8537
  init_config();
@@ -7231,7 +8552,7 @@ async function startElectronDev(inlineConfig = {}) {
7231
8552
  const { noSpawn, ...rest } = inlineConfig;
7232
8553
  const config = await resolveConfig({ ...rest, target: "electron" }, "serve");
7233
8554
  warnElectronVersion(config);
7234
- console.log(import_picocolors10.default.cyan("\n\u26A1 nasti electron dev") + import_picocolors10.default.dim(` v${"2.5.0"}`));
8555
+ console.log(import_picocolors10.default.cyan("\n\u26A1 nasti electron dev") + import_picocolors10.default.dim(` v${"2.5.1"}`));
7235
8556
  const { createServer: createServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
7236
8557
  const server = await createServer2({
7237
8558
  ...rest,
@@ -7241,11 +8562,11 @@ async function startElectronDev(inlineConfig = {}) {
7241
8562
  await server.listen();
7242
8563
  const devUrl = `http://localhost:${server.config.server.port}` + electronRendererDevPath(config.electron.renderer);
7243
8564
  console.log(import_picocolors10.default.dim(` renderer: ${devUrl}`));
7244
- const stageDir = import_node_path18.default.resolve(config.root, ".nasti");
7245
- import_node_fs13.default.mkdirSync(stageDir, { recursive: true });
7246
- const mainEntry = import_node_path18.default.resolve(config.root, config.electron.main);
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);
7247
8568
  const preloadEntries = normalizePreload(config.electron.preload, config.root);
7248
- const builtMainFile = import_node_path18.default.join(stageDir, "main" + extFor(config.electron.mainFormat));
8569
+ const builtMainFile = import_node_path20.default.join(stageDir, "main" + extFor(config.electron.mainFormat));
7249
8570
  const builtPreloadFiles = [];
7250
8571
  const compileAll = async () => {
7251
8572
  await compileNode(config, mainEntry, {
@@ -7255,9 +8576,9 @@ async function startElectronDev(inlineConfig = {}) {
7255
8576
  });
7256
8577
  builtPreloadFiles.length = 0;
7257
8578
  for (const entry of preloadEntries) {
7258
- if (!import_node_fs13.default.existsSync(entry)) continue;
7259
- const base = import_node_path18.default.basename(entry).replace(/\.[^.]+$/, "");
7260
- const out = import_node_path18.default.join(stageDir, base + extFor(config.electron.preloadFormat));
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));
7261
8582
  await compileNode(config, entry, {
7262
8583
  outFile: out,
7263
8584
  format: config.electron.preloadFormat,
@@ -7296,7 +8617,7 @@ async function startElectronDev(inlineConfig = {}) {
7296
8617
  };
7297
8618
  spawnElectron();
7298
8619
  if (config.electron.autoRestart) {
7299
- const watchTargets = [mainEntry, ...preloadEntries].filter(import_node_fs13.default.existsSync);
8620
+ const watchTargets = [mainEntry, ...preloadEntries].filter(import_node_fs15.default.existsSync);
7300
8621
  const watcher = import_chokidar2.default.watch(watchTargets, { ignoreInitial: true });
7301
8622
  let restarting = null;
7302
8623
  let pending = false;
@@ -7343,8 +8664,8 @@ async function startElectronDev(inlineConfig = {}) {
7343
8664
  });
7344
8665
  }
7345
8666
  }
7346
- function extFor(format) {
7347
- return format === "cjs" ? ".cjs" : ".mjs";
8667
+ function extFor(format2) {
8668
+ return format2 === "cjs" ? ".cjs" : ".mjs";
7348
8669
  }
7349
8670
  async function compileNode(config, entry, opts) {
7350
8671
  const env = loadEnv(config.mode, config.root, config.envPrefix);
@@ -7383,7 +8704,7 @@ async function compileNode(config, entry, opts) {
7383
8704
  platform: "node",
7384
8705
  plugins: [oxcTransformPlugin, electronPlugin(config), resolvePlugin(config)]
7385
8706
  });
7386
- import_node_fs13.default.mkdirSync(import_node_path18.default.dirname(opts.outFile), { recursive: true });
8707
+ import_node_fs15.default.mkdirSync(import_node_path20.default.dirname(opts.outFile), { recursive: true });
7387
8708
  await bundle2.write({
7388
8709
  file: opts.outFile,
7389
8710
  format: opts.format === "cjs" ? "cjs" : "esm",
@@ -7396,18 +8717,18 @@ async function compileNode(config, entry, opts) {
7396
8717
  await bundle2.close();
7397
8718
  }
7398
8719
  function electronRendererDevPath(renderer) {
7399
- const normalized = renderer.split(import_node_path18.default.sep).join("/").replace(/^\.?\//, "");
8720
+ const normalized = renderer.split(import_node_path20.default.sep).join("/").replace(/^\.?\//, "");
7400
8721
  return normalized === "index.html" ? "/" : `/${normalized}`;
7401
8722
  }
7402
8723
  function resolveElectronBinary(config) {
7403
- if (config.electron.electronPath && import_node_fs13.default.existsSync(config.electron.electronPath)) {
8724
+ if (config.electron.electronPath && import_node_fs15.default.existsSync(config.electron.electronPath)) {
7404
8725
  return config.electron.electronPath;
7405
8726
  }
7406
8727
  try {
7407
- const require2 = (0, import_node_module8.createRequire)(import_node_path18.default.resolve(config.root, "package.json"));
8728
+ const require2 = (0, import_node_module9.createRequire)(import_node_path20.default.resolve(config.root, "package.json"));
7408
8729
  const pathFile = require2.resolve("electron");
7409
8730
  const electronModule = require2(pathFile);
7410
- if (typeof electronModule === "string" && import_node_fs13.default.existsSync(electronModule)) {
8731
+ if (typeof electronModule === "string" && import_node_fs15.default.existsSync(electronModule)) {
7411
8732
  return electronModule;
7412
8733
  }
7413
8734
  } catch {
@@ -7432,13 +8753,13 @@ function warnElectronVersion(config) {
7432
8753
  );
7433
8754
  }
7434
8755
  }
7435
- var import_node_path18, import_node_fs13, import_node_module8, import_node_child_process, import_chokidar2, import_picocolors10, import_rolldown3;
8756
+ var import_node_path20, import_node_fs15, import_node_module9, import_node_child_process, import_chokidar2, import_picocolors10, import_rolldown3;
7436
8757
  var init_electron_dev = __esm({
7437
8758
  "src/server/electron-dev.ts"() {
7438
8759
  "use strict";
7439
- import_node_path18 = __toESM(require("path"), 1);
7440
- import_node_fs13 = __toESM(require("fs"), 1);
7441
- import_node_module8 = require("module");
8760
+ import_node_path20 = __toESM(require("path"), 1);
8761
+ import_node_fs15 = __toESM(require("fs"), 1);
8762
+ import_node_module9 = require("module");
7442
8763
  import_node_child_process = require("child_process");
7443
8764
  import_chokidar2 = __toESM(require("chokidar"), 1);
7444
8765
  import_picocolors10 = __toESM(require("picocolors"), 1);
@@ -7590,20 +8911,20 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
7590
8911
  const logger = createCliLogger(options);
7591
8912
  try {
7592
8913
  const http2 = await import("http");
7593
- const path19 = await import("path");
8914
+ const path21 = await import("path");
7594
8915
  const os2 = await import("os");
7595
8916
  const sirv2 = (await import("sirv")).default;
7596
8917
  const connect2 = (await import("connect")).default;
7597
8918
  const { printServerUrls: printServerUrls2 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
7598
- const resolvedRoot = path19.resolve(root ?? ".");
7599
- const outDir = path19.resolve(resolvedRoot, options.outDir);
8919
+ const resolvedRoot = path21.resolve(root ?? ".");
8920
+ const outDir = path21.resolve(resolvedRoot, options.outDir);
7600
8921
  const app = connect2();
7601
8922
  app.use(sirv2(outDir, { single: true, etag: true, gzip: true, brotli: true }));
7602
8923
  const port = options.port;
7603
8924
  const host = options.host === true ? "0.0.0.0" : options.host ?? "localhost";
7604
8925
  http2.createServer(app).listen(port, host, () => {
7605
8926
  logger.info(`
7606
- ${import_picocolors11.default.cyan(import_picocolors11.default.bold("NASTI"))} ${import_picocolors11.default.cyan(`v${"2.5.0"}`)} ${import_picocolors11.default.dim("preview")}
8927
+ ${import_picocolors11.default.cyan(import_picocolors11.default.bold("NASTI"))} ${import_picocolors11.default.cyan(`v${"2.5.1"}`)} ${import_picocolors11.default.dim("preview")}
7607
8928
  `);
7608
8929
  printServerUrls2(
7609
8930
  {
@@ -7620,6 +8941,6 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
7620
8941
  }
7621
8942
  });
7622
8943
  cli.help();
7623
- cli.version("2.5.0");
8944
+ cli.version("2.5.1");
7624
8945
  cli.parse();
7625
8946
  //# sourceMappingURL=cli.cjs.map