cod-dicomweb-server 1.3.11 → 1.3.13
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.
- package/dist/cjs/main.js +1764 -1724
- package/dist/esm/classes/CodDicomWebServer.d.ts +2 -1
- package/dist/esm/classes/CodDicomWebServer.js +69 -27
- package/dist/esm/classes/customClasses.d.ts +1 -0
- package/dist/esm/dataRetrieval/dataRetrievalManager.d.ts +1 -1
- package/dist/esm/dataRetrieval/dataRetrievalManager.js +1 -0
- package/dist/esm/dataRetrieval/register.d.ts +1 -1
- package/dist/esm/dataRetrieval/register.js +1 -2
- package/dist/esm/dataRetrieval/requestManager.d.ts +1 -1
- package/dist/esm/dataRetrieval/scripts/filePartial.d.ts +1 -1
- package/dist/esm/dataRetrieval/scripts/filePartial.js +7 -4
- package/dist/esm/dataRetrieval/scripts/fileStreaming.d.ts +1 -4
- package/dist/esm/dataRetrieval/scripts/fileStreaming.js +8 -28
- package/dist/esm/dataRetrieval/workerManager.d.ts +1 -1
- package/dist/esm/fileManager.d.ts +3 -7
- package/dist/esm/fileManager.js +29 -17
- package/dist/esm/types/codDicomWebServerOptions.d.ts +1 -1
- package/dist/esm/types/fileManagerFile.d.ts +6 -0
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/types/index.js +1 -1
- package/dist/umd/563.js +2 -2
- package/dist/umd/563.js.map +1 -1
- package/dist/umd/846.js +2 -2
- package/dist/umd/846.js.map +1 -1
- package/dist/umd/main.js +3 -3
- package/dist/umd/main.js.map +1 -1
- package/package.json +1 -1
- package/dist/esm/types/fileManagerOptions.d.ts +0 -4
- /package/dist/esm/types/{fileManagerOptions.js → fileManagerFile.js} +0 -0
package/dist/cjs/main.js
CHANGED
|
@@ -192,16 +192,134 @@ var URLType = /*#__PURE__*/function (URLType) {
|
|
|
192
192
|
}({});
|
|
193
193
|
// EXTERNAL MODULE: ./node_modules/dicom-parser/dist/dicomParser.min.js
|
|
194
194
|
var dicomParser_min = __webpack_require__(915);
|
|
195
|
-
;// ./src/
|
|
195
|
+
;// ./src/fileManager.ts
|
|
196
196
|
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); }
|
|
197
|
-
function
|
|
197
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
198
|
+
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."); }
|
|
199
|
+
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; } }
|
|
200
|
+
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; }
|
|
201
|
+
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; } }
|
|
202
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
203
|
+
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; }
|
|
204
|
+
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; }
|
|
205
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
198
206
|
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); } }
|
|
199
207
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
208
|
+
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; }
|
|
200
209
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
201
210
|
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); }
|
|
202
|
-
|
|
211
|
+
var FileManager = /*#__PURE__*/function () {
|
|
212
|
+
function FileManager() {
|
|
213
|
+
_classCallCheck(this, FileManager);
|
|
214
|
+
_defineProperty(this, "files", {});
|
|
215
|
+
}
|
|
216
|
+
return _createClass(FileManager, [{
|
|
217
|
+
key: "set",
|
|
218
|
+
value: function set(url, file) {
|
|
219
|
+
this.files[url] = _objectSpread(_objectSpread({}, file), {}, {
|
|
220
|
+
lastModified: Date.now()
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}, {
|
|
224
|
+
key: "get",
|
|
225
|
+
value: function get(url, offsets) {
|
|
226
|
+
if (!this.files[url] || offsets && this.files[url].position <= offsets.endByte) {
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
return offsets ? this.files[url].data.slice(offsets.startByte, offsets.endByte) : this.files[url].data;
|
|
230
|
+
}
|
|
231
|
+
}, {
|
|
232
|
+
key: "setPosition",
|
|
233
|
+
value: function setPosition(url, position) {
|
|
234
|
+
if (this.files[url]) {
|
|
235
|
+
this.files[url].position = position;
|
|
236
|
+
this.files[url].lastModified = Date.now();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}, {
|
|
240
|
+
key: "getPosition",
|
|
241
|
+
value: function getPosition(url) {
|
|
242
|
+
var _this$files$url;
|
|
243
|
+
return (_this$files$url = this.files[url]) === null || _this$files$url === void 0 ? void 0 : _this$files$url.position;
|
|
244
|
+
}
|
|
245
|
+
}, {
|
|
246
|
+
key: "append",
|
|
247
|
+
value: function append(url, chunk, position) {
|
|
248
|
+
if (this.files[url] && position) {
|
|
249
|
+
this.files[url].data.set(chunk, position - chunk.length);
|
|
250
|
+
this.setPosition(url, position);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}, {
|
|
254
|
+
key: "getTotalSize",
|
|
255
|
+
value: function getTotalSize() {
|
|
256
|
+
return Object.values(this.files).reduce(function (total, _ref) {
|
|
257
|
+
var data = _ref.data;
|
|
258
|
+
return total + data.byteLength;
|
|
259
|
+
}, 0);
|
|
260
|
+
}
|
|
261
|
+
}, {
|
|
262
|
+
key: "remove",
|
|
263
|
+
value: function remove(url) {
|
|
264
|
+
try {
|
|
265
|
+
delete this.files[url];
|
|
266
|
+
console.log("Removed ".concat(url, " from CodDicomwebServer cache"));
|
|
267
|
+
} catch (error) {
|
|
268
|
+
console.warn("Error removing ".concat(url, " from CodDicomwebServer cache:"), error);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}, {
|
|
272
|
+
key: "purge",
|
|
273
|
+
value: function purge() {
|
|
274
|
+
var _this = this;
|
|
275
|
+
var fileURLs = Object.keys(this.files);
|
|
276
|
+
var totalSize = this.getTotalSize();
|
|
277
|
+
fileURLs.forEach(function (url) {
|
|
278
|
+
return _this.remove(url);
|
|
279
|
+
});
|
|
280
|
+
console.log("Purged ".concat(totalSize - this.getTotalSize(), " bytes from CodDicomwebServer cache"));
|
|
281
|
+
}
|
|
282
|
+
}, {
|
|
283
|
+
key: "decacheNecessaryBytes",
|
|
284
|
+
value: function decacheNecessaryBytes(url, bytesNeeded) {
|
|
285
|
+
var _this2 = this;
|
|
286
|
+
var totalSize = this.getTotalSize();
|
|
287
|
+
var filesToDelete = [];
|
|
288
|
+
var collectiveSize = 0;
|
|
289
|
+
Object.entries(this.files).sort(function (_ref2, _ref3) {
|
|
290
|
+
var _ref4 = _slicedToArray(_ref2, 2),
|
|
291
|
+
a = _ref4[1];
|
|
292
|
+
var _ref5 = _slicedToArray(_ref3, 2),
|
|
293
|
+
b = _ref5[1];
|
|
294
|
+
return a.lastModified - b.lastModified;
|
|
295
|
+
}).forEach(function (_ref6) {
|
|
296
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
|
297
|
+
key = _ref7[0],
|
|
298
|
+
file = _ref7[1];
|
|
299
|
+
if (collectiveSize < bytesNeeded && key !== url) {
|
|
300
|
+
filesToDelete.push(key);
|
|
301
|
+
collectiveSize += file.data.byteLength;
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
filesToDelete.forEach(function (key) {
|
|
305
|
+
return _this2.remove(key);
|
|
306
|
+
});
|
|
307
|
+
console.log("Decached ".concat(totalSize - this.getTotalSize(), " bytes"));
|
|
308
|
+
return collectiveSize;
|
|
309
|
+
}
|
|
310
|
+
}]);
|
|
311
|
+
}();
|
|
312
|
+
/* harmony default export */ const fileManager = (FileManager);
|
|
313
|
+
;// ./src/classes/customClasses.ts
|
|
314
|
+
function customClasses_typeof(o) { "@babel/helpers - typeof"; return customClasses_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; }, customClasses_typeof(o); }
|
|
315
|
+
function customClasses_defineProperty(e, r, t) { return (r = customClasses_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
316
|
+
function customClasses_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, customClasses_toPropertyKey(o.key), o); } }
|
|
317
|
+
function customClasses_createClass(e, r, t) { return r && customClasses_defineProperties(e.prototype, r), t && customClasses_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
318
|
+
function customClasses_toPropertyKey(t) { var i = customClasses_toPrimitive(t, "string"); return "symbol" == customClasses_typeof(i) ? i : i + ""; }
|
|
319
|
+
function customClasses_toPrimitive(t, r) { if ("object" != customClasses_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != customClasses_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
320
|
+
function customClasses_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
203
321
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
204
|
-
function _possibleConstructorReturn(t, e) { if (e && ("object" ==
|
|
322
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == customClasses_typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
205
323
|
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
206
324
|
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
207
325
|
function _wrapNativeSuper(t) { var r = "function" == typeof Map ? new Map() : void 0; return _wrapNativeSuper = function _wrapNativeSuper(t) { if (null === t || !_isNativeFunction(t)) return t; if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); if (void 0 !== r) { if (r.has(t)) return r.get(t); r.set(t, Wrapper); } function Wrapper() { return _construct(t, arguments, _getPrototypeOf(this).constructor); } return Wrapper.prototype = Object.create(t.prototype, { constructor: { value: Wrapper, enumerable: !1, writable: !0, configurable: !0 } }), _setPrototypeOf(Wrapper, t); }, _wrapNativeSuper(t); }
|
|
@@ -212,33 +330,33 @@ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf
|
|
|
212
330
|
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
213
331
|
var CustomError = /*#__PURE__*/function (_Error) {
|
|
214
332
|
function CustomError() {
|
|
215
|
-
|
|
333
|
+
customClasses_classCallCheck(this, CustomError);
|
|
216
334
|
return _callSuper(this, CustomError, arguments);
|
|
217
335
|
}
|
|
218
336
|
_inherits(CustomError, _Error);
|
|
219
|
-
return
|
|
337
|
+
return customClasses_createClass(CustomError);
|
|
220
338
|
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
221
339
|
var CustomErrorEvent = /*#__PURE__*/function (_Event) {
|
|
222
340
|
function CustomErrorEvent(message, error) {
|
|
223
341
|
var _this;
|
|
224
|
-
|
|
342
|
+
customClasses_classCallCheck(this, CustomErrorEvent);
|
|
225
343
|
_this = _callSuper(this, CustomErrorEvent, [message]);
|
|
226
|
-
|
|
227
|
-
|
|
344
|
+
customClasses_defineProperty(_this, "error", void 0);
|
|
345
|
+
customClasses_defineProperty(_this, "message", void 0);
|
|
228
346
|
_this.message = message;
|
|
229
347
|
_this.error = error;
|
|
230
348
|
return _this;
|
|
231
349
|
}
|
|
232
350
|
_inherits(CustomErrorEvent, _Event);
|
|
233
|
-
return
|
|
351
|
+
return customClasses_createClass(CustomErrorEvent);
|
|
234
352
|
}(/*#__PURE__*/_wrapNativeSuper(Event));
|
|
235
353
|
var CustomMessageEvent = /*#__PURE__*/(/* unused pure expression or super */ null && (function (_MessageEvent) {
|
|
236
354
|
function CustomMessageEvent() {
|
|
237
|
-
|
|
355
|
+
customClasses_classCallCheck(this, CustomMessageEvent);
|
|
238
356
|
return _callSuper(this, CustomMessageEvent, arguments);
|
|
239
357
|
}
|
|
240
358
|
_inherits(CustomMessageEvent, _MessageEvent);
|
|
241
|
-
return
|
|
359
|
+
return customClasses_createClass(CustomMessageEvent);
|
|
242
360
|
}(/*#__PURE__*/_wrapNativeSuper(MessageEvent))));
|
|
243
361
|
;// ./src/constants/url.ts
|
|
244
362
|
var DOMAIN = 'https://storage.googleapis.com';
|
|
@@ -263,1697 +381,1609 @@ var constants = {
|
|
|
263
381
|
};
|
|
264
382
|
|
|
265
383
|
/* harmony default export */ const src_constants = (constants);
|
|
266
|
-
;// ./src/
|
|
267
|
-
function
|
|
268
|
-
function
|
|
269
|
-
function
|
|
270
|
-
function
|
|
271
|
-
function
|
|
272
|
-
function
|
|
273
|
-
function requestManager_createClass(e, r, t) { return r && requestManager_defineProperties(e.prototype, r), t && requestManager_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
274
|
-
function requestManager_defineProperty(e, r, t) { return (r = requestManager_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
275
|
-
function requestManager_toPropertyKey(t) { var i = requestManager_toPrimitive(t, "string"); return "symbol" == requestManager_typeof(i) ? i : i + ""; }
|
|
276
|
-
function requestManager_toPrimitive(t, r) { if ("object" != requestManager_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != requestManager_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
384
|
+
;// ./src/classes/utils.ts
|
|
385
|
+
function utils_slicedToArray(r, e) { return utils_arrayWithHoles(r) || utils_iterableToArrayLimit(r, e) || utils_unsupportedIterableToArray(r, e) || utils_nonIterableRest(); }
|
|
386
|
+
function utils_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."); }
|
|
387
|
+
function utils_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return utils_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) ? utils_arrayLikeToArray(r, a) : void 0; } }
|
|
388
|
+
function utils_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; }
|
|
389
|
+
function utils_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; } }
|
|
390
|
+
function utils_arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
277
391
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
requestManager_defineProperty(this, "loaderRegistry", {});
|
|
283
|
-
requestManager_defineProperty(this, "listenerCallback", function (loaderName, taskName, args) {
|
|
284
|
-
var _this$loaderRegistry$;
|
|
285
|
-
var listeners = (_this$loaderRegistry$ = _this.loaderRegistry[loaderName]) === null || _this$loaderRegistry$ === void 0 ? void 0 : _this$loaderRegistry$.listeners[taskName];
|
|
286
|
-
if (listeners) {
|
|
287
|
-
listeners.forEach(function (listener) {
|
|
288
|
-
return listener({
|
|
289
|
-
data: args
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
});
|
|
392
|
+
|
|
393
|
+
function parseWadorsURL(url, domain) {
|
|
394
|
+
if (!url.includes(src_constants.url.URL_VALIDATION_STRING)) {
|
|
395
|
+
return;
|
|
294
396
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
var _this$loaderRegistry$2,
|
|
316
|
-
_this2 = this;
|
|
317
|
-
var loaderObject;
|
|
318
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
319
|
-
while (1) switch (_context.prev = _context.next) {
|
|
320
|
-
case 0:
|
|
321
|
-
loaderObject = (_this$loaderRegistry$2 = this.loaderRegistry[loaderName]) === null || _this$loaderRegistry$2 === void 0 ? void 0 : _this$loaderRegistry$2.loaderObject;
|
|
322
|
-
if (loaderObject) {
|
|
323
|
-
_context.next = 3;
|
|
324
|
-
break;
|
|
325
|
-
}
|
|
326
|
-
throw new CustomError("Loader ".concat(loaderName, " not registered"));
|
|
327
|
-
case 3:
|
|
328
|
-
_context.prev = 3;
|
|
329
|
-
_context.next = 6;
|
|
330
|
-
return loaderObject[taskName](options, function (args) {
|
|
331
|
-
return _this2.listenerCallback(loaderName, 'message', args);
|
|
332
|
-
});
|
|
333
|
-
case 6:
|
|
334
|
-
return _context.abrupt("return", _context.sent);
|
|
335
|
-
case 9:
|
|
336
|
-
_context.prev = 9;
|
|
337
|
-
_context.t0 = _context["catch"](3);
|
|
338
|
-
console.error("Error executing task \"".concat(taskName, "\" on \"").concat(loaderName, "\":"), _context.t0);
|
|
339
|
-
throw new CustomError("Task \"".concat(taskName, "\" failed: ").concat(_context.t0.message));
|
|
340
|
-
case 13:
|
|
341
|
-
case "end":
|
|
342
|
-
return _context.stop();
|
|
343
|
-
}
|
|
344
|
-
}, _callee, this, [[3, 9]]);
|
|
345
|
-
}));
|
|
346
|
-
function executeTask(_x, _x2, _x3) {
|
|
347
|
-
return _executeTask.apply(this, arguments);
|
|
348
|
-
}
|
|
349
|
-
return executeTask;
|
|
350
|
-
}()
|
|
351
|
-
}, {
|
|
352
|
-
key: "addEventListener",
|
|
353
|
-
value: function addEventListener(workerName, eventType, listener) {
|
|
354
|
-
var loaderObject = this.loaderRegistry[workerName];
|
|
355
|
-
if (!loaderObject) {
|
|
356
|
-
console.error("Loader '".concat(workerName, "' is not registered."));
|
|
357
|
-
return;
|
|
358
|
-
}
|
|
359
|
-
if (!loaderObject.listeners[eventType]) {
|
|
360
|
-
loaderObject.listeners[eventType] = [listener];
|
|
397
|
+
var filePath = url.split(domain + '/')[1];
|
|
398
|
+
var prefix = filePath.split('/studies')[0];
|
|
399
|
+
var prefixParts = prefix.split('/');
|
|
400
|
+
var bucketName = prefixParts[0];
|
|
401
|
+
var bucketPrefix = prefixParts.slice(1).join('/');
|
|
402
|
+
var imagePath = filePath.split(prefix + '/')[1];
|
|
403
|
+
var imageParts = imagePath.split('/');
|
|
404
|
+
var studyInstanceUID = imageParts[1];
|
|
405
|
+
var seriesInstanceUID = imageParts[3];
|
|
406
|
+
var sopInstanceUID = '',
|
|
407
|
+
frameNumber = 1,
|
|
408
|
+
type;
|
|
409
|
+
switch (true) {
|
|
410
|
+
case imageParts.includes('thumbnail'):
|
|
411
|
+
type = RequestType.THUMBNAIL;
|
|
412
|
+
break;
|
|
413
|
+
case imageParts.includes('metadata'):
|
|
414
|
+
if (imageParts.includes('instances')) {
|
|
415
|
+
sopInstanceUID = imageParts[5];
|
|
416
|
+
type = RequestType.INSTANCE_METADATA;
|
|
361
417
|
} else {
|
|
362
|
-
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
}, {
|
|
366
|
-
key: "removeEventListener",
|
|
367
|
-
value: function removeEventListener(workerName, eventType, listener) {
|
|
368
|
-
var loaderObject = this.loaderRegistry[workerName];
|
|
369
|
-
if (!loaderObject) {
|
|
370
|
-
console.error("Loader '".concat(workerName, "' is not registered."));
|
|
371
|
-
return;
|
|
418
|
+
type = RequestType.SERIES_METADATA;
|
|
372
419
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
420
|
+
break;
|
|
421
|
+
case imageParts.includes('frames'):
|
|
422
|
+
sopInstanceUID = imageParts[5];
|
|
423
|
+
frameNumber = +imageParts[7];
|
|
424
|
+
type = RequestType.FRAME;
|
|
425
|
+
break;
|
|
426
|
+
default:
|
|
427
|
+
throw new CustomError('Invalid type of request');
|
|
428
|
+
}
|
|
429
|
+
return {
|
|
430
|
+
type: type,
|
|
431
|
+
bucketName: bucketName,
|
|
432
|
+
bucketPrefix: bucketPrefix,
|
|
433
|
+
studyInstanceUID: studyInstanceUID,
|
|
434
|
+
seriesInstanceUID: seriesInstanceUID,
|
|
435
|
+
sopInstanceUID: sopInstanceUID,
|
|
436
|
+
frameNumber: frameNumber
|
|
437
|
+
};
|
|
388
438
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
throw serialized.value;
|
|
443
|
-
},
|
|
444
|
-
};
|
|
445
|
-
/**
|
|
446
|
-
* Allows customizing the serialization of certain values.
|
|
447
|
-
*/
|
|
448
|
-
const transferHandlers = new Map([
|
|
449
|
-
["proxy", proxyTransferHandler],
|
|
450
|
-
["throw", throwTransferHandler],
|
|
451
|
-
]);
|
|
452
|
-
function isAllowedOrigin(allowedOrigins, origin) {
|
|
453
|
-
for (const allowedOrigin of allowedOrigins) {
|
|
454
|
-
if (origin === allowedOrigin || allowedOrigin === "*") {
|
|
455
|
-
return true;
|
|
456
|
-
}
|
|
457
|
-
if (allowedOrigin instanceof RegExp && allowedOrigin.test(origin)) {
|
|
458
|
-
return true;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
return false;
|
|
462
|
-
}
|
|
463
|
-
function expose(obj, ep = globalThis, allowedOrigins = ["*"]) {
|
|
464
|
-
ep.addEventListener("message", function callback(ev) {
|
|
465
|
-
if (!ev || !ev.data) {
|
|
466
|
-
return;
|
|
467
|
-
}
|
|
468
|
-
if (!isAllowedOrigin(allowedOrigins, ev.origin)) {
|
|
469
|
-
console.warn(`Invalid origin '${ev.origin}' for comlink proxy`);
|
|
470
|
-
return;
|
|
471
|
-
}
|
|
472
|
-
const { id, type, path } = Object.assign({ path: [] }, ev.data);
|
|
473
|
-
const argumentList = (ev.data.argumentList || []).map(fromWireValue);
|
|
474
|
-
let returnValue;
|
|
475
|
-
try {
|
|
476
|
-
const parent = path.slice(0, -1).reduce((obj, prop) => obj[prop], obj);
|
|
477
|
-
const rawValue = path.reduce((obj, prop) => obj[prop], obj);
|
|
478
|
-
switch (type) {
|
|
479
|
-
case "GET" /* MessageType.GET */:
|
|
480
|
-
{
|
|
481
|
-
returnValue = rawValue;
|
|
482
|
-
}
|
|
483
|
-
break;
|
|
484
|
-
case "SET" /* MessageType.SET */:
|
|
485
|
-
{
|
|
486
|
-
parent[path.slice(-1)[0]] = fromWireValue(ev.data.value);
|
|
487
|
-
returnValue = true;
|
|
488
|
-
}
|
|
489
|
-
break;
|
|
490
|
-
case "APPLY" /* MessageType.APPLY */:
|
|
491
|
-
{
|
|
492
|
-
returnValue = rawValue.apply(parent, argumentList);
|
|
493
|
-
}
|
|
494
|
-
break;
|
|
495
|
-
case "CONSTRUCT" /* MessageType.CONSTRUCT */:
|
|
496
|
-
{
|
|
497
|
-
const value = new rawValue(...argumentList);
|
|
498
|
-
returnValue = proxy(value);
|
|
499
|
-
}
|
|
500
|
-
break;
|
|
501
|
-
case "ENDPOINT" /* MessageType.ENDPOINT */:
|
|
502
|
-
{
|
|
503
|
-
const { port1, port2 } = new MessageChannel();
|
|
504
|
-
expose(obj, port2);
|
|
505
|
-
returnValue = transfer(port1, [port1]);
|
|
506
|
-
}
|
|
507
|
-
break;
|
|
508
|
-
case "RELEASE" /* MessageType.RELEASE */:
|
|
509
|
-
{
|
|
510
|
-
returnValue = undefined;
|
|
511
|
-
}
|
|
512
|
-
break;
|
|
513
|
-
default:
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
catch (value) {
|
|
518
|
-
returnValue = { value, [throwMarker]: 0 };
|
|
519
|
-
}
|
|
520
|
-
Promise.resolve(returnValue)
|
|
521
|
-
.catch((value) => {
|
|
522
|
-
return { value, [throwMarker]: 0 };
|
|
523
|
-
})
|
|
524
|
-
.then((returnValue) => {
|
|
525
|
-
const [wireValue, transferables] = toWireValue(returnValue);
|
|
526
|
-
ep.postMessage(Object.assign(Object.assign({}, wireValue), { id }), transferables);
|
|
527
|
-
if (type === "RELEASE" /* MessageType.RELEASE */) {
|
|
528
|
-
// detach and deactive after sending release response above.
|
|
529
|
-
ep.removeEventListener("message", callback);
|
|
530
|
-
closeEndPoint(ep);
|
|
531
|
-
if (finalizer in obj && typeof obj[finalizer] === "function") {
|
|
532
|
-
obj[finalizer]();
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
})
|
|
536
|
-
.catch((error) => {
|
|
537
|
-
// Send Serialization Error To Caller
|
|
538
|
-
const [wireValue, transferables] = toWireValue({
|
|
539
|
-
value: new TypeError("Unserializable return value"),
|
|
540
|
-
[throwMarker]: 0,
|
|
541
|
-
});
|
|
542
|
-
ep.postMessage(Object.assign(Object.assign({}, wireValue), { id }), transferables);
|
|
543
|
-
});
|
|
544
|
-
});
|
|
545
|
-
if (ep.start) {
|
|
546
|
-
ep.start();
|
|
547
|
-
}
|
|
439
|
+
function getFrameDetailsFromMetadata(seriesMetadata, sopInstanceUID, frameIndex, bucketDetails) {
|
|
440
|
+
var _seriesMetadata$cod, _Object$entries$find;
|
|
441
|
+
if (!seriesMetadata || !((_seriesMetadata$cod = seriesMetadata.cod) !== null && _seriesMetadata$cod !== void 0 && _seriesMetadata$cod.instances)) {
|
|
442
|
+
throw new CustomError('Invalid seriesMetadata provided.');
|
|
443
|
+
}
|
|
444
|
+
if (frameIndex === null || frameIndex === undefined) {
|
|
445
|
+
throw new CustomError('Frame index is required.');
|
|
446
|
+
}
|
|
447
|
+
var domain = bucketDetails.domain,
|
|
448
|
+
bucketName = bucketDetails.bucketName,
|
|
449
|
+
bucketPrefix = bucketDetails.bucketPrefix;
|
|
450
|
+
var thumbnailUrl;
|
|
451
|
+
if (seriesMetadata.thumbnail) {
|
|
452
|
+
var thumbnailGsUtilUri = seriesMetadata.thumbnail.uri;
|
|
453
|
+
thumbnailUrl = "".concat(domain, "/").concat(thumbnailGsUtilUri.split('gs://')[1]);
|
|
454
|
+
}
|
|
455
|
+
var instanceFound = (_Object$entries$find = Object.entries(seriesMetadata.cod.instances).find(function (_ref) {
|
|
456
|
+
var _ref2 = utils_slicedToArray(_ref, 2),
|
|
457
|
+
key = _ref2[0],
|
|
458
|
+
instance = _ref2[1];
|
|
459
|
+
return key === sopInstanceUID;
|
|
460
|
+
})) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[1];
|
|
461
|
+
if (!instanceFound) {
|
|
462
|
+
return {
|
|
463
|
+
thumbnailUrl: thumbnailUrl
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
var url = instanceFound.url,
|
|
467
|
+
uri = instanceFound.uri,
|
|
468
|
+
offsetHeaders = instanceFound.headers,
|
|
469
|
+
offset_tables = instanceFound.offset_tables;
|
|
470
|
+
var modifiedUrl = handleUrl(url || uri, domain, bucketName, bucketPrefix);
|
|
471
|
+
var CustomOffsetTable = offset_tables.CustomOffsetTable,
|
|
472
|
+
CustomOffsetTableLengths = offset_tables.CustomOffsetTableLengths;
|
|
473
|
+
var sliceStart,
|
|
474
|
+
sliceEnd,
|
|
475
|
+
isMultiframe = false;
|
|
476
|
+
if (CustomOffsetTable !== null && CustomOffsetTable !== void 0 && CustomOffsetTable.length && CustomOffsetTableLengths !== null && CustomOffsetTableLengths !== void 0 && CustomOffsetTableLengths.length) {
|
|
477
|
+
sliceStart = CustomOffsetTable[frameIndex];
|
|
478
|
+
sliceEnd = sliceStart + CustomOffsetTableLengths[frameIndex];
|
|
479
|
+
isMultiframe = true;
|
|
480
|
+
}
|
|
481
|
+
var fileStartByte = offsetHeaders.start_byte,
|
|
482
|
+
fileEndByte = offsetHeaders.end_byte;
|
|
483
|
+
var startByte = sliceStart !== undefined ? fileStartByte + sliceStart : fileStartByte;
|
|
484
|
+
var endByte = sliceEnd !== undefined ? fileStartByte + sliceEnd : fileEndByte;
|
|
485
|
+
return {
|
|
486
|
+
url: modifiedUrl,
|
|
487
|
+
startByte: startByte,
|
|
488
|
+
endByte: endByte,
|
|
489
|
+
thumbnailUrl: thumbnailUrl,
|
|
490
|
+
isMultiframe: isMultiframe
|
|
491
|
+
};
|
|
548
492
|
}
|
|
549
|
-
function
|
|
550
|
-
|
|
493
|
+
function handleUrl(url, domain, bucketName, bucketPrefix) {
|
|
494
|
+
var modifiedUrl = url;
|
|
495
|
+
var matchingExtension = src_constants.url.FILE_EXTENSIONS.find(function (extension) {
|
|
496
|
+
return url.includes(extension);
|
|
497
|
+
});
|
|
498
|
+
if (matchingExtension) {
|
|
499
|
+
var fileParts = url.split(matchingExtension);
|
|
500
|
+
modifiedUrl = fileParts[0] + matchingExtension;
|
|
501
|
+
}
|
|
502
|
+
var filePath = modifiedUrl.split('studies/')[1];
|
|
503
|
+
modifiedUrl = "".concat(domain, "/").concat(bucketName, "/").concat(bucketPrefix ? bucketPrefix + '/' : '', "studies/").concat(filePath);
|
|
504
|
+
return modifiedUrl;
|
|
551
505
|
}
|
|
552
|
-
function
|
|
553
|
-
|
|
554
|
-
|
|
506
|
+
function createMetadataJsonUrl(params) {
|
|
507
|
+
var _params$domain = params.domain,
|
|
508
|
+
domain = _params$domain === void 0 ? src_constants.url.DOMAIN : _params$domain,
|
|
509
|
+
bucketName = params.bucketName,
|
|
510
|
+
bucketPrefix = params.bucketPrefix,
|
|
511
|
+
studyInstanceUID = params.studyInstanceUID,
|
|
512
|
+
seriesInstanceUID = params.seriesInstanceUID;
|
|
513
|
+
if (!bucketName || !bucketPrefix || !studyInstanceUID || !seriesInstanceUID) {
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
return "".concat(domain, "/").concat(bucketName, "/").concat(bucketPrefix, "/studies/").concat(studyInstanceUID, "/series/").concat(seriesInstanceUID, "/metadata.json");
|
|
555
517
|
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
const resolver = pendingListeners.get(data.id);
|
|
564
|
-
if (!resolver) {
|
|
565
|
-
return;
|
|
566
|
-
}
|
|
567
|
-
try {
|
|
568
|
-
resolver(data);
|
|
569
|
-
}
|
|
570
|
-
finally {
|
|
571
|
-
pendingListeners.delete(data.id);
|
|
572
|
-
}
|
|
518
|
+
;// ./node_modules/idb-keyval/dist/index.js
|
|
519
|
+
function promisifyRequest(request) {
|
|
520
|
+
return new Promise((resolve, reject) => {
|
|
521
|
+
// @ts-ignore - file size hacks
|
|
522
|
+
request.oncomplete = request.onsuccess = () => resolve(request.result);
|
|
523
|
+
// @ts-ignore - file size hacks
|
|
524
|
+
request.onabort = request.onerror = () => reject(request.error);
|
|
573
525
|
});
|
|
574
|
-
return createProxy(ep, pendingListeners, [], target);
|
|
575
|
-
}
|
|
576
|
-
function throwIfProxyReleased(isReleased) {
|
|
577
|
-
if (isReleased) {
|
|
578
|
-
throw new Error("Proxy has been released and is not useable");
|
|
579
|
-
}
|
|
580
526
|
}
|
|
581
|
-
function
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
527
|
+
function createStore(dbName, storeName) {
|
|
528
|
+
let dbp;
|
|
529
|
+
const getDB = () => {
|
|
530
|
+
if (dbp)
|
|
531
|
+
return dbp;
|
|
532
|
+
const request = indexedDB.open(dbName);
|
|
533
|
+
request.onupgradeneeded = () => request.result.createObjectStore(storeName);
|
|
534
|
+
dbp = promisifyRequest(request);
|
|
535
|
+
dbp.then((db) => {
|
|
536
|
+
// It seems like Safari sometimes likes to just close the connection.
|
|
537
|
+
// It's supposed to fire this event when that happens. Let's hope it does!
|
|
538
|
+
db.onclose = () => (dbp = undefined);
|
|
539
|
+
}, () => { });
|
|
540
|
+
return dbp;
|
|
541
|
+
};
|
|
542
|
+
return (txMode, callback) => getDB().then((db) => callback(db.transaction(storeName, txMode).objectStore(storeName)));
|
|
543
|
+
}
|
|
544
|
+
let defaultGetStoreFunc;
|
|
545
|
+
function defaultGetStore() {
|
|
546
|
+
if (!defaultGetStoreFunc) {
|
|
547
|
+
defaultGetStoreFunc = createStore('keyval-store', 'keyval');
|
|
548
|
+
}
|
|
549
|
+
return defaultGetStoreFunc;
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Get a value by its key.
|
|
553
|
+
*
|
|
554
|
+
* @param key
|
|
555
|
+
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
556
|
+
*/
|
|
557
|
+
function get(key, customStore = defaultGetStore()) {
|
|
558
|
+
return customStore('readonly', (store) => promisifyRequest(store.get(key)));
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Set a value with a key.
|
|
562
|
+
*
|
|
563
|
+
* @param key
|
|
564
|
+
* @param value
|
|
565
|
+
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
566
|
+
*/
|
|
567
|
+
function set(key, value, customStore = defaultGetStore()) {
|
|
568
|
+
return customStore('readwrite', (store) => {
|
|
569
|
+
store.put(value, key);
|
|
570
|
+
return promisifyRequest(store.transaction);
|
|
586
571
|
});
|
|
587
572
|
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
573
|
+
/**
|
|
574
|
+
* Set multiple values at once. This is faster than calling set() multiple times.
|
|
575
|
+
* It's also atomic – if one of the pairs can't be added, none will be added.
|
|
576
|
+
*
|
|
577
|
+
* @param entries Array of entries, where each entry is an array of `[key, value]`.
|
|
578
|
+
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
579
|
+
*/
|
|
580
|
+
function setMany(entries, customStore = defaultGetStore()) {
|
|
581
|
+
return customStore('readwrite', (store) => {
|
|
582
|
+
entries.forEach((entry) => store.put(entry[1], entry[0]));
|
|
583
|
+
return promisifyRequest(store.transaction);
|
|
596
584
|
});
|
|
597
|
-
function registerProxy(proxy, ep) {
|
|
598
|
-
const newCount = (proxyCounter.get(ep) || 0) + 1;
|
|
599
|
-
proxyCounter.set(ep, newCount);
|
|
600
|
-
if (proxyFinalizers) {
|
|
601
|
-
proxyFinalizers.register(proxy, ep, proxy);
|
|
602
|
-
}
|
|
603
585
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
586
|
+
/**
|
|
587
|
+
* Get multiple values by their keys
|
|
588
|
+
*
|
|
589
|
+
* @param keys
|
|
590
|
+
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
591
|
+
*/
|
|
592
|
+
function getMany(keys, customStore = defaultGetStore()) {
|
|
593
|
+
return customStore('readonly', (store) => Promise.all(keys.map((key) => promisifyRequest(store.get(key)))));
|
|
608
594
|
}
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
const r = requestResponseMessage(ep, pendingListeners, {
|
|
627
|
-
type: "GET" /* MessageType.GET */,
|
|
628
|
-
path: path.map((p) => p.toString()),
|
|
629
|
-
}).then(fromWireValue);
|
|
630
|
-
return r.then.bind(r);
|
|
631
|
-
}
|
|
632
|
-
return createProxy(ep, pendingListeners, [...path, prop]);
|
|
633
|
-
},
|
|
634
|
-
set(_target, prop, rawValue) {
|
|
635
|
-
throwIfProxyReleased(isProxyReleased);
|
|
636
|
-
// FIXME: ES6 Proxy Handler `set` methods are supposed to return a
|
|
637
|
-
// boolean. To show good will, we return true asynchronously ¯\_(ツ)_/¯
|
|
638
|
-
const [value, transferables] = toWireValue(rawValue);
|
|
639
|
-
return requestResponseMessage(ep, pendingListeners, {
|
|
640
|
-
type: "SET" /* MessageType.SET */,
|
|
641
|
-
path: [...path, prop].map((p) => p.toString()),
|
|
642
|
-
value,
|
|
643
|
-
}, transferables).then(fromWireValue);
|
|
644
|
-
},
|
|
645
|
-
apply(_target, _thisArg, rawArgumentList) {
|
|
646
|
-
throwIfProxyReleased(isProxyReleased);
|
|
647
|
-
const last = path[path.length - 1];
|
|
648
|
-
if (last === createEndpoint) {
|
|
649
|
-
return requestResponseMessage(ep, pendingListeners, {
|
|
650
|
-
type: "ENDPOINT" /* MessageType.ENDPOINT */,
|
|
651
|
-
}).then(fromWireValue);
|
|
595
|
+
/**
|
|
596
|
+
* Update a value. This lets you see the old value and update it as an atomic operation.
|
|
597
|
+
*
|
|
598
|
+
* @param key
|
|
599
|
+
* @param updater A callback that takes the old value and returns a new value.
|
|
600
|
+
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
601
|
+
*/
|
|
602
|
+
function update(key, updater, customStore = defaultGetStore()) {
|
|
603
|
+
return customStore('readwrite', (store) =>
|
|
604
|
+
// Need to create the promise manually.
|
|
605
|
+
// If I try to chain promises, the transaction closes in browsers
|
|
606
|
+
// that use a promise polyfill (IE10/11).
|
|
607
|
+
new Promise((resolve, reject) => {
|
|
608
|
+
store.get(key).onsuccess = function () {
|
|
609
|
+
try {
|
|
610
|
+
store.put(updater(this.result), key);
|
|
611
|
+
resolve(promisifyRequest(store.transaction));
|
|
652
612
|
}
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
return createProxy(ep, pendingListeners, path.slice(0, -1));
|
|
613
|
+
catch (err) {
|
|
614
|
+
reject(err);
|
|
656
615
|
}
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
type: "APPLY" /* MessageType.APPLY */,
|
|
660
|
-
path: path.map((p) => p.toString()),
|
|
661
|
-
argumentList,
|
|
662
|
-
}, transferables).then(fromWireValue);
|
|
663
|
-
},
|
|
664
|
-
construct(_target, rawArgumentList) {
|
|
665
|
-
throwIfProxyReleased(isProxyReleased);
|
|
666
|
-
const [argumentList, transferables] = processArguments(rawArgumentList);
|
|
667
|
-
return requestResponseMessage(ep, pendingListeners, {
|
|
668
|
-
type: "CONSTRUCT" /* MessageType.CONSTRUCT */,
|
|
669
|
-
path: path.map((p) => p.toString()),
|
|
670
|
-
argumentList,
|
|
671
|
-
}, transferables).then(fromWireValue);
|
|
672
|
-
},
|
|
673
|
-
});
|
|
674
|
-
registerProxy(proxy, ep);
|
|
675
|
-
return proxy;
|
|
676
|
-
}
|
|
677
|
-
function myFlat(arr) {
|
|
678
|
-
return Array.prototype.concat.apply([], arr);
|
|
616
|
+
};
|
|
617
|
+
}));
|
|
679
618
|
}
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
619
|
+
/**
|
|
620
|
+
* Delete a particular key from the store.
|
|
621
|
+
*
|
|
622
|
+
* @param key
|
|
623
|
+
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
624
|
+
*/
|
|
625
|
+
function del(key, customStore = defaultGetStore()) {
|
|
626
|
+
return customStore('readwrite', (store) => {
|
|
627
|
+
store.delete(key);
|
|
628
|
+
return promisifyRequest(store.transaction);
|
|
629
|
+
});
|
|
683
630
|
}
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
631
|
+
/**
|
|
632
|
+
* Delete multiple keys at once.
|
|
633
|
+
*
|
|
634
|
+
* @param keys List of keys to delete.
|
|
635
|
+
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
636
|
+
*/
|
|
637
|
+
function delMany(keys, customStore = defaultGetStore()) {
|
|
638
|
+
return customStore('readwrite', (store) => {
|
|
639
|
+
keys.forEach((key) => store.delete(key));
|
|
640
|
+
return promisifyRequest(store.transaction);
|
|
641
|
+
});
|
|
688
642
|
}
|
|
689
|
-
|
|
690
|
-
|
|
643
|
+
/**
|
|
644
|
+
* Clear all values in the store.
|
|
645
|
+
*
|
|
646
|
+
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
647
|
+
*/
|
|
648
|
+
function clear(customStore = defaultGetStore()) {
|
|
649
|
+
return customStore('readwrite', (store) => {
|
|
650
|
+
store.clear();
|
|
651
|
+
return promisifyRequest(store.transaction);
|
|
652
|
+
});
|
|
691
653
|
}
|
|
692
|
-
function
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
654
|
+
function eachCursor(store, callback) {
|
|
655
|
+
store.openCursor().onsuccess = function () {
|
|
656
|
+
if (!this.result)
|
|
657
|
+
return;
|
|
658
|
+
callback(this.result);
|
|
659
|
+
this.result.continue();
|
|
697
660
|
};
|
|
661
|
+
return promisifyRequest(store.transaction);
|
|
698
662
|
}
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
transferables,
|
|
710
|
-
];
|
|
663
|
+
/**
|
|
664
|
+
* Get all keys in the store.
|
|
665
|
+
*
|
|
666
|
+
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
667
|
+
*/
|
|
668
|
+
function keys(customStore = defaultGetStore()) {
|
|
669
|
+
return customStore('readonly', (store) => {
|
|
670
|
+
// Fast path for modern browsers
|
|
671
|
+
if (store.getAllKeys) {
|
|
672
|
+
return promisifyRequest(store.getAllKeys());
|
|
711
673
|
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
type: "RAW" /* WireValueType.RAW */,
|
|
716
|
-
value,
|
|
717
|
-
},
|
|
718
|
-
transferCache.get(value) || [],
|
|
719
|
-
];
|
|
720
|
-
}
|
|
721
|
-
function fromWireValue(value) {
|
|
722
|
-
switch (value.type) {
|
|
723
|
-
case "HANDLER" /* WireValueType.HANDLER */:
|
|
724
|
-
return transferHandlers.get(value.name).deserialize(value.value);
|
|
725
|
-
case "RAW" /* WireValueType.RAW */:
|
|
726
|
-
return value.value;
|
|
727
|
-
}
|
|
674
|
+
const items = [];
|
|
675
|
+
return eachCursor(store, (cursor) => items.push(cursor.key)).then(() => items);
|
|
676
|
+
});
|
|
728
677
|
}
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
678
|
+
/**
|
|
679
|
+
* Get all values in the store.
|
|
680
|
+
*
|
|
681
|
+
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
682
|
+
*/
|
|
683
|
+
function values(customStore = defaultGetStore()) {
|
|
684
|
+
return customStore('readonly', (store) => {
|
|
685
|
+
// Fast path for modern browsers
|
|
686
|
+
if (store.getAll) {
|
|
687
|
+
return promisifyRequest(store.getAll());
|
|
735
688
|
}
|
|
736
|
-
|
|
689
|
+
const items = [];
|
|
690
|
+
return eachCursor(store, (cursor) => items.push(cursor.value)).then(() => items);
|
|
737
691
|
});
|
|
738
692
|
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
693
|
+
/**
|
|
694
|
+
* Get all entries in the store. Each entry is an array of `[key, value]`.
|
|
695
|
+
*
|
|
696
|
+
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
697
|
+
*/
|
|
698
|
+
function entries(customStore = defaultGetStore()) {
|
|
699
|
+
return customStore('readonly', (store) => {
|
|
700
|
+
// Fast path for modern browsers
|
|
701
|
+
// (although, hopefully we'll get a simpler path some day)
|
|
702
|
+
if (store.getAll && store.getAllKeys) {
|
|
703
|
+
return Promise.all([
|
|
704
|
+
promisifyRequest(store.getAllKeys()),
|
|
705
|
+
promisifyRequest(store.getAll()),
|
|
706
|
+
]).then(([keys, values]) => keys.map((key, i) => [key, values[i]]));
|
|
707
|
+
}
|
|
708
|
+
const items = [];
|
|
709
|
+
return customStore('readonly', (store) => eachCursor(store, (cursor) => items.push([cursor.key, cursor.value])).then(() => items));
|
|
710
|
+
});
|
|
744
711
|
}
|
|
745
712
|
|
|
746
713
|
|
|
747
|
-
//# sourceMappingURL=comlink.mjs.map
|
|
748
714
|
|
|
749
|
-
;// ./src/
|
|
750
|
-
function
|
|
751
|
-
function
|
|
752
|
-
function
|
|
753
|
-
function
|
|
754
|
-
function
|
|
755
|
-
function
|
|
756
|
-
function
|
|
757
|
-
function
|
|
758
|
-
function
|
|
759
|
-
function
|
|
715
|
+
;// ./src/fileAccessSystemUtils.ts
|
|
716
|
+
function fileAccessSystemUtils_typeof(o) { "@babel/helpers - typeof"; return fileAccessSystemUtils_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; }, fileAccessSystemUtils_typeof(o); }
|
|
717
|
+
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == fileAccessSystemUtils_typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(fileAccessSystemUtils_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
718
|
+
function fileAccessSystemUtils_slicedToArray(r, e) { return fileAccessSystemUtils_arrayWithHoles(r) || fileAccessSystemUtils_iterableToArrayLimit(r, e) || fileAccessSystemUtils_unsupportedIterableToArray(r, e) || fileAccessSystemUtils_nonIterableRest(); }
|
|
719
|
+
function fileAccessSystemUtils_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."); }
|
|
720
|
+
function fileAccessSystemUtils_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return fileAccessSystemUtils_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) ? fileAccessSystemUtils_arrayLikeToArray(r, a) : void 0; } }
|
|
721
|
+
function fileAccessSystemUtils_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; }
|
|
722
|
+
function fileAccessSystemUtils_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; } }
|
|
723
|
+
function fileAccessSystemUtils_arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
724
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
725
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
726
|
+
function _asyncIterator(r) { var n, t, o, e = 2; for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) { if (t && null != (n = r[t])) return n.call(r); if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r)); t = "@@asyncIterator", o = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
|
|
727
|
+
function AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var n = r.done; return Promise.resolve(r.value).then(function (r) { return { value: r, done: n }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(r) { this.s = r, this.n = r.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, "return": function _return(r) { var n = this.s["return"]; return void 0 === n ? Promise.resolve({ value: r, done: !0 }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); }, "throw": function _throw(r) { var n = this.s["return"]; return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(r); }
|
|
760
728
|
|
|
761
729
|
|
|
762
|
-
var
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
this.workerRegistry[name] = {
|
|
776
|
-
instance: wrap(worker),
|
|
777
|
-
nativeWorker: worker
|
|
778
|
-
};
|
|
779
|
-
} catch (error) {
|
|
780
|
-
console.warn(error);
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
}, {
|
|
784
|
-
key: "executeTask",
|
|
785
|
-
value: function () {
|
|
786
|
-
var _executeTask = workerManager_asyncToGenerator(/*#__PURE__*/workerManager_regeneratorRuntime().mark(function _callee(workerName, taskName, options) {
|
|
787
|
-
var _this$workerRegistry$;
|
|
788
|
-
var worker;
|
|
789
|
-
return workerManager_regeneratorRuntime().wrap(function _callee$(_context) {
|
|
790
|
-
while (1) switch (_context.prev = _context.next) {
|
|
791
|
-
case 0:
|
|
792
|
-
worker = (_this$workerRegistry$ = this.workerRegistry[workerName]) === null || _this$workerRegistry$ === void 0 ? void 0 : _this$workerRegistry$.instance;
|
|
793
|
-
if (worker) {
|
|
794
|
-
_context.next = 3;
|
|
795
|
-
break;
|
|
796
|
-
}
|
|
797
|
-
throw new CustomError("Worker ".concat(workerName, " not registered"));
|
|
798
|
-
case 3:
|
|
799
|
-
_context.prev = 3;
|
|
800
|
-
_context.next = 6;
|
|
801
|
-
return worker[taskName](options);
|
|
802
|
-
case 6:
|
|
803
|
-
return _context.abrupt("return", _context.sent);
|
|
804
|
-
case 9:
|
|
805
|
-
_context.prev = 9;
|
|
806
|
-
_context.t0 = _context["catch"](3);
|
|
807
|
-
console.error("Error executing task \"".concat(taskName, "\" on worker \"").concat(workerName, "\":"), _context.t0);
|
|
808
|
-
throw new CustomError("Task \"".concat(taskName, "\" failed: ").concat(_context.t0.message));
|
|
809
|
-
case 13:
|
|
810
|
-
case "end":
|
|
811
|
-
return _context.stop();
|
|
730
|
+
var directoryHandle;
|
|
731
|
+
function getDirectoryHandle() {
|
|
732
|
+
return _getDirectoryHandle.apply(this, arguments);
|
|
733
|
+
}
|
|
734
|
+
function _getDirectoryHandle() {
|
|
735
|
+
_getDirectoryHandle = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
736
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
737
|
+
while (1) switch (_context.prev = _context.next) {
|
|
738
|
+
case 0:
|
|
739
|
+
_context.prev = 0;
|
|
740
|
+
if (directoryHandle) {
|
|
741
|
+
_context.next = 5;
|
|
742
|
+
break;
|
|
812
743
|
}
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
744
|
+
_context.next = 4;
|
|
745
|
+
return get(IDB_DIR_HANDLE_KEY);
|
|
746
|
+
case 4:
|
|
747
|
+
directoryHandle = _context.sent;
|
|
748
|
+
case 5:
|
|
749
|
+
if (directoryHandle) {
|
|
750
|
+
_context.next = 9;
|
|
751
|
+
break;
|
|
752
|
+
}
|
|
753
|
+
_context.next = 8;
|
|
754
|
+
return navigator.storage.getDirectory();
|
|
755
|
+
case 8:
|
|
756
|
+
directoryHandle = _context.sent;
|
|
757
|
+
case 9:
|
|
758
|
+
return _context.abrupt("return", directoryHandle);
|
|
759
|
+
case 12:
|
|
760
|
+
_context.prev = 12;
|
|
761
|
+
_context.t0 = _context["catch"](0);
|
|
762
|
+
console.warn("Error getting directoryhandle: ".concat(_context.t0.message));
|
|
763
|
+
case 15:
|
|
764
|
+
case "end":
|
|
765
|
+
return _context.stop();
|
|
817
766
|
}
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
767
|
+
}, _callee, null, [[0, 12]]);
|
|
768
|
+
}));
|
|
769
|
+
return _getDirectoryHandle.apply(this, arguments);
|
|
770
|
+
}
|
|
771
|
+
function readJsonFile(_x, _x2) {
|
|
772
|
+
return _readJsonFile.apply(this, arguments);
|
|
773
|
+
}
|
|
774
|
+
function _readJsonFile() {
|
|
775
|
+
_readJsonFile = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(directoryHandle, name) {
|
|
776
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
777
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
778
|
+
case 0:
|
|
779
|
+
_context2.next = 2;
|
|
780
|
+
return directoryHandle.getFileHandle(name).then(function (fileHandle) {
|
|
781
|
+
return fileHandle.getFile().then(function (file) {
|
|
782
|
+
return file.text();
|
|
783
|
+
}).then(function (metadataString) {
|
|
784
|
+
return JSON.parse(metadataString);
|
|
785
|
+
});
|
|
786
|
+
})["catch"](function () {
|
|
787
|
+
return null;
|
|
788
|
+
});
|
|
789
|
+
case 2:
|
|
790
|
+
return _context2.abrupt("return", _context2.sent);
|
|
791
|
+
case 3:
|
|
792
|
+
case "end":
|
|
793
|
+
return _context2.stop();
|
|
827
794
|
}
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
795
|
+
}, _callee2);
|
|
796
|
+
}));
|
|
797
|
+
return _readJsonFile.apply(this, arguments);
|
|
798
|
+
}
|
|
799
|
+
function readArrayBufferFile(_x3, _x4) {
|
|
800
|
+
return _readArrayBufferFile.apply(this, arguments);
|
|
801
|
+
}
|
|
802
|
+
function _readArrayBufferFile() {
|
|
803
|
+
_readArrayBufferFile = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(directoryHandle, name) {
|
|
804
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
805
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
806
|
+
case 0:
|
|
807
|
+
_context3.next = 2;
|
|
808
|
+
return directoryHandle.getFileHandle(name).then(function (fileHandle) {
|
|
809
|
+
return fileHandle.getFile().then(function (file) {
|
|
810
|
+
return file.arrayBuffer();
|
|
811
|
+
});
|
|
812
|
+
})["catch"](function () {
|
|
813
|
+
return null;
|
|
814
|
+
});
|
|
815
|
+
case 2:
|
|
816
|
+
return _context3.abrupt("return", _context3.sent);
|
|
817
|
+
case 3:
|
|
818
|
+
case "end":
|
|
819
|
+
return _context3.stop();
|
|
837
820
|
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
key: "reset",
|
|
842
|
-
value: function reset() {
|
|
843
|
-
this.workerRegistry = {};
|
|
844
|
-
}
|
|
845
|
-
}]);
|
|
846
|
-
}();
|
|
847
|
-
/* harmony default export */ const workerManager = (WebWorkerManager);
|
|
848
|
-
;// ./src/dataRetrieval/dataRetrievalManager.ts
|
|
849
|
-
function dataRetrievalManager_typeof(o) { "@babel/helpers - typeof"; return dataRetrievalManager_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; }, dataRetrievalManager_typeof(o); }
|
|
850
|
-
function dataRetrievalManager_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ dataRetrievalManager_regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == dataRetrievalManager_typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(dataRetrievalManager_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
851
|
-
function dataRetrievalManager_asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
852
|
-
function dataRetrievalManager_asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { dataRetrievalManager_asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { dataRetrievalManager_asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
853
|
-
function dataRetrievalManager_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
854
|
-
function dataRetrievalManager_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, dataRetrievalManager_toPropertyKey(o.key), o); } }
|
|
855
|
-
function dataRetrievalManager_createClass(e, r, t) { return r && dataRetrievalManager_defineProperties(e.prototype, r), t && dataRetrievalManager_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
856
|
-
function dataRetrievalManager_defineProperty(e, r, t) { return (r = dataRetrievalManager_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
857
|
-
function dataRetrievalManager_toPropertyKey(t) { var i = dataRetrievalManager_toPrimitive(t, "string"); return "symbol" == dataRetrievalManager_typeof(i) ? i : i + ""; }
|
|
858
|
-
function dataRetrievalManager_toPrimitive(t, r) { if ("object" != dataRetrievalManager_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != dataRetrievalManager_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
var DataRetrievalManager = /*#__PURE__*/function () {
|
|
865
|
-
function DataRetrievalManager() {
|
|
866
|
-
dataRetrievalManager_classCallCheck(this, DataRetrievalManager);
|
|
867
|
-
dataRetrievalManager_defineProperty(this, "dataRetriever", void 0);
|
|
868
|
-
dataRetrievalManager_defineProperty(this, "dataRetrieverMode", void 0);
|
|
869
|
-
if (isNodeEnvironment()) {
|
|
870
|
-
this.dataRetriever = new requestManager();
|
|
871
|
-
this.dataRetrieverMode = DataRetrieveMode.REQUEST;
|
|
872
|
-
} else {
|
|
873
|
-
this.dataRetriever = new workerManager();
|
|
874
|
-
this.dataRetrieverMode = DataRetrieveMode.WORKER;
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
return dataRetrievalManager_createClass(DataRetrievalManager, [{
|
|
878
|
-
key: "getDataRetrieverMode",
|
|
879
|
-
value: function getDataRetrieverMode() {
|
|
880
|
-
return this.dataRetrieverMode;
|
|
881
|
-
}
|
|
882
|
-
}, {
|
|
883
|
-
key: "setDataRetrieverMode",
|
|
884
|
-
value: function setDataRetrieverMode(mode) {
|
|
885
|
-
var managers = dataRetrievalManager_defineProperty(dataRetrievalManager_defineProperty({}, DataRetrieveMode.WORKER, workerManager), DataRetrieveMode.REQUEST, requestManager);
|
|
886
|
-
if (!(mode in managers)) {
|
|
887
|
-
throw new CustomError('Invalid mode');
|
|
888
|
-
}
|
|
889
|
-
this.dataRetriever.reset();
|
|
890
|
-
this.dataRetriever = new managers[mode]();
|
|
891
|
-
this.dataRetrieverMode = mode;
|
|
892
|
-
}
|
|
893
|
-
}, {
|
|
894
|
-
key: "register",
|
|
895
|
-
value: function register(name, arg) {
|
|
896
|
-
// @ts-ignore
|
|
897
|
-
this.dataRetriever.register(name, arg);
|
|
898
|
-
}
|
|
899
|
-
}, {
|
|
900
|
-
key: "executeTask",
|
|
901
|
-
value: function () {
|
|
902
|
-
var _executeTask = dataRetrievalManager_asyncToGenerator(/*#__PURE__*/dataRetrievalManager_regeneratorRuntime().mark(function _callee(loaderName, taskName, options) {
|
|
903
|
-
return dataRetrievalManager_regeneratorRuntime().wrap(function _callee$(_context) {
|
|
904
|
-
while (1) switch (_context.prev = _context.next) {
|
|
905
|
-
case 0:
|
|
906
|
-
_context.next = 2;
|
|
907
|
-
return this.dataRetriever.executeTask(loaderName, taskName, options);
|
|
908
|
-
case 2:
|
|
909
|
-
return _context.abrupt("return", _context.sent);
|
|
910
|
-
case 3:
|
|
911
|
-
case "end":
|
|
912
|
-
return _context.stop();
|
|
913
|
-
}
|
|
914
|
-
}, _callee, this);
|
|
915
|
-
}));
|
|
916
|
-
function executeTask(_x, _x2, _x3) {
|
|
917
|
-
return _executeTask.apply(this, arguments);
|
|
918
|
-
}
|
|
919
|
-
return executeTask;
|
|
920
|
-
}()
|
|
921
|
-
}, {
|
|
922
|
-
key: "addEventListener",
|
|
923
|
-
value: function addEventListener(workerName, eventType, listener) {
|
|
924
|
-
this.dataRetriever.addEventListener(workerName, eventType, listener);
|
|
925
|
-
}
|
|
926
|
-
}, {
|
|
927
|
-
key: "removeEventListener",
|
|
928
|
-
value: function removeEventListener(workerName, eventType, listener) {
|
|
929
|
-
this.dataRetriever.removeEventListener(workerName, eventType, listener);
|
|
930
|
-
}
|
|
931
|
-
}, {
|
|
932
|
-
key: "reset",
|
|
933
|
-
value: function reset() {
|
|
934
|
-
this.dataRetriever.reset();
|
|
935
|
-
}
|
|
936
|
-
}]);
|
|
937
|
-
}();
|
|
938
|
-
var dataRetrievalManager = new DataRetrievalManager();
|
|
939
|
-
function getDataRetrievalManager() {
|
|
940
|
-
return dataRetrievalManager;
|
|
941
|
-
}
|
|
942
|
-
;// ./src/fileManager.ts
|
|
943
|
-
function fileManager_typeof(o) { "@babel/helpers - typeof"; return fileManager_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; }, fileManager_typeof(o); }
|
|
944
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
945
|
-
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."); }
|
|
946
|
-
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; } }
|
|
947
|
-
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; }
|
|
948
|
-
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; } }
|
|
949
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
950
|
-
function fileManager_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
951
|
-
function fileManager_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, fileManager_toPropertyKey(o.key), o); } }
|
|
952
|
-
function fileManager_createClass(e, r, t) { return r && fileManager_defineProperties(e.prototype, r), t && fileManager_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
953
|
-
function fileManager_defineProperty(e, r, t) { return (r = fileManager_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
954
|
-
function fileManager_toPropertyKey(t) { var i = fileManager_toPrimitive(t, "string"); return "symbol" == fileManager_typeof(i) ? i : i + ""; }
|
|
955
|
-
function fileManager_toPrimitive(t, r) { if ("object" != fileManager_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != fileManager_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
956
|
-
|
|
957
|
-
var FileManager = /*#__PURE__*/function () {
|
|
958
|
-
function FileManager(_ref) {
|
|
959
|
-
var fileStreamingScriptName = _ref.fileStreamingScriptName;
|
|
960
|
-
fileManager_classCallCheck(this, FileManager);
|
|
961
|
-
fileManager_defineProperty(this, "files", {});
|
|
962
|
-
fileManager_defineProperty(this, "fileStreamingScriptName", void 0);
|
|
963
|
-
this.fileStreamingScriptName = fileStreamingScriptName;
|
|
964
|
-
}
|
|
965
|
-
return fileManager_createClass(FileManager, [{
|
|
966
|
-
key: "set",
|
|
967
|
-
value: function set(url, file) {
|
|
968
|
-
this.files[url] = file;
|
|
969
|
-
}
|
|
970
|
-
}, {
|
|
971
|
-
key: "get",
|
|
972
|
-
value: function get(url, offsets) {
|
|
973
|
-
if (!this.files[url] || offsets && this.files[url].position <= offsets.endByte) {
|
|
974
|
-
return null;
|
|
975
|
-
}
|
|
976
|
-
return offsets ? this.files[url].data.slice(offsets.startByte, offsets.endByte) : this.files[url].data;
|
|
977
|
-
}
|
|
978
|
-
}, {
|
|
979
|
-
key: "setPosition",
|
|
980
|
-
value: function setPosition(url, position) {
|
|
981
|
-
if (this.files[url]) {
|
|
982
|
-
this.files[url].position = position;
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
}, {
|
|
986
|
-
key: "getPosition",
|
|
987
|
-
value: function getPosition(url) {
|
|
988
|
-
var _this$files$url;
|
|
989
|
-
return (_this$files$url = this.files[url]) === null || _this$files$url === void 0 ? void 0 : _this$files$url.position;
|
|
990
|
-
}
|
|
991
|
-
}, {
|
|
992
|
-
key: "append",
|
|
993
|
-
value: function append(url, chunk, position) {
|
|
994
|
-
if (this.files[url] && position) {
|
|
995
|
-
this.files[url].data.set(chunk, position - chunk.length);
|
|
996
|
-
this.setPosition(url, position);
|
|
997
|
-
}
|
|
998
|
-
}
|
|
999
|
-
}, {
|
|
1000
|
-
key: "getTotalSize",
|
|
1001
|
-
value: function getTotalSize() {
|
|
1002
|
-
return Object.entries(this.files).reduce(function (total, _ref2) {
|
|
1003
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
1004
|
-
url = _ref3[0],
|
|
1005
|
-
position = _ref3[1].position;
|
|
1006
|
-
return url.includes('?bytes=') ? total : total + position;
|
|
1007
|
-
}, 0);
|
|
1008
|
-
}
|
|
1009
|
-
}, {
|
|
1010
|
-
key: "remove",
|
|
1011
|
-
value: function remove(url) {
|
|
1012
|
-
var removedSize = this.getPosition(url);
|
|
1013
|
-
delete this.files[url];
|
|
1014
|
-
if (url.includes('?bytes=')) {
|
|
1015
|
-
return;
|
|
1016
|
-
}
|
|
1017
|
-
var retrievalManager = getDataRetrievalManager();
|
|
1018
|
-
retrievalManager.executeTask(this.fileStreamingScriptName, 'decreaseFetchedSize', removedSize);
|
|
1019
|
-
}
|
|
1020
|
-
}, {
|
|
1021
|
-
key: "purge",
|
|
1022
|
-
value: function purge() {
|
|
1023
|
-
var totalSize = this.getTotalSize();
|
|
1024
|
-
this.files = {};
|
|
1025
|
-
var retrievalManager = getDataRetrievalManager();
|
|
1026
|
-
retrievalManager.executeTask(this.fileStreamingScriptName, 'decreaseFetchedSize', totalSize);
|
|
1027
|
-
}
|
|
1028
|
-
}]);
|
|
1029
|
-
}();
|
|
1030
|
-
/* harmony default export */ const fileManager = (FileManager);
|
|
1031
|
-
;// ./src/classes/utils.ts
|
|
1032
|
-
function utils_slicedToArray(r, e) { return utils_arrayWithHoles(r) || utils_iterableToArrayLimit(r, e) || utils_unsupportedIterableToArray(r, e) || utils_nonIterableRest(); }
|
|
1033
|
-
function utils_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."); }
|
|
1034
|
-
function utils_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return utils_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) ? utils_arrayLikeToArray(r, a) : void 0; } }
|
|
1035
|
-
function utils_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; }
|
|
1036
|
-
function utils_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; } }
|
|
1037
|
-
function utils_arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
function parseWadorsURL(url, domain) {
|
|
1041
|
-
if (!url.includes(src_constants.url.URL_VALIDATION_STRING)) {
|
|
1042
|
-
return;
|
|
1043
|
-
}
|
|
1044
|
-
var filePath = url.split(domain + '/')[1];
|
|
1045
|
-
var prefix = filePath.split('/studies')[0];
|
|
1046
|
-
var prefixParts = prefix.split('/');
|
|
1047
|
-
var bucketName = prefixParts[0];
|
|
1048
|
-
var bucketPrefix = prefixParts.slice(1).join('/');
|
|
1049
|
-
var imagePath = filePath.split(prefix + '/')[1];
|
|
1050
|
-
var imageParts = imagePath.split('/');
|
|
1051
|
-
var studyInstanceUID = imageParts[1];
|
|
1052
|
-
var seriesInstanceUID = imageParts[3];
|
|
1053
|
-
var sopInstanceUID = '',
|
|
1054
|
-
frameNumber = 1,
|
|
1055
|
-
type;
|
|
1056
|
-
switch (true) {
|
|
1057
|
-
case imageParts.includes('thumbnail'):
|
|
1058
|
-
type = RequestType.THUMBNAIL;
|
|
1059
|
-
break;
|
|
1060
|
-
case imageParts.includes('metadata'):
|
|
1061
|
-
if (imageParts.includes('instances')) {
|
|
1062
|
-
sopInstanceUID = imageParts[5];
|
|
1063
|
-
type = RequestType.INSTANCE_METADATA;
|
|
1064
|
-
} else {
|
|
1065
|
-
type = RequestType.SERIES_METADATA;
|
|
1066
|
-
}
|
|
1067
|
-
break;
|
|
1068
|
-
case imageParts.includes('frames'):
|
|
1069
|
-
sopInstanceUID = imageParts[5];
|
|
1070
|
-
frameNumber = +imageParts[7];
|
|
1071
|
-
type = RequestType.FRAME;
|
|
1072
|
-
break;
|
|
1073
|
-
default:
|
|
1074
|
-
throw new CustomError('Invalid type of request');
|
|
1075
|
-
}
|
|
1076
|
-
return {
|
|
1077
|
-
type: type,
|
|
1078
|
-
bucketName: bucketName,
|
|
1079
|
-
bucketPrefix: bucketPrefix,
|
|
1080
|
-
studyInstanceUID: studyInstanceUID,
|
|
1081
|
-
seriesInstanceUID: seriesInstanceUID,
|
|
1082
|
-
sopInstanceUID: sopInstanceUID,
|
|
1083
|
-
frameNumber: frameNumber
|
|
1084
|
-
};
|
|
1085
|
-
}
|
|
1086
|
-
function getFrameDetailsFromMetadata(seriesMetadata, sopInstanceUID, frameIndex, bucketDetails) {
|
|
1087
|
-
var _seriesMetadata$cod, _Object$entries$find;
|
|
1088
|
-
if (!seriesMetadata || !((_seriesMetadata$cod = seriesMetadata.cod) !== null && _seriesMetadata$cod !== void 0 && _seriesMetadata$cod.instances)) {
|
|
1089
|
-
throw new CustomError('Invalid seriesMetadata provided.');
|
|
1090
|
-
}
|
|
1091
|
-
if (frameIndex === null || frameIndex === undefined) {
|
|
1092
|
-
throw new CustomError('Frame index is required.');
|
|
1093
|
-
}
|
|
1094
|
-
var domain = bucketDetails.domain,
|
|
1095
|
-
bucketName = bucketDetails.bucketName,
|
|
1096
|
-
bucketPrefix = bucketDetails.bucketPrefix;
|
|
1097
|
-
var thumbnailUrl;
|
|
1098
|
-
if (seriesMetadata.thumbnail) {
|
|
1099
|
-
var thumbnailGsUtilUri = seriesMetadata.thumbnail.uri;
|
|
1100
|
-
thumbnailUrl = "".concat(domain, "/").concat(thumbnailGsUtilUri.split('gs://')[1]);
|
|
1101
|
-
}
|
|
1102
|
-
var instanceFound = (_Object$entries$find = Object.entries(seriesMetadata.cod.instances).find(function (_ref) {
|
|
1103
|
-
var _ref2 = utils_slicedToArray(_ref, 2),
|
|
1104
|
-
key = _ref2[0],
|
|
1105
|
-
instance = _ref2[1];
|
|
1106
|
-
return key === sopInstanceUID;
|
|
1107
|
-
})) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[1];
|
|
1108
|
-
if (!instanceFound) {
|
|
1109
|
-
return {
|
|
1110
|
-
thumbnailUrl: thumbnailUrl
|
|
1111
|
-
};
|
|
1112
|
-
}
|
|
1113
|
-
var url = instanceFound.url,
|
|
1114
|
-
uri = instanceFound.uri,
|
|
1115
|
-
offsetHeaders = instanceFound.headers,
|
|
1116
|
-
offset_tables = instanceFound.offset_tables;
|
|
1117
|
-
var modifiedUrl = handleUrl(url || uri, domain, bucketName, bucketPrefix);
|
|
1118
|
-
var CustomOffsetTable = offset_tables.CustomOffsetTable,
|
|
1119
|
-
CustomOffsetTableLengths = offset_tables.CustomOffsetTableLengths;
|
|
1120
|
-
var sliceStart,
|
|
1121
|
-
sliceEnd,
|
|
1122
|
-
isMultiframe = false;
|
|
1123
|
-
if (CustomOffsetTable !== null && CustomOffsetTable !== void 0 && CustomOffsetTable.length && CustomOffsetTableLengths !== null && CustomOffsetTableLengths !== void 0 && CustomOffsetTableLengths.length) {
|
|
1124
|
-
sliceStart = CustomOffsetTable[frameIndex];
|
|
1125
|
-
sliceEnd = sliceStart + CustomOffsetTableLengths[frameIndex];
|
|
1126
|
-
isMultiframe = true;
|
|
1127
|
-
}
|
|
1128
|
-
var fileStartByte = offsetHeaders.start_byte,
|
|
1129
|
-
fileEndByte = offsetHeaders.end_byte;
|
|
1130
|
-
var startByte = sliceStart !== undefined ? fileStartByte + sliceStart : fileStartByte;
|
|
1131
|
-
var endByte = sliceEnd !== undefined ? fileStartByte + sliceEnd : fileEndByte;
|
|
1132
|
-
return {
|
|
1133
|
-
url: modifiedUrl,
|
|
1134
|
-
startByte: startByte,
|
|
1135
|
-
endByte: endByte,
|
|
1136
|
-
thumbnailUrl: thumbnailUrl,
|
|
1137
|
-
isMultiframe: isMultiframe
|
|
1138
|
-
};
|
|
1139
|
-
}
|
|
1140
|
-
function handleUrl(url, domain, bucketName, bucketPrefix) {
|
|
1141
|
-
var modifiedUrl = url;
|
|
1142
|
-
var matchingExtension = src_constants.url.FILE_EXTENSIONS.find(function (extension) {
|
|
1143
|
-
return url.includes(extension);
|
|
1144
|
-
});
|
|
1145
|
-
if (matchingExtension) {
|
|
1146
|
-
var fileParts = url.split(matchingExtension);
|
|
1147
|
-
modifiedUrl = fileParts[0] + matchingExtension;
|
|
1148
|
-
}
|
|
1149
|
-
var filePath = modifiedUrl.split('studies/')[1];
|
|
1150
|
-
modifiedUrl = "".concat(domain, "/").concat(bucketName, "/").concat(bucketPrefix ? bucketPrefix + '/' : '', "studies/").concat(filePath);
|
|
1151
|
-
return modifiedUrl;
|
|
1152
|
-
}
|
|
1153
|
-
function createMetadataJsonUrl(params) {
|
|
1154
|
-
var _params$domain = params.domain,
|
|
1155
|
-
domain = _params$domain === void 0 ? src_constants.url.DOMAIN : _params$domain,
|
|
1156
|
-
bucketName = params.bucketName,
|
|
1157
|
-
bucketPrefix = params.bucketPrefix,
|
|
1158
|
-
studyInstanceUID = params.studyInstanceUID,
|
|
1159
|
-
seriesInstanceUID = params.seriesInstanceUID;
|
|
1160
|
-
if (!bucketName || !bucketPrefix || !studyInstanceUID || !seriesInstanceUID) {
|
|
1161
|
-
return;
|
|
1162
|
-
}
|
|
1163
|
-
return "".concat(domain, "/").concat(bucketName, "/").concat(bucketPrefix, "/studies/").concat(studyInstanceUID, "/series/").concat(seriesInstanceUID, "/metadata.json");
|
|
1164
|
-
}
|
|
1165
|
-
;// ./node_modules/idb-keyval/dist/index.js
|
|
1166
|
-
function promisifyRequest(request) {
|
|
1167
|
-
return new Promise((resolve, reject) => {
|
|
1168
|
-
// @ts-ignore - file size hacks
|
|
1169
|
-
request.oncomplete = request.onsuccess = () => resolve(request.result);
|
|
1170
|
-
// @ts-ignore - file size hacks
|
|
1171
|
-
request.onabort = request.onerror = () => reject(request.error);
|
|
1172
|
-
});
|
|
1173
|
-
}
|
|
1174
|
-
function createStore(dbName, storeName) {
|
|
1175
|
-
let dbp;
|
|
1176
|
-
const getDB = () => {
|
|
1177
|
-
if (dbp)
|
|
1178
|
-
return dbp;
|
|
1179
|
-
const request = indexedDB.open(dbName);
|
|
1180
|
-
request.onupgradeneeded = () => request.result.createObjectStore(storeName);
|
|
1181
|
-
dbp = promisifyRequest(request);
|
|
1182
|
-
dbp.then((db) => {
|
|
1183
|
-
// It seems like Safari sometimes likes to just close the connection.
|
|
1184
|
-
// It's supposed to fire this event when that happens. Let's hope it does!
|
|
1185
|
-
db.onclose = () => (dbp = undefined);
|
|
1186
|
-
}, () => { });
|
|
1187
|
-
return dbp;
|
|
1188
|
-
};
|
|
1189
|
-
return (txMode, callback) => getDB().then((db) => callback(db.transaction(storeName, txMode).objectStore(storeName)));
|
|
1190
|
-
}
|
|
1191
|
-
let defaultGetStoreFunc;
|
|
1192
|
-
function defaultGetStore() {
|
|
1193
|
-
if (!defaultGetStoreFunc) {
|
|
1194
|
-
defaultGetStoreFunc = createStore('keyval-store', 'keyval');
|
|
1195
|
-
}
|
|
1196
|
-
return defaultGetStoreFunc;
|
|
1197
|
-
}
|
|
1198
|
-
/**
|
|
1199
|
-
* Get a value by its key.
|
|
1200
|
-
*
|
|
1201
|
-
* @param key
|
|
1202
|
-
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
1203
|
-
*/
|
|
1204
|
-
function get(key, customStore = defaultGetStore()) {
|
|
1205
|
-
return customStore('readonly', (store) => promisifyRequest(store.get(key)));
|
|
1206
|
-
}
|
|
1207
|
-
/**
|
|
1208
|
-
* Set a value with a key.
|
|
1209
|
-
*
|
|
1210
|
-
* @param key
|
|
1211
|
-
* @param value
|
|
1212
|
-
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
1213
|
-
*/
|
|
1214
|
-
function set(key, value, customStore = defaultGetStore()) {
|
|
1215
|
-
return customStore('readwrite', (store) => {
|
|
1216
|
-
store.put(value, key);
|
|
1217
|
-
return promisifyRequest(store.transaction);
|
|
1218
|
-
});
|
|
1219
|
-
}
|
|
1220
|
-
/**
|
|
1221
|
-
* Set multiple values at once. This is faster than calling set() multiple times.
|
|
1222
|
-
* It's also atomic – if one of the pairs can't be added, none will be added.
|
|
1223
|
-
*
|
|
1224
|
-
* @param entries Array of entries, where each entry is an array of `[key, value]`.
|
|
1225
|
-
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
1226
|
-
*/
|
|
1227
|
-
function setMany(entries, customStore = defaultGetStore()) {
|
|
1228
|
-
return customStore('readwrite', (store) => {
|
|
1229
|
-
entries.forEach((entry) => store.put(entry[1], entry[0]));
|
|
1230
|
-
return promisifyRequest(store.transaction);
|
|
1231
|
-
});
|
|
1232
|
-
}
|
|
1233
|
-
/**
|
|
1234
|
-
* Get multiple values by their keys
|
|
1235
|
-
*
|
|
1236
|
-
* @param keys
|
|
1237
|
-
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
1238
|
-
*/
|
|
1239
|
-
function getMany(keys, customStore = defaultGetStore()) {
|
|
1240
|
-
return customStore('readonly', (store) => Promise.all(keys.map((key) => promisifyRequest(store.get(key)))));
|
|
1241
|
-
}
|
|
1242
|
-
/**
|
|
1243
|
-
* Update a value. This lets you see the old value and update it as an atomic operation.
|
|
1244
|
-
*
|
|
1245
|
-
* @param key
|
|
1246
|
-
* @param updater A callback that takes the old value and returns a new value.
|
|
1247
|
-
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
1248
|
-
*/
|
|
1249
|
-
function update(key, updater, customStore = defaultGetStore()) {
|
|
1250
|
-
return customStore('readwrite', (store) =>
|
|
1251
|
-
// Need to create the promise manually.
|
|
1252
|
-
// If I try to chain promises, the transaction closes in browsers
|
|
1253
|
-
// that use a promise polyfill (IE10/11).
|
|
1254
|
-
new Promise((resolve, reject) => {
|
|
1255
|
-
store.get(key).onsuccess = function () {
|
|
1256
|
-
try {
|
|
1257
|
-
store.put(updater(this.result), key);
|
|
1258
|
-
resolve(promisifyRequest(store.transaction));
|
|
1259
|
-
}
|
|
1260
|
-
catch (err) {
|
|
1261
|
-
reject(err);
|
|
1262
|
-
}
|
|
1263
|
-
};
|
|
1264
|
-
}));
|
|
1265
|
-
}
|
|
1266
|
-
/**
|
|
1267
|
-
* Delete a particular key from the store.
|
|
1268
|
-
*
|
|
1269
|
-
* @param key
|
|
1270
|
-
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
1271
|
-
*/
|
|
1272
|
-
function del(key, customStore = defaultGetStore()) {
|
|
1273
|
-
return customStore('readwrite', (store) => {
|
|
1274
|
-
store.delete(key);
|
|
1275
|
-
return promisifyRequest(store.transaction);
|
|
1276
|
-
});
|
|
1277
|
-
}
|
|
1278
|
-
/**
|
|
1279
|
-
* Delete multiple keys at once.
|
|
1280
|
-
*
|
|
1281
|
-
* @param keys List of keys to delete.
|
|
1282
|
-
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
1283
|
-
*/
|
|
1284
|
-
function delMany(keys, customStore = defaultGetStore()) {
|
|
1285
|
-
return customStore('readwrite', (store) => {
|
|
1286
|
-
keys.forEach((key) => store.delete(key));
|
|
1287
|
-
return promisifyRequest(store.transaction);
|
|
1288
|
-
});
|
|
1289
|
-
}
|
|
1290
|
-
/**
|
|
1291
|
-
* Clear all values in the store.
|
|
1292
|
-
*
|
|
1293
|
-
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
1294
|
-
*/
|
|
1295
|
-
function clear(customStore = defaultGetStore()) {
|
|
1296
|
-
return customStore('readwrite', (store) => {
|
|
1297
|
-
store.clear();
|
|
1298
|
-
return promisifyRequest(store.transaction);
|
|
1299
|
-
});
|
|
1300
|
-
}
|
|
1301
|
-
function eachCursor(store, callback) {
|
|
1302
|
-
store.openCursor().onsuccess = function () {
|
|
1303
|
-
if (!this.result)
|
|
1304
|
-
return;
|
|
1305
|
-
callback(this.result);
|
|
1306
|
-
this.result.continue();
|
|
1307
|
-
};
|
|
1308
|
-
return promisifyRequest(store.transaction);
|
|
1309
|
-
}
|
|
1310
|
-
/**
|
|
1311
|
-
* Get all keys in the store.
|
|
1312
|
-
*
|
|
1313
|
-
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
1314
|
-
*/
|
|
1315
|
-
function keys(customStore = defaultGetStore()) {
|
|
1316
|
-
return customStore('readonly', (store) => {
|
|
1317
|
-
// Fast path for modern browsers
|
|
1318
|
-
if (store.getAllKeys) {
|
|
1319
|
-
return promisifyRequest(store.getAllKeys());
|
|
1320
|
-
}
|
|
1321
|
-
const items = [];
|
|
1322
|
-
return eachCursor(store, (cursor) => items.push(cursor.key)).then(() => items);
|
|
1323
|
-
});
|
|
821
|
+
}, _callee3);
|
|
822
|
+
}));
|
|
823
|
+
return _readArrayBufferFile.apply(this, arguments);
|
|
1324
824
|
}
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
*
|
|
1328
|
-
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
1329
|
-
*/
|
|
1330
|
-
function values(customStore = defaultGetStore()) {
|
|
1331
|
-
return customStore('readonly', (store) => {
|
|
1332
|
-
// Fast path for modern browsers
|
|
1333
|
-
if (store.getAll) {
|
|
1334
|
-
return promisifyRequest(store.getAll());
|
|
1335
|
-
}
|
|
1336
|
-
const items = [];
|
|
1337
|
-
return eachCursor(store, (cursor) => items.push(cursor.value)).then(() => items);
|
|
1338
|
-
});
|
|
825
|
+
function readFile(_x5, _x6) {
|
|
826
|
+
return _readFile.apply(this, arguments);
|
|
1339
827
|
}
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
828
|
+
function _readFile() {
|
|
829
|
+
_readFile = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(directoryHandle, name) {
|
|
830
|
+
var options,
|
|
831
|
+
pathParts,
|
|
832
|
+
currentDir,
|
|
833
|
+
i,
|
|
834
|
+
fileName,
|
|
835
|
+
_args5 = arguments;
|
|
836
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
837
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
838
|
+
case 0:
|
|
839
|
+
options = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : {};
|
|
840
|
+
if (name) {
|
|
841
|
+
_context5.next = 3;
|
|
842
|
+
break;
|
|
843
|
+
}
|
|
844
|
+
return _context5.abrupt("return");
|
|
845
|
+
case 3:
|
|
846
|
+
pathParts = name.split('/');
|
|
847
|
+
currentDir = directoryHandle;
|
|
848
|
+
_context5.prev = 5;
|
|
849
|
+
i = 0;
|
|
850
|
+
case 7:
|
|
851
|
+
if (!(i < pathParts.length - 1)) {
|
|
852
|
+
_context5.next = 14;
|
|
853
|
+
break;
|
|
854
|
+
}
|
|
855
|
+
_context5.next = 10;
|
|
856
|
+
return currentDir.getDirectoryHandle(pathParts[i], {
|
|
857
|
+
create: true
|
|
858
|
+
});
|
|
859
|
+
case 10:
|
|
860
|
+
currentDir = _context5.sent;
|
|
861
|
+
case 11:
|
|
862
|
+
i++;
|
|
863
|
+
_context5.next = 7;
|
|
864
|
+
break;
|
|
865
|
+
case 14:
|
|
866
|
+
fileName = pathParts.at(-1);
|
|
867
|
+
if (!options.isJson) {
|
|
868
|
+
_context5.next = 19;
|
|
869
|
+
break;
|
|
870
|
+
}
|
|
871
|
+
return _context5.abrupt("return", readJsonFile(currentDir, fileName));
|
|
872
|
+
case 19:
|
|
873
|
+
return _context5.abrupt("return", readArrayBufferFile(currentDir, fileName)["catch"](/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
874
|
+
var _i, convertedFileName, fileArraybuffer;
|
|
875
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
876
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
877
|
+
case 0:
|
|
878
|
+
console.warn("Error reading the file ".concat(name, " from partial folder, trying from full file"));
|
|
879
|
+
if (!(options.offsets && pathParts.includes(FILE_SYSTEM_ROUTES.Partial))) {
|
|
880
|
+
_context4.next = 23;
|
|
881
|
+
break;
|
|
882
|
+
}
|
|
883
|
+
_context4.prev = 2;
|
|
884
|
+
pathParts.splice(pathParts.findIndex(function (part) {
|
|
885
|
+
return part === FILE_SYSTEM_ROUTES.Partial;
|
|
886
|
+
}), 1);
|
|
887
|
+
currentDir = directoryHandle;
|
|
888
|
+
_i = 0;
|
|
889
|
+
case 6:
|
|
890
|
+
if (!(_i < pathParts.length - 1)) {
|
|
891
|
+
_context4.next = 13;
|
|
892
|
+
break;
|
|
893
|
+
}
|
|
894
|
+
_context4.next = 9;
|
|
895
|
+
return currentDir.getDirectoryHandle(pathParts[_i], {
|
|
896
|
+
create: true
|
|
897
|
+
});
|
|
898
|
+
case 9:
|
|
899
|
+
currentDir = _context4.sent;
|
|
900
|
+
case 10:
|
|
901
|
+
_i++;
|
|
902
|
+
_context4.next = 6;
|
|
903
|
+
break;
|
|
904
|
+
case 13:
|
|
905
|
+
convertedFileName = pathParts.at(-1).split('_')[0] + '.tar';
|
|
906
|
+
_context4.next = 16;
|
|
907
|
+
return readArrayBufferFile(currentDir, convertedFileName);
|
|
908
|
+
case 16:
|
|
909
|
+
fileArraybuffer = _context4.sent;
|
|
910
|
+
return _context4.abrupt("return", fileArraybuffer.slice(options.offsets.startByte, options.offsets.endByte));
|
|
911
|
+
case 20:
|
|
912
|
+
_context4.prev = 20;
|
|
913
|
+
_context4.t0 = _context4["catch"](2);
|
|
914
|
+
console.warn("Error reading the file ".concat(name, ": ").concat(_context4.t0.message));
|
|
915
|
+
case 23:
|
|
916
|
+
case "end":
|
|
917
|
+
return _context4.stop();
|
|
918
|
+
}
|
|
919
|
+
}, _callee4, null, [[2, 20]]);
|
|
920
|
+
}))));
|
|
921
|
+
case 20:
|
|
922
|
+
_context5.next = 25;
|
|
923
|
+
break;
|
|
924
|
+
case 22:
|
|
925
|
+
_context5.prev = 22;
|
|
926
|
+
_context5.t0 = _context5["catch"](5);
|
|
927
|
+
console.warn("Error reading the file ".concat(name, ": ").concat(_context5.t0.message));
|
|
928
|
+
case 25:
|
|
929
|
+
case "end":
|
|
930
|
+
return _context5.stop();
|
|
931
|
+
}
|
|
932
|
+
}, _callee5, null, [[5, 22]]);
|
|
933
|
+
}));
|
|
934
|
+
return _readFile.apply(this, arguments);
|
|
1358
935
|
}
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
;// ./src/fileAccessSystemUtils.ts
|
|
1363
|
-
function fileAccessSystemUtils_typeof(o) { "@babel/helpers - typeof"; return fileAccessSystemUtils_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; }, fileAccessSystemUtils_typeof(o); }
|
|
1364
|
-
function fileAccessSystemUtils_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ fileAccessSystemUtils_regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == fileAccessSystemUtils_typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(fileAccessSystemUtils_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
1365
|
-
function fileAccessSystemUtils_slicedToArray(r, e) { return fileAccessSystemUtils_arrayWithHoles(r) || fileAccessSystemUtils_iterableToArrayLimit(r, e) || fileAccessSystemUtils_unsupportedIterableToArray(r, e) || fileAccessSystemUtils_nonIterableRest(); }
|
|
1366
|
-
function fileAccessSystemUtils_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."); }
|
|
1367
|
-
function fileAccessSystemUtils_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return fileAccessSystemUtils_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) ? fileAccessSystemUtils_arrayLikeToArray(r, a) : void 0; } }
|
|
1368
|
-
function fileAccessSystemUtils_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; }
|
|
1369
|
-
function fileAccessSystemUtils_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; } }
|
|
1370
|
-
function fileAccessSystemUtils_arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
1371
|
-
function fileAccessSystemUtils_asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
1372
|
-
function fileAccessSystemUtils_asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { fileAccessSystemUtils_asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { fileAccessSystemUtils_asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
1373
|
-
function _asyncIterator(r) { var n, t, o, e = 2; for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) { if (t && null != (n = r[t])) return n.call(r); if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r)); t = "@@asyncIterator", o = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
|
|
1374
|
-
function AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var n = r.done; return Promise.resolve(r.value).then(function (r) { return { value: r, done: n }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(r) { this.s = r, this.n = r.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, "return": function _return(r) { var n = this.s["return"]; return void 0 === n ? Promise.resolve({ value: r, done: !0 }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); }, "throw": function _throw(r) { var n = this.s["return"]; return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(r); }
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
var directoryHandle;
|
|
1378
|
-
function getDirectoryHandle() {
|
|
1379
|
-
return _getDirectoryHandle.apply(this, arguments);
|
|
936
|
+
function writeFile(_x7, _x8, _x9) {
|
|
937
|
+
return _writeFile.apply(this, arguments);
|
|
1380
938
|
}
|
|
1381
|
-
function
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
939
|
+
function _writeFile() {
|
|
940
|
+
_writeFile = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(directoryHandle, name, file) {
|
|
941
|
+
var isJson,
|
|
942
|
+
pathParts,
|
|
943
|
+
currentDir,
|
|
944
|
+
i,
|
|
945
|
+
fileName,
|
|
946
|
+
fileHandle,
|
|
947
|
+
fileWritable,
|
|
948
|
+
_args6 = arguments;
|
|
949
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
950
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
1385
951
|
case 0:
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
_context.next = 4;
|
|
1392
|
-
return get(IDB_DIR_HANDLE_KEY);
|
|
1393
|
-
case 4:
|
|
1394
|
-
directoryHandle = _context.sent;
|
|
952
|
+
isJson = _args6.length > 3 && _args6[3] !== undefined ? _args6[3] : false;
|
|
953
|
+
_context6.prev = 1;
|
|
954
|
+
pathParts = name.split('/');
|
|
955
|
+
currentDir = directoryHandle;
|
|
956
|
+
i = 0;
|
|
1395
957
|
case 5:
|
|
1396
|
-
if (
|
|
1397
|
-
|
|
958
|
+
if (!(i < pathParts.length - 1)) {
|
|
959
|
+
_context6.next = 12;
|
|
1398
960
|
break;
|
|
1399
961
|
}
|
|
1400
|
-
|
|
1401
|
-
return
|
|
962
|
+
_context6.next = 8;
|
|
963
|
+
return currentDir.getDirectoryHandle(pathParts[i], {
|
|
964
|
+
create: true
|
|
965
|
+
});
|
|
1402
966
|
case 8:
|
|
1403
|
-
|
|
967
|
+
currentDir = _context6.sent;
|
|
1404
968
|
case 9:
|
|
1405
|
-
|
|
969
|
+
i++;
|
|
970
|
+
_context6.next = 5;
|
|
971
|
+
break;
|
|
1406
972
|
case 12:
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
973
|
+
fileName = pathParts.at(-1);
|
|
974
|
+
_context6.next = 15;
|
|
975
|
+
return currentDir.getFileHandle(fileName, {
|
|
976
|
+
create: true
|
|
977
|
+
});
|
|
1410
978
|
case 15:
|
|
979
|
+
fileHandle = _context6.sent;
|
|
980
|
+
_context6.next = 18;
|
|
981
|
+
return fileHandle.createWritable();
|
|
982
|
+
case 18:
|
|
983
|
+
fileWritable = _context6.sent;
|
|
984
|
+
if (!isJson) {
|
|
985
|
+
_context6.next = 24;
|
|
986
|
+
break;
|
|
987
|
+
}
|
|
988
|
+
_context6.next = 22;
|
|
989
|
+
return fileWritable.write(JSON.stringify(file));
|
|
990
|
+
case 22:
|
|
991
|
+
_context6.next = 26;
|
|
992
|
+
break;
|
|
993
|
+
case 24:
|
|
994
|
+
_context6.next = 26;
|
|
995
|
+
return fileWritable.write(file);
|
|
996
|
+
case 26:
|
|
997
|
+
_context6.next = 28;
|
|
998
|
+
return fileWritable.close();
|
|
999
|
+
case 28:
|
|
1000
|
+
_context6.next = 33;
|
|
1001
|
+
break;
|
|
1002
|
+
case 30:
|
|
1003
|
+
_context6.prev = 30;
|
|
1004
|
+
_context6.t0 = _context6["catch"](1);
|
|
1005
|
+
console.warn("Error writing the file ".concat(name, ": ").concat(_context6.t0.message));
|
|
1006
|
+
case 33:
|
|
1411
1007
|
case "end":
|
|
1412
|
-
return
|
|
1008
|
+
return _context6.stop();
|
|
1413
1009
|
}
|
|
1414
|
-
},
|
|
1010
|
+
}, _callee6, null, [[1, 30]]);
|
|
1415
1011
|
}));
|
|
1416
|
-
return
|
|
1012
|
+
return _writeFile.apply(this, arguments);
|
|
1417
1013
|
}
|
|
1418
|
-
function
|
|
1419
|
-
|
|
1014
|
+
function download(fileName, file) {
|
|
1015
|
+
try {
|
|
1016
|
+
var blob = new Blob([file], {
|
|
1017
|
+
type: 'application/x-tar'
|
|
1018
|
+
});
|
|
1019
|
+
var url = URL.createObjectURL(blob);
|
|
1020
|
+
var a = document.createElement('a');
|
|
1021
|
+
a.href = url;
|
|
1022
|
+
a.download = fileName;
|
|
1023
|
+
a.click();
|
|
1024
|
+
URL.revokeObjectURL(url);
|
|
1025
|
+
return true;
|
|
1026
|
+
} catch (error) {
|
|
1027
|
+
console.warn("Error downloading file - ".concat(fileName, ": ") + error.message);
|
|
1028
|
+
return false;
|
|
1029
|
+
}
|
|
1420
1030
|
}
|
|
1421
|
-
function
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1031
|
+
function clearPartialFiles() {
|
|
1032
|
+
return _clearPartialFiles.apply(this, arguments);
|
|
1033
|
+
}
|
|
1034
|
+
function _clearPartialFiles() {
|
|
1035
|
+
_clearPartialFiles = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
1036
|
+
var _removePartialFolder;
|
|
1037
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context9) {
|
|
1038
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
1425
1039
|
case 0:
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
return
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1040
|
+
_removePartialFolder = /*#__PURE__*/function () {
|
|
1041
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(dirHandle) {
|
|
1042
|
+
var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _loop, _iterator, _step;
|
|
1043
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context8) {
|
|
1044
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
1045
|
+
case 0:
|
|
1046
|
+
// @ts-ignore
|
|
1047
|
+
_iteratorAbruptCompletion = false;
|
|
1048
|
+
_didIteratorError = false;
|
|
1049
|
+
_context8.prev = 2;
|
|
1050
|
+
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
1051
|
+
var _step$value, name, handle;
|
|
1052
|
+
return _regeneratorRuntime().wrap(function _loop$(_context7) {
|
|
1053
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
1054
|
+
case 0:
|
|
1055
|
+
_step$value = fileAccessSystemUtils_slicedToArray(_step.value, 2), name = _step$value[0], handle = _step$value[1];
|
|
1056
|
+
if (!(handle.kind === 'directory')) {
|
|
1057
|
+
_context7.next = 9;
|
|
1058
|
+
break;
|
|
1059
|
+
}
|
|
1060
|
+
if (!(name.toLowerCase() === FILE_SYSTEM_ROUTES.Partial)) {
|
|
1061
|
+
_context7.next = 7;
|
|
1062
|
+
break;
|
|
1063
|
+
}
|
|
1064
|
+
_context7.next = 5;
|
|
1065
|
+
return dirHandle.removeEntry(name, {
|
|
1066
|
+
recursive: true
|
|
1067
|
+
})["catch"](function (e) {
|
|
1068
|
+
return console.warn("Failed to remove ".concat(name, ":"), e);
|
|
1069
|
+
});
|
|
1070
|
+
case 5:
|
|
1071
|
+
_context7.next = 9;
|
|
1072
|
+
break;
|
|
1073
|
+
case 7:
|
|
1074
|
+
_context7.next = 9;
|
|
1075
|
+
return _removePartialFolder(handle);
|
|
1076
|
+
case 9:
|
|
1077
|
+
case "end":
|
|
1078
|
+
return _context7.stop();
|
|
1079
|
+
}
|
|
1080
|
+
}, _loop);
|
|
1081
|
+
});
|
|
1082
|
+
_iterator = _asyncIterator(dirHandle.entries());
|
|
1083
|
+
case 5:
|
|
1084
|
+
_context8.next = 7;
|
|
1085
|
+
return _iterator.next();
|
|
1086
|
+
case 7:
|
|
1087
|
+
if (!(_iteratorAbruptCompletion = !(_step = _context8.sent).done)) {
|
|
1088
|
+
_context8.next = 12;
|
|
1089
|
+
break;
|
|
1090
|
+
}
|
|
1091
|
+
return _context8.delegateYield(_loop(), "t0", 9);
|
|
1092
|
+
case 9:
|
|
1093
|
+
_iteratorAbruptCompletion = false;
|
|
1094
|
+
_context8.next = 5;
|
|
1095
|
+
break;
|
|
1096
|
+
case 12:
|
|
1097
|
+
_context8.next = 18;
|
|
1098
|
+
break;
|
|
1099
|
+
case 14:
|
|
1100
|
+
_context8.prev = 14;
|
|
1101
|
+
_context8.t1 = _context8["catch"](2);
|
|
1102
|
+
_didIteratorError = true;
|
|
1103
|
+
_iteratorError = _context8.t1;
|
|
1104
|
+
case 18:
|
|
1105
|
+
_context8.prev = 18;
|
|
1106
|
+
_context8.prev = 19;
|
|
1107
|
+
if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
|
|
1108
|
+
_context8.next = 23;
|
|
1109
|
+
break;
|
|
1110
|
+
}
|
|
1111
|
+
_context8.next = 23;
|
|
1112
|
+
return _iterator["return"]();
|
|
1113
|
+
case 23:
|
|
1114
|
+
_context8.prev = 23;
|
|
1115
|
+
if (!_didIteratorError) {
|
|
1116
|
+
_context8.next = 26;
|
|
1117
|
+
break;
|
|
1118
|
+
}
|
|
1119
|
+
throw _iteratorError;
|
|
1120
|
+
case 26:
|
|
1121
|
+
return _context8.finish(23);
|
|
1122
|
+
case 27:
|
|
1123
|
+
return _context8.finish(18);
|
|
1124
|
+
case 28:
|
|
1125
|
+
case "end":
|
|
1126
|
+
return _context8.stop();
|
|
1127
|
+
}
|
|
1128
|
+
}, _callee7, null, [[2, 14, 18, 28], [19,, 23, 27]]);
|
|
1129
|
+
}));
|
|
1130
|
+
return function removePartialFolder(_x10) {
|
|
1131
|
+
return _ref2.apply(this, arguments);
|
|
1132
|
+
};
|
|
1133
|
+
}();
|
|
1134
|
+
_context9.prev = 1;
|
|
1135
|
+
_context9.next = 4;
|
|
1136
|
+
return _removePartialFolder(directoryHandle);
|
|
1137
|
+
case 4:
|
|
1138
|
+
_context9.next = 9;
|
|
1139
|
+
break;
|
|
1140
|
+
case 6:
|
|
1141
|
+
_context9.prev = 6;
|
|
1142
|
+
_context9.t0 = _context9["catch"](1);
|
|
1143
|
+
console.warn("Error clearing partial files: ".concat(_context9.t0.message));
|
|
1144
|
+
case 9:
|
|
1439
1145
|
case "end":
|
|
1440
|
-
return
|
|
1146
|
+
return _context9.stop();
|
|
1441
1147
|
}
|
|
1442
|
-
},
|
|
1148
|
+
}, _callee8, null, [[1, 6]]);
|
|
1443
1149
|
}));
|
|
1444
|
-
return
|
|
1150
|
+
return _clearPartialFiles.apply(this, arguments);
|
|
1445
1151
|
}
|
|
1446
|
-
function
|
|
1447
|
-
|
|
1152
|
+
function parseCachePath(url) {
|
|
1153
|
+
var urlObj = new URL(url);
|
|
1154
|
+
var bucketPath = urlObj.pathname.match(/\/(.*?)\/studies/)[1];
|
|
1155
|
+
var _urlObj$pathname$matc = urlObj.pathname.match(/studies\/(.*?)(\.tar|\/metadata.json)/)[1].split('/'),
|
|
1156
|
+
_urlObj$pathname$matc2 = fileAccessSystemUtils_slicedToArray(_urlObj$pathname$matc, 3),
|
|
1157
|
+
studyInstanceUID = _urlObj$pathname$matc2[0],
|
|
1158
|
+
_ = _urlObj$pathname$matc2[1],
|
|
1159
|
+
seriesInstanceUID = _urlObj$pathname$matc2[2];
|
|
1160
|
+
return "".concat(bucketPath, "/").concat(studyInstanceUID, "/").concat(seriesInstanceUID);
|
|
1448
1161
|
}
|
|
1449
|
-
function
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1162
|
+
function createStreamingFileName(url) {
|
|
1163
|
+
return "".concat(parseCachePath(url), "/").concat(url.split('series/')[1]);
|
|
1164
|
+
}
|
|
1165
|
+
function createPartialFileName(url, offsets) {
|
|
1166
|
+
var seriesInstanceUID = url.match(/series\/(.*?).tar/)[1];
|
|
1167
|
+
var offsetPart = "".concat(offsets ? "_".concat(offsets === null || offsets === void 0 ? void 0 : offsets.startByte, "_").concat(offsets === null || offsets === void 0 ? void 0 : offsets.endByte) : '');
|
|
1168
|
+
return "".concat(parseCachePath(url), "/").concat(FILE_SYSTEM_ROUTES.Partial, "/").concat(seriesInstanceUID).concat(offsetPart, ".dcm");
|
|
1169
|
+
}
|
|
1170
|
+
function createMetadataFileName(url) {
|
|
1171
|
+
return "".concat(parseCachePath(url), "/metadata.json");
|
|
1172
|
+
}
|
|
1173
|
+
;// ./src/metadataManager.ts
|
|
1174
|
+
function metadataManager_typeof(o) { "@babel/helpers - typeof"; return metadataManager_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; }, metadataManager_typeof(o); }
|
|
1175
|
+
function metadataManager_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ metadataManager_regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == metadataManager_typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(metadataManager_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
1176
|
+
function metadataManager_asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
1177
|
+
function metadataManager_asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { metadataManager_asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { metadataManager_asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
1178
|
+
function metadataManager_slicedToArray(r, e) { return metadataManager_arrayWithHoles(r) || metadataManager_iterableToArrayLimit(r, e) || metadataManager_unsupportedIterableToArray(r, e) || metadataManager_nonIterableRest(); }
|
|
1179
|
+
function metadataManager_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."); }
|
|
1180
|
+
function metadataManager_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return metadataManager_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) ? metadataManager_arrayLikeToArray(r, a) : void 0; } }
|
|
1181
|
+
function metadataManager_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; }
|
|
1182
|
+
function metadataManager_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; } }
|
|
1183
|
+
function metadataManager_arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
1184
|
+
function metadataManager_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
1185
|
+
function metadataManager_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, metadataManager_toPropertyKey(o.key), o); } }
|
|
1186
|
+
function metadataManager_createClass(e, r, t) { return r && metadataManager_defineProperties(e.prototype, r), t && metadataManager_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
1187
|
+
function metadataManager_defineProperty(e, r, t) { return (r = metadataManager_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
1188
|
+
function metadataManager_toPropertyKey(t) { var i = metadataManager_toPrimitive(t, "string"); return "symbol" == metadataManager_typeof(i) ? i : i + ""; }
|
|
1189
|
+
function metadataManager_toPrimitive(t, r) { if ("object" != metadataManager_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != metadataManager_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1190
|
+
|
|
1191
|
+
|
|
1192
|
+
|
|
1193
|
+
var MetadataManager = /*#__PURE__*/function () {
|
|
1194
|
+
function MetadataManager() {
|
|
1195
|
+
metadataManager_classCallCheck(this, MetadataManager);
|
|
1196
|
+
metadataManager_defineProperty(this, "metadataPromises", {});
|
|
1197
|
+
}
|
|
1198
|
+
return metadataManager_createClass(MetadataManager, [{
|
|
1199
|
+
key: "addDeidMetadata",
|
|
1200
|
+
value: function addDeidMetadata(jsonMetadata, url) {
|
|
1201
|
+
var _url$match;
|
|
1202
|
+
var cod = jsonMetadata.cod;
|
|
1203
|
+
var _ref = ((_url$match = url.match(/studies\/(.*?)\/metadata/)) === null || _url$match === void 0 ? void 0 : _url$match[1].split('/')) || [],
|
|
1204
|
+
_ref2 = metadataManager_slicedToArray(_ref, 3),
|
|
1205
|
+
studyUID = _ref2[0],
|
|
1206
|
+
_ = _ref2[1],
|
|
1207
|
+
seriesUID = _ref2[2];
|
|
1208
|
+
if (!cod || !studyUID || !seriesUID) {
|
|
1209
|
+
console.warn('Missing required metadata properties: cod, studyUID, or seriesUID');
|
|
1210
|
+
return;
|
|
1211
|
+
}
|
|
1212
|
+
for (var sopUID in cod.instances) {
|
|
1213
|
+
var instance = cod.instances[sopUID];
|
|
1214
|
+
instance.metadata.DeidStudyInstanceUID = {
|
|
1215
|
+
Value: [studyUID]
|
|
1216
|
+
};
|
|
1217
|
+
instance.metadata.DeidSeriesInstanceUID = {
|
|
1218
|
+
Value: [seriesUID]
|
|
1219
|
+
};
|
|
1220
|
+
instance.metadata.DeidSopInstanceUID = {
|
|
1221
|
+
Value: [sopUID]
|
|
1222
|
+
};
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
}, {
|
|
1226
|
+
key: "getMetadataFromCache",
|
|
1227
|
+
value: function getMetadataFromCache(url) {
|
|
1228
|
+
return this.metadataPromises[url];
|
|
1229
|
+
}
|
|
1230
|
+
}, {
|
|
1231
|
+
key: "getMetadata",
|
|
1232
|
+
value: function () {
|
|
1233
|
+
var _getMetadata = metadataManager_asyncToGenerator(/*#__PURE__*/metadataManager_regeneratorRuntime().mark(function _callee(params, headers) {
|
|
1234
|
+
var _this = this;
|
|
1235
|
+
var url, cachedMetadata, directoryHandle, fileName, locallyCachedMetadata;
|
|
1236
|
+
return metadataManager_regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1237
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1238
|
+
case 0:
|
|
1239
|
+
url = createMetadataJsonUrl(params);
|
|
1240
|
+
if (url) {
|
|
1241
|
+
_context.next = 3;
|
|
1242
|
+
break;
|
|
1243
|
+
}
|
|
1244
|
+
throw new CustomError('Error creating metadata json url');
|
|
1245
|
+
case 3:
|
|
1246
|
+
cachedMetadata = this.getMetadataFromCache(url);
|
|
1247
|
+
if (!cachedMetadata) {
|
|
1248
|
+
_context.next = 8;
|
|
1249
|
+
break;
|
|
1250
|
+
}
|
|
1251
|
+
_context.next = 7;
|
|
1252
|
+
return cachedMetadata;
|
|
1253
|
+
case 7:
|
|
1254
|
+
return _context.abrupt("return", _context.sent);
|
|
1255
|
+
case 8:
|
|
1256
|
+
_context.next = 10;
|
|
1257
|
+
return getDirectoryHandle();
|
|
1258
|
+
case 10:
|
|
1259
|
+
directoryHandle = _context.sent;
|
|
1260
|
+
fileName = createMetadataFileName(url);
|
|
1261
|
+
_context.next = 14;
|
|
1262
|
+
return readFile(directoryHandle, fileName, {
|
|
1263
|
+
isJson: true
|
|
1264
|
+
});
|
|
1265
|
+
case 14:
|
|
1266
|
+
locallyCachedMetadata = _context.sent;
|
|
1267
|
+
if (!locallyCachedMetadata) {
|
|
1268
|
+
_context.next = 17;
|
|
1269
|
+
break;
|
|
1270
|
+
}
|
|
1271
|
+
return _context.abrupt("return", locallyCachedMetadata);
|
|
1272
|
+
case 17:
|
|
1273
|
+
_context.prev = 17;
|
|
1274
|
+
this.metadataPromises[url] = fetch(url, {
|
|
1275
|
+
headers: headers
|
|
1276
|
+
}).then(function (response) {
|
|
1277
|
+
if (!response.ok) {
|
|
1278
|
+
throw new CustomError("Failed to fetch metadata: ".concat(response.statusText));
|
|
1279
|
+
}
|
|
1280
|
+
return response.json();
|
|
1281
|
+
}).then(function (data) {
|
|
1282
|
+
_this.addDeidMetadata(data, url);
|
|
1283
|
+
return writeFile(directoryHandle, fileName, data, true).then(function () {
|
|
1284
|
+
return data;
|
|
1285
|
+
});
|
|
1286
|
+
});
|
|
1287
|
+
_context.next = 21;
|
|
1288
|
+
return this.metadataPromises[url];
|
|
1289
|
+
case 21:
|
|
1290
|
+
return _context.abrupt("return", _context.sent);
|
|
1291
|
+
case 24:
|
|
1292
|
+
_context.prev = 24;
|
|
1293
|
+
_context.t0 = _context["catch"](17);
|
|
1294
|
+
console.error(_context.t0);
|
|
1295
|
+
throw _context.t0;
|
|
1296
|
+
case 28:
|
|
1297
|
+
case "end":
|
|
1298
|
+
return _context.stop();
|
|
1299
|
+
}
|
|
1300
|
+
}, _callee, this, [[17, 24]]);
|
|
1301
|
+
}));
|
|
1302
|
+
function getMetadata(_x, _x2) {
|
|
1303
|
+
return _getMetadata.apply(this, arguments);
|
|
1304
|
+
}
|
|
1305
|
+
return getMetadata;
|
|
1306
|
+
}()
|
|
1307
|
+
}]);
|
|
1308
|
+
}();
|
|
1309
|
+
/* harmony default export */ const metadataManager = (MetadataManager);
|
|
1310
|
+
;// ./src/dataRetrieval/requestManager.ts
|
|
1311
|
+
function requestManager_typeof(o) { "@babel/helpers - typeof"; return requestManager_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; }, requestManager_typeof(o); }
|
|
1312
|
+
function requestManager_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ requestManager_regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == requestManager_typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(requestManager_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
1313
|
+
function requestManager_asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
1314
|
+
function requestManager_asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { requestManager_asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { requestManager_asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
1315
|
+
function requestManager_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
1316
|
+
function requestManager_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, requestManager_toPropertyKey(o.key), o); } }
|
|
1317
|
+
function requestManager_createClass(e, r, t) { return r && requestManager_defineProperties(e.prototype, r), t && requestManager_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
1318
|
+
function requestManager_defineProperty(e, r, t) { return (r = requestManager_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
1319
|
+
function requestManager_toPropertyKey(t) { var i = requestManager_toPrimitive(t, "string"); return "symbol" == requestManager_typeof(i) ? i : i + ""; }
|
|
1320
|
+
function requestManager_toPrimitive(t, r) { if ("object" != requestManager_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != requestManager_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1321
|
+
|
|
1322
|
+
var RequestManager = /*#__PURE__*/function () {
|
|
1323
|
+
function RequestManager() {
|
|
1324
|
+
var _this = this;
|
|
1325
|
+
requestManager_classCallCheck(this, RequestManager);
|
|
1326
|
+
requestManager_defineProperty(this, "loaderRegistry", {});
|
|
1327
|
+
requestManager_defineProperty(this, "listenerCallback", function (loaderName, taskName, args) {
|
|
1328
|
+
var _this$loaderRegistry$;
|
|
1329
|
+
var listeners = (_this$loaderRegistry$ = _this.loaderRegistry[loaderName]) === null || _this$loaderRegistry$ === void 0 ? void 0 : _this$loaderRegistry$.listeners[taskName];
|
|
1330
|
+
if (listeners) {
|
|
1331
|
+
listeners.forEach(function (listener) {
|
|
1332
|
+
return listener({
|
|
1333
|
+
data: args
|
|
1461
1334
|
});
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1339
|
+
return requestManager_createClass(RequestManager, [{
|
|
1340
|
+
key: "register",
|
|
1341
|
+
value: function register(loaderName, loaderObject) {
|
|
1342
|
+
try {
|
|
1343
|
+
if (!loaderObject) {
|
|
1344
|
+
throw new CustomError("Loader object for ".concat(loaderName, " is not provided"));
|
|
1345
|
+
}
|
|
1346
|
+
this.loaderRegistry[loaderName] = {
|
|
1347
|
+
loaderObject: loaderObject,
|
|
1348
|
+
listeners: {}
|
|
1349
|
+
};
|
|
1350
|
+
} catch (error) {
|
|
1351
|
+
console.warn(error);
|
|
1352
|
+
throw new CustomError('throws');
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
}, {
|
|
1356
|
+
key: "executeTask",
|
|
1357
|
+
value: function () {
|
|
1358
|
+
var _executeTask = requestManager_asyncToGenerator(/*#__PURE__*/requestManager_regeneratorRuntime().mark(function _callee(loaderName, taskName, options) {
|
|
1359
|
+
var _this$loaderRegistry$2,
|
|
1360
|
+
_this2 = this;
|
|
1361
|
+
var loaderObject;
|
|
1362
|
+
return requestManager_regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1363
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1364
|
+
case 0:
|
|
1365
|
+
loaderObject = (_this$loaderRegistry$2 = this.loaderRegistry[loaderName]) === null || _this$loaderRegistry$2 === void 0 ? void 0 : _this$loaderRegistry$2.loaderObject;
|
|
1366
|
+
if (loaderObject) {
|
|
1367
|
+
_context.next = 3;
|
|
1368
|
+
break;
|
|
1369
|
+
}
|
|
1370
|
+
throw new CustomError("Loader ".concat(loaderName, " not registered"));
|
|
1371
|
+
case 3:
|
|
1372
|
+
_context.prev = 3;
|
|
1373
|
+
_context.next = 6;
|
|
1374
|
+
return loaderObject[taskName](options, function (args) {
|
|
1375
|
+
return _this2.listenerCallback(loaderName, 'message', args);
|
|
1376
|
+
});
|
|
1377
|
+
case 6:
|
|
1378
|
+
return _context.abrupt("return", _context.sent);
|
|
1379
|
+
case 9:
|
|
1380
|
+
_context.prev = 9;
|
|
1381
|
+
_context.t0 = _context["catch"](3);
|
|
1382
|
+
console.error("Error executing task \"".concat(taskName, "\" on \"").concat(loaderName, "\":"), _context.t0);
|
|
1383
|
+
throw new CustomError("Task \"".concat(taskName, "\" failed: ").concat(_context.t0.message));
|
|
1384
|
+
case 13:
|
|
1385
|
+
case "end":
|
|
1386
|
+
return _context.stop();
|
|
1387
|
+
}
|
|
1388
|
+
}, _callee, this, [[3, 9]]);
|
|
1389
|
+
}));
|
|
1390
|
+
function executeTask(_x, _x2, _x3) {
|
|
1391
|
+
return _executeTask.apply(this, arguments);
|
|
1392
|
+
}
|
|
1393
|
+
return executeTask;
|
|
1394
|
+
}()
|
|
1395
|
+
}, {
|
|
1396
|
+
key: "addEventListener",
|
|
1397
|
+
value: function addEventListener(workerName, eventType, listener) {
|
|
1398
|
+
var loaderObject = this.loaderRegistry[workerName];
|
|
1399
|
+
if (!loaderObject) {
|
|
1400
|
+
console.error("Loader '".concat(workerName, "' is not registered."));
|
|
1401
|
+
return;
|
|
1467
1402
|
}
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1403
|
+
if (!loaderObject.listeners[eventType]) {
|
|
1404
|
+
loaderObject.listeners[eventType] = [listener];
|
|
1405
|
+
} else {
|
|
1406
|
+
loaderObject.listeners[eventType].push(listener);
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
}, {
|
|
1410
|
+
key: "removeEventListener",
|
|
1411
|
+
value: function removeEventListener(workerName, eventType, listener) {
|
|
1412
|
+
var loaderObject = this.loaderRegistry[workerName];
|
|
1413
|
+
if (!loaderObject) {
|
|
1414
|
+
console.error("Loader '".concat(workerName, "' is not registered."));
|
|
1415
|
+
return;
|
|
1416
|
+
}
|
|
1417
|
+
loaderObject.listeners[eventType] = (loaderObject.listeners[eventType] || []).filter(function (existingListener) {
|
|
1418
|
+
return existingListener !== listener;
|
|
1419
|
+
});
|
|
1420
|
+
}
|
|
1421
|
+
}, {
|
|
1422
|
+
key: "reset",
|
|
1423
|
+
value: function reset() {
|
|
1424
|
+
this.loaderRegistry = {};
|
|
1425
|
+
}
|
|
1426
|
+
}]);
|
|
1427
|
+
}();
|
|
1428
|
+
/* harmony default export */ const requestManager = (RequestManager);
|
|
1429
|
+
;// ./src/dataRetrieval/utils/environment.ts
|
|
1430
|
+
function isNodeEnvironment() {
|
|
1431
|
+
return typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
1471
1432
|
}
|
|
1472
|
-
|
|
1473
|
-
|
|
1433
|
+
;// ./node_modules/comlink/dist/esm/comlink.mjs
|
|
1434
|
+
/**
|
|
1435
|
+
* @license
|
|
1436
|
+
* Copyright 2019 Google LLC
|
|
1437
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
1438
|
+
*/
|
|
1439
|
+
const proxyMarker = Symbol("Comlink.proxy");
|
|
1440
|
+
const createEndpoint = Symbol("Comlink.endpoint");
|
|
1441
|
+
const releaseProxy = Symbol("Comlink.releaseProxy");
|
|
1442
|
+
const finalizer = Symbol("Comlink.finalizer");
|
|
1443
|
+
const throwMarker = Symbol("Comlink.thrown");
|
|
1444
|
+
const isObject = (val) => (typeof val === "object" && val !== null) || typeof val === "function";
|
|
1445
|
+
/**
|
|
1446
|
+
* Internal transfer handle to handle objects marked to proxy.
|
|
1447
|
+
*/
|
|
1448
|
+
const proxyTransferHandler = {
|
|
1449
|
+
canHandle: (val) => isObject(val) && val[proxyMarker],
|
|
1450
|
+
serialize(obj) {
|
|
1451
|
+
const { port1, port2 } = new MessageChannel();
|
|
1452
|
+
expose(obj, port1);
|
|
1453
|
+
return [port2, [port2]];
|
|
1454
|
+
},
|
|
1455
|
+
deserialize(port) {
|
|
1456
|
+
port.start();
|
|
1457
|
+
return wrap(port);
|
|
1458
|
+
},
|
|
1459
|
+
};
|
|
1460
|
+
/**
|
|
1461
|
+
* Internal transfer handler to handle thrown exceptions.
|
|
1462
|
+
*/
|
|
1463
|
+
const throwTransferHandler = {
|
|
1464
|
+
canHandle: (value) => isObject(value) && throwMarker in value,
|
|
1465
|
+
serialize({ value }) {
|
|
1466
|
+
let serialized;
|
|
1467
|
+
if (value instanceof Error) {
|
|
1468
|
+
serialized = {
|
|
1469
|
+
isError: true,
|
|
1470
|
+
value: {
|
|
1471
|
+
message: value.message,
|
|
1472
|
+
name: value.name,
|
|
1473
|
+
stack: value.stack,
|
|
1474
|
+
},
|
|
1475
|
+
};
|
|
1476
|
+
}
|
|
1477
|
+
else {
|
|
1478
|
+
serialized = { isError: false, value };
|
|
1479
|
+
}
|
|
1480
|
+
return [serialized, []];
|
|
1481
|
+
},
|
|
1482
|
+
deserialize(serialized) {
|
|
1483
|
+
if (serialized.isError) {
|
|
1484
|
+
throw Object.assign(new Error(serialized.value.message), serialized.value);
|
|
1485
|
+
}
|
|
1486
|
+
throw serialized.value;
|
|
1487
|
+
},
|
|
1488
|
+
};
|
|
1489
|
+
/**
|
|
1490
|
+
* Allows customizing the serialization of certain values.
|
|
1491
|
+
*/
|
|
1492
|
+
const transferHandlers = new Map([
|
|
1493
|
+
["proxy", proxyTransferHandler],
|
|
1494
|
+
["throw", throwTransferHandler],
|
|
1495
|
+
]);
|
|
1496
|
+
function isAllowedOrigin(allowedOrigins, origin) {
|
|
1497
|
+
for (const allowedOrigin of allowedOrigins) {
|
|
1498
|
+
if (origin === allowedOrigin || allowedOrigin === "*") {
|
|
1499
|
+
return true;
|
|
1500
|
+
}
|
|
1501
|
+
if (allowedOrigin instanceof RegExp && allowedOrigin.test(origin)) {
|
|
1502
|
+
return true;
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
return false;
|
|
1474
1506
|
}
|
|
1475
|
-
function
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
_context5.prev = 5;
|
|
1496
|
-
i = 0;
|
|
1497
|
-
case 7:
|
|
1498
|
-
if (!(i < pathParts.length - 1)) {
|
|
1499
|
-
_context5.next = 14;
|
|
1500
|
-
break;
|
|
1501
|
-
}
|
|
1502
|
-
_context5.next = 10;
|
|
1503
|
-
return currentDir.getDirectoryHandle(pathParts[i], {
|
|
1504
|
-
create: true
|
|
1505
|
-
});
|
|
1506
|
-
case 10:
|
|
1507
|
-
currentDir = _context5.sent;
|
|
1508
|
-
case 11:
|
|
1509
|
-
i++;
|
|
1510
|
-
_context5.next = 7;
|
|
1511
|
-
break;
|
|
1512
|
-
case 14:
|
|
1513
|
-
fileName = pathParts.at(-1);
|
|
1514
|
-
if (!options.isJson) {
|
|
1515
|
-
_context5.next = 19;
|
|
1516
|
-
break;
|
|
1517
|
-
}
|
|
1518
|
-
return _context5.abrupt("return", readJsonFile(currentDir, fileName));
|
|
1519
|
-
case 19:
|
|
1520
|
-
return _context5.abrupt("return", readArrayBufferFile(currentDir, fileName)["catch"](/*#__PURE__*/fileAccessSystemUtils_asyncToGenerator(/*#__PURE__*/fileAccessSystemUtils_regeneratorRuntime().mark(function _callee4() {
|
|
1521
|
-
var _i, convertedFileName, fileArraybuffer;
|
|
1522
|
-
return fileAccessSystemUtils_regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1523
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
1524
|
-
case 0:
|
|
1525
|
-
console.warn("Error reading the file ".concat(name, " from partial folder, trying from full file"));
|
|
1526
|
-
if (!(options.offsets && pathParts.includes(FILE_SYSTEM_ROUTES.Partial))) {
|
|
1527
|
-
_context4.next = 23;
|
|
1507
|
+
function expose(obj, ep = globalThis, allowedOrigins = ["*"]) {
|
|
1508
|
+
ep.addEventListener("message", function callback(ev) {
|
|
1509
|
+
if (!ev || !ev.data) {
|
|
1510
|
+
return;
|
|
1511
|
+
}
|
|
1512
|
+
if (!isAllowedOrigin(allowedOrigins, ev.origin)) {
|
|
1513
|
+
console.warn(`Invalid origin '${ev.origin}' for comlink proxy`);
|
|
1514
|
+
return;
|
|
1515
|
+
}
|
|
1516
|
+
const { id, type, path } = Object.assign({ path: [] }, ev.data);
|
|
1517
|
+
const argumentList = (ev.data.argumentList || []).map(fromWireValue);
|
|
1518
|
+
let returnValue;
|
|
1519
|
+
try {
|
|
1520
|
+
const parent = path.slice(0, -1).reduce((obj, prop) => obj[prop], obj);
|
|
1521
|
+
const rawValue = path.reduce((obj, prop) => obj[prop], obj);
|
|
1522
|
+
switch (type) {
|
|
1523
|
+
case "GET" /* MessageType.GET */:
|
|
1524
|
+
{
|
|
1525
|
+
returnValue = rawValue;
|
|
1526
|
+
}
|
|
1528
1527
|
break;
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
currentDir = directoryHandle;
|
|
1535
|
-
_i = 0;
|
|
1536
|
-
case 6:
|
|
1537
|
-
if (!(_i < pathParts.length - 1)) {
|
|
1538
|
-
_context4.next = 13;
|
|
1528
|
+
case "SET" /* MessageType.SET */:
|
|
1529
|
+
{
|
|
1530
|
+
parent[path.slice(-1)[0]] = fromWireValue(ev.data.value);
|
|
1531
|
+
returnValue = true;
|
|
1532
|
+
}
|
|
1539
1533
|
break;
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
case
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
case
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
case
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1534
|
+
case "APPLY" /* MessageType.APPLY */:
|
|
1535
|
+
{
|
|
1536
|
+
returnValue = rawValue.apply(parent, argumentList);
|
|
1537
|
+
}
|
|
1538
|
+
break;
|
|
1539
|
+
case "CONSTRUCT" /* MessageType.CONSTRUCT */:
|
|
1540
|
+
{
|
|
1541
|
+
const value = new rawValue(...argumentList);
|
|
1542
|
+
returnValue = proxy(value);
|
|
1543
|
+
}
|
|
1544
|
+
break;
|
|
1545
|
+
case "ENDPOINT" /* MessageType.ENDPOINT */:
|
|
1546
|
+
{
|
|
1547
|
+
const { port1, port2 } = new MessageChannel();
|
|
1548
|
+
expose(obj, port2);
|
|
1549
|
+
returnValue = transfer(port1, [port1]);
|
|
1550
|
+
}
|
|
1551
|
+
break;
|
|
1552
|
+
case "RELEASE" /* MessageType.RELEASE */:
|
|
1553
|
+
{
|
|
1554
|
+
returnValue = undefined;
|
|
1555
|
+
}
|
|
1556
|
+
break;
|
|
1557
|
+
default:
|
|
1558
|
+
return;
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
catch (value) {
|
|
1562
|
+
returnValue = { value, [throwMarker]: 0 };
|
|
1563
|
+
}
|
|
1564
|
+
Promise.resolve(returnValue)
|
|
1565
|
+
.catch((value) => {
|
|
1566
|
+
return { value, [throwMarker]: 0 };
|
|
1567
|
+
})
|
|
1568
|
+
.then((returnValue) => {
|
|
1569
|
+
const [wireValue, transferables] = toWireValue(returnValue);
|
|
1570
|
+
ep.postMessage(Object.assign(Object.assign({}, wireValue), { id }), transferables);
|
|
1571
|
+
if (type === "RELEASE" /* MessageType.RELEASE */) {
|
|
1572
|
+
// detach and deactive after sending release response above.
|
|
1573
|
+
ep.removeEventListener("message", callback);
|
|
1574
|
+
closeEndPoint(ep);
|
|
1575
|
+
if (finalizer in obj && typeof obj[finalizer] === "function") {
|
|
1576
|
+
obj[finalizer]();
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
})
|
|
1580
|
+
.catch((error) => {
|
|
1581
|
+
// Send Serialization Error To Caller
|
|
1582
|
+
const [wireValue, transferables] = toWireValue({
|
|
1583
|
+
value: new TypeError("Unserializable return value"),
|
|
1584
|
+
[throwMarker]: 0,
|
|
1585
|
+
});
|
|
1586
|
+
ep.postMessage(Object.assign(Object.assign({}, wireValue), { id }), transferables);
|
|
1587
|
+
});
|
|
1588
|
+
});
|
|
1589
|
+
if (ep.start) {
|
|
1590
|
+
ep.start();
|
|
1591
|
+
}
|
|
1582
1592
|
}
|
|
1583
|
-
function
|
|
1584
|
-
|
|
1593
|
+
function isMessagePort(endpoint) {
|
|
1594
|
+
return endpoint.constructor.name === "MessagePort";
|
|
1585
1595
|
}
|
|
1586
|
-
function
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
pathParts,
|
|
1590
|
-
currentDir,
|
|
1591
|
-
i,
|
|
1592
|
-
fileName,
|
|
1593
|
-
fileHandle,
|
|
1594
|
-
fileWritable,
|
|
1595
|
-
_args6 = arguments;
|
|
1596
|
-
return fileAccessSystemUtils_regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
1597
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
1598
|
-
case 0:
|
|
1599
|
-
isJson = _args6.length > 3 && _args6[3] !== undefined ? _args6[3] : false;
|
|
1600
|
-
_context6.prev = 1;
|
|
1601
|
-
pathParts = name.split('/');
|
|
1602
|
-
currentDir = directoryHandle;
|
|
1603
|
-
i = 0;
|
|
1604
|
-
case 5:
|
|
1605
|
-
if (!(i < pathParts.length - 1)) {
|
|
1606
|
-
_context6.next = 12;
|
|
1607
|
-
break;
|
|
1608
|
-
}
|
|
1609
|
-
_context6.next = 8;
|
|
1610
|
-
return currentDir.getDirectoryHandle(pathParts[i], {
|
|
1611
|
-
create: true
|
|
1612
|
-
});
|
|
1613
|
-
case 8:
|
|
1614
|
-
currentDir = _context6.sent;
|
|
1615
|
-
case 9:
|
|
1616
|
-
i++;
|
|
1617
|
-
_context6.next = 5;
|
|
1618
|
-
break;
|
|
1619
|
-
case 12:
|
|
1620
|
-
fileName = pathParts.at(-1);
|
|
1621
|
-
_context6.next = 15;
|
|
1622
|
-
return currentDir.getFileHandle(fileName, {
|
|
1623
|
-
create: true
|
|
1624
|
-
});
|
|
1625
|
-
case 15:
|
|
1626
|
-
fileHandle = _context6.sent;
|
|
1627
|
-
_context6.next = 18;
|
|
1628
|
-
return fileHandle.createWritable();
|
|
1629
|
-
case 18:
|
|
1630
|
-
fileWritable = _context6.sent;
|
|
1631
|
-
if (!isJson) {
|
|
1632
|
-
_context6.next = 24;
|
|
1633
|
-
break;
|
|
1634
|
-
}
|
|
1635
|
-
_context6.next = 22;
|
|
1636
|
-
return fileWritable.write(JSON.stringify(file));
|
|
1637
|
-
case 22:
|
|
1638
|
-
_context6.next = 26;
|
|
1639
|
-
break;
|
|
1640
|
-
case 24:
|
|
1641
|
-
_context6.next = 26;
|
|
1642
|
-
return fileWritable.write(file);
|
|
1643
|
-
case 26:
|
|
1644
|
-
_context6.next = 28;
|
|
1645
|
-
return fileWritable.close();
|
|
1646
|
-
case 28:
|
|
1647
|
-
_context6.next = 33;
|
|
1648
|
-
break;
|
|
1649
|
-
case 30:
|
|
1650
|
-
_context6.prev = 30;
|
|
1651
|
-
_context6.t0 = _context6["catch"](1);
|
|
1652
|
-
console.warn("Error writing the file ".concat(name, ": ").concat(_context6.t0.message));
|
|
1653
|
-
case 33:
|
|
1654
|
-
case "end":
|
|
1655
|
-
return _context6.stop();
|
|
1656
|
-
}
|
|
1657
|
-
}, _callee6, null, [[1, 30]]);
|
|
1658
|
-
}));
|
|
1659
|
-
return _writeFile.apply(this, arguments);
|
|
1596
|
+
function closeEndPoint(endpoint) {
|
|
1597
|
+
if (isMessagePort(endpoint))
|
|
1598
|
+
endpoint.close();
|
|
1660
1599
|
}
|
|
1661
|
-
function
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1600
|
+
function wrap(ep, target) {
|
|
1601
|
+
const pendingListeners = new Map();
|
|
1602
|
+
ep.addEventListener("message", function handleMessage(ev) {
|
|
1603
|
+
const { data } = ev;
|
|
1604
|
+
if (!data || !data.id) {
|
|
1605
|
+
return;
|
|
1606
|
+
}
|
|
1607
|
+
const resolver = pendingListeners.get(data.id);
|
|
1608
|
+
if (!resolver) {
|
|
1609
|
+
return;
|
|
1610
|
+
}
|
|
1611
|
+
try {
|
|
1612
|
+
resolver(data);
|
|
1613
|
+
}
|
|
1614
|
+
finally {
|
|
1615
|
+
pendingListeners.delete(data.id);
|
|
1616
|
+
}
|
|
1665
1617
|
});
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1618
|
+
return createProxy(ep, pendingListeners, [], target);
|
|
1619
|
+
}
|
|
1620
|
+
function throwIfProxyReleased(isReleased) {
|
|
1621
|
+
if (isReleased) {
|
|
1622
|
+
throw new Error("Proxy has been released and is not useable");
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
function releaseEndpoint(ep) {
|
|
1626
|
+
return requestResponseMessage(ep, new Map(), {
|
|
1627
|
+
type: "RELEASE" /* MessageType.RELEASE */,
|
|
1628
|
+
}).then(() => {
|
|
1629
|
+
closeEndPoint(ep);
|
|
1630
|
+
});
|
|
1631
|
+
}
|
|
1632
|
+
const proxyCounter = new WeakMap();
|
|
1633
|
+
const proxyFinalizers = "FinalizationRegistry" in globalThis &&
|
|
1634
|
+
new FinalizationRegistry((ep) => {
|
|
1635
|
+
const newCount = (proxyCounter.get(ep) || 0) - 1;
|
|
1636
|
+
proxyCounter.set(ep, newCount);
|
|
1637
|
+
if (newCount === 0) {
|
|
1638
|
+
releaseEndpoint(ep);
|
|
1639
|
+
}
|
|
1640
|
+
});
|
|
1641
|
+
function registerProxy(proxy, ep) {
|
|
1642
|
+
const newCount = (proxyCounter.get(ep) || 0) + 1;
|
|
1643
|
+
proxyCounter.set(ep, newCount);
|
|
1644
|
+
if (proxyFinalizers) {
|
|
1645
|
+
proxyFinalizers.register(proxy, ep, proxy);
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
function unregisterProxy(proxy) {
|
|
1649
|
+
if (proxyFinalizers) {
|
|
1650
|
+
proxyFinalizers.unregister(proxy);
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
function createProxy(ep, pendingListeners, path = [], target = function () { }) {
|
|
1654
|
+
let isProxyReleased = false;
|
|
1655
|
+
const proxy = new Proxy(target, {
|
|
1656
|
+
get(_target, prop) {
|
|
1657
|
+
throwIfProxyReleased(isProxyReleased);
|
|
1658
|
+
if (prop === releaseProxy) {
|
|
1659
|
+
return () => {
|
|
1660
|
+
unregisterProxy(proxy);
|
|
1661
|
+
releaseEndpoint(ep);
|
|
1662
|
+
pendingListeners.clear();
|
|
1663
|
+
isProxyReleased = true;
|
|
1664
|
+
};
|
|
1665
|
+
}
|
|
1666
|
+
if (prop === "then") {
|
|
1667
|
+
if (path.length === 0) {
|
|
1668
|
+
return { then: () => proxy };
|
|
1669
|
+
}
|
|
1670
|
+
const r = requestResponseMessage(ep, pendingListeners, {
|
|
1671
|
+
type: "GET" /* MessageType.GET */,
|
|
1672
|
+
path: path.map((p) => p.toString()),
|
|
1673
|
+
}).then(fromWireValue);
|
|
1674
|
+
return r.then.bind(r);
|
|
1675
|
+
}
|
|
1676
|
+
return createProxy(ep, pendingListeners, [...path, prop]);
|
|
1677
|
+
},
|
|
1678
|
+
set(_target, prop, rawValue) {
|
|
1679
|
+
throwIfProxyReleased(isProxyReleased);
|
|
1680
|
+
// FIXME: ES6 Proxy Handler `set` methods are supposed to return a
|
|
1681
|
+
// boolean. To show good will, we return true asynchronously ¯\_(ツ)_/¯
|
|
1682
|
+
const [value, transferables] = toWireValue(rawValue);
|
|
1683
|
+
return requestResponseMessage(ep, pendingListeners, {
|
|
1684
|
+
type: "SET" /* MessageType.SET */,
|
|
1685
|
+
path: [...path, prop].map((p) => p.toString()),
|
|
1686
|
+
value,
|
|
1687
|
+
}, transferables).then(fromWireValue);
|
|
1688
|
+
},
|
|
1689
|
+
apply(_target, _thisArg, rawArgumentList) {
|
|
1690
|
+
throwIfProxyReleased(isProxyReleased);
|
|
1691
|
+
const last = path[path.length - 1];
|
|
1692
|
+
if (last === createEndpoint) {
|
|
1693
|
+
return requestResponseMessage(ep, pendingListeners, {
|
|
1694
|
+
type: "ENDPOINT" /* MessageType.ENDPOINT */,
|
|
1695
|
+
}).then(fromWireValue);
|
|
1696
|
+
}
|
|
1697
|
+
// We just pretend that `bind()` didn’t happen.
|
|
1698
|
+
if (last === "bind") {
|
|
1699
|
+
return createProxy(ep, pendingListeners, path.slice(0, -1));
|
|
1700
|
+
}
|
|
1701
|
+
const [argumentList, transferables] = processArguments(rawArgumentList);
|
|
1702
|
+
return requestResponseMessage(ep, pendingListeners, {
|
|
1703
|
+
type: "APPLY" /* MessageType.APPLY */,
|
|
1704
|
+
path: path.map((p) => p.toString()),
|
|
1705
|
+
argumentList,
|
|
1706
|
+
}, transferables).then(fromWireValue);
|
|
1707
|
+
},
|
|
1708
|
+
construct(_target, rawArgumentList) {
|
|
1709
|
+
throwIfProxyReleased(isProxyReleased);
|
|
1710
|
+
const [argumentList, transferables] = processArguments(rawArgumentList);
|
|
1711
|
+
return requestResponseMessage(ep, pendingListeners, {
|
|
1712
|
+
type: "CONSTRUCT" /* MessageType.CONSTRUCT */,
|
|
1713
|
+
path: path.map((p) => p.toString()),
|
|
1714
|
+
argumentList,
|
|
1715
|
+
}, transferables).then(fromWireValue);
|
|
1716
|
+
},
|
|
1717
|
+
});
|
|
1718
|
+
registerProxy(proxy, ep);
|
|
1719
|
+
return proxy;
|
|
1720
|
+
}
|
|
1721
|
+
function myFlat(arr) {
|
|
1722
|
+
return Array.prototype.concat.apply([], arr);
|
|
1677
1723
|
}
|
|
1678
|
-
function
|
|
1679
|
-
|
|
1724
|
+
function processArguments(argumentList) {
|
|
1725
|
+
const processed = argumentList.map(toWireValue);
|
|
1726
|
+
return [processed.map((v) => v[0]), myFlat(processed.map((v) => v[1]))];
|
|
1680
1727
|
}
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
return
|
|
1685
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
1686
|
-
case 0:
|
|
1687
|
-
_removePartialFolder = /*#__PURE__*/function () {
|
|
1688
|
-
var _ref2 = fileAccessSystemUtils_asyncToGenerator(/*#__PURE__*/fileAccessSystemUtils_regeneratorRuntime().mark(function _callee7(dirHandle) {
|
|
1689
|
-
var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _loop, _iterator, _step;
|
|
1690
|
-
return fileAccessSystemUtils_regeneratorRuntime().wrap(function _callee7$(_context8) {
|
|
1691
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
1692
|
-
case 0:
|
|
1693
|
-
// @ts-ignore
|
|
1694
|
-
_iteratorAbruptCompletion = false;
|
|
1695
|
-
_didIteratorError = false;
|
|
1696
|
-
_context8.prev = 2;
|
|
1697
|
-
_loop = /*#__PURE__*/fileAccessSystemUtils_regeneratorRuntime().mark(function _loop() {
|
|
1698
|
-
var _step$value, name, handle;
|
|
1699
|
-
return fileAccessSystemUtils_regeneratorRuntime().wrap(function _loop$(_context7) {
|
|
1700
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
1701
|
-
case 0:
|
|
1702
|
-
_step$value = fileAccessSystemUtils_slicedToArray(_step.value, 2), name = _step$value[0], handle = _step$value[1];
|
|
1703
|
-
if (!(handle.kind === 'directory')) {
|
|
1704
|
-
_context7.next = 9;
|
|
1705
|
-
break;
|
|
1706
|
-
}
|
|
1707
|
-
if (!(name.toLowerCase() === FILE_SYSTEM_ROUTES.Partial)) {
|
|
1708
|
-
_context7.next = 7;
|
|
1709
|
-
break;
|
|
1710
|
-
}
|
|
1711
|
-
_context7.next = 5;
|
|
1712
|
-
return dirHandle.removeEntry(name, {
|
|
1713
|
-
recursive: true
|
|
1714
|
-
})["catch"](function (e) {
|
|
1715
|
-
return console.warn("Failed to remove ".concat(name, ":"), e);
|
|
1716
|
-
});
|
|
1717
|
-
case 5:
|
|
1718
|
-
_context7.next = 9;
|
|
1719
|
-
break;
|
|
1720
|
-
case 7:
|
|
1721
|
-
_context7.next = 9;
|
|
1722
|
-
return _removePartialFolder(handle);
|
|
1723
|
-
case 9:
|
|
1724
|
-
case "end":
|
|
1725
|
-
return _context7.stop();
|
|
1726
|
-
}
|
|
1727
|
-
}, _loop);
|
|
1728
|
-
});
|
|
1729
|
-
_iterator = _asyncIterator(dirHandle.entries());
|
|
1730
|
-
case 5:
|
|
1731
|
-
_context8.next = 7;
|
|
1732
|
-
return _iterator.next();
|
|
1733
|
-
case 7:
|
|
1734
|
-
if (!(_iteratorAbruptCompletion = !(_step = _context8.sent).done)) {
|
|
1735
|
-
_context8.next = 12;
|
|
1736
|
-
break;
|
|
1737
|
-
}
|
|
1738
|
-
return _context8.delegateYield(_loop(), "t0", 9);
|
|
1739
|
-
case 9:
|
|
1740
|
-
_iteratorAbruptCompletion = false;
|
|
1741
|
-
_context8.next = 5;
|
|
1742
|
-
break;
|
|
1743
|
-
case 12:
|
|
1744
|
-
_context8.next = 18;
|
|
1745
|
-
break;
|
|
1746
|
-
case 14:
|
|
1747
|
-
_context8.prev = 14;
|
|
1748
|
-
_context8.t1 = _context8["catch"](2);
|
|
1749
|
-
_didIteratorError = true;
|
|
1750
|
-
_iteratorError = _context8.t1;
|
|
1751
|
-
case 18:
|
|
1752
|
-
_context8.prev = 18;
|
|
1753
|
-
_context8.prev = 19;
|
|
1754
|
-
if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
|
|
1755
|
-
_context8.next = 23;
|
|
1756
|
-
break;
|
|
1757
|
-
}
|
|
1758
|
-
_context8.next = 23;
|
|
1759
|
-
return _iterator["return"]();
|
|
1760
|
-
case 23:
|
|
1761
|
-
_context8.prev = 23;
|
|
1762
|
-
if (!_didIteratorError) {
|
|
1763
|
-
_context8.next = 26;
|
|
1764
|
-
break;
|
|
1765
|
-
}
|
|
1766
|
-
throw _iteratorError;
|
|
1767
|
-
case 26:
|
|
1768
|
-
return _context8.finish(23);
|
|
1769
|
-
case 27:
|
|
1770
|
-
return _context8.finish(18);
|
|
1771
|
-
case 28:
|
|
1772
|
-
case "end":
|
|
1773
|
-
return _context8.stop();
|
|
1774
|
-
}
|
|
1775
|
-
}, _callee7, null, [[2, 14, 18, 28], [19,, 23, 27]]);
|
|
1776
|
-
}));
|
|
1777
|
-
return function removePartialFolder(_x10) {
|
|
1778
|
-
return _ref2.apply(this, arguments);
|
|
1779
|
-
};
|
|
1780
|
-
}();
|
|
1781
|
-
_context9.prev = 1;
|
|
1782
|
-
_context9.next = 4;
|
|
1783
|
-
return _removePartialFolder(directoryHandle);
|
|
1784
|
-
case 4:
|
|
1785
|
-
_context9.next = 9;
|
|
1786
|
-
break;
|
|
1787
|
-
case 6:
|
|
1788
|
-
_context9.prev = 6;
|
|
1789
|
-
_context9.t0 = _context9["catch"](1);
|
|
1790
|
-
console.warn("Error clearing partial files: ".concat(_context9.t0.message));
|
|
1791
|
-
case 9:
|
|
1792
|
-
case "end":
|
|
1793
|
-
return _context9.stop();
|
|
1794
|
-
}
|
|
1795
|
-
}, _callee8, null, [[1, 6]]);
|
|
1796
|
-
}));
|
|
1797
|
-
return _clearPartialFiles.apply(this, arguments);
|
|
1728
|
+
const transferCache = new WeakMap();
|
|
1729
|
+
function transfer(obj, transfers) {
|
|
1730
|
+
transferCache.set(obj, transfers);
|
|
1731
|
+
return obj;
|
|
1798
1732
|
}
|
|
1799
|
-
function
|
|
1800
|
-
|
|
1801
|
-
var bucketPath = urlObj.pathname.match(/\/(.*?)\/studies/)[1];
|
|
1802
|
-
var _urlObj$pathname$matc = urlObj.pathname.match(/studies\/(.*?)(\.tar|\/metadata.json)/)[1].split('/'),
|
|
1803
|
-
_urlObj$pathname$matc2 = fileAccessSystemUtils_slicedToArray(_urlObj$pathname$matc, 3),
|
|
1804
|
-
studyInstanceUID = _urlObj$pathname$matc2[0],
|
|
1805
|
-
_ = _urlObj$pathname$matc2[1],
|
|
1806
|
-
seriesInstanceUID = _urlObj$pathname$matc2[2];
|
|
1807
|
-
return "".concat(bucketPath, "/").concat(studyInstanceUID, "/").concat(seriesInstanceUID);
|
|
1733
|
+
function proxy(obj) {
|
|
1734
|
+
return Object.assign(obj, { [proxyMarker]: true });
|
|
1808
1735
|
}
|
|
1809
|
-
function
|
|
1810
|
-
|
|
1736
|
+
function windowEndpoint(w, context = globalThis, targetOrigin = "*") {
|
|
1737
|
+
return {
|
|
1738
|
+
postMessage: (msg, transferables) => w.postMessage(msg, targetOrigin, transferables),
|
|
1739
|
+
addEventListener: context.addEventListener.bind(context),
|
|
1740
|
+
removeEventListener: context.removeEventListener.bind(context),
|
|
1741
|
+
};
|
|
1811
1742
|
}
|
|
1812
|
-
function
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1743
|
+
function toWireValue(value) {
|
|
1744
|
+
for (const [name, handler] of transferHandlers) {
|
|
1745
|
+
if (handler.canHandle(value)) {
|
|
1746
|
+
const [serializedValue, transferables] = handler.serialize(value);
|
|
1747
|
+
return [
|
|
1748
|
+
{
|
|
1749
|
+
type: "HANDLER" /* WireValueType.HANDLER */,
|
|
1750
|
+
name,
|
|
1751
|
+
value: serializedValue,
|
|
1752
|
+
},
|
|
1753
|
+
transferables,
|
|
1754
|
+
];
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
return [
|
|
1758
|
+
{
|
|
1759
|
+
type: "RAW" /* WireValueType.RAW */,
|
|
1760
|
+
value,
|
|
1761
|
+
},
|
|
1762
|
+
transferCache.get(value) || [],
|
|
1763
|
+
];
|
|
1816
1764
|
}
|
|
1817
|
-
function
|
|
1818
|
-
|
|
1765
|
+
function fromWireValue(value) {
|
|
1766
|
+
switch (value.type) {
|
|
1767
|
+
case "HANDLER" /* WireValueType.HANDLER */:
|
|
1768
|
+
return transferHandlers.get(value.name).deserialize(value.value);
|
|
1769
|
+
case "RAW" /* WireValueType.RAW */:
|
|
1770
|
+
return value.value;
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
function requestResponseMessage(ep, pendingListeners, msg, transfers) {
|
|
1774
|
+
return new Promise((resolve) => {
|
|
1775
|
+
const id = generateUUID();
|
|
1776
|
+
pendingListeners.set(id, resolve);
|
|
1777
|
+
if (ep.start) {
|
|
1778
|
+
ep.start();
|
|
1779
|
+
}
|
|
1780
|
+
ep.postMessage(Object.assign({ id }, msg), transfers);
|
|
1781
|
+
});
|
|
1782
|
+
}
|
|
1783
|
+
function generateUUID() {
|
|
1784
|
+
return new Array(4)
|
|
1785
|
+
.fill(0)
|
|
1786
|
+
.map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16))
|
|
1787
|
+
.join("-");
|
|
1819
1788
|
}
|
|
1820
|
-
;// ./src/metadataManager.ts
|
|
1821
|
-
function metadataManager_typeof(o) { "@babel/helpers - typeof"; return metadataManager_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; }, metadataManager_typeof(o); }
|
|
1822
|
-
function metadataManager_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ metadataManager_regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == metadataManager_typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(metadataManager_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
1823
|
-
function metadataManager_asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
1824
|
-
function metadataManager_asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { metadataManager_asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { metadataManager_asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
1825
|
-
function metadataManager_slicedToArray(r, e) { return metadataManager_arrayWithHoles(r) || metadataManager_iterableToArrayLimit(r, e) || metadataManager_unsupportedIterableToArray(r, e) || metadataManager_nonIterableRest(); }
|
|
1826
|
-
function metadataManager_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."); }
|
|
1827
|
-
function metadataManager_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return metadataManager_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) ? metadataManager_arrayLikeToArray(r, a) : void 0; } }
|
|
1828
|
-
function metadataManager_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; }
|
|
1829
|
-
function metadataManager_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; } }
|
|
1830
|
-
function metadataManager_arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
1831
|
-
function metadataManager_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
1832
|
-
function metadataManager_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, metadataManager_toPropertyKey(o.key), o); } }
|
|
1833
|
-
function metadataManager_createClass(e, r, t) { return r && metadataManager_defineProperties(e.prototype, r), t && metadataManager_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
1834
|
-
function metadataManager_defineProperty(e, r, t) { return (r = metadataManager_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
1835
|
-
function metadataManager_toPropertyKey(t) { var i = metadataManager_toPrimitive(t, "string"); return "symbol" == metadataManager_typeof(i) ? i : i + ""; }
|
|
1836
|
-
function metadataManager_toPrimitive(t, r) { if ("object" != metadataManager_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != metadataManager_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1837
1789
|
|
|
1838
1790
|
|
|
1791
|
+
//# sourceMappingURL=comlink.mjs.map
|
|
1839
1792
|
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1793
|
+
;// ./src/dataRetrieval/workerManager.ts
|
|
1794
|
+
function workerManager_typeof(o) { "@babel/helpers - typeof"; return workerManager_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; }, workerManager_typeof(o); }
|
|
1795
|
+
function workerManager_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ workerManager_regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == workerManager_typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(workerManager_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
1796
|
+
function workerManager_asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
1797
|
+
function workerManager_asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { workerManager_asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { workerManager_asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
1798
|
+
function workerManager_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
1799
|
+
function workerManager_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, workerManager_toPropertyKey(o.key), o); } }
|
|
1800
|
+
function workerManager_createClass(e, r, t) { return r && workerManager_defineProperties(e.prototype, r), t && workerManager_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
1801
|
+
function workerManager_defineProperty(e, r, t) { return (r = workerManager_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
1802
|
+
function workerManager_toPropertyKey(t) { var i = workerManager_toPrimitive(t, "string"); return "symbol" == workerManager_typeof(i) ? i : i + ""; }
|
|
1803
|
+
function workerManager_toPrimitive(t, r) { if ("object" != workerManager_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != workerManager_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1804
|
+
|
|
1805
|
+
|
|
1806
|
+
var WebWorkerManager = /*#__PURE__*/function () {
|
|
1807
|
+
function WebWorkerManager() {
|
|
1808
|
+
workerManager_classCallCheck(this, WebWorkerManager);
|
|
1809
|
+
workerManager_defineProperty(this, "workerRegistry", {});
|
|
1844
1810
|
}
|
|
1845
|
-
return
|
|
1846
|
-
key: "
|
|
1847
|
-
value: function
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
console.warn('Missing required metadata properties: cod, studyUID, or seriesUID');
|
|
1857
|
-
return;
|
|
1858
|
-
}
|
|
1859
|
-
for (var sopUID in cod.instances) {
|
|
1860
|
-
var instance = cod.instances[sopUID];
|
|
1861
|
-
instance.metadata.DeidStudyInstanceUID = {
|
|
1862
|
-
Value: [studyUID]
|
|
1863
|
-
};
|
|
1864
|
-
instance.metadata.DeidSeriesInstanceUID = {
|
|
1865
|
-
Value: [seriesUID]
|
|
1866
|
-
};
|
|
1867
|
-
instance.metadata.DeidSopInstanceUID = {
|
|
1868
|
-
Value: [sopUID]
|
|
1811
|
+
return workerManager_createClass(WebWorkerManager, [{
|
|
1812
|
+
key: "register",
|
|
1813
|
+
value: function register(name, workerFn) {
|
|
1814
|
+
try {
|
|
1815
|
+
var worker = workerFn();
|
|
1816
|
+
if (!worker) {
|
|
1817
|
+
throw new CustomError("WorkerFn of worker ".concat(name, " is not creating a worker"));
|
|
1818
|
+
}
|
|
1819
|
+
this.workerRegistry[name] = {
|
|
1820
|
+
instance: wrap(worker),
|
|
1821
|
+
nativeWorker: worker
|
|
1869
1822
|
};
|
|
1823
|
+
} catch (error) {
|
|
1824
|
+
console.warn(error);
|
|
1870
1825
|
}
|
|
1871
1826
|
}
|
|
1872
1827
|
}, {
|
|
1873
|
-
key: "
|
|
1874
|
-
value: function getMetadataFromCache(url) {
|
|
1875
|
-
return this.metadataPromises[url];
|
|
1876
|
-
}
|
|
1877
|
-
}, {
|
|
1878
|
-
key: "getMetadata",
|
|
1828
|
+
key: "executeTask",
|
|
1879
1829
|
value: function () {
|
|
1880
|
-
var
|
|
1881
|
-
var _this
|
|
1882
|
-
var
|
|
1883
|
-
return
|
|
1830
|
+
var _executeTask = workerManager_asyncToGenerator(/*#__PURE__*/workerManager_regeneratorRuntime().mark(function _callee(workerName, taskName, options) {
|
|
1831
|
+
var _this$workerRegistry$;
|
|
1832
|
+
var worker;
|
|
1833
|
+
return workerManager_regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1884
1834
|
while (1) switch (_context.prev = _context.next) {
|
|
1885
1835
|
case 0:
|
|
1886
|
-
|
|
1887
|
-
if (
|
|
1836
|
+
worker = (_this$workerRegistry$ = this.workerRegistry[workerName]) === null || _this$workerRegistry$ === void 0 ? void 0 : _this$workerRegistry$.instance;
|
|
1837
|
+
if (worker) {
|
|
1888
1838
|
_context.next = 3;
|
|
1889
1839
|
break;
|
|
1890
1840
|
}
|
|
1891
|
-
throw new CustomError(
|
|
1841
|
+
throw new CustomError("Worker ".concat(workerName, " not registered"));
|
|
1892
1842
|
case 3:
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
}
|
|
1898
|
-
_context.next = 7;
|
|
1899
|
-
return cachedMetadata;
|
|
1900
|
-
case 7:
|
|
1843
|
+
_context.prev = 3;
|
|
1844
|
+
_context.next = 6;
|
|
1845
|
+
return worker[taskName](options);
|
|
1846
|
+
case 6:
|
|
1901
1847
|
return _context.abrupt("return", _context.sent);
|
|
1902
|
-
case
|
|
1903
|
-
_context.
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
return
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1848
|
+
case 9:
|
|
1849
|
+
_context.prev = 9;
|
|
1850
|
+
_context.t0 = _context["catch"](3);
|
|
1851
|
+
console.error("Error executing task \"".concat(taskName, "\" on worker \"").concat(workerName, "\":"), _context.t0);
|
|
1852
|
+
throw new CustomError("Task \"".concat(taskName, "\" failed: ").concat(_context.t0.message));
|
|
1853
|
+
case 13:
|
|
1854
|
+
case "end":
|
|
1855
|
+
return _context.stop();
|
|
1856
|
+
}
|
|
1857
|
+
}, _callee, this, [[3, 9]]);
|
|
1858
|
+
}));
|
|
1859
|
+
function executeTask(_x, _x2, _x3) {
|
|
1860
|
+
return _executeTask.apply(this, arguments);
|
|
1861
|
+
}
|
|
1862
|
+
return executeTask;
|
|
1863
|
+
}()
|
|
1864
|
+
}, {
|
|
1865
|
+
key: "addEventListener",
|
|
1866
|
+
value: function addEventListener(workerName, eventType, listener) {
|
|
1867
|
+
var worker = this.workerRegistry[workerName];
|
|
1868
|
+
if (!worker) {
|
|
1869
|
+
console.error("Worker type '".concat(workerName, "' is not registered."));
|
|
1870
|
+
return;
|
|
1871
|
+
}
|
|
1872
|
+
worker.nativeWorker.addEventListener(eventType, listener);
|
|
1873
|
+
}
|
|
1874
|
+
}, {
|
|
1875
|
+
key: "removeEventListener",
|
|
1876
|
+
value: function removeEventListener(workerName, eventType, listener) {
|
|
1877
|
+
var worker = this.workerRegistry[workerName];
|
|
1878
|
+
if (!worker) {
|
|
1879
|
+
console.error("Worker type '".concat(workerName, "' is not registered."));
|
|
1880
|
+
return;
|
|
1881
|
+
}
|
|
1882
|
+
worker.nativeWorker.removeEventListener(eventType, listener);
|
|
1883
|
+
}
|
|
1884
|
+
}, {
|
|
1885
|
+
key: "reset",
|
|
1886
|
+
value: function reset() {
|
|
1887
|
+
this.workerRegistry = {};
|
|
1888
|
+
}
|
|
1889
|
+
}]);
|
|
1890
|
+
}();
|
|
1891
|
+
/* harmony default export */ const workerManager = (WebWorkerManager);
|
|
1892
|
+
;// ./src/dataRetrieval/dataRetrievalManager.ts
|
|
1893
|
+
function dataRetrievalManager_typeof(o) { "@babel/helpers - typeof"; return dataRetrievalManager_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; }, dataRetrievalManager_typeof(o); }
|
|
1894
|
+
function dataRetrievalManager_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ dataRetrievalManager_regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == dataRetrievalManager_typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(dataRetrievalManager_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
1895
|
+
function dataRetrievalManager_asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
1896
|
+
function dataRetrievalManager_asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { dataRetrievalManager_asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { dataRetrievalManager_asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
1897
|
+
function dataRetrievalManager_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
1898
|
+
function dataRetrievalManager_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, dataRetrievalManager_toPropertyKey(o.key), o); } }
|
|
1899
|
+
function dataRetrievalManager_createClass(e, r, t) { return r && dataRetrievalManager_defineProperties(e.prototype, r), t && dataRetrievalManager_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
1900
|
+
function dataRetrievalManager_defineProperty(e, r, t) { return (r = dataRetrievalManager_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
1901
|
+
function dataRetrievalManager_toPropertyKey(t) { var i = dataRetrievalManager_toPrimitive(t, "string"); return "symbol" == dataRetrievalManager_typeof(i) ? i : i + ""; }
|
|
1902
|
+
function dataRetrievalManager_toPrimitive(t, r) { if ("object" != dataRetrievalManager_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != dataRetrievalManager_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1903
|
+
|
|
1904
|
+
|
|
1905
|
+
|
|
1906
|
+
|
|
1907
|
+
|
|
1908
|
+
var DataRetrievalManager = /*#__PURE__*/function () {
|
|
1909
|
+
function DataRetrievalManager() {
|
|
1910
|
+
dataRetrievalManager_classCallCheck(this, DataRetrievalManager);
|
|
1911
|
+
dataRetrievalManager_defineProperty(this, "dataRetriever", void 0);
|
|
1912
|
+
dataRetrievalManager_defineProperty(this, "dataRetrieverMode", void 0);
|
|
1913
|
+
if (isNodeEnvironment()) {
|
|
1914
|
+
this.dataRetriever = new requestManager();
|
|
1915
|
+
this.dataRetrieverMode = DataRetrieveMode.REQUEST;
|
|
1916
|
+
} else {
|
|
1917
|
+
this.dataRetriever = new workerManager();
|
|
1918
|
+
this.dataRetrieverMode = DataRetrieveMode.WORKER;
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
return dataRetrievalManager_createClass(DataRetrievalManager, [{
|
|
1922
|
+
key: "getDataRetrieverMode",
|
|
1923
|
+
value: function getDataRetrieverMode() {
|
|
1924
|
+
return this.dataRetrieverMode;
|
|
1925
|
+
}
|
|
1926
|
+
}, {
|
|
1927
|
+
key: "setDataRetrieverMode",
|
|
1928
|
+
value: function setDataRetrieverMode(mode) {
|
|
1929
|
+
var managers = dataRetrievalManager_defineProperty(dataRetrievalManager_defineProperty({}, DataRetrieveMode.WORKER, workerManager), DataRetrieveMode.REQUEST, requestManager);
|
|
1930
|
+
if (!(mode in managers)) {
|
|
1931
|
+
throw new CustomError('Invalid mode');
|
|
1932
|
+
}
|
|
1933
|
+
this.dataRetriever.reset();
|
|
1934
|
+
this.dataRetriever = new managers[mode]();
|
|
1935
|
+
this.dataRetrieverMode = mode;
|
|
1936
|
+
}
|
|
1937
|
+
}, {
|
|
1938
|
+
key: "register",
|
|
1939
|
+
value: function register(name, arg) {
|
|
1940
|
+
// @ts-ignore
|
|
1941
|
+
this.dataRetriever.register(name, arg);
|
|
1942
|
+
}
|
|
1943
|
+
}, {
|
|
1944
|
+
key: "executeTask",
|
|
1945
|
+
value: function () {
|
|
1946
|
+
var _executeTask = dataRetrievalManager_asyncToGenerator(/*#__PURE__*/dataRetrievalManager_regeneratorRuntime().mark(function _callee(loaderName, taskName, options) {
|
|
1947
|
+
return dataRetrievalManager_regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1948
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1949
|
+
case 0:
|
|
1950
|
+
_context.next = 2;
|
|
1951
|
+
return this.dataRetriever.executeTask(loaderName, taskName, options);
|
|
1952
|
+
case 2:
|
|
1937
1953
|
return _context.abrupt("return", _context.sent);
|
|
1938
|
-
case
|
|
1939
|
-
_context.prev = 24;
|
|
1940
|
-
_context.t0 = _context["catch"](17);
|
|
1941
|
-
console.error(_context.t0);
|
|
1942
|
-
throw _context.t0;
|
|
1943
|
-
case 28:
|
|
1954
|
+
case 3:
|
|
1944
1955
|
case "end":
|
|
1945
1956
|
return _context.stop();
|
|
1946
1957
|
}
|
|
1947
|
-
}, _callee, this
|
|
1958
|
+
}, _callee, this);
|
|
1948
1959
|
}));
|
|
1949
|
-
function
|
|
1950
|
-
return
|
|
1960
|
+
function executeTask(_x, _x2, _x3) {
|
|
1961
|
+
return _executeTask.apply(this, arguments);
|
|
1951
1962
|
}
|
|
1952
|
-
return
|
|
1963
|
+
return executeTask;
|
|
1953
1964
|
}()
|
|
1965
|
+
}, {
|
|
1966
|
+
key: "addEventListener",
|
|
1967
|
+
value: function addEventListener(workerName, eventType, listener) {
|
|
1968
|
+
this.dataRetriever.addEventListener(workerName, eventType, listener);
|
|
1969
|
+
}
|
|
1970
|
+
}, {
|
|
1971
|
+
key: "removeEventListener",
|
|
1972
|
+
value: function removeEventListener(workerName, eventType, listener) {
|
|
1973
|
+
this.dataRetriever.removeEventListener(workerName, eventType, listener);
|
|
1974
|
+
}
|
|
1975
|
+
}, {
|
|
1976
|
+
key: "reset",
|
|
1977
|
+
value: function reset() {
|
|
1978
|
+
this.dataRetriever.reset();
|
|
1979
|
+
}
|
|
1954
1980
|
}]);
|
|
1955
1981
|
}();
|
|
1956
|
-
|
|
1982
|
+
var dataRetrievalManager = new DataRetrievalManager();
|
|
1983
|
+
Object.freeze(dataRetrievalManager);
|
|
1984
|
+
function getDataRetrievalManager() {
|
|
1985
|
+
return dataRetrievalManager;
|
|
1986
|
+
}
|
|
1957
1987
|
;// ./src/dataRetrieval/scripts/filePartial.ts
|
|
1958
1988
|
function filePartial_typeof(o) { "@babel/helpers - typeof"; return filePartial_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; }, filePartial_typeof(o); }
|
|
1959
1989
|
function filePartial_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ filePartial_regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == filePartial_typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(filePartial_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
@@ -1964,7 +1994,7 @@ function filePartial_asyncToGenerator(n) { return function () { var t = this, e
|
|
|
1964
1994
|
var filePartial = {
|
|
1965
1995
|
partial: function partial(args, callBack) {
|
|
1966
1996
|
return filePartial_asyncToGenerator(/*#__PURE__*/filePartial_regeneratorRuntime().mark(function _callee() {
|
|
1967
|
-
var url, offsets, headers, directoryHandle, storageName, file;
|
|
1997
|
+
var url, offsets, headers, directoryHandle, storageName, file, fileBuffer;
|
|
1968
1998
|
return filePartial_regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1969
1999
|
while (1) switch (_context.prev = _context.next) {
|
|
1970
2000
|
case 0:
|
|
@@ -1974,7 +2004,7 @@ var filePartial = {
|
|
|
1974
2004
|
}
|
|
1975
2005
|
storageName = createPartialFileName(url, offsets);
|
|
1976
2006
|
if (!directoryHandle) {
|
|
1977
|
-
_context.next =
|
|
2007
|
+
_context.next = 11;
|
|
1978
2008
|
break;
|
|
1979
2009
|
}
|
|
1980
2010
|
_context.next = 6;
|
|
@@ -1985,34 +2015,39 @@ var filePartial = {
|
|
|
1985
2015
|
case 6:
|
|
1986
2016
|
file = _context.sent;
|
|
1987
2017
|
if (!file) {
|
|
1988
|
-
_context.next =
|
|
2018
|
+
_context.next = 11;
|
|
1989
2019
|
break;
|
|
1990
2020
|
}
|
|
2021
|
+
fileBuffer = new Uint8Array(file);
|
|
1991
2022
|
callBack({
|
|
1992
2023
|
url: url,
|
|
1993
|
-
fileArraybuffer:
|
|
2024
|
+
fileArraybuffer: fileBuffer,
|
|
1994
2025
|
offsets: offsets
|
|
1995
2026
|
});
|
|
1996
|
-
return _context.abrupt("return");
|
|
1997
|
-
case
|
|
1998
|
-
_context.next =
|
|
2027
|
+
return _context.abrupt("return", fileBuffer);
|
|
2028
|
+
case 11:
|
|
2029
|
+
_context.next = 13;
|
|
1999
2030
|
return fetch(url, {
|
|
2000
2031
|
headers: headers
|
|
2001
2032
|
}).then(function (response) {
|
|
2002
2033
|
return response.arrayBuffer();
|
|
2003
2034
|
}).then(function (data) {
|
|
2035
|
+
var fileBuffer = new Uint8Array(data);
|
|
2004
2036
|
callBack({
|
|
2005
2037
|
url: url,
|
|
2006
|
-
fileArraybuffer:
|
|
2038
|
+
fileArraybuffer: fileBuffer,
|
|
2007
2039
|
offsets: offsets
|
|
2008
2040
|
});
|
|
2009
2041
|
if (directoryHandle) {
|
|
2010
2042
|
writeFile(directoryHandle, storageName, data);
|
|
2011
2043
|
}
|
|
2044
|
+
return fileBuffer;
|
|
2012
2045
|
})["catch"](function (error) {
|
|
2013
2046
|
throw new CustomError('filePartial.ts: Error when fetching file: ' + (error === null || error === void 0 ? void 0 : error.message));
|
|
2014
2047
|
});
|
|
2015
|
-
case
|
|
2048
|
+
case 13:
|
|
2049
|
+
return _context.abrupt("return", _context.sent);
|
|
2050
|
+
case 14:
|
|
2016
2051
|
case "end":
|
|
2017
2052
|
return _context.stop();
|
|
2018
2053
|
}
|
|
@@ -2024,8 +2059,8 @@ var filePartial = {
|
|
|
2024
2059
|
;// ./src/dataRetrieval/scripts/fileStreaming.ts
|
|
2025
2060
|
function fileStreaming_typeof(o) { "@babel/helpers - typeof"; return fileStreaming_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; }, fileStreaming_typeof(o); }
|
|
2026
2061
|
function fileStreaming_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ fileStreaming_regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == fileStreaming_typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(fileStreaming_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
2027
|
-
function
|
|
2028
|
-
function
|
|
2062
|
+
function fileStreaming_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; }
|
|
2063
|
+
function fileStreaming_objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? fileStreaming_ownKeys(Object(t), !0).forEach(function (r) { fileStreaming_defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : fileStreaming_ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2029
2064
|
function fileStreaming_defineProperty(e, r, t) { return (r = fileStreaming_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2030
2065
|
function fileStreaming_toPropertyKey(t) { var i = fileStreaming_toPrimitive(t, "string"); return "symbol" == fileStreaming_typeof(i) ? i : i + ""; }
|
|
2031
2066
|
function fileStreaming_toPrimitive(t, r) { if ("object" != fileStreaming_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != fileStreaming_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
@@ -2034,23 +2069,9 @@ function fileStreaming_asyncToGenerator(n) { return function () { var t = this,
|
|
|
2034
2069
|
|
|
2035
2070
|
|
|
2036
2071
|
var fileStreaming = {
|
|
2037
|
-
maxFetchSize: 4 * 1024 * 1024 * 1024,
|
|
2038
|
-
// 4GB
|
|
2039
|
-
fetchedSize: 0,
|
|
2040
|
-
setMaxFetchSize: function setMaxFetchSize(size) {
|
|
2041
|
-
if (size > 0) {
|
|
2042
|
-
this.maxFetchSize = size;
|
|
2043
|
-
}
|
|
2044
|
-
},
|
|
2045
|
-
decreaseFetchedSize: function decreaseFetchedSize(size) {
|
|
2046
|
-
if (size > 0 && size <= this.fetchedSize) {
|
|
2047
|
-
this.fetchedSize -= size;
|
|
2048
|
-
}
|
|
2049
|
-
},
|
|
2050
2072
|
stream: function stream(args, callBack) {
|
|
2051
|
-
var _this = this;
|
|
2052
2073
|
return fileStreaming_asyncToGenerator(/*#__PURE__*/fileStreaming_regeneratorRuntime().mark(function _callee() {
|
|
2053
|
-
var url, headers, useSharedArrayBuffer, directoryHandle, controller, sharedArraybuffer, fileArraybuffer, _response$body, fileName, file, response, reader, result, completed, totalLength, firstChunk, position, chunk, streamingError;
|
|
2074
|
+
var url, headers, useSharedArrayBuffer, directoryHandle, controller, sharedArraybuffer, fileArraybuffer, _response$body, fileName, file, _totalLength, fileBuffer, response, reader, result, completed, totalLength, firstChunk, position, chunk, streamingError;
|
|
2054
2075
|
return fileStreaming_regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2055
2076
|
while (1) switch (_context.prev = _context.next) {
|
|
2056
2077
|
case 0:
|
|
@@ -2061,7 +2082,7 @@ var fileStreaming = {
|
|
|
2061
2082
|
_context.prev = 4;
|
|
2062
2083
|
fileName = createStreamingFileName(url);
|
|
2063
2084
|
if (!directoryHandle) {
|
|
2064
|
-
_context.next =
|
|
2085
|
+
_context.next = 15;
|
|
2065
2086
|
break;
|
|
2066
2087
|
}
|
|
2067
2088
|
_context.next = 9;
|
|
@@ -2071,62 +2092,57 @@ var fileStreaming = {
|
|
|
2071
2092
|
case 9:
|
|
2072
2093
|
file = _context.sent;
|
|
2073
2094
|
if (!file) {
|
|
2074
|
-
_context.next =
|
|
2095
|
+
_context.next = 15;
|
|
2075
2096
|
break;
|
|
2076
2097
|
}
|
|
2098
|
+
_totalLength = file.byteLength;
|
|
2099
|
+
fileBuffer = new Uint8Array(file);
|
|
2077
2100
|
callBack({
|
|
2078
2101
|
url: url,
|
|
2079
|
-
position:
|
|
2080
|
-
fileArraybuffer:
|
|
2102
|
+
position: _totalLength,
|
|
2103
|
+
fileArraybuffer: fileBuffer,
|
|
2104
|
+
totalLength: _totalLength
|
|
2081
2105
|
});
|
|
2082
|
-
return _context.abrupt("return");
|
|
2083
|
-
case
|
|
2084
|
-
_context.next =
|
|
2106
|
+
return _context.abrupt("return", fileBuffer);
|
|
2107
|
+
case 15:
|
|
2108
|
+
_context.next = 17;
|
|
2085
2109
|
return fetch(url, {
|
|
2086
|
-
headers:
|
|
2110
|
+
headers: fileStreaming_objectSpread({}, headers),
|
|
2087
2111
|
signal: controller.signal
|
|
2088
2112
|
});
|
|
2089
|
-
case
|
|
2113
|
+
case 17:
|
|
2090
2114
|
response = _context.sent;
|
|
2091
2115
|
if (response.ok) {
|
|
2092
|
-
_context.next =
|
|
2116
|
+
_context.next = 20;
|
|
2093
2117
|
break;
|
|
2094
2118
|
}
|
|
2095
2119
|
throw new CustomError("HTTP error! status: ".concat(response.status));
|
|
2096
|
-
case
|
|
2120
|
+
case 20:
|
|
2097
2121
|
reader = (_response$body = response.body) === null || _response$body === void 0 ? void 0 : _response$body.getReader();
|
|
2098
2122
|
if (reader) {
|
|
2099
|
-
_context.next =
|
|
2123
|
+
_context.next = 23;
|
|
2100
2124
|
break;
|
|
2101
2125
|
}
|
|
2102
2126
|
throw new CustomError('Failed to get reader from response body');
|
|
2103
|
-
case
|
|
2127
|
+
case 23:
|
|
2104
2128
|
completed = false;
|
|
2105
2129
|
totalLength = parseInt(response.headers.get('Content-Length') || '0', 10);
|
|
2106
|
-
_context.next =
|
|
2130
|
+
_context.next = 27;
|
|
2107
2131
|
return reader.read();
|
|
2108
|
-
case
|
|
2132
|
+
case 27:
|
|
2109
2133
|
firstChunk = _context.sent;
|
|
2110
2134
|
completed = firstChunk.done;
|
|
2111
2135
|
if (firstChunk.value) {
|
|
2112
|
-
_context.next =
|
|
2136
|
+
_context.next = 31;
|
|
2113
2137
|
break;
|
|
2114
2138
|
}
|
|
2115
2139
|
throw new CustomError('The fetched chunks does not have value');
|
|
2116
|
-
case
|
|
2140
|
+
case 31:
|
|
2117
2141
|
if (completed) {
|
|
2118
|
-
_context.next =
|
|
2142
|
+
_context.next = 50;
|
|
2119
2143
|
break;
|
|
2120
2144
|
}
|
|
2121
2145
|
position = firstChunk.value.length;
|
|
2122
|
-
if (!(_this.fetchedSize + position > _this.maxFetchSize)) {
|
|
2123
|
-
_context.next = 34;
|
|
2124
|
-
break;
|
|
2125
|
-
}
|
|
2126
|
-
controller.abort();
|
|
2127
|
-
throw new CustomError("Maximum size(".concat(_this.maxFetchSize, ") for fetching files reached"));
|
|
2128
|
-
case 34:
|
|
2129
|
-
_this.fetchedSize += position;
|
|
2130
2146
|
if (useSharedArrayBuffer) {
|
|
2131
2147
|
sharedArraybuffer = new SharedArrayBuffer(totalLength);
|
|
2132
2148
|
fileArraybuffer = new Uint8Array(sharedArraybuffer);
|
|
@@ -2137,69 +2153,60 @@ var fileStreaming = {
|
|
|
2137
2153
|
callBack({
|
|
2138
2154
|
url: url,
|
|
2139
2155
|
position: position,
|
|
2140
|
-
fileArraybuffer: fileArraybuffer
|
|
2156
|
+
fileArraybuffer: fileArraybuffer,
|
|
2157
|
+
totalLength: totalLength
|
|
2141
2158
|
});
|
|
2142
|
-
case
|
|
2159
|
+
case 36:
|
|
2143
2160
|
if (completed) {
|
|
2144
|
-
_context.next =
|
|
2161
|
+
_context.next = 49;
|
|
2145
2162
|
break;
|
|
2146
2163
|
}
|
|
2147
|
-
_context.next =
|
|
2164
|
+
_context.next = 39;
|
|
2148
2165
|
return reader.read();
|
|
2149
|
-
case
|
|
2166
|
+
case 39:
|
|
2150
2167
|
result = _context.sent;
|
|
2151
2168
|
if (!result.done) {
|
|
2152
|
-
_context.next =
|
|
2169
|
+
_context.next = 43;
|
|
2153
2170
|
break;
|
|
2154
2171
|
}
|
|
2155
2172
|
completed = true;
|
|
2156
|
-
return _context.abrupt("continue",
|
|
2157
|
-
case
|
|
2173
|
+
return _context.abrupt("continue", 36);
|
|
2174
|
+
case 43:
|
|
2158
2175
|
chunk = result.value;
|
|
2159
|
-
if (!(_this.fetchedSize + chunk.length > _this.maxFetchSize)) {
|
|
2160
|
-
_context.next = 51;
|
|
2161
|
-
break;
|
|
2162
|
-
}
|
|
2163
|
-
sharedArraybuffer = null;
|
|
2164
|
-
fileArraybuffer = null;
|
|
2165
|
-
controller.abort();
|
|
2166
|
-
throw new CustomError("Maximum size(".concat(_this.maxFetchSize, ") for fetching files reached"));
|
|
2167
|
-
case 51:
|
|
2168
|
-
_this.fetchedSize += chunk.length;
|
|
2169
2176
|
fileArraybuffer.set(chunk, position);
|
|
2170
2177
|
position += chunk.length;
|
|
2171
2178
|
callBack({
|
|
2172
2179
|
isAppending: true,
|
|
2173
2180
|
url: url,
|
|
2174
2181
|
position: position,
|
|
2175
|
-
chunk: !useSharedArrayBuffer ? chunk : undefined
|
|
2182
|
+
chunk: !useSharedArrayBuffer ? chunk : undefined,
|
|
2183
|
+
totalLength: totalLength
|
|
2176
2184
|
});
|
|
2177
|
-
_context.next =
|
|
2185
|
+
_context.next = 36;
|
|
2178
2186
|
break;
|
|
2179
|
-
case
|
|
2187
|
+
case 49:
|
|
2180
2188
|
if (directoryHandle) {
|
|
2181
2189
|
writeFile(directoryHandle, fileName, fileArraybuffer.slice().buffer);
|
|
2182
2190
|
}
|
|
2183
|
-
case
|
|
2184
|
-
_context.
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
_context.prev = 60;
|
|
2191
|
+
case 50:
|
|
2192
|
+
return _context.abrupt("return", fileArraybuffer);
|
|
2193
|
+
case 53:
|
|
2194
|
+
_context.prev = 53;
|
|
2188
2195
|
_context.t0 = _context["catch"](4);
|
|
2189
2196
|
streamingError = new CustomError('fileStreaming.ts: ' + _context.t0.message || 0);
|
|
2190
2197
|
console.error(streamingError.message, _context.t0);
|
|
2191
2198
|
throw streamingError;
|
|
2192
|
-
case
|
|
2193
|
-
_context.prev =
|
|
2199
|
+
case 58:
|
|
2200
|
+
_context.prev = 58;
|
|
2194
2201
|
sharedArraybuffer = null;
|
|
2195
2202
|
fileArraybuffer = null;
|
|
2196
2203
|
controller.abort();
|
|
2197
|
-
return _context.finish(
|
|
2198
|
-
case
|
|
2204
|
+
return _context.finish(58);
|
|
2205
|
+
case 63:
|
|
2199
2206
|
case "end":
|
|
2200
2207
|
return _context.stop();
|
|
2201
2208
|
}
|
|
2202
|
-
}, _callee, null, [[4,
|
|
2209
|
+
}, _callee, null, [[4, 53, 58, 63]]);
|
|
2203
2210
|
}))();
|
|
2204
2211
|
}
|
|
2205
2212
|
};
|
|
@@ -2209,7 +2216,7 @@ var fileStreaming = {
|
|
|
2209
2216
|
|
|
2210
2217
|
|
|
2211
2218
|
|
|
2212
|
-
function register(workerNames
|
|
2219
|
+
function register(workerNames) {
|
|
2213
2220
|
var fileStreamingScriptName = workerNames.fileStreamingScriptName,
|
|
2214
2221
|
filePartialScriptName = workerNames.filePartialScriptName;
|
|
2215
2222
|
var dataRetrievalManager = getDataRetrievalManager();
|
|
@@ -2233,7 +2240,6 @@ function register(workerNames, maxFetchSize) {
|
|
|
2233
2240
|
};
|
|
2234
2241
|
dataRetrievalManager.register(filePartialScriptName, partialWorkerFn);
|
|
2235
2242
|
}
|
|
2236
|
-
dataRetrievalManager.executeTask(fileStreamingScriptName, 'setMaxFetchSize', maxFetchSize);
|
|
2237
2243
|
}
|
|
2238
2244
|
;// ./src/classes/CodDicomWebServer.ts
|
|
2239
2245
|
function CodDicomWebServer_typeof(o) { "@babel/helpers - typeof"; return CodDicomWebServer_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; }, CodDicomWebServer_typeof(o); }
|
|
@@ -2268,8 +2274,10 @@ var CodDicomWebServer = /*#__PURE__*/function () {
|
|
|
2268
2274
|
var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2269
2275
|
CodDicomWebServer_classCallCheck(this, CodDicomWebServer);
|
|
2270
2276
|
CodDicomWebServer_defineProperty(this, "filePromises", {});
|
|
2277
|
+
CodDicomWebServer_defineProperty(this, "files", {});
|
|
2271
2278
|
CodDicomWebServer_defineProperty(this, "options", {
|
|
2272
|
-
|
|
2279
|
+
maxCacheSize: 4 * 1024 * 1024 * 1024,
|
|
2280
|
+
// 4GB
|
|
2273
2281
|
domain: src_constants.url.DOMAIN,
|
|
2274
2282
|
enableLocalCache: false
|
|
2275
2283
|
});
|
|
@@ -2286,18 +2294,16 @@ var CodDicomWebServer = /*#__PURE__*/function () {
|
|
|
2286
2294
|
CodDicomWebServer_defineProperty(this, "getOptions", function () {
|
|
2287
2295
|
return _this.options;
|
|
2288
2296
|
});
|
|
2289
|
-
var
|
|
2297
|
+
var maxCacheSize = args.maxCacheSize,
|
|
2290
2298
|
domain = args.domain,
|
|
2291
2299
|
disableWorker = args.disableWorker,
|
|
2292
2300
|
enableLocalCache = args.enableLocalCache;
|
|
2293
|
-
this.options.
|
|
2301
|
+
this.options.maxCacheSize = maxCacheSize || this.options.maxCacheSize;
|
|
2294
2302
|
this.options.domain = domain || this.options.domain;
|
|
2295
2303
|
this.options.enableLocalCache = !!enableLocalCache;
|
|
2296
2304
|
var fileStreamingScriptName = src_constants.dataRetrieval.FILE_STREAMING_WORKER_NAME;
|
|
2297
2305
|
var filePartialScriptName = src_constants.dataRetrieval.FILE_PARTIAL_WORKER_NAME;
|
|
2298
|
-
this.fileManager = new fileManager(
|
|
2299
|
-
fileStreamingScriptName: fileStreamingScriptName
|
|
2300
|
-
});
|
|
2306
|
+
this.fileManager = new fileManager();
|
|
2301
2307
|
this.metadataManager = new metadataManager();
|
|
2302
2308
|
if (disableWorker) {
|
|
2303
2309
|
var dataRetrievalManager = getDataRetrievalManager();
|
|
@@ -2306,7 +2312,7 @@ var CodDicomWebServer = /*#__PURE__*/function () {
|
|
|
2306
2312
|
register({
|
|
2307
2313
|
fileStreamingScriptName: fileStreamingScriptName,
|
|
2308
2314
|
filePartialScriptName: filePartialScriptName
|
|
2309
|
-
}
|
|
2315
|
+
});
|
|
2310
2316
|
}
|
|
2311
2317
|
return CodDicomWebServer_createClass(CodDicomWebServer, [{
|
|
2312
2318
|
key: "addFileUrl",
|
|
@@ -2505,13 +2511,10 @@ var CodDicomWebServer = /*#__PURE__*/function () {
|
|
|
2505
2511
|
isBytesOptimized,
|
|
2506
2512
|
extractedFile,
|
|
2507
2513
|
directoryHandle,
|
|
2508
|
-
_this$getOptions,
|
|
2509
|
-
maxWorkerFetchSize,
|
|
2510
2514
|
dataRetrievalManager,
|
|
2511
2515
|
_constants$dataRetrie,
|
|
2512
2516
|
FILE_STREAMING_WORKER_NAME,
|
|
2513
2517
|
FILE_PARTIAL_WORKER_NAME,
|
|
2514
|
-
THRESHOLD,
|
|
2515
2518
|
tarPromise,
|
|
2516
2519
|
_args2 = arguments;
|
|
2517
2520
|
return CodDicomWebServer_regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
@@ -2543,14 +2546,10 @@ var CodDicomWebServer = /*#__PURE__*/function () {
|
|
|
2543
2546
|
_context2.t0 = _context2.sent;
|
|
2544
2547
|
case 10:
|
|
2545
2548
|
directoryHandle = _context2.t0;
|
|
2546
|
-
_this$getOptions = this.getOptions(), maxWorkerFetchSize = _this$getOptions.maxWorkerFetchSize;
|
|
2547
2549
|
dataRetrievalManager = getDataRetrievalManager();
|
|
2548
|
-
_constants$dataRetrie = src_constants.dataRetrieval, FILE_STREAMING_WORKER_NAME = _constants$dataRetrie.FILE_STREAMING_WORKER_NAME, FILE_PARTIAL_WORKER_NAME = _constants$dataRetrie.FILE_PARTIAL_WORKER_NAME
|
|
2550
|
+
_constants$dataRetrie = src_constants.dataRetrieval, FILE_STREAMING_WORKER_NAME = _constants$dataRetrie.FILE_STREAMING_WORKER_NAME, FILE_PARTIAL_WORKER_NAME = _constants$dataRetrie.FILE_PARTIAL_WORKER_NAME;
|
|
2549
2551
|
if (!this.filePromises[fileUrl]) {
|
|
2550
2552
|
tarPromise = new Promise(function (resolveFile, rejectFile) {
|
|
2551
|
-
if (_this3.fileManager.getTotalSize() + THRESHOLD > maxWorkerFetchSize) {
|
|
2552
|
-
throw new CustomError("CodDicomWebServer.ts: Maximum size(".concat(maxWorkerFetchSize, ") for fetching files reached"));
|
|
2553
|
-
}
|
|
2554
2553
|
var FetchTypeEnum = src_constants.Enums.FetchType;
|
|
2555
2554
|
if (fetchType === FetchTypeEnum.API_OPTIMIZED) {
|
|
2556
2555
|
var _handleFirstChunk = function handleFirstChunk(evt) {
|
|
@@ -2563,10 +2562,14 @@ var CodDicomWebServer = /*#__PURE__*/function () {
|
|
|
2563
2562
|
position = _evt$data.position,
|
|
2564
2563
|
fileArraybuffer = _evt$data.fileArraybuffer;
|
|
2565
2564
|
if (url === fileUrl && fileArraybuffer) {
|
|
2566
|
-
_this3.
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2565
|
+
if (_this3.options.enableLocalCache) {
|
|
2566
|
+
_this3.files[fileUrl] = fileArraybuffer;
|
|
2567
|
+
} else {
|
|
2568
|
+
_this3.fileManager.set(url, {
|
|
2569
|
+
data: fileArraybuffer,
|
|
2570
|
+
position: position
|
|
2571
|
+
});
|
|
2572
|
+
}
|
|
2570
2573
|
dataRetrievalManager.removeEventListener(FILE_STREAMING_WORKER_NAME, 'message', _handleFirstChunk);
|
|
2571
2574
|
}
|
|
2572
2575
|
};
|
|
@@ -2582,7 +2585,6 @@ var CodDicomWebServer = /*#__PURE__*/function () {
|
|
|
2582
2585
|
rejectFile(error);
|
|
2583
2586
|
}).then(function () {
|
|
2584
2587
|
dataRetrievalManager.removeEventListener(FILE_STREAMING_WORKER_NAME, 'message', _handleFirstChunk);
|
|
2585
|
-
delete _this3.filePromises[fileUrl];
|
|
2586
2588
|
});
|
|
2587
2589
|
} else if (fetchType === FetchTypeEnum.BYTES_OPTIMIZED && offsets) {
|
|
2588
2590
|
var startByte = offsets.startByte,
|
|
@@ -2598,10 +2600,14 @@ var CodDicomWebServer = /*#__PURE__*/function () {
|
|
|
2598
2600
|
fileArraybuffer = _evt$data2.fileArraybuffer,
|
|
2599
2601
|
offsets = _evt$data2.offsets;
|
|
2600
2602
|
if (url === bytesRemovedUrl && offsets.startByte === startByte && offsets.endByte === endByte) {
|
|
2601
|
-
_this3.
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2603
|
+
if (_this3.options.enableLocalCache) {
|
|
2604
|
+
_this3.files[fileUrl] = fileArraybuffer;
|
|
2605
|
+
} else {
|
|
2606
|
+
_this3.fileManager.set(fileUrl, {
|
|
2607
|
+
data: fileArraybuffer,
|
|
2608
|
+
position: fileArraybuffer.length
|
|
2609
|
+
});
|
|
2610
|
+
}
|
|
2605
2611
|
dataRetrievalManager.removeEventListener(FILE_PARTIAL_WORKER_NAME, 'message', _handleSlice);
|
|
2606
2612
|
resolveFile();
|
|
2607
2613
|
}
|
|
@@ -2619,18 +2625,22 @@ var CodDicomWebServer = /*#__PURE__*/function () {
|
|
|
2619
2625
|
rejectFile(error);
|
|
2620
2626
|
}).then(function () {
|
|
2621
2627
|
dataRetrievalManager.removeEventListener(FILE_PARTIAL_WORKER_NAME, 'message', _handleSlice);
|
|
2622
|
-
delete _this3.filePromises[fileUrl];
|
|
2623
2628
|
});
|
|
2624
2629
|
} else {
|
|
2625
2630
|
rejectFile(new CustomError('CodDicomWebServer.ts: Offsets is needed in bytes optimized fetching'));
|
|
2626
2631
|
}
|
|
2627
2632
|
});
|
|
2628
|
-
this.filePromises[fileUrl] =
|
|
2633
|
+
this.filePromises[fileUrl] = {
|
|
2634
|
+
promise: tarPromise,
|
|
2635
|
+
requestCount: 1
|
|
2636
|
+
};
|
|
2629
2637
|
} else {
|
|
2630
|
-
tarPromise = this.filePromises[fileUrl];
|
|
2638
|
+
tarPromise = this.filePromises[fileUrl].promise;
|
|
2639
|
+
this.filePromises[fileUrl].requestCount++;
|
|
2631
2640
|
}
|
|
2632
2641
|
return _context2.abrupt("return", new Promise(function (resolveRequest, rejectRequest) {
|
|
2633
|
-
var requestResolved = false
|
|
2642
|
+
var requestResolved = false,
|
|
2643
|
+
fileFetchingCompleted = false;
|
|
2634
2644
|
var handleChunkAppend = function handleChunkAppend(evt) {
|
|
2635
2645
|
if (evt instanceof CustomErrorEvent) {
|
|
2636
2646
|
rejectRequest(evt.message);
|
|
@@ -2640,44 +2650,74 @@ var CodDicomWebServer = /*#__PURE__*/function () {
|
|
|
2640
2650
|
url = _evt$data3.url,
|
|
2641
2651
|
position = _evt$data3.position,
|
|
2642
2652
|
chunk = _evt$data3.chunk,
|
|
2653
|
+
totalLength = _evt$data3.totalLength,
|
|
2643
2654
|
isAppending = _evt$data3.isAppending;
|
|
2644
2655
|
if (isAppending) {
|
|
2645
2656
|
if (chunk) {
|
|
2646
|
-
_this3.
|
|
2657
|
+
if (_this3.options.enableLocalCache) {
|
|
2658
|
+
_this3.files[url].set(chunk, position - chunk.length);
|
|
2659
|
+
} else {
|
|
2660
|
+
_this3.fileManager.append(url, chunk, position);
|
|
2661
|
+
}
|
|
2647
2662
|
} else {
|
|
2648
2663
|
_this3.fileManager.setPosition(url, position);
|
|
2649
2664
|
}
|
|
2665
|
+
} else {
|
|
2666
|
+
// The full empty file including with first chunk have been stored to fileManager
|
|
2667
|
+
// by the worker listener in the file promise.
|
|
2668
|
+
// So, we check whether the cache exceeded the limit here.
|
|
2669
|
+
if (_this3.fileManager.getTotalSize() > _this3.options.maxCacheSize) {
|
|
2670
|
+
_this3.fileManager.decacheNecessaryBytes(url, totalLength);
|
|
2671
|
+
}
|
|
2650
2672
|
}
|
|
2651
|
-
if (!requestResolved && url === fileUrl &&
|
|
2673
|
+
if (!requestResolved && url === fileUrl && position > offsets.endByte) {
|
|
2652
2674
|
try {
|
|
2653
|
-
var file = _this3.fileManager.get(url, offsets);
|
|
2654
|
-
requestResolved = true;
|
|
2675
|
+
var file = _this3.options.enableLocalCache ? _this3.files[url].slice(offsets.startByte, offsets.endByte) : _this3.fileManager.get(url, offsets);
|
|
2655
2676
|
resolveRequest(file === null || file === void 0 ? void 0 : file.buffer);
|
|
2656
2677
|
} catch (error) {
|
|
2657
2678
|
rejectRequest(error);
|
|
2679
|
+
} finally {
|
|
2680
|
+
completeRequest(url);
|
|
2658
2681
|
}
|
|
2659
2682
|
}
|
|
2660
2683
|
};
|
|
2684
|
+
var completeRequest = function completeRequest(url) {
|
|
2685
|
+
var _this3$filePromises$u;
|
|
2686
|
+
requestResolved = true;
|
|
2687
|
+
_this3.filePromises[url].requestCount--;
|
|
2688
|
+
dataRetrievalManager.removeEventListener(FILE_STREAMING_WORKER_NAME, 'message', handleChunkAppend);
|
|
2689
|
+
if (fileFetchingCompleted && _this3.filePromises[url] && !((_this3$filePromises$u = _this3.filePromises[url]) !== null && _this3$filePromises$u !== void 0 && _this3$filePromises$u.requestCount)) {
|
|
2690
|
+
delete _this3.filePromises[url];
|
|
2691
|
+
delete _this3.files[url];
|
|
2692
|
+
}
|
|
2693
|
+
};
|
|
2661
2694
|
if (offsets && !isBytesOptimized) {
|
|
2662
2695
|
dataRetrievalManager.addEventListener(FILE_STREAMING_WORKER_NAME, 'message', handleChunkAppend);
|
|
2663
2696
|
}
|
|
2664
2697
|
tarPromise.then(function () {
|
|
2698
|
+
fileFetchingCompleted = true;
|
|
2665
2699
|
if (!requestResolved) {
|
|
2666
|
-
if (_this3.fileManager.getPosition(fileUrl)) {
|
|
2667
|
-
var
|
|
2668
|
-
|
|
2669
|
-
|
|
2700
|
+
if (_this3.fileManager.getPosition(fileUrl) || _this3.files[fileUrl]) {
|
|
2701
|
+
var _file;
|
|
2702
|
+
var file;
|
|
2703
|
+
if (_this3.options.enableLocalCache) {
|
|
2704
|
+
file = isBytesOptimized || !offsets ? _this3.files[fileUrl] : _this3.files[fileUrl].slice(offsets.startByte, offsets.endByte);
|
|
2705
|
+
} else {
|
|
2706
|
+
file = _this3.fileManager.get(fileUrl, isBytesOptimized ? undefined : offsets);
|
|
2707
|
+
}
|
|
2708
|
+
resolveRequest((_file = file) === null || _file === void 0 ? void 0 : _file.buffer);
|
|
2670
2709
|
} else {
|
|
2671
2710
|
rejectRequest(new CustomError("File - ".concat(fileUrl, " not found")));
|
|
2672
2711
|
}
|
|
2673
2712
|
}
|
|
2674
2713
|
})["catch"](function (error) {
|
|
2714
|
+
fileFetchingCompleted = true;
|
|
2675
2715
|
rejectRequest(error);
|
|
2676
|
-
})
|
|
2677
|
-
|
|
2716
|
+
})["finally"](function () {
|
|
2717
|
+
completeRequest(fileUrl);
|
|
2678
2718
|
});
|
|
2679
2719
|
}));
|
|
2680
|
-
case
|
|
2720
|
+
case 15:
|
|
2681
2721
|
case "end":
|
|
2682
2722
|
return _context2.stop();
|
|
2683
2723
|
}
|