@loaders.gl/core 3.1.6 → 3.2.0-alpha.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.
Files changed (36) hide show
  1. package/dist/dist.min.js +720 -29
  2. package/dist/es5/lib/api/select-loader.js +15 -0
  3. package/dist/es5/lib/api/select-loader.js.map +1 -1
  4. package/dist/es5/lib/init.js +14 -4
  5. package/dist/es5/lib/init.js.map +1 -1
  6. package/dist/es5/lib/loader-utils/option-defaults.js +4 -1
  7. package/dist/es5/lib/loader-utils/option-defaults.js.map +1 -1
  8. package/dist/es5/lib/utils/log.js +14 -0
  9. package/dist/es5/lib/utils/log.js.map +1 -0
  10. package/dist/es5/null-loader.js +1 -1
  11. package/dist/es5/null-loader.js.map +1 -1
  12. package/dist/esm/lib/api/select-loader.js +14 -0
  13. package/dist/esm/lib/api/select-loader.js.map +1 -1
  14. package/dist/esm/lib/init.js +11 -4
  15. package/dist/esm/lib/init.js.map +1 -1
  16. package/dist/esm/lib/loader-utils/option-defaults.js +3 -1
  17. package/dist/esm/lib/loader-utils/option-defaults.js.map +1 -1
  18. package/dist/esm/lib/utils/log.js +5 -0
  19. package/dist/esm/lib/utils/log.js.map +1 -0
  20. package/dist/esm/null-loader.js +1 -1
  21. package/dist/esm/null-loader.js.map +1 -1
  22. package/dist/lib/api/select-loader.d.ts.map +1 -1
  23. package/dist/lib/api/select-loader.js +11 -0
  24. package/dist/lib/init.d.ts.map +1 -1
  25. package/dist/lib/init.js +9 -3
  26. package/dist/lib/loader-utils/option-defaults.d.ts.map +1 -1
  27. package/dist/lib/loader-utils/option-defaults.js +3 -1
  28. package/dist/lib/utils/log.d.ts +3 -0
  29. package/dist/lib/utils/log.d.ts.map +1 -0
  30. package/dist/lib/utils/log.js +6 -0
  31. package/dist/null-worker.js +46 -15
  32. package/package.json +7 -4
  33. package/src/lib/api/select-loader.ts +16 -0
  34. package/src/lib/init.ts +10 -3
  35. package/src/lib/loader-utils/option-defaults.ts +3 -1
  36. package/src/lib/utils/log.ts +4 -0
package/dist/dist.min.js CHANGED
@@ -65,7 +65,7 @@
65
65
  var DEFAULT_VERSION, VERSION;
66
66
  var init_version = __esm({
67
67
  "../worker-utils/src/lib/env-utils/version.ts"() {
68
- DEFAULT_VERSION = "latest";
68
+ DEFAULT_VERSION = "beta";
69
69
  VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : DEFAULT_VERSION;
70
70
  if (typeof __VERSION__ === "undefined") {
71
71
  console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
@@ -112,13 +112,13 @@
112
112
  init_assert2();
113
113
  WorkerJob = class {
114
114
  constructor(jobName, workerThread) {
115
- this.name = jobName;
116
- this.workerThread = workerThread;
117
115
  this.isRunning = true;
118
116
  this._resolve = () => {
119
117
  };
120
118
  this._reject = () => {
121
119
  };
120
+ this.name = jobName;
121
+ this.workerThread = workerThread;
122
122
  this.result = new Promise((resolve, reject) => {
123
123
  this._resolve = resolve;
124
124
  this._reject = reject;
@@ -145,6 +145,21 @@
145
145
  }
146
146
  });
147
147
 
148
+ // ../worker-utils/src/lib/node/worker_threads-browser.js
149
+ var Worker2;
150
+ var init_worker_threads_browser = __esm({
151
+ "../worker-utils/src/lib/node/worker_threads-browser.js"() {
152
+ Worker2 = class {
153
+ on(message, cb) {
154
+ }
155
+ postMessage(...args) {
156
+ }
157
+ terminate() {
158
+ }
159
+ };
160
+ }
161
+ });
162
+
148
163
  // ../worker-utils/src/lib/worker-utils/get-loadable-worker-url.ts
149
164
  function getLoadableWorkerURL(props) {
150
165
  assert2(props.source && !props.url || !props.source && props.url);
@@ -232,6 +247,8 @@
232
247
  var NOOP, WorkerThread;
233
248
  var init_worker_thread = __esm({
234
249
  "../worker-utils/src/lib/worker-farm/worker-thread.ts"() {
250
+ init_worker_threads_browser();
251
+ init_globals2();
235
252
  init_assert2();
236
253
  init_get_loadable_worker_url();
237
254
  init_get_transfer_list();
@@ -248,10 +265,10 @@
248
265
  this.url = url;
249
266
  this.onMessage = NOOP;
250
267
  this.onError = (error) => console.log(error);
251
- this.worker = this._createBrowserWorker();
268
+ this.worker = isBrowser2 ? this._createBrowserWorker() : this._createNodeWorker();
252
269
  }
253
270
  static isSupported() {
254
- return typeof Worker !== "undefined";
271
+ return typeof Worker !== "undefined" && isBrowser2;
255
272
  }
256
273
  destroy() {
257
274
  this.onMessage = NOOP;
@@ -294,6 +311,27 @@
294
311
  worker.onmessageerror = (event) => console.error(event);
295
312
  return worker;
296
313
  }
314
+ _createNodeWorker() {
315
+ let worker;
316
+ if (this.url) {
317
+ const absolute = this.url.includes(":/") || this.url.startsWith("/");
318
+ const url = absolute ? this.url : `./${this.url}`;
319
+ worker = new Worker2(url, { eval: false });
320
+ } else if (this.source) {
321
+ worker = new Worker2(this.source, { eval: true });
322
+ } else {
323
+ throw new Error("no worker");
324
+ }
325
+ worker.on("message", (data) => {
326
+ this.onMessage(data);
327
+ });
328
+ worker.on("error", (error) => {
329
+ this.onError(error);
330
+ });
331
+ worker.on("exit", (code) => {
332
+ });
333
+ return worker;
334
+ }
297
335
  };
298
336
  }
299
337
  });
@@ -322,6 +360,9 @@
322
360
  this.url = props.url;
323
361
  this.setProps(props);
324
362
  }
363
+ static isSupported() {
364
+ return WorkerThread.isSupported();
365
+ }
325
366
  destroy() {
326
367
  this.idleQueue.forEach((worker) => worker.destroy());
327
368
  this.isDestroyed = true;
@@ -418,9 +459,9 @@
418
459
  DEFAULT_PROPS = {
419
460
  maxConcurrency: 3,
420
461
  maxMobileConcurrency: 1,
462
+ reuseWorkers: true,
421
463
  onDebug: () => {
422
- },
423
- reuseWorkers: true
464
+ }
424
465
  };
425
466
  WorkerFarm = class {
426
467
  constructor(props) {
@@ -441,6 +482,7 @@
441
482
  for (const workerPool of this.workerPools.values()) {
442
483
  workerPool.destroy();
443
484
  }
485
+ this.workerPools = new Map();
444
486
  }
445
487
  setProps(props) {
446
488
  this.props = { ...this.props, ...props };
@@ -500,7 +542,7 @@
500
542
  var init_get_worker_url = __esm({
501
543
  "../worker-utils/src/lib/worker-api/get-worker-url.ts"() {
502
544
  init_assert2();
503
- NPM_TAG = "latest";
545
+ NPM_TAG = "beta";
504
546
  }
505
547
  });
506
548
 
@@ -524,6 +566,7 @@
524
566
  var init_src = __esm({
525
567
  "../worker-utils/src/index.ts"() {
526
568
  init_assert2();
569
+ init_globals2();
527
570
  init_worker_farm();
528
571
  init_get_worker_url();
529
572
  init_validate_worker_version();
@@ -535,6 +578,9 @@
535
578
  if (!WorkerFarm.isSupported()) {
536
579
  return false;
537
580
  }
581
+ if (!isBrowser2 && !options?._nodeWorkers) {
582
+ return false;
583
+ }
538
584
  return loader.worker && options?.worker;
539
585
  }
540
586
  async function parseWithWorker(loader, data, options, context, parseOnMainThread) {
@@ -576,6 +622,7 @@
576
622
  var init_parse_with_worker = __esm({
577
623
  "../loader-utils/src/lib/worker-loader-utils/parse-with-worker.ts"() {
578
624
  init_src();
625
+ init_src();
579
626
  }
580
627
  });
581
628
 
@@ -746,7 +793,7 @@
746
793
  }
747
794
  });
748
795
 
749
- // ../loader-utils/node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js
796
+ // ../../node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js
750
797
  function getHiResTimestamp() {
751
798
  let timestamp;
752
799
  if (typeof window !== "undefined" && window.performance) {
@@ -760,14 +807,14 @@
760
807
  return timestamp;
761
808
  }
762
809
  var init_hi_res_timestamp = __esm({
763
- "../loader-utils/node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js"() {
810
+ "../../node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js"() {
764
811
  }
765
812
  });
766
813
 
767
- // ../loader-utils/node_modules/@probe.gl/stats/dist/esm/lib/stat.js
814
+ // ../../node_modules/@probe.gl/stats/dist/esm/lib/stat.js
768
815
  var Stat;
769
816
  var init_stat = __esm({
770
- "../loader-utils/node_modules/@probe.gl/stats/dist/esm/lib/stat.js"() {
817
+ "../../node_modules/@probe.gl/stats/dist/esm/lib/stat.js"() {
771
818
  init_defineProperty();
772
819
  init_hi_res_timestamp();
773
820
  Stat = class {
@@ -883,10 +930,10 @@
883
930
  }
884
931
  });
885
932
 
886
- // ../loader-utils/node_modules/@probe.gl/stats/dist/esm/lib/stats.js
933
+ // ../../node_modules/@probe.gl/stats/dist/esm/lib/stats.js
887
934
  var Stats;
888
935
  var init_stats = __esm({
889
- "../loader-utils/node_modules/@probe.gl/stats/dist/esm/lib/stats.js"() {
936
+ "../../node_modules/@probe.gl/stats/dist/esm/lib/stats.js"() {
890
937
  init_defineProperty();
891
938
  init_stat();
892
939
  Stats = class {
@@ -956,9 +1003,9 @@
956
1003
  }
957
1004
  });
958
1005
 
959
- // ../loader-utils/node_modules/@probe.gl/stats/dist/esm/index.js
1006
+ // ../../node_modules/@probe.gl/stats/dist/esm/index.js
960
1007
  var init_esm = __esm({
961
- "../loader-utils/node_modules/@probe.gl/stats/dist/esm/index.js"() {
1008
+ "../../node_modules/@probe.gl/stats/dist/esm/index.js"() {
962
1009
  init_stats();
963
1010
  init_stat();
964
1011
  init_hi_res_timestamp();
@@ -2025,29 +2072,29 @@
2025
2072
  }
2026
2073
  });
2027
2074
 
2028
- // ../../node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js
2075
+ // ../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js
2029
2076
  var init_hi_res_timestamp3 = __esm({
2030
- "../../node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js"() {
2077
+ "../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js"() {
2031
2078
  }
2032
2079
  });
2033
2080
 
2034
- // ../../node_modules/@probe.gl/stats/dist/esm/lib/stat.js
2081
+ // ../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/lib/stat.js
2035
2082
  var init_stat2 = __esm({
2036
- "../../node_modules/@probe.gl/stats/dist/esm/lib/stat.js"() {
2083
+ "../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/lib/stat.js"() {
2037
2084
  init_hi_res_timestamp3();
2038
2085
  }
2039
2086
  });
2040
2087
 
2041
- // ../../node_modules/@probe.gl/stats/dist/esm/lib/stats.js
2088
+ // ../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/lib/stats.js
2042
2089
  var init_stats2 = __esm({
2043
- "../../node_modules/@probe.gl/stats/dist/esm/lib/stats.js"() {
2090
+ "../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/lib/stats.js"() {
2044
2091
  init_stat2();
2045
2092
  }
2046
2093
  });
2047
2094
 
2048
- // ../../node_modules/@probe.gl/stats/dist/esm/index.js
2095
+ // ../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/index.js
2049
2096
  var init_esm2 = __esm({
2050
- "../../node_modules/@probe.gl/stats/dist/esm/index.js"() {
2097
+ "../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/index.js"() {
2051
2098
  init_stats2();
2052
2099
  init_stat2();
2053
2100
  init_hi_res_timestamp3();
@@ -2115,6 +2162,7 @@
2115
2162
  var DEFAULT_LOADER_OPTIONS, REMOVED_LOADER_OPTIONS;
2116
2163
  var init_option_defaults = __esm({
2117
2164
  "src/lib/loader-utils/option-defaults.ts"() {
2165
+ init_src2();
2118
2166
  init_loggers();
2119
2167
  DEFAULT_LOADER_OPTIONS = {
2120
2168
  fetch: null,
@@ -2125,7 +2173,8 @@
2125
2173
  worker: true,
2126
2174
  maxConcurrency: 3,
2127
2175
  maxMobileConcurrency: 1,
2128
- reuseWorkers: true,
2176
+ reuseWorkers: isBrowser,
2177
+ _nodeWorkers: false,
2129
2178
  _workerType: "",
2130
2179
  limit: 0,
2131
2180
  _limitMB: 0,
@@ -2353,6 +2402,638 @@
2353
2402
  }
2354
2403
  });
2355
2404
 
2405
+ // ../../node_modules/@probe.gl/env/dist/esm/lib/is-electron.js
2406
+ function isElectron2(mockUserAgent) {
2407
+ if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
2408
+ return true;
2409
+ }
2410
+ if (typeof process !== "undefined" && typeof process.versions === "object" && Boolean(process.versions.electron)) {
2411
+ return true;
2412
+ }
2413
+ const realUserAgent = typeof navigator === "object" && typeof navigator.userAgent === "string" && navigator.userAgent;
2414
+ const userAgent = mockUserAgent || realUserAgent;
2415
+ if (userAgent && userAgent.indexOf("Electron") >= 0) {
2416
+ return true;
2417
+ }
2418
+ return false;
2419
+ }
2420
+ var init_is_electron2 = __esm({
2421
+ "../../node_modules/@probe.gl/env/dist/esm/lib/is-electron.js"() {
2422
+ }
2423
+ });
2424
+
2425
+ // ../../node_modules/@probe.gl/env/dist/esm/lib/is-browser.js
2426
+ function isBrowser5() {
2427
+ const isNode = typeof process === "object" && String(process) === "[object process]" && !process.browser;
2428
+ return !isNode || isElectron2();
2429
+ }
2430
+ var init_is_browser2 = __esm({
2431
+ "../../node_modules/@probe.gl/env/dist/esm/lib/is-browser.js"() {
2432
+ init_is_electron2();
2433
+ }
2434
+ });
2435
+
2436
+ // ../../node_modules/@probe.gl/env/dist/esm/lib/globals.js
2437
+ var globals4, self_4, window_4, document_4, process_2;
2438
+ var init_globals5 = __esm({
2439
+ "../../node_modules/@probe.gl/env/dist/esm/lib/globals.js"() {
2440
+ globals4 = {
2441
+ self: typeof self !== "undefined" && self,
2442
+ window: typeof window !== "undefined" && window,
2443
+ global: typeof global !== "undefined" && global,
2444
+ document: typeof document !== "undefined" && document,
2445
+ process: typeof process === "object" && process
2446
+ };
2447
+ self_4 = globals4.self || globals4.window || globals4.global;
2448
+ window_4 = globals4.window || globals4.self || globals4.global;
2449
+ document_4 = globals4.document || {};
2450
+ process_2 = globals4.process || {};
2451
+ }
2452
+ });
2453
+
2454
+ // ../../node_modules/@probe.gl/env/dist/esm/utils/globals.js
2455
+ var VERSION4, isBrowser6;
2456
+ var init_globals6 = __esm({
2457
+ "../../node_modules/@probe.gl/env/dist/esm/utils/globals.js"() {
2458
+ init_is_browser2();
2459
+ VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
2460
+ isBrowser6 = isBrowser5();
2461
+ }
2462
+ });
2463
+
2464
+ // ../../node_modules/@probe.gl/env/dist/esm/index.js
2465
+ var init_esm4 = __esm({
2466
+ "../../node_modules/@probe.gl/env/dist/esm/index.js"() {
2467
+ init_globals6();
2468
+ init_globals5();
2469
+ init_is_browser2();
2470
+ }
2471
+ });
2472
+
2473
+ // ../../node_modules/@probe.gl/log/dist/esm/utils/local-storage.js
2474
+ function getStorage2(type) {
2475
+ try {
2476
+ const storage = window[type];
2477
+ const x = "__storage_test__";
2478
+ storage.setItem(x, x);
2479
+ storage.removeItem(x);
2480
+ return storage;
2481
+ } catch (e) {
2482
+ return null;
2483
+ }
2484
+ }
2485
+ var LocalStorage2;
2486
+ var init_local_storage2 = __esm({
2487
+ "../../node_modules/@probe.gl/log/dist/esm/utils/local-storage.js"() {
2488
+ init_defineProperty();
2489
+ LocalStorage2 = class {
2490
+ constructor(id) {
2491
+ let defaultSettings = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
2492
+ let type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "sessionStorage";
2493
+ _defineProperty(this, "storage", void 0);
2494
+ _defineProperty(this, "id", void 0);
2495
+ _defineProperty(this, "config", {});
2496
+ this.storage = getStorage2(type);
2497
+ this.id = id;
2498
+ this.config = {};
2499
+ Object.assign(this.config, defaultSettings);
2500
+ this._loadConfiguration();
2501
+ }
2502
+ getConfiguration() {
2503
+ return this.config;
2504
+ }
2505
+ setConfiguration(configuration) {
2506
+ this.config = {};
2507
+ return this.updateConfiguration(configuration);
2508
+ }
2509
+ updateConfiguration(configuration) {
2510
+ Object.assign(this.config, configuration);
2511
+ if (this.storage) {
2512
+ const serialized = JSON.stringify(this.config);
2513
+ this.storage.setItem(this.id, serialized);
2514
+ }
2515
+ return this;
2516
+ }
2517
+ _loadConfiguration() {
2518
+ let configuration = {};
2519
+ if (this.storage) {
2520
+ const serializedConfiguration = this.storage.getItem(this.id);
2521
+ configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {};
2522
+ }
2523
+ Object.assign(this.config, configuration);
2524
+ return this;
2525
+ }
2526
+ };
2527
+ }
2528
+ });
2529
+
2530
+ // ../../node_modules/@probe.gl/log/dist/esm/utils/formatters.js
2531
+ function formatTime2(ms) {
2532
+ let formatted;
2533
+ if (ms < 10) {
2534
+ formatted = "".concat(ms.toFixed(2), "ms");
2535
+ } else if (ms < 100) {
2536
+ formatted = "".concat(ms.toFixed(1), "ms");
2537
+ } else if (ms < 1e3) {
2538
+ formatted = "".concat(ms.toFixed(0), "ms");
2539
+ } else {
2540
+ formatted = "".concat((ms / 1e3).toFixed(2), "s");
2541
+ }
2542
+ return formatted;
2543
+ }
2544
+ function leftPad2(string) {
2545
+ let length = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 8;
2546
+ const padLength = Math.max(length - string.length, 0);
2547
+ return "".concat(" ".repeat(padLength)).concat(string);
2548
+ }
2549
+ function formatImage2(image, message, scale) {
2550
+ let maxWidth = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 600;
2551
+ const imageUrl = image.src.replace(/\(/g, "%28").replace(/\)/g, "%29");
2552
+ if (image.width > maxWidth) {
2553
+ scale = Math.min(scale, maxWidth / image.width);
2554
+ }
2555
+ const width = image.width * scale;
2556
+ const height = image.height * scale;
2557
+ const style = ["font-size:1px;", "padding:".concat(Math.floor(height / 2), "px ").concat(Math.floor(width / 2), "px;"), "line-height:".concat(height, "px;"), "background:url(".concat(imageUrl, ");"), "background-size:".concat(width, "px ").concat(height, "px;"), "color:transparent;"].join("");
2558
+ return ["".concat(message, " %c+"), style];
2559
+ }
2560
+ var init_formatters2 = __esm({
2561
+ "../../node_modules/@probe.gl/log/dist/esm/utils/formatters.js"() {
2562
+ }
2563
+ });
2564
+
2565
+ // ../../node_modules/@probe.gl/log/dist/esm/utils/color.js
2566
+ function getColor2(color) {
2567
+ return typeof color === "string" ? COLOR2[color.toUpperCase()] || COLOR2.WHITE : color;
2568
+ }
2569
+ function addColor2(string, color, background) {
2570
+ if (!isBrowser5 && typeof string === "string") {
2571
+ if (color) {
2572
+ color = getColor2(color);
2573
+ string = "[".concat(color, "m").concat(string, "");
2574
+ }
2575
+ if (background) {
2576
+ color = getColor2(background);
2577
+ string = "[".concat(background + 10, "m").concat(string, "");
2578
+ }
2579
+ }
2580
+ return string;
2581
+ }
2582
+ var COLOR2;
2583
+ var init_color2 = __esm({
2584
+ "../../node_modules/@probe.gl/log/dist/esm/utils/color.js"() {
2585
+ init_esm4();
2586
+ (function(COLOR3) {
2587
+ COLOR3[COLOR3["BLACK"] = 30] = "BLACK";
2588
+ COLOR3[COLOR3["RED"] = 31] = "RED";
2589
+ COLOR3[COLOR3["GREEN"] = 32] = "GREEN";
2590
+ COLOR3[COLOR3["YELLOW"] = 33] = "YELLOW";
2591
+ COLOR3[COLOR3["BLUE"] = 34] = "BLUE";
2592
+ COLOR3[COLOR3["MAGENTA"] = 35] = "MAGENTA";
2593
+ COLOR3[COLOR3["CYAN"] = 36] = "CYAN";
2594
+ COLOR3[COLOR3["WHITE"] = 37] = "WHITE";
2595
+ COLOR3[COLOR3["BRIGHT_BLACK"] = 90] = "BRIGHT_BLACK";
2596
+ COLOR3[COLOR3["BRIGHT_RED"] = 91] = "BRIGHT_RED";
2597
+ COLOR3[COLOR3["BRIGHT_GREEN"] = 92] = "BRIGHT_GREEN";
2598
+ COLOR3[COLOR3["BRIGHT_YELLOW"] = 93] = "BRIGHT_YELLOW";
2599
+ COLOR3[COLOR3["BRIGHT_BLUE"] = 94] = "BRIGHT_BLUE";
2600
+ COLOR3[COLOR3["BRIGHT_MAGENTA"] = 95] = "BRIGHT_MAGENTA";
2601
+ COLOR3[COLOR3["BRIGHT_CYAN"] = 96] = "BRIGHT_CYAN";
2602
+ COLOR3[COLOR3["BRIGHT_WHITE"] = 97] = "BRIGHT_WHITE";
2603
+ })(COLOR2 || (COLOR2 = {}));
2604
+ }
2605
+ });
2606
+
2607
+ // ../../node_modules/@probe.gl/log/dist/esm/utils/autobind.js
2608
+ function autobind2(obj) {
2609
+ let predefined = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ["constructor"];
2610
+ const proto = Object.getPrototypeOf(obj);
2611
+ const propNames = Object.getOwnPropertyNames(proto);
2612
+ for (const key of propNames) {
2613
+ if (typeof obj[key] === "function") {
2614
+ if (!predefined.find((name) => key === name)) {
2615
+ obj[key] = obj[key].bind(obj);
2616
+ }
2617
+ }
2618
+ }
2619
+ }
2620
+ var init_autobind2 = __esm({
2621
+ "../../node_modules/@probe.gl/log/dist/esm/utils/autobind.js"() {
2622
+ }
2623
+ });
2624
+
2625
+ // ../../node_modules/@probe.gl/log/dist/esm/utils/assert.js
2626
+ function assert4(condition, message) {
2627
+ if (!condition) {
2628
+ throw new Error(message || "Assertion failed");
2629
+ }
2630
+ }
2631
+ var init_assert4 = __esm({
2632
+ "../../node_modules/@probe.gl/log/dist/esm/utils/assert.js"() {
2633
+ }
2634
+ });
2635
+
2636
+ // ../../node_modules/@probe.gl/log/dist/esm/utils/hi-res-timestamp.js
2637
+ function getHiResTimestamp4() {
2638
+ let timestamp;
2639
+ if (isBrowser5 && "performance" in window_4) {
2640
+ var _window$performance, _window$performance$n;
2641
+ timestamp = window_4 === null || window_4 === void 0 ? void 0 : (_window$performance = window_4.performance) === null || _window$performance === void 0 ? void 0 : (_window$performance$n = _window$performance.now) === null || _window$performance$n === void 0 ? void 0 : _window$performance$n.call(_window$performance);
2642
+ } else if ("hrtime" in process_2) {
2643
+ var _process$hrtime;
2644
+ const timeParts = process_2 === null || process_2 === void 0 ? void 0 : (_process$hrtime = process_2.hrtime) === null || _process$hrtime === void 0 ? void 0 : _process$hrtime.call(process_2);
2645
+ timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
2646
+ } else {
2647
+ timestamp = Date.now();
2648
+ }
2649
+ return timestamp;
2650
+ }
2651
+ var init_hi_res_timestamp4 = __esm({
2652
+ "../../node_modules/@probe.gl/log/dist/esm/utils/hi-res-timestamp.js"() {
2653
+ init_esm4();
2654
+ }
2655
+ });
2656
+
2657
+ // ../../node_modules/@probe.gl/log/dist/esm/log.js
2658
+ function noop2() {
2659
+ }
2660
+ function normalizeLogLevel2(logLevel) {
2661
+ if (!logLevel) {
2662
+ return 0;
2663
+ }
2664
+ let resolvedLevel;
2665
+ switch (typeof logLevel) {
2666
+ case "number":
2667
+ resolvedLevel = logLevel;
2668
+ break;
2669
+ case "object":
2670
+ resolvedLevel = logLevel.logLevel || logLevel.priority || 0;
2671
+ break;
2672
+ default:
2673
+ return 0;
2674
+ }
2675
+ assert4(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
2676
+ return resolvedLevel;
2677
+ }
2678
+ function normalizeArguments2(opts) {
2679
+ const {
2680
+ logLevel,
2681
+ message
2682
+ } = opts;
2683
+ opts.logLevel = normalizeLogLevel2(logLevel);
2684
+ const args = opts.args ? Array.from(opts.args) : [];
2685
+ while (args.length && args.shift() !== message) {
2686
+ }
2687
+ switch (typeof logLevel) {
2688
+ case "string":
2689
+ case "function":
2690
+ if (message !== void 0) {
2691
+ args.unshift(message);
2692
+ }
2693
+ opts.message = logLevel;
2694
+ break;
2695
+ case "object":
2696
+ Object.assign(opts, logLevel);
2697
+ break;
2698
+ default:
2699
+ }
2700
+ if (typeof opts.message === "function") {
2701
+ opts.message = opts.message();
2702
+ }
2703
+ const messageType = typeof opts.message;
2704
+ assert4(messageType === "string" || messageType === "object");
2705
+ return Object.assign(opts, {
2706
+ args
2707
+ }, opts.opts);
2708
+ }
2709
+ function decorateMessage2(id, message, opts) {
2710
+ if (typeof message === "string") {
2711
+ const time = opts.time ? leftPad2(formatTime2(opts.total)) : "";
2712
+ message = opts.time ? "".concat(id, ": ").concat(time, " ").concat(message) : "".concat(id, ": ").concat(message);
2713
+ message = addColor2(message, opts.color, opts.background);
2714
+ }
2715
+ return message;
2716
+ }
2717
+ function logImageInNode2(_ref2) {
2718
+ let {
2719
+ image,
2720
+ message = "",
2721
+ scale = 1
2722
+ } = _ref2;
2723
+ let asciify = null;
2724
+ try {
2725
+ asciify = module.require("asciify-image");
2726
+ } catch (error) {
2727
+ }
2728
+ if (asciify) {
2729
+ return () => asciify(image, {
2730
+ fit: "box",
2731
+ width: "".concat(Math.round(80 * scale), "%")
2732
+ }).then((data) => console.log(data));
2733
+ }
2734
+ return noop2;
2735
+ }
2736
+ function logImageInBrowser2(_ref3) {
2737
+ let {
2738
+ image,
2739
+ message = "",
2740
+ scale = 1
2741
+ } = _ref3;
2742
+ if (typeof image === "string") {
2743
+ const img = new Image();
2744
+ img.onload = () => {
2745
+ const args = formatImage2(img, message, scale);
2746
+ console.log(...args);
2747
+ };
2748
+ img.src = image;
2749
+ return noop2;
2750
+ }
2751
+ const element = image.nodeName || "";
2752
+ if (element.toLowerCase() === "img") {
2753
+ console.log(...formatImage2(image, message, scale));
2754
+ return noop2;
2755
+ }
2756
+ if (element.toLowerCase() === "canvas") {
2757
+ const img = new Image();
2758
+ img.onload = () => console.log(...formatImage2(img, message, scale));
2759
+ img.src = image.toDataURL();
2760
+ return noop2;
2761
+ }
2762
+ return noop2;
2763
+ }
2764
+ function getTableHeader2(table) {
2765
+ for (const key in table) {
2766
+ for (const title in table[key]) {
2767
+ return title || "untitled";
2768
+ }
2769
+ }
2770
+ return "empty";
2771
+ }
2772
+ var originalConsole2, DEFAULT_SETTINGS2, cache2, ONCE2, Log2;
2773
+ var init_log2 = __esm({
2774
+ "../../node_modules/@probe.gl/log/dist/esm/log.js"() {
2775
+ init_defineProperty();
2776
+ init_esm4();
2777
+ init_local_storage2();
2778
+ init_formatters2();
2779
+ init_color2();
2780
+ init_autobind2();
2781
+ init_assert4();
2782
+ init_hi_res_timestamp4();
2783
+ originalConsole2 = {
2784
+ debug: isBrowser5 ? console.debug || console.log : console.log,
2785
+ log: console.log,
2786
+ info: console.info,
2787
+ warn: console.warn,
2788
+ error: console.error
2789
+ };
2790
+ DEFAULT_SETTINGS2 = {
2791
+ enabled: true,
2792
+ level: 0
2793
+ };
2794
+ cache2 = {};
2795
+ ONCE2 = {
2796
+ once: true
2797
+ };
2798
+ Log2 = class {
2799
+ constructor() {
2800
+ let {
2801
+ id
2802
+ } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
2803
+ id: ""
2804
+ };
2805
+ _defineProperty(this, "id", void 0);
2806
+ _defineProperty(this, "VERSION", VERSION4);
2807
+ _defineProperty(this, "_startTs", getHiResTimestamp4());
2808
+ _defineProperty(this, "_deltaTs", getHiResTimestamp4());
2809
+ _defineProperty(this, "_storage", void 0);
2810
+ _defineProperty(this, "userData", {});
2811
+ _defineProperty(this, "LOG_THROTTLE_TIMEOUT", 0);
2812
+ this.id = id;
2813
+ this._storage = new LocalStorage2("__probe-".concat(this.id, "__"), DEFAULT_SETTINGS2);
2814
+ this.userData = {};
2815
+ this.timeStamp("".concat(this.id, " started"));
2816
+ autobind2(this);
2817
+ Object.seal(this);
2818
+ }
2819
+ set level(newLevel) {
2820
+ this.setLevel(newLevel);
2821
+ }
2822
+ get level() {
2823
+ return this.getLevel();
2824
+ }
2825
+ isEnabled() {
2826
+ return this._storage.config.enabled;
2827
+ }
2828
+ getLevel() {
2829
+ return this._storage.config.level;
2830
+ }
2831
+ getTotal() {
2832
+ return Number((getHiResTimestamp4() - this._startTs).toPrecision(10));
2833
+ }
2834
+ getDelta() {
2835
+ return Number((getHiResTimestamp4() - this._deltaTs).toPrecision(10));
2836
+ }
2837
+ set priority(newPriority) {
2838
+ this.level = newPriority;
2839
+ }
2840
+ get priority() {
2841
+ return this.level;
2842
+ }
2843
+ getPriority() {
2844
+ return this.level;
2845
+ }
2846
+ enable() {
2847
+ let enabled = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
2848
+ this._storage.updateConfiguration({
2849
+ enabled
2850
+ });
2851
+ return this;
2852
+ }
2853
+ setLevel(level) {
2854
+ this._storage.updateConfiguration({
2855
+ level
2856
+ });
2857
+ return this;
2858
+ }
2859
+ get(setting) {
2860
+ return this._storage.config[setting];
2861
+ }
2862
+ set(setting, value) {
2863
+ this._storage.updateConfiguration({
2864
+ [setting]: value
2865
+ });
2866
+ }
2867
+ settings() {
2868
+ if (console.table) {
2869
+ console.table(this._storage.config);
2870
+ } else {
2871
+ console.log(this._storage.config);
2872
+ }
2873
+ }
2874
+ assert(condition, message) {
2875
+ assert4(condition, message);
2876
+ }
2877
+ warn(message) {
2878
+ return this._getLogFunction(0, message, originalConsole2.warn, arguments, ONCE2);
2879
+ }
2880
+ error(message) {
2881
+ return this._getLogFunction(0, message, originalConsole2.error, arguments);
2882
+ }
2883
+ deprecated(oldUsage, newUsage) {
2884
+ return this.warn("`".concat(oldUsage, "` is deprecated and will be removed in a later version. Use `").concat(newUsage, "` instead"));
2885
+ }
2886
+ removed(oldUsage, newUsage) {
2887
+ return this.error("`".concat(oldUsage, "` has been removed. Use `").concat(newUsage, "` instead"));
2888
+ }
2889
+ probe(logLevel, message) {
2890
+ return this._getLogFunction(logLevel, message, originalConsole2.log, arguments, {
2891
+ time: true,
2892
+ once: true
2893
+ });
2894
+ }
2895
+ log(logLevel, message) {
2896
+ return this._getLogFunction(logLevel, message, originalConsole2.debug, arguments);
2897
+ }
2898
+ info(logLevel, message) {
2899
+ return this._getLogFunction(logLevel, message, console.info, arguments);
2900
+ }
2901
+ once(logLevel, message) {
2902
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
2903
+ args[_key - 2] = arguments[_key];
2904
+ }
2905
+ return this._getLogFunction(logLevel, message, originalConsole2.debug || originalConsole2.info, arguments, ONCE2);
2906
+ }
2907
+ table(logLevel, table, columns) {
2908
+ if (table) {
2909
+ return this._getLogFunction(logLevel, table, console.table || noop2, columns && [columns], {
2910
+ tag: getTableHeader2(table)
2911
+ });
2912
+ }
2913
+ return noop2;
2914
+ }
2915
+ image(_ref) {
2916
+ let {
2917
+ logLevel,
2918
+ priority,
2919
+ image,
2920
+ message = "",
2921
+ scale = 1
2922
+ } = _ref;
2923
+ if (!this._shouldLog(logLevel || priority)) {
2924
+ return noop2;
2925
+ }
2926
+ return isBrowser5 ? logImageInBrowser2({
2927
+ image,
2928
+ message,
2929
+ scale
2930
+ }) : logImageInNode2({
2931
+ image,
2932
+ message,
2933
+ scale
2934
+ });
2935
+ }
2936
+ time(logLevel, message) {
2937
+ return this._getLogFunction(logLevel, message, console.time ? console.time : console.info);
2938
+ }
2939
+ timeEnd(logLevel, message) {
2940
+ return this._getLogFunction(logLevel, message, console.timeEnd ? console.timeEnd : console.info);
2941
+ }
2942
+ timeStamp(logLevel, message) {
2943
+ return this._getLogFunction(logLevel, message, console.timeStamp || noop2);
2944
+ }
2945
+ group(logLevel, message) {
2946
+ let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
2947
+ collapsed: false
2948
+ };
2949
+ const options = normalizeArguments2({
2950
+ logLevel,
2951
+ message,
2952
+ opts
2953
+ });
2954
+ const {
2955
+ collapsed
2956
+ } = opts;
2957
+ options.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
2958
+ return this._getLogFunction(options);
2959
+ }
2960
+ groupCollapsed(logLevel, message) {
2961
+ let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
2962
+ return this.group(logLevel, message, Object.assign({}, opts, {
2963
+ collapsed: true
2964
+ }));
2965
+ }
2966
+ groupEnd(logLevel) {
2967
+ return this._getLogFunction(logLevel, "", console.groupEnd || noop2);
2968
+ }
2969
+ withGroup(logLevel, message, func) {
2970
+ this.group(logLevel, message)();
2971
+ try {
2972
+ func();
2973
+ } finally {
2974
+ this.groupEnd(logLevel)();
2975
+ }
2976
+ }
2977
+ trace() {
2978
+ if (console.trace) {
2979
+ console.trace();
2980
+ }
2981
+ }
2982
+ _shouldLog(logLevel) {
2983
+ return this.isEnabled() && this.getLevel() >= normalizeLogLevel2(logLevel);
2984
+ }
2985
+ _getLogFunction(logLevel, message, method, args, opts) {
2986
+ if (this._shouldLog(logLevel)) {
2987
+ opts = normalizeArguments2({
2988
+ logLevel,
2989
+ message,
2990
+ args,
2991
+ opts
2992
+ });
2993
+ method = method || opts.method;
2994
+ assert4(method);
2995
+ opts.total = this.getTotal();
2996
+ opts.delta = this.getDelta();
2997
+ this._deltaTs = getHiResTimestamp4();
2998
+ const tag = opts.tag || opts.message;
2999
+ if (opts.once) {
3000
+ if (!cache2[tag]) {
3001
+ cache2[tag] = getHiResTimestamp4();
3002
+ } else {
3003
+ return noop2;
3004
+ }
3005
+ }
3006
+ message = decorateMessage2(this.id, opts.message, opts);
3007
+ return method.bind(console, message, ...opts.args);
3008
+ }
3009
+ return noop2;
3010
+ }
3011
+ };
3012
+ _defineProperty(Log2, "VERSION", VERSION4);
3013
+ }
3014
+ });
3015
+
3016
+ // ../../node_modules/@probe.gl/log/dist/esm/index.js
3017
+ var esm_default2;
3018
+ var init_esm5 = __esm({
3019
+ "../../node_modules/@probe.gl/log/dist/esm/index.js"() {
3020
+ init_log2();
3021
+ init_log2();
3022
+ esm_default2 = new Log2({
3023
+ id: "@probe.gl/log"
3024
+ });
3025
+ }
3026
+ });
3027
+
3028
+ // src/lib/utils/log.ts
3029
+ var log;
3030
+ var init_log3 = __esm({
3031
+ "src/lib/utils/log.ts"() {
3032
+ init_esm5();
3033
+ log = new Log2({ id: "loaders.gl" });
3034
+ }
3035
+ });
3036
+
2356
3037
  // src/lib/api/select-loader.ts
2357
3038
  async function selectLoader(data, loaders = [], options, context) {
2358
3039
  if (!validHTTPResponse(data)) {
@@ -2396,13 +3077,22 @@
2396
3077
  const { url, type } = getResourceUrlAndType(data);
2397
3078
  const testUrl = url || context?.url;
2398
3079
  let loader = null;
3080
+ let reason = "";
2399
3081
  if (options?.mimeType) {
2400
3082
  loader = findLoaderByMIMEType(loaders, options?.mimeType);
3083
+ reason = `match forced by supplied MIME type ${options?.mimeType}`;
2401
3084
  }
2402
3085
  loader = loader || findLoaderByUrl(loaders, testUrl);
3086
+ reason = reason || (loader ? `matched url ${testUrl}` : "");
2403
3087
  loader = loader || findLoaderByMIMEType(loaders, type);
3088
+ reason = reason || (loader ? `matched MIME type ${type}` : "");
2404
3089
  loader = loader || findLoaderByInitialBytes(loaders, data);
3090
+ reason = reason || (loader ? `matched initial data ${getFirstCharacters(data)}` : "");
2405
3091
  loader = loader || findLoaderByMIMEType(loaders, options?.fallbackMimeType);
3092
+ reason = reason || (loader ? `matched fallback MIME type ${type}` : "");
3093
+ if (reason) {
3094
+ log.log(1, `selectLoader selected ${loader?.name}: ${reason}.`);
3095
+ }
2406
3096
  return loader;
2407
3097
  }
2408
3098
  function validHTTPResponse(data) {
@@ -2529,6 +3219,7 @@
2529
3219
  "src/lib/api/select-loader.ts"() {
2530
3220
  init_src2();
2531
3221
  init_normalize_loader();
3222
+ init_log3();
2532
3223
  init_resource_utils();
2533
3224
  init_register_loaders();
2534
3225
  init_is_type();
@@ -3148,15 +3839,15 @@
3148
3839
  });
3149
3840
 
3150
3841
  // src/null-loader.ts
3151
- var VERSION4, NullWorkerLoader, NullLoader;
3842
+ var VERSION5, NullWorkerLoader, NullLoader;
3152
3843
  var init_null_loader = __esm({
3153
3844
  "src/null-loader.ts"() {
3154
- VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3845
+ VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3155
3846
  NullWorkerLoader = {
3156
3847
  name: "Null loader",
3157
3848
  id: "null",
3158
3849
  module: "core",
3159
- version: VERSION4,
3850
+ version: VERSION5,
3160
3851
  worker: true,
3161
3852
  mimeTypes: ["application/x.empty"],
3162
3853
  extensions: ["null"],
@@ -3169,7 +3860,7 @@
3169
3860
  name: "Null loader",
3170
3861
  id: "null",
3171
3862
  module: "core",
3172
- version: VERSION4,
3863
+ version: VERSION5,
3173
3864
  mimeTypes: ["application/x.empty"],
3174
3865
  extensions: ["null"],
3175
3866
  parse: async (arrayBuffer) => arrayBuffer,