@nasti-toolchain/nasti 2.5.0 → 2.5.2

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.
Files changed (60) hide show
  1. package/README.md +34 -2
  2. package/dist/build-CENae4VM.js +748 -0
  3. package/dist/build-CENae4VM.js.map +1 -0
  4. package/dist/build-vjh6h7PB.cjs +786 -0
  5. package/dist/build-vjh6h7PB.cjs.map +1 -0
  6. package/dist/cli.cjs +166 -7608
  7. package/dist/cli.cjs.map +1 -1
  8. package/dist/cli.d.cts +1 -2
  9. package/dist/cli.d.ts +1 -2
  10. package/dist/cli.js +166 -7606
  11. package/dist/cli.js.map +1 -1
  12. package/dist/client/hmr.cjs +0 -19
  13. package/dist/client/hmr.d.cts +14 -12
  14. package/dist/client/hmr.d.cts.map +1 -0
  15. package/dist/client/hmr.d.ts +14 -12
  16. package/dist/client/hmr.d.ts.map +1 -0
  17. package/dist/client/hmr.js +1 -1
  18. package/dist/dev-engine-DJL9sfv5.cjs +473 -0
  19. package/dist/dev-engine-DJL9sfv5.cjs.map +1 -0
  20. package/dist/dev-engine-DapuTPIz.js +469 -0
  21. package/dist/dev-engine-DapuTPIz.js.map +1 -0
  22. package/dist/electron-Bj8H-BJ6.js +278 -0
  23. package/dist/electron-Bj8H-BJ6.js.map +1 -0
  24. package/dist/electron-D0PSXz-a.cjs +316 -0
  25. package/dist/electron-D0PSXz-a.cjs.map +1 -0
  26. package/dist/electron-dev-BzI2IFnR.cjs +272 -0
  27. package/dist/electron-dev-BzI2IFnR.cjs.map +1 -0
  28. package/dist/electron-dev-CM15gsFp.js +251 -0
  29. package/dist/electron-dev-CM15gsFp.js.map +1 -0
  30. package/dist/env-GY7K1zPK.js +833 -0
  31. package/dist/env-GY7K1zPK.js.map +1 -0
  32. package/dist/env-lOj3yw8v.cjs +924 -0
  33. package/dist/env-lOj3yw8v.cjs.map +1 -0
  34. package/dist/environment-B2jCrhY2.js +1361 -0
  35. package/dist/environment-B2jCrhY2.js.map +1 -0
  36. package/dist/environment-CjmvoHIG.cjs +1443 -0
  37. package/dist/environment-CjmvoHIG.cjs.map +1 -0
  38. package/dist/index.cjs +453 -7976
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.d.cts +872 -817
  41. package/dist/index.d.cts.map +1 -0
  42. package/dist/index.d.ts +872 -817
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +418 -7939
  45. package/dist/index.js.map +1 -1
  46. package/dist/logger-BVZwdqqT.js +116 -0
  47. package/dist/logger-BVZwdqqT.js.map +1 -0
  48. package/dist/logger-M7AuVVTV.cjs +171 -0
  49. package/dist/logger-M7AuVVTV.cjs.map +1 -0
  50. package/dist/runnable-environment-BjoOvdDa.js +1345 -0
  51. package/dist/runnable-environment-BjoOvdDa.js.map +1 -0
  52. package/dist/runnable-environment-ByA3DHQ6.cjs +1351 -0
  53. package/dist/runnable-environment-ByA3DHQ6.cjs.map +1 -0
  54. package/dist/server-Bqgl25z0.js +1871 -0
  55. package/dist/server-Bqgl25z0.js.map +1 -0
  56. package/dist/server-BynlMdFc.cjs +1895 -0
  57. package/dist/server-BynlMdFc.cjs.map +1 -0
  58. package/package.json +20 -10
  59. package/dist/client/hmr.cjs.map +0 -1
  60. package/dist/client/hmr.js.map +0 -1
@@ -0,0 +1,1351 @@
1
+ const require_logger = require("./logger-M7AuVVTV.cjs");
2
+ const require_env = require("./env-lOj3yw8v.cjs");
3
+ const require_environment = require("./environment-CjmvoHIG.cjs");
4
+ let node_url = require("node:url");
5
+ let node_path = require("node:path");
6
+ node_path = require_logger.__toESM(node_path, 1);
7
+ let node_fs = require("node:fs");
8
+ node_fs = require_logger.__toESM(node_fs, 1);
9
+ let node_module = require("node:module");
10
+ let node_assert = require("node:assert");
11
+ node_assert = require_logger.__toESM(node_assert, 1);
12
+ let node_process = require("node:process");
13
+ node_process = require_logger.__toESM(node_process, 1);
14
+ let node_v8 = require("node:v8");
15
+ node_v8 = require_logger.__toESM(node_v8, 1);
16
+ let node_util = require("node:util");
17
+ //#region node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/errors.js
18
+ /**
19
+ * @typedef ErrnoExceptionFields
20
+ * @property {number | undefined} [errnode]
21
+ * @property {string | undefined} [code]
22
+ * @property {string | undefined} [path]
23
+ * @property {string | undefined} [syscall]
24
+ * @property {string | undefined} [url]
25
+ *
26
+ * @typedef {Error & ErrnoExceptionFields} ErrnoException
27
+ */
28
+ /**
29
+ * @typedef {(...parameters: Array<any>) => string} MessageFunction
30
+ */
31
+ const own$1 = {}.hasOwnProperty;
32
+ const classRegExp = /^([A-Z][a-z\d]*)+$/;
33
+ const kTypes = /* @__PURE__ */ new Set([
34
+ "string",
35
+ "function",
36
+ "number",
37
+ "object",
38
+ "Function",
39
+ "Object",
40
+ "boolean",
41
+ "bigint",
42
+ "symbol"
43
+ ]);
44
+ const codes = {};
45
+ /**
46
+ * Create a list string in the form like 'A and B' or 'A, B, ..., and Z'.
47
+ * We cannot use Intl.ListFormat because it's not available in
48
+ * --without-intl builds.
49
+ *
50
+ * @param {Array<string>} array
51
+ * An array of strings.
52
+ * @param {string} [type]
53
+ * The list type to be inserted before the last element.
54
+ * @returns {string}
55
+ */
56
+ function formatList(array, type = "and") {
57
+ return array.length < 3 ? array.join(` ${type} `) : `${array.slice(0, -1).join(", ")}, ${type} ${array[array.length - 1]}`;
58
+ }
59
+ /** @type {Map<string, MessageFunction | string>} */
60
+ const messages = /* @__PURE__ */ new Map();
61
+ const nodeInternalPrefix = "__node_internal_";
62
+ /** @type {number} */
63
+ let userStackTraceLimit;
64
+ codes.ERR_INVALID_ARG_TYPE = createError(
65
+ "ERR_INVALID_ARG_TYPE",
66
+ /**
67
+ * @param {string} name
68
+ * @param {Array<string> | string} expected
69
+ * @param {unknown} actual
70
+ */
71
+ (name, expected, actual) => {
72
+ node_assert.default.ok(typeof name === "string", "'name' must be a string");
73
+ if (!Array.isArray(expected)) expected = [expected];
74
+ let message = "The ";
75
+ if (name.endsWith(" argument")) message += `${name} `;
76
+ else {
77
+ const type = name.includes(".") ? "property" : "argument";
78
+ message += `"${name}" ${type} `;
79
+ }
80
+ message += "must be ";
81
+ /** @type {Array<string>} */
82
+ const types = [];
83
+ /** @type {Array<string>} */
84
+ const instances = [];
85
+ /** @type {Array<string>} */
86
+ const other = [];
87
+ for (const value of expected) {
88
+ node_assert.default.ok(typeof value === "string", "All expected entries have to be of type string");
89
+ if (kTypes.has(value)) types.push(value.toLowerCase());
90
+ else if (classRegExp.exec(value) === null) {
91
+ node_assert.default.ok(value !== "object", "The value \"object\" should be written as \"Object\"");
92
+ other.push(value);
93
+ } else instances.push(value);
94
+ }
95
+ if (instances.length > 0) {
96
+ const pos = types.indexOf("object");
97
+ if (pos !== -1) {
98
+ types.slice(pos, 1);
99
+ instances.push("Object");
100
+ }
101
+ }
102
+ if (types.length > 0) {
103
+ message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(types, "or")}`;
104
+ if (instances.length > 0 || other.length > 0) message += " or ";
105
+ }
106
+ if (instances.length > 0) {
107
+ message += `an instance of ${formatList(instances, "or")}`;
108
+ if (other.length > 0) message += " or ";
109
+ }
110
+ if (other.length > 0) {
111
+ if (other.length > 1) message += `one of ${formatList(other, "or")}`;
112
+ else {
113
+ if (other[0].toLowerCase() !== other[0]) message += "an ";
114
+ message += `${other[0]}`;
115
+ }
116
+ }
117
+ message += `. Received ${determineSpecificType(actual)}`;
118
+ return message;
119
+ },
120
+ TypeError
121
+ );
122
+ codes.ERR_INVALID_MODULE_SPECIFIER = createError(
123
+ "ERR_INVALID_MODULE_SPECIFIER",
124
+ /**
125
+ * @param {string} request
126
+ * @param {string} reason
127
+ * @param {string} [base]
128
+ */
129
+ (request, reason, base = void 0) => {
130
+ return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
131
+ },
132
+ TypeError
133
+ );
134
+ codes.ERR_INVALID_PACKAGE_CONFIG = createError(
135
+ "ERR_INVALID_PACKAGE_CONFIG",
136
+ /**
137
+ * @param {string} path
138
+ * @param {string} [base]
139
+ * @param {string} [message]
140
+ */
141
+ (path, base, message) => {
142
+ return `Invalid package config ${path}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
143
+ },
144
+ Error
145
+ );
146
+ codes.ERR_INVALID_PACKAGE_TARGET = createError(
147
+ "ERR_INVALID_PACKAGE_TARGET",
148
+ /**
149
+ * @param {string} packagePath
150
+ * @param {string} key
151
+ * @param {unknown} target
152
+ * @param {boolean} [isImport=false]
153
+ * @param {string} [base]
154
+ */
155
+ (packagePath, key, target, isImport = false, base = void 0) => {
156
+ const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
157
+ if (key === ".") {
158
+ node_assert.default.ok(isImport === false);
159
+ 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 \"./\"" : ""}`;
160
+ }
161
+ return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(target)} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? "; targets must start with \"./\"" : ""}`;
162
+ },
163
+ Error
164
+ );
165
+ codes.ERR_MODULE_NOT_FOUND = createError(
166
+ "ERR_MODULE_NOT_FOUND",
167
+ /**
168
+ * @param {string} path
169
+ * @param {string} base
170
+ * @param {boolean} [exactUrl]
171
+ */
172
+ (path, base, exactUrl = false) => {
173
+ return `Cannot find ${exactUrl ? "module" : "package"} '${path}' imported from ${base}`;
174
+ },
175
+ Error
176
+ );
177
+ codes.ERR_NETWORK_IMPORT_DISALLOWED = createError("ERR_NETWORK_IMPORT_DISALLOWED", "import of '%s' by %s is not supported: %s", Error);
178
+ codes.ERR_PACKAGE_IMPORT_NOT_DEFINED = createError(
179
+ "ERR_PACKAGE_IMPORT_NOT_DEFINED",
180
+ /**
181
+ * @param {string} specifier
182
+ * @param {string} packagePath
183
+ * @param {string} base
184
+ */
185
+ (specifier, packagePath, base) => {
186
+ return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ""} imported from ${base}`;
187
+ },
188
+ TypeError
189
+ );
190
+ codes.ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
191
+ "ERR_PACKAGE_PATH_NOT_EXPORTED",
192
+ /**
193
+ * @param {string} packagePath
194
+ * @param {string} subpath
195
+ * @param {string} [base]
196
+ */
197
+ (packagePath, subpath, base = void 0) => {
198
+ if (subpath === ".") return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
199
+ return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
200
+ },
201
+ Error
202
+ );
203
+ codes.ERR_UNSUPPORTED_DIR_IMPORT = createError("ERR_UNSUPPORTED_DIR_IMPORT", "Directory import '%s' is not supported resolving ES modules imported from %s", Error);
204
+ codes.ERR_UNSUPPORTED_RESOLVE_REQUEST = createError("ERR_UNSUPPORTED_RESOLVE_REQUEST", "Failed to resolve module specifier \"%s\" from \"%s\": Invalid relative URL or base scheme is not hierarchical.", TypeError);
205
+ codes.ERR_UNKNOWN_FILE_EXTENSION = createError(
206
+ "ERR_UNKNOWN_FILE_EXTENSION",
207
+ /**
208
+ * @param {string} extension
209
+ * @param {string} path
210
+ */
211
+ (extension, path) => {
212
+ return `Unknown file extension "${extension}" for ${path}`;
213
+ },
214
+ TypeError
215
+ );
216
+ codes.ERR_INVALID_ARG_VALUE = createError(
217
+ "ERR_INVALID_ARG_VALUE",
218
+ /**
219
+ * @param {string} name
220
+ * @param {unknown} value
221
+ * @param {string} [reason='is invalid']
222
+ */
223
+ (name, value, reason = "is invalid") => {
224
+ let inspected = (0, node_util.inspect)(value);
225
+ if (inspected.length > 128) inspected = `${inspected.slice(0, 128)}...`;
226
+ return `The ${name.includes(".") ? "property" : "argument"} '${name}' ${reason}. Received ${inspected}`;
227
+ },
228
+ TypeError
229
+ );
230
+ /**
231
+ * Utility function for registering the error codes. Only used here. Exported
232
+ * *only* to allow for testing.
233
+ * @param {string} sym
234
+ * @param {MessageFunction | string} value
235
+ * @param {ErrorConstructor} constructor
236
+ * @returns {new (...parameters: Array<any>) => Error}
237
+ */
238
+ function createError(sym, value, constructor) {
239
+ messages.set(sym, value);
240
+ return makeNodeErrorWithCode(constructor, sym);
241
+ }
242
+ /**
243
+ * @param {ErrorConstructor} Base
244
+ * @param {string} key
245
+ * @returns {ErrorConstructor}
246
+ */
247
+ function makeNodeErrorWithCode(Base, key) {
248
+ return NodeError;
249
+ /**
250
+ * @param {Array<unknown>} parameters
251
+ */
252
+ function NodeError(...parameters) {
253
+ const limit = Error.stackTraceLimit;
254
+ if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
255
+ const error = new Base();
256
+ if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
257
+ const message = getMessage(key, parameters, error);
258
+ Object.defineProperties(error, {
259
+ message: {
260
+ value: message,
261
+ enumerable: false,
262
+ writable: true,
263
+ configurable: true
264
+ },
265
+ toString: {
266
+ /** @this {Error} */
267
+ value() {
268
+ return `${this.name} [${key}]: ${this.message}`;
269
+ },
270
+ enumerable: false,
271
+ writable: true,
272
+ configurable: true
273
+ }
274
+ });
275
+ captureLargerStackTrace(error);
276
+ error.code = key;
277
+ return error;
278
+ }
279
+ }
280
+ /**
281
+ * @returns {boolean}
282
+ */
283
+ function isErrorStackTraceLimitWritable() {
284
+ try {
285
+ if (node_v8.default.startupSnapshot.isBuildingSnapshot()) return false;
286
+ } catch {}
287
+ const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
288
+ if (desc === void 0) return Object.isExtensible(Error);
289
+ return own$1.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
290
+ }
291
+ /**
292
+ * This function removes unnecessary frames from Node.js core errors.
293
+ * @template {(...parameters: unknown[]) => unknown} T
294
+ * @param {T} wrappedFunction
295
+ * @returns {T}
296
+ */
297
+ function hideStackFrames(wrappedFunction) {
298
+ const hidden = nodeInternalPrefix + wrappedFunction.name;
299
+ Object.defineProperty(wrappedFunction, "name", { value: hidden });
300
+ return wrappedFunction;
301
+ }
302
+ const captureLargerStackTrace = hideStackFrames(
303
+ /**
304
+ * @param {Error} error
305
+ * @returns {Error}
306
+ */
307
+ function(error) {
308
+ const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
309
+ if (stackTraceLimitIsWritable) {
310
+ userStackTraceLimit = Error.stackTraceLimit;
311
+ Error.stackTraceLimit = Number.POSITIVE_INFINITY;
312
+ }
313
+ Error.captureStackTrace(error);
314
+ if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
315
+ return error;
316
+ }
317
+ );
318
+ /**
319
+ * @param {string} key
320
+ * @param {Array<unknown>} parameters
321
+ * @param {Error} self
322
+ * @returns {string}
323
+ */
324
+ function getMessage(key, parameters, self) {
325
+ const message = messages.get(key);
326
+ node_assert.default.ok(message !== void 0, "expected `message` to be found");
327
+ if (typeof message === "function") {
328
+ node_assert.default.ok(message.length <= parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`);
329
+ return Reflect.apply(message, self, parameters);
330
+ }
331
+ const regex = /%[dfijoOs]/g;
332
+ let expectedLength = 0;
333
+ while (regex.exec(message) !== null) expectedLength++;
334
+ node_assert.default.ok(expectedLength === parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`);
335
+ if (parameters.length === 0) return message;
336
+ parameters.unshift(message);
337
+ return Reflect.apply(node_util.format, null, parameters);
338
+ }
339
+ /**
340
+ * Determine the specific type of a value for type-mismatch errors.
341
+ * @param {unknown} value
342
+ * @returns {string}
343
+ */
344
+ function determineSpecificType(value) {
345
+ if (value === null || value === void 0) return String(value);
346
+ if (typeof value === "function" && value.name) return `function ${value.name}`;
347
+ if (typeof value === "object") {
348
+ if (value.constructor && value.constructor.name) return `an instance of ${value.constructor.name}`;
349
+ return `${(0, node_util.inspect)(value, { depth: -1 })}`;
350
+ }
351
+ let inspected = (0, node_util.inspect)(value, { colors: false });
352
+ if (inspected.length > 28) inspected = `${inspected.slice(0, 25)}...`;
353
+ return `type ${typeof value} (${inspected})`;
354
+ }
355
+ //#endregion
356
+ //#region node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/package-json-reader.js
357
+ /**
358
+ * @import {ErrnoException} from './errors.js'
359
+ *
360
+ * @typedef {'commonjs' | 'module' | 'none'} PackageType
361
+ *
362
+ * @typedef PackageConfig
363
+ * @property {string} pjsonPath
364
+ * @property {boolean} exists
365
+ * @property {string | undefined} [main]
366
+ * @property {string | undefined} [name]
367
+ * @property {PackageType} type
368
+ * @property {Record<string, unknown> | undefined} [exports]
369
+ * @property {Record<string, unknown> | undefined} [imports]
370
+ */
371
+ const hasOwnProperty$1 = {}.hasOwnProperty;
372
+ const { ERR_INVALID_PACKAGE_CONFIG: ERR_INVALID_PACKAGE_CONFIG$1 } = codes;
373
+ /** @type {Map<string, PackageConfig>} */
374
+ const cache = /* @__PURE__ */ new Map();
375
+ /**
376
+ * @param {string} jsonPath
377
+ * @param {{specifier: URL | string, base?: URL}} options
378
+ * @returns {PackageConfig}
379
+ */
380
+ function read(jsonPath, { base, specifier }) {
381
+ const existing = cache.get(jsonPath);
382
+ if (existing) return existing;
383
+ /** @type {string | undefined} */
384
+ let string;
385
+ try {
386
+ string = node_fs.default.readFileSync(node_path.default.toNamespacedPath(jsonPath), "utf8");
387
+ } catch (error) {
388
+ const exception = error;
389
+ if (exception.code !== "ENOENT") throw exception;
390
+ }
391
+ /** @type {PackageConfig} */
392
+ const result = {
393
+ exists: false,
394
+ pjsonPath: jsonPath,
395
+ main: void 0,
396
+ name: void 0,
397
+ type: "none",
398
+ exports: void 0,
399
+ imports: void 0
400
+ };
401
+ if (string !== void 0) {
402
+ /** @type {Record<string, unknown>} */
403
+ let parsed;
404
+ try {
405
+ parsed = JSON.parse(string);
406
+ } catch (error_) {
407
+ const cause = error_;
408
+ const error = new ERR_INVALID_PACKAGE_CONFIG$1(jsonPath, (base ? `"${specifier}" from ` : "") + (0, node_url.fileURLToPath)(base || specifier), cause.message);
409
+ error.cause = cause;
410
+ throw error;
411
+ }
412
+ result.exists = true;
413
+ if (hasOwnProperty$1.call(parsed, "name") && typeof parsed.name === "string") result.name = parsed.name;
414
+ if (hasOwnProperty$1.call(parsed, "main") && typeof parsed.main === "string") result.main = parsed.main;
415
+ if (hasOwnProperty$1.call(parsed, "exports")) result.exports = parsed.exports;
416
+ if (hasOwnProperty$1.call(parsed, "imports")) result.imports = parsed.imports;
417
+ if (hasOwnProperty$1.call(parsed, "type") && (parsed.type === "commonjs" || parsed.type === "module")) result.type = parsed.type;
418
+ }
419
+ cache.set(jsonPath, result);
420
+ return result;
421
+ }
422
+ /**
423
+ * @param {URL | string} resolved
424
+ * @returns {PackageConfig}
425
+ */
426
+ function getPackageScopeConfig(resolved) {
427
+ let packageJSONUrl = new URL("package.json", resolved);
428
+ while (true) {
429
+ if (packageJSONUrl.pathname.endsWith("node_modules/package.json")) break;
430
+ const packageConfig = read((0, node_url.fileURLToPath)(packageJSONUrl), { specifier: resolved });
431
+ if (packageConfig.exists) return packageConfig;
432
+ const lastPackageJSONUrl = packageJSONUrl;
433
+ packageJSONUrl = new URL("../package.json", packageJSONUrl);
434
+ if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) break;
435
+ }
436
+ return {
437
+ pjsonPath: (0, node_url.fileURLToPath)(packageJSONUrl),
438
+ exists: false,
439
+ type: "none"
440
+ };
441
+ }
442
+ /**
443
+ * Returns the package type for a given URL.
444
+ * @param {URL} url - The URL to get the package type for.
445
+ * @returns {PackageType}
446
+ */
447
+ function getPackageType(url) {
448
+ return getPackageScopeConfig(url).type;
449
+ }
450
+ //#endregion
451
+ //#region node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/get-format.js
452
+ const { ERR_UNKNOWN_FILE_EXTENSION } = codes;
453
+ const hasOwnProperty = {}.hasOwnProperty;
454
+ /** @type {Record<string, string>} */
455
+ const extensionFormatMap = {
456
+ __proto__: null,
457
+ ".cjs": "commonjs",
458
+ ".js": "module",
459
+ ".json": "json",
460
+ ".mjs": "module"
461
+ };
462
+ /**
463
+ * @param {string | null} mime
464
+ * @returns {string | null}
465
+ */
466
+ function mimeToFormat(mime) {
467
+ if (mime && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime)) return "module";
468
+ if (mime === "application/json") return "json";
469
+ return null;
470
+ }
471
+ /**
472
+ * @callback ProtocolHandler
473
+ * @param {URL} parsed
474
+ * @param {{parentURL: string, source?: Buffer}} context
475
+ * @param {boolean} ignoreErrors
476
+ * @returns {string | null | void}
477
+ */
478
+ /**
479
+ * @type {Record<string, ProtocolHandler>}
480
+ */
481
+ const protocolHandlers = {
482
+ __proto__: null,
483
+ "data:": getDataProtocolModuleFormat,
484
+ "file:": getFileProtocolModuleFormat,
485
+ "http:": getHttpProtocolModuleFormat,
486
+ "https:": getHttpProtocolModuleFormat,
487
+ "node:"() {
488
+ return "builtin";
489
+ }
490
+ };
491
+ /**
492
+ * @param {URL} parsed
493
+ */
494
+ function getDataProtocolModuleFormat(parsed) {
495
+ const { 1: mime } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(parsed.pathname) || [
496
+ null,
497
+ null,
498
+ null
499
+ ];
500
+ return mimeToFormat(mime);
501
+ }
502
+ /**
503
+ * Returns the file extension from a URL.
504
+ *
505
+ * Should give similar result to
506
+ * `require('node:path').extname(require('node:url').fileURLToPath(url))`
507
+ * when used with a `file:` URL.
508
+ *
509
+ * @param {URL} url
510
+ * @returns {string}
511
+ */
512
+ function extname(url) {
513
+ const pathname = url.pathname;
514
+ let index = pathname.length;
515
+ while (index--) {
516
+ const code = pathname.codePointAt(index);
517
+ if (code === 47) return "";
518
+ if (code === 46) return pathname.codePointAt(index - 1) === 47 ? "" : pathname.slice(index);
519
+ }
520
+ return "";
521
+ }
522
+ /**
523
+ * @type {ProtocolHandler}
524
+ */
525
+ function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
526
+ const value = extname(url);
527
+ if (value === ".js") {
528
+ const packageType = getPackageType(url);
529
+ if (packageType !== "none") return packageType;
530
+ return "commonjs";
531
+ }
532
+ if (value === "") {
533
+ const packageType = getPackageType(url);
534
+ if (packageType === "none" || packageType === "commonjs") return "commonjs";
535
+ return "module";
536
+ }
537
+ const format = extensionFormatMap[value];
538
+ if (format) return format;
539
+ if (ignoreErrors) return;
540
+ const filepath = (0, node_url.fileURLToPath)(url);
541
+ throw new ERR_UNKNOWN_FILE_EXTENSION(value, filepath);
542
+ }
543
+ function getHttpProtocolModuleFormat() {}
544
+ /**
545
+ * @param {URL} url
546
+ * @param {{parentURL: string}} context
547
+ * @returns {string | null}
548
+ */
549
+ function defaultGetFormatWithoutErrors(url, context) {
550
+ const protocol = url.protocol;
551
+ if (!hasOwnProperty.call(protocolHandlers, protocol)) return null;
552
+ return protocolHandlers[protocol](url, context, true) || null;
553
+ }
554
+ //#endregion
555
+ //#region node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/utils.js
556
+ const { ERR_INVALID_ARG_VALUE } = codes;
557
+ const DEFAULT_CONDITIONS = Object.freeze(["node", "import"]);
558
+ const DEFAULT_CONDITIONS_SET = new Set(DEFAULT_CONDITIONS);
559
+ /**
560
+ * Returns the default conditions for ES module loading.
561
+ */
562
+ function getDefaultConditions() {
563
+ return DEFAULT_CONDITIONS;
564
+ }
565
+ /**
566
+ * Returns the default conditions for ES module loading, as a Set.
567
+ */
568
+ function getDefaultConditionsSet() {
569
+ return DEFAULT_CONDITIONS_SET;
570
+ }
571
+ /**
572
+ * @param {Array<string>} [conditions]
573
+ * @returns {Set<string>}
574
+ */
575
+ function getConditionsSet(conditions) {
576
+ if (conditions !== void 0 && conditions !== getDefaultConditions()) {
577
+ if (!Array.isArray(conditions)) throw new ERR_INVALID_ARG_VALUE("conditions", conditions, "expected an array");
578
+ return new Set(conditions);
579
+ }
580
+ return getDefaultConditionsSet();
581
+ }
582
+ //#endregion
583
+ //#region node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/resolve.js
584
+ /**
585
+ * @import {Stats} from 'node:fs'
586
+ * @import {ErrnoException} from './errors.js'
587
+ * @import {PackageConfig} from './package-json-reader.js'
588
+ */
589
+ const RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
590
+ const { ERR_NETWORK_IMPORT_DISALLOWED, ERR_INVALID_MODULE_SPECIFIER, ERR_INVALID_PACKAGE_CONFIG, 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 } = codes;
591
+ const own = {}.hasOwnProperty;
592
+ const 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;
593
+ const 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;
594
+ const invalidPackageNameRegEx = /^\.|%|\\/;
595
+ const patternRegEx = /\*/g;
596
+ const encodedSeparatorRegEx = /%2f|%5c/i;
597
+ /** @type {Set<string>} */
598
+ const emittedPackageWarnings = /* @__PURE__ */ new Set();
599
+ const doubleSlashRegEx = /[/\\]{2}/;
600
+ /**
601
+ *
602
+ * @param {string} target
603
+ * @param {string} request
604
+ * @param {string} match
605
+ * @param {URL} packageJsonUrl
606
+ * @param {boolean} internal
607
+ * @param {URL} base
608
+ * @param {boolean} isTarget
609
+ */
610
+ function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, internal, base, isTarget) {
611
+ if (node_process.default.noDeprecation) return;
612
+ const pjsonPath = (0, node_url.fileURLToPath)(packageJsonUrl);
613
+ const double = doubleSlashRegEx.exec(isTarget ? target : request) !== null;
614
+ node_process.default.emitWarning(`Use of deprecated ${double ? "double slash" : "leading or trailing slash matching"} resolving "${target}" for module request "${request}" ${request === match ? "" : `matched to "${match}" `}in the "${internal ? "imports" : "exports"}" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${(0, node_url.fileURLToPath)(base)}` : ""}.`, "DeprecationWarning", "DEP0166");
615
+ }
616
+ /**
617
+ * @param {URL} url
618
+ * @param {URL} packageJsonUrl
619
+ * @param {URL} base
620
+ * @param {string} [main]
621
+ * @returns {void}
622
+ */
623
+ function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
624
+ if (node_process.default.noDeprecation) return;
625
+ if (defaultGetFormatWithoutErrors(url, { parentURL: base.href }) !== "module") return;
626
+ const urlPath = (0, node_url.fileURLToPath)(url.href);
627
+ const packagePath = (0, node_url.fileURLToPath)(new URL(".", packageJsonUrl));
628
+ const basePath = (0, node_url.fileURLToPath)(base);
629
+ if (!main) node_process.default.emitWarning(`No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\nDefault "index" lookups for the main are deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
630
+ else if (node_path.default.resolve(packagePath, main) !== urlPath) node_process.default.emitWarning(`Package ${packagePath} has a "main" field set to "${main}", excluding the full filename and extension to the resolved file at "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\n Automatic extension resolution of the "main" field is deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
631
+ }
632
+ /**
633
+ * @param {string} path
634
+ * @returns {Stats | undefined}
635
+ */
636
+ function tryStatSync(path) {
637
+ try {
638
+ return (0, node_fs.statSync)(path);
639
+ } catch {}
640
+ }
641
+ /**
642
+ * Legacy CommonJS main resolution:
643
+ * 1. let M = pkg_url + (json main field)
644
+ * 2. TRY(M, M.js, M.json, M.node)
645
+ * 3. TRY(M/index.js, M/index.json, M/index.node)
646
+ * 4. TRY(pkg_url/index.js, pkg_url/index.json, pkg_url/index.node)
647
+ * 5. NOT_FOUND
648
+ *
649
+ * @param {URL} url
650
+ * @returns {boolean}
651
+ */
652
+ function fileExists(url) {
653
+ const stats = (0, node_fs.statSync)(url, { throwIfNoEntry: false });
654
+ const isFile = stats ? stats.isFile() : void 0;
655
+ return isFile === null || isFile === void 0 ? false : isFile;
656
+ }
657
+ /**
658
+ * @param {URL} packageJsonUrl
659
+ * @param {PackageConfig} packageConfig
660
+ * @param {URL} base
661
+ * @returns {URL}
662
+ */
663
+ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
664
+ /** @type {URL | undefined} */
665
+ let guess;
666
+ if (packageConfig.main !== void 0) {
667
+ guess = new URL(packageConfig.main, packageJsonUrl);
668
+ if (fileExists(guess)) return guess;
669
+ const tries = [
670
+ `./${packageConfig.main}.js`,
671
+ `./${packageConfig.main}.json`,
672
+ `./${packageConfig.main}.node`,
673
+ `./${packageConfig.main}/index.js`,
674
+ `./${packageConfig.main}/index.json`,
675
+ `./${packageConfig.main}/index.node`
676
+ ];
677
+ let i = -1;
678
+ while (++i < tries.length) {
679
+ guess = new URL(tries[i], packageJsonUrl);
680
+ if (fileExists(guess)) break;
681
+ guess = void 0;
682
+ }
683
+ if (guess) {
684
+ emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
685
+ return guess;
686
+ }
687
+ }
688
+ const tries = [
689
+ "./index.js",
690
+ "./index.json",
691
+ "./index.node"
692
+ ];
693
+ let i = -1;
694
+ while (++i < tries.length) {
695
+ guess = new URL(tries[i], packageJsonUrl);
696
+ if (fileExists(guess)) break;
697
+ guess = void 0;
698
+ }
699
+ if (guess) {
700
+ emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
701
+ return guess;
702
+ }
703
+ throw new ERR_MODULE_NOT_FOUND((0, node_url.fileURLToPath)(new URL(".", packageJsonUrl)), (0, node_url.fileURLToPath)(base));
704
+ }
705
+ /**
706
+ * @param {URL} resolved
707
+ * @param {URL} base
708
+ * @param {boolean} [preserveSymlinks]
709
+ * @returns {URL}
710
+ */
711
+ function finalizeResolution(resolved, base, preserveSymlinks) {
712
+ if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) throw new ERR_INVALID_MODULE_SPECIFIER(resolved.pathname, "must not include encoded \"/\" or \"\\\" characters", (0, node_url.fileURLToPath)(base));
713
+ /** @type {string} */
714
+ let filePath;
715
+ try {
716
+ filePath = (0, node_url.fileURLToPath)(resolved);
717
+ } catch (error) {
718
+ const cause = error;
719
+ Object.defineProperty(cause, "input", { value: String(resolved) });
720
+ Object.defineProperty(cause, "module", { value: String(base) });
721
+ throw cause;
722
+ }
723
+ const stats = tryStatSync(filePath.endsWith("/") ? filePath.slice(-1) : filePath);
724
+ if (stats && stats.isDirectory()) {
725
+ const error = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, (0, node_url.fileURLToPath)(base));
726
+ error.url = String(resolved);
727
+ throw error;
728
+ }
729
+ if (!stats || !stats.isFile()) {
730
+ const error = new ERR_MODULE_NOT_FOUND(filePath || resolved.pathname, base && (0, node_url.fileURLToPath)(base), true);
731
+ error.url = String(resolved);
732
+ throw error;
733
+ }
734
+ if (!preserveSymlinks) {
735
+ const real = (0, node_fs.realpathSync)(filePath);
736
+ const { search, hash } = resolved;
737
+ resolved = (0, node_url.pathToFileURL)(real + (filePath.endsWith(node_path.default.sep) ? "/" : ""));
738
+ resolved.search = search;
739
+ resolved.hash = hash;
740
+ }
741
+ return resolved;
742
+ }
743
+ /**
744
+ * @param {string} specifier
745
+ * @param {URL | undefined} packageJsonUrl
746
+ * @param {URL} base
747
+ * @returns {Error}
748
+ */
749
+ function importNotDefined(specifier, packageJsonUrl, base) {
750
+ return new ERR_PACKAGE_IMPORT_NOT_DEFINED(specifier, packageJsonUrl && (0, node_url.fileURLToPath)(new URL(".", packageJsonUrl)), (0, node_url.fileURLToPath)(base));
751
+ }
752
+ /**
753
+ * @param {string} subpath
754
+ * @param {URL} packageJsonUrl
755
+ * @param {URL} base
756
+ * @returns {Error}
757
+ */
758
+ function exportsNotFound(subpath, packageJsonUrl, base) {
759
+ return new ERR_PACKAGE_PATH_NOT_EXPORTED((0, node_url.fileURLToPath)(new URL(".", packageJsonUrl)), subpath, base && (0, node_url.fileURLToPath)(base));
760
+ }
761
+ /**
762
+ * @param {string} request
763
+ * @param {string} match
764
+ * @param {URL} packageJsonUrl
765
+ * @param {boolean} internal
766
+ * @param {URL} [base]
767
+ * @returns {never}
768
+ */
769
+ function throwInvalidSubpath(request, match, packageJsonUrl, internal, base) {
770
+ const reason = `request is not a valid match in pattern "${match}" for the "${internal ? "imports" : "exports"}" resolution of ${(0, node_url.fileURLToPath)(packageJsonUrl)}`;
771
+ throw new ERR_INVALID_MODULE_SPECIFIER(request, reason, base && (0, node_url.fileURLToPath)(base));
772
+ }
773
+ /**
774
+ * @param {string} subpath
775
+ * @param {unknown} target
776
+ * @param {URL} packageJsonUrl
777
+ * @param {boolean} internal
778
+ * @param {URL} [base]
779
+ * @returns {Error}
780
+ */
781
+ function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
782
+ target = typeof target === "object" && target !== null ? JSON.stringify(target, null, "") : `${target}`;
783
+ return new ERR_INVALID_PACKAGE_TARGET((0, node_url.fileURLToPath)(new URL(".", packageJsonUrl)), subpath, target, internal, base && (0, node_url.fileURLToPath)(base));
784
+ }
785
+ /**
786
+ * @param {string} target
787
+ * @param {string} subpath
788
+ * @param {string} match
789
+ * @param {URL} packageJsonUrl
790
+ * @param {URL} base
791
+ * @param {boolean} pattern
792
+ * @param {boolean} internal
793
+ * @param {boolean} isPathMap
794
+ * @param {Set<string> | undefined} conditions
795
+ * @returns {URL}
796
+ */
797
+ function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base, pattern, internal, isPathMap, conditions) {
798
+ if (subpath !== "" && !pattern && target[target.length - 1] !== "/") throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
799
+ if (!target.startsWith("./")) {
800
+ if (internal && !target.startsWith("../") && !target.startsWith("/")) {
801
+ let isURL = false;
802
+ try {
803
+ new URL(target);
804
+ isURL = true;
805
+ } catch {}
806
+ if (!isURL) return packageResolve(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target + subpath, packageJsonUrl, conditions);
807
+ }
808
+ throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
809
+ }
810
+ if (invalidSegmentRegEx.exec(target.slice(2)) !== null) {
811
+ if (deprecatedInvalidSegmentRegEx.exec(target.slice(2)) === null) {
812
+ if (!isPathMap) {
813
+ const request = pattern ? match.replace("*", () => subpath) : match + subpath;
814
+ emitInvalidSegmentDeprecation(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target, request, match, packageJsonUrl, internal, base, true);
815
+ }
816
+ } else throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
817
+ }
818
+ const resolved = new URL(target, packageJsonUrl);
819
+ const resolvedPath = resolved.pathname;
820
+ const packagePath = new URL(".", packageJsonUrl).pathname;
821
+ if (!resolvedPath.startsWith(packagePath)) throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
822
+ if (subpath === "") return resolved;
823
+ if (invalidSegmentRegEx.exec(subpath) !== null) {
824
+ const request = pattern ? match.replace("*", () => subpath) : match + subpath;
825
+ if (deprecatedInvalidSegmentRegEx.exec(subpath) === null) {
826
+ if (!isPathMap) emitInvalidSegmentDeprecation(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target, request, match, packageJsonUrl, internal, base, false);
827
+ } else throwInvalidSubpath(request, match, packageJsonUrl, internal, base);
828
+ }
829
+ if (pattern) return new URL(RegExpPrototypeSymbolReplace.call(patternRegEx, resolved.href, () => subpath));
830
+ return new URL(subpath, resolved);
831
+ }
832
+ /**
833
+ * @param {string} key
834
+ * @returns {boolean}
835
+ */
836
+ function isArrayIndex(key) {
837
+ const keyNumber = Number(key);
838
+ if (`${keyNumber}` !== key) return false;
839
+ return keyNumber >= 0 && keyNumber < 4294967295;
840
+ }
841
+ /**
842
+ * @param {URL} packageJsonUrl
843
+ * @param {unknown} target
844
+ * @param {string} subpath
845
+ * @param {string} packageSubpath
846
+ * @param {URL} base
847
+ * @param {boolean} pattern
848
+ * @param {boolean} internal
849
+ * @param {boolean} isPathMap
850
+ * @param {Set<string> | undefined} conditions
851
+ * @returns {URL | null}
852
+ */
853
+ function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions) {
854
+ if (typeof target === "string") return resolvePackageTargetString(target, subpath, packageSubpath, packageJsonUrl, base, pattern, internal, isPathMap, conditions);
855
+ if (Array.isArray(target)) {
856
+ /** @type {Array<unknown>} */
857
+ const targetList = target;
858
+ if (targetList.length === 0) return null;
859
+ /** @type {ErrnoException | null | undefined} */
860
+ let lastException;
861
+ let i = -1;
862
+ while (++i < targetList.length) {
863
+ const targetItem = targetList[i];
864
+ /** @type {URL | null} */
865
+ let resolveResult;
866
+ try {
867
+ resolveResult = resolvePackageTarget(packageJsonUrl, targetItem, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
868
+ } catch (error) {
869
+ const exception = error;
870
+ lastException = exception;
871
+ if (exception.code === "ERR_INVALID_PACKAGE_TARGET") continue;
872
+ throw error;
873
+ }
874
+ if (resolveResult === void 0) continue;
875
+ if (resolveResult === null) {
876
+ lastException = null;
877
+ continue;
878
+ }
879
+ return resolveResult;
880
+ }
881
+ if (lastException === void 0 || lastException === null) return null;
882
+ throw lastException;
883
+ }
884
+ if (typeof target === "object" && target !== null) {
885
+ const keys = Object.getOwnPropertyNames(target);
886
+ let i = -1;
887
+ while (++i < keys.length) {
888
+ const key = keys[i];
889
+ if (isArrayIndex(key)) throw new ERR_INVALID_PACKAGE_CONFIG((0, node_url.fileURLToPath)(packageJsonUrl), base, "\"exports\" cannot contain numeric property keys.");
890
+ }
891
+ i = -1;
892
+ while (++i < keys.length) {
893
+ const key = keys[i];
894
+ if (key === "default" || conditions && conditions.has(key)) {
895
+ const conditionalTarget = target[key];
896
+ const resolveResult = resolvePackageTarget(packageJsonUrl, conditionalTarget, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
897
+ if (resolveResult === void 0) continue;
898
+ return resolveResult;
899
+ }
900
+ }
901
+ return null;
902
+ }
903
+ if (target === null) return null;
904
+ throw invalidPackageTarget(packageSubpath, target, packageJsonUrl, internal, base);
905
+ }
906
+ /**
907
+ * @param {unknown} exports
908
+ * @param {URL} packageJsonUrl
909
+ * @param {URL} base
910
+ * @returns {boolean}
911
+ */
912
+ function isConditionalExportsMainSugar(exports, packageJsonUrl, base) {
913
+ if (typeof exports === "string" || Array.isArray(exports)) return true;
914
+ if (typeof exports !== "object" || exports === null) return false;
915
+ const keys = Object.getOwnPropertyNames(exports);
916
+ let isConditionalSugar = false;
917
+ let i = 0;
918
+ let keyIndex = -1;
919
+ while (++keyIndex < keys.length) {
920
+ const key = keys[keyIndex];
921
+ const currentIsConditionalSugar = key === "" || key[0] !== ".";
922
+ if (i++ === 0) isConditionalSugar = currentIsConditionalSugar;
923
+ else if (isConditionalSugar !== currentIsConditionalSugar) throw new ERR_INVALID_PACKAGE_CONFIG((0, node_url.fileURLToPath)(packageJsonUrl), base, "\"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.");
924
+ }
925
+ return isConditionalSugar;
926
+ }
927
+ /**
928
+ * @param {string} match
929
+ * @param {URL} pjsonUrl
930
+ * @param {URL} base
931
+ */
932
+ function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
933
+ if (node_process.default.noDeprecation) return;
934
+ const pjsonPath = (0, node_url.fileURLToPath)(pjsonUrl);
935
+ if (emittedPackageWarnings.has(pjsonPath + "|" + match)) return;
936
+ emittedPackageWarnings.add(pjsonPath + "|" + match);
937
+ node_process.default.emitWarning(`Use of deprecated trailing slash pattern mapping "${match}" in the "exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${(0, node_url.fileURLToPath)(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`, "DeprecationWarning", "DEP0155");
938
+ }
939
+ /**
940
+ * @param {URL} packageJsonUrl
941
+ * @param {string} packageSubpath
942
+ * @param {Record<string, unknown>} packageConfig
943
+ * @param {URL} base
944
+ * @param {Set<string> | undefined} conditions
945
+ * @returns {URL}
946
+ */
947
+ function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions) {
948
+ let exports = packageConfig.exports;
949
+ if (isConditionalExportsMainSugar(exports, packageJsonUrl, base)) exports = { ".": exports };
950
+ if (own.call(exports, packageSubpath) && !packageSubpath.includes("*") && !packageSubpath.endsWith("/")) {
951
+ const target = exports[packageSubpath];
952
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, "", packageSubpath, base, false, false, false, conditions);
953
+ if (resolveResult === null || resolveResult === void 0) throw exportsNotFound(packageSubpath, packageJsonUrl, base);
954
+ return resolveResult;
955
+ }
956
+ let bestMatch = "";
957
+ let bestMatchSubpath = "";
958
+ const keys = Object.getOwnPropertyNames(exports);
959
+ let i = -1;
960
+ while (++i < keys.length) {
961
+ const key = keys[i];
962
+ const patternIndex = key.indexOf("*");
963
+ if (patternIndex !== -1 && packageSubpath.startsWith(key.slice(0, patternIndex))) {
964
+ if (packageSubpath.endsWith("/")) emitTrailingSlashPatternDeprecation(packageSubpath, packageJsonUrl, base);
965
+ const patternTrailer = key.slice(patternIndex + 1);
966
+ if (packageSubpath.length >= key.length && packageSubpath.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
967
+ bestMatch = key;
968
+ bestMatchSubpath = packageSubpath.slice(patternIndex, packageSubpath.length - patternTrailer.length);
969
+ }
970
+ }
971
+ }
972
+ if (bestMatch) {
973
+ const target = exports[bestMatch];
974
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, false, packageSubpath.endsWith("/"), conditions);
975
+ if (resolveResult === null || resolveResult === void 0) throw exportsNotFound(packageSubpath, packageJsonUrl, base);
976
+ return resolveResult;
977
+ }
978
+ throw exportsNotFound(packageSubpath, packageJsonUrl, base);
979
+ }
980
+ /**
981
+ * @param {string} a
982
+ * @param {string} b
983
+ */
984
+ function patternKeyCompare(a, b) {
985
+ const aPatternIndex = a.indexOf("*");
986
+ const bPatternIndex = b.indexOf("*");
987
+ const baseLengthA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
988
+ const baseLengthB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
989
+ if (baseLengthA > baseLengthB) return -1;
990
+ if (baseLengthB > baseLengthA) return 1;
991
+ if (aPatternIndex === -1) return 1;
992
+ if (bPatternIndex === -1) return -1;
993
+ if (a.length > b.length) return -1;
994
+ if (b.length > a.length) return 1;
995
+ return 0;
996
+ }
997
+ /**
998
+ * @param {string} name
999
+ * @param {URL} base
1000
+ * @param {Set<string>} [conditions]
1001
+ * @returns {URL}
1002
+ */
1003
+ function packageImportsResolve(name, base, conditions) {
1004
+ if (name === "#" || name.startsWith("#/") || name.endsWith("/")) throw new ERR_INVALID_MODULE_SPECIFIER(name, "is not a valid internal imports specifier name", (0, node_url.fileURLToPath)(base));
1005
+ /** @type {URL | undefined} */
1006
+ let packageJsonUrl;
1007
+ const packageConfig = getPackageScopeConfig(base);
1008
+ if (packageConfig.exists) {
1009
+ packageJsonUrl = (0, node_url.pathToFileURL)(packageConfig.pjsonPath);
1010
+ const imports = packageConfig.imports;
1011
+ if (imports) {
1012
+ if (own.call(imports, name) && !name.includes("*")) {
1013
+ const resolveResult = resolvePackageTarget(packageJsonUrl, imports[name], "", name, base, false, true, false, conditions);
1014
+ if (resolveResult !== null && resolveResult !== void 0) return resolveResult;
1015
+ } else {
1016
+ let bestMatch = "";
1017
+ let bestMatchSubpath = "";
1018
+ const keys = Object.getOwnPropertyNames(imports);
1019
+ let i = -1;
1020
+ while (++i < keys.length) {
1021
+ const key = keys[i];
1022
+ const patternIndex = key.indexOf("*");
1023
+ if (patternIndex !== -1 && name.startsWith(key.slice(0, -1))) {
1024
+ const patternTrailer = key.slice(patternIndex + 1);
1025
+ if (name.length >= key.length && name.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
1026
+ bestMatch = key;
1027
+ bestMatchSubpath = name.slice(patternIndex, name.length - patternTrailer.length);
1028
+ }
1029
+ }
1030
+ }
1031
+ if (bestMatch) {
1032
+ const target = imports[bestMatch];
1033
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, true, false, conditions);
1034
+ if (resolveResult !== null && resolveResult !== void 0) return resolveResult;
1035
+ }
1036
+ }
1037
+ }
1038
+ }
1039
+ throw importNotDefined(name, packageJsonUrl, base);
1040
+ }
1041
+ /**
1042
+ * @param {string} specifier
1043
+ * @param {URL} base
1044
+ */
1045
+ function parsePackageName(specifier, base) {
1046
+ let separatorIndex = specifier.indexOf("/");
1047
+ let validPackageName = true;
1048
+ let isScoped = false;
1049
+ if (specifier[0] === "@") {
1050
+ isScoped = true;
1051
+ if (separatorIndex === -1 || specifier.length === 0) validPackageName = false;
1052
+ else separatorIndex = specifier.indexOf("/", separatorIndex + 1);
1053
+ }
1054
+ const packageName = separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
1055
+ if (invalidPackageNameRegEx.exec(packageName) !== null) validPackageName = false;
1056
+ if (!validPackageName) throw new ERR_INVALID_MODULE_SPECIFIER(specifier, "is not a valid package name", (0, node_url.fileURLToPath)(base));
1057
+ return {
1058
+ packageName,
1059
+ packageSubpath: "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex)),
1060
+ isScoped
1061
+ };
1062
+ }
1063
+ /**
1064
+ * @param {string} specifier
1065
+ * @param {URL} base
1066
+ * @param {Set<string> | undefined} conditions
1067
+ * @returns {URL}
1068
+ */
1069
+ function packageResolve(specifier, base, conditions) {
1070
+ if (node_module.builtinModules.includes(specifier)) return new URL("node:" + specifier);
1071
+ const { packageName, packageSubpath, isScoped } = parsePackageName(specifier, base);
1072
+ const packageConfig = getPackageScopeConfig(base);
1073
+ /* c8 ignore next 16 */
1074
+ if (packageConfig.exists) {
1075
+ const packageJsonUrl = (0, node_url.pathToFileURL)(packageConfig.pjsonPath);
1076
+ if (packageConfig.name === packageName && packageConfig.exports !== void 0 && packageConfig.exports !== null) return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions);
1077
+ }
1078
+ let packageJsonUrl = new URL("./node_modules/" + packageName + "/package.json", base);
1079
+ let packageJsonPath = (0, node_url.fileURLToPath)(packageJsonUrl);
1080
+ /** @type {string} */
1081
+ let lastPath;
1082
+ do {
1083
+ const stat = tryStatSync(packageJsonPath.slice(0, -13));
1084
+ if (!stat || !stat.isDirectory()) {
1085
+ lastPath = packageJsonPath;
1086
+ packageJsonUrl = new URL((isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json", packageJsonUrl);
1087
+ packageJsonPath = (0, node_url.fileURLToPath)(packageJsonUrl);
1088
+ continue;
1089
+ }
1090
+ const packageConfig = read(packageJsonPath, {
1091
+ base,
1092
+ specifier
1093
+ });
1094
+ if (packageConfig.exports !== void 0 && packageConfig.exports !== null) return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions);
1095
+ if (packageSubpath === ".") return legacyMainResolve(packageJsonUrl, packageConfig, base);
1096
+ return new URL(packageSubpath, packageJsonUrl);
1097
+ } while (packageJsonPath.length !== lastPath.length);
1098
+ throw new ERR_MODULE_NOT_FOUND(packageName, (0, node_url.fileURLToPath)(base), false);
1099
+ }
1100
+ /**
1101
+ * @param {string} specifier
1102
+ * @returns {boolean}
1103
+ */
1104
+ function isRelativeSpecifier(specifier) {
1105
+ if (specifier[0] === ".") {
1106
+ if (specifier.length === 1 || specifier[1] === "/") return true;
1107
+ if (specifier[1] === "." && (specifier.length === 2 || specifier[2] === "/")) return true;
1108
+ }
1109
+ return false;
1110
+ }
1111
+ /**
1112
+ * @param {string} specifier
1113
+ * @returns {boolean}
1114
+ */
1115
+ function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) {
1116
+ if (specifier === "") return false;
1117
+ if (specifier[0] === "/") return true;
1118
+ return isRelativeSpecifier(specifier);
1119
+ }
1120
+ /**
1121
+ * The “Resolver Algorithm Specification” as detailed in the Node docs (which is
1122
+ * sync and slightly lower-level than `resolve`).
1123
+ *
1124
+ * @param {string} specifier
1125
+ * `/example.js`, `./example.js`, `../example.js`, `some-package`, `fs`, etc.
1126
+ * @param {URL} base
1127
+ * Full URL (to a file) that `specifier` is resolved relative from.
1128
+ * @param {Set<string>} [conditions]
1129
+ * Conditions.
1130
+ * @param {boolean} [preserveSymlinks]
1131
+ * Keep symlinks instead of resolving them.
1132
+ * @returns {URL}
1133
+ * A URL object to the found thing.
1134
+ */
1135
+ function moduleResolve(specifier, base, conditions, preserveSymlinks) {
1136
+ if (conditions === void 0) conditions = getConditionsSet();
1137
+ const protocol = base.protocol;
1138
+ const isRemote = protocol === "data:" || protocol === "http:" || protocol === "https:";
1139
+ /** @type {URL | undefined} */
1140
+ let resolved;
1141
+ if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) try {
1142
+ resolved = new URL(specifier, base);
1143
+ } catch (error_) {
1144
+ const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
1145
+ error.cause = error_;
1146
+ throw error;
1147
+ }
1148
+ else if (protocol === "file:" && specifier[0] === "#") resolved = packageImportsResolve(specifier, base, conditions);
1149
+ else try {
1150
+ resolved = new URL(specifier);
1151
+ } catch (error_) {
1152
+ if (isRemote && !node_module.builtinModules.includes(specifier)) {
1153
+ const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
1154
+ error.cause = error_;
1155
+ throw error;
1156
+ }
1157
+ resolved = packageResolve(specifier, base, conditions);
1158
+ }
1159
+ node_assert.default.ok(resolved !== void 0, "expected to be defined");
1160
+ if (resolved.protocol !== "file:") return resolved;
1161
+ return finalizeResolution(resolved, base, preserveSymlinks);
1162
+ }
1163
+ //#endregion
1164
+ //#region src/server/runnable-environment.ts
1165
+ const debug = require_environment.createDebugger("nasti:ssr");
1166
+ const NODE_BUILTINS = /* @__PURE__ */ new Set([...node_module.builtinModules, ...node_module.builtinModules.map((m) => `node:${m}`)]);
1167
+ var NastiModuleRunner = class {
1168
+ environment;
1169
+ config;
1170
+ cache = /* @__PURE__ */ new Map();
1171
+ envDefine;
1172
+ externalImportParent;
1173
+ externalImportConditions;
1174
+ constructor(environment) {
1175
+ this.environment = environment;
1176
+ this.config = environment.config;
1177
+ this.envDefine = require_env.buildEnvDefine(require_env.loadEnv(this.config.mode, this.config.root, this.config.envPrefix), this.config.mode, require_env.ssrDefineOverrides(environment.consumer));
1178
+ this.externalImportParent = (0, node_url.pathToFileURL)(node_path.default.join(this.config.root, "package.json"));
1179
+ this.externalImportConditions = /* @__PURE__ */ new Set([
1180
+ ...environment.options.resolve.conditions.filter((condition) => condition !== "require"),
1181
+ "node",
1182
+ "import"
1183
+ ]);
1184
+ environment.hot.setInvokeHandler?.({
1185
+ fetchModule: async (id, importer) => this.fetchModule(id, importer),
1186
+ getBuiltins: () => [/^node:/, ...node_module.builtinModules]
1187
+ });
1188
+ }
1189
+ /** 入口:加载并执行一个模块(url 为根相对或绝对路径) */
1190
+ async import(rawUrl) {
1191
+ const id = this.resolveToId(rawUrl);
1192
+ return this.instantiate(id);
1193
+ }
1194
+ /** 文件变更时按文件失效(含其所属的虚拟子模块) */
1195
+ invalidateFile(file) {
1196
+ for (const key of [...this.cache.keys()]) if (key === file || key.startsWith(file + "?")) this.cache.delete(key);
1197
+ }
1198
+ invalidateAll() {
1199
+ this.cache.clear();
1200
+ }
1201
+ resolveToId(rawUrl) {
1202
+ if (node_path.default.isAbsolute(rawUrl) && node_fs.default.existsSync(rawUrl.split("?")[0])) return rawUrl;
1203
+ const clean = rawUrl.replace(/^\//, "");
1204
+ return node_path.default.resolve(this.config.root, clean);
1205
+ }
1206
+ /**
1207
+ * fetchModule(invoke 契约方法):环境管线产出 runner 可执行代码。
1208
+ * resolve(插件 resolveId → 文件系统)→ load/读盘 → 插件 transform →
1209
+ * oxc(TS/JSX)→ moduleRunnerTransform。
1210
+ */
1211
+ async fetchModule(id, importer) {
1212
+ if (NODE_BUILTINS.has(id)) return { externalize: id };
1213
+ if (!id.startsWith(".") && !node_path.default.isAbsolute(id) && !id.startsWith("\0")) return { externalize: id };
1214
+ const container = this.environment.pluginContainer;
1215
+ let resolvedId = id;
1216
+ if (id.startsWith(".") && importer) {
1217
+ const resolved = await container.resolveId(id, importer);
1218
+ resolvedId = resolved ? typeof resolved === "string" ? resolved : resolved.id : node_path.default.resolve(node_path.default.dirname(importer.split("?")[0]), id);
1219
+ }
1220
+ resolvedId = this.completeExtension(resolvedId);
1221
+ const cleanId = resolvedId.split("?")[0];
1222
+ let code;
1223
+ const loaded = await container.load(resolvedId);
1224
+ if (loaded != null) code = typeof loaded === "string" ? loaded : loaded.code;
1225
+ else if (node_fs.default.existsSync(cleanId)) code = node_fs.default.readFileSync(cleanId, "utf-8");
1226
+ else throw new Error(`[nasti:ssr] cannot load module: ${resolvedId}`);
1227
+ const transformed = await container.transform(code, resolvedId);
1228
+ if (transformed != null) code = typeof transformed === "string" ? transformed : transformed.code;
1229
+ if (this.config.framework === "react") {
1230
+ const result = await require_env.transformReactCode(cleanId, code, {
1231
+ react: this.config.react,
1232
+ consumer: this.environment.consumer,
1233
+ development: true,
1234
+ sourcemap: false,
1235
+ target: this.environment.options.build.target,
1236
+ onWarning: (message) => this.config.logger.warn(`[nasti:react] ${message}`)
1237
+ });
1238
+ if (result) code = result.code;
1239
+ else if (require_env.shouldTransform(cleanId)) code = require_env.transformCode(cleanId, code, {
1240
+ sourcemap: false,
1241
+ jsxRuntime: this.config.react.jsxRuntime,
1242
+ jsxImportSource: this.config.react.jsxImportSource,
1243
+ target: this.environment.options.build.target
1244
+ }).code;
1245
+ } else if (require_env.shouldTransform(cleanId)) code = require_env.transformCode(cleanId, code, {
1246
+ sourcemap: false,
1247
+ target: this.environment.options.build.target,
1248
+ jsxRuntime: "automatic",
1249
+ jsxImportSource: "vue"
1250
+ }).code;
1251
+ code = require_env.replaceEnvInCode(code, this.envDefine);
1252
+ let moduleRunnerTransform;
1253
+ try {
1254
+ ({moduleRunnerTransform} = await import("rolldown/experimental"));
1255
+ } catch (err) {
1256
+ throw new Error(`[nasti:ssr] rolldown/experimental moduleRunnerTransform unavailable (installed rolldown incompatible?): ${err.message}`);
1257
+ }
1258
+ const runnerResult = await moduleRunnerTransform(resolvedId, code);
1259
+ debug?.(`fetchModule ${resolvedId} (${runnerResult.deps?.length ?? 0} deps)`);
1260
+ return {
1261
+ id: resolvedId,
1262
+ code: runnerResult.code
1263
+ };
1264
+ }
1265
+ completeExtension(id) {
1266
+ const clean = id.split("?")[0];
1267
+ const query = id.includes("?") ? id.slice(id.indexOf("?")) : "";
1268
+ if (node_fs.default.existsSync(clean) && node_fs.default.statSync(clean).isFile()) return id;
1269
+ const jsMatch = clean.match(/^(.*)\.([mc]?)jsx?$/);
1270
+ if (jsMatch) {
1271
+ for (const tsExt of [`.${jsMatch[2]}ts`, `.${jsMatch[2]}tsx`]) if (node_fs.default.existsSync(jsMatch[1] + tsExt)) return jsMatch[1] + tsExt + query;
1272
+ }
1273
+ for (const ext of this.config.resolve.extensions) if (node_fs.default.existsSync(clean + ext)) return clean + ext + query;
1274
+ for (const ext of this.config.resolve.extensions) {
1275
+ const indexPath = node_path.default.join(clean, `index${ext}`);
1276
+ if (node_fs.default.existsSync(indexPath)) return indexPath;
1277
+ }
1278
+ return id;
1279
+ }
1280
+ async instantiate(id) {
1281
+ const cached = this.cache.get(id);
1282
+ if (cached) return cached.promise ?? Promise.resolve(cached.exports);
1283
+ const entry = {
1284
+ exports: {},
1285
+ promise: null
1286
+ };
1287
+ this.cache.set(id, entry);
1288
+ entry.promise = this.evaluate(id, entry).then(() => {
1289
+ entry.promise = null;
1290
+ return entry.exports;
1291
+ }).catch((err) => {
1292
+ this.cache.delete(id);
1293
+ throw err;
1294
+ });
1295
+ return entry.promise;
1296
+ }
1297
+ async evaluate(id, entry) {
1298
+ const fetched = await this.fetchModule(id);
1299
+ if ("externalize" in fetched) {
1300
+ const spec = fetched.externalize;
1301
+ entry.exports = await this.importExternal(spec);
1302
+ return;
1303
+ }
1304
+ const ssrImport = async (dep) => {
1305
+ if (NODE_BUILTINS.has(dep) || !dep.startsWith(".") && !node_path.default.isAbsolute(dep) && !dep.startsWith("\0")) return this.importExternal(dep);
1306
+ const depId = dep.startsWith(".") ? this.completeExtension(node_path.default.resolve(node_path.default.dirname(fetched.id.split("?")[0]), dep)) : this.completeExtension(dep);
1307
+ return this.instantiate(depId);
1308
+ };
1309
+ const ssrExportAll = (sourceModule) => {
1310
+ for (const key of Object.keys(sourceModule)) if (key !== "default" && !(key in entry.exports)) Object.defineProperty(entry.exports, key, {
1311
+ enumerable: true,
1312
+ configurable: true,
1313
+ get: () => sourceModule[key]
1314
+ });
1315
+ };
1316
+ const importMeta = {
1317
+ url: (0, node_url.pathToFileURL)(fetched.id.split("?")[0]).href,
1318
+ env: {
1319
+ SSR: true,
1320
+ MODE: this.config.mode,
1321
+ DEV: this.config.mode !== "production",
1322
+ PROD: this.config.mode === "production"
1323
+ },
1324
+ hot: void 0
1325
+ };
1326
+ await new AsyncFunction("__vite_ssr_exports__", "__vite_ssr_import__", "__vite_ssr_dynamic_import__", "__vite_ssr_exportAll__", "__vite_ssr_import_meta__", `"use strict";${fetched.code}\n//# sourceURL=${fetched.id}`)(entry.exports, ssrImport, ssrImport, ssrExportAll, importMeta);
1327
+ }
1328
+ async importExternal(spec) {
1329
+ try {
1330
+ return await (spec.startsWith("node:") || !node_path.default.isAbsolute(spec) ? import(this.resolveExternalSpecifier(spec)) : import((0, node_url.pathToFileURL)(spec).href));
1331
+ } catch (err) {
1332
+ throw new Error(`[nasti:ssr] failed to import external "${spec}": ${err.message}`);
1333
+ }
1334
+ }
1335
+ /** bare specifier → 项目 node_modules 的 ESM URL(避免相对 Nasti 自身解析) */
1336
+ resolveExternalSpecifier(spec) {
1337
+ if (spec.startsWith("node:")) return spec;
1338
+ if (NODE_BUILTINS.has(spec)) return `node:${spec}`;
1339
+ return moduleResolve(spec, this.externalImportParent, this.externalImportConditions, false).href;
1340
+ }
1341
+ };
1342
+ const AsyncFunction = Object.getPrototypeOf(async function() {}).constructor;
1343
+ /** 为 server consumer 环境创建 module runner(Vite RunnableEnvironment 的精简版) */
1344
+ function createModuleRunner(environment) {
1345
+ if (environment.consumer !== "server") throw new Error(`[nasti] module runner requires a server-consumer environment (got "${environment.name}" / ${environment.consumer})`);
1346
+ return new NastiModuleRunner(environment);
1347
+ }
1348
+ //#endregion
1349
+ exports.createModuleRunner = createModuleRunner;
1350
+
1351
+ //# sourceMappingURL=runnable-environment-ByA3DHQ6.cjs.map