@tachybase/module-cloud-component 0.23.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 (109) hide show
  1. package/.turbo/turbo-build.log +9 -0
  2. package/README.md +1 -0
  3. package/client.d.ts +2 -0
  4. package/client.js +1 -0
  5. package/dist/client/CloudComponent.provider.d.ts +2 -0
  6. package/dist/client/cloud-library-manager/CloudLibrary.collection.d.ts +2 -0
  7. package/dist/client/cloud-library-manager/CloudLibraryManager.d.ts +2 -0
  8. package/dist/client/cloud-library-manager/CloudLibraryManager.fields.d.ts +82 -0
  9. package/dist/client/cloud-library-manager/CloudLibraryManager.schema.d.ts +1075 -0
  10. package/dist/client/components/CloudComponentLink.d.ts +2 -0
  11. package/dist/client/components/ComponentEditor.d.ts +6 -0
  12. package/dist/client/components/MarkdownEditor.d.ts +9 -0
  13. package/dist/client/components/Preview.d.ts +9 -0
  14. package/dist/client/index.d.ts +8 -0
  15. package/dist/client/index.js +1107 -0
  16. package/dist/client/locale.d.ts +9 -0
  17. package/dist/client/settings/CloudComponentBlock.d.ts +4 -0
  18. package/dist/client/settings/InitializerItem.d.ts +2 -0
  19. package/dist/client/settings/schema.d.ts +2 -0
  20. package/dist/client/settings/settings.d.ts +2 -0
  21. package/dist/externalVersion.js +15 -0
  22. package/dist/index.d.ts +2 -0
  23. package/dist/index.js +39 -0
  24. package/dist/locale/en-US.json +12 -0
  25. package/dist/locale/zh-CN.json +12 -0
  26. package/dist/node_modules/@babel/core/LICENSE +22 -0
  27. package/dist/node_modules/@babel/core/cjs-proxy.cjs +68 -0
  28. package/dist/node_modules/@babel/core/lib/config/cache-contexts.js +3 -0
  29. package/dist/node_modules/@babel/core/lib/config/caching.js +261 -0
  30. package/dist/node_modules/@babel/core/lib/config/config-chain.js +469 -0
  31. package/dist/node_modules/@babel/core/lib/config/config-descriptors.js +190 -0
  32. package/dist/node_modules/@babel/core/lib/config/files/configuration.js +287 -0
  33. package/dist/node_modules/@babel/core/lib/config/files/import.cjs +6 -0
  34. package/dist/node_modules/@babel/core/lib/config/files/index-browser.js +58 -0
  35. package/dist/node_modules/@babel/core/lib/config/files/index.js +78 -0
  36. package/dist/node_modules/@babel/core/lib/config/files/module-types.js +195 -0
  37. package/dist/node_modules/@babel/core/lib/config/files/package.js +61 -0
  38. package/dist/node_modules/@babel/core/lib/config/files/plugins.js +229 -0
  39. package/dist/node_modules/@babel/core/lib/config/files/types.js +3 -0
  40. package/dist/node_modules/@babel/core/lib/config/files/utils.js +36 -0
  41. package/dist/node_modules/@babel/core/lib/config/full.js +312 -0
  42. package/dist/node_modules/@babel/core/lib/config/helpers/config-api.js +84 -0
  43. package/dist/node_modules/@babel/core/lib/config/helpers/deep-array.js +23 -0
  44. package/dist/node_modules/@babel/core/lib/config/helpers/environment.js +12 -0
  45. package/dist/node_modules/@babel/core/lib/config/index.js +93 -0
  46. package/dist/node_modules/@babel/core/lib/config/item.js +67 -0
  47. package/dist/node_modules/@babel/core/lib/config/partial.js +158 -0
  48. package/dist/node_modules/@babel/core/lib/config/pattern-to-regex.js +38 -0
  49. package/dist/node_modules/@babel/core/lib/config/plugin.js +33 -0
  50. package/dist/node_modules/@babel/core/lib/config/printer.js +113 -0
  51. package/dist/node_modules/@babel/core/lib/config/resolve-targets-browser.js +41 -0
  52. package/dist/node_modules/@babel/core/lib/config/resolve-targets.js +61 -0
  53. package/dist/node_modules/@babel/core/lib/config/util.js +31 -0
  54. package/dist/node_modules/@babel/core/lib/config/validation/option-assertions.js +277 -0
  55. package/dist/node_modules/@babel/core/lib/config/validation/options.js +189 -0
  56. package/dist/node_modules/@babel/core/lib/config/validation/plugins.js +67 -0
  57. package/dist/node_modules/@babel/core/lib/config/validation/removed.js +68 -0
  58. package/dist/node_modules/@babel/core/lib/errors/config-error.js +18 -0
  59. package/dist/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js +98 -0
  60. package/dist/node_modules/@babel/core/lib/gensync-utils/async.js +90 -0
  61. package/dist/node_modules/@babel/core/lib/gensync-utils/fs.js +31 -0
  62. package/dist/node_modules/@babel/core/lib/gensync-utils/functional.js +58 -0
  63. package/dist/node_modules/@babel/core/lib/index.js +227 -0
  64. package/dist/node_modules/@babel/core/lib/parse.js +47 -0
  65. package/dist/node_modules/@babel/core/lib/parser/index.js +79 -0
  66. package/dist/node_modules/@babel/core/lib/parser/util/missing-plugin-helper.js +339 -0
  67. package/dist/node_modules/@babel/core/lib/tools/build-external-helpers.js +144 -0
  68. package/dist/node_modules/@babel/core/lib/transform-ast.js +50 -0
  69. package/dist/node_modules/@babel/core/lib/transform-file-browser.js +23 -0
  70. package/dist/node_modules/@babel/core/lib/transform-file.js +40 -0
  71. package/dist/node_modules/@babel/core/lib/transform.js +49 -0
  72. package/dist/node_modules/@babel/core/lib/transformation/block-hoist-plugin.js +84 -0
  73. package/dist/node_modules/@babel/core/lib/transformation/file/babel-7-helpers.cjs +4 -0
  74. package/dist/node_modules/@babel/core/lib/transformation/file/file.js +214 -0
  75. package/dist/node_modules/@babel/core/lib/transformation/file/generate.js +84 -0
  76. package/dist/node_modules/@babel/core/lib/transformation/file/merge-map.js +37 -0
  77. package/dist/node_modules/@babel/core/lib/transformation/index.js +92 -0
  78. package/dist/node_modules/@babel/core/lib/transformation/normalize-file.js +129 -0
  79. package/dist/node_modules/@babel/core/lib/transformation/normalize-opts.js +59 -0
  80. package/dist/node_modules/@babel/core/lib/transformation/plugin-pass.js +50 -0
  81. package/dist/node_modules/@babel/core/lib/transformation/util/clone-deep.js +36 -0
  82. package/dist/node_modules/@babel/core/lib/vendor/import-meta-resolve.js +1043 -0
  83. package/dist/node_modules/@babel/core/node_modules/.bin/json5 +17 -0
  84. package/dist/node_modules/@babel/core/node_modules/.bin/parser +17 -0
  85. package/dist/node_modules/@babel/core/node_modules/.bin/semver +17 -0
  86. package/dist/node_modules/@babel/core/package.json +1 -0
  87. package/dist/node_modules/@babel/core/src/config/files/index-browser.ts +113 -0
  88. package/dist/node_modules/@babel/core/src/config/files/index.ts +29 -0
  89. package/dist/node_modules/@babel/core/src/config/resolve-targets-browser.ts +40 -0
  90. package/dist/node_modules/@babel/core/src/config/resolve-targets.ts +56 -0
  91. package/dist/node_modules/@babel/core/src/transform-file-browser.ts +31 -0
  92. package/dist/node_modules/@babel/core/src/transform-file.ts +55 -0
  93. package/dist/server/actions/cloud-libraries-controller.d.ts +7 -0
  94. package/dist/server/actions/cloud-libraries-controller.js +147 -0
  95. package/dist/server/collections/cloud-libraries.d.ts +2 -0
  96. package/dist/server/collections/cloud-libraries.js +98 -0
  97. package/dist/server/collections/effect-libraries.d.ts +2 -0
  98. package/dist/server/collections/effect-libraries.js +78 -0
  99. package/dist/server/index.d.ts +1 -0
  100. package/dist/server/index.js +33 -0
  101. package/dist/server/plugin.d.ts +4 -0
  102. package/dist/server/plugin.js +87 -0
  103. package/dist/server/services/cloud-compiler.d.ts +8 -0
  104. package/dist/server/services/cloud-compiler.js +116 -0
  105. package/dist/server/services/cloud-libraries-service.d.ts +11 -0
  106. package/dist/server/services/cloud-libraries-service.js +196 -0
  107. package/package.json +44 -0
  108. package/server.d.ts +2 -0
  109. package/server.js +1 -0
@@ -0,0 +1,1043 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.moduleResolve = moduleResolve;
7
+ exports.resolve = resolve;
8
+ function _assert() {
9
+ const data = require("assert");
10
+ _assert = function () {
11
+ return data;
12
+ };
13
+ return data;
14
+ }
15
+ function _fs() {
16
+ const data = _interopRequireWildcard(require("fs"), true);
17
+ _fs = function () {
18
+ return data;
19
+ };
20
+ return data;
21
+ }
22
+ function _process() {
23
+ const data = require("process");
24
+ _process = function () {
25
+ return data;
26
+ };
27
+ return data;
28
+ }
29
+ function _url() {
30
+ const data = require("url");
31
+ _url = function () {
32
+ return data;
33
+ };
34
+ return data;
35
+ }
36
+ function _path() {
37
+ const data = require("path");
38
+ _path = function () {
39
+ return data;
40
+ };
41
+ return data;
42
+ }
43
+ function _module() {
44
+ const data = require("module");
45
+ _module = function () {
46
+ return data;
47
+ };
48
+ return data;
49
+ }
50
+ function _v() {
51
+ const data = require("v8");
52
+ _v = function () {
53
+ return data;
54
+ };
55
+ return data;
56
+ }
57
+ function _util() {
58
+ const data = require("util");
59
+ _util = function () {
60
+ return data;
61
+ };
62
+ return data;
63
+ }
64
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
65
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
66
+ const own$1 = {}.hasOwnProperty;
67
+ const classRegExp = /^([A-Z][a-z\d]*)+$/;
68
+ const kTypes = new Set(['string', 'function', 'number', 'object', 'Function', 'Object', 'boolean', 'bigint', 'symbol']);
69
+ const codes = {};
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
+ const messages = new Map();
74
+ const nodeInternalPrefix = '__node_internal_';
75
+ let userStackTraceLimit;
76
+ codes.ERR_INVALID_ARG_TYPE = createError('ERR_INVALID_ARG_TYPE', (name, expected, actual) => {
77
+ _assert()(typeof name === 'string', "'name' must be a string");
78
+ if (!Array.isArray(expected)) {
79
+ expected = [expected];
80
+ }
81
+ let message = 'The ';
82
+ if (name.endsWith(' argument')) {
83
+ message += `${name} `;
84
+ } else {
85
+ const type = name.includes('.') ? 'property' : 'argument';
86
+ message += `"${name}" ${type} `;
87
+ }
88
+ message += 'must be ';
89
+ const types = [];
90
+ const instances = [];
91
+ const other = [];
92
+ for (const value of expected) {
93
+ _assert()(typeof value === 'string', 'All expected entries have to be of type string');
94
+ if (kTypes.has(value)) {
95
+ types.push(value.toLowerCase());
96
+ } else if (classRegExp.exec(value) === null) {
97
+ _assert()(value !== 'object', 'The value "object" should be written as "Object"');
98
+ other.push(value);
99
+ } else {
100
+ instances.push(value);
101
+ }
102
+ }
103
+ if (instances.length > 0) {
104
+ const pos = types.indexOf('object');
105
+ if (pos !== -1) {
106
+ types.slice(pos, 1);
107
+ instances.push('Object');
108
+ }
109
+ }
110
+ if (types.length > 0) {
111
+ message += `${types.length > 1 ? 'one of type' : 'of type'} ${formatList(types, 'or')}`;
112
+ if (instances.length > 0 || other.length > 0) message += ' or ';
113
+ }
114
+ if (instances.length > 0) {
115
+ message += `an instance of ${formatList(instances, 'or')}`;
116
+ if (other.length > 0) message += ' or ';
117
+ }
118
+ if (other.length > 0) {
119
+ if (other.length > 1) {
120
+ message += `one of ${formatList(other, 'or')}`;
121
+ } else {
122
+ if (other[0].toLowerCase() !== other[0]) message += 'an ';
123
+ message += `${other[0]}`;
124
+ }
125
+ }
126
+ message += `. Received ${determineSpecificType(actual)}`;
127
+ return message;
128
+ }, TypeError);
129
+ codes.ERR_INVALID_MODULE_SPECIFIER = createError('ERR_INVALID_MODULE_SPECIFIER', (request, reason, base = undefined) => {
130
+ return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ''}`;
131
+ }, TypeError);
132
+ codes.ERR_INVALID_PACKAGE_CONFIG = createError('ERR_INVALID_PACKAGE_CONFIG', (path, base, message) => {
133
+ return `Invalid package config ${path}${base ? ` while importing ${base}` : ''}${message ? `. ${message}` : ''}`;
134
+ }, Error);
135
+ codes.ERR_INVALID_PACKAGE_TARGET = createError('ERR_INVALID_PACKAGE_TARGET', (packagePath, key, target, isImport = false, base = undefined) => {
136
+ const relatedError = typeof target === 'string' && !isImport && target.length > 0 && !target.startsWith('./');
137
+ if (key === '.') {
138
+ _assert()(isImport === false);
139
+ 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 "./"' : ''}`;
140
+ }
141
+ 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 "./"' : ''}`;
142
+ }, Error);
143
+ codes.ERR_MODULE_NOT_FOUND = createError('ERR_MODULE_NOT_FOUND', (path, base, exactUrl = false) => {
144
+ return `Cannot find ${exactUrl ? 'module' : 'package'} '${path}' imported from ${base}`;
145
+ }, Error);
146
+ codes.ERR_NETWORK_IMPORT_DISALLOWED = createError('ERR_NETWORK_IMPORT_DISALLOWED', "import of '%s' by %s is not supported: %s", Error);
147
+ codes.ERR_PACKAGE_IMPORT_NOT_DEFINED = createError('ERR_PACKAGE_IMPORT_NOT_DEFINED', (specifier, packagePath, base) => {
148
+ return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ''} imported from ${base}`;
149
+ }, TypeError);
150
+ codes.ERR_PACKAGE_PATH_NOT_EXPORTED = createError('ERR_PACKAGE_PATH_NOT_EXPORTED', (packagePath, subpath, base = undefined) => {
151
+ if (subpath === '.') return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ''}`;
152
+ return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ''}`;
153
+ }, Error);
154
+ codes.ERR_UNSUPPORTED_DIR_IMPORT = createError('ERR_UNSUPPORTED_DIR_IMPORT', "Directory import '%s' is not supported " + 'resolving ES modules imported from %s', Error);
155
+ 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);
156
+ codes.ERR_UNKNOWN_FILE_EXTENSION = createError('ERR_UNKNOWN_FILE_EXTENSION', (extension, path) => {
157
+ return `Unknown file extension "${extension}" for ${path}`;
158
+ }, TypeError);
159
+ codes.ERR_INVALID_ARG_VALUE = createError('ERR_INVALID_ARG_VALUE', (name, value, reason = 'is invalid') => {
160
+ let inspected = (0, _util().inspect)(value);
161
+ if (inspected.length > 128) {
162
+ inspected = `${inspected.slice(0, 128)}...`;
163
+ }
164
+ const type = name.includes('.') ? 'property' : 'argument';
165
+ return `The ${type} '${name}' ${reason}. Received ${inspected}`;
166
+ }, TypeError);
167
+ function createError(sym, value, constructor) {
168
+ messages.set(sym, value);
169
+ return makeNodeErrorWithCode(constructor, sym);
170
+ }
171
+ function makeNodeErrorWithCode(Base, key) {
172
+ return NodeError;
173
+ function NodeError(...parameters) {
174
+ const limit = Error.stackTraceLimit;
175
+ if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
176
+ const error = new Base();
177
+ if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
178
+ const message = getMessage(key, parameters, error);
179
+ Object.defineProperties(error, {
180
+ message: {
181
+ value: message,
182
+ enumerable: false,
183
+ writable: true,
184
+ configurable: true
185
+ },
186
+ toString: {
187
+ value() {
188
+ return `${this.name} [${key}]: ${this.message}`;
189
+ },
190
+ enumerable: false,
191
+ writable: true,
192
+ configurable: true
193
+ }
194
+ });
195
+ captureLargerStackTrace(error);
196
+ error.code = key;
197
+ return error;
198
+ }
199
+ }
200
+ function isErrorStackTraceLimitWritable() {
201
+ try {
202
+ if (_v().startupSnapshot.isBuildingSnapshot()) {
203
+ return false;
204
+ }
205
+ } catch (_unused) {}
206
+ const desc = Object.getOwnPropertyDescriptor(Error, 'stackTraceLimit');
207
+ if (desc === undefined) {
208
+ return Object.isExtensible(Error);
209
+ }
210
+ return own$1.call(desc, 'writable') && desc.writable !== undefined ? desc.writable : desc.set !== undefined;
211
+ }
212
+ function hideStackFrames(wrappedFunction) {
213
+ const hidden = nodeInternalPrefix + wrappedFunction.name;
214
+ Object.defineProperty(wrappedFunction, 'name', {
215
+ value: hidden
216
+ });
217
+ return wrappedFunction;
218
+ }
219
+ const captureLargerStackTrace = hideStackFrames(function (error) {
220
+ const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
221
+ if (stackTraceLimitIsWritable) {
222
+ userStackTraceLimit = Error.stackTraceLimit;
223
+ Error.stackTraceLimit = Number.POSITIVE_INFINITY;
224
+ }
225
+ Error.captureStackTrace(error);
226
+ if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
227
+ return error;
228
+ });
229
+ function getMessage(key, parameters, self) {
230
+ const message = messages.get(key);
231
+ _assert()(message !== undefined, 'expected `message` to be found');
232
+ if (typeof message === 'function') {
233
+ _assert()(message.length <= parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not ` + `match the required ones (${message.length}).`);
234
+ return Reflect.apply(message, self, parameters);
235
+ }
236
+ const regex = /%[dfijoOs]/g;
237
+ let expectedLength = 0;
238
+ while (regex.exec(message) !== null) expectedLength++;
239
+ _assert()(expectedLength === parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not ` + `match the required ones (${expectedLength}).`);
240
+ if (parameters.length === 0) return message;
241
+ parameters.unshift(message);
242
+ return Reflect.apply(_util().format, null, parameters);
243
+ }
244
+ function determineSpecificType(value) {
245
+ if (value === null || value === undefined) {
246
+ return String(value);
247
+ }
248
+ if (typeof value === 'function' && value.name) {
249
+ return `function ${value.name}`;
250
+ }
251
+ if (typeof value === 'object') {
252
+ if (value.constructor && value.constructor.name) {
253
+ return `an instance of ${value.constructor.name}`;
254
+ }
255
+ return `${(0, _util().inspect)(value, {
256
+ depth: -1
257
+ })}`;
258
+ }
259
+ let inspected = (0, _util().inspect)(value, {
260
+ colors: false
261
+ });
262
+ if (inspected.length > 28) {
263
+ inspected = `${inspected.slice(0, 25)}...`;
264
+ }
265
+ return `type ${typeof value} (${inspected})`;
266
+ }
267
+ const hasOwnProperty$1 = {}.hasOwnProperty;
268
+ const {
269
+ ERR_INVALID_PACKAGE_CONFIG: ERR_INVALID_PACKAGE_CONFIG$1
270
+ } = codes;
271
+ const cache = new Map();
272
+ function read(jsonPath, {
273
+ base,
274
+ specifier
275
+ }) {
276
+ const existing = cache.get(jsonPath);
277
+ if (existing) {
278
+ return existing;
279
+ }
280
+ let string;
281
+ try {
282
+ string = _fs().default.readFileSync(_path().toNamespacedPath(jsonPath), 'utf8');
283
+ } catch (error) {
284
+ const exception = error;
285
+ if (exception.code !== 'ENOENT') {
286
+ throw exception;
287
+ }
288
+ }
289
+ const result = {
290
+ exists: false,
291
+ pjsonPath: jsonPath,
292
+ main: undefined,
293
+ name: undefined,
294
+ type: 'none',
295
+ exports: undefined,
296
+ imports: undefined
297
+ };
298
+ if (string !== undefined) {
299
+ let parsed;
300
+ try {
301
+ parsed = JSON.parse(string);
302
+ } catch (error_) {
303
+ const cause = error_;
304
+ const error = new ERR_INVALID_PACKAGE_CONFIG$1(jsonPath, (base ? `"${specifier}" from ` : '') + (0, _url().fileURLToPath)(base || specifier), cause.message);
305
+ error.cause = cause;
306
+ throw error;
307
+ }
308
+ result.exists = true;
309
+ if (hasOwnProperty$1.call(parsed, 'name') && typeof parsed.name === 'string') {
310
+ result.name = parsed.name;
311
+ }
312
+ if (hasOwnProperty$1.call(parsed, 'main') && typeof parsed.main === 'string') {
313
+ result.main = parsed.main;
314
+ }
315
+ if (hasOwnProperty$1.call(parsed, 'exports')) {
316
+ result.exports = parsed.exports;
317
+ }
318
+ if (hasOwnProperty$1.call(parsed, 'imports')) {
319
+ result.imports = parsed.imports;
320
+ }
321
+ if (hasOwnProperty$1.call(parsed, 'type') && (parsed.type === 'commonjs' || parsed.type === 'module')) {
322
+ result.type = parsed.type;
323
+ }
324
+ }
325
+ cache.set(jsonPath, result);
326
+ return result;
327
+ }
328
+ function getPackageScopeConfig(resolved) {
329
+ let packageJSONUrl = new URL('package.json', resolved);
330
+ while (true) {
331
+ const packageJSONPath = packageJSONUrl.pathname;
332
+ if (packageJSONPath.endsWith('node_modules/package.json')) {
333
+ break;
334
+ }
335
+ const packageConfig = read((0, _url().fileURLToPath)(packageJSONUrl), {
336
+ specifier: resolved
337
+ });
338
+ if (packageConfig.exists) {
339
+ return packageConfig;
340
+ }
341
+ const lastPackageJSONUrl = packageJSONUrl;
342
+ packageJSONUrl = new URL('../package.json', packageJSONUrl);
343
+ if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) {
344
+ break;
345
+ }
346
+ }
347
+ const packageJSONPath = (0, _url().fileURLToPath)(packageJSONUrl);
348
+ return {
349
+ pjsonPath: packageJSONPath,
350
+ exists: false,
351
+ type: 'none'
352
+ };
353
+ }
354
+ function getPackageType(url) {
355
+ return getPackageScopeConfig(url).type;
356
+ }
357
+ const {
358
+ ERR_UNKNOWN_FILE_EXTENSION
359
+ } = codes;
360
+ const hasOwnProperty = {}.hasOwnProperty;
361
+ const extensionFormatMap = {
362
+ __proto__: null,
363
+ '.cjs': 'commonjs',
364
+ '.js': 'module',
365
+ '.json': 'json',
366
+ '.mjs': 'module'
367
+ };
368
+ function mimeToFormat(mime) {
369
+ if (mime && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime)) return 'module';
370
+ if (mime === 'application/json') return 'json';
371
+ return null;
372
+ }
373
+ const protocolHandlers = {
374
+ __proto__: null,
375
+ 'data:': getDataProtocolModuleFormat,
376
+ 'file:': getFileProtocolModuleFormat,
377
+ 'http:': getHttpProtocolModuleFormat,
378
+ 'https:': getHttpProtocolModuleFormat,
379
+ 'node:'() {
380
+ return 'builtin';
381
+ }
382
+ };
383
+ function getDataProtocolModuleFormat(parsed) {
384
+ const {
385
+ 1: mime
386
+ } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(parsed.pathname) || [null, null, null];
387
+ return mimeToFormat(mime);
388
+ }
389
+ function extname(url) {
390
+ const pathname = url.pathname;
391
+ let index = pathname.length;
392
+ while (index--) {
393
+ const code = pathname.codePointAt(index);
394
+ if (code === 47) {
395
+ return '';
396
+ }
397
+ if (code === 46) {
398
+ return pathname.codePointAt(index - 1) === 47 ? '' : pathname.slice(index);
399
+ }
400
+ }
401
+ return '';
402
+ }
403
+ function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
404
+ const value = extname(url);
405
+ if (value === '.js') {
406
+ const packageType = getPackageType(url);
407
+ if (packageType !== 'none') {
408
+ return packageType;
409
+ }
410
+ return 'commonjs';
411
+ }
412
+ if (value === '') {
413
+ const packageType = getPackageType(url);
414
+ if (packageType === 'none' || packageType === 'commonjs') {
415
+ return 'commonjs';
416
+ }
417
+ return 'module';
418
+ }
419
+ const format = extensionFormatMap[value];
420
+ if (format) return format;
421
+ if (ignoreErrors) {
422
+ return undefined;
423
+ }
424
+ const filepath = (0, _url().fileURLToPath)(url);
425
+ throw new ERR_UNKNOWN_FILE_EXTENSION(value, filepath);
426
+ }
427
+ function getHttpProtocolModuleFormat() {}
428
+ function defaultGetFormatWithoutErrors(url, context) {
429
+ const protocol = url.protocol;
430
+ if (!hasOwnProperty.call(protocolHandlers, protocol)) {
431
+ return null;
432
+ }
433
+ return protocolHandlers[protocol](url, context, true) || null;
434
+ }
435
+ const {
436
+ ERR_INVALID_ARG_VALUE
437
+ } = codes;
438
+ const DEFAULT_CONDITIONS = Object.freeze(['node', 'import']);
439
+ const DEFAULT_CONDITIONS_SET = new Set(DEFAULT_CONDITIONS);
440
+ function getDefaultConditions() {
441
+ return DEFAULT_CONDITIONS;
442
+ }
443
+ function getDefaultConditionsSet() {
444
+ return DEFAULT_CONDITIONS_SET;
445
+ }
446
+ function getConditionsSet(conditions) {
447
+ if (conditions !== undefined && conditions !== getDefaultConditions()) {
448
+ if (!Array.isArray(conditions)) {
449
+ throw new ERR_INVALID_ARG_VALUE('conditions', conditions, 'expected an array');
450
+ }
451
+ return new Set(conditions);
452
+ }
453
+ return getDefaultConditionsSet();
454
+ }
455
+ const RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
456
+ const {
457
+ ERR_NETWORK_IMPORT_DISALLOWED,
458
+ ERR_INVALID_MODULE_SPECIFIER,
459
+ ERR_INVALID_PACKAGE_CONFIG,
460
+ ERR_INVALID_PACKAGE_TARGET,
461
+ ERR_MODULE_NOT_FOUND,
462
+ ERR_PACKAGE_IMPORT_NOT_DEFINED,
463
+ ERR_PACKAGE_PATH_NOT_EXPORTED,
464
+ ERR_UNSUPPORTED_DIR_IMPORT,
465
+ ERR_UNSUPPORTED_RESOLVE_REQUEST
466
+ } = codes;
467
+ const own = {}.hasOwnProperty;
468
+ 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;
469
+ 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;
470
+ const invalidPackageNameRegEx = /^\.|%|\\/;
471
+ const patternRegEx = /\*/g;
472
+ const encodedSeparatorRegEx = /%2f|%5c/i;
473
+ const emittedPackageWarnings = new Set();
474
+ const doubleSlashRegEx = /[/\\]{2}/;
475
+ function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, internal, base, isTarget) {
476
+ if (_process().noDeprecation) {
477
+ return;
478
+ }
479
+ const pjsonPath = (0, _url().fileURLToPath)(packageJsonUrl);
480
+ const double = doubleSlashRegEx.exec(isTarget ? target : request) !== null;
481
+ _process().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, _url().fileURLToPath)(base)}` : ''}.`, 'DeprecationWarning', 'DEP0166');
482
+ }
483
+ function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
484
+ if (_process().noDeprecation) {
485
+ return;
486
+ }
487
+ const format = defaultGetFormatWithoutErrors(url, {
488
+ parentURL: base.href
489
+ });
490
+ if (format !== 'module') return;
491
+ const urlPath = (0, _url().fileURLToPath)(url.href);
492
+ const packagePath = (0, _url().fileURLToPath)(new (_url().URL)('.', packageJsonUrl));
493
+ const basePath = (0, _url().fileURLToPath)(base);
494
+ if (!main) {
495
+ _process().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');
496
+ } else if (_path().resolve(packagePath, main) !== urlPath) {
497
+ _process().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');
498
+ }
499
+ }
500
+ function tryStatSync(path) {
501
+ try {
502
+ return (0, _fs().statSync)(path);
503
+ } catch (_unused2) {}
504
+ }
505
+ function fileExists(url) {
506
+ const stats = (0, _fs().statSync)(url, {
507
+ throwIfNoEntry: false
508
+ });
509
+ const isFile = stats ? stats.isFile() : undefined;
510
+ return isFile === null || isFile === undefined ? false : isFile;
511
+ }
512
+ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
513
+ let guess;
514
+ if (packageConfig.main !== undefined) {
515
+ guess = new (_url().URL)(packageConfig.main, packageJsonUrl);
516
+ if (fileExists(guess)) return guess;
517
+ const tries = [`./${packageConfig.main}.js`, `./${packageConfig.main}.json`, `./${packageConfig.main}.node`, `./${packageConfig.main}/index.js`, `./${packageConfig.main}/index.json`, `./${packageConfig.main}/index.node`];
518
+ let i = -1;
519
+ while (++i < tries.length) {
520
+ guess = new (_url().URL)(tries[i], packageJsonUrl);
521
+ if (fileExists(guess)) break;
522
+ guess = undefined;
523
+ }
524
+ if (guess) {
525
+ emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
526
+ return guess;
527
+ }
528
+ }
529
+ const tries = ['./index.js', './index.json', './index.node'];
530
+ let i = -1;
531
+ while (++i < tries.length) {
532
+ guess = new (_url().URL)(tries[i], packageJsonUrl);
533
+ if (fileExists(guess)) break;
534
+ guess = undefined;
535
+ }
536
+ if (guess) {
537
+ emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
538
+ return guess;
539
+ }
540
+ throw new ERR_MODULE_NOT_FOUND((0, _url().fileURLToPath)(new (_url().URL)('.', packageJsonUrl)), (0, _url().fileURLToPath)(base));
541
+ }
542
+ function finalizeResolution(resolved, base, preserveSymlinks) {
543
+ if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) {
544
+ throw new ERR_INVALID_MODULE_SPECIFIER(resolved.pathname, 'must not include encoded "/" or "\\" characters', (0, _url().fileURLToPath)(base));
545
+ }
546
+ let filePath;
547
+ try {
548
+ filePath = (0, _url().fileURLToPath)(resolved);
549
+ } catch (error) {
550
+ const cause = error;
551
+ Object.defineProperty(cause, 'input', {
552
+ value: String(resolved)
553
+ });
554
+ Object.defineProperty(cause, 'module', {
555
+ value: String(base)
556
+ });
557
+ throw cause;
558
+ }
559
+ const stats = tryStatSync(filePath.endsWith('/') ? filePath.slice(-1) : filePath);
560
+ if (stats && stats.isDirectory()) {
561
+ const error = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, (0, _url().fileURLToPath)(base));
562
+ error.url = String(resolved);
563
+ throw error;
564
+ }
565
+ if (!stats || !stats.isFile()) {
566
+ const error = new ERR_MODULE_NOT_FOUND(filePath || resolved.pathname, base && (0, _url().fileURLToPath)(base), true);
567
+ error.url = String(resolved);
568
+ throw error;
569
+ }
570
+ if (!preserveSymlinks) {
571
+ const real = (0, _fs().realpathSync)(filePath);
572
+ const {
573
+ search,
574
+ hash
575
+ } = resolved;
576
+ resolved = (0, _url().pathToFileURL)(real + (filePath.endsWith(_path().sep) ? '/' : ''));
577
+ resolved.search = search;
578
+ resolved.hash = hash;
579
+ }
580
+ return resolved;
581
+ }
582
+ function importNotDefined(specifier, packageJsonUrl, base) {
583
+ return new ERR_PACKAGE_IMPORT_NOT_DEFINED(specifier, packageJsonUrl && (0, _url().fileURLToPath)(new (_url().URL)('.', packageJsonUrl)), (0, _url().fileURLToPath)(base));
584
+ }
585
+ function exportsNotFound(subpath, packageJsonUrl, base) {
586
+ return new ERR_PACKAGE_PATH_NOT_EXPORTED((0, _url().fileURLToPath)(new (_url().URL)('.', packageJsonUrl)), subpath, base && (0, _url().fileURLToPath)(base));
587
+ }
588
+ function throwInvalidSubpath(request, match, packageJsonUrl, internal, base) {
589
+ const reason = `request is not a valid match in pattern "${match}" for the "${internal ? 'imports' : 'exports'}" resolution of ${(0, _url().fileURLToPath)(packageJsonUrl)}`;
590
+ throw new ERR_INVALID_MODULE_SPECIFIER(request, reason, base && (0, _url().fileURLToPath)(base));
591
+ }
592
+ function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
593
+ target = typeof target === 'object' && target !== null ? JSON.stringify(target, null, '') : `${target}`;
594
+ return new ERR_INVALID_PACKAGE_TARGET((0, _url().fileURLToPath)(new (_url().URL)('.', packageJsonUrl)), subpath, target, internal, base && (0, _url().fileURLToPath)(base));
595
+ }
596
+ function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base, pattern, internal, isPathMap, conditions) {
597
+ if (subpath !== '' && !pattern && target[target.length - 1] !== '/') throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
598
+ if (!target.startsWith('./')) {
599
+ if (internal && !target.startsWith('../') && !target.startsWith('/')) {
600
+ let isURL = false;
601
+ try {
602
+ new (_url().URL)(target);
603
+ isURL = true;
604
+ } catch (_unused3) {}
605
+ if (!isURL) {
606
+ const exportTarget = pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target + subpath;
607
+ return packageResolve(exportTarget, packageJsonUrl, conditions);
608
+ }
609
+ }
610
+ throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
611
+ }
612
+ if (invalidSegmentRegEx.exec(target.slice(2)) !== null) {
613
+ if (deprecatedInvalidSegmentRegEx.exec(target.slice(2)) === null) {
614
+ if (!isPathMap) {
615
+ const request = pattern ? match.replace('*', () => subpath) : match + subpath;
616
+ const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target;
617
+ emitInvalidSegmentDeprecation(resolvedTarget, request, match, packageJsonUrl, internal, base, true);
618
+ }
619
+ } else {
620
+ throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
621
+ }
622
+ }
623
+ const resolved = new (_url().URL)(target, packageJsonUrl);
624
+ const resolvedPath = resolved.pathname;
625
+ const packagePath = new (_url().URL)('.', packageJsonUrl).pathname;
626
+ if (!resolvedPath.startsWith(packagePath)) throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
627
+ if (subpath === '') return resolved;
628
+ if (invalidSegmentRegEx.exec(subpath) !== null) {
629
+ const request = pattern ? match.replace('*', () => subpath) : match + subpath;
630
+ if (deprecatedInvalidSegmentRegEx.exec(subpath) === null) {
631
+ if (!isPathMap) {
632
+ const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target;
633
+ emitInvalidSegmentDeprecation(resolvedTarget, request, match, packageJsonUrl, internal, base, false);
634
+ }
635
+ } else {
636
+ throwInvalidSubpath(request, match, packageJsonUrl, internal, base);
637
+ }
638
+ }
639
+ if (pattern) {
640
+ return new (_url().URL)(RegExpPrototypeSymbolReplace.call(patternRegEx, resolved.href, () => subpath));
641
+ }
642
+ return new (_url().URL)(subpath, resolved);
643
+ }
644
+ function isArrayIndex(key) {
645
+ const keyNumber = Number(key);
646
+ if (`${keyNumber}` !== key) return false;
647
+ return keyNumber >= 0 && keyNumber < 0xffffffff;
648
+ }
649
+ function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions) {
650
+ if (typeof target === 'string') {
651
+ return resolvePackageTargetString(target, subpath, packageSubpath, packageJsonUrl, base, pattern, internal, isPathMap, conditions);
652
+ }
653
+ if (Array.isArray(target)) {
654
+ const targetList = target;
655
+ if (targetList.length === 0) return null;
656
+ let lastException;
657
+ let i = -1;
658
+ while (++i < targetList.length) {
659
+ const targetItem = targetList[i];
660
+ let resolveResult;
661
+ try {
662
+ resolveResult = resolvePackageTarget(packageJsonUrl, targetItem, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
663
+ } catch (error) {
664
+ const exception = error;
665
+ lastException = exception;
666
+ if (exception.code === 'ERR_INVALID_PACKAGE_TARGET') continue;
667
+ throw error;
668
+ }
669
+ if (resolveResult === undefined) continue;
670
+ if (resolveResult === null) {
671
+ lastException = null;
672
+ continue;
673
+ }
674
+ return resolveResult;
675
+ }
676
+ if (lastException === undefined || lastException === null) {
677
+ return null;
678
+ }
679
+ throw lastException;
680
+ }
681
+ if (typeof target === 'object' && target !== null) {
682
+ const keys = Object.getOwnPropertyNames(target);
683
+ let i = -1;
684
+ while (++i < keys.length) {
685
+ const key = keys[i];
686
+ if (isArrayIndex(key)) {
687
+ throw new ERR_INVALID_PACKAGE_CONFIG((0, _url().fileURLToPath)(packageJsonUrl), base, '"exports" cannot contain numeric property keys.');
688
+ }
689
+ }
690
+ i = -1;
691
+ while (++i < keys.length) {
692
+ const key = keys[i];
693
+ if (key === 'default' || conditions && conditions.has(key)) {
694
+ const conditionalTarget = target[key];
695
+ const resolveResult = resolvePackageTarget(packageJsonUrl, conditionalTarget, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
696
+ if (resolveResult === undefined) continue;
697
+ return resolveResult;
698
+ }
699
+ }
700
+ return null;
701
+ }
702
+ if (target === null) {
703
+ return null;
704
+ }
705
+ throw invalidPackageTarget(packageSubpath, target, packageJsonUrl, internal, base);
706
+ }
707
+ function isConditionalExportsMainSugar(exports, packageJsonUrl, base) {
708
+ if (typeof exports === 'string' || Array.isArray(exports)) return true;
709
+ if (typeof exports !== 'object' || exports === null) return false;
710
+ const keys = Object.getOwnPropertyNames(exports);
711
+ let isConditionalSugar = false;
712
+ let i = 0;
713
+ let keyIndex = -1;
714
+ while (++keyIndex < keys.length) {
715
+ const key = keys[keyIndex];
716
+ const currentIsConditionalSugar = key === '' || key[0] !== '.';
717
+ if (i++ === 0) {
718
+ isConditionalSugar = currentIsConditionalSugar;
719
+ } else if (isConditionalSugar !== currentIsConditionalSugar) {
720
+ throw new ERR_INVALID_PACKAGE_CONFIG((0, _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.');
721
+ }
722
+ }
723
+ return isConditionalSugar;
724
+ }
725
+ function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
726
+ if (_process().noDeprecation) {
727
+ return;
728
+ }
729
+ const pjsonPath = (0, _url().fileURLToPath)(pjsonUrl);
730
+ if (emittedPackageWarnings.has(pjsonPath + '|' + match)) return;
731
+ emittedPackageWarnings.add(pjsonPath + '|' + match);
732
+ _process().emitWarning(`Use of deprecated trailing slash pattern mapping "${match}" in the ` + `"exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${(0, _url().fileURLToPath)(base)}` : ''}. Mapping specifiers ending in "/" is no longer supported.`, 'DeprecationWarning', 'DEP0155');
733
+ }
734
+ function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions) {
735
+ let exports = packageConfig.exports;
736
+ if (isConditionalExportsMainSugar(exports, packageJsonUrl, base)) {
737
+ exports = {
738
+ '.': exports
739
+ };
740
+ }
741
+ if (own.call(exports, packageSubpath) && !packageSubpath.includes('*') && !packageSubpath.endsWith('/')) {
742
+ const target = exports[packageSubpath];
743
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, '', packageSubpath, base, false, false, false, conditions);
744
+ if (resolveResult === null || resolveResult === undefined) {
745
+ throw exportsNotFound(packageSubpath, packageJsonUrl, base);
746
+ }
747
+ return resolveResult;
748
+ }
749
+ let bestMatch = '';
750
+ let bestMatchSubpath = '';
751
+ const keys = Object.getOwnPropertyNames(exports);
752
+ let i = -1;
753
+ while (++i < keys.length) {
754
+ const key = keys[i];
755
+ const patternIndex = key.indexOf('*');
756
+ if (patternIndex !== -1 && packageSubpath.startsWith(key.slice(0, patternIndex))) {
757
+ if (packageSubpath.endsWith('/')) {
758
+ emitTrailingSlashPatternDeprecation(packageSubpath, packageJsonUrl, base);
759
+ }
760
+ const patternTrailer = key.slice(patternIndex + 1);
761
+ if (packageSubpath.length >= key.length && packageSubpath.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf('*') === patternIndex) {
762
+ bestMatch = key;
763
+ bestMatchSubpath = packageSubpath.slice(patternIndex, packageSubpath.length - patternTrailer.length);
764
+ }
765
+ }
766
+ }
767
+ if (bestMatch) {
768
+ const target = exports[bestMatch];
769
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, false, packageSubpath.endsWith('/'), conditions);
770
+ if (resolveResult === null || resolveResult === undefined) {
771
+ throw exportsNotFound(packageSubpath, packageJsonUrl, base);
772
+ }
773
+ return resolveResult;
774
+ }
775
+ throw exportsNotFound(packageSubpath, packageJsonUrl, base);
776
+ }
777
+ function patternKeyCompare(a, b) {
778
+ const aPatternIndex = a.indexOf('*');
779
+ const bPatternIndex = b.indexOf('*');
780
+ const baseLengthA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
781
+ const baseLengthB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
782
+ if (baseLengthA > baseLengthB) return -1;
783
+ if (baseLengthB > baseLengthA) return 1;
784
+ if (aPatternIndex === -1) return 1;
785
+ if (bPatternIndex === -1) return -1;
786
+ if (a.length > b.length) return -1;
787
+ if (b.length > a.length) return 1;
788
+ return 0;
789
+ }
790
+ function packageImportsResolve(name, base, conditions) {
791
+ if (name === '#' || name.startsWith('#/') || name.endsWith('/')) {
792
+ const reason = 'is not a valid internal imports specifier name';
793
+ throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, (0, _url().fileURLToPath)(base));
794
+ }
795
+ let packageJsonUrl;
796
+ const packageConfig = getPackageScopeConfig(base);
797
+ if (packageConfig.exists) {
798
+ packageJsonUrl = (0, _url().pathToFileURL)(packageConfig.pjsonPath);
799
+ const imports = packageConfig.imports;
800
+ if (imports) {
801
+ if (own.call(imports, name) && !name.includes('*')) {
802
+ const resolveResult = resolvePackageTarget(packageJsonUrl, imports[name], '', name, base, false, true, false, conditions);
803
+ if (resolveResult !== null && resolveResult !== undefined) {
804
+ return resolveResult;
805
+ }
806
+ } else {
807
+ let bestMatch = '';
808
+ let bestMatchSubpath = '';
809
+ const keys = Object.getOwnPropertyNames(imports);
810
+ let i = -1;
811
+ while (++i < keys.length) {
812
+ const key = keys[i];
813
+ const patternIndex = key.indexOf('*');
814
+ if (patternIndex !== -1 && name.startsWith(key.slice(0, -1))) {
815
+ const patternTrailer = key.slice(patternIndex + 1);
816
+ if (name.length >= key.length && name.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf('*') === patternIndex) {
817
+ bestMatch = key;
818
+ bestMatchSubpath = name.slice(patternIndex, name.length - patternTrailer.length);
819
+ }
820
+ }
821
+ }
822
+ if (bestMatch) {
823
+ const target = imports[bestMatch];
824
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, true, false, conditions);
825
+ if (resolveResult !== null && resolveResult !== undefined) {
826
+ return resolveResult;
827
+ }
828
+ }
829
+ }
830
+ }
831
+ }
832
+ throw importNotDefined(name, packageJsonUrl, base);
833
+ }
834
+ function parsePackageName(specifier, base) {
835
+ let separatorIndex = specifier.indexOf('/');
836
+ let validPackageName = true;
837
+ let isScoped = false;
838
+ if (specifier[0] === '@') {
839
+ isScoped = true;
840
+ if (separatorIndex === -1 || specifier.length === 0) {
841
+ validPackageName = false;
842
+ } else {
843
+ separatorIndex = specifier.indexOf('/', separatorIndex + 1);
844
+ }
845
+ }
846
+ const packageName = separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
847
+ if (invalidPackageNameRegEx.exec(packageName) !== null) {
848
+ validPackageName = false;
849
+ }
850
+ if (!validPackageName) {
851
+ throw new ERR_INVALID_MODULE_SPECIFIER(specifier, 'is not a valid package name', (0, _url().fileURLToPath)(base));
852
+ }
853
+ const packageSubpath = '.' + (separatorIndex === -1 ? '' : specifier.slice(separatorIndex));
854
+ return {
855
+ packageName,
856
+ packageSubpath,
857
+ isScoped
858
+ };
859
+ }
860
+ function packageResolve(specifier, base, conditions) {
861
+ if (_module().builtinModules.includes(specifier)) {
862
+ return new (_url().URL)('node:' + specifier);
863
+ }
864
+ const {
865
+ packageName,
866
+ packageSubpath,
867
+ isScoped
868
+ } = parsePackageName(specifier, base);
869
+ const packageConfig = getPackageScopeConfig(base);
870
+ if (packageConfig.exists) {
871
+ const packageJsonUrl = (0, _url().pathToFileURL)(packageConfig.pjsonPath);
872
+ if (packageConfig.name === packageName && packageConfig.exports !== undefined && packageConfig.exports !== null) {
873
+ return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions);
874
+ }
875
+ }
876
+ let packageJsonUrl = new (_url().URL)('./node_modules/' + packageName + '/package.json', base);
877
+ let packageJsonPath = (0, _url().fileURLToPath)(packageJsonUrl);
878
+ let lastPath;
879
+ do {
880
+ const stat = tryStatSync(packageJsonPath.slice(0, -13));
881
+ if (!stat || !stat.isDirectory()) {
882
+ lastPath = packageJsonPath;
883
+ packageJsonUrl = new (_url().URL)((isScoped ? '../../../../node_modules/' : '../../../node_modules/') + packageName + '/package.json', packageJsonUrl);
884
+ packageJsonPath = (0, _url().fileURLToPath)(packageJsonUrl);
885
+ continue;
886
+ }
887
+ const packageConfig = read(packageJsonPath, {
888
+ base,
889
+ specifier
890
+ });
891
+ if (packageConfig.exports !== undefined && packageConfig.exports !== null) {
892
+ return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions);
893
+ }
894
+ if (packageSubpath === '.') {
895
+ return legacyMainResolve(packageJsonUrl, packageConfig, base);
896
+ }
897
+ return new (_url().URL)(packageSubpath, packageJsonUrl);
898
+ } while (packageJsonPath.length !== lastPath.length);
899
+ throw new ERR_MODULE_NOT_FOUND(packageName, (0, _url().fileURLToPath)(base), false);
900
+ }
901
+ function isRelativeSpecifier(specifier) {
902
+ if (specifier[0] === '.') {
903
+ if (specifier.length === 1 || specifier[1] === '/') return true;
904
+ if (specifier[1] === '.' && (specifier.length === 2 || specifier[2] === '/')) {
905
+ return true;
906
+ }
907
+ }
908
+ return false;
909
+ }
910
+ function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) {
911
+ if (specifier === '') return false;
912
+ if (specifier[0] === '/') return true;
913
+ return isRelativeSpecifier(specifier);
914
+ }
915
+ function moduleResolve(specifier, base, conditions, preserveSymlinks) {
916
+ const protocol = base.protocol;
917
+ const isData = protocol === 'data:';
918
+ const isRemote = isData || protocol === 'http:' || protocol === 'https:';
919
+ let resolved;
920
+ if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) {
921
+ try {
922
+ resolved = new (_url().URL)(specifier, base);
923
+ } catch (error_) {
924
+ const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
925
+ error.cause = error_;
926
+ throw error;
927
+ }
928
+ } else if (protocol === 'file:' && specifier[0] === '#') {
929
+ resolved = packageImportsResolve(specifier, base, conditions);
930
+ } else {
931
+ try {
932
+ resolved = new (_url().URL)(specifier);
933
+ } catch (error_) {
934
+ if (isRemote && !_module().builtinModules.includes(specifier)) {
935
+ const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
936
+ error.cause = error_;
937
+ throw error;
938
+ }
939
+ resolved = packageResolve(specifier, base, conditions);
940
+ }
941
+ }
942
+ _assert()(resolved !== undefined, 'expected to be defined');
943
+ if (resolved.protocol !== 'file:') {
944
+ return resolved;
945
+ }
946
+ return finalizeResolution(resolved, base, preserveSymlinks);
947
+ }
948
+ function checkIfDisallowedImport(specifier, parsed, parsedParentURL) {
949
+ if (parsedParentURL) {
950
+ const parentProtocol = parsedParentURL.protocol;
951
+ if (parentProtocol === 'http:' || parentProtocol === 'https:') {
952
+ if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) {
953
+ const parsedProtocol = parsed == null ? void 0 : parsed.protocol;
954
+ if (parsedProtocol && parsedProtocol !== 'https:' && parsedProtocol !== 'http:') {
955
+ throw new ERR_NETWORK_IMPORT_DISALLOWED(specifier, parsedParentURL, 'remote imports cannot import from a local location.');
956
+ }
957
+ return {
958
+ url: (parsed == null ? void 0 : parsed.href) || ''
959
+ };
960
+ }
961
+ if (_module().builtinModules.includes(specifier)) {
962
+ throw new ERR_NETWORK_IMPORT_DISALLOWED(specifier, parsedParentURL, 'remote imports cannot import from a local location.');
963
+ }
964
+ throw new ERR_NETWORK_IMPORT_DISALLOWED(specifier, parsedParentURL, 'only relative and absolute specifiers are supported.');
965
+ }
966
+ }
967
+ }
968
+ function isURL(self) {
969
+ return Boolean(self && typeof self === 'object' && 'href' in self && typeof self.href === 'string' && 'protocol' in self && typeof self.protocol === 'string' && self.href && self.protocol);
970
+ }
971
+ function throwIfInvalidParentURL(parentURL) {
972
+ if (parentURL === undefined) {
973
+ return;
974
+ }
975
+ if (typeof parentURL !== 'string' && !isURL(parentURL)) {
976
+ throw new codes.ERR_INVALID_ARG_TYPE('parentURL', ['string', 'URL'], parentURL);
977
+ }
978
+ }
979
+ function defaultResolve(specifier, context = {}) {
980
+ const {
981
+ parentURL
982
+ } = context;
983
+ _assert()(parentURL !== undefined, 'expected `parentURL` to be defined');
984
+ throwIfInvalidParentURL(parentURL);
985
+ let parsedParentURL;
986
+ if (parentURL) {
987
+ try {
988
+ parsedParentURL = new (_url().URL)(parentURL);
989
+ } catch (_unused4) {}
990
+ }
991
+ let parsed;
992
+ let protocol;
993
+ try {
994
+ parsed = shouldBeTreatedAsRelativeOrAbsolutePath(specifier) ? new (_url().URL)(specifier, parsedParentURL) : new (_url().URL)(specifier);
995
+ protocol = parsed.protocol;
996
+ if (protocol === 'data:') {
997
+ return {
998
+ url: parsed.href,
999
+ format: null
1000
+ };
1001
+ }
1002
+ } catch (_unused5) {}
1003
+ const maybeReturn = checkIfDisallowedImport(specifier, parsed, parsedParentURL);
1004
+ if (maybeReturn) return maybeReturn;
1005
+ if (protocol === undefined && parsed) {
1006
+ protocol = parsed.protocol;
1007
+ }
1008
+ if (protocol === 'node:') {
1009
+ return {
1010
+ url: specifier
1011
+ };
1012
+ }
1013
+ if (parsed && parsed.protocol === 'node:') return {
1014
+ url: specifier
1015
+ };
1016
+ const conditions = getConditionsSet(context.conditions);
1017
+ const url = moduleResolve(specifier, new (_url().URL)(parentURL), conditions, false);
1018
+ return {
1019
+ url: url.href,
1020
+ format: defaultGetFormatWithoutErrors(url, {
1021
+ parentURL
1022
+ })
1023
+ };
1024
+ }
1025
+ function resolve(specifier, parent) {
1026
+ if (!parent) {
1027
+ throw new Error('Please pass `parent`: `import-meta-resolve` cannot ponyfill that');
1028
+ }
1029
+ try {
1030
+ return defaultResolve(specifier, {
1031
+ parentURL: parent
1032
+ }).url;
1033
+ } catch (error) {
1034
+ const exception = error;
1035
+ if ((exception.code === 'ERR_UNSUPPORTED_DIR_IMPORT' || exception.code === 'ERR_MODULE_NOT_FOUND') && typeof exception.url === 'string') {
1036
+ return exception.url;
1037
+ }
1038
+ throw error;
1039
+ }
1040
+ }
1041
+ 0 && 0;
1042
+
1043
+ //# sourceMappingURL=import-meta-resolve.js.map