@live-change/frontend-base 0.3.4 → 0.3.5

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.
@@ -0,0 +1,65 @@
1
+ <template>
2
+ <div v-if="updateAvailable && !updateBannerHidden" class="bg-yellow-400 text-gray-900 p-3 flex
3
+ justify-content-between lg:justify-content-center align-items-center flex-wrap">
4
+ <div class="font-bold mr-8">{{ t('app.updateAvailable') }}</div>
5
+ <div class="align-items-center hidden md:flex">
6
+ <span class="line-height-3">{{ t("app.newVersions") }}</span>
7
+ </div>
8
+ <a class="flex align-items-center ml-2 mr-8">
9
+ <a class="text-gray-900" href="#" @click="update">
10
+ <span class="underline font-bold">{{ t("app.reload") }}</span>
11
+ </a>
12
+ </a>
13
+ <a v-ripple class="flex align-items-center no-underline justify-content-center border-circle text-gray-900
14
+ hover:bg-bluegray-700 cursor-pointer transition-colors transition-duration-150 p-ripple"
15
+ style="width:2rem; height: 2rem" @click="hideUpdateBanner">
16
+ <i class="pi pi-times"></i>
17
+ </a>
18
+ </div>
19
+ </template>
20
+
21
+ <script setup>
22
+
23
+ import { computed, ref } from 'vue'
24
+
25
+ import { useApi } from '@live-change/vue3-ssr'
26
+ const api = useApi()
27
+
28
+ import { useI18n } from 'vue-i18n'
29
+ const { t } = useI18n()
30
+
31
+ const updateAvailable = computed(
32
+ () => api.metadata.version.value && api.metadata.version.value != ENV_VERSION
33
+ )
34
+ const updateBannerHidden = ref(false)
35
+ function hideUpdateBanner() {
36
+ updateBannerHidden.value = true
37
+ }
38
+
39
+ async function update(ev) {
40
+ ev.preventDefault()
41
+ ev.stopPropagation()
42
+ if (ENV_MODE == 'pwa' && navigator.serviceWorker) {
43
+ if(navigator.serviceWorker.ready) {
44
+ console.log("TRY UPDATE PWA!")
45
+ setTimeout(() => {
46
+ console.log("RELOADING ON TIMEOUT!!")
47
+ document.location.reload(true)
48
+ }, 2000)
49
+ try {
50
+ const registration = await navigator.serviceWorker.ready
51
+ await registration.unregister()
52
+ //await registration.update()
53
+ } catch(e) {
54
+ console.error("PWA UPDATE ERROR", e)
55
+ }
56
+ }
57
+ }
58
+ document.location.reload()
59
+ }
60
+
61
+ </script>
62
+
63
+ <style scoped>
64
+
65
+ </style>
package/index.js CHANGED
@@ -4,8 +4,9 @@ export { ComponentDialog }
4
4
  import ViewRoot from "./ViewRoot.vue"
5
5
  import Page from "./Page.vue"
6
6
  import NavBar from "./NavBar.vue"
7
+ import UpdateBanner from "./UpdateBanner.vue"
7
8
 
8
- export { ViewRoot, Page, NavBar }
9
+ export { ViewRoot, Page, NavBar, UpdateBanner }
9
10
 
10
11
  import { useHost } from "./host.js"
11
12
  export { useHost }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/frontend-base",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
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",
@@ -42,7 +42,7 @@
42
42
  "@live-change/password-authentication-service": "0.3.32",
43
43
  "@live-change/secret-code-service": "0.3.32",
44
44
  "@live-change/secret-link-service": "0.3.32",
45
- "@live-change/security-frontend": "^0.3.4",
45
+ "@live-change/security-frontend": "^0.3.5",
46
46
  "@live-change/session-service": "0.3.32",
47
47
  "@live-change/user-service": "0.3.32",
48
48
  "@live-change/vue3-components": "0.2.30",
@@ -107,5 +107,5 @@
107
107
  "author": "",
108
108
  "license": "BSD-3-Clause",
109
109
  "description": "",
110
- "gitHead": "74b3e14aeac867652b39517a861b6d93c46ad2e2"
110
+ "gitHead": "e85ef8527b35ec7e1c50be50ccf567270821e4ea"
111
111
  }
package/vite-config.js CHANGED
@@ -34,6 +34,8 @@ const ssrTransformCustomDir = () => {
34
34
  }
35
35
  }
36
36
 
37
+ let version = process.env.VERSION ?? 'unknown'
38
+
37
39
  module.exports = async ({ command, mode }) => {
38
40
  //console.log("VITE CONFIG", command, mode)
39
41
  return {
@@ -41,6 +43,8 @@ module.exports = async ({ command, mode }) => {
41
43
  ENV_BASE_HREF: JSON.stringify(process.env.BASE_HREF || 'http://localhost:8001'),
42
44
  ENV_BRAND_NAME: JSON.stringify("Example"),
43
45
  ENV_BRAND_DOMAIN: JSON.stringify("example.com"),
46
+ ENV_MODE: JSON.stringify(mode),
47
+ ENV_VERSION: JSON.stringify(version),
44
48
  },
45
49
  server: {
46
50
  hmr: {