@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.
Files changed (72) hide show
  1. package/es/aics-image-viewer/components/App/index.js +15 -5
  2. package/es/aics-image-viewer/components/ChannelsWidget.js +3 -1
  3. package/es/aics-image-viewer/components/ChannelsWidgetRow.js +29 -16
  4. package/es/aics-image-viewer/components/ColorPicker/index.js +9 -1
  5. package/es/aics-image-viewer/components/ControlPanel/CopySettingsButton.js +445 -0
  6. package/es/aics-image-viewer/components/ControlPanel/index.js +16 -5
  7. package/es/aics-image-viewer/components/ControlPanel/styles.css +29 -2
  8. package/es/aics-image-viewer/components/StyleProvider/index.js +17 -2
  9. package/es/aics-image-viewer/components/Toolbar/ViewModeRadioButtons.js +1 -1
  10. package/es/aics-image-viewer/components/Toolbar/index.js +1 -1
  11. package/es/aics-image-viewer/components/Toolbar/styles.css +0 -10
  12. package/es/aics-image-viewer/components/{CellViewerCanvasWrapper → ViewerCanvasWrapper}/index.js +3 -2
  13. package/es/aics-image-viewer/components/dimension_sliders/AxisClipSliders.js +21 -8
  14. package/es/aics-image-viewer/components/dimension_sliders/RotationSliders.js +6 -8
  15. package/es/aics-image-viewer/components/dimension_sliders/SliderRows.js +8 -6
  16. package/es/aics-image-viewer/components/shared/ContextualAlert.js +101 -0
  17. package/es/aics-image-viewer/components/shared/ControlPanelRow/index.js +4 -2
  18. package/es/aics-image-viewer/components/shared/ControlPanelRow/styles.css +4 -3
  19. package/es/aics-image-viewer/components/useVolume.js +59 -25
  20. package/es/aics-image-viewer/shared/constants.js +25 -1
  21. package/es/aics-image-viewer/shared/types.js +1 -1
  22. package/es/aics-image-viewer/shared/utils/controlPointsToLut.js +4 -0
  23. package/es/aics-image-viewer/shared/utils/parseSnapshot.js +205 -0
  24. package/es/aics-image-viewer/shared/utils/{urlParsing.js → parseUrl.js} +55 -191
  25. package/es/aics-image-viewer/shared/utils/permissions.js +46 -0
  26. package/es/aics-image-viewer/shared/utils/test/camera.test.js +1 -2
  27. package/es/aics-image-viewer/shared/utils/test/{urlParsing.test.js → parseUrl.test.js} +28 -25
  28. package/es/aics-image-viewer/shared/utils/test/storage.test.js +2 -2
  29. package/es/aics-image-viewer/shared/utils/test/viewerChannelSettings.test.js +1 -1
  30. package/es/aics-image-viewer/state/deserialize.js +443 -331
  31. package/es/aics-image-viewer/state/reset.js +1 -1
  32. package/es/aics-image-viewer/state/serialize.js +168 -78
  33. package/es/aics-image-viewer/state/subscribers.js +1 -1
  34. package/es/aics-image-viewer/state/test/deserialize.test.js +63 -77
  35. package/es/aics-image-viewer/state/test/reset.test.js +2 -2
  36. package/es/aics-image-viewer/state/test/serialize.test.js +42 -43
  37. package/es/aics-image-viewer/state/test/test_data.js +119 -1
  38. package/es/aics-image-viewer/state/types.js +157 -245
  39. package/es/aics-image-viewer/state/util.js +39 -1
  40. package/es/index.js +4 -2
  41. package/package.json +26 -44
  42. package/type-declarations/aics-image-viewer/components/App/types.d.ts +3 -3
  43. package/type-declarations/aics-image-viewer/components/ChannelsWidget.d.ts +3 -0
  44. package/type-declarations/aics-image-viewer/components/ChannelsWidgetRow.d.ts +3 -0
  45. package/type-declarations/aics-image-viewer/components/ControlPanel/CopySettingsButton.d.ts +11 -0
  46. package/type-declarations/aics-image-viewer/components/Toolbar/ViewModeRadioButtons.d.ts +1 -1
  47. package/type-declarations/aics-image-viewer/components/{CellViewerCanvasWrapper → ViewerCanvasWrapper}/index.d.ts +4 -3
  48. package/type-declarations/aics-image-viewer/components/dimension_sliders/AxisClipSliders.d.ts +7 -6
  49. package/type-declarations/aics-image-viewer/components/dimension_sliders/SliderRows.d.ts +1 -2
  50. package/type-declarations/aics-image-viewer/components/shared/ContextualAlert.d.ts +29 -0
  51. package/type-declarations/aics-image-viewer/components/shared/ControlPanelRow/index.d.ts +1 -0
  52. package/type-declarations/aics-image-viewer/components/useVolume.d.ts +3 -0
  53. package/type-declarations/aics-image-viewer/shared/constants.d.ts +2 -2
  54. package/type-declarations/aics-image-viewer/shared/types.d.ts +2 -2
  55. package/type-declarations/aics-image-viewer/shared/utils/controlPointsToLut.d.ts +1 -1
  56. package/type-declarations/aics-image-viewer/shared/utils/parseSnapshot.d.ts +49 -0
  57. package/type-declarations/aics-image-viewer/shared/utils/{urlParsing.d.ts → parseUrl.d.ts} +3 -24
  58. package/type-declarations/aics-image-viewer/shared/utils/permissions.d.ts +7 -0
  59. package/type-declarations/aics-image-viewer/shared/utils/viewerChannelSettings.d.ts +1 -1
  60. package/type-declarations/aics-image-viewer/state/deserialize.d.ts +70 -35
  61. package/type-declarations/aics-image-viewer/state/reset.d.ts +1 -1
  62. package/type-declarations/aics-image-viewer/state/serialize.d.ts +44 -10
  63. package/type-declarations/aics-image-viewer/state/types.d.ts +265 -159
  64. package/type-declarations/aics-image-viewer/state/util.d.ts +3 -1
  65. package/type-declarations/index.d.ts +5 -3
  66. package/es/Globals.d.js +0 -0
  67. package/es/aics-image-viewer/shared/enums.js +0 -18
  68. package/es/aics-image-viewer/shared/utils/firebase/index.js +0 -109
  69. package/type-declarations/aics-image-viewer/shared/enums.d.ts +0 -15
  70. package/type-declarations/aics-image-viewer/shared/utils/firebase/index.d.ts +0 -69
  71. package/type-declarations/aics-image-viewer/shared/utils/math.d.ts +0 -1
  72. /package/es/aics-image-viewer/components/{CellViewerCanvasWrapper → ViewerCanvasWrapper}/styles.css +0 -0
@@ -11,8 +11,8 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
11
11
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
12
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
13
  import { getDefaultCameraState, getDefaultChannelColor, getDefaultChannelState, getDefaultViewerState } from "../shared/constants";
14
- import { ViewMode } from "../shared/enums";
15
14
  import { getEnabledChannelIndices, initializeOneChannelSetting } from "../shared/utils/viewerState";
15
+ import { ViewMode } from "./types";
16
16
  import { validateState } from "./util";
17
17
  var resetState = function resetState(currentState, newState, newChannelStates) {
18
18
  var channelSettings = currentState.channelSettings,
@@ -1,15 +1,29 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
5
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
2
6
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
3
7
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
4
8
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5
- import { isEqual } from "lodash";
9
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
10
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
12
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
13
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
14
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
15
+ import { identity, isEqual } from "lodash";
6
16
  import { getDefaultCameraState, getDefaultChannelState, getDefaultViewerState } from "../shared/constants";
7
- import { ViewMode } from "../shared/enums";
8
17
  import { removeMatchingProperties, removeUndefinedProperties } from "../shared/utils/datatypes";
9
- import { CameraTransformKeys, ViewerChannelSettingKeys, ViewerStateKeys } from "./types";
18
+ import { CameraTransformKeys, ChannelStateSnapshotKeys, ImageType, ImageTypeSnapshot, RenderMode, RenderModeSnapshot, ViewerStateSnapshotKeys, ViewMode, ViewModeSnapshot } from "./types";
10
19
  var ENCODED_COLON_REGEX = /%3A/g;
11
20
  var DEFAULT_CONTROL_POINT_COLOR = [255, 255, 255];
12
21
  var DEFAULT_CONTROL_POINT_COLOR_CODE = "1";
22
+
23
+ /**
24
+ * Serializes an object with `string` keys to a compact `string` representation, where keys and values are separated
25
+ * by colons (`:`) and entries are separated by commas (`,`).
26
+ */
13
27
  export function objectToKeyValueList(obj) {
14
28
  var keyValuePairs = [];
15
29
  for (var key in obj) {
@@ -23,11 +37,98 @@ export function objectToKeyValueList(obj) {
23
37
  }
24
38
  return keyValuePairs.join(",");
25
39
  }
40
+
41
+ // MARK: Snapshot
42
+
26
43
  function colorArrayToHex(color) {
27
44
  return color.map(function (c) {
28
45
  return c.toString(16).padStart(2, "0");
29
46
  }).join("").toLowerCase();
30
47
  }
48
+ var xyzToArray = function xyzToArray(_ref) {
49
+ var x = _ref.x,
50
+ y = _ref.y,
51
+ z = _ref.z;
52
+ return [x, y, z];
53
+ };
54
+
55
+ /**
56
+ * Converts a `CameraState` to a `CameraStateSnapshot`, suitable for serialization.
57
+ * @param cameraState The camera state to serialize.
58
+ * @param removeDefaults Whether to remove default values.
59
+ * @param viewMode The current view mode. Default `ViewMode.threeD`.
60
+ * @returns The resulting `CameraStateSnapshot`, or `undefined` if all values are default.
61
+ */
62
+ export function cameraStateToSnapshot(cameraState, removeDefaults) {
63
+ var viewMode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ViewMode.threeD;
64
+ if (cameraState === undefined) {
65
+ return undefined;
66
+ }
67
+
68
+ // Note that we use the `getDefaultCameraState()` to get the defaults here,
69
+ // instead of `getDefaultViewerState().cameraState`. The latter is undefined, which signals
70
+ // that the camera should not be modified for URLs that don't specify it.
71
+ var modifiedState = removeDefaults ? removeMatchingProperties(cameraState, getDefaultCameraState(viewMode)) : cameraState;
72
+ var snapshot = removeUndefinedProperties(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, CameraTransformKeys.Position, modifiedState.position && _toConsumableArray(modifiedState.position)), CameraTransformKeys.Target, modifiedState.target && _toConsumableArray(modifiedState.target)), CameraTransformKeys.Up, modifiedState.up && _toConsumableArray(modifiedState.up)), CameraTransformKeys.OrthoScale, modifiedState.orthoScale), CameraTransformKeys.Fov, modifiedState.fov));
73
+ if (Object.keys(snapshot).length === 0) {
74
+ return undefined;
75
+ }
76
+ return snapshot;
77
+ }
78
+ function controlPointToSnapshot(controlPoint) {
79
+ return {
80
+ x: controlPoint.x,
81
+ opacity: controlPoint.opacity,
82
+ color: isEqual(controlPoint.color, DEFAULT_CONTROL_POINT_COLOR) ? DEFAULT_CONTROL_POINT_COLOR_CODE : colorArrayToHex(controlPoint.color)
83
+ };
84
+ }
85
+ var VIEW_MODE_TO_SNAPSHOT = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ViewMode.threeD, ViewModeSnapshot.threeD), ViewMode.xy, ViewModeSnapshot.xy), ViewMode.xz, ViewModeSnapshot.xz), ViewMode.yz, ViewModeSnapshot.yz);
86
+ var RENDER_MODE_TO_SNAPSHOT = _defineProperty(_defineProperty(_defineProperty({}, RenderMode.volumetric, RenderModeSnapshot.volumetric), RenderMode.maxProject, RenderModeSnapshot.maxProject), RenderMode.pathTrace, RenderModeSnapshot.pathTrace);
87
+ var IMAGE_TYPE_TO_SNAPSHOT = _defineProperty(_defineProperty({}, ImageType.segmentedCell, ImageTypeSnapshot.segmentedCell), ImageType.fullField, ImageTypeSnapshot.fullField);
88
+
89
+ /**
90
+ * Converts a `ViewerState` to a `ViewerStateSnapshot`, suitable for serialization.
91
+ */
92
+ export function viewerStateToSnapshot(state, removeDefaults) {
93
+ var _result;
94
+ var s = state;
95
+ if (removeDefaults) {
96
+ s = removeMatchingProperties(state, getDefaultViewerState());
97
+ // special case: if there's an explicit scale level but it's not being used, no reason to include it
98
+ if (s.scaleLevelIndex !== undefined && state.useExactScaleLevel === undefined) {
99
+ delete s.scaleLevelIndex;
100
+ }
101
+ }
102
+ var result = (_result = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_result, ViewerStateSnapshotKeys.View, s.viewMode && VIEW_MODE_TO_SNAPSHOT[s.viewMode]), ViewerStateSnapshotKeys.Mode, s.renderMode && RENDER_MODE_TO_SNAPSHOT[s.renderMode]), ViewerStateSnapshotKeys.MaskOpacity, s.maskAlpha), ViewerStateSnapshotKeys.ImageType, s.imageType && IMAGE_TYPE_TO_SNAPSHOT[s.imageType]), ViewerStateSnapshotKeys.ShowAxes, s.showAxes), ViewerStateSnapshotKeys.ShowBoundingBox, s.showBoundingBox), ViewerStateSnapshotKeys.BoundingBoxColor, s.boundingBoxColor && colorArrayToHex(s.boundingBoxColor)), ViewerStateSnapshotKeys.BackgroundColor, s.backgroundColor && colorArrayToHex(s.backgroundColor)), ViewerStateSnapshotKeys.Autorotate, s.autorotate), ViewerStateSnapshotKeys.Brightness, s.brightness), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_result, ViewerStateSnapshotKeys.Density, s.density), ViewerStateSnapshotKeys.Interpolation, s.interpolationEnabled), ViewerStateSnapshotKeys.Region, s.region && xyzToArray(s.region)), ViewerStateSnapshotKeys.Slice, s.slice && xyzToArray(s.slice)), ViewerStateSnapshotKeys.Levels, s.levels && _toConsumableArray(s.levels)), ViewerStateSnapshotKeys.Time, s.time), ViewerStateSnapshotKeys.Scene, s.scene), ViewerStateSnapshotKeys.SingleChannelMode, s.singleChannelMode), ViewerStateSnapshotKeys.SingleChannelIndex, s.singleChannelIndex), ViewerStateSnapshotKeys.UseExactScaleLevel, s.useExactScaleLevel), _defineProperty(_defineProperty(_result, ViewerStateSnapshotKeys.ScaleLevelIndex, s.scaleLevelIndex), ViewerStateSnapshotKeys.CameraState, cameraStateToSnapshot(s.cameraState, removeDefaults, s.viewMode)));
103
+ return removeUndefinedProperties(result);
104
+ }
105
+ export function channelStateToSnapshot(state, removeDefaults) {
106
+ var _result2;
107
+ var s = removeDefaults ? removeMatchingProperties(state, getDefaultChannelState()) : state;
108
+ var result = (_result2 = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_result2, ChannelStateSnapshotKeys.VolumeEnabled, s.volumeEnabled), ChannelStateSnapshotKeys.SurfaceEnabled, s.isosurfaceEnabled), ChannelStateSnapshotKeys.IsosurfaceValue, s.isovalue), ChannelStateSnapshotKeys.IsosurfaceAlpha, s.opacity), ChannelStateSnapshotKeys.Colorize, s.colorizeEnabled), ChannelStateSnapshotKeys.ColorizeAlpha, s.colorizeAlpha), ChannelStateSnapshotKeys.Color, s.color && colorArrayToHex(s.color)), ChannelStateSnapshotKeys.ControlPoints, s.controlPoints && s.controlPoints.map(controlPointToSnapshot)), ChannelStateSnapshotKeys.ControlPointsEnabled, s.useControlPoints), ChannelStateSnapshotKeys.Ramp, s.ramp && _toConsumableArray(s.ramp)), _defineProperty(_result2, ChannelStateSnapshotKeys.KeepRange, s.keepIntensityRange));
109
+ return removeUndefinedProperties(result);
110
+ }
111
+
112
+ // MARK: Stringify
113
+
114
+ /**
115
+ * Helper function for converting all keys of an object to `string` representations.
116
+ *
117
+ * Accepts an object of the input type, and a map of stringifiers for each of the input type's properties.
118
+ */
119
+ var stringify = function stringify(record, stringifiers) {
120
+ var result = {};
121
+ for (var _i = 0, _Object$keys = Object.keys(record); _i < _Object$keys.length; _i++) {
122
+ var k = _Object$keys[_i];
123
+ var key = k;
124
+ var value = record[key];
125
+ var stringifier = stringifiers[key];
126
+ if (value !== undefined && stringifier !== undefined) {
127
+ result[key] = stringifier(value);
128
+ }
129
+ }
130
+ return result;
131
+ };
31
132
 
32
133
  /**
33
134
  * Formats a float or integer value to a string with a maximum precision for float values.
@@ -53,93 +154,82 @@ function formatFloat(value) {
53
154
  }
54
155
  return Number(value.toPrecision(maxPrecision)).toString();
55
156
  }
56
- function perAxisToArray(perAxis) {
57
- return [perAxis.x, perAxis.y, perAxis.z];
58
- }
59
-
60
- /** Serializes a region into a `x1:x2,y1:y2,z1:z2` string format. */
61
- function serializeRegion(region) {
62
- return perAxisToArray(region).map(function (axis) {
63
- return axis.map(function (val) {
64
- return formatFloat(val);
65
- }).join(":");
66
- }).join(",");
67
- }
68
-
69
- /** Serializes a slice parameter into a `x,y,z` string format. */
70
- function serializeSlice(slice) {
71
- return perAxisToArray(slice).map(function (val) {
72
- return formatFloat(val);
73
- }).join(",");
74
- }
75
- function serializeBoolean(value) {
76
- if (value === undefined) {
77
- return undefined;
78
- }
157
+ var stringifyBoolean = function stringifyBoolean(value) {
79
158
  return value ? "1" : "0";
80
- }
81
- export function serializeCameraState(cameraState, removeDefaults) {
82
- var viewMode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ViewMode.threeD;
83
- if (removeDefaults) {
84
- // Note that we use the `getDefaultCameraState()` to get the defaults here,
85
- // instead of `getDefaultViewerState().cameraState`. The latter is undefined, which signals
86
- // that the camera should not be modified for URLs that don't specify it.
87
- cameraState = removeMatchingProperties(cameraState, getDefaultCameraState(viewMode));
88
- if (Object.keys(cameraState).length === 0) {
89
- return undefined;
90
- }
91
- }
92
- var cameraString = objectToKeyValueList(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, CameraTransformKeys.Position, cameraState.position && cameraState.position.map(function (value) {
93
- return formatFloat(value);
94
- }).join(":")), CameraTransformKeys.Target, cameraState.target && cameraState.target.map(function (value) {
159
+ };
160
+ var stringifyNumberList = function stringifyNumberList(list) {
161
+ var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ":";
162
+ return list.map(function (value) {
95
163
  return formatFloat(value);
96
- }).join(":")), CameraTransformKeys.Up, cameraState.up && cameraState.up.map(function (value) {
97
- return formatFloat(value);
98
- }).join(":")), CameraTransformKeys.OrthoScale, cameraState.orthoScale === undefined ? undefined : formatFloat(cameraState.orthoScale)), CameraTransformKeys.Fov, cameraState.fov === undefined ? undefined : formatFloat(cameraState.fov)));
99
- return cameraString === "" ? undefined : cameraString;
100
- }
101
- function serializeControlPoints(controlPoints) {
164
+ }).join(separator);
165
+ };
166
+ function stringifyControlPointSnapshots(controlPoints) {
102
167
  return controlPoints.map(function (cp) {
103
- var x = formatFloat(cp.x);
104
- var opacity = formatFloat(cp.opacity);
105
- // Default control-point color is encoded as DEFAULT_CONTROL_POINT_COLOR_CODE ("1").
106
- var color = isEqual(cp.color, DEFAULT_CONTROL_POINT_COLOR) ? DEFAULT_CONTROL_POINT_COLOR_CODE : colorArrayToHex(cp.color);
107
- return "".concat(x, ":").concat(opacity, ":").concat(color);
168
+ return "".concat(formatFloat(cp.x), ":").concat(formatFloat(cp.opacity), ":").concat(cp.color);
108
169
  }).join(":");
109
170
  }
110
171
 
111
172
  /**
112
- * Serializes a single viewer channel setting into a dictionary of URL parameters
113
- * (`ViewerChannelStateParams`).
173
+ * Converts all keys of a `CameraStateSnapshot` to compact `string` representations,
174
+ * for serialization to `string` formats.
175
+ */
176
+ export var stringifyCameraStateSnapshot = function stringifyCameraStateSnapshot(snapshot) {
177
+ return stringify(snapshot, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, CameraTransformKeys.Position, stringifyNumberList), CameraTransformKeys.Target, stringifyNumberList), CameraTransformKeys.Up, stringifyNumberList), CameraTransformKeys.OrthoScale, formatFloat), CameraTransformKeys.Fov, formatFloat));
178
+ };
179
+
180
+ /**
181
+ * Converts all keys of a `ViewerStateSnapshot` to compact `string` representations,
182
+ * for serialization to `string` formats.
183
+ */
184
+ export var stringifyViewerStateSnapshot = function stringifyViewerStateSnapshot(snapshot) {
185
+ var _stringify2;
186
+ return stringify(snapshot, (_stringify2 = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_stringify2, ViewerStateSnapshotKeys.View, identity), ViewerStateSnapshotKeys.Mode, identity), ViewerStateSnapshotKeys.MaskOpacity, formatFloat), ViewerStateSnapshotKeys.ImageType, identity), ViewerStateSnapshotKeys.ShowAxes, stringifyBoolean), ViewerStateSnapshotKeys.ShowBoundingBox, stringifyBoolean), ViewerStateSnapshotKeys.BoundingBoxColor, identity), ViewerStateSnapshotKeys.BackgroundColor, identity), ViewerStateSnapshotKeys.Autorotate, stringifyBoolean), ViewerStateSnapshotKeys.Brightness, formatFloat), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_stringify2, ViewerStateSnapshotKeys.Density, formatFloat), ViewerStateSnapshotKeys.Interpolation, stringifyBoolean), ViewerStateSnapshotKeys.Region, function (value) {
187
+ return value.map(function (axis) {
188
+ return stringifyNumberList(axis);
189
+ }).join(",");
190
+ }), ViewerStateSnapshotKeys.Slice, function (value) {
191
+ return stringifyNumberList(value, ",");
192
+ }), ViewerStateSnapshotKeys.Levels, function (value) {
193
+ return stringifyNumberList(value, ",");
194
+ }), ViewerStateSnapshotKeys.Time, formatFloat), ViewerStateSnapshotKeys.Scene, formatFloat), ViewerStateSnapshotKeys.SingleChannelMode, stringifyBoolean), ViewerStateSnapshotKeys.SingleChannelIndex, formatFloat), ViewerStateSnapshotKeys.UseExactScaleLevel, stringifyBoolean), _defineProperty(_defineProperty(_stringify2, ViewerStateSnapshotKeys.ScaleLevelIndex, formatFloat), ViewerStateSnapshotKeys.CameraState, function (value) {
195
+ return objectToKeyValueList(stringifyCameraStateSnapshot(value));
196
+ })));
197
+ };
198
+
199
+ /**
200
+ * Converts all keys of a `ChannelStateSnapshot` to compact `string` representations,
201
+ * for serialization to `string` formats.
202
+ */
203
+ export var stringifyChannelStateSnapshot = function stringifyChannelStateSnapshot(snapshot) {
204
+ var _stringify3;
205
+ return stringify(snapshot, (_stringify3 = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_stringify3, ChannelStateSnapshotKeys.Color, identity), ChannelStateSnapshotKeys.Colorize, stringifyBoolean), ChannelStateSnapshotKeys.ColorizeAlpha, formatFloat), ChannelStateSnapshotKeys.IsosurfaceAlpha, formatFloat), ChannelStateSnapshotKeys.Lut, function (_ref2) {
206
+ var _ref3 = _slicedToArray(_ref2, 2),
207
+ min = _ref3[0],
208
+ max = _ref3[1];
209
+ return "".concat(min, ":").concat(max);
210
+ }), ChannelStateSnapshotKeys.ControlPoints, stringifyControlPointSnapshots), ChannelStateSnapshotKeys.ControlPointsLegacy, stringifyControlPointSnapshots), ChannelStateSnapshotKeys.Ramp, stringifyNumberList), ChannelStateSnapshotKeys.RampLegacy, stringifyNumberList), ChannelStateSnapshotKeys.ControlPointsEnabled, stringifyBoolean), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_stringify3, ChannelStateSnapshotKeys.VolumeEnabled, stringifyBoolean), ChannelStateSnapshotKeys.SurfaceEnabled, stringifyBoolean), ChannelStateSnapshotKeys.IsosurfaceValue, formatFloat), ChannelStateSnapshotKeys.KeepRange, stringifyBoolean)));
211
+ };
212
+
213
+ /**
214
+ * Converts a single viewer channel setting into a `ChannelStateStringified`.
215
+ *
216
+ * This is equivalent to (and implemented by) applying `channelStateToSnapshot`, then `stringifyChannelStateSnapshot`.
114
217
  * @param channelSetting The channel state object to serialize.
115
218
  * @param removeDefaults Whether to remove properties that match the output of `getDefaultChannelState`.
116
- * @returns A `ViewerChannelSettingParams` object with the serialized parameters. Undefined values are removed.
219
+ * @returns A `ChannelStateStringified` object with the serialized parameters. `undefined` values are removed.
117
220
  */
118
- export function serializeViewerChannelSetting(channelSetting, removeDefaults) {
119
- var _channelSetting$isova, _channelSetting$opaci, _channelSetting$color, _channelSetting$ramp, _removeUndefinedPrope;
120
- if (removeDefaults) {
121
- channelSetting = removeMatchingProperties(channelSetting, getDefaultChannelState());
122
- }
123
- return removeUndefinedProperties((_removeUndefinedPrope = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_removeUndefinedPrope, ViewerChannelSettingKeys.VolumeEnabled, serializeBoolean(channelSetting.volumeEnabled)), ViewerChannelSettingKeys.SurfaceEnabled, serializeBoolean(channelSetting.isosurfaceEnabled)), ViewerChannelSettingKeys.IsosurfaceValue, (_channelSetting$isova = channelSetting.isovalue) === null || _channelSetting$isova === void 0 ? void 0 : _channelSetting$isova.toString()), ViewerChannelSettingKeys.IsosurfaceAlpha, (_channelSetting$opaci = channelSetting.opacity) === null || _channelSetting$opaci === void 0 ? void 0 : _channelSetting$opaci.toString()), ViewerChannelSettingKeys.Colorize, serializeBoolean(channelSetting.colorizeEnabled)), ViewerChannelSettingKeys.ColorizeAlpha, (_channelSetting$color = channelSetting.colorizeAlpha) === null || _channelSetting$color === void 0 ? void 0 : _channelSetting$color.toString()), ViewerChannelSettingKeys.Color, channelSetting.color && colorArrayToHex(channelSetting.color)), ViewerChannelSettingKeys.ControlPoints, channelSetting.controlPoints && serializeControlPoints(channelSetting.controlPoints)), ViewerChannelSettingKeys.ControlPointsEnabled, serializeBoolean(channelSetting.useControlPoints)), ViewerChannelSettingKeys.Ramp, (_channelSetting$ramp = channelSetting.ramp) === null || _channelSetting$ramp === void 0 ? void 0 : _channelSetting$ramp.join(":")), _defineProperty(_removeUndefinedPrope, ViewerChannelSettingKeys.KeepRange, serializeBoolean(channelSetting.keepIntensityRange))));
124
- }
221
+ export var channelStateToStringSnapshot = function channelStateToStringSnapshot(channelSetting, removeDefaults) {
222
+ return stringifyChannelStateSnapshot(channelStateToSnapshot(channelSetting, removeDefaults));
223
+ };
125
224
 
126
225
  /**
127
- * Serializes a `ViewerState` object into a dictionary of URL parameters.
226
+ * Serializes a `ViewerState` object into a `ViewerStateStringified`.
227
+ *
228
+ * This is equivalent to (and implemented by) applying `viewerStateToSnapshot`, then `stringifyViewerStateSnapshot`.
128
229
  * @param state The `ViewerState` to serialize.
129
230
  * @param removeDefaults If true, remove properties that match the output of `getDefaultViewerState`.
130
- * @returns A `ViewerStateParams` object with the serialized parameters. Undefined values are removed.
231
+ * @returns A `ViewerStateStringified` object with the serialized parameters. `undefined` values are removed.
131
232
  */
132
- export function serializeViewerState(state, removeDefaults) {
133
- var _state$maskAlpha, _state$brightness, _state$density, _state$levels, _state$time, _state$scene, _state$singleChannelI, _state$scaleLevelInde, _result;
134
- if (removeDefaults) {
135
- state = removeMatchingProperties(state, getDefaultViewerState());
136
- // special case: if there's an explicit scale level but it's not being used, no reason to include it
137
- if (state.scaleLevelIndex !== undefined && state.useExactScaleLevel === undefined) {
138
- delete state.scaleLevelIndex;
139
- }
140
- }
141
- var result = (_result = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_result, ViewerStateKeys.Mode, state.renderMode), ViewerStateKeys.Mask, (_state$maskAlpha = state.maskAlpha) === null || _state$maskAlpha === void 0 ? void 0 : _state$maskAlpha.toString()), ViewerStateKeys.Image, state.imageType), ViewerStateKeys.Axes, serializeBoolean(state.showAxes)), ViewerStateKeys.BoundingBox, serializeBoolean(state.showBoundingBox)), ViewerStateKeys.BoundingBoxColor, state.boundingBoxColor && colorArrayToHex(state.boundingBoxColor)), ViewerStateKeys.BackgroundColor, state.backgroundColor && colorArrayToHex(state.backgroundColor)), ViewerStateKeys.Autorotate, serializeBoolean(state.autorotate)), ViewerStateKeys.Brightness, (_state$brightness = state.brightness) === null || _state$brightness === void 0 ? void 0 : _state$brightness.toString()), ViewerStateKeys.Density, (_state$density = state.density) === null || _state$density === void 0 ? void 0 : _state$density.toString()), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_result, ViewerStateKeys.Interpolation, serializeBoolean(state.interpolationEnabled)), ViewerStateKeys.Region, state.region && serializeRegion(state.region)), ViewerStateKeys.Slice, state.slice && serializeSlice(state.slice)), ViewerStateKeys.Levels, (_state$levels = state.levels) === null || _state$levels === void 0 ? void 0 : _state$levels.join(",")), ViewerStateKeys.Time, (_state$time = state.time) === null || _state$time === void 0 ? void 0 : _state$time.toString()), ViewerStateKeys.Scene, (_state$scene = state.scene) === null || _state$scene === void 0 ? void 0 : _state$scene.toString()), ViewerStateKeys.SingleChannelMode, serializeBoolean(state.singleChannelMode)), ViewerStateKeys.SingleChannelIndex, (_state$singleChannelI = state.singleChannelIndex) === null || _state$singleChannelI === void 0 ? void 0 : _state$singleChannelI.toString()), ViewerStateKeys.UseExactScaleLevel, serializeBoolean(state.useExactScaleLevel)), ViewerStateKeys.ScaleLevelIndex, (_state$scaleLevelInde = state.scaleLevelIndex) === null || _state$scaleLevelInde === void 0 ? void 0 : _state$scaleLevelInde.toString()), _defineProperty(_result, ViewerStateKeys.CameraState, state.cameraState && serializeCameraState(state.cameraState, removeDefaults, state.viewMode)));
142
- var viewModeToViewParam = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ViewMode.threeD, "3D"), ViewMode.xy, "Z"), ViewMode.xz, "Y"), ViewMode.yz, "X");
143
- result[ViewerStateKeys.View] = state.viewMode && viewModeToViewParam[state.viewMode];
144
- return removeUndefinedProperties(result);
145
- }
233
+ export var viewerStateToStringSnapshot = function viewerStateToStringSnapshot(state, removeDefaults) {
234
+ return stringifyViewerStateSnapshot(viewerStateToSnapshot(state, removeDefaults));
235
+ };
@@ -6,11 +6,11 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
6
6
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
7
7
  import { RENDERMODE_PATHTRACE, RENDERMODE_RAYMARCH } from "@aics/vole-core";
8
8
  import { shallow } from "zustand/shallow";
9
- import { RenderMode, ViewMode } from "../shared/enums";
10
9
  import { activeAxisMap } from "../shared/types";
11
10
  import { colorArrayToFloats } from "../shared/utils/colorRepresentations";
12
11
  import { alphaSliderToImageValue, brightnessSliderToImageValue, densitySliderToImageValue, gammaSliderToImageValues } from "../shared/utils/sliderValuesToImageValues";
13
12
  import { select } from "./store";
13
+ import { RenderMode, ViewMode } from "./types";
14
14
  var REF_EQ = {
15
15
  fireImmediately: true
16
16
  };
@@ -10,11 +10,11 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
10
10
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
11
11
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
12
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
- import { describe, expect, it } from "@jest/globals";
14
- import { RenderMode, ViewMode } from "../../shared/enums";
15
- import { CONTROL_POINTS_REGEX, deserializeChannelState, deserializeViewerChannelSetting, deserializeViewerState, LEGACY_CONTROL_POINTS_REGEX, parseHexColorAsColorArray, parseKeyValueList, parseStringEnum, parseStringFloat, parseStringInt } from "../deserialize";
16
- import { serializeViewerState } from "../serialize";
17
- import { CUSTOM_TEST_VIEWER_STATE, DEFAULT_TEST_VIEWER_CHANNEL_SETTING, DEFAULT_TEST_VIEWER_STATE, SERIALIZED_CUSTOM_TEST_VIEWER_STATE, SERIALIZED_DEFAULT_TEST_VIEWER_STATE } from "./test_data";
13
+ import { describe, expect, it } from "vitest";
14
+ import { CONTROL_POINTS_REGEX, enumParser, LEGACY_CONTROL_POINTS_REGEX, parseHexColorAsColorArray, parseKeyValueList, stringSnapshotToChannelState, stringSnapshotToViewerChannelSetting, stringSnapshotToViewerState, validateInt, validateNumber } from "../deserialize";
15
+ import { viewerStateToStringSnapshot } from "../serialize";
16
+ import { RenderMode, ViewMode } from "../types";
17
+ import { CUSTOM_TEST_VIEWER_STATE, DEFAULT_TEST_VIEWER_CHANNEL_SETTING, DEFAULT_TEST_VIEWER_STATE, STRINGIFIED_CUSTOM_TEST_VIEWER_STATE, STRINGIFIED_DEFAULT_TEST_VIEWER_STATE } from "./test_data";
18
18
 
19
19
  //// VALUE PARSING ////////////////////////////////////////
20
20
 
@@ -129,67 +129,53 @@ describe("parseHexColorAsColorArray", function () {
129
129
  expect(parseHexColorAsColorArray("1")).toEqual([255, 255, 255]);
130
130
  });
131
131
  });
132
- describe("parseStringEnum", function () {
132
+ describe("enumParser", function () {
133
133
  var TestEnum = /*#__PURE__*/function (TestEnum) {
134
- TestEnum["SOME_VALUE"] = "some_value";
135
- TestEnum["ANOTHER_VALUE"] = "another_value";
134
+ TestEnum["SOME_VALUE"] = "someValue";
135
+ TestEnum["ANOTHER_VALUE"] = "anotherValue";
136
136
  return TestEnum;
137
137
  }({});
138
+ var parseTestEnum = enumParser(TestEnum);
138
139
  it("recognizes enum values", function () {
139
- expect(parseStringEnum("some_value", TestEnum)).toEqual(TestEnum.SOME_VALUE);
140
- expect(parseStringEnum("another_value", TestEnum)).toEqual(TestEnum.ANOTHER_VALUE);
140
+ expect(parseTestEnum("someValue")).toEqual(TestEnum.SOME_VALUE);
141
+ expect(parseTestEnum("anotherValue")).toEqual(TestEnum.ANOTHER_VALUE);
141
142
  });
142
- it("returns default values for unrecognized enum values", function () {
143
- expect(parseStringEnum("unexpected", TestEnum, undefined)).toEqual(undefined);
144
- expect(parseStringEnum("unexpected", TestEnum, TestEnum.SOME_VALUE)).toEqual(TestEnum.SOME_VALUE);
143
+ it("recognizes lowercase enum values", function () {
144
+ expect(parseTestEnum("somevalue")).toEqual(TestEnum.SOME_VALUE);
145
+ expect(parseTestEnum("anothervalue")).toEqual(TestEnum.ANOTHER_VALUE);
145
146
  });
146
147
  });
147
- describe("parseStringInt", function () {
148
- it("parses int and undefined values", function () {
149
- expect(parseStringInt("0", 0, 1000)).toEqual(0);
150
- expect(parseStringInt("1", 0, 1000)).toEqual(1);
151
- expect(parseStringInt("100", 0, 1000)).toEqual(100);
152
- expect(parseStringInt("255", 0, 1000)).toEqual(255);
153
- expect(parseStringInt("-1", -1000, 1000)).toEqual(-1);
154
- });
148
+ describe("validateInt", function () {
155
149
  it("returns undefined for undefined and NaN values", function () {
156
- expect(parseStringInt("bad", -1000, 1000)).toEqual(undefined);
157
- expect(parseStringInt("NaN", -1000, 1000)).toEqual(undefined);
158
- expect(parseStringInt(undefined, -1000, 1000)).toEqual(undefined);
150
+ expect(validateInt("bad", -1000, 1000)).toEqual(undefined);
151
+ expect(validateInt(NaN, -1000, 1000)).toEqual(undefined);
152
+ expect(validateInt(undefined, -1000, 1000)).toEqual(undefined);
159
153
  });
160
154
  it("casts float values to integers", function () {
161
- expect(parseStringInt("0.5", 0, 1000)).toEqual(0);
162
- expect(parseStringInt("99.5", 0, 1000)).toEqual(99);
163
- expect(parseStringInt("-10.5", -1000, 1000)).toEqual(-10);
155
+ expect(validateInt(0.5, 0, 1000)).toEqual(0);
156
+ expect(validateInt(99.5, 0, 1000)).toEqual(99);
157
+ expect(validateInt(-10.5, -1000, 1000)).toEqual(-10);
164
158
  });
165
159
  it("applies clamping", function () {
166
- expect(parseStringInt("0", 0, 255)).toEqual(0);
167
- expect(parseStringInt("-1", 0, 255)).toEqual(0);
168
- expect(parseStringInt("128", 0, 255)).toEqual(128);
169
- expect(parseStringInt("255", 0, 255)).toEqual(255);
170
- expect(parseStringInt("256", 0, 255)).toEqual(255);
160
+ expect(validateInt(0, 0, 255)).toEqual(0);
161
+ expect(validateInt(-1, 0, 255)).toEqual(0);
162
+ expect(validateInt(128, 0, 255)).toEqual(128);
163
+ expect(validateInt(255, 0, 255)).toEqual(255);
164
+ expect(validateInt(256, 0, 255)).toEqual(255);
171
165
  });
172
166
  });
173
- describe("parseStringFloat", function () {
174
- it("parses strings to float values", function () {
175
- expect(parseStringFloat("0", -1000, 1000)).toEqual(0);
176
- expect(parseStringFloat("1.0", -1000, 1000)).toEqual(1.0);
177
- expect(parseStringFloat("0.5", -1000, 1000)).toEqual(0.5);
178
- expect(parseStringFloat("128.5", -1000, 1000)).toEqual(128.5);
179
- expect(parseStringFloat("495.344", -1000, 1000)).toEqual(495.344);
180
- expect(parseStringFloat("-1", -1000, 1000)).toEqual(-1);
181
- });
167
+ describe("validateNumber", function () {
182
168
  it("returns undefined for NaN or undefined values", function () {
183
- expect(parseStringFloat("bad", -1000, 1000)).toEqual(undefined);
184
- expect(parseStringFloat("NaN", -1000, 1000)).toEqual(undefined);
185
- expect(parseStringFloat(undefined, -1000, 1000)).toEqual(undefined);
169
+ expect(validateNumber("bad", -1000, 1000)).toEqual(undefined);
170
+ expect(validateNumber(NaN, -1000, 1000)).toEqual(undefined);
171
+ expect(validateNumber(undefined, -1000, 1000)).toEqual(undefined);
186
172
  });
187
173
  it("applies clamping", function () {
188
- expect(parseStringFloat("0.5", 0, 1.0)).toEqual(0.5);
189
- expect(parseStringFloat("1.0", 0, 1.0)).toEqual(1.0);
190
- expect(parseStringFloat("1.1", 0, 1.0)).toEqual(1.0);
191
- expect(parseStringFloat("0", 0, 1.0)).toEqual(0);
192
- expect(parseStringFloat("-0.1", 0, 1.0)).toEqual(0);
174
+ expect(validateNumber(0.5, 0, 1.0)).toEqual(0.5);
175
+ expect(validateNumber(1.0, 0, 1.0)).toEqual(1.0);
176
+ expect(validateNumber(1.1, 0, 1.0)).toEqual(1.0);
177
+ expect(validateNumber(0, 0, 1.0)).toEqual(0);
178
+ expect(validateNumber(-0.1, 0, 1.0)).toEqual(0);
193
179
  });
194
180
  });
195
181
 
@@ -203,10 +189,10 @@ describe("parseStringFloat", function () {
203
189
  // input into the viewer and support grouping/matching to multiple channels.
204
190
  // TODO: refactor these to all be the same state?
205
191
 
206
- describe("deserializeViewerChannelSetting", function () {
192
+ describe("stringSnapshotToViewerChannelSetting", function () {
207
193
  it("returns default settings for empty objects", function () {
208
194
  var data = {};
209
- var result = deserializeViewerChannelSetting(0, data);
195
+ var result = stringSnapshotToViewerChannelSetting(0, data);
210
196
  expect(result).toEqual(DEFAULT_TEST_VIEWER_CHANNEL_SETTING);
211
197
  });
212
198
  it("ignores unexpected keys", function () {
@@ -215,7 +201,7 @@ describe("deserializeViewerChannelSetting", function () {
215
201
  ven: "1",
216
202
  sen: "1"
217
203
  };
218
- var result = deserializeViewerChannelSetting(0, data);
204
+ var result = stringSnapshotToViewerChannelSetting(0, data);
219
205
  expect(result).toEqual(_objectSpread(_objectSpread({}, DEFAULT_TEST_VIEWER_CHANNEL_SETTING), {}, {
220
206
  enabled: true,
221
207
  surfaceEnabled: true
@@ -232,7 +218,7 @@ describe("deserializeViewerChannelSetting", function () {
232
218
  isv: "128",
233
219
  lut: "0:255"
234
220
  };
235
- expect(deserializeViewerChannelSetting(0, data)).toEqual({
221
+ expect(stringSnapshotToViewerChannelSetting(0, data)).toEqual({
236
222
  match: 0,
237
223
  color: "FF0000",
238
224
  enabled: true,
@@ -257,7 +243,7 @@ describe("deserializeViewerChannelSetting", function () {
257
243
  var data = {
258
244
  lut: encodedLut
259
245
  };
260
- var result = deserializeViewerChannelSetting(0, data);
246
+ var result = stringSnapshotToViewerChannelSetting(0, data);
261
247
  expect((_result$intensity = result.intensity) === null || _result$intensity === void 0 ? void 0 : _result$intensity.lut).toEqual(decodedLut);
262
248
  }
263
249
  });
@@ -268,7 +254,7 @@ describe("deserializeViewerChannelSetting", function () {
268
254
  var data = {
269
255
  lut: lut
270
256
  };
271
- var result = deserializeViewerChannelSetting(0, data);
257
+ var result = stringSnapshotToViewerChannelSetting(0, data);
272
258
  expect(result.lut).toBeUndefined();
273
259
  }
274
260
  });
@@ -279,7 +265,7 @@ describe("deserializeViewerChannelSetting", function () {
279
265
  var data = {
280
266
  col: color
281
267
  };
282
- var result = deserializeViewerChannelSetting(0, data);
268
+ var result = stringSnapshotToViewerChannelSetting(0, data);
283
269
  expect(result.color).toEqual(color);
284
270
  }
285
271
  });
@@ -290,7 +276,7 @@ describe("deserializeViewerChannelSetting", function () {
290
276
  var data = {
291
277
  col: color
292
278
  };
293
- var result = deserializeViewerChannelSetting(0, data);
279
+ var result = stringSnapshotToViewerChannelSetting(0, data);
294
280
  expect(result.color).toBeUndefined();
295
281
  }
296
282
  });
@@ -300,15 +286,15 @@ describe("deserializeViewerChannelSetting", function () {
300
286
  isa: "bad",
301
287
  isv: "f8"
302
288
  };
303
- var result = deserializeViewerChannelSetting(0, data);
289
+ var result = stringSnapshotToViewerChannelSetting(0, data);
304
290
  expect(result.colorizeAlpha).toBeUndefined();
305
291
  expect(result.surfaceOpacity).toBeUndefined();
306
292
  expect(result.isovalue).toBeUndefined();
307
293
  });
308
294
  });
309
- describe("deserializeChannelState", function () {
295
+ describe("stringSnapshotToChannelState", function () {
310
296
  it("returns an empty object for empty input", function () {
311
- expect(deserializeChannelState({})).toEqual({});
297
+ expect(stringSnapshotToChannelState({})).toEqual({});
312
298
  });
313
299
  it("parses channel state fields", function () {
314
300
  var data = {
@@ -323,7 +309,7 @@ describe("deserializeChannelState", function () {
323
309
  cpe: "1",
324
310
  pin: "1"
325
311
  };
326
- expect(deserializeChannelState(data)).toEqual({
312
+ expect(stringSnapshotToChannelState(data)).toEqual({
327
313
  color: [255, 0, 0],
328
314
  colorizeEnabled: true,
329
315
  colorizeAlpha: 0.5,
@@ -343,7 +329,7 @@ describe("deserializeChannelState", function () {
343
329
  ram: "1:2",
344
330
  rmp: "3:4"
345
331
  };
346
- expect(deserializeChannelState(data)).toEqual({
332
+ expect(stringSnapshotToChannelState(data)).toEqual({
347
333
  controlPoints: [{
348
334
  x: 0,
349
335
  opacity: 0,
@@ -357,17 +343,17 @@ describe("deserializeChannelState", function () {
357
343
  });
358
344
  });
359
345
  });
360
- describe("deserializeViewerState", function () {
346
+ describe("stringSnapshotToViewerState", function () {
361
347
  it("returns an empty object for empty input", function () {
362
- expect(deserializeViewerState({})).toEqual({});
348
+ expect(stringSnapshotToViewerState({})).toEqual({});
363
349
  });
364
350
  it("deserializes the default viewer settings", function () {
365
- var params = SERIALIZED_DEFAULT_TEST_VIEWER_STATE;
366
- expect(deserializeViewerState(params)).toEqual(DEFAULT_TEST_VIEWER_STATE);
351
+ var params = STRINGIFIED_DEFAULT_TEST_VIEWER_STATE;
352
+ expect(stringSnapshotToViewerState(params)).toEqual(DEFAULT_TEST_VIEWER_STATE);
367
353
  });
368
354
  it("deserializes custom viewer settings", function () {
369
- var params = SERIALIZED_CUSTOM_TEST_VIEWER_STATE;
370
- expect(deserializeViewerState(params)).toEqual(CUSTOM_TEST_VIEWER_STATE);
355
+ var params = STRINGIFIED_CUSTOM_TEST_VIEWER_STATE;
356
+ expect(stringSnapshotToViewerState(params)).toEqual(CUSTOM_TEST_VIEWER_STATE);
371
357
  });
372
358
  it("handles all ViewMode values", function () {
373
359
  var viewModes = Object.values(ViewMode);
@@ -376,7 +362,7 @@ describe("deserializeViewerState", function () {
376
362
  var state = _objectSpread(_objectSpread({}, DEFAULT_TEST_VIEWER_STATE), {}, {
377
363
  viewMode: viewMode
378
364
  });
379
- expect(deserializeViewerState(serializeViewerState(state, false)).viewMode).toEqual(viewMode);
365
+ expect(stringSnapshotToViewerState(viewerStateToStringSnapshot(state, false)).viewMode).toEqual(viewMode);
380
366
  }
381
367
  });
382
368
  it("handles all RenderMode values", function () {
@@ -386,7 +372,7 @@ describe("deserializeViewerState", function () {
386
372
  var state = _objectSpread(_objectSpread({}, DEFAULT_TEST_VIEWER_STATE), {}, {
387
373
  renderMode: renderMode
388
374
  });
389
- expect(deserializeViewerState(serializeViewerState(state, false)).renderMode).toEqual(renderMode);
375
+ expect(stringSnapshotToViewerState(viewerStateToStringSnapshot(state, false)).renderMode).toEqual(renderMode);
390
376
  }
391
377
  });
392
378
  it("deserializes partial camera settings", function () {
@@ -398,7 +384,7 @@ describe("deserializeViewerState", function () {
398
384
  }
399
385
  };
400
386
  var serializedState = "pos:1:-1.4:45,up:0:1:0,fov:43.5";
401
- expect(deserializeViewerState({
387
+ expect(stringSnapshotToViewerState({
402
388
  cam: serializedState
403
389
  })).toEqual(state);
404
390
  });
@@ -426,19 +412,19 @@ var DEFAULT_CONTROL_POINTS = [{
426
412
  }];
427
413
  describe("legacy control points", function () {
428
414
  it("parses comma-separated control points", function () {
429
- var result = deserializeViewerChannelSetting(0, {
415
+ var result = stringSnapshotToViewerChannelSetting(0, {
430
416
  cps: "-10:0:000000,50:0:000000,100:0.3:0010ff,140:0.8:00ffff,260:1:00ffb4"
431
417
  });
432
418
  expect(result.controlPoints).toEqual(DEFAULT_CONTROL_POINTS);
433
419
  });
434
420
  it("parses colon-separated control points", function () {
435
- var result = deserializeViewerChannelSetting(0, {
421
+ var result = stringSnapshotToViewerChannelSetting(0, {
436
422
  cps: "-10:0:000000:50:0:000000:100:0.3:0010ff:140:0.8:00ffff:260:1:00ffb4"
437
423
  });
438
424
  expect(result.controlPoints).toEqual(DEFAULT_CONTROL_POINTS);
439
425
  });
440
426
  it("replaces '1' color strings with default color #ffffff", function () {
441
- var result = deserializeViewerChannelSetting(0, {
427
+ var result = stringSnapshotToViewerChannelSetting(0, {
442
428
  cps: "0:0:1:50:1:1"
443
429
  });
444
430
  expect(result.controlPoints).toEqual([{
@@ -454,21 +440,21 @@ describe("legacy control points", function () {
454
440
  });
455
441
  it("parses comma-separated control points", function () {
456
442
  var _result$intensity2;
457
- var result = deserializeViewerChannelSetting(0, {
443
+ var result = stringSnapshotToViewerChannelSetting(0, {
458
444
  cpt: "-10:0:000000,50:0:000000,100:0.3:0010ff,140:0.8:00ffff,260:1:00ffb4"
459
445
  });
460
446
  expect((_result$intensity2 = result.intensity) === null || _result$intensity2 === void 0 ? void 0 : _result$intensity2.controlPoints).toEqual(DEFAULT_CONTROL_POINTS);
461
447
  });
462
448
  it("parses colon-separated control points", function () {
463
449
  var _result$intensity3;
464
- var result = deserializeViewerChannelSetting(0, {
450
+ var result = stringSnapshotToViewerChannelSetting(0, {
465
451
  cpt: "-10:0:000000:50:0:000000:100:0.3:0010ff:140:0.8:00ffff:260:1:00ffb4"
466
452
  });
467
453
  expect((_result$intensity3 = result.intensity) === null || _result$intensity3 === void 0 ? void 0 : _result$intensity3.controlPoints).toEqual(DEFAULT_CONTROL_POINTS);
468
454
  });
469
455
  it("replaces '1' color strings with default color #ffffff", function () {
470
456
  var _result$intensity4;
471
- var result = deserializeViewerChannelSetting(0, {
457
+ var result = stringSnapshotToViewerChannelSetting(0, {
472
458
  cpt: "0:0:1:50:1:1"
473
459
  });
474
460
  expect((_result$intensity4 = result.intensity) === null || _result$intensity4 === void 0 ? void 0 : _result$intensity4.controlPoints).toEqual([{