@cornerstonejs/tools 1.65.3 → 1.65.4

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.
Files changed (46) hide show
  1. package/dist/cjs/stateManagement/annotation/annotationSelection.js +2 -1
  2. package/dist/cjs/stateManagement/annotation/annotationSelection.js.map +1 -1
  3. package/dist/cjs/tools/MIPJumpToClickTool.js +2 -1
  4. package/dist/cjs/tools/MIPJumpToClickTool.js.map +1 -1
  5. package/dist/cjs/tools/StackScrollToolMouseWheelTool.js +2 -1
  6. package/dist/cjs/tools/StackScrollToolMouseWheelTool.js.map +1 -1
  7. package/dist/cjs/tools/base/AnnotationDisplayTool.js +2 -1
  8. package/dist/cjs/tools/base/AnnotationDisplayTool.js.map +1 -1
  9. package/dist/cjs/tools/base/AnnotationTool.js +2 -1
  10. package/dist/cjs/tools/base/AnnotationTool.js.map +1 -1
  11. package/dist/cjs/tools/base/BaseTool.js +2 -1
  12. package/dist/cjs/tools/base/BaseTool.js.map +1 -1
  13. package/dist/cjs/utilities/getVolumeId.d.ts +1 -0
  14. package/dist/cjs/utilities/getVolumeId.js +16 -0
  15. package/dist/cjs/utilities/getVolumeId.js.map +1 -0
  16. package/dist/esm/stateManagement/annotation/annotationSelection.js +1 -1
  17. package/dist/esm/stateManagement/annotation/annotationSelection.js.map +1 -1
  18. package/dist/esm/tools/MIPJumpToClickTool.js +2 -1
  19. package/dist/esm/tools/MIPJumpToClickTool.js.map +1 -1
  20. package/dist/esm/tools/StackScrollToolMouseWheelTool.js +2 -1
  21. package/dist/esm/tools/StackScrollToolMouseWheelTool.js.map +1 -1
  22. package/dist/esm/tools/base/AnnotationDisplayTool.js +2 -1
  23. package/dist/esm/tools/base/AnnotationDisplayTool.js.map +1 -1
  24. package/dist/esm/tools/base/AnnotationTool.js +2 -1
  25. package/dist/esm/tools/base/AnnotationTool.js.map +1 -1
  26. package/dist/esm/tools/base/BaseTool.js +2 -1
  27. package/dist/esm/tools/base/BaseTool.js.map +1 -1
  28. package/dist/esm/utilities/getVolumeId.js +12 -0
  29. package/dist/esm/utilities/getVolumeId.js.map +1 -0
  30. package/dist/types/tools/MIPJumpToClickTool.d.ts.map +1 -1
  31. package/dist/types/tools/StackScrollToolMouseWheelTool.d.ts.map +1 -1
  32. package/dist/types/tools/base/AnnotationDisplayTool.d.ts.map +1 -1
  33. package/dist/types/tools/base/AnnotationTool.d.ts.map +1 -1
  34. package/dist/types/tools/base/BaseTool.d.ts.map +1 -1
  35. package/dist/types/utilities/getVolumeId.d.ts +2 -0
  36. package/dist/types/utilities/getVolumeId.d.ts.map +1 -0
  37. package/dist/umd/index.js +1 -1
  38. package/dist/umd/index.js.map +1 -1
  39. package/package.json +3 -3
  40. package/src/stateManagement/annotation/annotationSelection.ts +1 -1
  41. package/src/tools/MIPJumpToClickTool.ts +2 -1
  42. package/src/tools/StackScrollToolMouseWheelTool.ts +2 -1
  43. package/src/tools/base/AnnotationDisplayTool.ts +2 -1
  44. package/src/tools/base/AnnotationTool.ts +2 -1
  45. package/src/tools/base/BaseTool.ts +2 -1
  46. package/src/utilities/getVolumeId.ts +13 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "1.65.3",
3
+ "version": "1.65.4",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "main": "src/index.ts",
6
6
  "types": "dist/types/index.d.ts",
@@ -29,7 +29,7 @@
29
29
  "webpack:watch": "webpack --mode development --progress --watch --config ./.webpack/webpack.dev.js"
30
30
  },
31
31
  "dependencies": {
32
- "@cornerstonejs/core": "^1.65.3",
32
+ "@cornerstonejs/core": "^1.65.4",
33
33
  "@icr/polyseg-wasm": "0.4.0",
34
34
  "@types/offscreencanvas": "2019.7.3",
35
35
  "comlink": "^4.4.1",
@@ -59,5 +59,5 @@
59
59
  "type": "individual",
60
60
  "url": "https://ohif.org/donate"
61
61
  },
62
- "gitHead": "7059912b7d083525acdc48af7d0d38eec27efa64"
62
+ "gitHead": "9f0c1e30b8bf4cfca1ca04186f377e2a2f3a2b54"
63
63
  }
@@ -94,7 +94,7 @@ function getAnnotationsSelected(): Array<string> {
94
94
  function getAnnotationsSelectedByToolName(toolName: string): Array<string> {
95
95
  return getAnnotationsSelected().filter((annotationUID) => {
96
96
  const annotation = getAnnotation(annotationUID);
97
- return annotation.metadata.toolName === toolName;
97
+ return annotation?.metadata?.toolName === toolName;
98
98
  });
99
99
  }
100
100
 
@@ -5,6 +5,7 @@ import { getPointInLineOfSightWithCriteria } from '../utilities/planar';
5
5
  import jumpToWorld from '../utilities/viewport/jumpToWorld';
6
6
  import { PublicToolProps, ToolProps } from '../types';
7
7
  import { getToolGroupForViewport } from '../store/ToolGroupManager';
8
+ import { getVolumeId } from '../utilities/getVolumeId';
8
9
 
9
10
  /**
10
11
  * On a Maximum Intensity Projection (MIP) viewport, MIPJumpToClickTool allows the
@@ -54,7 +55,7 @@ class MIPJumpToClickTool extends BaseTool {
54
55
  );
55
56
  }
56
57
 
57
- const volumeId = targetId.split(/volumeId:|\?/)[1];
58
+ const volumeId = getVolumeId(targetId);
58
59
 
59
60
  // 3. Criteria function to search for the point (maximum intensity)
60
61
  let maxIntensity = -Infinity;
@@ -2,6 +2,7 @@ import { getEnabledElement } from '@cornerstonejs/core';
2
2
  import { BaseTool } from './base';
3
3
  import { MouseWheelEventType } from '../types/EventTypes';
4
4
  import scroll from '../utilities/scroll';
5
+ import { getVolumeId } from '../utilities/getVolumeId';
5
6
 
6
7
  /**
7
8
  * The StackScrollMouseWheelTool is a tool that allows the user to scroll through a
@@ -35,7 +36,7 @@ class StackScrollMouseWheelTool extends BaseTool {
35
36
  const delta = direction * (invert ? -1 : 1);
36
37
 
37
38
  const targetId = this.getTargetId(viewport);
38
- const volumeId = targetId.split(/volumeId:|\?/)[1];
39
+ const volumeId = getVolumeId(targetId);
39
40
 
40
41
  scroll(viewport, {
41
42
  delta,
@@ -15,6 +15,7 @@ import filterAnnotationsForDisplay from '../../utilities/planar/filterAnnotation
15
15
  import { getStyleProperty } from '../../stateManagement/annotation/config/helpers';
16
16
  import { getState } from '../../stateManagement/annotation/config';
17
17
  import { StyleSpecifier } from '../../types/AnnotationStyle';
18
+ import { getVolumeId } from '../../utilities/getVolumeId';
18
19
 
19
20
  /**
20
21
  * Abstract class for tools which create and display annotations on the
@@ -137,7 +138,7 @@ abstract class AnnotationDisplayTool extends BaseTool {
137
138
  } else if (viewport instanceof VideoViewport) {
138
139
  referencedImageId = targetId.split('videoId:')[1];
139
140
  } else {
140
- const volumeId = targetId.split(/volumeId:|\?/)[1];
141
+ const volumeId = getVolumeId(targetId);
141
142
  const imageVolume = cache.getVolume(volumeId);
142
143
 
143
144
  referencedImageId = utilities.getClosestImageId(
@@ -24,6 +24,7 @@ import {
24
24
  import { addAnnotation } from '../../stateManagement/annotation/annotationState';
25
25
  import { StyleSpecifier } from '../../types/AnnotationStyle';
26
26
  import { triggerAnnotationModified } from '../../stateManagement/annotation/helpers/state';
27
+ import { getVolumeId } from '../../utilities/getVolumeId';
27
28
 
28
29
  /**
29
30
  * Abstract class for tools which create and display annotations on the
@@ -368,7 +369,7 @@ abstract class AnnotationTool extends AnnotationDisplayTool {
368
369
  imageId?: string
369
370
  ): boolean {
370
371
  if (viewport instanceof BaseVolumeViewport) {
371
- const volumeId = targetId.split(/volumeId:|\?/)[1];
372
+ const volumeId = getVolumeId(targetId);
372
373
  const volume = cache.getVolume(volumeId);
373
374
  return volume.scaling?.PT !== undefined;
374
375
  }
@@ -3,6 +3,7 @@ import { Types } from '@cornerstonejs/core';
3
3
  import ToolModes from '../../enums/ToolModes';
4
4
  import StrategyCallbacks from '../../enums/StrategyCallbacks';
5
5
  import { InteractionTypes, ToolProps, PublicToolProps } from '../../types';
6
+ import { getVolumeId } from '../../utilities/getVolumeId';
6
7
 
7
8
  export interface IBaseTool {
8
9
  /** ToolGroup ID the tool instance belongs to */
@@ -208,7 +209,7 @@ abstract class BaseTool implements IBaseTool {
208
209
 
209
210
  return viewports[0].getImageData();
210
211
  } else if (targetId.startsWith('volumeId:')) {
211
- const volumeId = targetId.split(/volumeId:|\?/)[1];
212
+ const volumeId = getVolumeId(targetId);
212
213
  const viewports = utilities.getViewportsWithVolumeId(
213
214
  volumeId,
214
215
  renderingEngine.id
@@ -0,0 +1,13 @@
1
+ export const getVolumeId = (targetId: string) => {
2
+ const prefix = 'volumeId:';
3
+ const str = targetId.includes(prefix)
4
+ ? targetId.substring(prefix.length)
5
+ : targetId;
6
+
7
+ if (str.startsWith('nifti:')) {
8
+ return str;
9
+ }
10
+
11
+ const index = str.indexOf('?');
12
+ return index === -1 ? str : str.substring(0, index);
13
+ };