storybook 10.0.7 → 10.0.8

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 (80) hide show
  1. package/dist/_browser-chunks/{chunk-RW5PKMWM.js → chunk-HERDX7MO.js} +2 -2
  2. package/dist/_browser-chunks/{chunk-UTNZYD2N.js → chunk-KHNISLMN.js} +81 -37
  3. package/dist/_browser-chunks/{chunk-B4A3ADP3.js → chunk-U2JWIJRX.js} +1 -1
  4. package/dist/_browser-chunks/{chunk-SYS437NN.js → chunk-VQJJDUCI.js} +1 -1
  5. package/dist/_node-chunks/{builder-manager-IMGYSQ6C.js → builder-manager-32BKVJNY.js} +12 -12
  6. package/dist/_node-chunks/camelcase-A6XPJDW2.js +18 -0
  7. package/dist/_node-chunks/{chunk-WEXHDPHI.js → chunk-2JVDNALC.js} +7 -7
  8. package/dist/_node-chunks/{chunk-PVBMWXLV.js → chunk-2YHAMJAY.js} +7 -7
  9. package/dist/_node-chunks/{chunk-ODTNT22I.js → chunk-425EMBPZ.js} +297 -768
  10. package/dist/_node-chunks/{chunk-SQJQNNLJ.js → chunk-4UOXOBHK.js} +22 -16
  11. package/dist/_node-chunks/{chunk-X52AL5YW.js → chunk-4WKJYHSS.js} +7 -7
  12. package/dist/_node-chunks/{chunk-MD57HJIM.js → chunk-5VYG646K.js} +7 -7
  13. package/dist/_node-chunks/chunk-A3KNZ5FW.js +18 -0
  14. package/dist/_node-chunks/{chunk-24QJCCAD.js → chunk-C4ROO6RE.js} +7 -7
  15. package/dist/_node-chunks/{chunk-UMPQ4E76.js → chunk-CWWI6A7W.js} +8 -8
  16. package/dist/_node-chunks/{chunk-V3HQ6KQZ.js → chunk-DPKZQ6YX.js} +7 -7
  17. package/dist/_node-chunks/{chunk-QJE3V7EA.js → chunk-EGWLH7SG.js} +10 -10
  18. package/dist/_node-chunks/{chunk-76Y6LEGH.js → chunk-F6NUZ463.js} +9 -9
  19. package/dist/_node-chunks/{chunk-QWKN7XKO.js → chunk-FYLSDVSH.js} +21 -21
  20. package/dist/_node-chunks/{chunk-WB52FWVJ.js → chunk-HUKSE3QZ.js} +7 -7
  21. package/dist/_node-chunks/{chunk-LL7YW7JI.js → chunk-IR6AN3RK.js} +8 -8
  22. package/dist/_node-chunks/{chunk-WRVTNG75.js → chunk-J5R55OCP.js} +7 -7
  23. package/dist/_node-chunks/{chunk-H6EU5XDR.js → chunk-JBW3FROT.js} +6 -6
  24. package/dist/_node-chunks/{chunk-QHZ7UVRT.js → chunk-JFMDUYER.js} +7 -7
  25. package/dist/_node-chunks/{chunk-ZTMF3ZLU.js → chunk-JVUHT63V.js} +8 -8
  26. package/dist/_node-chunks/{chunk-2JHMFGYJ.js → chunk-K373EZTP.js} +12 -12
  27. package/dist/_node-chunks/{chunk-5I4UHD7U.js → chunk-KVR64UU2.js} +529 -284
  28. package/dist/_node-chunks/chunk-NEOS45YA.js +61 -0
  29. package/dist/_node-chunks/{chunk-RDC6YPRK.js → chunk-OVJEF4RI.js} +9 -9
  30. package/dist/_node-chunks/{chunk-I3VS3SZG.js → chunk-PK3UILX6.js} +7 -7
  31. package/dist/_node-chunks/{chunk-63N4MMRO.js → chunk-QHYQ5G5G.js} +7 -7
  32. package/dist/_node-chunks/{chunk-R5RWAUHB.js → chunk-TKXE3RQ5.js} +12 -12
  33. package/dist/_node-chunks/{chunk-CEKA7D2C.js → chunk-UOLIYXDF.js} +7 -7
  34. package/dist/_node-chunks/{chunk-RCEDZ5SF.js → chunk-V4MKEKP7.js} +7 -7
  35. package/dist/_node-chunks/{chunk-ZA2S75S7.js → chunk-V7ZKSK5R.js} +7 -7
  36. package/dist/_node-chunks/{chunk-LX7DNOAF.js → chunk-VTD5TIUC.js} +8 -8
  37. package/dist/_node-chunks/{chunk-3QRUKHNZ.js → chunk-VWYF3SCI.js} +7 -7
  38. package/dist/_node-chunks/{chunk-RQQ26RE6.js → chunk-YUFML7ZZ.js} +7 -7
  39. package/dist/_node-chunks/{chunk-5Y7ADYYI.js → chunk-ZDZQHU26.js} +6 -6
  40. package/dist/_node-chunks/{dist-64XMYCKL.js → dist-SD7YZH5A.js} +9 -9
  41. package/dist/_node-chunks/{globby-VVSMFUOS.js → globby-FODEQLAP.js} +9 -9
  42. package/dist/_node-chunks/{lib-3737YTFI.js → lib-G6JECM5H.js} +7 -7
  43. package/dist/_node-chunks/{mdx-N42X6CFJ-MMTNLXDP.js → mdx-N42X6CFJ-MK2KTUH7.js} +8 -8
  44. package/dist/_node-chunks/{p-limit-JUZ6J4TE.js → p-limit-IJ5D4B4L.js} +10 -7
  45. package/dist/_node-chunks/{plugin-53K4FV2S.js → plugin-NXD266M2.js} +10 -10
  46. package/dist/_node-chunks/{plugin-J57WYAS6.js → plugin-SAVMZDUL.js} +10 -10
  47. package/dist/_node-chunks/{webpack-inject-mocker-runtime-plugin-TSBFN4GA.js → webpack-inject-mocker-runtime-plugin-2PG2OIHX.js} +30 -24
  48. package/dist/_node-chunks/{webpack-mock-plugin-FFF3YTJU.js → webpack-mock-plugin-CQH72GQV.js} +9 -9
  49. package/dist/babel/index.d.ts +671 -335
  50. package/dist/babel/index.js +11 -11
  51. package/dist/bin/core.js +12 -12
  52. package/dist/bin/dispatcher.js +11 -11
  53. package/dist/bin/loader.js +9 -9
  54. package/dist/cli/index.js +77 -82
  55. package/dist/common/index.js +20 -20
  56. package/dist/components/index.js +394 -176
  57. package/dist/core-server/index.js +55 -44
  58. package/dist/core-server/presets/common-manager.js +238 -230
  59. package/dist/core-server/presets/common-override-preset.js +9 -9
  60. package/dist/core-server/presets/common-preset.js +24 -23
  61. package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +9 -9
  62. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +10 -10
  63. package/dist/csf/index.js +3 -3
  64. package/dist/csf-tools/index.js +9 -9
  65. package/dist/docs-tools/index.js +2 -2
  66. package/dist/manager/globals-runtime.js +4291 -4116
  67. package/dist/manager/runtime.js +1 -1
  68. package/dist/manager-api/index.js +3 -3
  69. package/dist/node-logger/index.js +576 -531
  70. package/dist/preview/runtime.js +953 -891
  71. package/dist/preview-api/index.d.ts +68 -67
  72. package/dist/preview-api/index.js +3 -3
  73. package/dist/server-errors.js +10 -10
  74. package/dist/telemetry/index.js +24 -24
  75. package/dist/test/index.js +609 -547
  76. package/dist/theming/index.d.ts +3363 -2597
  77. package/package.json +2 -2
  78. package/dist/_node-chunks/camelcase-IT57EA7A.js +0 -18
  79. package/dist/_node-chunks/chunk-W3ZTHPZN.js +0 -18
  80. package/dist/_node-chunks/chunk-X5UKDYKW.js +0 -61
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_gikfs3u543o from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_gikfs3u543o from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_gikfs3u543o from "node:module";
1
+ import CJS_COMPAT_NODE_URL_39zvq8kkt8 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_39zvq8kkt8 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_39zvq8kkt8 from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_gikfs3u543o.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_gikfs3u543o.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_gikfs3u543o.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_39zvq8kkt8.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_39zvq8kkt8.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_39zvq8kkt8.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -12,14 +12,14 @@ var require = CJS_COMPAT_NODE_MODULE_gikfs3u543o.createRequire(import.meta.url);
12
12
  import {
13
13
  dirname,
14
14
  join
15
- } from "./chunk-WRVTNG75.js";
15
+ } from "./chunk-J5R55OCP.js";
16
16
  import {
17
17
  __name
18
- } from "./chunk-H6EU5XDR.js";
18
+ } from "./chunk-JBW3FROT.js";
19
19
 
20
20
  // ../node_modules/exsolve/dist/index.mjs
21
- import fs, { realpathSync, statSync, lstatSync } from "node:fs";
22
- import { fileURLToPath, URL as URL$1, pathToFileURL } from "node:url";
21
+ import fs, { lstatSync, realpathSync, statSync } from "node:fs";
22
+ import { URL as URL$1, fileURLToPath, pathToFileURL } from "node:url";
23
23
  import path, { isAbsolute } from "node:path";
24
24
  import assert from "node:assert";
25
25
  import process$1 from "node:process";
@@ -102,7 +102,6 @@ var kTypes = /* @__PURE__ */ new Set([
102
102
  "function",
103
103
  "number",
104
104
  "object",
105
- // Accept 'Function' and 'Object' as alternative to the lower cased version.
106
105
  "Function",
107
106
  "Object",
108
107
  "boolean",
@@ -129,8 +128,6 @@ function makeNodeErrorWithCode(Base, key) {
129
128
  if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
130
129
  const message = getMessage(key, parameters, error);
131
130
  Object.defineProperties(error, {
132
- // Note: no need to implement `kIsNodeError` symbol, would be hard,
133
- // probably.
134
131
  message: {
135
132
  value: message,
136
133
  enumerable: false,
@@ -138,7 +135,6 @@ function makeNodeErrorWithCode(Base, key) {
138
135
  configurable: true
139
136
  },
140
137
  toString: {
141
- /** @this {Error} */
142
138
  value() {
143
139
  return `${this.name} [${key}]: ${this.message}`;
144
140
  },
@@ -155,15 +151,11 @@ function makeNodeErrorWithCode(Base, key) {
155
151
  __name(makeNodeErrorWithCode, "makeNodeErrorWithCode");
156
152
  function isErrorStackTraceLimitWritable() {
157
153
  try {
158
- if (v8.startupSnapshot.isBuildingSnapshot()) {
159
- return false;
160
- }
154
+ if (v8.startupSnapshot.isBuildingSnapshot()) return false;
161
155
  } catch {
162
156
  }
163
157
  const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
164
- if (desc === void 0) {
165
- return Object.isExtensible(Error);
166
- }
158
+ if (desc === void 0) return Object.isExtensible(Error);
167
159
  return own$1.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
168
160
  }
169
161
  __name(isErrorStackTraceLimitWritable, "isErrorStackTraceLimitWritable");
@@ -185,225 +177,140 @@ var captureLargerStackTrace = hideStackFrames(function(error) {
185
177
  });
186
178
  function getMessage(key, parameters, self) {
187
179
  const message = messages.get(key);
188
- assert(message !== void 0, "expected `message` to be found");
180
+ assert.ok(message !== void 0, "expected `message` to be found");
189
181
  if (typeof message === "function") {
190
- assert(
191
- message.length <= parameters.length,
192
- // Default options do not count.
193
- `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`
194
- );
182
+ assert.ok(message.length <= parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`);
195
183
  return Reflect.apply(message, self, parameters);
196
184
  }
197
185
  const regex = /%[dfijoOs]/g;
198
186
  let expectedLength = 0;
199
187
  while (regex.exec(message) !== null) expectedLength++;
200
- assert(
201
- expectedLength === parameters.length,
202
- `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`
203
- );
188
+ assert.ok(expectedLength === parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`);
204
189
  if (parameters.length === 0) return message;
205
190
  parameters.unshift(message);
206
191
  return Reflect.apply(format, null, parameters);
207
192
  }
208
193
  __name(getMessage, "getMessage");
209
194
  function determineSpecificType(value) {
210
- if (value === null || value === void 0) {
211
- return String(value);
212
- }
213
- if (typeof value === "function" && value.name) {
214
- return `function ${value.name}`;
215
- }
195
+ if (value === null || value === void 0) return String(value);
196
+ if (typeof value === "function" && value.name) return `function ${value.name}`;
216
197
  if (typeof value === "object") {
217
- if (value.constructor && value.constructor.name) {
218
- return `an instance of ${value.constructor.name}`;
219
- }
198
+ if (value.constructor && value.constructor.name) return `an instance of ${value.constructor.name}`;
220
199
  return `${inspect(value, { depth: -1 })}`;
221
200
  }
222
201
  let inspected = inspect(value, { colors: false });
223
- if (inspected.length > 28) {
224
- inspected = `${inspected.slice(0, 25)}...`;
225
- }
202
+ if (inspected.length > 28) inspected = `${inspected.slice(0, 25)}...`;
226
203
  return `type ${typeof value} (${inspected})`;
227
204
  }
228
205
  __name(determineSpecificType, "determineSpecificType");
229
- createError(
230
- "ERR_INVALID_ARG_TYPE",
231
- (name, expected, actual) => {
232
- assert(typeof name === "string", "'name' must be a string");
233
- if (!Array.isArray(expected)) {
234
- expected = [expected];
235
- }
236
- let message = "The ";
237
- if (name.endsWith(" argument")) {
238
- message += `${name} `;
239
- } else {
240
- const type = name.includes(".") ? "property" : "argument";
241
- message += `"${name}" ${type} `;
242
- }
243
- message += "must be ";
244
- const types = [];
245
- const instances = [];
246
- const other = [];
247
- for (const value of expected) {
248
- assert(
249
- typeof value === "string",
250
- "All expected entries have to be of type string"
251
- );
252
- if (kTypes.has(value)) {
253
- types.push(value.toLowerCase());
254
- } else if (classRegExp.exec(value) === null) {
255
- assert(
256
- value !== "object",
257
- 'The value "object" should be written as "Object"'
258
- );
259
- other.push(value);
260
- } else {
261
- instances.push(value);
262
- }
263
- }
264
- if (instances.length > 0) {
265
- const pos = types.indexOf("object");
266
- if (pos !== -1) {
267
- types.slice(pos, 1);
268
- instances.push("Object");
269
- }
270
- }
271
- if (types.length > 0) {
272
- message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(
273
- types,
274
- "or"
275
- )}`;
276
- if (instances.length > 0 || other.length > 0) message += " or ";
277
- }
278
- if (instances.length > 0) {
279
- message += `an instance of ${formatList(instances, "or")}`;
280
- if (other.length > 0) message += " or ";
281
- }
282
- if (other.length > 0) {
283
- if (other.length > 1) {
284
- message += `one of ${formatList(other, "or")}`;
285
- } else {
286
- if (other[0]?.toLowerCase() !== other[0]) message += "an ";
287
- message += `${other[0]}`;
288
- }
206
+ var ERR_INVALID_ARG_TYPE = createError("ERR_INVALID_ARG_TYPE", (name, expected, actual) => {
207
+ assert.ok(typeof name === "string", "'name' must be a string");
208
+ if (!Array.isArray(expected)) expected = [expected];
209
+ let message = "The ";
210
+ if (name.endsWith(" argument")) message += `${name} `;
211
+ else {
212
+ const type = name.includes(".") ? "property" : "argument";
213
+ message += `"${name}" ${type} `;
214
+ }
215
+ message += "must be ";
216
+ const types = [];
217
+ const instances = [];
218
+ const other = [];
219
+ for (const value of expected) {
220
+ assert.ok(typeof value === "string", "All expected entries have to be of type string");
221
+ if (kTypes.has(value)) types.push(value.toLowerCase());
222
+ else if (classRegExp.exec(value) === null) {
223
+ assert.ok(value !== "object", 'The value "object" should be written as "Object"');
224
+ other.push(value);
225
+ } else instances.push(value);
226
+ }
227
+ if (instances.length > 0) {
228
+ const pos = types.indexOf("object");
229
+ if (pos !== -1) {
230
+ types.slice(pos, 1);
231
+ instances.push("Object");
289
232
  }
290
- message += `. Received ${determineSpecificType(actual)}`;
291
- return message;
292
- },
293
- TypeError
294
- );
233
+ }
234
+ if (types.length > 0) {
235
+ message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(types, "or")}`;
236
+ if (instances.length > 0 || other.length > 0) message += " or ";
237
+ }
238
+ if (instances.length > 0) {
239
+ message += `an instance of ${formatList(instances, "or")}`;
240
+ if (other.length > 0) message += " or ";
241
+ }
242
+ if (other.length > 0) if (other.length > 1) message += `one of ${formatList(other, "or")}`;
243
+ else {
244
+ if (other[0]?.toLowerCase() !== other[0]) message += "an ";
245
+ message += `${other[0]}`;
246
+ }
247
+ message += `. Received ${determineSpecificType(actual)}`;
248
+ return message;
249
+ }, TypeError);
295
250
  var ERR_INVALID_MODULE_SPECIFIER = createError(
296
251
  "ERR_INVALID_MODULE_SPECIFIER",
297
252
  /**
298
- * @param {string} request
299
- * @param {string} reason
300
- * @param {string} [base]
301
- */
253
+ * @param {string} request
254
+ * @param {string} reason
255
+ * @param {string} [base]
256
+ */
302
257
  (request, reason, base) => {
303
258
  return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
304
259
  },
305
260
  TypeError
306
261
  );
307
- var ERR_INVALID_PACKAGE_CONFIG = createError(
308
- "ERR_INVALID_PACKAGE_CONFIG",
309
- (path2, base, message) => {
310
- return `Invalid package config ${path2}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
311
- },
312
- Error
313
- );
314
- var ERR_INVALID_PACKAGE_TARGET = createError(
315
- "ERR_INVALID_PACKAGE_TARGET",
316
- (packagePath, key, target, isImport = false, base) => {
317
- const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
318
- if (key === ".") {
319
- assert(isImport === false);
320
- 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 "./"' : ""}`;
321
- }
322
- return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(
323
- target
324
- )} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
325
- },
326
- Error
327
- );
328
- var ERR_MODULE_NOT_FOUND = createError(
329
- "ERR_MODULE_NOT_FOUND",
330
- (path2, base, exactUrl = false) => {
331
- return `Cannot find ${exactUrl ? "module" : "package"} '${path2}' imported from ${base}`;
332
- },
333
- Error
334
- );
335
- createError(
336
- "ERR_NETWORK_IMPORT_DISALLOWED",
337
- "import of '%s' by %s is not supported: %s",
338
- Error
339
- );
340
- var ERR_PACKAGE_IMPORT_NOT_DEFINED = createError(
341
- "ERR_PACKAGE_IMPORT_NOT_DEFINED",
342
- (specifier, packagePath, base) => {
343
- return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath || ""}package.json` : ""} imported from ${base}`;
344
- },
345
- TypeError
346
- );
262
+ var ERR_INVALID_PACKAGE_CONFIG = createError("ERR_INVALID_PACKAGE_CONFIG", (path$1, base, message) => {
263
+ return `Invalid package config ${path$1}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
264
+ }, Error);
265
+ var ERR_INVALID_PACKAGE_TARGET = createError("ERR_INVALID_PACKAGE_TARGET", (packagePath, key, target, isImport = false, base) => {
266
+ const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
267
+ if (key === ".") {
268
+ assert.ok(isImport === false);
269
+ 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 "./"' : ""}`;
270
+ }
271
+ 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 "./"' : ""}`;
272
+ }, Error);
273
+ var ERR_MODULE_NOT_FOUND = createError("ERR_MODULE_NOT_FOUND", (path$1, base, exactUrl = false) => {
274
+ return `Cannot find ${exactUrl ? "module" : "package"} '${path$1}' imported from ${base}`;
275
+ }, Error);
276
+ var ERR_NETWORK_IMPORT_DISALLOWED = createError("ERR_NETWORK_IMPORT_DISALLOWED", "import of '%s' by %s is not supported: %s", Error);
277
+ var ERR_PACKAGE_IMPORT_NOT_DEFINED = createError("ERR_PACKAGE_IMPORT_NOT_DEFINED", (specifier, packagePath, base) => {
278
+ return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath || ""}package.json` : ""} imported from ${base}`;
279
+ }, TypeError);
347
280
  var ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
348
281
  "ERR_PACKAGE_PATH_NOT_EXPORTED",
349
282
  /**
350
- * @param {string} packagePath
351
- * @param {string} subpath
352
- * @param {string} [base]
353
- */
283
+ * @param {string} packagePath
284
+ * @param {string} subpath
285
+ * @param {string} [base]
286
+ */
354
287
  (packagePath, subpath, base) => {
355
- if (subpath === ".")
356
- return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
288
+ if (subpath === ".") return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
357
289
  return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
358
290
  },
359
291
  Error
360
292
  );
361
- var ERR_UNSUPPORTED_DIR_IMPORT = createError(
362
- "ERR_UNSUPPORTED_DIR_IMPORT",
363
- "Directory import '%s' is not supported resolving ES modules imported from %s",
364
- Error
365
- );
366
- var ERR_UNSUPPORTED_RESOLVE_REQUEST = createError(
367
- "ERR_UNSUPPORTED_RESOLVE_REQUEST",
368
- 'Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.',
369
- TypeError
370
- );
371
- var ERR_UNKNOWN_FILE_EXTENSION = createError(
372
- "ERR_UNKNOWN_FILE_EXTENSION",
373
- (extension, path2) => {
374
- return `Unknown file extension "${extension}" for ${path2}`;
375
- },
376
- TypeError
377
- );
378
- createError(
379
- "ERR_INVALID_ARG_VALUE",
380
- (name, value, reason = "is invalid") => {
381
- let inspected = inspect(value);
382
- if (inspected.length > 128) {
383
- inspected = `${inspected.slice(0, 128)}...`;
384
- }
385
- const type = name.includes(".") ? "property" : "argument";
386
- return `The ${type} '${name}' ${reason}. Received ${inspected}`;
387
- },
388
- TypeError
389
- // Note: extra classes have been shaken out.
390
- // , RangeError
391
- );
293
+ var ERR_UNSUPPORTED_DIR_IMPORT = createError("ERR_UNSUPPORTED_DIR_IMPORT", "Directory import '%s' is not supported resolving ES modules imported from %s", Error);
294
+ var 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);
295
+ var ERR_UNKNOWN_FILE_EXTENSION = createError("ERR_UNKNOWN_FILE_EXTENSION", (extension, path$1) => {
296
+ return `Unknown file extension "${extension}" for ${path$1}`;
297
+ }, TypeError);
298
+ var ERR_INVALID_ARG_VALUE = createError("ERR_INVALID_ARG_VALUE", (name, value, reason = "is invalid") => {
299
+ let inspected = inspect(value);
300
+ if (inspected.length > 128) inspected = `${inspected.slice(0, 128)}...`;
301
+ return `The ${name.includes(".") ? "property" : "argument"} '${name}' ${reason}. Received ${inspected}`;
302
+ }, TypeError);
392
303
  var hasOwnProperty$1 = {}.hasOwnProperty;
393
304
  var cache = /* @__PURE__ */ new Map();
394
305
  function read(jsonPath, { base, specifier }) {
395
306
  const existing = cache.get(jsonPath);
396
- if (existing) {
397
- return existing;
398
- }
307
+ if (existing) return existing;
399
308
  let string;
400
309
  try {
401
310
  string = fs.readFileSync(path.toNamespacedPath(jsonPath), "utf8");
402
311
  } catch (error) {
403
312
  const exception = error;
404
- if (exception.code !== "ENOENT") {
405
- throw exception;
406
- }
313
+ if (exception.code !== "ENOENT") throw exception;
407
314
  }
408
315
  const result = {
409
316
  exists: false,
@@ -411,7 +318,6 @@ function read(jsonPath, { base, specifier }) {
411
318
  main: void 0,
412
319
  name: void 0,
413
320
  type: "none",
414
- // Ignore unknown types for forwards compatibility
415
321
  exports: void 0,
416
322
  imports: void 0
417
323
  };
@@ -420,30 +326,16 @@ function read(jsonPath, { base, specifier }) {
420
326
  try {
421
327
  parsed = JSON.parse(string);
422
328
  } catch (error_) {
423
- const error = new ERR_INVALID_PACKAGE_CONFIG(
424
- jsonPath,
425
- (base ? `"${specifier}" from ` : "") + fileURLToPath(base || specifier),
426
- error_.message
427
- );
329
+ const error = new ERR_INVALID_PACKAGE_CONFIG(jsonPath, (base ? `"${specifier}" from ` : "") + fileURLToPath(base || specifier), error_.message);
428
330
  error.cause = error_;
429
331
  throw error;
430
332
  }
431
333
  result.exists = true;
432
- if (hasOwnProperty$1.call(parsed, "name") && typeof parsed.name === "string") {
433
- result.name = parsed.name;
434
- }
435
- if (hasOwnProperty$1.call(parsed, "main") && typeof parsed.main === "string") {
436
- result.main = parsed.main;
437
- }
438
- if (hasOwnProperty$1.call(parsed, "exports")) {
439
- result.exports = parsed.exports;
440
- }
441
- if (hasOwnProperty$1.call(parsed, "imports")) {
442
- result.imports = parsed.imports;
443
- }
444
- if (hasOwnProperty$1.call(parsed, "type") && (parsed.type === "commonjs" || parsed.type === "module")) {
445
- result.type = parsed.type;
446
- }
334
+ if (hasOwnProperty$1.call(parsed, "name") && typeof parsed.name === "string") result.name = parsed.name;
335
+ if (hasOwnProperty$1.call(parsed, "main") && typeof parsed.main === "string") result.main = parsed.main;
336
+ if (hasOwnProperty$1.call(parsed, "exports")) result.exports = parsed.exports;
337
+ if (hasOwnProperty$1.call(parsed, "imports")) result.imports = parsed.imports;
338
+ if (hasOwnProperty$1.call(parsed, "type") && (parsed.type === "commonjs" || parsed.type === "module")) result.type = parsed.type;
447
339
  }
448
340
  cache.set(jsonPath, result);
449
341
  return result;
@@ -452,25 +344,15 @@ __name(read, "read");
452
344
  function getPackageScopeConfig(resolved) {
453
345
  let packageJSONUrl = new URL("package.json", resolved);
454
346
  while (true) {
455
- const packageJSONPath2 = packageJSONUrl.pathname;
456
- if (packageJSONPath2.endsWith("node_modules/package.json")) {
457
- break;
458
- }
459
- const packageConfig = read(fileURLToPath(packageJSONUrl), {
460
- specifier: resolved
461
- });
462
- if (packageConfig.exists) {
463
- return packageConfig;
464
- }
347
+ if (packageJSONUrl.pathname.endsWith("node_modules/package.json")) break;
348
+ const packageConfig = read(fileURLToPath(packageJSONUrl), { specifier: resolved });
349
+ if (packageConfig.exists) return packageConfig;
465
350
  const lastPackageJSONUrl = packageJSONUrl;
466
351
  packageJSONUrl = new URL("../package.json", packageJSONUrl);
467
- if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) {
468
- break;
469
- }
352
+ if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) break;
470
353
  }
471
- const packageJSONPath = fileURLToPath(packageJSONUrl);
472
354
  return {
473
- pjsonPath: packageJSONPath,
355
+ pjsonPath: fileURLToPath(packageJSONUrl),
474
356
  exists: false,
475
357
  type: "none"
476
358
  };
@@ -494,16 +376,17 @@ var protocolHandlers = {
494
376
  "node:": /* @__PURE__ */ __name(() => "builtin", "node:")
495
377
  };
496
378
  function mimeToFormat(mime) {
497
- if (mime && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime))
498
- return "module";
379
+ if (mime && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime)) return "module";
499
380
  if (mime === "application/json") return "json";
500
381
  return null;
501
382
  }
502
383
  __name(mimeToFormat, "mimeToFormat");
503
384
  function getDataProtocolModuleFormat(parsed) {
504
- const { 1: mime } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(
505
- parsed.pathname
506
- ) || [null, null, null];
385
+ const { 1: mime } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(parsed.pathname) || [
386
+ null,
387
+ null,
388
+ null
389
+ ];
507
390
  return mimeToFormat(mime);
508
391
  }
509
392
  __name(getDataProtocolModuleFormat, "getDataProtocolModuleFormat");
@@ -512,12 +395,8 @@ function extname(url) {
512
395
  let index = pathname.length;
513
396
  while (index--) {
514
397
  const code = pathname.codePointAt(index);
515
- if (code === 47) {
516
- return "";
517
- }
518
- if (code === 46) {
519
- return pathname.codePointAt(index - 1) === 47 ? "" : pathname.slice(index);
520
- }
398
+ if (code === 47) return "";
399
+ if (code === 46) return pathname.codePointAt(index - 1) === 47 ? "" : pathname.slice(index);
521
400
  }
522
401
  return "";
523
402
  }
@@ -526,32 +405,23 @@ function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
526
405
  const ext = extname(url);
527
406
  if (ext === ".js") {
528
407
  const { type: packageType } = getPackageScopeConfig(url);
529
- if (packageType !== "none") {
530
- return packageType;
531
- }
408
+ if (packageType !== "none") return packageType;
532
409
  return "commonjs";
533
410
  }
534
411
  if (ext === "") {
535
412
  const { type: packageType } = getPackageScopeConfig(url);
536
- if (packageType === "none" || packageType === "commonjs") {
537
- return "commonjs";
538
- }
413
+ if (packageType === "none" || packageType === "commonjs") return "commonjs";
539
414
  return "module";
540
415
  }
541
- const format2 = extensionFormatMap[ext];
542
- if (format2) return format2;
543
- if (ignoreErrors) {
544
- return void 0;
545
- }
546
- const filepath = fileURLToPath(url);
547
- throw new ERR_UNKNOWN_FILE_EXTENSION(ext, filepath);
416
+ const format$1 = extensionFormatMap[ext];
417
+ if (format$1) return format$1;
418
+ if (ignoreErrors) return;
419
+ throw new ERR_UNKNOWN_FILE_EXTENSION(ext, fileURLToPath(url));
548
420
  }
549
421
  __name(getFileProtocolModuleFormat, "getFileProtocolModuleFormat");
550
422
  function defaultGetFormatWithoutErrors(url, context) {
551
423
  const protocol = url.protocol;
552
- if (!hasOwnProperty.call(protocolHandlers, protocol)) {
553
- return null;
554
- }
424
+ if (!hasOwnProperty.call(protocolHandlers, protocol)) return null;
555
425
  return protocolHandlers[protocol](url, context, true) || null;
556
426
  }
557
427
  __name(defaultGetFormatWithoutErrors, "defaultGetFormatWithoutErrors");
@@ -565,51 +435,27 @@ var encodedSeparatorRegEx = /%2f|%5c/i;
565
435
  var emittedPackageWarnings = /* @__PURE__ */ new Set();
566
436
  var doubleSlashRegEx = /[/\\]{2}/;
567
437
  function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, internal, base, isTarget) {
568
- if (process$1.noDeprecation) {
569
- return;
570
- }
438
+ if (process$1.noDeprecation) return;
571
439
  const pjsonPath = fileURLToPath(packageJsonUrl);
572
440
  const double = doubleSlashRegEx.exec(isTarget ? target : request) !== null;
573
- process$1.emitWarning(
574
- `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 ${fileURLToPath(base)}` : ""}.`,
575
- "DeprecationWarning",
576
- "DEP0166"
577
- );
441
+ process$1.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 ${fileURLToPath(base)}` : ""}.`, "DeprecationWarning", "DEP0166");
578
442
  }
579
443
  __name(emitInvalidSegmentDeprecation, "emitInvalidSegmentDeprecation");
580
444
  function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
581
- if (process$1.noDeprecation) {
582
- return;
583
- }
584
- const format2 = defaultGetFormatWithoutErrors(url, { parentURL: base.href });
585
- if (format2 !== "module") return;
445
+ if (process$1.noDeprecation) return;
446
+ if (defaultGetFormatWithoutErrors(url, { parentURL: base.href }) !== "module") return;
586
447
  const urlPath = fileURLToPath(url.href);
587
448
  const packagePath = fileURLToPath(new URL$1(".", packageJsonUrl));
588
449
  const basePath = fileURLToPath(base);
589
- if (!main) {
590
- process$1.emitWarning(
591
- `No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(
592
- packagePath.length
593
- )}", imported from ${basePath}.
594
- Default "index" lookups for the main are deprecated for ES modules.`,
595
- "DeprecationWarning",
596
- "DEP0151"
597
- );
598
- } else if (path.resolve(packagePath, main) !== urlPath) {
599
- process$1.emitWarning(
600
- `Package ${packagePath} has a "main" field set to "${main}", excluding the full filename and extension to the resolved file at "${urlPath.slice(
601
- packagePath.length
602
- )}", imported from ${basePath}.
603
- Automatic extension resolution of the "main" field is deprecated for ES modules.`,
604
- "DeprecationWarning",
605
- "DEP0151"
606
- );
607
- }
450
+ if (!main) process$1.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}.
451
+ Default "index" lookups for the main are deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
452
+ else if (path.resolve(packagePath, main) !== urlPath) process$1.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}.
453
+ Automatic extension resolution of the "main" field is deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
608
454
  }
609
455
  __name(emitLegacyIndexDeprecation, "emitLegacyIndexDeprecation");
610
- function tryStatSync(path2) {
456
+ function tryStatSync(path$1) {
611
457
  try {
612
- return statSync(path2);
458
+ return statSync(path$1);
613
459
  } catch {
614
460
  }
615
461
  }
@@ -625,7 +471,7 @@ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
625
471
  if (packageConfig.main !== void 0) {
626
472
  guess = new URL$1(packageConfig.main, packageJsonUrl);
627
473
  if (fileExists(guess)) return guess;
628
- const tries2 = [
474
+ const tries$1 = [
629
475
  `./${packageConfig.main}.js`,
630
476
  `./${packageConfig.main}.json`,
631
477
  `./${packageConfig.main}.node`,
@@ -633,23 +479,22 @@ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
633
479
  `./${packageConfig.main}/index.json`,
634
480
  `./${packageConfig.main}/index.node`
635
481
  ];
636
- let i2 = -1;
637
- while (++i2 < tries2.length) {
638
- guess = new URL$1(tries2[i2], packageJsonUrl);
482
+ let i$1 = -1;
483
+ while (++i$1 < tries$1.length) {
484
+ guess = new URL$1(tries$1[i$1], packageJsonUrl);
639
485
  if (fileExists(guess)) break;
640
486
  guess = void 0;
641
487
  }
642
488
  if (guess) {
643
- emitLegacyIndexDeprecation(
644
- guess,
645
- packageJsonUrl,
646
- base,
647
- packageConfig.main
648
- );
489
+ emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
649
490
  return guess;
650
491
  }
651
492
  }
652
- const tries = ["./index.js", "./index.json", "./index.node"];
493
+ const tries = [
494
+ "./index.js",
495
+ "./index.json",
496
+ "./index.node"
497
+ ];
653
498
  let i = -1;
654
499
  while (++i < tries.length) {
655
500
  guess = new URL$1(tries[i], packageJsonUrl);
@@ -660,20 +505,11 @@ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
660
505
  emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
661
506
  return guess;
662
507
  }
663
- throw new ERR_MODULE_NOT_FOUND(
664
- fileURLToPath(new URL$1(".", packageJsonUrl)),
665
- fileURLToPath(base)
666
- );
508
+ throw new ERR_MODULE_NOT_FOUND(fileURLToPath(new URL$1(".", packageJsonUrl)), fileURLToPath(base));
667
509
  }
668
510
  __name(legacyMainResolve, "legacyMainResolve");
669
511
  function finalizeResolution(resolved, base, preserveSymlinks) {
670
- if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) {
671
- throw new ERR_INVALID_MODULE_SPECIFIER(
672
- resolved.pathname,
673
- String.raw`must not include encoded "/" or "\" characters`,
674
- fileURLToPath(base)
675
- );
676
- }
512
+ if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) throw new ERR_INVALID_MODULE_SPECIFIER(resolved.pathname, String.raw`must not include encoded "/" or "\" characters`, fileURLToPath(base));
677
513
  let filePath;
678
514
  try {
679
515
  filePath = fileURLToPath(resolved);
@@ -682,24 +518,18 @@ function finalizeResolution(resolved, base, preserveSymlinks) {
682
518
  Object.defineProperty(error, "module", { value: String(base) });
683
519
  throw error;
684
520
  }
685
- const stats = tryStatSync(
686
- filePath.endsWith("/") ? filePath.slice(-1) : filePath
687
- );
521
+ const stats = tryStatSync(filePath.endsWith("/") ? filePath.slice(-1) : filePath);
688
522
  if (stats && stats.isDirectory()) {
689
523
  const error = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, fileURLToPath(base));
690
524
  error.url = String(resolved);
691
525
  throw error;
692
526
  }
693
527
  if (!stats || !stats.isFile()) {
694
- const error = new ERR_MODULE_NOT_FOUND(
695
- filePath || resolved.pathname,
696
- base && fileURLToPath(base),
697
- true
698
- );
528
+ const error = new ERR_MODULE_NOT_FOUND(filePath || resolved.pathname, base && fileURLToPath(base), true);
699
529
  error.url = String(resolved);
700
530
  throw error;
701
531
  }
702
- {
532
+ if (!preserveSymlinks) {
703
533
  const real = realpathSync(filePath);
704
534
  const { search, hash } = resolved;
705
535
  resolved = pathToFileURL(real + (filePath.endsWith(path.sep) ? "/" : ""));
@@ -710,44 +540,24 @@ function finalizeResolution(resolved, base, preserveSymlinks) {
710
540
  }
711
541
  __name(finalizeResolution, "finalizeResolution");
712
542
  function importNotDefined(specifier, packageJsonUrl, base) {
713
- return new ERR_PACKAGE_IMPORT_NOT_DEFINED(
714
- specifier,
715
- packageJsonUrl && fileURLToPath(new URL$1(".", packageJsonUrl)),
716
- fileURLToPath(base)
717
- );
543
+ return new ERR_PACKAGE_IMPORT_NOT_DEFINED(specifier, packageJsonUrl && fileURLToPath(new URL$1(".", packageJsonUrl)), fileURLToPath(base));
718
544
  }
719
545
  __name(importNotDefined, "importNotDefined");
720
546
  function exportsNotFound(subpath, packageJsonUrl, base) {
721
- return new ERR_PACKAGE_PATH_NOT_EXPORTED(
722
- fileURLToPath(new URL$1(".", packageJsonUrl)),
723
- subpath,
724
- base && fileURLToPath(base)
725
- );
547
+ return new ERR_PACKAGE_PATH_NOT_EXPORTED(fileURLToPath(new URL$1(".", packageJsonUrl)), subpath, base && fileURLToPath(base));
726
548
  }
727
549
  __name(exportsNotFound, "exportsNotFound");
728
550
  function throwInvalidSubpath(request, match, packageJsonUrl, internal, base) {
729
- const reason = `request is not a valid match in pattern "${match}" for the "${internal ? "imports" : "exports"}" resolution of ${fileURLToPath(packageJsonUrl)}`;
730
- throw new ERR_INVALID_MODULE_SPECIFIER(
731
- request,
732
- reason,
733
- base && fileURLToPath(base)
734
- );
551
+ throw new ERR_INVALID_MODULE_SPECIFIER(request, `request is not a valid match in pattern "${match}" for the "${internal ? "imports" : "exports"}" resolution of ${fileURLToPath(packageJsonUrl)}`, base && fileURLToPath(base));
735
552
  }
736
553
  __name(throwInvalidSubpath, "throwInvalidSubpath");
737
554
  function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
738
555
  target = typeof target === "object" && target !== null ? JSON.stringify(target, null, "") : `${target}`;
739
- return new ERR_INVALID_PACKAGE_TARGET(
740
- fileURLToPath(new URL$1(".", packageJsonUrl)),
741
- subpath,
742
- target,
743
- internal,
744
- base && fileURLToPath(base)
745
- );
556
+ return new ERR_INVALID_PACKAGE_TARGET(fileURLToPath(new URL$1(".", packageJsonUrl)), subpath, target, internal, base && fileURLToPath(base));
746
557
  }
747
558
  __name(invalidPackageTarget, "invalidPackageTarget");
748
559
  function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base, pattern, internal, isPathMap, conditions) {
749
- if (subpath !== "" && !pattern && target.at(-1) !== "/")
750
- throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
560
+ if (subpath !== "" && !pattern && target.at(-1) !== "/") throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
751
561
  if (!target.startsWith("./")) {
752
562
  if (internal && !target.startsWith("../") && !target.startsWith("/")) {
753
563
  let isURL = false;
@@ -756,78 +566,28 @@ function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base
756
566
  isURL = true;
757
567
  } catch {
758
568
  }
759
- if (!isURL) {
760
- const exportTarget = pattern ? RegExpPrototypeSymbolReplace.call(
761
- patternRegEx,
762
- target,
763
- () => subpath
764
- ) : target + subpath;
765
- return packageResolve(exportTarget, packageJsonUrl, conditions);
766
- }
569
+ if (!isURL) return packageResolve(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target + subpath, packageJsonUrl, conditions);
767
570
  }
768
571
  throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
769
572
  }
770
- if (invalidSegmentRegEx.exec(target.slice(2)) !== null) {
771
- if (deprecatedInvalidSegmentRegEx.exec(target.slice(2)) === null) {
772
- if (!isPathMap) {
773
- const request = pattern ? match.replace("*", () => subpath) : match + subpath;
774
- const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(
775
- patternRegEx,
776
- target,
777
- () => subpath
778
- ) : target;
779
- emitInvalidSegmentDeprecation(
780
- resolvedTarget,
781
- request,
782
- match,
783
- packageJsonUrl,
784
- internal,
785
- base,
786
- true
787
- );
788
- }
789
- } else {
790
- throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
573
+ if (invalidSegmentRegEx.exec(target.slice(2)) !== null) if (deprecatedInvalidSegmentRegEx.exec(target.slice(2)) === null) {
574
+ if (!isPathMap) {
575
+ const request = pattern ? match.replace("*", () => subpath) : match + subpath;
576
+ emitInvalidSegmentDeprecation(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target, request, match, packageJsonUrl, internal, base, true);
791
577
  }
792
- }
578
+ } else throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
793
579
  const resolved = new URL$1(target, packageJsonUrl);
794
580
  const resolvedPath = resolved.pathname;
795
581
  const packagePath = new URL$1(".", packageJsonUrl).pathname;
796
- if (!resolvedPath.startsWith(packagePath))
797
- throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
582
+ if (!resolvedPath.startsWith(packagePath)) throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
798
583
  if (subpath === "") return resolved;
799
584
  if (invalidSegmentRegEx.exec(subpath) !== null) {
800
585
  const request = pattern ? match.replace("*", () => subpath) : match + subpath;
801
586
  if (deprecatedInvalidSegmentRegEx.exec(subpath) === null) {
802
- if (!isPathMap) {
803
- const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(
804
- patternRegEx,
805
- target,
806
- () => subpath
807
- ) : target;
808
- emitInvalidSegmentDeprecation(
809
- resolvedTarget,
810
- request,
811
- match,
812
- packageJsonUrl,
813
- internal,
814
- base,
815
- false
816
- );
817
- }
818
- } else {
819
- throwInvalidSubpath(request, match, packageJsonUrl, internal, base);
820
- }
821
- }
822
- if (pattern) {
823
- return new URL$1(
824
- RegExpPrototypeSymbolReplace.call(
825
- patternRegEx,
826
- resolved.href,
827
- () => subpath
828
- )
829
- );
587
+ if (!isPathMap) emitInvalidSegmentDeprecation(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target, request, match, packageJsonUrl, internal, base, false);
588
+ } else throwInvalidSubpath(request, match, packageJsonUrl, internal, base);
830
589
  }
590
+ if (pattern) return new URL$1(RegExpPrototypeSymbolReplace.call(patternRegEx, resolved.href, () => subpath));
831
591
  return new URL$1(subpath, resolved);
832
592
  }
833
593
  __name(resolvePackageTargetString, "resolvePackageTargetString");
@@ -838,19 +598,7 @@ function isArrayIndex(key) {
838
598
  }
839
599
  __name(isArrayIndex, "isArrayIndex");
840
600
  function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions) {
841
- if (typeof target === "string") {
842
- return resolvePackageTargetString(
843
- target,
844
- subpath,
845
- packageSubpath,
846
- packageJsonUrl,
847
- base,
848
- pattern,
849
- internal,
850
- isPathMap,
851
- conditions
852
- );
853
- }
601
+ if (typeof target === "string") return resolvePackageTargetString(target, subpath, packageSubpath, packageJsonUrl, base, pattern, internal, isPathMap, conditions);
854
602
  if (Array.isArray(target)) {
855
603
  const targetList = target;
856
604
  if (targetList.length === 0) return null;
@@ -860,17 +608,7 @@ function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, b
860
608
  const targetItem = targetList[i];
861
609
  let resolveResult;
862
610
  try {
863
- resolveResult = resolvePackageTarget(
864
- packageJsonUrl,
865
- targetItem,
866
- subpath,
867
- packageSubpath,
868
- base,
869
- pattern,
870
- internal,
871
- isPathMap,
872
- conditions
873
- );
611
+ resolveResult = resolvePackageTarget(packageJsonUrl, targetItem, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
874
612
  } catch (error) {
875
613
  const exception = error;
876
614
  lastException = exception;
@@ -884,9 +622,7 @@ function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, b
884
622
  }
885
623
  return resolveResult;
886
624
  }
887
- if (lastException === void 0 || lastException === null) {
888
- return null;
889
- }
625
+ if (lastException === void 0 || lastException === null) return null;
890
626
  throw lastException;
891
627
  }
892
628
  if (typeof target === "object" && target !== null) {
@@ -894,46 +630,22 @@ function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, b
894
630
  let i = -1;
895
631
  while (++i < keys.length) {
896
632
  const key = keys[i];
897
- if (isArrayIndex(key)) {
898
- throw new ERR_INVALID_PACKAGE_CONFIG(
899
- fileURLToPath(packageJsonUrl),
900
- fileURLToPath(base),
901
- '"exports" cannot contain numeric property keys.'
902
- );
903
- }
633
+ if (isArrayIndex(key)) throw new ERR_INVALID_PACKAGE_CONFIG(fileURLToPath(packageJsonUrl), fileURLToPath(base), '"exports" cannot contain numeric property keys.');
904
634
  }
905
635
  i = -1;
906
636
  while (++i < keys.length) {
907
637
  const key = keys[i];
908
638
  if (key === "default" || conditions && conditions.has(key)) {
909
639
  const conditionalTarget = target[key];
910
- const resolveResult = resolvePackageTarget(
911
- packageJsonUrl,
912
- conditionalTarget,
913
- subpath,
914
- packageSubpath,
915
- base,
916
- pattern,
917
- internal,
918
- isPathMap,
919
- conditions
920
- );
640
+ const resolveResult = resolvePackageTarget(packageJsonUrl, conditionalTarget, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
921
641
  if (resolveResult === void 0) continue;
922
642
  return resolveResult;
923
643
  }
924
644
  }
925
645
  return null;
926
646
  }
927
- if (target === null) {
928
- return null;
929
- }
930
- throw invalidPackageTarget(
931
- packageSubpath,
932
- target,
933
- packageJsonUrl,
934
- internal,
935
- base
936
- );
647
+ if (target === null) return null;
648
+ throw invalidPackageTarget(packageSubpath, target, packageJsonUrl, internal, base);
937
649
  }
938
650
  __name(resolvePackageTarget, "resolvePackageTarget");
939
651
  function isConditionalExportsMainSugar(exports, packageJsonUrl, base) {
@@ -946,54 +658,27 @@ function isConditionalExportsMainSugar(exports, packageJsonUrl, base) {
946
658
  while (++keyIndex < keys.length) {
947
659
  const key = keys[keyIndex];
948
660
  const currentIsConditionalSugar = key === "" || key[0] !== ".";
949
- if (i++ === 0) {
950
- isConditionalSugar = currentIsConditionalSugar;
951
- } else if (isConditionalSugar !== currentIsConditionalSugar) {
952
- throw new ERR_INVALID_PACKAGE_CONFIG(
953
- fileURLToPath(packageJsonUrl),
954
- fileURLToPath(base),
955
- `"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.`
956
- );
957
- }
661
+ if (i++ === 0) isConditionalSugar = currentIsConditionalSugar;
662
+ else if (isConditionalSugar !== currentIsConditionalSugar) throw new ERR_INVALID_PACKAGE_CONFIG(fileURLToPath(packageJsonUrl), fileURLToPath(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.`);
958
663
  }
959
664
  return isConditionalSugar;
960
665
  }
961
666
  __name(isConditionalExportsMainSugar, "isConditionalExportsMainSugar");
962
667
  function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
963
- if (process$1.noDeprecation) {
964
- return;
965
- }
668
+ if (process$1.noDeprecation) return;
966
669
  const pjsonPath = fileURLToPath(pjsonUrl);
967
670
  if (emittedPackageWarnings.has(pjsonPath + "|" + match)) return;
968
671
  emittedPackageWarnings.add(pjsonPath + "|" + match);
969
- process$1.emitWarning(
970
- `Use of deprecated trailing slash pattern mapping "${match}" in the "exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`,
971
- "DeprecationWarning",
972
- "DEP0155"
973
- );
672
+ process$1.emitWarning(`Use of deprecated trailing slash pattern mapping "${match}" in the "exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`, "DeprecationWarning", "DEP0155");
974
673
  }
975
674
  __name(emitTrailingSlashPatternDeprecation, "emitTrailingSlashPatternDeprecation");
976
675
  function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions) {
977
676
  let exports = packageConfig.exports;
978
- if (isConditionalExportsMainSugar(exports, packageJsonUrl, base)) {
979
- exports = { ".": exports };
980
- }
677
+ if (isConditionalExportsMainSugar(exports, packageJsonUrl, base)) exports = { ".": exports };
981
678
  if (own.call(exports, packageSubpath) && !packageSubpath.includes("*") && !packageSubpath.endsWith("/")) {
982
679
  const target = exports[packageSubpath];
983
- const resolveResult = resolvePackageTarget(
984
- packageJsonUrl,
985
- target,
986
- "",
987
- packageSubpath,
988
- base,
989
- false,
990
- false,
991
- false,
992
- conditions
993
- );
994
- if (resolveResult === null || resolveResult === void 0) {
995
- throw exportsNotFound(packageSubpath, packageJsonUrl, base);
996
- }
680
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, "", packageSubpath, base, false, false, false, conditions);
681
+ if (resolveResult === null || resolveResult === void 0) throw exportsNotFound(packageSubpath, packageJsonUrl, base);
997
682
  return resolveResult;
998
683
  }
999
684
  let bestMatch = "";
@@ -1004,39 +689,18 @@ function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, ba
1004
689
  const key = keys[i];
1005
690
  const patternIndex = key.indexOf("*");
1006
691
  if (patternIndex !== -1 && packageSubpath.startsWith(key.slice(0, patternIndex))) {
1007
- if (packageSubpath.endsWith("/")) {
1008
- emitTrailingSlashPatternDeprecation(
1009
- packageSubpath,
1010
- packageJsonUrl,
1011
- base
1012
- );
1013
- }
692
+ if (packageSubpath.endsWith("/")) emitTrailingSlashPatternDeprecation(packageSubpath, packageJsonUrl, base);
1014
693
  const patternTrailer = key.slice(patternIndex + 1);
1015
694
  if (packageSubpath.length >= key.length && packageSubpath.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
1016
695
  bestMatch = key;
1017
- bestMatchSubpath = packageSubpath.slice(
1018
- patternIndex,
1019
- packageSubpath.length - patternTrailer.length
1020
- );
696
+ bestMatchSubpath = packageSubpath.slice(patternIndex, packageSubpath.length - patternTrailer.length);
1021
697
  }
1022
698
  }
1023
699
  }
1024
700
  if (bestMatch) {
1025
701
  const target = exports[bestMatch];
1026
- const resolveResult = resolvePackageTarget(
1027
- packageJsonUrl,
1028
- target,
1029
- bestMatchSubpath,
1030
- bestMatch,
1031
- base,
1032
- true,
1033
- false,
1034
- packageSubpath.endsWith("/"),
1035
- conditions
1036
- );
1037
- if (resolveResult === null || resolveResult === void 0) {
1038
- throw exportsNotFound(packageSubpath, packageJsonUrl, base);
1039
- }
702
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, false, packageSubpath.endsWith("/"), conditions);
703
+ if (resolveResult === null || resolveResult === void 0) throw exportsNotFound(packageSubpath, packageJsonUrl, base);
1040
704
  return resolveResult;
1041
705
  }
1042
706
  throw exportsNotFound(packageSubpath, packageJsonUrl, base);
@@ -1057,68 +721,36 @@ function patternKeyCompare(a, b) {
1057
721
  }
1058
722
  __name(patternKeyCompare, "patternKeyCompare");
1059
723
  function packageImportsResolve(name, base, conditions) {
1060
- if (name === "#" || name.startsWith("#/") || name.endsWith("/")) {
1061
- const reason = "is not a valid internal imports specifier name";
1062
- throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, fileURLToPath(base));
1063
- }
724
+ if (name === "#" || name.startsWith("#/") || name.endsWith("/")) throw new ERR_INVALID_MODULE_SPECIFIER(name, "is not a valid internal imports specifier name", fileURLToPath(base));
1064
725
  let packageJsonUrl;
1065
726
  const packageConfig = getPackageScopeConfig(base);
1066
727
  if (packageConfig.exists) {
1067
728
  packageJsonUrl = pathToFileURL(packageConfig.pjsonPath);
1068
729
  const imports = packageConfig.imports;
1069
- if (imports) {
1070
- if (own.call(imports, name) && !name.includes("*")) {
1071
- const resolveResult = resolvePackageTarget(
1072
- packageJsonUrl,
1073
- imports[name],
1074
- "",
1075
- name,
1076
- base,
1077
- false,
1078
- true,
1079
- false,
1080
- conditions
1081
- );
1082
- if (resolveResult !== null && resolveResult !== void 0) {
1083
- return resolveResult;
1084
- }
1085
- } else {
1086
- let bestMatch = "";
1087
- let bestMatchSubpath = "";
1088
- const keys = Object.getOwnPropertyNames(imports);
1089
- let i = -1;
1090
- while (++i < keys.length) {
1091
- const key = keys[i];
1092
- const patternIndex = key.indexOf("*");
1093
- if (patternIndex !== -1 && name.startsWith(key.slice(0, -1))) {
1094
- const patternTrailer = key.slice(patternIndex + 1);
1095
- if (name.length >= key.length && name.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
1096
- bestMatch = key;
1097
- bestMatchSubpath = name.slice(
1098
- patternIndex,
1099
- name.length - patternTrailer.length
1100
- );
1101
- }
1102
- }
1103
- }
1104
- if (bestMatch) {
1105
- const target = imports[bestMatch];
1106
- const resolveResult = resolvePackageTarget(
1107
- packageJsonUrl,
1108
- target,
1109
- bestMatchSubpath,
1110
- bestMatch,
1111
- base,
1112
- true,
1113
- true,
1114
- false,
1115
- conditions
1116
- );
1117
- if (resolveResult !== null && resolveResult !== void 0) {
1118
- return resolveResult;
730
+ if (imports) if (own.call(imports, name) && !name.includes("*")) {
731
+ const resolveResult = resolvePackageTarget(packageJsonUrl, imports[name], "", name, base, false, true, false, conditions);
732
+ if (resolveResult !== null && resolveResult !== void 0) return resolveResult;
733
+ } else {
734
+ let bestMatch = "";
735
+ let bestMatchSubpath = "";
736
+ const keys = Object.getOwnPropertyNames(imports);
737
+ let i = -1;
738
+ while (++i < keys.length) {
739
+ const key = keys[i];
740
+ const patternIndex = key.indexOf("*");
741
+ if (patternIndex !== -1 && name.startsWith(key.slice(0, -1))) {
742
+ const patternTrailer = key.slice(patternIndex + 1);
743
+ if (name.length >= key.length && name.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
744
+ bestMatch = key;
745
+ bestMatchSubpath = name.slice(patternIndex, name.length - patternTrailer.length);
1119
746
  }
1120
747
  }
1121
748
  }
749
+ if (bestMatch) {
750
+ const target = imports[bestMatch];
751
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, true, false, conditions);
752
+ if (resolveResult !== null && resolveResult !== void 0) return resolveResult;
753
+ }
1122
754
  }
1123
755
  }
1124
756
  throw importNotDefined(name, packageJsonUrl, base);
@@ -1130,76 +762,41 @@ function parsePackageName(specifier, base) {
1130
762
  let isScoped = false;
1131
763
  if (specifier[0] === "@") {
1132
764
  isScoped = true;
1133
- if (separatorIndex === -1 || specifier.length === 0) {
1134
- validPackageName = false;
1135
- } else {
1136
- separatorIndex = specifier.indexOf("/", separatorIndex + 1);
1137
- }
765
+ if (separatorIndex === -1 || specifier.length === 0) validPackageName = false;
766
+ else separatorIndex = specifier.indexOf("/", separatorIndex + 1);
1138
767
  }
1139
768
  const packageName = separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
1140
- if (invalidPackageNameRegEx.exec(packageName) !== null) {
1141
- validPackageName = false;
1142
- }
1143
- if (!validPackageName) {
1144
- throw new ERR_INVALID_MODULE_SPECIFIER(
1145
- specifier,
1146
- "is not a valid package name",
1147
- fileURLToPath(base)
1148
- );
1149
- }
1150
- const packageSubpath = "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex));
1151
- return { packageName, packageSubpath, isScoped };
769
+ if (invalidPackageNameRegEx.exec(packageName) !== null) validPackageName = false;
770
+ if (!validPackageName) throw new ERR_INVALID_MODULE_SPECIFIER(specifier, "is not a valid package name", fileURLToPath(base));
771
+ return {
772
+ packageName,
773
+ packageSubpath: "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex)),
774
+ isScoped
775
+ };
1152
776
  }
1153
777
  __name(parsePackageName, "parsePackageName");
1154
778
  function packageResolve(specifier, base, conditions) {
1155
- if (nodeBuiltins.includes(specifier)) {
1156
- return new URL$1("node:" + specifier);
1157
- }
1158
- const { packageName, packageSubpath, isScoped } = parsePackageName(
1159
- specifier,
1160
- base
1161
- );
779
+ if (nodeBuiltins.includes(specifier)) return new URL$1("node:" + specifier);
780
+ const { packageName, packageSubpath, isScoped } = parsePackageName(specifier, base);
1162
781
  const packageConfig = getPackageScopeConfig(base);
1163
- if (packageConfig.exists && packageConfig.name === packageName && packageConfig.exports !== void 0 && packageConfig.exports !== null) {
1164
- const packageJsonUrl2 = pathToFileURL(packageConfig.pjsonPath);
1165
- return packageExportsResolve(
1166
- packageJsonUrl2,
1167
- packageSubpath,
1168
- packageConfig,
1169
- base,
1170
- conditions
1171
- );
1172
- }
1173
- let packageJsonUrl = new URL$1(
1174
- "./node_modules/" + packageName + "/package.json",
1175
- base
1176
- );
782
+ if (packageConfig.exists && packageConfig.name === packageName && packageConfig.exports !== void 0 && packageConfig.exports !== null) return packageExportsResolve(pathToFileURL(packageConfig.pjsonPath), packageSubpath, packageConfig, base, conditions);
783
+ let packageJsonUrl = new URL$1("./node_modules/" + packageName + "/package.json", base);
1177
784
  let packageJsonPath = fileURLToPath(packageJsonUrl);
1178
785
  let lastPath;
1179
786
  do {
1180
787
  const stat = tryStatSync(packageJsonPath.slice(0, -13));
1181
788
  if (!stat || !stat.isDirectory()) {
1182
789
  lastPath = packageJsonPath;
1183
- packageJsonUrl = new URL$1(
1184
- (isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json",
1185
- packageJsonUrl
1186
- );
790
+ packageJsonUrl = new URL$1((isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json", packageJsonUrl);
1187
791
  packageJsonPath = fileURLToPath(packageJsonUrl);
1188
792
  continue;
1189
793
  }
1190
- const packageConfig2 = read(packageJsonPath, { base, specifier });
1191
- if (packageConfig2.exports !== void 0 && packageConfig2.exports !== null) {
1192
- return packageExportsResolve(
1193
- packageJsonUrl,
1194
- packageSubpath,
1195
- packageConfig2,
1196
- base,
1197
- conditions
1198
- );
1199
- }
1200
- if (packageSubpath === ".") {
1201
- return legacyMainResolve(packageJsonUrl, packageConfig2, base);
1202
- }
794
+ const packageConfig$1 = read(packageJsonPath, {
795
+ base,
796
+ specifier
797
+ });
798
+ if (packageConfig$1.exports !== void 0 && packageConfig$1.exports !== null) return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig$1, base, conditions);
799
+ if (packageSubpath === ".") return legacyMainResolve(packageJsonUrl, packageConfig$1, base);
1203
800
  return new URL$1(packageSubpath, packageJsonUrl);
1204
801
  } while (packageJsonPath.length !== lastPath.length);
1205
802
  throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), false);
@@ -1208,9 +805,7 @@ __name(packageResolve, "packageResolve");
1208
805
  function isRelativeSpecifier(specifier) {
1209
806
  if (specifier[0] === ".") {
1210
807
  if (specifier.length === 1 || specifier[1] === "/") return true;
1211
- if (specifier[1] === "." && (specifier.length === 2 || specifier[2] === "/")) {
1212
- return true;
1213
- }
808
+ if (specifier[1] === "." && (specifier.length === 2 || specifier[2] === "/")) return true;
1214
809
  }
1215
810
  return false;
1216
811
  }
@@ -1225,53 +820,35 @@ function moduleResolve(specifier, base, conditions, preserveSymlinks) {
1225
820
  const protocol = base.protocol;
1226
821
  const isData = protocol === "data:";
1227
822
  let resolved;
1228
- if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) {
1229
- try {
1230
- resolved = new URL$1(specifier, base);
1231
- } catch (error_) {
823
+ if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) try {
824
+ resolved = new URL$1(specifier, base);
825
+ } catch (error_) {
826
+ const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
827
+ error.cause = error_;
828
+ throw error;
829
+ }
830
+ else if (protocol === "file:" && specifier[0] === "#") resolved = packageImportsResolve(specifier, base, conditions);
831
+ else try {
832
+ resolved = new URL$1(specifier);
833
+ } catch (error_) {
834
+ if (isData && !nodeBuiltins.includes(specifier)) {
1232
835
  const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
1233
836
  error.cause = error_;
1234
837
  throw error;
1235
838
  }
1236
- } else if (protocol === "file:" && specifier[0] === "#") {
1237
- resolved = packageImportsResolve(specifier, base, conditions);
1238
- } else {
1239
- try {
1240
- resolved = new URL$1(specifier);
1241
- } catch (error_) {
1242
- if (isData && !nodeBuiltins.includes(specifier)) {
1243
- const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
1244
- error.cause = error_;
1245
- throw error;
1246
- }
1247
- resolved = packageResolve(specifier, base, conditions);
1248
- }
839
+ resolved = packageResolve(specifier, base, conditions);
1249
840
  }
1250
- assert(resolved !== void 0, "expected to be defined");
1251
- if (resolved.protocol !== "file:") {
1252
- return resolved;
1253
- }
1254
- return finalizeResolution(resolved, base);
841
+ assert.ok(resolved !== void 0, "expected to be defined");
842
+ if (resolved.protocol !== "file:") return resolved;
843
+ return finalizeResolution(resolved, base, preserveSymlinks);
1255
844
  }
1256
845
  __name(moduleResolve, "moduleResolve");
1257
846
  var DEFAULT_CONDITIONS_SET = /* @__PURE__ */ new Set(["node", "import"]);
1258
847
  var isWindows = (() => process.platform === "win32")();
1259
- var NOT_FOUND_ERRORS = /* @__PURE__ */ new Set([
1260
- "ERR_MODULE_NOT_FOUND",
1261
- "ERR_UNSUPPORTED_DIR_IMPORT",
1262
- "MODULE_NOT_FOUND",
1263
- "ERR_PACKAGE_PATH_NOT_EXPORTED",
1264
- "ERR_PACKAGE_IMPORT_NOT_DEFINED"
1265
- ]);
1266
- var globalCache = (() => (
1267
- // eslint-disable-next-line unicorn/no-unreadable-iife
1268
- globalThis["__EXSOLVE_CACHE__"] ||= /* @__PURE__ */ new Map()
1269
- ))();
848
+ var globalCache = (() => globalThis["__EXSOLVE_CACHE__"] ||= /* @__PURE__ */ new Map())();
1270
849
  function resolveModuleURL(input, options) {
1271
850
  const parsedInput = _parseInput(input);
1272
- if ("external" in parsedInput) {
1273
- return parsedInput.external;
1274
- }
851
+ if ("external" in parsedInput) return parsedInput.external;
1275
852
  const specifier = parsedInput.specifier;
1276
853
  let url = parsedInput.url;
1277
854
  let absolutePath = parsedInput.absolutePath;
@@ -1283,36 +860,26 @@ function resolveModuleURL(input, options) {
1283
860
  }
1284
861
  if (cacheObj) {
1285
862
  const cached = cacheObj.get(cacheKey);
1286
- if (typeof cached === "string") {
1287
- return cached;
1288
- }
863
+ if (typeof cached === "string") return cached;
1289
864
  if (cached instanceof Error) {
1290
- if (options?.try) {
1291
- return void 0;
1292
- }
865
+ if (options?.try) return;
1293
866
  throw cached;
1294
867
  }
1295
868
  }
1296
- if (absolutePath) {
1297
- try {
1298
- const stat = lstatSync(absolutePath);
1299
- if (stat.isSymbolicLink()) {
1300
- absolutePath = realpathSync(absolutePath);
1301
- url = pathToFileURL(absolutePath);
1302
- }
1303
- if (stat.isFile()) {
1304
- if (cacheObj) {
1305
- cacheObj.set(cacheKey, url.href);
1306
- }
1307
- return url.href;
1308
- }
1309
- } catch (error) {
1310
- if (error?.code !== "ENOENT") {
1311
- if (cacheObj) {
1312
- cacheObj.set(cacheKey, error);
1313
- }
1314
- throw error;
1315
- }
869
+ if (absolutePath) try {
870
+ const stat = lstatSync(absolutePath);
871
+ if (stat.isSymbolicLink()) {
872
+ absolutePath = realpathSync(absolutePath);
873
+ url = pathToFileURL(absolutePath);
874
+ }
875
+ if (stat.isFile()) {
876
+ if (cacheObj) cacheObj.set(cacheKey, url.href);
877
+ return url.href;
878
+ }
879
+ } catch (error) {
880
+ if (error?.code !== "ENOENT") {
881
+ if (cacheObj) cacheObj.set(cacheKey, error);
882
+ throw error;
1316
883
  }
1317
884
  }
1318
885
  const conditionsSet = options?.conditions ? new Set(options.conditions) : DEFAULT_CONDITIONS_SET;
@@ -1324,50 +891,30 @@ function resolveModuleURL(input, options) {
1324
891
  for (const base of bases) {
1325
892
  for (const suffix of suffixes) {
1326
893
  let name = _join(target, suffix);
1327
- if (name === ".") {
1328
- name += "/.";
1329
- }
894
+ if (name === ".") name += "/.";
1330
895
  for (const extension of extensions) {
1331
896
  resolved = _tryModuleResolve(name + extension, base, conditionsSet);
1332
- if (resolved) {
1333
- break;
1334
- }
1335
- }
1336
- if (resolved) {
1337
- break;
897
+ if (resolved) break;
1338
898
  }
899
+ if (resolved) break;
1339
900
  }
1340
- if (resolved) {
1341
- break;
1342
- }
901
+ if (resolved) break;
1343
902
  }
1344
903
  if (!resolved) {
1345
- const error = new Error(
1346
- `Cannot resolve module "${input}" (from: ${bases.map((u) => _fmtPath(u)).join(", ")})`
1347
- );
904
+ const error = new Error(`Cannot resolve module "${input}" (from: ${bases.map((u) => _fmtPath(u)).join(", ")})`);
1348
905
  error.code = "ERR_MODULE_NOT_FOUND";
1349
- if (cacheObj) {
1350
- cacheObj.set(cacheKey, error);
1351
- }
1352
- if (options?.try) {
1353
- return void 0;
1354
- }
906
+ if (cacheObj) cacheObj.set(cacheKey, error);
907
+ if (options?.try) return;
1355
908
  throw error;
1356
909
  }
1357
- if (cacheObj) {
1358
- cacheObj.set(cacheKey, resolved.href);
1359
- }
910
+ if (cacheObj) cacheObj.set(cacheKey, resolved.href);
1360
911
  return resolved.href;
1361
912
  }
1362
913
  __name(resolveModuleURL, "resolveModuleURL");
1363
914
  function resolveModulePath(id, options) {
1364
915
  const resolved = resolveModuleURL(id, options);
1365
- if (!resolved) {
1366
- return void 0;
1367
- }
1368
- if (!resolved.startsWith("file://") && options?.try) {
1369
- return void 0;
1370
- }
916
+ if (!resolved) return;
917
+ if (!resolved.startsWith("file://") && options?.try) return;
1371
918
  const absolutePath = fileURLToPath(resolved);
1372
919
  return isWindows ? _normalizeWinPath(absolutePath) : absolutePath;
1373
920
  }
@@ -1375,40 +922,23 @@ __name(resolveModulePath, "resolveModulePath");
1375
922
  function _tryModuleResolve(specifier, base, conditions) {
1376
923
  try {
1377
924
  return moduleResolve(specifier, base, conditions);
1378
- } catch (error) {
1379
- if (!NOT_FOUND_ERRORS.has(error?.code)) {
1380
- throw error;
1381
- }
925
+ } catch {
1382
926
  }
1383
927
  }
1384
928
  __name(_tryModuleResolve, "_tryModuleResolve");
1385
929
  function _normalizeBases(inputs) {
1386
- const urls = (Array.isArray(inputs) ? inputs : [inputs]).flatMap(
1387
- (input) => _normalizeBase(input)
1388
- );
1389
- if (urls.length === 0) {
1390
- return [pathToFileURL("./")];
1391
- }
930
+ const urls = (Array.isArray(inputs) ? inputs : [inputs]).flatMap((input) => _normalizeBase(input));
931
+ if (urls.length === 0) return [pathToFileURL("./")];
1392
932
  return urls;
1393
933
  }
1394
934
  __name(_normalizeBases, "_normalizeBases");
1395
935
  function _normalizeBase(input) {
1396
- if (!input) {
1397
- return [];
1398
- }
1399
- if (_isURL(input)) {
1400
- return [input];
1401
- }
1402
- if (typeof input !== "string") {
1403
- return [];
1404
- }
1405
- if (/^(?:node|data|http|https|file):/.test(input)) {
1406
- return new URL(input);
1407
- }
936
+ if (!input) return [];
937
+ if (_isURL(input)) return [input];
938
+ if (typeof input !== "string") return [];
939
+ if (/^(?:node|data|http|https|file):/.test(input)) return new URL(input);
1408
940
  try {
1409
- if (input.endsWith("/") || statSync(input).isDirectory()) {
1410
- return pathToFileURL(input + "/");
1411
- }
941
+ if (input.endsWith("/") || statSync(input).isDirectory()) return pathToFileURL(input + "/");
1412
942
  return pathToFileURL(input);
1413
943
  } catch {
1414
944
  return [pathToFileURL(input + "/"), pathToFileURL(input)];
@@ -1434,14 +964,12 @@ function _cacheKey(id, opts) {
1434
964
  }
1435
965
  __name(_cacheKey, "_cacheKey");
1436
966
  function _join(a, b) {
1437
- if (!a || !b || b === "/") {
1438
- return a;
1439
- }
967
+ if (!a || !b || b === "/") return a;
1440
968
  return (a.endsWith("/") ? a : a + "/") + (b.startsWith("/") ? b.slice(1) : b);
1441
969
  }
1442
970
  __name(_join, "_join");
1443
- function _normalizeWinPath(path2) {
1444
- return path2.replace(/\\/g, "/").replace(/^[a-z]:\//, (r) => r.toUpperCase());
971
+ function _normalizeWinPath(path$1) {
972
+ return path$1.replace(/\\/g, "/").replace(/^[a-z]:\//, (r) => r.toUpperCase());
1445
973
  }
1446
974
  __name(_normalizeWinPath, "_normalizeWinPath");
1447
975
  function _isURL(input) {
@@ -1452,23 +980,24 @@ function _parseInput(input) {
1452
980
  if (typeof input === "string") {
1453
981
  if (input.startsWith("file:")) {
1454
982
  const url = new URL(input);
1455
- return { url, absolutePath: fileURLToPath(url) };
1456
- }
1457
- if (isAbsolute(input)) {
1458
- return { url: pathToFileURL(input), absolutePath: input };
1459
- }
1460
- if (/^(?:node|data|http|https):/.test(input)) {
1461
- return { external: input };
1462
- }
1463
- if (nodeBuiltins.includes(input) && !input.includes(":")) {
1464
- return { external: `node:${input}` };
983
+ return {
984
+ url,
985
+ absolutePath: fileURLToPath(url)
986
+ };
1465
987
  }
988
+ if (isAbsolute(input)) return {
989
+ url: pathToFileURL(input),
990
+ absolutePath: input
991
+ };
992
+ if (/^(?:node|data|http|https):/.test(input)) return { external: input };
993
+ if (nodeBuiltins.includes(input) && !input.includes(":")) return { external: `node:${input}` };
1466
994
  return { specifier: input };
1467
995
  }
1468
996
  if (_isURL(input)) {
1469
- if (input.protocol === "file:") {
1470
- return { url: input, absolutePath: fileURLToPath(input) };
1471
- }
997
+ if (input.protocol === "file:") return {
998
+ url: input,
999
+ absolutePath: fileURLToPath(input)
1000
+ };
1472
1001
  return { external: input.href };
1473
1002
  }
1474
1003
  throw new TypeError("id must be a `string` or `URL`");