@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
@@ -1,41 +1,69 @@
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
- var _ViewerStateKeys$View, _ViewerStateKeys$Mode, _ViewerStateKeys$Mask, _ViewerStateKeys$Imag, _ViewerStateKeys$Axes, _ViewerStateKeys$Boun, _ViewerStateKeys$Sing, _ViewerStateKeys$Sing2, _ViewerStateKeys$Boun2, _ViewerStateKeys$Back, _ViewerStateKeys$Auto, _ViewerStateKeys$Brig, _ViewerStateKeys$Dens, _ViewerStateKeys$Leve, _ViewerStateKeys$Inte, _ViewerStateKeys$Regi, _ViewerStateKeys$Slic, _ViewerStateKeys$Time, _ViewerStateKeys$Scen, _ViewerStateKeys$UseE, _ViewerStateKeys$Scal, _ViewerStateKeys$Came, _ViewerChannelSetting, _ViewerChannelSetting2, _ViewerChannelSetting3, _ViewerChannelSetting4, _ViewerChannelSetting5, _ViewerChannelSetting6, _ViewerChannelSetting7, _ViewerChannelSetting8, _ViewerChannelSetting9, _ViewerChannelSetting10, _ViewerChannelSetting11, _ViewerChannelSetting12, _ViewerChannelSetting13, _ViewerChannelSetting14;
3
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
4
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
5
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
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; }
7
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
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); }
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
+ }({});
19
+
9
20
  /** Global (not per-channel) viewer state which may be changed in the UI */
10
21
 
22
+ /** Settings for a single channel which may be changed in the UI */
23
+
11
24
  /**
12
- * Enum keys for serialized viewer settings. These are stored as enums for
13
- * better readability, and are mapped to types in `ViewerStateParams`.
25
+ * The variants of `ViewMode` that appear in serialized representations of state
26
+ * (`ViewerStateSnapshot`, `ViewerStateStringified`).
27
+ *
28
+ * **IMPORTANT:** Changing the values of this enum will BREAK existing image sharing links and exported app state.
29
+ * It should not be done without introducing code to handle the previous values. This enum must not have values that
30
+ * collide when `toLowerCase` is applied to them.
14
31
  */
15
- export var ViewerStateKeys = /*#__PURE__*/function (ViewerStateKeys) {
16
- ViewerStateKeys["View"] = "view";
17
- ViewerStateKeys["Mode"] = "mode";
18
- ViewerStateKeys["Mask"] = "mask";
19
- ViewerStateKeys["Image"] = "image";
20
- ViewerStateKeys["Axes"] = "axes";
21
- ViewerStateKeys["BoundingBox"] = "bb";
22
- ViewerStateKeys["BoundingBoxColor"] = "bbcol";
23
- ViewerStateKeys["BackgroundColor"] = "bgcol";
24
- ViewerStateKeys["Autorotate"] = "rot";
25
- ViewerStateKeys["Brightness"] = "bright";
26
- ViewerStateKeys["Density"] = "dens";
27
- ViewerStateKeys["Levels"] = "lvl";
28
- ViewerStateKeys["Interpolation"] = "interp";
29
- ViewerStateKeys["Region"] = "reg";
30
- ViewerStateKeys["Slice"] = "slice";
31
- ViewerStateKeys["Time"] = "t";
32
- ViewerStateKeys["Scene"] = "scene";
33
- ViewerStateKeys["CameraState"] = "cam";
34
- ViewerStateKeys["SingleChannelMode"] = "scm";
35
- ViewerStateKeys["SingleChannelIndex"] = "sci";
36
- ViewerStateKeys["UseExactScaleLevel"] = "esl";
37
- ViewerStateKeys["ScaleLevelIndex"] = "scl";
38
- return ViewerStateKeys;
32
+ export var ViewModeSnapshot = /*#__PURE__*/function (ViewModeSnapshot) {
33
+ ViewModeSnapshot["threeD"] = "3D";
34
+ ViewModeSnapshot["xy"] = "Z";
35
+ ViewModeSnapshot["xz"] = "Y";
36
+ ViewModeSnapshot["yz"] = "X";
37
+ return ViewModeSnapshot;
38
+ }({});
39
+
40
+ /**
41
+ * The variants of `RenderMode` that appear in serialized representations of state
42
+ * (`ViewerStateSnapshot`, `ViewerStateStringified`).
43
+ *
44
+ * **IMPORTANT:** Changing the values of this enum will BREAK existing image sharing links and exported app state.
45
+ * It should not be done without introducing code to handle the previous values. This enum must not have values that
46
+ * collide when `toLowerCase` is applied to them.
47
+ */
48
+ export var RenderModeSnapshot = /*#__PURE__*/function (RenderModeSnapshot) {
49
+ RenderModeSnapshot["volumetric"] = "volumetric";
50
+ RenderModeSnapshot["maxProject"] = "maxproject";
51
+ RenderModeSnapshot["pathTrace"] = "pathtrace";
52
+ return RenderModeSnapshot;
53
+ }({});
54
+
55
+ /**
56
+ * The variants of `ImageType` that appear in serialized representations of state
57
+ * (`ViewerStateSnapshot`, `ViewerStateStringified`).
58
+ *
59
+ * **IMPORTANT:** Changing the values of this enum will BREAK existing image sharing links and exported app state.
60
+ * It should not be done without introducing code to handle the previous values. This enum must not have values that
61
+ * collide when `toLowerCase` is applied to them.
62
+ */
63
+ export var ImageTypeSnapshot = /*#__PURE__*/function (ImageTypeSnapshot) {
64
+ ImageTypeSnapshot["segmentedCell"] = "cell";
65
+ ImageTypeSnapshot["fullField"] = "fov";
66
+ return ImageTypeSnapshot;
39
67
  }({});
40
68
  export var CameraTransformKeys = /*#__PURE__*/function (CameraTransformKeys) {
41
69
  CameraTransformKeys["Position"] = "pos";
@@ -45,221 +73,105 @@ export var CameraTransformKeys = /*#__PURE__*/function (CameraTransformKeys) {
45
73
  CameraTransformKeys["Fov"] = "fov";
46
74
  return CameraTransformKeys;
47
75
  }({});
48
-
49
- /** Serialized version of `ViewerState`. */
50
- _ViewerStateKeys$View = ViewerStateKeys.View;
51
- _ViewerStateKeys$Mode = ViewerStateKeys.Mode;
52
- _ViewerStateKeys$Mask = ViewerStateKeys.Mask;
53
- _ViewerStateKeys$Imag = ViewerStateKeys.Image;
54
- _ViewerStateKeys$Axes = ViewerStateKeys.Axes;
55
- _ViewerStateKeys$Boun = ViewerStateKeys.BoundingBox;
56
- _ViewerStateKeys$Sing = ViewerStateKeys.SingleChannelMode;
57
- _ViewerStateKeys$Sing2 = ViewerStateKeys.SingleChannelIndex;
58
- _ViewerStateKeys$Boun2 = ViewerStateKeys.BoundingBoxColor;
59
- _ViewerStateKeys$Back = ViewerStateKeys.BackgroundColor;
60
- _ViewerStateKeys$Auto = ViewerStateKeys.Autorotate;
61
- _ViewerStateKeys$Brig = ViewerStateKeys.Brightness;
62
- _ViewerStateKeys$Dens = ViewerStateKeys.Density;
63
- _ViewerStateKeys$Leve = ViewerStateKeys.Levels;
64
- _ViewerStateKeys$Inte = ViewerStateKeys.Interpolation;
65
- _ViewerStateKeys$Regi = ViewerStateKeys.Region;
66
- _ViewerStateKeys$Slic = ViewerStateKeys.Slice;
67
- _ViewerStateKeys$Time = ViewerStateKeys.Time;
68
- _ViewerStateKeys$Scen = ViewerStateKeys.Scene;
69
- _ViewerStateKeys$UseE = ViewerStateKeys.UseExactScaleLevel;
70
- _ViewerStateKeys$Scal = ViewerStateKeys.ScaleLevelIndex;
71
- _ViewerStateKeys$Came = ViewerStateKeys.CameraState;
72
- export var ViewerStateParams = /*#__PURE__*/_createClass(function ViewerStateParams() {
73
- _classCallCheck(this, ViewerStateParams);
74
- /** Axis to view. Valid values are "3D", "X", "Y", and "Z". Defaults to "3D". */
75
- _defineProperty(this, _ViewerStateKeys$View, undefined);
76
- /**
77
- * Render mode. Valid values are "volumetric", "maxproject", and "pathtrace".
78
- * Defaults to "volumetric".
79
- */
80
- _defineProperty(this, _ViewerStateKeys$Mode, undefined);
81
- /** The opacity of the mask channel, an integer in the range [0, 100]. Defaults to 50. */
82
- _defineProperty(this, _ViewerStateKeys$Mask, undefined);
83
- /** The type of image to display. Valid values are "cell" and "fov". Defaults to "cell". */
84
- _defineProperty(this, _ViewerStateKeys$Imag, undefined);
85
- /** Whether to show the axes helper. "1" is enabled. Disabled by default. */
86
- _defineProperty(this, _ViewerStateKeys$Axes, undefined);
87
- /** Whether to show the bounding box. "1" is enabled. Disabled by default. */
88
- _defineProperty(this, _ViewerStateKeys$Boun, undefined);
89
- /** Whether single-channel mode is active. "1" is active. Inactive by default. */
90
- _defineProperty(this, _ViewerStateKeys$Sing, undefined);
91
- /** If single-channel mode is active, which channel index is shown. Defaults to 0. */
92
- _defineProperty(this, _ViewerStateKeys$Sing2, undefined);
93
- /** The color of the bounding box, as a 6-digit hex color. */
94
- _defineProperty(this, _ViewerStateKeys$Boun2, undefined);
95
- /** The background color, as a 6-digit hex color. */
96
- _defineProperty(this, _ViewerStateKeys$Back, undefined);
97
- /** Whether to autorotate the view. "1" is enabled. Disabled by default. */
98
- _defineProperty(this, _ViewerStateKeys$Auto, undefined);
99
- /** The brightness of the image, an float in the range [0, 100]. Defaults to 70. */
100
- _defineProperty(this, _ViewerStateKeys$Brig, undefined);
101
- /** Density, a float in the range [0, 100]. Defaults to 50. */
102
- _defineProperty(this, _ViewerStateKeys$Dens, undefined);
103
- /**
104
- * Levels for image intensity adjustment. Should be three numeric values separated
105
- * by commas, representing the low, middle, and high values in a [0, 255] range.
106
- * Values will be sorted in ascending order; empty values will be parsed as 0.
107
- */
108
- _defineProperty(this, _ViewerStateKeys$Leve, undefined);
109
- /** Whether to enable interpolation. "1" is enabled. Enabled by default. */
110
- _defineProperty(this, _ViewerStateKeys$Inte, undefined);
111
- /** Subregions per axis, as min:max pairs separated by commas.
112
- * Defaults to full range (`0:1`) for each axis.
113
- */
114
- _defineProperty(this, _ViewerStateKeys$Regi, undefined);
115
- /** Slice position per X, Y, and Z axes, as a list of comma-separated floats.
116
- * 0.5 for all axes by default (e.g. `0.5,0.5,0.5`)
117
- */
118
- _defineProperty(this, _ViewerStateKeys$Slic, undefined);
119
- /** Frame number, for time-series volumes. 0 by default. */
120
- _defineProperty(this, _ViewerStateKeys$Time, undefined);
121
- /** Scene number, for multiscene images. 0 by default. */
122
- _defineProperty(this, _ViewerStateKeys$Scen, undefined);
123
- /** Whether to use an exact scale level index. 0 by default. */
124
- _defineProperty(this, _ViewerStateKeys$UseE, undefined);
125
- /** The exact scale level index to use, if `UseExactScaleLevel` is 1. 0 by default. */
126
- _defineProperty(this, _ViewerStateKeys$Scal, undefined);
127
- /**
128
- * Camera transform settings, as a list of `key:value` pairs separated by commas.
129
- * Valid keys are defined in `CameraTransformKeys`:
130
- * - `pos`: position
131
- * - `tar`: target
132
- * - `up`: up
133
- * - `ort`: orthographic scale
134
- * - `fov`: field of view
135
- *
136
- * Vector values are encoded as three floats separated by colons (e.g. `1:2:3`) and
137
- * encoded using `encodeURIComponent`.
138
- */
139
- _defineProperty(this, _ViewerStateKeys$Came, undefined);
140
- });
76
+ /**
77
+ * Property keys for the "snapshot" variants of `ViewerState`. These keys are shorter, for contexts that need brevity
78
+ * (like URLs), and have a stronger guarantee of stability than the keys of `ViewerState`.
79
+ *
80
+ * **IMPORTANT:** Changing the values of this enum will BREAK existing image sharing links and exported app state.
81
+ * Ideally, you should never do it. If you must, you must also add code to version-check and handle previous values.
82
+ */
83
+ export var ViewerStateSnapshotKeys = /*#__PURE__*/function (ViewerStateSnapshotKeys) {
84
+ ViewerStateSnapshotKeys["View"] = "view";
85
+ ViewerStateSnapshotKeys["Mode"] = "mode";
86
+ ViewerStateSnapshotKeys["MaskOpacity"] = "mask";
87
+ ViewerStateSnapshotKeys["ImageType"] = "image";
88
+ ViewerStateSnapshotKeys["ShowAxes"] = "axes";
89
+ ViewerStateSnapshotKeys["ShowBoundingBox"] = "bb";
90
+ ViewerStateSnapshotKeys["BoundingBoxColor"] = "bbcol";
91
+ ViewerStateSnapshotKeys["BackgroundColor"] = "bgcol";
92
+ ViewerStateSnapshotKeys["Autorotate"] = "rot";
93
+ ViewerStateSnapshotKeys["Brightness"] = "bright";
94
+ ViewerStateSnapshotKeys["Density"] = "dens";
95
+ ViewerStateSnapshotKeys["Levels"] = "lvl";
96
+ ViewerStateSnapshotKeys["Interpolation"] = "interp";
97
+ ViewerStateSnapshotKeys["Region"] = "reg";
98
+ ViewerStateSnapshotKeys["Slice"] = "slice";
99
+ ViewerStateSnapshotKeys["Time"] = "t";
100
+ ViewerStateSnapshotKeys["Scene"] = "scene";
101
+ ViewerStateSnapshotKeys["CameraState"] = "cam";
102
+ ViewerStateSnapshotKeys["SingleChannelMode"] = "scm";
103
+ ViewerStateSnapshotKeys["SingleChannelIndex"] = "sci";
104
+ ViewerStateSnapshotKeys["UseExactScaleLevel"] = "esl";
105
+ ViewerStateSnapshotKeys["ScaleLevelIndex"] = "scl";
106
+ return ViewerStateSnapshotKeys;
107
+ }({});
141
108
 
142
109
  /**
143
- * Mapped to types in `ViewerChannelStateParams`.
110
+ * Property keys for the "snapshot" variants of `ChannelState`/`ViewerChannelSettings`. These keys are shorter, for
111
+ * contexts that need brevity (like URLs), and have a stronger guarantee of stability than the keys of `ChannelState`.
112
+ *
113
+ * **IMPORTANT:** Changing the values of this enum will BREAK existing image sharing links and exported app state.
114
+ * Ideally, you should never do it. If you must, you must also add code to version-check and handle previous values.
144
115
  */
145
- export var ViewerChannelSettingKeys = /*#__PURE__*/function (ViewerChannelSettingKeys) {
146
- ViewerChannelSettingKeys["Color"] = "col";
147
- ViewerChannelSettingKeys["Colorize"] = "clz";
148
- ViewerChannelSettingKeys["ColorizeAlpha"] = "cza";
149
- ViewerChannelSettingKeys["IsosurfaceAlpha"] = "isa";
150
- ViewerChannelSettingKeys["Lut"] = "lut";
151
- ViewerChannelSettingKeys["ControlPoints"] = "cpt";
152
- ViewerChannelSettingKeys["ControlPointsLegacy"] = "cps";
153
- ViewerChannelSettingKeys["Ramp"] = "ram";
154
- ViewerChannelSettingKeys["RampLegacy"] = "rmp";
155
- ViewerChannelSettingKeys["ControlPointsEnabled"] = "cpe";
156
- ViewerChannelSettingKeys["VolumeEnabled"] = "ven";
157
- ViewerChannelSettingKeys["SurfaceEnabled"] = "sen";
158
- ViewerChannelSettingKeys["IsosurfaceValue"] = "isv";
159
- ViewerChannelSettingKeys["KeepRange"] = "pin";
160
- return ViewerChannelSettingKeys;
116
+ export var ChannelStateSnapshotKeys = /*#__PURE__*/function (ChannelStateSnapshotKeys) {
117
+ ChannelStateSnapshotKeys["Color"] = "col";
118
+ ChannelStateSnapshotKeys["Colorize"] = "clz";
119
+ ChannelStateSnapshotKeys["ColorizeAlpha"] = "cza";
120
+ ChannelStateSnapshotKeys["IsosurfaceAlpha"] = "isa";
121
+ ChannelStateSnapshotKeys["Lut"] = "lut";
122
+ ChannelStateSnapshotKeys["ControlPoints"] = "cpt";
123
+ ChannelStateSnapshotKeys["ControlPointsLegacy"] = "cps";
124
+ ChannelStateSnapshotKeys["Ramp"] = "ram";
125
+ ChannelStateSnapshotKeys["RampLegacy"] = "rmp";
126
+ ChannelStateSnapshotKeys["ControlPointsEnabled"] = "cpe";
127
+ ChannelStateSnapshotKeys["VolumeEnabled"] = "ven";
128
+ ChannelStateSnapshotKeys["SurfaceEnabled"] = "sen";
129
+ ChannelStateSnapshotKeys["IsosurfaceValue"] = "isv";
130
+ ChannelStateSnapshotKeys["KeepRange"] = "pin";
131
+ return ChannelStateSnapshotKeys;
161
132
  }({});
162
133
 
134
+ // Maps `ViewerStateKeys` to the type of each key in `ViewerStateSnapshot`.
135
+ // This is not the exported "snapshot" type: that's `ViewerStateSnapshot`, below. Defining `ViewerStateSnapshot` as
136
+ // a mapped type ensures that if a variant is added to `ViewerStateKeys`, `ViewerStateSnapshot` will type error until
137
+ // that key's value is added to this type.
138
+
139
+ /**
140
+ * A "snapshot" of a `ViewerState`.
141
+ *
142
+ * This type is a variant representation of `ViewerState`, specialized for saving/restoring state to/from some
143
+ * serialized representation. It has the following desirable properties for this purpose:
144
+ * - Its keys are *shorter*, for formats where that's desirable (mostly URL parameters)
145
+ * - Its keys are reasonably *stable*, so that settings exported from older app versions can be imported by newer ones
146
+ * - Some values, notably colors, are converted to alternate representations for compactness and/or clarity
147
+ */
148
+
163
149
  /**
164
- * The serialized form of a ViewerChannelSetting, as a dictionary object.
150
+ * A `ViewerStateSnapshot` with all its keys converted to compact string representations. Useful for (de)serializing
151
+ * viewer state to/from URL parameters.
165
152
  */
166
- _ViewerChannelSetting = ViewerChannelSettingKeys.Color;
167
- _ViewerChannelSetting2 = ViewerChannelSettingKeys.Colorize;
168
- _ViewerChannelSetting3 = ViewerChannelSettingKeys.ColorizeAlpha;
169
- _ViewerChannelSetting4 = ViewerChannelSettingKeys.IsosurfaceAlpha;
170
- _ViewerChannelSetting5 = ViewerChannelSettingKeys.Lut;
171
- _ViewerChannelSetting6 = ViewerChannelSettingKeys.ControlPointsLegacy;
172
- _ViewerChannelSetting7 = ViewerChannelSettingKeys.ControlPoints;
173
- _ViewerChannelSetting8 = ViewerChannelSettingKeys.ControlPointsEnabled;
174
- _ViewerChannelSetting9 = ViewerChannelSettingKeys.RampLegacy;
175
- _ViewerChannelSetting10 = ViewerChannelSettingKeys.Ramp;
176
- _ViewerChannelSetting11 = ViewerChannelSettingKeys.VolumeEnabled;
177
- _ViewerChannelSetting12 = ViewerChannelSettingKeys.SurfaceEnabled;
178
- _ViewerChannelSetting13 = ViewerChannelSettingKeys.IsosurfaceValue;
179
- _ViewerChannelSetting14 = ViewerChannelSettingKeys.KeepRange;
180
- export var ViewerChannelStateParams = /*#__PURE__*/_createClass(function ViewerChannelStateParams() {
181
- _classCallCheck(this, ViewerChannelStateParams);
182
- /** Color, as a 6-digit hex color. */
183
- _defineProperty(this, _ViewerChannelSetting, undefined);
184
- /** Colorize. "1" is enabled. Disabled by default. */
185
- _defineProperty(this, _ViewerChannelSetting2, undefined);
186
- /** Colorize alpha, in the [0, 1] range. Set to `1.0` by default. */
187
- _defineProperty(this, _ViewerChannelSetting3, undefined);
188
- /** Isosurface alpha, in the [0, 1 range]. Set to `1.0` by default.*/
189
- _defineProperty(this, _ViewerChannelSetting4, undefined);
190
- /**
191
- * Lookup table (LUT) to map from volume intensity to opacity. Should be two
192
- * alphanumeric values separated by a colon, where the first value is the
193
- * minimum and the second is the maximum. Defaults to [0, 255].
194
- *
195
- * Min and max values are determined as following:
196
- * - Plain numbers are indices of histogram bins, typically in the range [0,
197
- * 255].
198
- * - `v{n}` represents a raw intensity value, where `n` is a number.
199
- * - `p{n}` represents a percentile, where `n` is a percentile in the [0, 100]
200
- * range.
201
- * - `m{n}` represents the median multiplied by `n / 100`.
202
- * - `autoij` in either the min or max fields will use the "auto" algorithm
203
- * from ImageJ to select the min AND max.
204
- *
205
- * Values will be used to determine the initial control points and ramp if
206
- * those fields are not provided.
207
- *
208
- * @example
209
- * ```
210
- * "0:255" // min: intensity 0, max: intensity 255.
211
- * "p50:p90" // min: 50th percentile, max: 90th percentile.
212
- * "m1:p75" // min: median, max: 75th percentile.
213
- * "autoij:0" // use Auto-IJ to calculate min and max.
214
- * ```
215
- */
216
- _defineProperty(this, _ViewerChannelSetting5, undefined);
217
- /**
218
- * Legacy specifier for control points for the transfer function as a list of
219
- * `x:opacity:color` triplets, separated by colon. Uses histogram bin indices
220
- * instead of intensity values.
221
- * - `x` is a histogram bin index in the [0, 255] range.
222
- * - `opacity` is a float in the [0, 1] range.
223
- * - `color` is a 6-digit hex color, e.g. `ff0000`.
224
- *
225
- * Will be overridden by the ControlPoints field (`cpt`) if provided.
226
- */
227
- _defineProperty(this, _ViewerChannelSetting6, undefined);
228
- /**
229
- * Control points for the transfer function, formatted as a list of
230
- * `x:opacity:color` triplets, separated by colons.
231
- * - `x` is a numeric intensity value.
232
- * - `opacity` is a float in the [0, 1] range.
233
- * - `color` is a 6-digit hex color, e.g. `ff0000`.
234
- *
235
- * If provided, overrides the `lut` field when calculating the control points.
236
- */
237
- _defineProperty(this, _ViewerChannelSetting7, undefined);
238
- /**
239
- * Whether to show advanced mode, which will show control points instead of
240
- * ramp values defined by the LUT. "1" is enabled, disabled by default.
241
- */
242
- _defineProperty(this, _ViewerChannelSetting8, undefined);
243
- /**
244
- * Legacy specifier for the transfer function ramp which uses histogram bin
245
- * indices instead of intensity values, formatted as `min:max`. Will be
246
- * overridden by the Ramp field (`ram`) if provided.
247
- */
248
- _defineProperty(this, _ViewerChannelSetting9, undefined);
249
- /**
250
- * Ramp min and max intensity values (`min:max`). If provided, overrides the
251
- * `lut` field when calculating the ramp.
252
- */
253
- _defineProperty(this, _ViewerChannelSetting10, undefined);
254
- /** Volume enabled. "1" is enabled. Disabled by default. */
255
- _defineProperty(this, _ViewerChannelSetting11, undefined);
256
- /** Isosurface enabled. "1" is enabled. Disabled by default. */
257
- _defineProperty(this, _ViewerChannelSetting12, undefined);
258
- /** Isosurface value, in the [0, 255] range. Set to `128` by default. */
259
- _defineProperty(this, _ViewerChannelSetting13, undefined);
260
- /**
261
- * Whether to keep the current contrast settings when loading a new volume.
262
- * "1" is enabled. Disabled by default.
263
- */
264
- _defineProperty(this, _ViewerChannelSetting14, undefined);
265
- });
153
+
154
+ /**
155
+ * A `ControlPoint` where `color` is a six-digit hex string, or gets shortened to `"1"` in the overwhelming majority of
156
+ * cases where the control point is white to save space in sharing URLs. Used by `ChannelStateSnapshot`.
157
+ */
158
+
159
+ // Maps `ChannelStateKeys` to the type of each key in `ChannelStateSnapshot`.
160
+ // This is not the exported "snapshot" type: that's `ChannelStateSnapshot`, below. Defining `ChannelStateSnapshot` as
161
+ // a mapped type ensures that if a variant is added to `ChannelStateKeys`, `ChannelStateSnapshot` will type error until
162
+ // that key's value is added to this type.
163
+
164
+ /**
165
+ * A "snapshot" of a `ChannelState` or `ViewerChannelSetting`.
166
+ *
167
+ * This type is a variant representation of `ChannelState`/`ViewerChannelSetting`, specialized for saving/restoring
168
+ * channel state to/from some serialized representation. It has the following desirable properties for this purpose:
169
+ * - Its keys are *shorter*, for formats where that's desirable (mostly URL parameters)
170
+ * - Its keys are reasonably *stable*, so that settings exported from older app versions can be imported by newer ones
171
+ * - Some values, notably colors, are converted to alternate representations for compactness and/or clarity
172
+ */
173
+
174
+ /**
175
+ * A `ChannelStateSnapshot` with all its keys converted to compact string representations. Useful for (de)serializing
176
+ * channel state to/from URL parameters.
177
+ */
@@ -1,10 +1,16 @@
1
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
2
+ 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."); }
3
+ 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; } }
4
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
5
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
6
+ 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; }
1
7
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2
8
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3
9
  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; }
4
10
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
5
11
  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); }
6
12
  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); }
7
- import { RenderMode, ViewMode } from "../shared/enums";
13
+ import { RenderMode, ViewMode } from "./types";
8
14
 
9
15
  // TODO move back to a new `types` module (?)
10
16
 
@@ -68,4 +74,36 @@ export var validateState = function validateState(currentState, newState) {
68
74
  Object.assign(validated, validateStateValue(currentState, key, newState[key]));
69
75
  }
70
76
  return validated;
77
+ };
78
+
79
+ /** Creates a deep copy of a `ChannelState` */
80
+ // Fills in every property individually so that new properties force a modification to this function
81
+ export var cloneChannelState = function cloneChannelState(setting) {
82
+ return {
83
+ ramp: _toConsumableArray(setting.ramp),
84
+ controlPoints: setting.controlPoints.map(function (_ref5) {
85
+ var x = _ref5.x,
86
+ opacity = _ref5.opacity,
87
+ color = _ref5.color;
88
+ return {
89
+ x: x,
90
+ opacity: opacity,
91
+ color: _toConsumableArray(color)
92
+ };
93
+ }),
94
+ // Safe shallow copies
95
+ name: setting.name,
96
+ displayName: setting.displayName,
97
+ volumeEnabled: setting.volumeEnabled,
98
+ isosurfaceEnabled: setting.isosurfaceEnabled,
99
+ isovalue: setting.isovalue,
100
+ colorizeEnabled: setting.colorizeEnabled,
101
+ colorizeAlpha: setting.colorizeAlpha,
102
+ opacity: setting.opacity,
103
+ color: setting.color,
104
+ useControlPoints: setting.useControlPoints,
105
+ plotMin: setting.plotMin,
106
+ plotMax: setting.plotMax,
107
+ keepIntensityRange: setting.keepIntensityRange
108
+ };
71
109
  };
package/es/index.js CHANGED
@@ -1,5 +1,7 @@
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 { ViewMode, RenderMode, ImageType } from "./aics-image-viewer/shared/enums";
4
+ export { viewerMessageToParams, isStoreSnapshot, snapshotToViewerChannelSettings } from "./aics-image-viewer/shared/utils/parseSnapshot";
5
+ export { snapshotToViewerState } from "./aics-image-viewer/state/deserialize";
6
+ export { ViewMode, RenderMode, ImageType } from "./aics-image-viewer/state/types";
5
7
  export { ImageViewerApp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aics/vole-app",
3
- "version": "3.4.4",
3
+ "version": "3.6.0",
4
4
  "description": "web view of cell volume images",
5
5
  "main": "es/index.js",
6
6
  "module": "es/index.js",
@@ -21,32 +21,30 @@
21
21
  "url": "git+https://github.com/allen-cell-animated/vole-app.git"
22
22
  },
23
23
  "scripts": {
24
- "start": "webpack serve --config webpack.dev.js --env env=dev",
25
- "gh-build-nightly": "webpack --config webpack.dev.js --env env=production basename=/vole-app/",
26
- "gh-build-release": "webpack --config webpack.dev.js --env env=production basename=/website-3d-cell-viewer-release/",
27
- "s3-build": "webpack --config webpack.dev.js --env env=production",
28
- "release-build": "webpack --config webpack.dev.js --env env=production",
29
- "docker-build": "webpack --config webpack.common.js --env env=production",
30
- "dev": "webpack --config webpack.dev.js --env env=dev",
24
+ "start": "vite dev",
25
+ "gh-build-nightly": "vite build --base=/vole-app/",
26
+ "s3-build": "vite build",
27
+ "release-build": "vite build",
28
+ "docker-build": "vite build",
29
+ "dev": "vite dev",
31
30
  "lint": "eslint --config ./.eslintrc --ignore-path ./.eslintignore --ext .jsx --ext .js --ext .ts --ext .tsx ./",
32
- "test": "jest --coverage --passWithNoTests",
33
- "test:github-action": "jest --silent --passWithNoTests --ci --coverage --coverageReporters=\"text\" --coverageReporters=\"text-summary\" --outputFile=\"report.json\"",
31
+ "test": "vitest run --passWithNoTests",
34
32
  "typeCheck": "tsc -p tsconfig.json --noEmit",
35
33
  "generateTypes": "tsc -p tsconfig.base.json --emitDeclarationOnly",
36
- "transpileES": "cross-env TS_NODE_PROJECT=tsconfig.es.json BABEL_ENV=es babel src --out-dir es --extensions \".js,.jsx,.ts,.tsx,.svg\" --ignore src/**/*.test.*",
34
+ "transpileES": "cross-env TS_NODE_PROJECT=tsconfig.es.json BABEL_ENV=es VOLEAPP_VERSION=$npm_package_version babel src --out-dir es --extensions \".js,.jsx,.ts,.tsx,.svg\" --ignore src/**/*.test.*",
37
35
  "build": "npm-run-all generateTypes postcss transpileES",
38
36
  "postcss": "postcss src/**/*.css --base src --dir es",
39
37
  "publish-patch": "npm version patch | xargs -I {} sh -c 'git push origin {}'",
40
38
  "postpublish-patch": "git push origin main",
41
39
  "prepare": "cross-env DEPLOYMENT_ENV=production npm run build",
42
- "predeploy": "cross-env DEPLOYMENT_ENV=production npm run dev",
40
+ "predeploy": "cross-env DEPLOYMENT_ENV=production npm run release-build",
43
41
  "deploy": "gh-pages -d imageviewer -t true",
44
42
  "checks": "npm run lint && npm run typeCheck && npm run test"
45
43
  },
46
44
  "author": "Allen Institute, Cell Science",
47
45
  "license": "BSD-3-Clause",
48
46
  "dependencies": {
49
- "@aics/vole-core": "^4.9.2",
47
+ "@aics/vole-core": "^4.10.1",
50
48
  "@ant-design/icons": "^5.2.5",
51
49
  "@fortawesome/fontawesome-svg-core": "^6.5.2",
52
50
  "@fortawesome/free-solid-svg-icons": "^6.5.2",
@@ -81,60 +79,44 @@
81
79
  "@trivago/prettier-plugin-sort-imports": "^4.3.0",
82
80
  "@types/color-string": "^1.5.2",
83
81
  "@types/d3": "^7.4.3",
84
- "@types/jest": "^29.5.14",
85
82
  "@types/lodash": "^4.14.185",
83
+ "@types/node": "^26.5.0",
86
84
  "@types/react": "^18.x",
87
85
  "@types/react-color": "^3.0.12",
88
86
  "@types/react-dom": "^18.x",
89
87
  "@types/three": "0.184.0",
90
- "@typescript-eslint/eslint-plugin": "^8.46.2",
91
- "@typescript-eslint/parser": "^8.46.2",
88
+ "@typescript-eslint/eslint-plugin": "^8.70.0",
89
+ "@typescript-eslint/parser": "^8.70.0",
90
+ "@vitejs/plugin-react": "^6.1.1",
92
91
  "antd": "^5.16.2",
93
- "axios": "^0.21.1",
94
- "babel-loader": "^8.2.2",
95
92
  "babel-plugin-replace-import-extension": "^1.1.3",
96
- "clean-webpack-plugin": "^4.0.0-alpha.0",
97
- "command-line-args": "^5.1.1",
98
- "copy-webpack-plugin": "^11.0.0",
93
+ "babel-plugin-transform-inline-environment-variables": "^0.4.4",
99
94
  "cross-env": "^7.0.3",
100
- "css-loader": "^6.2.0",
101
- "esbuild": "^0.14.50",
102
- "esbuild-jest": "^0.5.0",
95
+ "esbuild": "^0.28.2",
103
96
  "eslint": "^8.20.0",
97
+ "eslint-import-resolver-typescript": "^4.4.5",
98
+ "eslint-plugin-import": "^2.32.0",
104
99
  "eslint-plugin-react": "^7.37.5",
105
100
  "eslint-plugin-react-hooks": "^5.2.0",
106
- "file-loader": "^6.2.0",
107
- "firebase": "^7.x",
108
101
  "gh-pages": "^4.0.0",
109
- "html-webpack-plugin": "^5.3.2",
110
- "jest": "^29.7.0",
111
- "jest-environment-jsdom": "^30.2.0",
112
- "mini-css-extract-plugin": "^2.9.1",
113
- "morgan": "^1.9.1",
102
+ "jsdom": "^30.0.1",
114
103
  "npm-run-all": "^4.1.5",
115
- "postcss": "^8.4.47",
104
+ "postcss": "^8.5.26",
116
105
  "postcss-cli": "^11.0.0",
117
106
  "postcss-discard-comments": "^7.0.3",
118
107
  "postcss-extend-rule": "^4.0.0",
119
108
  "postcss-import": "^16.1.0",
120
- "postcss-loader": "^8.1.1",
121
- "postcss-mixins": "^11.0.3",
109
+ "postcss-mixins": "^12.1.2",
122
110
  "postcss-nested": "^6.2.0",
123
111
  "postcss-simple-vars": "^7.0.1",
124
112
  "postcss-url": "^10.1.3",
125
113
  "prettier": "^3.3.3",
126
- "prop-types": "^15.5.10",
127
114
  "react": "^18.3.1",
128
115
  "react-dom": "^18.3.1",
129
- "resolve-url-loader": "^5.0.0",
130
- "style-loader": "^4.0.0",
131
- "ts-jest": "^29.4.6",
132
116
  "typescript": "^5.9.3",
133
- "url-loader": "^4.1.1",
134
- "webpack": "^5.89.0",
135
- "webpack-cli": "^4.7.2",
136
- "webpack-dev-server": "^4.9.3",
137
- "webpack-merge": "^5.8.0",
138
- "webpack-shell-plugin": "^0.5.0"
117
+ "vite": "^8.2.2",
118
+ "vite-plugin-glsl": "^1.6.1",
119
+ "vite-plugin-svgr": "^5.2.0",
120
+ "vitest": "^4.1.11"
139
121
  }
140
122
  }