@aics/vole-app 3.4.4 → 3.6.0
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/es/aics-image-viewer/components/App/index.js +15 -5
- package/es/aics-image-viewer/components/ChannelsWidget.js +3 -1
- package/es/aics-image-viewer/components/ChannelsWidgetRow.js +29 -16
- package/es/aics-image-viewer/components/ColorPicker/index.js +9 -1
- package/es/aics-image-viewer/components/ControlPanel/CopySettingsButton.js +445 -0
- package/es/aics-image-viewer/components/ControlPanel/index.js +16 -5
- package/es/aics-image-viewer/components/ControlPanel/styles.css +29 -2
- package/es/aics-image-viewer/components/StyleProvider/index.js +17 -2
- package/es/aics-image-viewer/components/Toolbar/ViewModeRadioButtons.js +1 -1
- package/es/aics-image-viewer/components/Toolbar/index.js +1 -1
- package/es/aics-image-viewer/components/Toolbar/styles.css +0 -10
- package/es/aics-image-viewer/components/{CellViewerCanvasWrapper → ViewerCanvasWrapper}/index.js +3 -2
- package/es/aics-image-viewer/components/dimension_sliders/AxisClipSliders.js +21 -8
- package/es/aics-image-viewer/components/dimension_sliders/RotationSliders.js +6 -8
- package/es/aics-image-viewer/components/dimension_sliders/SliderRows.js +8 -6
- package/es/aics-image-viewer/components/shared/ContextualAlert.js +101 -0
- package/es/aics-image-viewer/components/shared/ControlPanelRow/index.js +4 -2
- package/es/aics-image-viewer/components/shared/ControlPanelRow/styles.css +4 -3
- package/es/aics-image-viewer/components/useVolume.js +59 -25
- package/es/aics-image-viewer/shared/constants.js +25 -1
- package/es/aics-image-viewer/shared/types.js +1 -1
- package/es/aics-image-viewer/shared/utils/controlPointsToLut.js +4 -0
- package/es/aics-image-viewer/shared/utils/parseSnapshot.js +205 -0
- package/es/aics-image-viewer/shared/utils/{urlParsing.js → parseUrl.js} +55 -191
- package/es/aics-image-viewer/shared/utils/permissions.js +46 -0
- package/es/aics-image-viewer/shared/utils/test/camera.test.js +1 -2
- package/es/aics-image-viewer/shared/utils/test/{urlParsing.test.js → parseUrl.test.js} +28 -25
- package/es/aics-image-viewer/shared/utils/test/storage.test.js +2 -2
- package/es/aics-image-viewer/shared/utils/test/viewerChannelSettings.test.js +1 -1
- package/es/aics-image-viewer/state/deserialize.js +443 -331
- package/es/aics-image-viewer/state/reset.js +1 -1
- package/es/aics-image-viewer/state/serialize.js +168 -78
- package/es/aics-image-viewer/state/subscribers.js +1 -1
- package/es/aics-image-viewer/state/test/deserialize.test.js +63 -77
- package/es/aics-image-viewer/state/test/reset.test.js +2 -2
- package/es/aics-image-viewer/state/test/serialize.test.js +42 -43
- package/es/aics-image-viewer/state/test/test_data.js +119 -1
- package/es/aics-image-viewer/state/types.js +157 -245
- package/es/aics-image-viewer/state/util.js +39 -1
- package/es/index.js +4 -2
- package/package.json +26 -44
- package/type-declarations/aics-image-viewer/components/App/types.d.ts +3 -3
- package/type-declarations/aics-image-viewer/components/ChannelsWidget.d.ts +3 -0
- package/type-declarations/aics-image-viewer/components/ChannelsWidgetRow.d.ts +3 -0
- package/type-declarations/aics-image-viewer/components/ControlPanel/CopySettingsButton.d.ts +11 -0
- package/type-declarations/aics-image-viewer/components/Toolbar/ViewModeRadioButtons.d.ts +1 -1
- package/type-declarations/aics-image-viewer/components/{CellViewerCanvasWrapper → ViewerCanvasWrapper}/index.d.ts +4 -3
- package/type-declarations/aics-image-viewer/components/dimension_sliders/AxisClipSliders.d.ts +7 -6
- package/type-declarations/aics-image-viewer/components/dimension_sliders/SliderRows.d.ts +1 -2
- package/type-declarations/aics-image-viewer/components/shared/ContextualAlert.d.ts +29 -0
- package/type-declarations/aics-image-viewer/components/shared/ControlPanelRow/index.d.ts +1 -0
- package/type-declarations/aics-image-viewer/components/useVolume.d.ts +3 -0
- package/type-declarations/aics-image-viewer/shared/constants.d.ts +2 -2
- package/type-declarations/aics-image-viewer/shared/types.d.ts +2 -2
- package/type-declarations/aics-image-viewer/shared/utils/controlPointsToLut.d.ts +1 -1
- package/type-declarations/aics-image-viewer/shared/utils/parseSnapshot.d.ts +49 -0
- package/type-declarations/aics-image-viewer/shared/utils/{urlParsing.d.ts → parseUrl.d.ts} +3 -24
- package/type-declarations/aics-image-viewer/shared/utils/permissions.d.ts +7 -0
- package/type-declarations/aics-image-viewer/shared/utils/viewerChannelSettings.d.ts +1 -1
- package/type-declarations/aics-image-viewer/state/deserialize.d.ts +70 -35
- package/type-declarations/aics-image-viewer/state/reset.d.ts +1 -1
- package/type-declarations/aics-image-viewer/state/serialize.d.ts +44 -10
- package/type-declarations/aics-image-viewer/state/types.d.ts +265 -159
- package/type-declarations/aics-image-viewer/state/util.d.ts +3 -1
- package/type-declarations/index.d.ts +5 -3
- package/es/Globals.d.js +0 -0
- package/es/aics-image-viewer/shared/enums.js +0 -18
- package/es/aics-image-viewer/shared/utils/firebase/index.js +0 -109
- package/type-declarations/aics-image-viewer/shared/enums.d.ts +0 -15
- package/type-declarations/aics-image-viewer/shared/utils/firebase/index.d.ts +0 -69
- package/type-declarations/aics-image-viewer/shared/utils/math.d.ts +0 -1
- /package/es/aics-image-viewer/components/{CellViewerCanvasWrapper → ViewerCanvasWrapper}/styles.css +0 -0
|
@@ -26,11 +26,11 @@ export interface AppProps {
|
|
|
26
26
|
parentImageUrl?: string | MultisceneUrls;
|
|
27
27
|
viewerChannelSettings?: ViewerChannelSettings;
|
|
28
28
|
appHeight: string;
|
|
29
|
-
cellId
|
|
29
|
+
cellId?: string;
|
|
30
30
|
visibleControls?: Partial<ControlVisibilityFlags>;
|
|
31
31
|
viewerSettings?: Partial<ViewerState>;
|
|
32
|
-
imageDownloadHref
|
|
33
|
-
parentImageDownloadHref
|
|
32
|
+
imageDownloadHref?: string;
|
|
33
|
+
parentImageDownloadHref?: string;
|
|
34
34
|
pixelSize?: [number, number, number];
|
|
35
35
|
canvasMargin: string;
|
|
36
36
|
transform?: {
|
|
@@ -7,6 +7,9 @@ export type ChannelsWidgetProps = {
|
|
|
7
7
|
channelDataChannels: Channel[] | undefined;
|
|
8
8
|
channelGroupedByType: ChannelGrouping;
|
|
9
9
|
viewerChannelSettings?: ViewerChannelSettings;
|
|
10
|
+
scrollContainer?: HTMLElement | null;
|
|
11
|
+
getDropdownContainer?: () => HTMLElement;
|
|
12
|
+
controlPanelCollapsed?: boolean;
|
|
10
13
|
saveIsosurface: (channelIndex: number, type: IsosurfaceFormat) => void;
|
|
11
14
|
onApplyColorPresets: (presets: ColorArray[]) => void;
|
|
12
15
|
filterFunc?: (key: string) => boolean;
|
|
@@ -8,6 +8,9 @@ interface ChannelsWidgetRowProps {
|
|
|
8
8
|
channelDataForChannel: Channel;
|
|
9
9
|
saveIsosurface: (channelIndex: number, type: IsosurfaceFormat) => void;
|
|
10
10
|
onColorChangeComplete?: (newRGB: ColorObject, oldRGB?: ColorObject, index?: number) => void;
|
|
11
|
+
getDropdownContainer?: () => HTMLElement;
|
|
12
|
+
scrollContainer?: HTMLElement | null;
|
|
13
|
+
controlPanelCollapsed?: boolean;
|
|
11
14
|
}
|
|
12
15
|
declare const ChannelsWidgetRow: React.FC<ChannelsWidgetRowProps>;
|
|
13
16
|
export default ChannelsWidgetRow;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type CopySettingsButtonProps = {
|
|
3
|
+
imageName?: string;
|
|
4
|
+
scrollContainer?: HTMLElement | null;
|
|
5
|
+
hide?: boolean;
|
|
6
|
+
getDropdownContainer?: () => HTMLElement;
|
|
7
|
+
hideImportExport?: boolean;
|
|
8
|
+
channelIndex?: number;
|
|
9
|
+
};
|
|
10
|
+
declare const CopySettingsButton: React.FC<CopySettingsButtonProps>;
|
|
11
|
+
export default CopySettingsButton;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { View3d, Volume } from "@aics/vole-core";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import type { AxisName,
|
|
3
|
+
import type { AxisName, XYZ } from "../../shared/types";
|
|
4
4
|
import type PlayControls from "../../shared/utils/playControls";
|
|
5
5
|
import "./styles.css";
|
|
6
6
|
type ViewerWrapperProps = {
|
|
@@ -8,10 +8,11 @@ type ViewerWrapperProps = {
|
|
|
8
8
|
loadingImage: boolean;
|
|
9
9
|
appHeight: string;
|
|
10
10
|
image: Volume | null;
|
|
11
|
-
numSlices:
|
|
12
|
-
numSlicesLoaded:
|
|
11
|
+
numSlices: XYZ<number>;
|
|
12
|
+
numSlicesLoaded: XYZ<number>;
|
|
13
13
|
playControls: PlayControls;
|
|
14
14
|
playingAxis: AxisName | "t" | null;
|
|
15
|
+
setScrubbingAxis: (axis: AxisName | "t" | null) => void;
|
|
15
16
|
numTimesteps: number;
|
|
16
17
|
numScenes: number;
|
|
17
18
|
visibleControls: {
|
package/type-declarations/aics-image-viewer/components/dimension_sliders/AxisClipSliders.d.ts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import type { Volume } from "@aics/vole-core";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import type
|
|
4
|
-
import { type AxisName, type PerAxis } from "../../shared/types";
|
|
3
|
+
import { type AxisName, type XYZ } from "../../shared/types";
|
|
5
4
|
import type PlayControls from "../../shared/utils/playControls";
|
|
6
5
|
import type { ViewerStateActions } from "../../state/store";
|
|
6
|
+
import type { ViewMode } from "../../state/types";
|
|
7
7
|
type AxisClipSlidersProps = {
|
|
8
8
|
mode: ViewMode;
|
|
9
9
|
image: Volume | null;
|
|
10
10
|
changeViewerSetting: ViewerStateActions["changeViewerSetting"];
|
|
11
|
-
numSlices:
|
|
12
|
-
numSlicesLoaded:
|
|
11
|
+
numSlices: XYZ<number>;
|
|
12
|
+
numSlicesLoaded: XYZ<number>;
|
|
13
13
|
numScenes: number;
|
|
14
|
-
region:
|
|
15
|
-
slices:
|
|
14
|
+
region: XYZ<[number, number]>;
|
|
15
|
+
slices: XYZ<number>;
|
|
16
16
|
numTimesteps: number;
|
|
17
17
|
time: number;
|
|
18
18
|
scene: number;
|
|
19
19
|
playingAxis: AxisName | "t" | null;
|
|
20
20
|
playControls: PlayControls;
|
|
21
|
+
setScrubbingAxis: (axis: AxisName | "t" | null) => void;
|
|
21
22
|
};
|
|
22
23
|
export declare const AxisClipSliders: React.FC<AxisClipSlidersProps>;
|
|
23
24
|
export {};
|
|
@@ -17,9 +17,8 @@ type DimensionSliderRowProps = SharedSliderRowProps<number[]> & {
|
|
|
17
17
|
unitSymbol?: string;
|
|
18
18
|
};
|
|
19
19
|
type IndexSliderRowProps = Omit<SharedSliderRowProps, "min">;
|
|
20
|
-
type PlaySliderRowProps = Omit<SharedSliderRowProps, "valReadout" | "min"
|
|
20
|
+
type PlaySliderRowProps = Omit<SharedSliderRowProps, "valReadout" | "min"> & {
|
|
21
21
|
playing: boolean;
|
|
22
|
-
updateWhileSliding?: boolean;
|
|
23
22
|
onTogglePlayback: (play: boolean) => void;
|
|
24
23
|
};
|
|
25
24
|
/** A single slider row, with a slider, one or two spinbox inputs, and a max value. */
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type AlertProps } from "antd";
|
|
2
|
+
import React from "react";
|
|
3
|
+
type AlertType = AlertProps["type"];
|
|
4
|
+
type AlertContext = {
|
|
5
|
+
scrollContainer?: HTMLElement | null;
|
|
6
|
+
hide?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type ContextualAlertProps = AlertProps & AlertContext & {
|
|
9
|
+
target: HTMLElement | null;
|
|
10
|
+
};
|
|
11
|
+
export type ContextualAlertOptions = AlertContext & {
|
|
12
|
+
timeout?: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Antd's `Alert`, but positioned immediately under a `target` element to provide contextual information.
|
|
16
|
+
*
|
|
17
|
+
* This is relatively specialized to the use case of attaching to components inside the control panel. Since the
|
|
18
|
+
* control panel can be vertically scrolled and hidden, it has specific props for responding to both.
|
|
19
|
+
*/
|
|
20
|
+
export declare const ContextualAlert: React.FC<ContextualAlertProps>;
|
|
21
|
+
/**
|
|
22
|
+
* Creates an `antd` `Alert` element that stays positioned beneath the `target` element, and a function to show
|
|
23
|
+
* time-limited messages in the `Alert`.
|
|
24
|
+
*
|
|
25
|
+
* This is relatively specialized to the use case of attaching to components inside the control panel. Since the
|
|
26
|
+
* control panel can be vertically scrolled and hidden, it has specific props for responding to both.
|
|
27
|
+
*/
|
|
28
|
+
export declare const useContextualAlert: (target: HTMLElement | null, options: ContextualAlertOptions) => [React.ReactNode, (message: React.ReactNode, messageType?: AlertType) => void];
|
|
29
|
+
export {};
|
|
@@ -6,6 +6,7 @@ export type ControlPanelRowProps = React.PropsWithChildren<ColorPickerPropPassth
|
|
|
6
6
|
verticalMargin?: number;
|
|
7
7
|
showColorPicker?: boolean;
|
|
8
8
|
title?: React.ReactNode;
|
|
9
|
+
icon?: React.ReactNode;
|
|
9
10
|
onClick?: React.MouseEventHandler;
|
|
10
11
|
className?: string;
|
|
11
12
|
highlight?: boolean;
|
|
@@ -12,6 +12,8 @@ export type UseVolumeOptions = {
|
|
|
12
12
|
onChannelLoaded?: (image: Volume, channelIndex: number, isInitialLoad: boolean) => void;
|
|
13
13
|
/** Callback for when image loading encounters an error. */
|
|
14
14
|
onError?: (error: unknown, image?: Volume) => void;
|
|
15
|
+
/** Callback for when scrubbing starts or stops, including the state info needed */
|
|
16
|
+
onScrub?: (isScrubbing: boolean, image: Volume) => void;
|
|
15
17
|
/** The name of a channel which should be treated as a mask rather than as viewable data. */
|
|
16
18
|
maskChannelName?: string;
|
|
17
19
|
};
|
|
@@ -36,6 +38,7 @@ export type ReactiveVolume = {
|
|
|
36
38
|
imageLoadStatus: ImageLoadStatus;
|
|
37
39
|
setTime: (view3d: View3d, time: number) => void;
|
|
38
40
|
setScene: (scene: number) => void;
|
|
41
|
+
setScrubbingAxis: (axis: AxisName | "t" | null) => void;
|
|
39
42
|
playControls: PlayControls;
|
|
40
43
|
playingAxis: AxisName | "t" | null;
|
|
41
44
|
channelGroupedByType: ChannelGrouping;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type CameraState, type Channel, PrefetchDirection } from "@aics/vole-core";
|
|
2
|
-
import type
|
|
3
|
-
import { ViewMode } from "./enums";
|
|
2
|
+
import { type ChannelState, type ViewerState, ViewMode } from "../state/types";
|
|
4
3
|
import type { AxisName } from "./types";
|
|
5
4
|
import type { ColorArray } from "./utils/colorRepresentations";
|
|
6
5
|
import type { ViewerChannelSettings } from "./utils/viewerChannelSettings";
|
|
6
|
+
export declare const VOLEAPP_VERSION: string;
|
|
7
7
|
export declare const // Control panel will automatically close if viewport is less than this width
|
|
8
8
|
CONTROL_PANEL_CLOSE_WIDTH = 970, CLIPPING_PANEL_HEIGHT_DEFAULT = 200, CLIPPING_PANEL_HEIGHT_TALL = 235, BACKGROUND_COLOR_DEFAULT: ColorArray, BOUNDING_BOX_COLOR_DEFAULT: ColorArray, AXIS_MARGIN_DEFAULT: [number, number], SCALE_BAR_MARGIN_DEFAULT: [number, number], LUT_MIN_PERCENTILE = 0.5, LUT_MAX_PERCENTILE = 0.983, ALPHA_MASK_SLIDER_DEFAULT = 0, BRIGHTNESS_SLIDER_LEVEL_DEFAULT = 70, DENSITY_SLIDER_LEVEL_DEFAULT = 50, LEVELS_SLIDER_DEFAULT: ColorArray, INTERPOLATION_ENABLED_DEFAULT = true, OTHER_CHANNEL_KEY = "Other", SINGLE_GROUP_CHANNEL_KEY = "Channels", SINGLE_CHANNEL_MODE_COLOR: ColorArray;
|
|
9
9
|
export declare const TFEDITOR_DEFAULT_COLOR: ColorArray;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CSSProperties } from "react";
|
|
2
|
-
import { ViewMode } from "
|
|
2
|
+
import { ViewMode } from "../state/types";
|
|
3
3
|
export type AxisName = "x" | "y" | "z";
|
|
4
|
-
export type
|
|
4
|
+
export type XYZ<T> = Record<AxisName, T>;
|
|
5
5
|
export declare const activeAxisMap: {
|
|
6
6
|
[A in ViewMode]: AxisName | null;
|
|
7
7
|
};
|
|
@@ -35,7 +35,7 @@ export declare function getDefaultLut(histogram: Histogram): Lut;
|
|
|
35
35
|
* "autoij:0" // use Auto-IJ to calculate min and max.
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
|
-
export declare function parseLutSetting(histogram: Histogram, lutSetting: [string, string] | undefined): Lut | undefined;
|
|
38
|
+
export declare function parseLutSetting(histogram: Histogram, lutSetting: [string | number, string | number] | undefined): Lut | undefined;
|
|
39
39
|
/**
|
|
40
40
|
* Initializes the lookup table (LUT) that maps from volume intensity values to color + opacity and applies the LUT to the volume.
|
|
41
41
|
*
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { MultisceneUrls } from "../../components/App/types";
|
|
2
|
+
import type { ChannelState, ChannelStateSnapshot, ViewerStateSnapshot } from "../../state/types";
|
|
3
|
+
import type { MetadataRecord } from "../types";
|
|
4
|
+
import type { ViewerChannelSettings } from "./viewerChannelSettings";
|
|
5
|
+
/**
|
|
6
|
+
* A message sent from an external application after this app was opened,
|
|
7
|
+
* containing data that was too large to pack into the URL.
|
|
8
|
+
*/
|
|
9
|
+
export type ViewerMessage = {
|
|
10
|
+
/** A (possibly very long) list of scene URLs. */
|
|
11
|
+
scenes?: (string | string[])[];
|
|
12
|
+
/** A (likely very large) list of metadata records for each scene. */
|
|
13
|
+
meta?: Record<string, MetadataRecord>;
|
|
14
|
+
/** The scene to open once this message arrives. */
|
|
15
|
+
sceneIndex?: number;
|
|
16
|
+
};
|
|
17
|
+
/** A snapshot of app state, containing (optional) global and per-channel settings. */
|
|
18
|
+
export type StoreSnapshot = ViewerStateSnapshot & {
|
|
19
|
+
version: string;
|
|
20
|
+
channels: Record<string, ChannelStateSnapshot>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* A complete description of a viewer session, containing image URLs, global
|
|
24
|
+
* and per-channel settings, and optional image metadata.
|
|
25
|
+
*/
|
|
26
|
+
export type SessionSnapshot = StoreSnapshot & ViewerMessage & Required<Pick<ViewerMessage, "scenes">>;
|
|
27
|
+
/** Verifies that the given object is (likely) a `StoreSnapshot`. */
|
|
28
|
+
export declare const isStoreSnapshot: (settings: unknown) => settings is StoreSnapshot;
|
|
29
|
+
/** Verifies that the given object is (likely) a `SessionSnapshot`. */
|
|
30
|
+
export declare const isSessionSnapshot: (settings: unknown) => settings is SessionSnapshot;
|
|
31
|
+
/** Converts an array of `ChannelState`s to a compact JSON representation that can be stringified into the clipboard. */
|
|
32
|
+
export declare const channelStatesToSnapshot: (channelStates: ChannelState[], excludeKeys?: (keyof ChannelState)[]) => StoreSnapshot;
|
|
33
|
+
/** Converts a single `ChannelState` to a compact JSON representation that can be stringified into the clipboard. */
|
|
34
|
+
export declare const singleChannelStateToSnapshot: (channelState: ChannelState, excludeKeys?: (keyof ChannelState)[]) => StoreSnapshot;
|
|
35
|
+
/** Converts a compacted set of `ChannelState`s from the clipboard into a record of channel names and their states. */
|
|
36
|
+
export declare const snapshotToChannelStates: (serialized: StoreSnapshot) => Record<string, Partial<ChannelState>>;
|
|
37
|
+
export declare const snapshotToViewerChannelSettings: (serialized: StoreSnapshot) => ViewerChannelSettings | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Parses a `ViewerMessage` into the relevant entries in `AppProps`.
|
|
40
|
+
*
|
|
41
|
+
* Optionally accepts the current value of the `imageUrl` prop, for the case where the message contains only metadata
|
|
42
|
+
* and the image URLs that correspond to the metadata were passed in by other means.
|
|
43
|
+
*/
|
|
44
|
+
export declare function viewerMessageToParams(message: ViewerMessage, propUrl?: string | MultisceneUrls): {
|
|
45
|
+
imageUrl?: string | MultisceneUrls;
|
|
46
|
+
metadata?: (MetadataRecord | undefined)[];
|
|
47
|
+
};
|
|
48
|
+
/** Formats the values of the `imageUrl` and `metadata` props to `App` as a `ViewerMessage`. */
|
|
49
|
+
export declare function paramsToViewerMessage(imageUrl: string | MultisceneUrls, metadata?: (MetadataRecord | undefined)[]): ViewerMessage;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { FirebaseFirestore } from "@firebase/firestore-types";
|
|
2
1
|
import type { AppProps } from "../../components/App/types";
|
|
3
2
|
import type { ViewerStore } from "../../state/store";
|
|
4
|
-
import {
|
|
3
|
+
import type { ViewerState, ViewerStateStringified } from "../../state/types";
|
|
5
4
|
import type { MetadataRecord } from "../types";
|
|
6
5
|
/**
|
|
7
6
|
* Channels, matching the pattern `c0`, `c1`, etc. corresponding to the index of the channel being configured.
|
|
@@ -33,10 +32,6 @@ declare class DataParams {
|
|
|
33
32
|
* See `ManifestJson` for the type definition.
|
|
34
33
|
*/
|
|
35
34
|
manifest?: string;
|
|
36
|
-
/** The name of a dataset in the Cell Feature Explorer database. Used with `id`. */
|
|
37
|
-
dataset?: string;
|
|
38
|
-
/** The ID of a cell within the loaded dataset. Used with `dataset`. */
|
|
39
|
-
id?: string;
|
|
40
35
|
/** The key of a collection of scenes stored in local storage. Overrides `url`. */
|
|
41
36
|
collectionid?: string;
|
|
42
37
|
/**
|
|
@@ -60,19 +55,7 @@ declare class DeprecatedParams {
|
|
|
60
55
|
/** Deprecated query parameter for channel colors. */
|
|
61
56
|
colors?: string;
|
|
62
57
|
}
|
|
63
|
-
type AppParams = Partial<
|
|
64
|
-
/**
|
|
65
|
-
* A message sent from an external application after this app was opened,
|
|
66
|
-
* containing data that was too large to pack into the URL.
|
|
67
|
-
*/
|
|
68
|
-
type ViewerMessage = {
|
|
69
|
-
/** A (possibly very long) list of scene URLs. */
|
|
70
|
-
scenes?: string[];
|
|
71
|
-
/** A (likely very large) list of metadata records for each scene. */
|
|
72
|
-
meta?: Record<string, MetadataRecord>;
|
|
73
|
-
/** The scene to open once this message arrives. */
|
|
74
|
-
sceneIndex?: number;
|
|
75
|
-
};
|
|
58
|
+
type AppParams = Partial<ViewerStateStringified & DataParams & DeprecatedParams & ChannelParams>;
|
|
76
59
|
/**
|
|
77
60
|
* Filters a set of URLSearchParams for only the keys that are valid parameters for the viewer.
|
|
78
61
|
* Non-matching keys are discarded.
|
|
@@ -89,20 +72,16 @@ export declare function loadFromManifest(manifestUrl: string): Promise<{
|
|
|
89
72
|
/**
|
|
90
73
|
* Parses a set of URL search parameters into props for the viewer.
|
|
91
74
|
* @param search The query string to parse, which must be valid in the `URLSearchParams constructor
|
|
92
|
-
* @param firestore Optional Firestore instance. If provided, the function can load data from a
|
|
93
|
-
* Firestore dataset if the `dataset` and `id` parameters are provided.
|
|
94
75
|
* @returns An object containing:
|
|
95
76
|
* - `args`: Partial AppProps object.
|
|
96
77
|
* - `viewerSettings`: Partial ViewerState object.
|
|
97
78
|
*
|
|
98
79
|
* `args` can be passed as props to the `ImageViewerApp`, and `viewerSettings` can be passed to `ViewerStateProvider`.
|
|
99
80
|
*/
|
|
100
|
-
export declare function parseViewerUrlParams(search: string
|
|
81
|
+
export declare function parseViewerUrlParams(search: string): Promise<{
|
|
101
82
|
args: Partial<AppProps>;
|
|
102
83
|
viewerSettings: Partial<ViewerState>;
|
|
103
84
|
}>;
|
|
104
|
-
/** Adds the data in a newly-arrived `ViewerMessage` to an existing stored `AppProps` instance. */
|
|
105
|
-
export declare function addViewerParamsFromMessage<P extends Pick<AppProps, "imageUrl" | "metadata">>(args: P, message: ViewerMessage): P;
|
|
106
85
|
/**
|
|
107
86
|
* Serializes the ViewerState and ChannelState of a ViewerStateContext into a URLSearchParams object.
|
|
108
87
|
* @param state ViewerStateContext to serialize.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Try to determine whether attempting to access the clipboard will immediately fail.
|
|
3
|
+
*
|
|
4
|
+
* When this function returns `false`, accessing the clipboard *may* be successful, though some browsers require users
|
|
5
|
+
* to confirm every paste. When it returns `true`, access to the clipboard is definitely blocked.
|
|
6
|
+
*/
|
|
7
|
+
export declare const queryPasteDenied: () => Promise<boolean>;
|
|
@@ -21,7 +21,7 @@ export type IntensitySettings = {
|
|
|
21
21
|
* - `autoij` in either the min or max fields will use the "auto" algorithm
|
|
22
22
|
* from ImageJ to select the min and max.
|
|
23
23
|
*/
|
|
24
|
-
lut?: [string, string];
|
|
24
|
+
lut?: [string | number, string | number];
|
|
25
25
|
};
|
|
26
26
|
/** Settings for a single channel, as passed in via props by App users */
|
|
27
27
|
export interface ViewerChannelSetting {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Histogram } from "@aics/vole-core";
|
|
2
2
|
import type { ColorArray } from "../shared/utils/colorRepresentations";
|
|
3
3
|
import type { ViewerChannelSetting } from "../shared/utils/viewerChannelSettings";
|
|
4
|
-
import {
|
|
4
|
+
import type { CameraStateSnapshot, CameraStateStringified, ChannelState, ChannelStateSnapshot, ChannelStateStringified, ViewerState, ViewerStateSnapshot, ViewerStateStringified } from "./types";
|
|
5
5
|
/**
|
|
6
6
|
* LEGACY: Matches a COMMA-separated list of control points, where each control point is represented
|
|
7
7
|
* by a triplet of `{x}:{opacity}:{hex color}`.
|
|
@@ -19,6 +19,22 @@ export declare const LEGACY_CONTROL_POINTS_REGEX: RegExp;
|
|
|
19
19
|
* with `1` to represent white (`ffffff`).
|
|
20
20
|
*/
|
|
21
21
|
export declare const CONTROL_POINTS_REGEX: RegExp;
|
|
22
|
+
export declare const enumParser: <E extends string>(enumValues: Record<string, E>) => ((value: string) => E | undefined);
|
|
23
|
+
/**
|
|
24
|
+
* Converts a `CameraStateStringified` into a `CameraStateSnapshot` by parsing each key from its stringified
|
|
25
|
+
* representation to its type in `CameraStateSnapshot`.
|
|
26
|
+
*/
|
|
27
|
+
export declare const destringifyCameraStateSnapshot: (stringified: CameraStateStringified) => CameraStateSnapshot;
|
|
28
|
+
/**
|
|
29
|
+
* Converts a `ViewerStateStringified` into a `ViewerStateSnapshot` by parsing each key from its stringified
|
|
30
|
+
* representation to its type in `ViewerStateSnapshot`.
|
|
31
|
+
*/
|
|
32
|
+
export declare const destringifyViewerStateSnapshot: (stringified: ViewerStateStringified) => ViewerStateSnapshot;
|
|
33
|
+
/**
|
|
34
|
+
* Converts a `ChannelStateStringified` into a `ChannelStateSnapshot` by parsing each key from its stringified
|
|
35
|
+
* representation to its type in `ChannelStateSnapshot`.
|
|
36
|
+
*/
|
|
37
|
+
export declare const destringifyChannelStateSnapshot: (stringified: ChannelStateStringified) => ChannelStateSnapshot;
|
|
22
38
|
/**
|
|
23
39
|
* Parse a string list of comma-separated key:value pairs into
|
|
24
40
|
* a key-value object.
|
|
@@ -30,50 +46,68 @@ export declare const CONTROL_POINTS_REGEX: RegExp;
|
|
|
30
46
|
* will be decoded using `decodeURIComponent`.
|
|
31
47
|
*/
|
|
32
48
|
export declare function parseKeyValueList(data: string): Record<string, string>;
|
|
49
|
+
export declare function parseHexColorAsColorArray(hexColor: unknown): ColorArray | undefined;
|
|
50
|
+
/** Verifies that `value` is a `number`; if it is, clamps it between `min` and `max`. */
|
|
51
|
+
export declare const validateNumber: (value: unknown, min?: number, max?: number) => number | undefined;
|
|
52
|
+
/** Verifies that `value` is a `number`; if it is, truncates it to an integer and clamps it between `min` and `max`. */
|
|
53
|
+
export declare const validateInt: (value: unknown, min?: number, max?: number) => number | undefined;
|
|
54
|
+
type Untrusted<T> = {
|
|
55
|
+
[K in keyof T]?: unknown;
|
|
56
|
+
};
|
|
57
|
+
/** Parses a `ViewerStateSnapshot` to a `ViewerState`. */
|
|
58
|
+
export declare function snapshotToViewerState(snapshot: Untrusted<ViewerStateSnapshot>): Partial<ViewerState>;
|
|
33
59
|
/**
|
|
34
|
-
* Parses a
|
|
35
|
-
*
|
|
36
|
-
* @param
|
|
37
|
-
* @
|
|
38
|
-
* @param max Maximum value, inclusive.
|
|
39
|
-
* @returns
|
|
40
|
-
* - The parsed number, clamped to the [min, max] range.
|
|
41
|
-
* - `undefined` if the string is undefined or NaN.
|
|
60
|
+
* Parses a `ChannelStateSnapshot` to a `ViewerChannelSetting`.
|
|
61
|
+
* @param channelId Either the index or the name of the channel, to be turned into a `match` value.
|
|
62
|
+
* @param jsonState The serialized `ViewerChannelSetting` to parse, as an object.
|
|
63
|
+
* @returns A `ViewerChannelSetting` object.
|
|
42
64
|
*/
|
|
43
|
-
export declare function
|
|
65
|
+
export declare function snapshotToViewerChannelSetting(channelId: number | string, jsonState: Untrusted<ChannelStateSnapshot>): ViewerChannelSetting;
|
|
44
66
|
/**
|
|
45
|
-
* Parses a
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
67
|
+
* Parses a `ChannelStateSnapshot` object into a partial `ChannelState`.
|
|
68
|
+
*
|
|
69
|
+
* This is used to convert from serialized formats (URL params, JSON) into
|
|
70
|
+
* internal channel state fields, leaving absent or invalid values undefined.
|
|
71
|
+
*
|
|
72
|
+
* This function optionally accepts the target channel's `Histogram`. This
|
|
73
|
+
* argument is required to parse the following params correctly:
|
|
74
|
+
*
|
|
75
|
+
* - `lut`, which contains instructions for how to set the channel's
|
|
76
|
+
* intensities *relative to its intensity distribution*.
|
|
77
|
+
* - `rmp`, the legacy ramp parameter represented as histogram bin indices
|
|
78
|
+
* - `cps`, the legacy control points parameter where `x` values are
|
|
79
|
+
* represented as histogram bin indices
|
|
80
|
+
*
|
|
81
|
+
* If `histogram` is left undefined, e.g. because the channel has not yet been
|
|
82
|
+
* loaded, these params are ignored.
|
|
52
83
|
*/
|
|
53
|
-
export declare function
|
|
84
|
+
export declare function snapshotToChannelState(jsonState: Untrusted<ChannelStateSnapshot>, histogram?: Histogram): Partial<ChannelState>;
|
|
54
85
|
/**
|
|
55
|
-
* Parses a
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* if the `defaultValue` is `undefined`.
|
|
86
|
+
* Parses a stringified viewer state snapshot (`ViewerStateStringified`) to a
|
|
87
|
+
* `ViewerState`.
|
|
88
|
+
*
|
|
89
|
+
* This is equivalent to (and implemented by) calling
|
|
90
|
+
* `destringifyViewerStateSnapshot`, then `snapshotToViewerState`.
|
|
61
91
|
*/
|
|
62
|
-
export declare
|
|
63
|
-
export declare function parseHexColorAsColorArray(hexColor: string | undefined): ColorArray | undefined;
|
|
64
|
-
export declare function deserializeViewerState(params: ViewerStateParams): Partial<ViewerState>;
|
|
92
|
+
export declare const stringSnapshotToViewerState: (stringified: ViewerStateStringified) => Partial<ViewerState>;
|
|
65
93
|
/**
|
|
66
|
-
* Parses a
|
|
94
|
+
* Parses a stringified channel state snapshot (`ChannelStateStringified`) to a
|
|
95
|
+
* `ViewerChannelSetting`.
|
|
96
|
+
*
|
|
97
|
+
* This is equivalent to (and implemented by) calling
|
|
98
|
+
* `destringifyChannelStateSnapshot`, then `snapshotToViewerChannelSetting`.
|
|
99
|
+
*
|
|
67
100
|
* @param channelIndex Index of the channel, to be turned into a `match` value.
|
|
68
|
-
* @param jsonState The serialized ViewerChannelSetting to parse, as an object.
|
|
69
|
-
* @returns A ViewerChannelSetting object.
|
|
101
|
+
* @param jsonState The serialized `ViewerChannelSetting` to parse, as an object.
|
|
102
|
+
* @returns A `ViewerChannelSetting` object.
|
|
70
103
|
*/
|
|
71
|
-
export declare
|
|
104
|
+
export declare const stringSnapshotToViewerChannelSetting: (channelIndex: number, jsonState: ChannelStateStringified) => ViewerChannelSetting;
|
|
72
105
|
/**
|
|
73
|
-
* Parses a
|
|
106
|
+
* Parses a stringified channel state snapshot (`ChannelStateStringified`)
|
|
107
|
+
* into a partial `ChannelState`.
|
|
74
108
|
*
|
|
75
|
-
* This is
|
|
76
|
-
*
|
|
109
|
+
* This is equivalent to (and implemented by) calling
|
|
110
|
+
* `destringifyChannelStateSnapshot`, then `snapshotToChannelState`.
|
|
77
111
|
*
|
|
78
112
|
* This function optionally accepts the target channel's `Histogram`. This
|
|
79
113
|
* argument is required to parse the following params correctly:
|
|
@@ -87,4 +121,5 @@ export declare function deserializeViewerChannelSetting(channelIndex: number, js
|
|
|
87
121
|
* If `histogram` is left undefined, e.g. because the channel has not yet been
|
|
88
122
|
* loaded, these params are ignored.
|
|
89
123
|
*/
|
|
90
|
-
export declare
|
|
124
|
+
export declare const stringSnapshotToChannelState: (jsonState: ChannelStateStringified, histogram?: Histogram) => Partial<ChannelState>;
|
|
125
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { StateCreator } from "zustand";
|
|
2
2
|
import type { ViewerChannelSettings } from "../shared/utils/viewerChannelSettings";
|
|
3
|
-
import type { ViewerState } from "../state/types";
|
|
4
3
|
import type { ViewerStore } from "./store";
|
|
4
|
+
import { type ViewerState } from "./types";
|
|
5
5
|
export type ResetStateActions = {
|
|
6
6
|
/**
|
|
7
7
|
* Removes the channel from the list of channels to be reset (as given by
|
|
@@ -1,20 +1,54 @@
|
|
|
1
1
|
import type { CameraState } from "@aics/vole-core";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import type { CameraStateSnapshot, CameraStateStringified, ChannelState, ChannelStateSnapshot, ChannelStateStringified, ViewerState, ViewerStateSnapshot, ViewerStateStringified } from "./types";
|
|
3
|
+
import { ViewMode } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Serializes an object with `string` keys to a compact `string` representation, where keys and values are separated
|
|
6
|
+
* by colons (`:`) and entries are separated by commas (`,`).
|
|
7
|
+
*/
|
|
4
8
|
export declare function objectToKeyValueList(obj: Record<string, string | undefined>): string;
|
|
5
|
-
export declare function serializeCameraState(cameraState: Partial<CameraState>, removeDefaults: boolean, viewMode?: ViewMode): string | undefined;
|
|
6
9
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
10
|
+
* Converts a `CameraState` to a `CameraStateSnapshot`, suitable for serialization.
|
|
11
|
+
* @param cameraState The camera state to serialize.
|
|
12
|
+
* @param removeDefaults Whether to remove default values.
|
|
13
|
+
* @param viewMode The current view mode. Default `ViewMode.threeD`.
|
|
14
|
+
* @returns The resulting `CameraStateSnapshot`, or `undefined` if all values are default.
|
|
15
|
+
*/
|
|
16
|
+
export declare function cameraStateToSnapshot(cameraState: Partial<CameraState> | undefined, removeDefaults: boolean, viewMode?: ViewMode): CameraStateSnapshot | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Converts a `ViewerState` to a `ViewerStateSnapshot`, suitable for serialization.
|
|
19
|
+
*/
|
|
20
|
+
export declare function viewerStateToSnapshot(state: Partial<ViewerState>, removeDefaults: boolean): ViewerStateSnapshot;
|
|
21
|
+
export declare function channelStateToSnapshot(state: Partial<ChannelState>, removeDefaults: boolean): ChannelStateSnapshot;
|
|
22
|
+
/**
|
|
23
|
+
* Converts all keys of a `CameraStateSnapshot` to compact `string` representations,
|
|
24
|
+
* for serialization to `string` formats.
|
|
25
|
+
*/
|
|
26
|
+
export declare const stringifyCameraStateSnapshot: (snapshot: CameraStateSnapshot) => CameraStateStringified;
|
|
27
|
+
/**
|
|
28
|
+
* Converts all keys of a `ViewerStateSnapshot` to compact `string` representations,
|
|
29
|
+
* for serialization to `string` formats.
|
|
30
|
+
*/
|
|
31
|
+
export declare const stringifyViewerStateSnapshot: (snapshot: ViewerStateSnapshot) => ViewerStateStringified;
|
|
32
|
+
/**
|
|
33
|
+
* Converts all keys of a `ChannelStateSnapshot` to compact `string` representations,
|
|
34
|
+
* for serialization to `string` formats.
|
|
35
|
+
*/
|
|
36
|
+
export declare const stringifyChannelStateSnapshot: (snapshot: ChannelStateSnapshot) => ChannelStateStringified;
|
|
37
|
+
/**
|
|
38
|
+
* Converts a single viewer channel setting into a `ChannelStateStringified`.
|
|
39
|
+
*
|
|
40
|
+
* This is equivalent to (and implemented by) applying `channelStateToSnapshot`, then `stringifyChannelStateSnapshot`.
|
|
9
41
|
* @param channelSetting The channel state object to serialize.
|
|
10
42
|
* @param removeDefaults Whether to remove properties that match the output of `getDefaultChannelState`.
|
|
11
|
-
* @returns A `
|
|
43
|
+
* @returns A `ChannelStateStringified` object with the serialized parameters. `undefined` values are removed.
|
|
12
44
|
*/
|
|
13
|
-
export declare
|
|
45
|
+
export declare const channelStateToStringSnapshot: (channelSetting: Partial<ChannelState>, removeDefaults: boolean) => ChannelStateStringified;
|
|
14
46
|
/**
|
|
15
|
-
* Serializes a `ViewerState` object into a
|
|
47
|
+
* Serializes a `ViewerState` object into a `ViewerStateStringified`.
|
|
48
|
+
*
|
|
49
|
+
* This is equivalent to (and implemented by) applying `viewerStateToSnapshot`, then `stringifyViewerStateSnapshot`.
|
|
16
50
|
* @param state The `ViewerState` to serialize.
|
|
17
51
|
* @param removeDefaults If true, remove properties that match the output of `getDefaultViewerState`.
|
|
18
|
-
* @returns A `
|
|
52
|
+
* @returns A `ViewerStateStringified` object with the serialized parameters. `undefined` values are removed.
|
|
19
53
|
*/
|
|
20
|
-
export declare
|
|
54
|
+
export declare const viewerStateToStringSnapshot: (state: Partial<ViewerState>, removeDefaults: boolean) => ViewerStateStringified;
|