vitrify 0.2.5 → 0.3.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.
package/src/node/index.ts CHANGED
@@ -2,7 +2,6 @@ import vuePlugin from '@vitejs/plugin-vue'
2
2
  import type { InlineConfig, UserConfig } from 'vite'
3
3
  import { mergeConfig } from 'vite'
4
4
  import { readFileSync } from 'fs'
5
- import { QuasarPlugin } from './plugins/quasar.js'
6
5
  import builtinModules from 'builtin-modules'
7
6
  import { resolve } from 'import-meta-resolve'
8
7
  import type {
@@ -10,11 +9,12 @@ import type {
10
9
  BootFunction,
11
10
  OnMountedHook,
12
11
  VitrifyConfig,
13
- SsrFunction
12
+ OnRenderedHook,
13
+ OnBootHook,
14
+ OnSetupHook
14
15
  } from './vitrify-config.js'
15
16
  import type { VitrifyContext } from './bin/run.js'
16
17
  import type { VitrifyPlugin } from './plugins/index.js'
17
- import type { FastifyInstance } from 'fastify'
18
18
  import { getPkgJsonDir } from './app-urls.js'
19
19
 
20
20
  const serverModules = ['fastify', 'middie']
@@ -27,10 +27,7 @@ const configPluginMap: Record<string, () => Promise<VitrifyPlugin>> = {
27
27
  const manualChunks = ['prerender', 'fastify-ssr-plugin', 'server']
28
28
 
29
29
  export const VIRTUAL_MODULES = [
30
- 'virtual:fastify-setup',
31
- 'virtual:boot-functions',
32
- 'virtual:ssr-functions',
33
- 'virtual:on-mounted-hooks',
30
+ 'virtual:vitrify-hooks',
34
31
  'virtual:global-css',
35
32
  'virtual:static-imports'
36
33
  ]
@@ -61,16 +58,8 @@ export const baseConfig = async ({
61
58
  const cwd = getCwd()
62
59
  const cliDir = getCliDir()
63
60
  const cliViteDir = getCliViteDir(cliDir)
64
- // const {
65
- // appDir: tempAppDir,
66
- // cliDir,
67
- // cliViteDir,
68
- // srcDir
69
- // } = await import('./app-urls.js')
70
- // const cwd = appDir || tempAppDir
71
61
  const frameworkDir = new URL(`${framework}/`, cliViteDir)
72
62
 
73
- // const localPackages = ['vue', 'vue-router', 'quasar']
74
63
  const localPackages = ['vue', 'vue-router']
75
64
  const cliPackages = ['vitest']
76
65
  const packageUrls: Record<string, URL> = {}
@@ -87,18 +76,6 @@ export const baseConfig = async ({
87
76
  )
88
77
  })()
89
78
 
90
- // if (appDir) {
91
- // srcDir = new URL('src/', appDir);
92
- // quasarDir = new URL(await resolve('quasar/', appDir.href));
93
- // ({ appDir: cwd, cliDir } = await import('./app-urls.js'))
94
- // } else {
95
- // ({ appDir, cliDir, srcDir, quasarDir } = await import('./app-urls.js'))
96
- // cwd = appDir
97
- // }
98
- // vueDir = new URL('./', await resolve('vue', appDir.href));
99
- // vueRouterDir = new URL('../', await resolve('vue-router', appDir.href));
100
- // vitestDir = new URL('../', await resolve('vitest', cliDir.href));
101
-
102
79
  if (!publicDir) publicDir = new URL('public/', appDir)
103
80
  /**
104
81
  * TODO:Perform some manual check if command is run inside a Quasar Project
@@ -124,9 +101,6 @@ export const baseConfig = async ({
124
101
  })
125
102
  )
126
103
 
127
- const fastifySetup =
128
- vitrifyConfig.vitrify?.fastify?.setup || ((fastify: FastifyInstance) => {})
129
-
130
104
  const ssrTransformCustomDir = () => {
131
105
  return {
132
106
  props: [],
@@ -147,9 +121,10 @@ export const baseConfig = async ({
147
121
  }
148
122
  }
149
123
 
150
- let bootFunctions: BootFunction[]
151
- let ssrFunctions: SsrFunction[]
124
+ let onBootHooks: OnBootHook[]
125
+ let onRenderedHooks: OnRenderedHook[]
152
126
  let onMountedHooks: OnMountedHook[]
127
+ let onSetupHooks: OnSetupHook[]
153
128
  let globalCss: string[]
154
129
  let staticImports: StaticImports
155
130
  let sassVariables: Record<string, string>
@@ -177,18 +152,14 @@ export const baseConfig = async ({
177
152
  }
178
153
  }),
179
154
  ...frameworkPlugins,
180
- // await QuasarPlugin({
181
- // ssr: ssr,
182
- // pwa: pwa
183
- // // quasarDir: packageUrls.quasar
184
- // }),
185
155
  {
186
156
  name: 'vitrify-setup',
187
157
  enforce: 'post',
188
158
  config: async (config: VitrifyConfig, env) => {
189
- bootFunctions = config.vitrify?.bootFunctions || []
190
- ssrFunctions = config.vitrify?.ssrFunctions || []
159
+ onBootHooks = config.vitrify?.hooks?.onBoot || []
160
+ onRenderedHooks = config.vitrify?.hooks?.onRendered || []
191
161
  onMountedHooks = config.vitrify?.hooks?.onMounted || []
162
+ onSetupHooks = config?.vitrify?.hooks?.onSetup || []
192
163
  globalCss = config.vitrify?.globalCss || []
193
164
  staticImports = config.vitrify?.staticImports || {}
194
165
  sassVariables = config.vitrify?.sass?.variables || {}
@@ -221,20 +192,19 @@ export const baseConfig = async ({
221
192
  return
222
193
  },
223
194
  load(id) {
224
- if (id === 'virtual:fastify-setup') {
225
- return `export const setup = ${String(fastifySetup)}`
226
- } else if (id === 'virtual:boot-functions') {
227
- return `export default [${bootFunctions
228
- .map((fn) => `${String(fn)}`)
229
- .join(', ')}]`
230
- } else if (id === 'virtual:ssr-functions') {
231
- return `export default [${ssrFunctions
232
- .map((fn) => `${String(fn)}`)
233
- .join(', ')}]`
234
- } else if (id === 'virtual:on-mounted-hooks') {
235
- return `export default [${onMountedHooks
195
+ if (id === 'virtual:vitrify-hooks') {
196
+ return `export const onBoot = [${onBootHooks
236
197
  .map((fn) => `${String(fn)}`)
237
- .join(', ')}]`
198
+ .join(', ')}]
199
+ export const onMounted = [${onMountedHooks
200
+ .map((fn) => `${String(fn)}`)
201
+ .join(', ')}]
202
+ export const onRendered = [${onRenderedHooks
203
+ .map((fn) => `${String(fn)}`)
204
+ .join(', ')}]
205
+ export const onSetup = [${onSetupHooks
206
+ .map((fn) => `${String(fn)}`)
207
+ .join(', ')}]`
238
208
  } else if (id === 'virtual:global-css') {
239
209
  return `${globalCss.map((css) => `import '${css}'`).join('\n')}`
240
210
  } else if (id === 'virtual:static-imports') {
@@ -307,9 +277,6 @@ export const baseConfig = async ({
307
277
  { find: 'cwd', replacement: cwd.pathname },
308
278
  { find: 'boot', replacement: new URL('boot/', srcDir).pathname },
309
279
  { find: 'assets', replacement: new URL('assets/', srcDir).pathname },
310
- // ...Object.entries(packageUrls).map(([key, value]) => ({
311
- // find: key, replacement: value.pathname
312
- // })),
313
280
  { find: 'vue', replacement: packageUrls['vue'].pathname },
314
281
  { find: 'vue-router', replacement: packageUrls['vue-router'].pathname },
315
282
  { find: 'vitrify', replacement: cliDir.pathname }
@@ -326,7 +293,6 @@ export const baseConfig = async ({
326
293
  vitrify: {
327
294
  productName,
328
295
  urls: {
329
- // @ts-ignore
330
296
  app: appDir,
331
297
  cli: cliDir,
332
298
  src: srcDir,
@@ -380,13 +346,6 @@ export const baseConfig = async ({
380
346
  }
381
347
  }
382
348
  },
383
- // css: {
384
- // preprocessorOptions: {
385
- // sass: {
386
- // additionalData: sass ? [...sass].join('\n') : undefined
387
- // }
388
- // }
389
- // },
390
349
  ssr: {
391
350
  // Create a SSR bundle
392
351
  noExternal: [
@@ -4,6 +4,7 @@ import Components from 'unplugin-vue-components/vite'
4
4
  // import { prepareQuasarConf } from './quasar-conf-file.js'
5
5
  import type {
6
6
  BootFunction,
7
+ OnBootHook,
7
8
  OnMountedHook,
8
9
  VitrifyConfig
9
10
  } from '../vitrify-config.js'
@@ -75,43 +76,12 @@ export const injectSsrContext = (
75
76
  }${end}${ssrContext._meta.bodyTags || ''}`
76
77
  })
77
78
 
78
- // export interface Configuration {
79
- // ssr?: 'server' | 'client' | 'ssg' | false
80
- // }
81
-
82
79
  export const QuasarPlugin: VitrifyPlugin = async ({
83
80
  ssr = false,
84
81
  pwa = false
85
82
  }): Promise<Plugin[]> => {
86
- // const extraPlugins: Plugin[] = []
87
- // const ctx = {
88
- // prod: process.env.MODE === 'production',
89
- // dev: process.env.MODE === 'development',
90
- // mode: {
91
- // ssr: !!ssr,
92
- // pwa: !!pwa
93
- // }
94
- // }
95
-
96
- // let bootFilePaths: Record<string, any> = {}
97
- // let components: string[] = []
98
83
  let plugins: string[] = []
99
- // let css: string[] = []
100
- let extras: string[] = []
101
84
  return [
102
- // {
103
- // name: 'legacy-support',
104
- // enforce: 'pre',
105
- // transform (code, id) {
106
- // /**
107
- // * ESM does not resolve an import to .default when there are multiple exports. The following is required to make the VuePlugin import of QCalendar work.
108
- // */
109
- // if (code.includes('app.use(VuePlugin)')) {
110
- // code = code.replace(/app\.use\(VuePlugin\)/g, `app.use(VuePlugin.install ? VuePlugin : VuePlugin.default)`)
111
- // }
112
- // return code
113
- // }
114
- // },
115
85
  Components({
116
86
  resolvers: [QuasarResolver()]
117
87
  }),
@@ -143,10 +113,8 @@ export const QuasarPlugin: VitrifyPlugin = async ({
143
113
  }
144
114
  ]
145
115
 
146
- const bootFunctions: BootFunction[] = [
116
+ const onBootHooks: OnBootHook[] = [
147
117
  async ({ app, ssrContext, staticImports }) => {
148
- // @ts-ignore
149
- // const quasarVuePlugin = (await import('quasar/vue-plugin')).default
150
118
  // @ts-ignore
151
119
  const quasarPlugins = await import('virtual:quasar-plugins')
152
120
  // @ts-ignore
@@ -166,14 +134,14 @@ export const QuasarPlugin: VitrifyPlugin = async ({
166
134
  return {
167
135
  vitrify: {
168
136
  urls,
169
- bootFunctions,
170
- ssrFunctions: [injectSsrContext],
171
137
  globalCss,
172
138
  staticImports: {
173
139
  quasar: ['Quasar']
174
140
  },
175
141
  hooks: {
176
- onMounted: onMountedHooks
142
+ onBoot: onBootHooks,
143
+ onMounted: onMountedHooks,
144
+ onRendered: [injectSsrContext]
177
145
  },
178
146
  sass: {
179
147
  additionalData: [`@import 'quasar/src/css/index.sass'`]
@@ -185,22 +153,7 @@ export const QuasarPlugin: VitrifyPlugin = async ({
185
153
  {
186
154
  name: 'vite-plugin-quasar',
187
155
  enforce: 'post',
188
- // transformIndexHtml: {
189
- // enforce: 'post',
190
- // transform: (html) => {
191
- // return html.replace(
192
- // '<!--product-name-->',
193
- // productName
194
- // )
195
- // }
196
- // },
197
156
  config: async (config: VitrifyConfig, env) => {
198
- // let appDir: URL
199
- // let cliDir: URL
200
- // let cwd: URL
201
- // let quasarDir: URL
202
- // let quasarConf: QuasarConf | undefined
203
-
204
157
  const { quasar: quasarConf, vitrify: { urls } = {} } = config
205
158
 
206
159
  const quasarPkgJsonPath = new URL(
@@ -211,33 +164,6 @@ export const QuasarPlugin: VitrifyPlugin = async ({
211
164
  readFileSync(quasarPkgJsonPath, { encoding: 'utf-8' })
212
165
  )
213
166
 
214
- // if (quasarConf?.boot) {
215
- // bootFilePaths = (quasarConf.boot as (Record<string, any> | string)[])
216
- // .filter(entry => {
217
- // if (typeof entry === 'object') return (entry.server && (ssr === 'server'))
218
- // else if (entry !== '') return true
219
- // })
220
- // .map(entry => {
221
- // if (typeof entry === 'string') return entry
222
- // else if (typeof entry === 'object') return entry.path
223
- // })
224
- // .reduce((acc, entry) => {
225
- // if (entry[0] === '~') {
226
- // const split = entry.substring(1).split('/')
227
- // const name = split[0].replace(/[|&;$%@"<>()+,]/g, "");
228
- // acc[name] = {
229
- // path: new URL(`node_modules/${entry.substring(1)}`, urls?.app).pathname
230
- // }
231
- // } else {
232
- // const name = entry.split('.')[0]
233
- // acc[name] = {
234
- // path: `src/boot/${entry}`
235
- // }
236
- // }
237
- // return acc
238
- // }, {})
239
- // }
240
-
241
167
  /**
242
168
  * All components should have been auto-imported
243
169
  */
@@ -249,14 +175,6 @@ export const QuasarPlugin: VitrifyPlugin = async ({
249
175
  plugins = quasarConf?.framework.plugins
250
176
  }
251
177
 
252
- // css = (quasarConf?.css || []).map((v => {
253
- // if (v[0] === '~') {
254
- // return v.slice(1)
255
- // }
256
- // return v
257
- // })).map((v) => `@import '${v}'`)
258
- extras = quasarConf?.extras || []
259
-
260
178
  return {
261
179
  resolve: {
262
180
  alias: [
@@ -302,11 +220,6 @@ export const QuasarPlugin: VitrifyPlugin = async ({
302
220
  find: 'quasar/src',
303
221
  replacement: new URL('src/', urls?.packages?.quasar).pathname
304
222
  },
305
- // ...extras.map(extra => ({
306
- // find: `@quasar/extras/${extra}/${extra}.css`,
307
- // replacement: new URL(`${extra}/${extra}.css`, urls?.packages?.['@quasar/extras']).pathname
308
- // })
309
- // ),
310
223
  {
311
224
  find: 'quasar',
312
225
  replacement: new URL('src/', urls?.packages?.quasar).pathname
@@ -316,8 +229,6 @@ export const QuasarPlugin: VitrifyPlugin = async ({
316
229
  replacement: new URL('.', urls?.packages?.['@quasar/extras'])
317
230
  .pathname
318
231
  }
319
- // { find: new RegExp('^quasar$'), replacement: new URL('src/index.all.js', urls?.packages?.quasar).pathname },
320
- // { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' },
321
232
  ]
322
233
  },
323
234
  define: {
@@ -328,19 +239,6 @@ export const QuasarPlugin: VitrifyPlugin = async ({
328
239
  __QUASAR_SSR_CLIENT__: ssr === 'client',
329
240
  __QUASAR_SSR_PWA__: ssr === 'client' && pwa
330
241
  },
331
- // css: {
332
- // preprocessorOptions: {
333
- // sass: {
334
- // additionalData: `@import 'quasar/src/css/index.sass'`
335
- // // [
336
- // // // ...extras.map(extra => `@import "@quasar/extras/${extra}/${extra}.css"`),
337
- // // // ...extras.map(extra => `@import ${new URL(`${extra}/${extra}.css`, urls?.packages?.['@quasar/extras']).pathname}`) || [],
338
- // // // config.css?.preprocessorOptions?.sass?.additionalData,
339
- // // `@import 'quasar/src/css/index.sass'`
340
- // // ].join('\n')
341
- // }
342
- // }
343
- // },
344
242
  ssr: {
345
243
  noExternal: ['quasar']
346
244
  }
@@ -12,6 +12,15 @@ export type BootFunction = ({
12
12
  ssrContext: Record<string, unknown>
13
13
  staticImports: Record<string, any>
14
14
  }) => Promise<void> | void
15
+ export type OnBootHook = ({
16
+ app,
17
+ ssrContext,
18
+ staticImports
19
+ }: {
20
+ app: any
21
+ ssrContext: Record<string, unknown>
22
+ staticImports: Record<string, any>
23
+ }) => Promise<void> | void
15
24
  export type OnMountedHook = (
16
25
  instance: ComponentInternalInstance
17
26
  ) => Promise<void> | void
@@ -20,6 +29,11 @@ export type SsrFunction = (
20
29
  html: string,
21
30
  ssrContext: Record<string, any>
22
31
  ) => string
32
+ export type OnRenderedHook = (
33
+ html: string,
34
+ ssrContext: Record<string, any>
35
+ ) => string
36
+ export type OnSetupHook = (fastify: FastifyInstance) => any
23
37
 
24
38
  export interface VitrifyConfig extends UserConfig {
25
39
  vitrify?: {
@@ -27,23 +41,27 @@ export interface VitrifyConfig extends UserConfig {
27
41
  * Global CSS imports
28
42
  */
29
43
  globalCss?: string[]
30
- /**
31
- * Functions which run after initializing the app
32
- */
33
- bootFunctions?: BootFunction[]
34
- /**
35
- * Functions which run on the server after rendering the app
36
- */
37
- ssrFunctions?: SsrFunction[]
38
44
  /**
39
45
  * Static imports in the app: packageName: [imports]
40
46
  */
41
47
  staticImports?: StaticImports
42
48
  hooks?: {
49
+ /**
50
+ * setup() is called directly after instantiating fastify. Use it to register your own plugins, routes etc.
51
+ */
52
+ onSetup?: OnSetupHook[]
43
53
  /**
44
54
  * Functions which run in the onMounted hook of the app
45
55
  */
46
- onMounted: OnMountedHook[]
56
+ onMounted?: OnMountedHook[]
57
+ /**
58
+ * Functions which run after initializing the app
59
+ */
60
+ onBoot?: OnBootHook[]
61
+ /**
62
+ * Functions which run after rendering the app (SSR)
63
+ */
64
+ onRendered?: OnRenderedHook[]
47
65
  }
48
66
  /**
49
67
  * Global SASS variables
@@ -52,12 +70,6 @@ export interface VitrifyConfig extends UserConfig {
52
70
  variables?: Record<string, string>
53
71
  additionalData?: string[]
54
72
  }
55
- fastify?: {
56
- /**
57
- * setup() is called directly after instantiating fastify. Use it to register your own plugins, routes etc.
58
- */
59
- setup: (fastify: FastifyInstance) => any
60
- }
61
73
  /**
62
74
  * Product name of the application. Will be used for the HTML title tag
63
75
  */
@@ -4,16 +4,10 @@ import {
4
4
  createSSRApp,
5
5
  createApp as createVueApp,
6
6
  h,
7
- onMounted,
7
+ onMounted as onMountedVue,
8
8
  getCurrentInstance
9
9
  } from 'vue'
10
- // import { Quasar, useQuasar } from 'quasar'
11
- // import quasarPlugins from 'virtual:quasar-plugins'
12
- // import bootFunctions from 'virtual:quasar-boot'
13
- import bootFunctions from 'virtual:boot-functions'
14
- import onMountedHooks from 'virtual:on-mounted-hooks'
15
- // import 'virtual:quasar-extras'
16
- // import * as directives from 'quasar/directives'
10
+ import { onBoot, onMounted } from 'virtual:vitrify-hooks'
17
11
  import routes from 'src/router/routes'
18
12
  import 'virtual:global-css'
19
13
  import * as staticImports from 'virtual:static-imports'
@@ -34,13 +28,10 @@ export async function createApp(
34
28
  setup(props) {
35
29
  const instance = getCurrentInstance()
36
30
 
37
- onMounted(async () => {
38
- for (let fn of onMountedHooks) {
31
+ onMountedVue(async () => {
32
+ for (let fn of onMounted) {
39
33
  await fn(instance, staticImports)
40
34
  }
41
- // onAppMounted()
42
- // const { proxy: { $q } } = getCurrentInstance()
43
- // $q.onSSRHydrated !== void 0 && $q.onSSRHydrated()
44
35
  })
45
36
 
46
37
  return () => h(App, props)
@@ -63,11 +54,6 @@ export async function createApp(
63
54
  next()
64
55
  })
65
56
 
66
- // app.use(Quasar, {
67
- // plugins: quasarPlugins,
68
- // directives
69
- // }, ssrContext)
70
-
71
57
  let provide: Record<string, unknown> = {}
72
58
  if (import.meta.env.SSR) {
73
59
  if (ssrContext?.provide) {
@@ -81,7 +67,7 @@ export async function createApp(
81
67
  app.provide(key, provide[key])
82
68
  }
83
69
 
84
- for (let fn of bootFunctions) {
70
+ for (let fn of onBoot) {
85
71
  await fn({ app, ssrContext, staticImports })
86
72
  }
87
73
 
@@ -1,120 +1,4 @@
1
1
  import { fastifySsrPlugin } from '../../../node/frameworks/vue/fastify-ssr-plugin.js'
2
- import ssrFunctions from 'virtual:ssr-functions'
2
+ import { onRendered } from 'virtual:vitrify-hooks'
3
3
 
4
- export { fastifySsrPlugin, ssrFunctions }
5
-
6
- // import { FastifyPluginCallback, FastifyRequest, FastifyReply } from 'fastify'
7
- // import fastifyStatic from 'fastify-static'
8
- // import { readFileSync } from 'fs'
9
- // import { injectSsrContext } from '../../node/helpers/ssr.js'
10
- // import type { ViteDevServer } from 'vite'
11
-
12
- // export interface FastifySsrOptions {
13
- // baseUrl?: string
14
- // provide?: (req: FastifyRequest, res: FastifyReply) => Promise<Record<string, unknown>>
15
- // vite?: ViteDevServer
16
- // cliDir?: URL
17
- // appDir?: URL
18
- // productName?: string
19
- // }
20
-
21
- // const fastifySsrPlugin: FastifyPluginCallback<FastifySsrOptions> = async (fastify, options, done) => {
22
- // if (import.meta.env.MODE === 'development') {
23
- // if (!options.vite) throw new Error('Option vite cannot be undefined')
24
- // const middie = (await import('middie')).default
25
- // await fastify.register(middie)
26
- // fastify.use(options.vite.middlewares)
27
-
28
- // fastify.get('*', async (req, res) => {
29
- // try {
30
- // // const url = req.originalUrl
31
- // const url = req.raw.url
32
- // let template
33
- // let render
34
- // const ssrContext = {
35
- // req,
36
- // res
37
- // }
38
- // // always read fresh template in dev
39
- // // template = readFileSync(resolve('index.html'), 'utf-8')
40
- // template = readFileSync(new URL('index.html', options.cliDir)).toString()
41
-
42
- // // template = await vite.transformIndexHtml(url, template)
43
- // const entryUrl = new URL('ssr/entry-server.ts', options.cliDir).pathname
44
- // render = (await options.vite!.ssrLoadModule(entryUrl)).render
45
- // let manifest
46
- // // TODO: https://github.com/vitejs/vite/issues/2282
47
- // try {
48
- // manifest = {}
49
- // } catch (e) {
50
- // manifest = {}
51
- // }
52
-
53
- // const [appHtml, preloadLinks] = await render(url, manifest, ssrContext)
54
- // const html = template
55
- // .replace(`<!--preload-links-->`, preloadLinks)
56
- // .replace(`<!--app-html-->`, appHtml)
57
- // .replace('<!--product-name-->', options.productName || 'Product name')
58
-
59
- // res.code(200)
60
- // res.type('text/html')
61
- // res.send(html)
62
- // // res.status(200).set({ 'Content-Type': 'text/html' }).end(html)
63
- // } catch (e: any) {
64
- // console.error(e.stack)
65
- // options.vite && options.vite.ssrFixStacktrace(e)
66
- // res.code(500)
67
- // res.send(e.stack)
68
- // }
69
- // })
70
- // } else {
71
- // options.baseUrl = options.baseUrl || '/'
72
- // fastify.register(fastifyStatic, {
73
- // root: new URL('./dist/ssr/client', options.appDir).pathname,
74
- // wildcard: false,
75
- // index: false,
76
- // prefix: options.baseUrl
77
- // })
78
-
79
- // fastify.get(`${options.baseUrl}*`, async (req, res) => {
80
- // const url = req.raw.url
81
- // const provide = options.provide ? await options.provide(req, res) : {}
82
- // let template
83
- // let render
84
- // let manifest
85
- // const ssrContext: Record<string, any> = {
86
- // req,
87
- // res,
88
- // provide
89
- // }
90
-
91
- // // template = readFileSync(new URL('../client/index.html', import.meta.url).pathname).toString()
92
- // // manifest = JSON.parse(readFileSync(new URL('../client/ssr-manifest.json', import.meta.url)).toString())
93
- // // render = (await import(new URL('./entry-server.mjs', import.meta.url).pathname)).render
94
- // template = readFileSync(new URL('./dist/ssr/client/index.html', options.appDir).pathname).toString()
95
- // manifest = JSON.parse(readFileSync(new URL('./dist/ssr/client/ssr-manifest.json', options.appDir)).toString())
96
- // render = (await import(new URL('./dist/ssr/server/entry-server.mjs', options.appDir).pathname)).render
97
-
98
- // const [appHtml, preloadLinks] = await render(url, manifest, ssrContext)
99
-
100
- // if (!ssrContext.initialState) ssrContext.initialState = {}
101
- // ssrContext.initialState.provide = provide
102
-
103
- // let html = template
104
- // .replace(`<!--preload-links-->`, preloadLinks)
105
- // .replace(`<!--app-html-->`, appHtml)
106
- // html = injectSsrContext(html, ssrContext)
107
-
108
- // res.code(200)
109
- // res.type('text/html')
110
- // res.send(html)
111
- // })
112
- // }
113
-
114
- // done()
115
-
116
- // }
117
-
118
- // export {
119
- // fastifySsrPlugin
120
- // }
4
+ export { fastifySsrPlugin, onRendered }
@@ -1,4 +1,4 @@
1
1
  import { prerender } from '../../../node/frameworks/vue/prerender.js'
2
- import ssrFunctions from 'virtual:ssr-functions'
2
+ import { onRendered } from 'virtual:vitrify-hooks'
3
3
 
4
- export { prerender, ssrFunctions }
4
+ export { prerender, onRendered }
@@ -1,7 +1,7 @@
1
1
  import { createApp } from '../../../node/frameworks/vue/server.js'
2
2
  import { getAppDir } from '../../../node/app-urls.js'
3
- import { setup } from 'virtual:fastify-setup'
4
- import ssrFunctions from 'virtual:ssr-functions'
3
+ // import { setup } from 'virtual:fastify-setup'
4
+ import { onRendered, setup } from 'virtual:vitrify-hooks'
5
5
 
6
6
  // const appDir = getPkgJsonDir(import.meta.url)
7
7
  const getString = (str?: string) => str
@@ -12,7 +12,7 @@ const app = createApp({
12
12
  setup,
13
13
  appDir,
14
14
  baseUrl,
15
- ssrFunctions
15
+ onRendered
16
16
  })
17
17
 
18
18
  app.listen(process.env.PORT || 3000, process.env.HOST || '127.0.0.1')