nitro-nightly 3.0.1-20260120-020848-6786d069 → 3.0.1-20260120-133849-ca1a9dee
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_build/common.mjs +24931 -0
- package/dist/_build/rolldown.mjs +6 -11
- package/dist/_build/rollup.mjs +201 -0
- package/dist/_build/vite.build.mjs +1 -1
- package/dist/_chunks/dev.mjs +4 -6
- package/dist/_chunks/nitro.mjs +1183 -24
- package/dist/_chunks/nitro2.mjs +91 -248
- package/dist/_chunks/utils.mjs +254 -0
- package/dist/_common.mjs +45 -0
- package/dist/_libs/c12+giget+readdirp+chokidar.d.mts +214 -0
- package/dist/_libs/citty.mjs +140 -110
- package/dist/_libs/commondir+is-reference.mjs +1300 -0
- package/dist/_libs/compatx.d.mts +47 -0
- package/dist/_libs/confbox.mjs +2488 -70
- package/dist/_libs/esbuild.d.mts +20 -0
- package/dist/_libs/escape-string-regexp.mjs +8 -0
- package/dist/_libs/estree-walker.mjs +187 -0
- package/dist/_libs/hasown+resolve+deepmerge.mjs +1972 -0
- package/dist/_libs/httpxy.d.mts +79 -0
- package/dist/_libs/httpxy.mjs +6 -1
- package/dist/_libs/klona.mjs +38 -0
- package/dist/_libs/magic-string.d.mts +220 -0
- package/dist/_libs/mlly.d.mts +57 -0
- package/dist/_libs/nypm+giget+tinyexec.mjs +3603 -0
- package/dist/_libs/pkg-types.d.mts +23 -0
- package/dist/_libs/plugin-alias.mjs +64 -0
- package/dist/_libs/{plugin-alias+plugin-inject.mjs → plugin-inject.mjs} +2 -65
- package/dist/_libs/plugin-json.mjs +36 -0
- package/dist/_libs/pluginutils+plugin-commonjs.d.mts +241 -0
- package/dist/_libs/pluginutils.mjs +652 -0
- package/dist/_libs/{c12+dotenv+rc9.mjs → rc9+c12+dotenv.mjs} +105 -12
- package/dist/_libs/{chokidar+readdirp.mjs → readdirp+chokidar.mjs} +8 -1
- package/dist/_libs/remapping.mjs +117 -0
- package/dist/_libs/resolve-uri+gen-mapping.mjs +448 -0
- package/dist/_libs/rou3.d.mts +43 -0
- package/dist/_libs/rou3.mjs +322 -0
- package/dist/_libs/std-env.d.mts +4 -0
- package/dist/_libs/tsconfck.mjs +832 -0
- package/dist/_libs/ultrahtml.mjs +138 -0
- package/dist/_libs/{gen-mapping+remapping+resolve-uri+trace-mapping+unimport+unplugin+unplugin-utils+webpack-virtual-modules.mjs → unimport+unplugin.mjs} +228 -593
- package/dist/_libs/unplugin+unimport.d.mts +426 -0
- package/dist/_libs/unwasm.d.mts +29 -0
- package/dist/_presets.mjs +3 -8
- package/dist/builder.mjs +6 -8
- package/dist/cli/_chunks/build.mjs +1 -1
- package/dist/cli/_chunks/dev.mjs +2 -3
- package/dist/cli/_chunks/list.mjs +1 -1
- package/dist/cli/_chunks/prepare.mjs +1 -1
- package/dist/cli/_chunks/run.mjs +1 -1
- package/dist/cli/_chunks/task.mjs +16 -0
- package/dist/cli/index.mjs +1 -1
- package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -5
- package/dist/presets/netlify/runtime/netlify-edge.d.mts +0 -1
- package/dist/presets/winterjs/runtime/winterjs.d.mts +0 -1
- package/dist/runtime/internal/error/dev.d.mts +0 -1
- package/dist/runtime/internal/route-rules.d.mts +0 -4
- package/dist/runtime/internal/routes/openapi.d.mts +0 -1
- package/dist/runtime/internal/routes/scalar.d.mts +0 -1
- package/dist/runtime/internal/routes/swagger.d.mts +0 -1
- package/dist/runtime/internal/runtime-config.d.mts +0 -1
- package/dist/runtime/nitro.d.mts +0 -3
- package/dist/runtime/virtual/renderer-template.d.mts +0 -1
- package/dist/types/index.d.mts +25 -1394
- package/dist/vite.mjs +18 -641
- package/package.json +5 -5
- package/dist/_chunks/nitro3.mjs +0 -2696
- package/dist/_chunks/nitro4.mjs +0 -176
- package/dist/_chunks/nitro5.mjs +0 -733
- package/dist/_chunks/nitro6.mjs +0 -1458
- package/dist/_chunks/nitro7.mjs +0 -7561
- package/dist/_chunks/nitro8.mjs +0 -3524
- package/dist/_chunks/nitro9.mjs +0 -1729
- package/dist/_libs/_.mjs +0 -3
- package/dist/_libs/_2.mjs +0 -3
- package/dist/_libs/_3.mjs +0 -4
- package/dist/_libs/_4.mjs +0 -6
- package/dist/_libs/_5.mjs +0 -3
- package/dist/_libs/_6.mjs +0 -3
- package/dist/_libs/acorn+confbox+js-tokens+magic-string+mlly+pkg-types+sourcemap-codec+strip-literal+unimport.mjs +0 -8900
- package/dist/_libs/confbox+exsolve+pkg-types.mjs +0 -1249
- package/dist/_libs/confbox2.mjs +0 -786
- package/dist/_libs/confbox3.mjs +0 -404
- package/dist/_libs/confbox4.mjs +0 -3
- package/dist/_libs/estree-walker+unimport.mjs +0 -378
- package/dist/_libs/fdir+picomatch+tinyglobby.mjs +0 -2471
- package/dist/_libs/giget+node-fetch-native.mjs +0 -2692
- package/dist/_libs/local-pkg+quansync+unimport.mjs +0 -1526
- package/dist/_libs/nypm+tinyexec.mjs +0 -858
- package/dist/_libs/pathe.mjs +0 -164
- package/dist/_libs/perfect-debounce.mjs +0 -89
- package/dist/_libs/std-env.mjs +0 -158
- package/dist/_libs/unimport.mjs +0 -9
- package/dist/_libs/vite-plugin-fullstack.mjs +0 -26
|
@@ -1,1526 +0,0 @@
|
|
|
1
|
-
import { r as __toESM } from "../_chunks/nitro.mjs";
|
|
2
|
-
import { a as join$1, c as parse, n as dirname$1, o as normalize$1, t as basename$1, u as resolve$1 } from "./pathe.mjs";
|
|
3
|
-
import { c as resolvePackageJSON, o as readPackageJSON } from "./confbox+exsolve+pkg-types.mjs";
|
|
4
|
-
import { n as require_picomatch, t as glob } from "./fdir+picomatch+tinyglobby.mjs";
|
|
5
|
-
import { D as findStaticImports, E as findExports, M as resolve$2, N as resolveModuleExportNames, O as findTypeExports, P as resolvePathSync, T as detectSyntax, a as defineUnimportPreset, b as vueTemplateAddon, c as importAsRE, d as separatorRE, g as toTypeDeclarationFile, h as toExports, i as dedupeImports, j as parseStaticImport, l as matchRE, m as stripFileExtension, n as VUE_TEMPLATE_NAME, o as excludeRE, p as stripCommentsAndStrings, r as addImportToCode, s as getMagicString, t as VUE_DIRECTIVES_NAME, u as normalizeImports, v as toTypeReExports, y as vueDirectivesAddon } from "./acorn+confbox+js-tokens+magic-string+mlly+pkg-types+sourcemap-codec+strip-literal+unimport.mjs";
|
|
6
|
-
import { createRequire } from "node:module";
|
|
7
|
-
import fs, { accessSync, constants, existsSync, promises, readFileSync } from "node:fs";
|
|
8
|
-
import fsp, { readFile } from "node:fs/promises";
|
|
9
|
-
import { fileURLToPath } from "node:url";
|
|
10
|
-
import os from "node:os";
|
|
11
|
-
import path, { dirname, join, win32 } from "node:path";
|
|
12
|
-
import process$1 from "node:process";
|
|
13
|
-
import { camelCase } from "scule";
|
|
14
|
-
|
|
15
|
-
//#region node_modules/.pnpm/quansync@0.2.11/node_modules/quansync/dist/index.mjs
|
|
16
|
-
const GET_IS_ASYNC = Symbol.for("quansync.getIsAsync");
|
|
17
|
-
var QuansyncError = class extends Error {
|
|
18
|
-
constructor(message = "Unexpected promise in sync context") {
|
|
19
|
-
super(message);
|
|
20
|
-
this.name = "QuansyncError";
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
function isThenable(value) {
|
|
24
|
-
return value && typeof value === "object" && typeof value.then === "function";
|
|
25
|
-
}
|
|
26
|
-
function isQuansyncGenerator(value) {
|
|
27
|
-
return value && typeof value === "object" && typeof value[Symbol.iterator] === "function" && "__quansync" in value;
|
|
28
|
-
}
|
|
29
|
-
function fromObject(options) {
|
|
30
|
-
const generator = function* (...args) {
|
|
31
|
-
if (yield GET_IS_ASYNC) return yield options.async.apply(this, args);
|
|
32
|
-
return options.sync.apply(this, args);
|
|
33
|
-
};
|
|
34
|
-
function fn(...args) {
|
|
35
|
-
const iter = generator.apply(this, args);
|
|
36
|
-
iter.then = (...thenArgs) => options.async.apply(this, args).then(...thenArgs);
|
|
37
|
-
iter.__quansync = true;
|
|
38
|
-
return iter;
|
|
39
|
-
}
|
|
40
|
-
fn.sync = options.sync;
|
|
41
|
-
fn.async = options.async;
|
|
42
|
-
return fn;
|
|
43
|
-
}
|
|
44
|
-
function fromPromise(promise) {
|
|
45
|
-
return fromObject({
|
|
46
|
-
async: () => Promise.resolve(promise),
|
|
47
|
-
sync: () => {
|
|
48
|
-
if (isThenable(promise)) throw new QuansyncError();
|
|
49
|
-
return promise;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
function unwrapYield(value, isAsync) {
|
|
54
|
-
if (value === GET_IS_ASYNC) return isAsync;
|
|
55
|
-
if (isQuansyncGenerator(value)) return isAsync ? iterateAsync(value) : iterateSync(value);
|
|
56
|
-
if (!isAsync && isThenable(value)) throw new QuansyncError();
|
|
57
|
-
return value;
|
|
58
|
-
}
|
|
59
|
-
const DEFAULT_ON_YIELD = (value) => value;
|
|
60
|
-
function iterateSync(generator, onYield = DEFAULT_ON_YIELD) {
|
|
61
|
-
let current = generator.next();
|
|
62
|
-
while (!current.done) try {
|
|
63
|
-
current = generator.next(unwrapYield(onYield(current.value, false)));
|
|
64
|
-
} catch (err) {
|
|
65
|
-
current = generator.throw(err);
|
|
66
|
-
}
|
|
67
|
-
return unwrapYield(current.value);
|
|
68
|
-
}
|
|
69
|
-
async function iterateAsync(generator, onYield = DEFAULT_ON_YIELD) {
|
|
70
|
-
let current = generator.next();
|
|
71
|
-
while (!current.done) try {
|
|
72
|
-
current = generator.next(await unwrapYield(onYield(current.value, true), true));
|
|
73
|
-
} catch (err) {
|
|
74
|
-
current = generator.throw(err);
|
|
75
|
-
}
|
|
76
|
-
return current.value;
|
|
77
|
-
}
|
|
78
|
-
function fromGeneratorFn(generatorFn, options) {
|
|
79
|
-
return fromObject({
|
|
80
|
-
name: generatorFn.name,
|
|
81
|
-
async(...args) {
|
|
82
|
-
return iterateAsync(generatorFn.apply(this, args), options?.onYield);
|
|
83
|
-
},
|
|
84
|
-
sync(...args) {
|
|
85
|
-
return iterateSync(generatorFn.apply(this, args), options?.onYield);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
function quansync$1(input, options) {
|
|
90
|
-
if (isThenable(input)) return fromPromise(input);
|
|
91
|
-
if (typeof input === "function") return fromGeneratorFn(input, options);
|
|
92
|
-
else return fromObject(input);
|
|
93
|
-
}
|
|
94
|
-
const getIsAsync = quansync$1({
|
|
95
|
-
async: () => Promise.resolve(true),
|
|
96
|
-
sync: () => false
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
//#endregion
|
|
100
|
-
//#region node_modules/.pnpm/quansync@0.2.11/node_modules/quansync/dist/macro.mjs
|
|
101
|
-
const quansync = quansync$1;
|
|
102
|
-
|
|
103
|
-
//#endregion
|
|
104
|
-
//#region node_modules/.pnpm/local-pkg@1.1.2/node_modules/local-pkg/dist/index.mjs
|
|
105
|
-
const toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
|
|
106
|
-
async function findUp$1(name, { cwd: cwd$1 = process$1.cwd(), type: type$1 = "file", stopAt } = {}) {
|
|
107
|
-
let directory = path.resolve(toPath(cwd$1) ?? "");
|
|
108
|
-
const { root } = path.parse(directory);
|
|
109
|
-
stopAt = path.resolve(directory, toPath(stopAt ?? root));
|
|
110
|
-
const isAbsoluteName = path.isAbsolute(name);
|
|
111
|
-
while (directory) {
|
|
112
|
-
const filePath = isAbsoluteName ? name : path.join(directory, name);
|
|
113
|
-
try {
|
|
114
|
-
const stats = await fsp.stat(filePath);
|
|
115
|
-
if (type$1 === "file" && stats.isFile() || type$1 === "directory" && stats.isDirectory()) return filePath;
|
|
116
|
-
} catch {}
|
|
117
|
-
if (directory === stopAt || directory === root) break;
|
|
118
|
-
directory = path.dirname(directory);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
function findUpSync(name, { cwd: cwd$1 = process$1.cwd(), type: type$1 = "file", stopAt } = {}) {
|
|
122
|
-
let directory = path.resolve(toPath(cwd$1) ?? "");
|
|
123
|
-
const { root } = path.parse(directory);
|
|
124
|
-
stopAt = path.resolve(directory, toPath(stopAt) ?? root);
|
|
125
|
-
const isAbsoluteName = path.isAbsolute(name);
|
|
126
|
-
while (directory) {
|
|
127
|
-
const filePath = isAbsoluteName ? name : path.join(directory, name);
|
|
128
|
-
try {
|
|
129
|
-
const stats = fs.statSync(filePath, { throwIfNoEntry: false });
|
|
130
|
-
if (type$1 === "file" && stats?.isFile() || type$1 === "directory" && stats?.isDirectory()) return filePath;
|
|
131
|
-
} catch {}
|
|
132
|
-
if (directory === stopAt || directory === root) break;
|
|
133
|
-
directory = path.dirname(directory);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
function _resolve(path$1, options = {}) {
|
|
137
|
-
if (options.platform === "auto" || !options.platform) options.platform = process$1.platform === "win32" ? "win32" : "posix";
|
|
138
|
-
if (process$1.versions.pnp) {
|
|
139
|
-
const paths = options.paths || [];
|
|
140
|
-
if (paths.length === 0) paths.push(process$1.cwd());
|
|
141
|
-
const targetRequire = createRequire(import.meta.url);
|
|
142
|
-
try {
|
|
143
|
-
return targetRequire.resolve(path$1, { paths });
|
|
144
|
-
} catch {}
|
|
145
|
-
}
|
|
146
|
-
const modulePath = resolvePathSync(path$1, { url: options.paths });
|
|
147
|
-
if (options.platform === "win32") return win32.normalize(modulePath);
|
|
148
|
-
return modulePath;
|
|
149
|
-
}
|
|
150
|
-
function resolveModule(name, options = {}) {
|
|
151
|
-
try {
|
|
152
|
-
return _resolve(name, options);
|
|
153
|
-
} catch {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
function getPackageJsonPath(name, options = {}) {
|
|
158
|
-
const entry = resolvePackage(name, options);
|
|
159
|
-
if (!entry) return;
|
|
160
|
-
return searchPackageJSON(entry);
|
|
161
|
-
}
|
|
162
|
-
const readFile$1 = quansync({
|
|
163
|
-
async: (id) => fs.promises.readFile(id, "utf8"),
|
|
164
|
-
sync: (id) => fs.readFileSync(id, "utf8")
|
|
165
|
-
});
|
|
166
|
-
const getPackageInfo = quansync(function* (name, options = {}) {
|
|
167
|
-
const packageJsonPath = getPackageJsonPath(name, options);
|
|
168
|
-
if (!packageJsonPath) return;
|
|
169
|
-
const packageJson = JSON.parse(yield readFile$1(packageJsonPath));
|
|
170
|
-
return {
|
|
171
|
-
name,
|
|
172
|
-
version: packageJson.version,
|
|
173
|
-
rootPath: dirname(packageJsonPath),
|
|
174
|
-
packageJsonPath,
|
|
175
|
-
packageJson
|
|
176
|
-
};
|
|
177
|
-
});
|
|
178
|
-
const getPackageInfoSync = getPackageInfo.sync;
|
|
179
|
-
function resolvePackage(name, options = {}) {
|
|
180
|
-
try {
|
|
181
|
-
return _resolve(`${name}/package.json`, options);
|
|
182
|
-
} catch {}
|
|
183
|
-
try {
|
|
184
|
-
return _resolve(name, options);
|
|
185
|
-
} catch (e) {
|
|
186
|
-
if (e.code !== "MODULE_NOT_FOUND" && e.code !== "ERR_MODULE_NOT_FOUND") console.error(e);
|
|
187
|
-
return false;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
function searchPackageJSON(dir) {
|
|
191
|
-
let packageJsonPath;
|
|
192
|
-
while (true) {
|
|
193
|
-
if (!dir) return;
|
|
194
|
-
const newDir = dirname(dir);
|
|
195
|
-
if (newDir === dir) return;
|
|
196
|
-
dir = newDir;
|
|
197
|
-
packageJsonPath = join(dir, "package.json");
|
|
198
|
-
if (fs.existsSync(packageJsonPath)) break;
|
|
199
|
-
}
|
|
200
|
-
return packageJsonPath;
|
|
201
|
-
}
|
|
202
|
-
const findUp = quansync({
|
|
203
|
-
sync: findUpSync,
|
|
204
|
-
async: findUp$1
|
|
205
|
-
});
|
|
206
|
-
const loadPackageJSON = quansync(function* (cwd$1 = process$1.cwd()) {
|
|
207
|
-
const path$1 = yield findUp("package.json", { cwd: cwd$1 });
|
|
208
|
-
if (!path$1 || !fs.existsSync(path$1)) return null;
|
|
209
|
-
return JSON.parse(yield readFile$1(path$1));
|
|
210
|
-
});
|
|
211
|
-
const loadPackageJSONSync = loadPackageJSON.sync;
|
|
212
|
-
const isPackageListed = quansync(function* (name, cwd$1) {
|
|
213
|
-
const pkg = (yield loadPackageJSON(cwd$1)) || {};
|
|
214
|
-
return name in (pkg.dependencies || {}) || name in (pkg.devDependencies || {});
|
|
215
|
-
});
|
|
216
|
-
const isPackageListedSync = isPackageListed.sync;
|
|
217
|
-
|
|
218
|
-
//#endregion
|
|
219
|
-
//#region node_modules/.pnpm/unimport@5.6.0/node_modules/unimport/dist/shared/unimport.u_OYhQoS.mjs
|
|
220
|
-
var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch(), 1);
|
|
221
|
-
const version = "5.6.0";
|
|
222
|
-
function configureAddons(opts) {
|
|
223
|
-
const addons = [];
|
|
224
|
-
if (Array.isArray(opts.addons)) addons.push(...opts.addons);
|
|
225
|
-
else {
|
|
226
|
-
const addonsMap = /* @__PURE__ */ new Map();
|
|
227
|
-
if (opts.addons?.addons?.length) {
|
|
228
|
-
let i = 0;
|
|
229
|
-
for (const addon of opts.addons.addons) addonsMap.set(addon.name || `external:custom-${i++}`, addon);
|
|
230
|
-
}
|
|
231
|
-
if (opts.addons?.vueTemplate) {
|
|
232
|
-
if (!addonsMap.has(VUE_TEMPLATE_NAME)) addonsMap.set(VUE_TEMPLATE_NAME, vueTemplateAddon());
|
|
233
|
-
}
|
|
234
|
-
if (opts.addons?.vueDirectives) {
|
|
235
|
-
if (!addonsMap.has(VUE_DIRECTIVES_NAME)) addonsMap.set(VUE_DIRECTIVES_NAME, vueDirectivesAddon(typeof opts.addons.vueDirectives === "object" ? opts.addons.vueDirectives : void 0));
|
|
236
|
-
}
|
|
237
|
-
addons.push(...addonsMap.values());
|
|
238
|
-
}
|
|
239
|
-
return addons;
|
|
240
|
-
}
|
|
241
|
-
async function detectImportsRegex(code, ctx, options) {
|
|
242
|
-
const s = getMagicString(code);
|
|
243
|
-
const original = s.original;
|
|
244
|
-
const strippedCode = stripCommentsAndStrings(original, options?.transformVirtualImports !== false && ctx.options.virtualImports?.length ? {
|
|
245
|
-
filter: (i) => !ctx.options.virtualImports.includes(i),
|
|
246
|
-
fillChar: "-"
|
|
247
|
-
} : void 0);
|
|
248
|
-
const syntax = detectSyntax(strippedCode);
|
|
249
|
-
const isCJSContext = syntax.hasCJS && !syntax.hasESM;
|
|
250
|
-
let matchedImports = [];
|
|
251
|
-
const occurrenceMap = /* @__PURE__ */ new Map();
|
|
252
|
-
const map = await ctx.getImportMap();
|
|
253
|
-
if (options?.autoImport !== false) {
|
|
254
|
-
Array.from(strippedCode.matchAll(matchRE)).forEach((i) => {
|
|
255
|
-
if (i[1] === ".") return null;
|
|
256
|
-
const end = strippedCode[i.index + i[0].length];
|
|
257
|
-
const before = strippedCode[i.index - 1];
|
|
258
|
-
if (end === ":" && !["?", "case"].includes(i[1].trim()) && before !== ":") return null;
|
|
259
|
-
const name = i[2];
|
|
260
|
-
const occurrence = i.index + i[1].length;
|
|
261
|
-
if (occurrenceMap.get(name) || Number.POSITIVE_INFINITY > occurrence) occurrenceMap.set(name, occurrence);
|
|
262
|
-
});
|
|
263
|
-
for (const regex of excludeRE) for (const match of strippedCode.matchAll(regex)) {
|
|
264
|
-
const segments = [...match[1]?.split(separatorRE) || [], ...match[2]?.split(separatorRE) || []];
|
|
265
|
-
for (const segment of segments) {
|
|
266
|
-
const identifier = segment.replace(importAsRE, "").trim();
|
|
267
|
-
occurrenceMap.delete(identifier);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
const identifiers = new Set(occurrenceMap.keys());
|
|
271
|
-
matchedImports = Array.from(identifiers).map((name) => {
|
|
272
|
-
const item = map.get(name);
|
|
273
|
-
if (item && !item.disabled) return item;
|
|
274
|
-
occurrenceMap.delete(name);
|
|
275
|
-
return null;
|
|
276
|
-
}).filter(Boolean);
|
|
277
|
-
for (const addon of ctx.addons) matchedImports = await addon.matchImports?.call(ctx, identifiers, matchedImports) || matchedImports;
|
|
278
|
-
}
|
|
279
|
-
if (options?.transformVirtualImports !== false && ctx.options.virtualImports?.length) {
|
|
280
|
-
const virtualImports = parseVirtualImportsRegex(strippedCode, map, ctx.options.virtualImports);
|
|
281
|
-
virtualImports.ranges.forEach(([start, end]) => {
|
|
282
|
-
s.remove(start, end);
|
|
283
|
-
});
|
|
284
|
-
matchedImports.push(...virtualImports.imports);
|
|
285
|
-
}
|
|
286
|
-
const firstOccurrence = Math.min(...Array.from(occurrenceMap.entries()).map((i) => i[1]));
|
|
287
|
-
return {
|
|
288
|
-
s,
|
|
289
|
-
strippedCode,
|
|
290
|
-
isCJSContext,
|
|
291
|
-
matchedImports,
|
|
292
|
-
firstOccurrence
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
function parseVirtualImportsRegex(strippedCode, importMap, virtualImports) {
|
|
296
|
-
const imports = [];
|
|
297
|
-
const ranges = [];
|
|
298
|
-
if (virtualImports?.length) findStaticImports(strippedCode).filter((i) => virtualImports.includes(i.specifier)).map((i) => parseStaticImport(i)).forEach((i) => {
|
|
299
|
-
ranges.push([i.start, i.end]);
|
|
300
|
-
Object.entries(i.namedImports || {}).forEach(([name, as]) => {
|
|
301
|
-
const original = importMap.get(name);
|
|
302
|
-
if (!original) throw new Error(`[unimport] failed to find "${name}" imported from "${i.specifier}"`);
|
|
303
|
-
imports.push({
|
|
304
|
-
from: original.from,
|
|
305
|
-
name: original.name,
|
|
306
|
-
as
|
|
307
|
-
});
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
return {
|
|
311
|
-
imports,
|
|
312
|
-
ranges
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
async function detectImports(code, ctx, options) {
|
|
316
|
-
if (options?.parser === "acorn") return import("./estree-walker+unimport.mjs").then((r) => r.detectImportsAcorn(code, ctx, options));
|
|
317
|
-
return detectImportsRegex(code, ctx, options);
|
|
318
|
-
}
|
|
319
|
-
const FileExtensionLookup = [
|
|
320
|
-
"mts",
|
|
321
|
-
"cts",
|
|
322
|
-
"ts",
|
|
323
|
-
"tsx",
|
|
324
|
-
"mjs",
|
|
325
|
-
"cjs",
|
|
326
|
-
"js",
|
|
327
|
-
"jsx"
|
|
328
|
-
];
|
|
329
|
-
const FileLookupPatterns = `*.{${FileExtensionLookup.join(",")}}`;
|
|
330
|
-
function resolveGlobsExclude(glob2, cwd$1) {
|
|
331
|
-
return `${glob2.startsWith("!") ? "!" : ""}${resolve$1(cwd$1, glob2.replace(/^!/, ""))}`;
|
|
332
|
-
}
|
|
333
|
-
function joinGlobFilePattern(glob2, filePattern) {
|
|
334
|
-
return join$1(basename$1(glob2) === "*" ? dirname$1(glob2) : glob2, filePattern);
|
|
335
|
-
}
|
|
336
|
-
function normalizeScanDirs(dirs, options) {
|
|
337
|
-
const topLevelTypes = options?.types ?? true;
|
|
338
|
-
const cwd$1 = options?.cwd ?? process$1.cwd();
|
|
339
|
-
const filePatterns = options?.filePatterns || [FileLookupPatterns];
|
|
340
|
-
return dirs.map((dir) => {
|
|
341
|
-
const isString = typeof dir === "string";
|
|
342
|
-
const glob2 = resolveGlobsExclude(isString ? dir : dir.glob, cwd$1);
|
|
343
|
-
const types = isString ? topLevelTypes : dir.types ?? topLevelTypes;
|
|
344
|
-
if (glob2.match(/\.\w+$/)) return {
|
|
345
|
-
glob: glob2,
|
|
346
|
-
types
|
|
347
|
-
};
|
|
348
|
-
const withFilePatterns = filePatterns.map((filePattern) => ({
|
|
349
|
-
glob: joinGlobFilePattern(glob2, filePattern),
|
|
350
|
-
types
|
|
351
|
-
}));
|
|
352
|
-
return [{
|
|
353
|
-
glob: glob2,
|
|
354
|
-
types
|
|
355
|
-
}, ...withFilePatterns];
|
|
356
|
-
}).flat();
|
|
357
|
-
}
|
|
358
|
-
async function scanFilesFromDir(dir, options) {
|
|
359
|
-
const dirGlobs = (Array.isArray(dir) ? dir : [dir]).map((i) => i.glob);
|
|
360
|
-
const files = (await glob(dirGlobs, {
|
|
361
|
-
absolute: true,
|
|
362
|
-
cwd: options?.cwd || process$1.cwd(),
|
|
363
|
-
onlyFiles: true,
|
|
364
|
-
followSymbolicLinks: true,
|
|
365
|
-
expandDirectories: false
|
|
366
|
-
})).map((i) => normalize$1(i));
|
|
367
|
-
const fileFilter = options?.fileFilter || (() => true);
|
|
368
|
-
const indexOfDirs = (file) => dirGlobs.findIndex((glob2) => import_picomatch.default.isMatch(file, glob2));
|
|
369
|
-
return files.reduce((acc, file) => {
|
|
370
|
-
const index = indexOfDirs(file);
|
|
371
|
-
if (acc[index]) acc[index].push(normalize$1(file));
|
|
372
|
-
else acc[index] = [normalize$1(file)];
|
|
373
|
-
return acc;
|
|
374
|
-
}, []).map((files2) => files2.sort()).flat().filter(fileFilter);
|
|
375
|
-
}
|
|
376
|
-
async function scanDirExports(dirs, options) {
|
|
377
|
-
const normalizedDirs = normalizeScanDirs(dirs, options);
|
|
378
|
-
const files = await scanFilesFromDir(normalizedDirs, options);
|
|
379
|
-
const includeTypesDirs = normalizedDirs.filter((dir) => !dir.glob.startsWith("!") && dir.types);
|
|
380
|
-
const isIncludeTypes = (file) => includeTypesDirs.some((dir) => import_picomatch.default.isMatch(file, dir.glob));
|
|
381
|
-
return dedupeDtsExports((await Promise.all(files.map((file) => scanExports(file, isIncludeTypes(file))))).flat());
|
|
382
|
-
}
|
|
383
|
-
function dedupeDtsExports(exports) {
|
|
384
|
-
return exports.filter((i) => {
|
|
385
|
-
if (!i.type) return true;
|
|
386
|
-
if (i.declarationType === "enum" || i.declarationType === "const enum" || i.declarationType === "class") return true;
|
|
387
|
-
return !exports.find((e) => e.as === i.as && e.name === i.name && !e.type);
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
async function scanExports(filepath, includeTypes, seen = /* @__PURE__ */ new Set()) {
|
|
391
|
-
if (seen.has(filepath)) {
|
|
392
|
-
console.warn(`[unimport] "${filepath}" is already scanned, skipping`);
|
|
393
|
-
return [];
|
|
394
|
-
}
|
|
395
|
-
seen.add(filepath);
|
|
396
|
-
const imports = [];
|
|
397
|
-
const code = await readFile(filepath, "utf-8");
|
|
398
|
-
const exports = findExports(code);
|
|
399
|
-
if (exports.find((i) => i.type === "default")) {
|
|
400
|
-
let name = parse(filepath).name;
|
|
401
|
-
if (name === "index") name = parse(filepath.split("/").slice(0, -1).join("/")).name;
|
|
402
|
-
const as = /[-_.]/.test(name) ? camelCase(name) : name;
|
|
403
|
-
imports.push({
|
|
404
|
-
name: "default",
|
|
405
|
-
as,
|
|
406
|
-
from: filepath
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
async function toImport(exports2, additional) {
|
|
410
|
-
for (const exp of exports2) if (exp.type === "named") for (const name of exp.names) imports.push({
|
|
411
|
-
name,
|
|
412
|
-
as: name,
|
|
413
|
-
from: filepath,
|
|
414
|
-
...additional
|
|
415
|
-
});
|
|
416
|
-
else if (exp.type === "declaration") {
|
|
417
|
-
if (exp.name) {
|
|
418
|
-
imports.push({
|
|
419
|
-
name: exp.name,
|
|
420
|
-
as: exp.name,
|
|
421
|
-
from: filepath,
|
|
422
|
-
...additional
|
|
423
|
-
});
|
|
424
|
-
if (exp.declarationType === "enum" || exp.declarationType === "const enum" || exp.declarationType === "class") imports.push({
|
|
425
|
-
name: exp.name,
|
|
426
|
-
as: exp.name,
|
|
427
|
-
from: filepath,
|
|
428
|
-
type: true,
|
|
429
|
-
declarationType: exp.declarationType,
|
|
430
|
-
...additional
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
} else if (exp.type === "star" && exp.specifier) if (exp.name) imports.push({
|
|
434
|
-
name: exp.name,
|
|
435
|
-
as: exp.name,
|
|
436
|
-
from: filepath,
|
|
437
|
-
...additional
|
|
438
|
-
});
|
|
439
|
-
else {
|
|
440
|
-
const subfile = exp.specifier;
|
|
441
|
-
let subfilepath = resolve$1(dirname$1(filepath), subfile);
|
|
442
|
-
let subfilepathResolved = false;
|
|
443
|
-
for (const ext of FileExtensionLookup) if (existsSync(`${subfilepath}.${ext}`)) {
|
|
444
|
-
subfilepath = `${subfilepath}.${ext}`;
|
|
445
|
-
break;
|
|
446
|
-
} else if (existsSync(`${subfilepath}/index.${ext}`)) {
|
|
447
|
-
subfilepath = `${subfilepath}/index.${ext}`;
|
|
448
|
-
break;
|
|
449
|
-
}
|
|
450
|
-
if (existsSync(subfilepath)) subfilepathResolved = true;
|
|
451
|
-
else try {
|
|
452
|
-
subfilepath = await resolve$2(exp.specifier);
|
|
453
|
-
subfilepath = normalize$1(fileURLToPath(subfilepath));
|
|
454
|
-
if (existsSync(subfilepath)) subfilepathResolved = true;
|
|
455
|
-
} catch {}
|
|
456
|
-
if (!subfilepathResolved) {
|
|
457
|
-
console.warn(`[unimport] failed to resolve "${subfilepath}", skip scanning`);
|
|
458
|
-
continue;
|
|
459
|
-
}
|
|
460
|
-
const nested = await scanExports(subfilepath, includeTypes, seen);
|
|
461
|
-
imports.push(...additional ? nested.map((i) => ({
|
|
462
|
-
...i,
|
|
463
|
-
...additional
|
|
464
|
-
})) : nested);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
if (filepath.match(/\.d\.[mc]?ts$/)) {
|
|
468
|
-
if (includeTypes) {
|
|
469
|
-
await toImport(exports, { type: true });
|
|
470
|
-
await toImport(findTypeExports(code), { type: true });
|
|
471
|
-
}
|
|
472
|
-
} else {
|
|
473
|
-
await toImport(exports);
|
|
474
|
-
if (includeTypes) await toImport(findTypeExports(code), { type: true });
|
|
475
|
-
}
|
|
476
|
-
return imports;
|
|
477
|
-
}
|
|
478
|
-
const CACHE_PATH = /* @__PURE__ */ join$1(os.tmpdir(), "unimport");
|
|
479
|
-
let CACHE_WRITEABLE;
|
|
480
|
-
async function resolvePackagePreset(preset) {
|
|
481
|
-
return (await extractExports(preset.package, preset.url, preset.cache)).filter((name) => {
|
|
482
|
-
for (const item of preset.ignore || []) {
|
|
483
|
-
if (typeof item === "string" && item === name) return false;
|
|
484
|
-
if (item instanceof RegExp && item.test(name)) return false;
|
|
485
|
-
if (typeof item === "function" && item(name) === false) return false;
|
|
486
|
-
}
|
|
487
|
-
return true;
|
|
488
|
-
}).map((name) => ({
|
|
489
|
-
from: preset.package,
|
|
490
|
-
name
|
|
491
|
-
}));
|
|
492
|
-
}
|
|
493
|
-
async function extractExports(name, url, cache = true) {
|
|
494
|
-
const version$1 = (await readPackageJSON(await resolvePackageJSON(name, { url }))).version;
|
|
495
|
-
const cachePath = join$1(CACHE_PATH, `${name}@${version$1}`, "exports.json");
|
|
496
|
-
if (cache && CACHE_WRITEABLE === void 0) try {
|
|
497
|
-
CACHE_WRITEABLE = isWritable(CACHE_PATH);
|
|
498
|
-
} catch {
|
|
499
|
-
CACHE_WRITEABLE = false;
|
|
500
|
-
}
|
|
501
|
-
const useCache = cache && version$1 && CACHE_WRITEABLE;
|
|
502
|
-
if (useCache && existsSync(cachePath)) return JSON.parse(await promises.readFile(cachePath, "utf-8"));
|
|
503
|
-
const scanned = await resolveModuleExportNames(name, { url });
|
|
504
|
-
if (useCache) {
|
|
505
|
-
await promises.mkdir(dirname$1(cachePath), { recursive: true });
|
|
506
|
-
await promises.writeFile(cachePath, JSON.stringify(scanned), "utf-8");
|
|
507
|
-
}
|
|
508
|
-
return scanned;
|
|
509
|
-
}
|
|
510
|
-
function isWritable(filename) {
|
|
511
|
-
try {
|
|
512
|
-
accessSync(filename, constants.W_OK);
|
|
513
|
-
return true;
|
|
514
|
-
} catch {
|
|
515
|
-
return false;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
const dateFns = defineUnimportPreset({
|
|
519
|
-
from: "date-fns",
|
|
520
|
-
imports: [
|
|
521
|
-
"add",
|
|
522
|
-
"addBusinessDays",
|
|
523
|
-
"addDays",
|
|
524
|
-
"addHours",
|
|
525
|
-
"addISOWeekYears",
|
|
526
|
-
"addMilliseconds",
|
|
527
|
-
"addMinutes",
|
|
528
|
-
"addMonths",
|
|
529
|
-
"addQuarters",
|
|
530
|
-
"addSeconds",
|
|
531
|
-
"addWeeks",
|
|
532
|
-
"addYears",
|
|
533
|
-
"areIntervalsOverlapping",
|
|
534
|
-
"clamp",
|
|
535
|
-
"closestIndexTo",
|
|
536
|
-
"closestTo",
|
|
537
|
-
"compareAsc",
|
|
538
|
-
"compareDesc",
|
|
539
|
-
"constants",
|
|
540
|
-
"daysToWeeks",
|
|
541
|
-
"differenceInBusinessDays",
|
|
542
|
-
"differenceInCalendarDays",
|
|
543
|
-
"differenceInCalendarISOWeekYears",
|
|
544
|
-
"differenceInCalendarISOWeeks",
|
|
545
|
-
"differenceInCalendarMonths",
|
|
546
|
-
"differenceInCalendarQuarters",
|
|
547
|
-
"differenceInCalendarWeeks",
|
|
548
|
-
"differenceInCalendarYears",
|
|
549
|
-
"differenceInDays",
|
|
550
|
-
"differenceInHours",
|
|
551
|
-
"differenceInISOWeekYears",
|
|
552
|
-
"differenceInMilliseconds",
|
|
553
|
-
"differenceInMinutes",
|
|
554
|
-
"differenceInMonths",
|
|
555
|
-
"differenceInQuarters",
|
|
556
|
-
"differenceInSeconds",
|
|
557
|
-
"differenceInWeeks",
|
|
558
|
-
"differenceInYears",
|
|
559
|
-
"eachDayOfInterval",
|
|
560
|
-
"eachHourOfInterval",
|
|
561
|
-
"eachMinuteOfInterval",
|
|
562
|
-
"eachMonthOfInterval",
|
|
563
|
-
"eachQuarterOfInterval",
|
|
564
|
-
"eachWeekOfInterval",
|
|
565
|
-
"eachWeekendOfInterval",
|
|
566
|
-
"eachWeekendOfMonth",
|
|
567
|
-
"eachWeekendOfYear",
|
|
568
|
-
"eachYearOfInterval",
|
|
569
|
-
"endOfDay",
|
|
570
|
-
"endOfDecade",
|
|
571
|
-
"endOfHour",
|
|
572
|
-
"endOfISOWeek",
|
|
573
|
-
"endOfISOWeekYear",
|
|
574
|
-
"endOfMinute",
|
|
575
|
-
"endOfMonth",
|
|
576
|
-
"endOfQuarter",
|
|
577
|
-
"endOfSecond",
|
|
578
|
-
"endOfToday",
|
|
579
|
-
"endOfTomorrow",
|
|
580
|
-
"endOfWeek",
|
|
581
|
-
"endOfYear",
|
|
582
|
-
"endOfYesterday",
|
|
583
|
-
"format",
|
|
584
|
-
"formatDistance",
|
|
585
|
-
"formatDistanceStrict",
|
|
586
|
-
"formatDistanceToNow",
|
|
587
|
-
"formatDistanceToNowStrict",
|
|
588
|
-
"formatDuration",
|
|
589
|
-
"formatISO",
|
|
590
|
-
"formatISO9075",
|
|
591
|
-
"formatISODuration",
|
|
592
|
-
"formatRFC3339",
|
|
593
|
-
"formatRFC7231",
|
|
594
|
-
"formatRelative",
|
|
595
|
-
"fromUnixTime",
|
|
596
|
-
"getDate",
|
|
597
|
-
"getDay",
|
|
598
|
-
"getDayOfYear",
|
|
599
|
-
"getDaysInMonth",
|
|
600
|
-
"getDaysInYear",
|
|
601
|
-
"getDecade",
|
|
602
|
-
"getDefaultOptions",
|
|
603
|
-
"getHours",
|
|
604
|
-
"getISODay",
|
|
605
|
-
"getISOWeek",
|
|
606
|
-
"getISOWeekYear",
|
|
607
|
-
"getISOWeeksInYear",
|
|
608
|
-
"getMilliseconds",
|
|
609
|
-
"getMinutes",
|
|
610
|
-
"getMonth",
|
|
611
|
-
"getOverlappingDaysInIntervals",
|
|
612
|
-
"getQuarter",
|
|
613
|
-
"getSeconds",
|
|
614
|
-
"getTime",
|
|
615
|
-
"getUnixTime",
|
|
616
|
-
"getWeek",
|
|
617
|
-
"getWeekOfMonth",
|
|
618
|
-
"getWeekYear",
|
|
619
|
-
"getWeeksInMonth",
|
|
620
|
-
"getYear",
|
|
621
|
-
"hoursToMilliseconds",
|
|
622
|
-
"hoursToMinutes",
|
|
623
|
-
"hoursToSeconds",
|
|
624
|
-
"intervalToDuration",
|
|
625
|
-
"intlFormat",
|
|
626
|
-
"intlFormatDistance",
|
|
627
|
-
"isAfter",
|
|
628
|
-
"isBefore",
|
|
629
|
-
"isDate",
|
|
630
|
-
"isEqual",
|
|
631
|
-
"isExists",
|
|
632
|
-
"isFirstDayOfMonth",
|
|
633
|
-
"isFriday",
|
|
634
|
-
"isFuture",
|
|
635
|
-
"isLastDayOfMonth",
|
|
636
|
-
"isLeapYear",
|
|
637
|
-
"isMatch",
|
|
638
|
-
"isMonday",
|
|
639
|
-
"isPast",
|
|
640
|
-
"isSameDay",
|
|
641
|
-
"isSameHour",
|
|
642
|
-
"isSameISOWeek",
|
|
643
|
-
"isSameISOWeekYear",
|
|
644
|
-
"isSameMinute",
|
|
645
|
-
"isSameMonth",
|
|
646
|
-
"isSameQuarter",
|
|
647
|
-
"isSameSecond",
|
|
648
|
-
"isSameWeek",
|
|
649
|
-
"isSameYear",
|
|
650
|
-
"isSaturday",
|
|
651
|
-
"isSunday",
|
|
652
|
-
"isThisHour",
|
|
653
|
-
"isThisISOWeek",
|
|
654
|
-
"isThisMinute",
|
|
655
|
-
"isThisMonth",
|
|
656
|
-
"isThisQuarter",
|
|
657
|
-
"isThisSecond",
|
|
658
|
-
"isThisWeek",
|
|
659
|
-
"isThisYear",
|
|
660
|
-
"isThursday",
|
|
661
|
-
"isToday",
|
|
662
|
-
"isTomorrow",
|
|
663
|
-
"isTuesday",
|
|
664
|
-
"isValid",
|
|
665
|
-
"isWednesday",
|
|
666
|
-
"isWeekend",
|
|
667
|
-
"isWithinInterval",
|
|
668
|
-
"isYesterday",
|
|
669
|
-
"lastDayOfDecade",
|
|
670
|
-
"lastDayOfISOWeek",
|
|
671
|
-
"lastDayOfISOWeekYear",
|
|
672
|
-
"lastDayOfMonth",
|
|
673
|
-
"lastDayOfQuarter",
|
|
674
|
-
"lastDayOfWeek",
|
|
675
|
-
"lastDayOfYear",
|
|
676
|
-
"lightFormat",
|
|
677
|
-
"max",
|
|
678
|
-
"milliseconds",
|
|
679
|
-
"millisecondsToHours",
|
|
680
|
-
"millisecondsToMinutes",
|
|
681
|
-
"millisecondsToSeconds",
|
|
682
|
-
"min",
|
|
683
|
-
"minutesToHours",
|
|
684
|
-
"minutesToMilliseconds",
|
|
685
|
-
"minutesToSeconds",
|
|
686
|
-
"monthsToQuarters",
|
|
687
|
-
"monthsToYears",
|
|
688
|
-
"nextDay",
|
|
689
|
-
"nextFriday",
|
|
690
|
-
"nextMonday",
|
|
691
|
-
"nextSaturday",
|
|
692
|
-
"nextSunday",
|
|
693
|
-
"nextThursday",
|
|
694
|
-
"nextTuesday",
|
|
695
|
-
"nextWednesday",
|
|
696
|
-
"parse",
|
|
697
|
-
"parseISO",
|
|
698
|
-
"parseJSON",
|
|
699
|
-
"previousDay",
|
|
700
|
-
"previousFriday",
|
|
701
|
-
"previousMonday",
|
|
702
|
-
"previousSaturday",
|
|
703
|
-
"previousSunday",
|
|
704
|
-
"previousThursday",
|
|
705
|
-
"previousTuesday",
|
|
706
|
-
"previousWednesday",
|
|
707
|
-
"quartersToMonths",
|
|
708
|
-
"quartersToYears",
|
|
709
|
-
"roundToNearestMinutes",
|
|
710
|
-
"secondsToHours",
|
|
711
|
-
"secondsToMilliseconds",
|
|
712
|
-
"secondsToMinutes",
|
|
713
|
-
"set",
|
|
714
|
-
"setDate",
|
|
715
|
-
"setDay",
|
|
716
|
-
"setDayOfYear",
|
|
717
|
-
"setDefaultOptions",
|
|
718
|
-
"setHours",
|
|
719
|
-
"setISODay",
|
|
720
|
-
"setISOWeek",
|
|
721
|
-
"setISOWeekYear",
|
|
722
|
-
"setMilliseconds",
|
|
723
|
-
"setMinutes",
|
|
724
|
-
"setMonth",
|
|
725
|
-
"setQuarter",
|
|
726
|
-
"setSeconds",
|
|
727
|
-
"setWeek",
|
|
728
|
-
"setWeekYear",
|
|
729
|
-
"setYear",
|
|
730
|
-
"startOfDay",
|
|
731
|
-
"startOfDecade",
|
|
732
|
-
"startOfHour",
|
|
733
|
-
"startOfISOWeek",
|
|
734
|
-
"startOfISOWeekYear",
|
|
735
|
-
"startOfMinute",
|
|
736
|
-
"startOfMonth",
|
|
737
|
-
"startOfQuarter",
|
|
738
|
-
"startOfSecond",
|
|
739
|
-
"startOfToday",
|
|
740
|
-
"startOfTomorrow",
|
|
741
|
-
"startOfWeek",
|
|
742
|
-
"startOfWeekYear",
|
|
743
|
-
"startOfYear",
|
|
744
|
-
"startOfYesterday",
|
|
745
|
-
"sub",
|
|
746
|
-
"subBusinessDays",
|
|
747
|
-
"subDays",
|
|
748
|
-
"subHours",
|
|
749
|
-
"subISOWeekYears",
|
|
750
|
-
"subMilliseconds",
|
|
751
|
-
"subMinutes",
|
|
752
|
-
"subMonths",
|
|
753
|
-
"subQuarters",
|
|
754
|
-
"subSeconds",
|
|
755
|
-
"subWeeks",
|
|
756
|
-
"subYears",
|
|
757
|
-
"toDate",
|
|
758
|
-
"weeksToDays",
|
|
759
|
-
"yearsToMonths",
|
|
760
|
-
"yearsToQuarters"
|
|
761
|
-
]
|
|
762
|
-
});
|
|
763
|
-
const pinia = defineUnimportPreset({
|
|
764
|
-
from: "pinia",
|
|
765
|
-
imports: [
|
|
766
|
-
"acceptHMRUpdate",
|
|
767
|
-
"createPinia",
|
|
768
|
-
"defineStore",
|
|
769
|
-
"getActivePinia",
|
|
770
|
-
"mapActions",
|
|
771
|
-
"mapGetters",
|
|
772
|
-
"mapState",
|
|
773
|
-
"mapStores",
|
|
774
|
-
"mapWritableState",
|
|
775
|
-
"setActivePinia",
|
|
776
|
-
"setMapStoreSuffix",
|
|
777
|
-
"storeToRefs"
|
|
778
|
-
]
|
|
779
|
-
});
|
|
780
|
-
const preact = defineUnimportPreset({
|
|
781
|
-
from: "preact",
|
|
782
|
-
imports: [
|
|
783
|
-
"useState",
|
|
784
|
-
"useCallback",
|
|
785
|
-
"useMemo",
|
|
786
|
-
"useEffect",
|
|
787
|
-
"useRef",
|
|
788
|
-
"useContext",
|
|
789
|
-
"useReducer"
|
|
790
|
-
]
|
|
791
|
-
});
|
|
792
|
-
const quasar = defineUnimportPreset({
|
|
793
|
-
from: "quasar",
|
|
794
|
-
imports: [
|
|
795
|
-
"useQuasar",
|
|
796
|
-
"useDialogPluginComponent",
|
|
797
|
-
"useFormChild",
|
|
798
|
-
"useMeta"
|
|
799
|
-
]
|
|
800
|
-
});
|
|
801
|
-
const react = defineUnimportPreset({
|
|
802
|
-
from: "react",
|
|
803
|
-
imports: [
|
|
804
|
-
"useState",
|
|
805
|
-
"useCallback",
|
|
806
|
-
"useMemo",
|
|
807
|
-
"useEffect",
|
|
808
|
-
"useRef",
|
|
809
|
-
"useContext",
|
|
810
|
-
"useReducer"
|
|
811
|
-
]
|
|
812
|
-
});
|
|
813
|
-
const ReactRouterHooks = [
|
|
814
|
-
"useOutletContext",
|
|
815
|
-
"useHref",
|
|
816
|
-
"useInRouterContext",
|
|
817
|
-
"useLocation",
|
|
818
|
-
"useNavigationType",
|
|
819
|
-
"useNavigate",
|
|
820
|
-
"useOutlet",
|
|
821
|
-
"useParams",
|
|
822
|
-
"useResolvedPath",
|
|
823
|
-
"useRoutes"
|
|
824
|
-
];
|
|
825
|
-
const reactRouter = defineUnimportPreset({
|
|
826
|
-
from: "react-router",
|
|
827
|
-
imports: [...ReactRouterHooks]
|
|
828
|
-
});
|
|
829
|
-
const reactRouterDom = defineUnimportPreset({
|
|
830
|
-
from: "react-router-dom",
|
|
831
|
-
imports: [
|
|
832
|
-
...ReactRouterHooks,
|
|
833
|
-
"useLinkClickHandler",
|
|
834
|
-
"useSearchParams",
|
|
835
|
-
"Link",
|
|
836
|
-
"NavLink",
|
|
837
|
-
"Navigate",
|
|
838
|
-
"Outlet",
|
|
839
|
-
"Route",
|
|
840
|
-
"Routes"
|
|
841
|
-
]
|
|
842
|
-
});
|
|
843
|
-
const rxjs = defineUnimportPreset({
|
|
844
|
-
from: "rxjs",
|
|
845
|
-
imports: [
|
|
846
|
-
"of",
|
|
847
|
-
"from",
|
|
848
|
-
"map",
|
|
849
|
-
"tap",
|
|
850
|
-
"filter",
|
|
851
|
-
"forkJoin",
|
|
852
|
-
"throwError",
|
|
853
|
-
"catchError",
|
|
854
|
-
"Observable",
|
|
855
|
-
"mergeMap",
|
|
856
|
-
"switchMap",
|
|
857
|
-
"merge",
|
|
858
|
-
"zip",
|
|
859
|
-
"take",
|
|
860
|
-
"takeUntil",
|
|
861
|
-
"first",
|
|
862
|
-
"lastValueFrom",
|
|
863
|
-
"skip",
|
|
864
|
-
"skipUntil",
|
|
865
|
-
"distinct",
|
|
866
|
-
"distinctUntilChanged",
|
|
867
|
-
"throttle",
|
|
868
|
-
"throttleTime",
|
|
869
|
-
"retry",
|
|
870
|
-
"retryWhen",
|
|
871
|
-
"timeout",
|
|
872
|
-
"delay",
|
|
873
|
-
"debounce",
|
|
874
|
-
"debounceTime",
|
|
875
|
-
"find",
|
|
876
|
-
"every"
|
|
877
|
-
]
|
|
878
|
-
});
|
|
879
|
-
const solid = defineUnimportPreset({
|
|
880
|
-
from: "solid-js",
|
|
881
|
-
imports: [
|
|
882
|
-
defineUnimportPreset({
|
|
883
|
-
from: "solid-js",
|
|
884
|
-
imports: [
|
|
885
|
-
"createSignal",
|
|
886
|
-
"createEffect",
|
|
887
|
-
"createMemo",
|
|
888
|
-
"createResource",
|
|
889
|
-
"onMount",
|
|
890
|
-
"onCleanup",
|
|
891
|
-
"onError",
|
|
892
|
-
"untrack",
|
|
893
|
-
"batch",
|
|
894
|
-
"on",
|
|
895
|
-
"createRoot",
|
|
896
|
-
"mergeProps",
|
|
897
|
-
"splitProps",
|
|
898
|
-
"useTransition",
|
|
899
|
-
"observable",
|
|
900
|
-
"mapArray",
|
|
901
|
-
"indexArray",
|
|
902
|
-
"createContext",
|
|
903
|
-
"useContext",
|
|
904
|
-
"children",
|
|
905
|
-
"lazy",
|
|
906
|
-
"createDeferred",
|
|
907
|
-
"createRenderEffect",
|
|
908
|
-
"createSelector",
|
|
909
|
-
"For",
|
|
910
|
-
"Show",
|
|
911
|
-
"Switch",
|
|
912
|
-
"Match",
|
|
913
|
-
"Index",
|
|
914
|
-
"ErrorBoundary",
|
|
915
|
-
"Suspense",
|
|
916
|
-
"SuspenseList"
|
|
917
|
-
]
|
|
918
|
-
}),
|
|
919
|
-
defineUnimportPreset({
|
|
920
|
-
from: "solid-js/store",
|
|
921
|
-
imports: [
|
|
922
|
-
"createStore",
|
|
923
|
-
"produce",
|
|
924
|
-
"reconcile",
|
|
925
|
-
"createMutable"
|
|
926
|
-
]
|
|
927
|
-
}),
|
|
928
|
-
defineUnimportPreset({
|
|
929
|
-
from: "solid-js/web",
|
|
930
|
-
imports: [
|
|
931
|
-
"Dynamic",
|
|
932
|
-
"hydrate",
|
|
933
|
-
"render",
|
|
934
|
-
"renderToString",
|
|
935
|
-
"renderToStringAsync",
|
|
936
|
-
"renderToStream",
|
|
937
|
-
"isServer",
|
|
938
|
-
"Portal"
|
|
939
|
-
]
|
|
940
|
-
})
|
|
941
|
-
]
|
|
942
|
-
});
|
|
943
|
-
const solidAppRouter = defineUnimportPreset({
|
|
944
|
-
from: "solid-app-router",
|
|
945
|
-
imports: [
|
|
946
|
-
"Link",
|
|
947
|
-
"NavLink",
|
|
948
|
-
"Navigate",
|
|
949
|
-
"Outlet",
|
|
950
|
-
"Route",
|
|
951
|
-
"Router",
|
|
952
|
-
"Routes",
|
|
953
|
-
"_mergeSearchString",
|
|
954
|
-
"createIntegration",
|
|
955
|
-
"hashIntegration",
|
|
956
|
-
"normalizeIntegration",
|
|
957
|
-
"pathIntegration",
|
|
958
|
-
"staticIntegration",
|
|
959
|
-
"useHref",
|
|
960
|
-
"useIsRouting",
|
|
961
|
-
"useLocation",
|
|
962
|
-
"useMatch",
|
|
963
|
-
"useNavigate",
|
|
964
|
-
"useParams",
|
|
965
|
-
"useResolvedPath",
|
|
966
|
-
"useRouteData",
|
|
967
|
-
"useRoutes",
|
|
968
|
-
"useSearchParams"
|
|
969
|
-
]
|
|
970
|
-
});
|
|
971
|
-
const svelteAnimate = defineUnimportPreset({
|
|
972
|
-
from: "svelte/animate",
|
|
973
|
-
imports: ["flip"]
|
|
974
|
-
});
|
|
975
|
-
const svelteEasing = defineUnimportPreset({
|
|
976
|
-
from: "svelte/easing",
|
|
977
|
-
imports: [
|
|
978
|
-
"back",
|
|
979
|
-
"bounce",
|
|
980
|
-
"circ",
|
|
981
|
-
"cubic",
|
|
982
|
-
"elastic",
|
|
983
|
-
"expo",
|
|
984
|
-
"quad",
|
|
985
|
-
"quart",
|
|
986
|
-
"quint",
|
|
987
|
-
"sine"
|
|
988
|
-
].reduce((acc, e) => {
|
|
989
|
-
acc.push(`${e}In`, `${e}Out`, `${e}InOut`);
|
|
990
|
-
return acc;
|
|
991
|
-
}, ["linear"])
|
|
992
|
-
});
|
|
993
|
-
const svelteStore = defineUnimportPreset({
|
|
994
|
-
from: "svelte/store",
|
|
995
|
-
imports: [
|
|
996
|
-
"writable",
|
|
997
|
-
"readable",
|
|
998
|
-
"derived",
|
|
999
|
-
"get"
|
|
1000
|
-
]
|
|
1001
|
-
});
|
|
1002
|
-
const svelteMotion = defineUnimportPreset({
|
|
1003
|
-
from: "svelte/motion",
|
|
1004
|
-
imports: ["tweened", "spring"]
|
|
1005
|
-
});
|
|
1006
|
-
const svelteTransition = defineUnimportPreset({
|
|
1007
|
-
from: "svelte/transition",
|
|
1008
|
-
imports: [
|
|
1009
|
-
"fade",
|
|
1010
|
-
"blur",
|
|
1011
|
-
"fly",
|
|
1012
|
-
"slide",
|
|
1013
|
-
"scale",
|
|
1014
|
-
"draw",
|
|
1015
|
-
"crossfade"
|
|
1016
|
-
]
|
|
1017
|
-
});
|
|
1018
|
-
const svelte = defineUnimportPreset({
|
|
1019
|
-
from: "svelte",
|
|
1020
|
-
imports: [
|
|
1021
|
-
"onMount",
|
|
1022
|
-
"beforeUpdate",
|
|
1023
|
-
"afterUpdate",
|
|
1024
|
-
"onDestroy",
|
|
1025
|
-
"tick",
|
|
1026
|
-
"setContext",
|
|
1027
|
-
"getContext",
|
|
1028
|
-
"hasContext",
|
|
1029
|
-
"getAllContexts",
|
|
1030
|
-
"createEventDispatcher"
|
|
1031
|
-
]
|
|
1032
|
-
});
|
|
1033
|
-
const uniApp = defineUnimportPreset({
|
|
1034
|
-
from: "@dcloudio/uni-app",
|
|
1035
|
-
imports: [
|
|
1036
|
-
"onAddToFavorites",
|
|
1037
|
-
"onBackPress",
|
|
1038
|
-
"onError",
|
|
1039
|
-
"onHide",
|
|
1040
|
-
"onLaunch",
|
|
1041
|
-
"onLoad",
|
|
1042
|
-
"onNavigationBarButtonTap",
|
|
1043
|
-
"onNavigationBarSearchInputChanged",
|
|
1044
|
-
"onNavigationBarSearchInputClicked",
|
|
1045
|
-
"onNavigationBarSearchInputConfirmed",
|
|
1046
|
-
"onNavigationBarSearchInputFocusChanged",
|
|
1047
|
-
"onPageNotFound",
|
|
1048
|
-
"onPageScroll",
|
|
1049
|
-
"onPullDownRefresh",
|
|
1050
|
-
"onReachBottom",
|
|
1051
|
-
"onReady",
|
|
1052
|
-
"onResize",
|
|
1053
|
-
"onShareAppMessage",
|
|
1054
|
-
"onShareTimeline",
|
|
1055
|
-
"onShow",
|
|
1056
|
-
"onTabItemTap",
|
|
1057
|
-
"onThemeChange",
|
|
1058
|
-
"onUnhandledRejection",
|
|
1059
|
-
"onUnload"
|
|
1060
|
-
]
|
|
1061
|
-
});
|
|
1062
|
-
const veeValidate = defineUnimportPreset({
|
|
1063
|
-
from: "vee-validate",
|
|
1064
|
-
imports: [
|
|
1065
|
-
"validate",
|
|
1066
|
-
"defineRule",
|
|
1067
|
-
"configure",
|
|
1068
|
-
"useField",
|
|
1069
|
-
"useForm",
|
|
1070
|
-
"useFieldArray",
|
|
1071
|
-
"useResetForm",
|
|
1072
|
-
"useIsFieldDirty",
|
|
1073
|
-
"useIsFieldTouched",
|
|
1074
|
-
"useIsFieldValid",
|
|
1075
|
-
"useIsSubmitting",
|
|
1076
|
-
"useValidateField",
|
|
1077
|
-
"useIsFormDirty",
|
|
1078
|
-
"useIsFormTouched",
|
|
1079
|
-
"useIsFormValid",
|
|
1080
|
-
"useValidateForm",
|
|
1081
|
-
"useSubmitCount",
|
|
1082
|
-
"useFieldValue",
|
|
1083
|
-
"useFormValues",
|
|
1084
|
-
"useFormErrors",
|
|
1085
|
-
"useFieldError",
|
|
1086
|
-
"useSubmitForm",
|
|
1087
|
-
"FormContextKey",
|
|
1088
|
-
"FieldContextKey"
|
|
1089
|
-
]
|
|
1090
|
-
});
|
|
1091
|
-
const vitepress = defineUnimportPreset({
|
|
1092
|
-
from: "vitepress",
|
|
1093
|
-
imports: [
|
|
1094
|
-
"useData",
|
|
1095
|
-
"useRoute",
|
|
1096
|
-
"useRouter",
|
|
1097
|
-
"withBase"
|
|
1098
|
-
]
|
|
1099
|
-
});
|
|
1100
|
-
const vitest = defineUnimportPreset({
|
|
1101
|
-
from: "vitest",
|
|
1102
|
-
imports: [
|
|
1103
|
-
"suite",
|
|
1104
|
-
"test",
|
|
1105
|
-
"describe",
|
|
1106
|
-
"it",
|
|
1107
|
-
"chai",
|
|
1108
|
-
"expect",
|
|
1109
|
-
"assert",
|
|
1110
|
-
"vitest",
|
|
1111
|
-
"vi",
|
|
1112
|
-
"beforeAll",
|
|
1113
|
-
"afterAll",
|
|
1114
|
-
"beforeEach",
|
|
1115
|
-
"afterEach"
|
|
1116
|
-
]
|
|
1117
|
-
});
|
|
1118
|
-
const CommonCompositionAPI = [
|
|
1119
|
-
"onActivated",
|
|
1120
|
-
"onBeforeMount",
|
|
1121
|
-
"onBeforeUnmount",
|
|
1122
|
-
"onBeforeUpdate",
|
|
1123
|
-
"onErrorCaptured",
|
|
1124
|
-
"onDeactivated",
|
|
1125
|
-
"onMounted",
|
|
1126
|
-
"onServerPrefetch",
|
|
1127
|
-
"onUnmounted",
|
|
1128
|
-
"onUpdated",
|
|
1129
|
-
"useAttrs",
|
|
1130
|
-
"useSlots",
|
|
1131
|
-
"computed",
|
|
1132
|
-
"customRef",
|
|
1133
|
-
"isReadonly",
|
|
1134
|
-
"isRef",
|
|
1135
|
-
"isShallow",
|
|
1136
|
-
"isProxy",
|
|
1137
|
-
"isReactive",
|
|
1138
|
-
"markRaw",
|
|
1139
|
-
"reactive",
|
|
1140
|
-
"readonly",
|
|
1141
|
-
"ref",
|
|
1142
|
-
"shallowReactive",
|
|
1143
|
-
"shallowReadonly",
|
|
1144
|
-
"shallowRef",
|
|
1145
|
-
"triggerRef",
|
|
1146
|
-
"toRaw",
|
|
1147
|
-
"toRef",
|
|
1148
|
-
"toRefs",
|
|
1149
|
-
"toValue",
|
|
1150
|
-
"unref",
|
|
1151
|
-
"watch",
|
|
1152
|
-
"watchEffect",
|
|
1153
|
-
"watchPostEffect",
|
|
1154
|
-
"watchSyncEffect",
|
|
1155
|
-
"defineComponent",
|
|
1156
|
-
"defineAsyncComponent",
|
|
1157
|
-
"getCurrentInstance",
|
|
1158
|
-
"h",
|
|
1159
|
-
"inject",
|
|
1160
|
-
"nextTick",
|
|
1161
|
-
"provide",
|
|
1162
|
-
"useCssModule",
|
|
1163
|
-
"createApp",
|
|
1164
|
-
"effectScope",
|
|
1165
|
-
"EffectScope",
|
|
1166
|
-
"getCurrentScope",
|
|
1167
|
-
"onScopeDispose",
|
|
1168
|
-
...[
|
|
1169
|
-
"Component",
|
|
1170
|
-
"Slot",
|
|
1171
|
-
"Slots",
|
|
1172
|
-
"ComponentPublicInstance",
|
|
1173
|
-
"ComputedRef",
|
|
1174
|
-
"DirectiveBinding",
|
|
1175
|
-
"ExtractDefaultPropTypes",
|
|
1176
|
-
"ExtractPropTypes",
|
|
1177
|
-
"ExtractPublicPropTypes",
|
|
1178
|
-
"InjectionKey",
|
|
1179
|
-
"PropType",
|
|
1180
|
-
"Ref",
|
|
1181
|
-
"ShallowRef",
|
|
1182
|
-
"MaybeRef",
|
|
1183
|
-
"MaybeRefOrGetter",
|
|
1184
|
-
"VNode",
|
|
1185
|
-
"WritableComputedRef"
|
|
1186
|
-
].map((name) => ({
|
|
1187
|
-
name,
|
|
1188
|
-
type: true
|
|
1189
|
-
}))
|
|
1190
|
-
];
|
|
1191
|
-
const vue = defineUnimportPreset({
|
|
1192
|
-
from: "vue",
|
|
1193
|
-
imports: [
|
|
1194
|
-
...CommonCompositionAPI,
|
|
1195
|
-
"onRenderTracked",
|
|
1196
|
-
"onRenderTriggered",
|
|
1197
|
-
"resolveComponent",
|
|
1198
|
-
"useCssVars",
|
|
1199
|
-
"useModel",
|
|
1200
|
-
"getCurrentWatcher",
|
|
1201
|
-
"onWatcherCleanup",
|
|
1202
|
-
"useId",
|
|
1203
|
-
"useTemplateRef"
|
|
1204
|
-
]
|
|
1205
|
-
});
|
|
1206
|
-
const vueCompositionApi = defineUnimportPreset({
|
|
1207
|
-
from: "@vue/composition-api",
|
|
1208
|
-
imports: CommonCompositionAPI
|
|
1209
|
-
});
|
|
1210
|
-
const vueDemi = defineUnimportPreset({
|
|
1211
|
-
from: "vue-demi",
|
|
1212
|
-
imports: CommonCompositionAPI
|
|
1213
|
-
});
|
|
1214
|
-
const vueI18n = defineUnimportPreset({
|
|
1215
|
-
from: "vue-i18n",
|
|
1216
|
-
imports: ["useI18n"]
|
|
1217
|
-
});
|
|
1218
|
-
const vueMacros = defineUnimportPreset({
|
|
1219
|
-
from: "vue/macros",
|
|
1220
|
-
imports: [
|
|
1221
|
-
"$",
|
|
1222
|
-
"$$",
|
|
1223
|
-
"$ref",
|
|
1224
|
-
"$shallowRef",
|
|
1225
|
-
"$toRef",
|
|
1226
|
-
"$customRef",
|
|
1227
|
-
"$computed"
|
|
1228
|
-
]
|
|
1229
|
-
});
|
|
1230
|
-
const vueRouter = defineUnimportPreset({
|
|
1231
|
-
from: "vue-router",
|
|
1232
|
-
imports: [
|
|
1233
|
-
"useRouter",
|
|
1234
|
-
"useRoute",
|
|
1235
|
-
"useLink",
|
|
1236
|
-
"onBeforeRouteLeave",
|
|
1237
|
-
"onBeforeRouteUpdate"
|
|
1238
|
-
]
|
|
1239
|
-
});
|
|
1240
|
-
const vueRouterComposables = defineUnimportPreset({
|
|
1241
|
-
from: "vue-router/composables",
|
|
1242
|
-
imports: [
|
|
1243
|
-
"useRouter",
|
|
1244
|
-
"useRoute",
|
|
1245
|
-
"useLink",
|
|
1246
|
-
"onBeforeRouteLeave",
|
|
1247
|
-
"onBeforeRouteUpdate"
|
|
1248
|
-
]
|
|
1249
|
-
});
|
|
1250
|
-
let _cache;
|
|
1251
|
-
const vueuseCore = () => {
|
|
1252
|
-
const excluded = ["toRefs", "utils"];
|
|
1253
|
-
if (!_cache) try {
|
|
1254
|
-
const corePath = resolveModule("@vueuse/core") || process$1.cwd();
|
|
1255
|
-
const path$1 = resolveModule("@vueuse/core/indexes.json") || resolveModule("@vueuse/metadata/index.json") || resolveModule("@vueuse/metadata/index.json", { paths: [corePath] });
|
|
1256
|
-
_cache = defineUnimportPreset({
|
|
1257
|
-
from: "@vueuse/core",
|
|
1258
|
-
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))
|
|
1259
|
-
});
|
|
1260
|
-
} catch (error) {
|
|
1261
|
-
console.error(error);
|
|
1262
|
-
throw new Error("[auto-import] failed to load @vueuse/core, have you installed it?");
|
|
1263
|
-
}
|
|
1264
|
-
return _cache;
|
|
1265
|
-
};
|
|
1266
|
-
const vueuseHead = defineUnimportPreset({
|
|
1267
|
-
from: "@vueuse/head",
|
|
1268
|
-
imports: ["useHead"]
|
|
1269
|
-
});
|
|
1270
|
-
const vuex = defineUnimportPreset({
|
|
1271
|
-
from: "vuex",
|
|
1272
|
-
imports: [
|
|
1273
|
-
"createStore",
|
|
1274
|
-
"createLogger",
|
|
1275
|
-
"mapState",
|
|
1276
|
-
"mapGetters",
|
|
1277
|
-
"mapActions",
|
|
1278
|
-
"mapMutations",
|
|
1279
|
-
"createNamespacedHelpers",
|
|
1280
|
-
"useStore"
|
|
1281
|
-
]
|
|
1282
|
-
});
|
|
1283
|
-
const builtinPresets = {
|
|
1284
|
-
"@vue/composition-api": vueCompositionApi,
|
|
1285
|
-
"@vueuse/core": vueuseCore,
|
|
1286
|
-
"@vueuse/head": vueuseHead,
|
|
1287
|
-
"pinia": pinia,
|
|
1288
|
-
"preact": preact,
|
|
1289
|
-
"quasar": quasar,
|
|
1290
|
-
"react": react,
|
|
1291
|
-
"react-router": reactRouter,
|
|
1292
|
-
"react-router-dom": reactRouterDom,
|
|
1293
|
-
"svelte": svelte,
|
|
1294
|
-
"svelte/animate": svelteAnimate,
|
|
1295
|
-
"svelte/easing": svelteEasing,
|
|
1296
|
-
"svelte/motion": svelteMotion,
|
|
1297
|
-
"svelte/store": svelteStore,
|
|
1298
|
-
"svelte/transition": svelteTransition,
|
|
1299
|
-
"vee-validate": veeValidate,
|
|
1300
|
-
"vitepress": vitepress,
|
|
1301
|
-
"vue-demi": vueDemi,
|
|
1302
|
-
"vue-i18n": vueI18n,
|
|
1303
|
-
"vue-router": vueRouter,
|
|
1304
|
-
"vue-router-composables": vueRouterComposables,
|
|
1305
|
-
"vue": vue,
|
|
1306
|
-
"vue/macros": vueMacros,
|
|
1307
|
-
"vuex": vuex,
|
|
1308
|
-
"vitest": vitest,
|
|
1309
|
-
"uni-app": uniApp,
|
|
1310
|
-
"solid-js": solid,
|
|
1311
|
-
"solid-app-router": solidAppRouter,
|
|
1312
|
-
"rxjs": rxjs,
|
|
1313
|
-
"date-fns": dateFns
|
|
1314
|
-
};
|
|
1315
|
-
const commonProps = [
|
|
1316
|
-
"from",
|
|
1317
|
-
"priority",
|
|
1318
|
-
"disabled",
|
|
1319
|
-
"dtsDisabled",
|
|
1320
|
-
"declarationType",
|
|
1321
|
-
"meta",
|
|
1322
|
-
"type",
|
|
1323
|
-
"typeFrom"
|
|
1324
|
-
];
|
|
1325
|
-
async function resolvePreset(preset) {
|
|
1326
|
-
const imports = [];
|
|
1327
|
-
if ("package" in preset) return await resolvePackagePreset(preset);
|
|
1328
|
-
const common = {};
|
|
1329
|
-
commonProps.forEach((i) => {
|
|
1330
|
-
if (i in preset) common[i] = preset[i];
|
|
1331
|
-
});
|
|
1332
|
-
for (const _import of preset.imports) if (typeof _import === "string") imports.push({
|
|
1333
|
-
...common,
|
|
1334
|
-
name: _import,
|
|
1335
|
-
as: _import
|
|
1336
|
-
});
|
|
1337
|
-
else if (Array.isArray(_import)) imports.push({
|
|
1338
|
-
...common,
|
|
1339
|
-
name: _import[0],
|
|
1340
|
-
as: _import[1] || _import[0],
|
|
1341
|
-
from: _import[2] || preset.from
|
|
1342
|
-
});
|
|
1343
|
-
else if (_import.imports) imports.push(...await resolvePreset(_import));
|
|
1344
|
-
else imports.push({
|
|
1345
|
-
...common,
|
|
1346
|
-
..._import
|
|
1347
|
-
});
|
|
1348
|
-
return imports;
|
|
1349
|
-
}
|
|
1350
|
-
async function resolveBuiltinPresets(presets) {
|
|
1351
|
-
return (await Promise.all(presets.map(async (p) => {
|
|
1352
|
-
let preset = typeof p === "string" ? builtinPresets[p] : p;
|
|
1353
|
-
if (typeof preset === "function") preset = preset();
|
|
1354
|
-
return await resolvePreset(preset);
|
|
1355
|
-
}))).flat();
|
|
1356
|
-
}
|
|
1357
|
-
function createUnimport(opts) {
|
|
1358
|
-
const ctx = createInternalContext(opts);
|
|
1359
|
-
async function generateTypeDeclarations(options) {
|
|
1360
|
-
const opts2 = {
|
|
1361
|
-
resolvePath: (i) => stripFileExtension(i.typeFrom || i.from),
|
|
1362
|
-
...options
|
|
1363
|
-
};
|
|
1364
|
-
const { typeReExports = true } = opts2;
|
|
1365
|
-
const imports = await ctx.getImports();
|
|
1366
|
-
let dts = toTypeDeclarationFile(imports.filter((i) => !i.type && !i.dtsDisabled), opts2);
|
|
1367
|
-
const typeOnly = imports.filter((i) => i.type);
|
|
1368
|
-
if (typeReExports && typeOnly.length) dts += `
|
|
1369
|
-
${toTypeReExports(typeOnly, opts2)}`;
|
|
1370
|
-
for (const addon of ctx.addons) dts = await addon.declaration?.call(ctx, dts, opts2) ?? dts;
|
|
1371
|
-
return dts;
|
|
1372
|
-
}
|
|
1373
|
-
async function scanImportsFromFile(filepath, includeTypes = true) {
|
|
1374
|
-
const additions = await scanExports(filepath, includeTypes);
|
|
1375
|
-
await ctx.modifyDynamicImports((imports) => imports.filter((i) => i.from !== filepath).concat(additions));
|
|
1376
|
-
return additions;
|
|
1377
|
-
}
|
|
1378
|
-
async function scanImportsFromDir(dirs = ctx.options.dirs || [], options = ctx.options.dirsScanOptions) {
|
|
1379
|
-
const imports = await scanDirExports(dirs, options);
|
|
1380
|
-
const files = new Set(imports.map((f) => f.from));
|
|
1381
|
-
await ctx.modifyDynamicImports((i) => i.filter((i2) => !files.has(i2.from)).concat(imports));
|
|
1382
|
-
return imports;
|
|
1383
|
-
}
|
|
1384
|
-
async function injectImportsWithContext(code, id, options) {
|
|
1385
|
-
const result = await injectImports(code, id, ctx, {
|
|
1386
|
-
...opts,
|
|
1387
|
-
...options
|
|
1388
|
-
});
|
|
1389
|
-
const metadata = ctx.getMetadata();
|
|
1390
|
-
if (metadata) result.imports.forEach((i) => {
|
|
1391
|
-
metadata.injectionUsage[i.name] = metadata.injectionUsage[i.name] || {
|
|
1392
|
-
import: i,
|
|
1393
|
-
count: 0,
|
|
1394
|
-
moduleIds: []
|
|
1395
|
-
};
|
|
1396
|
-
metadata.injectionUsage[i.name].count++;
|
|
1397
|
-
if (id && !metadata.injectionUsage[i.name].moduleIds.includes(id)) metadata.injectionUsage[i.name].moduleIds.push(id);
|
|
1398
|
-
});
|
|
1399
|
-
return result;
|
|
1400
|
-
}
|
|
1401
|
-
async function init() {
|
|
1402
|
-
if (ctx.options.dirs?.length) await scanImportsFromDir();
|
|
1403
|
-
}
|
|
1404
|
-
return {
|
|
1405
|
-
version,
|
|
1406
|
-
init,
|
|
1407
|
-
clearDynamicImports: () => ctx.clearDynamicImports(),
|
|
1408
|
-
modifyDynamicImports: (fn) => ctx.modifyDynamicImports(fn),
|
|
1409
|
-
scanImportsFromDir,
|
|
1410
|
-
scanImportsFromFile,
|
|
1411
|
-
getImports: () => ctx.getImports(),
|
|
1412
|
-
getImportMap: () => ctx.getImportMap(),
|
|
1413
|
-
detectImports: (code) => detectImports(code, ctx),
|
|
1414
|
-
injectImports: injectImportsWithContext,
|
|
1415
|
-
generateTypeDeclarations: (options) => generateTypeDeclarations(options),
|
|
1416
|
-
getMetadata: () => ctx.getMetadata(),
|
|
1417
|
-
getInternalContext: () => ctx,
|
|
1418
|
-
toExports: async (filepath, includeTypes = false) => toExports(await ctx.getImports(), filepath, includeTypes)
|
|
1419
|
-
};
|
|
1420
|
-
}
|
|
1421
|
-
function createInternalContext(opts) {
|
|
1422
|
-
let _combinedImports;
|
|
1423
|
-
const _map = /* @__PURE__ */ new Map();
|
|
1424
|
-
const addons = configureAddons(opts);
|
|
1425
|
-
opts.addons = addons;
|
|
1426
|
-
opts.commentsDisable = opts.commentsDisable ?? ["@unimport-disable", "@imports-disable"];
|
|
1427
|
-
opts.commentsDebug = opts.commentsDebug ?? ["@unimport-debug", "@imports-debug"];
|
|
1428
|
-
let metadata;
|
|
1429
|
-
if (opts.collectMeta) metadata = { injectionUsage: {} };
|
|
1430
|
-
let resolvePromise;
|
|
1431
|
-
const ctx = {
|
|
1432
|
-
version,
|
|
1433
|
-
options: opts,
|
|
1434
|
-
addons,
|
|
1435
|
-
staticImports: [...opts.imports || []].filter(Boolean),
|
|
1436
|
-
dynamicImports: [],
|
|
1437
|
-
modifyDynamicImports,
|
|
1438
|
-
clearDynamicImports,
|
|
1439
|
-
async getImports() {
|
|
1440
|
-
await resolvePromise;
|
|
1441
|
-
return updateImports();
|
|
1442
|
-
},
|
|
1443
|
-
async replaceImports(imports) {
|
|
1444
|
-
ctx.staticImports = [...imports || []].filter(Boolean);
|
|
1445
|
-
ctx.invalidate();
|
|
1446
|
-
await resolvePromise;
|
|
1447
|
-
return updateImports();
|
|
1448
|
-
},
|
|
1449
|
-
async getImportMap() {
|
|
1450
|
-
await ctx.getImports();
|
|
1451
|
-
return _map;
|
|
1452
|
-
},
|
|
1453
|
-
getMetadata() {
|
|
1454
|
-
return metadata;
|
|
1455
|
-
},
|
|
1456
|
-
invalidate() {
|
|
1457
|
-
_combinedImports = void 0;
|
|
1458
|
-
},
|
|
1459
|
-
resolveId: (id, parentId) => opts.resolveId?.(id, parentId)
|
|
1460
|
-
};
|
|
1461
|
-
resolvePromise = resolveBuiltinPresets(opts.presets || []).then((r) => {
|
|
1462
|
-
ctx.staticImports.unshift(...r);
|
|
1463
|
-
_combinedImports = void 0;
|
|
1464
|
-
updateImports();
|
|
1465
|
-
});
|
|
1466
|
-
function updateImports() {
|
|
1467
|
-
if (!_combinedImports) {
|
|
1468
|
-
let imports = normalizeImports(dedupeImports([...ctx.staticImports, ...ctx.dynamicImports], opts.warn || console.warn));
|
|
1469
|
-
for (const addon of ctx.addons) if (addon.extendImports) imports = addon.extendImports.call(ctx, imports) ?? imports;
|
|
1470
|
-
imports = imports.filter((i) => !i.disabled);
|
|
1471
|
-
_map.clear();
|
|
1472
|
-
for (const _import of imports) if (!_import.type) _map.set(_import.as ?? _import.name, _import);
|
|
1473
|
-
_combinedImports = imports;
|
|
1474
|
-
}
|
|
1475
|
-
return _combinedImports;
|
|
1476
|
-
}
|
|
1477
|
-
async function modifyDynamicImports(fn) {
|
|
1478
|
-
const result = await fn(ctx.dynamicImports);
|
|
1479
|
-
if (Array.isArray(result)) ctx.dynamicImports = result;
|
|
1480
|
-
ctx.invalidate();
|
|
1481
|
-
}
|
|
1482
|
-
function clearDynamicImports() {
|
|
1483
|
-
ctx.dynamicImports.length = 0;
|
|
1484
|
-
ctx.invalidate();
|
|
1485
|
-
}
|
|
1486
|
-
return ctx;
|
|
1487
|
-
}
|
|
1488
|
-
async function injectImports(code, id, ctx, options) {
|
|
1489
|
-
const s = getMagicString(code);
|
|
1490
|
-
if (ctx.options.commentsDisable?.some((c) => s.original.includes(c))) return {
|
|
1491
|
-
s,
|
|
1492
|
-
get code() {
|
|
1493
|
-
return s.toString();
|
|
1494
|
-
},
|
|
1495
|
-
imports: []
|
|
1496
|
-
};
|
|
1497
|
-
for (const addon of ctx.addons) await addon.transform?.call(ctx, s, id);
|
|
1498
|
-
const { isCJSContext, matchedImports, firstOccurrence } = await detectImports(s, ctx, options);
|
|
1499
|
-
const imports = await resolveImports(ctx, matchedImports, id);
|
|
1500
|
-
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(", ")}` : ""}`);
|
|
1501
|
-
return {
|
|
1502
|
-
...addImportToCode(s, imports, isCJSContext, options?.mergeExisting, options?.injectAtEnd, firstOccurrence, (imports2) => {
|
|
1503
|
-
for (const addon of ctx.addons) imports2 = addon.injectImportsResolved?.call(ctx, imports2, s, id) ?? imports2;
|
|
1504
|
-
return imports2;
|
|
1505
|
-
}, (str, imports2) => {
|
|
1506
|
-
for (const addon of ctx.addons) str = addon.injectImportsStringified?.call(ctx, str, imports2, s, id) ?? str;
|
|
1507
|
-
return str;
|
|
1508
|
-
}),
|
|
1509
|
-
imports
|
|
1510
|
-
};
|
|
1511
|
-
}
|
|
1512
|
-
async function resolveImports(ctx, imports, id) {
|
|
1513
|
-
const resolveCache = /* @__PURE__ */ new Map();
|
|
1514
|
-
return (await Promise.all(imports.map(async (i) => {
|
|
1515
|
-
if (!resolveCache.has(i.from)) resolveCache.set(i.from, await ctx.resolveId(i.from, id) || i.from);
|
|
1516
|
-
const from = resolveCache.get(i.from);
|
|
1517
|
-
if (i.from === id || !from || from === "." || from === id) return;
|
|
1518
|
-
return {
|
|
1519
|
-
...i,
|
|
1520
|
-
from
|
|
1521
|
-
};
|
|
1522
|
-
}))).filter(Boolean);
|
|
1523
|
-
}
|
|
1524
|
-
|
|
1525
|
-
//#endregion
|
|
1526
|
-
export { resolveBuiltinPresets as a, scanExports as c, normalizeScanDirs as i, scanFilesFromDir as l, createUnimport as n, resolvePreset as o, dedupeDtsExports as r, scanDirExports as s, builtinPresets as t, version as u };
|