nitro-nightly 3.0.1-20260120-020848-6786d069 → 3.0.1-20260120-133205-cbfce96c

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 (92) hide show
  1. package/dist/_build/common.mjs +24931 -0
  2. package/dist/_build/rolldown.mjs +6 -11
  3. package/dist/_build/rollup.mjs +201 -0
  4. package/dist/_build/vite.build.mjs +1 -1
  5. package/dist/_chunks/dev.mjs +4 -6
  6. package/dist/_chunks/nitro.mjs +1183 -24
  7. package/dist/_chunks/nitro2.mjs +91 -248
  8. package/dist/_chunks/utils.mjs +254 -0
  9. package/dist/_common.mjs +45 -0
  10. package/dist/_libs/@hiogawa/vite-plugin-fullstack.mjs +652 -0
  11. package/dist/_libs/@jridgewell/gen-mapping.mjs +448 -0
  12. package/dist/_libs/@jridgewell/remapping.mjs +117 -0
  13. package/dist/_libs/@rollup/plugin-alias.mjs +64 -0
  14. package/dist/_libs/@rollup/plugin-commonjs.d.mts +241 -0
  15. package/dist/_libs/@rollup/plugin-commonjs.mjs +1300 -0
  16. package/dist/_libs/{plugin-alias+plugin-inject.mjs → @rollup/plugin-inject.mjs} +2 -65
  17. package/dist/_libs/@rollup/plugin-json.mjs +36 -0
  18. package/dist/_libs/@rollup/plugin-node-resolve.mjs +1972 -0
  19. package/dist/_libs/c12.d.mts +214 -0
  20. package/dist/_libs/{c12+dotenv+rc9.mjs → c12.mjs} +105 -12
  21. package/dist/_libs/{chokidar+readdirp.mjs → chokidar.mjs} +8 -1
  22. package/dist/_libs/compatx.d.mts +47 -0
  23. package/dist/_libs/confbox.mjs +2488 -70
  24. package/dist/_libs/esbuild.d.mts +20 -0
  25. package/dist/_libs/escape-string-regexp.mjs +8 -0
  26. package/dist/_libs/estree-walker.mjs +187 -0
  27. package/dist/_libs/giget.mjs +3550 -0
  28. package/dist/_libs/httpxy.d.mts +79 -0
  29. package/dist/_libs/httpxy.mjs +6 -1
  30. package/dist/_libs/klona.mjs +38 -0
  31. package/dist/_libs/magic-string.d.mts +220 -0
  32. package/dist/_libs/mlly.d.mts +57 -0
  33. package/dist/_libs/pkg-types.d.mts +23 -0
  34. package/dist/_libs/rou3.d.mts +43 -0
  35. package/dist/_libs/rou3.mjs +322 -0
  36. package/dist/_libs/std-env.d.mts +4 -0
  37. package/dist/_libs/tsconfck.mjs +832 -0
  38. package/dist/_libs/ultrahtml.mjs +138 -0
  39. package/dist/_libs/unimport.d.mts +426 -0
  40. package/dist/_libs/unimport.mjs +1781 -5
  41. package/dist/_libs/unwasm.d.mts +29 -0
  42. package/dist/_presets.mjs +3 -8
  43. package/dist/builder.mjs +6 -8
  44. package/dist/cli/_chunks/build.mjs +1 -1
  45. package/dist/cli/_chunks/dev.mjs +2 -3
  46. package/dist/cli/_chunks/list.mjs +1 -1
  47. package/dist/cli/_chunks/prepare.mjs +1 -1
  48. package/dist/cli/_chunks/run.mjs +1 -1
  49. package/dist/cli/_chunks/task.mjs +16 -0
  50. package/dist/cli/index.mjs +1 -1
  51. package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -5
  52. package/dist/presets/netlify/runtime/netlify-edge.d.mts +0 -1
  53. package/dist/presets/winterjs/runtime/winterjs.d.mts +0 -1
  54. package/dist/runtime/internal/error/dev.d.mts +0 -1
  55. package/dist/runtime/internal/route-rules.d.mts +0 -4
  56. package/dist/runtime/internal/routes/openapi.d.mts +0 -1
  57. package/dist/runtime/internal/routes/scalar.d.mts +0 -1
  58. package/dist/runtime/internal/routes/swagger.d.mts +0 -1
  59. package/dist/runtime/internal/runtime-config.d.mts +0 -1
  60. package/dist/runtime/nitro.d.mts +0 -3
  61. package/dist/runtime/virtual/renderer-template.d.mts +0 -1
  62. package/dist/types/index.d.mts +36 -1405
  63. package/dist/vite.mjs +18 -641
  64. package/package.json +2 -2
  65. package/dist/_chunks/nitro3.mjs +0 -2696
  66. package/dist/_chunks/nitro4.mjs +0 -176
  67. package/dist/_chunks/nitro5.mjs +0 -733
  68. package/dist/_chunks/nitro6.mjs +0 -1458
  69. package/dist/_chunks/nitro7.mjs +0 -7561
  70. package/dist/_chunks/nitro8.mjs +0 -3524
  71. package/dist/_chunks/nitro9.mjs +0 -1729
  72. package/dist/_libs/_.mjs +0 -3
  73. package/dist/_libs/_2.mjs +0 -3
  74. package/dist/_libs/_3.mjs +0 -4
  75. package/dist/_libs/_4.mjs +0 -6
  76. package/dist/_libs/_5.mjs +0 -3
  77. package/dist/_libs/_6.mjs +0 -3
  78. package/dist/_libs/acorn+confbox+js-tokens+magic-string+mlly+pkg-types+sourcemap-codec+strip-literal+unimport.mjs +0 -8900
  79. package/dist/_libs/confbox+exsolve+pkg-types.mjs +0 -1249
  80. package/dist/_libs/confbox2.mjs +0 -786
  81. package/dist/_libs/confbox3.mjs +0 -404
  82. package/dist/_libs/confbox4.mjs +0 -3
  83. package/dist/_libs/estree-walker+unimport.mjs +0 -378
  84. package/dist/_libs/fdir+picomatch+tinyglobby.mjs +0 -2471
  85. package/dist/_libs/gen-mapping+remapping+resolve-uri+trace-mapping+unimport+unplugin+unplugin-utils+webpack-virtual-modules.mjs +0 -2150
  86. package/dist/_libs/giget+node-fetch-native.mjs +0 -2692
  87. package/dist/_libs/local-pkg+quansync+unimport.mjs +0 -1526
  88. package/dist/_libs/nypm+tinyexec.mjs +0 -858
  89. package/dist/_libs/pathe.mjs +0 -164
  90. package/dist/_libs/perfect-debounce.mjs +0 -89
  91. package/dist/_libs/std-env.mjs +0 -158
  92. package/dist/_libs/vite-plugin-fullstack.mjs +0 -26
@@ -1,3524 +0,0 @@
1
- import { n as __require, r as __toESM, t as __commonJSMin } from "./nitro.mjs";
2
- import { a as join$1, i as isAbsolute$1, l as relative$1 } from "../_libs/pathe.mjs";
3
- import { t as generateFSTree } from "./nitro2.mjs";
4
- import { t as debounce } from "../_libs/perfect-debounce.mjs";
5
- import { t as formatCompatibilityDate } from "../_libs/compatx.mjs";
6
- import "./nitro4.mjs";
7
- import { r as Builder } from "../_libs/fdir+picomatch+tinyglobby.mjs";
8
- import { c as scanHandlers, n as writeTypes } from "./nitro5.mjs";
9
- import { n as writeBuildInfo } from "./nitro6.mjs";
10
- import { S as MagicString } from "../_libs/acorn+confbox+js-tokens+magic-string+mlly+pkg-types+sourcemap-codec+strip-literal+unimport.mjs";
11
- import { i as watch$1 } from "../_libs/chokidar+readdirp.mjs";
12
- import { n as alias, t as inject } from "../_libs/plugin-alias+plugin-inject.mjs";
13
- import { a as baseBuildConfig, c as dataToEsm, d as walk, i as libChunkName, l as extractAssignedNames, n as NODE_MODULES_RE, o as attachScopes, r as getChunkName, s as createFilter, t as baseBuildPlugins, u as makeLegalIdentifier } from "./nitro7.mjs";
14
- import { watch } from "node:fs";
15
- import nativeFs, { existsSync as existsSync$1, readFileSync as readFileSync$1, realpathSync as realpathSync$1, statSync as statSync$1 } from "fs";
16
- import path, { basename, dirname, extname, join, normalize, relative, resolve, sep } from "path";
17
- import { defu } from "defu";
18
- import { builtinModules } from "module";
19
- import { fileURLToPath, pathToFileURL } from "url";
20
- import { transformSync } from "oxc-transform";
21
- import { promisify } from "util";
22
- import { minifySync } from "oxc-minify";
23
-
24
- //#region node_modules/.pnpm/commondir@1.0.1/node_modules/commondir/index.js
25
- var require_commondir = /* @__PURE__ */ __commonJSMin(((exports, module) => {
26
- var path$4 = __require("path");
27
- module.exports = function(basedir, relfiles) {
28
- if (relfiles) var files = relfiles.map(function(r) {
29
- return path$4.resolve(basedir, r);
30
- });
31
- else var files = basedir;
32
- var res = files.slice(1).reduce(function(ps, file) {
33
- if (!file.match(/^([A-Za-z]:)?\/|\\/)) throw new Error("relative path without a basedir");
34
- var xs = file.split(/\/+|\\+/);
35
- for (var i = 0; ps[i] === xs[i] && i < Math.min(ps.length, xs.length); i++);
36
- return ps.slice(0, i);
37
- }, files[0].split(/\/+|\\+/));
38
- return res.length > 1 ? res.join("/") : "/";
39
- };
40
- }));
41
-
42
- //#endregion
43
- //#region node_modules/.pnpm/is-reference@1.2.1/node_modules/is-reference/dist/is-reference.js
44
- var require_is_reference = /* @__PURE__ */ __commonJSMin(((exports, module) => {
45
- (function(global, factory) {
46
- typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = global || self, global.isReference = factory());
47
- })(exports, (function() {
48
- "use strict";
49
- function isReference$1(node, parent) {
50
- if (node.type === "MemberExpression") return !node.computed && isReference$1(node.object, node);
51
- if (node.type === "Identifier") {
52
- if (!parent) return true;
53
- switch (parent.type) {
54
- case "MemberExpression": return parent.computed || node === parent.object;
55
- case "MethodDefinition": return parent.computed;
56
- case "FieldDefinition": return parent.computed || node === parent.value;
57
- case "Property": return parent.computed || node === parent.value;
58
- case "ExportSpecifier":
59
- case "ImportSpecifier": return node === parent.local;
60
- case "LabeledStatement":
61
- case "BreakStatement":
62
- case "ContinueStatement": return false;
63
- default: return true;
64
- }
65
- }
66
- return false;
67
- }
68
- return isReference$1;
69
- }));
70
- }));
71
-
72
- //#endregion
73
- //#region node_modules/.pnpm/@rollup+plugin-commonjs@29.0.0_rollup@4.55.2/node_modules/@rollup/plugin-commonjs/dist/es/index.js
74
- var import_commondir = /* @__PURE__ */ __toESM(require_commondir(), 1);
75
- var import_is_reference = /* @__PURE__ */ __toESM(require_is_reference(), 1);
76
- var version$1 = "29.0.0";
77
- var peerDependencies$1 = { rollup: "^2.68.0||^3.0.0||^4.0.0" };
78
- function tryParse(parse, code, id) {
79
- try {
80
- return parse(code, { allowReturnOutsideFunction: true });
81
- } catch (err) {
82
- err.message += ` in ${id}`;
83
- throw err;
84
- }
85
- }
86
- const firstpassGlobal = /\b(?:require|module|exports|global)\b/;
87
- const firstpassNoGlobal = /\b(?:require|module|exports)\b/;
88
- function hasCjsKeywords(code, ignoreGlobal) {
89
- return (ignoreGlobal ? firstpassNoGlobal : firstpassGlobal).test(code);
90
- }
91
- function analyzeTopLevelStatements(parse, code, id) {
92
- const ast = tryParse(parse, code, id);
93
- let isEsModule = false;
94
- let hasDefaultExport = false;
95
- let hasNamedExports = false;
96
- for (const node of ast.body) switch (node.type) {
97
- case "ExportDefaultDeclaration":
98
- isEsModule = true;
99
- hasDefaultExport = true;
100
- break;
101
- case "ExportNamedDeclaration":
102
- isEsModule = true;
103
- if (node.declaration) hasNamedExports = true;
104
- else for (const specifier of node.specifiers) if (specifier.exported.name === "default") hasDefaultExport = true;
105
- else hasNamedExports = true;
106
- break;
107
- case "ExportAllDeclaration":
108
- isEsModule = true;
109
- if (node.exported && node.exported.name === "default") hasDefaultExport = true;
110
- else hasNamedExports = true;
111
- break;
112
- case "ImportDeclaration":
113
- isEsModule = true;
114
- break;
115
- }
116
- return {
117
- isEsModule,
118
- hasDefaultExport,
119
- hasNamedExports,
120
- ast
121
- };
122
- }
123
- function deconflict(scopes, globals, identifier) {
124
- let i = 1;
125
- let deconflicted = makeLegalIdentifier(identifier);
126
- const hasConflicts = () => scopes.some((scope) => scope.contains(deconflicted)) || globals.has(deconflicted);
127
- while (hasConflicts()) {
128
- deconflicted = makeLegalIdentifier(`${identifier}_${i}`);
129
- i += 1;
130
- }
131
- for (const scope of scopes) scope.declarations[deconflicted] = true;
132
- return deconflicted;
133
- }
134
- function getName(id) {
135
- const name = makeLegalIdentifier(basename(id, extname(id)));
136
- if (name !== "index") return name;
137
- return makeLegalIdentifier(basename(dirname(id)));
138
- }
139
- function normalizePathSlashes(path$5) {
140
- return path$5.replace(/\\/g, "/");
141
- }
142
- const getVirtualPathForDynamicRequirePath = (path$5, commonDir) => `/${normalizePathSlashes(relative(commonDir, path$5))}`;
143
- function capitalize(name) {
144
- return name[0].toUpperCase() + name.slice(1);
145
- }
146
- function getStrictRequiresFilter({ strictRequires }) {
147
- switch (strictRequires) {
148
- case void 0:
149
- case true: return {
150
- strictRequiresFilter: () => true,
151
- detectCyclesAndConditional: false
152
- };
153
- case "auto":
154
- case "debug":
155
- case null: return {
156
- strictRequiresFilter: () => false,
157
- detectCyclesAndConditional: true
158
- };
159
- case false: return {
160
- strictRequiresFilter: () => false,
161
- detectCyclesAndConditional: false
162
- };
163
- default:
164
- if (typeof strictRequires === "string" || Array.isArray(strictRequires)) return {
165
- strictRequiresFilter: createFilter(strictRequires),
166
- detectCyclesAndConditional: false
167
- };
168
- throw new Error("Unexpected value for \"strictRequires\" option.");
169
- }
170
- }
171
- function getPackageEntryPoint(dirPath) {
172
- let entryPoint = "index.js";
173
- try {
174
- if (existsSync$1(join(dirPath, "package.json"))) entryPoint = JSON.parse(readFileSync$1(join(dirPath, "package.json"), { encoding: "utf8" })).main || entryPoint;
175
- } catch (ignored) {}
176
- return entryPoint;
177
- }
178
- function isDirectory(path$5) {
179
- try {
180
- if (statSync$1(path$5).isDirectory()) return true;
181
- } catch (ignored) {}
182
- return false;
183
- }
184
- function getDynamicRequireModules(patterns, dynamicRequireRoot) {
185
- const dynamicRequireModules = /* @__PURE__ */ new Map();
186
- const dirNames = /* @__PURE__ */ new Set();
187
- for (const pattern of !patterns || Array.isArray(patterns) ? patterns || [] : [patterns]) {
188
- const isNegated = pattern.startsWith("!");
189
- const modifyMap = (targetPath, resolvedPath) => isNegated ? dynamicRequireModules.delete(targetPath) : dynamicRequireModules.set(targetPath, resolvedPath);
190
- for (const path$5 of new Builder().withBasePath().withDirs().glob(isNegated ? pattern.substr(1) : pattern).crawl(relative(".", dynamicRequireRoot)).sync().sort((a, b) => a.localeCompare(b, "en"))) {
191
- const resolvedPath = resolve(path$5);
192
- const requirePath = normalizePathSlashes(resolvedPath);
193
- if (isDirectory(resolvedPath)) {
194
- dirNames.add(resolvedPath);
195
- const modulePath = resolve(join(resolvedPath, getPackageEntryPoint(path$5)));
196
- modifyMap(requirePath, modulePath);
197
- modifyMap(normalizePathSlashes(modulePath), modulePath);
198
- } else {
199
- dirNames.add(dirname(resolvedPath));
200
- modifyMap(requirePath, resolvedPath);
201
- }
202
- }
203
- }
204
- return {
205
- commonDir: dirNames.size ? (0, import_commondir.default)([...dirNames, dynamicRequireRoot]) : null,
206
- dynamicRequireModules
207
- };
208
- }
209
- const FAILED_REQUIRE_ERROR = `throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');`;
210
- const COMMONJS_REQUIRE_EXPORT = "commonjsRequire";
211
- const CREATE_COMMONJS_REQUIRE_EXPORT = "createCommonjsRequire";
212
- function getDynamicModuleRegistry(isDynamicRequireModulesEnabled, dynamicRequireModules, commonDir, ignoreDynamicRequires) {
213
- if (!isDynamicRequireModulesEnabled) return `export function ${COMMONJS_REQUIRE_EXPORT}(path) {
214
- ${FAILED_REQUIRE_ERROR}
215
- }`;
216
- return `${[...dynamicRequireModules.values()].map((id, index) => `import ${id.endsWith(".json") ? `json${index}` : `{ __require as require${index} }`} from ${JSON.stringify(id)};`).join("\n")}
217
-
218
- var dynamicModules;
219
-
220
- function getDynamicModules() {
221
- return dynamicModules || (dynamicModules = {
222
- ${[...dynamicRequireModules.keys()].map((id, index) => `\t\t${JSON.stringify(getVirtualPathForDynamicRequirePath(id, commonDir))}: ${id.endsWith(".json") ? `function () { return json${index}; }` : `require${index}`}`).join(",\n")}
223
- });
224
- }
225
-
226
- export function ${CREATE_COMMONJS_REQUIRE_EXPORT}(originalModuleDir) {
227
- function handleRequire(path) {
228
- var resolvedPath = commonjsResolve(path, originalModuleDir);
229
- if (resolvedPath !== null) {
230
- return getDynamicModules()[resolvedPath]();
231
- }
232
- ${ignoreDynamicRequires ? "return require(path);" : FAILED_REQUIRE_ERROR}
233
- }
234
- handleRequire.resolve = function (path) {
235
- var resolvedPath = commonjsResolve(path, originalModuleDir);
236
- if (resolvedPath !== null) {
237
- return resolvedPath;
238
- }
239
- return require.resolve(path);
240
- }
241
- return handleRequire;
242
- }
243
-
244
- function commonjsResolve (path, originalModuleDir) {
245
- var shouldTryNodeModules = isPossibleNodeModulesPath(path);
246
- path = normalize(path);
247
- var relPath;
248
- if (path[0] === '/') {
249
- originalModuleDir = '';
250
- }
251
- var modules = getDynamicModules();
252
- var checkedExtensions = ['', '.js', '.json'];
253
- while (true) {
254
- if (!shouldTryNodeModules) {
255
- relPath = normalize(originalModuleDir + '/' + path);
256
- } else {
257
- relPath = normalize(originalModuleDir + '/node_modules/' + path);
258
- }
259
-
260
- if (relPath.endsWith('/..')) {
261
- break; // Travelled too far up, avoid infinite loop
262
- }
263
-
264
- for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) {
265
- var resolvedPath = relPath + checkedExtensions[extensionIndex];
266
- if (modules[resolvedPath]) {
267
- return resolvedPath;
268
- }
269
- }
270
- if (!shouldTryNodeModules) break;
271
- var nextDir = normalize(originalModuleDir + '/..');
272
- if (nextDir === originalModuleDir) break;
273
- originalModuleDir = nextDir;
274
- }
275
- return null;
276
- }
277
-
278
- function isPossibleNodeModulesPath (modulePath) {
279
- var c0 = modulePath[0];
280
- if (c0 === '/' || c0 === '\\\\') return false;
281
- var c1 = modulePath[1], c2 = modulePath[2];
282
- if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||
283
- (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;
284
- if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false;
285
- return true;
286
- }
287
-
288
- function normalize (path) {
289
- path = path.replace(/\\\\/g, '/');
290
- var parts = path.split('/');
291
- var slashed = parts[0] === '';
292
- for (var i = 1; i < parts.length; i++) {
293
- if (parts[i] === '.' || parts[i] === '') {
294
- parts.splice(i--, 1);
295
- }
296
- }
297
- for (var i = 1; i < parts.length; i++) {
298
- if (parts[i] !== '..') continue;
299
- if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {
300
- parts.splice(--i, 2);
301
- i--;
302
- }
303
- }
304
- path = parts.join('/');
305
- if (slashed && path[0] !== '/') path = '/' + path;
306
- else if (path.length === 0) path = '.';
307
- return path;
308
- }`;
309
- }
310
- const isWrappedId = (id, suffix) => id.endsWith(suffix);
311
- const wrapId = (id, suffix) => `\0${id}${suffix}`;
312
- const unwrapId = (wrappedId, suffix) => wrappedId.slice(1, -suffix.length);
313
- const PROXY_SUFFIX = "?commonjs-proxy";
314
- const WRAPPED_SUFFIX = "?commonjs-wrapped";
315
- const EXTERNAL_SUFFIX = "?commonjs-external";
316
- const EXPORTS_SUFFIX = "?commonjs-exports";
317
- const MODULE_SUFFIX = "?commonjs-module";
318
- const ENTRY_SUFFIX = "?commonjs-entry";
319
- const ES_IMPORT_SUFFIX = "?commonjs-es-import";
320
- const DYNAMIC_MODULES_ID = "\0commonjs-dynamic-modules";
321
- const HELPERS_ID = "\0commonjsHelpers.js";
322
- const IS_WRAPPED_COMMONJS = "withRequireFunction";
323
- const HELPERS = `
324
- export var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
325
-
326
- export function getDefaultExportFromCjs (x) {
327
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
328
- }
329
-
330
- export function getDefaultExportFromNamespaceIfPresent (n) {
331
- return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n['default'] : n;
332
- }
333
-
334
- export function getDefaultExportFromNamespaceIfNotNamed (n) {
335
- return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n;
336
- }
337
-
338
- export function getAugmentedNamespace(n) {
339
- if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n;
340
- var f = n.default;
341
- if (typeof f == "function") {
342
- var a = function a () {
343
- var isInstance = false;
344
- try {
345
- isInstance = this instanceof a;
346
- } catch {}
347
- if (isInstance) {
348
- return Reflect.construct(f, arguments, this.constructor);
349
- }
350
- return f.apply(this, arguments);
351
- };
352
- a.prototype = f.prototype;
353
- } else a = {};
354
- Object.defineProperty(a, '__esModule', {value: true});
355
- Object.keys(n).forEach(function (k) {
356
- var d = Object.getOwnPropertyDescriptor(n, k);
357
- Object.defineProperty(a, k, d.get ? d : {
358
- enumerable: true,
359
- get: function () {
360
- return n[k];
361
- }
362
- });
363
- });
364
- return a;
365
- }
366
- `;
367
- function getHelpersModule() {
368
- return HELPERS;
369
- }
370
- function getUnknownRequireProxy(id, requireReturnsDefault) {
371
- if (requireReturnsDefault === true || id.endsWith(".json")) return `export { default } from ${JSON.stringify(id)};`;
372
- const name = getName(id);
373
- const exported = requireReturnsDefault === "auto" ? `import { getDefaultExportFromNamespaceIfNotNamed } from "${HELPERS_ID}"; export default /*@__PURE__*/getDefaultExportFromNamespaceIfNotNamed(${name});` : requireReturnsDefault === "preferred" ? `import { getDefaultExportFromNamespaceIfPresent } from "${HELPERS_ID}"; export default /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(${name});` : !requireReturnsDefault ? `import { getAugmentedNamespace } from "${HELPERS_ID}"; export default /*@__PURE__*/getAugmentedNamespace(${name});` : `export default ${name};`;
374
- return `import * as ${name} from ${JSON.stringify(id)}; ${exported}`;
375
- }
376
- async function getStaticRequireProxy(id, requireReturnsDefault, loadModule) {
377
- const name = getName(id);
378
- const { meta: { commonjs: commonjsMeta } } = await loadModule({ id });
379
- if (!commonjsMeta) return getUnknownRequireProxy(id, requireReturnsDefault);
380
- if (commonjsMeta.isCommonJS) return `export { __moduleExports as default } from ${JSON.stringify(id)};`;
381
- if (!requireReturnsDefault) return `import { getAugmentedNamespace } from "${HELPERS_ID}"; import * as ${name} from ${JSON.stringify(id)}; export default /*@__PURE__*/getAugmentedNamespace(${name});`;
382
- if (requireReturnsDefault !== true && (requireReturnsDefault === "namespace" || !commonjsMeta.hasDefaultExport || requireReturnsDefault === "auto" && commonjsMeta.hasNamedExports)) return `import * as ${name} from ${JSON.stringify(id)}; export default ${name};`;
383
- return `export { default } from ${JSON.stringify(id)};`;
384
- }
385
- function getEntryProxy(id, defaultIsModuleExports, getModuleInfo, shebang) {
386
- const { meta: { commonjs: commonjsMeta }, hasDefaultExport } = getModuleInfo(id);
387
- if (!commonjsMeta || commonjsMeta.isCommonJS !== IS_WRAPPED_COMMONJS) {
388
- const stringifiedId = JSON.stringify(id);
389
- let code = `export * from ${stringifiedId};`;
390
- if (hasDefaultExport) code += `export { default } from ${stringifiedId};`;
391
- return shebang + code;
392
- }
393
- const result = getEsImportProxy(id, defaultIsModuleExports, true);
394
- return {
395
- ...result,
396
- code: shebang + result.code
397
- };
398
- }
399
- function getEsImportProxy(id, defaultIsModuleExports, moduleSideEffects) {
400
- const name = getName(id);
401
- const exportsName = `${name}Exports`;
402
- const requireModule = `require${capitalize(name)}`;
403
- let code = `import { getDefaultExportFromCjs } from "${HELPERS_ID}";\nimport { __require as ${requireModule} } from ${JSON.stringify(id)};\nvar ${exportsName} = ${moduleSideEffects ? "" : "/*@__PURE__*/ "}${requireModule}();\nexport { ${exportsName} as __moduleExports };`;
404
- if (defaultIsModuleExports === true) code += `\nexport { ${exportsName} as default };`;
405
- else if (defaultIsModuleExports === false) code += `\nexport default ${exportsName}.default;`;
406
- else code += `\nexport default /*@__PURE__*/getDefaultExportFromCjs(${exportsName});`;
407
- return {
408
- code,
409
- syntheticNamedExports: "__moduleExports"
410
- };
411
- }
412
- function getExternalBuiltinRequireProxy(id) {
413
- return `import { createRequire } from 'node:module';
414
- const require = createRequire(import.meta.url);
415
- export function __require() { return require(${JSON.stringify(id)}); }`;
416
- }
417
- function getCandidatesForExtension(resolved, extension) {
418
- return [resolved + extension, `${resolved}${sep}index${extension}`];
419
- }
420
- function getCandidates(resolved, extensions) {
421
- return extensions.reduce((paths, extension) => paths.concat(getCandidatesForExtension(resolved, extension)), [resolved]);
422
- }
423
- function resolveExtensions(importee, importer, extensions) {
424
- if (importee[0] !== "." || !importer) return void 0;
425
- const candidates = getCandidates(resolve(dirname(importer), importee), extensions);
426
- for (let i = 0; i < candidates.length; i += 1) try {
427
- if (statSync$1(candidates[i]).isFile()) return { id: candidates[i] };
428
- } catch (err) {}
429
- }
430
- function getResolveId(extensions, isPossibleCjsId) {
431
- const currentlyResolving = /* @__PURE__ */ new Map();
432
- return {
433
- currentlyResolving,
434
- async resolveId(importee, importer, resolveOptions) {
435
- if (resolveOptions.custom?.["node-resolve"]?.isRequire) return null;
436
- const currentlyResolvingForParent = currentlyResolving.get(importer);
437
- if (currentlyResolvingForParent && currentlyResolvingForParent.has(importee)) {
438
- this.warn({
439
- code: "THIS_RESOLVE_WITHOUT_OPTIONS",
440
- message: "It appears a plugin has implemented a \"resolveId\" hook that uses \"this.resolve\" without forwarding the third \"options\" parameter of \"resolveId\". This is problematic as it can lead to wrong module resolutions especially for the node-resolve plugin and in certain cases cause early exit errors for the commonjs plugin.\nIn rare cases, this warning can appear if the same file is both imported and required from the same mixed ES/CommonJS module, in which case it can be ignored.",
441
- url: "https://rollupjs.org/guide/en/#resolveid"
442
- });
443
- return null;
444
- }
445
- if (isWrappedId(importee, WRAPPED_SUFFIX)) return unwrapId(importee, WRAPPED_SUFFIX);
446
- if (importee.endsWith(ENTRY_SUFFIX) || isWrappedId(importee, MODULE_SUFFIX) || isWrappedId(importee, EXPORTS_SUFFIX) || isWrappedId(importee, PROXY_SUFFIX) || isWrappedId(importee, ES_IMPORT_SUFFIX) || isWrappedId(importee, EXTERNAL_SUFFIX) || importee.startsWith(HELPERS_ID) || importee === DYNAMIC_MODULES_ID) return importee;
447
- if (importer) {
448
- if (importer === DYNAMIC_MODULES_ID || isWrappedId(importer, PROXY_SUFFIX) || isWrappedId(importer, ES_IMPORT_SUFFIX) || importer.endsWith(ENTRY_SUFFIX)) return importee;
449
- if (isWrappedId(importer, EXTERNAL_SUFFIX)) {
450
- if (!await this.resolve(importee, importer, Object.assign({ skipSelf: true }, resolveOptions))) return null;
451
- return {
452
- id: importee,
453
- external: true
454
- };
455
- }
456
- }
457
- if (importee.startsWith("\0")) return null;
458
- const resolved = await this.resolve(importee, importer, Object.assign({ skipSelf: true }, resolveOptions)) || resolveExtensions(importee, importer, extensions);
459
- if (!resolved || resolved.external || resolved.id.endsWith(ENTRY_SUFFIX) || isWrappedId(resolved.id, ES_IMPORT_SUFFIX) || !isPossibleCjsId(resolved.id)) return resolved;
460
- const moduleInfo = await this.load(resolved);
461
- const { meta: { commonjs: commonjsMeta } } = moduleInfo;
462
- if (commonjsMeta) {
463
- const { isCommonJS } = commonjsMeta;
464
- if (isCommonJS) {
465
- if (resolveOptions.isEntry) {
466
- moduleInfo.moduleSideEffects = true;
467
- return resolved.id + ENTRY_SUFFIX;
468
- }
469
- if (isCommonJS === IS_WRAPPED_COMMONJS) return {
470
- id: wrapId(resolved.id, ES_IMPORT_SUFFIX),
471
- meta: { commonjs: { resolved } }
472
- };
473
- }
474
- }
475
- return resolved;
476
- }
477
- };
478
- }
479
- function getRequireResolver(extensions, detectCyclesAndConditional, currentlyResolving, requireNodeBuiltins) {
480
- const knownCjsModuleTypes = Object.create(null);
481
- const requiredIds = Object.create(null);
482
- const unconditionallyRequiredIds = Object.create(null);
483
- const dependencies = Object.create(null);
484
- const getDependencies = (id) => dependencies[id] || (dependencies[id] = /* @__PURE__ */ new Set());
485
- const isCyclic = (id) => {
486
- const dependenciesToCheck = new Set(getDependencies(id));
487
- for (const dependency of dependenciesToCheck) {
488
- if (dependency === id) return true;
489
- for (const childDependency of getDependencies(dependency)) dependenciesToCheck.add(childDependency);
490
- }
491
- return false;
492
- };
493
- const fullyAnalyzedModules = Object.create(null);
494
- const getTypeForFullyAnalyzedModule = (id) => {
495
- const knownType = knownCjsModuleTypes[id];
496
- if (knownType !== true || !detectCyclesAndConditional || fullyAnalyzedModules[id]) return knownType;
497
- if (isCyclic(id)) return knownCjsModuleTypes[id] = IS_WRAPPED_COMMONJS;
498
- return knownType;
499
- };
500
- const setInitialParentType = (id, initialCommonJSType) => {
501
- if (fullyAnalyzedModules[id]) return;
502
- knownCjsModuleTypes[id] = initialCommonJSType;
503
- if (detectCyclesAndConditional && knownCjsModuleTypes[id] === true && requiredIds[id] && !unconditionallyRequiredIds[id]) knownCjsModuleTypes[id] = IS_WRAPPED_COMMONJS;
504
- };
505
- const analyzeRequiredModule = async (parentId, resolved, isConditional, loadModule) => {
506
- const childId = resolved.id;
507
- requiredIds[childId] = true;
508
- if (!(isConditional || knownCjsModuleTypes[parentId] === IS_WRAPPED_COMMONJS)) unconditionallyRequiredIds[childId] = true;
509
- getDependencies(parentId).add(childId);
510
- if (!isCyclic(childId)) await loadModule(resolved);
511
- };
512
- const getTypeForImportedModule = async (resolved, loadModule) => {
513
- if (resolved.id in knownCjsModuleTypes) return knownCjsModuleTypes[resolved.id];
514
- const { meta: { commonjs: commonjs$1 } } = await loadModule(resolved);
515
- return commonjs$1 && commonjs$1.isCommonJS || false;
516
- };
517
- return {
518
- getWrappedIds: () => Object.keys(knownCjsModuleTypes).filter((id) => knownCjsModuleTypes[id] === IS_WRAPPED_COMMONJS),
519
- isRequiredId: (id) => requiredIds[id],
520
- async shouldTransformCachedModule({ id: parentId, resolvedSources, meta: { commonjs: parentMeta } }) {
521
- if (!(parentMeta && parentMeta.isCommonJS)) knownCjsModuleTypes[parentId] = false;
522
- if (isWrappedId(parentId, ES_IMPORT_SUFFIX)) return false;
523
- const parentRequires = parentMeta && parentMeta.requires;
524
- if (parentRequires) {
525
- setInitialParentType(parentId, parentMeta.initialCommonJSType);
526
- await Promise.all(parentRequires.map(({ resolved, isConditional }) => analyzeRequiredModule(parentId, resolved, isConditional, this.load)));
527
- if (getTypeForFullyAnalyzedModule(parentId) !== parentMeta.isCommonJS) return true;
528
- for (const { resolved: { id } } of parentRequires) if (getTypeForFullyAnalyzedModule(id) !== parentMeta.isRequiredCommonJS[id]) return true;
529
- fullyAnalyzedModules[parentId] = true;
530
- for (const { resolved: { id } } of parentRequires) fullyAnalyzedModules[id] = true;
531
- }
532
- const parentRequireSet = new Set((parentRequires || []).map(({ resolved: { id } }) => id));
533
- return (await Promise.all(Object.keys(resolvedSources).map((source) => resolvedSources[source]).filter(({ id, external }) => !(external || parentRequireSet.has(id))).map(async (resolved) => {
534
- if (isWrappedId(resolved.id, ES_IMPORT_SUFFIX)) return await getTypeForImportedModule((await this.load(resolved)).meta.commonjs.resolved, this.load) !== IS_WRAPPED_COMMONJS;
535
- return await getTypeForImportedModule(resolved, this.load) === IS_WRAPPED_COMMONJS;
536
- }))).some((shouldTransform) => shouldTransform);
537
- },
538
- resolveRequireSourcesAndUpdateMeta: (rollupContext) => async (parentId, isParentCommonJS, parentMeta, sources) => {
539
- parentMeta.initialCommonJSType = isParentCommonJS;
540
- parentMeta.requires = [];
541
- parentMeta.isRequiredCommonJS = Object.create(null);
542
- setInitialParentType(parentId, isParentCommonJS);
543
- const currentlyResolvingForParent = currentlyResolving.get(parentId) || /* @__PURE__ */ new Set();
544
- currentlyResolving.set(parentId, currentlyResolvingForParent);
545
- const requireTargets = await Promise.all(sources.map(async ({ source, isConditional }) => {
546
- if (source.startsWith("\0")) return {
547
- id: source,
548
- allowProxy: false
549
- };
550
- currentlyResolvingForParent.add(source);
551
- const resolved = await rollupContext.resolve(source, parentId, {
552
- skipSelf: false,
553
- custom: { "node-resolve": { isRequire: true } }
554
- }) || resolveExtensions(source, parentId, extensions);
555
- currentlyResolvingForParent.delete(source);
556
- if (!resolved) return {
557
- id: wrapId(source, EXTERNAL_SUFFIX),
558
- allowProxy: false
559
- };
560
- const childId = resolved.id;
561
- if (resolved.external) return {
562
- id: wrapId(childId, EXTERNAL_SUFFIX),
563
- allowProxy: false
564
- };
565
- parentMeta.requires.push({
566
- resolved,
567
- isConditional
568
- });
569
- await analyzeRequiredModule(parentId, resolved, isConditional, rollupContext.load);
570
- return {
571
- id: childId,
572
- allowProxy: true
573
- };
574
- }));
575
- parentMeta.isCommonJS = getTypeForFullyAnalyzedModule(parentId);
576
- fullyAnalyzedModules[parentId] = true;
577
- return requireTargets.map(({ id: dependencyId, allowProxy }, index) => {
578
- let isCommonJS = parentMeta.isRequiredCommonJS[dependencyId] = getTypeForFullyAnalyzedModule(dependencyId);
579
- const isExternalWrapped = isWrappedId(dependencyId, EXTERNAL_SUFFIX);
580
- let resolvedDependencyId = dependencyId;
581
- if (requireNodeBuiltins === true) {
582
- if (parentMeta.isCommonJS === IS_WRAPPED_COMMONJS && !allowProxy && isExternalWrapped) {
583
- if (unwrapId(dependencyId, EXTERNAL_SUFFIX).startsWith("node:")) {
584
- isCommonJS = IS_WRAPPED_COMMONJS;
585
- parentMeta.isRequiredCommonJS[dependencyId] = isCommonJS;
586
- }
587
- } else if (isExternalWrapped && !allowProxy) {
588
- const actualExternalId = unwrapId(dependencyId, EXTERNAL_SUFFIX);
589
- if (actualExternalId.startsWith("node:")) resolvedDependencyId = actualExternalId;
590
- }
591
- }
592
- const isWrappedCommonJS = isCommonJS === IS_WRAPPED_COMMONJS;
593
- fullyAnalyzedModules[dependencyId] = true;
594
- const moduleInfo = isWrappedCommonJS && !isExternalWrapped ? rollupContext.getModuleInfo(dependencyId) : null;
595
- return {
596
- wrappedModuleSideEffects: !isWrappedCommonJS ? false : moduleInfo?.moduleSideEffects ?? true,
597
- source: sources[index].source,
598
- id: allowProxy ? wrapId(resolvedDependencyId, isWrappedCommonJS ? WRAPPED_SUFFIX : PROXY_SUFFIX) : resolvedDependencyId,
599
- isCommonJS
600
- };
601
- });
602
- },
603
- isCurrentlyResolving(source, parentId) {
604
- const currentlyResolvingForParent = currentlyResolving.get(parentId);
605
- return currentlyResolvingForParent && currentlyResolvingForParent.has(source);
606
- }
607
- };
608
- }
609
- function validateVersion$1(actualVersion, peerDependencyVersion, name) {
610
- const versionRegexp$1 = /\^(\d+\.\d+\.\d+)/g;
611
- let minMajor = Infinity;
612
- let minMinor = Infinity;
613
- let minPatch = Infinity;
614
- let foundVersion;
615
- while (foundVersion = versionRegexp$1.exec(peerDependencyVersion)) {
616
- const [foundMajor, foundMinor, foundPatch] = foundVersion[1].split(".").map(Number);
617
- if (foundMajor < minMajor) {
618
- minMajor = foundMajor;
619
- minMinor = foundMinor;
620
- minPatch = foundPatch;
621
- }
622
- }
623
- if (!actualVersion) throw new Error(`Insufficient ${name} version: "@rollup/plugin-commonjs" requires at least ${name}@${minMajor}.${minMinor}.${minPatch}.`);
624
- const [major, minor, patch] = actualVersion.split(".").map(Number);
625
- if (major < minMajor || major === minMajor && (minor < minMinor || minor === minMinor && patch < minPatch)) throw new Error(`Insufficient ${name} version: "@rollup/plugin-commonjs" requires at least ${name}@${minMajor}.${minMinor}.${minPatch} but found ${name}@${actualVersion}.`);
626
- }
627
- const operators = {
628
- "==": (x) => equals(x.left, x.right, false),
629
- "!=": (x) => not(operators["=="](x)),
630
- "===": (x) => equals(x.left, x.right, true),
631
- "!==": (x) => not(operators["==="](x)),
632
- "!": (x) => isFalsy(x.argument),
633
- "&&": (x) => isTruthy(x.left) && isTruthy(x.right),
634
- "||": (x) => isTruthy(x.left) || isTruthy(x.right)
635
- };
636
- function not(value) {
637
- return value === null ? value : !value;
638
- }
639
- function equals(a, b, strict) {
640
- if (a.type !== b.type) return null;
641
- if (a.type === "Literal") return strict ? a.value === b.value : a.value == b.value;
642
- return null;
643
- }
644
- function isTruthy(node) {
645
- if (!node) return false;
646
- if (node.type === "Literal") return !!node.value;
647
- if (node.type === "ParenthesizedExpression") return isTruthy(node.expression);
648
- if (node.operator in operators) return operators[node.operator](node);
649
- return null;
650
- }
651
- function isFalsy(node) {
652
- return not(isTruthy(node));
653
- }
654
- function getKeypath(node) {
655
- const parts = [];
656
- while (node.type === "MemberExpression") {
657
- if (node.computed) return null;
658
- parts.unshift(node.property.name);
659
- node = node.object;
660
- }
661
- if (node.type !== "Identifier") return null;
662
- const { name } = node;
663
- parts.unshift(name);
664
- return {
665
- name,
666
- keypath: parts.join(".")
667
- };
668
- }
669
- const KEY_COMPILED_ESM = "__esModule";
670
- function getDefineCompiledEsmType(node) {
671
- const definedPropertyWithExports = getDefinePropertyCallName(node, "exports");
672
- const definedProperty = definedPropertyWithExports || getDefinePropertyCallName(node, "module.exports");
673
- if (definedProperty && definedProperty.key === KEY_COMPILED_ESM) return isTruthy(definedProperty.value) ? definedPropertyWithExports ? "exports" : "module" : false;
674
- return false;
675
- }
676
- function getDefinePropertyCallName(node, targetName) {
677
- const { callee: { object, property } } = node;
678
- if (!object || object.type !== "Identifier" || object.name !== "Object") return;
679
- if (!property || property.type !== "Identifier" || property.name !== "defineProperty") return;
680
- if (node.arguments.length !== 3) return;
681
- const targetNames = targetName.split(".");
682
- const [target, key, value] = node.arguments;
683
- if (targetNames.length === 1) {
684
- if (target.type !== "Identifier" || target.name !== targetNames[0]) return;
685
- }
686
- if (targetNames.length === 2) {
687
- if (target.type !== "MemberExpression" || target.object.name !== targetNames[0] || target.property.name !== targetNames[1]) return;
688
- }
689
- if (value.type !== "ObjectExpression" || !value.properties) return;
690
- const valueProperty = value.properties.find((p) => p.key && p.key.name === "value");
691
- if (!valueProperty || !valueProperty.value) return;
692
- return {
693
- key: key.value,
694
- value: valueProperty.value
695
- };
696
- }
697
- function isShorthandProperty(parent) {
698
- return parent && parent.type === "Property" && parent.shorthand;
699
- }
700
- function wrapCode(magicString, uses, moduleName, exportsName, indentExclusionRanges) {
701
- const args = [];
702
- const passedArgs = [];
703
- if (uses.module) {
704
- args.push("module");
705
- passedArgs.push(moduleName);
706
- }
707
- if (uses.exports) {
708
- args.push("exports");
709
- passedArgs.push(uses.module ? `${moduleName}.exports` : exportsName);
710
- }
711
- magicString.trim().indent(" ", { exclude: indentExclusionRanges }).prepend(`(function (${args.join(", ")}) {\n`).append(` \n} (${passedArgs.join(", ")}));`);
712
- }
713
- function rewriteExportsAndGetExportsBlock(magicString, moduleName, exportsName, exportedExportsName, wrapped, moduleExportsAssignments, firstTopLevelModuleExportsAssignment, exportsAssignmentsByName, topLevelAssignments, defineCompiledEsmExpressions, deconflictedExportNames, code, HELPERS_NAME, exportMode, defaultIsModuleExports, usesRequireWrapper, requireName) {
714
- const exports$1 = [];
715
- const exportDeclarations = [];
716
- if (usesRequireWrapper) getExportsWhenUsingRequireWrapper(magicString, wrapped, exportMode, exports$1, moduleExportsAssignments, exportsAssignmentsByName, moduleName, exportsName, requireName, defineCompiledEsmExpressions);
717
- else if (exportMode === "replace") getExportsForReplacedModuleExports(magicString, exports$1, exportDeclarations, moduleExportsAssignments, firstTopLevelModuleExportsAssignment, exportsName, defaultIsModuleExports, HELPERS_NAME);
718
- else {
719
- if (exportMode === "module") {
720
- exportDeclarations.push(`var ${exportedExportsName} = ${moduleName}.exports`);
721
- exports$1.push(`${exportedExportsName} as __moduleExports`);
722
- } else exports$1.push(`${exportsName} as __moduleExports`);
723
- if (wrapped) exportDeclarations.push(getDefaultExportDeclaration(exportedExportsName, defaultIsModuleExports, HELPERS_NAME));
724
- else getExports(magicString, exports$1, exportDeclarations, moduleExportsAssignments, exportsAssignmentsByName, deconflictedExportNames, topLevelAssignments, moduleName, exportsName, exportedExportsName, defineCompiledEsmExpressions, HELPERS_NAME, defaultIsModuleExports, exportMode);
725
- }
726
- if (exports$1.length) exportDeclarations.push(`export { ${exports$1.join(", ")} }`);
727
- return `\n\n${exportDeclarations.join(";\n")};`;
728
- }
729
- function getExportsWhenUsingRequireWrapper(magicString, wrapped, exportMode, exports$1, moduleExportsAssignments, exportsAssignmentsByName, moduleName, exportsName, requireName, defineCompiledEsmExpressions) {
730
- exports$1.push(`${requireName} as __require`);
731
- if (wrapped) return;
732
- if (exportMode === "replace") rewriteModuleExportsAssignments(magicString, moduleExportsAssignments, exportsName);
733
- else {
734
- rewriteModuleExportsAssignments(magicString, moduleExportsAssignments, `${moduleName}.exports`);
735
- for (const [exportName, { nodes }] of exportsAssignmentsByName) for (const { node, type } of nodes) magicString.overwrite(node.start, node.left.end, `${exportMode === "module" && type === "module" ? `${moduleName}.exports` : exportsName}.${exportName}`);
736
- replaceDefineCompiledEsmExpressionsAndGetIfRestorable(defineCompiledEsmExpressions, magicString, exportMode, moduleName, exportsName);
737
- }
738
- }
739
- function getExportsForReplacedModuleExports(magicString, exports$1, exportDeclarations, moduleExportsAssignments, firstTopLevelModuleExportsAssignment, exportsName, defaultIsModuleExports, HELPERS_NAME) {
740
- for (const { left } of moduleExportsAssignments) magicString.overwrite(left.start, left.end, exportsName);
741
- magicString.prependRight(firstTopLevelModuleExportsAssignment.left.start, "var ");
742
- exports$1.push(`${exportsName} as __moduleExports`);
743
- exportDeclarations.push(getDefaultExportDeclaration(exportsName, defaultIsModuleExports, HELPERS_NAME));
744
- }
745
- function getDefaultExportDeclaration(exportedExportsName, defaultIsModuleExports, HELPERS_NAME) {
746
- return `export default ${defaultIsModuleExports === true ? exportedExportsName : defaultIsModuleExports === false ? `${exportedExportsName}.default` : `/*@__PURE__*/${HELPERS_NAME}.getDefaultExportFromCjs(${exportedExportsName})`}`;
747
- }
748
- function getExports(magicString, exports$1, exportDeclarations, moduleExportsAssignments, exportsAssignmentsByName, deconflictedExportNames, topLevelAssignments, moduleName, exportsName, exportedExportsName, defineCompiledEsmExpressions, HELPERS_NAME, defaultIsModuleExports, exportMode) {
749
- let deconflictedDefaultExportName;
750
- for (const { left } of moduleExportsAssignments) magicString.overwrite(left.start, left.end, `${moduleName}.exports`);
751
- for (const [exportName, { nodes }] of exportsAssignmentsByName) {
752
- const deconflicted = deconflictedExportNames[exportName];
753
- let needsDeclaration = true;
754
- for (const { node, type } of nodes) {
755
- let replacement = `${deconflicted} = ${exportMode === "module" && type === "module" ? `${moduleName}.exports` : exportsName}.${exportName}`;
756
- if (needsDeclaration && topLevelAssignments.has(node)) {
757
- replacement = `var ${replacement}`;
758
- needsDeclaration = false;
759
- }
760
- magicString.overwrite(node.start, node.left.end, replacement);
761
- }
762
- if (needsDeclaration) magicString.prepend(`var ${deconflicted};\n`);
763
- if (exportName === "default") deconflictedDefaultExportName = deconflicted;
764
- else exports$1.push(exportName === deconflicted ? exportName : `${deconflicted} as ${exportName}`);
765
- }
766
- const isRestorableCompiledEsm = replaceDefineCompiledEsmExpressionsAndGetIfRestorable(defineCompiledEsmExpressions, magicString, exportMode, moduleName, exportsName);
767
- if (defaultIsModuleExports === false || defaultIsModuleExports === "auto" && isRestorableCompiledEsm && moduleExportsAssignments.length === 0) exports$1.push(`${deconflictedDefaultExportName || exportedExportsName} as default`);
768
- else if (defaultIsModuleExports === true || !isRestorableCompiledEsm && moduleExportsAssignments.length === 0) exports$1.push(`${exportedExportsName} as default`);
769
- else exportDeclarations.push(getDefaultExportDeclaration(exportedExportsName, defaultIsModuleExports, HELPERS_NAME));
770
- }
771
- function rewriteModuleExportsAssignments(magicString, moduleExportsAssignments, exportsName) {
772
- for (const { left } of moduleExportsAssignments) magicString.overwrite(left.start, left.end, exportsName);
773
- }
774
- function replaceDefineCompiledEsmExpressionsAndGetIfRestorable(defineCompiledEsmExpressions, magicString, exportMode, moduleName, exportsName) {
775
- let isRestorableCompiledEsm = false;
776
- for (const { node, type } of defineCompiledEsmExpressions) {
777
- isRestorableCompiledEsm = true;
778
- const moduleExportsExpression = node.type === "CallExpression" ? node.arguments[0] : node.left.object;
779
- magicString.overwrite(moduleExportsExpression.start, moduleExportsExpression.end, exportMode === "module" && type === "module" ? `${moduleName}.exports` : exportsName);
780
- }
781
- return isRestorableCompiledEsm;
782
- }
783
- function isRequireExpression(node, scope) {
784
- if (!node) return false;
785
- if (node.type !== "CallExpression") return false;
786
- if (node.arguments.length === 0) return false;
787
- return isRequire(node.callee, scope);
788
- }
789
- function isRequire(node, scope) {
790
- return node.type === "Identifier" && node.name === "require" && !scope.contains("require") || node.type === "MemberExpression" && isModuleRequire(node, scope);
791
- }
792
- function isModuleRequire({ object, property }, scope) {
793
- return object.type === "Identifier" && object.name === "module" && property.type === "Identifier" && property.name === "require" && !scope.contains("module");
794
- }
795
- function hasDynamicArguments(node) {
796
- return node.arguments.length > 1 || node.arguments[0].type !== "Literal" && (node.arguments[0].type !== "TemplateLiteral" || node.arguments[0].expressions.length > 0);
797
- }
798
- const reservedMethod = {
799
- resolve: true,
800
- cache: true,
801
- main: true
802
- };
803
- function isNodeRequirePropertyAccess(parent) {
804
- return parent && parent.property && reservedMethod[parent.property.name];
805
- }
806
- function getRequireStringArg(node) {
807
- return node.arguments[0].type === "Literal" ? node.arguments[0].value : node.arguments[0].quasis[0].value.cooked;
808
- }
809
- function getRequireHandlers() {
810
- const requireExpressions = [];
811
- function addRequireExpression(sourceId, node, scope, usesReturnValue, isInsideTryBlock, isInsideConditional, toBeRemoved) {
812
- requireExpressions.push({
813
- sourceId,
814
- node,
815
- scope,
816
- usesReturnValue,
817
- isInsideTryBlock,
818
- isInsideConditional,
819
- toBeRemoved
820
- });
821
- }
822
- async function rewriteRequireExpressionsAndGetImportBlock(magicString, topLevelDeclarations, reassignedNames, helpersName, dynamicRequireName, moduleName, exportsName, id, exportMode, resolveRequireSourcesAndUpdateMeta, needsRequireWrapper, isEsModule, isDynamicRequireModulesEnabled, getIgnoreTryCatchRequireStatementMode, commonjsMeta) {
823
- const imports = [];
824
- imports.push(`import * as ${helpersName} from "${HELPERS_ID}"`);
825
- if (dynamicRequireName) imports.push(`import { ${isDynamicRequireModulesEnabled ? CREATE_COMMONJS_REQUIRE_EXPORT : COMMONJS_REQUIRE_EXPORT} as ${dynamicRequireName} } from "${DYNAMIC_MODULES_ID}"`);
826
- if (exportMode === "module") imports.push(`import { __module as ${moduleName} } from ${JSON.stringify(wrapId(id, MODULE_SUFFIX))}`, `var ${exportsName} = ${moduleName}.exports`);
827
- else if (exportMode === "exports") imports.push(`import { __exports as ${exportsName} } from ${JSON.stringify(wrapId(id, EXPORTS_SUFFIX))}`);
828
- const requiresBySource = collectSources(requireExpressions);
829
- processRequireExpressions(imports, await resolveRequireSourcesAndUpdateMeta(id, needsRequireWrapper ? IS_WRAPPED_COMMONJS : !isEsModule, commonjsMeta, Object.keys(requiresBySource).map((source) => {
830
- return {
831
- source,
832
- isConditional: requiresBySource[source].every((require$1) => require$1.isInsideConditional)
833
- };
834
- })), requiresBySource, getIgnoreTryCatchRequireStatementMode, magicString);
835
- return imports.length ? `${imports.join(";\n")};\n\n` : "";
836
- }
837
- return {
838
- addRequireExpression,
839
- rewriteRequireExpressionsAndGetImportBlock
840
- };
841
- }
842
- function collectSources(requireExpressions) {
843
- const requiresBySource = Object.create(null);
844
- for (const requireExpression of requireExpressions) {
845
- const { sourceId } = requireExpression;
846
- if (!requiresBySource[sourceId]) requiresBySource[sourceId] = [];
847
- requiresBySource[sourceId].push(requireExpression);
848
- }
849
- return requiresBySource;
850
- }
851
- function processRequireExpressions(imports, requireTargets, requiresBySource, getIgnoreTryCatchRequireStatementMode, magicString) {
852
- const generateRequireName = getGenerateRequireName();
853
- for (const { source, id: resolvedId, isCommonJS, wrappedModuleSideEffects } of requireTargets) {
854
- const requires = requiresBySource[source];
855
- const name = generateRequireName(requires);
856
- let usesRequired = false;
857
- let needsImport = false;
858
- for (const { node, usesReturnValue, toBeRemoved, isInsideTryBlock } of requires) {
859
- const { canConvertRequire, shouldRemoveRequire } = isInsideTryBlock && isWrappedId(resolvedId, EXTERNAL_SUFFIX) ? getIgnoreTryCatchRequireStatementMode(source) : {
860
- canConvertRequire: true,
861
- shouldRemoveRequire: false
862
- };
863
- if (shouldRemoveRequire) if (usesReturnValue) magicString.overwrite(node.start, node.end, "undefined");
864
- else magicString.remove(toBeRemoved.start, toBeRemoved.end);
865
- else if (canConvertRequire) {
866
- needsImport = true;
867
- if (isCommonJS === IS_WRAPPED_COMMONJS) magicString.overwrite(node.start, node.end, `${wrappedModuleSideEffects ? "" : "/*@__PURE__*/ "}${name}()`);
868
- else if (usesReturnValue) {
869
- usesRequired = true;
870
- magicString.overwrite(node.start, node.end, name);
871
- } else magicString.remove(toBeRemoved.start, toBeRemoved.end);
872
- }
873
- }
874
- if (needsImport) if (isCommonJS === IS_WRAPPED_COMMONJS) imports.push(`import { __require as ${name} } from ${JSON.stringify(resolvedId)}`);
875
- else imports.push(`import ${usesRequired ? `${name} from ` : ""}${JSON.stringify(resolvedId)}`);
876
- }
877
- }
878
- function getGenerateRequireName() {
879
- let uid = 0;
880
- return (requires) => {
881
- let name;
882
- const hasNameConflict = ({ scope }) => scope.contains(name);
883
- do {
884
- name = `require$$${uid}`;
885
- uid += 1;
886
- } while (requires.some(hasNameConflict));
887
- return name;
888
- };
889
- }
890
- const exportsPattern = /^(?:module\.)?exports(?:\.([a-zA-Z_$][a-zA-Z_$0-9]*))?$/;
891
- const functionType = /^(?:FunctionDeclaration|FunctionExpression|ArrowFunctionExpression)$/;
892
- async function transformCommonjs(parse, code, id, isEsModule, ignoreGlobal, ignoreRequire, ignoreDynamicRequires, getIgnoreTryCatchRequireStatementMode, sourceMap, isDynamicRequireModulesEnabled, dynamicRequireModules, commonDir, astCache, defaultIsModuleExports, needsRequireWrapper, resolveRequireSourcesAndUpdateMeta, isRequired, checkDynamicRequire, commonjsMeta) {
893
- const ast = astCache || tryParse(parse, code, id);
894
- const magicString = new MagicString(code);
895
- const uses = {
896
- module: false,
897
- exports: false,
898
- global: false,
899
- require: false
900
- };
901
- const virtualDynamicRequirePath = isDynamicRequireModulesEnabled && getVirtualPathForDynamicRequirePath(dirname(id), commonDir);
902
- let scope = attachScopes(ast, "scope");
903
- let lexicalDepth = 0;
904
- let programDepth = 0;
905
- let classBodyDepth = 0;
906
- let currentTryBlockEnd = null;
907
- let shouldWrap = false;
908
- const globals = /* @__PURE__ */ new Set();
909
- let currentConditionalNodeEnd = null;
910
- const conditionalNodes = /* @__PURE__ */ new Set();
911
- const { addRequireExpression, rewriteRequireExpressionsAndGetImportBlock } = getRequireHandlers();
912
- const reassignedNames = /* @__PURE__ */ new Set();
913
- const topLevelDeclarations = [];
914
- const skippedNodes = /* @__PURE__ */ new Set();
915
- const moduleAccessScopes = new Set([scope]);
916
- const exportsAccessScopes = new Set([scope]);
917
- const moduleExportsAssignments = [];
918
- let firstTopLevelModuleExportsAssignment = null;
919
- const exportsAssignmentsByName = /* @__PURE__ */ new Map();
920
- const topLevelAssignments = /* @__PURE__ */ new Set();
921
- const topLevelDefineCompiledEsmExpressions = [];
922
- const replacedGlobal = [];
923
- const replacedThis = [];
924
- const replacedDynamicRequires = [];
925
- const importedVariables = /* @__PURE__ */ new Set();
926
- const indentExclusionRanges = [];
927
- walk(ast, {
928
- enter(node, parent) {
929
- if (skippedNodes.has(node)) {
930
- this.skip();
931
- return;
932
- }
933
- if (currentTryBlockEnd !== null && node.start > currentTryBlockEnd) currentTryBlockEnd = null;
934
- if (currentConditionalNodeEnd !== null && node.start > currentConditionalNodeEnd) currentConditionalNodeEnd = null;
935
- if (currentConditionalNodeEnd === null && conditionalNodes.has(node)) currentConditionalNodeEnd = node.end;
936
- programDepth += 1;
937
- if (node.scope) ({scope} = node);
938
- if (functionType.test(node.type)) lexicalDepth += 1;
939
- if (sourceMap) {
940
- magicString.addSourcemapLocation(node.start);
941
- magicString.addSourcemapLocation(node.end);
942
- }
943
- switch (node.type) {
944
- case "AssignmentExpression":
945
- if (node.left.type === "MemberExpression") {
946
- const flattened = getKeypath(node.left);
947
- if (!flattened || scope.contains(flattened.name)) return;
948
- const exportsPatternMatch = exportsPattern.exec(flattened.keypath);
949
- if (!exportsPatternMatch || flattened.keypath === "exports") return;
950
- const [, exportName] = exportsPatternMatch;
951
- uses[flattened.name] = true;
952
- if (flattened.keypath === "module.exports") {
953
- moduleExportsAssignments.push(node);
954
- if (programDepth > 3) moduleAccessScopes.add(scope);
955
- else if (!firstTopLevelModuleExportsAssignment) firstTopLevelModuleExportsAssignment = node;
956
- } else if (exportName === KEY_COMPILED_ESM) if (programDepth > 3) shouldWrap = true;
957
- else topLevelDefineCompiledEsmExpressions.push({
958
- node,
959
- type: flattened.name
960
- });
961
- else {
962
- const exportsAssignments = exportsAssignmentsByName.get(exportName) || {
963
- nodes: [],
964
- scopes: /* @__PURE__ */ new Set()
965
- };
966
- exportsAssignments.nodes.push({
967
- node,
968
- type: flattened.name
969
- });
970
- exportsAssignments.scopes.add(scope);
971
- exportsAccessScopes.add(scope);
972
- exportsAssignmentsByName.set(exportName, exportsAssignments);
973
- if (programDepth <= 3) topLevelAssignments.add(node);
974
- }
975
- skippedNodes.add(node.left);
976
- } else for (const name of extractAssignedNames(node.left)) reassignedNames.add(name);
977
- return;
978
- case "CallExpression": {
979
- const defineCompiledEsmType = getDefineCompiledEsmType(node);
980
- if (defineCompiledEsmType) {
981
- if (programDepth === 3 && parent.type === "ExpressionStatement") {
982
- skippedNodes.add(node.arguments[0]);
983
- topLevelDefineCompiledEsmExpressions.push({
984
- node,
985
- type: defineCompiledEsmType
986
- });
987
- } else shouldWrap = true;
988
- return;
989
- }
990
- if (isDynamicRequireModulesEnabled && node.callee.object && isRequire(node.callee.object, scope) && node.callee.property.name === "resolve") {
991
- checkDynamicRequire(node.start);
992
- uses.require = true;
993
- const requireNode = node.callee.object;
994
- replacedDynamicRequires.push(requireNode);
995
- skippedNodes.add(node.callee);
996
- return;
997
- }
998
- if (!isRequireExpression(node, scope)) {
999
- const keypath = getKeypath(node.callee);
1000
- if (keypath && importedVariables.has(keypath.name)) currentConditionalNodeEnd = Infinity;
1001
- return;
1002
- }
1003
- skippedNodes.add(node.callee);
1004
- uses.require = true;
1005
- if (hasDynamicArguments(node)) {
1006
- if (isDynamicRequireModulesEnabled) checkDynamicRequire(node.start);
1007
- if (!ignoreDynamicRequires) replacedDynamicRequires.push(node.callee);
1008
- return;
1009
- }
1010
- const requireStringArg = getRequireStringArg(node);
1011
- if (!ignoreRequire(requireStringArg)) {
1012
- const usesReturnValue = parent.type !== "ExpressionStatement";
1013
- const toBeRemoved = parent.type === "ExpressionStatement" && (!currentConditionalNodeEnd || currentTryBlockEnd !== null && currentTryBlockEnd < currentConditionalNodeEnd) ? parent : node;
1014
- addRequireExpression(requireStringArg, node, scope, usesReturnValue, currentTryBlockEnd !== null, currentConditionalNodeEnd !== null, toBeRemoved);
1015
- if (parent.type === "VariableDeclarator" && parent.id.type === "Identifier") for (const name of extractAssignedNames(parent.id)) importedVariables.add(name);
1016
- }
1017
- return;
1018
- }
1019
- case "ClassBody":
1020
- classBodyDepth += 1;
1021
- return;
1022
- case "ConditionalExpression":
1023
- case "IfStatement":
1024
- if (isFalsy(node.test)) skippedNodes.add(node.consequent);
1025
- else if (isTruthy(node.test)) {
1026
- if (node.alternate) skippedNodes.add(node.alternate);
1027
- } else {
1028
- conditionalNodes.add(node.consequent);
1029
- if (node.alternate) conditionalNodes.add(node.alternate);
1030
- }
1031
- return;
1032
- case "ArrowFunctionExpression":
1033
- case "FunctionDeclaration":
1034
- case "FunctionExpression":
1035
- if (currentConditionalNodeEnd === null && !(parent.type === "CallExpression" && parent.callee === node)) currentConditionalNodeEnd = node.end;
1036
- return;
1037
- case "Identifier": {
1038
- const { name } = node;
1039
- if (!(0, import_is_reference.default)(node, parent) || scope.contains(name) || parent.type === "PropertyDefinition" && parent.key === node) return;
1040
- switch (name) {
1041
- case "require":
1042
- uses.require = true;
1043
- if (isNodeRequirePropertyAccess(parent)) return;
1044
- if (!ignoreDynamicRequires) {
1045
- if (isShorthandProperty(parent)) {
1046
- skippedNodes.add(parent.value);
1047
- magicString.prependRight(node.start, "require: ");
1048
- }
1049
- replacedDynamicRequires.push(node);
1050
- }
1051
- return;
1052
- case "module":
1053
- case "exports":
1054
- shouldWrap = true;
1055
- uses[name] = true;
1056
- return;
1057
- case "global":
1058
- uses.global = true;
1059
- if (!ignoreGlobal) replacedGlobal.push(node);
1060
- return;
1061
- case "define":
1062
- magicString.overwrite(node.start, node.end, "undefined", { storeName: true });
1063
- return;
1064
- default:
1065
- globals.add(name);
1066
- return;
1067
- }
1068
- }
1069
- case "LogicalExpression":
1070
- if (node.operator === "&&") {
1071
- if (isFalsy(node.left)) skippedNodes.add(node.right);
1072
- else if (!isTruthy(node.left)) conditionalNodes.add(node.right);
1073
- } else if (node.operator === "||") {
1074
- if (isTruthy(node.left)) skippedNodes.add(node.right);
1075
- else if (!isFalsy(node.left)) conditionalNodes.add(node.right);
1076
- }
1077
- return;
1078
- case "MemberExpression":
1079
- if (!isDynamicRequireModulesEnabled && isModuleRequire(node, scope)) {
1080
- uses.require = true;
1081
- replacedDynamicRequires.push(node);
1082
- skippedNodes.add(node.object);
1083
- skippedNodes.add(node.property);
1084
- }
1085
- return;
1086
- case "ReturnStatement":
1087
- if (lexicalDepth === 0) shouldWrap = true;
1088
- return;
1089
- case "ThisExpression":
1090
- if (lexicalDepth === 0 && !classBodyDepth) {
1091
- uses.global = true;
1092
- if (!ignoreGlobal) replacedThis.push(node);
1093
- }
1094
- return;
1095
- case "TryStatement":
1096
- if (currentTryBlockEnd === null) currentTryBlockEnd = node.block.end;
1097
- if (currentConditionalNodeEnd === null) currentConditionalNodeEnd = node.end;
1098
- return;
1099
- case "UnaryExpression":
1100
- if (node.operator === "typeof") {
1101
- const flattened = getKeypath(node.argument);
1102
- if (!flattened) return;
1103
- if (scope.contains(flattened.name)) return;
1104
- if (!isEsModule && (flattened.keypath === "module.exports" || flattened.keypath === "module" || flattened.keypath === "exports")) magicString.overwrite(node.start, node.end, `'object'`, { storeName: false });
1105
- }
1106
- return;
1107
- case "VariableDeclaration":
1108
- if (!scope.parent) topLevelDeclarations.push(node);
1109
- return;
1110
- case "TemplateElement": if (node.value.raw.includes("\n")) indentExclusionRanges.push([node.start, node.end]);
1111
- }
1112
- },
1113
- leave(node) {
1114
- programDepth -= 1;
1115
- if (node.scope) scope = scope.parent;
1116
- if (functionType.test(node.type)) lexicalDepth -= 1;
1117
- if (node.type === "ClassBody") classBodyDepth -= 1;
1118
- }
1119
- });
1120
- const nameBase = getName(id);
1121
- const exportsName = deconflict([...exportsAccessScopes], globals, nameBase);
1122
- const moduleName = deconflict([...moduleAccessScopes], globals, `${nameBase}Module`);
1123
- const requireName = deconflict([scope], globals, `require${capitalize(nameBase)}`);
1124
- const isRequiredName = deconflict([scope], globals, `hasRequired${capitalize(nameBase)}`);
1125
- const helpersName = deconflict([scope], globals, "commonjsHelpers");
1126
- const dynamicRequireName = replacedDynamicRequires.length > 0 && deconflict([scope], globals, isDynamicRequireModulesEnabled ? CREATE_COMMONJS_REQUIRE_EXPORT : COMMONJS_REQUIRE_EXPORT);
1127
- const deconflictedExportNames = Object.create(null);
1128
- for (const [exportName, { scopes }] of exportsAssignmentsByName) deconflictedExportNames[exportName] = deconflict([...scopes], globals, exportName);
1129
- for (const node of replacedGlobal) magicString.overwrite(node.start, node.end, `${helpersName}.commonjsGlobal`, { storeName: true });
1130
- for (const node of replacedThis) magicString.overwrite(node.start, node.end, exportsName, { storeName: true });
1131
- for (const node of replacedDynamicRequires) magicString.overwrite(node.start, node.end, isDynamicRequireModulesEnabled ? `${dynamicRequireName}(${JSON.stringify(virtualDynamicRequirePath)})` : dynamicRequireName, {
1132
- contentOnly: true,
1133
- storeName: true
1134
- });
1135
- shouldWrap = !isEsModule && (shouldWrap || uses.exports && moduleExportsAssignments.length > 0);
1136
- if (!(shouldWrap || isRequired || needsRequireWrapper || uses.module || uses.exports || uses.require || topLevelDefineCompiledEsmExpressions.length > 0) && (ignoreGlobal || !uses.global)) return { meta: { commonjs: { isCommonJS: false } } };
1137
- let leadingComment = "";
1138
- if (code.startsWith("/*")) {
1139
- const commentEnd = code.indexOf("*/", 2) + 2;
1140
- leadingComment = `${code.slice(0, commentEnd)}\n`;
1141
- magicString.remove(0, commentEnd).trim();
1142
- }
1143
- let shebang = "";
1144
- if (code.startsWith("#!")) {
1145
- const shebangEndPosition = code.indexOf("\n") + 1;
1146
- shebang = code.slice(0, shebangEndPosition);
1147
- magicString.remove(0, shebangEndPosition).trim();
1148
- }
1149
- const exportMode = isEsModule ? "none" : shouldWrap ? uses.module ? "module" : "exports" : firstTopLevelModuleExportsAssignment ? exportsAssignmentsByName.size === 0 && topLevelDefineCompiledEsmExpressions.length === 0 ? "replace" : "module" : moduleExportsAssignments.length === 0 ? "exports" : "module";
1150
- const exportedExportsName = exportMode === "module" ? deconflict([], globals, `${nameBase}Exports`) : exportsName;
1151
- const importBlock = await rewriteRequireExpressionsAndGetImportBlock(magicString, topLevelDeclarations, reassignedNames, helpersName, dynamicRequireName, moduleName, exportsName, id, exportMode, resolveRequireSourcesAndUpdateMeta, needsRequireWrapper, isEsModule, isDynamicRequireModulesEnabled, getIgnoreTryCatchRequireStatementMode, commonjsMeta);
1152
- const usesRequireWrapper = commonjsMeta.isCommonJS === IS_WRAPPED_COMMONJS;
1153
- const exportBlock = isEsModule ? "" : rewriteExportsAndGetExportsBlock(magicString, moduleName, exportsName, exportedExportsName, shouldWrap, moduleExportsAssignments, firstTopLevelModuleExportsAssignment, exportsAssignmentsByName, topLevelAssignments, topLevelDefineCompiledEsmExpressions, deconflictedExportNames, code, helpersName, exportMode, defaultIsModuleExports, usesRequireWrapper, requireName);
1154
- if (shouldWrap) wrapCode(magicString, uses, moduleName, exportsName, indentExclusionRanges);
1155
- if (usesRequireWrapper) {
1156
- magicString.trim().indent(" ", { exclude: indentExclusionRanges });
1157
- const exported = exportMode === "module" ? `${moduleName}.exports` : exportsName;
1158
- magicString.prepend(`var ${isRequiredName};
1159
-
1160
- function ${requireName} () {
1161
- \tif (${isRequiredName}) return ${exported};
1162
- \t${isRequiredName} = 1;
1163
- `).append(`
1164
- \treturn ${exported};
1165
- }`);
1166
- if (exportMode === "replace") magicString.prepend(`var ${exportsName};\n`);
1167
- }
1168
- magicString.trim().prepend(shebang + leadingComment + importBlock).append(exportBlock);
1169
- return {
1170
- code: magicString.toString(),
1171
- map: sourceMap ? magicString.generateMap() : null,
1172
- syntheticNamedExports: isEsModule || usesRequireWrapper ? false : "__moduleExports",
1173
- meta: { commonjs: {
1174
- ...commonjsMeta,
1175
- shebang
1176
- } }
1177
- };
1178
- }
1179
- const PLUGIN_NAME = "commonjs";
1180
- function commonjs(options = {}) {
1181
- const { ignoreGlobal, ignoreDynamicRequires, requireReturnsDefault: requireReturnsDefaultOption, defaultIsModuleExports: defaultIsModuleExportsOption, esmExternals, requireNodeBuiltins = false } = options;
1182
- const extensions = options.extensions || [".js"];
1183
- const filter = createFilter(options.include, options.exclude);
1184
- const isPossibleCjsId = (id) => {
1185
- const extName = extname(id);
1186
- return extName === ".cjs" || extensions.includes(extName) && filter(id);
1187
- };
1188
- const { strictRequiresFilter, detectCyclesAndConditional } = getStrictRequiresFilter(options);
1189
- const getRequireReturnsDefault = typeof requireReturnsDefaultOption === "function" ? requireReturnsDefaultOption : () => requireReturnsDefaultOption;
1190
- let esmExternalIds;
1191
- const isEsmExternal = typeof esmExternals === "function" ? esmExternals : Array.isArray(esmExternals) ? (esmExternalIds = new Set(esmExternals), (id) => esmExternalIds.has(id)) : () => esmExternals;
1192
- const getDefaultIsModuleExports = typeof defaultIsModuleExportsOption === "function" ? defaultIsModuleExportsOption : () => typeof defaultIsModuleExportsOption === "boolean" ? defaultIsModuleExportsOption : "auto";
1193
- const dynamicRequireRoot = typeof options.dynamicRequireRoot === "string" ? resolve(options.dynamicRequireRoot) : process.cwd();
1194
- const { commonDir, dynamicRequireModules } = getDynamicRequireModules(options.dynamicRequireTargets, dynamicRequireRoot);
1195
- const isDynamicRequireModulesEnabled = dynamicRequireModules.size > 0;
1196
- const ignoreRequire = typeof options.ignore === "function" ? options.ignore : Array.isArray(options.ignore) ? (id) => options.ignore.includes(id) : () => false;
1197
- const getIgnoreTryCatchRequireStatementMode = (id) => {
1198
- const mode = typeof options.ignoreTryCatch === "function" ? options.ignoreTryCatch(id) : Array.isArray(options.ignoreTryCatch) ? options.ignoreTryCatch.includes(id) : typeof options.ignoreTryCatch !== "undefined" ? options.ignoreTryCatch : true;
1199
- return {
1200
- canConvertRequire: mode !== "remove" && mode !== true,
1201
- shouldRemoveRequire: mode === "remove"
1202
- };
1203
- };
1204
- const { currentlyResolving, resolveId } = getResolveId(extensions, isPossibleCjsId);
1205
- const sourceMap = options.sourceMap !== false;
1206
- let requireResolver;
1207
- function transformAndCheckExports(code, id) {
1208
- const normalizedId = normalizePathSlashes(id);
1209
- const { isEsModule, hasDefaultExport, hasNamedExports, ast } = analyzeTopLevelStatements(this.parse, code, id);
1210
- const commonjsMeta = this.getModuleInfo(id).meta.commonjs || {};
1211
- if (hasDefaultExport) commonjsMeta.hasDefaultExport = true;
1212
- if (hasNamedExports) commonjsMeta.hasNamedExports = true;
1213
- if (!dynamicRequireModules.has(normalizedId) && (!(hasCjsKeywords(code, ignoreGlobal) || requireResolver.isRequiredId(id)) || isEsModule && !options.transformMixedEsModules)) {
1214
- commonjsMeta.isCommonJS = false;
1215
- return { meta: { commonjs: commonjsMeta } };
1216
- }
1217
- const needsRequireWrapper = !isEsModule && (dynamicRequireModules.has(normalizedId) || strictRequiresFilter(id));
1218
- const checkDynamicRequire = (position) => {
1219
- const normalizedDynamicRequireRoot = normalizePathSlashes(dynamicRequireRoot);
1220
- if (normalizedId.indexOf(normalizedDynamicRequireRoot) !== 0) this.error({
1221
- code: "DYNAMIC_REQUIRE_OUTSIDE_ROOT",
1222
- normalizedId,
1223
- normalizedDynamicRequireRoot,
1224
- message: `"${normalizedId}" contains dynamic require statements but it is not within the current dynamicRequireRoot "${normalizedDynamicRequireRoot}". You should set dynamicRequireRoot to "${dirname(normalizedId)}" or one of its parent directories.`
1225
- }, position);
1226
- };
1227
- return transformCommonjs(this.parse, code, id, isEsModule, ignoreGlobal || isEsModule, ignoreRequire, ignoreDynamicRequires && !isDynamicRequireModulesEnabled, getIgnoreTryCatchRequireStatementMode, sourceMap, isDynamicRequireModulesEnabled, dynamicRequireModules, commonDir, ast, getDefaultIsModuleExports(id), needsRequireWrapper, requireResolver.resolveRequireSourcesAndUpdateMeta(this), requireResolver.isRequiredId(id), checkDynamicRequire, commonjsMeta);
1228
- }
1229
- return {
1230
- name: PLUGIN_NAME,
1231
- version: version$1,
1232
- options(rawOptions) {
1233
- const plugins = Array.isArray(rawOptions.plugins) ? [...rawOptions.plugins] : rawOptions.plugins ? [rawOptions.plugins] : [];
1234
- plugins.unshift({
1235
- name: "commonjs--resolver",
1236
- resolveId
1237
- });
1238
- return {
1239
- ...rawOptions,
1240
- plugins
1241
- };
1242
- },
1243
- buildStart({ plugins }) {
1244
- validateVersion$1(this.meta.rollupVersion, peerDependencies$1.rollup, "rollup");
1245
- const nodeResolve$1 = plugins.find(({ name }) => name === "node-resolve");
1246
- if (nodeResolve$1) validateVersion$1(nodeResolve$1.version, "^13.0.6", "@rollup/plugin-node-resolve");
1247
- if (options.namedExports != null) this.warn("The namedExports option from \"@rollup/plugin-commonjs\" is deprecated. Named exports are now handled automatically.");
1248
- requireResolver = getRequireResolver(extensions, detectCyclesAndConditional, currentlyResolving, requireNodeBuiltins);
1249
- },
1250
- buildEnd() {
1251
- if (options.strictRequires === "debug") {
1252
- const wrappedIds = requireResolver.getWrappedIds();
1253
- if (wrappedIds.length) this.warn({
1254
- code: "WRAPPED_IDS",
1255
- ids: wrappedIds,
1256
- message: `The commonjs plugin automatically wrapped the following files:\n[\n${wrappedIds.map((id) => `\t${JSON.stringify(relative(process.cwd(), id))}`).join(",\n")}\n]`
1257
- });
1258
- else this.warn({
1259
- code: "WRAPPED_IDS",
1260
- ids: wrappedIds,
1261
- message: "The commonjs plugin did not wrap any files."
1262
- });
1263
- }
1264
- },
1265
- async load(id) {
1266
- if (id === HELPERS_ID) return getHelpersModule();
1267
- if (isWrappedId(id, MODULE_SUFFIX)) {
1268
- const name = getName(unwrapId(id, MODULE_SUFFIX));
1269
- return {
1270
- code: `var ${name} = {exports: {}}; export {${name} as __module}`,
1271
- meta: { commonjs: { isCommonJS: false } }
1272
- };
1273
- }
1274
- if (isWrappedId(id, EXPORTS_SUFFIX)) {
1275
- const name = getName(unwrapId(id, EXPORTS_SUFFIX));
1276
- return {
1277
- code: `var ${name} = {}; export {${name} as __exports}`,
1278
- meta: { commonjs: { isCommonJS: false } }
1279
- };
1280
- }
1281
- if (isWrappedId(id, EXTERNAL_SUFFIX)) {
1282
- const actualId = unwrapId(id, EXTERNAL_SUFFIX);
1283
- if (requireNodeBuiltins === true && actualId.startsWith("node:")) return getExternalBuiltinRequireProxy(actualId);
1284
- return getUnknownRequireProxy(actualId, isEsmExternal(actualId) ? getRequireReturnsDefault(actualId) : true);
1285
- }
1286
- if (id.endsWith(ENTRY_SUFFIX)) {
1287
- const acutalId = id.slice(0, -15);
1288
- const { meta: { commonjs: commonjsMeta } } = this.getModuleInfo(acutalId);
1289
- const shebang = commonjsMeta?.shebang ?? "";
1290
- return getEntryProxy(acutalId, getDefaultIsModuleExports(acutalId), this.getModuleInfo, shebang);
1291
- }
1292
- if (isWrappedId(id, ES_IMPORT_SUFFIX)) {
1293
- const actualId = unwrapId(id, ES_IMPORT_SUFFIX);
1294
- return getEsImportProxy(actualId, getDefaultIsModuleExports(actualId), (await this.load({ id: actualId })).moduleSideEffects);
1295
- }
1296
- if (id === DYNAMIC_MODULES_ID) return getDynamicModuleRegistry(isDynamicRequireModulesEnabled, dynamicRequireModules, commonDir, ignoreDynamicRequires);
1297
- if (isWrappedId(id, PROXY_SUFFIX)) {
1298
- const actualId = unwrapId(id, PROXY_SUFFIX);
1299
- return getStaticRequireProxy(actualId, getRequireReturnsDefault(actualId), this.load);
1300
- }
1301
- return null;
1302
- },
1303
- shouldTransformCachedModule(...args) {
1304
- return requireResolver.shouldTransformCachedModule.call(this, ...args);
1305
- },
1306
- transform(code, id) {
1307
- if (!isPossibleCjsId(id)) return null;
1308
- try {
1309
- return transformAndCheckExports.call(this, code, id);
1310
- } catch (err) {
1311
- return this.error(err, err.pos);
1312
- }
1313
- }
1314
- };
1315
- }
1316
-
1317
- //#endregion
1318
- //#region node_modules/.pnpm/@rollup+plugin-json@6.1.0_rollup@4.55.2/node_modules/@rollup/plugin-json/dist/es/index.js
1319
- function json(options) {
1320
- if (options === void 0) options = {};
1321
- var filter = createFilter(options.include, options.exclude);
1322
- var indent = "indent" in options ? options.indent : " ";
1323
- return {
1324
- name: "json",
1325
- transform: function transform(code, id) {
1326
- if (id.slice(-5) !== ".json" || !filter(id)) return null;
1327
- try {
1328
- return {
1329
- code: dataToEsm(JSON.parse(code), {
1330
- preferConst: options.preferConst,
1331
- compact: options.compact,
1332
- namedExports: options.namedExports,
1333
- includeArbitraryNames: options.includeArbitraryNames,
1334
- indent
1335
- }),
1336
- map: { mappings: "" }
1337
- };
1338
- } catch (err) {
1339
- this.error({
1340
- message: "Could not parse JSON file",
1341
- id,
1342
- cause: err
1343
- });
1344
- return null;
1345
- }
1346
- }
1347
- };
1348
- }
1349
-
1350
- //#endregion
1351
- //#region node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js
1352
- var require_cjs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1353
- var isMergeableObject = function isMergeableObject(value) {
1354
- return isNonNullObject(value) && !isSpecial(value);
1355
- };
1356
- function isNonNullObject(value) {
1357
- return !!value && typeof value === "object";
1358
- }
1359
- function isSpecial(value) {
1360
- var stringValue = Object.prototype.toString.call(value);
1361
- return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
1362
- }
1363
- var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for ? Symbol.for("react.element") : 60103;
1364
- function isReactElement(value) {
1365
- return value.$$typeof === REACT_ELEMENT_TYPE;
1366
- }
1367
- function emptyTarget(val) {
1368
- return Array.isArray(val) ? [] : {};
1369
- }
1370
- function cloneUnlessOtherwiseSpecified(value, options) {
1371
- return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value;
1372
- }
1373
- function defaultArrayMerge(target, source, options) {
1374
- return target.concat(source).map(function(element) {
1375
- return cloneUnlessOtherwiseSpecified(element, options);
1376
- });
1377
- }
1378
- function getMergeFunction(key, options) {
1379
- if (!options.customMerge) return deepmerge;
1380
- var customMerge = options.customMerge(key);
1381
- return typeof customMerge === "function" ? customMerge : deepmerge;
1382
- }
1383
- function getEnumerableOwnPropertySymbols(target) {
1384
- return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
1385
- return Object.propertyIsEnumerable.call(target, symbol);
1386
- }) : [];
1387
- }
1388
- function getKeys(target) {
1389
- return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
1390
- }
1391
- function propertyIsOnObject(object, property) {
1392
- try {
1393
- return property in object;
1394
- } catch (_) {
1395
- return false;
1396
- }
1397
- }
1398
- function propertyIsUnsafe(target, key) {
1399
- return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
1400
- }
1401
- function mergeObject(target, source, options) {
1402
- var destination = {};
1403
- if (options.isMergeableObject(target)) getKeys(target).forEach(function(key) {
1404
- destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
1405
- });
1406
- getKeys(source).forEach(function(key) {
1407
- if (propertyIsUnsafe(target, key)) return;
1408
- if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
1409
- else destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
1410
- });
1411
- return destination;
1412
- }
1413
- function deepmerge(target, source, options) {
1414
- options = options || {};
1415
- options.arrayMerge = options.arrayMerge || defaultArrayMerge;
1416
- options.isMergeableObject = options.isMergeableObject || isMergeableObject;
1417
- options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
1418
- var sourceIsArray = Array.isArray(source);
1419
- if (!(sourceIsArray === Array.isArray(target))) return cloneUnlessOtherwiseSpecified(source, options);
1420
- else if (sourceIsArray) return options.arrayMerge(target, source, options);
1421
- else return mergeObject(target, source, options);
1422
- }
1423
- deepmerge.all = function deepmergeAll(array, options) {
1424
- if (!Array.isArray(array)) throw new Error("first argument should be an array");
1425
- return array.reduce(function(prev, next) {
1426
- return deepmerge(prev, next, options);
1427
- }, {});
1428
- };
1429
- var deepmerge_1 = deepmerge;
1430
- module.exports = deepmerge_1;
1431
- }));
1432
-
1433
- //#endregion
1434
- //#region node_modules/.pnpm/is-module@1.0.0/node_modules/is-module/index.js
1435
- var require_is_module = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1436
- var ES6ImportExportRegExp = /(?:^\s*|[}{\(\);,\n]\s*)(import\s+['"]|(import|module)\s+[^"'\(\)\n;]+\s+from\s+['"]|export\s+(\*|\{|default|function|var|const|let|[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*))/;
1437
- var ES6AliasRegExp = /(?:^\s*|[}{\(\);,\n]\s*)(export\s*\*\s*from\s*(?:'([^']+)'|"([^"]+)"))/;
1438
- module.exports = function(sauce) {
1439
- return ES6ImportExportRegExp.test(sauce) || ES6AliasRegExp.test(sauce);
1440
- };
1441
- }));
1442
-
1443
- //#endregion
1444
- //#region node_modules/.pnpm/resolve@1.22.11/node_modules/resolve/lib/homedir.js
1445
- var require_homedir = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1446
- var os = __require("os");
1447
- module.exports = os.homedir || function homedir() {
1448
- var home = process.env.HOME;
1449
- var user = process.env.LOGNAME || process.env.USER || process.env.LNAME || process.env.USERNAME;
1450
- if (process.platform === "win32") return process.env.USERPROFILE || process.env.HOMEDRIVE + process.env.HOMEPATH || home || null;
1451
- if (process.platform === "darwin") return home || (user ? "/Users/" + user : null);
1452
- if (process.platform === "linux") return home || (process.getuid() === 0 ? "/root" : user ? "/home/" + user : null);
1453
- return home || null;
1454
- };
1455
- }));
1456
-
1457
- //#endregion
1458
- //#region node_modules/.pnpm/resolve@1.22.11/node_modules/resolve/lib/caller.js
1459
- var require_caller = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1460
- module.exports = function() {
1461
- var origPrepareStackTrace = Error.prepareStackTrace;
1462
- Error.prepareStackTrace = function(_, stack$1) {
1463
- return stack$1;
1464
- };
1465
- var stack = (/* @__PURE__ */ new Error()).stack;
1466
- Error.prepareStackTrace = origPrepareStackTrace;
1467
- return stack[2].getFileName();
1468
- };
1469
- }));
1470
-
1471
- //#endregion
1472
- //#region node_modules/.pnpm/path-parse@1.0.7/node_modules/path-parse/index.js
1473
- var require_path_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1474
- var isWindows = process.platform === "win32";
1475
- var splitWindowsRe = /^(((?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?[\\\/]?)(?:[^\\\/]*[\\\/])*)((\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))[\\\/]*$/;
1476
- var win32 = {};
1477
- function win32SplitPath(filename) {
1478
- return splitWindowsRe.exec(filename).slice(1);
1479
- }
1480
- win32.parse = function(pathString) {
1481
- if (typeof pathString !== "string") throw new TypeError("Parameter 'pathString' must be a string, not " + typeof pathString);
1482
- var allParts = win32SplitPath(pathString);
1483
- if (!allParts || allParts.length !== 5) throw new TypeError("Invalid path '" + pathString + "'");
1484
- return {
1485
- root: allParts[1],
1486
- dir: allParts[0] === allParts[1] ? allParts[0] : allParts[0].slice(0, -1),
1487
- base: allParts[2],
1488
- ext: allParts[4],
1489
- name: allParts[3]
1490
- };
1491
- };
1492
- var splitPathRe = /^((\/?)(?:[^\/]*\/)*)((\.{1,2}|[^\/]+?|)(\.[^.\/]*|))[\/]*$/;
1493
- var posix = {};
1494
- function posixSplitPath(filename) {
1495
- return splitPathRe.exec(filename).slice(1);
1496
- }
1497
- posix.parse = function(pathString) {
1498
- if (typeof pathString !== "string") throw new TypeError("Parameter 'pathString' must be a string, not " + typeof pathString);
1499
- var allParts = posixSplitPath(pathString);
1500
- if (!allParts || allParts.length !== 5) throw new TypeError("Invalid path '" + pathString + "'");
1501
- return {
1502
- root: allParts[1],
1503
- dir: allParts[0].slice(0, -1),
1504
- base: allParts[2],
1505
- ext: allParts[4],
1506
- name: allParts[3]
1507
- };
1508
- };
1509
- if (isWindows) module.exports = win32.parse;
1510
- else module.exports = posix.parse;
1511
- module.exports.posix = posix.parse;
1512
- module.exports.win32 = win32.parse;
1513
- }));
1514
-
1515
- //#endregion
1516
- //#region node_modules/.pnpm/resolve@1.22.11/node_modules/resolve/lib/node-modules-paths.js
1517
- var require_node_modules_paths = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1518
- var path$3 = __require("path");
1519
- var parse = path$3.parse || require_path_parse();
1520
- var driveLetterRegex = /^([A-Za-z]:)/;
1521
- var uncPathRegex = /^\\\\/;
1522
- var getNodeModulesDirs = function getNodeModulesDirs(absoluteStart, modules) {
1523
- var prefix = "/";
1524
- if (driveLetterRegex.test(absoluteStart)) prefix = "";
1525
- else if (uncPathRegex.test(absoluteStart)) prefix = "\\\\";
1526
- var paths = [absoluteStart];
1527
- var parsed = parse(absoluteStart);
1528
- while (parsed.dir !== paths[paths.length - 1]) {
1529
- paths.push(parsed.dir);
1530
- parsed = parse(parsed.dir);
1531
- }
1532
- return paths.reduce(function(dirs, aPath) {
1533
- return dirs.concat(modules.map(function(moduleDir) {
1534
- return path$3.resolve(prefix, aPath, moduleDir);
1535
- }));
1536
- }, []);
1537
- };
1538
- module.exports = function nodeModulesPaths(start, opts, request) {
1539
- var modules = opts && opts.moduleDirectory ? [].concat(opts.moduleDirectory) : ["node_modules"];
1540
- if (opts && typeof opts.paths === "function") return opts.paths(request, start, function() {
1541
- return getNodeModulesDirs(start, modules);
1542
- }, opts);
1543
- var dirs = getNodeModulesDirs(start, modules);
1544
- return opts && opts.paths ? dirs.concat(opts.paths) : dirs;
1545
- };
1546
- }));
1547
-
1548
- //#endregion
1549
- //#region node_modules/.pnpm/resolve@1.22.11/node_modules/resolve/lib/normalize-options.js
1550
- var require_normalize_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1551
- module.exports = function(x, opts) {
1552
- /**
1553
- * This file is purposefully a passthrough. It's expected that third-party
1554
- * environments will override it at runtime in order to inject special logic
1555
- * into `resolve` (by manipulating the options). One such example is the PnP
1556
- * code path in Yarn.
1557
- */
1558
- return opts || {};
1559
- };
1560
- }));
1561
-
1562
- //#endregion
1563
- //#region node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/implementation.js
1564
- var require_implementation = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1565
- var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
1566
- var toStr = Object.prototype.toString;
1567
- var max = Math.max;
1568
- var funcType = "[object Function]";
1569
- var concatty = function concatty(a, b) {
1570
- var arr = [];
1571
- for (var i = 0; i < a.length; i += 1) arr[i] = a[i];
1572
- for (var j = 0; j < b.length; j += 1) arr[j + a.length] = b[j];
1573
- return arr;
1574
- };
1575
- var slicy = function slicy(arrLike, offset) {
1576
- var arr = [];
1577
- for (var i = offset || 0, j = 0; i < arrLike.length; i += 1, j += 1) arr[j] = arrLike[i];
1578
- return arr;
1579
- };
1580
- var joiny = function(arr, joiner) {
1581
- var str = "";
1582
- for (var i = 0; i < arr.length; i += 1) {
1583
- str += arr[i];
1584
- if (i + 1 < arr.length) str += joiner;
1585
- }
1586
- return str;
1587
- };
1588
- module.exports = function bind(that) {
1589
- var target = this;
1590
- if (typeof target !== "function" || toStr.apply(target) !== funcType) throw new TypeError(ERROR_MESSAGE + target);
1591
- var args = slicy(arguments, 1);
1592
- var bound;
1593
- var binder = function() {
1594
- if (this instanceof bound) {
1595
- var result = target.apply(this, concatty(args, arguments));
1596
- if (Object(result) === result) return result;
1597
- return this;
1598
- }
1599
- return target.apply(that, concatty(args, arguments));
1600
- };
1601
- var boundLength = max(0, target.length - args.length);
1602
- var boundArgs = [];
1603
- for (var i = 0; i < boundLength; i++) boundArgs[i] = "$" + i;
1604
- bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
1605
- if (target.prototype) {
1606
- var Empty = function Empty$1() {};
1607
- Empty.prototype = target.prototype;
1608
- bound.prototype = new Empty();
1609
- Empty.prototype = null;
1610
- }
1611
- return bound;
1612
- };
1613
- }));
1614
-
1615
- //#endregion
1616
- //#region node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/index.js
1617
- var require_function_bind = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1618
- var implementation = require_implementation();
1619
- module.exports = Function.prototype.bind || implementation;
1620
- }));
1621
-
1622
- //#endregion
1623
- //#region node_modules/.pnpm/hasown@2.0.2/node_modules/hasown/index.js
1624
- var require_hasown = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1625
- var call = Function.prototype.call;
1626
- var $hasOwn = Object.prototype.hasOwnProperty;
1627
- var bind = require_function_bind();
1628
- /** @type {import('.')} */
1629
- module.exports = bind.call(call, $hasOwn);
1630
- }));
1631
-
1632
- //#endregion
1633
- //#region node_modules/.pnpm/is-core-module@2.16.1/node_modules/is-core-module/core.json
1634
- var require_core$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1635
- module.exports = {
1636
- "assert": true,
1637
- "node:assert": [">= 14.18 && < 15", ">= 16"],
1638
- "assert/strict": ">= 15",
1639
- "node:assert/strict": ">= 16",
1640
- "async_hooks": ">= 8",
1641
- "node:async_hooks": [">= 14.18 && < 15", ">= 16"],
1642
- "buffer_ieee754": ">= 0.5 && < 0.9.7",
1643
- "buffer": true,
1644
- "node:buffer": [">= 14.18 && < 15", ">= 16"],
1645
- "child_process": true,
1646
- "node:child_process": [">= 14.18 && < 15", ">= 16"],
1647
- "cluster": ">= 0.5",
1648
- "node:cluster": [">= 14.18 && < 15", ">= 16"],
1649
- "console": true,
1650
- "node:console": [">= 14.18 && < 15", ">= 16"],
1651
- "constants": true,
1652
- "node:constants": [">= 14.18 && < 15", ">= 16"],
1653
- "crypto": true,
1654
- "node:crypto": [">= 14.18 && < 15", ">= 16"],
1655
- "_debug_agent": ">= 1 && < 8",
1656
- "_debugger": "< 8",
1657
- "dgram": true,
1658
- "node:dgram": [">= 14.18 && < 15", ">= 16"],
1659
- "diagnostics_channel": [">= 14.17 && < 15", ">= 15.1"],
1660
- "node:diagnostics_channel": [">= 14.18 && < 15", ">= 16"],
1661
- "dns": true,
1662
- "node:dns": [">= 14.18 && < 15", ">= 16"],
1663
- "dns/promises": ">= 15",
1664
- "node:dns/promises": ">= 16",
1665
- "domain": ">= 0.7.12",
1666
- "node:domain": [">= 14.18 && < 15", ">= 16"],
1667
- "events": true,
1668
- "node:events": [">= 14.18 && < 15", ">= 16"],
1669
- "freelist": "< 6",
1670
- "fs": true,
1671
- "node:fs": [">= 14.18 && < 15", ">= 16"],
1672
- "fs/promises": [">= 10 && < 10.1", ">= 14"],
1673
- "node:fs/promises": [">= 14.18 && < 15", ">= 16"],
1674
- "_http_agent": ">= 0.11.1",
1675
- "node:_http_agent": [">= 14.18 && < 15", ">= 16"],
1676
- "_http_client": ">= 0.11.1",
1677
- "node:_http_client": [">= 14.18 && < 15", ">= 16"],
1678
- "_http_common": ">= 0.11.1",
1679
- "node:_http_common": [">= 14.18 && < 15", ">= 16"],
1680
- "_http_incoming": ">= 0.11.1",
1681
- "node:_http_incoming": [">= 14.18 && < 15", ">= 16"],
1682
- "_http_outgoing": ">= 0.11.1",
1683
- "node:_http_outgoing": [">= 14.18 && < 15", ">= 16"],
1684
- "_http_server": ">= 0.11.1",
1685
- "node:_http_server": [">= 14.18 && < 15", ">= 16"],
1686
- "http": true,
1687
- "node:http": [">= 14.18 && < 15", ">= 16"],
1688
- "http2": ">= 8.8",
1689
- "node:http2": [">= 14.18 && < 15", ">= 16"],
1690
- "https": true,
1691
- "node:https": [">= 14.18 && < 15", ">= 16"],
1692
- "inspector": ">= 8",
1693
- "node:inspector": [">= 14.18 && < 15", ">= 16"],
1694
- "inspector/promises": [">= 19"],
1695
- "node:inspector/promises": [">= 19"],
1696
- "_linklist": "< 8",
1697
- "module": true,
1698
- "node:module": [">= 14.18 && < 15", ">= 16"],
1699
- "net": true,
1700
- "node:net": [">= 14.18 && < 15", ">= 16"],
1701
- "node-inspect/lib/_inspect": ">= 7.6 && < 12",
1702
- "node-inspect/lib/internal/inspect_client": ">= 7.6 && < 12",
1703
- "node-inspect/lib/internal/inspect_repl": ">= 7.6 && < 12",
1704
- "os": true,
1705
- "node:os": [">= 14.18 && < 15", ">= 16"],
1706
- "path": true,
1707
- "node:path": [">= 14.18 && < 15", ">= 16"],
1708
- "path/posix": ">= 15.3",
1709
- "node:path/posix": ">= 16",
1710
- "path/win32": ">= 15.3",
1711
- "node:path/win32": ">= 16",
1712
- "perf_hooks": ">= 8.5",
1713
- "node:perf_hooks": [">= 14.18 && < 15", ">= 16"],
1714
- "process": ">= 1",
1715
- "node:process": [">= 14.18 && < 15", ">= 16"],
1716
- "punycode": ">= 0.5",
1717
- "node:punycode": [">= 14.18 && < 15", ">= 16"],
1718
- "querystring": true,
1719
- "node:querystring": [">= 14.18 && < 15", ">= 16"],
1720
- "readline": true,
1721
- "node:readline": [">= 14.18 && < 15", ">= 16"],
1722
- "readline/promises": ">= 17",
1723
- "node:readline/promises": ">= 17",
1724
- "repl": true,
1725
- "node:repl": [">= 14.18 && < 15", ">= 16"],
1726
- "node:sea": [">= 20.12 && < 21", ">= 21.7"],
1727
- "smalloc": ">= 0.11.5 && < 3",
1728
- "node:sqlite": [">= 22.13 && < 23", ">= 23.4"],
1729
- "_stream_duplex": ">= 0.9.4",
1730
- "node:_stream_duplex": [">= 14.18 && < 15", ">= 16"],
1731
- "_stream_transform": ">= 0.9.4",
1732
- "node:_stream_transform": [">= 14.18 && < 15", ">= 16"],
1733
- "_stream_wrap": ">= 1.4.1",
1734
- "node:_stream_wrap": [">= 14.18 && < 15", ">= 16"],
1735
- "_stream_passthrough": ">= 0.9.4",
1736
- "node:_stream_passthrough": [">= 14.18 && < 15", ">= 16"],
1737
- "_stream_readable": ">= 0.9.4",
1738
- "node:_stream_readable": [">= 14.18 && < 15", ">= 16"],
1739
- "_stream_writable": ">= 0.9.4",
1740
- "node:_stream_writable": [">= 14.18 && < 15", ">= 16"],
1741
- "stream": true,
1742
- "node:stream": [">= 14.18 && < 15", ">= 16"],
1743
- "stream/consumers": ">= 16.7",
1744
- "node:stream/consumers": ">= 16.7",
1745
- "stream/promises": ">= 15",
1746
- "node:stream/promises": ">= 16",
1747
- "stream/web": ">= 16.5",
1748
- "node:stream/web": ">= 16.5",
1749
- "string_decoder": true,
1750
- "node:string_decoder": [">= 14.18 && < 15", ">= 16"],
1751
- "sys": [">= 0.4 && < 0.7", ">= 0.8"],
1752
- "node:sys": [">= 14.18 && < 15", ">= 16"],
1753
- "test/reporters": ">= 19.9 && < 20.2",
1754
- "node:test/reporters": [
1755
- ">= 18.17 && < 19",
1756
- ">= 19.9",
1757
- ">= 20"
1758
- ],
1759
- "test/mock_loader": ">= 22.3 && < 22.7",
1760
- "node:test/mock_loader": ">= 22.3 && < 22.7",
1761
- "node:test": [">= 16.17 && < 17", ">= 18"],
1762
- "timers": true,
1763
- "node:timers": [">= 14.18 && < 15", ">= 16"],
1764
- "timers/promises": ">= 15",
1765
- "node:timers/promises": ">= 16",
1766
- "_tls_common": ">= 0.11.13",
1767
- "node:_tls_common": [">= 14.18 && < 15", ">= 16"],
1768
- "_tls_legacy": ">= 0.11.3 && < 10",
1769
- "_tls_wrap": ">= 0.11.3",
1770
- "node:_tls_wrap": [">= 14.18 && < 15", ">= 16"],
1771
- "tls": true,
1772
- "node:tls": [">= 14.18 && < 15", ">= 16"],
1773
- "trace_events": ">= 10",
1774
- "node:trace_events": [">= 14.18 && < 15", ">= 16"],
1775
- "tty": true,
1776
- "node:tty": [">= 14.18 && < 15", ">= 16"],
1777
- "url": true,
1778
- "node:url": [">= 14.18 && < 15", ">= 16"],
1779
- "util": true,
1780
- "node:util": [">= 14.18 && < 15", ">= 16"],
1781
- "util/types": ">= 15.3",
1782
- "node:util/types": ">= 16",
1783
- "v8/tools/arguments": ">= 10 && < 12",
1784
- "v8/tools/codemap": [">= 4.4 && < 5", ">= 5.2 && < 12"],
1785
- "v8/tools/consarray": [">= 4.4 && < 5", ">= 5.2 && < 12"],
1786
- "v8/tools/csvparser": [">= 4.4 && < 5", ">= 5.2 && < 12"],
1787
- "v8/tools/logreader": [">= 4.4 && < 5", ">= 5.2 && < 12"],
1788
- "v8/tools/profile_view": [">= 4.4 && < 5", ">= 5.2 && < 12"],
1789
- "v8/tools/splaytree": [">= 4.4 && < 5", ">= 5.2 && < 12"],
1790
- "v8": ">= 1",
1791
- "node:v8": [">= 14.18 && < 15", ">= 16"],
1792
- "vm": true,
1793
- "node:vm": [">= 14.18 && < 15", ">= 16"],
1794
- "wasi": [
1795
- ">= 13.4 && < 13.5",
1796
- ">= 18.17 && < 19",
1797
- ">= 20"
1798
- ],
1799
- "node:wasi": [">= 18.17 && < 19", ">= 20"],
1800
- "worker_threads": ">= 11.7",
1801
- "node:worker_threads": [">= 14.18 && < 15", ">= 16"],
1802
- "zlib": ">= 0.5",
1803
- "node:zlib": [">= 14.18 && < 15", ">= 16"]
1804
- };
1805
- }));
1806
-
1807
- //#endregion
1808
- //#region node_modules/.pnpm/is-core-module@2.16.1/node_modules/is-core-module/index.js
1809
- var require_is_core_module = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1810
- var hasOwn = require_hasown();
1811
- function specifierIncluded(current, specifier) {
1812
- var nodeParts = current.split(".");
1813
- var parts = specifier.split(" ");
1814
- var op = parts.length > 1 ? parts[0] : "=";
1815
- var versionParts = (parts.length > 1 ? parts[1] : parts[0]).split(".");
1816
- for (var i = 0; i < 3; ++i) {
1817
- var cur = parseInt(nodeParts[i] || 0, 10);
1818
- var ver = parseInt(versionParts[i] || 0, 10);
1819
- if (cur === ver) continue;
1820
- if (op === "<") return cur < ver;
1821
- if (op === ">=") return cur >= ver;
1822
- return false;
1823
- }
1824
- return op === ">=";
1825
- }
1826
- function matchesRange(current, range) {
1827
- var specifiers = range.split(/ ?&& ?/);
1828
- if (specifiers.length === 0) return false;
1829
- for (var i = 0; i < specifiers.length; ++i) if (!specifierIncluded(current, specifiers[i])) return false;
1830
- return true;
1831
- }
1832
- function versionIncluded(nodeVersion, specifierValue) {
1833
- if (typeof specifierValue === "boolean") return specifierValue;
1834
- var current = typeof nodeVersion === "undefined" ? process.versions && process.versions.node : nodeVersion;
1835
- if (typeof current !== "string") throw new TypeError(typeof nodeVersion === "undefined" ? "Unable to determine current node version" : "If provided, a valid node version is required");
1836
- if (specifierValue && typeof specifierValue === "object") {
1837
- for (var i = 0; i < specifierValue.length; ++i) if (matchesRange(current, specifierValue[i])) return true;
1838
- return false;
1839
- }
1840
- return matchesRange(current, specifierValue);
1841
- }
1842
- var data = require_core$2();
1843
- module.exports = function isCore(x, nodeVersion) {
1844
- return hasOwn(data, x) && versionIncluded(nodeVersion, data[x]);
1845
- };
1846
- }));
1847
-
1848
- //#endregion
1849
- //#region node_modules/.pnpm/resolve@1.22.11/node_modules/resolve/lib/async.js
1850
- var require_async = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1851
- var fs$2 = __require("fs");
1852
- var getHomedir = require_homedir();
1853
- var path$2 = __require("path");
1854
- var caller = require_caller();
1855
- var nodeModulesPaths = require_node_modules_paths();
1856
- var normalizeOptions = require_normalize_options();
1857
- var isCore = require_is_core_module();
1858
- var realpathFS = process.platform !== "win32" && fs$2.realpath && typeof fs$2.realpath.native === "function" ? fs$2.realpath.native : fs$2.realpath;
1859
- var relativePathRegex = /^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/;
1860
- var windowsDriveRegex = /^\w:[/\\]*$/;
1861
- var nodeModulesRegex = /[/\\]node_modules[/\\]*$/;
1862
- var homedir = getHomedir();
1863
- var defaultPaths = function() {
1864
- return [path$2.join(homedir, ".node_modules"), path$2.join(homedir, ".node_libraries")];
1865
- };
1866
- var defaultIsFile = function isFile(file, cb) {
1867
- fs$2.stat(file, function(err, stat$2) {
1868
- if (!err) return cb(null, stat$2.isFile() || stat$2.isFIFO());
1869
- if (err.code === "ENOENT" || err.code === "ENOTDIR") return cb(null, false);
1870
- return cb(err);
1871
- });
1872
- };
1873
- var defaultIsDir = function isDirectory$1(dir, cb) {
1874
- fs$2.stat(dir, function(err, stat$2) {
1875
- if (!err) return cb(null, stat$2.isDirectory());
1876
- if (err.code === "ENOENT" || err.code === "ENOTDIR") return cb(null, false);
1877
- return cb(err);
1878
- });
1879
- };
1880
- var defaultRealpath = function realpath$1(x, cb) {
1881
- realpathFS(x, function(realpathErr, realPath) {
1882
- if (realpathErr && realpathErr.code !== "ENOENT") cb(realpathErr);
1883
- else cb(null, realpathErr ? x : realPath);
1884
- });
1885
- };
1886
- var maybeRealpath = function maybeRealpath(realpath$1, x, opts, cb) {
1887
- if (opts && opts.preserveSymlinks === false) realpath$1(x, cb);
1888
- else cb(null, x);
1889
- };
1890
- var defaultReadPackage = function defaultReadPackage(readFile$2, pkgfile, cb) {
1891
- readFile$2(pkgfile, function(readFileErr, body) {
1892
- if (readFileErr) cb(readFileErr);
1893
- else try {
1894
- cb(null, JSON.parse(body));
1895
- } catch (jsonErr) {
1896
- cb(null);
1897
- }
1898
- });
1899
- };
1900
- var getPackageCandidates = function getPackageCandidates(x, start, opts) {
1901
- var dirs = nodeModulesPaths(start, opts, x);
1902
- for (var i = 0; i < dirs.length; i++) dirs[i] = path$2.join(dirs[i], x);
1903
- return dirs;
1904
- };
1905
- module.exports = function resolve$2(x, options, callback) {
1906
- var cb = callback;
1907
- var opts = options;
1908
- if (typeof options === "function") {
1909
- cb = opts;
1910
- opts = {};
1911
- }
1912
- if (typeof x !== "string") {
1913
- var err = /* @__PURE__ */ new TypeError("Path must be a string.");
1914
- return process.nextTick(function() {
1915
- cb(err);
1916
- });
1917
- }
1918
- opts = normalizeOptions(x, opts);
1919
- var isFile = opts.isFile || defaultIsFile;
1920
- var isDirectory$1 = opts.isDirectory || defaultIsDir;
1921
- var readFile$2 = opts.readFile || fs$2.readFile;
1922
- var realpath$1 = opts.realpath || defaultRealpath;
1923
- var readPackage = opts.readPackage || defaultReadPackage;
1924
- if (opts.readFile && opts.readPackage) {
1925
- var conflictErr = /* @__PURE__ */ new TypeError("`readFile` and `readPackage` are mutually exclusive.");
1926
- return process.nextTick(function() {
1927
- cb(conflictErr);
1928
- });
1929
- }
1930
- var packageIterator = opts.packageIterator;
1931
- var extensions = opts.extensions || [".js"];
1932
- var includeCoreModules = opts.includeCoreModules !== false;
1933
- var basedir = opts.basedir || path$2.dirname(caller());
1934
- var parent = opts.filename || basedir;
1935
- opts.paths = opts.paths || defaultPaths();
1936
- maybeRealpath(realpath$1, path$2.resolve(basedir), opts, function(err$1, realStart) {
1937
- if (err$1) cb(err$1);
1938
- else init(realStart);
1939
- });
1940
- var res;
1941
- function init(basedir$1) {
1942
- if (relativePathRegex.test(x)) {
1943
- res = path$2.resolve(basedir$1, x);
1944
- if (x === "." || x === ".." || x.slice(-1) === "/") res += "/";
1945
- if (x.slice(-1) === "/" && res === basedir$1) loadAsDirectory(res, opts.package, onfile);
1946
- else loadAsFile(res, opts.package, onfile);
1947
- } else if (includeCoreModules && isCore(x)) return cb(null, x);
1948
- else loadNodeModules(x, basedir$1, function(err$1, n, pkg) {
1949
- if (err$1) cb(err$1);
1950
- else if (n) return maybeRealpath(realpath$1, n, opts, function(err$2, realN) {
1951
- if (err$2) cb(err$2);
1952
- else cb(null, realN, pkg);
1953
- });
1954
- else {
1955
- var moduleError = /* @__PURE__ */ new Error("Cannot find module '" + x + "' from '" + parent + "'");
1956
- moduleError.code = "MODULE_NOT_FOUND";
1957
- cb(moduleError);
1958
- }
1959
- });
1960
- }
1961
- function onfile(err$1, m, pkg) {
1962
- if (err$1) cb(err$1);
1963
- else if (m) cb(null, m, pkg);
1964
- else loadAsDirectory(res, function(err$2, d, pkg$1) {
1965
- if (err$2) cb(err$2);
1966
- else if (d) maybeRealpath(realpath$1, d, opts, function(err$3, realD) {
1967
- if (err$3) cb(err$3);
1968
- else cb(null, realD, pkg$1);
1969
- });
1970
- else {
1971
- var moduleError = /* @__PURE__ */ new Error("Cannot find module '" + x + "' from '" + parent + "'");
1972
- moduleError.code = "MODULE_NOT_FOUND";
1973
- cb(moduleError);
1974
- }
1975
- });
1976
- }
1977
- function loadAsFile(x$1, thePackage, callback$1) {
1978
- var loadAsFilePackage = thePackage;
1979
- var cb$1 = callback$1;
1980
- if (typeof loadAsFilePackage === "function") {
1981
- cb$1 = loadAsFilePackage;
1982
- loadAsFilePackage = void 0;
1983
- }
1984
- load([""].concat(extensions), x$1, loadAsFilePackage);
1985
- function load(exts, x$2, loadPackage) {
1986
- if (exts.length === 0) return cb$1(null, void 0, loadPackage);
1987
- var file = x$2 + exts[0];
1988
- var pkg = loadPackage;
1989
- if (pkg) onpkg(null, pkg);
1990
- else loadpkg(path$2.dirname(file), onpkg);
1991
- function onpkg(err$1, pkg_, dir) {
1992
- pkg = pkg_;
1993
- if (err$1) return cb$1(err$1);
1994
- if (dir && pkg && opts.pathFilter) {
1995
- var rfile = path$2.relative(dir, file);
1996
- var rel = rfile.slice(0, rfile.length - exts[0].length);
1997
- var r = opts.pathFilter(pkg, x$2, rel);
1998
- if (r) return load([""].concat(extensions.slice()), path$2.resolve(dir, r), pkg);
1999
- }
2000
- isFile(file, onex);
2001
- }
2002
- function onex(err$1, ex) {
2003
- if (err$1) return cb$1(err$1);
2004
- if (ex) return cb$1(null, file, pkg);
2005
- load(exts.slice(1), x$2, pkg);
2006
- }
2007
- }
2008
- }
2009
- function loadpkg(dir, cb$1) {
2010
- if (dir === "" || dir === "/") return cb$1(null);
2011
- if (process.platform === "win32" && windowsDriveRegex.test(dir)) return cb$1(null);
2012
- if (nodeModulesRegex.test(dir)) return cb$1(null);
2013
- maybeRealpath(realpath$1, dir, opts, function(unwrapErr, pkgdir) {
2014
- if (unwrapErr) return loadpkg(path$2.dirname(dir), cb$1);
2015
- var pkgfile = path$2.join(pkgdir, "package.json");
2016
- isFile(pkgfile, function(err$1, ex) {
2017
- if (!ex) return loadpkg(path$2.dirname(dir), cb$1);
2018
- readPackage(readFile$2, pkgfile, function(err$2, pkgParam) {
2019
- if (err$2) cb$1(err$2);
2020
- var pkg = pkgParam;
2021
- if (pkg && opts.packageFilter) pkg = opts.packageFilter(pkg, pkgfile);
2022
- cb$1(null, pkg, dir);
2023
- });
2024
- });
2025
- });
2026
- }
2027
- function loadAsDirectory(x$1, loadAsDirectoryPackage, callback$1) {
2028
- var cb$1 = callback$1;
2029
- var fpkg = loadAsDirectoryPackage;
2030
- if (typeof fpkg === "function") {
2031
- cb$1 = fpkg;
2032
- fpkg = opts.package;
2033
- }
2034
- maybeRealpath(realpath$1, x$1, opts, function(unwrapErr, pkgdir) {
2035
- if (unwrapErr) return cb$1(unwrapErr);
2036
- var pkgfile = path$2.join(pkgdir, "package.json");
2037
- isFile(pkgfile, function(err$1, ex) {
2038
- if (err$1) return cb$1(err$1);
2039
- if (!ex) return loadAsFile(path$2.join(x$1, "index"), fpkg, cb$1);
2040
- readPackage(readFile$2, pkgfile, function(err$2, pkgParam) {
2041
- if (err$2) return cb$1(err$2);
2042
- var pkg = pkgParam;
2043
- if (pkg && opts.packageFilter) pkg = opts.packageFilter(pkg, pkgfile);
2044
- if (pkg && pkg.main) {
2045
- if (typeof pkg.main !== "string") {
2046
- var mainError = /* @__PURE__ */ new TypeError("package “" + pkg.name + "” `main` must be a string");
2047
- mainError.code = "INVALID_PACKAGE_MAIN";
2048
- return cb$1(mainError);
2049
- }
2050
- if (pkg.main === "." || pkg.main === "./") pkg.main = "index";
2051
- loadAsFile(path$2.resolve(x$1, pkg.main), pkg, function(err$3, m, pkg$1) {
2052
- if (err$3) return cb$1(err$3);
2053
- if (m) return cb$1(null, m, pkg$1);
2054
- if (!pkg$1) return loadAsFile(path$2.join(x$1, "index"), pkg$1, cb$1);
2055
- loadAsDirectory(path$2.resolve(x$1, pkg$1.main), pkg$1, function(err$4, n, pkg$2) {
2056
- if (err$4) return cb$1(err$4);
2057
- if (n) return cb$1(null, n, pkg$2);
2058
- loadAsFile(path$2.join(x$1, "index"), pkg$2, cb$1);
2059
- });
2060
- });
2061
- return;
2062
- }
2063
- loadAsFile(path$2.join(x$1, "/index"), pkg, cb$1);
2064
- });
2065
- });
2066
- });
2067
- }
2068
- function processDirs(cb$1, dirs) {
2069
- if (dirs.length === 0) return cb$1(null, void 0);
2070
- var dir = dirs[0];
2071
- isDirectory$1(path$2.dirname(dir), isdir);
2072
- function isdir(err$1, isdir$1) {
2073
- if (err$1) return cb$1(err$1);
2074
- if (!isdir$1) return processDirs(cb$1, dirs.slice(1));
2075
- loadAsFile(dir, opts.package, onfile$1);
2076
- }
2077
- function onfile$1(err$1, m, pkg) {
2078
- if (err$1) return cb$1(err$1);
2079
- if (m) return cb$1(null, m, pkg);
2080
- loadAsDirectory(dir, opts.package, ondir);
2081
- }
2082
- function ondir(err$1, n, pkg) {
2083
- if (err$1) return cb$1(err$1);
2084
- if (n) return cb$1(null, n, pkg);
2085
- processDirs(cb$1, dirs.slice(1));
2086
- }
2087
- }
2088
- function loadNodeModules(x$1, start, cb$1) {
2089
- var thunk = function() {
2090
- return getPackageCandidates(x$1, start, opts);
2091
- };
2092
- processDirs(cb$1, packageIterator ? packageIterator(x$1, start, thunk, opts) : thunk());
2093
- }
2094
- };
2095
- }));
2096
-
2097
- //#endregion
2098
- //#region node_modules/.pnpm/resolve@1.22.11/node_modules/resolve/lib/core.json
2099
- var require_core$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2100
- module.exports = {
2101
- "assert": true,
2102
- "node:assert": [">= 14.18 && < 15", ">= 16"],
2103
- "assert/strict": ">= 15",
2104
- "node:assert/strict": ">= 16",
2105
- "async_hooks": ">= 8",
2106
- "node:async_hooks": [">= 14.18 && < 15", ">= 16"],
2107
- "buffer_ieee754": ">= 0.5 && < 0.9.7",
2108
- "buffer": true,
2109
- "node:buffer": [">= 14.18 && < 15", ">= 16"],
2110
- "child_process": true,
2111
- "node:child_process": [">= 14.18 && < 15", ">= 16"],
2112
- "cluster": ">= 0.5",
2113
- "node:cluster": [">= 14.18 && < 15", ">= 16"],
2114
- "console": true,
2115
- "node:console": [">= 14.18 && < 15", ">= 16"],
2116
- "constants": true,
2117
- "node:constants": [">= 14.18 && < 15", ">= 16"],
2118
- "crypto": true,
2119
- "node:crypto": [">= 14.18 && < 15", ">= 16"],
2120
- "_debug_agent": ">= 1 && < 8",
2121
- "_debugger": "< 8",
2122
- "dgram": true,
2123
- "node:dgram": [">= 14.18 && < 15", ">= 16"],
2124
- "diagnostics_channel": [">= 14.17 && < 15", ">= 15.1"],
2125
- "node:diagnostics_channel": [">= 14.18 && < 15", ">= 16"],
2126
- "dns": true,
2127
- "node:dns": [">= 14.18 && < 15", ">= 16"],
2128
- "dns/promises": ">= 15",
2129
- "node:dns/promises": ">= 16",
2130
- "domain": ">= 0.7.12",
2131
- "node:domain": [">= 14.18 && < 15", ">= 16"],
2132
- "events": true,
2133
- "node:events": [">= 14.18 && < 15", ">= 16"],
2134
- "freelist": "< 6",
2135
- "fs": true,
2136
- "node:fs": [">= 14.18 && < 15", ">= 16"],
2137
- "fs/promises": [">= 10 && < 10.1", ">= 14"],
2138
- "node:fs/promises": [">= 14.18 && < 15", ">= 16"],
2139
- "_http_agent": ">= 0.11.1",
2140
- "node:_http_agent": [">= 14.18 && < 15", ">= 16"],
2141
- "_http_client": ">= 0.11.1",
2142
- "node:_http_client": [">= 14.18 && < 15", ">= 16"],
2143
- "_http_common": ">= 0.11.1",
2144
- "node:_http_common": [">= 14.18 && < 15", ">= 16"],
2145
- "_http_incoming": ">= 0.11.1",
2146
- "node:_http_incoming": [">= 14.18 && < 15", ">= 16"],
2147
- "_http_outgoing": ">= 0.11.1",
2148
- "node:_http_outgoing": [">= 14.18 && < 15", ">= 16"],
2149
- "_http_server": ">= 0.11.1",
2150
- "node:_http_server": [">= 14.18 && < 15", ">= 16"],
2151
- "http": true,
2152
- "node:http": [">= 14.18 && < 15", ">= 16"],
2153
- "http2": ">= 8.8",
2154
- "node:http2": [">= 14.18 && < 15", ">= 16"],
2155
- "https": true,
2156
- "node:https": [">= 14.18 && < 15", ">= 16"],
2157
- "inspector": ">= 8",
2158
- "node:inspector": [">= 14.18 && < 15", ">= 16"],
2159
- "inspector/promises": [">= 19"],
2160
- "node:inspector/promises": [">= 19"],
2161
- "_linklist": "< 8",
2162
- "module": true,
2163
- "node:module": [">= 14.18 && < 15", ">= 16"],
2164
- "net": true,
2165
- "node:net": [">= 14.18 && < 15", ">= 16"],
2166
- "node-inspect/lib/_inspect": ">= 7.6 && < 12",
2167
- "node-inspect/lib/internal/inspect_client": ">= 7.6 && < 12",
2168
- "node-inspect/lib/internal/inspect_repl": ">= 7.6 && < 12",
2169
- "os": true,
2170
- "node:os": [">= 14.18 && < 15", ">= 16"],
2171
- "path": true,
2172
- "node:path": [">= 14.18 && < 15", ">= 16"],
2173
- "path/posix": ">= 15.3",
2174
- "node:path/posix": ">= 16",
2175
- "path/win32": ">= 15.3",
2176
- "node:path/win32": ">= 16",
2177
- "perf_hooks": ">= 8.5",
2178
- "node:perf_hooks": [">= 14.18 && < 15", ">= 16"],
2179
- "process": ">= 1",
2180
- "node:process": [">= 14.18 && < 15", ">= 16"],
2181
- "punycode": ">= 0.5",
2182
- "node:punycode": [">= 14.18 && < 15", ">= 16"],
2183
- "querystring": true,
2184
- "node:querystring": [">= 14.18 && < 15", ">= 16"],
2185
- "readline": true,
2186
- "node:readline": [">= 14.18 && < 15", ">= 16"],
2187
- "readline/promises": ">= 17",
2188
- "node:readline/promises": ">= 17",
2189
- "repl": true,
2190
- "node:repl": [">= 14.18 && < 15", ">= 16"],
2191
- "node:sea": [">= 20.12 && < 21", ">= 21.7"],
2192
- "smalloc": ">= 0.11.5 && < 3",
2193
- "node:sqlite": [">= 22.13 && < 23", ">= 23.4"],
2194
- "_stream_duplex": ">= 0.9.4",
2195
- "node:_stream_duplex": [">= 14.18 && < 15", ">= 16"],
2196
- "_stream_transform": ">= 0.9.4",
2197
- "node:_stream_transform": [">= 14.18 && < 15", ">= 16"],
2198
- "_stream_wrap": ">= 1.4.1",
2199
- "node:_stream_wrap": [">= 14.18 && < 15", ">= 16"],
2200
- "_stream_passthrough": ">= 0.9.4",
2201
- "node:_stream_passthrough": [">= 14.18 && < 15", ">= 16"],
2202
- "_stream_readable": ">= 0.9.4",
2203
- "node:_stream_readable": [">= 14.18 && < 15", ">= 16"],
2204
- "_stream_writable": ">= 0.9.4",
2205
- "node:_stream_writable": [">= 14.18 && < 15", ">= 16"],
2206
- "stream": true,
2207
- "node:stream": [">= 14.18 && < 15", ">= 16"],
2208
- "stream/consumers": ">= 16.7",
2209
- "node:stream/consumers": ">= 16.7",
2210
- "stream/promises": ">= 15",
2211
- "node:stream/promises": ">= 16",
2212
- "stream/web": ">= 16.5",
2213
- "node:stream/web": ">= 16.5",
2214
- "string_decoder": true,
2215
- "node:string_decoder": [">= 14.18 && < 15", ">= 16"],
2216
- "sys": [">= 0.4 && < 0.7", ">= 0.8"],
2217
- "node:sys": [">= 14.18 && < 15", ">= 16"],
2218
- "test/reporters": ">= 19.9 && < 20.2",
2219
- "node:test/reporters": [
2220
- ">= 18.17 && < 19",
2221
- ">= 19.9",
2222
- ">= 20"
2223
- ],
2224
- "test/mock_loader": ">= 22.3 && < 22.7",
2225
- "node:test/mock_loader": ">= 22.3 && < 22.7",
2226
- "node:test": [">= 16.17 && < 17", ">= 18"],
2227
- "timers": true,
2228
- "node:timers": [">= 14.18 && < 15", ">= 16"],
2229
- "timers/promises": ">= 15",
2230
- "node:timers/promises": ">= 16",
2231
- "_tls_common": ">= 0.11.13",
2232
- "node:_tls_common": [">= 14.18 && < 15", ">= 16"],
2233
- "_tls_legacy": ">= 0.11.3 && < 10",
2234
- "_tls_wrap": ">= 0.11.3",
2235
- "node:_tls_wrap": [">= 14.18 && < 15", ">= 16"],
2236
- "tls": true,
2237
- "node:tls": [">= 14.18 && < 15", ">= 16"],
2238
- "trace_events": ">= 10",
2239
- "node:trace_events": [">= 14.18 && < 15", ">= 16"],
2240
- "tty": true,
2241
- "node:tty": [">= 14.18 && < 15", ">= 16"],
2242
- "url": true,
2243
- "node:url": [">= 14.18 && < 15", ">= 16"],
2244
- "util": true,
2245
- "node:util": [">= 14.18 && < 15", ">= 16"],
2246
- "util/types": ">= 15.3",
2247
- "node:util/types": ">= 16",
2248
- "v8/tools/arguments": ">= 10 && < 12",
2249
- "v8/tools/codemap": [">= 4.4 && < 5", ">= 5.2 && < 12"],
2250
- "v8/tools/consarray": [">= 4.4 && < 5", ">= 5.2 && < 12"],
2251
- "v8/tools/csvparser": [">= 4.4 && < 5", ">= 5.2 && < 12"],
2252
- "v8/tools/logreader": [">= 4.4 && < 5", ">= 5.2 && < 12"],
2253
- "v8/tools/profile_view": [">= 4.4 && < 5", ">= 5.2 && < 12"],
2254
- "v8/tools/splaytree": [">= 4.4 && < 5", ">= 5.2 && < 12"],
2255
- "v8": ">= 1",
2256
- "node:v8": [">= 14.18 && < 15", ">= 16"],
2257
- "vm": true,
2258
- "node:vm": [">= 14.18 && < 15", ">= 16"],
2259
- "wasi": [
2260
- ">= 13.4 && < 13.5",
2261
- ">= 18.17 && < 19",
2262
- ">= 20"
2263
- ],
2264
- "node:wasi": [">= 18.17 && < 19", ">= 20"],
2265
- "worker_threads": ">= 11.7",
2266
- "node:worker_threads": [">= 14.18 && < 15", ">= 16"],
2267
- "zlib": ">= 0.5",
2268
- "node:zlib": [">= 14.18 && < 15", ">= 16"]
2269
- };
2270
- }));
2271
-
2272
- //#endregion
2273
- //#region node_modules/.pnpm/resolve@1.22.11/node_modules/resolve/lib/core.js
2274
- var require_core = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2275
- var isCoreModule = require_is_core_module();
2276
- var data = require_core$1();
2277
- var core = {};
2278
- for (var mod in data) if (Object.prototype.hasOwnProperty.call(data, mod)) core[mod] = isCoreModule(mod);
2279
- module.exports = core;
2280
- }));
2281
-
2282
- //#endregion
2283
- //#region node_modules/.pnpm/resolve@1.22.11/node_modules/resolve/lib/is-core.js
2284
- var require_is_core = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2285
- var isCoreModule = require_is_core_module();
2286
- module.exports = function isCore(x) {
2287
- return isCoreModule(x);
2288
- };
2289
- }));
2290
-
2291
- //#endregion
2292
- //#region node_modules/.pnpm/resolve@1.22.11/node_modules/resolve/lib/sync.js
2293
- var require_sync = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2294
- var isCore = require_is_core_module();
2295
- var fs$1 = __require("fs");
2296
- var path$1 = __require("path");
2297
- var getHomedir = require_homedir();
2298
- var caller = require_caller();
2299
- var nodeModulesPaths = require_node_modules_paths();
2300
- var normalizeOptions = require_normalize_options();
2301
- var realpathFS = process.platform !== "win32" && fs$1.realpathSync && typeof fs$1.realpathSync.native === "function" ? fs$1.realpathSync.native : fs$1.realpathSync;
2302
- var relativePathRegex = /^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/;
2303
- var windowsDriveRegex = /^\w:[/\\]*$/;
2304
- var nodeModulesRegex = /[/\\]node_modules[/\\]*$/;
2305
- var homedir = getHomedir();
2306
- var defaultPaths = function() {
2307
- return [path$1.join(homedir, ".node_modules"), path$1.join(homedir, ".node_libraries")];
2308
- };
2309
- var defaultIsFile = function isFile(file) {
2310
- try {
2311
- var stat$2 = fs$1.statSync(file, { throwIfNoEntry: false });
2312
- } catch (e) {
2313
- if (e && (e.code === "ENOENT" || e.code === "ENOTDIR")) return false;
2314
- throw e;
2315
- }
2316
- return !!stat$2 && (stat$2.isFile() || stat$2.isFIFO());
2317
- };
2318
- var defaultIsDir = function isDirectory$1(dir) {
2319
- try {
2320
- var stat$2 = fs$1.statSync(dir, { throwIfNoEntry: false });
2321
- } catch (e) {
2322
- if (e && (e.code === "ENOENT" || e.code === "ENOTDIR")) return false;
2323
- throw e;
2324
- }
2325
- return !!stat$2 && stat$2.isDirectory();
2326
- };
2327
- var defaultRealpathSync = function realpathSync$2(x) {
2328
- try {
2329
- return realpathFS(x);
2330
- } catch (realpathErr) {
2331
- if (realpathErr.code !== "ENOENT") throw realpathErr;
2332
- }
2333
- return x;
2334
- };
2335
- var maybeRealpathSync = function maybeRealpathSync(realpathSync$2, x, opts) {
2336
- if (opts && opts.preserveSymlinks === false) return realpathSync$2(x);
2337
- return x;
2338
- };
2339
- var defaultReadPackageSync = function defaultReadPackageSync(readFileSync$2, pkgfile) {
2340
- var body = readFileSync$2(pkgfile);
2341
- try {
2342
- return JSON.parse(body);
2343
- } catch (jsonErr) {}
2344
- };
2345
- var getPackageCandidates = function getPackageCandidates(x, start, opts) {
2346
- var dirs = nodeModulesPaths(start, opts, x);
2347
- for (var i = 0; i < dirs.length; i++) dirs[i] = path$1.join(dirs[i], x);
2348
- return dirs;
2349
- };
2350
- module.exports = function resolveSync(x, options) {
2351
- if (typeof x !== "string") throw new TypeError("Path must be a string.");
2352
- var opts = normalizeOptions(x, options);
2353
- var isFile = opts.isFile || defaultIsFile;
2354
- var readFileSync$2 = opts.readFileSync || fs$1.readFileSync;
2355
- var isDirectory$1 = opts.isDirectory || defaultIsDir;
2356
- var realpathSync$2 = opts.realpathSync || defaultRealpathSync;
2357
- var readPackageSync = opts.readPackageSync || defaultReadPackageSync;
2358
- if (opts.readFileSync && opts.readPackageSync) throw new TypeError("`readFileSync` and `readPackageSync` are mutually exclusive.");
2359
- var packageIterator = opts.packageIterator;
2360
- var extensions = opts.extensions || [".js"];
2361
- var includeCoreModules = opts.includeCoreModules !== false;
2362
- var basedir = opts.basedir || path$1.dirname(caller());
2363
- var parent = opts.filename || basedir;
2364
- opts.paths = opts.paths || defaultPaths();
2365
- var absoluteStart = maybeRealpathSync(realpathSync$2, path$1.resolve(basedir), opts);
2366
- if (relativePathRegex.test(x)) {
2367
- var res = path$1.resolve(absoluteStart, x);
2368
- if (x === "." || x === ".." || x.slice(-1) === "/") res += "/";
2369
- var m = loadAsFileSync(res) || loadAsDirectorySync(res);
2370
- if (m) return maybeRealpathSync(realpathSync$2, m, opts);
2371
- } else if (includeCoreModules && isCore(x)) return x;
2372
- else {
2373
- var n = loadNodeModulesSync(x, absoluteStart);
2374
- if (n) return maybeRealpathSync(realpathSync$2, n, opts);
2375
- }
2376
- var err = /* @__PURE__ */ new Error("Cannot find module '" + x + "' from '" + parent + "'");
2377
- err.code = "MODULE_NOT_FOUND";
2378
- throw err;
2379
- function loadAsFileSync(x$1) {
2380
- var pkg = loadpkg(path$1.dirname(x$1));
2381
- if (pkg && pkg.dir && pkg.pkg && opts.pathFilter) {
2382
- var rfile = path$1.relative(pkg.dir, x$1);
2383
- var r = opts.pathFilter(pkg.pkg, x$1, rfile);
2384
- if (r) x$1 = path$1.resolve(pkg.dir, r);
2385
- }
2386
- if (isFile(x$1)) return x$1;
2387
- for (var i = 0; i < extensions.length; i++) {
2388
- var file = x$1 + extensions[i];
2389
- if (isFile(file)) return file;
2390
- }
2391
- }
2392
- function loadpkg(dir) {
2393
- if (dir === "" || dir === "/") return;
2394
- if (process.platform === "win32" && windowsDriveRegex.test(dir)) return;
2395
- if (nodeModulesRegex.test(dir)) return;
2396
- var pkgfile = path$1.join(maybeRealpathSync(realpathSync$2, dir, opts), "package.json");
2397
- if (!isFile(pkgfile)) return loadpkg(path$1.dirname(dir));
2398
- var pkg = readPackageSync(readFileSync$2, pkgfile);
2399
- if (pkg && opts.packageFilter) pkg = opts.packageFilter(pkg, dir);
2400
- return {
2401
- pkg,
2402
- dir
2403
- };
2404
- }
2405
- function loadAsDirectorySync(x$1) {
2406
- var pkgfile = path$1.join(maybeRealpathSync(realpathSync$2, x$1, opts), "/package.json");
2407
- if (isFile(pkgfile)) {
2408
- try {
2409
- var pkg = readPackageSync(readFileSync$2, pkgfile);
2410
- } catch (e) {}
2411
- if (pkg && opts.packageFilter) pkg = opts.packageFilter(pkg, x$1);
2412
- if (pkg && pkg.main) {
2413
- if (typeof pkg.main !== "string") {
2414
- var mainError = /* @__PURE__ */ new TypeError("package “" + pkg.name + "” `main` must be a string");
2415
- mainError.code = "INVALID_PACKAGE_MAIN";
2416
- throw mainError;
2417
- }
2418
- if (pkg.main === "." || pkg.main === "./") pkg.main = "index";
2419
- try {
2420
- var m$1 = loadAsFileSync(path$1.resolve(x$1, pkg.main));
2421
- if (m$1) return m$1;
2422
- var n$1 = loadAsDirectorySync(path$1.resolve(x$1, pkg.main));
2423
- if (n$1) return n$1;
2424
- } catch (e) {}
2425
- }
2426
- }
2427
- return loadAsFileSync(path$1.join(x$1, "/index"));
2428
- }
2429
- function loadNodeModulesSync(x$1, start) {
2430
- var thunk = function() {
2431
- return getPackageCandidates(x$1, start, opts);
2432
- };
2433
- var dirs = packageIterator ? packageIterator(x$1, start, thunk, opts) : thunk();
2434
- for (var i = 0; i < dirs.length; i++) {
2435
- var dir = dirs[i];
2436
- if (isDirectory$1(path$1.dirname(dir))) {
2437
- var m$1 = loadAsFileSync(dir);
2438
- if (m$1) return m$1;
2439
- var n$1 = loadAsDirectorySync(dir);
2440
- if (n$1) return n$1;
2441
- }
2442
- }
2443
- }
2444
- };
2445
- }));
2446
-
2447
- //#endregion
2448
- //#region node_modules/.pnpm/resolve@1.22.11/node_modules/resolve/index.js
2449
- var require_resolve = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2450
- var async = require_async();
2451
- async.core = require_core();
2452
- async.isCore = require_is_core();
2453
- async.sync = require_sync();
2454
- module.exports = async;
2455
- }));
2456
-
2457
- //#endregion
2458
- //#region node_modules/.pnpm/@rollup+plugin-node-resolve@16.0.3_rollup@4.55.2/node_modules/@rollup/plugin-node-resolve/dist/es/index.js
2459
- var import_cjs = /* @__PURE__ */ __toESM(require_cjs(), 1);
2460
- var import_is_module = /* @__PURE__ */ __toESM(require_is_module(), 1);
2461
- var import_resolve = /* @__PURE__ */ __toESM(require_resolve(), 1);
2462
- var version = "16.0.3";
2463
- var peerDependencies = { rollup: "^2.78.0||^3.0.0||^4.0.0" };
2464
- promisify(nativeFs.access);
2465
- const readFile$1 = promisify(nativeFs.readFile);
2466
- const realpath = promisify(nativeFs.realpath);
2467
- const stat$1 = promisify(nativeFs.stat);
2468
- async function fileExists(filePath) {
2469
- try {
2470
- return (await stat$1(filePath)).isFile();
2471
- } catch {
2472
- return false;
2473
- }
2474
- }
2475
- async function resolveSymlink(path$5) {
2476
- return await fileExists(path$5) ? realpath(path$5) : path$5;
2477
- }
2478
- const onError = (error) => {
2479
- if (error.code === "ENOENT") return false;
2480
- throw error;
2481
- };
2482
- const makeCache = (fn) => {
2483
- const cache = /* @__PURE__ */ new Map();
2484
- const wrapped = async (param, done) => {
2485
- if (cache.has(param) === false) cache.set(param, fn(param).catch((err) => {
2486
- cache.delete(param);
2487
- throw err;
2488
- }));
2489
- try {
2490
- return done(null, await cache.get(param));
2491
- } catch (error) {
2492
- return done(error);
2493
- }
2494
- };
2495
- wrapped.clear = () => cache.clear();
2496
- return wrapped;
2497
- };
2498
- const isDirCached = makeCache(async (file) => {
2499
- try {
2500
- return (await stat$1(file)).isDirectory();
2501
- } catch (error) {
2502
- return onError(error);
2503
- }
2504
- });
2505
- const isFileCached = makeCache(async (file) => {
2506
- try {
2507
- return (await stat$1(file)).isFile();
2508
- } catch (error) {
2509
- return onError(error);
2510
- }
2511
- });
2512
- const readCachedFile = makeCache(readFile$1);
2513
- function handleDeprecatedOptions(opts) {
2514
- const warnings = [];
2515
- if (opts.customResolveOptions) {
2516
- const { customResolveOptions } = opts;
2517
- if (customResolveOptions.moduleDirectory) {
2518
- opts.moduleDirectories = Array.isArray(customResolveOptions.moduleDirectory) ? customResolveOptions.moduleDirectory : [customResolveOptions.moduleDirectory];
2519
- warnings.push("node-resolve: The `customResolveOptions.moduleDirectory` option has been deprecated. Use `moduleDirectories`, which must be an array.");
2520
- }
2521
- if (customResolveOptions.preserveSymlinks) throw new Error("node-resolve: `customResolveOptions.preserveSymlinks` is no longer an option. We now always use the rollup `preserveSymlinks` option.");
2522
- [
2523
- "basedir",
2524
- "package",
2525
- "extensions",
2526
- "includeCoreModules",
2527
- "readFile",
2528
- "isFile",
2529
- "isDirectory",
2530
- "realpath",
2531
- "packageFilter",
2532
- "pathFilter",
2533
- "paths",
2534
- "packageIterator"
2535
- ].forEach((resolveOption) => {
2536
- if (customResolveOptions[resolveOption]) throw new Error(`node-resolve: \`customResolveOptions.${resolveOption}\` is no longer an option. If you need this, please open an issue.`);
2537
- });
2538
- }
2539
- return { warnings };
2540
- }
2541
- function getPackageName(id) {
2542
- if (id.startsWith(".") || id.startsWith("/")) return null;
2543
- const split = id.split("/");
2544
- if (split[0][0] === "@") return `${split[0]}/${split[1]}`;
2545
- return split[0];
2546
- }
2547
- function getMainFields(options) {
2548
- let mainFields;
2549
- if (options.mainFields) ({mainFields} = options);
2550
- else mainFields = ["module", "main"];
2551
- if (options.browser && mainFields.indexOf("browser") === -1) return ["browser"].concat(mainFields);
2552
- if (!mainFields.length) throw new Error("Please ensure at least one `mainFields` value is specified");
2553
- return mainFields;
2554
- }
2555
- function getPackageInfo(options) {
2556
- const { cache, extensions, pkg, mainFields, preserveSymlinks, useBrowserOverrides, rootDir, ignoreSideEffectsForRoot } = options;
2557
- let { pkgPath } = options;
2558
- if (cache.has(pkgPath)) return cache.get(pkgPath);
2559
- if (!preserveSymlinks) pkgPath = realpathSync$1(pkgPath);
2560
- const pkgRoot = dirname(pkgPath);
2561
- const packageInfo = {
2562
- packageJson: { ...pkg },
2563
- packageJsonPath: pkgPath,
2564
- root: pkgRoot,
2565
- resolvedMainField: "main",
2566
- browserMappedMain: false,
2567
- resolvedEntryPoint: ""
2568
- };
2569
- let overriddenMain = false;
2570
- for (let i = 0; i < mainFields.length; i++) {
2571
- const field = mainFields[i];
2572
- if (typeof pkg[field] === "string") {
2573
- pkg.main = pkg[field];
2574
- packageInfo.resolvedMainField = field;
2575
- overriddenMain = true;
2576
- break;
2577
- }
2578
- }
2579
- const internalPackageInfo = {
2580
- cachedPkg: pkg,
2581
- hasModuleSideEffects: () => null,
2582
- hasPackageEntry: overriddenMain !== false || mainFields.indexOf("main") !== -1,
2583
- packageBrowserField: useBrowserOverrides && typeof pkg.browser === "object" && Object.keys(pkg.browser).reduce((browser, key) => {
2584
- let resolved = pkg.browser[key];
2585
- if (resolved && resolved[0] === ".") resolved = resolve(pkgRoot, resolved);
2586
- browser[key] = resolved;
2587
- if (key[0] === ".") {
2588
- const absoluteKey = resolve(pkgRoot, key);
2589
- browser[absoluteKey] = resolved;
2590
- if (!extname(key)) extensions.reduce((subBrowser, ext) => {
2591
- subBrowser[absoluteKey + ext] = subBrowser[key];
2592
- return subBrowser;
2593
- }, browser);
2594
- }
2595
- return browser;
2596
- }, {}),
2597
- packageInfo
2598
- };
2599
- const browserMap = internalPackageInfo.packageBrowserField;
2600
- if (useBrowserOverrides && typeof pkg.browser === "object" && browserMap.hasOwnProperty(pkg.main)) {
2601
- packageInfo.resolvedEntryPoint = browserMap[pkg.main];
2602
- packageInfo.browserMappedMain = true;
2603
- } else {
2604
- packageInfo.resolvedEntryPoint = resolve(pkgRoot, pkg.main || "index.js");
2605
- packageInfo.browserMappedMain = false;
2606
- }
2607
- if (!ignoreSideEffectsForRoot || rootDir !== pkgRoot) {
2608
- const packageSideEffects = pkg.sideEffects;
2609
- if (typeof packageSideEffects === "boolean") internalPackageInfo.hasModuleSideEffects = () => packageSideEffects;
2610
- else if (Array.isArray(packageSideEffects)) internalPackageInfo.hasModuleSideEffects = createFilter(packageSideEffects.map((sideEffect) => {
2611
- if (sideEffect.includes("/")) return sideEffect;
2612
- return `**/${sideEffect}`;
2613
- }), null, { resolve: pkgRoot });
2614
- }
2615
- cache.set(pkgPath, internalPackageInfo);
2616
- return internalPackageInfo;
2617
- }
2618
- function normalizeInput(input) {
2619
- if (Array.isArray(input)) return input;
2620
- else if (typeof input === "object") return Object.values(input);
2621
- return [input];
2622
- }
2623
- function isModuleDir(current, moduleDirs) {
2624
- return moduleDirs.some((dir) => current.endsWith(dir));
2625
- }
2626
- async function findPackageJson(base, moduleDirs) {
2627
- const { root } = path.parse(base);
2628
- let current = base;
2629
- while (current !== root && !isModuleDir(current, moduleDirs)) {
2630
- const pkgJsonPath = path.join(current, "package.json");
2631
- if (await fileExists(pkgJsonPath)) {
2632
- const pkgJsonString = nativeFs.readFileSync(pkgJsonPath, "utf-8");
2633
- return {
2634
- pkgJson: JSON.parse(pkgJsonString),
2635
- pkgPath: current,
2636
- pkgJsonPath
2637
- };
2638
- }
2639
- current = path.resolve(current, "..");
2640
- }
2641
- return null;
2642
- }
2643
- function isUrl(str) {
2644
- try {
2645
- return !!new URL(str);
2646
- } catch (_) {
2647
- return false;
2648
- }
2649
- }
2650
- /**
2651
- * Conditions is an export object where all keys are conditions like 'node' (aka do not with '.')
2652
- */
2653
- function isConditions(exports$1) {
2654
- return typeof exports$1 === "object" && Object.keys(exports$1).every((k) => !k.startsWith("."));
2655
- }
2656
- /**
2657
- * Mappings is an export object where all keys start with '.
2658
- */
2659
- function isMappings(exports$1) {
2660
- return typeof exports$1 === "object" && !isConditions(exports$1);
2661
- }
2662
- /**
2663
- * Check for mixed exports, which are exports where some keys start with '.' and some do not
2664
- */
2665
- function isMixedExports(exports$1) {
2666
- const keys = Object.keys(exports$1);
2667
- return keys.some((k) => k.startsWith(".")) && keys.some((k) => !k.startsWith("."));
2668
- }
2669
- function createBaseErrorMsg(importSpecifier, importer) {
2670
- return `Could not resolve import "${importSpecifier}" in ${importer}`;
2671
- }
2672
- function createErrorMsg(context, reason, isImports) {
2673
- const { importSpecifier, importer, pkgJsonPath } = context;
2674
- return `${createBaseErrorMsg(importSpecifier, importer)} using ${isImports ? "imports" : "exports"} defined in ${pkgJsonPath}.${reason ? ` ${reason}` : ""}`;
2675
- }
2676
- var ResolveError = class extends Error {};
2677
- var InvalidConfigurationError = class extends ResolveError {
2678
- constructor(context, reason) {
2679
- super(createErrorMsg(context, `Invalid "exports" field. ${reason}`));
2680
- }
2681
- };
2682
- var InvalidModuleSpecifierError = class extends ResolveError {
2683
- constructor(context, isImports, reason) {
2684
- super(createErrorMsg(context, reason, isImports));
2685
- }
2686
- };
2687
- var InvalidPackageTargetError = class extends ResolveError {
2688
- constructor(context, reason) {
2689
- super(createErrorMsg(context, reason));
2690
- }
2691
- };
2692
- /**
2693
- * Check for invalid path segments
2694
- */
2695
- function includesInvalidSegments(pathSegments, moduleDirs) {
2696
- const invalidSegments = [
2697
- "",
2698
- ".",
2699
- "..",
2700
- ...moduleDirs
2701
- ];
2702
- return pathSegments.some((v) => invalidSegments.includes(v) || invalidSegments.includes(decodeURI(v)));
2703
- }
2704
- async function resolvePackageTarget(context, { target, patternMatch, isImports }) {
2705
- if (typeof target === "string") {
2706
- if (!target.startsWith("./")) {
2707
- if (!isImports || ["/", "../"].some((p) => target.startsWith(p)) || isUrl(target)) throw new InvalidPackageTargetError(context, `Invalid mapping: "${target}".`);
2708
- if (typeof patternMatch === "string") {
2709
- const result$1 = await context.resolveId(target.replace(/\*/g, patternMatch), context.pkgURL.href);
2710
- return result$1 ? pathToFileURL(result$1.location).href : null;
2711
- }
2712
- const result = await context.resolveId(target, context.pkgURL.href);
2713
- return result ? pathToFileURL(result.location).href : null;
2714
- }
2715
- if (context.allowExportsFolderMapping) target = target.replace(/\/$/, "/*");
2716
- {
2717
- const pathSegments = target.split(/\/|\\/);
2718
- const firstDot = pathSegments.indexOf(".");
2719
- firstDot !== -1 && pathSegments.slice(firstDot);
2720
- if (firstDot !== -1 && firstDot < pathSegments.length - 1 && includesInvalidSegments(pathSegments.slice(firstDot + 1), context.moduleDirs)) throw new InvalidPackageTargetError(context, `Invalid mapping: "${target}".`);
2721
- }
2722
- const resolvedTarget = new URL(target, context.pkgURL);
2723
- if (!resolvedTarget.href.startsWith(context.pkgURL.href)) throw new InvalidPackageTargetError(context, `Resolved to ${resolvedTarget.href} which is outside package ${context.pkgURL.href}`);
2724
- if (!patternMatch) return resolvedTarget;
2725
- if (includesInvalidSegments(patternMatch.split(/\/|\\/), context.moduleDirs)) throw new InvalidModuleSpecifierError(context);
2726
- return resolvedTarget.href.replace(/\*/g, patternMatch);
2727
- }
2728
- if (Array.isArray(target)) {
2729
- if (target.length === 0) return null;
2730
- let lastError = null;
2731
- for (const item of target) try {
2732
- const resolved = await resolvePackageTarget(context, {
2733
- target: item,
2734
- patternMatch,
2735
- isImports
2736
- });
2737
- if (resolved !== void 0) return resolved;
2738
- } catch (error) {
2739
- if (!(error instanceof InvalidPackageTargetError)) throw error;
2740
- else lastError = error;
2741
- }
2742
- if (lastError) throw lastError;
2743
- return null;
2744
- }
2745
- if (target && typeof target === "object") {
2746
- for (const [key, value] of Object.entries(target)) if (key === "default" || context.conditions.includes(key)) {
2747
- const resolved = await resolvePackageTarget(context, {
2748
- target: value,
2749
- patternMatch,
2750
- isImports
2751
- });
2752
- if (resolved !== void 0) return resolved;
2753
- }
2754
- return;
2755
- }
2756
- if (target === null) return null;
2757
- throw new InvalidPackageTargetError(context, `Invalid exports field.`);
2758
- }
2759
- /**
2760
- * Implementation of Node's `PATTERN_KEY_COMPARE` function
2761
- */
2762
- function nodePatternKeyCompare(keyA, keyB) {
2763
- const baseLengthA = keyA.includes("*") ? keyA.indexOf("*") + 1 : keyA.length;
2764
- const rval = (keyB.includes("*") ? keyB.indexOf("*") + 1 : keyB.length) - baseLengthA;
2765
- if (rval !== 0) return rval;
2766
- if (!keyA.includes("*")) return 1;
2767
- if (!keyB.includes("*")) return -1;
2768
- return keyB.length - keyA.length;
2769
- }
2770
- async function resolvePackageImportsExports(context, { matchKey, matchObj, isImports }) {
2771
- if (!matchKey.includes("*") && matchKey in matchObj) {
2772
- const target = matchObj[matchKey];
2773
- return await resolvePackageTarget(context, {
2774
- target,
2775
- patternMatch: "",
2776
- isImports
2777
- });
2778
- }
2779
- const expansionKeys = Object.keys(matchObj).filter((k) => k.endsWith("/") || k.includes("*")).sort(nodePatternKeyCompare);
2780
- for (const expansionKey of expansionKeys) {
2781
- const indexOfAsterisk = expansionKey.indexOf("*");
2782
- const patternBase = indexOfAsterisk === -1 ? expansionKey : expansionKey.substring(0, indexOfAsterisk);
2783
- if (matchKey.startsWith(patternBase) && matchKey !== patternBase) {
2784
- const patternTrailer = indexOfAsterisk !== -1 ? expansionKey.substring(indexOfAsterisk + 1) : "";
2785
- if (patternTrailer.length === 0 || matchKey.endsWith(patternTrailer) && matchKey.length >= expansionKey.length) {
2786
- const target = matchObj[expansionKey];
2787
- return await resolvePackageTarget(context, {
2788
- target,
2789
- patternMatch: matchKey.substring(patternBase.length, matchKey.length - patternTrailer.length),
2790
- isImports
2791
- });
2792
- }
2793
- }
2794
- }
2795
- throw new InvalidModuleSpecifierError(context, isImports);
2796
- }
2797
- /**
2798
- * Implementation of PACKAGE_EXPORTS_RESOLVE
2799
- */
2800
- async function resolvePackageExports(context, subpath, exports$1) {
2801
- if (isMixedExports(exports$1)) throw new InvalidConfigurationError(context, "All keys must either start with ./, or without one.");
2802
- if (subpath === ".") {
2803
- let mainExport;
2804
- if (typeof exports$1 === "string" || Array.isArray(exports$1) || isConditions(exports$1)) mainExport = exports$1;
2805
- else if (isMappings(exports$1)) mainExport = exports$1["."];
2806
- if (mainExport) {
2807
- const resolved = await resolvePackageTarget(context, {
2808
- target: mainExport,
2809
- patternMatch: "",
2810
- isImports: false
2811
- });
2812
- if (resolved) return resolved;
2813
- }
2814
- } else if (isMappings(exports$1)) {
2815
- const resolvedMatch = await resolvePackageImportsExports(context, {
2816
- matchKey: subpath,
2817
- matchObj: exports$1,
2818
- isImports: false
2819
- });
2820
- if (resolvedMatch) return resolvedMatch;
2821
- }
2822
- throw new InvalidModuleSpecifierError(context);
2823
- }
2824
- async function resolvePackageImports({ importSpecifier, importer, moduleDirs, conditions, resolveId }) {
2825
- const result = await findPackageJson(importer, moduleDirs);
2826
- if (!result) throw new Error(`${createBaseErrorMsg(importSpecifier, importer)}. Could not find a parent package.json.`);
2827
- const { pkgPath, pkgJsonPath, pkgJson } = result;
2828
- const context = {
2829
- importer,
2830
- importSpecifier,
2831
- moduleDirs,
2832
- pkgURL: pathToFileURL(`${pkgPath}/`),
2833
- pkgJsonPath,
2834
- conditions,
2835
- resolveId
2836
- };
2837
- if (!importSpecifier.startsWith("#")) throw new InvalidModuleSpecifierError(context, true, "Invalid import specifier.");
2838
- if (importSpecifier === "#" || importSpecifier.startsWith("#/")) throw new InvalidModuleSpecifierError(context, true, "Invalid import specifier.");
2839
- const { imports } = pkgJson;
2840
- if (!imports) throw new InvalidModuleSpecifierError(context, true);
2841
- return resolvePackageImportsExports(context, {
2842
- matchKey: importSpecifier,
2843
- matchObj: imports,
2844
- isImports: true
2845
- });
2846
- }
2847
- const resolveImportPath = promisify(import_resolve.default);
2848
- const readFile = promisify(nativeFs.readFile);
2849
- async function getPackageJson(importer, pkgName, resolveOptions, moduleDirectories) {
2850
- if (importer) {
2851
- const selfPackageJsonResult = await findPackageJson(importer, moduleDirectories);
2852
- if (selfPackageJsonResult && selfPackageJsonResult.pkgJson.name === pkgName) return selfPackageJsonResult;
2853
- }
2854
- try {
2855
- const pkgJsonPath = await resolveImportPath(`${pkgName}/package.json`, resolveOptions);
2856
- return {
2857
- pkgJsonPath,
2858
- pkgJson: JSON.parse(await readFile(pkgJsonPath, "utf-8")),
2859
- pkgPath: dirname(pkgJsonPath)
2860
- };
2861
- } catch (_) {
2862
- return null;
2863
- }
2864
- }
2865
- async function resolveIdClassic({ importSpecifier, packageInfoCache, extensions, mainFields, preserveSymlinks, useBrowserOverrides, baseDir, moduleDirectories, modulePaths, rootDir, ignoreSideEffectsForRoot }) {
2866
- let hasModuleSideEffects = () => null;
2867
- let hasPackageEntry = true;
2868
- let packageBrowserField = false;
2869
- let packageInfo;
2870
- const filter = (pkg, pkgPath) => {
2871
- const info = getPackageInfo({
2872
- cache: packageInfoCache,
2873
- extensions,
2874
- pkg,
2875
- pkgPath,
2876
- mainFields,
2877
- preserveSymlinks,
2878
- useBrowserOverrides,
2879
- rootDir,
2880
- ignoreSideEffectsForRoot
2881
- });
2882
- ({packageInfo, hasModuleSideEffects, hasPackageEntry, packageBrowserField} = info);
2883
- return info.cachedPkg;
2884
- };
2885
- const resolveOptions = {
2886
- basedir: baseDir,
2887
- readFile: readCachedFile,
2888
- isFile: isFileCached,
2889
- isDirectory: isDirCached,
2890
- extensions,
2891
- includeCoreModules: false,
2892
- moduleDirectory: moduleDirectories,
2893
- paths: modulePaths,
2894
- preserveSymlinks,
2895
- packageFilter: filter
2896
- };
2897
- let location;
2898
- try {
2899
- location = await resolveImportPath(importSpecifier, resolveOptions);
2900
- } catch (error) {
2901
- if (error.code !== "MODULE_NOT_FOUND") throw error;
2902
- return null;
2903
- }
2904
- return {
2905
- location: preserveSymlinks ? location : await resolveSymlink(location),
2906
- hasModuleSideEffects,
2907
- hasPackageEntry,
2908
- packageBrowserField,
2909
- packageInfo
2910
- };
2911
- }
2912
- async function resolveWithExportMap({ importer, importSpecifier, exportConditions, packageInfoCache, extensions, mainFields, preserveSymlinks, useBrowserOverrides, baseDir, moduleDirectories, modulePaths, rootDir, ignoreSideEffectsForRoot, allowExportsFolderMapping }) {
2913
- if (importSpecifier.startsWith("#")) {
2914
- const resolveResult = await resolvePackageImports({
2915
- importSpecifier,
2916
- importer,
2917
- moduleDirs: moduleDirectories,
2918
- conditions: exportConditions,
2919
- resolveId(id) {
2920
- return resolveImportSpecifiers({
2921
- importer,
2922
- importSpecifierList: [id],
2923
- exportConditions,
2924
- packageInfoCache,
2925
- extensions,
2926
- mainFields,
2927
- preserveSymlinks,
2928
- useBrowserOverrides,
2929
- baseDir,
2930
- moduleDirectories,
2931
- modulePaths,
2932
- rootDir,
2933
- ignoreSideEffectsForRoot,
2934
- allowExportsFolderMapping
2935
- });
2936
- }
2937
- });
2938
- if (resolveResult == null) throw new ResolveError(`Could not resolve import "${importSpecifier}" in ${importer} using imports.`);
2939
- const location = fileURLToPath(resolveResult);
2940
- return {
2941
- location: preserveSymlinks ? location : await resolveSymlink(location),
2942
- hasModuleSideEffects: () => null,
2943
- hasPackageEntry: true,
2944
- packageBrowserField: false,
2945
- packageInfo: void 0
2946
- };
2947
- }
2948
- const pkgName = getPackageName(importSpecifier);
2949
- if (pkgName) {
2950
- let hasModuleSideEffects = () => null;
2951
- let hasPackageEntry = true;
2952
- let packageBrowserField = false;
2953
- let packageInfo;
2954
- const filter = (pkg, pkgPath) => {
2955
- const info = getPackageInfo({
2956
- cache: packageInfoCache,
2957
- extensions,
2958
- pkg,
2959
- pkgPath,
2960
- mainFields,
2961
- preserveSymlinks,
2962
- useBrowserOverrides,
2963
- rootDir,
2964
- ignoreSideEffectsForRoot
2965
- });
2966
- ({packageInfo, hasModuleSideEffects, hasPackageEntry, packageBrowserField} = info);
2967
- return info.cachedPkg;
2968
- };
2969
- const result = await getPackageJson(importer, pkgName, {
2970
- basedir: baseDir,
2971
- readFile: readCachedFile,
2972
- isFile: isFileCached,
2973
- isDirectory: isDirCached,
2974
- extensions,
2975
- includeCoreModules: false,
2976
- moduleDirectory: moduleDirectories,
2977
- paths: modulePaths,
2978
- preserveSymlinks,
2979
- packageFilter: filter
2980
- }, moduleDirectories);
2981
- if (result && result.pkgJson.exports) {
2982
- const { pkgJson, pkgJsonPath } = result;
2983
- const subpath = pkgName === importSpecifier ? "." : `.${importSpecifier.substring(pkgName.length)}`;
2984
- const location = fileURLToPath(await resolvePackageExports({
2985
- importer,
2986
- importSpecifier,
2987
- moduleDirs: moduleDirectories,
2988
- pkgURL: pathToFileURL(pkgJsonPath.replace("package.json", "")),
2989
- pkgJsonPath,
2990
- allowExportsFolderMapping,
2991
- conditions: exportConditions
2992
- }, subpath, pkgJson.exports));
2993
- if (location) return {
2994
- location: preserveSymlinks ? location : await resolveSymlink(location),
2995
- hasModuleSideEffects,
2996
- hasPackageEntry,
2997
- packageBrowserField,
2998
- packageInfo
2999
- };
3000
- }
3001
- }
3002
- return null;
3003
- }
3004
- async function resolveWithClassic({ importer, importSpecifierList, exportConditions, warn, packageInfoCache, extensions, mainFields, preserveSymlinks, useBrowserOverrides, baseDir, moduleDirectories, modulePaths, rootDir, ignoreSideEffectsForRoot }) {
3005
- for (let i = 0; i < importSpecifierList.length; i++) {
3006
- const result = await resolveIdClassic({
3007
- importer,
3008
- importSpecifier: importSpecifierList[i],
3009
- exportConditions,
3010
- warn,
3011
- packageInfoCache,
3012
- extensions,
3013
- mainFields,
3014
- preserveSymlinks,
3015
- useBrowserOverrides,
3016
- baseDir,
3017
- moduleDirectories,
3018
- modulePaths,
3019
- rootDir,
3020
- ignoreSideEffectsForRoot
3021
- });
3022
- if (result) return result;
3023
- }
3024
- return null;
3025
- }
3026
- async function resolveImportSpecifiers({ importer, importSpecifierList, exportConditions, warn, packageInfoCache, extensions, mainFields, preserveSymlinks, useBrowserOverrides, baseDir, moduleDirectories, modulePaths, rootDir, ignoreSideEffectsForRoot, allowExportsFolderMapping }) {
3027
- try {
3028
- const exportMapRes = await resolveWithExportMap({
3029
- importer,
3030
- importSpecifier: importSpecifierList[0],
3031
- exportConditions,
3032
- packageInfoCache,
3033
- extensions,
3034
- mainFields,
3035
- preserveSymlinks,
3036
- useBrowserOverrides,
3037
- baseDir,
3038
- moduleDirectories,
3039
- modulePaths,
3040
- rootDir,
3041
- ignoreSideEffectsForRoot,
3042
- allowExportsFolderMapping
3043
- });
3044
- if (exportMapRes) return exportMapRes;
3045
- } catch (error) {
3046
- if (error instanceof ResolveError) {
3047
- warn(error);
3048
- return null;
3049
- }
3050
- throw error;
3051
- }
3052
- return resolveWithClassic({
3053
- importer,
3054
- importSpecifierList,
3055
- exportConditions,
3056
- warn,
3057
- packageInfoCache,
3058
- extensions,
3059
- mainFields,
3060
- preserveSymlinks,
3061
- useBrowserOverrides,
3062
- baseDir,
3063
- moduleDirectories,
3064
- modulePaths,
3065
- rootDir,
3066
- ignoreSideEffectsForRoot
3067
- });
3068
- }
3069
- const versionRegexp = /\^(\d+\.\d+\.\d+)/g;
3070
- function validateVersion(actualVersion, peerDependencyVersion) {
3071
- let minMajor = Infinity;
3072
- let minMinor = Infinity;
3073
- let minPatch = Infinity;
3074
- let foundVersion;
3075
- while (foundVersion = versionRegexp.exec(peerDependencyVersion)) {
3076
- const [foundMajor, foundMinor, foundPatch] = foundVersion[1].split(".").map(Number);
3077
- if (foundMajor < minMajor) {
3078
- minMajor = foundMajor;
3079
- minMinor = foundMinor;
3080
- minPatch = foundPatch;
3081
- }
3082
- }
3083
- if (!actualVersion) throw new Error(`Insufficient Rollup version: "@rollup/plugin-node-resolve" requires at least rollup@${minMajor}.${minMinor}.${minPatch}.`);
3084
- const [major, minor, patch] = actualVersion.split(".").map(Number);
3085
- if (major < minMajor || major === minMajor && (minor < minMinor || minor === minMinor && patch < minPatch)) throw new Error(`Insufficient rollup version: "@rollup/plugin-node-resolve" requires at least rollup@${minMajor}.${minMinor}.${minPatch} but found rollup@${actualVersion}.`);
3086
- }
3087
- const ES6_BROWSER_EMPTY = "\0node-resolve:empty.js";
3088
- const deepFreeze = (object) => {
3089
- Object.freeze(object);
3090
- for (const value of Object.values(object)) if (typeof value === "object" && !Object.isFrozen(value)) deepFreeze(value);
3091
- return object;
3092
- };
3093
- const baseConditions = ["default", "module"];
3094
- const baseConditionsEsm = [...baseConditions, "import"];
3095
- const baseConditionsCjs = [...baseConditions, "require"];
3096
- const defaults = {
3097
- dedupe: [],
3098
- extensions: [
3099
- ".mjs",
3100
- ".js",
3101
- ".json",
3102
- ".node"
3103
- ],
3104
- resolveOnly: [],
3105
- moduleDirectories: ["node_modules"],
3106
- modulePaths: [],
3107
- ignoreSideEffectsForRoot: false,
3108
- allowExportsFolderMapping: true
3109
- };
3110
- const nodeImportPrefix = /^node:/;
3111
- const DEFAULTS = deepFreeze((0, import_cjs.default)({}, defaults));
3112
- function nodeResolve(opts = {}) {
3113
- const { warnings } = handleDeprecatedOptions(opts);
3114
- const options = {
3115
- ...defaults,
3116
- ...opts
3117
- };
3118
- const { extensions, jail, moduleDirectories, modulePaths, ignoreSideEffectsForRoot } = options;
3119
- const exportConditions = options.exportConditions || [];
3120
- const devProdCondition = exportConditions.includes("development") || exportConditions.includes("production") ? [] : [process.env.NODE_ENV && process.env.NODE_ENV !== "production" ? "development" : "production"];
3121
- const conditionsEsm = [
3122
- ...baseConditionsEsm,
3123
- ...exportConditions,
3124
- ...devProdCondition
3125
- ];
3126
- const conditionsCjs = [
3127
- ...baseConditionsCjs,
3128
- ...exportConditions,
3129
- ...devProdCondition
3130
- ];
3131
- const packageInfoCache = /* @__PURE__ */ new Map();
3132
- const idToPackageInfo = /* @__PURE__ */ new Map();
3133
- const mainFields = getMainFields(options);
3134
- const useBrowserOverrides = mainFields.indexOf("browser") !== -1;
3135
- const isPreferBuiltinsSet = Object.prototype.hasOwnProperty.call(options, "preferBuiltins");
3136
- const preferBuiltins = isPreferBuiltinsSet ? options.preferBuiltins : true;
3137
- const rootDir = resolve(options.rootDir || process.cwd());
3138
- let { dedupe } = options;
3139
- let rollupOptions;
3140
- if (moduleDirectories.some((name) => name.includes("/"))) throw new Error("`moduleDirectories` option must only contain directory names. If you want to load modules from somewhere not supported by the default module resolution algorithm, see `modulePaths`.");
3141
- if (typeof dedupe !== "function") dedupe = (importee) => options.dedupe.includes(importee) || options.dedupe.includes(getPackageName(importee));
3142
- const allowPatterns = (patterns) => {
3143
- const regexPatterns = patterns.map((pattern) => {
3144
- if (pattern instanceof RegExp) return pattern;
3145
- const normalized = pattern.replace(/[\\^$*+?.()|[\]{}]/g, "\\$&");
3146
- return /* @__PURE__ */ new RegExp(`^${normalized}$`);
3147
- });
3148
- return (id) => !regexPatterns.length || regexPatterns.some((pattern) => pattern.test(id));
3149
- };
3150
- const resolveOnly = typeof options.resolveOnly === "function" ? options.resolveOnly : allowPatterns(options.resolveOnly);
3151
- const browserMapCache = /* @__PURE__ */ new Map();
3152
- let preserveSymlinks;
3153
- const resolveLikeNode = async (context, importee, importer, custom) => {
3154
- const [importPath, params] = importee.split("?");
3155
- const importSuffix = `${params ? `?${params}` : ""}`;
3156
- importee = importPath;
3157
- const baseDir = !importer || dedupe(importee) ? rootDir : dirname(importer);
3158
- const browser = browserMapCache.get(importer);
3159
- if (useBrowserOverrides && browser) {
3160
- const resolvedImportee = resolve(baseDir, importee);
3161
- if (browser[importee] === false || browser[resolvedImportee] === false) return { id: ES6_BROWSER_EMPTY };
3162
- const browserImportee = importee[0] !== "." && browser[importee] || browser[resolvedImportee] || browser[`${resolvedImportee}.js`] || browser[`${resolvedImportee}.json`];
3163
- if (browserImportee) importee = browserImportee;
3164
- }
3165
- const parts = importee.split(/[/\\]/);
3166
- let id = parts.shift();
3167
- let isRelativeImport = false;
3168
- if (id[0] === "@" && parts.length > 0) id += `/${parts.shift()}`;
3169
- else if (id[0] === ".") {
3170
- id = resolve(baseDir, importee);
3171
- isRelativeImport = true;
3172
- }
3173
- if (!isRelativeImport && !resolveOnly(id)) {
3174
- if (normalizeInput(rollupOptions.input).includes(importee)) return null;
3175
- return false;
3176
- }
3177
- const importSpecifierList = [importee];
3178
- if (importer === void 0 && importee[0] && !importee[0].match(/^\.?\.?\//)) importSpecifierList.push(`./${importee}`);
3179
- if (importer && /\.(ts|mts|cts|tsx)$/.test(importer)) {
3180
- for (const [importeeExt, resolvedExt] of [
3181
- [".js", ".ts"],
3182
- [".js", ".tsx"],
3183
- [".jsx", ".tsx"],
3184
- [".mjs", ".mts"],
3185
- [".cjs", ".cts"]
3186
- ]) if (importee.endsWith(importeeExt) && extensions.includes(resolvedExt)) importSpecifierList.push(importee.slice(0, -importeeExt.length) + resolvedExt);
3187
- }
3188
- const warn = (...args) => context.warn(...args);
3189
- const exportConditions$1 = custom && custom["node-resolve"] && custom["node-resolve"].isRequire ? conditionsCjs : conditionsEsm;
3190
- if (useBrowserOverrides && !exportConditions$1.includes("browser")) exportConditions$1.push("browser");
3191
- const resolvedWithoutBuiltins = await resolveImportSpecifiers({
3192
- importer,
3193
- importSpecifierList,
3194
- exportConditions: exportConditions$1,
3195
- warn,
3196
- packageInfoCache,
3197
- extensions,
3198
- mainFields,
3199
- preserveSymlinks,
3200
- useBrowserOverrides,
3201
- baseDir,
3202
- moduleDirectories,
3203
- modulePaths,
3204
- rootDir,
3205
- ignoreSideEffectsForRoot,
3206
- allowExportsFolderMapping: options.allowExportsFolderMapping
3207
- });
3208
- const importeeIsBuiltin = builtinModules.includes(importee.replace(nodeImportPrefix, ""));
3209
- const preferImporteeIsBuiltin = typeof preferBuiltins === "function" ? preferBuiltins(importee) : preferBuiltins;
3210
- const resolved = importeeIsBuiltin && preferImporteeIsBuiltin ? {
3211
- packageInfo: void 0,
3212
- hasModuleSideEffects: () => null,
3213
- hasPackageEntry: true,
3214
- packageBrowserField: false
3215
- } : resolvedWithoutBuiltins;
3216
- if (!resolved) return null;
3217
- const { packageInfo, hasModuleSideEffects, hasPackageEntry, packageBrowserField } = resolved;
3218
- let { location } = resolved;
3219
- if (packageBrowserField) {
3220
- if (Object.prototype.hasOwnProperty.call(packageBrowserField, location)) {
3221
- if (!packageBrowserField[location]) {
3222
- browserMapCache.set(location, packageBrowserField);
3223
- return { id: ES6_BROWSER_EMPTY };
3224
- }
3225
- location = packageBrowserField[location];
3226
- }
3227
- browserMapCache.set(location, packageBrowserField);
3228
- }
3229
- if (hasPackageEntry && !preserveSymlinks) {
3230
- if (await fileExists(location)) location = await realpath(location);
3231
- }
3232
- idToPackageInfo.set(location, packageInfo);
3233
- if (hasPackageEntry) {
3234
- if (importeeIsBuiltin && preferImporteeIsBuiltin) {
3235
- if (!isPreferBuiltinsSet && resolvedWithoutBuiltins && resolved !== importee) context.warn({
3236
- message: `preferring built-in module '${importee}' over local alternative at '${resolvedWithoutBuiltins.location}', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning.or passing a function to 'preferBuiltins' to provide more fine-grained control over which built-in modules to prefer.`,
3237
- pluginCode: "PREFER_BUILTINS"
3238
- });
3239
- return false;
3240
- } else if (jail && location.indexOf(normalize(jail.trim(sep))) !== 0) return null;
3241
- }
3242
- if (options.modulesOnly && await fileExists(location)) {
3243
- if ((0, import_is_module.default)(await readFile$1(location, "utf-8"))) return {
3244
- id: `${location}${importSuffix}`,
3245
- moduleSideEffects: hasModuleSideEffects(location)
3246
- };
3247
- return null;
3248
- }
3249
- return {
3250
- id: `${location}${importSuffix}`,
3251
- moduleSideEffects: hasModuleSideEffects(location)
3252
- };
3253
- };
3254
- return {
3255
- name: "node-resolve",
3256
- version,
3257
- buildStart(buildOptions) {
3258
- validateVersion(this.meta.rollupVersion, peerDependencies.rollup);
3259
- rollupOptions = buildOptions;
3260
- for (const warning of warnings) this.warn(warning);
3261
- ({preserveSymlinks} = buildOptions);
3262
- },
3263
- generateBundle() {
3264
- readCachedFile.clear();
3265
- isFileCached.clear();
3266
- isDirCached.clear();
3267
- },
3268
- resolveId: {
3269
- order: "post",
3270
- async handler(importee, importer, resolveOptions) {
3271
- if (importee === ES6_BROWSER_EMPTY) return importee;
3272
- if (importee && importee.includes("\0")) return null;
3273
- const { custom = {} } = resolveOptions;
3274
- const { "node-resolve": { resolved: alreadyResolved } = {} } = custom;
3275
- if (alreadyResolved) return alreadyResolved;
3276
- if (importer && importer.includes("\0")) importer = void 0;
3277
- const resolved = await resolveLikeNode(this, importee, importer, custom);
3278
- if (resolved) {
3279
- const resolvedResolved = await this.resolve(resolved.id, importer, {
3280
- ...resolveOptions,
3281
- skipSelf: false,
3282
- custom: {
3283
- ...custom,
3284
- "node-resolve": {
3285
- ...custom["node-resolve"],
3286
- resolved,
3287
- importee
3288
- }
3289
- }
3290
- });
3291
- if (resolvedResolved) {
3292
- if (resolvedResolved.external) return false;
3293
- if (resolvedResolved.id !== resolved.id) return resolvedResolved;
3294
- return {
3295
- ...resolved,
3296
- meta: resolvedResolved.meta
3297
- };
3298
- }
3299
- }
3300
- return resolved;
3301
- }
3302
- },
3303
- load(importee) {
3304
- if (importee === ES6_BROWSER_EMPTY) return "export default {};";
3305
- return null;
3306
- },
3307
- getPackageInfoForId(id) {
3308
- return idToPackageInfo.get(id);
3309
- }
3310
- };
3311
- }
3312
-
3313
- //#endregion
3314
- //#region src/build/plugins/oxc.ts
3315
- function oxc(options) {
3316
- return {
3317
- name: "nitro:oxc",
3318
- transform: {
3319
- filter: { id: /^(?!.*\/node_modules\/).*\.m?[jt]sx?$/ },
3320
- handler(code, id) {
3321
- const res = transformSync(id, code, {
3322
- sourcemap: options.sourcemap,
3323
- ...options.transform
3324
- });
3325
- if (res.errors?.length > 0) this.error(res.errors.join("\n"));
3326
- return res;
3327
- }
3328
- },
3329
- renderChunk(code, chunk) {
3330
- if (options.minify) return minifySync(chunk.fileName, code, {
3331
- sourcemap: options.sourcemap,
3332
- ...typeof options.minify === "object" ? options.minify : {}
3333
- });
3334
- }
3335
- };
3336
- }
3337
-
3338
- //#endregion
3339
- //#region src/build/rollup/config.ts
3340
- const getRollupConfig = async (nitro) => {
3341
- const base = baseBuildConfig(nitro);
3342
- const tsc = nitro.options.typescript.tsConfig?.compilerOptions;
3343
- let config = {
3344
- input: nitro.options.entry,
3345
- external: [...base.env.external],
3346
- plugins: [
3347
- ...await baseBuildPlugins(nitro, base),
3348
- oxc({
3349
- sourcemap: !!nitro.options.sourcemap,
3350
- minify: nitro.options.minify ? { ...nitro.options.oxc?.minify } : false,
3351
- transform: {
3352
- target: "esnext",
3353
- cwd: nitro.options.rootDir,
3354
- ...nitro.options.oxc?.transform,
3355
- jsx: {
3356
- runtime: tsc?.jsx === "react" ? "classic" : "automatic",
3357
- pragma: tsc?.jsxFactory,
3358
- pragmaFrag: tsc?.jsxFragmentFactory,
3359
- importSource: tsc?.jsxImportSource,
3360
- development: nitro.options.dev,
3361
- ...nitro.options.oxc?.transform?.jsx
3362
- }
3363
- }
3364
- }),
3365
- alias({ entries: base.aliases }),
3366
- nodeResolve({
3367
- extensions: base.extensions,
3368
- preferBuiltins: !!nitro.options.node,
3369
- rootDir: nitro.options.rootDir,
3370
- exportConditions: nitro.options.exportConditions
3371
- }),
3372
- commonjs({ ...nitro.options.commonJS }),
3373
- json(),
3374
- inject(base.env.inject)
3375
- ],
3376
- onwarn(warning, rollupWarn) {
3377
- if (!base.ignoreWarningCodes.has(warning.code || "")) rollupWarn(warning);
3378
- },
3379
- treeshake: { moduleSideEffects(id) {
3380
- return nitro.options.moduleSideEffects.some((p) => id.startsWith(p));
3381
- } },
3382
- output: {
3383
- format: "esm",
3384
- entryFileNames: "index.mjs",
3385
- chunkFileNames: (chunk) => getChunkName(chunk, nitro),
3386
- dir: nitro.options.output.serverDir,
3387
- inlineDynamicImports: nitro.options.inlineDynamicImports,
3388
- generatedCode: { constBindings: true },
3389
- sourcemap: nitro.options.sourcemap,
3390
- sourcemapExcludeSources: true,
3391
- sourcemapIgnoreList: (id) => id.includes("node_modules"),
3392
- manualChunks(id) {
3393
- if (NODE_MODULES_RE.test(id)) return libChunkName(id);
3394
- }
3395
- }
3396
- };
3397
- config = defu(nitro.options.rollupConfig, config);
3398
- const outputConfig = config.output;
3399
- if (outputConfig.inlineDynamicImports || outputConfig.format === "iife") delete outputConfig.manualChunks;
3400
- return config;
3401
- };
3402
-
3403
- //#endregion
3404
- //#region src/build/rollup/error.ts
3405
- function formatRollupError(_error) {
3406
- try {
3407
- const logs = [_error.toString()];
3408
- const errors = _error?.errors || [_error];
3409
- for (const error of errors) {
3410
- const id = error.path || error.id || _error.id;
3411
- let path$5 = isAbsolute$1(id) ? relative$1(process.cwd(), id) : id;
3412
- const location = error.loc;
3413
- if (location) path$5 += `:${location.line}:${location.column}`;
3414
- const text = error.frame;
3415
- logs.push(`Rollup error while processing \`${path$5}\`` + text ? "\n\n" + text : "");
3416
- }
3417
- return logs.join("\n");
3418
- } catch {
3419
- return _error?.toString();
3420
- }
3421
- }
3422
-
3423
- //#endregion
3424
- //#region src/build/rollup/dev.ts
3425
- async function watchDev(nitro, rollupConfig) {
3426
- const rollup = await import("rollup");
3427
- let rollupWatcher;
3428
- async function load() {
3429
- if (rollupWatcher) await rollupWatcher.close();
3430
- await scanHandlers(nitro);
3431
- nitro.routing.sync();
3432
- rollupWatcher = startRollupWatcher(nitro, rollupConfig);
3433
- await writeTypes(nitro);
3434
- }
3435
- const reload = debounce(load);
3436
- const scanDirs = nitro.options.scanDirs.flatMap((dir) => [
3437
- join$1(dir, nitro.options.apiDir || "api"),
3438
- join$1(dir, nitro.options.routesDir || "routes"),
3439
- join$1(dir, "middleware"),
3440
- join$1(dir, "plugins"),
3441
- join$1(dir, "modules")
3442
- ]);
3443
- const watchReloadEvents = new Set([
3444
- "add",
3445
- "addDir",
3446
- "unlink",
3447
- "unlinkDir"
3448
- ]);
3449
- const scanDirsWatcher = watch$1(scanDirs, { ignoreInitial: true }).on("all", (event, path$5, stat$2) => {
3450
- if (watchReloadEvents.has(event)) reload();
3451
- });
3452
- const rootDirWatcher = watch(nitro.options.rootDir, { persistent: false }, (_event, filename) => {
3453
- if (filename && /^server\.[mc]?[jt]sx?$/.test(filename)) reload();
3454
- });
3455
- nitro.hooks.hook("close", () => {
3456
- rollupWatcher.close();
3457
- scanDirsWatcher.close();
3458
- rootDirWatcher.close();
3459
- });
3460
- nitro.hooks.hook("rollup:reload", () => reload());
3461
- await load();
3462
- function startRollupWatcher(nitro$1, rollupConfig$1) {
3463
- const watcher = rollup.watch(defu(rollupConfig$1, { watch: { chokidar: nitro$1.options.watchOptions } }));
3464
- let start;
3465
- watcher.on("event", (event) => {
3466
- switch (event.code) {
3467
- case "START":
3468
- start = Date.now();
3469
- nitro$1.logger.info(`Starting dev watcher (builder: \`rollup\`, preset: \`${nitro$1.options.preset}\`, compatibility date: \`${formatCompatibilityDate(nitro$1.options.compatibilityDate)}\`)`);
3470
- nitro$1.hooks.callHook("dev:start");
3471
- break;
3472
- case "BUNDLE_END":
3473
- nitro$1.hooks.callHook("compiled", nitro$1);
3474
- if (nitro$1.options.logging.buildSuccess) nitro$1.logger.success(`Server built`, start ? `in ${Date.now() - start}ms` : "");
3475
- nitro$1.hooks.callHook("dev:reload");
3476
- break;
3477
- case "ERROR":
3478
- nitro$1.logger.error(formatRollupError(event.error));
3479
- nitro$1.hooks.callHook("dev:error", event.error);
3480
- }
3481
- });
3482
- return watcher;
3483
- }
3484
- }
3485
-
3486
- //#endregion
3487
- //#region src/build/rollup/prod.ts
3488
- async function buildProduction(nitro, rollupConfig) {
3489
- const rollup = await import("rollup");
3490
- const buildStartTime = Date.now();
3491
- await scanHandlers(nitro);
3492
- await writeTypes(nitro);
3493
- if (!nitro.options.static) {
3494
- nitro.logger.info(`Building server (builder: \`rollup\`, preset: \`${nitro.options.preset}\`, compatibility date: \`${formatCompatibilityDate(nitro.options.compatibilityDate)}\`)`);
3495
- await (await rollup.rollup(rollupConfig).catch((error) => {
3496
- nitro.logger.error(formatRollupError(error));
3497
- throw error;
3498
- })).write(rollupConfig.output);
3499
- }
3500
- const buildInfo = await writeBuildInfo(nitro);
3501
- if (!nitro.options.static) {
3502
- if (nitro.options.logging.buildSuccess) nitro.logger.success(`Server built in ${Date.now() - buildStartTime}ms`);
3503
- if (nitro.options.logLevel > 1) process.stdout.write(await generateFSTree(nitro.options.output.serverDir, { compressedSizes: nitro.options.logging.compressedSizes }) || "");
3504
- }
3505
- await nitro.hooks.callHook("compiled", nitro);
3506
- const rOutput = relative$1(process.cwd(), nitro.options.output.dir);
3507
- const rewriteRelativePaths = (input) => {
3508
- return input.replace(/([\s:])\.\/(\S*)/g, `$1${rOutput}/$2`);
3509
- };
3510
- if (buildInfo.commands.preview) nitro.logger.success(`You can preview this build using \`${rewriteRelativePaths(buildInfo.commands.preview)}\``);
3511
- if (buildInfo.commands.deploy) nitro.logger.success(`You can deploy this build using \`${rewriteRelativePaths(buildInfo.commands.deploy)}\``);
3512
- }
3513
-
3514
- //#endregion
3515
- //#region src/build/rollup/build.ts
3516
- async function rollupBuild(nitro) {
3517
- await nitro.hooks.callHook("build:before", nitro);
3518
- const config = await getRollupConfig(nitro);
3519
- await nitro.hooks.callHook("rollup:before", nitro, config);
3520
- return nitro.options.dev ? watchDev(nitro, config) : buildProduction(nitro, config);
3521
- }
3522
-
3523
- //#endregion
3524
- export { rollupBuild };