vitrify 0.22.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/bin/cli.js +3 -3
  2. package/dist/bin/dev.js +3 -3
  3. package/dist/frameworks/vue/fastify-ssr-plugin.js +54 -18
  4. package/dist/frameworks/vue/prerender.js +4 -4
  5. package/dist/frameworks/vue/server.js +2 -1
  6. package/dist/hooks/index.js +1 -0
  7. package/dist/index.js +16 -5
  8. package/dist/plugins/index.js +1 -0
  9. package/dist/plugins/pinia/index.js +60 -0
  10. package/dist/plugins/quasar/index.js +10 -11
  11. package/dist/types/frameworks/vue/fastify-ssr-plugin.d.ts +6 -3
  12. package/dist/types/frameworks/vue/prerender.d.ts +3 -3
  13. package/dist/types/frameworks/vue/server.d.ts +4 -4
  14. package/dist/types/hooks/index.d.ts +2 -0
  15. package/dist/types/index.d.ts +2 -2
  16. package/dist/types/plugins/index.d.ts +1 -0
  17. package/dist/types/plugins/pinia/index.d.ts +5 -0
  18. package/dist/types/plugins/quasar/index.d.ts +2 -2
  19. package/dist/types/vitrify-config.d.ts +77 -13
  20. package/package.json +37 -26
  21. package/src/node/bin/cli.ts +13 -7
  22. package/src/node/bin/dev.ts +7 -4
  23. package/src/node/frameworks/vue/fastify-ssr-plugin.ts +81 -27
  24. package/src/node/frameworks/vue/prerender.ts +6 -6
  25. package/src/node/frameworks/vue/server.ts +8 -2
  26. package/src/node/hooks/index.ts +19 -0
  27. package/src/node/index.ts +21 -9
  28. package/src/node/plugins/index.ts +1 -0
  29. package/src/node/plugins/pinia/index.ts +99 -0
  30. package/src/node/plugins/quasar/index.ts +17 -19
  31. package/src/node/vitrify-config.ts +109 -22
  32. package/src/vite/vue/RootComponent.vue +3 -4
  33. package/src/vite/vue/main.ts +52 -22
  34. package/src/vite/vue/ssr/app.ts +3 -2
  35. package/src/vite/vue/ssr/entry-server.ts +22 -41
  36. package/src/vite/vue/ssr/prerender.ts +2 -2
@@ -1,28 +1,84 @@
1
1
  import type { Alias, UserConfig as ViteUserConfig, ViteDevServer } from 'vite';
2
2
  import type { ComponentInternalInstance } from '@vue/runtime-core';
3
- import type { FastifyInstance, FastifyServerOptions } from 'fastify';
3
+ import type { FastifyInstance, FastifyReply, FastifyRequest, FastifyServerOptions } from 'fastify';
4
4
  import type { VitePWAOptions } from 'vite-plugin-pwa';
5
5
  import type { Options as unpluginVueComponentsOptions } from 'unplugin-vue-components';
6
6
  import type { UserConfig as UnoCSSUserConfig } from '@unocss/core';
7
- import { VitrifyPlugin } from './plugins/index.js';
8
- export type BootFunction = ({ app, ssrContext, staticImports }: {
9
- app: any;
10
- ssrContext: Record<string, unknown>;
11
- staticImports: Record<string, any>;
7
+ import type { VitrifyPlugin } from './plugins/index.js';
8
+ import type { Router } from 'vue-router';
9
+ import type { App } from '@vue/runtime-core';
10
+ import type { Pinia } from 'pinia';
11
+ import type { _UseQueryEntryNodeValueSerialized } from '@pinia/colada/index.js';
12
+ export type SSRContext = {
13
+ req: FastifyRequest | {
14
+ headers: Record<string, unknown>;
15
+ url: string;
16
+ };
17
+ res: FastifyReply | Record<string, unknown>;
18
+ provide: Record<string, unknown>;
19
+ initialState: {
20
+ provide?: Record<string, unknown>;
21
+ pinia?: Record<string, unknown>;
22
+ piniaColada?: Record<string, _UseQueryEntryNodeValueSerialized>;
23
+ [key: string]: unknown;
24
+ };
25
+ pinia?: Pinia;
26
+ _modules: Set<unknown>;
27
+ _meta: Record<string, any>;
28
+ __qMetaList: unknown[];
29
+ /**
30
+ * Required for Quasar
31
+ */
32
+ onRenderedList: (() => unknown)[];
33
+ onRendered: (fn: () => unknown) => void;
34
+ /**
35
+ * Vue internals
36
+ */
37
+ modules?: Map<unknown, unknown>;
38
+ transports?: Record<string, unknown>;
39
+ [key: string]: unknown;
40
+ };
41
+ export type onAppCreatedHook = ({ app, router, ctx, initialState, ssrContext }: {
42
+ app: App;
43
+ router: Router;
44
+ ctx: {
45
+ pinia?: Pinia;
46
+ [key: string]: unknown;
47
+ };
48
+ initialState: {
49
+ provide?: Record<string, unknown>;
50
+ pinia?: Record<string, unknown>;
51
+ piniaColada?: Record<string, _UseQueryEntryNodeValueSerialized>;
52
+ [key: string]: unknown;
53
+ };
54
+ ssrContext?: SSRContext;
12
55
  }) => Promise<void> | void;
13
56
  export type OnBootHook = ({ app, ssrContext, staticImports }: {
14
- app: any;
15
- ssrContext: Record<string, unknown>;
57
+ app: App;
58
+ ssrContext: SSRContext;
16
59
  staticImports?: Record<string, any>;
17
60
  }) => Promise<void> | void;
18
- export type OnMountedHook = (instance: ComponentInternalInstance) => Promise<void> | void;
61
+ export type OnAppMountedHook = ({ instance }: {
62
+ instance: ComponentInternalInstance;
63
+ }) => Promise<void> | void;
19
64
  export type StaticImports = Record<string, string[]>;
20
- export type SsrFunction = (html: string, ssrContext: Record<string, any>) => string;
21
- export type OnRenderedHook = (html: string, ssrContext: Record<string, any>) => string;
65
+ export type OnSetupFile = URL;
22
66
  export type OnSetupHook = (fastify: FastifyInstance, options?: {
23
67
  vite?: ViteDevServer;
24
68
  }) => any;
25
- export type OnSetupFile = URL;
69
+ export type Render = (url: string, manifest: Record<string, unknown>, ssrContext: SSRContext, renderToString: (app: App, ctx?: Record<string, any>) => Promise<string>) => Promise<{
70
+ html: string;
71
+ preloadLinks: string;
72
+ app: App;
73
+ }>;
74
+ export type OnRenderedHook = ({ app, ssrContext }: {
75
+ app: App;
76
+ ssrContext?: SSRContext;
77
+ }) => Promise<void> | void;
78
+ export type OnTemplateRenderedHook = ({ html, ssrContext }: {
79
+ html: string;
80
+ ssrContext?: SSRContext;
81
+ }) => Promise<string> | string;
26
82
  export interface VitrifyConfig extends ViteUserConfig {
27
83
  vitrify?: {
28
84
  lang?: string;
@@ -46,7 +102,7 @@ export interface VitrifyConfig extends ViteUserConfig {
46
102
  /**
47
103
  * Functions which run in the onMounted hook of the app
48
104
  */
49
- onMounted?: OnMountedHook[];
105
+ onAppMounted?: OnAppMountedHook[];
50
106
  /**
51
107
  * Functions which run after initializing the app
52
108
  */
@@ -55,6 +111,14 @@ export interface VitrifyConfig extends ViteUserConfig {
55
111
  * Functions which run after rendering the app (SSR)
56
112
  */
57
113
  onRendered?: OnRenderedHook[];
114
+ /**
115
+ * Functions which run after rendering the template (SSR)
116
+ */
117
+ onTemplateRendered?: OnTemplateRenderedHook[];
118
+ /**
119
+ * Functions which run directly after initializing the application
120
+ */
121
+ onAppCreated?: onAppCreatedHook[];
58
122
  };
59
123
  /**
60
124
  * Global SASS variables
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitrify",
3
- "version": "0.22.0",
3
+ "version": "0.24.0",
4
4
  "license": "MIT",
5
5
  "author": "Stefan van Herwijnen",
6
6
  "description": "Vite as your Full Stack development tool",
@@ -33,6 +33,10 @@
33
33
  "./plugins": {
34
34
  "types": "./dist/types/plugins/index.d.ts",
35
35
  "import": "./dist/plugins/index.js"
36
+ },
37
+ "./hooks": {
38
+ "types": "./dist/types/hooks/index.d.ts",
39
+ "import": "./dist/hooks/index.d.ts"
36
40
  }
37
41
  },
38
42
  "engines": {
@@ -50,62 +54,69 @@
50
54
  "dependencies": {
51
55
  "@fastify/middie": "^9.0.3",
52
56
  "@fastify/one-line-logger": "^2.0.2",
53
- "@fastify/static": "^8.1.1",
54
- "@unocss/core": "^66.0.0",
55
- "@unocss/preset-uno": "^66.0.0",
56
- "@unocss/preset-web-fonts": "66.1.0-beta.13",
57
- "@unocss/preset-wind": "^66.0.0",
58
- "@vitejs/plugin-vue": "^5.2.3",
57
+ "@fastify/static": "^8.2.0",
58
+ "@unocss/core": "^66.1.3",
59
+ "@unocss/preset-uno": "^66.1.3",
60
+ "@unocss/preset-web-fonts": "66.1.3",
61
+ "@unocss/preset-wind": "^66.1.3",
62
+ "@vitejs/plugin-vue": "^5.2.4",
59
63
  "ajv": "^8.17.1",
60
64
  "animated-unocss": "^0.0.6",
61
65
  "cac": "^6.7.14",
62
66
  "chalk": "^5.4.1",
63
67
  "cross-env": "^7.0.3",
64
- "esbuild": "^0.25.3",
65
- "fastify": "^5.3.2",
68
+ "devalue": "^5.1.1",
69
+ "esbuild": "^0.25.5",
70
+ "fastify": "^5.3.3",
66
71
  "glob": "^11.0.2",
67
- "happy-dom": "^17.4.6",
72
+ "happy-dom": "^17.5.6",
68
73
  "is-port-reachable": "^4.0.0",
69
74
  "magic-string": "^0.30.17",
70
75
  "merge-deep": "^3.0.3",
71
76
  "readline": "^1.3.0",
72
- "rollup-plugin-visualizer": "^5.14.0",
73
- "sass": "1.87.0",
77
+ "rollup-plugin-visualizer": "^6.0.1",
78
+ "sass": "1.89.1",
79
+ "stringify-object": "^5.0.0",
74
80
  "ts-node": "^10.9.2",
75
- "unocss": "^66.0.0",
76
- "unplugin-vue-components": "^28.5.0",
77
- "vite": "^6.3.4",
81
+ "unocss": "^66.1.3",
82
+ "unplugin-vue-components": "^28.7.0",
83
+ "vite": "^6.3.5",
78
84
  "vite-plugin-pwa": "^1.0.0",
79
85
  "vitefu": "^1.0.6",
80
- "vitest": "^3.1.2",
86
+ "vitest": "^3.2.0",
81
87
  "workbox-window": "^7.3.0"
82
88
  },
83
89
  "devDependencies": {
84
90
  "@iconify-json/mdi": "^1.2.3",
85
- "@quasar/extras": "^1.16.17",
91
+ "@pinia/colada": "^0.16.1",
92
+ "@quasar/extras": "^1.17.0",
86
93
  "@quasar/quasar-ui-qmarkdown": "^2.0.5",
87
94
  "@quasar/quasar-ui-qmediaplayer": "^2.0.0-beta.0",
88
95
  "@types/connect": "^3.4.38",
89
96
  "@types/glob": "^8.1.0",
90
97
  "@types/merge-deep": "^3.0.3",
91
- "@types/node": "^22.15.3",
98
+ "@types/node": "^22.15.29",
99
+ "@types/stringify-object": "^4.0.5",
92
100
  "@types/ws": "^8.18.1",
93
- "@unocss/preset-icons": "^66.0.0",
94
- "@vue/runtime-core": "^3.5.13",
95
- "beasties": "^0.3.3",
101
+ "@unocss/preset-icons": "^66.1.3",
102
+ "@vue/runtime-core": "^3.5.16",
103
+ "beasties": "^0.3.4",
96
104
  "css": "^3.0.0",
97
105
  "css-to-tailwind-translator": "^1.2.8",
106
+ "pinia": "^3.0.2",
98
107
  "quasar": "^2.18.1",
99
- "rollup": "^4.40.1",
108
+ "rollup": "^4.41.1",
100
109
  "typescript": "^5.8.3",
101
- "vue": "^3.5.13",
110
+ "vue": "^3.5.16",
102
111
  "vue-router": "^4.5.1"
103
112
  },
104
113
  "peerDependencies": {
105
- "@fastify/static": "^8.1.1",
106
- "fastify": "^5.3.2",
114
+ "@fastify/static": "^8.2.0",
115
+ "@pinia/colada": "^0.16.1",
116
+ "fastify": "^5.3.3",
117
+ "pinia": "^3.0.2",
107
118
  "quasar": "^2.18.1",
108
- "vue": "^3.5.13",
119
+ "vue": "^3.5.16",
109
120
  "vue-router": "^4.5.1"
110
121
  },
111
122
  "publishConfig": {
@@ -24,7 +24,6 @@ cli
24
24
  const { build } = await import('./build.js')
25
25
  let appDir: URL
26
26
  let prerender
27
- let onRendered
28
27
  if (options.appDir) {
29
28
  if (options.appDir.slice(-1) !== '/') options.appDir += '/'
30
29
  appDir = new URL(`file://${options.appDir}`)
@@ -90,11 +89,17 @@ cli
90
89
  new URL('ssr/server/prerender.mjs', baseOutDir).pathname
91
90
  ))
92
91
 
93
- const { template, manifest, render, getRoutes, onRendered } =
94
- await loadSSRAssets({
95
- mode: 'ssg',
96
- distDir: baseOutDir
97
- })
92
+ const {
93
+ template,
94
+ manifest,
95
+ render,
96
+ getRoutes,
97
+ onRendered,
98
+ onTemplateRendered
99
+ } = await loadSSRAssets({
100
+ mode: 'ssg',
101
+ distDir: baseOutDir
102
+ })
98
103
  const routes = await getRoutes()
99
104
 
100
105
  prerender({
@@ -103,7 +108,8 @@ cli
103
108
  manifest,
104
109
  render,
105
110
  routes,
106
- onRendered
111
+ onRendered,
112
+ onTemplateRendered
107
113
  })
108
114
  break
109
115
  default:
@@ -5,7 +5,10 @@ import type { Server } from 'net'
5
5
  import fastify from 'fastify'
6
6
  import type { FastifyServerOptions } from 'fastify'
7
7
  import { fastifySsrPlugin } from '../frameworks/vue/fastify-ssr-plugin.js'
8
- import type { OnRenderedHook, VitrifyConfig } from '../vitrify-config.js'
8
+ import type {
9
+ OnTemplateRenderedHook,
10
+ VitrifyConfig
11
+ } from '../vitrify-config.js'
9
12
  import isPortReachable from 'is-port-reachable'
10
13
  import { exitLogs } from '../helpers/logger.js'
11
14
  import { fileURLToPath } from 'url'
@@ -138,7 +141,7 @@ export async function createServer({
138
141
  let setup
139
142
  let app: FastifyInstance | undefined
140
143
  let server: Server
141
- let onRendered: OnRenderedHook[]
144
+ let onTemplateRendered: OnTemplateRenderedHook[]
142
145
  let vitrifyConfig: VitrifyConfig
143
146
 
144
147
  console.log(`Development mode: ${ssr ? ssr : 'csr'}`)
@@ -149,7 +152,7 @@ export async function createServer({
149
152
  : fileURLToPath(new URL(`src/vite/${framework}/ssr/app.ts`, cliDir))
150
153
 
151
154
  const environment = vite.environments.ssr
152
- ;({ setup, onRendered, vitrifyConfig } =
155
+ ;({ setup, onTemplateRendered, vitrifyConfig } =
153
156
  // @ts-expect-error missing types
154
157
  await environment.runner.import(entryUrl))
155
158
  // console.log(module)
@@ -177,7 +180,7 @@ export async function createServer({
177
180
  await app.register(fastifySsrPlugin, {
178
181
  appDir,
179
182
  mode: 'development',
180
- onRendered,
183
+ onTemplateRendered,
181
184
  host
182
185
  })
183
186
  }
@@ -8,8 +8,14 @@ import {
8
8
  appendToHead
9
9
  } from '../../helpers/utils.js'
10
10
  import type { ViteDevServer } from 'vite'
11
- import type { OnRenderedHook } from '../../vitrify-config.js'
11
+ import type {
12
+ OnRenderedHook,
13
+ OnTemplateRenderedHook,
14
+ SSRContext
15
+ } from '../../vitrify-config.js'
12
16
  import { getAppDir } from '../../app-urls.js'
17
+ import { stringify } from 'devalue'
18
+ import stringifyObject from 'stringify-object'
13
19
 
14
20
  type ProvideFn = (
15
21
  req: FastifyRequest,
@@ -23,6 +29,7 @@ export interface FastifySsrOptions {
23
29
  vite?: ViteDevServer
24
30
  // frameworkDir?: URL
25
31
  onRendered?: OnRenderedHook[]
32
+ onTemplateRendered?: OnTemplateRenderedHook[]
26
33
  appDir?: URL
27
34
  publicDir?: URL
28
35
  mode?: string
@@ -92,11 +99,12 @@ const fastifySsrPlugin: FastifyPluginAsync<FastifySsrOptions> = async (
92
99
  }
93
100
 
94
101
  const html = await renderHtml({
95
- request: req,
96
- reply: res,
102
+ req,
103
+ res,
97
104
  url: url ?? '/',
98
105
  provide,
99
106
  onRendered: options.onRendered,
107
+ onTemplateRendered: options.onTemplateRendered,
100
108
  template,
101
109
  manifest,
102
110
  render
@@ -127,16 +135,18 @@ const fastifySsrPlugin: FastifyPluginAsync<FastifySsrOptions> = async (
127
135
  const url = req.raw.url?.replace(options.baseUrl!, '/')
128
136
  const provide = options.provide ? await options.provide(req, res) : {}
129
137
 
130
- const { template, manifest, render, onRendered } = await loadSSRAssets({
131
- distDir: new URL('./dist/', options.appDir)
132
- })
138
+ const { template, manifest, render, onRendered, onTemplateRendered } =
139
+ await loadSSRAssets({
140
+ distDir: new URL('./dist/', options.appDir)
141
+ })
133
142
 
134
143
  const html = await renderHtml({
135
- request: req,
136
- reply: res,
144
+ req,
145
+ res,
137
146
  url: url ?? '/',
138
147
  provide,
139
148
  onRendered,
149
+ onTemplateRendered,
140
150
  template,
141
151
  manifest,
142
152
  render
@@ -168,34 +178,77 @@ const renderTemplate = ({
168
178
 
169
179
  const renderHtml = async (options: {
170
180
  url: string
171
- request: FastifyRequest | { headers: Record<string, unknown>; url: string }
172
- reply: FastifyReply | Record<string, unknown>
181
+ req: FastifyRequest | { headers: Record<string, unknown>; url: string }
182
+ res: FastifyReply | Record<string, unknown>
173
183
  provide: Record<string, unknown>
174
184
  onRendered?: OnRenderedHook[]
185
+ onTemplateRendered?: OnTemplateRenderedHook[]
175
186
  template: string
176
187
  manifest: Record<string, unknown>
177
188
  render: any
178
189
  }) => {
179
- const ssrContext: Record<string, any> = {
180
- req: options.request,
181
- res: options.reply,
182
- provide: options.provide
190
+ const ssrContextOnRendered: (() => unknown)[] = []
191
+ const ssrContext: SSRContext = {
192
+ req: options.req,
193
+ res: options.res,
194
+ provide: options.provide,
195
+ initialState: {},
196
+ _modules: new Set(),
197
+ _meta: {},
198
+ __qMetaList: [],
199
+ onRenderedList: ssrContextOnRendered,
200
+ onRendered: (fn: () => unknown) => {
201
+ ssrContextOnRendered.push(fn)
202
+ }
183
203
  }
184
204
 
185
205
  const onRendered = options.onRendered ?? []
206
+ const onTemplateRendered = options.onTemplateRendered ?? []
186
207
 
187
- const [appHtml, preloadLinks] = await options.render(
188
- options.url,
189
- options.manifest,
190
- ssrContext
191
- )
208
+ const {
209
+ html: appHtml,
210
+ preloadLinks,
211
+ app
212
+ } = await options.render(options.url, options.manifest, ssrContext)
213
+
214
+ if (ssrContextOnRendered?.length) {
215
+ for (const ssrFunction of ssrContextOnRendered) {
216
+ await ssrFunction()
217
+ }
218
+ }
219
+
220
+ if (onRendered?.length) {
221
+ for (const ssrFunction of onRendered) {
222
+ await ssrFunction({ app, ssrContext })
223
+ }
224
+ }
192
225
 
193
- if (!ssrContext.initialState) ssrContext.initialState = {}
226
+ // if (!ssrContext.initialState) ssrContext.initialState = {}
194
227
  ssrContext.initialState.provide = options.provide
195
228
 
229
+ const ssrContextInitialStateStringified: Record<
230
+ keyof SSRContext['initialState'],
231
+ string
232
+ > = {}
233
+ for (const key in ssrContext.initialState) {
234
+ if (key === 'provide') {
235
+ ssrContextInitialStateStringified[key] = JSON.stringify(
236
+ ssrContext.initialState.provide
237
+ )
238
+ } else if (key === 'piniaColada') {
239
+ ssrContextInitialStateStringified[key] = JSON.stringify(
240
+ ssrContext.initialState.piniaColada
241
+ )
242
+ } else {
243
+ ssrContextInitialStateStringified[key] = stringify(
244
+ ssrContext.initialState[key]
245
+ )
246
+ }
247
+ }
248
+
196
249
  const initialStateScript = `
197
250
  <script>
198
- __INITIAL_STATE__ = '${JSON.stringify(ssrContext.initialState)}'
251
+ __INITIAL_STATE__ = ${stringifyObject(ssrContextInitialStateStringified)}
199
252
  </script>`
200
253
 
201
254
  let html = renderTemplate({
@@ -205,9 +258,9 @@ const renderHtml = async (options: {
205
258
  preloadLinks
206
259
  })
207
260
 
208
- if (onRendered?.length) {
209
- for (const ssrFunction of onRendered) {
210
- html = ssrFunction(html, ssrContext)
261
+ if (onTemplateRendered?.length) {
262
+ for (const ssrFunction of onTemplateRendered) {
263
+ html = await ssrFunction({ html, ssrContext })
211
264
  }
212
265
  }
213
266
 
@@ -229,7 +282,7 @@ const loadSSRAssets = async (
229
282
  const baseOutDir = distDir || new URL('dist/', appDir)
230
283
 
231
284
  let templatePath, manifestPath, entryServerPath
232
- const onRenderedPath = fileURLToPath(
285
+ const vitrifyHooksPath = fileURLToPath(
233
286
  new URL('ssr/server/virtual_vitrify-hooks.mjs', baseOutDir)
234
287
  )
235
288
  if (mode === 'ssg') {
@@ -254,14 +307,15 @@ const loadSSRAssets = async (
254
307
  const manifest = JSON.parse(readFileSync(manifestPath).toString())
255
308
  const entryServer = await import(entryServerPath)
256
309
  const { render, getRoutes } = entryServer
257
- const onRendered = (await import(onRenderedPath)).onRendered
310
+ const { onTemplateRendered, onRendered } = await import(vitrifyHooksPath)
258
311
 
259
312
  return {
260
313
  template,
261
314
  manifest,
262
315
  render,
263
316
  getRoutes,
264
- onRendered
317
+ onRendered,
318
+ onTemplateRendered
265
319
  }
266
320
  } catch (e) {
267
321
  console.error(e)
@@ -1,5 +1,5 @@
1
1
  import { existsSync, promises as fs, mkdirSync } from 'fs'
2
- import type { OnRenderedHook } from 'src/node/vitrify-config.js'
2
+ import type { OnTemplateRenderedHook } from 'src/node/vitrify-config.js'
3
3
  import { routesToPaths } from '../../helpers/routes.js'
4
4
  import { renderHtml } from './fastify-ssr-plugin.js'
5
5
  import { type RouteRecordRaw } from 'vue-router'
@@ -10,14 +10,14 @@ export const prerender = async ({
10
10
  manifest,
11
11
  render,
12
12
  routes,
13
- onRendered
13
+ onTemplateRendered
14
14
  }: {
15
15
  outDir: string
16
16
  template: string
17
17
  manifest: Record<string, unknown>
18
18
  render: unknown
19
19
  routes: RouteRecordRaw[]
20
- onRendered: OnRenderedHook[]
20
+ onTemplateRendered: OnTemplateRenderedHook[]
21
21
  }) => {
22
22
  const promises = []
23
23
  const paths = routesToPaths(routes).filter(
@@ -49,10 +49,10 @@ export const prerender = async ({
49
49
  manifest,
50
50
  provide: {},
51
51
  render,
52
- request: { headers: {}, url },
53
- reply: {},
52
+ req: { headers: {}, url },
53
+ res: {},
54
54
  template,
55
- onRendered
55
+ onTemplateRendered
56
56
  })
57
57
  html = await beasties.process(html)
58
58
 
@@ -1,6 +1,9 @@
1
- import type { FastifyInstance } from 'fastify'
2
1
  import fastify from 'fastify'
3
- import type { OnRenderedHook, OnSetupHook } from '../../vitrify-config.js'
2
+ import type {
3
+ OnTemplateRenderedHook,
4
+ OnSetupHook,
5
+ OnRenderedHook
6
+ } from '../../vitrify-config.js'
4
7
  import type { FastifyCsrPlugin } from './fastify-csr-plugin.js'
5
8
  import type { FastifySsrPlugin } from './fastify-ssr-plugin.js'
6
9
 
@@ -10,6 +13,7 @@ export const createApp = ({
10
13
  baseUrl,
11
14
  fastifyPlugin,
12
15
  onRendered,
16
+ onTemplateRendered,
13
17
  vitrifyDir,
14
18
  mode
15
19
  }: {
@@ -18,6 +22,7 @@ export const createApp = ({
18
22
  baseUrl?: string
19
23
  fastifyPlugin: FastifySsrPlugin | FastifyCsrPlugin
20
24
  onRendered?: OnRenderedHook[]
25
+ onTemplateRendered?: OnTemplateRenderedHook[]
21
26
  vitrifyDir?: URL
22
27
  mode: string
23
28
  }) => {
@@ -35,6 +40,7 @@ export const createApp = ({
35
40
  appDir,
36
41
  vitrifyDir,
37
42
  onRendered,
43
+ onTemplateRendered,
38
44
  mode
39
45
  })
40
46
 
@@ -0,0 +1,19 @@
1
+ import type {
2
+ OnBootHook,
3
+ onAppCreatedHook,
4
+ OnAppMountedHook,
5
+ OnRenderedHook,
6
+ OnTemplateRenderedHook,
7
+ OnSetupFile,
8
+ OnSetupHook
9
+ } from '../vitrify-config.js'
10
+
11
+ export {
12
+ OnBootHook,
13
+ onAppCreatedHook,
14
+ OnAppMountedHook,
15
+ OnRenderedHook,
16
+ OnTemplateRenderedHook,
17
+ OnSetupFile,
18
+ OnSetupHook
19
+ }