@loaders.gl/core 5.0.0-beta.4 → 5.0.0-beta.5
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/GEOARROW-README.md +1 -1
- package/README.md +1 -1
- package/SCAN-README.md +1 -1
- package/SCHEMA-UTILS-README.md +1 -1
- package/dist/arrow-geometry/binary-geometry-to-wkb.cjs +2 -2
- package/dist/arrow-geometry/binary-geometry-to-wkb.cjs.map +2 -2
- package/dist/arrow-geometry/binary-geometry-to-wkb.js +1 -1
- package/dist/arrow-geometry/binary-geometry-to-wkb.js.map +1 -1
- package/dist/arrow-geometry/geojson-table.cjs +3 -3
- package/dist/arrow-geometry/geojson-table.cjs.map +2 -2
- package/dist/arrow-geometry/geojson-table.js +2 -2
- package/dist/arrow-geometry/geojson-table.js.map +1 -1
- package/dist/arrow-geometry/geometry-codecs.cjs +6 -6
- package/dist/arrow-geometry/geometry-codecs.cjs.map +2 -2
- package/dist/arrow-geometry/geometry-codecs.js +1 -1
- package/dist/arrow-geometry/geometry-codecs.js.map +1 -1
- package/dist/arrow-geometry/geometry-to-wkt.cjs +2 -2
- package/dist/arrow-geometry/geometry-to-wkt.cjs.map +2 -2
- package/dist/arrow-geometry/geometry-to-wkt.js +1 -1
- package/dist/arrow-geometry/geometry-to-wkt.js.map +1 -1
- package/dist/arrow-geometry/index.cjs +0 -11
- package/dist/arrow-geometry/index.cjs.map +2 -2
- package/dist/arrow-geometry/index.d.ts +0 -1
- package/dist/arrow-geometry/index.d.ts.map +1 -1
- package/dist/arrow-geometry/index.js +0 -1
- package/dist/arrow-geometry/index.js.map +1 -1
- package/dist/arrow-geometry/wkb-builder.cjs +3 -3
- package/dist/arrow-geometry/wkb-builder.cjs.map +2 -2
- package/dist/arrow-geometry/wkb-builder.d.ts +1 -1
- package/dist/arrow-geometry/wkb-builder.d.ts.map +1 -1
- package/dist/arrow-geometry/wkb-builder.js +1 -1
- package/dist/arrow-geometry/wkb-builder.js.map +1 -1
- package/dist/arrow-geometry/wkb-statistics.cjs +2 -2
- package/dist/arrow-geometry/wkb-statistics.cjs.map +2 -2
- package/dist/arrow-geometry/wkb-statistics.js +1 -1
- package/dist/arrow-geometry/wkb-statistics.js.map +1 -1
- package/dist/arrow-worker-transport.cjs +81 -0
- package/dist/arrow-worker-transport.cjs.map +6 -0
- package/dist/arrow-worker-transport.d.ts +9 -0
- package/dist/arrow-worker-transport.d.ts.map +1 -0
- package/dist/arrow-worker-transport.js +60 -0
- package/dist/arrow-worker-transport.js.map +1 -0
- package/dist/cluster-source.cjs +153 -584
- package/dist/cluster-source.cjs.map +3 -3
- package/dist/dist.dev.js +546 -54
- package/dist/dist.min.js +3 -3
- package/dist/geoarrow/binary-polygon-to-geoarrow.cjs +2 -2
- package/dist/geoarrow/binary-polygon-to-geoarrow.cjs.map +2 -2
- package/dist/geoarrow/binary-polygon-to-geoarrow.d.ts +1 -1
- package/dist/geoarrow/binary-polygon-to-geoarrow.d.ts.map +1 -1
- package/dist/geoarrow/binary-polygon-to-geoarrow.js +1 -1
- package/dist/geoarrow/binary-polygon-to-geoarrow.js.map +1 -1
- package/dist/geoarrow/geoarrow-bounds.cjs +7 -7
- package/dist/geoarrow/geoarrow-bounds.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-bounds.js +3 -3
- package/dist/geoarrow/geoarrow-bounds.js.map +1 -1
- package/dist/geoarrow/geoarrow-capabilities.cjs +2 -2
- package/dist/geoarrow/geoarrow-capabilities.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-capabilities.js +1 -1
- package/dist/geoarrow/geoarrow-capabilities.js.map +1 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.cjs +8 -8
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.js +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.js.map +1 -1
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.d.ts +2 -2
- package/dist/geoarrow/geoarrow-inspection.cjs +2 -2
- package/dist/geoarrow/geoarrow-inspection.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-inspection.js +1 -1
- package/dist/geoarrow/geoarrow-inspection.js.map +1 -1
- package/dist/geoarrow/geoarrow-stream.cjs +1 -1
- package/dist/geoarrow/geoarrow-stream.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-stream.js +1 -1
- package/dist/geoarrow/geoarrow-stream.js.map +1 -1
- package/dist/geoarrow/get-geoarrow-vertex-count.cjs +2 -2
- package/dist/geoarrow/get-geoarrow-vertex-count.cjs.map +2 -2
- package/dist/geoarrow/get-geoarrow-vertex-count.js +1 -1
- package/dist/geoarrow/get-geoarrow-vertex-count.js.map +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.cjs +4 -4
- package/dist/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.cjs.map +2 -2
- package/dist/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.js +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.js.map +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.cjs +3 -3
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.cjs.map +2 -2
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.js +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.js.map +1 -1
- package/dist/geoarrow/lib/kernels/encode-geoarrow-box.cjs +3 -3
- package/dist/geoarrow/lib/kernels/encode-geoarrow-box.cjs.map +2 -2
- package/dist/geoarrow/lib/kernels/encode-geoarrow-box.js +1 -1
- package/dist/geoarrow/lib/kernels/encode-geoarrow-box.js.map +1 -1
- package/dist/index.cjs +8 -11
- package/dist/index.cjs.map +3 -3
- package/dist/lib/init.js +1 -1
- package/dist/loader-utils/index.cjs +20 -23
- package/dist/loader-utils/index.cjs.map +3 -3
- package/dist/loader-utils/index.js +1 -1
- package/dist/loader-utils/json-loader.js +1 -1
- package/dist/loader-utils/lib/log-utils/log.js +1 -1
- package/dist/null-loader.js +1 -1
- package/dist/null-worker-node.js +244 -11
- package/dist/null-worker.js +239 -11
- package/dist/schema/geometry/geoarrow.d.ts +3 -6
- package/dist/schema/geometry/geoarrow.d.ts.map +1 -1
- package/dist/worker-utils/index.cjs +19 -26
- package/dist/worker-utils/index.cjs.map +3 -3
- package/dist/worker-utils/index.d.ts +0 -3
- package/dist/worker-utils/index.d.ts.map +1 -1
- package/dist/worker-utils/index.js +0 -3
- package/dist/worker-utils/index.js.map +1 -1
- package/dist/worker-utils/lib/env-utils/version.js +1 -1
- package/dist/worker-utils/lib/worker-api/process-on-worker.d.ts +1 -1
- package/dist/worker-utils/lib/worker-api/process-on-worker.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-api/process-on-worker.js +1 -1
- package/dist/worker-utils/lib/worker-api/process-on-worker.js.map +1 -1
- package/dist/worker-utils/lib/worker-api/task-runtime.d.ts +1 -1
- package/dist/worker-utils/lib/worker-api/task-runtime.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-api/task-runtime.js +1 -1
- package/dist/worker-utils/lib/worker-api/task-runtime.js.map +1 -1
- package/dist/worker-utils/null-worker-node.js +243 -10
- package/dist/worker-utils/null-worker-node.js.map +4 -4
- package/dist/worker-utils/null-worker.js +238 -10
- package/dist/worker-utils/null-worker.js.map +4 -4
- package/dist/worker-utils/types.d.ts +1 -1
- package/dist/worker-utils/types.d.ts.map +1 -1
- package/package.json +13 -11
- package/src/arrow-geometry/binary-geometry-to-wkb.ts +1 -1
- package/src/arrow-geometry/geojson-table.ts +2 -2
- package/src/arrow-geometry/geometry-codecs.ts +2 -2
- package/src/arrow-geometry/geometry-to-wkt.ts +2 -2
- package/src/arrow-geometry/index.ts +0 -9
- package/src/arrow-geometry/wkb-builder.ts +2 -2
- package/src/arrow-geometry/wkb-statistics.ts +2 -2
- package/src/arrow-worker-transport.ts +87 -0
- package/src/geoarrow/binary-polygon-to-geoarrow.ts +2 -2
- package/src/geoarrow/geoarrow-bounds.ts +3 -3
- package/src/geoarrow/geoarrow-capabilities.ts +1 -1
- package/src/geoarrow/geoarrow-converter/convert-geoarrow-geometry.ts +3 -3
- package/src/geoarrow/geoarrow-inspection.ts +2 -2
- package/src/geoarrow/geoarrow-stream.ts +1 -1
- package/src/geoarrow/get-geoarrow-vertex-count.ts +1 -1
- package/src/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.ts +1 -1
- package/src/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.ts +2 -2
- package/src/geoarrow/lib/kernels/encode-geoarrow-box.ts +1 -1
- package/src/loader-utils/index.ts +1 -1
- package/src/schema/geometry/geoarrow.ts +8 -19
- package/src/worker-utils/index.ts +0 -16
- package/src/worker-utils/lib/worker-api/create-worker.ts +1 -1
- package/src/worker-utils/lib/worker-api/process-on-worker.ts +1 -6
- package/src/worker-utils/lib/worker-api/task-runtime.ts +1 -1
- package/src/worker-utils/types.ts +1 -1
- package/dist/arrow-geometry/arrow-geoarrow-adapter.cjs +0 -477
- package/dist/arrow-geometry/arrow-geoarrow-adapter.cjs.map +0 -7
- package/dist/arrow-geometry/arrow-geoarrow-adapter.d.ts +0 -29
- package/dist/arrow-geometry/arrow-geoarrow-adapter.d.ts.map +0 -1
- package/dist/arrow-geometry/arrow-geoarrow-adapter.js +0 -434
- package/dist/arrow-geometry/arrow-geoarrow-adapter.js.map +0 -1
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.cjs +0 -39
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.cjs.map +0 -7
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.d.ts +0 -2
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.d.ts.map +0 -1
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.js +0 -5
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.js.map +0 -1
- package/dist/schema-utils/arrow-transport.cjs +0 -691
- package/dist/schema-utils/arrow-transport.cjs.map +0 -6
- package/dist/schema-utils/arrow-transport.d.ts +0 -4
- package/dist/schema-utils/arrow-transport.d.ts.map +0 -1
- package/dist/schema-utils/arrow-transport.js +0 -7
- package/dist/schema-utils/arrow-transport.js.map +0 -1
- package/dist/schema-utils/lib/arrow/arrow-table-transport.d.ts +0 -76
- package/dist/schema-utils/lib/arrow/arrow-table-transport.d.ts.map +0 -1
- package/dist/schema-utils/lib/arrow/arrow-table-transport.js +0 -182
- package/dist/schema-utils/lib/arrow/arrow-table-transport.js.map +0 -1
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.d.ts +0 -33
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.d.ts.map +0 -1
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.js +0 -134
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.js.map +0 -1
- package/src/arrow-geometry/arrow-geoarrow-adapter.ts +0 -568
- package/src/geoarrow/lib/arrow-geoarrow-adapter.ts +0 -12
- package/src/schema-utils/arrow-transport.ts +0 -7
- package/src/schema-utils/lib/arrow/arrow-table-transport.ts +0 -282
- package/src/schema-utils/lib/arrow/split-arrow-buffers.ts +0 -247
|
@@ -12,7 +12,7 @@ export { mergeOptions, getRequiredOptions } from "./lib/option-utils/merge-optio
|
|
|
12
12
|
export { initializeWasmModule } from "./lib/module-utils/initialize-wasm-module.js";
|
|
13
13
|
export { registerJSModules } from "./lib/module-utils/js-module-utils.js";
|
|
14
14
|
export { checkJSModule, getJSModule, getJSModuleOrNull } from "./lib/module-utils/js-module-utils.js";
|
|
15
|
-
//
|
|
15
|
+
// loaders.gl-SPECIFIC WORKER UTILS
|
|
16
16
|
export { createLoaderWorker, processLoaderWorkerBatches } from "./lib/worker-loader-utils/create-loader-worker.js";
|
|
17
17
|
export { parseWithWorker, parseWithWorkerInBatches, canParseWithWorker, canParseWithWorkerInBatches, shouldParseWithWorker } from "./lib/worker-loader-utils/parse-with-worker.js";
|
|
18
18
|
export { canEncodeWithWorker } from "./lib/worker-loader-utils/encode-with-worker.js";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
5
5
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
6
|
-
const VERSION = typeof "5.0.0-beta.
|
|
6
|
+
const VERSION = typeof "5.0.0-beta.5" !== 'undefined' ? "5.0.0-beta.5" : 'latest';
|
|
7
7
|
/**
|
|
8
8
|
* A JSON Micro loader (minimal bundle size)
|
|
9
9
|
* Alternative to `@loaders.gl/tables/json`
|
|
@@ -5,7 +5,7 @@ import { Log } from 'probe.gl/log';
|
|
|
5
5
|
// Version constant cannot be imported, it needs to correspond to the build version of **this** module.
|
|
6
6
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
7
7
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
8
|
-
export const VERSION = typeof "5.0.0-beta.
|
|
8
|
+
export const VERSION = typeof "5.0.0-beta.5" !== 'undefined' ? "5.0.0-beta.5" : 'latest';
|
|
9
9
|
const version = VERSION[0] >= '0' && VERSION[0] <= '9' ? `v${VERSION}` : '';
|
|
10
10
|
// Make sure we set the global variable
|
|
11
11
|
function createLog() {
|
package/dist/null-loader.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
5
5
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
6
|
-
const VERSION = typeof "5.0.0-beta.
|
|
6
|
+
const VERSION = typeof "5.0.0-beta.5" !== 'undefined' ? "5.0.0-beta.5" : 'latest';
|
|
7
7
|
/**
|
|
8
8
|
* Loads any data and returns null (or optionally passes through data unparsed)
|
|
9
9
|
*/
|
package/dist/null-worker-node.js
CHANGED
|
@@ -76,11 +76,11 @@ var init_worker_threads = __esm({
|
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
// ../../node_modules/@math.gl/
|
|
79
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/node/worker_threads.js
|
|
80
80
|
var import_worker_threads = require("worker_threads");
|
|
81
81
|
var parentPort = import_worker_threads.parentPort;
|
|
82
82
|
|
|
83
|
-
// ../../node_modules/@math.gl/
|
|
83
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-transfer-list.js
|
|
84
84
|
function getTransferList(object, recursive = true, transfers) {
|
|
85
85
|
const transfersSet = transfers || /* @__PURE__ */ new Set();
|
|
86
86
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -131,7 +131,7 @@ function isTransferable(object) {
|
|
|
131
131
|
return false;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
// ../../node_modules/@math.gl/
|
|
134
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-body.js
|
|
135
135
|
async function getParentPort() {
|
|
136
136
|
return parentPort;
|
|
137
137
|
}
|
|
@@ -218,7 +218,7 @@ function getWorkerMessageData(message) {
|
|
|
218
218
|
return messageData && typeof messageData.source === "string" && messageData.source.startsWith("loaders.gl") ? messageData : null;
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
// ../../node_modules/@math.gl/
|
|
221
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/async-queue/async-queue.js
|
|
222
222
|
var AsyncQueue = class {
|
|
223
223
|
constructor() {
|
|
224
224
|
this._values = [];
|
|
@@ -285,7 +285,7 @@ var AsyncQueue = class {
|
|
|
285
285
|
}
|
|
286
286
|
};
|
|
287
287
|
|
|
288
|
-
// ../../node_modules/@math.gl/
|
|
288
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/shared-state.js
|
|
289
289
|
var SharedWorkerState = class {
|
|
290
290
|
constructor(buffer) {
|
|
291
291
|
if (typeof SharedArrayBuffer === "undefined" || !(buffer instanceof SharedArrayBuffer) || buffer.byteLength !== 16)
|
|
@@ -324,14 +324,14 @@ var SharedWorkerState = class {
|
|
|
324
324
|
}
|
|
325
325
|
};
|
|
326
326
|
|
|
327
|
-
// ../../node_modules/@math.gl/
|
|
327
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js
|
|
328
328
|
function validateOutputOwnership(ownership) {
|
|
329
329
|
if (ownership !== void 0 && ownership !== "copy" && ownership !== "transfer") {
|
|
330
330
|
throw new Error("Invalid worker output ownership");
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
-
// ../../node_modules/@math.gl/
|
|
334
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/create-worker.js
|
|
335
335
|
var requestId = 0;
|
|
336
336
|
var activeController = null;
|
|
337
337
|
var activeInputBatches = null;
|
|
@@ -540,12 +540,12 @@ function createProgressReporter() {
|
|
|
540
540
|
};
|
|
541
541
|
}
|
|
542
542
|
|
|
543
|
-
// ../../node_modules/@math.gl/
|
|
543
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/index.js
|
|
544
544
|
var import_meta = {};
|
|
545
545
|
var path = typeof __filename === "string" ? __filename.replace(/\\/g, "/") : "";
|
|
546
546
|
var moduleUrl = path ? `file://${path.startsWith("/") ? "" : "/"}${encodeURI(path).replace(/#/g, "%23").replace(/\?/g, "%3F")}` : import_meta.url;
|
|
547
547
|
|
|
548
|
-
// ../../node_modules/@math.gl/
|
|
548
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js
|
|
549
549
|
var pending = /* @__PURE__ */ new WeakMap();
|
|
550
550
|
var loaded = /* @__PURE__ */ new WeakSet();
|
|
551
551
|
function preloadTaskCode(task, signal) {
|
|
@@ -582,17 +582,186 @@ function withSignal(operation, signal) {
|
|
|
582
582
|
});
|
|
583
583
|
}
|
|
584
584
|
|
|
585
|
-
// ../../node_modules/@math.gl/
|
|
585
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-channel.js
|
|
586
|
+
var TaskRequestError = class extends Error {
|
|
587
|
+
};
|
|
588
|
+
var TaskChannel = class {
|
|
589
|
+
constructor(options) {
|
|
590
|
+
this.options = options;
|
|
591
|
+
this.nextId = 1;
|
|
592
|
+
this.pending = /* @__PURE__ */ new Map();
|
|
593
|
+
this.incoming = /* @__PURE__ */ new Map();
|
|
594
|
+
}
|
|
595
|
+
/** Send a request without serializing other in-flight requests. */
|
|
596
|
+
request(operation, value, signal, transfer = []) {
|
|
597
|
+
if (this.failure)
|
|
598
|
+
return Promise.reject(this.failure.reason);
|
|
599
|
+
if (signal == null ? void 0 : signal.aborted)
|
|
600
|
+
return Promise.reject(signal.reason);
|
|
601
|
+
const id = this.nextId++;
|
|
602
|
+
return new Promise((resolve, reject) => {
|
|
603
|
+
const abort = () => {
|
|
604
|
+
const pending2 = this.pending.get(id);
|
|
605
|
+
if (!pending2)
|
|
606
|
+
return;
|
|
607
|
+
this.pending.delete(id);
|
|
608
|
+
pending2.cleanup();
|
|
609
|
+
reject(signal == null ? void 0 : signal.reason);
|
|
610
|
+
this.send({ source: "math.gl/tasks", kind: "cancel", id });
|
|
611
|
+
};
|
|
612
|
+
this.pending.set(id, {
|
|
613
|
+
resolve,
|
|
614
|
+
reject,
|
|
615
|
+
cleanup: () => signal == null ? void 0 : signal.removeEventListener("abort", abort)
|
|
616
|
+
});
|
|
617
|
+
signal == null ? void 0 : signal.addEventListener("abort", abort, { once: true });
|
|
618
|
+
this.send({ source: "math.gl/tasks", kind: "request", id, operation, value }, transfer);
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
/** Send a one-way notification. */
|
|
622
|
+
emit(operation, value, transfer = []) {
|
|
623
|
+
if (this.failure)
|
|
624
|
+
throw this.failure.reason;
|
|
625
|
+
this.send({ source: "math.gl/tasks", kind: "event", id: 0, operation, value }, transfer);
|
|
626
|
+
}
|
|
627
|
+
/** Dispatch a transport message; unrelated protocols are ignored. */
|
|
628
|
+
receive(message) {
|
|
629
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
630
|
+
if (this.failure || (message == null ? void 0 : message.source) !== "math.gl/tasks")
|
|
631
|
+
return;
|
|
632
|
+
if (message.kind === "failure") {
|
|
633
|
+
const reason = new Error(((_a = message.error) == null ? void 0 : _a.message) ?? "Task channel failed");
|
|
634
|
+
this.close(reason);
|
|
635
|
+
(_c = (_b = this.options).onFailure) == null ? void 0 : _c.call(_b, reason);
|
|
636
|
+
} else if (message.kind === "result" || message.kind === "error") {
|
|
637
|
+
const pending2 = this.pending.get(message.id);
|
|
638
|
+
if (!pending2)
|
|
639
|
+
return;
|
|
640
|
+
this.pending.delete(message.id);
|
|
641
|
+
pending2.cleanup();
|
|
642
|
+
if (message.kind === "result")
|
|
643
|
+
pending2.resolve(message.value);
|
|
644
|
+
else {
|
|
645
|
+
const error = new TaskRequestError(((_d = message.error) == null ? void 0 : _d.message) ?? "Task request failed");
|
|
646
|
+
error.name = ((_e = message.error) == null ? void 0 : _e.name) ?? "Error";
|
|
647
|
+
pending2.reject(error);
|
|
648
|
+
}
|
|
649
|
+
} else if (message.kind === "cancel") {
|
|
650
|
+
(_f = this.incoming.get(message.id)) == null ? void 0 : _f.abort(new DOMException("Task request cancelled", "AbortError"));
|
|
651
|
+
} else if (message.kind === "event") {
|
|
652
|
+
try {
|
|
653
|
+
(_h = (_g = this.options).handleEvent) == null ? void 0 : _h.call(_g, message.operation, message.value);
|
|
654
|
+
} catch (error) {
|
|
655
|
+
this.fail(error);
|
|
656
|
+
}
|
|
657
|
+
} else if (message.kind === "request") {
|
|
658
|
+
if (this.incoming.has(message.id)) {
|
|
659
|
+
this.fail(new Error("Duplicate task request identifier"));
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
const controller = new AbortController();
|
|
663
|
+
this.incoming.set(message.id, controller);
|
|
664
|
+
void Promise.resolve().then(() => {
|
|
665
|
+
controller.signal.throwIfAborted();
|
|
666
|
+
return this.options.handleRequest(message.operation, message.value, controller.signal);
|
|
667
|
+
}).then((value) => {
|
|
668
|
+
var _a2, _b2;
|
|
669
|
+
if (!controller.signal.aborted && !this.failure) {
|
|
670
|
+
this.send({ source: "math.gl/tasks", kind: "result", id: message.id, value }, (_b2 = (_a2 = this.options).getResultTransferList) == null ? void 0 : _b2.call(_a2, value, message.value));
|
|
671
|
+
}
|
|
672
|
+
}).catch((reason) => {
|
|
673
|
+
if (!controller.signal.aborted && !this.failure) {
|
|
674
|
+
this.send({
|
|
675
|
+
source: "math.gl/tasks",
|
|
676
|
+
kind: "error",
|
|
677
|
+
id: message.id,
|
|
678
|
+
error: {
|
|
679
|
+
name: reason instanceof Error ? reason.name : "Error",
|
|
680
|
+
message: reason instanceof Error ? reason.message : String(reason)
|
|
681
|
+
}
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
}).finally(() => this.incoming.delete(message.id));
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
/** Reject all outstanding calls with a common cause and abort incoming callbacks. */
|
|
688
|
+
close(reason = new Error("Task channel closed")) {
|
|
689
|
+
if (this.failure)
|
|
690
|
+
return;
|
|
691
|
+
this.failure = { reason };
|
|
692
|
+
for (const pending2 of this.pending.values()) {
|
|
693
|
+
pending2.cleanup();
|
|
694
|
+
pending2.reject(reason);
|
|
695
|
+
}
|
|
696
|
+
this.pending.clear();
|
|
697
|
+
for (const controller of this.incoming.values())
|
|
698
|
+
controller.abort(reason);
|
|
699
|
+
this.incoming.clear();
|
|
700
|
+
}
|
|
701
|
+
send(message, transfer = []) {
|
|
702
|
+
if (this.failure)
|
|
703
|
+
return;
|
|
704
|
+
try {
|
|
705
|
+
this.options.send(message, transfer);
|
|
706
|
+
} catch (error) {
|
|
707
|
+
this.fail(error);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
/** Invalidate the channel and notify the peer when the transport still works. */
|
|
711
|
+
fail(reason) {
|
|
712
|
+
var _a, _b;
|
|
713
|
+
if (this.failure)
|
|
714
|
+
return;
|
|
715
|
+
this.close(reason);
|
|
716
|
+
try {
|
|
717
|
+
this.options.send({
|
|
718
|
+
source: "math.gl/tasks",
|
|
719
|
+
kind: "failure",
|
|
720
|
+
id: 0,
|
|
721
|
+
error: {
|
|
722
|
+
name: reason instanceof Error ? reason.name : "Error",
|
|
723
|
+
message: reason instanceof Error ? reason.message : String(reason)
|
|
724
|
+
}
|
|
725
|
+
}, []);
|
|
726
|
+
} catch {
|
|
727
|
+
}
|
|
728
|
+
(_b = (_a = this.options).onFailure) == null ? void 0 : _b.call(_a, reason);
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-runtime.js
|
|
586
733
|
function assertPayload(value) {
|
|
587
734
|
if (!value || typeof value !== "object" || Object.getPrototypeOf(value) !== Object.prototype) {
|
|
588
735
|
throw new TypeError("Task payloads must be plain objects with named fields");
|
|
589
736
|
}
|
|
590
737
|
}
|
|
738
|
+
function clonePayload(value, ownership = "copy") {
|
|
739
|
+
assertPayload(value);
|
|
740
|
+
if (!["copy", "transfer", "share"].includes(ownership))
|
|
741
|
+
throw new TypeError("Invalid input ownership");
|
|
742
|
+
const transfer = getTransferList(value);
|
|
743
|
+
if (ownership === "share" && transfer.length)
|
|
744
|
+
throw new TypeError("Share requires shared storage");
|
|
745
|
+
return structuredClone(value, {
|
|
746
|
+
transfer: ownership === "transfer" ? transfer : []
|
|
747
|
+
});
|
|
748
|
+
}
|
|
591
749
|
function taskContext(state, context = {}) {
|
|
592
750
|
const signal = context.signal ?? new AbortController().signal;
|
|
593
751
|
return {
|
|
594
752
|
state,
|
|
595
753
|
signal,
|
|
754
|
+
requestHost: async (operation, payload, controls) => {
|
|
755
|
+
signal.throwIfAborted();
|
|
756
|
+
if (!context.requestHost)
|
|
757
|
+
throw new Error("No host request handler configured");
|
|
758
|
+
return context.requestHost(operation, payload, controls);
|
|
759
|
+
},
|
|
760
|
+
emitHost: (operation, payload) => {
|
|
761
|
+
var _a;
|
|
762
|
+
signal.throwIfAborted();
|
|
763
|
+
(_a = context.emitHost) == null ? void 0 : _a.call(context, operation, payload);
|
|
764
|
+
},
|
|
596
765
|
throwIfAborted: () => {
|
|
597
766
|
var _a;
|
|
598
767
|
signal.throwIfAborted();
|
|
@@ -663,6 +832,70 @@ async function initializeTaskWorker(task) {
|
|
|
663
832
|
throw new Error("A task is already installed in this worker");
|
|
664
833
|
installed = true;
|
|
665
834
|
const runtime = new TaskRuntime(task);
|
|
835
|
+
let channelStream;
|
|
836
|
+
const channel = new TaskChannel({
|
|
837
|
+
getResultTransferList: (value, request) => request.outputOwnership === "transfer" ? getTransferList(value) : [],
|
|
838
|
+
send: (message, transfer) => {
|
|
839
|
+
const snapshot = structuredClone(message, { transfer });
|
|
840
|
+
void WorkerBody.postMessage("task-channel", snapshot).catch((reason) => channel.fail(reason));
|
|
841
|
+
},
|
|
842
|
+
handleRequest: async (operation, value, signal) => {
|
|
843
|
+
var _a;
|
|
844
|
+
const request = value;
|
|
845
|
+
const context = {
|
|
846
|
+
signal,
|
|
847
|
+
reportProgress: (progress) => channel.emit("task:progress", { id: request.progressId, progress }),
|
|
848
|
+
requestHost: (operation2, payload, controls = {}) => {
|
|
849
|
+
const request2 = {
|
|
850
|
+
operation: operation2,
|
|
851
|
+
payload: clonePayload(payload, controls.inputOwnership),
|
|
852
|
+
outputOwnership: controls.outputOwnership ?? "copy"
|
|
853
|
+
};
|
|
854
|
+
return channel.request("task:host-request", request2, signal, getTransferList(request2));
|
|
855
|
+
},
|
|
856
|
+
emitHost: (operation2, payload) => channel.emit("task:host-event", { operation: operation2, payload, id: request.progressId })
|
|
857
|
+
};
|
|
858
|
+
switch (operation) {
|
|
859
|
+
case "initialize":
|
|
860
|
+
return runtime.initialize(request.input, context);
|
|
861
|
+
case "process":
|
|
862
|
+
return runtime.process(request.input, request.options, context);
|
|
863
|
+
case "stream-open": {
|
|
864
|
+
if (channelStream)
|
|
865
|
+
throw new Error("A task stream is already open");
|
|
866
|
+
async function* inputs() {
|
|
867
|
+
while (true) {
|
|
868
|
+
const result = await channel.request("task:next-input", { outputOwnership: "transfer" }, signal);
|
|
869
|
+
if (result.done)
|
|
870
|
+
return;
|
|
871
|
+
yield result.value;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
channelStream = runtime.stream(inputs(), request.options, context)[Symbol.asyncIterator]();
|
|
875
|
+
return {};
|
|
876
|
+
}
|
|
877
|
+
case "stream-next":
|
|
878
|
+
if (!channelStream)
|
|
879
|
+
throw new Error("No active task stream");
|
|
880
|
+
return channelStream.next();
|
|
881
|
+
case "stream-close":
|
|
882
|
+
try {
|
|
883
|
+
await ((_a = channelStream == null ? void 0 : channelStream.return) == null ? void 0 : _a.call(channelStream));
|
|
884
|
+
} finally {
|
|
885
|
+
channelStream = void 0;
|
|
886
|
+
}
|
|
887
|
+
return {};
|
|
888
|
+
case "destroy":
|
|
889
|
+
return runtime.destroy();
|
|
890
|
+
default:
|
|
891
|
+
throw new Error("Unknown task channel operation");
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
});
|
|
895
|
+
await WorkerBody.addEventListener((type, payload) => {
|
|
896
|
+
if (type === "task-channel")
|
|
897
|
+
channel.receive(payload);
|
|
898
|
+
});
|
|
666
899
|
let streamOptions = {};
|
|
667
900
|
return createWorker(async (request, _options, context) => {
|
|
668
901
|
switch (request.operation) {
|
|
@@ -962,7 +1195,7 @@ function getWorkerLoaderOptions(loader, options) {
|
|
|
962
1195
|
}
|
|
963
1196
|
|
|
964
1197
|
// src/null-loader.ts
|
|
965
|
-
var VERSION = true ? "5.0.0-beta.
|
|
1198
|
+
var VERSION = true ? "5.0.0-beta.5" : "latest";
|
|
966
1199
|
var NullLoader = {
|
|
967
1200
|
dataType: null,
|
|
968
1201
|
batchType: null,
|