@imfusion/sdk-react 1.3.1-dev.1.g3f06a0fc → 1.3.1-dev.10.ge5572efd
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/README.md +4 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/useBrush.d.ts +31 -0
- package/dist/useBrush.js +44 -0
- package/dist/useDisplayOptions.js +2 -2
- package/dist/useLabelConfig.d.ts +1 -1
- package/dist/useLabelConfig.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# ImFusion
|
|
1
|
+
# ImFusion React SDK
|
|
2
2
|
|
|
3
3
|
React components and hooks for using the ImFusion Web SDK in React applications. This package
|
|
4
4
|
provides a canvas, SDK lifecycle components, and hooks for working with medical image data.
|
|
@@ -6,14 +6,14 @@ It builds on [@imfusion/sdk](https://www.npmjs.com/package/@imfusion/sdk).
|
|
|
6
6
|
|
|
7
7
|
Documentation: [docs.imfusion.com/websdk](https://docs.imfusion.com/websdk).
|
|
8
8
|
|
|
9
|
-
##
|
|
10
|
-
|
|
11
|
-
Install both packages in your React application:
|
|
9
|
+
## Installation
|
|
12
10
|
|
|
13
11
|
```sh
|
|
14
12
|
npm install @imfusion/sdk @imfusion/sdk-react
|
|
15
13
|
```
|
|
16
14
|
|
|
15
|
+
## Getting Started
|
|
16
|
+
|
|
17
17
|
Wrap your app with `ImFusionProvider`, add a canvas, and use the lifecycle components:
|
|
18
18
|
|
|
19
19
|
```tsx
|
package/dist/index.d.ts
CHANGED
|
@@ -17,3 +17,4 @@ export { useFrameSelection } from './useFrameSelection.js';
|
|
|
17
17
|
export { useContextMenu } from './useContextMenu.js';
|
|
18
18
|
export { useLabelConfig } from './useLabelConfig.js';
|
|
19
19
|
export { useThumbnail } from './useThumbnail.js';
|
|
20
|
+
export { useBrush } from './useBrush.js';
|
package/dist/index.js
CHANGED
|
@@ -17,3 +17,4 @@ export { useFrameSelection } from './useFrameSelection.js';
|
|
|
17
17
|
export { useContextMenu } from './useContextMenu.js';
|
|
18
18
|
export { useLabelConfig } from './useLabelConfig.js';
|
|
19
19
|
export { useThumbnail } from './useThumbnail.js';
|
|
20
|
+
export { useBrush } from './useBrush.js';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the reactive Brush state.
|
|
3
|
+
*
|
|
4
|
+
* Subscribes to {@link @imfusion/sdk!Brush.onBrushSettingsChanged | onBrushSettingsChanged} so the component re-renders
|
|
5
|
+
* when the brush's settings change.
|
|
6
|
+
*
|
|
7
|
+
* @returns The {@link @imfusion/sdk!Brush | Brush} handle
|
|
8
|
+
* @throws If called outside of an {@link ImFusionProvider}
|
|
9
|
+
* @throws If called before the SDK has finished initializing
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* function BrushAdaptivenessSlider() {
|
|
14
|
+
* const brush = useBrush();
|
|
15
|
+
*
|
|
16
|
+
* return (
|
|
17
|
+
* <input
|
|
18
|
+
* type="range"
|
|
19
|
+
* min={0}
|
|
20
|
+
* max={1}
|
|
21
|
+
* value={brush.adaptiveness}
|
|
22
|
+
* step={0.01}
|
|
23
|
+
* onChange={(event) => {
|
|
24
|
+
* brush.adaptiveness = parseFloat(event.target.value);
|
|
25
|
+
* }}
|
|
26
|
+
* ></input>
|
|
27
|
+
* );
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function useBrush(): import("@imfusion/sdk").Brush;
|
package/dist/useBrush.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useState, useEffect, useReducer } from 'react';
|
|
2
|
+
import { useImFusion } from './useImFusion.js';
|
|
3
|
+
/**
|
|
4
|
+
* Returns the reactive Brush state.
|
|
5
|
+
*
|
|
6
|
+
* Subscribes to {@link @imfusion/sdk!Brush.onBrushSettingsChanged | onBrushSettingsChanged} so the component re-renders
|
|
7
|
+
* when the brush's settings change.
|
|
8
|
+
*
|
|
9
|
+
* @returns The {@link @imfusion/sdk!Brush | Brush} handle
|
|
10
|
+
* @throws If called outside of an {@link ImFusionProvider}
|
|
11
|
+
* @throws If called before the SDK has finished initializing
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* function BrushAdaptivenessSlider() {
|
|
16
|
+
* const brush = useBrush();
|
|
17
|
+
*
|
|
18
|
+
* return (
|
|
19
|
+
* <input
|
|
20
|
+
* type="range"
|
|
21
|
+
* min={0}
|
|
22
|
+
* max={1}
|
|
23
|
+
* value={brush.adaptiveness}
|
|
24
|
+
* step={0.01}
|
|
25
|
+
* onChange={(event) => {
|
|
26
|
+
* brush.adaptiveness = parseFloat(event.target.value);
|
|
27
|
+
* }}
|
|
28
|
+
* ></input>
|
|
29
|
+
* );
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export function useBrush() {
|
|
34
|
+
const imf = useImFusion();
|
|
35
|
+
const [brush, setBrush] = useState(() => imf.brush);
|
|
36
|
+
// Triggers a re-render without mirroring all C++ properties as React state.
|
|
37
|
+
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
|
38
|
+
useEffect(function syncBrush() {
|
|
39
|
+
setBrush(imf.brush);
|
|
40
|
+
const off = brush.onBrushSettingsChanged(() => forceUpdate());
|
|
41
|
+
return off;
|
|
42
|
+
}, [imf, brush]);
|
|
43
|
+
return brush;
|
|
44
|
+
}
|
|
@@ -32,7 +32,7 @@ import { useStableHandle } from './useStableHandle.js';
|
|
|
32
32
|
export function useDisplayOptions2d(sis) {
|
|
33
33
|
useImFusion();
|
|
34
34
|
// Triggers a re-render without mirroring all C++ properties as React state.
|
|
35
|
-
const [, forceUpdate] = useReducer((x) =>
|
|
35
|
+
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
|
36
36
|
const stableSis = useStableHandle(sis);
|
|
37
37
|
const [options, setOptions] = useState(() => stableSis.displayOptions2d());
|
|
38
38
|
useEffect(() => {
|
|
@@ -74,7 +74,7 @@ export function useDisplayOptions2d(sis) {
|
|
|
74
74
|
export function useDisplayOptions3d(sis) {
|
|
75
75
|
useImFusion();
|
|
76
76
|
// Triggers a re-render without mirroring all C++ properties as React state.
|
|
77
|
-
const [, forceUpdate] = useReducer((x) =>
|
|
77
|
+
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
|
78
78
|
const stableSis = useStableHandle(sis);
|
|
79
79
|
const [options, setOptions] = useState(() => stableSis.displayOptions3d());
|
|
80
80
|
useEffect(() => {
|
package/dist/useLabelConfig.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { LabelConfig, SharedImageSet } from '@imfusion/sdk';
|
|
|
2
2
|
/**
|
|
3
3
|
* Returns the reactive `LabelConfigMap` state of a label map.
|
|
4
4
|
*
|
|
5
|
-
* Subscribes to {@link @imfusion/sdk!
|
|
5
|
+
* Subscribes to {@link @imfusion/sdk!Bindings.onLabelConfigChanged | onLabelConfigChanged}
|
|
6
6
|
*
|
|
7
7
|
* @param labelMap - The label map to observe
|
|
8
8
|
* @returns The current label config state as a `Map<number, LabelConfig>`, a function to change the whole map and a function to change individual entries
|
package/dist/useLabelConfig.js
CHANGED
|
@@ -4,7 +4,7 @@ import { useStableHandle } from './useStableHandle.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Returns the reactive `LabelConfigMap` state of a label map.
|
|
6
6
|
*
|
|
7
|
-
* Subscribes to {@link @imfusion/sdk!
|
|
7
|
+
* Subscribes to {@link @imfusion/sdk!Bindings.onLabelConfigChanged | onLabelConfigChanged}
|
|
8
8
|
*
|
|
9
9
|
* @param labelMap - The label map to observe
|
|
10
10
|
* @returns The current label config state as a `Map<number, LabelConfig>`, a function to change the whole map and a function to change individual entries
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imfusion/sdk-react",
|
|
3
|
-
"version": "1.3.1-dev.
|
|
3
|
+
"version": "1.3.1-dev.10.ge5572efd",
|
|
4
4
|
"description": "React bindings for ImFusion Web SDK",
|
|
5
5
|
"homepage": "https://docs.imfusion.com/websdk",
|
|
6
6
|
"author": "ImFusion GmbH",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"LICENSE.txt"
|
|
31
31
|
],
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@imfusion/sdk": "1.3.1-dev.
|
|
33
|
+
"@imfusion/sdk": "1.3.1-dev.10.ge5572efd",
|
|
34
34
|
"react": ">=18"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|