@live-change/frontend-base 0.2.8 → 0.2.10
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/client-entry.js +5 -3
- package/main.js +19 -1
- package/package.json +12 -11
- package/server-entry.js +8 -4
package/client-entry.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
|
|
8
8
|
import { createApp } from "./main.js"
|
|
9
9
|
|
|
10
|
-
export function clientEntry(App, createRouter) {
|
|
10
|
+
export async function clientEntry(App, createRouter, config = {}) {
|
|
11
11
|
|
|
12
12
|
const windowId = window.__WINDOW_ID__
|
|
13
13
|
console.error("CLIENT WINDOW ID", windowId)
|
|
@@ -18,8 +18,10 @@ export function clientEntry(App, createRouter) {
|
|
|
18
18
|
})
|
|
19
19
|
|
|
20
20
|
const host = document.location.host
|
|
21
|
-
|
|
22
|
-
const { app, router } = createApp(
|
|
21
|
+
const url = document.location.pathname + document.location.search
|
|
22
|
+
const { app, router } = await createApp(
|
|
23
|
+
config, api, App, createRouter, host, null, null, url
|
|
24
|
+
)
|
|
23
25
|
|
|
24
26
|
app.use(createSharedElementDirective())
|
|
25
27
|
router.beforeEach(SharedElementRouteGuard)
|
package/main.js
CHANGED
|
@@ -15,11 +15,12 @@ import StyleClass from 'primevue/styleclass'
|
|
|
15
15
|
import Ripple from 'primevue/ripple'
|
|
16
16
|
import BadgeDirective from 'primevue/badgedirective'
|
|
17
17
|
import VueLazyLoad from 'vue3-lazyload'
|
|
18
|
+
import { createI18n } from 'vue-i18n'
|
|
18
19
|
|
|
19
20
|
// SSR requires a fresh app instance per request, therefore we export a function
|
|
20
21
|
// that creates a fresh app instance. If using Vuex, we'd also be creating a
|
|
21
22
|
// fresh store here.
|
|
22
|
-
export function createApp(api, App, createRouter, host, response) {
|
|
23
|
+
export async function createApp(config, api, App, createRouter, host, headers, response, url) {
|
|
23
24
|
const isSSR = response !== undefined
|
|
24
25
|
const app = createSSRApp(App)
|
|
25
26
|
app.config.devtools = true
|
|
@@ -74,5 +75,22 @@ export function createApp(api, App, createRouter, host, response) {
|
|
|
74
75
|
})
|
|
75
76
|
app.use(meta)
|
|
76
77
|
|
|
78
|
+
app.directive("focus", {
|
|
79
|
+
mounted: (el) => el.focus(),
|
|
80
|
+
updated: (el, binding) => value && app.nextTick(() => el.focus())
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
const defaultLocale = config.defaultLocale || 'en'
|
|
84
|
+
const i18n = createI18n({
|
|
85
|
+
legacy: false,
|
|
86
|
+
locale: config.localeSelector // TODO: read stored language
|
|
87
|
+
? await config.localeSelector({ api, host, url, headers })
|
|
88
|
+
: defaultLocale,
|
|
89
|
+
fallbackLocale: config.fallbackLocale || defaultLocale,
|
|
90
|
+
messages: config.i18nMessages || {}
|
|
91
|
+
})
|
|
92
|
+
console.log("I18N MESSAGES", config.i18nMessages)
|
|
93
|
+
app.use(i18n)
|
|
94
|
+
|
|
77
95
|
return { app, router }
|
|
78
96
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/frontend-base",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"memDev": "lcli memDev --enableSessions --initScript ./init.js --templatePath ../../base-frontend/index.html",
|
|
6
6
|
"localDevInit": "rm tmp.db; lcli localDev --enableSessions --initScript ./init.js",
|
|
@@ -20,17 +20,17 @@
|
|
|
20
20
|
"debug": "node --inspect-brk server"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@live-change/cli": "0.7.
|
|
23
|
+
"@live-change/cli": "0.7.5",
|
|
24
24
|
"@live-change/dao": "0.5.8",
|
|
25
25
|
"@live-change/dao-vue3": "0.5.8",
|
|
26
26
|
"@live-change/dao-websocket": "0.5.8",
|
|
27
|
-
"@live-change/email-service": "0.3.
|
|
28
|
-
"@live-change/password-authentication-service": "0.3.
|
|
29
|
-
"@live-change/secret-code-service": "0.3.
|
|
30
|
-
"@live-change/secret-link-service": "0.3.
|
|
31
|
-
"@live-change/security-frontend": "^0.2.
|
|
32
|
-
"@live-change/session-service": "0.3.
|
|
33
|
-
"@live-change/user-service": "0.3.
|
|
27
|
+
"@live-change/email-service": "0.3.3",
|
|
28
|
+
"@live-change/password-authentication-service": "0.3.3",
|
|
29
|
+
"@live-change/secret-code-service": "0.3.3",
|
|
30
|
+
"@live-change/secret-link-service": "0.3.3",
|
|
31
|
+
"@live-change/security-frontend": "^0.2.10",
|
|
32
|
+
"@live-change/session-service": "0.3.3",
|
|
33
|
+
"@live-change/user-service": "0.3.3",
|
|
34
34
|
"@live-change/vue3-components": "0.2.16",
|
|
35
35
|
"@live-change/vue3-ssr": "0.2.16",
|
|
36
36
|
"@vitejs/plugin-vue": "^2.3.1",
|
|
@@ -51,13 +51,14 @@
|
|
|
51
51
|
"v-shared-element": "3.1.0",
|
|
52
52
|
"vite-plugin-compression": "0.5.1",
|
|
53
53
|
"vite-plugin-vue-images": "^0.6.1",
|
|
54
|
+
"vue-i18n": "^9.2.2",
|
|
54
55
|
"vue-meta": "^3.0.0-alpha.9",
|
|
55
56
|
"vue-router": "^4.1.3",
|
|
56
57
|
"vue3-lazyload": "0.2.5-beta",
|
|
57
58
|
"vue3-scroll-border": "0.1.2"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
|
-
"@live-change/codeceptjs-helper": "0.7.
|
|
61
|
+
"@live-change/codeceptjs-helper": "0.7.5",
|
|
61
62
|
"@wdio/selenium-standalone-service": "^7.20.8",
|
|
62
63
|
"codeceptjs": "^3.3.4",
|
|
63
64
|
"generate-password": "1.7.0",
|
|
@@ -69,5 +70,5 @@
|
|
|
69
70
|
"author": "",
|
|
70
71
|
"license": "BSD-3-Clause",
|
|
71
72
|
"description": "",
|
|
72
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "7d4c56cc610d692df963c3916411ceb46663b344"
|
|
73
74
|
}
|
package/server-entry.js
CHANGED
|
@@ -6,7 +6,7 @@ import { serverApi } from '@live-change/vue3-ssr/serverApi.js'
|
|
|
6
6
|
import { createApp } from "./main.js"
|
|
7
7
|
|
|
8
8
|
function escapeHtml(unsafe) {
|
|
9
|
-
return unsafe
|
|
9
|
+
return (''+unsafe)
|
|
10
10
|
.replace(/&/g, "&")
|
|
11
11
|
.replace(/</g, "<")
|
|
12
12
|
.replace(/>/g, ">")
|
|
@@ -14,8 +14,9 @@ function escapeHtml(unsafe) {
|
|
|
14
14
|
.replace(/'/g, "'");
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export function serverEntry(App, createRouter) {
|
|
18
|
-
return async function({ url,
|
|
17
|
+
export function serverEntry(App, createRouter, config = {}) {
|
|
18
|
+
return async function({ url, headers, dao, windowId }) {
|
|
19
|
+
const host = headers['host']
|
|
19
20
|
console.error('URL', host, url)
|
|
20
21
|
const api = await serverApi(dao, {
|
|
21
22
|
use: [],
|
|
@@ -29,7 +30,9 @@ export function serverEntry(App, createRouter) {
|
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
const { app, router } = createApp(
|
|
33
|
+
const { app, router } = await createApp(
|
|
34
|
+
config, api, App, createRouter, host, headers, response, url
|
|
35
|
+
)
|
|
33
36
|
|
|
34
37
|
app.directive('shared-element', {})
|
|
35
38
|
|
|
@@ -56,6 +59,7 @@ export function serverEntry(App, createRouter) {
|
|
|
56
59
|
|
|
57
60
|
const metaManager = app.config.globalProperties.$metaManager
|
|
58
61
|
const activeMeta = metaManager.target.context.active
|
|
62
|
+
console.log("ACTIVE META", activeMeta)
|
|
59
63
|
ctx.teleports.head = [
|
|
60
64
|
...(activeMeta.title ? [`<title data-vm-ssr="true">${escapeHtml(activeMeta.title)}</title>`] : []),
|
|
61
65
|
...((activeMeta.meta || []).map(meta => `<meta ${Object.keys(meta).map(
|