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/dist/app-urls.js CHANGED
@@ -12,7 +12,6 @@ export const getCliDir = () => getPkgJsonDir(new URL('./', import.meta.url));
12
12
  export const getCliViteDir = (cliDir) => new URL('src/vite/', cliDir);
13
13
  export const getSrcDir = (appDir) => new URL('src/', appDir);
14
14
  export const getCwd = () => new URL(`file://${process.cwd()}/`);
15
- // export const quasarDir = getPkgJsonDir(new URL('./', await resolve('quasar', appDir.href)))
16
15
  export const parsePath = (path, basePath) => {
17
16
  if (path) {
18
17
  if (path.slice(-1) !== '/')
package/dist/bin/build.js CHANGED
@@ -1,49 +1,6 @@
1
1
  #!/usr/bin/node --experimental-specifier-resolution=node
2
2
  import { baseConfig } from '../index.js';
3
- // import { promises as fs } from 'fs'
4
- // import { routesToPaths } from '../helpers/routes.js'
5
3
  import { build as viteBuild } from 'vite';
6
- // import { SsrFunction } from '../vitrify-config.js'
7
- // export const prerender = async ({
8
- // outDir,
9
- // templatePath,
10
- // manifestPath,
11
- // entryServerPath,
12
- // injectSsrContext
13
- // }: {
14
- // outDir: string
15
- // templatePath: string
16
- // manifestPath: string
17
- // entryServerPath: string
18
- // injectSsrContext: SsrFunction
19
- // }) => {
20
- // let template
21
- // let manifest
22
- // const promises = []
23
- // template = (await fs.readFile(templatePath)).toString()
24
- // manifest = await fs.readFile(manifestPath)
25
- // let { render, getRoutes } = await import(entryServerPath)
26
- // const routes = await getRoutes()
27
- // const paths = routesToPaths(routes).filter(
28
- // (i) => !i.includes(':') && !i.includes('*')
29
- // )
30
- // for (let url of paths) {
31
- // const filename =
32
- // (url.endsWith('/') ? 'index' : url.replace(/^\//g, '')) + '.html'
33
- // console.log(`Generating ${filename}`)
34
- // const ssrContext = {
35
- // req: { headers: {}, url },
36
- // res: {}
37
- // }
38
- // const [appHtml, preloadLinks] = await render(url, manifest, ssrContext)
39
- // let html = template
40
- // .replace(`<!--preload-links-->`, preloadLinks)
41
- // .replace(`<!--app-html-->`, appHtml)
42
- // html = injectSsrContext(html, ssrContext)
43
- // promises.push(fs.writeFile(outDir + filename, html, 'utf-8'))
44
- // }
45
- // return Promise.all(promises)
46
- // }
47
4
  export async function build(opts) {
48
5
  const config = await baseConfig({
49
6
  command: 'build',
package/dist/bin/cli.js CHANGED
@@ -14,7 +14,7 @@ cli
14
14
  .action(async (options) => {
15
15
  const { build } = await import('./build.js');
16
16
  let appDir;
17
- let prerender, ssrFunctions;
17
+ let prerender, onRenderedHooks;
18
18
  if (options.appDir) {
19
19
  if (options.appDir.slice(-1) !== '/')
20
20
  options.appDir += '/';
@@ -59,7 +59,7 @@ cli
59
59
  ...args,
60
60
  outDir: new URL('ssr/server/', baseOutDir).pathname
61
61
  });
62
- ({ prerender, ssrFunctions } = await import(new URL('ssr/server/prerender.mjs', baseOutDir).pathname));
62
+ ({ prerender, onRenderedHooks } = await import(new URL('ssr/server/prerender.mjs', baseOutDir).pathname));
63
63
  prerender({
64
64
  outDir: new URL('static/', baseOutDir).pathname,
65
65
  templatePath: new URL('static/index.html', baseOutDir).pathname,
@@ -67,7 +67,7 @@ cli
67
67
  .pathname,
68
68
  entryServerPath: new URL('ssr/server/entry-server.mjs', baseOutDir)
69
69
  .pathname,
70
- ssrFunctions
70
+ onRenderedHooks
71
71
  });
72
72
  break;
73
73
  default:
package/dist/bin/dev.js CHANGED
@@ -8,7 +8,7 @@ export async function createServer({ port = 3000, logLevel = 'info', mode = 'csr
8
8
  const cliDir = getCliDir();
9
9
  if (!appDir)
10
10
  appDir = getAppDir();
11
- const { fastifySsrPlugin } = await import(`../${framework}/fastify-ssr-plugin.js`);
11
+ const { fastifySsrPlugin } = await import(`../frameworks/${framework}/fastify-ssr-plugin.js`);
12
12
  /**
13
13
  * @type {import('vite').ViteDevServer}
14
14
  */
@@ -57,47 +57,6 @@ export async function createServer({ port = 3000, logLevel = 'info', mode = 'csr
57
57
  vite,
58
58
  productName
59
59
  });
60
- // await app.register(middie)
61
- // app.use(vite.middlewares)
62
- // app.get('*', async (req, res) => {
63
- // try {
64
- // // const url = req.originalUrl
65
- // const url = req.raw.url
66
- // let template
67
- // let render
68
- // const ssrContext = {
69
- // req,
70
- // res
71
- // }
72
- // // always read fresh template in dev
73
- // // template = readFileSync(resolve('index.html'), 'utf-8')
74
- // template = readFileSync(new URL('index.html', cliDir)).toString()
75
- // // template = await vite.transformIndexHtml(url, template)
76
- // const entryUrl = new URL('ssr/entry-server.ts', cliDir).pathname
77
- // render = (await vite.ssrLoadModule(entryUrl)).render
78
- // let manifest
79
- // // TODO: https://github.com/vitejs/vite/issues/2282
80
- // try {
81
- // manifest = {}
82
- // } catch (e) {
83
- // manifest = {}
84
- // }
85
- // const [appHtml, preloadLinks] = await render(url, manifest, ssrContext)
86
- // const html = template
87
- // .replace(`<!--preload-links-->`, preloadLinks)
88
- // .replace(`<!--app-html-->`, appHtml)
89
- // .replace('<!--product-name-->', productName)
90
- // res.code(200)
91
- // res.type('text/html')
92
- // res.send(html)
93
- // // res.status(200).set({ 'Content-Type': 'text/html' }).end(html)
94
- // } catch (e: any) {
95
- // console.error(e.stack)
96
- // vite && vite.ssrFixStacktrace(e)
97
- // res.code(500)
98
- // res.send(e.stack)
99
- // }
100
- // })
101
60
  await app.listen(port || 3000, host);
102
61
  server = app.server;
103
62
  }
@@ -9,16 +9,12 @@ const fastifySsrPlugin = async (fastify, options, done) => {
9
9
  fastify.use(options.vite.middlewares);
10
10
  fastify.get('*', async (req, res) => {
11
11
  try {
12
- // const url = req.originalUrl
13
12
  const url = req.raw.url;
14
13
  const ssrContext = {
15
14
  req,
16
15
  res
17
16
  };
18
- // always read fresh template in dev
19
- // template = readFileSync(resolve('index.html'), 'utf-8')
20
17
  const template = readFileSync(new URL('index.html', options.cliDir)).toString();
21
- // template = await vite.transformIndexHtml(url, template)
22
18
  const entryUrl = new URL('ssr/entry-server.ts', options.cliDir).pathname;
23
19
  const render = (await options.vite.ssrLoadModule(entryUrl)).render;
24
20
  let manifest;
@@ -63,9 +59,6 @@ const fastifySsrPlugin = async (fastify, options, done) => {
63
59
  res,
64
60
  provide
65
61
  };
66
- // template = readFileSync(new URL('../client/index.html', import.meta.url).pathname).toString()
67
- // manifest = JSON.parse(readFileSync(new URL('../client/ssr-manifest.json', import.meta.url)).toString())
68
- // render = (await import(new URL('./entry-server.mjs', import.meta.url).pathname)).render
69
62
  const template = readFileSync(new URL('./dist/ssr/client/index.html', options.appDir).pathname).toString();
70
63
  const manifest = JSON.parse(readFileSync(new URL('./dist/ssr/client/ssr-manifest.json', options.appDir)).toString());
71
64
  const render = (await import(new URL('./dist/ssr/server/entry-server.mjs', options.appDir).pathname)).render;
@@ -76,8 +69,8 @@ const fastifySsrPlugin = async (fastify, options, done) => {
76
69
  let html = template
77
70
  .replace(`<!--preload-links-->`, preloadLinks)
78
71
  .replace(`<!--app-html-->`, appHtml);
79
- if (options.ssrFunctions?.length) {
80
- for (const ssrFunction of options.ssrFunctions) {
72
+ if (options.onRenderedHooks?.length) {
73
+ for (const ssrFunction of options.onRenderedHooks) {
81
74
  html = ssrFunction(html, ssrContext);
82
75
  }
83
76
  }
@@ -1,6 +1,6 @@
1
1
  import { promises as fs } from 'fs';
2
2
  import { routesToPaths } from '../../helpers/routes.js';
3
- export const prerender = async ({ outDir, templatePath, manifestPath, entryServerPath, ssrFunctions }) => {
3
+ export const prerender = async ({ outDir, templatePath, manifestPath, entryServerPath, onRenderedHooks }) => {
4
4
  const promises = [];
5
5
  const template = (await fs.readFile(templatePath)).toString();
6
6
  const manifest = await fs.readFile(manifestPath);
@@ -18,8 +18,8 @@ export const prerender = async ({ outDir, templatePath, manifestPath, entryServe
18
18
  let html = template
19
19
  .replace(`<!--preload-links-->`, preloadLinks)
20
20
  .replace(`<!--app-html-->`, appHtml);
21
- if (ssrFunctions?.length) {
22
- for (const ssrFunction of ssrFunctions) {
21
+ if (onRenderedHooks?.length) {
22
+ for (const ssrFunction of onRenderedHooks) {
23
23
  html = ssrFunction(html, ssrContext);
24
24
  }
25
25
  }
@@ -1,20 +1,14 @@
1
1
  import fastify from 'fastify';
2
- // import { setup } from 'virtual:fastify-setup'
3
2
  import { fastifySsrPlugin } from './fastify-ssr-plugin.js';
4
- // import { getPkgJsonDir } from '../app-urls.js'
5
- export const createApp = ({ setup, appDir, baseUrl, ssrFunctions }) => {
3
+ export const createApp = ({ setup, appDir, baseUrl, onRenderedHooks }) => {
6
4
  const app = fastify({
7
5
  logger: true
8
6
  });
9
7
  app.register(fastifySsrPlugin, {
10
8
  baseUrl,
11
9
  appDir,
12
- ssrFunctions
10
+ onRenderedHooks
13
11
  });
14
12
  setup(app);
15
13
  return app;
16
14
  };
17
- // const app = createApp({
18
- // setup
19
- // })
20
- // app.listen(process.env.PORT || 3000, process.env.HOST || '127.0.0.1')
@@ -1,79 +1,7 @@
1
1
  // https://github.com/quasarframework/quasar/blob/dev/app/lib/helpers/logger.js
2
2
  import chalk from 'chalk';
3
- const { bgGreen, green, inverse, bgRed, red, bgYellow, yellow } = chalk;
4
- import readline from 'readline';
5
3
  import os from 'os';
6
4
  import { resolveHostname } from '../helpers/utils.js';
7
- /**
8
- * Main approach - App CLI related
9
- */
10
- const dot = '•';
11
- const banner = 'App ' + dot;
12
- const greenBanner = green(banner);
13
- const redBanner = red(banner);
14
- const yellowBanner = yellow(banner);
15
- export const clearConsole = process.stdout.isTTY
16
- ? () => {
17
- // Fill screen with blank lines. Then move to 0 (beginning of visible part) and clear it
18
- const blank = '\n'.repeat(process.stdout.rows);
19
- console.log(blank);
20
- readline.cursorTo(process.stdout, 0, 0);
21
- readline.clearScreenDown(process.stdout);
22
- }
23
- : () => { };
24
- export const log = function (msg) {
25
- console.log(msg ? ` ${greenBanner} ${msg}` : '');
26
- };
27
- export const warn = function (msg, pill) {
28
- if (msg !== void 0) {
29
- const pillBanner = pill !== void 0 ? bgYellow.black('', pill, '') + ' ' : '';
30
- console.warn(` ${yellowBanner} ⚠️ ${pillBanner}${msg}`);
31
- }
32
- else {
33
- console.warn();
34
- }
35
- };
36
- export const fatal = function (msg, pill) {
37
- if (msg !== void 0) {
38
- const pillBanner = pill !== void 0 ? errorPill(pill) + ' ' : '';
39
- console.error(`\n ${redBanner} ⚠️ ${pillBanner}${msg}\n`);
40
- }
41
- else {
42
- console.error();
43
- }
44
- process.exit(1);
45
- };
46
- /**
47
- * Extended approach - Compilation status & pills
48
- */
49
- export const successPill = (msg) => bgGreen.black('', msg, '');
50
- export const infoPill = (msg) => inverse('', msg, '');
51
- export const errorPill = (msg) => bgRed.white('', msg, '');
52
- export const warningPill = (msg) => bgYellow.black('', msg, '');
53
- export const success = function (msg, title = 'SUCCESS') {
54
- console.log(` ${greenBanner} ${successPill(title)} ${green(dot + ' ' + msg)}`);
55
- };
56
- export const getSuccess = function (msg, title) {
57
- return ` ${greenBanner} ${successPill(title)} ${green(dot + ' ' + msg)}`;
58
- };
59
- export const info = function (msg, title = 'INFO') {
60
- console.log(` ${greenBanner} ${infoPill(title)} ${green(dot)} ${msg}`);
61
- };
62
- export const getInfo = function (msg, title) {
63
- return ` ${greenBanner} ${infoPill(title)} ${green(dot)} ${msg}`;
64
- };
65
- export const error = function (msg, title = 'ERROR') {
66
- console.log(` ${redBanner} ${errorPill(title)} ${red(dot + ' ' + msg)}`);
67
- };
68
- export const getError = function (msg, title = 'ERROR') {
69
- return ` ${redBanner} ${errorPill(title)} ${red(dot + ' ' + msg)}`;
70
- };
71
- export const warning = function (msg, title = 'WARNING') {
72
- console.log(` ${yellowBanner} ${warningPill(title)} ${yellow(dot + ' ' + msg)}`);
73
- };
74
- export const getWarning = function (msg, title = 'WARNING') {
75
- return ` ${yellowBanner} ${warningPill(title)} ${yellow(dot + ' ' + msg)}`;
76
- };
77
5
  export function printHttpServerUrls(server, config) {
78
6
  const address = server.address();
79
7
  const isAddressInfo = (x) => x?.address;
package/dist/index.js CHANGED
@@ -10,10 +10,7 @@ const configPluginMap = {
10
10
  };
11
11
  const manualChunks = ['prerender', 'fastify-ssr-plugin', 'server'];
12
12
  export const VIRTUAL_MODULES = [
13
- 'virtual:fastify-setup',
14
- 'virtual:boot-functions',
15
- 'virtual:ssr-functions',
16
- 'virtual:on-mounted-hooks',
13
+ 'virtual:vitrify-hooks',
17
14
  'virtual:global-css',
18
15
  'virtual:static-imports'
19
16
  ];
@@ -26,15 +23,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, command = 'build', mo
26
23
  const cwd = getCwd();
27
24
  const cliDir = getCliDir();
28
25
  const cliViteDir = getCliViteDir(cliDir);
29
- // const {
30
- // appDir: tempAppDir,
31
- // cliDir,
32
- // cliViteDir,
33
- // srcDir
34
- // } = await import('./app-urls.js')
35
- // const cwd = appDir || tempAppDir
36
26
  const frameworkDir = new URL(`${framework}/`, cliViteDir);
37
- // const localPackages = ['vue', 'vue-router', 'quasar']
38
27
  const localPackages = ['vue', 'vue-router'];
39
28
  const cliPackages = ['vitest'];
40
29
  const packageUrls = {};
@@ -46,17 +35,6 @@ export const baseConfig = async ({ ssr, appDir, publicDir, command = 'build', mo
46
35
  for (const val of cliPackages)
47
36
  packageUrls[val] = getPkgJsonDir(new URL(await resolve(val, cliDir.href)));
48
37
  })();
49
- // if (appDir) {
50
- // srcDir = new URL('src/', appDir);
51
- // quasarDir = new URL(await resolve('quasar/', appDir.href));
52
- // ({ appDir: cwd, cliDir } = await import('./app-urls.js'))
53
- // } else {
54
- // ({ appDir, cliDir, srcDir, quasarDir } = await import('./app-urls.js'))
55
- // cwd = appDir
56
- // }
57
- // vueDir = new URL('./', await resolve('vue', appDir.href));
58
- // vueRouterDir = new URL('../', await resolve('vue-router', appDir.href));
59
- // vitestDir = new URL('../', await resolve('vitest', cliDir.href));
60
38
  if (!publicDir)
61
39
  publicDir = new URL('public/', appDir);
62
40
  /**
@@ -76,7 +54,6 @@ export const baseConfig = async ({ ssr, appDir, publicDir, command = 'build', mo
76
54
  let { productName = 'Product name' } = JSON.parse(readFileSync(new URL('package.json', appDir).pathname, {
77
55
  encoding: 'utf-8'
78
56
  }));
79
- const fastifySetup = vitrifyConfig.vitrify?.fastify?.setup || ((fastify) => { });
80
57
  const ssrTransformCustomDir = () => {
81
58
  return {
82
59
  props: [],
@@ -93,9 +70,10 @@ export const baseConfig = async ({ ssr, appDir, publicDir, command = 'build', mo
93
70
  }));
94
71
  }
95
72
  }
96
- let bootFunctions;
97
- let ssrFunctions;
73
+ let onBootHooks;
74
+ let onRenderedHooks;
98
75
  let onMountedHooks;
76
+ let onSetupHooks;
99
77
  let globalCss;
100
78
  let staticImports;
101
79
  let sassVariables;
@@ -122,18 +100,14 @@ export const baseConfig = async ({ ssr, appDir, publicDir, command = 'build', mo
122
100
  }
123
101
  }),
124
102
  ...frameworkPlugins,
125
- // await QuasarPlugin({
126
- // ssr: ssr,
127
- // pwa: pwa
128
- // // quasarDir: packageUrls.quasar
129
- // }),
130
103
  {
131
104
  name: 'vitrify-setup',
132
105
  enforce: 'post',
133
106
  config: async (config, env) => {
134
- bootFunctions = config.vitrify?.bootFunctions || [];
135
- ssrFunctions = config.vitrify?.ssrFunctions || [];
107
+ onBootHooks = config.vitrify?.hooks?.onBoot || [];
108
+ onRenderedHooks = config.vitrify?.hooks?.onRendered || [];
136
109
  onMountedHooks = config.vitrify?.hooks?.onMounted || [];
110
+ onSetupHooks = config?.vitrify?.hooks?.onSetup || [];
137
111
  globalCss = config.vitrify?.globalCss || [];
138
112
  staticImports = config.vitrify?.staticImports || {};
139
113
  sassVariables = config.vitrify?.sass?.variables || {};
@@ -164,21 +138,17 @@ export const baseConfig = async ({ ssr, appDir, publicDir, command = 'build', mo
164
138
  return;
165
139
  },
166
140
  load(id) {
167
- if (id === 'virtual:fastify-setup') {
168
- return `export const setup = ${String(fastifySetup)}`;
169
- }
170
- else if (id === 'virtual:boot-functions') {
171
- return `export default [${bootFunctions
141
+ if (id === 'virtual:vitrify-hooks') {
142
+ return `export const onBoot = [${onBootHooks
172
143
  .map((fn) => `${String(fn)}`)
173
- .join(', ')}]`;
174
- }
175
- else if (id === 'virtual:ssr-functions') {
176
- return `export default [${ssrFunctions
144
+ .join(', ')}]
145
+ export const onMounted = [${onMountedHooks
177
146
  .map((fn) => `${String(fn)}`)
178
- .join(', ')}]`;
179
- }
180
- else if (id === 'virtual:on-mounted-hooks') {
181
- return `export default [${onMountedHooks
147
+ .join(', ')}]
148
+ export const onRendered = [${onRenderedHooks
149
+ .map((fn) => `${String(fn)}`)
150
+ .join(', ')}]
151
+ export const onSetup = [${onSetupHooks
182
152
  .map((fn) => `${String(fn)}`)
183
153
  .join(', ')}]`;
184
154
  }
@@ -251,9 +221,6 @@ export const baseConfig = async ({ ssr, appDir, publicDir, command = 'build', mo
251
221
  { find: 'cwd', replacement: cwd.pathname },
252
222
  { find: 'boot', replacement: new URL('boot/', srcDir).pathname },
253
223
  { find: 'assets', replacement: new URL('assets/', srcDir).pathname },
254
- // ...Object.entries(packageUrls).map(([key, value]) => ({
255
- // find: key, replacement: value.pathname
256
- // })),
257
224
  { find: 'vue', replacement: packageUrls['vue'].pathname },
258
225
  { find: 'vue-router', replacement: packageUrls['vue-router'].pathname },
259
226
  { find: 'vitrify', replacement: cliDir.pathname }
@@ -269,7 +236,6 @@ export const baseConfig = async ({ ssr, appDir, publicDir, command = 'build', mo
269
236
  vitrify: {
270
237
  productName,
271
238
  urls: {
272
- // @ts-ignore
273
239
  app: appDir,
274
240
  cli: cliDir,
275
241
  src: srcDir,
@@ -324,13 +290,6 @@ export const baseConfig = async ({ ssr, appDir, publicDir, command = 'build', mo
324
290
  }
325
291
  }
326
292
  },
327
- // css: {
328
- // preprocessorOptions: {
329
- // sass: {
330
- // additionalData: sass ? [...sass].join('\n') : undefined
331
- // }
332
- // }
333
- // },
334
293
  ssr: {
335
294
  // Create a SSR bundle
336
295
  noExternal: [
@@ -31,38 +31,9 @@ export const injectSsrContext = (html, ssrContext) => html
31
31
  }
32
32
  return `${start} class="${classes.trim()}" ${ssrContext._meta.bodyAttrs || ''}${end}${ssrContext._meta.bodyTags || ''}`;
33
33
  });
34
- // export interface Configuration {
35
- // ssr?: 'server' | 'client' | 'ssg' | false
36
- // }
37
34
  export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
38
- // const extraPlugins: Plugin[] = []
39
- // const ctx = {
40
- // prod: process.env.MODE === 'production',
41
- // dev: process.env.MODE === 'development',
42
- // mode: {
43
- // ssr: !!ssr,
44
- // pwa: !!pwa
45
- // }
46
- // }
47
- // let bootFilePaths: Record<string, any> = {}
48
- // let components: string[] = []
49
35
  let plugins = [];
50
- // let css: string[] = []
51
- let extras = [];
52
36
  return [
53
- // {
54
- // name: 'legacy-support',
55
- // enforce: 'pre',
56
- // transform (code, id) {
57
- // /**
58
- // * 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.
59
- // */
60
- // if (code.includes('app.use(VuePlugin)')) {
61
- // code = code.replace(/app\.use\(VuePlugin\)/g, `app.use(VuePlugin.install ? VuePlugin : VuePlugin.default)`)
62
- // }
63
- // return code
64
- // }
65
- // },
66
37
  Components({
67
38
  resolvers: [QuasarResolver()]
68
39
  }),
@@ -84,10 +55,8 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
84
55
  $q.onSSRHydrated !== void 0 && $q.onSSRHydrated();
85
56
  }
86
57
  ];
87
- const bootFunctions = [
58
+ const onBootHooks = [
88
59
  async ({ app, ssrContext, staticImports }) => {
89
- // @ts-ignore
90
- // const quasarVuePlugin = (await import('quasar/vue-plugin')).default
91
60
  // @ts-ignore
92
61
  const quasarPlugins = await import('virtual:quasar-plugins');
93
62
  // @ts-ignore
@@ -101,14 +70,14 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
101
70
  return {
102
71
  vitrify: {
103
72
  urls,
104
- bootFunctions,
105
- ssrFunctions: [injectSsrContext],
106
73
  globalCss,
107
74
  staticImports: {
108
75
  quasar: ['Quasar']
109
76
  },
110
77
  hooks: {
111
- onMounted: onMountedHooks
78
+ onBoot: onBootHooks,
79
+ onMounted: onMountedHooks,
80
+ onRendered: [injectSsrContext]
112
81
  },
113
82
  sass: {
114
83
  additionalData: [`@import 'quasar/src/css/index.sass'`]
@@ -120,50 +89,10 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
120
89
  {
121
90
  name: 'vite-plugin-quasar',
122
91
  enforce: 'post',
123
- // transformIndexHtml: {
124
- // enforce: 'post',
125
- // transform: (html) => {
126
- // return html.replace(
127
- // '<!--product-name-->',
128
- // productName
129
- // )
130
- // }
131
- // },
132
92
  config: async (config, env) => {
133
- // let appDir: URL
134
- // let cliDir: URL
135
- // let cwd: URL
136
- // let quasarDir: URL
137
- // let quasarConf: QuasarConf | undefined
138
93
  const { quasar: quasarConf, vitrify: { urls } = {} } = config;
139
94
  const quasarPkgJsonPath = new URL('package.json', urls?.packages?.quasar).pathname;
140
95
  const { version } = JSON.parse(readFileSync(quasarPkgJsonPath, { encoding: 'utf-8' }));
141
- // if (quasarConf?.boot) {
142
- // bootFilePaths = (quasarConf.boot as (Record<string, any> | string)[])
143
- // .filter(entry => {
144
- // if (typeof entry === 'object') return (entry.server && (ssr === 'server'))
145
- // else if (entry !== '') return true
146
- // })
147
- // .map(entry => {
148
- // if (typeof entry === 'string') return entry
149
- // else if (typeof entry === 'object') return entry.path
150
- // })
151
- // .reduce((acc, entry) => {
152
- // if (entry[0] === '~') {
153
- // const split = entry.substring(1).split('/')
154
- // const name = split[0].replace(/[|&;$%@"<>()+,]/g, "");
155
- // acc[name] = {
156
- // path: new URL(`node_modules/${entry.substring(1)}`, urls?.app).pathname
157
- // }
158
- // } else {
159
- // const name = entry.split('.')[0]
160
- // acc[name] = {
161
- // path: `src/boot/${entry}`
162
- // }
163
- // }
164
- // return acc
165
- // }, {})
166
- // }
167
96
  /**
168
97
  * All components should have been auto-imported
169
98
  */
@@ -175,13 +104,6 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
175
104
  ];
176
105
  plugins = quasarConf?.framework.plugins;
177
106
  }
178
- // css = (quasarConf?.css || []).map((v => {
179
- // if (v[0] === '~') {
180
- // return v.slice(1)
181
- // }
182
- // return v
183
- // })).map((v) => `@import '${v}'`)
184
- extras = quasarConf?.extras || [];
185
107
  return {
186
108
  resolve: {
187
109
  alias: [
@@ -214,11 +136,6 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
214
136
  find: 'quasar/src',
215
137
  replacement: new URL('src/', urls?.packages?.quasar).pathname
216
138
  },
217
- // ...extras.map(extra => ({
218
- // find: `@quasar/extras/${extra}/${extra}.css`,
219
- // replacement: new URL(`${extra}/${extra}.css`, urls?.packages?.['@quasar/extras']).pathname
220
- // })
221
- // ),
222
139
  {
223
140
  find: 'quasar',
224
141
  replacement: new URL('src/', urls?.packages?.quasar).pathname
@@ -228,8 +145,6 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
228
145
  replacement: new URL('.', urls?.packages?.['@quasar/extras'])
229
146
  .pathname
230
147
  }
231
- // { find: new RegExp('^quasar$'), replacement: new URL('src/index.all.js', urls?.packages?.quasar).pathname },
232
- // { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' },
233
148
  ]
234
149
  },
235
150
  define: {
@@ -240,19 +155,6 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
240
155
  __QUASAR_SSR_CLIENT__: ssr === 'client',
241
156
  __QUASAR_SSR_PWA__: ssr === 'client' && pwa
242
157
  },
243
- // css: {
244
- // preprocessorOptions: {
245
- // sass: {
246
- // additionalData: `@import 'quasar/src/css/index.sass'`
247
- // // [
248
- // // // ...extras.map(extra => `@import "@quasar/extras/${extra}/${extra}.css"`),
249
- // // // ...extras.map(extra => `@import ${new URL(`${extra}/${extra}.css`, urls?.packages?.['@quasar/extras']).pathname}`) || [],
250
- // // // config.css?.preprocessorOptions?.sass?.additionalData,
251
- // // `@import 'quasar/src/css/index.sass'`
252
- // // ].join('\n')
253
- // }
254
- // }
255
- // },
256
158
  ssr: {
257
159
  noExternal: ['quasar']
258
160
  }
@@ -1,6 +1,6 @@
1
1
  import type { FastifyPluginCallback, FastifyRequest, FastifyReply } from 'fastify';
2
2
  import type { ViteDevServer } from 'vite';
3
- import type { SsrFunction } from '../../vitrify-config.js';
3
+ import type { OnRenderedHook } from '../../vitrify-config.js';
4
4
  export interface FastifySsrOptions {
5
5
  baseUrl?: string;
6
6
  provide?: (req: FastifyRequest, res: FastifyReply) => Promise<Record<string, unknown>>;
@@ -8,7 +8,7 @@ export interface FastifySsrOptions {
8
8
  cliDir?: URL;
9
9
  appDir?: URL;
10
10
  productName?: string;
11
- ssrFunctions?: SsrFunction[];
11
+ onRenderedHooks?: OnRenderedHook[];
12
12
  }
13
13
  declare const fastifySsrPlugin: FastifyPluginCallback<FastifySsrOptions>;
14
14
  export { fastifySsrPlugin };
@@ -1,8 +1,8 @@
1
- import type { SsrFunction } from '../../vitrify-config.js';
2
- export declare const prerender: ({ outDir, templatePath, manifestPath, entryServerPath, ssrFunctions }: {
1
+ import type { OnRenderedHook } from '../../vitrify-config.js';
2
+ export declare const prerender: ({ outDir, templatePath, manifestPath, entryServerPath, onRenderedHooks }: {
3
3
  outDir: string;
4
4
  templatePath: string;
5
5
  manifestPath: string;
6
6
  entryServerPath: string;
7
- ssrFunctions: SsrFunction[];
7
+ onRenderedHooks: OnRenderedHook[];
8
8
  }) => Promise<void[]>;