vitrify 0.21.0 → 0.23.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/bin/cli.js +3 -3
- package/dist/bin/dev.js +26 -39
- package/dist/frameworks/vue/fastify-ssr-plugin.js +58 -19
- package/dist/frameworks/vue/prerender.js +4 -4
- package/dist/frameworks/vue/server.js +5 -1
- package/dist/hooks/index.js +1 -0
- package/dist/index.js +80 -94
- package/dist/plugins/index.js +2 -1
- package/dist/plugins/pinia/index.js +61 -0
- package/dist/plugins/quasar/index.js +226 -0
- package/dist/types/frameworks/vue/fastify-ssr-plugin.d.ts +6 -3
- package/dist/types/frameworks/vue/prerender.d.ts +3 -3
- package/dist/types/frameworks/vue/server.d.ts +4 -4
- package/dist/types/hooks/index.d.ts +2 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/plugins/index.d.ts +13 -2
- package/dist/types/plugins/pinia/index.d.ts +5 -0
- package/dist/types/plugins/{quasar.d.ts → quasar/index.d.ts} +5 -5
- package/dist/types/vitrify-config.d.ts +87 -12
- package/package.json +37 -25
- package/src/node/bin/cli.ts +13 -7
- package/src/node/bin/dev.ts +30 -41
- package/src/node/frameworks/vue/fastify-ssr-plugin.ts +85 -28
- package/src/node/frameworks/vue/prerender.ts +6 -6
- package/src/node/frameworks/vue/server.ts +11 -2
- package/src/node/hooks/index.ts +19 -0
- package/src/node/index.ts +114 -130
- package/src/node/plugins/index.ts +20 -3
- package/src/node/plugins/pinia/index.ts +96 -0
- package/src/node/plugins/quasar/index.ts +318 -0
- package/src/node/vitrify-config.ts +120 -21
- package/src/vite/fastify/server.ts +3 -0
- package/src/vite/vue/RootComponent.vue +1 -1
- package/src/vite/vue/main.ts +52 -22
- package/src/vite/vue/ssr/app.ts +3 -2
- package/src/vite/vue/ssr/entry-server.ts +22 -41
- package/src/vite/vue/ssr/prerender.ts +2 -2
- package/dist/plugins/quasar.js +0 -217
- package/src/node/plugins/quasar.ts +0 -307
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const piniaonAppCreated = async ({ app, ctx, initialState, ssrContext }) => {
|
|
2
|
+
const { createPinia } = await import('pinia');
|
|
3
|
+
const pinia = createPinia();
|
|
4
|
+
ctx.pinia = pinia;
|
|
5
|
+
app.use(pinia);
|
|
6
|
+
// SSR Client
|
|
7
|
+
if (initialState?.pinia)
|
|
8
|
+
pinia.state.value = initialState.pinia;
|
|
9
|
+
// SSR Server
|
|
10
|
+
if (ssrContext)
|
|
11
|
+
ssrContext.pinia = pinia;
|
|
12
|
+
};
|
|
13
|
+
const piniaOnRenderedHook = ({ app, ssrContext }) => {
|
|
14
|
+
// SSR Server
|
|
15
|
+
if (ssrContext?.initialState && ssrContext.pinia) {
|
|
16
|
+
ssrContext.initialState.pinia = ssrContext.pinia.state.value;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const piniaColadaonAppCreated = async ({ app, ctx, initialState }) => {
|
|
20
|
+
if (ctx?.pinia) {
|
|
21
|
+
const { PiniaColada, useQueryCache, hydrateQueryCache } = await import('@pinia/colada');
|
|
22
|
+
app.use(PiniaColada);
|
|
23
|
+
// SSR Client
|
|
24
|
+
if (initialState?.piniaColada) {
|
|
25
|
+
hydrateQueryCache(useQueryCache(ctx.pinia), initialState.piniaColada);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const piniaColadaOnRenderedHook = async ({ app, ssrContext }) => {
|
|
30
|
+
// SSR Server
|
|
31
|
+
if (ssrContext?.initialState && ssrContext.pinia) {
|
|
32
|
+
const { useQueryCache, serializeQueryCache } = await import('@pinia/colada');
|
|
33
|
+
// Delete to prevent Non-POJO error
|
|
34
|
+
if (ssrContext.initialState.pinia?._pc_query) {
|
|
35
|
+
delete ssrContext.initialState.pinia._pc_query;
|
|
36
|
+
}
|
|
37
|
+
ssrContext.initialState.piniaColada = serializeQueryCache(useQueryCache(ssrContext.pinia));
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
export const PiniaPlugin = async ({ ssr = false, pwa = false, options = {} }) => {
|
|
41
|
+
const onAppCreated = [piniaonAppCreated];
|
|
42
|
+
const onRendered = [piniaOnRenderedHook];
|
|
43
|
+
if (options.colada) {
|
|
44
|
+
onAppCreated.push(piniaColadaonAppCreated);
|
|
45
|
+
onRendered.push(piniaColadaOnRenderedHook);
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
plugins: [],
|
|
49
|
+
config: {
|
|
50
|
+
vitrify: {
|
|
51
|
+
ssr: {
|
|
52
|
+
serverModules: ['@pinia/colada']
|
|
53
|
+
},
|
|
54
|
+
hooks: {
|
|
55
|
+
onAppCreated,
|
|
56
|
+
onRendered
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
};
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { fileURLToPath } from 'url';
|
|
2
|
+
import { findDepPkgJsonPath } from 'vitefu';
|
|
3
|
+
import { QuasarResolver } from 'unplugin-vue-components/resolvers';
|
|
4
|
+
export const injectSsrContext = ({ html, ssrContext }) => html
|
|
5
|
+
.replace(/(<html[^>]*)(>)/i, (found, start, end) => {
|
|
6
|
+
let matches;
|
|
7
|
+
matches = found.match(/\sdir\s*=\s*['"]([^'"]*)['"]/i);
|
|
8
|
+
if (matches) {
|
|
9
|
+
start = start.replace(matches[0], '');
|
|
10
|
+
}
|
|
11
|
+
matches = found.match(/\slang\s*=\s*['"]([^'"]*)['"]/i);
|
|
12
|
+
if (matches) {
|
|
13
|
+
start = start.replace(matches[0], '');
|
|
14
|
+
}
|
|
15
|
+
return `${start} ${ssrContext?._meta.htmlAttrs || ''} ${end}`;
|
|
16
|
+
})
|
|
17
|
+
.replace(/(<head[^>]*)(>)/i, (_, start, end) => `${start}${end}${ssrContext?._meta.headTags || ''}`)
|
|
18
|
+
.replace(/(<\/head>)/i, (_, tag) => `${ssrContext?._meta.resourceStyles || ''}${ssrContext?._meta.endingHeadTags || ''}${tag}`)
|
|
19
|
+
.replace(/(<body[^>]*)(>)/i, (found, start, end) => {
|
|
20
|
+
let classes = ssrContext?._meta.bodyClasses || '';
|
|
21
|
+
const matches = found.match(/\sclass\s*=\s*['"]([^'"]*)['"]/i);
|
|
22
|
+
if (matches) {
|
|
23
|
+
if (matches[1].length > 0) {
|
|
24
|
+
classes += ` ${matches[1]}`;
|
|
25
|
+
}
|
|
26
|
+
start = start.replace(matches[0], '');
|
|
27
|
+
}
|
|
28
|
+
return `${start} class="${classes.trim()}" ${ssrContext?._meta.bodyAttrs || ''}${end}${ssrContext?._meta.bodyTags || ''}`;
|
|
29
|
+
});
|
|
30
|
+
export const QuasarPlugin = async ({ ssr = false, pwa = false, options }) => {
|
|
31
|
+
let plugins = [];
|
|
32
|
+
const quasarConf = options;
|
|
33
|
+
return {
|
|
34
|
+
plugins: [
|
|
35
|
+
{
|
|
36
|
+
name: 'vite-plugin-quasar-transform',
|
|
37
|
+
enforce: 'pre',
|
|
38
|
+
transform: (code, id, options) => {
|
|
39
|
+
code = code
|
|
40
|
+
.replaceAll('__QUASAR_SSR__', ssr ? 'true' : 'false')
|
|
41
|
+
.replaceAll('__QUASAR_SSR_SERVER__', ssr ? '(import.meta.env.SSR === true)' : 'false')
|
|
42
|
+
.replaceAll('__QUASAR_SSR_CLIENT__', ssr ? '(import.meta.env.SSR === false)' : 'false')
|
|
43
|
+
.replaceAll('__QUASAR_SSR_PWA__', ssr && pwa ? '(import.meta.env.SSR === false)' : 'false');
|
|
44
|
+
return code;
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'vite-plugin-quasar-setup',
|
|
49
|
+
enforce: 'pre',
|
|
50
|
+
config: async (config, env) => {
|
|
51
|
+
const { vitrify: { urls } = {} } = config;
|
|
52
|
+
// if (quasar) quasarConf = quasar
|
|
53
|
+
if (!quasarConf.framework.lang && config.vitrify?.lang)
|
|
54
|
+
quasarConf.framework.lang = config.vitrify.lang;
|
|
55
|
+
const globalCss = quasarConf?.extras?.map((extra) => `@quasar/extras/${extra}/${extra}.css`);
|
|
56
|
+
const localPackages = ['@quasar/extras', 'quasar'];
|
|
57
|
+
// const localPackages: string[] = []
|
|
58
|
+
await (async () => {
|
|
59
|
+
for (const val of localPackages) {
|
|
60
|
+
const pkgDir = await findDepPkgJsonPath(val, fileURLToPath(config.vitrify.urls.app));
|
|
61
|
+
if (pkgDir)
|
|
62
|
+
urls.packages[val] = new URL(`file://${pkgDir}`);
|
|
63
|
+
}
|
|
64
|
+
})();
|
|
65
|
+
const onMountedHooks = [
|
|
66
|
+
async (instance) => {
|
|
67
|
+
const { proxy: { $q } } = instance;
|
|
68
|
+
if ($q.onSSRHydrated !== void 0)
|
|
69
|
+
$q.onSSRHydrated();
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
const onBootHooks = [
|
|
73
|
+
async ({ app, ssrContext, staticImports }) => {
|
|
74
|
+
// @ts-expect-error undefined
|
|
75
|
+
const quasarPlugins = await import('virtual:quasar-plugins');
|
|
76
|
+
// @ts-expect-error undefined
|
|
77
|
+
const directives = await import('virtual:quasar-directives');
|
|
78
|
+
// @ts-expect-error undefined
|
|
79
|
+
const { default: lang } = await import('virtual:quasar-lang');
|
|
80
|
+
const { default: iconSet } = await import(
|
|
81
|
+
// @ts-expect-error undefined
|
|
82
|
+
'virtual:quasar-iconSet');
|
|
83
|
+
const { default: iconMapFn } = await import(
|
|
84
|
+
// @ts-expect-error undefined
|
|
85
|
+
'virtual:quasar-iconMapFn');
|
|
86
|
+
app.use(staticImports?.Quasar, {
|
|
87
|
+
plugins: quasarPlugins,
|
|
88
|
+
directives,
|
|
89
|
+
lang,
|
|
90
|
+
iconSet,
|
|
91
|
+
config: {
|
|
92
|
+
iconMapFn
|
|
93
|
+
}
|
|
94
|
+
}, ssrContext);
|
|
95
|
+
}
|
|
96
|
+
];
|
|
97
|
+
/**
|
|
98
|
+
* Importing package.json is problematic
|
|
99
|
+
*/
|
|
100
|
+
const version = '?';
|
|
101
|
+
/**
|
|
102
|
+
* All components should have been auto-imported
|
|
103
|
+
*/
|
|
104
|
+
if (quasarConf?.framework?.plugins) {
|
|
105
|
+
if (!quasarConf.framework)
|
|
106
|
+
quasarConf.framework = {};
|
|
107
|
+
quasarConf.framework.plugins = [
|
|
108
|
+
...new Set(quasarConf.framework.plugins)
|
|
109
|
+
];
|
|
110
|
+
plugins = quasarConf?.framework.plugins;
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
vitrify: {
|
|
114
|
+
urls,
|
|
115
|
+
globalCss,
|
|
116
|
+
staticImports: {
|
|
117
|
+
quasar: ['Quasar']
|
|
118
|
+
},
|
|
119
|
+
hooks: {
|
|
120
|
+
onBoot: onBootHooks,
|
|
121
|
+
onMounted: onMountedHooks,
|
|
122
|
+
onTemplateRendered: [injectSsrContext]
|
|
123
|
+
},
|
|
124
|
+
sass: quasarConf.disableSass
|
|
125
|
+
? undefined
|
|
126
|
+
: {
|
|
127
|
+
global: ['quasar/src/css/index.sass']
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
resolve: {
|
|
131
|
+
alias: [
|
|
132
|
+
{
|
|
133
|
+
find: 'quasar/src/',
|
|
134
|
+
replacement: fileURLToPath(new URL('./src/', config.vitrify.urls.packages.quasar))
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
optimizeDeps: {
|
|
139
|
+
exclude: ['quasar']
|
|
140
|
+
},
|
|
141
|
+
define: {
|
|
142
|
+
__DEV__: process.env.NODE_ENV !== 'production' || true,
|
|
143
|
+
__QUASAR_VERSION__: `'${version}'`
|
|
144
|
+
},
|
|
145
|
+
ssr: {
|
|
146
|
+
noExternal: ['quasar']
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: 'quasar-virtual-modules',
|
|
153
|
+
enforce: 'pre',
|
|
154
|
+
config: async (config, env) => ({
|
|
155
|
+
resolve: {
|
|
156
|
+
alias: [
|
|
157
|
+
{
|
|
158
|
+
find: new RegExp('^quasar$'),
|
|
159
|
+
replacement: 'virtual:quasar'
|
|
160
|
+
}
|
|
161
|
+
// { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
}),
|
|
165
|
+
resolveId(id) {
|
|
166
|
+
switch (id) {
|
|
167
|
+
case 'virtual:quasar-plugins':
|
|
168
|
+
return 'virtual:quasar-plugins';
|
|
169
|
+
case 'virtual:quasar-directives':
|
|
170
|
+
return 'virtual:quasar-directives';
|
|
171
|
+
case 'virtual:quasar-lang':
|
|
172
|
+
return 'virtual:quasar-lang';
|
|
173
|
+
case 'virtual:quasar-iconSet':
|
|
174
|
+
return 'virtual:quasar-iconSet';
|
|
175
|
+
case 'virtual:quasar-iconMapFn':
|
|
176
|
+
return 'virtual:quasar-iconMapFn';
|
|
177
|
+
case 'virtual:quasar':
|
|
178
|
+
return { id: 'virtual:quasar', moduleSideEffects: false };
|
|
179
|
+
default:
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
load(id) {
|
|
184
|
+
if (id === 'virtual:quasar-plugins') {
|
|
185
|
+
return `export { ${plugins.join(',')} } from 'quasar'`;
|
|
186
|
+
}
|
|
187
|
+
else if (id === 'virtual:quasar-directives') {
|
|
188
|
+
return `export * from 'quasar/src/directives.js'`;
|
|
189
|
+
}
|
|
190
|
+
else if (id === 'virtual:quasar-lang') {
|
|
191
|
+
return `import lang from 'quasar/lang/${quasarConf?.framework?.lang || 'en-US'}';
|
|
192
|
+
export default lang`;
|
|
193
|
+
}
|
|
194
|
+
else if (id === 'virtual:quasar-iconSet') {
|
|
195
|
+
return `${typeof quasarConf.framework.iconSet === 'string'
|
|
196
|
+
? `import iconSet from 'quasar/icon-set/${quasarConf?.framework.iconSet || 'material-icons'}';
|
|
197
|
+
export default iconSet`
|
|
198
|
+
: `export default ${quasarConf.framework.iconSet
|
|
199
|
+
? JSON.stringify(quasarConf.framework.iconSet)
|
|
200
|
+
: null}`}`;
|
|
201
|
+
}
|
|
202
|
+
else if (id === 'virtual:quasar-iconMapFn') {
|
|
203
|
+
return `export default ${quasarConf?.framework.iconMapFn?.toString() ?? null}`;
|
|
204
|
+
}
|
|
205
|
+
else if (id === 'virtual:quasar') {
|
|
206
|
+
return `export * from 'quasar/src/plugins.js';
|
|
207
|
+
export * from 'quasar/src/components.js';
|
|
208
|
+
export * from 'quasar/src/composables.js';
|
|
209
|
+
export * from 'quasar/src/directives.js';
|
|
210
|
+
export * from 'quasar/src/utils.js';
|
|
211
|
+
export * from 'quasar/src/composables.js';
|
|
212
|
+
export { default as Quasar } from 'quasar/src/install-quasar.js'`;
|
|
213
|
+
}
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
],
|
|
218
|
+
config: {
|
|
219
|
+
vitrify: {
|
|
220
|
+
unpluginVueComponents: {
|
|
221
|
+
resolvers: [QuasarResolver()]
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FastifyPluginAsync, FastifyRequest, FastifyReply } from 'fastify';
|
|
2
2
|
import type { ViteDevServer } from 'vite';
|
|
3
|
-
import type { OnRenderedHook } from '../../vitrify-config.js';
|
|
3
|
+
import type { OnRenderedHook, OnTemplateRenderedHook } from '../../vitrify-config.js';
|
|
4
4
|
type ProvideFn = (req: FastifyRequest, res: FastifyReply) => Promise<Record<string, unknown | {
|
|
5
5
|
value: unknown;
|
|
6
6
|
}>>;
|
|
@@ -10,6 +10,7 @@ export interface FastifySsrOptions {
|
|
|
10
10
|
vitrifyDir?: URL;
|
|
11
11
|
vite?: ViteDevServer;
|
|
12
12
|
onRendered?: OnRenderedHook[];
|
|
13
|
+
onTemplateRendered?: OnTemplateRenderedHook[];
|
|
13
14
|
appDir?: URL;
|
|
14
15
|
publicDir?: URL;
|
|
15
16
|
mode?: string;
|
|
@@ -18,13 +19,14 @@ export interface FastifySsrOptions {
|
|
|
18
19
|
declare const fastifySsrPlugin: FastifyPluginAsync<FastifySsrOptions>;
|
|
19
20
|
declare const renderHtml: (options: {
|
|
20
21
|
url: string;
|
|
21
|
-
|
|
22
|
+
req: FastifyRequest | {
|
|
22
23
|
headers: Record<string, unknown>;
|
|
23
24
|
url: string;
|
|
24
25
|
};
|
|
25
|
-
|
|
26
|
+
res: FastifyReply | Record<string, unknown>;
|
|
26
27
|
provide: Record<string, unknown>;
|
|
27
28
|
onRendered?: OnRenderedHook[];
|
|
29
|
+
onTemplateRendered?: OnTemplateRenderedHook[];
|
|
28
30
|
template: string;
|
|
29
31
|
manifest: Record<string, unknown>;
|
|
30
32
|
render: any;
|
|
@@ -38,6 +40,7 @@ declare const loadSSRAssets: ({ mode, distDir }?: {
|
|
|
38
40
|
render: any;
|
|
39
41
|
getRoutes: any;
|
|
40
42
|
onRendered: any;
|
|
43
|
+
onTemplateRendered: any;
|
|
41
44
|
}>;
|
|
42
45
|
export { fastifySsrPlugin, renderHtml, loadSSRAssets };
|
|
43
46
|
export type FastifySsrPlugin = typeof fastifySsrPlugin;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OnTemplateRenderedHook } from 'src/node/vitrify-config.js';
|
|
2
2
|
import { type RouteRecordRaw } from 'vue-router';
|
|
3
|
-
export declare const prerender: ({ outDir, template, manifest, render, routes,
|
|
3
|
+
export declare const prerender: ({ outDir, template, manifest, render, routes, onTemplateRendered }: {
|
|
4
4
|
outDir: string;
|
|
5
5
|
template: string;
|
|
6
6
|
manifest: Record<string, unknown>;
|
|
7
7
|
render: unknown;
|
|
8
8
|
routes: RouteRecordRaw[];
|
|
9
|
-
|
|
9
|
+
onTemplateRendered: OnTemplateRenderedHook[];
|
|
10
10
|
}) => Promise<void[]>;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { OnRenderedHook, OnSetupHook } from '../../vitrify-config.js';
|
|
1
|
+
import type { OnTemplateRenderedHook, OnSetupHook, OnRenderedHook } from '../../vitrify-config.js';
|
|
3
2
|
import type { FastifyCsrPlugin } from './fastify-csr-plugin.js';
|
|
4
3
|
import type { FastifySsrPlugin } from './fastify-ssr-plugin.js';
|
|
5
|
-
export declare const createApp: ({ onSetup, appDir, baseUrl, fastifyPlugin, onRendered, vitrifyDir, mode }: {
|
|
4
|
+
export declare const createApp: ({ onSetup, appDir, baseUrl, fastifyPlugin, onRendered, onTemplateRendered, vitrifyDir, mode }: {
|
|
6
5
|
onSetup: OnSetupHook[];
|
|
7
6
|
appDir: URL;
|
|
8
7
|
baseUrl?: string;
|
|
9
8
|
fastifyPlugin: FastifySsrPlugin | FastifyCsrPlugin;
|
|
10
9
|
onRendered?: OnRenderedHook[];
|
|
10
|
+
onTemplateRendered?: OnTemplateRenderedHook[];
|
|
11
11
|
vitrifyDir?: URL;
|
|
12
12
|
mode: string;
|
|
13
|
-
}) => FastifyInstance<import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault> & PromiseLike<FastifyInstance<import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault>> & {
|
|
13
|
+
}) => import("fastify").FastifyInstance<import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault> & PromiseLike<import("fastify").FastifyInstance<import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault>> & {
|
|
14
14
|
__linterBrands: "SafePromiseLike";
|
|
15
15
|
};
|
|
@@ -0,0 +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 };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InlineConfig } from 'vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { VitrifyConfig, VitrifyConfigAsync, VitrifyCommands, VitrifyModes, VitrifyUIFrameworks, VitrifySSRModes, OnBootHook } 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,
|
|
19
|
+
export type { VitrifyConfig, VitrifyConfigAsync, VitrifyPlugin, VitrifyContext, OnBootHook };
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
|
-
|
|
2
|
+
import { VitrifyConfig } from '../vitrify-config.js';
|
|
3
|
+
type VitrifyPluginReturnType = {
|
|
4
|
+
plugin: Plugin;
|
|
5
|
+
config?: Partial<VitrifyConfig>;
|
|
6
|
+
} | {
|
|
7
|
+
plugins: Plugin[];
|
|
8
|
+
config?: Partial<VitrifyConfig>;
|
|
9
|
+
};
|
|
10
|
+
export type VitrifyPlugin<Options> = ({ ssr, pwa, mode, command, options }: {
|
|
3
11
|
ssr?: 'server' | 'client' | 'ssg' | 'fastify' | false;
|
|
4
12
|
pwa?: boolean;
|
|
5
13
|
mode?: 'production' | 'development';
|
|
6
14
|
command?: 'build' | 'dev' | 'test';
|
|
7
|
-
|
|
15
|
+
options: Options;
|
|
16
|
+
}) => Promise<VitrifyPluginReturnType> | VitrifyPluginReturnType;
|
|
17
|
+
export * from './quasar/index.js';
|
|
18
|
+
export * from './pinia/index.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OnTemplateRenderedHook } from '../../vitrify-config.js';
|
|
2
|
+
import type { VitrifyPlugin } from '../index.js';
|
|
2
3
|
import { type QuasarFonts, type QuasarComponents, type QuasarDirectives, type QuasarIconSets, type QuasarPlugins, type GlobalQuasarIconMapFn, type QuasarIconSet } from 'quasar';
|
|
3
|
-
export interface
|
|
4
|
+
export interface QuasarPluginOptions {
|
|
4
5
|
framework: {
|
|
5
6
|
components?: (keyof QuasarComponents)[];
|
|
6
7
|
directives?: (keyof QuasarDirectives)[];
|
|
@@ -12,6 +13,5 @@ export interface QuasarConf {
|
|
|
12
13
|
extras?: (QuasarIconSets | QuasarFonts)[];
|
|
13
14
|
disableSass?: boolean;
|
|
14
15
|
}
|
|
15
|
-
export declare const injectSsrContext:
|
|
16
|
-
export declare const QuasarPlugin: VitrifyPlugin
|
|
17
|
-
export default QuasarPlugin;
|
|
16
|
+
export declare const injectSsrContext: OnTemplateRenderedHook;
|
|
17
|
+
export declare const QuasarPlugin: VitrifyPlugin<QuasarPluginOptions>;
|
|
@@ -1,30 +1,89 @@
|
|
|
1
1
|
import type { Alias, UserConfig as ViteUserConfig, ViteDevServer } from 'vite';
|
|
2
|
-
import type { QuasarConf } from './plugins/quasar.js';
|
|
3
2
|
import type { ComponentInternalInstance } from '@vue/runtime-core';
|
|
4
|
-
import type { FastifyInstance, FastifyServerOptions } from 'fastify';
|
|
3
|
+
import type { FastifyInstance, FastifyReply, FastifyRequest, FastifyServerOptions } from 'fastify';
|
|
5
4
|
import type { VitePWAOptions } from 'vite-plugin-pwa';
|
|
5
|
+
import type { Options as unpluginVueComponentsOptions } from 'unplugin-vue-components';
|
|
6
6
|
import type { UserConfig as UnoCSSUserConfig } from '@unocss/core';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import type { VitrifyPlugin } from './plugins/index.js';
|
|
8
|
+
import type { Router } from 'vue-router';
|
|
9
|
+
import type { App } from '@vue/runtime-core';
|
|
10
|
+
import type { Pinia } from 'pinia';
|
|
11
|
+
import type { _UseQueryEntryNodeValueSerialized } from '@pinia/colada/index.js';
|
|
12
|
+
export type SSRContext = {
|
|
13
|
+
req: FastifyRequest | {
|
|
14
|
+
headers: Record<string, unknown>;
|
|
15
|
+
url: string;
|
|
16
|
+
};
|
|
17
|
+
res: FastifyReply | Record<string, unknown>;
|
|
18
|
+
provide: Record<string, unknown>;
|
|
19
|
+
initialState: {
|
|
20
|
+
provide?: Record<string, unknown>;
|
|
21
|
+
pinia?: Record<string, unknown>;
|
|
22
|
+
piniaColada?: Record<string, _UseQueryEntryNodeValueSerialized>;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
};
|
|
25
|
+
pinia?: Pinia;
|
|
26
|
+
_modules: Set<unknown>;
|
|
27
|
+
_meta: Record<string, any>;
|
|
28
|
+
__qMetaList: unknown[];
|
|
29
|
+
/**
|
|
30
|
+
* Required for Quasar
|
|
31
|
+
*/
|
|
32
|
+
onRenderedList: (() => unknown)[];
|
|
33
|
+
onRendered: (fn: () => unknown) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Vue internals
|
|
36
|
+
*/
|
|
37
|
+
modules?: Map<unknown, unknown>;
|
|
38
|
+
transports?: Record<string, unknown>;
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
};
|
|
41
|
+
export type onAppCreatedHook = ({ app, router, ctx, initialState, ssrContext }: {
|
|
42
|
+
app: App;
|
|
43
|
+
router: Router;
|
|
44
|
+
ctx: {
|
|
45
|
+
pinia?: Pinia;
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
};
|
|
48
|
+
initialState: {
|
|
49
|
+
provide?: Record<string, unknown>;
|
|
50
|
+
pinia?: Record<string, unknown>;
|
|
51
|
+
piniaColada?: Record<string, _UseQueryEntryNodeValueSerialized>;
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
};
|
|
54
|
+
ssrContext?: SSRContext;
|
|
11
55
|
}) => Promise<void> | void;
|
|
12
56
|
export type OnBootHook = ({ app, ssrContext, staticImports }: {
|
|
13
|
-
app:
|
|
14
|
-
ssrContext:
|
|
57
|
+
app: App;
|
|
58
|
+
ssrContext: SSRContext;
|
|
15
59
|
staticImports?: Record<string, any>;
|
|
16
60
|
}) => Promise<void> | void;
|
|
17
61
|
export type OnMountedHook = (instance: ComponentInternalInstance) => Promise<void> | void;
|
|
18
62
|
export type StaticImports = Record<string, string[]>;
|
|
19
|
-
export type
|
|
20
|
-
export type OnRenderedHook = (html: string, ssrContext: Record<string, any>) => string;
|
|
63
|
+
export type OnSetupFile = URL;
|
|
21
64
|
export type OnSetupHook = (fastify: FastifyInstance, options?: {
|
|
22
65
|
vite?: ViteDevServer;
|
|
23
66
|
}) => any;
|
|
24
|
-
export type
|
|
67
|
+
export type Render = (url: string, manifest: Record<string, unknown>, ssrContext: SSRContext, renderToString: (app: App, ctx?: Record<string, any>) => Promise<string>) => Promise<{
|
|
68
|
+
html: string;
|
|
69
|
+
preloadLinks: string;
|
|
70
|
+
app: App;
|
|
71
|
+
}>;
|
|
72
|
+
export type OnRenderedHook = ({ app, ssrContext }: {
|
|
73
|
+
app: App;
|
|
74
|
+
ssrContext?: SSRContext;
|
|
75
|
+
}) => Promise<void> | void;
|
|
76
|
+
export type OnTemplateRenderedHook = ({ html, ssrContext }: {
|
|
77
|
+
html: string;
|
|
78
|
+
ssrContext?: SSRContext;
|
|
79
|
+
}) => Promise<string> | string;
|
|
25
80
|
export interface VitrifyConfig extends ViteUserConfig {
|
|
26
81
|
vitrify?: {
|
|
27
82
|
lang?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Vitrify plugins
|
|
85
|
+
*/
|
|
86
|
+
plugins?: VitrifyPluginConfig[];
|
|
28
87
|
/**
|
|
29
88
|
* Global CSS imports
|
|
30
89
|
*/
|
|
@@ -50,6 +109,14 @@ export interface VitrifyConfig extends ViteUserConfig {
|
|
|
50
109
|
* Functions which run after rendering the app (SSR)
|
|
51
110
|
*/
|
|
52
111
|
onRendered?: OnRenderedHook[];
|
|
112
|
+
/**
|
|
113
|
+
* Functions which run after rendering the template (SSR)
|
|
114
|
+
*/
|
|
115
|
+
onTemplateRendered?: OnTemplateRenderedHook[];
|
|
116
|
+
/**
|
|
117
|
+
* Functions which run directly after initializing the application
|
|
118
|
+
*/
|
|
119
|
+
onAppCreated?: onAppCreatedHook[];
|
|
53
120
|
};
|
|
54
121
|
/**
|
|
55
122
|
* Global SASS variables
|
|
@@ -97,8 +164,11 @@ export interface VitrifyConfig extends ViteUserConfig {
|
|
|
97
164
|
* UnoCSS Configuration
|
|
98
165
|
*/
|
|
99
166
|
unocss?: UnoCSSUserConfig;
|
|
167
|
+
/**
|
|
168
|
+
* unplugin-vue-components configuration
|
|
169
|
+
*/
|
|
170
|
+
unpluginVueComponents?: unpluginVueComponentsOptions;
|
|
100
171
|
};
|
|
101
|
-
quasar?: QuasarConf;
|
|
102
172
|
}
|
|
103
173
|
export type VitrifyCommands = 'build' | 'dev' | 'test';
|
|
104
174
|
export type VitrifyModes = 'production' | 'development';
|
|
@@ -108,4 +178,9 @@ export type VitrifyConfigAsync = ({ mode, command }: {
|
|
|
108
178
|
mode: VitrifyModes;
|
|
109
179
|
command: VitrifyCommands;
|
|
110
180
|
}) => Promise<VitrifyConfig>;
|
|
181
|
+
type VitrifyPluginConfig = {
|
|
182
|
+
plugin: VitrifyPlugin<any>;
|
|
183
|
+
options: any;
|
|
184
|
+
};
|
|
111
185
|
export declare const defineConfig: (config: VitrifyConfig) => VitrifyConfig;
|
|
186
|
+
export {};
|