agglomerative-clustering 3.0.0-beta.1 → 3.0.0-beta.2
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/README.md +93 -34
- package/dist/clustering.wasm +0 -0
- package/dist/index.cjs +574 -258
- package/dist/index.d.cts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.mjs +561 -258
- package/dist/shared.cjs +58 -3
- package/dist/shared.mjs +58 -3
- package/dist/worker.d.ts +2 -2
- package/dist/worker.mjs +281 -136
- package/package.json +1 -1
package/dist/worker.mjs
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
var _excluded = ["signal", "onProgress"];
|
|
2
|
-
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
3
2
|
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
4
3
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
-
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; } }
|
|
6
4
|
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
7
5
|
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
8
|
-
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; }
|
|
9
6
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
10
7
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
12
|
+
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); }
|
|
13
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
11
14
|
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); }
|
|
12
15
|
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (c = i[4] || 3, u = i[5] === e ? i[3] : i[5], i[4] = 3, i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
13
16
|
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { if (r) i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n;else { var o = function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); }; o("next", 0), o("throw", 1), o("return", 2); } }, _regeneratorDefine2(e, r, n, t); }
|
|
17
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
18
|
+
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."); }
|
|
19
|
+
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; } }
|
|
20
|
+
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; }
|
|
21
|
+
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; } }
|
|
22
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
14
23
|
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); }
|
|
15
24
|
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); }); }; }
|
|
16
25
|
// The `agglomerative-clustering/worker` entry: the same API, run in a Web Worker (browsers) or a worker thread
|
|
@@ -26,15 +35,76 @@ export { version, Palette, Clustering } from "./shared.mjs";
|
|
|
26
35
|
export var formatVersion = latestVersion;
|
|
27
36
|
var isNode = typeof process !== 'undefined' && !!(process.versions && process.versions.node) && typeof window === 'undefined';
|
|
28
37
|
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
// The worker thread's script in Node: the one next to this file, which imports the main entry (index.mjs) next to it. A
|
|
39
|
+
// server bundle (Next.js with webpack or Turbopack) copies the script elsewhere without what it imports, and may hand
|
|
40
|
+
// over its URL as another realm's URL object, which Node's Worker rejects. Then the package's own copy is used, found the
|
|
41
|
+
// way Node resolves packages from the working directory. Built from strings so Node's own URL class makes it.
|
|
42
|
+
var nodeWorkerScript = /*#__PURE__*/function () {
|
|
43
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
44
|
+
var load, script, made, _yield$Promise$all, _yield$Promise$all2, existsSync, _yield$Promise$all2$, fileURLToPath, pathToFileURL, _yield$load, createRequire, packaged, _t;
|
|
33
45
|
return _regenerator().w(function (_context) {
|
|
34
46
|
while (1) switch (_context.n) {
|
|
47
|
+
case 0:
|
|
48
|
+
load = function load(name) {
|
|
49
|
+
return import(/* webpackIgnore: true */ /* @vite-ignore */['node', name].join(':'));
|
|
50
|
+
};
|
|
51
|
+
script = null;
|
|
52
|
+
try {
|
|
53
|
+
made = new URL('./worker-thread.mjs', import.meta.url);
|
|
54
|
+
script = new URL(typeof made.href === 'string' ? made.href : String(made));
|
|
55
|
+
} catch (error) {/* a URL Node can't read: use the package's copy */}
|
|
56
|
+
_context.p = 1;
|
|
57
|
+
_context.n = 2;
|
|
58
|
+
return Promise.all([load('fs'), load('url')]);
|
|
59
|
+
case 2:
|
|
60
|
+
_yield$Promise$all = _context.v;
|
|
61
|
+
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
62
|
+
existsSync = _yield$Promise$all2[0].existsSync;
|
|
63
|
+
_yield$Promise$all2$ = _yield$Promise$all2[1];
|
|
64
|
+
fileURLToPath = _yield$Promise$all2$.fileURLToPath;
|
|
65
|
+
pathToFileURL = _yield$Promise$all2$.pathToFileURL;
|
|
66
|
+
if (!(script && script.protocol === 'file:' && existsSync(fileURLToPath(script)) && existsSync(fileURLToPath(new URL('./index.mjs', script))))) {
|
|
67
|
+
_context.n = 3;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
return _context.a(2, script);
|
|
71
|
+
case 3:
|
|
72
|
+
_context.n = 4;
|
|
73
|
+
return load('module');
|
|
74
|
+
case 4:
|
|
75
|
+
_yield$load = _context.v;
|
|
76
|
+
createRequire = _yield$load.createRequire;
|
|
77
|
+
packaged = new URL('./dist/worker-thread.mjs', pathToFileURL(createRequire("".concat(process.cwd(), "/")).resolve('agglomerative-clustering/package.json')));
|
|
78
|
+
if (!existsSync(fileURLToPath(packaged))) {
|
|
79
|
+
_context.n = 5;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
return _context.a(2, packaged);
|
|
83
|
+
case 5:
|
|
84
|
+
_context.n = 7;
|
|
85
|
+
break;
|
|
86
|
+
case 6:
|
|
87
|
+
_context.p = 6;
|
|
88
|
+
_t = _context.v;
|
|
89
|
+
case 7:
|
|
90
|
+
return _context.a(2, script || new URL('./worker-thread.mjs', import.meta.url));
|
|
91
|
+
}
|
|
92
|
+
}, _callee, null, [[1, 6]]);
|
|
93
|
+
}));
|
|
94
|
+
return function nodeWorkerScript() {
|
|
95
|
+
return _ref.apply(this, arguments);
|
|
96
|
+
};
|
|
97
|
+
}();
|
|
98
|
+
|
|
99
|
+
// Starts the worker and returns {post, terminate, ref, unref}, with messages delivered to `receive`.
|
|
100
|
+
var start = /*#__PURE__*/function () {
|
|
101
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(receive) {
|
|
102
|
+
var _worker, _yield$import, NodeWorker, worker, _t2, _t3, _t4;
|
|
103
|
+
return _regenerator().w(function (_context2) {
|
|
104
|
+
while (1) switch (_context2.n) {
|
|
35
105
|
case 0:
|
|
36
106
|
if (isNode) {
|
|
37
|
-
|
|
107
|
+
_context2.n = 1;
|
|
38
108
|
break;
|
|
39
109
|
}
|
|
40
110
|
// Written out in full so bundlers (Vite, webpack 5, Parcel) find and bundle the worker script.
|
|
@@ -49,7 +119,7 @@ var start = /*#__PURE__*/function () {
|
|
|
49
119
|
failure: event.message || 'The worker failed to start.'
|
|
50
120
|
});
|
|
51
121
|
});
|
|
52
|
-
return
|
|
122
|
+
return _context2.a(2, {
|
|
53
123
|
post: function post(message, transfer) {
|
|
54
124
|
return _worker.postMessage(message, transfer);
|
|
55
125
|
},
|
|
@@ -60,15 +130,20 @@ var start = /*#__PURE__*/function () {
|
|
|
60
130
|
unref: function unref() {}
|
|
61
131
|
});
|
|
62
132
|
case 1:
|
|
63
|
-
|
|
133
|
+
_context2.n = 2;
|
|
64
134
|
return import(/* webpackIgnore: true */ /* @vite-ignore */['node', 'worker_threads'].join(':'));
|
|
65
135
|
case 2:
|
|
66
|
-
_yield$import =
|
|
136
|
+
_yield$import = _context2.v;
|
|
67
137
|
NodeWorker = _yield$import.Worker;
|
|
68
|
-
|
|
69
|
-
|
|
138
|
+
_t2 = NodeWorker;
|
|
139
|
+
_context2.n = 3;
|
|
140
|
+
return nodeWorkerScript();
|
|
141
|
+
case 3:
|
|
142
|
+
_t3 = _context2.v;
|
|
143
|
+
_t4 = {
|
|
70
144
|
execArgv: []
|
|
71
|
-
}
|
|
145
|
+
};
|
|
146
|
+
worker = new _t2(_t3, _t4);
|
|
72
147
|
worker.on('message', receive);
|
|
73
148
|
worker.on('error', function (error) {
|
|
74
149
|
return receive({
|
|
@@ -81,7 +156,7 @@ var start = /*#__PURE__*/function () {
|
|
|
81
156
|
});
|
|
82
157
|
});
|
|
83
158
|
worker.unref();
|
|
84
|
-
return
|
|
159
|
+
return _context2.a(2, {
|
|
85
160
|
post: function post(message, transfer) {
|
|
86
161
|
return worker.postMessage(message, transfer);
|
|
87
162
|
},
|
|
@@ -96,18 +171,66 @@ var start = /*#__PURE__*/function () {
|
|
|
96
171
|
}
|
|
97
172
|
});
|
|
98
173
|
}
|
|
99
|
-
},
|
|
174
|
+
}, _callee2);
|
|
100
175
|
}));
|
|
101
176
|
return function start(_x) {
|
|
102
|
-
return
|
|
177
|
+
return _ref2.apply(this, arguments);
|
|
103
178
|
};
|
|
104
179
|
}();
|
|
105
180
|
|
|
181
|
+
// Checked by tag as well as `instanceof`, so an ImageData from another realm (an iframe's canvas) or a module compiled by a
|
|
182
|
+
// bundler's runtime is recognised (see index.js).
|
|
183
|
+
var tagOf = function tagOf(value) {
|
|
184
|
+
return Object.prototype.toString.call(value);
|
|
185
|
+
};
|
|
186
|
+
var isImageData = function isImageData(value) {
|
|
187
|
+
return _typeof(value) === 'object' && value !== null && (typeof ImageData !== 'undefined' && value instanceof ImageData || tagOf(value) === '[object ImageData]');
|
|
188
|
+
};
|
|
189
|
+
var isWasmModule = function isWasmModule(value) {
|
|
190
|
+
return _typeof(value) === 'object' && value !== null && (typeof WebAssembly !== 'undefined' && value instanceof WebAssembly.Module || tagOf(value) === '[object WebAssembly.Module]');
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// A copy of the bytes in an argument (a typed array, or an image's `data`), for a call made before the worker is ready to
|
|
194
|
+
// take it: the caller may change or reuse its arrays as soon as the call returns, as with the main entry. Once the worker
|
|
195
|
+
// is running, a call posts (and so copies or transfers) its arguments before it returns.
|
|
196
|
+
var own = function own(value) {
|
|
197
|
+
if (ArrayBuffer.isView(value)) {
|
|
198
|
+
var copy = value.slice();
|
|
199
|
+
// A Palette or Clustering keeps its tags (slice gives a plain array).
|
|
200
|
+
var _iterator = _createForOfIteratorHelper(Object.getOwnPropertySymbols(value)),
|
|
201
|
+
_step;
|
|
202
|
+
try {
|
|
203
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
204
|
+
var key = _step.value;
|
|
205
|
+
Object.defineProperty(copy, key, {
|
|
206
|
+
value: value[key]
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
} catch (err) {
|
|
210
|
+
_iterator.e(err);
|
|
211
|
+
} finally {
|
|
212
|
+
_iterator.f();
|
|
213
|
+
}
|
|
214
|
+
if (Object.prototype.hasOwnProperty.call(value, 'colorSpace')) {
|
|
215
|
+
Object.defineProperty(copy, 'colorSpace', {
|
|
216
|
+
value: value.colorSpace
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
return copy;
|
|
220
|
+
}
|
|
221
|
+
if (isOptionsObject(value) && ArrayBuffer.isView(value.data)) {
|
|
222
|
+
return _objectSpread(_objectSpread({}, value), {}, {
|
|
223
|
+
data: value.data.slice()
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
return value;
|
|
227
|
+
};
|
|
228
|
+
|
|
106
229
|
// Images cross to the worker as plain {data, format, width?, height?} objects (ImageData can't cross into Node
|
|
107
230
|
// worker threads, and its clamped array needn't), and mapped images are rebuilt in the caller's type on return.
|
|
108
231
|
// Anything else is sent as it is, so the worker's validation gives the usual errors.
|
|
109
232
|
var send = function send(image) {
|
|
110
|
-
if (
|
|
233
|
+
if (isImageData(image)) {
|
|
111
234
|
var data = image.data;
|
|
112
235
|
return {
|
|
113
236
|
data: new Uint8Array(data.buffer, data.byteOffset, data.byteLength),
|
|
@@ -135,7 +258,7 @@ var send = function send(image) {
|
|
|
135
258
|
// The worker returns what the main entry gives for the image it was sent: the same type for a Uint8Array or a
|
|
136
259
|
// RawImage, and a RawImage for ImageData, which is turned back into ImageData here.
|
|
137
260
|
var rebuild = function rebuild(image) {
|
|
138
|
-
if (
|
|
261
|
+
if (isImageData(image)) {
|
|
139
262
|
var width = image.width,
|
|
140
263
|
height = image.height,
|
|
141
264
|
colorSpace = image.colorSpace;
|
|
@@ -192,13 +315,13 @@ var wasmOption = function wasmOption(wasm) {
|
|
|
192
315
|
if (typeof wasm === 'string') {
|
|
193
316
|
return wasm;
|
|
194
317
|
}
|
|
195
|
-
if (typeof URL !== 'undefined' && wasm instanceof URL) {
|
|
318
|
+
if (_typeof(wasm) === 'object' && wasm !== null && (typeof URL !== 'undefined' && wasm instanceof URL || tagOf(wasm) === '[object URL]')) {
|
|
196
319
|
return wasm.href;
|
|
197
320
|
}
|
|
198
|
-
if (wasm instanceof ArrayBuffer || ArrayBuffer.isView(wasm)) {
|
|
321
|
+
if (wasm instanceof ArrayBuffer || tagOf(wasm) === '[object ArrayBuffer]' || ArrayBuffer.isView(wasm)) {
|
|
199
322
|
return wasm;
|
|
200
323
|
}
|
|
201
|
-
if (
|
|
324
|
+
if (isWasmModule(wasm)) {
|
|
202
325
|
return wasm;
|
|
203
326
|
}
|
|
204
327
|
throw fail('invalid-argument', "Invalid wasm: must be a URL or path string, a URL, an ArrayBuffer or typed array of the .wasm bytes, or a WebAssembly.Module.", 'options.wasm');
|
|
@@ -323,6 +446,24 @@ export var createWorker = function createWorker(options) {
|
|
|
323
446
|
var nextId = 1;
|
|
324
447
|
var nextHandle = 1;
|
|
325
448
|
var pending = new Map();
|
|
449
|
+
// Whether a call made now is posted before it returns (see `own`).
|
|
450
|
+
var ready = function ready() {
|
|
451
|
+
return connection !== null && !initial;
|
|
452
|
+
};
|
|
453
|
+
// The image of a call made before the worker is ready: with `transfer: true` its buffer is moved out of the caller's
|
|
454
|
+
// hands at once (a structured clone that transfers it, so the caller's array empties now, as it would on posting),
|
|
455
|
+
// otherwise copied.
|
|
456
|
+
var take = function take(sent) {
|
|
457
|
+
var buffers = transfer ? pixelBuffers(sent) : [];
|
|
458
|
+
if (buffers.length > 0 && typeof structuredClone === 'function') {
|
|
459
|
+
try {
|
|
460
|
+
return structuredClone(sent, {
|
|
461
|
+
transfer: buffers
|
|
462
|
+
});
|
|
463
|
+
} catch (error) {/* untransferable: copy it */}
|
|
464
|
+
}
|
|
465
|
+
return own(sent);
|
|
466
|
+
};
|
|
326
467
|
|
|
327
468
|
// Safety net for handles dropped without release(): when a handle is garbage-collected, the worker frees what it
|
|
328
469
|
// kept for it. Best-effort, since collection time is up to the engine; release() or `await using` is the contract.
|
|
@@ -348,18 +489,18 @@ export var createWorker = function createWorker(options) {
|
|
|
348
489
|
}
|
|
349
490
|
var calls = _toConsumableArray(pending.values());
|
|
350
491
|
pending.clear();
|
|
351
|
-
var
|
|
352
|
-
|
|
492
|
+
var _iterator2 = _createForOfIteratorHelper(calls),
|
|
493
|
+
_step2;
|
|
353
494
|
try {
|
|
354
|
-
for (
|
|
355
|
-
var call =
|
|
495
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
496
|
+
var call = _step2.value;
|
|
356
497
|
call.cleanup();
|
|
357
498
|
call.reject(fail('worker-failed', reason));
|
|
358
499
|
}
|
|
359
500
|
} catch (err) {
|
|
360
|
-
|
|
501
|
+
_iterator2.e(err);
|
|
361
502
|
} finally {
|
|
362
|
-
|
|
503
|
+
_iterator2.f();
|
|
363
504
|
}
|
|
364
505
|
if (lost) {
|
|
365
506
|
try {
|
|
@@ -414,24 +555,24 @@ export var createWorker = function createWorker(options) {
|
|
|
414
555
|
// `origin` is an Error made in the caller's own (non-async) function, for the stack of a failure: async helpers
|
|
415
556
|
// from transpiled code would otherwise fill the stack's frame limit before the caller shows up.
|
|
416
557
|
var invoke = /*#__PURE__*/function () {
|
|
417
|
-
var
|
|
558
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(method, args, transferable, origin) {
|
|
418
559
|
var controls,
|
|
419
560
|
mine,
|
|
420
561
|
waitingFor,
|
|
421
562
|
started,
|
|
422
|
-
|
|
423
|
-
return _regenerator().w(function (
|
|
424
|
-
while (1) switch (
|
|
563
|
+
_args3 = arguments;
|
|
564
|
+
return _regenerator().w(function (_context3) {
|
|
565
|
+
while (1) switch (_context3.n) {
|
|
425
566
|
case 0:
|
|
426
|
-
controls =
|
|
567
|
+
controls = _args3.length > 4 && _args3[4] !== undefined ? _args3[4] : {};
|
|
427
568
|
if (!terminated) {
|
|
428
|
-
|
|
569
|
+
_context3.n = 1;
|
|
429
570
|
break;
|
|
430
571
|
}
|
|
431
572
|
throw fail('worker-terminated', "Worker terminated.");
|
|
432
573
|
case 1:
|
|
433
574
|
if (connection) {
|
|
434
|
-
|
|
575
|
+
_context3.n = 5;
|
|
435
576
|
break;
|
|
436
577
|
}
|
|
437
578
|
if (!starting) {
|
|
@@ -452,19 +593,19 @@ export var createWorker = function createWorker(options) {
|
|
|
452
593
|
});
|
|
453
594
|
}
|
|
454
595
|
waitingFor = startingGeneration;
|
|
455
|
-
|
|
596
|
+
_context3.n = 2;
|
|
456
597
|
return starting;
|
|
457
598
|
case 2:
|
|
458
|
-
started =
|
|
599
|
+
started = _context3.v;
|
|
459
600
|
if (!terminated) {
|
|
460
|
-
|
|
601
|
+
_context3.n = 3;
|
|
461
602
|
break;
|
|
462
603
|
}
|
|
463
604
|
started.terminate();
|
|
464
605
|
throw fail('worker-terminated', "Worker terminated.");
|
|
465
606
|
case 3:
|
|
466
607
|
if (!(waitingFor !== generation)) {
|
|
467
|
-
|
|
608
|
+
_context3.n = 4;
|
|
468
609
|
break;
|
|
469
610
|
}
|
|
470
611
|
throw fail('worker-failed', 'Worker failed while starting.');
|
|
@@ -472,7 +613,7 @@ export var createWorker = function createWorker(options) {
|
|
|
472
613
|
connection = connection || started;
|
|
473
614
|
case 5:
|
|
474
615
|
if (!(initial && !(method === 'init' && args.length > 0 && args[0].wasm !== undefined))) {
|
|
475
|
-
|
|
616
|
+
_context3.n = 6;
|
|
476
617
|
break;
|
|
477
618
|
}
|
|
478
619
|
initialising = initialising || post('init', [initial], [], origin).then(function () {
|
|
@@ -481,21 +622,21 @@ export var createWorker = function createWorker(options) {
|
|
|
481
622
|
initialising = null;
|
|
482
623
|
throw error;
|
|
483
624
|
});
|
|
484
|
-
|
|
625
|
+
_context3.n = 6;
|
|
485
626
|
return initialising;
|
|
486
627
|
case 6:
|
|
487
|
-
return
|
|
628
|
+
return _context3.a(2, post(method, args, transferable, origin, controls));
|
|
488
629
|
}
|
|
489
|
-
},
|
|
630
|
+
}, _callee3);
|
|
490
631
|
}));
|
|
491
632
|
return function invoke(_x2, _x3, _x4, _x5) {
|
|
492
|
-
return
|
|
633
|
+
return _ref3.apply(this, arguments);
|
|
493
634
|
};
|
|
494
635
|
}();
|
|
495
636
|
var post = function post(method, args, transferable, origin) {
|
|
496
|
-
var
|
|
497
|
-
signal =
|
|
498
|
-
onProgress =
|
|
637
|
+
var _ref4 = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {},
|
|
638
|
+
signal = _ref4.signal,
|
|
639
|
+
onProgress = _ref4.onProgress;
|
|
499
640
|
if (terminated) {
|
|
500
641
|
return Promise.reject(fail('worker-terminated', "Worker terminated."));
|
|
501
642
|
}
|
|
@@ -580,15 +721,15 @@ export var createWorker = function createWorker(options) {
|
|
|
580
721
|
rest[_key - 1] = arguments[_key];
|
|
581
722
|
}
|
|
582
723
|
var origin = new Error();
|
|
583
|
-
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
724
|
+
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
584
725
|
var position, _takeControls, options, signal, onProgress, args, sent, result;
|
|
585
|
-
return _regenerator().w(function (
|
|
586
|
-
while (1) switch (
|
|
726
|
+
return _regenerator().w(function (_context4) {
|
|
727
|
+
while (1) switch (_context4.n) {
|
|
587
728
|
case 0:
|
|
588
729
|
position = optionsPosition[name];
|
|
589
730
|
_takeControls = takeControls(rest[position], !mappingOnlyFunctions.includes(name)), options = _takeControls.options, signal = _takeControls.signal, onProgress = _takeControls.onProgress; // Checked before the image is copied or transferred away, so an aborted call leaves it with the caller.
|
|
590
731
|
if (!(signal && signal.aborted)) {
|
|
591
|
-
|
|
732
|
+
_context4.n = 1;
|
|
592
733
|
break;
|
|
593
734
|
}
|
|
594
735
|
throw abortReason(signal);
|
|
@@ -598,16 +739,20 @@ export var createWorker = function createWorker(options) {
|
|
|
598
739
|
args[position] = options;
|
|
599
740
|
}
|
|
600
741
|
sent = send(image);
|
|
601
|
-
|
|
742
|
+
if (!ready()) {
|
|
743
|
+
sent = take(sent);
|
|
744
|
+
args = args.map(own);
|
|
745
|
+
}
|
|
746
|
+
_context4.n = 2;
|
|
602
747
|
return invoke(name, [sent].concat(_toConsumableArray(args)), pixelBuffers(sent), origin, {
|
|
603
748
|
signal: signal,
|
|
604
749
|
onProgress: onProgress
|
|
605
750
|
});
|
|
606
751
|
case 2:
|
|
607
|
-
result =
|
|
608
|
-
return
|
|
752
|
+
result = _context4.v;
|
|
753
|
+
return _context4.a(2, mapped ? rebuild(image)(result) : result);
|
|
609
754
|
}
|
|
610
|
-
},
|
|
755
|
+
}, _callee4);
|
|
611
756
|
}))();
|
|
612
757
|
};
|
|
613
758
|
};
|
|
@@ -620,7 +765,7 @@ export var createWorker = function createWorker(options) {
|
|
|
620
765
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
621
766
|
args[_key2] = arguments[_key2];
|
|
622
767
|
}
|
|
623
|
-
return invoke(name, args, [], new Error());
|
|
768
|
+
return invoke(name, ready() ? args : args.map(own), [], new Error());
|
|
624
769
|
};
|
|
625
770
|
};
|
|
626
771
|
for (var _i4 = 0, _otherFunctions = otherFunctions; _i4 < _otherFunctions.length; _i4++) {
|
|
@@ -642,39 +787,39 @@ export var createWorker = function createWorker(options) {
|
|
|
642
787
|
// Clusters `image` and keeps it, with its clustering, in the worker.
|
|
643
788
|
instance.cluster = function (image, clusterOptions) {
|
|
644
789
|
var origin = new Error();
|
|
645
|
-
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
646
|
-
var _takeControls2, options, signal, onProgress, id, sent, output, released, use, withControls, handle,
|
|
647
|
-
return _regenerator().w(function (
|
|
648
|
-
while (1) switch (
|
|
790
|
+
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
791
|
+
var _takeControls2, options, signal, onProgress, id, sent, output, released, use, withControls, handle, _t0;
|
|
792
|
+
return _regenerator().w(function (_context8) {
|
|
793
|
+
while (1) switch (_context8.n) {
|
|
649
794
|
case 0:
|
|
650
795
|
_takeControls2 = takeControls(clusterOptions), options = _takeControls2.options, signal = _takeControls2.signal, onProgress = _takeControls2.onProgress;
|
|
651
796
|
if (!(signal && signal.aborted)) {
|
|
652
|
-
|
|
797
|
+
_context8.n = 1;
|
|
653
798
|
break;
|
|
654
799
|
}
|
|
655
800
|
throw abortReason(signal);
|
|
656
801
|
case 1:
|
|
657
802
|
id = nextHandle++;
|
|
658
|
-
sent = send(image);
|
|
659
|
-
|
|
660
|
-
|
|
803
|
+
sent = ready() ? send(image) : take(send(image));
|
|
804
|
+
_context8.p = 2;
|
|
805
|
+
_context8.n = 3;
|
|
661
806
|
return invoke('cluster', [id, sent, options], pixelBuffers(sent), origin, {
|
|
662
807
|
signal: signal,
|
|
663
808
|
onProgress: onProgress
|
|
664
809
|
});
|
|
665
810
|
case 3:
|
|
666
|
-
|
|
811
|
+
_context8.n = 5;
|
|
667
812
|
break;
|
|
668
813
|
case 4:
|
|
669
|
-
|
|
670
|
-
|
|
814
|
+
_context8.p = 4;
|
|
815
|
+
_t0 = _context8.v;
|
|
671
816
|
// A cancelled call is rejected at once, but the worker may have finished it just before it heard: it
|
|
672
817
|
// would then keep the image and clustering with nobody able to release them. Releasing an unknown handle
|
|
673
818
|
// is harmless, and this message follows the cluster call in the worker's queue.
|
|
674
819
|
if (!terminated) {
|
|
675
820
|
invoke('release', [id], [], new Error())["catch"](function () {});
|
|
676
821
|
}
|
|
677
|
-
throw
|
|
822
|
+
throw _t0;
|
|
678
823
|
case 5:
|
|
679
824
|
output = rebuild(image);
|
|
680
825
|
released = false; // Every method goes through `use`, which refers to `handle`, so a method kept after the handle itself is dropped
|
|
@@ -711,19 +856,19 @@ export var createWorker = function createWorker(options) {
|
|
|
711
856
|
return use('handleGetClusteringInfo', []);
|
|
712
857
|
},
|
|
713
858
|
quantize: function () {
|
|
714
|
-
var _quantize = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
715
|
-
var
|
|
716
|
-
return _regenerator().w(function (
|
|
717
|
-
while (1) switch (
|
|
859
|
+
var _quantize = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(k, mapOptions) {
|
|
860
|
+
var _t5, _t6;
|
|
861
|
+
return _regenerator().w(function (_context5) {
|
|
862
|
+
while (1) switch (_context5.n) {
|
|
718
863
|
case 0:
|
|
719
|
-
|
|
720
|
-
|
|
864
|
+
_t5 = output;
|
|
865
|
+
_context5.n = 1;
|
|
721
866
|
return withControls('handleQuantize', [k], mapOptions);
|
|
722
867
|
case 1:
|
|
723
|
-
|
|
724
|
-
return
|
|
868
|
+
_t6 = _context5.v;
|
|
869
|
+
return _context5.a(2, _t5(_t6));
|
|
725
870
|
}
|
|
726
|
-
},
|
|
871
|
+
}, _callee5);
|
|
727
872
|
}));
|
|
728
873
|
function quantize(_x6, _x7) {
|
|
729
874
|
return _quantize.apply(this, arguments);
|
|
@@ -734,19 +879,19 @@ export var createWorker = function createWorker(options) {
|
|
|
734
879
|
return withControls('handleQuantizeToIndices', [k], mapOptions);
|
|
735
880
|
},
|
|
736
881
|
quantizeWithPalette: function () {
|
|
737
|
-
var _quantizeWithPalette = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
738
|
-
var
|
|
739
|
-
return _regenerator().w(function (
|
|
740
|
-
while (1) switch (
|
|
882
|
+
var _quantizeWithPalette = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(palette, mapOptions) {
|
|
883
|
+
var _t7, _t8;
|
|
884
|
+
return _regenerator().w(function (_context6) {
|
|
885
|
+
while (1) switch (_context6.n) {
|
|
741
886
|
case 0:
|
|
742
|
-
|
|
743
|
-
|
|
887
|
+
_t7 = output;
|
|
888
|
+
_context6.n = 1;
|
|
744
889
|
return withControls('handleQuantizeWithPalette', [palette], mapOptions);
|
|
745
890
|
case 1:
|
|
746
|
-
|
|
747
|
-
return
|
|
891
|
+
_t8 = _context6.v;
|
|
892
|
+
return _context6.a(2, _t7(_t8));
|
|
748
893
|
}
|
|
749
|
-
},
|
|
894
|
+
}, _callee6);
|
|
750
895
|
}));
|
|
751
896
|
function quantizeWithPalette(_x8, _x9) {
|
|
752
897
|
return _quantizeWithPalette.apply(this, arguments);
|
|
@@ -757,16 +902,16 @@ export var createWorker = function createWorker(options) {
|
|
|
757
902
|
return withControls('handleQuantizeToIndicesWithPalette', [palette], mapOptions);
|
|
758
903
|
},
|
|
759
904
|
release: function () {
|
|
760
|
-
var _release = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
761
|
-
var
|
|
762
|
-
return _regenerator().w(function (
|
|
763
|
-
while (1) switch (
|
|
905
|
+
var _release = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
906
|
+
var _t9;
|
|
907
|
+
return _regenerator().w(function (_context7) {
|
|
908
|
+
while (1) switch (_context7.n) {
|
|
764
909
|
case 0:
|
|
765
910
|
if (!released) {
|
|
766
|
-
|
|
911
|
+
_context7.n = 1;
|
|
767
912
|
break;
|
|
768
913
|
}
|
|
769
|
-
return
|
|
914
|
+
return _context7.a(2);
|
|
770
915
|
case 1:
|
|
771
916
|
released = true;
|
|
772
917
|
if (reclaim) {
|
|
@@ -774,24 +919,24 @@ export var createWorker = function createWorker(options) {
|
|
|
774
919
|
}
|
|
775
920
|
// If the worker has been terminated there is nothing left to free (so `await using` and
|
|
776
921
|
// terminate() can come in either order); any other failure is reported.
|
|
777
|
-
|
|
778
|
-
|
|
922
|
+
_context7.p = 2;
|
|
923
|
+
_context7.n = 3;
|
|
779
924
|
return invoke('release', [id], [], new Error());
|
|
780
925
|
case 3:
|
|
781
|
-
|
|
926
|
+
_context7.n = 5;
|
|
782
927
|
break;
|
|
783
928
|
case 4:
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
if (!(
|
|
787
|
-
|
|
929
|
+
_context7.p = 4;
|
|
930
|
+
_t9 = _context7.v;
|
|
931
|
+
if (!(_t9.code !== 'worker-terminated')) {
|
|
932
|
+
_context7.n = 5;
|
|
788
933
|
break;
|
|
789
934
|
}
|
|
790
|
-
throw
|
|
935
|
+
throw _t9;
|
|
791
936
|
case 5:
|
|
792
|
-
return
|
|
937
|
+
return _context7.a(2);
|
|
793
938
|
}
|
|
794
|
-
},
|
|
939
|
+
}, _callee7, null, [[2, 4]]);
|
|
795
940
|
}));
|
|
796
941
|
function release() {
|
|
797
942
|
return _release.apply(this, arguments);
|
|
@@ -805,66 +950,66 @@ export var createWorker = function createWorker(options) {
|
|
|
805
950
|
if (reclaim) {
|
|
806
951
|
reclaim.register(handle, id, handle);
|
|
807
952
|
}
|
|
808
|
-
return
|
|
953
|
+
return _context8.a(2, handle);
|
|
809
954
|
}
|
|
810
|
-
},
|
|
955
|
+
}, _callee8, null, [[2, 4]]);
|
|
811
956
|
}))();
|
|
812
957
|
};
|
|
813
958
|
|
|
814
959
|
// Stops the worker. Calls still waiting are rejected, and later calls fail.
|
|
815
|
-
instance.terminate = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
816
|
-
var
|
|
817
|
-
return _regenerator().w(function (
|
|
818
|
-
while (1) switch (
|
|
960
|
+
instance.terminate = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
|
|
961
|
+
var _iterator3, _step3, call, _t1;
|
|
962
|
+
return _regenerator().w(function (_context9) {
|
|
963
|
+
while (1) switch (_context9.n) {
|
|
819
964
|
case 0:
|
|
820
965
|
if (!terminated) {
|
|
821
|
-
|
|
966
|
+
_context9.n = 1;
|
|
822
967
|
break;
|
|
823
968
|
}
|
|
824
|
-
return
|
|
969
|
+
return _context9.a(2);
|
|
825
970
|
case 1:
|
|
826
971
|
terminated = true;
|
|
827
|
-
|
|
972
|
+
_iterator3 = _createForOfIteratorHelper(pending.values());
|
|
828
973
|
try {
|
|
829
|
-
for (
|
|
830
|
-
call =
|
|
974
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
975
|
+
call = _step3.value;
|
|
831
976
|
call.cleanup();
|
|
832
977
|
call.reject(fail('worker-terminated', "Worker terminated."));
|
|
833
978
|
}
|
|
834
979
|
} catch (err) {
|
|
835
|
-
|
|
980
|
+
_iterator3.e(err);
|
|
836
981
|
} finally {
|
|
837
|
-
|
|
982
|
+
_iterator3.f();
|
|
838
983
|
}
|
|
839
984
|
pending.clear();
|
|
840
985
|
if (!connection) {
|
|
841
|
-
|
|
986
|
+
_context9.n = 3;
|
|
842
987
|
break;
|
|
843
988
|
}
|
|
844
|
-
|
|
989
|
+
_context9.n = 2;
|
|
845
990
|
return connection.terminate();
|
|
846
991
|
case 2:
|
|
847
|
-
|
|
992
|
+
_context9.n = 7;
|
|
848
993
|
break;
|
|
849
994
|
case 3:
|
|
850
995
|
if (!starting) {
|
|
851
|
-
|
|
996
|
+
_context9.n = 7;
|
|
852
997
|
break;
|
|
853
998
|
}
|
|
854
|
-
|
|
855
|
-
|
|
999
|
+
_context9.p = 4;
|
|
1000
|
+
_context9.n = 5;
|
|
856
1001
|
return starting;
|
|
857
1002
|
case 5:
|
|
858
|
-
|
|
859
|
-
|
|
1003
|
+
_context9.v.terminate();
|
|
1004
|
+
_context9.n = 7;
|
|
860
1005
|
break;
|
|
861
1006
|
case 6:
|
|
862
|
-
|
|
863
|
-
|
|
1007
|
+
_context9.p = 6;
|
|
1008
|
+
_t1 = _context9.v;
|
|
864
1009
|
case 7:
|
|
865
|
-
return
|
|
1010
|
+
return _context9.a(2);
|
|
866
1011
|
}
|
|
867
|
-
},
|
|
1012
|
+
}, _callee9, null, [[4, 6]]);
|
|
868
1013
|
}));
|
|
869
1014
|
return instance;
|
|
870
1015
|
};
|
|
@@ -875,28 +1020,28 @@ var sharedWorker = function sharedWorker() {
|
|
|
875
1020
|
|
|
876
1021
|
// Stops the shared worker, rejecting calls still waiting. The next call starts a fresh one.
|
|
877
1022
|
export var terminate = /*#__PURE__*/function () {
|
|
878
|
-
var
|
|
1023
|
+
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
|
|
879
1024
|
var stopping;
|
|
880
|
-
return _regenerator().w(function (
|
|
881
|
-
while (1) switch (
|
|
1025
|
+
return _regenerator().w(function (_context0) {
|
|
1026
|
+
while (1) switch (_context0.n) {
|
|
882
1027
|
case 0:
|
|
883
1028
|
if (shared) {
|
|
884
|
-
|
|
1029
|
+
_context0.n = 1;
|
|
885
1030
|
break;
|
|
886
1031
|
}
|
|
887
|
-
return
|
|
1032
|
+
return _context0.a(2);
|
|
888
1033
|
case 1:
|
|
889
1034
|
stopping = shared;
|
|
890
1035
|
shared = null;
|
|
891
|
-
|
|
1036
|
+
_context0.n = 2;
|
|
892
1037
|
return stopping.terminate();
|
|
893
1038
|
case 2:
|
|
894
|
-
return
|
|
1039
|
+
return _context0.a(2);
|
|
895
1040
|
}
|
|
896
|
-
},
|
|
1041
|
+
}, _callee0);
|
|
897
1042
|
}));
|
|
898
1043
|
return function terminate() {
|
|
899
|
-
return
|
|
1044
|
+
return _ref8.apply(this, arguments);
|
|
900
1045
|
};
|
|
901
1046
|
}();
|
|
902
1047
|
export var init = function init() {
|