vitrify 0.2.5 → 0.5.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.
Files changed (54) hide show
  1. package/README.md +2 -2
  2. package/dist/app-urls.js +1 -2
  3. package/dist/bin/build.js +9 -51
  4. package/dist/bin/cli.js +31 -9
  5. package/dist/bin/dev.js +72 -70
  6. package/dist/frameworks/vue/fastify-csr-plugin.js +38 -0
  7. package/dist/frameworks/vue/fastify-ssr-plugin.js +83 -25
  8. package/dist/frameworks/vue/prerender.js +3 -3
  9. package/dist/frameworks/vue/server.js +10 -11
  10. package/dist/helpers/collect-css-ssr.js +61 -0
  11. package/dist/helpers/logger.js +0 -72
  12. package/dist/index.js +310 -130
  13. package/dist/plugins/quasar.js +34 -111
  14. package/dist/types/bin/build.d.ts +2 -2
  15. package/dist/types/bin/dev.d.ts +42 -4
  16. package/dist/types/frameworks/vue/fastify-csr-plugin.d.ts +17 -0
  17. package/dist/types/frameworks/vue/fastify-ssr-plugin.d.ts +6 -3
  18. package/dist/types/frameworks/vue/prerender.d.ts +3 -3
  19. package/dist/types/frameworks/vue/server.d.ts +10 -5
  20. package/dist/types/helpers/collect-css-ssr.d.ts +14 -0
  21. package/dist/types/helpers/logger.d.ts +0 -19
  22. package/dist/types/helpers/routes.d.ts +1 -1
  23. package/dist/types/index.d.ts +4 -2
  24. package/dist/types/plugins/index.d.ts +1 -1
  25. package/dist/types/vitrify-config.d.ts +33 -17
  26. package/package.json +33 -32
  27. package/src/node/app-urls.ts +1 -2
  28. package/src/node/bin/build.ts +11 -57
  29. package/src/node/bin/cli.ts +38 -10
  30. package/src/node/bin/dev.ts +106 -80
  31. package/src/node/bin/test.ts +0 -3
  32. package/src/node/frameworks/vue/fastify-csr-plugin.ts +72 -0
  33. package/src/node/frameworks/vue/fastify-ssr-plugin.ts +99 -28
  34. package/src/node/frameworks/vue/prerender.ts +5 -5
  35. package/src/node/frameworks/vue/server.ts +24 -17
  36. package/src/node/helpers/collect-css-ssr.ts +85 -0
  37. package/src/node/helpers/logger.ts +0 -87
  38. package/src/node/index.ts +353 -146
  39. package/src/node/plugins/index.ts +1 -1
  40. package/src/node/plugins/quasar.ts +39 -116
  41. package/src/node/vitrify-config.ts +44 -17
  42. package/src/vite/fastify/entry.ts +11 -0
  43. package/src/vite/fastify/server.ts +12 -0
  44. package/src/vite/vue/csr/app.ts +25 -0
  45. package/src/vite/vue/csr/fastify-csr-plugin.ts +3 -0
  46. package/src/vite/vue/csr/server.ts +8 -0
  47. package/src/vite/vue/index.html +1 -0
  48. package/src/vite/vue/main.ts +5 -20
  49. package/src/vite/vue/ssr/app.ts +25 -0
  50. package/src/vite/vue/ssr/entry-server.ts +13 -1
  51. package/src/vite/vue/ssr/fastify-ssr-plugin.ts +2 -118
  52. package/src/vite/vue/ssr/prerender.ts +2 -2
  53. package/src/vite/vue/ssr/server.ts +24 -15
  54. package/src/node/helpers/ssr.ts.bak +0 -52
@@ -1,18 +1,27 @@
1
- import { createApp } from '../../../node/frameworks/vue/server.js'
2
- import { getAppDir } from '../../../node/app-urls.js'
3
- import { setup } from 'virtual:fastify-setup'
4
- import ssrFunctions from 'virtual:ssr-functions'
5
-
1
+ // import { createApp } from '../../../node/frameworks/vue/server.js'
2
+ // import { getAppDir } from '../../../node/app-urls.js'
3
+ // import { setup } from 'virtual:fastify-setup'
4
+ // import { onRendered, onSetup } from 'virtual:vitrify-hooks'
5
+ // import { fastifySsrPlugin } from './fastify-ssr-plugin.js'
6
+ import { setupApp } from './app.js'
7
+ // import * as staticImports from 'virtual:static-imports'
6
8
  // const appDir = getPkgJsonDir(import.meta.url)
7
- const getString = (str?: string) => str
8
- let baseUrl = getString(__BASE_URL__)
9
- const appDir = getAppDir()
9
+ // const getString = (str?: string) => str
10
+ // let baseUrl = getString(__BASE_URL__)
11
+ // const appDir = getAppDir()
10
12
 
11
- const app = createApp({
12
- setup,
13
- appDir,
14
- baseUrl,
15
- ssrFunctions
16
- })
13
+ // const app = createApp({
14
+ // onSetup,
15
+ // appDir,
16
+ // baseUrl,
17
+ // onRendered,
18
+ // fastifySsrPlugin,
19
+ // mode: import.meta.env.MODE
20
+ // })
17
21
 
18
- app.listen(process.env.PORT || 3000, process.env.HOST || '127.0.0.1')
22
+ const app = await setupApp()
23
+
24
+ app.listen({
25
+ port: Number(process.env.PORT || 3000),
26
+ host: process.env.HOST || '127.0.0.1'
27
+ })
@@ -1,52 +0,0 @@
1
- export const injectSsrContext = (html: string, ssrContext: Record<string, any>) => html.replace(
2
- /(<html[^>]*)(>)/i,
3
- (found, start, end) => {
4
- let matches
5
-
6
- matches = found.match(/\sdir\s*=\s*['"]([^'"]*)['"]/i)
7
- if (matches) {
8
- start = start.replace(matches[0], '')
9
- }
10
-
11
- matches = found.match(/\slang\s*=\s*['"]([^'"]*)['"]/i)
12
- if (matches) {
13
- start = start.replace(matches[0], '')
14
- }
15
-
16
- return `${start} ${ssrContext._meta.htmlAttrs || ''} ${end}`
17
- }
18
- )
19
- .replace(
20
- /(<head[^>]*)(>)/i,
21
- (_, start, end) => `${start}${end}${ssrContext._meta.headTags || ''}`
22
- )
23
- .replace(
24
- /(<\/head>)/i,
25
- (_, tag) => `${ssrContext._meta.resourceStyles || ''}${ssrContext._meta.endingHeadTags || ''}${tag}`
26
- )
27
- .replace(
28
- /(<body[^>]*)(>)/i,
29
- (found, start, end) => {
30
- let classes = ssrContext._meta.bodyClasses || ''
31
-
32
- const matches = found.match(/\sclass\s*=\s*['"]([^'"]*)['"]/i)
33
-
34
- if (matches) {
35
- if (matches[1].length > 0) {
36
- classes += ` ${matches[1]}`
37
- }
38
- start = start.replace(matches[0], '')
39
- }
40
-
41
- return `${start} class="${classes.trim()}" ${ssrContext._meta.bodyAttrs || ''}${end}${ssrContext._meta.bodyTags || ''}`
42
- }
43
- )
44
- .replace(`<!--initial-state-->`, `<script>
45
- window.__INITIAL_STATE__ = ${JSON.stringify(ssrContext.initialState)}
46
- </script>
47
- `)
48
-
49
- export const injectInitialState = (html: string, ssrContext: Record<string, any>) =>
50
- html.replace(`<!--initial-state-->`, `<script>
51
- window.__INITIAL_STATE__ = ${JSON.stringify(ssrContext.initialState)}
52
- </script>`)