@live-change/vue3-ssr 0.2.13 → 0.2.15

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/Api.js CHANGED
@@ -154,6 +154,8 @@ class Api extends DaoProxy {
154
154
  api.globals.$actions = this.actions
155
155
  api.globals.$fetch = this.fetch
156
156
 
157
+ api.windowId = this.settings.windowId || api.uid()
158
+
157
159
  for(const glob of this.globalInstances) {
158
160
  this.installInstanceProperties(glob)
159
161
  }
@@ -188,7 +190,7 @@ class Api extends DaoProxy {
188
190
  { what: ['metadata', 'api'] },
189
191
  { what: ['version', 'version'] }
190
192
  ]}))
191
- console.log("PREFETCH WAIT!")
193
+ //console.log("PREFETCH WAIT!")
192
194
  // const apiPromise = this.apiObservable.wait()
193
195
  // apiPromise.then(res => console.log("API RES", res))
194
196
  // const versionPromise = this.versionObservable.wait()
@@ -196,7 +198,7 @@ class Api extends DaoProxy {
196
198
  // if(this.apiObservable.getValue() === undefined) preFetchPromises.push(apiPromise)
197
199
  // if(this.versionObservable.getValue() === undefined) preFetchPromises.push(versionPromise)
198
200
  await Promise.all(preFetchPromises)
199
- console.log("PREFETCHED", this.metadata.api, this.metadata.version)
201
+ //console.log("PREFETCHED", this.metadata.api, this.metadata.version)
200
202
  for(const afterPreFetch of this.afterPreFetch) {
201
203
  afterPreFetch()
202
204
  }
@@ -245,4 +247,4 @@ class Api extends DaoProxy {
245
247
  }
246
248
  }
247
249
 
248
- export default Api
250
+ export default Api
package/clientApi.js CHANGED
@@ -41,6 +41,7 @@ function clientApi(settings = {}) {
41
41
  api.setup({
42
42
  ssr: true,
43
43
  cache: true,
44
+ ...settings,
44
45
  createReactiveObject(definition) {
45
46
  //console.log("CREATE REACTIVE OBJECT", definition)
46
47
  return createReactiveObject(definition, reactiveMixin(api), reactivePrefetchMixin(api) )
@@ -54,4 +55,4 @@ function clientApi(settings = {}) {
54
55
  return api
55
56
  }
56
57
 
57
- export { clientApi }
58
+ export { clientApi }
package/index.js CHANGED
@@ -1,33 +1,34 @@
1
1
  import { getCurrentInstance, onUnmounted } from 'vue'
2
2
  import { live as d3live, fetch as d3fetch, RangeBuckets } from '@live-change/dao-vue3'
3
+ import { InboxReader } from '@live-change/dao'
3
4
 
4
- function api(context) {
5
+ function useApi(context) {
5
6
  context = context || getCurrentInstance().appContext
6
7
  return context.config.globalProperties.$lc
7
8
  }
8
9
 
9
10
  function path(context) {
10
- return api(context).fetch
11
+ return useApi(context).fetch
11
12
  }
12
13
 
13
14
  function view(context) {
14
- return api(context).view
15
+ return useApi(context).view
15
16
  }
16
17
 
17
18
  function actions(context) {
18
- return api(context).actions
19
+ return useApi(context).actions
19
20
  }
20
21
 
21
22
  function live(path) {
22
- return d3live(api(), path)
23
+ return d3live(useApi(), path)
23
24
  }
24
25
 
25
26
  function fetch(path) {
26
- return d3fetch(api(), path)
27
+ return d3fetch(useApi(), path)
27
28
  }
28
29
 
29
30
  async function rangeBuckets(pathFunction, options, app = getCurrentInstance()) {
30
- const lc = api()
31
+ const lc = useApi()
31
32
  const extendedPathFunction = (range) => pathFunction(range, lc.fetch)
32
33
  const buckets = new RangeBuckets(lc, extendedPathFunction, options)
33
34
  if(app) {
@@ -60,12 +61,39 @@ function reverseRange(range) {
60
61
  }
61
62
  }
62
63
 
64
+ function inboxReader(pathFunction, callback, start = '', options = {}) {
65
+ const {
66
+ bucketSize = 32,
67
+ context = getCurrentInstance().appContext
68
+ } = options
69
+ const api = useApi(context)
70
+ return new InboxReader((position, bucketSize) => {
71
+ const path = pathFunction(position, bucketSize)
72
+ console.log("OBSERVE PATH", path)
73
+ return api.observable(path)
74
+ }, callback, start, bucketSize)
75
+ }
76
+
63
77
  function client(context) {
64
- return api(context).client
78
+ return useApi(context).client
65
79
  }
66
80
 
67
81
  function uid(context) {
68
- return api(context).uid
82
+ return useApi(context).uid
83
+ }
84
+
85
+ function serviceDefinition(service, context = getCurrentInstance().appContext) {
86
+ const api = useApi(context)
87
+ return [...api.metadata.api.value.services].find(x => x.name == service)
69
88
  }
70
89
 
71
- export { path, api, view, actions, live, fetch, client, uid, rangeBuckets, reverseRange }
90
+ const api = useApi
91
+
92
+ export {
93
+ path, live, fetch,
94
+ useApi, api,
95
+ view, actions, client, uid,
96
+ rangeBuckets, reverseRange,
97
+ inboxReader,
98
+ serviceDefinition
99
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/vue3-ssr",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
4
4
  "description": "Live Change Framework - vue components",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,11 +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.4.12",
25
- "@live-change/uid": "0.6.5",
26
- "@vueuse/core": "^8.3.1",
27
- "debug": "^4.3.4",
28
- "vue": "^3.2.33"
24
+ "@live-change/dao-vue3": "0.5.6",
25
+ "@live-change/uid": "0.6.14",
26
+ "@vueuse/core": "^9.1.0",
27
+ "debug": "^4.3.4"
29
28
  },
30
- "gitHead": "2a8fa3e359bb31fecf9ea0674e10a3cd11c460e9"
29
+ "gitHead": "d63a43e94b3bb271297b70d40be4774e176b1c59"
31
30
  }
package/serverApi.js CHANGED
@@ -7,6 +7,7 @@ async function serverApi(dao, settings = {}) {
7
7
  const api = new Api(dao)
8
8
  api.setup({
9
9
  ssr: true,
10
+ ...settings,
10
11
  createReactiveObject(definition) {
11
12
  return createReactiveObject(definition, reactiveMixin(api)/*, reactivePrefetchMixin(api)*/ )
12
13
  }