UI优化完善初版
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021-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.
|
||||
+397
@@ -0,0 +1,397 @@
|
||||
# unplugin-auto-import
|
||||
|
||||
[](https://www.npmjs.com/package/unplugin-auto-import)
|
||||
|
||||
Auto import APIs on-demand for Vite, Webpack, Rspack, Rollup and esbuild. With TypeScript support. Powered by [unplugin](https://github.com/unjs/unplugin).
|
||||
|
||||
---
|
||||
|
||||
without
|
||||
|
||||
```ts
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
const count = ref(0)
|
||||
const doubled = computed(() => count.value * 2)
|
||||
```
|
||||
|
||||
with
|
||||
|
||||
```ts
|
||||
const count = ref(0)
|
||||
const doubled = computed(() => count.value * 2)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
without
|
||||
|
||||
```tsx
|
||||
import { useState } from 'react'
|
||||
|
||||
export function Counter() {
|
||||
const [count, setCount] = useState(0)
|
||||
return <div>{ count }</div>
|
||||
}
|
||||
```
|
||||
|
||||
with
|
||||
|
||||
```tsx
|
||||
export function Counter() {
|
||||
const [count, setCount] = useState(0)
|
||||
return <div>{ count }</div>
|
||||
}
|
||||
```
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm i -D unplugin-auto-import
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Vite</summary><br>
|
||||
|
||||
```ts
|
||||
// vite.config.ts
|
||||
import AutoImport from 'unplugin-auto-import/vite'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
AutoImport({ /* options */ }),
|
||||
],
|
||||
})
|
||||
```
|
||||
|
||||
Example: [`playground/`](./playground/)
|
||||
|
||||
<br></details>
|
||||
|
||||
<details>
|
||||
<summary>Rollup</summary><br>
|
||||
|
||||
```ts
|
||||
// rollup.config.js
|
||||
import AutoImport from 'unplugin-auto-import/rollup'
|
||||
|
||||
export default {
|
||||
plugins: [
|
||||
AutoImport({ /* options */ }),
|
||||
// other plugins
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
<br></details>
|
||||
|
||||
|
||||
<details>
|
||||
<summary>Webpack</summary><br>
|
||||
|
||||
```ts
|
||||
// webpack.config.js
|
||||
module.exports = {
|
||||
/* ... */
|
||||
plugins: [
|
||||
require('unplugin-auto-import/webpack')({ /* options */ }),
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
<br></details>
|
||||
|
||||
<details>
|
||||
<summary>Rspack</summary><br>
|
||||
|
||||
```ts
|
||||
// rspack.config.js
|
||||
module.exports = {
|
||||
/* ... */
|
||||
plugins: [
|
||||
require('unplugin-auto-import/rspack')({ /* options */ }),
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
<br></details>
|
||||
|
||||
<details>
|
||||
<summary>Nuxt</summary><br>
|
||||
|
||||
> You **don't need** this plugin for Nuxt, it's already builtin.
|
||||
|
||||
<br></details>
|
||||
|
||||
<details>
|
||||
<summary>Vue CLI</summary><br>
|
||||
|
||||
```ts
|
||||
// vue.config.js
|
||||
module.exports = {
|
||||
configureWebpack: {
|
||||
plugins: [
|
||||
require('unplugin-auto-import/webpack')({ /* options */ }),
|
||||
],
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
<br></details>
|
||||
|
||||
<details>
|
||||
<summary>Quasar</summary><br>
|
||||
|
||||
```ts
|
||||
// quasar.conf.js [Vite]
|
||||
module.exports = {
|
||||
vitePlugins: [
|
||||
['unplugin-auto-import/vite', { /* options */ }],
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
```ts
|
||||
// quasar.conf.js [Webpack]
|
||||
const AutoImportPlugin = require('unplugin-auto-import/webpack')
|
||||
|
||||
module.exports = {
|
||||
build: {
|
||||
chainWebpack(chain) {
|
||||
chain.plugin('unplugin-auto-import').use(
|
||||
AutoImportPlugin({ /* options */ }),
|
||||
)
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
<br></details>
|
||||
|
||||
|
||||
<details>
|
||||
<summary>esbuild</summary><br>
|
||||
|
||||
```ts
|
||||
// esbuild.config.js
|
||||
import { build } from 'esbuild'
|
||||
|
||||
build({
|
||||
/* ... */
|
||||
plugins: [
|
||||
require('unplugin-auto-import/esbuild')({
|
||||
/* options */
|
||||
}),
|
||||
],
|
||||
})
|
||||
```
|
||||
|
||||
<br></details>
|
||||
|
||||
|
||||
<details>
|
||||
<summary>Astro</summary><br>
|
||||
|
||||
```ts
|
||||
// astro.config.mjs
|
||||
import AutoImport from 'unplugin-auto-import/astro'
|
||||
|
||||
export default defineConfig({
|
||||
integrations: [
|
||||
AutoImport({
|
||||
/* options */
|
||||
})
|
||||
],
|
||||
})
|
||||
```
|
||||
|
||||
<br></details>
|
||||
|
||||
## Configuration
|
||||
|
||||
```ts
|
||||
AutoImport({
|
||||
// targets to transform
|
||||
include: [
|
||||
/\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
|
||||
/\.vue$/,
|
||||
/\.vue\?vue/, // .vue
|
||||
/\.md$/, // .md
|
||||
],
|
||||
|
||||
// global imports to register
|
||||
imports: [
|
||||
// presets
|
||||
'vue',
|
||||
'vue-router',
|
||||
// custom
|
||||
{
|
||||
'@vueuse/core': [
|
||||
// named imports
|
||||
'useMouse', // import { useMouse } from '@vueuse/core',
|
||||
// alias
|
||||
['useFetch', 'useMyFetch'], // import { useFetch as useMyFetch } from '@vueuse/core',
|
||||
],
|
||||
'axios': [
|
||||
// default imports
|
||||
['default', 'axios'], // import { default as axios } from 'axios',
|
||||
],
|
||||
'[package-name]': [
|
||||
'[import-names]',
|
||||
// alias
|
||||
['[from]', '[alias]'],
|
||||
],
|
||||
},
|
||||
// example type import
|
||||
{
|
||||
from: 'vue-router',
|
||||
imports: ['RouteLocationRaw'],
|
||||
type: true,
|
||||
},
|
||||
],
|
||||
// Enable auto import by filename for default module exports under directories
|
||||
defaultExportByFilename: false,
|
||||
|
||||
// Auto import for module exports under directories
|
||||
// by default it only scan one level of modules under the directory
|
||||
dirs: [
|
||||
// './hooks',
|
||||
// './composables' // only root modules
|
||||
// './composables/**', // all nested modules
|
||||
// ...
|
||||
],
|
||||
|
||||
// Filepath to generate corresponding .d.ts file.
|
||||
// Defaults to './auto-imports.d.ts' when `typescript` is installed locally.
|
||||
// Set `false` to disable.
|
||||
dts: './auto-imports.d.ts',
|
||||
|
||||
// Auto import inside Vue template
|
||||
// see https://github.com/unjs/unimport/pull/15 and https://github.com/unjs/unimport/pull/72
|
||||
vueTemplate: false,
|
||||
|
||||
// Custom resolvers, compatible with `unplugin-vue-components`
|
||||
// see https://github.com/antfu/unplugin-auto-import/pull/23/
|
||||
resolvers: [
|
||||
/* ... */
|
||||
],
|
||||
|
||||
// Inject the imports at the end of other imports
|
||||
injectAtEnd: true,
|
||||
|
||||
// Generate corresponding .eslintrc-auto-import.json file.
|
||||
// eslint globals Docs - https://eslint.org/docs/user-guide/configuring/language-options#specifying-globals
|
||||
eslintrc: {
|
||||
enabled: false, // Default `false`
|
||||
filepath: './.eslintrc-auto-import.json', // Default `./.eslintrc-auto-import.json`
|
||||
globalsPropValue: true, // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
Refer to the [type definitions](./src/types.ts) for more options.
|
||||
|
||||
## Presets
|
||||
|
||||
See [src/presets](./src/presets).
|
||||
|
||||
## TypeScript
|
||||
|
||||
In order to properly hint types for auto-imported APIs
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td width="400px" valign="top">
|
||||
|
||||
1. Enable `options.dts` so that `auto-imports.d.ts` file is automatically generated
|
||||
2. Make sure `auto-imports.d.ts` is not excluded in `tsconfig.json`
|
||||
|
||||
</td>
|
||||
<td width="600px"><br>
|
||||
|
||||
```ts
|
||||
AutoImport({
|
||||
dts: true // or a custom path
|
||||
})
|
||||
```
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## ESLint
|
||||
|
||||
> 💡 When using TypeScript, we recommend to **disable** `no-undef` rule directly as TypeScript already check for them and you don't need to worry about this.
|
||||
|
||||
If you have encountered ESLint error of `no-undef`:
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td width="400px">
|
||||
|
||||
1. Enable `eslintrc.enabled`
|
||||
|
||||
</td>
|
||||
<td width="600px"><br>
|
||||
|
||||
```ts
|
||||
AutoImport({
|
||||
eslintrc: {
|
||||
enabled: true, // <-- this
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
</td></tr></table>
|
||||
<table><tr><td width="400px">
|
||||
|
||||
2. Update your `eslintrc`:
|
||||
[Extending Configuration Files](https://eslint.org/docs/user-guide/configuring/configuration-files#extending-configuration-files)
|
||||
|
||||
</td>
|
||||
<td width="600px"><br>
|
||||
|
||||
```ts
|
||||
// .eslintrc.js
|
||||
module.exports = {
|
||||
extends: [
|
||||
'./.eslintrc-auto-import.json',
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## FAQ
|
||||
|
||||
### Compare to [`unimport`](https://github.com/unjs/unimport)
|
||||
|
||||
From v0.8.0, `unplugin-auto-import` **uses** `unimport` underneath. `unimport` is designed to be a lower-level tool (it also powered Nuxt's auto import). You can think `unplugin-auto-import` is a wrapper of it that provides more user-friendly config APIs and capabilities like resolvers. Development of new features will mostly happen in `unimport`` from now.
|
||||
|
||||
### Compare to [`vue-global-api`](https://github.com/antfu/vue-global-api)
|
||||
|
||||
You can think of this plugin as a successor to `vue-global-api`, but offering much more flexibility and bindings with libraries other than Vue (e.g. React).
|
||||
|
||||
###### Pros
|
||||
|
||||
- Flexible and customizable
|
||||
- Tree-shakable (on-demand transforming)
|
||||
- No global population
|
||||
|
||||
###### Cons
|
||||
|
||||
- Relying on build tools integrations (while `vue-global-api` is pure runtime) - but hey, we have supported quite a few of them already!
|
||||
|
||||
## Sponsors
|
||||
|
||||
<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>
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./LICENSE) License © 2021-PRESENT [Anthony Fu](https://github.com/antfu)
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
// @ts-nocheck
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
// Generated by unplugin-auto-import
|
||||
export {}
|
||||
declare global {
|
||||
const $: typeof import('vue/macros')['$']
|
||||
const $$: typeof import('vue/macros')['$$']
|
||||
const $computed: typeof import('vue/macros')['$computed']
|
||||
const $customRef: typeof import('vue/macros')['$customRef']
|
||||
const $ref: typeof import('vue/macros')['$ref']
|
||||
const $shallowRef: typeof import('vue/macros')['$shallowRef']
|
||||
const $toRef: typeof import('vue/macros')['$toRef']
|
||||
const EffectScope: typeof import('vue')['EffectScope']
|
||||
const THREE: typeof import('three.js')
|
||||
const acceptHMRUpdate: typeof import('pinia')['acceptHMRUpdate']
|
||||
const afterAll: typeof import('vitest')['afterAll']
|
||||
const afterEach: typeof import('vitest')['afterEach']
|
||||
const afterUpdate: typeof import('svelte')['afterUpdate']
|
||||
const assert: typeof import('vitest')['assert']
|
||||
const backIn: typeof import('svelte/easing')['backIn']
|
||||
const backInOut: typeof import('svelte/easing')['backInOut']
|
||||
const backOut: typeof import('svelte/easing')['backOut']
|
||||
const beforeAll: typeof import('vitest')['beforeAll']
|
||||
const beforeEach: typeof import('vitest')['beforeEach']
|
||||
const beforeUpdate: typeof import('svelte')['beforeUpdate']
|
||||
const blur: typeof import('svelte/transition')['blur']
|
||||
const bounceIn: typeof import('svelte/easing')['bounceIn']
|
||||
const bounceInOut: typeof import('svelte/easing')['bounceInOut']
|
||||
const bounceOut: typeof import('svelte/easing')['bounceOut']
|
||||
const chai: typeof import('vitest')['chai']
|
||||
const circIn: typeof import('svelte/easing')['circIn']
|
||||
const circInOut: typeof import('svelte/easing')['circInOut']
|
||||
const circOut: typeof import('svelte/easing')['circOut']
|
||||
const computed: typeof import('vue')['computed']
|
||||
const createApp: typeof import('vue')['createApp']
|
||||
const createEventDispatcher: typeof import('svelte')['createEventDispatcher']
|
||||
const createPinia: typeof import('pinia')['createPinia']
|
||||
const createRef: typeof import('react')['createRef']
|
||||
const crossfade: typeof import('svelte/transition')['crossfade']
|
||||
const cubicIn: typeof import('svelte/easing')['cubicIn']
|
||||
const cubicInOut: typeof import('svelte/easing')['cubicInOut']
|
||||
const cubicOut: typeof import('svelte/easing')['cubicOut']
|
||||
const customDefault: typeof import('custom')['default']
|
||||
const customDefaultAlias: typeof import('custom')['default']
|
||||
const customNamed: typeof import('custom')['customNamed']
|
||||
const customRef: typeof import('vue')['customRef']
|
||||
const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']
|
||||
const defineComponent: typeof import('vue')['defineComponent']
|
||||
const defineStore: typeof import('pinia')['defineStore']
|
||||
const derived: typeof import('svelte/store')['derived']
|
||||
const describe: typeof import('vitest')['describe']
|
||||
const draw: typeof import('svelte/transition')['draw']
|
||||
const effectScope: typeof import('vue')['effectScope']
|
||||
const elasticIn: typeof import('svelte/easing')['elasticIn']
|
||||
const elasticInOut: typeof import('svelte/easing')['elasticInOut']
|
||||
const elasticOut: typeof import('svelte/easing')['elasticOut']
|
||||
const expect: typeof import('vitest')['expect']
|
||||
const expoIn: typeof import('svelte/easing')['expoIn']
|
||||
const expoInOut: typeof import('svelte/easing')['expoInOut']
|
||||
const expoOut: typeof import('svelte/easing')['expoOut']
|
||||
const fade: typeof import('svelte/transition')['fade']
|
||||
const flip: typeof import('svelte/animate')['flip']
|
||||
const fly: typeof import('svelte/transition')['fly']
|
||||
const forwardRef: typeof import('react')['forwardRef']
|
||||
const get: typeof import('svelte/store')['get']
|
||||
const getActivePinia: typeof import('pinia')['getActivePinia']
|
||||
const getAllContexts: typeof import('svelte')['getAllContexts']
|
||||
const getContext: typeof import('svelte')['getContext']
|
||||
const getCurrentInstance: typeof import('vue')['getCurrentInstance']
|
||||
const getCurrentScope: typeof import('vue')['getCurrentScope']
|
||||
const h: typeof import('vue')['h']
|
||||
const hasContext: typeof import('svelte')['hasContext']
|
||||
const inject: typeof import('vue')['inject']
|
||||
const isProxy: typeof import('vue')['isProxy']
|
||||
const isReactive: typeof import('vue')['isReactive']
|
||||
const isReadonly: typeof import('vue')['isReadonly']
|
||||
const isRef: typeof import('vue')['isRef']
|
||||
const it: typeof import('vitest')['it']
|
||||
const lazy: typeof import('react')['lazy']
|
||||
const linear: typeof import('svelte/easing')['linear']
|
||||
const mapActions: typeof import('pinia')['mapActions']
|
||||
const mapGetters: typeof import('pinia')['mapGetters']
|
||||
const mapState: typeof import('pinia')['mapState']
|
||||
const mapStores: typeof import('pinia')['mapStores']
|
||||
const mapWritableState: typeof import('pinia')['mapWritableState']
|
||||
const markRaw: typeof import('vue')['markRaw']
|
||||
const memo: typeof import('react')['memo']
|
||||
const nextTick: typeof import('vue')['nextTick']
|
||||
const onActivated: typeof import('vue')['onActivated']
|
||||
const onBeforeMount: typeof import('vue')['onBeforeMount']
|
||||
const onBeforeUnmount: typeof import('vue')['onBeforeUnmount']
|
||||
const onBeforeUpdate: typeof import('vue')['onBeforeUpdate']
|
||||
const onDeactivated: typeof import('vue')['onDeactivated']
|
||||
const onDestroy: typeof import('svelte')['onDestroy']
|
||||
const onErrorCaptured: typeof import('vue')['onErrorCaptured']
|
||||
const onMount: typeof import('svelte')['onMount']
|
||||
const onMounted: typeof import('vue')['onMounted']
|
||||
const onRenderTracked: typeof import('vue')['onRenderTracked']
|
||||
const onRenderTriggered: typeof import('vue')['onRenderTriggered']
|
||||
const onScopeDispose: typeof import('vue')['onScopeDispose']
|
||||
const onServerPrefetch: typeof import('vue')['onServerPrefetch']
|
||||
const onUnmounted: typeof import('vue')['onUnmounted']
|
||||
const onUpdated: typeof import('vue')['onUpdated']
|
||||
const provide: typeof import('vue')['provide']
|
||||
const quadIn: typeof import('svelte/easing')['quadIn']
|
||||
const quadInOut: typeof import('svelte/easing')['quadInOut']
|
||||
const quadOut: typeof import('svelte/easing')['quadOut']
|
||||
const quartIn: typeof import('svelte/easing')['quartIn']
|
||||
const quartInOut: typeof import('svelte/easing')['quartInOut']
|
||||
const quartOut: typeof import('svelte/easing')['quartOut']
|
||||
const quintIn: typeof import('svelte/easing')['quintIn']
|
||||
const quintInOut: typeof import('svelte/easing')['quintInOut']
|
||||
const quintOut: typeof import('svelte/easing')['quintOut']
|
||||
const reactive: typeof import('vue')['reactive']
|
||||
const readable: typeof import('svelte/store')['readable']
|
||||
const readonly: typeof import('vue')['readonly']
|
||||
const ref: typeof import('vue')['ref']
|
||||
const resolveComponent: typeof import('vue')['resolveComponent']
|
||||
const scale: typeof import('svelte/transition')['scale']
|
||||
const setActivePinia: typeof import('pinia')['setActivePinia']
|
||||
const setContext: typeof import('svelte')['setContext']
|
||||
const setMapStoreSuffix: typeof import('pinia')['setMapStoreSuffix']
|
||||
const shallowReactive: typeof import('vue')['shallowReactive']
|
||||
const shallowReadonly: typeof import('vue')['shallowReadonly']
|
||||
const shallowRef: typeof import('vue')['shallowRef']
|
||||
const sineIn: typeof import('svelte/easing')['sineIn']
|
||||
const sineInOut: typeof import('svelte/easing')['sineInOut']
|
||||
const sineOut: typeof import('svelte/easing')['sineOut']
|
||||
const slide: typeof import('svelte/transition')['slide']
|
||||
const spring: typeof import('svelte/motion')['spring']
|
||||
const startTransition: typeof import('react')['startTransition']
|
||||
const storeToRefs: typeof import('pinia')['storeToRefs']
|
||||
const suite: typeof import('vitest')['suite']
|
||||
const test: typeof import('vitest')['test']
|
||||
const tick: typeof import('svelte')['tick']
|
||||
const toRaw: typeof import('vue')['toRaw']
|
||||
const toRef: typeof import('vue')['toRef']
|
||||
const toRefs: typeof import('vue')['toRefs']
|
||||
const toValue: typeof import('vue')['toValue']
|
||||
const triggerRef: typeof import('vue')['triggerRef']
|
||||
const tweened: typeof import('svelte/motion')['tweened']
|
||||
const unref: typeof import('vue')['unref']
|
||||
const useAttrs: typeof import('vue')['useAttrs']
|
||||
const useCallback: typeof import('react')['useCallback']
|
||||
const useContext: typeof import('react')['useContext']
|
||||
const useCssModule: typeof import('vue')['useCssModule']
|
||||
const useCssVars: typeof import('vue')['useCssVars']
|
||||
const useDebugValue: typeof import('react')['useDebugValue']
|
||||
const useDeferredValue: typeof import('react')['useDeferredValue']
|
||||
const useDialogPluginComponent: typeof import('quasar')['useDialogPluginComponent']
|
||||
const useEffect: typeof import('react')['useEffect']
|
||||
const useFormChild: typeof import('quasar')['useFormChild']
|
||||
const useId: typeof import('react')['useId']
|
||||
const useImperativeHandle: typeof import('react')['useImperativeHandle']
|
||||
const useInsertionEffect: typeof import('react')['useInsertionEffect']
|
||||
const useLayoutEffect: typeof import('react')['useLayoutEffect']
|
||||
const useMemo: typeof import('react')['useMemo']
|
||||
const useMeta: typeof import('quasar')['useMeta']
|
||||
const useQuasar: typeof import('quasar')['useQuasar']
|
||||
const useReducer: typeof import('react')['useReducer']
|
||||
const useRef: typeof import('react')['useRef']
|
||||
const useSlots: typeof import('vue')['useSlots']
|
||||
const useState: typeof import('react')['useState']
|
||||
const useSyncExternalStore: typeof import('react')['useSyncExternalStore']
|
||||
const useTransition: typeof import('react')['useTransition']
|
||||
const vi: typeof import('vitest')['vi']
|
||||
const vitest: typeof import('vitest')['vitest']
|
||||
const watch: typeof import('vue')['watch']
|
||||
const watchEffect: typeof import('vue')['watchEffect']
|
||||
const watchPostEffect: typeof import('vue')['watchPostEffect']
|
||||
const watchSyncEffect: typeof import('vue')['watchSyncEffect']
|
||||
const writable: typeof import('svelte/store')['writable']
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
||||
|
||||
var _chunkERF3N54Scjs = require('./chunk-ERF3N54S.cjs');
|
||||
require('./chunk-6UOGCAOY.cjs');
|
||||
|
||||
// src/astro.ts
|
||||
function astro_default(options) {
|
||||
return {
|
||||
name: "unplugin-auto-import",
|
||||
hooks: {
|
||||
"astro:config:setup": async (astro) => {
|
||||
var _a;
|
||||
(_a = astro.config.vite).plugins || (_a.plugins = []);
|
||||
astro.config.vite.plugins.push(_chunkERF3N54Scjs.unplugin_default.vite(options));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
module.exports = astro_default;
|
||||
exports.default = module.exports;
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import { Options } from './types.cjs';
|
||||
import '@antfu/utils';
|
||||
import '@rollup/pluginutils';
|
||||
import 'unimport';
|
||||
import 'unimport/dist/shared/unimport.b55a67ec';
|
||||
|
||||
declare function export_default(options: Options): {
|
||||
name: string;
|
||||
hooks: {
|
||||
'astro:config:setup': (astro: any) => Promise<void>;
|
||||
};
|
||||
};
|
||||
|
||||
export { export_default as default };
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import { Options } from './types.js';
|
||||
import '@antfu/utils';
|
||||
import '@rollup/pluginutils';
|
||||
import 'unimport';
|
||||
import 'unimport/dist/shared/unimport.b55a67ec';
|
||||
|
||||
declare function export_default(options: Options): {
|
||||
name: string;
|
||||
hooks: {
|
||||
'astro:config:setup': (astro: any) => Promise<void>;
|
||||
};
|
||||
};
|
||||
|
||||
export { export_default as default };
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import {
|
||||
unplugin_default
|
||||
} from "./chunk-6AAI2DNE.js";
|
||||
import "./chunk-EZINZJYF.js";
|
||||
|
||||
// src/astro.ts
|
||||
function astro_default(options) {
|
||||
return {
|
||||
name: "unplugin-auto-import",
|
||||
hooks: {
|
||||
"astro:config:setup": async (astro) => {
|
||||
var _a;
|
||||
(_a = astro.config.vite).plugins || (_a.plugins = []);
|
||||
astro.config.vite.plugins.push(unplugin_default.vite(options));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
export {
|
||||
astro_default as default
|
||||
};
|
||||
+361
@@ -0,0 +1,361 @@
|
||||
import {
|
||||
__spreadValues,
|
||||
presets
|
||||
} from "./chunk-EZINZJYF.js";
|
||||
|
||||
// src/core/unplugin.ts
|
||||
import { minimatch } from "minimatch";
|
||||
import { slash as slash2 } from "@antfu/utils";
|
||||
import { createUnplugin } from "unplugin";
|
||||
|
||||
// src/core/ctx.ts
|
||||
import { dirname, isAbsolute, join, relative, resolve } from "path";
|
||||
import { existsSync, promises as fs } from "fs";
|
||||
import process from "process";
|
||||
import { slash, throttle, toArray as toArray2 } from "@antfu/utils";
|
||||
import { createFilter } from "@rollup/pluginutils";
|
||||
import { isPackageExists } from "local-pkg";
|
||||
import { createUnimport, resolvePreset, scanExports } from "unimport";
|
||||
import fg from "fast-glob";
|
||||
import { vueTemplateAddon } from "unimport/addons";
|
||||
import MagicString from "magic-string";
|
||||
|
||||
// src/core/eslintrc.ts
|
||||
function generateESLintConfigs(imports, eslintrc, globals = {}) {
|
||||
const eslintConfigs = { globals };
|
||||
imports.map((i) => {
|
||||
var _a;
|
||||
return (_a = i.as) != null ? _a : i.name;
|
||||
}).filter(Boolean).sort().forEach((name) => {
|
||||
eslintConfigs.globals[name] = eslintrc.globalsPropValue;
|
||||
});
|
||||
const jsonBody = JSON.stringify(eslintConfigs, null, 2);
|
||||
return jsonBody;
|
||||
}
|
||||
|
||||
// src/core/resolvers.ts
|
||||
import { toArray } from "@antfu/utils";
|
||||
function normalizeImport(info, name) {
|
||||
if (typeof info === "string") {
|
||||
return {
|
||||
name: "default",
|
||||
as: name,
|
||||
from: info
|
||||
};
|
||||
}
|
||||
if ("path" in info) {
|
||||
return {
|
||||
from: info.path,
|
||||
as: info.name,
|
||||
name: info.importName,
|
||||
sideEffects: info.sideEffects
|
||||
};
|
||||
}
|
||||
return __spreadValues({
|
||||
name,
|
||||
as: name
|
||||
}, info);
|
||||
}
|
||||
async function firstMatchedResolver(resolvers, fullname) {
|
||||
let name = fullname;
|
||||
for (const resolver of resolvers) {
|
||||
if (typeof resolver === "object" && resolver.type === "directive") {
|
||||
if (name.startsWith("v"))
|
||||
name = name.slice(1);
|
||||
else
|
||||
continue;
|
||||
}
|
||||
const resolved = await (typeof resolver === "function" ? resolver(name) : resolver.resolve(name));
|
||||
if (resolved)
|
||||
return normalizeImport(resolved, fullname);
|
||||
}
|
||||
}
|
||||
function resolversAddon(resolvers) {
|
||||
return {
|
||||
async matchImports(names, matched) {
|
||||
if (!resolvers.length)
|
||||
return;
|
||||
const dynamic = [];
|
||||
const sideEffects = [];
|
||||
await Promise.all([...names].map(async (name) => {
|
||||
const matchedImport = matched.find((i) => i.as === name);
|
||||
if (matchedImport) {
|
||||
if ("sideEffects" in matchedImport)
|
||||
sideEffects.push(...toArray(matchedImport.sideEffects).map((i) => normalizeImport(i, "")));
|
||||
return;
|
||||
}
|
||||
const resolved = await firstMatchedResolver(resolvers, name);
|
||||
if (resolved)
|
||||
dynamic.push(resolved);
|
||||
if (resolved == null ? void 0 : resolved.sideEffects)
|
||||
sideEffects.push(...toArray(resolved == null ? void 0 : resolved.sideEffects).map((i) => normalizeImport(i, "")));
|
||||
}));
|
||||
if (dynamic.length) {
|
||||
this.dynamicImports.push(...dynamic);
|
||||
this.invalidate();
|
||||
}
|
||||
if (dynamic.length || sideEffects.length)
|
||||
return [...matched, ...dynamic, ...sideEffects];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// src/core/ctx.ts
|
||||
function resolveGlobsExclude(root, glob) {
|
||||
const excludeReg = /^!/;
|
||||
return `${excludeReg.test(glob) ? "!" : ""}${resolve(root, glob.replace(excludeReg, ""))}`;
|
||||
}
|
||||
async function scanDirExports(dirs, root) {
|
||||
const result = await fg(dirs, {
|
||||
absolute: true,
|
||||
cwd: root,
|
||||
onlyFiles: true,
|
||||
followSymbolicLinks: true
|
||||
});
|
||||
const files = Array.from(new Set(result.flat())).map(slash);
|
||||
return (await Promise.all(files.map((i) => scanExports(i, false)))).flat();
|
||||
}
|
||||
function createContext(options = {}, root = process.cwd()) {
|
||||
var _a;
|
||||
const {
|
||||
dts: preferDTS = isPackageExists("typescript")
|
||||
} = options;
|
||||
const dirs = (_a = options.dirs) == null ? void 0 : _a.concat(options.dirs.map((dir) => join(dir, "*.{tsx,jsx,ts,js,mjs,cjs,mts,cts}"))).map((dir) => slash(resolveGlobsExclude(root, dir)));
|
||||
const eslintrc = options.eslintrc || {};
|
||||
eslintrc.enabled = eslintrc.enabled === void 0 ? false : eslintrc.enabled;
|
||||
eslintrc.filepath = eslintrc.filepath || "./.eslintrc-auto-import.json";
|
||||
eslintrc.globalsPropValue = eslintrc.globalsPropValue === void 0 ? true : eslintrc.globalsPropValue;
|
||||
const resolvers = options.resolvers ? [options.resolvers].flat(2) : [];
|
||||
const injectAtEnd = options.injectAtEnd !== false;
|
||||
const unimport = createUnimport({
|
||||
imports: [],
|
||||
presets: [],
|
||||
injectAtEnd,
|
||||
addons: [
|
||||
...options.vueTemplate ? [vueTemplateAddon()] : [],
|
||||
resolversAddon(resolvers),
|
||||
{
|
||||
declaration(dts2) {
|
||||
return `${`
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
// @ts-nocheck
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
// Generated by unplugin-auto-import
|
||||
${dts2}`.trim()}
|
||||
`;
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
const importsPromise = flattenImports(options.imports).then((imports) => {
|
||||
var _a2;
|
||||
if (!imports.length && !resolvers.length && !(dirs == null ? void 0 : dirs.length))
|
||||
console.warn("[auto-import] plugin installed but no imports has defined, see https://github.com/antfu/unplugin-auto-import#configurations for configurations");
|
||||
(_a2 = options.ignore) == null ? void 0 : _a2.forEach((name) => {
|
||||
const i = imports.find((i2) => i2.as === name);
|
||||
if (i)
|
||||
i.disabled = true;
|
||||
});
|
||||
return unimport.getInternalContext().replaceImports(imports);
|
||||
});
|
||||
const filter = createFilter(
|
||||
options.include || [/\.[jt]sx?$/, /\.vue$/, /\.vue\?vue/, /\.svelte$/],
|
||||
options.exclude || [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/]
|
||||
);
|
||||
const dts = preferDTS === false ? false : preferDTS === true ? resolve(root, "auto-imports.d.ts") : resolve(root, preferDTS);
|
||||
const multilineCommentsRE = new RegExp("\\/\\*.*?\\*\\/", "gms");
|
||||
const singlelineCommentsRE = /\/\/.*$/gm;
|
||||
const dtsReg = new RegExp("declare\\s+global\\s*{(.*?)[\\n\\r]}", "s");
|
||||
function parseDTS(dts2) {
|
||||
var _a2;
|
||||
dts2 = dts2.replace(multilineCommentsRE, "").replace(singlelineCommentsRE, "");
|
||||
const code = (_a2 = dts2.match(dtsReg)) == null ? void 0 : _a2[0];
|
||||
if (!code)
|
||||
return;
|
||||
return Object.fromEntries(Array.from(code.matchAll(/['"]?(const\s*[^\s'"]+)['"]?\s*:\s*(.+?)[,;\r\n]/g)).map((i) => [i[1], i[2]]));
|
||||
}
|
||||
async function generateDTS(file) {
|
||||
await importsPromise;
|
||||
const dir = dirname(file);
|
||||
const originalContent = existsSync(file) ? await fs.readFile(file, "utf-8") : "";
|
||||
const originalDTS = parseDTS(originalContent);
|
||||
const currentContent = await unimport.generateTypeDeclarations({
|
||||
resolvePath: (i) => {
|
||||
if (i.from.startsWith(".") || isAbsolute(i.from)) {
|
||||
const related = slash(relative(dir, i.from).replace(/\.ts(x)?$/, ""));
|
||||
return !related.startsWith(".") ? `./${related}` : related;
|
||||
}
|
||||
return i.from;
|
||||
}
|
||||
});
|
||||
const currentDTS = parseDTS(currentContent);
|
||||
if (originalDTS) {
|
||||
Object.keys(currentDTS).forEach((key) => {
|
||||
originalDTS[key] = currentDTS[key];
|
||||
});
|
||||
const dtsList = Object.keys(originalDTS).sort().map((k) => ` ${k}: ${originalDTS[k]}`);
|
||||
return currentContent.replace(dtsReg, () => `declare global {
|
||||
${dtsList.join("\n")}
|
||||
}`);
|
||||
}
|
||||
return currentContent;
|
||||
}
|
||||
async function parseESLint() {
|
||||
const configStr = existsSync(eslintrc.filepath) ? await fs.readFile(eslintrc.filepath, "utf-8") : "";
|
||||
const config = JSON.parse(configStr || '{ "globals": {} }');
|
||||
return config.globals;
|
||||
}
|
||||
async function generateESLint() {
|
||||
return generateESLintConfigs(await unimport.getImports(), eslintrc, await parseESLint());
|
||||
}
|
||||
const writeConfigFilesThrottled = throttle(500, writeConfigFiles, { noLeading: false });
|
||||
async function writeFile(filePath, content = "") {
|
||||
await fs.mkdir(dirname(filePath), { recursive: true });
|
||||
return await fs.writeFile(filePath, content, "utf-8");
|
||||
}
|
||||
let lastDTS;
|
||||
let lastESLint;
|
||||
async function writeConfigFiles() {
|
||||
const promises = [];
|
||||
if (dts) {
|
||||
promises.push(
|
||||
generateDTS(dts).then((content) => {
|
||||
if (content !== lastDTS) {
|
||||
lastDTS = content;
|
||||
return writeFile(dts, content);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
if (eslintrc.enabled && eslintrc.filepath) {
|
||||
promises.push(
|
||||
generateESLint().then((content) => {
|
||||
content = `${content}
|
||||
`;
|
||||
if (content.trim() !== (lastESLint == null ? void 0 : lastESLint.trim())) {
|
||||
lastESLint = content;
|
||||
return writeFile(eslintrc.filepath, content);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
return Promise.all(promises);
|
||||
}
|
||||
async function scanDirs() {
|
||||
if (dirs == null ? void 0 : dirs.length) {
|
||||
await unimport.modifyDynamicImports(async (imports) => {
|
||||
const exports_ = await scanDirExports(dirs, root);
|
||||
exports_.forEach((i) => i.__source = "dir");
|
||||
return modifyDefaultExportsAlias([
|
||||
...imports.filter((i) => i.__source !== "dir"),
|
||||
...exports_
|
||||
], options);
|
||||
});
|
||||
}
|
||||
writeConfigFilesThrottled();
|
||||
}
|
||||
async function transform(code, id) {
|
||||
await importsPromise;
|
||||
const s = new MagicString(code);
|
||||
await unimport.injectImports(s, id);
|
||||
if (!s.hasChanged())
|
||||
return;
|
||||
writeConfigFilesThrottled();
|
||||
return {
|
||||
code: s.toString(),
|
||||
map: s.generateMap({ source: id, includeContent: true, hires: true })
|
||||
};
|
||||
}
|
||||
return {
|
||||
root,
|
||||
dirs,
|
||||
filter,
|
||||
scanDirs,
|
||||
writeConfigFiles,
|
||||
writeConfigFilesThrottled,
|
||||
transform,
|
||||
generateDTS,
|
||||
generateESLint
|
||||
};
|
||||
}
|
||||
async function flattenImports(map) {
|
||||
const promises = await Promise.all(toArray2(map).map(async (definition) => {
|
||||
if (typeof definition === "string") {
|
||||
if (!presets[definition])
|
||||
throw new Error(`[auto-import] preset ${definition} not found`);
|
||||
const preset = presets[definition];
|
||||
definition = typeof preset === "function" ? preset() : preset;
|
||||
}
|
||||
if ("from" in definition && "imports" in definition) {
|
||||
return await resolvePreset(definition);
|
||||
} else {
|
||||
const resolved = [];
|
||||
for (const mod of Object.keys(definition)) {
|
||||
for (const id of definition[mod]) {
|
||||
const meta = {
|
||||
from: mod
|
||||
};
|
||||
if (Array.isArray(id)) {
|
||||
meta.name = id[0];
|
||||
meta.as = id[1];
|
||||
} else {
|
||||
meta.name = id;
|
||||
meta.as = id;
|
||||
}
|
||||
resolved.push(meta);
|
||||
}
|
||||
}
|
||||
return resolved;
|
||||
}
|
||||
}));
|
||||
return promises.flat();
|
||||
}
|
||||
function modifyDefaultExportsAlias(imports, options) {
|
||||
if (options.defaultExportByFilename) {
|
||||
imports.forEach((i) => {
|
||||
var _a, _b, _c;
|
||||
if (i.name === "default")
|
||||
i.as = (_c = (_b = (_a = i.from.split("/").pop()) == null ? void 0 : _a.split(".")) == null ? void 0 : _b.shift()) != null ? _c : i.as;
|
||||
});
|
||||
}
|
||||
return imports;
|
||||
}
|
||||
|
||||
// src/core/unplugin.ts
|
||||
var unplugin_default = createUnplugin((options) => {
|
||||
let ctx = createContext(options);
|
||||
return {
|
||||
name: "unplugin-auto-import",
|
||||
enforce: "post",
|
||||
transformInclude(id) {
|
||||
return ctx.filter(id);
|
||||
},
|
||||
async transform(code, id) {
|
||||
return ctx.transform(code, id);
|
||||
},
|
||||
async buildStart() {
|
||||
await ctx.scanDirs();
|
||||
},
|
||||
async buildEnd() {
|
||||
await ctx.writeConfigFiles();
|
||||
},
|
||||
vite: {
|
||||
async handleHotUpdate({ file }) {
|
||||
var _a;
|
||||
if ((_a = ctx.dirs) == null ? void 0 : _a.some((glob) => minimatch(slash2(file), slash2(glob))))
|
||||
await ctx.scanDirs();
|
||||
},
|
||||
async configResolved(config) {
|
||||
if (ctx.root !== config.root) {
|
||||
ctx = createContext(options, config.root);
|
||||
await ctx.scanDirs();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
export {
|
||||
unplugin_default
|
||||
};
|
||||
+624
@@ -0,0 +1,624 @@
|
||||
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __defProp = Object.defineProperty;
|
||||
var __defProps = Object.defineProperties;
|
||||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
||||
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
||||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||
var __spreadValues = (a, b) => {
|
||||
for (var prop in b || (b = {}))
|
||||
if (__hasOwnProp.call(b, prop))
|
||||
__defNormalProp(a, prop, b[prop]);
|
||||
if (__getOwnPropSymbols)
|
||||
for (var prop of __getOwnPropSymbols(b)) {
|
||||
if (__propIsEnum.call(b, prop))
|
||||
__defNormalProp(a, prop, b[prop]);
|
||||
}
|
||||
return a;
|
||||
};
|
||||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
||||
|
||||
// src/presets/index.ts
|
||||
var _unimport = require('unimport');
|
||||
|
||||
// src/presets/ahooks.ts
|
||||
var _fs = require('fs');
|
||||
var _localpkg = require('local-pkg');
|
||||
var _cache;
|
||||
var ahooks_default = () => {
|
||||
if (!_cache) {
|
||||
let indexesJson;
|
||||
try {
|
||||
const path = _localpkg.resolveModule.call(void 0, "ahooks/metadata.json");
|
||||
indexesJson = JSON.parse(_fs.readFileSync.call(void 0, path, "utf-8"));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw new Error("[auto-import] failed to load ahooks, have you installed it?");
|
||||
}
|
||||
if (indexesJson) {
|
||||
_cache = {
|
||||
ahooks: indexesJson.functions.flatMap((i) => [i.name, ...i.alias || []])
|
||||
};
|
||||
}
|
||||
}
|
||||
return _cache || {};
|
||||
};
|
||||
|
||||
// src/presets/mobx.ts
|
||||
var mobx = [
|
||||
// https://mobx.js.org/api.html
|
||||
"makeObservable",
|
||||
"makeAutoObservable",
|
||||
"extendObservable",
|
||||
"observable",
|
||||
"action",
|
||||
"runInAction",
|
||||
"flow",
|
||||
"flowResult",
|
||||
"computed",
|
||||
"autorun",
|
||||
"reaction",
|
||||
"when",
|
||||
"onReactionError",
|
||||
"intercept",
|
||||
"observe",
|
||||
"onBecomeObserved",
|
||||
"onBecomeUnobserved",
|
||||
"toJS"
|
||||
];
|
||||
var mobx_default = {
|
||||
mobx: [
|
||||
// https://mobx.js.org/api.html
|
||||
...mobx
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/mobx-react-lite.ts
|
||||
var mobx_react_lite_default = {
|
||||
// https://mobx.js.org/api.html
|
||||
"mobx-react-lite": [
|
||||
"observer",
|
||||
"Observer",
|
||||
"useLocalObservable"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/preact.ts
|
||||
var preact_default = {
|
||||
"preact/hooks": [
|
||||
"useState",
|
||||
"useCallback",
|
||||
"useMemo",
|
||||
"useEffect",
|
||||
"useRef",
|
||||
"useContext",
|
||||
"useReducer"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/quasar.ts
|
||||
var quasar_default = {
|
||||
quasar: [
|
||||
// https://quasar.dev/vue-composables
|
||||
"useQuasar",
|
||||
"useDialogPluginComponent",
|
||||
"useFormChild",
|
||||
"useMeta"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/react.ts
|
||||
var CommonReactAPI = [
|
||||
"useState",
|
||||
"useCallback",
|
||||
"useMemo",
|
||||
"useEffect",
|
||||
"useRef",
|
||||
"useContext",
|
||||
"useReducer",
|
||||
"useImperativeHandle",
|
||||
"useDebugValue",
|
||||
"useDeferredValue",
|
||||
"useLayoutEffect",
|
||||
"useTransition",
|
||||
"startTransition",
|
||||
"useSyncExternalStore",
|
||||
"useInsertionEffect",
|
||||
"useId",
|
||||
"lazy",
|
||||
"memo",
|
||||
"createRef",
|
||||
"forwardRef"
|
||||
];
|
||||
var react_default = {
|
||||
react: CommonReactAPI
|
||||
};
|
||||
|
||||
// src/presets/react-router.ts
|
||||
var ReactRouterHooks = [
|
||||
"useOutletContext",
|
||||
"useHref",
|
||||
"useInRouterContext",
|
||||
"useLocation",
|
||||
"useNavigationType",
|
||||
"useNavigate",
|
||||
"useOutlet",
|
||||
"useParams",
|
||||
"useResolvedPath",
|
||||
"useRoutes"
|
||||
];
|
||||
var react_router_default = {
|
||||
"react-router": [
|
||||
...ReactRouterHooks
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/react-router-dom.ts
|
||||
var react_router_dom_default = {
|
||||
"react-router-dom": [
|
||||
...ReactRouterHooks,
|
||||
// react-router-dom only hooks
|
||||
"useLinkClickHandler",
|
||||
"useSearchParams",
|
||||
// react-router-dom Component
|
||||
// call once in general
|
||||
// 'BrowserRouter',
|
||||
// 'HashRouter',
|
||||
// 'MemoryRouter',
|
||||
"Link",
|
||||
"NavLink",
|
||||
"Navigate",
|
||||
"Outlet",
|
||||
"Route",
|
||||
"Routes"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/react-i18next.ts
|
||||
var react_i18next_default = {
|
||||
"react-i18next": ["useTranslation"]
|
||||
};
|
||||
|
||||
// src/presets/svelte.ts
|
||||
var svelteAnimate = {
|
||||
"svelte/animate": [
|
||||
"flip"
|
||||
]
|
||||
};
|
||||
var svelteEasing = {
|
||||
"svelte/easing": [
|
||||
"back",
|
||||
"bounce",
|
||||
"circ",
|
||||
"cubic",
|
||||
"elastic",
|
||||
"expo",
|
||||
"quad",
|
||||
"quart",
|
||||
"quint",
|
||||
"sine"
|
||||
].reduce((acc, e) => {
|
||||
acc.push(`${e}In`, `${e}Out`, `${e}InOut`);
|
||||
return acc;
|
||||
}, ["linear"])
|
||||
};
|
||||
var svelteStore = {
|
||||
"svelte/store": [
|
||||
"writable",
|
||||
"readable",
|
||||
"derived",
|
||||
"get"
|
||||
]
|
||||
};
|
||||
var svelteMotion = {
|
||||
"svelte/motion": [
|
||||
"tweened",
|
||||
"spring"
|
||||
]
|
||||
};
|
||||
var svelteTransition = {
|
||||
"svelte/transition": [
|
||||
"fade",
|
||||
"blur",
|
||||
"fly",
|
||||
"slide",
|
||||
"scale",
|
||||
"draw",
|
||||
"crossfade"
|
||||
]
|
||||
};
|
||||
var svelte = {
|
||||
svelte: [
|
||||
// lifecycle
|
||||
"onMount",
|
||||
"beforeUpdate",
|
||||
"afterUpdate",
|
||||
"onDestroy",
|
||||
// tick
|
||||
"tick",
|
||||
// context
|
||||
"setContext",
|
||||
"getContext",
|
||||
"hasContext",
|
||||
"getAllContexts",
|
||||
// event dispatcher
|
||||
"createEventDispatcher"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/vee-validate.ts
|
||||
var vee_validate_default = {
|
||||
"vee-validate": [
|
||||
// https://vee-validate.logaretm.com/v4/guide/composition-api/api-review
|
||||
// https://github.com/logaretm/vee-validate/blob/main/packages/vee-validate/src/index.ts
|
||||
"validate",
|
||||
"defineRule",
|
||||
"configure",
|
||||
"useField",
|
||||
"useForm",
|
||||
"useFieldArray",
|
||||
"useResetForm",
|
||||
"useIsFieldDirty",
|
||||
"useIsFieldTouched",
|
||||
"useIsFieldValid",
|
||||
"useIsSubmitting",
|
||||
"useValidateField",
|
||||
"useIsFormDirty",
|
||||
"useIsFormTouched",
|
||||
"useIsFormValid",
|
||||
"useValidateForm",
|
||||
"useSubmitCount",
|
||||
"useFieldValue",
|
||||
"useFormValues",
|
||||
"useFormErrors",
|
||||
"useFieldError",
|
||||
"useSubmitForm",
|
||||
"FormContextKey",
|
||||
"FieldContextKey"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/vitepress.ts
|
||||
var vitepress_default = {
|
||||
vitepress: [
|
||||
// helper methods
|
||||
"useData",
|
||||
"useRoute",
|
||||
"useRouter",
|
||||
"withBase"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/vue-router.ts
|
||||
var vue_router_default = {
|
||||
"vue-router": [
|
||||
"useRouter",
|
||||
"useRoute",
|
||||
"useLink",
|
||||
"onBeforeRouteLeave",
|
||||
"onBeforeRouteUpdate"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/vue-router-composables.ts
|
||||
var vue_router_composables_default = {
|
||||
"vue-router/composables": [
|
||||
"useRouter",
|
||||
"useRoute",
|
||||
"useLink",
|
||||
"onBeforeRouteLeave",
|
||||
"onBeforeRouteUpdate"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/vueuse-core.ts
|
||||
|
||||
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
||||
|
||||
var _cache2;
|
||||
var vueuse_core_default = () => {
|
||||
const excluded = ["toRefs", "utils", "toRef", "toValue"];
|
||||
if (!_cache2) {
|
||||
let indexesJson;
|
||||
try {
|
||||
const corePath = _localpkg.resolveModule.call(void 0, "@vueuse/core") || _process2.default.cwd();
|
||||
const path = _localpkg.resolveModule.call(void 0, "@vueuse/core/indexes.json") || _localpkg.resolveModule.call(void 0, "@vueuse/metadata/index.json") || _localpkg.resolveModule.call(void 0, "@vueuse/metadata/index.json", { paths: [corePath] });
|
||||
indexesJson = JSON.parse(_fs.readFileSync.call(void 0, path, "utf-8"));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw new Error("[auto-import] failed to load @vueuse/core, have you installed it?");
|
||||
}
|
||||
if (indexesJson) {
|
||||
_cache2 = {
|
||||
"@vueuse/core": indexesJson.functions.filter((i) => ["core", "shared"].includes(i.package)).flatMap((i) => [i.name, ...i.alias || []]).filter((i) => i && i.length >= 4 && !excluded.includes(i))
|
||||
};
|
||||
}
|
||||
}
|
||||
return _cache2 || {};
|
||||
};
|
||||
|
||||
// src/presets/vueuse-head.ts
|
||||
var vueuse_head_default = {
|
||||
"@vueuse/head": [
|
||||
"useHead",
|
||||
"useSeoMeta"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/vuex.ts
|
||||
var vuex_default = {
|
||||
vuex: [
|
||||
// https://next.vuex.vuejs.org/api/#createstore
|
||||
"createStore",
|
||||
// https://github.com/vuejs/vuex/blob/4.0/types/logger.d.ts#L20
|
||||
"createLogger",
|
||||
// https://next.vuex.vuejs.org/api/#component-binding-helpers
|
||||
"mapState",
|
||||
"mapGetters",
|
||||
"mapActions",
|
||||
"mapMutations",
|
||||
"createNamespacedHelpers",
|
||||
// https://next.vuex.vuejs.org/api/#composable-functions
|
||||
"useStore"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/uni-app.ts
|
||||
var uni_app_default = {
|
||||
"@dcloudio/uni-app": [
|
||||
"onAddToFavorites",
|
||||
"onBackPress",
|
||||
"onError",
|
||||
"onHide",
|
||||
"onLaunch",
|
||||
"onLoad",
|
||||
"onNavigationBarButtonTap",
|
||||
"onNavigationBarSearchInputChanged",
|
||||
"onNavigationBarSearchInputClicked",
|
||||
"onNavigationBarSearchInputConfirmed",
|
||||
"onNavigationBarSearchInputFocusChanged",
|
||||
"onPageNotFound",
|
||||
"onPageScroll",
|
||||
"onPullDownRefresh",
|
||||
"onReachBottom",
|
||||
"onReady",
|
||||
"onResize",
|
||||
"onShareAppMessage",
|
||||
"onShareTimeline",
|
||||
"onShow",
|
||||
"onTabItemTap",
|
||||
"onThemeChange",
|
||||
"onUnhandledRejection",
|
||||
"onUnload"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/solid.ts
|
||||
var solidCore = {
|
||||
"solid-js": [
|
||||
"createSignal",
|
||||
"createEffect",
|
||||
"createMemo",
|
||||
"createResource",
|
||||
"onMount",
|
||||
"onCleanup",
|
||||
"onError",
|
||||
"untrack",
|
||||
"batch",
|
||||
"on",
|
||||
"createRoot",
|
||||
"mergeProps",
|
||||
"splitProps",
|
||||
"useTransition",
|
||||
"observable",
|
||||
"mapArray",
|
||||
"indexArray",
|
||||
"createContext",
|
||||
"useContext",
|
||||
"children",
|
||||
"lazy",
|
||||
"createDeferred",
|
||||
"createRenderEffect",
|
||||
"createSelector",
|
||||
"For",
|
||||
"Show",
|
||||
"Switch",
|
||||
"Match",
|
||||
"Index",
|
||||
"ErrorBoundary",
|
||||
"Suspense",
|
||||
"SuspenseList"
|
||||
]
|
||||
};
|
||||
var solidStore = {
|
||||
"solid-js/store": [
|
||||
"createStore",
|
||||
"produce",
|
||||
"reconcile",
|
||||
"createMutable"
|
||||
]
|
||||
};
|
||||
var solidWeb = {
|
||||
"solid-js/web": [
|
||||
"Dynamic",
|
||||
"hydrate",
|
||||
"render",
|
||||
"renderToString",
|
||||
"renderToStringAsync",
|
||||
"renderToStream",
|
||||
"isServer",
|
||||
"Portal"
|
||||
]
|
||||
};
|
||||
var solid_default = __spreadValues(__spreadValues(__spreadValues({}, solidCore), solidStore), solidWeb);
|
||||
|
||||
// src/presets/solid-router.ts
|
||||
var solid_router_default = {
|
||||
"@solidjs/router": [
|
||||
"Link",
|
||||
"NavLink",
|
||||
"Navigate",
|
||||
"Outlet",
|
||||
"Route",
|
||||
"Router",
|
||||
"Routes",
|
||||
"_mergeSearchString",
|
||||
"createIntegration",
|
||||
"hashIntegration",
|
||||
"normalizeIntegration",
|
||||
"pathIntegration",
|
||||
"staticIntegration",
|
||||
"useHref",
|
||||
"useIsRouting",
|
||||
"useLocation",
|
||||
"useMatch",
|
||||
"useNavigate",
|
||||
"useParams",
|
||||
"useResolvedPath",
|
||||
"useRouteData",
|
||||
"useRoutes",
|
||||
"useSearchParams"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/solid-app-router.ts
|
||||
var solid_app_router_default = {
|
||||
"solid-app-router": [
|
||||
"Link",
|
||||
"NavLink",
|
||||
"Navigate",
|
||||
"Outlet",
|
||||
"Route",
|
||||
"Router",
|
||||
"Routes",
|
||||
"_mergeSearchString",
|
||||
"createIntegration",
|
||||
"hashIntegration",
|
||||
"normalizeIntegration",
|
||||
"pathIntegration",
|
||||
"staticIntegration",
|
||||
"useHref",
|
||||
"useIsRouting",
|
||||
"useLocation",
|
||||
"useMatch",
|
||||
"useNavigate",
|
||||
"useParams",
|
||||
"useResolvedPath",
|
||||
"useRouteData",
|
||||
"useRoutes",
|
||||
"useSearchParams"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/jotai.ts
|
||||
var jotai = {
|
||||
jotai: [
|
||||
"atom",
|
||||
"useAtom",
|
||||
"useAtomValue",
|
||||
"useSetAtom"
|
||||
]
|
||||
};
|
||||
var jotaiUtils = {
|
||||
"jotai/utils": [
|
||||
"atomWithReset",
|
||||
"useResetAtom",
|
||||
"useReducerAtom",
|
||||
"atomWithReducer",
|
||||
"atomFamily",
|
||||
"selectAtom",
|
||||
"useAtomCallback",
|
||||
"freezeAtom",
|
||||
"freezeAtomCreator",
|
||||
"splitAtom",
|
||||
"atomWithDefault",
|
||||
"waitForAll",
|
||||
"atomWithStorage",
|
||||
"atomWithHash",
|
||||
"createJSONStorage",
|
||||
"atomWithObservable",
|
||||
"useHydrateAtoms",
|
||||
"loadable"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/vueuse-math.ts
|
||||
|
||||
|
||||
|
||||
var _cache3;
|
||||
var vueuse_math_default = () => {
|
||||
if (!_cache3) {
|
||||
let indexesJson;
|
||||
try {
|
||||
const corePath = _localpkg.resolveModule.call(void 0, "@vueuse/core") || _process2.default.cwd();
|
||||
const path = _localpkg.resolveModule.call(void 0, "@vueuse/metadata/index.json") || _localpkg.resolveModule.call(void 0, "@vueuse/metadata/index.json", { paths: [corePath] });
|
||||
indexesJson = JSON.parse(_fs.readFileSync.call(void 0, path, "utf-8"));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw new Error("[auto-import] failed to load @vueuse/math, have you installed it?");
|
||||
}
|
||||
if (indexesJson) {
|
||||
_cache3 = {
|
||||
"@vueuse/math": indexesJson.functions.filter((i) => ["math"].includes(i.package)).flatMap((i) => [i.name, ...i.alias || []]).filter((i) => i && i.length >= 4)
|
||||
};
|
||||
}
|
||||
}
|
||||
return _cache3 || {};
|
||||
};
|
||||
|
||||
// src/presets/recoil.ts
|
||||
var recoil_default = {
|
||||
// https://recoiljs.org/docs/api-reference/core/atom/
|
||||
recoil: [
|
||||
"atom",
|
||||
"selector",
|
||||
"useRecoilState",
|
||||
"useRecoilValue",
|
||||
"useSetRecoilState",
|
||||
"useResetRecoilState",
|
||||
"useRecoilStateLoadable",
|
||||
"useRecoilValueLoadable",
|
||||
"isRecoilValue",
|
||||
"useRecoilCallback"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/index.ts
|
||||
var presets = __spreadProps(__spreadValues({}, _unimport.builtinPresets), {
|
||||
"ahooks": ahooks_default,
|
||||
"@vueuse/core": vueuse_core_default,
|
||||
"@vueuse/math": vueuse_math_default,
|
||||
"@vueuse/head": vueuse_head_default,
|
||||
"mobx": mobx_default,
|
||||
"mobx-react-lite": mobx_react_lite_default,
|
||||
"preact": preact_default,
|
||||
"quasar": quasar_default,
|
||||
"react": react_default,
|
||||
"react-router": react_router_default,
|
||||
"react-router-dom": react_router_dom_default,
|
||||
"react-i18next": react_i18next_default,
|
||||
"svelte": svelte,
|
||||
"svelte/animate": svelteAnimate,
|
||||
"svelte/easing": svelteEasing,
|
||||
"svelte/motion": svelteMotion,
|
||||
"svelte/store": svelteStore,
|
||||
"svelte/transition": svelteTransition,
|
||||
"vee-validate": vee_validate_default,
|
||||
"vitepress": vitepress_default,
|
||||
"vue-router": vue_router_default,
|
||||
"vue-router/composables": vue_router_composables_default,
|
||||
"vuex": vuex_default,
|
||||
"uni-app": uni_app_default,
|
||||
"solid-js": solid_default,
|
||||
"@solidjs/router": solid_router_default,
|
||||
"solid-app-router": solid_app_router_default,
|
||||
"jotai": jotai,
|
||||
"jotai/utils": jotaiUtils,
|
||||
"recoil": recoil_default
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
exports.__spreadValues = __spreadValues; exports.presets = presets;
|
||||
+361
@@ -0,0 +1,361 @@
|
||||
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
|
||||
var _chunk6UOGCAOYcjs = require('./chunk-6UOGCAOY.cjs');
|
||||
|
||||
// src/core/unplugin.ts
|
||||
var _minimatch = require('minimatch');
|
||||
var _utils = require('@antfu/utils');
|
||||
var _unplugin = require('unplugin');
|
||||
|
||||
// src/core/ctx.ts
|
||||
var _path = require('path');
|
||||
var _fs = require('fs');
|
||||
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
||||
|
||||
var _pluginutils = require('@rollup/pluginutils');
|
||||
var _localpkg = require('local-pkg');
|
||||
var _unimport = require('unimport');
|
||||
var _fastglob = require('fast-glob'); var _fastglob2 = _interopRequireDefault(_fastglob);
|
||||
var _addons = require('unimport/addons');
|
||||
var _magicstring = require('magic-string'); var _magicstring2 = _interopRequireDefault(_magicstring);
|
||||
|
||||
// src/core/eslintrc.ts
|
||||
function generateESLintConfigs(imports, eslintrc, globals = {}) {
|
||||
const eslintConfigs = { globals };
|
||||
imports.map((i) => {
|
||||
var _a;
|
||||
return (_a = i.as) != null ? _a : i.name;
|
||||
}).filter(Boolean).sort().forEach((name) => {
|
||||
eslintConfigs.globals[name] = eslintrc.globalsPropValue;
|
||||
});
|
||||
const jsonBody = JSON.stringify(eslintConfigs, null, 2);
|
||||
return jsonBody;
|
||||
}
|
||||
|
||||
// src/core/resolvers.ts
|
||||
|
||||
function normalizeImport(info, name) {
|
||||
if (typeof info === "string") {
|
||||
return {
|
||||
name: "default",
|
||||
as: name,
|
||||
from: info
|
||||
};
|
||||
}
|
||||
if ("path" in info) {
|
||||
return {
|
||||
from: info.path,
|
||||
as: info.name,
|
||||
name: info.importName,
|
||||
sideEffects: info.sideEffects
|
||||
};
|
||||
}
|
||||
return _chunk6UOGCAOYcjs.__spreadValues.call(void 0, {
|
||||
name,
|
||||
as: name
|
||||
}, info);
|
||||
}
|
||||
async function firstMatchedResolver(resolvers, fullname) {
|
||||
let name = fullname;
|
||||
for (const resolver of resolvers) {
|
||||
if (typeof resolver === "object" && resolver.type === "directive") {
|
||||
if (name.startsWith("v"))
|
||||
name = name.slice(1);
|
||||
else
|
||||
continue;
|
||||
}
|
||||
const resolved = await (typeof resolver === "function" ? resolver(name) : resolver.resolve(name));
|
||||
if (resolved)
|
||||
return normalizeImport(resolved, fullname);
|
||||
}
|
||||
}
|
||||
function resolversAddon(resolvers) {
|
||||
return {
|
||||
async matchImports(names, matched) {
|
||||
if (!resolvers.length)
|
||||
return;
|
||||
const dynamic = [];
|
||||
const sideEffects = [];
|
||||
await Promise.all([...names].map(async (name) => {
|
||||
const matchedImport = matched.find((i) => i.as === name);
|
||||
if (matchedImport) {
|
||||
if ("sideEffects" in matchedImport)
|
||||
sideEffects.push(..._utils.toArray.call(void 0, matchedImport.sideEffects).map((i) => normalizeImport(i, "")));
|
||||
return;
|
||||
}
|
||||
const resolved = await firstMatchedResolver(resolvers, name);
|
||||
if (resolved)
|
||||
dynamic.push(resolved);
|
||||
if (resolved == null ? void 0 : resolved.sideEffects)
|
||||
sideEffects.push(..._utils.toArray.call(void 0, resolved == null ? void 0 : resolved.sideEffects).map((i) => normalizeImport(i, "")));
|
||||
}));
|
||||
if (dynamic.length) {
|
||||
this.dynamicImports.push(...dynamic);
|
||||
this.invalidate();
|
||||
}
|
||||
if (dynamic.length || sideEffects.length)
|
||||
return [...matched, ...dynamic, ...sideEffects];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// src/core/ctx.ts
|
||||
function resolveGlobsExclude(root, glob) {
|
||||
const excludeReg = /^!/;
|
||||
return `${excludeReg.test(glob) ? "!" : ""}${_path.resolve.call(void 0, root, glob.replace(excludeReg, ""))}`;
|
||||
}
|
||||
async function scanDirExports(dirs, root) {
|
||||
const result = await _fastglob2.default.call(void 0, dirs, {
|
||||
absolute: true,
|
||||
cwd: root,
|
||||
onlyFiles: true,
|
||||
followSymbolicLinks: true
|
||||
});
|
||||
const files = Array.from(new Set(result.flat())).map(_utils.slash);
|
||||
return (await Promise.all(files.map((i) => _unimport.scanExports.call(void 0, i, false)))).flat();
|
||||
}
|
||||
function createContext(options = {}, root = _process2.default.cwd()) {
|
||||
var _a;
|
||||
const {
|
||||
dts: preferDTS = _localpkg.isPackageExists.call(void 0, "typescript")
|
||||
} = options;
|
||||
const dirs = (_a = options.dirs) == null ? void 0 : _a.concat(options.dirs.map((dir) => _path.join.call(void 0, dir, "*.{tsx,jsx,ts,js,mjs,cjs,mts,cts}"))).map((dir) => _utils.slash.call(void 0, resolveGlobsExclude(root, dir)));
|
||||
const eslintrc = options.eslintrc || {};
|
||||
eslintrc.enabled = eslintrc.enabled === void 0 ? false : eslintrc.enabled;
|
||||
eslintrc.filepath = eslintrc.filepath || "./.eslintrc-auto-import.json";
|
||||
eslintrc.globalsPropValue = eslintrc.globalsPropValue === void 0 ? true : eslintrc.globalsPropValue;
|
||||
const resolvers = options.resolvers ? [options.resolvers].flat(2) : [];
|
||||
const injectAtEnd = options.injectAtEnd !== false;
|
||||
const unimport = _unimport.createUnimport.call(void 0, {
|
||||
imports: [],
|
||||
presets: [],
|
||||
injectAtEnd,
|
||||
addons: [
|
||||
...options.vueTemplate ? [_addons.vueTemplateAddon.call(void 0, )] : [],
|
||||
resolversAddon(resolvers),
|
||||
{
|
||||
declaration(dts2) {
|
||||
return `${`
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
// @ts-nocheck
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
// Generated by unplugin-auto-import
|
||||
${dts2}`.trim()}
|
||||
`;
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
const importsPromise = flattenImports(options.imports).then((imports) => {
|
||||
var _a2;
|
||||
if (!imports.length && !resolvers.length && !(dirs == null ? void 0 : dirs.length))
|
||||
console.warn("[auto-import] plugin installed but no imports has defined, see https://github.com/antfu/unplugin-auto-import#configurations for configurations");
|
||||
(_a2 = options.ignore) == null ? void 0 : _a2.forEach((name) => {
|
||||
const i = imports.find((i2) => i2.as === name);
|
||||
if (i)
|
||||
i.disabled = true;
|
||||
});
|
||||
return unimport.getInternalContext().replaceImports(imports);
|
||||
});
|
||||
const filter = _pluginutils.createFilter.call(void 0,
|
||||
options.include || [/\.[jt]sx?$/, /\.vue$/, /\.vue\?vue/, /\.svelte$/],
|
||||
options.exclude || [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/]
|
||||
);
|
||||
const dts = preferDTS === false ? false : preferDTS === true ? _path.resolve.call(void 0, root, "auto-imports.d.ts") : _path.resolve.call(void 0, root, preferDTS);
|
||||
const multilineCommentsRE = new RegExp("\\/\\*.*?\\*\\/", "gms");
|
||||
const singlelineCommentsRE = /\/\/.*$/gm;
|
||||
const dtsReg = new RegExp("declare\\s+global\\s*{(.*?)[\\n\\r]}", "s");
|
||||
function parseDTS(dts2) {
|
||||
var _a2;
|
||||
dts2 = dts2.replace(multilineCommentsRE, "").replace(singlelineCommentsRE, "");
|
||||
const code = (_a2 = dts2.match(dtsReg)) == null ? void 0 : _a2[0];
|
||||
if (!code)
|
||||
return;
|
||||
return Object.fromEntries(Array.from(code.matchAll(/['"]?(const\s*[^\s'"]+)['"]?\s*:\s*(.+?)[,;\r\n]/g)).map((i) => [i[1], i[2]]));
|
||||
}
|
||||
async function generateDTS(file) {
|
||||
await importsPromise;
|
||||
const dir = _path.dirname.call(void 0, file);
|
||||
const originalContent = _fs.existsSync.call(void 0, file) ? await _fs.promises.readFile(file, "utf-8") : "";
|
||||
const originalDTS = parseDTS(originalContent);
|
||||
const currentContent = await unimport.generateTypeDeclarations({
|
||||
resolvePath: (i) => {
|
||||
if (i.from.startsWith(".") || _path.isAbsolute.call(void 0, i.from)) {
|
||||
const related = _utils.slash.call(void 0, _path.relative.call(void 0, dir, i.from).replace(/\.ts(x)?$/, ""));
|
||||
return !related.startsWith(".") ? `./${related}` : related;
|
||||
}
|
||||
return i.from;
|
||||
}
|
||||
});
|
||||
const currentDTS = parseDTS(currentContent);
|
||||
if (originalDTS) {
|
||||
Object.keys(currentDTS).forEach((key) => {
|
||||
originalDTS[key] = currentDTS[key];
|
||||
});
|
||||
const dtsList = Object.keys(originalDTS).sort().map((k) => ` ${k}: ${originalDTS[k]}`);
|
||||
return currentContent.replace(dtsReg, () => `declare global {
|
||||
${dtsList.join("\n")}
|
||||
}`);
|
||||
}
|
||||
return currentContent;
|
||||
}
|
||||
async function parseESLint() {
|
||||
const configStr = _fs.existsSync.call(void 0, eslintrc.filepath) ? await _fs.promises.readFile(eslintrc.filepath, "utf-8") : "";
|
||||
const config = JSON.parse(configStr || '{ "globals": {} }');
|
||||
return config.globals;
|
||||
}
|
||||
async function generateESLint() {
|
||||
return generateESLintConfigs(await unimport.getImports(), eslintrc, await parseESLint());
|
||||
}
|
||||
const writeConfigFilesThrottled = _utils.throttle.call(void 0, 500, writeConfigFiles, { noLeading: false });
|
||||
async function writeFile(filePath, content = "") {
|
||||
await _fs.promises.mkdir(_path.dirname.call(void 0, filePath), { recursive: true });
|
||||
return await _fs.promises.writeFile(filePath, content, "utf-8");
|
||||
}
|
||||
let lastDTS;
|
||||
let lastESLint;
|
||||
async function writeConfigFiles() {
|
||||
const promises = [];
|
||||
if (dts) {
|
||||
promises.push(
|
||||
generateDTS(dts).then((content) => {
|
||||
if (content !== lastDTS) {
|
||||
lastDTS = content;
|
||||
return writeFile(dts, content);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
if (eslintrc.enabled && eslintrc.filepath) {
|
||||
promises.push(
|
||||
generateESLint().then((content) => {
|
||||
content = `${content}
|
||||
`;
|
||||
if (content.trim() !== (lastESLint == null ? void 0 : lastESLint.trim())) {
|
||||
lastESLint = content;
|
||||
return writeFile(eslintrc.filepath, content);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
return Promise.all(promises);
|
||||
}
|
||||
async function scanDirs() {
|
||||
if (dirs == null ? void 0 : dirs.length) {
|
||||
await unimport.modifyDynamicImports(async (imports) => {
|
||||
const exports_ = await scanDirExports(dirs, root);
|
||||
exports_.forEach((i) => i.__source = "dir");
|
||||
return modifyDefaultExportsAlias([
|
||||
...imports.filter((i) => i.__source !== "dir"),
|
||||
...exports_
|
||||
], options);
|
||||
});
|
||||
}
|
||||
writeConfigFilesThrottled();
|
||||
}
|
||||
async function transform(code, id) {
|
||||
await importsPromise;
|
||||
const s = new (0, _magicstring2.default)(code);
|
||||
await unimport.injectImports(s, id);
|
||||
if (!s.hasChanged())
|
||||
return;
|
||||
writeConfigFilesThrottled();
|
||||
return {
|
||||
code: s.toString(),
|
||||
map: s.generateMap({ source: id, includeContent: true, hires: true })
|
||||
};
|
||||
}
|
||||
return {
|
||||
root,
|
||||
dirs,
|
||||
filter,
|
||||
scanDirs,
|
||||
writeConfigFiles,
|
||||
writeConfigFilesThrottled,
|
||||
transform,
|
||||
generateDTS,
|
||||
generateESLint
|
||||
};
|
||||
}
|
||||
async function flattenImports(map) {
|
||||
const promises = await Promise.all(_utils.toArray.call(void 0, map).map(async (definition) => {
|
||||
if (typeof definition === "string") {
|
||||
if (!_chunk6UOGCAOYcjs.presets[definition])
|
||||
throw new Error(`[auto-import] preset ${definition} not found`);
|
||||
const preset = _chunk6UOGCAOYcjs.presets[definition];
|
||||
definition = typeof preset === "function" ? preset() : preset;
|
||||
}
|
||||
if ("from" in definition && "imports" in definition) {
|
||||
return await _unimport.resolvePreset.call(void 0, definition);
|
||||
} else {
|
||||
const resolved = [];
|
||||
for (const mod of Object.keys(definition)) {
|
||||
for (const id of definition[mod]) {
|
||||
const meta = {
|
||||
from: mod
|
||||
};
|
||||
if (Array.isArray(id)) {
|
||||
meta.name = id[0];
|
||||
meta.as = id[1];
|
||||
} else {
|
||||
meta.name = id;
|
||||
meta.as = id;
|
||||
}
|
||||
resolved.push(meta);
|
||||
}
|
||||
}
|
||||
return resolved;
|
||||
}
|
||||
}));
|
||||
return promises.flat();
|
||||
}
|
||||
function modifyDefaultExportsAlias(imports, options) {
|
||||
if (options.defaultExportByFilename) {
|
||||
imports.forEach((i) => {
|
||||
var _a, _b, _c;
|
||||
if (i.name === "default")
|
||||
i.as = (_c = (_b = (_a = i.from.split("/").pop()) == null ? void 0 : _a.split(".")) == null ? void 0 : _b.shift()) != null ? _c : i.as;
|
||||
});
|
||||
}
|
||||
return imports;
|
||||
}
|
||||
|
||||
// src/core/unplugin.ts
|
||||
var unplugin_default = _unplugin.createUnplugin.call(void 0, (options) => {
|
||||
let ctx = createContext(options);
|
||||
return {
|
||||
name: "unplugin-auto-import",
|
||||
enforce: "post",
|
||||
transformInclude(id) {
|
||||
return ctx.filter(id);
|
||||
},
|
||||
async transform(code, id) {
|
||||
return ctx.transform(code, id);
|
||||
},
|
||||
async buildStart() {
|
||||
await ctx.scanDirs();
|
||||
},
|
||||
async buildEnd() {
|
||||
await ctx.writeConfigFiles();
|
||||
},
|
||||
vite: {
|
||||
async handleHotUpdate({ file }) {
|
||||
var _a;
|
||||
if ((_a = ctx.dirs) == null ? void 0 : _a.some((glob) => _minimatch.minimatch.call(void 0, _utils.slash.call(void 0, file), _utils.slash.call(void 0, glob))))
|
||||
await ctx.scanDirs();
|
||||
},
|
||||
async configResolved(config) {
|
||||
if (ctx.root !== config.root) {
|
||||
ctx = createContext(options, config.root);
|
||||
await ctx.scanDirs();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
|
||||
exports.unplugin_default = unplugin_default;
|
||||
+624
@@ -0,0 +1,624 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __defProps = Object.defineProperties;
|
||||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
||||
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
||||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||
var __spreadValues = (a, b) => {
|
||||
for (var prop in b || (b = {}))
|
||||
if (__hasOwnProp.call(b, prop))
|
||||
__defNormalProp(a, prop, b[prop]);
|
||||
if (__getOwnPropSymbols)
|
||||
for (var prop of __getOwnPropSymbols(b)) {
|
||||
if (__propIsEnum.call(b, prop))
|
||||
__defNormalProp(a, prop, b[prop]);
|
||||
}
|
||||
return a;
|
||||
};
|
||||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
||||
|
||||
// src/presets/index.ts
|
||||
import { builtinPresets } from "unimport";
|
||||
|
||||
// src/presets/ahooks.ts
|
||||
import { readFileSync } from "fs";
|
||||
import { resolveModule } from "local-pkg";
|
||||
var _cache;
|
||||
var ahooks_default = () => {
|
||||
if (!_cache) {
|
||||
let indexesJson;
|
||||
try {
|
||||
const path = resolveModule("ahooks/metadata.json");
|
||||
indexesJson = JSON.parse(readFileSync(path, "utf-8"));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw new Error("[auto-import] failed to load ahooks, have you installed it?");
|
||||
}
|
||||
if (indexesJson) {
|
||||
_cache = {
|
||||
ahooks: indexesJson.functions.flatMap((i) => [i.name, ...i.alias || []])
|
||||
};
|
||||
}
|
||||
}
|
||||
return _cache || {};
|
||||
};
|
||||
|
||||
// src/presets/mobx.ts
|
||||
var mobx = [
|
||||
// https://mobx.js.org/api.html
|
||||
"makeObservable",
|
||||
"makeAutoObservable",
|
||||
"extendObservable",
|
||||
"observable",
|
||||
"action",
|
||||
"runInAction",
|
||||
"flow",
|
||||
"flowResult",
|
||||
"computed",
|
||||
"autorun",
|
||||
"reaction",
|
||||
"when",
|
||||
"onReactionError",
|
||||
"intercept",
|
||||
"observe",
|
||||
"onBecomeObserved",
|
||||
"onBecomeUnobserved",
|
||||
"toJS"
|
||||
];
|
||||
var mobx_default = {
|
||||
mobx: [
|
||||
// https://mobx.js.org/api.html
|
||||
...mobx
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/mobx-react-lite.ts
|
||||
var mobx_react_lite_default = {
|
||||
// https://mobx.js.org/api.html
|
||||
"mobx-react-lite": [
|
||||
"observer",
|
||||
"Observer",
|
||||
"useLocalObservable"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/preact.ts
|
||||
var preact_default = {
|
||||
"preact/hooks": [
|
||||
"useState",
|
||||
"useCallback",
|
||||
"useMemo",
|
||||
"useEffect",
|
||||
"useRef",
|
||||
"useContext",
|
||||
"useReducer"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/quasar.ts
|
||||
var quasar_default = {
|
||||
quasar: [
|
||||
// https://quasar.dev/vue-composables
|
||||
"useQuasar",
|
||||
"useDialogPluginComponent",
|
||||
"useFormChild",
|
||||
"useMeta"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/react.ts
|
||||
var CommonReactAPI = [
|
||||
"useState",
|
||||
"useCallback",
|
||||
"useMemo",
|
||||
"useEffect",
|
||||
"useRef",
|
||||
"useContext",
|
||||
"useReducer",
|
||||
"useImperativeHandle",
|
||||
"useDebugValue",
|
||||
"useDeferredValue",
|
||||
"useLayoutEffect",
|
||||
"useTransition",
|
||||
"startTransition",
|
||||
"useSyncExternalStore",
|
||||
"useInsertionEffect",
|
||||
"useId",
|
||||
"lazy",
|
||||
"memo",
|
||||
"createRef",
|
||||
"forwardRef"
|
||||
];
|
||||
var react_default = {
|
||||
react: CommonReactAPI
|
||||
};
|
||||
|
||||
// src/presets/react-router.ts
|
||||
var ReactRouterHooks = [
|
||||
"useOutletContext",
|
||||
"useHref",
|
||||
"useInRouterContext",
|
||||
"useLocation",
|
||||
"useNavigationType",
|
||||
"useNavigate",
|
||||
"useOutlet",
|
||||
"useParams",
|
||||
"useResolvedPath",
|
||||
"useRoutes"
|
||||
];
|
||||
var react_router_default = {
|
||||
"react-router": [
|
||||
...ReactRouterHooks
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/react-router-dom.ts
|
||||
var react_router_dom_default = {
|
||||
"react-router-dom": [
|
||||
...ReactRouterHooks,
|
||||
// react-router-dom only hooks
|
||||
"useLinkClickHandler",
|
||||
"useSearchParams",
|
||||
// react-router-dom Component
|
||||
// call once in general
|
||||
// 'BrowserRouter',
|
||||
// 'HashRouter',
|
||||
// 'MemoryRouter',
|
||||
"Link",
|
||||
"NavLink",
|
||||
"Navigate",
|
||||
"Outlet",
|
||||
"Route",
|
||||
"Routes"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/react-i18next.ts
|
||||
var react_i18next_default = {
|
||||
"react-i18next": ["useTranslation"]
|
||||
};
|
||||
|
||||
// src/presets/svelte.ts
|
||||
var svelteAnimate = {
|
||||
"svelte/animate": [
|
||||
"flip"
|
||||
]
|
||||
};
|
||||
var svelteEasing = {
|
||||
"svelte/easing": [
|
||||
"back",
|
||||
"bounce",
|
||||
"circ",
|
||||
"cubic",
|
||||
"elastic",
|
||||
"expo",
|
||||
"quad",
|
||||
"quart",
|
||||
"quint",
|
||||
"sine"
|
||||
].reduce((acc, e) => {
|
||||
acc.push(`${e}In`, `${e}Out`, `${e}InOut`);
|
||||
return acc;
|
||||
}, ["linear"])
|
||||
};
|
||||
var svelteStore = {
|
||||
"svelte/store": [
|
||||
"writable",
|
||||
"readable",
|
||||
"derived",
|
||||
"get"
|
||||
]
|
||||
};
|
||||
var svelteMotion = {
|
||||
"svelte/motion": [
|
||||
"tweened",
|
||||
"spring"
|
||||
]
|
||||
};
|
||||
var svelteTransition = {
|
||||
"svelte/transition": [
|
||||
"fade",
|
||||
"blur",
|
||||
"fly",
|
||||
"slide",
|
||||
"scale",
|
||||
"draw",
|
||||
"crossfade"
|
||||
]
|
||||
};
|
||||
var svelte = {
|
||||
svelte: [
|
||||
// lifecycle
|
||||
"onMount",
|
||||
"beforeUpdate",
|
||||
"afterUpdate",
|
||||
"onDestroy",
|
||||
// tick
|
||||
"tick",
|
||||
// context
|
||||
"setContext",
|
||||
"getContext",
|
||||
"hasContext",
|
||||
"getAllContexts",
|
||||
// event dispatcher
|
||||
"createEventDispatcher"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/vee-validate.ts
|
||||
var vee_validate_default = {
|
||||
"vee-validate": [
|
||||
// https://vee-validate.logaretm.com/v4/guide/composition-api/api-review
|
||||
// https://github.com/logaretm/vee-validate/blob/main/packages/vee-validate/src/index.ts
|
||||
"validate",
|
||||
"defineRule",
|
||||
"configure",
|
||||
"useField",
|
||||
"useForm",
|
||||
"useFieldArray",
|
||||
"useResetForm",
|
||||
"useIsFieldDirty",
|
||||
"useIsFieldTouched",
|
||||
"useIsFieldValid",
|
||||
"useIsSubmitting",
|
||||
"useValidateField",
|
||||
"useIsFormDirty",
|
||||
"useIsFormTouched",
|
||||
"useIsFormValid",
|
||||
"useValidateForm",
|
||||
"useSubmitCount",
|
||||
"useFieldValue",
|
||||
"useFormValues",
|
||||
"useFormErrors",
|
||||
"useFieldError",
|
||||
"useSubmitForm",
|
||||
"FormContextKey",
|
||||
"FieldContextKey"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/vitepress.ts
|
||||
var vitepress_default = {
|
||||
vitepress: [
|
||||
// helper methods
|
||||
"useData",
|
||||
"useRoute",
|
||||
"useRouter",
|
||||
"withBase"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/vue-router.ts
|
||||
var vue_router_default = {
|
||||
"vue-router": [
|
||||
"useRouter",
|
||||
"useRoute",
|
||||
"useLink",
|
||||
"onBeforeRouteLeave",
|
||||
"onBeforeRouteUpdate"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/vue-router-composables.ts
|
||||
var vue_router_composables_default = {
|
||||
"vue-router/composables": [
|
||||
"useRouter",
|
||||
"useRoute",
|
||||
"useLink",
|
||||
"onBeforeRouteLeave",
|
||||
"onBeforeRouteUpdate"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/vueuse-core.ts
|
||||
import { readFileSync as readFileSync2 } from "fs";
|
||||
import process from "process";
|
||||
import { resolveModule as resolveModule2 } from "local-pkg";
|
||||
var _cache2;
|
||||
var vueuse_core_default = () => {
|
||||
const excluded = ["toRefs", "utils", "toRef", "toValue"];
|
||||
if (!_cache2) {
|
||||
let indexesJson;
|
||||
try {
|
||||
const corePath = resolveModule2("@vueuse/core") || process.cwd();
|
||||
const path = resolveModule2("@vueuse/core/indexes.json") || resolveModule2("@vueuse/metadata/index.json") || resolveModule2("@vueuse/metadata/index.json", { paths: [corePath] });
|
||||
indexesJson = JSON.parse(readFileSync2(path, "utf-8"));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw new Error("[auto-import] failed to load @vueuse/core, have you installed it?");
|
||||
}
|
||||
if (indexesJson) {
|
||||
_cache2 = {
|
||||
"@vueuse/core": indexesJson.functions.filter((i) => ["core", "shared"].includes(i.package)).flatMap((i) => [i.name, ...i.alias || []]).filter((i) => i && i.length >= 4 && !excluded.includes(i))
|
||||
};
|
||||
}
|
||||
}
|
||||
return _cache2 || {};
|
||||
};
|
||||
|
||||
// src/presets/vueuse-head.ts
|
||||
var vueuse_head_default = {
|
||||
"@vueuse/head": [
|
||||
"useHead",
|
||||
"useSeoMeta"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/vuex.ts
|
||||
var vuex_default = {
|
||||
vuex: [
|
||||
// https://next.vuex.vuejs.org/api/#createstore
|
||||
"createStore",
|
||||
// https://github.com/vuejs/vuex/blob/4.0/types/logger.d.ts#L20
|
||||
"createLogger",
|
||||
// https://next.vuex.vuejs.org/api/#component-binding-helpers
|
||||
"mapState",
|
||||
"mapGetters",
|
||||
"mapActions",
|
||||
"mapMutations",
|
||||
"createNamespacedHelpers",
|
||||
// https://next.vuex.vuejs.org/api/#composable-functions
|
||||
"useStore"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/uni-app.ts
|
||||
var uni_app_default = {
|
||||
"@dcloudio/uni-app": [
|
||||
"onAddToFavorites",
|
||||
"onBackPress",
|
||||
"onError",
|
||||
"onHide",
|
||||
"onLaunch",
|
||||
"onLoad",
|
||||
"onNavigationBarButtonTap",
|
||||
"onNavigationBarSearchInputChanged",
|
||||
"onNavigationBarSearchInputClicked",
|
||||
"onNavigationBarSearchInputConfirmed",
|
||||
"onNavigationBarSearchInputFocusChanged",
|
||||
"onPageNotFound",
|
||||
"onPageScroll",
|
||||
"onPullDownRefresh",
|
||||
"onReachBottom",
|
||||
"onReady",
|
||||
"onResize",
|
||||
"onShareAppMessage",
|
||||
"onShareTimeline",
|
||||
"onShow",
|
||||
"onTabItemTap",
|
||||
"onThemeChange",
|
||||
"onUnhandledRejection",
|
||||
"onUnload"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/solid.ts
|
||||
var solidCore = {
|
||||
"solid-js": [
|
||||
"createSignal",
|
||||
"createEffect",
|
||||
"createMemo",
|
||||
"createResource",
|
||||
"onMount",
|
||||
"onCleanup",
|
||||
"onError",
|
||||
"untrack",
|
||||
"batch",
|
||||
"on",
|
||||
"createRoot",
|
||||
"mergeProps",
|
||||
"splitProps",
|
||||
"useTransition",
|
||||
"observable",
|
||||
"mapArray",
|
||||
"indexArray",
|
||||
"createContext",
|
||||
"useContext",
|
||||
"children",
|
||||
"lazy",
|
||||
"createDeferred",
|
||||
"createRenderEffect",
|
||||
"createSelector",
|
||||
"For",
|
||||
"Show",
|
||||
"Switch",
|
||||
"Match",
|
||||
"Index",
|
||||
"ErrorBoundary",
|
||||
"Suspense",
|
||||
"SuspenseList"
|
||||
]
|
||||
};
|
||||
var solidStore = {
|
||||
"solid-js/store": [
|
||||
"createStore",
|
||||
"produce",
|
||||
"reconcile",
|
||||
"createMutable"
|
||||
]
|
||||
};
|
||||
var solidWeb = {
|
||||
"solid-js/web": [
|
||||
"Dynamic",
|
||||
"hydrate",
|
||||
"render",
|
||||
"renderToString",
|
||||
"renderToStringAsync",
|
||||
"renderToStream",
|
||||
"isServer",
|
||||
"Portal"
|
||||
]
|
||||
};
|
||||
var solid_default = __spreadValues(__spreadValues(__spreadValues({}, solidCore), solidStore), solidWeb);
|
||||
|
||||
// src/presets/solid-router.ts
|
||||
var solid_router_default = {
|
||||
"@solidjs/router": [
|
||||
"Link",
|
||||
"NavLink",
|
||||
"Navigate",
|
||||
"Outlet",
|
||||
"Route",
|
||||
"Router",
|
||||
"Routes",
|
||||
"_mergeSearchString",
|
||||
"createIntegration",
|
||||
"hashIntegration",
|
||||
"normalizeIntegration",
|
||||
"pathIntegration",
|
||||
"staticIntegration",
|
||||
"useHref",
|
||||
"useIsRouting",
|
||||
"useLocation",
|
||||
"useMatch",
|
||||
"useNavigate",
|
||||
"useParams",
|
||||
"useResolvedPath",
|
||||
"useRouteData",
|
||||
"useRoutes",
|
||||
"useSearchParams"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/solid-app-router.ts
|
||||
var solid_app_router_default = {
|
||||
"solid-app-router": [
|
||||
"Link",
|
||||
"NavLink",
|
||||
"Navigate",
|
||||
"Outlet",
|
||||
"Route",
|
||||
"Router",
|
||||
"Routes",
|
||||
"_mergeSearchString",
|
||||
"createIntegration",
|
||||
"hashIntegration",
|
||||
"normalizeIntegration",
|
||||
"pathIntegration",
|
||||
"staticIntegration",
|
||||
"useHref",
|
||||
"useIsRouting",
|
||||
"useLocation",
|
||||
"useMatch",
|
||||
"useNavigate",
|
||||
"useParams",
|
||||
"useResolvedPath",
|
||||
"useRouteData",
|
||||
"useRoutes",
|
||||
"useSearchParams"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/jotai.ts
|
||||
var jotai = {
|
||||
jotai: [
|
||||
"atom",
|
||||
"useAtom",
|
||||
"useAtomValue",
|
||||
"useSetAtom"
|
||||
]
|
||||
};
|
||||
var jotaiUtils = {
|
||||
"jotai/utils": [
|
||||
"atomWithReset",
|
||||
"useResetAtom",
|
||||
"useReducerAtom",
|
||||
"atomWithReducer",
|
||||
"atomFamily",
|
||||
"selectAtom",
|
||||
"useAtomCallback",
|
||||
"freezeAtom",
|
||||
"freezeAtomCreator",
|
||||
"splitAtom",
|
||||
"atomWithDefault",
|
||||
"waitForAll",
|
||||
"atomWithStorage",
|
||||
"atomWithHash",
|
||||
"createJSONStorage",
|
||||
"atomWithObservable",
|
||||
"useHydrateAtoms",
|
||||
"loadable"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/vueuse-math.ts
|
||||
import { readFileSync as readFileSync3 } from "fs";
|
||||
import process2 from "process";
|
||||
import { resolveModule as resolveModule3 } from "local-pkg";
|
||||
var _cache3;
|
||||
var vueuse_math_default = () => {
|
||||
if (!_cache3) {
|
||||
let indexesJson;
|
||||
try {
|
||||
const corePath = resolveModule3("@vueuse/core") || process2.cwd();
|
||||
const path = resolveModule3("@vueuse/metadata/index.json") || resolveModule3("@vueuse/metadata/index.json", { paths: [corePath] });
|
||||
indexesJson = JSON.parse(readFileSync3(path, "utf-8"));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw new Error("[auto-import] failed to load @vueuse/math, have you installed it?");
|
||||
}
|
||||
if (indexesJson) {
|
||||
_cache3 = {
|
||||
"@vueuse/math": indexesJson.functions.filter((i) => ["math"].includes(i.package)).flatMap((i) => [i.name, ...i.alias || []]).filter((i) => i && i.length >= 4)
|
||||
};
|
||||
}
|
||||
}
|
||||
return _cache3 || {};
|
||||
};
|
||||
|
||||
// src/presets/recoil.ts
|
||||
var recoil_default = {
|
||||
// https://recoiljs.org/docs/api-reference/core/atom/
|
||||
recoil: [
|
||||
"atom",
|
||||
"selector",
|
||||
"useRecoilState",
|
||||
"useRecoilValue",
|
||||
"useSetRecoilState",
|
||||
"useResetRecoilState",
|
||||
"useRecoilStateLoadable",
|
||||
"useRecoilValueLoadable",
|
||||
"isRecoilValue",
|
||||
"useRecoilCallback"
|
||||
]
|
||||
};
|
||||
|
||||
// src/presets/index.ts
|
||||
var presets = __spreadProps(__spreadValues({}, builtinPresets), {
|
||||
"ahooks": ahooks_default,
|
||||
"@vueuse/core": vueuse_core_default,
|
||||
"@vueuse/math": vueuse_math_default,
|
||||
"@vueuse/head": vueuse_head_default,
|
||||
"mobx": mobx_default,
|
||||
"mobx-react-lite": mobx_react_lite_default,
|
||||
"preact": preact_default,
|
||||
"quasar": quasar_default,
|
||||
"react": react_default,
|
||||
"react-router": react_router_default,
|
||||
"react-router-dom": react_router_dom_default,
|
||||
"react-i18next": react_i18next_default,
|
||||
"svelte": svelte,
|
||||
"svelte/animate": svelteAnimate,
|
||||
"svelte/easing": svelteEasing,
|
||||
"svelte/motion": svelteMotion,
|
||||
"svelte/store": svelteStore,
|
||||
"svelte/transition": svelteTransition,
|
||||
"vee-validate": vee_validate_default,
|
||||
"vitepress": vitepress_default,
|
||||
"vue-router": vue_router_default,
|
||||
"vue-router/composables": vue_router_composables_default,
|
||||
"vuex": vuex_default,
|
||||
"uni-app": uni_app_default,
|
||||
"solid-js": solid_default,
|
||||
"@solidjs/router": solid_router_default,
|
||||
"solid-app-router": solid_app_router_default,
|
||||
"jotai": jotai,
|
||||
"jotai/utils": jotaiUtils,
|
||||
"recoil": recoil_default
|
||||
});
|
||||
|
||||
export {
|
||||
__spreadValues,
|
||||
presets
|
||||
};
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
||||
|
||||
var _chunkERF3N54Scjs = require('./chunk-ERF3N54S.cjs');
|
||||
require('./chunk-6UOGCAOY.cjs');
|
||||
|
||||
// src/esbuild.ts
|
||||
var esbuild_default = _chunkERF3N54Scjs.unplugin_default.esbuild;
|
||||
|
||||
|
||||
module.exports = esbuild_default;
|
||||
exports.default = module.exports;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import { Options } from './types.cjs';
|
||||
import '@antfu/utils';
|
||||
import '@rollup/pluginutils';
|
||||
import 'unimport';
|
||||
import 'unimport/dist/shared/unimport.b55a67ec';
|
||||
|
||||
declare const _default: (options?: Options) => any;
|
||||
|
||||
export { _default as default };
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import { Options } from './types.js';
|
||||
import '@antfu/utils';
|
||||
import '@rollup/pluginutils';
|
||||
import 'unimport';
|
||||
import 'unimport/dist/shared/unimport.b55a67ec';
|
||||
|
||||
declare const _default: (options?: Options) => any;
|
||||
|
||||
export { _default as default };
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import {
|
||||
unplugin_default
|
||||
} from "./chunk-6AAI2DNE.js";
|
||||
import "./chunk-EZINZJYF.js";
|
||||
|
||||
// src/esbuild.ts
|
||||
var esbuild_default = unplugin_default.esbuild;
|
||||
export {
|
||||
esbuild_default as default
|
||||
};
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
||||
|
||||
var _chunkERF3N54Scjs = require('./chunk-ERF3N54S.cjs');
|
||||
require('./chunk-6UOGCAOY.cjs');
|
||||
|
||||
|
||||
module.exports = _chunkERF3N54Scjs.unplugin_default;
|
||||
exports.default = module.exports;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import * as unplugin from 'unplugin';
|
||||
import { Options } from './types.cjs';
|
||||
import '@antfu/utils';
|
||||
import '@rollup/pluginutils';
|
||||
import 'unimport';
|
||||
import 'unimport/dist/shared/unimport.b55a67ec';
|
||||
|
||||
declare const _default: unplugin.UnpluginInstance<Options, boolean>;
|
||||
|
||||
export { _default as default };
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import * as unplugin from 'unplugin';
|
||||
import { Options } from './types.js';
|
||||
import '@antfu/utils';
|
||||
import '@rollup/pluginutils';
|
||||
import 'unimport';
|
||||
import 'unimport/dist/shared/unimport.b55a67ec';
|
||||
|
||||
declare const _default: unplugin.UnpluginInstance<Options, boolean>;
|
||||
|
||||
export { _default as default };
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import {
|
||||
unplugin_default
|
||||
} from "./chunk-6AAI2DNE.js";
|
||||
import "./chunk-EZINZJYF.js";
|
||||
export {
|
||||
unplugin_default as default
|
||||
};
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
||||
|
||||
var _chunkERF3N54Scjs = require('./chunk-ERF3N54S.cjs');
|
||||
require('./chunk-6UOGCAOY.cjs');
|
||||
|
||||
// src/nuxt.ts
|
||||
var _kit = require('@nuxt/kit');
|
||||
var nuxt_default = _kit.defineNuxtModule.call(void 0, {
|
||||
setup(options) {
|
||||
options.exclude = options.exclude || [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/, /[\\/]\.nuxt[\\/]/];
|
||||
_kit.addWebpackPlugin.call(void 0, _chunkERF3N54Scjs.unplugin_default.webpack(options));
|
||||
_kit.addVitePlugin.call(void 0, _chunkERF3N54Scjs.unplugin_default.vite(options));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
module.exports = nuxt_default;
|
||||
exports.default = module.exports;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import * as _nuxt_schema from '@nuxt/schema';
|
||||
import { Options } from './types.cjs';
|
||||
import '@antfu/utils';
|
||||
import '@rollup/pluginutils';
|
||||
import 'unimport';
|
||||
import 'unimport/dist/shared/unimport.b55a67ec';
|
||||
|
||||
declare const _default: _nuxt_schema.NuxtModule<Options>;
|
||||
|
||||
export { _default as default };
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import * as _nuxt_schema from '@nuxt/schema';
|
||||
import { Options } from './types.js';
|
||||
import '@antfu/utils';
|
||||
import '@rollup/pluginutils';
|
||||
import 'unimport';
|
||||
import 'unimport/dist/shared/unimport.b55a67ec';
|
||||
|
||||
declare const _default: _nuxt_schema.NuxtModule<Options>;
|
||||
|
||||
export { _default as default };
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import {
|
||||
unplugin_default
|
||||
} from "./chunk-6AAI2DNE.js";
|
||||
import "./chunk-EZINZJYF.js";
|
||||
|
||||
// src/nuxt.ts
|
||||
import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit";
|
||||
var nuxt_default = defineNuxtModule({
|
||||
setup(options) {
|
||||
options.exclude = options.exclude || [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/, /[\\/]\.nuxt[\\/]/];
|
||||
addWebpackPlugin(unplugin_default.webpack(options));
|
||||
addVitePlugin(unplugin_default.vite(options));
|
||||
}
|
||||
});
|
||||
export {
|
||||
nuxt_default as default
|
||||
};
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
||||
|
||||
var _chunkERF3N54Scjs = require('./chunk-ERF3N54S.cjs');
|
||||
require('./chunk-6UOGCAOY.cjs');
|
||||
|
||||
// src/rollup.ts
|
||||
var rollup_default = _chunkERF3N54Scjs.unplugin_default.rollup;
|
||||
|
||||
|
||||
module.exports = rollup_default;
|
||||
exports.default = module.exports;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import { Options } from './types.cjs';
|
||||
import '@antfu/utils';
|
||||
import '@rollup/pluginutils';
|
||||
import 'unimport';
|
||||
import 'unimport/dist/shared/unimport.b55a67ec';
|
||||
|
||||
declare const _default: (options?: Options) => any;
|
||||
|
||||
export { _default as default };
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import { Options } from './types.js';
|
||||
import '@antfu/utils';
|
||||
import '@rollup/pluginutils';
|
||||
import 'unimport';
|
||||
import 'unimport/dist/shared/unimport.b55a67ec';
|
||||
|
||||
declare const _default: (options?: Options) => any;
|
||||
|
||||
export { _default as default };
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import {
|
||||
unplugin_default
|
||||
} from "./chunk-6AAI2DNE.js";
|
||||
import "./chunk-EZINZJYF.js";
|
||||
|
||||
// src/rollup.ts
|
||||
var rollup_default = unplugin_default.rollup;
|
||||
export {
|
||||
rollup_default as default
|
||||
};
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
||||
|
||||
var _chunkERF3N54Scjs = require('./chunk-ERF3N54S.cjs');
|
||||
require('./chunk-6UOGCAOY.cjs');
|
||||
|
||||
// src/rspack.ts
|
||||
var rspack_default = _chunkERF3N54Scjs.unplugin_default.rspack;
|
||||
|
||||
|
||||
module.exports = rspack_default;
|
||||
exports.default = module.exports;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import { Options } from './types.cjs';
|
||||
import '@antfu/utils';
|
||||
import '@rollup/pluginutils';
|
||||
import 'unimport';
|
||||
import 'unimport/dist/shared/unimport.b55a67ec';
|
||||
|
||||
declare const _default: (options?: Options) => any;
|
||||
|
||||
export { _default as default };
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import { Options } from './types.js';
|
||||
import '@antfu/utils';
|
||||
import '@rollup/pluginutils';
|
||||
import 'unimport';
|
||||
import 'unimport/dist/shared/unimport.b55a67ec';
|
||||
|
||||
declare const _default: (options?: Options) => any;
|
||||
|
||||
export { _default as default };
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import {
|
||||
unplugin_default
|
||||
} from "./chunk-6AAI2DNE.js";
|
||||
import "./chunk-EZINZJYF.js";
|
||||
|
||||
// src/rspack.ts
|
||||
var rspack_default = unplugin_default.rspack;
|
||||
export {
|
||||
rspack_default as default
|
||||
};
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
"use strict";require('./chunk-6UOGCAOY.cjs');
|
||||
exports.default = module.exports;
|
||||
+172
@@ -0,0 +1,172 @@
|
||||
import { Arrayable, Awaitable } from '@antfu/utils';
|
||||
import { FilterPattern } from '@rollup/pluginutils';
|
||||
import { Import, InlinePreset } from 'unimport';
|
||||
import * as unimport_dist_shared_unimport_b55a67ec from 'unimport/dist/shared/unimport.b55a67ec';
|
||||
|
||||
declare const presets: {
|
||||
ahooks: () => ImportsMap;
|
||||
'@vueuse/core': () => ImportsMap;
|
||||
'@vueuse/math': () => ImportsMap;
|
||||
'@vueuse/head': ImportsMap;
|
||||
mobx: ImportsMap;
|
||||
'mobx-react-lite': ImportsMap;
|
||||
preact: ImportsMap;
|
||||
quasar: ImportsMap;
|
||||
react: ImportsMap;
|
||||
'react-router': ImportsMap;
|
||||
'react-router-dom': ImportsMap;
|
||||
'react-i18next': ImportsMap;
|
||||
svelte: ImportsMap;
|
||||
'svelte/animate': ImportsMap;
|
||||
'svelte/easing': ImportsMap;
|
||||
'svelte/motion': ImportsMap;
|
||||
'svelte/store': ImportsMap;
|
||||
'svelte/transition': ImportsMap;
|
||||
'vee-validate': ImportsMap;
|
||||
vitepress: ImportsMap;
|
||||
'vue-router': ImportsMap;
|
||||
'vue-router/composables': ImportsMap;
|
||||
vuex: ImportsMap;
|
||||
'uni-app': ImportsMap;
|
||||
'solid-js': ImportsMap;
|
||||
'@solidjs/router': ImportsMap;
|
||||
'solid-app-router': ImportsMap;
|
||||
jotai: ImportsMap;
|
||||
'jotai/utils': ImportsMap;
|
||||
recoil: ImportsMap;
|
||||
'@vue/composition-api': unimport_dist_shared_unimport_b55a67ec.a;
|
||||
pinia: unimport_dist_shared_unimport_b55a67ec.a;
|
||||
'vue-demi': unimport_dist_shared_unimport_b55a67ec.a;
|
||||
'vue-i18n': unimport_dist_shared_unimport_b55a67ec.a;
|
||||
'vue-router-composables': unimport_dist_shared_unimport_b55a67ec.a;
|
||||
vue: unimport_dist_shared_unimport_b55a67ec.a;
|
||||
'vue/macros': unimport_dist_shared_unimport_b55a67ec.a;
|
||||
vitest: unimport_dist_shared_unimport_b55a67ec.a;
|
||||
rxjs: unimport_dist_shared_unimport_b55a67ec.a;
|
||||
};
|
||||
type PresetName = keyof typeof presets;
|
||||
|
||||
interface ImportLegacy {
|
||||
/**
|
||||
* @deprecated renamed to `as`
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* @deprecated renamed to `name`
|
||||
*/
|
||||
importName?: string;
|
||||
/**
|
||||
* @deprecated renamed to `from`
|
||||
*/
|
||||
path: string;
|
||||
sideEffects?: SideEffectsInfo;
|
||||
}
|
||||
interface ImportExtended extends Import {
|
||||
sideEffects?: SideEffectsInfo;
|
||||
__source?: 'dir' | 'resolver';
|
||||
}
|
||||
type ImportNameAlias = [string, string];
|
||||
type SideEffectsInfo = Arrayable<ResolverResult | string> | undefined;
|
||||
interface ResolverResult {
|
||||
as?: string;
|
||||
name?: string;
|
||||
from: string;
|
||||
}
|
||||
type ResolverFunction = (name: string) => Awaitable<string | ResolverResult | ImportExtended | null | undefined | void>;
|
||||
interface ResolverResultObject {
|
||||
type: 'component' | 'directive';
|
||||
resolve: ResolverFunction;
|
||||
}
|
||||
/**
|
||||
* Given a identifier name, returns the import path or an import object
|
||||
*/
|
||||
type Resolver = ResolverFunction | ResolverResultObject;
|
||||
/**
|
||||
* module, name, alias
|
||||
*/
|
||||
type ImportsMap = Record<string, (string | ImportNameAlias)[]>;
|
||||
type ESLintGlobalsPropValue = boolean | 'readonly' | 'readable' | 'writable' | 'writeable';
|
||||
interface ESLintrc {
|
||||
/**
|
||||
* @default false
|
||||
*/
|
||||
enabled?: boolean;
|
||||
/**
|
||||
* Filepath to save the generated eslint config
|
||||
*
|
||||
* @default './.eslintrc-auto-import.json'
|
||||
*/
|
||||
filepath?: string;
|
||||
/**
|
||||
* @default true
|
||||
*/
|
||||
globalsPropValue?: ESLintGlobalsPropValue;
|
||||
}
|
||||
interface Options {
|
||||
/**
|
||||
* Preset names or custom imports map
|
||||
*
|
||||
* @default []
|
||||
*/
|
||||
imports?: Arrayable<ImportsMap | PresetName | InlinePreset>;
|
||||
/**
|
||||
* Identifiers to be ignored
|
||||
*/
|
||||
ignore?: (string | RegExp)[];
|
||||
/**
|
||||
* Inject the imports at the end of other imports
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
injectAtEnd?: boolean;
|
||||
/**
|
||||
* Path for directories to be auto imported
|
||||
*/
|
||||
dirs?: string[];
|
||||
/**
|
||||
* Pass a custom function to resolve the component importing path from the component name.
|
||||
*
|
||||
* The component names are always in PascalCase
|
||||
*/
|
||||
resolvers?: Arrayable<Arrayable<Resolver>>;
|
||||
/**
|
||||
* Filepath to generate corresponding .d.ts file.
|
||||
* Default enabled when `typescript` is installed locally.
|
||||
* Set `false` to disable.
|
||||
*
|
||||
* @default './auto-imports.d.ts'
|
||||
*/
|
||||
dts?: string | boolean;
|
||||
/**
|
||||
* Auto import inside Vue templates
|
||||
*
|
||||
* @see https://github.com/unjs/unimport/pull/15
|
||||
* @see https://github.com/unjs/unimport/pull/72
|
||||
* @default false
|
||||
*/
|
||||
vueTemplate?: boolean;
|
||||
/**
|
||||
* Set default export alias by file name
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
defaultExportByFilename?: boolean;
|
||||
/**
|
||||
* Rules to include transforming target.
|
||||
*
|
||||
* @default [/\.[jt]sx?$/, /\.vue\??/]
|
||||
*/
|
||||
include?: FilterPattern;
|
||||
/**
|
||||
* Rules to exclude transforming target.
|
||||
*
|
||||
* @default [/node_modules/, /\.git/]
|
||||
*/
|
||||
exclude?: FilterPattern;
|
||||
/**
|
||||
* Generate corresponding .eslintrc-auto-import.json file.
|
||||
*/
|
||||
eslintrc?: ESLintrc;
|
||||
}
|
||||
|
||||
export { ESLintGlobalsPropValue, ESLintrc, ImportExtended, ImportLegacy, ImportNameAlias, ImportsMap, Options, PresetName, Resolver, ResolverFunction, ResolverResult, ResolverResultObject, SideEffectsInfo };
|
||||
+172
@@ -0,0 +1,172 @@
|
||||
import { Arrayable, Awaitable } from '@antfu/utils';
|
||||
import { FilterPattern } from '@rollup/pluginutils';
|
||||
import { Import, InlinePreset } from 'unimport';
|
||||
import * as unimport_dist_shared_unimport_b55a67ec from 'unimport/dist/shared/unimport.b55a67ec';
|
||||
|
||||
declare const presets: {
|
||||
ahooks: () => ImportsMap;
|
||||
'@vueuse/core': () => ImportsMap;
|
||||
'@vueuse/math': () => ImportsMap;
|
||||
'@vueuse/head': ImportsMap;
|
||||
mobx: ImportsMap;
|
||||
'mobx-react-lite': ImportsMap;
|
||||
preact: ImportsMap;
|
||||
quasar: ImportsMap;
|
||||
react: ImportsMap;
|
||||
'react-router': ImportsMap;
|
||||
'react-router-dom': ImportsMap;
|
||||
'react-i18next': ImportsMap;
|
||||
svelte: ImportsMap;
|
||||
'svelte/animate': ImportsMap;
|
||||
'svelte/easing': ImportsMap;
|
||||
'svelte/motion': ImportsMap;
|
||||
'svelte/store': ImportsMap;
|
||||
'svelte/transition': ImportsMap;
|
||||
'vee-validate': ImportsMap;
|
||||
vitepress: ImportsMap;
|
||||
'vue-router': ImportsMap;
|
||||
'vue-router/composables': ImportsMap;
|
||||
vuex: ImportsMap;
|
||||
'uni-app': ImportsMap;
|
||||
'solid-js': ImportsMap;
|
||||
'@solidjs/router': ImportsMap;
|
||||
'solid-app-router': ImportsMap;
|
||||
jotai: ImportsMap;
|
||||
'jotai/utils': ImportsMap;
|
||||
recoil: ImportsMap;
|
||||
'@vue/composition-api': unimport_dist_shared_unimport_b55a67ec.a;
|
||||
pinia: unimport_dist_shared_unimport_b55a67ec.a;
|
||||
'vue-demi': unimport_dist_shared_unimport_b55a67ec.a;
|
||||
'vue-i18n': unimport_dist_shared_unimport_b55a67ec.a;
|
||||
'vue-router-composables': unimport_dist_shared_unimport_b55a67ec.a;
|
||||
vue: unimport_dist_shared_unimport_b55a67ec.a;
|
||||
'vue/macros': unimport_dist_shared_unimport_b55a67ec.a;
|
||||
vitest: unimport_dist_shared_unimport_b55a67ec.a;
|
||||
rxjs: unimport_dist_shared_unimport_b55a67ec.a;
|
||||
};
|
||||
type PresetName = keyof typeof presets;
|
||||
|
||||
interface ImportLegacy {
|
||||
/**
|
||||
* @deprecated renamed to `as`
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* @deprecated renamed to `name`
|
||||
*/
|
||||
importName?: string;
|
||||
/**
|
||||
* @deprecated renamed to `from`
|
||||
*/
|
||||
path: string;
|
||||
sideEffects?: SideEffectsInfo;
|
||||
}
|
||||
interface ImportExtended extends Import {
|
||||
sideEffects?: SideEffectsInfo;
|
||||
__source?: 'dir' | 'resolver';
|
||||
}
|
||||
type ImportNameAlias = [string, string];
|
||||
type SideEffectsInfo = Arrayable<ResolverResult | string> | undefined;
|
||||
interface ResolverResult {
|
||||
as?: string;
|
||||
name?: string;
|
||||
from: string;
|
||||
}
|
||||
type ResolverFunction = (name: string) => Awaitable<string | ResolverResult | ImportExtended | null | undefined | void>;
|
||||
interface ResolverResultObject {
|
||||
type: 'component' | 'directive';
|
||||
resolve: ResolverFunction;
|
||||
}
|
||||
/**
|
||||
* Given a identifier name, returns the import path or an import object
|
||||
*/
|
||||
type Resolver = ResolverFunction | ResolverResultObject;
|
||||
/**
|
||||
* module, name, alias
|
||||
*/
|
||||
type ImportsMap = Record<string, (string | ImportNameAlias)[]>;
|
||||
type ESLintGlobalsPropValue = boolean | 'readonly' | 'readable' | 'writable' | 'writeable';
|
||||
interface ESLintrc {
|
||||
/**
|
||||
* @default false
|
||||
*/
|
||||
enabled?: boolean;
|
||||
/**
|
||||
* Filepath to save the generated eslint config
|
||||
*
|
||||
* @default './.eslintrc-auto-import.json'
|
||||
*/
|
||||
filepath?: string;
|
||||
/**
|
||||
* @default true
|
||||
*/
|
||||
globalsPropValue?: ESLintGlobalsPropValue;
|
||||
}
|
||||
interface Options {
|
||||
/**
|
||||
* Preset names or custom imports map
|
||||
*
|
||||
* @default []
|
||||
*/
|
||||
imports?: Arrayable<ImportsMap | PresetName | InlinePreset>;
|
||||
/**
|
||||
* Identifiers to be ignored
|
||||
*/
|
||||
ignore?: (string | RegExp)[];
|
||||
/**
|
||||
* Inject the imports at the end of other imports
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
injectAtEnd?: boolean;
|
||||
/**
|
||||
* Path for directories to be auto imported
|
||||
*/
|
||||
dirs?: string[];
|
||||
/**
|
||||
* Pass a custom function to resolve the component importing path from the component name.
|
||||
*
|
||||
* The component names are always in PascalCase
|
||||
*/
|
||||
resolvers?: Arrayable<Arrayable<Resolver>>;
|
||||
/**
|
||||
* Filepath to generate corresponding .d.ts file.
|
||||
* Default enabled when `typescript` is installed locally.
|
||||
* Set `false` to disable.
|
||||
*
|
||||
* @default './auto-imports.d.ts'
|
||||
*/
|
||||
dts?: string | boolean;
|
||||
/**
|
||||
* Auto import inside Vue templates
|
||||
*
|
||||
* @see https://github.com/unjs/unimport/pull/15
|
||||
* @see https://github.com/unjs/unimport/pull/72
|
||||
* @default false
|
||||
*/
|
||||
vueTemplate?: boolean;
|
||||
/**
|
||||
* Set default export alias by file name
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
defaultExportByFilename?: boolean;
|
||||
/**
|
||||
* Rules to include transforming target.
|
||||
*
|
||||
* @default [/\.[jt]sx?$/, /\.vue\??/]
|
||||
*/
|
||||
include?: FilterPattern;
|
||||
/**
|
||||
* Rules to exclude transforming target.
|
||||
*
|
||||
* @default [/node_modules/, /\.git/]
|
||||
*/
|
||||
exclude?: FilterPattern;
|
||||
/**
|
||||
* Generate corresponding .eslintrc-auto-import.json file.
|
||||
*/
|
||||
eslintrc?: ESLintrc;
|
||||
}
|
||||
|
||||
export { ESLintGlobalsPropValue, ESLintrc, ImportExtended, ImportLegacy, ImportNameAlias, ImportsMap, Options, PresetName, Resolver, ResolverFunction, ResolverResult, ResolverResultObject, SideEffectsInfo };
|
||||
+1
@@ -0,0 +1 @@
|
||||
import "./chunk-EZINZJYF.js";
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
||||
|
||||
var _chunkERF3N54Scjs = require('./chunk-ERF3N54S.cjs');
|
||||
require('./chunk-6UOGCAOY.cjs');
|
||||
|
||||
// src/vite.ts
|
||||
var vite_default = _chunkERF3N54Scjs.unplugin_default.vite;
|
||||
|
||||
|
||||
module.exports = vite_default;
|
||||
exports.default = module.exports;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import { Options } from './types.cjs';
|
||||
import '@antfu/utils';
|
||||
import '@rollup/pluginutils';
|
||||
import 'unimport';
|
||||
import 'unimport/dist/shared/unimport.b55a67ec';
|
||||
|
||||
declare const _default: (options?: Options) => any;
|
||||
|
||||
export { _default as default };
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import { Options } from './types.js';
|
||||
import '@antfu/utils';
|
||||
import '@rollup/pluginutils';
|
||||
import 'unimport';
|
||||
import 'unimport/dist/shared/unimport.b55a67ec';
|
||||
|
||||
declare const _default: (options?: Options) => any;
|
||||
|
||||
export { _default as default };
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import {
|
||||
unplugin_default
|
||||
} from "./chunk-6AAI2DNE.js";
|
||||
import "./chunk-EZINZJYF.js";
|
||||
|
||||
// src/vite.ts
|
||||
var vite_default = unplugin_default.vite;
|
||||
export {
|
||||
vite_default as default
|
||||
};
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
||||
|
||||
var _chunkERF3N54Scjs = require('./chunk-ERF3N54S.cjs');
|
||||
require('./chunk-6UOGCAOY.cjs');
|
||||
|
||||
// src/webpack.ts
|
||||
var webpack_default = _chunkERF3N54Scjs.unplugin_default.webpack;
|
||||
|
||||
|
||||
module.exports = webpack_default;
|
||||
exports.default = module.exports;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import { Options } from './types.cjs';
|
||||
import '@antfu/utils';
|
||||
import '@rollup/pluginutils';
|
||||
import 'unimport';
|
||||
import 'unimport/dist/shared/unimport.b55a67ec';
|
||||
|
||||
declare const _default: (options?: Options) => any;
|
||||
|
||||
export { _default as default };
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import { Options } from './types.js';
|
||||
import '@antfu/utils';
|
||||
import '@rollup/pluginutils';
|
||||
import 'unimport';
|
||||
import 'unimport/dist/shared/unimport.b55a67ec';
|
||||
|
||||
declare const _default: (options?: Options) => any;
|
||||
|
||||
export { _default as default };
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import {
|
||||
unplugin_default
|
||||
} from "./chunk-6AAI2DNE.js";
|
||||
import "./chunk-EZINZJYF.js";
|
||||
|
||||
// src/webpack.ts
|
||||
var webpack_default = unplugin_default.webpack;
|
||||
export {
|
||||
webpack_default as default
|
||||
};
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
{
|
||||
"name": "unplugin-auto-import",
|
||||
"type": "module",
|
||||
"version": "0.16.7",
|
||||
"packageManager": "pnpm@8.9.2",
|
||||
"description": "Register global imports on demand for Vite and Webpack",
|
||||
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
||||
"license": "MIT",
|
||||
"funding": "https://github.com/sponsors/antfu",
|
||||
"homepage": "https://github.com/antfu/unplugin-auto-import#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/antfu/unplugin-auto-import.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/antfu/unplugin-auto-import/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"unplugin",
|
||||
"vite",
|
||||
"astro",
|
||||
"webpack",
|
||||
"rollup",
|
||||
"rspack",
|
||||
"auto-import",
|
||||
"transform"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"./nuxt": {
|
||||
"types": "./dist/nuxt.d.ts",
|
||||
"import": "./dist/nuxt.js",
|
||||
"require": "./dist/nuxt.cjs"
|
||||
},
|
||||
"./astro": {
|
||||
"types": "./dist/astro.d.ts",
|
||||
"import": "./dist/astro.js",
|
||||
"require": "./dist/astro.cjs"
|
||||
},
|
||||
"./rollup": {
|
||||
"types": "./dist/rollup.d.ts",
|
||||
"import": "./dist/rollup.js",
|
||||
"require": "./dist/rollup.cjs"
|
||||
},
|
||||
"./types": {
|
||||
"types": "./dist/types.d.ts",
|
||||
"import": "./dist/types.js",
|
||||
"require": "./dist/types.cjs"
|
||||
},
|
||||
"./vite": {
|
||||
"types": "./dist/vite.d.ts",
|
||||
"import": "./dist/vite.js",
|
||||
"require": "./dist/vite.cjs"
|
||||
},
|
||||
"./webpack": {
|
||||
"types": "./dist/webpack.d.ts",
|
||||
"import": "./dist/webpack.js",
|
||||
"require": "./dist/webpack.cjs"
|
||||
},
|
||||
"./rspack": {
|
||||
"types": "./dist/rspack.d.ts",
|
||||
"import": "./dist/rspack.js",
|
||||
"require": "./dist/rspack.cjs"
|
||||
},
|
||||
"./esbuild": {
|
||||
"types": "./dist/esbuild.d.ts",
|
||||
"import": "./dist/esbuild.js",
|
||||
"require": "./dist/esbuild.cjs"
|
||||
},
|
||||
"./*": "./*"
|
||||
},
|
||||
"main": "dist/index.cjs",
|
||||
"module": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"typesVersions": {
|
||||
"*": {
|
||||
"*": [
|
||||
"./dist/*",
|
||||
"./*"
|
||||
]
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"*.d.ts",
|
||||
"dist"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@nuxt/kit": "^3.2.2",
|
||||
"@vueuse/core": "*"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@vueuse/core": {
|
||||
"optional": true
|
||||
},
|
||||
"@nuxt/kit": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@antfu/utils": "^0.7.6",
|
||||
"@rollup/pluginutils": "^5.0.5",
|
||||
"fast-glob": "^3.3.1",
|
||||
"local-pkg": "^0.5.0",
|
||||
"magic-string": "^0.30.5",
|
||||
"minimatch": "^9.0.3",
|
||||
"unimport": "^3.4.0",
|
||||
"unplugin": "^1.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "^1.0.0-beta.29",
|
||||
"@antfu/ni": "^0.21.8",
|
||||
"@nuxt/kit": "^3.8.0",
|
||||
"@types/node": "^20.8.9",
|
||||
"@types/resolve": "^1.20.4",
|
||||
"@vueuse/metadata": "^10.5.0",
|
||||
"bumpp": "^9.2.0",
|
||||
"eslint": "^8.52.0",
|
||||
"esno": "^0.17.0",
|
||||
"rollup": "^4.1.4",
|
||||
"tsup": "^7.2.0",
|
||||
"typescript": "^5.2.2",
|
||||
"vite": "^4.5.0",
|
||||
"vitest": "^0.34.6",
|
||||
"webpack": "^5.89.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsup src/*.ts --format cjs,esm --dts --splitting --clean && esno scripts/postbuild.ts",
|
||||
"dev": "tsup src/*.ts --watch src",
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "nr lint --fix",
|
||||
"play": "npm -C playground run dev",
|
||||
"release": "bumpp && pnpm publish",
|
||||
"start": "esno src/index.ts",
|
||||
"test": "vitest",
|
||||
"test:run": "vitest run"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user