@cornerstonejs/core 1.81.6 → 1.82.1
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/dist/cjs/RenderingEngine/WSIViewport.d.ts +2 -2
- package/dist/cjs/RenderingEngine/WSIViewport.js +26 -17
- package/dist/cjs/RenderingEngine/WSIViewport.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +3 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/init.d.ts +2 -1
- package/dist/cjs/init.js +7 -13
- package/dist/cjs/init.js.map +1 -1
- package/dist/cjs/types/Cornerstone3DConfig.d.ts +1 -0
- package/dist/esm/RenderingEngine/WSIViewport.js +15 -8
- package/dist/esm/RenderingEngine/WSIViewport.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/init.js +7 -11
- package/dist/esm/init.js.map +1 -1
- package/dist/types/RenderingEngine/WSIViewport.d.ts +2 -2
- package/dist/types/RenderingEngine/WSIViewport.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/init.d.ts +2 -1
- package/dist/types/init.d.ts.map +1 -1
- package/dist/types/types/Cornerstone3DConfig.d.ts +1 -0
- package/dist/types/types/Cornerstone3DConfig.d.ts.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +2 -2
- package/src/RenderingEngine/WSIViewport.ts +28 -12
- package/src/index.ts +2 -0
- package/src/init.ts +13 -12
- package/src/types/Cornerstone3DConfig.ts +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.82.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"type": "individual",
|
|
48
48
|
"url": "https://ohif.org/donate"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "5be811c05403fff8add1857d7427e04e801a7c25"
|
|
51
51
|
}
|
|
@@ -9,18 +9,26 @@ import {
|
|
|
9
9
|
WSIViewportInput,
|
|
10
10
|
VOIRange,
|
|
11
11
|
} from '../types';
|
|
12
|
+
import uuidv4 from '../utilities/uuidv4';
|
|
12
13
|
import * as metaData from '../metaData';
|
|
13
14
|
import { Transform } from './helpers/cpuFallback/rendering/transform';
|
|
14
15
|
import Viewport from './Viewport';
|
|
15
16
|
import { getOrCreateCanvas } from './helpers';
|
|
16
17
|
import { EPSILON } from '../constants';
|
|
17
18
|
import { triggerEvent } from '../utilities';
|
|
19
|
+
import { peerImport } from '../init';
|
|
18
20
|
|
|
19
21
|
const _map = Symbol.for('map');
|
|
20
22
|
const EVENT_POSTRENDER = 'postrender';
|
|
21
23
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
+
* A viewport which shows a microscopy view using the dicom-microscopy-viewer
|
|
25
|
+
* library. This viewport accepts standard CS3D annotations, and responds
|
|
26
|
+
* similar to how the other types of viewports do for things like zoom/pan.
|
|
27
|
+
*
|
|
28
|
+
* This viewport required the `dicom-microscopy-viewer` import to be available
|
|
29
|
+
* from the peerImport function in the CS3D init configuration. See the
|
|
30
|
+
* example `initDemo.js` for one possible implementation, but the actual
|
|
31
|
+
* implementation of this will depend on your platform.
|
|
24
32
|
*/
|
|
25
33
|
class WSIViewport extends Viewport implements IWSIViewport {
|
|
26
34
|
public modality;
|
|
@@ -76,7 +84,7 @@ class WSIViewport extends Viewport implements IWSIViewport {
|
|
|
76
84
|
// use absolute positioning internally.
|
|
77
85
|
this.element.style.position = 'relative';
|
|
78
86
|
this.microscopyElement = document.createElement('div');
|
|
79
|
-
this.microscopyElement.id =
|
|
87
|
+
this.microscopyElement.id = uuidv4();
|
|
80
88
|
this.microscopyElement.innerText = 'Initial';
|
|
81
89
|
this.microscopyElement.style.background = 'grey';
|
|
82
90
|
this.microscopyElement.style.width = '100%';
|
|
@@ -209,8 +217,11 @@ class WSIViewport extends Viewport implements IWSIViewport {
|
|
|
209
217
|
|
|
210
218
|
public getImageData() {
|
|
211
219
|
const { metadata } = this;
|
|
220
|
+
if (!metadata) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
212
223
|
|
|
213
|
-
const spacing = metadata
|
|
224
|
+
const { spacing } = metadata;
|
|
214
225
|
|
|
215
226
|
return {
|
|
216
227
|
dimensions: metadata.dimensions,
|
|
@@ -342,11 +353,15 @@ class WSIViewport extends Viewport implements IWSIViewport {
|
|
|
342
353
|
};
|
|
343
354
|
|
|
344
355
|
/**
|
|
345
|
-
*
|
|
356
|
+
* Encapsulate the dicom microscopy fetch so that it can be replaced
|
|
357
|
+
* with the browser import function. Webpack munges this and then throws
|
|
358
|
+
* exceptions trying to get this working, so this has to be provided externally
|
|
359
|
+
* as a globalThis.browserImportFunction taking the package name, and a set
|
|
360
|
+
* of options defining how to get the value out of the package.
|
|
346
361
|
*/
|
|
347
|
-
|
|
348
|
-
return '
|
|
349
|
-
}
|
|
362
|
+
public static getDicomMicroscopyViewer = async () => {
|
|
363
|
+
return peerImport('dicom-microscopy-viewer');
|
|
364
|
+
};
|
|
350
365
|
|
|
351
366
|
/**
|
|
352
367
|
* The FOR for whole slide imaging is the frame of reference in the DICOM
|
|
@@ -434,16 +449,15 @@ class WSIViewport extends Viewport implements IWSIViewport {
|
|
|
434
449
|
);
|
|
435
450
|
}
|
|
436
451
|
|
|
437
|
-
|
|
452
|
+
// Returns the Promise from the child element.
|
|
453
|
+
return this.setWSI(imageIds, webClient);
|
|
438
454
|
}
|
|
439
455
|
|
|
440
456
|
public async setWSI(imageIds: string[], client) {
|
|
441
457
|
this.microscopyElement.style.background = 'red';
|
|
442
458
|
this.microscopyElement.innerText = 'Loading';
|
|
443
459
|
this.imageIds = imageIds;
|
|
444
|
-
|
|
445
|
-
await import(/* webpackIgnore: true */ this.getImportPath());
|
|
446
|
-
const DicomMicroscopyViewer = (window as any).dicomMicroscopyViewer;
|
|
460
|
+
const DicomMicroscopyViewer = await WSIViewport.getDicomMicroscopyViewer();
|
|
447
461
|
this.frameOfReferenceUID = null;
|
|
448
462
|
|
|
449
463
|
const metadataDicomweb = this.imageIds.map((imageId) => {
|
|
@@ -479,6 +493,8 @@ class WSIViewport extends Viewport implements IWSIViewport {
|
|
|
479
493
|
const imageFlavor = image.ImageType[2];
|
|
480
494
|
if (imageFlavor === 'VOLUME' || imageFlavor === 'THUMBNAIL') {
|
|
481
495
|
volumeImages.push(image);
|
|
496
|
+
} else {
|
|
497
|
+
console.log('Unknown image type', image.ImageType);
|
|
482
498
|
}
|
|
483
499
|
});
|
|
484
500
|
this.metadataDicomweb = volumeImages;
|
package/src/index.ts
CHANGED
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
setConfiguration,
|
|
45
45
|
getWebWorkerManager,
|
|
46
46
|
canRenderFloatTextures,
|
|
47
|
+
peerImport,
|
|
47
48
|
} from './init';
|
|
48
49
|
|
|
49
50
|
// Classes
|
|
@@ -87,6 +88,7 @@ export {
|
|
|
87
88
|
// init
|
|
88
89
|
init,
|
|
89
90
|
isCornerstoneInitialized,
|
|
91
|
+
peerImport,
|
|
90
92
|
// configs
|
|
91
93
|
getConfiguration,
|
|
92
94
|
setConfiguration,
|
package/src/init.ts
CHANGED
|
@@ -23,21 +23,17 @@ const defaultConfig: Cornerstone3DConfig = {
|
|
|
23
23
|
},
|
|
24
24
|
// cache
|
|
25
25
|
enableCacheOptimization: true,
|
|
26
|
+
/**
|
|
27
|
+
* Imports peer modules.
|
|
28
|
+
* This may just fallback to the default import, but many packaging
|
|
29
|
+
* systems don't deal with peer imports properly.
|
|
30
|
+
*/
|
|
31
|
+
peerImport: (moduleId) => null,
|
|
26
32
|
};
|
|
27
33
|
|
|
28
34
|
let config: Cornerstone3DConfig = {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
isMobile: false, // is mobile device
|
|
32
|
-
rendering: {
|
|
33
|
-
useCPURendering: false,
|
|
34
|
-
// GPU rendering options
|
|
35
|
-
preferSizeOverAccuracy: false,
|
|
36
|
-
useNorm16Texture: false,
|
|
37
|
-
strictZSpacingForVolumeViewport: true,
|
|
38
|
-
},
|
|
39
|
-
// cache
|
|
40
|
-
enableCacheOptimization: true,
|
|
35
|
+
...defaultConfig,
|
|
36
|
+
rendering: { ...defaultConfig.rendering },
|
|
41
37
|
};
|
|
42
38
|
|
|
43
39
|
let webWorkerManager = null;
|
|
@@ -313,6 +309,10 @@ function getWebWorkerManager() {
|
|
|
313
309
|
return webWorkerManager;
|
|
314
310
|
}
|
|
315
311
|
|
|
312
|
+
function peerImport(moduleId: string) {
|
|
313
|
+
return config.peerImport(moduleId);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
316
|
export {
|
|
317
317
|
init,
|
|
318
318
|
getShouldUseCPURendering,
|
|
@@ -327,4 +327,5 @@ export {
|
|
|
327
327
|
setConfiguration,
|
|
328
328
|
getWebWorkerManager,
|
|
329
329
|
canRenderFloatTextures,
|
|
330
|
+
peerImport,
|
|
330
331
|
};
|
|
@@ -68,6 +68,12 @@ type Cornerstone3DConfig = {
|
|
|
68
68
|
* buffers.
|
|
69
69
|
*/
|
|
70
70
|
enableCacheOptimization: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* This function returns an imported module for the given module id.
|
|
73
|
+
* It allows replacing broken packing system imports with external importers
|
|
74
|
+
* that perform lazy imports.
|
|
75
|
+
*/
|
|
76
|
+
peerImport?: (moduleId: string) => any;
|
|
71
77
|
};
|
|
72
78
|
|
|
73
79
|
export default Cornerstone3DConfig;
|