@cornerstonejs/core 1.81.3 → 1.81.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/core",
3
- "version": "1.81.3",
3
+ "version": "1.81.5",
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": "945fb26ade3946d7beccd8a4684c1ca20552d647"
50
+ "gitHead": "e3e10fa13b4615e78e5cf08e252f2a9156700383"
51
51
  }
@@ -2965,17 +2965,17 @@ class StackViewport extends Viewport implements IStackViewport, IImagesLoader {
2965
2965
  if (!viewRef) {
2966
2966
  return;
2967
2967
  }
2968
- const { referencedImageId, sliceIndex, volumeId } = viewRef;
2968
+ const { referencedImageId, sliceIndex } = viewRef;
2969
2969
  if (
2970
2970
  typeof sliceIndex === 'number' &&
2971
2971
  referencedImageId &&
2972
2972
  referencedImageId === this.imageIds[sliceIndex]
2973
2973
  ) {
2974
- this.setImageIdIndex(sliceIndex);
2974
+ this.scroll(sliceIndex - this.targetImageIdIndex);
2975
2975
  } else {
2976
2976
  const foundIndex = this.imageIds.indexOf(referencedImageId);
2977
2977
  if (foundIndex !== -1) {
2978
- this.setImageIdIndex(foundIndex);
2978
+ this.scroll(foundIndex - this.targetImageIdIndex);
2979
2979
  } else {
2980
2980
  throw new Error('Unsupported - referenced image id not found');
2981
2981
  }
@@ -121,7 +121,13 @@ class Cache implements ICache {
121
121
  *
122
122
  */
123
123
  private _decacheImage = (imageId: string) => {
124
- const { imageLoadObject } = this._imageCache.get(imageId);
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 === undefined) {
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
- volume: IImageVolume;
474
- imageIdIndex: number;
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 = (volumeId: string): IVolumeLoadObject => {
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 === undefined) {
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 === undefined) {
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 === undefined) {
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 === undefined) {
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 === undefined) {
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 === undefined) {
809
+ if (!cachedVolume) {
780
810
  throw new Error(
781
811
  'removeVolumeLoadObject: volumeId was not present in volumeCache'
782
812
  );