@pit-frontend-framework/unplugin-vue-components 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +464 -0
- package/dist/esbuild.d.mts +6 -0
- package/dist/esbuild.mjs +5 -0
- package/dist/index.d.mts +11 -0
- package/dist/index.mjs +3 -0
- package/dist/nuxt.d.mts +7 -0
- package/dist/nuxt.mjs +9 -0
- package/dist/resolvers.d.mts +552 -0
- package/dist/resolvers.mjs +2007 -0
- package/dist/rolldown.d.mts +6 -0
- package/dist/rolldown.mjs +5 -0
- package/dist/rollup.d.mts +6 -0
- package/dist/rollup.mjs +5 -0
- package/dist/rspack.d.mts +6 -0
- package/dist/rspack.mjs +5 -0
- package/dist/src-S1kwY0Q8.mjs +656 -0
- package/dist/types-BbnOeCab.d.mts +217 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +1 -0
- package/dist/utils-BfjsfvcK.mjs +229 -0
- package/dist/vite.d.mts +9 -0
- package/dist/vite.mjs +5 -0
- package/dist/webpack.d.mts +6 -0
- package/dist/webpack.mjs +5 -0
- package/package.json +95 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { TransformResult } from "unplugin";
|
|
2
|
+
import { FilterPattern } from "unplugin-utils";
|
|
3
|
+
|
|
4
|
+
//#region node_modules/.pnpm/@antfu+utils@9.3.0/node_modules/@antfu/utils/dist/index.d.mts
|
|
5
|
+
/**
|
|
6
|
+
* Promise, or maybe not
|
|
7
|
+
*/
|
|
8
|
+
type Awaitable<T> = T | PromiseLike<T>;
|
|
9
|
+
/**
|
|
10
|
+
* Null or whatever
|
|
11
|
+
*/
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/types.d.ts
|
|
14
|
+
interface ImportInfoLegacy {
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated renamed to `as`
|
|
17
|
+
*/
|
|
18
|
+
name?: string;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated renamed to `name`
|
|
21
|
+
*/
|
|
22
|
+
importName?: string;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated renamed to `from`
|
|
25
|
+
*/
|
|
26
|
+
path: string;
|
|
27
|
+
sideEffects?: SideEffectsInfo;
|
|
28
|
+
}
|
|
29
|
+
interface ImportInfo {
|
|
30
|
+
as?: string;
|
|
31
|
+
name?: string;
|
|
32
|
+
from: string;
|
|
33
|
+
}
|
|
34
|
+
type SideEffectsInfo = (ImportInfo | string)[] | ImportInfo | string | undefined;
|
|
35
|
+
interface ComponentInfo extends ImportInfo {
|
|
36
|
+
sideEffects?: SideEffectsInfo;
|
|
37
|
+
}
|
|
38
|
+
type ComponentResolveResult = Awaitable<string | ComponentInfo | null | undefined | void>;
|
|
39
|
+
type ComponentResolverFunction = (name: string) => ComponentResolveResult;
|
|
40
|
+
interface ComponentResolverObject {
|
|
41
|
+
type: 'component' | 'directive';
|
|
42
|
+
resolve: ComponentResolverFunction;
|
|
43
|
+
}
|
|
44
|
+
type ComponentResolver = ComponentResolverFunction | ComponentResolverObject;
|
|
45
|
+
type Matcher = (id: string) => boolean | null | undefined;
|
|
46
|
+
type Transformer = (code: string, id: string, path: string, query: Record<string, string>) => Awaitable<TransformResult | null>;
|
|
47
|
+
interface PublicPluginAPI {
|
|
48
|
+
/**
|
|
49
|
+
* Resolves a component using the configured resolvers.
|
|
50
|
+
*/
|
|
51
|
+
findComponent: (name: string, filename?: string) => Promise<ComponentInfo | undefined>;
|
|
52
|
+
/**
|
|
53
|
+
* Obtain an import statement for a resolved component.
|
|
54
|
+
*/
|
|
55
|
+
stringifyImport: (info: ComponentInfo) => string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Plugin options.
|
|
59
|
+
*/
|
|
60
|
+
interface Options {
|
|
61
|
+
/**
|
|
62
|
+
* RegExp or glob to match files to be transformed
|
|
63
|
+
*/
|
|
64
|
+
include?: FilterPattern;
|
|
65
|
+
/**
|
|
66
|
+
* RegExp or glob to match files to NOT be transformed
|
|
67
|
+
*/
|
|
68
|
+
exclude?: FilterPattern;
|
|
69
|
+
/**
|
|
70
|
+
* RegExp or string to match component names that will NOT be imported
|
|
71
|
+
*/
|
|
72
|
+
excludeNames?: FilterPattern;
|
|
73
|
+
/**
|
|
74
|
+
* Relative paths to the directory to search for components.
|
|
75
|
+
* @default 'src/components'
|
|
76
|
+
*/
|
|
77
|
+
dirs?: string | string[];
|
|
78
|
+
/**
|
|
79
|
+
* Valid file extensions for components.
|
|
80
|
+
* @default ['vue']
|
|
81
|
+
*/
|
|
82
|
+
extensions?: string | string[];
|
|
83
|
+
/**
|
|
84
|
+
* Glob patterns to match file names to be detected as components.
|
|
85
|
+
*
|
|
86
|
+
* When specified, the `dirs`, `extensions`, and `directoryAsNamespace` options will be ignored.
|
|
87
|
+
*/
|
|
88
|
+
globs?: string | string[];
|
|
89
|
+
/**
|
|
90
|
+
* Negated glob patterns to exclude files from being detected as components.
|
|
91
|
+
*
|
|
92
|
+
* @default []
|
|
93
|
+
*/
|
|
94
|
+
globsExclude?: string | string[];
|
|
95
|
+
/**
|
|
96
|
+
* Search for subdirectories
|
|
97
|
+
* @default true
|
|
98
|
+
*/
|
|
99
|
+
deep?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Allow subdirectories as namespace prefix for components
|
|
102
|
+
* @default false
|
|
103
|
+
*/
|
|
104
|
+
directoryAsNamespace?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Generate components with prefix.
|
|
107
|
+
*/
|
|
108
|
+
prefix?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Collapse same prefixes (camel-sensitive) of folders and components
|
|
111
|
+
* to prevent duplication inside namespaced component name.
|
|
112
|
+
*
|
|
113
|
+
* Works when `directoryAsNamespace: true`
|
|
114
|
+
* @default false
|
|
115
|
+
*/
|
|
116
|
+
collapseSamePrefixes?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Subdirectory paths for ignoring namespace prefixes
|
|
119
|
+
*
|
|
120
|
+
* Works when `directoryAsNamespace: true`
|
|
121
|
+
* @default "[]"
|
|
122
|
+
*/
|
|
123
|
+
globalNamespaces?: string[];
|
|
124
|
+
/**
|
|
125
|
+
* Pass a custom function to resolve the component importing path from the component name.
|
|
126
|
+
*
|
|
127
|
+
* The component names are always in PascalCase
|
|
128
|
+
*/
|
|
129
|
+
resolvers?: (ComponentResolver | ComponentResolver[])[];
|
|
130
|
+
/**
|
|
131
|
+
* Apply custom transform over the path for importing
|
|
132
|
+
*/
|
|
133
|
+
importPathTransform?: (path: string) => string | undefined;
|
|
134
|
+
/**
|
|
135
|
+
* Tranform users' usage of resolveComponent/resolveDirective as well
|
|
136
|
+
*
|
|
137
|
+
* If disabled, only components inside templates (which compiles to `_resolveComponent` etc.)
|
|
138
|
+
* will be transformed.
|
|
139
|
+
*
|
|
140
|
+
* @default true
|
|
141
|
+
*/
|
|
142
|
+
transformerUserResolveFunctions?: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Generate TypeScript declaration for global components
|
|
145
|
+
*
|
|
146
|
+
* Accept boolean or a path related to project root
|
|
147
|
+
*
|
|
148
|
+
* @see https://github.com/vuejs/core/pull/3399
|
|
149
|
+
* @see https://github.com/johnsoncodehk/volar#using
|
|
150
|
+
* @default true
|
|
151
|
+
*/
|
|
152
|
+
dts?: boolean | string;
|
|
153
|
+
/**
|
|
154
|
+
* Generate TypeScript declaration for global components
|
|
155
|
+
* For TSX support
|
|
156
|
+
*
|
|
157
|
+
* @default true if `@vitejs/plugin-vue-jsx` is installed
|
|
158
|
+
*/
|
|
159
|
+
dtsTsx?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Do not emit warning on component overriding
|
|
162
|
+
*
|
|
163
|
+
* @default false
|
|
164
|
+
*/
|
|
165
|
+
allowOverrides?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* auto import for directives.
|
|
168
|
+
* @default true
|
|
169
|
+
*/
|
|
170
|
+
directives?: boolean;
|
|
171
|
+
/**
|
|
172
|
+
* Only provide types of components in library (registered globally)
|
|
173
|
+
*/
|
|
174
|
+
types?: TypeImport[];
|
|
175
|
+
/**
|
|
176
|
+
* Generate sourcemap for the transformed code.
|
|
177
|
+
*
|
|
178
|
+
* @default true
|
|
179
|
+
*/
|
|
180
|
+
sourcemap?: boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Save component information into a JSON file for other tools to consume.
|
|
183
|
+
* Provide a filepath to save the JSON file.
|
|
184
|
+
*
|
|
185
|
+
* When set to `true`, it will save to `./.components-info.json`
|
|
186
|
+
*
|
|
187
|
+
* @default false
|
|
188
|
+
*/
|
|
189
|
+
dumpComponentsInfo?: boolean | string;
|
|
190
|
+
/**
|
|
191
|
+
* The mode for syncing the components.d.ts and .components-info.json file.
|
|
192
|
+
* - `append`: only append the new components to the existing files.
|
|
193
|
+
* - `overwrite`: overwrite the whole existing files with the current components.
|
|
194
|
+
* - `default`: use `append` strategy when using dev server, `overwrite` strategy when using build.
|
|
195
|
+
*
|
|
196
|
+
* @default 'default'
|
|
197
|
+
*/
|
|
198
|
+
syncMode?: 'default' | 'append' | 'overwrite';
|
|
199
|
+
}
|
|
200
|
+
type ResolvedOptions = Omit<Required<Options>, 'resolvers' | 'extensions' | 'dirs' | 'globalComponentsDeclaration'> & {
|
|
201
|
+
resolvers: ComponentResolverObject[];
|
|
202
|
+
extensions: string[];
|
|
203
|
+
dirs: string[];
|
|
204
|
+
resolvedDirs: string[];
|
|
205
|
+
globs: string[];
|
|
206
|
+
globsExclude: string[];
|
|
207
|
+
dts: string | false;
|
|
208
|
+
dtsTsx: boolean;
|
|
209
|
+
root: string;
|
|
210
|
+
};
|
|
211
|
+
type ComponentsImportMap = Record<string, string[] | undefined>;
|
|
212
|
+
interface TypeImport {
|
|
213
|
+
from: string;
|
|
214
|
+
names: string[];
|
|
215
|
+
}
|
|
216
|
+
//#endregion
|
|
217
|
+
export { ComponentResolverObject as a, ImportInfoLegacy as c, PublicPluginAPI as d, ResolvedOptions as f, TypeImport as h, ComponentResolverFunction as i, Matcher as l, Transformer as m, ComponentResolveResult as n, ComponentsImportMap as o, SideEffectsInfo as p, ComponentResolver as r, ImportInfo as s, ComponentInfo as t, Options as u };
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as ComponentResolverObject, c as ImportInfoLegacy, d as PublicPluginAPI, f as ResolvedOptions, h as TypeImport, i as ComponentResolverFunction, l as Matcher, m as Transformer, n as ComponentResolveResult, o as ComponentsImportMap, p as SideEffectsInfo, r as ComponentResolver, s as ImportInfo, t as ComponentInfo, u as Options } from "./types-BbnOeCab.mjs";
|
|
2
|
+
export { ComponentInfo, ComponentResolveResult, ComponentResolver, ComponentResolverFunction, ComponentResolverObject, ComponentsImportMap, ImportInfo, ImportInfoLegacy, Matcher, Options, PublicPluginAPI, ResolvedOptions, SideEffectsInfo, Transformer, TypeImport };
|
package/dist/types.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { parse } from "node:path";
|
|
3
|
+
import { getPackageInfo, isPackageExists } from "local-pkg";
|
|
4
|
+
import picomatch from "picomatch";
|
|
5
|
+
//#region node_modules/.pnpm/@antfu+utils@9.3.0/node_modules/@antfu/utils/dist/index.mjs
|
|
6
|
+
function toArray(array) {
|
|
7
|
+
array = array ?? [];
|
|
8
|
+
return Array.isArray(array) ? array : [array];
|
|
9
|
+
}
|
|
10
|
+
function notNullish(v) {
|
|
11
|
+
return v != null;
|
|
12
|
+
}
|
|
13
|
+
function slash(str) {
|
|
14
|
+
return str.replace(/\\/g, "/");
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Throttle execution of a function. Especially useful for rate limiting
|
|
18
|
+
* execution of handlers on events like resize and scroll.
|
|
19
|
+
*
|
|
20
|
+
* @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher)
|
|
21
|
+
* are most useful.
|
|
22
|
+
* @param {Function} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through,
|
|
23
|
+
* as-is, to `callback` when the throttled-function is executed.
|
|
24
|
+
* @param {object} [options] - An object to configure options.
|
|
25
|
+
* @param {boolean} [options.noTrailing] - Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds
|
|
26
|
+
* while the throttled-function is being called. If noTrailing is false or unspecified, callback will be executed
|
|
27
|
+
* one final time after the last throttled-function call. (After the throttled-function has not been called for
|
|
28
|
+
* `delay` milliseconds, the internal counter is reset).
|
|
29
|
+
* @param {boolean} [options.noLeading] - Optional, defaults to false. If noLeading is false, the first throttled-function call will execute callback
|
|
30
|
+
* immediately. If noLeading is true, the first the callback execution will be skipped. It should be noted that
|
|
31
|
+
* callback will never executed if both noLeading = true and noTrailing = true.
|
|
32
|
+
* @param {boolean} [options.debounceMode] - If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is
|
|
33
|
+
* false (at end), schedule `callback` to execute after `delay` ms.
|
|
34
|
+
*
|
|
35
|
+
* @returns {Function} A new, throttled, function.
|
|
36
|
+
*/
|
|
37
|
+
function throttle$1(delay, callback, options) {
|
|
38
|
+
var _ref = options || {}, _ref$noTrailing = _ref.noTrailing, noTrailing = _ref$noTrailing === void 0 ? false : _ref$noTrailing, _ref$noLeading = _ref.noLeading, noLeading = _ref$noLeading === void 0 ? false : _ref$noLeading, _ref$debounceMode = _ref.debounceMode, debounceMode = _ref$debounceMode === void 0 ? void 0 : _ref$debounceMode;
|
|
39
|
+
var timeoutID;
|
|
40
|
+
var cancelled = false;
|
|
41
|
+
var lastExec = 0;
|
|
42
|
+
function clearExistingTimeout() {
|
|
43
|
+
if (timeoutID) clearTimeout(timeoutID);
|
|
44
|
+
}
|
|
45
|
+
function cancel(options) {
|
|
46
|
+
var _ref2$upcomingOnly = (options || {}).upcomingOnly, upcomingOnly = _ref2$upcomingOnly === void 0 ? false : _ref2$upcomingOnly;
|
|
47
|
+
clearExistingTimeout();
|
|
48
|
+
cancelled = !upcomingOnly;
|
|
49
|
+
}
|
|
50
|
+
function wrapper() {
|
|
51
|
+
for (var _len = arguments.length, arguments_ = new Array(_len), _key = 0; _key < _len; _key++) arguments_[_key] = arguments[_key];
|
|
52
|
+
var self = this;
|
|
53
|
+
var elapsed = Date.now() - lastExec;
|
|
54
|
+
if (cancelled) return;
|
|
55
|
+
function exec() {
|
|
56
|
+
lastExec = Date.now();
|
|
57
|
+
callback.apply(self, arguments_);
|
|
58
|
+
}
|
|
59
|
+
function clear() {
|
|
60
|
+
timeoutID = void 0;
|
|
61
|
+
}
|
|
62
|
+
if (!noLeading && debounceMode && !timeoutID) exec();
|
|
63
|
+
clearExistingTimeout();
|
|
64
|
+
if (debounceMode === void 0 && elapsed > delay) if (noLeading) {
|
|
65
|
+
lastExec = Date.now();
|
|
66
|
+
if (!noTrailing) timeoutID = setTimeout(debounceMode ? clear : exec, delay);
|
|
67
|
+
} else exec();
|
|
68
|
+
else if (noTrailing !== true) timeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === void 0 ? delay - elapsed : delay);
|
|
69
|
+
}
|
|
70
|
+
wrapper.cancel = cancel;
|
|
71
|
+
return wrapper;
|
|
72
|
+
}
|
|
73
|
+
function throttle(...args) {
|
|
74
|
+
return throttle$1(...args);
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/core/constants.ts
|
|
78
|
+
const DISABLE_COMMENT = "/* unplugin-vue-components disabled */";
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/core/utils.ts
|
|
81
|
+
const isSSR = Boolean(process.env.SSR || process.env.SSG || process.env.VITE_SSR || process.env.VITE_SSG);
|
|
82
|
+
function pascalCase(str) {
|
|
83
|
+
return capitalize(camelCase(str));
|
|
84
|
+
}
|
|
85
|
+
function camelCase(str) {
|
|
86
|
+
return str.replace(/-(\w)/g, (_, c) => c ? c.toUpperCase() : "");
|
|
87
|
+
}
|
|
88
|
+
function kebabCase(key) {
|
|
89
|
+
return key.replace(/([A-Z])/g, " $1").trim().split(" ").join("-").toLowerCase();
|
|
90
|
+
}
|
|
91
|
+
function capitalize(str) {
|
|
92
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
93
|
+
}
|
|
94
|
+
function parseId(id) {
|
|
95
|
+
const index = id.indexOf("?");
|
|
96
|
+
if (index < 0) return {
|
|
97
|
+
path: id,
|
|
98
|
+
query: {}
|
|
99
|
+
};
|
|
100
|
+
else {
|
|
101
|
+
const query = Object.fromEntries(new URLSearchParams(id.slice(index)));
|
|
102
|
+
return {
|
|
103
|
+
path: id.slice(0, index),
|
|
104
|
+
query
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function isEmpty(value) {
|
|
109
|
+
if (!value || value === null || value === void 0 || Array.isArray(value) && Object.keys(value).length <= 0) return true;
|
|
110
|
+
else return false;
|
|
111
|
+
}
|
|
112
|
+
function matchGlobs(filepath, globs) {
|
|
113
|
+
for (const glob of globs) {
|
|
114
|
+
const isNegated = glob[0] === "!";
|
|
115
|
+
if (picomatch(isNegated ? glob.slice(1) : glob)(slash(filepath))) return !isNegated;
|
|
116
|
+
}
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
function getTransformedPath(path, importPathTransform) {
|
|
120
|
+
if (importPathTransform) {
|
|
121
|
+
const result = importPathTransform(path);
|
|
122
|
+
if (result != null) path = result;
|
|
123
|
+
}
|
|
124
|
+
return path;
|
|
125
|
+
}
|
|
126
|
+
function stringifyImport(info) {
|
|
127
|
+
if (typeof info === "string") return `import '${info}'`;
|
|
128
|
+
if (!info.as) return `import '${info.from}'`;
|
|
129
|
+
else if (info.name) return `import { ${info.name} as ${info.as} } from '${info.from}'`;
|
|
130
|
+
else return `import ${info.as} from '${info.from}'`;
|
|
131
|
+
}
|
|
132
|
+
function normalizeComponentInfo(info) {
|
|
133
|
+
if ("path" in info) return {
|
|
134
|
+
from: info.path,
|
|
135
|
+
as: info.name,
|
|
136
|
+
name: info.importName,
|
|
137
|
+
sideEffects: info.sideEffects
|
|
138
|
+
};
|
|
139
|
+
return info;
|
|
140
|
+
}
|
|
141
|
+
function stringifyComponentImport({ as: name, from: path, name: importName, sideEffects }, ctx) {
|
|
142
|
+
path = getTransformedPath(path, ctx.options.importPathTransform);
|
|
143
|
+
const imports = [stringifyImport({
|
|
144
|
+
as: name,
|
|
145
|
+
from: path,
|
|
146
|
+
name: importName
|
|
147
|
+
})];
|
|
148
|
+
if (sideEffects) toArray(sideEffects).forEach((i) => imports.push(stringifyImport(i)));
|
|
149
|
+
return imports.join(";");
|
|
150
|
+
}
|
|
151
|
+
function getNameFromFilePath(filePath, options) {
|
|
152
|
+
const { resolvedDirs, directoryAsNamespace, globalNamespaces, collapseSamePrefixes, root } = options;
|
|
153
|
+
const parsedFilePath = parse(slash(filePath));
|
|
154
|
+
let strippedPath = "";
|
|
155
|
+
for (const dir of resolvedDirs) if (parsedFilePath.dir.startsWith(dir)) {
|
|
156
|
+
strippedPath = parsedFilePath.dir.slice(dir.length);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
let folders = strippedPath.slice(1).split("/").filter(Boolean);
|
|
160
|
+
let filename = parsedFilePath.name;
|
|
161
|
+
if (filename === "index" && !directoryAsNamespace) {
|
|
162
|
+
if (isEmpty(folders)) folders = parsedFilePath.dir.slice(root.length + 1).split("/").filter(Boolean);
|
|
163
|
+
filename = `${folders.slice(-1)[0]}`;
|
|
164
|
+
return filename;
|
|
165
|
+
}
|
|
166
|
+
if (directoryAsNamespace) {
|
|
167
|
+
if (globalNamespaces.some((name) => folders.includes(name))) folders = folders.filter((f) => !globalNamespaces.includes(f));
|
|
168
|
+
folders = folders.map((f) => f.replace(/[^a-z0-9\-]/gi, ""));
|
|
169
|
+
if (filename.toLowerCase() === "index") filename = "";
|
|
170
|
+
if (!isEmpty(folders)) {
|
|
171
|
+
let namespaced = [...folders, filename];
|
|
172
|
+
if (collapseSamePrefixes) {
|
|
173
|
+
const collapsed = [];
|
|
174
|
+
for (const fileOrFolderName of namespaced) {
|
|
175
|
+
let cumulativePrefix = "";
|
|
176
|
+
let didCollapse = false;
|
|
177
|
+
const pascalCasedName = pascalCase(fileOrFolderName);
|
|
178
|
+
for (const parentFolder of [...collapsed].reverse()) {
|
|
179
|
+
cumulativePrefix = `${parentFolder}${cumulativePrefix}`;
|
|
180
|
+
if (pascalCasedName.startsWith(cumulativePrefix)) {
|
|
181
|
+
const collapseSamePrefix = pascalCasedName.slice(cumulativePrefix.length);
|
|
182
|
+
collapsed.push(collapseSamePrefix);
|
|
183
|
+
didCollapse = true;
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (!didCollapse) collapsed.push(pascalCasedName);
|
|
188
|
+
}
|
|
189
|
+
namespaced = collapsed;
|
|
190
|
+
}
|
|
191
|
+
filename = namespaced.filter(Boolean).join("-");
|
|
192
|
+
}
|
|
193
|
+
return filename;
|
|
194
|
+
}
|
|
195
|
+
return filename;
|
|
196
|
+
}
|
|
197
|
+
function resolveAlias(filepath, alias) {
|
|
198
|
+
const result = filepath;
|
|
199
|
+
if (Array.isArray(alias)) for (const { find, replacement } of alias) result.replace(find, replacement);
|
|
200
|
+
return result;
|
|
201
|
+
}
|
|
202
|
+
async function getPkgVersion(pkgName, defaultVersion) {
|
|
203
|
+
try {
|
|
204
|
+
if (isPackageExists(pkgName)) return (await getPackageInfo(pkgName))?.version ?? defaultVersion;
|
|
205
|
+
else return defaultVersion;
|
|
206
|
+
} catch (err) {
|
|
207
|
+
console.error(err);
|
|
208
|
+
return defaultVersion;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function shouldTransform(code) {
|
|
212
|
+
if (code.includes("/* unplugin-vue-components disabled */")) return false;
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
function isExclude(name, exclude) {
|
|
216
|
+
if (!exclude) return false;
|
|
217
|
+
if (typeof exclude === "string") return name === exclude;
|
|
218
|
+
if (exclude instanceof RegExp) return !!name.match(exclude);
|
|
219
|
+
if (Array.isArray(exclude)) {
|
|
220
|
+
for (const item of exclude) if (name === item || name.match(item)) return true;
|
|
221
|
+
}
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
const ESCAPE_PARENTHESES_REGEX = /[()]/g;
|
|
225
|
+
function escapeSpecialChars(str) {
|
|
226
|
+
return str.replace(ESCAPE_PARENTHESES_REGEX, "\\$&");
|
|
227
|
+
}
|
|
228
|
+
//#endregion
|
|
229
|
+
export { notNullish as _, getTransformedPath as a, toArray as b, kebabCase as c, parseId as d, pascalCase as f, DISABLE_COMMENT as g, stringifyComponentImport as h, getPkgVersion as i, matchGlobs as l, shouldTransform as m, escapeSpecialChars as n, isExclude as o, resolveAlias as p, getNameFromFilePath as r, isSSR as s, camelCase as t, normalizeComponentInfo as u, slash as v, throttle as y };
|
package/dist/vite.d.mts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { d as PublicPluginAPI, u as Options } from "./types-BbnOeCab.mjs";
|
|
2
|
+
import { Plugin } from "vite";
|
|
3
|
+
|
|
4
|
+
//#region src/vite.d.ts
|
|
5
|
+
declare const vite: (options?: Options | undefined) => Plugin<any> & {
|
|
6
|
+
api: PublicPluginAPI;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { vite as default, vite as "module.exports" };
|
package/dist/vite.mjs
ADDED
package/dist/webpack.mjs
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pit-frontend-framework/unplugin-vue-components",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "湖南创智艾泰克科技有限公司-前端组组件自动导入插件库",
|
|
6
|
+
"author": "湖南创智艾泰克科技有限公司-前端组",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/index.mjs",
|
|
9
|
+
"./esbuild": "./dist/esbuild.mjs",
|
|
10
|
+
"./nuxt": "./dist/nuxt.mjs",
|
|
11
|
+
"./resolvers": "./dist/resolvers.mjs",
|
|
12
|
+
"./rolldown": "./dist/rolldown.mjs",
|
|
13
|
+
"./rollup": "./dist/rollup.mjs",
|
|
14
|
+
"./rspack": "./dist/rspack.mjs",
|
|
15
|
+
"./types": "./dist/types.mjs",
|
|
16
|
+
"./vite": "./dist/vite.mjs",
|
|
17
|
+
"./webpack": "./dist/webpack.mjs",
|
|
18
|
+
"./package.json": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"typesVersions": {
|
|
22
|
+
"*": {
|
|
23
|
+
"*": [
|
|
24
|
+
"./dist/*.d.mts",
|
|
25
|
+
"./*"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=20.19.0"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsdown",
|
|
37
|
+
"dev": "tsdown -w",
|
|
38
|
+
"example:build": "npm -C examples/vite-vue3 run build",
|
|
39
|
+
"example:dev": "npm -C examples/vite-vue3 run dev",
|
|
40
|
+
"prepublishOnly": "npm run build",
|
|
41
|
+
"lint": "eslint .",
|
|
42
|
+
"typecheck": "tsgo",
|
|
43
|
+
"release": "bumpp",
|
|
44
|
+
"test": "vitest",
|
|
45
|
+
"test:update": "vitest -u"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@nuxt/kit": "^3.2.2 || ^4.0.0",
|
|
49
|
+
"vue": "^3.0.0"
|
|
50
|
+
},
|
|
51
|
+
"peerDependenciesMeta": {
|
|
52
|
+
"@nuxt/kit": {
|
|
53
|
+
"optional": true
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"chokidar": "^5.0.0",
|
|
58
|
+
"local-pkg": "^1.2.0",
|
|
59
|
+
"magic-string": "^0.30.21",
|
|
60
|
+
"mlly": "^1.8.2",
|
|
61
|
+
"obug": "^2.1.1",
|
|
62
|
+
"picomatch": "^4.0.4",
|
|
63
|
+
"tinyglobby": "^0.2.16",
|
|
64
|
+
"unplugin": "^3.0.0",
|
|
65
|
+
"unplugin-utils": "^0.3.1"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@antfu/eslint-config": "^9.0.0",
|
|
69
|
+
"@antfu/utils": "^9.3.0",
|
|
70
|
+
"@nuxt/kit": "^4.4.6",
|
|
71
|
+
"@nuxt/schema": "^4.4.6",
|
|
72
|
+
"@types/node": "^25.9.1",
|
|
73
|
+
"@types/picomatch": "^4.0.3",
|
|
74
|
+
"@typescript/native-preview": "7.0.0-dev.20260114.1",
|
|
75
|
+
"bumpp": "^11.1.0",
|
|
76
|
+
"compare-versions": "^6.1.1",
|
|
77
|
+
"element-plus": "^2.14.0",
|
|
78
|
+
"eslint": "^10.4.0",
|
|
79
|
+
"eslint-plugin-format": "^2.0.1",
|
|
80
|
+
"pathe": "^2.0.3",
|
|
81
|
+
"rolldown": "^1.0.1",
|
|
82
|
+
"rollup": "^4.60.4",
|
|
83
|
+
"tsdown": "^0.22.0",
|
|
84
|
+
"typescript": "^6.0.3",
|
|
85
|
+
"vite": "^8.0.13",
|
|
86
|
+
"vitest": "^4.1.6",
|
|
87
|
+
"vue": "3.2.45",
|
|
88
|
+
"vue-tsc": "^3.3.1",
|
|
89
|
+
"webpack": "^5.106.2"
|
|
90
|
+
},
|
|
91
|
+
"inlinedDependencies": {
|
|
92
|
+
"@antfu/utils": "9.3.0",
|
|
93
|
+
"compare-versions": "6.1.1"
|
|
94
|
+
}
|
|
95
|
+
}
|