@live-change/vue3-ssr 0.1.3 → 0.1.7

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/clientApi.js CHANGED
@@ -2,7 +2,7 @@ import { createReactiveObject } from '@live-change/vue3-components'
2
2
  import * as lcapi from '@live-change/vue-api'
3
3
  import * as lcdao from '@live-change/dao'
4
4
  import { reactiveMixin, reactivePrefetchMixin, ReactiveObservableList } from '@live-change/dao-vue3'
5
- import { SockJsConnection } from '@live-change/dao-sockjs'
5
+ import SockJsConnection from '@live-change/dao-sockjs'
6
6
 
7
7
  function clientApi(settings = {}) {
8
8
  const dao = new lcdao.Dao(window.__CREDENTIALS__, {
package/index.js CHANGED
@@ -0,0 +1,75 @@
1
+ import { getCurrentInstance, onUnmounted } from 'vue'
2
+ import { live as d3live, RangeBuckets } from '@live-change/dao-vue3'
3
+
4
+ function path(app) {
5
+ app = app || getCurrentInstance()
6
+ return app.appContext.config.globalProperties.$lc.fetch
7
+ }
8
+
9
+ function api(app) {
10
+ app = app || getCurrentInstance()
11
+ return app.appContext.config.globalProperties.$lc
12
+ }
13
+
14
+ function view(app) {
15
+ app = app || getCurrentInstance()
16
+ return app.appContext.config.globalProperties.$lc.view
17
+ }
18
+
19
+ function actions(app) {
20
+ app = app || getCurrentInstance()
21
+ return app.appContext.config.globalProperties.$lc.actions
22
+ }
23
+
24
+ function live(path) {
25
+ const app = getCurrentInstance()
26
+ const api = app.appContext.config.globalProperties.$lc
27
+ return d3live(api, path)
28
+ }
29
+
30
+ async function rangeBuckets(pathFunction, options, app) {
31
+ app = app || getCurrentInstance()
32
+ const api = app.appContext.config.globalProperties.$lc
33
+ const extendedPathFunction = (range) => pathFunction(range, api.fetch)
34
+ const buckets = new RangeBuckets(api, extendedPathFunction, options)
35
+ if(app) {
36
+ onUnmounted(() => {
37
+ buckets.dispose()
38
+ })
39
+ } else {
40
+ console.error("live fetch outside component instance - possible memory leak")
41
+ }
42
+ await buckets.wait()
43
+ return {
44
+ buckets: buckets.buckets,
45
+ loadTop: () => buckets.loadTop(),
46
+ loadBottom: () => buckets.loadBottom(),
47
+ dropTop: () => buckets.dropTop(),
48
+ dropBottom: () => buckets.dropBottom(),
49
+ canLoadTop: () => buckets.isTopLoadPossible(),
50
+ canLoadBottom: () => buckets.isBottomLoadPossible(),
51
+ }
52
+ }
53
+
54
+ function reverseRange(range) {
55
+ return {
56
+ gt: range.lt,
57
+ gte: range.lte,
58
+ lt: range.gt == '' ? '\xFF\xFF\xFF\xFF' : range.gt,
59
+ lte: range.gte,
60
+ limit: range.limit,
61
+ reverse: !range.reverse
62
+ }
63
+ }
64
+
65
+ function client(app) {
66
+ app = app || getCurrentInstance()
67
+ return app.appContext.config.globalProperties.$lc.client
68
+ }
69
+
70
+ function uid(app) {
71
+ app = app || getCurrentInstance()
72
+ return app.appContext.config.globalProperties.$lc.uid
73
+ }
74
+
75
+ export { path, api, view, actions, live, client, uid, rangeBuckets, reverseRange }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/vue3-ssr",
3
- "version": "0.1.3",
3
+ "version": "0.1.7",
4
4
  "description": "Live Change Framework - vue components",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,8 +21,9 @@
21
21
  },
22
22
  "homepage": "https://github.com/live-change/vue3-ssr",
23
23
  "dependencies": {
24
- "@vue/server-renderer": "^3.2.6",
25
24
  "debug": "^4.3.2",
26
- "vue": "^3.2.6"
25
+ "vue": "^3.2.21",
26
+ "@live-change/vue-api": "^0.1.10",
27
+ "@live-change/uid": "^0.1.3"
27
28
  }
28
29
  }
package/generateUuid.js DELETED
@@ -1,21 +0,0 @@
1
- const crypto = require('crypto')
2
- function uuidFromBytes(rnd) {
3
- rnd[6] = (rnd[6] & 0x0f) | 0x40
4
- rnd[8] = (rnd[8] & 0x3f) | 0x80
5
- rnd = rnd.toString('hex').match(/(.{8})(.{4})(.{4})(.{4})(.{12})/)
6
- rnd.shift()
7
- return rnd.join('-')
8
- }
9
-
10
- function genUuid(callback) {
11
- if (typeof(callback) !== 'function') {
12
- return uuidFromBytes(crypto.randomBytes(16))
13
- }
14
- crypto.randomBytes(16, function(err, rnd) {
15
- if (err) return callback(err)
16
- callback(null, uuidFromBytes(rnd))
17
- })
18
- }
19
-
20
- module.exports = genUuid
21
-