@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
package/dist/dist.dev.js
CHANGED
|
@@ -766,23 +766,23 @@ var __exports__ = (() => {
|
|
|
766
766
|
var matches2 = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
767
767
|
var nodeVersion2 = matches2 && parseFloat(matches2[1]) || 0;
|
|
768
768
|
|
|
769
|
-
// ../../node_modules/@math.gl/
|
|
769
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/npm-tag.js
|
|
770
770
|
var NPM_TAG2 = "latest";
|
|
771
771
|
|
|
772
|
-
// ../../node_modules/@math.gl/
|
|
772
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/env-utils/version.js
|
|
773
773
|
function getVersion2() {
|
|
774
774
|
return typeof __VERSION__ === "undefined" ? NPM_TAG2 : __VERSION__;
|
|
775
775
|
}
|
|
776
776
|
var VERSION4 = getVersion2();
|
|
777
777
|
|
|
778
|
-
// ../../node_modules/@math.gl/
|
|
778
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/env-utils/assert.js
|
|
779
779
|
function assert5(condition, message) {
|
|
780
780
|
if (!condition) {
|
|
781
781
|
throw new Error(message || "loaders.gl assertion failed.");
|
|
782
782
|
}
|
|
783
783
|
}
|
|
784
784
|
|
|
785
|
-
// ../../node_modules/@math.gl/
|
|
785
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/env-utils/globals.js
|
|
786
786
|
var globals3 = {
|
|
787
787
|
self: typeof self !== "undefined" && self,
|
|
788
788
|
window: typeof window !== "undefined" && window,
|
|
@@ -801,7 +801,7 @@ var __exports__ = (() => {
|
|
|
801
801
|
var matches3 = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
802
802
|
var nodeVersion3 = matches3 && parseFloat(matches3[1]) || 0;
|
|
803
803
|
|
|
804
|
-
// ../../node_modules/@math.gl/
|
|
804
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-job.js
|
|
805
805
|
var WorkerJob = class {
|
|
806
806
|
constructor(jobName, workerThread) {
|
|
807
807
|
this.isRunning = true;
|
|
@@ -918,7 +918,7 @@ var __exports__ = (() => {
|
|
|
918
918
|
return error;
|
|
919
919
|
}
|
|
920
920
|
|
|
921
|
-
// ../../node_modules/@math.gl/
|
|
921
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/node/worker_threads-browser.js
|
|
922
922
|
var NodeWorker = class {
|
|
923
923
|
/** Restores the native worker constructor when this browser shim is embedded in a Node bundle. */
|
|
924
924
|
constructor(...arguments_) {
|
|
@@ -934,7 +934,7 @@ var __exports__ = (() => {
|
|
|
934
934
|
};
|
|
935
935
|
var parentPort = globalThis.process?.getBuiltinModule?.("node:worker_threads")?.parentPort ?? null;
|
|
936
936
|
|
|
937
|
-
// ../../node_modules/@math.gl/
|
|
937
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js
|
|
938
938
|
var workerURLCache = /* @__PURE__ */ new Map();
|
|
939
939
|
function getLoadableWorkerURL(props) {
|
|
940
940
|
assert5(props.source && !props.url || !props.source && props.url);
|
|
@@ -983,7 +983,7 @@ var __exports__ = (() => {
|
|
|
983
983
|
}`;
|
|
984
984
|
}
|
|
985
985
|
|
|
986
|
-
// ../../node_modules/@math.gl/
|
|
986
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-transfer-list.js
|
|
987
987
|
function getTransferList(object, recursive = true, transfers) {
|
|
988
988
|
const transfersSet = transfers || /* @__PURE__ */ new Set();
|
|
989
989
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -1067,7 +1067,7 @@ var __exports__ = (() => {
|
|
|
1067
1067
|
return object === null ? {} : clone(object);
|
|
1068
1068
|
}
|
|
1069
1069
|
|
|
1070
|
-
// ../../node_modules/@math.gl/
|
|
1070
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-thread.js
|
|
1071
1071
|
var NOOP = () => {
|
|
1072
1072
|
};
|
|
1073
1073
|
var WorkerThread = class {
|
|
@@ -1248,7 +1248,7 @@ var __exports__ = (() => {
|
|
|
1248
1248
|
}
|
|
1249
1249
|
};
|
|
1250
1250
|
|
|
1251
|
-
// ../../node_modules/@math.gl/
|
|
1251
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-pool.js
|
|
1252
1252
|
var WorkerPool = class {
|
|
1253
1253
|
/** Snapshot; byte figures describe input buffers, not total heap memory. */
|
|
1254
1254
|
get stats() {
|
|
@@ -1774,7 +1774,7 @@ var __exports__ = (() => {
|
|
|
1774
1774
|
}
|
|
1775
1775
|
};
|
|
1776
1776
|
|
|
1777
|
-
// ../../node_modules/@math.gl/
|
|
1777
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-farm.js
|
|
1778
1778
|
var DEFAULT_PROPS = {
|
|
1779
1779
|
maxQueuedJobs: Infinity,
|
|
1780
1780
|
maxPendingAdmissions: 128,
|
|
@@ -1895,7 +1895,7 @@ var __exports__ = (() => {
|
|
|
1895
1895
|
return loadWorkerId;
|
|
1896
1896
|
}
|
|
1897
1897
|
|
|
1898
|
-
// ../../node_modules/@math.gl/
|
|
1898
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/async-queue/async-queue.js
|
|
1899
1899
|
var AsyncQueue = class {
|
|
1900
1900
|
constructor() {
|
|
1901
1901
|
this._values = [];
|
|
@@ -1962,7 +1962,7 @@ var __exports__ = (() => {
|
|
|
1962
1962
|
}
|
|
1963
1963
|
};
|
|
1964
1964
|
|
|
1965
|
-
// ../../node_modules/@math.gl/
|
|
1965
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/get-worker-url.js
|
|
1966
1966
|
var warnedWorkerVersionFallbacks = /* @__PURE__ */ new Set();
|
|
1967
1967
|
function getWorkerName(worker) {
|
|
1968
1968
|
const warning = worker.version !== VERSION4 ? ` (worker-utils@${VERSION4})` : "";
|
|
@@ -1976,7 +1976,7 @@ var __exports__ = (() => {
|
|
|
1976
1976
|
if (isBrowser4) {
|
|
1977
1977
|
url = `modules/${worker.module}/dist/${workerFile}`;
|
|
1978
1978
|
} else {
|
|
1979
|
-
const workerSourceDirectory = worker.module === "
|
|
1979
|
+
const workerSourceDirectory = worker.module === "tasks" && worker.workerNode?.startsWith("worker-utils/") ? "worker-utils/workers" : "workers";
|
|
1980
1980
|
const workerSourceNode = worker.workerSourceNode || `${workerSourceDirectory}/${worker.id}-worker-node.ts`;
|
|
1981
1981
|
url = `modules/${worker.module}/src/${workerSourceNode}`;
|
|
1982
1982
|
}
|
|
@@ -2020,7 +2020,7 @@ var __exports__ = (() => {
|
|
|
2020
2020
|
console.warn(`loaders.gl: ${worker.name} loader worker version is "latest" because __VERSION__ was not injected. Fetching ${url} from CDN.`);
|
|
2021
2021
|
}
|
|
2022
2022
|
|
|
2023
|
-
// ../../node_modules/@math.gl/
|
|
2023
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/shared-state.js
|
|
2024
2024
|
function getWorkerCapabilities() {
|
|
2025
2025
|
const isolated = typeof globalThis.crossOriginIsolated === "boolean" ? globalThis.crossOriginIsolated : void 0;
|
|
2026
2026
|
const capabilities = {
|
|
@@ -2103,7 +2103,7 @@ var __exports__ = (() => {
|
|
|
2103
2103
|
return options;
|
|
2104
2104
|
}
|
|
2105
2105
|
|
|
2106
|
-
// ../../node_modules/@math.gl/
|
|
2106
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-input-byte-length.js
|
|
2107
2107
|
function getInputByteLength(input) {
|
|
2108
2108
|
const seen = /* @__PURE__ */ new Set();
|
|
2109
2109
|
let bytes = 0;
|
|
@@ -2132,14 +2132,14 @@ var __exports__ = (() => {
|
|
|
2132
2132
|
return bytes;
|
|
2133
2133
|
}
|
|
2134
2134
|
|
|
2135
|
-
// ../../node_modules/@math.gl/
|
|
2135
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js
|
|
2136
2136
|
function validateOutputOwnership(ownership) {
|
|
2137
2137
|
if (ownership !== void 0 && ownership !== "copy" && ownership !== "transfer") {
|
|
2138
2138
|
throw new Error("Invalid worker output ownership");
|
|
2139
2139
|
}
|
|
2140
2140
|
}
|
|
2141
2141
|
|
|
2142
|
-
// ../../node_modules/@math.gl/
|
|
2142
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/process-on-worker.js
|
|
2143
2143
|
async function processOnWorker(worker, data, options = {}, context = {}, jobContext = {}) {
|
|
2144
2144
|
validateOutputOwnership(options.outputOwnership);
|
|
2145
2145
|
if (options.inputOwnership !== void 0 && !["copy", "transfer", "share"].includes(options.inputOwnership))
|
|
@@ -2433,12 +2433,12 @@ var __exports__ = (() => {
|
|
|
2433
2433
|
return inputOptions;
|
|
2434
2434
|
}
|
|
2435
2435
|
|
|
2436
|
-
// ../../node_modules/@math.gl/
|
|
2436
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/index.js
|
|
2437
2437
|
var import_meta = {};
|
|
2438
2438
|
var path = typeof __filename === "string" ? __filename.replace(/\\/g, "/") : "";
|
|
2439
2439
|
var moduleUrl = path ? `file://${path.startsWith("/") ? "" : "/"}${encodeURI(path).replace(/#/g, "%23").replace(/\?/g, "%3F")}` : import_meta.url;
|
|
2440
2440
|
|
|
2441
|
-
// ../../node_modules/@math.gl/
|
|
2441
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js
|
|
2442
2442
|
var pending = /* @__PURE__ */ new WeakMap();
|
|
2443
2443
|
var loaded = /* @__PURE__ */ new WeakSet();
|
|
2444
2444
|
function preloadTaskCode(task, signal) {
|
|
@@ -2478,7 +2478,151 @@ var __exports__ = (() => {
|
|
|
2478
2478
|
});
|
|
2479
2479
|
}
|
|
2480
2480
|
|
|
2481
|
-
// ../../node_modules/@math.gl/
|
|
2481
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-channel.js
|
|
2482
|
+
var TaskRequestError = class extends Error {
|
|
2483
|
+
};
|
|
2484
|
+
var TaskChannel = class {
|
|
2485
|
+
constructor(options) {
|
|
2486
|
+
this.options = options;
|
|
2487
|
+
this.nextId = 1;
|
|
2488
|
+
this.pending = /* @__PURE__ */ new Map();
|
|
2489
|
+
this.incoming = /* @__PURE__ */ new Map();
|
|
2490
|
+
}
|
|
2491
|
+
/** Send a request without serializing other in-flight requests. */
|
|
2492
|
+
request(operation, value, signal, transfer = []) {
|
|
2493
|
+
if (this.failure)
|
|
2494
|
+
return Promise.reject(this.failure.reason);
|
|
2495
|
+
if (signal?.aborted)
|
|
2496
|
+
return Promise.reject(signal.reason);
|
|
2497
|
+
const id = this.nextId++;
|
|
2498
|
+
return new Promise((resolve2, reject) => {
|
|
2499
|
+
const abort = () => {
|
|
2500
|
+
const pending2 = this.pending.get(id);
|
|
2501
|
+
if (!pending2)
|
|
2502
|
+
return;
|
|
2503
|
+
this.pending.delete(id);
|
|
2504
|
+
pending2.cleanup();
|
|
2505
|
+
reject(signal?.reason);
|
|
2506
|
+
this.send({ source: "math.gl/tasks", kind: "cancel", id });
|
|
2507
|
+
};
|
|
2508
|
+
this.pending.set(id, {
|
|
2509
|
+
resolve: resolve2,
|
|
2510
|
+
reject,
|
|
2511
|
+
cleanup: () => signal?.removeEventListener("abort", abort)
|
|
2512
|
+
});
|
|
2513
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
2514
|
+
this.send({ source: "math.gl/tasks", kind: "request", id, operation, value }, transfer);
|
|
2515
|
+
});
|
|
2516
|
+
}
|
|
2517
|
+
/** Send a one-way notification. */
|
|
2518
|
+
emit(operation, value, transfer = []) {
|
|
2519
|
+
if (this.failure)
|
|
2520
|
+
throw this.failure.reason;
|
|
2521
|
+
this.send({ source: "math.gl/tasks", kind: "event", id: 0, operation, value }, transfer);
|
|
2522
|
+
}
|
|
2523
|
+
/** Dispatch a transport message; unrelated protocols are ignored. */
|
|
2524
|
+
receive(message) {
|
|
2525
|
+
if (this.failure || message?.source !== "math.gl/tasks")
|
|
2526
|
+
return;
|
|
2527
|
+
if (message.kind === "failure") {
|
|
2528
|
+
const reason = new Error(message.error?.message ?? "Task channel failed");
|
|
2529
|
+
this.close(reason);
|
|
2530
|
+
this.options.onFailure?.(reason);
|
|
2531
|
+
} else if (message.kind === "result" || message.kind === "error") {
|
|
2532
|
+
const pending2 = this.pending.get(message.id);
|
|
2533
|
+
if (!pending2)
|
|
2534
|
+
return;
|
|
2535
|
+
this.pending.delete(message.id);
|
|
2536
|
+
pending2.cleanup();
|
|
2537
|
+
if (message.kind === "result")
|
|
2538
|
+
pending2.resolve(message.value);
|
|
2539
|
+
else {
|
|
2540
|
+
const error = new TaskRequestError(message.error?.message ?? "Task request failed");
|
|
2541
|
+
error.name = message.error?.name ?? "Error";
|
|
2542
|
+
pending2.reject(error);
|
|
2543
|
+
}
|
|
2544
|
+
} else if (message.kind === "cancel") {
|
|
2545
|
+
this.incoming.get(message.id)?.abort(new DOMException("Task request cancelled", "AbortError"));
|
|
2546
|
+
} else if (message.kind === "event") {
|
|
2547
|
+
try {
|
|
2548
|
+
this.options.handleEvent?.(message.operation, message.value);
|
|
2549
|
+
} catch (error) {
|
|
2550
|
+
this.fail(error);
|
|
2551
|
+
}
|
|
2552
|
+
} else if (message.kind === "request") {
|
|
2553
|
+
if (this.incoming.has(message.id)) {
|
|
2554
|
+
this.fail(new Error("Duplicate task request identifier"));
|
|
2555
|
+
return;
|
|
2556
|
+
}
|
|
2557
|
+
const controller = new AbortController();
|
|
2558
|
+
this.incoming.set(message.id, controller);
|
|
2559
|
+
void Promise.resolve().then(() => {
|
|
2560
|
+
controller.signal.throwIfAborted();
|
|
2561
|
+
return this.options.handleRequest(message.operation, message.value, controller.signal);
|
|
2562
|
+
}).then((value) => {
|
|
2563
|
+
if (!controller.signal.aborted && !this.failure) {
|
|
2564
|
+
this.send({ source: "math.gl/tasks", kind: "result", id: message.id, value }, this.options.getResultTransferList?.(value, message.value));
|
|
2565
|
+
}
|
|
2566
|
+
}).catch((reason) => {
|
|
2567
|
+
if (!controller.signal.aborted && !this.failure) {
|
|
2568
|
+
this.send({
|
|
2569
|
+
source: "math.gl/tasks",
|
|
2570
|
+
kind: "error",
|
|
2571
|
+
id: message.id,
|
|
2572
|
+
error: {
|
|
2573
|
+
name: reason instanceof Error ? reason.name : "Error",
|
|
2574
|
+
message: reason instanceof Error ? reason.message : String(reason)
|
|
2575
|
+
}
|
|
2576
|
+
});
|
|
2577
|
+
}
|
|
2578
|
+
}).finally(() => this.incoming.delete(message.id));
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
/** Reject all outstanding calls with a common cause and abort incoming callbacks. */
|
|
2582
|
+
close(reason = new Error("Task channel closed")) {
|
|
2583
|
+
if (this.failure)
|
|
2584
|
+
return;
|
|
2585
|
+
this.failure = { reason };
|
|
2586
|
+
for (const pending2 of this.pending.values()) {
|
|
2587
|
+
pending2.cleanup();
|
|
2588
|
+
pending2.reject(reason);
|
|
2589
|
+
}
|
|
2590
|
+
this.pending.clear();
|
|
2591
|
+
for (const controller of this.incoming.values())
|
|
2592
|
+
controller.abort(reason);
|
|
2593
|
+
this.incoming.clear();
|
|
2594
|
+
}
|
|
2595
|
+
send(message, transfer = []) {
|
|
2596
|
+
if (this.failure)
|
|
2597
|
+
return;
|
|
2598
|
+
try {
|
|
2599
|
+
this.options.send(message, transfer);
|
|
2600
|
+
} catch (error) {
|
|
2601
|
+
this.fail(error);
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
/** Invalidate the channel and notify the peer when the transport still works. */
|
|
2605
|
+
fail(reason) {
|
|
2606
|
+
if (this.failure)
|
|
2607
|
+
return;
|
|
2608
|
+
this.close(reason);
|
|
2609
|
+
try {
|
|
2610
|
+
this.options.send({
|
|
2611
|
+
source: "math.gl/tasks",
|
|
2612
|
+
kind: "failure",
|
|
2613
|
+
id: 0,
|
|
2614
|
+
error: {
|
|
2615
|
+
name: reason instanceof Error ? reason.name : "Error",
|
|
2616
|
+
message: reason instanceof Error ? reason.message : String(reason)
|
|
2617
|
+
}
|
|
2618
|
+
}, []);
|
|
2619
|
+
} catch {
|
|
2620
|
+
}
|
|
2621
|
+
this.options.onFailure?.(reason);
|
|
2622
|
+
}
|
|
2623
|
+
};
|
|
2624
|
+
|
|
2625
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-runtime.js
|
|
2482
2626
|
function assertPayload(value) {
|
|
2483
2627
|
if (!value || typeof value !== "object" || Object.getPrototypeOf(value) !== Object.prototype) {
|
|
2484
2628
|
throw new TypeError("Task payloads must be plain objects with named fields");
|
|
@@ -2500,6 +2644,16 @@ var __exports__ = (() => {
|
|
|
2500
2644
|
return {
|
|
2501
2645
|
state,
|
|
2502
2646
|
signal,
|
|
2647
|
+
requestHost: async (operation, payload, controls) => {
|
|
2648
|
+
signal.throwIfAborted();
|
|
2649
|
+
if (!context.requestHost)
|
|
2650
|
+
throw new Error("No host request handler configured");
|
|
2651
|
+
return context.requestHost(operation, payload, controls);
|
|
2652
|
+
},
|
|
2653
|
+
emitHost: (operation, payload) => {
|
|
2654
|
+
signal.throwIfAborted();
|
|
2655
|
+
context.emitHost?.(operation, payload);
|
|
2656
|
+
},
|
|
2503
2657
|
throwIfAborted: () => {
|
|
2504
2658
|
signal.throwIfAborted();
|
|
2505
2659
|
context.throwIfAborted?.();
|
|
@@ -2564,7 +2718,7 @@ var __exports__ = (() => {
|
|
|
2564
2718
|
};
|
|
2565
2719
|
}
|
|
2566
2720
|
|
|
2567
|
-
// ../../node_modules/@math.gl/
|
|
2721
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-sync.js
|
|
2568
2722
|
function runTaskSync(task, input, request = {}) {
|
|
2569
2723
|
if (!isTaskCodeLoaded(task))
|
|
2570
2724
|
throw new Error("Preload task on the main thread before runTaskSync");
|
|
@@ -2644,18 +2798,155 @@ var __exports__ = (() => {
|
|
|
2644
2798
|
return Boolean(value && (typeof value === "object" || typeof value === "function") && typeof value.then === "function");
|
|
2645
2799
|
}
|
|
2646
2800
|
|
|
2647
|
-
// ../../node_modules/@math.gl/
|
|
2801
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-operation-queue.js
|
|
2802
|
+
var TaskOperationQueue = class {
|
|
2803
|
+
constructor(maxConcurrency) {
|
|
2804
|
+
this.maxConcurrency = maxConcurrency;
|
|
2805
|
+
this.pending = [];
|
|
2806
|
+
this.active = 0;
|
|
2807
|
+
this.exclusive = false;
|
|
2808
|
+
this.closed = false;
|
|
2809
|
+
this.idleWaiters = /* @__PURE__ */ new Set();
|
|
2810
|
+
if (!Number.isSafeInteger(maxConcurrency) || maxConcurrency < 1) {
|
|
2811
|
+
throw new RangeError("maxConcurrency must be a positive safe integer");
|
|
2812
|
+
}
|
|
2813
|
+
}
|
|
2814
|
+
/** Queue an operation; aborting before it starts removes it without running it. */
|
|
2815
|
+
run(mode, operation, signal) {
|
|
2816
|
+
if (this.closed)
|
|
2817
|
+
return Promise.reject(new Error("Task operation queue is closed"));
|
|
2818
|
+
if (mode !== "parallel" && mode !== "exclusive")
|
|
2819
|
+
return Promise.reject(new TypeError("Invalid operation mode"));
|
|
2820
|
+
if (signal?.aborted)
|
|
2821
|
+
return Promise.reject(signal.reason);
|
|
2822
|
+
return new Promise((resolve2, reject) => {
|
|
2823
|
+
const onAbort = () => {
|
|
2824
|
+
const index = this.pending.indexOf(entry);
|
|
2825
|
+
if (index >= 0) {
|
|
2826
|
+
this.pending.splice(index, 1);
|
|
2827
|
+
entry.cancel(signal?.reason);
|
|
2828
|
+
this.pump();
|
|
2829
|
+
}
|
|
2830
|
+
};
|
|
2831
|
+
const entry = {
|
|
2832
|
+
mode,
|
|
2833
|
+
cancel: (reason) => {
|
|
2834
|
+
signal?.removeEventListener("abort", onAbort);
|
|
2835
|
+
reject(reason);
|
|
2836
|
+
},
|
|
2837
|
+
start: () => {
|
|
2838
|
+
signal?.removeEventListener("abort", onAbort);
|
|
2839
|
+
this.active++;
|
|
2840
|
+
if (mode === "exclusive")
|
|
2841
|
+
this.exclusive = true;
|
|
2842
|
+
void Promise.resolve().then(() => {
|
|
2843
|
+
signal?.throwIfAborted();
|
|
2844
|
+
return operation();
|
|
2845
|
+
}).then(resolve2, reject).finally(() => {
|
|
2846
|
+
this.active--;
|
|
2847
|
+
if (mode === "exclusive")
|
|
2848
|
+
this.exclusive = false;
|
|
2849
|
+
this.pump();
|
|
2850
|
+
});
|
|
2851
|
+
}
|
|
2852
|
+
};
|
|
2853
|
+
this.pending.push(entry);
|
|
2854
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
2855
|
+
if (signal?.aborted)
|
|
2856
|
+
onAbort();
|
|
2857
|
+
else
|
|
2858
|
+
this.pump();
|
|
2859
|
+
});
|
|
2860
|
+
}
|
|
2861
|
+
/** Reject queued calls with one cause while allowing active operations to settle. */
|
|
2862
|
+
cancelPending(reason) {
|
|
2863
|
+
this.closed = true;
|
|
2864
|
+
for (const entry of this.pending.splice(0))
|
|
2865
|
+
entry.cancel(reason);
|
|
2866
|
+
this.pump();
|
|
2867
|
+
}
|
|
2868
|
+
/** Stop accepting new work; accepted operations continue to completion. */
|
|
2869
|
+
close() {
|
|
2870
|
+
this.closed = true;
|
|
2871
|
+
return this.whenIdle();
|
|
2872
|
+
}
|
|
2873
|
+
/** Wait until the queue has no running or waiting operations. */
|
|
2874
|
+
whenIdle() {
|
|
2875
|
+
if (!this.active && !this.pending.length)
|
|
2876
|
+
return Promise.resolve();
|
|
2877
|
+
return new Promise((resolve2) => this.idleWaiters.add(resolve2));
|
|
2878
|
+
}
|
|
2879
|
+
pump() {
|
|
2880
|
+
while (!this.exclusive && this.pending.length && this.active < this.maxConcurrency) {
|
|
2881
|
+
const entry = this.pending[0];
|
|
2882
|
+
if (entry.mode === "exclusive" && this.active)
|
|
2883
|
+
break;
|
|
2884
|
+
this.pending.shift();
|
|
2885
|
+
entry.start();
|
|
2886
|
+
if (entry.mode === "exclusive")
|
|
2887
|
+
break;
|
|
2888
|
+
}
|
|
2889
|
+
if (!this.active && !this.pending.length) {
|
|
2890
|
+
for (const resolve2 of this.idleWaiters)
|
|
2891
|
+
resolve2();
|
|
2892
|
+
this.idleWaiters.clear();
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
};
|
|
2896
|
+
|
|
2897
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-worker-channel.js
|
|
2898
|
+
var TaskWorkerChannel = class {
|
|
2899
|
+
constructor(name, target, options) {
|
|
2900
|
+
this.thread = new WorkerThread({
|
|
2901
|
+
name,
|
|
2902
|
+
url: target.url?.toString(),
|
|
2903
|
+
loadWorker: target.create,
|
|
2904
|
+
workerType: "module"
|
|
2905
|
+
});
|
|
2906
|
+
this.channel = new TaskChannel({
|
|
2907
|
+
...options,
|
|
2908
|
+
send: (message, transfer) => this.thread.postMessage({ source: "loaders.gl/tasks", type: "task-channel", payload: message }, transfer)
|
|
2909
|
+
});
|
|
2910
|
+
this.thread.onMessage = (message) => {
|
|
2911
|
+
if (message?.type === "task-channel")
|
|
2912
|
+
this.channel.receive(message.payload);
|
|
2913
|
+
};
|
|
2914
|
+
this.thread.onError = (reason) => {
|
|
2915
|
+
this.channel.close(reason);
|
|
2916
|
+
options.onFailure?.(reason);
|
|
2917
|
+
};
|
|
2918
|
+
}
|
|
2919
|
+
/** Settle pending calls and terminate the worker without replacing its state. */
|
|
2920
|
+
async destroy(reason) {
|
|
2921
|
+
this.channel.close(reason);
|
|
2922
|
+
await this.thread.destroy();
|
|
2923
|
+
}
|
|
2924
|
+
};
|
|
2925
|
+
|
|
2926
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-runner.js
|
|
2648
2927
|
var InitializedTask = class {
|
|
2649
2928
|
/** @internal Use TaskRunner.initializeTask. */
|
|
2650
|
-
constructor(task, release,
|
|
2929
|
+
constructor(task, release, initializationControls) {
|
|
2651
2930
|
this.task = task;
|
|
2652
2931
|
this.release = release;
|
|
2653
|
-
this.
|
|
2932
|
+
this.initializationControls = initializationControls;
|
|
2933
|
+
this.nextProgressId = 1;
|
|
2934
|
+
this.progressCallbacks = /* @__PURE__ */ new Map();
|
|
2935
|
+
this.callbackFailures = /* @__PURE__ */ new Map();
|
|
2654
2936
|
this.closed = false;
|
|
2937
|
+
this.finalized = false;
|
|
2655
2938
|
this.streams = /* @__PURE__ */ new Set();
|
|
2656
2939
|
this.invalid = false;
|
|
2657
2940
|
this.controller = new AbortController();
|
|
2941
|
+
const controls = initializationControls;
|
|
2658
2942
|
this.runtime = new TaskRuntime(task);
|
|
2943
|
+
const concurrency = controls.operationConcurrency ?? 1;
|
|
2944
|
+
const maximum = task.concurrency?.maxConcurrency ?? 1;
|
|
2945
|
+
if (!Number.isSafeInteger(maximum) || maximum < 1 || !Number.isSafeInteger(concurrency) || concurrency < 1 || concurrency > maximum) {
|
|
2946
|
+
throw new RangeError("Task concurrency must be between 1 and the task maximum");
|
|
2947
|
+
}
|
|
2948
|
+
this.operationQueue = new TaskOperationQueue(concurrency);
|
|
2949
|
+
this.concurrent = concurrency > 1;
|
|
2659
2950
|
const execution = controls.execution ?? "auto";
|
|
2660
2951
|
if (!["auto", "main-thread", "worker"].includes(execution))
|
|
2661
2952
|
throw new TypeError("Invalid execution mode");
|
|
@@ -2665,6 +2956,47 @@ var __exports__ = (() => {
|
|
|
2665
2956
|
const target = task.worker;
|
|
2666
2957
|
if (Boolean(target.url) === Boolean(target.create))
|
|
2667
2958
|
throw new Error("Supply exactly one worker URL or factory");
|
|
2959
|
+
if (this.concurrent || controls.onRequest || controls.onEvent) {
|
|
2960
|
+
this.workerChannel = new TaskWorkerChannel(task.id, target, {
|
|
2961
|
+
handleRequest: async (operation, payload, signal) => {
|
|
2962
|
+
if (operation === "task:next-input") {
|
|
2963
|
+
if (!this.channelInputs)
|
|
2964
|
+
throw new Error("No active task stream");
|
|
2965
|
+
return this.channelInputs.next();
|
|
2966
|
+
}
|
|
2967
|
+
if (!controls.onRequest)
|
|
2968
|
+
throw new Error("No host request handler configured");
|
|
2969
|
+
const request = payload;
|
|
2970
|
+
if (operation !== "task:host-request")
|
|
2971
|
+
throw new Error("Unknown host request");
|
|
2972
|
+
return controls.onRequest(request.operation, request.payload, signal);
|
|
2973
|
+
},
|
|
2974
|
+
getResultTransferList: (value, request) => request.outputOwnership === "transfer" ? getTransferList(value) : [],
|
|
2975
|
+
handleEvent: (operation, payload) => {
|
|
2976
|
+
const { id } = payload;
|
|
2977
|
+
try {
|
|
2978
|
+
if (operation === "task:progress") {
|
|
2979
|
+
const event = payload;
|
|
2980
|
+
(this.progressCallbacks.get(event.id) ?? this.streamProgress)?.(event.progress);
|
|
2981
|
+
} else if (operation === "task:host-event") {
|
|
2982
|
+
const event = payload;
|
|
2983
|
+
controls.onEvent?.(event.operation, event.payload);
|
|
2984
|
+
}
|
|
2985
|
+
} catch (reason) {
|
|
2986
|
+
if (this.progressCallbacks.has(id) || this.streamProgressId === id) {
|
|
2987
|
+
if (!this.callbackFailures.has(id))
|
|
2988
|
+
this.callbackFailures.set(id, { reason });
|
|
2989
|
+
}
|
|
2990
|
+
}
|
|
2991
|
+
},
|
|
2992
|
+
onFailure: (reason) => {
|
|
2993
|
+
this.invalid = true;
|
|
2994
|
+
this.operationQueue.cancelPending(reason);
|
|
2995
|
+
this.controller.abort(reason);
|
|
2996
|
+
}
|
|
2997
|
+
});
|
|
2998
|
+
return;
|
|
2999
|
+
}
|
|
2668
3000
|
this.pool = new WorkerPool({
|
|
2669
3001
|
name: task.id,
|
|
2670
3002
|
url: target.url?.toString(),
|
|
@@ -2676,7 +3008,7 @@ var __exports__ = (() => {
|
|
|
2676
3008
|
this.descriptor = {
|
|
2677
3009
|
id: task.id,
|
|
2678
3010
|
name: task.id,
|
|
2679
|
-
module: "
|
|
3011
|
+
module: "tasks",
|
|
2680
3012
|
version: "prototype",
|
|
2681
3013
|
options: {},
|
|
2682
3014
|
worker: target.url?.toString() ?? true,
|
|
@@ -2696,23 +3028,48 @@ var __exports__ = (() => {
|
|
|
2696
3028
|
}
|
|
2697
3029
|
}
|
|
2698
3030
|
runTask(input, ...args) {
|
|
2699
|
-
|
|
3031
|
+
if (this.invalid)
|
|
3032
|
+
return Promise.reject(new Error("Initialized task is invalid; initialize a new instance"));
|
|
3033
|
+
if (this.closed)
|
|
3034
|
+
return Promise.reject(new Error("Initialized task is closed"));
|
|
3035
|
+
const timeout = args[0]?.timeout;
|
|
3036
|
+
if (timeout !== void 0 && (!Number.isSafeInteger(timeout) || timeout < 0 || timeout > 4294967295)) {
|
|
3037
|
+
return Promise.reject(new RangeError("Invalid task timeout"));
|
|
3038
|
+
}
|
|
3039
|
+
const deadline = timeout === void 0 ? void 0 : AbortSignal.timeout(timeout);
|
|
3040
|
+
const signal = deadline && args[0]?.signal ? AbortSignal.any([deadline, args[0].signal]) : deadline ?? args[0]?.signal;
|
|
3041
|
+
const controls = { ...args[0], signal };
|
|
3042
|
+
const mode = this.task.concurrency?.getSchedulingMode?.(input) ?? "exclusive";
|
|
3043
|
+
return this.operationQueue.run(mode, async () => {
|
|
3044
|
+
signal?.throwIfAborted();
|
|
2700
3045
|
this.checkCapability("atomic");
|
|
2701
|
-
|
|
2702
|
-
|
|
3046
|
+
const invalidate = () => {
|
|
3047
|
+
if (this.concurrent) {
|
|
3048
|
+
this.invalid = true;
|
|
3049
|
+
this.operationQueue.cancelPending(signal?.reason);
|
|
3050
|
+
this.controller.abort(signal?.reason);
|
|
3051
|
+
}
|
|
3052
|
+
};
|
|
3053
|
+
signal?.addEventListener("abort", invalidate, { once: true });
|
|
3054
|
+
try {
|
|
3055
|
+
return await this.invoke("process", input, args[0]?.options ?? {}, controls);
|
|
3056
|
+
} finally {
|
|
3057
|
+
signal?.removeEventListener("abort", invalidate);
|
|
3058
|
+
}
|
|
3059
|
+
}, signal);
|
|
2703
3060
|
}
|
|
2704
3061
|
/** Independent calls sharing this instance, always serial and in input order. */
|
|
2705
|
-
|
|
2706
|
-
|
|
3062
|
+
runTasks(inputs, ...args) {
|
|
3063
|
+
return this.serialStream(async function* (self2) {
|
|
2707
3064
|
self2.checkCapability("atomic");
|
|
2708
3065
|
for await (const input of asAsync(inputs, self2.controls(args[0]).signal)) {
|
|
2709
3066
|
yield await self2.invoke("process", input, args[0]?.options ?? {}, args[0]);
|
|
2710
3067
|
}
|
|
2711
|
-
});
|
|
3068
|
+
}, args[0]?.signal);
|
|
2712
3069
|
}
|
|
2713
3070
|
/** One processor invocation for the entire input iterable. */
|
|
2714
|
-
|
|
2715
|
-
|
|
3071
|
+
runTaskInBatches(inputs, ...args) {
|
|
3072
|
+
return this.serialStream(async function* (self2) {
|
|
2716
3073
|
self2.checkCapability("streaming");
|
|
2717
3074
|
const controls = self2.controls(args[0]);
|
|
2718
3075
|
const options = clonePayload(args[0]?.options ?? {});
|
|
@@ -2725,7 +3082,31 @@ var __exports__ = (() => {
|
|
|
2725
3082
|
}
|
|
2726
3083
|
let completed = false;
|
|
2727
3084
|
try {
|
|
2728
|
-
if (self2.
|
|
3085
|
+
if (self2.workerChannel) {
|
|
3086
|
+
self2.channelInputs = prepared()[Symbol.asyncIterator]();
|
|
3087
|
+
self2.streamProgress = controls.onProgress;
|
|
3088
|
+
try {
|
|
3089
|
+
await self2.invoke("stream-open", {}, options, controls);
|
|
3090
|
+
while (true) {
|
|
3091
|
+
const result = await self2.invoke("stream-next", {}, {}, controls);
|
|
3092
|
+
if (result.done)
|
|
3093
|
+
break;
|
|
3094
|
+
yield result.value;
|
|
3095
|
+
}
|
|
3096
|
+
} finally {
|
|
3097
|
+
try {
|
|
3098
|
+
if (!self2.invalid)
|
|
3099
|
+
await self2.invoke("stream-close", {}, {}, controls);
|
|
3100
|
+
} finally {
|
|
3101
|
+
await self2.channelInputs.return?.();
|
|
3102
|
+
self2.channelInputs = void 0;
|
|
3103
|
+
self2.streamProgress = void 0;
|
|
3104
|
+
if (self2.streamProgressId !== void 0)
|
|
3105
|
+
self2.callbackFailures.delete(self2.streamProgressId);
|
|
3106
|
+
self2.streamProgressId = void 0;
|
|
3107
|
+
}
|
|
3108
|
+
}
|
|
3109
|
+
} else if (self2.pool) {
|
|
2729
3110
|
await self2.invoke("stream-options", {}, options, controls);
|
|
2730
3111
|
yield* processOnWorkerInBatches(self2.descriptor, prepared(), {
|
|
2731
3112
|
...self2.workerOptions(controls),
|
|
@@ -2733,13 +3114,19 @@ var __exports__ = (() => {
|
|
|
2733
3114
|
workerInBatches: true
|
|
2734
3115
|
});
|
|
2735
3116
|
} else {
|
|
2736
|
-
for await (const output of self2.runtime.stream(prepared(), options,
|
|
3117
|
+
for await (const output of self2.runtime.stream(prepared(), options, self2.runtimeContext(controls))) {
|
|
2737
3118
|
controls.signal?.throwIfAborted();
|
|
2738
3119
|
yield clonePayload(output, controls.outputOwnership ?? "transfer");
|
|
2739
3120
|
}
|
|
2740
3121
|
}
|
|
2741
3122
|
completed = true;
|
|
2742
3123
|
} catch (error) {
|
|
3124
|
+
if (self2.workerChannel) {
|
|
3125
|
+
self2.invalid = true;
|
|
3126
|
+
self2.operationQueue.cancelPending(error);
|
|
3127
|
+
self2.controller.abort(error);
|
|
3128
|
+
await self2.workerChannel.destroy(error);
|
|
3129
|
+
}
|
|
2743
3130
|
if (self2.pool) {
|
|
2744
3131
|
self2.invalid = true;
|
|
2745
3132
|
await self2.pool.destroy(error);
|
|
@@ -2748,8 +3135,23 @@ var __exports__ = (() => {
|
|
|
2748
3135
|
} finally {
|
|
2749
3136
|
if (self2.pool && !completed)
|
|
2750
3137
|
self2.invalid = true;
|
|
3138
|
+
if (self2.workerChannel && !completed && !self2.invalid) {
|
|
3139
|
+
const reason = new Error("Worker stream ended before completion");
|
|
3140
|
+
self2.invalid = true;
|
|
3141
|
+
self2.operationQueue.cancelPending(reason);
|
|
3142
|
+
self2.controller.abort(reason);
|
|
3143
|
+
await self2.workerChannel.destroy(reason);
|
|
3144
|
+
}
|
|
2751
3145
|
}
|
|
2752
|
-
});
|
|
3146
|
+
}, args[0]?.signal);
|
|
3147
|
+
}
|
|
3148
|
+
/** Lifecycle status of this initialized task. */
|
|
3149
|
+
get state() {
|
|
3150
|
+
if (this.invalid)
|
|
3151
|
+
return "invalid";
|
|
3152
|
+
if (this.finalized)
|
|
3153
|
+
return "closed";
|
|
3154
|
+
return this.closed ? "closing" : "ready";
|
|
2753
3155
|
}
|
|
2754
3156
|
/** Drain accepted work, invoke destroy, and release execution capacity. */
|
|
2755
3157
|
close() {
|
|
@@ -2757,13 +3159,17 @@ var __exports__ = (() => {
|
|
|
2757
3159
|
this.closed = true;
|
|
2758
3160
|
this.closing = (async () => {
|
|
2759
3161
|
try {
|
|
2760
|
-
await this.
|
|
3162
|
+
await this.operationQueue.close();
|
|
2761
3163
|
if (!this.invalid)
|
|
2762
3164
|
await this.invoke("destroy", {}, {});
|
|
3165
|
+
else if (!this.pool && !this.workerChannel)
|
|
3166
|
+
await this.runtime.destroy();
|
|
2763
3167
|
} finally {
|
|
2764
3168
|
try {
|
|
2765
3169
|
await this.pool?.destroy();
|
|
3170
|
+
await this.workerChannel?.destroy();
|
|
2766
3171
|
} finally {
|
|
3172
|
+
this.finalized = true;
|
|
2767
3173
|
this.release();
|
|
2768
3174
|
}
|
|
2769
3175
|
}
|
|
@@ -2773,7 +3179,12 @@ var __exports__ = (() => {
|
|
|
2773
3179
|
}
|
|
2774
3180
|
/** Abort work. Local JavaScript must settle before its state can be destroyed. */
|
|
2775
3181
|
async terminate(reason = new Error("Task terminated")) {
|
|
3182
|
+
this.operationQueue.cancelPending(reason);
|
|
2776
3183
|
this.controller.abort(reason);
|
|
3184
|
+
if (this.workerChannel) {
|
|
3185
|
+
this.invalid = true;
|
|
3186
|
+
await this.workerChannel.destroy(reason);
|
|
3187
|
+
}
|
|
2777
3188
|
if (this.pool) {
|
|
2778
3189
|
this.invalid = true;
|
|
2779
3190
|
await this.pool.destroy(reason);
|
|
@@ -2782,7 +3193,7 @@ var __exports__ = (() => {
|
|
|
2782
3193
|
await this.close();
|
|
2783
3194
|
}
|
|
2784
3195
|
checkCapability(kind) {
|
|
2785
|
-
if (this.pool ? !this.task.worker?.capabilities[kind] : !(kind === "atomic" ? this.task.process : this.task.processInBatches)) {
|
|
3196
|
+
if (this.pool || this.workerChannel ? !this.task.worker?.capabilities[kind] : !(kind === "atomic" ? this.task.process : this.task.processInBatches)) {
|
|
2786
3197
|
throw new Error(`Task has no ${kind} processor for this execution route`);
|
|
2787
3198
|
}
|
|
2788
3199
|
}
|
|
@@ -2813,6 +3224,38 @@ var __exports__ = (() => {
|
|
|
2813
3224
|
assertPayload(input);
|
|
2814
3225
|
assertNoTransferAlias(input, options, prepared.inputOwnership);
|
|
2815
3226
|
const copiedOptions = clonePayload(options);
|
|
3227
|
+
if (this.workerChannel) {
|
|
3228
|
+
const progressId = this.nextProgressId++;
|
|
3229
|
+
const request = {
|
|
3230
|
+
input: clonePayload(input, prepared.inputOwnership),
|
|
3231
|
+
options: copiedOptions,
|
|
3232
|
+
outputOwnership: prepared.outputOwnership ?? "transfer",
|
|
3233
|
+
progressId
|
|
3234
|
+
};
|
|
3235
|
+
if (operation === "stream-open")
|
|
3236
|
+
this.streamProgressId = progressId;
|
|
3237
|
+
this.progressCallbacks.set(progressId, prepared.onProgress);
|
|
3238
|
+
let callbackFailure;
|
|
3239
|
+
try {
|
|
3240
|
+
const result2 = await this.workerChannel.channel.request(operation, request, prepared.signal, getTransferList(request));
|
|
3241
|
+
callbackFailure = this.callbackFailures.get(progressId) ?? (operation.startsWith("stream-") && this.streamProgressId !== void 0 ? this.callbackFailures.get(this.streamProgressId) : void 0);
|
|
3242
|
+
if (callbackFailure)
|
|
3243
|
+
throw callbackFailure.reason;
|
|
3244
|
+
return result2;
|
|
3245
|
+
} catch (reason) {
|
|
3246
|
+
if (operation === "process" && !prepared.signal?.aborted && (reason instanceof TaskRequestError || callbackFailure))
|
|
3247
|
+
throw reason;
|
|
3248
|
+
this.invalid = true;
|
|
3249
|
+
this.operationQueue.cancelPending(reason);
|
|
3250
|
+
this.controller.abort(reason);
|
|
3251
|
+
await this.workerChannel.destroy(reason);
|
|
3252
|
+
throw reason;
|
|
3253
|
+
} finally {
|
|
3254
|
+
this.progressCallbacks.delete(progressId);
|
|
3255
|
+
if (this.streamProgressId !== progressId)
|
|
3256
|
+
this.callbackFailures.delete(progressId);
|
|
3257
|
+
}
|
|
3258
|
+
}
|
|
2816
3259
|
if (this.pool) {
|
|
2817
3260
|
try {
|
|
2818
3261
|
return await processOnWorker(this.descriptor, { operation, input: clonePayload(input, prepared.inputOwnership), options: copiedOptions }, this.workerOptions({ ...prepared, inputOwnership: "transfer" }));
|
|
@@ -2825,7 +3268,7 @@ var __exports__ = (() => {
|
|
|
2825
3268
|
if (operation === "destroy")
|
|
2826
3269
|
return this.runtime.destroy();
|
|
2827
3270
|
const copied = clonePayload(input, prepared.inputOwnership);
|
|
2828
|
-
const context =
|
|
3271
|
+
const context = this.runtimeContext(prepared);
|
|
2829
3272
|
if (operation === "initialize") {
|
|
2830
3273
|
const result2 = await this.runtime.initialize(copied, context);
|
|
2831
3274
|
prepared.signal?.throwIfAborted();
|
|
@@ -2835,27 +3278,76 @@ var __exports__ = (() => {
|
|
|
2835
3278
|
prepared.signal?.throwIfAborted();
|
|
2836
3279
|
return clonePayload(result, prepared.outputOwnership ?? "transfer");
|
|
2837
3280
|
}
|
|
3281
|
+
runtimeContext(prepared) {
|
|
3282
|
+
return {
|
|
3283
|
+
...localContext(prepared),
|
|
3284
|
+
requestHost: async (operation, payload, controls = {}) => {
|
|
3285
|
+
const signal = prepared.signal ?? this.controller.signal;
|
|
3286
|
+
signal.throwIfAborted();
|
|
3287
|
+
const handler = this.initializationControls.onRequest;
|
|
3288
|
+
if (!handler)
|
|
3289
|
+
throw new Error("No host request handler configured");
|
|
3290
|
+
const result = await handler(operation, clonePayload(payload, controls.inputOwnership), signal);
|
|
3291
|
+
signal.throwIfAborted();
|
|
3292
|
+
return structuredClone(result, {
|
|
3293
|
+
transfer: controls.outputOwnership === "transfer" ? getTransferList(result) : []
|
|
3294
|
+
});
|
|
3295
|
+
},
|
|
3296
|
+
emitHost: (operation, payload) => this.initializationControls.onEvent?.(operation, structuredClone(payload))
|
|
3297
|
+
};
|
|
3298
|
+
}
|
|
2838
3299
|
enqueue(operation) {
|
|
2839
3300
|
if (this.closed)
|
|
2840
3301
|
return Promise.reject(new Error("Initialized task is closed"));
|
|
2841
|
-
|
|
2842
|
-
|
|
3302
|
+
return this.operationQueue.run("exclusive", operation);
|
|
3303
|
+
}
|
|
3304
|
+
serialStream(operation, signal) {
|
|
3305
|
+
const waiting = new AbortController();
|
|
3306
|
+
const queueSignal = AbortSignal.any([waiting.signal, this.controller.signal, signal].filter((value) => Boolean(value)));
|
|
3307
|
+
let started = false;
|
|
3308
|
+
const iterator = this.acquireStream(operation, queueSignal, () => {
|
|
3309
|
+
started = true;
|
|
2843
3310
|
});
|
|
2844
|
-
|
|
3311
|
+
const cancelWaiting = () => {
|
|
3312
|
+
if (!started)
|
|
3313
|
+
waiting.abort(new Error("Stream returned before execution"));
|
|
3314
|
+
};
|
|
3315
|
+
return {
|
|
3316
|
+
[Symbol.asyncIterator]() {
|
|
3317
|
+
return this;
|
|
3318
|
+
},
|
|
3319
|
+
next: () => iterator.next(),
|
|
3320
|
+
return: async () => {
|
|
3321
|
+
cancelWaiting();
|
|
3322
|
+
return iterator.return(void 0);
|
|
3323
|
+
},
|
|
3324
|
+
throw: async (reason) => {
|
|
3325
|
+
cancelWaiting();
|
|
3326
|
+
return iterator.throw(reason);
|
|
3327
|
+
}
|
|
3328
|
+
};
|
|
2845
3329
|
}
|
|
2846
|
-
async *
|
|
3330
|
+
async *acquireStream(operation, signal, onStart) {
|
|
2847
3331
|
if (this.closed)
|
|
2848
3332
|
throw new Error("Initialized task is closed");
|
|
2849
|
-
|
|
3333
|
+
let acquire;
|
|
3334
|
+
const acquired = new Promise((resolve2) => {
|
|
3335
|
+
acquire = resolve2;
|
|
3336
|
+
});
|
|
2850
3337
|
let release;
|
|
2851
|
-
|
|
3338
|
+
const held = new Promise((resolve2) => {
|
|
2852
3339
|
release = resolve2;
|
|
2853
3340
|
});
|
|
2854
|
-
|
|
2855
|
-
|
|
3341
|
+
const lease = this.operationQueue.run("exclusive", async () => {
|
|
3342
|
+
acquire();
|
|
3343
|
+
await held;
|
|
3344
|
+
}, signal);
|
|
3345
|
+
await Promise.race([acquired, lease]);
|
|
3346
|
+
if (signal.aborted) {
|
|
2856
3347
|
release();
|
|
2857
|
-
throw
|
|
3348
|
+
throw signal.reason;
|
|
2858
3349
|
}
|
|
3350
|
+
onStart();
|
|
2859
3351
|
const iterator = operation(this)[Symbol.asyncIterator]();
|
|
2860
3352
|
let stopping;
|
|
2861
3353
|
const stop = () => {
|
|
@@ -3171,11 +3663,6 @@ var __exports__ = (() => {
|
|
|
3171
3663
|
}
|
|
3172
3664
|
}
|
|
3173
3665
|
|
|
3174
|
-
// src/worker-utils/lib/worker-api/task-runtime.ts
|
|
3175
|
-
function normalizeTaskProgress(progress) {
|
|
3176
|
-
return { ...progress, phase: progress.phase ?? "process", unit: progress.unit ?? "items" };
|
|
3177
|
-
}
|
|
3178
|
-
|
|
3179
3666
|
// src/worker-utils/lib/worker-api/get-worker-url.ts
|
|
3180
3667
|
var warnedWorkerVersionFallbacks2 = /* @__PURE__ */ new Set();
|
|
3181
3668
|
function getCustomWorkerURL2(worker, options = {}) {
|
|
@@ -3231,6 +3718,11 @@ var __exports__ = (() => {
|
|
|
3231
3718
|
);
|
|
3232
3719
|
}
|
|
3233
3720
|
|
|
3721
|
+
// src/worker-utils/lib/worker-api/task-runtime.ts
|
|
3722
|
+
function normalizeTaskProgress(progress) {
|
|
3723
|
+
return { ...progress, phase: progress.phase ?? "process", unit: progress.unit ?? "items" };
|
|
3724
|
+
}
|
|
3725
|
+
|
|
3234
3726
|
// src/worker-utils/lib/worker-utils/get-transfer-list.ts
|
|
3235
3727
|
function getTransferList2(object, recursive = true, transfers) {
|
|
3236
3728
|
const transfersSet = transfers || /* @__PURE__ */ new Set();
|