@loaders.gl/tiles-3d 5.0.0-beta.2 → 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/README.md +1 -1
- package/dist/3d-tiles/3d-tiles-archive-loader.js +1 -1
- package/dist/3d-tiles/dist.dev.js +1393 -962
- package/dist/3d-tiles/dist.min.js +37 -37
- package/dist/3d-tiles/index.cjs +989 -987
- package/dist/3d-tiles/index.cjs.map +3 -3
- package/dist/3d-tiles/lib/classes/tile-3d-batch-table.d.ts.map +1 -1
- package/dist/3d-tiles/lib/classes/tile-3d-batch-table.js +12 -8
- package/dist/3d-tiles/lib/classes/tile-3d-batch-table.js.map +1 -1
- package/dist/3d-tiles/lib/parsers/parse-3d-tile-instanced-model.js +5 -1
- package/dist/3d-tiles/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
- package/dist/3d-tiles/lib/utils/version.js +1 -1
- package/dist/3d-tiles-archive-writer.cjs +1 -1
- package/dist/cesium-ion-loader-with-parser.cjs +983 -981
- package/dist/cesium-ion-loader-with-parser.cjs.map +3 -3
- package/dist/copc/copc-source-loader.js +2 -2
- package/dist/copc/copc-source-loader.js.map +1 -1
- package/dist/copc/copc-writer.js +1 -1
- package/dist/copc/index.cjs +365 -170
- package/dist/copc/index.cjs.map +3 -3
- package/dist/dist.dev.js +231 -38
- package/dist/dist.min.js +10 -10
- package/dist/i3s/arcgis-webscene-loader.js +1 -1
- package/dist/i3s/dist.dev.js +6591 -1184
- package/dist/i3s/dist.min.js +55 -47
- package/dist/i3s/i3s-attribute-loader.js +1 -1
- package/dist/i3s/i3s-building-scene-layer-loader.js +1 -1
- package/dist/i3s/i3s-content-loader.js +1 -1
- package/dist/i3s/i3s-lepcc-loader-types.js +1 -1
- package/dist/i3s/i3s-loader.js +1 -1
- package/dist/i3s/i3s-node-page-loader.js +1 -1
- package/dist/i3s/i3s-slpk-loader.js +1 -1
- package/dist/i3s/i3s-slpk-writer.js +1 -1
- package/dist/i3s/index.cjs +4763 -1136
- package/dist/i3s/index.cjs.map +3 -3
- package/dist/i3s-content-worker-node.js +11 -11
- package/dist/i3s-content-worker-node.js.map +4 -4
- package/dist/i3s-content-worker.js +1148 -391
- package/dist/i3s-lepcc-worker-node.js +609 -44
- package/dist/i3s-lepcc-worker-node.js.map +4 -4
- package/dist/i3s-lepcc-worker.js +575 -40
- package/dist/i3s-mesh-writer.cjs +8880 -5253
- package/dist/i3s-mesh-writer.cjs.map +3 -3
- package/dist/i3s-slpk-writer.cjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/point-cloud-tile-source-loader-types.js +1 -1
- package/dist/point-cloud-tile-source-loader.cjs +1 -1
- package/dist/potree/dist.dev.js +310 -110
- package/dist/potree/dist.min.js +31 -31
- package/dist/potree/index.cjs +19 -166
- package/dist/potree/index.cjs.map +3 -3
- package/dist/potree/potree-bin-loader.js +1 -1
- package/dist/potree/potree-hierarchy-chunk-loader.js +1 -1
- package/dist/potree/potree-loader-types.js +1 -1
- package/dist/potree/potree-source-loader.js +1 -1
- package/dist/potree/potree-writer.js +1 -1
- package/dist/potree-loader.cjs +1 -1
- package/package.json +13 -13
- package/src/3d-tiles/lib/classes/tile-3d-batch-table.ts +12 -8
- package/src/3d-tiles/lib/parsers/parse-3d-tile-instanced-model.ts +4 -1
- package/src/copc/copc-source-loader.ts +1 -1
package/dist/i3s-lepcc-worker.js
CHANGED
|
@@ -15,6 +15,33 @@
|
|
|
15
15
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
// ../core/src/worker-utils/lib/node/worker_threads-browser.ts
|
|
19
|
+
var worker_threads_browser_exports = {};
|
|
20
|
+
__export(worker_threads_browser_exports, {
|
|
21
|
+
NodeWorker: () => NodeWorker,
|
|
22
|
+
parentPort: () => parentPort2
|
|
23
|
+
});
|
|
24
|
+
var NodeWorker, parentPort2;
|
|
25
|
+
var init_worker_threads_browser = __esm({
|
|
26
|
+
"../core/src/worker-utils/lib/node/worker_threads-browser.ts"() {
|
|
27
|
+
"use strict";
|
|
28
|
+
NodeWorker = class {
|
|
29
|
+
/** Restores the native worker constructor when this browser shim is embedded in a Node bundle. */
|
|
30
|
+
constructor(...arguments_) {
|
|
31
|
+
const runtimeProcess = globalThis.process;
|
|
32
|
+
const WorkerConstructor = runtimeProcess?.getBuiltinModule?.("node:worker_threads").Worker;
|
|
33
|
+
if (WorkerConstructor) {
|
|
34
|
+
return new WorkerConstructor(...arguments_);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** No-op browser fallback matching the native Worker API. */
|
|
38
|
+
terminate() {
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
parentPort2 = null;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
18
45
|
// dist/i3s/i3s-lepcc.js
|
|
19
46
|
function readMagic2(bytes) {
|
|
20
47
|
if (bytes.byteLength < 10) {
|
|
@@ -541,7 +568,7 @@
|
|
|
541
568
|
"dist/i3s/i3s-lepcc-loader-types.js"() {
|
|
542
569
|
"use strict";
|
|
543
570
|
init_i3s_format();
|
|
544
|
-
VERSION = true ? "5.0.0-beta.
|
|
571
|
+
VERSION = true ? "5.0.0-beta.5" : "latest";
|
|
545
572
|
I3SLEPCCLoader = {
|
|
546
573
|
...I3SLEPCCFormat2,
|
|
547
574
|
dataType: null,
|
|
@@ -594,10 +621,10 @@
|
|
|
594
621
|
}
|
|
595
622
|
});
|
|
596
623
|
|
|
597
|
-
// ../../node_modules/@math.gl/
|
|
598
|
-
var parentPort = null;
|
|
624
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/node/worker_threads-browser.js
|
|
625
|
+
var parentPort = globalThis.process?.getBuiltinModule?.("node:worker_threads")?.parentPort ?? null;
|
|
599
626
|
|
|
600
|
-
// ../../node_modules/@math.gl/
|
|
627
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-transfer-list.js
|
|
601
628
|
function getTransferList(object, recursive = true, transfers) {
|
|
602
629
|
const transfersSet = transfers || /* @__PURE__ */ new Set();
|
|
603
630
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -610,6 +637,9 @@
|
|
|
610
637
|
else if (ArrayBuffer.isView(value)) {
|
|
611
638
|
if (isTransferable(value.buffer))
|
|
612
639
|
transfersSet.add(value.buffer);
|
|
640
|
+
} else if (recursive && typeof MessageChannel !== "undefined" && value instanceof MessageChannel) {
|
|
641
|
+
visit(value.port1);
|
|
642
|
+
visit(value.port2);
|
|
613
643
|
} else if (recursive && value instanceof Map) {
|
|
614
644
|
for (const [key, item] of value) {
|
|
615
645
|
visit(key);
|
|
@@ -645,7 +675,7 @@
|
|
|
645
675
|
return false;
|
|
646
676
|
}
|
|
647
677
|
|
|
648
|
-
// ../../node_modules/@math.gl/
|
|
678
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-body.js
|
|
649
679
|
async function getParentPort() {
|
|
650
680
|
return parentPort;
|
|
651
681
|
}
|
|
@@ -661,16 +691,16 @@
|
|
|
661
691
|
*/
|
|
662
692
|
static set onmessage(onMessage) {
|
|
663
693
|
async function handleMessage(message) {
|
|
664
|
-
const
|
|
665
|
-
const { type, payload } =
|
|
694
|
+
const parentPort3 = await getParentPort();
|
|
695
|
+
const { type, payload } = parentPort3 ? message : message.data;
|
|
666
696
|
onMessage(type, payload);
|
|
667
697
|
}
|
|
668
|
-
getParentPort().then((
|
|
669
|
-
if (
|
|
670
|
-
|
|
698
|
+
getParentPort().then((parentPort3) => {
|
|
699
|
+
if (parentPort3) {
|
|
700
|
+
parentPort3.on("message", (message) => {
|
|
671
701
|
handleMessage(message);
|
|
672
702
|
});
|
|
673
|
-
|
|
703
|
+
parentPort3.on("exit", () => console.debug("Node worker closing"));
|
|
674
704
|
} else {
|
|
675
705
|
globalThis.onmessage = handleMessage;
|
|
676
706
|
}
|
|
@@ -688,9 +718,9 @@
|
|
|
688
718
|
};
|
|
689
719
|
onMessageWrapperMap.set(onMessage, onMessageWrapper);
|
|
690
720
|
}
|
|
691
|
-
const
|
|
692
|
-
if (
|
|
693
|
-
|
|
721
|
+
const parentPort3 = await getParentPort();
|
|
722
|
+
if (parentPort3) {
|
|
723
|
+
parentPort3.on("message", onMessageWrapper);
|
|
694
724
|
} else {
|
|
695
725
|
globalThis.addEventListener("message", onMessageWrapper);
|
|
696
726
|
}
|
|
@@ -701,9 +731,9 @@
|
|
|
701
731
|
if (!onMessageWrapper) {
|
|
702
732
|
return;
|
|
703
733
|
}
|
|
704
|
-
const
|
|
705
|
-
if (
|
|
706
|
-
|
|
734
|
+
const parentPort3 = await getParentPort();
|
|
735
|
+
if (parentPort3) {
|
|
736
|
+
parentPort3.off("message", onMessageWrapper);
|
|
707
737
|
} else {
|
|
708
738
|
globalThis.removeEventListener("message", onMessageWrapper);
|
|
709
739
|
}
|
|
@@ -713,12 +743,12 @@
|
|
|
713
743
|
* @param type
|
|
714
744
|
* @param payload
|
|
715
745
|
*/
|
|
716
|
-
static async postMessage(type, payload) {
|
|
746
|
+
static async postMessage(type, payload, copy = false) {
|
|
717
747
|
const data = { source: "loaders.gl", type, payload };
|
|
718
|
-
const transferList = getTransferList(payload);
|
|
719
|
-
const
|
|
720
|
-
if (
|
|
721
|
-
|
|
748
|
+
const transferList = copy ? [] : getTransferList(payload);
|
|
749
|
+
const parentPort3 = await getParentPort();
|
|
750
|
+
if (parentPort3) {
|
|
751
|
+
parentPort3.postMessage(data, transferList);
|
|
722
752
|
} else {
|
|
723
753
|
globalThis.postMessage(data, transferList);
|
|
724
754
|
}
|
|
@@ -732,7 +762,7 @@
|
|
|
732
762
|
return messageData && typeof messageData.source === "string" && messageData.source.startsWith("loaders.gl") ? messageData : null;
|
|
733
763
|
}
|
|
734
764
|
|
|
735
|
-
// ../../node_modules/@math.gl/
|
|
765
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/async-queue/async-queue.js
|
|
736
766
|
var AsyncQueue = class {
|
|
737
767
|
constructor() {
|
|
738
768
|
this._values = [];
|
|
@@ -799,7 +829,7 @@
|
|
|
799
829
|
}
|
|
800
830
|
};
|
|
801
831
|
|
|
802
|
-
// ../../node_modules/@math.gl/
|
|
832
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/shared-state.js
|
|
803
833
|
var SharedWorkerState = class {
|
|
804
834
|
constructor(buffer) {
|
|
805
835
|
if (typeof SharedArrayBuffer === "undefined" || !(buffer instanceof SharedArrayBuffer) || buffer.byteLength !== 16)
|
|
@@ -838,12 +868,19 @@
|
|
|
838
868
|
}
|
|
839
869
|
};
|
|
840
870
|
|
|
841
|
-
// ../../node_modules/@math.gl/
|
|
871
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js
|
|
872
|
+
function validateOutputOwnership(ownership) {
|
|
873
|
+
if (ownership !== void 0 && ownership !== "copy" && ownership !== "transfer") {
|
|
874
|
+
throw new Error("Invalid worker output ownership");
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/create-worker.js
|
|
842
879
|
var requestId = 0;
|
|
843
880
|
var activeController = null;
|
|
844
881
|
var activeInputBatches = null;
|
|
845
882
|
var activeOutputAcknowledgements = null;
|
|
846
|
-
async function createWorker(
|
|
883
|
+
async function createWorker(process2, processInBatches, preload) {
|
|
847
884
|
if (!await WorkerBody.inWorkerThread()) {
|
|
848
885
|
return;
|
|
849
886
|
}
|
|
@@ -884,23 +921,26 @@
|
|
|
884
921
|
}
|
|
885
922
|
switch (type) {
|
|
886
923
|
case "preload":
|
|
924
|
+
await preload?.();
|
|
887
925
|
WorkerBody.postMessage("done", {});
|
|
888
926
|
break;
|
|
889
927
|
case "process":
|
|
890
928
|
throwIfAborted();
|
|
891
|
-
|
|
929
|
+
validateOutputOwnership(payload.options?.["outputOwnership"]);
|
|
930
|
+
if (!process2) {
|
|
892
931
|
throw new Error("Worker does not support atomic processing");
|
|
893
932
|
}
|
|
894
|
-
const result = await
|
|
933
|
+
const result = await process2(payload.input, payload.options || {}, jobContext, payload.context || {});
|
|
895
934
|
throwIfAborted();
|
|
896
935
|
reporter?.finish();
|
|
897
936
|
await WorkerBody.postMessage("done", {
|
|
898
937
|
result,
|
|
899
938
|
executionMs: performance.now() - startedAt
|
|
900
|
-
});
|
|
939
|
+
}, payload.options?.["outputOwnership"] === "copy");
|
|
901
940
|
break;
|
|
902
941
|
case "process-in-batches":
|
|
903
942
|
throwIfAborted();
|
|
943
|
+
validateOutputOwnership(payload.options?.["outputOwnership"]);
|
|
904
944
|
if (!processInBatches) {
|
|
905
945
|
throw new Error("Worker does not support batched processing");
|
|
906
946
|
}
|
|
@@ -912,7 +952,7 @@
|
|
|
912
952
|
const resultIterator = processInBatches(createDemandDrivenIterator(inputBatches), payload.options || {}, jobContext, payload.context || {});
|
|
913
953
|
for await (const batch of resultIterator) {
|
|
914
954
|
throwIfAborted();
|
|
915
|
-
await WorkerBody.postMessage("output-batch", { result: batch });
|
|
955
|
+
await WorkerBody.postMessage("output-batch", { result: batch }, payload.options?.["outputOwnership"] === "copy");
|
|
916
956
|
await outputAcknowledgements.next();
|
|
917
957
|
}
|
|
918
958
|
throwIfAborted();
|
|
@@ -1010,14 +1050,14 @@
|
|
|
1010
1050
|
});
|
|
1011
1051
|
}
|
|
1012
1052
|
function createProgressReporter() {
|
|
1013
|
-
let
|
|
1053
|
+
let pending2;
|
|
1014
1054
|
let finished = false;
|
|
1015
1055
|
let scheduled = false;
|
|
1016
1056
|
const flush = () => {
|
|
1017
1057
|
scheduled = false;
|
|
1018
|
-
if (
|
|
1019
|
-
WorkerBody.postMessage("progress", { progress:
|
|
1020
|
-
|
|
1058
|
+
if (pending2) {
|
|
1059
|
+
WorkerBody.postMessage("progress", { progress: pending2 });
|
|
1060
|
+
pending2 = void 0;
|
|
1021
1061
|
}
|
|
1022
1062
|
};
|
|
1023
1063
|
return {
|
|
@@ -1025,9 +1065,9 @@
|
|
|
1025
1065
|
report(progress) {
|
|
1026
1066
|
if (finished)
|
|
1027
1067
|
return;
|
|
1028
|
-
if (
|
|
1068
|
+
if (pending2 && pending2.phase !== progress.phase)
|
|
1029
1069
|
flush();
|
|
1030
|
-
|
|
1070
|
+
pending2 = { ...progress };
|
|
1031
1071
|
if (!scheduled) {
|
|
1032
1072
|
scheduled = true;
|
|
1033
1073
|
setTimeout(flush, 0);
|
|
@@ -1036,21 +1076,516 @@
|
|
|
1036
1076
|
/** Flushes final progress and suppresses reports from stale callbacks. */
|
|
1037
1077
|
finish(discard = false) {
|
|
1038
1078
|
if (discard)
|
|
1039
|
-
|
|
1079
|
+
pending2 = void 0;
|
|
1040
1080
|
flush();
|
|
1041
1081
|
finished = true;
|
|
1042
1082
|
}
|
|
1043
1083
|
};
|
|
1044
1084
|
}
|
|
1045
1085
|
|
|
1046
|
-
// ../../node_modules/@math.gl/
|
|
1086
|
+
// ../../node_modules/@math.gl/tasks/dist/worker-utils/index.js
|
|
1047
1087
|
var import_meta = {};
|
|
1048
1088
|
var path = typeof __filename === "string" ? __filename.replace(/\\/g, "/") : "";
|
|
1049
1089
|
var moduleUrl = path ? `file://${path.startsWith("/") ? "" : "/"}${encodeURI(path).replace(/#/g, "%23").replace(/\?/g, "%3F")}` : import_meta.url;
|
|
1050
1090
|
|
|
1091
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js
|
|
1092
|
+
var pending = /* @__PURE__ */ new WeakMap();
|
|
1093
|
+
var loaded = /* @__PURE__ */ new WeakSet();
|
|
1094
|
+
function preloadTaskCode(task, signal) {
|
|
1095
|
+
if (!task.preload)
|
|
1096
|
+
return Promise.resolve();
|
|
1097
|
+
let promise = pending.get(task);
|
|
1098
|
+
if (!promise) {
|
|
1099
|
+
promise = Promise.resolve().then(() => task.preload()).then(() => {
|
|
1100
|
+
loaded.add(task);
|
|
1101
|
+
});
|
|
1102
|
+
pending.set(task, promise);
|
|
1103
|
+
void promise.catch(() => pending.delete(task));
|
|
1104
|
+
}
|
|
1105
|
+
return withSignal(promise, signal);
|
|
1106
|
+
}
|
|
1107
|
+
function withSignal(operation, signal) {
|
|
1108
|
+
if (!signal)
|
|
1109
|
+
return operation;
|
|
1110
|
+
return new Promise((resolve, reject) => {
|
|
1111
|
+
const abort = () => {
|
|
1112
|
+
signal.removeEventListener("abort", abort);
|
|
1113
|
+
reject(signal.reason);
|
|
1114
|
+
};
|
|
1115
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
1116
|
+
if (signal.aborted)
|
|
1117
|
+
abort();
|
|
1118
|
+
operation.then((value) => {
|
|
1119
|
+
signal.removeEventListener("abort", abort);
|
|
1120
|
+
resolve(value);
|
|
1121
|
+
}, (error) => {
|
|
1122
|
+
signal.removeEventListener("abort", abort);
|
|
1123
|
+
reject(error);
|
|
1124
|
+
});
|
|
1125
|
+
});
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-channel.js
|
|
1129
|
+
var TaskRequestError = class extends Error {
|
|
1130
|
+
};
|
|
1131
|
+
var TaskChannel = class {
|
|
1132
|
+
constructor(options) {
|
|
1133
|
+
this.options = options;
|
|
1134
|
+
this.nextId = 1;
|
|
1135
|
+
this.pending = /* @__PURE__ */ new Map();
|
|
1136
|
+
this.incoming = /* @__PURE__ */ new Map();
|
|
1137
|
+
}
|
|
1138
|
+
/** Send a request without serializing other in-flight requests. */
|
|
1139
|
+
request(operation, value, signal, transfer = []) {
|
|
1140
|
+
if (this.failure)
|
|
1141
|
+
return Promise.reject(this.failure.reason);
|
|
1142
|
+
if (signal?.aborted)
|
|
1143
|
+
return Promise.reject(signal.reason);
|
|
1144
|
+
const id = this.nextId++;
|
|
1145
|
+
return new Promise((resolve, reject) => {
|
|
1146
|
+
const abort = () => {
|
|
1147
|
+
const pending2 = this.pending.get(id);
|
|
1148
|
+
if (!pending2)
|
|
1149
|
+
return;
|
|
1150
|
+
this.pending.delete(id);
|
|
1151
|
+
pending2.cleanup();
|
|
1152
|
+
reject(signal?.reason);
|
|
1153
|
+
this.send({ source: "math.gl/tasks", kind: "cancel", id });
|
|
1154
|
+
};
|
|
1155
|
+
this.pending.set(id, {
|
|
1156
|
+
resolve,
|
|
1157
|
+
reject,
|
|
1158
|
+
cleanup: () => signal?.removeEventListener("abort", abort)
|
|
1159
|
+
});
|
|
1160
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
1161
|
+
this.send({ source: "math.gl/tasks", kind: "request", id, operation, value }, transfer);
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
/** Send a one-way notification. */
|
|
1165
|
+
emit(operation, value, transfer = []) {
|
|
1166
|
+
if (this.failure)
|
|
1167
|
+
throw this.failure.reason;
|
|
1168
|
+
this.send({ source: "math.gl/tasks", kind: "event", id: 0, operation, value }, transfer);
|
|
1169
|
+
}
|
|
1170
|
+
/** Dispatch a transport message; unrelated protocols are ignored. */
|
|
1171
|
+
receive(message) {
|
|
1172
|
+
if (this.failure || message?.source !== "math.gl/tasks")
|
|
1173
|
+
return;
|
|
1174
|
+
if (message.kind === "failure") {
|
|
1175
|
+
const reason = new Error(message.error?.message ?? "Task channel failed");
|
|
1176
|
+
this.close(reason);
|
|
1177
|
+
this.options.onFailure?.(reason);
|
|
1178
|
+
} else if (message.kind === "result" || message.kind === "error") {
|
|
1179
|
+
const pending2 = this.pending.get(message.id);
|
|
1180
|
+
if (!pending2)
|
|
1181
|
+
return;
|
|
1182
|
+
this.pending.delete(message.id);
|
|
1183
|
+
pending2.cleanup();
|
|
1184
|
+
if (message.kind === "result")
|
|
1185
|
+
pending2.resolve(message.value);
|
|
1186
|
+
else {
|
|
1187
|
+
const error = new TaskRequestError(message.error?.message ?? "Task request failed");
|
|
1188
|
+
error.name = message.error?.name ?? "Error";
|
|
1189
|
+
pending2.reject(error);
|
|
1190
|
+
}
|
|
1191
|
+
} else if (message.kind === "cancel") {
|
|
1192
|
+
this.incoming.get(message.id)?.abort(new DOMException("Task request cancelled", "AbortError"));
|
|
1193
|
+
} else if (message.kind === "event") {
|
|
1194
|
+
try {
|
|
1195
|
+
this.options.handleEvent?.(message.operation, message.value);
|
|
1196
|
+
} catch (error) {
|
|
1197
|
+
this.fail(error);
|
|
1198
|
+
}
|
|
1199
|
+
} else if (message.kind === "request") {
|
|
1200
|
+
if (this.incoming.has(message.id)) {
|
|
1201
|
+
this.fail(new Error("Duplicate task request identifier"));
|
|
1202
|
+
return;
|
|
1203
|
+
}
|
|
1204
|
+
const controller = new AbortController();
|
|
1205
|
+
this.incoming.set(message.id, controller);
|
|
1206
|
+
void Promise.resolve().then(() => {
|
|
1207
|
+
controller.signal.throwIfAborted();
|
|
1208
|
+
return this.options.handleRequest(message.operation, message.value, controller.signal);
|
|
1209
|
+
}).then((value) => {
|
|
1210
|
+
if (!controller.signal.aborted && !this.failure) {
|
|
1211
|
+
this.send({ source: "math.gl/tasks", kind: "result", id: message.id, value }, this.options.getResultTransferList?.(value, message.value));
|
|
1212
|
+
}
|
|
1213
|
+
}).catch((reason) => {
|
|
1214
|
+
if (!controller.signal.aborted && !this.failure) {
|
|
1215
|
+
this.send({
|
|
1216
|
+
source: "math.gl/tasks",
|
|
1217
|
+
kind: "error",
|
|
1218
|
+
id: message.id,
|
|
1219
|
+
error: {
|
|
1220
|
+
name: reason instanceof Error ? reason.name : "Error",
|
|
1221
|
+
message: reason instanceof Error ? reason.message : String(reason)
|
|
1222
|
+
}
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
}).finally(() => this.incoming.delete(message.id));
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
/** Reject all outstanding calls with a common cause and abort incoming callbacks. */
|
|
1229
|
+
close(reason = new Error("Task channel closed")) {
|
|
1230
|
+
if (this.failure)
|
|
1231
|
+
return;
|
|
1232
|
+
this.failure = { reason };
|
|
1233
|
+
for (const pending2 of this.pending.values()) {
|
|
1234
|
+
pending2.cleanup();
|
|
1235
|
+
pending2.reject(reason);
|
|
1236
|
+
}
|
|
1237
|
+
this.pending.clear();
|
|
1238
|
+
for (const controller of this.incoming.values())
|
|
1239
|
+
controller.abort(reason);
|
|
1240
|
+
this.incoming.clear();
|
|
1241
|
+
}
|
|
1242
|
+
send(message, transfer = []) {
|
|
1243
|
+
if (this.failure)
|
|
1244
|
+
return;
|
|
1245
|
+
try {
|
|
1246
|
+
this.options.send(message, transfer);
|
|
1247
|
+
} catch (error) {
|
|
1248
|
+
this.fail(error);
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
/** Invalidate the channel and notify the peer when the transport still works. */
|
|
1252
|
+
fail(reason) {
|
|
1253
|
+
if (this.failure)
|
|
1254
|
+
return;
|
|
1255
|
+
this.close(reason);
|
|
1256
|
+
try {
|
|
1257
|
+
this.options.send({
|
|
1258
|
+
source: "math.gl/tasks",
|
|
1259
|
+
kind: "failure",
|
|
1260
|
+
id: 0,
|
|
1261
|
+
error: {
|
|
1262
|
+
name: reason instanceof Error ? reason.name : "Error",
|
|
1263
|
+
message: reason instanceof Error ? reason.message : String(reason)
|
|
1264
|
+
}
|
|
1265
|
+
}, []);
|
|
1266
|
+
} catch {
|
|
1267
|
+
}
|
|
1268
|
+
this.options.onFailure?.(reason);
|
|
1269
|
+
}
|
|
1270
|
+
};
|
|
1271
|
+
|
|
1272
|
+
// ../../node_modules/@math.gl/tasks/dist/tasks/task-runtime.js
|
|
1273
|
+
function assertPayload(value) {
|
|
1274
|
+
if (!value || typeof value !== "object" || Object.getPrototypeOf(value) !== Object.prototype) {
|
|
1275
|
+
throw new TypeError("Task payloads must be plain objects with named fields");
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
function clonePayload(value, ownership = "copy") {
|
|
1279
|
+
assertPayload(value);
|
|
1280
|
+
if (!["copy", "transfer", "share"].includes(ownership))
|
|
1281
|
+
throw new TypeError("Invalid input ownership");
|
|
1282
|
+
const transfer = getTransferList(value);
|
|
1283
|
+
if (ownership === "share" && transfer.length)
|
|
1284
|
+
throw new TypeError("Share requires shared storage");
|
|
1285
|
+
return structuredClone(value, {
|
|
1286
|
+
transfer: ownership === "transfer" ? transfer : []
|
|
1287
|
+
});
|
|
1288
|
+
}
|
|
1289
|
+
function taskContext(state, context = {}) {
|
|
1290
|
+
const signal = context.signal ?? new AbortController().signal;
|
|
1291
|
+
return {
|
|
1292
|
+
state,
|
|
1293
|
+
signal,
|
|
1294
|
+
requestHost: async (operation, payload, controls) => {
|
|
1295
|
+
signal.throwIfAborted();
|
|
1296
|
+
if (!context.requestHost)
|
|
1297
|
+
throw new Error("No host request handler configured");
|
|
1298
|
+
return context.requestHost(operation, payload, controls);
|
|
1299
|
+
},
|
|
1300
|
+
emitHost: (operation, payload) => {
|
|
1301
|
+
signal.throwIfAborted();
|
|
1302
|
+
context.emitHost?.(operation, payload);
|
|
1303
|
+
},
|
|
1304
|
+
throwIfAborted: () => {
|
|
1305
|
+
signal.throwIfAborted();
|
|
1306
|
+
context.throwIfAborted?.();
|
|
1307
|
+
},
|
|
1308
|
+
reportProgress: (progress) => context.reportProgress?.({
|
|
1309
|
+
...progress,
|
|
1310
|
+
phase: progress.phase ?? "process",
|
|
1311
|
+
unit: progress.unit ?? "items"
|
|
1312
|
+
})
|
|
1313
|
+
};
|
|
1314
|
+
}
|
|
1315
|
+
var TaskRuntime = class {
|
|
1316
|
+
constructor(task) {
|
|
1317
|
+
this.task = task;
|
|
1318
|
+
this.initialized = false;
|
|
1319
|
+
}
|
|
1320
|
+
async initialize(input, context = {}) {
|
|
1321
|
+
if (this.initialized)
|
|
1322
|
+
throw new Error("Task is already initialized");
|
|
1323
|
+
assertPayload(input);
|
|
1324
|
+
await preloadTaskCode(this.task, context.signal);
|
|
1325
|
+
context.signal?.throwIfAborted();
|
|
1326
|
+
this.state = await this.task.initialize?.(input, taskContext(void 0, context));
|
|
1327
|
+
this.initialized = true;
|
|
1328
|
+
return {};
|
|
1329
|
+
}
|
|
1330
|
+
async destroy() {
|
|
1331
|
+
if (this.initialized) {
|
|
1332
|
+
this.initialized = false;
|
|
1333
|
+
const state = this.state;
|
|
1334
|
+
this.state = void 0;
|
|
1335
|
+
if (this.task.initialize)
|
|
1336
|
+
await this.task.destroy?.(state);
|
|
1337
|
+
}
|
|
1338
|
+
return {};
|
|
1339
|
+
}
|
|
1340
|
+
async process(input, options, context = {}) {
|
|
1341
|
+
if (!this.initialized)
|
|
1342
|
+
throw new Error("Task is not initialized");
|
|
1343
|
+
if (!this.task.process)
|
|
1344
|
+
throw new Error("Task has no atomic processor");
|
|
1345
|
+
assertPayload(input);
|
|
1346
|
+
const result = await this.task.process(input, options, taskContext(this.state, context));
|
|
1347
|
+
assertPayload(result);
|
|
1348
|
+
return result;
|
|
1349
|
+
}
|
|
1350
|
+
async *stream(inputs, options, context = {}) {
|
|
1351
|
+
if (!this.initialized)
|
|
1352
|
+
throw new Error("Task is not initialized");
|
|
1353
|
+
if (!this.task.processInBatches)
|
|
1354
|
+
throw new Error("Task has no streaming processor");
|
|
1355
|
+
for await (const output of this.task.processInBatches(inputs, options, taskContext(this.state, context))) {
|
|
1356
|
+
assertPayload(output);
|
|
1357
|
+
yield output;
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
};
|
|
1361
|
+
async function initializeTaskWorker(task) {
|
|
1362
|
+
if (!await WorkerBody.inWorkerThread())
|
|
1363
|
+
throw new Error("initializeTaskWorker must run inside a worker");
|
|
1364
|
+
if (installed)
|
|
1365
|
+
throw new Error("A task is already installed in this worker");
|
|
1366
|
+
installed = true;
|
|
1367
|
+
const runtime = new TaskRuntime(task);
|
|
1368
|
+
let channelStream;
|
|
1369
|
+
const channel = new TaskChannel({
|
|
1370
|
+
getResultTransferList: (value, request) => request.outputOwnership === "transfer" ? getTransferList(value) : [],
|
|
1371
|
+
send: (message, transfer) => {
|
|
1372
|
+
const snapshot = structuredClone(message, { transfer });
|
|
1373
|
+
void WorkerBody.postMessage("task-channel", snapshot).catch((reason) => channel.fail(reason));
|
|
1374
|
+
},
|
|
1375
|
+
handleRequest: async (operation, value, signal) => {
|
|
1376
|
+
const request = value;
|
|
1377
|
+
const context = {
|
|
1378
|
+
signal,
|
|
1379
|
+
reportProgress: (progress) => channel.emit("task:progress", { id: request.progressId, progress }),
|
|
1380
|
+
requestHost: (operation2, payload, controls = {}) => {
|
|
1381
|
+
const request2 = {
|
|
1382
|
+
operation: operation2,
|
|
1383
|
+
payload: clonePayload(payload, controls.inputOwnership),
|
|
1384
|
+
outputOwnership: controls.outputOwnership ?? "copy"
|
|
1385
|
+
};
|
|
1386
|
+
return channel.request("task:host-request", request2, signal, getTransferList(request2));
|
|
1387
|
+
},
|
|
1388
|
+
emitHost: (operation2, payload) => channel.emit("task:host-event", { operation: operation2, payload, id: request.progressId })
|
|
1389
|
+
};
|
|
1390
|
+
switch (operation) {
|
|
1391
|
+
case "initialize":
|
|
1392
|
+
return runtime.initialize(request.input, context);
|
|
1393
|
+
case "process":
|
|
1394
|
+
return runtime.process(request.input, request.options, context);
|
|
1395
|
+
case "stream-open": {
|
|
1396
|
+
if (channelStream)
|
|
1397
|
+
throw new Error("A task stream is already open");
|
|
1398
|
+
async function* inputs() {
|
|
1399
|
+
while (true) {
|
|
1400
|
+
const result = await channel.request("task:next-input", { outputOwnership: "transfer" }, signal);
|
|
1401
|
+
if (result.done)
|
|
1402
|
+
return;
|
|
1403
|
+
yield result.value;
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
channelStream = runtime.stream(inputs(), request.options, context)[Symbol.asyncIterator]();
|
|
1407
|
+
return {};
|
|
1408
|
+
}
|
|
1409
|
+
case "stream-next":
|
|
1410
|
+
if (!channelStream)
|
|
1411
|
+
throw new Error("No active task stream");
|
|
1412
|
+
return channelStream.next();
|
|
1413
|
+
case "stream-close":
|
|
1414
|
+
try {
|
|
1415
|
+
await channelStream?.return?.();
|
|
1416
|
+
} finally {
|
|
1417
|
+
channelStream = void 0;
|
|
1418
|
+
}
|
|
1419
|
+
return {};
|
|
1420
|
+
case "destroy":
|
|
1421
|
+
return runtime.destroy();
|
|
1422
|
+
default:
|
|
1423
|
+
throw new Error("Unknown task channel operation");
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
});
|
|
1427
|
+
await WorkerBody.addEventListener((type, payload) => {
|
|
1428
|
+
if (type === "task-channel")
|
|
1429
|
+
channel.receive(payload);
|
|
1430
|
+
});
|
|
1431
|
+
let streamOptions = {};
|
|
1432
|
+
return createWorker(async (request, _options, context) => {
|
|
1433
|
+
switch (request.operation) {
|
|
1434
|
+
case "initialize":
|
|
1435
|
+
return runtime.initialize(request.input, context);
|
|
1436
|
+
case "destroy":
|
|
1437
|
+
return runtime.destroy();
|
|
1438
|
+
case "stream-options":
|
|
1439
|
+
streamOptions = request.options;
|
|
1440
|
+
return {};
|
|
1441
|
+
case "process":
|
|
1442
|
+
return runtime.process(request.input, request.options, context);
|
|
1443
|
+
default:
|
|
1444
|
+
throw new Error("Unknown task operation");
|
|
1445
|
+
}
|
|
1446
|
+
}, async function* (inputs, _options, context) {
|
|
1447
|
+
async function* batches() {
|
|
1448
|
+
for await (const input of inputs) {
|
|
1449
|
+
assertPayload(input);
|
|
1450
|
+
yield input;
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
try {
|
|
1454
|
+
yield* runtime.stream(batches(), streamOptions, context);
|
|
1455
|
+
} finally {
|
|
1456
|
+
streamOptions = {};
|
|
1457
|
+
}
|
|
1458
|
+
}, () => preloadTaskCode(task));
|
|
1459
|
+
}
|
|
1460
|
+
var installed = false;
|
|
1461
|
+
|
|
1462
|
+
// ../core/src/worker-utils/lib/worker-api/task-runtime.ts
|
|
1463
|
+
function normalizeTaskProgress(progress) {
|
|
1464
|
+
return { ...progress, phase: progress.phase ?? "process", unit: progress.unit ?? "items" };
|
|
1465
|
+
}
|
|
1466
|
+
async function isWorkerThread() {
|
|
1467
|
+
if (typeof self !== "undefined" && typeof document === "undefined" && typeof self.postMessage === "function")
|
|
1468
|
+
return true;
|
|
1469
|
+
if (typeof process !== "undefined" && process.versions?.node) {
|
|
1470
|
+
const { isMainThread } = await Promise.resolve().then(() => (init_worker_threads_browser(), worker_threads_browser_exports));
|
|
1471
|
+
return !isMainThread;
|
|
1472
|
+
}
|
|
1473
|
+
return false;
|
|
1474
|
+
}
|
|
1475
|
+
var initializeTaskWorker2 = initializeTaskWorker;
|
|
1476
|
+
|
|
1477
|
+
// ../core/src/worker-utils/lib/worker-utils/get-transfer-list.ts
|
|
1478
|
+
function getTransferList2(object, recursive = true, transfers) {
|
|
1479
|
+
const transfersSet = transfers || /* @__PURE__ */ new Set();
|
|
1480
|
+
if (!object) {
|
|
1481
|
+
} else if (isTransferable2(object)) {
|
|
1482
|
+
transfersSet.add(object);
|
|
1483
|
+
} else if (isTransferable2(object.buffer)) {
|
|
1484
|
+
transfersSet.add(object.buffer);
|
|
1485
|
+
} else if (ArrayBuffer.isView(object)) {
|
|
1486
|
+
} else if (recursive && typeof object === "object") {
|
|
1487
|
+
for (const key in object) {
|
|
1488
|
+
getTransferList2(object[key], recursive, transfersSet);
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
return transfers === void 0 ? Array.from(transfersSet) : [];
|
|
1492
|
+
}
|
|
1493
|
+
function isTransferable2(object) {
|
|
1494
|
+
if (!object) {
|
|
1495
|
+
return false;
|
|
1496
|
+
}
|
|
1497
|
+
if (object instanceof ArrayBuffer) {
|
|
1498
|
+
return true;
|
|
1499
|
+
}
|
|
1500
|
+
if (typeof MessagePort !== "undefined" && object instanceof MessagePort) {
|
|
1501
|
+
return true;
|
|
1502
|
+
}
|
|
1503
|
+
if (typeof ImageBitmap !== "undefined" && object instanceof ImageBitmap) {
|
|
1504
|
+
return true;
|
|
1505
|
+
}
|
|
1506
|
+
if (typeof OffscreenCanvas !== "undefined" && object instanceof OffscreenCanvas) {
|
|
1507
|
+
return true;
|
|
1508
|
+
}
|
|
1509
|
+
return false;
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
// ../core/src/worker-utils/lib/worker-api/create-worker.ts
|
|
1513
|
+
async function createWorker2(process2, processInBatches) {
|
|
1514
|
+
if (!await isWorkerThread()) return;
|
|
1515
|
+
await initializeTaskWorker2(createWorkerTask(process2, processInBatches));
|
|
1516
|
+
}
|
|
1517
|
+
function createWorkerTask(process2, processInBatches) {
|
|
1518
|
+
return {
|
|
1519
|
+
id: "loaders.gl",
|
|
1520
|
+
initialize: (state) => state,
|
|
1521
|
+
destroy: (state) => state.port?.close(),
|
|
1522
|
+
process: async ({ value }, options, context) => {
|
|
1523
|
+
if (!process2) throw new Error("Worker does not support atomic processing");
|
|
1524
|
+
return { value: await process2(value, options, createContext(context), context.state.context) };
|
|
1525
|
+
},
|
|
1526
|
+
...processInBatches ? {
|
|
1527
|
+
processInBatches: async function* (inputs, options, context) {
|
|
1528
|
+
async function* values() {
|
|
1529
|
+
for await (const input of inputs) yield input.value;
|
|
1530
|
+
}
|
|
1531
|
+
for await (const value of processInBatches(
|
|
1532
|
+
values(),
|
|
1533
|
+
options,
|
|
1534
|
+
createContext(context),
|
|
1535
|
+
context.state.context
|
|
1536
|
+
)) {
|
|
1537
|
+
yield { value };
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
} : {}
|
|
1541
|
+
};
|
|
1542
|
+
}
|
|
1543
|
+
function createContext(context) {
|
|
1544
|
+
let requestIdentifier = 0;
|
|
1545
|
+
const port = context.state.port;
|
|
1546
|
+
return {
|
|
1547
|
+
signal: context.signal,
|
|
1548
|
+
throwIfAborted: () => context.throwIfAborted(),
|
|
1549
|
+
reportProgress: (progress) => context.reportProgress(normalizeTaskProgress(progress)),
|
|
1550
|
+
process: port ? (input, options = {}, jobContext = {}) => {
|
|
1551
|
+
context.throwIfAborted();
|
|
1552
|
+
const identifier = ++requestIdentifier;
|
|
1553
|
+
return new Promise((resolve, reject) => {
|
|
1554
|
+
const onMessage = (event) => {
|
|
1555
|
+
if (event.data.identifier !== identifier) return;
|
|
1556
|
+
cleanup();
|
|
1557
|
+
if (event.data.error) {
|
|
1558
|
+
const error = new Error(event.data.error.message);
|
|
1559
|
+
error.name = event.data.error.name;
|
|
1560
|
+
reject(error);
|
|
1561
|
+
} else resolve(event.data.value);
|
|
1562
|
+
};
|
|
1563
|
+
const onAbort = () => {
|
|
1564
|
+
cleanup();
|
|
1565
|
+
reject(context.signal.reason);
|
|
1566
|
+
};
|
|
1567
|
+
const cleanup = () => {
|
|
1568
|
+
port.removeEventListener("message", onMessage);
|
|
1569
|
+
context.signal.removeEventListener("abort", onAbort);
|
|
1570
|
+
};
|
|
1571
|
+
port.addEventListener("message", onMessage);
|
|
1572
|
+
context.signal.addEventListener("abort", onAbort, { once: true });
|
|
1573
|
+
port.start();
|
|
1574
|
+
try {
|
|
1575
|
+
const request = { identifier, input, options, context: jobContext };
|
|
1576
|
+
port.postMessage(request, getTransferList2(request));
|
|
1577
|
+
} catch (error) {
|
|
1578
|
+
cleanup();
|
|
1579
|
+
reject(error);
|
|
1580
|
+
}
|
|
1581
|
+
});
|
|
1582
|
+
} : void 0
|
|
1583
|
+
};
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1051
1586
|
// ../core/src/loader-utils/lib/worker-loader-utils/create-loader-worker.ts
|
|
1052
1587
|
async function createLoaderWorker(loader, selectLoader = () => loader) {
|
|
1053
|
-
await
|
|
1588
|
+
await createWorker2(
|
|
1054
1589
|
(input, options, workerContext, loaderContext) => processLoaderWorkerData(
|
|
1055
1590
|
selectLoader(options || {}),
|
|
1056
1591
|
input,
|
|
@@ -1706,7 +2241,7 @@
|
|
|
1706
2241
|
);
|
|
1707
2242
|
|
|
1708
2243
|
// src/i3s/i3s-lepcc-loader-types.ts
|
|
1709
|
-
var VERSION2 = true ? "5.0.0-beta.
|
|
2244
|
+
var VERSION2 = true ? "5.0.0-beta.5" : "latest";
|
|
1710
2245
|
var I3SLEPCCLoader2 = {
|
|
1711
2246
|
...I3SLEPCCFormat,
|
|
1712
2247
|
dataType: null,
|