first commit

This commit is contained in:
2025-12-29 14:59:44 +08:00
commit 10c3fbb0d7
5315 changed files with 795443 additions and 0 deletions

21
node_modules/unplugin-vue-components/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020-PRESENT Anthony Fu<https://github.com/antfu>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

496
node_modules/unplugin-vue-components/README.md generated vendored Normal file
View File

@@ -0,0 +1,496 @@
# unplugin-vue-components
[![NPM version](https://img.shields.io/npm/v/unplugin-vue-components?color=a1b858&label=)](https://www.npmjs.com/package/unplugin-vue-components)
On-demand components auto importing for Vue.
###### Features
- 💚 Supports both Vue 2 and Vue 3 out-of-the-box.
- ✨ Supports both components and directives.
- ⚡️ Supports Vite, Webpack, Rspack, Vue CLI, Rollup, esbuild and more, powered by <a href="https://github.com/unjs/unplugin">unplugin</a>.
- 🏝 Tree-shakable, only registers the components you use.
- 🪐 Folder names as namespaces.
- 🦾 Full TypeScript support.
- 🌈 [Built-in resolvers](#importing-from-ui-libraries) for popular UI libraries.
- 😃 Works perfectly with [unplugin-icons](https://github.com/antfu/unplugin-icons).
<br>
<p align="center">
<a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/>
</a>
</p>
<br>
## Installation
```bash
npm i unplugin-vue-components -D
```
> **`vite-plugin-components` has been renamed to `unplugin-vue-components`**, see the [migration guide](#migrate-from-vite-plugin-components).
<details>
<summary>Vite</summary><br>
```ts
// vite.config.ts
import Components from 'unplugin-vue-components/vite'
export default defineConfig({
plugins: [
Components({ /* options */ }),
],
})
```
<br></details>
<details>
<summary>Rollup</summary><br>
```ts
// rollup.config.js
import Components from 'unplugin-vue-components/rollup'
export default {
plugins: [
Components({ /* options */ }),
],
}
```
<br></details>
<details>
<summary>Rolldown</summary><br>
```ts
// rolldown.config.js
import Components from 'unplugin-vue-components/rolldown'
export default {
plugins: [
Components({ /* options */ }),
],
}
```
<br></details>
<details>
<summary>Webpack</summary><br>
```ts
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-vue-components/webpack')({ /* options */ }),
],
}
```
<br></details>
<details>
<summary>Rspack</summary><br>
```ts
// rspack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-vue-components/rspack')({ /* options */ }),
],
}
```
<br></details>
<details>
<summary>Nuxt</summary><br>
You might not need this plugin for Nuxt. Use [`@nuxt/components`](https://github.com/nuxt/components) instead.
<br></details>
<details>
<summary>Vue CLI</summary><br>
```ts
// vue.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-vue-components/webpack')({ /* options */ }),
],
}
```
You can also rename the Vue configuration file to `vue.config.mjs` and use static import syntax (you should use latest `@vue/cli-service ^5.0.8`):
```ts
// vue.config.mjs
import Components from 'unplugin-vue-components/webpack'
export default {
configureWebpack: {
plugins: [
Components({ /* options */ }),
],
},
}
```
<br></details>
<details>
<summary>Quasar</summary><br>
```ts
// vite.config.js [Vite]
import Components from 'unplugin-vue-components/vite'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [
Components({ /* options */ })
]
})
```
```ts
// quasar.config.js
export default defineConfig(() => {
return {
build: {
vitePlugins: [
['unplugin-vue-components/vite', { /* options */ }],
]
},
}
})
```
<br></details>
<details>
<summary>esbuild</summary><br>
```ts
// esbuild.config.js
import { build } from 'esbuild'
import Components from 'unplugin-vue-components/esbuild'
build({
/* ... */
plugins: [
Components({
/* options */
}),
],
})
```
<br></details>
## Usage
Use components in templates as you would usually do, it will import components on demand, and there is no `import` and `component registration` required anymore! If you register the parent component asynchronously (or lazy route), the auto-imported components will be code-split along with their parent.
It will automatically turn this
```html
<template>
<div>
<HelloWorld msg="Hello Vue 3.0 + Vite" />
</div>
</template>
<script>
export default {
name: 'App',
}
</script>
```
into this
```html
<template>
<div>
<HelloWorld msg="Hello Vue 3.0 + Vite" />
</div>
</template>
<script>
import HelloWorld from './src/components/HelloWorld.vue'
export default {
name: 'App',
components: {
HelloWorld,
},
}
</script>
```
> **Note**
> By default this plugin will import components in the `src/components` path. You can customize it using the `dirs` option.
## TypeScript
To get TypeScript support for auto-imported components, there is [a PR](https://github.com/vuejs/core/pull/3399) to Vue 3 extending the interface of global components. Currently, [Volar](https://github.com/johnsoncodehk/volar) has supported this usage already. If you are using Volar, you can change the config as following to get the support.
```ts
Components({
dts: true, // enabled by default if `typescript` is installed
})
```
Once the setup is done, a `components.d.ts` will be generated and updates automatically with the type definitions. Feel free to commit it into git or not as you want.
> **Make sure you also add `components.d.ts` to your `tsconfig.json` under `include`.**
## Importing from UI Libraries
We have several built-in resolvers for popular UI libraries like **Vuetify**, **Ant Design Vue**, and **Element Plus**, where you can enable them by:
Supported Resolvers:
- [Ant Design Vue](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/antdv.ts)
- [Arco Design Vue](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/arco.ts)
- [BootstrapVue](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/bootstrap-vue.ts)
- [Element Plus](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/element-plus.ts)
- [Element UI](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/element-ui.ts)
- [Headless UI](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/headless-ui.ts)
- [IDux](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/idux.ts)
- [Inkline](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/inkline.ts)
- [Ionic](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/ionic.ts)
- [Naive UI](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/naive-ui.ts)
- [Prime Vue](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/prime-vue.ts)
- [Quasar](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/quasar.ts)
- [TDesign](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/tdesign.ts)
- [`@tdesign-vue-next/auto-import-resolver`](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/auto-import-resolver/README.md) - TDesign's own auto-import resolver
- [Vant](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/vant.ts)
- [`@vant/auto-import-resolver`](https://github.com/youzan/vant/blob/main/packages/vant-auto-import-resolver/README.md) - Vant's own auto-import resolver
- [Varlet UI](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/varlet-ui.ts)
- [`@varlet/import-resolver`](https://github.com/varletjs/varlet/blob/dev/packages/varlet-import-resolver/README.md) - Varlet's own auto-import resolver
- [VEUI](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/veui.ts)
- [View UI](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/view-ui.ts)
- [Vuetify](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/vuetify.ts) &mdash; Prefer first-party plugins when possible: [v3 + vite](https://www.npmjs.com/package/vite-plugin-vuetify), [v3 + webpack](https://www.npmjs.com/package/webpack-plugin-vuetify), [v2 + webpack](https://npmjs.com/package/vuetify-loader)
- [VueUse Components](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/vueuse.ts)
- [VueUse Directives](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/vueuse-directive.ts)
- [Dev UI](https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/devui.ts)
```ts
import {
AntDesignVueResolver,
ElementPlusResolver,
VantResolver,
} from 'unplugin-vue-components/resolvers'
// vite.config.js
import Components from 'unplugin-vue-components/vite'
// your plugin installation
Components({
resolvers: [
AntDesignVueResolver(),
ElementPlusResolver(),
VantResolver(),
],
})
```
You can also write your own resolver quickly:
```ts
Components({
resolvers: [
// example of importing Vant
(componentName) => {
// where `componentName` is always CapitalCase
if (componentName.startsWith('Van'))
return { name: componentName.slice(3), from: 'vant' }
},
],
})
```
> [We no longer accept new resolvers](./src/core/resolvers/_READ_BEFORE_CONTRIBUTE.md).
## Types for global registered components
Some libraries might register some global components for you to use anywhere (e.g. Vue Router provides `<RouterLink>` and `<RouterView>`). Since they are global available, there is no need for this plugin to import them. However, those are commonly not TypeScript friendly, and you might need to register their types manually.
Thus `unplugin-vue-components` provided a way to only register types for global components.
```ts
Components({
dts: true,
types: [{
from: 'vue-router',
names: ['RouterLink', 'RouterView'],
}],
})
```
So the `RouterLink` and `RouterView` will be presented in `components.d.ts`.
By default, `unplugin-vue-components` detects supported libraries automatically (e.g. `vue-router`) when they are installed in the workspace. If you want to disable it completely, you can pass an empty array to it:
```ts
Components({
// Disable type only registration
types: [],
})
```
## Migrate from `vite-plugin-components`
`package.json`
```diff
{
"devDependencies": {
- "vite-plugin-components": "*",
+ "unplugin-vue-components": "^0.14.0",
}
}
```
`vite.config.js`
```diff
- import Components, { ElementPlusResolver } from 'vite-plugin-components'
+ import Components from 'unplugin-vue-components/vite'
+ import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
export default {
plugins: [
/* ... */
Components({
/* ... */
// `customComponentsResolvers` has renamed to `resolver`
- customComponentsResolvers: [
+ resolvers: [
ElementPlusResolver(),
],
// `globalComponentsDeclaration` has renamed to `dts`
- globalComponentsDeclaration: true,
+ dts: true,
// `customLoaderMatcher` is depreacted, use `include` instead
- customLoaderMatcher: id => id.endsWith('.md'),
+ include: [/\.vue$/, /\.vue\?vue/, /\.vue\.[tj]sx?\?vue/, /\.md$/],
}),
],
}
```
## Configuration
The following show the default values of the configuration
```ts
Components({
// relative paths to the directory to search for components.
dirs: ['src/components'],
// valid file extensions for components.
extensions: ['vue'],
// Glob patterns to match file names to be detected as components.
// You can also specify multiple like this: `src/components/*.{vue,tsx}`
// When specified, the `dirs`, `extensions`, and `directoryAsNamespace` options will be ignored.
// If you want to exclude components being registered, use negative globs with leading `!`.
globs: ['src/components/*.vue'],
// search for subdirectories
deep: true,
// resolvers for custom components
resolvers: [],
// generate `components.d.ts` global declarations,
// also accepts a path for custom filename
// default: `true` if package typescript is installed
dts: false,
// generate dts with TSX support
// default: `true` if `@vitejs/plugin-vue-jsx` is installed
dtsTsx: false,
// Allow subdirectories as namespace prefix for components.
directoryAsNamespace: false,
// Collapse same prefixes (camel-sensitive) of folders and components
// to prevent duplication inside namespaced component name.
// works when `directoryAsNamespace: true`
collapseSamePrefixes: false,
// Subdirectory paths for ignoring namespace prefixes.
// works when `directoryAsNamespace: true`
globalNamespaces: [],
// auto import for directives
// default: `true` for Vue 3, `false` for Vue 2
// Babel is needed to do the transformation for Vue 2, it's disabled by default for performance concerns.
// To install Babel, run: `npm install -D @babel/parser`
directives: true,
// Transform path before resolving
importPathTransform: v => v,
// Allow for components to override other components with the same name
allowOverrides: false,
// Filters for transforming targets (components to insert the auto import)
// Note these are NOT about including/excluding components registered - use `globs` or `excludeNames` for that
include: [/\.vue$/, /\.vue\?vue/, /\.vue\.[tj]sx?\?vue/],
exclude: [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/, /[\\/]\.nuxt[\\/]/],
// Filters for component names that will not be imported
// Use for globally imported async components or other conflicts that the plugin cannot detect
excludeNames: [/^Async.+/],
// Vue version of project. It will detect automatically if not specified.
// Acceptable value: 2 | 2.7 | 3
version: 2.7,
// Only provide types of components in library (registered globally)
// see https://github.com/unplugin/unplugin-vue-components/blob/main/src/core/type-imports/index.ts
types: [
/* ... */
],
// Save component information into a JSON file for other tools to consume.
// Provide a filepath to save the JSON file.
// When set to `true`, it will save to `./.components-info.json`
dumpComponentsInfo: false,
// The mode for syncing the components.d.ts and .components-info.json file.
// 'append': only append the new components to the existing files.
// 'overwrite': overwrite the whole existing files with the current components.
// 'default': use 'append' strategy when using dev server, 'overwrite' strategy when using build.
syncMode: 'default',
})
```
## Example
[Vitesse](https://github.com/antfu/vitesse) starter template.
## Thanks
Thanks to [@brattonross](https://github.com/brattonross), this project is heavily inspired by [vite-plugin-voie](https://github.com/vamplate/vite-plugin-voie).
## License
[MIT](./LICENSE) License © 2020-PRESENT [Anthony Fu](https://github.com/antfu)

View File

@@ -0,0 +1,9 @@
require('./utils-8UQ22cuO.cjs');
const require_src = require('./src-DzdkjKhH.cjs');
require('./types-CBTc19th.cjs');
//#region src/esbuild.ts
var esbuild_default = require_src.unplugin_default.esbuild;
//#endregion
module.exports = esbuild_default;

View File

@@ -0,0 +1,6 @@
import { Options } from "./types-DSJ5r-ta.cjs";
import * as esbuild0 from "esbuild";
//#region src/esbuild.d.ts
declare const _default: (options: Options) => esbuild0.Plugin;
export = _default;

View File

@@ -0,0 +1,7 @@
import { Options } from "./types-rC3290ja.js";
import * as esbuild0 from "esbuild";
//#region src/esbuild.d.ts
declare const _default: (options: Options) => esbuild0.Plugin;
//#endregion
export { _default as default };

9
node_modules/unplugin-vue-components/dist/esbuild.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import "./utils-BoXu-4gQ.js";
import { unplugin_default } from "./src-BcnnO6GN.js";
import "./types-DQoXDiso.js";
//#region src/esbuild.ts
var esbuild_default = unplugin_default.esbuild;
//#endregion
export { esbuild_default as default };

9
node_modules/unplugin-vue-components/dist/index.cjs generated vendored Normal file
View File

@@ -0,0 +1,9 @@
Object.defineProperty(exports, '__esModule', { value: true });
const require_utils = require('./utils-8UQ22cuO.cjs');
const require_src = require('./src-DzdkjKhH.cjs');
require('./types-CBTc19th.cjs');
exports.camelCase = require_utils.camelCase;
exports.default = require_src.unplugin_default;
exports.kebabCase = require_utils.kebabCase;
exports.pascalCase = require_utils.pascalCase;

13
node_modules/unplugin-vue-components/dist/index.d.cts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
import { ComponentInfo, ComponentResolveResult, ComponentResolver, ComponentResolverFunction, ComponentResolverObject, ComponentsImportMap, ImportInfo, ImportInfoLegacy, Matcher, Options, PublicPluginAPI, ResolvedOptions, SideEffectsInfo, SupportedTransformer, Transformer, TypeImport } from "./types-DSJ5r-ta.cjs";
import * as unplugin0 from "unplugin";
import { FilterPattern } from "unplugin-utils";
//#region src/core/unplugin.d.ts
declare const _default: unplugin0.UnpluginInstance<Options, boolean>;
//#endregion
//#region src/core/utils.d.ts
declare function pascalCase(str: string): string;
declare function camelCase(str: string): string;
declare function kebabCase(key: string): string;
//#endregion
export { ComponentInfo, ComponentResolveResult, ComponentResolver, ComponentResolverFunction, ComponentResolverObject, ComponentsImportMap, ImportInfo, ImportInfoLegacy, Matcher, Options, PublicPluginAPI, ResolvedOptions, SideEffectsInfo, SupportedTransformer, Transformer, TypeImport, camelCase, _default as default, kebabCase, pascalCase };

13
node_modules/unplugin-vue-components/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
import { ComponentInfo, ComponentResolveResult, ComponentResolver, ComponentResolverFunction, ComponentResolverObject, ComponentsImportMap, ImportInfo, ImportInfoLegacy, Matcher, Options, PublicPluginAPI, ResolvedOptions, SideEffectsInfo, SupportedTransformer, Transformer, TypeImport } from "./types-rC3290ja.js";
import * as unplugin0 from "unplugin";
import { FilterPattern } from "unplugin-utils";
//#region src/core/unplugin.d.ts
declare const _default: unplugin0.UnpluginInstance<Options, boolean>;
//#endregion
//#region src/core/utils.d.ts
declare function pascalCase(str: string): string;
declare function camelCase(str: string): string;
declare function kebabCase(key: string): string;
//#endregion
export { ComponentInfo, ComponentResolveResult, ComponentResolver, ComponentResolverFunction, ComponentResolverObject, ComponentsImportMap, ImportInfo, ImportInfoLegacy, Matcher, Options, PublicPluginAPI, ResolvedOptions, SideEffectsInfo, SupportedTransformer, Transformer, TypeImport, camelCase, _default as default, kebabCase, pascalCase };

5
node_modules/unplugin-vue-components/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import { camelCase, kebabCase, pascalCase } from "./utils-BoXu-4gQ.js";
import { unplugin_default } from "./src-BcnnO6GN.js";
import "./types-DQoXDiso.js";
export { camelCase, unplugin_default as default, kebabCase, pascalCase };

14
node_modules/unplugin-vue-components/dist/nuxt.cjs generated vendored Normal file
View File

@@ -0,0 +1,14 @@
const require_utils = require('./utils-8UQ22cuO.cjs');
const require_src = require('./src-DzdkjKhH.cjs');
require('./types-CBTc19th.cjs');
let __nuxt_kit = require("@nuxt/kit");
__nuxt_kit = require_utils.__toESM(__nuxt_kit);
//#region src/nuxt.ts
var nuxt_default = (0, __nuxt_kit.defineNuxtModule)({ setup(options) {
(0, __nuxt_kit.addWebpackPlugin)(require_src.unplugin_default.webpack(options));
(0, __nuxt_kit.addVitePlugin)(require_src.unplugin_default.vite(options));
} });
//#endregion
module.exports = nuxt_default;

6
node_modules/unplugin-vue-components/dist/nuxt.d.cts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import { Options } from "./types-DSJ5r-ta.cjs";
import * as _nuxt_schema0 from "@nuxt/schema";
//#region src/nuxt.d.ts
declare const _default: _nuxt_schema0.NuxtModule<Options, Options, false>;
export = _default;

7
node_modules/unplugin-vue-components/dist/nuxt.d.ts generated vendored Normal file
View File

@@ -0,0 +1,7 @@
import { Options } from "./types-rC3290ja.js";
import * as _nuxt_schema0 from "@nuxt/schema";
//#region src/nuxt.d.ts
declare const _default: _nuxt_schema0.NuxtModule<Options, Options, false>;
//#endregion
export { _default as default };

13
node_modules/unplugin-vue-components/dist/nuxt.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
import "./utils-BoXu-4gQ.js";
import { unplugin_default } from "./src-BcnnO6GN.js";
import "./types-DQoXDiso.js";
import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit";
//#region src/nuxt.ts
var nuxt_default = defineNuxtModule({ setup(options) {
addWebpackPlugin(unplugin_default.webpack(options));
addVitePlugin(unplugin_default.vite(options));
} });
//#endregion
export { nuxt_default as default };

2074
node_modules/unplugin-vue-components/dist/resolvers.cjs generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,574 @@
import { ComponentResolveResult, ComponentResolver } from "./types-DSJ5r-ta.cjs";
import { FilterPattern } from "unplugin-utils";
//#region src/core/resolvers/antdv.d.ts
interface AntDesignVueResolverOptions {
/**
* exclude components that do not require automatic import
*
* @default []
*/
exclude?: string[];
/**
* import style along with components
*
* @default 'css'
*/
importStyle?: boolean | 'css' | 'less' | 'css-in-js';
/**
* resolve `ant-design-vue' icons
*
* requires package `@ant-design/icons-vue`
*
* @default false
*/
resolveIcons?: boolean;
/**
* @deprecated use `importStyle: 'css'` instead
*/
importCss?: boolean;
/**
* @deprecated use `importStyle: 'less'` instead
*/
importLess?: boolean;
/**
* use commonjs build default false
*/
cjs?: boolean;
/**
* rename package
*
* @default 'ant-design-vue'
*/
packageName?: string;
/**
* customize prefix of component
* @default 'A'
*/
prefix?: string;
}
/**
* Resolver for Ant Design Vue
*
* Requires ant-design-vue@v2.2.0-beta.6 or later
*
* See https://github.com/antfu/unplugin-vue-components/issues/26#issuecomment-789767941 for more details
*
* @author @yangss3
* @link https://antdv.com/
*/
declare function AntDesignVueResolver(options?: AntDesignVueResolverOptions): ComponentResolver;
//#endregion
//#region src/core/resolvers/arco.d.ts
type DisallowResolveIconOption = undefined | false | {
enable: false;
};
type AllowResolveIconOption = true | {
enable: true;
iconPrefix?: string;
};
type ResolveIconsOption = DisallowResolveIconOption | AllowResolveIconOption;
interface ArcoResolverOptions {
/**
* exclude components that do not require automatic import
*
* @default []
*/
exclude?: string | RegExp | (string | RegExp)[];
/**
* import style css or less with components
*
* @default 'css'
*/
importStyle?: boolean | 'css' | 'less';
/**
* resolve icons
*
* @default false
*/
resolveIcons?: ResolveIconsOption;
/**
* Control style automatic import
*
* @default true
*/
sideEffect?: boolean;
}
/**
* Resolver for Arco Design Vue
*
* Requires arco-design/web-vue@2.11.0 or later
*
* @author @flsion
* @link https://arco.design/ for arco-design
*
*/
declare function ArcoResolver(options?: ArcoResolverOptions): ComponentResolver;
//#endregion
//#region src/core/resolvers/bootstrap-vue.d.ts
interface BootstrapVueResolverOptions {
/**
* Auto import for directives.
*
* @default true
*/
directives?: boolean;
}
/**
* Resolver for BootstrapVue
*
* @link https://github.com/bootstrap-vue/bootstrap-vue
*/
declare function BootstrapVueResolver(_options?: BootstrapVueResolverOptions): ComponentResolver[];
/**
* Resolver for BootstrapVueNext
*
* @link https://github.com/bootstrap-vue/bootstrap-vue-next
*
* @deprecated use `import { BootstrapVueNextResolver } from 'bootstrap-vue-next'` instead
*/
declare function BootstrapVueNextResolver(_options?: BootstrapVueResolverOptions): Array<ComponentResolver>;
/**
* Resolver for legacy BootstrapVue3 apps
*
* @deprecated use BootstrapVueNextResolver with https://github.com/bootstrap-vue/bootstrap-vue-next
* @link https://www.npmjs.com/package/bootstrap-vue-3
*/
declare function BootstrapVue3Resolver(_options?: BootstrapVueResolverOptions): Array<ComponentResolver>;
//#endregion
//#region src/core/resolvers/devui.d.ts
interface DevResolverOptions {
/**
* bring in components and styles
*
* @default true
*/
importStyle?: boolean;
/**
* auto import for directives
*
* @default true
*/
directives?: boolean;
/**
* use umd lib file
*/
ssr?: boolean;
}
declare function DevUiResolver(options?: DevResolverOptions): ComponentResolver[];
//#endregion
//#region src/core/resolvers/element-plus.d.ts
interface ElementPlusResolverOptions {
/**
* import style css or sass with components
*
* @default 'css'
*/
importStyle?: boolean | 'css' | 'sass';
/**
* use commonjs lib & source css or scss for ssr
*/
ssr?: boolean;
/**
* specify element-plus version to load style
*
* @default installed version
*/
version?: string;
/**
* auto import for directives
*
* @default true
*/
directives?: boolean;
/**
* exclude component name, if match do not resolve the name
*/
exclude?: RegExp;
/**
* a list of component names that have no styles, so resolving their styles file should be prevented
*/
noStylesComponents?: string[];
/**
* nightly version
*/
nightly?: boolean;
}
/**
* Resolver for Element Plus
*
* See https://github.com/antfu/vite-plugin-components/pull/28 for more details
* See https://github.com/antfu/vite-plugin-components/issues/117 for more details
*
* @author @develar @nabaonan @sxzz
* @link https://element-plus.org/ for element-plus
*
*/
declare function ElementPlusResolver(options?: ElementPlusResolverOptions): ComponentResolver[];
//#endregion
//#region src/core/resolvers/element-ui.d.ts
interface ElementUiResolverOptions {
/**
* import style css or sass with components
*
* @default 'css'
*/
importStyle?: boolean | 'css' | 'sass';
/**
* exclude component name, if match do not resolve the name
*/
exclude?: RegExp;
}
/**
* Resolver for Element-UI
* @link https://element.eleme.cn/#/zh-CN
* @version @element-ui ^2.15.3, @vue ^2.6.14
* @author @nabaonan
*/
declare function ElementUiResolver(options?: ElementUiResolverOptions): ComponentResolver;
//#endregion
//#region src/core/resolvers/headless-ui.d.ts
interface HeadlessUiResolverOptions {
/**
* prefix for headless ui components used in templates
*
* @default ""
*/
prefix?: string;
}
/**
* Resolver for headlessui
*
* @link https://github.com/tailwindlabs/headlessui
*/
declare function HeadlessUiResolver(options?: HeadlessUiResolverOptions): ComponentResolver;
//#endregion
//#region src/core/resolvers/idux.d.ts
interface IduxResolverOptions {
/**
* exclude components that do not require automatic import
*
* @default []
*/
exclude?: string[];
/**
* import style along with components
*/
importStyle?: 'css' | 'less';
/**
* theme for import style
*
* @default 'default' for 1.x version
*/
importStyleTheme?: string;
/**
* The scope of the packages.
*
* @default '@idux'
*/
scope?: string;
/**
* specify idux version to load style
*
* @default installed version
*/
version?: string;
}
/**
* Resolver for `@idux/cdk`, `@idux/components` and ``@idux/pro``
*
* @link https://idux.site
*/
declare function IduxResolver(options?: IduxResolverOptions): ComponentResolver;
//#endregion
//#region src/core/resolvers/inkline.d.ts
/**
* Resolver for Inkline
*
* @author @alexgrozav
* @link https://github.com/inkline/inkline
*/
declare function InklineResolver(): ComponentResolver;
//#endregion
//#region src/core/resolvers/ionic.d.ts
/**
* source: https://github.com/nuxt-modules/ionic/blob/main/src/imports.ts
* @author @danielroe
*/
declare const IonicBuiltInComponents: string[];
/**
* Resolver for ionic framework
*
* @author @mathsgod @reslear
* @link https://ionicframework.com/
*/
declare function IonicResolver(): ComponentResolver;
//#endregion
//#region src/core/resolvers/layui-vue.d.ts
interface LayuiVueResolverOptions {
/**
* import style along with components
*
* @default 'css'
*/
importStyle?: boolean | 'css';
/**
* resolve '@layui/layui-vue' icons
* requires package `@layui/icons-vue`
*
* @default false
*/
resolveIcons?: boolean;
/**
* exclude components that do not require automatic import
*
*/
exclude?: FilterPattern;
}
/**
* Resolver for layui-vue
*
* @link http://www.layui-vue.com/ for layui-vue
*
*/
declare function LayuiVueResolver(options?: LayuiVueResolverOptions): ComponentResolver;
//#endregion
//#region src/core/resolvers/naive-ui.d.ts
/**
* Resolver for Naive UI
*
* @author @antfu
* @link https://www.naiveui.com/
*/
declare function NaiveUiResolver(): ComponentResolver;
//#endregion
//#region src/core/resolvers/prime-vue.d.ts
interface PrimeVueResolverOptions {
/**
* import style along with components
*
* @default true
*/
importStyle?: boolean;
/**
* import `primeicons' icons
*
* requires package `primeicons`
*
* @default true
*/
importIcons?: boolean;
/**
* imports a free theme - set theme name here (e.g. saga-blue)
*
* @default ''
*/
importTheme?: string;
/**
* prefix for components (e.g. 'P' to resolve Menu from PMenu)
*
* @default ''
*/
prefix?: string;
}
/**
* Resolver for PrimeVue - If you're using a component with the same tag as an native HTML element (e.g. button) the component must be in uppercase
*
* @link https://github.com/primefaces/primevue
*/
declare function PrimeVueResolver(options?: PrimeVueResolverOptions): ComponentResolver;
//#endregion
//#region src/core/resolvers/quasar.d.ts
/**
* Resolver for Quasar
*
* @link https://github.com/quasarframework/quasar
*/
declare function QuasarResolver(): ComponentResolver;
//#endregion
//#region src/core/resolvers/tdesign.d.ts
interface TDesignResolverOptions {
/**
* select the specified library
* @default 'vue'
*/
library?: 'vue' | 'vue-next' | 'react' | 'mobile-vue' | 'mobile-react';
/**
* resolve `tdesign-icons'
* @default false
*/
resolveIcons?: boolean;
/**
* whether to import ESM version
* @default false
*/
esm?: boolean;
/**
* exclude component name, if match do not resolve the name
*
*/
exclude?: FilterPattern;
}
declare function TDesignResolver(options?: TDesignResolverOptions): ComponentResolver;
//#endregion
//#region src/core/resolvers/vant.d.ts
interface VantResolverOptions {
/**
* import style css or less along with components
*
* @default true
*/
importStyle?: boolean | 'css' | 'less';
}
/**
* Resolver for Vant
*
* @link https://github.com/youzan/vant
*/
declare function VantResolver(options?: VantResolverOptions): ComponentResolver;
//#endregion
//#region src/core/resolvers/varlet-ui.d.ts
interface VarletUIResolverOptions {
/**
* support vue version
* vue3 use @varlet/ui, vue2 use @varlet-vue2/ui
*
* @default 'vue3'
*/
version?: 'vue3' | 'vue2';
/**
* import style along with components
*
* @default 'css'
*/
importStyle?: boolean | 'css' | 'less';
/**
* style entry file extname
*
* @default '.mjs'
*/
styleExtname?: string;
/**
* auto import for directives
*
* @default true
*/
directives?: boolean;
/**
* compatible with unplugin-auto-import
*
* @default false
*/
autoImport?: boolean;
/**
* @deprecated use `importStyle: 'css'` instead
*/
importCss?: boolean;
/**
* @deprecated use `importStyle: 'less'` instead
*/
importLess?: boolean;
}
declare function getResolved(name: string, options: VarletUIResolverOptions): ComponentResolveResult;
/**
* Resolver for VarletUI
*
* @link https://github.com/varletjs/varlet
* @link https://github.com/varletjs/varlet-vue2
*/
declare function VarletUIResolver(options?: VarletUIResolverOptions): ComponentResolver[];
//#endregion
//#region src/core/resolvers/veui.d.ts
interface VeuiPeerConfig {
/**
* The package name of the peer module.
*/
package: string;
/**
* The directory path of the peer module.
* @default 'components'
*/
path?: string;
/**
* The file name template for the peer module.
* @default '{module}.css'
*/
fileName?: `${string}{module}${string}`;
/**
* The text transform to be applied to the '{module}' part of the file name.
* @default 'kebab-case'
*/
transform?: 'kebab-case' | 'camelCase' | 'PascalCase' | false;
}
type SupportedLocale = 'en-US' | 'zh-Hans';
interface VeuiResolverOptions {
/**
* The alias of 'veui` package.
* @default 'veui'
*/
alias?: string;
/**
* Peer modules to be injected.
*/
modules?: VeuiPeerConfig[];
/**
* Locale modules to be injected.
* @default 'zh-Hans'
*/
locale?: SupportedLocale | SupportedLocale[] | false;
/**
* Global modules to be injected to all components.
* @default []
*/
global?: string[];
}
/**
* Resolver for VEUI
*
* @link https://github.com/ecomfe/veui
*/
declare function VeuiResolver(options?: VeuiResolverOptions): ComponentResolver;
//#endregion
//#region src/core/resolvers/view-ui.d.ts
/**
* Resolver for View UI
* @requires @originjs/vite-plugin-commonjs
* @author @nabaonan
* @link https://www.iviewui.com/
* @description has known problems list below
* - select component render error PR: https://github.com/view-design/ViewUI/pull/944, choose can't display value,because click option trigger twice,at second time,select value turn into undefined.
* - scroll component has a template syntax called lang='html',it is require html-loader,but vite plugin not support yet,remove it can run. relate pr: https://github.com/view-design/ViewUI/pull/985
*/
declare function ViewUiResolver(): ComponentResolver;
//#endregion
//#region src/core/resolvers/vuetify.d.ts
/**
* Resolver for Vuetify
*
* @link https://github.com/vuetifyjs/vuetify
*/
declare function VuetifyResolver(): ComponentResolver;
/**
* Resolver for Vuetify 3 Beta
*
* @link https://github.com/vuetifyjs/vuetify
*/
declare function Vuetify3Resolver(): ComponentResolver;
//#endregion
//#region src/core/resolvers/vueuse.d.ts
/**
* Resolver for VueUse
*
* @link https://github.com/vueuse/vueuse
*/
declare function VueUseComponentsResolver(): ComponentResolver;
//#endregion
//#region src/core/resolvers/vueuse-directive.d.ts
/**
* Resolver for VueUse
*
* @link https://github.com/vueuse/vueuse
*/
declare function VueUseDirectiveResolver(): ComponentResolver;
//#endregion
export { AllowResolveIconOption, AntDesignVueResolver, AntDesignVueResolverOptions, ArcoResolver, ArcoResolverOptions, BootstrapVue3Resolver, BootstrapVueNextResolver, BootstrapVueResolver, BootstrapVueResolverOptions, DevResolverOptions, DevUiResolver, DisallowResolveIconOption, ElementPlusResolver, ElementPlusResolverOptions, ElementUiResolver, ElementUiResolverOptions, HeadlessUiResolver, HeadlessUiResolverOptions, IduxResolver, IduxResolverOptions, InklineResolver, IonicBuiltInComponents, IonicResolver, LayuiVueResolver, LayuiVueResolverOptions, NaiveUiResolver, PrimeVueResolver, PrimeVueResolverOptions, QuasarResolver, ResolveIconsOption, TDesignResolver, TDesignResolverOptions, VantResolver, VantResolverOptions, VarletUIResolver, VarletUIResolverOptions, VeuiResolver, VeuiResolverOptions, ViewUiResolver, VueUseComponentsResolver, VueUseDirectiveResolver, Vuetify3Resolver, VuetifyResolver, getResolved };

View File

@@ -0,0 +1,574 @@
import { ComponentResolveResult, ComponentResolver } from "./types-rC3290ja.js";
import { FilterPattern } from "unplugin-utils";
//#region src/core/resolvers/antdv.d.ts
interface AntDesignVueResolverOptions {
/**
* exclude components that do not require automatic import
*
* @default []
*/
exclude?: string[];
/**
* import style along with components
*
* @default 'css'
*/
importStyle?: boolean | 'css' | 'less' | 'css-in-js';
/**
* resolve `ant-design-vue' icons
*
* requires package `@ant-design/icons-vue`
*
* @default false
*/
resolveIcons?: boolean;
/**
* @deprecated use `importStyle: 'css'` instead
*/
importCss?: boolean;
/**
* @deprecated use `importStyle: 'less'` instead
*/
importLess?: boolean;
/**
* use commonjs build default false
*/
cjs?: boolean;
/**
* rename package
*
* @default 'ant-design-vue'
*/
packageName?: string;
/**
* customize prefix of component
* @default 'A'
*/
prefix?: string;
}
/**
* Resolver for Ant Design Vue
*
* Requires ant-design-vue@v2.2.0-beta.6 or later
*
* See https://github.com/antfu/unplugin-vue-components/issues/26#issuecomment-789767941 for more details
*
* @author @yangss3
* @link https://antdv.com/
*/
declare function AntDesignVueResolver(options?: AntDesignVueResolverOptions): ComponentResolver;
//#endregion
//#region src/core/resolvers/arco.d.ts
type DisallowResolveIconOption = undefined | false | {
enable: false;
};
type AllowResolveIconOption = true | {
enable: true;
iconPrefix?: string;
};
type ResolveIconsOption = DisallowResolveIconOption | AllowResolveIconOption;
interface ArcoResolverOptions {
/**
* exclude components that do not require automatic import
*
* @default []
*/
exclude?: string | RegExp | (string | RegExp)[];
/**
* import style css or less with components
*
* @default 'css'
*/
importStyle?: boolean | 'css' | 'less';
/**
* resolve icons
*
* @default false
*/
resolveIcons?: ResolveIconsOption;
/**
* Control style automatic import
*
* @default true
*/
sideEffect?: boolean;
}
/**
* Resolver for Arco Design Vue
*
* Requires arco-design/web-vue@2.11.0 or later
*
* @author @flsion
* @link https://arco.design/ for arco-design
*
*/
declare function ArcoResolver(options?: ArcoResolverOptions): ComponentResolver;
//#endregion
//#region src/core/resolvers/bootstrap-vue.d.ts
interface BootstrapVueResolverOptions {
/**
* Auto import for directives.
*
* @default true
*/
directives?: boolean;
}
/**
* Resolver for BootstrapVue
*
* @link https://github.com/bootstrap-vue/bootstrap-vue
*/
declare function BootstrapVueResolver(_options?: BootstrapVueResolverOptions): ComponentResolver[];
/**
* Resolver for BootstrapVueNext
*
* @link https://github.com/bootstrap-vue/bootstrap-vue-next
*
* @deprecated use `import { BootstrapVueNextResolver } from 'bootstrap-vue-next'` instead
*/
declare function BootstrapVueNextResolver(_options?: BootstrapVueResolverOptions): Array<ComponentResolver>;
/**
* Resolver for legacy BootstrapVue3 apps
*
* @deprecated use BootstrapVueNextResolver with https://github.com/bootstrap-vue/bootstrap-vue-next
* @link https://www.npmjs.com/package/bootstrap-vue-3
*/
declare function BootstrapVue3Resolver(_options?: BootstrapVueResolverOptions): Array<ComponentResolver>;
//#endregion
//#region src/core/resolvers/devui.d.ts
interface DevResolverOptions {
/**
* bring in components and styles
*
* @default true
*/
importStyle?: boolean;
/**
* auto import for directives
*
* @default true
*/
directives?: boolean;
/**
* use umd lib file
*/
ssr?: boolean;
}
declare function DevUiResolver(options?: DevResolverOptions): ComponentResolver[];
//#endregion
//#region src/core/resolvers/element-plus.d.ts
interface ElementPlusResolverOptions {
/**
* import style css or sass with components
*
* @default 'css'
*/
importStyle?: boolean | 'css' | 'sass';
/**
* use commonjs lib & source css or scss for ssr
*/
ssr?: boolean;
/**
* specify element-plus version to load style
*
* @default installed version
*/
version?: string;
/**
* auto import for directives
*
* @default true
*/
directives?: boolean;
/**
* exclude component name, if match do not resolve the name
*/
exclude?: RegExp;
/**
* a list of component names that have no styles, so resolving their styles file should be prevented
*/
noStylesComponents?: string[];
/**
* nightly version
*/
nightly?: boolean;
}
/**
* Resolver for Element Plus
*
* See https://github.com/antfu/vite-plugin-components/pull/28 for more details
* See https://github.com/antfu/vite-plugin-components/issues/117 for more details
*
* @author @develar @nabaonan @sxzz
* @link https://element-plus.org/ for element-plus
*
*/
declare function ElementPlusResolver(options?: ElementPlusResolverOptions): ComponentResolver[];
//#endregion
//#region src/core/resolvers/element-ui.d.ts
interface ElementUiResolverOptions {
/**
* import style css or sass with components
*
* @default 'css'
*/
importStyle?: boolean | 'css' | 'sass';
/**
* exclude component name, if match do not resolve the name
*/
exclude?: RegExp;
}
/**
* Resolver for Element-UI
* @link https://element.eleme.cn/#/zh-CN
* @version @element-ui ^2.15.3, @vue ^2.6.14
* @author @nabaonan
*/
declare function ElementUiResolver(options?: ElementUiResolverOptions): ComponentResolver;
//#endregion
//#region src/core/resolvers/headless-ui.d.ts
interface HeadlessUiResolverOptions {
/**
* prefix for headless ui components used in templates
*
* @default ""
*/
prefix?: string;
}
/**
* Resolver for headlessui
*
* @link https://github.com/tailwindlabs/headlessui
*/
declare function HeadlessUiResolver(options?: HeadlessUiResolverOptions): ComponentResolver;
//#endregion
//#region src/core/resolvers/idux.d.ts
interface IduxResolverOptions {
/**
* exclude components that do not require automatic import
*
* @default []
*/
exclude?: string[];
/**
* import style along with components
*/
importStyle?: 'css' | 'less';
/**
* theme for import style
*
* @default 'default' for 1.x version
*/
importStyleTheme?: string;
/**
* The scope of the packages.
*
* @default '@idux'
*/
scope?: string;
/**
* specify idux version to load style
*
* @default installed version
*/
version?: string;
}
/**
* Resolver for `@idux/cdk`, `@idux/components` and ``@idux/pro``
*
* @link https://idux.site
*/
declare function IduxResolver(options?: IduxResolverOptions): ComponentResolver;
//#endregion
//#region src/core/resolvers/inkline.d.ts
/**
* Resolver for Inkline
*
* @author @alexgrozav
* @link https://github.com/inkline/inkline
*/
declare function InklineResolver(): ComponentResolver;
//#endregion
//#region src/core/resolvers/ionic.d.ts
/**
* source: https://github.com/nuxt-modules/ionic/blob/main/src/imports.ts
* @author @danielroe
*/
declare const IonicBuiltInComponents: string[];
/**
* Resolver for ionic framework
*
* @author @mathsgod @reslear
* @link https://ionicframework.com/
*/
declare function IonicResolver(): ComponentResolver;
//#endregion
//#region src/core/resolvers/layui-vue.d.ts
interface LayuiVueResolverOptions {
/**
* import style along with components
*
* @default 'css'
*/
importStyle?: boolean | 'css';
/**
* resolve '@layui/layui-vue' icons
* requires package `@layui/icons-vue`
*
* @default false
*/
resolveIcons?: boolean;
/**
* exclude components that do not require automatic import
*
*/
exclude?: FilterPattern;
}
/**
* Resolver for layui-vue
*
* @link http://www.layui-vue.com/ for layui-vue
*
*/
declare function LayuiVueResolver(options?: LayuiVueResolverOptions): ComponentResolver;
//#endregion
//#region src/core/resolvers/naive-ui.d.ts
/**
* Resolver for Naive UI
*
* @author @antfu
* @link https://www.naiveui.com/
*/
declare function NaiveUiResolver(): ComponentResolver;
//#endregion
//#region src/core/resolvers/prime-vue.d.ts
interface PrimeVueResolverOptions {
/**
* import style along with components
*
* @default true
*/
importStyle?: boolean;
/**
* import `primeicons' icons
*
* requires package `primeicons`
*
* @default true
*/
importIcons?: boolean;
/**
* imports a free theme - set theme name here (e.g. saga-blue)
*
* @default ''
*/
importTheme?: string;
/**
* prefix for components (e.g. 'P' to resolve Menu from PMenu)
*
* @default ''
*/
prefix?: string;
}
/**
* Resolver for PrimeVue - If you're using a component with the same tag as an native HTML element (e.g. button) the component must be in uppercase
*
* @link https://github.com/primefaces/primevue
*/
declare function PrimeVueResolver(options?: PrimeVueResolverOptions): ComponentResolver;
//#endregion
//#region src/core/resolvers/quasar.d.ts
/**
* Resolver for Quasar
*
* @link https://github.com/quasarframework/quasar
*/
declare function QuasarResolver(): ComponentResolver;
//#endregion
//#region src/core/resolvers/tdesign.d.ts
interface TDesignResolverOptions {
/**
* select the specified library
* @default 'vue'
*/
library?: 'vue' | 'vue-next' | 'react' | 'mobile-vue' | 'mobile-react';
/**
* resolve `tdesign-icons'
* @default false
*/
resolveIcons?: boolean;
/**
* whether to import ESM version
* @default false
*/
esm?: boolean;
/**
* exclude component name, if match do not resolve the name
*
*/
exclude?: FilterPattern;
}
declare function TDesignResolver(options?: TDesignResolverOptions): ComponentResolver;
//#endregion
//#region src/core/resolvers/vant.d.ts
interface VantResolverOptions {
/**
* import style css or less along with components
*
* @default true
*/
importStyle?: boolean | 'css' | 'less';
}
/**
* Resolver for Vant
*
* @link https://github.com/youzan/vant
*/
declare function VantResolver(options?: VantResolverOptions): ComponentResolver;
//#endregion
//#region src/core/resolvers/varlet-ui.d.ts
interface VarletUIResolverOptions {
/**
* support vue version
* vue3 use @varlet/ui, vue2 use @varlet-vue2/ui
*
* @default 'vue3'
*/
version?: 'vue3' | 'vue2';
/**
* import style along with components
*
* @default 'css'
*/
importStyle?: boolean | 'css' | 'less';
/**
* style entry file extname
*
* @default '.mjs'
*/
styleExtname?: string;
/**
* auto import for directives
*
* @default true
*/
directives?: boolean;
/**
* compatible with unplugin-auto-import
*
* @default false
*/
autoImport?: boolean;
/**
* @deprecated use `importStyle: 'css'` instead
*/
importCss?: boolean;
/**
* @deprecated use `importStyle: 'less'` instead
*/
importLess?: boolean;
}
declare function getResolved(name: string, options: VarletUIResolverOptions): ComponentResolveResult;
/**
* Resolver for VarletUI
*
* @link https://github.com/varletjs/varlet
* @link https://github.com/varletjs/varlet-vue2
*/
declare function VarletUIResolver(options?: VarletUIResolverOptions): ComponentResolver[];
//#endregion
//#region src/core/resolvers/veui.d.ts
interface VeuiPeerConfig {
/**
* The package name of the peer module.
*/
package: string;
/**
* The directory path of the peer module.
* @default 'components'
*/
path?: string;
/**
* The file name template for the peer module.
* @default '{module}.css'
*/
fileName?: `${string}{module}${string}`;
/**
* The text transform to be applied to the '{module}' part of the file name.
* @default 'kebab-case'
*/
transform?: 'kebab-case' | 'camelCase' | 'PascalCase' | false;
}
type SupportedLocale = 'en-US' | 'zh-Hans';
interface VeuiResolverOptions {
/**
* The alias of 'veui` package.
* @default 'veui'
*/
alias?: string;
/**
* Peer modules to be injected.
*/
modules?: VeuiPeerConfig[];
/**
* Locale modules to be injected.
* @default 'zh-Hans'
*/
locale?: SupportedLocale | SupportedLocale[] | false;
/**
* Global modules to be injected to all components.
* @default []
*/
global?: string[];
}
/**
* Resolver for VEUI
*
* @link https://github.com/ecomfe/veui
*/
declare function VeuiResolver(options?: VeuiResolverOptions): ComponentResolver;
//#endregion
//#region src/core/resolvers/view-ui.d.ts
/**
* Resolver for View UI
* @requires @originjs/vite-plugin-commonjs
* @author @nabaonan
* @link https://www.iviewui.com/
* @description has known problems list below
* - select component render error PR: https://github.com/view-design/ViewUI/pull/944, choose can't display value,because click option trigger twice,at second time,select value turn into undefined.
* - scroll component has a template syntax called lang='html',it is require html-loader,but vite plugin not support yet,remove it can run. relate pr: https://github.com/view-design/ViewUI/pull/985
*/
declare function ViewUiResolver(): ComponentResolver;
//#endregion
//#region src/core/resolvers/vuetify.d.ts
/**
* Resolver for Vuetify
*
* @link https://github.com/vuetifyjs/vuetify
*/
declare function VuetifyResolver(): ComponentResolver;
/**
* Resolver for Vuetify 3 Beta
*
* @link https://github.com/vuetifyjs/vuetify
*/
declare function Vuetify3Resolver(): ComponentResolver;
//#endregion
//#region src/core/resolvers/vueuse.d.ts
/**
* Resolver for VueUse
*
* @link https://github.com/vueuse/vueuse
*/
declare function VueUseComponentsResolver(): ComponentResolver;
//#endregion
//#region src/core/resolvers/vueuse-directive.d.ts
/**
* Resolver for VueUse
*
* @link https://github.com/vueuse/vueuse
*/
declare function VueUseDirectiveResolver(): ComponentResolver;
//#endregion
export { AllowResolveIconOption, AntDesignVueResolver, AntDesignVueResolverOptions, ArcoResolver, ArcoResolverOptions, BootstrapVue3Resolver, BootstrapVueNextResolver, BootstrapVueResolver, BootstrapVueResolverOptions, DevResolverOptions, DevUiResolver, DisallowResolveIconOption, ElementPlusResolver, ElementPlusResolverOptions, ElementUiResolver, ElementUiResolverOptions, HeadlessUiResolver, HeadlessUiResolverOptions, IduxResolver, IduxResolverOptions, InklineResolver, IonicBuiltInComponents, IonicResolver, LayuiVueResolver, LayuiVueResolverOptions, NaiveUiResolver, PrimeVueResolver, PrimeVueResolverOptions, QuasarResolver, ResolveIconsOption, TDesignResolver, TDesignResolverOptions, VantResolver, VantResolverOptions, VarletUIResolver, VarletUIResolverOptions, VeuiResolver, VeuiResolverOptions, ViewUiResolver, VueUseComponentsResolver, VueUseDirectiveResolver, Vuetify3Resolver, VuetifyResolver, getResolved };

2070
node_modules/unplugin-vue-components/dist/resolvers.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,9 @@
require('./utils-8UQ22cuO.cjs');
const require_src = require('./src-DzdkjKhH.cjs');
require('./types-CBTc19th.cjs');
//#region src/rolldown.ts
var rolldown_default = require_src.unplugin_default.rolldown;
//#endregion
module.exports = rolldown_default;

View File

@@ -0,0 +1,6 @@
import { Options } from "./types-DSJ5r-ta.cjs";
import * as rolldown0 from "rolldown";
//#region src/rolldown.d.ts
declare const _default: (options: Options) => rolldown0.Plugin<any> | rolldown0.Plugin<any>[];
export = _default;

View File

@@ -0,0 +1,7 @@
import { Options } from "./types-rC3290ja.js";
import * as rolldown0 from "rolldown";
//#region src/rolldown.d.ts
declare const _default: (options: Options) => rolldown0.Plugin<any> | rolldown0.Plugin<any>[];
//#endregion
export { _default as default };

View File

@@ -0,0 +1,9 @@
import "./utils-BoXu-4gQ.js";
import { unplugin_default } from "./src-BcnnO6GN.js";
import "./types-DQoXDiso.js";
//#region src/rolldown.ts
var rolldown_default = unplugin_default.rolldown;
//#endregion
export { rolldown_default as default };

9
node_modules/unplugin-vue-components/dist/rollup.cjs generated vendored Normal file
View File

@@ -0,0 +1,9 @@
require('./utils-8UQ22cuO.cjs');
const require_src = require('./src-DzdkjKhH.cjs');
require('./types-CBTc19th.cjs');
//#region src/rollup.ts
var rollup_default = require_src.unplugin_default.rollup;
//#endregion
module.exports = rollup_default;

View File

@@ -0,0 +1,6 @@
import { Options } from "./types-DSJ5r-ta.cjs";
import * as rollup0 from "rollup";
//#region src/rollup.d.ts
declare const _default: (options: Options) => rollup0.Plugin<any> | rollup0.Plugin<any>[];
export = _default;

View File

@@ -0,0 +1,7 @@
import { Options } from "./types-rC3290ja.js";
import * as rollup0 from "rollup";
//#region src/rollup.d.ts
declare const _default: (options: Options) => rollup0.Plugin<any> | rollup0.Plugin<any>[];
//#endregion
export { _default as default };

9
node_modules/unplugin-vue-components/dist/rollup.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import "./utils-BoXu-4gQ.js";
import { unplugin_default } from "./src-BcnnO6GN.js";
import "./types-DQoXDiso.js";
//#region src/rollup.ts
var rollup_default = unplugin_default.rollup;
//#endregion
export { rollup_default as default };

9
node_modules/unplugin-vue-components/dist/rspack.cjs generated vendored Normal file
View File

@@ -0,0 +1,9 @@
require('./utils-8UQ22cuO.cjs');
const require_src = require('./src-DzdkjKhH.cjs');
require('./types-CBTc19th.cjs');
//#region src/rspack.ts
var rspack_default = require_src.unplugin_default.rspack;
//#endregion
module.exports = rspack_default;

View File

@@ -0,0 +1,5 @@
import { Options } from "./types-DSJ5r-ta.cjs";
//#region src/rspack.d.ts
declare const _default: (options: Options) => RspackPluginInstance;
export = _default;

View File

@@ -0,0 +1,6 @@
import { Options } from "./types-rC3290ja.js";
//#region src/rspack.d.ts
declare const _default: (options: Options) => RspackPluginInstance;
//#endregion
export { _default as default };

9
node_modules/unplugin-vue-components/dist/rspack.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import "./utils-BoXu-4gQ.js";
import { unplugin_default } from "./src-BcnnO6GN.js";
import "./types-DQoXDiso.js";
//#region src/rspack.ts
var rspack_default = unplugin_default.rspack;
//#endregion
export { rspack_default as default };

View File

@@ -0,0 +1,188 @@
//#region node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/walker.js
/**
* @typedef { import('estree').Node} Node
* @typedef {{
* skip: () => void;
* remove: () => void;
* replace: (node: Node) => void;
* }} WalkerContext
*/
var WalkerBase = class {
constructor() {
/** @type {boolean} */
this.should_skip = false;
/** @type {boolean} */
this.should_remove = false;
/** @type {Node | null} */
this.replacement = null;
/** @type {WalkerContext} */
this.context = {
skip: () => this.should_skip = true,
remove: () => this.should_remove = true,
replace: (node) => this.replacement = node
};
}
/**
* @template {Node} Parent
* @param {Parent | null | undefined} parent
* @param {keyof Parent | null | undefined} prop
* @param {number | null | undefined} index
* @param {Node} node
*/
replace(parent, prop, index, node) {
if (parent && prop) if (index != null)
/** @type {Array<Node>} */ parent[prop][index] = node;
else
/** @type {Node} */ parent[prop] = node;
}
/**
* @template {Node} Parent
* @param {Parent | null | undefined} parent
* @param {keyof Parent | null | undefined} prop
* @param {number | null | undefined} index
*/
remove(parent, prop, index) {
if (parent && prop) if (index !== null && index !== void 0)
/** @type {Array<Node>} */ parent[prop].splice(index, 1);
else delete parent[prop];
}
};
//#endregion
//#region node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/sync.js
/**
* @typedef { import('estree').Node} Node
* @typedef { import('./walker.js').WalkerContext} WalkerContext
* @typedef {(
* this: WalkerContext,
* node: Node,
* parent: Node | null,
* key: string | number | symbol | null | undefined,
* index: number | null | undefined
* ) => void} SyncHandler
*/
var SyncWalker = class extends WalkerBase {
/**
*
* @param {SyncHandler} [enter]
* @param {SyncHandler} [leave]
*/
constructor(enter, leave) {
super();
/** @type {boolean} */
this.should_skip = false;
/** @type {boolean} */
this.should_remove = false;
/** @type {Node | null} */
this.replacement = null;
/** @type {WalkerContext} */
this.context = {
skip: () => this.should_skip = true,
remove: () => this.should_remove = true,
replace: (node) => this.replacement = node
};
/** @type {SyncHandler | undefined} */
this.enter = enter;
/** @type {SyncHandler | undefined} */
this.leave = leave;
}
/**
* @template {Node} Parent
* @param {Node} node
* @param {Parent | null} parent
* @param {keyof Parent} [prop]
* @param {number | null} [index]
* @returns {Node | null}
*/
visit(node, parent, prop, index) {
if (node) {
if (this.enter) {
const _should_skip = this.should_skip;
const _should_remove = this.should_remove;
const _replacement = this.replacement;
this.should_skip = false;
this.should_remove = false;
this.replacement = null;
this.enter.call(this.context, node, parent, prop, index);
if (this.replacement) {
node = this.replacement;
this.replace(parent, prop, index, node);
}
if (this.should_remove) this.remove(parent, prop, index);
const skipped = this.should_skip;
const removed = this.should_remove;
this.should_skip = _should_skip;
this.should_remove = _should_remove;
this.replacement = _replacement;
if (skipped) return node;
if (removed) return null;
}
/** @type {keyof Node} */
let key;
for (key in node) {
/** @type {unknown} */
const value = node[key];
if (value && typeof value === "object") {
if (Array.isArray(value)) {
const nodes = value;
for (let i = 0; i < nodes.length; i += 1) {
const item = nodes[i];
if (isNode(item)) {
if (!this.visit(item, node, key, i)) i--;
}
}
} else if (isNode(value)) this.visit(value, node, key, null);
}
}
if (this.leave) {
const _replacement = this.replacement;
const _should_remove = this.should_remove;
this.replacement = null;
this.should_remove = false;
this.leave.call(this.context, node, parent, prop, index);
if (this.replacement) {
node = this.replacement;
this.replace(parent, prop, index, node);
}
if (this.should_remove) this.remove(parent, prop, index);
const removed = this.should_remove;
this.replacement = _replacement;
this.should_remove = _should_remove;
if (removed) return null;
}
}
return node;
}
};
/**
* Ducktype a node.
*
* @param {unknown} value
* @returns {value is Node}
*/
function isNode(value) {
return value !== null && typeof value === "object" && "type" in value && typeof value.type === "string";
}
//#endregion
//#region node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/index.js
/**
* @typedef {import('estree').Node} Node
* @typedef {import('./sync.js').SyncHandler} SyncHandler
* @typedef {import('./async.js').AsyncHandler} AsyncHandler
*/
/**
* @param {Node} ast
* @param {{
* enter?: SyncHandler
* leave?: SyncHandler
* }} walker
* @returns {Node | null}
*/
function walk(ast, { enter, leave }) {
return new SyncWalker(enter, leave).visit(ast, null);
}
//#endregion
exports.walk = walk;

View File

@@ -0,0 +1,753 @@
import { DIRECTIVE_IMPORT_PREFIX, DISABLE_COMMENT, escapeSpecialChars, getNameFromFilePath, getTransformedPath, isExclude, matchGlobs, normalizeComponentInfo, notNullish, parseId, pascalCase, resolveAlias, shouldTransform, slash, stringifyComponentImport, throttle, toArray } from "./utils-BoXu-4gQ.js";
import { existsSync } from "node:fs";
import process from "node:process";
import chokidar from "chokidar";
import { glob, globSync } from "tinyglobby";
import { createUnplugin } from "unplugin";
import { createFilter } from "unplugin-utils";
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
import Debug from "debug";
import { mkdir, readFile, writeFile } from "node:fs/promises";
import { getPackageInfoSync, importModule, isPackageExists } from "local-pkg";
import MagicString from "magic-string";
//#region src/core/type-imports/index.ts
const TypeImportPresets = [{
from: "vue-router",
names: ["RouterView", "RouterLink"]
}, {
from: "vue-starport",
names: ["Starport", "StarportCarrier"]
}];
//#endregion
//#region src/core/type-imports/detect.ts
function detectTypeImports() {
return TypeImportPresets.map((i) => isPackageExists(i.from) ? i : void 0).filter(notNullish);
}
function resolveTypeImports(imports) {
return imports.flatMap((i) => i.names.map((n) => ({
from: i.from,
name: n,
as: n
})));
}
//#endregion
//#region src/core/declaration.ts
const multilineCommentsRE = /\/\*.*?\*\//gs;
const singlelineCommentsRE = /\/\/.*$/gm;
function extractImports(code) {
return Object.fromEntries(Array.from(code.matchAll(/['"]?([^\s'"]+)['"]?\s*:\s*(.+?)[,;\r\n]/g)).map((i) => [i[1], i[2]]));
}
function parseDeclaration(code) {
var _exec, _exec2;
if (!code) return;
code = code.replace(multilineCommentsRE, "").replace(singlelineCommentsRE, "");
const imports = {
component: {},
directive: {}
};
const componentDeclaration = (_exec = /export\s+interface\s+GlobalComponents\s*\{.*?\}/s.exec(code)) === null || _exec === void 0 ? void 0 : _exec[0];
if (componentDeclaration) imports.component = extractImports(componentDeclaration);
const directiveDeclaration = (_exec2 = /export\s+interface\s+GlobalDirectives\s*\{.*?\}/s.exec(code)) === null || _exec2 === void 0 ? void 0 : _exec2[0];
if (directiveDeclaration) imports.directive = extractImports(directiveDeclaration);
return imports;
}
/**
* Converts `ComponentInfo` to an array
*
* `[name, "typeof import(path)[importName]"]`
*/
function stringifyComponentInfo(filepath, { from: path, as: name, name: importName }, importPathTransform) {
if (!name) return void 0;
path = getTransformedPath(path, importPathTransform);
return [name, `typeof import('${slash(isAbsolute(path) ? `./${relative(dirname(filepath), path)}` : path)}')['${importName || "default"}']`];
}
/**
* Converts array of `ComponentInfo` to an import map
*
* `{ name: "typeof import(path)[importName]", ... }`
*/
function stringifyComponentsInfo(filepath, components, importPathTransform) {
return Object.fromEntries(components.map((info) => stringifyComponentInfo(filepath, info, importPathTransform)).filter(notNullish));
}
function getDeclarationImports(ctx, filepath) {
const component = stringifyComponentsInfo(filepath, [...Object.values({
...ctx.componentNameMap,
...ctx.componentCustomMap
}), ...resolveTypeImports(ctx.options.types)], ctx.options.importPathTransform);
const directive = stringifyComponentsInfo(filepath, Object.values(ctx.directiveCustomMap), ctx.options.importPathTransform);
if (Object.keys(component).length + Object.keys(directive).length === 0) return;
return {
component,
directive
};
}
function stringifyDeclarationImports(imports) {
return Object.entries(imports).sort(([a], [b]) => a.localeCompare(b)).map(([name, v]) => {
if (!/^\w+$/.test(name)) name = `'${name}'`;
return `${name}: ${v}`;
});
}
function getDeclaration(ctx, filepath, originalImports) {
const imports = getDeclarationImports(ctx, filepath);
if (!imports) return;
const declarations = {
component: stringifyDeclarationImports({
...originalImports === null || originalImports === void 0 ? void 0 : originalImports.component,
...imports.component
}),
directive: stringifyDeclarationImports({
...originalImports === null || originalImports === void 0 ? void 0 : originalImports.directive,
...imports.directive
})
};
let code = `/* eslint-disable */
// @ts-nocheck
// biome-ignore lint: disable
// oxlint-disable
// ------
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
${ctx.options.dtsTsx ? `import { GlobalComponents } from 'vue'\n` : ""}
export {}
/* prettier-ignore */
declare module 'vue' {`;
if (Object.keys(declarations.component).length > 0) code += `
export interface GlobalComponents {
${declarations.component.join("\n ")}
}`;
if (Object.keys(declarations.directive).length > 0) code += `
export interface GlobalDirectives {
${declarations.directive.join("\n ")}
}`;
code += "\n}\n";
if (ctx.options.dtsTsx) {
if (Object.keys(declarations.component).length > 0) code += `
// For TSX support
declare global {
${declarations.component.map((d) => d.replace(/(.+):/, "const $1:")).join("\n ")}
}`;
}
return code;
}
async function writeFile$1(filePath, content) {
await mkdir(dirname(filePath), { recursive: true });
return await writeFile(filePath, content, "utf-8");
}
async function writeDeclaration(ctx, filepath, removeUnused = false) {
const originalContent = existsSync(filepath) ? await readFile(filepath, "utf-8") : "";
const code = getDeclaration(ctx, filepath, removeUnused ? void 0 : parseDeclaration(originalContent));
if (!code) return;
if (code !== originalContent) await writeFile$1(filepath, code);
}
async function writeComponentsJson(ctx, _removeUnused = false) {
if (!ctx.dumpComponentsInfoPath) return;
const components = [...Object.entries({
...ctx.componentNameMap,
...ctx.componentCustomMap
}).map(([_, { name, as, from }]) => ({
name: name || "default",
as,
from
})), ...resolveTypeImports(ctx.options.types)];
await writeFile$1(ctx.dumpComponentsInfoPath, JSON.stringify(components, null, 2));
}
//#endregion
//#region src/core/fs/glob.ts
const debug$4 = Debug("unplugin-vue-components:glob");
function searchComponents(ctx) {
var _ctx$options$resolver;
debug$4(`started with: [${ctx.options.globs.join(", ")}]`);
const root = ctx.root;
const files = globSync(ctx.options.globs, {
ignore: ctx.options.globsExclude,
onlyFiles: true,
cwd: root,
absolute: true,
expandDirectories: false
});
if (!files.length && !((_ctx$options$resolver = ctx.options.resolvers) === null || _ctx$options$resolver === void 0 ? void 0 : _ctx$options$resolver.length)) console.warn("[unplugin-vue-components] no components found");
debug$4(`${files.length} components found.`);
ctx.addComponents(files);
}
//#endregion
//#region src/core/options.ts
const defaultOptions = {
dirs: "src/components",
extensions: "vue",
deep: true,
dts: isPackageExists("typescript"),
dtsTsx: isPackageExists("@vitejs/plugin-vue-jsx"),
directoryAsNamespace: false,
collapseSamePrefixes: false,
globalNamespaces: [],
transformerUserResolveFunctions: true,
resolvers: [],
importPathTransform: (v) => v,
allowOverrides: false,
sourcemap: true,
dumpComponentsInfo: false,
syncMode: "default",
prefix: ""
};
function normalizeResolvers(resolvers) {
return toArray(resolvers).flat().map((r) => typeof r === "function" ? {
resolve: r,
type: "component"
} : r);
}
function resolveGlobsExclude(root, glob$1) {
const excludeReg = /^!/;
return slash(`${excludeReg.test(glob$1) ? "!" : ""}${resolve(root, glob$1.replace(excludeReg, ""))}`);
}
function resolveOptions(options, root) {
const resolved = Object.assign({}, defaultOptions, options);
resolved.resolvers = normalizeResolvers(resolved.resolvers);
resolved.extensions = toArray(resolved.extensions);
if (resolved.globs) {
resolved.globs = toArray(resolved.globs).map((glob$1) => resolveGlobsExclude(root, glob$1));
resolved.resolvedDirs = [];
} else {
const extsGlob = resolved.extensions.length === 1 ? resolved.extensions : `{${resolved.extensions.join(",")}}`;
resolved.dirs = toArray(resolved.dirs);
const globs = resolved.dirs.map((i) => resolveGlobsExclude(root, i));
resolved.resolvedDirs = globs.filter((i) => !i.startsWith("!"));
resolved.globs = globs.map((i) => {
let prefix = "";
if (i.startsWith("!")) {
prefix = "!";
i = i.slice(1);
}
return resolved.deep ? prefix + escapeSpecialChars(slash(join(i, `**/*.${extsGlob}`))) : prefix + escapeSpecialChars(slash(join(i, `*.${extsGlob}`)));
});
if (!resolved.extensions.length) throw new Error("[unplugin-vue-components] `extensions` option is required to search for components");
}
resolved.globsExclude = toArray(resolved.globsExclude || []).map((i) => resolveGlobsExclude(root, i));
resolved.globs = resolved.globs.filter((i) => {
if (!i.startsWith("!")) return true;
resolved.globsExclude.push(i.slice(1));
return false;
});
resolved.dts = !resolved.dts ? false : resolve(root, typeof resolved.dts === "string" ? resolved.dts : "components.d.ts");
if (!resolved.types && resolved.dts) resolved.types = detectTypeImports();
resolved.types = resolved.types || [];
resolved.root = root;
resolved.version = resolved.version ?? getVueVersion(root);
if (resolved.version < 2 || resolved.version >= 4) throw new Error(`[unplugin-vue-components] unsupported version: ${resolved.version}`);
resolved.transformer = options.transformer || `vue${Math.trunc(resolved.version)}`;
resolved.directives = typeof options.directives === "boolean" ? options.directives : !resolved.resolvers.some((i) => i.type === "directive") ? false : resolved.version >= 3;
return resolved;
}
function getVueVersion(root) {
var _getPackageInfoSync;
const version = +(((_getPackageInfoSync = getPackageInfoSync("vue", { paths: [join(root, "/")] })) === null || _getPackageInfoSync === void 0 ? void 0 : _getPackageInfoSync.version) || "3").split(".").slice(0, 2).join(".");
if (version === 2.7) return 2.7;
else if (version < 2.7) return 2;
return 3;
}
//#endregion
//#region src/core/transforms/component.ts
const debug$3 = Debug("unplugin-vue-components:transform:component");
function resolveVue2$1(code, s) {
const results = [];
for (const match of code.matchAll(/\b(_c|h)\(\s*['"](.+?)["']([,)])/g)) {
const [full, renderFunctionName, matchedName, append] = match;
if (match.index != null && matchedName && !matchedName.startsWith("_")) {
const start = match.index;
const end = start + full.length;
results.push({
rawName: matchedName,
replace: (resolved) => s.overwrite(start, end, `${renderFunctionName}(${resolved}${append}`)
});
}
}
return results;
}
function resolveVue3$1(code, s, transformerUserResolveFunctions) {
const results = [];
/**
* when using some plugin like plugin-vue-jsx, resolveComponent will be imported as resolveComponent1 to avoid duplicate import
*/
for (const match of code.matchAll(/_?resolveComponent\d*\("(.+?)"\)/g)) {
if (!transformerUserResolveFunctions && !match[0].startsWith("_")) continue;
const matchedName = match[1];
if (match.index != null && matchedName && !matchedName.startsWith("_")) {
const start = match.index;
const end = start + match[0].length;
results.push({
rawName: matchedName,
replace: (resolved) => s.overwrite(start, end, resolved)
});
}
}
return results;
}
async function transformComponent(code, transformer$1, s, ctx, sfcPath) {
let no = 0;
const results = transformer$1 === "vue2" ? resolveVue2$1(code, s) : resolveVue3$1(code, s, ctx.options.transformerUserResolveFunctions);
for (const { rawName, replace } of results) {
debug$3(`| ${rawName}`);
const name = pascalCase(rawName);
ctx.updateUsageMap(sfcPath, [name]);
const component = await ctx.findComponent(name, "component", [sfcPath]);
if (component) {
const varName = `__unplugin_components_${no}`;
s.prepend(`${stringifyComponentImport({
...component,
as: varName
}, ctx)};\n`);
no += 1;
replace(varName);
}
}
debug$3(`^ (${no})`);
}
//#endregion
//#region src/core/transforms/directive/vue2.ts
/**
* Get Vue 2 render function position
*/
function getRenderFnStart(program) {
var _ref;
const renderFn = program.body.find((node) => node.type === "VariableDeclaration" && node.declarations[0].id.type === "Identifier" && ["render", "_sfc_render"].includes(node.declarations[0].id.name));
const start = renderFn === null || renderFn === void 0 || (_ref = renderFn.declarations[0].init) === null || _ref === void 0 || (_ref = _ref.body) === null || _ref === void 0 ? void 0 : _ref.start;
if (start === null || start === void 0) throw new Error("[unplugin-vue-components:directive] Cannot find render function position.");
return start + 1;
}
async function resolveVue2(code, s) {
if (!isPackageExists("@babel/parser")) throw new Error("[unplugin-vue-components:directive] To use Vue 2 directive you will need to install Babel first: \"npm install -D @babel/parser\"");
const { parse: parse$1 } = await importModule("@babel/parser");
const { program } = parse$1(code, { sourceType: "module" });
const nodes = [];
const { walk } = await import("./src-D2-JfLYq.js");
walk(program, { enter(node) {
if (node.type === "CallExpression") nodes.push(node);
} });
if (nodes.length === 0) return [];
let _renderStart;
const getRenderStart = () => {
if (_renderStart !== void 0) return _renderStart;
return _renderStart = getRenderFnStart(program);
};
const results = [];
for (const node of nodes) {
var _args$, _args$1$properties$fi;
const { callee, arguments: args } = node;
if (callee.type !== "Identifier" || callee.name !== "_c" || ((_args$ = args[1]) === null || _args$ === void 0 ? void 0 : _args$.type) !== "ObjectExpression") continue;
const directives = (_args$1$properties$fi = args[1].properties.find((property) => property.type === "ObjectProperty" && property.key.type === "Identifier" && property.key.name === "directives")) === null || _args$1$properties$fi === void 0 ? void 0 : _args$1$properties$fi.value;
if (!directives || directives.type !== "ArrayExpression") continue;
for (const directive of directives.elements) {
var _directive$properties;
if ((directive === null || directive === void 0 ? void 0 : directive.type) !== "ObjectExpression") continue;
const nameNode = (_directive$properties = directive.properties.find((p) => p.type === "ObjectProperty" && p.key.type === "Identifier" && p.key.name === "name")) === null || _directive$properties === void 0 ? void 0 : _directive$properties.value;
if ((nameNode === null || nameNode === void 0 ? void 0 : nameNode.type) !== "StringLiteral") continue;
const name = nameNode.value;
if (!name || name.startsWith("_")) continue;
results.push({
rawName: name,
replace: (resolved) => {
s.prependLeft(getRenderStart(), `\nthis.$options.directives["${name}"] = ${resolved};`);
}
});
}
}
return results;
}
//#endregion
//#region src/core/transforms/directive/vue3.ts
function resolveVue3(code, s, transformerUserResolveFunctions) {
const results = [];
for (const match of code.matchAll(/_?resolveDirective\("(.+?)"\)/g)) {
const matchedName = match[1];
if (!transformerUserResolveFunctions && !match[0].startsWith("_")) continue;
if (match.index != null && matchedName && !matchedName.startsWith("_")) {
const start = match.index;
const end = start + match[0].length;
results.push({
rawName: matchedName,
replace: (resolved) => s.overwrite(start, end, resolved)
});
}
}
return results;
}
//#endregion
//#region src/core/transforms/directive/index.ts
const debug$2 = Debug("unplugin-vue-components:transform:directive");
async function transformDirective(code, transformer$1, s, ctx, sfcPath) {
let no = 0;
const results = await (transformer$1 === "vue2" ? resolveVue2(code, s) : resolveVue3(code, s));
for (const { rawName, replace } of results) {
debug$2(`| ${rawName}`);
const name = `${DIRECTIVE_IMPORT_PREFIX}${pascalCase(rawName)}`;
ctx.updateUsageMap(sfcPath, [name]);
const directive = await ctx.findComponent(name, "directive", [sfcPath]);
if (!directive) continue;
const varName = `__unplugin_directives_${no}`;
s.prepend(`${stringifyComponentImport({
...directive,
as: varName
}, ctx)};\n`);
no += 1;
replace(varName);
}
debug$2(`^ (${no})`);
}
//#endregion
//#region src/core/transformer.ts
const debug$1 = Debug("unplugin-vue-components:transformer");
function transformer(ctx, transformer$1) {
return async (code, id, path) => {
ctx.searchGlob();
const sfcPath = ctx.normalizePath(path);
debug$1(sfcPath);
const s = new MagicString(code);
await transformComponent(code, transformer$1, s, ctx, sfcPath);
if (ctx.options.directives) await transformDirective(code, transformer$1, s, ctx, sfcPath);
s.prepend(DISABLE_COMMENT);
const result = { code: s.toString() };
if (ctx.sourcemap) result.map = s.generateMap({
source: id,
includeContent: true,
hires: "boundary"
});
return result;
};
}
//#endregion
//#region src/core/context.ts
const debug = {
components: Debug("unplugin-vue-components:context:components"),
search: Debug("unplugin-vue-components:context:search"),
hmr: Debug("unplugin-vue-components:context:hmr"),
declaration: Debug("unplugin-vue-components:declaration"),
env: Debug("unplugin-vue-components:env")
};
var Context = class {
options;
transformer = void 0;
_componentPaths = /* @__PURE__ */ new Set();
_componentNameMap = {};
_componentUsageMap = {};
_componentCustomMap = {};
_directiveCustomMap = {};
_removeUnused = false;
_server;
root = process.cwd();
sourcemap = true;
alias = {};
dumpComponentsInfoPath;
constructor(rawOptions) {
this.rawOptions = rawOptions;
this.options = resolveOptions(rawOptions, this.root);
this.sourcemap = rawOptions.sourcemap ?? true;
this.generateDeclaration = throttle(500, this._generateDeclaration.bind(this), { noLeading: false });
this._removeUnused = this.options.syncMode !== "append";
if (this.options.dumpComponentsInfo) {
this.dumpComponentsInfoPath = this.options.dumpComponentsInfo === true ? "./.components-info.json" : this.options.dumpComponentsInfo ?? false;
this.generateComponentsJson = throttle(500, this._generateComponentsJson.bind(this), { noLeading: false });
}
this.setTransformer(this.options.transformer);
}
setRoot(root) {
if (this.root === root) return;
debug.env("root", root);
this.root = root;
this.options = resolveOptions(this.rawOptions, this.root);
}
setTransformer(name) {
debug.env("transformer", name);
this.transformer = transformer(this, name || "vue3");
}
transform(code, id) {
const { path, query } = parseId(id);
return this.transformer(code, id, path, query);
}
setupViteServer(server) {
if (this._server === server) return;
this._server = server;
this._removeUnused = this.options.syncMode === "overwrite";
this.setupWatcher(server.watcher);
}
setupWatcher(watcher) {
const { globs } = this.options;
this._removeUnused = this.options.syncMode === "overwrite";
watcher.on("unlink", (path) => {
if (!matchGlobs(path, globs)) return;
path = slash(path);
this.removeComponents(path);
this.onUpdate(path);
});
watcher.on("add", (path) => {
if (!matchGlobs(path, globs)) return;
path = slash(path);
this.addComponents(path);
this.onUpdate(path);
});
}
/**
* start watcher for webpack
*/
setupWatcherWebpack(watcher, emitUpdate) {
const { globs } = this.options;
this._removeUnused = this.options.syncMode === "overwrite";
watcher.on("unlink", (path) => {
if (!matchGlobs(path, globs)) return;
path = slash(path);
this.removeComponents(path);
emitUpdate(path, "unlink");
});
watcher.on("add", (path) => {
if (!matchGlobs(path, globs)) return;
path = slash(path);
this.addComponents(path);
emitUpdate(path, "add");
});
}
/**
* Record the usage of components
* @param path
* @param paths paths of used components
*/
updateUsageMap(path, paths) {
if (!this._componentUsageMap[path]) this._componentUsageMap[path] = /* @__PURE__ */ new Set();
paths.forEach((p) => {
this._componentUsageMap[path].add(p);
});
}
addComponents(paths) {
debug.components("add", paths);
const size = this._componentPaths.size;
toArray(paths).forEach((p) => this._componentPaths.add(p));
if (this._componentPaths.size !== size) {
this.updateComponentNameMap();
return true;
}
return false;
}
addCustomComponents(info) {
if (info.as) this._componentCustomMap[info.as] = info;
}
addCustomDirectives(info) {
if (info.as) this._directiveCustomMap[info.as] = info;
}
removeComponents(paths) {
debug.components("remove", paths);
const size = this._componentPaths.size;
toArray(paths).forEach((p) => this._componentPaths.delete(p));
if (this._componentPaths.size !== size) {
this.updateComponentNameMap();
return true;
}
return false;
}
onUpdate(path) {
this.generateDeclaration();
this.generateComponentsJson();
if (!this._server) return;
const payload = {
type: "update",
updates: []
};
const timestamp = +/* @__PURE__ */ new Date();
const name = pascalCase(getNameFromFilePath(path, this.options));
Object.entries(this._componentUsageMap).forEach(([key, values]) => {
if (values.has(name)) {
const r = `/${slash(relative(this.root, key))}`;
payload.updates.push({
acceptedPath: r,
path: r,
timestamp,
type: "js-update"
});
}
});
if (payload.updates.length) this._server.ws.send(payload);
}
updateComponentNameMap() {
this._componentNameMap = {};
Array.from(this._componentPaths).forEach((path) => {
const fileName = getNameFromFilePath(path, this.options);
const name = this.options.prefix ? `${pascalCase(this.options.prefix)}${pascalCase(fileName)}` : pascalCase(fileName);
if (isExclude(name, this.options.excludeNames)) {
debug.components("exclude", name);
return;
}
if (this._componentNameMap[name] && !this.options.allowOverrides) {
console.warn(`[unplugin-vue-components] component "${name}"(${path}) has naming conflicts with other components, ignored.`);
return;
}
this._componentNameMap[name] = {
as: name,
from: path
};
});
}
async findComponent(name, type, excludePaths = []) {
let info = this._componentNameMap[name];
if (info && !excludePaths.includes(info.from) && !excludePaths.includes(info.from.slice(1))) return info;
for (const resolver of this.options.resolvers) {
if (resolver.type !== type) continue;
const result = await resolver.resolve(type === "directive" ? name.slice(DIRECTIVE_IMPORT_PREFIX.length) : name);
if (!result) continue;
if (typeof result === "string") info = {
as: name,
from: result
};
else info = {
as: name,
...normalizeComponentInfo(result)
};
if (type === "component") this.addCustomComponents(info);
else if (type === "directive") this.addCustomDirectives(info);
return info;
}
}
normalizePath(path) {
var _this$viteConfig, _this$viteConfig2;
return resolveAlias(path, ((_this$viteConfig = this.viteConfig) === null || _this$viteConfig === void 0 || (_this$viteConfig = _this$viteConfig.resolve) === null || _this$viteConfig === void 0 ? void 0 : _this$viteConfig.alias) || ((_this$viteConfig2 = this.viteConfig) === null || _this$viteConfig2 === void 0 ? void 0 : _this$viteConfig2.alias) || []);
}
relative(path) {
if (path.startsWith("/") && !path.startsWith(this.root)) return slash(path.slice(1));
return slash(relative(this.root, path));
}
_searched = false;
/**
* This search for components in with the given options.
* Will be called multiple times to ensure file loaded,
* should normally run only once.
*/
searchGlob() {
if (this._searched) return;
searchComponents(this);
debug.search(this._componentNameMap);
this._searched = true;
}
_generateDeclaration(removeUnused = this._removeUnused) {
if (!this.options.dts) return;
debug.declaration("generating dts");
return writeDeclaration(this, this.options.dts, removeUnused);
}
generateDeclaration(removeUnused = this._removeUnused) {
this._generateDeclaration(removeUnused);
}
_generateComponentsJson(removeUnused = this._removeUnused) {
if (!Object.keys(this._componentNameMap).length) return;
debug.components("generating components-info");
return writeComponentsJson(this, removeUnused);
}
generateComponentsJson(removeUnused = this._removeUnused) {
this._generateComponentsJson(removeUnused);
}
get componentNameMap() {
return this._componentNameMap;
}
get componentCustomMap() {
return this._componentCustomMap;
}
get directiveCustomMap() {
return this._directiveCustomMap;
}
};
//#endregion
//#region src/core/unplugin.ts
const PLUGIN_NAME = "unplugin:webpack";
var unplugin_default = createUnplugin((options = {}) => {
const filter = createFilter(options.include || [
/\.vue$/,
/\.vue\?vue/,
/\.vue\.[tj]sx?\?vue/,
/\.vue\?v=/
], options.exclude || [
/[\\/]node_modules[\\/]/,
/[\\/]\.git[\\/]/,
/[\\/]\.nuxt[\\/]/
]);
const ctx = new Context(options);
return {
name: "unplugin-vue-components",
enforce: "post",
api: {
async findComponent(name, filename) {
return await ctx.findComponent(name, "component", filename ? [filename] : []);
},
stringifyImport(info) {
return stringifyComponentImport(info, ctx);
}
},
transformInclude(id) {
return filter(id);
},
async transform(code, id) {
if (!shouldTransform(code)) return null;
try {
const result = await ctx.transform(code, id);
ctx.generateDeclaration();
ctx.generateComponentsJson();
return result;
} catch (e) {
this.error(e);
}
},
vite: {
async configResolved(config) {
ctx.setRoot(config.root);
ctx.sourcemap = true;
if (config.plugins.find((i) => i.name === "vite-plugin-vue2")) ctx.setTransformer("vue2");
if (ctx.options.dts) {
ctx.searchGlob();
if (!existsSync(ctx.options.dts)) ctx.generateDeclaration();
}
if (ctx.options.dumpComponentsInfo && ctx.dumpComponentsInfoPath) {
if (!existsSync(ctx.dumpComponentsInfoPath)) ctx.generateComponentsJson();
}
if (config.build.watch && config.command === "build") ctx.setupWatcher(chokidar.watch(await glob(ctx.options.globs)));
},
configureServer(server) {
ctx.setupViteServer(server);
}
},
webpack(compiler) {
let watcher;
let fileDepQueue = [];
compiler.hooks.watchRun.tapAsync(PLUGIN_NAME, async () => {
if (!watcher && compiler.watching) {
watcher = compiler.watching;
ctx.setupWatcherWebpack(chokidar.watch(await glob(ctx.options.globs)), (path, type) => {
fileDepQueue.push({
path,
type
});
process.nextTick(() => {
watcher.invalidate();
});
});
}
});
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
if (fileDepQueue.length) {
fileDepQueue.forEach(({ path, type }) => {
if (type === "unlink") compilation.fileDependencies.delete(path);
else compilation.fileDependencies.add(path);
});
fileDepQueue = [];
}
});
}
};
});
//#endregion
export { unplugin_default };

View File

@@ -0,0 +1,187 @@
//#region node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/walker.js
/**
* @typedef { import('estree').Node} Node
* @typedef {{
* skip: () => void;
* remove: () => void;
* replace: (node: Node) => void;
* }} WalkerContext
*/
var WalkerBase = class {
constructor() {
/** @type {boolean} */
this.should_skip = false;
/** @type {boolean} */
this.should_remove = false;
/** @type {Node | null} */
this.replacement = null;
/** @type {WalkerContext} */
this.context = {
skip: () => this.should_skip = true,
remove: () => this.should_remove = true,
replace: (node) => this.replacement = node
};
}
/**
* @template {Node} Parent
* @param {Parent | null | undefined} parent
* @param {keyof Parent | null | undefined} prop
* @param {number | null | undefined} index
* @param {Node} node
*/
replace(parent, prop, index, node) {
if (parent && prop) if (index != null)
/** @type {Array<Node>} */ parent[prop][index] = node;
else
/** @type {Node} */ parent[prop] = node;
}
/**
* @template {Node} Parent
* @param {Parent | null | undefined} parent
* @param {keyof Parent | null | undefined} prop
* @param {number | null | undefined} index
*/
remove(parent, prop, index) {
if (parent && prop) if (index !== null && index !== void 0)
/** @type {Array<Node>} */ parent[prop].splice(index, 1);
else delete parent[prop];
}
};
//#endregion
//#region node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/sync.js
/**
* @typedef { import('estree').Node} Node
* @typedef { import('./walker.js').WalkerContext} WalkerContext
* @typedef {(
* this: WalkerContext,
* node: Node,
* parent: Node | null,
* key: string | number | symbol | null | undefined,
* index: number | null | undefined
* ) => void} SyncHandler
*/
var SyncWalker = class extends WalkerBase {
/**
*
* @param {SyncHandler} [enter]
* @param {SyncHandler} [leave]
*/
constructor(enter, leave) {
super();
/** @type {boolean} */
this.should_skip = false;
/** @type {boolean} */
this.should_remove = false;
/** @type {Node | null} */
this.replacement = null;
/** @type {WalkerContext} */
this.context = {
skip: () => this.should_skip = true,
remove: () => this.should_remove = true,
replace: (node) => this.replacement = node
};
/** @type {SyncHandler | undefined} */
this.enter = enter;
/** @type {SyncHandler | undefined} */
this.leave = leave;
}
/**
* @template {Node} Parent
* @param {Node} node
* @param {Parent | null} parent
* @param {keyof Parent} [prop]
* @param {number | null} [index]
* @returns {Node | null}
*/
visit(node, parent, prop, index) {
if (node) {
if (this.enter) {
const _should_skip = this.should_skip;
const _should_remove = this.should_remove;
const _replacement = this.replacement;
this.should_skip = false;
this.should_remove = false;
this.replacement = null;
this.enter.call(this.context, node, parent, prop, index);
if (this.replacement) {
node = this.replacement;
this.replace(parent, prop, index, node);
}
if (this.should_remove) this.remove(parent, prop, index);
const skipped = this.should_skip;
const removed = this.should_remove;
this.should_skip = _should_skip;
this.should_remove = _should_remove;
this.replacement = _replacement;
if (skipped) return node;
if (removed) return null;
}
/** @type {keyof Node} */
let key;
for (key in node) {
/** @type {unknown} */
const value = node[key];
if (value && typeof value === "object") {
if (Array.isArray(value)) {
const nodes = value;
for (let i = 0; i < nodes.length; i += 1) {
const item = nodes[i];
if (isNode(item)) {
if (!this.visit(item, node, key, i)) i--;
}
}
} else if (isNode(value)) this.visit(value, node, key, null);
}
}
if (this.leave) {
const _replacement = this.replacement;
const _should_remove = this.should_remove;
this.replacement = null;
this.should_remove = false;
this.leave.call(this.context, node, parent, prop, index);
if (this.replacement) {
node = this.replacement;
this.replace(parent, prop, index, node);
}
if (this.should_remove) this.remove(parent, prop, index);
const removed = this.should_remove;
this.replacement = _replacement;
this.should_remove = _should_remove;
if (removed) return null;
}
}
return node;
}
};
/**
* Ducktype a node.
*
* @param {unknown} value
* @returns {value is Node}
*/
function isNode(value) {
return value !== null && typeof value === "object" && "type" in value && typeof value.type === "string";
}
//#endregion
//#region node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/index.js
/**
* @typedef {import('estree').Node} Node
* @typedef {import('./sync.js').SyncHandler} SyncHandler
* @typedef {import('./async.js').AsyncHandler} AsyncHandler
*/
/**
* @param {Node} ast
* @param {{
* enter?: SyncHandler
* leave?: SyncHandler
* }} walker
* @returns {Node | null}
*/
function walk(ast, { enter, leave }) {
return new SyncWalker(enter, leave).visit(ast, null);
}
//#endregion
export { walk };

View File

@@ -0,0 +1,769 @@
const require_utils = require('./utils-8UQ22cuO.cjs');
let node_fs = require("node:fs");
node_fs = require_utils.__toESM(node_fs);
let node_process = require("node:process");
node_process = require_utils.__toESM(node_process);
let chokidar = require("chokidar");
chokidar = require_utils.__toESM(chokidar);
let tinyglobby = require("tinyglobby");
tinyglobby = require_utils.__toESM(tinyglobby);
let unplugin = require("unplugin");
unplugin = require_utils.__toESM(unplugin);
let unplugin_utils = require("unplugin-utils");
unplugin_utils = require_utils.__toESM(unplugin_utils);
let node_path = require("node:path");
node_path = require_utils.__toESM(node_path);
let debug = require("debug");
debug = require_utils.__toESM(debug);
let node_fs_promises = require("node:fs/promises");
node_fs_promises = require_utils.__toESM(node_fs_promises);
let local_pkg = require("local-pkg");
local_pkg = require_utils.__toESM(local_pkg);
let magic_string = require("magic-string");
magic_string = require_utils.__toESM(magic_string);
//#region src/core/type-imports/index.ts
const TypeImportPresets = [{
from: "vue-router",
names: ["RouterView", "RouterLink"]
}, {
from: "vue-starport",
names: ["Starport", "StarportCarrier"]
}];
//#endregion
//#region src/core/type-imports/detect.ts
function detectTypeImports() {
return TypeImportPresets.map((i) => (0, local_pkg.isPackageExists)(i.from) ? i : void 0).filter(require_utils.notNullish);
}
function resolveTypeImports(imports) {
return imports.flatMap((i) => i.names.map((n) => ({
from: i.from,
name: n,
as: n
})));
}
//#endregion
//#region src/core/declaration.ts
const multilineCommentsRE = /\/\*.*?\*\//gs;
const singlelineCommentsRE = /\/\/.*$/gm;
function extractImports(code) {
return Object.fromEntries(Array.from(code.matchAll(/['"]?([^\s'"]+)['"]?\s*:\s*(.+?)[,;\r\n]/g)).map((i) => [i[1], i[2]]));
}
function parseDeclaration(code) {
var _exec, _exec2;
if (!code) return;
code = code.replace(multilineCommentsRE, "").replace(singlelineCommentsRE, "");
const imports = {
component: {},
directive: {}
};
const componentDeclaration = (_exec = /export\s+interface\s+GlobalComponents\s*\{.*?\}/s.exec(code)) === null || _exec === void 0 ? void 0 : _exec[0];
if (componentDeclaration) imports.component = extractImports(componentDeclaration);
const directiveDeclaration = (_exec2 = /export\s+interface\s+GlobalDirectives\s*\{.*?\}/s.exec(code)) === null || _exec2 === void 0 ? void 0 : _exec2[0];
if (directiveDeclaration) imports.directive = extractImports(directiveDeclaration);
return imports;
}
/**
* Converts `ComponentInfo` to an array
*
* `[name, "typeof import(path)[importName]"]`
*/
function stringifyComponentInfo(filepath, { from: path, as: name, name: importName }, importPathTransform) {
if (!name) return void 0;
path = require_utils.getTransformedPath(path, importPathTransform);
return [name, `typeof import('${require_utils.slash((0, node_path.isAbsolute)(path) ? `./${(0, node_path.relative)((0, node_path.dirname)(filepath), path)}` : path)}')['${importName || "default"}']`];
}
/**
* Converts array of `ComponentInfo` to an import map
*
* `{ name: "typeof import(path)[importName]", ... }`
*/
function stringifyComponentsInfo(filepath, components, importPathTransform) {
return Object.fromEntries(components.map((info) => stringifyComponentInfo(filepath, info, importPathTransform)).filter(require_utils.notNullish));
}
function getDeclarationImports(ctx, filepath) {
const component = stringifyComponentsInfo(filepath, [...Object.values({
...ctx.componentNameMap,
...ctx.componentCustomMap
}), ...resolveTypeImports(ctx.options.types)], ctx.options.importPathTransform);
const directive = stringifyComponentsInfo(filepath, Object.values(ctx.directiveCustomMap), ctx.options.importPathTransform);
if (Object.keys(component).length + Object.keys(directive).length === 0) return;
return {
component,
directive
};
}
function stringifyDeclarationImports(imports) {
return Object.entries(imports).sort(([a], [b]) => a.localeCompare(b)).map(([name, v]) => {
if (!/^\w+$/.test(name)) name = `'${name}'`;
return `${name}: ${v}`;
});
}
function getDeclaration(ctx, filepath, originalImports) {
const imports = getDeclarationImports(ctx, filepath);
if (!imports) return;
const declarations = {
component: stringifyDeclarationImports({
...originalImports === null || originalImports === void 0 ? void 0 : originalImports.component,
...imports.component
}),
directive: stringifyDeclarationImports({
...originalImports === null || originalImports === void 0 ? void 0 : originalImports.directive,
...imports.directive
})
};
let code = `/* eslint-disable */
// @ts-nocheck
// biome-ignore lint: disable
// oxlint-disable
// ------
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
${ctx.options.dtsTsx ? `import { GlobalComponents } from 'vue'\n` : ""}
export {}
/* prettier-ignore */
declare module 'vue' {`;
if (Object.keys(declarations.component).length > 0) code += `
export interface GlobalComponents {
${declarations.component.join("\n ")}
}`;
if (Object.keys(declarations.directive).length > 0) code += `
export interface GlobalDirectives {
${declarations.directive.join("\n ")}
}`;
code += "\n}\n";
if (ctx.options.dtsTsx) {
if (Object.keys(declarations.component).length > 0) code += `
// For TSX support
declare global {
${declarations.component.map((d) => d.replace(/(.+):/, "const $1:")).join("\n ")}
}`;
}
return code;
}
async function writeFile(filePath, content) {
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(filePath), { recursive: true });
return await (0, node_fs_promises.writeFile)(filePath, content, "utf-8");
}
async function writeDeclaration(ctx, filepath, removeUnused = false) {
const originalContent = (0, node_fs.existsSync)(filepath) ? await (0, node_fs_promises.readFile)(filepath, "utf-8") : "";
const code = getDeclaration(ctx, filepath, removeUnused ? void 0 : parseDeclaration(originalContent));
if (!code) return;
if (code !== originalContent) await writeFile(filepath, code);
}
async function writeComponentsJson(ctx, _removeUnused = false) {
if (!ctx.dumpComponentsInfoPath) return;
const components = [...Object.entries({
...ctx.componentNameMap,
...ctx.componentCustomMap
}).map(([_, { name, as, from }]) => ({
name: name || "default",
as,
from
})), ...resolveTypeImports(ctx.options.types)];
await writeFile(ctx.dumpComponentsInfoPath, JSON.stringify(components, null, 2));
}
//#endregion
//#region src/core/fs/glob.ts
const debug$5 = (0, debug.default)("unplugin-vue-components:glob");
function searchComponents(ctx) {
var _ctx$options$resolver;
debug$5(`started with: [${ctx.options.globs.join(", ")}]`);
const root = ctx.root;
const files = (0, tinyglobby.globSync)(ctx.options.globs, {
ignore: ctx.options.globsExclude,
onlyFiles: true,
cwd: root,
absolute: true,
expandDirectories: false
});
if (!files.length && !((_ctx$options$resolver = ctx.options.resolvers) === null || _ctx$options$resolver === void 0 ? void 0 : _ctx$options$resolver.length)) console.warn("[unplugin-vue-components] no components found");
debug$5(`${files.length} components found.`);
ctx.addComponents(files);
}
//#endregion
//#region src/core/options.ts
const defaultOptions = {
dirs: "src/components",
extensions: "vue",
deep: true,
dts: (0, local_pkg.isPackageExists)("typescript"),
dtsTsx: (0, local_pkg.isPackageExists)("@vitejs/plugin-vue-jsx"),
directoryAsNamespace: false,
collapseSamePrefixes: false,
globalNamespaces: [],
transformerUserResolveFunctions: true,
resolvers: [],
importPathTransform: (v) => v,
allowOverrides: false,
sourcemap: true,
dumpComponentsInfo: false,
syncMode: "default",
prefix: ""
};
function normalizeResolvers(resolvers) {
return require_utils.toArray(resolvers).flat().map((r) => typeof r === "function" ? {
resolve: r,
type: "component"
} : r);
}
function resolveGlobsExclude(root, glob$1) {
const excludeReg = /^!/;
return require_utils.slash(`${excludeReg.test(glob$1) ? "!" : ""}${(0, node_path.resolve)(root, glob$1.replace(excludeReg, ""))}`);
}
function resolveOptions(options, root) {
const resolved = Object.assign({}, defaultOptions, options);
resolved.resolvers = normalizeResolvers(resolved.resolvers);
resolved.extensions = require_utils.toArray(resolved.extensions);
if (resolved.globs) {
resolved.globs = require_utils.toArray(resolved.globs).map((glob$1) => resolveGlobsExclude(root, glob$1));
resolved.resolvedDirs = [];
} else {
const extsGlob = resolved.extensions.length === 1 ? resolved.extensions : `{${resolved.extensions.join(",")}}`;
resolved.dirs = require_utils.toArray(resolved.dirs);
const globs = resolved.dirs.map((i) => resolveGlobsExclude(root, i));
resolved.resolvedDirs = globs.filter((i) => !i.startsWith("!"));
resolved.globs = globs.map((i) => {
let prefix = "";
if (i.startsWith("!")) {
prefix = "!";
i = i.slice(1);
}
return resolved.deep ? prefix + require_utils.escapeSpecialChars(require_utils.slash((0, node_path.join)(i, `**/*.${extsGlob}`))) : prefix + require_utils.escapeSpecialChars(require_utils.slash((0, node_path.join)(i, `*.${extsGlob}`)));
});
if (!resolved.extensions.length) throw new Error("[unplugin-vue-components] `extensions` option is required to search for components");
}
resolved.globsExclude = require_utils.toArray(resolved.globsExclude || []).map((i) => resolveGlobsExclude(root, i));
resolved.globs = resolved.globs.filter((i) => {
if (!i.startsWith("!")) return true;
resolved.globsExclude.push(i.slice(1));
return false;
});
resolved.dts = !resolved.dts ? false : (0, node_path.resolve)(root, typeof resolved.dts === "string" ? resolved.dts : "components.d.ts");
if (!resolved.types && resolved.dts) resolved.types = detectTypeImports();
resolved.types = resolved.types || [];
resolved.root = root;
resolved.version = resolved.version ?? getVueVersion(root);
if (resolved.version < 2 || resolved.version >= 4) throw new Error(`[unplugin-vue-components] unsupported version: ${resolved.version}`);
resolved.transformer = options.transformer || `vue${Math.trunc(resolved.version)}`;
resolved.directives = typeof options.directives === "boolean" ? options.directives : !resolved.resolvers.some((i) => i.type === "directive") ? false : resolved.version >= 3;
return resolved;
}
function getVueVersion(root) {
var _getPackageInfoSync;
const version = +(((_getPackageInfoSync = (0, local_pkg.getPackageInfoSync)("vue", { paths: [(0, node_path.join)(root, "/")] })) === null || _getPackageInfoSync === void 0 ? void 0 : _getPackageInfoSync.version) || "3").split(".").slice(0, 2).join(".");
if (version === 2.7) return 2.7;
else if (version < 2.7) return 2;
return 3;
}
//#endregion
//#region src/core/transforms/component.ts
const debug$4 = (0, debug.default)("unplugin-vue-components:transform:component");
function resolveVue2$1(code, s) {
const results = [];
for (const match of code.matchAll(/\b(_c|h)\(\s*['"](.+?)["']([,)])/g)) {
const [full, renderFunctionName, matchedName, append] = match;
if (match.index != null && matchedName && !matchedName.startsWith("_")) {
const start = match.index;
const end = start + full.length;
results.push({
rawName: matchedName,
replace: (resolved) => s.overwrite(start, end, `${renderFunctionName}(${resolved}${append}`)
});
}
}
return results;
}
function resolveVue3$1(code, s, transformerUserResolveFunctions) {
const results = [];
/**
* when using some plugin like plugin-vue-jsx, resolveComponent will be imported as resolveComponent1 to avoid duplicate import
*/
for (const match of code.matchAll(/_?resolveComponent\d*\("(.+?)"\)/g)) {
if (!transformerUserResolveFunctions && !match[0].startsWith("_")) continue;
const matchedName = match[1];
if (match.index != null && matchedName && !matchedName.startsWith("_")) {
const start = match.index;
const end = start + match[0].length;
results.push({
rawName: matchedName,
replace: (resolved) => s.overwrite(start, end, resolved)
});
}
}
return results;
}
async function transformComponent(code, transformer$1, s, ctx, sfcPath) {
let no = 0;
const results = transformer$1 === "vue2" ? resolveVue2$1(code, s) : resolveVue3$1(code, s, ctx.options.transformerUserResolveFunctions);
for (const { rawName, replace } of results) {
debug$4(`| ${rawName}`);
const name = require_utils.pascalCase(rawName);
ctx.updateUsageMap(sfcPath, [name]);
const component = await ctx.findComponent(name, "component", [sfcPath]);
if (component) {
const varName = `__unplugin_components_${no}`;
s.prepend(`${require_utils.stringifyComponentImport({
...component,
as: varName
}, ctx)};\n`);
no += 1;
replace(varName);
}
}
debug$4(`^ (${no})`);
}
//#endregion
//#region src/core/transforms/directive/vue2.ts
/**
* Get Vue 2 render function position
*/
function getRenderFnStart(program) {
var _ref;
const renderFn = program.body.find((node) => node.type === "VariableDeclaration" && node.declarations[0].id.type === "Identifier" && ["render", "_sfc_render"].includes(node.declarations[0].id.name));
const start = renderFn === null || renderFn === void 0 || (_ref = renderFn.declarations[0].init) === null || _ref === void 0 || (_ref = _ref.body) === null || _ref === void 0 ? void 0 : _ref.start;
if (start === null || start === void 0) throw new Error("[unplugin-vue-components:directive] Cannot find render function position.");
return start + 1;
}
async function resolveVue2(code, s) {
if (!(0, local_pkg.isPackageExists)("@babel/parser")) throw new Error("[unplugin-vue-components:directive] To use Vue 2 directive you will need to install Babel first: \"npm install -D @babel/parser\"");
const { parse } = await (0, local_pkg.importModule)("@babel/parser");
const { program } = parse(code, { sourceType: "module" });
const nodes = [];
const { walk } = await Promise.resolve().then(() => require("./src-BTwFq3T3.cjs"));
walk(program, { enter(node) {
if (node.type === "CallExpression") nodes.push(node);
} });
if (nodes.length === 0) return [];
let _renderStart;
const getRenderStart = () => {
if (_renderStart !== void 0) return _renderStart;
return _renderStart = getRenderFnStart(program);
};
const results = [];
for (const node of nodes) {
var _args$, _args$1$properties$fi;
const { callee, arguments: args } = node;
if (callee.type !== "Identifier" || callee.name !== "_c" || ((_args$ = args[1]) === null || _args$ === void 0 ? void 0 : _args$.type) !== "ObjectExpression") continue;
const directives = (_args$1$properties$fi = args[1].properties.find((property) => property.type === "ObjectProperty" && property.key.type === "Identifier" && property.key.name === "directives")) === null || _args$1$properties$fi === void 0 ? void 0 : _args$1$properties$fi.value;
if (!directives || directives.type !== "ArrayExpression") continue;
for (const directive of directives.elements) {
var _directive$properties;
if ((directive === null || directive === void 0 ? void 0 : directive.type) !== "ObjectExpression") continue;
const nameNode = (_directive$properties = directive.properties.find((p) => p.type === "ObjectProperty" && p.key.type === "Identifier" && p.key.name === "name")) === null || _directive$properties === void 0 ? void 0 : _directive$properties.value;
if ((nameNode === null || nameNode === void 0 ? void 0 : nameNode.type) !== "StringLiteral") continue;
const name = nameNode.value;
if (!name || name.startsWith("_")) continue;
results.push({
rawName: name,
replace: (resolved) => {
s.prependLeft(getRenderStart(), `\nthis.$options.directives["${name}"] = ${resolved};`);
}
});
}
}
return results;
}
//#endregion
//#region src/core/transforms/directive/vue3.ts
function resolveVue3(code, s, transformerUserResolveFunctions) {
const results = [];
for (const match of code.matchAll(/_?resolveDirective\("(.+?)"\)/g)) {
const matchedName = match[1];
if (!transformerUserResolveFunctions && !match[0].startsWith("_")) continue;
if (match.index != null && matchedName && !matchedName.startsWith("_")) {
const start = match.index;
const end = start + match[0].length;
results.push({
rawName: matchedName,
replace: (resolved) => s.overwrite(start, end, resolved)
});
}
}
return results;
}
//#endregion
//#region src/core/transforms/directive/index.ts
const debug$3 = (0, debug.default)("unplugin-vue-components:transform:directive");
async function transformDirective(code, transformer$1, s, ctx, sfcPath) {
let no = 0;
const results = await (transformer$1 === "vue2" ? resolveVue2(code, s) : resolveVue3(code, s));
for (const { rawName, replace } of results) {
debug$3(`| ${rawName}`);
const name = `${require_utils.DIRECTIVE_IMPORT_PREFIX}${require_utils.pascalCase(rawName)}`;
ctx.updateUsageMap(sfcPath, [name]);
const directive = await ctx.findComponent(name, "directive", [sfcPath]);
if (!directive) continue;
const varName = `__unplugin_directives_${no}`;
s.prepend(`${require_utils.stringifyComponentImport({
...directive,
as: varName
}, ctx)};\n`);
no += 1;
replace(varName);
}
debug$3(`^ (${no})`);
}
//#endregion
//#region src/core/transformer.ts
const debug$2 = (0, debug.default)("unplugin-vue-components:transformer");
function transformer(ctx, transformer$1) {
return async (code, id, path) => {
ctx.searchGlob();
const sfcPath = ctx.normalizePath(path);
debug$2(sfcPath);
const s = new magic_string.default(code);
await transformComponent(code, transformer$1, s, ctx, sfcPath);
if (ctx.options.directives) await transformDirective(code, transformer$1, s, ctx, sfcPath);
s.prepend(require_utils.DISABLE_COMMENT);
const result = { code: s.toString() };
if (ctx.sourcemap) result.map = s.generateMap({
source: id,
includeContent: true,
hires: "boundary"
});
return result;
};
}
//#endregion
//#region src/core/context.ts
const debug$1 = {
components: (0, debug.default)("unplugin-vue-components:context:components"),
search: (0, debug.default)("unplugin-vue-components:context:search"),
hmr: (0, debug.default)("unplugin-vue-components:context:hmr"),
declaration: (0, debug.default)("unplugin-vue-components:declaration"),
env: (0, debug.default)("unplugin-vue-components:env")
};
var Context = class {
options;
transformer = void 0;
_componentPaths = /* @__PURE__ */ new Set();
_componentNameMap = {};
_componentUsageMap = {};
_componentCustomMap = {};
_directiveCustomMap = {};
_removeUnused = false;
_server;
root = node_process.default.cwd();
sourcemap = true;
alias = {};
dumpComponentsInfoPath;
constructor(rawOptions) {
this.rawOptions = rawOptions;
this.options = resolveOptions(rawOptions, this.root);
this.sourcemap = rawOptions.sourcemap ?? true;
this.generateDeclaration = require_utils.throttle(500, this._generateDeclaration.bind(this), { noLeading: false });
this._removeUnused = this.options.syncMode !== "append";
if (this.options.dumpComponentsInfo) {
this.dumpComponentsInfoPath = this.options.dumpComponentsInfo === true ? "./.components-info.json" : this.options.dumpComponentsInfo ?? false;
this.generateComponentsJson = require_utils.throttle(500, this._generateComponentsJson.bind(this), { noLeading: false });
}
this.setTransformer(this.options.transformer);
}
setRoot(root) {
if (this.root === root) return;
debug$1.env("root", root);
this.root = root;
this.options = resolveOptions(this.rawOptions, this.root);
}
setTransformer(name) {
debug$1.env("transformer", name);
this.transformer = transformer(this, name || "vue3");
}
transform(code, id) {
const { path, query } = require_utils.parseId(id);
return this.transformer(code, id, path, query);
}
setupViteServer(server) {
if (this._server === server) return;
this._server = server;
this._removeUnused = this.options.syncMode === "overwrite";
this.setupWatcher(server.watcher);
}
setupWatcher(watcher) {
const { globs } = this.options;
this._removeUnused = this.options.syncMode === "overwrite";
watcher.on("unlink", (path) => {
if (!require_utils.matchGlobs(path, globs)) return;
path = require_utils.slash(path);
this.removeComponents(path);
this.onUpdate(path);
});
watcher.on("add", (path) => {
if (!require_utils.matchGlobs(path, globs)) return;
path = require_utils.slash(path);
this.addComponents(path);
this.onUpdate(path);
});
}
/**
* start watcher for webpack
*/
setupWatcherWebpack(watcher, emitUpdate) {
const { globs } = this.options;
this._removeUnused = this.options.syncMode === "overwrite";
watcher.on("unlink", (path) => {
if (!require_utils.matchGlobs(path, globs)) return;
path = require_utils.slash(path);
this.removeComponents(path);
emitUpdate(path, "unlink");
});
watcher.on("add", (path) => {
if (!require_utils.matchGlobs(path, globs)) return;
path = require_utils.slash(path);
this.addComponents(path);
emitUpdate(path, "add");
});
}
/**
* Record the usage of components
* @param path
* @param paths paths of used components
*/
updateUsageMap(path, paths) {
if (!this._componentUsageMap[path]) this._componentUsageMap[path] = /* @__PURE__ */ new Set();
paths.forEach((p) => {
this._componentUsageMap[path].add(p);
});
}
addComponents(paths) {
debug$1.components("add", paths);
const size = this._componentPaths.size;
require_utils.toArray(paths).forEach((p) => this._componentPaths.add(p));
if (this._componentPaths.size !== size) {
this.updateComponentNameMap();
return true;
}
return false;
}
addCustomComponents(info) {
if (info.as) this._componentCustomMap[info.as] = info;
}
addCustomDirectives(info) {
if (info.as) this._directiveCustomMap[info.as] = info;
}
removeComponents(paths) {
debug$1.components("remove", paths);
const size = this._componentPaths.size;
require_utils.toArray(paths).forEach((p) => this._componentPaths.delete(p));
if (this._componentPaths.size !== size) {
this.updateComponentNameMap();
return true;
}
return false;
}
onUpdate(path) {
this.generateDeclaration();
this.generateComponentsJson();
if (!this._server) return;
const payload = {
type: "update",
updates: []
};
const timestamp = +/* @__PURE__ */ new Date();
const name = require_utils.pascalCase(require_utils.getNameFromFilePath(path, this.options));
Object.entries(this._componentUsageMap).forEach(([key, values]) => {
if (values.has(name)) {
const r = `/${require_utils.slash((0, node_path.relative)(this.root, key))}`;
payload.updates.push({
acceptedPath: r,
path: r,
timestamp,
type: "js-update"
});
}
});
if (payload.updates.length) this._server.ws.send(payload);
}
updateComponentNameMap() {
this._componentNameMap = {};
Array.from(this._componentPaths).forEach((path) => {
const fileName = require_utils.getNameFromFilePath(path, this.options);
const name = this.options.prefix ? `${require_utils.pascalCase(this.options.prefix)}${require_utils.pascalCase(fileName)}` : require_utils.pascalCase(fileName);
if (require_utils.isExclude(name, this.options.excludeNames)) {
debug$1.components("exclude", name);
return;
}
if (this._componentNameMap[name] && !this.options.allowOverrides) {
console.warn(`[unplugin-vue-components] component "${name}"(${path}) has naming conflicts with other components, ignored.`);
return;
}
this._componentNameMap[name] = {
as: name,
from: path
};
});
}
async findComponent(name, type, excludePaths = []) {
let info = this._componentNameMap[name];
if (info && !excludePaths.includes(info.from) && !excludePaths.includes(info.from.slice(1))) return info;
for (const resolver of this.options.resolvers) {
if (resolver.type !== type) continue;
const result = await resolver.resolve(type === "directive" ? name.slice(require_utils.DIRECTIVE_IMPORT_PREFIX.length) : name);
if (!result) continue;
if (typeof result === "string") info = {
as: name,
from: result
};
else info = {
as: name,
...require_utils.normalizeComponentInfo(result)
};
if (type === "component") this.addCustomComponents(info);
else if (type === "directive") this.addCustomDirectives(info);
return info;
}
}
normalizePath(path) {
var _this$viteConfig, _this$viteConfig2;
return require_utils.resolveAlias(path, ((_this$viteConfig = this.viteConfig) === null || _this$viteConfig === void 0 || (_this$viteConfig = _this$viteConfig.resolve) === null || _this$viteConfig === void 0 ? void 0 : _this$viteConfig.alias) || ((_this$viteConfig2 = this.viteConfig) === null || _this$viteConfig2 === void 0 ? void 0 : _this$viteConfig2.alias) || []);
}
relative(path) {
if (path.startsWith("/") && !path.startsWith(this.root)) return require_utils.slash(path.slice(1));
return require_utils.slash((0, node_path.relative)(this.root, path));
}
_searched = false;
/**
* This search for components in with the given options.
* Will be called multiple times to ensure file loaded,
* should normally run only once.
*/
searchGlob() {
if (this._searched) return;
searchComponents(this);
debug$1.search(this._componentNameMap);
this._searched = true;
}
_generateDeclaration(removeUnused = this._removeUnused) {
if (!this.options.dts) return;
debug$1.declaration("generating dts");
return writeDeclaration(this, this.options.dts, removeUnused);
}
generateDeclaration(removeUnused = this._removeUnused) {
this._generateDeclaration(removeUnused);
}
_generateComponentsJson(removeUnused = this._removeUnused) {
if (!Object.keys(this._componentNameMap).length) return;
debug$1.components("generating components-info");
return writeComponentsJson(this, removeUnused);
}
generateComponentsJson(removeUnused = this._removeUnused) {
this._generateComponentsJson(removeUnused);
}
get componentNameMap() {
return this._componentNameMap;
}
get componentCustomMap() {
return this._componentCustomMap;
}
get directiveCustomMap() {
return this._directiveCustomMap;
}
};
//#endregion
//#region src/core/unplugin.ts
const PLUGIN_NAME = "unplugin:webpack";
var unplugin_default = (0, unplugin.createUnplugin)((options = {}) => {
const filter = (0, unplugin_utils.createFilter)(options.include || [
/\.vue$/,
/\.vue\?vue/,
/\.vue\.[tj]sx?\?vue/,
/\.vue\?v=/
], options.exclude || [
/[\\/]node_modules[\\/]/,
/[\\/]\.git[\\/]/,
/[\\/]\.nuxt[\\/]/
]);
const ctx = new Context(options);
return {
name: "unplugin-vue-components",
enforce: "post",
api: {
async findComponent(name, filename) {
return await ctx.findComponent(name, "component", filename ? [filename] : []);
},
stringifyImport(info) {
return require_utils.stringifyComponentImport(info, ctx);
}
},
transformInclude(id) {
return filter(id);
},
async transform(code, id) {
if (!require_utils.shouldTransform(code)) return null;
try {
const result = await ctx.transform(code, id);
ctx.generateDeclaration();
ctx.generateComponentsJson();
return result;
} catch (e) {
this.error(e);
}
},
vite: {
async configResolved(config) {
ctx.setRoot(config.root);
ctx.sourcemap = true;
if (config.plugins.find((i) => i.name === "vite-plugin-vue2")) ctx.setTransformer("vue2");
if (ctx.options.dts) {
ctx.searchGlob();
if (!(0, node_fs.existsSync)(ctx.options.dts)) ctx.generateDeclaration();
}
if (ctx.options.dumpComponentsInfo && ctx.dumpComponentsInfoPath) {
if (!(0, node_fs.existsSync)(ctx.dumpComponentsInfoPath)) ctx.generateComponentsJson();
}
if (config.build.watch && config.command === "build") ctx.setupWatcher(chokidar.default.watch(await (0, tinyglobby.glob)(ctx.options.globs)));
},
configureServer(server) {
ctx.setupViteServer(server);
}
},
webpack(compiler) {
let watcher;
let fileDepQueue = [];
compiler.hooks.watchRun.tapAsync(PLUGIN_NAME, async () => {
if (!watcher && compiler.watching) {
watcher = compiler.watching;
ctx.setupWatcherWebpack(chokidar.default.watch(await (0, tinyglobby.glob)(ctx.options.globs)), (path, type) => {
fileDepQueue.push({
path,
type
});
node_process.default.nextTick(() => {
watcher.invalidate();
});
});
}
});
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
if (fileDepQueue.length) {
fileDepQueue.forEach(({ path, type }) => {
if (type === "unlink") compilation.fileDependencies.delete(path);
else compilation.fileDependencies.add(path);
});
fileDepQueue = [];
}
});
}
};
});
//#endregion
Object.defineProperty(exports, 'unplugin_default', {
enumerable: true,
get: function () {
return unplugin_default;
}
});

View File

View File

@@ -0,0 +1 @@
export { };

View File

@@ -0,0 +1,225 @@
import { Awaitable } from "@antfu/utils";
import { TransformResult } from "unplugin";
import { FilterPattern } from "unplugin-utils";
//#region src/types.d.ts
interface ImportInfoLegacy {
/**
* @deprecated renamed to `as`
*/
name?: string;
/**
* @deprecated renamed to `name`
*/
importName?: string;
/**
* @deprecated renamed to `from`
*/
path: string;
sideEffects?: SideEffectsInfo;
}
interface ImportInfo {
as?: string;
name?: string;
from: string;
}
type SideEffectsInfo = (ImportInfo | string)[] | ImportInfo | string | undefined;
interface ComponentInfo extends ImportInfo {
sideEffects?: SideEffectsInfo;
}
type ComponentResolveResult = Awaitable<string | ComponentInfo | null | undefined | void>;
type ComponentResolverFunction = (name: string) => ComponentResolveResult;
interface ComponentResolverObject {
type: 'component' | 'directive';
resolve: ComponentResolverFunction;
}
type ComponentResolver = ComponentResolverFunction | ComponentResolverObject;
type Matcher = (id: string) => boolean | null | undefined;
type Transformer = (code: string, id: string, path: string, query: Record<string, string>) => Awaitable<TransformResult | null>;
type SupportedTransformer = 'vue3' | 'vue2';
interface PublicPluginAPI {
/**
* Resolves a component using the configured resolvers.
*/
findComponent: (name: string, filename?: string) => Promise<ComponentInfo | undefined>;
/**
* Obtain an import statement for a resolved component.
*/
stringifyImport: (info: ComponentInfo) => string;
}
/**
* Plugin options.
*/
interface Options {
/**
* RegExp or glob to match files to be transformed
*/
include?: FilterPattern;
/**
* RegExp or glob to match files to NOT be transformed
*/
exclude?: FilterPattern;
/**
* RegExp or string to match component names that will NOT be imported
*/
excludeNames?: FilterPattern;
/**
* Relative paths to the directory to search for components.
* @default 'src/components'
*/
dirs?: string | string[];
/**
* Valid file extensions for components.
* @default ['vue']
*/
extensions?: string | string[];
/**
* Glob patterns to match file names to be detected as components.
*
* When specified, the `dirs`, `extensions`, and `directoryAsNamespace` options will be ignored.
*/
globs?: string | string[];
/**
* Negated glob patterns to exclude files from being detected as components.
*
* @default []
*/
globsExclude?: string | string[];
/**
* Search for subdirectories
* @default true
*/
deep?: boolean;
/**
* Allow subdirectories as namespace prefix for components
* @default false
*/
directoryAsNamespace?: boolean;
/**
* Generate components with prefix.
*/
prefix?: string;
/**
* Collapse same prefixes (camel-sensitive) of folders and components
* to prevent duplication inside namespaced component name.
*
* Works when `directoryAsNamespace: true`
* @default false
*/
collapseSamePrefixes?: boolean;
/**
* Subdirectory paths for ignoring namespace prefixes
*
* Works when `directoryAsNamespace: true`
* @default "[]"
*/
globalNamespaces?: string[];
/**
* Pass a custom function to resolve the component importing path from the component name.
*
* The component names are always in PascalCase
*/
resolvers?: (ComponentResolver | ComponentResolver[])[];
/**
* Apply custom transform over the path for importing
*/
importPathTransform?: (path: string) => string | undefined;
/**
* Transformer to apply
*
* @default 'vue3'
*/
transformer?: SupportedTransformer;
/**
* Tranform users' usage of resolveComponent/resolveDirective as well
*
* If disabled, only components inside templates (which compiles to `_resolveComponent` etc.)
* will be transformed.
*
* @default true
*/
transformerUserResolveFunctions?: boolean;
/**
* Generate TypeScript declaration for global components
*
* Accept boolean or a path related to project root
*
* @see https://github.com/vuejs/core/pull/3399
* @see https://github.com/johnsoncodehk/volar#using
* @default true
*/
dts?: boolean | string;
/**
* Generate TypeScript declaration for global components
* For TSX support
*
* @default true if `@vitejs/plugin-vue-jsx` is installed
*/
dtsTsx?: boolean;
/**
* Do not emit warning on component overriding
*
* @default false
*/
allowOverrides?: boolean;
/**
* auto import for directives.
*
* default: `true` for Vue 3, `false` for Vue 2
*
* Babel is needed to do the transformation for Vue 2, it's disabled by default for performance concerns.
* To install Babel, run: `npm install -D @babel/parser`
* @default undefined
*/
directives?: boolean;
/**
* Only provide types of components in library (registered globally)
*/
types?: TypeImport[];
/**
* Vue version of project. It will detect automatically if not specified.
*/
version?: 2 | 2.7 | 3;
/**
* Generate sourcemap for the transformed code.
*
* @default true
*/
sourcemap?: boolean;
/**
* Save component information into a JSON file for other tools to consume.
* Provide a filepath to save the JSON file.
*
* When set to `true`, it will save to `./.components-info.json`
*
* @default false
*/
dumpComponentsInfo?: boolean | string;
/**
* The mode for syncing the components.d.ts and .components-info.json file.
* - `append`: only append the new components to the existing files.
* - `overwrite`: overwrite the whole existing files with the current components.
* - `default`: use `append` strategy when using dev server, `overwrite` strategy when using build.
*
* @default 'default'
*/
syncMode?: 'default' | 'append' | 'overwrite';
}
type ResolvedOptions = Omit<Required<Options>, 'resolvers' | 'extensions' | 'dirs' | 'globalComponentsDeclaration'> & {
resolvers: ComponentResolverObject[];
extensions: string[];
dirs: string[];
resolvedDirs: string[];
globs: string[];
globsExclude: string[];
dts: string | false;
dtsTsx: boolean;
root: string;
};
type ComponentsImportMap = Record<string, string[] | undefined>;
interface TypeImport {
from: string;
names: string[];
}
//#endregion
export { ComponentInfo, ComponentResolveResult, ComponentResolver, ComponentResolverFunction, ComponentResolverObject, ComponentsImportMap, ImportInfo, ImportInfoLegacy, Matcher, Options, PublicPluginAPI, ResolvedOptions, SideEffectsInfo, SupportedTransformer, Transformer, TypeImport };

View File

@@ -0,0 +1,225 @@
import { TransformResult } from "unplugin";
import { FilterPattern } from "unplugin-utils";
import { Awaitable } from "@antfu/utils";
//#region src/types.d.ts
interface ImportInfoLegacy {
/**
* @deprecated renamed to `as`
*/
name?: string;
/**
* @deprecated renamed to `name`
*/
importName?: string;
/**
* @deprecated renamed to `from`
*/
path: string;
sideEffects?: SideEffectsInfo;
}
interface ImportInfo {
as?: string;
name?: string;
from: string;
}
type SideEffectsInfo = (ImportInfo | string)[] | ImportInfo | string | undefined;
interface ComponentInfo extends ImportInfo {
sideEffects?: SideEffectsInfo;
}
type ComponentResolveResult = Awaitable<string | ComponentInfo | null | undefined | void>;
type ComponentResolverFunction = (name: string) => ComponentResolveResult;
interface ComponentResolverObject {
type: 'component' | 'directive';
resolve: ComponentResolverFunction;
}
type ComponentResolver = ComponentResolverFunction | ComponentResolverObject;
type Matcher = (id: string) => boolean | null | undefined;
type Transformer = (code: string, id: string, path: string, query: Record<string, string>) => Awaitable<TransformResult | null>;
type SupportedTransformer = 'vue3' | 'vue2';
interface PublicPluginAPI {
/**
* Resolves a component using the configured resolvers.
*/
findComponent: (name: string, filename?: string) => Promise<ComponentInfo | undefined>;
/**
* Obtain an import statement for a resolved component.
*/
stringifyImport: (info: ComponentInfo) => string;
}
/**
* Plugin options.
*/
interface Options {
/**
* RegExp or glob to match files to be transformed
*/
include?: FilterPattern;
/**
* RegExp or glob to match files to NOT be transformed
*/
exclude?: FilterPattern;
/**
* RegExp or string to match component names that will NOT be imported
*/
excludeNames?: FilterPattern;
/**
* Relative paths to the directory to search for components.
* @default 'src/components'
*/
dirs?: string | string[];
/**
* Valid file extensions for components.
* @default ['vue']
*/
extensions?: string | string[];
/**
* Glob patterns to match file names to be detected as components.
*
* When specified, the `dirs`, `extensions`, and `directoryAsNamespace` options will be ignored.
*/
globs?: string | string[];
/**
* Negated glob patterns to exclude files from being detected as components.
*
* @default []
*/
globsExclude?: string | string[];
/**
* Search for subdirectories
* @default true
*/
deep?: boolean;
/**
* Allow subdirectories as namespace prefix for components
* @default false
*/
directoryAsNamespace?: boolean;
/**
* Generate components with prefix.
*/
prefix?: string;
/**
* Collapse same prefixes (camel-sensitive) of folders and components
* to prevent duplication inside namespaced component name.
*
* Works when `directoryAsNamespace: true`
* @default false
*/
collapseSamePrefixes?: boolean;
/**
* Subdirectory paths for ignoring namespace prefixes
*
* Works when `directoryAsNamespace: true`
* @default "[]"
*/
globalNamespaces?: string[];
/**
* Pass a custom function to resolve the component importing path from the component name.
*
* The component names are always in PascalCase
*/
resolvers?: (ComponentResolver | ComponentResolver[])[];
/**
* Apply custom transform over the path for importing
*/
importPathTransform?: (path: string) => string | undefined;
/**
* Transformer to apply
*
* @default 'vue3'
*/
transformer?: SupportedTransformer;
/**
* Tranform users' usage of resolveComponent/resolveDirective as well
*
* If disabled, only components inside templates (which compiles to `_resolveComponent` etc.)
* will be transformed.
*
* @default true
*/
transformerUserResolveFunctions?: boolean;
/**
* Generate TypeScript declaration for global components
*
* Accept boolean or a path related to project root
*
* @see https://github.com/vuejs/core/pull/3399
* @see https://github.com/johnsoncodehk/volar#using
* @default true
*/
dts?: boolean | string;
/**
* Generate TypeScript declaration for global components
* For TSX support
*
* @default true if `@vitejs/plugin-vue-jsx` is installed
*/
dtsTsx?: boolean;
/**
* Do not emit warning on component overriding
*
* @default false
*/
allowOverrides?: boolean;
/**
* auto import for directives.
*
* default: `true` for Vue 3, `false` for Vue 2
*
* Babel is needed to do the transformation for Vue 2, it's disabled by default for performance concerns.
* To install Babel, run: `npm install -D @babel/parser`
* @default undefined
*/
directives?: boolean;
/**
* Only provide types of components in library (registered globally)
*/
types?: TypeImport[];
/**
* Vue version of project. It will detect automatically if not specified.
*/
version?: 2 | 2.7 | 3;
/**
* Generate sourcemap for the transformed code.
*
* @default true
*/
sourcemap?: boolean;
/**
* Save component information into a JSON file for other tools to consume.
* Provide a filepath to save the JSON file.
*
* When set to `true`, it will save to `./.components-info.json`
*
* @default false
*/
dumpComponentsInfo?: boolean | string;
/**
* The mode for syncing the components.d.ts and .components-info.json file.
* - `append`: only append the new components to the existing files.
* - `overwrite`: overwrite the whole existing files with the current components.
* - `default`: use `append` strategy when using dev server, `overwrite` strategy when using build.
*
* @default 'default'
*/
syncMode?: 'default' | 'append' | 'overwrite';
}
type ResolvedOptions = Omit<Required<Options>, 'resolvers' | 'extensions' | 'dirs' | 'globalComponentsDeclaration'> & {
resolvers: ComponentResolverObject[];
extensions: string[];
dirs: string[];
resolvedDirs: string[];
globs: string[];
globsExclude: string[];
dts: string | false;
dtsTsx: boolean;
root: string;
};
type ComponentsImportMap = Record<string, string[] | undefined>;
interface TypeImport {
from: string;
names: string[];
}
//#endregion
export { ComponentInfo, ComponentResolveResult, ComponentResolver, ComponentResolverFunction, ComponentResolverObject, ComponentsImportMap, ImportInfo, ImportInfoLegacy, Matcher, Options, PublicPluginAPI, ResolvedOptions, SideEffectsInfo, SupportedTransformer, Transformer, TypeImport };

1
node_modules/unplugin-vue-components/dist/types.cjs generated vendored Normal file
View File

@@ -0,0 +1 @@
require('./types-CBTc19th.cjs');

View File

@@ -0,0 +1,2 @@
import { ComponentInfo, ComponentResolveResult, ComponentResolver, ComponentResolverFunction, ComponentResolverObject, ComponentsImportMap, ImportInfo, ImportInfoLegacy, Matcher, Options, PublicPluginAPI, ResolvedOptions, SideEffectsInfo, SupportedTransformer, Transformer, TypeImport } from "./types-DSJ5r-ta.cjs";
export { ComponentInfo, ComponentResolveResult, ComponentResolver, ComponentResolverFunction, ComponentResolverObject, ComponentsImportMap, ImportInfo, ImportInfoLegacy, Matcher, Options, PublicPluginAPI, ResolvedOptions, SideEffectsInfo, SupportedTransformer, Transformer, TypeImport };

2
node_modules/unplugin-vue-components/dist/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { ComponentInfo, ComponentResolveResult, ComponentResolver, ComponentResolverFunction, ComponentResolverObject, ComponentsImportMap, ImportInfo, ImportInfoLegacy, Matcher, Options, PublicPluginAPI, ResolvedOptions, SideEffectsInfo, SupportedTransformer, Transformer, TypeImport } from "./types-rC3290ja.js";
export { ComponentInfo, ComponentResolveResult, ComponentResolver, ComponentResolverFunction, ComponentResolverObject, ComponentsImportMap, ImportInfo, ImportInfoLegacy, Matcher, Options, PublicPluginAPI, ResolvedOptions, SideEffectsInfo, SupportedTransformer, Transformer, TypeImport };

3
node_modules/unplugin-vue-components/dist/types.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import "./types-DQoXDiso.js";
export { };

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

9
node_modules/unplugin-vue-components/dist/vite.cjs generated vendored Normal file
View File

@@ -0,0 +1,9 @@
require('./utils-8UQ22cuO.cjs');
const require_src = require('./src-DzdkjKhH.cjs');
require('./types-CBTc19th.cjs');
//#region src/vite.ts
var vite_default = require_src.unplugin_default.vite;
//#endregion
module.exports = vite_default;

8
node_modules/unplugin-vue-components/dist/vite.d.cts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import { Options, PublicPluginAPI } from "./types-DSJ5r-ta.cjs";
import { Plugin } from "vite";
//#region src/vite.d.ts
declare const _default: (options?: Options | undefined) => Plugin & {
api: PublicPluginAPI;
};
export = _default;

9
node_modules/unplugin-vue-components/dist/vite.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import { Options, PublicPluginAPI } from "./types-rC3290ja.js";
import { Plugin } from "vite";
//#region src/vite.d.ts
declare const _default: (options?: Options | undefined) => Plugin & {
api: PublicPluginAPI;
};
//#endregion
export { _default as default };

9
node_modules/unplugin-vue-components/dist/vite.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import "./utils-BoXu-4gQ.js";
import { unplugin_default } from "./src-BcnnO6GN.js";
import "./types-DQoXDiso.js";
//#region src/vite.ts
var vite_default = unplugin_default.vite;
//#endregion
export { vite_default as default };

View File

@@ -0,0 +1,9 @@
require('./utils-8UQ22cuO.cjs');
const require_src = require('./src-DzdkjKhH.cjs');
require('./types-CBTc19th.cjs');
//#region src/webpack.ts
var webpack_default = require_src.unplugin_default.webpack;
//#endregion
module.exports = webpack_default;

View File

@@ -0,0 +1,6 @@
import { Options } from "./types-DSJ5r-ta.cjs";
import * as webpack0 from "webpack";
//#region src/webpack.d.ts
declare const _default: (options: Options) => webpack0.WebpackPluginInstance;
export = _default;

View File

@@ -0,0 +1,7 @@
import { Options } from "./types-rC3290ja.js";
import * as webpack0 from "webpack";
//#region src/webpack.d.ts
declare const _default: (options: Options) => webpack0.WebpackPluginInstance;
//#endregion
export { _default as default };

9
node_modules/unplugin-vue-components/dist/webpack.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import "./utils-BoXu-4gQ.js";
import { unplugin_default } from "./src-BcnnO6GN.js";
import "./types-DQoXDiso.js";
//#region src/webpack.ts
var webpack_default = unplugin_default.webpack;
//#endregion
export { webpack_default as default };

135
node_modules/unplugin-vue-components/package.json generated vendored Normal file
View File

@@ -0,0 +1,135 @@
{
"name": "unplugin-vue-components",
"type": "module",
"version": "30.0.0",
"description": "Components auto importing for Vue",
"author": "antfu <anthonyfu117@hotmail.com>",
"license": "MIT",
"funding": "https://github.com/sponsors/antfu",
"homepage": "https://github.com/unplugin/unplugin-vue-components#readme",
"repository": {
"type": "git",
"url": "https://github.com/unplugin/unplugin-vue-components.git"
},
"bugs": "https://github.com/unplugin/unplugin-vue-components/issues",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"./nuxt": {
"import": "./dist/nuxt.js",
"require": "./dist/nuxt.cjs"
},
"./resolvers": {
"import": "./dist/resolvers.js",
"require": "./dist/resolvers.cjs"
},
"./rollup": {
"import": "./dist/rollup.js",
"require": "./dist/rollup.cjs"
},
"./rolldown": {
"import": "./dist/rolldown.js",
"require": "./dist/rolldown.cjs"
},
"./types": {
"import": "./dist/types.js",
"require": "./dist/types.cjs"
},
"./vite": {
"import": "./dist/vite.js",
"require": "./dist/vite.cjs"
},
"./webpack": {
"import": "./dist/webpack.js",
"require": "./dist/webpack.cjs"
},
"./rspack": {
"import": "./dist/rspack.js",
"require": "./dist/rspack.cjs"
},
"./esbuild": {
"import": "./dist/esbuild.js",
"require": "./dist/esbuild.cjs"
},
"./*": "./*"
},
"main": "dist/index.cjs",
"module": "dist/index.js",
"types": "index.d.ts",
"typesVersions": {
"*": {
"*": [
"./dist/*"
]
}
},
"files": [
"dist"
],
"engines": {
"node": ">=14"
},
"peerDependencies": {
"@babel/parser": "^7.15.8",
"@nuxt/kit": "^3.2.2 || ^4.0.0",
"vue": "2 || 3"
},
"peerDependenciesMeta": {
"@babel/parser": {
"optional": true
},
"@nuxt/kit": {
"optional": true
}
},
"dependencies": {
"chokidar": "^4.0.3",
"debug": "^4.4.3",
"local-pkg": "^1.1.2",
"magic-string": "^0.30.19",
"mlly": "^1.8.0",
"tinyglobby": "^0.2.15",
"unplugin": "^2.3.10",
"unplugin-utils": "^0.3.1"
},
"devDependencies": {
"@antfu/eslint-config": "^6.0.0",
"@antfu/utils": "^9.3.0",
"@babel/parser": "^7.28.4",
"@babel/types": "^7.28.4",
"@nuxt/kit": "^4.1.3",
"@nuxt/schema": "^4.1.3",
"@types/debug": "^4.1.12",
"@types/node": "^24.8.1",
"bumpp": "^10.3.1",
"compare-versions": "^6.1.1",
"element-plus": "^2.11.5",
"eslint": "^9.38.0",
"eslint-plugin-format": "^1.0.2",
"esno": "^4.8.0",
"estree-walker": "^3.0.3",
"minimatch": "^10.0.3",
"pathe": "^2.0.3",
"rolldown": "^1.0.0-beta.43",
"rollup": "^4.52.5",
"tsdown": "^0.15.8",
"typescript": "^5.9.3",
"vite": "^7.1.10",
"vitest": "^3.2.4",
"vue": "3.2.45",
"vue-tsc": "^3.1.1"
},
"scripts": {
"build": "tsdown",
"dev": "tsdown -w",
"example:build": "npm -C examples/vite-vue3 run build",
"example:dev": "npm -C examples/vite-vue3 run dev",
"lint": "eslint .",
"typecheck": "tsc",
"release": "bumpp",
"test": "vitest",
"test:update": "vitest -u"
}
}