@live-change/vue3-ssr 0.2.1 → 0.2.2
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/index.js +18 -26
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,37 +1,31 @@
|
|
|
1
1
|
import { getCurrentInstance, onUnmounted } from 'vue'
|
|
2
2
|
import { live as d3live, RangeBuckets } from '@live-change/dao-vue3'
|
|
3
3
|
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
return
|
|
4
|
+
function api(context) {
|
|
5
|
+
context = context || getCurrentInstance().appContext
|
|
6
|
+
return context.config.globalProperties.$lc
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
return app.appContext.config.globalProperties.$lc
|
|
9
|
+
function path(context) {
|
|
10
|
+
return api(context).fetch
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
function view(
|
|
15
|
-
|
|
16
|
-
return app.appContext.config.globalProperties.$lc.view
|
|
13
|
+
function view(context) {
|
|
14
|
+
return api(context).view
|
|
17
15
|
}
|
|
18
16
|
|
|
19
|
-
function actions(
|
|
20
|
-
|
|
21
|
-
return app.appContext.config.globalProperties.$lc.actions
|
|
17
|
+
function actions(context) {
|
|
18
|
+
return api(context).actions
|
|
22
19
|
}
|
|
23
20
|
|
|
24
21
|
function live(path) {
|
|
25
|
-
|
|
26
|
-
const api = app.appContext.config.globalProperties.$lc
|
|
27
|
-
return d3live(api, path)
|
|
22
|
+
return d3live(api(), path)
|
|
28
23
|
}
|
|
29
24
|
|
|
30
|
-
async function rangeBuckets(pathFunction, options, app) {
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const buckets = new RangeBuckets(api, extendedPathFunction, options)
|
|
25
|
+
async function rangeBuckets(pathFunction, options, app = getCurrentInstance()) {
|
|
26
|
+
const lc = api()
|
|
27
|
+
const extendedPathFunction = (range) => pathFunction(range, lc.fetch)
|
|
28
|
+
const buckets = new RangeBuckets(lc, extendedPathFunction, options)
|
|
35
29
|
if(app) {
|
|
36
30
|
onUnmounted(() => {
|
|
37
31
|
buckets.dispose()
|
|
@@ -62,14 +56,12 @@ function reverseRange(range) {
|
|
|
62
56
|
}
|
|
63
57
|
}
|
|
64
58
|
|
|
65
|
-
function client(
|
|
66
|
-
|
|
67
|
-
return app.appContext.config.globalProperties.$lc.client
|
|
59
|
+
function client(context) {
|
|
60
|
+
return api(context).client
|
|
68
61
|
}
|
|
69
62
|
|
|
70
|
-
function uid(
|
|
71
|
-
|
|
72
|
-
return app.appContext.config.globalProperties.$lc.uid
|
|
63
|
+
function uid(context) {
|
|
64
|
+
return api(context).uid
|
|
73
65
|
}
|
|
74
66
|
|
|
75
67
|
export { path, api, view, actions, live, client, uid, rangeBuckets, reverseRange }
|