@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.js CHANGED
@@ -10,16 +10,25 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
10
10
  if (typeof require !== "undefined") return require.apply(this, arguments);
11
11
  throw Error('Dynamic require of "' + x + '" is not supported');
12
12
  });
13
- var __glob = (map) => (path19) => {
14
- var fn = map[path19];
13
+ var __glob = (map) => (path21) => {
14
+ var fn = map[path21];
15
15
  if (fn) return fn();
16
- throw new Error("Module not found in bundle: " + path19);
16
+ throw new Error("Module not found in bundle: " + path21);
17
17
  };
18
- var __esm = (fn, res) => function __init() {
19
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
18
+ var __esm = (fn, res, err) => function __init() {
19
+ if (err) throw err[0];
20
+ try {
21
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
22
+ } catch (e) {
23
+ throw err = [e], e;
24
+ }
20
25
  };
21
26
  var __commonJS = (cb, mod) => function __require3() {
22
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
27
+ try {
28
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
29
+ } catch (e) {
30
+ throw mod = 0, e;
31
+ }
23
32
  };
24
33
  var __export = (target, all) => {
25
34
  for (var name in all)
@@ -69,7 +78,7 @@ function createLogger(level = "info", options = {}) {
69
78
  const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI;
70
79
  const clear = canClearScreen ? clearScreen : () => {
71
80
  };
72
- function format(type, msg, options2 = {}) {
81
+ function format2(type, msg, options2 = {}) {
73
82
  if (options2.timestamp) {
74
83
  const tag = type === "info" ? pc.cyan(pc.bold(prefix)) : type === "warn" ? pc.yellow(pc.bold(prefix)) : pc.red(pc.bold(prefix));
75
84
  return `${pc.dim(timeFormatter.format(/* @__PURE__ */ new Date()))} ${tag} ${msg}`;
@@ -86,16 +95,16 @@ function createLogger(level = "info", options = {}) {
86
95
  if (type === lastType && msg === lastMsg) {
87
96
  sameCount++;
88
97
  clear();
89
- console_[method](format(type, msg, options2), pc.yellow(`(x${sameCount + 1})`));
98
+ console_[method](format2(type, msg, options2), pc.yellow(`(x${sameCount + 1})`));
90
99
  } else {
91
100
  sameCount = 0;
92
101
  lastMsg = msg;
93
102
  lastType = type;
94
103
  if (options2.clear) clear();
95
- console_[method](format(type, msg, options2));
104
+ console_[method](format2(type, msg, options2));
96
105
  }
97
106
  } else {
98
- console_[method](format(type, msg, options2));
107
+ console_[method](format2(type, msg, options2));
99
108
  }
100
109
  }
101
110
  const warnedMessages = /* @__PURE__ */ new Set();
@@ -2330,8 +2339,8 @@ function rewriteExternalRequires(code, baseDir, root) {
2330
2339
  }
2331
2340
  async function injectCjsNamedExports(code, entryFile) {
2332
2341
  try {
2333
- const { createRequire: createRequire7 } = await import("module");
2334
- const req = createRequire7(entryFile);
2342
+ const { createRequire: createRequire6 } = await import("module");
2343
+ const req = createRequire6(entryFile);
2335
2344
  const cjsExports = req(entryFile);
2336
2345
  if (!cjsExports || typeof cjsExports !== "object" && typeof cjsExports !== "function" || Array.isArray(cjsExports)) return code;
2337
2346
  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"(exports, module) {
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;
@@ -4547,8 +4556,8 @@ function vuePlugin(config, environmentName = "client") {
4547
4556
  let cached2 = descriptorCache.get(filePath);
4548
4557
  if (!cached2) {
4549
4558
  try {
4550
- const fs14 = await import("fs");
4551
- const rawSource = fs14.readFileSync(filePath, "utf-8");
4559
+ const fs15 = await import("fs");
4560
+ const rawSource = fs15.readFileSync(filePath, "utf-8");
4552
4561
  const transformedSfc = await applySourceTransform(
4553
4562
  vueOptions.transformSfc,
4554
4563
  rawSource,
@@ -4970,16 +4979,1320 @@ var init_builtins = __esm({
4970
4979
  }
4971
4980
  });
4972
4981
 
4982
+ // node_modules/import-meta-resolve/lib/errors.js
4983
+ import v8 from "v8";
4984
+ import assert from "assert";
4985
+ import { format, inspect } from "util";
4986
+ function formatList(array, type = "and") {
4987
+ return array.length < 3 ? array.join(` ${type} `) : `${array.slice(0, -1).join(", ")}, ${type} ${array[array.length - 1]}`;
4988
+ }
4989
+ function createError(sym, value, constructor) {
4990
+ messages.set(sym, value);
4991
+ return makeNodeErrorWithCode(constructor, sym);
4992
+ }
4993
+ function makeNodeErrorWithCode(Base, key) {
4994
+ return NodeError;
4995
+ function NodeError(...parameters) {
4996
+ const limit = Error.stackTraceLimit;
4997
+ if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
4998
+ const error = new Base();
4999
+ if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
5000
+ const message = getMessage(key, parameters, error);
5001
+ Object.defineProperties(error, {
5002
+ // Note: no need to implement `kIsNodeError` symbol, would be hard,
5003
+ // probably.
5004
+ message: {
5005
+ value: message,
5006
+ enumerable: false,
5007
+ writable: true,
5008
+ configurable: true
5009
+ },
5010
+ toString: {
5011
+ /** @this {Error} */
5012
+ value() {
5013
+ return `${this.name} [${key}]: ${this.message}`;
5014
+ },
5015
+ enumerable: false,
5016
+ writable: true,
5017
+ configurable: true
5018
+ }
5019
+ });
5020
+ captureLargerStackTrace(error);
5021
+ error.code = key;
5022
+ return error;
5023
+ }
5024
+ }
5025
+ function isErrorStackTraceLimitWritable() {
5026
+ try {
5027
+ if (v8.startupSnapshot.isBuildingSnapshot()) {
5028
+ return false;
5029
+ }
5030
+ } catch {
5031
+ }
5032
+ const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
5033
+ if (desc === void 0) {
5034
+ return Object.isExtensible(Error);
5035
+ }
5036
+ return own.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
5037
+ }
5038
+ function hideStackFrames(wrappedFunction) {
5039
+ const hidden = nodeInternalPrefix + wrappedFunction.name;
5040
+ Object.defineProperty(wrappedFunction, "name", { value: hidden });
5041
+ return wrappedFunction;
5042
+ }
5043
+ function getMessage(key, parameters, self) {
5044
+ const message = messages.get(key);
5045
+ assert.ok(message !== void 0, "expected `message` to be found");
5046
+ if (typeof message === "function") {
5047
+ assert.ok(
5048
+ message.length <= parameters.length,
5049
+ // Default options do not count.
5050
+ `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`
5051
+ );
5052
+ return Reflect.apply(message, self, parameters);
5053
+ }
5054
+ const regex = /%[dfijoOs]/g;
5055
+ let expectedLength = 0;
5056
+ while (regex.exec(message) !== null) expectedLength++;
5057
+ assert.ok(
5058
+ expectedLength === parameters.length,
5059
+ `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`
5060
+ );
5061
+ if (parameters.length === 0) return message;
5062
+ parameters.unshift(message);
5063
+ return Reflect.apply(format, null, parameters);
5064
+ }
5065
+ function determineSpecificType(value) {
5066
+ if (value === null || value === void 0) {
5067
+ return String(value);
5068
+ }
5069
+ if (typeof value === "function" && value.name) {
5070
+ return `function ${value.name}`;
5071
+ }
5072
+ if (typeof value === "object") {
5073
+ if (value.constructor && value.constructor.name) {
5074
+ return `an instance of ${value.constructor.name}`;
5075
+ }
5076
+ return `${inspect(value, { depth: -1 })}`;
5077
+ }
5078
+ let inspected = inspect(value, { colors: false });
5079
+ if (inspected.length > 28) {
5080
+ inspected = `${inspected.slice(0, 25)}...`;
5081
+ }
5082
+ return `type ${typeof value} (${inspected})`;
5083
+ }
5084
+ var own, classRegExp, kTypes, codes, messages, nodeInternalPrefix, userStackTraceLimit, captureLargerStackTrace;
5085
+ var init_errors = __esm({
5086
+ "node_modules/import-meta-resolve/lib/errors.js"() {
5087
+ "use strict";
5088
+ own = {}.hasOwnProperty;
5089
+ classRegExp = /^([A-Z][a-z\d]*)+$/;
5090
+ kTypes = /* @__PURE__ */ new Set([
5091
+ "string",
5092
+ "function",
5093
+ "number",
5094
+ "object",
5095
+ // Accept 'Function' and 'Object' as alternative to the lower cased version.
5096
+ "Function",
5097
+ "Object",
5098
+ "boolean",
5099
+ "bigint",
5100
+ "symbol"
5101
+ ]);
5102
+ codes = {};
5103
+ messages = /* @__PURE__ */ new Map();
5104
+ nodeInternalPrefix = "__node_internal_";
5105
+ codes.ERR_INVALID_ARG_TYPE = createError(
5106
+ "ERR_INVALID_ARG_TYPE",
5107
+ /**
5108
+ * @param {string} name
5109
+ * @param {Array<string> | string} expected
5110
+ * @param {unknown} actual
5111
+ */
5112
+ (name, expected, actual) => {
5113
+ assert.ok(typeof name === "string", "'name' must be a string");
5114
+ if (!Array.isArray(expected)) {
5115
+ expected = [expected];
5116
+ }
5117
+ let message = "The ";
5118
+ if (name.endsWith(" argument")) {
5119
+ message += `${name} `;
5120
+ } else {
5121
+ const type = name.includes(".") ? "property" : "argument";
5122
+ message += `"${name}" ${type} `;
5123
+ }
5124
+ message += "must be ";
5125
+ const types = [];
5126
+ const instances = [];
5127
+ const other = [];
5128
+ for (const value of expected) {
5129
+ assert.ok(
5130
+ typeof value === "string",
5131
+ "All expected entries have to be of type string"
5132
+ );
5133
+ if (kTypes.has(value)) {
5134
+ types.push(value.toLowerCase());
5135
+ } else if (classRegExp.exec(value) === null) {
5136
+ assert.ok(
5137
+ value !== "object",
5138
+ 'The value "object" should be written as "Object"'
5139
+ );
5140
+ other.push(value);
5141
+ } else {
5142
+ instances.push(value);
5143
+ }
5144
+ }
5145
+ if (instances.length > 0) {
5146
+ const pos = types.indexOf("object");
5147
+ if (pos !== -1) {
5148
+ types.slice(pos, 1);
5149
+ instances.push("Object");
5150
+ }
5151
+ }
5152
+ if (types.length > 0) {
5153
+ message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(
5154
+ types,
5155
+ "or"
5156
+ )}`;
5157
+ if (instances.length > 0 || other.length > 0) message += " or ";
5158
+ }
5159
+ if (instances.length > 0) {
5160
+ message += `an instance of ${formatList(instances, "or")}`;
5161
+ if (other.length > 0) message += " or ";
5162
+ }
5163
+ if (other.length > 0) {
5164
+ if (other.length > 1) {
5165
+ message += `one of ${formatList(other, "or")}`;
5166
+ } else {
5167
+ if (other[0].toLowerCase() !== other[0]) message += "an ";
5168
+ message += `${other[0]}`;
5169
+ }
5170
+ }
5171
+ message += `. Received ${determineSpecificType(actual)}`;
5172
+ return message;
5173
+ },
5174
+ TypeError
5175
+ );
5176
+ codes.ERR_INVALID_MODULE_SPECIFIER = createError(
5177
+ "ERR_INVALID_MODULE_SPECIFIER",
5178
+ /**
5179
+ * @param {string} request
5180
+ * @param {string} reason
5181
+ * @param {string} [base]
5182
+ */
5183
+ (request, reason, base = void 0) => {
5184
+ return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
5185
+ },
5186
+ TypeError
5187
+ );
5188
+ codes.ERR_INVALID_PACKAGE_CONFIG = createError(
5189
+ "ERR_INVALID_PACKAGE_CONFIG",
5190
+ /**
5191
+ * @param {string} path
5192
+ * @param {string} [base]
5193
+ * @param {string} [message]
5194
+ */
5195
+ (path21, base, message) => {
5196
+ return `Invalid package config ${path21}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
5197
+ },
5198
+ Error
5199
+ );
5200
+ codes.ERR_INVALID_PACKAGE_TARGET = createError(
5201
+ "ERR_INVALID_PACKAGE_TARGET",
5202
+ /**
5203
+ * @param {string} packagePath
5204
+ * @param {string} key
5205
+ * @param {unknown} target
5206
+ * @param {boolean} [isImport=false]
5207
+ * @param {string} [base]
5208
+ */
5209
+ (packagePath, key, target, isImport = false, base = void 0) => {
5210
+ const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
5211
+ if (key === ".") {
5212
+ assert.ok(isImport === false);
5213
+ 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 "./"' : ""}`;
5214
+ }
5215
+ return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(
5216
+ target
5217
+ )} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
5218
+ },
5219
+ Error
5220
+ );
5221
+ codes.ERR_MODULE_NOT_FOUND = createError(
5222
+ "ERR_MODULE_NOT_FOUND",
5223
+ /**
5224
+ * @param {string} path
5225
+ * @param {string} base
5226
+ * @param {boolean} [exactUrl]
5227
+ */
5228
+ (path21, base, exactUrl = false) => {
5229
+ return `Cannot find ${exactUrl ? "module" : "package"} '${path21}' imported from ${base}`;
5230
+ },
5231
+ Error
5232
+ );
5233
+ codes.ERR_NETWORK_IMPORT_DISALLOWED = createError(
5234
+ "ERR_NETWORK_IMPORT_DISALLOWED",
5235
+ "import of '%s' by %s is not supported: %s",
5236
+ Error
5237
+ );
5238
+ codes.ERR_PACKAGE_IMPORT_NOT_DEFINED = createError(
5239
+ "ERR_PACKAGE_IMPORT_NOT_DEFINED",
5240
+ /**
5241
+ * @param {string} specifier
5242
+ * @param {string} packagePath
5243
+ * @param {string} base
5244
+ */
5245
+ (specifier, packagePath, base) => {
5246
+ return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ""} imported from ${base}`;
5247
+ },
5248
+ TypeError
5249
+ );
5250
+ codes.ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
5251
+ "ERR_PACKAGE_PATH_NOT_EXPORTED",
5252
+ /**
5253
+ * @param {string} packagePath
5254
+ * @param {string} subpath
5255
+ * @param {string} [base]
5256
+ */
5257
+ (packagePath, subpath, base = void 0) => {
5258
+ if (subpath === ".")
5259
+ return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
5260
+ return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
5261
+ },
5262
+ Error
5263
+ );
5264
+ codes.ERR_UNSUPPORTED_DIR_IMPORT = createError(
5265
+ "ERR_UNSUPPORTED_DIR_IMPORT",
5266
+ "Directory import '%s' is not supported resolving ES modules imported from %s",
5267
+ Error
5268
+ );
5269
+ codes.ERR_UNSUPPORTED_RESOLVE_REQUEST = createError(
5270
+ "ERR_UNSUPPORTED_RESOLVE_REQUEST",
5271
+ 'Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.',
5272
+ TypeError
5273
+ );
5274
+ codes.ERR_UNKNOWN_FILE_EXTENSION = createError(
5275
+ "ERR_UNKNOWN_FILE_EXTENSION",
5276
+ /**
5277
+ * @param {string} extension
5278
+ * @param {string} path
5279
+ */
5280
+ (extension, path21) => {
5281
+ return `Unknown file extension "${extension}" for ${path21}`;
5282
+ },
5283
+ TypeError
5284
+ );
5285
+ codes.ERR_INVALID_ARG_VALUE = createError(
5286
+ "ERR_INVALID_ARG_VALUE",
5287
+ /**
5288
+ * @param {string} name
5289
+ * @param {unknown} value
5290
+ * @param {string} [reason='is invalid']
5291
+ */
5292
+ (name, value, reason = "is invalid") => {
5293
+ let inspected = inspect(value);
5294
+ if (inspected.length > 128) {
5295
+ inspected = `${inspected.slice(0, 128)}...`;
5296
+ }
5297
+ const type = name.includes(".") ? "property" : "argument";
5298
+ return `The ${type} '${name}' ${reason}. Received ${inspected}`;
5299
+ },
5300
+ TypeError
5301
+ // Note: extra classes have been shaken out.
5302
+ // , RangeError
5303
+ );
5304
+ captureLargerStackTrace = hideStackFrames(
5305
+ /**
5306
+ * @param {Error} error
5307
+ * @returns {Error}
5308
+ */
5309
+ // @ts-expect-error: fine
5310
+ function(error) {
5311
+ const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
5312
+ if (stackTraceLimitIsWritable) {
5313
+ userStackTraceLimit = Error.stackTraceLimit;
5314
+ Error.stackTraceLimit = Number.POSITIVE_INFINITY;
5315
+ }
5316
+ Error.captureStackTrace(error);
5317
+ if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
5318
+ return error;
5319
+ }
5320
+ );
5321
+ }
5322
+ });
5323
+
5324
+ // node_modules/import-meta-resolve/lib/package-json-reader.js
5325
+ import fs9 from "fs";
5326
+ import path11 from "path";
5327
+ import { fileURLToPath as fileURLToPath2 } from "url";
5328
+ function read(jsonPath, { base, specifier }) {
5329
+ const existing = cache.get(jsonPath);
5330
+ if (existing) {
5331
+ return existing;
5332
+ }
5333
+ let string;
5334
+ try {
5335
+ string = fs9.readFileSync(path11.toNamespacedPath(jsonPath), "utf8");
5336
+ } catch (error) {
5337
+ const exception = (
5338
+ /** @type {ErrnoException} */
5339
+ error
5340
+ );
5341
+ if (exception.code !== "ENOENT") {
5342
+ throw exception;
5343
+ }
5344
+ }
5345
+ const result = {
5346
+ exists: false,
5347
+ pjsonPath: jsonPath,
5348
+ main: void 0,
5349
+ name: void 0,
5350
+ type: "none",
5351
+ // Ignore unknown types for forwards compatibility
5352
+ exports: void 0,
5353
+ imports: void 0
5354
+ };
5355
+ if (string !== void 0) {
5356
+ let parsed;
5357
+ try {
5358
+ parsed = JSON.parse(string);
5359
+ } catch (error_) {
5360
+ const cause = (
5361
+ /** @type {ErrnoException} */
5362
+ error_
5363
+ );
5364
+ const error = new ERR_INVALID_PACKAGE_CONFIG(
5365
+ jsonPath,
5366
+ (base ? `"${specifier}" from ` : "") + fileURLToPath2(base || specifier),
5367
+ cause.message
5368
+ );
5369
+ error.cause = cause;
5370
+ throw error;
5371
+ }
5372
+ result.exists = true;
5373
+ if (hasOwnProperty.call(parsed, "name") && typeof parsed.name === "string") {
5374
+ result.name = parsed.name;
5375
+ }
5376
+ if (hasOwnProperty.call(parsed, "main") && typeof parsed.main === "string") {
5377
+ result.main = parsed.main;
5378
+ }
5379
+ if (hasOwnProperty.call(parsed, "exports")) {
5380
+ result.exports = parsed.exports;
5381
+ }
5382
+ if (hasOwnProperty.call(parsed, "imports")) {
5383
+ result.imports = parsed.imports;
5384
+ }
5385
+ if (hasOwnProperty.call(parsed, "type") && (parsed.type === "commonjs" || parsed.type === "module")) {
5386
+ result.type = parsed.type;
5387
+ }
5388
+ }
5389
+ cache.set(jsonPath, result);
5390
+ return result;
5391
+ }
5392
+ function getPackageScopeConfig(resolved) {
5393
+ let packageJSONUrl = new URL("package.json", resolved);
5394
+ while (true) {
5395
+ const packageJSONPath2 = packageJSONUrl.pathname;
5396
+ if (packageJSONPath2.endsWith("node_modules/package.json")) {
5397
+ break;
5398
+ }
5399
+ const packageConfig = read(fileURLToPath2(packageJSONUrl), {
5400
+ specifier: resolved
5401
+ });
5402
+ if (packageConfig.exists) {
5403
+ return packageConfig;
5404
+ }
5405
+ const lastPackageJSONUrl = packageJSONUrl;
5406
+ packageJSONUrl = new URL("../package.json", packageJSONUrl);
5407
+ if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) {
5408
+ break;
5409
+ }
5410
+ }
5411
+ const packageJSONPath = fileURLToPath2(packageJSONUrl);
5412
+ return {
5413
+ pjsonPath: packageJSONPath,
5414
+ exists: false,
5415
+ type: "none"
5416
+ };
5417
+ }
5418
+ function getPackageType(url) {
5419
+ return getPackageScopeConfig(url).type;
5420
+ }
5421
+ var hasOwnProperty, ERR_INVALID_PACKAGE_CONFIG, cache;
5422
+ var init_package_json_reader = __esm({
5423
+ "node_modules/import-meta-resolve/lib/package-json-reader.js"() {
5424
+ "use strict";
5425
+ init_errors();
5426
+ hasOwnProperty = {}.hasOwnProperty;
5427
+ ({ ERR_INVALID_PACKAGE_CONFIG } = codes);
5428
+ cache = /* @__PURE__ */ new Map();
5429
+ }
5430
+ });
5431
+
5432
+ // node_modules/import-meta-resolve/lib/get-format.js
5433
+ import { fileURLToPath as fileURLToPath3 } from "url";
5434
+ function mimeToFormat(mime) {
5435
+ if (mime && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime))
5436
+ return "module";
5437
+ if (mime === "application/json") return "json";
5438
+ return null;
5439
+ }
5440
+ function getDataProtocolModuleFormat(parsed) {
5441
+ const { 1: mime } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(
5442
+ parsed.pathname
5443
+ ) || [null, null, null];
5444
+ return mimeToFormat(mime);
5445
+ }
5446
+ function extname(url) {
5447
+ const pathname = url.pathname;
5448
+ let index2 = pathname.length;
5449
+ while (index2--) {
5450
+ const code = pathname.codePointAt(index2);
5451
+ if (code === 47) {
5452
+ return "";
5453
+ }
5454
+ if (code === 46) {
5455
+ return pathname.codePointAt(index2 - 1) === 47 ? "" : pathname.slice(index2);
5456
+ }
5457
+ }
5458
+ return "";
5459
+ }
5460
+ function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
5461
+ const value = extname(url);
5462
+ if (value === ".js") {
5463
+ const packageType = getPackageType(url);
5464
+ if (packageType !== "none") {
5465
+ return packageType;
5466
+ }
5467
+ return "commonjs";
5468
+ }
5469
+ if (value === "") {
5470
+ const packageType = getPackageType(url);
5471
+ if (packageType === "none" || packageType === "commonjs") {
5472
+ return "commonjs";
5473
+ }
5474
+ return "module";
5475
+ }
5476
+ const format2 = extensionFormatMap[value];
5477
+ if (format2) return format2;
5478
+ if (ignoreErrors) {
5479
+ return void 0;
5480
+ }
5481
+ const filepath = fileURLToPath3(url);
5482
+ throw new ERR_UNKNOWN_FILE_EXTENSION(value, filepath);
5483
+ }
5484
+ function getHttpProtocolModuleFormat() {
5485
+ }
5486
+ function defaultGetFormatWithoutErrors(url, context) {
5487
+ const protocol = url.protocol;
5488
+ if (!hasOwnProperty2.call(protocolHandlers, protocol)) {
5489
+ return null;
5490
+ }
5491
+ return protocolHandlers[protocol](url, context, true) || null;
5492
+ }
5493
+ var ERR_UNKNOWN_FILE_EXTENSION, hasOwnProperty2, extensionFormatMap, protocolHandlers;
5494
+ var init_get_format = __esm({
5495
+ "node_modules/import-meta-resolve/lib/get-format.js"() {
5496
+ "use strict";
5497
+ init_package_json_reader();
5498
+ init_errors();
5499
+ ({ ERR_UNKNOWN_FILE_EXTENSION } = codes);
5500
+ hasOwnProperty2 = {}.hasOwnProperty;
5501
+ extensionFormatMap = {
5502
+ // @ts-expect-error: hush.
5503
+ __proto__: null,
5504
+ ".cjs": "commonjs",
5505
+ ".js": "module",
5506
+ ".json": "json",
5507
+ ".mjs": "module"
5508
+ };
5509
+ protocolHandlers = {
5510
+ // @ts-expect-error: hush.
5511
+ __proto__: null,
5512
+ "data:": getDataProtocolModuleFormat,
5513
+ "file:": getFileProtocolModuleFormat,
5514
+ "http:": getHttpProtocolModuleFormat,
5515
+ "https:": getHttpProtocolModuleFormat,
5516
+ "node:"() {
5517
+ return "builtin";
5518
+ }
5519
+ };
5520
+ }
5521
+ });
5522
+
5523
+ // node_modules/import-meta-resolve/lib/utils.js
5524
+ function getDefaultConditions() {
5525
+ return DEFAULT_CONDITIONS;
5526
+ }
5527
+ function getDefaultConditionsSet() {
5528
+ return DEFAULT_CONDITIONS_SET;
5529
+ }
5530
+ function getConditionsSet(conditions) {
5531
+ if (conditions !== void 0 && conditions !== getDefaultConditions()) {
5532
+ if (!Array.isArray(conditions)) {
5533
+ throw new ERR_INVALID_ARG_VALUE(
5534
+ "conditions",
5535
+ conditions,
5536
+ "expected an array"
5537
+ );
5538
+ }
5539
+ return new Set(conditions);
5540
+ }
5541
+ return getDefaultConditionsSet();
5542
+ }
5543
+ var ERR_INVALID_ARG_VALUE, DEFAULT_CONDITIONS, DEFAULT_CONDITIONS_SET;
5544
+ var init_utils = __esm({
5545
+ "node_modules/import-meta-resolve/lib/utils.js"() {
5546
+ "use strict";
5547
+ init_errors();
5548
+ ({ ERR_INVALID_ARG_VALUE } = codes);
5549
+ DEFAULT_CONDITIONS = Object.freeze(["node", "import"]);
5550
+ DEFAULT_CONDITIONS_SET = new Set(DEFAULT_CONDITIONS);
5551
+ }
5552
+ });
5553
+
5554
+ // node_modules/import-meta-resolve/lib/resolve.js
5555
+ import assert2 from "assert";
5556
+ import { statSync, realpathSync } from "fs";
5557
+ import process2 from "process";
5558
+ import { fileURLToPath as fileURLToPath4, pathToFileURL as pathToFileURL4 } from "url";
5559
+ import path12 from "path";
5560
+ import { builtinModules } from "module";
5561
+ function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, internal, base, isTarget) {
5562
+ if (process2.noDeprecation) {
5563
+ return;
5564
+ }
5565
+ const pjsonPath = fileURLToPath4(packageJsonUrl);
5566
+ const double = doubleSlashRegEx.exec(isTarget ? target : request) !== null;
5567
+ process2.emitWarning(
5568
+ `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 ${fileURLToPath4(base)}` : ""}.`,
5569
+ "DeprecationWarning",
5570
+ "DEP0166"
5571
+ );
5572
+ }
5573
+ function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
5574
+ if (process2.noDeprecation) {
5575
+ return;
5576
+ }
5577
+ const format2 = defaultGetFormatWithoutErrors(url, { parentURL: base.href });
5578
+ if (format2 !== "module") return;
5579
+ const urlPath = fileURLToPath4(url.href);
5580
+ const packagePath = fileURLToPath4(new URL(".", packageJsonUrl));
5581
+ const basePath = fileURLToPath4(base);
5582
+ if (!main) {
5583
+ process2.emitWarning(
5584
+ `No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(
5585
+ packagePath.length
5586
+ )}", imported from ${basePath}.
5587
+ Default "index" lookups for the main are deprecated for ES modules.`,
5588
+ "DeprecationWarning",
5589
+ "DEP0151"
5590
+ );
5591
+ } else if (path12.resolve(packagePath, main) !== urlPath) {
5592
+ process2.emitWarning(
5593
+ `Package ${packagePath} has a "main" field set to "${main}", excluding the full filename and extension to the resolved file at "${urlPath.slice(
5594
+ packagePath.length
5595
+ )}", imported from ${basePath}.
5596
+ Automatic extension resolution of the "main" field is deprecated for ES modules.`,
5597
+ "DeprecationWarning",
5598
+ "DEP0151"
5599
+ );
5600
+ }
5601
+ }
5602
+ function tryStatSync(path21) {
5603
+ try {
5604
+ return statSync(path21);
5605
+ } catch {
5606
+ }
5607
+ }
5608
+ function fileExists(url) {
5609
+ const stats = statSync(url, { throwIfNoEntry: false });
5610
+ const isFile = stats ? stats.isFile() : void 0;
5611
+ return isFile === null || isFile === void 0 ? false : isFile;
5612
+ }
5613
+ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
5614
+ let guess;
5615
+ if (packageConfig.main !== void 0) {
5616
+ guess = new URL(packageConfig.main, packageJsonUrl);
5617
+ if (fileExists(guess)) return guess;
5618
+ const tries2 = [
5619
+ `./${packageConfig.main}.js`,
5620
+ `./${packageConfig.main}.json`,
5621
+ `./${packageConfig.main}.node`,
5622
+ `./${packageConfig.main}/index.js`,
5623
+ `./${packageConfig.main}/index.json`,
5624
+ `./${packageConfig.main}/index.node`
5625
+ ];
5626
+ let i2 = -1;
5627
+ while (++i2 < tries2.length) {
5628
+ guess = new URL(tries2[i2], packageJsonUrl);
5629
+ if (fileExists(guess)) break;
5630
+ guess = void 0;
5631
+ }
5632
+ if (guess) {
5633
+ emitLegacyIndexDeprecation(
5634
+ guess,
5635
+ packageJsonUrl,
5636
+ base,
5637
+ packageConfig.main
5638
+ );
5639
+ return guess;
5640
+ }
5641
+ }
5642
+ const tries = ["./index.js", "./index.json", "./index.node"];
5643
+ let i = -1;
5644
+ while (++i < tries.length) {
5645
+ guess = new URL(tries[i], packageJsonUrl);
5646
+ if (fileExists(guess)) break;
5647
+ guess = void 0;
5648
+ }
5649
+ if (guess) {
5650
+ emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
5651
+ return guess;
5652
+ }
5653
+ throw new ERR_MODULE_NOT_FOUND(
5654
+ fileURLToPath4(new URL(".", packageJsonUrl)),
5655
+ fileURLToPath4(base)
5656
+ );
5657
+ }
5658
+ function finalizeResolution(resolved, base, preserveSymlinks) {
5659
+ if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) {
5660
+ throw new ERR_INVALID_MODULE_SPECIFIER(
5661
+ resolved.pathname,
5662
+ 'must not include encoded "/" or "\\" characters',
5663
+ fileURLToPath4(base)
5664
+ );
5665
+ }
5666
+ let filePath;
5667
+ try {
5668
+ filePath = fileURLToPath4(resolved);
5669
+ } catch (error) {
5670
+ const cause = (
5671
+ /** @type {ErrnoException} */
5672
+ error
5673
+ );
5674
+ Object.defineProperty(cause, "input", { value: String(resolved) });
5675
+ Object.defineProperty(cause, "module", { value: String(base) });
5676
+ throw cause;
5677
+ }
5678
+ const stats = tryStatSync(
5679
+ filePath.endsWith("/") ? filePath.slice(-1) : filePath
5680
+ );
5681
+ if (stats && stats.isDirectory()) {
5682
+ const error = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, fileURLToPath4(base));
5683
+ error.url = String(resolved);
5684
+ throw error;
5685
+ }
5686
+ if (!stats || !stats.isFile()) {
5687
+ const error = new ERR_MODULE_NOT_FOUND(
5688
+ filePath || resolved.pathname,
5689
+ base && fileURLToPath4(base),
5690
+ true
5691
+ );
5692
+ error.url = String(resolved);
5693
+ throw error;
5694
+ }
5695
+ if (!preserveSymlinks) {
5696
+ const real = realpathSync(filePath);
5697
+ const { search, hash } = resolved;
5698
+ resolved = pathToFileURL4(real + (filePath.endsWith(path12.sep) ? "/" : ""));
5699
+ resolved.search = search;
5700
+ resolved.hash = hash;
5701
+ }
5702
+ return resolved;
5703
+ }
5704
+ function importNotDefined(specifier, packageJsonUrl, base) {
5705
+ return new ERR_PACKAGE_IMPORT_NOT_DEFINED(
5706
+ specifier,
5707
+ packageJsonUrl && fileURLToPath4(new URL(".", packageJsonUrl)),
5708
+ fileURLToPath4(base)
5709
+ );
5710
+ }
5711
+ function exportsNotFound(subpath, packageJsonUrl, base) {
5712
+ return new ERR_PACKAGE_PATH_NOT_EXPORTED(
5713
+ fileURLToPath4(new URL(".", packageJsonUrl)),
5714
+ subpath,
5715
+ base && fileURLToPath4(base)
5716
+ );
5717
+ }
5718
+ function throwInvalidSubpath(request, match, packageJsonUrl, internal, base) {
5719
+ const reason = `request is not a valid match in pattern "${match}" for the "${internal ? "imports" : "exports"}" resolution of ${fileURLToPath4(packageJsonUrl)}`;
5720
+ throw new ERR_INVALID_MODULE_SPECIFIER(
5721
+ request,
5722
+ reason,
5723
+ base && fileURLToPath4(base)
5724
+ );
5725
+ }
5726
+ function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
5727
+ target = typeof target === "object" && target !== null ? JSON.stringify(target, null, "") : `${target}`;
5728
+ return new ERR_INVALID_PACKAGE_TARGET(
5729
+ fileURLToPath4(new URL(".", packageJsonUrl)),
5730
+ subpath,
5731
+ target,
5732
+ internal,
5733
+ base && fileURLToPath4(base)
5734
+ );
5735
+ }
5736
+ function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base, pattern, internal, isPathMap, conditions) {
5737
+ if (subpath !== "" && !pattern && target[target.length - 1] !== "/")
5738
+ throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
5739
+ if (!target.startsWith("./")) {
5740
+ if (internal && !target.startsWith("../") && !target.startsWith("/")) {
5741
+ let isURL = false;
5742
+ try {
5743
+ new URL(target);
5744
+ isURL = true;
5745
+ } catch {
5746
+ }
5747
+ if (!isURL) {
5748
+ const exportTarget = pattern ? RegExpPrototypeSymbolReplace.call(
5749
+ patternRegEx,
5750
+ target,
5751
+ () => subpath
5752
+ ) : target + subpath;
5753
+ return packageResolve(exportTarget, packageJsonUrl, conditions);
5754
+ }
5755
+ }
5756
+ throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
5757
+ }
5758
+ if (invalidSegmentRegEx.exec(target.slice(2)) !== null) {
5759
+ if (deprecatedInvalidSegmentRegEx.exec(target.slice(2)) === null) {
5760
+ if (!isPathMap) {
5761
+ const request = pattern ? match.replace("*", () => subpath) : match + subpath;
5762
+ const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(
5763
+ patternRegEx,
5764
+ target,
5765
+ () => subpath
5766
+ ) : target;
5767
+ emitInvalidSegmentDeprecation(
5768
+ resolvedTarget,
5769
+ request,
5770
+ match,
5771
+ packageJsonUrl,
5772
+ internal,
5773
+ base,
5774
+ true
5775
+ );
5776
+ }
5777
+ } else {
5778
+ throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
5779
+ }
5780
+ }
5781
+ const resolved = new URL(target, packageJsonUrl);
5782
+ const resolvedPath = resolved.pathname;
5783
+ const packagePath = new URL(".", packageJsonUrl).pathname;
5784
+ if (!resolvedPath.startsWith(packagePath))
5785
+ throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
5786
+ if (subpath === "") return resolved;
5787
+ if (invalidSegmentRegEx.exec(subpath) !== null) {
5788
+ const request = pattern ? match.replace("*", () => subpath) : match + subpath;
5789
+ if (deprecatedInvalidSegmentRegEx.exec(subpath) === null) {
5790
+ if (!isPathMap) {
5791
+ const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(
5792
+ patternRegEx,
5793
+ target,
5794
+ () => subpath
5795
+ ) : target;
5796
+ emitInvalidSegmentDeprecation(
5797
+ resolvedTarget,
5798
+ request,
5799
+ match,
5800
+ packageJsonUrl,
5801
+ internal,
5802
+ base,
5803
+ false
5804
+ );
5805
+ }
5806
+ } else {
5807
+ throwInvalidSubpath(request, match, packageJsonUrl, internal, base);
5808
+ }
5809
+ }
5810
+ if (pattern) {
5811
+ return new URL(
5812
+ RegExpPrototypeSymbolReplace.call(
5813
+ patternRegEx,
5814
+ resolved.href,
5815
+ () => subpath
5816
+ )
5817
+ );
5818
+ }
5819
+ return new URL(subpath, resolved);
5820
+ }
5821
+ function isArrayIndex(key) {
5822
+ const keyNumber = Number(key);
5823
+ if (`${keyNumber}` !== key) return false;
5824
+ return keyNumber >= 0 && keyNumber < 4294967295;
5825
+ }
5826
+ function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions) {
5827
+ if (typeof target === "string") {
5828
+ return resolvePackageTargetString(
5829
+ target,
5830
+ subpath,
5831
+ packageSubpath,
5832
+ packageJsonUrl,
5833
+ base,
5834
+ pattern,
5835
+ internal,
5836
+ isPathMap,
5837
+ conditions
5838
+ );
5839
+ }
5840
+ if (Array.isArray(target)) {
5841
+ const targetList = target;
5842
+ if (targetList.length === 0) return null;
5843
+ let lastException;
5844
+ let i = -1;
5845
+ while (++i < targetList.length) {
5846
+ const targetItem = targetList[i];
5847
+ let resolveResult;
5848
+ try {
5849
+ resolveResult = resolvePackageTarget(
5850
+ packageJsonUrl,
5851
+ targetItem,
5852
+ subpath,
5853
+ packageSubpath,
5854
+ base,
5855
+ pattern,
5856
+ internal,
5857
+ isPathMap,
5858
+ conditions
5859
+ );
5860
+ } catch (error) {
5861
+ const exception = (
5862
+ /** @type {ErrnoException} */
5863
+ error
5864
+ );
5865
+ lastException = exception;
5866
+ if (exception.code === "ERR_INVALID_PACKAGE_TARGET") continue;
5867
+ throw error;
5868
+ }
5869
+ if (resolveResult === void 0) continue;
5870
+ if (resolveResult === null) {
5871
+ lastException = null;
5872
+ continue;
5873
+ }
5874
+ return resolveResult;
5875
+ }
5876
+ if (lastException === void 0 || lastException === null) {
5877
+ return null;
5878
+ }
5879
+ throw lastException;
5880
+ }
5881
+ if (typeof target === "object" && target !== null) {
5882
+ const keys = Object.getOwnPropertyNames(target);
5883
+ let i = -1;
5884
+ while (++i < keys.length) {
5885
+ const key = keys[i];
5886
+ if (isArrayIndex(key)) {
5887
+ throw new ERR_INVALID_PACKAGE_CONFIG2(
5888
+ fileURLToPath4(packageJsonUrl),
5889
+ base,
5890
+ '"exports" cannot contain numeric property keys.'
5891
+ );
5892
+ }
5893
+ }
5894
+ i = -1;
5895
+ while (++i < keys.length) {
5896
+ const key = keys[i];
5897
+ if (key === "default" || conditions && conditions.has(key)) {
5898
+ const conditionalTarget = (
5899
+ /** @type {unknown} */
5900
+ target[key]
5901
+ );
5902
+ const resolveResult = resolvePackageTarget(
5903
+ packageJsonUrl,
5904
+ conditionalTarget,
5905
+ subpath,
5906
+ packageSubpath,
5907
+ base,
5908
+ pattern,
5909
+ internal,
5910
+ isPathMap,
5911
+ conditions
5912
+ );
5913
+ if (resolveResult === void 0) continue;
5914
+ return resolveResult;
5915
+ }
5916
+ }
5917
+ return null;
5918
+ }
5919
+ if (target === null) {
5920
+ return null;
5921
+ }
5922
+ throw invalidPackageTarget(
5923
+ packageSubpath,
5924
+ target,
5925
+ packageJsonUrl,
5926
+ internal,
5927
+ base
5928
+ );
5929
+ }
5930
+ function isConditionalExportsMainSugar(exports, packageJsonUrl, base) {
5931
+ if (typeof exports === "string" || Array.isArray(exports)) return true;
5932
+ if (typeof exports !== "object" || exports === null) return false;
5933
+ const keys = Object.getOwnPropertyNames(exports);
5934
+ let isConditionalSugar = false;
5935
+ let i = 0;
5936
+ let keyIndex = -1;
5937
+ while (++keyIndex < keys.length) {
5938
+ const key = keys[keyIndex];
5939
+ const currentIsConditionalSugar = key === "" || key[0] !== ".";
5940
+ if (i++ === 0) {
5941
+ isConditionalSugar = currentIsConditionalSugar;
5942
+ } else if (isConditionalSugar !== currentIsConditionalSugar) {
5943
+ throw new ERR_INVALID_PACKAGE_CONFIG2(
5944
+ fileURLToPath4(packageJsonUrl),
5945
+ base,
5946
+ `"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.`
5947
+ );
5948
+ }
5949
+ }
5950
+ return isConditionalSugar;
5951
+ }
5952
+ function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
5953
+ if (process2.noDeprecation) {
5954
+ return;
5955
+ }
5956
+ const pjsonPath = fileURLToPath4(pjsonUrl);
5957
+ if (emittedPackageWarnings.has(pjsonPath + "|" + match)) return;
5958
+ emittedPackageWarnings.add(pjsonPath + "|" + match);
5959
+ process2.emitWarning(
5960
+ `Use of deprecated trailing slash pattern mapping "${match}" in the "exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath4(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`,
5961
+ "DeprecationWarning",
5962
+ "DEP0155"
5963
+ );
5964
+ }
5965
+ function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions) {
5966
+ let exports = packageConfig.exports;
5967
+ if (isConditionalExportsMainSugar(exports, packageJsonUrl, base)) {
5968
+ exports = { ".": exports };
5969
+ }
5970
+ if (own2.call(exports, packageSubpath) && !packageSubpath.includes("*") && !packageSubpath.endsWith("/")) {
5971
+ const target = exports[packageSubpath];
5972
+ const resolveResult = resolvePackageTarget(
5973
+ packageJsonUrl,
5974
+ target,
5975
+ "",
5976
+ packageSubpath,
5977
+ base,
5978
+ false,
5979
+ false,
5980
+ false,
5981
+ conditions
5982
+ );
5983
+ if (resolveResult === null || resolveResult === void 0) {
5984
+ throw exportsNotFound(packageSubpath, packageJsonUrl, base);
5985
+ }
5986
+ return resolveResult;
5987
+ }
5988
+ let bestMatch = "";
5989
+ let bestMatchSubpath = "";
5990
+ const keys = Object.getOwnPropertyNames(exports);
5991
+ let i = -1;
5992
+ while (++i < keys.length) {
5993
+ const key = keys[i];
5994
+ const patternIndex = key.indexOf("*");
5995
+ if (patternIndex !== -1 && packageSubpath.startsWith(key.slice(0, patternIndex))) {
5996
+ if (packageSubpath.endsWith("/")) {
5997
+ emitTrailingSlashPatternDeprecation(
5998
+ packageSubpath,
5999
+ packageJsonUrl,
6000
+ base
6001
+ );
6002
+ }
6003
+ const patternTrailer = key.slice(patternIndex + 1);
6004
+ if (packageSubpath.length >= key.length && packageSubpath.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
6005
+ bestMatch = key;
6006
+ bestMatchSubpath = packageSubpath.slice(
6007
+ patternIndex,
6008
+ packageSubpath.length - patternTrailer.length
6009
+ );
6010
+ }
6011
+ }
6012
+ }
6013
+ if (bestMatch) {
6014
+ const target = (
6015
+ /** @type {unknown} */
6016
+ exports[bestMatch]
6017
+ );
6018
+ const resolveResult = resolvePackageTarget(
6019
+ packageJsonUrl,
6020
+ target,
6021
+ bestMatchSubpath,
6022
+ bestMatch,
6023
+ base,
6024
+ true,
6025
+ false,
6026
+ packageSubpath.endsWith("/"),
6027
+ conditions
6028
+ );
6029
+ if (resolveResult === null || resolveResult === void 0) {
6030
+ throw exportsNotFound(packageSubpath, packageJsonUrl, base);
6031
+ }
6032
+ return resolveResult;
6033
+ }
6034
+ throw exportsNotFound(packageSubpath, packageJsonUrl, base);
6035
+ }
6036
+ function patternKeyCompare(a, b) {
6037
+ const aPatternIndex = a.indexOf("*");
6038
+ const bPatternIndex = b.indexOf("*");
6039
+ const baseLengthA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
6040
+ const baseLengthB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
6041
+ if (baseLengthA > baseLengthB) return -1;
6042
+ if (baseLengthB > baseLengthA) return 1;
6043
+ if (aPatternIndex === -1) return 1;
6044
+ if (bPatternIndex === -1) return -1;
6045
+ if (a.length > b.length) return -1;
6046
+ if (b.length > a.length) return 1;
6047
+ return 0;
6048
+ }
6049
+ function packageImportsResolve(name, base, conditions) {
6050
+ if (name === "#" || name.startsWith("#/") || name.endsWith("/")) {
6051
+ const reason = "is not a valid internal imports specifier name";
6052
+ throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, fileURLToPath4(base));
6053
+ }
6054
+ let packageJsonUrl;
6055
+ const packageConfig = getPackageScopeConfig(base);
6056
+ if (packageConfig.exists) {
6057
+ packageJsonUrl = pathToFileURL4(packageConfig.pjsonPath);
6058
+ const imports = packageConfig.imports;
6059
+ if (imports) {
6060
+ if (own2.call(imports, name) && !name.includes("*")) {
6061
+ const resolveResult = resolvePackageTarget(
6062
+ packageJsonUrl,
6063
+ imports[name],
6064
+ "",
6065
+ name,
6066
+ base,
6067
+ false,
6068
+ true,
6069
+ false,
6070
+ conditions
6071
+ );
6072
+ if (resolveResult !== null && resolveResult !== void 0) {
6073
+ return resolveResult;
6074
+ }
6075
+ } else {
6076
+ let bestMatch = "";
6077
+ let bestMatchSubpath = "";
6078
+ const keys = Object.getOwnPropertyNames(imports);
6079
+ let i = -1;
6080
+ while (++i < keys.length) {
6081
+ const key = keys[i];
6082
+ const patternIndex = key.indexOf("*");
6083
+ if (patternIndex !== -1 && name.startsWith(key.slice(0, -1))) {
6084
+ const patternTrailer = key.slice(patternIndex + 1);
6085
+ if (name.length >= key.length && name.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
6086
+ bestMatch = key;
6087
+ bestMatchSubpath = name.slice(
6088
+ patternIndex,
6089
+ name.length - patternTrailer.length
6090
+ );
6091
+ }
6092
+ }
6093
+ }
6094
+ if (bestMatch) {
6095
+ const target = imports[bestMatch];
6096
+ const resolveResult = resolvePackageTarget(
6097
+ packageJsonUrl,
6098
+ target,
6099
+ bestMatchSubpath,
6100
+ bestMatch,
6101
+ base,
6102
+ true,
6103
+ true,
6104
+ false,
6105
+ conditions
6106
+ );
6107
+ if (resolveResult !== null && resolveResult !== void 0) {
6108
+ return resolveResult;
6109
+ }
6110
+ }
6111
+ }
6112
+ }
6113
+ }
6114
+ throw importNotDefined(name, packageJsonUrl, base);
6115
+ }
6116
+ function parsePackageName(specifier, base) {
6117
+ let separatorIndex = specifier.indexOf("/");
6118
+ let validPackageName = true;
6119
+ let isScoped = false;
6120
+ if (specifier[0] === "@") {
6121
+ isScoped = true;
6122
+ if (separatorIndex === -1 || specifier.length === 0) {
6123
+ validPackageName = false;
6124
+ } else {
6125
+ separatorIndex = specifier.indexOf("/", separatorIndex + 1);
6126
+ }
6127
+ }
6128
+ const packageName = separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
6129
+ if (invalidPackageNameRegEx.exec(packageName) !== null) {
6130
+ validPackageName = false;
6131
+ }
6132
+ if (!validPackageName) {
6133
+ throw new ERR_INVALID_MODULE_SPECIFIER(
6134
+ specifier,
6135
+ "is not a valid package name",
6136
+ fileURLToPath4(base)
6137
+ );
6138
+ }
6139
+ const packageSubpath = "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex));
6140
+ return { packageName, packageSubpath, isScoped };
6141
+ }
6142
+ function packageResolve(specifier, base, conditions) {
6143
+ if (builtinModules.includes(specifier)) {
6144
+ return new URL("node:" + specifier);
6145
+ }
6146
+ const { packageName, packageSubpath, isScoped } = parsePackageName(
6147
+ specifier,
6148
+ base
6149
+ );
6150
+ const packageConfig = getPackageScopeConfig(base);
6151
+ if (packageConfig.exists) {
6152
+ const packageJsonUrl2 = pathToFileURL4(packageConfig.pjsonPath);
6153
+ if (packageConfig.name === packageName && packageConfig.exports !== void 0 && packageConfig.exports !== null) {
6154
+ return packageExportsResolve(
6155
+ packageJsonUrl2,
6156
+ packageSubpath,
6157
+ packageConfig,
6158
+ base,
6159
+ conditions
6160
+ );
6161
+ }
6162
+ }
6163
+ let packageJsonUrl = new URL(
6164
+ "./node_modules/" + packageName + "/package.json",
6165
+ base
6166
+ );
6167
+ let packageJsonPath = fileURLToPath4(packageJsonUrl);
6168
+ let lastPath;
6169
+ do {
6170
+ const stat = tryStatSync(packageJsonPath.slice(0, -13));
6171
+ if (!stat || !stat.isDirectory()) {
6172
+ lastPath = packageJsonPath;
6173
+ packageJsonUrl = new URL(
6174
+ (isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json",
6175
+ packageJsonUrl
6176
+ );
6177
+ packageJsonPath = fileURLToPath4(packageJsonUrl);
6178
+ continue;
6179
+ }
6180
+ const packageConfig2 = read(packageJsonPath, { base, specifier });
6181
+ if (packageConfig2.exports !== void 0 && packageConfig2.exports !== null) {
6182
+ return packageExportsResolve(
6183
+ packageJsonUrl,
6184
+ packageSubpath,
6185
+ packageConfig2,
6186
+ base,
6187
+ conditions
6188
+ );
6189
+ }
6190
+ if (packageSubpath === ".") {
6191
+ return legacyMainResolve(packageJsonUrl, packageConfig2, base);
6192
+ }
6193
+ return new URL(packageSubpath, packageJsonUrl);
6194
+ } while (packageJsonPath.length !== lastPath.length);
6195
+ throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath4(base), false);
6196
+ }
6197
+ function isRelativeSpecifier(specifier) {
6198
+ if (specifier[0] === ".") {
6199
+ if (specifier.length === 1 || specifier[1] === "/") return true;
6200
+ if (specifier[1] === "." && (specifier.length === 2 || specifier[2] === "/")) {
6201
+ return true;
6202
+ }
6203
+ }
6204
+ return false;
6205
+ }
6206
+ function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) {
6207
+ if (specifier === "") return false;
6208
+ if (specifier[0] === "/") return true;
6209
+ return isRelativeSpecifier(specifier);
6210
+ }
6211
+ function moduleResolve(specifier, base, conditions, preserveSymlinks) {
6212
+ if (conditions === void 0) {
6213
+ conditions = getConditionsSet();
6214
+ }
6215
+ const protocol = base.protocol;
6216
+ const isData = protocol === "data:";
6217
+ const isRemote = isData || protocol === "http:" || protocol === "https:";
6218
+ let resolved;
6219
+ if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) {
6220
+ try {
6221
+ resolved = new URL(specifier, base);
6222
+ } catch (error_) {
6223
+ const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
6224
+ error.cause = error_;
6225
+ throw error;
6226
+ }
6227
+ } else if (protocol === "file:" && specifier[0] === "#") {
6228
+ resolved = packageImportsResolve(specifier, base, conditions);
6229
+ } else {
6230
+ try {
6231
+ resolved = new URL(specifier);
6232
+ } catch (error_) {
6233
+ if (isRemote && !builtinModules.includes(specifier)) {
6234
+ const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
6235
+ error.cause = error_;
6236
+ throw error;
6237
+ }
6238
+ resolved = packageResolve(specifier, base, conditions);
6239
+ }
6240
+ }
6241
+ assert2.ok(resolved !== void 0, "expected to be defined");
6242
+ if (resolved.protocol !== "file:") {
6243
+ return resolved;
6244
+ }
6245
+ return finalizeResolution(resolved, base, preserveSymlinks);
6246
+ }
6247
+ var 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;
6248
+ var init_resolve2 = __esm({
6249
+ "node_modules/import-meta-resolve/lib/resolve.js"() {
6250
+ "use strict";
6251
+ init_get_format();
6252
+ init_errors();
6253
+ init_package_json_reader();
6254
+ init_utils();
6255
+ RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
6256
+ ({
6257
+ ERR_NETWORK_IMPORT_DISALLOWED,
6258
+ ERR_INVALID_MODULE_SPECIFIER,
6259
+ ERR_INVALID_PACKAGE_CONFIG: ERR_INVALID_PACKAGE_CONFIG2,
6260
+ ERR_INVALID_PACKAGE_TARGET,
6261
+ ERR_MODULE_NOT_FOUND,
6262
+ ERR_PACKAGE_IMPORT_NOT_DEFINED,
6263
+ ERR_PACKAGE_PATH_NOT_EXPORTED,
6264
+ ERR_UNSUPPORTED_DIR_IMPORT,
6265
+ ERR_UNSUPPORTED_RESOLVE_REQUEST
6266
+ } = codes);
6267
+ own2 = {}.hasOwnProperty;
6268
+ 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;
6269
+ 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;
6270
+ invalidPackageNameRegEx = /^\.|%|\\/;
6271
+ patternRegEx = /\*/g;
6272
+ encodedSeparatorRegEx = /%2f|%5c/i;
6273
+ emittedPackageWarnings = /* @__PURE__ */ new Set();
6274
+ doubleSlashRegEx = /[/\\]{2}/;
6275
+ }
6276
+ });
6277
+
6278
+ // node_modules/import-meta-resolve/index.js
6279
+ var init_import_meta_resolve = __esm({
6280
+ "node_modules/import-meta-resolve/index.js"() {
6281
+ "use strict";
6282
+ init_resolve2();
6283
+ }
6284
+ });
6285
+
4973
6286
  // src/server/runnable-environment.ts
4974
6287
  var runnable_environment_exports = {};
4975
6288
  __export(runnable_environment_exports, {
4976
6289
  NastiModuleRunner: () => NastiModuleRunner,
4977
6290
  createModuleRunner: () => createModuleRunner
4978
6291
  });
4979
- import path11 from "path";
4980
- import fs9 from "fs";
4981
- import { builtinModules, createRequire as createRequire4 } from "module";
4982
- import { pathToFileURL as pathToFileURL4 } from "url";
6292
+ import path13 from "path";
6293
+ import fs10 from "fs";
6294
+ import { builtinModules as builtinModules2 } from "module";
6295
+ import { pathToFileURL as pathToFileURL5 } from "url";
4983
6296
  function createModuleRunner(environment) {
4984
6297
  if (environment.consumer !== "server") {
4985
6298
  throw new Error(
@@ -4992,17 +6305,19 @@ var debug4, NODE_BUILTINS, NastiModuleRunner, AsyncFunction;
4992
6305
  var init_runnable_environment = __esm({
4993
6306
  "src/server/runnable-environment.ts"() {
4994
6307
  "use strict";
6308
+ init_import_meta_resolve();
4995
6309
  init_transformer();
4996
6310
  init_env();
4997
6311
  init_debug();
4998
6312
  debug4 = createDebugger("nasti:ssr");
4999
- NODE_BUILTINS = /* @__PURE__ */ new Set([...builtinModules, ...builtinModules.map((m) => `node:${m}`)]);
6313
+ NODE_BUILTINS = /* @__PURE__ */ new Set([...builtinModules2, ...builtinModules2.map((m) => `node:${m}`)]);
5000
6314
  NastiModuleRunner = class {
5001
6315
  environment;
5002
6316
  config;
5003
6317
  cache = /* @__PURE__ */ new Map();
5004
6318
  envDefine;
5005
- require;
6319
+ externalImportParent;
6320
+ externalImportConditions;
5006
6321
  constructor(environment) {
5007
6322
  this.environment = environment;
5008
6323
  this.config = environment.config;
@@ -5011,10 +6326,15 @@ var init_runnable_environment = __esm({
5011
6326
  this.config.mode,
5012
6327
  ssrDefineOverrides(environment.consumer)
5013
6328
  );
5014
- this.require = createRequire4(path11.join(this.config.root, "package.json"));
6329
+ this.externalImportParent = pathToFileURL5(path13.join(this.config.root, "package.json"));
6330
+ this.externalImportConditions = /* @__PURE__ */ new Set([
6331
+ ...environment.options.resolve.conditions.filter((condition) => condition !== "require"),
6332
+ "node",
6333
+ "import"
6334
+ ]);
5015
6335
  const handlers = {
5016
6336
  fetchModule: async (id, importer) => this.fetchModule(id, importer),
5017
- getBuiltins: () => [/^node:/, ...builtinModules]
6337
+ getBuiltins: () => [/^node:/, ...builtinModules2]
5018
6338
  };
5019
6339
  environment.hot.setInvokeHandler?.(handlers);
5020
6340
  }
@@ -5035,9 +6355,9 @@ var init_runnable_environment = __esm({
5035
6355
  this.cache.clear();
5036
6356
  }
5037
6357
  resolveToId(rawUrl) {
5038
- if (path11.isAbsolute(rawUrl) && fs9.existsSync(rawUrl.split("?")[0])) return rawUrl;
6358
+ if (path13.isAbsolute(rawUrl) && fs10.existsSync(rawUrl.split("?")[0])) return rawUrl;
5039
6359
  const clean = rawUrl.replace(/^\//, "");
5040
- return path11.resolve(this.config.root, clean);
6360
+ return path13.resolve(this.config.root, clean);
5041
6361
  }
5042
6362
  /**
5043
6363
  * fetchModule(invoke 契约方法):环境管线产出 runner 可执行代码。
@@ -5046,14 +6366,14 @@ var init_runnable_environment = __esm({
5046
6366
  */
5047
6367
  async fetchModule(id, importer) {
5048
6368
  if (NODE_BUILTINS.has(id)) return { externalize: id };
5049
- if (!id.startsWith(".") && !path11.isAbsolute(id) && !id.startsWith("\0")) {
6369
+ if (!id.startsWith(".") && !path13.isAbsolute(id) && !id.startsWith("\0")) {
5050
6370
  return { externalize: id };
5051
6371
  }
5052
6372
  const container = this.environment.pluginContainer;
5053
6373
  let resolvedId = id;
5054
6374
  if (id.startsWith(".") && importer) {
5055
6375
  const resolved = await container.resolveId(id, importer);
5056
- resolvedId = resolved ? typeof resolved === "string" ? resolved : resolved.id : path11.resolve(path11.dirname(importer.split("?")[0]), id);
6376
+ resolvedId = resolved ? typeof resolved === "string" ? resolved : resolved.id : path13.resolve(path13.dirname(importer.split("?")[0]), id);
5057
6377
  }
5058
6378
  resolvedId = this.completeExtension(resolvedId);
5059
6379
  const cleanId = resolvedId.split("?")[0];
@@ -5061,8 +6381,8 @@ var init_runnable_environment = __esm({
5061
6381
  const loaded = await container.load(resolvedId);
5062
6382
  if (loaded != null) {
5063
6383
  code = typeof loaded === "string" ? loaded : loaded.code;
5064
- } else if (fs9.existsSync(cleanId)) {
5065
- code = fs9.readFileSync(cleanId, "utf-8");
6384
+ } else if (fs10.existsSync(cleanId)) {
6385
+ code = fs10.readFileSync(cleanId, "utf-8");
5066
6386
  } else {
5067
6387
  throw new Error(`[nasti:ssr] cannot load module: ${resolvedId}`);
5068
6388
  }
@@ -5116,19 +6436,19 @@ var init_runnable_environment = __esm({
5116
6436
  completeExtension(id) {
5117
6437
  const clean = id.split("?")[0];
5118
6438
  const query = id.includes("?") ? id.slice(id.indexOf("?")) : "";
5119
- if (fs9.existsSync(clean) && fs9.statSync(clean).isFile()) return id;
6439
+ if (fs10.existsSync(clean) && fs10.statSync(clean).isFile()) return id;
5120
6440
  const jsMatch = clean.match(/^(.*)\.([mc]?)jsx?$/);
5121
6441
  if (jsMatch) {
5122
6442
  for (const tsExt of [`.${jsMatch[2]}ts`, `.${jsMatch[2]}tsx`]) {
5123
- if (fs9.existsSync(jsMatch[1] + tsExt)) return jsMatch[1] + tsExt + query;
6443
+ if (fs10.existsSync(jsMatch[1] + tsExt)) return jsMatch[1] + tsExt + query;
5124
6444
  }
5125
6445
  }
5126
6446
  for (const ext of this.config.resolve.extensions) {
5127
- if (fs9.existsSync(clean + ext)) return clean + ext + query;
6447
+ if (fs10.existsSync(clean + ext)) return clean + ext + query;
5128
6448
  }
5129
6449
  for (const ext of this.config.resolve.extensions) {
5130
- const indexPath = path11.join(clean, `index${ext}`);
5131
- if (fs9.existsSync(indexPath)) return indexPath;
6450
+ const indexPath = path13.join(clean, `index${ext}`);
6451
+ if (fs10.existsSync(indexPath)) return indexPath;
5132
6452
  }
5133
6453
  return id;
5134
6454
  }
@@ -5155,10 +6475,10 @@ var init_runnable_environment = __esm({
5155
6475
  return;
5156
6476
  }
5157
6477
  const ssrImport = async (dep) => {
5158
- if (NODE_BUILTINS.has(dep) || !dep.startsWith(".") && !path11.isAbsolute(dep) && !dep.startsWith("\0")) {
6478
+ if (NODE_BUILTINS.has(dep) || !dep.startsWith(".") && !path13.isAbsolute(dep) && !dep.startsWith("\0")) {
5159
6479
  return this.importExternal(dep);
5160
6480
  }
5161
- const depId = dep.startsWith(".") ? this.completeExtension(path11.resolve(path11.dirname(fetched.id.split("?")[0]), dep)) : this.completeExtension(dep);
6481
+ const depId = dep.startsWith(".") ? this.completeExtension(path13.resolve(path13.dirname(fetched.id.split("?")[0]), dep)) : this.completeExtension(dep);
5162
6482
  return this.instantiate(depId);
5163
6483
  };
5164
6484
  const ssrExportAll = (sourceModule) => {
@@ -5173,7 +6493,7 @@ var init_runnable_environment = __esm({
5173
6493
  }
5174
6494
  };
5175
6495
  const importMeta = {
5176
- url: pathToFileURL4(fetched.id.split("?")[0]).href,
6496
+ url: pathToFileURL5(fetched.id.split("?")[0]).href,
5177
6497
  env: { SSR: true, MODE: this.config.mode, DEV: this.config.mode !== "production", PROD: this.config.mode === "production" },
5178
6498
  hot: void 0
5179
6499
  };
@@ -5190,20 +6510,21 @@ var init_runnable_environment = __esm({
5190
6510
  }
5191
6511
  async importExternal(spec) {
5192
6512
  try {
5193
- return await (spec.startsWith("node:") || !path11.isAbsolute(spec) ? import(this.resolveExternalSpecifier(spec)) : import(pathToFileURL4(spec).href));
6513
+ return await (spec.startsWith("node:") || !path13.isAbsolute(spec) ? import(this.resolveExternalSpecifier(spec)) : import(pathToFileURL5(spec).href));
5194
6514
  } catch (err) {
5195
6515
  throw new Error(`[nasti:ssr] failed to import external "${spec}": ${err.message}`);
5196
6516
  }
5197
6517
  }
5198
- /** bare specifier → 项目 node_modules 的绝对 URL(避免相对 Nasti 自身解析) */
6518
+ /** bare specifier → 项目 node_modules ESM URL(避免相对 Nasti 自身解析) */
5199
6519
  resolveExternalSpecifier(spec) {
5200
6520
  if (spec.startsWith("node:")) return spec;
5201
6521
  if (NODE_BUILTINS.has(spec)) return `node:${spec}`;
5202
- try {
5203
- return pathToFileURL4(this.require.resolve(spec)).href;
5204
- } catch {
5205
- return spec;
5206
- }
6522
+ return moduleResolve(
6523
+ spec,
6524
+ this.externalImportParent,
6525
+ this.externalImportConditions,
6526
+ false
6527
+ ).href;
5207
6528
  }
5208
6529
  };
5209
6530
  AsyncFunction = Object.getPrototypeOf(async function() {
@@ -5250,7 +6571,7 @@ var init_react = __esm({
5250
6571
  });
5251
6572
 
5252
6573
  // src/build/reporter.ts
5253
- import path12 from "path";
6574
+ import path14 from "path";
5254
6575
  import { gzipSync } from "zlib";
5255
6576
  import pc5 from "picocolors";
5256
6577
  async function tryNativeReporterPlugin(config, logger) {
@@ -5291,7 +6612,7 @@ function reportBuildOutput(output, config, logger) {
5291
6612
  if (compressed && content != null) {
5292
6613
  gzip = gzipSync(typeof content === "string" ? Buffer.from(content) : content).byteLength;
5293
6614
  }
5294
- const ext = path12.extname(file.fileName);
6615
+ const ext = path14.extname(file.fileName);
5295
6616
  const group = file.type === "chunk" ? "js" : ext === ".css" ? "css" : "assets";
5296
6617
  entries.push({ name: file.fileName, size, gzip, group });
5297
6618
  }
@@ -5339,12 +6660,12 @@ var init_reporter = __esm({
5339
6660
  });
5340
6661
 
5341
6662
  // src/core/build-app-context.ts
5342
- import fs10 from "fs";
5343
- import path13 from "path";
6663
+ import fs11 from "fs";
6664
+ import path15 from "path";
5344
6665
  function createBuildAppContext(config, results) {
5345
6666
  const output = [];
5346
6667
  const emitted = /* @__PURE__ */ new Set();
5347
- const outDir = path13.resolve(config.root, config.build.outDir);
6668
+ const outDir = path15.resolve(config.root, config.build.outDir);
5348
6669
  let environmentArtifacts;
5349
6670
  return {
5350
6671
  config,
@@ -5400,14 +6721,14 @@ function createBuildAppContext(config, results) {
5400
6721
  if (environmentArtifacts.has(collisionKey)) {
5401
6722
  throw new Error(`[nasti] app artifact conflicts with environment output: ${fileName}`);
5402
6723
  }
5403
- const target = path13.resolve(outDir, ...fileName.split("/"));
5404
- const relative = path13.relative(outDir, target);
5405
- if (relative.startsWith("..") || path13.isAbsolute(relative)) {
6724
+ const target = path15.resolve(outDir, ...fileName.split("/"));
6725
+ const relative = path15.relative(outDir, target);
6726
+ if (relative.startsWith("..") || path15.isAbsolute(relative)) {
5406
6727
  throw new Error(`[nasti] app artifact must stay inside build.outDir: ${file.fileName}`);
5407
6728
  }
5408
6729
  assertNoSymlinkComponents(outDir, fileName);
5409
- fs10.mkdirSync(path13.dirname(target), { recursive: true });
5410
- fs10.writeFileSync(target, file.source);
6730
+ fs11.mkdirSync(path15.dirname(target), { recursive: true });
6731
+ fs11.writeFileSync(target, file.source);
5411
6732
  const artifact = {
5412
6733
  ...file,
5413
6734
  fileName,
@@ -5423,10 +6744,10 @@ function joinPublicPath(base, fileName) {
5423
6744
  return `${base.endsWith("/") ? base : `${base}/`}${fileName.replace(/^\//, "")}`;
5424
6745
  }
5425
6746
  function normalizeEnvironmentFileName(fileName) {
5426
- return path13.posix.normalize(fileName.replace(/\\/g, "/").replace(/^\.\//, ""));
6747
+ return path15.posix.normalize(fileName.replace(/\\/g, "/").replace(/^\.\//, ""));
5427
6748
  }
5428
6749
  function isInvalidEnvironmentFileName(fileName) {
5429
- return !fileName || fileName === "." || fileName === ".." || fileName.startsWith("../") || path13.posix.isAbsolute(fileName) || /^[A-Za-z]:\//.test(fileName);
6750
+ return !fileName || fileName === "." || fileName === ".." || fileName.startsWith("../") || path15.posix.isAbsolute(fileName) || /^[A-Za-z]:\//.test(fileName);
5430
6751
  }
5431
6752
  function normalizeAppFileName(fileName) {
5432
6753
  const normalized = normalizeEnvironmentFileName(fileName);
@@ -5443,14 +6764,14 @@ function collectEnvironmentArtifacts(config, results, appOutDir) {
5443
6764
  for (const [environmentName, result] of Object.entries(results)) {
5444
6765
  const environment = config.environments[environmentName];
5445
6766
  if (!environment) continue;
5446
- const environmentOutDir = path13.resolve(config.root, environment.build.outDir);
6767
+ const environmentOutDir = path15.resolve(config.root, environment.build.outDir);
5447
6768
  for (const artifact of result.output) {
5448
- const artifactPath = path13.resolve(
6769
+ const artifactPath = path15.resolve(
5449
6770
  environmentOutDir,
5450
6771
  ...normalizeEnvironmentFileName(artifact.fileName).split("/")
5451
6772
  );
5452
- const relative = path13.relative(appOutDir, artifactPath);
5453
- if (!relative.startsWith("..") && !path13.isAbsolute(relative)) {
6773
+ const relative = path15.relative(appOutDir, artifactPath);
6774
+ if (!relative.startsWith("..") && !path15.isAbsolute(relative)) {
5454
6775
  occupied.add(artifactCollisionKey(relative));
5455
6776
  }
5456
6777
  }
@@ -5460,10 +6781,10 @@ function collectEnvironmentArtifacts(config, results, appOutDir) {
5460
6781
  function assertNoSymlinkComponents(outDir, fileName) {
5461
6782
  let current = outDir;
5462
6783
  for (const segment of fileName.split("/")) {
5463
- current = path13.join(current, segment);
6784
+ current = path15.join(current, segment);
5464
6785
  let stats;
5465
6786
  try {
5466
- stats = fs10.lstatSync(current);
6787
+ stats = fs11.lstatSync(current);
5467
6788
  } catch (error) {
5468
6789
  if (error.code === "ENOENT") continue;
5469
6790
  throw error;
@@ -5496,16 +6817,16 @@ __export(build_exports, {
5496
6817
  resolveClientEntries: () => resolveClientEntries,
5497
6818
  toRolldownPlugins: () => toRolldownPlugins
5498
6819
  });
5499
- import path14 from "path";
5500
- import fs11 from "fs";
5501
- import { builtinModules as builtinModules2 } from "module";
6820
+ import path16 from "path";
6821
+ import fs12 from "fs";
6822
+ import { builtinModules as builtinModules3 } from "module";
5502
6823
  import { rolldown } from "rolldown";
5503
6824
  import pc6 from "picocolors";
5504
6825
  function getRolldownOptions(environment, entryPoints, rolldownPlugins) {
5505
6826
  const config = environment.config;
5506
6827
  const envOptions = environment.options;
5507
6828
  const isServer = environment.consumer === "server";
5508
- const outDir = path14.resolve(config.root, envOptions.build.outDir);
6829
+ const outDir = path16.resolve(config.root, envOptions.build.outDir);
5509
6830
  const assetsDir = envOptions.build.assetsDir;
5510
6831
  const {
5511
6832
  output: userOutput,
@@ -5545,7 +6866,7 @@ function getRolldownOptions(environment, entryPoints, rolldownPlugins) {
5545
6866
  // 相对/绝对/虚拟模块照常打包。需要内联依赖时经 rolldownOptions.external 覆盖。
5546
6867
  external: restInputOptions.external ?? ((id) => {
5547
6868
  if (NODE_BUILTINS2.has(id)) return true;
5548
- return !id.startsWith(".") && !path14.isAbsolute(id) && !id.startsWith("\0") && !id.startsWith("virtual:");
6869
+ return !id.startsWith(".") && !path16.isAbsolute(id) && !id.startsWith("\0") && !id.startsWith("virtual:");
5549
6870
  })
5550
6871
  } : {}
5551
6872
  };
@@ -5702,11 +7023,11 @@ function prepareBuildOutputDirectories(config, buildableNames) {
5702
7023
  const protectedPaths = /* @__PURE__ */ new Set();
5703
7024
  const clientIsBuilt = buildableNames.includes("client");
5704
7025
  if (!clientIsBuilt && config.build.emptyOutDir) {
5705
- directories.add(path14.resolve(config.root, config.build.outDir));
7026
+ directories.add(path16.resolve(config.root, config.build.outDir));
5706
7027
  }
5707
7028
  for (const name of buildableNames) {
5708
7029
  const environment = config.environments[name];
5709
- const outDir = path14.resolve(config.root, environment.build.outDir);
7030
+ const outDir = path16.resolve(config.root, environment.build.outDir);
5710
7031
  if (!environment.build.emptyOutDir) {
5711
7032
  protectedPaths.add(outDir);
5712
7033
  continue;
@@ -5714,8 +7035,8 @@ function prepareBuildOutputDirectories(config, buildableNames) {
5714
7035
  if (!environment.driver) directories.add(outDir);
5715
7036
  }
5716
7037
  const containsPath = (parent, child) => {
5717
- const relative = path14.relative(parent, child);
5718
- return relative === "" || !relative.startsWith("..") && !path14.isAbsolute(relative);
7038
+ const relative = path16.relative(parent, child);
7039
+ return relative === "" || !relative.startsWith("..") && !path16.isAbsolute(relative);
5719
7040
  };
5720
7041
  const roots = [...directories].filter(
5721
7042
  (directory) => ![...protectedPaths].some((protectedPath) => containsPath(directory, protectedPath))
@@ -5723,7 +7044,7 @@ function prepareBuildOutputDirectories(config, buildableNames) {
5723
7044
  (directory, index2, all) => !all.slice(0, index2).some((parent) => containsPath(parent, directory))
5724
7045
  );
5725
7046
  for (const directory of roots) {
5726
- if (fs11.existsSync(directory)) fs11.rmSync(directory, { recursive: true, force: true });
7047
+ if (fs12.existsSync(directory)) fs12.rmSync(directory, { recursive: true, force: true });
5727
7048
  }
5728
7049
  }
5729
7050
  function assertDriverBuildResult(environment, result) {
@@ -5742,7 +7063,7 @@ function resolveClientEntries(config, html) {
5742
7063
  if (configuredEntries.length > 0) return configuredEntries;
5743
7064
  const entryPoints = [];
5744
7065
  const htmlFile = config.environments.client?.html;
5745
- const htmlDir = htmlFile ? path14.dirname(htmlFile) : config.root;
7066
+ const htmlDir = htmlFile ? path16.dirname(htmlFile) : config.root;
5746
7067
  if (html) {
5747
7068
  const scriptMatches = html.matchAll(/<script[^>]+src=["']([^"']+)["'][^>]*>/gi);
5748
7069
  for (const match of scriptMatches) {
@@ -5750,7 +7071,7 @@ function resolveClientEntries(config, html) {
5750
7071
  if (src && !src.startsWith("http")) {
5751
7072
  const cleanSrc = src.split(/[?#]/, 1)[0];
5752
7073
  entryPoints.push(
5753
- cleanSrc.startsWith("/") ? path14.resolve(config.root, cleanSrc.replace(/^\//, "")) : path14.resolve(htmlDir, cleanSrc)
7074
+ cleanSrc.startsWith("/") ? path16.resolve(config.root, cleanSrc.replace(/^\//, "")) : path16.resolve(htmlDir, cleanSrc)
5754
7075
  );
5755
7076
  }
5756
7077
  }
@@ -5758,8 +7079,8 @@ function resolveClientEntries(config, html) {
5758
7079
  if (entryPoints.length === 0) {
5759
7080
  const fallbackEntries = ["src/main.ts", "src/main.tsx", "src/main.js", "src/index.ts", "src/index.tsx", "src/index.js"];
5760
7081
  for (const entry of fallbackEntries) {
5761
- const fullPath = path14.resolve(config.root, entry);
5762
- if (fs11.existsSync(fullPath)) {
7082
+ const fullPath = path16.resolve(config.root, entry);
7083
+ if (fs12.existsSync(fullPath)) {
5763
7084
  entryPoints.push(fullPath);
5764
7085
  break;
5765
7086
  }
@@ -5789,7 +7110,7 @@ async function build(inlineConfig = {}) {
5789
7110
  const startTime = performance.now();
5790
7111
  logger.info(
5791
7112
  pc6.cyan(`
5792
- nasti v${"2.5.0"} `) + pc6.green(`building for ${config.mode}...`)
7113
+ nasti v${"2.5.1"} `) + pc6.green(`building for ${config.mode}...`)
5793
7114
  );
5794
7115
  debug6?.(`root: ${config.root}`);
5795
7116
  const buildableNames = Object.keys(config.environments).filter((name) => {
@@ -5864,7 +7185,7 @@ nasti v${"2.5.0"} `) + pc6.green(`building for ${config.mode}...`)
5864
7185
  }
5865
7186
  async function buildClientEnvironment(config) {
5866
7187
  const logger = config.logger;
5867
- const outDir = path14.resolve(config.root, config.build.outDir);
7188
+ const outDir = path16.resolve(config.root, config.build.outDir);
5868
7189
  const cssEngine = createCssEngine();
5869
7190
  const pluginList = resolvePluginList(config, config.plugins, {
5870
7191
  cssEngine,
@@ -5887,8 +7208,8 @@ async function buildClientEnvironment(config) {
5887
7208
  assertDriverBuildResult(clientEnv, result);
5888
7209
  return { environment: clientEnv, result: finalizeEnvironmentResult(clientEnv, result) };
5889
7210
  }
5890
- fs11.mkdirSync(outDir, { recursive: true });
5891
- const htmlFile = config.environments.client.html ?? path14.resolve(config.root, "index.html");
7211
+ fs12.mkdirSync(outDir, { recursive: true });
7212
+ const htmlFile = config.environments.client.html ?? path16.resolve(config.root, "index.html");
5892
7213
  const html = await readHtmlFile(config.root, htmlFile);
5893
7214
  const entryPoints = resolveClientEntries(config, html);
5894
7215
  if (entryPoints.length === 0) {
@@ -5938,7 +7259,7 @@ async function buildClientEnvironment(config) {
5938
7259
  );
5939
7260
  }
5940
7261
  }
5941
- fs11.writeFileSync(path14.resolve(outDir, "index.html"), processedHtml);
7262
+ fs12.writeFileSync(path16.resolve(outDir, "index.html"), processedHtml);
5942
7263
  }
5943
7264
  if (!nativeReporter && config.logLevel !== "silent") {
5944
7265
  reportBuildOutput(output, config, logger);
@@ -5992,7 +7313,7 @@ async function buildServerEnvironment(config, name) {
5992
7313
  }
5993
7314
  }
5994
7315
  for (const entry of envOptions.entry) {
5995
- if (!fs11.existsSync(entry)) {
7316
+ if (!fs12.existsSync(entry)) {
5996
7317
  await environment.close();
5997
7318
  throw new Error(`[nasti] environment "${name}" entry not found: ${entry}`);
5998
7319
  }
@@ -6006,13 +7327,13 @@ async function buildServerEnvironment(config, name) {
6006
7327
  envOptions.entry,
6007
7328
  rolldownPlugins
6008
7329
  );
6009
- fs11.mkdirSync(outDir, { recursive: true });
7330
+ fs12.mkdirSync(outDir, { recursive: true });
6010
7331
  const bundle2 = await rolldown(inputOptions);
6011
7332
  const { output } = await bundle2.write(outputOptions);
6012
7333
  await bundle2.close();
6013
7334
  if (cssEngine) environment.setBuildMetadata({ css: getCssMetadata(cssEngine) });
6014
7335
  logger.info(
6015
- pc6.dim(` [${name}] `) + output.map((o) => path14.join(envOptions.build.outDir, o.fileName)).join(pc6.dim(", "))
7336
+ pc6.dim(` [${name}] `) + output.map((o) => path16.join(envOptions.build.outDir, o.fileName)).join(pc6.dim(", "))
6016
7337
  );
6017
7338
  return {
6018
7339
  environment,
@@ -6044,9 +7365,9 @@ function escapeRegExp(string) {
6044
7365
  return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
6045
7366
  }
6046
7367
  function replaceEntryScript(html, facadeModuleId, fileName, config, htmlFile, urlPrefix) {
6047
- const rootRelative = path14.relative(config.root, facadeModuleId).split(path14.sep).join("/");
6048
- const resolvedHtmlFile = path14.resolve(config.root, htmlFile);
6049
- const htmlRelative = path14.relative(path14.dirname(resolvedHtmlFile), facadeModuleId).split(path14.sep).join("/");
7368
+ const rootRelative = path16.relative(config.root, facadeModuleId).split(path16.sep).join("/");
7369
+ const resolvedHtmlFile = path16.resolve(config.root, htmlFile);
7370
+ const htmlRelative = path16.relative(path16.dirname(resolvedHtmlFile), facadeModuleId).split(path16.sep).join("/");
6050
7371
  const candidates = /* @__PURE__ */ new Set([
6051
7372
  rootRelative,
6052
7373
  `/${rootRelative}`,
@@ -6079,7 +7400,7 @@ var init_build = __esm({
6079
7400
  init_plugin_api();
6080
7401
  init_build_app_context();
6081
7402
  debug6 = createDebugger("nasti:build");
6082
- NODE_BUILTINS2 = /* @__PURE__ */ new Set([...builtinModules2, ...builtinModules2.map((m) => `node:${m}`)]);
7403
+ NODE_BUILTINS2 = /* @__PURE__ */ new Set([...builtinModules3, ...builtinModules3.map((m) => `node:${m}`)]);
6083
7404
  }
6084
7405
  });
6085
7406
 
@@ -6088,7 +7409,7 @@ var dev_engine_exports = {};
6088
7409
  __export(dev_engine_exports, {
6089
7410
  createBundledDevServer: () => createBundledDevServer
6090
7411
  });
6091
- import path15 from "path";
7412
+ import path17 from "path";
6092
7413
  import crypto3 from "crypto";
6093
7414
  import { WebSocketServer as WsServer2 } from "ws";
6094
7415
  import pc7 from "picocolors";
@@ -6173,7 +7494,7 @@ async function createBundledDevServer(opts) {
6173
7494
  }
6174
7495
  const url = `/${patchPath}`;
6175
7496
  logger.info(
6176
- pc7.green("hmr update ") + pc7.dim(changedFiles.map((f) => path15.relative(config.root, f)).join(", ")),
7497
+ pc7.green("hmr update ") + pc7.dim(changedFiles.map((f) => path17.relative(config.root, f)).join(", ")),
6177
7498
  { timestamp: true }
6178
7499
  );
6179
7500
  sendTo(clientId, { type: "hmr:update", path: url, url });
@@ -6328,7 +7649,7 @@ async function createBundledDevServer(opts) {
6328
7649
  return;
6329
7650
  }
6330
7651
  res.setHeader("ETag", hit.etag);
6331
- res.setHeader("Content-Type", MIME_TYPES[path15.extname(fileName)] ?? "application/octet-stream");
7652
+ res.setHeader("Content-Type", MIME_TYPES[path17.extname(fileName)] ?? "application/octet-stream");
6332
7653
  res.setHeader("Cache-Control", "no-cache");
6333
7654
  res.once("finish", () => {
6334
7655
  void engine.notifyPayloadDelivered(fileName).catch(
@@ -6369,7 +7690,7 @@ function stripCatchAllLoad(plugins) {
6369
7690
  );
6370
7691
  }
6371
7692
  function createReactRefreshRuntimePlugin(entryPoints) {
6372
- const entryIds = new Set(entryPoints.map((p) => path15.resolve(p)));
7693
+ const entryIds = new Set(entryPoints.map((p) => path17.resolve(p)));
6373
7694
  return {
6374
7695
  name: "nasti:bundled-react-refresh",
6375
7696
  resolveId(source) {
@@ -6387,7 +7708,7 @@ function createReactRefreshRuntimePlugin(entryPoints) {
6387
7708
  return null;
6388
7709
  },
6389
7710
  transform(code, id) {
6390
- if (!entryIds.has(path15.resolve(id.split("?")[0]))) return null;
7711
+ if (!entryIds.has(path17.resolve(id.split("?")[0]))) return null;
6391
7712
  return { code: `import ${JSON.stringify(PREAMBLE_SPEC)};
6392
7713
  ${code}`, map: null };
6393
7714
  }
@@ -6561,7 +7882,7 @@ __export(server_exports, {
6561
7882
  createServer: () => createServer
6562
7883
  });
6563
7884
  import http from "http";
6564
- import path16 from "path";
7885
+ import path18 from "path";
6565
7886
  import os from "os";
6566
7887
  import connect from "connect";
6567
7888
  import sirv from "sirv";
@@ -6654,19 +7975,19 @@ async function createServer(inlineConfig = {}) {
6654
7975
  app.use(bundledServer.middleware);
6655
7976
  }
6656
7977
  const ignoredSegments = /* @__PURE__ */ new Set(["node_modules", ".git", ".nasti"]);
6657
- const outDirAbs = path16.resolve(config.root, config.build.outDir);
7978
+ const outDirAbs = path18.resolve(config.root, config.build.outDir);
6658
7979
  const linkedPackageRoots = getLinkedPackageRoots(config.root).filter(
6659
7980
  (r) => r !== config.root && !isUnderRoot(config.root, r)
6660
7981
  );
6661
7982
  const watchTargets = [config.root, ...linkedPackageRoots];
6662
7983
  const watcher = watch(watchTargets, {
6663
7984
  ignored: (filePath) => {
6664
- if (filePath === outDirAbs || filePath.startsWith(outDirAbs + path16.sep)) return true;
7985
+ if (filePath === outDirAbs || filePath.startsWith(outDirAbs + path18.sep)) return true;
6665
7986
  for (const watchRoot of watchTargets) {
6666
7987
  if (filePath === watchRoot) return false;
6667
- const rel = path16.relative(watchRoot, filePath);
6668
- if (!rel || rel.startsWith("..") || path16.isAbsolute(rel)) continue;
6669
- for (const seg of rel.split(path16.sep)) {
7988
+ const rel = path18.relative(watchRoot, filePath);
7989
+ if (!rel || rel.startsWith("..") || path18.isAbsolute(rel)) continue;
7990
+ for (const seg of rel.split(path18.sep)) {
6670
7991
  if (ignoredSegments.has(seg)) return true;
6671
7992
  }
6672
7993
  return false;
@@ -6798,7 +8119,7 @@ async function createServer(inlineConfig = {}) {
6798
8119
  });
6799
8120
  };
6800
8121
  watcher.on("change", (file) => {
6801
- if (file.includes(`${path16.sep}node_modules${path16.sep}`) || file.endsWith(`${path16.sep}node_modules`)) {
8122
+ if (file.includes(`${path18.sep}node_modules${path18.sep}`) || file.endsWith(`${path18.sep}node_modules`)) {
6802
8123
  clearLinkedPackageRootsCache();
6803
8124
  }
6804
8125
  ssrRunner?.invalidateFile(file);
@@ -6806,7 +8127,7 @@ async function createServer(inlineConfig = {}) {
6806
8127
  notifyEnvironmentDrivers(file, "change");
6807
8128
  });
6808
8129
  watcher.on("add", (file) => {
6809
- if (file.includes(`${path16.sep}node_modules${path16.sep}`) || file.endsWith(`${path16.sep}node_modules`)) {
8130
+ if (file.includes(`${path18.sep}node_modules${path18.sep}`) || file.endsWith(`${path18.sep}node_modules`)) {
6810
8131
  clearLinkedPackageRootsCache();
6811
8132
  }
6812
8133
  ssrRunner?.invalidateFile(file);
@@ -6814,7 +8135,7 @@ async function createServer(inlineConfig = {}) {
6814
8135
  notifyEnvironmentDrivers(file, "add");
6815
8136
  });
6816
8137
  watcher.on("unlink", (file) => {
6817
- if (file.includes(`${path16.sep}node_modules${path16.sep}`) || file.endsWith(`${path16.sep}node_modules`)) {
8138
+ if (file.includes(`${path18.sep}node_modules${path18.sep}`) || file.endsWith(`${path18.sep}node_modules`)) {
6818
8139
  clearLinkedPackageRootsCache();
6819
8140
  }
6820
8141
  ssrRunner?.invalidateFile(file);
@@ -6846,7 +8167,7 @@ async function createServer(inlineConfig = {}) {
6846
8167
  const readyIn = Math.ceil(performance.now() - startTime);
6847
8168
  logger.info(
6848
8169
  `
6849
- ${pc8.cyan(pc8.bold("NASTI"))} ${pc8.cyan(`v${"2.5.0"}`)} ${pc8.dim("ready in")} ${pc8.bold(readyIn)} ${pc8.dim("ms")}
8170
+ ${pc8.cyan(pc8.bold("NASTI"))} ${pc8.cyan(`v${"2.5.1"}`)} ${pc8.dim("ready in")} ${pc8.bold(readyIn)} ${pc8.dim("ms")}
6850
8171
  `
6851
8172
  );
6852
8173
  printServerUrls(
@@ -6943,7 +8264,7 @@ async function createServer(inlineConfig = {}) {
6943
8264
  throw error;
6944
8265
  }
6945
8266
  app.use(transformMiddleware(transformContexts.get("client")));
6946
- const publicDir = path16.resolve(config.root, "public");
8267
+ const publicDir = path18.resolve(config.root, "public");
6947
8268
  app.use(sirv(publicDir, { dev: true, etag: true }));
6948
8269
  app.use(sirv(config.root, { dev: true, etag: true }));
6949
8270
  const postMiddlewares = [];
@@ -6987,7 +8308,7 @@ var init_server = __esm({
6987
8308
  });
6988
8309
 
6989
8310
  // src/plugins/electron.ts
6990
- import { builtinModules as builtinModules3 } from "module";
8311
+ import { builtinModules as builtinModules4 } from "module";
6991
8312
  function electronPlugin(config) {
6992
8313
  const external = /* @__PURE__ */ new Set([
6993
8314
  ...ELECTRON_MODULES,
@@ -7013,8 +8334,8 @@ var init_electron = __esm({
7013
8334
  "src/plugins/electron.ts"() {
7014
8335
  "use strict";
7015
8336
  NODE_BUILTINS3 = /* @__PURE__ */ new Set([
7016
- ...builtinModules3,
7017
- ...builtinModules3.map((m) => `node:${m}`)
8337
+ ...builtinModules4,
8338
+ ...builtinModules4.map((m) => `node:${m}`)
7018
8339
  ]);
7019
8340
  ELECTRON_MODULES = /* @__PURE__ */ new Set([
7020
8341
  "electron",
@@ -7033,25 +8354,25 @@ __export(electron_exports, {
7033
8354
  detectInstalledElectron: () => detectInstalledElectron,
7034
8355
  normalizePreload: () => normalizePreload
7035
8356
  });
7036
- import path17 from "path";
7037
- import fs12 from "fs";
7038
- import { createRequire as createRequire5 } from "module";
8357
+ import path19 from "path";
8358
+ import fs13 from "fs";
8359
+ import { createRequire as createRequire4 } from "module";
7039
8360
  import { rolldown as rolldown2 } from "rolldown";
7040
8361
  import pc9 from "picocolors";
7041
8362
  async function buildElectron(inlineConfig = {}) {
7042
8363
  const config = await resolveConfig({ ...inlineConfig, target: "electron" }, "build");
7043
8364
  const startTime = performance.now();
7044
8365
  assertElectronVersion(config);
7045
- console.log(pc9.cyan("\n\u26A1 nasti build (electron)") + pc9.dim(` v${"2.5.0"}`));
8366
+ console.log(pc9.cyan("\n\u26A1 nasti build (electron)") + pc9.dim(` v${"2.5.1"}`));
7046
8367
  console.log(pc9.dim(` root: ${config.root}`));
7047
8368
  console.log(pc9.dim(` mode: ${config.mode}`));
7048
8369
  console.log(pc9.dim(` target: electron (\u2265 ${config.electron.minVersion})`));
7049
- const outDir = path17.resolve(config.root, config.build.outDir);
7050
- if (config.build.emptyOutDir && fs12.existsSync(outDir)) {
7051
- fs12.rmSync(outDir, { recursive: true, force: true });
8370
+ const outDir = path19.resolve(config.root, config.build.outDir);
8371
+ if (config.build.emptyOutDir && fs13.existsSync(outDir)) {
8372
+ fs13.rmSync(outDir, { recursive: true, force: true });
7052
8373
  }
7053
- fs12.mkdirSync(outDir, { recursive: true });
7054
- const rendererOutDir = path17.join(outDir, "renderer");
8374
+ fs13.mkdirSync(outDir, { recursive: true });
8375
+ const rendererOutDir = path19.join(outDir, "renderer");
7055
8376
  const { build: build2 } = await Promise.resolve().then(() => (init_build(), build_exports));
7056
8377
  await build2(createElectronRendererConfig(config, inlineConfig, {
7057
8378
  build: {
@@ -7060,8 +8381,8 @@ async function buildElectron(inlineConfig = {}) {
7060
8381
  emptyOutDir: false
7061
8382
  }
7062
8383
  }));
7063
- const mainEntry = path17.resolve(config.root, config.electron.main);
7064
- if (!fs12.existsSync(mainEntry)) {
8384
+ const mainEntry = path19.resolve(config.root, config.electron.main);
8385
+ if (!fs13.existsSync(mainEntry)) {
7065
8386
  throw new Error(
7066
8387
  `Electron main entry not found: ${config.electron.main}
7067
8388
  \u5728 nasti.config.ts \u7684 electron.main \u6307\u5B9A\u4E3B\u8FDB\u7A0B\u5165\u53E3\u6587\u4EF6\u3002`
@@ -7075,11 +8396,11 @@ async function buildElectron(inlineConfig = {}) {
7075
8396
  const preloadEntries = normalizePreload(config.electron.preload, config.root);
7076
8397
  const preloadFiles = [];
7077
8398
  for (const entry of preloadEntries) {
7078
- if (!fs12.existsSync(entry)) {
8399
+ if (!fs13.existsSync(entry)) {
7079
8400
  console.warn(pc9.yellow(` \u26A0 preload entry not found, skipped: ${entry}`));
7080
8401
  continue;
7081
8402
  }
7082
- const base = path17.basename(entry).replace(/\.[^.]+$/, "");
8403
+ const base = path19.basename(entry).replace(/\.[^.]+$/, "");
7083
8404
  const out = outFileName(outDir, base, config.electron.preloadFormat);
7084
8405
  await bundleNode(config, entry, {
7085
8406
  outFile: out,
@@ -7091,10 +8412,10 @@ async function buildElectron(inlineConfig = {}) {
7091
8412
  const elapsed = ((performance.now() - startTime) / 1e3).toFixed(2);
7092
8413
  console.log(pc9.green(`
7093
8414
  \u2713 Electron build complete in ${elapsed}s`));
7094
- console.log(pc9.dim(` renderer: ${path17.relative(config.root, rendererOutDir)}/`));
7095
- console.log(pc9.dim(` main: ${path17.relative(config.root, mainFile)}`));
8415
+ console.log(pc9.dim(` renderer: ${path19.relative(config.root, rendererOutDir)}/`));
8416
+ console.log(pc9.dim(` main: ${path19.relative(config.root, mainFile)}`));
7096
8417
  for (const pf of preloadFiles) {
7097
- console.log(pc9.dim(` preload: ${path17.relative(config.root, pf)}`));
8418
+ console.log(pc9.dim(` preload: ${path19.relative(config.root, pf)}`));
7098
8419
  }
7099
8420
  console.log();
7100
8421
  return { rendererOutDir, mainFile, preloadFiles };
@@ -7139,7 +8460,7 @@ async function bundleNode(config, entry, opts) {
7139
8460
  },
7140
8461
  plugins: [oxcTransformPlugin, electronPlugin(config), resolvePlugin(config)]
7141
8462
  });
7142
- fs12.mkdirSync(path17.dirname(opts.outFile), { recursive: true });
8463
+ fs13.mkdirSync(path19.dirname(opts.outFile), { recursive: true });
7143
8464
  await bundle2.write({
7144
8465
  sourcemap: !!config.build.sourcemap,
7145
8466
  minify: !!config.build.minify,
@@ -7150,7 +8471,7 @@ async function bundleNode(config, entry, opts) {
7150
8471
  codeSplitting: false
7151
8472
  });
7152
8473
  await bundle2.close();
7153
- console.log(pc9.dim(` \u2713 ${opts.label} \u2192 ${path17.relative(config.root, opts.outFile)}`));
8474
+ console.log(pc9.dim(` \u2713 ${opts.label} \u2192 ${path19.relative(config.root, opts.outFile)}`));
7154
8475
  return opts.outFile;
7155
8476
  }
7156
8477
  function createElectronRendererConfig(config, inlineConfig = {}, overrides = {}) {
@@ -7172,13 +8493,13 @@ function createElectronRendererConfig(config, inlineConfig = {}, overrides = {})
7172
8493
  }
7173
8494
  };
7174
8495
  }
7175
- function outFileName(outDir, base, format) {
7176
- const ext = format === "cjs" ? ".cjs" : ".mjs";
7177
- return path17.join(outDir, base + ext);
8496
+ function outFileName(outDir, base, format2) {
8497
+ const ext = format2 === "cjs" ? ".cjs" : ".mjs";
8498
+ return path19.join(outDir, base + ext);
7178
8499
  }
7179
8500
  function normalizePreload(preload, root) {
7180
8501
  const list = Array.isArray(preload) ? preload : preload ? [preload] : [];
7181
- return list.map((p) => path17.resolve(root, p));
8502
+ return list.map((p) => path19.resolve(root, p));
7182
8503
  }
7183
8504
  function assertElectronVersion(config) {
7184
8505
  const min = config.electron.minVersion;
@@ -7193,16 +8514,16 @@ function assertElectronVersion(config) {
7193
8514
  }
7194
8515
  function detectInstalledElectron(root) {
7195
8516
  try {
7196
- const require2 = createRequire5(path17.resolve(root, "package.json"));
8517
+ const require2 = createRequire4(path19.resolve(root, "package.json"));
7197
8518
  const pkgPath = require2.resolve("electron/package.json");
7198
- const pkg = JSON.parse(fs12.readFileSync(pkgPath, "utf-8"));
8519
+ const pkg = JSON.parse(fs13.readFileSync(pkgPath, "utf-8"));
7199
8520
  const major = parseInt(String(pkg.version).split(".")[0], 10);
7200
8521
  return Number.isFinite(major) ? major : null;
7201
8522
  } catch {
7202
8523
  try {
7203
- const pkgPath = path17.resolve(root, "node_modules/electron/package.json");
7204
- if (!fs12.existsSync(pkgPath)) return null;
7205
- const pkg = JSON.parse(fs12.readFileSync(pkgPath, "utf-8"));
8524
+ const pkgPath = path19.resolve(root, "node_modules/electron/package.json");
8525
+ if (!fs13.existsSync(pkgPath)) return null;
8526
+ const pkg = JSON.parse(fs13.readFileSync(pkgPath, "utf-8"));
7206
8527
  const major = parseInt(String(pkg.version).split(".")[0], 10);
7207
8528
  return Number.isFinite(major) ? major : null;
7208
8529
  } catch {
@@ -7227,9 +8548,9 @@ __export(electron_dev_exports, {
7227
8548
  electronRendererDevPath: () => electronRendererDevPath,
7228
8549
  startElectronDev: () => startElectronDev
7229
8550
  });
7230
- import path18 from "path";
7231
- import fs13 from "fs";
7232
- import { createRequire as createRequire6 } from "module";
8551
+ import path20 from "path";
8552
+ import fs14 from "fs";
8553
+ import { createRequire as createRequire5 } from "module";
7233
8554
  import { spawn } from "child_process";
7234
8555
  import chokidar from "chokidar";
7235
8556
  import pc10 from "picocolors";
@@ -7238,7 +8559,7 @@ async function startElectronDev(inlineConfig = {}) {
7238
8559
  const { noSpawn, ...rest } = inlineConfig;
7239
8560
  const config = await resolveConfig({ ...rest, target: "electron" }, "serve");
7240
8561
  warnElectronVersion(config);
7241
- console.log(pc10.cyan("\n\u26A1 nasti electron dev") + pc10.dim(` v${"2.5.0"}`));
8562
+ console.log(pc10.cyan("\n\u26A1 nasti electron dev") + pc10.dim(` v${"2.5.1"}`));
7242
8563
  const { createServer: createServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
7243
8564
  const server = await createServer2({
7244
8565
  ...rest,
@@ -7248,11 +8569,11 @@ async function startElectronDev(inlineConfig = {}) {
7248
8569
  await server.listen();
7249
8570
  const devUrl = `http://localhost:${server.config.server.port}` + electronRendererDevPath(config.electron.renderer);
7250
8571
  console.log(pc10.dim(` renderer: ${devUrl}`));
7251
- const stageDir = path18.resolve(config.root, ".nasti");
7252
- fs13.mkdirSync(stageDir, { recursive: true });
7253
- const mainEntry = path18.resolve(config.root, config.electron.main);
8572
+ const stageDir = path20.resolve(config.root, ".nasti");
8573
+ fs14.mkdirSync(stageDir, { recursive: true });
8574
+ const mainEntry = path20.resolve(config.root, config.electron.main);
7254
8575
  const preloadEntries = normalizePreload(config.electron.preload, config.root);
7255
- const builtMainFile = path18.join(stageDir, "main" + extFor(config.electron.mainFormat));
8576
+ const builtMainFile = path20.join(stageDir, "main" + extFor(config.electron.mainFormat));
7256
8577
  const builtPreloadFiles = [];
7257
8578
  const compileAll = async () => {
7258
8579
  await compileNode(config, mainEntry, {
@@ -7262,9 +8583,9 @@ async function startElectronDev(inlineConfig = {}) {
7262
8583
  });
7263
8584
  builtPreloadFiles.length = 0;
7264
8585
  for (const entry of preloadEntries) {
7265
- if (!fs13.existsSync(entry)) continue;
7266
- const base = path18.basename(entry).replace(/\.[^.]+$/, "");
7267
- const out = path18.join(stageDir, base + extFor(config.electron.preloadFormat));
8586
+ if (!fs14.existsSync(entry)) continue;
8587
+ const base = path20.basename(entry).replace(/\.[^.]+$/, "");
8588
+ const out = path20.join(stageDir, base + extFor(config.electron.preloadFormat));
7268
8589
  await compileNode(config, entry, {
7269
8590
  outFile: out,
7270
8591
  format: config.electron.preloadFormat,
@@ -7303,7 +8624,7 @@ async function startElectronDev(inlineConfig = {}) {
7303
8624
  };
7304
8625
  spawnElectron();
7305
8626
  if (config.electron.autoRestart) {
7306
- const watchTargets = [mainEntry, ...preloadEntries].filter(fs13.existsSync);
8627
+ const watchTargets = [mainEntry, ...preloadEntries].filter(fs14.existsSync);
7307
8628
  const watcher = chokidar.watch(watchTargets, { ignoreInitial: true });
7308
8629
  let restarting = null;
7309
8630
  let pending = false;
@@ -7350,8 +8671,8 @@ async function startElectronDev(inlineConfig = {}) {
7350
8671
  });
7351
8672
  }
7352
8673
  }
7353
- function extFor(format) {
7354
- return format === "cjs" ? ".cjs" : ".mjs";
8674
+ function extFor(format2) {
8675
+ return format2 === "cjs" ? ".cjs" : ".mjs";
7355
8676
  }
7356
8677
  async function compileNode(config, entry, opts) {
7357
8678
  const env = loadEnv(config.mode, config.root, config.envPrefix);
@@ -7390,7 +8711,7 @@ async function compileNode(config, entry, opts) {
7390
8711
  platform: "node",
7391
8712
  plugins: [oxcTransformPlugin, electronPlugin(config), resolvePlugin(config)]
7392
8713
  });
7393
- fs13.mkdirSync(path18.dirname(opts.outFile), { recursive: true });
8714
+ fs14.mkdirSync(path20.dirname(opts.outFile), { recursive: true });
7394
8715
  await bundle2.write({
7395
8716
  file: opts.outFile,
7396
8717
  format: opts.format === "cjs" ? "cjs" : "esm",
@@ -7403,18 +8724,18 @@ async function compileNode(config, entry, opts) {
7403
8724
  await bundle2.close();
7404
8725
  }
7405
8726
  function electronRendererDevPath(renderer) {
7406
- const normalized = renderer.split(path18.sep).join("/").replace(/^\.?\//, "");
8727
+ const normalized = renderer.split(path20.sep).join("/").replace(/^\.?\//, "");
7407
8728
  return normalized === "index.html" ? "/" : `/${normalized}`;
7408
8729
  }
7409
8730
  function resolveElectronBinary(config) {
7410
- if (config.electron.electronPath && fs13.existsSync(config.electron.electronPath)) {
8731
+ if (config.electron.electronPath && fs14.existsSync(config.electron.electronPath)) {
7411
8732
  return config.electron.electronPath;
7412
8733
  }
7413
8734
  try {
7414
- const require2 = createRequire6(path18.resolve(config.root, "package.json"));
8735
+ const require2 = createRequire5(path20.resolve(config.root, "package.json"));
7415
8736
  const pathFile = require2.resolve("electron");
7416
8737
  const electronModule = require2(pathFile);
7417
- if (typeof electronModule === "string" && fs13.existsSync(electronModule)) {
8738
+ if (typeof electronModule === "string" && fs14.existsSync(electronModule)) {
7418
8739
  return electronModule;
7419
8740
  }
7420
8741
  } catch {
@@ -7589,20 +8910,20 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
7589
8910
  const logger = createCliLogger(options);
7590
8911
  try {
7591
8912
  const http2 = await import("http");
7592
- const path19 = await import("path");
8913
+ const path21 = await import("path");
7593
8914
  const os2 = await import("os");
7594
8915
  const sirv2 = (await import("sirv")).default;
7595
8916
  const connect2 = (await import("connect")).default;
7596
8917
  const { printServerUrls: printServerUrls2 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
7597
- const resolvedRoot = path19.resolve(root ?? ".");
7598
- const outDir = path19.resolve(resolvedRoot, options.outDir);
8918
+ const resolvedRoot = path21.resolve(root ?? ".");
8919
+ const outDir = path21.resolve(resolvedRoot, options.outDir);
7599
8920
  const app = connect2();
7600
8921
  app.use(sirv2(outDir, { single: true, etag: true, gzip: true, brotli: true }));
7601
8922
  const port = options.port;
7602
8923
  const host = options.host === true ? "0.0.0.0" : options.host ?? "localhost";
7603
8924
  http2.createServer(app).listen(port, host, () => {
7604
8925
  logger.info(`
7605
- ${pc11.cyan(pc11.bold("NASTI"))} ${pc11.cyan(`v${"2.5.0"}`)} ${pc11.dim("preview")}
8926
+ ${pc11.cyan(pc11.bold("NASTI"))} ${pc11.cyan(`v${"2.5.1"}`)} ${pc11.dim("preview")}
7606
8927
  `);
7607
8928
  printServerUrls2(
7608
8929
  {
@@ -7619,6 +8940,6 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
7619
8940
  }
7620
8941
  });
7621
8942
  cli.help();
7622
- cli.version("2.5.0");
8943
+ cli.version("2.5.1");
7623
8944
  cli.parse();
7624
8945
  //# sourceMappingURL=cli.js.map