2021-10-12 12:51:41 +00:00
|
|
|
<template>
|
2022-01-26 17:24:54 +00:00
|
|
|
<Suspense @resolve="onResolve">
|
2022-03-11 08:22:16 +00:00
|
|
|
<ErrorComponent v-if="error" :error="error" />
|
2022-11-24 12:24:14 +00:00
|
|
|
<IslandRendererer v-else-if="islandContext" :context="islandContext" />
|
2022-11-09 09:14:15 +00:00
|
|
|
<AppComponent v-else />
|
2021-10-12 12:51:41 +00:00
|
|
|
</Suspense>
|
|
|
|
</template>
|
2021-12-21 14:44:35 +00:00
|
|
|
|
2022-03-18 10:57:53 +00:00
|
|
|
<script setup>
|
2023-01-23 23:37:38 +00:00
|
|
|
import { defineAsyncComponent, onErrorCaptured, onServerPrefetch, provide } from 'vue'
|
2022-08-02 09:58:03 +00:00
|
|
|
import { callWithNuxt, isNuxtError, showError, useError, useRoute, useNuxtApp } from '#app'
|
2022-11-09 09:14:15 +00:00
|
|
|
import AppComponent from '#build/app-component.mjs'
|
2022-07-15 22:15:31 +00:00
|
|
|
|
2022-09-10 09:41:32 +00:00
|
|
|
const ErrorComponent = defineAsyncComponent(() => import('#build/error-component.mjs').then(r => r.default || r))
|
2022-11-24 12:24:14 +00:00
|
|
|
const IslandRendererer = process.server
|
|
|
|
? defineAsyncComponent(() => import('./island-renderer').then(r => r.default || r))
|
|
|
|
: () => null
|
2021-12-21 14:44:35 +00:00
|
|
|
|
2022-03-11 08:22:16 +00:00
|
|
|
const nuxtApp = useNuxtApp()
|
2022-10-08 14:18:57 +00:00
|
|
|
const onResolve = nuxtApp.deferHydration()
|
2022-03-11 08:22:16 +00:00
|
|
|
|
2022-08-02 09:58:03 +00:00
|
|
|
// Inject default route (outside of pages) as active route
|
|
|
|
provide('_route', useRoute())
|
|
|
|
|
2022-03-11 08:22:16 +00:00
|
|
|
// vue:setup hook
|
|
|
|
const results = nuxtApp.hooks.callHookWith(hooks => hooks.map(hook => hook()), 'vue:setup')
|
|
|
|
if (process.dev && results && results.some(i => i && 'then' in i)) {
|
|
|
|
console.error('[nuxt] Error in `vue:setup`. Callbacks must be synchronous.')
|
2021-12-21 14:44:35 +00:00
|
|
|
}
|
2022-03-11 08:22:16 +00:00
|
|
|
|
|
|
|
// error handling
|
|
|
|
const error = useError()
|
|
|
|
onErrorCaptured((err, target, info) => {
|
|
|
|
nuxtApp.hooks.callHook('vue:error', err, target, info).catch(hookError => console.error('[nuxt] Error in `vue:error` hook', hookError))
|
2022-07-21 14:29:03 +00:00
|
|
|
if (process.server || (isNuxtError(err) && (err.fatal || err.unhandled))) {
|
2023-01-23 11:13:21 +00:00
|
|
|
const p = callWithNuxt(nuxtApp, showError, [err])
|
|
|
|
onServerPrefetch(() => p)
|
2022-03-11 08:22:16 +00:00
|
|
|
}
|
|
|
|
})
|
2022-11-24 12:24:14 +00:00
|
|
|
|
|
|
|
// Component islands context
|
|
|
|
const { islandContext } = process.server && nuxtApp.ssrContext
|
2021-12-21 14:44:35 +00:00
|
|
|
</script>
|