@live-change/vue3-ssr 0.1.9 → 0.2.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 (2) hide show
  1. package/Api.js +6 -15
  2. package/package.json +1 -1
package/Api.js CHANGED
@@ -1,16 +1,8 @@
1
1
  import { DaoProxy, DaoPrerenderCache, DaoCache, Path } from "@live-change/dao"
2
2
  import validators from '@live-change/framework/lib/utils/validators.js'
3
- import { hashCode, encodeNumber, uidGenerator } from '@live-change/uid'
3
+ import { hashCode, encodeNumber, uidGenerator, randomString } from '@live-change/uid'
4
4
  import { ref, computed, watch } from "vue"
5
5
 
6
- function guid() {
7
- function s4() {
8
- return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1)
9
- }
10
- return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
11
- s4() + '-' + s4() + s4() + s4()
12
- }
13
-
14
6
  class Api extends DaoProxy {
15
7
  constructor(source, settings = {}) {
16
8
  super()
@@ -39,10 +31,6 @@ class Api extends DaoProxy {
39
31
  this.setupMetadata()
40
32
  }
41
33
 
42
- guid() {
43
- return guid()
44
- }
45
-
46
34
  setupCaches() {
47
35
  let dao = this.source
48
36
  if(this.settings.cache) {
@@ -113,11 +101,14 @@ class Api extends DaoProxy {
113
101
  apiInfo = this.prerenderCache.cache.get(cachePath)
114
102
  }
115
103
  }
104
+ console.trace("GENERATE API SERVICES!")
116
105
  console.log("GENERATE SERVICES API", apiInfo)
117
106
  const definitions = apiInfo?.services
118
107
  if(JSON.stringify(definitions) == JSON.stringify(api.servicesApiDefinitions)) return
119
108
  if(!definitions) throw new Error("API DEFINITIONS NOT FOUND! UNABLE TO GENERATE API!")
120
- api.uidGenerator = uidGenerator(apiInfo.client.user || apiInfo.client.session.slice(0, 16), 1)
109
+ api.uidGenerator = uidGenerator(
110
+ apiInfo.client.user || (apiInfo.client.session ? apiInfo.client.session.slice(0, 16) : randomString(10) )
111
+ , 1, '[]')
121
112
  //console.log("GENERATE API DEFINITIONS", definitions)
122
113
  api.servicesApiDefinitions = definitions
123
114
  let globalViews = {}
@@ -227,7 +218,7 @@ class Api extends DaoProxy {
227
218
  }
228
219
 
229
220
  command(method, args = {}) {
230
- const _commandId = args._commandId || guid()
221
+ const _commandId = args._commandId || this.uidGenerator()
231
222
  console.trace("COMMAND "+_commandId+":"+JSON.stringify(method))
232
223
  return this.request(method, { ...args, _commandId })
233
224
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/vue3-ssr",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "description": "Live Change Framework - vue components",
5
5
  "main": "index.js",
6
6
  "scripts": {