@cornerstonejs/tools 4.15.23 → 4.15.25

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.
@@ -21,14 +21,11 @@ export default function mouseDown(evt) {
21
21
  return;
22
22
  }
23
23
  }
24
- const isPrimaryClick = evt.detail.event.buttons === 1;
25
- const activeToolsWithEventBinding = getToolsWithModesForMouseEvent(evt, [Active], evt.detail.event.buttons);
26
- const passiveToolsIfEventWasPrimaryMouseButton = isPrimaryClick
27
- ? getToolsWithModesForMouseEvent(evt, [Passive])
28
- : undefined;
24
+ const allActiveTools = getToolsWithModesForMouseEvent(evt, [Active]);
25
+ const allPassiveTools = getToolsWithModesForMouseEvent(evt, [Passive]);
29
26
  const applicableTools = [
30
- ...(activeToolsWithEventBinding || []),
31
- ...(passiveToolsIfEventWasPrimaryMouseButton || []),
27
+ ...(allActiveTools || []),
28
+ ...(allPassiveTools || []),
32
29
  ];
33
30
  const actionExecuted = mouseDownAnnotationAction(evt);
34
31
  if (actionExecuted) {
@@ -20,15 +20,11 @@ export default function touchStart(evt) {
20
20
  return;
21
21
  }
22
22
  }
23
- const isPrimaryClick = Object.keys(evt.detail.event.touches).length === 1;
24
- const activeToolsWithEventBinding = getToolsWithModesForTouchEvent(evt, [Active], Object.keys(evt.detail.event.touches).length);
25
- const passiveToolsIfEventWasPrimaryTouchButton = isPrimaryClick
26
- ? getToolsWithModesForTouchEvent(evt, [Passive])
27
- : undefined;
23
+ const allActiveTools = getToolsWithModesForTouchEvent(evt, [Active]);
24
+ const allPassiveTools = getToolsWithModesForTouchEvent(evt, [Passive]);
28
25
  const applicableTools = [
29
- ...(activeToolsWithEventBinding || []),
30
- ...(passiveToolsIfEventWasPrimaryTouchButton || []),
31
- activeTool,
26
+ ...(allActiveTools || []),
27
+ ...(allPassiveTools || []),
32
28
  ];
33
29
  const eventDetail = evt.detail;
34
30
  const { element } = eventDetail;
@@ -8,8 +8,8 @@ import { triggerAnnotationModified } from '../../stateManagement/annotation/help
8
8
  import ChangeTypes from '../../enums/ChangeTypes';
9
9
  import { setAnnotationSelected } from '../../stateManagement/annotation/annotationSelection';
10
10
  import { addContourSegmentationAnnotation } from '../../utilities/contourSegmentation';
11
+ import { safeStructuredClone } from '../../utilities/safeStructuredClone';
11
12
  const { DefaultHistoryMemo } = csUtils.HistoryMemo;
12
- const { PointsManager } = csUtils;
13
13
  class AnnotationTool extends AnnotationDisplayTool {
14
14
  static createAnnotationForViewport(viewport, ...annotationBaseData) {
15
15
  return this.createAnnotation({ metadata: viewport.getViewReference() }, ...annotationBaseData);
@@ -161,26 +161,11 @@ class AnnotationTool extends AnnotationDisplayTool {
161
161
  }
162
162
  static createAnnotationState(annotation, deleting) {
163
163
  const { data, annotationUID } = annotation;
164
- const cloneData = {
165
- ...data,
166
- cachedStats: {},
167
- };
168
- delete cloneData.contour;
169
- delete cloneData.spline;
170
- const state = {
164
+ return {
171
165
  annotationUID,
172
- data: structuredClone(cloneData),
166
+ data: safeStructuredClone(data),
173
167
  deleting,
174
168
  };
175
- const contour = data.contour;
176
- if (contour) {
177
- state.data.contour = {
178
- ...contour,
179
- polyline: null,
180
- pointsManager: PointsManager.create3(contour.polyline.length, contour.polyline),
181
- };
182
- }
183
- return state;
184
169
  }
185
170
  static createAnnotationMemo(element, annotation, options) {
186
171
  if (!annotation) {
@@ -39,6 +39,7 @@ import { getPixelValueUnits, getPixelValueUnitsImageId } from './getPixelValueUn
39
39
  import * as geometricSurfaceUtils from './geometricSurfaceUtils';
40
40
  import setAnnotationLabel from './setAnnotationLabel';
41
41
  import { moveAnnotationToViewPlane } from './moveAnnotationToViewPlane';
42
+ import { safeStructuredClone } from './safeStructuredClone';
42
43
  import getOrCreateImageVolume from './segmentation/getOrCreateImageVolume';
43
44
  import * as usFanExtraction from '../tools/annotation/UltrasoundPleuraBLineTool/utils/fanExtraction';
44
- export { math, planar, viewportFilters, drawing, debounce, dynamicVolume, throttle, orientation, isObject, touch, triggerEvent, calibrateImageSpacing, getCalibratedLengthUnitsAndScale, getCalibratedProbeUnitsAndValue, getCalibratedAspect, getPixelValueUnits, getPixelValueUnitsImageId, segmentation, contours, triggerAnnotationRenderForViewportIds, triggerAnnotationRenderForToolGroupIds, triggerAnnotationRender, getSphereBoundsInfo, getAnnotationNearPoint, getViewportForAnnotation, getAnnotationNearPointOnEnabledElement, viewport, cine, boundingBox, rectangleROITool, planarFreehandROITool, stackPrefetch, stackContextPrefetch, roundNumber, pointToString, polyDataUtils, voi, AnnotationMultiSlice, contourSegmentation, annotationHydration, getClosestImageIdForStackViewport, pointInSurroundingSphereCallback, normalizeViewportPlane, IslandRemoval, geometricSurfaceUtils, usFanExtraction, setAnnotationLabel, moveAnnotationToViewPlane, getOrCreateImageVolume, };
45
+ export { math, planar, viewportFilters, drawing, debounce, dynamicVolume, throttle, orientation, isObject, touch, triggerEvent, calibrateImageSpacing, getCalibratedLengthUnitsAndScale, getCalibratedProbeUnitsAndValue, getCalibratedAspect, getPixelValueUnits, getPixelValueUnitsImageId, segmentation, contours, triggerAnnotationRenderForViewportIds, triggerAnnotationRenderForToolGroupIds, triggerAnnotationRender, getSphereBoundsInfo, getAnnotationNearPoint, getViewportForAnnotation, getAnnotationNearPointOnEnabledElement, viewport, cine, boundingBox, rectangleROITool, planarFreehandROITool, stackPrefetch, stackContextPrefetch, roundNumber, pointToString, polyDataUtils, voi, AnnotationMultiSlice, contourSegmentation, annotationHydration, getClosestImageIdForStackViewport, pointInSurroundingSphereCallback, normalizeViewportPlane, IslandRemoval, geometricSurfaceUtils, usFanExtraction, setAnnotationLabel, moveAnnotationToViewPlane, safeStructuredClone, getOrCreateImageVolume, };
@@ -39,6 +39,7 @@ import { getPixelValueUnits, getPixelValueUnitsImageId, } from './getPixelValueU
39
39
  import * as geometricSurfaceUtils from './geometricSurfaceUtils';
40
40
  import setAnnotationLabel from './setAnnotationLabel';
41
41
  import { moveAnnotationToViewPlane } from './moveAnnotationToViewPlane';
42
+ import { safeStructuredClone } from './safeStructuredClone';
42
43
  import getOrCreateImageVolume from './segmentation/getOrCreateImageVolume';
43
44
  import * as usFanExtraction from '../tools/annotation/UltrasoundPleuraBLineTool/utils/fanExtraction';
44
- export { math, planar, viewportFilters, drawing, debounce, dynamicVolume, throttle, orientation, isObject, touch, triggerEvent, calibrateImageSpacing, getCalibratedLengthUnitsAndScale, getCalibratedProbeUnitsAndValue, getCalibratedAspect, getPixelValueUnits, getPixelValueUnitsImageId, segmentation, contours, triggerAnnotationRenderForViewportIds, triggerAnnotationRenderForToolGroupIds, triggerAnnotationRender, getSphereBoundsInfo, getAnnotationNearPoint, getViewportForAnnotation, getAnnotationNearPointOnEnabledElement, viewport, cine, boundingBox, rectangleROITool, planarFreehandROITool, stackPrefetch, stackContextPrefetch, roundNumber, pointToString, polyDataUtils, voi, AnnotationMultiSlice, contourSegmentation, annotationHydration, getClosestImageIdForStackViewport, pointInSurroundingSphereCallback, normalizeViewportPlane, IslandRemoval, geometricSurfaceUtils, usFanExtraction, setAnnotationLabel, moveAnnotationToViewPlane, getOrCreateImageVolume, };
45
+ export { math, planar, viewportFilters, drawing, debounce, dynamicVolume, throttle, orientation, isObject, touch, triggerEvent, calibrateImageSpacing, getCalibratedLengthUnitsAndScale, getCalibratedProbeUnitsAndValue, getCalibratedAspect, getPixelValueUnits, getPixelValueUnitsImageId, segmentation, contours, triggerAnnotationRenderForViewportIds, triggerAnnotationRenderForToolGroupIds, triggerAnnotationRender, getSphereBoundsInfo, getAnnotationNearPoint, getViewportForAnnotation, getAnnotationNearPointOnEnabledElement, viewport, cine, boundingBox, rectangleROITool, planarFreehandROITool, stackPrefetch, stackContextPrefetch, roundNumber, pointToString, polyDataUtils, voi, AnnotationMultiSlice, contourSegmentation, annotationHydration, getClosestImageIdForStackViewport, pointInSurroundingSphereCallback, normalizeViewportPlane, IslandRemoval, geometricSurfaceUtils, usFanExtraction, setAnnotationLabel, moveAnnotationToViewPlane, safeStructuredClone, getOrCreateImageVolume, };
@@ -0,0 +1 @@
1
+ export declare function safeStructuredClone<T>(value: T): T;
@@ -0,0 +1,53 @@
1
+ import { utilities as csUtils } from '@cornerstonejs/core';
2
+ const { PointsManager } = csUtils;
3
+ function cloneContourValue(_key, value) {
4
+ if (value == null || typeof value !== 'object' || !('polyline' in value)) {
5
+ return value;
6
+ }
7
+ const contour = value;
8
+ return {
9
+ ...contour,
10
+ polyline: null,
11
+ pointsManager: PointsManager.create3(contour.polyline.length, contour.polyline),
12
+ };
13
+ }
14
+ const OMIT_KEYS = new Map([
15
+ ['pointsInVolume', null],
16
+ ['projectionPoints', null],
17
+ ['contour', cloneContourValue],
18
+ ['spline', null],
19
+ ]);
20
+ function omitUncloneableKeys(obj) {
21
+ const result = {};
22
+ for (const [key, value] of Object.entries(obj)) {
23
+ if (OMIT_KEYS.has(key)) {
24
+ const handler = OMIT_KEYS.get(key);
25
+ if (handler) {
26
+ result[key] = handler(key, value);
27
+ }
28
+ continue;
29
+ }
30
+ if (value === null || value === undefined || typeof value !== 'object') {
31
+ result[key] = value;
32
+ }
33
+ else if (Array.isArray(value)) {
34
+ result[key] = value.map((value) => safeStructuredClone(value));
35
+ }
36
+ else {
37
+ result[key] = omitUncloneableKeys(value);
38
+ }
39
+ }
40
+ return result;
41
+ }
42
+ export function safeStructuredClone(value) {
43
+ if (value === null || value === undefined) {
44
+ return value;
45
+ }
46
+ if (typeof value !== 'object') {
47
+ return value;
48
+ }
49
+ if (Array.isArray(value)) {
50
+ return value.map((item) => safeStructuredClone(item));
51
+ }
52
+ return omitUncloneableKeys(value);
53
+ }
@@ -1 +1 @@
1
- export declare const version = "4.15.23";
1
+ export declare const version = "4.15.25";
@@ -1 +1 @@
1
- export const version = '4.15.23';
1
+ export const version = '4.15.25';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "4.15.23",
3
+ "version": "4.15.25",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "types": "./dist/esm/index.d.ts",
6
6
  "module": "./dist/esm/index.js",
@@ -108,7 +108,7 @@
108
108
  "canvas": "3.2.0"
109
109
  },
110
110
  "peerDependencies": {
111
- "@cornerstonejs/core": "4.15.23",
111
+ "@cornerstonejs/core": "4.15.25",
112
112
  "@kitware/vtk.js": "34.15.1",
113
113
  "@types/d3-array": "3.2.1",
114
114
  "@types/d3-interpolate": "3.0.4",
@@ -127,5 +127,5 @@
127
127
  "type": "individual",
128
128
  "url": "https://ohif.org/donate"
129
129
  },
130
- "gitHead": "993b2ea724b4e8ef03fb5a710ee8a106d151f2a9"
130
+ "gitHead": "7609d25e3506ef4c15ffa82e1e35afcc1082863e"
131
131
  }