@3cr/viewer-browser 0.0.52 → 0.0.53
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 +108 -81
- package/package.json +1 -1
- package/README2.md +0 -201
package/README.md
CHANGED
|
@@ -1,81 +1,108 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
1
|
+
# @3cr/viewer-browser
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Ecosystem integration for installing and running [3DICOM Online Viewer (3CR-OV)](https://docs.3cr.singular.health/) within the Browser (client-side)
|
|
8
|
+
|
|
9
|
+
[3DICOM Online Viewer (3CR-OV) Playground](https://playground.3cr.singular.health/)
|
|
10
|
+
|
|
11
|
+
## Include `@3cr/viewer-browser` script
|
|
12
|
+
|
|
13
|
+
Choose one of the following ways
|
|
14
|
+
- ### HTML Script Tag
|
|
15
|
+
|
|
16
|
+
Insert this line into your `index.html`
|
|
17
|
+
|
|
18
|
+
```html
|
|
19
|
+
<script src="https://cdn.jsdelivr.net/npm/@3cr/viewer-browser@{{version}}/dist/Viewer3CR.umd.js"> </script>
|
|
20
|
+
```
|
|
21
|
+
Note: Please ensure you replace the `{{version}}` with the version of the viewer you want.
|
|
22
|
+
|
|
23
|
+
- ### JS/TS way
|
|
24
|
+
|
|
25
|
+
You can also include it dynamically within your code.
|
|
26
|
+
|
|
27
|
+
`Typescript (.ts)`
|
|
28
|
+
```ts
|
|
29
|
+
export async function loadViewerScript(version: string): Promise<void> {
|
|
30
|
+
return new Promise<void>((resolve) => {
|
|
31
|
+
const s = document.createElement('script');
|
|
32
|
+
s.onload = () => {
|
|
33
|
+
resolve()
|
|
34
|
+
}
|
|
35
|
+
s.src = `https://cdn.jsdelivr.net/npm/@3cr/viewer-browser@${version}/dist/Viewer3CR.umd.js`;
|
|
36
|
+
document.head.appendChild(s);
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ...
|
|
41
|
+
|
|
42
|
+
await loadViewerScript("1.0.0");
|
|
43
|
+
```
|
|
44
|
+
`Javascript (.js)`
|
|
45
|
+
```js
|
|
46
|
+
export async function loadViewerScript(version) {
|
|
47
|
+
return new Promise((resolve) => {
|
|
48
|
+
const s = document.createElement('script');
|
|
49
|
+
s.onload = () => {
|
|
50
|
+
resolve()
|
|
51
|
+
}
|
|
52
|
+
s.src = `https://cdn.jsdelivr.net/npm/@3cr/viewer-browser@${version}/dist/Viewer3CR.umd.js`;
|
|
53
|
+
document.head.appendChild(s);
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// ...
|
|
58
|
+
|
|
59
|
+
await loadViewerScript("1.0.0");
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
## Using the Package
|
|
64
|
+
|
|
65
|
+
1. #### Register 3DICOM Online Viewer version
|
|
66
|
+
|
|
67
|
+
Call the `registerViewer` function with the version of 3CR you would like to view. This will generate a new container to load the viewer within and register the 3CR Instance.
|
|
68
|
+
|
|
69
|
+
`Typescript (.ts) / Javascript (.js)`
|
|
70
|
+
```ts
|
|
71
|
+
const VERSION_3CR: string = '1.0.0';
|
|
72
|
+
|
|
73
|
+
await window.registerViewer(VERSION_3CR)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
2. #### Load in the 3VXL file
|
|
77
|
+
|
|
78
|
+
Generate the 3VXL file and Decryption Key/Iv and supply that to the `loadViewer` function
|
|
79
|
+
|
|
80
|
+
Note: You can supply undefined/nothing to the loadViewer() function to display a default scan for testing purposes.
|
|
81
|
+
|
|
82
|
+
`Typescript (.ts) / Javascript (.js)`
|
|
83
|
+
```ts
|
|
84
|
+
const payload = {
|
|
85
|
+
Url: "<Some presigned URL to a 3VXL file.>",
|
|
86
|
+
DecryptionKey: {
|
|
87
|
+
Iv: "<Initialisation Vector of the Key>",
|
|
88
|
+
Key: "<Decryption Key>"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
await window.loadViewer(payload)
|
|
92
|
+
|
|
93
|
+
// OR
|
|
94
|
+
|
|
95
|
+
await window.loadViewer()
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
## Contributing
|
|
100
|
+
|
|
101
|
+
Pull requests are welcome. For changes, please open an issue first
|
|
102
|
+
to discuss what you would like to change.
|
|
103
|
+
|
|
104
|
+
Please make sure to update tests as appropriate.
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
[MIT](https://choosealicense.com/licenses/mit/)
|
package/package.json
CHANGED
package/README2.md
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
# @3cr/sdk-browser
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-

|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Ecosystem integration for installing and running [3DICOM Online Viewer (3CR-OV)](https://docs.3cr.singular.health/) within the Browser (client-side)
|
|
8
|
-
|
|
9
|
-
## Include `@3cr/viewer-browser` script
|
|
10
|
-
|
|
11
|
-
Choose one of the following ways
|
|
12
|
-
- ### HTML Script Tag
|
|
13
|
-
|
|
14
|
-
Insert this line into your `index.html`
|
|
15
|
-
|
|
16
|
-
```html
|
|
17
|
-
<script src="https://cdn.jsdelivr.net/npm/@3cr/viewer-browser@{{version}}/dist/Viewer3CR.umd.js"> </script>
|
|
18
|
-
```
|
|
19
|
-
Note: Please ensure you replace the `{{version}}` with the version of the viewer you want.
|
|
20
|
-
|
|
21
|
-
- ### JS/TS way
|
|
22
|
-
|
|
23
|
-
You can also include it dynamically within your code.
|
|
24
|
-
|
|
25
|
-
`Typescript (.ts)`
|
|
26
|
-
```ts
|
|
27
|
-
export async function loadViewerScript(version: string): Promise<void> {
|
|
28
|
-
return new Promise<void>((resolve) => {
|
|
29
|
-
const s = document.createElement('script');
|
|
30
|
-
s.onload = () => {
|
|
31
|
-
resolve()
|
|
32
|
-
}
|
|
33
|
-
s.src = `https://cdn.jsdelivr.net/npm/@3cr/viewer-browser@${version}/dist/Viewer3CR.umd.js`;
|
|
34
|
-
document.head.appendChild(s);
|
|
35
|
-
})
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// ...
|
|
39
|
-
|
|
40
|
-
await loadViewerScript("1.0.0");
|
|
41
|
-
```
|
|
42
|
-
`Javascript (.js)`
|
|
43
|
-
```js
|
|
44
|
-
export async function loadViewerScript(version) {
|
|
45
|
-
return new Promise((resolve) => {
|
|
46
|
-
const s = document.createElement('script');
|
|
47
|
-
s.onload = () => {
|
|
48
|
-
resolve()
|
|
49
|
-
}
|
|
50
|
-
s.src = `https://cdn.jsdelivr.net/npm/@3cr/viewer-browser@${version}/dist/Viewer3CR.umd.js`;
|
|
51
|
-
document.head.appendChild(s);
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// ...
|
|
56
|
-
|
|
57
|
-
await loadViewerScript("1.0.0");
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
## Using the Package
|
|
62
|
-
|
|
63
|
-
1. #### Register 3DICOM Online Viewer version
|
|
64
|
-
|
|
65
|
-
Call the `registerViewer` function with the version of 3CR you would like to view. You also need to supply a
|
|
66
|
-
|
|
67
|
-
`Typescript (.ts)`
|
|
68
|
-
```ts
|
|
69
|
-
import { registerVersion } from '@3cr/sdk-browser';
|
|
70
|
-
|
|
71
|
-
const VERSION_3CR: string = '1.0.0';
|
|
72
|
-
|
|
73
|
-
await registerVersion(VERSION_3CR);
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
`Javascript (.js)`
|
|
77
|
-
```js
|
|
78
|
-
import { registerVersion } from '@3cr/sdk-browser';
|
|
79
|
-
|
|
80
|
-
const VERSION_3CR = '1.0.0';
|
|
81
|
-
|
|
82
|
-
await registerVersion(VERSION_3CR);
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
2. #### Create HTML Canvas
|
|
86
|
-
|
|
87
|
-
Create a canvas element within your HTML Markup and assign it an `id`.
|
|
88
|
-
|
|
89
|
-
You will have to ensure that the size (width & height) both match the inline css styling and the canvas styling
|
|
90
|
-
|
|
91
|
-
`html`
|
|
92
|
-
```html
|
|
93
|
-
<canvas
|
|
94
|
-
id="renderer-canvas"
|
|
95
|
-
width="1080"
|
|
96
|
-
height="1920"
|
|
97
|
-
tabindex="-1"
|
|
98
|
-
style=" width: 1920px; height: 1080px; "
|
|
99
|
-
>
|
|
100
|
-
</canvas>
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
3. #### Register response handler for 3DICOM Core Renderer Instance
|
|
104
|
-
|
|
105
|
-
You will need to register a function that can accept the responses from the 3CR instance.
|
|
106
|
-
|
|
107
|
-
`Typescript (.ts)`
|
|
108
|
-
```ts
|
|
109
|
-
import { registerOnPayloadHandler } from '@3cr/sdk-browser';
|
|
110
|
-
import { FrontEndPayload } from '@3cr/sdk-browser/types/payload';
|
|
111
|
-
|
|
112
|
-
function onPayload(json: FrontEndPayload) {
|
|
113
|
-
console.log("Payload recieved from 3CR!", json)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
await registerOnPayloadHandler(onPayload);
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
`Javascript (.js)`
|
|
120
|
-
```js
|
|
121
|
-
import { registerOnPayloadHandler } from '@3cr/sdk-browser';
|
|
122
|
-
|
|
123
|
-
function onPayload(json) {
|
|
124
|
-
console.log("Payload recieved from 3CR!", json)
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
await registerOnPayloadHandler(onPayload);
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
4. #### Attach the 3CR Instance to the HTML Canvas
|
|
131
|
-
Get the HTML Element from the DOM Object and inject it into the instance.
|
|
132
|
-
|
|
133
|
-
`Typescript (.ts)`
|
|
134
|
-
```ts
|
|
135
|
-
import { createInstance } from '@3cr/sdk-browser';
|
|
136
|
-
const canvas: HTMLCanvasElement = document.querySelector('#renderer-canvas') as HTMLCanvasElement;
|
|
137
|
-
|
|
138
|
-
await createInstance(canvas);
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
`Javascript (.js)`
|
|
142
|
-
```js
|
|
143
|
-
import { createInstance } from '@3cr/sdk-browser';
|
|
144
|
-
const canvas = document.querySelector('#renderer-canvas');
|
|
145
|
-
|
|
146
|
-
await createInstance(canvas);
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
5. #### Execute payload on Instance
|
|
151
|
-
Get the HTML Element from the DOM Object and inject it into the instance.
|
|
152
|
-
|
|
153
|
-
`Typescript (.ts)`
|
|
154
|
-
```ts
|
|
155
|
-
import { executePayload } from '@3cr/sdk-browser';
|
|
156
|
-
import { FrontEndInterfaces, FileManagementActions } from '@3cr/sdk-browser/types/payload';
|
|
157
|
-
|
|
158
|
-
await executePayload({
|
|
159
|
-
Version: '1.0.0',
|
|
160
|
-
Interface: FrontEndInterfaces.file_management,
|
|
161
|
-
Action: FileManagementActions.fm_01,
|
|
162
|
-
Message: JSON.stringify({
|
|
163
|
-
Url: 'https://somethingtodownload.com/some.3vxl.compressed.encrypted',
|
|
164
|
-
DecryptionKey: {
|
|
165
|
-
Key: '<Encryption Key>',
|
|
166
|
-
Iv: '<Encryption IV>'
|
|
167
|
-
}
|
|
168
|
-
}),
|
|
169
|
-
});
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
`Javascript (.js)`
|
|
173
|
-
```js
|
|
174
|
-
import { executePayload } from '@3cr/sdk-browser';
|
|
175
|
-
|
|
176
|
-
await executePayload({
|
|
177
|
-
Version: '1.0.0',
|
|
178
|
-
Interface: 'file_management',
|
|
179
|
-
Action: 'fm_01',
|
|
180
|
-
Message: JSON.stringify({
|
|
181
|
-
Url: 'https://somethingtodownload.com/some.3vxl.compressed.encrypted',
|
|
182
|
-
DecryptionKey: {
|
|
183
|
-
Key: '<Encryption Key>',
|
|
184
|
-
Iv: '<Encryption IV>'
|
|
185
|
-
}
|
|
186
|
-
}),
|
|
187
|
-
});
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
## Contributing
|
|
193
|
-
|
|
194
|
-
Pull requests are welcome. For changes, please open an issue first
|
|
195
|
-
to discuss what you would like to change.
|
|
196
|
-
|
|
197
|
-
Please make sure to update tests as appropriate.
|
|
198
|
-
|
|
199
|
-
## License
|
|
200
|
-
|
|
201
|
-
[MIT](https://choosealicense.com/licenses/mit/)
|