2022-12-11 21:44:52 +00:00
|
|
|
import type { InlinePreset } from 'unimport'
|
|
|
|
import { defineUnimportPreset } from 'unimport'
|
2022-03-11 08:09:11 +00:00
|
|
|
|
2022-10-26 08:28:00 +00:00
|
|
|
const commonPresets: InlinePreset[] = [
|
2022-04-05 14:02:29 +00:00
|
|
|
// #head
|
2022-03-11 08:09:11 +00:00
|
|
|
defineUnimportPreset({
|
2022-04-05 14:02:29 +00:00
|
|
|
from: '#head',
|
2022-03-11 08:09:11 +00:00
|
|
|
imports: [
|
2023-01-24 15:34:20 +00:00
|
|
|
'useHead',
|
|
|
|
'useSeoMeta',
|
|
|
|
'useServerSeoMeta'
|
2022-03-11 08:09:11 +00:00
|
|
|
]
|
|
|
|
}),
|
|
|
|
// vue-demi (mocked)
|
|
|
|
defineUnimportPreset({
|
|
|
|
from: 'vue-demi',
|
|
|
|
imports: [
|
|
|
|
'isVue2',
|
|
|
|
'isVue3'
|
|
|
|
]
|
|
|
|
})
|
|
|
|
]
|
|
|
|
|
2022-08-17 15:23:13 +00:00
|
|
|
const appPreset = defineUnimportPreset({
|
2022-03-11 08:09:11 +00:00
|
|
|
from: '#app',
|
|
|
|
imports: [
|
|
|
|
'useAsyncData',
|
|
|
|
'useLazyAsyncData',
|
2022-12-05 13:07:33 +00:00
|
|
|
'useNuxtData',
|
2022-03-28 17:12:41 +00:00
|
|
|
'refreshNuxtData',
|
2022-09-21 09:53:38 +00:00
|
|
|
'clearNuxtData',
|
2022-03-11 08:09:11 +00:00
|
|
|
'defineNuxtComponent',
|
|
|
|
'useNuxtApp',
|
|
|
|
'defineNuxtPlugin',
|
|
|
|
'useRuntimeConfig',
|
|
|
|
'useState',
|
|
|
|
'useFetch',
|
|
|
|
'useLazyFetch',
|
|
|
|
'useCookie',
|
|
|
|
'useRequestHeaders',
|
2022-04-07 11:28:04 +00:00
|
|
|
'useRequestEvent',
|
2022-08-02 16:01:59 +00:00
|
|
|
'setResponseStatus',
|
2022-08-31 08:02:48 +00:00
|
|
|
'setPageLayout',
|
2022-12-05 10:09:58 +00:00
|
|
|
'onNuxtReady',
|
2022-03-11 08:09:11 +00:00
|
|
|
'useRouter',
|
|
|
|
'useRoute',
|
|
|
|
'defineNuxtRouteMiddleware',
|
|
|
|
'navigateTo',
|
|
|
|
'abortNavigation',
|
2022-03-11 08:22:16 +00:00
|
|
|
'addRouteMiddleware',
|
2022-07-21 14:29:03 +00:00
|
|
|
'showError',
|
2022-03-11 08:22:16 +00:00
|
|
|
'clearError',
|
2022-07-21 14:29:03 +00:00
|
|
|
'isNuxtError',
|
2022-03-14 13:36:32 +00:00
|
|
|
'useError',
|
2022-07-21 14:29:03 +00:00
|
|
|
'createError',
|
2022-08-17 15:23:13 +00:00
|
|
|
'defineNuxtLink',
|
|
|
|
'useAppConfig',
|
2022-08-24 16:35:02 +00:00
|
|
|
'updateAppConfig',
|
2022-08-23 19:12:22 +00:00
|
|
|
'defineAppConfig',
|
|
|
|
'preloadComponents',
|
2022-10-17 11:15:29 +00:00
|
|
|
'preloadRouteComponents',
|
2022-09-10 13:57:16 +00:00
|
|
|
'prefetchComponents',
|
|
|
|
'loadPayload',
|
|
|
|
'preloadPayload',
|
|
|
|
'isPrerendered'
|
2022-03-11 08:09:11 +00:00
|
|
|
]
|
|
|
|
})
|
|
|
|
|
2022-11-10 13:52:04 +00:00
|
|
|
// vue-router
|
|
|
|
const routerPreset = defineUnimportPreset({
|
|
|
|
from: '#app',
|
|
|
|
imports: [
|
|
|
|
'onBeforeRouteLeave',
|
|
|
|
'onBeforeRouteUpdate'
|
|
|
|
]
|
|
|
|
})
|
|
|
|
|
2022-03-11 08:09:11 +00:00
|
|
|
// vue
|
2022-08-17 15:23:13 +00:00
|
|
|
const vuePreset = defineUnimportPreset({
|
2022-03-11 08:09:11 +00:00
|
|
|
from: 'vue',
|
|
|
|
imports: [
|
|
|
|
// <script setup>
|
|
|
|
'withCtx',
|
|
|
|
'withDirectives',
|
|
|
|
'withKeys',
|
|
|
|
'withMemo',
|
|
|
|
'withModifiers',
|
|
|
|
'withScopeId',
|
|
|
|
|
|
|
|
// Lifecycle
|
|
|
|
'onActivated',
|
|
|
|
'onBeforeMount',
|
|
|
|
'onBeforeUnmount',
|
|
|
|
'onBeforeUpdate',
|
|
|
|
'onDeactivated',
|
|
|
|
'onErrorCaptured',
|
|
|
|
'onMounted',
|
|
|
|
'onRenderTracked',
|
|
|
|
'onRenderTriggered',
|
|
|
|
'onServerPrefetch',
|
|
|
|
'onUnmounted',
|
|
|
|
'onUpdated',
|
|
|
|
|
|
|
|
// Reactivity
|
|
|
|
'computed',
|
|
|
|
'customRef',
|
|
|
|
'isProxy',
|
|
|
|
'isReactive',
|
|
|
|
'isReadonly',
|
|
|
|
'isRef',
|
|
|
|
'markRaw',
|
|
|
|
'proxyRefs',
|
|
|
|
'reactive',
|
|
|
|
'readonly',
|
|
|
|
'ref',
|
|
|
|
'shallowReactive',
|
|
|
|
'shallowReadonly',
|
|
|
|
'shallowRef',
|
|
|
|
'toRaw',
|
|
|
|
'toRef',
|
|
|
|
'toRefs',
|
|
|
|
'triggerRef',
|
|
|
|
'unref',
|
|
|
|
'watch',
|
|
|
|
'watchEffect',
|
|
|
|
'isShallow',
|
|
|
|
|
|
|
|
// effect
|
|
|
|
'effect',
|
|
|
|
'effectScope',
|
|
|
|
'getCurrentScope',
|
|
|
|
'onScopeDispose',
|
|
|
|
|
|
|
|
// Component
|
|
|
|
'defineComponent',
|
|
|
|
'defineAsyncComponent',
|
2022-03-22 17:04:31 +00:00
|
|
|
'resolveComponent',
|
2022-03-11 08:09:11 +00:00
|
|
|
'getCurrentInstance',
|
|
|
|
'h',
|
|
|
|
'inject',
|
|
|
|
'nextTick',
|
|
|
|
'provide',
|
|
|
|
'useAttrs',
|
|
|
|
'useCssModule',
|
|
|
|
'useCssVars',
|
|
|
|
'useSlots',
|
|
|
|
'useTransitionState'
|
2023-02-07 14:00:11 +00:00
|
|
|
]
|
|
|
|
})
|
|
|
|
|
|
|
|
const vueTypesPreset = defineUnimportPreset({
|
|
|
|
from: 'vue',
|
|
|
|
type: true,
|
|
|
|
imports: [
|
|
|
|
'Component',
|
|
|
|
'ComponentPublicInstance',
|
|
|
|
'ComputedRef',
|
|
|
|
'InjectionKey',
|
|
|
|
'PropType',
|
|
|
|
'Ref',
|
|
|
|
'VNode'
|
|
|
|
]
|
2022-03-11 08:09:11 +00:00
|
|
|
})
|
|
|
|
|
2022-10-26 08:28:00 +00:00
|
|
|
export const defaultPresets: InlinePreset[] = [
|
2022-03-11 08:09:11 +00:00
|
|
|
...commonPresets,
|
|
|
|
appPreset,
|
2022-11-10 13:52:04 +00:00
|
|
|
routerPreset,
|
2023-02-07 14:00:11 +00:00
|
|
|
vuePreset,
|
|
|
|
vueTypesPreset
|
2022-03-11 08:09:11 +00:00
|
|
|
]
|