diff --git a/src/NiivueCanvas.tsx b/src/NiivueCanvas.tsx index ed72ec0..7d4b82f 100644 --- a/src/NiivueCanvas.tsx +++ b/src/NiivueCanvas.tsx @@ -139,7 +139,7 @@ const NiivueCanvas: React.FC = ({ setup().then(() => setReady(true)); }, []); - return (); + return ; }; export type { NiivueCanvasProps }; diff --git a/src/model.ts b/src/model.ts index e9edff9..efe17ef 100644 --- a/src/model.ts +++ b/src/model.ts @@ -1,4 +1,5 @@ import { NiiVueOptions } from "./reexport.ts"; +import { Niivue, NVImage, NVMeshFromUrlOptions } from "@niivue/niivue"; type HasUrlObject = { [key: string]: any; url: string }; @@ -21,22 +22,10 @@ type NVRMeshLayer = { /** * A mesh (e.g. white-matter surface) in Niivue. */ -type NVRMesh = { - url: string; - name?: string; - opacity?: number; - visible?: boolean; - rgba255?: number[]; - /** - * Map keys must be some kind of unique ID. For example, given `NVRMeshLayer[]`: - * - * ```typescript - * (layers: NVRMeshLayer[]) => Object.fromEntries(layers.map((layer) => [layer.url, layer])) - * ``` - */ - layers?: { [key: string]: NVRMeshLayer }; - colorbarVisible?: boolean; -}; +type NVRMesh = { url: string } & Pick< + NVMeshFromUrlOptions, + "name" | "opacity" | "visible" | "rgba255" | "colorbarVisible" +>; /** * Options of a volume which are directly compatible with `ImageFromUrlOptions` and `NVImage`, meaning: @@ -44,23 +33,22 @@ type NVRMesh = { * - properties are supported by `Niivue.loadVolumes` * - properties can be changed by mutating `nv.volumes[*].*` */ -type LoadableVolumeOptions = { - opacity?: number; - colormap?: string; - colormapNegative?: string; - cal_min?: number; - cal_max?: number; - trustCalMinMax?: boolean; - visible?: boolean; - colorbarVisible?: boolean; -}; +type LoadableVolumeOptions = Pick< + NVImage, + | "opacity" + | "colormap" + | "colormapNegative" + | "cal_min" + | "cal_max" + | "trustCalMinMax" + | "visible" + | "colorbarVisible" +>; /** * Options of a volume which are directly compatible with `NVImage`. */ -type ImageOptions = LoadableVolumeOptions & { - modulateAlpha?: number; -}; +type ImageOptions = LoadableVolumeOptions & Pick; /** * Special options of a volume which are supported handled differently in `niivue-react` and Niivue, diff --git a/src/reexport.ts b/src/reexport.ts index be6d896..61e9dda 100644 --- a/src/reexport.ts +++ b/src/reexport.ts @@ -2,7 +2,7 @@ * Type definitions copy-pasted from `niivue` since they are not public. */ -import {DRAG_MODE, SLICE_TYPE} from "@niivue/niivue"; +import { DRAG_MODE, SLICE_TYPE } from "@niivue/niivue"; /** * Niivue options. @@ -99,7 +99,7 @@ type NiiVueOptions = { thumbnail?: string; // from NVConfigOptions - sliceType?: SLICE_TYPE + sliceType?: SLICE_TYPE; }; export type { NiiVueOptions }; diff --git a/src/setters.ts b/src/setters.ts index acd459e..3f49a28 100644 --- a/src/setters.ts +++ b/src/setters.ts @@ -16,7 +16,7 @@ function optionUpdateFunctionMap(nv: Niivue): OptionUpdateFunctionMap { crosshairWidth: nv.setCrosshairWidth, crosshairColor: nv.setCrosshairColor, sliceType: nv.setSliceType, - isSliceMM: nv.setSliceMM + isSliceMM: nv.setSliceMM, }; return bindAllValues(nv, mapping); }