nitro-nightly 4.0.0-20251030-091344-d4418b98 → 4.0.0-20251030-122334-09c1a7a8
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/common.mjs +763 -0
- package/dist/_build/rolldown.mjs +216 -0
- package/dist/_build/rollup.mjs +359 -0
- package/dist/_build/vite.build.mjs +67 -0
- package/dist/_build/vite.plugin.mjs +762 -0
- package/dist/_chunks/B-7HiF0V.mjs +1303 -0
- package/dist/_chunks/B3asVbT4.mjs +151 -0
- package/dist/_chunks/B5ooyfLk.mjs +372 -0
- package/dist/_chunks/DXMHy5ca.mjs +43 -0
- package/dist/_dev.d.mts +12 -0
- package/dist/_dev.mjs +675 -0
- package/dist/_libs/acorn.mjs +5034 -0
- package/dist/_libs/c12.mjs +2798 -0
- package/dist/_libs/chokidar.mjs +1560 -0
- package/dist/_libs/citty.mjs +333 -0
- package/dist/_libs/commondir.mjs +22 -0
- package/dist/_libs/compatx.mjs +46 -0
- package/dist/_libs/confbox.mjs +2920 -0
- package/dist/_libs/debug.mjs +848 -0
- package/dist/_libs/deepmerge.mjs +86 -0
- package/dist/_libs/depd.mjs +314 -0
- package/dist/_libs/dot-prop.mjs +138 -0
- package/dist/_libs/duplexer.mjs +71 -0
- package/dist/_libs/ee-first.mjs +68 -0
- package/dist/_libs/encodeurl.mjs +49 -0
- package/dist/_libs/escape-html.mjs +58 -0
- package/dist/_libs/escape-string-regexp.mjs +8 -0
- package/dist/_libs/estree-walker.mjs +330 -0
- package/dist/_libs/etag.mjs +75 -0
- package/dist/{_chunks/_deps → _libs}/fdir.mjs +49 -104
- package/dist/_libs/fresh.mjs +85 -0
- package/dist/_libs/function-bind.mjs +63 -0
- package/dist/_libs/gen-mapping.mjs +612 -0
- package/dist/_libs/giget.mjs +19076 -0
- package/dist/_libs/gzip-size.mjs +21 -0
- package/dist/_libs/hasown.mjs +14 -0
- package/dist/_libs/http-errors.mjs +436 -0
- package/dist/_libs/httpxy.mjs +410 -0
- package/dist/_libs/is-core-module.mjs +220 -0
- package/dist/_libs/is-module.mjs +13 -0
- package/dist/_libs/is-reference.mjs +32 -0
- package/dist/{_chunks/_deps → _libs}/js-tokens.mjs +83 -112
- package/dist/_libs/klona.mjs +90 -0
- package/dist/_libs/knitwork.mjs +124 -0
- package/dist/_libs/local-pkg.mjs +1686 -0
- package/dist/{_chunks/_deps → _libs}/magic-string.mjs +272 -629
- package/dist/_libs/mime-db.mjs +7642 -0
- package/dist/_libs/mime-types.mjs +162 -0
- package/dist/_libs/mime.mjs +1391 -0
- package/dist/_libs/node-fetch-native.mjs +173 -0
- package/dist/_libs/on-finished.mjs +170 -0
- package/dist/_libs/parseurl.mjs +103 -0
- package/dist/_libs/path-parse.mjs +47 -0
- package/dist/_libs/pathe.mjs +41 -0
- package/dist/_libs/picomatch.mjs +1673 -0
- package/dist/_libs/plugin-alias.mjs +64 -0
- package/dist/_libs/plugin-commonjs.mjs +1489 -0
- package/dist/_libs/plugin-inject.mjs +135 -0
- package/dist/_libs/plugin-json.mjs +36 -0
- package/dist/_libs/plugin-node-resolve.mjs +1553 -0
- package/dist/_libs/plugin-replace.mjs +104 -0
- package/dist/_libs/pretty-bytes.mjs +116 -0
- package/dist/_libs/range-parser.mjs +102 -0
- package/dist/_libs/remapping.mjs +117 -0
- package/dist/{_chunks/_deps → _libs}/rou3.mjs +7 -22
- package/dist/_libs/send.mjs +857 -0
- package/dist/_libs/serve-static.mjs +124 -0
- package/dist/_libs/std-env.mjs +158 -0
- package/dist/_libs/strip-literal.mjs +51 -0
- package/dist/{_chunks/_deps → _libs}/tinyglobby.mjs +32 -33
- package/dist/_libs/ultrahtml.mjs +138 -0
- package/dist/_libs/unimport.mjs +3520 -0
- package/dist/_libs/untyped.mjs +271 -0
- package/dist/_libs/unwasm.mjs +5825 -0
- package/dist/{_chunks/_deps/@pi0 → _libs}/vite-plugin-fullstack.mjs +28 -42
- package/dist/_presets.mjs +1723 -0
- package/dist/builder.d.mts +37 -35
- package/dist/builder.mjs +45 -117
- package/dist/cli/_chunks/build.mjs +43 -0
- package/dist/cli/_chunks/common.mjs +15 -0
- package/dist/cli/_chunks/detect-acorn.mjs +12 -0
- package/dist/cli/_chunks/dev.mjs +79 -0
- package/dist/cli/_chunks/dist.mjs +3 -0
- package/dist/cli/_chunks/dist2.mjs +4 -0
- package/dist/cli/_chunks/esm.mjs +3 -0
- package/dist/cli/_chunks/json5.mjs +4 -0
- package/dist/cli/_chunks/jsonc.mjs +4 -0
- package/dist/cli/_chunks/list.mjs +27 -0
- package/dist/cli/_chunks/multipart-parser.mjs +6 -0
- package/dist/cli/_chunks/prepare.mjs +19 -0
- package/dist/cli/_chunks/run.mjs +55 -0
- package/dist/cli/_chunks/task.mjs +16 -0
- package/dist/cli/_chunks/toml.mjs +4 -0
- package/dist/cli/_chunks/yaml.mjs +4 -0
- package/dist/cli/index.d.mts +1 -1
- package/dist/cli/index.mjs +19 -18
- package/dist/presets/_nitro/runtime/nitro-dev.d.mts +1 -0
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +42 -33
- package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +2 -2
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +4 -8
- package/dist/presets/_nitro/runtime/service-worker.d.mts +1 -0
- package/dist/presets/_nitro/runtime/service-worker.mjs +14 -11
- package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +1 -0
- package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +6 -5
- package/dist/presets/aws-lambda/runtime/_utils.d.mts +8 -13
- package/dist/presets/aws-lambda/runtime/_utils.mjs +95 -81
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +1 -2
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +25 -27
- package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +7 -7
- package/dist/presets/azure/runtime/_utils.mjs +43 -43
- package/dist/presets/azure/runtime/azure-swa.d.mts +2 -2
- package/dist/presets/azure/runtime/azure-swa.mjs +22 -21
- package/dist/presets/bun/runtime/bun.d.mts +1 -0
- package/dist/presets/bun/runtime/bun.mjs +18 -17
- package/dist/presets/cloudflare/runtime/_module-handler.d.mts +10 -7
- package/dist/presets/cloudflare/runtime/_module-handler.mjs +78 -87
- package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +6 -14
- package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +53 -58
- package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +1 -7
- package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +12 -14
- package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +12 -12
- package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +35 -39
- package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +2 -2
- package/dist/presets/cloudflare/runtime/plugin.dev.mjs +86 -76
- package/dist/presets/deno/runtime/deno-deploy.d.mts +1 -0
- package/dist/presets/deno/runtime/deno-deploy.mjs +12 -11
- package/dist/presets/deno/runtime/deno-server.d.mts +2 -1
- package/dist/presets/deno/runtime/deno-server.mjs +31 -39
- package/dist/presets/netlify/runtime/netlify-edge.d.mts +2 -1
- package/dist/presets/netlify/runtime/netlify-edge.mjs +14 -11
- package/dist/presets/netlify/runtime/netlify.mjs +11 -17
- package/dist/presets/node/runtime/node-cluster.mjs +49 -48
- package/dist/presets/node/runtime/node-middleware.d.mts +3 -2
- package/dist/presets/node/runtime/node-middleware.mjs +7 -6
- package/dist/presets/node/runtime/node-server.mjs +33 -23
- package/dist/presets/standard/runtime/server.d.mts +1 -3
- package/dist/presets/standard/runtime/server.mjs +1 -3
- package/dist/presets/stormkit/runtime/stormkit.d.mts +13 -13
- package/dist/presets/stormkit/runtime/stormkit.mjs +20 -20
- package/dist/presets/vercel/runtime/vercel.d.mts +3 -3
- package/dist/presets/vercel/runtime/vercel.mjs +15 -14
- package/dist/presets/winterjs/runtime/winterjs.d.mts +2 -0
- package/dist/presets/winterjs/runtime/winterjs.mjs +72 -68
- package/dist/presets/zeabur/runtime/zeabur.d.mts +1 -1
- package/dist/runtime/index.d.mts +12 -1
- package/dist/runtime/index.mjs +12 -7
- package/dist/runtime/internal/app.mjs +175 -162
- package/dist/runtime/internal/cache.d.mts +10 -4
- package/dist/runtime/internal/cache.mjs +247 -216
- package/dist/runtime/internal/context.d.mts +9 -9
- package/dist/runtime/internal/context.mjs +17 -10
- package/dist/runtime/internal/database.mjs +8 -10
- package/dist/runtime/internal/error/dev.d.mts +5 -4
- package/dist/runtime/internal/error/dev.mjs +106 -105
- package/dist/runtime/internal/error/prod.d.mts +2 -2
- package/dist/runtime/internal/error/prod.mjs +48 -52
- package/dist/runtime/internal/error/utils.d.mts +4 -4
- package/dist/runtime/internal/error/utils.mjs +1 -1
- package/dist/runtime/internal/index.d.mts +2 -0
- package/dist/runtime/internal/index.mjs +2 -0
- package/dist/runtime/internal/lib/http-graceful-shutdown.d.mts +14 -14
- package/dist/runtime/internal/lib/http-graceful-shutdown.mjs +248 -209
- package/dist/runtime/internal/meta.d.mts +1 -1
- package/dist/runtime/internal/meta.mjs +1 -1
- package/dist/runtime/internal/plugin.d.mts +2 -2
- package/dist/runtime/internal/plugin.mjs +1 -1
- package/dist/runtime/internal/renderer.mjs +39 -31
- package/dist/runtime/internal/route-rules.d.mts +8 -8
- package/dist/runtime/internal/route-rules.mjs +53 -51
- package/dist/runtime/internal/routes/dev-tasks.d.mts +1 -30
- package/dist/runtime/internal/routes/dev-tasks.mjs +15 -17
- package/dist/runtime/internal/routes/openapi.d.mts +1 -0
- package/dist/runtime/internal/routes/openapi.mjs +81 -87
- package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
- package/dist/runtime/internal/routes/renderer-template.dev.d.mts +1 -2
- package/dist/runtime/internal/routes/renderer-template.dev.mjs +10 -17
- package/dist/runtime/internal/routes/renderer-template.mjs +1 -1
- package/dist/runtime/internal/routes/scalar.d.mts +1 -0
- package/dist/runtime/internal/routes/scalar.mjs +22 -23
- package/dist/runtime/internal/routes/swagger.d.mts +1 -0
- package/dist/runtime/internal/routes/swagger.mjs +9 -11
- package/dist/runtime/internal/runtime-config.d.mts +4 -4
- package/dist/runtime/internal/runtime-config.mjs +40 -35
- package/dist/runtime/internal/shutdown.d.mts +2 -7
- package/dist/runtime/internal/shutdown.mjs +30 -29
- package/dist/runtime/internal/static.mjs +63 -74
- package/dist/runtime/internal/storage.mjs +2 -2
- package/dist/runtime/internal/task.d.mts +6 -6
- package/dist/runtime/internal/task.mjs +56 -59
- package/dist/runtime/internal/utils.d.mts +1 -1
- package/dist/runtime/internal/utils.mjs +4 -10
- package/dist/types/index.d.mts +2566 -3851
- package/dist/types/index.mjs +1 -1
- package/dist/vite.d.mts +61 -51
- package/dist/vite.mjs +55 -132
- package/package.json +10 -10
- package/dist/_build/build.mjs +0 -368
- package/dist/_build/build2.mjs +0 -556
- package/dist/_build/info.mjs +0 -1002
- package/dist/_build/prepare.mjs +0 -1511
- package/dist/_build/snapshot.mjs +0 -185
- package/dist/_build/vite.mjs +0 -959
- package/dist/_build/vite2.mjs +0 -149
- package/dist/_chunks/_deps/@jridgewell/gen-mapping.mjs +0 -189
- package/dist/_chunks/_deps/@jridgewell/remapping.mjs +0 -137
- package/dist/_chunks/_deps/@jridgewell/resolve-uri.mjs +0 -231
- package/dist/_chunks/_deps/@jridgewell/sourcemap-codec.mjs +0 -173
- package/dist/_chunks/_deps/@jridgewell/trace-mapping.mjs +0 -170
- package/dist/_chunks/_deps/@rollup/plugin-alias.mjs +0 -89
- package/dist/_chunks/_deps/@rollup/plugin-commonjs.mjs +0 -2376
- package/dist/_chunks/_deps/@rollup/plugin-inject.mjs +0 -212
- package/dist/_chunks/_deps/@rollup/plugin-json.mjs +0 -37
- package/dist/_chunks/_deps/@rollup/plugin-node-resolve.mjs +0 -1386
- package/dist/_chunks/_deps/@rollup/plugin-replace.mjs +0 -133
- package/dist/_chunks/_deps/@rollup/pluginutils.mjs +0 -346
- package/dist/_chunks/_deps/acorn.mjs +0 -6225
- package/dist/_chunks/_deps/c12.mjs +0 -510
- package/dist/_chunks/_deps/chokidar.mjs +0 -1428
- package/dist/_chunks/_deps/citty.mjs +0 -460
- package/dist/_chunks/_deps/commondir.mjs +0 -77
- package/dist/_chunks/_deps/compatx.mjs +0 -76
- package/dist/_chunks/_deps/confbox.mjs +0 -300
- package/dist/_chunks/_deps/debug.mjs +0 -885
- package/dist/_chunks/_deps/deepmerge.mjs +0 -147
- package/dist/_chunks/_deps/depd.mjs +0 -550
- package/dist/_chunks/_deps/dot-prop.mjs +0 -282
- package/dist/_chunks/_deps/dotenv.mjs +0 -555
- package/dist/_chunks/_deps/duplexer.mjs +0 -1
- package/dist/_chunks/_deps/ee-first.mjs +0 -104
- package/dist/_chunks/_deps/encodeurl.mjs +0 -69
- package/dist/_chunks/_deps/escape-html.mjs +0 -87
- package/dist/_chunks/_deps/escape-string-regexp.mjs +0 -13
- package/dist/_chunks/_deps/estree-walker.mjs +0 -433
- package/dist/_chunks/_deps/etag.mjs +0 -147
- package/dist/_chunks/_deps/exsolve.mjs +0 -1416
- package/dist/_chunks/_deps/fresh.mjs +0 -145
- package/dist/_chunks/_deps/function-bind.mjs +0 -106
- package/dist/_chunks/_deps/giget.mjs +0 -451
- package/dist/_chunks/_deps/gzip-size.mjs +0 -19
- package/dist/_chunks/_deps/hasown.mjs +0 -19
- package/dist/_chunks/_deps/http-errors.mjs +0 -307
- package/dist/_chunks/_deps/httpxy.mjs +0 -580
- package/dist/_chunks/_deps/inherits.mjs +0 -57
- package/dist/_chunks/_deps/is-core-module.mjs +0 -596
- package/dist/_chunks/_deps/is-module.mjs +0 -25
- package/dist/_chunks/_deps/is-reference.mjs +0 -31
- package/dist/_chunks/_deps/klona.mjs +0 -137
- package/dist/_chunks/_deps/knitwork.mjs +0 -172
- package/dist/_chunks/_deps/local-pkg.mjs +0 -163
- package/dist/_chunks/_deps/mime-db.mjs +0 -11685
- package/dist/_chunks/_deps/mime-types.mjs +0 -287
- package/dist/_chunks/_deps/mime.mjs +0 -1172
- package/dist/_chunks/_deps/mlly.mjs +0 -2413
- package/dist/_chunks/_deps/ms.mjs +0 -172
- package/dist/_chunks/_deps/node-fetch-native.mjs +0 -3
- package/dist/_chunks/_deps/nypm.mjs +0 -219
- package/dist/_chunks/_deps/on-finished.mjs +0 -246
- package/dist/_chunks/_deps/parseurl.mjs +0 -168
- package/dist/_chunks/_deps/path-parse.mjs +0 -85
- package/dist/_chunks/_deps/pathe.mjs +0 -251
- package/dist/_chunks/_deps/perfect-debounce.mjs +0 -88
- package/dist/_chunks/_deps/picomatch.mjs +0 -2144
- package/dist/_chunks/_deps/pkg-types.mjs +0 -247
- package/dist/_chunks/_deps/pretty-bytes.mjs +0 -180
- package/dist/_chunks/_deps/quansync.mjs +0 -99
- package/dist/_chunks/_deps/range-parser.mjs +0 -171
- package/dist/_chunks/_deps/rc9.mjs +0 -219
- package/dist/_chunks/_deps/readdirp.mjs +0 -245
- package/dist/_chunks/_deps/resolve.mjs +0 -1260
- package/dist/_chunks/_deps/send.mjs +0 -1022
- package/dist/_chunks/_deps/serve-static.mjs +0 -228
- package/dist/_chunks/_deps/setprototypeof.mjs +0 -26
- package/dist/_chunks/_deps/statuses.mjs +0 -457
- package/dist/_chunks/_deps/std-env.mjs +0 -3
- package/dist/_chunks/_deps/strip-literal.mjs +0 -67
- package/dist/_chunks/_deps/supports-color.mjs +0 -44
- package/dist/_chunks/_deps/tinyexec.mjs +0 -552
- package/dist/_chunks/_deps/toidentifier.mjs +0 -41
- package/dist/_chunks/_deps/ultrahtml.mjs +0 -3
- package/dist/_chunks/_deps/unimport.mjs +0 -2267
- package/dist/_chunks/_deps/unplugin-utils.mjs +0 -65
- package/dist/_chunks/_deps/unplugin.mjs +0 -1294
- package/dist/_chunks/_deps/untyped.mjs +0 -375
- package/dist/_chunks/_deps/unwasm.mjs +0 -6959
- package/dist/_chunks/_deps/webpack-virtual-modules.mjs +0 -360
- package/dist/_chunks/_presets/_all.mjs +0 -59
- package/dist/_chunks/_presets/_nitro.mjs +0 -74
- package/dist/_chunks/_presets/_resolve.mjs +0 -64
- package/dist/_chunks/_presets/_static.mjs +0 -69
- package/dist/_chunks/_presets/_types.mjs +0 -3
- package/dist/_chunks/_presets/_utils.mjs +0 -31
- package/dist/_chunks/_presets/alwaysdata.mjs +0 -17
- package/dist/_chunks/_presets/aws-amplify.mjs +0 -111
- package/dist/_chunks/_presets/aws-lambda.mjs +0 -23
- package/dist/_chunks/_presets/azure.mjs +0 -162
- package/dist/_chunks/_presets/bun.mjs +0 -19
- package/dist/_chunks/_presets/cleavr.mjs +0 -15
- package/dist/_chunks/_presets/cloudflare.mjs +0 -608
- package/dist/_chunks/_presets/deno.mjs +0 -196
- package/dist/_chunks/_presets/digitalocean.mjs +0 -14
- package/dist/_chunks/_presets/firebase.mjs +0 -47
- package/dist/_chunks/_presets/flightcontrol.mjs +0 -14
- package/dist/_chunks/_presets/genezio.mjs +0 -13
- package/dist/_chunks/_presets/heroku.mjs +0 -14
- package/dist/_chunks/_presets/iis.mjs +0 -194
- package/dist/_chunks/_presets/index.mjs +0 -62
- package/dist/_chunks/_presets/koyeb.mjs +0 -14
- package/dist/_chunks/_presets/netlify.mjs +0 -241
- package/dist/_chunks/_presets/node.mjs +0 -54
- package/dist/_chunks/_presets/platform.mjs +0 -14
- package/dist/_chunks/_presets/render.mjs +0 -14
- package/dist/_chunks/_presets/standard.mjs +0 -23
- package/dist/_chunks/_presets/stormkit.mjs +0 -18
- package/dist/_chunks/_presets/vercel.mjs +0 -375
- package/dist/_chunks/_presets/winterjs.mjs +0 -22
- package/dist/_chunks/_presets/zeabur.mjs +0 -69
- package/dist/_chunks/_presets/zerops.mjs +0 -27
- package/dist/_chunks/app.mjs +0 -600
- package/dist/_chunks/builder.mjs +0 -648
- package/dist/_chunks/server.mjs +0 -256
- package/dist/_cli/build.mjs +0 -49
- package/dist/_cli/common.mjs +0 -13
- package/dist/_cli/dev.mjs +0 -121
- package/dist/_cli/index.mjs +0 -16
- package/dist/_cli/list.mjs +0 -33
- package/dist/_cli/prepare.mjs +0 -23
- package/dist/_cli/run.mjs +0 -59
- package/dist/presets/cloudflare/runtime/shims/workers.dev.d.mts +0 -21
- package/dist/runtime/internal/empty.d.mts +0 -0
- package/dist/runtime/internal/vite/dev-entry.d.mts +0 -1
- package/dist/runtime/internal/vite/dev-worker.d.mts +0 -1
- package/dist/runtime/internal/vite/prod-setup.d.mts +0 -4
- package/dist/runtime/internal/vite/ssr-renderer.d.mts +0 -4
- /package/lib/{indexd.mts → index.d.mts} +0 -0
|
@@ -0,0 +1,3520 @@
|
|
|
1
|
+
import { i as __require, s as __toESM, t as __commonJS } from "../_chunks/DXMHy5ca.mjs";
|
|
2
|
+
import { C as parse$2, T as resolve$1, _ as dirname$1, b as join$1, d as resolvePackageJSON, g as basename$1, l as readPackageJSON, w as relative$1, x as normalize$2, y as isAbsolute$1 } from "./c12.mjs";
|
|
3
|
+
import { t as MagicString } from "./magic-string.mjs";
|
|
4
|
+
import { n as parse, t as Parser } from "./acorn.mjs";
|
|
5
|
+
import { a as findStaticImports, d as resolveModuleExportNames, i as findExports, l as parseStaticImport, n as detectSyntax, o as findTypeExports, t as resolveModule, u as resolve$2 } from "./local-pkg.mjs";
|
|
6
|
+
import { t as stripLiteral } from "./strip-literal.mjs";
|
|
7
|
+
import { t as require_picomatch } from "./picomatch.mjs";
|
|
8
|
+
import { t as glob } from "./tinyglobby.mjs";
|
|
9
|
+
import { t as walk } from "./estree-walker.mjs";
|
|
10
|
+
import { t as remapping } from "./remapping.mjs";
|
|
11
|
+
import { createRequire } from "node:module";
|
|
12
|
+
import path, { basename, dirname, extname, isAbsolute, normalize, resolve } from "node:path";
|
|
13
|
+
import process$1 from "node:process";
|
|
14
|
+
import { camelCase, kebabCase } from "scule";
|
|
15
|
+
import fs, { accessSync, constants, existsSync, promises, readFileSync } from "node:fs";
|
|
16
|
+
import { fileURLToPath } from "node:url";
|
|
17
|
+
import { readFile } from "node:fs/promises";
|
|
18
|
+
import os from "node:os";
|
|
19
|
+
import { Buffer } from "node:buffer";
|
|
20
|
+
import * as querystring from "node:querystring";
|
|
21
|
+
|
|
22
|
+
//#region node_modules/.pnpm/unimport@5.5.0/node_modules/unimport/dist/shared/unimport.rkT0nXLK.mjs
|
|
23
|
+
const excludeRE = [
|
|
24
|
+
/\b(import|export)\b([\w$*{},\s]+?)\bfrom\s*["']/g,
|
|
25
|
+
/\bfunction\s*([\w$]+)\s*\(/g,
|
|
26
|
+
/\bclass\s*([\w$]+)\s*\{/g,
|
|
27
|
+
/\b(?:const|let|var)\s+?(\[.*?\]|\{.*?\}|.+?)\s*?[=;\n]/gs
|
|
28
|
+
];
|
|
29
|
+
const importAsRE = /^.*\sas\s+/;
|
|
30
|
+
const separatorRE = /[,[\]{}\n]|\b(?:import|export)\b/g;
|
|
31
|
+
const matchRE = /(^|\.\.\.|(?:\bcase|\?)\s+|[^\w$/)]|\bextends\s+)([\w$]+)\s*(?=[.()[\]}:;?+\-*&|`<>,\n]|\b(?:instanceof|in)\b|$|(?<=extends\s+\w+)\s+\{)/g;
|
|
32
|
+
const regexRE = /\/\S*?(?<!\\)(?<!\[[^\]]*)\/[gimsuy]*/g;
|
|
33
|
+
function stripCommentsAndStrings(code, options) {
|
|
34
|
+
return stripLiteral(code, options).replace(regexRE, "new RegExp(\"\")");
|
|
35
|
+
}
|
|
36
|
+
function defineUnimportPreset(preset) {
|
|
37
|
+
return preset;
|
|
38
|
+
}
|
|
39
|
+
const identifierRE = /^[A-Z_$][\w$]*$/i;
|
|
40
|
+
const safePropertyName = /^[a-z$_][\w$]*$/i;
|
|
41
|
+
function stringifyWith(withValues) {
|
|
42
|
+
let withDefs = "";
|
|
43
|
+
for (let entries = Object.entries(withValues), l = entries.length, i = 0; i < l; i++) {
|
|
44
|
+
const [prop, value] = entries[i];
|
|
45
|
+
withDefs += safePropertyName.test(prop) ? prop : JSON.stringify(prop);
|
|
46
|
+
withDefs += `: ${JSON.stringify(String(value))}`;
|
|
47
|
+
if (i + 1 !== l) withDefs += ", ";
|
|
48
|
+
}
|
|
49
|
+
return `{ ${withDefs} }`;
|
|
50
|
+
}
|
|
51
|
+
function stringifyImports(imports, isCJS = false) {
|
|
52
|
+
const map = toImportModuleMap(imports);
|
|
53
|
+
return Object.entries(map).flatMap(([name, importSet]) => {
|
|
54
|
+
const entries = [];
|
|
55
|
+
const imports2 = Array.from(importSet).filter((i) => {
|
|
56
|
+
if (!i.name || i.as === "") {
|
|
57
|
+
let importStr;
|
|
58
|
+
if (isCJS) importStr = `require('${name}');`;
|
|
59
|
+
else {
|
|
60
|
+
importStr = `import '${name}'`;
|
|
61
|
+
if (i.with) importStr += ` with ${stringifyWith(i.with)}`;
|
|
62
|
+
importStr += ";";
|
|
63
|
+
}
|
|
64
|
+
entries.push(importStr);
|
|
65
|
+
return false;
|
|
66
|
+
} else if (i.name === "default" || i.name === "=") {
|
|
67
|
+
let importStr;
|
|
68
|
+
if (isCJS) importStr = i.name === "=" ? `const ${i.as} = require('${name}');` : `const { default: ${i.as} } = require('${name}');`;
|
|
69
|
+
else {
|
|
70
|
+
importStr = `import ${i.as} from '${name}'`;
|
|
71
|
+
if (i.with) importStr += ` with ${stringifyWith(i.with)}`;
|
|
72
|
+
importStr += ";";
|
|
73
|
+
}
|
|
74
|
+
entries.push(importStr);
|
|
75
|
+
return false;
|
|
76
|
+
} else if (i.name === "*") {
|
|
77
|
+
let importStr;
|
|
78
|
+
if (isCJS) importStr = `const ${i.as} = require('${name}');`;
|
|
79
|
+
else {
|
|
80
|
+
importStr = `import * as ${i.as} from '${name}'`;
|
|
81
|
+
if (i.with) importStr += ` with ${stringifyWith(i.with)}`;
|
|
82
|
+
importStr += ";";
|
|
83
|
+
}
|
|
84
|
+
entries.push(importStr);
|
|
85
|
+
return false;
|
|
86
|
+
} else if (!isCJS && i.with) {
|
|
87
|
+
entries.push(`import { ${stringifyImportAlias(i)} } from '${name}' with ${stringifyWith(i.with)};`);
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
});
|
|
92
|
+
if (imports2.length) {
|
|
93
|
+
const importsAs = imports2.map((i) => stringifyImportAlias(i, isCJS));
|
|
94
|
+
entries.push(isCJS ? `const { ${importsAs.join(", ")} } = require('${name}');` : `import { ${importsAs.join(", ")} } from '${name}';`);
|
|
95
|
+
}
|
|
96
|
+
return entries;
|
|
97
|
+
}).join("\n");
|
|
98
|
+
}
|
|
99
|
+
function dedupeImports(imports, warn) {
|
|
100
|
+
const map = /* @__PURE__ */ new Map();
|
|
101
|
+
const indexToRemove = /* @__PURE__ */ new Set();
|
|
102
|
+
imports.filter((i) => !i.disabled).forEach((i, idx) => {
|
|
103
|
+
if (i.declarationType === "enum" || i.declarationType === "class") return;
|
|
104
|
+
const name = i.as ?? i.name;
|
|
105
|
+
if (!map.has(name)) {
|
|
106
|
+
map.set(name, idx);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const other = imports[map.get(name)];
|
|
110
|
+
if (other.from === i.from) {
|
|
111
|
+
indexToRemove.add(idx);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const diff = (other.priority || 1) - (i.priority || 1);
|
|
115
|
+
if (diff === 0) warn(`Duplicated imports "${name}", the one from "${other.from}" has been ignored and "${i.from}" is used`);
|
|
116
|
+
if (diff <= 0) {
|
|
117
|
+
indexToRemove.add(map.get(name));
|
|
118
|
+
map.set(name, idx);
|
|
119
|
+
} else indexToRemove.add(idx);
|
|
120
|
+
});
|
|
121
|
+
return imports.filter((_, idx) => !indexToRemove.has(idx));
|
|
122
|
+
}
|
|
123
|
+
function toExports(imports, fileDir, includeType = false) {
|
|
124
|
+
const map = toImportModuleMap(imports, includeType);
|
|
125
|
+
return Object.entries(map).flatMap(([name, imports2]) => {
|
|
126
|
+
if (isFilePath(name)) name = name.replace(/\.[a-z]+$/i, "");
|
|
127
|
+
if (fileDir && isAbsolute$1(name)) {
|
|
128
|
+
name = relative$1(fileDir, name);
|
|
129
|
+
if (!name.match(/^[./]/)) name = `./${name}`;
|
|
130
|
+
}
|
|
131
|
+
const entries = [];
|
|
132
|
+
const filtered = Array.from(imports2).filter((i) => {
|
|
133
|
+
if (i.name === "*") {
|
|
134
|
+
entries.push(`export * as ${i.as} from '${name}';`);
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
return true;
|
|
138
|
+
});
|
|
139
|
+
if (filtered.length) entries.push(`export { ${filtered.map((i) => stringifyImportAlias(i, false)).join(", ")} } from '${name}';`);
|
|
140
|
+
return entries;
|
|
141
|
+
}).join("\n");
|
|
142
|
+
}
|
|
143
|
+
function stripFileExtension(path$1) {
|
|
144
|
+
return path$1.replace(/\.[a-z]+$/i, "");
|
|
145
|
+
}
|
|
146
|
+
function toTypeDeclarationItems(imports, options) {
|
|
147
|
+
return imports.map((i) => {
|
|
148
|
+
const from = options?.resolvePath?.(i) || stripFileExtension(i.typeFrom || i.from);
|
|
149
|
+
let typeDef = "";
|
|
150
|
+
if (i.with) typeDef += `import('${from}', { with: ${stringifyWith(i.with)} })`;
|
|
151
|
+
else typeDef += `import('${from}')`;
|
|
152
|
+
if (i.name !== "*" && i.name !== "=") typeDef += identifierRE.test(i.name) ? `.${i.name}` : `['${i.name}']`;
|
|
153
|
+
return `const ${i.as}: typeof ${typeDef}`;
|
|
154
|
+
}).sort();
|
|
155
|
+
}
|
|
156
|
+
function toTypeDeclarationFile(imports, options) {
|
|
157
|
+
const items = toTypeDeclarationItems(imports, options);
|
|
158
|
+
const { exportHelper = true } = options || {};
|
|
159
|
+
let declaration = "";
|
|
160
|
+
if (exportHelper) declaration += "export {}\n";
|
|
161
|
+
declaration += `declare global {
|
|
162
|
+
${items.map((i) => ` ${i}`).join("\n")}
|
|
163
|
+
}`;
|
|
164
|
+
return declaration;
|
|
165
|
+
}
|
|
166
|
+
function makeTypeModulesMap(imports, resolvePath$1) {
|
|
167
|
+
const modulesMap = /* @__PURE__ */ new Map();
|
|
168
|
+
const resolveImportFrom = typeof resolvePath$1 === "function" ? (i) => {
|
|
169
|
+
return resolvePath$1(i) || stripFileExtension(i.typeFrom || i.from);
|
|
170
|
+
} : (i) => stripFileExtension(i.typeFrom || i.from);
|
|
171
|
+
for (const import_ of imports) {
|
|
172
|
+
const from = resolveImportFrom(import_);
|
|
173
|
+
let module$1 = modulesMap.get(from);
|
|
174
|
+
if (!module$1) {
|
|
175
|
+
module$1 = {
|
|
176
|
+
typeImports: /* @__PURE__ */ new Set(),
|
|
177
|
+
starTypeImport: void 0
|
|
178
|
+
};
|
|
179
|
+
modulesMap.set(from, module$1);
|
|
180
|
+
}
|
|
181
|
+
if (import_.name === "*") {
|
|
182
|
+
if (import_.as) module$1.starTypeImport = import_;
|
|
183
|
+
} else module$1.typeImports.add(import_);
|
|
184
|
+
}
|
|
185
|
+
return modulesMap;
|
|
186
|
+
}
|
|
187
|
+
function toTypeReExports(imports, options) {
|
|
188
|
+
const importsMap = makeTypeModulesMap(imports, options?.resolvePath);
|
|
189
|
+
return `// for type re-export
|
|
190
|
+
declare global {
|
|
191
|
+
${Array.from(importsMap).flatMap(([from, module$1]) => {
|
|
192
|
+
from = from.replace(/\.d\.([cm]?)ts$/i, ".$1js");
|
|
193
|
+
const { starTypeImport, typeImports } = module$1;
|
|
194
|
+
const strings = [];
|
|
195
|
+
if (typeImports.size) {
|
|
196
|
+
const typeImportNames = Array.from(typeImports).map(({ name, as }) => {
|
|
197
|
+
if (as && as !== name) return `${name} as ${as}`;
|
|
198
|
+
return name;
|
|
199
|
+
});
|
|
200
|
+
strings.push("// @ts-ignore", `export type { ${typeImportNames.join(", ")} } from '${from}'`);
|
|
201
|
+
}
|
|
202
|
+
if (starTypeImport) strings.push("// @ts-ignore", `export type * as ${starTypeImport.as} from '${from}'`);
|
|
203
|
+
if (strings.length) strings.push(`import('${from}')`);
|
|
204
|
+
return strings;
|
|
205
|
+
}).map((i) => ` ${i}`).join("\n")}
|
|
206
|
+
}`;
|
|
207
|
+
}
|
|
208
|
+
function stringifyImportAlias(item, isCJS = false) {
|
|
209
|
+
return item.as === void 0 || item.name === item.as ? item.name : isCJS ? `${item.name}: ${item.as}` : `${item.name} as ${item.as}`;
|
|
210
|
+
}
|
|
211
|
+
function toImportModuleMap(imports, includeType = false) {
|
|
212
|
+
const map = {};
|
|
213
|
+
for (const _import of imports) {
|
|
214
|
+
if (_import.type && !includeType) continue;
|
|
215
|
+
if (!map[_import.from]) map[_import.from] = /* @__PURE__ */ new Set();
|
|
216
|
+
map[_import.from].add(_import);
|
|
217
|
+
}
|
|
218
|
+
return map;
|
|
219
|
+
}
|
|
220
|
+
function getMagicString(code) {
|
|
221
|
+
if (typeof code === "string") return new MagicString(code);
|
|
222
|
+
return code;
|
|
223
|
+
}
|
|
224
|
+
function addImportToCode(code, imports, isCJS = false, mergeExisting = false, injectAtLast = false, firstOccurrence = Number.POSITIVE_INFINITY, onResolved, onStringified) {
|
|
225
|
+
let newImports = [];
|
|
226
|
+
const s = getMagicString(code);
|
|
227
|
+
let _staticImports;
|
|
228
|
+
const strippedCode = stripCommentsAndStrings(s.original);
|
|
229
|
+
function findStaticImportsLazy() {
|
|
230
|
+
if (!_staticImports) _staticImports = findStaticImports(s.original).filter((i) => Boolean(strippedCode.slice(i.start, i.end).trim())).map((i) => parseStaticImport(i));
|
|
231
|
+
return _staticImports;
|
|
232
|
+
}
|
|
233
|
+
function hasShebang() {
|
|
234
|
+
return /^#!.+/.test(s.original);
|
|
235
|
+
}
|
|
236
|
+
if (mergeExisting && !isCJS) {
|
|
237
|
+
const existingImports = findStaticImportsLazy();
|
|
238
|
+
const map = /* @__PURE__ */ new Map();
|
|
239
|
+
imports.forEach((i) => {
|
|
240
|
+
const target = existingImports.find((e) => e.specifier === i.from && e.imports.startsWith("{"));
|
|
241
|
+
if (!target) return newImports.push(i);
|
|
242
|
+
if (!map.has(target)) map.set(target, []);
|
|
243
|
+
map.get(target).push(i);
|
|
244
|
+
});
|
|
245
|
+
for (const [target, items] of map.entries()) {
|
|
246
|
+
const strings = items.map((i) => `${stringifyImportAlias(i)}, `);
|
|
247
|
+
const importLength = target.code.match(/^\s*import\s*\{/)?.[0]?.length;
|
|
248
|
+
if (importLength) s.appendLeft(target.start + importLength, ` ${strings.join("").trim()}`);
|
|
249
|
+
}
|
|
250
|
+
} else newImports = imports;
|
|
251
|
+
newImports = onResolved?.(newImports) ?? newImports;
|
|
252
|
+
let newEntries = stringifyImports(newImports, isCJS);
|
|
253
|
+
newEntries = onStringified?.(newEntries, newImports) ?? newEntries;
|
|
254
|
+
if (newEntries) {
|
|
255
|
+
const insertionIndex = injectAtLast ? findStaticImportsLazy().reverse().find((i) => i.end <= firstOccurrence)?.end ?? 0 : 0;
|
|
256
|
+
if (insertionIndex > 0) s.appendRight(insertionIndex, `
|
|
257
|
+
${newEntries}
|
|
258
|
+
`);
|
|
259
|
+
else if (hasShebang()) s.appendLeft(s.original.indexOf("\n") + 1, `
|
|
260
|
+
${newEntries}
|
|
261
|
+
`);
|
|
262
|
+
else s.prepend(`${newEntries}
|
|
263
|
+
`);
|
|
264
|
+
}
|
|
265
|
+
return {
|
|
266
|
+
s,
|
|
267
|
+
get code() {
|
|
268
|
+
return s.toString();
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
function normalizeImports(imports) {
|
|
273
|
+
for (const _import of imports) _import.as = _import.as ?? _import.name;
|
|
274
|
+
return imports;
|
|
275
|
+
}
|
|
276
|
+
function isFilePath(path$1) {
|
|
277
|
+
return path$1.startsWith(".") || isAbsolute$1(path$1) || path$1.includes("://");
|
|
278
|
+
}
|
|
279
|
+
const contextRE$1 = /\b_ctx\.([$\w]+)\b/g;
|
|
280
|
+
const UNREF_KEY = "__unimport_unref_";
|
|
281
|
+
const VUE_TEMPLATE_NAME = "unimport:vue-template";
|
|
282
|
+
function vueTemplateAddon() {
|
|
283
|
+
const self = {
|
|
284
|
+
name: VUE_TEMPLATE_NAME,
|
|
285
|
+
async transform(s, id) {
|
|
286
|
+
if (!s.original.includes("_ctx.") || s.original.includes(UNREF_KEY)) return s;
|
|
287
|
+
const matches = Array.from(s.original.matchAll(contextRE$1));
|
|
288
|
+
const imports = await this.getImports();
|
|
289
|
+
let targets = [];
|
|
290
|
+
for (const match of matches) {
|
|
291
|
+
const name = match[1];
|
|
292
|
+
const item = imports.find((i) => i.as === name);
|
|
293
|
+
if (!item) continue;
|
|
294
|
+
const start = match.index;
|
|
295
|
+
const end = start + match[0].length;
|
|
296
|
+
const tempName = `__unimport_${name}`;
|
|
297
|
+
s.overwrite(start, end, `(${JSON.stringify(name)} in _ctx ? _ctx.${name} : ${UNREF_KEY}(${tempName}))`);
|
|
298
|
+
if (!targets.find((i) => i.as === tempName)) targets.push({
|
|
299
|
+
...item,
|
|
300
|
+
as: tempName
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
if (targets.length) {
|
|
304
|
+
targets.push({
|
|
305
|
+
name: "unref",
|
|
306
|
+
from: "vue",
|
|
307
|
+
as: UNREF_KEY
|
|
308
|
+
});
|
|
309
|
+
for (const addon of this.addons) {
|
|
310
|
+
if (addon === self) continue;
|
|
311
|
+
targets = await addon.injectImportsResolved?.call(this, targets, s, id) ?? targets;
|
|
312
|
+
}
|
|
313
|
+
let injection = stringifyImports(targets);
|
|
314
|
+
for (const addon of this.addons) {
|
|
315
|
+
if (addon === self) continue;
|
|
316
|
+
injection = await addon.injectImportsStringified?.call(this, injection, targets, s, id) ?? injection;
|
|
317
|
+
}
|
|
318
|
+
s.prepend(injection);
|
|
319
|
+
}
|
|
320
|
+
return s;
|
|
321
|
+
},
|
|
322
|
+
async declaration(dts, options) {
|
|
323
|
+
return `${dts}
|
|
324
|
+
// for vue template auto import
|
|
325
|
+
import { UnwrapRef } from 'vue'
|
|
326
|
+
declare module 'vue' {
|
|
327
|
+
interface ComponentCustomProperties {
|
|
328
|
+
${(await this.getImports()).map((i) => {
|
|
329
|
+
if (i.type || i.dtsDisabled) return "";
|
|
330
|
+
const from = options?.resolvePath?.(i) || i.from;
|
|
331
|
+
return `readonly ${i.as}: UnwrapRef<typeof import('${from}')${i.name !== "*" ? `['${i.name}']` : ""}>`;
|
|
332
|
+
}).filter(Boolean).sort().map((i) => ` ${i}`).join("\n")}
|
|
333
|
+
}
|
|
334
|
+
}`;
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
return self;
|
|
338
|
+
}
|
|
339
|
+
const contextRE = /resolveDirective as _resolveDirective/;
|
|
340
|
+
const contextText = `${contextRE.source}, `;
|
|
341
|
+
const directiveRE = /(?:var|const) (\w+) = _resolveDirective\("([\w.-]+)"\);?\s*/g;
|
|
342
|
+
const VUE_DIRECTIVES_NAME = "unimport:vue-directives";
|
|
343
|
+
function vueDirectivesAddon(options = {}) {
|
|
344
|
+
function isDirective(importEntry) {
|
|
345
|
+
let isDirective2 = importEntry.meta?.vueDirective === true;
|
|
346
|
+
if (isDirective2) return true;
|
|
347
|
+
isDirective2 = options.isDirective?.(normalizePath$1(process$1.cwd(), importEntry.from), importEntry) ?? false;
|
|
348
|
+
if (isDirective2) {
|
|
349
|
+
importEntry.meta ??= {};
|
|
350
|
+
importEntry.meta.vueDirective = true;
|
|
351
|
+
}
|
|
352
|
+
return isDirective2;
|
|
353
|
+
}
|
|
354
|
+
const self = {
|
|
355
|
+
name: VUE_DIRECTIVES_NAME,
|
|
356
|
+
async transform(s, id) {
|
|
357
|
+
if (!s.original.match(contextRE)) return s;
|
|
358
|
+
const matches = Array.from(s.original.matchAll(directiveRE)).sort((a, b) => b.index - a.index);
|
|
359
|
+
if (!matches.length) return s;
|
|
360
|
+
let targets = [];
|
|
361
|
+
for await (const [begin, end, importEntry] of findDirectives(isDirective, matches, this.getImports())) {
|
|
362
|
+
s.overwrite(begin, end, "");
|
|
363
|
+
targets.push(importEntry);
|
|
364
|
+
}
|
|
365
|
+
if (!targets.length) return s;
|
|
366
|
+
if (!s.toString().match(directiveRE)) s.replace(contextText, "");
|
|
367
|
+
for (const addon of this.addons) {
|
|
368
|
+
if (addon === self) continue;
|
|
369
|
+
targets = await addon.injectImportsResolved?.call(this, targets, s, id) ?? targets;
|
|
370
|
+
}
|
|
371
|
+
let injection = stringifyImports(targets);
|
|
372
|
+
for (const addon of this.addons) {
|
|
373
|
+
if (addon === self) continue;
|
|
374
|
+
injection = await addon.injectImportsStringified?.call(this, injection, targets, s, id) ?? injection;
|
|
375
|
+
}
|
|
376
|
+
s.prepend(injection);
|
|
377
|
+
return s;
|
|
378
|
+
},
|
|
379
|
+
async declaration(dts, options2) {
|
|
380
|
+
const directivesMap = await this.getImports().then((imports) => {
|
|
381
|
+
return imports.filter(isDirective).reduce((acc, i) => {
|
|
382
|
+
if (i.type || i.dtsDisabled) return acc;
|
|
383
|
+
let name;
|
|
384
|
+
if (i.name === "default" && (i.as === "default" || !i.as)) {
|
|
385
|
+
const file = basename(i.from);
|
|
386
|
+
const idx = file.indexOf(".");
|
|
387
|
+
name = idx > -1 ? file.slice(0, idx) : file;
|
|
388
|
+
} else name = i.as ?? i.name;
|
|
389
|
+
name = name[0] === "v" ? camelCase(name) : camelCase(`v-${name}`);
|
|
390
|
+
if (!acc.has(name)) acc.set(name, i);
|
|
391
|
+
return acc;
|
|
392
|
+
}, /* @__PURE__ */ new Map());
|
|
393
|
+
});
|
|
394
|
+
if (!directivesMap.size) return dts;
|
|
395
|
+
return `${dts}
|
|
396
|
+
// for vue directives auto import
|
|
397
|
+
declare module 'vue' {
|
|
398
|
+
interface GlobalDirectives {
|
|
399
|
+
${Array.from(directivesMap.entries()).map(([name, i]) => ` ${name}: typeof import('${options2?.resolvePath?.(i) || i.from}')['${i.name}']`).sort().join("\n")}
|
|
400
|
+
}
|
|
401
|
+
}`;
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
return self;
|
|
405
|
+
}
|
|
406
|
+
function resolvePath(cwd, path$1) {
|
|
407
|
+
return path$1[0] === "." ? resolve$1(cwd, path$1) : path$1;
|
|
408
|
+
}
|
|
409
|
+
function normalizePath$1(cwd, path$1) {
|
|
410
|
+
return resolvePath(cwd, path$1).replace(/\\/g, "/");
|
|
411
|
+
}
|
|
412
|
+
async function* findDirectives(isDirective, regexArray, importsPromise) {
|
|
413
|
+
const imports = (await importsPromise).filter(isDirective);
|
|
414
|
+
if (!imports.length) return;
|
|
415
|
+
const symbols = regexArray.reduce((acc, regex) => {
|
|
416
|
+
const [all, symbol, resolveDirectiveName] = regex;
|
|
417
|
+
if (acc.has(symbol)) return acc;
|
|
418
|
+
acc.set(symbol, [
|
|
419
|
+
regex.index,
|
|
420
|
+
regex.index + all.length,
|
|
421
|
+
kebabCase(resolveDirectiveName)
|
|
422
|
+
]);
|
|
423
|
+
return acc;
|
|
424
|
+
}, /* @__PURE__ */ new Map());
|
|
425
|
+
for (const [symbol, data] of symbols.entries()) yield* findDirective(imports, symbol, data);
|
|
426
|
+
}
|
|
427
|
+
function* findDirective(imports, symbol, [begin, end, importName]) {
|
|
428
|
+
let resolvedName;
|
|
429
|
+
for (const i of imports) {
|
|
430
|
+
if (i.name === "default" && (i.as === "default" || !i.as)) {
|
|
431
|
+
const file = basename(i.from);
|
|
432
|
+
const idx = file.indexOf(".");
|
|
433
|
+
resolvedName = kebabCase(idx > -1 ? file.slice(0, idx) : file);
|
|
434
|
+
} else resolvedName = kebabCase(i.as ?? i.name);
|
|
435
|
+
if (resolvedName === importName) {
|
|
436
|
+
yield [
|
|
437
|
+
begin,
|
|
438
|
+
end,
|
|
439
|
+
{
|
|
440
|
+
...i,
|
|
441
|
+
name: i.name,
|
|
442
|
+
as: symbol
|
|
443
|
+
}
|
|
444
|
+
];
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
if (resolvedName[0] === "v") resolvedName = resolvedName.slice(resolvedName[1] === "-" ? 2 : 1);
|
|
448
|
+
if (resolvedName === importName) {
|
|
449
|
+
yield [
|
|
450
|
+
begin,
|
|
451
|
+
end,
|
|
452
|
+
{
|
|
453
|
+
...i,
|
|
454
|
+
name: i.name,
|
|
455
|
+
as: symbol
|
|
456
|
+
}
|
|
457
|
+
];
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
//#endregion
|
|
464
|
+
//#region node_modules/.pnpm/unimport@5.5.0/node_modules/unimport/dist/shared/unimport.C1hu2RXM.mjs
|
|
465
|
+
var import_picomatch$2 = /* @__PURE__ */ __toESM(require_picomatch(), 1);
|
|
466
|
+
const version = "5.5.0";
|
|
467
|
+
function configureAddons(opts) {
|
|
468
|
+
const addons = [];
|
|
469
|
+
if (Array.isArray(opts.addons)) addons.push(...opts.addons);
|
|
470
|
+
else {
|
|
471
|
+
const addonsMap = /* @__PURE__ */ new Map();
|
|
472
|
+
if (opts.addons?.addons?.length) {
|
|
473
|
+
let i = 0;
|
|
474
|
+
for (const addon of opts.addons.addons) addonsMap.set(addon.name || `external:custom-${i++}`, addon);
|
|
475
|
+
}
|
|
476
|
+
if (opts.addons?.vueTemplate) {
|
|
477
|
+
if (!addonsMap.has(VUE_TEMPLATE_NAME)) addonsMap.set(VUE_TEMPLATE_NAME, vueTemplateAddon());
|
|
478
|
+
}
|
|
479
|
+
if (opts.addons?.vueDirectives) {
|
|
480
|
+
if (!addonsMap.has(VUE_DIRECTIVES_NAME)) addonsMap.set(VUE_DIRECTIVES_NAME, vueDirectivesAddon(typeof opts.addons.vueDirectives === "object" ? opts.addons.vueDirectives : void 0));
|
|
481
|
+
}
|
|
482
|
+
addons.push(...addonsMap.values());
|
|
483
|
+
}
|
|
484
|
+
return addons;
|
|
485
|
+
}
|
|
486
|
+
async function detectImportsRegex(code, ctx, options) {
|
|
487
|
+
const s = getMagicString(code);
|
|
488
|
+
const original = s.original;
|
|
489
|
+
const strippedCode = stripCommentsAndStrings(original, options?.transformVirtualImports !== false && ctx.options.virtualImports?.length ? {
|
|
490
|
+
filter: (i) => !ctx.options.virtualImports.includes(i),
|
|
491
|
+
fillChar: "-"
|
|
492
|
+
} : void 0);
|
|
493
|
+
const syntax = detectSyntax(strippedCode);
|
|
494
|
+
const isCJSContext = syntax.hasCJS && !syntax.hasESM;
|
|
495
|
+
let matchedImports = [];
|
|
496
|
+
const occurrenceMap = /* @__PURE__ */ new Map();
|
|
497
|
+
const map = await ctx.getImportMap();
|
|
498
|
+
if (options?.autoImport !== false) {
|
|
499
|
+
Array.from(strippedCode.matchAll(matchRE)).forEach((i) => {
|
|
500
|
+
if (i[1] === ".") return null;
|
|
501
|
+
const end = strippedCode[i.index + i[0].length];
|
|
502
|
+
const before = strippedCode[i.index - 1];
|
|
503
|
+
if (end === ":" && !["?", "case"].includes(i[1].trim()) && before !== ":") return null;
|
|
504
|
+
const name = i[2];
|
|
505
|
+
const occurrence = i.index + i[1].length;
|
|
506
|
+
if (occurrenceMap.get(name) || Number.POSITIVE_INFINITY > occurrence) occurrenceMap.set(name, occurrence);
|
|
507
|
+
});
|
|
508
|
+
for (const regex of excludeRE) for (const match of strippedCode.matchAll(regex)) {
|
|
509
|
+
const segments = [...match[1]?.split(separatorRE) || [], ...match[2]?.split(separatorRE) || []];
|
|
510
|
+
for (const segment of segments) {
|
|
511
|
+
const identifier = segment.replace(importAsRE, "").trim();
|
|
512
|
+
occurrenceMap.delete(identifier);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
const identifiers = new Set(occurrenceMap.keys());
|
|
516
|
+
matchedImports = Array.from(identifiers).map((name) => {
|
|
517
|
+
const item = map.get(name);
|
|
518
|
+
if (item && !item.disabled) return item;
|
|
519
|
+
occurrenceMap.delete(name);
|
|
520
|
+
return null;
|
|
521
|
+
}).filter(Boolean);
|
|
522
|
+
for (const addon of ctx.addons) matchedImports = await addon.matchImports?.call(ctx, identifiers, matchedImports) || matchedImports;
|
|
523
|
+
}
|
|
524
|
+
if (options?.transformVirtualImports !== false && ctx.options.virtualImports?.length) {
|
|
525
|
+
const virtualImports = parseVirtualImportsRegex(strippedCode, map, ctx.options.virtualImports);
|
|
526
|
+
virtualImports.ranges.forEach(([start, end]) => {
|
|
527
|
+
s.remove(start, end);
|
|
528
|
+
});
|
|
529
|
+
matchedImports.push(...virtualImports.imports);
|
|
530
|
+
}
|
|
531
|
+
const firstOccurrence = Math.min(...Array.from(occurrenceMap.entries()).map((i) => i[1]));
|
|
532
|
+
return {
|
|
533
|
+
s,
|
|
534
|
+
strippedCode,
|
|
535
|
+
isCJSContext,
|
|
536
|
+
matchedImports,
|
|
537
|
+
firstOccurrence
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
function parseVirtualImportsRegex(strippedCode, importMap, virtualImports) {
|
|
541
|
+
const imports = [];
|
|
542
|
+
const ranges = [];
|
|
543
|
+
if (virtualImports?.length) findStaticImports(strippedCode).filter((i) => virtualImports.includes(i.specifier)).map((i) => parseStaticImport(i)).forEach((i) => {
|
|
544
|
+
ranges.push([i.start, i.end]);
|
|
545
|
+
Object.entries(i.namedImports || {}).forEach(([name, as]) => {
|
|
546
|
+
const original = importMap.get(name);
|
|
547
|
+
if (!original) throw new Error(`[unimport] failed to find "${name}" imported from "${i.specifier}"`);
|
|
548
|
+
imports.push({
|
|
549
|
+
from: original.from,
|
|
550
|
+
name: original.name,
|
|
551
|
+
as
|
|
552
|
+
});
|
|
553
|
+
});
|
|
554
|
+
});
|
|
555
|
+
return {
|
|
556
|
+
imports,
|
|
557
|
+
ranges
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
async function detectImports(code, ctx, options) {
|
|
561
|
+
if (options?.parser === "acorn") return import("../cli/_chunks/detect-acorn.mjs").then((r) => r.detectImportsAcorn(code, ctx, options));
|
|
562
|
+
return detectImportsRegex(code, ctx, options);
|
|
563
|
+
}
|
|
564
|
+
const FileExtensionLookup = [
|
|
565
|
+
"mts",
|
|
566
|
+
"cts",
|
|
567
|
+
"ts",
|
|
568
|
+
"tsx",
|
|
569
|
+
"mjs",
|
|
570
|
+
"cjs",
|
|
571
|
+
"js",
|
|
572
|
+
"jsx"
|
|
573
|
+
];
|
|
574
|
+
const FileLookupPatterns = `*.{${FileExtensionLookup.join(",")}}`;
|
|
575
|
+
function resolveGlobsExclude(glob2, cwd) {
|
|
576
|
+
return `${glob2.startsWith("!") ? "!" : ""}${resolve$1(cwd, glob2.replace(/^!/, ""))}`;
|
|
577
|
+
}
|
|
578
|
+
function joinGlobFilePattern(glob2, filePattern) {
|
|
579
|
+
return join$1(basename$1(glob2) === "*" ? dirname$1(glob2) : glob2, filePattern);
|
|
580
|
+
}
|
|
581
|
+
function normalizeScanDirs(dirs, options) {
|
|
582
|
+
const topLevelTypes = options?.types ?? true;
|
|
583
|
+
const cwd = options?.cwd ?? process$1.cwd();
|
|
584
|
+
const filePatterns = options?.filePatterns || [FileLookupPatterns];
|
|
585
|
+
return dirs.map((dir) => {
|
|
586
|
+
const isString$1 = typeof dir === "string";
|
|
587
|
+
const glob2 = resolveGlobsExclude(isString$1 ? dir : dir.glob, cwd);
|
|
588
|
+
const types = isString$1 ? topLevelTypes : dir.types ?? topLevelTypes;
|
|
589
|
+
if (glob2.match(/\.\w+$/)) return {
|
|
590
|
+
glob: glob2,
|
|
591
|
+
types
|
|
592
|
+
};
|
|
593
|
+
const withFilePatterns = filePatterns.map((filePattern) => ({
|
|
594
|
+
glob: joinGlobFilePattern(glob2, filePattern),
|
|
595
|
+
types
|
|
596
|
+
}));
|
|
597
|
+
return [{
|
|
598
|
+
glob: glob2,
|
|
599
|
+
types
|
|
600
|
+
}, ...withFilePatterns];
|
|
601
|
+
}).flat();
|
|
602
|
+
}
|
|
603
|
+
async function scanFilesFromDir(dir, options) {
|
|
604
|
+
const dirGlobs = (Array.isArray(dir) ? dir : [dir]).map((i) => i.glob);
|
|
605
|
+
const files = (await glob(dirGlobs, {
|
|
606
|
+
absolute: true,
|
|
607
|
+
cwd: options?.cwd || process$1.cwd(),
|
|
608
|
+
onlyFiles: true,
|
|
609
|
+
followSymbolicLinks: true,
|
|
610
|
+
expandDirectories: false
|
|
611
|
+
})).map((i) => normalize$2(i));
|
|
612
|
+
const fileFilter = options?.fileFilter || (() => true);
|
|
613
|
+
const indexOfDirs = (file) => dirGlobs.findIndex((glob2) => import_picomatch$2.default.isMatch(file, glob2));
|
|
614
|
+
return files.reduce((acc, file) => {
|
|
615
|
+
const index = indexOfDirs(file);
|
|
616
|
+
if (acc[index]) acc[index].push(normalize$2(file));
|
|
617
|
+
else acc[index] = [normalize$2(file)];
|
|
618
|
+
return acc;
|
|
619
|
+
}, []).map((files2) => files2.sort()).flat().filter(fileFilter);
|
|
620
|
+
}
|
|
621
|
+
async function scanDirExports(dirs, options) {
|
|
622
|
+
const normalizedDirs = normalizeScanDirs(dirs, options);
|
|
623
|
+
const files = await scanFilesFromDir(normalizedDirs, options);
|
|
624
|
+
const includeTypesDirs = normalizedDirs.filter((dir) => !dir.glob.startsWith("!") && dir.types);
|
|
625
|
+
const isIncludeTypes = (file) => includeTypesDirs.some((dir) => import_picomatch$2.default.isMatch(file, dir.glob));
|
|
626
|
+
return dedupeDtsExports((await Promise.all(files.map((file) => scanExports(file, isIncludeTypes(file))))).flat());
|
|
627
|
+
}
|
|
628
|
+
function dedupeDtsExports(exports$1) {
|
|
629
|
+
return exports$1.filter((i) => {
|
|
630
|
+
if (!i.type) return true;
|
|
631
|
+
if (i.declarationType === "enum" || i.declarationType === "class") return true;
|
|
632
|
+
return !exports$1.find((e) => e.as === i.as && e.name === i.name && !e.type);
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
async function scanExports(filepath, includeTypes, seen = /* @__PURE__ */ new Set()) {
|
|
636
|
+
if (seen.has(filepath)) {
|
|
637
|
+
console.warn(`[unimport] "${filepath}" is already scanned, skipping`);
|
|
638
|
+
return [];
|
|
639
|
+
}
|
|
640
|
+
seen.add(filepath);
|
|
641
|
+
const imports = [];
|
|
642
|
+
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$2(filepath).name;
|
|
646
|
+
if (name === "index") name = parse$2(filepath.split("/").slice(0, -1).join("/")).name;
|
|
647
|
+
const as = /[-_.]/.test(name) ? camelCase(name) : name;
|
|
648
|
+
imports.push({
|
|
649
|
+
name: "default",
|
|
650
|
+
as,
|
|
651
|
+
from: filepath
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
async function toImport(exports2, additional) {
|
|
655
|
+
for (const exp of exports2) if (exp.type === "named") for (const name of exp.names) imports.push({
|
|
656
|
+
name,
|
|
657
|
+
as: name,
|
|
658
|
+
from: filepath,
|
|
659
|
+
...additional
|
|
660
|
+
});
|
|
661
|
+
else if (exp.type === "declaration") {
|
|
662
|
+
if (exp.name) {
|
|
663
|
+
imports.push({
|
|
664
|
+
name: exp.name,
|
|
665
|
+
as: exp.name,
|
|
666
|
+
from: filepath,
|
|
667
|
+
...additional
|
|
668
|
+
});
|
|
669
|
+
if (exp.declarationType === "enum" || exp.declarationType === "class") imports.push({
|
|
670
|
+
name: exp.name,
|
|
671
|
+
as: exp.name,
|
|
672
|
+
from: filepath,
|
|
673
|
+
type: true,
|
|
674
|
+
declarationType: exp.declarationType,
|
|
675
|
+
...additional
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
} else if (exp.type === "star" && exp.specifier) if (exp.name) imports.push({
|
|
679
|
+
name: exp.name,
|
|
680
|
+
as: exp.name,
|
|
681
|
+
from: filepath,
|
|
682
|
+
...additional
|
|
683
|
+
});
|
|
684
|
+
else {
|
|
685
|
+
const subfile = exp.specifier;
|
|
686
|
+
let subfilepath = resolve$1(dirname$1(filepath), subfile);
|
|
687
|
+
let subfilepathResolved = false;
|
|
688
|
+
for (const ext of FileExtensionLookup) if (existsSync(`${subfilepath}.${ext}`)) {
|
|
689
|
+
subfilepath = `${subfilepath}.${ext}`;
|
|
690
|
+
break;
|
|
691
|
+
} else if (existsSync(`${subfilepath}/index.${ext}`)) {
|
|
692
|
+
subfilepath = `${subfilepath}/index.${ext}`;
|
|
693
|
+
break;
|
|
694
|
+
}
|
|
695
|
+
if (existsSync(subfilepath)) subfilepathResolved = true;
|
|
696
|
+
else try {
|
|
697
|
+
subfilepath = await resolve$2(exp.specifier);
|
|
698
|
+
subfilepath = normalize$2(fileURLToPath(subfilepath));
|
|
699
|
+
if (existsSync(subfilepath)) subfilepathResolved = true;
|
|
700
|
+
} catch {}
|
|
701
|
+
if (!subfilepathResolved) {
|
|
702
|
+
console.warn(`[unimport] failed to resolve "${subfilepath}", skip scanning`);
|
|
703
|
+
continue;
|
|
704
|
+
}
|
|
705
|
+
const nested = await scanExports(subfilepath, includeTypes, seen);
|
|
706
|
+
imports.push(...additional ? nested.map((i) => ({
|
|
707
|
+
...i,
|
|
708
|
+
...additional
|
|
709
|
+
})) : nested);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
if (filepath.match(/\.d\.[mc]?ts$/)) {
|
|
713
|
+
if (includeTypes) {
|
|
714
|
+
await toImport(exports$1, { type: true });
|
|
715
|
+
await toImport(findTypeExports(code), { type: true });
|
|
716
|
+
}
|
|
717
|
+
} else {
|
|
718
|
+
await toImport(exports$1);
|
|
719
|
+
if (includeTypes) await toImport(findTypeExports(code), { type: true });
|
|
720
|
+
}
|
|
721
|
+
return imports;
|
|
722
|
+
}
|
|
723
|
+
const CACHE_PATH = /* @__PURE__ */ join$1(os.tmpdir(), "unimport");
|
|
724
|
+
let CACHE_WRITEABLE;
|
|
725
|
+
async function resolvePackagePreset(preset) {
|
|
726
|
+
return (await extractExports(preset.package, preset.url, preset.cache)).filter((name) => {
|
|
727
|
+
for (const item of preset.ignore || []) {
|
|
728
|
+
if (typeof item === "string" && item === name) return false;
|
|
729
|
+
if (item instanceof RegExp && item.test(name)) return false;
|
|
730
|
+
if (typeof item === "function" && item(name) === false) return false;
|
|
731
|
+
}
|
|
732
|
+
return true;
|
|
733
|
+
}).map((name) => ({
|
|
734
|
+
from: preset.package,
|
|
735
|
+
name
|
|
736
|
+
}));
|
|
737
|
+
}
|
|
738
|
+
async function extractExports(name, url, cache = true) {
|
|
739
|
+
const version$1 = (await readPackageJSON(await resolvePackageJSON(name, { url }))).version;
|
|
740
|
+
const cachePath = join$1(CACHE_PATH, `${name}@${version$1}`, "exports.json");
|
|
741
|
+
if (cache && CACHE_WRITEABLE === void 0) try {
|
|
742
|
+
CACHE_WRITEABLE = isWritable(CACHE_PATH);
|
|
743
|
+
} catch {
|
|
744
|
+
CACHE_WRITEABLE = false;
|
|
745
|
+
}
|
|
746
|
+
const useCache = cache && version$1 && CACHE_WRITEABLE;
|
|
747
|
+
if (useCache && existsSync(cachePath)) return JSON.parse(await promises.readFile(cachePath, "utf-8"));
|
|
748
|
+
const scanned = await resolveModuleExportNames(name, { url });
|
|
749
|
+
if (useCache) {
|
|
750
|
+
await promises.mkdir(dirname$1(cachePath), { recursive: true });
|
|
751
|
+
await promises.writeFile(cachePath, JSON.stringify(scanned), "utf-8");
|
|
752
|
+
}
|
|
753
|
+
return scanned;
|
|
754
|
+
}
|
|
755
|
+
function isWritable(filename) {
|
|
756
|
+
try {
|
|
757
|
+
accessSync(filename, constants.W_OK);
|
|
758
|
+
return true;
|
|
759
|
+
} catch {
|
|
760
|
+
return false;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
const dateFns = defineUnimportPreset({
|
|
764
|
+
from: "date-fns",
|
|
765
|
+
imports: [
|
|
766
|
+
"add",
|
|
767
|
+
"addBusinessDays",
|
|
768
|
+
"addDays",
|
|
769
|
+
"addHours",
|
|
770
|
+
"addISOWeekYears",
|
|
771
|
+
"addMilliseconds",
|
|
772
|
+
"addMinutes",
|
|
773
|
+
"addMonths",
|
|
774
|
+
"addQuarters",
|
|
775
|
+
"addSeconds",
|
|
776
|
+
"addWeeks",
|
|
777
|
+
"addYears",
|
|
778
|
+
"areIntervalsOverlapping",
|
|
779
|
+
"clamp",
|
|
780
|
+
"closestIndexTo",
|
|
781
|
+
"closestTo",
|
|
782
|
+
"compareAsc",
|
|
783
|
+
"compareDesc",
|
|
784
|
+
"constants",
|
|
785
|
+
"daysToWeeks",
|
|
786
|
+
"differenceInBusinessDays",
|
|
787
|
+
"differenceInCalendarDays",
|
|
788
|
+
"differenceInCalendarISOWeekYears",
|
|
789
|
+
"differenceInCalendarISOWeeks",
|
|
790
|
+
"differenceInCalendarMonths",
|
|
791
|
+
"differenceInCalendarQuarters",
|
|
792
|
+
"differenceInCalendarWeeks",
|
|
793
|
+
"differenceInCalendarYears",
|
|
794
|
+
"differenceInDays",
|
|
795
|
+
"differenceInHours",
|
|
796
|
+
"differenceInISOWeekYears",
|
|
797
|
+
"differenceInMilliseconds",
|
|
798
|
+
"differenceInMinutes",
|
|
799
|
+
"differenceInMonths",
|
|
800
|
+
"differenceInQuarters",
|
|
801
|
+
"differenceInSeconds",
|
|
802
|
+
"differenceInWeeks",
|
|
803
|
+
"differenceInYears",
|
|
804
|
+
"eachDayOfInterval",
|
|
805
|
+
"eachHourOfInterval",
|
|
806
|
+
"eachMinuteOfInterval",
|
|
807
|
+
"eachMonthOfInterval",
|
|
808
|
+
"eachQuarterOfInterval",
|
|
809
|
+
"eachWeekOfInterval",
|
|
810
|
+
"eachWeekendOfInterval",
|
|
811
|
+
"eachWeekendOfMonth",
|
|
812
|
+
"eachWeekendOfYear",
|
|
813
|
+
"eachYearOfInterval",
|
|
814
|
+
"endOfDay",
|
|
815
|
+
"endOfDecade",
|
|
816
|
+
"endOfHour",
|
|
817
|
+
"endOfISOWeek",
|
|
818
|
+
"endOfISOWeekYear",
|
|
819
|
+
"endOfMinute",
|
|
820
|
+
"endOfMonth",
|
|
821
|
+
"endOfQuarter",
|
|
822
|
+
"endOfSecond",
|
|
823
|
+
"endOfToday",
|
|
824
|
+
"endOfTomorrow",
|
|
825
|
+
"endOfWeek",
|
|
826
|
+
"endOfYear",
|
|
827
|
+
"endOfYesterday",
|
|
828
|
+
"format",
|
|
829
|
+
"formatDistance",
|
|
830
|
+
"formatDistanceStrict",
|
|
831
|
+
"formatDistanceToNow",
|
|
832
|
+
"formatDistanceToNowStrict",
|
|
833
|
+
"formatDuration",
|
|
834
|
+
"formatISO",
|
|
835
|
+
"formatISO9075",
|
|
836
|
+
"formatISODuration",
|
|
837
|
+
"formatRFC3339",
|
|
838
|
+
"formatRFC7231",
|
|
839
|
+
"formatRelative",
|
|
840
|
+
"fromUnixTime",
|
|
841
|
+
"getDate",
|
|
842
|
+
"getDay",
|
|
843
|
+
"getDayOfYear",
|
|
844
|
+
"getDaysInMonth",
|
|
845
|
+
"getDaysInYear",
|
|
846
|
+
"getDecade",
|
|
847
|
+
"getDefaultOptions",
|
|
848
|
+
"getHours",
|
|
849
|
+
"getISODay",
|
|
850
|
+
"getISOWeek",
|
|
851
|
+
"getISOWeekYear",
|
|
852
|
+
"getISOWeeksInYear",
|
|
853
|
+
"getMilliseconds",
|
|
854
|
+
"getMinutes",
|
|
855
|
+
"getMonth",
|
|
856
|
+
"getOverlappingDaysInIntervals",
|
|
857
|
+
"getQuarter",
|
|
858
|
+
"getSeconds",
|
|
859
|
+
"getTime",
|
|
860
|
+
"getUnixTime",
|
|
861
|
+
"getWeek",
|
|
862
|
+
"getWeekOfMonth",
|
|
863
|
+
"getWeekYear",
|
|
864
|
+
"getWeeksInMonth",
|
|
865
|
+
"getYear",
|
|
866
|
+
"hoursToMilliseconds",
|
|
867
|
+
"hoursToMinutes",
|
|
868
|
+
"hoursToSeconds",
|
|
869
|
+
"intervalToDuration",
|
|
870
|
+
"intlFormat",
|
|
871
|
+
"intlFormatDistance",
|
|
872
|
+
"isAfter",
|
|
873
|
+
"isBefore",
|
|
874
|
+
"isDate",
|
|
875
|
+
"isEqual",
|
|
876
|
+
"isExists",
|
|
877
|
+
"isFirstDayOfMonth",
|
|
878
|
+
"isFriday",
|
|
879
|
+
"isFuture",
|
|
880
|
+
"isLastDayOfMonth",
|
|
881
|
+
"isLeapYear",
|
|
882
|
+
"isMatch",
|
|
883
|
+
"isMonday",
|
|
884
|
+
"isPast",
|
|
885
|
+
"isSameDay",
|
|
886
|
+
"isSameHour",
|
|
887
|
+
"isSameISOWeek",
|
|
888
|
+
"isSameISOWeekYear",
|
|
889
|
+
"isSameMinute",
|
|
890
|
+
"isSameMonth",
|
|
891
|
+
"isSameQuarter",
|
|
892
|
+
"isSameSecond",
|
|
893
|
+
"isSameWeek",
|
|
894
|
+
"isSameYear",
|
|
895
|
+
"isSaturday",
|
|
896
|
+
"isSunday",
|
|
897
|
+
"isThisHour",
|
|
898
|
+
"isThisISOWeek",
|
|
899
|
+
"isThisMinute",
|
|
900
|
+
"isThisMonth",
|
|
901
|
+
"isThisQuarter",
|
|
902
|
+
"isThisSecond",
|
|
903
|
+
"isThisWeek",
|
|
904
|
+
"isThisYear",
|
|
905
|
+
"isThursday",
|
|
906
|
+
"isToday",
|
|
907
|
+
"isTomorrow",
|
|
908
|
+
"isTuesday",
|
|
909
|
+
"isValid",
|
|
910
|
+
"isWednesday",
|
|
911
|
+
"isWeekend",
|
|
912
|
+
"isWithinInterval",
|
|
913
|
+
"isYesterday",
|
|
914
|
+
"lastDayOfDecade",
|
|
915
|
+
"lastDayOfISOWeek",
|
|
916
|
+
"lastDayOfISOWeekYear",
|
|
917
|
+
"lastDayOfMonth",
|
|
918
|
+
"lastDayOfQuarter",
|
|
919
|
+
"lastDayOfWeek",
|
|
920
|
+
"lastDayOfYear",
|
|
921
|
+
"lightFormat",
|
|
922
|
+
"max",
|
|
923
|
+
"milliseconds",
|
|
924
|
+
"millisecondsToHours",
|
|
925
|
+
"millisecondsToMinutes",
|
|
926
|
+
"millisecondsToSeconds",
|
|
927
|
+
"min",
|
|
928
|
+
"minutesToHours",
|
|
929
|
+
"minutesToMilliseconds",
|
|
930
|
+
"minutesToSeconds",
|
|
931
|
+
"monthsToQuarters",
|
|
932
|
+
"monthsToYears",
|
|
933
|
+
"nextDay",
|
|
934
|
+
"nextFriday",
|
|
935
|
+
"nextMonday",
|
|
936
|
+
"nextSaturday",
|
|
937
|
+
"nextSunday",
|
|
938
|
+
"nextThursday",
|
|
939
|
+
"nextTuesday",
|
|
940
|
+
"nextWednesday",
|
|
941
|
+
"parse",
|
|
942
|
+
"parseISO",
|
|
943
|
+
"parseJSON",
|
|
944
|
+
"previousDay",
|
|
945
|
+
"previousFriday",
|
|
946
|
+
"previousMonday",
|
|
947
|
+
"previousSaturday",
|
|
948
|
+
"previousSunday",
|
|
949
|
+
"previousThursday",
|
|
950
|
+
"previousTuesday",
|
|
951
|
+
"previousWednesday",
|
|
952
|
+
"quartersToMonths",
|
|
953
|
+
"quartersToYears",
|
|
954
|
+
"roundToNearestMinutes",
|
|
955
|
+
"secondsToHours",
|
|
956
|
+
"secondsToMilliseconds",
|
|
957
|
+
"secondsToMinutes",
|
|
958
|
+
"set",
|
|
959
|
+
"setDate",
|
|
960
|
+
"setDay",
|
|
961
|
+
"setDayOfYear",
|
|
962
|
+
"setDefaultOptions",
|
|
963
|
+
"setHours",
|
|
964
|
+
"setISODay",
|
|
965
|
+
"setISOWeek",
|
|
966
|
+
"setISOWeekYear",
|
|
967
|
+
"setMilliseconds",
|
|
968
|
+
"setMinutes",
|
|
969
|
+
"setMonth",
|
|
970
|
+
"setQuarter",
|
|
971
|
+
"setSeconds",
|
|
972
|
+
"setWeek",
|
|
973
|
+
"setWeekYear",
|
|
974
|
+
"setYear",
|
|
975
|
+
"startOfDay",
|
|
976
|
+
"startOfDecade",
|
|
977
|
+
"startOfHour",
|
|
978
|
+
"startOfISOWeek",
|
|
979
|
+
"startOfISOWeekYear",
|
|
980
|
+
"startOfMinute",
|
|
981
|
+
"startOfMonth",
|
|
982
|
+
"startOfQuarter",
|
|
983
|
+
"startOfSecond",
|
|
984
|
+
"startOfToday",
|
|
985
|
+
"startOfTomorrow",
|
|
986
|
+
"startOfWeek",
|
|
987
|
+
"startOfWeekYear",
|
|
988
|
+
"startOfYear",
|
|
989
|
+
"startOfYesterday",
|
|
990
|
+
"sub",
|
|
991
|
+
"subBusinessDays",
|
|
992
|
+
"subDays",
|
|
993
|
+
"subHours",
|
|
994
|
+
"subISOWeekYears",
|
|
995
|
+
"subMilliseconds",
|
|
996
|
+
"subMinutes",
|
|
997
|
+
"subMonths",
|
|
998
|
+
"subQuarters",
|
|
999
|
+
"subSeconds",
|
|
1000
|
+
"subWeeks",
|
|
1001
|
+
"subYears",
|
|
1002
|
+
"toDate",
|
|
1003
|
+
"weeksToDays",
|
|
1004
|
+
"yearsToMonths",
|
|
1005
|
+
"yearsToQuarters"
|
|
1006
|
+
]
|
|
1007
|
+
});
|
|
1008
|
+
const pinia = defineUnimportPreset({
|
|
1009
|
+
from: "pinia",
|
|
1010
|
+
imports: [
|
|
1011
|
+
"acceptHMRUpdate",
|
|
1012
|
+
"createPinia",
|
|
1013
|
+
"defineStore",
|
|
1014
|
+
"getActivePinia",
|
|
1015
|
+
"mapActions",
|
|
1016
|
+
"mapGetters",
|
|
1017
|
+
"mapState",
|
|
1018
|
+
"mapStores",
|
|
1019
|
+
"mapWritableState",
|
|
1020
|
+
"setActivePinia",
|
|
1021
|
+
"setMapStoreSuffix",
|
|
1022
|
+
"storeToRefs"
|
|
1023
|
+
]
|
|
1024
|
+
});
|
|
1025
|
+
const preact = defineUnimportPreset({
|
|
1026
|
+
from: "preact",
|
|
1027
|
+
imports: [
|
|
1028
|
+
"useState",
|
|
1029
|
+
"useCallback",
|
|
1030
|
+
"useMemo",
|
|
1031
|
+
"useEffect",
|
|
1032
|
+
"useRef",
|
|
1033
|
+
"useContext",
|
|
1034
|
+
"useReducer"
|
|
1035
|
+
]
|
|
1036
|
+
});
|
|
1037
|
+
const quasar = defineUnimportPreset({
|
|
1038
|
+
from: "quasar",
|
|
1039
|
+
imports: [
|
|
1040
|
+
"useQuasar",
|
|
1041
|
+
"useDialogPluginComponent",
|
|
1042
|
+
"useFormChild",
|
|
1043
|
+
"useMeta"
|
|
1044
|
+
]
|
|
1045
|
+
});
|
|
1046
|
+
const react = defineUnimportPreset({
|
|
1047
|
+
from: "react",
|
|
1048
|
+
imports: [
|
|
1049
|
+
"useState",
|
|
1050
|
+
"useCallback",
|
|
1051
|
+
"useMemo",
|
|
1052
|
+
"useEffect",
|
|
1053
|
+
"useRef",
|
|
1054
|
+
"useContext",
|
|
1055
|
+
"useReducer"
|
|
1056
|
+
]
|
|
1057
|
+
});
|
|
1058
|
+
const ReactRouterHooks = [
|
|
1059
|
+
"useOutletContext",
|
|
1060
|
+
"useHref",
|
|
1061
|
+
"useInRouterContext",
|
|
1062
|
+
"useLocation",
|
|
1063
|
+
"useNavigationType",
|
|
1064
|
+
"useNavigate",
|
|
1065
|
+
"useOutlet",
|
|
1066
|
+
"useParams",
|
|
1067
|
+
"useResolvedPath",
|
|
1068
|
+
"useRoutes"
|
|
1069
|
+
];
|
|
1070
|
+
const reactRouter = defineUnimportPreset({
|
|
1071
|
+
from: "react-router",
|
|
1072
|
+
imports: [...ReactRouterHooks]
|
|
1073
|
+
});
|
|
1074
|
+
const reactRouterDom = defineUnimportPreset({
|
|
1075
|
+
from: "react-router-dom",
|
|
1076
|
+
imports: [
|
|
1077
|
+
...ReactRouterHooks,
|
|
1078
|
+
"useLinkClickHandler",
|
|
1079
|
+
"useSearchParams",
|
|
1080
|
+
"Link",
|
|
1081
|
+
"NavLink",
|
|
1082
|
+
"Navigate",
|
|
1083
|
+
"Outlet",
|
|
1084
|
+
"Route",
|
|
1085
|
+
"Routes"
|
|
1086
|
+
]
|
|
1087
|
+
});
|
|
1088
|
+
const rxjs = defineUnimportPreset({
|
|
1089
|
+
from: "rxjs",
|
|
1090
|
+
imports: [
|
|
1091
|
+
"of",
|
|
1092
|
+
"from",
|
|
1093
|
+
"map",
|
|
1094
|
+
"tap",
|
|
1095
|
+
"filter",
|
|
1096
|
+
"forkJoin",
|
|
1097
|
+
"throwError",
|
|
1098
|
+
"catchError",
|
|
1099
|
+
"Observable",
|
|
1100
|
+
"mergeMap",
|
|
1101
|
+
"switchMap",
|
|
1102
|
+
"merge",
|
|
1103
|
+
"zip",
|
|
1104
|
+
"take",
|
|
1105
|
+
"takeUntil",
|
|
1106
|
+
"first",
|
|
1107
|
+
"lastValueFrom",
|
|
1108
|
+
"skip",
|
|
1109
|
+
"skipUntil",
|
|
1110
|
+
"distinct",
|
|
1111
|
+
"distinctUntilChanged",
|
|
1112
|
+
"throttle",
|
|
1113
|
+
"throttleTime",
|
|
1114
|
+
"retry",
|
|
1115
|
+
"retryWhen",
|
|
1116
|
+
"timeout",
|
|
1117
|
+
"delay",
|
|
1118
|
+
"debounce",
|
|
1119
|
+
"debounceTime",
|
|
1120
|
+
"find",
|
|
1121
|
+
"every"
|
|
1122
|
+
]
|
|
1123
|
+
});
|
|
1124
|
+
const solid = defineUnimportPreset({
|
|
1125
|
+
from: "solid-js",
|
|
1126
|
+
imports: [
|
|
1127
|
+
defineUnimportPreset({
|
|
1128
|
+
from: "solid-js",
|
|
1129
|
+
imports: [
|
|
1130
|
+
"createSignal",
|
|
1131
|
+
"createEffect",
|
|
1132
|
+
"createMemo",
|
|
1133
|
+
"createResource",
|
|
1134
|
+
"onMount",
|
|
1135
|
+
"onCleanup",
|
|
1136
|
+
"onError",
|
|
1137
|
+
"untrack",
|
|
1138
|
+
"batch",
|
|
1139
|
+
"on",
|
|
1140
|
+
"createRoot",
|
|
1141
|
+
"mergeProps",
|
|
1142
|
+
"splitProps",
|
|
1143
|
+
"useTransition",
|
|
1144
|
+
"observable",
|
|
1145
|
+
"mapArray",
|
|
1146
|
+
"indexArray",
|
|
1147
|
+
"createContext",
|
|
1148
|
+
"useContext",
|
|
1149
|
+
"children",
|
|
1150
|
+
"lazy",
|
|
1151
|
+
"createDeferred",
|
|
1152
|
+
"createRenderEffect",
|
|
1153
|
+
"createSelector",
|
|
1154
|
+
"For",
|
|
1155
|
+
"Show",
|
|
1156
|
+
"Switch",
|
|
1157
|
+
"Match",
|
|
1158
|
+
"Index",
|
|
1159
|
+
"ErrorBoundary",
|
|
1160
|
+
"Suspense",
|
|
1161
|
+
"SuspenseList"
|
|
1162
|
+
]
|
|
1163
|
+
}),
|
|
1164
|
+
defineUnimportPreset({
|
|
1165
|
+
from: "solid-js/store",
|
|
1166
|
+
imports: [
|
|
1167
|
+
"createStore",
|
|
1168
|
+
"produce",
|
|
1169
|
+
"reconcile",
|
|
1170
|
+
"createMutable"
|
|
1171
|
+
]
|
|
1172
|
+
}),
|
|
1173
|
+
defineUnimportPreset({
|
|
1174
|
+
from: "solid-js/web",
|
|
1175
|
+
imports: [
|
|
1176
|
+
"Dynamic",
|
|
1177
|
+
"hydrate",
|
|
1178
|
+
"render",
|
|
1179
|
+
"renderToString",
|
|
1180
|
+
"renderToStringAsync",
|
|
1181
|
+
"renderToStream",
|
|
1182
|
+
"isServer",
|
|
1183
|
+
"Portal"
|
|
1184
|
+
]
|
|
1185
|
+
})
|
|
1186
|
+
]
|
|
1187
|
+
});
|
|
1188
|
+
const solidAppRouter = defineUnimportPreset({
|
|
1189
|
+
from: "solid-app-router",
|
|
1190
|
+
imports: [
|
|
1191
|
+
"Link",
|
|
1192
|
+
"NavLink",
|
|
1193
|
+
"Navigate",
|
|
1194
|
+
"Outlet",
|
|
1195
|
+
"Route",
|
|
1196
|
+
"Router",
|
|
1197
|
+
"Routes",
|
|
1198
|
+
"_mergeSearchString",
|
|
1199
|
+
"createIntegration",
|
|
1200
|
+
"hashIntegration",
|
|
1201
|
+
"normalizeIntegration",
|
|
1202
|
+
"pathIntegration",
|
|
1203
|
+
"staticIntegration",
|
|
1204
|
+
"useHref",
|
|
1205
|
+
"useIsRouting",
|
|
1206
|
+
"useLocation",
|
|
1207
|
+
"useMatch",
|
|
1208
|
+
"useNavigate",
|
|
1209
|
+
"useParams",
|
|
1210
|
+
"useResolvedPath",
|
|
1211
|
+
"useRouteData",
|
|
1212
|
+
"useRoutes",
|
|
1213
|
+
"useSearchParams"
|
|
1214
|
+
]
|
|
1215
|
+
});
|
|
1216
|
+
const svelteAnimate = defineUnimportPreset({
|
|
1217
|
+
from: "svelte/animate",
|
|
1218
|
+
imports: ["flip"]
|
|
1219
|
+
});
|
|
1220
|
+
const svelteEasing = defineUnimportPreset({
|
|
1221
|
+
from: "svelte/easing",
|
|
1222
|
+
imports: [
|
|
1223
|
+
"back",
|
|
1224
|
+
"bounce",
|
|
1225
|
+
"circ",
|
|
1226
|
+
"cubic",
|
|
1227
|
+
"elastic",
|
|
1228
|
+
"expo",
|
|
1229
|
+
"quad",
|
|
1230
|
+
"quart",
|
|
1231
|
+
"quint",
|
|
1232
|
+
"sine"
|
|
1233
|
+
].reduce((acc, e) => {
|
|
1234
|
+
acc.push(`${e}In`, `${e}Out`, `${e}InOut`);
|
|
1235
|
+
return acc;
|
|
1236
|
+
}, ["linear"])
|
|
1237
|
+
});
|
|
1238
|
+
const svelteStore = defineUnimportPreset({
|
|
1239
|
+
from: "svelte/store",
|
|
1240
|
+
imports: [
|
|
1241
|
+
"writable",
|
|
1242
|
+
"readable",
|
|
1243
|
+
"derived",
|
|
1244
|
+
"get"
|
|
1245
|
+
]
|
|
1246
|
+
});
|
|
1247
|
+
const svelteMotion = defineUnimportPreset({
|
|
1248
|
+
from: "svelte/motion",
|
|
1249
|
+
imports: ["tweened", "spring"]
|
|
1250
|
+
});
|
|
1251
|
+
const svelteTransition = defineUnimportPreset({
|
|
1252
|
+
from: "svelte/transition",
|
|
1253
|
+
imports: [
|
|
1254
|
+
"fade",
|
|
1255
|
+
"blur",
|
|
1256
|
+
"fly",
|
|
1257
|
+
"slide",
|
|
1258
|
+
"scale",
|
|
1259
|
+
"draw",
|
|
1260
|
+
"crossfade"
|
|
1261
|
+
]
|
|
1262
|
+
});
|
|
1263
|
+
const svelte = defineUnimportPreset({
|
|
1264
|
+
from: "svelte",
|
|
1265
|
+
imports: [
|
|
1266
|
+
"onMount",
|
|
1267
|
+
"beforeUpdate",
|
|
1268
|
+
"afterUpdate",
|
|
1269
|
+
"onDestroy",
|
|
1270
|
+
"tick",
|
|
1271
|
+
"setContext",
|
|
1272
|
+
"getContext",
|
|
1273
|
+
"hasContext",
|
|
1274
|
+
"getAllContexts",
|
|
1275
|
+
"createEventDispatcher"
|
|
1276
|
+
]
|
|
1277
|
+
});
|
|
1278
|
+
const uniApp = defineUnimportPreset({
|
|
1279
|
+
from: "@dcloudio/uni-app",
|
|
1280
|
+
imports: [
|
|
1281
|
+
"onAddToFavorites",
|
|
1282
|
+
"onBackPress",
|
|
1283
|
+
"onError",
|
|
1284
|
+
"onHide",
|
|
1285
|
+
"onLaunch",
|
|
1286
|
+
"onLoad",
|
|
1287
|
+
"onNavigationBarButtonTap",
|
|
1288
|
+
"onNavigationBarSearchInputChanged",
|
|
1289
|
+
"onNavigationBarSearchInputClicked",
|
|
1290
|
+
"onNavigationBarSearchInputConfirmed",
|
|
1291
|
+
"onNavigationBarSearchInputFocusChanged",
|
|
1292
|
+
"onPageNotFound",
|
|
1293
|
+
"onPageScroll",
|
|
1294
|
+
"onPullDownRefresh",
|
|
1295
|
+
"onReachBottom",
|
|
1296
|
+
"onReady",
|
|
1297
|
+
"onResize",
|
|
1298
|
+
"onShareAppMessage",
|
|
1299
|
+
"onShareTimeline",
|
|
1300
|
+
"onShow",
|
|
1301
|
+
"onTabItemTap",
|
|
1302
|
+
"onThemeChange",
|
|
1303
|
+
"onUnhandledRejection",
|
|
1304
|
+
"onUnload"
|
|
1305
|
+
]
|
|
1306
|
+
});
|
|
1307
|
+
const veeValidate = defineUnimportPreset({
|
|
1308
|
+
from: "vee-validate",
|
|
1309
|
+
imports: [
|
|
1310
|
+
"validate",
|
|
1311
|
+
"defineRule",
|
|
1312
|
+
"configure",
|
|
1313
|
+
"useField",
|
|
1314
|
+
"useForm",
|
|
1315
|
+
"useFieldArray",
|
|
1316
|
+
"useResetForm",
|
|
1317
|
+
"useIsFieldDirty",
|
|
1318
|
+
"useIsFieldTouched",
|
|
1319
|
+
"useIsFieldValid",
|
|
1320
|
+
"useIsSubmitting",
|
|
1321
|
+
"useValidateField",
|
|
1322
|
+
"useIsFormDirty",
|
|
1323
|
+
"useIsFormTouched",
|
|
1324
|
+
"useIsFormValid",
|
|
1325
|
+
"useValidateForm",
|
|
1326
|
+
"useSubmitCount",
|
|
1327
|
+
"useFieldValue",
|
|
1328
|
+
"useFormValues",
|
|
1329
|
+
"useFormErrors",
|
|
1330
|
+
"useFieldError",
|
|
1331
|
+
"useSubmitForm",
|
|
1332
|
+
"FormContextKey",
|
|
1333
|
+
"FieldContextKey"
|
|
1334
|
+
]
|
|
1335
|
+
});
|
|
1336
|
+
const vitepress = defineUnimportPreset({
|
|
1337
|
+
from: "vitepress",
|
|
1338
|
+
imports: [
|
|
1339
|
+
"useData",
|
|
1340
|
+
"useRoute",
|
|
1341
|
+
"useRouter",
|
|
1342
|
+
"withBase"
|
|
1343
|
+
]
|
|
1344
|
+
});
|
|
1345
|
+
const vitest = defineUnimportPreset({
|
|
1346
|
+
from: "vitest",
|
|
1347
|
+
imports: [
|
|
1348
|
+
"suite",
|
|
1349
|
+
"test",
|
|
1350
|
+
"describe",
|
|
1351
|
+
"it",
|
|
1352
|
+
"chai",
|
|
1353
|
+
"expect",
|
|
1354
|
+
"assert",
|
|
1355
|
+
"vitest",
|
|
1356
|
+
"vi",
|
|
1357
|
+
"beforeAll",
|
|
1358
|
+
"afterAll",
|
|
1359
|
+
"beforeEach",
|
|
1360
|
+
"afterEach"
|
|
1361
|
+
]
|
|
1362
|
+
});
|
|
1363
|
+
const CommonCompositionAPI = [
|
|
1364
|
+
"onActivated",
|
|
1365
|
+
"onBeforeMount",
|
|
1366
|
+
"onBeforeUnmount",
|
|
1367
|
+
"onBeforeUpdate",
|
|
1368
|
+
"onErrorCaptured",
|
|
1369
|
+
"onDeactivated",
|
|
1370
|
+
"onMounted",
|
|
1371
|
+
"onServerPrefetch",
|
|
1372
|
+
"onUnmounted",
|
|
1373
|
+
"onUpdated",
|
|
1374
|
+
"useAttrs",
|
|
1375
|
+
"useSlots",
|
|
1376
|
+
"computed",
|
|
1377
|
+
"customRef",
|
|
1378
|
+
"isReadonly",
|
|
1379
|
+
"isRef",
|
|
1380
|
+
"isShallow",
|
|
1381
|
+
"isProxy",
|
|
1382
|
+
"isReactive",
|
|
1383
|
+
"markRaw",
|
|
1384
|
+
"reactive",
|
|
1385
|
+
"readonly",
|
|
1386
|
+
"ref",
|
|
1387
|
+
"shallowReactive",
|
|
1388
|
+
"shallowReadonly",
|
|
1389
|
+
"shallowRef",
|
|
1390
|
+
"triggerRef",
|
|
1391
|
+
"toRaw",
|
|
1392
|
+
"toRef",
|
|
1393
|
+
"toRefs",
|
|
1394
|
+
"toValue",
|
|
1395
|
+
"unref",
|
|
1396
|
+
"watch",
|
|
1397
|
+
"watchEffect",
|
|
1398
|
+
"watchPostEffect",
|
|
1399
|
+
"watchSyncEffect",
|
|
1400
|
+
"defineComponent",
|
|
1401
|
+
"defineAsyncComponent",
|
|
1402
|
+
"getCurrentInstance",
|
|
1403
|
+
"h",
|
|
1404
|
+
"inject",
|
|
1405
|
+
"nextTick",
|
|
1406
|
+
"provide",
|
|
1407
|
+
"useCssModule",
|
|
1408
|
+
"createApp",
|
|
1409
|
+
"effectScope",
|
|
1410
|
+
"EffectScope",
|
|
1411
|
+
"getCurrentScope",
|
|
1412
|
+
"onScopeDispose",
|
|
1413
|
+
...[
|
|
1414
|
+
"Component",
|
|
1415
|
+
"Slot",
|
|
1416
|
+
"Slots",
|
|
1417
|
+
"ComponentPublicInstance",
|
|
1418
|
+
"ComputedRef",
|
|
1419
|
+
"DirectiveBinding",
|
|
1420
|
+
"ExtractDefaultPropTypes",
|
|
1421
|
+
"ExtractPropTypes",
|
|
1422
|
+
"ExtractPublicPropTypes",
|
|
1423
|
+
"InjectionKey",
|
|
1424
|
+
"PropType",
|
|
1425
|
+
"Ref",
|
|
1426
|
+
"ShallowRef",
|
|
1427
|
+
"MaybeRef",
|
|
1428
|
+
"MaybeRefOrGetter",
|
|
1429
|
+
"VNode",
|
|
1430
|
+
"WritableComputedRef"
|
|
1431
|
+
].map((name) => ({
|
|
1432
|
+
name,
|
|
1433
|
+
type: true
|
|
1434
|
+
}))
|
|
1435
|
+
];
|
|
1436
|
+
const vue = defineUnimportPreset({
|
|
1437
|
+
from: "vue",
|
|
1438
|
+
imports: [
|
|
1439
|
+
...CommonCompositionAPI,
|
|
1440
|
+
"onRenderTracked",
|
|
1441
|
+
"onRenderTriggered",
|
|
1442
|
+
"resolveComponent",
|
|
1443
|
+
"useCssVars",
|
|
1444
|
+
"useModel",
|
|
1445
|
+
"getCurrentWatcher",
|
|
1446
|
+
"onWatcherCleanup",
|
|
1447
|
+
"useId",
|
|
1448
|
+
"useTemplateRef"
|
|
1449
|
+
]
|
|
1450
|
+
});
|
|
1451
|
+
const vueCompositionApi = defineUnimportPreset({
|
|
1452
|
+
from: "@vue/composition-api",
|
|
1453
|
+
imports: CommonCompositionAPI
|
|
1454
|
+
});
|
|
1455
|
+
const vueDemi = defineUnimportPreset({
|
|
1456
|
+
from: "vue-demi",
|
|
1457
|
+
imports: CommonCompositionAPI
|
|
1458
|
+
});
|
|
1459
|
+
const vueI18n = defineUnimportPreset({
|
|
1460
|
+
from: "vue-i18n",
|
|
1461
|
+
imports: ["useI18n"]
|
|
1462
|
+
});
|
|
1463
|
+
const vueMacros = defineUnimportPreset({
|
|
1464
|
+
from: "vue/macros",
|
|
1465
|
+
imports: [
|
|
1466
|
+
"$",
|
|
1467
|
+
"$$",
|
|
1468
|
+
"$ref",
|
|
1469
|
+
"$shallowRef",
|
|
1470
|
+
"$toRef",
|
|
1471
|
+
"$customRef",
|
|
1472
|
+
"$computed"
|
|
1473
|
+
]
|
|
1474
|
+
});
|
|
1475
|
+
const vueRouter = defineUnimportPreset({
|
|
1476
|
+
from: "vue-router",
|
|
1477
|
+
imports: [
|
|
1478
|
+
"useRouter",
|
|
1479
|
+
"useRoute",
|
|
1480
|
+
"useLink",
|
|
1481
|
+
"onBeforeRouteLeave",
|
|
1482
|
+
"onBeforeRouteUpdate"
|
|
1483
|
+
]
|
|
1484
|
+
});
|
|
1485
|
+
const vueRouterComposables = defineUnimportPreset({
|
|
1486
|
+
from: "vue-router/composables",
|
|
1487
|
+
imports: [
|
|
1488
|
+
"useRouter",
|
|
1489
|
+
"useRoute",
|
|
1490
|
+
"useLink",
|
|
1491
|
+
"onBeforeRouteLeave",
|
|
1492
|
+
"onBeforeRouteUpdate"
|
|
1493
|
+
]
|
|
1494
|
+
});
|
|
1495
|
+
let _cache;
|
|
1496
|
+
const vueuseCore = () => {
|
|
1497
|
+
const excluded = ["toRefs", "utils"];
|
|
1498
|
+
if (!_cache) try {
|
|
1499
|
+
const corePath = resolveModule("@vueuse/core") || process$1.cwd();
|
|
1500
|
+
const path$1 = resolveModule("@vueuse/core/indexes.json") || resolveModule("@vueuse/metadata/index.json") || resolveModule("@vueuse/metadata/index.json", { paths: [corePath] });
|
|
1501
|
+
_cache = defineUnimportPreset({
|
|
1502
|
+
from: "@vueuse/core",
|
|
1503
|
+
imports: JSON.parse(readFileSync(path$1, "utf-8")).functions.filter((i) => ["core", "shared"].includes(i.package)).map((i) => i.name).filter((i) => i && i.length >= 4 && !excluded.includes(i))
|
|
1504
|
+
});
|
|
1505
|
+
} catch (error) {
|
|
1506
|
+
console.error(error);
|
|
1507
|
+
throw new Error("[auto-import] failed to load @vueuse/core, have you installed it?");
|
|
1508
|
+
}
|
|
1509
|
+
return _cache;
|
|
1510
|
+
};
|
|
1511
|
+
const vueuseHead = defineUnimportPreset({
|
|
1512
|
+
from: "@vueuse/head",
|
|
1513
|
+
imports: ["useHead"]
|
|
1514
|
+
});
|
|
1515
|
+
const vuex = defineUnimportPreset({
|
|
1516
|
+
from: "vuex",
|
|
1517
|
+
imports: [
|
|
1518
|
+
"createStore",
|
|
1519
|
+
"createLogger",
|
|
1520
|
+
"mapState",
|
|
1521
|
+
"mapGetters",
|
|
1522
|
+
"mapActions",
|
|
1523
|
+
"mapMutations",
|
|
1524
|
+
"createNamespacedHelpers",
|
|
1525
|
+
"useStore"
|
|
1526
|
+
]
|
|
1527
|
+
});
|
|
1528
|
+
const builtinPresets = {
|
|
1529
|
+
"@vue/composition-api": vueCompositionApi,
|
|
1530
|
+
"@vueuse/core": vueuseCore,
|
|
1531
|
+
"@vueuse/head": vueuseHead,
|
|
1532
|
+
"pinia": pinia,
|
|
1533
|
+
"preact": preact,
|
|
1534
|
+
"quasar": quasar,
|
|
1535
|
+
"react": react,
|
|
1536
|
+
"react-router": reactRouter,
|
|
1537
|
+
"react-router-dom": reactRouterDom,
|
|
1538
|
+
"svelte": svelte,
|
|
1539
|
+
"svelte/animate": svelteAnimate,
|
|
1540
|
+
"svelte/easing": svelteEasing,
|
|
1541
|
+
"svelte/motion": svelteMotion,
|
|
1542
|
+
"svelte/store": svelteStore,
|
|
1543
|
+
"svelte/transition": svelteTransition,
|
|
1544
|
+
"vee-validate": veeValidate,
|
|
1545
|
+
"vitepress": vitepress,
|
|
1546
|
+
"vue-demi": vueDemi,
|
|
1547
|
+
"vue-i18n": vueI18n,
|
|
1548
|
+
"vue-router": vueRouter,
|
|
1549
|
+
"vue-router-composables": vueRouterComposables,
|
|
1550
|
+
"vue": vue,
|
|
1551
|
+
"vue/macros": vueMacros,
|
|
1552
|
+
"vuex": vuex,
|
|
1553
|
+
"vitest": vitest,
|
|
1554
|
+
"uni-app": uniApp,
|
|
1555
|
+
"solid-js": solid,
|
|
1556
|
+
"solid-app-router": solidAppRouter,
|
|
1557
|
+
"rxjs": rxjs,
|
|
1558
|
+
"date-fns": dateFns
|
|
1559
|
+
};
|
|
1560
|
+
const commonProps = [
|
|
1561
|
+
"from",
|
|
1562
|
+
"priority",
|
|
1563
|
+
"disabled",
|
|
1564
|
+
"dtsDisabled",
|
|
1565
|
+
"declarationType",
|
|
1566
|
+
"meta",
|
|
1567
|
+
"type",
|
|
1568
|
+
"typeFrom"
|
|
1569
|
+
];
|
|
1570
|
+
async function resolvePreset(preset) {
|
|
1571
|
+
const imports = [];
|
|
1572
|
+
if ("package" in preset) return await resolvePackagePreset(preset);
|
|
1573
|
+
const common = {};
|
|
1574
|
+
commonProps.forEach((i) => {
|
|
1575
|
+
if (i in preset) common[i] = preset[i];
|
|
1576
|
+
});
|
|
1577
|
+
for (const _import of preset.imports) if (typeof _import === "string") imports.push({
|
|
1578
|
+
...common,
|
|
1579
|
+
name: _import,
|
|
1580
|
+
as: _import
|
|
1581
|
+
});
|
|
1582
|
+
else if (Array.isArray(_import)) imports.push({
|
|
1583
|
+
...common,
|
|
1584
|
+
name: _import[0],
|
|
1585
|
+
as: _import[1] || _import[0],
|
|
1586
|
+
from: _import[2] || preset.from
|
|
1587
|
+
});
|
|
1588
|
+
else if (_import.imports) imports.push(...await resolvePreset(_import));
|
|
1589
|
+
else imports.push({
|
|
1590
|
+
...common,
|
|
1591
|
+
..._import
|
|
1592
|
+
});
|
|
1593
|
+
return imports;
|
|
1594
|
+
}
|
|
1595
|
+
async function resolveBuiltinPresets(presets) {
|
|
1596
|
+
return (await Promise.all(presets.map(async (p) => {
|
|
1597
|
+
let preset = typeof p === "string" ? builtinPresets[p] : p;
|
|
1598
|
+
if (typeof preset === "function") preset = preset();
|
|
1599
|
+
return await resolvePreset(preset);
|
|
1600
|
+
}))).flat();
|
|
1601
|
+
}
|
|
1602
|
+
function createUnimport(opts) {
|
|
1603
|
+
const ctx = createInternalContext(opts);
|
|
1604
|
+
async function generateTypeDeclarations(options) {
|
|
1605
|
+
const opts2 = {
|
|
1606
|
+
resolvePath: (i) => stripFileExtension(i.typeFrom || i.from),
|
|
1607
|
+
...options
|
|
1608
|
+
};
|
|
1609
|
+
const { typeReExports = true } = opts2;
|
|
1610
|
+
const imports = await ctx.getImports();
|
|
1611
|
+
let dts = toTypeDeclarationFile(imports.filter((i) => !i.type && !i.dtsDisabled), opts2);
|
|
1612
|
+
const typeOnly = imports.filter((i) => i.type);
|
|
1613
|
+
if (typeReExports && typeOnly.length) dts += `
|
|
1614
|
+
${toTypeReExports(typeOnly, opts2)}`;
|
|
1615
|
+
for (const addon of ctx.addons) dts = await addon.declaration?.call(ctx, dts, opts2) ?? dts;
|
|
1616
|
+
return dts;
|
|
1617
|
+
}
|
|
1618
|
+
async function scanImportsFromFile(filepath, includeTypes = true) {
|
|
1619
|
+
const additions = await scanExports(filepath, includeTypes);
|
|
1620
|
+
await ctx.modifyDynamicImports((imports) => imports.filter((i) => i.from !== filepath).concat(additions));
|
|
1621
|
+
return additions;
|
|
1622
|
+
}
|
|
1623
|
+
async function scanImportsFromDir(dirs = ctx.options.dirs || [], options = ctx.options.dirsScanOptions) {
|
|
1624
|
+
const imports = await scanDirExports(dirs, options);
|
|
1625
|
+
const files = new Set(imports.map((f) => f.from));
|
|
1626
|
+
await ctx.modifyDynamicImports((i) => i.filter((i2) => !files.has(i2.from)).concat(imports));
|
|
1627
|
+
return imports;
|
|
1628
|
+
}
|
|
1629
|
+
async function injectImportsWithContext(code, id, options) {
|
|
1630
|
+
const result = await injectImports(code, id, ctx, {
|
|
1631
|
+
...opts,
|
|
1632
|
+
...options
|
|
1633
|
+
});
|
|
1634
|
+
const metadata = ctx.getMetadata();
|
|
1635
|
+
if (metadata) result.imports.forEach((i) => {
|
|
1636
|
+
metadata.injectionUsage[i.name] = metadata.injectionUsage[i.name] || {
|
|
1637
|
+
import: i,
|
|
1638
|
+
count: 0,
|
|
1639
|
+
moduleIds: []
|
|
1640
|
+
};
|
|
1641
|
+
metadata.injectionUsage[i.name].count++;
|
|
1642
|
+
if (id && !metadata.injectionUsage[i.name].moduleIds.includes(id)) metadata.injectionUsage[i.name].moduleIds.push(id);
|
|
1643
|
+
});
|
|
1644
|
+
return result;
|
|
1645
|
+
}
|
|
1646
|
+
async function init() {
|
|
1647
|
+
if (ctx.options.dirs?.length) await scanImportsFromDir();
|
|
1648
|
+
}
|
|
1649
|
+
return {
|
|
1650
|
+
version,
|
|
1651
|
+
init,
|
|
1652
|
+
clearDynamicImports: () => ctx.clearDynamicImports(),
|
|
1653
|
+
modifyDynamicImports: (fn) => ctx.modifyDynamicImports(fn),
|
|
1654
|
+
scanImportsFromDir,
|
|
1655
|
+
scanImportsFromFile,
|
|
1656
|
+
getImports: () => ctx.getImports(),
|
|
1657
|
+
getImportMap: () => ctx.getImportMap(),
|
|
1658
|
+
detectImports: (code) => detectImports(code, ctx),
|
|
1659
|
+
injectImports: injectImportsWithContext,
|
|
1660
|
+
generateTypeDeclarations: (options) => generateTypeDeclarations(options),
|
|
1661
|
+
getMetadata: () => ctx.getMetadata(),
|
|
1662
|
+
getInternalContext: () => ctx,
|
|
1663
|
+
toExports: async (filepath, includeTypes = false) => toExports(await ctx.getImports(), filepath, includeTypes)
|
|
1664
|
+
};
|
|
1665
|
+
}
|
|
1666
|
+
function createInternalContext(opts) {
|
|
1667
|
+
let _combinedImports;
|
|
1668
|
+
const _map = /* @__PURE__ */ new Map();
|
|
1669
|
+
const addons = configureAddons(opts);
|
|
1670
|
+
opts.addons = addons;
|
|
1671
|
+
opts.commentsDisable = opts.commentsDisable ?? ["@unimport-disable", "@imports-disable"];
|
|
1672
|
+
opts.commentsDebug = opts.commentsDebug ?? ["@unimport-debug", "@imports-debug"];
|
|
1673
|
+
let metadata;
|
|
1674
|
+
if (opts.collectMeta) metadata = { injectionUsage: {} };
|
|
1675
|
+
let resolvePromise;
|
|
1676
|
+
const ctx = {
|
|
1677
|
+
version,
|
|
1678
|
+
options: opts,
|
|
1679
|
+
addons,
|
|
1680
|
+
staticImports: [...opts.imports || []].filter(Boolean),
|
|
1681
|
+
dynamicImports: [],
|
|
1682
|
+
modifyDynamicImports,
|
|
1683
|
+
clearDynamicImports,
|
|
1684
|
+
async getImports() {
|
|
1685
|
+
await resolvePromise;
|
|
1686
|
+
return updateImports();
|
|
1687
|
+
},
|
|
1688
|
+
async replaceImports(imports) {
|
|
1689
|
+
ctx.staticImports = [...imports || []].filter(Boolean);
|
|
1690
|
+
ctx.invalidate();
|
|
1691
|
+
await resolvePromise;
|
|
1692
|
+
return updateImports();
|
|
1693
|
+
},
|
|
1694
|
+
async getImportMap() {
|
|
1695
|
+
await ctx.getImports();
|
|
1696
|
+
return _map;
|
|
1697
|
+
},
|
|
1698
|
+
getMetadata() {
|
|
1699
|
+
return metadata;
|
|
1700
|
+
},
|
|
1701
|
+
invalidate() {
|
|
1702
|
+
_combinedImports = void 0;
|
|
1703
|
+
},
|
|
1704
|
+
resolveId: (id, parentId) => opts.resolveId?.(id, parentId)
|
|
1705
|
+
};
|
|
1706
|
+
resolvePromise = resolveBuiltinPresets(opts.presets || []).then((r) => {
|
|
1707
|
+
ctx.staticImports.unshift(...r);
|
|
1708
|
+
_combinedImports = void 0;
|
|
1709
|
+
updateImports();
|
|
1710
|
+
});
|
|
1711
|
+
function updateImports() {
|
|
1712
|
+
if (!_combinedImports) {
|
|
1713
|
+
let imports = normalizeImports(dedupeImports([...ctx.staticImports, ...ctx.dynamicImports], opts.warn || console.warn));
|
|
1714
|
+
for (const addon of ctx.addons) if (addon.extendImports) imports = addon.extendImports.call(ctx, imports) ?? imports;
|
|
1715
|
+
imports = imports.filter((i) => !i.disabled);
|
|
1716
|
+
_map.clear();
|
|
1717
|
+
for (const _import of imports) if (!_import.type) _map.set(_import.as ?? _import.name, _import);
|
|
1718
|
+
_combinedImports = imports;
|
|
1719
|
+
}
|
|
1720
|
+
return _combinedImports;
|
|
1721
|
+
}
|
|
1722
|
+
async function modifyDynamicImports(fn) {
|
|
1723
|
+
const result = await fn(ctx.dynamicImports);
|
|
1724
|
+
if (Array.isArray(result)) ctx.dynamicImports = result;
|
|
1725
|
+
ctx.invalidate();
|
|
1726
|
+
}
|
|
1727
|
+
function clearDynamicImports() {
|
|
1728
|
+
ctx.dynamicImports.length = 0;
|
|
1729
|
+
ctx.invalidate();
|
|
1730
|
+
}
|
|
1731
|
+
return ctx;
|
|
1732
|
+
}
|
|
1733
|
+
async function injectImports(code, id, ctx, options) {
|
|
1734
|
+
const s = getMagicString(code);
|
|
1735
|
+
if (ctx.options.commentsDisable?.some((c) => s.original.includes(c))) return {
|
|
1736
|
+
s,
|
|
1737
|
+
get code() {
|
|
1738
|
+
return s.toString();
|
|
1739
|
+
},
|
|
1740
|
+
imports: []
|
|
1741
|
+
};
|
|
1742
|
+
for (const addon of ctx.addons) await addon.transform?.call(ctx, s, id);
|
|
1743
|
+
const { isCJSContext, matchedImports, firstOccurrence } = await detectImports(s, ctx, options);
|
|
1744
|
+
const imports = await resolveImports(ctx, matchedImports, id);
|
|
1745
|
+
if (ctx.options.commentsDebug?.some((c) => s.original.includes(c))) (ctx.options.debugLog || console.log)(`[unimport] ${imports.length} imports detected in "${id}"${imports.length ? `: ${imports.map((i) => i.name).join(", ")}` : ""}`);
|
|
1746
|
+
return {
|
|
1747
|
+
...addImportToCode(s, imports, isCJSContext, options?.mergeExisting, options?.injectAtEnd, firstOccurrence, (imports2) => {
|
|
1748
|
+
for (const addon of ctx.addons) imports2 = addon.injectImportsResolved?.call(ctx, imports2, s, id) ?? imports2;
|
|
1749
|
+
return imports2;
|
|
1750
|
+
}, (str, imports2) => {
|
|
1751
|
+
for (const addon of ctx.addons) str = addon.injectImportsStringified?.call(ctx, str, imports2, s, id) ?? str;
|
|
1752
|
+
return str;
|
|
1753
|
+
}),
|
|
1754
|
+
imports
|
|
1755
|
+
};
|
|
1756
|
+
}
|
|
1757
|
+
async function resolveImports(ctx, imports, id) {
|
|
1758
|
+
const resolveCache = /* @__PURE__ */ new Map();
|
|
1759
|
+
return (await Promise.all(imports.map(async (i) => {
|
|
1760
|
+
if (!resolveCache.has(i.from)) resolveCache.set(i.from, await ctx.resolveId(i.from, id) || i.from);
|
|
1761
|
+
const from = resolveCache.get(i.from);
|
|
1762
|
+
if (i.from === id || !from || from === "." || from === id) return;
|
|
1763
|
+
return {
|
|
1764
|
+
...i,
|
|
1765
|
+
from
|
|
1766
|
+
};
|
|
1767
|
+
}))).filter(Boolean);
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
//#endregion
|
|
1771
|
+
//#region node_modules/.pnpm/unplugin@2.3.10/node_modules/unplugin/dist/context-D49cMElb.js
|
|
1772
|
+
var import_picomatch$1 = /* @__PURE__ */ __toESM(require_picomatch(), 1);
|
|
1773
|
+
function toArray$2(array) {
|
|
1774
|
+
array = array || [];
|
|
1775
|
+
if (Array.isArray(array)) return array;
|
|
1776
|
+
return [array];
|
|
1777
|
+
}
|
|
1778
|
+
const BACKSLASH_REGEX = /\\/g;
|
|
1779
|
+
function normalize$1(path$1) {
|
|
1780
|
+
return path$1.replace(BACKSLASH_REGEX, "/");
|
|
1781
|
+
}
|
|
1782
|
+
const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Z]:)?[/\\|])/i;
|
|
1783
|
+
function isAbsolute$1$1(path$1) {
|
|
1784
|
+
return ABSOLUTE_PATH_REGEX.test(path$1);
|
|
1785
|
+
}
|
|
1786
|
+
function getMatcherString$1(glob$1, cwd) {
|
|
1787
|
+
if (glob$1.startsWith("**") || isAbsolute$1$1(glob$1)) return normalize$1(glob$1);
|
|
1788
|
+
return normalize$1(resolve(cwd, glob$1));
|
|
1789
|
+
}
|
|
1790
|
+
function patternToIdFilter(pattern) {
|
|
1791
|
+
if (pattern instanceof RegExp) return (id) => {
|
|
1792
|
+
const normalizedId = normalize$1(id);
|
|
1793
|
+
const result = pattern.test(normalizedId);
|
|
1794
|
+
pattern.lastIndex = 0;
|
|
1795
|
+
return result;
|
|
1796
|
+
};
|
|
1797
|
+
const matcher = (0, import_picomatch$1.default)(getMatcherString$1(pattern, process.cwd()), { dot: true });
|
|
1798
|
+
return (id) => {
|
|
1799
|
+
return matcher(normalize$1(id));
|
|
1800
|
+
};
|
|
1801
|
+
}
|
|
1802
|
+
function patternToCodeFilter(pattern) {
|
|
1803
|
+
if (pattern instanceof RegExp) return (code) => {
|
|
1804
|
+
const result = pattern.test(code);
|
|
1805
|
+
pattern.lastIndex = 0;
|
|
1806
|
+
return result;
|
|
1807
|
+
};
|
|
1808
|
+
return (code) => code.includes(pattern);
|
|
1809
|
+
}
|
|
1810
|
+
function createFilter$1(exclude, include) {
|
|
1811
|
+
if (!exclude && !include) return;
|
|
1812
|
+
return (input) => {
|
|
1813
|
+
if (exclude?.some((filter) => filter(input))) return false;
|
|
1814
|
+
if (include?.some((filter) => filter(input))) return true;
|
|
1815
|
+
return !(include && include.length > 0);
|
|
1816
|
+
};
|
|
1817
|
+
}
|
|
1818
|
+
function normalizeFilter(filter) {
|
|
1819
|
+
if (typeof filter === "string" || filter instanceof RegExp) return { include: [filter] };
|
|
1820
|
+
if (Array.isArray(filter)) return { include: filter };
|
|
1821
|
+
return {
|
|
1822
|
+
exclude: filter.exclude ? toArray$2(filter.exclude) : void 0,
|
|
1823
|
+
include: filter.include ? toArray$2(filter.include) : void 0
|
|
1824
|
+
};
|
|
1825
|
+
}
|
|
1826
|
+
function createIdFilter(filter) {
|
|
1827
|
+
if (!filter) return;
|
|
1828
|
+
const { exclude, include } = normalizeFilter(filter);
|
|
1829
|
+
const excludeFilter = exclude?.map(patternToIdFilter);
|
|
1830
|
+
const includeFilter = include?.map(patternToIdFilter);
|
|
1831
|
+
return createFilter$1(excludeFilter, includeFilter);
|
|
1832
|
+
}
|
|
1833
|
+
function createCodeFilter(filter) {
|
|
1834
|
+
if (!filter) return;
|
|
1835
|
+
const { exclude, include } = normalizeFilter(filter);
|
|
1836
|
+
const excludeFilter = exclude?.map(patternToCodeFilter);
|
|
1837
|
+
const includeFilter = include?.map(patternToCodeFilter);
|
|
1838
|
+
return createFilter$1(excludeFilter, includeFilter);
|
|
1839
|
+
}
|
|
1840
|
+
function createFilterForId(filter) {
|
|
1841
|
+
const filterFunction = createIdFilter(filter);
|
|
1842
|
+
return filterFunction ? (id) => !!filterFunction(id) : void 0;
|
|
1843
|
+
}
|
|
1844
|
+
function createFilterForTransform(idFilter, codeFilter) {
|
|
1845
|
+
if (!idFilter && !codeFilter) return;
|
|
1846
|
+
const idFilterFunction = createIdFilter(idFilter);
|
|
1847
|
+
const codeFilterFunction = createCodeFilter(codeFilter);
|
|
1848
|
+
return (id, code) => {
|
|
1849
|
+
let fallback = true;
|
|
1850
|
+
if (idFilterFunction) fallback &&= idFilterFunction(id);
|
|
1851
|
+
if (!fallback) return false;
|
|
1852
|
+
if (codeFilterFunction) fallback &&= codeFilterFunction(code);
|
|
1853
|
+
return fallback;
|
|
1854
|
+
};
|
|
1855
|
+
}
|
|
1856
|
+
function normalizeObjectHook(name, hook) {
|
|
1857
|
+
let handler;
|
|
1858
|
+
let filter;
|
|
1859
|
+
if (typeof hook === "function") handler = hook;
|
|
1860
|
+
else {
|
|
1861
|
+
handler = hook.handler;
|
|
1862
|
+
const hookFilter = hook.filter;
|
|
1863
|
+
if (name === "resolveId" || name === "load") filter = createFilterForId(hookFilter?.id);
|
|
1864
|
+
else filter = createFilterForTransform(hookFilter?.id, hookFilter?.code);
|
|
1865
|
+
}
|
|
1866
|
+
return {
|
|
1867
|
+
handler,
|
|
1868
|
+
filter: filter || (() => true)
|
|
1869
|
+
};
|
|
1870
|
+
}
|
|
1871
|
+
function parse$1(code, opts = {}) {
|
|
1872
|
+
return Parser.parse(code, {
|
|
1873
|
+
sourceType: "module",
|
|
1874
|
+
ecmaVersion: "latest",
|
|
1875
|
+
locations: true,
|
|
1876
|
+
...opts
|
|
1877
|
+
});
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
//#endregion
|
|
1881
|
+
//#region node_modules/.pnpm/unplugin@2.3.10/node_modules/unplugin/dist/webpack-like-CSbnjTNU.js
|
|
1882
|
+
function transformUse(data, plugin, transformLoader) {
|
|
1883
|
+
if (data.resource == null) return [];
|
|
1884
|
+
const id = normalizeAbsolutePath(data.resource + (data.resourceQuery || ""));
|
|
1885
|
+
if (plugin.transformInclude && !plugin.transformInclude(id)) return [];
|
|
1886
|
+
const { filter } = normalizeObjectHook("load", plugin.transform);
|
|
1887
|
+
if (!filter(id)) return [];
|
|
1888
|
+
return [{
|
|
1889
|
+
loader: transformLoader,
|
|
1890
|
+
options: { plugin },
|
|
1891
|
+
ident: plugin.name
|
|
1892
|
+
}];
|
|
1893
|
+
}
|
|
1894
|
+
/**
|
|
1895
|
+
* Normalizes a given path when it's absolute. Normalizing means returning a new path by converting
|
|
1896
|
+
* the input path to the native os format. This is useful in cases where we want to normalize
|
|
1897
|
+
* the `id` argument of a hook. Any absolute ids should be in the default format
|
|
1898
|
+
* of the operating system. Any relative imports or node_module imports should remain
|
|
1899
|
+
* untouched.
|
|
1900
|
+
*
|
|
1901
|
+
* @param path - Path to normalize.
|
|
1902
|
+
* @returns a new normalized path.
|
|
1903
|
+
*/
|
|
1904
|
+
function normalizeAbsolutePath(path$1) {
|
|
1905
|
+
if (isAbsolute(path$1)) return normalize(path$1);
|
|
1906
|
+
else return path$1;
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
//#endregion
|
|
1910
|
+
//#region node_modules/.pnpm/unplugin@2.3.10/node_modules/unplugin/dist/context-D_KPTgTH.js
|
|
1911
|
+
function createBuildContext(compiler, compilation, loaderContext) {
|
|
1912
|
+
return {
|
|
1913
|
+
getNativeBuildContext() {
|
|
1914
|
+
return {
|
|
1915
|
+
framework: "rspack",
|
|
1916
|
+
compiler,
|
|
1917
|
+
compilation,
|
|
1918
|
+
loaderContext
|
|
1919
|
+
};
|
|
1920
|
+
},
|
|
1921
|
+
addWatchFile(file) {
|
|
1922
|
+
const cwd = process.cwd();
|
|
1923
|
+
compilation.fileDependencies.add(resolve(cwd, file));
|
|
1924
|
+
},
|
|
1925
|
+
getWatchFiles() {
|
|
1926
|
+
return Array.from(compilation.fileDependencies);
|
|
1927
|
+
},
|
|
1928
|
+
parse: parse$1,
|
|
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(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.10/node_modules/unplugin/dist/utils-C8vphsat.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.10/node_modules/unplugin/dist/context-BZKy5Nsn.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$1(options, compiler, compilation, loaderContext) {
|
|
2014
|
+
return {
|
|
2015
|
+
parse: parse$1,
|
|
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
|
+
};
|
|
2036
|
+
}
|
|
2037
|
+
};
|
|
2038
|
+
}
|
|
2039
|
+
function normalizeMessage$1(error) {
|
|
2040
|
+
const err = new Error(typeof error === "string" ? error : error.message);
|
|
2041
|
+
if (typeof error === "object") {
|
|
2042
|
+
err.stack = error.stack;
|
|
2043
|
+
err.cause = error.meta;
|
|
2044
|
+
}
|
|
2045
|
+
return err;
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
//#endregion
|
|
2049
|
+
//#region node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/virtual-stats.js
|
|
2050
|
+
var require_virtual_stats = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/virtual-stats.js": ((exports) => {
|
|
2051
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
2052
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
2053
|
+
};
|
|
2054
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2055
|
+
exports.VirtualStats = void 0;
|
|
2056
|
+
const constants_1 = __importDefault(__require("constants"));
|
|
2057
|
+
var VirtualStats = class {
|
|
2058
|
+
constructor(config) {
|
|
2059
|
+
for (const key in config) {
|
|
2060
|
+
if (!Object.prototype.hasOwnProperty.call(config, key)) continue;
|
|
2061
|
+
this[key] = config[key];
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
_checkModeProperty(property) {
|
|
2065
|
+
return (this.mode & constants_1.default.S_IFMT) === property;
|
|
2066
|
+
}
|
|
2067
|
+
isDirectory() {
|
|
2068
|
+
return this._checkModeProperty(constants_1.default.S_IFDIR);
|
|
2069
|
+
}
|
|
2070
|
+
isFile() {
|
|
2071
|
+
return this._checkModeProperty(constants_1.default.S_IFREG);
|
|
2072
|
+
}
|
|
2073
|
+
isBlockDevice() {
|
|
2074
|
+
return this._checkModeProperty(constants_1.default.S_IFBLK);
|
|
2075
|
+
}
|
|
2076
|
+
isCharacterDevice() {
|
|
2077
|
+
return this._checkModeProperty(constants_1.default.S_IFCHR);
|
|
2078
|
+
}
|
|
2079
|
+
isSymbolicLink() {
|
|
2080
|
+
return this._checkModeProperty(constants_1.default.S_IFLNK);
|
|
2081
|
+
}
|
|
2082
|
+
isFIFO() {
|
|
2083
|
+
return this._checkModeProperty(constants_1.default.S_IFIFO);
|
|
2084
|
+
}
|
|
2085
|
+
isSocket() {
|
|
2086
|
+
return this._checkModeProperty(constants_1.default.S_IFSOCK);
|
|
2087
|
+
}
|
|
2088
|
+
};
|
|
2089
|
+
exports.VirtualStats = VirtualStats;
|
|
2090
|
+
}) });
|
|
2091
|
+
|
|
2092
|
+
//#endregion
|
|
2093
|
+
//#region node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/index.js
|
|
2094
|
+
var require_lib = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/index.js": ((exports, module) => {
|
|
2095
|
+
const path_1 = (exports && exports.__importDefault || function(mod) {
|
|
2096
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
2097
|
+
})(__require("path"));
|
|
2098
|
+
const virtual_stats_1 = require_virtual_stats();
|
|
2099
|
+
let inode = 45e6;
|
|
2100
|
+
const ALL = "all";
|
|
2101
|
+
const STATIC = "static";
|
|
2102
|
+
const DYNAMIC = "dynamic";
|
|
2103
|
+
function checkActivation(instance) {
|
|
2104
|
+
if (!instance._compiler) throw new Error("You must use this plugin only after creating webpack instance!");
|
|
2105
|
+
}
|
|
2106
|
+
function getModulePath(filePath, compiler) {
|
|
2107
|
+
return path_1.default.isAbsolute(filePath) ? filePath : path_1.default.join(compiler.context, filePath);
|
|
2108
|
+
}
|
|
2109
|
+
function createWebpackData(result) {
|
|
2110
|
+
return (backendOrStorage) => {
|
|
2111
|
+
if (backendOrStorage._data) {
|
|
2112
|
+
const curLevelIdx = backendOrStorage._currentLevel;
|
|
2113
|
+
return {
|
|
2114
|
+
result,
|
|
2115
|
+
level: backendOrStorage._levels[curLevelIdx]
|
|
2116
|
+
};
|
|
2117
|
+
}
|
|
2118
|
+
return [null, result];
|
|
2119
|
+
};
|
|
2120
|
+
}
|
|
2121
|
+
function getData(storage, key) {
|
|
2122
|
+
if (storage._data instanceof Map) return storage._data.get(key);
|
|
2123
|
+
else if (storage._data) return storage.data[key];
|
|
2124
|
+
else if (storage.data instanceof Map) return storage.data.get(key);
|
|
2125
|
+
else return storage.data[key];
|
|
2126
|
+
}
|
|
2127
|
+
function setData(backendOrStorage, key, valueFactory) {
|
|
2128
|
+
const value = valueFactory(backendOrStorage);
|
|
2129
|
+
if (backendOrStorage._data instanceof Map) backendOrStorage._data.set(key, value);
|
|
2130
|
+
else if (backendOrStorage._data) backendOrStorage.data[key] = value;
|
|
2131
|
+
else if (backendOrStorage.data instanceof Map) backendOrStorage.data.set(key, value);
|
|
2132
|
+
else backendOrStorage.data[key] = value;
|
|
2133
|
+
}
|
|
2134
|
+
function getStatStorage(fileSystem) {
|
|
2135
|
+
if (fileSystem._statStorage) return fileSystem._statStorage;
|
|
2136
|
+
else if (fileSystem._statBackend) return fileSystem._statBackend;
|
|
2137
|
+
else throw new Error("Couldn't find a stat storage");
|
|
2138
|
+
}
|
|
2139
|
+
function getFileStorage(fileSystem) {
|
|
2140
|
+
if (fileSystem._readFileStorage) return fileSystem._readFileStorage;
|
|
2141
|
+
else if (fileSystem._readFileBackend) return fileSystem._readFileBackend;
|
|
2142
|
+
else throw new Error("Couldn't find a readFileStorage");
|
|
2143
|
+
}
|
|
2144
|
+
function getReadDirBackend(fileSystem) {
|
|
2145
|
+
if (fileSystem._readdirBackend) return fileSystem._readdirBackend;
|
|
2146
|
+
else if (fileSystem._readdirStorage) return fileSystem._readdirStorage;
|
|
2147
|
+
else throw new Error("Couldn't find a readDirStorage from Webpack Internals");
|
|
2148
|
+
}
|
|
2149
|
+
function getRealpathBackend(fileSystem) {
|
|
2150
|
+
if (fileSystem._realpathBackend) return fileSystem._realpathBackend;
|
|
2151
|
+
}
|
|
2152
|
+
var VirtualModulesPlugin$1 = class {
|
|
2153
|
+
constructor(modules) {
|
|
2154
|
+
this._compiler = null;
|
|
2155
|
+
this._watcher = null;
|
|
2156
|
+
this._staticModules = modules || null;
|
|
2157
|
+
}
|
|
2158
|
+
getModuleList(filter = ALL) {
|
|
2159
|
+
var _a, _b;
|
|
2160
|
+
let modules = {};
|
|
2161
|
+
const shouldGetStaticModules = filter === ALL || filter === STATIC;
|
|
2162
|
+
const shouldGetDynamicModules = filter === ALL || filter === DYNAMIC;
|
|
2163
|
+
if (shouldGetStaticModules) modules = Object.assign(Object.assign({}, modules), this._staticModules);
|
|
2164
|
+
if (shouldGetDynamicModules) {
|
|
2165
|
+
const finalInputFileSystem = (_a = this._compiler) === null || _a === void 0 ? void 0 : _a.inputFileSystem;
|
|
2166
|
+
const virtualFiles = (_b = finalInputFileSystem === null || finalInputFileSystem === void 0 ? void 0 : finalInputFileSystem._virtualFiles) !== null && _b !== void 0 ? _b : {};
|
|
2167
|
+
const dynamicModules = {};
|
|
2168
|
+
Object.keys(virtualFiles).forEach((key) => {
|
|
2169
|
+
dynamicModules[key] = virtualFiles[key].contents;
|
|
2170
|
+
});
|
|
2171
|
+
modules = Object.assign(Object.assign({}, modules), dynamicModules);
|
|
2172
|
+
}
|
|
2173
|
+
return modules;
|
|
2174
|
+
}
|
|
2175
|
+
writeModule(filePath, contents) {
|
|
2176
|
+
if (!this._compiler) throw new Error(`Plugin has not been initialized`);
|
|
2177
|
+
checkActivation(this);
|
|
2178
|
+
const len = contents ? contents.length : 0;
|
|
2179
|
+
const time = Date.now();
|
|
2180
|
+
const date = new Date(time);
|
|
2181
|
+
const stats = new virtual_stats_1.VirtualStats({
|
|
2182
|
+
dev: 8675309,
|
|
2183
|
+
nlink: 0,
|
|
2184
|
+
uid: 1e3,
|
|
2185
|
+
gid: 1e3,
|
|
2186
|
+
rdev: 0,
|
|
2187
|
+
blksize: 4096,
|
|
2188
|
+
ino: inode++,
|
|
2189
|
+
mode: 33188,
|
|
2190
|
+
size: len,
|
|
2191
|
+
blocks: Math.floor(len / 4096),
|
|
2192
|
+
atime: date,
|
|
2193
|
+
mtime: date,
|
|
2194
|
+
ctime: date,
|
|
2195
|
+
birthtime: date
|
|
2196
|
+
});
|
|
2197
|
+
const modulePath = getModulePath(filePath, this._compiler);
|
|
2198
|
+
if (process.env.WVM_DEBUG) console.log(this._compiler.name, "Write virtual module:", modulePath, contents);
|
|
2199
|
+
let finalWatchFileSystem = this._watcher && this._watcher.watchFileSystem;
|
|
2200
|
+
while (finalWatchFileSystem && finalWatchFileSystem.wfs) finalWatchFileSystem = finalWatchFileSystem.wfs;
|
|
2201
|
+
let finalInputFileSystem = this._compiler.inputFileSystem;
|
|
2202
|
+
while (finalInputFileSystem && finalInputFileSystem._inputFileSystem) finalInputFileSystem = finalInputFileSystem._inputFileSystem;
|
|
2203
|
+
finalInputFileSystem._writeVirtualFile(modulePath, stats, contents);
|
|
2204
|
+
if (finalWatchFileSystem && finalWatchFileSystem.watcher && (finalWatchFileSystem.watcher.fileWatchers.size || finalWatchFileSystem.watcher.fileWatchers.length)) {
|
|
2205
|
+
const fileWatchers = finalWatchFileSystem.watcher.fileWatchers instanceof Map ? Array.from(finalWatchFileSystem.watcher.fileWatchers.values()) : finalWatchFileSystem.watcher.fileWatchers;
|
|
2206
|
+
for (let fileWatcher of fileWatchers) {
|
|
2207
|
+
if ("watcher" in fileWatcher) fileWatcher = fileWatcher.watcher;
|
|
2208
|
+
if (fileWatcher.path === modulePath) {
|
|
2209
|
+
if (process.env.DEBUG) console.log(this._compiler.name, "Emit file change:", modulePath, time);
|
|
2210
|
+
delete fileWatcher.directoryWatcher._cachedTimeInfoEntries;
|
|
2211
|
+
fileWatcher.emit("change", time, null);
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
apply(compiler) {
|
|
2217
|
+
this._compiler = compiler;
|
|
2218
|
+
const afterEnvironmentHook = () => {
|
|
2219
|
+
let finalInputFileSystem = compiler.inputFileSystem;
|
|
2220
|
+
while (finalInputFileSystem && finalInputFileSystem._inputFileSystem) finalInputFileSystem = finalInputFileSystem._inputFileSystem;
|
|
2221
|
+
if (!finalInputFileSystem._writeVirtualFile) {
|
|
2222
|
+
const originalPurge = finalInputFileSystem.purge;
|
|
2223
|
+
finalInputFileSystem.purge = () => {
|
|
2224
|
+
originalPurge.apply(finalInputFileSystem, []);
|
|
2225
|
+
if (finalInputFileSystem._virtualFiles) Object.keys(finalInputFileSystem._virtualFiles).forEach((file) => {
|
|
2226
|
+
const data = finalInputFileSystem._virtualFiles[file];
|
|
2227
|
+
finalInputFileSystem._writeVirtualFile(file, data.stats, data.contents);
|
|
2228
|
+
});
|
|
2229
|
+
};
|
|
2230
|
+
finalInputFileSystem._writeVirtualFile = (file, stats, contents) => {
|
|
2231
|
+
const statStorage = getStatStorage(finalInputFileSystem);
|
|
2232
|
+
const fileStorage = getFileStorage(finalInputFileSystem);
|
|
2233
|
+
const readDirStorage = getReadDirBackend(finalInputFileSystem);
|
|
2234
|
+
const realPathStorage = getRealpathBackend(finalInputFileSystem);
|
|
2235
|
+
finalInputFileSystem._virtualFiles = finalInputFileSystem._virtualFiles || {};
|
|
2236
|
+
finalInputFileSystem._virtualFiles[file] = {
|
|
2237
|
+
stats,
|
|
2238
|
+
contents
|
|
2239
|
+
};
|
|
2240
|
+
setData(statStorage, file, createWebpackData(stats));
|
|
2241
|
+
setData(fileStorage, file, createWebpackData(contents));
|
|
2242
|
+
const segments = file.split(/[\\/]/);
|
|
2243
|
+
let count = segments.length - 1;
|
|
2244
|
+
const minCount = segments[0] ? 1 : 0;
|
|
2245
|
+
while (count > minCount) {
|
|
2246
|
+
const dir = segments.slice(0, count).join(path_1.default.sep) || path_1.default.sep;
|
|
2247
|
+
try {
|
|
2248
|
+
finalInputFileSystem.readdirSync(dir);
|
|
2249
|
+
} catch (e) {
|
|
2250
|
+
const time = Date.now();
|
|
2251
|
+
const dirStats = new virtual_stats_1.VirtualStats({
|
|
2252
|
+
dev: 8675309,
|
|
2253
|
+
nlink: 0,
|
|
2254
|
+
uid: 1e3,
|
|
2255
|
+
gid: 1e3,
|
|
2256
|
+
rdev: 0,
|
|
2257
|
+
blksize: 4096,
|
|
2258
|
+
ino: inode++,
|
|
2259
|
+
mode: 16877,
|
|
2260
|
+
size: stats.size,
|
|
2261
|
+
blocks: Math.floor(stats.size / 4096),
|
|
2262
|
+
atime: time,
|
|
2263
|
+
mtime: time,
|
|
2264
|
+
ctime: time,
|
|
2265
|
+
birthtime: time
|
|
2266
|
+
});
|
|
2267
|
+
setData(readDirStorage, dir, createWebpackData([]));
|
|
2268
|
+
if (realPathStorage) setData(realPathStorage, dir, createWebpackData(dir));
|
|
2269
|
+
setData(statStorage, dir, createWebpackData(dirStats));
|
|
2270
|
+
}
|
|
2271
|
+
let dirData = getData(getReadDirBackend(finalInputFileSystem), dir);
|
|
2272
|
+
dirData = dirData[1] || dirData.result;
|
|
2273
|
+
const filename = segments[count];
|
|
2274
|
+
if (dirData.indexOf(filename) < 0) {
|
|
2275
|
+
const files = dirData.concat([filename]).sort();
|
|
2276
|
+
setData(getReadDirBackend(finalInputFileSystem), dir, createWebpackData(files));
|
|
2277
|
+
} else break;
|
|
2278
|
+
count--;
|
|
2279
|
+
}
|
|
2280
|
+
};
|
|
2281
|
+
}
|
|
2282
|
+
};
|
|
2283
|
+
const afterResolversHook = () => {
|
|
2284
|
+
if (this._staticModules) {
|
|
2285
|
+
for (const [filePath, contents] of Object.entries(this._staticModules)) this.writeModule(filePath, contents);
|
|
2286
|
+
this._staticModules = null;
|
|
2287
|
+
}
|
|
2288
|
+
};
|
|
2289
|
+
const version$1 = typeof compiler.webpack === "undefined" ? 4 : 5;
|
|
2290
|
+
const watchRunHook = (watcher, callback) => {
|
|
2291
|
+
this._watcher = watcher.compiler || watcher;
|
|
2292
|
+
const virtualFiles = compiler.inputFileSystem._virtualFiles;
|
|
2293
|
+
const fts = compiler.fileTimestamps;
|
|
2294
|
+
if (virtualFiles && fts && typeof fts.set === "function") Object.keys(virtualFiles).forEach((file) => {
|
|
2295
|
+
const mtime = +virtualFiles[file].stats.mtime;
|
|
2296
|
+
fts.set(file, version$1 === 4 ? mtime : {
|
|
2297
|
+
safeTime: mtime,
|
|
2298
|
+
timestamp: mtime
|
|
2299
|
+
});
|
|
2300
|
+
});
|
|
2301
|
+
callback();
|
|
2302
|
+
};
|
|
2303
|
+
if (compiler.hooks) {
|
|
2304
|
+
compiler.hooks.afterEnvironment.tap("VirtualModulesPlugin", afterEnvironmentHook);
|
|
2305
|
+
compiler.hooks.afterResolvers.tap("VirtualModulesPlugin", afterResolversHook);
|
|
2306
|
+
compiler.hooks.watchRun.tapAsync("VirtualModulesPlugin", watchRunHook);
|
|
2307
|
+
} else {
|
|
2308
|
+
compiler.plugin("after-environment", afterEnvironmentHook);
|
|
2309
|
+
compiler.plugin("after-resolvers", afterResolversHook);
|
|
2310
|
+
compiler.plugin("watch-run", watchRunHook);
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
};
|
|
2314
|
+
module.exports = VirtualModulesPlugin$1;
|
|
2315
|
+
}) });
|
|
2316
|
+
|
|
2317
|
+
//#endregion
|
|
2318
|
+
//#region node_modules/.pnpm/unplugin@2.3.10/node_modules/unplugin/dist/index.js
|
|
2319
|
+
var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
|
|
2320
|
+
const ExtToLoader = {
|
|
2321
|
+
".js": "js",
|
|
2322
|
+
".mjs": "js",
|
|
2323
|
+
".cjs": "js",
|
|
2324
|
+
".jsx": "jsx",
|
|
2325
|
+
".ts": "ts",
|
|
2326
|
+
".cts": "ts",
|
|
2327
|
+
".mts": "ts",
|
|
2328
|
+
".tsx": "tsx",
|
|
2329
|
+
".css": "css",
|
|
2330
|
+
".less": "css",
|
|
2331
|
+
".stylus": "css",
|
|
2332
|
+
".scss": "css",
|
|
2333
|
+
".sass": "css",
|
|
2334
|
+
".json": "json",
|
|
2335
|
+
".txt": "text"
|
|
2336
|
+
};
|
|
2337
|
+
function guessLoader(code, id) {
|
|
2338
|
+
return ExtToLoader[path.extname(id).toLowerCase()] || "js";
|
|
2339
|
+
}
|
|
2340
|
+
function unwrapLoader(loader, code, id) {
|
|
2341
|
+
if (typeof loader === "function") return loader(code, id);
|
|
2342
|
+
return loader;
|
|
2343
|
+
}
|
|
2344
|
+
function fixSourceMap(map) {
|
|
2345
|
+
if (!Object.prototype.hasOwnProperty.call(map, "toString")) Object.defineProperty(map, "toString", {
|
|
2346
|
+
enumerable: false,
|
|
2347
|
+
value: function toString() {
|
|
2348
|
+
return JSON.stringify(this);
|
|
2349
|
+
}
|
|
2350
|
+
});
|
|
2351
|
+
if (!Object.prototype.hasOwnProperty.call(map, "toUrl")) Object.defineProperty(map, "toUrl", {
|
|
2352
|
+
enumerable: false,
|
|
2353
|
+
value: function toUrl() {
|
|
2354
|
+
return `data:application/json;charset=utf-8;base64,${Buffer.from(this.toString()).toString("base64")}`;
|
|
2355
|
+
}
|
|
2356
|
+
});
|
|
2357
|
+
return map;
|
|
2358
|
+
}
|
|
2359
|
+
const nullSourceMap = {
|
|
2360
|
+
names: [],
|
|
2361
|
+
sources: [],
|
|
2362
|
+
mappings: "",
|
|
2363
|
+
version: 3
|
|
2364
|
+
};
|
|
2365
|
+
function combineSourcemaps(filename, sourcemapList) {
|
|
2366
|
+
sourcemapList = sourcemapList.filter((m) => m.sources);
|
|
2367
|
+
if (sourcemapList.length === 0 || sourcemapList.every((m) => m.sources.length === 0)) return { ...nullSourceMap };
|
|
2368
|
+
let map;
|
|
2369
|
+
let mapIndex = 1;
|
|
2370
|
+
if (sourcemapList.slice(0, -1).find((m) => m.sources.length !== 1) === void 0) map = remapping(sourcemapList, () => null, true);
|
|
2371
|
+
else map = remapping(sourcemapList[0], (sourcefile) => {
|
|
2372
|
+
if (sourcefile === filename && sourcemapList[mapIndex]) return sourcemapList[mapIndex++];
|
|
2373
|
+
else return { ...nullSourceMap };
|
|
2374
|
+
}, true);
|
|
2375
|
+
if (!map.file) delete map.file;
|
|
2376
|
+
return map;
|
|
2377
|
+
}
|
|
2378
|
+
function createBuildContext$2(build) {
|
|
2379
|
+
const watchFiles = [];
|
|
2380
|
+
const { initialOptions } = build;
|
|
2381
|
+
return {
|
|
2382
|
+
parse: parse$1,
|
|
2383
|
+
addWatchFile() {
|
|
2384
|
+
throw new Error("unplugin/esbuild: addWatchFile outside supported hooks (resolveId, load, transform)");
|
|
2385
|
+
},
|
|
2386
|
+
emitFile(emittedFile) {
|
|
2387
|
+
const outFileName = emittedFile.fileName || emittedFile.name;
|
|
2388
|
+
if (initialOptions.outdir && emittedFile.source && outFileName) {
|
|
2389
|
+
const outPath = path.resolve(initialOptions.outdir, outFileName);
|
|
2390
|
+
const outDir = path.dirname(outPath);
|
|
2391
|
+
if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true });
|
|
2392
|
+
fs.writeFileSync(outPath, emittedFile.source);
|
|
2393
|
+
}
|
|
2394
|
+
},
|
|
2395
|
+
getWatchFiles() {
|
|
2396
|
+
return watchFiles;
|
|
2397
|
+
},
|
|
2398
|
+
getNativeBuildContext() {
|
|
2399
|
+
return {
|
|
2400
|
+
framework: "esbuild",
|
|
2401
|
+
build
|
|
2402
|
+
};
|
|
2403
|
+
}
|
|
2404
|
+
};
|
|
2405
|
+
}
|
|
2406
|
+
function createPluginContext(context) {
|
|
2407
|
+
const errors = [];
|
|
2408
|
+
const warnings = [];
|
|
2409
|
+
const pluginContext = {
|
|
2410
|
+
error(message) {
|
|
2411
|
+
errors.push(normalizeMessage$2(message));
|
|
2412
|
+
},
|
|
2413
|
+
warn(message) {
|
|
2414
|
+
warnings.push(normalizeMessage$2(message));
|
|
2415
|
+
}
|
|
2416
|
+
};
|
|
2417
|
+
return {
|
|
2418
|
+
errors,
|
|
2419
|
+
warnings,
|
|
2420
|
+
mixedContext: {
|
|
2421
|
+
...context,
|
|
2422
|
+
...pluginContext,
|
|
2423
|
+
addWatchFile(id) {
|
|
2424
|
+
context.getWatchFiles().push(id);
|
|
2425
|
+
}
|
|
2426
|
+
}
|
|
2427
|
+
};
|
|
2428
|
+
}
|
|
2429
|
+
function normalizeMessage$2(message) {
|
|
2430
|
+
if (typeof message === "string") message = { message };
|
|
2431
|
+
return {
|
|
2432
|
+
id: message.id,
|
|
2433
|
+
pluginName: message.plugin,
|
|
2434
|
+
text: message.message,
|
|
2435
|
+
location: message.loc ? {
|
|
2436
|
+
file: message.loc.file,
|
|
2437
|
+
line: message.loc.line,
|
|
2438
|
+
column: message.loc.column
|
|
2439
|
+
} : null,
|
|
2440
|
+
detail: message.meta,
|
|
2441
|
+
notes: []
|
|
2442
|
+
};
|
|
2443
|
+
}
|
|
2444
|
+
function processCodeWithSourceMap(map, code) {
|
|
2445
|
+
if (map) {
|
|
2446
|
+
if (!map.sourcesContent || map.sourcesContent.length === 0) map.sourcesContent = [code];
|
|
2447
|
+
map = fixSourceMap(map);
|
|
2448
|
+
code += `\n//# sourceMappingURL=${map.toUrl()}`;
|
|
2449
|
+
}
|
|
2450
|
+
return code;
|
|
2451
|
+
}
|
|
2452
|
+
function getEsbuildPlugin(factory) {
|
|
2453
|
+
return (userOptions) => {
|
|
2454
|
+
const meta = { framework: "esbuild" };
|
|
2455
|
+
const plugins = toArray$2(factory(userOptions, meta));
|
|
2456
|
+
const setupPlugins = async (build) => {
|
|
2457
|
+
const setup = buildSetup();
|
|
2458
|
+
const loaders = [];
|
|
2459
|
+
for (const plugin of plugins) {
|
|
2460
|
+
const loader = {};
|
|
2461
|
+
await setup(plugin)({
|
|
2462
|
+
...build,
|
|
2463
|
+
onLoad(_options, callback) {
|
|
2464
|
+
loader.options = _options;
|
|
2465
|
+
loader.onLoadCb = callback;
|
|
2466
|
+
},
|
|
2467
|
+
onTransform(_options, callback) {
|
|
2468
|
+
loader.options ||= _options;
|
|
2469
|
+
loader.onTransformCb = callback;
|
|
2470
|
+
}
|
|
2471
|
+
}, build);
|
|
2472
|
+
if (loader.onLoadCb || loader.onTransformCb) loaders.push(loader);
|
|
2473
|
+
}
|
|
2474
|
+
if (loaders.length) build.onLoad(loaders.length === 1 ? loaders[0].options : { filter: /.*/ }, async (args) => {
|
|
2475
|
+
function checkFilter(options) {
|
|
2476
|
+
return loaders.length === 1 || !options?.filter || options.filter.test(args.path);
|
|
2477
|
+
}
|
|
2478
|
+
let result;
|
|
2479
|
+
for (const { options, onLoadCb } of loaders) {
|
|
2480
|
+
if (!checkFilter(options)) continue;
|
|
2481
|
+
if (onLoadCb) result = await onLoadCb(args);
|
|
2482
|
+
if (result?.contents) break;
|
|
2483
|
+
}
|
|
2484
|
+
let fsContentsCache;
|
|
2485
|
+
for (const { options, onTransformCb } of loaders) {
|
|
2486
|
+
if (!checkFilter(options)) continue;
|
|
2487
|
+
if (onTransformCb) {
|
|
2488
|
+
const _result = await onTransformCb({
|
|
2489
|
+
...result,
|
|
2490
|
+
...args,
|
|
2491
|
+
async getContents() {
|
|
2492
|
+
if (result?.contents) return result.contents;
|
|
2493
|
+
if (fsContentsCache) return fsContentsCache;
|
|
2494
|
+
return fsContentsCache = await fs.promises.readFile(args.path, "utf8");
|
|
2495
|
+
}
|
|
2496
|
+
});
|
|
2497
|
+
if (_result?.contents) result = _result;
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
if (result?.contents) return result;
|
|
2501
|
+
});
|
|
2502
|
+
};
|
|
2503
|
+
return {
|
|
2504
|
+
name: (plugins.length === 1 ? plugins[0].name : meta.esbuildHostName) ?? `unplugin-host:${plugins.map((p) => p.name).join(":")}`,
|
|
2505
|
+
setup: setupPlugins
|
|
2506
|
+
};
|
|
2507
|
+
};
|
|
2508
|
+
}
|
|
2509
|
+
function buildSetup() {
|
|
2510
|
+
return (plugin) => {
|
|
2511
|
+
return (build, rawBuild) => {
|
|
2512
|
+
const context = createBuildContext$2(rawBuild);
|
|
2513
|
+
const { onStart, onEnd, onResolve, onLoad, onTransform, initialOptions } = build;
|
|
2514
|
+
const onResolveFilter = plugin.esbuild?.onResolveFilter ?? /.*/;
|
|
2515
|
+
const onLoadFilter = plugin.esbuild?.onLoadFilter ?? /.*/;
|
|
2516
|
+
const loader = plugin.esbuild?.loader ?? guessLoader;
|
|
2517
|
+
plugin.esbuild?.config?.call(context, initialOptions);
|
|
2518
|
+
if (plugin.buildStart) onStart(() => plugin.buildStart.call(context));
|
|
2519
|
+
if (plugin.buildEnd || plugin.writeBundle) onEnd(async () => {
|
|
2520
|
+
if (plugin.buildEnd) await plugin.buildEnd.call(context);
|
|
2521
|
+
if (plugin.writeBundle) await plugin.writeBundle();
|
|
2522
|
+
});
|
|
2523
|
+
if (plugin.resolveId) onResolve({ filter: onResolveFilter }, async (args) => {
|
|
2524
|
+
const id = args.path;
|
|
2525
|
+
if (initialOptions.external?.includes(id)) return;
|
|
2526
|
+
const { handler, filter } = normalizeObjectHook("resolveId", plugin.resolveId);
|
|
2527
|
+
if (!filter(id)) return;
|
|
2528
|
+
const { errors, warnings, mixedContext } = createPluginContext(context);
|
|
2529
|
+
const isEntry = args.kind === "entry-point";
|
|
2530
|
+
const result = await handler.call(mixedContext, id, isEntry ? void 0 : args.importer, { isEntry });
|
|
2531
|
+
if (typeof result === "string") return {
|
|
2532
|
+
path: result,
|
|
2533
|
+
namespace: plugin.name,
|
|
2534
|
+
errors,
|
|
2535
|
+
warnings,
|
|
2536
|
+
watchFiles: mixedContext.getWatchFiles()
|
|
2537
|
+
};
|
|
2538
|
+
else if (typeof result === "object" && result !== null) return {
|
|
2539
|
+
path: result.id,
|
|
2540
|
+
external: result.external,
|
|
2541
|
+
namespace: plugin.name,
|
|
2542
|
+
errors,
|
|
2543
|
+
warnings,
|
|
2544
|
+
watchFiles: mixedContext.getWatchFiles()
|
|
2545
|
+
};
|
|
2546
|
+
});
|
|
2547
|
+
if (plugin.load) onLoad({ filter: onLoadFilter }, async (args) => {
|
|
2548
|
+
const { handler, filter } = normalizeObjectHook("load", plugin.load);
|
|
2549
|
+
const id = args.path + (args.suffix || "");
|
|
2550
|
+
if (plugin.loadInclude && !plugin.loadInclude(id)) return;
|
|
2551
|
+
if (!filter(id)) return;
|
|
2552
|
+
const { errors, warnings, mixedContext } = createPluginContext(context);
|
|
2553
|
+
let code;
|
|
2554
|
+
let map;
|
|
2555
|
+
const result = await handler.call(mixedContext, id);
|
|
2556
|
+
if (typeof result === "string") code = result;
|
|
2557
|
+
else if (typeof result === "object" && result !== null) {
|
|
2558
|
+
code = result.code;
|
|
2559
|
+
map = result.map;
|
|
2560
|
+
}
|
|
2561
|
+
if (code === void 0) return null;
|
|
2562
|
+
if (map) code = processCodeWithSourceMap(map, code);
|
|
2563
|
+
const resolveDir = path.dirname(args.path);
|
|
2564
|
+
return {
|
|
2565
|
+
contents: code,
|
|
2566
|
+
errors,
|
|
2567
|
+
warnings,
|
|
2568
|
+
watchFiles: mixedContext.getWatchFiles(),
|
|
2569
|
+
loader: unwrapLoader(loader, code, args.path),
|
|
2570
|
+
resolveDir
|
|
2571
|
+
};
|
|
2572
|
+
});
|
|
2573
|
+
if (plugin.transform) onTransform({ filter: onLoadFilter }, async (args) => {
|
|
2574
|
+
const { handler, filter } = normalizeObjectHook("transform", plugin.transform);
|
|
2575
|
+
const id = args.path + (args.suffix || "");
|
|
2576
|
+
if (plugin.transformInclude && !plugin.transformInclude(id)) return;
|
|
2577
|
+
let code = await args.getContents();
|
|
2578
|
+
if (!filter(id, code)) return;
|
|
2579
|
+
const { mixedContext, errors, warnings } = createPluginContext(context);
|
|
2580
|
+
const resolveDir = path.dirname(args.path);
|
|
2581
|
+
let map;
|
|
2582
|
+
const result = await handler.call(mixedContext, code, id);
|
|
2583
|
+
if (typeof result === "string") code = result;
|
|
2584
|
+
else if (typeof result === "object" && result !== null) {
|
|
2585
|
+
code = result.code;
|
|
2586
|
+
if (map && result.map) map = combineSourcemaps(args.path, [result.map === "string" ? JSON.parse(result.map) : result.map, map]);
|
|
2587
|
+
else if (typeof result.map === "string") map = JSON.parse(result.map);
|
|
2588
|
+
else map = result.map;
|
|
2589
|
+
}
|
|
2590
|
+
if (code) {
|
|
2591
|
+
if (map) code = processCodeWithSourceMap(map, code);
|
|
2592
|
+
return {
|
|
2593
|
+
contents: code,
|
|
2594
|
+
errors,
|
|
2595
|
+
warnings,
|
|
2596
|
+
watchFiles: mixedContext.getWatchFiles(),
|
|
2597
|
+
loader: unwrapLoader(loader, code, args.path),
|
|
2598
|
+
resolveDir
|
|
2599
|
+
};
|
|
2600
|
+
}
|
|
2601
|
+
});
|
|
2602
|
+
if (plugin.esbuild?.setup) return plugin.esbuild.setup(rawBuild);
|
|
2603
|
+
};
|
|
2604
|
+
};
|
|
2605
|
+
}
|
|
2606
|
+
function createFarmContext(context, currentResolveId) {
|
|
2607
|
+
return {
|
|
2608
|
+
parse: parse$1,
|
|
2609
|
+
addWatchFile(id) {
|
|
2610
|
+
context.addWatchFile(id, currentResolveId || id);
|
|
2611
|
+
},
|
|
2612
|
+
emitFile(emittedFile) {
|
|
2613
|
+
const outFileName = emittedFile.fileName || emittedFile.name;
|
|
2614
|
+
if (emittedFile.source && outFileName) context.emitFile({
|
|
2615
|
+
resolvedPath: outFileName,
|
|
2616
|
+
name: outFileName,
|
|
2617
|
+
content: [...Buffer.from(emittedFile.source)],
|
|
2618
|
+
resourceType: extname(outFileName)
|
|
2619
|
+
});
|
|
2620
|
+
},
|
|
2621
|
+
getWatchFiles() {
|
|
2622
|
+
return context.getWatchFiles();
|
|
2623
|
+
},
|
|
2624
|
+
getNativeBuildContext() {
|
|
2625
|
+
return {
|
|
2626
|
+
framework: "farm",
|
|
2627
|
+
context
|
|
2628
|
+
};
|
|
2629
|
+
}
|
|
2630
|
+
};
|
|
2631
|
+
}
|
|
2632
|
+
function unpluginContext(context) {
|
|
2633
|
+
return {
|
|
2634
|
+
error: (error) => context.error(typeof error === "string" ? new Error(error) : error),
|
|
2635
|
+
warn: (error) => context.warn(typeof error === "string" ? new Error(error) : error)
|
|
2636
|
+
};
|
|
2637
|
+
}
|
|
2638
|
+
function convertEnforceToPriority(value) {
|
|
2639
|
+
const defaultPriority = 100;
|
|
2640
|
+
const enforceToPriority = {
|
|
2641
|
+
pre: 102,
|
|
2642
|
+
post: 98
|
|
2643
|
+
};
|
|
2644
|
+
return enforceToPriority[value] !== void 0 ? enforceToPriority[value] : defaultPriority;
|
|
2645
|
+
}
|
|
2646
|
+
function convertWatchEventChange(value) {
|
|
2647
|
+
return {
|
|
2648
|
+
Added: "create",
|
|
2649
|
+
Updated: "update",
|
|
2650
|
+
Removed: "delete"
|
|
2651
|
+
}[value];
|
|
2652
|
+
}
|
|
2653
|
+
function isString(variable) {
|
|
2654
|
+
return typeof variable === "string";
|
|
2655
|
+
}
|
|
2656
|
+
function isObject(variable) {
|
|
2657
|
+
return typeof variable === "object" && variable !== null;
|
|
2658
|
+
}
|
|
2659
|
+
function customParseQueryString(url) {
|
|
2660
|
+
if (!url) return [];
|
|
2661
|
+
const queryString = url.split("?")[1];
|
|
2662
|
+
const parsedParams = querystring.parse(queryString);
|
|
2663
|
+
const paramsArray = [];
|
|
2664
|
+
for (const key in parsedParams) paramsArray.push([key, parsedParams[key]]);
|
|
2665
|
+
return paramsArray;
|
|
2666
|
+
}
|
|
2667
|
+
function encodeStr(str) {
|
|
2668
|
+
const len = str.length;
|
|
2669
|
+
if (len === 0) return str;
|
|
2670
|
+
const firstNullIndex = str.indexOf("\0");
|
|
2671
|
+
if (firstNullIndex === -1) return str;
|
|
2672
|
+
const result = Array.from({ length: len + countNulls(str, firstNullIndex) });
|
|
2673
|
+
let pos = 0;
|
|
2674
|
+
for (let i = 0; i < firstNullIndex; i++) result[pos++] = str[i];
|
|
2675
|
+
for (let i = firstNullIndex; i < len; i++) {
|
|
2676
|
+
const char = str[i];
|
|
2677
|
+
if (char === "\0") {
|
|
2678
|
+
result[pos++] = "\\";
|
|
2679
|
+
result[pos++] = "0";
|
|
2680
|
+
} else result[pos++] = char;
|
|
2681
|
+
}
|
|
2682
|
+
return path.posix.normalize(result.join(""));
|
|
2683
|
+
}
|
|
2684
|
+
function decodeStr(str) {
|
|
2685
|
+
const len = str.length;
|
|
2686
|
+
if (len === 0) return str;
|
|
2687
|
+
const firstIndex = str.indexOf("\\0");
|
|
2688
|
+
if (firstIndex === -1) return str;
|
|
2689
|
+
const result = Array.from({ length: len - countBackslashZeros(str, firstIndex) });
|
|
2690
|
+
let pos = 0;
|
|
2691
|
+
for (let i$1 = 0; i$1 < firstIndex; i$1++) result[pos++] = str[i$1];
|
|
2692
|
+
let i = firstIndex;
|
|
2693
|
+
while (i < len) if (str[i] === "\\" && str[i + 1] === "0") {
|
|
2694
|
+
result[pos++] = "\0";
|
|
2695
|
+
i += 2;
|
|
2696
|
+
} else result[pos++] = str[i++];
|
|
2697
|
+
return path.posix.normalize(result.join(""));
|
|
2698
|
+
}
|
|
2699
|
+
function getContentValue(content) {
|
|
2700
|
+
if (content === null || content === void 0) throw new Error("Content cannot be null or undefined");
|
|
2701
|
+
return encodeStr(typeof content === "string" ? content : content.code || "");
|
|
2702
|
+
}
|
|
2703
|
+
function countNulls(str, startIndex) {
|
|
2704
|
+
let count = 0;
|
|
2705
|
+
const len = str.length;
|
|
2706
|
+
for (let i = startIndex; i < len; i++) if (str[i] === "\0") count++;
|
|
2707
|
+
return count;
|
|
2708
|
+
}
|
|
2709
|
+
function countBackslashZeros(str, startIndex) {
|
|
2710
|
+
let count = 0;
|
|
2711
|
+
const len = str.length;
|
|
2712
|
+
for (let i = startIndex; i < len - 1; i++) if (str[i] === "\\" && str[i + 1] === "0") {
|
|
2713
|
+
count++;
|
|
2714
|
+
i++;
|
|
2715
|
+
}
|
|
2716
|
+
return count;
|
|
2717
|
+
}
|
|
2718
|
+
function removeQuery(pathe) {
|
|
2719
|
+
const queryIndex = pathe.indexOf("?");
|
|
2720
|
+
if (queryIndex !== -1) return path.posix.normalize(pathe.slice(0, queryIndex));
|
|
2721
|
+
return path.posix.normalize(pathe);
|
|
2722
|
+
}
|
|
2723
|
+
function isStartsWithSlash(str) {
|
|
2724
|
+
return str?.startsWith("/");
|
|
2725
|
+
}
|
|
2726
|
+
function appendQuery(id, query) {
|
|
2727
|
+
if (!query.length) return id;
|
|
2728
|
+
return `${id}?${stringifyQuery(query)}`;
|
|
2729
|
+
}
|
|
2730
|
+
function stringifyQuery(query) {
|
|
2731
|
+
if (!query.length) return "";
|
|
2732
|
+
let queryStr = "";
|
|
2733
|
+
for (const [key, value] of query) queryStr += `${key}${value ? `=${value}` : ""}&`;
|
|
2734
|
+
return `${queryStr.slice(0, -1)}`;
|
|
2735
|
+
}
|
|
2736
|
+
const CSS_LANGS_RES = [
|
|
2737
|
+
[/\.(less)(?:$|\?)/, "less"],
|
|
2738
|
+
[/\.(scss|sass)(?:$|\?)/, "sass"],
|
|
2739
|
+
[/\.(styl|stylus)(?:$|\?)/, "stylus"],
|
|
2740
|
+
[/\.(css)(?:$|\?)/, "css"]
|
|
2741
|
+
];
|
|
2742
|
+
const JS_LANGS_RES = [
|
|
2743
|
+
[/\.(js|mjs|cjs)(?:$|\?)/, "js"],
|
|
2744
|
+
[/\.(jsx)(?:$|\?)/, "jsx"],
|
|
2745
|
+
[/\.(ts|cts|mts)(?:$|\?)/, "ts"],
|
|
2746
|
+
[/\.(tsx)(?:$|\?)/, "tsx"]
|
|
2747
|
+
];
|
|
2748
|
+
function getCssModuleType(id) {
|
|
2749
|
+
for (const [reg, lang] of CSS_LANGS_RES) if (reg.test(id)) return lang;
|
|
2750
|
+
return null;
|
|
2751
|
+
}
|
|
2752
|
+
function getJsModuleType(id) {
|
|
2753
|
+
for (const [reg, lang] of JS_LANGS_RES) if (reg.test(id)) return lang;
|
|
2754
|
+
return null;
|
|
2755
|
+
}
|
|
2756
|
+
function formatLoadModuleType(id) {
|
|
2757
|
+
const cssModuleType = getCssModuleType(id);
|
|
2758
|
+
if (cssModuleType) return cssModuleType;
|
|
2759
|
+
const jsModuleType = getJsModuleType(id);
|
|
2760
|
+
if (jsModuleType) return jsModuleType;
|
|
2761
|
+
return "js";
|
|
2762
|
+
}
|
|
2763
|
+
function formatTransformModuleType(id) {
|
|
2764
|
+
return formatLoadModuleType(id);
|
|
2765
|
+
}
|
|
2766
|
+
function getFarmPlugin(factory) {
|
|
2767
|
+
return ((userOptions) => {
|
|
2768
|
+
const plugins = toArray$2(factory(userOptions, { framework: "farm" })).map((rawPlugin) => {
|
|
2769
|
+
const plugin = toFarmPlugin(rawPlugin, userOptions);
|
|
2770
|
+
if (rawPlugin.farm) Object.assign(plugin, rawPlugin.farm);
|
|
2771
|
+
return plugin;
|
|
2772
|
+
});
|
|
2773
|
+
return plugins.length === 1 ? plugins[0] : plugins;
|
|
2774
|
+
});
|
|
2775
|
+
}
|
|
2776
|
+
function toFarmPlugin(plugin, options) {
|
|
2777
|
+
const farmPlugin = {
|
|
2778
|
+
name: plugin.name,
|
|
2779
|
+
priority: convertEnforceToPriority(plugin.enforce)
|
|
2780
|
+
};
|
|
2781
|
+
if (plugin.farm) Object.keys(plugin.farm).forEach((key) => {
|
|
2782
|
+
const value = plugin.farm[key];
|
|
2783
|
+
if (value) Reflect.set(farmPlugin, key, value);
|
|
2784
|
+
});
|
|
2785
|
+
if (plugin.buildStart) {
|
|
2786
|
+
const _buildStart = plugin.buildStart;
|
|
2787
|
+
farmPlugin.buildStart = { async executor(_, context) {
|
|
2788
|
+
await _buildStart.call(createFarmContext(context));
|
|
2789
|
+
} };
|
|
2790
|
+
}
|
|
2791
|
+
if (plugin.resolveId) {
|
|
2792
|
+
const _resolveId = plugin.resolveId;
|
|
2793
|
+
let filters = [];
|
|
2794
|
+
if (options) filters = options?.filters ?? [];
|
|
2795
|
+
farmPlugin.resolve = {
|
|
2796
|
+
filters: {
|
|
2797
|
+
sources: filters.length ? filters : [".*"],
|
|
2798
|
+
importers: [".*"]
|
|
2799
|
+
},
|
|
2800
|
+
async executor(params, context) {
|
|
2801
|
+
const resolvedIdPath = path.resolve(params.importer ?? "");
|
|
2802
|
+
const id = decodeStr(params.source);
|
|
2803
|
+
const { handler, filter } = normalizeObjectHook("resolveId", _resolveId);
|
|
2804
|
+
if (!filter(id)) return null;
|
|
2805
|
+
let isEntry = false;
|
|
2806
|
+
if (isObject(params.kind) && "entry" in params.kind) isEntry = params.kind.entry === "index";
|
|
2807
|
+
const farmContext = createFarmContext(context, resolvedIdPath);
|
|
2808
|
+
const resolveIdResult = await handler.call(Object.assign(unpluginContext(context), farmContext), id, resolvedIdPath ?? null, { isEntry });
|
|
2809
|
+
if (isString(resolveIdResult)) return {
|
|
2810
|
+
resolvedPath: removeQuery(encodeStr(resolveIdResult)),
|
|
2811
|
+
query: customParseQueryString(resolveIdResult),
|
|
2812
|
+
sideEffects: true,
|
|
2813
|
+
external: false,
|
|
2814
|
+
meta: {}
|
|
2815
|
+
};
|
|
2816
|
+
if (isObject(resolveIdResult)) return {
|
|
2817
|
+
resolvedPath: removeQuery(encodeStr(resolveIdResult?.id)),
|
|
2818
|
+
query: customParseQueryString(resolveIdResult?.id),
|
|
2819
|
+
sideEffects: false,
|
|
2820
|
+
external: Boolean(resolveIdResult?.external),
|
|
2821
|
+
meta: {}
|
|
2822
|
+
};
|
|
2823
|
+
if (!isStartsWithSlash(params.source)) return null;
|
|
2824
|
+
}
|
|
2825
|
+
};
|
|
2826
|
+
}
|
|
2827
|
+
if (plugin.load) {
|
|
2828
|
+
const _load = plugin.load;
|
|
2829
|
+
farmPlugin.load = {
|
|
2830
|
+
filters: { resolvedPaths: [".*"] },
|
|
2831
|
+
async executor(params, context) {
|
|
2832
|
+
const id = appendQuery(decodeStr(params.resolvedPath), params.query);
|
|
2833
|
+
const loader = formatTransformModuleType(id);
|
|
2834
|
+
if (plugin.loadInclude && !plugin.loadInclude?.(id)) return null;
|
|
2835
|
+
const { handler, filter } = normalizeObjectHook("load", _load);
|
|
2836
|
+
if (!filter(id)) return null;
|
|
2837
|
+
const farmContext = createFarmContext(context, id);
|
|
2838
|
+
return {
|
|
2839
|
+
content: getContentValue(await handler.call(Object.assign(unpluginContext(context), farmContext), id)),
|
|
2840
|
+
moduleType: loader
|
|
2841
|
+
};
|
|
2842
|
+
}
|
|
2843
|
+
};
|
|
2844
|
+
}
|
|
2845
|
+
if (plugin.transform) {
|
|
2846
|
+
const _transform = plugin.transform;
|
|
2847
|
+
farmPlugin.transform = {
|
|
2848
|
+
filters: {
|
|
2849
|
+
resolvedPaths: [".*"],
|
|
2850
|
+
moduleTypes: [".*"]
|
|
2851
|
+
},
|
|
2852
|
+
async executor(params, context) {
|
|
2853
|
+
const id = appendQuery(decodeStr(params.resolvedPath), params.query);
|
|
2854
|
+
const loader = formatTransformModuleType(id);
|
|
2855
|
+
if (plugin.transformInclude && !plugin.transformInclude(id)) return null;
|
|
2856
|
+
const { handler, filter } = normalizeObjectHook("transform", _transform);
|
|
2857
|
+
if (!filter(id, params.content)) return null;
|
|
2858
|
+
const farmContext = createFarmContext(context, id);
|
|
2859
|
+
const resource = await handler.call(Object.assign(unpluginContext(context), farmContext), params.content, id);
|
|
2860
|
+
if (resource && typeof resource !== "string") return {
|
|
2861
|
+
content: getContentValue(resource),
|
|
2862
|
+
moduleType: loader,
|
|
2863
|
+
sourceMap: typeof resource.map === "object" && resource.map !== null ? JSON.stringify(resource.map) : void 0
|
|
2864
|
+
};
|
|
2865
|
+
}
|
|
2866
|
+
};
|
|
2867
|
+
}
|
|
2868
|
+
if (plugin.watchChange) {
|
|
2869
|
+
const _watchChange = plugin.watchChange;
|
|
2870
|
+
farmPlugin.updateModules = { async executor(param, context) {
|
|
2871
|
+
const updatePathContent = param.paths[0];
|
|
2872
|
+
const ModifiedPath = updatePathContent[0];
|
|
2873
|
+
const eventChange = convertWatchEventChange(updatePathContent[1]);
|
|
2874
|
+
await _watchChange.call(createFarmContext(context), ModifiedPath, { event: eventChange });
|
|
2875
|
+
} };
|
|
2876
|
+
}
|
|
2877
|
+
if (plugin.buildEnd) {
|
|
2878
|
+
const _buildEnd = plugin.buildEnd;
|
|
2879
|
+
farmPlugin.buildEnd = { async executor(_, context) {
|
|
2880
|
+
await _buildEnd.call(createFarmContext(context));
|
|
2881
|
+
} };
|
|
2882
|
+
}
|
|
2883
|
+
if (plugin.writeBundle) {
|
|
2884
|
+
const _writeBundle = plugin.writeBundle;
|
|
2885
|
+
farmPlugin.finish = { async executor() {
|
|
2886
|
+
await _writeBundle();
|
|
2887
|
+
} };
|
|
2888
|
+
}
|
|
2889
|
+
return farmPlugin;
|
|
2890
|
+
}
|
|
2891
|
+
function getRollupPlugin(factory) {
|
|
2892
|
+
return ((userOptions) => {
|
|
2893
|
+
const plugins = toArray$2(factory(userOptions, { framework: "rollup" })).map((plugin) => toRollupPlugin(plugin, "rollup"));
|
|
2894
|
+
return plugins.length === 1 ? plugins[0] : plugins;
|
|
2895
|
+
});
|
|
2896
|
+
}
|
|
2897
|
+
function toRollupPlugin(plugin, key) {
|
|
2898
|
+
const nativeFilter = key === "rolldown";
|
|
2899
|
+
if (plugin.resolveId && !nativeFilter && typeof plugin.resolveId === "object" && plugin.resolveId.filter) {
|
|
2900
|
+
const resolveIdHook = plugin.resolveId;
|
|
2901
|
+
const { handler, filter } = normalizeObjectHook("load", resolveIdHook);
|
|
2902
|
+
replaceHookHandler("resolveId", resolveIdHook, function(...args) {
|
|
2903
|
+
const [id] = args;
|
|
2904
|
+
if (!supportNativeFilter(this, key) && !filter(id)) return;
|
|
2905
|
+
return handler.apply(this, args);
|
|
2906
|
+
});
|
|
2907
|
+
}
|
|
2908
|
+
if (plugin.load && (plugin.loadInclude || !nativeFilter && typeof plugin.load === "object" && plugin.load.filter)) {
|
|
2909
|
+
const loadHook = plugin.load;
|
|
2910
|
+
const { handler, filter } = normalizeObjectHook("load", loadHook);
|
|
2911
|
+
replaceHookHandler("load", loadHook, function(...args) {
|
|
2912
|
+
const [id] = args;
|
|
2913
|
+
if (plugin.loadInclude && !plugin.loadInclude(id)) return;
|
|
2914
|
+
if (!supportNativeFilter(this, key) && !filter(id)) return;
|
|
2915
|
+
return handler.apply(this, args);
|
|
2916
|
+
});
|
|
2917
|
+
}
|
|
2918
|
+
if (plugin.transform && (plugin.transformInclude || !nativeFilter && typeof plugin.transform === "object" && plugin.transform.filter)) {
|
|
2919
|
+
const transformHook = plugin.transform;
|
|
2920
|
+
const { handler, filter } = normalizeObjectHook("transform", transformHook);
|
|
2921
|
+
replaceHookHandler("transform", transformHook, function(...args) {
|
|
2922
|
+
const [code, id] = args;
|
|
2923
|
+
if (plugin.transformInclude && !plugin.transformInclude(id)) return;
|
|
2924
|
+
if (!supportNativeFilter(this, key) && !filter(id, code)) return;
|
|
2925
|
+
return handler.apply(this, args);
|
|
2926
|
+
});
|
|
2927
|
+
}
|
|
2928
|
+
if (plugin[key]) Object.assign(plugin, plugin[key]);
|
|
2929
|
+
return plugin;
|
|
2930
|
+
function replaceHookHandler(name, hook, handler) {
|
|
2931
|
+
if (typeof hook === "function") plugin[name] = handler;
|
|
2932
|
+
else hook.handler = handler;
|
|
2933
|
+
}
|
|
2934
|
+
}
|
|
2935
|
+
function supportNativeFilter(context, framework) {
|
|
2936
|
+
if (framework === "unloader") return false;
|
|
2937
|
+
if (framework === "vite") return !!context?.meta?.viteVersion;
|
|
2938
|
+
if (framework === "rolldown") return true;
|
|
2939
|
+
const rollupVersion = context?.meta?.rollupVersion;
|
|
2940
|
+
if (!rollupVersion) return false;
|
|
2941
|
+
const [major, minor] = rollupVersion.split(".");
|
|
2942
|
+
return Number(major) > 4 || Number(major) === 4 && Number(minor) >= 40;
|
|
2943
|
+
}
|
|
2944
|
+
function getRolldownPlugin(factory) {
|
|
2945
|
+
return ((userOptions) => {
|
|
2946
|
+
const plugins = toArray$2(factory(userOptions, { framework: "rolldown" })).map((rawPlugin) => {
|
|
2947
|
+
return toRollupPlugin(rawPlugin, "rolldown");
|
|
2948
|
+
});
|
|
2949
|
+
return plugins.length === 1 ? plugins[0] : plugins;
|
|
2950
|
+
});
|
|
2951
|
+
}
|
|
2952
|
+
const getFilename = () => fileURLToPath(import.meta.url);
|
|
2953
|
+
const getDirname = () => path.dirname(getFilename());
|
|
2954
|
+
const __dirname = /* @__PURE__ */ getDirname();
|
|
2955
|
+
const TRANSFORM_LOADER$1 = resolve(__dirname, "rspack/loaders/transform");
|
|
2956
|
+
const LOAD_LOADER$1 = resolve(__dirname, "rspack/loaders/load");
|
|
2957
|
+
function getRspackPlugin(factory) {
|
|
2958
|
+
return (userOptions) => {
|
|
2959
|
+
return { apply(compiler) {
|
|
2960
|
+
const VIRTUAL_MODULE_PREFIX = resolve(compiler.options.context ?? process.cwd(), "node_modules/.virtual", process.pid.toString());
|
|
2961
|
+
const meta = {
|
|
2962
|
+
framework: "rspack",
|
|
2963
|
+
rspack: { compiler }
|
|
2964
|
+
};
|
|
2965
|
+
const rawPlugins = toArray$2(factory(userOptions, meta));
|
|
2966
|
+
for (const rawPlugin of rawPlugins) {
|
|
2967
|
+
const plugin = Object.assign(rawPlugin, {
|
|
2968
|
+
__unpluginMeta: meta,
|
|
2969
|
+
__virtualModulePrefix: VIRTUAL_MODULE_PREFIX
|
|
2970
|
+
});
|
|
2971
|
+
const externalModules = /* @__PURE__ */ new Set();
|
|
2972
|
+
if (plugin.resolveId) {
|
|
2973
|
+
const createPlugin = (plugin$1) => {
|
|
2974
|
+
if (compiler.rspack.experiments.VirtualModulesPlugin) return new compiler.rspack.experiments.VirtualModulesPlugin();
|
|
2975
|
+
return new FakeVirtualModulesPlugin(plugin$1);
|
|
2976
|
+
};
|
|
2977
|
+
const vfs = createPlugin(plugin);
|
|
2978
|
+
vfs.apply(compiler);
|
|
2979
|
+
const vfsModules = /* @__PURE__ */ new Map();
|
|
2980
|
+
plugin.__vfsModules = vfsModules;
|
|
2981
|
+
plugin.__vfs = vfs;
|
|
2982
|
+
compiler.hooks.compilation.tap(plugin.name, (compilation, { normalModuleFactory }) => {
|
|
2983
|
+
normalModuleFactory.hooks.resolve.tapPromise(plugin.name, async (resolveData) => {
|
|
2984
|
+
const id = normalizeAbsolutePath(resolveData.request);
|
|
2985
|
+
const requestContext = resolveData.contextInfo;
|
|
2986
|
+
let importer = requestContext.issuer !== "" ? requestContext.issuer : void 0;
|
|
2987
|
+
const isEntry = requestContext.issuer === "";
|
|
2988
|
+
if (importer?.startsWith(plugin.__virtualModulePrefix)) importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
|
|
2989
|
+
const context = createBuildContext(compiler, compilation);
|
|
2990
|
+
let error;
|
|
2991
|
+
const pluginContext = {
|
|
2992
|
+
error(msg) {
|
|
2993
|
+
if (error == null) error = normalizeMessage(msg);
|
|
2994
|
+
else console.error(`unplugin/rspack: multiple errors returned from resolveId hook: ${msg}`);
|
|
2995
|
+
},
|
|
2996
|
+
warn(msg) {
|
|
2997
|
+
console.warn(`unplugin/rspack: warning from resolveId hook: ${msg}`);
|
|
2998
|
+
}
|
|
2999
|
+
};
|
|
3000
|
+
const { handler, filter } = normalizeObjectHook("resolveId", plugin.resolveId);
|
|
3001
|
+
if (!filter(id)) return;
|
|
3002
|
+
const resolveIdResult = await handler.call({
|
|
3003
|
+
...context,
|
|
3004
|
+
...pluginContext
|
|
3005
|
+
}, id, importer, { isEntry });
|
|
3006
|
+
if (error != null) throw error;
|
|
3007
|
+
if (resolveIdResult == null) return;
|
|
3008
|
+
let resolved = typeof resolveIdResult === "string" ? resolveIdResult : resolveIdResult.id;
|
|
3009
|
+
if (typeof resolveIdResult === "string" ? false : resolveIdResult.external === true) externalModules.add(resolved);
|
|
3010
|
+
let isVirtual = true;
|
|
3011
|
+
try {
|
|
3012
|
+
(compiler.inputFileSystem?.statSync ?? fs.statSync)(resolved);
|
|
3013
|
+
isVirtual = false;
|
|
3014
|
+
} catch {
|
|
3015
|
+
isVirtual = !isVirtualModuleId(resolved, plugin);
|
|
3016
|
+
}
|
|
3017
|
+
if (isVirtual) {
|
|
3018
|
+
const encodedVirtualPath = encodeVirtualModuleId(resolved, plugin);
|
|
3019
|
+
if (!vfsModules.has(resolved)) {
|
|
3020
|
+
const fsPromise = Promise.resolve(vfs.writeModule(encodedVirtualPath, ""));
|
|
3021
|
+
vfsModules.set(resolved, fsPromise);
|
|
3022
|
+
await fsPromise;
|
|
3023
|
+
} else await vfsModules.get(resolved);
|
|
3024
|
+
resolved = encodedVirtualPath;
|
|
3025
|
+
}
|
|
3026
|
+
resolveData.request = resolved;
|
|
3027
|
+
});
|
|
3028
|
+
});
|
|
3029
|
+
}
|
|
3030
|
+
if (plugin.load) compiler.options.module.rules.unshift({
|
|
3031
|
+
enforce: plugin.enforce,
|
|
3032
|
+
include(id) {
|
|
3033
|
+
if (isVirtualModuleId(id, plugin)) id = decodeVirtualModuleId(id, plugin);
|
|
3034
|
+
if (plugin.loadInclude && !plugin.loadInclude(id)) return false;
|
|
3035
|
+
const { filter } = normalizeObjectHook("load", plugin.load);
|
|
3036
|
+
if (!filter(id)) return false;
|
|
3037
|
+
return !externalModules.has(id);
|
|
3038
|
+
},
|
|
3039
|
+
use: [{
|
|
3040
|
+
loader: LOAD_LOADER$1,
|
|
3041
|
+
options: { plugin }
|
|
3042
|
+
}],
|
|
3043
|
+
type: "javascript/auto"
|
|
3044
|
+
});
|
|
3045
|
+
if (plugin.transform) compiler.options.module.rules.unshift({
|
|
3046
|
+
enforce: plugin.enforce,
|
|
3047
|
+
use(data) {
|
|
3048
|
+
return transformUse(data, plugin, TRANSFORM_LOADER$1);
|
|
3049
|
+
}
|
|
3050
|
+
});
|
|
3051
|
+
if (plugin.rspack) plugin.rspack(compiler);
|
|
3052
|
+
if (plugin.watchChange || plugin.buildStart) compiler.hooks.make.tapPromise(plugin.name, async (compilation) => {
|
|
3053
|
+
const context = createBuildContext(compiler, compilation);
|
|
3054
|
+
if (plugin.watchChange && (compiler.modifiedFiles || compiler.removedFiles)) {
|
|
3055
|
+
const promises$1 = [];
|
|
3056
|
+
if (compiler.modifiedFiles) compiler.modifiedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
|
|
3057
|
+
if (compiler.removedFiles) compiler.removedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "delete" }))));
|
|
3058
|
+
await Promise.all(promises$1);
|
|
3059
|
+
}
|
|
3060
|
+
if (plugin.buildStart) return await plugin.buildStart.call(context);
|
|
3061
|
+
});
|
|
3062
|
+
if (plugin.buildEnd) compiler.hooks.emit.tapPromise(plugin.name, async (compilation) => {
|
|
3063
|
+
await plugin.buildEnd.call(createBuildContext(compiler, compilation));
|
|
3064
|
+
});
|
|
3065
|
+
if (plugin.writeBundle) compiler.hooks.afterEmit.tapPromise(plugin.name, async () => {
|
|
3066
|
+
await plugin.writeBundle();
|
|
3067
|
+
});
|
|
3068
|
+
}
|
|
3069
|
+
} };
|
|
3070
|
+
};
|
|
3071
|
+
}
|
|
3072
|
+
function getUnloaderPlugin(factory) {
|
|
3073
|
+
return ((userOptions) => {
|
|
3074
|
+
const plugins = toArray$2(factory(userOptions, { framework: "unloader" })).map((rawPlugin) => {
|
|
3075
|
+
return toRollupPlugin(rawPlugin, "unloader");
|
|
3076
|
+
});
|
|
3077
|
+
return plugins.length === 1 ? plugins[0] : plugins;
|
|
3078
|
+
});
|
|
3079
|
+
}
|
|
3080
|
+
function getVitePlugin(factory) {
|
|
3081
|
+
return ((userOptions) => {
|
|
3082
|
+
const plugins = toArray$2(factory(userOptions, { framework: "vite" })).map((rawPlugin) => {
|
|
3083
|
+
return toRollupPlugin(rawPlugin, "vite");
|
|
3084
|
+
});
|
|
3085
|
+
return plugins.length === 1 ? plugins[0] : plugins;
|
|
3086
|
+
});
|
|
3087
|
+
}
|
|
3088
|
+
const TRANSFORM_LOADER = resolve(__dirname, "webpack/loaders/transform");
|
|
3089
|
+
const LOAD_LOADER = resolve(__dirname, "webpack/loaders/load");
|
|
3090
|
+
function getWebpackPlugin(factory) {
|
|
3091
|
+
return (userOptions) => {
|
|
3092
|
+
return { apply(compiler) {
|
|
3093
|
+
const VIRTUAL_MODULE_PREFIX = resolve(compiler.options.context ?? process$1.cwd(), "_virtual_");
|
|
3094
|
+
const meta = {
|
|
3095
|
+
framework: "webpack",
|
|
3096
|
+
webpack: { compiler }
|
|
3097
|
+
};
|
|
3098
|
+
const rawPlugins = toArray$2(factory(userOptions, meta));
|
|
3099
|
+
for (const rawPlugin of rawPlugins) {
|
|
3100
|
+
const plugin = Object.assign(rawPlugin, {
|
|
3101
|
+
__unpluginMeta: meta,
|
|
3102
|
+
__virtualModulePrefix: VIRTUAL_MODULE_PREFIX
|
|
3103
|
+
});
|
|
3104
|
+
const externalModules = /* @__PURE__ */ new Set();
|
|
3105
|
+
if (plugin.resolveId) {
|
|
3106
|
+
let vfs = compiler.options.plugins.find((i) => i instanceof import_lib.default);
|
|
3107
|
+
if (!vfs) {
|
|
3108
|
+
vfs = new import_lib.default();
|
|
3109
|
+
compiler.options.plugins.push(vfs);
|
|
3110
|
+
}
|
|
3111
|
+
const vfsModules = /* @__PURE__ */ new Set();
|
|
3112
|
+
plugin.__vfsModules = vfsModules;
|
|
3113
|
+
plugin.__vfs = vfs;
|
|
3114
|
+
const resolverPlugin = { apply(resolver) {
|
|
3115
|
+
const target = resolver.ensureHook("resolve");
|
|
3116
|
+
resolver.getHook("resolve").tapAsync(plugin.name, async (request, resolveContext, callback) => {
|
|
3117
|
+
if (!request.request) return callback();
|
|
3118
|
+
if (normalizeAbsolutePath(request.request).startsWith(plugin.__virtualModulePrefix)) return callback();
|
|
3119
|
+
const id = normalizeAbsolutePath(request.request);
|
|
3120
|
+
const requestContext = request.context;
|
|
3121
|
+
let importer = requestContext.issuer !== "" ? requestContext.issuer : void 0;
|
|
3122
|
+
const isEntry = requestContext.issuer === "";
|
|
3123
|
+
if (importer?.startsWith(plugin.__virtualModulePrefix)) importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
|
|
3124
|
+
const fileDependencies = /* @__PURE__ */ new Set();
|
|
3125
|
+
const context = createBuildContext$1({
|
|
3126
|
+
addWatchFile(file) {
|
|
3127
|
+
fileDependencies.add(file);
|
|
3128
|
+
resolveContext.fileDependencies?.add(file);
|
|
3129
|
+
},
|
|
3130
|
+
getWatchFiles() {
|
|
3131
|
+
return Array.from(fileDependencies);
|
|
3132
|
+
}
|
|
3133
|
+
}, compiler);
|
|
3134
|
+
let error;
|
|
3135
|
+
const pluginContext = {
|
|
3136
|
+
error(msg) {
|
|
3137
|
+
if (error == null) error = normalizeMessage$1(msg);
|
|
3138
|
+
else console.error(`unplugin/webpack: multiple errors returned from resolveId hook: ${msg}`);
|
|
3139
|
+
},
|
|
3140
|
+
warn(msg) {
|
|
3141
|
+
console.warn(`unplugin/webpack: warning from resolveId hook: ${msg}`);
|
|
3142
|
+
}
|
|
3143
|
+
};
|
|
3144
|
+
const { handler, filter } = normalizeObjectHook("resolveId", plugin.resolveId);
|
|
3145
|
+
if (!filter(id)) return callback();
|
|
3146
|
+
const resolveIdResult = await handler.call({
|
|
3147
|
+
...context,
|
|
3148
|
+
...pluginContext
|
|
3149
|
+
}, id, importer, { isEntry });
|
|
3150
|
+
if (error != null) return callback(error);
|
|
3151
|
+
if (resolveIdResult == null) return callback();
|
|
3152
|
+
let resolved = typeof resolveIdResult === "string" ? resolveIdResult : resolveIdResult.id;
|
|
3153
|
+
if (typeof resolveIdResult === "string" ? false : resolveIdResult.external === true) externalModules.add(resolved);
|
|
3154
|
+
if (!fs.existsSync(resolved)) {
|
|
3155
|
+
resolved = normalizeAbsolutePath(plugin.__virtualModulePrefix + encodeURIComponent(resolved));
|
|
3156
|
+
if (!vfsModules.has(resolved)) {
|
|
3157
|
+
plugin.__vfs.writeModule(resolved, "");
|
|
3158
|
+
vfsModules.add(resolved);
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
const newRequest = {
|
|
3162
|
+
...request,
|
|
3163
|
+
request: resolved
|
|
3164
|
+
};
|
|
3165
|
+
resolver.doResolve(target, newRequest, null, resolveContext, callback);
|
|
3166
|
+
});
|
|
3167
|
+
} };
|
|
3168
|
+
compiler.options.resolve.plugins = compiler.options.resolve.plugins || [];
|
|
3169
|
+
compiler.options.resolve.plugins.push(resolverPlugin);
|
|
3170
|
+
}
|
|
3171
|
+
if (plugin.load) compiler.options.module.rules.unshift({
|
|
3172
|
+
include(id) {
|
|
3173
|
+
return shouldLoad(id, plugin, externalModules);
|
|
3174
|
+
},
|
|
3175
|
+
enforce: plugin.enforce,
|
|
3176
|
+
use: [{
|
|
3177
|
+
loader: LOAD_LOADER,
|
|
3178
|
+
options: { plugin }
|
|
3179
|
+
}],
|
|
3180
|
+
type: "javascript/auto"
|
|
3181
|
+
});
|
|
3182
|
+
if (plugin.transform) compiler.options.module.rules.unshift({
|
|
3183
|
+
enforce: plugin.enforce,
|
|
3184
|
+
use(data) {
|
|
3185
|
+
return transformUse(data, plugin, TRANSFORM_LOADER);
|
|
3186
|
+
}
|
|
3187
|
+
});
|
|
3188
|
+
if (plugin.webpack) plugin.webpack(compiler);
|
|
3189
|
+
if (plugin.watchChange || plugin.buildStart) compiler.hooks.make.tapPromise(plugin.name, async (compilation) => {
|
|
3190
|
+
const context = createBuildContext$1(contextOptionsFromCompilation(compilation), compiler, compilation);
|
|
3191
|
+
if (plugin.watchChange && (compiler.modifiedFiles || compiler.removedFiles)) {
|
|
3192
|
+
const promises$1 = [];
|
|
3193
|
+
if (compiler.modifiedFiles) compiler.modifiedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
|
|
3194
|
+
if (compiler.removedFiles) compiler.removedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "delete" }))));
|
|
3195
|
+
await Promise.all(promises$1);
|
|
3196
|
+
}
|
|
3197
|
+
if (plugin.buildStart) return await plugin.buildStart.call(context);
|
|
3198
|
+
});
|
|
3199
|
+
if (plugin.buildEnd) compiler.hooks.emit.tapPromise(plugin.name, async (compilation) => {
|
|
3200
|
+
await plugin.buildEnd.call(createBuildContext$1(contextOptionsFromCompilation(compilation), compiler, compilation));
|
|
3201
|
+
});
|
|
3202
|
+
if (plugin.writeBundle) compiler.hooks.afterEmit.tapPromise(plugin.name, async () => {
|
|
3203
|
+
await plugin.writeBundle();
|
|
3204
|
+
});
|
|
3205
|
+
}
|
|
3206
|
+
} };
|
|
3207
|
+
};
|
|
3208
|
+
}
|
|
3209
|
+
function shouldLoad(id, plugin, externalModules) {
|
|
3210
|
+
if (id.startsWith(plugin.__virtualModulePrefix)) id = decodeURIComponent(id.slice(plugin.__virtualModulePrefix.length));
|
|
3211
|
+
if (plugin.loadInclude && !plugin.loadInclude(id)) return false;
|
|
3212
|
+
const { filter } = normalizeObjectHook("load", plugin.load);
|
|
3213
|
+
if (!filter(id)) return false;
|
|
3214
|
+
return !externalModules.has(id);
|
|
3215
|
+
}
|
|
3216
|
+
function createUnplugin(factory) {
|
|
3217
|
+
return {
|
|
3218
|
+
get esbuild() {
|
|
3219
|
+
return getEsbuildPlugin(factory);
|
|
3220
|
+
},
|
|
3221
|
+
get rollup() {
|
|
3222
|
+
return getRollupPlugin(factory);
|
|
3223
|
+
},
|
|
3224
|
+
get vite() {
|
|
3225
|
+
return getVitePlugin(factory);
|
|
3226
|
+
},
|
|
3227
|
+
get rolldown() {
|
|
3228
|
+
return getRolldownPlugin(factory);
|
|
3229
|
+
},
|
|
3230
|
+
get webpack() {
|
|
3231
|
+
return getWebpackPlugin(factory);
|
|
3232
|
+
},
|
|
3233
|
+
get rspack() {
|
|
3234
|
+
return getRspackPlugin(factory);
|
|
3235
|
+
},
|
|
3236
|
+
get farm() {
|
|
3237
|
+
return getFarmPlugin(factory);
|
|
3238
|
+
},
|
|
3239
|
+
get unloader() {
|
|
3240
|
+
return getUnloaderPlugin(factory);
|
|
3241
|
+
},
|
|
3242
|
+
get raw() {
|
|
3243
|
+
return factory;
|
|
3244
|
+
}
|
|
3245
|
+
};
|
|
3246
|
+
}
|
|
3247
|
+
|
|
3248
|
+
//#endregion
|
|
3249
|
+
//#region node_modules/.pnpm/unplugin-utils@0.3.1/node_modules/unplugin-utils/dist/index.js
|
|
3250
|
+
var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch(), 1);
|
|
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$1(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.5.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
|
+
});
|
|
3342
|
+
|
|
3343
|
+
//#endregion
|
|
3344
|
+
//#region node_modules/.pnpm/unimport@5.5.0/node_modules/unimport/dist/chunks/detect-acorn.mjs
|
|
3345
|
+
async function detectImportsAcorn(code, ctx, options) {
|
|
3346
|
+
const s = getMagicString(code);
|
|
3347
|
+
const map = await ctx.getImportMap();
|
|
3348
|
+
let matchedImports = [];
|
|
3349
|
+
const enableAutoImport = options?.autoImport !== false;
|
|
3350
|
+
const enableTransformVirtualImports = options?.transformVirtualImports !== false && ctx.options.virtualImports?.length;
|
|
3351
|
+
if (enableAutoImport || enableTransformVirtualImports) {
|
|
3352
|
+
const ast = parse(s.original, {
|
|
3353
|
+
sourceType: "module",
|
|
3354
|
+
ecmaVersion: "latest",
|
|
3355
|
+
locations: true
|
|
3356
|
+
});
|
|
3357
|
+
const virtualImports = createVirtualImportsAcronWalker(map, ctx.options.virtualImports);
|
|
3358
|
+
const scopes = traveseScopes(ast, enableTransformVirtualImports ? virtualImports.walk : {});
|
|
3359
|
+
if (enableAutoImport) {
|
|
3360
|
+
const identifiers = scopes.unmatched;
|
|
3361
|
+
matchedImports.push(...Array.from(identifiers).map((name) => {
|
|
3362
|
+
const item = map.get(name);
|
|
3363
|
+
if (item && !item.disabled) return item;
|
|
3364
|
+
return null;
|
|
3365
|
+
}).filter(Boolean));
|
|
3366
|
+
for (const addon of ctx.addons) matchedImports = await addon.matchImports?.call(ctx, identifiers, matchedImports) || matchedImports;
|
|
3367
|
+
}
|
|
3368
|
+
virtualImports.ranges.forEach(([start, end]) => {
|
|
3369
|
+
s.remove(start, end);
|
|
3370
|
+
});
|
|
3371
|
+
matchedImports.push(...virtualImports.imports);
|
|
3372
|
+
}
|
|
3373
|
+
return {
|
|
3374
|
+
s,
|
|
3375
|
+
strippedCode: code.toString(),
|
|
3376
|
+
matchedImports,
|
|
3377
|
+
isCJSContext: false,
|
|
3378
|
+
firstOccurrence: 0
|
|
3379
|
+
};
|
|
3380
|
+
}
|
|
3381
|
+
function traveseScopes(ast, additionalWalk) {
|
|
3382
|
+
const scopes = [];
|
|
3383
|
+
let scopeCurrent = void 0;
|
|
3384
|
+
const scopesStack = [];
|
|
3385
|
+
function pushScope(node) {
|
|
3386
|
+
scopeCurrent = {
|
|
3387
|
+
node,
|
|
3388
|
+
parent: scopeCurrent,
|
|
3389
|
+
declarations: /* @__PURE__ */ new Set(),
|
|
3390
|
+
references: /* @__PURE__ */ new Set()
|
|
3391
|
+
};
|
|
3392
|
+
scopes.push(scopeCurrent);
|
|
3393
|
+
scopesStack.push(scopeCurrent);
|
|
3394
|
+
}
|
|
3395
|
+
function popScope(node) {
|
|
3396
|
+
if (scopesStack.pop()?.node !== node) throw new Error("Scope mismatch");
|
|
3397
|
+
scopeCurrent = scopesStack[scopesStack.length - 1];
|
|
3398
|
+
}
|
|
3399
|
+
pushScope(void 0);
|
|
3400
|
+
walk(ast, {
|
|
3401
|
+
enter(node, parent, prop, index) {
|
|
3402
|
+
additionalWalk?.enter?.call(this, node, parent, prop, index);
|
|
3403
|
+
switch (node.type) {
|
|
3404
|
+
case "ImportSpecifier":
|
|
3405
|
+
case "ImportDefaultSpecifier":
|
|
3406
|
+
case "ImportNamespaceSpecifier":
|
|
3407
|
+
scopeCurrent.declarations.add(node.local.name);
|
|
3408
|
+
return;
|
|
3409
|
+
case "FunctionDeclaration":
|
|
3410
|
+
case "ClassDeclaration":
|
|
3411
|
+
if (node.id) scopeCurrent.declarations.add(node.id.name);
|
|
3412
|
+
return;
|
|
3413
|
+
case "VariableDeclarator":
|
|
3414
|
+
if (node.id.type === "Identifier") scopeCurrent.declarations.add(node.id.name);
|
|
3415
|
+
else walk(node.id, { enter(node2) {
|
|
3416
|
+
if (node2.type === "ObjectPattern") node2.properties.forEach((i) => {
|
|
3417
|
+
if (i.type === "Property" && i.value.type === "Identifier") scopeCurrent.declarations.add(i.value.name);
|
|
3418
|
+
else if (i.type === "RestElement" && i.argument.type === "Identifier") scopeCurrent.declarations.add(i.argument.name);
|
|
3419
|
+
});
|
|
3420
|
+
else if (node2.type === "ArrayPattern") node2.elements.forEach((i) => {
|
|
3421
|
+
if (i?.type === "Identifier") scopeCurrent.declarations.add(i.name);
|
|
3422
|
+
if (i?.type === "RestElement" && i.argument.type === "Identifier") scopeCurrent.declarations.add(i.argument.name);
|
|
3423
|
+
});
|
|
3424
|
+
} });
|
|
3425
|
+
return;
|
|
3426
|
+
case "BlockStatement":
|
|
3427
|
+
pushScope(node);
|
|
3428
|
+
return;
|
|
3429
|
+
case "Identifier":
|
|
3430
|
+
switch (parent?.type) {
|
|
3431
|
+
case "CallExpression":
|
|
3432
|
+
if (parent.callee === node || parent.arguments.includes(node)) scopeCurrent.references.add(node.name);
|
|
3433
|
+
return;
|
|
3434
|
+
case "MemberExpression":
|
|
3435
|
+
if (parent.object === node) scopeCurrent.references.add(node.name);
|
|
3436
|
+
return;
|
|
3437
|
+
case "VariableDeclarator":
|
|
3438
|
+
if (parent.init === node) scopeCurrent.references.add(node.name);
|
|
3439
|
+
return;
|
|
3440
|
+
case "SpreadElement":
|
|
3441
|
+
if (parent.argument === node) scopeCurrent.references.add(node.name);
|
|
3442
|
+
return;
|
|
3443
|
+
case "ClassDeclaration":
|
|
3444
|
+
if (parent.superClass === node) scopeCurrent.references.add(node.name);
|
|
3445
|
+
return;
|
|
3446
|
+
case "Property":
|
|
3447
|
+
if (parent.value === node) scopeCurrent.references.add(node.name);
|
|
3448
|
+
return;
|
|
3449
|
+
case "TemplateLiteral":
|
|
3450
|
+
if (parent.expressions.includes(node)) scopeCurrent.references.add(node.name);
|
|
3451
|
+
return;
|
|
3452
|
+
case "AssignmentExpression":
|
|
3453
|
+
if (parent.right === node) scopeCurrent.references.add(node.name);
|
|
3454
|
+
return;
|
|
3455
|
+
case "IfStatement":
|
|
3456
|
+
case "WhileStatement":
|
|
3457
|
+
case "DoWhileStatement":
|
|
3458
|
+
if (parent.test === node) scopeCurrent.references.add(node.name);
|
|
3459
|
+
return;
|
|
3460
|
+
case "SwitchStatement":
|
|
3461
|
+
if (parent.discriminant === node) scopeCurrent.references.add(node.name);
|
|
3462
|
+
return;
|
|
3463
|
+
}
|
|
3464
|
+
if (parent?.type.includes("Expression")) scopeCurrent.references.add(node.name);
|
|
3465
|
+
}
|
|
3466
|
+
},
|
|
3467
|
+
leave(node, parent, prop, index) {
|
|
3468
|
+
additionalWalk?.leave?.call(this, node, parent, prop, index);
|
|
3469
|
+
switch (node.type) {
|
|
3470
|
+
case "BlockStatement": popScope(node);
|
|
3471
|
+
}
|
|
3472
|
+
}
|
|
3473
|
+
});
|
|
3474
|
+
const unmatched = /* @__PURE__ */ new Set();
|
|
3475
|
+
for (const scope of scopes) for (const name of scope.references) {
|
|
3476
|
+
let defined = false;
|
|
3477
|
+
let parent = scope;
|
|
3478
|
+
while (parent) {
|
|
3479
|
+
if (parent.declarations.has(name)) {
|
|
3480
|
+
defined = true;
|
|
3481
|
+
break;
|
|
3482
|
+
}
|
|
3483
|
+
parent = parent?.parent;
|
|
3484
|
+
}
|
|
3485
|
+
if (!defined) unmatched.add(name);
|
|
3486
|
+
}
|
|
3487
|
+
return {
|
|
3488
|
+
unmatched,
|
|
3489
|
+
scopes
|
|
3490
|
+
};
|
|
3491
|
+
}
|
|
3492
|
+
function createVirtualImportsAcronWalker(importMap, virtualImports = []) {
|
|
3493
|
+
const imports = [];
|
|
3494
|
+
const ranges = [];
|
|
3495
|
+
return {
|
|
3496
|
+
imports,
|
|
3497
|
+
ranges,
|
|
3498
|
+
walk: { enter(node) {
|
|
3499
|
+
if (node.type === "ImportDeclaration") {
|
|
3500
|
+
if (virtualImports.includes(node.source.value)) {
|
|
3501
|
+
ranges.push([node.start, node.end]);
|
|
3502
|
+
node.specifiers.forEach((i) => {
|
|
3503
|
+
if (i.type === "ImportSpecifier" && i.imported.type === "Identifier") {
|
|
3504
|
+
const original = importMap.get(i.imported.name);
|
|
3505
|
+
if (!original) throw new Error(`[unimport] failed to find "${i.imported.name}" imported from "${node.source.value}"`);
|
|
3506
|
+
imports.push({
|
|
3507
|
+
from: original.from,
|
|
3508
|
+
name: original.name,
|
|
3509
|
+
as: i.local.name
|
|
3510
|
+
});
|
|
3511
|
+
}
|
|
3512
|
+
});
|
|
3513
|
+
}
|
|
3514
|
+
}
|
|
3515
|
+
} }
|
|
3516
|
+
};
|
|
3517
|
+
}
|
|
3518
|
+
|
|
3519
|
+
//#endregion
|
|
3520
|
+
export { createFilter as a, toExports as c, unplugin as i, detectImportsAcorn as n, createUnplugin as o, traveseScopes as r, createUnimport as s, createVirtualImportsAcronWalker as t };
|