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']
|
|
|
|
},
|
|
|
|
{
|
2024-01-18 09:59:59 +00:00
|
|
|
imports: ['useNuxtApp', 'tryUseNuxtApp', 'defineNuxtPlugin', 'definePayloadPlugin', 'useRuntimeConfig', 'defineAppConfig'],
|
2023-10-30 21:05:02 +00:00
|
|
|
from: '#app/nuxt'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['requestIdleCallback', 'cancelIdleCallback'],
|
|
|
|
from: '#app/compat/idle-callback'
|
|
|
|
},
|
2024-01-19 22:38:15 +00:00
|
|
|
{
|
|
|
|
imports: ['setInterval'],
|
|
|
|
from: '#app/compat/interval'
|
|
|
|
},
|
2023-10-30 21:05:02 +00:00
|
|
|
{
|
|
|
|
imports: ['useAppConfig', 'updateAppConfig'],
|
|
|
|
from: '#app/config'
|
|
|
|
},
|
|
|
|
{
|
2023-12-16 11:09:41 +00:00
|
|
|
imports: ['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'
|
|
|
|
},
|
2023-12-19 11:00:11 +00:00
|
|
|
{
|
|
|
|
imports: ['callOnce'],
|
|
|
|
from: '#app/composables/once'
|
|
|
|
},
|
2023-10-30 21:05:02 +00:00
|
|
|
{
|
|
|
|
imports: ['useState', 'clearNuxtState'],
|
|
|
|
from: '#app/composables/state'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['clearError', 'createError', 'isNuxtError', 'showError', 'useError'],
|
|
|
|
from: '#app/composables/error'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['useFetch', 'useLazyFetch'],
|
|
|
|
from: '#app/composables/fetch'
|
|
|
|
},
|
|
|
|
{
|
2024-01-29 10:37:32 +00:00
|
|
|
imports: ['useCookie', 'refreshCookie'],
|
2023-10-30 21:05:02 +00:00
|
|
|
from: '#app/composables/cookie'
|
|
|
|
},
|
|
|
|
{
|
2023-12-16 09:08:56 +00:00
|
|
|
imports: ['prerenderRoutes', 'useRequestHeader', 'useRequestHeaders', 'useRequestEvent', 'useRequestFetch', 'setResponseStatus'],
|
2023-10-30 21:05:02 +00:00
|
|
|
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'
|
|
|
|
},
|
2023-12-19 10:18:10 +00:00
|
|
|
{
|
|
|
|
imports: ['useLoadingIndicator'],
|
|
|
|
from: '#app/composables/loading-indicator'
|
|
|
|
},
|
2023-10-30 21:05:02 +00:00
|
|
|
{
|
|
|
|
imports: ['getAppManifest', 'getRouteRules'],
|
|
|
|
from: '#app/composables/manifest'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['reloadNuxtApp'],
|
|
|
|
from: '#app/composables/chunk'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['useRequestURL'],
|
|
|
|
from: '#app/composables/url'
|
2024-01-30 09:10:13 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
imports: ['useId'],
|
|
|
|
from: '#app/composables/id'
|
2023-10-30 21:05:02 +00:00
|
|
|
}
|
|
|
|
]
|
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
|
2023-12-16 11:09:41 +00:00
|
|
|
'defineComponent',
|
2022-03-11 08:09:11 +00:00
|
|
|
'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
|
|
|
]
|