@loaders.gl/core 4.3.4 → 4.4.0-alpha.10
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/README.md +4 -0
- package/dist/core-addons/write-file-browser.js +1 -0
- package/dist/core-addons/write-file-browser.js.map +1 -0
- package/dist/dist.dev.js +384 -160
- package/dist/dist.min.js +3 -3
- package/dist/index.cjs +346 -233
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -0
- package/dist/iterators/batch-iterators/timed-batch-iterator.js +1 -0
- package/dist/iterators/batch-iterators/timed-batch-iterator.js.map +1 -0
- package/dist/iterators/make-iterator/make-array-buffer-iterator.js +1 -0
- package/dist/iterators/make-iterator/make-array-buffer-iterator.js.map +1 -0
- package/dist/iterators/make-iterator/make-blob-iterator.js +1 -0
- package/dist/iterators/make-iterator/make-blob-iterator.js.map +1 -0
- package/dist/iterators/make-iterator/make-iterator.d.ts.map +1 -1
- package/dist/iterators/make-iterator/make-iterator.js +7 -3
- package/dist/iterators/make-iterator/make-iterator.js.map +1 -0
- package/dist/iterators/make-iterator/make-stream-iterator.js +1 -0
- package/dist/iterators/make-iterator/make-stream-iterator.js.map +1 -0
- package/dist/iterators/make-iterator/make-string-iterator.d.ts.map +1 -1
- package/dist/iterators/make-iterator/make-string-iterator.js +3 -1
- package/dist/iterators/make-iterator/make-string-iterator.js.map +1 -0
- package/dist/iterators/make-stream/make-stream.js +1 -0
- package/dist/iterators/make-stream/make-stream.js.map +1 -0
- package/dist/lib/api/create-data-source.d.ts +2 -5
- package/dist/lib/api/create-data-source.d.ts.map +1 -1
- package/dist/lib/api/create-data-source.js +7 -4
- package/dist/lib/api/create-data-source.js.map +1 -0
- package/dist/lib/api/encode-table.d.ts +1 -1
- package/dist/lib/api/encode-table.d.ts.map +1 -1
- package/dist/lib/api/encode-table.js +3 -2
- package/dist/lib/api/encode-table.js.map +1 -0
- package/dist/lib/api/encode.d.ts.map +1 -1
- package/dist/lib/api/encode.js +3 -2
- package/dist/lib/api/encode.js.map +1 -0
- package/dist/lib/api/load-in-batches.js +1 -0
- package/dist/lib/api/load-in-batches.js.map +1 -0
- package/dist/lib/api/load.js +2 -1
- package/dist/lib/api/load.js.map +1 -0
- package/dist/lib/api/loader-options.js +1 -0
- package/dist/lib/api/loader-options.js.map +1 -0
- package/dist/lib/api/parse-in-batches.d.ts.map +1 -1
- package/dist/lib/api/parse-in-batches.js +11 -8
- package/dist/lib/api/parse-in-batches.js.map +1 -0
- package/dist/lib/api/parse-sync.d.ts.map +1 -1
- package/dist/lib/api/parse-sync.js +4 -3
- package/dist/lib/api/parse-sync.js.map +1 -0
- package/dist/lib/api/parse.d.ts.map +1 -1
- package/dist/lib/api/parse.js +9 -10
- package/dist/lib/api/parse.js.map +1 -0
- package/dist/lib/api/register-loaders.js +1 -0
- package/dist/lib/api/register-loaders.js.map +1 -0
- package/dist/lib/api/select-loader.d.ts +3 -3
- package/dist/lib/api/select-loader.d.ts.map +1 -1
- package/dist/lib/api/select-loader.js +20 -15
- package/dist/lib/api/select-loader.js.map +1 -0
- package/dist/lib/api/select-source.js +1 -0
- package/dist/lib/api/select-source.js.map +1 -0
- package/dist/lib/common.js +1 -0
- package/dist/lib/common.js.map +1 -0
- package/dist/lib/fetch/fetch-error-message.js +1 -0
- package/dist/lib/fetch/fetch-error-message.js.map +1 -0
- package/dist/lib/fetch/fetch-error.js +1 -0
- package/dist/lib/fetch/fetch-error.js.map +1 -0
- package/dist/lib/fetch/fetch-file.js +1 -0
- package/dist/lib/fetch/fetch-file.js.map +1 -0
- package/dist/lib/fetch/read-array-buffer.js +1 -0
- package/dist/lib/fetch/read-array-buffer.js.map +1 -0
- package/dist/lib/filesystems/browser-filesystem.js +1 -0
- package/dist/lib/filesystems/browser-filesystem.js.map +1 -0
- package/dist/lib/filesystems/read-array-buffer.js +1 -0
- package/dist/lib/filesystems/read-array-buffer.js.map +1 -0
- package/dist/lib/init.js +2 -1
- package/dist/lib/init.js.map +1 -0
- package/dist/lib/loader-utils/check-errors.js +1 -0
- package/dist/lib/loader-utils/check-errors.js.map +1 -0
- package/dist/lib/loader-utils/get-data.d.ts +18 -1
- package/dist/lib/loader-utils/get-data.d.ts.map +1 -1
- package/dist/lib/loader-utils/get-data.js +47 -38
- package/dist/lib/loader-utils/get-data.js.map +1 -0
- package/dist/lib/loader-utils/get-fetch-function.d.ts.map +1 -1
- package/dist/lib/loader-utils/get-fetch-function.js +7 -5
- package/dist/lib/loader-utils/get-fetch-function.js.map +1 -0
- package/dist/lib/loader-utils/loader-context.d.ts +2 -2
- package/dist/lib/loader-utils/loader-context.d.ts.map +1 -1
- package/dist/lib/loader-utils/loader-context.js +1 -0
- package/dist/lib/loader-utils/loader-context.js.map +1 -0
- package/dist/lib/loader-utils/loggers.js +1 -0
- package/dist/lib/loader-utils/loggers.js.map +1 -0
- package/dist/lib/loader-utils/normalize-loader.js +1 -0
- package/dist/lib/loader-utils/normalize-loader.js.map +1 -0
- package/dist/lib/loader-utils/option-defaults.d.ts +22 -0
- package/dist/lib/loader-utils/option-defaults.d.ts.map +1 -1
- package/dist/lib/loader-utils/option-defaults.js +50 -20
- package/dist/lib/loader-utils/option-defaults.js.map +1 -0
- package/dist/lib/loader-utils/option-utils.d.ts +9 -3
- package/dist/lib/loader-utils/option-utils.d.ts.map +1 -1
- package/dist/lib/loader-utils/option-utils.js +108 -13
- package/dist/lib/loader-utils/option-utils.js.map +1 -0
- package/dist/lib/progress/fetch-progress.js +1 -0
- package/dist/lib/progress/fetch-progress.js.map +1 -0
- package/dist/lib/utils/mime-type-utils.js +1 -0
- package/dist/lib/utils/mime-type-utils.js.map +1 -0
- package/dist/lib/utils/resource-utils.d.ts.map +1 -1
- package/dist/lib/utils/resource-utils.js +8 -10
- package/dist/lib/utils/resource-utils.js.map +1 -0
- package/dist/lib/utils/response-utils.js +2 -1
- package/dist/lib/utils/response-utils.js.map +1 -0
- package/dist/lib/utils/url-utils.js +1 -0
- package/dist/lib/utils/url-utils.js.map +1 -0
- package/dist/null-loader.d.ts +3 -3
- package/dist/null-loader.d.ts.map +1 -1
- package/dist/null-loader.js +2 -1
- package/dist/null-loader.js.map +1 -0
- package/dist/null-worker-node.js +5 -2
- package/dist/null-worker.js +5 -2
- package/dist/workers/null-worker-node.js +1 -0
- package/dist/workers/null-worker-node.js.map +1 -0
- package/dist/workers/null-worker.js +1 -0
- package/dist/workers/null-worker.js.map +1 -0
- package/package.json +12 -5
- package/src/index.ts +1 -1
- package/src/iterators/make-iterator/make-iterator.ts +8 -5
- package/src/iterators/make-iterator/make-string-iterator.ts +2 -1
- package/src/lib/api/create-data-source.ts +16 -11
- package/src/lib/api/encode-table.ts +3 -2
- package/src/lib/api/encode.ts +8 -2
- package/src/lib/api/load.ts +1 -1
- package/src/lib/api/parse-in-batches.ts +31 -22
- package/src/lib/api/parse-sync.ts +6 -5
- package/src/lib/api/parse.ts +16 -12
- package/src/lib/api/select-loader.ts +43 -25
- package/src/lib/loader-utils/get-data.ts +62 -48
- package/src/lib/loader-utils/get-fetch-function.ts +6 -5
- package/src/lib/loader-utils/loader-context.ts +2 -2
- package/src/lib/loader-utils/option-defaults.ts +54 -22
- package/src/lib/loader-utils/option-utils.ts +125 -19
- package/src/lib/utils/resource-utils.ts +9 -12
- package/src/lib/utils/response-utils.ts +2 -2
- package/src/null-loader.ts +6 -3
- package/dist/javascript-utils/is-type.d.ts +0 -21
- package/dist/javascript-utils/is-type.d.ts.map +0 -1
- package/dist/javascript-utils/is-type.js +0 -25
- package/src/javascript-utils/is-type.ts +0 -51
package/dist/dist.dev.js
CHANGED
|
@@ -117,14 +117,14 @@ var __exports__ = (() => {
|
|
|
117
117
|
var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
118
118
|
var nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
119
119
|
|
|
120
|
-
// ../../node_modules/@probe.gl/
|
|
120
|
+
// ../../node_modules/@probe.gl/env/dist/lib/globals.js
|
|
121
121
|
var window_2 = globalThis;
|
|
122
122
|
var document_2 = globalThis.document || {};
|
|
123
123
|
var process_ = globalThis.process || {};
|
|
124
124
|
var console_ = globalThis.console;
|
|
125
125
|
var navigator_ = globalThis.navigator || {};
|
|
126
126
|
|
|
127
|
-
// ../../node_modules/@probe.gl/
|
|
127
|
+
// ../../node_modules/@probe.gl/env/dist/lib/is-electron.js
|
|
128
128
|
function isElectron(mockUserAgent) {
|
|
129
129
|
if (typeof window !== "undefined" && window.process?.type === "renderer") {
|
|
130
130
|
return true;
|
|
@@ -137,7 +137,7 @@ var __exports__ = (() => {
|
|
|
137
137
|
return Boolean(userAgent && userAgent.indexOf("Electron") >= 0);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
// ../../node_modules/@probe.gl/
|
|
140
|
+
// ../../node_modules/@probe.gl/env/dist/lib/is-browser.js
|
|
141
141
|
function isBrowser2() {
|
|
142
142
|
const isNode = (
|
|
143
143
|
// @ts-expect-error
|
|
@@ -146,7 +146,7 @@ var __exports__ = (() => {
|
|
|
146
146
|
return !isNode || isElectron();
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
// ../../node_modules/@probe.gl/
|
|
149
|
+
// ../../node_modules/@probe.gl/env/dist/index.js
|
|
150
150
|
var VERSION = true ? "4.0.7" : "untranspiled source";
|
|
151
151
|
|
|
152
152
|
// ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
|
|
@@ -562,8 +562,28 @@ var __exports__ = (() => {
|
|
|
562
562
|
}
|
|
563
563
|
var log = createLog();
|
|
564
564
|
|
|
565
|
-
// ../loader-utils/src/lib/
|
|
566
|
-
|
|
565
|
+
// ../loader-utils/src/lib/javascript-utils/is-type.ts
|
|
566
|
+
var isBoolean = (value) => typeof value === "boolean";
|
|
567
|
+
var isFunction = (value) => typeof value === "function";
|
|
568
|
+
var isObject = (value) => value !== null && typeof value === "object";
|
|
569
|
+
var isPureObject = (value) => isObject(value) && value.constructor === {}.constructor;
|
|
570
|
+
var isSharedArrayBuffer = (value) => typeof SharedArrayBuffer !== "undefined" && value instanceof SharedArrayBuffer;
|
|
571
|
+
var isArrayBufferLike = (value) => isObject(value) && typeof value.byteLength === "number" && typeof value.slice === "function";
|
|
572
|
+
var isPromise = (value) => isObject(value) && "then" in value && isFunction(value.then);
|
|
573
|
+
var isIterable = (value) => Boolean(value) && isFunction(value[Symbol.iterator]);
|
|
574
|
+
var isAsyncIterable = (value) => Boolean(value) && isFunction(value[Symbol.asyncIterator]);
|
|
575
|
+
var isIterator = (value) => Boolean(value) && isFunction(value.next);
|
|
576
|
+
var isResponse = (value) => typeof Response !== "undefined" && value instanceof Response || isObject(value) && isFunction(value.arrayBuffer) && isFunction(value.text) && isFunction(value.json);
|
|
577
|
+
var isBlob = (value) => typeof Blob !== "undefined" && value instanceof Blob;
|
|
578
|
+
var isWritableDOMStream = (value) => isObject(value) && isFunction(value.abort) && isFunction(value.getWriter);
|
|
579
|
+
var isReadableDOMStream = (value) => typeof ReadableStream !== "undefined" && value instanceof ReadableStream || isObject(value) && isFunction(value.tee) && isFunction(value.cancel) && isFunction(value.getReader);
|
|
580
|
+
var isWritableNodeStream = (value) => isObject(value) && isFunction(value.end) && isFunction(value.write) && isBoolean(value.writable);
|
|
581
|
+
var isReadableNodeStream = (value) => isObject(value) && isFunction(value.read) && isFunction(value.pipe) && isBoolean(value.readable);
|
|
582
|
+
var isReadableStream = (value) => isReadableDOMStream(value) || isReadableNodeStream(value);
|
|
583
|
+
var isWritableStream = (value) => isWritableDOMStream(value) || isWritableNodeStream(value);
|
|
584
|
+
|
|
585
|
+
// ../loader-utils/src/lib/option-utils/merge-options.ts
|
|
586
|
+
function mergeOptions(baseOptions, newOptions) {
|
|
567
587
|
return mergeOptionsRecursively(baseOptions || {}, newOptions);
|
|
568
588
|
}
|
|
569
589
|
function mergeOptionsRecursively(baseOptions, newOptions, level = 0) {
|
|
@@ -592,16 +612,20 @@ var __exports__ = (() => {
|
|
|
592
612
|
Object.assign(globalThis.loaders.modules, modules);
|
|
593
613
|
}
|
|
594
614
|
|
|
615
|
+
// ../worker-utils/src/lib/npm-tag.ts
|
|
616
|
+
var NPM_TAG = "beta";
|
|
617
|
+
|
|
595
618
|
// ../worker-utils/src/lib/env-utils/version.ts
|
|
596
|
-
var
|
|
619
|
+
var warningIssued = false;
|
|
597
620
|
function getVersion() {
|
|
598
621
|
if (!globalThis._loadersgl_?.version) {
|
|
599
622
|
globalThis._loadersgl_ = globalThis._loadersgl_ || {};
|
|
600
|
-
if (typeof __VERSION__ === "undefined") {
|
|
623
|
+
if (typeof __VERSION__ === "undefined" && !warningIssued) {
|
|
601
624
|
console.warn(
|
|
602
625
|
"loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN."
|
|
603
626
|
);
|
|
604
627
|
globalThis._loadersgl_.version = NPM_TAG;
|
|
628
|
+
warningIssued = true;
|
|
605
629
|
} else {
|
|
606
630
|
globalThis._loadersgl_.version = __VERSION__;
|
|
607
631
|
}
|
|
@@ -873,7 +897,8 @@ var __exports__ = (() => {
|
|
|
873
897
|
if (this.url) {
|
|
874
898
|
const absolute = this.url.includes(":/") || this.url.startsWith("/");
|
|
875
899
|
const url = absolute ? this.url : `./${this.url}`;
|
|
876
|
-
|
|
900
|
+
const type = this.url.endsWith(".ts") || this.url.endsWith(".mjs") ? "module" : "commonjs";
|
|
901
|
+
worker = new NodeWorker(url, { eval: false, type });
|
|
877
902
|
} else if (this.source) {
|
|
878
903
|
worker = new NodeWorker(this.source, { eval: true });
|
|
879
904
|
} else {
|
|
@@ -1129,7 +1154,8 @@ var __exports__ = (() => {
|
|
|
1129
1154
|
if (!url && worker.id === "compression") {
|
|
1130
1155
|
url = options.workerUrl;
|
|
1131
1156
|
}
|
|
1132
|
-
|
|
1157
|
+
const workerType = options._workerType || options?.core?._workerType;
|
|
1158
|
+
if (workerType === "test") {
|
|
1133
1159
|
if (isBrowser3) {
|
|
1134
1160
|
url = `modules/${worker.module}/dist/${workerFile}`;
|
|
1135
1161
|
} else {
|
|
@@ -1211,15 +1237,17 @@ var __exports__ = (() => {
|
|
|
1211
1237
|
if (!WorkerFarm.isSupported()) {
|
|
1212
1238
|
return false;
|
|
1213
1239
|
}
|
|
1214
|
-
|
|
1240
|
+
const nodeWorkers = options?._nodeWorkers ?? options?.core?._nodeWorkers;
|
|
1241
|
+
if (!isBrowser3 && !nodeWorkers) {
|
|
1215
1242
|
return false;
|
|
1216
1243
|
}
|
|
1217
|
-
|
|
1244
|
+
const useWorkers = options?.worker ?? options?.core?.worker;
|
|
1245
|
+
return Boolean(loader.worker && useWorkers);
|
|
1218
1246
|
}
|
|
1219
1247
|
async function parseWithWorker(loader, data, options, context, parseOnMainThread) {
|
|
1220
1248
|
const name = loader.id;
|
|
1221
1249
|
const url = getWorkerURL(loader, options);
|
|
1222
|
-
const workerFarm = WorkerFarm.getWorkerFarm(options);
|
|
1250
|
+
const workerFarm = WorkerFarm.getWorkerFarm(options?.core);
|
|
1223
1251
|
const workerPool = workerFarm.getWorkerPool({ name, url });
|
|
1224
1252
|
options = JSON.parse(JSON.stringify(options));
|
|
1225
1253
|
context = JSON.parse(JSON.stringify(context || {}));
|
|
@@ -1266,10 +1294,12 @@ var __exports__ = (() => {
|
|
|
1266
1294
|
if (!WorkerFarm.isSupported()) {
|
|
1267
1295
|
return false;
|
|
1268
1296
|
}
|
|
1269
|
-
|
|
1297
|
+
const nodeWorkers = options?._nodeWorkers ?? options?.core?._nodeWorkers;
|
|
1298
|
+
const useWorkers = options?.worker ?? options?.core?.worker;
|
|
1299
|
+
if (!isBrowser && !nodeWorkers) {
|
|
1270
1300
|
return false;
|
|
1271
1301
|
}
|
|
1272
|
-
return writer.worker &&
|
|
1302
|
+
return Boolean(writer.worker && useWorkers);
|
|
1273
1303
|
}
|
|
1274
1304
|
|
|
1275
1305
|
// ../loader-utils/src/lib/binary-utils/array-buffer-utils.ts
|
|
@@ -1314,7 +1344,7 @@ var __exports__ = (() => {
|
|
|
1314
1344
|
async function* makeTextEncoderIterator(textIterator) {
|
|
1315
1345
|
const textEncoder = new TextEncoder();
|
|
1316
1346
|
for await (const text of textIterator) {
|
|
1317
|
-
yield typeof text === "string" ? textEncoder.encode(text) : text;
|
|
1347
|
+
yield typeof text === "string" ? textEncoder.encode(text).buffer : text;
|
|
1318
1348
|
}
|
|
1319
1349
|
}
|
|
1320
1350
|
async function* makeLineIterator(textIterator) {
|
|
@@ -1341,11 +1371,14 @@ var __exports__ = (() => {
|
|
|
1341
1371
|
}
|
|
1342
1372
|
|
|
1343
1373
|
// ../loader-utils/src/lib/iterators/async-iteration.ts
|
|
1344
|
-
async function forEach(
|
|
1374
|
+
async function forEach(iterable, visitor) {
|
|
1375
|
+
const iterator = toAsyncIterator(iterable);
|
|
1345
1376
|
while (true) {
|
|
1346
1377
|
const { done, value } = await iterator.next();
|
|
1347
1378
|
if (done) {
|
|
1348
|
-
iterator.return
|
|
1379
|
+
if (iterator.return) {
|
|
1380
|
+
iterator.return();
|
|
1381
|
+
}
|
|
1349
1382
|
return;
|
|
1350
1383
|
}
|
|
1351
1384
|
const cancel = visitor(value);
|
|
@@ -1357,10 +1390,55 @@ var __exports__ = (() => {
|
|
|
1357
1390
|
async function concatenateArrayBuffersAsync(asyncIterator) {
|
|
1358
1391
|
const arrayBuffers = [];
|
|
1359
1392
|
for await (const chunk of asyncIterator) {
|
|
1360
|
-
arrayBuffers.push(chunk);
|
|
1393
|
+
arrayBuffers.push(copyToArrayBuffer(chunk));
|
|
1361
1394
|
}
|
|
1362
1395
|
return concatenateArrayBuffers(...arrayBuffers);
|
|
1363
1396
|
}
|
|
1397
|
+
function copyToArrayBuffer(chunk) {
|
|
1398
|
+
if (chunk instanceof ArrayBuffer) {
|
|
1399
|
+
return chunk;
|
|
1400
|
+
}
|
|
1401
|
+
if (ArrayBuffer.isView(chunk)) {
|
|
1402
|
+
const { buffer, byteOffset, byteLength } = chunk;
|
|
1403
|
+
return copyFromBuffer(buffer, byteOffset, byteLength);
|
|
1404
|
+
}
|
|
1405
|
+
return copyFromBuffer(chunk);
|
|
1406
|
+
}
|
|
1407
|
+
function copyFromBuffer(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
|
|
1408
|
+
const view = new Uint8Array(buffer, byteOffset, byteLength);
|
|
1409
|
+
const copy = new Uint8Array(view.length);
|
|
1410
|
+
copy.set(view);
|
|
1411
|
+
return copy.buffer;
|
|
1412
|
+
}
|
|
1413
|
+
function toAsyncIterator(iterable) {
|
|
1414
|
+
if (typeof iterable[Symbol.asyncIterator] === "function") {
|
|
1415
|
+
return iterable[Symbol.asyncIterator]();
|
|
1416
|
+
}
|
|
1417
|
+
if (typeof iterable[Symbol.iterator] === "function") {
|
|
1418
|
+
const iterator = iterable[Symbol.iterator]();
|
|
1419
|
+
return iteratorToAsyncIterator(iterator);
|
|
1420
|
+
}
|
|
1421
|
+
return iterable;
|
|
1422
|
+
}
|
|
1423
|
+
function iteratorToAsyncIterator(iterator) {
|
|
1424
|
+
return {
|
|
1425
|
+
next(value) {
|
|
1426
|
+
return Promise.resolve(iterator.next(value));
|
|
1427
|
+
},
|
|
1428
|
+
return(value) {
|
|
1429
|
+
if (typeof iterator.return === "function") {
|
|
1430
|
+
return Promise.resolve(iterator.return(value));
|
|
1431
|
+
}
|
|
1432
|
+
return Promise.resolve({ done: true, value });
|
|
1433
|
+
},
|
|
1434
|
+
throw(error) {
|
|
1435
|
+
if (typeof iterator.throw === "function") {
|
|
1436
|
+
return Promise.resolve(iterator.throw(error));
|
|
1437
|
+
}
|
|
1438
|
+
return Promise.reject(error);
|
|
1439
|
+
}
|
|
1440
|
+
};
|
|
1441
|
+
}
|
|
1364
1442
|
|
|
1365
1443
|
// ../../node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js
|
|
1366
1444
|
function getHiResTimestamp2() {
|
|
@@ -1590,6 +1668,20 @@ var __exports__ = (() => {
|
|
|
1590
1668
|
this.stats.get(STAT_QUEUED_REQUESTS_EVER);
|
|
1591
1669
|
this.stats.get(STAT_ACTIVE_REQUESTS_EVER);
|
|
1592
1670
|
}
|
|
1671
|
+
/**
|
|
1672
|
+
* Update scheduler props. Preserves active and queued requests.
|
|
1673
|
+
*/
|
|
1674
|
+
setProps(props) {
|
|
1675
|
+
if (props.throttleRequests !== void 0) {
|
|
1676
|
+
this.props.throttleRequests = props.throttleRequests;
|
|
1677
|
+
}
|
|
1678
|
+
if (props.maxRequests !== void 0) {
|
|
1679
|
+
this.props.maxRequests = props.maxRequests;
|
|
1680
|
+
}
|
|
1681
|
+
if (props.debounceTime !== void 0) {
|
|
1682
|
+
this.props.debounceTime = props.debounceTime;
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1593
1685
|
/**
|
|
1594
1686
|
* Called by an application that wants to issue a request, without having it deeply queued by the browser
|
|
1595
1687
|
*
|
|
@@ -1747,11 +1839,15 @@ var __exports__ = (() => {
|
|
|
1747
1839
|
if (data instanceof ArrayBuffer) {
|
|
1748
1840
|
return data;
|
|
1749
1841
|
}
|
|
1842
|
+
if (isSharedArrayBuffer(data)) {
|
|
1843
|
+
return copyToArrayBuffer2(data);
|
|
1844
|
+
}
|
|
1750
1845
|
if (ArrayBuffer.isView(data)) {
|
|
1846
|
+
const buffer = data.buffer;
|
|
1751
1847
|
if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
|
|
1752
|
-
return
|
|
1848
|
+
return buffer;
|
|
1753
1849
|
}
|
|
1754
|
-
return
|
|
1850
|
+
return buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
1755
1851
|
}
|
|
1756
1852
|
if (typeof data === "string") {
|
|
1757
1853
|
const text = data;
|
|
@@ -1763,6 +1859,31 @@ var __exports__ = (() => {
|
|
|
1763
1859
|
}
|
|
1764
1860
|
throw new Error("toArrayBuffer");
|
|
1765
1861
|
}
|
|
1862
|
+
function ensureArrayBuffer(bufferSource) {
|
|
1863
|
+
if (bufferSource instanceof ArrayBuffer) {
|
|
1864
|
+
return bufferSource;
|
|
1865
|
+
}
|
|
1866
|
+
if (isSharedArrayBuffer(bufferSource)) {
|
|
1867
|
+
return copyToArrayBuffer2(bufferSource);
|
|
1868
|
+
}
|
|
1869
|
+
const { buffer, byteOffset, byteLength } = bufferSource;
|
|
1870
|
+
if (buffer instanceof ArrayBuffer && byteOffset === 0 && byteLength === buffer.byteLength) {
|
|
1871
|
+
return buffer;
|
|
1872
|
+
}
|
|
1873
|
+
return copyToArrayBuffer2(buffer, byteOffset, byteLength);
|
|
1874
|
+
}
|
|
1875
|
+
function copyToArrayBuffer2(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
|
|
1876
|
+
const view = new Uint8Array(buffer, byteOffset, byteLength);
|
|
1877
|
+
const copy = new Uint8Array(view.length);
|
|
1878
|
+
copy.set(view);
|
|
1879
|
+
return copy.buffer;
|
|
1880
|
+
}
|
|
1881
|
+
function toArrayBufferView(data) {
|
|
1882
|
+
if (ArrayBuffer.isView(data)) {
|
|
1883
|
+
return data;
|
|
1884
|
+
}
|
|
1885
|
+
return new Uint8Array(data);
|
|
1886
|
+
}
|
|
1766
1887
|
|
|
1767
1888
|
// ../loader-utils/src/lib/path-utils/path.ts
|
|
1768
1889
|
var path_exports = {};
|
|
@@ -1785,7 +1906,7 @@ var __exports__ = (() => {
|
|
|
1785
1906
|
// ../loader-utils/src/lib/path-utils/path.ts
|
|
1786
1907
|
function filename(url) {
|
|
1787
1908
|
const slashIndex = url ? url.lastIndexOf("/") : -1;
|
|
1788
|
-
return slashIndex >= 0 ? url.substr(slashIndex + 1) :
|
|
1909
|
+
return slashIndex >= 0 ? url.substr(slashIndex + 1) : url;
|
|
1789
1910
|
}
|
|
1790
1911
|
function dirname(url) {
|
|
1791
1912
|
const slashIndex = url ? url.lastIndexOf("/") : -1;
|
|
@@ -1975,25 +2096,6 @@ var __exports__ = (() => {
|
|
|
1975
2096
|
}
|
|
1976
2097
|
};
|
|
1977
2098
|
|
|
1978
|
-
// src/javascript-utils/is-type.ts
|
|
1979
|
-
var isBoolean = (x) => typeof x === "boolean";
|
|
1980
|
-
var isFunction = (x) => typeof x === "function";
|
|
1981
|
-
var isObject = (x) => x !== null && typeof x === "object";
|
|
1982
|
-
var isPureObject = (x) => isObject(x) && x.constructor === {}.constructor;
|
|
1983
|
-
var isPromise = (x) => isObject(x) && isFunction(x.then);
|
|
1984
|
-
var isIterable = (x) => Boolean(x) && typeof x[Symbol.iterator] === "function";
|
|
1985
|
-
var isAsyncIterable = (x) => x && typeof x[Symbol.asyncIterator] === "function";
|
|
1986
|
-
var isIterator = (x) => x && isFunction(x.next);
|
|
1987
|
-
var isResponse = (x) => typeof Response !== "undefined" && x instanceof Response || x && x.arrayBuffer && x.text && x.json;
|
|
1988
|
-
var isBlob = (x) => typeof Blob !== "undefined" && x instanceof Blob;
|
|
1989
|
-
var isBuffer2 = (x) => x && typeof x === "object" && x.isBuffer;
|
|
1990
|
-
var isWritableDOMStream = (x) => isObject(x) && isFunction(x.abort) && isFunction(x.getWriter);
|
|
1991
|
-
var isReadableDOMStream = (x) => typeof ReadableStream !== "undefined" && x instanceof ReadableStream || isObject(x) && isFunction(x.tee) && isFunction(x.cancel) && isFunction(x.getReader);
|
|
1992
|
-
var isWritableNodeStream = (x) => isObject(x) && isFunction(x.end) && isFunction(x.write) && isBoolean(x.writable);
|
|
1993
|
-
var isReadableNodeStream = (x) => isObject(x) && isFunction(x.read) && isFunction(x.pipe) && isBoolean(x.readable);
|
|
1994
|
-
var isReadableStream = (x) => isReadableDOMStream(x) || isReadableNodeStream(x);
|
|
1995
|
-
var isWritableStream = (x) => isWritableDOMStream(x) || isWritableNodeStream(x);
|
|
1996
|
-
|
|
1997
2099
|
// src/lib/fetch/fetch-error.ts
|
|
1998
2100
|
var FetchError = class extends Error {
|
|
1999
2101
|
constructor(message, info) {
|
|
@@ -2055,12 +2157,11 @@ var __exports__ = (() => {
|
|
|
2055
2157
|
// src/lib/utils/resource-utils.ts
|
|
2056
2158
|
function getResourceUrl(resource) {
|
|
2057
2159
|
if (isResponse(resource)) {
|
|
2058
|
-
|
|
2059
|
-
return response.url;
|
|
2160
|
+
return resource.url;
|
|
2060
2161
|
}
|
|
2061
2162
|
if (isBlob(resource)) {
|
|
2062
|
-
const
|
|
2063
|
-
return
|
|
2163
|
+
const fileName = "name" in resource ? resource.name : "";
|
|
2164
|
+
return fileName || "";
|
|
2064
2165
|
}
|
|
2065
2166
|
if (typeof resource === "string") {
|
|
2066
2167
|
return resource;
|
|
@@ -2069,14 +2170,12 @@ var __exports__ = (() => {
|
|
|
2069
2170
|
}
|
|
2070
2171
|
function getResourceMIMEType(resource) {
|
|
2071
2172
|
if (isResponse(resource)) {
|
|
2072
|
-
const
|
|
2073
|
-
const
|
|
2074
|
-
const noQueryUrl = stripQueryString(response.url);
|
|
2173
|
+
const contentTypeHeader = resource.headers.get("content-type") || "";
|
|
2174
|
+
const noQueryUrl = stripQueryString(resource.url);
|
|
2075
2175
|
return parseMIMEType(contentTypeHeader) || parseMIMETypeFromURL(noQueryUrl);
|
|
2076
2176
|
}
|
|
2077
2177
|
if (isBlob(resource)) {
|
|
2078
|
-
|
|
2079
|
-
return blob.type || "";
|
|
2178
|
+
return resource.type || "";
|
|
2080
2179
|
}
|
|
2081
2180
|
if (typeof resource === "string") {
|
|
2082
2181
|
return parseMIMETypeFromURL(resource);
|
|
@@ -2262,39 +2361,68 @@ var __exports__ = (() => {
|
|
|
2262
2361
|
|
|
2263
2362
|
// src/lib/loader-utils/option-defaults.ts
|
|
2264
2363
|
var DEFAULT_LOADER_OPTIONS = {
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2364
|
+
core: {
|
|
2365
|
+
baseUri: void 0,
|
|
2366
|
+
// baseUri
|
|
2367
|
+
fetch: null,
|
|
2368
|
+
mimeType: void 0,
|
|
2369
|
+
fallbackMimeType: void 0,
|
|
2370
|
+
ignoreRegisteredLoaders: void 0,
|
|
2371
|
+
nothrow: false,
|
|
2372
|
+
log: new ConsoleLog(),
|
|
2373
|
+
// A probe.gl compatible (`log.log()()` syntax) that just logs to console
|
|
2374
|
+
useLocalLibraries: false,
|
|
2375
|
+
CDN: "https://unpkg.com/@loaders.gl",
|
|
2376
|
+
worker: true,
|
|
2377
|
+
// By default, use worker if provided by loader.
|
|
2378
|
+
maxConcurrency: 3,
|
|
2379
|
+
// How many worker instances should be created for each loader.
|
|
2380
|
+
maxMobileConcurrency: 1,
|
|
2381
|
+
// How many worker instances should be created for each loader on mobile devices.
|
|
2382
|
+
reuseWorkers: isBrowser,
|
|
2383
|
+
// By default reuse workers in browser (Node.js refuses to terminate if browsers are running)
|
|
2384
|
+
_nodeWorkers: false,
|
|
2385
|
+
// By default do not support node workers
|
|
2386
|
+
_workerType: "",
|
|
2387
|
+
// 'test' to use locally generated workers
|
|
2388
|
+
limit: 0,
|
|
2389
|
+
_limitMB: 0,
|
|
2390
|
+
batchSize: "auto",
|
|
2391
|
+
batchDebounceMs: 0,
|
|
2392
|
+
metadata: false,
|
|
2393
|
+
// TODO - currently only implemented for parseInBatches, adds initial metadata batch,
|
|
2394
|
+
transforms: []
|
|
2395
|
+
}
|
|
2292
2396
|
};
|
|
2293
2397
|
var REMOVED_LOADER_OPTIONS = {
|
|
2398
|
+
// baseUri
|
|
2399
|
+
baseUri: "core.baseUri",
|
|
2400
|
+
fetch: "core.fetch",
|
|
2401
|
+
mimeType: "core.mimeType",
|
|
2402
|
+
fallbackMimeType: "core.fallbackMimeType",
|
|
2403
|
+
ignoreRegisteredLoaders: "core.ignoreRegisteredLoaders",
|
|
2404
|
+
nothrow: "core.nothrow",
|
|
2405
|
+
log: "core.log",
|
|
2406
|
+
useLocalLibraries: "core.useLocalLibraries",
|
|
2407
|
+
CDN: "core.CDN",
|
|
2408
|
+
worker: "core.worker",
|
|
2409
|
+
maxConcurrency: "core.maxConcurrency",
|
|
2410
|
+
maxMobileConcurrency: "core.maxMobileConcurrency",
|
|
2411
|
+
reuseWorkers: "core.reuseWorkers",
|
|
2412
|
+
_nodeWorkers: "core.nodeWorkers",
|
|
2413
|
+
_workerType: "core._workerType",
|
|
2414
|
+
_worker: "core._workerType",
|
|
2415
|
+
limit: "core.limit",
|
|
2416
|
+
_limitMB: "core._limitMB",
|
|
2417
|
+
batchSize: "core.batchSize",
|
|
2418
|
+
batchDebounceMs: "core.batchDebounceMs",
|
|
2419
|
+
metadata: "core.metadata",
|
|
2420
|
+
transforms: "core.transforms",
|
|
2421
|
+
// Older deprecations
|
|
2294
2422
|
throws: "nothrow",
|
|
2295
2423
|
dataType: "(no longer used)",
|
|
2296
2424
|
uri: "baseUri",
|
|
2297
|
-
// Warn if fetch options are used on
|
|
2425
|
+
// Warn if fetch options are used on toplevel
|
|
2298
2426
|
method: "fetch.method",
|
|
2299
2427
|
headers: "fetch.headers",
|
|
2300
2428
|
body: "fetch.body",
|
|
@@ -2310,6 +2438,29 @@ var __exports__ = (() => {
|
|
|
2310
2438
|
};
|
|
2311
2439
|
|
|
2312
2440
|
// src/lib/loader-utils/option-utils.ts
|
|
2441
|
+
var CORE_LOADER_OPTION_KEYS = [
|
|
2442
|
+
"baseUri",
|
|
2443
|
+
"fetch",
|
|
2444
|
+
"mimeType",
|
|
2445
|
+
"fallbackMimeType",
|
|
2446
|
+
"ignoreRegisteredLoaders",
|
|
2447
|
+
"nothrow",
|
|
2448
|
+
"log",
|
|
2449
|
+
"useLocalLibraries",
|
|
2450
|
+
"CDN",
|
|
2451
|
+
"worker",
|
|
2452
|
+
"maxConcurrency",
|
|
2453
|
+
"maxMobileConcurrency",
|
|
2454
|
+
"reuseWorkers",
|
|
2455
|
+
"_nodeWorkers",
|
|
2456
|
+
"_workerType",
|
|
2457
|
+
"limit",
|
|
2458
|
+
"_limitMB",
|
|
2459
|
+
"batchSize",
|
|
2460
|
+
"batchDebounceMs",
|
|
2461
|
+
"metadata",
|
|
2462
|
+
"transforms"
|
|
2463
|
+
];
|
|
2313
2464
|
function getGlobalLoaderState() {
|
|
2314
2465
|
globalThis.loaders = globalThis.loaders || {};
|
|
2315
2466
|
const { loaders } = globalThis;
|
|
@@ -2320,8 +2471,11 @@ var __exports__ = (() => {
|
|
|
2320
2471
|
}
|
|
2321
2472
|
function getGlobalLoaderOptions() {
|
|
2322
2473
|
const state = getGlobalLoaderState();
|
|
2323
|
-
state.globalOptions = state.globalOptions || {
|
|
2324
|
-
|
|
2474
|
+
state.globalOptions = state.globalOptions || {
|
|
2475
|
+
...DEFAULT_LOADER_OPTIONS,
|
|
2476
|
+
core: { ...DEFAULT_LOADER_OPTIONS.core }
|
|
2477
|
+
};
|
|
2478
|
+
return normalizeLoaderOptions(state.globalOptions);
|
|
2325
2479
|
}
|
|
2326
2480
|
function setGlobalOptions(options) {
|
|
2327
2481
|
const state = getGlobalLoaderState();
|
|
@@ -2333,7 +2487,20 @@ var __exports__ = (() => {
|
|
|
2333
2487
|
loaders = loaders || [];
|
|
2334
2488
|
loaders = Array.isArray(loaders) ? loaders : [loaders];
|
|
2335
2489
|
validateOptions(options, loaders);
|
|
2336
|
-
return normalizeOptionsInternal(loader, options, url);
|
|
2490
|
+
return normalizeLoaderOptions(normalizeOptionsInternal(loader, options, url));
|
|
2491
|
+
}
|
|
2492
|
+
function normalizeLoaderOptions(options) {
|
|
2493
|
+
const normalized = cloneLoaderOptions(options);
|
|
2494
|
+
moveDeprecatedTopLevelOptionsToCore(normalized);
|
|
2495
|
+
for (const key of CORE_LOADER_OPTION_KEYS) {
|
|
2496
|
+
if (normalized.core && normalized.core[key] !== void 0) {
|
|
2497
|
+
delete normalized[key];
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
if (normalized.core && normalized.core._workerType !== void 0) {
|
|
2501
|
+
delete normalized._worker;
|
|
2502
|
+
}
|
|
2503
|
+
return normalized;
|
|
2337
2504
|
}
|
|
2338
2505
|
function validateOptions(options, loaders) {
|
|
2339
2506
|
validateOptionsObject(options, null, DEFAULT_LOADER_OPTIONS, REMOVED_LOADER_OPTIONS, loaders);
|
|
@@ -2385,12 +2552,18 @@ var __exports__ = (() => {
|
|
|
2385
2552
|
function normalizeOptionsInternal(loader, options, url) {
|
|
2386
2553
|
const loaderDefaultOptions = loader.options || {};
|
|
2387
2554
|
const mergedOptions = { ...loaderDefaultOptions };
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2555
|
+
if (loaderDefaultOptions.core) {
|
|
2556
|
+
mergedOptions.core = { ...loaderDefaultOptions.core };
|
|
2557
|
+
}
|
|
2558
|
+
moveDeprecatedTopLevelOptionsToCore(mergedOptions);
|
|
2559
|
+
if (mergedOptions.core?.log === null) {
|
|
2560
|
+
mergedOptions.core = { ...mergedOptions.core, log: new NullLog() };
|
|
2391
2561
|
}
|
|
2392
|
-
mergeNestedFields(mergedOptions, getGlobalLoaderOptions());
|
|
2393
|
-
|
|
2562
|
+
mergeNestedFields(mergedOptions, normalizeLoaderOptions(getGlobalLoaderOptions()));
|
|
2563
|
+
const userOptions = normalizeLoaderOptions(options);
|
|
2564
|
+
mergeNestedFields(mergedOptions, userOptions);
|
|
2565
|
+
addUrlOptions(mergedOptions, url);
|
|
2566
|
+
addDeprecatedTopLevelOptions(mergedOptions);
|
|
2394
2567
|
return mergedOptions;
|
|
2395
2568
|
}
|
|
2396
2569
|
function mergeNestedFields(mergedOptions, options) {
|
|
@@ -2409,8 +2582,50 @@ var __exports__ = (() => {
|
|
|
2409
2582
|
}
|
|
2410
2583
|
}
|
|
2411
2584
|
function addUrlOptions(options, url) {
|
|
2412
|
-
if (url
|
|
2413
|
-
|
|
2585
|
+
if (!url) {
|
|
2586
|
+
return;
|
|
2587
|
+
}
|
|
2588
|
+
const hasTopLevelBaseUri = options.baseUri !== void 0;
|
|
2589
|
+
const hasCoreBaseUri = options.core?.baseUri !== void 0;
|
|
2590
|
+
if (!hasTopLevelBaseUri && !hasCoreBaseUri) {
|
|
2591
|
+
options.core ||= {};
|
|
2592
|
+
options.core.baseUri = url;
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
function cloneLoaderOptions(options) {
|
|
2596
|
+
const clonedOptions = { ...options };
|
|
2597
|
+
if (options.core) {
|
|
2598
|
+
clonedOptions.core = { ...options.core };
|
|
2599
|
+
}
|
|
2600
|
+
return clonedOptions;
|
|
2601
|
+
}
|
|
2602
|
+
function moveDeprecatedTopLevelOptionsToCore(options) {
|
|
2603
|
+
for (const key of CORE_LOADER_OPTION_KEYS) {
|
|
2604
|
+
if (options[key] !== void 0) {
|
|
2605
|
+
const coreOptions = options.core = options.core || {};
|
|
2606
|
+
const coreRecord = coreOptions;
|
|
2607
|
+
if (coreRecord[key] === void 0) {
|
|
2608
|
+
coreRecord[key] = options[key];
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2611
|
+
}
|
|
2612
|
+
const workerTypeAlias = options._worker;
|
|
2613
|
+
if (workerTypeAlias !== void 0) {
|
|
2614
|
+
options.core ||= {};
|
|
2615
|
+
if (options.core._workerType === void 0) {
|
|
2616
|
+
options.core._workerType = workerTypeAlias;
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
function addDeprecatedTopLevelOptions(options) {
|
|
2621
|
+
const coreOptions = options.core;
|
|
2622
|
+
if (!coreOptions) {
|
|
2623
|
+
return;
|
|
2624
|
+
}
|
|
2625
|
+
for (const key of CORE_LOADER_OPTION_KEYS) {
|
|
2626
|
+
if (coreOptions[key] !== void 0) {
|
|
2627
|
+
options[key] = coreOptions[key];
|
|
2628
|
+
}
|
|
2414
2629
|
}
|
|
2415
2630
|
}
|
|
2416
2631
|
|
|
@@ -2476,15 +2691,22 @@ var __exports__ = (() => {
|
|
|
2476
2691
|
if (!validHTTPResponse(data)) {
|
|
2477
2692
|
return null;
|
|
2478
2693
|
}
|
|
2479
|
-
|
|
2694
|
+
const normalizedOptions = normalizeLoaderOptions(options || {});
|
|
2695
|
+
normalizedOptions.core ||= {};
|
|
2696
|
+
let loader = selectLoaderSync(
|
|
2697
|
+
data,
|
|
2698
|
+
loaders,
|
|
2699
|
+
{ ...normalizedOptions, core: { ...normalizedOptions.core, nothrow: true } },
|
|
2700
|
+
context
|
|
2701
|
+
);
|
|
2480
2702
|
if (loader) {
|
|
2481
2703
|
return loader;
|
|
2482
2704
|
}
|
|
2483
2705
|
if (isBlob(data)) {
|
|
2484
2706
|
data = await data.slice(0, 10).arrayBuffer();
|
|
2485
|
-
loader = selectLoaderSync(data, loaders,
|
|
2707
|
+
loader = selectLoaderSync(data, loaders, normalizedOptions, context);
|
|
2486
2708
|
}
|
|
2487
|
-
if (!loader && !
|
|
2709
|
+
if (!loader && !normalizedOptions.core.nothrow) {
|
|
2488
2710
|
throw new Error(getNoValidLoaderMessage(data));
|
|
2489
2711
|
}
|
|
2490
2712
|
return loader;
|
|
@@ -2493,6 +2715,8 @@ var __exports__ = (() => {
|
|
|
2493
2715
|
if (!validHTTPResponse(data)) {
|
|
2494
2716
|
return null;
|
|
2495
2717
|
}
|
|
2718
|
+
const normalizedOptions = normalizeLoaderOptions(options || {});
|
|
2719
|
+
normalizedOptions.core ||= {};
|
|
2496
2720
|
if (loaders && !Array.isArray(loaders)) {
|
|
2497
2721
|
return normalizeLoader(loaders);
|
|
2498
2722
|
}
|
|
@@ -2500,12 +2724,12 @@ var __exports__ = (() => {
|
|
|
2500
2724
|
if (loaders) {
|
|
2501
2725
|
candidateLoaders = candidateLoaders.concat(loaders);
|
|
2502
2726
|
}
|
|
2503
|
-
if (!
|
|
2727
|
+
if (!normalizedOptions.core.ignoreRegisteredLoaders) {
|
|
2504
2728
|
candidateLoaders.push(...getRegisteredLoaders());
|
|
2505
2729
|
}
|
|
2506
2730
|
normalizeLoaders(candidateLoaders);
|
|
2507
|
-
const loader = selectLoaderInternal(data, candidateLoaders,
|
|
2508
|
-
if (!loader && !
|
|
2731
|
+
const loader = selectLoaderInternal(data, candidateLoaders, normalizedOptions, context);
|
|
2732
|
+
if (!loader && !normalizedOptions.core.nothrow) {
|
|
2509
2733
|
throw new Error(getNoValidLoaderMessage(data));
|
|
2510
2734
|
}
|
|
2511
2735
|
return loader;
|
|
@@ -2516,9 +2740,9 @@ var __exports__ = (() => {
|
|
|
2516
2740
|
const testUrl = stripQueryString(url) || context?.url;
|
|
2517
2741
|
let loader = null;
|
|
2518
2742
|
let reason = "";
|
|
2519
|
-
if (options?.mimeType) {
|
|
2520
|
-
loader = findLoaderByMIMEType(loaders, options?.mimeType);
|
|
2521
|
-
reason = `match forced by supplied MIME type ${options?.mimeType}`;
|
|
2743
|
+
if (options?.core?.mimeType) {
|
|
2744
|
+
loader = findLoaderByMIMEType(loaders, options?.core?.mimeType);
|
|
2745
|
+
reason = `match forced by supplied MIME type ${options?.core?.mimeType}`;
|
|
2522
2746
|
}
|
|
2523
2747
|
loader = loader || findLoaderByUrl(loaders, testUrl);
|
|
2524
2748
|
reason = reason || (loader ? `matched url ${testUrl}` : "");
|
|
@@ -2526,8 +2750,8 @@ var __exports__ = (() => {
|
|
|
2526
2750
|
reason = reason || (loader ? `matched MIME type ${type}` : "");
|
|
2527
2751
|
loader = loader || findLoaderByInitialBytes(loaders, data);
|
|
2528
2752
|
reason = reason || (loader ? `matched initial data ${getFirstCharacters(data)}` : "");
|
|
2529
|
-
if (options?.fallbackMimeType) {
|
|
2530
|
-
loader = loader || findLoaderByMIMEType(loaders, options?.fallbackMimeType);
|
|
2753
|
+
if (options?.core?.fallbackMimeType) {
|
|
2754
|
+
loader = loader || findLoaderByMIMEType(loaders, options?.core?.fallbackMimeType);
|
|
2531
2755
|
reason = reason || (loader ? `matched fallback MIME type ${type}` : "");
|
|
2532
2756
|
}
|
|
2533
2757
|
if (reason) {
|
|
@@ -2620,12 +2844,12 @@ var __exports__ = (() => {
|
|
|
2620
2844
|
return tests.some((test) => testBinary(data, byteOffset, loader, test));
|
|
2621
2845
|
}
|
|
2622
2846
|
function testBinary(data, byteOffset, loader, test) {
|
|
2623
|
-
if (test
|
|
2847
|
+
if (isArrayBufferLike(test)) {
|
|
2624
2848
|
return compareArrayBuffers(test, data, test.byteLength);
|
|
2625
2849
|
}
|
|
2626
2850
|
switch (typeof test) {
|
|
2627
2851
|
case "function":
|
|
2628
|
-
return test(data);
|
|
2852
|
+
return test(ensureArrayBuffer(data));
|
|
2629
2853
|
case "string":
|
|
2630
2854
|
const magic = getMagicString(data, byteOffset, test.length);
|
|
2631
2855
|
return test === magic;
|
|
@@ -2666,7 +2890,7 @@ var __exports__ = (() => {
|
|
|
2666
2890
|
const chunkLength = Math.min(string.length - offset, chunkSize);
|
|
2667
2891
|
const chunk = string.slice(offset, offset + chunkLength);
|
|
2668
2892
|
offset += chunkLength;
|
|
2669
|
-
yield textEncoder.encode(chunk);
|
|
2893
|
+
yield ensureArrayBuffer(textEncoder.encode(chunk));
|
|
2670
2894
|
}
|
|
2671
2895
|
}
|
|
2672
2896
|
|
|
@@ -2743,8 +2967,11 @@ var __exports__ = (() => {
|
|
|
2743
2967
|
return makeStreamIterator(data, options);
|
|
2744
2968
|
}
|
|
2745
2969
|
if (isResponse(data)) {
|
|
2746
|
-
const
|
|
2747
|
-
|
|
2970
|
+
const responseBody = data.body;
|
|
2971
|
+
if (!responseBody) {
|
|
2972
|
+
throw new Error("Readable stream not available on Response");
|
|
2973
|
+
}
|
|
2974
|
+
return makeStreamIterator(responseBody, options);
|
|
2748
2975
|
}
|
|
2749
2976
|
throw new Error("makeIterator");
|
|
2750
2977
|
}
|
|
@@ -2755,43 +2982,29 @@ var __exports__ = (() => {
|
|
|
2755
2982
|
if (loader.text && typeof data === "string") {
|
|
2756
2983
|
return data;
|
|
2757
2984
|
}
|
|
2758
|
-
if (
|
|
2985
|
+
if (isBuffer(data)) {
|
|
2759
2986
|
data = data.buffer;
|
|
2760
2987
|
}
|
|
2761
|
-
if (data
|
|
2762
|
-
const
|
|
2988
|
+
if (isArrayBufferLike(data)) {
|
|
2989
|
+
const bufferSource = toArrayBufferView(data);
|
|
2763
2990
|
if (loader.text && !loader.binary) {
|
|
2764
2991
|
const textDecoder = new TextDecoder("utf8");
|
|
2765
|
-
return textDecoder.decode(
|
|
2992
|
+
return textDecoder.decode(bufferSource);
|
|
2766
2993
|
}
|
|
2767
|
-
return
|
|
2768
|
-
}
|
|
2769
|
-
if (ArrayBuffer.isView(data)) {
|
|
2770
|
-
if (loader.text && !loader.binary) {
|
|
2771
|
-
const textDecoder = new TextDecoder("utf8");
|
|
2772
|
-
return textDecoder.decode(data);
|
|
2773
|
-
}
|
|
2774
|
-
let arrayBuffer = data.buffer;
|
|
2775
|
-
const byteLength = data.byteLength || data.length;
|
|
2776
|
-
if (data.byteOffset !== 0 || byteLength !== arrayBuffer.byteLength) {
|
|
2777
|
-
arrayBuffer = arrayBuffer.slice(data.byteOffset, data.byteOffset + byteLength);
|
|
2778
|
-
}
|
|
2779
|
-
return arrayBuffer;
|
|
2994
|
+
return toArrayBuffer2(bufferSource);
|
|
2780
2995
|
}
|
|
2781
2996
|
throw new Error(ERR_DATA);
|
|
2782
2997
|
}
|
|
2783
2998
|
async function getArrayBufferOrStringFromData(data, loader, options) {
|
|
2784
|
-
|
|
2785
|
-
if (typeof data === "string" || isArrayBuffer) {
|
|
2999
|
+
if (typeof data === "string" || isArrayBufferLike(data)) {
|
|
2786
3000
|
return getArrayBufferOrStringFromDataSync(data, loader, options);
|
|
2787
3001
|
}
|
|
2788
3002
|
if (isBlob(data)) {
|
|
2789
3003
|
data = await makeResponse(data);
|
|
2790
3004
|
}
|
|
2791
3005
|
if (isResponse(data)) {
|
|
2792
|
-
|
|
2793
|
-
await
|
|
2794
|
-
return loader.binary ? await response.arrayBuffer() : await response.text();
|
|
3006
|
+
await checkResponse(data);
|
|
3007
|
+
return loader.binary ? await data.arrayBuffer() : await data.text();
|
|
2795
3008
|
}
|
|
2796
3009
|
if (isReadableStream(data)) {
|
|
2797
3010
|
data = makeIterator(data, options);
|
|
@@ -2802,13 +3015,18 @@ var __exports__ = (() => {
|
|
|
2802
3015
|
throw new Error(ERR_DATA);
|
|
2803
3016
|
}
|
|
2804
3017
|
async function getAsyncIterableFromData(data, options) {
|
|
3018
|
+
if (isPromise(data)) {
|
|
3019
|
+
data = await data;
|
|
3020
|
+
}
|
|
2805
3021
|
if (isIterator(data)) {
|
|
2806
3022
|
return data;
|
|
2807
3023
|
}
|
|
2808
3024
|
if (isResponse(data)) {
|
|
2809
|
-
|
|
2810
|
-
await
|
|
2811
|
-
|
|
3025
|
+
await checkResponse(data);
|
|
3026
|
+
const body = await data.body;
|
|
3027
|
+
if (!body) {
|
|
3028
|
+
throw new Error(ERR_DATA);
|
|
3029
|
+
}
|
|
2812
3030
|
return makeIterator(body, options);
|
|
2813
3031
|
}
|
|
2814
3032
|
if (isBlob(data) || isReadableStream(data)) {
|
|
@@ -2817,17 +3035,20 @@ var __exports__ = (() => {
|
|
|
2817
3035
|
if (isAsyncIterable(data)) {
|
|
2818
3036
|
return data;
|
|
2819
3037
|
}
|
|
3038
|
+
if (isIterable(data)) {
|
|
3039
|
+
return data;
|
|
3040
|
+
}
|
|
2820
3041
|
return getIterableFromData(data);
|
|
2821
3042
|
}
|
|
2822
3043
|
function getIterableFromData(data) {
|
|
2823
3044
|
if (ArrayBuffer.isView(data)) {
|
|
2824
3045
|
return function* oneChunk() {
|
|
2825
|
-
yield data
|
|
3046
|
+
yield toArrayBuffer2(data);
|
|
2826
3047
|
}();
|
|
2827
3048
|
}
|
|
2828
|
-
if (data
|
|
3049
|
+
if (isArrayBufferLike(data)) {
|
|
2829
3050
|
return function* oneChunk() {
|
|
2830
|
-
yield data;
|
|
3051
|
+
yield toArrayBuffer2(data);
|
|
2831
3052
|
}();
|
|
2832
3053
|
}
|
|
2833
3054
|
if (isIterator(data)) {
|
|
@@ -2843,11 +3064,12 @@ var __exports__ = (() => {
|
|
|
2843
3064
|
function getFetchFunction(options, context) {
|
|
2844
3065
|
const globalOptions = getGlobalLoaderOptions();
|
|
2845
3066
|
const loaderOptions = options || globalOptions;
|
|
2846
|
-
|
|
2847
|
-
|
|
3067
|
+
const fetchOption = loaderOptions.fetch ?? loaderOptions.core?.fetch;
|
|
3068
|
+
if (typeof fetchOption === "function") {
|
|
3069
|
+
return fetchOption;
|
|
2848
3070
|
}
|
|
2849
|
-
if (isObject(
|
|
2850
|
-
return (url) => fetchFile(url,
|
|
3071
|
+
if (isObject(fetchOption)) {
|
|
3072
|
+
return (url) => fetchFile(url, fetchOption);
|
|
2851
3073
|
}
|
|
2852
3074
|
if (context?.fetch) {
|
|
2853
3075
|
return context?.fetch;
|
|
@@ -2907,22 +3129,21 @@ var __exports__ = (() => {
|
|
|
2907
3129
|
if (!loader) {
|
|
2908
3130
|
return null;
|
|
2909
3131
|
}
|
|
2910
|
-
|
|
3132
|
+
const strictOptions = normalizeOptions(options, loader, candidateLoaders, url);
|
|
2911
3133
|
context = getLoaderContext(
|
|
2912
3134
|
// @ts-expect-error
|
|
2913
3135
|
{ url, _parse: parse, loaders: candidateLoaders },
|
|
2914
|
-
|
|
3136
|
+
strictOptions,
|
|
2915
3137
|
context || null
|
|
2916
3138
|
);
|
|
2917
|
-
return await parseWithLoader(loader, data,
|
|
3139
|
+
return await parseWithLoader(loader, data, strictOptions, context);
|
|
2918
3140
|
}
|
|
2919
3141
|
async function parseWithLoader(loader, data, options, context) {
|
|
2920
3142
|
validateWorkerVersion(loader);
|
|
2921
|
-
options =
|
|
3143
|
+
options = mergeOptions(loader.options, options);
|
|
2922
3144
|
if (isResponse(data)) {
|
|
2923
|
-
const
|
|
2924
|
-
const
|
|
2925
|
-
const headers = Object.fromEntries(response.headers.entries());
|
|
3145
|
+
const { ok, redirected, status, statusText, type, url } = data;
|
|
3146
|
+
const headers = Object.fromEntries(data.headers.entries());
|
|
2926
3147
|
context.response = { headers, ok, redirected, status, statusText, type, url };
|
|
2927
3148
|
}
|
|
2928
3149
|
data = await getArrayBufferOrStringFromData(data, loader, options);
|
|
@@ -2957,17 +3178,17 @@ var __exports__ = (() => {
|
|
|
2957
3178
|
if (!loader) {
|
|
2958
3179
|
return null;
|
|
2959
3180
|
}
|
|
2960
|
-
|
|
3181
|
+
const strictOptions = normalizeOptions(options, loader, candidateLoaders);
|
|
2961
3182
|
const url = getResourceUrl(data);
|
|
2962
3183
|
const parse2 = () => {
|
|
2963
3184
|
throw new Error("parseSync called parse (which is async");
|
|
2964
3185
|
};
|
|
2965
3186
|
context = getLoaderContext(
|
|
2966
3187
|
{ url, _parseSync: parse2, _parse: parse2, loaders },
|
|
2967
|
-
|
|
3188
|
+
strictOptions,
|
|
2968
3189
|
context || null
|
|
2969
3190
|
);
|
|
2970
|
-
return parseWithLoaderSync(loader, data,
|
|
3191
|
+
return parseWithLoaderSync(loader, data, strictOptions, context);
|
|
2971
3192
|
}
|
|
2972
3193
|
function parseWithLoaderSync(loader, data, options, context) {
|
|
2973
3194
|
data = getArrayBufferOrStringFromDataSync(data, loader, options);
|
|
@@ -2982,7 +3203,7 @@ var __exports__ = (() => {
|
|
|
2982
3203
|
);
|
|
2983
3204
|
}
|
|
2984
3205
|
|
|
2985
|
-
// ../schema/src/lib/table/
|
|
3206
|
+
// ../schema-utils/src/lib/table/tables/table-accessors.ts
|
|
2986
3207
|
function isTable(table) {
|
|
2987
3208
|
const shape = typeof table === "object" && table?.shape;
|
|
2988
3209
|
switch (shape) {
|
|
@@ -3019,7 +3240,7 @@ var __exports__ = (() => {
|
|
|
3019
3240
|
}
|
|
3020
3241
|
}
|
|
3021
3242
|
|
|
3022
|
-
// ../schema/src/lib/table/
|
|
3243
|
+
// ../schema-utils/src/lib/table/batches/make-table-batch-iterator.ts
|
|
3023
3244
|
function makeBatchFromTable(table) {
|
|
3024
3245
|
return { ...table, length: getTableLength(table), batchType: "data" };
|
|
3025
3246
|
}
|
|
@@ -3039,17 +3260,17 @@ var __exports__ = (() => {
|
|
|
3039
3260
|
if (!loader) {
|
|
3040
3261
|
return [];
|
|
3041
3262
|
}
|
|
3042
|
-
|
|
3263
|
+
const strictOptions = normalizeOptions(options, loader, loaderArray, url);
|
|
3043
3264
|
context = getLoaderContext(
|
|
3044
3265
|
{ url, _parseInBatches: parseInBatches, _parse: parse, loaders: loaderArray },
|
|
3045
|
-
|
|
3266
|
+
strictOptions,
|
|
3046
3267
|
context || null
|
|
3047
3268
|
);
|
|
3048
|
-
return await parseWithLoaderInBatches(loader, data,
|
|
3269
|
+
return await parseWithLoaderInBatches(loader, data, strictOptions, context);
|
|
3049
3270
|
}
|
|
3050
3271
|
async function parseWithLoaderInBatches(loader, data, options, context) {
|
|
3051
3272
|
const outputIterator = await parseToOutputIterator(loader, data, options, context);
|
|
3052
|
-
if (!options
|
|
3273
|
+
if (!options?.core?.metadata) {
|
|
3053
3274
|
return outputIterator;
|
|
3054
3275
|
}
|
|
3055
3276
|
const metadataBatch = {
|
|
@@ -3071,7 +3292,10 @@ var __exports__ = (() => {
|
|
|
3071
3292
|
}
|
|
3072
3293
|
async function parseToOutputIterator(loader, data, options, context) {
|
|
3073
3294
|
const inputIterator = await getAsyncIterableFromData(data, options);
|
|
3074
|
-
const transformedIterator = await applyInputTransforms(
|
|
3295
|
+
const transformedIterator = await applyInputTransforms(
|
|
3296
|
+
inputIterator,
|
|
3297
|
+
options?.core?.transforms || []
|
|
3298
|
+
);
|
|
3075
3299
|
if (loader.parseInBatches) {
|
|
3076
3300
|
return loader.parseInBatches(transformedIterator, options, context);
|
|
3077
3301
|
}
|
|
@@ -3083,7 +3307,7 @@ var __exports__ = (() => {
|
|
|
3083
3307
|
arrayBuffer,
|
|
3084
3308
|
loader,
|
|
3085
3309
|
// TODO - Hack: supply loaders MIME type to ensure we match it
|
|
3086
|
-
{ ...options, mimeType: loader.mimeTypes[0] },
|
|
3310
|
+
{ ...options, core: { ...options?.core, mimeType: loader.mimeTypes[0] } },
|
|
3087
3311
|
context
|
|
3088
3312
|
);
|
|
3089
3313
|
const batch = convertDataToBatch(parsedData, loader);
|
|
@@ -3165,7 +3389,7 @@ var __exports__ = (() => {
|
|
|
3165
3389
|
}
|
|
3166
3390
|
if (writer.encodeText) {
|
|
3167
3391
|
const text = await writer.encodeText(data, options);
|
|
3168
|
-
return new TextEncoder().encode(text);
|
|
3392
|
+
return ensureArrayBuffer(new TextEncoder().encode(text));
|
|
3169
3393
|
}
|
|
3170
3394
|
if (writer.encodeInBatches) {
|
|
3171
3395
|
const batches = encodeTableInBatches(data, writer, options);
|
|
@@ -3216,7 +3440,7 @@ var __exports__ = (() => {
|
|
|
3216
3440
|
return writer.encodeSync(data, options);
|
|
3217
3441
|
}
|
|
3218
3442
|
if (writer.encodeTextSync) {
|
|
3219
|
-
return new TextEncoder().encode(writer.encodeTextSync(data, options));
|
|
3443
|
+
return ensureArrayBuffer(new TextEncoder().encode(writer.encodeTextSync(data, options)));
|
|
3220
3444
|
}
|
|
3221
3445
|
throw new Error(`Writer ${writer.name} could not synchronously encode data`);
|
|
3222
3446
|
}
|
|
@@ -3280,13 +3504,13 @@ var __exports__ = (() => {
|
|
|
3280
3504
|
}
|
|
3281
3505
|
|
|
3282
3506
|
// src/lib/api/create-data-source.ts
|
|
3283
|
-
function createDataSource(data, sources,
|
|
3284
|
-
const
|
|
3507
|
+
function createDataSource(data, sources, options) {
|
|
3508
|
+
const type = options?.core?.type || options.type || "auto";
|
|
3285
3509
|
const source = type === "auto" ? selectSource(data, sources) : getSourceOfType(type, sources);
|
|
3286
3510
|
if (!source) {
|
|
3287
|
-
throw new Error("Not a valid
|
|
3511
|
+
throw new Error("Not a valid source type");
|
|
3288
3512
|
}
|
|
3289
|
-
return source.createDataSource(data,
|
|
3513
|
+
return source.createDataSource(data, options);
|
|
3290
3514
|
}
|
|
3291
3515
|
function selectSource(url, sources) {
|
|
3292
3516
|
for (const service of sources) {
|