@powerlines/plugin-automd 0.1.340 → 0.1.342

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