@loaders.gl/core 4.0.0-beta.3 → 4.0.0-beta.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"write-file-browser.js","names":[],"sources":["../../src/core-addons/write-file-browser.ts"],"sourcesContent":["// A browser implementation of the Node.js `fs` module's `fs.writeFile` method.\n// NOTE: WAS COMMENTED OUT TO GET NODE 8 TESTS RUNNING\n\n/*\n/* global global *\n/* global Blob *\nimport {isBrowser} from '@loaders.gl/core';\n\n// TODO hack - trick filesaver.js to skip loading under node\nconst savedNavigatorExists = 'navigator' in global;\nconst savedNavigator = global.navigator;\nif (!isBrowser) {\n global.navigator = {userAgent: 'MSIE 9.'};\n}\n\n// Need to use `require` to ensure our modification of global code above happens first\nconst saveAs = require('filesaver.js');\n\nif (!isBrowser) {\n if (savedNavigatorExists) {\n global.navigator = savedNavigator;\n } else {\n delete global.navigator;\n }\n}\n// END hack\n\n/**\n * File system write function for the browser, similar to Node's fs.writeFile\n *\n * Saves a file by downloading it with the given file name.\n *\n * @param {String} file - file name\n * @param {String|Blob} data - data to be written to file\n * @param {String|Object} options -\n * @param {Function} callback - Standard node (err, data) callback\n * @return {Promise} - promise, can be used instead of callback\n *\nasync export function writeFile(file, data, options, callback = () => {}) {\n // options is optional\n if (callback === undefined && typeof options === 'function') {\n options = undefined;\n callback = options;\n }\n if (typeof data === 'string') {\n data = new Blob(data);\n }\n return new Promise((resolve, reject) => {\n let result;\n try {\n result = saveAs(data, file, options);\n } catch (error) {\n reject(error);\n return callback(error, null);\n }\n resolve();\n return callback(null, result);\n });\n}\n*/\n"],"mappings":""}
1
+ {"version":3,"file":"write-file-browser.js","names":[],"sources":["../../src/core-addons/write-file-browser.ts"],"sourcesContent":["// A browser implementation of the Node.js `fs` module's `fs.writeFile` method.\n// NOTE: WAS COMMENTED OUT TO GET NODE 8 TESTS RUNNING\n\n/*\n/* global global *\n/* global Blob *\nimport {isBrowser} from '@loaders.gl/core';\n\n// TODO hack - trick filesaver.js to skip loading under node\nconst savedNavigatorExists = 'navigator' in global;\nconst savedNavigator = globalThis.navigator;\nif (!isBrowser) {\n globalThis.navigator = {userAgent: 'MSIE 9.'};\n}\n\n// Need to use `require` to ensure our modification of global code above happens first\nconst saveAs = require('filesaver.js');\n\nif (!isBrowser) {\n if (savedNavigatorExists) {\n globalThis.navigator = savedNavigator;\n } else {\n delete globalThis.navigator;\n }\n}\n// END hack\n\n/**\n * File system write function for the browser, similar to Node's fs.writeFile\n *\n * Saves a file by downloading it with the given file name.\n *\n * @param {String} file - file name\n * @param {String|Blob} data - data to be written to file\n * @param {String|Object} options -\n * @param {Function} callback - Standard node (err, data) callback\n * @return {Promise} - promise, can be used instead of callback\n *\nasync export function writeFile(file, data, options, callback = () => {}) {\n // options is optional\n if (callback === undefined && typeof options === 'function') {\n options = undefined;\n callback = options;\n }\n if (typeof data === 'string') {\n data = new Blob(data);\n }\n return new Promise((resolve, reject) => {\n let result;\n try {\n result = saveAs(data, file, options);\n } catch (error) {\n reject(error);\n return callback(error, null);\n }\n resolve();\n return callback(null, result);\n });\n}\n*/\n"],"mappings":""}
package/dist/dist.dev.js CHANGED
@@ -101,10 +101,7 @@ var __exports__ = (() => {
101
101
  var window_ = globals.window || globals.self || globals.global || {};
102
102
  var global_ = globals.global || globals.self || globals.window || {};
103
103
  var document_ = globals.document || {};
104
- var isBrowser = (
105
- // @ts-ignore process does not exist on browser
106
- Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser)
107
- );
104
+ var isBrowser = Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser);
108
105
  var isWorker = typeof importScripts === "function";
109
106
  var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
110
107
  var nodeVersion = matches && parseFloat(matches[1]) || 0;
@@ -161,10 +158,7 @@ var __exports__ = (() => {
161
158
  var window_2 = globals2.window || globals2.self || globals2.global || {};
162
159
  var global_2 = globals2.global || globals2.self || globals2.window || {};
163
160
  var document_2 = globals2.document || {};
164
- var isBrowser2 = (
165
- // @ts-ignore process.browser
166
- typeof process !== "object" || String(process) !== "[object process]" || process.browser
167
- );
161
+ var isBrowser2 = typeof process !== "object" || String(process) !== "[object process]" || process.browser;
168
162
  var isMobile = typeof window !== "undefined" && typeof window.orientation !== "undefined";
169
163
  var matches2 = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
170
164
  var nodeVersion2 = matches2 && parseFloat(matches2[1]) || 0;
@@ -172,7 +166,6 @@ var __exports__ = (() => {
172
166
  // ../worker-utils/src/lib/worker-farm/worker-job.ts
173
167
  var WorkerJob = class {
174
168
  isRunning = true;
175
- /** Promise that resolves when Job is done */
176
169
  _resolve = () => {
177
170
  };
178
171
  _reject = () => {
@@ -185,29 +178,18 @@ var __exports__ = (() => {
185
178
  this._reject = reject;
186
179
  });
187
180
  }
188
- /**
189
- * Send a message to the job's worker thread
190
- * @param data any data structure, ideally consisting mostly of transferrable objects
191
- */
192
181
  postMessage(type, payload) {
193
182
  this.workerThread.postMessage({
194
183
  source: "loaders.gl",
195
- // Lets worker ignore unrelated messages
196
184
  type,
197
185
  payload
198
186
  });
199
187
  }
200
- /**
201
- * Call to resolve the `result` Promise with the supplied value
202
- */
203
188
  done(value) {
204
189
  assert2(this.isRunning);
205
190
  this.isRunning = false;
206
191
  this._resolve(value);
207
192
  }
208
- /**
209
- * Call to reject the `result` Promise with the supplied error
210
- */
211
193
  error(error) {
212
194
  assert2(this.isRunning);
213
195
  this.isRunning = false;
@@ -318,7 +300,6 @@ var __exports__ = (() => {
318
300
  var WorkerThread = class {
319
301
  terminated = false;
320
302
  _loadableURL = "";
321
- /** Checks if workers are supported on this platform */
322
303
  static isSupported() {
323
304
  return typeof Worker !== "undefined" && isBrowser2 || typeof Worker2 !== "undefined" && !isBrowser2;
324
305
  }
@@ -336,10 +317,6 @@ var __exports__ = (() => {
336
317
  this.onError = (error) => console.log(error);
337
318
  this.worker = isBrowser2 ? this._createBrowserWorker() : this._createNodeWorker();
338
319
  }
339
- /**
340
- * Terminate this worker thread
341
- * @note Can free up significant memory
342
- */
343
320
  destroy() {
344
321
  this.onMessage = NOOP;
345
322
  this.onError = NOOP;
@@ -349,20 +326,10 @@ var __exports__ = (() => {
349
326
  get isRunning() {
350
327
  return Boolean(this.onMessage);
351
328
  }
352
- /**
353
- * Send a message to this worker thread
354
- * @param data any data structure, ideally consisting mostly of transferrable objects
355
- * @param transferList If not supplied, calculated automatically by traversing data
356
- */
357
329
  postMessage(data, transferList) {
358
330
  transferList = transferList || getTransferList(data);
359
331
  this.worker.postMessage(data, transferList);
360
332
  }
361
- // PRIVATE
362
- /**
363
- * Generate a standard Error from an ErrorEvent
364
- * @param event
365
- */
366
333
  _getErrorFromErrorEvent(event) {
367
334
  let message = "Failed to load ";
368
335
  message += `worker ${this.name} from ${this.url}. `;
@@ -374,9 +341,6 @@ var __exports__ = (() => {
374
341
  }
375
342
  return new Error(message);
376
343
  }
377
- /**
378
- * Creates a worker thread on the browser
379
- */
380
344
  _createBrowserWorker() {
381
345
  this._loadableURL = getLoadableWorkerURL({
382
346
  source: this.source,
@@ -399,10 +363,6 @@ var __exports__ = (() => {
399
363
  worker.onmessageerror = (event) => console.error(event);
400
364
  return worker;
401
365
  }
402
- /**
403
- * Creates a worker thread in node.js
404
- * @todo https://nodejs.org/api/async_hooks.html#async-resource-worker-pool
405
- */
406
366
  _createNodeWorker() {
407
367
  let worker;
408
368
  if (this.url) {
@@ -433,7 +393,6 @@ var __exports__ = (() => {
433
393
  // ../worker-utils/src/lib/worker-farm/worker-pool.ts
434
394
  var WorkerPool = class {
435
395
  name = "unnamed";
436
- // | Function;
437
396
  maxConcurrency = 1;
438
397
  maxMobileConcurrency = 1;
439
398
  onDebug = () => {
@@ -444,23 +403,14 @@ var __exports__ = (() => {
444
403
  idleQueue = [];
445
404
  count = 0;
446
405
  isDestroyed = false;
447
- /** Checks if workers are supported on this platform */
448
406
  static isSupported() {
449
407
  return WorkerThread.isSupported();
450
408
  }
451
- /**
452
- * @param processor - worker function
453
- * @param maxConcurrency - max count of workers
454
- */
455
409
  constructor(props) {
456
410
  this.source = props.source;
457
411
  this.url = props.url;
458
412
  this.setProps(props);
459
413
  }
460
- /**
461
- * Terminates all workers in the pool
462
- * @note Can free up significant memory
463
- */
464
414
  destroy() {
465
415
  this.idleQueue.forEach((worker) => worker.destroy());
466
416
  this.isDestroyed = true;
@@ -499,11 +449,6 @@ var __exports__ = (() => {
499
449
  this._startQueuedJob();
500
450
  return await startPromise;
501
451
  }
502
- // PRIVATE
503
- /**
504
- * Starts first queued job if worker is available or can be created
505
- * Called when job is started and whenever a worker returns to the idleQueue
506
- */
507
452
  async _startQueuedJob() {
508
453
  if (!this.jobQueue.length) {
509
454
  return;
@@ -533,23 +478,8 @@ var __exports__ = (() => {
533
478
  }
534
479
  }
535
480
  }
536
- /**
537
- * Returns a worker to the idle queue
538
- * Destroys the worker if
539
- * - pool is destroyed
540
- * - if this pool doesn't reuse workers
541
- * - if maxConcurrency has been lowered
542
- * @param worker
543
- */
544
481
  returnWorkerToQueue(worker) {
545
- const shouldDestroyWorker = (
546
- // Workers on Node.js prevent the process from exiting.
547
- // Until we figure out how to close them before exit, we always destroy them
548
- !isBrowser2 || // If the pool is destroyed, there is no reason to keep the worker around
549
- this.isDestroyed || // If the app has disabled worker reuse, any completed workers should be destroyed
550
- !this.reuseWorkers || // If concurrency has been lowered, this worker might be surplus to requirements
551
- this.count > this._getMaxConcurrency()
552
- );
482
+ const shouldDestroyWorker = !isBrowser2 || this.isDestroyed || !this.reuseWorkers || this.count > this._getMaxConcurrency();
553
483
  if (shouldDestroyWorker) {
554
484
  worker.destroy();
555
485
  this.count--;
@@ -560,9 +490,6 @@ var __exports__ = (() => {
560
490
  this._startQueuedJob();
561
491
  }
562
492
  }
563
- /**
564
- * Returns idle worker or creates new worker if maxConcurrency has not been reached
565
- */
566
493
  _getAvailableWorker() {
567
494
  if (this.idleQueue.length > 0) {
568
495
  return this.idleQueue.shift() || null;
@@ -593,18 +520,14 @@ var __exports__ = (() => {
593
520
  };
594
521
  var WorkerFarm = class {
595
522
  workerPools = /* @__PURE__ */ new Map();
596
- // singleton
597
- /** Checks if workers are supported on this platform */
598
523
  static isSupported() {
599
524
  return WorkerThread.isSupported();
600
525
  }
601
- /** Get the singleton instance of the global worker farm */
602
526
  static getWorkerFarm(props = {}) {
603
527
  WorkerFarm._workerFarm = WorkerFarm._workerFarm || new WorkerFarm({});
604
528
  WorkerFarm._workerFarm.setProps(props);
605
529
  return WorkerFarm._workerFarm;
606
530
  }
607
- /** get global instance with WorkerFarm.getWorkerFarm() */
608
531
  constructor(props) {
609
532
  this.props = {
610
533
  ...DEFAULT_PROPS
@@ -612,20 +535,12 @@ var __exports__ = (() => {
612
535
  this.setProps(props);
613
536
  this.workerPools = /* @__PURE__ */ new Map();
614
537
  }
615
- /**
616
- * Terminate all workers in the farm
617
- * @note Can free up significant memory
618
- */
619
538
  destroy() {
620
539
  for (const workerPool of this.workerPools.values()) {
621
540
  workerPool.destroy();
622
541
  }
623
542
  this.workerPools = /* @__PURE__ */ new Map();
624
543
  }
625
- /**
626
- * Set props used when initializing worker pools
627
- * @param props
628
- */
629
544
  setProps(props) {
630
545
  this.props = {
631
546
  ...this.props,
@@ -635,15 +550,6 @@ var __exports__ = (() => {
635
550
  workerPool.setProps(this._getWorkerPoolProps());
636
551
  }
637
552
  }
638
- /**
639
- * Returns a worker pool for the specified worker
640
- * @param options - only used first time for a specific worker name
641
- * @param options.name - the name of the worker - used to identify worker pool
642
- * @param options.url -
643
- * @param options.source -
644
- * @example
645
- * const job = WorkerFarm.getWorkerFarm().getWorkerPool({name, url}).startJob(...);
646
- */
647
553
  getWorkerPool(options) {
648
554
  const {
649
555
  name,
@@ -715,11 +621,7 @@ var __exports__ = (() => {
715
621
  }
716
622
  const workerPool = workerFarm.getWorkerPool(workerPoolProps);
717
623
  const jobName = options.jobName || worker.name;
718
- const job = await workerPool.startJob(
719
- jobName,
720
- // eslint-disable-next-line
721
- onMessage.bind(null, context)
722
- );
624
+ const job = await workerPool.startJob(jobName, onMessage.bind(null, context));
723
625
  const transferableOptions = getTransferListForWriter(options);
724
626
  job.postMessage("process", {
725
627
  input: data,
@@ -798,14 +700,8 @@ var __exports__ = (() => {
798
700
  });
799
701
  options = JSON.parse(JSON.stringify(options));
800
702
  context = JSON.parse(JSON.stringify(context || {}));
801
- const job = await workerPool.startJob(
802
- "process-on-worker",
803
- // @ts-expect-error
804
- onMessage2.bind(null, parseOnMainThread)
805
- // eslint-disable-line @typescript-eslint/no-misused-promises
806
- );
703
+ const job = await workerPool.startJob("process-on-worker", onMessage2.bind(null, parseOnMainThread));
807
704
  job.postMessage("process", {
808
- // @ts-ignore
809
705
  input: data,
810
706
  options,
811
707
  context
@@ -1195,14 +1091,11 @@ var __exports__ = (() => {
1195
1091
  var STAT_ACTIVE_REQUESTS_EVER = "Active Requests Ever";
1196
1092
  var DEFAULT_PROPS2 = {
1197
1093
  id: "request-scheduler",
1198
- // Specifies if the request scheduler should throttle incoming requests, mainly for comparative testing
1199
1094
  throttleRequests: true,
1200
- // The maximum number of simultaneous active requests. Un-throttled requests do not observe this limit.
1201
1095
  maxRequests: 6
1202
1096
  };
1203
1097
  var RequestScheduler = class {
1204
1098
  activeRequestCount = 0;
1205
- /** Tracks the number of active requests and prioritizes/cancels queued requests. */
1206
1099
  requestQueue = [];
1207
1100
  requestMap = /* @__PURE__ */ new Map();
1208
1101
  deferredUpdate = null;
@@ -1220,22 +1113,6 @@ var __exports__ = (() => {
1220
1113
  this.stats.get(STAT_QUEUED_REQUESTS_EVER);
1221
1114
  this.stats.get(STAT_ACTIVE_REQUESTS_EVER);
1222
1115
  }
1223
- /**
1224
- * Called by an application that wants to issue a request, without having it deeply queued by the browser
1225
- *
1226
- * When the returned promise resolved, it is OK for the application to issue a request.
1227
- * The promise resolves to an object that contains a `done` method.
1228
- * When the application's request has completed (or failed), the application must call the `done` function
1229
- *
1230
- * @param handle
1231
- * @param getPriority will be called when request "slots" open up,
1232
- * allowing the caller to update priority or cancel the request
1233
- * Highest priority executes first, priority < 0 cancels the request
1234
- * @returns a promise
1235
- * - resolves to a object (with a `done` field) when the request can be issued without queueing,
1236
- * - resolves to `null` if the request has been cancelled (by the callback return < 0).
1237
- * In this case the application should not issue the request
1238
- */
1239
1116
  scheduleRequest(handle, getPriority = () => 0) {
1240
1117
  if (!this.props.throttleRequests) {
1241
1118
  return Promise.resolve({
@@ -1260,7 +1137,6 @@ var __exports__ = (() => {
1260
1137
  this._issueNewRequests();
1261
1138
  return promise;
1262
1139
  }
1263
- // PRIVATE
1264
1140
  _issueRequest(request) {
1265
1141
  const {
1266
1142
  handle,
@@ -1282,13 +1158,11 @@ var __exports__ = (() => {
1282
1158
  done
1283
1159
  });
1284
1160
  }
1285
- /** We check requests asynchronously, to prevent multiple updates */
1286
1161
  _issueNewRequests() {
1287
1162
  if (!this.deferredUpdate) {
1288
1163
  this.deferredUpdate = setTimeout(() => this._issueNewRequestsAsync(), 0);
1289
1164
  }
1290
1165
  }
1291
- /** Refresh all requests */
1292
1166
  _issueNewRequestsAsync() {
1293
1167
  this.deferredUpdate = null;
1294
1168
  const freeSlots = Math.max(this.props.maxRequests - this.activeRequestCount, 0);
@@ -1303,7 +1177,6 @@ var __exports__ = (() => {
1303
1177
  }
1304
1178
  }
1305
1179
  }
1306
- /** Ensure all requests have updated priorities, and that no longer valid requests are cancelled */
1307
1180
  _updateAllRequests() {
1308
1181
  const requestQueue = this.requestQueue;
1309
1182
  for (let i = 0; i < requestQueue.length; ++i) {
@@ -1316,7 +1189,6 @@ var __exports__ = (() => {
1316
1189
  }
1317
1190
  requestQueue.sort((a, b) => a.priority - b.priority);
1318
1191
  }
1319
- /** Update a single request by calling the callback */
1320
1192
  _updateRequest(request) {
1321
1193
  request.priority = request.getPriority(request.handle);
1322
1194
  if (request.priority < 0) {
@@ -1582,19 +1454,15 @@ var __exports__ = (() => {
1582
1454
  }
1583
1455
  throw new Error("Can't instantiate NodeFile. Make sure to import @loaders.gl/polyfills first.");
1584
1456
  }
1585
- /** Read data */
1586
1457
  async read(start, end) {
1587
1458
  throw NOT_IMPLEMENTED;
1588
1459
  }
1589
- /** Write to file. The number of bytes written will be returned */
1590
1460
  async write(arrayBuffer, offset, length) {
1591
1461
  throw NOT_IMPLEMENTED;
1592
1462
  }
1593
- /** Get information about file */
1594
1463
  async stat() {
1595
1464
  throw NOT_IMPLEMENTED;
1596
1465
  }
1597
- /** Close the file */
1598
1466
  async close() {
1599
1467
  }
1600
1468
  };
@@ -2387,39 +2255,29 @@ var __exports__ = (() => {
2387
2255
 
2388
2256
  // src/lib/loader-utils/option-defaults.ts
2389
2257
  var DEFAULT_LOADER_OPTIONS = {
2390
- // baseUri
2391
2258
  fetch: null,
2392
2259
  mimeType: void 0,
2393
2260
  nothrow: false,
2394
2261
  log: new ConsoleLog(),
2395
- // A probe.gl compatible (`log.log()()` syntax) that just logs to console
2396
2262
  useLocalLibraries: false,
2397
2263
  CDN: "https://unpkg.com/@loaders.gl",
2398
2264
  worker: true,
2399
- // By default, use worker if provided by loader.
2400
2265
  maxConcurrency: 3,
2401
- // How many worker instances should be created for each loader.
2402
2266
  maxMobileConcurrency: 1,
2403
- // How many worker instances should be created for each loader on mobile devices.
2404
2267
  reuseWorkers: isBrowser,
2405
- // By default reuse workers in browser (Node.js refuses to terminate if browsers are running)
2406
2268
  _nodeWorkers: false,
2407
- // By default do not support node workers
2408
2269
  _workerType: "",
2409
- // 'test' to use locally generated workers
2410
2270
  limit: 0,
2411
2271
  _limitMB: 0,
2412
2272
  batchSize: "auto",
2413
2273
  batchDebounceMs: 0,
2414
2274
  metadata: false,
2415
- // TODO - currently only implemented for parseInBatches, adds initial metadata batch,
2416
2275
  transforms: []
2417
2276
  };
2418
2277
  var REMOVED_LOADER_OPTIONS = {
2419
2278
  throws: "nothrow",
2420
2279
  dataType: "(no longer used)",
2421
2280
  uri: "baseUri",
2422
- // Warn if fetch options are used on top-level
2423
2281
  method: "fetch.method",
2424
2282
  headers: "fetch.headers",
2425
2283
  body: "fetch.body",
@@ -3048,16 +2906,11 @@ var __exports__ = (() => {
3048
2906
  return null;
3049
2907
  }
3050
2908
  options = normalizeOptions(options, loader, candidateLoaders, url);
3051
- context = getLoaderContext(
3052
- // @ts-expect-error
3053
- {
3054
- url,
3055
- _parse: parse,
3056
- loaders: candidateLoaders
3057
- },
3058
- options,
3059
- context || null
3060
- );
2909
+ context = getLoaderContext({
2910
+ url,
2911
+ _parse: parse,
2912
+ loaders: candidateLoaders
2913
+ }, options, context || null);
3061
2914
  return await parseWithLoader(loader, data, options, context);
3062
2915
  }
3063
2916
  async function parseWithLoader(loader, data, options, context) {
@@ -3175,7 +3028,6 @@ var __exports__ = (() => {
3175
3028
  _loader: loader,
3176
3029
  _context: context
3177
3030
  },
3178
- // Populate with some default fields to avoid crashing
3179
3031
  data: [],
3180
3032
  bytesUsed: 0
3181
3033
  };
@@ -3193,16 +3045,10 @@ var __exports__ = (() => {
3193
3045
  }
3194
3046
  async function* parseChunkInBatches() {
3195
3047
  const arrayBuffer = await concatenateArrayBuffersAsync(transformedIterator);
3196
- const parsedData = await parse(
3197
- arrayBuffer,
3198
- loader,
3199
- // TODO - Hack: supply loaders MIME type to ensure we match it
3200
- {
3201
- ...options,
3202
- mimeType: loader.mimeTypes[0]
3203
- },
3204
- context
3205
- );
3048
+ const parsedData = await parse(arrayBuffer, loader, {
3049
+ ...options,
3050
+ mimeType: loader.mimeTypes[0]
3051
+ }, context);
3206
3052
  const batch = {
3207
3053
  mimeType: loader.mimeTypes[0],
3208
3054
  shape: Array.isArray(parsedData) ? "row-table" : "unknown",
@@ -3414,38 +3260,30 @@ var __exports__ = (() => {
3414
3260
  return globalThis.loaders.makeNodeStream(source, options);
3415
3261
  }
3416
3262
  const iterator = source[Symbol.asyncIterator] ? source[Symbol.asyncIterator]() : source[Symbol.iterator]();
3417
- return new ReadableStream(
3418
- {
3419
- // Create a byte stream (enables `Response(stream).arrayBuffer()`)
3420
- // Only supported on Chrome
3421
- // See: https://developer.mozilla.org/en-US/docs/Web/API/ReadableByteStreamController
3422
- type: "bytes",
3423
- async pull(controller) {
3424
- try {
3425
- const {
3426
- done,
3427
- value
3428
- } = await iterator.next();
3429
- if (done) {
3430
- controller.close();
3431
- } else {
3432
- controller.enqueue(new Uint8Array(value));
3433
- }
3434
- } catch (error) {
3435
- controller.error(error);
3263
+ return new ReadableStream({
3264
+ type: "bytes",
3265
+ async pull(controller) {
3266
+ try {
3267
+ const {
3268
+ done,
3269
+ value
3270
+ } = await iterator.next();
3271
+ if (done) {
3272
+ controller.close();
3273
+ } else {
3274
+ controller.enqueue(new Uint8Array(value));
3436
3275
  }
3437
- },
3438
- async cancel() {
3439
- await iterator?.return?.();
3276
+ } catch (error) {
3277
+ controller.error(error);
3440
3278
  }
3441
3279
  },
3442
- // options: QueingStrategy<Uint8Array>
3443
- {
3444
- // This is bytes, not chunks
3445
- highWaterMark: 2 ** 24,
3446
- ...options
3280
+ async cancel() {
3281
+ await iterator?.return?.();
3447
3282
  }
3448
- );
3283
+ }, {
3284
+ highWaterMark: 2 ** 24,
3285
+ ...options
3286
+ });
3449
3287
  }
3450
3288
 
3451
3289
  // src/null-loader.ts
@@ -3544,11 +3382,6 @@ var __exports__ = (() => {
3544
3382
  files = {};
3545
3383
  lowerCaseFiles = {};
3546
3384
  usedFiles = {};
3547
- /**
3548
- * A FileSystem API wrapper around a list of browser 'File' objects
3549
- * @param files
3550
- * @param options
3551
- */
3552
3385
  constructor(files, options) {
3553
3386
  this._fetch = options?.fetch || fetch;
3554
3387
  for (let i = 0; i < files.length; ++i) {
@@ -3559,11 +3392,6 @@ var __exports__ = (() => {
3559
3392
  }
3560
3393
  this.fetch = this.fetch.bind(this);
3561
3394
  }
3562
- // implements IFileSystem
3563
- /**
3564
- * Implementation of fetch against this file system
3565
- * Delegates to global fetch for http{s}:// or data://
3566
- */
3567
3395
  async fetch(path, options) {
3568
3396
  if (path.includes("://")) {
3569
3397
  return this._fetch(path, options);
@@ -3594,11 +3422,6 @@ var __exports__ = (() => {
3594
3422
  });
3595
3423
  return response;
3596
3424
  }
3597
- /**
3598
- * List filenames in this filesystem
3599
- * @param dirname
3600
- * @returns
3601
- */
3602
3425
  async readdir(dirname2) {
3603
3426
  const files = [];
3604
3427
  for (const path in this.files) {
@@ -3606,9 +3429,6 @@ var __exports__ = (() => {
3606
3429
  }
3607
3430
  return files;
3608
3431
  }
3609
- /**
3610
- * Return information (size) about files in this file system
3611
- */
3612
3432
  async stat(path, options) {
3613
3433
  const file = this.files[path];
3614
3434
  if (!file) {
@@ -3618,21 +3438,14 @@ var __exports__ = (() => {
3618
3438
  size: file.size
3619
3439
  };
3620
3440
  }
3621
- /**
3622
- * Just removes the file from the list
3623
- */
3624
3441
  async unlink(path) {
3625
3442
  delete this.files[path];
3626
3443
  delete this.lowerCaseFiles[path];
3627
3444
  this.usedFiles[path] = true;
3628
3445
  }
3629
- // implements IRandomAccessFileSystem
3630
- // RANDOM ACCESS
3631
3446
  async openReadableFile(pathname, flags) {
3632
3447
  return new BlobFile(this.files[pathname]);
3633
3448
  }
3634
- // PRIVATE
3635
- // Supports case independent paths, and file usage tracking
3636
3449
  _getFile(path, used) {
3637
3450
  const file = this.files[path] || this.lowerCaseFiles[path];
3638
3451
  if (file && used) {
package/dist/index.cjs CHANGED
@@ -1359,6 +1359,7 @@ function makeStream(source, options) {
1359
1359
  // Create a byte stream (enables `Response(stream).arrayBuffer()`)
1360
1360
  // Only supported on Chrome
1361
1361
  // See: https://developer.mozilla.org/en-US/docs/Web/API/ReadableByteStreamController
1362
+ // @ts-ignore
1362
1363
  type: "bytes",
1363
1364
  async pull(controller) {
1364
1365
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"make-stream.d.ts","sourceRoot":"","sources":["../../../src/iterators/make-stream/make-stream.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,wEAAwE;IACxE,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,sEAAsE;IACtE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,WAAW,EACpC,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,EAC1D,OAAO,CAAC,EAAE,iBAAiB,GAC1B,cAAc,CA2ChB"}
1
+ {"version":3,"file":"make-stream.d.ts","sourceRoot":"","sources":["../../../src/iterators/make-stream/make-stream.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,wEAAwE;IACxE,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,sEAAsE;IACtE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,WAAW,EACpC,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,EAC1D,OAAO,CAAC,EAAE,iBAAiB,GAC1B,cAAc,CA4ChB"}
@@ -1 +1 @@
1
- {"version":3,"file":"make-stream.js","names":["makeStream","source","options","globalThis","loaders","makeNodeStream","iterator","Symbol","asyncIterator","ReadableStream","type","pull","controller","done","value","next","close","enqueue","Uint8Array","error","cancel","_iterator$return","return","call","highWaterMark"],"sources":["../../../src/iterators/make-stream/make-stream.ts"],"sourcesContent":["export type MakeStreamOptions = {\n /** Stream allocates an arrayBuffer. Enables use of a default reader. */\n autoAllocateChunkSize?: number;\n /** Total number of chunks in queue before back pressure is applied */\n highWaterMark?: number;\n};\n\n/**\n * Builds a DOM stream from an iterator\n * This stream is currently used in browsers only,\n * but note that Web stream support is present in Node from Node 16\n * https://nodejs.org/api/webstreams.html#webstreams_web_streams_api\n */\nexport function makeStream<ArrayBuffer>(\n source: Iterable<ArrayBuffer> | AsyncIterable<ArrayBuffer>,\n options?: MakeStreamOptions\n): ReadableStream {\n if (globalThis.loaders.makeNodeStream) {\n return globalThis.loaders.makeNodeStream(source, options);\n }\n\n // TODO - add AsyncGenerator to parameter types?\n const iterator = (source as AsyncGenerator<ArrayBuffer>)[Symbol.asyncIterator]\n ? (source as AsyncIterable<ArrayBuffer>)[Symbol.asyncIterator]()\n : (source as Iterable<ArrayBuffer>)[Symbol.iterator]();\n\n return new ReadableStream<Uint8Array>(\n {\n // Create a byte stream (enables `Response(stream).arrayBuffer()`)\n // Only supported on Chrome\n // See: https://developer.mozilla.org/en-US/docs/Web/API/ReadableByteStreamController\n type: 'bytes',\n\n async pull(controller) {\n try {\n const {done, value} = await iterator.next();\n if (done) {\n controller.close();\n } else {\n // TODO - ignores controller.desiredSize\n // @ts-expect-error Unclear why value is not correctly typed\n controller.enqueue(new Uint8Array(value));\n }\n } catch (error) {\n controller.error(error);\n }\n },\n\n async cancel() {\n await iterator?.return?.();\n }\n },\n // options: QueingStrategy<Uint8Array>\n {\n // This is bytes, not chunks\n highWaterMark: 2 ** 24,\n ...options\n }\n );\n}\n"],"mappings":"AAaA,OAAO,SAASA,UAAUA,CACxBC,MAA0D,EAC1DC,OAA2B,EACX;EAChB,IAAIC,UAAU,CAACC,OAAO,CAACC,cAAc,EAAE;IACrC,OAAOF,UAAU,CAACC,OAAO,CAACC,cAAc,CAACJ,MAAM,EAAEC,OAAO,CAAC;EAC3D;EAGA,MAAMI,QAAQ,GAAIL,MAAM,CAAiCM,MAAM,CAACC,aAAa,CAAC,GACzEP,MAAM,CAAgCM,MAAM,CAACC,aAAa,CAAC,CAAC,CAAC,GAC7DP,MAAM,CAA2BM,MAAM,CAACD,QAAQ,CAAC,CAAC,CAAC;EAExD,OAAO,IAAIG,cAAc,CACvB;IAIEC,IAAI,EAAE,OAAO;IAEb,MAAMC,IAAIA,CAACC,UAAU,EAAE;MACrB,IAAI;QACF,MAAM;UAACC,IAAI;UAAEC;QAAK,CAAC,GAAG,MAAMR,QAAQ,CAACS,IAAI,CAAC,CAAC;QAC3C,IAAIF,IAAI,EAAE;UACRD,UAAU,CAACI,KAAK,CAAC,CAAC;QACpB,CAAC,MAAM;UAGLJ,UAAU,CAACK,OAAO,CAAC,IAAIC,UAAU,CAACJ,KAAK,CAAC,CAAC;QAC3C;MACF,CAAC,CAAC,OAAOK,KAAK,EAAE;QACdP,UAAU,CAACO,KAAK,CAACA,KAAK,CAAC;MACzB;IACF,CAAC;IAED,MAAMC,MAAMA,CAAA,EAAG;MAAA,IAAAC,gBAAA;MACb,OAAMf,QAAQ,aAARA,QAAQ,wBAAAe,gBAAA,GAARf,QAAQ,CAAEgB,MAAM,cAAAD,gBAAA,uBAAhBA,gBAAA,CAAAE,IAAA,CAAAjB,QAAmB,CAAC;IAC5B;EACF,CAAC,EAED;IAEEkB,aAAa,EAAE,CAAC,IAAI,EAAE;IACtB,GAAGtB;EACL,CACF,CAAC;AACH"}
1
+ {"version":3,"file":"make-stream.js","names":["makeStream","source","options","globalThis","loaders","makeNodeStream","iterator","Symbol","asyncIterator","ReadableStream","type","pull","controller","done","value","next","close","enqueue","Uint8Array","error","cancel","_iterator$return","return","call","highWaterMark"],"sources":["../../../src/iterators/make-stream/make-stream.ts"],"sourcesContent":["export type MakeStreamOptions = {\n /** Stream allocates an arrayBuffer. Enables use of a default reader. */\n autoAllocateChunkSize?: number;\n /** Total number of chunks in queue before back pressure is applied */\n highWaterMark?: number;\n};\n\n/**\n * Builds a DOM stream from an iterator\n * This stream is currently used in browsers only,\n * but note that Web stream support is present in Node from Node 16\n * https://nodejs.org/api/webstreams.html#webstreams_web_streams_api\n */\nexport function makeStream<ArrayBuffer>(\n source: Iterable<ArrayBuffer> | AsyncIterable<ArrayBuffer>,\n options?: MakeStreamOptions\n): ReadableStream {\n if (globalThis.loaders.makeNodeStream) {\n return globalThis.loaders.makeNodeStream(source, options);\n }\n\n // TODO - add AsyncGenerator to parameter types?\n const iterator = (source as AsyncGenerator<ArrayBuffer>)[Symbol.asyncIterator]\n ? (source as AsyncIterable<ArrayBuffer>)[Symbol.asyncIterator]()\n : (source as Iterable<ArrayBuffer>)[Symbol.iterator]();\n\n return new ReadableStream<Uint8Array>(\n {\n // Create a byte stream (enables `Response(stream).arrayBuffer()`)\n // Only supported on Chrome\n // See: https://developer.mozilla.org/en-US/docs/Web/API/ReadableByteStreamController\n // @ts-ignore\n type: 'bytes',\n\n async pull(controller) {\n try {\n const {done, value} = await iterator.next();\n if (done) {\n controller.close();\n } else {\n // TODO - ignores controller.desiredSize\n // @ts-expect-error Unclear why value is not correctly typed\n controller.enqueue(new Uint8Array(value));\n }\n } catch (error) {\n controller.error(error);\n }\n },\n\n async cancel() {\n await iterator?.return?.();\n }\n },\n // options: QueingStrategy<Uint8Array>\n {\n // This is bytes, not chunks\n highWaterMark: 2 ** 24,\n ...options\n }\n );\n}\n"],"mappings":"AAaA,OAAO,SAASA,UAAUA,CACxBC,MAA0D,EAC1DC,OAA2B,EACX;EAChB,IAAIC,UAAU,CAACC,OAAO,CAACC,cAAc,EAAE;IACrC,OAAOF,UAAU,CAACC,OAAO,CAACC,cAAc,CAACJ,MAAM,EAAEC,OAAO,CAAC;EAC3D;EAGA,MAAMI,QAAQ,GAAIL,MAAM,CAAiCM,MAAM,CAACC,aAAa,CAAC,GACzEP,MAAM,CAAgCM,MAAM,CAACC,aAAa,CAAC,CAAC,CAAC,GAC7DP,MAAM,CAA2BM,MAAM,CAACD,QAAQ,CAAC,CAAC,CAAC;EAExD,OAAO,IAAIG,cAAc,CACvB;IAKEC,IAAI,EAAE,OAAO;IAEb,MAAMC,IAAIA,CAACC,UAAU,EAAE;MACrB,IAAI;QACF,MAAM;UAACC,IAAI;UAAEC;QAAK,CAAC,GAAG,MAAMR,QAAQ,CAACS,IAAI,CAAC,CAAC;QAC3C,IAAIF,IAAI,EAAE;UACRD,UAAU,CAACI,KAAK,CAAC,CAAC;QACpB,CAAC,MAAM;UAGLJ,UAAU,CAACK,OAAO,CAAC,IAAIC,UAAU,CAACJ,KAAK,CAAC,CAAC;QAC3C;MACF,CAAC,CAAC,OAAOK,KAAK,EAAE;QACdP,UAAU,CAACO,KAAK,CAACA,KAAK,CAAC;MACzB;IACF,CAAC;IAED,MAAMC,MAAMA,CAAA,EAAG;MAAA,IAAAC,gBAAA;MACb,OAAMf,QAAQ,aAARA,QAAQ,wBAAAe,gBAAA,GAARf,QAAQ,CAAEgB,MAAM,cAAAD,gBAAA,uBAAhBA,gBAAA,CAAAE,IAAA,CAAAjB,QAAmB,CAAC;IAC5B;EACF,CAAC,EAED;IAEEkB,aAAa,EAAE,CAAC,IAAI,EAAE;IACtB,GAAGtB;EACL,CACF,CAAC;AACH"}
@@ -1,6 +1,6 @@
1
1
  import type { Loader, LoaderOptions } from '@loaders.gl/loader-utils';
2
2
  /**
3
- * Global state for loaders.gl. Stored on `global.loaders._state`
3
+ * Global state for loaders.gl. Stored on `globalThis.loaders._state`
4
4
  */
5
5
  type GlobalLoaderState = {
6
6
  loaderRegistry: Loader[];
@@ -1 +1 @@
1
- {"version":3,"file":"option-utils.js","names":["isPureObject","isObject","probeLog","NullLog","DEFAULT_LOADER_OPTIONS","REMOVED_LOADER_OPTIONS","getGlobalLoaderState","globalThis","loaders","_state","getGlobalLoaderOptions","state","globalOptions","setGlobalOptions","options","normalizeOptionsInternal","normalizeOptions","loader","url","Array","isArray","validateOptions","validateOptionsObject","idOptions","id","loaderOptions","deprecatedOptions","defaultOptions","loaderName","prefix","key","isSubOptions","isBaseUriOption","isWorkerUrlOption","warn","suggestion","findSimilarOption","optionKey","lowerCaseOptionKey","toLowerCase","bestSuggestion","lowerCaseKey","isPartialMatch","startsWith","loaderDefaultOptions","mergedOptions","addUrlOptions","log","mergeNestedFields","value","baseUri"],"sources":["../../../src/lib/loader-utils/option-utils.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {isPureObject, isObject} from '../../javascript-utils/is-type';\nimport {probeLog, NullLog} from './loggers';\nimport {DEFAULT_LOADER_OPTIONS, REMOVED_LOADER_OPTIONS} from './option-defaults';\n\n/**\n * Global state for loaders.gl. Stored on `global.loaders._state`\n */\ntype GlobalLoaderState = {\n loaderRegistry: Loader[];\n globalOptions: LoaderOptions;\n};\n\n/**\n * Helper for safely accessing global loaders.gl variables\n * Wraps initialization of global variable in function to defeat overly aggressive tree-shakers\n */\nexport function getGlobalLoaderState(): GlobalLoaderState {\n // @ts-ignore\n globalThis.loaders = globalThis.loaders || {};\n // @ts-ignore\n const {loaders} = globalThis;\n\n // Add _state object to keep separate from modules added to globalThis.loaders\n loaders._state = loaders._state || {};\n return loaders._state;\n}\n\n/**\n * Store global loader options on the global object to increase chances of cross loaders-version interoperability\n * NOTE: This use case is not reliable but can help when testing new versions of loaders.gl with existing frameworks\n * @returns global loader options merged with default loader options\n */\nexport function getGlobalLoaderOptions(): LoaderOptions {\n const state = getGlobalLoaderState();\n // Ensure all default loader options from this library are mentioned\n state.globalOptions = state.globalOptions || {...DEFAULT_LOADER_OPTIONS};\n return state.globalOptions;\n}\n\n/**\n * Set global loader options\n * @param options\n */\nexport function setGlobalOptions(options: LoaderOptions): void {\n const state = getGlobalLoaderState();\n const globalOptions = getGlobalLoaderOptions();\n // @ts-expect-error First param looks incorrect\n state.globalOptions = normalizeOptionsInternal(globalOptions, options);\n}\n\n/**\n * Merges options with global opts and loader defaults, also injects baseUri\n * @param options\n * @param loader\n * @param loaders\n * @param url\n */\nexport function normalizeOptions(\n options: LoaderOptions,\n loader: Loader,\n loaders?: Loader[],\n url?: string\n): LoaderOptions {\n loaders = loaders || [];\n loaders = Array.isArray(loaders) ? loaders : [loaders];\n\n validateOptions(options, loaders);\n return normalizeOptionsInternal(loader, options, url);\n}\n\n// VALIDATE OPTIONS\n\n/**\n * Warn for unsupported options\n * @param options\n * @param loaders\n */\nfunction validateOptions(options: LoaderOptions, loaders: Loader[]): void {\n // Check top level options\n validateOptionsObject(options, null, DEFAULT_LOADER_OPTIONS, REMOVED_LOADER_OPTIONS, loaders);\n for (const loader of loaders) {\n // Get the scoped, loader specific options from the user supplied options\n const idOptions: Record<string, unknown> = ((options && options[loader.id]) || {}) as Record<\n string,\n unknown\n >;\n\n // Get scoped, loader specific default and deprecated options from the selected loader\n const loaderOptions = (loader.options && loader.options[loader.id]) || {};\n const deprecatedOptions =\n (loader.deprecatedOptions && loader.deprecatedOptions[loader.id]) || {};\n\n // Validate loader specific options\n // @ts-ignore\n validateOptionsObject(idOptions, loader.id, loaderOptions, deprecatedOptions, loaders);\n }\n}\n\n// eslint-disable-next-line max-params, complexity\nfunction validateOptionsObject(\n options: LoaderOptions,\n id: string | null,\n defaultOptions: Record<string, unknown>,\n deprecatedOptions: Record<string, unknown>,\n loaders: Loader[]\n): void {\n const loaderName = id || 'Top level';\n const prefix = id ? `${id}.` : '';\n\n for (const key in options) {\n // If top level option value is an object it could options for a loader, so ignore\n const isSubOptions = !id && isObject(options[key]);\n const isBaseUriOption = key === 'baseUri' && !id;\n const isWorkerUrlOption = key === 'workerUrl' && id;\n // <loader>.workerUrl requires special handling as it is now auto-generated and no longer specified as a default option.\n if (!(key in defaultOptions) && !isBaseUriOption && !isWorkerUrlOption) {\n // Issue deprecation warnings\n if (key in deprecatedOptions) {\n probeLog.warn(\n `${loaderName} loader option \\'${prefix}${key}\\' no longer supported, use \\'${deprecatedOptions[key]}\\'`\n )();\n } else if (!isSubOptions) {\n const suggestion = findSimilarOption(key, loaders);\n probeLog.warn(\n `${loaderName} loader option \\'${prefix}${key}\\' not recognized. ${suggestion}`\n )();\n }\n }\n }\n}\n\nfunction findSimilarOption(optionKey: string, loaders: Loader[]): string {\n const lowerCaseOptionKey = optionKey.toLowerCase();\n let bestSuggestion = '';\n for (const loader of loaders) {\n for (const key in loader.options) {\n if (optionKey === key) {\n return `Did you mean \\'${loader.id}.${key}\\'?`;\n }\n const lowerCaseKey = key.toLowerCase();\n const isPartialMatch =\n lowerCaseOptionKey.startsWith(lowerCaseKey) || lowerCaseKey.startsWith(lowerCaseOptionKey);\n if (isPartialMatch) {\n bestSuggestion = bestSuggestion || `Did you mean \\'${loader.id}.${key}\\'?`;\n }\n }\n }\n return bestSuggestion;\n}\n\nfunction normalizeOptionsInternal(\n loader: Loader,\n options: LoaderOptions,\n url?: string\n): LoaderOptions {\n const loaderDefaultOptions = loader.options || {};\n\n const mergedOptions = {...loaderDefaultOptions};\n\n addUrlOptions(mergedOptions, url);\n\n // LOGGING: options.log can be set to `null` to defeat logging\n if (mergedOptions.log === null) {\n mergedOptions.log = new NullLog();\n }\n\n mergeNestedFields(mergedOptions, getGlobalLoaderOptions());\n mergeNestedFields(mergedOptions, options);\n\n return mergedOptions;\n}\n\n// Merge nested options objects\nfunction mergeNestedFields(mergedOptions: LoaderOptions, options: LoaderOptions): void {\n for (const key in options) {\n // Check for nested options\n // object in options => either no key in defaultOptions or object in defaultOptions\n if (key in options) {\n const value = options[key];\n if (isPureObject(value) && isPureObject(mergedOptions[key])) {\n mergedOptions[key] = {\n ...(mergedOptions[key] as object),\n ...(options[key] as object)\n };\n } else {\n mergedOptions[key] = options[key];\n }\n }\n // else: No need to merge nested opts, and the initial merge already copied over the nested options\n }\n}\n\n/**\n * Harvest information from the url\n * @deprecated This is mainly there to support a hack in the GLTFLoader\n * TODO - baseUri should be a directory, i.e. remove file component from baseUri\n * TODO - extract extension?\n * TODO - extract query parameters?\n * TODO - should these be injected on context instead of options?\n */\nfunction addUrlOptions(options: LoaderOptions, url?: string): void {\n if (url && !('baseUri' in options)) {\n options.baseUri = url;\n }\n}\n"],"mappings":"SAGQA,YAAY,EAAEC,QAAQ;AAAA,SACtBC,QAAQ,EAAEC,OAAO;AAAA,SACjBC,sBAAsB,EAAEC,sBAAsB;AActD,OAAO,SAASC,oBAAoBA,CAAA,EAAsB;EAExDC,UAAU,CAACC,OAAO,GAAGD,UAAU,CAACC,OAAO,IAAI,CAAC,CAAC;EAE7C,MAAM;IAACA;EAAO,CAAC,GAAGD,UAAU;EAG5BC,OAAO,CAACC,MAAM,GAAGD,OAAO,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;EACrF,KAAK,MAAMgB,GAAG,IAAIhB,OAAO,EAAE;IAGzB,IAAIgB,GAAG,IAAIhB,OAAO,EAAE;MAClB,MAAMmC,KAAK,GAAGnC,OAAO,CAACgB,GAAG,CAAC;MAC1B,IAAI9B,YAAY,CAACiD,KAAK,CAAC,IAAIjD,YAAY,CAAC6C,aAAa,CAACf,GAAG,CAAC,CAAC,EAAE;QAC3De,aAAa,CAACf,GAAG,CAAC,GAAG;UACnB,GAAIe,aAAa,CAACf,GAAG,CAAY;UACjC,GAAIhB,OAAO,CAACgB,GAAG;QACjB,CAAC;MACH,CAAC,MAAM;QACLe,aAAa,CAACf,GAAG,CAAC,GAAGhB,OAAO,CAACgB,GAAG,CAAC;MACnC;IACF;EAEF;AACF;AAUA,SAASgB,aAAaA,CAAChC,OAAsB,EAAEI,GAAY,EAAQ;EACjE,IAAIA,GAAG,IAAI,EAAE,SAAS,IAAIJ,OAAO,CAAC,EAAE;IAClCA,OAAO,CAACoC,OAAO,GAAGhC,GAAG;EACvB;AACF"}
1
+ {"version":3,"file":"option-utils.js","names":["isPureObject","isObject","probeLog","NullLog","DEFAULT_LOADER_OPTIONS","REMOVED_LOADER_OPTIONS","getGlobalLoaderState","globalThis","loaders","_state","getGlobalLoaderOptions","state","globalOptions","setGlobalOptions","options","normalizeOptionsInternal","normalizeOptions","loader","url","Array","isArray","validateOptions","validateOptionsObject","idOptions","id","loaderOptions","deprecatedOptions","defaultOptions","loaderName","prefix","key","isSubOptions","isBaseUriOption","isWorkerUrlOption","warn","suggestion","findSimilarOption","optionKey","lowerCaseOptionKey","toLowerCase","bestSuggestion","lowerCaseKey","isPartialMatch","startsWith","loaderDefaultOptions","mergedOptions","addUrlOptions","log","mergeNestedFields","value","baseUri"],"sources":["../../../src/lib/loader-utils/option-utils.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {isPureObject, isObject} from '../../javascript-utils/is-type';\nimport {probeLog, NullLog} from './loggers';\nimport {DEFAULT_LOADER_OPTIONS, REMOVED_LOADER_OPTIONS} from './option-defaults';\n\n/**\n * Global state for loaders.gl. Stored on `globalThis.loaders._state`\n */\ntype GlobalLoaderState = {\n loaderRegistry: Loader[];\n globalOptions: LoaderOptions;\n};\n\n/**\n * Helper for safely accessing global loaders.gl variables\n * Wraps initialization of global variable in function to defeat overly aggressive tree-shakers\n */\nexport function getGlobalLoaderState(): GlobalLoaderState {\n // @ts-ignore\n globalThis.loaders = globalThis.loaders || {};\n // @ts-ignore\n const {loaders} = globalThis;\n\n // Add _state object to keep separate from modules added to globalThis.loaders\n loaders._state = loaders._state || {};\n return loaders._state;\n}\n\n/**\n * Store global loader options on the global object to increase chances of cross loaders-version interoperability\n * NOTE: This use case is not reliable but can help when testing new versions of loaders.gl with existing frameworks\n * @returns global loader options merged with default loader options\n */\nexport function getGlobalLoaderOptions(): LoaderOptions {\n const state = getGlobalLoaderState();\n // Ensure all default loader options from this library are mentioned\n state.globalOptions = state.globalOptions || {...DEFAULT_LOADER_OPTIONS};\n return state.globalOptions;\n}\n\n/**\n * Set global loader options\n * @param options\n */\nexport function setGlobalOptions(options: LoaderOptions): void {\n const state = getGlobalLoaderState();\n const globalOptions = getGlobalLoaderOptions();\n // @ts-expect-error First param looks incorrect\n state.globalOptions = normalizeOptionsInternal(globalOptions, options);\n}\n\n/**\n * Merges options with global opts and loader defaults, also injects baseUri\n * @param options\n * @param loader\n * @param loaders\n * @param url\n */\nexport function normalizeOptions(\n options: LoaderOptions,\n loader: Loader,\n loaders?: Loader[],\n url?: string\n): LoaderOptions {\n loaders = loaders || [];\n loaders = Array.isArray(loaders) ? loaders : [loaders];\n\n validateOptions(options, loaders);\n return normalizeOptionsInternal(loader, options, url);\n}\n\n// VALIDATE OPTIONS\n\n/**\n * Warn for unsupported options\n * @param options\n * @param loaders\n */\nfunction validateOptions(options: LoaderOptions, loaders: Loader[]): void {\n // Check top level options\n validateOptionsObject(options, null, DEFAULT_LOADER_OPTIONS, REMOVED_LOADER_OPTIONS, loaders);\n for (const loader of loaders) {\n // Get the scoped, loader specific options from the user supplied options\n const idOptions: Record<string, unknown> = ((options && options[loader.id]) || {}) as Record<\n string,\n unknown\n >;\n\n // Get scoped, loader specific default and deprecated options from the selected loader\n const loaderOptions = (loader.options && loader.options[loader.id]) || {};\n const deprecatedOptions =\n (loader.deprecatedOptions && loader.deprecatedOptions[loader.id]) || {};\n\n // Validate loader specific options\n // @ts-ignore\n validateOptionsObject(idOptions, loader.id, loaderOptions, deprecatedOptions, loaders);\n }\n}\n\n// eslint-disable-next-line max-params, complexity\nfunction validateOptionsObject(\n options: LoaderOptions,\n id: string | null,\n defaultOptions: Record<string, unknown>,\n deprecatedOptions: Record<string, unknown>,\n loaders: Loader[]\n): void {\n const loaderName = id || 'Top level';\n const prefix = id ? `${id}.` : '';\n\n for (const key in options) {\n // If top level option value is an object it could options for a loader, so ignore\n const isSubOptions = !id && isObject(options[key]);\n const isBaseUriOption = key === 'baseUri' && !id;\n const isWorkerUrlOption = key === 'workerUrl' && id;\n // <loader>.workerUrl requires special handling as it is now auto-generated and no longer specified as a default option.\n if (!(key in defaultOptions) && !isBaseUriOption && !isWorkerUrlOption) {\n // Issue deprecation warnings\n if (key in deprecatedOptions) {\n probeLog.warn(\n `${loaderName} loader option \\'${prefix}${key}\\' no longer supported, use \\'${deprecatedOptions[key]}\\'`\n )();\n } else if (!isSubOptions) {\n const suggestion = findSimilarOption(key, loaders);\n probeLog.warn(\n `${loaderName} loader option \\'${prefix}${key}\\' not recognized. ${suggestion}`\n )();\n }\n }\n }\n}\n\nfunction findSimilarOption(optionKey: string, loaders: Loader[]): string {\n const lowerCaseOptionKey = optionKey.toLowerCase();\n let bestSuggestion = '';\n for (const loader of loaders) {\n for (const key in loader.options) {\n if (optionKey === key) {\n return `Did you mean \\'${loader.id}.${key}\\'?`;\n }\n const lowerCaseKey = key.toLowerCase();\n const isPartialMatch =\n lowerCaseOptionKey.startsWith(lowerCaseKey) || lowerCaseKey.startsWith(lowerCaseOptionKey);\n if (isPartialMatch) {\n bestSuggestion = bestSuggestion || `Did you mean \\'${loader.id}.${key}\\'?`;\n }\n }\n }\n return bestSuggestion;\n}\n\nfunction normalizeOptionsInternal(\n loader: Loader,\n options: LoaderOptions,\n url?: string\n): LoaderOptions {\n const loaderDefaultOptions = loader.options || {};\n\n const mergedOptions = {...loaderDefaultOptions};\n\n addUrlOptions(mergedOptions, url);\n\n // LOGGING: options.log can be set to `null` to defeat logging\n if (mergedOptions.log === null) {\n mergedOptions.log = new NullLog();\n }\n\n mergeNestedFields(mergedOptions, getGlobalLoaderOptions());\n mergeNestedFields(mergedOptions, options);\n\n return mergedOptions;\n}\n\n// Merge nested options objects\nfunction mergeNestedFields(mergedOptions: LoaderOptions, options: LoaderOptions): void {\n for (const key in options) {\n // Check for nested options\n // object in options => either no key in defaultOptions or object in defaultOptions\n if (key in options) {\n const value = options[key];\n if (isPureObject(value) && isPureObject(mergedOptions[key])) {\n mergedOptions[key] = {\n ...(mergedOptions[key] as object),\n ...(options[key] as object)\n };\n } else {\n mergedOptions[key] = options[key];\n }\n }\n // else: No need to merge nested opts, and the initial merge already copied over the nested options\n }\n}\n\n/**\n * Harvest information from the url\n * @deprecated This is mainly there to support a hack in the GLTFLoader\n * TODO - baseUri should be a directory, i.e. remove file component from baseUri\n * TODO - extract extension?\n * TODO - extract query parameters?\n * TODO - should these be injected on context instead of options?\n */\nfunction addUrlOptions(options: LoaderOptions, url?: string): void {\n if (url && !('baseUri' in options)) {\n options.baseUri = url;\n }\n}\n"],"mappings":"SAGQA,YAAY,EAAEC,QAAQ;AAAA,SACtBC,QAAQ,EAAEC,OAAO;AAAA,SACjBC,sBAAsB,EAAEC,sBAAsB;AActD,OAAO,SAASC,oBAAoBA,CAAA,EAAsB;EAExDC,UAAU,CAACC,OAAO,GAAGD,UAAU,CAACC,OAAO,IAAI,CAAC,CAAC;EAE7C,MAAM;IAACA;EAAO,CAAC,GAAGD,UAAU;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iBA,CAACH,aAA4B,EAAE/B,OAAsB,EAAQ;EACrF,KAAK,MAAMgB,GAAG,IAAIhB,OAAO,EAAE;IAGzB,IAAIgB,GAAG,IAAIhB,OAAO,EAAE;MAClB,MAAMmC,KAAK,GAAGnC,OAAO,CAACgB,GAAG,CAAC;MAC1B,IAAI9B,YAAY,CAACiD,KAAK,CAAC,IAAIjD,YAAY,CAAC6C,aAAa,CAACf,GAAG,CAAC,CAAC,EAAE;QAC3De,aAAa,CAACf,GAAG,CAAC,GAAG;UACnB,GAAIe,aAAa,CAACf,GAAG,CAAY;UACjC,GAAIhB,OAAO,CAACgB,GAAG;QACjB,CAAC;MACH,CAAC,MAAM;QACLe,aAAa,CAACf,GAAG,CAAC,GAAGhB,OAAO,CAACgB,GAAG,CAAC;MACnC;IACF;EAEF;AACF;AAUA,SAASgB,aAAaA,CAAChC,OAAsB,EAAEI,GAAY,EAAQ;EACjE,IAAIA,GAAG,IAAI,EAAE,SAAS,IAAIJ,OAAO,CAAC,EAAE;IAClCA,OAAO,CAACoC,OAAO,GAAGhC,GAAG;EACvB;AACF"}
@@ -200,7 +200,7 @@ async function parseData({
200
200
  }
201
201
 
202
202
  // src/null-loader.ts
203
- var VERSION = true ? "4.0.0-beta.3" : "latest";
203
+ var VERSION = true ? "4.0.0-beta.5" : "latest";
204
204
  var NullLoader = {
205
205
  name: "Null loader",
206
206
  id: "null",
@@ -200,7 +200,7 @@
200
200
  }
201
201
 
202
202
  // src/null-loader.ts
203
- var VERSION = true ? "4.0.0-beta.3" : "latest";
203
+ var VERSION = true ? "4.0.0-beta.5" : "latest";
204
204
  var NullLoader = {
205
205
  name: "Null loader",
206
206
  id: "null",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/core",
3
- "version": "4.0.0-beta.3",
3
+ "version": "4.0.0-beta.5",
4
4
  "description": "The core API for working with loaders.gl loaders and writers",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -46,9 +46,9 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@babel/runtime": "^7.3.1",
49
- "@loaders.gl/loader-utils": "4.0.0-beta.3",
50
- "@loaders.gl/worker-utils": "4.0.0-beta.3",
49
+ "@loaders.gl/loader-utils": "4.0.0-beta.5",
50
+ "@loaders.gl/worker-utils": "4.0.0-beta.5",
51
51
  "@probe.gl/log": "^4.0.2"
52
52
  },
53
- "gitHead": "7ba9621cc51c7a26c407086ac86171f35b8712af"
53
+ "gitHead": "a6f5a0d1a316cc22396e5a4d480c14329d1ef146"
54
54
  }
@@ -8,9 +8,9 @@ import {isBrowser} from '@loaders.gl/core';
8
8
 
9
9
  // TODO hack - trick filesaver.js to skip loading under node
10
10
  const savedNavigatorExists = 'navigator' in global;
11
- const savedNavigator = global.navigator;
11
+ const savedNavigator = globalThis.navigator;
12
12
  if (!isBrowser) {
13
- global.navigator = {userAgent: 'MSIE 9.'};
13
+ globalThis.navigator = {userAgent: 'MSIE 9.'};
14
14
  }
15
15
 
16
16
  // Need to use `require` to ensure our modification of global code above happens first
@@ -18,9 +18,9 @@ const saveAs = require('filesaver.js');
18
18
 
19
19
  if (!isBrowser) {
20
20
  if (savedNavigatorExists) {
21
- global.navigator = savedNavigator;
21
+ globalThis.navigator = savedNavigator;
22
22
  } else {
23
- delete global.navigator;
23
+ delete globalThis.navigator;
24
24
  }
25
25
  }
26
26
  // END hack
@@ -29,6 +29,7 @@ export function makeStream<ArrayBuffer>(
29
29
  // Create a byte stream (enables `Response(stream).arrayBuffer()`)
30
30
  // Only supported on Chrome
31
31
  // See: https://developer.mozilla.org/en-US/docs/Web/API/ReadableByteStreamController
32
+ // @ts-ignore
32
33
  type: 'bytes',
33
34
 
34
35
  async pull(controller) {
@@ -6,7 +6,7 @@ import {probeLog, NullLog} from './loggers';
6
6
  import {DEFAULT_LOADER_OPTIONS, REMOVED_LOADER_OPTIONS} from './option-defaults';
7
7
 
8
8
  /**
9
- * Global state for loaders.gl. Stored on `global.loaders._state`
9
+ * Global state for loaders.gl. Stored on `globalThis.loaders._state`
10
10
  */
11
11
  type GlobalLoaderState = {
12
12
  loaderRegistry: Loader[];