@aics/vole-app 2.13.6 → 2.14.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.
@@ -72,7 +72,8 @@ var defaultProps = {
72
72
  parentImageDownloadHref: "",
73
73
  pixelSize: undefined,
74
74
  canvasMargin: "0 0 0 0",
75
- view3dRef: undefined
75
+ view3dRef: undefined,
76
+ showError: undefined
76
77
  };
77
78
  var CLIPPING_PANEL_ANIMATION_DURATION_MS = 300;
78
79
  var setIndicatorPositions = function setIndicatorPositions(view3d, panelOpen, hasTime, hasScenes, isMode3d) {
@@ -104,7 +105,7 @@ var setIndicatorPositions = function setIndicatorPositions(view3d, panelOpen, ha
104
105
  view3d.setScaleBarPosition(scaleBarX, scaleBarY);
105
106
  };
106
107
  var App = function App(props) {
107
- var _getCurrentViewerChan, _scenes$length, _scenes2, _image$imageInfo$volu, _image$imageInfo$subr, _image$imageInfo$time, _props$transform2, _props$transform4;
108
+ var _props$showError, _getCurrentViewerChan, _scenes$length, _scenes2, _image$imageInfo$volu, _image$imageInfo$subr, _image$imageInfo$time, _props$transform2, _props$transform4;
108
109
  props = _objectSpread(_objectSpread({}, defaultProps), props);
109
110
 
110
111
  // State management /////////////////////////////////////////////////////////
@@ -121,6 +122,7 @@ var App = function App(props) {
121
122
  onResetChannel = _viewerState$current.onResetChannel;
122
123
  var _props = props,
123
124
  onControlPanelToggle = _props.onControlPanelToggle,
125
+ onImageTitleChange = _props.onImageTitleChange,
124
126
  metadata = _props.metadata,
125
127
  metadataFormatter = _props.metadataFormatter;
126
128
  useMemo(function () {
@@ -134,10 +136,14 @@ var App = function App(props) {
134
136
  if (props.view3dRef !== undefined) {
135
137
  props.view3dRef.current = view3d;
136
138
  }
139
+
140
+ // Allows AppWrapper to pass in its own `useErrorAlert` callbacks, but still keeps error
141
+ // messaging when App is used standalone.
137
142
  var _useErrorAlert = useErrorAlert(),
138
143
  _useErrorAlert2 = _slicedToArray(_useErrorAlert, 2),
139
144
  errorAlert = _useErrorAlert2[0],
140
- showError = _useErrorAlert2[1];
145
+ _showError = _useErrorAlert2[1];
146
+ var showError = (_props$showError = props.showError) !== null && _props$showError !== void 0 ? _props$showError : _showError;
141
147
  useEffect(function () {
142
148
  // Get notifications of loading errors which occur after the initial load, e.g. on time change or new channel load
143
149
  view3d.setLoadErrorHandler(function (_vol, e) {
@@ -203,8 +209,9 @@ var App = function App(props) {
203
209
  };
204
210
  })
205
211
  });
212
+ onImageTitleChange === null || onImageTitleChange === void 0 || onImageTitleChange(newImage.imageInfo.imageInfo.name);
206
213
  view3d.updateActiveChannels(newImage);
207
- }, [view3d, viewerState]);
214
+ }, [view3d, viewerState, onImageTitleChange]);
208
215
  var onChannelLoaded = useCallback(function (image, channelIndex, isInitialLoad) {
209
216
  // TODO this was once a search by name - is that still necessary or will the index always be correct?
210
217
  var thisChannelSettings = channelSettings[channelIndex];
@@ -263,10 +270,14 @@ var App = function App(props) {
263
270
  view3d.updateActiveChannels(image);
264
271
  }
265
272
  }, [view3d, channelSettings, maskChannelName, viewerState]);
273
+ var onError = useCallback(function (error) {
274
+ showError(error);
275
+ onImageTitleChange === null || onImageTitleChange === void 0 || onImageTitleChange(undefined);
276
+ }, [showError, onImageTitleChange]);
266
277
  var volume = useVolume(scenes, {
267
278
  onCreateImage: onCreateImage,
268
279
  onChannelLoaded: onChannelLoaded,
269
- onError: showError,
280
+ onError: onError,
270
281
  maskChannelName: maskChannelName
271
282
  });
272
283
  var image = volume.image,
@@ -37,7 +37,7 @@ var ERROR_TYPE_DESCRIPTIONS = _defineProperty(_defineProperty(_defineProperty(_d
37
37
  }, "start a bug report here"), ".")), VolumeLoadErrorType.INVALID_METADATA, /*#__PURE__*/React.createElement(React.Fragment, null, "The viewer was unable to read all necessary information from this volume's metadata. Check that your dataset's metadata is complete and properly formatted. If you believe your data is valid and should be supported by our viewer, let us know by ", /*#__PURE__*/React.createElement(IssueLink, null, "opening a GitHub issue"), ".")), VolumeLoadErrorType.INVALID_MULTI_SOURCE_ZARR, /*#__PURE__*/React.createElement(React.Fragment, null, "The viewer is currently configured to consolidate multiple OME-Zarr datasets into a single volume, but the provided datasets can't all be matched up. Ensure that all dataset URLs are correct and that at least one equivalently-sized scale level exists in all datasets."));
38
38
  var getErrorTitle = function getErrorTitle(error) {
39
39
  var _error$toString;
40
- return error instanceof Error && ((_error$toString = error.toString) === null || _error$toString === void 0 ? void 0 : _error$toString.call(error)) || "Unknown error";
40
+ return error instanceof Error && ((_error$toString = error.toString) === null || _error$toString === void 0 ? void 0 : _error$toString.call(error)) || typeof error === "string" && error || "Unknown error";
41
41
  };
42
42
  var getErrorDescription = function getErrorDescription(error) {
43
43
  var _ERROR_TYPE_DESCRIPTI2;
@@ -132,7 +132,10 @@ var ResetStateProvider = /*#__PURE__*/function () {
132
132
  }, this.savedViewerState);
133
133
  var newChannelSettings = channelSettings.map(function (_, index) {
134
134
  var initialChannelSetting = initializeOneChannelSetting(channelSettings[index].name, index, getDefaultChannelColor(index), _this.savedViewerChannelSettings);
135
- return initialChannelSetting;
135
+ return _objectSpread(_objectSpread({}, initialChannelSetting), {}, {
136
+ plotMin: channelSettings[index].plotMin,
137
+ plotMax: channelSettings[index].plotMax
138
+ });
136
139
  });
137
140
  this.resetToState(newViewerState, newChannelSettings);
138
141
  this.useDefaultViewerChannelSettings = false;
@@ -0,0 +1,29 @@
1
+ import { isEqual } from "lodash";
2
+
3
+ /**
4
+ * Returns a (shallow) copy of an object with all properties that are
5
+ * `undefined` removed.
6
+ */
7
+ export function removeUndefinedProperties(obj) {
8
+ var result = {};
9
+ for (var key in obj) {
10
+ if (obj[key] !== undefined) {
11
+ result[key] = obj[key];
12
+ }
13
+ }
14
+ return result;
15
+ }
16
+
17
+ /**
18
+ * Returns a copy of `obj` where all properties with values that match the properties of `match`
19
+ * are removed. Matching is determined by deep equality (see `isDeepEqual()`).
20
+ */
21
+ export function removeMatchingProperties(obj, match) {
22
+ var result = {};
23
+ for (var key in obj) {
24
+ if (!isEqual(obj[key], match[key])) {
25
+ result[key] = obj[key];
26
+ }
27
+ }
28
+ return result;
29
+ }
@@ -0,0 +1,109 @@
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 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; }
3
+ 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; }
4
+ 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); } }
5
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
6
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
7
+ 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; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
+ 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); }
10
+ // TODO: These types are shared with Cell Feature Explorer. Can they be moved to
11
+ // a shared package?
12
+
13
+ function isDevOrStagingSite(host) {
14
+ // first condition is for testing with no client
15
+ return !host || host.includes("localhost") || host.includes("staging") || host.includes("stg");
16
+ }
17
+ var FirebaseRequest = /*#__PURE__*/_createClass(
18
+ // TODO: These properties are private and unused. Remove?
19
+
20
+ function FirebaseRequest(firestore) {
21
+ var _this = this;
22
+ _classCallCheck(this, FirebaseRequest);
23
+ _defineProperty(this, "getDoc", function (docPath) {
24
+ return _this.firestore.doc(docPath).get();
25
+ });
26
+ _defineProperty(this, "getAvailableDatasets", function () {
27
+ return _this.firestore.collection("dataset-descriptions").get().then(function (snapShot) {
28
+ var datasets = [];
29
+ snapShot.forEach(function (doc) {
30
+ var metadata = doc.data();
31
+ /** if running the site in a local development env or on staging.cfe.allencell.org
32
+ * include all cards, otherwise, only include cards with a production flag.
33
+ * this is based on hostname instead of a build time variable so we don't
34
+ * need a separate build for staging and production
35
+ */
36
+
37
+ if (isDevOrStagingSite(location.hostname)) {
38
+ datasets.push(metadata);
39
+ } else if (metadata.production) {
40
+ datasets.push(metadata);
41
+ }
42
+ });
43
+ return datasets;
44
+ });
45
+ });
46
+ _defineProperty(this, "setCollectionRef", function (id) {
47
+ _this.collectionRef = _this.firestore.collection("cfe-datasets").doc(id);
48
+ });
49
+ _defineProperty(this, "getManifest", function (ref) {
50
+ return _this.firestore.doc(ref).get().then(function (manifestDoc) {
51
+ return manifestDoc.data();
52
+ });
53
+ });
54
+ _defineProperty(this, "selectDataset", function (ref) {
55
+ return _this.getManifest(ref).then(function (data) {
56
+ _this.featuresDataPath = data.featuresDataPath;
57
+ _this.thumbnailRoot = data.thumbnailRoot;
58
+ _this.downloadRoot = data.downloadRoot;
59
+ _this.volumeViewerDataRoot = data.volumeViewerDataRoot;
60
+ _this.featuresDisplayOrder = data.featuresDisplayOrder;
61
+ _this.cellLineDataPath = data.cellLineDataPath;
62
+ _this.fileInfoPath = data.fileInfoPath;
63
+ _this.featuresDataOrder = data.featuresDataOrder;
64
+ _this.featureDefsPath = data.featureDefsPath;
65
+ _this.albumPath = data.albumPath;
66
+ return _objectSpread({}, data);
67
+ });
68
+ });
69
+ _defineProperty(this, "getFileInfoByCellId", function (cellId) {
70
+ return _this.getDoc("".concat(_this.fileInfoPath, "/").concat(cellId)).then(function (doc) {
71
+ var data = doc.data();
72
+ if (!data) {
73
+ return;
74
+ }
75
+ return _objectSpread(_objectSpread({}, data), {}, {
76
+ CellId: data.CellId.toString(),
77
+ FOVId: data.FOVId.toString()
78
+ });
79
+ });
80
+ });
81
+ _defineProperty(this, "getFileInfoByArrayOfCellIds", function (cellIds) {
82
+ return Promise.all(cellIds.map(function (id) {
83
+ return _this.getDoc("".concat(_this.fileInfoPath, "/").concat(id)).then(function (doc) {
84
+ var data = doc.data();
85
+ if (!data) {
86
+ return;
87
+ }
88
+ return _objectSpread(_objectSpread({}, data), {}, {
89
+ CellId: data.CellId.toString(),
90
+ FOVId: data.FOVId.toString()
91
+ });
92
+ });
93
+ }));
94
+ });
95
+ this.firestore = firestore;
96
+ this.featuresDataPath = "";
97
+ this.cellLineDataPath = "";
98
+ this.thumbnailRoot = "";
99
+ this.downloadRoot = "";
100
+ this.volumeViewerDataRoot = "";
101
+ this.featuresDisplayOrder = [];
102
+ this.fileInfoPath = "";
103
+ this.datasetId = "";
104
+ this.featuresDataOrder = [];
105
+ this.albumPath = "";
106
+ this.featureDefsPath = "";
107
+ this.collectionRef = firestore.collection("cfe-datasets").doc("v1");
108
+ });
109
+ export default FirebaseRequest;
@@ -0,0 +1,3 @@
1
+ export function clamp(value, min, max) {
2
+ return Math.min(Math.max(value, min), max);
3
+ }