@loaders.gl/core 4.4.3 → 5.0.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.
- package/dist/dist.dev.js +583 -162
- package/dist/dist.min.js +4 -3
- package/dist/index.cjs +499 -148
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/iterators/make-iterator/make-stream-iterator.js +1 -1
- package/dist/iterators/make-iterator/make-stream-iterator.js.map +1 -1
- package/dist/lib/api/core-api.d.ts +6 -0
- package/dist/lib/api/core-api.d.ts.map +1 -0
- package/dist/lib/api/core-api.js +23 -0
- package/dist/lib/api/core-api.js.map +1 -0
- package/dist/lib/api/create-data-source.d.ts +2 -2
- package/dist/lib/api/create-data-source.d.ts.map +1 -1
- package/dist/lib/api/create-data-source.js +15 -14
- package/dist/lib/api/create-data-source.js.map +1 -1
- package/dist/lib/api/load-in-batches.d.ts +4 -4
- package/dist/lib/api/load-in-batches.d.ts.map +1 -1
- package/dist/lib/api/load-in-batches.js +1 -1
- package/dist/lib/api/load-in-batches.js.map +1 -1
- package/dist/lib/api/load-loader.d.ts +8 -0
- package/dist/lib/api/load-loader.d.ts.map +1 -0
- package/dist/lib/api/load-loader.js +116 -0
- package/dist/lib/api/load-loader.js.map +1 -0
- package/dist/lib/api/load.d.ts +2 -2
- package/dist/lib/api/load.d.ts.map +1 -1
- package/dist/lib/api/load.js +52 -3
- package/dist/lib/api/load.js.map +1 -1
- package/dist/lib/api/parse-file.d.ts +15 -0
- package/dist/lib/api/parse-file.d.ts.map +1 -0
- package/dist/lib/api/parse-file.js +70 -0
- package/dist/lib/api/parse-file.js.map +1 -0
- package/dist/lib/api/parse-in-batches.d.ts +2 -2
- package/dist/lib/api/parse-in-batches.d.ts.map +1 -1
- package/dist/lib/api/parse-in-batches.js +6 -4
- package/dist/lib/api/parse-in-batches.js.map +1 -1
- package/dist/lib/api/parse-sync.d.ts +2 -2
- package/dist/lib/api/parse-sync.d.ts.map +1 -1
- package/dist/lib/api/parse-sync.js +10 -1
- package/dist/lib/api/parse-sync.js.map +1 -1
- package/dist/lib/api/parse.d.ts +2 -2
- package/dist/lib/api/parse.d.ts.map +1 -1
- package/dist/lib/api/parse.js +25 -16
- package/dist/lib/api/parse.js.map +1 -1
- package/dist/lib/api/preload.d.ts +11 -0
- package/dist/lib/api/preload.d.ts.map +1 -0
- package/dist/lib/api/preload.js +14 -0
- package/dist/lib/api/preload.js.map +1 -0
- package/dist/lib/api/register-loaders.js +1 -1
- package/dist/lib/api/register-loaders.js.map +1 -1
- package/dist/lib/api/select-loader.d.ts.map +1 -1
- package/dist/lib/api/select-loader.js +48 -5
- package/dist/lib/api/select-loader.js.map +1 -1
- package/dist/lib/api/select-source.d.ts +3 -3
- package/dist/lib/api/select-source.d.ts.map +1 -1
- package/dist/lib/api/select-source.js +2 -5
- package/dist/lib/api/select-source.js.map +1 -1
- package/dist/lib/fetch/fetch-error-message.js +1 -1
- package/dist/lib/fetch/fetch-error-message.js.map +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/lib/init.js.map +1 -1
- package/dist/lib/loader-utils/check-errors.js +1 -1
- package/dist/lib/loader-utils/check-errors.js.map +1 -1
- package/dist/lib/loader-utils/get-data.d.ts +4 -0
- package/dist/lib/loader-utils/get-data.d.ts.map +1 -1
- package/dist/lib/loader-utils/get-data.js +26 -0
- package/dist/lib/loader-utils/get-data.js.map +1 -1
- package/dist/lib/loader-utils/get-fetch-function.d.ts +1 -1
- package/dist/lib/loader-utils/get-fetch-function.d.ts.map +1 -1
- package/dist/lib/loader-utils/get-fetch-function.js +1 -1
- package/dist/lib/loader-utils/get-fetch-function.js.map +1 -1
- package/dist/lib/loader-utils/loader-context.d.ts +1 -1
- package/dist/lib/loader-utils/loader-context.d.ts.map +1 -1
- package/dist/lib/loader-utils/loader-context.js +3 -1
- package/dist/lib/loader-utils/loader-context.js.map +1 -1
- package/dist/lib/loader-utils/loggers.d.ts +19 -0
- package/dist/lib/loader-utils/loggers.d.ts.map +1 -1
- package/dist/lib/loader-utils/loggers.js +28 -2
- package/dist/lib/loader-utils/loggers.js.map +1 -1
- package/dist/lib/loader-utils/option-defaults.d.ts +1 -0
- package/dist/lib/loader-utils/option-defaults.d.ts.map +1 -1
- package/dist/lib/loader-utils/option-defaults.js +2 -0
- package/dist/lib/loader-utils/option-defaults.js.map +1 -1
- package/dist/lib/loader-utils/option-utils.d.ts.map +1 -1
- package/dist/lib/loader-utils/option-utils.js +50 -2
- package/dist/lib/loader-utils/option-utils.js.map +1 -1
- package/dist/lib/utils/response-utils.js +3 -3
- package/dist/lib/utils/response-utils.js.map +1 -1
- package/dist/null-loader.d.ts.map +1 -1
- package/dist/null-loader.js +1 -1
- package/dist/null-loader.js.map +1 -1
- package/dist/null-worker-node.js +199 -36
- package/dist/null-worker.js +199 -36
- package/package.json +6 -6
- package/src/index.ts +10 -1
- package/src/iterators/make-iterator/make-stream-iterator.ts +1 -1
- package/src/lib/api/core-api.ts +25 -0
- package/src/lib/api/create-data-source.ts +24 -24
- package/src/lib/api/load-in-batches.ts +16 -11
- package/src/lib/api/load-loader.ts +163 -0
- package/src/lib/api/load.ts +78 -5
- package/src/lib/api/parse-file.ts +143 -0
- package/src/lib/api/parse-in-batches.ts +13 -5
- package/src/lib/api/parse-sync.ts +27 -2
- package/src/lib/api/parse.ts +44 -18
- package/src/lib/api/preload.ts +31 -0
- package/src/lib/api/register-loaders.ts +1 -1
- package/src/lib/api/select-loader.ts +57 -5
- package/src/lib/api/select-source.ts +7 -10
- package/src/lib/fetch/fetch-error-message.ts +1 -1
- package/src/lib/loader-utils/check-errors.ts +1 -1
- package/src/lib/loader-utils/get-data.ts +36 -0
- package/src/lib/loader-utils/get-fetch-function.ts +3 -2
- package/src/lib/loader-utils/loader-context.ts +5 -2
- package/src/lib/loader-utils/loggers.ts +28 -2
- package/src/lib/loader-utils/option-defaults.ts +2 -0
- package/src/lib/loader-utils/option-utils.ts +59 -2
- package/src/lib/utils/response-utils.ts +3 -3
- package/src/null-loader.ts +3 -3
package/dist/index.cjs
CHANGED
|
@@ -21,18 +21,19 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var dist_exports = {};
|
|
22
22
|
__export(dist_exports, {
|
|
23
23
|
FetchError: () => FetchError,
|
|
24
|
-
JSONLoader: () =>
|
|
24
|
+
JSONLoader: () => import_loader_utils24.JSONLoader,
|
|
25
25
|
NullLoader: () => NullLoader,
|
|
26
26
|
NullWorkerLoader: () => NullWorkerLoader,
|
|
27
|
-
RequestScheduler: () =>
|
|
27
|
+
RequestScheduler: () => import_loader_utils23.RequestScheduler,
|
|
28
28
|
_BrowserFileSystem: () => BrowserFileSystem,
|
|
29
29
|
_fetchProgress: () => fetchProgress,
|
|
30
|
-
_selectSource: () =>
|
|
30
|
+
_selectSource: () => selectSource,
|
|
31
31
|
_unregisterLoaders: () => _unregisterLoaders,
|
|
32
|
-
assert: () =>
|
|
33
|
-
concatenateArrayBuffersAsync: () =>
|
|
32
|
+
assert: () => import_loader_utils26.assert,
|
|
33
|
+
concatenateArrayBuffersAsync: () => import_loader_utils27.concatenateArrayBuffersAsync,
|
|
34
|
+
coreApi: () => coreApi,
|
|
34
35
|
createDataSource: () => createDataSource,
|
|
35
|
-
document: () =>
|
|
36
|
+
document: () => import_loader_utils25.document,
|
|
36
37
|
encode: () => encode,
|
|
37
38
|
encodeInBatches: () => encodeInBatches,
|
|
38
39
|
encodeSync: () => encodeSync,
|
|
@@ -43,40 +44,43 @@ __export(dist_exports, {
|
|
|
43
44
|
encodeTextSync: () => encodeTextSync,
|
|
44
45
|
encodeURLtoURL: () => encodeURLtoURL,
|
|
45
46
|
fetchFile: () => fetchFile,
|
|
46
|
-
forEach: () =>
|
|
47
|
+
forEach: () => import_loader_utils27.forEach,
|
|
47
48
|
getLoaderOptions: () => getGlobalLoaderOptions,
|
|
48
|
-
getPathPrefix: () =>
|
|
49
|
-
global: () =>
|
|
50
|
-
isAsyncIterable: () =>
|
|
51
|
-
isBrowser: () =>
|
|
52
|
-
isIterable: () =>
|
|
53
|
-
isIterator: () =>
|
|
54
|
-
isPromise: () =>
|
|
55
|
-
isPureObject: () =>
|
|
56
|
-
isReadableStream: () =>
|
|
57
|
-
isResponse: () =>
|
|
58
|
-
isWorker: () =>
|
|
59
|
-
isWritableStream: () =>
|
|
49
|
+
getPathPrefix: () => import_loader_utils22.getPathPrefix,
|
|
50
|
+
global: () => import_loader_utils25.global,
|
|
51
|
+
isAsyncIterable: () => import_loader_utils29.isAsyncIterable,
|
|
52
|
+
isBrowser: () => import_loader_utils25.isBrowser,
|
|
53
|
+
isIterable: () => import_loader_utils29.isIterable,
|
|
54
|
+
isIterator: () => import_loader_utils29.isIterator,
|
|
55
|
+
isPromise: () => import_loader_utils29.isPromise,
|
|
56
|
+
isPureObject: () => import_loader_utils29.isPureObject,
|
|
57
|
+
isReadableStream: () => import_loader_utils29.isReadableStream,
|
|
58
|
+
isResponse: () => import_loader_utils29.isResponse,
|
|
59
|
+
isWorker: () => import_loader_utils25.isWorker,
|
|
60
|
+
isWritableStream: () => import_loader_utils29.isWritableStream,
|
|
60
61
|
load: () => load,
|
|
61
62
|
loadInBatches: () => loadInBatches,
|
|
62
63
|
makeIterator: () => makeIterator,
|
|
63
|
-
makeLineIterator: () =>
|
|
64
|
-
makeNumberedLineIterator: () =>
|
|
64
|
+
makeLineIterator: () => import_loader_utils28.makeLineIterator,
|
|
65
|
+
makeNumberedLineIterator: () => import_loader_utils28.makeNumberedLineIterator,
|
|
65
66
|
makeStream: () => makeStream,
|
|
66
|
-
makeTextDecoderIterator: () =>
|
|
67
|
-
makeTextEncoderIterator: () =>
|
|
67
|
+
makeTextDecoderIterator: () => import_loader_utils28.makeTextDecoderIterator,
|
|
68
|
+
makeTextEncoderIterator: () => import_loader_utils28.makeTextEncoderIterator,
|
|
68
69
|
parse: () => parse,
|
|
70
|
+
parseFile: () => parseFile,
|
|
69
71
|
parseInBatches: () => parseInBatches,
|
|
70
72
|
parseSync: () => parseSync,
|
|
73
|
+
preload: () => preload,
|
|
74
|
+
preloadSync: () => preloadSync,
|
|
71
75
|
readArrayBuffer: () => readArrayBuffer,
|
|
72
76
|
registerLoaders: () => registerLoaders,
|
|
73
|
-
resolvePath: () =>
|
|
77
|
+
resolvePath: () => import_loader_utils22.resolvePath,
|
|
74
78
|
selectLoader: () => selectLoader,
|
|
75
79
|
selectLoaderSync: () => selectLoaderSync,
|
|
76
|
-
self: () =>
|
|
80
|
+
self: () => import_loader_utils25.self,
|
|
77
81
|
setLoaderOptions: () => setGlobalOptions,
|
|
78
|
-
setPathPrefix: () =>
|
|
79
|
-
window: () =>
|
|
82
|
+
setPathPrefix: () => import_loader_utils22.setPathPrefix,
|
|
83
|
+
window: () => import_loader_utils25.window
|
|
80
84
|
});
|
|
81
85
|
module.exports = __toCommonJS(dist_exports);
|
|
82
86
|
|
|
@@ -240,7 +244,7 @@ async function getResponseError(response) {
|
|
|
240
244
|
try {
|
|
241
245
|
const contentType = response.headers.get("Content-Type");
|
|
242
246
|
info.reason = !response.bodyUsed && (contentType == null ? void 0 : contentType.includes("application/json")) ? await response.json() : await response.text();
|
|
243
|
-
} catch (
|
|
247
|
+
} catch (_error) {
|
|
244
248
|
}
|
|
245
249
|
return new FetchError(message, info);
|
|
246
250
|
}
|
|
@@ -327,37 +331,64 @@ var import_loader_utils5 = require("@loaders.gl/loader-utils");
|
|
|
327
331
|
var import_log = require("@probe.gl/log");
|
|
328
332
|
var probeLog = new import_log.Log({ id: "loaders.gl" });
|
|
329
333
|
var NullLog = class {
|
|
334
|
+
/** Drops a log message. */
|
|
330
335
|
log() {
|
|
331
336
|
return () => {
|
|
332
337
|
};
|
|
333
338
|
}
|
|
339
|
+
/** Drops an info message. */
|
|
334
340
|
info() {
|
|
335
341
|
return () => {
|
|
336
342
|
};
|
|
337
343
|
}
|
|
344
|
+
/** Logs one message once; no-op for the null logger. */
|
|
345
|
+
once() {
|
|
346
|
+
return () => {
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
/** Drops a warning message. */
|
|
338
350
|
warn() {
|
|
339
351
|
return () => {
|
|
340
352
|
};
|
|
341
353
|
}
|
|
354
|
+
/** Drops an error message. */
|
|
342
355
|
error() {
|
|
343
356
|
return () => {
|
|
344
357
|
};
|
|
345
358
|
}
|
|
346
359
|
};
|
|
347
360
|
var ConsoleLog = class {
|
|
361
|
+
/** Console-like object used for message output. */
|
|
348
362
|
console;
|
|
363
|
+
/** Messages already emitted through `once`. */
|
|
364
|
+
onceMessages = /* @__PURE__ */ new Set();
|
|
365
|
+
/** Creates a console-backed logger. */
|
|
349
366
|
constructor() {
|
|
350
367
|
this.console = console;
|
|
351
368
|
}
|
|
369
|
+
/** Logs a message to the console. */
|
|
352
370
|
log(...args) {
|
|
353
371
|
return this.console.log.bind(this.console, ...args);
|
|
354
372
|
}
|
|
373
|
+
/** Logs an informational message to the console. */
|
|
355
374
|
info(...args) {
|
|
356
375
|
return this.console.info.bind(this.console, ...args);
|
|
357
376
|
}
|
|
377
|
+
/** Logs one message once to the console. */
|
|
378
|
+
once(...args) {
|
|
379
|
+
const message = String(args[0]);
|
|
380
|
+
if (this.onceMessages.has(message)) {
|
|
381
|
+
return () => {
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
this.onceMessages.add(message);
|
|
385
|
+
return this.console.info.bind(this.console, ...args);
|
|
386
|
+
}
|
|
387
|
+
/** Logs a warning message to the console. */
|
|
358
388
|
warn(...args) {
|
|
359
389
|
return this.console.warn.bind(this.console, ...args);
|
|
360
390
|
}
|
|
391
|
+
/** Logs an error message to the console. */
|
|
361
392
|
error(...args) {
|
|
362
393
|
return this.console.error.bind(this.console, ...args);
|
|
363
394
|
}
|
|
@@ -374,6 +405,7 @@ var DEFAULT_LOADER_OPTIONS = {
|
|
|
374
405
|
fallbackMimeType: void 0,
|
|
375
406
|
ignoreRegisteredLoaders: void 0,
|
|
376
407
|
nothrow: false,
|
|
408
|
+
shape: void 0,
|
|
377
409
|
log: new ConsoleLog(),
|
|
378
410
|
// A probe.gl compatible (`log.log()()` syntax) that just logs to console
|
|
379
411
|
useLocalLibraries: false,
|
|
@@ -419,6 +451,7 @@ var REMOVED_LOADER_OPTIONS = {
|
|
|
419
451
|
_worker: "core._workerType",
|
|
420
452
|
limit: "core.limit",
|
|
421
453
|
_limitMB: "core._limitMB",
|
|
454
|
+
shape: "core.shape",
|
|
422
455
|
batchSize: "core.batchSize",
|
|
423
456
|
batchDebounceMs: "core.batchDebounceMs",
|
|
424
457
|
metadata: "core.metadata",
|
|
@@ -457,10 +490,12 @@ var CORE_LOADER_OPTION_KEYS = [
|
|
|
457
490
|
"maxConcurrency",
|
|
458
491
|
"maxMobileConcurrency",
|
|
459
492
|
"reuseWorkers",
|
|
493
|
+
"workerTransferBufferCopy",
|
|
460
494
|
"_nodeWorkers",
|
|
461
495
|
"_workerType",
|
|
462
496
|
"limit",
|
|
463
497
|
"_limitMB",
|
|
498
|
+
"shape",
|
|
464
499
|
"batchSize",
|
|
465
500
|
"batchDebounceMs",
|
|
466
501
|
"metadata",
|
|
@@ -568,10 +603,35 @@ function normalizeOptionsInternal(loader, options, url) {
|
|
|
568
603
|
mergeNestedFields(mergedOptions, normalizeLoaderOptions(getGlobalLoaderOptions()));
|
|
569
604
|
const userOptions = normalizeLoaderOptions(options);
|
|
570
605
|
mergeNestedFields(mergedOptions, userOptions);
|
|
606
|
+
applyCoreShapeDefault(mergedOptions, userOptions, loader);
|
|
571
607
|
addUrlOptions(mergedOptions, url);
|
|
572
608
|
addDeprecatedTopLevelOptions(mergedOptions);
|
|
573
609
|
return mergedOptions;
|
|
574
610
|
}
|
|
611
|
+
function applyCoreShapeDefault(mergedOptions, userOptions, loader) {
|
|
612
|
+
var _a, _b;
|
|
613
|
+
const coreShape = (_a = mergedOptions.core) == null ? void 0 : _a.shape;
|
|
614
|
+
if (coreShape === void 0) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
const loaderScopedDefaults = (_b = loader.options) == null ? void 0 : _b[loader.id];
|
|
618
|
+
if (!(0, import_loader_utils5.isPureObject)(loaderScopedDefaults) || !("shape" in loaderScopedDefaults)) {
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
const globalLoaderScopedOptions = getGlobalLoaderOptions()[loader.id];
|
|
622
|
+
if ((0, import_loader_utils5.isPureObject)(globalLoaderScopedOptions) && "shape" in globalLoaderScopedOptions) {
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
const userLoaderScopedOptions = userOptions[loader.id];
|
|
626
|
+
if ((0, import_loader_utils5.isPureObject)(userLoaderScopedOptions) && "shape" in userLoaderScopedOptions) {
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
const loaderScopedOptions = mergedOptions[loader.id];
|
|
630
|
+
mergedOptions[loader.id] = {
|
|
631
|
+
...(0, import_loader_utils5.isPureObject)(loaderScopedOptions) ? loaderScopedOptions : {},
|
|
632
|
+
shape: coreShape
|
|
633
|
+
};
|
|
634
|
+
}
|
|
575
635
|
function mergeNestedFields(mergedOptions, options) {
|
|
576
636
|
for (const key in options) {
|
|
577
637
|
if (key in options) {
|
|
@@ -614,7 +674,8 @@ function moveDeprecatedTopLevelOptionsToCore(options) {
|
|
|
614
674
|
}
|
|
615
675
|
for (const key of CORE_LOADER_OPTION_KEYS) {
|
|
616
676
|
if (options[key] !== void 0) {
|
|
617
|
-
|
|
677
|
+
options.core ||= {};
|
|
678
|
+
const coreOptions = options.core;
|
|
618
679
|
const coreRecord = coreOptions;
|
|
619
680
|
if (coreRecord[key] === void 0) {
|
|
620
681
|
coreRecord[key] = options[key];
|
|
@@ -765,16 +826,27 @@ function selectLoaderInternal(data, loaders, options, context) {
|
|
|
765
826
|
const testUrl = stripQueryString(url) || (context == null ? void 0 : context.url);
|
|
766
827
|
let loader = null;
|
|
767
828
|
let reason = "";
|
|
829
|
+
const sourceType = (options == null ? void 0 : options.core) && "type" in options.core ? options.core.type : void 0;
|
|
830
|
+
if (sourceType && sourceType !== "auto") {
|
|
831
|
+
loader = findSourceLoaderByType(loaders, sourceType);
|
|
832
|
+
reason = loader ? `match forced by supplied source type ${sourceType}` : "";
|
|
833
|
+
}
|
|
768
834
|
if ((_a = options == null ? void 0 : options.core) == null ? void 0 : _a.mimeType) {
|
|
769
835
|
loader = findLoaderByMIMEType(loaders, (_b = options == null ? void 0 : options.core) == null ? void 0 : _b.mimeType);
|
|
770
836
|
reason = `match forced by supplied MIME type ${(_c = options == null ? void 0 : options.core) == null ? void 0 : _c.mimeType}`;
|
|
771
837
|
}
|
|
838
|
+
loader = loader || findSourceLoaderByTestURL(loaders, testUrl);
|
|
839
|
+
reason = reason || (loader ? `matched source url ${testUrl}` : "");
|
|
772
840
|
loader = loader || findLoaderByUrl(loaders, testUrl);
|
|
773
841
|
reason = reason || (loader ? `matched url ${testUrl}` : "");
|
|
774
842
|
loader = loader || findLoaderByMIMEType(loaders, type);
|
|
775
843
|
reason = reason || (loader ? `matched MIME type ${type}` : "");
|
|
776
844
|
loader = loader || findLoaderByInitialBytes(loaders, data);
|
|
777
845
|
reason = reason || (loader ? `matched initial data ${getFirstCharacters(data)}` : "");
|
|
846
|
+
if (!loader && (0, import_loader_utils7.isBlob)(data)) {
|
|
847
|
+
loader = findSourceLoaderByTestData(loaders, data);
|
|
848
|
+
reason = reason || (loader ? "matched source testData" : "");
|
|
849
|
+
}
|
|
778
850
|
if ((_d = options == null ? void 0 : options.core) == null ? void 0 : _d.fallbackMimeType) {
|
|
779
851
|
loader = loader || findLoaderByMIMEType(loaders, (_e = options == null ? void 0 : options.core) == null ? void 0 : _e.fallbackMimeType);
|
|
780
852
|
reason = reason || (loader ? `matched fallback MIME type ${type}` : "");
|
|
@@ -824,6 +896,36 @@ function findLoaderByExtension(loaders, extension) {
|
|
|
824
896
|
}
|
|
825
897
|
return null;
|
|
826
898
|
}
|
|
899
|
+
function findSourceLoaderByType(loaders, type) {
|
|
900
|
+
for (const loader of loaders) {
|
|
901
|
+
if ((0, import_loader_utils7.isSourceLoader)(loader) && loader.type === type) {
|
|
902
|
+
return loader;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
return null;
|
|
906
|
+
}
|
|
907
|
+
function findSourceLoaderByTestURL(loaders, url) {
|
|
908
|
+
if (!url) {
|
|
909
|
+
return null;
|
|
910
|
+
}
|
|
911
|
+
for (const loader of loaders) {
|
|
912
|
+
if ((0, import_loader_utils7.isSourceLoader)(loader) && loader.testURL(url)) {
|
|
913
|
+
return loader;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
return null;
|
|
917
|
+
}
|
|
918
|
+
function findSourceLoaderByTestData(loaders, data) {
|
|
919
|
+
var _a;
|
|
920
|
+
for (const loader of loaders) {
|
|
921
|
+
if ((0, import_loader_utils7.isSourceLoader)(loader)) {
|
|
922
|
+
if ((_a = loader.testData) == null ? void 0 : _a.call(loader, data)) {
|
|
923
|
+
return loader;
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
return null;
|
|
928
|
+
}
|
|
827
929
|
function findLoaderByMIMEType(loaders, mimeType) {
|
|
828
930
|
var _a;
|
|
829
931
|
for (const loader of loaders) {
|
|
@@ -907,8 +1009,8 @@ function getMagicString(arrayBuffer, byteOffset, length) {
|
|
|
907
1009
|
}
|
|
908
1010
|
|
|
909
1011
|
// dist/lib/api/parse.js
|
|
910
|
-
var
|
|
911
|
-
var
|
|
1012
|
+
var import_loader_utils18 = require("@loaders.gl/loader-utils");
|
|
1013
|
+
var import_worker_utils2 = require("@loaders.gl/worker-utils");
|
|
912
1014
|
|
|
913
1015
|
// dist/lib/loader-utils/get-data.js
|
|
914
1016
|
var import_loader_utils11 = require("@loaders.gl/loader-utils");
|
|
@@ -977,7 +1079,7 @@ async function* makeBrowserStreamIterator(stream, options) {
|
|
|
977
1079
|
}
|
|
978
1080
|
yield (0, import_loader_utils9.toArrayBuffer)(value);
|
|
979
1081
|
}
|
|
980
|
-
} catch (
|
|
1082
|
+
} catch (_error) {
|
|
981
1083
|
reader.releaseLock();
|
|
982
1084
|
}
|
|
983
1085
|
}
|
|
@@ -1050,6 +1152,28 @@ async function getArrayBufferOrStringFromData(data, loader, options) {
|
|
|
1050
1152
|
}
|
|
1051
1153
|
throw new Error(ERR_DATA);
|
|
1052
1154
|
}
|
|
1155
|
+
async function getArrayBufferFromData(data, options) {
|
|
1156
|
+
if (typeof data === "string") {
|
|
1157
|
+
return new TextEncoder().encode(data).buffer;
|
|
1158
|
+
}
|
|
1159
|
+
if ((0, import_loader_utils11.isArrayBufferLike)(data)) {
|
|
1160
|
+
return (0, import_loader_utils11.toArrayBuffer)((0, import_loader_utils11.toArrayBufferView)(data));
|
|
1161
|
+
}
|
|
1162
|
+
if ((0, import_loader_utils11.isBlob)(data)) {
|
|
1163
|
+
data = await makeResponse(data);
|
|
1164
|
+
}
|
|
1165
|
+
if ((0, import_loader_utils11.isResponse)(data)) {
|
|
1166
|
+
await checkResponse(data);
|
|
1167
|
+
return await data.arrayBuffer();
|
|
1168
|
+
}
|
|
1169
|
+
if ((0, import_loader_utils11.isReadableStream)(data)) {
|
|
1170
|
+
data = makeIterator(data, options);
|
|
1171
|
+
}
|
|
1172
|
+
if ((0, import_loader_utils11.isIterable)(data) || (0, import_loader_utils11.isAsyncIterable)(data)) {
|
|
1173
|
+
return (0, import_loader_utils11.concatenateArrayBuffersAsync)(data);
|
|
1174
|
+
}
|
|
1175
|
+
throw new Error(ERR_DATA);
|
|
1176
|
+
}
|
|
1053
1177
|
async function getAsyncIterableFromData(data, options) {
|
|
1054
1178
|
if ((0, import_loader_utils11.isPromise)(data)) {
|
|
1055
1179
|
data = await data;
|
|
@@ -1116,94 +1240,160 @@ function getFetchFunction(options, context) {
|
|
|
1116
1240
|
}
|
|
1117
1241
|
|
|
1118
1242
|
// dist/lib/loader-utils/loader-context.js
|
|
1243
|
+
var import_loader_utils17 = require("@loaders.gl/loader-utils");
|
|
1244
|
+
|
|
1245
|
+
// dist/lib/api/parse-file.js
|
|
1119
1246
|
var import_loader_utils13 = require("@loaders.gl/loader-utils");
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1247
|
+
var import_worker_utils = require("@loaders.gl/worker-utils");
|
|
1248
|
+
|
|
1249
|
+
// dist/lib/api/load-loader.js
|
|
1250
|
+
var loaderImplementationPromises = /* @__PURE__ */ new Map();
|
|
1251
|
+
var loaderImplementations = /* @__PURE__ */ new Map();
|
|
1252
|
+
async function getLoaderImplementation(loader, options, url) {
|
|
1253
|
+
var _a;
|
|
1254
|
+
if (isLoaderWithParser(loader)) {
|
|
1255
|
+
return loader;
|
|
1123
1256
|
}
|
|
1124
|
-
const
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1257
|
+
const implementationCacheKey = getLoaderImplementationCacheKey(loader, options);
|
|
1258
|
+
const loaderImplementation = (_a = loaderImplementations.get(loader)) == null ? void 0 : _a.get(implementationCacheKey);
|
|
1259
|
+
if (loaderImplementation) {
|
|
1260
|
+
return loaderImplementation;
|
|
1261
|
+
}
|
|
1262
|
+
let loaderImplementationPromisesForLoader = loaderImplementationPromises.get(loader);
|
|
1263
|
+
if (!loaderImplementationPromisesForLoader) {
|
|
1264
|
+
loaderImplementationPromisesForLoader = /* @__PURE__ */ new Map();
|
|
1265
|
+
loaderImplementationPromises.set(loader, loaderImplementationPromisesForLoader);
|
|
1266
|
+
}
|
|
1267
|
+
let loaderImplementationPromise = loaderImplementationPromisesForLoader.get(implementationCacheKey);
|
|
1268
|
+
if (!loaderImplementationPromise) {
|
|
1269
|
+
loaderImplementationPromise = resolveLoaderImplementation(loader, options, url).then((implementation) => {
|
|
1270
|
+
let loaderImplementationsForLoader = loaderImplementations.get(loader);
|
|
1271
|
+
if (!loaderImplementationsForLoader) {
|
|
1272
|
+
loaderImplementationsForLoader = /* @__PURE__ */ new Map();
|
|
1273
|
+
loaderImplementations.set(loader, loaderImplementationsForLoader);
|
|
1274
|
+
}
|
|
1275
|
+
loaderImplementationsForLoader.set(implementationCacheKey, implementation);
|
|
1276
|
+
return implementation;
|
|
1277
|
+
}).catch((error) => {
|
|
1278
|
+
loaderImplementationPromisesForLoader.delete(implementationCacheKey);
|
|
1279
|
+
if (loaderImplementationPromisesForLoader.size === 0) {
|
|
1280
|
+
loaderImplementationPromises.delete(loader);
|
|
1281
|
+
}
|
|
1282
|
+
throw error;
|
|
1283
|
+
});
|
|
1284
|
+
loaderImplementationPromisesForLoader.set(implementationCacheKey, loaderImplementationPromise);
|
|
1134
1285
|
}
|
|
1135
|
-
|
|
1136
|
-
|
|
1286
|
+
return await loaderImplementationPromise;
|
|
1287
|
+
}
|
|
1288
|
+
function getLoaderImplementationSync(loader) {
|
|
1289
|
+
var _a;
|
|
1290
|
+
if (isLoaderWithParser(loader)) {
|
|
1291
|
+
return loader;
|
|
1137
1292
|
}
|
|
1138
|
-
|
|
1293
|
+
const implementationCacheKey = getLoaderImplementationCacheKey(loader);
|
|
1294
|
+
return ((_a = loaderImplementations.get(loader)) == null ? void 0 : _a.get(implementationCacheKey)) || null;
|
|
1139
1295
|
}
|
|
1140
|
-
function
|
|
1141
|
-
|
|
1142
|
-
|
|
1296
|
+
function isLoaderWithParser(loader) {
|
|
1297
|
+
const candidate = loader;
|
|
1298
|
+
return Boolean(candidate.parse || candidate.parseSync || candidate.parseInBatches || candidate.parseText || candidate.parseTextSync || candidate.parseFile || candidate.parseFileInBatches);
|
|
1299
|
+
}
|
|
1300
|
+
async function resolveLoaderImplementation(loader, options, url) {
|
|
1301
|
+
if (loader.preload) {
|
|
1302
|
+
const preloadedLoader = await loader.preload(url || "", options);
|
|
1303
|
+
if (isLoaderWithParser(preloadedLoader)) {
|
|
1304
|
+
return preloadedLoader;
|
|
1305
|
+
}
|
|
1306
|
+
throw new Error(`${loader.id} loader preload() did not return a parser-bearing loader`);
|
|
1143
1307
|
}
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1308
|
+
const implementationSpecifier = getLoaderImplementationSpecifier(loader, options);
|
|
1309
|
+
return await importLoaderImplementation(implementationSpecifier, loader.id);
|
|
1310
|
+
}
|
|
1311
|
+
function getLoaderImplementationSpecifier(loader, options) {
|
|
1312
|
+
var _a;
|
|
1313
|
+
const workerType = (options == null ? void 0 : options._workerType) || ((_a = options == null ? void 0 : options.core) == null ? void 0 : _a._workerType);
|
|
1314
|
+
if (workerType === "test") {
|
|
1315
|
+
const sourcePath = `modules/${loader.module}/src/${loader.id}-loader.ts`;
|
|
1316
|
+
if (typeof window !== "undefined") {
|
|
1317
|
+
return `/${sourcePath}`;
|
|
1318
|
+
}
|
|
1319
|
+
if (typeof process !== "undefined" && process.cwd) {
|
|
1320
|
+
return new URL(sourcePath, `file://${process.cwd()}/`).toString();
|
|
1321
|
+
}
|
|
1322
|
+
return sourcePath;
|
|
1147
1323
|
}
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1324
|
+
throw new Error(`${loader.id} loader does not provide a parser implementation. Import a parser-bearing loader directly, or use preload() before parse/load.`);
|
|
1325
|
+
}
|
|
1326
|
+
function getLoaderImplementationCacheKey(loader, options) {
|
|
1327
|
+
var _a;
|
|
1328
|
+
const loaderOptions = options == null ? void 0 : options[loader.id];
|
|
1329
|
+
const defaultLoaderOptions = (_a = loader.options) == null ? void 0 : _a[loader.id];
|
|
1330
|
+
return String((loaderOptions == null ? void 0 : loaderOptions.backend) || getDeprecatedImplementationBackend(loaderOptions == null ? void 0 : loaderOptions.implementation) || (defaultLoaderOptions == null ? void 0 : defaultLoaderOptions.backend) || "");
|
|
1331
|
+
}
|
|
1332
|
+
function getDeprecatedImplementationBackend(implementation) {
|
|
1333
|
+
return implementation === "js" ? "typescript" : implementation;
|
|
1334
|
+
}
|
|
1335
|
+
async function importLoaderImplementation(implementationSpecifier, loaderId) {
|
|
1336
|
+
const moduleExports = await import(
|
|
1337
|
+
/* webpackIgnore: true */
|
|
1338
|
+
/* @vite-ignore */
|
|
1339
|
+
implementationSpecifier
|
|
1340
|
+
);
|
|
1341
|
+
for (const exportValue of Object.values(moduleExports)) {
|
|
1342
|
+
if (exportValue && typeof exportValue === "object" && exportValue.id === loaderId && isLoaderWithParser(exportValue)) {
|
|
1343
|
+
return exportValue;
|
|
1344
|
+
}
|
|
1151
1345
|
}
|
|
1152
|
-
|
|
1346
|
+
throw new Error(`Could not find parser implementation for ${loaderId} in ${implementationSpecifier}`);
|
|
1153
1347
|
}
|
|
1154
1348
|
|
|
1155
|
-
// dist/lib/api/parse.js
|
|
1156
|
-
async function
|
|
1349
|
+
// dist/lib/api/parse-file.js
|
|
1350
|
+
async function parseFile(file, loaders, options, context) {
|
|
1157
1351
|
if (loaders && !Array.isArray(loaders) && !isLoaderObject(loaders)) {
|
|
1158
1352
|
context = void 0;
|
|
1159
1353
|
options = loaders;
|
|
1160
1354
|
loaders = void 0;
|
|
1161
1355
|
}
|
|
1162
|
-
data = await data;
|
|
1163
1356
|
options = options || {};
|
|
1164
|
-
const url =
|
|
1357
|
+
const url = file.url || "";
|
|
1165
1358
|
const typedLoaders = loaders;
|
|
1166
1359
|
const candidateLoaders = getLoadersFromContext(typedLoaders, context);
|
|
1167
|
-
const loader = await selectLoader(
|
|
1360
|
+
const loader = await selectLoader(url, candidateLoaders, options);
|
|
1168
1361
|
if (!loader) {
|
|
1169
1362
|
return null;
|
|
1170
1363
|
}
|
|
1364
|
+
if ((0, import_loader_utils13.isSourceLoader)(loader)) {
|
|
1365
|
+
throw new Error(`${loader.id} is a SourceLoader. Use load() to create a runtime source object instead of parseFile().`);
|
|
1366
|
+
}
|
|
1171
1367
|
const strictOptions = normalizeOptions(options, loader, candidateLoaders, url);
|
|
1172
1368
|
context = getLoaderContext(
|
|
1173
|
-
// @ts-expect-error
|
|
1369
|
+
// @ts-expect-error candidateLoaders may be a single forced loader
|
|
1174
1370
|
{ url, _parse: parse, loaders: candidateLoaders },
|
|
1175
1371
|
strictOptions,
|
|
1176
1372
|
context || null
|
|
1177
1373
|
);
|
|
1178
|
-
return await
|
|
1374
|
+
return await parseFileWithLoader(loader, file, strictOptions, context);
|
|
1179
1375
|
}
|
|
1180
|
-
async function
|
|
1376
|
+
async function parseFileWithLoader(loader, file, options, context) {
|
|
1181
1377
|
(0, import_worker_utils.validateWorkerVersion)(loader);
|
|
1182
|
-
options = (0,
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
return await (
|
|
1195
|
-
}
|
|
1196
|
-
if (loaderWithParser.parseText && typeof data === "string") {
|
|
1197
|
-
return await loaderWithParser.parseText(data, options, context);
|
|
1198
|
-
}
|
|
1199
|
-
if (loaderWithParser.parse) {
|
|
1200
|
-
return await loaderWithParser.parse(data, options, context);
|
|
1378
|
+
options = (0, import_loader_utils13.mergeOptions)(loader.options, options);
|
|
1379
|
+
const loaderWithParser = await getLoaderImplementation(loader, options, context.url);
|
|
1380
|
+
if (loaderWithParser.parseFile) {
|
|
1381
|
+
return await loaderWithParser.parseFile(file, options, context);
|
|
1382
|
+
}
|
|
1383
|
+
const parseFunction = loaderWithParser.parse;
|
|
1384
|
+
if (parseFunction) {
|
|
1385
|
+
const length = file.bigsize > 0n ? Number(file.bigsize) : file.size;
|
|
1386
|
+
if (!length) {
|
|
1387
|
+
throw new Error(`${loader.id} loader - cannot fall back to parse without a file size`);
|
|
1388
|
+
}
|
|
1389
|
+
const data = await file.read(0n, length);
|
|
1390
|
+
return await parse(data, loaderWithParser, options, context);
|
|
1201
1391
|
}
|
|
1202
|
-
|
|
1203
|
-
throw new Error(`${loader.id} loader - no parser found and worker is disabled`);
|
|
1392
|
+
throw new Error(`${loader.id} loader - no file parser found`);
|
|
1204
1393
|
}
|
|
1205
1394
|
|
|
1206
1395
|
// dist/lib/api/parse-sync.js
|
|
1396
|
+
var import_loader_utils14 = require("@loaders.gl/loader-utils");
|
|
1207
1397
|
function parseSync(data, loaders, options, context) {
|
|
1208
1398
|
if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {
|
|
1209
1399
|
context = void 0;
|
|
@@ -1217,13 +1407,17 @@ function parseSync(data, loaders, options, context) {
|
|
|
1217
1407
|
if (!loader) {
|
|
1218
1408
|
return null;
|
|
1219
1409
|
}
|
|
1410
|
+
if ((0, import_loader_utils14.isSourceLoader)(loader)) {
|
|
1411
|
+
throw new Error(`${loader.id} is a SourceLoader. Use load() to create a runtime source object instead of parseSync().`);
|
|
1412
|
+
}
|
|
1220
1413
|
const strictOptions = normalizeOptions(options, loader, candidateLoaders);
|
|
1221
1414
|
const url = getResourceUrl(data);
|
|
1222
1415
|
const parse2 = () => {
|
|
1223
1416
|
throw new Error("parseSync called parse (which is async");
|
|
1224
1417
|
};
|
|
1225
1418
|
context = getLoaderContext({ url, _parseSync: parse2, _parse: parse2, loaders }, strictOptions, context || null);
|
|
1226
|
-
|
|
1419
|
+
const loaderWithParser = getLoaderImplementationSync(loader);
|
|
1420
|
+
return parseWithLoaderSync(loaderWithParser || loader, data, strictOptions, context);
|
|
1227
1421
|
}
|
|
1228
1422
|
function parseWithLoaderSync(loader, data, options, context) {
|
|
1229
1423
|
data = getArrayBufferOrStringFromDataSync(data, loader, options);
|
|
@@ -1233,6 +1427,9 @@ function parseWithLoaderSync(loader, data, options, context) {
|
|
|
1233
1427
|
if (loader.parseSync && data instanceof ArrayBuffer) {
|
|
1234
1428
|
return loader.parseSync(data, options, context);
|
|
1235
1429
|
}
|
|
1430
|
+
if (loader.preload) {
|
|
1431
|
+
throw new Error(`${loader.name} loader: 'parseSync' requires a parser-bearing loader. Import the loader implementation directly, or call preload(loader) before parseSync(). ${context.url || ""}`);
|
|
1432
|
+
}
|
|
1236
1433
|
throw new Error(`${loader.name} loader: 'parseSync' not supported by this loader, use 'parse' instead. ${context.url || ""}`);
|
|
1237
1434
|
}
|
|
1238
1435
|
|
|
@@ -1255,9 +1452,10 @@ async function parseInBatches(data, loaders, options, context) {
|
|
|
1255
1452
|
}
|
|
1256
1453
|
const strictOptions = normalizeOptions(options, loader, loaderArray, url);
|
|
1257
1454
|
context = getLoaderContext({ url, _parseInBatches: parseInBatches, _parse: parse, loaders: loaderArray }, strictOptions, context || null);
|
|
1258
|
-
|
|
1455
|
+
const loaderWithParser = await getLoaderImplementation(loader, strictOptions, context.url);
|
|
1456
|
+
return await parseWithLoaderInBatches(loader, loaderWithParser, data, strictOptions, context);
|
|
1259
1457
|
}
|
|
1260
|
-
async function parseWithLoaderInBatches(loader, data, options, context) {
|
|
1458
|
+
async function parseWithLoaderInBatches(originalLoader, loader, data, options, context) {
|
|
1261
1459
|
var _a;
|
|
1262
1460
|
const outputIterator = await parseToOutputIterator(loader, data, options, context);
|
|
1263
1461
|
if (!((_a = options == null ? void 0 : options.core) == null ? void 0 : _a.metadata)) {
|
|
@@ -1267,7 +1465,7 @@ async function parseWithLoaderInBatches(loader, data, options, context) {
|
|
|
1267
1465
|
shape: "metadata",
|
|
1268
1466
|
batchType: "metadata",
|
|
1269
1467
|
metadata: {
|
|
1270
|
-
_loader:
|
|
1468
|
+
_loader: originalLoader,
|
|
1271
1469
|
_context: context
|
|
1272
1470
|
},
|
|
1273
1471
|
// Populate with some default fields to avoid crashing
|
|
@@ -1321,6 +1519,34 @@ async function applyInputTransforms(inputIterator, transforms = []) {
|
|
|
1321
1519
|
|
|
1322
1520
|
// dist/lib/api/load.js
|
|
1323
1521
|
var import_loader_utils16 = require("@loaders.gl/loader-utils");
|
|
1522
|
+
|
|
1523
|
+
// dist/lib/api/load-in-batches.js
|
|
1524
|
+
function loadInBatches(files, loaders, options, context) {
|
|
1525
|
+
let loadersArray;
|
|
1526
|
+
if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {
|
|
1527
|
+
context = void 0;
|
|
1528
|
+
options = loaders;
|
|
1529
|
+
loadersArray = void 0;
|
|
1530
|
+
} else {
|
|
1531
|
+
loadersArray = loaders;
|
|
1532
|
+
}
|
|
1533
|
+
const fetch2 = getFetchFunction(options || {});
|
|
1534
|
+
if (!Array.isArray(files)) {
|
|
1535
|
+
return loadOneFileInBatches(files, loadersArray, options || {}, fetch2);
|
|
1536
|
+
}
|
|
1537
|
+
const promises = files.map((file) => loadOneFileInBatches(file, loadersArray, options || {}, fetch2));
|
|
1538
|
+
return promises;
|
|
1539
|
+
}
|
|
1540
|
+
async function loadOneFileInBatches(file, loaders, options, fetch2) {
|
|
1541
|
+
if (typeof file === "string") {
|
|
1542
|
+
const url = file;
|
|
1543
|
+
const response = await fetch2(url);
|
|
1544
|
+
return Array.isArray(loaders) ? await parseInBatches(response, loaders, options) : await parseInBatches(response, loaders, options);
|
|
1545
|
+
}
|
|
1546
|
+
return Array.isArray(loaders) ? await parseInBatches(file, loaders, options) : await parseInBatches(file, loaders, options);
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
// dist/lib/api/load.js
|
|
1324
1550
|
async function load(url, loaders, options, context) {
|
|
1325
1551
|
var _a;
|
|
1326
1552
|
let resolvedLoaders;
|
|
@@ -1333,6 +1559,47 @@ async function load(url, loaders, options, context) {
|
|
|
1333
1559
|
resolvedLoaders = loaders;
|
|
1334
1560
|
resolvedOptions = options;
|
|
1335
1561
|
}
|
|
1562
|
+
if (!Array.isArray(resolvedLoaders) && (0, import_loader_utils16.isSourceLoader)(resolvedLoaders)) {
|
|
1563
|
+
const runtimeCoreApi = {
|
|
1564
|
+
fetchFile,
|
|
1565
|
+
parse,
|
|
1566
|
+
parseFile,
|
|
1567
|
+
parseSync,
|
|
1568
|
+
parseInBatches,
|
|
1569
|
+
load,
|
|
1570
|
+
loadInBatches
|
|
1571
|
+
};
|
|
1572
|
+
return resolvedLoaders.createDataSource(url, resolvedOptions || {}, runtimeCoreApi);
|
|
1573
|
+
}
|
|
1574
|
+
if (Array.isArray(resolvedLoaders) && resolvedLoaders.length === 1 && (0, import_loader_utils16.isSourceLoader)(resolvedLoaders[0])) {
|
|
1575
|
+
const runtimeCoreApi = {
|
|
1576
|
+
fetchFile,
|
|
1577
|
+
parse,
|
|
1578
|
+
parseFile,
|
|
1579
|
+
parseSync,
|
|
1580
|
+
parseInBatches,
|
|
1581
|
+
load,
|
|
1582
|
+
loadInBatches
|
|
1583
|
+
};
|
|
1584
|
+
return resolvedLoaders[0].createDataSource(url, resolvedOptions || {}, runtimeCoreApi);
|
|
1585
|
+
}
|
|
1586
|
+
if (typeof url === "string" || (0, import_loader_utils16.isBlob)(url)) {
|
|
1587
|
+
const selectedLoader = await selectLoader(url, resolvedLoaders, {
|
|
1588
|
+
...resolvedOptions,
|
|
1589
|
+
core: { ...resolvedOptions == null ? void 0 : resolvedOptions.core, nothrow: true }
|
|
1590
|
+
});
|
|
1591
|
+
if (selectedLoader && (0, import_loader_utils16.isSourceLoader)(selectedLoader)) {
|
|
1592
|
+
return selectedLoader.createDataSource(url, resolvedOptions || {}, {
|
|
1593
|
+
fetchFile,
|
|
1594
|
+
parse,
|
|
1595
|
+
parseFile,
|
|
1596
|
+
parseSync,
|
|
1597
|
+
parseInBatches,
|
|
1598
|
+
load,
|
|
1599
|
+
loadInBatches
|
|
1600
|
+
});
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1336
1603
|
const fetch2 = getFetchFunction(resolvedOptions);
|
|
1337
1604
|
let data = url;
|
|
1338
1605
|
if (typeof url === "string") {
|
|
@@ -1353,44 +1620,134 @@ async function load(url, loaders, options, context) {
|
|
|
1353
1620
|
};
|
|
1354
1621
|
}
|
|
1355
1622
|
}
|
|
1356
|
-
return Array.isArray(resolvedLoaders) ? await parse(data, resolvedLoaders, resolvedOptions) : await parse(data, resolvedLoaders, resolvedOptions);
|
|
1623
|
+
return Array.isArray(resolvedLoaders) ? await parse(data, resolvedLoaders, resolvedOptions, context) : await parse(data, resolvedLoaders, resolvedOptions, context);
|
|
1357
1624
|
}
|
|
1358
1625
|
|
|
1359
|
-
// dist/lib/api/
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1626
|
+
// dist/lib/api/core-api.js
|
|
1627
|
+
var coreApi = Object.freeze({
|
|
1628
|
+
fetchFile,
|
|
1629
|
+
parse,
|
|
1630
|
+
parseFile,
|
|
1631
|
+
parseSync,
|
|
1632
|
+
parseInBatches,
|
|
1633
|
+
load,
|
|
1634
|
+
loadInBatches
|
|
1635
|
+
});
|
|
1636
|
+
|
|
1637
|
+
// dist/lib/loader-utils/loader-context.js
|
|
1638
|
+
function getLoaderContext(context, options, parentContext) {
|
|
1639
|
+
if (parentContext) {
|
|
1640
|
+
return parentContext;
|
|
1641
|
+
}
|
|
1642
|
+
const newContext = {
|
|
1643
|
+
...context,
|
|
1644
|
+
fetch: getFetchFunction(options, context),
|
|
1645
|
+
coreApi: context.coreApi || coreApi
|
|
1646
|
+
};
|
|
1647
|
+
if (newContext.url) {
|
|
1648
|
+
const baseUrl = stripQueryString(newContext.url);
|
|
1649
|
+
newContext.baseUrl = baseUrl;
|
|
1650
|
+
newContext.queryString = extractQueryString(newContext.url);
|
|
1651
|
+
newContext.filename = import_loader_utils17.path.filename(baseUrl);
|
|
1652
|
+
newContext.baseUrl = import_loader_utils17.path.dirname(baseUrl);
|
|
1653
|
+
}
|
|
1654
|
+
if (!Array.isArray(newContext.loaders)) {
|
|
1655
|
+
newContext.loaders = null;
|
|
1656
|
+
}
|
|
1657
|
+
return newContext;
|
|
1658
|
+
}
|
|
1659
|
+
function getLoadersFromContext(loaders, context) {
|
|
1660
|
+
if (loaders && !Array.isArray(loaders)) {
|
|
1661
|
+
return loaders;
|
|
1662
|
+
}
|
|
1663
|
+
let candidateLoaders;
|
|
1664
|
+
if (loaders) {
|
|
1665
|
+
candidateLoaders = Array.isArray(loaders) ? loaders : [loaders];
|
|
1666
|
+
}
|
|
1667
|
+
if (context && context.loaders) {
|
|
1668
|
+
const contextLoaders = Array.isArray(context.loaders) ? context.loaders : [context.loaders];
|
|
1669
|
+
candidateLoaders = candidateLoaders ? [...candidateLoaders, ...contextLoaders] : contextLoaders;
|
|
1670
|
+
}
|
|
1671
|
+
return candidateLoaders && candidateLoaders.length ? candidateLoaders : void 0;
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
// dist/lib/api/parse.js
|
|
1675
|
+
async function parse(data, loaders, options, context) {
|
|
1676
|
+
if (loaders && !Array.isArray(loaders) && !isLoaderObject(loaders)) {
|
|
1363
1677
|
context = void 0;
|
|
1364
1678
|
options = loaders;
|
|
1365
|
-
|
|
1366
|
-
} else {
|
|
1367
|
-
loadersArray = loaders;
|
|
1679
|
+
loaders = void 0;
|
|
1368
1680
|
}
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1681
|
+
data = await data;
|
|
1682
|
+
options = options || {};
|
|
1683
|
+
const url = getResourceUrl(data);
|
|
1684
|
+
const typedLoaders = loaders;
|
|
1685
|
+
const candidateLoaders = getLoadersFromContext(typedLoaders, context);
|
|
1686
|
+
const loader = await selectLoader(data, candidateLoaders, options);
|
|
1687
|
+
if (!loader) {
|
|
1688
|
+
return null;
|
|
1372
1689
|
}
|
|
1373
|
-
|
|
1374
|
-
|
|
1690
|
+
if ((0, import_loader_utils18.isSourceLoader)(loader)) {
|
|
1691
|
+
throw new Error(`${loader.id} is a SourceLoader. Use load() to create a runtime source object instead of parse().`);
|
|
1692
|
+
}
|
|
1693
|
+
const strictOptions = normalizeOptions(options, loader, candidateLoaders, url);
|
|
1694
|
+
context = getLoaderContext(
|
|
1695
|
+
// @ts-expect-error
|
|
1696
|
+
{ url, _parse: parse, loaders: candidateLoaders },
|
|
1697
|
+
strictOptions,
|
|
1698
|
+
context || null
|
|
1699
|
+
);
|
|
1700
|
+
return await parseWithLoader(loader, data, strictOptions, context);
|
|
1375
1701
|
}
|
|
1376
|
-
async function
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1702
|
+
async function parseWithLoader(loader, data, options, context) {
|
|
1703
|
+
(0, import_worker_utils2.validateWorkerVersion)(loader);
|
|
1704
|
+
options = (0, import_loader_utils18.mergeOptions)(loader.options, options);
|
|
1705
|
+
if ((0, import_loader_utils18.isResponse)(data)) {
|
|
1706
|
+
const { ok, redirected, status, statusText, type, url } = data;
|
|
1707
|
+
const headers = Object.fromEntries(data.headers.entries());
|
|
1708
|
+
context.response = { headers, ok, redirected, status, statusText, type, url };
|
|
1381
1709
|
}
|
|
1382
|
-
|
|
1710
|
+
const loaderWithParser = await getLoaderImplementation(loader, options, context.url);
|
|
1711
|
+
if ((0, import_loader_utils18.canParseWithWorker)(loaderWithParser, options)) {
|
|
1712
|
+
data = await getArrayBufferFromData(data, options);
|
|
1713
|
+
return await (0, import_loader_utils18.parseWithWorker)(loaderWithParser, data, options, context, parse);
|
|
1714
|
+
}
|
|
1715
|
+
data = await getArrayBufferOrStringFromData(data, loader, options);
|
|
1716
|
+
return await parseWithLoaderImplementation(loaderWithParser, data, options, context);
|
|
1717
|
+
}
|
|
1718
|
+
async function parseWithLoaderImplementation(loader, data, options, context) {
|
|
1719
|
+
if (loader.parseText && typeof data === "string") {
|
|
1720
|
+
return await loader.parseText(data, options, context);
|
|
1721
|
+
}
|
|
1722
|
+
if (loader.parseTextSync && typeof data === "string") {
|
|
1723
|
+
return loader.parseTextSync(data, options, context);
|
|
1724
|
+
}
|
|
1725
|
+
if (loader.parse) {
|
|
1726
|
+
return await loader.parse(data, options, context);
|
|
1727
|
+
}
|
|
1728
|
+
if (loader.parseSync) {
|
|
1729
|
+
throw new Error(`${loader.name} loader: 'parse' not available on parser-bearing sync loader. Add an async 'parse' function to this loader, or call preload(loader) before parseSync(). ${context.url || ""}`);
|
|
1730
|
+
}
|
|
1731
|
+
throw new Error(`${loader.id} loader - no parser found and worker is disabled`);
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
// dist/lib/api/preload.js
|
|
1735
|
+
async function preload(loader, options, url) {
|
|
1736
|
+
return await getLoaderImplementation(loader, options, url);
|
|
1737
|
+
}
|
|
1738
|
+
function preloadSync(loader) {
|
|
1739
|
+
return getLoaderImplementationSync(loader);
|
|
1383
1740
|
}
|
|
1384
1741
|
|
|
1385
1742
|
// dist/lib/api/encode-table.js
|
|
1386
|
-
var
|
|
1743
|
+
var import_loader_utils19 = require("@loaders.gl/loader-utils");
|
|
1387
1744
|
async function encodeTable(data, writer, options) {
|
|
1388
1745
|
if (writer.encode) {
|
|
1389
1746
|
return await writer.encode(data, options);
|
|
1390
1747
|
}
|
|
1391
1748
|
if (writer.encodeText) {
|
|
1392
1749
|
const text = await writer.encodeText(data, options);
|
|
1393
|
-
return (0,
|
|
1750
|
+
return (0, import_loader_utils19.ensureArrayBuffer)(new TextEncoder().encode(text));
|
|
1394
1751
|
}
|
|
1395
1752
|
if (writer.encodeInBatches) {
|
|
1396
1753
|
const batches = encodeTableInBatches(data, writer, options);
|
|
@@ -1398,7 +1755,7 @@ async function encodeTable(data, writer, options) {
|
|
|
1398
1755
|
for await (const batch of batches) {
|
|
1399
1756
|
chunks.push(batch);
|
|
1400
1757
|
}
|
|
1401
|
-
return (0,
|
|
1758
|
+
return (0, import_loader_utils19.concatenateArrayBuffers)(...chunks);
|
|
1402
1759
|
}
|
|
1403
1760
|
throw new Error("Writer could not encode data");
|
|
1404
1761
|
}
|
|
@@ -1425,16 +1782,16 @@ function getIterator(data) {
|
|
|
1425
1782
|
}
|
|
1426
1783
|
|
|
1427
1784
|
// dist/lib/api/encode.js
|
|
1428
|
-
var
|
|
1429
|
-
var
|
|
1785
|
+
var import_loader_utils20 = require("@loaders.gl/loader-utils");
|
|
1786
|
+
var import_worker_utils3 = require("@loaders.gl/worker-utils");
|
|
1430
1787
|
async function encode(data, writer, options_) {
|
|
1431
1788
|
const globalOptions = getGlobalLoaderOptions();
|
|
1432
1789
|
const options = { ...globalOptions, ...options_ };
|
|
1433
1790
|
if (writer.encodeURLtoURL) {
|
|
1434
1791
|
return encodeWithCommandLineTool(writer, data, options);
|
|
1435
1792
|
}
|
|
1436
|
-
if ((0,
|
|
1437
|
-
return await (0,
|
|
1793
|
+
if ((0, import_loader_utils20.canEncodeWithWorker)(writer, options)) {
|
|
1794
|
+
return await (0, import_worker_utils3.processOnWorker)(writer, data, options);
|
|
1438
1795
|
}
|
|
1439
1796
|
return await writer.encode(data, options);
|
|
1440
1797
|
}
|
|
@@ -1443,7 +1800,7 @@ function encodeSync(data, writer, options) {
|
|
|
1443
1800
|
return writer.encodeSync(data, options);
|
|
1444
1801
|
}
|
|
1445
1802
|
if (writer.encodeTextSync) {
|
|
1446
|
-
return (0,
|
|
1803
|
+
return (0, import_loader_utils20.ensureArrayBuffer)(new TextEncoder().encode(writer.encodeTextSync(data, options)));
|
|
1447
1804
|
}
|
|
1448
1805
|
throw new Error(`Writer ${writer.name} could not synchronously encode data`);
|
|
1449
1806
|
}
|
|
@@ -1478,20 +1835,20 @@ function encodeInBatches(data, writer, options) {
|
|
|
1478
1835
|
throw new Error(`Writer ${writer.name} could not encode in batches`);
|
|
1479
1836
|
}
|
|
1480
1837
|
async function encodeURLtoURL(inputUrl, outputUrl, writer, options) {
|
|
1481
|
-
inputUrl = (0,
|
|
1482
|
-
outputUrl = (0,
|
|
1483
|
-
if (
|
|
1838
|
+
inputUrl = (0, import_loader_utils20.resolvePath)(inputUrl);
|
|
1839
|
+
outputUrl = (0, import_loader_utils20.resolvePath)(outputUrl);
|
|
1840
|
+
if (import_loader_utils20.isBrowser || !writer.encodeURLtoURL) {
|
|
1484
1841
|
throw new Error();
|
|
1485
1842
|
}
|
|
1486
1843
|
const outputFilename = await writer.encodeURLtoURL(inputUrl, outputUrl, options);
|
|
1487
1844
|
return outputFilename;
|
|
1488
1845
|
}
|
|
1489
1846
|
async function encodeWithCommandLineTool(writer, data, options) {
|
|
1490
|
-
if (
|
|
1847
|
+
if (import_loader_utils20.isBrowser) {
|
|
1491
1848
|
throw new Error(`Writer ${writer.name} not supported in browser`);
|
|
1492
1849
|
}
|
|
1493
1850
|
const tmpInputFilename = getTemporaryFilename("input");
|
|
1494
|
-
const file = new
|
|
1851
|
+
const file = new import_loader_utils20.NodeFile(tmpInputFilename, "w");
|
|
1495
1852
|
await file.write(data);
|
|
1496
1853
|
const tmpOutputFilename = getTemporaryFilename("output");
|
|
1497
1854
|
const outputFilename = await encodeURLtoURL(tmpInputFilename, tmpOutputFilename, writer, options);
|
|
@@ -1509,20 +1866,18 @@ function getTemporaryFilename(filename) {
|
|
|
1509
1866
|
// dist/lib/api/create-data-source.js
|
|
1510
1867
|
function createDataSource(data, sources, options) {
|
|
1511
1868
|
var _a;
|
|
1512
|
-
const
|
|
1513
|
-
const
|
|
1869
|
+
const resolvedOptions = options || {};
|
|
1870
|
+
const type = ((_a = resolvedOptions == null ? void 0 : resolvedOptions.core) == null ? void 0 : _a.type) || resolvedOptions.type || "auto";
|
|
1871
|
+
const source = sources.length === 1 ? sources[0] : type === "auto" ? selectLoaderSync(data, sources, {
|
|
1872
|
+
// `createDataSource` supports non-fetch inputs such as in-memory tables.
|
|
1873
|
+
// Selection remains best-effort for those cases.
|
|
1874
|
+
...resolvedOptions,
|
|
1875
|
+
core: { ...resolvedOptions == null ? void 0 : resolvedOptions.core, type: "auto" }
|
|
1876
|
+
}) : getSourceOfType(type, sources);
|
|
1514
1877
|
if (!source) {
|
|
1515
1878
|
throw new Error("Not a valid source type");
|
|
1516
1879
|
}
|
|
1517
|
-
return source.createDataSource(data,
|
|
1518
|
-
}
|
|
1519
|
-
function selectSource(url, sources) {
|
|
1520
|
-
for (const service of sources) {
|
|
1521
|
-
if (service.testURL && service.testURL(url)) {
|
|
1522
|
-
return service;
|
|
1523
|
-
}
|
|
1524
|
-
}
|
|
1525
|
-
return null;
|
|
1880
|
+
return source.createDataSource(data, resolvedOptions, coreApi);
|
|
1526
1881
|
}
|
|
1527
1882
|
function getSourceOfType(type, sources) {
|
|
1528
1883
|
for (const service of sources) {
|
|
@@ -1534,15 +1889,11 @@ function getSourceOfType(type, sources) {
|
|
|
1534
1889
|
}
|
|
1535
1890
|
|
|
1536
1891
|
// dist/lib/api/select-source.js
|
|
1537
|
-
function
|
|
1892
|
+
function selectSource(url, sources, options) {
|
|
1538
1893
|
const type = (options == null ? void 0 : options.type) || "auto";
|
|
1539
1894
|
let selectedSource = null;
|
|
1540
1895
|
if (type === "auto") {
|
|
1541
|
-
|
|
1542
|
-
if (typeof url === "string" && source.testURL && source.testURL(url)) {
|
|
1543
|
-
return source;
|
|
1544
|
-
}
|
|
1545
|
-
}
|
|
1896
|
+
selectedSource = selectLoaderSync(url, sources, { core: { nothrow: true } });
|
|
1546
1897
|
} else {
|
|
1547
1898
|
selectedSource = getSourceOfType2(type, sources);
|
|
1548
1899
|
}
|
|
@@ -1561,8 +1912,8 @@ function getSourceOfType2(type, sources) {
|
|
|
1561
1912
|
}
|
|
1562
1913
|
|
|
1563
1914
|
// dist/index.js
|
|
1564
|
-
var
|
|
1565
|
-
var
|
|
1915
|
+
var import_loader_utils22 = require("@loaders.gl/loader-utils");
|
|
1916
|
+
var import_loader_utils23 = require("@loaders.gl/loader-utils");
|
|
1566
1917
|
|
|
1567
1918
|
// dist/iterators/make-stream/make-stream.js
|
|
1568
1919
|
function makeStream(source, options) {
|
|
@@ -1604,7 +1955,7 @@ function makeStream(source, options) {
|
|
|
1604
1955
|
}
|
|
1605
1956
|
|
|
1606
1957
|
// dist/null-loader.js
|
|
1607
|
-
var VERSION = true ? "
|
|
1958
|
+
var VERSION = true ? "5.0.0-alpha.1" : "latest";
|
|
1608
1959
|
var NullWorkerLoader = {
|
|
1609
1960
|
dataType: null,
|
|
1610
1961
|
batchType: null,
|
|
@@ -1646,7 +1997,7 @@ function parseSync2(arrayBuffer, options, context) {
|
|
|
1646
1997
|
}
|
|
1647
1998
|
|
|
1648
1999
|
// dist/index.js
|
|
1649
|
-
var
|
|
2000
|
+
var import_loader_utils24 = require("@loaders.gl/loader-utils");
|
|
1650
2001
|
|
|
1651
2002
|
// dist/lib/progress/fetch-progress.js
|
|
1652
2003
|
async function fetchProgress(response, onProgress, onDone = () => {
|
|
@@ -1696,7 +2047,7 @@ async function read(controller, reader, loadedBytes, totalBytes, onProgress, onD
|
|
|
1696
2047
|
}
|
|
1697
2048
|
|
|
1698
2049
|
// dist/lib/filesystems/browser-filesystem.js
|
|
1699
|
-
var
|
|
2050
|
+
var import_loader_utils21 = require("@loaders.gl/loader-utils");
|
|
1700
2051
|
var BrowserFileSystem = class {
|
|
1701
2052
|
_fetch;
|
|
1702
2053
|
files = {};
|
|
@@ -1778,7 +2129,7 @@ var BrowserFileSystem = class {
|
|
|
1778
2129
|
// implements IRandomAccessFileSystem
|
|
1779
2130
|
// RANDOM ACCESS
|
|
1780
2131
|
async openReadableFile(pathname, flags) {
|
|
1781
|
-
return new
|
|
2132
|
+
return new import_loader_utils21.BlobFile(this.files[pathname]);
|
|
1782
2133
|
}
|
|
1783
2134
|
// PRIVATE
|
|
1784
2135
|
// Supports case independent paths, and file usage tracking
|
|
@@ -1792,9 +2143,9 @@ var BrowserFileSystem = class {
|
|
|
1792
2143
|
};
|
|
1793
2144
|
|
|
1794
2145
|
// dist/index.js
|
|
1795
|
-
var import_loader_utils23 = require("@loaders.gl/loader-utils");
|
|
1796
|
-
var import_loader_utils24 = require("@loaders.gl/loader-utils");
|
|
1797
2146
|
var import_loader_utils25 = require("@loaders.gl/loader-utils");
|
|
1798
2147
|
var import_loader_utils26 = require("@loaders.gl/loader-utils");
|
|
1799
2148
|
var import_loader_utils27 = require("@loaders.gl/loader-utils");
|
|
2149
|
+
var import_loader_utils28 = require("@loaders.gl/loader-utils");
|
|
2150
|
+
var import_loader_utils29 = require("@loaders.gl/loader-utils");
|
|
1800
2151
|
//# sourceMappingURL=index.cjs.map
|