@live-change/vue3-ssr 0.2.15 → 0.2.17

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 +12 -2
  2. package/clientApi.js +9 -3
  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,12 @@ 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
+ console.trace("RESOLVE READY PROMISE")
169
+ api.resolveReadyPromise()
170
+ api.resolveReadyPromise = null
171
+ }
162
172
  }
163
173
 
164
174
  addGlobalInstance(globalProperties) {
package/clientApi.js CHANGED
@@ -5,7 +5,11 @@ 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__, {
8
+ let credentials = window.__DAO_CACHE__ ? window.__CREDENTIALS__ : undefined
9
+ if(settings.credentials) {
10
+ credentials = { ...credentials, ...settings.credentials }
11
+ }
12
+ const dao = new lcdao.Dao(credentials, {
9
13
  remoteUrl: document.location.protocol + '//' + document.location.host + "/api/sockjs",
10
14
  protocols: {
11
15
  'sockjs': SockJsConnection
@@ -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.15",
3
+ "version": "0.2.17",
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.6",
25
- "@live-change/uid": "0.6.14",
24
+ "@live-change/dao-vue3": "0.5.9",
25
+ "@live-change/uid": "0.7.15",
26
26
  "@vueuse/core": "^9.1.0",
27
27
  "debug": "^4.3.4"
28
28
  },
29
- "gitHead": "d63a43e94b3bb271297b70d40be4774e176b1c59"
29
+ "gitHead": "72026576e9525cfea2960d4f291de151d9d6d112"
30
30
  }