@aics/vole-app 3.4.4 → 3.5.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 (55) hide show
  1. package/es/aics-image-viewer/components/App/index.js +5 -5
  2. package/es/aics-image-viewer/components/ColorPicker/index.js +9 -1
  3. package/es/aics-image-viewer/components/ControlPanel/CopySettingsButton.js +415 -0
  4. package/es/aics-image-viewer/components/ControlPanel/index.js +12 -4
  5. package/es/aics-image-viewer/components/ControlPanel/styles.css +29 -2
  6. package/es/aics-image-viewer/components/StyleProvider/index.js +17 -2
  7. package/es/aics-image-viewer/components/Toolbar/ViewModeRadioButtons.js +1 -1
  8. package/es/aics-image-viewer/components/Toolbar/index.js +1 -1
  9. package/es/aics-image-viewer/components/{CellViewerCanvasWrapper → ViewerCanvasWrapper}/index.js +1 -1
  10. package/es/aics-image-viewer/components/dimension_sliders/RotationSliders.js +1 -1
  11. package/es/aics-image-viewer/components/shared/ContextualAlert.js +101 -0
  12. package/es/aics-image-viewer/components/useVolume.js +1 -1
  13. package/es/aics-image-viewer/shared/constants.js +1 -1
  14. package/es/aics-image-viewer/shared/types.js +1 -1
  15. package/es/aics-image-viewer/shared/utils/controlPointsToLut.js +4 -0
  16. package/es/aics-image-viewer/shared/utils/parseSnapshot.js +179 -0
  17. package/es/aics-image-viewer/shared/utils/{urlParsing.js → parseUrl.js} +14 -52
  18. package/es/aics-image-viewer/shared/utils/permissions.js +46 -0
  19. package/es/aics-image-viewer/shared/utils/test/camera.test.js +0 -1
  20. package/es/aics-image-viewer/shared/utils/test/{urlParsing.test.js → parseUrl.test.js} +8 -5
  21. package/es/aics-image-viewer/state/deserialize.js +443 -331
  22. package/es/aics-image-viewer/state/reset.js +1 -1
  23. package/es/aics-image-viewer/state/serialize.js +168 -78
  24. package/es/aics-image-viewer/state/subscribers.js +1 -1
  25. package/es/aics-image-viewer/state/test/deserialize.test.js +62 -76
  26. package/es/aics-image-viewer/state/test/reset.test.js +1 -1
  27. package/es/aics-image-viewer/state/test/serialize.test.js +41 -43
  28. package/es/aics-image-viewer/state/test/test_data.js +119 -1
  29. package/es/aics-image-viewer/state/types.js +157 -245
  30. package/es/aics-image-viewer/state/util.js +39 -1
  31. package/es/index.js +4 -2
  32. package/package.json +1 -1
  33. package/type-declarations/aics-image-viewer/components/App/types.d.ts +3 -3
  34. package/type-declarations/aics-image-viewer/components/ControlPanel/CopySettingsButton.d.ts +9 -0
  35. package/type-declarations/aics-image-viewer/components/Toolbar/ViewModeRadioButtons.d.ts +1 -1
  36. package/type-declarations/aics-image-viewer/components/{CellViewerCanvasWrapper → ViewerCanvasWrapper}/index.d.ts +3 -3
  37. package/type-declarations/aics-image-viewer/components/dimension_sliders/AxisClipSliders.d.ts +6 -6
  38. package/type-declarations/aics-image-viewer/components/shared/ContextualAlert.d.ts +29 -0
  39. package/type-declarations/aics-image-viewer/shared/constants.d.ts +1 -2
  40. package/type-declarations/aics-image-viewer/shared/types.d.ts +2 -2
  41. package/type-declarations/aics-image-viewer/shared/utils/controlPointsToLut.d.ts +1 -1
  42. package/type-declarations/aics-image-viewer/shared/utils/parseSnapshot.d.ts +47 -0
  43. package/type-declarations/aics-image-viewer/shared/utils/{urlParsing.d.ts → parseUrl.d.ts} +2 -16
  44. package/type-declarations/aics-image-viewer/shared/utils/permissions.d.ts +7 -0
  45. package/type-declarations/aics-image-viewer/shared/utils/viewerChannelSettings.d.ts +1 -1
  46. package/type-declarations/aics-image-viewer/state/deserialize.d.ts +70 -35
  47. package/type-declarations/aics-image-viewer/state/reset.d.ts +1 -1
  48. package/type-declarations/aics-image-viewer/state/serialize.d.ts +44 -10
  49. package/type-declarations/aics-image-viewer/state/types.d.ts +265 -159
  50. package/type-declarations/aics-image-viewer/state/util.d.ts +3 -1
  51. package/type-declarations/index.d.ts +5 -3
  52. package/es/aics-image-viewer/shared/enums.js +0 -18
  53. package/type-declarations/aics-image-viewer/shared/enums.d.ts +0 -15
  54. package/type-declarations/aics-image-viewer/shared/utils/math.d.ts +0 -1
  55. /package/es/aics-image-viewer/components/{CellViewerCanvasWrapper → ViewerCanvasWrapper}/styles.css +0 -0
@@ -1,7 +1,21 @@
1
1
  import type { CameraState, ControlPoint } from "@aics/vole-core";
2
- import type { ImageType, RenderMode, ViewMode } from "../shared/enums";
3
- import type { PerAxis } from "../shared/types";
2
+ import type { XYZ } from "../shared/types";
4
3
  import type { ColorArray } from "../shared/utils/colorRepresentations";
4
+ export declare enum ViewMode {
5
+ threeD = "3D",
6
+ xy = "XY",
7
+ xz = "XZ",
8
+ yz = "YZ"
9
+ }
10
+ export declare enum RenderMode {
11
+ volumetric = "volumetric",
12
+ maxProject = "maxproject",
13
+ pathTrace = "pathtrace"
14
+ }
15
+ export declare enum ImageType {
16
+ segmentedCell = "cell",
17
+ fullField = "fov"
18
+ }
5
19
  /** Global (not per-channel) viewer state which may be changed in the UI */
6
20
  export type ViewerState = {
7
21
  viewMode: ViewMode;
@@ -17,8 +31,8 @@ export type ViewerState = {
17
31
  density: number;
18
32
  levels: [number, number, number];
19
33
  interpolationEnabled: boolean;
20
- region: PerAxis<[number, number]>;
21
- slice: PerAxis<number>;
34
+ region: XYZ<[number, number]>;
35
+ slice: XYZ<number>;
22
36
  time: number;
23
37
  scene: number;
24
38
  cameraState: Partial<CameraState> | undefined;
@@ -27,6 +41,7 @@ export type ViewerState = {
27
41
  useExactScaleLevel: boolean;
28
42
  scaleLevelIndex: number;
29
43
  };
44
+ /** Settings for a single channel which may be changed in the UI */
30
45
  export type ChannelState = {
31
46
  name: string;
32
47
  displayName: string;
@@ -49,32 +64,43 @@ export type ChannelState = {
49
64
  keepIntensityRange: boolean;
50
65
  };
51
66
  /**
52
- * Enum keys for serialized viewer settings. These are stored as enums for
53
- * better readability, and are mapped to types in `ViewerStateParams`.
67
+ * The variants of `ViewMode` that appear in serialized representations of state
68
+ * (`ViewerStateSnapshot`, `ViewerStateStringified`).
69
+ *
70
+ * **IMPORTANT:** Changing the values of this enum will BREAK existing image sharing links and exported app state.
71
+ * It should not be done without introducing code to handle the previous values. This enum must not have values that
72
+ * collide when `toLowerCase` is applied to them.
54
73
  */
55
- export declare enum ViewerStateKeys {
56
- View = "view",
57
- Mode = "mode",
58
- Mask = "mask",
59
- Image = "image",
60
- Axes = "axes",
61
- BoundingBox = "bb",
62
- BoundingBoxColor = "bbcol",
63
- BackgroundColor = "bgcol",
64
- Autorotate = "rot",
65
- Brightness = "bright",
66
- Density = "dens",
67
- Levels = "lvl",
68
- Interpolation = "interp",
69
- Region = "reg",
70
- Slice = "slice",
71
- Time = "t",
72
- Scene = "scene",
73
- CameraState = "cam",
74
- SingleChannelMode = "scm",
75
- SingleChannelIndex = "sci",
76
- UseExactScaleLevel = "esl",
77
- ScaleLevelIndex = "scl"
74
+ export declare enum ViewModeSnapshot {
75
+ threeD = "3D",
76
+ xy = "Z",
77
+ xz = "Y",
78
+ yz = "X"
79
+ }
80
+ /**
81
+ * The variants of `RenderMode` that appear in serialized representations of state
82
+ * (`ViewerStateSnapshot`, `ViewerStateStringified`).
83
+ *
84
+ * **IMPORTANT:** Changing the values of this enum will BREAK existing image sharing links and exported app state.
85
+ * It should not be done without introducing code to handle the previous values. This enum must not have values that
86
+ * collide when `toLowerCase` is applied to them.
87
+ */
88
+ export declare enum RenderModeSnapshot {
89
+ volumetric = "volumetric",
90
+ maxProject = "maxproject",
91
+ pathTrace = "pathtrace"
92
+ }
93
+ /**
94
+ * The variants of `ImageType` that appear in serialized representations of state
95
+ * (`ViewerStateSnapshot`, `ViewerStateStringified`).
96
+ *
97
+ * **IMPORTANT:** Changing the values of this enum will BREAK existing image sharing links and exported app state.
98
+ * It should not be done without introducing code to handle the previous values. This enum must not have values that
99
+ * collide when `toLowerCase` is applied to them.
100
+ */
101
+ export declare enum ImageTypeSnapshot {
102
+ segmentedCell = "cell",
103
+ fullField = "fov"
78
104
  }
79
105
  export declare enum CameraTransformKeys {
80
106
  /** Camera position in 3D coordinates. */
@@ -88,123 +114,114 @@ export declare enum CameraTransformKeys {
88
114
  /** Vertical FOV of the camera view frustum, from top to bottom, in degrees. */
89
115
  Fov = "fov"
90
116
  }
91
- /** Serialized version of `ViewerState`. */
92
- export declare class ViewerStateParams {
93
- /** Axis to view. Valid values are "3D", "X", "Y", and "Z". Defaults to "3D". */
94
- [ViewerStateKeys.View]?: string;
95
- /**
96
- * Render mode. Valid values are "volumetric", "maxproject", and "pathtrace".
97
- * Defaults to "volumetric".
98
- */
99
- [ViewerStateKeys.Mode]?: string;
100
- /** The opacity of the mask channel, an integer in the range [0, 100]. Defaults to 50. */
101
- [ViewerStateKeys.Mask]?: string;
102
- /** The type of image to display. Valid values are "cell" and "fov". Defaults to "cell". */
103
- [ViewerStateKeys.Image]?: string;
104
- /** Whether to show the axes helper. "1" is enabled. Disabled by default. */
105
- [ViewerStateKeys.Axes]?: string;
106
- /** Whether to show the bounding box. "1" is enabled. Disabled by default. */
107
- [ViewerStateKeys.BoundingBox]?: string;
108
- /** Whether single-channel mode is active. "1" is active. Inactive by default. */
109
- [ViewerStateKeys.SingleChannelMode]?: string;
110
- /** If single-channel mode is active, which channel index is shown. Defaults to 0. */
111
- [ViewerStateKeys.SingleChannelIndex]?: string;
117
+ export type CameraStateSnapshot = {
118
+ [CameraTransformKeys.Position]?: [number, number, number];
119
+ [CameraTransformKeys.Target]?: [number, number, number];
120
+ [CameraTransformKeys.Up]?: [number, number, number];
121
+ [CameraTransformKeys.OrthoScale]?: number;
122
+ [CameraTransformKeys.Fov]?: number;
123
+ };
124
+ export type CameraStateStringified = {
125
+ [K in CameraTransformKeys]?: string;
126
+ };
127
+ /**
128
+ * Property keys for the "snapshot" variants of `ViewerState`. These keys are shorter, for contexts that need brevity
129
+ * (like URLs), and have a stronger guarantee of stability than the keys of `ViewerState`.
130
+ *
131
+ * **IMPORTANT:** Changing the values of this enum will BREAK existing image sharing links and exported app state.
132
+ * Ideally, you should never do it. If you must, you must also add code to version-check and handle previous values.
133
+ */
134
+ export declare enum ViewerStateSnapshotKeys {
135
+ /** Axis to view. Snapshot values are `3D`, `Z`, `Y`, `X` (from `ViewModeSnapshot`). */
136
+ View = "view",
137
+ /** Render mode. Possible values are `volumetric`, `maxproject`, or `pathtrace` (from `RenderModeSnapshot`). */
138
+ Mode = "mode",
139
+ /** The opacity of the mask channel, an integer in the range `[0, 100]`. Defaults to `50`. */
140
+ MaskOpacity = "mask",
141
+ /** The type of image to display. Valid values are `cell` and `fov` (from `ImageTypeSnapshot`). Default `cell`. */
142
+ ImageType = "image",
143
+ /** Whether to show the axes helper. Boolean, or `0`/`1` when stringified. Default `false`. */
144
+ ShowAxes = "axes",
145
+ /** Whether to show the bounding box. Boolean, or `0`/`1` when stringified. Default `false`. */
146
+ ShowBoundingBox = "bb",
112
147
  /** The color of the bounding box, as a 6-digit hex color. */
113
- [ViewerStateKeys.BoundingBoxColor]?: string;
148
+ BoundingBoxColor = "bbcol",
114
149
  /** The background color, as a 6-digit hex color. */
115
- [ViewerStateKeys.BackgroundColor]?: string;
116
- /** Whether to autorotate the view. "1" is enabled. Disabled by default. */
117
- [ViewerStateKeys.Autorotate]?: string;
118
- /** The brightness of the image, an float in the range [0, 100]. Defaults to 70. */
119
- [ViewerStateKeys.Brightness]?: string;
120
- /** Density, a float in the range [0, 100]. Defaults to 50. */
121
- [ViewerStateKeys.Density]?: string;
150
+ BackgroundColor = "bgcol",
151
+ /** Whether to autorotate the view. Boolean, or `0`/`1` when stringified. Default `false`. */
152
+ Autorotate = "rot",
153
+ /** The brightness of the image, a float in the range `[0, 100]`. Default `70`. */
154
+ Brightness = "bright",
155
+ /** Density, a float in the range `[0, 100]`. Default `50`. */
156
+ Density = "dens",
122
157
  /**
123
- * Levels for image intensity adjustment. Should be three numeric values separated
124
- * by commas, representing the low, middle, and high values in a [0, 255] range.
125
- * Values will be sorted in ascending order; empty values will be parsed as 0.
158
+ * Levels for image intensity adjustment. Should be a three-element array of numbers (comma-separated when
159
+ * stringified), representing the low, middle, and high values in the range `[0, 255]`. Values will be sorted in
160
+ * ascending order. Empty values in stringified form will be parsed as `0`.
126
161
  */
127
- [ViewerStateKeys.Levels]?: string;
128
- /** Whether to enable interpolation. "1" is enabled. Enabled by default. */
129
- [ViewerStateKeys.Interpolation]?: string;
130
- /** Subregions per axis, as min:max pairs separated by commas.
131
- * Defaults to full range (`0:1`) for each axis.
162
+ Levels = "lvl",
163
+ /** Whether to enable interpolation. Boolean, or `0`/`1` when stringified. Default `true`. */
164
+ Interpolation = "interp",
165
+ /**
166
+ * Size of the clipped subregion, in the form `[[xmin, xmax], [ymin, ymax], [zmin, zmax]]`.
167
+ * Stringifies to the form `xmin:xmax,ymin:ymax,zmin:zmax`. Default full range (`[0, 1]`) for each axis.
132
168
  */
133
- [ViewerStateKeys.Region]?: string;
134
- /** Slice position per X, Y, and Z axes, as a list of comma-separated floats.
135
- * 0.5 for all axes by default (e.g. `0.5,0.5,0.5`)
169
+ Region = "reg",
170
+ /**
171
+ * Slice position per X, Y, and Z axes, as a three-element array of floats (comma-separated when stringified).
172
+ * Default `0.5` for all axes (e.g. `[0.5, 0.5, 0.5]`).
136
173
  */
137
- [ViewerStateKeys.Slice]?: string;
138
- /** Frame number, for time-series volumes. 0 by default. */
139
- [ViewerStateKeys.Time]?: string;
140
- /** Scene number, for multiscene images. 0 by default. */
141
- [ViewerStateKeys.Scene]?: string;
142
- /** Whether to use an exact scale level index. 0 by default. */
143
- [ViewerStateKeys.UseExactScaleLevel]?: string;
144
- /** The exact scale level index to use, if `UseExactScaleLevel` is 1. 0 by default. */
145
- [ViewerStateKeys.ScaleLevelIndex]?: string;
174
+ Slice = "slice",
175
+ /** Frame number, for time-series volumes. `0` by default. */
176
+ Time = "t",
177
+ /** Scene number, for multiscene images. `0` by default. */
178
+ Scene = "scene",
146
179
  /**
147
- * Camera transform settings, as a list of `key:value` pairs separated by commas.
148
- * Valid keys are defined in `CameraTransformKeys`:
149
- * - `pos`: position
150
- * - `tar`: target
151
- * - `up`: up
152
- * - `ort`: orthographic scale
153
- * - `fov`: field of view
180
+ * Camera transform settings. An object with type `CameraTransformSnapshot`; see `CameraTransformKeys` for more.
154
181
  *
155
- * Vector values are encoded as three floats separated by colons (e.g. `1:2:3`) and
156
- * encoded using `encodeURIComponent`.
182
+ * Stringifies to a list of `key:value` pairs separated by commas. Vector values are encoded as three floats
183
+ * separated by colons (e.g. `1:2:3`) and encoded using `encodeURIComponent`.
157
184
  */
158
- [ViewerStateKeys.CameraState]?: string;
185
+ CameraState = "cam",
186
+ /** Whether single-channel mode is active. Boolean, or `0`/`1` when stringified. Default `false`. */
187
+ SingleChannelMode = "scm",
188
+ /** If single-channel mode is active, which channel index is shown. Default `0`. */
189
+ SingleChannelIndex = "sci",
190
+ /** Whether to use an exact scale level index. Boolean, or `0`/`1` when stringified. Default `false`. */
191
+ UseExactScaleLevel = "esl",
192
+ /** The exact scale level index to use, if `UseExactScaleLevel` is `true`. Default `0`. */
193
+ ScaleLevelIndex = "scl"
159
194
  }
160
195
  /**
161
- * Mapped to types in `ViewerChannelStateParams`.
196
+ * Property keys for the "snapshot" variants of `ChannelState`/`ViewerChannelSettings`. These keys are shorter, for
197
+ * contexts that need brevity (like URLs), and have a stronger guarantee of stability than the keys of `ChannelState`.
198
+ *
199
+ * **IMPORTANT:** Changing the values of this enum will BREAK existing image sharing links and exported app state.
200
+ * Ideally, you should never do it. If you must, you must also add code to version-check and handle previous values.
162
201
  */
163
- export declare enum ViewerChannelSettingKeys {
202
+ export declare enum ChannelStateSnapshotKeys {
203
+ /** Color, as a 6-digit hex color. */
164
204
  Color = "col",
205
+ /** Whether colorize is enabled. Boolean, or `0`/`1` when stringified. Default `false`. */
165
206
  Colorize = "clz",
207
+ /** Colorize alpha, in the range `[0, 1]`. Default `1.0`. */
166
208
  ColorizeAlpha = "cza",
209
+ /** Isosurface alpha, in the range `[0, 1]`. Set to `1.0` by default.*/
167
210
  IsosurfaceAlpha = "isa",
168
- Lut = "lut",
169
- ControlPoints = "cpt",
170
- ControlPointsLegacy = "cps",
171
- Ramp = "ram",
172
- RampLegacy = "rmp",
173
- ControlPointsEnabled = "cpe",
174
- VolumeEnabled = "ven",
175
- SurfaceEnabled = "sen",
176
- IsosurfaceValue = "isv",
177
- KeepRange = "pin"
178
- }
179
- /**
180
- * The serialized form of a ViewerChannelSetting, as a dictionary object.
181
- */
182
- export declare class ViewerChannelStateParams {
183
- /** Color, as a 6-digit hex color. */
184
- [ViewerChannelSettingKeys.Color]?: string;
185
- /** Colorize. "1" is enabled. Disabled by default. */
186
- [ViewerChannelSettingKeys.Colorize]?: "1" | "0";
187
- /** Colorize alpha, in the [0, 1] range. Set to `1.0` by default. */
188
- [ViewerChannelSettingKeys.ColorizeAlpha]?: string;
189
- /** Isosurface alpha, in the [0, 1 range]. Set to `1.0` by default.*/
190
- [ViewerChannelSettingKeys.IsosurfaceAlpha]?: string;
191
211
  /**
192
- * Lookup table (LUT) to map from volume intensity to opacity. Should be two
193
- * alphanumeric values separated by a colon, where the first value is the
194
- * minimum and the second is the maximum. Defaults to [0, 255].
212
+ * Lookup table (LUT) to map from volume intensity to opacity. A two-element array of alphanumeric values
213
+ * (colon-separated when stringified), where the first value is the minimum and the second is the maximum.
214
+ * Default `[0, 255]`.
195
215
  *
196
216
  * Min and max values are determined as following:
197
- * - Plain numbers are indices of histogram bins, typically in the range [0,
198
- * 255].
217
+ * - Plain numbers are indices of histogram bins, typically in the range `[0, 255]`.
199
218
  * - `v{n}` represents a raw intensity value, where `n` is a number.
200
- * - `p{n}` represents a percentile, where `n` is a percentile in the [0, 100]
201
- * range.
219
+ * - `p{n}` represents a percentile, where `n` is a percentile in the range `[0, 100]`.
202
220
  * - `m{n}` represents the median multiplied by `n / 100`.
203
- * - `autoij` in either the min or max fields will use the "auto" algorithm
204
- * from ImageJ to select the min AND max.
221
+ * - `autoij` in either the min or max fields will use the "auto" algorithm from ImageJ to select the min AND max.
205
222
  *
206
- * Values will be used to determine the initial control points and ramp if
207
- * those fields are not provided.
223
+ * This field has no counterpart in `ChannelState`. It will be used to determine the initial values of
224
+ * `ControlPoints` and `Ramp` if those fields are not provided.
208
225
  *
209
226
  * @example
210
227
  * ```
@@ -214,53 +231,142 @@ export declare class ViewerChannelStateParams {
214
231
  * "autoij:0" // use Auto-IJ to calculate min and max.
215
232
  * ```
216
233
  */
217
- [ViewerChannelSettingKeys.Lut]?: string;
234
+ Lut = "lut",
218
235
  /**
219
- * Legacy specifier for control points for the transfer function as a list of
220
- * `x:opacity:color` triplets, separated by colon. Uses histogram bin indices
221
- * instead of intensity values.
222
- * - `x` is a histogram bin index in the [0, 255] range.
223
- * - `opacity` is a float in the [0, 1] range.
224
- * - `color` is a 6-digit hex color, e.g. `ff0000`.
236
+ * Control points for the transfer function, formatted as a list of objects of type `ControlPointSnapshot` with the
237
+ * following keys:
238
+ * - `x` is a numeric intensity value.
239
+ * - `opacity` is a float in the range `[0, 1]`.
240
+ * - `color` is a 6-digit hex color, e.g. `"ff0000"`. For the extremely common default case where the control point is
241
+ * white (`"ffffff"`), `color` is shortened to just `"1"`.
225
242
  *
226
- * Will be overridden by the ControlPoints field (`cpt`) if provided.
243
+ * Stringifies to a colon-separated list: `x1:opacity1:color1:x2:opacity2:color2:...`
244
+ *
245
+ * If provided, overrides the `lut` field when calculating control points.
227
246
  */
228
- [ViewerChannelSettingKeys.ControlPointsLegacy]?: string;
247
+ ControlPoints = "cpt",
229
248
  /**
230
- * Control points for the transfer function, formatted as a list of
231
- * `x:opacity:color` triplets, separated by colons.
232
- * - `x` is a numeric intensity value.
233
- * - `opacity` is a float in the [0, 1] range.
234
- * - `color` is a 6-digit hex color, e.g. `ff0000`.
249
+ * Legacy specifier for control points for the transfer function. Formatted exactly like `ControlPoints`,
250
+ * except `x` represents histogram bin indices (in the range `[0, 255]`), not raw intensities.
235
251
  *
236
- * If provided, overrides the `lut` field when calculating the control points.
252
+ * Will be overridden by the `ControlPoints` field (`cpt`) if provided.
237
253
  */
238
- [ViewerChannelSettingKeys.ControlPoints]?: string;
254
+ ControlPointsLegacy = "cps",
239
255
  /**
240
- * Whether to show advanced mode, which will show control points instead of
241
- * ramp values defined by the LUT. "1" is enabled, disabled by default.
256
+ * Ramp min and max intensity values. Two-element array, colon-separated when stringified (`min:max`).
257
+ *
258
+ * If provided, overrides the `lut` field when calculating the ramp.
242
259
  */
243
- [ViewerChannelSettingKeys.ControlPointsEnabled]?: "1" | "0";
260
+ Ramp = "ram",
244
261
  /**
245
- * Legacy specifier for the transfer function ramp which uses histogram bin
246
- * indices instead of intensity values, formatted as `min:max`. Will be
247
- * overridden by the Ramp field (`ram`) if provided.
262
+ * Legacy specifier for the transfer function ramp. Formatted exactly like `Ramp`, except values represent histogram
263
+ * bin indices (in the range `[0, 255]`), not raw intensities.
264
+ *
265
+ * Will be overridden by the Ramp field (`ram`) if provided.
248
266
  */
249
- [ViewerChannelSettingKeys.RampLegacy]?: string;
267
+ RampLegacy = "rmp",
250
268
  /**
251
- * Ramp min and max intensity values (`min:max`). If provided, overrides the
252
- * `lut` field when calculating the ramp.
269
+ * Whether this channel's settings are in "advanced mode" and using control points rather than min/max ramp to derive
270
+ * the transfer function. Boolean, or `0`/`1` when stringified. Default `false`.
253
271
  */
254
- [ViewerChannelSettingKeys.Ramp]?: string;
255
- /** Volume enabled. "1" is enabled. Disabled by default. */
256
- [ViewerChannelSettingKeys.VolumeEnabled]?: "1" | "0";
257
- /** Isosurface enabled. "1" is enabled. Disabled by default. */
258
- [ViewerChannelSettingKeys.SurfaceEnabled]?: "1" | "0";
259
- /** Isosurface value, in the [0, 255] range. Set to `128` by default. */
260
- [ViewerChannelSettingKeys.IsosurfaceValue]?: string;
272
+ ControlPointsEnabled = "cpe",
273
+ /** Whether volume is enabled. Boolean, or `0`/`1` when stringified. Default `false`. */
274
+ VolumeEnabled = "ven",
275
+ /** Whether isosurface is enabled. Boolean, or `0`/`1` when stringified. Default `false`. */
276
+ SurfaceEnabled = "sen",
277
+ /** Isosurface value, in the range `[0, 255]`. Default `128`. */
278
+ IsosurfaceValue = "isv",
261
279
  /**
262
- * Whether to keep the current contrast settings when loading a new volume.
263
- * "1" is enabled. Disabled by default.
280
+ * Whether to keep the current contrast settings when loading a new volume. Boolean, or `0`/`1` when stringified.
281
+ * Default `false`.
264
282
  */
265
- [ViewerChannelSettingKeys.KeepRange]?: "1" | "0";
283
+ KeepRange = "pin"
266
284
  }
285
+ type ViewerStateSnapshotTypes = {
286
+ [ViewerStateSnapshotKeys.View]: ViewModeSnapshot;
287
+ [ViewerStateSnapshotKeys.Mode]: RenderModeSnapshot;
288
+ [ViewerStateSnapshotKeys.MaskOpacity]: number;
289
+ [ViewerStateSnapshotKeys.ImageType]: ImageTypeSnapshot;
290
+ [ViewerStateSnapshotKeys.ShowAxes]: boolean;
291
+ [ViewerStateSnapshotKeys.ShowBoundingBox]: boolean;
292
+ [ViewerStateSnapshotKeys.BoundingBoxColor]: string;
293
+ [ViewerStateSnapshotKeys.BackgroundColor]: string;
294
+ [ViewerStateSnapshotKeys.Autorotate]: boolean;
295
+ [ViewerStateSnapshotKeys.Brightness]: number;
296
+ [ViewerStateSnapshotKeys.Density]: number;
297
+ [ViewerStateSnapshotKeys.Levels]: [number, number, number];
298
+ [ViewerStateSnapshotKeys.Interpolation]: boolean;
299
+ [ViewerStateSnapshotKeys.Region]: [[number, number], [number, number], [number, number]];
300
+ [ViewerStateSnapshotKeys.Slice]: [number, number, number];
301
+ [ViewerStateSnapshotKeys.Time]: number;
302
+ [ViewerStateSnapshotKeys.Scene]: number;
303
+ [ViewerStateSnapshotKeys.CameraState]: CameraStateSnapshot;
304
+ [ViewerStateSnapshotKeys.SingleChannelMode]: boolean;
305
+ [ViewerStateSnapshotKeys.SingleChannelIndex]: number;
306
+ [ViewerStateSnapshotKeys.UseExactScaleLevel]: boolean;
307
+ [ViewerStateSnapshotKeys.ScaleLevelIndex]: number;
308
+ };
309
+ /**
310
+ * A "snapshot" of a `ViewerState`.
311
+ *
312
+ * This type is a variant representation of `ViewerState`, specialized for saving/restoring state to/from some
313
+ * serialized representation. It has the following desirable properties for this purpose:
314
+ * - Its keys are *shorter*, for formats where that's desirable (mostly URL parameters)
315
+ * - Its keys are reasonably *stable*, so that settings exported from older app versions can be imported by newer ones
316
+ * - Some values, notably colors, are converted to alternate representations for compactness and/or clarity
317
+ */
318
+ export type ViewerStateSnapshot = {
319
+ [K in ViewerStateSnapshotKeys]?: ViewerStateSnapshotTypes[K];
320
+ };
321
+ /**
322
+ * A `ViewerStateSnapshot` with all its keys converted to compact string representations. Useful for (de)serializing
323
+ * viewer state to/from URL parameters.
324
+ */
325
+ export type ViewerStateStringified = {
326
+ [K in ViewerStateSnapshotKeys]?: string;
327
+ };
328
+ /**
329
+ * A `ControlPoint` where `color` is a six-digit hex string, or gets shortened to `"1"` in the overwhelming majority of
330
+ * cases where the control point is white to save space in sharing URLs. Used by `ChannelStateSnapshot`.
331
+ */
332
+ export type ControlPointSnapshot = {
333
+ x: number;
334
+ opacity: number;
335
+ color: string;
336
+ };
337
+ type ChannelStateSnapshotTypes = {
338
+ [ChannelStateSnapshotKeys.Color]: string;
339
+ [ChannelStateSnapshotKeys.Colorize]: boolean;
340
+ [ChannelStateSnapshotKeys.ColorizeAlpha]: number;
341
+ [ChannelStateSnapshotKeys.IsosurfaceAlpha]: number;
342
+ [ChannelStateSnapshotKeys.Lut]: [string | number, string | number];
343
+ [ChannelStateSnapshotKeys.ControlPointsLegacy]: ControlPointSnapshot[];
344
+ [ChannelStateSnapshotKeys.ControlPoints]: ControlPointSnapshot[];
345
+ [ChannelStateSnapshotKeys.ControlPointsEnabled]: boolean;
346
+ [ChannelStateSnapshotKeys.RampLegacy]: [number, number];
347
+ [ChannelStateSnapshotKeys.Ramp]: [number, number];
348
+ [ChannelStateSnapshotKeys.VolumeEnabled]: boolean;
349
+ [ChannelStateSnapshotKeys.SurfaceEnabled]: boolean;
350
+ [ChannelStateSnapshotKeys.IsosurfaceValue]: number;
351
+ [ChannelStateSnapshotKeys.KeepRange]: boolean;
352
+ };
353
+ /**
354
+ * A "snapshot" of a `ChannelState` or `ViewerChannelSetting`.
355
+ *
356
+ * This type is a variant representation of `ChannelState`/`ViewerChannelSetting`, specialized for saving/restoring
357
+ * channel state to/from some serialized representation. It has the following desirable properties for this purpose:
358
+ * - Its keys are *shorter*, for formats where that's desirable (mostly URL parameters)
359
+ * - Its keys are reasonably *stable*, so that settings exported from older app versions can be imported by newer ones
360
+ * - Some values, notably colors, are converted to alternate representations for compactness and/or clarity
361
+ */
362
+ export type ChannelStateSnapshot = {
363
+ [K in ChannelStateSnapshotKeys]?: ChannelStateSnapshotTypes[K];
364
+ };
365
+ /**
366
+ * A `ChannelStateSnapshot` with all its keys converted to compact string representations. Useful for (de)serializing
367
+ * channel state to/from URL parameters.
368
+ */
369
+ export type ChannelStateStringified = {
370
+ [K in ChannelStateSnapshotKeys]?: string;
371
+ };
372
+ export {};
@@ -1,4 +1,4 @@
1
- import type { ViewerState } from "../state/types";
1
+ import type { ChannelState, ViewerState } from "../state/types";
2
2
  /**
3
3
  * Accepts a `key` and a new (potentially partial) `value` for a single field of `ViewerState`, & returns a fragment of
4
4
  * `ViewerState` that can safely be merged into `currentState` to apply that value without creating an illegal state.
@@ -6,3 +6,5 @@ import type { ViewerState } from "../state/types";
6
6
  export declare const validateStateValue: <K extends keyof ViewerState>(currentState: ViewerState, key: K, value: Partial<ViewerState[K]>) => Partial<ViewerState>;
7
7
  /** Ensures a fragment of `ViewerState` can be safely merged into `currentState` without creating an illegal state. */
8
8
  export declare const validateState: (currentState: ViewerState, newState: Partial<{ [K in keyof ViewerState]: Partial<ViewerState[K]>; }>) => Partial<ViewerState>;
9
+ /** Creates a deep copy of a `ChannelState` */
10
+ export declare const cloneChannelState: (setting: ChannelState) => ChannelState;
@@ -1,9 +1,11 @@
1
1
  import ImageViewerApp from "./aics-image-viewer/components/App";
2
- export { addViewerParamsFromMessage, parseViewerUrlParams } from "./aics-image-viewer/shared/utils/urlParsing";
2
+ export { parseViewerUrlParams } from "./aics-image-viewer/shared/utils/parseUrl";
3
3
  export { writeMetadata, writeScenes } from "./aics-image-viewer/shared/utils/storage";
4
+ export { type ViewerMessage, type StoreSnapshot, viewerMessageToParams, isStoreSnapshot, snapshotToViewerChannelSettings, } from "./aics-image-viewer/shared/utils/parseSnapshot";
5
+ export { snapshotToViewerState } from "./aics-image-viewer/state/deserialize";
4
6
  export type { ViewerChannelSettings, ViewerChannelGroup, ViewerChannelSetting, } from "./aics-image-viewer/shared/utils/viewerChannelSettings";
5
- export type { ViewerState } from "./aics-image-viewer/state/types";
6
- export { ViewMode, RenderMode, ImageType } from "./aics-image-viewer/shared/enums";
7
+ export { ViewMode, RenderMode, ImageType } from "./aics-image-viewer/state/types";
8
+ export type { ViewerState, ViewerStateSnapshot, ChannelStateSnapshot } from "./aics-image-viewer/state/types";
7
9
  export type { AppProps } from "./aics-image-viewer/components/App/types";
8
10
  export type { RawArrayData, RawArrayInfo } from "@aics/vole-core";
9
11
  export { ImageViewerApp };
@@ -1,18 +0,0 @@
1
- export var ViewMode = /*#__PURE__*/function (ViewMode) {
2
- ViewMode["threeD"] = "3D";
3
- ViewMode["xy"] = "XY";
4
- ViewMode["xz"] = "XZ";
5
- ViewMode["yz"] = "YZ";
6
- return ViewMode;
7
- }({});
8
- export var RenderMode = /*#__PURE__*/function (RenderMode) {
9
- RenderMode["volumetric"] = "volumetric";
10
- RenderMode["maxProject"] = "maxproject";
11
- RenderMode["pathTrace"] = "pathtrace";
12
- return RenderMode;
13
- }({});
14
- export var ImageType = /*#__PURE__*/function (ImageType) {
15
- ImageType["segmentedCell"] = "cell";
16
- ImageType["fullField"] = "fov";
17
- return ImageType;
18
- }({});
@@ -1,15 +0,0 @@
1
- export declare enum ViewMode {
2
- threeD = "3D",
3
- xy = "XY",
4
- xz = "XZ",
5
- yz = "YZ"
6
- }
7
- export declare enum RenderMode {
8
- volumetric = "volumetric",
9
- maxProject = "maxproject",
10
- pathTrace = "pathtrace"
11
- }
12
- export declare enum ImageType {
13
- segmentedCell = "cell",
14
- fullField = "fov"
15
- }
@@ -1 +0,0 @@
1
- export declare function clamp(value: number, min: number, max: number): number;