123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- import {
- e
- } from "./chunk-3OHML7FO.js";
- import {
- d,
- f as f2,
- s as s3
- } from "./chunk-R5IG2D6H.js";
- import {
- r as r2
- } from "./chunk-Y3WMVFTW.js";
- import {
- T,
- f,
- g,
- k,
- m,
- p,
- r2 as r3,
- v
- } from "./chunk-ULGDPLM2.js";
- import {
- s,
- s3 as s2
- } from "./chunk-EMJ4ZSM2.js";
- import {
- a,
- a2,
- r
- } from "./chunk-GZT4BVFP.js";
- // node_modules/@arcgis/core/core/workers/utils.js
- var e2;
- !function(t) {
- t[t.HANDSHAKE = 0] = "HANDSHAKE", t[t.OPEN = 1] = "OPEN", t[t.OPENED = 2] = "OPENED", t[t.RESPONSE = 3] = "RESPONSE", t[t.INVOKE = 4] = "INVOKE", t[t.ABORT = 5] = "ABORT", t[t.CLOSE = 6] = "CLOSE", t[t.OPEN_PORT = 7] = "OPEN_PORT", t[t.ON = 8] = "ON";
- }(e2 || (e2 = {}));
- var r4 = 0;
- function n() {
- return r4++;
- }
- function s4(t) {
- return t && typeof t == "object" && ("result" in t || "transferList" in t);
- }
- function a3(t) {
- return t ? typeof t == "string" ? JSON.stringify({ name: "message", message: t }) : t.toJSON ? JSON.stringify(t) : JSON.stringify({ name: t.name, message: t.message, details: t.details || { stack: t.stack } }) : null;
- }
- function i(t, r5, n2, a4) {
- if (r5.type === e2.OPEN_PORT)
- return void t.postMessage(r5, [r5.port]);
- if (r5.type !== e2.INVOKE && r5.type !== e2.RESPONSE)
- return void t.postMessage(r5);
- let i2;
- s4(n2) ? (i2 = o(n2.transferList), r5.data = n2.result) : (i2 = o(a4), r5.data = n2), i2 ? t.postMessage(r5, i2) : t.postMessage(r5);
- }
- function f3(t) {
- if (!t)
- return null;
- const e3 = t.data;
- return e3 ? typeof e3 == "string" ? JSON.parse(e3) : e3 : null;
- }
- function o(e3) {
- if (!e3 || !e3.length)
- return null;
- if (a("esri-workers-arraybuffer-transfer"))
- return e3;
- const r5 = e3.filter((t) => !u(t));
- return r5.length ? r5 : null;
- }
- function u(t) {
- return t instanceof ArrayBuffer || t && t.constructor && t.constructor.name === "ArrayBuffer";
- }
- // node_modules/@arcgis/core/core/workers/RemoteClient.js
- var k2 = { statsWorker: () => import("./statsWorker-Z3SQUZHX.js"), geometryEngineWorker: () => import("./geometryEngineWorker-6Z5M6H2V.js"), CSVSourceWorker: () => import("./CSVSourceWorker-3RM7DFJI.js"), EdgeProcessingWorker: () => import("./EdgeProcessingWorker-UXPNBBU5.js"), ElevationSamplerWorker: () => import("./ElevationSamplerWorker-Z23AUMNI.js"), FeatureServiceSnappingSourceWorker: () => import("./FeatureServiceSnappingSourceWorker-O4IDMMDZ.js"), GeoJSONSourceWorker: () => import("./GeoJSONSourceWorker-NOAEMPL4.js"), LercWorker: () => import("./LercWorker-ISXTXRV5.js"), MemorySourceWorker: () => import("./MemorySourceWorker-O22FX6GJ.js"), PBFDecoderWorker: () => import("./PBFDecoderWorker-SIUZSYGK.js"), Pipeline: () => import("./Pipeline-FIWUDD7H.js"), PointCloudWorker: () => import("./PointCloudWorker-Z76DJAJC.js"), RasterWorker: () => import("./RasterWorker-7YM3XEAT.js"), SceneLayerSnappingSourceWorker: () => import("./SceneLayerSnappingSourceWorker-ZCIBJJSJ.js"), SceneLayerWorker: () => import("./SceneLayerWorker-SAXSQD5N.js"), WFSSourceWorker: () => import("./WFSSourceWorker-2XJ7RNZY.js"), WorkerTileHandler: () => import("./WorkerTileHandler-RHSUEZH4.js") };
- var { CLOSE: b, ABORT: v2, INVOKE: y, RESPONSE: j, OPEN_PORT: S, ON: f4 } = e2;
- var W = 2;
- var M = class {
- constructor(e3) {
- this._timer = null, this._cancelledJobIds = new Set(), this._invokeMessages = [], this._invoke = e3, this._timer = null, this._process = this._process.bind(this);
- }
- push(e3) {
- e3.type === e2.ABORT ? this._cancelledJobIds.add(e3.jobId) : (this._invokeMessages.push(e3), this._timer === null && (this._timer = setTimeout(this._process, 0)));
- }
- clear() {
- this._invokeMessages.length = 0, this._cancelledJobIds.clear(), this._timer = null;
- }
- _process() {
- this._timer = null;
- for (const e3 of this._invokeMessages)
- this._cancelledJobIds.has(e3.jobId) || this._invoke(e3);
- this._cancelledJobIds.clear(), this._invokeMessages.length = 0;
- }
- };
- var w = class {
- constructor(e3, s5, t) {
- this._port = e3, this._getNextJob = t, this._outJobs = new Map(), this._inJobs = new Map(), this._invokeQueue = new M((e4) => this._onInvokeMessage(e4)), this._client = s5.client, this._onMessage = this._onMessage.bind(this), this._channel = s5.channel, this._schedule = s5.schedule, this._port.addEventListener("message", this._onMessage), this._port.start();
- }
- static connect(e3) {
- const s5 = new MessageChannel();
- let t;
- t = typeof e3 == "function" ? new e3() : "default" in e3 && typeof e3.default == "function" ? new e3.default() : e3;
- const o2 = new w(s5.port1, { channel: s5, client: t }, () => null);
- return typeof t == "object" && "remoteClient" in t && (t.remoteClient = o2), w.clients.set(o2, t), s5.port2;
- }
- static loadWorker(e3) {
- const s5 = k2[e3];
- return s5 ? s5() : Promise.resolve(null);
- }
- close() {
- this._post({ type: b }), this._close();
- }
- isBusy() {
- return this._outJobs.size > 0;
- }
- invoke(e3, t, r5) {
- const c2 = r5 && r5.signal, l = r5 && r5.transferList;
- if (!this._port)
- return Promise.reject(new s2("worker:port-closed", `Cannot call invoke('${e3}'), port is closed`, { methodName: e3, data: t }));
- const h2 = n();
- return new Promise((s5, r6) => {
- if (p(c2))
- return this._processWork(), void r6(m());
- const p2 = v(c2, () => {
- const e4 = this._outJobs.get(h2);
- e4 && (this._outJobs.delete(h2), this._processWork(), a2(e4.abortHandle), this._post({ type: v2, jobId: h2 }), r6(m()));
- }), u2 = { resolve: s5, reject: r6, abortHandle: p2, debugInfo: e3 };
- this._outJobs.set(h2, u2), this._post({ type: y, jobId: h2, methodName: e3, abortable: c2 != null }, t, l);
- });
- }
- on(e3, s5) {
- const t = new MessageChannel();
- function o2(e4) {
- s5(e4.data);
- }
- return this._port.postMessage({ type: e2.ON, eventType: e3, port: t.port2 }, [t.port2]), t.port1.addEventListener("message", o2), t.port1.start(), { remove() {
- t.port1.postMessage({ type: e2.CLOSE }), t.port1.close(), t.port1.removeEventListener("message", o2);
- } };
- }
- jobAdded() {
- this._processWork();
- }
- openPort() {
- const e3 = new MessageChannel();
- return this._post({ type: S, port: e3.port2 }), e3.port1;
- }
- _processWork() {
- if (this._outJobs.size >= W)
- return;
- const e3 = this._getNextJob();
- if (!e3)
- return;
- const { methodName: s5, data: t, invokeOptions: o2, deferred: r5 } = e3;
- this.invoke(s5, t, o2).then((e4) => r5.resolve(e4)).catch((e4) => r5.reject(e4));
- }
- _close() {
- this._channel && (this._channel = null), this._port.removeEventListener("message", this._onMessage), this._port.close(), this._outJobs.forEach((e3) => {
- a2(e3.abortHandle), e3.reject(m(`Worker closing, aborting job calling '${e3.debugInfo}'`));
- }), this._inJobs.clear(), this._outJobs.clear(), this._invokeQueue.clear(), this._port = this._client = this._schedule = null;
- }
- _onMessage(e3) {
- r(this._schedule) ? this._schedule(() => this._processMessage(e3)) : this._processMessage(e3);
- }
- _processMessage(e3) {
- const s5 = f3(e3);
- if (s5)
- switch (s5.type) {
- case j:
- this._onResponseMessage(s5);
- break;
- case y:
- this._invokeQueue.push(s5);
- break;
- case v2:
- this._onAbortMessage(s5);
- break;
- case b:
- this._onCloseMessage();
- break;
- case S:
- this._onOpenPortMessage(s5);
- break;
- case f4:
- this._onOnMessage(s5);
- }
- }
- _onAbortMessage(e3) {
- const s5 = this._inJobs, t = e3.jobId, o2 = s5.get(t);
- this._invokeQueue.push(e3), o2 && (o2.controller && o2.controller.abort(), s5.delete(t));
- }
- _onCloseMessage() {
- const e3 = this._client;
- this._close(), e3 && "destroy" in e3 && w.clients.get(this) === e3 && e3.destroy(), w.clients.delete(this), e3 && e3.remoteClient && (e3.remoteClient = null);
- }
- _onInvokeMessage(e3) {
- const { methodName: s5, jobId: t, data: o2, abortable: r5 } = e3, i2 = r5 ? new AbortController() : null, n2 = this._inJobs;
- let a4, p2 = this._client, h2 = p2[s5];
- try {
- if (!h2 && s5 && s5.includes(".")) {
- const e4 = s5.split(".");
- for (let s6 = 0; s6 < e4.length - 1; s6++)
- p2 = p2[e4[s6]], h2 = p2[e4[s6 + 1]];
- }
- if (typeof h2 != "function")
- throw new TypeError(`${s5} is not a function`);
- a4 = h2.call(p2, o2, { client: this, signal: i2 ? i2.signal : null });
- } catch (u2) {
- return void this._post({ type: j, jobId: t, error: a3(u2) });
- }
- k(a4) ? (n2.set(t, { controller: i2, promise: a4 }), a4.then((e4) => {
- n2.has(t) && (n2.delete(t), this._post({ type: j, jobId: t }, e4));
- }, (e4) => {
- n2.has(t) && (n2.delete(t), g(e4) || this._post({ type: j, jobId: t, error: a3(e4 || { message: `Error encountered at method ${s5}` }) }));
- })) : this._post({ type: j, jobId: t }, a4);
- }
- _onOpenPortMessage(e3) {
- new w(e3.port, { client: this._client }, () => null);
- }
- _onOnMessage(e3) {
- const { port: s5 } = e3, o2 = this._client.on(e3.eventType, (e4) => {
- s5.postMessage(e4);
- }), r5 = r3(e3.port, "message", (e4) => {
- f3(e4).type === e2.CLOSE && (r5.remove(), o2.remove(), s5.close());
- });
- }
- _onResponseMessage(e3) {
- const { jobId: t, error: r5, data: i2 } = e3, n2 = this._outJobs;
- if (!n2.has(t))
- return;
- const a4 = n2.get(t);
- this._processWork(), n2.delete(t), a2(a4.abortHandle), r5 ? a4.reject(s2.fromJSON(JSON.parse(r5))) : a4.resolve(i2);
- }
- _post(e3, s5, t) {
- return i(this._port, e3, s5, t);
- }
- };
- w.kernelInfo = { revision: f2, version: s3, buildDate: d }, w.clients = new Map();
- // node_modules/@arcgis/core/core/workers/Connection.js
- var h = s.getLogger("esri.core.workers.Connection");
- var c = class {
- constructor() {
- this._inUseClients = new Array(), this._clients = new Array(), this._clientPromises = new Array(), this._ongoingJobsQueue = new e();
- }
- destroy() {
- this.close();
- }
- get closed() {
- return !this._clients || !this._clients.length;
- }
- open(e3, t) {
- return new Promise((n2, i2) => {
- let r5 = true;
- const h2 = (e4) => {
- f(t.signal), r5 && (r5 = false, e4());
- };
- this._clients.length = e3.length, this._clientPromises.length = e3.length, this._inUseClients.length = e3.length;
- for (let o2 = 0; o2 < e3.length; ++o2) {
- const r6 = e3[o2];
- k(r6) ? this._clientPromises[o2] = r6.then((e4) => (this._clients[o2] = new w(e4, t, () => this._ongoingJobsQueue.pop()), h2(n2), this._clients[o2]), () => (h2(i2), null)) : (this._clients[o2] = new w(r6, t, () => this._ongoingJobsQueue.pop()), this._clientPromises[o2] = Promise.resolve(this._clients[o2]), h2(n2));
- }
- });
- }
- broadcast(e3, t, s5) {
- const n2 = new Array(this._clientPromises.length);
- for (let i2 = 0; i2 < this._clientPromises.length; ++i2) {
- const o2 = this._clientPromises[i2];
- n2[i2] = o2.then((n3) => n3.invoke(e3, t, s5));
- }
- return n2;
- }
- close() {
- let e3;
- for (; e3 = this._ongoingJobsQueue.pop(); )
- e3.deferred.reject(m(`Worker closing, aborting job calling '${e3.methodName}'`));
- for (const t of this._clientPromises)
- t.then((e4) => e4.close());
- this._clients.length = 0, this._clientPromises.length = 0;
- }
- invoke(e3, t, s5) {
- let n2 = null;
- Array.isArray(s5) ? (h.warn("invoke()", "The transferList parameter is deprecated, use the options object instead"), n2 = { transferList: s5 }) : n2 = s5;
- const o2 = T();
- this._ongoingJobsQueue.push({ methodName: e3, data: t, invokeOptions: n2, deferred: o2 });
- for (let i2 = 0; i2 < this._clientPromises.length; i2++) {
- const e4 = this._clients[i2];
- e4 ? e4.jobAdded() : this._clientPromises[i2].then((e5) => e5.jobAdded());
- }
- return o2.promise;
- }
- on(t, s5) {
- return Promise.all(this._clientPromises).then(() => r2(this._clients.map((e3) => e3.on(t, s5))));
- }
- openPorts() {
- return new Promise((e3) => {
- const t = new Array(this._clientPromises.length);
- let s5 = t.length;
- for (let n2 = 0; n2 < this._clientPromises.length; ++n2) {
- this._clientPromises[n2].then((i2) => {
- t[n2] = i2.openPort(), --s5 == 0 && e3(t);
- });
- }
- });
- }
- get test() {
- return { numClients: this._clients.length };
- }
- };
- export {
- e2 as e,
- n,
- a3 as a,
- i,
- f3 as f,
- w,
- c
- };
- //# sourceMappingURL=chunk-6SASJ6IM.js.map
|