nitro-nightly 3.0.1-20260106-130706-e20c92d9 → 3.0.1-20260106-182834-5019d347

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 (71) hide show
  1. package/dist/_build/rolldown.mjs +7 -5
  2. package/dist/_build/rollup.mjs +15 -5
  3. package/dist/_build/shared.mjs +2 -1
  4. package/dist/_build/shared2.mjs +1 -1
  5. package/dist/_build/shared3.mjs +1 -1
  6. package/dist/_build/vite.build.mjs +7 -6
  7. package/dist/_dev.mjs +2 -1
  8. package/dist/_libs/@hiogawa/vite-plugin-fullstack.mjs +5 -1560
  9. package/dist/_libs/@jridgewell/gen-mapping.mjs +2 -304
  10. package/dist/_libs/@jridgewell/remapping.mjs +2 -1
  11. package/dist/_libs/@jridgewell/resolve-uri.mjs +166 -0
  12. package/dist/_libs/@jridgewell/sourcemap-codec.mjs +167 -0
  13. package/dist/_libs/@jridgewell/trace-mapping.mjs +141 -0
  14. package/dist/_libs/@rolldown/pluginutils.mjs +31 -0
  15. package/dist/_libs/@rollup/plugin-commonjs.mjs +33 -2636
  16. package/dist/_libs/@rollup/plugin-inject.mjs +3 -2
  17. package/dist/_libs/@rollup/plugin-json.mjs +1 -1
  18. package/dist/_libs/@rollup/plugin-node-resolve.mjs +7 -1111
  19. package/dist/_libs/@rollup/plugin-replace.mjs +2 -2
  20. package/dist/_libs/@rollup/pluginutils.mjs +241 -0
  21. package/dist/_libs/c12.mjs +63 -2513
  22. package/dist/_libs/chokidar.mjs +1 -234
  23. package/dist/_libs/commondir.mjs +22 -0
  24. package/dist/_libs/confbox.mjs +1102 -502
  25. package/dist/_libs/deepmerge.mjs +86 -0
  26. package/dist/_libs/dotenv.mjs +345 -0
  27. package/dist/_libs/estree-walker.mjs +144 -1
  28. package/dist/_libs/exsolve.mjs +1007 -0
  29. package/dist/_libs/fdir.mjs +514 -0
  30. package/dist/_libs/function-bind.mjs +63 -0
  31. package/dist/_libs/giget.mjs +1376 -2234
  32. package/dist/_libs/hasown.mjs +14 -0
  33. package/dist/_libs/is-core-module.mjs +220 -0
  34. package/dist/_libs/is-module.mjs +13 -0
  35. package/dist/_libs/is-reference.mjs +33 -0
  36. package/dist/_libs/js-tokens.mjs +382 -0
  37. package/dist/_libs/local-pkg.mjs +6 -1560
  38. package/dist/_libs/magic-string.mjs +939 -0
  39. package/dist/_libs/mlly.mjs +1415 -0
  40. package/dist/_libs/node-fetch-native.mjs +7 -0
  41. package/dist/_libs/nypm.mjs +239 -0
  42. package/dist/_libs/path-parse.mjs +47 -0
  43. package/dist/_libs/pathe.mjs +163 -2
  44. package/dist/_libs/perfect-debounce.mjs +89 -0
  45. package/dist/_libs/picomatch.mjs +1673 -0
  46. package/dist/_libs/pkg-types.mjs +197 -0
  47. package/dist/_libs/quansync.mjs +90 -0
  48. package/dist/_libs/rc9.mjs +136 -0
  49. package/dist/_libs/readdirp.mjs +237 -0
  50. package/dist/_libs/resolve.mjs +689 -0
  51. package/dist/_libs/strip-literal.mjs +51 -0
  52. package/dist/_libs/tinyexec.mjs +627 -0
  53. package/dist/_libs/tinyglobby.mjs +2 -1
  54. package/dist/_libs/unimport.mjs +42 -1575
  55. package/dist/_libs/unplugin-utils.mjs +61 -0
  56. package/dist/_libs/unplugin.mjs +1225 -0
  57. package/dist/_libs/unwasm.mjs +3 -2
  58. package/dist/_libs/webpack-virtual-modules.mjs +272 -0
  59. package/dist/_nitro.mjs +5 -2
  60. package/dist/_nitro2.mjs +3 -3
  61. package/dist/_presets.mjs +5 -3
  62. package/dist/builder.mjs +4 -4
  63. package/dist/cli/_chunks/build.mjs +1 -1
  64. package/dist/cli/_chunks/dev.mjs +1 -1
  65. package/dist/cli/_chunks/list.mjs +1 -1
  66. package/dist/cli/_chunks/prepare.mjs +1 -1
  67. package/dist/cli/_chunks/run.mjs +1 -1
  68. package/dist/vite.mjs +1824 -19
  69. package/package.json +2 -2
  70. package/dist/_build/shared4.mjs +0 -1114
  71. package/dist/_build/vite.plugin.mjs +0 -712
@@ -1,22 +1,23 @@
1
- import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "../_rolldown.mjs";
2
- import { A as resolve$1, E as normalize$2, O as parse$1, S as dirname$1, T as join$1, h as resolvePackageJSON, k as relative$1, p as readPackageJSON, w as isAbsolute$2, x as basename$1 } from "./c12.mjs";
3
- import { s as require_picomatch } from "./@rollup/plugin-commonjs.mjs";
1
+ import { i as __toESM, n as __exportAll } from "../_rolldown.mjs";
2
+ import { a as isAbsolute$1, c as parse, l as relative$1, n as basename$1, o as join$1, r as dirname$1, s as normalize$1, u as resolve$1 } from "./pathe.mjs";
3
+ import { l as resolvePackageJSON, s as readPackageJSON } from "./pkg-types.mjs";
4
+ import { t as require_picomatch } from "./picomatch.mjs";
4
5
  import { t as glob } from "./tinyglobby.mjs";
5
- import { n as parse$2, t as Parser } from "./acorn.mjs";
6
- import { a as findTypeExports, c as parseStaticImport, i as findStaticImports, l as resolve$2, n as detectSyntax, r as findExports, t as resolveModule, u as resolveModuleExportNames } from "./local-pkg.mjs";
7
- import { a as MagicString, i as stripLiteral } from "./@hiogawa/vite-plugin-fullstack.mjs";
6
+ import { n as parse$1 } from "./acorn.mjs";
7
+ import { c as resolve$2, i as findTypeExports, l as resolveModuleExportNames, n as findExports, r as findStaticImports, s as parseStaticImport, t as detectSyntax } from "./mlly.mjs";
8
+ import { t as MagicString } from "./magic-string.mjs";
9
+ import { t as stripLiteral } from "./strip-literal.mjs";
10
+ import { t as resolveModule } from "./local-pkg.mjs";
8
11
  import { t as walk } from "./estree-walker.mjs";
9
- import { t as remapping } from "./@jridgewell/remapping.mjs";
10
- import { createRequire } from "node:module";
11
- import fs, { accessSync, constants, existsSync, promises, readFileSync } from "node:fs";
12
+ import { t as createUnplugin } from "./unplugin.mjs";
13
+ import { t as createFilter } from "./unplugin-utils.mjs";
14
+ import { accessSync, constants, existsSync, promises, readFileSync } from "node:fs";
12
15
  import { readFile } from "node:fs/promises";
13
16
  import { fileURLToPath } from "node:url";
14
17
  import os from "node:os";
15
- import path, { basename, dirname, extname, isAbsolute, normalize, resolve } from "node:path";
18
+ import { basename } from "node:path";
16
19
  import process$1 from "node:process";
17
20
  import { camelCase, kebabCase } from "scule";
18
- import { Buffer } from "node:buffer";
19
- import * as querystring from "node:querystring";
20
21
 
21
22
  //#region node_modules/.pnpm/unimport@5.6.0/node_modules/unimport/dist/shared/unimport.CWY7iHFZ.mjs
22
23
  const excludeRE = [
@@ -123,7 +124,7 @@ function toExports(imports, fileDir, includeType = false, options = {}) {
123
124
  const map = toImportModuleMap(imports, includeType, options);
124
125
  return Object.entries(map).flatMap(([name, imports2]) => {
125
126
  if (isFilePath(name)) name = name.replace(/\.[a-z]+$/i, "");
126
- if (fileDir && isAbsolute$2(name)) {
127
+ if (fileDir && isAbsolute$1(name)) {
127
128
  name = relative$1(fileDir, name);
128
129
  if (!name.match(/^[./]/)) name = `./${name}`;
129
130
  }
@@ -169,17 +170,17 @@ function makeTypeModulesMap(imports, resolvePath$1) {
169
170
  } : (i) => stripFileExtension(i.typeFrom || i.from);
170
171
  for (const import_ of imports) {
171
172
  const from = resolveImportFrom(import_);
172
- let module$1 = modulesMap.get(from);
173
- if (!module$1) {
174
- module$1 = {
173
+ let module = modulesMap.get(from);
174
+ if (!module) {
175
+ module = {
175
176
  typeImports: /* @__PURE__ */ new Set(),
176
177
  starTypeImport: void 0
177
178
  };
178
- modulesMap.set(from, module$1);
179
+ modulesMap.set(from, module);
179
180
  }
180
181
  if (import_.name === "*") {
181
- if (import_.as) module$1.starTypeImport = import_;
182
- } else module$1.typeImports.add(import_);
182
+ if (import_.as) module.starTypeImport = import_;
183
+ } else module.typeImports.add(import_);
183
184
  }
184
185
  return modulesMap;
185
186
  }
@@ -187,9 +188,9 @@ function toTypeReExports(imports, options) {
187
188
  const importsMap = makeTypeModulesMap(imports, options?.resolvePath);
188
189
  return `// for type re-export
189
190
  declare global {
190
- ${Array.from(importsMap).flatMap(([from, module$1]) => {
191
+ ${Array.from(importsMap).flatMap(([from, module]) => {
191
192
  from = from.replace(/\.d\.([cm]?)ts$/i, ".$1js");
192
- const { starTypeImport, typeImports } = module$1;
193
+ const { starTypeImport, typeImports } = module;
193
194
  const strings = [];
194
195
  if (typeImports.size) {
195
196
  const typeImportNames = Array.from(typeImports).map(({ name, as }) => {
@@ -274,7 +275,7 @@ function normalizeImports(imports) {
274
275
  return imports;
275
276
  }
276
277
  function isFilePath(path$1) {
277
- return path$1.startsWith(".") || isAbsolute$2(path$1) || path$1.includes("://");
278
+ return path$1.startsWith(".") || isAbsolute$1(path$1) || path$1.includes("://");
278
279
  }
279
280
  const contextRE$1 = /\b_ctx\.([$\w]+)\b/g;
280
281
  const UNREF_KEY = "__unimport_unref_";
@@ -344,7 +345,7 @@ function vueDirectivesAddon(options = {}) {
344
345
  function isDirective(importEntry) {
345
346
  let isDirective2 = importEntry.meta?.vueDirective === true;
346
347
  if (isDirective2) return true;
347
- isDirective2 = options.isDirective?.(normalizePath$1(process$1.cwd(), importEntry.from), importEntry) ?? false;
348
+ isDirective2 = options.isDirective?.(normalizePath(process$1.cwd(), importEntry.from), importEntry) ?? false;
348
349
  if (isDirective2) {
349
350
  importEntry.meta ??= {};
350
351
  importEntry.meta.vueDirective = true;
@@ -406,7 +407,7 @@ ${Array.from(directivesMap.entries()).map(([name, i]) => ` ${name}: typeof im
406
407
  function resolvePath(cwd$1, path$1) {
407
408
  return path$1[0] === "." ? resolve$1(cwd$1, path$1) : path$1;
408
409
  }
409
- function normalizePath$1(cwd$1, path$1) {
410
+ function normalizePath(cwd$1, path$1) {
410
411
  return resolvePath(cwd$1, path$1).replace(/\\/g, "/");
411
412
  }
412
413
  async function* findDirectives(isDirective, regexArray, importsPromise) {
@@ -583,9 +584,9 @@ function normalizeScanDirs(dirs, options) {
583
584
  const cwd$1 = options?.cwd ?? process$1.cwd();
584
585
  const filePatterns = options?.filePatterns || [FileLookupPatterns];
585
586
  return dirs.map((dir) => {
586
- const isString$1 = typeof dir === "string";
587
- const glob2 = resolveGlobsExclude(isString$1 ? dir : dir.glob, cwd$1);
588
- const types = isString$1 ? topLevelTypes : dir.types ?? topLevelTypes;
587
+ const isString = typeof dir === "string";
588
+ const glob2 = resolveGlobsExclude(isString ? dir : dir.glob, cwd$1);
589
+ const types = isString ? topLevelTypes : dir.types ?? topLevelTypes;
589
590
  if (glob2.match(/\.\w+$/)) return {
590
591
  glob: glob2,
591
592
  types
@@ -608,13 +609,13 @@ async function scanFilesFromDir(dir, options) {
608
609
  onlyFiles: true,
609
610
  followSymbolicLinks: true,
610
611
  expandDirectories: false
611
- })).map((i) => normalize$2(i));
612
+ })).map((i) => normalize$1(i));
612
613
  const fileFilter = options?.fileFilter || (() => true);
613
614
  const indexOfDirs = (file) => dirGlobs.findIndex((glob2) => import_picomatch.default.isMatch(file, glob2));
614
615
  return files.reduce((acc, file) => {
615
616
  const index = indexOfDirs(file);
616
- if (acc[index]) acc[index].push(normalize$2(file));
617
- else acc[index] = [normalize$2(file)];
617
+ if (acc[index]) acc[index].push(normalize$1(file));
618
+ else acc[index] = [normalize$1(file)];
618
619
  return acc;
619
620
  }, []).map((files2) => files2.sort()).flat().filter(fileFilter);
620
621
  }
@@ -625,11 +626,11 @@ async function scanDirExports(dirs, options) {
625
626
  const isIncludeTypes = (file) => includeTypesDirs.some((dir) => import_picomatch.default.isMatch(file, dir.glob));
626
627
  return dedupeDtsExports((await Promise.all(files.map((file) => scanExports(file, isIncludeTypes(file))))).flat());
627
628
  }
628
- function dedupeDtsExports(exports$1) {
629
- return exports$1.filter((i) => {
629
+ function dedupeDtsExports(exports) {
630
+ return exports.filter((i) => {
630
631
  if (!i.type) return true;
631
632
  if (i.declarationType === "enum" || i.declarationType === "const enum" || i.declarationType === "class") return true;
632
- return !exports$1.find((e) => e.as === i.as && e.name === i.name && !e.type);
633
+ return !exports.find((e) => e.as === i.as && e.name === i.name && !e.type);
633
634
  });
634
635
  }
635
636
  async function scanExports(filepath, includeTypes, seen = /* @__PURE__ */ new Set()) {
@@ -640,10 +641,10 @@ async function scanExports(filepath, includeTypes, seen = /* @__PURE__ */ new Se
640
641
  seen.add(filepath);
641
642
  const imports = [];
642
643
  const code = await readFile(filepath, "utf-8");
643
- const exports$1 = findExports(code);
644
- if (exports$1.find((i) => i.type === "default")) {
645
- let name = parse$1(filepath).name;
646
- if (name === "index") name = parse$1(filepath.split("/").slice(0, -1).join("/")).name;
644
+ const exports = findExports(code);
645
+ if (exports.find((i) => i.type === "default")) {
646
+ let name = parse(filepath).name;
647
+ if (name === "index") name = parse(filepath.split("/").slice(0, -1).join("/")).name;
647
648
  const as = /[-_.]/.test(name) ? camelCase(name) : name;
648
649
  imports.push({
649
650
  name: "default",
@@ -695,7 +696,7 @@ async function scanExports(filepath, includeTypes, seen = /* @__PURE__ */ new Se
695
696
  if (existsSync(subfilepath)) subfilepathResolved = true;
696
697
  else try {
697
698
  subfilepath = await resolve$2(exp.specifier);
698
- subfilepath = normalize$2(fileURLToPath(subfilepath));
699
+ subfilepath = normalize$1(fileURLToPath(subfilepath));
699
700
  if (existsSync(subfilepath)) subfilepathResolved = true;
700
701
  } catch {}
701
702
  if (!subfilepathResolved) {
@@ -711,11 +712,11 @@ async function scanExports(filepath, includeTypes, seen = /* @__PURE__ */ new Se
711
712
  }
712
713
  if (filepath.match(/\.d\.[mc]?ts$/)) {
713
714
  if (includeTypes) {
714
- await toImport(exports$1, { type: true });
715
+ await toImport(exports, { type: true });
715
716
  await toImport(findTypeExports(code), { type: true });
716
717
  }
717
718
  } else {
718
- await toImport(exports$1);
719
+ await toImport(exports);
719
720
  if (includeTypes) await toImport(findTypeExports(code), { type: true });
720
721
  }
721
722
  return imports;
@@ -1785,7 +1786,7 @@ async function detectImportsAcorn(code, ctx, options) {
1785
1786
  const enableAutoImport = options?.autoImport !== false;
1786
1787
  const enableTransformVirtualImports = options?.transformVirtualImports !== false && ctx.options.virtualImports?.length;
1787
1788
  if (enableAutoImport || enableTransformVirtualImports) {
1788
- const ast = parse$2(s.original, {
1789
+ const ast = parse$1(s.original, {
1789
1790
  sourceType: "module",
1790
1791
  ecmaVersion: "latest",
1791
1792
  locations: true
@@ -1961,1540 +1962,6 @@ function createVirtualImportsAcronWalker(importMap, virtualImports = []) {
1961
1962
  };
1962
1963
  }
1963
1964
 
1964
- //#endregion
1965
- //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/context-Csj9j3eN.js
1966
- function toArray$2(array) {
1967
- array = array || [];
1968
- if (Array.isArray(array)) return array;
1969
- return [array];
1970
- }
1971
- const BACKSLASH_REGEX = /\\/g;
1972
- function normalize$1(path$1) {
1973
- return path$1.replace(BACKSLASH_REGEX, "/");
1974
- }
1975
- const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Z]:)?[/\\|])/i;
1976
- function isAbsolute$1(path$1) {
1977
- return ABSOLUTE_PATH_REGEX.test(path$1);
1978
- }
1979
- function getMatcherString$1(glob$1, cwd$1) {
1980
- if (glob$1.startsWith("**") || isAbsolute$1(glob$1)) return normalize$1(glob$1);
1981
- return normalize$1(resolve(cwd$1, glob$1));
1982
- }
1983
- function patternToIdFilter(pattern) {
1984
- if (pattern instanceof RegExp) return (id) => {
1985
- const normalizedId = normalize$1(id);
1986
- const result = pattern.test(normalizedId);
1987
- pattern.lastIndex = 0;
1988
- return result;
1989
- };
1990
- const matcher = (0, import_picomatch.default)(getMatcherString$1(pattern, process.cwd()), { dot: true });
1991
- return (id) => {
1992
- return matcher(normalize$1(id));
1993
- };
1994
- }
1995
- function patternToCodeFilter(pattern) {
1996
- if (pattern instanceof RegExp) return (code) => {
1997
- const result = pattern.test(code);
1998
- pattern.lastIndex = 0;
1999
- return result;
2000
- };
2001
- return (code) => code.includes(pattern);
2002
- }
2003
- function createFilter$1(exclude, include) {
2004
- if (!exclude && !include) return;
2005
- return (input) => {
2006
- if (exclude?.some((filter) => filter(input))) return false;
2007
- if (include?.some((filter) => filter(input))) return true;
2008
- return !(include && include.length > 0);
2009
- };
2010
- }
2011
- function normalizeFilter(filter) {
2012
- if (typeof filter === "string" || filter instanceof RegExp) return { include: [filter] };
2013
- if (Array.isArray(filter)) return { include: filter };
2014
- return {
2015
- exclude: filter.exclude ? toArray$2(filter.exclude) : void 0,
2016
- include: filter.include ? toArray$2(filter.include) : void 0
2017
- };
2018
- }
2019
- function createIdFilter(filter) {
2020
- if (!filter) return;
2021
- const { exclude, include } = normalizeFilter(filter);
2022
- const excludeFilter = exclude?.map(patternToIdFilter);
2023
- const includeFilter = include?.map(patternToIdFilter);
2024
- return createFilter$1(excludeFilter, includeFilter);
2025
- }
2026
- function createCodeFilter(filter) {
2027
- if (!filter) return;
2028
- const { exclude, include } = normalizeFilter(filter);
2029
- const excludeFilter = exclude?.map(patternToCodeFilter);
2030
- const includeFilter = include?.map(patternToCodeFilter);
2031
- return createFilter$1(excludeFilter, includeFilter);
2032
- }
2033
- function createFilterForId(filter) {
2034
- const filterFunction = createIdFilter(filter);
2035
- return filterFunction ? (id) => !!filterFunction(id) : void 0;
2036
- }
2037
- function createFilterForTransform(idFilter, codeFilter) {
2038
- if (!idFilter && !codeFilter) return;
2039
- const idFilterFunction = createIdFilter(idFilter);
2040
- const codeFilterFunction = createCodeFilter(codeFilter);
2041
- return (id, code) => {
2042
- let fallback = true;
2043
- if (idFilterFunction) fallback &&= idFilterFunction(id);
2044
- if (!fallback) return false;
2045
- if (codeFilterFunction) fallback &&= codeFilterFunction(code);
2046
- return fallback;
2047
- };
2048
- }
2049
- function normalizeObjectHook(name, hook) {
2050
- let handler;
2051
- let filter;
2052
- if (typeof hook === "function") handler = hook;
2053
- else {
2054
- handler = hook.handler;
2055
- const hookFilter = hook.filter;
2056
- if (name === "resolveId" || name === "load") filter = createFilterForId(hookFilter?.id);
2057
- else filter = createFilterForTransform(hookFilter?.id, hookFilter?.code);
2058
- }
2059
- return {
2060
- handler,
2061
- filter: filter || (() => true)
2062
- };
2063
- }
2064
- function parse(code, opts = {}) {
2065
- return Parser.parse(code, {
2066
- sourceType: "module",
2067
- ecmaVersion: "latest",
2068
- locations: true,
2069
- ...opts
2070
- });
2071
- }
2072
-
2073
- //#endregion
2074
- //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/webpack-like-DFGTNSuV.js
2075
- function transformUse(data, plugin, transformLoader) {
2076
- if (data.resource == null) return [];
2077
- const id = normalizeAbsolutePath(data.resource + (data.resourceQuery || ""));
2078
- if (plugin.transformInclude && !plugin.transformInclude(id)) return [];
2079
- const { filter } = normalizeObjectHook("load", plugin.transform);
2080
- if (!filter(id)) return [];
2081
- return [{
2082
- loader: transformLoader,
2083
- options: { plugin },
2084
- ident: plugin.name
2085
- }];
2086
- }
2087
- /**
2088
- * Normalizes a given path when it's absolute. Normalizing means returning a new path by converting
2089
- * the input path to the native os format. This is useful in cases where we want to normalize
2090
- * the `id` argument of a hook. Any absolute ids should be in the default format
2091
- * of the operating system. Any relative imports or node_module imports should remain
2092
- * untouched.
2093
- *
2094
- * @param path - Path to normalize.
2095
- * @returns a new normalized path.
2096
- */
2097
- function normalizeAbsolutePath(path$1) {
2098
- if (isAbsolute(path$1)) return normalize(path$1);
2099
- else return path$1;
2100
- }
2101
-
2102
- //#endregion
2103
- //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/context-DkYlx1xL.js
2104
- function createBuildContext$1(compiler, compilation, loaderContext, inputSourceMap) {
2105
- return {
2106
- getNativeBuildContext() {
2107
- return {
2108
- framework: "rspack",
2109
- compiler,
2110
- compilation,
2111
- loaderContext,
2112
- inputSourceMap
2113
- };
2114
- },
2115
- addWatchFile(file) {
2116
- const cwd$1 = process.cwd();
2117
- compilation.fileDependencies.add(resolve(cwd$1, file));
2118
- },
2119
- getWatchFiles() {
2120
- return Array.from(compilation.fileDependencies);
2121
- },
2122
- parse,
2123
- emitFile(emittedFile) {
2124
- const outFileName = emittedFile.fileName || emittedFile.name;
2125
- if (emittedFile.source && outFileName) {
2126
- const { sources } = compilation.compiler.webpack;
2127
- compilation.emitAsset(outFileName, new sources.RawSource(typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)));
2128
- }
2129
- }
2130
- };
2131
- }
2132
- function normalizeMessage$1(error) {
2133
- const err = new Error(typeof error === "string" ? error : error.message);
2134
- if (typeof error === "object") {
2135
- err.stack = error.stack;
2136
- err.cause = error.meta;
2137
- }
2138
- return err;
2139
- }
2140
-
2141
- //#endregion
2142
- //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/utils-BosfZ0pB.js
2143
- function encodeVirtualModuleId(id, plugin) {
2144
- return resolve(plugin.__virtualModulePrefix, encodeURIComponent(id));
2145
- }
2146
- function decodeVirtualModuleId(encoded, _plugin) {
2147
- return decodeURIComponent(basename(encoded));
2148
- }
2149
- function isVirtualModuleId(encoded, plugin) {
2150
- return dirname(encoded) === plugin.__virtualModulePrefix;
2151
- }
2152
- var FakeVirtualModulesPlugin = class FakeVirtualModulesPlugin$1 {
2153
- name = "FakeVirtualModulesPlugin";
2154
- static counters = /* @__PURE__ */ new Map();
2155
- static initCleanup = false;
2156
- constructor(plugin) {
2157
- this.plugin = plugin;
2158
- if (!FakeVirtualModulesPlugin$1.initCleanup) {
2159
- FakeVirtualModulesPlugin$1.initCleanup = true;
2160
- process.once("exit", () => {
2161
- FakeVirtualModulesPlugin$1.counters.forEach((_, dir) => {
2162
- fs.rmSync(dir, {
2163
- recursive: true,
2164
- force: true
2165
- });
2166
- });
2167
- });
2168
- }
2169
- }
2170
- apply(compiler) {
2171
- const dir = this.plugin.__virtualModulePrefix;
2172
- if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
2173
- const counter = FakeVirtualModulesPlugin$1.counters.get(dir) ?? 0;
2174
- FakeVirtualModulesPlugin$1.counters.set(dir, counter + 1);
2175
- compiler.hooks.shutdown.tap(this.name, () => {
2176
- const counter$1 = (FakeVirtualModulesPlugin$1.counters.get(dir) ?? 1) - 1;
2177
- if (counter$1 === 0) {
2178
- FakeVirtualModulesPlugin$1.counters.delete(dir);
2179
- fs.rmSync(dir, {
2180
- recursive: true,
2181
- force: true
2182
- });
2183
- } else FakeVirtualModulesPlugin$1.counters.set(dir, counter$1);
2184
- });
2185
- }
2186
- async writeModule(file) {
2187
- return fs.promises.writeFile(file, "");
2188
- }
2189
- };
2190
-
2191
- //#endregion
2192
- //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/context-OCFO8EW1.js
2193
- function contextOptionsFromCompilation(compilation) {
2194
- return {
2195
- addWatchFile(file) {
2196
- (compilation.fileDependencies ?? compilation.compilationDependencies).add(file);
2197
- },
2198
- getWatchFiles() {
2199
- return Array.from(compilation.fileDependencies ?? compilation.compilationDependencies);
2200
- }
2201
- };
2202
- }
2203
- const require$1 = createRequire(import.meta.url);
2204
- function getSource(fileSource) {
2205
- return new (require$1("webpack")).sources.RawSource(typeof fileSource === "string" ? fileSource : Buffer.from(fileSource.buffer));
2206
- }
2207
- function createBuildContext(options, compiler, compilation, loaderContext, inputSourceMap) {
2208
- return {
2209
- parse,
2210
- addWatchFile(id) {
2211
- options.addWatchFile(resolve(process$1.cwd(), id));
2212
- },
2213
- emitFile(emittedFile) {
2214
- const outFileName = emittedFile.fileName || emittedFile.name;
2215
- if (emittedFile.source && outFileName) {
2216
- if (!compilation) throw new Error("unplugin/webpack: emitFile outside supported hooks (buildStart, buildEnd, load, transform, watchChange)");
2217
- compilation.emitAsset(outFileName, getSource(emittedFile.source));
2218
- }
2219
- },
2220
- getWatchFiles() {
2221
- return options.getWatchFiles();
2222
- },
2223
- getNativeBuildContext() {
2224
- return {
2225
- framework: "webpack",
2226
- compiler,
2227
- compilation,
2228
- loaderContext,
2229
- inputSourceMap
2230
- };
2231
- }
2232
- };
2233
- }
2234
- function normalizeMessage(error) {
2235
- const err = new Error(typeof error === "string" ? error : error.message);
2236
- if (typeof error === "object") {
2237
- err.stack = error.stack;
2238
- err.cause = error.meta;
2239
- }
2240
- return err;
2241
- }
2242
-
2243
- //#endregion
2244
- //#region node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/virtual-stats.js
2245
- var require_virtual_stats = /* @__PURE__ */ __commonJSMin(((exports) => {
2246
- var __importDefault = exports && exports.__importDefault || function(mod) {
2247
- return mod && mod.__esModule ? mod : { "default": mod };
2248
- };
2249
- Object.defineProperty(exports, "__esModule", { value: true });
2250
- exports.VirtualStats = void 0;
2251
- const constants_1 = __importDefault(__require("constants"));
2252
- var VirtualStats = class {
2253
- constructor(config) {
2254
- for (const key in config) {
2255
- if (!Object.prototype.hasOwnProperty.call(config, key)) continue;
2256
- this[key] = config[key];
2257
- }
2258
- }
2259
- _checkModeProperty(property) {
2260
- return (this.mode & constants_1.default.S_IFMT) === property;
2261
- }
2262
- isDirectory() {
2263
- return this._checkModeProperty(constants_1.default.S_IFDIR);
2264
- }
2265
- isFile() {
2266
- return this._checkModeProperty(constants_1.default.S_IFREG);
2267
- }
2268
- isBlockDevice() {
2269
- return this._checkModeProperty(constants_1.default.S_IFBLK);
2270
- }
2271
- isCharacterDevice() {
2272
- return this._checkModeProperty(constants_1.default.S_IFCHR);
2273
- }
2274
- isSymbolicLink() {
2275
- return this._checkModeProperty(constants_1.default.S_IFLNK);
2276
- }
2277
- isFIFO() {
2278
- return this._checkModeProperty(constants_1.default.S_IFIFO);
2279
- }
2280
- isSocket() {
2281
- return this._checkModeProperty(constants_1.default.S_IFSOCK);
2282
- }
2283
- };
2284
- exports.VirtualStats = VirtualStats;
2285
- }));
2286
-
2287
- //#endregion
2288
- //#region node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/index.js
2289
- var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2290
- const path_1 = (exports && exports.__importDefault || function(mod) {
2291
- return mod && mod.__esModule ? mod : { "default": mod };
2292
- })(__require("path"));
2293
- const virtual_stats_1 = require_virtual_stats();
2294
- let inode = 45e6;
2295
- const ALL = "all";
2296
- const STATIC = "static";
2297
- const DYNAMIC = "dynamic";
2298
- function checkActivation(instance) {
2299
- if (!instance._compiler) throw new Error("You must use this plugin only after creating webpack instance!");
2300
- }
2301
- function getModulePath(filePath, compiler) {
2302
- return path_1.default.isAbsolute(filePath) ? filePath : path_1.default.join(compiler.context, filePath);
2303
- }
2304
- function createWebpackData(result) {
2305
- return (backendOrStorage) => {
2306
- if (backendOrStorage._data) {
2307
- const curLevelIdx = backendOrStorage._currentLevel;
2308
- return {
2309
- result,
2310
- level: backendOrStorage._levels[curLevelIdx]
2311
- };
2312
- }
2313
- return [null, result];
2314
- };
2315
- }
2316
- function getData(storage, key) {
2317
- if (storage._data instanceof Map) return storage._data.get(key);
2318
- else if (storage._data) return storage.data[key];
2319
- else if (storage.data instanceof Map) return storage.data.get(key);
2320
- else return storage.data[key];
2321
- }
2322
- function setData(backendOrStorage, key, valueFactory) {
2323
- const value = valueFactory(backendOrStorage);
2324
- if (backendOrStorage._data instanceof Map) backendOrStorage._data.set(key, value);
2325
- else if (backendOrStorage._data) backendOrStorage.data[key] = value;
2326
- else if (backendOrStorage.data instanceof Map) backendOrStorage.data.set(key, value);
2327
- else backendOrStorage.data[key] = value;
2328
- }
2329
- function getStatStorage(fileSystem) {
2330
- if (fileSystem._statStorage) return fileSystem._statStorage;
2331
- else if (fileSystem._statBackend) return fileSystem._statBackend;
2332
- else throw new Error("Couldn't find a stat storage");
2333
- }
2334
- function getFileStorage(fileSystem) {
2335
- if (fileSystem._readFileStorage) return fileSystem._readFileStorage;
2336
- else if (fileSystem._readFileBackend) return fileSystem._readFileBackend;
2337
- else throw new Error("Couldn't find a readFileStorage");
2338
- }
2339
- function getReadDirBackend(fileSystem) {
2340
- if (fileSystem._readdirBackend) return fileSystem._readdirBackend;
2341
- else if (fileSystem._readdirStorage) return fileSystem._readdirStorage;
2342
- else throw new Error("Couldn't find a readDirStorage from Webpack Internals");
2343
- }
2344
- function getRealpathBackend(fileSystem) {
2345
- if (fileSystem._realpathBackend) return fileSystem._realpathBackend;
2346
- }
2347
- var VirtualModulesPlugin = class {
2348
- constructor(modules) {
2349
- this._compiler = null;
2350
- this._watcher = null;
2351
- this._staticModules = modules || null;
2352
- }
2353
- getModuleList(filter = ALL) {
2354
- var _a, _b;
2355
- let modules = {};
2356
- const shouldGetStaticModules = filter === ALL || filter === STATIC;
2357
- const shouldGetDynamicModules = filter === ALL || filter === DYNAMIC;
2358
- if (shouldGetStaticModules) modules = Object.assign(Object.assign({}, modules), this._staticModules);
2359
- if (shouldGetDynamicModules) {
2360
- const finalInputFileSystem = (_a = this._compiler) === null || _a === void 0 ? void 0 : _a.inputFileSystem;
2361
- const virtualFiles = (_b = finalInputFileSystem === null || finalInputFileSystem === void 0 ? void 0 : finalInputFileSystem._virtualFiles) !== null && _b !== void 0 ? _b : {};
2362
- const dynamicModules = {};
2363
- Object.keys(virtualFiles).forEach((key) => {
2364
- dynamicModules[key] = virtualFiles[key].contents;
2365
- });
2366
- modules = Object.assign(Object.assign({}, modules), dynamicModules);
2367
- }
2368
- return modules;
2369
- }
2370
- writeModule(filePath, contents) {
2371
- if (!this._compiler) throw new Error(`Plugin has not been initialized`);
2372
- checkActivation(this);
2373
- const len = contents ? contents.length : 0;
2374
- const time = Date.now();
2375
- const date = new Date(time);
2376
- const stats = new virtual_stats_1.VirtualStats({
2377
- dev: 8675309,
2378
- nlink: 0,
2379
- uid: 1e3,
2380
- gid: 1e3,
2381
- rdev: 0,
2382
- blksize: 4096,
2383
- ino: inode++,
2384
- mode: 33188,
2385
- size: len,
2386
- blocks: Math.floor(len / 4096),
2387
- atime: date,
2388
- mtime: date,
2389
- ctime: date,
2390
- birthtime: date
2391
- });
2392
- const modulePath = getModulePath(filePath, this._compiler);
2393
- if (process.env.WVM_DEBUG) console.log(this._compiler.name, "Write virtual module:", modulePath, contents);
2394
- let finalWatchFileSystem = this._watcher && this._watcher.watchFileSystem;
2395
- while (finalWatchFileSystem && finalWatchFileSystem.wfs) finalWatchFileSystem = finalWatchFileSystem.wfs;
2396
- let finalInputFileSystem = this._compiler.inputFileSystem;
2397
- while (finalInputFileSystem && finalInputFileSystem._inputFileSystem) finalInputFileSystem = finalInputFileSystem._inputFileSystem;
2398
- finalInputFileSystem._writeVirtualFile(modulePath, stats, contents);
2399
- if (finalWatchFileSystem && finalWatchFileSystem.watcher && (finalWatchFileSystem.watcher.fileWatchers.size || finalWatchFileSystem.watcher.fileWatchers.length)) {
2400
- const fileWatchers = finalWatchFileSystem.watcher.fileWatchers instanceof Map ? Array.from(finalWatchFileSystem.watcher.fileWatchers.values()) : finalWatchFileSystem.watcher.fileWatchers;
2401
- for (let fileWatcher of fileWatchers) {
2402
- if ("watcher" in fileWatcher) fileWatcher = fileWatcher.watcher;
2403
- if (fileWatcher.path === modulePath) {
2404
- if (process.env.DEBUG) console.log(this._compiler.name, "Emit file change:", modulePath, time);
2405
- delete fileWatcher.directoryWatcher._cachedTimeInfoEntries;
2406
- fileWatcher.emit("change", time, null);
2407
- }
2408
- }
2409
- }
2410
- }
2411
- apply(compiler) {
2412
- this._compiler = compiler;
2413
- const afterEnvironmentHook = () => {
2414
- let finalInputFileSystem = compiler.inputFileSystem;
2415
- while (finalInputFileSystem && finalInputFileSystem._inputFileSystem) finalInputFileSystem = finalInputFileSystem._inputFileSystem;
2416
- if (!finalInputFileSystem._writeVirtualFile) {
2417
- const originalPurge = finalInputFileSystem.purge;
2418
- finalInputFileSystem.purge = () => {
2419
- originalPurge.apply(finalInputFileSystem, []);
2420
- if (finalInputFileSystem._virtualFiles) Object.keys(finalInputFileSystem._virtualFiles).forEach((file) => {
2421
- const data = finalInputFileSystem._virtualFiles[file];
2422
- finalInputFileSystem._writeVirtualFile(file, data.stats, data.contents);
2423
- });
2424
- };
2425
- finalInputFileSystem._writeVirtualFile = (file, stats, contents) => {
2426
- const statStorage = getStatStorage(finalInputFileSystem);
2427
- const fileStorage = getFileStorage(finalInputFileSystem);
2428
- const readDirStorage = getReadDirBackend(finalInputFileSystem);
2429
- const realPathStorage = getRealpathBackend(finalInputFileSystem);
2430
- finalInputFileSystem._virtualFiles = finalInputFileSystem._virtualFiles || {};
2431
- finalInputFileSystem._virtualFiles[file] = {
2432
- stats,
2433
- contents
2434
- };
2435
- setData(statStorage, file, createWebpackData(stats));
2436
- setData(fileStorage, file, createWebpackData(contents));
2437
- const segments = file.split(/[\\/]/);
2438
- let count = segments.length - 1;
2439
- const minCount = segments[0] ? 1 : 0;
2440
- while (count > minCount) {
2441
- const dir = segments.slice(0, count).join(path_1.default.sep) || path_1.default.sep;
2442
- try {
2443
- finalInputFileSystem.readdirSync(dir);
2444
- } catch (e) {
2445
- const time = Date.now();
2446
- const dirStats = new virtual_stats_1.VirtualStats({
2447
- dev: 8675309,
2448
- nlink: 0,
2449
- uid: 1e3,
2450
- gid: 1e3,
2451
- rdev: 0,
2452
- blksize: 4096,
2453
- ino: inode++,
2454
- mode: 16877,
2455
- size: stats.size,
2456
- blocks: Math.floor(stats.size / 4096),
2457
- atime: time,
2458
- mtime: time,
2459
- ctime: time,
2460
- birthtime: time
2461
- });
2462
- setData(readDirStorage, dir, createWebpackData([]));
2463
- if (realPathStorage) setData(realPathStorage, dir, createWebpackData(dir));
2464
- setData(statStorage, dir, createWebpackData(dirStats));
2465
- }
2466
- let dirData = getData(getReadDirBackend(finalInputFileSystem), dir);
2467
- dirData = dirData[1] || dirData.result;
2468
- const filename = segments[count];
2469
- if (dirData.indexOf(filename) < 0) {
2470
- const files = dirData.concat([filename]).sort();
2471
- setData(getReadDirBackend(finalInputFileSystem), dir, createWebpackData(files));
2472
- } else break;
2473
- count--;
2474
- }
2475
- };
2476
- }
2477
- };
2478
- const afterResolversHook = () => {
2479
- if (this._staticModules) {
2480
- for (const [filePath, contents] of Object.entries(this._staticModules)) this.writeModule(filePath, contents);
2481
- this._staticModules = null;
2482
- }
2483
- };
2484
- const version$1 = typeof compiler.webpack === "undefined" ? 4 : 5;
2485
- const watchRunHook = (watcher, callback) => {
2486
- this._watcher = watcher.compiler || watcher;
2487
- const virtualFiles = compiler.inputFileSystem._virtualFiles;
2488
- const fts = compiler.fileTimestamps;
2489
- if (virtualFiles && fts && typeof fts.set === "function") Object.keys(virtualFiles).forEach((file) => {
2490
- const mtime = +virtualFiles[file].stats.mtime;
2491
- fts.set(file, version$1 === 4 ? mtime : {
2492
- safeTime: mtime,
2493
- timestamp: mtime
2494
- });
2495
- });
2496
- callback();
2497
- };
2498
- if (compiler.hooks) {
2499
- compiler.hooks.afterEnvironment.tap("VirtualModulesPlugin", afterEnvironmentHook);
2500
- compiler.hooks.afterResolvers.tap("VirtualModulesPlugin", afterResolversHook);
2501
- compiler.hooks.watchRun.tapAsync("VirtualModulesPlugin", watchRunHook);
2502
- } else {
2503
- compiler.plugin("after-environment", afterEnvironmentHook);
2504
- compiler.plugin("after-resolvers", afterResolversHook);
2505
- compiler.plugin("watch-run", watchRunHook);
2506
- }
2507
- }
2508
- };
2509
- module.exports = VirtualModulesPlugin;
2510
- }));
2511
-
2512
- //#endregion
2513
- //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/index.js
2514
- var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
2515
- const ExtToLoader = {
2516
- ".js": "js",
2517
- ".mjs": "js",
2518
- ".cjs": "js",
2519
- ".jsx": "jsx",
2520
- ".ts": "ts",
2521
- ".cts": "ts",
2522
- ".mts": "ts",
2523
- ".tsx": "tsx",
2524
- ".css": "css",
2525
- ".less": "css",
2526
- ".stylus": "css",
2527
- ".scss": "css",
2528
- ".sass": "css",
2529
- ".json": "json",
2530
- ".txt": "text"
2531
- };
2532
- function guessLoader(code, id) {
2533
- return ExtToLoader[path.extname(id).toLowerCase()] || "js";
2534
- }
2535
- function unwrapLoader(loader, code, id) {
2536
- if (typeof loader === "function") return loader(code, id);
2537
- return loader;
2538
- }
2539
- function fixSourceMap(map) {
2540
- if (!Object.prototype.hasOwnProperty.call(map, "toString")) Object.defineProperty(map, "toString", {
2541
- enumerable: false,
2542
- value: function toString() {
2543
- return JSON.stringify(this);
2544
- }
2545
- });
2546
- if (!Object.prototype.hasOwnProperty.call(map, "toUrl")) Object.defineProperty(map, "toUrl", {
2547
- enumerable: false,
2548
- value: function toUrl() {
2549
- return `data:application/json;charset=utf-8;base64,${Buffer.from(this.toString()).toString("base64")}`;
2550
- }
2551
- });
2552
- return map;
2553
- }
2554
- const nullSourceMap = {
2555
- names: [],
2556
- sources: [],
2557
- mappings: "",
2558
- version: 3
2559
- };
2560
- function combineSourcemaps(filename, sourcemapList) {
2561
- sourcemapList = sourcemapList.filter((m) => m.sources);
2562
- if (sourcemapList.length === 0 || sourcemapList.every((m) => m.sources.length === 0)) return { ...nullSourceMap };
2563
- let map;
2564
- let mapIndex = 1;
2565
- if (sourcemapList.slice(0, -1).find((m) => m.sources.length !== 1) === void 0) map = remapping(sourcemapList, () => null, true);
2566
- else map = remapping(sourcemapList[0], (sourcefile) => {
2567
- if (sourcefile === filename && sourcemapList[mapIndex]) return sourcemapList[mapIndex++];
2568
- else return { ...nullSourceMap };
2569
- }, true);
2570
- if (!map.file) delete map.file;
2571
- return map;
2572
- }
2573
- function createBuildContext$2(build) {
2574
- const watchFiles = [];
2575
- const { initialOptions } = build;
2576
- return {
2577
- parse,
2578
- addWatchFile() {
2579
- throw new Error("unplugin/esbuild: addWatchFile outside supported hooks (resolveId, load, transform)");
2580
- },
2581
- emitFile(emittedFile) {
2582
- const outFileName = emittedFile.fileName || emittedFile.name;
2583
- if (initialOptions.outdir && emittedFile.source && outFileName) {
2584
- const outPath = path.resolve(initialOptions.outdir, outFileName);
2585
- const outDir = path.dirname(outPath);
2586
- if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true });
2587
- fs.writeFileSync(outPath, emittedFile.source);
2588
- }
2589
- },
2590
- getWatchFiles() {
2591
- return watchFiles;
2592
- },
2593
- getNativeBuildContext() {
2594
- return {
2595
- framework: "esbuild",
2596
- build
2597
- };
2598
- }
2599
- };
2600
- }
2601
- function createPluginContext(context) {
2602
- const errors = [];
2603
- const warnings = [];
2604
- const pluginContext = {
2605
- error(message) {
2606
- errors.push(normalizeMessage$2(message));
2607
- },
2608
- warn(message) {
2609
- warnings.push(normalizeMessage$2(message));
2610
- }
2611
- };
2612
- return {
2613
- errors,
2614
- warnings,
2615
- mixedContext: {
2616
- ...context,
2617
- ...pluginContext,
2618
- addWatchFile(id) {
2619
- context.getWatchFiles().push(id);
2620
- }
2621
- }
2622
- };
2623
- }
2624
- function normalizeMessage$2(message) {
2625
- if (typeof message === "string") message = { message };
2626
- return {
2627
- id: message.id,
2628
- pluginName: message.plugin,
2629
- text: message.message,
2630
- location: message.loc ? {
2631
- file: message.loc.file,
2632
- line: message.loc.line,
2633
- column: message.loc.column
2634
- } : null,
2635
- detail: message.meta,
2636
- notes: []
2637
- };
2638
- }
2639
- function processCodeWithSourceMap(map, code) {
2640
- if (map) {
2641
- if (!map.sourcesContent || map.sourcesContent.length === 0) map.sourcesContent = [code];
2642
- map = fixSourceMap(map);
2643
- code += `\n//# sourceMappingURL=${map.toUrl()}`;
2644
- }
2645
- return code;
2646
- }
2647
- function getEsbuildPlugin(factory) {
2648
- return (userOptions) => {
2649
- const meta = { framework: "esbuild" };
2650
- const plugins = toArray$2(factory(userOptions, meta));
2651
- const setupPlugins = async (build) => {
2652
- const setup = buildSetup();
2653
- const loaders = [];
2654
- for (const plugin of plugins) {
2655
- const loader = {};
2656
- await setup(plugin)({
2657
- ...build,
2658
- onLoad(_options, callback) {
2659
- loader.options = _options;
2660
- loader.onLoadCb = callback;
2661
- },
2662
- onTransform(_options, callback) {
2663
- loader.options ||= _options;
2664
- loader.onTransformCb = callback;
2665
- }
2666
- }, build);
2667
- if (loader.onLoadCb || loader.onTransformCb) loaders.push(loader);
2668
- }
2669
- if (loaders.length) build.onLoad(loaders.length === 1 ? loaders[0].options : { filter: /.*/ }, async (args) => {
2670
- function checkFilter(options) {
2671
- return loaders.length === 1 || !options?.filter || options.filter.test(args.path);
2672
- }
2673
- let result;
2674
- for (const { options, onLoadCb } of loaders) {
2675
- if (!checkFilter(options)) continue;
2676
- if (onLoadCb) result = await onLoadCb(args);
2677
- if (result?.contents) break;
2678
- }
2679
- let fsContentsCache;
2680
- for (const { options, onTransformCb } of loaders) {
2681
- if (!checkFilter(options)) continue;
2682
- if (onTransformCb) {
2683
- const _result = await onTransformCb({
2684
- ...result,
2685
- ...args,
2686
- async getContents() {
2687
- if (result?.contents) return result.contents;
2688
- if (fsContentsCache) return fsContentsCache;
2689
- return fsContentsCache = await fs.promises.readFile(args.path, "utf8");
2690
- }
2691
- });
2692
- if (_result?.contents) result = _result;
2693
- }
2694
- }
2695
- if (result?.contents) return result;
2696
- });
2697
- };
2698
- return {
2699
- name: (plugins.length === 1 ? plugins[0].name : meta.esbuildHostName) ?? `unplugin-host:${plugins.map((p) => p.name).join(":")}`,
2700
- setup: setupPlugins
2701
- };
2702
- };
2703
- }
2704
- function buildSetup() {
2705
- return (plugin) => {
2706
- return (build, rawBuild) => {
2707
- const context = createBuildContext$2(rawBuild);
2708
- const { onStart, onEnd, onResolve, onLoad, onTransform, initialOptions } = build;
2709
- const onResolveFilter = plugin.esbuild?.onResolveFilter ?? /.*/;
2710
- const onLoadFilter = plugin.esbuild?.onLoadFilter ?? /.*/;
2711
- const loader = plugin.esbuild?.loader ?? guessLoader;
2712
- plugin.esbuild?.config?.call(context, initialOptions);
2713
- if (plugin.buildStart) onStart(() => plugin.buildStart.call(context));
2714
- if (plugin.buildEnd || plugin.writeBundle) onEnd(async () => {
2715
- if (plugin.buildEnd) await plugin.buildEnd.call(context);
2716
- if (plugin.writeBundle) await plugin.writeBundle();
2717
- });
2718
- if (plugin.resolveId) onResolve({ filter: onResolveFilter }, async (args) => {
2719
- const id = args.path;
2720
- if (initialOptions.external?.includes(id)) return;
2721
- const { handler, filter } = normalizeObjectHook("resolveId", plugin.resolveId);
2722
- if (!filter(id)) return;
2723
- const { errors, warnings, mixedContext } = createPluginContext(context);
2724
- const isEntry = args.kind === "entry-point";
2725
- const result = await handler.call(mixedContext, id, isEntry ? void 0 : args.importer, { isEntry });
2726
- if (typeof result === "string") return {
2727
- path: result,
2728
- namespace: plugin.name,
2729
- errors,
2730
- warnings,
2731
- watchFiles: mixedContext.getWatchFiles()
2732
- };
2733
- else if (typeof result === "object" && result !== null) return {
2734
- path: result.id,
2735
- external: result.external,
2736
- namespace: plugin.name,
2737
- errors,
2738
- warnings,
2739
- watchFiles: mixedContext.getWatchFiles()
2740
- };
2741
- });
2742
- if (plugin.load) onLoad({ filter: onLoadFilter }, async (args) => {
2743
- const { handler, filter } = normalizeObjectHook("load", plugin.load);
2744
- const id = args.path + (args.suffix || "");
2745
- if (plugin.loadInclude && !plugin.loadInclude(id)) return;
2746
- if (!filter(id)) return;
2747
- const { errors, warnings, mixedContext } = createPluginContext(context);
2748
- let code;
2749
- let map;
2750
- const result = await handler.call(mixedContext, id);
2751
- if (typeof result === "string") code = result;
2752
- else if (typeof result === "object" && result !== null) {
2753
- code = result.code;
2754
- map = result.map;
2755
- }
2756
- if (code === void 0) return null;
2757
- if (map) code = processCodeWithSourceMap(map, code);
2758
- const resolveDir = path.dirname(args.path);
2759
- return {
2760
- contents: code,
2761
- errors,
2762
- warnings,
2763
- watchFiles: mixedContext.getWatchFiles(),
2764
- loader: unwrapLoader(loader, code, args.path),
2765
- resolveDir
2766
- };
2767
- });
2768
- if (plugin.transform) onTransform({ filter: onLoadFilter }, async (args) => {
2769
- const { handler, filter } = normalizeObjectHook("transform", plugin.transform);
2770
- const id = args.path + (args.suffix || "");
2771
- if (plugin.transformInclude && !plugin.transformInclude(id)) return;
2772
- let code = await args.getContents();
2773
- if (!filter(id, code)) return;
2774
- const { mixedContext, errors, warnings } = createPluginContext(context);
2775
- const resolveDir = path.dirname(args.path);
2776
- let map;
2777
- const result = await handler.call(mixedContext, code, id);
2778
- if (typeof result === "string") code = result;
2779
- else if (typeof result === "object" && result !== null) {
2780
- code = result.code;
2781
- if (map && result.map) map = combineSourcemaps(args.path, [result.map === "string" ? JSON.parse(result.map) : result.map, map]);
2782
- else if (typeof result.map === "string") map = JSON.parse(result.map);
2783
- else map = result.map;
2784
- }
2785
- if (code) {
2786
- if (map) code = processCodeWithSourceMap(map, code);
2787
- return {
2788
- contents: code,
2789
- errors,
2790
- warnings,
2791
- watchFiles: mixedContext.getWatchFiles(),
2792
- loader: unwrapLoader(loader, code, args.path),
2793
- resolveDir
2794
- };
2795
- }
2796
- });
2797
- if (plugin.esbuild?.setup) return plugin.esbuild.setup(rawBuild);
2798
- };
2799
- };
2800
- }
2801
- function createFarmContext(context, currentResolveId) {
2802
- return {
2803
- parse,
2804
- addWatchFile(id) {
2805
- context.addWatchFile(id, currentResolveId || id);
2806
- },
2807
- emitFile(emittedFile) {
2808
- const outFileName = emittedFile.fileName || emittedFile.name;
2809
- if (emittedFile.source && outFileName) context.emitFile({
2810
- resolvedPath: outFileName,
2811
- name: outFileName,
2812
- content: [...Buffer.from(emittedFile.source)],
2813
- resourceType: extname(outFileName)
2814
- });
2815
- },
2816
- getWatchFiles() {
2817
- return context.getWatchFiles();
2818
- },
2819
- getNativeBuildContext() {
2820
- return {
2821
- framework: "farm",
2822
- context
2823
- };
2824
- }
2825
- };
2826
- }
2827
- function unpluginContext(context) {
2828
- return {
2829
- error: (error) => context.error(typeof error === "string" ? new Error(error) : error),
2830
- warn: (error) => context.warn(typeof error === "string" ? new Error(error) : error)
2831
- };
2832
- }
2833
- function convertEnforceToPriority(value) {
2834
- const defaultPriority = 100;
2835
- const enforceToPriority = {
2836
- pre: 102,
2837
- post: 98
2838
- };
2839
- return enforceToPriority[value] !== void 0 ? enforceToPriority[value] : defaultPriority;
2840
- }
2841
- function convertWatchEventChange(value) {
2842
- return {
2843
- Added: "create",
2844
- Updated: "update",
2845
- Removed: "delete"
2846
- }[value];
2847
- }
2848
- function isString(variable) {
2849
- return typeof variable === "string";
2850
- }
2851
- function isObject(variable) {
2852
- return typeof variable === "object" && variable !== null;
2853
- }
2854
- function customParseQueryString(url) {
2855
- if (!url) return [];
2856
- const queryString = url.split("?")[1];
2857
- const parsedParams = querystring.parse(queryString);
2858
- const paramsArray = [];
2859
- for (const key in parsedParams) paramsArray.push([key, parsedParams[key]]);
2860
- return paramsArray;
2861
- }
2862
- function encodeStr(str) {
2863
- const len = str.length;
2864
- if (len === 0) return str;
2865
- const firstNullIndex = str.indexOf("\0");
2866
- if (firstNullIndex === -1) return str;
2867
- const result = Array.from({ length: len + countNulls(str, firstNullIndex) });
2868
- let pos = 0;
2869
- for (let i = 0; i < firstNullIndex; i++) result[pos++] = str[i];
2870
- for (let i = firstNullIndex; i < len; i++) {
2871
- const char = str[i];
2872
- if (char === "\0") {
2873
- result[pos++] = "\\";
2874
- result[pos++] = "0";
2875
- } else result[pos++] = char;
2876
- }
2877
- return path.posix.normalize(result.join(""));
2878
- }
2879
- function decodeStr(str) {
2880
- const len = str.length;
2881
- if (len === 0) return str;
2882
- const firstIndex = str.indexOf("\\0");
2883
- if (firstIndex === -1) return str;
2884
- const result = Array.from({ length: len - countBackslashZeros(str, firstIndex) });
2885
- let pos = 0;
2886
- for (let i$1 = 0; i$1 < firstIndex; i$1++) result[pos++] = str[i$1];
2887
- let i = firstIndex;
2888
- while (i < len) if (str[i] === "\\" && str[i + 1] === "0") {
2889
- result[pos++] = "\0";
2890
- i += 2;
2891
- } else result[pos++] = str[i++];
2892
- return path.posix.normalize(result.join(""));
2893
- }
2894
- function getContentValue(content) {
2895
- if (content === null || content === void 0) throw new Error("Content cannot be null or undefined");
2896
- return encodeStr(typeof content === "string" ? content : content.code || "");
2897
- }
2898
- function countNulls(str, startIndex) {
2899
- let count = 0;
2900
- const len = str.length;
2901
- for (let i = startIndex; i < len; i++) if (str[i] === "\0") count++;
2902
- return count;
2903
- }
2904
- function countBackslashZeros(str, startIndex) {
2905
- let count = 0;
2906
- const len = str.length;
2907
- for (let i = startIndex; i < len - 1; i++) if (str[i] === "\\" && str[i + 1] === "0") {
2908
- count++;
2909
- i++;
2910
- }
2911
- return count;
2912
- }
2913
- function removeQuery(pathe) {
2914
- const queryIndex = pathe.indexOf("?");
2915
- if (queryIndex !== -1) return path.posix.normalize(pathe.slice(0, queryIndex));
2916
- return path.posix.normalize(pathe);
2917
- }
2918
- function isStartsWithSlash(str) {
2919
- return str?.startsWith("/");
2920
- }
2921
- function appendQuery(id, query) {
2922
- if (!query.length) return id;
2923
- return `${id}?${stringifyQuery(query)}`;
2924
- }
2925
- function stringifyQuery(query) {
2926
- if (!query.length) return "";
2927
- let queryStr = "";
2928
- for (const [key, value] of query) queryStr += `${key}${value ? `=${value}` : ""}&`;
2929
- return `${queryStr.slice(0, -1)}`;
2930
- }
2931
- const CSS_LANGS_RES = [
2932
- [/\.(less)(?:$|\?)/, "less"],
2933
- [/\.(scss|sass)(?:$|\?)/, "sass"],
2934
- [/\.(styl|stylus)(?:$|\?)/, "stylus"],
2935
- [/\.(css)(?:$|\?)/, "css"]
2936
- ];
2937
- const JS_LANGS_RES = [
2938
- [/\.(js|mjs|cjs)(?:$|\?)/, "js"],
2939
- [/\.(jsx)(?:$|\?)/, "jsx"],
2940
- [/\.(ts|cts|mts)(?:$|\?)/, "ts"],
2941
- [/\.(tsx)(?:$|\?)/, "tsx"]
2942
- ];
2943
- function getCssModuleType(id) {
2944
- for (const [reg, lang] of CSS_LANGS_RES) if (reg.test(id)) return lang;
2945
- return null;
2946
- }
2947
- function getJsModuleType(id) {
2948
- for (const [reg, lang] of JS_LANGS_RES) if (reg.test(id)) return lang;
2949
- return null;
2950
- }
2951
- function formatLoadModuleType(id) {
2952
- const cssModuleType = getCssModuleType(id);
2953
- if (cssModuleType) return cssModuleType;
2954
- const jsModuleType = getJsModuleType(id);
2955
- if (jsModuleType) return jsModuleType;
2956
- return "js";
2957
- }
2958
- function formatTransformModuleType(id) {
2959
- return formatLoadModuleType(id);
2960
- }
2961
- function getFarmPlugin(factory) {
2962
- return ((userOptions) => {
2963
- const plugins = toArray$2(factory(userOptions, { framework: "farm" })).map((rawPlugin) => {
2964
- const plugin = toFarmPlugin(rawPlugin, userOptions);
2965
- if (rawPlugin.farm) Object.assign(plugin, rawPlugin.farm);
2966
- return plugin;
2967
- });
2968
- return plugins.length === 1 ? plugins[0] : plugins;
2969
- });
2970
- }
2971
- function toFarmPlugin(plugin, options) {
2972
- const farmPlugin = {
2973
- name: plugin.name,
2974
- priority: convertEnforceToPriority(plugin.enforce)
2975
- };
2976
- if (plugin.farm) Object.keys(plugin.farm).forEach((key) => {
2977
- const value = plugin.farm[key];
2978
- if (value) Reflect.set(farmPlugin, key, value);
2979
- });
2980
- if (plugin.buildStart) {
2981
- const _buildStart = plugin.buildStart;
2982
- farmPlugin.buildStart = { async executor(_, context) {
2983
- await _buildStart.call(createFarmContext(context));
2984
- } };
2985
- }
2986
- if (plugin.resolveId) {
2987
- const _resolveId = plugin.resolveId;
2988
- let filters = [];
2989
- if (options) filters = options?.filters ?? [];
2990
- farmPlugin.resolve = {
2991
- filters: {
2992
- sources: filters.length ? filters : [".*"],
2993
- importers: [".*"]
2994
- },
2995
- async executor(params, context) {
2996
- const resolvedIdPath = path.resolve(params.importer ?? "");
2997
- const id = decodeStr(params.source);
2998
- const { handler, filter } = normalizeObjectHook("resolveId", _resolveId);
2999
- if (!filter(id)) return null;
3000
- let isEntry = false;
3001
- if (isObject(params.kind) && "entry" in params.kind) isEntry = params.kind.entry === "index";
3002
- const farmContext = createFarmContext(context, resolvedIdPath);
3003
- const resolveIdResult = await handler.call(Object.assign(unpluginContext(context), farmContext), id, resolvedIdPath ?? null, { isEntry });
3004
- if (isString(resolveIdResult)) return {
3005
- resolvedPath: removeQuery(encodeStr(resolveIdResult)),
3006
- query: customParseQueryString(resolveIdResult),
3007
- sideEffects: true,
3008
- external: false,
3009
- meta: {}
3010
- };
3011
- if (isObject(resolveIdResult)) return {
3012
- resolvedPath: removeQuery(encodeStr(resolveIdResult?.id)),
3013
- query: customParseQueryString(resolveIdResult?.id),
3014
- sideEffects: false,
3015
- external: Boolean(resolveIdResult?.external),
3016
- meta: {}
3017
- };
3018
- if (!isStartsWithSlash(params.source)) return null;
3019
- }
3020
- };
3021
- }
3022
- if (plugin.load) {
3023
- const _load = plugin.load;
3024
- farmPlugin.load = {
3025
- filters: { resolvedPaths: [".*"] },
3026
- async executor(params, context) {
3027
- const id = appendQuery(decodeStr(params.resolvedPath), params.query);
3028
- const loader = formatTransformModuleType(id);
3029
- if (plugin.loadInclude && !plugin.loadInclude?.(id)) return null;
3030
- const { handler, filter } = normalizeObjectHook("load", _load);
3031
- if (!filter(id)) return null;
3032
- const farmContext = createFarmContext(context, id);
3033
- return {
3034
- content: getContentValue(await handler.call(Object.assign(unpluginContext(context), farmContext), id)),
3035
- moduleType: loader
3036
- };
3037
- }
3038
- };
3039
- }
3040
- if (plugin.transform) {
3041
- const _transform = plugin.transform;
3042
- farmPlugin.transform = {
3043
- filters: {
3044
- resolvedPaths: [".*"],
3045
- moduleTypes: [".*"]
3046
- },
3047
- async executor(params, context) {
3048
- const id = appendQuery(decodeStr(params.resolvedPath), params.query);
3049
- const loader = formatTransformModuleType(id);
3050
- if (plugin.transformInclude && !plugin.transformInclude(id)) return null;
3051
- const { handler, filter } = normalizeObjectHook("transform", _transform);
3052
- if (!filter(id, params.content)) return null;
3053
- const farmContext = createFarmContext(context, id);
3054
- const resource = await handler.call(Object.assign(unpluginContext(context), farmContext), params.content, id);
3055
- if (resource && typeof resource !== "string") return {
3056
- content: getContentValue(resource),
3057
- moduleType: loader,
3058
- sourceMap: typeof resource.map === "object" && resource.map !== null ? JSON.stringify(resource.map) : void 0
3059
- };
3060
- }
3061
- };
3062
- }
3063
- if (plugin.watchChange) {
3064
- const _watchChange = plugin.watchChange;
3065
- farmPlugin.updateModules = { async executor(param, context) {
3066
- const updatePathContent = param.paths[0];
3067
- const ModifiedPath = updatePathContent[0];
3068
- const eventChange = convertWatchEventChange(updatePathContent[1]);
3069
- await _watchChange.call(createFarmContext(context), ModifiedPath, { event: eventChange });
3070
- } };
3071
- }
3072
- if (plugin.buildEnd) {
3073
- const _buildEnd = plugin.buildEnd;
3074
- farmPlugin.buildEnd = { async executor(_, context) {
3075
- await _buildEnd.call(createFarmContext(context));
3076
- } };
3077
- }
3078
- if (plugin.writeBundle) {
3079
- const _writeBundle = plugin.writeBundle;
3080
- farmPlugin.finish = { async executor() {
3081
- await _writeBundle();
3082
- } };
3083
- }
3084
- return farmPlugin;
3085
- }
3086
- function getRollupPlugin(factory) {
3087
- return ((userOptions) => {
3088
- const plugins = toArray$2(factory(userOptions, { framework: "rollup" })).map((plugin) => toRollupPlugin(plugin, "rollup"));
3089
- return plugins.length === 1 ? plugins[0] : plugins;
3090
- });
3091
- }
3092
- function toRollupPlugin(plugin, key) {
3093
- const nativeFilter = key === "rolldown";
3094
- if (plugin.resolveId && !nativeFilter && typeof plugin.resolveId === "object" && plugin.resolveId.filter) {
3095
- const resolveIdHook = plugin.resolveId;
3096
- const { handler, filter } = normalizeObjectHook("load", resolveIdHook);
3097
- replaceHookHandler("resolveId", resolveIdHook, function(...args) {
3098
- const [id] = args;
3099
- if (!supportNativeFilter(this, key) && !filter(id)) return;
3100
- return handler.apply(this, args);
3101
- });
3102
- }
3103
- if (plugin.load && (plugin.loadInclude || !nativeFilter && typeof plugin.load === "object" && plugin.load.filter)) {
3104
- const loadHook = plugin.load;
3105
- const { handler, filter } = normalizeObjectHook("load", loadHook);
3106
- replaceHookHandler("load", loadHook, function(...args) {
3107
- const [id] = args;
3108
- if (plugin.loadInclude && !plugin.loadInclude(id)) return;
3109
- if (!supportNativeFilter(this, key) && !filter(id)) return;
3110
- return handler.apply(this, args);
3111
- });
3112
- }
3113
- if (plugin.transform && (plugin.transformInclude || !nativeFilter && typeof plugin.transform === "object" && plugin.transform.filter)) {
3114
- const transformHook = plugin.transform;
3115
- const { handler, filter } = normalizeObjectHook("transform", transformHook);
3116
- replaceHookHandler("transform", transformHook, function(...args) {
3117
- const [code, id] = args;
3118
- if (plugin.transformInclude && !plugin.transformInclude(id)) return;
3119
- if (!supportNativeFilter(this, key) && !filter(id, code)) return;
3120
- return handler.apply(this, args);
3121
- });
3122
- }
3123
- if (plugin[key]) Object.assign(plugin, plugin[key]);
3124
- return plugin;
3125
- function replaceHookHandler(name, hook, handler) {
3126
- if (typeof hook === "function") plugin[name] = handler;
3127
- else hook.handler = handler;
3128
- }
3129
- }
3130
- function supportNativeFilter(context, framework) {
3131
- if (framework === "unloader") return false;
3132
- if (framework === "vite") return !!context?.meta?.viteVersion;
3133
- if (framework === "rolldown") return true;
3134
- const rollupVersion = context?.meta?.rollupVersion;
3135
- if (!rollupVersion) return false;
3136
- const [major, minor] = rollupVersion.split(".");
3137
- return Number(major) > 4 || Number(major) === 4 && Number(minor) >= 40;
3138
- }
3139
- function getRolldownPlugin(factory) {
3140
- return ((userOptions) => {
3141
- const plugins = toArray$2(factory(userOptions, { framework: "rolldown" })).map((rawPlugin) => {
3142
- return toRollupPlugin(rawPlugin, "rolldown");
3143
- });
3144
- return plugins.length === 1 ? plugins[0] : plugins;
3145
- });
3146
- }
3147
- const getFilename = () => fileURLToPath(import.meta.url);
3148
- const getDirname = () => path.dirname(getFilename());
3149
- const __dirname = /* @__PURE__ */ getDirname();
3150
- const TRANSFORM_LOADER$1 = resolve(__dirname, "rspack/loaders/transform");
3151
- const LOAD_LOADER$1 = resolve(__dirname, "rspack/loaders/load");
3152
- function getRspackPlugin(factory) {
3153
- return (userOptions) => {
3154
- return { apply(compiler) {
3155
- const VIRTUAL_MODULE_PREFIX = resolve(compiler.options.context ?? process.cwd(), "node_modules/.virtual", compiler.rspack.experiments.VirtualModulesPlugin ? "" : process.pid.toString());
3156
- const meta = {
3157
- framework: "rspack",
3158
- rspack: { compiler }
3159
- };
3160
- const rawPlugins = toArray$2(factory(userOptions, meta));
3161
- for (const rawPlugin of rawPlugins) {
3162
- const plugin = Object.assign(rawPlugin, {
3163
- __unpluginMeta: meta,
3164
- __virtualModulePrefix: VIRTUAL_MODULE_PREFIX
3165
- });
3166
- const externalModules = /* @__PURE__ */ new Set();
3167
- if (plugin.resolveId) {
3168
- const createPlugin = (plugin$1) => {
3169
- if (compiler.rspack.experiments.VirtualModulesPlugin) return new compiler.rspack.experiments.VirtualModulesPlugin();
3170
- return new FakeVirtualModulesPlugin(plugin$1);
3171
- };
3172
- const vfs = createPlugin(plugin);
3173
- vfs.apply(compiler);
3174
- const vfsModules = /* @__PURE__ */ new Map();
3175
- plugin.__vfsModules = vfsModules;
3176
- plugin.__vfs = vfs;
3177
- compiler.hooks.compilation.tap(plugin.name, (compilation, { normalModuleFactory }) => {
3178
- normalModuleFactory.hooks.resolve.tapPromise(plugin.name, async (resolveData) => {
3179
- const id = normalizeAbsolutePath(resolveData.request);
3180
- const requestContext = resolveData.contextInfo;
3181
- let importer = requestContext.issuer !== "" ? requestContext.issuer : void 0;
3182
- const isEntry = requestContext.issuer === "";
3183
- if (importer?.startsWith(plugin.__virtualModulePrefix)) importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
3184
- const context = createBuildContext$1(compiler, compilation);
3185
- let error;
3186
- const pluginContext = {
3187
- error(msg) {
3188
- if (error == null) error = normalizeMessage$1(msg);
3189
- else console.error(`unplugin/rspack: multiple errors returned from resolveId hook: ${msg}`);
3190
- },
3191
- warn(msg) {
3192
- console.warn(`unplugin/rspack: warning from resolveId hook: ${msg}`);
3193
- }
3194
- };
3195
- const { handler, filter } = normalizeObjectHook("resolveId", plugin.resolveId);
3196
- if (!filter(id)) return;
3197
- const resolveIdResult = await handler.call({
3198
- ...context,
3199
- ...pluginContext
3200
- }, id, importer, { isEntry });
3201
- if (error != null) throw error;
3202
- if (resolveIdResult == null) return;
3203
- let resolved = typeof resolveIdResult === "string" ? resolveIdResult : resolveIdResult.id;
3204
- if (typeof resolveIdResult === "string" ? false : resolveIdResult.external === true) externalModules.add(resolved);
3205
- let isVirtual = true;
3206
- try {
3207
- (compiler.inputFileSystem?.statSync ?? fs.statSync)(resolved);
3208
- isVirtual = false;
3209
- } catch {
3210
- isVirtual = !isVirtualModuleId(resolved, plugin);
3211
- }
3212
- if (isVirtual) {
3213
- const encodedVirtualPath = encodeVirtualModuleId(resolved, plugin);
3214
- if (!vfsModules.has(resolved)) {
3215
- const fsPromise = Promise.resolve(vfs.writeModule(encodedVirtualPath, ""));
3216
- vfsModules.set(resolved, fsPromise);
3217
- await fsPromise;
3218
- } else await vfsModules.get(resolved);
3219
- resolved = encodedVirtualPath;
3220
- }
3221
- resolveData.request = resolved;
3222
- });
3223
- });
3224
- }
3225
- if (plugin.load) compiler.options.module.rules.unshift({
3226
- enforce: plugin.enforce,
3227
- include(id) {
3228
- if (isVirtualModuleId(id, plugin)) id = decodeVirtualModuleId(id, plugin);
3229
- if (plugin.loadInclude && !plugin.loadInclude(id)) return false;
3230
- const { filter } = normalizeObjectHook("load", plugin.load);
3231
- if (!filter(id)) return false;
3232
- return !externalModules.has(id);
3233
- },
3234
- use: [{
3235
- loader: LOAD_LOADER$1,
3236
- options: { plugin }
3237
- }],
3238
- type: "javascript/auto"
3239
- });
3240
- if (plugin.transform) compiler.options.module.rules.unshift({
3241
- enforce: plugin.enforce,
3242
- use(data) {
3243
- return transformUse(data, plugin, TRANSFORM_LOADER$1);
3244
- }
3245
- });
3246
- if (plugin.rspack) plugin.rspack(compiler);
3247
- if (plugin.watchChange || plugin.buildStart) compiler.hooks.make.tapPromise(plugin.name, async (compilation) => {
3248
- const context = createBuildContext$1(compiler, compilation);
3249
- if (plugin.watchChange && (compiler.modifiedFiles || compiler.removedFiles)) {
3250
- const promises$1 = [];
3251
- if (compiler.modifiedFiles) compiler.modifiedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
3252
- if (compiler.removedFiles) compiler.removedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "delete" }))));
3253
- await Promise.all(promises$1);
3254
- }
3255
- if (plugin.buildStart) return await plugin.buildStart.call(context);
3256
- });
3257
- if (plugin.buildEnd) compiler.hooks.emit.tapPromise(plugin.name, async (compilation) => {
3258
- await plugin.buildEnd.call(createBuildContext$1(compiler, compilation));
3259
- });
3260
- if (plugin.writeBundle) compiler.hooks.afterEmit.tapPromise(plugin.name, async () => {
3261
- await plugin.writeBundle();
3262
- });
3263
- }
3264
- } };
3265
- };
3266
- }
3267
- function getUnloaderPlugin(factory) {
3268
- return ((userOptions) => {
3269
- const plugins = toArray$2(factory(userOptions, { framework: "unloader" })).map((rawPlugin) => {
3270
- return toRollupPlugin(rawPlugin, "unloader");
3271
- });
3272
- return plugins.length === 1 ? plugins[0] : plugins;
3273
- });
3274
- }
3275
- function getVitePlugin(factory) {
3276
- return ((userOptions) => {
3277
- const plugins = toArray$2(factory(userOptions, { framework: "vite" })).map((rawPlugin) => {
3278
- return toRollupPlugin(rawPlugin, "vite");
3279
- });
3280
- return plugins.length === 1 ? plugins[0] : plugins;
3281
- });
3282
- }
3283
- const TRANSFORM_LOADER = resolve(__dirname, "webpack/loaders/transform");
3284
- const LOAD_LOADER = resolve(__dirname, "webpack/loaders/load");
3285
- function getWebpackPlugin(factory) {
3286
- return (userOptions) => {
3287
- return { apply(compiler) {
3288
- const VIRTUAL_MODULE_PREFIX = resolve(compiler.options.context ?? process$1.cwd(), "_virtual_");
3289
- const meta = {
3290
- framework: "webpack",
3291
- webpack: { compiler }
3292
- };
3293
- const rawPlugins = toArray$2(factory(userOptions, meta));
3294
- for (const rawPlugin of rawPlugins) {
3295
- const plugin = Object.assign(rawPlugin, {
3296
- __unpluginMeta: meta,
3297
- __virtualModulePrefix: VIRTUAL_MODULE_PREFIX
3298
- });
3299
- const externalModules = /* @__PURE__ */ new Set();
3300
- if (plugin.resolveId) {
3301
- let vfs = compiler.options.plugins.find((i) => i instanceof import_lib.default);
3302
- if (!vfs) {
3303
- vfs = new import_lib.default();
3304
- compiler.options.plugins.push(vfs);
3305
- }
3306
- const vfsModules = /* @__PURE__ */ new Set();
3307
- plugin.__vfsModules = vfsModules;
3308
- plugin.__vfs = vfs;
3309
- const resolverPlugin = { apply(resolver) {
3310
- const target = resolver.ensureHook("resolve");
3311
- resolver.getHook("resolve").tapAsync(plugin.name, async (request, resolveContext, callback) => {
3312
- if (!request.request) return callback();
3313
- if (normalizeAbsolutePath(request.request).startsWith(plugin.__virtualModulePrefix)) return callback();
3314
- const id = normalizeAbsolutePath(request.request);
3315
- const requestContext = request.context;
3316
- let importer = requestContext.issuer !== "" ? requestContext.issuer : void 0;
3317
- const isEntry = requestContext.issuer === "";
3318
- if (importer?.startsWith(plugin.__virtualModulePrefix)) importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
3319
- const fileDependencies = /* @__PURE__ */ new Set();
3320
- const context = createBuildContext({
3321
- addWatchFile(file) {
3322
- fileDependencies.add(file);
3323
- resolveContext.fileDependencies?.add(file);
3324
- },
3325
- getWatchFiles() {
3326
- return Array.from(fileDependencies);
3327
- }
3328
- }, compiler);
3329
- let error;
3330
- const pluginContext = {
3331
- error(msg) {
3332
- if (error == null) error = normalizeMessage(msg);
3333
- else console.error(`unplugin/webpack: multiple errors returned from resolveId hook: ${msg}`);
3334
- },
3335
- warn(msg) {
3336
- console.warn(`unplugin/webpack: warning from resolveId hook: ${msg}`);
3337
- }
3338
- };
3339
- const { handler, filter } = normalizeObjectHook("resolveId", plugin.resolveId);
3340
- if (!filter(id)) return callback();
3341
- const resolveIdResult = await handler.call({
3342
- ...context,
3343
- ...pluginContext
3344
- }, id, importer, { isEntry });
3345
- if (error != null) return callback(error);
3346
- if (resolveIdResult == null) return callback();
3347
- let resolved = typeof resolveIdResult === "string" ? resolveIdResult : resolveIdResult.id;
3348
- if (typeof resolveIdResult === "string" ? false : resolveIdResult.external === true) externalModules.add(resolved);
3349
- if (!fs.existsSync(resolved)) {
3350
- resolved = normalizeAbsolutePath(plugin.__virtualModulePrefix + encodeURIComponent(resolved));
3351
- if (!vfsModules.has(resolved)) {
3352
- plugin.__vfs.writeModule(resolved, "");
3353
- vfsModules.add(resolved);
3354
- }
3355
- }
3356
- const newRequest = {
3357
- ...request,
3358
- request: resolved
3359
- };
3360
- resolver.doResolve(target, newRequest, null, resolveContext, callback);
3361
- });
3362
- } };
3363
- compiler.options.resolve.plugins = compiler.options.resolve.plugins || [];
3364
- compiler.options.resolve.plugins.push(resolverPlugin);
3365
- }
3366
- if (plugin.load) compiler.options.module.rules.unshift({
3367
- include(id) {
3368
- return shouldLoad(id, plugin, externalModules);
3369
- },
3370
- enforce: plugin.enforce,
3371
- use: [{
3372
- loader: LOAD_LOADER,
3373
- options: { plugin }
3374
- }],
3375
- type: "javascript/auto"
3376
- });
3377
- if (plugin.transform) compiler.options.module.rules.unshift({
3378
- enforce: plugin.enforce,
3379
- use(data) {
3380
- return transformUse(data, plugin, TRANSFORM_LOADER);
3381
- }
3382
- });
3383
- if (plugin.webpack) plugin.webpack(compiler);
3384
- if (plugin.watchChange || plugin.buildStart) compiler.hooks.make.tapPromise(plugin.name, async (compilation) => {
3385
- const context = createBuildContext(contextOptionsFromCompilation(compilation), compiler, compilation);
3386
- if (plugin.watchChange && (compiler.modifiedFiles || compiler.removedFiles)) {
3387
- const promises$1 = [];
3388
- if (compiler.modifiedFiles) compiler.modifiedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
3389
- if (compiler.removedFiles) compiler.removedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "delete" }))));
3390
- await Promise.all(promises$1);
3391
- }
3392
- if (plugin.buildStart) return await plugin.buildStart.call(context);
3393
- });
3394
- if (plugin.buildEnd) compiler.hooks.emit.tapPromise(plugin.name, async (compilation) => {
3395
- await plugin.buildEnd.call(createBuildContext(contextOptionsFromCompilation(compilation), compiler, compilation));
3396
- });
3397
- if (plugin.writeBundle) compiler.hooks.afterEmit.tapPromise(plugin.name, async () => {
3398
- await plugin.writeBundle();
3399
- });
3400
- }
3401
- } };
3402
- };
3403
- }
3404
- function shouldLoad(id, plugin, externalModules) {
3405
- if (id.startsWith(plugin.__virtualModulePrefix)) id = decodeURIComponent(id.slice(plugin.__virtualModulePrefix.length));
3406
- if (plugin.loadInclude && !plugin.loadInclude(id)) return false;
3407
- const { filter } = normalizeObjectHook("load", plugin.load);
3408
- if (!filter(id)) return false;
3409
- return !externalModules.has(id);
3410
- }
3411
- function createUnplugin(factory) {
3412
- return {
3413
- get esbuild() {
3414
- return getEsbuildPlugin(factory);
3415
- },
3416
- get rollup() {
3417
- return getRollupPlugin(factory);
3418
- },
3419
- get vite() {
3420
- return getVitePlugin(factory);
3421
- },
3422
- get rolldown() {
3423
- return getRolldownPlugin(factory);
3424
- },
3425
- get webpack() {
3426
- return getWebpackPlugin(factory);
3427
- },
3428
- get rspack() {
3429
- return getRspackPlugin(factory);
3430
- },
3431
- get farm() {
3432
- return getFarmPlugin(factory);
3433
- },
3434
- get unloader() {
3435
- return getUnloaderPlugin(factory);
3436
- },
3437
- get raw() {
3438
- return factory;
3439
- }
3440
- };
3441
- }
3442
-
3443
- //#endregion
3444
- //#region node_modules/.pnpm/unplugin-utils@0.3.1/node_modules/unplugin-utils/dist/index.js
3445
- /**
3446
- * Converts path separators to forward slash.
3447
- */
3448
- function normalizePath(filename) {
3449
- return filename.replaceAll("\\", "/");
3450
- }
3451
- const isArray = Array.isArray;
3452
- function toArray$1(thing) {
3453
- if (isArray(thing)) return thing;
3454
- if (thing == null) return [];
3455
- return [thing];
3456
- }
3457
- const escapeMark = "[_#EsCaPe#_]";
3458
- function getMatcherString(id, resolutionBase) {
3459
- if (resolutionBase === false || isAbsolute$2(id) || id.startsWith("**")) return normalizePath(id);
3460
- return join$1(normalizePath(resolve$1(resolutionBase || "")).replaceAll(/[-^$*+?.()|[\]{}]/g, `${escapeMark}$&`), normalizePath(id)).replaceAll(escapeMark, "\\");
3461
- }
3462
- /**
3463
- * Constructs a filter function which can be used to determine whether or not
3464
- * certain modules should be operated upon.
3465
- * @param include If `include` is omitted or has zero length, filter will return `true` by default.
3466
- * @param exclude ID must not match any of the `exclude` patterns.
3467
- * @param options Additional options.
3468
- * @param options.resolve Optionally resolves the patterns against a directory other than `process.cwd()`.
3469
- * If a `string` is specified, then the value will be used as the base directory.
3470
- * Relative paths will be resolved against `process.cwd()` first.
3471
- * If `false`, then the patterns will not be resolved against any directory.
3472
- * This can be useful if you want to create a filter for virtual module names.
3473
- */
3474
- function createFilter(include, exclude, options) {
3475
- const resolutionBase = options && options.resolve;
3476
- const getMatcher = (id) => id instanceof RegExp ? id : { test: (what) => {
3477
- return (0, import_picomatch.default)(getMatcherString(id, resolutionBase), { dot: true })(what);
3478
- } };
3479
- const includeMatchers = toArray$1(include).map(getMatcher);
3480
- const excludeMatchers = toArray$1(exclude).map(getMatcher);
3481
- if (!includeMatchers.length && !excludeMatchers.length) return (id) => typeof id === "string" && !id.includes("\0");
3482
- return function result(id) {
3483
- if (typeof id !== "string") return false;
3484
- if (id.includes("\0")) return false;
3485
- const pathId = normalizePath(id);
3486
- for (const matcher of excludeMatchers) {
3487
- if (matcher instanceof RegExp) matcher.lastIndex = 0;
3488
- if (matcher.test(pathId)) return false;
3489
- }
3490
- for (const matcher of includeMatchers) {
3491
- if (matcher instanceof RegExp) matcher.lastIndex = 0;
3492
- if (matcher.test(pathId)) return true;
3493
- }
3494
- return !includeMatchers.length;
3495
- };
3496
- }
3497
-
3498
1965
  //#endregion
3499
1966
  //#region node_modules/.pnpm/unimport@5.6.0/node_modules/unimport/dist/unplugin.mjs
3500
1967
  var unplugin_exports = /* @__PURE__ */ __exportAll({