tsviewer 1.0.24 → 1.0.26
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/README.md +85 -18
- package/dist/tsviewer.es.js +13 -2
- package/dist/tsviewer.umd.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,33 +1,100 @@
|
|
|
1
1
|
# tsviewer
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
```
|
|
5
|
-
yarn install
|
|
6
|
-
```
|
|
3
|
+
tsviewer is a Vue 3 component library that provides an embeddable viewer component, backed by a Pinia store. This README will guide you through installation, setup, and usage.
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
yarn
|
|
5
|
+
## **📦 Installation**
|
|
6
|
+
|
|
7
|
+
Install the package via npm or yarn:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install tsviewer
|
|
11
|
+
# or
|
|
12
|
+
yarn add tsviewer
|
|
11
13
|
```
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
## **🚀 Usage**
|
|
16
|
+
|
|
17
|
+
### **1. Import the Component and Styles**
|
|
18
|
+
|
|
19
|
+
In your Vue 3 component or layout setup:
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
import { useViewerStore, tsviewer } from 'tsviewer'
|
|
23
|
+
import 'tsviewer/style'
|
|
14
24
|
```
|
|
15
|
-
|
|
25
|
+
|
|
26
|
+
### **2. Initialize the Viewer Store**
|
|
27
|
+
|
|
28
|
+
Before rendering `<tsviewer />`, you must initialize it by calling `fetchAndSetActiveViewer()` from the store. This ensures the viewer has the correct context.
|
|
29
|
+
|
|
30
|
+
You need to provide two string parameters:
|
|
31
|
+
- **packageId**: The unique identifier for the package to load.
|
|
32
|
+
- **packageType**: The type or category of the package.
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
const viewerStore = useViewerStore()
|
|
36
|
+
|
|
37
|
+
await viewerStore.fetchAndSetActiveViewer({
|
|
38
|
+
packageId: packageId.value,
|
|
39
|
+
packageType: packageType.value
|
|
40
|
+
})
|
|
16
41
|
```
|
|
17
42
|
|
|
18
|
-
|
|
43
|
+
⚠️ **This is an async function. You must await it before using the component.**
|
|
44
|
+
|
|
45
|
+
### **3. Use the Component**
|
|
46
|
+
|
|
47
|
+
Once the store is initialized, you can render the component:
|
|
48
|
+
|
|
49
|
+
```vue
|
|
50
|
+
<template>
|
|
51
|
+
<tsviewer />
|
|
52
|
+
</template>
|
|
19
53
|
```
|
|
20
|
-
|
|
54
|
+
|
|
55
|
+
## **✅ Full Example (Vue 3 + Composition API)**
|
|
56
|
+
|
|
57
|
+
```vue
|
|
58
|
+
<script setup>
|
|
59
|
+
import { ref, onMounted } from 'vue'
|
|
60
|
+
import { useViewerStore, TSViewer } from 'tsviewer'
|
|
61
|
+
import 'tsviewer/style'
|
|
62
|
+
|
|
63
|
+
const packageId = ref('your-package-id')
|
|
64
|
+
const packageType = ref('your-package-type')
|
|
65
|
+
const isViewerReady = ref(false)
|
|
66
|
+
|
|
67
|
+
const viewerStore = useViewerStore()
|
|
68
|
+
|
|
69
|
+
onMounted(async () => {
|
|
70
|
+
await viewerStore.fetchAndSetActiveViewer({
|
|
71
|
+
packageId: packageId.value,
|
|
72
|
+
packageType: packageType.value
|
|
73
|
+
})
|
|
74
|
+
isViewerReady.value = true
|
|
75
|
+
})
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<template>
|
|
79
|
+
<TSViewer v-if="isViewerReady" />
|
|
80
|
+
</template>
|
|
81
|
+
|
|
82
|
+
<template>
|
|
83
|
+
<tsviewer />
|
|
84
|
+
</template>
|
|
21
85
|
```
|
|
22
86
|
|
|
23
|
-
|
|
24
|
-
See [Configuration Reference](https://cli.vuejs.org/config/).
|
|
87
|
+
## **⚙️ Requirements**
|
|
25
88
|
|
|
26
|
-
|
|
89
|
+
- Vue 3
|
|
90
|
+
- Pinia (state management)
|
|
27
91
|
|
|
28
|
-
|
|
92
|
+
## **🛠️ Development & Contributing**
|
|
29
93
|
|
|
30
|
-
|
|
94
|
+
Coming soon.
|
|
31
95
|
|
|
32
|
-
|
|
33
|
-
|
|
96
|
+
## **📄 License**
|
|
97
|
+
|
|
98
|
+
MIT License.
|
|
99
|
+
|
|
100
|
+
Feel free to open issues or pull requests if you'd like to contribute or report bugs.
|
package/dist/tsviewer.es.js
CHANGED
|
@@ -12860,7 +12860,16 @@ const getLayerIndex = (e, t, n) => {
|
|
|
12860
12860
|
propOr([{}], "properties"),
|
|
12861
12861
|
find(propEq("category", "Blackfynn")),
|
|
12862
12862
|
propOr([{}], "properties")
|
|
12863
|
-
)(e.activeViewer)
|
|
12863
|
+
)(e.activeViewer),
|
|
12864
|
+
/**
|
|
12865
|
+
* Getter to check if file is processed
|
|
12866
|
+
* @param {Object} fileRecord - The file record object to check status for
|
|
12867
|
+
* @returns {Boolean} True if file is processed (READY), false otherwise
|
|
12868
|
+
*/
|
|
12869
|
+
isTSFileProcessed: (e) => (t) => {
|
|
12870
|
+
var r;
|
|
12871
|
+
return ((r = t == null ? void 0 : t.content) == null ? void 0 : r.state) === "READY";
|
|
12872
|
+
}
|
|
12864
12873
|
},
|
|
12865
12874
|
actions: {
|
|
12866
12875
|
clearState() {
|
|
@@ -12871,7 +12880,9 @@ const getLayerIndex = (e, t, n) => {
|
|
|
12871
12880
|
},
|
|
12872
12881
|
async fetchAndSetActiveViewer(e) {
|
|
12873
12882
|
const t = e.packageId, n = await useToken(), r = `https://api.pennsieve.net/packages/${t}?api_key=${n}`, i = await useSendXhr(r);
|
|
12874
|
-
this.
|
|
12883
|
+
if (this.isFileProcessed(i))
|
|
12884
|
+
return this.setActiveViewer(i), Promise.resolve(i);
|
|
12885
|
+
throw new Error("Timeseries viewer is not available, since the file is not processed");
|
|
12875
12886
|
},
|
|
12876
12887
|
closeViewer() {
|
|
12877
12888
|
this.clearState();
|