@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.
@@ -287,6 +287,8 @@
287
287
  process: processOnMainThread
288
288
  };
289
289
  WorkerBody.onmessage = async (type, payload) => {
290
+ const reporter = type === "process" || type === "process-in-batches" ? createProgressReporter() : void 0;
291
+ const jobContext = { ...context, reportProgress: reporter?.report };
290
292
  try {
291
293
  switch (type) {
292
294
  case "preload":
@@ -299,9 +301,10 @@
299
301
  const result = await process2(
300
302
  payload.input,
301
303
  payload.options || {},
302
- context,
304
+ jobContext,
303
305
  payload.context || {}
304
306
  );
307
+ reporter?.finish();
305
308
  WorkerBody.postMessage("done", { result });
306
309
  break;
307
310
  case "process-in-batches":
@@ -316,13 +319,14 @@
316
319
  const resultIterator = processInBatches(
317
320
  createDemandDrivenIterator(inputBatches),
318
321
  payload.options || {},
319
- context,
322
+ jobContext,
320
323
  payload.context || {}
321
324
  );
322
325
  for await (const batch of resultIterator) {
323
326
  await WorkerBody.postMessage("output-batch", { result: batch });
324
327
  await outputAcknowledgements.next();
325
328
  }
329
+ reporter?.finish();
326
330
  await WorkerBody.postMessage("done", {});
327
331
  } finally {
328
332
  activeInputBatches = null;
@@ -350,6 +354,7 @@
350
354
  default:
351
355
  }
352
356
  } catch (error) {
357
+ reporter?.finish();
353
358
  const message = error instanceof Error ? error.message : "";
354
359
  WorkerBody.postMessage("error", { error: message });
355
360
  }
@@ -389,6 +394,35 @@
389
394
  WorkerBody.postMessage("process", payload);
390
395
  });
391
396
  }
397
+ function createProgressReporter() {
398
+ let pending;
399
+ let finished = false;
400
+ let scheduled = false;
401
+ const flush = () => {
402
+ scheduled = false;
403
+ if (pending) {
404
+ WorkerBody.postMessage("progress", { progress: pending });
405
+ pending = void 0;
406
+ }
407
+ };
408
+ return {
409
+ /** Records progress while retaining phase transitions. */
410
+ report(progress) {
411
+ if (finished) return;
412
+ if (pending && pending.phase !== progress.phase) flush();
413
+ pending = { ...progress };
414
+ if (!scheduled) {
415
+ scheduled = true;
416
+ setTimeout(flush, 0);
417
+ }
418
+ },
419
+ /** Flushes final progress and suppresses reports from stale callbacks. */
420
+ finish() {
421
+ flush();
422
+ finished = true;
423
+ }
424
+ };
425
+ }
392
426
  var requestId, activeInputBatches, activeOutputAcknowledgements;
393
427
  var init_create_worker = __esm({
394
428
  "../core/src/worker-utils/lib/worker-api/create-worker.ts"() {
@@ -435,6 +469,7 @@
435
469
  options,
436
470
  context: {
437
471
  ...loaderContext,
472
+ reportProgress: workerContext?.reportProgress,
438
473
  coreApi: createWorkerCoreApi(),
439
474
  _parse: createParseOnMainThread(workerContext?.process)
440
475
  }
@@ -445,8 +480,10 @@
445
480
  if (!loader.parseInBatches) {
446
481
  throw new Error(`${loader.id} loader does not support batched parsing`);
447
482
  }
448
- const resultIterator = loader.parseInBatches(inputIterator, options, {
483
+ const parserOptions = getWorkerLoaderOptions(loader, options);
484
+ const resultIterator = loader.parseInBatches(inputIterator, parserOptions, {
449
485
  ...loaderContext,
486
+ reportProgress: workerContext?.reportProgress,
450
487
  coreApi: createWorkerCoreApi(),
451
488
  _parse: createParseOnMainThread(workerContext?.process)
452
489
  });
@@ -502,7 +539,17 @@
502
539
  if (!context) {
503
540
  return void 0;
504
541
  }
505
- const { fetch: fetch2, loaders, coreApi, _parse, _parseSync, _parseInBatches, ...serializableContext } = context;
542
+ const {
543
+ fetch: fetch2,
544
+ loaders,
545
+ coreApi,
546
+ signal,
547
+ reportProgress,
548
+ _parse,
549
+ _parseSync,
550
+ _parseInBatches,
551
+ ...serializableContext
552
+ } = context;
506
553
  return JSON.parse(JSON.stringify(serializableContext));
507
554
  }
508
555
  async function parseData({
@@ -523,18 +570,15 @@
523
570
  } else {
524
571
  throw new Error(`Could not load data with ${loader.name} loader`);
525
572
  }
526
- options = {
573
+ options = getWorkerLoaderOptions(loader, options);
574
+ return await parser(data, { ...options }, context, loader);
575
+ }
576
+ function getWorkerLoaderOptions(loader, options) {
577
+ return {
527
578
  ...options,
528
- modules: {
529
- ...loader && loader.options && loader.options.modules || {},
530
- ...options.modules || {}
531
- },
532
- core: {
533
- ...options.core,
534
- worker: false
535
- }
579
+ modules: { ...loader.options?.modules, ...options.modules },
580
+ core: { ...options.core, worker: false }
536
581
  };
537
- return await parser(data, { ...options }, context, loader);
538
582
  }
539
583
  var init_create_loader_worker = __esm({
540
584
  "../core/src/loader-utils/lib/worker-loader-utils/create-loader-worker.ts"() {
@@ -567,6 +611,134 @@
567
611
  }
568
612
  });
569
613
 
614
+ // ../../node_modules/@math.gl/core/dist/lib/math-utils.js
615
+ var PI_OVER_TWO, PI_OVER_FOUR, PI_OVER_SIX, TWO_PI;
616
+ var init_math_utils = __esm({
617
+ "../../node_modules/@math.gl/core/dist/lib/math-utils.js"() {
618
+ PI_OVER_TWO = Math.PI / 2;
619
+ PI_OVER_FOUR = Math.PI / 4;
620
+ PI_OVER_SIX = Math.PI / 6;
621
+ TWO_PI = Math.PI * 2;
622
+ }
623
+ });
624
+
625
+ // ../../node_modules/@math.gl/core/dist/gl-matrix/vec2.js
626
+ var init_vec2 = __esm({
627
+ "../../node_modules/@math.gl/core/dist/gl-matrix/vec2.js"() {
628
+ }
629
+ });
630
+
631
+ // ../../node_modules/@math.gl/core/dist/gl-matrix/vec3.js
632
+ var init_vec3 = __esm({
633
+ "../../node_modules/@math.gl/core/dist/gl-matrix/vec3.js"() {
634
+ }
635
+ });
636
+
637
+ // ../../node_modules/@math.gl/core/dist/gl-matrix/mat3.js
638
+ var init_mat3 = __esm({
639
+ "../../node_modules/@math.gl/core/dist/gl-matrix/mat3.js"() {
640
+ }
641
+ });
642
+
643
+ // ../../node_modules/@math.gl/core/dist/gl-matrix/mat4.js
644
+ var init_mat4 = __esm({
645
+ "../../node_modules/@math.gl/core/dist/gl-matrix/mat4.js"() {
646
+ }
647
+ });
648
+
649
+ // ../../node_modules/@math.gl/core/dist/gl-matrix/vec4.js
650
+ var init_vec4 = __esm({
651
+ "../../node_modules/@math.gl/core/dist/gl-matrix/vec4.js"() {
652
+ }
653
+ });
654
+
655
+ // ../../node_modules/@math.gl/core/dist/gl-matrix/quat.js
656
+ var init_quat = __esm({
657
+ "../../node_modules/@math.gl/core/dist/gl-matrix/quat.js"() {
658
+ }
659
+ });
660
+
661
+ // ../../node_modules/@math.gl/core/dist/types/float16.js
662
+ function getFloat16ArrayConstructor() {
663
+ return NativeFloat16ArrayConstructor ?? Uint16Array;
664
+ }
665
+ var NativeFloat16ArrayConstructor;
666
+ var init_float16 = __esm({
667
+ "../../node_modules/@math.gl/core/dist/types/float16.js"() {
668
+ NativeFloat16ArrayConstructor = globalThis.Float16Array;
669
+ }
670
+ });
671
+
672
+ // ../../node_modules/@math.gl/core/dist/types/index.js
673
+ var init_types = __esm({
674
+ "../../node_modules/@math.gl/core/dist/types/index.js"() {
675
+ init_float16();
676
+ }
677
+ });
678
+
679
+ // ../../node_modules/@math.gl/core/dist/types.js
680
+ var init_types2 = __esm({
681
+ "../../node_modules/@math.gl/core/dist/types.js"() {
682
+ init_types();
683
+ }
684
+ });
685
+
686
+ // ../../node_modules/@math.gl/core/dist/mat3.js
687
+ var init_mat32 = __esm({
688
+ "../../node_modules/@math.gl/core/dist/mat3.js"() {
689
+ init_mat3();
690
+ }
691
+ });
692
+
693
+ // ../../node_modules/@math.gl/core/dist/mat4.js
694
+ var init_mat42 = __esm({
695
+ "../../node_modules/@math.gl/core/dist/mat4.js"() {
696
+ init_mat4();
697
+ }
698
+ });
699
+
700
+ // ../../node_modules/@math.gl/core/dist/quat.js
701
+ var init_quat2 = __esm({
702
+ "../../node_modules/@math.gl/core/dist/quat.js"() {
703
+ init_quat();
704
+ }
705
+ });
706
+
707
+ // ../../node_modules/@math.gl/core/dist/vec2.js
708
+ var init_vec22 = __esm({
709
+ "../../node_modules/@math.gl/core/dist/vec2.js"() {
710
+ init_vec2();
711
+ }
712
+ });
713
+
714
+ // ../../node_modules/@math.gl/core/dist/vec3.js
715
+ var init_vec32 = __esm({
716
+ "../../node_modules/@math.gl/core/dist/vec3.js"() {
717
+ init_vec3();
718
+ }
719
+ });
720
+
721
+ // ../../node_modules/@math.gl/core/dist/vec4.js
722
+ var init_vec42 = __esm({
723
+ "../../node_modules/@math.gl/core/dist/vec4.js"() {
724
+ init_vec4();
725
+ }
726
+ });
727
+
728
+ // ../../node_modules/@math.gl/core/dist/index.js
729
+ var init_dist = __esm({
730
+ "../../node_modules/@math.gl/core/dist/index.js"() {
731
+ init_math_utils();
732
+ init_types2();
733
+ init_mat32();
734
+ init_mat42();
735
+ init_quat2();
736
+ init_vec22();
737
+ init_vec32();
738
+ init_vec42();
739
+ }
740
+ });
741
+
570
742
  // ../core/src/loader-utils/index.ts
571
743
  var init_loader_utils = __esm({
572
744
  "../core/src/loader-utils/index.ts"() {
@@ -15916,16 +16088,17 @@ return true;`);
15916
16088
 
15917
16089
  // ../core/src/schema-utils/lib/arrow/split-arrow-buffers.ts
15918
16090
  function splitArrowBuffers(input, options = {}) {
16091
+ const context = { ...options, copies: /* @__PURE__ */ new WeakMap() };
15919
16092
  if (isArrowTable2(input)) {
15920
- return splitArrowTableBuffersInternal(input, options);
16093
+ return splitArrowTableBuffersInternal(input, context);
15921
16094
  }
15922
16095
  if (isArrowRecordBatch2(input)) {
15923
- return splitArrowRecordBatchBuffers(input, options);
16096
+ return splitArrowRecordBatchBuffers(input, context);
15924
16097
  }
15925
16098
  if (isArrowVector2(input)) {
15926
- return splitArrowVectorBuffers(input, options);
16099
+ return splitArrowVectorBuffers(input, context);
15927
16100
  }
15928
- return splitArrowDataBuffers(input, options);
16101
+ return splitArrowDataBuffers(input, context);
15929
16102
  }
15930
16103
  function isArrowTable2(input) {
15931
16104
  return "batches" in input;
@@ -15981,7 +16154,12 @@ return true;`);
15981
16154
  if (options.copy !== "all" && array.byteOffset === 0 && array.byteLength === array.buffer.byteLength) {
15982
16155
  return array;
15983
16156
  }
15984
- return array.slice();
16157
+ let copy = options.copies.get(array);
16158
+ if (!copy) {
16159
+ copy = array.slice();
16160
+ options.copies.set(array, copy);
16161
+ }
16162
+ return copy;
15985
16163
  }
15986
16164
  function isArrowTypedArray(value) {
15987
16165
  return ArrayBuffer.isView(value) && !(value instanceof DataView);
@@ -16096,31 +16274,6 @@ return true;`);
16096
16274
  }
16097
16275
  });
16098
16276
 
16099
- // ../../node_modules/@math.gl/core/dist/types/float16.js
16100
- function getFloat16ArrayConstructor() {
16101
- return NativeFloat16ArrayConstructor ?? Uint16Array;
16102
- }
16103
- var NativeFloat16ArrayConstructor;
16104
- var init_float16 = __esm({
16105
- "../../node_modules/@math.gl/core/dist/types/float16.js"() {
16106
- NativeFloat16ArrayConstructor = globalThis.Float16Array;
16107
- }
16108
- });
16109
-
16110
- // ../../node_modules/@math.gl/core/dist/types/index.js
16111
- var init_types = __esm({
16112
- "../../node_modules/@math.gl/core/dist/types/index.js"() {
16113
- init_float16();
16114
- }
16115
- });
16116
-
16117
- // ../../node_modules/@math.gl/core/dist/types.js
16118
- var init_types2 = __esm({
16119
- "../../node_modules/@math.gl/core/dist/types.js"() {
16120
- init_types();
16121
- }
16122
- });
16123
-
16124
16277
  // ../core/src/schema-utils/lib/schema/data-type.ts
16125
16278
  function getDataTypeFromValue(value, defaultNumberType = "float32") {
16126
16279
  if (value instanceof Date) {
@@ -16288,7 +16441,7 @@ return true;`);
16288
16441
  var init_float162 = __esm({
16289
16442
  "../core/src/schema/float16.ts"() {
16290
16443
  "use strict";
16291
- init_types2();
16444
+ init_dist();
16292
16445
  }
16293
16446
  });
16294
16447
 
@@ -16996,7 +17149,7 @@ return true;`);
16996
17149
  var init_version = __esm({
16997
17150
  "../images/src/lib/utils/version.ts"() {
16998
17151
  "use strict";
16999
- VERSION = true ? "5.0.0-alpha.13" : "latest";
17152
+ VERSION = true ? "5.0.0-beta.1" : "latest";
17000
17153
  }
17001
17154
  });
17002
17155
 
@@ -18117,7 +18270,7 @@ return true;`);
18117
18270
  var init_version2 = __esm({
18118
18271
  "src/terrain/lib/utils/version.ts"() {
18119
18272
  "use strict";
18120
- VERSION2 = true ? "5.0.0-alpha.13" : "latest";
18273
+ VERSION2 = true ? "5.0.0-beta.1" : "latest";
18121
18274
  }
18122
18275
  });
18123
18276
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/raster",
3
- "version": "5.0.0-alpha.13",
3
+ "version": "5.0.0-beta.1",
4
4
  "description": "GeoTIFF, LERC and terrain loaders with lazy format entry points",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -311,7 +311,10 @@
311
311
  "files": [
312
312
  "src",
313
313
  "dist",
314
- "README.md"
314
+ "README.md",
315
+ "LICENSE",
316
+ "THIRD-PARTY-NOTICES.md",
317
+ "third-party-licenses"
315
318
  ],
316
319
  "scripts": {
317
320
  "copy-libs": "mkdir -p dist/terrain/libs dist/lerc/libs && cp -R src/terrain/libs/. dist/terrain/libs/ && cp -R src/lerc/libs/. dist/lerc/libs/",
@@ -321,8 +324,8 @@
321
324
  "pre-build": "npm run copy-libs && node ./build-cjs.mjs && npm run build-worker-terrain && npm run build-worker-quantized-mesh"
322
325
  },
323
326
  "dependencies": {
324
- "@loaders.gl/images": "5.0.0-alpha.13",
325
- "@math.gl/geospatial": "5.0.0-alpha.19",
327
+ "@loaders.gl/images": "5.0.0-beta.1",
328
+ "@math.gl/geospatial": "5.0.0-beta.1",
326
329
  "fast-xml-parser": "^5.3.6"
327
330
  },
328
331
  "peerDependencies": {
@@ -342,5 +345,6 @@
342
345
  "@mapbox/martini": "0.2.0",
343
346
  "geotiff": "^2.1.0",
344
347
  "lerc": "^4.2.0"
345
- }
348
+ },
349
+ "gitHead": "89312301ed9e8ec89a58501c052a38284d1570c1"
346
350
  }
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2019, Michael Fogleman, Vladimir Agafonkin
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any purpose
6
+ with or without fee is hereby granted, provided that the above copyright notice
7
+ and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
11
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
13
+ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
14
+ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
15
+ THIS SOFTWARE.