vitrify 0.24.2 → 0.25.1

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/README.md CHANGED
@@ -1,19 +1,5 @@
1
1
  # Vitrify
2
2
 
3
- > Vite as your Full Stack development tool
4
-
5
- - Use a simple configuration file to configure and integrate required Vite plugins into your project.
6
- - Client-Side Rendering (CSR), Server-Side Rendering (SSR), Static Site Generation (SSG) and Fastify server build and development modes.
7
- - Run both your frontend- and backend code through Vite at development and build time.
8
-
9
- ## Features
10
-
11
- - Uses [Fastify](https://github.com/fastify/fastify-vite) for the development server and SSR production server.
12
- - Generates a Fastify plugin to serve your server-side rendered application.
13
- - A [`run`](./src/node/bin/run.ts) command which injects context such as application paths into the script which you want to run.
14
- - A [`test`](./src/node/bin/test.ts) command which runs a pre-configured [Vitest](https://github.com/vitest-dev/vitest) instance.
15
- - An [extra plugin layer](./src/node/plugins/index.ts) which provides some extra context such as the SSR mode (client or server) and PWA mode. Used for UI frameworks which render differently based on these settings.
16
-
17
3
  ## Commands
18
4
 
19
5
  ### build
@@ -83,15 +69,14 @@ Options:
83
69
  end
84
70
  merge-- mode: fastify -->frameworkFastify{Load framework entrypoints from fastify/...};
85
71
  merge-- mode: csr/ssr/ssg -->framework{Load framework entrypoints from vite/...};
86
- frameworkFastify-->fastifyBuild{Build the application};
87
- frameworkFastify-->fastifyDev{Start Fastify dev server};
88
- fastifySetup{onSetup / onRendered}-->fastifyDev
89
- fastifySetup{onSetup / onRendered}-->fastifyBuild
90
- framework-->build{Build the application};
72
+ frameworkFastify-->fastifySetup{onSetup / onRendered};
73
+ fastifySetup-->frameworkSetup;
91
74
  build-- mode: ssg -->prerender{Run prerender.js}
92
- framework-->dev{Start Vite dev server};
93
- frameworkSetup{onBoot / onMounted}-->dev
94
- frameworkSetup{onBoot / onMounted}-->build
75
+ framework-->frameworkSetup{onAppCreated / onMounted}
76
+ frameworkSetup-->frameworkOnRendered{onRendered};
77
+ frameworkOnRendered-->frameworkOnTemplateRendered{onTemplateRendered};
78
+ frameworkOnTemplateRendered-->build{Build the application};
79
+ frameworkOnTemplateRendered-->dev{Start dev server};
95
80
  node/bin/test.ts-->test{Run a pre-configured Vitest instance};
96
81
  node/bin/run.ts-->run{Inject context into script and run script};
97
82
  ```
package/dist/bin/cli.js CHANGED
@@ -74,7 +74,7 @@ cli
74
74
  outDir: fileURLToPath(new URL('ssr/server/', baseOutDir))
75
75
  });
76
76
  ({ prerender } = await import(new URL('ssr/server/prerender.mjs', baseOutDir).pathname));
77
- const { template, manifest, render, getRoutes, onRendered, onTemplateRendered } = await loadSSRAssets({
77
+ const { template, manifest, render, getRoutes, onAppRendered, onTemplateRendered } = await loadSSRAssets({
78
78
  mode: 'ssg',
79
79
  distDir: baseOutDir
80
80
  });
@@ -85,7 +85,7 @@ cli
85
85
  manifest,
86
86
  render,
87
87
  routes,
88
- onRendered,
88
+ onAppRendered,
89
89
  onTemplateRendered
90
90
  });
91
91
  break;
package/dist/bin/dev.js CHANGED
@@ -76,6 +76,7 @@ ssr, framework = 'vue', host, appDir, publicDir, vite }) {
76
76
  let app;
77
77
  let server;
78
78
  let onTemplateRendered;
79
+ let onAppRendered;
79
80
  let vitrifyConfig;
80
81
  console.log(`Development mode: ${ssr ? ssr : 'csr'}`);
81
82
  if (ssr) {
@@ -83,11 +84,9 @@ ssr, framework = 'vue', host, appDir, publicDir, vite }) {
83
84
  ? fileURLToPath(new URL('src/vite/fastify/entry.ts', cliDir))
84
85
  : fileURLToPath(new URL(`src/vite/${framework}/ssr/app.ts`, cliDir));
85
86
  const environment = vite.environments.ssr;
86
- ({ setup, onTemplateRendered, vitrifyConfig } =
87
+ ({ setup, onTemplateRendered, onAppRendered, vitrifyConfig } =
87
88
  // @ts-expect-error missing types
88
89
  await environment.runner.import(entryUrl));
89
- // console.log(module)
90
- // ;({ setup, onRendered, vitrifyConfig } = await vite.ssrLoadModule(entryUrl))
91
90
  app = fastify({
92
91
  logger: {
93
92
  transport: {
@@ -113,6 +112,7 @@ ssr, framework = 'vue', host, appDir, publicDir, vite }) {
113
112
  appDir,
114
113
  mode: 'development',
115
114
  onTemplateRendered,
115
+ onAppRendered,
116
116
  host
117
117
  });
118
118
  }
@@ -55,7 +55,7 @@ const fastifySsrPlugin = async (fastify, options) => {
55
55
  res,
56
56
  url: url ?? '/',
57
57
  provide,
58
- onRendered: options.onRendered,
58
+ onAppRendered: options.onAppRendered,
59
59
  onTemplateRendered: options.onTemplateRendered,
60
60
  template,
61
61
  manifest,
@@ -87,7 +87,7 @@ const fastifySsrPlugin = async (fastify, options) => {
87
87
  fastify.get(`${options.baseUrl}*`, async (req, res) => {
88
88
  const url = req.raw.url?.replace(options.baseUrl, '/');
89
89
  const provide = options.provide ? await options.provide(req, res) : {};
90
- const { template, manifest, render, onRendered, onTemplateRendered } = await loadSSRAssets({
90
+ const { template, manifest, render, onAppRendered, onTemplateRendered } = await loadSSRAssets({
91
91
  distDir: new URL('./dist/', options.appDir)
92
92
  });
93
93
  const html = await renderHtml({
@@ -95,7 +95,7 @@ const fastifySsrPlugin = async (fastify, options) => {
95
95
  res,
96
96
  url: url ?? '/',
97
97
  provide,
98
- onRendered,
98
+ onAppRendered,
99
99
  onTemplateRendered,
100
100
  template,
101
101
  manifest,
@@ -111,7 +111,7 @@ const renderTemplate = ({ template, initialStateScript, appHtml, preloadLinks })
111
111
  return appendToHead(preloadLinks, appendToBody(initialStateScript, addOrReplaceAppDiv(appHtml, template)));
112
112
  };
113
113
  const renderHtml = async (options) => {
114
- const ssrContextOnRendered = [];
114
+ const ssrContextonAppRendered = [];
115
115
  const ssrContext = {
116
116
  req: options.req,
117
117
  res: options.res,
@@ -120,21 +120,21 @@ const renderHtml = async (options) => {
120
120
  _modules: new Set(),
121
121
  _meta: {},
122
122
  __qMetaList: [],
123
- onRenderedList: ssrContextOnRendered,
123
+ onRenderedList: ssrContextonAppRendered,
124
124
  onRendered: (fn) => {
125
- ssrContextOnRendered.push(fn);
125
+ ssrContextonAppRendered.push(fn);
126
126
  }
127
127
  };
128
- const onRendered = options.onRendered ?? [];
128
+ const onAppRendered = options.onAppRendered ?? [];
129
129
  const onTemplateRendered = options.onTemplateRendered ?? [];
130
130
  const { html: appHtml, preloadLinks, app } = await options.render(options.url, options.manifest, ssrContext);
131
- if (ssrContextOnRendered?.length) {
132
- for (const ssrFunction of ssrContextOnRendered) {
131
+ if (ssrContextonAppRendered?.length) {
132
+ for (const ssrFunction of ssrContextonAppRendered) {
133
133
  await ssrFunction();
134
134
  }
135
135
  }
136
- if (onRendered?.length) {
137
- for (const ssrFunction of onRendered) {
136
+ if (onAppRendered?.length) {
137
+ for (const ssrFunction of onAppRendered) {
138
138
  await ssrFunction({ app, ssrContext });
139
139
  }
140
140
  }
@@ -191,13 +191,13 @@ const loadSSRAssets = async ({ mode, distDir } = {
191
191
  const manifest = JSON.parse(readFileSync(manifestPath).toString());
192
192
  const entryServer = await import(entryServerPath);
193
193
  const { render, getRoutes } = entryServer;
194
- const { onTemplateRendered, onRendered } = await import(vitrifyHooksPath);
194
+ const { onTemplateRendered, onAppRendered } = await import(vitrifyHooksPath);
195
195
  return {
196
196
  template,
197
197
  manifest,
198
198
  render,
199
199
  getRoutes,
200
- onRendered,
200
+ onAppRendered,
201
201
  onTemplateRendered
202
202
  };
203
203
  }
@@ -1,5 +1,5 @@
1
1
  import fastify from 'fastify';
2
- export const createApp = ({ onSetup, appDir, baseUrl, fastifyPlugin, onRendered, onTemplateRendered, vitrifyDir, mode }) => {
2
+ export const createApp = ({ onSetup, appDir, baseUrl, fastifyPlugin, onAppRendered, onTemplateRendered, vitrifyDir, mode }) => {
3
3
  const app = fastify({
4
4
  logger: {
5
5
  transport: {
@@ -12,7 +12,7 @@ export const createApp = ({ onSetup, appDir, baseUrl, fastifyPlugin, onRendered,
12
12
  baseUrl,
13
13
  appDir,
14
14
  vitrifyDir,
15
- onRendered,
15
+ onAppRendered,
16
16
  onTemplateRendered,
17
17
  mode
18
18
  });
package/dist/index.js CHANGED
@@ -207,11 +207,14 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
207
207
  }
208
208
  }
209
209
  }
210
- let onBootHooks;
211
- let onRenderedHooks;
210
+ let onAppRenderedHooks;
211
+ let onAppRenderedFiles;
212
212
  let onTemplateRenderedHooks;
213
+ let onTemplateRenderedFiles;
213
214
  let onAppMountedHooks;
214
- let onAppCreatedHooks;
215
+ let onAppMountedFiles;
216
+ let OnAppCreatedHooks;
217
+ let onAppCreatedFiles;
215
218
  let onSetupFiles;
216
219
  let globalCss = [];
217
220
  let staticImports;
@@ -270,12 +273,16 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
270
273
  name: 'vitrify-setup',
271
274
  enforce: 'post',
272
275
  config: (config, env) => {
273
- onBootHooks = config.vitrify?.hooks?.onBoot || [];
274
- onRenderedHooks = config.vitrify?.hooks?.onRendered || [];
276
+ onAppRenderedHooks = config.vitrify?.hooks?.onAppRendered || [];
277
+ onAppRenderedFiles = config.vitrify?.hooks?.onAppRenderedFiles || [];
275
278
  onTemplateRenderedHooks =
276
279
  config.vitrify?.hooks?.onTemplateRendered || [];
280
+ onTemplateRenderedFiles =
281
+ config.vitrify?.hooks?.onTemplateRenderedFiles || [];
277
282
  onAppMountedHooks = config.vitrify?.hooks?.onAppMounted || [];
278
- onAppCreatedHooks = config.vitrify?.hooks?.onAppCreated || [];
283
+ onAppMountedFiles = config.vitrify?.hooks?.onAppMountedFiles || [];
284
+ OnAppCreatedHooks = config.vitrify?.hooks?.onAppCreated || [];
285
+ onAppCreatedFiles = config.vitrify?.hooks?.onAppCreatedFiles || [];
279
286
  onSetupFiles = config?.vitrify?.hooks?.onSetup || [];
280
287
  globalCss = config.vitrify?.globalCss || [];
281
288
  staticImports = config.vitrify?.staticImports || {};
@@ -306,21 +313,68 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
306
313
  },
307
314
  load(id) {
308
315
  if (id === 'virtual:vitrify-hooks') {
309
- return `export const onBoot = [${onBootHooks
316
+ return `export const onAppMounted = [${onAppMountedHooks
310
317
  .map((fn) => `${String(fn)}`)
311
318
  .join(', ')}]
312
- export const onAppMounted = [${onAppMountedHooks
313
- .map((fn) => `${String(fn)}`)
314
- .join(', ')}]
315
- export const onRendered = [${onRenderedHooks
319
+ ${onAppMountedFiles
320
+ .map((url, index) => {
321
+ const varName = fileURLToPath(url)
322
+ .replaceAll('/', '')
323
+ .replaceAll(':', '')
324
+ .replaceAll('\\', '')
325
+ .replaceAll('.', '')
326
+ .replaceAll('-', '')
327
+ .replaceAll('_', '')
328
+ .replaceAll('+', '');
329
+ return `import ${varName} from '${new URL(url, appDir).pathname}'; onAppMounted.push(${varName});`;
330
+ })
331
+ .join('\n')}
332
+ export const onAppRendered = [${onAppRenderedHooks
316
333
  .map((fn) => `${String(fn)}`)
317
334
  .join(', ')}]
335
+ ${onAppRenderedFiles
336
+ .map((url, index) => {
337
+ const varName = fileURLToPath(url)
338
+ .replaceAll('/', '')
339
+ .replaceAll(':', '')
340
+ .replaceAll('\\', '')
341
+ .replaceAll('.', '')
342
+ .replaceAll('-', '')
343
+ .replaceAll('_', '')
344
+ .replaceAll('+', '');
345
+ return `import ${varName} from '${new URL(url, appDir).pathname}'; onAppRendered.push(${varName});`;
346
+ })
347
+ .join('\n')}
318
348
  export const onTemplateRendered = [${onTemplateRenderedHooks
319
349
  .map((fn) => `${String(fn)}`)
320
350
  .join(', ')}]
321
- export const onAppCreated = [${onAppCreatedHooks
322
- .map((fn) => `${String(fn)}`)
323
- .join(', ')}]
351
+ ${onTemplateRenderedFiles
352
+ .map((url, index) => {
353
+ const varName = fileURLToPath(url)
354
+ .replaceAll('/', '')
355
+ .replaceAll(':', '')
356
+ .replaceAll('\\', '')
357
+ .replaceAll('.', '')
358
+ .replaceAll('-', '')
359
+ .replaceAll('_', '')
360
+ .replaceAll('+', '');
361
+ return `import ${varName} from '${new URL(url, appDir).pathname}'; onTemplateRendered.push(${varName});`;
362
+ })
363
+ .join('\n')}
364
+ export const onAppCreated = [${OnAppCreatedHooks.map((fn) => `${String(fn)}`).join(', ')}]
365
+ ${onAppCreatedFiles
366
+ .map((url, index) => {
367
+ const varName = fileURLToPath(url)
368
+ .replaceAll('/', '')
369
+ .replaceAll(':', '')
370
+ .replaceAll('\\', '')
371
+ .replaceAll('.', '')
372
+ .replaceAll('-', '')
373
+ .replaceAll('_', '')
374
+ .replaceAll('+', '');
375
+ return `import ${varName} from '${new URL(url, appDir).pathname}'; onAppCreated.push(${varName});`;
376
+ })
377
+ .join('\n')}
324
378
  export const onSetup = []
325
379
  ${onSetupFiles
326
380
  .map((url, index) => {
@@ -332,7 +386,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
332
386
  .replaceAll('-', '')
333
387
  .replaceAll('_', '')
334
388
  .replaceAll('+', '');
335
- return `import ${varName} from '${new URL(url, appDir).pathname}'; onSetup.push(${varName})`;
389
+ return `import ${varName} from '${new URL(url, appDir).pathname}'; onSetup.push(${varName});`;
336
390
  })
337
391
  .join('\n')}`;
338
392
  }
@@ -10,7 +10,7 @@ const piniaOnAppCreated = async ({ app, ctx, initialState, ssrContext }) => {
10
10
  if (ssrContext)
11
11
  ssrContext.pinia = pinia;
12
12
  };
13
- const piniaOnRenderedHook = async ({ app, ssrContext }) => {
13
+ const piniaonAppRenderedHook = async ({ app, ssrContext }) => {
14
14
  // SSR Server
15
15
  if (ssrContext?.initialState && ssrContext.pinia) {
16
16
  ssrContext.initialState.pinia = ssrContext.pinia.state.value;
@@ -25,7 +25,7 @@ const piniaColadaonAppCreated = async ({ app, ctx, initialState }) => {
25
25
  }
26
26
  }
27
27
  };
28
- const piniaColadaOnRenderedHook = async ({ app, ssrContext }) => {
28
+ const piniaColadaonAppRenderedHook = async ({ app, ssrContext }) => {
29
29
  // SSR Server
30
30
  if (ssrContext?.initialState && ssrContext.pinia) {
31
31
  const { useQueryCache, serializeQueryCache } = await import('@pinia/colada');
@@ -38,10 +38,10 @@ const piniaColadaOnRenderedHook = async ({ app, ssrContext }) => {
38
38
  };
39
39
  export const PiniaPlugin = async ({ ssr = false, pwa = false, options = {} }) => {
40
40
  const onAppCreated = [piniaOnAppCreated];
41
- const onRendered = [piniaOnRenderedHook];
41
+ const onAppRendered = [piniaonAppRenderedHook];
42
42
  if (options.colada) {
43
43
  onAppCreated.push(piniaColadaonAppCreated);
44
- onRendered.push(piniaColadaOnRenderedHook);
44
+ onAppRendered.push(piniaColadaonAppRenderedHook);
45
45
  }
46
46
  return {
47
47
  plugins: [],
@@ -49,7 +49,7 @@ export const PiniaPlugin = async ({ ssr = false, pwa = false, options = {} }) =>
49
49
  vitrify: {
50
50
  hooks: {
51
51
  onAppCreated,
52
- onRendered
52
+ onAppRendered
53
53
  }
54
54
  }
55
55
  }
@@ -69,7 +69,7 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false, options }) => {
69
69
  $q.onSSRHydrated();
70
70
  }
71
71
  ];
72
- const onBootHooks = [
72
+ const onAppCreatedHooks = [
73
73
  async ({ app, ssrContext, staticImports }) => {
74
74
  // @ts-expect-error undefined
75
75
  const quasarPlugins = await import('virtual:quasar-plugins');
@@ -117,7 +117,7 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false, options }) => {
117
117
  quasar: ['Quasar']
118
118
  },
119
119
  hooks: {
120
- onBoot: onBootHooks,
120
+ onAppCreated: onAppCreatedHooks,
121
121
  onAppMounted: onAppMountedHooks,
122
122
  onTemplateRendered: [injectSsrContext]
123
123
  },
@@ -1,6 +1,6 @@
1
1
  import type { FastifyPluginAsync, FastifyRequest, FastifyReply } from 'fastify';
2
2
  import type { ViteDevServer } from 'vite';
3
- import type { OnRenderedHook, OnTemplateRenderedHook } from '../../vitrify-config.js';
3
+ import type { OnAppRenderedHook, OnTemplateRenderedHook } from '../../vitrify-config.js';
4
4
  type ProvideFn = (req: FastifyRequest, res: FastifyReply) => Promise<Record<string, unknown | {
5
5
  value: unknown;
6
6
  }>>;
@@ -9,7 +9,7 @@ export interface FastifySsrOptions {
9
9
  provide?: ProvideFn;
10
10
  vitrifyDir?: URL;
11
11
  vite?: ViteDevServer;
12
- onRendered?: OnRenderedHook[];
12
+ onAppRendered?: OnAppRenderedHook[];
13
13
  onTemplateRendered?: OnTemplateRenderedHook[];
14
14
  appDir?: URL;
15
15
  publicDir?: URL;
@@ -25,7 +25,7 @@ declare const renderHtml: (options: {
25
25
  };
26
26
  res: FastifyReply | Record<string, unknown>;
27
27
  provide: Record<string, unknown>;
28
- onRendered?: OnRenderedHook[];
28
+ onAppRendered?: OnAppRenderedHook[];
29
29
  onTemplateRendered?: OnTemplateRenderedHook[];
30
30
  template: string;
31
31
  manifest: Record<string, unknown>;
@@ -39,7 +39,7 @@ declare const loadSSRAssets: ({ mode, distDir }?: {
39
39
  manifest: any;
40
40
  render: any;
41
41
  getRoutes: any;
42
- onRendered: any;
42
+ onAppRendered: any;
43
43
  onTemplateRendered: any;
44
44
  }>;
45
45
  export { fastifySsrPlugin, renderHtml, loadSSRAssets };
@@ -1,12 +1,12 @@
1
- import type { OnTemplateRenderedHook, OnSetupHook, OnRenderedHook } from '../../vitrify-config.js';
1
+ import type { OnTemplateRenderedHook, OnSetupHook, OnAppRenderedHook } from '../../vitrify-config.js';
2
2
  import type { FastifyCsrPlugin } from './fastify-csr-plugin.js';
3
3
  import type { FastifySsrPlugin } from './fastify-ssr-plugin.js';
4
- export declare const createApp: ({ onSetup, appDir, baseUrl, fastifyPlugin, onRendered, onTemplateRendered, vitrifyDir, mode }: {
4
+ export declare const createApp: ({ onSetup, appDir, baseUrl, fastifyPlugin, onAppRendered, onTemplateRendered, vitrifyDir, mode }: {
5
5
  onSetup: OnSetupHook[];
6
6
  appDir: URL;
7
7
  baseUrl?: string;
8
8
  fastifyPlugin: FastifySsrPlugin | FastifyCsrPlugin;
9
- onRendered?: OnRenderedHook[];
9
+ onAppRendered?: OnAppRenderedHook[];
10
10
  onTemplateRendered?: OnTemplateRenderedHook[];
11
11
  vitrifyDir?: URL;
12
12
  mode: string;
@@ -1,2 +1,2 @@
1
- import type { OnBootHook, onAppCreatedHook, OnAppMountedHook, OnRenderedHook, OnTemplateRenderedHook, OnSetupFile, OnSetupHook } from '../vitrify-config.js';
2
- export { OnBootHook, onAppCreatedHook, OnAppMountedHook, OnRenderedHook, OnTemplateRenderedHook, OnSetupFile, OnSetupHook };
1
+ import type { OnAppCreatedHook, OnAppCreatedHookFile, OnAppMountedHook, OnAppMountedHookFile, OnAppRenderedHook, OnAppRenderedHookFile, OnTemplateRenderedHook, OnTemplateRenderedHookFile, OnSetupHookFile, OnSetupHook } from '../vitrify-config.js';
2
+ export { OnAppCreatedHook, OnAppCreatedHookFile, OnAppMountedHook, OnAppMountedHookFile, OnAppRenderedHook, OnAppRenderedHookFile, OnTemplateRenderedHook, OnTemplateRenderedHookFile, OnSetupHookFile, OnSetupHook };
@@ -1,5 +1,5 @@
1
1
  import type { InlineConfig } from 'vite';
2
- import type { VitrifyConfig, VitrifyConfigAsync, VitrifyCommands, VitrifyModes, VitrifyUIFrameworks, VitrifySSRModes, OnBootHook } from './vitrify-config.js';
2
+ import type { VitrifyConfig, VitrifyConfigAsync, VitrifyCommands, VitrifyModes, VitrifyUIFrameworks, VitrifySSRModes } from './vitrify-config.js';
3
3
  import type { VitrifyContext } from './bin/run.js';
4
4
  import type { VitrifyPlugin } from './plugins/index.js';
5
5
  export declare const VIRTUAL_MODULES: string[];
@@ -16,4 +16,4 @@ export declare const baseConfig: ({ ssr, appDir, publicDir, base, command, mode,
16
16
  }) => Promise<InlineConfig>;
17
17
  export declare const vitrifyDir: URL;
18
18
  export { prerender } from './frameworks/vue/prerender.js';
19
- export type { VitrifyConfig, VitrifyConfigAsync, VitrifyPlugin, VitrifyContext, OnBootHook };
19
+ export type { VitrifyConfig, VitrifyConfigAsync, VitrifyPlugin, VitrifyContext };
@@ -38,7 +38,8 @@ export type SSRContext = {
38
38
  transports?: Record<string, unknown>;
39
39
  [key: string]: unknown;
40
40
  };
41
- export type onAppCreatedHook = ({ app, router, ctx, initialState, ssrContext }: {
41
+ export type OnAppCreatedHookFile = URL;
42
+ export type OnAppCreatedHook = ({ app, router, ctx, initialState, ssrContext, staticImports }: {
42
43
  app: App;
43
44
  router: Router;
44
45
  ctx: {
@@ -52,17 +53,14 @@ export type onAppCreatedHook = ({ app, router, ctx, initialState, ssrContext }:
52
53
  [key: string]: unknown;
53
54
  };
54
55
  ssrContext?: SSRContext;
55
- }) => Promise<void> | void;
56
- export type OnBootHook = ({ app, ssrContext, staticImports }: {
57
- app: App;
58
- ssrContext: SSRContext;
59
56
  staticImports?: Record<string, any>;
60
57
  }) => Promise<void> | void;
58
+ export type OnAppMountedHookFile = URL;
61
59
  export type OnAppMountedHook = ({ instance }: {
62
60
  instance: ComponentInternalInstance;
63
61
  }) => Promise<void> | void;
64
62
  export type StaticImports = Record<string, string[]>;
65
- export type OnSetupFile = URL;
63
+ export type OnSetupHookFile = URL;
66
64
  export type OnSetupHook = (fastify: FastifyInstance, options?: {
67
65
  vite?: ViteDevServer;
68
66
  }) => any;
@@ -71,10 +69,12 @@ export type Render = (url: string, manifest: Record<string, unknown>, ssrContext
71
69
  preloadLinks: string;
72
70
  app: App;
73
71
  }>;
74
- export type OnRenderedHook = ({ app, ssrContext }: {
72
+ export type OnAppRenderedHookFile = URL;
73
+ export type OnAppRenderedHook = ({ app, ssrContext }: {
75
74
  app: App;
76
75
  ssrContext?: SSRContext;
77
76
  }) => Promise<void> | void;
77
+ export type OnTemplateRenderedHookFile = URL;
78
78
  export type OnTemplateRenderedHook = ({ html, ssrContext }: {
79
79
  html: string;
80
80
  ssrContext?: SSRContext;
@@ -98,27 +98,39 @@ export interface VitrifyConfig extends ViteUserConfig {
98
98
  /**
99
99
  * setup() is called directly after instantiating fastify. Use it to register your own plugins, routes etc.
100
100
  */
101
- onSetup?: OnSetupFile[];
101
+ onSetup?: OnSetupHookFile[];
102
+ /**
103
+ * Functions which run directly after initializing the application
104
+ */
105
+ onAppCreated?: OnAppCreatedHook[];
106
+ /**
107
+ * Functions which run directly after initializing the application
108
+ */
109
+ onAppCreatedFiles?: OnAppCreatedHookFile[];
102
110
  /**
103
111
  * Functions which run in the onMounted hook of the app
104
112
  */
105
113
  onAppMounted?: OnAppMountedHook[];
106
114
  /**
107
- * Functions which run after initializing the app
115
+ * Files with functions which run in the onMounted hook of the app
108
116
  */
109
- onBoot?: OnBootHook[];
117
+ onAppMountedFiles?: OnAppMountedHookFile[];
110
118
  /**
111
119
  * Functions which run after rendering the app (SSR)
112
120
  */
113
- onRendered?: OnRenderedHook[];
121
+ onAppRendered?: OnAppRenderedHook[];
122
+ /**
123
+ * Files with functions which run after rendering the app (SSR)
124
+ */
125
+ onAppRenderedFiles?: OnAppRenderedHookFile[];
114
126
  /**
115
127
  * Functions which run after rendering the template (SSR)
116
128
  */
117
129
  onTemplateRendered?: OnTemplateRenderedHook[];
118
130
  /**
119
- * Functions which run directly after initializing the application
131
+ * Files with functions which run after rendering the template (SSR)
120
132
  */
121
- onAppCreated?: onAppCreatedHook[];
133
+ onTemplateRenderedFiles?: OnTemplateRenderedHookFile[];
122
134
  };
123
135
  /**
124
136
  * Global SASS variables
@@ -145,6 +157,9 @@ export interface VitrifyConfig extends ViteUserConfig {
145
157
  * SSR specific configuration
146
158
  */
147
159
  ssr?: {
160
+ /**
161
+ * Packages which should not be bundled but installed on the server instead.
162
+ */
148
163
  serverModules?: string[];
149
164
  fastify?: FastifyServerOptions;
150
165
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitrify",
3
- "version": "0.24.2",
3
+ "version": "0.25.1",
4
4
  "license": "MIT",
5
5
  "author": "Stefan van Herwijnen",
6
6
  "description": "Vite as your Full Stack development tool",
@@ -55,10 +55,10 @@
55
55
  "@fastify/middie": "^9.0.3",
56
56
  "@fastify/one-line-logger": "^2.0.2",
57
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",
58
+ "@unocss/core": "^66.2.3",
59
+ "@unocss/preset-uno": "^66.2.3",
60
+ "@unocss/preset-web-fonts": "66.2.3",
61
+ "@unocss/preset-wind": "^66.2.3",
62
62
  "@vitejs/plugin-vue": "^5.2.4",
63
63
  "ajv": "^8.17.1",
64
64
  "animated-unocss": "^0.0.6",
@@ -67,54 +67,54 @@
67
67
  "cross-env": "^7.0.3",
68
68
  "devalue": "^5.1.1",
69
69
  "esbuild": "^0.25.5",
70
- "fastify": "^5.3.3",
71
- "glob": "^11.0.2",
72
- "happy-dom": "^17.5.6",
70
+ "fastify": "^5.4.0",
71
+ "glob": "^11.0.3",
72
+ "happy-dom": "^18.0.1",
73
73
  "is-port-reachable": "^4.0.0",
74
74
  "magic-string": "^0.30.17",
75
75
  "merge-deep": "^3.0.3",
76
76
  "readline": "^1.3.0",
77
- "rollup-plugin-visualizer": "^6.0.1",
78
- "sass": "1.89.1",
77
+ "rollup-plugin-visualizer": "^6.0.3",
78
+ "sass": "1.89.2",
79
79
  "stringify-object": "^5.0.0",
80
80
  "ts-node": "^10.9.2",
81
- "unocss": "^66.1.3",
81
+ "unocss": "^66.2.3",
82
82
  "unplugin-vue-components": "^28.7.0",
83
83
  "vite": "^6.3.5",
84
84
  "vite-plugin-pwa": "^1.0.0",
85
85
  "vitefu": "^1.0.6",
86
- "vitest": "^3.2.0",
86
+ "vitest": "^3.2.4",
87
87
  "workbox-window": "^7.3.0"
88
88
  },
89
89
  "devDependencies": {
90
90
  "@iconify-json/mdi": "^1.2.3",
91
- "@pinia/colada": "^0.16.1",
91
+ "@pinia/colada": "^0.17.1",
92
92
  "@quasar/extras": "^1.17.0",
93
93
  "@quasar/quasar-ui-qmarkdown": "^2.0.5",
94
94
  "@quasar/quasar-ui-qmediaplayer": "^2.0.0-beta.0",
95
95
  "@types/connect": "^3.4.38",
96
96
  "@types/glob": "^8.1.0",
97
97
  "@types/merge-deep": "^3.0.3",
98
- "@types/node": "^22.15.29",
98
+ "@types/node": "^24.0.3",
99
99
  "@types/stringify-object": "^4.0.5",
100
100
  "@types/ws": "^8.18.1",
101
- "@unocss/preset-icons": "^66.1.3",
101
+ "@unocss/preset-icons": "^66.2.3",
102
102
  "@vue/runtime-core": "^3.5.16",
103
103
  "beasties": "^0.3.4",
104
104
  "css": "^3.0.0",
105
105
  "css-to-tailwind-translator": "^1.2.8",
106
- "pinia": "^3.0.2",
106
+ "pinia": "^3.0.3",
107
107
  "quasar": "^2.18.1",
108
- "rollup": "^4.41.1",
108
+ "rollup": "^4.43.0",
109
109
  "typescript": "^5.8.3",
110
110
  "vue": "^3.5.16",
111
111
  "vue-router": "^4.5.1"
112
112
  },
113
113
  "peerDependencies": {
114
114
  "@fastify/static": "^8.2.0",
115
- "@pinia/colada": "^0.16.1",
116
- "fastify": "^5.3.3",
117
- "pinia": "^3.0.2",
115
+ "@pinia/colada": "^0.17.1",
116
+ "fastify": "^5.4.0",
117
+ "pinia": "^3.0.3",
118
118
  "quasar": "^2.18.1",
119
119
  "vue": "^3.5.16",
120
120
  "vue-router": "^4.5.1"
@@ -94,7 +94,7 @@ cli
94
94
  manifest,
95
95
  render,
96
96
  getRoutes,
97
- onRendered,
97
+ onAppRendered,
98
98
  onTemplateRendered
99
99
  } = await loadSSRAssets({
100
100
  mode: 'ssg',
@@ -108,7 +108,7 @@ cli
108
108
  manifest,
109
109
  render,
110
110
  routes,
111
- onRendered,
111
+ onAppRendered,
112
112
  onTemplateRendered
113
113
  })
114
114
  break