mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-01 18:07:22 +00:00
feat(nuxt): add renderResult
to app:rendered
(#18610)
This commit is contained in:
parent
0bc38b7e19
commit
6bb0a849fe
@ -5,7 +5,7 @@ import type { RouteLocationNormalizedLoaded } from '#vue-router'
|
|||||||
import type { HookCallback, Hookable } from 'hookable'
|
import type { HookCallback, Hookable } from 'hookable'
|
||||||
import { createHooks } from 'hookable'
|
import { createHooks } from 'hookable'
|
||||||
import { getContext } from 'unctx'
|
import { getContext } from 'unctx'
|
||||||
import type { SSRContext } from 'vue-bundle-renderer/runtime'
|
import type { SSRContext, createRenderer } from 'vue-bundle-renderer/runtime'
|
||||||
import type { H3Event } from 'h3'
|
import type { H3Event } from 'h3'
|
||||||
import type { AppConfig, AppConfigInput, RuntimeConfig } from 'nuxt/schema'
|
import type { AppConfig, AppConfigInput, RuntimeConfig } from 'nuxt/schema'
|
||||||
import type { RenderResponse } from 'nitropack'
|
import type { RenderResponse } from 'nitropack'
|
||||||
@ -28,7 +28,7 @@ type NuxtMeta = {
|
|||||||
|
|
||||||
type HookResult = Promise<void> | void
|
type HookResult = Promise<void> | void
|
||||||
|
|
||||||
type AppRenderedContext = { ssrContext: NuxtApp['ssrContext'] }
|
type AppRenderedContext = { ssrContext: NuxtApp['ssrContext'], renderResult: null | Awaited<ReturnType<ReturnType<typeof createRenderer>['renderToString']>> }
|
||||||
export interface RuntimeNuxtHooks {
|
export interface RuntimeNuxtHooks {
|
||||||
'app:created': (app: App<Element>) => HookResult
|
'app:created': (app: App<Element>) => HookResult
|
||||||
'app:beforeMount': (app: App<Element>) => HookResult
|
'app:beforeMount': (app: App<Element>) => HookResult
|
||||||
|
@ -252,7 +252,7 @@ export default defineRenderHandler(async (event): Promise<Partial<RenderResponse
|
|||||||
await ssrContext.nuxt?.hooks.callHook('app:error', _err)
|
await ssrContext.nuxt?.hooks.callHook('app:error', _err)
|
||||||
throw _err
|
throw _err
|
||||||
})
|
})
|
||||||
await ssrContext.nuxt?.hooks.callHook('app:rendered', { ssrContext })
|
await ssrContext.nuxt?.hooks.callHook('app:rendered', { ssrContext, renderResult: _rendered })
|
||||||
|
|
||||||
if (ssrContext._renderResponse) { return ssrContext._renderResponse }
|
if (ssrContext._renderResponse) { return ssrContext._renderResponse }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user