@aics/vole-app 3.3.0 → 3.4.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.
Files changed (60) hide show
  1. package/LICENSE +21 -25
  2. package/es/aics-image-viewer/components/App/index.js +11 -9
  3. package/es/aics-image-viewer/components/BottomPanel/index.js +48 -19
  4. package/es/aics-image-viewer/components/BottomPanel/styles.css +16 -7
  5. package/es/aics-image-viewer/components/CellViewerCanvasWrapper/index.js +39 -19
  6. package/es/aics-image-viewer/components/ChannelsWidget.js +2 -2
  7. package/es/aics-image-viewer/components/ControlPanel/index.js +17 -11
  8. package/es/aics-image-viewer/components/ControlPanel/styles.css +5 -5
  9. package/es/aics-image-viewer/components/ErrorAlert/index.js +91 -64
  10. package/es/aics-image-viewer/components/ErrorAlert/styles.css +33 -4
  11. package/es/aics-image-viewer/components/StyleProvider/index.js +42 -22
  12. package/es/aics-image-viewer/components/TfEditor/index.js +8 -1
  13. package/es/aics-image-viewer/components/Toolbar/index.js +33 -12
  14. package/es/aics-image-viewer/components/Toolbar/styles.css +21 -130
  15. package/es/aics-image-viewer/components/dimension_sliders/AxisClipSliders.js +148 -0
  16. package/es/aics-image-viewer/components/dimension_sliders/RotationSliders.js +165 -0
  17. package/es/aics-image-viewer/components/dimension_sliders/SliderRows.js +167 -0
  18. package/es/aics-image-viewer/components/{AxisClipSliders → dimension_sliders}/styles.css +7 -1
  19. package/es/aics-image-viewer/components/shared/ControlPanelRow/styles.css +1 -1
  20. package/es/aics-image-viewer/components/shared/NumericInput/index.js +4 -2
  21. package/es/aics-image-viewer/components/shared/SliderRow/index.js +2 -0
  22. package/es/aics-image-viewer/components/shared/SliderRow/styles.css +2 -1
  23. package/es/aics-image-viewer/components/useVolume.js +3 -0
  24. package/es/aics-image-viewer/shared/constants.js +2 -2
  25. package/es/aics-image-viewer/shared/utils/camera.js +122 -0
  26. package/es/aics-image-viewer/shared/utils/playControls.js +12 -1
  27. package/es/aics-image-viewer/shared/utils/sceneStore.js +8 -0
  28. package/es/aics-image-viewer/shared/utils/test/camera.test.js +127 -0
  29. package/es/aics-image-viewer/shared/utils/test/urlParsing.test.js +23 -702
  30. package/es/aics-image-viewer/shared/utils/urlParsing.js +14 -828
  31. package/es/aics-image-viewer/shared/utils/viewerChannelSettings.js +3 -4
  32. package/es/aics-image-viewer/state/deserialize.js +437 -0
  33. package/es/aics-image-viewer/state/serialize.js +145 -0
  34. package/es/aics-image-viewer/state/test/deserialize.test.js +432 -0
  35. package/es/aics-image-viewer/state/test/serialize.test.js +97 -0
  36. package/es/aics-image-viewer/state/test/test_data.js +168 -0
  37. package/es/aics-image-viewer/state/types.js +265 -1
  38. package/package.json +6 -5
  39. package/type-declarations/aics-image-viewer/components/App/types.d.ts +2 -2
  40. package/type-declarations/aics-image-viewer/components/BottomPanel/index.d.ts +6 -3
  41. package/type-declarations/aics-image-viewer/components/CellViewerCanvasWrapper/index.d.ts +1 -0
  42. package/type-declarations/aics-image-viewer/components/ControlPanel/index.d.ts +4 -5
  43. package/type-declarations/aics-image-viewer/components/ErrorAlert/index.d.ts +8 -5
  44. package/type-declarations/aics-image-viewer/components/Toolbar/index.d.ts +2 -1
  45. package/type-declarations/aics-image-viewer/components/{AxisClipSliders/index.d.ts → dimension_sliders/AxisClipSliders.d.ts} +2 -3
  46. package/type-declarations/aics-image-viewer/components/dimension_sliders/RotationSliders.d.ts +6 -0
  47. package/type-declarations/aics-image-viewer/components/dimension_sliders/SliderRows.d.ts +31 -0
  48. package/type-declarations/aics-image-viewer/components/shared/NumericInput/index.d.ts +1 -0
  49. package/type-declarations/aics-image-viewer/components/shared/SliderRow/index.d.ts +3 -1
  50. package/type-declarations/aics-image-viewer/components/useVolume.d.ts +1 -1
  51. package/type-declarations/aics-image-viewer/shared/constants.d.ts +1 -1
  52. package/type-declarations/aics-image-viewer/shared/utils/camera.d.ts +19 -0
  53. package/type-declarations/aics-image-viewer/shared/utils/playControls.d.ts +1 -0
  54. package/type-declarations/aics-image-viewer/shared/utils/sceneStore.d.ts +2 -1
  55. package/type-declarations/aics-image-viewer/shared/utils/urlParsing.d.ts +1 -307
  56. package/type-declarations/aics-image-viewer/state/deserialize.d.ts +70 -0
  57. package/type-declarations/aics-image-viewer/state/serialize.d.ts +20 -0
  58. package/type-declarations/aics-image-viewer/state/types.d.ts +216 -0
  59. package/LICENSE.txt +0 -26
  60. package/es/aics-image-viewer/components/AxisClipSliders/index.js +0 -295
@@ -11,7 +11,7 @@ export type UseVolumeOptions = {
11
11
  /** Callback for when a single channel of the volume has loaded. */
12
12
  onChannelLoaded?: (image: Volume, channelIndex: number, isInitialLoad: boolean) => void;
13
13
  /** Callback for when image loading encounters an error. */
14
- onError?: (error: unknown) => void;
14
+ onError?: (error: unknown, image?: Volume) => void;
15
15
  /** The name of a channel which should be treated as a mask rather than as viewable data. */
16
16
  maskChannelName?: string;
17
17
  };
@@ -10,7 +10,7 @@ export declare const TFEDITOR_DEFAULT_COLOR: ColorArray;
10
10
  export declare const TFEDITOR_MAX_BIN = 255;
11
11
  export declare const CACHE_MAX_SIZE = 1000000000;
12
12
  export declare const QUEUE_MAX_SIZE = 10;
13
- export declare const QUEUE_MAX_LOW_PRIORITY_SIZE = 4;
13
+ export declare const QUEUE_MAX_LOW_PRIORITY_SIZE = 6;
14
14
  /** Maps an axis the user can "play" through to the direction to prefetch while playing that axis */
15
15
  export declare const AXIS_TO_LOADER_PRIORITY: Record<AxisName | "t", PrefetchDirection>;
16
16
  /** Maps channel data types to their minimum and maximum values */
@@ -0,0 +1,19 @@
1
+ import type { CameraState, View3d } from "@aics/vole-core";
2
+ import { mat3 } from "gl-matrix";
3
+ /** Multiply every vector in `state` by `matrix` */
4
+ export declare const applyMatrix: (state: CameraState, matrix: mat3) => CameraState;
5
+ /** Creates a XYZ rotation matrix with the given angles */
6
+ export declare const rotationMatrix: (x: number, y: number, z: number) => mat3;
7
+ /** Extract Tait-Bryan angles from a `CameraState` */
8
+ export declare const getRotationAngles: (state: CameraState) => {
9
+ x: number;
10
+ y: number;
11
+ z: number;
12
+ };
13
+ /**
14
+ * Constructs a new `CameraState` equivalent to rotating `state` about the origin such that the camera returns to its
15
+ * default *orientation* (looking towards -Z, +Y up), though not necessarily its default *position*.
16
+ */
17
+ export declare const defaultOrientedCamera: (state: CameraState) => CameraState;
18
+ /** Creates a callback that performs some action on the camera, by applying `transform` to the current camera state. */
19
+ export declare const useCameraCallback: <T extends any[]>(transform: (state: CameraState, ...args: T) => Partial<CameraState>, view3d: View3d) => ((...args: T) => CameraState);
@@ -5,6 +5,7 @@ export default class PlayControls {
5
5
  playWaitingForLoad: boolean;
6
6
  playHolding: boolean;
7
7
  playTimeoutId: number;
8
+ private lastStepTime;
8
9
  getVolumeIsLoaded?: () => boolean;
9
10
  stepAxis?: (axis: PlayAxisName) => void;
10
11
  onPlayingAxisChanged?: (axis: PlayAxisName | null) => void;
@@ -1,4 +1,4 @@
1
- import type { LoadSpec, PrefetchDirection, RawArrayLoaderOptions, Volume, VolumeLoaderContext } from "@aics/vole-core";
1
+ import type { LoadSpec, PrefetchDirection, RawArrayLoaderOptions, Volume, VolumeLoaderContext, ZarrLoaderFetchOptions } from "@aics/vole-core";
2
2
  import type { ThreadableVolumeLoader } from "@aics/vole-core/es/types/loaders/IVolumeLoader";
3
3
  export type LoadSceneOptions = {
4
4
  onCreateScene?: (volume: Volume, sceneIndex: number, loadSpec: LoadSpec) => void;
@@ -18,4 +18,5 @@ export default class SceneStore {
18
18
  createVolume(scene: number, loadSpec: LoadSpec, onChannelLoaded?: (volume: Volume, channelIndex: number) => void): Promise<Volume>;
19
19
  syncMultichannelLoading(sync: boolean): void;
20
20
  setPrefetchPriority(priority: PrefetchDirection[]): void;
21
+ updateFetchOptions(fetchOptions: Partial<ZarrLoaderFetchOptions>): void;
21
22
  }
@@ -1,178 +1,8 @@
1
- import type { CameraState } from "@aics/vole-core";
2
1
  import type { FirebaseFirestore } from "@firebase/firestore-types";
3
2
  import type { AppProps } from "../../components/App/types";
4
3
  import type { ViewerStore } from "../../state/store";
5
- import type { ChannelState, ViewerState } from "../../state/types";
6
- import { ViewMode } from "../enums";
4
+ import { type ViewerState, ViewerStateParams } from "../../state/types";
7
5
  import type { MetadataRecord } from "../types";
8
- import type { ColorArray } from "./colorRepresentations";
9
- import type { ViewerChannelSetting } from "./viewerChannelSettings";
10
- export declare const ENCODED_COMMA_REGEX: RegExp;
11
- export declare const ENCODED_COLON_REGEX: RegExp;
12
- /**
13
- * LEGACY: Matches a COMMA-separated list of control points, where each control point is represented
14
- * by a triplet of `{x}:{opacity}:{hex color}`.
15
- * The hex color can be replaced with `1` to represent white (`ffffff`).
16
- */
17
- export declare const LEGACY_CONTROL_POINTS_REGEX: RegExp;
18
- /**
19
- * Matches a COLON-separated list of control points, where each control point is
20
- * represented by a triplet of `{x}:{opacity}:{hex color}`.
21
- * - `x` is a value that will either be parsed as a histogram bin index (legacy,
22
- * for `ControlPointsLegacy`) or intensity value (for `ControlPoints`),
23
- * depending on on which field is being parsed.
24
- * - Opacity is a float in the [0, 1] range.
25
- * - The hex color is a 6-digit hex color (e.g. `ffeecc`), and can be replaced
26
- * with `1` to represent white (`ffffff`).
27
- */
28
- export declare const CONTROL_POINTS_REGEX: RegExp;
29
- /**
30
- * Enum keys for URL parameters. These are stored as enums for better readability,
31
- * and are mapped to types in `ViewerStateParams`.
32
- */
33
- export declare enum ViewerStateKeys {
34
- View = "view",
35
- Mode = "mode",
36
- Mask = "mask",
37
- Image = "image",
38
- Axes = "axes",
39
- BoundingBox = "bb",
40
- BoundingBoxColor = "bbcol",
41
- BackgroundColor = "bgcol",
42
- Autorotate = "rot",
43
- Brightness = "bright",
44
- Density = "dens",
45
- Levels = "lvl",
46
- Interpolation = "interp",
47
- Region = "reg",
48
- Slice = "slice",
49
- Time = "t",
50
- Scene = "scene",
51
- CameraState = "cam",
52
- SingleChannelMode = "scm",
53
- SingleChannelIndex = "sci",
54
- UseExactScaleLevel = "esl",
55
- ScaleLevelIndex = "scl"
56
- }
57
- export declare enum CameraTransformKeys {
58
- /** Camera position in 3D coordinates. */
59
- Position = "pos",
60
- /** Target position of the trackball controls in 3D coordinates. */
61
- Target = "tar",
62
- /** The up vector of the camera. Will be normalized to magnitude of 1. */
63
- Up = "up",
64
- /** Scale factor for orthographic cameras. */
65
- OrthoScale = "ort",
66
- /** Vertical FOV of the camera view frustum, from top to bottom, in degrees. */
67
- Fov = "fov"
68
- }
69
- /**
70
- * Mapped to types in `ViewerChannelSettingParams`
71
- */
72
- export declare enum ViewerChannelSettingKeys {
73
- Color = "col",
74
- Colorize = "clz",
75
- ColorizeAlpha = "cza",
76
- IsosurfaceAlpha = "isa",
77
- Lut = "lut",
78
- ControlPoints = "cpt",
79
- ControlPointsLegacy = "cps",
80
- Ramp = "ram",
81
- RampLegacy = "rmp",
82
- ControlPointsEnabled = "cpe",
83
- VolumeEnabled = "ven",
84
- SurfaceEnabled = "sen",
85
- IsosurfaceValue = "isv",
86
- KeepRange = "pin"
87
- }
88
- /**
89
- * The serialized form of a ViewerChannelSetting, as a dictionary object.
90
- */
91
- export declare class ViewerChannelSettingParams {
92
- /** Color, as a 6-digit hex color. */
93
- [ViewerChannelSettingKeys.Color]?: string;
94
- /** Colorize. "1" is enabled. Disabled by default. */
95
- [ViewerChannelSettingKeys.Colorize]?: "1" | "0";
96
- /** Colorize alpha, in the [0, 1] range. Set to `1.0` by default. */
97
- [ViewerChannelSettingKeys.ColorizeAlpha]?: string;
98
- /** Isosurface alpha, in the [0, 1 range]. Set to `1.0` by default.*/
99
- [ViewerChannelSettingKeys.IsosurfaceAlpha]?: string;
100
- /**
101
- * Lookup table (LUT) to map from volume intensity to opacity. Should be two
102
- * alphanumeric values separated by a colon, where the first value is the
103
- * minimum and the second is the maximum. Defaults to [0, 255].
104
- *
105
- * Min and max values are determined as following:
106
- * - Plain numbers are indices of histogram bins, typically in the range [0,
107
- * 255].
108
- * - `v{n}` represents a raw intensity value, where `n` is a number.
109
- * - `p{n}` represents a percentile, where `n` is a percentile in the [0, 100]
110
- * range.
111
- * - `m{n}` represents the median multiplied by `n / 100`.
112
- * - `autoij` in either the min or max fields will use the "auto" algorithm
113
- * from ImageJ to select the min and max.
114
- *
115
- * Values will be used to determine the initial control points and ramp if
116
- * those fields are not provided.
117
- *
118
- * @example
119
- * ```
120
- * "0:255" // min: intensity 0, max: intensity 255.
121
- * "p50:p90" // min: 50th percentile, max: 90th percentile.
122
- * "m1:p75" // min: median, max: 75th percentile.
123
- * "autoij:0" // use Auto-IJ to calculate min and max.
124
- * ```
125
- */
126
- [ViewerChannelSettingKeys.Lut]?: string;
127
- /**
128
- * Legacy specifier for control points for the transfer function as a list of
129
- * `x:opacity:color` triplets, separated by colon. Uses histogram bin indices
130
- * instead of intensity values.
131
- * - `x` is a histogram bin index in the [0, 255] range.
132
- * - `opacity` is a float in the [0, 1] range.
133
- * - `color` is a 6-digit hex color, e.g. `ff0000`.
134
- *
135
- * Will be overridden by the ControlPoints field (`cpt`) if provided.
136
- */
137
- [ViewerChannelSettingKeys.ControlPointsLegacy]?: string;
138
- /**
139
- * Control points for the transfer function, formatted as a list of
140
- * `x:opacity:color` triplets, separated by colons.
141
- * - `x` is a numeric intensity value.
142
- * - `opacity` is a float in the [0, 1] range.
143
- * - `color` is a 6-digit hex color, e.g. `ff0000`.
144
- *
145
- * If provided, overrides the `lut` field when calculating the control points.
146
- */
147
- [ViewerChannelSettingKeys.ControlPoints]?: string;
148
- /**
149
- * Whether to show advanced mode, which will show control points instead of
150
- * ramp values defined by the LUT. "1" is enabled, disabled by default.
151
- */
152
- [ViewerChannelSettingKeys.ControlPointsEnabled]?: "1" | "0";
153
- /**
154
- * Legacy specifier for the transfer function ramp which uses histogram bin
155
- * indices instead of intensity values, formatted as `min:max`. Will be
156
- * overridden by the Ramp field (`ram`) if provided.
157
- */
158
- [ViewerChannelSettingKeys.RampLegacy]?: string;
159
- /**
160
- * Ramp min and max intensity values (`min:max`). If provided, overrides the
161
- * `lut` field when calculating the ramp.
162
- */
163
- [ViewerChannelSettingKeys.Ramp]?: string;
164
- /** Volume enabled. "1" is enabled. Disabled by default. */
165
- [ViewerChannelSettingKeys.VolumeEnabled]?: "1" | "0";
166
- /** Isosurface enabled. "1" is enabled. Disabled by default. */
167
- [ViewerChannelSettingKeys.SurfaceEnabled]?: "1" | "0";
168
- /** Isosurface value, in the [0, 255] range. Set to `128` by default. */
169
- [ViewerChannelSettingKeys.IsosurfaceValue]?: string;
170
- /**
171
- * Whether to keep the current contrast settings when loading a new volume.
172
- * "1" is enabled. Disabled by default.
173
- */
174
- [ViewerChannelSettingKeys.KeepRange]?: "1" | "0";
175
- }
176
6
  /**
177
7
  * Channels, matching the pattern `c0`, `c1`, etc. corresponding to the index of the channel being configured.
178
8
  * The channel parameter should have a value that is a comma-separated list of `key:value` pairs, with keys
@@ -181,75 +11,6 @@ export declare class ViewerChannelSettingParams {
181
11
  type ChannelParams = {
182
12
  [_ in `c${number}`]?: string;
183
13
  };
184
- /** Serialized version of `ViewerState`. */
185
- export declare class ViewerStateParams {
186
- /** Axis to view. Valid values are "3D", "X", "Y", and "Z". Defaults to "3D". */
187
- [ViewerStateKeys.View]?: string;
188
- /**
189
- * Render mode. Valid values are "volumetric", "maxproject", and "pathtrace".
190
- * Defaults to "volumetric".
191
- */
192
- [ViewerStateKeys.Mode]?: string;
193
- /** The opacity of the mask channel, an integer in the range [0, 100]. Defaults to 50. */
194
- [ViewerStateKeys.Mask]?: string;
195
- /** The type of image to display. Valid values are "cell" and "fov". Defaults to "cell". */
196
- [ViewerStateKeys.Image]?: string;
197
- /** Whether to show the axes helper. "1" is enabled. Disabled by default. */
198
- [ViewerStateKeys.Axes]?: string;
199
- /** Whether to show the bounding box. "1" is enabled. Disabled by default. */
200
- [ViewerStateKeys.BoundingBox]?: string;
201
- /** Whether single-channel mode is active. "1" is active. Inactive by default. */
202
- [ViewerStateKeys.SingleChannelMode]?: string;
203
- /** If single-channel mode is active, which channel index is shown. Defaults to 0. */
204
- [ViewerStateKeys.SingleChannelIndex]?: string;
205
- /** The color of the bounding box, as a 6-digit hex color. */
206
- [ViewerStateKeys.BoundingBoxColor]?: string;
207
- /** The background color, as a 6-digit hex color. */
208
- [ViewerStateKeys.BackgroundColor]?: string;
209
- /** Whether to autorotate the view. "1" is enabled. Disabled by default. */
210
- [ViewerStateKeys.Autorotate]?: string;
211
- /** The brightness of the image, an float in the range [0, 100]. Defaults to 70. */
212
- [ViewerStateKeys.Brightness]?: string;
213
- /** Density, a float in the range [0, 100]. Defaults to 50. */
214
- [ViewerStateKeys.Density]?: string;
215
- /**
216
- * Levels for image intensity adjustment. Should be three numeric values separated
217
- * by commas, representing the low, middle, and high values in a [0, 255] range.
218
- * Values will be sorted in ascending order; empty values will be parsed as 0.
219
- */
220
- [ViewerStateKeys.Levels]?: string;
221
- /** Whether to enable interpolation. "1" is enabled. Enabled by default. */
222
- [ViewerStateKeys.Interpolation]?: string;
223
- /** Subregions per axis, as min:max pairs separated by commas.
224
- * Defaults to full range (`0:1`) for each axis.
225
- */
226
- [ViewerStateKeys.Region]?: string;
227
- /** Slice position per X, Y, and Z axes, as a list of comma-separated floats.
228
- * 0.5 for all axes by default (e.g. `0.5,0.5,0.5`)
229
- */
230
- [ViewerStateKeys.Slice]?: string;
231
- /** Frame number, for time-series volumes. 0 by default. */
232
- [ViewerStateKeys.Time]?: string;
233
- /** Scene number, for multiscene images. 0 by default. */
234
- [ViewerStateKeys.Scene]?: string;
235
- /** Whether to use an exact scale level index. 0 by default. */
236
- [ViewerStateKeys.UseExactScaleLevel]?: string;
237
- /** The exact scale level index to use, if `UseExactScaleLevel` is 1. 0 by default. */
238
- [ViewerStateKeys.ScaleLevelIndex]?: string;
239
- /**
240
- * Camera transform settings, as a list of `key:value` pairs separated by commas.
241
- * Valid keys are defined in `CameraTransformKeys`:
242
- * - `pos`: position
243
- * - `tar`: target
244
- * - `up`: up
245
- * - `rot`: rotation
246
- * - `ort`: orthographic scales
247
- *
248
- * All values are an array of three floats, separated by commas and
249
- * encoded using `encodeURIComponent`.
250
- */
251
- [ViewerStateKeys.CameraState]?: string;
252
- }
253
14
  /** URL parameters that define data sources when loading volumes. */
254
15
  declare class DataParams {
255
16
  /**
@@ -321,73 +82,6 @@ type ViewerMessage = {
321
82
  export declare function getAllowedParams(searchParams: URLSearchParams): AppParams;
322
83
  /** Parses the `url` query param into a 2D URL array: one or more scenes, with one or more sources per scene. */
323
84
  export declare const parseImageURLParam: (urlParam: string) => string[][];
324
- /**
325
- * Parse a string list of comma-separated key:value pairs into
326
- * a key-value object.
327
- *
328
- * @param data The string to parse. Expected to be in the format
329
- * "key1:value1,key2:value2,...". Commas in keys or values
330
- * must be encoded using `encodeURIComponent`.
331
- * @returns An object with the parsed key-value pairs. Key and value strings
332
- * will be decoded using `decodeURIComponent`.
333
- */
334
- export declare function parseKeyValueList(data: string): Record<string, string>;
335
- export declare function objectToKeyValueList(obj: Record<string, string | undefined>): string;
336
- /**
337
- * Parses a string to a float and clamps the result to the [min, max] range.
338
- * Returns `undefined` if the string is undefined or NaN.
339
- * @param value String to parse as a float. Will be parsed with `Number.parseFloat`.
340
- * @param min Minimum value, inclusive.
341
- * @param max Maximum value, inclusive.
342
- * @returns
343
- * - The parsed number, clamped to the [min, max] range.
344
- * - `undefined` if the string is undefined or NaN.
345
- */
346
- export declare function parseStringFloat(value: string | undefined, min: number, max: number): number | undefined;
347
- /**
348
- * Parses a string to an integer and clamps the result to the [min, max] range.
349
- * @param value String to parse as a float. Assumes base 10, parses with `Number.parseInt(value, 10)`.
350
- * @param min Minimum value, inclusive.
351
- * @param max Maximum value, inclusive.
352
- * @returns
353
- * - The parsed number, clamped to the [min, max] range.
354
- * - `undefined` if the string is undefined or NaN.
355
- */
356
- export declare function parseStringInt(value: string | undefined, min: number, max: number): number | undefined;
357
- /**
358
- * Parses a string to an enum value; if the string is not in the enum, returns the default value.
359
- * @param value String to parse.
360
- * @param enumValues Enum. Cannot be a `const enum`, as these are removed at compile time.
361
- * @param defaultValue Default value to return if the string is not in the enum.
362
- * @returns A value from the enum or the default value. Note that the return type includes `undefined`
363
- * if the `defaultValue` is `undefined`.
364
- */
365
- export declare function parseStringEnum<E extends string, T extends E | undefined>(value: string | undefined, enumValues: Record<string | number | symbol, E>, defaultValue?: T): T;
366
- export declare function parseHexColorAsColorArray(hexColor: string | undefined): ColorArray | undefined;
367
- export declare function serializeCameraState(cameraState: Partial<CameraState>, removeDefaults: boolean, viewMode?: ViewMode): string | undefined;
368
- /**
369
- * Parses a ViewerChannelSetting from a JSON object.
370
- * @param channelIndex Index of the channel, to be turned into a `match` value.
371
- * @param jsonState The serialized ViewerChannelSetting to parse, as an object.
372
- * @returns A ViewerChannelSetting object.
373
- */
374
- export declare function deserializeViewerChannelSetting(channelIndex: number, jsonState: ViewerChannelSettingParams): ViewerChannelSetting;
375
- /**
376
- * Serializes a single viewer channel setting into a dictionary of URL parameters
377
- * (`ViewerChannelSettingParams`).
378
- * @param channelSetting The channel state object to serialize.
379
- * @param removeDefaults Whether to remove properties that match the output of `GET_DEFAULT_CHANNEL_STATE`.
380
- * @returns A `ViewerChannelSettingParams` object with the serialized parameters. Undefined values are removed.
381
- */
382
- export declare function serializeViewerChannelSetting(channelSetting: Partial<ChannelState>, removeDefaults: boolean): Partial<ViewerChannelSettingParams>;
383
- export declare function deserializeViewerState(params: ViewerStateParams): Partial<ViewerState>;
384
- /**
385
- * Serializes a ViewerState object into a dictionary of URL parameters.
386
- * @param state The ViewerState to serialize.
387
- * @param removeDefaults If true, remove properties that match the output of `GET_DEFAULT_VIEWER_STATE`.
388
- * @returns A `ViewerStateParams` object with the serialized parameters. Undefined values are removed.
389
- */
390
- export declare function serializeViewerState(state: Partial<ViewerState>, removeDefaults: boolean): ViewerStateParams;
391
85
  export declare function loadFromManifest(manifestUrl: string): Promise<{
392
86
  scenes: (string | string[])[];
393
87
  metadata?: MetadataRecord[];
@@ -0,0 +1,70 @@
1
+ import type { ColorArray } from "../shared/utils/colorRepresentations";
2
+ import type { ViewerChannelSetting } from "../shared/utils/viewerChannelSettings";
3
+ import { type ViewerChannelStateParams, type ViewerState, type ViewerStateParams } from "./types";
4
+ /**
5
+ * LEGACY: Matches a COMMA-separated list of control points, where each control point is represented
6
+ * by a triplet of `{x}:{opacity}:{hex color}`.
7
+ * The hex color can be replaced with `1` to represent white (`ffffff`).
8
+ */
9
+ export declare const LEGACY_CONTROL_POINTS_REGEX: RegExp;
10
+ /**
11
+ * Matches a COLON-separated list of control points, where each control point is
12
+ * represented by a triplet of `{x}:{opacity}:{hex color}`.
13
+ * - `x` is a value that will either be parsed as a histogram bin index (legacy,
14
+ * for `ControlPointsLegacy`) or intensity value (for `ControlPoints`),
15
+ * depending on on which field is being parsed.
16
+ * - Opacity is a float in the [0, 1] range.
17
+ * - The hex color is a 6-digit hex color (e.g. `ffeecc`), and can be replaced
18
+ * with `1` to represent white (`ffffff`).
19
+ */
20
+ export declare const CONTROL_POINTS_REGEX: RegExp;
21
+ /**
22
+ * Parse a string list of comma-separated key:value pairs into
23
+ * a key-value object.
24
+ *
25
+ * @param data The string to parse. Expected to be in the format
26
+ * "key1:value1,key2:value2,...". Commas in keys or values
27
+ * must be encoded using `encodeURIComponent`.
28
+ * @returns An object with the parsed key-value pairs. Key and value strings
29
+ * will be decoded using `decodeURIComponent`.
30
+ */
31
+ export declare function parseKeyValueList(data: string): Record<string, string>;
32
+ /**
33
+ * Parses a string to a float and clamps the result to the [min, max] range.
34
+ * Returns `undefined` if the string is undefined or NaN.
35
+ * @param value String to parse as a float. Will be parsed with `Number.parseFloat`.
36
+ * @param min Minimum value, inclusive.
37
+ * @param max Maximum value, inclusive.
38
+ * @returns
39
+ * - The parsed number, clamped to the [min, max] range.
40
+ * - `undefined` if the string is undefined or NaN.
41
+ */
42
+ export declare function parseStringFloat(value: string | undefined, min: number, max: number): number | undefined;
43
+ /**
44
+ * Parses a string to an integer and clamps the result to the [min, max] range.
45
+ * @param value String to parse as a float. Assumes base 10, parses with `Number.parseInt(value, 10)`.
46
+ * @param min Minimum value, inclusive.
47
+ * @param max Maximum value, inclusive.
48
+ * @returns
49
+ * - The parsed number, clamped to the [min, max] range.
50
+ * - `undefined` if the string is undefined or NaN.
51
+ */
52
+ export declare function parseStringInt(value: string | undefined, min: number, max: number): number | undefined;
53
+ /**
54
+ * Parses a string to an enum value; if the string is not in the enum, returns the default value.
55
+ * @param value String to parse.
56
+ * @param enumValues Enum. Cannot be a `const enum`, as these are removed at compile time.
57
+ * @param defaultValue Default value to return if the string is not in the enum.
58
+ * @returns A value from the enum or the default value. Note that the return type includes `undefined`
59
+ * if the `defaultValue` is `undefined`.
60
+ */
61
+ export declare function parseStringEnum<E extends string, T extends E | undefined>(value: string | undefined, enumValues: Record<string | number | symbol, E>, defaultValue?: T): T;
62
+ export declare function parseHexColorAsColorArray(hexColor: string | undefined): ColorArray | undefined;
63
+ export declare function deserializeViewerState(params: ViewerStateParams): Partial<ViewerState>;
64
+ /**
65
+ * Parses a ViewerChannelSetting from a JSON object.
66
+ * @param channelIndex Index of the channel, to be turned into a `match` value.
67
+ * @param jsonState The serialized ViewerChannelSetting to parse, as an object.
68
+ * @returns A ViewerChannelSetting object.
69
+ */
70
+ export declare function deserializeViewerChannelSetting(channelIndex: number, jsonState: ViewerChannelStateParams): ViewerChannelSetting;
@@ -0,0 +1,20 @@
1
+ import type { CameraState } from "@aics/vole-core";
2
+ import { ViewMode } from "../shared/enums";
3
+ import type { ChannelState, ViewerChannelStateParams, ViewerState, ViewerStateParams } from "./types";
4
+ 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
+ /**
7
+ * Serializes a single viewer channel setting into a dictionary of URL parameters
8
+ * (`ViewerChannelStateParams`).
9
+ * @param channelSetting The channel state object to serialize.
10
+ * @param removeDefaults Whether to remove properties that match the output of `getDefaultChannelState`.
11
+ * @returns A `ViewerChannelSettingParams` object with the serialized parameters. Undefined values are removed.
12
+ */
13
+ export declare function serializeViewerChannelSetting(channelSetting: Partial<ChannelState>, removeDefaults: boolean): Partial<ViewerChannelStateParams>;
14
+ /**
15
+ * Serializes a `ViewerState` object into a dictionary of URL parameters.
16
+ * @param state The `ViewerState` to serialize.
17
+ * @param removeDefaults If true, remove properties that match the output of `getDefaultViewerState`.
18
+ * @returns A `ViewerStateParams` object with the serialized parameters. Undefined values are removed.
19
+ */
20
+ export declare function serializeViewerState(state: Partial<ViewerState>, removeDefaults: boolean): ViewerStateParams;