@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.
Files changed (2) hide show
  1. package/index.js +18 -26
  2. 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 path(app) {
5
- app = app || getCurrentInstance()
6
- return app.appContext.config.globalProperties.$lc.fetch
4
+ function api(context) {
5
+ context = context || getCurrentInstance().appContext
6
+ return context.config.globalProperties.$lc
7
7
  }
8
8
 
9
- function api(app) {
10
- app = app || getCurrentInstance()
11
- return app.appContext.config.globalProperties.$lc
9
+ function path(context) {
10
+ return api(context).fetch
12
11
  }
13
12
 
14
- function view(app) {
15
- app = app || getCurrentInstance()
16
- return app.appContext.config.globalProperties.$lc.view
13
+ function view(context) {
14
+ return api(context).view
17
15
  }
18
16
 
19
- function actions(app) {
20
- app = app || getCurrentInstance()
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
- const app = getCurrentInstance()
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
- 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)
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(app) {
66
- app = app || getCurrentInstance()
67
- return app.appContext.config.globalProperties.$lc.client
59
+ function client(context) {
60
+ return api(context).client
68
61
  }
69
62
 
70
- function uid(app) {
71
- app = app || getCurrentInstance()
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 }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/vue3-ssr",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Live Change Framework - vue components",
5
5
  "main": "index.js",
6
6
  "scripts": {