chore: update frontend build for v1.1.83 [skip ci]

This commit is contained in:
github-actions[bot]
2025-08-06 02:30:41 +00:00
parent f3787d775e
commit edb59f3b4a
19316 changed files with 2351599 additions and 35 deletions

15
web/admin-spa/node_modules/unimport/dist/addons.cjs generated vendored Normal file
View File

@@ -0,0 +1,15 @@
'use strict';
const vueDirectives = require('./shared/unimport.MMUMmZ45.cjs');
require('node:path');
require('node:process');
require('pathe');
require('scule');
require('magic-string');
require('mlly');
require('strip-literal');
exports.vueDirectivesAddon = vueDirectives.vueDirectivesAddon;
exports.vueTemplateAddon = vueDirectives.vueTemplateAddon;

View File

@@ -0,0 +1,8 @@
import { n as AddonVueDirectivesOptions, r as Addon } from './shared/unimport.CaVRR9SH.cjs';
export { v as vueTemplateAddon } from './shared/unimport.D0oAO1c8.cjs';
import 'magic-string';
import 'mlly';
declare function vueDirectivesAddon(options?: AddonVueDirectivesOptions): Addon;
export { vueDirectivesAddon };

View File

@@ -0,0 +1,8 @@
import { n as AddonVueDirectivesOptions, r as Addon } from './shared/unimport.CaVRR9SH.mjs';
export { v as vueTemplateAddon } from './shared/unimport.CzOA5cgj.mjs';
import 'magic-string';
import 'mlly';
declare function vueDirectivesAddon(options?: AddonVueDirectivesOptions): Addon;
export { vueDirectivesAddon };

8
web/admin-spa/node_modules/unimport/dist/addons.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import { n as AddonVueDirectivesOptions, r as Addon } from './shared/unimport.CaVRR9SH.js';
export { v as vueTemplateAddon } from './shared/unimport.BGSZL1Hy.js';
import 'magic-string';
import 'mlly';
declare function vueDirectivesAddon(options?: AddonVueDirectivesOptions): Addon;
export { vueDirectivesAddon };

8
web/admin-spa/node_modules/unimport/dist/addons.mjs generated vendored Normal file
View File

@@ -0,0 +1,8 @@
export { v as vueDirectivesAddon, a as vueTemplateAddon } from './shared/unimport.0aitavbJ.mjs';
import 'node:path';
import 'node:process';
import 'pathe';
import 'scule';
import 'magic-string';
import 'mlly';
import 'strip-literal';

View File

@@ -0,0 +1,234 @@
'use strict';
const acorn = require('acorn');
const estreeWalker = require('estree-walker');
const vueDirectives = require('../shared/unimport.MMUMmZ45.cjs');
require('node:path');
require('node:process');
require('pathe');
require('scule');
require('magic-string');
require('mlly');
require('strip-literal');
async function detectImportsAcorn(code, ctx, options) {
const s = vueDirectives.getMagicString(code);
const map = await ctx.getImportMap();
let matchedImports = [];
const enableAutoImport = options?.autoImport !== false;
const enableTransformVirtualImports = options?.transformVirtualImports !== false && ctx.options.virtualImports?.length;
if (enableAutoImport || enableTransformVirtualImports) {
const ast = acorn.parse(s.original, {
sourceType: "module",
ecmaVersion: "latest",
locations: true
});
const virtualImports = createVirtualImportsAcronWalker(map, ctx.options.virtualImports);
const scopes = traveseScopes(
ast,
enableTransformVirtualImports ? virtualImports.walk : {}
);
if (enableAutoImport) {
const identifiers = scopes.unmatched;
matchedImports.push(
...Array.from(identifiers).map((name) => {
const item = map.get(name);
if (item && !item.disabled)
return item;
return null;
}).filter(Boolean)
);
for (const addon of ctx.addons)
matchedImports = await addon.matchImports?.call(ctx, identifiers, matchedImports) || matchedImports;
}
virtualImports.ranges.forEach(([start, end]) => {
s.remove(start, end);
});
matchedImports.push(...virtualImports.imports);
}
return {
s,
strippedCode: code.toString(),
matchedImports,
isCJSContext: false,
firstOccurrence: 0
// TODO:
};
}
function traveseScopes(ast, additionalWalk) {
const scopes = [];
let scopeCurrent = undefined;
const scopesStack = [];
function pushScope(node) {
scopeCurrent = {
node,
parent: scopeCurrent,
declarations: /* @__PURE__ */ new Set(),
references: /* @__PURE__ */ new Set()
};
scopes.push(scopeCurrent);
scopesStack.push(scopeCurrent);
}
function popScope(node) {
const scope = scopesStack.pop();
if (scope?.node !== node)
throw new Error("Scope mismatch");
scopeCurrent = scopesStack[scopesStack.length - 1];
}
pushScope(undefined);
estreeWalker.walk(ast, {
enter(node, parent, prop, index) {
additionalWalk?.enter?.call(this, node, parent, prop, index);
switch (node.type) {
// ====== Declaration ======
case "ImportSpecifier":
case "ImportDefaultSpecifier":
case "ImportNamespaceSpecifier":
scopeCurrent.declarations.add(node.local.name);
return;
case "FunctionDeclaration":
case "ClassDeclaration":
if (node.id)
scopeCurrent.declarations.add(node.id.name);
return;
case "VariableDeclarator":
if (node.id.type === "Identifier") {
scopeCurrent.declarations.add(node.id.name);
} else {
estreeWalker.walk(node.id, {
enter(node2) {
if (node2.type === "ObjectPattern") {
node2.properties.forEach((i) => {
if (i.type === "Property" && i.value.type === "Identifier")
scopeCurrent.declarations.add(i.value.name);
else if (i.type === "RestElement" && i.argument.type === "Identifier")
scopeCurrent.declarations.add(i.argument.name);
});
} else if (node2.type === "ArrayPattern") {
node2.elements.forEach((i) => {
if (i?.type === "Identifier")
scopeCurrent.declarations.add(i.name);
if (i?.type === "RestElement" && i.argument.type === "Identifier")
scopeCurrent.declarations.add(i.argument.name);
});
}
}
});
}
return;
// ====== Scope ======
case "BlockStatement":
pushScope(node);
return;
// ====== Reference ======
case "Identifier":
switch (parent?.type) {
case "CallExpression":
if (parent.callee === node || parent.arguments.includes(node))
scopeCurrent.references.add(node.name);
return;
case "MemberExpression":
if (parent.object === node)
scopeCurrent.references.add(node.name);
return;
case "VariableDeclarator":
if (parent.init === node)
scopeCurrent.references.add(node.name);
return;
case "SpreadElement":
if (parent.argument === node)
scopeCurrent.references.add(node.name);
return;
case "ClassDeclaration":
if (parent.superClass === node)
scopeCurrent.references.add(node.name);
return;
case "Property":
if (parent.value === node)
scopeCurrent.references.add(node.name);
return;
case "TemplateLiteral":
if (parent.expressions.includes(node))
scopeCurrent.references.add(node.name);
return;
case "AssignmentExpression":
if (parent.right === node)
scopeCurrent.references.add(node.name);
return;
case "IfStatement":
case "WhileStatement":
case "DoWhileStatement":
if (parent.test === node)
scopeCurrent.references.add(node.name);
return;
case "SwitchStatement":
if (parent.discriminant === node)
scopeCurrent.references.add(node.name);
return;
}
if (parent?.type.includes("Expression"))
scopeCurrent.references.add(node.name);
}
},
leave(node, parent, prop, index) {
additionalWalk?.leave?.call(this, node, parent, prop, index);
switch (node.type) {
case "BlockStatement":
popScope(node);
}
}
});
const unmatched = /* @__PURE__ */ new Set();
for (const scope of scopes) {
for (const name of scope.references) {
let defined = false;
let parent = scope;
while (parent) {
if (parent.declarations.has(name)) {
defined = true;
break;
}
parent = parent?.parent;
}
if (!defined)
unmatched.add(name);
}
}
return {
unmatched,
scopes
};
}
function createVirtualImportsAcronWalker(importMap, virtualImports = []) {
const imports = [];
const ranges = [];
return {
imports,
ranges,
walk: {
enter(node) {
if (node.type === "ImportDeclaration") {
if (virtualImports.includes(node.source.value)) {
ranges.push([node.start, node.end]);
node.specifiers.forEach((i) => {
if (i.type === "ImportSpecifier" && i.imported.type === "Identifier") {
const original = importMap.get(i.imported.name);
if (!original)
throw new Error(`[unimport] failed to find "${i.imported.name}" imported from "${node.source.value}"`);
imports.push({
from: original.from,
name: original.name,
as: i.local.name
});
}
});
}
}
}
}
};
}
exports.createVirtualImportsAcronWalker = createVirtualImportsAcronWalker;
exports.detectImportsAcorn = detectImportsAcorn;
exports.traveseScopes = traveseScopes;

View File

@@ -0,0 +1,230 @@
import { parse } from 'acorn';
import { walk } from 'estree-walker';
import { n as getMagicString } from '../shared/unimport.0aitavbJ.mjs';
import 'node:path';
import 'node:process';
import 'pathe';
import 'scule';
import 'magic-string';
import 'mlly';
import 'strip-literal';
async function detectImportsAcorn(code, ctx, options) {
const s = getMagicString(code);
const map = await ctx.getImportMap();
let matchedImports = [];
const enableAutoImport = options?.autoImport !== false;
const enableTransformVirtualImports = options?.transformVirtualImports !== false && ctx.options.virtualImports?.length;
if (enableAutoImport || enableTransformVirtualImports) {
const ast = parse(s.original, {
sourceType: "module",
ecmaVersion: "latest",
locations: true
});
const virtualImports = createVirtualImportsAcronWalker(map, ctx.options.virtualImports);
const scopes = traveseScopes(
ast,
enableTransformVirtualImports ? virtualImports.walk : {}
);
if (enableAutoImport) {
const identifiers = scopes.unmatched;
matchedImports.push(
...Array.from(identifiers).map((name) => {
const item = map.get(name);
if (item && !item.disabled)
return item;
return null;
}).filter(Boolean)
);
for (const addon of ctx.addons)
matchedImports = await addon.matchImports?.call(ctx, identifiers, matchedImports) || matchedImports;
}
virtualImports.ranges.forEach(([start, end]) => {
s.remove(start, end);
});
matchedImports.push(...virtualImports.imports);
}
return {
s,
strippedCode: code.toString(),
matchedImports,
isCJSContext: false,
firstOccurrence: 0
// TODO:
};
}
function traveseScopes(ast, additionalWalk) {
const scopes = [];
let scopeCurrent = undefined;
const scopesStack = [];
function pushScope(node) {
scopeCurrent = {
node,
parent: scopeCurrent,
declarations: /* @__PURE__ */ new Set(),
references: /* @__PURE__ */ new Set()
};
scopes.push(scopeCurrent);
scopesStack.push(scopeCurrent);
}
function popScope(node) {
const scope = scopesStack.pop();
if (scope?.node !== node)
throw new Error("Scope mismatch");
scopeCurrent = scopesStack[scopesStack.length - 1];
}
pushScope(undefined);
walk(ast, {
enter(node, parent, prop, index) {
additionalWalk?.enter?.call(this, node, parent, prop, index);
switch (node.type) {
// ====== Declaration ======
case "ImportSpecifier":
case "ImportDefaultSpecifier":
case "ImportNamespaceSpecifier":
scopeCurrent.declarations.add(node.local.name);
return;
case "FunctionDeclaration":
case "ClassDeclaration":
if (node.id)
scopeCurrent.declarations.add(node.id.name);
return;
case "VariableDeclarator":
if (node.id.type === "Identifier") {
scopeCurrent.declarations.add(node.id.name);
} else {
walk(node.id, {
enter(node2) {
if (node2.type === "ObjectPattern") {
node2.properties.forEach((i) => {
if (i.type === "Property" && i.value.type === "Identifier")
scopeCurrent.declarations.add(i.value.name);
else if (i.type === "RestElement" && i.argument.type === "Identifier")
scopeCurrent.declarations.add(i.argument.name);
});
} else if (node2.type === "ArrayPattern") {
node2.elements.forEach((i) => {
if (i?.type === "Identifier")
scopeCurrent.declarations.add(i.name);
if (i?.type === "RestElement" && i.argument.type === "Identifier")
scopeCurrent.declarations.add(i.argument.name);
});
}
}
});
}
return;
// ====== Scope ======
case "BlockStatement":
pushScope(node);
return;
// ====== Reference ======
case "Identifier":
switch (parent?.type) {
case "CallExpression":
if (parent.callee === node || parent.arguments.includes(node))
scopeCurrent.references.add(node.name);
return;
case "MemberExpression":
if (parent.object === node)
scopeCurrent.references.add(node.name);
return;
case "VariableDeclarator":
if (parent.init === node)
scopeCurrent.references.add(node.name);
return;
case "SpreadElement":
if (parent.argument === node)
scopeCurrent.references.add(node.name);
return;
case "ClassDeclaration":
if (parent.superClass === node)
scopeCurrent.references.add(node.name);
return;
case "Property":
if (parent.value === node)
scopeCurrent.references.add(node.name);
return;
case "TemplateLiteral":
if (parent.expressions.includes(node))
scopeCurrent.references.add(node.name);
return;
case "AssignmentExpression":
if (parent.right === node)
scopeCurrent.references.add(node.name);
return;
case "IfStatement":
case "WhileStatement":
case "DoWhileStatement":
if (parent.test === node)
scopeCurrent.references.add(node.name);
return;
case "SwitchStatement":
if (parent.discriminant === node)
scopeCurrent.references.add(node.name);
return;
}
if (parent?.type.includes("Expression"))
scopeCurrent.references.add(node.name);
}
},
leave(node, parent, prop, index) {
additionalWalk?.leave?.call(this, node, parent, prop, index);
switch (node.type) {
case "BlockStatement":
popScope(node);
}
}
});
const unmatched = /* @__PURE__ */ new Set();
for (const scope of scopes) {
for (const name of scope.references) {
let defined = false;
let parent = scope;
while (parent) {
if (parent.declarations.has(name)) {
defined = true;
break;
}
parent = parent?.parent;
}
if (!defined)
unmatched.add(name);
}
}
return {
unmatched,
scopes
};
}
function createVirtualImportsAcronWalker(importMap, virtualImports = []) {
const imports = [];
const ranges = [];
return {
imports,
ranges,
walk: {
enter(node) {
if (node.type === "ImportDeclaration") {
if (virtualImports.includes(node.source.value)) {
ranges.push([node.start, node.end]);
node.specifiers.forEach((i) => {
if (i.type === "ImportSpecifier" && i.imported.type === "Identifier") {
const original = importMap.get(i.imported.name);
if (!original)
throw new Error(`[unimport] failed to find "${i.imported.name}" imported from "${node.source.value}"`);
imports.push({
from: original.from,
name: original.name,
as: i.local.name
});
}
});
}
}
}
}
};
}
export { createVirtualImportsAcronWalker, detectImportsAcorn, traveseScopes };

71
web/admin-spa/node_modules/unimport/dist/index.cjs generated vendored Normal file
View File

@@ -0,0 +1,71 @@
'use strict';
const context = require('./shared/unimport.D6_N7ILk.cjs');
const vueDirectives = require('./shared/unimport.MMUMmZ45.cjs');
require('mlly');
require('node:fs');
require('node:fs/promises');
require('node:process');
require('node:url');
require('fast-glob');
require('pathe');
require('picomatch');
require('scule');
require('node:os');
require('pkg-types');
require('local-pkg');
require('node:path');
require('magic-string');
require('strip-literal');
async function installGlobalAutoImports(imports, options = {}) {
const {
globalObject = globalThis,
overrides = false
} = options;
imports = Array.isArray(imports) ? imports : await imports.getImports();
await Promise.all(
imports.map(async (i) => {
if (i.disabled || i.type)
return;
const as = i.as || i.name;
if (overrides || !(as in globalObject)) {
const module = await import(i.from);
globalObject[as] = module[i.name];
}
})
);
return globalObject;
}
exports.builtinPresets = context.builtinPresets;
exports.createUnimport = context.createUnimport;
exports.dedupeDtsExports = context.dedupeDtsExports;
exports.normalizeScanDirs = context.normalizeScanDirs;
exports.resolveBuiltinPresets = context.resolveBuiltinPresets;
exports.resolvePreset = context.resolvePreset;
exports.scanDirExports = context.scanDirExports;
exports.scanExports = context.scanExports;
exports.scanFilesFromDir = context.scanFilesFromDir;
exports.version = context.version;
exports.addImportToCode = vueDirectives.addImportToCode;
exports.dedupeImports = vueDirectives.dedupeImports;
exports.defineUnimportPreset = vueDirectives.defineUnimportPreset;
exports.excludeRE = vueDirectives.excludeRE;
exports.getMagicString = vueDirectives.getMagicString;
exports.getString = vueDirectives.getString;
exports.importAsRE = vueDirectives.importAsRE;
exports.matchRE = vueDirectives.matchRE;
exports.normalizeImports = vueDirectives.normalizeImports;
exports.resolveIdAbsolute = vueDirectives.resolveIdAbsolute;
exports.separatorRE = vueDirectives.separatorRE;
exports.stringifyImports = vueDirectives.stringifyImports;
exports.stripCommentsAndStrings = vueDirectives.stripCommentsAndStrings;
exports.stripFileExtension = vueDirectives.stripFileExtension;
exports.toExports = vueDirectives.toExports;
exports.toImports = vueDirectives.toImports;
exports.toTypeDeclarationFile = vueDirectives.toTypeDeclarationFile;
exports.toTypeDeclarationItems = vueDirectives.toTypeDeclarationItems;
exports.toTypeReExports = vueDirectives.toTypeReExports;
exports.vueTemplateAddon = vueDirectives.vueTemplateAddon;
exports.installGlobalAutoImports = installGlobalAutoImports;

52
web/admin-spa/node_modules/unimport/dist/index.d.cts generated vendored Normal file
View File

@@ -0,0 +1,52 @@
export { v as vueTemplateAddon } from './shared/unimport.D0oAO1c8.cjs';
import { U as UnimportOptions, a as Unimport, I as Import, b as InstallGlobalOptions, S as ScanDir, c as ScanDirExportsOptions, P as Preset, B as BuiltinPresetName, d as InlinePreset, T as TypeDeclarationOptions, M as MagicStringResult } from './shared/unimport.CaVRR9SH.cjs';
export { r as Addon, n as AddonVueDirectivesOptions, A as AddonsOptions, D as DetectImportResult, h as ImportCommon, s as ImportInjectionResult, g as ImportName, p as InjectImportsOptions, l as InjectionUsageRecord, f as ModuleId, j as PackagePreset, o as PathFromResolver, i as PresetImport, q as Thenable, k as UnimportContext, m as UnimportMeta, e as builtinPresets } from './shared/unimport.CaVRR9SH.cjs';
import { StripLiteralOptions } from 'strip-literal';
import MagicString from 'magic-string';
import 'mlly';
const version = "3.14.6";
declare function createUnimport(opts: Partial<UnimportOptions>): Unimport;
declare function installGlobalAutoImports(imports: Import[] | Unimport, options?: InstallGlobalOptions): Promise<any>;
declare function normalizeScanDirs(dirs: (string | ScanDir)[], options?: ScanDirExportsOptions): Required<ScanDir>[];
declare function scanFilesFromDir(dir: ScanDir | ScanDir[], options?: ScanDirExportsOptions): Promise<string[]>;
declare function scanDirExports(dirs: (string | ScanDir)[], options?: ScanDirExportsOptions): Promise<Import[]>;
declare function dedupeDtsExports(exports: Import[]): Import[];
declare function scanExports(filepath: string, includeTypes: boolean, seen?: Set<string>): Promise<Import[]>;
declare function resolvePreset(preset: Preset): Promise<Import[]>;
declare function resolveBuiltinPresets(presets: (BuiltinPresetName | Preset)[]): Promise<Import[]>;
declare const excludeRE: RegExp[];
declare const importAsRE: RegExp;
declare const separatorRE: RegExp;
/**
* | |
* destructing case&ternary non-call inheritance | id |
* ↓ ↓ ↓ ↓ | |
*/
declare const matchRE: RegExp;
declare function stripCommentsAndStrings(code: string, options?: StripLiteralOptions): string;
declare function defineUnimportPreset(preset: InlinePreset): InlinePreset;
declare function stringifyImports(imports: Import[], isCJS?: boolean): string;
declare function dedupeImports(imports: Import[], warn: (msg: string) => void): Import[];
declare function toExports(imports: Import[], fileDir?: string, includeType?: boolean): string;
declare function stripFileExtension(path: string): string;
declare function toTypeDeclarationItems(imports: Import[], options?: TypeDeclarationOptions): string[];
declare function toTypeDeclarationFile(imports: Import[], options?: TypeDeclarationOptions): string;
declare function toTypeReExports(imports: Import[], options?: TypeDeclarationOptions): string;
declare function getString(code: string | MagicString): string;
declare function getMagicString(code: string | MagicString): MagicString;
declare function addImportToCode(code: string | MagicString, imports: Import[], isCJS?: boolean, mergeExisting?: boolean, injectAtLast?: boolean, firstOccurrence?: number, onResolved?: (imports: Import[]) => void | Import[], onStringified?: (str: string, imports: Import[]) => void | string): MagicStringResult;
declare function normalizeImports(imports: Import[]): Import[];
declare function resolveIdAbsolute(id: string, parentId?: string): string;
/**
* @deprecated renamed to `stringifyImports`
*/
declare const toImports: typeof stringifyImports;
export { BuiltinPresetName, Import, InlinePreset, InstallGlobalOptions, MagicStringResult, Preset, ScanDir, ScanDirExportsOptions, TypeDeclarationOptions, Unimport, UnimportOptions, addImportToCode, createUnimport, dedupeDtsExports, dedupeImports, defineUnimportPreset, excludeRE, getMagicString, getString, importAsRE, installGlobalAutoImports, matchRE, normalizeImports, normalizeScanDirs, resolveBuiltinPresets, resolveIdAbsolute, resolvePreset, scanDirExports, scanExports, scanFilesFromDir, separatorRE, stringifyImports, stripCommentsAndStrings, stripFileExtension, toExports, toImports, toTypeDeclarationFile, toTypeDeclarationItems, toTypeReExports, version };

52
web/admin-spa/node_modules/unimport/dist/index.d.mts generated vendored Normal file
View File

@@ -0,0 +1,52 @@
export { v as vueTemplateAddon } from './shared/unimport.CzOA5cgj.mjs';
import { U as UnimportOptions, a as Unimport, I as Import, b as InstallGlobalOptions, S as ScanDir, c as ScanDirExportsOptions, P as Preset, B as BuiltinPresetName, d as InlinePreset, T as TypeDeclarationOptions, M as MagicStringResult } from './shared/unimport.CaVRR9SH.mjs';
export { r as Addon, n as AddonVueDirectivesOptions, A as AddonsOptions, D as DetectImportResult, h as ImportCommon, s as ImportInjectionResult, g as ImportName, p as InjectImportsOptions, l as InjectionUsageRecord, f as ModuleId, j as PackagePreset, o as PathFromResolver, i as PresetImport, q as Thenable, k as UnimportContext, m as UnimportMeta, e as builtinPresets } from './shared/unimport.CaVRR9SH.mjs';
import { StripLiteralOptions } from 'strip-literal';
import MagicString from 'magic-string';
import 'mlly';
const version = "3.14.6";
declare function createUnimport(opts: Partial<UnimportOptions>): Unimport;
declare function installGlobalAutoImports(imports: Import[] | Unimport, options?: InstallGlobalOptions): Promise<any>;
declare function normalizeScanDirs(dirs: (string | ScanDir)[], options?: ScanDirExportsOptions): Required<ScanDir>[];
declare function scanFilesFromDir(dir: ScanDir | ScanDir[], options?: ScanDirExportsOptions): Promise<string[]>;
declare function scanDirExports(dirs: (string | ScanDir)[], options?: ScanDirExportsOptions): Promise<Import[]>;
declare function dedupeDtsExports(exports: Import[]): Import[];
declare function scanExports(filepath: string, includeTypes: boolean, seen?: Set<string>): Promise<Import[]>;
declare function resolvePreset(preset: Preset): Promise<Import[]>;
declare function resolveBuiltinPresets(presets: (BuiltinPresetName | Preset)[]): Promise<Import[]>;
declare const excludeRE: RegExp[];
declare const importAsRE: RegExp;
declare const separatorRE: RegExp;
/**
* | |
* destructing case&ternary non-call inheritance | id |
* ↓ ↓ ↓ ↓ | |
*/
declare const matchRE: RegExp;
declare function stripCommentsAndStrings(code: string, options?: StripLiteralOptions): string;
declare function defineUnimportPreset(preset: InlinePreset): InlinePreset;
declare function stringifyImports(imports: Import[], isCJS?: boolean): string;
declare function dedupeImports(imports: Import[], warn: (msg: string) => void): Import[];
declare function toExports(imports: Import[], fileDir?: string, includeType?: boolean): string;
declare function stripFileExtension(path: string): string;
declare function toTypeDeclarationItems(imports: Import[], options?: TypeDeclarationOptions): string[];
declare function toTypeDeclarationFile(imports: Import[], options?: TypeDeclarationOptions): string;
declare function toTypeReExports(imports: Import[], options?: TypeDeclarationOptions): string;
declare function getString(code: string | MagicString): string;
declare function getMagicString(code: string | MagicString): MagicString;
declare function addImportToCode(code: string | MagicString, imports: Import[], isCJS?: boolean, mergeExisting?: boolean, injectAtLast?: boolean, firstOccurrence?: number, onResolved?: (imports: Import[]) => void | Import[], onStringified?: (str: string, imports: Import[]) => void | string): MagicStringResult;
declare function normalizeImports(imports: Import[]): Import[];
declare function resolveIdAbsolute(id: string, parentId?: string): string;
/**
* @deprecated renamed to `stringifyImports`
*/
declare const toImports: typeof stringifyImports;
export { BuiltinPresetName, Import, InlinePreset, InstallGlobalOptions, MagicStringResult, Preset, ScanDir, ScanDirExportsOptions, TypeDeclarationOptions, Unimport, UnimportOptions, addImportToCode, createUnimport, dedupeDtsExports, dedupeImports, defineUnimportPreset, excludeRE, getMagicString, getString, importAsRE, installGlobalAutoImports, matchRE, normalizeImports, normalizeScanDirs, resolveBuiltinPresets, resolveIdAbsolute, resolvePreset, scanDirExports, scanExports, scanFilesFromDir, separatorRE, stringifyImports, stripCommentsAndStrings, stripFileExtension, toExports, toImports, toTypeDeclarationFile, toTypeDeclarationItems, toTypeReExports, version };

52
web/admin-spa/node_modules/unimport/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,52 @@
export { v as vueTemplateAddon } from './shared/unimport.BGSZL1Hy.js';
import { U as UnimportOptions, a as Unimport, I as Import, b as InstallGlobalOptions, S as ScanDir, c as ScanDirExportsOptions, P as Preset, B as BuiltinPresetName, d as InlinePreset, T as TypeDeclarationOptions, M as MagicStringResult } from './shared/unimport.CaVRR9SH.js';
export { r as Addon, n as AddonVueDirectivesOptions, A as AddonsOptions, D as DetectImportResult, h as ImportCommon, s as ImportInjectionResult, g as ImportName, p as InjectImportsOptions, l as InjectionUsageRecord, f as ModuleId, j as PackagePreset, o as PathFromResolver, i as PresetImport, q as Thenable, k as UnimportContext, m as UnimportMeta, e as builtinPresets } from './shared/unimport.CaVRR9SH.js';
import { StripLiteralOptions } from 'strip-literal';
import MagicString from 'magic-string';
import 'mlly';
const version = "3.14.6";
declare function createUnimport(opts: Partial<UnimportOptions>): Unimport;
declare function installGlobalAutoImports(imports: Import[] | Unimport, options?: InstallGlobalOptions): Promise<any>;
declare function normalizeScanDirs(dirs: (string | ScanDir)[], options?: ScanDirExportsOptions): Required<ScanDir>[];
declare function scanFilesFromDir(dir: ScanDir | ScanDir[], options?: ScanDirExportsOptions): Promise<string[]>;
declare function scanDirExports(dirs: (string | ScanDir)[], options?: ScanDirExportsOptions): Promise<Import[]>;
declare function dedupeDtsExports(exports: Import[]): Import[];
declare function scanExports(filepath: string, includeTypes: boolean, seen?: Set<string>): Promise<Import[]>;
declare function resolvePreset(preset: Preset): Promise<Import[]>;
declare function resolveBuiltinPresets(presets: (BuiltinPresetName | Preset)[]): Promise<Import[]>;
declare const excludeRE: RegExp[];
declare const importAsRE: RegExp;
declare const separatorRE: RegExp;
/**
* | |
* destructing case&ternary non-call inheritance | id |
* ↓ ↓ ↓ ↓ | |
*/
declare const matchRE: RegExp;
declare function stripCommentsAndStrings(code: string, options?: StripLiteralOptions): string;
declare function defineUnimportPreset(preset: InlinePreset): InlinePreset;
declare function stringifyImports(imports: Import[], isCJS?: boolean): string;
declare function dedupeImports(imports: Import[], warn: (msg: string) => void): Import[];
declare function toExports(imports: Import[], fileDir?: string, includeType?: boolean): string;
declare function stripFileExtension(path: string): string;
declare function toTypeDeclarationItems(imports: Import[], options?: TypeDeclarationOptions): string[];
declare function toTypeDeclarationFile(imports: Import[], options?: TypeDeclarationOptions): string;
declare function toTypeReExports(imports: Import[], options?: TypeDeclarationOptions): string;
declare function getString(code: string | MagicString): string;
declare function getMagicString(code: string | MagicString): MagicString;
declare function addImportToCode(code: string | MagicString, imports: Import[], isCJS?: boolean, mergeExisting?: boolean, injectAtLast?: boolean, firstOccurrence?: number, onResolved?: (imports: Import[]) => void | Import[], onStringified?: (str: string, imports: Import[]) => void | string): MagicStringResult;
declare function normalizeImports(imports: Import[]): Import[];
declare function resolveIdAbsolute(id: string, parentId?: string): string;
/**
* @deprecated renamed to `stringifyImports`
*/
declare const toImports: typeof stringifyImports;
export { BuiltinPresetName, Import, InlinePreset, InstallGlobalOptions, MagicStringResult, Preset, ScanDir, ScanDirExportsOptions, TypeDeclarationOptions, Unimport, UnimportOptions, addImportToCode, createUnimport, dedupeDtsExports, dedupeImports, defineUnimportPreset, excludeRE, getMagicString, getString, importAsRE, installGlobalAutoImports, matchRE, normalizeImports, normalizeScanDirs, resolveBuiltinPresets, resolveIdAbsolute, resolvePreset, scanDirExports, scanExports, scanFilesFromDir, separatorRE, stringifyImports, stripCommentsAndStrings, stripFileExtension, toExports, toImports, toTypeDeclarationFile, toTypeDeclarationItems, toTypeReExports, version };

39
web/admin-spa/node_modules/unimport/dist/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,39 @@
export { b as builtinPresets, c as createUnimport, e as dedupeDtsExports, n as normalizeScanDirs, r as resolveBuiltinPresets, a as resolvePreset, d as scanDirExports, f as scanExports, s as scanFilesFromDir, v as version } from './shared/unimport.Ww9aF1N_.mjs';
export { o as addImportToCode, f as dedupeImports, d as defineUnimportPreset, e as excludeRE, n as getMagicString, l as getString, i as importAsRE, m as matchRE, p as normalizeImports, r as resolveIdAbsolute, s as separatorRE, c as stringifyImports, b as stripCommentsAndStrings, g as stripFileExtension, t as toExports, q as toImports, j as toTypeDeclarationFile, h as toTypeDeclarationItems, k as toTypeReExports, a as vueTemplateAddon } from './shared/unimport.0aitavbJ.mjs';
import 'mlly';
import 'node:fs';
import 'node:fs/promises';
import 'node:process';
import 'node:url';
import 'fast-glob';
import 'pathe';
import 'picomatch';
import 'scule';
import 'node:os';
import 'pkg-types';
import 'local-pkg';
import 'node:path';
import 'magic-string';
import 'strip-literal';
async function installGlobalAutoImports(imports, options = {}) {
const {
globalObject = globalThis,
overrides = false
} = options;
imports = Array.isArray(imports) ? imports : await imports.getImports();
await Promise.all(
imports.map(async (i) => {
if (i.disabled || i.type)
return;
const as = i.as || i.name;
if (overrides || !(as in globalObject)) {
const module = await import(i.from);
globalObject[as] = module[i.name];
}
})
);
return globalObject;
}
export { installGlobalAutoImports };

View File

@@ -0,0 +1,546 @@
import { basename } from 'node:path';
import process from 'node:process';
import { isAbsolute, relative, resolve } from 'pathe';
import { camelCase, kebabCase } from 'scule';
import MagicString from 'magic-string';
import { resolvePathSync, findStaticImports, parseStaticImport } from 'mlly';
import { stripLiteral } from 'strip-literal';
const excludeRE = [
// imported/exported from other module
/\b(import|export)\b([\w$*{},\s]+?)\bfrom\s*["']/g,
// defined as function
/\bfunction\s*([\w$]+)\s*\(/g,
// defined as class
/\bclass\s*([\w$]+)\s*\{/g,
// defined as local variable
// eslint-disable-next-line regexp/no-super-linear-backtracking
/\b(?:const|let|var)\s+?(\[.*?\]|\{.*?\}|.+?)\s*?[=;\n]/gs
];
const importAsRE = /^.*\sas\s+/;
const separatorRE = /[,[\]{}\n]|\b(?:import|export)\b/g;
const matchRE = /(^|\.\.\.|(?:\bcase|\?)\s+|[^\w$/)]|\bextends\s+)([\w$]+)\s*(?=[.()[\]}:;?+\-*&|`<>,\n]|\b(?:instanceof|in)\b|$|(?<=extends\s+\w+)\s+\{)/g;
const regexRE = /\/\S*?(?<!\\)(?<!\[[^\]]*)\/[gimsuy]*/g;
function stripCommentsAndStrings(code, options) {
return stripLiteral(code, options).replace(regexRE, 'new RegExp("")');
}
function defineUnimportPreset(preset) {
return preset;
}
const safePropertyName = /^[a-z$_][\w$]*$/i;
function stringifyWith(withValues) {
let withDefs = "";
for (let entries = Object.entries(withValues), l = entries.length, i = 0; i < l; i++) {
const [prop, value] = entries[i];
withDefs += safePropertyName.test(prop) ? prop : JSON.stringify(prop);
withDefs += `: ${JSON.stringify(String(value))}`;
if (i + 1 !== l)
withDefs += ", ";
}
return `{ ${withDefs} }`;
}
function stringifyImports(imports, isCJS = false) {
const map = toImportModuleMap(imports);
return Object.entries(map).flatMap(([name, importSet]) => {
const entries = [];
const imports2 = Array.from(importSet).filter((i) => {
if (!i.name || i.as === "") {
let importStr;
if (isCJS) {
importStr = `require('${name}');`;
} else {
importStr = `import '${name}'`;
if (i.with)
importStr += ` with ${stringifyWith(i.with)}`;
importStr += ";";
}
entries.push(importStr);
return false;
} else if (i.name === "default" || i.name === "=") {
let importStr;
if (isCJS) {
importStr = i.name === "=" ? `const ${i.as} = require('${name}');` : `const { default: ${i.as} } = require('${name}');`;
} else {
importStr = `import ${i.as} from '${name}'`;
if (i.with)
importStr += ` with ${stringifyWith(i.with)}`;
importStr += ";";
}
entries.push(importStr);
return false;
} else if (i.name === "*") {
let importStr;
if (isCJS) {
importStr = `const ${i.as} = require('${name}');`;
} else {
importStr = `import * as ${i.as} from '${name}'`;
if (i.with)
importStr += ` with ${stringifyWith(i.with)}`;
importStr += ";";
}
entries.push(importStr);
return false;
} else if (!isCJS && i.with) {
entries.push(`import { ${stringifyImportAlias(i)} } from '${name}' with ${stringifyWith(i.with)};`);
return false;
}
return true;
});
if (imports2.length) {
const importsAs = imports2.map((i) => stringifyImportAlias(i, isCJS));
entries.push(
isCJS ? `const { ${importsAs.join(", ")} } = require('${name}');` : `import { ${importsAs.join(", ")} } from '${name}';`
);
}
return entries;
}).join("\n");
}
function dedupeImports(imports, warn) {
const map = /* @__PURE__ */ new Map();
const indexToRemove = /* @__PURE__ */ new Set();
imports.filter((i) => !i.disabled).forEach((i, idx) => {
if (i.declarationType === "enum" || i.declarationType === "class")
return;
const name = i.as ?? i.name;
if (!map.has(name)) {
map.set(name, idx);
return;
}
const other = imports[map.get(name)];
if (other.from === i.from) {
indexToRemove.add(idx);
return;
}
const diff = (other.priority || 1) - (i.priority || 1);
if (diff === 0)
warn(`Duplicated imports "${name}", the one from "${other.from}" has been ignored and "${i.from}" is used`);
if (diff <= 0) {
indexToRemove.add(map.get(name));
map.set(name, idx);
} else {
indexToRemove.add(idx);
}
});
return imports.filter((_, idx) => !indexToRemove.has(idx));
}
function toExports(imports, fileDir, includeType = false) {
const map = toImportModuleMap(imports, includeType);
return Object.entries(map).flatMap(([name, imports2]) => {
if (isFilePath(name))
name = name.replace(/\.[a-z]+$/i, "");
if (fileDir && isAbsolute(name)) {
name = relative(fileDir, name);
if (!name.match(/^[./]/))
name = `./${name}`;
}
const entries = [];
const filtered = Array.from(imports2).filter((i) => {
if (i.name === "*") {
entries.push(`export * as ${i.as} from '${name}';`);
return false;
}
return true;
});
if (filtered.length)
entries.push(`export { ${filtered.map((i) => stringifyImportAlias(i, false)).join(", ")} } from '${name}';`);
return entries;
}).join("\n");
}
function stripFileExtension(path) {
return path.replace(/\.[a-z]+$/i, "");
}
function toTypeDeclarationItems(imports, options) {
return imports.map((i) => {
const from = options?.resolvePath?.(i) || stripFileExtension(i.typeFrom || i.from);
let typeDef = "";
if (i.with)
typeDef += `import('${from}', { with: ${stringifyWith(i.with)} })`;
else
typeDef += `import('${from}')`;
if (i.name !== "*" && i.name !== "=")
typeDef += `['${i.name}']`;
return `const ${i.as}: typeof ${typeDef}`;
}).sort();
}
function toTypeDeclarationFile(imports, options) {
const items = toTypeDeclarationItems(imports, options);
const {
exportHelper = true
} = options || {};
let declaration = "";
if (exportHelper)
declaration += "export {}\n";
declaration += `declare global {
${items.map((i) => ` ${i}`).join("\n")}
}`;
return declaration;
}
function makeTypeModulesMap(imports, resolvePath) {
const modulesMap = /* @__PURE__ */ new Map();
const resolveImportFrom = typeof resolvePath === "function" ? (i) => {
return resolvePath(i) || stripFileExtension(i.typeFrom || i.from);
} : (i) => stripFileExtension(i.typeFrom || i.from);
for (const import_ of imports) {
const from = resolveImportFrom(import_);
let module = modulesMap.get(from);
if (!module) {
module = { typeImports: /* @__PURE__ */ new Set(), starTypeImport: undefined };
modulesMap.set(from, module);
}
if (import_.name === "*") {
if (import_.as)
module.starTypeImport = import_;
} else {
module.typeImports.add(import_);
}
}
return modulesMap;
}
function toTypeReExports(imports, options) {
const importsMap = makeTypeModulesMap(imports, options?.resolvePath);
const code = Array.from(importsMap).flatMap(([from, module]) => {
from = from.replace(/\.d\.([cm]?)ts$/i, ".$1js");
const { starTypeImport, typeImports } = module;
const strings = [];
if (typeImports.size) {
const typeImportNames = Array.from(typeImports).map(({ name, as }) => {
if (as && as !== name)
return `${name} as ${as}`;
return name;
});
strings.push(
"// @ts-ignore",
`export type { ${typeImportNames.join(", ")} } from '${from}'`
);
}
if (starTypeImport) {
strings.push(
"// @ts-ignore",
`export type * as ${starTypeImport.as} from '${from}'`
);
}
if (strings.length) {
strings.push(
// This is a workaround for a TypeScript issue where type-only re-exports are not properly initialized.
`import('${from}')`
);
}
return strings;
});
return `// for type re-export
declare global {
${code.map((i) => ` ${i}`).join("\n")}
}`;
}
function stringifyImportAlias(item, isCJS = false) {
return item.as === undefined || item.name === item.as ? item.name : isCJS ? `${item.name}: ${item.as}` : `${item.name} as ${item.as}`;
}
function toImportModuleMap(imports, includeType = false) {
const map = {};
for (const _import of imports) {
if (_import.type && !includeType)
continue;
if (!map[_import.from])
map[_import.from] = /* @__PURE__ */ new Set();
map[_import.from].add(_import);
}
return map;
}
function getString(code) {
if (typeof code === "string")
return code;
return code.toString();
}
function getMagicString(code) {
if (typeof code === "string")
return new MagicString(code);
return code;
}
function addImportToCode(code, imports, isCJS = false, mergeExisting = false, injectAtLast = false, firstOccurrence = Number.POSITIVE_INFINITY, onResolved, onStringified) {
let newImports = [];
const s = getMagicString(code);
let _staticImports;
const strippedCode = stripCommentsAndStrings(s.original);
function findStaticImportsLazy() {
if (!_staticImports) {
_staticImports = findStaticImports(s.original).filter((i) => Boolean(strippedCode.slice(i.start, i.end).trim())).map((i) => parseStaticImport(i));
}
return _staticImports;
}
function hasShebang() {
const shebangRegex = /^#!.+/;
return shebangRegex.test(s.original);
}
if (mergeExisting && !isCJS) {
const existingImports = findStaticImportsLazy();
const map = /* @__PURE__ */ new Map();
imports.forEach((i) => {
const target = existingImports.find((e) => e.specifier === i.from && e.imports.startsWith("{"));
if (!target)
return newImports.push(i);
if (!map.has(target))
map.set(target, []);
map.get(target).push(i);
});
for (const [target, items] of map.entries()) {
const strings = items.map((i) => `${stringifyImportAlias(i)}, `);
const importLength = target.code.match(/^\s*import\s*\{/)?.[0]?.length;
if (importLength)
s.appendLeft(target.start + importLength, ` ${strings.join("").trim()}`);
}
} else {
newImports = imports;
}
newImports = onResolved?.(newImports) ?? newImports;
let newEntries = stringifyImports(newImports, isCJS);
newEntries = onStringified?.(newEntries, newImports) ?? newEntries;
if (newEntries) {
const insertionIndex = injectAtLast ? findStaticImportsLazy().reverse().find((i) => i.end <= firstOccurrence)?.end ?? 0 : 0;
if (insertionIndex > 0)
s.appendRight(insertionIndex, `
${newEntries}
`);
else if (hasShebang())
s.appendLeft(s.original.indexOf("\n") + 1, `
${newEntries}
`);
else
s.prepend(`${newEntries}
`);
}
return {
s,
get code() {
return s.toString();
}
};
}
function normalizeImports(imports) {
for (const _import of imports)
_import.as = _import.as ?? _import.name;
return imports;
}
function resolveIdAbsolute(id, parentId) {
return resolvePathSync(id, {
url: parentId
});
}
function isFilePath(path) {
return path.startsWith(".") || isAbsolute(path) || path.includes("://");
}
const toImports = stringifyImports;
const contextRE$1 = /\b_ctx\.([$\w]+)\b/g;
const UNREF_KEY = "__unimport_unref_";
const VUE_TEMPLATE_NAME = "unimport:vue-template";
function vueTemplateAddon() {
const self = {
name: VUE_TEMPLATE_NAME,
async transform(s, id) {
if (!s.original.includes("_ctx.") || s.original.includes(UNREF_KEY))
return s;
const matches = Array.from(s.original.matchAll(contextRE$1));
const imports = await this.getImports();
let targets = [];
for (const match of matches) {
const name = match[1];
const item = imports.find((i) => i.as === name);
if (!item)
continue;
const start = match.index;
const end = start + match[0].length;
const tempName = `__unimport_${name}`;
s.overwrite(start, end, `(${JSON.stringify(name)} in _ctx ? _ctx.${name} : ${UNREF_KEY}(${tempName}))`);
if (!targets.find((i) => i.as === tempName)) {
targets.push({
...item,
as: tempName
});
}
}
if (targets.length) {
targets.push({
name: "unref",
from: "vue",
as: UNREF_KEY
});
for (const addon of this.addons) {
if (addon === self)
continue;
targets = await addon.injectImportsResolved?.call(this, targets, s, id) ?? targets;
}
let injection = stringifyImports(targets);
for (const addon of this.addons) {
if (addon === self)
continue;
injection = await addon.injectImportsStringified?.call(this, injection, targets, s, id) ?? injection;
}
s.prepend(injection);
}
return s;
},
async declaration(dts, options) {
const imports = await this.getImports();
const items = imports.map((i) => {
if (i.type || i.dtsDisabled)
return "";
const from = options?.resolvePath?.(i) || i.from;
return `readonly ${i.as}: UnwrapRef<typeof import('${from}')${i.name !== "*" ? `['${i.name}']` : ""}>`;
}).filter(Boolean).sort();
const extendItems = items.map((i) => ` ${i}`).join("\n");
return `${dts}
// for vue template auto import
import { UnwrapRef } from 'vue'
declare module 'vue' {
interface ComponentCustomProperties {
${extendItems}
}
}`;
}
};
return self;
}
const contextRE = /resolveDirective as _resolveDirective/;
const contextText = `${contextRE.source}, `;
const directiveRE = /(?:var|const) (\w+) = _resolveDirective\("([\w.-]+)"\);?\s*/g;
const VUE_DIRECTIVES_NAME = "unimport:vue-directives";
function vueDirectivesAddon(options = {}) {
function isDirective(importEntry) {
let isDirective2 = importEntry.meta?.vueDirective === true;
if (isDirective2) {
return true;
}
isDirective2 = options.isDirective?.(normalizePath(process.cwd(), importEntry.from), importEntry) ?? false;
if (isDirective2) {
importEntry.meta ??= {};
importEntry.meta.vueDirective = true;
}
return isDirective2;
}
const self = {
name: VUE_DIRECTIVES_NAME,
async transform(s, id) {
if (!s.original.match(contextRE))
return s;
const matches = Array.from(s.original.matchAll(directiveRE)).sort((a, b) => b.index - a.index);
if (!matches.length)
return s;
let targets = [];
for await (const [
begin,
end,
importEntry
] of findDirectives(
isDirective,
matches,
this.getImports()
)) {
s.overwrite(begin, end, "");
targets.push(importEntry);
}
if (!targets.length)
return s;
s.replace(contextText, "");
for (const addon of this.addons) {
if (addon === self)
continue;
targets = await addon.injectImportsResolved?.call(this, targets, s, id) ?? targets;
}
let injection = stringifyImports(targets);
for (const addon of this.addons) {
if (addon === self)
continue;
injection = await addon.injectImportsStringified?.call(this, injection, targets, s, id) ?? injection;
}
s.prepend(injection);
return s;
},
async declaration(dts, options2) {
const directivesMap = await this.getImports().then((imports) => {
return imports.filter(isDirective).reduce((acc, i) => {
if (i.type || i.dtsDisabled)
return acc;
let name;
if (i.name === "default" && (i.as === "default" || !i.as)) {
const file = basename(i.from);
const idx = file.indexOf(".");
name = idx > -1 ? file.slice(0, idx) : file;
} else {
name = i.as ?? i.name;
}
name = name[0] === "v" ? camelCase(name) : camelCase(`v-${name}`);
if (!acc.has(name)) {
acc.set(name, i);
}
return acc;
}, /* @__PURE__ */ new Map());
});
if (!directivesMap.size)
return dts;
const directives = Array.from(directivesMap.entries()).map(([name, i]) => ` ${name}: typeof import('${options2?.resolvePath?.(i) || i.from}')['${i.name}']`).sort().join("\n");
return `${dts}
// for vue directives auto import
declare module 'vue' {
interface ComponentCustomProperties {
${directives}
}
interface GlobalDirectives {
${directives}
}
}`;
}
};
return self;
}
function resolvePath(cwd, path) {
return path[0] === "." ? resolve(cwd, path) : path;
}
function normalizePath(cwd, path) {
return resolvePath(cwd, path).replace(/\\/g, "/");
}
async function* findDirectives(isDirective, regexArray, importsPromise) {
const imports = (await importsPromise).filter(isDirective);
if (!imports.length)
return;
const symbols = regexArray.reduce((acc, regex) => {
const [all, symbol, resolveDirectiveName] = regex;
if (acc.has(symbol))
return acc;
acc.set(symbol, [
regex.index,
regex.index + all.length,
kebabCase(resolveDirectiveName)
]);
return acc;
}, /* @__PURE__ */ new Map());
for (const [symbol, data] of symbols.entries()) {
yield* findDirective(imports, symbol, data);
}
}
function* findDirective(imports, symbol, [begin, end, importName]) {
let resolvedName;
for (const i of imports) {
if (i.name === "default" && (i.as === "default" || !i.as)) {
const file = basename(i.from);
const idx = file.indexOf(".");
resolvedName = kebabCase(idx > -1 ? file.slice(0, idx) : file);
} else {
resolvedName = kebabCase(i.as ?? i.name);
}
if (resolvedName[0] === "v") {
resolvedName = resolvedName.slice(resolvedName[1] === "-" ? 2 : 1);
}
if (resolvedName === importName) {
yield [
begin,
end,
{ ...i, name: i.name, as: symbol }
];
return;
}
}
}
export { VUE_TEMPLATE_NAME as V, vueTemplateAddon as a, stripCommentsAndStrings as b, stringifyImports as c, defineUnimportPreset as d, excludeRE as e, dedupeImports as f, stripFileExtension as g, toTypeDeclarationItems as h, importAsRE as i, toTypeDeclarationFile as j, toTypeReExports as k, getString as l, matchRE as m, getMagicString as n, addImportToCode as o, normalizeImports as p, toImports as q, resolveIdAbsolute as r, separatorRE as s, toExports as t, VUE_DIRECTIVES_NAME as u, vueDirectivesAddon as v };

View File

@@ -0,0 +1,5 @@
import { r as Addon } from './unimport.CaVRR9SH.js';
declare function vueTemplateAddon(): Addon;
export { vueTemplateAddon as v };

View File

@@ -0,0 +1,400 @@
import MagicString from 'magic-string';
import { ESMExport } from 'mlly';
declare const builtinPresets: {
'@vue/composition-api': InlinePreset;
'@vueuse/core': () => Preset;
'@vueuse/head': InlinePreset;
pinia: InlinePreset;
preact: InlinePreset;
quasar: InlinePreset;
react: InlinePreset;
'react-router': InlinePreset;
'react-router-dom': InlinePreset;
svelte: InlinePreset;
'svelte/animate': InlinePreset;
'svelte/easing': InlinePreset;
'svelte/motion': InlinePreset;
'svelte/store': InlinePreset;
'svelte/transition': InlinePreset;
'vee-validate': InlinePreset;
vitepress: InlinePreset;
'vue-demi': InlinePreset;
'vue-i18n': InlinePreset;
'vue-router': InlinePreset;
'vue-router-composables': InlinePreset;
vue: InlinePreset;
'vue/macros': InlinePreset;
vuex: InlinePreset;
vitest: InlinePreset;
'uni-app': InlinePreset;
'solid-js': InlinePreset;
'solid-app-router': InlinePreset;
rxjs: InlinePreset;
'date-fns': InlinePreset;
};
type BuiltinPresetName = keyof typeof builtinPresets;
type ModuleId = string;
type ImportName = string;
interface ImportCommon {
/** Module specifier to import from */
from: ModuleId;
/**
* Priority of the import, if multiple imports have the same name, the one with the highest priority will be used
* @default 1
*/
priority?: number;
/** If this import is disabled */
disabled?: boolean;
/** Won't output import in declaration file if true */
dtsDisabled?: boolean;
/** Import declaration type like const / var / enum */
declarationType?: ESMExport['declarationType'];
/**
* Metadata of the import
*/
meta?: {
/** Short description of the import */
description?: string;
/** URL to the documentation */
docsUrl?: string;
/** Additional metadata */
[key: string]: any;
};
/**
* If this import is a pure type import
*/
type?: boolean;
/**
* Using this as the from when generating type declarations
*/
typeFrom?: ModuleId;
}
interface Import extends ImportCommon {
/** Import name to be detected */
name: ImportName;
/** Import as this name */
as?: ImportName;
/**
* With properties
*
* Ignored for CJS imports.
*/
with?: Record<string, string>;
}
type PresetImport = Omit<Import, 'from'> | ImportName | [name: ImportName, as?: ImportName, from?: ModuleId];
interface InlinePreset extends ImportCommon {
imports: (PresetImport | InlinePreset)[];
}
/**
* Auto extract exports from a package for auto import
*/
interface PackagePreset {
/**
* Name of the package
*/
package: string;
/**
* Path of the importer
* @default process.cwd()
*/
url?: string;
/**
* RegExp, string, or custom function to exclude names of the extracted imports
*/
ignore?: (string | RegExp | ((name: string) => boolean))[];
/**
* Use local cache if exits
* @default true
*/
cache?: boolean;
}
type Preset = InlinePreset | PackagePreset;
interface UnimportContext {
readonly version: string;
options: Partial<UnimportOptions>;
staticImports: Import[];
dynamicImports: Import[];
addons: Addon[];
getImports: () => Promise<Import[]>;
getImportMap: () => Promise<Map<string, Import>>;
getMetadata: () => UnimportMeta | undefined;
modifyDynamicImports: (fn: (imports: Import[]) => Thenable<void | Import[]>) => Promise<void>;
clearDynamicImports: () => void;
replaceImports: (imports: UnimportOptions['imports']) => Promise<Import[]>;
invalidate: () => void;
resolveId: (id: string, parentId?: string) => Thenable<string | null | undefined | void>;
}
interface DetectImportResult {
s: MagicString;
strippedCode: string;
isCJSContext: boolean;
matchedImports: Import[];
firstOccurrence: number;
}
interface Unimport {
readonly version: string;
init: () => Promise<void>;
clearDynamicImports: UnimportContext['clearDynamicImports'];
getImportMap: UnimportContext['getImportMap'];
getImports: UnimportContext['getImports'];
getInternalContext: () => UnimportContext;
getMetadata: UnimportContext['getMetadata'];
modifyDynamicImports: UnimportContext['modifyDynamicImports'];
generateTypeDeclarations: (options?: TypeDeclarationOptions) => Promise<string>;
/**
* Get un-imported usages from code
*/
detectImports: (code: string | MagicString) => Promise<DetectImportResult>;
/**
* Insert missing imports statements to code
*/
injectImports: (code: string | MagicString, id?: string, options?: InjectImportsOptions) => Promise<ImportInjectionResult>;
scanImportsFromDir: (dir?: (string | ScanDir)[], options?: ScanDirExportsOptions) => Promise<Import[]>;
scanImportsFromFile: (file: string, includeTypes?: boolean) => Promise<Import[]>;
/**
* @deprecated
*/
toExports: (filepath?: string, includeTypes?: boolean) => Promise<string>;
}
interface InjectionUsageRecord {
import: Import;
count: number;
moduleIds: string[];
}
interface UnimportMeta {
injectionUsage: Record<string, InjectionUsageRecord>;
}
interface AddonsOptions {
addons?: Addon[];
/**
* Enable auto import inside for Vue's <template>
*
* @default false
*/
vueTemplate?: boolean;
/**
* Enable auto import directives for Vue's SFC.
*
* Library authors should include `meta.vueDirective: true` in the import metadata.
*
* When using a local directives folder, provide the `isDirective`
* callback to check if the import is a Vue directive.
*/
vueDirectives?: true | AddonVueDirectivesOptions;
}
interface AddonVueDirectivesOptions {
/**
* Checks if the import is a Vue directive.
*
* **NOTES**:
* - imports from a library should include `meta.vueDirective: true`.
* - this callback is only invoked for local directives (only when meta.vueDirective is not set).
*
* @param from The path of the import normalized.
* @param importEntry The import entry.
*/
isDirective?: (from: string, importEntry: Import) => boolean;
}
interface UnimportOptions extends Pick<InjectImportsOptions, 'injectAtEnd' | 'mergeExisting' | 'parser'> {
/**
* Auto import items
*/
imports: Import[];
/**
* Auto import preset
*/
presets: (Preset | BuiltinPresetName)[];
/**
* Custom warning function
* @default console.warn
*/
warn: (msg: string) => void;
/**
* Custom debug log function
* @default console.log
*/
debugLog: (msg: string) => void;
/**
* Unimport Addons.
* To use built-in addons, use:
* ```js
* addons: {
* addons: [<custom-addons-here>] // if you want to use also custom addons
* vueTemplate: true,
* vueDirectives: [<the-directives-here>]
* }
* ```
*
* Built-in addons:
* - vueDirectives: enable auto import directives for Vue's SFC
* - vueTemplate: enable auto import inside for Vue's <template>
*
* @default {}
*/
addons: AddonsOptions | Addon[];
/**
* Name of virtual modules that exposed all the registed auto-imports
* @default []
*/
virtualImports: string[];
/**
* Directories to scan for auto import
* @default []
*/
dirs?: (string | ScanDir)[];
/**
* Options for scanning directories for auto import
*/
dirsScanOptions?: ScanDirExportsOptions;
/**
* Custom resolver to auto import id
*/
resolveId?: (id: string, importee?: string) => Thenable<string | void>;
/**
* Custom magic comments to be opt-out for auto import, per file/module
*
* @default ['@unimport-disable', '@imports-disable']
*/
commentsDisable?: string[];
/**
* Custom magic comments to debug auto import, printed to console
*
* @default ['@unimport-debug', '@imports-debug']
*/
commentsDebug?: string[];
/**
* Collect meta data for each auto import. Accessible via `ctx.meta`
*/
collectMeta?: boolean;
}
type PathFromResolver = (_import: Import) => string | undefined;
interface ScanDirExportsOptions {
/**
* Glob patterns for matching files
*
* @default ['*.{ts,js,mjs,cjs,mts,cts}']
*/
filePatterns?: string[];
/**
* Custom function to filter scanned files
*/
fileFilter?: (file: string) => boolean;
/**
* Register type exports
*
* @default true
*/
types?: boolean;
/**
* Current working directory
*
* @default process.cwd()
*/
cwd?: string;
}
interface ScanDir {
/**
* Path pattern of the directory
*/
glob: string;
/**
* Register type exports
*
* @default true
*/
types?: boolean;
}
interface TypeDeclarationOptions {
/**
* Custom resolver for path of the import
*/
resolvePath?: PathFromResolver;
/**
* Append `export {}` to the end of the file
*
* @default true
*/
exportHelper?: boolean;
/**
* Auto-import for type exports
*
* @default true
*/
typeReExports?: boolean;
}
interface InjectImportsOptions {
/**
* Merge the existing imports
*
* @default false
*/
mergeExisting?: boolean;
/**
* If the module should be auto imported
*
* @default true
*/
autoImport?: boolean;
/**
* If the module should be transformed for virtual modules.
* Only available when `virtualImports` is set.
*
* @default true
*/
transformVirtualImports?: boolean;
/**
* Parser to use for parsing the code
*
* Note that `acorn` only takes valid JS Code, should usually only be used after transformationa and transpilation
*
* @default 'regex'
*/
parser?: 'acorn' | 'regex';
/**
* Inject the imports at the end of other imports
*
* @default false
*/
injectAtEnd?: boolean;
}
type Thenable<T> = Promise<T> | T;
interface Addon {
name?: string;
transform?: (this: UnimportContext, code: MagicString, id: string | undefined) => Thenable<MagicString>;
declaration?: (this: UnimportContext, dts: string, options: TypeDeclarationOptions) => Thenable<string>;
matchImports?: (this: UnimportContext, identifiers: Set<string>, matched: Import[]) => Thenable<Import[] | void>;
/**
* Extend or modify the imports list before injecting
*/
extendImports?: (this: UnimportContext, imports: Import[]) => Import[] | void;
/**
* Resolve imports before injecting
*/
injectImportsResolved?: (this: UnimportContext, imports: Import[], code: MagicString, id?: string) => Import[] | void;
/**
* Modify the injection code before injecting
*/
injectImportsStringified?: (this: UnimportContext, injection: string, imports: Import[], code: MagicString, id?: string) => string | void;
}
interface InstallGlobalOptions {
/**
* @default globalThis
*/
globalObject?: any;
/**
* Overrides the existing property
* @default false
*/
overrides?: boolean;
}
interface MagicStringResult {
s: MagicString;
code: string;
}
interface ImportInjectionResult extends MagicStringResult {
imports: Import[];
}
export { type AddonsOptions as A, type BuiltinPresetName as B, type DetectImportResult as D, type Import as I, type MagicStringResult as M, type Preset as P, type ScanDir as S, type TypeDeclarationOptions as T, type UnimportOptions as U, type Unimport as a, type InstallGlobalOptions as b, type ScanDirExportsOptions as c, type InlinePreset as d, builtinPresets as e, type ModuleId as f, type ImportName as g, type ImportCommon as h, type PresetImport as i, type PackagePreset as j, type UnimportContext as k, type InjectionUsageRecord as l, type UnimportMeta as m, type AddonVueDirectivesOptions as n, type PathFromResolver as o, type InjectImportsOptions as p, type Thenable as q, type Addon as r, type ImportInjectionResult as s };

View File

@@ -0,0 +1,400 @@
import MagicString from 'magic-string';
import { ESMExport } from 'mlly';
declare const builtinPresets: {
'@vue/composition-api': InlinePreset;
'@vueuse/core': () => Preset;
'@vueuse/head': InlinePreset;
pinia: InlinePreset;
preact: InlinePreset;
quasar: InlinePreset;
react: InlinePreset;
'react-router': InlinePreset;
'react-router-dom': InlinePreset;
svelte: InlinePreset;
'svelte/animate': InlinePreset;
'svelte/easing': InlinePreset;
'svelte/motion': InlinePreset;
'svelte/store': InlinePreset;
'svelte/transition': InlinePreset;
'vee-validate': InlinePreset;
vitepress: InlinePreset;
'vue-demi': InlinePreset;
'vue-i18n': InlinePreset;
'vue-router': InlinePreset;
'vue-router-composables': InlinePreset;
vue: InlinePreset;
'vue/macros': InlinePreset;
vuex: InlinePreset;
vitest: InlinePreset;
'uni-app': InlinePreset;
'solid-js': InlinePreset;
'solid-app-router': InlinePreset;
rxjs: InlinePreset;
'date-fns': InlinePreset;
};
type BuiltinPresetName = keyof typeof builtinPresets;
type ModuleId = string;
type ImportName = string;
interface ImportCommon {
/** Module specifier to import from */
from: ModuleId;
/**
* Priority of the import, if multiple imports have the same name, the one with the highest priority will be used
* @default 1
*/
priority?: number;
/** If this import is disabled */
disabled?: boolean;
/** Won't output import in declaration file if true */
dtsDisabled?: boolean;
/** Import declaration type like const / var / enum */
declarationType?: ESMExport['declarationType'];
/**
* Metadata of the import
*/
meta?: {
/** Short description of the import */
description?: string;
/** URL to the documentation */
docsUrl?: string;
/** Additional metadata */
[key: string]: any;
};
/**
* If this import is a pure type import
*/
type?: boolean;
/**
* Using this as the from when generating type declarations
*/
typeFrom?: ModuleId;
}
interface Import extends ImportCommon {
/** Import name to be detected */
name: ImportName;
/** Import as this name */
as?: ImportName;
/**
* With properties
*
* Ignored for CJS imports.
*/
with?: Record<string, string>;
}
type PresetImport = Omit<Import, 'from'> | ImportName | [name: ImportName, as?: ImportName, from?: ModuleId];
interface InlinePreset extends ImportCommon {
imports: (PresetImport | InlinePreset)[];
}
/**
* Auto extract exports from a package for auto import
*/
interface PackagePreset {
/**
* Name of the package
*/
package: string;
/**
* Path of the importer
* @default process.cwd()
*/
url?: string;
/**
* RegExp, string, or custom function to exclude names of the extracted imports
*/
ignore?: (string | RegExp | ((name: string) => boolean))[];
/**
* Use local cache if exits
* @default true
*/
cache?: boolean;
}
type Preset = InlinePreset | PackagePreset;
interface UnimportContext {
readonly version: string;
options: Partial<UnimportOptions>;
staticImports: Import[];
dynamicImports: Import[];
addons: Addon[];
getImports: () => Promise<Import[]>;
getImportMap: () => Promise<Map<string, Import>>;
getMetadata: () => UnimportMeta | undefined;
modifyDynamicImports: (fn: (imports: Import[]) => Thenable<void | Import[]>) => Promise<void>;
clearDynamicImports: () => void;
replaceImports: (imports: UnimportOptions['imports']) => Promise<Import[]>;
invalidate: () => void;
resolveId: (id: string, parentId?: string) => Thenable<string | null | undefined | void>;
}
interface DetectImportResult {
s: MagicString;
strippedCode: string;
isCJSContext: boolean;
matchedImports: Import[];
firstOccurrence: number;
}
interface Unimport {
readonly version: string;
init: () => Promise<void>;
clearDynamicImports: UnimportContext['clearDynamicImports'];
getImportMap: UnimportContext['getImportMap'];
getImports: UnimportContext['getImports'];
getInternalContext: () => UnimportContext;
getMetadata: UnimportContext['getMetadata'];
modifyDynamicImports: UnimportContext['modifyDynamicImports'];
generateTypeDeclarations: (options?: TypeDeclarationOptions) => Promise<string>;
/**
* Get un-imported usages from code
*/
detectImports: (code: string | MagicString) => Promise<DetectImportResult>;
/**
* Insert missing imports statements to code
*/
injectImports: (code: string | MagicString, id?: string, options?: InjectImportsOptions) => Promise<ImportInjectionResult>;
scanImportsFromDir: (dir?: (string | ScanDir)[], options?: ScanDirExportsOptions) => Promise<Import[]>;
scanImportsFromFile: (file: string, includeTypes?: boolean) => Promise<Import[]>;
/**
* @deprecated
*/
toExports: (filepath?: string, includeTypes?: boolean) => Promise<string>;
}
interface InjectionUsageRecord {
import: Import;
count: number;
moduleIds: string[];
}
interface UnimportMeta {
injectionUsage: Record<string, InjectionUsageRecord>;
}
interface AddonsOptions {
addons?: Addon[];
/**
* Enable auto import inside for Vue's <template>
*
* @default false
*/
vueTemplate?: boolean;
/**
* Enable auto import directives for Vue's SFC.
*
* Library authors should include `meta.vueDirective: true` in the import metadata.
*
* When using a local directives folder, provide the `isDirective`
* callback to check if the import is a Vue directive.
*/
vueDirectives?: true | AddonVueDirectivesOptions;
}
interface AddonVueDirectivesOptions {
/**
* Checks if the import is a Vue directive.
*
* **NOTES**:
* - imports from a library should include `meta.vueDirective: true`.
* - this callback is only invoked for local directives (only when meta.vueDirective is not set).
*
* @param from The path of the import normalized.
* @param importEntry The import entry.
*/
isDirective?: (from: string, importEntry: Import) => boolean;
}
interface UnimportOptions extends Pick<InjectImportsOptions, 'injectAtEnd' | 'mergeExisting' | 'parser'> {
/**
* Auto import items
*/
imports: Import[];
/**
* Auto import preset
*/
presets: (Preset | BuiltinPresetName)[];
/**
* Custom warning function
* @default console.warn
*/
warn: (msg: string) => void;
/**
* Custom debug log function
* @default console.log
*/
debugLog: (msg: string) => void;
/**
* Unimport Addons.
* To use built-in addons, use:
* ```js
* addons: {
* addons: [<custom-addons-here>] // if you want to use also custom addons
* vueTemplate: true,
* vueDirectives: [<the-directives-here>]
* }
* ```
*
* Built-in addons:
* - vueDirectives: enable auto import directives for Vue's SFC
* - vueTemplate: enable auto import inside for Vue's <template>
*
* @default {}
*/
addons: AddonsOptions | Addon[];
/**
* Name of virtual modules that exposed all the registed auto-imports
* @default []
*/
virtualImports: string[];
/**
* Directories to scan for auto import
* @default []
*/
dirs?: (string | ScanDir)[];
/**
* Options for scanning directories for auto import
*/
dirsScanOptions?: ScanDirExportsOptions;
/**
* Custom resolver to auto import id
*/
resolveId?: (id: string, importee?: string) => Thenable<string | void>;
/**
* Custom magic comments to be opt-out for auto import, per file/module
*
* @default ['@unimport-disable', '@imports-disable']
*/
commentsDisable?: string[];
/**
* Custom magic comments to debug auto import, printed to console
*
* @default ['@unimport-debug', '@imports-debug']
*/
commentsDebug?: string[];
/**
* Collect meta data for each auto import. Accessible via `ctx.meta`
*/
collectMeta?: boolean;
}
type PathFromResolver = (_import: Import) => string | undefined;
interface ScanDirExportsOptions {
/**
* Glob patterns for matching files
*
* @default ['*.{ts,js,mjs,cjs,mts,cts}']
*/
filePatterns?: string[];
/**
* Custom function to filter scanned files
*/
fileFilter?: (file: string) => boolean;
/**
* Register type exports
*
* @default true
*/
types?: boolean;
/**
* Current working directory
*
* @default process.cwd()
*/
cwd?: string;
}
interface ScanDir {
/**
* Path pattern of the directory
*/
glob: string;
/**
* Register type exports
*
* @default true
*/
types?: boolean;
}
interface TypeDeclarationOptions {
/**
* Custom resolver for path of the import
*/
resolvePath?: PathFromResolver;
/**
* Append `export {}` to the end of the file
*
* @default true
*/
exportHelper?: boolean;
/**
* Auto-import for type exports
*
* @default true
*/
typeReExports?: boolean;
}
interface InjectImportsOptions {
/**
* Merge the existing imports
*
* @default false
*/
mergeExisting?: boolean;
/**
* If the module should be auto imported
*
* @default true
*/
autoImport?: boolean;
/**
* If the module should be transformed for virtual modules.
* Only available when `virtualImports` is set.
*
* @default true
*/
transformVirtualImports?: boolean;
/**
* Parser to use for parsing the code
*
* Note that `acorn` only takes valid JS Code, should usually only be used after transformationa and transpilation
*
* @default 'regex'
*/
parser?: 'acorn' | 'regex';
/**
* Inject the imports at the end of other imports
*
* @default false
*/
injectAtEnd?: boolean;
}
type Thenable<T> = Promise<T> | T;
interface Addon {
name?: string;
transform?: (this: UnimportContext, code: MagicString, id: string | undefined) => Thenable<MagicString>;
declaration?: (this: UnimportContext, dts: string, options: TypeDeclarationOptions) => Thenable<string>;
matchImports?: (this: UnimportContext, identifiers: Set<string>, matched: Import[]) => Thenable<Import[] | void>;
/**
* Extend or modify the imports list before injecting
*/
extendImports?: (this: UnimportContext, imports: Import[]) => Import[] | void;
/**
* Resolve imports before injecting
*/
injectImportsResolved?: (this: UnimportContext, imports: Import[], code: MagicString, id?: string) => Import[] | void;
/**
* Modify the injection code before injecting
*/
injectImportsStringified?: (this: UnimportContext, injection: string, imports: Import[], code: MagicString, id?: string) => string | void;
}
interface InstallGlobalOptions {
/**
* @default globalThis
*/
globalObject?: any;
/**
* Overrides the existing property
* @default false
*/
overrides?: boolean;
}
interface MagicStringResult {
s: MagicString;
code: string;
}
interface ImportInjectionResult extends MagicStringResult {
imports: Import[];
}
export { type AddonsOptions as A, type BuiltinPresetName as B, type DetectImportResult as D, type Import as I, type MagicStringResult as M, type Preset as P, type ScanDir as S, type TypeDeclarationOptions as T, type UnimportOptions as U, type Unimport as a, type InstallGlobalOptions as b, type ScanDirExportsOptions as c, type InlinePreset as d, builtinPresets as e, type ModuleId as f, type ImportName as g, type ImportCommon as h, type PresetImport as i, type PackagePreset as j, type UnimportContext as k, type InjectionUsageRecord as l, type UnimportMeta as m, type AddonVueDirectivesOptions as n, type PathFromResolver as o, type InjectImportsOptions as p, type Thenable as q, type Addon as r, type ImportInjectionResult as s };

View File

@@ -0,0 +1,400 @@
import MagicString from 'magic-string';
import { ESMExport } from 'mlly';
declare const builtinPresets: {
'@vue/composition-api': InlinePreset;
'@vueuse/core': () => Preset;
'@vueuse/head': InlinePreset;
pinia: InlinePreset;
preact: InlinePreset;
quasar: InlinePreset;
react: InlinePreset;
'react-router': InlinePreset;
'react-router-dom': InlinePreset;
svelte: InlinePreset;
'svelte/animate': InlinePreset;
'svelte/easing': InlinePreset;
'svelte/motion': InlinePreset;
'svelte/store': InlinePreset;
'svelte/transition': InlinePreset;
'vee-validate': InlinePreset;
vitepress: InlinePreset;
'vue-demi': InlinePreset;
'vue-i18n': InlinePreset;
'vue-router': InlinePreset;
'vue-router-composables': InlinePreset;
vue: InlinePreset;
'vue/macros': InlinePreset;
vuex: InlinePreset;
vitest: InlinePreset;
'uni-app': InlinePreset;
'solid-js': InlinePreset;
'solid-app-router': InlinePreset;
rxjs: InlinePreset;
'date-fns': InlinePreset;
};
type BuiltinPresetName = keyof typeof builtinPresets;
type ModuleId = string;
type ImportName = string;
interface ImportCommon {
/** Module specifier to import from */
from: ModuleId;
/**
* Priority of the import, if multiple imports have the same name, the one with the highest priority will be used
* @default 1
*/
priority?: number;
/** If this import is disabled */
disabled?: boolean;
/** Won't output import in declaration file if true */
dtsDisabled?: boolean;
/** Import declaration type like const / var / enum */
declarationType?: ESMExport['declarationType'];
/**
* Metadata of the import
*/
meta?: {
/** Short description of the import */
description?: string;
/** URL to the documentation */
docsUrl?: string;
/** Additional metadata */
[key: string]: any;
};
/**
* If this import is a pure type import
*/
type?: boolean;
/**
* Using this as the from when generating type declarations
*/
typeFrom?: ModuleId;
}
interface Import extends ImportCommon {
/** Import name to be detected */
name: ImportName;
/** Import as this name */
as?: ImportName;
/**
* With properties
*
* Ignored for CJS imports.
*/
with?: Record<string, string>;
}
type PresetImport = Omit<Import, 'from'> | ImportName | [name: ImportName, as?: ImportName, from?: ModuleId];
interface InlinePreset extends ImportCommon {
imports: (PresetImport | InlinePreset)[];
}
/**
* Auto extract exports from a package for auto import
*/
interface PackagePreset {
/**
* Name of the package
*/
package: string;
/**
* Path of the importer
* @default process.cwd()
*/
url?: string;
/**
* RegExp, string, or custom function to exclude names of the extracted imports
*/
ignore?: (string | RegExp | ((name: string) => boolean))[];
/**
* Use local cache if exits
* @default true
*/
cache?: boolean;
}
type Preset = InlinePreset | PackagePreset;
interface UnimportContext {
readonly version: string;
options: Partial<UnimportOptions>;
staticImports: Import[];
dynamicImports: Import[];
addons: Addon[];
getImports: () => Promise<Import[]>;
getImportMap: () => Promise<Map<string, Import>>;
getMetadata: () => UnimportMeta | undefined;
modifyDynamicImports: (fn: (imports: Import[]) => Thenable<void | Import[]>) => Promise<void>;
clearDynamicImports: () => void;
replaceImports: (imports: UnimportOptions['imports']) => Promise<Import[]>;
invalidate: () => void;
resolveId: (id: string, parentId?: string) => Thenable<string | null | undefined | void>;
}
interface DetectImportResult {
s: MagicString;
strippedCode: string;
isCJSContext: boolean;
matchedImports: Import[];
firstOccurrence: number;
}
interface Unimport {
readonly version: string;
init: () => Promise<void>;
clearDynamicImports: UnimportContext['clearDynamicImports'];
getImportMap: UnimportContext['getImportMap'];
getImports: UnimportContext['getImports'];
getInternalContext: () => UnimportContext;
getMetadata: UnimportContext['getMetadata'];
modifyDynamicImports: UnimportContext['modifyDynamicImports'];
generateTypeDeclarations: (options?: TypeDeclarationOptions) => Promise<string>;
/**
* Get un-imported usages from code
*/
detectImports: (code: string | MagicString) => Promise<DetectImportResult>;
/**
* Insert missing imports statements to code
*/
injectImports: (code: string | MagicString, id?: string, options?: InjectImportsOptions) => Promise<ImportInjectionResult>;
scanImportsFromDir: (dir?: (string | ScanDir)[], options?: ScanDirExportsOptions) => Promise<Import[]>;
scanImportsFromFile: (file: string, includeTypes?: boolean) => Promise<Import[]>;
/**
* @deprecated
*/
toExports: (filepath?: string, includeTypes?: boolean) => Promise<string>;
}
interface InjectionUsageRecord {
import: Import;
count: number;
moduleIds: string[];
}
interface UnimportMeta {
injectionUsage: Record<string, InjectionUsageRecord>;
}
interface AddonsOptions {
addons?: Addon[];
/**
* Enable auto import inside for Vue's <template>
*
* @default false
*/
vueTemplate?: boolean;
/**
* Enable auto import directives for Vue's SFC.
*
* Library authors should include `meta.vueDirective: true` in the import metadata.
*
* When using a local directives folder, provide the `isDirective`
* callback to check if the import is a Vue directive.
*/
vueDirectives?: true | AddonVueDirectivesOptions;
}
interface AddonVueDirectivesOptions {
/**
* Checks if the import is a Vue directive.
*
* **NOTES**:
* - imports from a library should include `meta.vueDirective: true`.
* - this callback is only invoked for local directives (only when meta.vueDirective is not set).
*
* @param from The path of the import normalized.
* @param importEntry The import entry.
*/
isDirective?: (from: string, importEntry: Import) => boolean;
}
interface UnimportOptions extends Pick<InjectImportsOptions, 'injectAtEnd' | 'mergeExisting' | 'parser'> {
/**
* Auto import items
*/
imports: Import[];
/**
* Auto import preset
*/
presets: (Preset | BuiltinPresetName)[];
/**
* Custom warning function
* @default console.warn
*/
warn: (msg: string) => void;
/**
* Custom debug log function
* @default console.log
*/
debugLog: (msg: string) => void;
/**
* Unimport Addons.
* To use built-in addons, use:
* ```js
* addons: {
* addons: [<custom-addons-here>] // if you want to use also custom addons
* vueTemplate: true,
* vueDirectives: [<the-directives-here>]
* }
* ```
*
* Built-in addons:
* - vueDirectives: enable auto import directives for Vue's SFC
* - vueTemplate: enable auto import inside for Vue's <template>
*
* @default {}
*/
addons: AddonsOptions | Addon[];
/**
* Name of virtual modules that exposed all the registed auto-imports
* @default []
*/
virtualImports: string[];
/**
* Directories to scan for auto import
* @default []
*/
dirs?: (string | ScanDir)[];
/**
* Options for scanning directories for auto import
*/
dirsScanOptions?: ScanDirExportsOptions;
/**
* Custom resolver to auto import id
*/
resolveId?: (id: string, importee?: string) => Thenable<string | void>;
/**
* Custom magic comments to be opt-out for auto import, per file/module
*
* @default ['@unimport-disable', '@imports-disable']
*/
commentsDisable?: string[];
/**
* Custom magic comments to debug auto import, printed to console
*
* @default ['@unimport-debug', '@imports-debug']
*/
commentsDebug?: string[];
/**
* Collect meta data for each auto import. Accessible via `ctx.meta`
*/
collectMeta?: boolean;
}
type PathFromResolver = (_import: Import) => string | undefined;
interface ScanDirExportsOptions {
/**
* Glob patterns for matching files
*
* @default ['*.{ts,js,mjs,cjs,mts,cts}']
*/
filePatterns?: string[];
/**
* Custom function to filter scanned files
*/
fileFilter?: (file: string) => boolean;
/**
* Register type exports
*
* @default true
*/
types?: boolean;
/**
* Current working directory
*
* @default process.cwd()
*/
cwd?: string;
}
interface ScanDir {
/**
* Path pattern of the directory
*/
glob: string;
/**
* Register type exports
*
* @default true
*/
types?: boolean;
}
interface TypeDeclarationOptions {
/**
* Custom resolver for path of the import
*/
resolvePath?: PathFromResolver;
/**
* Append `export {}` to the end of the file
*
* @default true
*/
exportHelper?: boolean;
/**
* Auto-import for type exports
*
* @default true
*/
typeReExports?: boolean;
}
interface InjectImportsOptions {
/**
* Merge the existing imports
*
* @default false
*/
mergeExisting?: boolean;
/**
* If the module should be auto imported
*
* @default true
*/
autoImport?: boolean;
/**
* If the module should be transformed for virtual modules.
* Only available when `virtualImports` is set.
*
* @default true
*/
transformVirtualImports?: boolean;
/**
* Parser to use for parsing the code
*
* Note that `acorn` only takes valid JS Code, should usually only be used after transformationa and transpilation
*
* @default 'regex'
*/
parser?: 'acorn' | 'regex';
/**
* Inject the imports at the end of other imports
*
* @default false
*/
injectAtEnd?: boolean;
}
type Thenable<T> = Promise<T> | T;
interface Addon {
name?: string;
transform?: (this: UnimportContext, code: MagicString, id: string | undefined) => Thenable<MagicString>;
declaration?: (this: UnimportContext, dts: string, options: TypeDeclarationOptions) => Thenable<string>;
matchImports?: (this: UnimportContext, identifiers: Set<string>, matched: Import[]) => Thenable<Import[] | void>;
/**
* Extend or modify the imports list before injecting
*/
extendImports?: (this: UnimportContext, imports: Import[]) => Import[] | void;
/**
* Resolve imports before injecting
*/
injectImportsResolved?: (this: UnimportContext, imports: Import[], code: MagicString, id?: string) => Import[] | void;
/**
* Modify the injection code before injecting
*/
injectImportsStringified?: (this: UnimportContext, injection: string, imports: Import[], code: MagicString, id?: string) => string | void;
}
interface InstallGlobalOptions {
/**
* @default globalThis
*/
globalObject?: any;
/**
* Overrides the existing property
* @default false
*/
overrides?: boolean;
}
interface MagicStringResult {
s: MagicString;
code: string;
}
interface ImportInjectionResult extends MagicStringResult {
imports: Import[];
}
export { type AddonsOptions as A, type BuiltinPresetName as B, type DetectImportResult as D, type Import as I, type MagicStringResult as M, type Preset as P, type ScanDir as S, type TypeDeclarationOptions as T, type UnimportOptions as U, type Unimport as a, type InstallGlobalOptions as b, type ScanDirExportsOptions as c, type InlinePreset as d, builtinPresets as e, type ModuleId as f, type ImportName as g, type ImportCommon as h, type PresetImport as i, type PackagePreset as j, type UnimportContext as k, type InjectionUsageRecord as l, type UnimportMeta as m, type AddonVueDirectivesOptions as n, type PathFromResolver as o, type InjectImportsOptions as p, type Thenable as q, type Addon as r, type ImportInjectionResult as s };

View File

@@ -0,0 +1,5 @@
import { r as Addon } from './unimport.CaVRR9SH.mjs';
declare function vueTemplateAddon(): Addon;
export { vueTemplateAddon as v };

View File

@@ -0,0 +1,5 @@
import { r as Addon } from './unimport.CaVRR9SH.cjs';
declare function vueTemplateAddon(): Addon;
export { vueTemplateAddon as v };

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,575 @@
'use strict';
const node_path = require('node:path');
const process = require('node:process');
const pathe = require('pathe');
const scule = require('scule');
const MagicString = require('magic-string');
const mlly = require('mlly');
const stripLiteral = require('strip-literal');
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
const process__default = /*#__PURE__*/_interopDefaultCompat(process);
const MagicString__default = /*#__PURE__*/_interopDefaultCompat(MagicString);
const excludeRE = [
// imported/exported from other module
/\b(import|export)\b([\w$*{},\s]+?)\bfrom\s*["']/g,
// defined as function
/\bfunction\s*([\w$]+)\s*\(/g,
// defined as class
/\bclass\s*([\w$]+)\s*\{/g,
// defined as local variable
// eslint-disable-next-line regexp/no-super-linear-backtracking
/\b(?:const|let|var)\s+?(\[.*?\]|\{.*?\}|.+?)\s*?[=;\n]/gs
];
const importAsRE = /^.*\sas\s+/;
const separatorRE = /[,[\]{}\n]|\b(?:import|export)\b/g;
const matchRE = /(^|\.\.\.|(?:\bcase|\?)\s+|[^\w$/)]|\bextends\s+)([\w$]+)\s*(?=[.()[\]}:;?+\-*&|`<>,\n]|\b(?:instanceof|in)\b|$|(?<=extends\s+\w+)\s+\{)/g;
const regexRE = /\/\S*?(?<!\\)(?<!\[[^\]]*)\/[gimsuy]*/g;
function stripCommentsAndStrings(code, options) {
return stripLiteral.stripLiteral(code, options).replace(regexRE, 'new RegExp("")');
}
function defineUnimportPreset(preset) {
return preset;
}
const safePropertyName = /^[a-z$_][\w$]*$/i;
function stringifyWith(withValues) {
let withDefs = "";
for (let entries = Object.entries(withValues), l = entries.length, i = 0; i < l; i++) {
const [prop, value] = entries[i];
withDefs += safePropertyName.test(prop) ? prop : JSON.stringify(prop);
withDefs += `: ${JSON.stringify(String(value))}`;
if (i + 1 !== l)
withDefs += ", ";
}
return `{ ${withDefs} }`;
}
function stringifyImports(imports, isCJS = false) {
const map = toImportModuleMap(imports);
return Object.entries(map).flatMap(([name, importSet]) => {
const entries = [];
const imports2 = Array.from(importSet).filter((i) => {
if (!i.name || i.as === "") {
let importStr;
if (isCJS) {
importStr = `require('${name}');`;
} else {
importStr = `import '${name}'`;
if (i.with)
importStr += ` with ${stringifyWith(i.with)}`;
importStr += ";";
}
entries.push(importStr);
return false;
} else if (i.name === "default" || i.name === "=") {
let importStr;
if (isCJS) {
importStr = i.name === "=" ? `const ${i.as} = require('${name}');` : `const { default: ${i.as} } = require('${name}');`;
} else {
importStr = `import ${i.as} from '${name}'`;
if (i.with)
importStr += ` with ${stringifyWith(i.with)}`;
importStr += ";";
}
entries.push(importStr);
return false;
} else if (i.name === "*") {
let importStr;
if (isCJS) {
importStr = `const ${i.as} = require('${name}');`;
} else {
importStr = `import * as ${i.as} from '${name}'`;
if (i.with)
importStr += ` with ${stringifyWith(i.with)}`;
importStr += ";";
}
entries.push(importStr);
return false;
} else if (!isCJS && i.with) {
entries.push(`import { ${stringifyImportAlias(i)} } from '${name}' with ${stringifyWith(i.with)};`);
return false;
}
return true;
});
if (imports2.length) {
const importsAs = imports2.map((i) => stringifyImportAlias(i, isCJS));
entries.push(
isCJS ? `const { ${importsAs.join(", ")} } = require('${name}');` : `import { ${importsAs.join(", ")} } from '${name}';`
);
}
return entries;
}).join("\n");
}
function dedupeImports(imports, warn) {
const map = /* @__PURE__ */ new Map();
const indexToRemove = /* @__PURE__ */ new Set();
imports.filter((i) => !i.disabled).forEach((i, idx) => {
if (i.declarationType === "enum" || i.declarationType === "class")
return;
const name = i.as ?? i.name;
if (!map.has(name)) {
map.set(name, idx);
return;
}
const other = imports[map.get(name)];
if (other.from === i.from) {
indexToRemove.add(idx);
return;
}
const diff = (other.priority || 1) - (i.priority || 1);
if (diff === 0)
warn(`Duplicated imports "${name}", the one from "${other.from}" has been ignored and "${i.from}" is used`);
if (diff <= 0) {
indexToRemove.add(map.get(name));
map.set(name, idx);
} else {
indexToRemove.add(idx);
}
});
return imports.filter((_, idx) => !indexToRemove.has(idx));
}
function toExports(imports, fileDir, includeType = false) {
const map = toImportModuleMap(imports, includeType);
return Object.entries(map).flatMap(([name, imports2]) => {
if (isFilePath(name))
name = name.replace(/\.[a-z]+$/i, "");
if (fileDir && pathe.isAbsolute(name)) {
name = pathe.relative(fileDir, name);
if (!name.match(/^[./]/))
name = `./${name}`;
}
const entries = [];
const filtered = Array.from(imports2).filter((i) => {
if (i.name === "*") {
entries.push(`export * as ${i.as} from '${name}';`);
return false;
}
return true;
});
if (filtered.length)
entries.push(`export { ${filtered.map((i) => stringifyImportAlias(i, false)).join(", ")} } from '${name}';`);
return entries;
}).join("\n");
}
function stripFileExtension(path) {
return path.replace(/\.[a-z]+$/i, "");
}
function toTypeDeclarationItems(imports, options) {
return imports.map((i) => {
const from = options?.resolvePath?.(i) || stripFileExtension(i.typeFrom || i.from);
let typeDef = "";
if (i.with)
typeDef += `import('${from}', { with: ${stringifyWith(i.with)} })`;
else
typeDef += `import('${from}')`;
if (i.name !== "*" && i.name !== "=")
typeDef += `['${i.name}']`;
return `const ${i.as}: typeof ${typeDef}`;
}).sort();
}
function toTypeDeclarationFile(imports, options) {
const items = toTypeDeclarationItems(imports, options);
const {
exportHelper = true
} = options || {};
let declaration = "";
if (exportHelper)
declaration += "export {}\n";
declaration += `declare global {
${items.map((i) => ` ${i}`).join("\n")}
}`;
return declaration;
}
function makeTypeModulesMap(imports, resolvePath) {
const modulesMap = /* @__PURE__ */ new Map();
const resolveImportFrom = typeof resolvePath === "function" ? (i) => {
return resolvePath(i) || stripFileExtension(i.typeFrom || i.from);
} : (i) => stripFileExtension(i.typeFrom || i.from);
for (const import_ of imports) {
const from = resolveImportFrom(import_);
let module = modulesMap.get(from);
if (!module) {
module = { typeImports: /* @__PURE__ */ new Set(), starTypeImport: undefined };
modulesMap.set(from, module);
}
if (import_.name === "*") {
if (import_.as)
module.starTypeImport = import_;
} else {
module.typeImports.add(import_);
}
}
return modulesMap;
}
function toTypeReExports(imports, options) {
const importsMap = makeTypeModulesMap(imports, options?.resolvePath);
const code = Array.from(importsMap).flatMap(([from, module]) => {
from = from.replace(/\.d\.([cm]?)ts$/i, ".$1js");
const { starTypeImport, typeImports } = module;
const strings = [];
if (typeImports.size) {
const typeImportNames = Array.from(typeImports).map(({ name, as }) => {
if (as && as !== name)
return `${name} as ${as}`;
return name;
});
strings.push(
"// @ts-ignore",
`export type { ${typeImportNames.join(", ")} } from '${from}'`
);
}
if (starTypeImport) {
strings.push(
"// @ts-ignore",
`export type * as ${starTypeImport.as} from '${from}'`
);
}
if (strings.length) {
strings.push(
// This is a workaround for a TypeScript issue where type-only re-exports are not properly initialized.
`import('${from}')`
);
}
return strings;
});
return `// for type re-export
declare global {
${code.map((i) => ` ${i}`).join("\n")}
}`;
}
function stringifyImportAlias(item, isCJS = false) {
return item.as === undefined || item.name === item.as ? item.name : isCJS ? `${item.name}: ${item.as}` : `${item.name} as ${item.as}`;
}
function toImportModuleMap(imports, includeType = false) {
const map = {};
for (const _import of imports) {
if (_import.type && !includeType)
continue;
if (!map[_import.from])
map[_import.from] = /* @__PURE__ */ new Set();
map[_import.from].add(_import);
}
return map;
}
function getString(code) {
if (typeof code === "string")
return code;
return code.toString();
}
function getMagicString(code) {
if (typeof code === "string")
return new MagicString__default(code);
return code;
}
function addImportToCode(code, imports, isCJS = false, mergeExisting = false, injectAtLast = false, firstOccurrence = Number.POSITIVE_INFINITY, onResolved, onStringified) {
let newImports = [];
const s = getMagicString(code);
let _staticImports;
const strippedCode = stripCommentsAndStrings(s.original);
function findStaticImportsLazy() {
if (!_staticImports) {
_staticImports = mlly.findStaticImports(s.original).filter((i) => Boolean(strippedCode.slice(i.start, i.end).trim())).map((i) => mlly.parseStaticImport(i));
}
return _staticImports;
}
function hasShebang() {
const shebangRegex = /^#!.+/;
return shebangRegex.test(s.original);
}
if (mergeExisting && !isCJS) {
const existingImports = findStaticImportsLazy();
const map = /* @__PURE__ */ new Map();
imports.forEach((i) => {
const target = existingImports.find((e) => e.specifier === i.from && e.imports.startsWith("{"));
if (!target)
return newImports.push(i);
if (!map.has(target))
map.set(target, []);
map.get(target).push(i);
});
for (const [target, items] of map.entries()) {
const strings = items.map((i) => `${stringifyImportAlias(i)}, `);
const importLength = target.code.match(/^\s*import\s*\{/)?.[0]?.length;
if (importLength)
s.appendLeft(target.start + importLength, ` ${strings.join("").trim()}`);
}
} else {
newImports = imports;
}
newImports = onResolved?.(newImports) ?? newImports;
let newEntries = stringifyImports(newImports, isCJS);
newEntries = onStringified?.(newEntries, newImports) ?? newEntries;
if (newEntries) {
const insertionIndex = injectAtLast ? findStaticImportsLazy().reverse().find((i) => i.end <= firstOccurrence)?.end ?? 0 : 0;
if (insertionIndex > 0)
s.appendRight(insertionIndex, `
${newEntries}
`);
else if (hasShebang())
s.appendLeft(s.original.indexOf("\n") + 1, `
${newEntries}
`);
else
s.prepend(`${newEntries}
`);
}
return {
s,
get code() {
return s.toString();
}
};
}
function normalizeImports(imports) {
for (const _import of imports)
_import.as = _import.as ?? _import.name;
return imports;
}
function resolveIdAbsolute(id, parentId) {
return mlly.resolvePathSync(id, {
url: parentId
});
}
function isFilePath(path) {
return path.startsWith(".") || pathe.isAbsolute(path) || path.includes("://");
}
const toImports = stringifyImports;
const contextRE$1 = /\b_ctx\.([$\w]+)\b/g;
const UNREF_KEY = "__unimport_unref_";
const VUE_TEMPLATE_NAME = "unimport:vue-template";
function vueTemplateAddon() {
const self = {
name: VUE_TEMPLATE_NAME,
async transform(s, id) {
if (!s.original.includes("_ctx.") || s.original.includes(UNREF_KEY))
return s;
const matches = Array.from(s.original.matchAll(contextRE$1));
const imports = await this.getImports();
let targets = [];
for (const match of matches) {
const name = match[1];
const item = imports.find((i) => i.as === name);
if (!item)
continue;
const start = match.index;
const end = start + match[0].length;
const tempName = `__unimport_${name}`;
s.overwrite(start, end, `(${JSON.stringify(name)} in _ctx ? _ctx.${name} : ${UNREF_KEY}(${tempName}))`);
if (!targets.find((i) => i.as === tempName)) {
targets.push({
...item,
as: tempName
});
}
}
if (targets.length) {
targets.push({
name: "unref",
from: "vue",
as: UNREF_KEY
});
for (const addon of this.addons) {
if (addon === self)
continue;
targets = await addon.injectImportsResolved?.call(this, targets, s, id) ?? targets;
}
let injection = stringifyImports(targets);
for (const addon of this.addons) {
if (addon === self)
continue;
injection = await addon.injectImportsStringified?.call(this, injection, targets, s, id) ?? injection;
}
s.prepend(injection);
}
return s;
},
async declaration(dts, options) {
const imports = await this.getImports();
const items = imports.map((i) => {
if (i.type || i.dtsDisabled)
return "";
const from = options?.resolvePath?.(i) || i.from;
return `readonly ${i.as}: UnwrapRef<typeof import('${from}')${i.name !== "*" ? `['${i.name}']` : ""}>`;
}).filter(Boolean).sort();
const extendItems = items.map((i) => ` ${i}`).join("\n");
return `${dts}
// for vue template auto import
import { UnwrapRef } from 'vue'
declare module 'vue' {
interface ComponentCustomProperties {
${extendItems}
}
}`;
}
};
return self;
}
const contextRE = /resolveDirective as _resolveDirective/;
const contextText = `${contextRE.source}, `;
const directiveRE = /(?:var|const) (\w+) = _resolveDirective\("([\w.-]+)"\);?\s*/g;
const VUE_DIRECTIVES_NAME = "unimport:vue-directives";
function vueDirectivesAddon(options = {}) {
function isDirective(importEntry) {
let isDirective2 = importEntry.meta?.vueDirective === true;
if (isDirective2) {
return true;
}
isDirective2 = options.isDirective?.(normalizePath(process__default.cwd(), importEntry.from), importEntry) ?? false;
if (isDirective2) {
importEntry.meta ??= {};
importEntry.meta.vueDirective = true;
}
return isDirective2;
}
const self = {
name: VUE_DIRECTIVES_NAME,
async transform(s, id) {
if (!s.original.match(contextRE))
return s;
const matches = Array.from(s.original.matchAll(directiveRE)).sort((a, b) => b.index - a.index);
if (!matches.length)
return s;
let targets = [];
for await (const [
begin,
end,
importEntry
] of findDirectives(
isDirective,
matches,
this.getImports()
)) {
s.overwrite(begin, end, "");
targets.push(importEntry);
}
if (!targets.length)
return s;
s.replace(contextText, "");
for (const addon of this.addons) {
if (addon === self)
continue;
targets = await addon.injectImportsResolved?.call(this, targets, s, id) ?? targets;
}
let injection = stringifyImports(targets);
for (const addon of this.addons) {
if (addon === self)
continue;
injection = await addon.injectImportsStringified?.call(this, injection, targets, s, id) ?? injection;
}
s.prepend(injection);
return s;
},
async declaration(dts, options2) {
const directivesMap = await this.getImports().then((imports) => {
return imports.filter(isDirective).reduce((acc, i) => {
if (i.type || i.dtsDisabled)
return acc;
let name;
if (i.name === "default" && (i.as === "default" || !i.as)) {
const file = node_path.basename(i.from);
const idx = file.indexOf(".");
name = idx > -1 ? file.slice(0, idx) : file;
} else {
name = i.as ?? i.name;
}
name = name[0] === "v" ? scule.camelCase(name) : scule.camelCase(`v-${name}`);
if (!acc.has(name)) {
acc.set(name, i);
}
return acc;
}, /* @__PURE__ */ new Map());
});
if (!directivesMap.size)
return dts;
const directives = Array.from(directivesMap.entries()).map(([name, i]) => ` ${name}: typeof import('${options2?.resolvePath?.(i) || i.from}')['${i.name}']`).sort().join("\n");
return `${dts}
// for vue directives auto import
declare module 'vue' {
interface ComponentCustomProperties {
${directives}
}
interface GlobalDirectives {
${directives}
}
}`;
}
};
return self;
}
function resolvePath(cwd, path) {
return path[0] === "." ? pathe.resolve(cwd, path) : path;
}
function normalizePath(cwd, path) {
return resolvePath(cwd, path).replace(/\\/g, "/");
}
async function* findDirectives(isDirective, regexArray, importsPromise) {
const imports = (await importsPromise).filter(isDirective);
if (!imports.length)
return;
const symbols = regexArray.reduce((acc, regex) => {
const [all, symbol, resolveDirectiveName] = regex;
if (acc.has(symbol))
return acc;
acc.set(symbol, [
regex.index,
regex.index + all.length,
scule.kebabCase(resolveDirectiveName)
]);
return acc;
}, /* @__PURE__ */ new Map());
for (const [symbol, data] of symbols.entries()) {
yield* findDirective(imports, symbol, data);
}
}
function* findDirective(imports, symbol, [begin, end, importName]) {
let resolvedName;
for (const i of imports) {
if (i.name === "default" && (i.as === "default" || !i.as)) {
const file = node_path.basename(i.from);
const idx = file.indexOf(".");
resolvedName = scule.kebabCase(idx > -1 ? file.slice(0, idx) : file);
} else {
resolvedName = scule.kebabCase(i.as ?? i.name);
}
if (resolvedName[0] === "v") {
resolvedName = resolvedName.slice(resolvedName[1] === "-" ? 2 : 1);
}
if (resolvedName === importName) {
yield [
begin,
end,
{ ...i, name: i.name, as: symbol }
];
return;
}
}
}
exports.VUE_DIRECTIVES_NAME = VUE_DIRECTIVES_NAME;
exports.VUE_TEMPLATE_NAME = VUE_TEMPLATE_NAME;
exports.addImportToCode = addImportToCode;
exports.dedupeImports = dedupeImports;
exports.defineUnimportPreset = defineUnimportPreset;
exports.excludeRE = excludeRE;
exports.getMagicString = getMagicString;
exports.getString = getString;
exports.importAsRE = importAsRE;
exports.matchRE = matchRE;
exports.normalizeImports = normalizeImports;
exports.resolveIdAbsolute = resolveIdAbsolute;
exports.separatorRE = separatorRE;
exports.stringifyImports = stringifyImports;
exports.stripCommentsAndStrings = stripCommentsAndStrings;
exports.stripFileExtension = stripFileExtension;
exports.toExports = toExports;
exports.toImports = toImports;
exports.toTypeDeclarationFile = toTypeDeclarationFile;
exports.toTypeDeclarationItems = toTypeDeclarationItems;
exports.toTypeReExports = toTypeReExports;
exports.vueDirectivesAddon = vueDirectivesAddon;
exports.vueTemplateAddon = vueTemplateAddon;

File diff suppressed because it is too large Load Diff

72
web/admin-spa/node_modules/unimport/dist/unplugin.cjs generated vendored Normal file
View File

@@ -0,0 +1,72 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const node_fs = require('node:fs');
const pluginutils = require('@rollup/pluginutils');
const MagicString = require('magic-string');
const unplugin$1 = require('unplugin');
const context = require('./shared/unimport.D6_N7ILk.cjs');
require('./shared/unimport.MMUMmZ45.cjs');
require('node:path');
require('node:process');
require('pathe');
require('scule');
require('mlly');
require('strip-literal');
require('node:fs/promises');
require('node:url');
require('fast-glob');
require('picomatch');
require('node:os');
require('pkg-types');
require('local-pkg');
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
const MagicString__default = /*#__PURE__*/_interopDefaultCompat(MagicString);
const defaultIncludes = [/\.[jt]sx?$/, /\.vue$/, /\.vue\?vue/, /\.svelte$/];
const defaultExcludes = [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/];
function toArray(x) {
return x == null ? [] : Array.isArray(x) ? x : [x];
}
const unplugin = unplugin$1.createUnplugin((options = {}) => {
const ctx = context.createUnimport(options);
const filter = pluginutils.createFilter(
toArray(options.include || []).length ? options.include : defaultIncludes,
options.exclude || defaultExcludes
);
const dts = options.dts === true ? "unimport.d.ts" : options.dts;
const {
autoImport = true
} = options;
return {
name: "unimport",
enforce: "post",
transformInclude(id) {
return filter(id);
},
async transform(code, id) {
const s = new MagicString__default(code);
await ctx.injectImports(s, id, {
autoImport
});
if (!s.hasChanged())
return;
return {
code: s.toString(),
map: s.generateMap()
};
},
async buildStart() {
await ctx.init();
if (dts)
return node_fs.promises.writeFile(dts, await ctx.generateTypeDeclarations(), "utf-8");
}
};
});
exports.default = unplugin;
exports.defaultExcludes = defaultExcludes;
exports.defaultIncludes = defaultIncludes;

View File

@@ -0,0 +1,23 @@
import * as unplugin from 'unplugin';
import { FilterPattern } from '@rollup/pluginutils';
import { U as UnimportOptions } from './shared/unimport.CaVRR9SH.cjs';
import 'magic-string';
import 'mlly';
interface UnimportPluginOptions extends UnimportOptions {
include: FilterPattern;
exclude: FilterPattern;
dts: boolean | string;
/**
* Enable implicit auto import.
* Generate global TypeScript definitions.
*
* @default true
*/
autoImport?: boolean;
}
declare const defaultIncludes: RegExp[];
declare const defaultExcludes: RegExp[];
declare const _default: unplugin.UnpluginInstance<Partial<UnimportPluginOptions>, boolean>;
export { type UnimportPluginOptions, _default as default, defaultExcludes, defaultIncludes };

View File

@@ -0,0 +1,23 @@
import * as unplugin from 'unplugin';
import { FilterPattern } from '@rollup/pluginutils';
import { U as UnimportOptions } from './shared/unimport.CaVRR9SH.mjs';
import 'magic-string';
import 'mlly';
interface UnimportPluginOptions extends UnimportOptions {
include: FilterPattern;
exclude: FilterPattern;
dts: boolean | string;
/**
* Enable implicit auto import.
* Generate global TypeScript definitions.
*
* @default true
*/
autoImport?: boolean;
}
declare const defaultIncludes: RegExp[];
declare const defaultExcludes: RegExp[];
declare const _default: unplugin.UnpluginInstance<Partial<UnimportPluginOptions>, boolean>;
export { type UnimportPluginOptions, _default as default, defaultExcludes, defaultIncludes };

23
web/admin-spa/node_modules/unimport/dist/unplugin.d.ts generated vendored Normal file
View File

@@ -0,0 +1,23 @@
import * as unplugin from 'unplugin';
import { FilterPattern } from '@rollup/pluginutils';
import { U as UnimportOptions } from './shared/unimport.CaVRR9SH.js';
import 'magic-string';
import 'mlly';
interface UnimportPluginOptions extends UnimportOptions {
include: FilterPattern;
exclude: FilterPattern;
dts: boolean | string;
/**
* Enable implicit auto import.
* Generate global TypeScript definitions.
*
* @default true
*/
autoImport?: boolean;
}
declare const defaultIncludes: RegExp[];
declare const defaultExcludes: RegExp[];
declare const _default: unplugin.UnpluginInstance<Partial<UnimportPluginOptions>, boolean>;
export { type UnimportPluginOptions, _default as default, defaultExcludes, defaultIncludes };

62
web/admin-spa/node_modules/unimport/dist/unplugin.mjs generated vendored Normal file
View File

@@ -0,0 +1,62 @@
import { promises } from 'node:fs';
import { createFilter } from '@rollup/pluginutils';
import MagicString from 'magic-string';
import { createUnplugin } from 'unplugin';
import { c as createUnimport } from './shared/unimport.Ww9aF1N_.mjs';
import './shared/unimport.0aitavbJ.mjs';
import 'node:path';
import 'node:process';
import 'pathe';
import 'scule';
import 'mlly';
import 'strip-literal';
import 'node:fs/promises';
import 'node:url';
import 'fast-glob';
import 'picomatch';
import 'node:os';
import 'pkg-types';
import 'local-pkg';
const defaultIncludes = [/\.[jt]sx?$/, /\.vue$/, /\.vue\?vue/, /\.svelte$/];
const defaultExcludes = [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/];
function toArray(x) {
return x == null ? [] : Array.isArray(x) ? x : [x];
}
const unplugin = createUnplugin((options = {}) => {
const ctx = createUnimport(options);
const filter = createFilter(
toArray(options.include || []).length ? options.include : defaultIncludes,
options.exclude || defaultExcludes
);
const dts = options.dts === true ? "unimport.d.ts" : options.dts;
const {
autoImport = true
} = options;
return {
name: "unimport",
enforce: "post",
transformInclude(id) {
return filter(id);
},
async transform(code, id) {
const s = new MagicString(code);
await ctx.injectImports(s, id, {
autoImport
});
if (!s.hasChanged())
return;
return {
code: s.toString(),
map: s.generateMap()
};
},
async buildStart() {
await ctx.init();
if (dts)
return promises.writeFile(dts, await ctx.generateTypeDeclarations(), "utf-8");
}
};
});
export { unplugin as default, defaultExcludes, defaultIncludes };