vitrify 0.23.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.
package/dist/index.js CHANGED
@@ -210,7 +210,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
210
210
  let onBootHooks;
211
211
  let onRenderedHooks;
212
212
  let onTemplateRenderedHooks;
213
- let onMountedHooks;
213
+ let onAppMountedHooks;
214
214
  let onAppCreatedHooks;
215
215
  let onSetupFiles;
216
216
  let globalCss = [];
@@ -274,7 +274,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
274
274
  onRenderedHooks = config.vitrify?.hooks?.onRendered || [];
275
275
  onTemplateRenderedHooks =
276
276
  config.vitrify?.hooks?.onTemplateRendered || [];
277
- onMountedHooks = config.vitrify?.hooks?.onMounted || [];
277
+ onAppMountedHooks = config.vitrify?.hooks?.onAppMounted || [];
278
278
  onAppCreatedHooks = config.vitrify?.hooks?.onAppCreated || [];
279
279
  onSetupFiles = config?.vitrify?.hooks?.onSetup || [];
280
280
  globalCss = config.vitrify?.globalCss || [];
@@ -309,7 +309,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
309
309
  return `export const onBoot = [${onBootHooks
310
310
  .map((fn) => `${String(fn)}`)
311
311
  .join(', ')}]
312
- export const onMounted = [${onMountedHooks
312
+ export const onAppMounted = [${onAppMountedHooks
313
313
  .map((fn) => `${String(fn)}`)
314
314
  .join(', ')}]
315
315
  export const onRendered = [${onRenderedHooks
@@ -565,7 +565,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
565
565
  alias
566
566
  },
567
567
  build: {
568
- target: ssr === 'server' || ssr === 'fastify' ? 'esnext' : 'modules',
568
+ target: 'esnext',
569
569
  ssr: ssr === 'server' || ssr === 'fastify' ? true : false,
570
570
  ssrManifest: ssr === 'client' || ssr === 'ssg',
571
571
  rollupOptions
@@ -1,4 +1,4 @@
1
- const piniaonAppCreated = async ({ app, ctx, initialState, ssrContext }) => {
1
+ const piniaOnAppCreated = async ({ app, ctx, initialState, ssrContext }) => {
2
2
  const { createPinia } = await import('pinia');
3
3
  const pinia = createPinia();
4
4
  ctx.pinia = pinia;
@@ -10,19 +10,18 @@ const piniaonAppCreated = async ({ app, ctx, initialState, ssrContext }) => {
10
10
  if (ssrContext)
11
11
  ssrContext.pinia = pinia;
12
12
  };
13
- const piniaOnRenderedHook = ({ app, ssrContext }) => {
13
+ const piniaOnRenderedHook = async ({ app, ssrContext }) => {
14
14
  // SSR Server
15
15
  if (ssrContext?.initialState && ssrContext.pinia) {
16
16
  ssrContext.initialState.pinia = ssrContext.pinia.state.value;
17
17
  }
18
18
  };
19
19
  const piniaColadaonAppCreated = async ({ app, ctx, initialState }) => {
20
- if (ctx?.pinia) {
21
- const { PiniaColada, useQueryCache, hydrateQueryCache } = await import('@pinia/colada');
20
+ if (ctx.pinia) {
21
+ const { PiniaColada, hydrateQueryCache, useQueryCache } = await import('@pinia/colada');
22
22
  app.use(PiniaColada);
23
- // SSR Client
24
23
  if (initialState?.piniaColada) {
25
- hydrateQueryCache(useQueryCache(ctx.pinia), initialState.piniaColada);
24
+ app.runWithContext(() => hydrateQueryCache(useQueryCache(ctx.pinia), initialState.piniaColada || {}));
26
25
  }
27
26
  }
28
27
  };
@@ -34,11 +33,11 @@ const piniaColadaOnRenderedHook = async ({ app, ssrContext }) => {
34
33
  if (ssrContext.initialState.pinia?._pc_query) {
35
34
  delete ssrContext.initialState.pinia._pc_query;
36
35
  }
37
- ssrContext.initialState.piniaColada = serializeQueryCache(useQueryCache(ssrContext.pinia));
36
+ ssrContext.initialState.piniaColada = app.runWithContext(() => serializeQueryCache(useQueryCache()));
38
37
  }
39
38
  };
40
39
  export const PiniaPlugin = async ({ ssr = false, pwa = false, options = {} }) => {
41
- const onAppCreated = [piniaonAppCreated];
40
+ const onAppCreated = [piniaOnAppCreated];
42
41
  const onRendered = [piniaOnRenderedHook];
43
42
  if (options.colada) {
44
43
  onAppCreated.push(piniaColadaonAppCreated);
@@ -62,8 +62,8 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false, options }) => {
62
62
  urls.packages[val] = new URL(`file://${pkgDir}`);
63
63
  }
64
64
  })();
65
- const onMountedHooks = [
66
- async (instance) => {
65
+ const onAppMountedHooks = [
66
+ async ({ instance }) => {
67
67
  const { proxy: { $q } } = instance;
68
68
  if ($q.onSSRHydrated !== void 0)
69
69
  $q.onSSRHydrated();
@@ -118,7 +118,7 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false, options }) => {
118
118
  },
119
119
  hooks: {
120
120
  onBoot: onBootHooks,
121
- onMounted: onMountedHooks,
121
+ onAppMounted: onAppMountedHooks,
122
122
  onTemplateRendered: [injectSsrContext]
123
123
  },
124
124
  sass: quasarConf.disableSass
@@ -1,2 +1,2 @@
1
- import type { OnBootHook, onAppCreatedHook, OnMountedHook, OnRenderedHook, OnTemplateRenderedHook, OnSetupFile, OnSetupHook } from '../vitrify-config.js';
2
- export { OnBootHook, onAppCreatedHook, OnMountedHook, OnRenderedHook, OnTemplateRenderedHook, OnSetupFile, OnSetupHook };
1
+ import type { OnBootHook, onAppCreatedHook, OnAppMountedHook, OnRenderedHook, OnTemplateRenderedHook, OnSetupFile, OnSetupHook } from '../vitrify-config.js';
2
+ export { OnBootHook, onAppCreatedHook, OnAppMountedHook, OnRenderedHook, OnTemplateRenderedHook, OnSetupFile, OnSetupHook };
@@ -58,7 +58,9 @@ export type OnBootHook = ({ app, ssrContext, staticImports }: {
58
58
  ssrContext: SSRContext;
59
59
  staticImports?: Record<string, any>;
60
60
  }) => Promise<void> | void;
61
- export type OnMountedHook = (instance: ComponentInternalInstance) => Promise<void> | void;
61
+ export type OnAppMountedHook = ({ instance }: {
62
+ instance: ComponentInternalInstance;
63
+ }) => Promise<void> | void;
62
64
  export type StaticImports = Record<string, string[]>;
63
65
  export type OnSetupFile = URL;
64
66
  export type OnSetupHook = (fastify: FastifyInstance, options?: {
@@ -100,7 +102,7 @@ export interface VitrifyConfig extends ViteUserConfig {
100
102
  /**
101
103
  * Functions which run in the onMounted hook of the app
102
104
  */
103
- onMounted?: OnMountedHook[];
105
+ onAppMounted?: OnAppMountedHook[];
104
106
  /**
105
107
  * Functions which run after initializing the app
106
108
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitrify",
3
- "version": "0.23.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",
@@ -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.2",
59
- "@unocss/preset-uno": "^66.1.2",
60
- "@unocss/preset-web-fonts": "66.1.2",
61
- "@unocss/preset-wind": "^66.1.2",
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
62
  "@vitejs/plugin-vue": "^5.2.4",
63
63
  "ajv": "^8.17.1",
64
64
  "animated-unocss": "^0.0.6",
@@ -66,24 +66,24 @@
66
66
  "chalk": "^5.4.1",
67
67
  "cross-env": "^7.0.3",
68
68
  "devalue": "^5.1.1",
69
- "esbuild": "^0.25.4",
69
+ "esbuild": "^0.25.5",
70
70
  "fastify": "^5.3.3",
71
71
  "glob": "^11.0.2",
72
- "happy-dom": "^17.4.7",
72
+ "happy-dom": "^17.5.6",
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": "^5.14.0",
78
- "sass": "1.89.0",
77
+ "rollup-plugin-visualizer": "^6.0.1",
78
+ "sass": "1.89.1",
79
79
  "stringify-object": "^5.0.0",
80
80
  "ts-node": "^10.9.2",
81
- "unocss": "^66.1.2",
82
- "unplugin-vue-components": "^28.5.0",
81
+ "unocss": "^66.1.3",
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.1.4",
86
+ "vitest": "^3.2.0",
87
87
  "workbox-window": "^7.3.0"
88
88
  },
89
89
  "devDependencies": {
@@ -95,19 +95,19 @@
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.21",
98
+ "@types/node": "^22.15.29",
99
99
  "@types/stringify-object": "^4.0.5",
100
100
  "@types/ws": "^8.18.1",
101
- "@unocss/preset-icons": "^66.1.2",
102
- "@vue/runtime-core": "^3.5.14",
101
+ "@unocss/preset-icons": "^66.1.3",
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
106
  "pinia": "^3.0.2",
107
107
  "quasar": "^2.18.1",
108
- "rollup": "^4.41.0",
108
+ "rollup": "^4.41.1",
109
109
  "typescript": "^5.8.3",
110
- "vue": "^3.5.13",
110
+ "vue": "^3.5.16",
111
111
  "vue-router": "^4.5.1"
112
112
  },
113
113
  "peerDependencies": {
@@ -116,7 +116,7 @@
116
116
  "fastify": "^5.3.3",
117
117
  "pinia": "^3.0.2",
118
118
  "quasar": "^2.18.1",
119
- "vue": "^3.5.13",
119
+ "vue": "^3.5.16",
120
120
  "vue-router": "^4.5.1"
121
121
  },
122
122
  "publishConfig": {
@@ -1,7 +1,7 @@
1
1
  import type {
2
2
  OnBootHook,
3
3
  onAppCreatedHook,
4
- OnMountedHook,
4
+ OnAppMountedHook,
5
5
  OnRenderedHook,
6
6
  OnTemplateRenderedHook,
7
7
  OnSetupFile,
@@ -11,7 +11,7 @@ import type {
11
11
  export {
12
12
  OnBootHook,
13
13
  onAppCreatedHook,
14
- OnMountedHook,
14
+ OnAppMountedHook,
15
15
  OnRenderedHook,
16
16
  OnTemplateRenderedHook,
17
17
  OnSetupFile,
package/src/node/index.ts CHANGED
@@ -17,7 +17,7 @@ import { visualizer } from 'rollup-plugin-visualizer'
17
17
  import { fileURLToPath } from 'url'
18
18
  import type {
19
19
  StaticImports,
20
- OnMountedHook,
20
+ OnAppMountedHook,
21
21
  VitrifyConfig,
22
22
  VitrifyConfigAsync,
23
23
  VitrifyCommands,
@@ -281,7 +281,7 @@ export const baseConfig = async ({
281
281
  let onBootHooks: OnBootHook[]
282
282
  let onRenderedHooks: OnRenderedHook[]
283
283
  let onTemplateRenderedHooks: OnTemplateRenderedHook[]
284
- let onMountedHooks: OnMountedHook[]
284
+ let onAppMountedHooks: OnAppMountedHook[]
285
285
  let onAppCreatedHooks: onAppCreatedHook[]
286
286
  let onSetupFiles: OnSetupFile[]
287
287
  let globalCss: string[] = []
@@ -362,7 +362,7 @@ export const baseConfig = async ({
362
362
  onRenderedHooks = config.vitrify?.hooks?.onRendered || []
363
363
  onTemplateRenderedHooks =
364
364
  config.vitrify?.hooks?.onTemplateRendered || []
365
- onMountedHooks = config.vitrify?.hooks?.onMounted || []
365
+ onAppMountedHooks = config.vitrify?.hooks?.onAppMounted || []
366
366
  onAppCreatedHooks = config.vitrify?.hooks?.onAppCreated || []
367
367
  onSetupFiles = config?.vitrify?.hooks?.onSetup || []
368
368
  globalCss = config.vitrify?.globalCss || []
@@ -395,7 +395,7 @@ export const baseConfig = async ({
395
395
  return `export const onBoot = [${onBootHooks
396
396
  .map((fn) => `${String(fn)}`)
397
397
  .join(', ')}]
398
- export const onMounted = [${onMountedHooks
398
+ export const onAppMounted = [${onAppMountedHooks
399
399
  .map((fn) => `${String(fn)}`)
400
400
  .join(', ')}]
401
401
  export const onRendered = [${onRenderedHooks
@@ -688,7 +688,7 @@ export const baseConfig = async ({
688
688
  alias
689
689
  },
690
690
  build: {
691
- target: ssr === 'server' || ssr === 'fastify' ? 'esnext' : 'modules',
691
+ target: 'esnext',
692
692
  ssr: ssr === 'server' || ssr === 'fastify' ? true : false,
693
693
  ssrManifest: ssr === 'client' || ssr === 'ssg',
694
694
  rollupOptions
@@ -6,7 +6,7 @@ export type PiniaPluginOptions = {
6
6
  colada?: boolean
7
7
  }
8
8
 
9
- const piniaonAppCreated: onAppCreatedHook = async ({
9
+ const piniaOnAppCreated: onAppCreatedHook = async ({
10
10
  app,
11
11
  ctx,
12
12
  initialState,
@@ -23,7 +23,7 @@ const piniaonAppCreated: onAppCreatedHook = async ({
23
23
  if (ssrContext) ssrContext.pinia = pinia
24
24
  }
25
25
 
26
- const piniaOnRenderedHook: OnRenderedHook = ({ app, ssrContext }) => {
26
+ const piniaOnRenderedHook: OnRenderedHook = async ({ app, ssrContext }) => {
27
27
  // SSR Server
28
28
  if (ssrContext?.initialState && ssrContext.pinia) {
29
29
  ssrContext.initialState.pinia = ssrContext.pinia.state.value
@@ -35,16 +35,19 @@ const piniaColadaonAppCreated: onAppCreatedHook = async ({
35
35
  ctx,
36
36
  initialState
37
37
  }) => {
38
- if (ctx?.pinia) {
39
- const { PiniaColada, useQueryCache, hydrateQueryCache } = await import(
38
+ if (ctx.pinia) {
39
+ const { PiniaColada, hydrateQueryCache, useQueryCache } = await import(
40
40
  '@pinia/colada'
41
41
  )
42
-
43
42
  app.use(PiniaColada)
44
43
 
45
- // SSR Client
46
44
  if (initialState?.piniaColada) {
47
- hydrateQueryCache(useQueryCache(ctx.pinia), initialState.piniaColada)
45
+ app.runWithContext(() =>
46
+ hydrateQueryCache(
47
+ useQueryCache(ctx.pinia),
48
+ initialState.piniaColada || {}
49
+ )
50
+ )
48
51
  }
49
52
  }
50
53
  }
@@ -61,8 +64,8 @@ const piniaColadaOnRenderedHook: OnRenderedHook = async ({
61
64
  if (ssrContext.initialState.pinia?._pc_query) {
62
65
  delete ssrContext.initialState.pinia._pc_query
63
66
  }
64
- ssrContext.initialState.piniaColada = serializeQueryCache(
65
- useQueryCache(ssrContext.pinia)
67
+ ssrContext.initialState.piniaColada = app.runWithContext(() =>
68
+ serializeQueryCache(useQueryCache())
66
69
  )
67
70
  }
68
71
  }
@@ -72,7 +75,7 @@ export const PiniaPlugin: VitrifyPlugin<PiniaPluginOptions> = async ({
72
75
  pwa = false,
73
76
  options = {}
74
77
  }) => {
75
- const onAppCreated = [piniaonAppCreated]
78
+ const onAppCreated = [piniaOnAppCreated]
76
79
  const onRendered = [piniaOnRenderedHook]
77
80
  if (options.colada) {
78
81
  onAppCreated.push(piniaColadaonAppCreated)
@@ -1,7 +1,7 @@
1
1
  import { fileURLToPath } from 'url'
2
2
  import type {
3
3
  OnBootHook,
4
- OnMountedHook,
4
+ OnAppMountedHook,
5
5
  OnTemplateRenderedHook,
6
6
  VitrifyConfig
7
7
  } from '../../vitrify-config.js'
@@ -136,8 +136,8 @@ export const QuasarPlugin: VitrifyPlugin<QuasarPluginOptions> = async ({
136
136
  }
137
137
  })()
138
138
 
139
- const onMountedHooks: OnMountedHook[] = [
140
- async (instance) => {
139
+ const onAppMountedHooks: OnAppMountedHook[] = [
140
+ async ({ instance }) => {
141
141
  const {
142
142
  proxy: { $q }
143
143
  } = instance
@@ -203,7 +203,7 @@ export const QuasarPlugin: VitrifyPlugin<QuasarPluginOptions> = async ({
203
203
  },
204
204
  hooks: {
205
205
  onBoot: onBootHooks,
206
- onMounted: onMountedHooks,
206
+ onAppMounted: onAppMountedHooks,
207
207
  onTemplateRendered: [injectSsrContext]
208
208
  },
209
209
  sass: quasarConf.disableSass
@@ -81,9 +81,11 @@ export type OnBootHook = ({
81
81
  staticImports?: Record<string, any>
82
82
  }) => Promise<void> | void
83
83
 
84
- export type OnMountedHook = (
84
+ export type OnAppMountedHook = ({
85
+ instance
86
+ }: {
85
87
  instance: ComponentInternalInstance
86
- ) => Promise<void> | void
88
+ }) => Promise<void> | void
87
89
  export type StaticImports = Record<string, string[]>
88
90
 
89
91
  export type OnSetupFile = URL
@@ -144,7 +146,7 @@ export interface VitrifyConfig extends ViteUserConfig {
144
146
  /**
145
147
  * Functions which run in the onMounted hook of the app
146
148
  */
147
- onMounted?: OnMountedHook[]
149
+ onAppMounted?: OnAppMountedHook[]
148
150
  /**
149
151
  * Functions which run after initializing the app
150
152
  */
@@ -8,16 +8,15 @@ import {
8
8
  onMounted as onMountedVue,
9
9
  getCurrentInstance
10
10
  } from 'vue'
11
- import { onMounted } from 'virtual:vitrify-hooks'
12
- import * as staticImports from 'virtual:static-imports'
11
+ import { onAppMounted } from 'virtual:vitrify-hooks'
13
12
  import App from 'src/App.vue'
14
13
  // import 'vitrify.sass'
15
14
  const instance = getCurrentInstance()
16
15
  const props = defineProps()
17
16
 
18
17
  onMountedVue(async () => {
19
- for (let fn of onMounted) {
20
- await fn(instance, staticImports)
18
+ for (let fn of onAppMounted) {
19
+ await fn({ instance })
21
20
  }
22
21
  })
23
22