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,2150 +0,0 @@
1
- import { n as __require, r as __toESM, t as __commonJSMin } from "../_chunks/nitro.mjs";
2
- import { a as join$1, i as isAbsolute$2, u as resolve$2 } from "./pathe.mjs";
3
- import { n as require_picomatch } from "./fdir+picomatch+tinyglobby.mjs";
4
- import { C as decode, F as Parser, S as MagicString, w as encode } from "./acorn+confbox+js-tokens+magic-string+mlly+pkg-types+sourcemap-codec+strip-literal+unimport.mjs";
5
- import { n as createUnimport } from "./local-pkg+quansync+unimport.mjs";
6
- import { createRequire } from "node:module";
7
- import fs, { promises } from "node:fs";
8
- import "node:fs/promises";
9
- import { fileURLToPath } from "node:url";
10
- import "node:os";
11
- import path, { basename, dirname, extname, isAbsolute, normalize, resolve } from "node:path";
12
- import process$1 from "node:process";
13
- import "scule";
14
- import { Buffer } from "node:buffer";
15
- import * as querystring from "node:querystring";
16
-
17
- //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/context-Csj9j3eN.js
18
- var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch(), 1);
19
- function toArray$2(array) {
20
- array = array || [];
21
- if (Array.isArray(array)) return array;
22
- return [array];
23
- }
24
- const BACKSLASH_REGEX = /\\/g;
25
- function normalize$1(path$1) {
26
- return path$1.replace(BACKSLASH_REGEX, "/");
27
- }
28
- const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Z]:)?[/\\|])/i;
29
- function isAbsolute$1(path$1) {
30
- return ABSOLUTE_PATH_REGEX.test(path$1);
31
- }
32
- function getMatcherString$1(glob, cwd$1) {
33
- if (glob.startsWith("**") || isAbsolute$1(glob)) return normalize$1(glob);
34
- return normalize$1(resolve(cwd$1, glob));
35
- }
36
- function patternToIdFilter(pattern) {
37
- if (pattern instanceof RegExp) return (id) => {
38
- const normalizedId = normalize$1(id);
39
- const result = pattern.test(normalizedId);
40
- pattern.lastIndex = 0;
41
- return result;
42
- };
43
- const matcher = (0, import_picomatch.default)(getMatcherString$1(pattern, process.cwd()), { dot: true });
44
- return (id) => {
45
- return matcher(normalize$1(id));
46
- };
47
- }
48
- function patternToCodeFilter(pattern) {
49
- if (pattern instanceof RegExp) return (code) => {
50
- const result = pattern.test(code);
51
- pattern.lastIndex = 0;
52
- return result;
53
- };
54
- return (code) => code.includes(pattern);
55
- }
56
- function createFilter$1(exclude, include) {
57
- if (!exclude && !include) return;
58
- return (input) => {
59
- if (exclude?.some((filter) => filter(input))) return false;
60
- if (include?.some((filter) => filter(input))) return true;
61
- return !(include && include.length > 0);
62
- };
63
- }
64
- function normalizeFilter(filter) {
65
- if (typeof filter === "string" || filter instanceof RegExp) return { include: [filter] };
66
- if (Array.isArray(filter)) return { include: filter };
67
- return {
68
- exclude: filter.exclude ? toArray$2(filter.exclude) : void 0,
69
- include: filter.include ? toArray$2(filter.include) : void 0
70
- };
71
- }
72
- function createIdFilter(filter) {
73
- if (!filter) return;
74
- const { exclude, include } = normalizeFilter(filter);
75
- const excludeFilter = exclude?.map(patternToIdFilter);
76
- const includeFilter = include?.map(patternToIdFilter);
77
- return createFilter$1(excludeFilter, includeFilter);
78
- }
79
- function createCodeFilter(filter) {
80
- if (!filter) return;
81
- const { exclude, include } = normalizeFilter(filter);
82
- const excludeFilter = exclude?.map(patternToCodeFilter);
83
- const includeFilter = include?.map(patternToCodeFilter);
84
- return createFilter$1(excludeFilter, includeFilter);
85
- }
86
- function createFilterForId(filter) {
87
- const filterFunction = createIdFilter(filter);
88
- return filterFunction ? (id) => !!filterFunction(id) : void 0;
89
- }
90
- function createFilterForTransform(idFilter, codeFilter) {
91
- if (!idFilter && !codeFilter) return;
92
- const idFilterFunction = createIdFilter(idFilter);
93
- const codeFilterFunction = createCodeFilter(codeFilter);
94
- return (id, code) => {
95
- let fallback = true;
96
- if (idFilterFunction) fallback &&= idFilterFunction(id);
97
- if (!fallback) return false;
98
- if (codeFilterFunction) fallback &&= codeFilterFunction(code);
99
- return fallback;
100
- };
101
- }
102
- function normalizeObjectHook(name, hook) {
103
- let handler;
104
- let filter;
105
- if (typeof hook === "function") handler = hook;
106
- else {
107
- handler = hook.handler;
108
- const hookFilter = hook.filter;
109
- if (name === "resolveId" || name === "load") filter = createFilterForId(hookFilter?.id);
110
- else filter = createFilterForTransform(hookFilter?.id, hookFilter?.code);
111
- }
112
- return {
113
- handler,
114
- filter: filter || (() => true)
115
- };
116
- }
117
- function parse$1(code, opts = {}) {
118
- return Parser.parse(code, {
119
- sourceType: "module",
120
- ecmaVersion: "latest",
121
- locations: true,
122
- ...opts
123
- });
124
- }
125
-
126
- //#endregion
127
- //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/webpack-like-DFGTNSuV.js
128
- function transformUse(data, plugin, transformLoader) {
129
- if (data.resource == null) return [];
130
- const id = normalizeAbsolutePath(data.resource + (data.resourceQuery || ""));
131
- if (plugin.transformInclude && !plugin.transformInclude(id)) return [];
132
- const { filter } = normalizeObjectHook("load", plugin.transform);
133
- if (!filter(id)) return [];
134
- return [{
135
- loader: transformLoader,
136
- options: { plugin },
137
- ident: plugin.name
138
- }];
139
- }
140
- /**
141
- * Normalizes a given path when it's absolute. Normalizing means returning a new path by converting
142
- * the input path to the native os format. This is useful in cases where we want to normalize
143
- * the `id` argument of a hook. Any absolute ids should be in the default format
144
- * of the operating system. Any relative imports or node_module imports should remain
145
- * untouched.
146
- *
147
- * @param path - Path to normalize.
148
- * @returns a new normalized path.
149
- */
150
- function normalizeAbsolutePath(path$1) {
151
- if (isAbsolute(path$1)) return normalize(path$1);
152
- else return path$1;
153
- }
154
-
155
- //#endregion
156
- //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/context-DkYlx1xL.js
157
- function createBuildContext$1(compiler, compilation, loaderContext, inputSourceMap) {
158
- return {
159
- getNativeBuildContext() {
160
- return {
161
- framework: "rspack",
162
- compiler,
163
- compilation,
164
- loaderContext,
165
- inputSourceMap
166
- };
167
- },
168
- addWatchFile(file) {
169
- const cwd$1 = process.cwd();
170
- compilation.fileDependencies.add(resolve(cwd$1, file));
171
- },
172
- getWatchFiles() {
173
- return Array.from(compilation.fileDependencies);
174
- },
175
- parse: parse$1,
176
- emitFile(emittedFile) {
177
- const outFileName = emittedFile.fileName || emittedFile.name;
178
- if (emittedFile.source && outFileName) {
179
- const { sources } = compilation.compiler.webpack;
180
- compilation.emitAsset(outFileName, new sources.RawSource(typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)));
181
- }
182
- }
183
- };
184
- }
185
- function normalizeMessage$1(error) {
186
- const err = new Error(typeof error === "string" ? error : error.message);
187
- if (typeof error === "object") {
188
- err.stack = error.stack;
189
- err.cause = error.meta;
190
- }
191
- return err;
192
- }
193
-
194
- //#endregion
195
- //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/utils-BosfZ0pB.js
196
- function encodeVirtualModuleId(id, plugin) {
197
- return resolve(plugin.__virtualModulePrefix, encodeURIComponent(id));
198
- }
199
- function decodeVirtualModuleId(encoded, _plugin) {
200
- return decodeURIComponent(basename(encoded));
201
- }
202
- function isVirtualModuleId(encoded, plugin) {
203
- return dirname(encoded) === plugin.__virtualModulePrefix;
204
- }
205
- var FakeVirtualModulesPlugin = class FakeVirtualModulesPlugin$1 {
206
- name = "FakeVirtualModulesPlugin";
207
- static counters = /* @__PURE__ */ new Map();
208
- static initCleanup = false;
209
- constructor(plugin) {
210
- this.plugin = plugin;
211
- if (!FakeVirtualModulesPlugin$1.initCleanup) {
212
- FakeVirtualModulesPlugin$1.initCleanup = true;
213
- process.once("exit", () => {
214
- FakeVirtualModulesPlugin$1.counters.forEach((_, dir) => {
215
- fs.rmSync(dir, {
216
- recursive: true,
217
- force: true
218
- });
219
- });
220
- });
221
- }
222
- }
223
- apply(compiler) {
224
- const dir = this.plugin.__virtualModulePrefix;
225
- if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
226
- const counter = FakeVirtualModulesPlugin$1.counters.get(dir) ?? 0;
227
- FakeVirtualModulesPlugin$1.counters.set(dir, counter + 1);
228
- compiler.hooks.shutdown.tap(this.name, () => {
229
- const counter$1 = (FakeVirtualModulesPlugin$1.counters.get(dir) ?? 1) - 1;
230
- if (counter$1 === 0) {
231
- FakeVirtualModulesPlugin$1.counters.delete(dir);
232
- fs.rmSync(dir, {
233
- recursive: true,
234
- force: true
235
- });
236
- } else FakeVirtualModulesPlugin$1.counters.set(dir, counter$1);
237
- });
238
- }
239
- async writeModule(file) {
240
- return fs.promises.writeFile(file, "");
241
- }
242
- };
243
-
244
- //#endregion
245
- //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/context-OCFO8EW1.js
246
- function contextOptionsFromCompilation(compilation) {
247
- return {
248
- addWatchFile(file) {
249
- (compilation.fileDependencies ?? compilation.compilationDependencies).add(file);
250
- },
251
- getWatchFiles() {
252
- return Array.from(compilation.fileDependencies ?? compilation.compilationDependencies);
253
- }
254
- };
255
- }
256
- const require$1 = createRequire(import.meta.url);
257
- function getSource(fileSource) {
258
- return new (require$1("webpack")).sources.RawSource(typeof fileSource === "string" ? fileSource : Buffer.from(fileSource.buffer));
259
- }
260
- function createBuildContext(options, compiler, compilation, loaderContext, inputSourceMap) {
261
- return {
262
- parse: parse$1,
263
- addWatchFile(id) {
264
- options.addWatchFile(resolve(process$1.cwd(), id));
265
- },
266
- emitFile(emittedFile) {
267
- const outFileName = emittedFile.fileName || emittedFile.name;
268
- if (emittedFile.source && outFileName) {
269
- if (!compilation) throw new Error("unplugin/webpack: emitFile outside supported hooks (buildStart, buildEnd, load, transform, watchChange)");
270
- compilation.emitAsset(outFileName, getSource(emittedFile.source));
271
- }
272
- },
273
- getWatchFiles() {
274
- return options.getWatchFiles();
275
- },
276
- getNativeBuildContext() {
277
- return {
278
- framework: "webpack",
279
- compiler,
280
- compilation,
281
- loaderContext,
282
- inputSourceMap
283
- };
284
- }
285
- };
286
- }
287
- function normalizeMessage(error) {
288
- const err = new Error(typeof error === "string" ? error : error.message);
289
- if (typeof error === "object") {
290
- err.stack = error.stack;
291
- err.cause = error.meta;
292
- }
293
- return err;
294
- }
295
-
296
- //#endregion
297
- //#region node_modules/.pnpm/@jridgewell+resolve-uri@3.1.2/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs
298
- const schemeRegex = /^[\w+.-]+:\/\//;
299
- /**
300
- * Matches the parts of a URL:
301
- * 1. Scheme, including ":", guaranteed.
302
- * 2. User/password, including "@", optional.
303
- * 3. Host, guaranteed.
304
- * 4. Port, including ":", optional.
305
- * 5. Path, including "/", optional.
306
- * 6. Query, including "?", optional.
307
- * 7. Hash, including "#", optional.
308
- */
309
- const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
310
- /**
311
- * File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start
312
- * with a leading `/`, they can have a domain (but only if they don't start with a Windows drive).
313
- *
314
- * 1. Host, optional.
315
- * 2. Path, which may include "/", guaranteed.
316
- * 3. Query, including "?", optional.
317
- * 4. Hash, including "#", optional.
318
- */
319
- const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
320
- function isAbsoluteUrl(input) {
321
- return schemeRegex.test(input);
322
- }
323
- function isSchemeRelativeUrl(input) {
324
- return input.startsWith("//");
325
- }
326
- function isAbsolutePath(input) {
327
- return input.startsWith("/");
328
- }
329
- function isFileUrl(input) {
330
- return input.startsWith("file:");
331
- }
332
- function isRelative(input) {
333
- return /^[.?#]/.test(input);
334
- }
335
- function parseAbsoluteUrl(input) {
336
- const match = urlRegex.exec(input);
337
- return makeUrl(match[1], match[2] || "", match[3], match[4] || "", match[5] || "/", match[6] || "", match[7] || "");
338
- }
339
- function parseFileUrl(input) {
340
- const match = fileRegex.exec(input);
341
- const path$1 = match[2];
342
- return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path$1) ? path$1 : "/" + path$1, match[3] || "", match[4] || "");
343
- }
344
- function makeUrl(scheme, user, host, port, path$1, query, hash) {
345
- return {
346
- scheme,
347
- user,
348
- host,
349
- port,
350
- path: path$1,
351
- query,
352
- hash,
353
- type: 7
354
- };
355
- }
356
- function parseUrl(input) {
357
- if (isSchemeRelativeUrl(input)) {
358
- const url$1 = parseAbsoluteUrl("http:" + input);
359
- url$1.scheme = "";
360
- url$1.type = 6;
361
- return url$1;
362
- }
363
- if (isAbsolutePath(input)) {
364
- const url$1 = parseAbsoluteUrl("http://foo.com" + input);
365
- url$1.scheme = "";
366
- url$1.host = "";
367
- url$1.type = 5;
368
- return url$1;
369
- }
370
- if (isFileUrl(input)) return parseFileUrl(input);
371
- if (isAbsoluteUrl(input)) return parseAbsoluteUrl(input);
372
- const url = parseAbsoluteUrl("http://foo.com/" + input);
373
- url.scheme = "";
374
- url.host = "";
375
- url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1;
376
- return url;
377
- }
378
- function stripPathFilename(path$1) {
379
- if (path$1.endsWith("/..")) return path$1;
380
- const index = path$1.lastIndexOf("/");
381
- return path$1.slice(0, index + 1);
382
- }
383
- function mergePaths(url, base) {
384
- normalizePath$1(base, base.type);
385
- if (url.path === "/") url.path = base.path;
386
- else url.path = stripPathFilename(base.path) + url.path;
387
- }
388
- /**
389
- * The path can have empty directories "//", unneeded parents "foo/..", or current directory
390
- * "foo/.". We need to normalize to a standard representation.
391
- */
392
- function normalizePath$1(url, type$1) {
393
- const rel = type$1 <= 4;
394
- const pieces = url.path.split("/");
395
- let pointer = 1;
396
- let positive = 0;
397
- let addTrailingSlash = false;
398
- for (let i = 1; i < pieces.length; i++) {
399
- const piece = pieces[i];
400
- if (!piece) {
401
- addTrailingSlash = true;
402
- continue;
403
- }
404
- addTrailingSlash = false;
405
- if (piece === ".") continue;
406
- if (piece === "..") {
407
- if (positive) {
408
- addTrailingSlash = true;
409
- positive--;
410
- pointer--;
411
- } else if (rel) pieces[pointer++] = piece;
412
- continue;
413
- }
414
- pieces[pointer++] = piece;
415
- positive++;
416
- }
417
- let path$1 = "";
418
- for (let i = 1; i < pointer; i++) path$1 += "/" + pieces[i];
419
- if (!path$1 || addTrailingSlash && !path$1.endsWith("/..")) path$1 += "/";
420
- url.path = path$1;
421
- }
422
- /**
423
- * Attempts to resolve `input` URL/path relative to `base`.
424
- */
425
- function resolve$1(input, base) {
426
- if (!input && !base) return "";
427
- const url = parseUrl(input);
428
- let inputType = url.type;
429
- if (base && inputType !== 7) {
430
- const baseUrl = parseUrl(base);
431
- const baseType = baseUrl.type;
432
- switch (inputType) {
433
- case 1: url.hash = baseUrl.hash;
434
- case 2: url.query = baseUrl.query;
435
- case 3:
436
- case 4: mergePaths(url, baseUrl);
437
- case 5:
438
- url.user = baseUrl.user;
439
- url.host = baseUrl.host;
440
- url.port = baseUrl.port;
441
- case 6: url.scheme = baseUrl.scheme;
442
- }
443
- if (baseType > inputType) inputType = baseType;
444
- }
445
- normalizePath$1(url, inputType);
446
- const queryHash = url.query + url.hash;
447
- switch (inputType) {
448
- case 2:
449
- case 3: return queryHash;
450
- case 4: {
451
- const path$1 = url.path.slice(1);
452
- if (!path$1) return queryHash || ".";
453
- if (isRelative(base || input) && !isRelative(path$1)) return "./" + path$1 + queryHash;
454
- return path$1 + queryHash;
455
- }
456
- case 5: return url.path + queryHash;
457
- default: return url.scheme + "//" + url.user + url.host + url.port + url.path + queryHash;
458
- }
459
- }
460
-
461
- //#endregion
462
- //#region node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs
463
- function stripFilename(path$1) {
464
- if (!path$1) return "";
465
- const index = path$1.lastIndexOf("/");
466
- return path$1.slice(0, index + 1);
467
- }
468
- function resolver(mapUrl, sourceRoot) {
469
- const from = stripFilename(mapUrl);
470
- const prefix = sourceRoot ? sourceRoot + "/" : "";
471
- return (source) => resolve$1(prefix + (source || ""), from);
472
- }
473
- var COLUMN$1 = 0;
474
- function maybeSort(mappings, owned) {
475
- const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
476
- if (unsortedIndex === mappings.length) return mappings;
477
- if (!owned) mappings = mappings.slice();
478
- for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) mappings[i] = sortSegments(mappings[i], owned);
479
- return mappings;
480
- }
481
- function nextUnsortedSegmentLine(mappings, start) {
482
- for (let i = start; i < mappings.length; i++) if (!isSorted(mappings[i])) return i;
483
- return mappings.length;
484
- }
485
- function isSorted(line) {
486
- for (let j = 1; j < line.length; j++) if (line[j][COLUMN$1] < line[j - 1][COLUMN$1]) return false;
487
- return true;
488
- }
489
- function sortSegments(line, owned) {
490
- if (!owned) line = line.slice();
491
- return line.sort(sortComparator);
492
- }
493
- function sortComparator(a, b) {
494
- return a[COLUMN$1] - b[COLUMN$1];
495
- }
496
- var found = false;
497
- function binarySearch(haystack, needle, low, high) {
498
- while (low <= high) {
499
- const mid = low + (high - low >> 1);
500
- const cmp = haystack[mid][COLUMN$1] - needle;
501
- if (cmp === 0) {
502
- found = true;
503
- return mid;
504
- }
505
- if (cmp < 0) low = mid + 1;
506
- else high = mid - 1;
507
- }
508
- found = false;
509
- return low - 1;
510
- }
511
- function upperBound(haystack, needle, index) {
512
- for (let i = index + 1; i < haystack.length; index = i++) if (haystack[i][COLUMN$1] !== needle) break;
513
- return index;
514
- }
515
- function lowerBound(haystack, needle, index) {
516
- for (let i = index - 1; i >= 0; index = i--) if (haystack[i][COLUMN$1] !== needle) break;
517
- return index;
518
- }
519
- function memoizedState() {
520
- return {
521
- lastKey: -1,
522
- lastNeedle: -1,
523
- lastIndex: -1
524
- };
525
- }
526
- function memoizedBinarySearch(haystack, needle, state, key) {
527
- const { lastKey, lastNeedle, lastIndex } = state;
528
- let low = 0;
529
- let high = haystack.length - 1;
530
- if (key === lastKey) {
531
- if (needle === lastNeedle) {
532
- found = lastIndex !== -1 && haystack[lastIndex][COLUMN$1] === needle;
533
- return lastIndex;
534
- }
535
- if (needle >= lastNeedle) low = lastIndex === -1 ? 0 : lastIndex;
536
- else high = lastIndex;
537
- }
538
- state.lastKey = key;
539
- state.lastNeedle = needle;
540
- return state.lastIndex = binarySearch(haystack, needle, low, high);
541
- }
542
- function parse(map) {
543
- return typeof map === "string" ? JSON.parse(map) : map;
544
- }
545
- var LEAST_UPPER_BOUND = -1;
546
- var GREATEST_LOWER_BOUND = 1;
547
- var TraceMap = class {
548
- constructor(map, mapUrl) {
549
- const isString$1 = typeof map === "string";
550
- if (!isString$1 && map._decodedMemo) return map;
551
- const parsed = parse(map);
552
- const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
553
- this.version = version;
554
- this.file = file;
555
- this.names = names || [];
556
- this.sourceRoot = sourceRoot;
557
- this.sources = sources;
558
- this.sourcesContent = sourcesContent;
559
- this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
560
- const resolve$3 = resolver(mapUrl, sourceRoot);
561
- this.resolvedSources = sources.map(resolve$3);
562
- const { mappings } = parsed;
563
- if (typeof mappings === "string") {
564
- this._encoded = mappings;
565
- this._decoded = void 0;
566
- } else if (Array.isArray(mappings)) {
567
- this._encoded = void 0;
568
- this._decoded = maybeSort(mappings, isString$1);
569
- } else if (parsed.sections) throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);
570
- else throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);
571
- this._decodedMemo = memoizedState();
572
- this._bySources = void 0;
573
- this._bySourceMemos = void 0;
574
- }
575
- };
576
- function cast$1(map) {
577
- return map;
578
- }
579
- function decodedMappings(map) {
580
- var _a;
581
- return (_a = cast$1(map))._decoded || (_a._decoded = decode(cast$1(map)._encoded));
582
- }
583
- function traceSegment(map, line, column) {
584
- const decoded = decodedMappings(map);
585
- if (line >= decoded.length) return null;
586
- const segments = decoded[line];
587
- const index = traceSegmentInternal(segments, cast$1(map)._decodedMemo, line, column, GREATEST_LOWER_BOUND);
588
- return index === -1 ? null : segments[index];
589
- }
590
- function traceSegmentInternal(segments, memo, line, column, bias) {
591
- let index = memoizedBinarySearch(segments, column, memo, line);
592
- if (found) index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
593
- else if (bias === LEAST_UPPER_BOUND) index++;
594
- if (index === -1 || index === segments.length) return -1;
595
- return index;
596
- }
597
-
598
- //#endregion
599
- //#region node_modules/.pnpm/@jridgewell+gen-mapping@0.3.13/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs
600
- var SetArray = class {
601
- constructor() {
602
- this._indexes = { __proto__: null };
603
- this.array = [];
604
- }
605
- };
606
- function cast(set) {
607
- return set;
608
- }
609
- function get(setarr, key) {
610
- return cast(setarr)._indexes[key];
611
- }
612
- function put(setarr, key) {
613
- const index = get(setarr, key);
614
- if (index !== void 0) return index;
615
- const { array, _indexes: indexes } = cast(setarr);
616
- return indexes[key] = array.push(key) - 1;
617
- }
618
- function remove(setarr, key) {
619
- const index = get(setarr, key);
620
- if (index === void 0) return;
621
- const { array, _indexes: indexes } = cast(setarr);
622
- for (let i = index + 1; i < array.length; i++) {
623
- const k = array[i];
624
- array[i - 1] = k;
625
- indexes[k]--;
626
- }
627
- indexes[key] = void 0;
628
- array.pop();
629
- }
630
- var COLUMN = 0;
631
- var SOURCES_INDEX = 1;
632
- var SOURCE_LINE = 2;
633
- var SOURCE_COLUMN = 3;
634
- var NAMES_INDEX = 4;
635
- var NO_NAME = -1;
636
- var GenMapping = class {
637
- constructor({ file, sourceRoot } = {}) {
638
- this._names = new SetArray();
639
- this._sources = new SetArray();
640
- this._sourcesContent = [];
641
- this._mappings = [];
642
- this.file = file;
643
- this.sourceRoot = sourceRoot;
644
- this._ignoreList = new SetArray();
645
- }
646
- };
647
- function cast2(map) {
648
- return map;
649
- }
650
- var maybeAddSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => {
651
- return addSegmentInternal(true, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content);
652
- };
653
- function setSourceContent(map, source, content) {
654
- const { _sources: sources, _sourcesContent: sourcesContent } = cast2(map);
655
- const index = put(sources, source);
656
- sourcesContent[index] = content;
657
- }
658
- function setIgnore(map, source, ignore = true) {
659
- const { _sources: sources, _sourcesContent: sourcesContent, _ignoreList: ignoreList } = cast2(map);
660
- const index = put(sources, source);
661
- if (index === sourcesContent.length) sourcesContent[index] = null;
662
- if (ignore) put(ignoreList, index);
663
- else remove(ignoreList, index);
664
- }
665
- function toDecodedMap(map) {
666
- const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, _ignoreList: ignoreList } = cast2(map);
667
- removeEmptyFinalLines(mappings);
668
- return {
669
- version: 3,
670
- file: map.file || void 0,
671
- names: names.array,
672
- sourceRoot: map.sourceRoot || void 0,
673
- sources: sources.array,
674
- sourcesContent,
675
- mappings,
676
- ignoreList: ignoreList.array
677
- };
678
- }
679
- function toEncodedMap(map) {
680
- const decoded = toDecodedMap(map);
681
- return Object.assign({}, decoded, { mappings: encode(decoded.mappings) });
682
- }
683
- function addSegmentInternal(skipable, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) {
684
- const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names } = cast2(map);
685
- const line = getIndex(mappings, genLine);
686
- const index = getColumnIndex(line, genColumn);
687
- if (!source) {
688
- if (skipable && skipSourceless(line, index)) return;
689
- return insert(line, index, [genColumn]);
690
- }
691
- assert(sourceLine);
692
- assert(sourceColumn);
693
- const sourcesIndex = put(sources, source);
694
- const namesIndex = name ? put(names, name) : NO_NAME;
695
- if (sourcesIndex === sourcesContent.length) sourcesContent[sourcesIndex] = content != null ? content : null;
696
- if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) return;
697
- return insert(line, index, name ? [
698
- genColumn,
699
- sourcesIndex,
700
- sourceLine,
701
- sourceColumn,
702
- namesIndex
703
- ] : [
704
- genColumn,
705
- sourcesIndex,
706
- sourceLine,
707
- sourceColumn
708
- ]);
709
- }
710
- function assert(_val) {}
711
- function getIndex(arr, index) {
712
- for (let i = arr.length; i <= index; i++) arr[i] = [];
713
- return arr[index];
714
- }
715
- function getColumnIndex(line, genColumn) {
716
- let index = line.length;
717
- for (let i = index - 1; i >= 0; index = i--) if (genColumn >= line[i][COLUMN]) break;
718
- return index;
719
- }
720
- function insert(array, index, value) {
721
- for (let i = array.length; i > index; i--) array[i] = array[i - 1];
722
- array[index] = value;
723
- }
724
- function removeEmptyFinalLines(mappings) {
725
- const { length } = mappings;
726
- let len = length;
727
- for (let i = len - 1; i >= 0; len = i, i--) if (mappings[i].length > 0) break;
728
- if (len < length) mappings.length = len;
729
- }
730
- function skipSourceless(line, index) {
731
- if (index === 0) return true;
732
- return line[index - 1].length === 1;
733
- }
734
- function skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex) {
735
- if (index === 0) return false;
736
- const prev = line[index - 1];
737
- if (prev.length === 1) return false;
738
- return sourcesIndex === prev[SOURCES_INDEX] && sourceLine === prev[SOURCE_LINE] && sourceColumn === prev[SOURCE_COLUMN] && namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME);
739
- }
740
-
741
- //#endregion
742
- //#region node_modules/.pnpm/@jridgewell+remapping@2.3.5/node_modules/@jridgewell/remapping/dist/remapping.mjs
743
- var SOURCELESS_MAPPING = /* @__PURE__ */ SegmentObject("", -1, -1, "", null, false);
744
- var EMPTY_SOURCES = [];
745
- function SegmentObject(source, line, column, name, content, ignore) {
746
- return {
747
- source,
748
- line,
749
- column,
750
- name,
751
- content,
752
- ignore
753
- };
754
- }
755
- function Source(map, sources, source, content, ignore) {
756
- return {
757
- map,
758
- sources,
759
- source,
760
- content,
761
- ignore
762
- };
763
- }
764
- function MapSource(map, sources) {
765
- return Source(map, sources, "", null, false);
766
- }
767
- function OriginalSource(source, content, ignore) {
768
- return Source(null, EMPTY_SOURCES, source, content, ignore);
769
- }
770
- function traceMappings(tree) {
771
- const gen = new GenMapping({ file: tree.map.file });
772
- const { sources: rootSources, map } = tree;
773
- const rootNames = map.names;
774
- const rootMappings = decodedMappings(map);
775
- for (let i = 0; i < rootMappings.length; i++) {
776
- const segments = rootMappings[i];
777
- for (let j = 0; j < segments.length; j++) {
778
- const segment = segments[j];
779
- const genCol = segment[0];
780
- let traced = SOURCELESS_MAPPING;
781
- if (segment.length !== 1) {
782
- const source2 = rootSources[segment[1]];
783
- traced = originalPositionFor(source2, segment[2], segment[3], segment.length === 5 ? rootNames[segment[4]] : "");
784
- if (traced == null) continue;
785
- }
786
- const { column, line, name, content, source, ignore } = traced;
787
- maybeAddSegment(gen, i, genCol, source, line, column, name);
788
- if (source && content != null) setSourceContent(gen, source, content);
789
- if (ignore) setIgnore(gen, source, true);
790
- }
791
- }
792
- return gen;
793
- }
794
- function originalPositionFor(source, line, column, name) {
795
- if (!source.map) return SegmentObject(source.source, line, column, name, source.content, source.ignore);
796
- const segment = traceSegment(source.map, line, column);
797
- if (segment == null) return null;
798
- if (segment.length === 1) return SOURCELESS_MAPPING;
799
- return originalPositionFor(source.sources[segment[1]], segment[2], segment[3], segment.length === 5 ? source.map.names[segment[4]] : name);
800
- }
801
- function asArray(value) {
802
- if (Array.isArray(value)) return value;
803
- return [value];
804
- }
805
- function buildSourceMapTree(input, loader) {
806
- const maps = asArray(input).map((m) => new TraceMap(m, ""));
807
- const map = maps.pop();
808
- for (let i = 0; i < maps.length; i++) if (maps[i].sources.length > 1) throw new Error(`Transformation map ${i} must have exactly one source file.
809
- Did you specify these with the most recent transformation maps first?`);
810
- let tree = build(map, loader, "", 0);
811
- for (let i = maps.length - 1; i >= 0; i--) tree = MapSource(maps[i], [tree]);
812
- return tree;
813
- }
814
- function build(map, loader, importer, importerDepth) {
815
- const { resolvedSources, sourcesContent, ignoreList } = map;
816
- const depth = importerDepth + 1;
817
- return MapSource(map, resolvedSources.map((sourceFile, i) => {
818
- const ctx = {
819
- importer,
820
- depth,
821
- source: sourceFile || "",
822
- content: void 0,
823
- ignore: void 0
824
- };
825
- const sourceMap = loader(ctx.source, ctx);
826
- const { source, content, ignore } = ctx;
827
- if (sourceMap) return build(new TraceMap(sourceMap, source), loader, source, depth);
828
- return OriginalSource(source, content !== void 0 ? content : sourcesContent ? sourcesContent[i] : null, ignore !== void 0 ? ignore : ignoreList ? ignoreList.includes(i) : false);
829
- }));
830
- }
831
- var SourceMap = class {
832
- constructor(map, options) {
833
- const out = options.decodedMappings ? toDecodedMap(map) : toEncodedMap(map);
834
- this.version = out.version;
835
- this.file = out.file;
836
- this.mappings = out.mappings;
837
- this.names = out.names;
838
- this.ignoreList = out.ignoreList;
839
- this.sourceRoot = out.sourceRoot;
840
- this.sources = out.sources;
841
- if (!options.excludeContent) this.sourcesContent = out.sourcesContent;
842
- }
843
- toString() {
844
- return JSON.stringify(this);
845
- }
846
- };
847
- function remapping(input, loader, options) {
848
- const opts = typeof options === "object" ? options : {
849
- excludeContent: !!options,
850
- decodedMappings: false
851
- };
852
- return new SourceMap(traceMappings(buildSourceMapTree(input, loader)), opts);
853
- }
854
-
855
- //#endregion
856
- //#region node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/virtual-stats.js
857
- var require_virtual_stats = /* @__PURE__ */ __commonJSMin(((exports) => {
858
- var __importDefault = exports && exports.__importDefault || function(mod) {
859
- return mod && mod.__esModule ? mod : { "default": mod };
860
- };
861
- Object.defineProperty(exports, "__esModule", { value: true });
862
- exports.VirtualStats = void 0;
863
- const constants_1 = __importDefault(__require("constants"));
864
- var VirtualStats = class {
865
- constructor(config) {
866
- for (const key in config) {
867
- if (!Object.prototype.hasOwnProperty.call(config, key)) continue;
868
- this[key] = config[key];
869
- }
870
- }
871
- _checkModeProperty(property) {
872
- return (this.mode & constants_1.default.S_IFMT) === property;
873
- }
874
- isDirectory() {
875
- return this._checkModeProperty(constants_1.default.S_IFDIR);
876
- }
877
- isFile() {
878
- return this._checkModeProperty(constants_1.default.S_IFREG);
879
- }
880
- isBlockDevice() {
881
- return this._checkModeProperty(constants_1.default.S_IFBLK);
882
- }
883
- isCharacterDevice() {
884
- return this._checkModeProperty(constants_1.default.S_IFCHR);
885
- }
886
- isSymbolicLink() {
887
- return this._checkModeProperty(constants_1.default.S_IFLNK);
888
- }
889
- isFIFO() {
890
- return this._checkModeProperty(constants_1.default.S_IFIFO);
891
- }
892
- isSocket() {
893
- return this._checkModeProperty(constants_1.default.S_IFSOCK);
894
- }
895
- };
896
- exports.VirtualStats = VirtualStats;
897
- }));
898
-
899
- //#endregion
900
- //#region node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/index.js
901
- var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
902
- const path_1 = (exports && exports.__importDefault || function(mod) {
903
- return mod && mod.__esModule ? mod : { "default": mod };
904
- })(__require("path"));
905
- const virtual_stats_1 = require_virtual_stats();
906
- let inode = 45e6;
907
- const ALL = "all";
908
- const STATIC = "static";
909
- const DYNAMIC = "dynamic";
910
- function checkActivation(instance) {
911
- if (!instance._compiler) throw new Error("You must use this plugin only after creating webpack instance!");
912
- }
913
- function getModulePath(filePath, compiler) {
914
- return path_1.default.isAbsolute(filePath) ? filePath : path_1.default.join(compiler.context, filePath);
915
- }
916
- function createWebpackData(result) {
917
- return (backendOrStorage) => {
918
- if (backendOrStorage._data) {
919
- const curLevelIdx = backendOrStorage._currentLevel;
920
- return {
921
- result,
922
- level: backendOrStorage._levels[curLevelIdx]
923
- };
924
- }
925
- return [null, result];
926
- };
927
- }
928
- function getData(storage, key) {
929
- if (storage._data instanceof Map) return storage._data.get(key);
930
- else if (storage._data) return storage.data[key];
931
- else if (storage.data instanceof Map) return storage.data.get(key);
932
- else return storage.data[key];
933
- }
934
- function setData(backendOrStorage, key, valueFactory) {
935
- const value = valueFactory(backendOrStorage);
936
- if (backendOrStorage._data instanceof Map) backendOrStorage._data.set(key, value);
937
- else if (backendOrStorage._data) backendOrStorage.data[key] = value;
938
- else if (backendOrStorage.data instanceof Map) backendOrStorage.data.set(key, value);
939
- else backendOrStorage.data[key] = value;
940
- }
941
- function getStatStorage(fileSystem) {
942
- if (fileSystem._statStorage) return fileSystem._statStorage;
943
- else if (fileSystem._statBackend) return fileSystem._statBackend;
944
- else throw new Error("Couldn't find a stat storage");
945
- }
946
- function getFileStorage(fileSystem) {
947
- if (fileSystem._readFileStorage) return fileSystem._readFileStorage;
948
- else if (fileSystem._readFileBackend) return fileSystem._readFileBackend;
949
- else throw new Error("Couldn't find a readFileStorage");
950
- }
951
- function getReadDirBackend(fileSystem) {
952
- if (fileSystem._readdirBackend) return fileSystem._readdirBackend;
953
- else if (fileSystem._readdirStorage) return fileSystem._readdirStorage;
954
- else throw new Error("Couldn't find a readDirStorage from Webpack Internals");
955
- }
956
- function getRealpathBackend(fileSystem) {
957
- if (fileSystem._realpathBackend) return fileSystem._realpathBackend;
958
- }
959
- var VirtualModulesPlugin = class {
960
- constructor(modules) {
961
- this._compiler = null;
962
- this._watcher = null;
963
- this._staticModules = modules || null;
964
- }
965
- getModuleList(filter = ALL) {
966
- var _a, _b;
967
- let modules = {};
968
- const shouldGetStaticModules = filter === ALL || filter === STATIC;
969
- const shouldGetDynamicModules = filter === ALL || filter === DYNAMIC;
970
- if (shouldGetStaticModules) modules = Object.assign(Object.assign({}, modules), this._staticModules);
971
- if (shouldGetDynamicModules) {
972
- const finalInputFileSystem = (_a = this._compiler) === null || _a === void 0 ? void 0 : _a.inputFileSystem;
973
- const virtualFiles = (_b = finalInputFileSystem === null || finalInputFileSystem === void 0 ? void 0 : finalInputFileSystem._virtualFiles) !== null && _b !== void 0 ? _b : {};
974
- const dynamicModules = {};
975
- Object.keys(virtualFiles).forEach((key) => {
976
- dynamicModules[key] = virtualFiles[key].contents;
977
- });
978
- modules = Object.assign(Object.assign({}, modules), dynamicModules);
979
- }
980
- return modules;
981
- }
982
- writeModule(filePath, contents) {
983
- if (!this._compiler) throw new Error(`Plugin has not been initialized`);
984
- checkActivation(this);
985
- const len = contents ? contents.length : 0;
986
- const time = Date.now();
987
- const date = new Date(time);
988
- const stats = new virtual_stats_1.VirtualStats({
989
- dev: 8675309,
990
- nlink: 0,
991
- uid: 1e3,
992
- gid: 1e3,
993
- rdev: 0,
994
- blksize: 4096,
995
- ino: inode++,
996
- mode: 33188,
997
- size: len,
998
- blocks: Math.floor(len / 4096),
999
- atime: date,
1000
- mtime: date,
1001
- ctime: date,
1002
- birthtime: date
1003
- });
1004
- const modulePath = getModulePath(filePath, this._compiler);
1005
- if (process.env.WVM_DEBUG) console.log(this._compiler.name, "Write virtual module:", modulePath, contents);
1006
- let finalWatchFileSystem = this._watcher && this._watcher.watchFileSystem;
1007
- while (finalWatchFileSystem && finalWatchFileSystem.wfs) finalWatchFileSystem = finalWatchFileSystem.wfs;
1008
- let finalInputFileSystem = this._compiler.inputFileSystem;
1009
- while (finalInputFileSystem && finalInputFileSystem._inputFileSystem) finalInputFileSystem = finalInputFileSystem._inputFileSystem;
1010
- finalInputFileSystem._writeVirtualFile(modulePath, stats, contents);
1011
- if (finalWatchFileSystem && finalWatchFileSystem.watcher && (finalWatchFileSystem.watcher.fileWatchers.size || finalWatchFileSystem.watcher.fileWatchers.length)) {
1012
- const fileWatchers = finalWatchFileSystem.watcher.fileWatchers instanceof Map ? Array.from(finalWatchFileSystem.watcher.fileWatchers.values()) : finalWatchFileSystem.watcher.fileWatchers;
1013
- for (let fileWatcher of fileWatchers) {
1014
- if ("watcher" in fileWatcher) fileWatcher = fileWatcher.watcher;
1015
- if (fileWatcher.path === modulePath) {
1016
- if (process.env.DEBUG) console.log(this._compiler.name, "Emit file change:", modulePath, time);
1017
- delete fileWatcher.directoryWatcher._cachedTimeInfoEntries;
1018
- fileWatcher.emit("change", time, null);
1019
- }
1020
- }
1021
- }
1022
- }
1023
- apply(compiler) {
1024
- this._compiler = compiler;
1025
- const afterEnvironmentHook = () => {
1026
- let finalInputFileSystem = compiler.inputFileSystem;
1027
- while (finalInputFileSystem && finalInputFileSystem._inputFileSystem) finalInputFileSystem = finalInputFileSystem._inputFileSystem;
1028
- if (!finalInputFileSystem._writeVirtualFile) {
1029
- const originalPurge = finalInputFileSystem.purge;
1030
- finalInputFileSystem.purge = () => {
1031
- originalPurge.apply(finalInputFileSystem, []);
1032
- if (finalInputFileSystem._virtualFiles) Object.keys(finalInputFileSystem._virtualFiles).forEach((file) => {
1033
- const data = finalInputFileSystem._virtualFiles[file];
1034
- finalInputFileSystem._writeVirtualFile(file, data.stats, data.contents);
1035
- });
1036
- };
1037
- finalInputFileSystem._writeVirtualFile = (file, stats, contents) => {
1038
- const statStorage = getStatStorage(finalInputFileSystem);
1039
- const fileStorage = getFileStorage(finalInputFileSystem);
1040
- const readDirStorage = getReadDirBackend(finalInputFileSystem);
1041
- const realPathStorage = getRealpathBackend(finalInputFileSystem);
1042
- finalInputFileSystem._virtualFiles = finalInputFileSystem._virtualFiles || {};
1043
- finalInputFileSystem._virtualFiles[file] = {
1044
- stats,
1045
- contents
1046
- };
1047
- setData(statStorage, file, createWebpackData(stats));
1048
- setData(fileStorage, file, createWebpackData(contents));
1049
- const segments = file.split(/[\\/]/);
1050
- let count = segments.length - 1;
1051
- const minCount = segments[0] ? 1 : 0;
1052
- while (count > minCount) {
1053
- const dir = segments.slice(0, count).join(path_1.default.sep) || path_1.default.sep;
1054
- try {
1055
- finalInputFileSystem.readdirSync(dir);
1056
- } catch (e) {
1057
- const time = Date.now();
1058
- const dirStats = new virtual_stats_1.VirtualStats({
1059
- dev: 8675309,
1060
- nlink: 0,
1061
- uid: 1e3,
1062
- gid: 1e3,
1063
- rdev: 0,
1064
- blksize: 4096,
1065
- ino: inode++,
1066
- mode: 16877,
1067
- size: stats.size,
1068
- blocks: Math.floor(stats.size / 4096),
1069
- atime: time,
1070
- mtime: time,
1071
- ctime: time,
1072
- birthtime: time
1073
- });
1074
- setData(readDirStorage, dir, createWebpackData([]));
1075
- if (realPathStorage) setData(realPathStorage, dir, createWebpackData(dir));
1076
- setData(statStorage, dir, createWebpackData(dirStats));
1077
- }
1078
- let dirData = getData(getReadDirBackend(finalInputFileSystem), dir);
1079
- dirData = dirData[1] || dirData.result;
1080
- const filename = segments[count];
1081
- if (dirData.indexOf(filename) < 0) {
1082
- const files = dirData.concat([filename]).sort();
1083
- setData(getReadDirBackend(finalInputFileSystem), dir, createWebpackData(files));
1084
- } else break;
1085
- count--;
1086
- }
1087
- };
1088
- }
1089
- };
1090
- const afterResolversHook = () => {
1091
- if (this._staticModules) {
1092
- for (const [filePath, contents] of Object.entries(this._staticModules)) this.writeModule(filePath, contents);
1093
- this._staticModules = null;
1094
- }
1095
- };
1096
- const version = typeof compiler.webpack === "undefined" ? 4 : 5;
1097
- const watchRunHook = (watcher, callback) => {
1098
- this._watcher = watcher.compiler || watcher;
1099
- const virtualFiles = compiler.inputFileSystem._virtualFiles;
1100
- const fts = compiler.fileTimestamps;
1101
- if (virtualFiles && fts && typeof fts.set === "function") Object.keys(virtualFiles).forEach((file) => {
1102
- const mtime = +virtualFiles[file].stats.mtime;
1103
- fts.set(file, version === 4 ? mtime : {
1104
- safeTime: mtime,
1105
- timestamp: mtime
1106
- });
1107
- });
1108
- callback();
1109
- };
1110
- if (compiler.hooks) {
1111
- compiler.hooks.afterEnvironment.tap("VirtualModulesPlugin", afterEnvironmentHook);
1112
- compiler.hooks.afterResolvers.tap("VirtualModulesPlugin", afterResolversHook);
1113
- compiler.hooks.watchRun.tapAsync("VirtualModulesPlugin", watchRunHook);
1114
- } else {
1115
- compiler.plugin("after-environment", afterEnvironmentHook);
1116
- compiler.plugin("after-resolvers", afterResolversHook);
1117
- compiler.plugin("watch-run", watchRunHook);
1118
- }
1119
- }
1120
- };
1121
- module.exports = VirtualModulesPlugin;
1122
- }));
1123
-
1124
- //#endregion
1125
- //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/index.js
1126
- var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
1127
- const ExtToLoader = {
1128
- ".js": "js",
1129
- ".mjs": "js",
1130
- ".cjs": "js",
1131
- ".jsx": "jsx",
1132
- ".ts": "ts",
1133
- ".cts": "ts",
1134
- ".mts": "ts",
1135
- ".tsx": "tsx",
1136
- ".css": "css",
1137
- ".less": "css",
1138
- ".stylus": "css",
1139
- ".scss": "css",
1140
- ".sass": "css",
1141
- ".json": "json",
1142
- ".txt": "text"
1143
- };
1144
- function guessLoader(code, id) {
1145
- return ExtToLoader[path.extname(id).toLowerCase()] || "js";
1146
- }
1147
- function unwrapLoader(loader, code, id) {
1148
- if (typeof loader === "function") return loader(code, id);
1149
- return loader;
1150
- }
1151
- function fixSourceMap(map) {
1152
- if (!Object.prototype.hasOwnProperty.call(map, "toString")) Object.defineProperty(map, "toString", {
1153
- enumerable: false,
1154
- value: function toString() {
1155
- return JSON.stringify(this);
1156
- }
1157
- });
1158
- if (!Object.prototype.hasOwnProperty.call(map, "toUrl")) Object.defineProperty(map, "toUrl", {
1159
- enumerable: false,
1160
- value: function toUrl() {
1161
- return `data:application/json;charset=utf-8;base64,${Buffer.from(this.toString()).toString("base64")}`;
1162
- }
1163
- });
1164
- return map;
1165
- }
1166
- const nullSourceMap = {
1167
- names: [],
1168
- sources: [],
1169
- mappings: "",
1170
- version: 3
1171
- };
1172
- function combineSourcemaps(filename, sourcemapList) {
1173
- sourcemapList = sourcemapList.filter((m) => m.sources);
1174
- if (sourcemapList.length === 0 || sourcemapList.every((m) => m.sources.length === 0)) return { ...nullSourceMap };
1175
- let map;
1176
- let mapIndex = 1;
1177
- if (sourcemapList.slice(0, -1).find((m) => m.sources.length !== 1) === void 0) map = remapping(sourcemapList, () => null, true);
1178
- else map = remapping(sourcemapList[0], (sourcefile) => {
1179
- if (sourcefile === filename && sourcemapList[mapIndex]) return sourcemapList[mapIndex++];
1180
- else return { ...nullSourceMap };
1181
- }, true);
1182
- if (!map.file) delete map.file;
1183
- return map;
1184
- }
1185
- function createBuildContext$2(build$1) {
1186
- const watchFiles = [];
1187
- const { initialOptions } = build$1;
1188
- return {
1189
- parse: parse$1,
1190
- addWatchFile() {
1191
- throw new Error("unplugin/esbuild: addWatchFile outside supported hooks (resolveId, load, transform)");
1192
- },
1193
- emitFile(emittedFile) {
1194
- const outFileName = emittedFile.fileName || emittedFile.name;
1195
- if (initialOptions.outdir && emittedFile.source && outFileName) {
1196
- const outPath = path.resolve(initialOptions.outdir, outFileName);
1197
- const outDir = path.dirname(outPath);
1198
- if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true });
1199
- fs.writeFileSync(outPath, emittedFile.source);
1200
- }
1201
- },
1202
- getWatchFiles() {
1203
- return watchFiles;
1204
- },
1205
- getNativeBuildContext() {
1206
- return {
1207
- framework: "esbuild",
1208
- build: build$1
1209
- };
1210
- }
1211
- };
1212
- }
1213
- function createPluginContext(context) {
1214
- const errors = [];
1215
- const warnings = [];
1216
- const pluginContext = {
1217
- error(message) {
1218
- errors.push(normalizeMessage$2(message));
1219
- },
1220
- warn(message) {
1221
- warnings.push(normalizeMessage$2(message));
1222
- }
1223
- };
1224
- return {
1225
- errors,
1226
- warnings,
1227
- mixedContext: {
1228
- ...context,
1229
- ...pluginContext,
1230
- addWatchFile(id) {
1231
- context.getWatchFiles().push(id);
1232
- }
1233
- }
1234
- };
1235
- }
1236
- function normalizeMessage$2(message) {
1237
- if (typeof message === "string") message = { message };
1238
- return {
1239
- id: message.id,
1240
- pluginName: message.plugin,
1241
- text: message.message,
1242
- location: message.loc ? {
1243
- file: message.loc.file,
1244
- line: message.loc.line,
1245
- column: message.loc.column
1246
- } : null,
1247
- detail: message.meta,
1248
- notes: []
1249
- };
1250
- }
1251
- function processCodeWithSourceMap(map, code) {
1252
- if (map) {
1253
- if (!map.sourcesContent || map.sourcesContent.length === 0) map.sourcesContent = [code];
1254
- map = fixSourceMap(map);
1255
- code += `\n//# sourceMappingURL=${map.toUrl()}`;
1256
- }
1257
- return code;
1258
- }
1259
- function getEsbuildPlugin(factory) {
1260
- return (userOptions) => {
1261
- const meta = { framework: "esbuild" };
1262
- const plugins = toArray$2(factory(userOptions, meta));
1263
- const setupPlugins = async (build$1) => {
1264
- const setup = buildSetup();
1265
- const loaders = [];
1266
- for (const plugin of plugins) {
1267
- const loader = {};
1268
- await setup(plugin)({
1269
- ...build$1,
1270
- onLoad(_options, callback) {
1271
- loader.options = _options;
1272
- loader.onLoadCb = callback;
1273
- },
1274
- onTransform(_options, callback) {
1275
- loader.options ||= _options;
1276
- loader.onTransformCb = callback;
1277
- }
1278
- }, build$1);
1279
- if (loader.onLoadCb || loader.onTransformCb) loaders.push(loader);
1280
- }
1281
- if (loaders.length) build$1.onLoad(loaders.length === 1 ? loaders[0].options : { filter: /.*/ }, async (args) => {
1282
- function checkFilter(options) {
1283
- return loaders.length === 1 || !options?.filter || options.filter.test(args.path);
1284
- }
1285
- let result;
1286
- for (const { options, onLoadCb } of loaders) {
1287
- if (!checkFilter(options)) continue;
1288
- if (onLoadCb) result = await onLoadCb(args);
1289
- if (result?.contents) break;
1290
- }
1291
- let fsContentsCache;
1292
- for (const { options, onTransformCb } of loaders) {
1293
- if (!checkFilter(options)) continue;
1294
- if (onTransformCb) {
1295
- const _result = await onTransformCb({
1296
- ...result,
1297
- ...args,
1298
- async getContents() {
1299
- if (result?.contents) return result.contents;
1300
- if (fsContentsCache) return fsContentsCache;
1301
- return fsContentsCache = await fs.promises.readFile(args.path, "utf8");
1302
- }
1303
- });
1304
- if (_result?.contents) result = _result;
1305
- }
1306
- }
1307
- if (result?.contents) return result;
1308
- });
1309
- };
1310
- return {
1311
- name: (plugins.length === 1 ? plugins[0].name : meta.esbuildHostName) ?? `unplugin-host:${plugins.map((p) => p.name).join(":")}`,
1312
- setup: setupPlugins
1313
- };
1314
- };
1315
- }
1316
- function buildSetup() {
1317
- return (plugin) => {
1318
- return (build$1, rawBuild) => {
1319
- const context = createBuildContext$2(rawBuild);
1320
- const { onStart, onEnd, onResolve, onLoad, onTransform, initialOptions } = build$1;
1321
- const onResolveFilter = plugin.esbuild?.onResolveFilter ?? /.*/;
1322
- const onLoadFilter = plugin.esbuild?.onLoadFilter ?? /.*/;
1323
- const loader = plugin.esbuild?.loader ?? guessLoader;
1324
- plugin.esbuild?.config?.call(context, initialOptions);
1325
- if (plugin.buildStart) onStart(() => plugin.buildStart.call(context));
1326
- if (plugin.buildEnd || plugin.writeBundle) onEnd(async () => {
1327
- if (plugin.buildEnd) await plugin.buildEnd.call(context);
1328
- if (plugin.writeBundle) await plugin.writeBundle();
1329
- });
1330
- if (plugin.resolveId) onResolve({ filter: onResolveFilter }, async (args) => {
1331
- const id = args.path;
1332
- if (initialOptions.external?.includes(id)) return;
1333
- const { handler, filter } = normalizeObjectHook("resolveId", plugin.resolveId);
1334
- if (!filter(id)) return;
1335
- const { errors, warnings, mixedContext } = createPluginContext(context);
1336
- const isEntry = args.kind === "entry-point";
1337
- const result = await handler.call(mixedContext, id, isEntry ? void 0 : args.importer, { isEntry });
1338
- if (typeof result === "string") return {
1339
- path: result,
1340
- namespace: plugin.name,
1341
- errors,
1342
- warnings,
1343
- watchFiles: mixedContext.getWatchFiles()
1344
- };
1345
- else if (typeof result === "object" && result !== null) return {
1346
- path: result.id,
1347
- external: result.external,
1348
- namespace: plugin.name,
1349
- errors,
1350
- warnings,
1351
- watchFiles: mixedContext.getWatchFiles()
1352
- };
1353
- });
1354
- if (plugin.load) onLoad({ filter: onLoadFilter }, async (args) => {
1355
- const { handler, filter } = normalizeObjectHook("load", plugin.load);
1356
- const id = args.path + (args.suffix || "");
1357
- if (plugin.loadInclude && !plugin.loadInclude(id)) return;
1358
- if (!filter(id)) return;
1359
- const { errors, warnings, mixedContext } = createPluginContext(context);
1360
- let code;
1361
- let map;
1362
- const result = await handler.call(mixedContext, id);
1363
- if (typeof result === "string") code = result;
1364
- else if (typeof result === "object" && result !== null) {
1365
- code = result.code;
1366
- map = result.map;
1367
- }
1368
- if (code === void 0) return null;
1369
- if (map) code = processCodeWithSourceMap(map, code);
1370
- const resolveDir = path.dirname(args.path);
1371
- return {
1372
- contents: code,
1373
- errors,
1374
- warnings,
1375
- watchFiles: mixedContext.getWatchFiles(),
1376
- loader: unwrapLoader(loader, code, args.path),
1377
- resolveDir
1378
- };
1379
- });
1380
- if (plugin.transform) onTransform({ filter: onLoadFilter }, async (args) => {
1381
- const { handler, filter } = normalizeObjectHook("transform", plugin.transform);
1382
- const id = args.path + (args.suffix || "");
1383
- if (plugin.transformInclude && !plugin.transformInclude(id)) return;
1384
- let code = await args.getContents();
1385
- if (!filter(id, code)) return;
1386
- const { mixedContext, errors, warnings } = createPluginContext(context);
1387
- const resolveDir = path.dirname(args.path);
1388
- let map;
1389
- const result = await handler.call(mixedContext, code, id);
1390
- if (typeof result === "string") code = result;
1391
- else if (typeof result === "object" && result !== null) {
1392
- code = result.code;
1393
- if (map && result.map) map = combineSourcemaps(args.path, [result.map === "string" ? JSON.parse(result.map) : result.map, map]);
1394
- else if (typeof result.map === "string") map = JSON.parse(result.map);
1395
- else map = result.map;
1396
- }
1397
- if (code) {
1398
- if (map) code = processCodeWithSourceMap(map, code);
1399
- return {
1400
- contents: code,
1401
- errors,
1402
- warnings,
1403
- watchFiles: mixedContext.getWatchFiles(),
1404
- loader: unwrapLoader(loader, code, args.path),
1405
- resolveDir
1406
- };
1407
- }
1408
- });
1409
- if (plugin.esbuild?.setup) return plugin.esbuild.setup(rawBuild);
1410
- };
1411
- };
1412
- }
1413
- function createFarmContext(context, currentResolveId) {
1414
- return {
1415
- parse: parse$1,
1416
- addWatchFile(id) {
1417
- context.addWatchFile(id, currentResolveId || id);
1418
- },
1419
- emitFile(emittedFile) {
1420
- const outFileName = emittedFile.fileName || emittedFile.name;
1421
- if (emittedFile.source && outFileName) context.emitFile({
1422
- resolvedPath: outFileName,
1423
- name: outFileName,
1424
- content: [...Buffer.from(emittedFile.source)],
1425
- resourceType: extname(outFileName)
1426
- });
1427
- },
1428
- getWatchFiles() {
1429
- return context.getWatchFiles();
1430
- },
1431
- getNativeBuildContext() {
1432
- return {
1433
- framework: "farm",
1434
- context
1435
- };
1436
- }
1437
- };
1438
- }
1439
- function unpluginContext(context) {
1440
- return {
1441
- error: (error) => context.error(typeof error === "string" ? new Error(error) : error),
1442
- warn: (error) => context.warn(typeof error === "string" ? new Error(error) : error)
1443
- };
1444
- }
1445
- function convertEnforceToPriority(value) {
1446
- const defaultPriority = 100;
1447
- const enforceToPriority = {
1448
- pre: 102,
1449
- post: 98
1450
- };
1451
- return enforceToPriority[value] !== void 0 ? enforceToPriority[value] : defaultPriority;
1452
- }
1453
- function convertWatchEventChange(value) {
1454
- return {
1455
- Added: "create",
1456
- Updated: "update",
1457
- Removed: "delete"
1458
- }[value];
1459
- }
1460
- function isString(variable) {
1461
- return typeof variable === "string";
1462
- }
1463
- function isObject(variable) {
1464
- return typeof variable === "object" && variable !== null;
1465
- }
1466
- function customParseQueryString(url) {
1467
- if (!url) return [];
1468
- const queryString = url.split("?")[1];
1469
- const parsedParams = querystring.parse(queryString);
1470
- const paramsArray = [];
1471
- for (const key in parsedParams) paramsArray.push([key, parsedParams[key]]);
1472
- return paramsArray;
1473
- }
1474
- function encodeStr(str) {
1475
- const len = str.length;
1476
- if (len === 0) return str;
1477
- const firstNullIndex = str.indexOf("\0");
1478
- if (firstNullIndex === -1) return str;
1479
- const result = Array.from({ length: len + countNulls(str, firstNullIndex) });
1480
- let pos = 0;
1481
- for (let i = 0; i < firstNullIndex; i++) result[pos++] = str[i];
1482
- for (let i = firstNullIndex; i < len; i++) {
1483
- const char = str[i];
1484
- if (char === "\0") {
1485
- result[pos++] = "\\";
1486
- result[pos++] = "0";
1487
- } else result[pos++] = char;
1488
- }
1489
- return path.posix.normalize(result.join(""));
1490
- }
1491
- function decodeStr(str) {
1492
- const len = str.length;
1493
- if (len === 0) return str;
1494
- const firstIndex = str.indexOf("\\0");
1495
- if (firstIndex === -1) return str;
1496
- const result = Array.from({ length: len - countBackslashZeros(str, firstIndex) });
1497
- let pos = 0;
1498
- for (let i$1 = 0; i$1 < firstIndex; i$1++) result[pos++] = str[i$1];
1499
- let i = firstIndex;
1500
- while (i < len) if (str[i] === "\\" && str[i + 1] === "0") {
1501
- result[pos++] = "\0";
1502
- i += 2;
1503
- } else result[pos++] = str[i++];
1504
- return path.posix.normalize(result.join(""));
1505
- }
1506
- function getContentValue(content) {
1507
- if (content === null || content === void 0) throw new Error("Content cannot be null or undefined");
1508
- return encodeStr(typeof content === "string" ? content : content.code || "");
1509
- }
1510
- function countNulls(str, startIndex) {
1511
- let count = 0;
1512
- const len = str.length;
1513
- for (let i = startIndex; i < len; i++) if (str[i] === "\0") count++;
1514
- return count;
1515
- }
1516
- function countBackslashZeros(str, startIndex) {
1517
- let count = 0;
1518
- const len = str.length;
1519
- for (let i = startIndex; i < len - 1; i++) if (str[i] === "\\" && str[i + 1] === "0") {
1520
- count++;
1521
- i++;
1522
- }
1523
- return count;
1524
- }
1525
- function removeQuery(pathe) {
1526
- const queryIndex = pathe.indexOf("?");
1527
- if (queryIndex !== -1) return path.posix.normalize(pathe.slice(0, queryIndex));
1528
- return path.posix.normalize(pathe);
1529
- }
1530
- function isStartsWithSlash(str) {
1531
- return str?.startsWith("/");
1532
- }
1533
- function appendQuery(id, query) {
1534
- if (!query.length) return id;
1535
- return `${id}?${stringifyQuery(query)}`;
1536
- }
1537
- function stringifyQuery(query) {
1538
- if (!query.length) return "";
1539
- let queryStr = "";
1540
- for (const [key, value] of query) queryStr += `${key}${value ? `=${value}` : ""}&`;
1541
- return `${queryStr.slice(0, -1)}`;
1542
- }
1543
- const CSS_LANGS_RES = [
1544
- [/\.(less)(?:$|\?)/, "less"],
1545
- [/\.(scss|sass)(?:$|\?)/, "sass"],
1546
- [/\.(styl|stylus)(?:$|\?)/, "stylus"],
1547
- [/\.(css)(?:$|\?)/, "css"]
1548
- ];
1549
- const JS_LANGS_RES = [
1550
- [/\.(js|mjs|cjs)(?:$|\?)/, "js"],
1551
- [/\.(jsx)(?:$|\?)/, "jsx"],
1552
- [/\.(ts|cts|mts)(?:$|\?)/, "ts"],
1553
- [/\.(tsx)(?:$|\?)/, "tsx"]
1554
- ];
1555
- function getCssModuleType(id) {
1556
- for (const [reg, lang] of CSS_LANGS_RES) if (reg.test(id)) return lang;
1557
- return null;
1558
- }
1559
- function getJsModuleType(id) {
1560
- for (const [reg, lang] of JS_LANGS_RES) if (reg.test(id)) return lang;
1561
- return null;
1562
- }
1563
- function formatLoadModuleType(id) {
1564
- const cssModuleType = getCssModuleType(id);
1565
- if (cssModuleType) return cssModuleType;
1566
- const jsModuleType = getJsModuleType(id);
1567
- if (jsModuleType) return jsModuleType;
1568
- return "js";
1569
- }
1570
- function formatTransformModuleType(id) {
1571
- return formatLoadModuleType(id);
1572
- }
1573
- function getFarmPlugin(factory) {
1574
- return ((userOptions) => {
1575
- const plugins = toArray$2(factory(userOptions, { framework: "farm" })).map((rawPlugin) => {
1576
- const plugin = toFarmPlugin(rawPlugin, userOptions);
1577
- if (rawPlugin.farm) Object.assign(plugin, rawPlugin.farm);
1578
- return plugin;
1579
- });
1580
- return plugins.length === 1 ? plugins[0] : plugins;
1581
- });
1582
- }
1583
- function toFarmPlugin(plugin, options) {
1584
- const farmPlugin = {
1585
- name: plugin.name,
1586
- priority: convertEnforceToPriority(plugin.enforce)
1587
- };
1588
- if (plugin.farm) Object.keys(plugin.farm).forEach((key) => {
1589
- const value = plugin.farm[key];
1590
- if (value) Reflect.set(farmPlugin, key, value);
1591
- });
1592
- if (plugin.buildStart) {
1593
- const _buildStart = plugin.buildStart;
1594
- farmPlugin.buildStart = { async executor(_, context) {
1595
- await _buildStart.call(createFarmContext(context));
1596
- } };
1597
- }
1598
- if (plugin.resolveId) {
1599
- const _resolveId = plugin.resolveId;
1600
- let filters = [];
1601
- if (options) filters = options?.filters ?? [];
1602
- farmPlugin.resolve = {
1603
- filters: {
1604
- sources: filters.length ? filters : [".*"],
1605
- importers: [".*"]
1606
- },
1607
- async executor(params, context) {
1608
- const resolvedIdPath = path.resolve(params.importer ?? "");
1609
- const id = decodeStr(params.source);
1610
- const { handler, filter } = normalizeObjectHook("resolveId", _resolveId);
1611
- if (!filter(id)) return null;
1612
- let isEntry = false;
1613
- if (isObject(params.kind) && "entry" in params.kind) isEntry = params.kind.entry === "index";
1614
- const farmContext = createFarmContext(context, resolvedIdPath);
1615
- const resolveIdResult = await handler.call(Object.assign(unpluginContext(context), farmContext), id, resolvedIdPath ?? null, { isEntry });
1616
- if (isString(resolveIdResult)) return {
1617
- resolvedPath: removeQuery(encodeStr(resolveIdResult)),
1618
- query: customParseQueryString(resolveIdResult),
1619
- sideEffects: true,
1620
- external: false,
1621
- meta: {}
1622
- };
1623
- if (isObject(resolveIdResult)) return {
1624
- resolvedPath: removeQuery(encodeStr(resolveIdResult?.id)),
1625
- query: customParseQueryString(resolveIdResult?.id),
1626
- sideEffects: false,
1627
- external: Boolean(resolveIdResult?.external),
1628
- meta: {}
1629
- };
1630
- if (!isStartsWithSlash(params.source)) return null;
1631
- }
1632
- };
1633
- }
1634
- if (plugin.load) {
1635
- const _load = plugin.load;
1636
- farmPlugin.load = {
1637
- filters: { resolvedPaths: [".*"] },
1638
- async executor(params, context) {
1639
- const id = appendQuery(decodeStr(params.resolvedPath), params.query);
1640
- const loader = formatTransformModuleType(id);
1641
- if (plugin.loadInclude && !plugin.loadInclude?.(id)) return null;
1642
- const { handler, filter } = normalizeObjectHook("load", _load);
1643
- if (!filter(id)) return null;
1644
- const farmContext = createFarmContext(context, id);
1645
- return {
1646
- content: getContentValue(await handler.call(Object.assign(unpluginContext(context), farmContext), id)),
1647
- moduleType: loader
1648
- };
1649
- }
1650
- };
1651
- }
1652
- if (plugin.transform) {
1653
- const _transform = plugin.transform;
1654
- farmPlugin.transform = {
1655
- filters: {
1656
- resolvedPaths: [".*"],
1657
- moduleTypes: [".*"]
1658
- },
1659
- async executor(params, context) {
1660
- const id = appendQuery(decodeStr(params.resolvedPath), params.query);
1661
- const loader = formatTransformModuleType(id);
1662
- if (plugin.transformInclude && !plugin.transformInclude(id)) return null;
1663
- const { handler, filter } = normalizeObjectHook("transform", _transform);
1664
- if (!filter(id, params.content)) return null;
1665
- const farmContext = createFarmContext(context, id);
1666
- const resource = await handler.call(Object.assign(unpluginContext(context), farmContext), params.content, id);
1667
- if (resource && typeof resource !== "string") return {
1668
- content: getContentValue(resource),
1669
- moduleType: loader,
1670
- sourceMap: typeof resource.map === "object" && resource.map !== null ? JSON.stringify(resource.map) : void 0
1671
- };
1672
- }
1673
- };
1674
- }
1675
- if (plugin.watchChange) {
1676
- const _watchChange = plugin.watchChange;
1677
- farmPlugin.updateModules = { async executor(param, context) {
1678
- const updatePathContent = param.paths[0];
1679
- const ModifiedPath = updatePathContent[0];
1680
- const eventChange = convertWatchEventChange(updatePathContent[1]);
1681
- await _watchChange.call(createFarmContext(context), ModifiedPath, { event: eventChange });
1682
- } };
1683
- }
1684
- if (plugin.buildEnd) {
1685
- const _buildEnd = plugin.buildEnd;
1686
- farmPlugin.buildEnd = { async executor(_, context) {
1687
- await _buildEnd.call(createFarmContext(context));
1688
- } };
1689
- }
1690
- if (plugin.writeBundle) {
1691
- const _writeBundle = plugin.writeBundle;
1692
- farmPlugin.finish = { async executor() {
1693
- await _writeBundle();
1694
- } };
1695
- }
1696
- return farmPlugin;
1697
- }
1698
- function getRollupPlugin(factory) {
1699
- return ((userOptions) => {
1700
- const plugins = toArray$2(factory(userOptions, { framework: "rollup" })).map((plugin) => toRollupPlugin(plugin, "rollup"));
1701
- return plugins.length === 1 ? plugins[0] : plugins;
1702
- });
1703
- }
1704
- function toRollupPlugin(plugin, key) {
1705
- const nativeFilter = key === "rolldown";
1706
- if (plugin.resolveId && !nativeFilter && typeof plugin.resolveId === "object" && plugin.resolveId.filter) {
1707
- const resolveIdHook = plugin.resolveId;
1708
- const { handler, filter } = normalizeObjectHook("load", resolveIdHook);
1709
- replaceHookHandler("resolveId", resolveIdHook, function(...args) {
1710
- const [id] = args;
1711
- if (!supportNativeFilter(this, key) && !filter(id)) return;
1712
- return handler.apply(this, args);
1713
- });
1714
- }
1715
- if (plugin.load && (plugin.loadInclude || !nativeFilter && typeof plugin.load === "object" && plugin.load.filter)) {
1716
- const loadHook = plugin.load;
1717
- const { handler, filter } = normalizeObjectHook("load", loadHook);
1718
- replaceHookHandler("load", loadHook, function(...args) {
1719
- const [id] = args;
1720
- if (plugin.loadInclude && !plugin.loadInclude(id)) return;
1721
- if (!supportNativeFilter(this, key) && !filter(id)) return;
1722
- return handler.apply(this, args);
1723
- });
1724
- }
1725
- if (plugin.transform && (plugin.transformInclude || !nativeFilter && typeof plugin.transform === "object" && plugin.transform.filter)) {
1726
- const transformHook = plugin.transform;
1727
- const { handler, filter } = normalizeObjectHook("transform", transformHook);
1728
- replaceHookHandler("transform", transformHook, function(...args) {
1729
- const [code, id] = args;
1730
- if (plugin.transformInclude && !plugin.transformInclude(id)) return;
1731
- if (!supportNativeFilter(this, key) && !filter(id, code)) return;
1732
- return handler.apply(this, args);
1733
- });
1734
- }
1735
- if (plugin[key]) Object.assign(plugin, plugin[key]);
1736
- return plugin;
1737
- function replaceHookHandler(name, hook, handler) {
1738
- if (typeof hook === "function") plugin[name] = handler;
1739
- else hook.handler = handler;
1740
- }
1741
- }
1742
- function supportNativeFilter(context, framework) {
1743
- if (framework === "unloader") return false;
1744
- if (framework === "vite") return !!context?.meta?.viteVersion;
1745
- if (framework === "rolldown") return true;
1746
- const rollupVersion = context?.meta?.rollupVersion;
1747
- if (!rollupVersion) return false;
1748
- const [major, minor] = rollupVersion.split(".");
1749
- return Number(major) > 4 || Number(major) === 4 && Number(minor) >= 40;
1750
- }
1751
- function getRolldownPlugin(factory) {
1752
- return ((userOptions) => {
1753
- const plugins = toArray$2(factory(userOptions, { framework: "rolldown" })).map((rawPlugin) => {
1754
- return toRollupPlugin(rawPlugin, "rolldown");
1755
- });
1756
- return plugins.length === 1 ? plugins[0] : plugins;
1757
- });
1758
- }
1759
- const getFilename = () => fileURLToPath(import.meta.url);
1760
- const getDirname = () => path.dirname(getFilename());
1761
- const __dirname = /* @__PURE__ */ getDirname();
1762
- const TRANSFORM_LOADER$1 = resolve(__dirname, "rspack/loaders/transform");
1763
- const LOAD_LOADER$1 = resolve(__dirname, "rspack/loaders/load");
1764
- function getRspackPlugin(factory) {
1765
- return (userOptions) => {
1766
- return { apply(compiler) {
1767
- const VIRTUAL_MODULE_PREFIX = resolve(compiler.options.context ?? process.cwd(), "node_modules/.virtual", compiler.rspack.experiments.VirtualModulesPlugin ? "" : process.pid.toString());
1768
- const meta = {
1769
- framework: "rspack",
1770
- rspack: { compiler }
1771
- };
1772
- const rawPlugins = toArray$2(factory(userOptions, meta));
1773
- for (const rawPlugin of rawPlugins) {
1774
- const plugin = Object.assign(rawPlugin, {
1775
- __unpluginMeta: meta,
1776
- __virtualModulePrefix: VIRTUAL_MODULE_PREFIX
1777
- });
1778
- const externalModules = /* @__PURE__ */ new Set();
1779
- if (plugin.resolveId) {
1780
- const createPlugin = (plugin$1) => {
1781
- if (compiler.rspack.experiments.VirtualModulesPlugin) return new compiler.rspack.experiments.VirtualModulesPlugin();
1782
- return new FakeVirtualModulesPlugin(plugin$1);
1783
- };
1784
- const vfs = createPlugin(plugin);
1785
- vfs.apply(compiler);
1786
- const vfsModules = /* @__PURE__ */ new Map();
1787
- plugin.__vfsModules = vfsModules;
1788
- plugin.__vfs = vfs;
1789
- compiler.hooks.compilation.tap(plugin.name, (compilation, { normalModuleFactory }) => {
1790
- normalModuleFactory.hooks.resolve.tapPromise(plugin.name, async (resolveData) => {
1791
- const id = normalizeAbsolutePath(resolveData.request);
1792
- const requestContext = resolveData.contextInfo;
1793
- let importer = requestContext.issuer !== "" ? requestContext.issuer : void 0;
1794
- const isEntry = requestContext.issuer === "";
1795
- if (importer?.startsWith(plugin.__virtualModulePrefix)) importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
1796
- const context = createBuildContext$1(compiler, compilation);
1797
- let error;
1798
- const pluginContext = {
1799
- error(msg) {
1800
- if (error == null) error = normalizeMessage$1(msg);
1801
- else console.error(`unplugin/rspack: multiple errors returned from resolveId hook: ${msg}`);
1802
- },
1803
- warn(msg) {
1804
- console.warn(`unplugin/rspack: warning from resolveId hook: ${msg}`);
1805
- }
1806
- };
1807
- const { handler, filter } = normalizeObjectHook("resolveId", plugin.resolveId);
1808
- if (!filter(id)) return;
1809
- const resolveIdResult = await handler.call({
1810
- ...context,
1811
- ...pluginContext
1812
- }, id, importer, { isEntry });
1813
- if (error != null) throw error;
1814
- if (resolveIdResult == null) return;
1815
- let resolved = typeof resolveIdResult === "string" ? resolveIdResult : resolveIdResult.id;
1816
- if (typeof resolveIdResult === "string" ? false : resolveIdResult.external === true) externalModules.add(resolved);
1817
- let isVirtual = true;
1818
- try {
1819
- (compiler.inputFileSystem?.statSync ?? fs.statSync)(resolved);
1820
- isVirtual = false;
1821
- } catch {
1822
- isVirtual = !isVirtualModuleId(resolved, plugin);
1823
- }
1824
- if (isVirtual) {
1825
- const encodedVirtualPath = encodeVirtualModuleId(resolved, plugin);
1826
- if (!vfsModules.has(resolved)) {
1827
- const fsPromise = Promise.resolve(vfs.writeModule(encodedVirtualPath, ""));
1828
- vfsModules.set(resolved, fsPromise);
1829
- await fsPromise;
1830
- } else await vfsModules.get(resolved);
1831
- resolved = encodedVirtualPath;
1832
- }
1833
- resolveData.request = resolved;
1834
- });
1835
- });
1836
- }
1837
- if (plugin.load) compiler.options.module.rules.unshift({
1838
- enforce: plugin.enforce,
1839
- include(id) {
1840
- if (isVirtualModuleId(id, plugin)) id = decodeVirtualModuleId(id, plugin);
1841
- if (plugin.loadInclude && !plugin.loadInclude(id)) return false;
1842
- const { filter } = normalizeObjectHook("load", plugin.load);
1843
- if (!filter(id)) return false;
1844
- return !externalModules.has(id);
1845
- },
1846
- use: [{
1847
- loader: LOAD_LOADER$1,
1848
- options: { plugin }
1849
- }],
1850
- type: "javascript/auto"
1851
- });
1852
- if (plugin.transform) compiler.options.module.rules.unshift({
1853
- enforce: plugin.enforce,
1854
- use(data) {
1855
- return transformUse(data, plugin, TRANSFORM_LOADER$1);
1856
- }
1857
- });
1858
- if (plugin.rspack) plugin.rspack(compiler);
1859
- if (plugin.watchChange || plugin.buildStart) compiler.hooks.make.tapPromise(plugin.name, async (compilation) => {
1860
- const context = createBuildContext$1(compiler, compilation);
1861
- if (plugin.watchChange && (compiler.modifiedFiles || compiler.removedFiles)) {
1862
- const promises$1 = [];
1863
- if (compiler.modifiedFiles) compiler.modifiedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
1864
- if (compiler.removedFiles) compiler.removedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "delete" }))));
1865
- await Promise.all(promises$1);
1866
- }
1867
- if (plugin.buildStart) return await plugin.buildStart.call(context);
1868
- });
1869
- if (plugin.buildEnd) compiler.hooks.emit.tapPromise(plugin.name, async (compilation) => {
1870
- await plugin.buildEnd.call(createBuildContext$1(compiler, compilation));
1871
- });
1872
- if (plugin.writeBundle) compiler.hooks.afterEmit.tapPromise(plugin.name, async () => {
1873
- await plugin.writeBundle();
1874
- });
1875
- }
1876
- } };
1877
- };
1878
- }
1879
- function getUnloaderPlugin(factory) {
1880
- return ((userOptions) => {
1881
- const plugins = toArray$2(factory(userOptions, { framework: "unloader" })).map((rawPlugin) => {
1882
- return toRollupPlugin(rawPlugin, "unloader");
1883
- });
1884
- return plugins.length === 1 ? plugins[0] : plugins;
1885
- });
1886
- }
1887
- function getVitePlugin(factory) {
1888
- return ((userOptions) => {
1889
- const plugins = toArray$2(factory(userOptions, { framework: "vite" })).map((rawPlugin) => {
1890
- return toRollupPlugin(rawPlugin, "vite");
1891
- });
1892
- return plugins.length === 1 ? plugins[0] : plugins;
1893
- });
1894
- }
1895
- const TRANSFORM_LOADER = resolve(__dirname, "webpack/loaders/transform");
1896
- const LOAD_LOADER = resolve(__dirname, "webpack/loaders/load");
1897
- function getWebpackPlugin(factory) {
1898
- return (userOptions) => {
1899
- return { apply(compiler) {
1900
- const VIRTUAL_MODULE_PREFIX = resolve(compiler.options.context ?? process$1.cwd(), "_virtual_");
1901
- const meta = {
1902
- framework: "webpack",
1903
- webpack: { compiler }
1904
- };
1905
- const rawPlugins = toArray$2(factory(userOptions, meta));
1906
- for (const rawPlugin of rawPlugins) {
1907
- const plugin = Object.assign(rawPlugin, {
1908
- __unpluginMeta: meta,
1909
- __virtualModulePrefix: VIRTUAL_MODULE_PREFIX
1910
- });
1911
- const externalModules = /* @__PURE__ */ new Set();
1912
- if (plugin.resolveId) {
1913
- let vfs = compiler.options.plugins.find((i) => i instanceof import_lib.default);
1914
- if (!vfs) {
1915
- vfs = new import_lib.default();
1916
- compiler.options.plugins.push(vfs);
1917
- }
1918
- const vfsModules = /* @__PURE__ */ new Set();
1919
- plugin.__vfsModules = vfsModules;
1920
- plugin.__vfs = vfs;
1921
- const resolverPlugin = { apply(resolver$1) {
1922
- const target = resolver$1.ensureHook("resolve");
1923
- resolver$1.getHook("resolve").tapAsync(plugin.name, async (request, resolveContext, callback) => {
1924
- if (!request.request) return callback();
1925
- if (normalizeAbsolutePath(request.request).startsWith(plugin.__virtualModulePrefix)) return callback();
1926
- const id = normalizeAbsolutePath(request.request);
1927
- const requestContext = request.context;
1928
- let importer = requestContext.issuer !== "" ? requestContext.issuer : void 0;
1929
- const isEntry = requestContext.issuer === "";
1930
- if (importer?.startsWith(plugin.__virtualModulePrefix)) importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
1931
- const fileDependencies = /* @__PURE__ */ new Set();
1932
- const context = createBuildContext({
1933
- addWatchFile(file) {
1934
- fileDependencies.add(file);
1935
- resolveContext.fileDependencies?.add(file);
1936
- },
1937
- getWatchFiles() {
1938
- return Array.from(fileDependencies);
1939
- }
1940
- }, compiler);
1941
- let error;
1942
- const pluginContext = {
1943
- error(msg) {
1944
- if (error == null) error = normalizeMessage(msg);
1945
- else console.error(`unplugin/webpack: multiple errors returned from resolveId hook: ${msg}`);
1946
- },
1947
- warn(msg) {
1948
- console.warn(`unplugin/webpack: warning from resolveId hook: ${msg}`);
1949
- }
1950
- };
1951
- const { handler, filter } = normalizeObjectHook("resolveId", plugin.resolveId);
1952
- if (!filter(id)) return callback();
1953
- const resolveIdResult = await handler.call({
1954
- ...context,
1955
- ...pluginContext
1956
- }, id, importer, { isEntry });
1957
- if (error != null) return callback(error);
1958
- if (resolveIdResult == null) return callback();
1959
- let resolved = typeof resolveIdResult === "string" ? resolveIdResult : resolveIdResult.id;
1960
- if (typeof resolveIdResult === "string" ? false : resolveIdResult.external === true) externalModules.add(resolved);
1961
- if (!fs.existsSync(resolved)) {
1962
- resolved = normalizeAbsolutePath(plugin.__virtualModulePrefix + encodeURIComponent(resolved));
1963
- if (!vfsModules.has(resolved)) {
1964
- plugin.__vfs.writeModule(resolved, "");
1965
- vfsModules.add(resolved);
1966
- }
1967
- }
1968
- const newRequest = {
1969
- ...request,
1970
- request: resolved
1971
- };
1972
- resolver$1.doResolve(target, newRequest, null, resolveContext, callback);
1973
- });
1974
- } };
1975
- compiler.options.resolve.plugins = compiler.options.resolve.plugins || [];
1976
- compiler.options.resolve.plugins.push(resolverPlugin);
1977
- }
1978
- if (plugin.load) compiler.options.module.rules.unshift({
1979
- include(id) {
1980
- return shouldLoad(id, plugin, externalModules);
1981
- },
1982
- enforce: plugin.enforce,
1983
- use: [{
1984
- loader: LOAD_LOADER,
1985
- options: { plugin }
1986
- }],
1987
- type: "javascript/auto"
1988
- });
1989
- if (plugin.transform) compiler.options.module.rules.unshift({
1990
- enforce: plugin.enforce,
1991
- use(data) {
1992
- return transformUse(data, plugin, TRANSFORM_LOADER);
1993
- }
1994
- });
1995
- if (plugin.webpack) plugin.webpack(compiler);
1996
- if (plugin.watchChange || plugin.buildStart) compiler.hooks.make.tapPromise(plugin.name, async (compilation) => {
1997
- const context = createBuildContext(contextOptionsFromCompilation(compilation), compiler, compilation);
1998
- if (plugin.watchChange && (compiler.modifiedFiles || compiler.removedFiles)) {
1999
- const promises$1 = [];
2000
- if (compiler.modifiedFiles) compiler.modifiedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
2001
- if (compiler.removedFiles) compiler.removedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "delete" }))));
2002
- await Promise.all(promises$1);
2003
- }
2004
- if (plugin.buildStart) return await plugin.buildStart.call(context);
2005
- });
2006
- if (plugin.buildEnd) compiler.hooks.emit.tapPromise(plugin.name, async (compilation) => {
2007
- await plugin.buildEnd.call(createBuildContext(contextOptionsFromCompilation(compilation), compiler, compilation));
2008
- });
2009
- if (plugin.writeBundle) compiler.hooks.afterEmit.tapPromise(plugin.name, async () => {
2010
- await plugin.writeBundle();
2011
- });
2012
- }
2013
- } };
2014
- };
2015
- }
2016
- function shouldLoad(id, plugin, externalModules) {
2017
- if (id.startsWith(plugin.__virtualModulePrefix)) id = decodeURIComponent(id.slice(plugin.__virtualModulePrefix.length));
2018
- if (plugin.loadInclude && !plugin.loadInclude(id)) return false;
2019
- const { filter } = normalizeObjectHook("load", plugin.load);
2020
- if (!filter(id)) return false;
2021
- return !externalModules.has(id);
2022
- }
2023
- function createUnplugin(factory) {
2024
- return {
2025
- get esbuild() {
2026
- return getEsbuildPlugin(factory);
2027
- },
2028
- get rollup() {
2029
- return getRollupPlugin(factory);
2030
- },
2031
- get vite() {
2032
- return getVitePlugin(factory);
2033
- },
2034
- get rolldown() {
2035
- return getRolldownPlugin(factory);
2036
- },
2037
- get webpack() {
2038
- return getWebpackPlugin(factory);
2039
- },
2040
- get rspack() {
2041
- return getRspackPlugin(factory);
2042
- },
2043
- get farm() {
2044
- return getFarmPlugin(factory);
2045
- },
2046
- get unloader() {
2047
- return getUnloaderPlugin(factory);
2048
- },
2049
- get raw() {
2050
- return factory;
2051
- }
2052
- };
2053
- }
2054
-
2055
- //#endregion
2056
- //#region node_modules/.pnpm/unplugin-utils@0.3.1/node_modules/unplugin-utils/dist/index.js
2057
- /**
2058
- * Converts path separators to forward slash.
2059
- */
2060
- function normalizePath(filename) {
2061
- return filename.replaceAll("\\", "/");
2062
- }
2063
- const isArray = Array.isArray;
2064
- function toArray$1(thing) {
2065
- if (isArray(thing)) return thing;
2066
- if (thing == null) return [];
2067
- return [thing];
2068
- }
2069
- const escapeMark = "[_#EsCaPe#_]";
2070
- function getMatcherString(id, resolutionBase) {
2071
- if (resolutionBase === false || isAbsolute$2(id) || id.startsWith("**")) return normalizePath(id);
2072
- return join$1(normalizePath(resolve$2(resolutionBase || "")).replaceAll(/[-^$*+?.()|[\]{}]/g, `${escapeMark}$&`), normalizePath(id)).replaceAll(escapeMark, "\\");
2073
- }
2074
- /**
2075
- * Constructs a filter function which can be used to determine whether or not
2076
- * certain modules should be operated upon.
2077
- * @param include If `include` is omitted or has zero length, filter will return `true` by default.
2078
- * @param exclude ID must not match any of the `exclude` patterns.
2079
- * @param options Additional options.
2080
- * @param options.resolve Optionally resolves the patterns against a directory other than `process.cwd()`.
2081
- * If a `string` is specified, then the value will be used as the base directory.
2082
- * Relative paths will be resolved against `process.cwd()` first.
2083
- * If `false`, then the patterns will not be resolved against any directory.
2084
- * This can be useful if you want to create a filter for virtual module names.
2085
- */
2086
- function createFilter(include, exclude, options) {
2087
- const resolutionBase = options && options.resolve;
2088
- const getMatcher = (id) => id instanceof RegExp ? id : { test: (what) => {
2089
- return (0, import_picomatch.default)(getMatcherString(id, resolutionBase), { dot: true })(what);
2090
- } };
2091
- const includeMatchers = toArray$1(include).map(getMatcher);
2092
- const excludeMatchers = toArray$1(exclude).map(getMatcher);
2093
- if (!includeMatchers.length && !excludeMatchers.length) return (id) => typeof id === "string" && !id.includes("\0");
2094
- return function result(id) {
2095
- if (typeof id !== "string") return false;
2096
- if (id.includes("\0")) return false;
2097
- const pathId = normalizePath(id);
2098
- for (const matcher of excludeMatchers) {
2099
- if (matcher instanceof RegExp) matcher.lastIndex = 0;
2100
- if (matcher.test(pathId)) return false;
2101
- }
2102
- for (const matcher of includeMatchers) {
2103
- if (matcher instanceof RegExp) matcher.lastIndex = 0;
2104
- if (matcher.test(pathId)) return true;
2105
- }
2106
- return !includeMatchers.length;
2107
- };
2108
- }
2109
-
2110
- //#endregion
2111
- //#region node_modules/.pnpm/unimport@5.6.0/node_modules/unimport/dist/unplugin.mjs
2112
- const defaultIncludes = [
2113
- /\.[jt]sx?$/,
2114
- /\.vue$/,
2115
- /\.vue\?vue/,
2116
- /\.svelte$/
2117
- ];
2118
- const defaultExcludes = [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/];
2119
- function toArray(x) {
2120
- return x == null ? [] : Array.isArray(x) ? x : [x];
2121
- }
2122
- const unplugin = createUnplugin((options = {}) => {
2123
- const ctx = createUnimport(options);
2124
- const filter = createFilter(toArray(options.include || []).length ? options.include : defaultIncludes, options.exclude || defaultExcludes);
2125
- const dts = options.dts === true ? "unimport.d.ts" : options.dts;
2126
- const { autoImport = true } = options;
2127
- return {
2128
- name: "unimport",
2129
- enforce: "post",
2130
- transformInclude(id) {
2131
- return filter(id);
2132
- },
2133
- async transform(code, id) {
2134
- const s = new MagicString(code);
2135
- await ctx.injectImports(s, id, { autoImport });
2136
- if (!s.hasChanged()) return;
2137
- return {
2138
- code: s.toString(),
2139
- map: s.generateMap()
2140
- };
2141
- },
2142
- async buildStart() {
2143
- await ctx.init();
2144
- if (dts) return promises.writeFile(dts, await ctx.generateTypeDeclarations(), "utf-8");
2145
- }
2146
- };
2147
- });
2148
-
2149
- //#endregion
2150
- export { unplugin as default };