cod-dicomweb-server 1.3.10 → 1.3.12
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 +1680 -1683
- package/dist/esm/classes/CodDicomWebServer.d.ts +1 -1
- package/dist/esm/classes/CodDicomWebServer.js +15 -15
- package/dist/esm/classes/customClasses.d.ts +1 -0
- package/dist/esm/dataRetrieval/register.d.ts +1 -1
- package/dist/esm/dataRetrieval/register.js +1 -2
- package/dist/esm/dataRetrieval/scripts/fileStreaming.d.ts +1 -4
- package/dist/esm/dataRetrieval/scripts/fileStreaming.js +5 -27
- 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 +1 -1
- 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,1608 @@ 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
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
821
|
+
}, _callee3);
|
|
822
|
+
}));
|
|
823
|
+
return _readArrayBufferFile.apply(this, arguments);
|
|
824
|
+
}
|
|
825
|
+
function readFile(_x5, _x6) {
|
|
826
|
+
return _readFile.apply(this, arguments);
|
|
827
|
+
}
|
|
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);
|
|
935
|
+
}
|
|
936
|
+
function writeFile(_x7, _x8, _x9) {
|
|
937
|
+
return _writeFile.apply(this, arguments);
|
|
938
|
+
}
|
|
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) {
|
|
951
|
+
case 0:
|
|
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;
|
|
957
|
+
case 5:
|
|
958
|
+
if (!(i < pathParts.length - 1)) {
|
|
959
|
+
_context6.next = 12;
|
|
960
|
+
break;
|
|
961
|
+
}
|
|
962
|
+
_context6.next = 8;
|
|
963
|
+
return currentDir.getDirectoryHandle(pathParts[i], {
|
|
964
|
+
create: true
|
|
965
|
+
});
|
|
966
|
+
case 8:
|
|
967
|
+
currentDir = _context6.sent;
|
|
968
|
+
case 9:
|
|
969
|
+
i++;
|
|
970
|
+
_context6.next = 5;
|
|
971
|
+
break;
|
|
972
|
+
case 12:
|
|
973
|
+
fileName = pathParts.at(-1);
|
|
974
|
+
_context6.next = 15;
|
|
975
|
+
return currentDir.getFileHandle(fileName, {
|
|
976
|
+
create: true
|
|
977
|
+
});
|
|
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:
|
|
1007
|
+
case "end":
|
|
1008
|
+
return _context6.stop();
|
|
1009
|
+
}
|
|
1010
|
+
}, _callee6, null, [[1, 30]]);
|
|
1011
|
+
}));
|
|
1012
|
+
return _writeFile.apply(this, arguments);
|
|
1013
|
+
}
|
|
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
|
+
}
|
|
1030
|
+
}
|
|
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) {
|
|
1039
|
+
case 0:
|
|
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:
|
|
1145
|
+
case "end":
|
|
1146
|
+
return _context9.stop();
|
|
1147
|
+
}
|
|
1148
|
+
}, _callee8, null, [[1, 6]]);
|
|
1149
|
+
}));
|
|
1150
|
+
return _clearPartialFiles.apply(this, arguments);
|
|
1151
|
+
}
|
|
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);
|
|
1161
|
+
}
|
|
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); }
|
|
863
1190
|
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
this.dataRetriever = new requestManager();
|
|
871
|
-
this.dataRetrieverMode = DataRetrieveMode.REQUEST;
|
|
872
|
-
} else {
|
|
873
|
-
this.dataRetriever = new workerManager();
|
|
874
|
-
this.dataRetrieverMode = DataRetrieveMode.WORKER;
|
|
875
|
-
}
|
|
1191
|
+
|
|
1192
|
+
|
|
1193
|
+
var MetadataManager = /*#__PURE__*/function () {
|
|
1194
|
+
function MetadataManager() {
|
|
1195
|
+
metadataManager_classCallCheck(this, MetadataManager);
|
|
1196
|
+
metadataManager_defineProperty(this, "metadataPromises", {});
|
|
876
1197
|
}
|
|
877
|
-
return
|
|
878
|
-
key: "
|
|
879
|
-
value: function
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
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
|
+
};
|
|
888
1223
|
}
|
|
889
|
-
this.dataRetriever.reset();
|
|
890
|
-
this.dataRetriever = new managers[mode]();
|
|
891
|
-
this.dataRetrieverMode = mode;
|
|
892
1224
|
}
|
|
893
1225
|
}, {
|
|
894
|
-
key: "
|
|
895
|
-
value: function
|
|
896
|
-
|
|
897
|
-
this.dataRetriever.register(name, arg);
|
|
1226
|
+
key: "getMetadataFromCache",
|
|
1227
|
+
value: function getMetadataFromCache(url) {
|
|
1228
|
+
return this.metadataPromises[url];
|
|
898
1229
|
}
|
|
899
1230
|
}, {
|
|
900
|
-
key: "
|
|
1231
|
+
key: "getMetadata",
|
|
901
1232
|
value: function () {
|
|
902
|
-
var
|
|
903
|
-
|
|
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) {
|
|
904
1237
|
while (1) switch (_context.prev = _context.next) {
|
|
905
1238
|
case 0:
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
1239
|
+
url = createMetadataJsonUrl(params);
|
|
1240
|
+
if (url) {
|
|
1241
|
+
_context.next = 3;
|
|
1242
|
+
break;
|
|
1243
|
+
}
|
|
1244
|
+
throw new CustomError('Error creating metadata json url');
|
|
910
1245
|
case 3:
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
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;
|
|
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);
|
|
1016
1304
|
}
|
|
1017
|
-
|
|
1018
|
-
|
|
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
|
-
}
|
|
1305
|
+
return getMetadata;
|
|
1306
|
+
}()
|
|
1028
1307
|
}]);
|
|
1029
1308
|
}();
|
|
1030
|
-
/* harmony default export */ const
|
|
1031
|
-
;// ./src/
|
|
1032
|
-
function
|
|
1033
|
-
function
|
|
1034
|
-
function
|
|
1035
|
-
function
|
|
1036
|
-
function
|
|
1037
|
-
function
|
|
1038
|
-
|
|
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); }
|
|
1039
1321
|
|
|
1040
|
-
function
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
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;
|
|
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
|
|
1334
|
+
});
|
|
1335
|
+
});
|
|
1066
1336
|
}
|
|
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
1337
|
});
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
function
|
|
1193
|
-
|
|
1194
|
-
|
|
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;
|
|
1402
|
+
}
|
|
1403
|
+
if (!loaderObject.listeners[eventType]) {
|
|
1404
|
+
loaderObject.listeners[eventType] = [listener];
|
|
1405
|
+
} else {
|
|
1406
|
+
loaderObject.listeners[eventType].push(listener);
|
|
1407
|
+
}
|
|
1195
1408
|
}
|
|
1196
|
-
|
|
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;
|
|
1197
1432
|
}
|
|
1433
|
+
;// ./node_modules/comlink/dist/esm/comlink.mjs
|
|
1198
1434
|
/**
|
|
1199
|
-
*
|
|
1200
|
-
*
|
|
1201
|
-
*
|
|
1202
|
-
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
1435
|
+
* @license
|
|
1436
|
+
* Copyright 2019 Google LLC
|
|
1437
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
1203
1438
|
*/
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
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";
|
|
1207
1445
|
/**
|
|
1208
|
-
*
|
|
1209
|
-
*
|
|
1210
|
-
* @param key
|
|
1211
|
-
* @param value
|
|
1212
|
-
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
1446
|
+
* Internal transfer handle to handle objects marked to proxy.
|
|
1213
1447
|
*/
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
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
|
+
};
|
|
1220
1460
|
/**
|
|
1221
|
-
*
|
|
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).
|
|
1461
|
+
* Internal transfer handler to handle thrown exceptions.
|
|
1226
1462
|
*/
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
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
|
+
};
|
|
1233
1489
|
/**
|
|
1234
|
-
*
|
|
1235
|
-
*
|
|
1236
|
-
* @param keys
|
|
1237
|
-
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
1490
|
+
* Allows customizing the serialization of certain values.
|
|
1238
1491
|
*/
|
|
1239
|
-
|
|
1240
|
-
|
|
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;
|
|
1241
1506
|
}
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
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
|
+
}
|
|
1527
|
+
break;
|
|
1528
|
+
case "SET" /* MessageType.SET */:
|
|
1529
|
+
{
|
|
1530
|
+
parent[path.slice(-1)[0]] = fromWireValue(ev.data.value);
|
|
1531
|
+
returnValue = true;
|
|
1532
|
+
}
|
|
1533
|
+
break;
|
|
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;
|
|
1259
1559
|
}
|
|
1260
|
-
|
|
1261
|
-
|
|
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
|
+
}
|
|
1262
1578
|
}
|
|
1263
|
-
}
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
function del(key, customStore = defaultGetStore()) {
|
|
1273
|
-
return customStore('readwrite', (store) => {
|
|
1274
|
-
store.delete(key);
|
|
1275
|
-
return promisifyRequest(store.transaction);
|
|
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
|
+
});
|
|
1276
1588
|
});
|
|
1589
|
+
if (ep.start) {
|
|
1590
|
+
ep.start();
|
|
1591
|
+
}
|
|
1277
1592
|
}
|
|
1278
|
-
|
|
1279
|
-
|
|
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
|
-
});
|
|
1593
|
+
function isMessagePort(endpoint) {
|
|
1594
|
+
return endpoint.constructor.name === "MessagePort";
|
|
1289
1595
|
}
|
|
1290
|
-
|
|
1291
|
-
|
|
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
|
-
});
|
|
1596
|
+
function closeEndPoint(endpoint) {
|
|
1597
|
+
if (isMessagePort(endpoint))
|
|
1598
|
+
endpoint.close();
|
|
1300
1599
|
}
|
|
1301
|
-
function
|
|
1302
|
-
|
|
1303
|
-
|
|
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) {
|
|
1304
1605
|
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
1606
|
}
|
|
1321
|
-
const
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
}
|
|
1325
|
-
/**
|
|
1326
|
-
* Get all values in the store.
|
|
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());
|
|
1607
|
+
const resolver = pendingListeners.get(data.id);
|
|
1608
|
+
if (!resolver) {
|
|
1609
|
+
return;
|
|
1335
1610
|
}
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
* Get all entries in the store. Each entry is an array of `[key, value]`.
|
|
1342
|
-
*
|
|
1343
|
-
* @param customStore Method to get a custom store. Use with caution (see the docs).
|
|
1344
|
-
*/
|
|
1345
|
-
function entries(customStore = defaultGetStore()) {
|
|
1346
|
-
return customStore('readonly', (store) => {
|
|
1347
|
-
// Fast path for modern browsers
|
|
1348
|
-
// (although, hopefully we'll get a simpler path some day)
|
|
1349
|
-
if (store.getAll && store.getAllKeys) {
|
|
1350
|
-
return Promise.all([
|
|
1351
|
-
promisifyRequest(store.getAllKeys()),
|
|
1352
|
-
promisifyRequest(store.getAll()),
|
|
1353
|
-
]).then(([keys, values]) => keys.map((key, i) => [key, values[i]]));
|
|
1611
|
+
try {
|
|
1612
|
+
resolver(data);
|
|
1613
|
+
}
|
|
1614
|
+
finally {
|
|
1615
|
+
pendingListeners.delete(data.id);
|
|
1354
1616
|
}
|
|
1355
|
-
const items = [];
|
|
1356
|
-
return customStore('readonly', (store) => eachCursor(store, (cursor) => items.push([cursor.key, cursor.value])).then(() => items));
|
|
1357
1617
|
});
|
|
1618
|
+
return createProxy(ep, pendingListeners, [], target);
|
|
1358
1619
|
}
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
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);
|
|
1620
|
+
function throwIfProxyReleased(isReleased) {
|
|
1621
|
+
if (isReleased) {
|
|
1622
|
+
throw new Error("Proxy has been released and is not useable");
|
|
1623
|
+
}
|
|
1380
1624
|
}
|
|
1381
|
-
function
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
if (directoryHandle) {
|
|
1388
|
-
_context.next = 5;
|
|
1389
|
-
break;
|
|
1390
|
-
}
|
|
1391
|
-
_context.next = 4;
|
|
1392
|
-
return get(IDB_DIR_HANDLE_KEY);
|
|
1393
|
-
case 4:
|
|
1394
|
-
directoryHandle = _context.sent;
|
|
1395
|
-
case 5:
|
|
1396
|
-
if (directoryHandle) {
|
|
1397
|
-
_context.next = 9;
|
|
1398
|
-
break;
|
|
1399
|
-
}
|
|
1400
|
-
_context.next = 8;
|
|
1401
|
-
return navigator.storage.getDirectory();
|
|
1402
|
-
case 8:
|
|
1403
|
-
directoryHandle = _context.sent;
|
|
1404
|
-
case 9:
|
|
1405
|
-
return _context.abrupt("return", directoryHandle);
|
|
1406
|
-
case 12:
|
|
1407
|
-
_context.prev = 12;
|
|
1408
|
-
_context.t0 = _context["catch"](0);
|
|
1409
|
-
console.warn("Error getting directoryhandle: ".concat(_context.t0.message));
|
|
1410
|
-
case 15:
|
|
1411
|
-
case "end":
|
|
1412
|
-
return _context.stop();
|
|
1413
|
-
}
|
|
1414
|
-
}, _callee, null, [[0, 12]]);
|
|
1415
|
-
}));
|
|
1416
|
-
return _getDirectoryHandle.apply(this, arguments);
|
|
1625
|
+
function releaseEndpoint(ep) {
|
|
1626
|
+
return requestResponseMessage(ep, new Map(), {
|
|
1627
|
+
type: "RELEASE" /* MessageType.RELEASE */,
|
|
1628
|
+
}).then(() => {
|
|
1629
|
+
closeEndPoint(ep);
|
|
1630
|
+
});
|
|
1417
1631
|
}
|
|
1418
|
-
|
|
1419
|
-
|
|
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
|
+
}
|
|
1420
1647
|
}
|
|
1421
|
-
function
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
case 0:
|
|
1426
|
-
_context2.next = 2;
|
|
1427
|
-
return directoryHandle.getFileHandle(name).then(function (fileHandle) {
|
|
1428
|
-
return fileHandle.getFile().then(function (file) {
|
|
1429
|
-
return file.text();
|
|
1430
|
-
}).then(function (metadataString) {
|
|
1431
|
-
return JSON.parse(metadataString);
|
|
1432
|
-
});
|
|
1433
|
-
})["catch"](function () {
|
|
1434
|
-
return null;
|
|
1435
|
-
});
|
|
1436
|
-
case 2:
|
|
1437
|
-
return _context2.abrupt("return", _context2.sent);
|
|
1438
|
-
case 3:
|
|
1439
|
-
case "end":
|
|
1440
|
-
return _context2.stop();
|
|
1441
|
-
}
|
|
1442
|
-
}, _callee2);
|
|
1443
|
-
}));
|
|
1444
|
-
return _readJsonFile.apply(this, arguments);
|
|
1648
|
+
function unregisterProxy(proxy) {
|
|
1649
|
+
if (proxyFinalizers) {
|
|
1650
|
+
proxyFinalizers.unregister(proxy);
|
|
1651
|
+
}
|
|
1445
1652
|
}
|
|
1446
|
-
function
|
|
1447
|
-
|
|
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;
|
|
1448
1720
|
}
|
|
1449
|
-
function
|
|
1450
|
-
|
|
1451
|
-
return fileAccessSystemUtils_regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1452
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
1453
|
-
case 0:
|
|
1454
|
-
_context3.next = 2;
|
|
1455
|
-
return directoryHandle.getFileHandle(name).then(function (fileHandle) {
|
|
1456
|
-
return fileHandle.getFile().then(function (file) {
|
|
1457
|
-
return file.arrayBuffer();
|
|
1458
|
-
});
|
|
1459
|
-
})["catch"](function () {
|
|
1460
|
-
return null;
|
|
1461
|
-
});
|
|
1462
|
-
case 2:
|
|
1463
|
-
return _context3.abrupt("return", _context3.sent);
|
|
1464
|
-
case 3:
|
|
1465
|
-
case "end":
|
|
1466
|
-
return _context3.stop();
|
|
1467
|
-
}
|
|
1468
|
-
}, _callee3);
|
|
1469
|
-
}));
|
|
1470
|
-
return _readArrayBufferFile.apply(this, arguments);
|
|
1721
|
+
function myFlat(arr) {
|
|
1722
|
+
return Array.prototype.concat.apply([], arr);
|
|
1471
1723
|
}
|
|
1472
|
-
function
|
|
1473
|
-
|
|
1724
|
+
function processArguments(argumentList) {
|
|
1725
|
+
const processed = argumentList.map(toWireValue);
|
|
1726
|
+
return [processed.map((v) => v[0]), myFlat(processed.map((v) => v[1]))];
|
|
1474
1727
|
}
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
currentDir,
|
|
1480
|
-
i,
|
|
1481
|
-
fileName,
|
|
1482
|
-
_args5 = arguments;
|
|
1483
|
-
return fileAccessSystemUtils_regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
1484
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
1485
|
-
case 0:
|
|
1486
|
-
options = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : {};
|
|
1487
|
-
if (name) {
|
|
1488
|
-
_context5.next = 3;
|
|
1489
|
-
break;
|
|
1490
|
-
}
|
|
1491
|
-
return _context5.abrupt("return");
|
|
1492
|
-
case 3:
|
|
1493
|
-
pathParts = name.split('/');
|
|
1494
|
-
currentDir = directoryHandle;
|
|
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;
|
|
1528
|
-
break;
|
|
1529
|
-
}
|
|
1530
|
-
_context4.prev = 2;
|
|
1531
|
-
pathParts.splice(pathParts.findIndex(function (part) {
|
|
1532
|
-
return part === FILE_SYSTEM_ROUTES.Partial;
|
|
1533
|
-
}), 1);
|
|
1534
|
-
currentDir = directoryHandle;
|
|
1535
|
-
_i = 0;
|
|
1536
|
-
case 6:
|
|
1537
|
-
if (!(_i < pathParts.length - 1)) {
|
|
1538
|
-
_context4.next = 13;
|
|
1539
|
-
break;
|
|
1540
|
-
}
|
|
1541
|
-
_context4.next = 9;
|
|
1542
|
-
return currentDir.getDirectoryHandle(pathParts[_i], {
|
|
1543
|
-
create: true
|
|
1544
|
-
});
|
|
1545
|
-
case 9:
|
|
1546
|
-
currentDir = _context4.sent;
|
|
1547
|
-
case 10:
|
|
1548
|
-
_i++;
|
|
1549
|
-
_context4.next = 6;
|
|
1550
|
-
break;
|
|
1551
|
-
case 13:
|
|
1552
|
-
convertedFileName = pathParts.at(-1).split('_')[0] + '.tar';
|
|
1553
|
-
_context4.next = 16;
|
|
1554
|
-
return readArrayBufferFile(currentDir, convertedFileName);
|
|
1555
|
-
case 16:
|
|
1556
|
-
fileArraybuffer = _context4.sent;
|
|
1557
|
-
return _context4.abrupt("return", fileArraybuffer.slice(options.offsets.startByte, options.offsets.endByte));
|
|
1558
|
-
case 20:
|
|
1559
|
-
_context4.prev = 20;
|
|
1560
|
-
_context4.t0 = _context4["catch"](2);
|
|
1561
|
-
console.warn("Error reading the file ".concat(name, ": ").concat(_context4.t0.message));
|
|
1562
|
-
case 23:
|
|
1563
|
-
case "end":
|
|
1564
|
-
return _context4.stop();
|
|
1565
|
-
}
|
|
1566
|
-
}, _callee4, null, [[2, 20]]);
|
|
1567
|
-
}))));
|
|
1568
|
-
case 20:
|
|
1569
|
-
_context5.next = 25;
|
|
1570
|
-
break;
|
|
1571
|
-
case 22:
|
|
1572
|
-
_context5.prev = 22;
|
|
1573
|
-
_context5.t0 = _context5["catch"](5);
|
|
1574
|
-
console.warn("Error reading the file ".concat(name, ": ").concat(_context5.t0.message));
|
|
1575
|
-
case 25:
|
|
1576
|
-
case "end":
|
|
1577
|
-
return _context5.stop();
|
|
1578
|
-
}
|
|
1579
|
-
}, _callee5, null, [[5, 22]]);
|
|
1580
|
-
}));
|
|
1581
|
-
return _readFile.apply(this, arguments);
|
|
1728
|
+
const transferCache = new WeakMap();
|
|
1729
|
+
function transfer(obj, transfers) {
|
|
1730
|
+
transferCache.set(obj, transfers);
|
|
1731
|
+
return obj;
|
|
1582
1732
|
}
|
|
1583
|
-
function
|
|
1584
|
-
|
|
1733
|
+
function proxy(obj) {
|
|
1734
|
+
return Object.assign(obj, { [proxyMarker]: true });
|
|
1585
1735
|
}
|
|
1586
|
-
function
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
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);
|
|
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
|
+
};
|
|
1660
1742
|
}
|
|
1661
|
-
function
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
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
|
+
];
|
|
1764
|
+
}
|
|
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);
|
|
1665
1781
|
});
|
|
1666
|
-
var url = URL.createObjectURL(blob);
|
|
1667
|
-
var a = document.createElement('a');
|
|
1668
|
-
a.href = url;
|
|
1669
|
-
a.download = fileName;
|
|
1670
|
-
a.click();
|
|
1671
|
-
URL.revokeObjectURL(url);
|
|
1672
|
-
return true;
|
|
1673
|
-
} catch (error) {
|
|
1674
|
-
console.warn("Error downloading file - ".concat(fileName, ": ") + error.message);
|
|
1675
|
-
return false;
|
|
1676
|
-
}
|
|
1677
1782
|
}
|
|
1678
|
-
function
|
|
1679
|
-
|
|
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("-");
|
|
1680
1788
|
}
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
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();
|
|
1789
|
+
|
|
1790
|
+
|
|
1791
|
+
//# sourceMappingURL=comlink.mjs.map
|
|
1792
|
+
|
|
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", {});
|
|
1810
|
+
}
|
|
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
|
|
1822
|
+
};
|
|
1823
|
+
} catch (error) {
|
|
1824
|
+
console.warn(error);
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
}, {
|
|
1828
|
+
key: "executeTask",
|
|
1829
|
+
value: function () {
|
|
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) {
|
|
1834
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1835
|
+
case 0:
|
|
1836
|
+
worker = (_this$workerRegistry$ = this.workerRegistry[workerName]) === null || _this$workerRegistry$ === void 0 ? void 0 : _this$workerRegistry$.instance;
|
|
1837
|
+
if (worker) {
|
|
1838
|
+
_context.next = 3;
|
|
1839
|
+
break;
|
|
1840
|
+
}
|
|
1841
|
+
throw new CustomError("Worker ".concat(workerName, " not registered"));
|
|
1842
|
+
case 3:
|
|
1843
|
+
_context.prev = 3;
|
|
1844
|
+
_context.next = 6;
|
|
1845
|
+
return worker[taskName](options);
|
|
1846
|
+
case 6:
|
|
1847
|
+
return _context.abrupt("return", _context.sent);
|
|
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;
|
|
1794
1881
|
}
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
function
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
}
|
|
1809
|
-
function
|
|
1810
|
-
|
|
1811
|
-
}
|
|
1812
|
-
function
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
}
|
|
1817
|
-
function createMetadataFileName(url) {
|
|
1818
|
-
return "".concat(parseCachePath(url), "/metadata.json");
|
|
1819
|
-
}
|
|
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); }
|
|
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); }
|
|
1837
1903
|
|
|
1838
1904
|
|
|
1839
1905
|
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
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
|
+
}
|
|
1844
1920
|
}
|
|
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]
|
|
1869
|
-
};
|
|
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');
|
|
1870
1932
|
}
|
|
1933
|
+
this.dataRetriever.reset();
|
|
1934
|
+
this.dataRetriever = new managers[mode]();
|
|
1935
|
+
this.dataRetrieverMode = mode;
|
|
1871
1936
|
}
|
|
1872
1937
|
}, {
|
|
1873
|
-
key: "
|
|
1874
|
-
value: function
|
|
1875
|
-
|
|
1938
|
+
key: "register",
|
|
1939
|
+
value: function register(name, arg) {
|
|
1940
|
+
// @ts-ignore
|
|
1941
|
+
this.dataRetriever.register(name, arg);
|
|
1876
1942
|
}
|
|
1877
1943
|
}, {
|
|
1878
|
-
key: "
|
|
1944
|
+
key: "executeTask",
|
|
1879
1945
|
value: function () {
|
|
1880
|
-
var
|
|
1881
|
-
|
|
1882
|
-
var url, cachedMetadata, directoryHandle, fileName, locallyCachedMetadata;
|
|
1883
|
-
return metadataManager_regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1946
|
+
var _executeTask = dataRetrievalManager_asyncToGenerator(/*#__PURE__*/dataRetrievalManager_regeneratorRuntime().mark(function _callee(loaderName, taskName, options) {
|
|
1947
|
+
return dataRetrievalManager_regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1884
1948
|
while (1) switch (_context.prev = _context.next) {
|
|
1885
1949
|
case 0:
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
break;
|
|
1890
|
-
}
|
|
1891
|
-
throw new CustomError('Error creating metadata json url');
|
|
1892
|
-
case 3:
|
|
1893
|
-
cachedMetadata = this.getMetadataFromCache(url);
|
|
1894
|
-
if (!cachedMetadata) {
|
|
1895
|
-
_context.next = 8;
|
|
1896
|
-
break;
|
|
1897
|
-
}
|
|
1898
|
-
_context.next = 7;
|
|
1899
|
-
return cachedMetadata;
|
|
1900
|
-
case 7:
|
|
1901
|
-
return _context.abrupt("return", _context.sent);
|
|
1902
|
-
case 8:
|
|
1903
|
-
_context.next = 10;
|
|
1904
|
-
return getDirectoryHandle();
|
|
1905
|
-
case 10:
|
|
1906
|
-
directoryHandle = _context.sent;
|
|
1907
|
-
fileName = createMetadataFileName(url);
|
|
1908
|
-
_context.next = 14;
|
|
1909
|
-
return readFile(directoryHandle, fileName, {
|
|
1910
|
-
isJson: true
|
|
1911
|
-
});
|
|
1912
|
-
case 14:
|
|
1913
|
-
locallyCachedMetadata = _context.sent;
|
|
1914
|
-
if (!locallyCachedMetadata) {
|
|
1915
|
-
_context.next = 17;
|
|
1916
|
-
break;
|
|
1917
|
-
}
|
|
1918
|
-
return _context.abrupt("return", locallyCachedMetadata);
|
|
1919
|
-
case 17:
|
|
1920
|
-
_context.prev = 17;
|
|
1921
|
-
this.metadataPromises[url] = fetch(url, {
|
|
1922
|
-
headers: headers
|
|
1923
|
-
}).then(function (response) {
|
|
1924
|
-
if (!response.ok) {
|
|
1925
|
-
throw new CustomError("Failed to fetch metadata: ".concat(response.statusText));
|
|
1926
|
-
}
|
|
1927
|
-
return response.json();
|
|
1928
|
-
}).then(function (data) {
|
|
1929
|
-
_this.addDeidMetadata(data, url);
|
|
1930
|
-
return writeFile(directoryHandle, fileName, data, true).then(function () {
|
|
1931
|
-
return data;
|
|
1932
|
-
});
|
|
1933
|
-
});
|
|
1934
|
-
_context.next = 21;
|
|
1935
|
-
return this.metadataPromises[url];
|
|
1936
|
-
case 21:
|
|
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
|
+
function getDataRetrievalManager() {
|
|
1984
|
+
return dataRetrievalManager;
|
|
1985
|
+
}
|
|
1957
1986
|
;// ./src/dataRetrieval/scripts/filePartial.ts
|
|
1958
1987
|
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
1988
|
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; }
|
|
@@ -2024,8 +2053,8 @@ var filePartial = {
|
|
|
2024
2053
|
;// ./src/dataRetrieval/scripts/fileStreaming.ts
|
|
2025
2054
|
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
2055
|
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
|
|
2056
|
+
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; }
|
|
2057
|
+
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
2058
|
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
2059
|
function fileStreaming_toPropertyKey(t) { var i = fileStreaming_toPrimitive(t, "string"); return "symbol" == fileStreaming_typeof(i) ? i : i + ""; }
|
|
2031
2060
|
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 +2063,9 @@ function fileStreaming_asyncToGenerator(n) { return function () { var t = this,
|
|
|
2034
2063
|
|
|
2035
2064
|
|
|
2036
2065
|
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
2066
|
stream: function stream(args, callBack) {
|
|
2051
|
-
var _this = this;
|
|
2052
2067
|
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;
|
|
2068
|
+
var url, headers, useSharedArrayBuffer, directoryHandle, controller, sharedArraybuffer, fileArraybuffer, _response$body, fileName, file, _totalLength, response, reader, result, completed, totalLength, firstChunk, position, chunk, streamingError;
|
|
2054
2069
|
return fileStreaming_regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2055
2070
|
while (1) switch (_context.prev = _context.next) {
|
|
2056
2071
|
case 0:
|
|
@@ -2061,7 +2076,7 @@ var fileStreaming = {
|
|
|
2061
2076
|
_context.prev = 4;
|
|
2062
2077
|
fileName = createStreamingFileName(url);
|
|
2063
2078
|
if (!directoryHandle) {
|
|
2064
|
-
_context.next =
|
|
2079
|
+
_context.next = 14;
|
|
2065
2080
|
break;
|
|
2066
2081
|
}
|
|
2067
2082
|
_context.next = 9;
|
|
@@ -2071,62 +2086,56 @@ var fileStreaming = {
|
|
|
2071
2086
|
case 9:
|
|
2072
2087
|
file = _context.sent;
|
|
2073
2088
|
if (!file) {
|
|
2074
|
-
_context.next =
|
|
2089
|
+
_context.next = 14;
|
|
2075
2090
|
break;
|
|
2076
2091
|
}
|
|
2092
|
+
_totalLength = file.byteLength;
|
|
2077
2093
|
callBack({
|
|
2078
2094
|
url: url,
|
|
2079
|
-
position:
|
|
2080
|
-
fileArraybuffer: new Uint8Array(file)
|
|
2095
|
+
position: _totalLength,
|
|
2096
|
+
fileArraybuffer: new Uint8Array(file),
|
|
2097
|
+
totalLength: _totalLength
|
|
2081
2098
|
});
|
|
2082
2099
|
return _context.abrupt("return");
|
|
2083
|
-
case
|
|
2084
|
-
_context.next =
|
|
2100
|
+
case 14:
|
|
2101
|
+
_context.next = 16;
|
|
2085
2102
|
return fetch(url, {
|
|
2086
|
-
headers:
|
|
2103
|
+
headers: fileStreaming_objectSpread({}, headers),
|
|
2087
2104
|
signal: controller.signal
|
|
2088
2105
|
});
|
|
2089
|
-
case
|
|
2106
|
+
case 16:
|
|
2090
2107
|
response = _context.sent;
|
|
2091
2108
|
if (response.ok) {
|
|
2092
|
-
_context.next =
|
|
2109
|
+
_context.next = 19;
|
|
2093
2110
|
break;
|
|
2094
2111
|
}
|
|
2095
2112
|
throw new CustomError("HTTP error! status: ".concat(response.status));
|
|
2096
|
-
case
|
|
2113
|
+
case 19:
|
|
2097
2114
|
reader = (_response$body = response.body) === null || _response$body === void 0 ? void 0 : _response$body.getReader();
|
|
2098
2115
|
if (reader) {
|
|
2099
|
-
_context.next =
|
|
2116
|
+
_context.next = 22;
|
|
2100
2117
|
break;
|
|
2101
2118
|
}
|
|
2102
2119
|
throw new CustomError('Failed to get reader from response body');
|
|
2103
|
-
case
|
|
2120
|
+
case 22:
|
|
2104
2121
|
completed = false;
|
|
2105
2122
|
totalLength = parseInt(response.headers.get('Content-Length') || '0', 10);
|
|
2106
|
-
_context.next =
|
|
2123
|
+
_context.next = 26;
|
|
2107
2124
|
return reader.read();
|
|
2108
|
-
case
|
|
2125
|
+
case 26:
|
|
2109
2126
|
firstChunk = _context.sent;
|
|
2110
2127
|
completed = firstChunk.done;
|
|
2111
2128
|
if (firstChunk.value) {
|
|
2112
|
-
_context.next =
|
|
2129
|
+
_context.next = 30;
|
|
2113
2130
|
break;
|
|
2114
2131
|
}
|
|
2115
2132
|
throw new CustomError('The fetched chunks does not have value');
|
|
2116
|
-
case
|
|
2133
|
+
case 30:
|
|
2117
2134
|
if (completed) {
|
|
2118
|
-
_context.next =
|
|
2135
|
+
_context.next = 49;
|
|
2119
2136
|
break;
|
|
2120
2137
|
}
|
|
2121
2138
|
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
2139
|
if (useSharedArrayBuffer) {
|
|
2131
2140
|
sharedArraybuffer = new SharedArrayBuffer(totalLength);
|
|
2132
2141
|
fileArraybuffer = new Uint8Array(sharedArraybuffer);
|
|
@@ -2137,69 +2146,61 @@ var fileStreaming = {
|
|
|
2137
2146
|
callBack({
|
|
2138
2147
|
url: url,
|
|
2139
2148
|
position: position,
|
|
2140
|
-
fileArraybuffer: fileArraybuffer
|
|
2149
|
+
fileArraybuffer: fileArraybuffer,
|
|
2150
|
+
totalLength: totalLength
|
|
2141
2151
|
});
|
|
2142
|
-
case
|
|
2152
|
+
case 35:
|
|
2143
2153
|
if (completed) {
|
|
2144
|
-
_context.next =
|
|
2154
|
+
_context.next = 48;
|
|
2145
2155
|
break;
|
|
2146
2156
|
}
|
|
2147
|
-
_context.next =
|
|
2157
|
+
_context.next = 38;
|
|
2148
2158
|
return reader.read();
|
|
2149
|
-
case
|
|
2159
|
+
case 38:
|
|
2150
2160
|
result = _context.sent;
|
|
2151
2161
|
if (!result.done) {
|
|
2152
|
-
_context.next =
|
|
2162
|
+
_context.next = 42;
|
|
2153
2163
|
break;
|
|
2154
2164
|
}
|
|
2155
2165
|
completed = true;
|
|
2156
|
-
return _context.abrupt("continue",
|
|
2157
|
-
case
|
|
2166
|
+
return _context.abrupt("continue", 35);
|
|
2167
|
+
case 42:
|
|
2158
2168
|
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
2169
|
fileArraybuffer.set(chunk, position);
|
|
2170
2170
|
position += chunk.length;
|
|
2171
2171
|
callBack({
|
|
2172
2172
|
isAppending: true,
|
|
2173
2173
|
url: url,
|
|
2174
2174
|
position: position,
|
|
2175
|
-
chunk: !useSharedArrayBuffer ? chunk : undefined
|
|
2175
|
+
chunk: !useSharedArrayBuffer ? chunk : undefined,
|
|
2176
|
+
totalLength: totalLength
|
|
2176
2177
|
});
|
|
2177
|
-
_context.next =
|
|
2178
|
+
_context.next = 35;
|
|
2178
2179
|
break;
|
|
2179
|
-
case
|
|
2180
|
+
case 48:
|
|
2180
2181
|
if (directoryHandle) {
|
|
2181
2182
|
writeFile(directoryHandle, fileName, fileArraybuffer.slice().buffer);
|
|
2182
2183
|
}
|
|
2183
|
-
case
|
|
2184
|
-
_context.next =
|
|
2184
|
+
case 49:
|
|
2185
|
+
_context.next = 56;
|
|
2185
2186
|
break;
|
|
2186
|
-
case
|
|
2187
|
-
_context.prev =
|
|
2187
|
+
case 51:
|
|
2188
|
+
_context.prev = 51;
|
|
2188
2189
|
_context.t0 = _context["catch"](4);
|
|
2189
2190
|
streamingError = new CustomError('fileStreaming.ts: ' + _context.t0.message || 0);
|
|
2190
2191
|
console.error(streamingError.message, _context.t0);
|
|
2191
2192
|
throw streamingError;
|
|
2192
|
-
case
|
|
2193
|
-
_context.prev =
|
|
2193
|
+
case 56:
|
|
2194
|
+
_context.prev = 56;
|
|
2194
2195
|
sharedArraybuffer = null;
|
|
2195
2196
|
fileArraybuffer = null;
|
|
2196
2197
|
controller.abort();
|
|
2197
|
-
return _context.finish(
|
|
2198
|
-
case
|
|
2198
|
+
return _context.finish(56);
|
|
2199
|
+
case 61:
|
|
2199
2200
|
case "end":
|
|
2200
2201
|
return _context.stop();
|
|
2201
2202
|
}
|
|
2202
|
-
}, _callee, null, [[4,
|
|
2203
|
+
}, _callee, null, [[4, 51, 56, 61]]);
|
|
2203
2204
|
}))();
|
|
2204
2205
|
}
|
|
2205
2206
|
};
|
|
@@ -2209,7 +2210,7 @@ var fileStreaming = {
|
|
|
2209
2210
|
|
|
2210
2211
|
|
|
2211
2212
|
|
|
2212
|
-
function register(workerNames
|
|
2213
|
+
function register(workerNames) {
|
|
2213
2214
|
var fileStreamingScriptName = workerNames.fileStreamingScriptName,
|
|
2214
2215
|
filePartialScriptName = workerNames.filePartialScriptName;
|
|
2215
2216
|
var dataRetrievalManager = getDataRetrievalManager();
|
|
@@ -2233,7 +2234,6 @@ function register(workerNames, maxFetchSize) {
|
|
|
2233
2234
|
};
|
|
2234
2235
|
dataRetrievalManager.register(filePartialScriptName, partialWorkerFn);
|
|
2235
2236
|
}
|
|
2236
|
-
dataRetrievalManager.executeTask(fileStreamingScriptName, 'setMaxFetchSize', maxFetchSize);
|
|
2237
2237
|
}
|
|
2238
2238
|
;// ./src/classes/CodDicomWebServer.ts
|
|
2239
2239
|
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); }
|
|
@@ -2269,7 +2269,8 @@ var CodDicomWebServer = /*#__PURE__*/function () {
|
|
|
2269
2269
|
CodDicomWebServer_classCallCheck(this, CodDicomWebServer);
|
|
2270
2270
|
CodDicomWebServer_defineProperty(this, "filePromises", {});
|
|
2271
2271
|
CodDicomWebServer_defineProperty(this, "options", {
|
|
2272
|
-
|
|
2272
|
+
maxCacheSize: 4 * 1024 * 1024 * 1024,
|
|
2273
|
+
// 4GB
|
|
2273
2274
|
domain: src_constants.url.DOMAIN,
|
|
2274
2275
|
enableLocalCache: false
|
|
2275
2276
|
});
|
|
@@ -2286,18 +2287,16 @@ var CodDicomWebServer = /*#__PURE__*/function () {
|
|
|
2286
2287
|
CodDicomWebServer_defineProperty(this, "getOptions", function () {
|
|
2287
2288
|
return _this.options;
|
|
2288
2289
|
});
|
|
2289
|
-
var
|
|
2290
|
+
var maxCacheSize = args.maxCacheSize,
|
|
2290
2291
|
domain = args.domain,
|
|
2291
2292
|
disableWorker = args.disableWorker,
|
|
2292
2293
|
enableLocalCache = args.enableLocalCache;
|
|
2293
|
-
this.options.
|
|
2294
|
+
this.options.maxCacheSize = maxCacheSize || this.options.maxCacheSize;
|
|
2294
2295
|
this.options.domain = domain || this.options.domain;
|
|
2295
2296
|
this.options.enableLocalCache = !!enableLocalCache;
|
|
2296
2297
|
var fileStreamingScriptName = src_constants.dataRetrieval.FILE_STREAMING_WORKER_NAME;
|
|
2297
2298
|
var filePartialScriptName = src_constants.dataRetrieval.FILE_PARTIAL_WORKER_NAME;
|
|
2298
|
-
this.fileManager = new fileManager(
|
|
2299
|
-
fileStreamingScriptName: fileStreamingScriptName
|
|
2300
|
-
});
|
|
2299
|
+
this.fileManager = new fileManager();
|
|
2301
2300
|
this.metadataManager = new metadataManager();
|
|
2302
2301
|
if (disableWorker) {
|
|
2303
2302
|
var dataRetrievalManager = getDataRetrievalManager();
|
|
@@ -2306,7 +2305,7 @@ var CodDicomWebServer = /*#__PURE__*/function () {
|
|
|
2306
2305
|
register({
|
|
2307
2306
|
fileStreamingScriptName: fileStreamingScriptName,
|
|
2308
2307
|
filePartialScriptName: filePartialScriptName
|
|
2309
|
-
}
|
|
2308
|
+
});
|
|
2310
2309
|
}
|
|
2311
2310
|
return CodDicomWebServer_createClass(CodDicomWebServer, [{
|
|
2312
2311
|
key: "addFileUrl",
|
|
@@ -2439,9 +2438,6 @@ var CodDicomWebServer = /*#__PURE__*/function () {
|
|
|
2439
2438
|
var _pixelDataElement$fra = pixelDataElement.fragments[0];
|
|
2440
2439
|
dataOffset = _pixelDataElement$fra.position;
|
|
2441
2440
|
length = _pixelDataElement$fra.length;
|
|
2442
|
-
} else {
|
|
2443
|
-
// Adding 8 bytes for 4 bytes tag + 4 bytes length for uncomppressed pixelData
|
|
2444
|
-
dataOffset += 8;
|
|
2445
2441
|
}
|
|
2446
2442
|
return arraybuffer.slice(dataOffset, dataOffset + length);
|
|
2447
2443
|
}
|
|
@@ -2508,13 +2504,10 @@ var CodDicomWebServer = /*#__PURE__*/function () {
|
|
|
2508
2504
|
isBytesOptimized,
|
|
2509
2505
|
extractedFile,
|
|
2510
2506
|
directoryHandle,
|
|
2511
|
-
_this$getOptions,
|
|
2512
|
-
maxWorkerFetchSize,
|
|
2513
2507
|
dataRetrievalManager,
|
|
2514
2508
|
_constants$dataRetrie,
|
|
2515
2509
|
FILE_STREAMING_WORKER_NAME,
|
|
2516
2510
|
FILE_PARTIAL_WORKER_NAME,
|
|
2517
|
-
THRESHOLD,
|
|
2518
2511
|
tarPromise,
|
|
2519
2512
|
_args2 = arguments;
|
|
2520
2513
|
return CodDicomWebServer_regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
@@ -2546,14 +2539,10 @@ var CodDicomWebServer = /*#__PURE__*/function () {
|
|
|
2546
2539
|
_context2.t0 = _context2.sent;
|
|
2547
2540
|
case 10:
|
|
2548
2541
|
directoryHandle = _context2.t0;
|
|
2549
|
-
_this$getOptions = this.getOptions(), maxWorkerFetchSize = _this$getOptions.maxWorkerFetchSize;
|
|
2550
2542
|
dataRetrievalManager = getDataRetrievalManager();
|
|
2551
|
-
_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
|
|
2543
|
+
_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;
|
|
2552
2544
|
if (!this.filePromises[fileUrl]) {
|
|
2553
2545
|
tarPromise = new Promise(function (resolveFile, rejectFile) {
|
|
2554
|
-
if (_this3.fileManager.getTotalSize() + THRESHOLD > maxWorkerFetchSize) {
|
|
2555
|
-
throw new CustomError("CodDicomWebServer.ts: Maximum size(".concat(maxWorkerFetchSize, ") for fetching files reached"));
|
|
2556
|
-
}
|
|
2557
2546
|
var FetchTypeEnum = src_constants.Enums.FetchType;
|
|
2558
2547
|
if (fetchType === FetchTypeEnum.API_OPTIMIZED) {
|
|
2559
2548
|
var _handleFirstChunk = function handleFirstChunk(evt) {
|
|
@@ -2643,6 +2632,7 @@ var CodDicomWebServer = /*#__PURE__*/function () {
|
|
|
2643
2632
|
url = _evt$data3.url,
|
|
2644
2633
|
position = _evt$data3.position,
|
|
2645
2634
|
chunk = _evt$data3.chunk,
|
|
2635
|
+
totalLength = _evt$data3.totalLength,
|
|
2646
2636
|
isAppending = _evt$data3.isAppending;
|
|
2647
2637
|
if (isAppending) {
|
|
2648
2638
|
if (chunk) {
|
|
@@ -2650,6 +2640,13 @@ var CodDicomWebServer = /*#__PURE__*/function () {
|
|
|
2650
2640
|
} else {
|
|
2651
2641
|
_this3.fileManager.setPosition(url, position);
|
|
2652
2642
|
}
|
|
2643
|
+
} else {
|
|
2644
|
+
// The full empty file including with first chunk have been stored to fileManager
|
|
2645
|
+
// by the worker listener in the file promise.
|
|
2646
|
+
// So, we check whether the cache exceeded the limit here.
|
|
2647
|
+
if (_this3.fileManager.getTotalSize() > _this3.options.maxCacheSize) {
|
|
2648
|
+
_this3.fileManager.decacheNecessaryBytes(url, totalLength);
|
|
2649
|
+
}
|
|
2653
2650
|
}
|
|
2654
2651
|
if (!requestResolved && url === fileUrl && offsets && position > offsets.endByte) {
|
|
2655
2652
|
try {
|
|
@@ -2680,7 +2677,7 @@ var CodDicomWebServer = /*#__PURE__*/function () {
|
|
|
2680
2677
|
dataRetrievalManager.removeEventListener(FILE_STREAMING_WORKER_NAME, 'message', handleChunkAppend);
|
|
2681
2678
|
});
|
|
2682
2679
|
}));
|
|
2683
|
-
case
|
|
2680
|
+
case 15:
|
|
2684
2681
|
case "end":
|
|
2685
2682
|
return _context2.stop();
|
|
2686
2683
|
}
|