chunk-NBKUI76A.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. import {
  2. e as e2
  3. } from "./chunk-6334AFGG.js";
  4. import {
  5. a as a2,
  6. e,
  7. f as f2
  8. } from "./chunk-FWSQEIAR.js";
  9. import {
  10. r as r2
  11. } from "./chunk-2Z2TG5CU.js";
  12. import {
  13. A,
  14. C,
  15. a,
  16. f,
  17. j,
  18. p,
  19. r2 as r3,
  20. v
  21. } from "./chunk-V6P2MAQQ.js";
  22. import {
  23. s2 as s,
  24. s3 as s2
  25. } from "./chunk-E5O6P5I2.js";
  26. import {
  27. has
  28. } from "./chunk-SPWQ3AWG.js";
  29. import {
  30. h,
  31. r
  32. } from "./chunk-YXWMMD76.js";
  33. // node_modules/@arcgis/core/core/workers/utils.js
  34. var t;
  35. !function(t2) {
  36. t2[t2.HANDSHAKE = 0] = "HANDSHAKE", t2[t2.OPEN = 1] = "OPEN", t2[t2.OPENED = 2] = "OPENED", t2[t2.RESPONSE = 3] = "RESPONSE", t2[t2.INVOKE = 4] = "INVOKE", t2[t2.ABORT = 5] = "ABORT", t2[t2.CLOSE = 6] = "CLOSE", t2[t2.OPEN_PORT = 7] = "OPEN_PORT", t2[t2.ON = 8] = "ON";
  37. }(t || (t = {}));
  38. var e3 = 0;
  39. function r4() {
  40. return e3++;
  41. }
  42. function n(t2) {
  43. return t2 && "object" == typeof t2 && ("result" in t2 || "transferList" in t2);
  44. }
  45. function s3(t2) {
  46. return t2 ? "string" == typeof t2 ? JSON.stringify({ name: "message", message: t2 }) : t2.toJSON ? JSON.stringify(t2) : JSON.stringify({ name: t2.name, message: t2.message, details: t2.details || { stack: t2.stack } }) : null;
  47. }
  48. function o(e4, r5, f5, a4) {
  49. if (r5.type === t.OPEN_PORT)
  50. return void e4.postMessage(r5, [r5.port]);
  51. if (r5.type !== t.INVOKE && r5.type !== t.RESPONSE)
  52. return void e4.postMessage(r5);
  53. let u;
  54. if (n(f5) ? (u = i(f5.transferList), r5.data = f5.result) : (u = i(a4), r5.data = f5), u) {
  55. if (has("ff")) {
  56. for (const n2 of u)
  57. if ("byteLength" in n2 && n2.byteLength > 267386880) {
  58. const n3 = "Worker call with large ArrayBuffer would crash Firefox";
  59. switch (r5.type) {
  60. case t.INVOKE:
  61. throw n3;
  62. case t.RESPONSE:
  63. return void o(e4, { type: t.RESPONSE, jobId: r5.jobId, error: s3(n3) });
  64. }
  65. }
  66. }
  67. e4.postMessage(r5, u);
  68. } else
  69. e4.postMessage(r5);
  70. }
  71. function f3(t2) {
  72. if (!t2)
  73. return null;
  74. const e4 = t2.data;
  75. return e4 ? "string" == typeof e4 ? JSON.parse(e4) : e4 : null;
  76. }
  77. function i(t2) {
  78. if (!t2 || !t2.length)
  79. return null;
  80. if (has("esri-workers-arraybuffer-transfer"))
  81. return t2;
  82. const e4 = t2.filter((t3) => !a3(t3));
  83. return e4.length ? e4 : null;
  84. }
  85. function a3(t2) {
  86. return t2 instanceof ArrayBuffer || t2 && t2.constructor && "ArrayBuffer" === t2.constructor.name;
  87. }
  88. // node_modules/@arcgis/core/core/workers/RemoteClient.js
  89. var k = { statsWorker: () => import("./statsWorker-YRELGGWY.js"), geometryEngineWorker: () => import("./geometryEngineWorker-EUQVNDKF.js"), CSVSourceWorker: () => import("./CSVSourceWorker-QJPD44IC.js"), EdgeProcessingWorker: () => import("./EdgeProcessingWorker-ABXSFLHS.js"), ElevationSamplerWorker: () => import("./ElevationSamplerWorker-ETI272ZX.js"), FeatureServiceSnappingSourceWorker: () => import("./FeatureServiceSnappingSourceWorker-ID2DKINZ.js"), GeoJSONSourceWorker: () => import("./GeoJSONSourceWorker-ZQVDDZS5.js"), LercWorker: () => import("./LercWorker-ANBWKSUG.js"), MemorySourceWorker: () => import("./MemorySourceWorker-6VFACWO6.js"), PBFDecoderWorker: () => import("./PBFDecoderWorker-IGUUFCFU.js"), Pipeline: () => import("./Pipeline-DHW3SLJM.js"), PointCloudWorker: () => import("./PointCloudWorker-M5JXFAS4.js"), RasterWorker: () => import("./RasterWorker-JZAMX6NM.js"), SceneLayerSnappingSourceWorker: () => import("./SceneLayerSnappingSourceWorker-B4FQTD4Q.js"), SceneLayerWorker: () => import("./SceneLayerWorker-HPZS4JRR.js"), WFSSourceWorker: () => import("./WFSSourceWorker-KUOZZVB5.js"), WorkerTileHandler: () => import("./WorkerTileHandler-53EXBVCL.js") };
  90. var { CLOSE: b, ABORT: v2, INVOKE: y, RESPONSE: j2, OPEN_PORT: S, ON: f4 } = t;
  91. var W = 2;
  92. var M = class {
  93. constructor(e4) {
  94. this._timer = null, this._cancelledJobIds = /* @__PURE__ */ new Set(), this._invokeMessages = [], this._invoke = e4, this._timer = null, this._process = this._process.bind(this);
  95. }
  96. push(e4) {
  97. e4.type === t.ABORT ? this._cancelledJobIds.add(e4.jobId) : (this._invokeMessages.push(e4), null === this._timer && (this._timer = setTimeout(this._process, 0)));
  98. }
  99. clear() {
  100. this._invokeMessages.length = 0, this._cancelledJobIds.clear(), this._timer = null;
  101. }
  102. _process() {
  103. this._timer = null;
  104. for (const e4 of this._invokeMessages)
  105. this._cancelledJobIds.has(e4.jobId) || this._invoke(e4);
  106. this._cancelledJobIds.clear(), this._invokeMessages.length = 0;
  107. }
  108. };
  109. var w = class {
  110. constructor(e4, s4, t2) {
  111. this._port = e4, this._getNextJob = t2, this._outJobs = /* @__PURE__ */ new Map(), this._inJobs = /* @__PURE__ */ new Map(), this._invokeQueue = new M((e5) => this._onInvokeMessage(e5)), this._client = s4.client, this._onMessage = this._onMessage.bind(this), this._channel = s4.channel, this._schedule = s4.schedule, this._port.addEventListener("message", this._onMessage), this._port.start();
  112. }
  113. static connect(e4) {
  114. const s4 = new MessageChannel();
  115. let t2;
  116. t2 = "function" == typeof e4 ? new e4() : "default" in e4 && "function" == typeof e4.default ? new e4.default() : e4;
  117. const o2 = new w(s4.port1, { channel: s4, client: t2 }, () => null);
  118. return "object" == typeof t2 && "remoteClient" in t2 && (t2.remoteClient = o2), w.clients.set(o2, t2), s4.port2;
  119. }
  120. static loadWorker(e4) {
  121. const s4 = k[e4];
  122. return s4 ? s4() : Promise.resolve(null);
  123. }
  124. close() {
  125. this._post({ type: b }), this._close();
  126. }
  127. isBusy() {
  128. return this._outJobs.size > 0;
  129. }
  130. invoke(e4, t2, r5) {
  131. const c = r5 && r5.signal, l = r5 && r5.transferList;
  132. if (!this._port)
  133. return Promise.reject(new s2("worker:port-closed", `Cannot call invoke('${e4}'), port is closed`, { methodName: e4, data: t2 }));
  134. const h3 = r4();
  135. return new Promise((s4, r6) => {
  136. if (p(c))
  137. return this._processWork(), void r6(a());
  138. const p2 = v(c, () => {
  139. const e5 = this._outJobs.get(h3);
  140. e5 && (this._outJobs.delete(h3), this._processWork(), h(e5.abortHandle), this._post({ type: v2, jobId: h3 }), r6(a()));
  141. }), u = { resolve: s4, reject: r6, abortHandle: p2, debugInfo: e4 };
  142. this._outJobs.set(h3, u), this._post({ type: y, jobId: h3, methodName: e4, abortable: null != c }, t2, l);
  143. });
  144. }
  145. on(e4, s4) {
  146. const t2 = new MessageChannel();
  147. function o2(e5) {
  148. s4(e5.data);
  149. }
  150. return this._port.postMessage({ type: t.ON, eventType: e4, port: t2.port2 }, [t2.port2]), t2.port1.addEventListener("message", o2), t2.port1.start(), { remove() {
  151. t2.port1.postMessage({ type: t.CLOSE }), t2.port1.close(), t2.port1.removeEventListener("message", o2);
  152. } };
  153. }
  154. jobAdded() {
  155. this._processWork();
  156. }
  157. openPort() {
  158. const e4 = new MessageChannel();
  159. return this._post({ type: S, port: e4.port2 }), e4.port1;
  160. }
  161. _processWork() {
  162. if (this._outJobs.size >= W)
  163. return;
  164. const e4 = this._getNextJob();
  165. if (!e4)
  166. return;
  167. const { methodName: s4, data: t2, invokeOptions: o2, deferred: r5 } = e4;
  168. this.invoke(s4, t2, o2).then((e5) => r5.resolve(e5)).catch((e5) => r5.reject(e5));
  169. }
  170. _close() {
  171. this._channel && (this._channel = void 0), this._port.removeEventListener("message", this._onMessage), this._port.close(), this._outJobs.forEach((e4) => {
  172. h(e4.abortHandle), e4.reject(a(`Worker closing, aborting job calling '${e4.debugInfo}'`));
  173. }), this._inJobs.clear(), this._outJobs.clear(), this._invokeQueue.clear(), this._port = this._client = this._schedule = null;
  174. }
  175. _onMessage(e4) {
  176. r(this._schedule) ? this._schedule(() => this._processMessage(e4)) : this._processMessage(e4);
  177. }
  178. _processMessage(e4) {
  179. const s4 = f3(e4);
  180. if (s4)
  181. switch (s4.type) {
  182. case j2:
  183. this._onResponseMessage(s4);
  184. break;
  185. case y:
  186. this._invokeQueue.push(s4);
  187. break;
  188. case v2:
  189. this._onAbortMessage(s4);
  190. break;
  191. case b:
  192. this._onCloseMessage();
  193. break;
  194. case S:
  195. this._onOpenPortMessage(s4);
  196. break;
  197. case f4:
  198. this._onOnMessage(s4);
  199. }
  200. }
  201. _onAbortMessage(e4) {
  202. const s4 = this._inJobs, t2 = e4.jobId, o2 = s4.get(t2);
  203. this._invokeQueue.push(e4), o2 && (o2.controller && o2.controller.abort(), s4.delete(t2));
  204. }
  205. _onCloseMessage() {
  206. const e4 = this._client;
  207. this._close(), e4 && "destroy" in e4 && w.clients.get(this) === e4 && e4.destroy(), w.clients.delete(this), e4 && e4.remoteClient && (e4.remoteClient = null);
  208. }
  209. _onInvokeMessage(e4) {
  210. const { methodName: s4, jobId: t2, data: o2, abortable: r5 } = e4, i2 = r5 ? new AbortController() : null, n2 = this._inJobs;
  211. let a4, p2 = this._client, h3 = p2[s4];
  212. try {
  213. if (!h3 && s4 && s4.includes(".")) {
  214. const e5 = s4.split(".");
  215. for (let s5 = 0; s5 < e5.length - 1; s5++)
  216. p2 = p2[e5[s5]], h3 = p2[e5[s5 + 1]];
  217. }
  218. if ("function" != typeof h3)
  219. throw new TypeError(`${s4} is not a function`);
  220. a4 = h3.call(p2, o2, { client: this, signal: i2 ? i2.signal : null });
  221. } catch (u) {
  222. return void this._post({ type: j2, jobId: t2, error: s3(u) });
  223. }
  224. C(a4) ? (n2.set(t2, { controller: i2, promise: a4 }), a4.then((e5) => {
  225. n2.has(t2) && (n2.delete(t2), this._post({ type: j2, jobId: t2 }, e5));
  226. }, (e5) => {
  227. n2.has(t2) && (n2.delete(t2), j(e5) || this._post({ type: j2, jobId: t2, error: s3(e5 || { message: `Error encountered at method ${s4}` }) }));
  228. })) : this._post({ type: j2, jobId: t2 }, a4);
  229. }
  230. _onOpenPortMessage(e4) {
  231. new w(e4.port, { client: this._client }, () => null);
  232. }
  233. _onOnMessage(e4) {
  234. const { port: s4 } = e4, o2 = this._client.on(e4.eventType, (e5) => {
  235. s4.postMessage(e5);
  236. }), r5 = r3(e4.port, "message", (e5) => {
  237. var _a;
  238. ((_a = f3(e5)) == null ? void 0 : _a.type) === t.CLOSE && (r5.remove(), o2.remove(), s4.close());
  239. });
  240. }
  241. _onResponseMessage(e4) {
  242. const { jobId: t2, error: r5, data: i2 } = e4, n2 = this._outJobs;
  243. if (!n2.has(t2))
  244. return;
  245. const a4 = n2.get(t2);
  246. n2.delete(t2), this._processWork(), h(a4.abortHandle), r5 ? a4.reject(s2.fromJSON(JSON.parse(r5))) : a4.resolve(i2);
  247. }
  248. _post(e4, s4, t2) {
  249. return o(this._port, e4, s4, t2);
  250. }
  251. };
  252. w.kernelInfo = { revision: f2, version: a2, buildDate: e }, w.clients = /* @__PURE__ */ new Map();
  253. // node_modules/@arcgis/core/core/workers/Connection.js
  254. var h2 = class {
  255. constructor() {
  256. this._inUseClients = new Array(), this._clients = new Array(), this._clientPromises = new Array(), this._ongoingJobsQueue = new e2();
  257. }
  258. destroy() {
  259. this.close();
  260. }
  261. get closed() {
  262. return !this._clients || !this._clients.length;
  263. }
  264. open(e4, t2) {
  265. return new Promise((n2, i2) => {
  266. let r5 = true;
  267. const h3 = (e5) => {
  268. f(t2.signal), r5 && (r5 = false, e5());
  269. };
  270. this._clients.length = e4.length, this._clientPromises.length = e4.length, this._inUseClients.length = e4.length;
  271. for (let o2 = 0; o2 < e4.length; ++o2) {
  272. const r6 = e4[o2];
  273. C(r6) ? this._clientPromises[o2] = r6.then((e5) => (this._clients[o2] = new w(e5, t2, () => {
  274. var _a;
  275. return (_a = this._ongoingJobsQueue.pop()) != null ? _a : null;
  276. }), h3(n2), this._clients[o2]), () => (h3(i2), null)) : (this._clients[o2] = new w(r6, t2, () => {
  277. var _a;
  278. return (_a = this._ongoingJobsQueue.pop()) != null ? _a : null;
  279. }), this._clientPromises[o2] = Promise.resolve(this._clients[o2]), h3(n2));
  280. }
  281. });
  282. }
  283. broadcast(e4, t2, s4) {
  284. const n2 = new Array(this._clientPromises.length);
  285. for (let i2 = 0; i2 < this._clientPromises.length; ++i2) {
  286. const o2 = this._clientPromises[i2];
  287. n2[i2] = o2.then((n3) => n3 == null ? void 0 : n3.invoke(e4, t2, s4));
  288. }
  289. return n2;
  290. }
  291. close() {
  292. let e4;
  293. for (; e4 = this._ongoingJobsQueue.pop(); )
  294. e4.deferred.reject(a(`Worker closing, aborting job calling '${e4.methodName}'`));
  295. for (const t2 of this._clientPromises)
  296. t2.then((e5) => e5 == null ? void 0 : e5.close());
  297. this._clients.length = 0, this._clientPromises.length = 0;
  298. }
  299. invoke(e4, s4, n2) {
  300. let o2;
  301. Array.isArray(n2) ? (s.getLogger("esri.core.workers.Connection").warn("invoke()", "The transferList parameter is deprecated, use the options object instead"), o2 = { transferList: n2 }) : o2 = n2;
  302. const r5 = A();
  303. this._ongoingJobsQueue.push({ methodName: e4, data: s4, invokeOptions: o2, deferred: r5 });
  304. for (let t2 = 0; t2 < this._clientPromises.length; t2++) {
  305. const e5 = this._clients[t2];
  306. e5 ? e5.jobAdded() : this._clientPromises[t2].then((e6) => e6 == null ? void 0 : e6.jobAdded());
  307. }
  308. return r5.promise;
  309. }
  310. on(t2, s4) {
  311. return Promise.all(this._clientPromises).then(() => r2(this._clients.map((e4) => e4.on(t2, s4))));
  312. }
  313. openPorts() {
  314. return new Promise((e4) => {
  315. const t2 = new Array(this._clientPromises.length);
  316. let s4 = t2.length;
  317. for (let n2 = 0; n2 < this._clientPromises.length; ++n2) {
  318. this._clientPromises[n2].then((i2) => {
  319. i2 && (t2[n2] = i2.openPort()), 0 == --s4 && e4(t2);
  320. });
  321. }
  322. });
  323. }
  324. get test() {
  325. return { numClients: this._clients.length };
  326. }
  327. };
  328. export {
  329. t,
  330. r4 as r,
  331. s3 as s,
  332. o,
  333. f3 as f,
  334. w,
  335. h2 as h
  336. };
  337. //# sourceMappingURL=chunk-NBKUI76A.js.map