@live-change/vue3-ssr 0.2.16 → 0.2.18

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 (3) hide show
  1. package/Api.js +11 -2
  2. package/clientApi.js +10 -4
  3. package/package.json +4 -4
package/Api.js CHANGED
@@ -23,6 +23,9 @@ class Api extends DaoProxy {
23
23
  $validators: this.validators
24
24
  }
25
25
  this.globalInstances = []
26
+ this.readyPromise = new Promise(resolve => {
27
+ this.resolveReadyPromise = resolve
28
+ })
26
29
  }
27
30
 
28
31
  setup(settings = this.settings) {
@@ -71,12 +74,13 @@ class Api extends DaoProxy {
71
74
  const client = computed(() => {
72
75
  return api?.value?.client
73
76
  })
74
- watch(() => api, (api) => {
77
+ watch(() => api.value, (api) => {
75
78
  console.log("API CHANGE!", api)
76
79
  if(!api) return
77
80
  console.log("API CHANGE!", api)
78
- api.generateServicesApi()
81
+ this.generateServicesApi()
79
82
  })
83
+ console.log("SETUP API", api.value)
80
84
  this.metadata = {
81
85
  api, version,
82
86
  softwareVersion,
@@ -159,6 +163,11 @@ class Api extends DaoProxy {
159
163
  for(const glob of this.globalInstances) {
160
164
  this.installInstanceProperties(glob)
161
165
  }
166
+
167
+ if(api.resolveReadyPromise) {
168
+ api.resolveReadyPromise()
169
+ api.resolveReadyPromise = null
170
+ }
162
171
  }
163
172
 
164
173
  addGlobalInstance(globalProperties) {
package/clientApi.js CHANGED
@@ -5,8 +5,12 @@ import SockJsConnection from '@live-change/dao-sockjs'
5
5
  import Api from "./Api.js"
6
6
 
7
7
  function clientApi(settings = {}) {
8
- const dao = new lcdao.Dao(window.__CREDENTIALS__, {
9
- remoteUrl: document.location.protocol + '//' + document.location.host + "/api/sockjs",
8
+ let credentials = settings.credentials ?? (window.__DAO_CACHE__ ? window.__CREDENTIALS__ : undefined)
9
+ if(settings.credentials) {
10
+ credentials = { ...credentials, ...settings.credentials }
11
+ }
12
+ const dao = new lcdao.Dao(credentials, {
13
+ remoteUrl: settings.remoteUrl || document.location.protocol + '//' + document.location.host + "/api/sockjs",
10
14
  protocols: {
11
15
  'sockjs': SockJsConnection
12
16
  },
@@ -39,7 +43,7 @@ function clientApi(settings = {}) {
39
43
 
40
44
  const api = new Api(dao)
41
45
  api.setup({
42
- ssr: true,
46
+ ssr: (typeof window == "undefined") || !!window.__DAO_CACHE__,
43
47
  cache: true,
44
48
  ...settings,
45
49
  createReactiveObject(definition) {
@@ -50,7 +54,9 @@ function clientApi(settings = {}) {
50
54
  for(const plugin of (settings.use || [])) {
51
55
  plugin(api)
52
56
  }
53
- api.generateServicesApi()
57
+ if(!!window.__DAO_CACHE__) {
58
+ api.generateServicesApi()
59
+ }
54
60
 
55
61
  return api
56
62
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/vue3-ssr",
3
- "version": "0.2.16",
3
+ "version": "0.2.18",
4
4
  "description": "Live Change Framework - vue components",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,10 +21,10 @@
21
21
  },
22
22
  "homepage": "https://github.com/live-change/live-change-framework-vue3",
23
23
  "dependencies": {
24
- "@live-change/dao-vue3": "0.5.8",
25
- "@live-change/uid": "0.7.4",
24
+ "@live-change/dao-vue3": "0.5.10",
25
+ "@live-change/uid": "0.7.16",
26
26
  "@vueuse/core": "^9.1.0",
27
27
  "debug": "^4.3.4"
28
28
  },
29
- "gitHead": "a11c281e5913e7bc26955bbc1676dd8153ebc486"
29
+ "gitHead": "ba8e0f2c67695d1e5ffdf8d713e5a4dec25d03b2"
30
30
  }