@loaders.gl/core 5.0.0-beta.1 → 5.0.0-beta.2
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 +3 -1
- package/dist/cluster-source.cjs +7228 -0
- package/dist/cluster-source.cjs.map +6 -0
- package/dist/cluster-source.d.ts +2 -0
- package/dist/cluster-source.d.ts.map +1 -0
- package/dist/cluster-source.js +2 -0
- package/dist/cluster-source.js.map +1 -0
- package/dist/dist.dev.js +894 -273
- package/dist/dist.min.js +3 -3
- package/dist/federated-table-scan-source.cjs +2677 -0
- package/dist/federated-table-scan-source.cjs.map +6 -0
- package/dist/federated-table-scan-source.d.ts +2 -0
- package/dist/federated-table-scan-source.d.ts.map +1 -0
- package/dist/federated-table-scan-source.js +2 -0
- package/dist/federated-table-scan-source.js.map +1 -0
- package/dist/index.cjs +12 -1045
- package/dist/index.cjs.map +3 -3
- package/dist/lib/init.js +1 -1
- package/dist/loader-utils/index.cjs +43 -1331
- package/dist/loader-utils/index.cjs.map +3 -3
- 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 +169 -79
- package/dist/null-worker.js +166 -55
- package/dist/polyfills/images/encode-image-node.d.ts +18 -15
- package/dist/polyfills/images/encode-image-node.d.ts.map +1 -1
- package/dist/polyfills/images/encode-image-node.js +19 -33
- package/dist/polyfills/images/encode-image-node.js.map +1 -1
- package/dist/polyfills/images/image-codecs-node.d.ts +2 -6
- package/dist/polyfills/images/image-codecs-node.d.ts.map +1 -1
- package/dist/polyfills/images/image-codecs-node.js +2 -24
- package/dist/polyfills/images/image-codecs-node.js.map +1 -1
- package/dist/polyfills/images/load-sharp.d.ts +3 -0
- package/dist/polyfills/images/load-sharp.d.ts.map +1 -0
- package/dist/polyfills/images/load-sharp.js +11 -0
- package/dist/polyfills/images/load-sharp.js.map +1 -0
- package/dist/polyfills/images/node-image-bitmap.d.ts +1 -1
- package/dist/polyfills/images/node-image-bitmap.js +1 -1
- package/dist/polyfills/images/node-image-formats.d.ts +1 -1
- package/dist/polyfills/images/node-image-formats.d.ts.map +1 -1
- package/dist/polyfills/images/node-image-formats.js +10 -4
- package/dist/polyfills/images/node-image-formats.js.map +1 -1
- package/dist/polyfills/images/parse-image-node.d.ts +10 -2
- package/dist/polyfills/images/parse-image-node.d.ts.map +1 -1
- package/dist/polyfills/images/parse-image-node.js +20 -32
- package/dist/polyfills/images/parse-image-node.js.map +1 -1
- package/dist/polyfills/index.cjs +73 -149
- package/dist/vector-table-scan-source.cjs +1703 -0
- package/dist/vector-table-scan-source.cjs.map +6 -0
- package/dist/vector-table-scan-source.d.ts +2 -0
- package/dist/vector-table-scan-source.d.ts.map +1 -0
- package/dist/vector-table-scan-source.js +2 -0
- package/dist/vector-table-scan-source.js.map +1 -0
- package/dist/worker-utils/index.cjs +72 -1225
- package/dist/worker-utils/index.cjs.map +3 -3
- package/dist/worker-utils/lib/async-queue/async-queue.d.ts +1 -31
- package/dist/worker-utils/lib/async-queue/async-queue.d.ts.map +1 -1
- package/dist/worker-utils/lib/async-queue/async-queue.js +1 -87
- package/dist/worker-utils/lib/async-queue/async-queue.js.map +1 -1
- package/dist/worker-utils/lib/env-utils/version.js +1 -1
- package/dist/worker-utils/lib/worker-api/create-worker.d.ts +1 -8
- package/dist/worker-utils/lib/worker-api/create-worker.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-api/create-worker.js +1 -157
- package/dist/worker-utils/lib/worker-api/create-worker.js.map +1 -1
- package/dist/worker-utils/lib/worker-api/process-on-worker.d.ts +2 -49
- 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 -345
- package/dist/worker-utils/lib/worker-api/process-on-worker.js.map +1 -1
- package/dist/worker-utils/lib/worker-farm/worker-body.d.ts +1 -19
- package/dist/worker-utils/lib/worker-farm/worker-body.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-farm/worker-body.js +1 -127
- package/dist/worker-utils/lib/worker-farm/worker-body.js.map +1 -1
- package/dist/worker-utils/lib/worker-farm/worker-farm.d.ts +1 -57
- package/dist/worker-utils/lib/worker-farm/worker-farm.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-farm/worker-farm.js +1 -112
- package/dist/worker-utils/lib/worker-farm/worker-farm.js.map +1 -1
- package/dist/worker-utils/lib/worker-farm/worker-job.d.ts +1 -33
- package/dist/worker-utils/lib/worker-farm/worker-job.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-farm/worker-job.js +1 -70
- package/dist/worker-utils/lib/worker-farm/worker-job.js.map +1 -1
- package/dist/worker-utils/lib/worker-farm/worker-pool.d.ts +1 -93
- package/dist/worker-utils/lib/worker-farm/worker-pool.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-farm/worker-pool.js +1 -242
- package/dist/worker-utils/lib/worker-farm/worker-pool.js.map +1 -1
- package/dist/worker-utils/lib/worker-farm/worker-thread.d.ts +1 -66
- package/dist/worker-utils/lib/worker-farm/worker-thread.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-farm/worker-thread.js +1 -171
- package/dist/worker-utils/lib/worker-farm/worker-thread.js.map +1 -1
- package/dist/worker-utils/null-worker-node.js +234 -144
- package/dist/worker-utils/null-worker-node.js.map +4 -4
- package/dist/worker-utils/null-worker.js +232 -121
- package/dist/worker-utils/null-worker.js.map +4 -4
- package/dist/worker-utils/types.d.ts +1 -99
- package/dist/worker-utils/types.d.ts.map +1 -1
- package/package.json +27 -29
- package/src/cluster-source.ts +1 -0
- package/src/federated-table-scan-source.ts +1 -0
- package/src/polyfills/README.md +2 -2
- package/src/polyfills/images/encode-image-node.ts +44 -37
- package/src/polyfills/images/image-codecs-node.ts +2 -37
- package/src/polyfills/images/load-sharp.ts +13 -0
- package/src/polyfills/images/node-image-bitmap.ts +1 -1
- package/src/polyfills/images/node-image-formats.ts +10 -4
- package/src/polyfills/images/parse-image-node.ts +31 -40
- package/src/vector-table-scan-source.ts +1 -0
- package/src/worker-utils/lib/async-queue/async-queue.ts +1 -96
- package/src/worker-utils/lib/worker-api/create-worker.ts +1 -201
- package/src/worker-utils/lib/worker-api/process-on-worker.ts +8 -464
- package/src/worker-utils/lib/worker-farm/worker-body.ts +1 -141
- package/src/worker-utils/lib/worker-farm/worker-farm.ts +1 -140
- package/src/worker-utils/lib/worker-farm/worker-job.ts +1 -81
- package/src/worker-utils/lib/worker-farm/worker-pool.ts +1 -312
- package/src/worker-utils/lib/worker-farm/worker-thread.ts +1 -202
- package/src/worker-utils/types.ts +14 -144
- package/src/polyfills/images/encode-image.node.ts.disabled +0 -41
- package/src/polyfills/images/parse-image.node.ts.disabled +0 -55
package/dist/null-worker.js
CHANGED
|
@@ -1,22 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
|
-
//
|
|
3
|
+
// ../../node_modules/@math.gl/core/dist/worker-utils/lib/node/worker_threads-browser.js
|
|
4
4
|
var parentPort = null;
|
|
5
5
|
|
|
6
|
-
//
|
|
6
|
+
// ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-utils/get-transfer-list.js
|
|
7
7
|
function getTransferList(object, recursive = true, transfers) {
|
|
8
8
|
const transfersSet = transfers || /* @__PURE__ */ new Set();
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10
|
+
function visit(value) {
|
|
11
|
+
if (!value || typeof value !== "object" || seen.has(value))
|
|
12
|
+
return;
|
|
13
|
+
seen.add(value);
|
|
14
|
+
if (isTransferable(value))
|
|
15
|
+
transfersSet.add(value);
|
|
16
|
+
else if (ArrayBuffer.isView(value)) {
|
|
17
|
+
if (isTransferable(value.buffer))
|
|
18
|
+
transfersSet.add(value.buffer);
|
|
19
|
+
} else if (recursive && value instanceof Map) {
|
|
20
|
+
for (const [key, item] of value) {
|
|
21
|
+
visit(key);
|
|
22
|
+
visit(item);
|
|
23
|
+
}
|
|
24
|
+
} else if (recursive && value instanceof Set) {
|
|
25
|
+
for (const item of value)
|
|
26
|
+
visit(item);
|
|
27
|
+
} else if (recursive) {
|
|
28
|
+
for (const key of Object.keys(value))
|
|
29
|
+
visit(value[key]);
|
|
18
30
|
}
|
|
19
31
|
}
|
|
32
|
+
visit(object);
|
|
20
33
|
return transfers === void 0 ? Array.from(transfersSet) : [];
|
|
21
34
|
}
|
|
22
35
|
function isTransferable(object) {
|
|
@@ -38,7 +51,7 @@
|
|
|
38
51
|
return false;
|
|
39
52
|
}
|
|
40
53
|
|
|
41
|
-
//
|
|
54
|
+
// ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-farm/worker-body.js
|
|
42
55
|
async function getParentPort() {
|
|
43
56
|
return parentPort;
|
|
44
57
|
}
|
|
@@ -46,7 +59,8 @@
|
|
|
46
59
|
var WorkerBody = class {
|
|
47
60
|
/** Check that we are actually in a worker thread */
|
|
48
61
|
static async inWorkerThread() {
|
|
49
|
-
|
|
62
|
+
const workerGlobalScope = globalThis.WorkerGlobalScope;
|
|
63
|
+
return typeof workerGlobalScope === "function" && globalThis instanceof workerGlobalScope || Boolean(await getParentPort());
|
|
50
64
|
}
|
|
51
65
|
/*
|
|
52
66
|
* (type: WorkerMessageType, payload: WorkerMessagePayload) => any
|
|
@@ -124,11 +138,8 @@
|
|
|
124
138
|
return messageData && typeof messageData.source === "string" && messageData.source.startsWith("loaders.gl") ? messageData : null;
|
|
125
139
|
}
|
|
126
140
|
|
|
127
|
-
//
|
|
141
|
+
// ../../node_modules/@math.gl/core/dist/worker-utils/lib/async-queue/async-queue.js
|
|
128
142
|
var AsyncQueue = class {
|
|
129
|
-
_values;
|
|
130
|
-
_settlers;
|
|
131
|
-
_closed;
|
|
132
143
|
constructor() {
|
|
133
144
|
this._values = [];
|
|
134
145
|
this._settlers = [];
|
|
@@ -194,8 +205,48 @@
|
|
|
194
205
|
}
|
|
195
206
|
};
|
|
196
207
|
|
|
197
|
-
//
|
|
208
|
+
// ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/shared-state.js
|
|
209
|
+
var SharedWorkerState = class {
|
|
210
|
+
constructor(buffer) {
|
|
211
|
+
if (typeof SharedArrayBuffer === "undefined" || !(buffer instanceof SharedArrayBuffer) || buffer.byteLength !== 16)
|
|
212
|
+
throw new Error("Expected a 16-byte shared worker control buffer");
|
|
213
|
+
this.buffer = buffer;
|
|
214
|
+
this.values = new Int32Array(buffer);
|
|
215
|
+
}
|
|
216
|
+
get snapshot() {
|
|
217
|
+
return {
|
|
218
|
+
cancelled: Atomics.load(this.values, 0) !== 0,
|
|
219
|
+
completed: Atomics.load(this.values, 1),
|
|
220
|
+
total: Atomics.load(this.values, 2),
|
|
221
|
+
revision: Atomics.load(this.values, 3)
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
cancel() {
|
|
225
|
+
Atomics.store(this.values, 0, 1);
|
|
226
|
+
Atomics.add(this.values, 3, 1);
|
|
227
|
+
Atomics.notify(this.values, 0);
|
|
228
|
+
}
|
|
229
|
+
throwIfCancelled() {
|
|
230
|
+
if (Atomics.load(this.values, 0) !== 0) {
|
|
231
|
+
const error = new Error("Shared worker task was cancelled");
|
|
232
|
+
error.name = "AbortError";
|
|
233
|
+
throw error;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/** Integer counters for application-defined work; messages still carry phase names and units. */
|
|
237
|
+
setProgress(completed, total = -1) {
|
|
238
|
+
if (!Number.isInteger(completed) || completed < 0 || completed > 2147483647 || !Number.isInteger(total) || total < -1 || total > 2147483647) {
|
|
239
|
+
throw new RangeError("Shared progress requires nonnegative int32 counts (or total -1)");
|
|
240
|
+
}
|
|
241
|
+
Atomics.store(this.values, 1, completed);
|
|
242
|
+
Atomics.store(this.values, 2, total);
|
|
243
|
+
Atomics.add(this.values, 3, 1);
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
// ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/create-worker.js
|
|
198
248
|
var requestId = 0;
|
|
249
|
+
var activeController = null;
|
|
199
250
|
var activeInputBatches = null;
|
|
200
251
|
var activeOutputAcknowledgements = null;
|
|
201
252
|
async function createWorker(process, processInBatches) {
|
|
@@ -206,27 +257,56 @@
|
|
|
206
257
|
process: processOnMainThread
|
|
207
258
|
};
|
|
208
259
|
WorkerBody.onmessage = async (type, payload) => {
|
|
260
|
+
if (type === "cancel") {
|
|
261
|
+
activeController?.abort();
|
|
262
|
+
activeInputBatches?.close();
|
|
263
|
+
activeOutputAcknowledgements?.close();
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const controller = type === "process" || type === "process-in-batches" ? new AbortController() : void 0;
|
|
267
|
+
if (controller)
|
|
268
|
+
activeController = controller;
|
|
269
|
+
const startedAt = performance.now();
|
|
209
270
|
const reporter = type === "process" || type === "process-in-batches" ? createProgressReporter() : void 0;
|
|
210
|
-
|
|
271
|
+
let sharedState;
|
|
272
|
+
const throwIfAborted = () => {
|
|
273
|
+
controller?.signal.throwIfAborted();
|
|
274
|
+
sharedState?.throwIfCancelled();
|
|
275
|
+
};
|
|
276
|
+
const jobContext = {
|
|
277
|
+
...context,
|
|
278
|
+
signal: controller?.signal,
|
|
279
|
+
sharedState,
|
|
280
|
+
throwIfAborted,
|
|
281
|
+
reportProgress: (progress) => {
|
|
282
|
+
if (!controller?.signal.aborted && !sharedState?.snapshot.cancelled)
|
|
283
|
+
reporter?.report(progress);
|
|
284
|
+
}
|
|
285
|
+
};
|
|
211
286
|
try {
|
|
287
|
+
if (controller && payload.options?.["sharedState"]) {
|
|
288
|
+
sharedState = new SharedWorkerState(payload.options["sharedState"]);
|
|
289
|
+
jobContext.sharedState = sharedState;
|
|
290
|
+
}
|
|
212
291
|
switch (type) {
|
|
213
292
|
case "preload":
|
|
214
293
|
WorkerBody.postMessage("done", {});
|
|
215
294
|
break;
|
|
216
295
|
case "process":
|
|
296
|
+
throwIfAborted();
|
|
217
297
|
if (!process) {
|
|
218
298
|
throw new Error("Worker does not support atomic processing");
|
|
219
299
|
}
|
|
220
|
-
const result = await process(
|
|
221
|
-
|
|
222
|
-
payload.options || {},
|
|
223
|
-
jobContext,
|
|
224
|
-
payload.context || {}
|
|
225
|
-
);
|
|
300
|
+
const result = await process(payload.input, payload.options || {}, jobContext, payload.context || {});
|
|
301
|
+
throwIfAborted();
|
|
226
302
|
reporter?.finish();
|
|
227
|
-
WorkerBody.postMessage("done", {
|
|
303
|
+
await WorkerBody.postMessage("done", {
|
|
304
|
+
result,
|
|
305
|
+
executionMs: performance.now() - startedAt
|
|
306
|
+
});
|
|
228
307
|
break;
|
|
229
308
|
case "process-in-batches":
|
|
309
|
+
throwIfAborted();
|
|
230
310
|
if (!processInBatches) {
|
|
231
311
|
throw new Error("Worker does not support batched processing");
|
|
232
312
|
}
|
|
@@ -235,18 +315,15 @@
|
|
|
235
315
|
activeInputBatches = inputBatches;
|
|
236
316
|
activeOutputAcknowledgements = outputAcknowledgements;
|
|
237
317
|
try {
|
|
238
|
-
const resultIterator = processInBatches(
|
|
239
|
-
createDemandDrivenIterator(inputBatches),
|
|
240
|
-
payload.options || {},
|
|
241
|
-
jobContext,
|
|
242
|
-
payload.context || {}
|
|
243
|
-
);
|
|
318
|
+
const resultIterator = processInBatches(createDemandDrivenIterator(inputBatches), payload.options || {}, jobContext, payload.context || {});
|
|
244
319
|
for await (const batch of resultIterator) {
|
|
320
|
+
throwIfAborted();
|
|
245
321
|
await WorkerBody.postMessage("output-batch", { result: batch });
|
|
246
322
|
await outputAcknowledgements.next();
|
|
247
323
|
}
|
|
324
|
+
throwIfAborted();
|
|
248
325
|
reporter?.finish();
|
|
249
|
-
await WorkerBody.postMessage("done", {});
|
|
326
|
+
await WorkerBody.postMessage("done", { executionMs: performance.now() - startedAt });
|
|
250
327
|
} finally {
|
|
251
328
|
activeInputBatches = null;
|
|
252
329
|
activeOutputAcknowledgements = null;
|
|
@@ -273,11 +350,18 @@
|
|
|
273
350
|
default:
|
|
274
351
|
}
|
|
275
352
|
} catch (error) {
|
|
276
|
-
reporter?.finish();
|
|
353
|
+
reporter?.finish(controller?.signal.aborted || sharedState?.snapshot.cancelled);
|
|
277
354
|
const message = error instanceof Error ? error.message : "";
|
|
278
|
-
WorkerBody.postMessage("error", {
|
|
355
|
+
await WorkerBody.postMessage("error", {
|
|
356
|
+
error: message,
|
|
357
|
+
errorName: error instanceof Error ? error.name : "Error"
|
|
358
|
+
});
|
|
359
|
+
} finally {
|
|
360
|
+
if (controller && activeController === controller)
|
|
361
|
+
activeController = null;
|
|
279
362
|
}
|
|
280
363
|
};
|
|
364
|
+
await WorkerBody.postMessage("ready", {});
|
|
281
365
|
}
|
|
282
366
|
async function* createDemandDrivenIterator(inputBatches) {
|
|
283
367
|
while (true) {
|
|
@@ -290,27 +374,45 @@
|
|
|
290
374
|
}
|
|
291
375
|
}
|
|
292
376
|
function processOnMainThread(arrayBuffer, options = {}, jobContext = {}) {
|
|
377
|
+
const signal = activeController?.signal;
|
|
378
|
+
signal?.throwIfAborted();
|
|
293
379
|
return new Promise((resolve, reject) => {
|
|
294
380
|
const id = requestId++;
|
|
295
|
-
const
|
|
296
|
-
|
|
381
|
+
const cleanup = () => {
|
|
382
|
+
signal?.removeEventListener("abort", abort);
|
|
383
|
+
void WorkerBody.removeEventListener(onMessage);
|
|
384
|
+
};
|
|
385
|
+
const abort = () => {
|
|
386
|
+
cleanup();
|
|
387
|
+
reject(signal?.reason);
|
|
388
|
+
};
|
|
389
|
+
const onMessage = (type, payload) => {
|
|
390
|
+
if (payload.id !== id)
|
|
297
391
|
return;
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
case "error":
|
|
305
|
-
WorkerBody.removeEventListener(onMessage);
|
|
306
|
-
reject(payload2.error);
|
|
307
|
-
break;
|
|
308
|
-
default:
|
|
392
|
+
if (type === "done") {
|
|
393
|
+
cleanup();
|
|
394
|
+
resolve(payload.result);
|
|
395
|
+
} else if (type === "error") {
|
|
396
|
+
cleanup();
|
|
397
|
+
reject(payload.error);
|
|
309
398
|
}
|
|
310
399
|
};
|
|
311
|
-
WorkerBody.addEventListener(onMessage)
|
|
312
|
-
|
|
313
|
-
|
|
400
|
+
void WorkerBody.addEventListener(onMessage).then(async () => {
|
|
401
|
+
if (signal?.aborted) {
|
|
402
|
+
abort();
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
406
|
+
await WorkerBody.postMessage("process", {
|
|
407
|
+
id,
|
|
408
|
+
input: arrayBuffer,
|
|
409
|
+
options,
|
|
410
|
+
context: jobContext
|
|
411
|
+
});
|
|
412
|
+
}).catch((error) => {
|
|
413
|
+
cleanup();
|
|
414
|
+
reject(error);
|
|
415
|
+
});
|
|
314
416
|
});
|
|
315
417
|
}
|
|
316
418
|
function createProgressReporter() {
|
|
@@ -327,8 +429,10 @@
|
|
|
327
429
|
return {
|
|
328
430
|
/** Records progress while retaining phase transitions. */
|
|
329
431
|
report(progress) {
|
|
330
|
-
if (finished)
|
|
331
|
-
|
|
432
|
+
if (finished)
|
|
433
|
+
return;
|
|
434
|
+
if (pending && pending.phase !== progress.phase)
|
|
435
|
+
flush();
|
|
332
436
|
pending = { ...progress };
|
|
333
437
|
if (!scheduled) {
|
|
334
438
|
scheduled = true;
|
|
@@ -336,13 +440,20 @@
|
|
|
336
440
|
}
|
|
337
441
|
},
|
|
338
442
|
/** Flushes final progress and suppresses reports from stale callbacks. */
|
|
339
|
-
finish() {
|
|
443
|
+
finish(discard = false) {
|
|
444
|
+
if (discard)
|
|
445
|
+
pending = void 0;
|
|
340
446
|
flush();
|
|
341
447
|
finished = true;
|
|
342
448
|
}
|
|
343
449
|
};
|
|
344
450
|
}
|
|
345
451
|
|
|
452
|
+
// ../../node_modules/@math.gl/core/dist/worker-utils/index.js
|
|
453
|
+
var import_meta = {};
|
|
454
|
+
var path = typeof __filename === "string" ? __filename.replace(/\\/g, "/") : "";
|
|
455
|
+
var moduleUrl = path ? `file://${path.startsWith("/") ? "" : "/"}${encodeURI(path).replace(/#/g, "%23").replace(/\?/g, "%3F")}` : import_meta.url;
|
|
456
|
+
|
|
346
457
|
// src/loader-utils/lib/worker-loader-utils/create-loader-worker.ts
|
|
347
458
|
async function createLoaderWorker(loader, selectLoader = () => loader) {
|
|
348
459
|
await createWorker(
|
|
@@ -482,7 +593,7 @@
|
|
|
482
593
|
}
|
|
483
594
|
|
|
484
595
|
// src/null-loader.ts
|
|
485
|
-
var VERSION = true ? "5.0.0-beta.
|
|
596
|
+
var VERSION = true ? "5.0.0-beta.2" : "latest";
|
|
486
597
|
var NullLoader = {
|
|
487
598
|
dataType: null,
|
|
488
599
|
batchType: null,
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* @param options.type='png' - png, jpg or image/png, image/jpg are valid
|
|
8
|
-
* @param options.dataURI - Whether to include a data URI header
|
|
9
|
-
* @return {*} bytes
|
|
10
|
-
*/
|
|
11
|
-
export declare function encodeImageToStreamNode(image: {
|
|
12
|
-
data: any;
|
|
1
|
+
import { PassThrough } from 'node:stream';
|
|
2
|
+
/** Raw RGBA image accepted by the Node encoder. */
|
|
3
|
+
type NodeImageData = {
|
|
4
|
+
/** Interleaved RGBA pixels. */
|
|
5
|
+
data: Uint8Array;
|
|
6
|
+
/** Width in pixels. */
|
|
13
7
|
width: number;
|
|
8
|
+
/** Height in pixels. */
|
|
14
9
|
height: number;
|
|
15
|
-
}
|
|
10
|
+
};
|
|
11
|
+
/** Options for the Node image encoder. */
|
|
12
|
+
type NodeImageEncoderOptions = {
|
|
13
|
+
/** Output format name or MIME type; defaults to JPEG. */
|
|
16
14
|
type?: string;
|
|
15
|
+
/** Legacy option retained for callers. */
|
|
17
16
|
dataURI?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
17
|
+
};
|
|
18
|
+
/** Encodes raw RGBA pixels with the optional Sharp backend. */
|
|
19
|
+
export declare function encodeImageNode(image: NodeImageData, options?: NodeImageEncoderOptions): Promise<ArrayBuffer>;
|
|
20
|
+
/** Streams an encoded image and forwards codec loading and encoding failures. */
|
|
21
|
+
export declare function encodeImageToStreamNode(image: NodeImageData, options?: NodeImageEncoderOptions): PassThrough;
|
|
22
|
+
export {};
|
|
20
23
|
//# sourceMappingURL=encode-image-node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encode-image-node.d.ts","sourceRoot":"","sources":["../../../src/polyfills/images/encode-image-node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"encode-image-node.d.ts","sourceRoot":"","sources":["../../../src/polyfills/images/encode-image-node.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AAIxC,mDAAmD;AACnD,KAAK,aAAa,GAAG;IACnB,+BAA+B;IAC/B,IAAI,EAAE,UAAU,CAAC;IACjB,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,wBAAwB;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,0CAA0C;AAC1C,KAAK,uBAAuB,GAAG;IAC7B,yDAAyD;IACzD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,+DAA+D;AAC/D,wBAAsB,eAAe,CACnC,KAAK,EAAE,aAAa,EACpB,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,WAAW,CAAC,CAUtB;AAED,iFAAiF;AACjF,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,aAAa,EACpB,OAAO,GAAE,uBAA4B,GACpC,WAAW,CAOb"}
|
|
@@ -1,37 +1,23 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
1
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*/
|
|
18
|
-
export function encodeImageToStreamNode(image, options) {
|
|
19
|
-
// Support MIME type strings
|
|
20
|
-
const type = options.type ? options.type.replace('image/', '') : 'jpeg';
|
|
21
|
-
const pixels = ndarray(image.data, [image.width, image.height, 4], [4, image.width * 4, 1], 0);
|
|
22
|
-
// Note: savePixels returns a stream
|
|
23
|
-
return savePixels(pixels, type, options);
|
|
2
|
+
import { PassThrough } from 'node:stream';
|
|
3
|
+
import { loadSharp } from "./load-sharp.js";
|
|
4
|
+
import { toArrayBuffer } from "../utils/buffer-utils.js";
|
|
5
|
+
/** Encodes raw RGBA pixels with the optional Sharp backend. */
|
|
6
|
+
export async function encodeImageNode(image, options = {}) {
|
|
7
|
+
const sharp = await loadSharp();
|
|
8
|
+
const requestedFormat = (options.type || 'jpeg').toLowerCase().replace(/^image\//, '');
|
|
9
|
+
const format = requestedFormat === 'jpg' ? 'jpeg' : requestedFormat;
|
|
10
|
+
const encodedImage = await sharp(Buffer.from(image.data), {
|
|
11
|
+
raw: { width: image.width, height: image.height, channels: 4 }
|
|
12
|
+
})
|
|
13
|
+
.toFormat(format)
|
|
14
|
+
.toBuffer();
|
|
15
|
+
return toArrayBuffer(encodedImage);
|
|
24
16
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// TODO - convert to arraybuffer?
|
|
31
|
-
imageStream.on('end', () => {
|
|
32
|
-
const buffer = Buffer.concat(buffers);
|
|
33
|
-
resolve(bufferToArrayBuffer(buffer));
|
|
34
|
-
});
|
|
35
|
-
});
|
|
17
|
+
/** Streams an encoded image and forwards codec loading and encoding failures. */
|
|
18
|
+
export function encodeImageToStreamNode(image, options = {}) {
|
|
19
|
+
const stream = new PassThrough();
|
|
20
|
+
void encodeImageNode(image, options).then(arrayBuffer => stream.end(Buffer.from(arrayBuffer)), error => stream.destroy(error));
|
|
21
|
+
return stream;
|
|
36
22
|
}
|
|
37
23
|
//# sourceMappingURL=encode-image-node.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encode-image-node.js","sourceRoot":"","sources":["../../../src/polyfills/images/encode-image-node.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"encode-image-node.js","sourceRoot":"","sources":["../../../src/polyfills/images/encode-image-node.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,EAAC,SAAS,EAAC,wBAAqB;AACvC,OAAO,EAAC,aAAa,EAAC,iCAA8B;AAoBpD,+DAA+D;AAC/D,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,KAAoB,EACpB,UAAmC,EAAE;IAErC,MAAM,KAAK,GAAG,MAAM,SAAS,EAAE,CAAC;IAChC,MAAM,eAAe,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IACvF,MAAM,MAAM,GAAG,eAAe,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC;IACpE,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;QACxD,GAAG,EAAE,EAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAC;KAC7D,CAAC;SACC,QAAQ,CAAC,MAA0C,CAAC;SACpD,QAAQ,EAAE,CAAC;IACd,OAAO,aAAa,CAAC,YAAY,CAAC,CAAC;AACrC,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,uBAAuB,CACrC,KAAoB,EACpB,UAAmC,EAAE;IAErC,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;IACjC,KAAK,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CACvC,WAAW,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,EACnD,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAC/B,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export { parseImageNode } from "./parse-image-node.js";
|
|
2
|
+
export { encodeImageNode } from "./encode-image-node.js";
|
|
3
3
|
export { NODE_FORMAT_SUPPORT } from "./node-image-formats.js";
|
|
4
|
-
/** Loads the optional image decoder only when pixel decoding is requested. */
|
|
5
|
-
export declare function parseImageNode(...parameters: Parameters<typeof parseImageImplementation>): Promise<Awaited<ReturnType<typeof parseImageImplementation>>>;
|
|
6
|
-
/** Loads the optional image encoder only when image encoding is requested. */
|
|
7
|
-
export declare function encodeImageNode(...parameters: Parameters<typeof encodeImageImplementation>): Promise<Awaited<ReturnType<typeof encodeImageImplementation>>>;
|
|
8
4
|
//# sourceMappingURL=image-codecs-node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-codecs-node.d.ts","sourceRoot":"","sources":["../../../src/polyfills/images/image-codecs-node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"image-codecs-node.d.ts","sourceRoot":"","sources":["../../../src/polyfills/images/image-codecs-node.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,cAAc,EAAC,8BAA2B;AAClD,OAAO,EAAC,eAAe,EAAC,+BAA4B;AACpD,OAAO,EAAC,mBAAmB,EAAC,gCAA6B"}
|
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
1
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
|
|
2
|
+
export { parseImageNode } from "./parse-image-node.js";
|
|
3
|
+
export { encodeImageNode } from "./encode-image-node.js";
|
|
4
4
|
export { NODE_FORMAT_SUPPORT } from "./node-image-formats.js";
|
|
5
|
-
/** Loads the optional image decoder only when pixel decoding is requested. */
|
|
6
|
-
export async function parseImageNode(...parameters) {
|
|
7
|
-
let decoder;
|
|
8
|
-
try {
|
|
9
|
-
decoder = await import("./parse-image-node.js");
|
|
10
|
-
}
|
|
11
|
-
catch (error) {
|
|
12
|
-
throw new Error('Node image decoding requires get-pixels. Install get-pixels to decode images.', { cause: error });
|
|
13
|
-
}
|
|
14
|
-
return decoder.parseImageNode(...parameters);
|
|
15
|
-
}
|
|
16
|
-
/** Loads the optional image encoder only when image encoding is requested. */
|
|
17
|
-
export async function encodeImageNode(...parameters) {
|
|
18
|
-
let encoder;
|
|
19
|
-
try {
|
|
20
|
-
encoder = await import("./encode-image-node.js");
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
throw new Error('Node image encoding requires save-pixels and ndarray. Install save-pixels and ndarray to encode images.', { cause: error });
|
|
24
|
-
}
|
|
25
|
-
return encoder.encodeImageNode(...parameters);
|
|
26
|
-
}
|
|
27
5
|
//# sourceMappingURL=image-codecs-node.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-codecs-node.js","sourceRoot":"","sources":["../../../src/polyfills/images/image-codecs-node.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"image-codecs-node.js","sourceRoot":"","sources":["../../../src/polyfills/images/image-codecs-node.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B,OAAO,EAAC,cAAc,EAAC,8BAA2B;AAClD,OAAO,EAAC,eAAe,EAAC,+BAA4B;AACpD,OAAO,EAAC,mBAAmB,EAAC,gCAA6B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-sharp.d.ts","sourceRoot":"","sources":["../../../src/polyfills/images/load-sharp.ts"],"names":[],"mappings":"AAEA,mFAAmF;AACnF,wBAAsB,SAAS,IAAI,OAAO,CAAC,cAAc,OAAO,EAAE,OAAO,CAAC,CASzE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
/** Loads the optional Node image codec only when image processing is requested. */
|
|
3
|
+
export async function loadSharp() {
|
|
4
|
+
try {
|
|
5
|
+
return (await import('sharp')).default;
|
|
6
|
+
}
|
|
7
|
+
catch (error) {
|
|
8
|
+
throw new Error("Node image decoding and encoding require the optional 'sharp' package. Install it with 'npm install sharp'.", { cause: error });
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=load-sharp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-sharp.js","sourceRoot":"","sources":["../../../src/polyfills/images/load-sharp.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B,mFAAmF;AACnF,MAAM,CAAC,KAAK,UAAU,SAAS;IAC7B,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IACzC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,6GAA6G,EAC7G,EAAC,KAAK,EAAE,KAAK,EAAC,CACf,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -5,7 +5,7 @@ type NodeImageData = {
|
|
|
5
5
|
};
|
|
6
6
|
/**
|
|
7
7
|
* Minimal Node.js `ImageBitmap` polyfill backed by decoded pixel data.
|
|
8
|
-
* This is intentionally limited to the functionality needed by `
|
|
8
|
+
* This is intentionally limited to the functionality needed by `ImageLoader`
|
|
9
9
|
* and `getImageBitmapData()`.
|
|
10
10
|
*/
|
|
11
11
|
export declare class NodeImageBitmap {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
/**
|
|
5
5
|
* Minimal Node.js `ImageBitmap` polyfill backed by decoded pixel data.
|
|
6
|
-
* This is intentionally limited to the functionality needed by `
|
|
6
|
+
* This is intentionally limited to the functionality needed by `ImageLoader`
|
|
7
7
|
* and `getImageBitmapData()`.
|
|
8
8
|
*/
|
|
9
9
|
export class NodeImageBitmap {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-image-formats.d.ts","sourceRoot":"","sources":["../../../src/polyfills/images/node-image-formats.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node-image-formats.d.ts","sourceRoot":"","sources":["../../../src/polyfills/images/node-image-formats.ts"],"names":[],"mappings":"AAEA,qEAAqE;AACrE,eAAO,MAAM,mBAAmB,UAQ/B,CAAC"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
1
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
/** Image MIME types supported by the optional Sharp Node backend. */
|
|
3
|
+
export const NODE_FORMAT_SUPPORT = [
|
|
4
|
+
'image/png',
|
|
5
|
+
'image/jpeg',
|
|
6
|
+
'image/gif',
|
|
7
|
+
'image/webp',
|
|
8
|
+
'image/avif',
|
|
9
|
+
'image/tiff',
|
|
10
|
+
'image/svg+xml'
|
|
11
|
+
];
|
|
6
12
|
//# sourceMappingURL=node-image-formats.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-image-formats.js","sourceRoot":"","sources":["../../../src/polyfills/images/node-image-formats.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"node-image-formats.js","sourceRoot":"","sources":["../../../src/polyfills/images/node-image-formats.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B,qEAAqE;AACrE,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,WAAW;IACX,YAAY;IACZ,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,eAAe;CAChB,CAAC"}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
export { NODE_FORMAT_SUPPORT } from "./node-image-formats.js";
|
|
2
|
-
|
|
2
|
+
/** Decoded Node image pixels and dimensions. */
|
|
3
|
+
type NodeImageData = {
|
|
4
|
+
/** Pixel layout, including a frame dimension for animations. */
|
|
3
5
|
shape: number[];
|
|
6
|
+
/** Interleaved RGBA pixels. */
|
|
4
7
|
data: Uint8Array;
|
|
8
|
+
/** Frame width in pixels. */
|
|
5
9
|
width: number;
|
|
10
|
+
/** Frame height in pixels. */
|
|
6
11
|
height: number;
|
|
12
|
+
/** Number of components per pixel. */
|
|
7
13
|
components: number;
|
|
14
|
+
/** Number of animation frames. */
|
|
8
15
|
layers: number[];
|
|
9
16
|
};
|
|
10
|
-
|
|
17
|
+
/** Decodes encoded image bytes into RGBA pixels, detecting the format from the bytes. */
|
|
18
|
+
export declare function parseImageNode(arrayBuffer: ArrayBuffer, _mimeType?: string): Promise<NodeImageData>;
|
|
11
19
|
//# sourceMappingURL=parse-image-node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-image-node.d.ts","sourceRoot":"","sources":["../../../src/polyfills/images/parse-image-node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse-image-node.d.ts","sourceRoot":"","sources":["../../../src/polyfills/images/parse-image-node.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,mBAAmB,EAAC,gCAA6B;AAEzD,gDAAgD;AAChD,KAAK,aAAa,GAAG;IACnB,gEAAgE;IAChE,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,+BAA+B;IAC/B,IAAI,EAAE,UAAU,CAAC;IACjB,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,kCAAkC;IAClC,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,yFAAyF;AACzF,wBAAsB,cAAc,CAClC,WAAW,EAAE,WAAW,EACxB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,aAAa,CAAC,CAkBxB"}
|