nitro-nightly 3.0.1-20260106-122901-e9c3a660 → 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.
- package/dist/_build/rolldown.mjs +11 -11
- package/dist/_build/rollup.mjs +19 -11
- package/dist/_build/shared.mjs +3 -2
- package/dist/_build/shared2.mjs +1 -1
- package/dist/_build/shared3.mjs +2 -2
- package/dist/_build/vite.build.mjs +8 -9
- package/dist/_dev.mjs +4 -3
- package/dist/_libs/@hiogawa/vite-plugin-fullstack.mjs +6 -1561
- package/dist/_libs/@jridgewell/gen-mapping.mjs +2 -304
- package/dist/_libs/@jridgewell/remapping.mjs +2 -1
- package/dist/_libs/@jridgewell/resolve-uri.mjs +166 -0
- package/dist/_libs/@jridgewell/sourcemap-codec.mjs +167 -0
- package/dist/_libs/@jridgewell/trace-mapping.mjs +141 -0
- package/dist/_libs/@rolldown/pluginutils.mjs +31 -0
- package/dist/_libs/@rollup/plugin-commonjs.mjs +33 -2636
- package/dist/_libs/@rollup/plugin-inject.mjs +3 -2
- package/dist/_libs/@rollup/plugin-json.mjs +1 -1
- package/dist/_libs/@rollup/plugin-node-resolve.mjs +8 -1112
- package/dist/_libs/@rollup/plugin-replace.mjs +2 -2
- package/dist/_libs/@rollup/pluginutils.mjs +241 -0
- package/dist/_libs/c12.mjs +63 -2513
- package/dist/_libs/chokidar.mjs +2 -235
- package/dist/_libs/commondir.mjs +22 -0
- package/dist/_libs/confbox.mjs +1511 -911
- package/dist/_libs/deepmerge.mjs +86 -0
- package/dist/_libs/dotenv.mjs +345 -0
- package/dist/_libs/estree-walker.mjs +144 -1
- package/dist/_libs/exsolve.mjs +1007 -0
- package/dist/_libs/fdir.mjs +514 -0
- package/dist/_libs/function-bind.mjs +63 -0
- package/dist/_libs/giget.mjs +1380 -2238
- package/dist/_libs/hasown.mjs +14 -0
- package/dist/_libs/is-core-module.mjs +220 -0
- package/dist/_libs/is-module.mjs +13 -0
- package/dist/_libs/is-reference.mjs +33 -0
- package/dist/_libs/js-tokens.mjs +382 -0
- package/dist/_libs/local-pkg.mjs +7 -1561
- package/dist/_libs/magic-string.mjs +939 -0
- package/dist/_libs/mlly.mjs +1415 -0
- package/dist/_libs/node-fetch-native.mjs +7 -0
- package/dist/_libs/nypm.mjs +239 -0
- package/dist/_libs/path-parse.mjs +47 -0
- package/dist/_libs/pathe.mjs +163 -2
- package/dist/_libs/perfect-debounce.mjs +89 -0
- package/dist/_libs/picomatch.mjs +1673 -0
- package/dist/_libs/pkg-types.mjs +197 -0
- package/dist/_libs/quansync.mjs +90 -0
- package/dist/_libs/rc9.mjs +136 -0
- package/dist/_libs/readdirp.mjs +237 -0
- package/dist/_libs/resolve.mjs +689 -0
- package/dist/_libs/strip-literal.mjs +51 -0
- package/dist/_libs/tinyexec.mjs +627 -0
- package/dist/_libs/tinyglobby.mjs +2 -1
- package/dist/_libs/tsconfck.mjs +1 -1
- package/dist/_libs/unimport.mjs +93 -1617
- package/dist/_libs/unplugin-utils.mjs +61 -0
- package/dist/_libs/unplugin.mjs +1225 -0
- package/dist/_libs/unwasm.mjs +3 -2
- package/dist/_libs/webpack-virtual-modules.mjs +272 -0
- package/dist/_nitro.mjs +9 -7
- package/dist/_nitro2.mjs +6 -7
- package/dist/_presets.mjs +9 -7
- package/dist/builder.mjs +5 -5
- package/dist/cli/_chunks/build.mjs +1 -1
- package/dist/cli/_chunks/dev.mjs +1 -1
- package/dist/cli/_chunks/list.mjs +1 -1
- package/dist/cli/_chunks/prepare.mjs +1 -1
- package/dist/cli/_chunks/run.mjs +1 -1
- package/dist/vite.mjs +1825 -22
- package/package.json +2 -2
- package/dist/_build/shared4.mjs +0 -1112
- package/dist/_build/vite.plugin.mjs +0 -712
package/dist/_libs/unimport.mjs
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import { i as __toESM, n as __exportAll
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
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";
|
|
6
|
-
import { c 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";
|
|
7
5
|
import { t as glob } from "./tinyglobby.mjs";
|
|
8
|
-
import {
|
|
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";
|
|
9
11
|
import { t as walk } from "./estree-walker.mjs";
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { camelCase, kebabCase } from "scule";
|
|
14
|
-
import fs, { accessSync, constants, existsSync, promises, readFileSync } from "node:fs";
|
|
15
|
-
import { fileURLToPath } from "node:url";
|
|
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";
|
|
16
15
|
import { readFile } from "node:fs/promises";
|
|
16
|
+
import { fileURLToPath } from "node:url";
|
|
17
17
|
import os from "node:os";
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
18
|
+
import { basename } from "node:path";
|
|
19
|
+
import process$1 from "node:process";
|
|
20
|
+
import { camelCase, kebabCase } from "scule";
|
|
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$
|
|
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
|
|
173
|
-
if (!module
|
|
174
|
-
module
|
|
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
|
|
179
|
+
modulesMap.set(from, module);
|
|
179
180
|
}
|
|
180
181
|
if (import_.name === "*") {
|
|
181
|
-
if (import_.as) module
|
|
182
|
-
} else module
|
|
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
|
|
191
|
+
${Array.from(importsMap).flatMap(([from, module]) => {
|
|
191
192
|
from = from.replace(/\.d\.([cm]?)ts$/i, ".$1js");
|
|
192
|
-
const { starTypeImport, typeImports } = module
|
|
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$
|
|
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
|
|
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
|
|
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) {
|
|
@@ -558,7 +559,7 @@ function parseVirtualImportsRegex(strippedCode, importMap, virtualImports) {
|
|
|
558
559
|
};
|
|
559
560
|
}
|
|
560
561
|
async function detectImports(code, ctx, options) {
|
|
561
|
-
if (options?.parser === "acorn") return import("./unimport.mjs").then((n) => n.
|
|
562
|
+
if (options?.parser === "acorn") return import("./unimport.mjs").then((n) => n.s).then((r) => r.detectImportsAcorn(code, ctx, options));
|
|
562
563
|
return detectImportsRegex(code, ctx, options);
|
|
563
564
|
}
|
|
564
565
|
const FileExtensionLookup = [
|
|
@@ -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
|
|
587
|
-
const glob2 = resolveGlobsExclude(isString
|
|
588
|
-
const types = isString
|
|
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$
|
|
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$
|
|
617
|
-
else acc[index] = [normalize$
|
|
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
|
|
629
|
-
return exports
|
|
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
|
|
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
|
|
644
|
-
if (exports
|
|
645
|
-
let name = parse
|
|
646
|
-
if (name === "index") name = parse
|
|
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$
|
|
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
|
|
715
|
+
await toImport(exports, { type: true });
|
|
715
716
|
await toImport(findTypeExports(code), { type: true });
|
|
716
717
|
}
|
|
717
718
|
} else {
|
|
718
|
-
await toImport(exports
|
|
719
|
+
await toImport(exports);
|
|
719
720
|
if (includeTypes) await toImport(findTypeExports(code), { type: true });
|
|
720
721
|
}
|
|
721
722
|
return imports;
|
|
@@ -1768,1577 +1769,8 @@ async function resolveImports(ctx, imports, id) {
|
|
|
1768
1769
|
}
|
|
1769
1770
|
|
|
1770
1771
|
//#endregion
|
|
1771
|
-
//#region node_modules/.pnpm/
|
|
1772
|
-
|
|
1773
|
-
array = array || [];
|
|
1774
|
-
if (Array.isArray(array)) return array;
|
|
1775
|
-
return [array];
|
|
1776
|
-
}
|
|
1777
|
-
const BACKSLASH_REGEX = /\\/g;
|
|
1778
|
-
function normalize$1(path$1) {
|
|
1779
|
-
return path$1.replace(BACKSLASH_REGEX, "/");
|
|
1780
|
-
}
|
|
1781
|
-
const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Z]:)?[/\\|])/i;
|
|
1782
|
-
function isAbsolute$1(path$1) {
|
|
1783
|
-
return ABSOLUTE_PATH_REGEX.test(path$1);
|
|
1784
|
-
}
|
|
1785
|
-
function getMatcherString$1(glob$1, cwd$1) {
|
|
1786
|
-
if (glob$1.startsWith("**") || isAbsolute$1(glob$1)) return normalize$1(glob$1);
|
|
1787
|
-
return normalize$1(resolve(cwd$1, glob$1));
|
|
1788
|
-
}
|
|
1789
|
-
function patternToIdFilter(pattern) {
|
|
1790
|
-
if (pattern instanceof RegExp) return (id) => {
|
|
1791
|
-
const normalizedId = normalize$1(id);
|
|
1792
|
-
const result = pattern.test(normalizedId);
|
|
1793
|
-
pattern.lastIndex = 0;
|
|
1794
|
-
return result;
|
|
1795
|
-
};
|
|
1796
|
-
const matcher = (0, import_picomatch.default)(getMatcherString$1(pattern, process.cwd()), { dot: true });
|
|
1797
|
-
return (id) => {
|
|
1798
|
-
return matcher(normalize$1(id));
|
|
1799
|
-
};
|
|
1800
|
-
}
|
|
1801
|
-
function patternToCodeFilter(pattern) {
|
|
1802
|
-
if (pattern instanceof RegExp) return (code) => {
|
|
1803
|
-
const result = pattern.test(code);
|
|
1804
|
-
pattern.lastIndex = 0;
|
|
1805
|
-
return result;
|
|
1806
|
-
};
|
|
1807
|
-
return (code) => code.includes(pattern);
|
|
1808
|
-
}
|
|
1809
|
-
function createFilter$1(exclude, include) {
|
|
1810
|
-
if (!exclude && !include) return;
|
|
1811
|
-
return (input) => {
|
|
1812
|
-
if (exclude?.some((filter) => filter(input))) return false;
|
|
1813
|
-
if (include?.some((filter) => filter(input))) return true;
|
|
1814
|
-
return !(include && include.length > 0);
|
|
1815
|
-
};
|
|
1816
|
-
}
|
|
1817
|
-
function normalizeFilter(filter) {
|
|
1818
|
-
if (typeof filter === "string" || filter instanceof RegExp) return { include: [filter] };
|
|
1819
|
-
if (Array.isArray(filter)) return { include: filter };
|
|
1820
|
-
return {
|
|
1821
|
-
exclude: filter.exclude ? toArray$2(filter.exclude) : void 0,
|
|
1822
|
-
include: filter.include ? toArray$2(filter.include) : void 0
|
|
1823
|
-
};
|
|
1824
|
-
}
|
|
1825
|
-
function createIdFilter(filter) {
|
|
1826
|
-
if (!filter) return;
|
|
1827
|
-
const { exclude, include } = normalizeFilter(filter);
|
|
1828
|
-
const excludeFilter = exclude?.map(patternToIdFilter);
|
|
1829
|
-
const includeFilter = include?.map(patternToIdFilter);
|
|
1830
|
-
return createFilter$1(excludeFilter, includeFilter);
|
|
1831
|
-
}
|
|
1832
|
-
function createCodeFilter(filter) {
|
|
1833
|
-
if (!filter) return;
|
|
1834
|
-
const { exclude, include } = normalizeFilter(filter);
|
|
1835
|
-
const excludeFilter = exclude?.map(patternToCodeFilter);
|
|
1836
|
-
const includeFilter = include?.map(patternToCodeFilter);
|
|
1837
|
-
return createFilter$1(excludeFilter, includeFilter);
|
|
1838
|
-
}
|
|
1839
|
-
function createFilterForId(filter) {
|
|
1840
|
-
const filterFunction = createIdFilter(filter);
|
|
1841
|
-
return filterFunction ? (id) => !!filterFunction(id) : void 0;
|
|
1842
|
-
}
|
|
1843
|
-
function createFilterForTransform(idFilter, codeFilter) {
|
|
1844
|
-
if (!idFilter && !codeFilter) return;
|
|
1845
|
-
const idFilterFunction = createIdFilter(idFilter);
|
|
1846
|
-
const codeFilterFunction = createCodeFilter(codeFilter);
|
|
1847
|
-
return (id, code) => {
|
|
1848
|
-
let fallback = true;
|
|
1849
|
-
if (idFilterFunction) fallback &&= idFilterFunction(id);
|
|
1850
|
-
if (!fallback) return false;
|
|
1851
|
-
if (codeFilterFunction) fallback &&= codeFilterFunction(code);
|
|
1852
|
-
return fallback;
|
|
1853
|
-
};
|
|
1854
|
-
}
|
|
1855
|
-
function normalizeObjectHook(name, hook) {
|
|
1856
|
-
let handler;
|
|
1857
|
-
let filter;
|
|
1858
|
-
if (typeof hook === "function") handler = hook;
|
|
1859
|
-
else {
|
|
1860
|
-
handler = hook.handler;
|
|
1861
|
-
const hookFilter = hook.filter;
|
|
1862
|
-
if (name === "resolveId" || name === "load") filter = createFilterForId(hookFilter?.id);
|
|
1863
|
-
else filter = createFilterForTransform(hookFilter?.id, hookFilter?.code);
|
|
1864
|
-
}
|
|
1865
|
-
return {
|
|
1866
|
-
handler,
|
|
1867
|
-
filter: filter || (() => true)
|
|
1868
|
-
};
|
|
1869
|
-
}
|
|
1870
|
-
function parse(code, opts = {}) {
|
|
1871
|
-
return Parser.parse(code, {
|
|
1872
|
-
sourceType: "module",
|
|
1873
|
-
ecmaVersion: "latest",
|
|
1874
|
-
locations: true,
|
|
1875
|
-
...opts
|
|
1876
|
-
});
|
|
1877
|
-
}
|
|
1878
|
-
|
|
1879
|
-
//#endregion
|
|
1880
|
-
//#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/webpack-like-DFGTNSuV.js
|
|
1881
|
-
function transformUse(data, plugin, transformLoader) {
|
|
1882
|
-
if (data.resource == null) return [];
|
|
1883
|
-
const id = normalizeAbsolutePath(data.resource + (data.resourceQuery || ""));
|
|
1884
|
-
if (plugin.transformInclude && !plugin.transformInclude(id)) return [];
|
|
1885
|
-
const { filter } = normalizeObjectHook("load", plugin.transform);
|
|
1886
|
-
if (!filter(id)) return [];
|
|
1887
|
-
return [{
|
|
1888
|
-
loader: transformLoader,
|
|
1889
|
-
options: { plugin },
|
|
1890
|
-
ident: plugin.name
|
|
1891
|
-
}];
|
|
1892
|
-
}
|
|
1893
|
-
/**
|
|
1894
|
-
* Normalizes a given path when it's absolute. Normalizing means returning a new path by converting
|
|
1895
|
-
* the input path to the native os format. This is useful in cases where we want to normalize
|
|
1896
|
-
* the `id` argument of a hook. Any absolute ids should be in the default format
|
|
1897
|
-
* of the operating system. Any relative imports or node_module imports should remain
|
|
1898
|
-
* untouched.
|
|
1899
|
-
*
|
|
1900
|
-
* @param path - Path to normalize.
|
|
1901
|
-
* @returns a new normalized path.
|
|
1902
|
-
*/
|
|
1903
|
-
function normalizeAbsolutePath(path$1) {
|
|
1904
|
-
if (isAbsolute(path$1)) return normalize(path$1);
|
|
1905
|
-
else return path$1;
|
|
1906
|
-
}
|
|
1907
|
-
|
|
1908
|
-
//#endregion
|
|
1909
|
-
//#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/context-DkYlx1xL.js
|
|
1910
|
-
function createBuildContext$1(compiler, compilation, loaderContext, inputSourceMap) {
|
|
1911
|
-
return {
|
|
1912
|
-
getNativeBuildContext() {
|
|
1913
|
-
return {
|
|
1914
|
-
framework: "rspack",
|
|
1915
|
-
compiler,
|
|
1916
|
-
compilation,
|
|
1917
|
-
loaderContext,
|
|
1918
|
-
inputSourceMap
|
|
1919
|
-
};
|
|
1920
|
-
},
|
|
1921
|
-
addWatchFile(file) {
|
|
1922
|
-
const cwd$1 = process.cwd();
|
|
1923
|
-
compilation.fileDependencies.add(resolve(cwd$1, file));
|
|
1924
|
-
},
|
|
1925
|
-
getWatchFiles() {
|
|
1926
|
-
return Array.from(compilation.fileDependencies);
|
|
1927
|
-
},
|
|
1928
|
-
parse,
|
|
1929
|
-
emitFile(emittedFile) {
|
|
1930
|
-
const outFileName = emittedFile.fileName || emittedFile.name;
|
|
1931
|
-
if (emittedFile.source && outFileName) {
|
|
1932
|
-
const { sources } = compilation.compiler.webpack;
|
|
1933
|
-
compilation.emitAsset(outFileName, new sources.RawSource(typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)));
|
|
1934
|
-
}
|
|
1935
|
-
}
|
|
1936
|
-
};
|
|
1937
|
-
}
|
|
1938
|
-
function normalizeMessage$1(error) {
|
|
1939
|
-
const err = new Error(typeof error === "string" ? error : error.message);
|
|
1940
|
-
if (typeof error === "object") {
|
|
1941
|
-
err.stack = error.stack;
|
|
1942
|
-
err.cause = error.meta;
|
|
1943
|
-
}
|
|
1944
|
-
return err;
|
|
1945
|
-
}
|
|
1946
|
-
|
|
1947
|
-
//#endregion
|
|
1948
|
-
//#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/utils-BosfZ0pB.js
|
|
1949
|
-
function encodeVirtualModuleId(id, plugin) {
|
|
1950
|
-
return resolve(plugin.__virtualModulePrefix, encodeURIComponent(id));
|
|
1951
|
-
}
|
|
1952
|
-
function decodeVirtualModuleId(encoded, _plugin) {
|
|
1953
|
-
return decodeURIComponent(basename(encoded));
|
|
1954
|
-
}
|
|
1955
|
-
function isVirtualModuleId(encoded, plugin) {
|
|
1956
|
-
return dirname(encoded) === plugin.__virtualModulePrefix;
|
|
1957
|
-
}
|
|
1958
|
-
var FakeVirtualModulesPlugin = class FakeVirtualModulesPlugin$1 {
|
|
1959
|
-
name = "FakeVirtualModulesPlugin";
|
|
1960
|
-
static counters = /* @__PURE__ */ new Map();
|
|
1961
|
-
static initCleanup = false;
|
|
1962
|
-
constructor(plugin) {
|
|
1963
|
-
this.plugin = plugin;
|
|
1964
|
-
if (!FakeVirtualModulesPlugin$1.initCleanup) {
|
|
1965
|
-
FakeVirtualModulesPlugin$1.initCleanup = true;
|
|
1966
|
-
process.once("exit", () => {
|
|
1967
|
-
FakeVirtualModulesPlugin$1.counters.forEach((_, dir) => {
|
|
1968
|
-
fs.rmSync(dir, {
|
|
1969
|
-
recursive: true,
|
|
1970
|
-
force: true
|
|
1971
|
-
});
|
|
1972
|
-
});
|
|
1973
|
-
});
|
|
1974
|
-
}
|
|
1975
|
-
}
|
|
1976
|
-
apply(compiler) {
|
|
1977
|
-
const dir = this.plugin.__virtualModulePrefix;
|
|
1978
|
-
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
1979
|
-
const counter = FakeVirtualModulesPlugin$1.counters.get(dir) ?? 0;
|
|
1980
|
-
FakeVirtualModulesPlugin$1.counters.set(dir, counter + 1);
|
|
1981
|
-
compiler.hooks.shutdown.tap(this.name, () => {
|
|
1982
|
-
const counter$1 = (FakeVirtualModulesPlugin$1.counters.get(dir) ?? 1) - 1;
|
|
1983
|
-
if (counter$1 === 0) {
|
|
1984
|
-
FakeVirtualModulesPlugin$1.counters.delete(dir);
|
|
1985
|
-
fs.rmSync(dir, {
|
|
1986
|
-
recursive: true,
|
|
1987
|
-
force: true
|
|
1988
|
-
});
|
|
1989
|
-
} else FakeVirtualModulesPlugin$1.counters.set(dir, counter$1);
|
|
1990
|
-
});
|
|
1991
|
-
}
|
|
1992
|
-
async writeModule(file) {
|
|
1993
|
-
return fs.promises.writeFile(file, "");
|
|
1994
|
-
}
|
|
1995
|
-
};
|
|
1996
|
-
|
|
1997
|
-
//#endregion
|
|
1998
|
-
//#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/context-OCFO8EW1.js
|
|
1999
|
-
function contextOptionsFromCompilation(compilation) {
|
|
2000
|
-
return {
|
|
2001
|
-
addWatchFile(file) {
|
|
2002
|
-
(compilation.fileDependencies ?? compilation.compilationDependencies).add(file);
|
|
2003
|
-
},
|
|
2004
|
-
getWatchFiles() {
|
|
2005
|
-
return Array.from(compilation.fileDependencies ?? compilation.compilationDependencies);
|
|
2006
|
-
}
|
|
2007
|
-
};
|
|
2008
|
-
}
|
|
2009
|
-
const require$1 = createRequire(import.meta.url);
|
|
2010
|
-
function getSource(fileSource) {
|
|
2011
|
-
return new (require$1("webpack")).sources.RawSource(typeof fileSource === "string" ? fileSource : Buffer.from(fileSource.buffer));
|
|
2012
|
-
}
|
|
2013
|
-
function createBuildContext(options, compiler, compilation, loaderContext, inputSourceMap) {
|
|
2014
|
-
return {
|
|
2015
|
-
parse,
|
|
2016
|
-
addWatchFile(id) {
|
|
2017
|
-
options.addWatchFile(resolve(process$1.cwd(), id));
|
|
2018
|
-
},
|
|
2019
|
-
emitFile(emittedFile) {
|
|
2020
|
-
const outFileName = emittedFile.fileName || emittedFile.name;
|
|
2021
|
-
if (emittedFile.source && outFileName) {
|
|
2022
|
-
if (!compilation) throw new Error("unplugin/webpack: emitFile outside supported hooks (buildStart, buildEnd, load, transform, watchChange)");
|
|
2023
|
-
compilation.emitAsset(outFileName, getSource(emittedFile.source));
|
|
2024
|
-
}
|
|
2025
|
-
},
|
|
2026
|
-
getWatchFiles() {
|
|
2027
|
-
return options.getWatchFiles();
|
|
2028
|
-
},
|
|
2029
|
-
getNativeBuildContext() {
|
|
2030
|
-
return {
|
|
2031
|
-
framework: "webpack",
|
|
2032
|
-
compiler,
|
|
2033
|
-
compilation,
|
|
2034
|
-
loaderContext,
|
|
2035
|
-
inputSourceMap
|
|
2036
|
-
};
|
|
2037
|
-
}
|
|
2038
|
-
};
|
|
2039
|
-
}
|
|
2040
|
-
function normalizeMessage(error) {
|
|
2041
|
-
const err = new Error(typeof error === "string" ? error : error.message);
|
|
2042
|
-
if (typeof error === "object") {
|
|
2043
|
-
err.stack = error.stack;
|
|
2044
|
-
err.cause = error.meta;
|
|
2045
|
-
}
|
|
2046
|
-
return err;
|
|
2047
|
-
}
|
|
2048
|
-
|
|
2049
|
-
//#endregion
|
|
2050
|
-
//#region node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/virtual-stats.js
|
|
2051
|
-
var require_virtual_stats = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2052
|
-
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
2053
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
2054
|
-
};
|
|
2055
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2056
|
-
exports.VirtualStats = void 0;
|
|
2057
|
-
const constants_1 = __importDefault(__require("constants"));
|
|
2058
|
-
var VirtualStats = class {
|
|
2059
|
-
constructor(config) {
|
|
2060
|
-
for (const key in config) {
|
|
2061
|
-
if (!Object.prototype.hasOwnProperty.call(config, key)) continue;
|
|
2062
|
-
this[key] = config[key];
|
|
2063
|
-
}
|
|
2064
|
-
}
|
|
2065
|
-
_checkModeProperty(property) {
|
|
2066
|
-
return (this.mode & constants_1.default.S_IFMT) === property;
|
|
2067
|
-
}
|
|
2068
|
-
isDirectory() {
|
|
2069
|
-
return this._checkModeProperty(constants_1.default.S_IFDIR);
|
|
2070
|
-
}
|
|
2071
|
-
isFile() {
|
|
2072
|
-
return this._checkModeProperty(constants_1.default.S_IFREG);
|
|
2073
|
-
}
|
|
2074
|
-
isBlockDevice() {
|
|
2075
|
-
return this._checkModeProperty(constants_1.default.S_IFBLK);
|
|
2076
|
-
}
|
|
2077
|
-
isCharacterDevice() {
|
|
2078
|
-
return this._checkModeProperty(constants_1.default.S_IFCHR);
|
|
2079
|
-
}
|
|
2080
|
-
isSymbolicLink() {
|
|
2081
|
-
return this._checkModeProperty(constants_1.default.S_IFLNK);
|
|
2082
|
-
}
|
|
2083
|
-
isFIFO() {
|
|
2084
|
-
return this._checkModeProperty(constants_1.default.S_IFIFO);
|
|
2085
|
-
}
|
|
2086
|
-
isSocket() {
|
|
2087
|
-
return this._checkModeProperty(constants_1.default.S_IFSOCK);
|
|
2088
|
-
}
|
|
2089
|
-
};
|
|
2090
|
-
exports.VirtualStats = VirtualStats;
|
|
2091
|
-
}));
|
|
2092
|
-
|
|
2093
|
-
//#endregion
|
|
2094
|
-
//#region node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/index.js
|
|
2095
|
-
var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2096
|
-
const path_1 = (exports && exports.__importDefault || function(mod) {
|
|
2097
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
2098
|
-
})(__require("path"));
|
|
2099
|
-
const virtual_stats_1 = require_virtual_stats();
|
|
2100
|
-
let inode = 45e6;
|
|
2101
|
-
const ALL = "all";
|
|
2102
|
-
const STATIC = "static";
|
|
2103
|
-
const DYNAMIC = "dynamic";
|
|
2104
|
-
function checkActivation(instance) {
|
|
2105
|
-
if (!instance._compiler) throw new Error("You must use this plugin only after creating webpack instance!");
|
|
2106
|
-
}
|
|
2107
|
-
function getModulePath(filePath, compiler) {
|
|
2108
|
-
return path_1.default.isAbsolute(filePath) ? filePath : path_1.default.join(compiler.context, filePath);
|
|
2109
|
-
}
|
|
2110
|
-
function createWebpackData(result) {
|
|
2111
|
-
return (backendOrStorage) => {
|
|
2112
|
-
if (backendOrStorage._data) {
|
|
2113
|
-
const curLevelIdx = backendOrStorage._currentLevel;
|
|
2114
|
-
return {
|
|
2115
|
-
result,
|
|
2116
|
-
level: backendOrStorage._levels[curLevelIdx]
|
|
2117
|
-
};
|
|
2118
|
-
}
|
|
2119
|
-
return [null, result];
|
|
2120
|
-
};
|
|
2121
|
-
}
|
|
2122
|
-
function getData(storage, key) {
|
|
2123
|
-
if (storage._data instanceof Map) return storage._data.get(key);
|
|
2124
|
-
else if (storage._data) return storage.data[key];
|
|
2125
|
-
else if (storage.data instanceof Map) return storage.data.get(key);
|
|
2126
|
-
else return storage.data[key];
|
|
2127
|
-
}
|
|
2128
|
-
function setData(backendOrStorage, key, valueFactory) {
|
|
2129
|
-
const value = valueFactory(backendOrStorage);
|
|
2130
|
-
if (backendOrStorage._data instanceof Map) backendOrStorage._data.set(key, value);
|
|
2131
|
-
else if (backendOrStorage._data) backendOrStorage.data[key] = value;
|
|
2132
|
-
else if (backendOrStorage.data instanceof Map) backendOrStorage.data.set(key, value);
|
|
2133
|
-
else backendOrStorage.data[key] = value;
|
|
2134
|
-
}
|
|
2135
|
-
function getStatStorage(fileSystem) {
|
|
2136
|
-
if (fileSystem._statStorage) return fileSystem._statStorage;
|
|
2137
|
-
else if (fileSystem._statBackend) return fileSystem._statBackend;
|
|
2138
|
-
else throw new Error("Couldn't find a stat storage");
|
|
2139
|
-
}
|
|
2140
|
-
function getFileStorage(fileSystem) {
|
|
2141
|
-
if (fileSystem._readFileStorage) return fileSystem._readFileStorage;
|
|
2142
|
-
else if (fileSystem._readFileBackend) return fileSystem._readFileBackend;
|
|
2143
|
-
else throw new Error("Couldn't find a readFileStorage");
|
|
2144
|
-
}
|
|
2145
|
-
function getReadDirBackend(fileSystem) {
|
|
2146
|
-
if (fileSystem._readdirBackend) return fileSystem._readdirBackend;
|
|
2147
|
-
else if (fileSystem._readdirStorage) return fileSystem._readdirStorage;
|
|
2148
|
-
else throw new Error("Couldn't find a readDirStorage from Webpack Internals");
|
|
2149
|
-
}
|
|
2150
|
-
function getRealpathBackend(fileSystem) {
|
|
2151
|
-
if (fileSystem._realpathBackend) return fileSystem._realpathBackend;
|
|
2152
|
-
}
|
|
2153
|
-
var VirtualModulesPlugin = class {
|
|
2154
|
-
constructor(modules) {
|
|
2155
|
-
this._compiler = null;
|
|
2156
|
-
this._watcher = null;
|
|
2157
|
-
this._staticModules = modules || null;
|
|
2158
|
-
}
|
|
2159
|
-
getModuleList(filter = ALL) {
|
|
2160
|
-
var _a, _b;
|
|
2161
|
-
let modules = {};
|
|
2162
|
-
const shouldGetStaticModules = filter === ALL || filter === STATIC;
|
|
2163
|
-
const shouldGetDynamicModules = filter === ALL || filter === DYNAMIC;
|
|
2164
|
-
if (shouldGetStaticModules) modules = Object.assign(Object.assign({}, modules), this._staticModules);
|
|
2165
|
-
if (shouldGetDynamicModules) {
|
|
2166
|
-
const finalInputFileSystem = (_a = this._compiler) === null || _a === void 0 ? void 0 : _a.inputFileSystem;
|
|
2167
|
-
const virtualFiles = (_b = finalInputFileSystem === null || finalInputFileSystem === void 0 ? void 0 : finalInputFileSystem._virtualFiles) !== null && _b !== void 0 ? _b : {};
|
|
2168
|
-
const dynamicModules = {};
|
|
2169
|
-
Object.keys(virtualFiles).forEach((key) => {
|
|
2170
|
-
dynamicModules[key] = virtualFiles[key].contents;
|
|
2171
|
-
});
|
|
2172
|
-
modules = Object.assign(Object.assign({}, modules), dynamicModules);
|
|
2173
|
-
}
|
|
2174
|
-
return modules;
|
|
2175
|
-
}
|
|
2176
|
-
writeModule(filePath, contents) {
|
|
2177
|
-
if (!this._compiler) throw new Error(`Plugin has not been initialized`);
|
|
2178
|
-
checkActivation(this);
|
|
2179
|
-
const len = contents ? contents.length : 0;
|
|
2180
|
-
const time = Date.now();
|
|
2181
|
-
const date = new Date(time);
|
|
2182
|
-
const stats = new virtual_stats_1.VirtualStats({
|
|
2183
|
-
dev: 8675309,
|
|
2184
|
-
nlink: 0,
|
|
2185
|
-
uid: 1e3,
|
|
2186
|
-
gid: 1e3,
|
|
2187
|
-
rdev: 0,
|
|
2188
|
-
blksize: 4096,
|
|
2189
|
-
ino: inode++,
|
|
2190
|
-
mode: 33188,
|
|
2191
|
-
size: len,
|
|
2192
|
-
blocks: Math.floor(len / 4096),
|
|
2193
|
-
atime: date,
|
|
2194
|
-
mtime: date,
|
|
2195
|
-
ctime: date,
|
|
2196
|
-
birthtime: date
|
|
2197
|
-
});
|
|
2198
|
-
const modulePath = getModulePath(filePath, this._compiler);
|
|
2199
|
-
if (process.env.WVM_DEBUG) console.log(this._compiler.name, "Write virtual module:", modulePath, contents);
|
|
2200
|
-
let finalWatchFileSystem = this._watcher && this._watcher.watchFileSystem;
|
|
2201
|
-
while (finalWatchFileSystem && finalWatchFileSystem.wfs) finalWatchFileSystem = finalWatchFileSystem.wfs;
|
|
2202
|
-
let finalInputFileSystem = this._compiler.inputFileSystem;
|
|
2203
|
-
while (finalInputFileSystem && finalInputFileSystem._inputFileSystem) finalInputFileSystem = finalInputFileSystem._inputFileSystem;
|
|
2204
|
-
finalInputFileSystem._writeVirtualFile(modulePath, stats, contents);
|
|
2205
|
-
if (finalWatchFileSystem && finalWatchFileSystem.watcher && (finalWatchFileSystem.watcher.fileWatchers.size || finalWatchFileSystem.watcher.fileWatchers.length)) {
|
|
2206
|
-
const fileWatchers = finalWatchFileSystem.watcher.fileWatchers instanceof Map ? Array.from(finalWatchFileSystem.watcher.fileWatchers.values()) : finalWatchFileSystem.watcher.fileWatchers;
|
|
2207
|
-
for (let fileWatcher of fileWatchers) {
|
|
2208
|
-
if ("watcher" in fileWatcher) fileWatcher = fileWatcher.watcher;
|
|
2209
|
-
if (fileWatcher.path === modulePath) {
|
|
2210
|
-
if (process.env.DEBUG) console.log(this._compiler.name, "Emit file change:", modulePath, time);
|
|
2211
|
-
delete fileWatcher.directoryWatcher._cachedTimeInfoEntries;
|
|
2212
|
-
fileWatcher.emit("change", time, null);
|
|
2213
|
-
}
|
|
2214
|
-
}
|
|
2215
|
-
}
|
|
2216
|
-
}
|
|
2217
|
-
apply(compiler) {
|
|
2218
|
-
this._compiler = compiler;
|
|
2219
|
-
const afterEnvironmentHook = () => {
|
|
2220
|
-
let finalInputFileSystem = compiler.inputFileSystem;
|
|
2221
|
-
while (finalInputFileSystem && finalInputFileSystem._inputFileSystem) finalInputFileSystem = finalInputFileSystem._inputFileSystem;
|
|
2222
|
-
if (!finalInputFileSystem._writeVirtualFile) {
|
|
2223
|
-
const originalPurge = finalInputFileSystem.purge;
|
|
2224
|
-
finalInputFileSystem.purge = () => {
|
|
2225
|
-
originalPurge.apply(finalInputFileSystem, []);
|
|
2226
|
-
if (finalInputFileSystem._virtualFiles) Object.keys(finalInputFileSystem._virtualFiles).forEach((file) => {
|
|
2227
|
-
const data = finalInputFileSystem._virtualFiles[file];
|
|
2228
|
-
finalInputFileSystem._writeVirtualFile(file, data.stats, data.contents);
|
|
2229
|
-
});
|
|
2230
|
-
};
|
|
2231
|
-
finalInputFileSystem._writeVirtualFile = (file, stats, contents) => {
|
|
2232
|
-
const statStorage = getStatStorage(finalInputFileSystem);
|
|
2233
|
-
const fileStorage = getFileStorage(finalInputFileSystem);
|
|
2234
|
-
const readDirStorage = getReadDirBackend(finalInputFileSystem);
|
|
2235
|
-
const realPathStorage = getRealpathBackend(finalInputFileSystem);
|
|
2236
|
-
finalInputFileSystem._virtualFiles = finalInputFileSystem._virtualFiles || {};
|
|
2237
|
-
finalInputFileSystem._virtualFiles[file] = {
|
|
2238
|
-
stats,
|
|
2239
|
-
contents
|
|
2240
|
-
};
|
|
2241
|
-
setData(statStorage, file, createWebpackData(stats));
|
|
2242
|
-
setData(fileStorage, file, createWebpackData(contents));
|
|
2243
|
-
const segments = file.split(/[\\/]/);
|
|
2244
|
-
let count = segments.length - 1;
|
|
2245
|
-
const minCount = segments[0] ? 1 : 0;
|
|
2246
|
-
while (count > minCount) {
|
|
2247
|
-
const dir = segments.slice(0, count).join(path_1.default.sep) || path_1.default.sep;
|
|
2248
|
-
try {
|
|
2249
|
-
finalInputFileSystem.readdirSync(dir);
|
|
2250
|
-
} catch (e) {
|
|
2251
|
-
const time = Date.now();
|
|
2252
|
-
const dirStats = new virtual_stats_1.VirtualStats({
|
|
2253
|
-
dev: 8675309,
|
|
2254
|
-
nlink: 0,
|
|
2255
|
-
uid: 1e3,
|
|
2256
|
-
gid: 1e3,
|
|
2257
|
-
rdev: 0,
|
|
2258
|
-
blksize: 4096,
|
|
2259
|
-
ino: inode++,
|
|
2260
|
-
mode: 16877,
|
|
2261
|
-
size: stats.size,
|
|
2262
|
-
blocks: Math.floor(stats.size / 4096),
|
|
2263
|
-
atime: time,
|
|
2264
|
-
mtime: time,
|
|
2265
|
-
ctime: time,
|
|
2266
|
-
birthtime: time
|
|
2267
|
-
});
|
|
2268
|
-
setData(readDirStorage, dir, createWebpackData([]));
|
|
2269
|
-
if (realPathStorage) setData(realPathStorage, dir, createWebpackData(dir));
|
|
2270
|
-
setData(statStorage, dir, createWebpackData(dirStats));
|
|
2271
|
-
}
|
|
2272
|
-
let dirData = getData(getReadDirBackend(finalInputFileSystem), dir);
|
|
2273
|
-
dirData = dirData[1] || dirData.result;
|
|
2274
|
-
const filename = segments[count];
|
|
2275
|
-
if (dirData.indexOf(filename) < 0) {
|
|
2276
|
-
const files = dirData.concat([filename]).sort();
|
|
2277
|
-
setData(getReadDirBackend(finalInputFileSystem), dir, createWebpackData(files));
|
|
2278
|
-
} else break;
|
|
2279
|
-
count--;
|
|
2280
|
-
}
|
|
2281
|
-
};
|
|
2282
|
-
}
|
|
2283
|
-
};
|
|
2284
|
-
const afterResolversHook = () => {
|
|
2285
|
-
if (this._staticModules) {
|
|
2286
|
-
for (const [filePath, contents] of Object.entries(this._staticModules)) this.writeModule(filePath, contents);
|
|
2287
|
-
this._staticModules = null;
|
|
2288
|
-
}
|
|
2289
|
-
};
|
|
2290
|
-
const version$1 = typeof compiler.webpack === "undefined" ? 4 : 5;
|
|
2291
|
-
const watchRunHook = (watcher, callback) => {
|
|
2292
|
-
this._watcher = watcher.compiler || watcher;
|
|
2293
|
-
const virtualFiles = compiler.inputFileSystem._virtualFiles;
|
|
2294
|
-
const fts = compiler.fileTimestamps;
|
|
2295
|
-
if (virtualFiles && fts && typeof fts.set === "function") Object.keys(virtualFiles).forEach((file) => {
|
|
2296
|
-
const mtime = +virtualFiles[file].stats.mtime;
|
|
2297
|
-
fts.set(file, version$1 === 4 ? mtime : {
|
|
2298
|
-
safeTime: mtime,
|
|
2299
|
-
timestamp: mtime
|
|
2300
|
-
});
|
|
2301
|
-
});
|
|
2302
|
-
callback();
|
|
2303
|
-
};
|
|
2304
|
-
if (compiler.hooks) {
|
|
2305
|
-
compiler.hooks.afterEnvironment.tap("VirtualModulesPlugin", afterEnvironmentHook);
|
|
2306
|
-
compiler.hooks.afterResolvers.tap("VirtualModulesPlugin", afterResolversHook);
|
|
2307
|
-
compiler.hooks.watchRun.tapAsync("VirtualModulesPlugin", watchRunHook);
|
|
2308
|
-
} else {
|
|
2309
|
-
compiler.plugin("after-environment", afterEnvironmentHook);
|
|
2310
|
-
compiler.plugin("after-resolvers", afterResolversHook);
|
|
2311
|
-
compiler.plugin("watch-run", watchRunHook);
|
|
2312
|
-
}
|
|
2313
|
-
}
|
|
2314
|
-
};
|
|
2315
|
-
module.exports = VirtualModulesPlugin;
|
|
2316
|
-
}));
|
|
2317
|
-
|
|
2318
|
-
//#endregion
|
|
2319
|
-
//#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/index.js
|
|
2320
|
-
var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
|
|
2321
|
-
const ExtToLoader = {
|
|
2322
|
-
".js": "js",
|
|
2323
|
-
".mjs": "js",
|
|
2324
|
-
".cjs": "js",
|
|
2325
|
-
".jsx": "jsx",
|
|
2326
|
-
".ts": "ts",
|
|
2327
|
-
".cts": "ts",
|
|
2328
|
-
".mts": "ts",
|
|
2329
|
-
".tsx": "tsx",
|
|
2330
|
-
".css": "css",
|
|
2331
|
-
".less": "css",
|
|
2332
|
-
".stylus": "css",
|
|
2333
|
-
".scss": "css",
|
|
2334
|
-
".sass": "css",
|
|
2335
|
-
".json": "json",
|
|
2336
|
-
".txt": "text"
|
|
2337
|
-
};
|
|
2338
|
-
function guessLoader(code, id) {
|
|
2339
|
-
return ExtToLoader[path.extname(id).toLowerCase()] || "js";
|
|
2340
|
-
}
|
|
2341
|
-
function unwrapLoader(loader, code, id) {
|
|
2342
|
-
if (typeof loader === "function") return loader(code, id);
|
|
2343
|
-
return loader;
|
|
2344
|
-
}
|
|
2345
|
-
function fixSourceMap(map) {
|
|
2346
|
-
if (!Object.prototype.hasOwnProperty.call(map, "toString")) Object.defineProperty(map, "toString", {
|
|
2347
|
-
enumerable: false,
|
|
2348
|
-
value: function toString() {
|
|
2349
|
-
return JSON.stringify(this);
|
|
2350
|
-
}
|
|
2351
|
-
});
|
|
2352
|
-
if (!Object.prototype.hasOwnProperty.call(map, "toUrl")) Object.defineProperty(map, "toUrl", {
|
|
2353
|
-
enumerable: false,
|
|
2354
|
-
value: function toUrl() {
|
|
2355
|
-
return `data:application/json;charset=utf-8;base64,${Buffer.from(this.toString()).toString("base64")}`;
|
|
2356
|
-
}
|
|
2357
|
-
});
|
|
2358
|
-
return map;
|
|
2359
|
-
}
|
|
2360
|
-
const nullSourceMap = {
|
|
2361
|
-
names: [],
|
|
2362
|
-
sources: [],
|
|
2363
|
-
mappings: "",
|
|
2364
|
-
version: 3
|
|
2365
|
-
};
|
|
2366
|
-
function combineSourcemaps(filename, sourcemapList) {
|
|
2367
|
-
sourcemapList = sourcemapList.filter((m) => m.sources);
|
|
2368
|
-
if (sourcemapList.length === 0 || sourcemapList.every((m) => m.sources.length === 0)) return { ...nullSourceMap };
|
|
2369
|
-
let map;
|
|
2370
|
-
let mapIndex = 1;
|
|
2371
|
-
if (sourcemapList.slice(0, -1).find((m) => m.sources.length !== 1) === void 0) map = remapping(sourcemapList, () => null, true);
|
|
2372
|
-
else map = remapping(sourcemapList[0], (sourcefile) => {
|
|
2373
|
-
if (sourcefile === filename && sourcemapList[mapIndex]) return sourcemapList[mapIndex++];
|
|
2374
|
-
else return { ...nullSourceMap };
|
|
2375
|
-
}, true);
|
|
2376
|
-
if (!map.file) delete map.file;
|
|
2377
|
-
return map;
|
|
2378
|
-
}
|
|
2379
|
-
function createBuildContext$2(build) {
|
|
2380
|
-
const watchFiles = [];
|
|
2381
|
-
const { initialOptions } = build;
|
|
2382
|
-
return {
|
|
2383
|
-
parse,
|
|
2384
|
-
addWatchFile() {
|
|
2385
|
-
throw new Error("unplugin/esbuild: addWatchFile outside supported hooks (resolveId, load, transform)");
|
|
2386
|
-
},
|
|
2387
|
-
emitFile(emittedFile) {
|
|
2388
|
-
const outFileName = emittedFile.fileName || emittedFile.name;
|
|
2389
|
-
if (initialOptions.outdir && emittedFile.source && outFileName) {
|
|
2390
|
-
const outPath = path.resolve(initialOptions.outdir, outFileName);
|
|
2391
|
-
const outDir = path.dirname(outPath);
|
|
2392
|
-
if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true });
|
|
2393
|
-
fs.writeFileSync(outPath, emittedFile.source);
|
|
2394
|
-
}
|
|
2395
|
-
},
|
|
2396
|
-
getWatchFiles() {
|
|
2397
|
-
return watchFiles;
|
|
2398
|
-
},
|
|
2399
|
-
getNativeBuildContext() {
|
|
2400
|
-
return {
|
|
2401
|
-
framework: "esbuild",
|
|
2402
|
-
build
|
|
2403
|
-
};
|
|
2404
|
-
}
|
|
2405
|
-
};
|
|
2406
|
-
}
|
|
2407
|
-
function createPluginContext(context) {
|
|
2408
|
-
const errors = [];
|
|
2409
|
-
const warnings = [];
|
|
2410
|
-
const pluginContext = {
|
|
2411
|
-
error(message) {
|
|
2412
|
-
errors.push(normalizeMessage$2(message));
|
|
2413
|
-
},
|
|
2414
|
-
warn(message) {
|
|
2415
|
-
warnings.push(normalizeMessage$2(message));
|
|
2416
|
-
}
|
|
2417
|
-
};
|
|
2418
|
-
return {
|
|
2419
|
-
errors,
|
|
2420
|
-
warnings,
|
|
2421
|
-
mixedContext: {
|
|
2422
|
-
...context,
|
|
2423
|
-
...pluginContext,
|
|
2424
|
-
addWatchFile(id) {
|
|
2425
|
-
context.getWatchFiles().push(id);
|
|
2426
|
-
}
|
|
2427
|
-
}
|
|
2428
|
-
};
|
|
2429
|
-
}
|
|
2430
|
-
function normalizeMessage$2(message) {
|
|
2431
|
-
if (typeof message === "string") message = { message };
|
|
2432
|
-
return {
|
|
2433
|
-
id: message.id,
|
|
2434
|
-
pluginName: message.plugin,
|
|
2435
|
-
text: message.message,
|
|
2436
|
-
location: message.loc ? {
|
|
2437
|
-
file: message.loc.file,
|
|
2438
|
-
line: message.loc.line,
|
|
2439
|
-
column: message.loc.column
|
|
2440
|
-
} : null,
|
|
2441
|
-
detail: message.meta,
|
|
2442
|
-
notes: []
|
|
2443
|
-
};
|
|
2444
|
-
}
|
|
2445
|
-
function processCodeWithSourceMap(map, code) {
|
|
2446
|
-
if (map) {
|
|
2447
|
-
if (!map.sourcesContent || map.sourcesContent.length === 0) map.sourcesContent = [code];
|
|
2448
|
-
map = fixSourceMap(map);
|
|
2449
|
-
code += `\n//# sourceMappingURL=${map.toUrl()}`;
|
|
2450
|
-
}
|
|
2451
|
-
return code;
|
|
2452
|
-
}
|
|
2453
|
-
function getEsbuildPlugin(factory) {
|
|
2454
|
-
return (userOptions) => {
|
|
2455
|
-
const meta = { framework: "esbuild" };
|
|
2456
|
-
const plugins = toArray$2(factory(userOptions, meta));
|
|
2457
|
-
const setupPlugins = async (build) => {
|
|
2458
|
-
const setup = buildSetup();
|
|
2459
|
-
const loaders = [];
|
|
2460
|
-
for (const plugin of plugins) {
|
|
2461
|
-
const loader = {};
|
|
2462
|
-
await setup(plugin)({
|
|
2463
|
-
...build,
|
|
2464
|
-
onLoad(_options, callback) {
|
|
2465
|
-
loader.options = _options;
|
|
2466
|
-
loader.onLoadCb = callback;
|
|
2467
|
-
},
|
|
2468
|
-
onTransform(_options, callback) {
|
|
2469
|
-
loader.options ||= _options;
|
|
2470
|
-
loader.onTransformCb = callback;
|
|
2471
|
-
}
|
|
2472
|
-
}, build);
|
|
2473
|
-
if (loader.onLoadCb || loader.onTransformCb) loaders.push(loader);
|
|
2474
|
-
}
|
|
2475
|
-
if (loaders.length) build.onLoad(loaders.length === 1 ? loaders[0].options : { filter: /.*/ }, async (args) => {
|
|
2476
|
-
function checkFilter(options) {
|
|
2477
|
-
return loaders.length === 1 || !options?.filter || options.filter.test(args.path);
|
|
2478
|
-
}
|
|
2479
|
-
let result;
|
|
2480
|
-
for (const { options, onLoadCb } of loaders) {
|
|
2481
|
-
if (!checkFilter(options)) continue;
|
|
2482
|
-
if (onLoadCb) result = await onLoadCb(args);
|
|
2483
|
-
if (result?.contents) break;
|
|
2484
|
-
}
|
|
2485
|
-
let fsContentsCache;
|
|
2486
|
-
for (const { options, onTransformCb } of loaders) {
|
|
2487
|
-
if (!checkFilter(options)) continue;
|
|
2488
|
-
if (onTransformCb) {
|
|
2489
|
-
const _result = await onTransformCb({
|
|
2490
|
-
...result,
|
|
2491
|
-
...args,
|
|
2492
|
-
async getContents() {
|
|
2493
|
-
if (result?.contents) return result.contents;
|
|
2494
|
-
if (fsContentsCache) return fsContentsCache;
|
|
2495
|
-
return fsContentsCache = await fs.promises.readFile(args.path, "utf8");
|
|
2496
|
-
}
|
|
2497
|
-
});
|
|
2498
|
-
if (_result?.contents) result = _result;
|
|
2499
|
-
}
|
|
2500
|
-
}
|
|
2501
|
-
if (result?.contents) return result;
|
|
2502
|
-
});
|
|
2503
|
-
};
|
|
2504
|
-
return {
|
|
2505
|
-
name: (plugins.length === 1 ? plugins[0].name : meta.esbuildHostName) ?? `unplugin-host:${plugins.map((p) => p.name).join(":")}`,
|
|
2506
|
-
setup: setupPlugins
|
|
2507
|
-
};
|
|
2508
|
-
};
|
|
2509
|
-
}
|
|
2510
|
-
function buildSetup() {
|
|
2511
|
-
return (plugin) => {
|
|
2512
|
-
return (build, rawBuild) => {
|
|
2513
|
-
const context = createBuildContext$2(rawBuild);
|
|
2514
|
-
const { onStart, onEnd, onResolve, onLoad, onTransform, initialOptions } = build;
|
|
2515
|
-
const onResolveFilter = plugin.esbuild?.onResolveFilter ?? /.*/;
|
|
2516
|
-
const onLoadFilter = plugin.esbuild?.onLoadFilter ?? /.*/;
|
|
2517
|
-
const loader = plugin.esbuild?.loader ?? guessLoader;
|
|
2518
|
-
plugin.esbuild?.config?.call(context, initialOptions);
|
|
2519
|
-
if (plugin.buildStart) onStart(() => plugin.buildStart.call(context));
|
|
2520
|
-
if (plugin.buildEnd || plugin.writeBundle) onEnd(async () => {
|
|
2521
|
-
if (plugin.buildEnd) await plugin.buildEnd.call(context);
|
|
2522
|
-
if (plugin.writeBundle) await plugin.writeBundle();
|
|
2523
|
-
});
|
|
2524
|
-
if (plugin.resolveId) onResolve({ filter: onResolveFilter }, async (args) => {
|
|
2525
|
-
const id = args.path;
|
|
2526
|
-
if (initialOptions.external?.includes(id)) return;
|
|
2527
|
-
const { handler, filter } = normalizeObjectHook("resolveId", plugin.resolveId);
|
|
2528
|
-
if (!filter(id)) return;
|
|
2529
|
-
const { errors, warnings, mixedContext } = createPluginContext(context);
|
|
2530
|
-
const isEntry = args.kind === "entry-point";
|
|
2531
|
-
const result = await handler.call(mixedContext, id, isEntry ? void 0 : args.importer, { isEntry });
|
|
2532
|
-
if (typeof result === "string") return {
|
|
2533
|
-
path: result,
|
|
2534
|
-
namespace: plugin.name,
|
|
2535
|
-
errors,
|
|
2536
|
-
warnings,
|
|
2537
|
-
watchFiles: mixedContext.getWatchFiles()
|
|
2538
|
-
};
|
|
2539
|
-
else if (typeof result === "object" && result !== null) return {
|
|
2540
|
-
path: result.id,
|
|
2541
|
-
external: result.external,
|
|
2542
|
-
namespace: plugin.name,
|
|
2543
|
-
errors,
|
|
2544
|
-
warnings,
|
|
2545
|
-
watchFiles: mixedContext.getWatchFiles()
|
|
2546
|
-
};
|
|
2547
|
-
});
|
|
2548
|
-
if (plugin.load) onLoad({ filter: onLoadFilter }, async (args) => {
|
|
2549
|
-
const { handler, filter } = normalizeObjectHook("load", plugin.load);
|
|
2550
|
-
const id = args.path + (args.suffix || "");
|
|
2551
|
-
if (plugin.loadInclude && !plugin.loadInclude(id)) return;
|
|
2552
|
-
if (!filter(id)) return;
|
|
2553
|
-
const { errors, warnings, mixedContext } = createPluginContext(context);
|
|
2554
|
-
let code;
|
|
2555
|
-
let map;
|
|
2556
|
-
const result = await handler.call(mixedContext, id);
|
|
2557
|
-
if (typeof result === "string") code = result;
|
|
2558
|
-
else if (typeof result === "object" && result !== null) {
|
|
2559
|
-
code = result.code;
|
|
2560
|
-
map = result.map;
|
|
2561
|
-
}
|
|
2562
|
-
if (code === void 0) return null;
|
|
2563
|
-
if (map) code = processCodeWithSourceMap(map, code);
|
|
2564
|
-
const resolveDir = path.dirname(args.path);
|
|
2565
|
-
return {
|
|
2566
|
-
contents: code,
|
|
2567
|
-
errors,
|
|
2568
|
-
warnings,
|
|
2569
|
-
watchFiles: mixedContext.getWatchFiles(),
|
|
2570
|
-
loader: unwrapLoader(loader, code, args.path),
|
|
2571
|
-
resolveDir
|
|
2572
|
-
};
|
|
2573
|
-
});
|
|
2574
|
-
if (plugin.transform) onTransform({ filter: onLoadFilter }, async (args) => {
|
|
2575
|
-
const { handler, filter } = normalizeObjectHook("transform", plugin.transform);
|
|
2576
|
-
const id = args.path + (args.suffix || "");
|
|
2577
|
-
if (plugin.transformInclude && !plugin.transformInclude(id)) return;
|
|
2578
|
-
let code = await args.getContents();
|
|
2579
|
-
if (!filter(id, code)) return;
|
|
2580
|
-
const { mixedContext, errors, warnings } = createPluginContext(context);
|
|
2581
|
-
const resolveDir = path.dirname(args.path);
|
|
2582
|
-
let map;
|
|
2583
|
-
const result = await handler.call(mixedContext, code, id);
|
|
2584
|
-
if (typeof result === "string") code = result;
|
|
2585
|
-
else if (typeof result === "object" && result !== null) {
|
|
2586
|
-
code = result.code;
|
|
2587
|
-
if (map && result.map) map = combineSourcemaps(args.path, [result.map === "string" ? JSON.parse(result.map) : result.map, map]);
|
|
2588
|
-
else if (typeof result.map === "string") map = JSON.parse(result.map);
|
|
2589
|
-
else map = result.map;
|
|
2590
|
-
}
|
|
2591
|
-
if (code) {
|
|
2592
|
-
if (map) code = processCodeWithSourceMap(map, code);
|
|
2593
|
-
return {
|
|
2594
|
-
contents: code,
|
|
2595
|
-
errors,
|
|
2596
|
-
warnings,
|
|
2597
|
-
watchFiles: mixedContext.getWatchFiles(),
|
|
2598
|
-
loader: unwrapLoader(loader, code, args.path),
|
|
2599
|
-
resolveDir
|
|
2600
|
-
};
|
|
2601
|
-
}
|
|
2602
|
-
});
|
|
2603
|
-
if (plugin.esbuild?.setup) return plugin.esbuild.setup(rawBuild);
|
|
2604
|
-
};
|
|
2605
|
-
};
|
|
2606
|
-
}
|
|
2607
|
-
function createFarmContext(context, currentResolveId) {
|
|
2608
|
-
return {
|
|
2609
|
-
parse,
|
|
2610
|
-
addWatchFile(id) {
|
|
2611
|
-
context.addWatchFile(id, currentResolveId || id);
|
|
2612
|
-
},
|
|
2613
|
-
emitFile(emittedFile) {
|
|
2614
|
-
const outFileName = emittedFile.fileName || emittedFile.name;
|
|
2615
|
-
if (emittedFile.source && outFileName) context.emitFile({
|
|
2616
|
-
resolvedPath: outFileName,
|
|
2617
|
-
name: outFileName,
|
|
2618
|
-
content: [...Buffer.from(emittedFile.source)],
|
|
2619
|
-
resourceType: extname(outFileName)
|
|
2620
|
-
});
|
|
2621
|
-
},
|
|
2622
|
-
getWatchFiles() {
|
|
2623
|
-
return context.getWatchFiles();
|
|
2624
|
-
},
|
|
2625
|
-
getNativeBuildContext() {
|
|
2626
|
-
return {
|
|
2627
|
-
framework: "farm",
|
|
2628
|
-
context
|
|
2629
|
-
};
|
|
2630
|
-
}
|
|
2631
|
-
};
|
|
2632
|
-
}
|
|
2633
|
-
function unpluginContext(context) {
|
|
2634
|
-
return {
|
|
2635
|
-
error: (error) => context.error(typeof error === "string" ? new Error(error) : error),
|
|
2636
|
-
warn: (error) => context.warn(typeof error === "string" ? new Error(error) : error)
|
|
2637
|
-
};
|
|
2638
|
-
}
|
|
2639
|
-
function convertEnforceToPriority(value) {
|
|
2640
|
-
const defaultPriority = 100;
|
|
2641
|
-
const enforceToPriority = {
|
|
2642
|
-
pre: 102,
|
|
2643
|
-
post: 98
|
|
2644
|
-
};
|
|
2645
|
-
return enforceToPriority[value] !== void 0 ? enforceToPriority[value] : defaultPriority;
|
|
2646
|
-
}
|
|
2647
|
-
function convertWatchEventChange(value) {
|
|
2648
|
-
return {
|
|
2649
|
-
Added: "create",
|
|
2650
|
-
Updated: "update",
|
|
2651
|
-
Removed: "delete"
|
|
2652
|
-
}[value];
|
|
2653
|
-
}
|
|
2654
|
-
function isString(variable) {
|
|
2655
|
-
return typeof variable === "string";
|
|
2656
|
-
}
|
|
2657
|
-
function isObject(variable) {
|
|
2658
|
-
return typeof variable === "object" && variable !== null;
|
|
2659
|
-
}
|
|
2660
|
-
function customParseQueryString(url) {
|
|
2661
|
-
if (!url) return [];
|
|
2662
|
-
const queryString = url.split("?")[1];
|
|
2663
|
-
const parsedParams = querystring.parse(queryString);
|
|
2664
|
-
const paramsArray = [];
|
|
2665
|
-
for (const key in parsedParams) paramsArray.push([key, parsedParams[key]]);
|
|
2666
|
-
return paramsArray;
|
|
2667
|
-
}
|
|
2668
|
-
function encodeStr(str) {
|
|
2669
|
-
const len = str.length;
|
|
2670
|
-
if (len === 0) return str;
|
|
2671
|
-
const firstNullIndex = str.indexOf("\0");
|
|
2672
|
-
if (firstNullIndex === -1) return str;
|
|
2673
|
-
const result = Array.from({ length: len + countNulls(str, firstNullIndex) });
|
|
2674
|
-
let pos = 0;
|
|
2675
|
-
for (let i = 0; i < firstNullIndex; i++) result[pos++] = str[i];
|
|
2676
|
-
for (let i = firstNullIndex; i < len; i++) {
|
|
2677
|
-
const char = str[i];
|
|
2678
|
-
if (char === "\0") {
|
|
2679
|
-
result[pos++] = "\\";
|
|
2680
|
-
result[pos++] = "0";
|
|
2681
|
-
} else result[pos++] = char;
|
|
2682
|
-
}
|
|
2683
|
-
return path.posix.normalize(result.join(""));
|
|
2684
|
-
}
|
|
2685
|
-
function decodeStr(str) {
|
|
2686
|
-
const len = str.length;
|
|
2687
|
-
if (len === 0) return str;
|
|
2688
|
-
const firstIndex = str.indexOf("\\0");
|
|
2689
|
-
if (firstIndex === -1) return str;
|
|
2690
|
-
const result = Array.from({ length: len - countBackslashZeros(str, firstIndex) });
|
|
2691
|
-
let pos = 0;
|
|
2692
|
-
for (let i$1 = 0; i$1 < firstIndex; i$1++) result[pos++] = str[i$1];
|
|
2693
|
-
let i = firstIndex;
|
|
2694
|
-
while (i < len) if (str[i] === "\\" && str[i + 1] === "0") {
|
|
2695
|
-
result[pos++] = "\0";
|
|
2696
|
-
i += 2;
|
|
2697
|
-
} else result[pos++] = str[i++];
|
|
2698
|
-
return path.posix.normalize(result.join(""));
|
|
2699
|
-
}
|
|
2700
|
-
function getContentValue(content) {
|
|
2701
|
-
if (content === null || content === void 0) throw new Error("Content cannot be null or undefined");
|
|
2702
|
-
return encodeStr(typeof content === "string" ? content : content.code || "");
|
|
2703
|
-
}
|
|
2704
|
-
function countNulls(str, startIndex) {
|
|
2705
|
-
let count = 0;
|
|
2706
|
-
const len = str.length;
|
|
2707
|
-
for (let i = startIndex; i < len; i++) if (str[i] === "\0") count++;
|
|
2708
|
-
return count;
|
|
2709
|
-
}
|
|
2710
|
-
function countBackslashZeros(str, startIndex) {
|
|
2711
|
-
let count = 0;
|
|
2712
|
-
const len = str.length;
|
|
2713
|
-
for (let i = startIndex; i < len - 1; i++) if (str[i] === "\\" && str[i + 1] === "0") {
|
|
2714
|
-
count++;
|
|
2715
|
-
i++;
|
|
2716
|
-
}
|
|
2717
|
-
return count;
|
|
2718
|
-
}
|
|
2719
|
-
function removeQuery(pathe) {
|
|
2720
|
-
const queryIndex = pathe.indexOf("?");
|
|
2721
|
-
if (queryIndex !== -1) return path.posix.normalize(pathe.slice(0, queryIndex));
|
|
2722
|
-
return path.posix.normalize(pathe);
|
|
2723
|
-
}
|
|
2724
|
-
function isStartsWithSlash(str) {
|
|
2725
|
-
return str?.startsWith("/");
|
|
2726
|
-
}
|
|
2727
|
-
function appendQuery(id, query) {
|
|
2728
|
-
if (!query.length) return id;
|
|
2729
|
-
return `${id}?${stringifyQuery(query)}`;
|
|
2730
|
-
}
|
|
2731
|
-
function stringifyQuery(query) {
|
|
2732
|
-
if (!query.length) return "";
|
|
2733
|
-
let queryStr = "";
|
|
2734
|
-
for (const [key, value] of query) queryStr += `${key}${value ? `=${value}` : ""}&`;
|
|
2735
|
-
return `${queryStr.slice(0, -1)}`;
|
|
2736
|
-
}
|
|
2737
|
-
const CSS_LANGS_RES = [
|
|
2738
|
-
[/\.(less)(?:$|\?)/, "less"],
|
|
2739
|
-
[/\.(scss|sass)(?:$|\?)/, "sass"],
|
|
2740
|
-
[/\.(styl|stylus)(?:$|\?)/, "stylus"],
|
|
2741
|
-
[/\.(css)(?:$|\?)/, "css"]
|
|
2742
|
-
];
|
|
2743
|
-
const JS_LANGS_RES = [
|
|
2744
|
-
[/\.(js|mjs|cjs)(?:$|\?)/, "js"],
|
|
2745
|
-
[/\.(jsx)(?:$|\?)/, "jsx"],
|
|
2746
|
-
[/\.(ts|cts|mts)(?:$|\?)/, "ts"],
|
|
2747
|
-
[/\.(tsx)(?:$|\?)/, "tsx"]
|
|
2748
|
-
];
|
|
2749
|
-
function getCssModuleType(id) {
|
|
2750
|
-
for (const [reg, lang] of CSS_LANGS_RES) if (reg.test(id)) return lang;
|
|
2751
|
-
return null;
|
|
2752
|
-
}
|
|
2753
|
-
function getJsModuleType(id) {
|
|
2754
|
-
for (const [reg, lang] of JS_LANGS_RES) if (reg.test(id)) return lang;
|
|
2755
|
-
return null;
|
|
2756
|
-
}
|
|
2757
|
-
function formatLoadModuleType(id) {
|
|
2758
|
-
const cssModuleType = getCssModuleType(id);
|
|
2759
|
-
if (cssModuleType) return cssModuleType;
|
|
2760
|
-
const jsModuleType = getJsModuleType(id);
|
|
2761
|
-
if (jsModuleType) return jsModuleType;
|
|
2762
|
-
return "js";
|
|
2763
|
-
}
|
|
2764
|
-
function formatTransformModuleType(id) {
|
|
2765
|
-
return formatLoadModuleType(id);
|
|
2766
|
-
}
|
|
2767
|
-
function getFarmPlugin(factory) {
|
|
2768
|
-
return ((userOptions) => {
|
|
2769
|
-
const plugins = toArray$2(factory(userOptions, { framework: "farm" })).map((rawPlugin) => {
|
|
2770
|
-
const plugin = toFarmPlugin(rawPlugin, userOptions);
|
|
2771
|
-
if (rawPlugin.farm) Object.assign(plugin, rawPlugin.farm);
|
|
2772
|
-
return plugin;
|
|
2773
|
-
});
|
|
2774
|
-
return plugins.length === 1 ? plugins[0] : plugins;
|
|
2775
|
-
});
|
|
2776
|
-
}
|
|
2777
|
-
function toFarmPlugin(plugin, options) {
|
|
2778
|
-
const farmPlugin = {
|
|
2779
|
-
name: plugin.name,
|
|
2780
|
-
priority: convertEnforceToPriority(plugin.enforce)
|
|
2781
|
-
};
|
|
2782
|
-
if (plugin.farm) Object.keys(plugin.farm).forEach((key) => {
|
|
2783
|
-
const value = plugin.farm[key];
|
|
2784
|
-
if (value) Reflect.set(farmPlugin, key, value);
|
|
2785
|
-
});
|
|
2786
|
-
if (plugin.buildStart) {
|
|
2787
|
-
const _buildStart = plugin.buildStart;
|
|
2788
|
-
farmPlugin.buildStart = { async executor(_, context) {
|
|
2789
|
-
await _buildStart.call(createFarmContext(context));
|
|
2790
|
-
} };
|
|
2791
|
-
}
|
|
2792
|
-
if (plugin.resolveId) {
|
|
2793
|
-
const _resolveId = plugin.resolveId;
|
|
2794
|
-
let filters = [];
|
|
2795
|
-
if (options) filters = options?.filters ?? [];
|
|
2796
|
-
farmPlugin.resolve = {
|
|
2797
|
-
filters: {
|
|
2798
|
-
sources: filters.length ? filters : [".*"],
|
|
2799
|
-
importers: [".*"]
|
|
2800
|
-
},
|
|
2801
|
-
async executor(params, context) {
|
|
2802
|
-
const resolvedIdPath = path.resolve(params.importer ?? "");
|
|
2803
|
-
const id = decodeStr(params.source);
|
|
2804
|
-
const { handler, filter } = normalizeObjectHook("resolveId", _resolveId);
|
|
2805
|
-
if (!filter(id)) return null;
|
|
2806
|
-
let isEntry = false;
|
|
2807
|
-
if (isObject(params.kind) && "entry" in params.kind) isEntry = params.kind.entry === "index";
|
|
2808
|
-
const farmContext = createFarmContext(context, resolvedIdPath);
|
|
2809
|
-
const resolveIdResult = await handler.call(Object.assign(unpluginContext(context), farmContext), id, resolvedIdPath ?? null, { isEntry });
|
|
2810
|
-
if (isString(resolveIdResult)) return {
|
|
2811
|
-
resolvedPath: removeQuery(encodeStr(resolveIdResult)),
|
|
2812
|
-
query: customParseQueryString(resolveIdResult),
|
|
2813
|
-
sideEffects: true,
|
|
2814
|
-
external: false,
|
|
2815
|
-
meta: {}
|
|
2816
|
-
};
|
|
2817
|
-
if (isObject(resolveIdResult)) return {
|
|
2818
|
-
resolvedPath: removeQuery(encodeStr(resolveIdResult?.id)),
|
|
2819
|
-
query: customParseQueryString(resolveIdResult?.id),
|
|
2820
|
-
sideEffects: false,
|
|
2821
|
-
external: Boolean(resolveIdResult?.external),
|
|
2822
|
-
meta: {}
|
|
2823
|
-
};
|
|
2824
|
-
if (!isStartsWithSlash(params.source)) return null;
|
|
2825
|
-
}
|
|
2826
|
-
};
|
|
2827
|
-
}
|
|
2828
|
-
if (plugin.load) {
|
|
2829
|
-
const _load = plugin.load;
|
|
2830
|
-
farmPlugin.load = {
|
|
2831
|
-
filters: { resolvedPaths: [".*"] },
|
|
2832
|
-
async executor(params, context) {
|
|
2833
|
-
const id = appendQuery(decodeStr(params.resolvedPath), params.query);
|
|
2834
|
-
const loader = formatTransformModuleType(id);
|
|
2835
|
-
if (plugin.loadInclude && !plugin.loadInclude?.(id)) return null;
|
|
2836
|
-
const { handler, filter } = normalizeObjectHook("load", _load);
|
|
2837
|
-
if (!filter(id)) return null;
|
|
2838
|
-
const farmContext = createFarmContext(context, id);
|
|
2839
|
-
return {
|
|
2840
|
-
content: getContentValue(await handler.call(Object.assign(unpluginContext(context), farmContext), id)),
|
|
2841
|
-
moduleType: loader
|
|
2842
|
-
};
|
|
2843
|
-
}
|
|
2844
|
-
};
|
|
2845
|
-
}
|
|
2846
|
-
if (plugin.transform) {
|
|
2847
|
-
const _transform = plugin.transform;
|
|
2848
|
-
farmPlugin.transform = {
|
|
2849
|
-
filters: {
|
|
2850
|
-
resolvedPaths: [".*"],
|
|
2851
|
-
moduleTypes: [".*"]
|
|
2852
|
-
},
|
|
2853
|
-
async executor(params, context) {
|
|
2854
|
-
const id = appendQuery(decodeStr(params.resolvedPath), params.query);
|
|
2855
|
-
const loader = formatTransformModuleType(id);
|
|
2856
|
-
if (plugin.transformInclude && !plugin.transformInclude(id)) return null;
|
|
2857
|
-
const { handler, filter } = normalizeObjectHook("transform", _transform);
|
|
2858
|
-
if (!filter(id, params.content)) return null;
|
|
2859
|
-
const farmContext = createFarmContext(context, id);
|
|
2860
|
-
const resource = await handler.call(Object.assign(unpluginContext(context), farmContext), params.content, id);
|
|
2861
|
-
if (resource && typeof resource !== "string") return {
|
|
2862
|
-
content: getContentValue(resource),
|
|
2863
|
-
moduleType: loader,
|
|
2864
|
-
sourceMap: typeof resource.map === "object" && resource.map !== null ? JSON.stringify(resource.map) : void 0
|
|
2865
|
-
};
|
|
2866
|
-
}
|
|
2867
|
-
};
|
|
2868
|
-
}
|
|
2869
|
-
if (plugin.watchChange) {
|
|
2870
|
-
const _watchChange = plugin.watchChange;
|
|
2871
|
-
farmPlugin.updateModules = { async executor(param, context) {
|
|
2872
|
-
const updatePathContent = param.paths[0];
|
|
2873
|
-
const ModifiedPath = updatePathContent[0];
|
|
2874
|
-
const eventChange = convertWatchEventChange(updatePathContent[1]);
|
|
2875
|
-
await _watchChange.call(createFarmContext(context), ModifiedPath, { event: eventChange });
|
|
2876
|
-
} };
|
|
2877
|
-
}
|
|
2878
|
-
if (plugin.buildEnd) {
|
|
2879
|
-
const _buildEnd = plugin.buildEnd;
|
|
2880
|
-
farmPlugin.buildEnd = { async executor(_, context) {
|
|
2881
|
-
await _buildEnd.call(createFarmContext(context));
|
|
2882
|
-
} };
|
|
2883
|
-
}
|
|
2884
|
-
if (plugin.writeBundle) {
|
|
2885
|
-
const _writeBundle = plugin.writeBundle;
|
|
2886
|
-
farmPlugin.finish = { async executor() {
|
|
2887
|
-
await _writeBundle();
|
|
2888
|
-
} };
|
|
2889
|
-
}
|
|
2890
|
-
return farmPlugin;
|
|
2891
|
-
}
|
|
2892
|
-
function getRollupPlugin(factory) {
|
|
2893
|
-
return ((userOptions) => {
|
|
2894
|
-
const plugins = toArray$2(factory(userOptions, { framework: "rollup" })).map((plugin) => toRollupPlugin(plugin, "rollup"));
|
|
2895
|
-
return plugins.length === 1 ? plugins[0] : plugins;
|
|
2896
|
-
});
|
|
2897
|
-
}
|
|
2898
|
-
function toRollupPlugin(plugin, key) {
|
|
2899
|
-
const nativeFilter = key === "rolldown";
|
|
2900
|
-
if (plugin.resolveId && !nativeFilter && typeof plugin.resolveId === "object" && plugin.resolveId.filter) {
|
|
2901
|
-
const resolveIdHook = plugin.resolveId;
|
|
2902
|
-
const { handler, filter } = normalizeObjectHook("load", resolveIdHook);
|
|
2903
|
-
replaceHookHandler("resolveId", resolveIdHook, function(...args) {
|
|
2904
|
-
const [id] = args;
|
|
2905
|
-
if (!supportNativeFilter(this, key) && !filter(id)) return;
|
|
2906
|
-
return handler.apply(this, args);
|
|
2907
|
-
});
|
|
2908
|
-
}
|
|
2909
|
-
if (plugin.load && (plugin.loadInclude || !nativeFilter && typeof plugin.load === "object" && plugin.load.filter)) {
|
|
2910
|
-
const loadHook = plugin.load;
|
|
2911
|
-
const { handler, filter } = normalizeObjectHook("load", loadHook);
|
|
2912
|
-
replaceHookHandler("load", loadHook, function(...args) {
|
|
2913
|
-
const [id] = args;
|
|
2914
|
-
if (plugin.loadInclude && !plugin.loadInclude(id)) return;
|
|
2915
|
-
if (!supportNativeFilter(this, key) && !filter(id)) return;
|
|
2916
|
-
return handler.apply(this, args);
|
|
2917
|
-
});
|
|
2918
|
-
}
|
|
2919
|
-
if (plugin.transform && (plugin.transformInclude || !nativeFilter && typeof plugin.transform === "object" && plugin.transform.filter)) {
|
|
2920
|
-
const transformHook = plugin.transform;
|
|
2921
|
-
const { handler, filter } = normalizeObjectHook("transform", transformHook);
|
|
2922
|
-
replaceHookHandler("transform", transformHook, function(...args) {
|
|
2923
|
-
const [code, id] = args;
|
|
2924
|
-
if (plugin.transformInclude && !plugin.transformInclude(id)) return;
|
|
2925
|
-
if (!supportNativeFilter(this, key) && !filter(id, code)) return;
|
|
2926
|
-
return handler.apply(this, args);
|
|
2927
|
-
});
|
|
2928
|
-
}
|
|
2929
|
-
if (plugin[key]) Object.assign(plugin, plugin[key]);
|
|
2930
|
-
return plugin;
|
|
2931
|
-
function replaceHookHandler(name, hook, handler) {
|
|
2932
|
-
if (typeof hook === "function") plugin[name] = handler;
|
|
2933
|
-
else hook.handler = handler;
|
|
2934
|
-
}
|
|
2935
|
-
}
|
|
2936
|
-
function supportNativeFilter(context, framework) {
|
|
2937
|
-
if (framework === "unloader") return false;
|
|
2938
|
-
if (framework === "vite") return !!context?.meta?.viteVersion;
|
|
2939
|
-
if (framework === "rolldown") return true;
|
|
2940
|
-
const rollupVersion = context?.meta?.rollupVersion;
|
|
2941
|
-
if (!rollupVersion) return false;
|
|
2942
|
-
const [major, minor] = rollupVersion.split(".");
|
|
2943
|
-
return Number(major) > 4 || Number(major) === 4 && Number(minor) >= 40;
|
|
2944
|
-
}
|
|
2945
|
-
function getRolldownPlugin(factory) {
|
|
2946
|
-
return ((userOptions) => {
|
|
2947
|
-
const plugins = toArray$2(factory(userOptions, { framework: "rolldown" })).map((rawPlugin) => {
|
|
2948
|
-
return toRollupPlugin(rawPlugin, "rolldown");
|
|
2949
|
-
});
|
|
2950
|
-
return plugins.length === 1 ? plugins[0] : plugins;
|
|
2951
|
-
});
|
|
2952
|
-
}
|
|
2953
|
-
const getFilename = () => fileURLToPath(import.meta.url);
|
|
2954
|
-
const getDirname = () => path.dirname(getFilename());
|
|
2955
|
-
const __dirname = /* @__PURE__ */ getDirname();
|
|
2956
|
-
const TRANSFORM_LOADER$1 = resolve(__dirname, "rspack/loaders/transform");
|
|
2957
|
-
const LOAD_LOADER$1 = resolve(__dirname, "rspack/loaders/load");
|
|
2958
|
-
function getRspackPlugin(factory) {
|
|
2959
|
-
return (userOptions) => {
|
|
2960
|
-
return { apply(compiler) {
|
|
2961
|
-
const VIRTUAL_MODULE_PREFIX = resolve(compiler.options.context ?? process.cwd(), "node_modules/.virtual", compiler.rspack.experiments.VirtualModulesPlugin ? "" : process.pid.toString());
|
|
2962
|
-
const meta = {
|
|
2963
|
-
framework: "rspack",
|
|
2964
|
-
rspack: { compiler }
|
|
2965
|
-
};
|
|
2966
|
-
const rawPlugins = toArray$2(factory(userOptions, meta));
|
|
2967
|
-
for (const rawPlugin of rawPlugins) {
|
|
2968
|
-
const plugin = Object.assign(rawPlugin, {
|
|
2969
|
-
__unpluginMeta: meta,
|
|
2970
|
-
__virtualModulePrefix: VIRTUAL_MODULE_PREFIX
|
|
2971
|
-
});
|
|
2972
|
-
const externalModules = /* @__PURE__ */ new Set();
|
|
2973
|
-
if (plugin.resolveId) {
|
|
2974
|
-
const createPlugin = (plugin$1) => {
|
|
2975
|
-
if (compiler.rspack.experiments.VirtualModulesPlugin) return new compiler.rspack.experiments.VirtualModulesPlugin();
|
|
2976
|
-
return new FakeVirtualModulesPlugin(plugin$1);
|
|
2977
|
-
};
|
|
2978
|
-
const vfs = createPlugin(plugin);
|
|
2979
|
-
vfs.apply(compiler);
|
|
2980
|
-
const vfsModules = /* @__PURE__ */ new Map();
|
|
2981
|
-
plugin.__vfsModules = vfsModules;
|
|
2982
|
-
plugin.__vfs = vfs;
|
|
2983
|
-
compiler.hooks.compilation.tap(plugin.name, (compilation, { normalModuleFactory }) => {
|
|
2984
|
-
normalModuleFactory.hooks.resolve.tapPromise(plugin.name, async (resolveData) => {
|
|
2985
|
-
const id = normalizeAbsolutePath(resolveData.request);
|
|
2986
|
-
const requestContext = resolveData.contextInfo;
|
|
2987
|
-
let importer = requestContext.issuer !== "" ? requestContext.issuer : void 0;
|
|
2988
|
-
const isEntry = requestContext.issuer === "";
|
|
2989
|
-
if (importer?.startsWith(plugin.__virtualModulePrefix)) importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
|
|
2990
|
-
const context = createBuildContext$1(compiler, compilation);
|
|
2991
|
-
let error;
|
|
2992
|
-
const pluginContext = {
|
|
2993
|
-
error(msg) {
|
|
2994
|
-
if (error == null) error = normalizeMessage$1(msg);
|
|
2995
|
-
else console.error(`unplugin/rspack: multiple errors returned from resolveId hook: ${msg}`);
|
|
2996
|
-
},
|
|
2997
|
-
warn(msg) {
|
|
2998
|
-
console.warn(`unplugin/rspack: warning from resolveId hook: ${msg}`);
|
|
2999
|
-
}
|
|
3000
|
-
};
|
|
3001
|
-
const { handler, filter } = normalizeObjectHook("resolveId", plugin.resolveId);
|
|
3002
|
-
if (!filter(id)) return;
|
|
3003
|
-
const resolveIdResult = await handler.call({
|
|
3004
|
-
...context,
|
|
3005
|
-
...pluginContext
|
|
3006
|
-
}, id, importer, { isEntry });
|
|
3007
|
-
if (error != null) throw error;
|
|
3008
|
-
if (resolveIdResult == null) return;
|
|
3009
|
-
let resolved = typeof resolveIdResult === "string" ? resolveIdResult : resolveIdResult.id;
|
|
3010
|
-
if (typeof resolveIdResult === "string" ? false : resolveIdResult.external === true) externalModules.add(resolved);
|
|
3011
|
-
let isVirtual = true;
|
|
3012
|
-
try {
|
|
3013
|
-
(compiler.inputFileSystem?.statSync ?? fs.statSync)(resolved);
|
|
3014
|
-
isVirtual = false;
|
|
3015
|
-
} catch {
|
|
3016
|
-
isVirtual = !isVirtualModuleId(resolved, plugin);
|
|
3017
|
-
}
|
|
3018
|
-
if (isVirtual) {
|
|
3019
|
-
const encodedVirtualPath = encodeVirtualModuleId(resolved, plugin);
|
|
3020
|
-
if (!vfsModules.has(resolved)) {
|
|
3021
|
-
const fsPromise = Promise.resolve(vfs.writeModule(encodedVirtualPath, ""));
|
|
3022
|
-
vfsModules.set(resolved, fsPromise);
|
|
3023
|
-
await fsPromise;
|
|
3024
|
-
} else await vfsModules.get(resolved);
|
|
3025
|
-
resolved = encodedVirtualPath;
|
|
3026
|
-
}
|
|
3027
|
-
resolveData.request = resolved;
|
|
3028
|
-
});
|
|
3029
|
-
});
|
|
3030
|
-
}
|
|
3031
|
-
if (plugin.load) compiler.options.module.rules.unshift({
|
|
3032
|
-
enforce: plugin.enforce,
|
|
3033
|
-
include(id) {
|
|
3034
|
-
if (isVirtualModuleId(id, plugin)) id = decodeVirtualModuleId(id, plugin);
|
|
3035
|
-
if (plugin.loadInclude && !plugin.loadInclude(id)) return false;
|
|
3036
|
-
const { filter } = normalizeObjectHook("load", plugin.load);
|
|
3037
|
-
if (!filter(id)) return false;
|
|
3038
|
-
return !externalModules.has(id);
|
|
3039
|
-
},
|
|
3040
|
-
use: [{
|
|
3041
|
-
loader: LOAD_LOADER$1,
|
|
3042
|
-
options: { plugin }
|
|
3043
|
-
}],
|
|
3044
|
-
type: "javascript/auto"
|
|
3045
|
-
});
|
|
3046
|
-
if (plugin.transform) compiler.options.module.rules.unshift({
|
|
3047
|
-
enforce: plugin.enforce,
|
|
3048
|
-
use(data) {
|
|
3049
|
-
return transformUse(data, plugin, TRANSFORM_LOADER$1);
|
|
3050
|
-
}
|
|
3051
|
-
});
|
|
3052
|
-
if (plugin.rspack) plugin.rspack(compiler);
|
|
3053
|
-
if (plugin.watchChange || plugin.buildStart) compiler.hooks.make.tapPromise(plugin.name, async (compilation) => {
|
|
3054
|
-
const context = createBuildContext$1(compiler, compilation);
|
|
3055
|
-
if (plugin.watchChange && (compiler.modifiedFiles || compiler.removedFiles)) {
|
|
3056
|
-
const promises$1 = [];
|
|
3057
|
-
if (compiler.modifiedFiles) compiler.modifiedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
|
|
3058
|
-
if (compiler.removedFiles) compiler.removedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "delete" }))));
|
|
3059
|
-
await Promise.all(promises$1);
|
|
3060
|
-
}
|
|
3061
|
-
if (plugin.buildStart) return await plugin.buildStart.call(context);
|
|
3062
|
-
});
|
|
3063
|
-
if (plugin.buildEnd) compiler.hooks.emit.tapPromise(plugin.name, async (compilation) => {
|
|
3064
|
-
await plugin.buildEnd.call(createBuildContext$1(compiler, compilation));
|
|
3065
|
-
});
|
|
3066
|
-
if (plugin.writeBundle) compiler.hooks.afterEmit.tapPromise(plugin.name, async () => {
|
|
3067
|
-
await plugin.writeBundle();
|
|
3068
|
-
});
|
|
3069
|
-
}
|
|
3070
|
-
} };
|
|
3071
|
-
};
|
|
3072
|
-
}
|
|
3073
|
-
function getUnloaderPlugin(factory) {
|
|
3074
|
-
return ((userOptions) => {
|
|
3075
|
-
const plugins = toArray$2(factory(userOptions, { framework: "unloader" })).map((rawPlugin) => {
|
|
3076
|
-
return toRollupPlugin(rawPlugin, "unloader");
|
|
3077
|
-
});
|
|
3078
|
-
return plugins.length === 1 ? plugins[0] : plugins;
|
|
3079
|
-
});
|
|
3080
|
-
}
|
|
3081
|
-
function getVitePlugin(factory) {
|
|
3082
|
-
return ((userOptions) => {
|
|
3083
|
-
const plugins = toArray$2(factory(userOptions, { framework: "vite" })).map((rawPlugin) => {
|
|
3084
|
-
return toRollupPlugin(rawPlugin, "vite");
|
|
3085
|
-
});
|
|
3086
|
-
return plugins.length === 1 ? plugins[0] : plugins;
|
|
3087
|
-
});
|
|
3088
|
-
}
|
|
3089
|
-
const TRANSFORM_LOADER = resolve(__dirname, "webpack/loaders/transform");
|
|
3090
|
-
const LOAD_LOADER = resolve(__dirname, "webpack/loaders/load");
|
|
3091
|
-
function getWebpackPlugin(factory) {
|
|
3092
|
-
return (userOptions) => {
|
|
3093
|
-
return { apply(compiler) {
|
|
3094
|
-
const VIRTUAL_MODULE_PREFIX = resolve(compiler.options.context ?? process$1.cwd(), "_virtual_");
|
|
3095
|
-
const meta = {
|
|
3096
|
-
framework: "webpack",
|
|
3097
|
-
webpack: { compiler }
|
|
3098
|
-
};
|
|
3099
|
-
const rawPlugins = toArray$2(factory(userOptions, meta));
|
|
3100
|
-
for (const rawPlugin of rawPlugins) {
|
|
3101
|
-
const plugin = Object.assign(rawPlugin, {
|
|
3102
|
-
__unpluginMeta: meta,
|
|
3103
|
-
__virtualModulePrefix: VIRTUAL_MODULE_PREFIX
|
|
3104
|
-
});
|
|
3105
|
-
const externalModules = /* @__PURE__ */ new Set();
|
|
3106
|
-
if (plugin.resolveId) {
|
|
3107
|
-
let vfs = compiler.options.plugins.find((i) => i instanceof import_lib.default);
|
|
3108
|
-
if (!vfs) {
|
|
3109
|
-
vfs = new import_lib.default();
|
|
3110
|
-
compiler.options.plugins.push(vfs);
|
|
3111
|
-
}
|
|
3112
|
-
const vfsModules = /* @__PURE__ */ new Set();
|
|
3113
|
-
plugin.__vfsModules = vfsModules;
|
|
3114
|
-
plugin.__vfs = vfs;
|
|
3115
|
-
const resolverPlugin = { apply(resolver) {
|
|
3116
|
-
const target = resolver.ensureHook("resolve");
|
|
3117
|
-
resolver.getHook("resolve").tapAsync(plugin.name, async (request, resolveContext, callback) => {
|
|
3118
|
-
if (!request.request) return callback();
|
|
3119
|
-
if (normalizeAbsolutePath(request.request).startsWith(plugin.__virtualModulePrefix)) return callback();
|
|
3120
|
-
const id = normalizeAbsolutePath(request.request);
|
|
3121
|
-
const requestContext = request.context;
|
|
3122
|
-
let importer = requestContext.issuer !== "" ? requestContext.issuer : void 0;
|
|
3123
|
-
const isEntry = requestContext.issuer === "";
|
|
3124
|
-
if (importer?.startsWith(plugin.__virtualModulePrefix)) importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
|
|
3125
|
-
const fileDependencies = /* @__PURE__ */ new Set();
|
|
3126
|
-
const context = createBuildContext({
|
|
3127
|
-
addWatchFile(file) {
|
|
3128
|
-
fileDependencies.add(file);
|
|
3129
|
-
resolveContext.fileDependencies?.add(file);
|
|
3130
|
-
},
|
|
3131
|
-
getWatchFiles() {
|
|
3132
|
-
return Array.from(fileDependencies);
|
|
3133
|
-
}
|
|
3134
|
-
}, compiler);
|
|
3135
|
-
let error;
|
|
3136
|
-
const pluginContext = {
|
|
3137
|
-
error(msg) {
|
|
3138
|
-
if (error == null) error = normalizeMessage(msg);
|
|
3139
|
-
else console.error(`unplugin/webpack: multiple errors returned from resolveId hook: ${msg}`);
|
|
3140
|
-
},
|
|
3141
|
-
warn(msg) {
|
|
3142
|
-
console.warn(`unplugin/webpack: warning from resolveId hook: ${msg}`);
|
|
3143
|
-
}
|
|
3144
|
-
};
|
|
3145
|
-
const { handler, filter } = normalizeObjectHook("resolveId", plugin.resolveId);
|
|
3146
|
-
if (!filter(id)) return callback();
|
|
3147
|
-
const resolveIdResult = await handler.call({
|
|
3148
|
-
...context,
|
|
3149
|
-
...pluginContext
|
|
3150
|
-
}, id, importer, { isEntry });
|
|
3151
|
-
if (error != null) return callback(error);
|
|
3152
|
-
if (resolveIdResult == null) return callback();
|
|
3153
|
-
let resolved = typeof resolveIdResult === "string" ? resolveIdResult : resolveIdResult.id;
|
|
3154
|
-
if (typeof resolveIdResult === "string" ? false : resolveIdResult.external === true) externalModules.add(resolved);
|
|
3155
|
-
if (!fs.existsSync(resolved)) {
|
|
3156
|
-
resolved = normalizeAbsolutePath(plugin.__virtualModulePrefix + encodeURIComponent(resolved));
|
|
3157
|
-
if (!vfsModules.has(resolved)) {
|
|
3158
|
-
plugin.__vfs.writeModule(resolved, "");
|
|
3159
|
-
vfsModules.add(resolved);
|
|
3160
|
-
}
|
|
3161
|
-
}
|
|
3162
|
-
const newRequest = {
|
|
3163
|
-
...request,
|
|
3164
|
-
request: resolved
|
|
3165
|
-
};
|
|
3166
|
-
resolver.doResolve(target, newRequest, null, resolveContext, callback);
|
|
3167
|
-
});
|
|
3168
|
-
} };
|
|
3169
|
-
compiler.options.resolve.plugins = compiler.options.resolve.plugins || [];
|
|
3170
|
-
compiler.options.resolve.plugins.push(resolverPlugin);
|
|
3171
|
-
}
|
|
3172
|
-
if (plugin.load) compiler.options.module.rules.unshift({
|
|
3173
|
-
include(id) {
|
|
3174
|
-
return shouldLoad(id, plugin, externalModules);
|
|
3175
|
-
},
|
|
3176
|
-
enforce: plugin.enforce,
|
|
3177
|
-
use: [{
|
|
3178
|
-
loader: LOAD_LOADER,
|
|
3179
|
-
options: { plugin }
|
|
3180
|
-
}],
|
|
3181
|
-
type: "javascript/auto"
|
|
3182
|
-
});
|
|
3183
|
-
if (plugin.transform) compiler.options.module.rules.unshift({
|
|
3184
|
-
enforce: plugin.enforce,
|
|
3185
|
-
use(data) {
|
|
3186
|
-
return transformUse(data, plugin, TRANSFORM_LOADER);
|
|
3187
|
-
}
|
|
3188
|
-
});
|
|
3189
|
-
if (plugin.webpack) plugin.webpack(compiler);
|
|
3190
|
-
if (plugin.watchChange || plugin.buildStart) compiler.hooks.make.tapPromise(plugin.name, async (compilation) => {
|
|
3191
|
-
const context = createBuildContext(contextOptionsFromCompilation(compilation), compiler, compilation);
|
|
3192
|
-
if (plugin.watchChange && (compiler.modifiedFiles || compiler.removedFiles)) {
|
|
3193
|
-
const promises$1 = [];
|
|
3194
|
-
if (compiler.modifiedFiles) compiler.modifiedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
|
|
3195
|
-
if (compiler.removedFiles) compiler.removedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "delete" }))));
|
|
3196
|
-
await Promise.all(promises$1);
|
|
3197
|
-
}
|
|
3198
|
-
if (plugin.buildStart) return await plugin.buildStart.call(context);
|
|
3199
|
-
});
|
|
3200
|
-
if (plugin.buildEnd) compiler.hooks.emit.tapPromise(plugin.name, async (compilation) => {
|
|
3201
|
-
await plugin.buildEnd.call(createBuildContext(contextOptionsFromCompilation(compilation), compiler, compilation));
|
|
3202
|
-
});
|
|
3203
|
-
if (plugin.writeBundle) compiler.hooks.afterEmit.tapPromise(plugin.name, async () => {
|
|
3204
|
-
await plugin.writeBundle();
|
|
3205
|
-
});
|
|
3206
|
-
}
|
|
3207
|
-
} };
|
|
3208
|
-
};
|
|
3209
|
-
}
|
|
3210
|
-
function shouldLoad(id, plugin, externalModules) {
|
|
3211
|
-
if (id.startsWith(plugin.__virtualModulePrefix)) id = decodeURIComponent(id.slice(plugin.__virtualModulePrefix.length));
|
|
3212
|
-
if (plugin.loadInclude && !plugin.loadInclude(id)) return false;
|
|
3213
|
-
const { filter } = normalizeObjectHook("load", plugin.load);
|
|
3214
|
-
if (!filter(id)) return false;
|
|
3215
|
-
return !externalModules.has(id);
|
|
3216
|
-
}
|
|
3217
|
-
function createUnplugin(factory) {
|
|
3218
|
-
return {
|
|
3219
|
-
get esbuild() {
|
|
3220
|
-
return getEsbuildPlugin(factory);
|
|
3221
|
-
},
|
|
3222
|
-
get rollup() {
|
|
3223
|
-
return getRollupPlugin(factory);
|
|
3224
|
-
},
|
|
3225
|
-
get vite() {
|
|
3226
|
-
return getVitePlugin(factory);
|
|
3227
|
-
},
|
|
3228
|
-
get rolldown() {
|
|
3229
|
-
return getRolldownPlugin(factory);
|
|
3230
|
-
},
|
|
3231
|
-
get webpack() {
|
|
3232
|
-
return getWebpackPlugin(factory);
|
|
3233
|
-
},
|
|
3234
|
-
get rspack() {
|
|
3235
|
-
return getRspackPlugin(factory);
|
|
3236
|
-
},
|
|
3237
|
-
get farm() {
|
|
3238
|
-
return getFarmPlugin(factory);
|
|
3239
|
-
},
|
|
3240
|
-
get unloader() {
|
|
3241
|
-
return getUnloaderPlugin(factory);
|
|
3242
|
-
},
|
|
3243
|
-
get raw() {
|
|
3244
|
-
return factory;
|
|
3245
|
-
}
|
|
3246
|
-
};
|
|
3247
|
-
}
|
|
3248
|
-
|
|
3249
|
-
//#endregion
|
|
3250
|
-
//#region node_modules/.pnpm/unplugin-utils@0.3.1/node_modules/unplugin-utils/dist/index.js
|
|
3251
|
-
/**
|
|
3252
|
-
* Converts path separators to forward slash.
|
|
3253
|
-
*/
|
|
3254
|
-
function normalizePath(filename) {
|
|
3255
|
-
return filename.replaceAll("\\", "/");
|
|
3256
|
-
}
|
|
3257
|
-
const isArray = Array.isArray;
|
|
3258
|
-
function toArray$1(thing) {
|
|
3259
|
-
if (isArray(thing)) return thing;
|
|
3260
|
-
if (thing == null) return [];
|
|
3261
|
-
return [thing];
|
|
3262
|
-
}
|
|
3263
|
-
const escapeMark = "[_#EsCaPe#_]";
|
|
3264
|
-
function getMatcherString(id, resolutionBase) {
|
|
3265
|
-
if (resolutionBase === false || isAbsolute$2(id) || id.startsWith("**")) return normalizePath(id);
|
|
3266
|
-
return join$1(normalizePath(resolve$1(resolutionBase || "")).replaceAll(/[-^$*+?.()|[\]{}]/g, `${escapeMark}$&`), normalizePath(id)).replaceAll(escapeMark, "\\");
|
|
3267
|
-
}
|
|
3268
|
-
/**
|
|
3269
|
-
* Constructs a filter function which can be used to determine whether or not
|
|
3270
|
-
* certain modules should be operated upon.
|
|
3271
|
-
* @param include If `include` is omitted or has zero length, filter will return `true` by default.
|
|
3272
|
-
* @param exclude ID must not match any of the `exclude` patterns.
|
|
3273
|
-
* @param options Additional options.
|
|
3274
|
-
* @param options.resolve Optionally resolves the patterns against a directory other than `process.cwd()`.
|
|
3275
|
-
* If a `string` is specified, then the value will be used as the base directory.
|
|
3276
|
-
* Relative paths will be resolved against `process.cwd()` first.
|
|
3277
|
-
* If `false`, then the patterns will not be resolved against any directory.
|
|
3278
|
-
* This can be useful if you want to create a filter for virtual module names.
|
|
3279
|
-
*/
|
|
3280
|
-
function createFilter(include, exclude, options) {
|
|
3281
|
-
const resolutionBase = options && options.resolve;
|
|
3282
|
-
const getMatcher = (id) => id instanceof RegExp ? id : { test: (what) => {
|
|
3283
|
-
return (0, import_picomatch.default)(getMatcherString(id, resolutionBase), { dot: true })(what);
|
|
3284
|
-
} };
|
|
3285
|
-
const includeMatchers = toArray$1(include).map(getMatcher);
|
|
3286
|
-
const excludeMatchers = toArray$1(exclude).map(getMatcher);
|
|
3287
|
-
if (!includeMatchers.length && !excludeMatchers.length) return (id) => typeof id === "string" && !id.includes("\0");
|
|
3288
|
-
return function result(id) {
|
|
3289
|
-
if (typeof id !== "string") return false;
|
|
3290
|
-
if (id.includes("\0")) return false;
|
|
3291
|
-
const pathId = normalizePath(id);
|
|
3292
|
-
for (const matcher of excludeMatchers) {
|
|
3293
|
-
if (matcher instanceof RegExp) matcher.lastIndex = 0;
|
|
3294
|
-
if (matcher.test(pathId)) return false;
|
|
3295
|
-
}
|
|
3296
|
-
for (const matcher of includeMatchers) {
|
|
3297
|
-
if (matcher instanceof RegExp) matcher.lastIndex = 0;
|
|
3298
|
-
if (matcher.test(pathId)) return true;
|
|
3299
|
-
}
|
|
3300
|
-
return !includeMatchers.length;
|
|
3301
|
-
};
|
|
3302
|
-
}
|
|
3303
|
-
|
|
3304
|
-
//#endregion
|
|
3305
|
-
//#region node_modules/.pnpm/unimport@5.6.0/node_modules/unimport/dist/unplugin.mjs
|
|
3306
|
-
const defaultIncludes = [
|
|
3307
|
-
/\.[jt]sx?$/,
|
|
3308
|
-
/\.vue$/,
|
|
3309
|
-
/\.vue\?vue/,
|
|
3310
|
-
/\.svelte$/
|
|
3311
|
-
];
|
|
3312
|
-
const defaultExcludes = [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/];
|
|
3313
|
-
function toArray(x) {
|
|
3314
|
-
return x == null ? [] : Array.isArray(x) ? x : [x];
|
|
3315
|
-
}
|
|
3316
|
-
const unplugin = createUnplugin((options = {}) => {
|
|
3317
|
-
const ctx = createUnimport(options);
|
|
3318
|
-
const filter = createFilter(toArray(options.include || []).length ? options.include : defaultIncludes, options.exclude || defaultExcludes);
|
|
3319
|
-
const dts = options.dts === true ? "unimport.d.ts" : options.dts;
|
|
3320
|
-
const { autoImport = true } = options;
|
|
3321
|
-
return {
|
|
3322
|
-
name: "unimport",
|
|
3323
|
-
enforce: "post",
|
|
3324
|
-
transformInclude(id) {
|
|
3325
|
-
return filter(id);
|
|
3326
|
-
},
|
|
3327
|
-
async transform(code, id) {
|
|
3328
|
-
const s = new MagicString(code);
|
|
3329
|
-
await ctx.injectImports(s, id, { autoImport });
|
|
3330
|
-
if (!s.hasChanged()) return;
|
|
3331
|
-
return {
|
|
3332
|
-
code: s.toString(),
|
|
3333
|
-
map: s.generateMap()
|
|
3334
|
-
};
|
|
3335
|
-
},
|
|
3336
|
-
async buildStart() {
|
|
3337
|
-
await ctx.init();
|
|
3338
|
-
if (dts) return promises.writeFile(dts, await ctx.generateTypeDeclarations(), "utf-8");
|
|
3339
|
-
}
|
|
3340
|
-
};
|
|
3341
|
-
});
|
|
1772
|
+
//#region node_modules/.pnpm/unimport@5.6.0/node_modules/unimport/dist/index.mjs
|
|
1773
|
+
var dist_exports = /* @__PURE__ */ __exportAll({ createUnimport: () => createUnimport });
|
|
3342
1774
|
|
|
3343
1775
|
//#endregion
|
|
3344
1776
|
//#region node_modules/.pnpm/unimport@5.6.0/node_modules/unimport/dist/chunks/detect-acorn.mjs
|
|
@@ -3354,7 +1786,7 @@ async function detectImportsAcorn(code, ctx, options) {
|
|
|
3354
1786
|
const enableAutoImport = options?.autoImport !== false;
|
|
3355
1787
|
const enableTransformVirtualImports = options?.transformVirtualImports !== false && ctx.options.virtualImports?.length;
|
|
3356
1788
|
if (enableAutoImport || enableTransformVirtualImports) {
|
|
3357
|
-
const ast = parse$
|
|
1789
|
+
const ast = parse$1(s.original, {
|
|
3358
1790
|
sourceType: "module",
|
|
3359
1791
|
ecmaVersion: "latest",
|
|
3360
1792
|
locations: true
|
|
@@ -3531,4 +1963,48 @@ function createVirtualImportsAcronWalker(importMap, virtualImports = []) {
|
|
|
3531
1963
|
}
|
|
3532
1964
|
|
|
3533
1965
|
//#endregion
|
|
3534
|
-
|
|
1966
|
+
//#region node_modules/.pnpm/unimport@5.6.0/node_modules/unimport/dist/unplugin.mjs
|
|
1967
|
+
var unplugin_exports = /* @__PURE__ */ __exportAll({
|
|
1968
|
+
default: () => unplugin,
|
|
1969
|
+
defaultExcludes: () => defaultExcludes,
|
|
1970
|
+
defaultIncludes: () => defaultIncludes
|
|
1971
|
+
});
|
|
1972
|
+
const defaultIncludes = [
|
|
1973
|
+
/\.[jt]sx?$/,
|
|
1974
|
+
/\.vue$/,
|
|
1975
|
+
/\.vue\?vue/,
|
|
1976
|
+
/\.svelte$/
|
|
1977
|
+
];
|
|
1978
|
+
const defaultExcludes = [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/];
|
|
1979
|
+
function toArray(x) {
|
|
1980
|
+
return x == null ? [] : Array.isArray(x) ? x : [x];
|
|
1981
|
+
}
|
|
1982
|
+
const unplugin = createUnplugin((options = {}) => {
|
|
1983
|
+
const ctx = createUnimport(options);
|
|
1984
|
+
const filter = createFilter(toArray(options.include || []).length ? options.include : defaultIncludes, options.exclude || defaultExcludes);
|
|
1985
|
+
const dts = options.dts === true ? "unimport.d.ts" : options.dts;
|
|
1986
|
+
const { autoImport = true } = options;
|
|
1987
|
+
return {
|
|
1988
|
+
name: "unimport",
|
|
1989
|
+
enforce: "post",
|
|
1990
|
+
transformInclude(id) {
|
|
1991
|
+
return filter(id);
|
|
1992
|
+
},
|
|
1993
|
+
async transform(code, id) {
|
|
1994
|
+
const s = new MagicString(code);
|
|
1995
|
+
await ctx.injectImports(s, id, { autoImport });
|
|
1996
|
+
if (!s.hasChanged()) return;
|
|
1997
|
+
return {
|
|
1998
|
+
code: s.toString(),
|
|
1999
|
+
map: s.generateMap()
|
|
2000
|
+
};
|
|
2001
|
+
},
|
|
2002
|
+
async buildStart() {
|
|
2003
|
+
await ctx.init();
|
|
2004
|
+
if (dts) return promises.writeFile(dts, await ctx.generateTypeDeclarations(), "utf-8");
|
|
2005
|
+
}
|
|
2006
|
+
};
|
|
2007
|
+
});
|
|
2008
|
+
|
|
2009
|
+
//#endregion
|
|
2010
|
+
export { stripCommentsAndStrings as A, excludeRE as C, normalizeImports as D, matchRE as E, toTypeReExports as F, vueTemplateAddon as I, toExports as M, toTypeDeclarationFile as N, separatorRE as O, toTypeDeclarationItems as P, defineUnimportPreset as S, importAsRE as T, scanExports as _, createVirtualImportsAcronWalker as a, addImportToCode as b, traveseScopes as c, createUnimport as d, dedupeDtsExports as f, scanDirExports as g, resolvePreset as h, unplugin_exports as i, stripFileExtension as j, stringifyImports as k, dist_exports as l, resolveBuiltinPresets as m, defaultIncludes as n, detectImportsAcorn as o, normalizeScanDirs as p, unplugin as r, detect_acorn_exports as s, defaultExcludes as t, builtinPresets as u, scanFilesFromDir as v, getMagicString as w, dedupeImports as x, version as y };
|