@loaders.gl/raster 5.0.0-alpha.13 → 5.0.0-beta.1

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.
@@ -243,6 +243,8 @@
243
243
  process: processOnMainThread
244
244
  };
245
245
  WorkerBody.onmessage = async (type, payload) => {
246
+ const reporter = type === "process" || type === "process-in-batches" ? createProgressReporter() : void 0;
247
+ const jobContext = { ...context, reportProgress: reporter?.report };
246
248
  try {
247
249
  switch (type) {
248
250
  case "preload":
@@ -255,9 +257,10 @@
255
257
  const result = await process(
256
258
  payload.input,
257
259
  payload.options || {},
258
- context,
260
+ jobContext,
259
261
  payload.context || {}
260
262
  );
263
+ reporter?.finish();
261
264
  WorkerBody.postMessage("done", { result });
262
265
  break;
263
266
  case "process-in-batches":
@@ -272,13 +275,14 @@
272
275
  const resultIterator = processInBatches(
273
276
  createDemandDrivenIterator(inputBatches),
274
277
  payload.options || {},
275
- context,
278
+ jobContext,
276
279
  payload.context || {}
277
280
  );
278
281
  for await (const batch of resultIterator) {
279
282
  await WorkerBody.postMessage("output-batch", { result: batch });
280
283
  await outputAcknowledgements.next();
281
284
  }
285
+ reporter?.finish();
282
286
  await WorkerBody.postMessage("done", {});
283
287
  } finally {
284
288
  activeInputBatches = null;
@@ -306,6 +310,7 @@
306
310
  default:
307
311
  }
308
312
  } catch (error) {
313
+ reporter?.finish();
309
314
  const message = error instanceof Error ? error.message : "";
310
315
  WorkerBody.postMessage("error", { error: message });
311
316
  }
@@ -345,6 +350,35 @@
345
350
  WorkerBody.postMessage("process", payload);
346
351
  });
347
352
  }
353
+ function createProgressReporter() {
354
+ let pending;
355
+ let finished = false;
356
+ let scheduled = false;
357
+ const flush = () => {
358
+ scheduled = false;
359
+ if (pending) {
360
+ WorkerBody.postMessage("progress", { progress: pending });
361
+ pending = void 0;
362
+ }
363
+ };
364
+ return {
365
+ /** Records progress while retaining phase transitions. */
366
+ report(progress) {
367
+ if (finished) return;
368
+ if (pending && pending.phase !== progress.phase) flush();
369
+ pending = { ...progress };
370
+ if (!scheduled) {
371
+ scheduled = true;
372
+ setTimeout(flush, 0);
373
+ }
374
+ },
375
+ /** Flushes final progress and suppresses reports from stale callbacks. */
376
+ finish() {
377
+ flush();
378
+ finished = true;
379
+ }
380
+ };
381
+ }
348
382
  var requestId, activeInputBatches, activeOutputAcknowledgements;
349
383
  var init_create_worker = __esm({
350
384
  "../core/src/worker-utils/lib/worker-api/create-worker.ts"() {
@@ -391,6 +425,7 @@
391
425
  options,
392
426
  context: {
393
427
  ...loaderContext,
428
+ reportProgress: workerContext?.reportProgress,
394
429
  coreApi: createWorkerCoreApi(),
395
430
  _parse: createParseOnMainThread(workerContext?.process)
396
431
  }
@@ -401,8 +436,10 @@
401
436
  if (!loader.parseInBatches) {
402
437
  throw new Error(`${loader.id} loader does not support batched parsing`);
403
438
  }
404
- const resultIterator = loader.parseInBatches(inputIterator, options, {
439
+ const parserOptions = getWorkerLoaderOptions(loader, options);
440
+ const resultIterator = loader.parseInBatches(inputIterator, parserOptions, {
405
441
  ...loaderContext,
442
+ reportProgress: workerContext?.reportProgress,
406
443
  coreApi: createWorkerCoreApi(),
407
444
  _parse: createParseOnMainThread(workerContext?.process)
408
445
  });
@@ -458,7 +495,17 @@
458
495
  if (!context) {
459
496
  return void 0;
460
497
  }
461
- const { fetch: fetch2, loaders, coreApi, _parse, _parseSync, _parseInBatches, ...serializableContext } = context;
498
+ const {
499
+ fetch: fetch2,
500
+ loaders,
501
+ coreApi,
502
+ signal,
503
+ reportProgress,
504
+ _parse,
505
+ _parseSync,
506
+ _parseInBatches,
507
+ ...serializableContext
508
+ } = context;
462
509
  return JSON.parse(JSON.stringify(serializableContext));
463
510
  }
464
511
  async function parseData({
@@ -479,18 +526,15 @@
479
526
  } else {
480
527
  throw new Error(`Could not load data with ${loader.name} loader`);
481
528
  }
482
- options = {
529
+ options = getWorkerLoaderOptions(loader, options);
530
+ return await parser(data, { ...options }, context, loader);
531
+ }
532
+ function getWorkerLoaderOptions(loader, options) {
533
+ return {
483
534
  ...options,
484
- modules: {
485
- ...loader && loader.options && loader.options.modules || {},
486
- ...options.modules || {}
487
- },
488
- core: {
489
- ...options.core,
490
- worker: false
491
- }
535
+ modules: { ...loader.options?.modules, ...options.modules },
536
+ core: { ...options.core, worker: false }
492
537
  };
493
- return await parser(data, { ...options }, context, loader);
494
538
  }
495
539
  var init_create_loader_worker = __esm({
496
540
  "../core/src/loader-utils/lib/worker-loader-utils/create-loader-worker.ts"() {
@@ -523,6 +567,134 @@
523
567
  }
524
568
  });
525
569
 
570
+ // ../../node_modules/@math.gl/core/dist/lib/math-utils.js
571
+ var PI_OVER_TWO, PI_OVER_FOUR, PI_OVER_SIX, TWO_PI;
572
+ var init_math_utils = __esm({
573
+ "../../node_modules/@math.gl/core/dist/lib/math-utils.js"() {
574
+ PI_OVER_TWO = Math.PI / 2;
575
+ PI_OVER_FOUR = Math.PI / 4;
576
+ PI_OVER_SIX = Math.PI / 6;
577
+ TWO_PI = Math.PI * 2;
578
+ }
579
+ });
580
+
581
+ // ../../node_modules/@math.gl/core/dist/gl-matrix/vec2.js
582
+ var init_vec2 = __esm({
583
+ "../../node_modules/@math.gl/core/dist/gl-matrix/vec2.js"() {
584
+ }
585
+ });
586
+
587
+ // ../../node_modules/@math.gl/core/dist/gl-matrix/vec3.js
588
+ var init_vec3 = __esm({
589
+ "../../node_modules/@math.gl/core/dist/gl-matrix/vec3.js"() {
590
+ }
591
+ });
592
+
593
+ // ../../node_modules/@math.gl/core/dist/gl-matrix/mat3.js
594
+ var init_mat3 = __esm({
595
+ "../../node_modules/@math.gl/core/dist/gl-matrix/mat3.js"() {
596
+ }
597
+ });
598
+
599
+ // ../../node_modules/@math.gl/core/dist/gl-matrix/mat4.js
600
+ var init_mat4 = __esm({
601
+ "../../node_modules/@math.gl/core/dist/gl-matrix/mat4.js"() {
602
+ }
603
+ });
604
+
605
+ // ../../node_modules/@math.gl/core/dist/gl-matrix/vec4.js
606
+ var init_vec4 = __esm({
607
+ "../../node_modules/@math.gl/core/dist/gl-matrix/vec4.js"() {
608
+ }
609
+ });
610
+
611
+ // ../../node_modules/@math.gl/core/dist/gl-matrix/quat.js
612
+ var init_quat = __esm({
613
+ "../../node_modules/@math.gl/core/dist/gl-matrix/quat.js"() {
614
+ }
615
+ });
616
+
617
+ // ../../node_modules/@math.gl/core/dist/types/float16.js
618
+ function getFloat16ArrayConstructor() {
619
+ return NativeFloat16ArrayConstructor ?? Uint16Array;
620
+ }
621
+ var NativeFloat16ArrayConstructor;
622
+ var init_float16 = __esm({
623
+ "../../node_modules/@math.gl/core/dist/types/float16.js"() {
624
+ NativeFloat16ArrayConstructor = globalThis.Float16Array;
625
+ }
626
+ });
627
+
628
+ // ../../node_modules/@math.gl/core/dist/types/index.js
629
+ var init_types = __esm({
630
+ "../../node_modules/@math.gl/core/dist/types/index.js"() {
631
+ init_float16();
632
+ }
633
+ });
634
+
635
+ // ../../node_modules/@math.gl/core/dist/types.js
636
+ var init_types2 = __esm({
637
+ "../../node_modules/@math.gl/core/dist/types.js"() {
638
+ init_types();
639
+ }
640
+ });
641
+
642
+ // ../../node_modules/@math.gl/core/dist/mat3.js
643
+ var init_mat32 = __esm({
644
+ "../../node_modules/@math.gl/core/dist/mat3.js"() {
645
+ init_mat3();
646
+ }
647
+ });
648
+
649
+ // ../../node_modules/@math.gl/core/dist/mat4.js
650
+ var init_mat42 = __esm({
651
+ "../../node_modules/@math.gl/core/dist/mat4.js"() {
652
+ init_mat4();
653
+ }
654
+ });
655
+
656
+ // ../../node_modules/@math.gl/core/dist/quat.js
657
+ var init_quat2 = __esm({
658
+ "../../node_modules/@math.gl/core/dist/quat.js"() {
659
+ init_quat();
660
+ }
661
+ });
662
+
663
+ // ../../node_modules/@math.gl/core/dist/vec2.js
664
+ var init_vec22 = __esm({
665
+ "../../node_modules/@math.gl/core/dist/vec2.js"() {
666
+ init_vec2();
667
+ }
668
+ });
669
+
670
+ // ../../node_modules/@math.gl/core/dist/vec3.js
671
+ var init_vec32 = __esm({
672
+ "../../node_modules/@math.gl/core/dist/vec3.js"() {
673
+ init_vec3();
674
+ }
675
+ });
676
+
677
+ // ../../node_modules/@math.gl/core/dist/vec4.js
678
+ var init_vec42 = __esm({
679
+ "../../node_modules/@math.gl/core/dist/vec4.js"() {
680
+ init_vec4();
681
+ }
682
+ });
683
+
684
+ // ../../node_modules/@math.gl/core/dist/index.js
685
+ var init_dist = __esm({
686
+ "../../node_modules/@math.gl/core/dist/index.js"() {
687
+ init_math_utils();
688
+ init_types2();
689
+ init_mat32();
690
+ init_mat42();
691
+ init_quat2();
692
+ init_vec22();
693
+ init_vec32();
694
+ init_vec42();
695
+ }
696
+ });
697
+
526
698
  // ../core/src/loader-utils/index.ts
527
699
  var init_loader_utils = __esm({
528
700
  "../core/src/loader-utils/index.ts"() {
@@ -15869,16 +16041,17 @@ return true;`);
15869
16041
 
15870
16042
  // ../core/src/schema-utils/lib/arrow/split-arrow-buffers.ts
15871
16043
  function splitArrowBuffers(input, options = {}) {
16044
+ const context = { ...options, copies: /* @__PURE__ */ new WeakMap() };
15872
16045
  if (isArrowTable2(input)) {
15873
- return splitArrowTableBuffersInternal(input, options);
16046
+ return splitArrowTableBuffersInternal(input, context);
15874
16047
  }
15875
16048
  if (isArrowRecordBatch2(input)) {
15876
- return splitArrowRecordBatchBuffers(input, options);
16049
+ return splitArrowRecordBatchBuffers(input, context);
15877
16050
  }
15878
16051
  if (isArrowVector2(input)) {
15879
- return splitArrowVectorBuffers(input, options);
16052
+ return splitArrowVectorBuffers(input, context);
15880
16053
  }
15881
- return splitArrowDataBuffers(input, options);
16054
+ return splitArrowDataBuffers(input, context);
15882
16055
  }
15883
16056
  function isArrowTable2(input) {
15884
16057
  return "batches" in input;
@@ -15934,7 +16107,12 @@ return true;`);
15934
16107
  if (options.copy !== "all" && array.byteOffset === 0 && array.byteLength === array.buffer.byteLength) {
15935
16108
  return array;
15936
16109
  }
15937
- return array.slice();
16110
+ let copy = options.copies.get(array);
16111
+ if (!copy) {
16112
+ copy = array.slice();
16113
+ options.copies.set(array, copy);
16114
+ }
16115
+ return copy;
15938
16116
  }
15939
16117
  function isArrowTypedArray(value) {
15940
16118
  return ArrayBuffer.isView(value) && !(value instanceof DataView);
@@ -16049,31 +16227,6 @@ return true;`);
16049
16227
  }
16050
16228
  });
16051
16229
 
16052
- // ../../node_modules/@math.gl/core/dist/types/float16.js
16053
- function getFloat16ArrayConstructor() {
16054
- return NativeFloat16ArrayConstructor ?? Uint16Array;
16055
- }
16056
- var NativeFloat16ArrayConstructor;
16057
- var init_float16 = __esm({
16058
- "../../node_modules/@math.gl/core/dist/types/float16.js"() {
16059
- NativeFloat16ArrayConstructor = globalThis.Float16Array;
16060
- }
16061
- });
16062
-
16063
- // ../../node_modules/@math.gl/core/dist/types/index.js
16064
- var init_types = __esm({
16065
- "../../node_modules/@math.gl/core/dist/types/index.js"() {
16066
- init_float16();
16067
- }
16068
- });
16069
-
16070
- // ../../node_modules/@math.gl/core/dist/types.js
16071
- var init_types2 = __esm({
16072
- "../../node_modules/@math.gl/core/dist/types.js"() {
16073
- init_types();
16074
- }
16075
- });
16076
-
16077
16230
  // ../core/src/schema-utils/lib/schema/data-type.ts
16078
16231
  function getDataTypeFromValue(value, defaultNumberType = "float32") {
16079
16232
  if (value instanceof Date) {
@@ -16241,7 +16394,7 @@ return true;`);
16241
16394
  var init_float162 = __esm({
16242
16395
  "../core/src/schema/float16.ts"() {
16243
16396
  "use strict";
16244
- init_types2();
16397
+ init_dist();
16245
16398
  }
16246
16399
  });
16247
16400
 
@@ -17180,7 +17333,7 @@ return true;`);
17180
17333
  var init_version = __esm({
17181
17334
  "src/terrain/lib/utils/version.ts"() {
17182
17335
  "use strict";
17183
- VERSION = true ? "5.0.0-alpha.13" : "latest";
17336
+ VERSION = true ? "5.0.0-beta.1" : "latest";
17184
17337
  }
17185
17338
  });
17186
17339
 
@@ -64,7 +64,7 @@ var QuantizedMeshFormat = {
64
64
  };
65
65
 
66
66
  // dist/terrain/lib/utils/version.js
67
- var VERSION = true ? "5.0.0-alpha.13" : "latest";
67
+ var VERSION = true ? "5.0.0-beta.1" : "latest";
68
68
 
69
69
  // dist/terrain/terrain-loader-types.js
70
70
  var TerrainLoader = {