nitro-nightly 3.0.1-alpha.1 → 3.0.1-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/README.md +2 -0
  2. package/dist/_build/common.mjs +24924 -52
  3. package/dist/_build/rolldown.mjs +29 -63
  4. package/dist/_build/rollup.mjs +22 -110
  5. package/dist/_build/vite.build.mjs +3 -43
  6. package/dist/{_dev.mjs → _chunks/dev.mjs} +45 -43
  7. package/dist/_chunks/{B-D1JOIz.mjs → nitro.mjs} +144 -308
  8. package/dist/_chunks/nitro2.mjs +101 -0
  9. package/dist/_chunks/utils.mjs +254 -0
  10. package/dist/{_chunks/Bqks5huO.mjs → _common.mjs} +24 -10
  11. package/dist/_libs/c12+giget+readdirp+chokidar.d.mts +214 -0
  12. package/dist/_libs/citty.mjs +140 -110
  13. package/dist/_libs/{plugin-commonjs.mjs → commondir+is-reference.mjs} +59 -250
  14. package/dist/_libs/compatx.d.mts +47 -0
  15. package/dist/_libs/confbox.mjs +388 -799
  16. package/dist/_libs/esbuild.d.mts +20 -0
  17. package/dist/_libs/estree-walker.mjs +1 -144
  18. package/dist/_libs/{plugin-node-resolve.mjs → hasown+resolve+deepmerge.mjs} +497 -78
  19. package/dist/_libs/httpxy.d.mts +79 -0
  20. package/dist/_libs/httpxy.mjs +6 -1
  21. package/dist/_libs/magic-string.d.mts +220 -0
  22. package/dist/_libs/mlly.d.mts +57 -0
  23. package/dist/_libs/nypm+giget+tinyexec.mjs +3603 -0
  24. package/dist/_libs/pkg-types.d.mts +23 -0
  25. package/dist/_libs/plugin-alias.mjs +4 -2
  26. package/dist/_libs/plugin-inject.mjs +5 -5
  27. package/dist/_libs/plugin-json.mjs +2 -2
  28. package/dist/_libs/pluginutils+plugin-commonjs.d.mts +241 -0
  29. package/dist/_libs/{vite-plugin-fullstack.mjs → pluginutils.mjs} +244 -153
  30. package/dist/_libs/rc9+c12+dotenv.mjs +972 -0
  31. package/dist/_libs/{chokidar.mjs → readdirp+chokidar.mjs} +237 -187
  32. package/dist/_libs/remapping.mjs +1 -1
  33. package/dist/_libs/{gen-mapping.mjs → resolve-uri+gen-mapping.mjs} +2 -166
  34. package/dist/_libs/rou3.d.mts +43 -0
  35. package/dist/_libs/rou3.mjs +9 -6
  36. package/dist/_libs/std-env.d.mts +4 -0
  37. package/dist/_libs/tsconfck.mjs +3 -3
  38. package/dist/_libs/{unimport.mjs → unimport+unplugin.mjs} +226 -1961
  39. package/dist/_libs/unplugin+unimport.d.mts +426 -0
  40. package/dist/_libs/unwasm.d.mts +29 -0
  41. package/dist/_presets.mjs +130 -80
  42. package/dist/builder.d.mts +4 -4
  43. package/dist/builder.mjs +6 -30
  44. package/dist/cli/_chunks/build.mjs +1 -1
  45. package/dist/cli/_chunks/dev.mjs +5 -11
  46. package/dist/cli/_chunks/list.mjs +1 -1
  47. package/dist/cli/_chunks/prepare.mjs +1 -1
  48. package/dist/cli/_chunks/run.mjs +1 -1
  49. package/dist/node_modules/@poppinss/colors/build/index.js +130 -160
  50. package/dist/node_modules/@poppinss/colors/package.json +20 -18
  51. package/dist/node_modules/@poppinss/exception/build/index.js +36 -55
  52. package/dist/node_modules/@poppinss/exception/package.json +19 -16
  53. package/dist/node_modules/@sindresorhus/is/distribution/index.js +46 -5
  54. package/dist/node_modules/@sindresorhus/is/package.json +1 -1
  55. package/dist/node_modules/@speed-highlight/core/dist/index.js +1 -1
  56. package/dist/node_modules/@speed-highlight/core/dist/terminal.js +1 -1
  57. package/dist/node_modules/@speed-highlight/core/package.json +2 -2
  58. package/dist/node_modules/hookable/dist/index.mjs +5 -6
  59. package/dist/node_modules/hookable/package.json +13 -13
  60. package/dist/node_modules/ufo/dist/index.mjs +16 -9
  61. package/dist/node_modules/ufo/package.json +15 -14
  62. package/dist/node_modules/unctx/package.json +16 -16
  63. package/dist/node_modules/youch/build/{chunk-4XB2BYKC.js → chunk-7QV3D5YX.js} +2 -4
  64. package/dist/node_modules/youch/build/{chunk-PUHGL6HA.js → chunk-AUGPHE32.js} +2 -4
  65. package/dist/node_modules/youch/build/{chunk-F4I6KX4R.js → chunk-CM7DWJNZ.js} +2 -4
  66. package/dist/node_modules/youch/build/{chunk-YYEJ3AGB.js → chunk-EJH674NB.js} +2 -4
  67. package/dist/node_modules/youch/build/{chunk-EUJBVOYB.js → chunk-OIJ3WD7L.js} +2 -4
  68. package/dist/node_modules/youch/build/{chunk-HFSXRSKS.js → chunk-P36L72PL.js} +5 -3
  69. package/dist/node_modules/youch/build/{chunk-4YEN7HVQ.js → chunk-PE3GG3TN.js} +5 -1
  70. package/dist/node_modules/youch/build/{chunk-PINJDICN.js → chunk-X53OIOJH.js} +2 -4
  71. package/dist/node_modules/youch/build/index.js +8 -9
  72. package/dist/node_modules/youch/build/public/error_info/style.css +1 -0
  73. package/dist/node_modules/youch/build/public/error_metadata/style.css +3 -0
  74. package/dist/node_modules/youch/build/public/error_stack/style.css +2 -3
  75. package/dist/node_modules/youch/package.json +1 -1
  76. package/dist/presets/_nitro/runtime/nitro-dev.d.mts +1 -1
  77. package/dist/presets/_nitro/runtime/nitro-dev.mjs +5 -6
  78. package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +1 -1
  79. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +1 -1
  80. package/dist/presets/_nitro/runtime/service-worker.d.mts +1 -1
  81. package/dist/presets/_nitro/runtime/service-worker.mjs +2 -2
  82. package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +1 -1
  83. package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +1 -1
  84. package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -5
  85. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +1 -1
  86. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +9 -11
  87. package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +1 -1
  88. package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +1 -1
  89. package/dist/presets/azure/runtime/azure-swa.d.mts +1 -1
  90. package/dist/presets/azure/runtime/azure-swa.mjs +1 -1
  91. package/dist/presets/bun/runtime/bun.d.mts +1 -1
  92. package/dist/presets/bun/runtime/bun.mjs +7 -8
  93. package/dist/presets/cloudflare/runtime/_module-handler.d.mts +3 -3
  94. package/dist/presets/cloudflare/runtime/_module-handler.mjs +19 -17
  95. package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +1 -1
  96. package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +17 -16
  97. package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +1 -1
  98. package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +8 -9
  99. package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +1 -1
  100. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +12 -18
  101. package/dist/presets/deno/runtime/deno-deploy.d.mts +1 -1
  102. package/dist/presets/deno/runtime/deno-deploy.mjs +4 -5
  103. package/dist/presets/deno/runtime/deno-server.d.mts +1 -1
  104. package/dist/presets/deno/runtime/deno-server.mjs +5 -6
  105. package/dist/presets/netlify/runtime/netlify-edge.d.mts +1 -2
  106. package/dist/presets/netlify/runtime/netlify-edge.mjs +3 -2
  107. package/dist/presets/netlify/runtime/netlify.d.mts +3 -2
  108. package/dist/presets/netlify/runtime/netlify.mjs +3 -1
  109. package/dist/presets/node/runtime/node-cluster.d.mts +1 -1
  110. package/dist/presets/node/runtime/node-cluster.mjs +5 -6
  111. package/dist/presets/node/runtime/node-middleware.d.mts +1 -1
  112. package/dist/presets/node/runtime/node-middleware.mjs +4 -5
  113. package/dist/presets/node/runtime/node-server.d.mts +1 -1
  114. package/dist/presets/node/runtime/node-server.mjs +5 -6
  115. package/dist/presets/standard/runtime/server.d.mts +1 -1
  116. package/dist/presets/standard/runtime/server.mjs +1 -1
  117. package/dist/presets/stormkit/runtime/stormkit.d.mts +1 -1
  118. package/dist/presets/stormkit/runtime/stormkit.mjs +1 -1
  119. package/dist/presets/vercel/runtime/isr.d.mts +2 -0
  120. package/dist/presets/vercel/runtime/isr.mjs +19 -0
  121. package/dist/presets/vercel/runtime/vercel.node.d.mts +1 -1
  122. package/dist/presets/vercel/runtime/vercel.node.mjs +16 -7
  123. package/dist/presets/vercel/runtime/vercel.web.d.mts +1 -1
  124. package/dist/presets/vercel/runtime/vercel.web.mjs +18 -13
  125. package/dist/presets/winterjs/runtime/winterjs.d.mts +1 -2
  126. package/dist/presets/winterjs/runtime/winterjs.mjs +1 -1
  127. package/dist/presets/zeabur/runtime/zeabur.d.mts +1 -1
  128. package/dist/presets/zeabur/runtime/zeabur.mjs +1 -1
  129. package/dist/runtime/app.d.mts +1 -1
  130. package/dist/runtime/app.mjs +1 -1
  131. package/dist/runtime/internal/app.d.mts +7 -3
  132. package/dist/runtime/internal/app.mjs +29 -22
  133. package/dist/runtime/internal/database.mjs +1 -1
  134. package/dist/runtime/internal/error/dev.d.mts +0 -1
  135. package/dist/runtime/internal/error/dev.mjs +1 -1
  136. package/dist/runtime/internal/route-rules.d.mts +0 -4
  137. package/dist/runtime/internal/routes/dev-tasks.mjs +1 -1
  138. package/dist/runtime/internal/routes/openapi.d.mts +0 -1
  139. package/dist/runtime/internal/routes/openapi.mjs +3 -3
  140. package/dist/runtime/internal/routes/renderer-template.dev.mjs +1 -1
  141. package/dist/runtime/internal/routes/renderer-template.mjs +1 -1
  142. package/dist/runtime/internal/routes/scalar.d.mts +0 -1
  143. package/dist/runtime/internal/routes/scalar.mjs +4 -4
  144. package/dist/runtime/internal/routes/swagger.d.mts +0 -1
  145. package/dist/runtime/internal/routes/swagger.mjs +3 -3
  146. package/dist/runtime/internal/runtime-config.mjs +8 -8
  147. package/dist/runtime/internal/static.mjs +1 -1
  148. package/dist/runtime/internal/storage.mjs +1 -1
  149. package/dist/runtime/internal/task.mjs +1 -1
  150. package/dist/runtime/internal/vite/dev-entry.mjs +3 -4
  151. package/dist/runtime/internal/vite/{dev-worker.mjs → node-runner.mjs} +51 -6
  152. package/dist/runtime/meta.d.mts +1 -1
  153. package/dist/runtime/meta.mjs +1 -1
  154. package/dist/runtime/nitro.d.mts +0 -3
  155. package/dist/runtime/nitro.mjs +1 -1
  156. package/dist/runtime/virtual/_runtime_warn.d.mts +1 -0
  157. package/dist/runtime/virtual/_runtime_warn.mjs +5 -0
  158. package/dist/runtime/virtual/database.d.mts +8 -0
  159. package/dist/runtime/virtual/database.mjs +2 -0
  160. package/dist/runtime/virtual/error-handler.d.mts +6 -0
  161. package/dist/runtime/virtual/error-handler.mjs +9 -0
  162. package/dist/runtime/virtual/feature-flags.d.mts +7 -0
  163. package/dist/runtime/virtual/feature-flags.mjs +7 -0
  164. package/dist/runtime/virtual/plugins.d.mts +3 -0
  165. package/dist/runtime/virtual/plugins.mjs +2 -0
  166. package/dist/runtime/virtual/polyfills.d.mts +3 -0
  167. package/dist/runtime/virtual/polyfills.mjs +2 -0
  168. package/dist/runtime/virtual/public-assets.d.mts +9 -0
  169. package/dist/runtime/virtual/public-assets.mjs +8 -0
  170. package/dist/runtime/virtual/renderer-template.d.mts +4 -0
  171. package/dist/runtime/virtual/renderer-template.mjs +7 -0
  172. package/dist/runtime/virtual/routing-meta.d.mts +7 -0
  173. package/dist/runtime/virtual/routing-meta.mjs +2 -0
  174. package/dist/runtime/virtual/routing.d.mts +8 -0
  175. package/dist/runtime/virtual/routing.mjs +11 -0
  176. package/dist/runtime/virtual/runtime-config.d.mts +3 -0
  177. package/dist/runtime/virtual/runtime-config.mjs +5 -0
  178. package/dist/runtime/virtual/server-assets.d.mts +6 -0
  179. package/dist/runtime/virtual/server-assets.mjs +12 -0
  180. package/dist/runtime/virtual/storage.d.mts +3 -0
  181. package/dist/runtime/virtual/storage.mjs +5 -0
  182. package/dist/runtime/virtual/tasks.d.mts +10 -0
  183. package/dist/runtime/virtual/tasks.mjs +3 -0
  184. package/dist/types/index.d.mts +292 -371
  185. package/dist/types/index.mjs +10 -0
  186. package/dist/vite.d.mts +7 -12
  187. package/dist/vite.mjs +734 -41
  188. package/lib/vite.types.d.mts +26 -0
  189. package/lib/vite.types.mjs +2 -0
  190. package/package.json +82 -53
  191. package/dist/_build/common2.mjs +0 -772
  192. package/dist/_build/vite.plugin.mjs +0 -768
  193. package/dist/_chunks/ANM1K1bE.mjs +0 -304
  194. package/dist/_chunks/BX9-zVkM.mjs +0 -59
  195. package/dist/_chunks/C7CbzoI1.mjs +0 -39
  196. package/dist/_libs/acorn.mjs +0 -5034
  197. package/dist/_libs/c12.mjs +0 -2858
  198. package/dist/_libs/commondir.mjs +0 -22
  199. package/dist/_libs/deepmerge.mjs +0 -86
  200. package/dist/_libs/dot-prop.mjs +0 -138
  201. package/dist/_libs/duplexer.mjs +0 -71
  202. package/dist/_libs/etag.mjs +0 -80
  203. package/dist/_libs/fdir.mjs +0 -514
  204. package/dist/_libs/function-bind.mjs +0 -63
  205. package/dist/_libs/giget.mjs +0 -19289
  206. package/dist/_libs/gzip-size.mjs +0 -21
  207. package/dist/_libs/hasown.mjs +0 -14
  208. package/dist/_libs/is-core-module.mjs +0 -220
  209. package/dist/_libs/is-module.mjs +0 -13
  210. package/dist/_libs/is-reference.mjs +0 -32
  211. package/dist/_libs/js-tokens.mjs +0 -382
  212. package/dist/_libs/knitwork.mjs +0 -124
  213. package/dist/_libs/local-pkg.mjs +0 -1686
  214. package/dist/_libs/magic-string.mjs +0 -939
  215. package/dist/_libs/mime.mjs +0 -1391
  216. package/dist/_libs/node-fetch-native.mjs +0 -173
  217. package/dist/_libs/path-parse.mjs +0 -47
  218. package/dist/_libs/pathe.mjs +0 -41
  219. package/dist/_libs/picomatch.mjs +0 -1673
  220. package/dist/_libs/plugin-replace.mjs +0 -104
  221. package/dist/_libs/pretty-bytes.mjs +0 -116
  222. package/dist/_libs/std-env.mjs +0 -158
  223. package/dist/_libs/strip-literal.mjs +0 -51
  224. package/dist/_libs/tinyglobby.mjs +0 -292
  225. package/dist/_libs/untyped.mjs +0 -271
  226. package/dist/_libs/unwasm.mjs +0 -5836
  227. package/dist/cli/_chunks/detect-acorn.mjs +0 -12
  228. package/dist/cli/_chunks/dist.mjs +0 -3
  229. package/dist/cli/_chunks/dist2.mjs +0 -3
  230. package/dist/cli/_chunks/dist3.mjs +0 -3
  231. package/dist/cli/_chunks/dist4.mjs +0 -4
  232. package/dist/cli/_chunks/dist5.mjs +0 -4
  233. package/dist/cli/_chunks/esm.mjs +0 -3
  234. package/dist/cli/_chunks/json5.mjs +0 -4
  235. package/dist/cli/_chunks/jsonc.mjs +0 -4
  236. package/dist/cli/_chunks/multipart-parser.mjs +0 -6
  237. package/dist/cli/_chunks/toml.mjs +0 -4
  238. package/dist/cli/_chunks/yaml.mjs +0 -4
  239. package/dist/node_modules/kleur/index.js +0 -110
  240. package/dist/node_modules/youch/build/chunk-OSUFJZHZ.js +0 -6
  241. package/lib/deps/ofetch.mjs +0 -1
  242. package/lib/deps/ofetch.mts +0 -1
  243. /package/dist/runtime/{vite-runtime.d.mts → vite.d.mts} +0 -0
  244. /package/dist/runtime/{vite-runtime.mjs → vite.mjs} +0 -0
  245. /package/lib/{deps/h3.d.mts → h3.d.mts} +0 -0
  246. /package/lib/{deps/h3.mjs → h3.mjs} +0 -0
@@ -1,1775 +1,210 @@
1
- import { i as __toESM, n as __require, t as __commonJS } from "../_chunks/Bqks5huO.mjs";
2
- import { C as isAbsolute$1, D as parse$2, O as relative$1, T as normalize$2, b as basename$1, f as readPackageJSON, k as resolve$1, m as resolvePackageJSON, w as join$1, x as dirname$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";
1
+ import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "../_common.mjs";
2
+ import { E as parse$1, P as require_picomatch, S as MagicString, T as Parser, at as join$1, b as getMagicString, ct as resolve$1, it as isAbsolute$2, y as createUnimport } from "../_build/common.mjs";
9
3
  import { t as walk } from "./estree-walker.mjs";
10
4
  import { t as remapping } from "./remapping.mjs";
11
5
  import { createRequire } from "node:module";
6
+ import fs, { promises } from "node:fs";
7
+ import "node:fs/promises";
8
+ import { fileURLToPath } from "node:url";
9
+ import "node:os";
12
10
  import path, { basename, dirname, extname, isAbsolute, normalize, resolve } from "node:path";
13
11
  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";
12
+ import "scule";
19
13
  import { Buffer } from "node:buffer";
20
14
  import * as querystring from "node:querystring";
21
15
 
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$1, path$1) {
407
- return path$1[0] === "." ? resolve$1(cwd$1, path$1) : path$1;
408
- }
409
- function normalizePath$1(cwd$1, path$1) {
410
- return resolvePath(cwd$1, 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) {
16
+ //#region node_modules/.pnpm/unimport@5.6.0/node_modules/unimport/dist/chunks/detect-acorn.mjs
17
+ var detect_acorn_exports = /* @__PURE__ */ __exportAll({
18
+ createVirtualImportsAcronWalker: () => createVirtualImportsAcronWalker,
19
+ detectImportsAcorn: () => detectImportsAcorn,
20
+ traveseScopes: () => traveseScopes
21
+ });
22
+ async function detectImportsAcorn(code, ctx, options) {
487
23
  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
24
  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);
25
+ let matchedImports = [];
26
+ const enableAutoImport = options?.autoImport !== false;
27
+ const enableTransformVirtualImports = options?.transformVirtualImports !== false && ctx.options.virtualImports?.length;
28
+ if (enableAutoImport || enableTransformVirtualImports) {
29
+ const ast = parse$1(s.original, {
30
+ sourceType: "module",
31
+ ecmaVersion: "latest",
32
+ locations: true
507
33
  });
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
- }
34
+ const virtualImports = createVirtualImportsAcronWalker(map, ctx.options.virtualImports);
35
+ const scopes = traveseScopes(ast, enableTransformVirtualImports ? virtualImports.walk : {});
36
+ if (enableAutoImport) {
37
+ const identifiers = scopes.unmatched;
38
+ matchedImports.push(...Array.from(identifiers).map((name) => {
39
+ const item = map.get(name);
40
+ if (item && !item.disabled) return item;
41
+ return null;
42
+ }).filter(Boolean));
43
+ for (const addon of ctx.addons) matchedImports = await addon.matchImports?.call(ctx, identifiers, matchedImports) || matchedImports;
514
44
  }
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
45
  virtualImports.ranges.forEach(([start, end]) => {
527
46
  s.remove(start, end);
528
47
  });
529
48
  matchedImports.push(...virtualImports.imports);
530
49
  }
531
- const firstOccurrence = Math.min(...Array.from(occurrenceMap.entries()).map((i) => i[1]));
532
50
  return {
533
51
  s,
534
- strippedCode,
535
- isCJSContext,
52
+ strippedCode: code.toString(),
536
53
  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
54
+ isCJSContext: false,
55
+ firstOccurrence: 0
558
56
  };
559
57
  }
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$1) {
576
- return `${glob2.startsWith("!") ? "!" : ""}${resolve$1(cwd$1, 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$1 = 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$1);
588
- const types = isString$1 ? topLevelTypes : dir.types ?? topLevelTypes;
589
- if (glob2.match(/\.\w+$/)) return {
590
- glob: glob2,
591
- types
58
+ function traveseScopes(ast, additionalWalk) {
59
+ const scopes = [];
60
+ let scopeCurrent = void 0;
61
+ const scopesStack = [];
62
+ function pushScope(node) {
63
+ scopeCurrent = {
64
+ node,
65
+ parent: scopeCurrent,
66
+ declarations: /* @__PURE__ */ new Set(),
67
+ references: /* @__PURE__ */ new Set()
592
68
  };
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 [];
69
+ scopes.push(scopeCurrent);
70
+ scopesStack.push(scopeCurrent);
639
71
  }
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
- });
72
+ function popScope(node) {
73
+ if (scopesStack.pop()?.node !== node) throw new Error("Scope mismatch");
74
+ scopeCurrent = scopesStack[scopesStack.length - 1];
653
75
  }
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;
76
+ pushScope(void 0);
77
+ walk(ast, {
78
+ enter(node, parent, prop, index) {
79
+ additionalWalk?.enter?.call(this, node, parent, prop, index);
80
+ switch (node.type) {
81
+ case "ImportSpecifier":
82
+ case "ImportDefaultSpecifier":
83
+ case "ImportNamespaceSpecifier":
84
+ scopeCurrent.declarations.add(node.local.name);
85
+ return;
86
+ case "FunctionDeclaration":
87
+ case "ClassDeclaration":
88
+ if (node.id) scopeCurrent.declarations.add(node.id.name);
89
+ return;
90
+ case "VariableDeclarator":
91
+ if (node.id.type === "Identifier") scopeCurrent.declarations.add(node.id.name);
92
+ else walk(node.id, { enter(node2) {
93
+ if (node2.type === "ObjectPattern") node2.properties.forEach((i) => {
94
+ if (i.type === "Property" && i.value.type === "Identifier") scopeCurrent.declarations.add(i.value.name);
95
+ else if (i.type === "RestElement" && i.argument.type === "Identifier") scopeCurrent.declarations.add(i.argument.name);
96
+ });
97
+ else if (node2.type === "ArrayPattern") node2.elements.forEach((i) => {
98
+ if (i?.type === "Identifier") scopeCurrent.declarations.add(i.name);
99
+ if (i?.type === "RestElement" && i.argument.type === "Identifier") scopeCurrent.declarations.add(i.argument.name);
100
+ });
101
+ } });
102
+ return;
103
+ case "BlockStatement":
104
+ switch (parent?.type) {
105
+ case "FunctionDeclaration":
106
+ case "ArrowFunctionExpression":
107
+ case "FunctionExpression": {
108
+ const parameterIdentifiers = parent.params.filter((p) => p.type === "Identifier");
109
+ for (const id of parameterIdentifiers) scopeCurrent.declarations.add(id.name);
110
+ break;
111
+ }
112
+ }
113
+ pushScope(node);
114
+ return;
115
+ case "Identifier":
116
+ switch (parent?.type) {
117
+ case "CallExpression":
118
+ if (parent.callee === node || parent.arguments.includes(node)) scopeCurrent.references.add(node.name);
119
+ return;
120
+ case "MemberExpression":
121
+ if (parent.object === node) scopeCurrent.references.add(node.name);
122
+ return;
123
+ case "VariableDeclarator":
124
+ if (parent.init === node) scopeCurrent.references.add(node.name);
125
+ return;
126
+ case "SpreadElement":
127
+ if (parent.argument === node) scopeCurrent.references.add(node.name);
128
+ return;
129
+ case "ClassDeclaration":
130
+ if (parent.superClass === node) scopeCurrent.references.add(node.name);
131
+ return;
132
+ case "Property":
133
+ if (parent.value === node) scopeCurrent.references.add(node.name);
134
+ return;
135
+ case "TemplateLiteral":
136
+ if (parent.expressions.includes(node)) scopeCurrent.references.add(node.name);
137
+ return;
138
+ case "AssignmentExpression":
139
+ if (parent.right === node) scopeCurrent.references.add(node.name);
140
+ return;
141
+ case "IfStatement":
142
+ case "WhileStatement":
143
+ case "DoWhileStatement":
144
+ if (parent.test === node) scopeCurrent.references.add(node.name);
145
+ return;
146
+ case "SwitchStatement":
147
+ if (parent.discriminant === node) scopeCurrent.references.add(node.name);
148
+ return;
149
+ }
150
+ if (parent?.type.includes("Expression")) scopeCurrent.references.add(node.name);
694
151
  }
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;
152
+ },
153
+ leave(node, parent, prop, index) {
154
+ additionalWalk?.leave?.call(this, node, parent, prop, index);
155
+ switch (node.type) {
156
+ case "BlockStatement": popScope(node);
704
157
  }
705
- const nested = await scanExports(subfilepath, includeTypes, seen);
706
- imports.push(...additional ? nested.map((i) => ({
707
- ...i,
708
- ...additional
709
- })) : nested);
710
158
  }
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
159
  });
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();
160
+ const unmatched = /* @__PURE__ */ new Set();
161
+ for (const scope of scopes) for (const name of scope.references) {
162
+ let defined = false;
163
+ let parent = scope;
164
+ while (parent) {
165
+ if (parent.declarations.has(name)) {
166
+ defined = true;
167
+ break;
168
+ }
169
+ parent = parent?.parent;
170
+ }
171
+ if (!defined) unmatched.add(name);
1648
172
  }
1649
173
  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)
174
+ unmatched,
175
+ scopes
1664
176
  };
1665
177
  }
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(", ")}` : ""}`);
178
+ function createVirtualImportsAcronWalker(importMap, virtualImports = []) {
179
+ const imports = [];
180
+ const ranges = [];
1746
181
  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
182
+ imports,
183
+ ranges,
184
+ walk: { enter(node) {
185
+ if (node.type === "ImportDeclaration") {
186
+ if (virtualImports.includes(node.source.value)) {
187
+ ranges.push([node.start, node.end]);
188
+ node.specifiers.forEach((i) => {
189
+ if (i.type === "ImportSpecifier" && i.imported.type === "Identifier") {
190
+ const original = importMap.get(i.imported.name);
191
+ if (!original) throw new Error(`[unimport] failed to find "${i.imported.name}" imported from "${node.source.value}"`);
192
+ imports.push({
193
+ from: original.from,
194
+ name: original.name,
195
+ as: i.local.name
196
+ });
197
+ }
198
+ });
199
+ }
200
+ }
201
+ } }
1755
202
  };
1756
203
  }
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
204
 
1770
205
  //#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);
206
+ //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/context-Csj9j3eN.js
207
+ var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch(), 1);
1773
208
  function toArray$2(array) {
1774
209
  array = array || [];
1775
210
  if (Array.isArray(array)) return array;
@@ -1780,12 +215,12 @@ function normalize$1(path$1) {
1780
215
  return path$1.replace(BACKSLASH_REGEX, "/");
1781
216
  }
1782
217
  const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Z]:)?[/\\|])/i;
1783
- function isAbsolute$1$1(path$1) {
218
+ function isAbsolute$1(path$1) {
1784
219
  return ABSOLUTE_PATH_REGEX.test(path$1);
1785
220
  }
1786
- function getMatcherString$1(glob$1, cwd$1) {
1787
- if (glob$1.startsWith("**") || isAbsolute$1$1(glob$1)) return normalize$1(glob$1);
1788
- return normalize$1(resolve(cwd$1, glob$1));
221
+ function getMatcherString$1(glob, cwd$1) {
222
+ if (glob.startsWith("**") || isAbsolute$1(glob)) return normalize$1(glob);
223
+ return normalize$1(resolve(cwd$1, glob));
1789
224
  }
1790
225
  function patternToIdFilter(pattern) {
1791
226
  if (pattern instanceof RegExp) return (id) => {
@@ -1794,7 +229,7 @@ function patternToIdFilter(pattern) {
1794
229
  pattern.lastIndex = 0;
1795
230
  return result;
1796
231
  };
1797
- const matcher = (0, import_picomatch$1.default)(getMatcherString$1(pattern, process.cwd()), { dot: true });
232
+ const matcher = (0, import_picomatch.default)(getMatcherString$1(pattern, process.cwd()), { dot: true });
1798
233
  return (id) => {
1799
234
  return matcher(normalize$1(id));
1800
235
  };
@@ -1868,7 +303,7 @@ function normalizeObjectHook(name, hook) {
1868
303
  filter: filter || (() => true)
1869
304
  };
1870
305
  }
1871
- function parse$1(code, opts = {}) {
306
+ function parse(code, opts = {}) {
1872
307
  return Parser.parse(code, {
1873
308
  sourceType: "module",
1874
309
  ecmaVersion: "latest",
@@ -1878,7 +313,7 @@ function parse$1(code, opts = {}) {
1878
313
  }
1879
314
 
1880
315
  //#endregion
1881
- //#region node_modules/.pnpm/unplugin@2.3.10/node_modules/unplugin/dist/webpack-like-CSbnjTNU.js
316
+ //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/webpack-like-DFGTNSuV.js
1882
317
  function transformUse(data, plugin, transformLoader) {
1883
318
  if (data.resource == null) return [];
1884
319
  const id = normalizeAbsolutePath(data.resource + (data.resourceQuery || ""));
@@ -1907,15 +342,16 @@ function normalizeAbsolutePath(path$1) {
1907
342
  }
1908
343
 
1909
344
  //#endregion
1910
- //#region node_modules/.pnpm/unplugin@2.3.10/node_modules/unplugin/dist/context-D_KPTgTH.js
1911
- function createBuildContext(compiler, compilation, loaderContext) {
345
+ //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/context-DkYlx1xL.js
346
+ function createBuildContext$1(compiler, compilation, loaderContext, inputSourceMap) {
1912
347
  return {
1913
348
  getNativeBuildContext() {
1914
349
  return {
1915
350
  framework: "rspack",
1916
351
  compiler,
1917
352
  compilation,
1918
- loaderContext
353
+ loaderContext,
354
+ inputSourceMap
1919
355
  };
1920
356
  },
1921
357
  addWatchFile(file) {
@@ -1925,7 +361,7 @@ function createBuildContext(compiler, compilation, loaderContext) {
1925
361
  getWatchFiles() {
1926
362
  return Array.from(compilation.fileDependencies);
1927
363
  },
1928
- parse: parse$1,
364
+ parse,
1929
365
  emitFile(emittedFile) {
1930
366
  const outFileName = emittedFile.fileName || emittedFile.name;
1931
367
  if (emittedFile.source && outFileName) {
@@ -1935,7 +371,7 @@ function createBuildContext(compiler, compilation, loaderContext) {
1935
371
  }
1936
372
  };
1937
373
  }
1938
- function normalizeMessage(error) {
374
+ function normalizeMessage$1(error) {
1939
375
  const err = new Error(typeof error === "string" ? error : error.message);
1940
376
  if (typeof error === "object") {
1941
377
  err.stack = error.stack;
@@ -1945,7 +381,7 @@ function normalizeMessage(error) {
1945
381
  }
1946
382
 
1947
383
  //#endregion
1948
- //#region node_modules/.pnpm/unplugin@2.3.10/node_modules/unplugin/dist/utils-C8vphsat.js
384
+ //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/utils-BosfZ0pB.js
1949
385
  function encodeVirtualModuleId(id, plugin) {
1950
386
  return resolve(plugin.__virtualModulePrefix, encodeURIComponent(id));
1951
387
  }
@@ -1955,16 +391,16 @@ function decodeVirtualModuleId(encoded, _plugin) {
1955
391
  function isVirtualModuleId(encoded, plugin) {
1956
392
  return dirname(encoded) === plugin.__virtualModulePrefix;
1957
393
  }
1958
- var FakeVirtualModulesPlugin = class FakeVirtualModulesPlugin$1 {
394
+ var FakeVirtualModulesPlugin = class FakeVirtualModulesPlugin {
1959
395
  name = "FakeVirtualModulesPlugin";
1960
396
  static counters = /* @__PURE__ */ new Map();
1961
397
  static initCleanup = false;
1962
398
  constructor(plugin) {
1963
399
  this.plugin = plugin;
1964
- if (!FakeVirtualModulesPlugin$1.initCleanup) {
1965
- FakeVirtualModulesPlugin$1.initCleanup = true;
400
+ if (!FakeVirtualModulesPlugin.initCleanup) {
401
+ FakeVirtualModulesPlugin.initCleanup = true;
1966
402
  process.once("exit", () => {
1967
- FakeVirtualModulesPlugin$1.counters.forEach((_, dir) => {
403
+ FakeVirtualModulesPlugin.counters.forEach((_, dir) => {
1968
404
  fs.rmSync(dir, {
1969
405
  recursive: true,
1970
406
  force: true
@@ -1976,17 +412,17 @@ var FakeVirtualModulesPlugin = class FakeVirtualModulesPlugin$1 {
1976
412
  apply(compiler) {
1977
413
  const dir = this.plugin.__virtualModulePrefix;
1978
414
  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);
415
+ const counter = FakeVirtualModulesPlugin.counters.get(dir) ?? 0;
416
+ FakeVirtualModulesPlugin.counters.set(dir, counter + 1);
1981
417
  compiler.hooks.shutdown.tap(this.name, () => {
1982
- const counter$1 = (FakeVirtualModulesPlugin$1.counters.get(dir) ?? 1) - 1;
418
+ const counter$1 = (FakeVirtualModulesPlugin.counters.get(dir) ?? 1) - 1;
1983
419
  if (counter$1 === 0) {
1984
- FakeVirtualModulesPlugin$1.counters.delete(dir);
420
+ FakeVirtualModulesPlugin.counters.delete(dir);
1985
421
  fs.rmSync(dir, {
1986
422
  recursive: true,
1987
423
  force: true
1988
424
  });
1989
- } else FakeVirtualModulesPlugin$1.counters.set(dir, counter$1);
425
+ } else FakeVirtualModulesPlugin.counters.set(dir, counter$1);
1990
426
  });
1991
427
  }
1992
428
  async writeModule(file) {
@@ -1995,7 +431,7 @@ var FakeVirtualModulesPlugin = class FakeVirtualModulesPlugin$1 {
1995
431
  };
1996
432
 
1997
433
  //#endregion
1998
- //#region node_modules/.pnpm/unplugin@2.3.10/node_modules/unplugin/dist/context-BZKy5Nsn.js
434
+ //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/context-OCFO8EW1.js
1999
435
  function contextOptionsFromCompilation(compilation) {
2000
436
  return {
2001
437
  addWatchFile(file) {
@@ -2010,9 +446,9 @@ const require$1 = createRequire(import.meta.url);
2010
446
  function getSource(fileSource) {
2011
447
  return new (require$1("webpack")).sources.RawSource(typeof fileSource === "string" ? fileSource : Buffer.from(fileSource.buffer));
2012
448
  }
2013
- function createBuildContext$1(options, compiler, compilation, loaderContext) {
449
+ function createBuildContext(options, compiler, compilation, loaderContext, inputSourceMap) {
2014
450
  return {
2015
- parse: parse$1,
451
+ parse,
2016
452
  addWatchFile(id) {
2017
453
  options.addWatchFile(resolve(process$1.cwd(), id));
2018
454
  },
@@ -2031,12 +467,13 @@ function createBuildContext$1(options, compiler, compilation, loaderContext) {
2031
467
  framework: "webpack",
2032
468
  compiler,
2033
469
  compilation,
2034
- loaderContext
470
+ loaderContext,
471
+ inputSourceMap
2035
472
  };
2036
473
  }
2037
474
  };
2038
475
  }
2039
- function normalizeMessage$1(error) {
476
+ function normalizeMessage(error) {
2040
477
  const err = new Error(typeof error === "string" ? error : error.message);
2041
478
  if (typeof error === "object") {
2042
479
  err.stack = error.stack;
@@ -2047,7 +484,7 @@ function normalizeMessage$1(error) {
2047
484
 
2048
485
  //#endregion
2049
486
  //#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) => {
487
+ var require_virtual_stats = /* @__PURE__ */ __commonJSMin(((exports) => {
2051
488
  var __importDefault = exports && exports.__importDefault || function(mod) {
2052
489
  return mod && mod.__esModule ? mod : { "default": mod };
2053
490
  };
@@ -2087,11 +524,11 @@ var require_virtual_stats = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/web
2087
524
  }
2088
525
  };
2089
526
  exports.VirtualStats = VirtualStats;
2090
- }) });
527
+ }));
2091
528
 
2092
529
  //#endregion
2093
530
  //#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) => {
531
+ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2095
532
  const path_1 = (exports && exports.__importDefault || function(mod) {
2096
533
  return mod && mod.__esModule ? mod : { "default": mod };
2097
534
  })(__require("path"));
@@ -2149,7 +586,7 @@ var require_lib = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/webpack-virtu
2149
586
  function getRealpathBackend(fileSystem) {
2150
587
  if (fileSystem._realpathBackend) return fileSystem._realpathBackend;
2151
588
  }
2152
- var VirtualModulesPlugin$1 = class {
589
+ var VirtualModulesPlugin = class {
2153
590
  constructor(modules) {
2154
591
  this._compiler = null;
2155
592
  this._watcher = null;
@@ -2286,14 +723,14 @@ var require_lib = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/webpack-virtu
2286
723
  this._staticModules = null;
2287
724
  }
2288
725
  };
2289
- const version$1 = typeof compiler.webpack === "undefined" ? 4 : 5;
726
+ const version = typeof compiler.webpack === "undefined" ? 4 : 5;
2290
727
  const watchRunHook = (watcher, callback) => {
2291
728
  this._watcher = watcher.compiler || watcher;
2292
729
  const virtualFiles = compiler.inputFileSystem._virtualFiles;
2293
730
  const fts = compiler.fileTimestamps;
2294
731
  if (virtualFiles && fts && typeof fts.set === "function") Object.keys(virtualFiles).forEach((file) => {
2295
732
  const mtime = +virtualFiles[file].stats.mtime;
2296
- fts.set(file, version$1 === 4 ? mtime : {
733
+ fts.set(file, version === 4 ? mtime : {
2297
734
  safeTime: mtime,
2298
735
  timestamp: mtime
2299
736
  });
@@ -2311,11 +748,11 @@ var require_lib = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/webpack-virtu
2311
748
  }
2312
749
  }
2313
750
  };
2314
- module.exports = VirtualModulesPlugin$1;
2315
- }) });
751
+ module.exports = VirtualModulesPlugin;
752
+ }));
2316
753
 
2317
754
  //#endregion
2318
- //#region node_modules/.pnpm/unplugin@2.3.10/node_modules/unplugin/dist/index.js
755
+ //#region node_modules/.pnpm/unplugin@2.3.11/node_modules/unplugin/dist/index.js
2319
756
  var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
2320
757
  const ExtToLoader = {
2321
758
  ".js": "js",
@@ -2379,7 +816,7 @@ function createBuildContext$2(build) {
2379
816
  const watchFiles = [];
2380
817
  const { initialOptions } = build;
2381
818
  return {
2382
- parse: parse$1,
819
+ parse,
2383
820
  addWatchFile() {
2384
821
  throw new Error("unplugin/esbuild: addWatchFile outside supported hooks (resolveId, load, transform)");
2385
822
  },
@@ -2605,7 +1042,7 @@ function buildSetup() {
2605
1042
  }
2606
1043
  function createFarmContext(context, currentResolveId) {
2607
1044
  return {
2608
- parse: parse$1,
1045
+ parse,
2609
1046
  addWatchFile(id) {
2610
1047
  context.addWatchFile(id, currentResolveId || id);
2611
1048
  },
@@ -2957,7 +1394,7 @@ const LOAD_LOADER$1 = resolve(__dirname, "rspack/loaders/load");
2957
1394
  function getRspackPlugin(factory) {
2958
1395
  return (userOptions) => {
2959
1396
  return { apply(compiler) {
2960
- const VIRTUAL_MODULE_PREFIX = resolve(compiler.options.context ?? process.cwd(), "node_modules/.virtual", process.pid.toString());
1397
+ const VIRTUAL_MODULE_PREFIX = resolve(compiler.options.context ?? process.cwd(), "node_modules/.virtual", compiler.rspack.experiments.VirtualModulesPlugin ? "" : process.pid.toString());
2961
1398
  const meta = {
2962
1399
  framework: "rspack",
2963
1400
  rspack: { compiler }
@@ -2986,11 +1423,11 @@ function getRspackPlugin(factory) {
2986
1423
  let importer = requestContext.issuer !== "" ? requestContext.issuer : void 0;
2987
1424
  const isEntry = requestContext.issuer === "";
2988
1425
  if (importer?.startsWith(plugin.__virtualModulePrefix)) importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
2989
- const context = createBuildContext(compiler, compilation);
1426
+ const context = createBuildContext$1(compiler, compilation);
2990
1427
  let error;
2991
1428
  const pluginContext = {
2992
1429
  error(msg) {
2993
- if (error == null) error = normalizeMessage(msg);
1430
+ if (error == null) error = normalizeMessage$1(msg);
2994
1431
  else console.error(`unplugin/rspack: multiple errors returned from resolveId hook: ${msg}`);
2995
1432
  },
2996
1433
  warn(msg) {
@@ -3050,7 +1487,7 @@ function getRspackPlugin(factory) {
3050
1487
  });
3051
1488
  if (plugin.rspack) plugin.rspack(compiler);
3052
1489
  if (plugin.watchChange || plugin.buildStart) compiler.hooks.make.tapPromise(plugin.name, async (compilation) => {
3053
- const context = createBuildContext(compiler, compilation);
1490
+ const context = createBuildContext$1(compiler, compilation);
3054
1491
  if (plugin.watchChange && (compiler.modifiedFiles || compiler.removedFiles)) {
3055
1492
  const promises$1 = [];
3056
1493
  if (compiler.modifiedFiles) compiler.modifiedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
@@ -3060,7 +1497,7 @@ function getRspackPlugin(factory) {
3060
1497
  if (plugin.buildStart) return await plugin.buildStart.call(context);
3061
1498
  });
3062
1499
  if (plugin.buildEnd) compiler.hooks.emit.tapPromise(plugin.name, async (compilation) => {
3063
- await plugin.buildEnd.call(createBuildContext(compiler, compilation));
1500
+ await plugin.buildEnd.call(createBuildContext$1(compiler, compilation));
3064
1501
  });
3065
1502
  if (plugin.writeBundle) compiler.hooks.afterEmit.tapPromise(plugin.name, async () => {
3066
1503
  await plugin.writeBundle();
@@ -3122,7 +1559,7 @@ function getWebpackPlugin(factory) {
3122
1559
  const isEntry = requestContext.issuer === "";
3123
1560
  if (importer?.startsWith(plugin.__virtualModulePrefix)) importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
3124
1561
  const fileDependencies = /* @__PURE__ */ new Set();
3125
- const context = createBuildContext$1({
1562
+ const context = createBuildContext({
3126
1563
  addWatchFile(file) {
3127
1564
  fileDependencies.add(file);
3128
1565
  resolveContext.fileDependencies?.add(file);
@@ -3134,7 +1571,7 @@ function getWebpackPlugin(factory) {
3134
1571
  let error;
3135
1572
  const pluginContext = {
3136
1573
  error(msg) {
3137
- if (error == null) error = normalizeMessage$1(msg);
1574
+ if (error == null) error = normalizeMessage(msg);
3138
1575
  else console.error(`unplugin/webpack: multiple errors returned from resolveId hook: ${msg}`);
3139
1576
  },
3140
1577
  warn(msg) {
@@ -3187,7 +1624,7 @@ function getWebpackPlugin(factory) {
3187
1624
  });
3188
1625
  if (plugin.webpack) plugin.webpack(compiler);
3189
1626
  if (plugin.watchChange || plugin.buildStart) compiler.hooks.make.tapPromise(plugin.name, async (compilation) => {
3190
- const context = createBuildContext$1(contextOptionsFromCompilation(compilation), compiler, compilation);
1627
+ const context = createBuildContext(contextOptionsFromCompilation(compilation), compiler, compilation);
3191
1628
  if (plugin.watchChange && (compiler.modifiedFiles || compiler.removedFiles)) {
3192
1629
  const promises$1 = [];
3193
1630
  if (compiler.modifiedFiles) compiler.modifiedFiles.forEach((file) => promises$1.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
@@ -3197,7 +1634,7 @@ function getWebpackPlugin(factory) {
3197
1634
  if (plugin.buildStart) return await plugin.buildStart.call(context);
3198
1635
  });
3199
1636
  if (plugin.buildEnd) compiler.hooks.emit.tapPromise(plugin.name, async (compilation) => {
3200
- await plugin.buildEnd.call(createBuildContext$1(contextOptionsFromCompilation(compilation), compiler, compilation));
1637
+ await plugin.buildEnd.call(createBuildContext(contextOptionsFromCompilation(compilation), compiler, compilation));
3201
1638
  });
3202
1639
  if (plugin.writeBundle) compiler.hooks.afterEmit.tapPromise(plugin.name, async () => {
3203
1640
  await plugin.writeBundle();
@@ -3247,7 +1684,6 @@ function createUnplugin(factory) {
3247
1684
 
3248
1685
  //#endregion
3249
1686
  //#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
1687
  /**
3252
1688
  * Converts path separators to forward slash.
3253
1689
  */
@@ -3262,7 +1698,7 @@ function toArray$1(thing) {
3262
1698
  }
3263
1699
  const escapeMark = "[_#EsCaPe#_]";
3264
1700
  function getMatcherString(id, resolutionBase) {
3265
- if (resolutionBase === false || isAbsolute$1(id) || id.startsWith("**")) return normalizePath(id);
1701
+ if (resolutionBase === false || isAbsolute$2(id) || id.startsWith("**")) return normalizePath(id);
3266
1702
  return join$1(normalizePath(resolve$1(resolutionBase || "")).replaceAll(/[-^$*+?.()|[\]{}]/g, `${escapeMark}$&`), normalizePath(id)).replaceAll(escapeMark, "\\");
3267
1703
  }
3268
1704
  /**
@@ -3302,7 +1738,12 @@ function createFilter(include, exclude, options) {
3302
1738
  }
3303
1739
 
3304
1740
  //#endregion
3305
- //#region node_modules/.pnpm/unimport@5.5.0/node_modules/unimport/dist/unplugin.mjs
1741
+ //#region node_modules/.pnpm/unimport@5.6.0/node_modules/unimport/dist/unplugin.mjs
1742
+ var unplugin_exports = /* @__PURE__ */ __exportAll({
1743
+ default: () => unplugin,
1744
+ defaultExcludes: () => defaultExcludes,
1745
+ defaultIncludes: () => defaultIncludes
1746
+ });
3306
1747
  const defaultIncludes = [
3307
1748
  /\.[jt]sx?$/,
3308
1749
  /\.vue$/,
@@ -3341,180 +1782,4 @@ const unplugin = createUnplugin((options = {}) => {
3341
1782
  });
3342
1783
 
3343
1784
  //#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 { createUnimport as a, unplugin as i, detectImportsAcorn as n, toExports as o, traveseScopes as r, createVirtualImportsAcronWalker as t };
1785
+ export { detect_acorn_exports as n, unplugin_exports as t };