@haniffalab/cherita-react 0.2.0-dev.2024-02-12.4d768f57 → 0.2.0-dev.2024-02-13.d1d7e6d7

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.
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
@@ -23,95 +22,55 @@ var _map = require("../../helpers/map");
23
22
  var _zarr = require("../../helpers/zarr");
24
23
  var _color = require("../../helpers/color");
25
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
28
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
29
- 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."); }
30
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
31
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
32
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
33
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
34
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
35
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
36
- 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."); }
37
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
38
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
39
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
40
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
25
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
26
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
41
27
  window.deck.log.level = 1;
42
28
  function ScatterplotControls() {
43
- var dataset = (0, _DatasetContext.useDataset)();
44
- var dispatch = (0, _DatasetContext.useDatasetDispatch)();
45
- var colormapList = _constants.PLOTLY_COLORSCALES.map(function (item) {
46
- return /*#__PURE__*/_react.default.createElement(_Dropdown.default.Item, {
47
- key: item,
48
- active: dataset.controls.colorScale === item,
49
- onClick: function onClick() {
50
- dispatch({
51
- type: "set.controls.colorScale",
52
- colorScale: item
53
- });
54
- }
55
- }, item);
56
- });
29
+ const dataset = (0, _DatasetContext.useDataset)();
30
+ const dispatch = (0, _DatasetContext.useDatasetDispatch)();
31
+ const colormapList = _constants.PLOTLY_COLORSCALES.map(item => /*#__PURE__*/_react.default.createElement(_Dropdown.default.Item, {
32
+ key: item,
33
+ active: dataset.controls.colorScale === item,
34
+ onClick: () => {
35
+ dispatch({
36
+ type: "set.controls.colorScale",
37
+ colorScale: item
38
+ });
39
+ }
40
+ }, item));
57
41
  return /*#__PURE__*/_react.default.createElement(_Dropdown.default, null, /*#__PURE__*/_react.default.createElement(_Dropdown.default.Toggle, {
58
42
  id: "dropdownColorscale",
59
43
  variant: "light"
60
44
  }, dataset.controls.colorScale), /*#__PURE__*/_react.default.createElement(_Dropdown.default.Menu, null, colormapList));
61
45
  }
62
46
  function Scatterplot(_ref) {
63
- var _ref$radius = _ref.radius,
64
- radius = _ref$radius === void 0 ? 30 : _ref$radius;
65
- var dataset = (0, _DatasetContext.useDataset)();
66
- var dispatch = (0, _DatasetContext.useDatasetDispatch)();
67
- var _useState = (0, _react.useState)({
68
- type: "FeatureCollection",
69
- features: []
70
- }),
71
- _useState2 = _slicedToArray(_useState, 2),
72
- features = _useState2[0],
73
- setFeatures = _useState2[1];
74
- var _useState3 = (0, _react.useState)(function () {
75
- return _editModes.ViewMode;
76
- }),
77
- _useState4 = _slicedToArray(_useState3, 2),
78
- mode = _useState4[0],
79
- setMode = _useState4[1];
80
- var _useState5 = (0, _react.useState)([]),
81
- _useState6 = _slicedToArray(_useState5, 2),
82
- selectedFeatureIndexes = _useState6[0],
83
- setSelectedFeatureIndexes = _useState6[1];
84
- var _useState7 = (0, _react.useState)([]),
85
- _useState8 = _slicedToArray(_useState7, 2),
86
- featureState = _useState8[0],
87
- setFeatureState = _useState8[1];
88
- var _useState9 = (0, _react.useState)([]),
89
- _useState10 = _slicedToArray(_useState9, 2),
90
- data = _useState10[0],
91
- setData = _useState10[1];
92
- var _useState11 = (0, _react.useState)([]),
93
- _useState12 = _slicedToArray(_useState11, 2),
94
- position = _useState12[0],
95
- setPosition = _useState12[1];
96
- var _useState13 = (0, _react.useState)([]),
97
- _useState14 = _slicedToArray(_useState13, 2),
98
- values = _useState14[0],
99
- setValues = _useState14[1];
100
- var _useState15 = (0, _react.useState)({
101
- longitude: 0,
102
- latitude: 0,
103
- zoom: 0,
104
- maxZoom: 16,
105
- pitch: 0,
106
- bearing: 0
107
- }),
108
- _useState16 = _slicedToArray(_useState15, 2),
109
- viewport = _useState16[0],
110
- setViewport = _useState16[1];
111
- (0, _react.useEffect)(function () {
47
+ let {
48
+ radius = 30
49
+ } = _ref;
50
+ const dataset = (0, _DatasetContext.useDataset)();
51
+ const dispatch = (0, _DatasetContext.useDatasetDispatch)();
52
+ const [features, setFeatures] = (0, _react.useState)({
53
+ type: "FeatureCollection",
54
+ features: []
55
+ });
56
+ const [mode, setMode] = (0, _react.useState)(() => _editModes.ViewMode);
57
+ const [selectedFeatureIndexes, setSelectedFeatureIndexes] = (0, _react.useState)([]);
58
+ let [featureState, setFeatureState] = (0, _react.useState)([]);
59
+ let [data, setData] = (0, _react.useState)([]);
60
+ let [position, setPosition] = (0, _react.useState)([]);
61
+ let [values, setValues] = (0, _react.useState)([]);
62
+ let [viewport, setViewport] = (0, _react.useState)({
63
+ longitude: 0,
64
+ latitude: 0,
65
+ zoom: 0,
66
+ maxZoom: 16,
67
+ pitch: 0,
68
+ bearing: 0
69
+ });
70
+ (0, _react.useEffect)(() => {
112
71
  setData(function (prevState, props) {
113
- var colorHelper = new _color.ColorHelper();
114
- var scale = dataset.colorEncoding === "var" ? colorHelper.getScale(dataset, values) : null;
72
+ const colorHelper = new _color.ColorHelper();
73
+ let scale = dataset.colorEncoding === "var" ? colorHelper.getScale(dataset, values) : null;
115
74
  var data = position.map(function (e, i) {
116
75
  return {
117
76
  index: i,
@@ -123,152 +82,98 @@ function Scatterplot(_ref) {
123
82
  return data;
124
83
  });
125
84
  }, [position, values, dataset.controls.colorScale]);
126
- (0, _react.useEffect)(function () {
85
+ (0, _react.useEffect)(() => {
127
86
  if (dataset.selectedObsm) {
128
- var helper = new _map.MapHelper();
129
- var zarrHelper = new _zarr.ZarrHelper();
130
- var fetchObsm = /*#__PURE__*/function () {
131
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
132
- var z;
133
- return _regeneratorRuntime().wrap(function _callee$(_context) {
134
- while (1) switch (_context.prev = _context.next) {
135
- case 0:
136
- _context.next = 2;
137
- return zarrHelper.open(dataset.url, "obsm/" + dataset.selectedObsm);
138
- case 2:
139
- z = _context.sent;
140
- _context.next = 5;
141
- return z.get(null, _zarr.GET_OPTIONS).then(function (result) {
142
- var _helper$fitBounds = helper.fitBounds(result.data),
143
- latitude = _helper$fitBounds.latitude,
144
- longitude = _helper$fitBounds.longitude,
145
- zoom = _helper$fitBounds.zoom;
146
- setViewport({
147
- longitude: latitude,
148
- latitude: longitude,
149
- zoom: zoom,
150
- maxZoom: 16,
151
- pitch: 0,
152
- bearing: 0
153
- });
154
- setPosition(result.data);
155
- });
156
- case 5:
157
- case "end":
158
- return _context.stop();
159
- }
160
- }, _callee);
161
- }));
162
- return function fetchObsm() {
163
- return _ref2.apply(this, arguments);
164
- };
165
- }();
87
+ const helper = new _map.MapHelper();
88
+ const zarrHelper = new _zarr.ZarrHelper();
89
+ const fetchObsm = async () => {
90
+ const z = await zarrHelper.open(dataset.url, "obsm/" + dataset.selectedObsm);
91
+ await z.get(null, _zarr.GET_OPTIONS).then(result => {
92
+ const {
93
+ latitude,
94
+ longitude,
95
+ zoom
96
+ } = helper.fitBounds(result.data);
97
+ setViewport({
98
+ longitude: latitude,
99
+ latitude: longitude,
100
+ zoom: zoom,
101
+ maxZoom: 16,
102
+ pitch: 0,
103
+ bearing: 0
104
+ });
105
+ setPosition(result.data);
106
+ });
107
+ };
166
108
  fetchObsm().catch(console.error);
167
109
  }
168
110
  }, [dataset.url, dataset.selectedObsm]);
169
- (0, _react.useEffect)(function () {
111
+ (0, _react.useEffect)(() => {
170
112
  if (dataset.selectedVar) {
171
- var zarrHelper = new _zarr.ZarrHelper();
172
- var fetchData = /*#__PURE__*/function () {
173
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
174
- var z;
175
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
176
- while (1) switch (_context2.prev = _context2.next) {
177
- case 0:
178
- _context2.next = 2;
179
- return zarrHelper.open(dataset.url, "X");
180
- case 2:
181
- z = _context2.sent;
182
- _context2.next = 5;
183
- return z.get([null, dataset.selectedVar.matrix_index], _zarr.GET_OPTIONS).then(function (result) {
184
- setValues(result.data);
185
- dispatch({
186
- type: "set.colorEncoding",
187
- value: "var"
188
- });
189
- });
190
- case 5:
191
- case "end":
192
- return _context2.stop();
193
- }
194
- }, _callee2);
195
- }));
196
- return function fetchData() {
197
- return _ref3.apply(this, arguments);
198
- };
199
- }();
113
+ const zarrHelper = new _zarr.ZarrHelper();
114
+ const fetchData = async () => {
115
+ const z = await zarrHelper.open(dataset.url, "X");
116
+ await z.get([null, dataset.selectedVar.matrix_index], _zarr.GET_OPTIONS).then(result => {
117
+ setValues(result.data);
118
+ dispatch({
119
+ type: "set.colorEncoding",
120
+ value: "var"
121
+ });
122
+ });
123
+ };
200
124
  fetchData().catch(console.error);
201
125
  }
202
126
  }, [dataset.url, dataset.selectedVar]);
203
- (0, _react.useEffect)(function () {
127
+ (0, _react.useEffect)(() => {
204
128
  if (dataset.selectedObs) {
205
- var zarrHelper = new _zarr.ZarrHelper();
206
- var fetchData = /*#__PURE__*/function () {
207
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
208
- var z;
209
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
210
- while (1) switch (_context3.prev = _context3.next) {
211
- case 0:
212
- _context3.next = 2;
213
- return zarrHelper.open(dataset.url, "obs/" + dataset.selectedObs.name + "/codes");
214
- case 2:
215
- z = _context3.sent;
216
- _context3.next = 5;
217
- return z.get().then(function (result) {
218
- setValues(result.data);
219
- dispatch({
220
- type: "set.colorEncoding",
221
- value: "obs"
222
- });
223
- });
224
- case 5:
225
- case "end":
226
- return _context3.stop();
227
- }
228
- }, _callee3);
229
- }));
230
- return function fetchData() {
231
- return _ref4.apply(this, arguments);
232
- };
233
- }();
129
+ const zarrHelper = new _zarr.ZarrHelper();
130
+ const fetchData = async () => {
131
+ const z = await zarrHelper.open(dataset.url, "obs/" + dataset.selectedObs.name + "/codes");
132
+ await z.get().then(result => {
133
+ setValues(result.data);
134
+ dispatch({
135
+ type: "set.colorEncoding",
136
+ value: "obs"
137
+ });
138
+ });
139
+ };
234
140
  fetchData().catch(console.error);
235
141
  }
236
142
  }, [dataset.url, dataset.selectedObs]);
237
- var layers = [new _layers.ScatterplotLayer({
143
+ const layers = [new _layers.ScatterplotLayer({
238
144
  id: "cherita-layer-scatterplot",
239
- data: data,
145
+ data,
240
146
  radiusScale: radius,
241
147
  radiusMinPixels: 1,
242
- getPosition: function getPosition(d) {
243
- return d.position;
244
- },
245
- getFillColor: function getFillColor(d) {
246
- return d.color;
247
- },
148
+ getPosition: d => d.position,
149
+ getFillColor: d => d.color,
248
150
  getRadius: 1
249
151
  }), new _layers2.EditableGeoJsonLayer({
250
152
  id: "cherita-layer-draw",
251
153
  data: features,
252
- mode: mode,
253
- selectedFeatureIndexes: selectedFeatureIndexes,
254
- onEdit: function onEdit(_ref5) {
255
- var updatedData = _ref5.updatedData,
256
- editType = _ref5.editType,
257
- editContext = _ref5.editContext;
154
+ mode,
155
+ selectedFeatureIndexes,
156
+ onEdit: _ref2 => {
157
+ let {
158
+ updatedData,
159
+ editType,
160
+ editContext
161
+ } = _ref2;
258
162
  setFeatures(updatedData);
259
- var updatedSelectedFeatureIndexes = selectedFeatureIndexes;
163
+ let updatedSelectedFeatureIndexes = selectedFeatureIndexes;
260
164
  setFeatureState({
261
165
  data: updatedData
262
166
  });
263
167
  if (editType === "addFeature") {
264
168
  // when a drawing is complete, the value of editType becomes addFeature
265
- var featureIndexes = editContext.featureIndexes; //extracting indexes of current features selected
266
- updatedSelectedFeatureIndexes = [].concat(_toConsumableArray(selectedFeatureIndexes), _toConsumableArray(featureIndexes));
169
+ const {
170
+ featureIndexes
171
+ } = editContext; //extracting indexes of current features selected
172
+ updatedSelectedFeatureIndexes = [...selectedFeatureIndexes, ...featureIndexes];
267
173
  }
268
174
  setSelectedFeatureIndexes(updatedSelectedFeatureIndexes); //now update your state
269
175
  }
270
176
  })];
271
-
272
177
  function onLayerClick(info) {
273
178
  if (mode !== _editModes.ViewMode) {
274
179
  // don't change selection while editing
@@ -15,45 +15,35 @@ var _reactFontawesome = require("@fortawesome/react-fontawesome");
15
15
  var _freeSolidSvgIcons = require("@fortawesome/free-solid-svg-icons");
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
  function Toolbox(_ref) {
18
- var mode = _ref.mode,
19
- setMode = _ref.setMode,
20
- features = _ref.features,
21
- setFeatures = _ref.setFeatures;
22
- var onSelect = function onSelect(eventKey, event) {
18
+ let {
19
+ mode,
20
+ setMode,
21
+ features,
22
+ setFeatures
23
+ } = _ref;
24
+ const onSelect = (eventKey, event) => {
23
25
  console.log(eventKey); // selected event will trigger
24
26
  switch (eventKey) {
25
27
  case "DrawPolygonMode":
26
- setMode(function () {
27
- return _editModes.DrawPolygonMode;
28
- });
28
+ setMode(() => _editModes.DrawPolygonMode);
29
29
  break;
30
30
  case "DrawLineStringMode":
31
- setMode(function () {
32
- return _editModes.DrawLineStringMode;
33
- });
31
+ setMode(() => _editModes.DrawLineStringMode);
34
32
  break;
35
33
  case "DrawPolygonByDraggingMode":
36
- setMode(function () {
37
- return _editModes.DrawPolygonByDraggingMode;
38
- });
34
+ setMode(() => _editModes.DrawPolygonByDraggingMode);
39
35
  break;
40
36
  case "DrawRectangleMode":
41
- setMode(function () {
42
- return _editModes.DrawRectangleMode;
43
- });
37
+ setMode(() => _editModes.DrawRectangleMode);
44
38
  break;
45
39
  case "ModifyMode":
46
- setMode(function () {
47
- return _editModes.ModifyMode;
48
- });
40
+ setMode(() => _editModes.ModifyMode);
49
41
  break;
50
42
  default:
51
- setMode(function () {
52
- return _editModes.ViewMode;
53
- });
43
+ setMode(() => _editModes.ViewMode);
54
44
  }
55
45
  };
56
- var deleteFeatures = function deleteFeatures(eventKey, event) {
46
+ const deleteFeatures = (eventKey, event) => {
57
47
  console.log(eventKey); // selected event will trigger
58
48
  setFeatures({
59
49
  type: "FeatureCollection",