@cornerstonejs/core 1.81.4 → 1.81.6
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/cache/cache.d.ts +6 -6
- package/dist/cjs/cache/cache.js +21 -8
- package/dist/cjs/cache/cache.js.map +1 -1
- package/dist/esm/cache/cache.js +21 -8
- package/dist/esm/cache/cache.js.map +1 -1
- package/dist/types/cache/cache.d.ts +6 -6
- package/dist/types/cache/cache.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/cache/cache.ts +47 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/core",
|
|
3
|
-
"version": "1.81.
|
|
3
|
+
"version": "1.81.6",
|
|
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": "ea0dc0386909120486e76447a86ba3ff6ffe0cd9"
|
|
51
51
|
}
|
package/src/cache/cache.ts
CHANGED
|
@@ -121,7 +121,13 @@ class Cache implements ICache {
|
|
|
121
121
|
*
|
|
122
122
|
*/
|
|
123
123
|
private _decacheImage = (imageId: string) => {
|
|
124
|
-
const
|
|
124
|
+
const cachedImage = this._imageCache.get(imageId);
|
|
125
|
+
|
|
126
|
+
if (!cachedImage) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const { imageLoadObject } = cachedImage;
|
|
125
131
|
|
|
126
132
|
// Cancel any in-progress loading
|
|
127
133
|
if (imageLoadObject.cancelFn) {
|
|
@@ -143,8 +149,17 @@ class Cache implements ICache {
|
|
|
143
149
|
*/
|
|
144
150
|
private _decacheVolume = (volumeId: string) => {
|
|
145
151
|
const cachedVolume = this._volumeCache.get(volumeId);
|
|
152
|
+
|
|
153
|
+
if (!cachedVolume) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
146
157
|
const { volumeLoadObject, volume } = cachedVolume;
|
|
147
158
|
|
|
159
|
+
if (!volume) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
148
163
|
if (volume.cancelLoading) {
|
|
149
164
|
volume.cancelLoading();
|
|
150
165
|
}
|
|
@@ -429,13 +444,14 @@ class Cache implements ICache {
|
|
|
429
444
|
* @param imageId - Image ID
|
|
430
445
|
* @returns IImageLoadObject
|
|
431
446
|
*/
|
|
432
|
-
public getImageLoadObject(imageId: string): IImageLoadObject {
|
|
447
|
+
public getImageLoadObject(imageId: string): IImageLoadObject | undefined {
|
|
433
448
|
if (imageId === undefined) {
|
|
434
449
|
throw new Error('getImageLoadObject: imageId must not be undefined');
|
|
435
450
|
}
|
|
451
|
+
|
|
436
452
|
const cachedImage = this._imageCache.get(imageId);
|
|
437
453
|
|
|
438
|
-
if (cachedImage
|
|
454
|
+
if (!cachedImage) {
|
|
439
455
|
return;
|
|
440
456
|
}
|
|
441
457
|
|
|
@@ -469,15 +485,22 @@ class Cache implements ICache {
|
|
|
469
485
|
* @param imageId - ImageId
|
|
470
486
|
* @returns - Volume object
|
|
471
487
|
*/
|
|
472
|
-
public getVolumeContainingImageId(imageId: string):
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
488
|
+
public getVolumeContainingImageId(imageId: string):
|
|
489
|
+
| {
|
|
490
|
+
volume: IImageVolume;
|
|
491
|
+
imageIdIndex: number;
|
|
492
|
+
}
|
|
493
|
+
| undefined {
|
|
476
494
|
const volumeIds = Array.from(this._volumeCache.keys());
|
|
477
495
|
const imageIdToUse = imageIdToURI(imageId);
|
|
478
496
|
|
|
479
497
|
for (const volumeId of volumeIds) {
|
|
480
498
|
const cachedVolume = this._volumeCache.get(volumeId);
|
|
499
|
+
|
|
500
|
+
if (!cachedVolume) {
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
|
|
481
504
|
const { volume } = cachedVolume;
|
|
482
505
|
|
|
483
506
|
if (!volume?.imageIds?.length) {
|
|
@@ -627,13 +650,16 @@ class Cache implements ICache {
|
|
|
627
650
|
* @param volumeId - Volume ID
|
|
628
651
|
* @returns IVolumeLoadObject
|
|
629
652
|
*/
|
|
630
|
-
public getVolumeLoadObject = (
|
|
653
|
+
public getVolumeLoadObject = (
|
|
654
|
+
volumeId: string
|
|
655
|
+
): IVolumeLoadObject | undefined => {
|
|
631
656
|
if (volumeId === undefined) {
|
|
632
657
|
throw new Error('getVolumeLoadObject: volumeId must not be undefined');
|
|
633
658
|
}
|
|
659
|
+
|
|
634
660
|
const cachedVolume = this._volumeCache.get(volumeId);
|
|
635
661
|
|
|
636
|
-
if (cachedVolume
|
|
662
|
+
if (!cachedVolume) {
|
|
637
663
|
return;
|
|
638
664
|
}
|
|
639
665
|
|
|
@@ -643,14 +669,14 @@ class Cache implements ICache {
|
|
|
643
669
|
return cachedVolume.volumeLoadObject;
|
|
644
670
|
};
|
|
645
671
|
|
|
646
|
-
public getGeometry = (geometryId: string): IGeometry => {
|
|
672
|
+
public getGeometry = (geometryId: string): IGeometry | undefined => {
|
|
647
673
|
if (geometryId == null) {
|
|
648
674
|
throw new Error('getGeometry: geometryId must not be undefined');
|
|
649
675
|
}
|
|
650
676
|
|
|
651
677
|
const cachedGeometry = this._geometryCache.get(geometryId);
|
|
652
678
|
|
|
653
|
-
if (cachedGeometry
|
|
679
|
+
if (!cachedGeometry) {
|
|
654
680
|
return;
|
|
655
681
|
}
|
|
656
682
|
|
|
@@ -666,13 +692,14 @@ class Cache implements ICache {
|
|
|
666
692
|
* @param imageId - image ID
|
|
667
693
|
* @returns Image
|
|
668
694
|
*/
|
|
669
|
-
public getImage = (imageId: string): IImage => {
|
|
695
|
+
public getImage = (imageId: string): IImage | undefined => {
|
|
670
696
|
if (imageId === undefined) {
|
|
671
697
|
throw new Error('getImage: imageId must not be undefined');
|
|
672
698
|
}
|
|
699
|
+
|
|
673
700
|
const cachedImage = this._imageCache.get(imageId);
|
|
674
701
|
|
|
675
|
-
if (cachedImage
|
|
702
|
+
if (!cachedImage) {
|
|
676
703
|
return;
|
|
677
704
|
}
|
|
678
705
|
|
|
@@ -688,13 +715,14 @@ class Cache implements ICache {
|
|
|
688
715
|
* @param volumeId - Volume ID
|
|
689
716
|
* @returns Volume
|
|
690
717
|
*/
|
|
691
|
-
public getVolume = (volumeId: string): IImageVolume => {
|
|
718
|
+
public getVolume = (volumeId: string): IImageVolume | undefined => {
|
|
692
719
|
if (volumeId === undefined) {
|
|
693
720
|
throw new Error('getVolume: volumeId must not be undefined');
|
|
694
721
|
}
|
|
722
|
+
|
|
695
723
|
const cachedVolume = this._volumeCache.get(volumeId);
|
|
696
724
|
|
|
697
|
-
if (cachedVolume
|
|
725
|
+
if (!cachedVolume) {
|
|
698
726
|
return;
|
|
699
727
|
}
|
|
700
728
|
|
|
@@ -742,9 +770,10 @@ class Cache implements ICache {
|
|
|
742
770
|
if (imageId === undefined) {
|
|
743
771
|
throw new Error('removeImageLoadObject: imageId must not be undefined');
|
|
744
772
|
}
|
|
773
|
+
|
|
745
774
|
const cachedImage = this._imageCache.get(imageId);
|
|
746
775
|
|
|
747
|
-
if (cachedImage
|
|
776
|
+
if (!cachedImage) {
|
|
748
777
|
throw new Error(
|
|
749
778
|
'removeImageLoadObject: imageId was not present in imageCache'
|
|
750
779
|
);
|
|
@@ -774,9 +803,10 @@ class Cache implements ICache {
|
|
|
774
803
|
if (volumeId === undefined) {
|
|
775
804
|
throw new Error('removeVolumeLoadObject: volumeId must not be undefined');
|
|
776
805
|
}
|
|
806
|
+
|
|
777
807
|
const cachedVolume = this._volumeCache.get(volumeId);
|
|
778
808
|
|
|
779
|
-
if (cachedVolume
|
|
809
|
+
if (!cachedVolume) {
|
|
780
810
|
throw new Error(
|
|
781
811
|
'removeVolumeLoadObject: volumeId was not present in volumeCache'
|
|
782
812
|
);
|