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-03-11 08:09:11 +00:00
|
|
|
// vue-demi (mocked)
|
|
|
|
defineUnimportPreset({
|
|
|
|
from: 'vue-demi',
|
|
|
|
imports: [
|
|
|
|
'isVue2',
|
|
|
|
'isVue3'
|
|
|
|
]
|
|
|
|
})
|
|
|
|
]
|
|
|
|
|
2023-10-30 21:05:02 +00:00
|
|
|
const granularAppPresets: InlinePreset[] = [
|
|
|
|
{
|
|
|
|
from: '#app/components/nuxt-link',
|
|
|
|
imports: ['defineNuxtLink']
|
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['useNuxtApp', 'defineNuxtPlugin', 'definePayloadPlugin', 'useRuntimeConfig', 'defineAppConfig'],
|
|
|
|
from: '#app/nuxt'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['requestIdleCallback', 'cancelIdleCallback'],
|
|
|
|
from: '#app/compat/idle-callback'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['useAppConfig', 'updateAppConfig'],
|
|
|
|
from: '#app/config'
|
|
|
|
},
|
|
|
|
{
|
2023-12-14 21:00:36 +00:00
|
|
|
imports: ['defineComponent', 'defineNuxtComponent'],
|
2023-10-30 21:05:02 +00:00
|
|
|
from: '#app/composables/component'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['useAsyncData', 'useLazyAsyncData', 'useNuxtData', 'refreshNuxtData', 'clearNuxtData'],
|
|
|
|
from: '#app/composables/asyncData'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['useHydration'],
|
|
|
|
from: '#app/composables/hydrate'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['useState', 'clearNuxtState'],
|
|
|
|
from: '#app/composables/state'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['clearError', 'createError', 'isNuxtError', 'showError', 'useError'],
|
|
|
|
from: '#app/composables/error'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['useFetch', 'useLazyFetch'],
|
|
|
|
from: '#app/composables/fetch'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['useCookie'],
|
|
|
|
from: '#app/composables/cookie'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['prerenderRoutes', 'useRequestHeaders', 'useRequestEvent', 'useRequestFetch', 'setResponseStatus'],
|
|
|
|
from: '#app/composables/ssr'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['onNuxtReady'],
|
|
|
|
from: '#app/composables/ready'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['preloadComponents', 'prefetchComponents', 'preloadRouteComponents'],
|
|
|
|
from: '#app/composables/preload'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['abortNavigation', 'addRouteMiddleware', 'defineNuxtRouteMiddleware', 'setPageLayout', 'navigateTo', 'useRoute', 'useRouter'],
|
|
|
|
from: '#app/composables/router'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['isPrerendered', 'loadPayload', 'preloadPayload', 'definePayloadReducer', 'definePayloadReviver'],
|
|
|
|
from: '#app/composables/payload'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['getAppManifest', 'getRouteRules'],
|
|
|
|
from: '#app/composables/manifest'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['reloadNuxtApp'],
|
|
|
|
from: '#app/composables/chunk'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['useRequestURL'],
|
|
|
|
from: '#app/composables/url'
|
|
|
|
}
|
|
|
|
]
|
2022-03-11 08:09:11 +00:00
|
|
|
|
2023-10-30 21:05:02 +00:00
|
|
|
// This is a separate preset as we'll swap these out for import from `vue-router` itself in `pages` module
|
2022-11-10 13:52:04 +00:00
|
|
|
const routerPreset = defineUnimportPreset({
|
2023-10-30 21:05:02 +00:00
|
|
|
imports: ['onBeforeRouteLeave', 'onBeforeRouteUpdate'],
|
|
|
|
from: '#app/composables/router'
|
2022-11-10 13:52:04 +00:00
|
|
|
})
|
|
|
|
|
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',
|
2023-04-29 22:33:29 +00:00
|
|
|
'watchPostEffect',
|
|
|
|
'watchSyncEffect',
|
2022-03-11 08:09:11 +00:00
|
|
|
'isShallow',
|
|
|
|
|
|
|
|
// effect
|
|
|
|
'effect',
|
|
|
|
'effectScope',
|
|
|
|
'getCurrentScope',
|
|
|
|
'onScopeDispose',
|
|
|
|
|
|
|
|
// Component
|
|
|
|
'defineAsyncComponent',
|
2022-03-22 17:04:31 +00:00
|
|
|
'resolveComponent',
|
2022-03-11 08:09:11 +00:00
|
|
|
'getCurrentInstance',
|
|
|
|
'h',
|
|
|
|
'inject',
|
2023-05-11 08:37:32 +00:00
|
|
|
'hasInjectionContext',
|
2022-03-11 08:09:11 +00:00
|
|
|
'nextTick',
|
|
|
|
'provide',
|
2023-05-11 08:37:32 +00:00
|
|
|
'defineModel',
|
|
|
|
'defineOptions',
|
|
|
|
'defineSlots',
|
|
|
|
'mergeModels',
|
|
|
|
'toValue',
|
|
|
|
'useModel',
|
2022-03-11 08:09:11 +00:00
|
|
|
'useAttrs',
|
|
|
|
'useCssModule',
|
|
|
|
'useCssVars',
|
|
|
|
'useSlots',
|
|
|
|
'useTransitionState'
|
2023-02-07 14:00:11 +00:00
|
|
|
]
|
|
|
|
})
|
|
|
|
|
|
|
|
const vueTypesPreset = defineUnimportPreset({
|
|
|
|
from: 'vue',
|
|
|
|
type: true,
|
|
|
|
imports: [
|
|
|
|
'Component',
|
|
|
|
'ComponentPublicInstance',
|
|
|
|
'ComputedRef',
|
2023-06-07 19:49:19 +00:00
|
|
|
'ExtractPropTypes',
|
|
|
|
'ExtractPublicPropTypes',
|
2023-02-07 14:00:11 +00:00
|
|
|
'InjectionKey',
|
|
|
|
'PropType',
|
|
|
|
'Ref',
|
2023-06-07 19:49:19 +00:00
|
|
|
'MaybeRef',
|
|
|
|
'MaybeRefOrGetter',
|
2023-02-07 14:00:11 +00:00
|
|
|
'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,
|
2023-10-30 21:05:02 +00:00
|
|
|
...granularAppPresets,
|
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
|
|
|
]
|