@loaders.gl/core 4.4.0-alpha.2 → 4.4.0-alpha.9
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 +368 -146
- package/dist/dist.min.js +3 -3
- package/dist/index.cjs +339 -227
- 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.js +1 -0
- package/dist/lib/api/create-data-source.js.map +1 -0
- 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 +7 -6
- 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 +8 -9
- 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 -6
- 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/encode-table.ts +2 -1
- package/src/lib/api/encode.ts +8 -2
- package/src/lib/api/load.ts +1 -1
- package/src/lib/api/parse-in-batches.ts +26 -19
- package/src/lib/api/parse-sync.ts +6 -5
- package/src/lib/api/parse.ts +15 -11
- package/src/lib/api/select-loader.ts +42 -24
- 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
|
@@ -562,6 +562,26 @@ var __exports__ = (() => {
|
|
|
562
562
|
}
|
|
563
563
|
var log = createLog();
|
|
564
564
|
|
|
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
|
+
|
|
565
585
|
// ../loader-utils/src/lib/option-utils/merge-options.ts
|
|
566
586
|
function mergeOptions(baseOptions, newOptions) {
|
|
567
587
|
return mergeOptionsRecursively(baseOptions || {}, newOptions);
|
|
@@ -596,14 +616,16 @@ var __exports__ = (() => {
|
|
|
596
616
|
var NPM_TAG = "beta";
|
|
597
617
|
|
|
598
618
|
// ../worker-utils/src/lib/env-utils/version.ts
|
|
619
|
+
var warningIssued = false;
|
|
599
620
|
function getVersion() {
|
|
600
621
|
if (!globalThis._loadersgl_?.version) {
|
|
601
622
|
globalThis._loadersgl_ = globalThis._loadersgl_ || {};
|
|
602
|
-
if (typeof __VERSION__ === "undefined") {
|
|
623
|
+
if (typeof __VERSION__ === "undefined" && !warningIssued) {
|
|
603
624
|
console.warn(
|
|
604
625
|
"loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN."
|
|
605
626
|
);
|
|
606
627
|
globalThis._loadersgl_.version = NPM_TAG;
|
|
628
|
+
warningIssued = true;
|
|
607
629
|
} else {
|
|
608
630
|
globalThis._loadersgl_.version = __VERSION__;
|
|
609
631
|
}
|
|
@@ -875,7 +897,8 @@ var __exports__ = (() => {
|
|
|
875
897
|
if (this.url) {
|
|
876
898
|
const absolute = this.url.includes(":/") || this.url.startsWith("/");
|
|
877
899
|
const url = absolute ? this.url : `./${this.url}`;
|
|
878
|
-
|
|
900
|
+
const type = this.url.endsWith(".ts") || this.url.endsWith(".mjs") ? "module" : "commonjs";
|
|
901
|
+
worker = new NodeWorker(url, { eval: false, type });
|
|
879
902
|
} else if (this.source) {
|
|
880
903
|
worker = new NodeWorker(this.source, { eval: true });
|
|
881
904
|
} else {
|
|
@@ -1131,7 +1154,8 @@ var __exports__ = (() => {
|
|
|
1131
1154
|
if (!url && worker.id === "compression") {
|
|
1132
1155
|
url = options.workerUrl;
|
|
1133
1156
|
}
|
|
1134
|
-
|
|
1157
|
+
const workerType = options._workerType || options?.core?._workerType;
|
|
1158
|
+
if (workerType === "test") {
|
|
1135
1159
|
if (isBrowser3) {
|
|
1136
1160
|
url = `modules/${worker.module}/dist/${workerFile}`;
|
|
1137
1161
|
} else {
|
|
@@ -1213,15 +1237,17 @@ var __exports__ = (() => {
|
|
|
1213
1237
|
if (!WorkerFarm.isSupported()) {
|
|
1214
1238
|
return false;
|
|
1215
1239
|
}
|
|
1216
|
-
|
|
1240
|
+
const nodeWorkers = options?._nodeWorkers ?? options?.core?._nodeWorkers;
|
|
1241
|
+
if (!isBrowser3 && !nodeWorkers) {
|
|
1217
1242
|
return false;
|
|
1218
1243
|
}
|
|
1219
|
-
|
|
1244
|
+
const useWorkers = options?.worker ?? options?.core?.worker;
|
|
1245
|
+
return Boolean(loader.worker && useWorkers);
|
|
1220
1246
|
}
|
|
1221
1247
|
async function parseWithWorker(loader, data, options, context, parseOnMainThread) {
|
|
1222
1248
|
const name = loader.id;
|
|
1223
1249
|
const url = getWorkerURL(loader, options);
|
|
1224
|
-
const workerFarm = WorkerFarm.getWorkerFarm(options);
|
|
1250
|
+
const workerFarm = WorkerFarm.getWorkerFarm(options?.core);
|
|
1225
1251
|
const workerPool = workerFarm.getWorkerPool({ name, url });
|
|
1226
1252
|
options = JSON.parse(JSON.stringify(options));
|
|
1227
1253
|
context = JSON.parse(JSON.stringify(context || {}));
|
|
@@ -1268,10 +1294,12 @@ var __exports__ = (() => {
|
|
|
1268
1294
|
if (!WorkerFarm.isSupported()) {
|
|
1269
1295
|
return false;
|
|
1270
1296
|
}
|
|
1271
|
-
|
|
1297
|
+
const nodeWorkers = options?._nodeWorkers ?? options?.core?._nodeWorkers;
|
|
1298
|
+
const useWorkers = options?.worker ?? options?.core?.worker;
|
|
1299
|
+
if (!isBrowser && !nodeWorkers) {
|
|
1272
1300
|
return false;
|
|
1273
1301
|
}
|
|
1274
|
-
return writer.worker &&
|
|
1302
|
+
return Boolean(writer.worker && useWorkers);
|
|
1275
1303
|
}
|
|
1276
1304
|
|
|
1277
1305
|
// ../loader-utils/src/lib/binary-utils/array-buffer-utils.ts
|
|
@@ -1316,7 +1344,7 @@ var __exports__ = (() => {
|
|
|
1316
1344
|
async function* makeTextEncoderIterator(textIterator) {
|
|
1317
1345
|
const textEncoder = new TextEncoder();
|
|
1318
1346
|
for await (const text of textIterator) {
|
|
1319
|
-
yield typeof text === "string" ? textEncoder.encode(text) : text;
|
|
1347
|
+
yield typeof text === "string" ? textEncoder.encode(text).buffer : text;
|
|
1320
1348
|
}
|
|
1321
1349
|
}
|
|
1322
1350
|
async function* makeLineIterator(textIterator) {
|
|
@@ -1343,11 +1371,14 @@ var __exports__ = (() => {
|
|
|
1343
1371
|
}
|
|
1344
1372
|
|
|
1345
1373
|
// ../loader-utils/src/lib/iterators/async-iteration.ts
|
|
1346
|
-
async function forEach(
|
|
1374
|
+
async function forEach(iterable, visitor) {
|
|
1375
|
+
const iterator = toAsyncIterator(iterable);
|
|
1347
1376
|
while (true) {
|
|
1348
1377
|
const { done, value } = await iterator.next();
|
|
1349
1378
|
if (done) {
|
|
1350
|
-
iterator.return
|
|
1379
|
+
if (iterator.return) {
|
|
1380
|
+
iterator.return();
|
|
1381
|
+
}
|
|
1351
1382
|
return;
|
|
1352
1383
|
}
|
|
1353
1384
|
const cancel = visitor(value);
|
|
@@ -1359,10 +1390,55 @@ var __exports__ = (() => {
|
|
|
1359
1390
|
async function concatenateArrayBuffersAsync(asyncIterator) {
|
|
1360
1391
|
const arrayBuffers = [];
|
|
1361
1392
|
for await (const chunk of asyncIterator) {
|
|
1362
|
-
arrayBuffers.push(chunk);
|
|
1393
|
+
arrayBuffers.push(copyToArrayBuffer(chunk));
|
|
1363
1394
|
}
|
|
1364
1395
|
return concatenateArrayBuffers(...arrayBuffers);
|
|
1365
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
|
+
}
|
|
1366
1442
|
|
|
1367
1443
|
// ../../node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js
|
|
1368
1444
|
function getHiResTimestamp2() {
|
|
@@ -1592,6 +1668,20 @@ var __exports__ = (() => {
|
|
|
1592
1668
|
this.stats.get(STAT_QUEUED_REQUESTS_EVER);
|
|
1593
1669
|
this.stats.get(STAT_ACTIVE_REQUESTS_EVER);
|
|
1594
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
|
+
}
|
|
1595
1685
|
/**
|
|
1596
1686
|
* Called by an application that wants to issue a request, without having it deeply queued by the browser
|
|
1597
1687
|
*
|
|
@@ -1749,11 +1839,15 @@ var __exports__ = (() => {
|
|
|
1749
1839
|
if (data instanceof ArrayBuffer) {
|
|
1750
1840
|
return data;
|
|
1751
1841
|
}
|
|
1842
|
+
if (isSharedArrayBuffer(data)) {
|
|
1843
|
+
return copyToArrayBuffer2(data);
|
|
1844
|
+
}
|
|
1752
1845
|
if (ArrayBuffer.isView(data)) {
|
|
1846
|
+
const buffer = data.buffer;
|
|
1753
1847
|
if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
|
|
1754
|
-
return
|
|
1848
|
+
return buffer;
|
|
1755
1849
|
}
|
|
1756
|
-
return
|
|
1850
|
+
return buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
1757
1851
|
}
|
|
1758
1852
|
if (typeof data === "string") {
|
|
1759
1853
|
const text = data;
|
|
@@ -1765,6 +1859,31 @@ var __exports__ = (() => {
|
|
|
1765
1859
|
}
|
|
1766
1860
|
throw new Error("toArrayBuffer");
|
|
1767
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
|
+
}
|
|
1768
1887
|
|
|
1769
1888
|
// ../loader-utils/src/lib/path-utils/path.ts
|
|
1770
1889
|
var path_exports = {};
|
|
@@ -1787,7 +1906,7 @@ var __exports__ = (() => {
|
|
|
1787
1906
|
// ../loader-utils/src/lib/path-utils/path.ts
|
|
1788
1907
|
function filename(url) {
|
|
1789
1908
|
const slashIndex = url ? url.lastIndexOf("/") : -1;
|
|
1790
|
-
return slashIndex >= 0 ? url.substr(slashIndex + 1) :
|
|
1909
|
+
return slashIndex >= 0 ? url.substr(slashIndex + 1) : url;
|
|
1791
1910
|
}
|
|
1792
1911
|
function dirname(url) {
|
|
1793
1912
|
const slashIndex = url ? url.lastIndexOf("/") : -1;
|
|
@@ -1977,25 +2096,6 @@ var __exports__ = (() => {
|
|
|
1977
2096
|
}
|
|
1978
2097
|
};
|
|
1979
2098
|
|
|
1980
|
-
// src/javascript-utils/is-type.ts
|
|
1981
|
-
var isBoolean = (x) => typeof x === "boolean";
|
|
1982
|
-
var isFunction = (x) => typeof x === "function";
|
|
1983
|
-
var isObject = (x) => x !== null && typeof x === "object";
|
|
1984
|
-
var isPureObject = (x) => isObject(x) && x.constructor === {}.constructor;
|
|
1985
|
-
var isPromise = (x) => isObject(x) && isFunction(x.then);
|
|
1986
|
-
var isIterable = (x) => Boolean(x) && typeof x[Symbol.iterator] === "function";
|
|
1987
|
-
var isAsyncIterable = (x) => x && typeof x[Symbol.asyncIterator] === "function";
|
|
1988
|
-
var isIterator = (x) => x && isFunction(x.next);
|
|
1989
|
-
var isResponse = (x) => typeof Response !== "undefined" && x instanceof Response || x && x.arrayBuffer && x.text && x.json;
|
|
1990
|
-
var isBlob = (x) => typeof Blob !== "undefined" && x instanceof Blob;
|
|
1991
|
-
var isBuffer2 = (x) => x && typeof x === "object" && x.isBuffer;
|
|
1992
|
-
var isWritableDOMStream = (x) => isObject(x) && isFunction(x.abort) && isFunction(x.getWriter);
|
|
1993
|
-
var isReadableDOMStream = (x) => typeof ReadableStream !== "undefined" && x instanceof ReadableStream || isObject(x) && isFunction(x.tee) && isFunction(x.cancel) && isFunction(x.getReader);
|
|
1994
|
-
var isWritableNodeStream = (x) => isObject(x) && isFunction(x.end) && isFunction(x.write) && isBoolean(x.writable);
|
|
1995
|
-
var isReadableNodeStream = (x) => isObject(x) && isFunction(x.read) && isFunction(x.pipe) && isBoolean(x.readable);
|
|
1996
|
-
var isReadableStream = (x) => isReadableDOMStream(x) || isReadableNodeStream(x);
|
|
1997
|
-
var isWritableStream = (x) => isWritableDOMStream(x) || isWritableNodeStream(x);
|
|
1998
|
-
|
|
1999
2099
|
// src/lib/fetch/fetch-error.ts
|
|
2000
2100
|
var FetchError = class extends Error {
|
|
2001
2101
|
constructor(message, info) {
|
|
@@ -2057,12 +2157,11 @@ var __exports__ = (() => {
|
|
|
2057
2157
|
// src/lib/utils/resource-utils.ts
|
|
2058
2158
|
function getResourceUrl(resource) {
|
|
2059
2159
|
if (isResponse(resource)) {
|
|
2060
|
-
|
|
2061
|
-
return response.url;
|
|
2160
|
+
return resource.url;
|
|
2062
2161
|
}
|
|
2063
2162
|
if (isBlob(resource)) {
|
|
2064
|
-
const
|
|
2065
|
-
return
|
|
2163
|
+
const fileName = "name" in resource ? resource.name : "";
|
|
2164
|
+
return fileName || "";
|
|
2066
2165
|
}
|
|
2067
2166
|
if (typeof resource === "string") {
|
|
2068
2167
|
return resource;
|
|
@@ -2071,14 +2170,12 @@ var __exports__ = (() => {
|
|
|
2071
2170
|
}
|
|
2072
2171
|
function getResourceMIMEType(resource) {
|
|
2073
2172
|
if (isResponse(resource)) {
|
|
2074
|
-
const
|
|
2075
|
-
const
|
|
2076
|
-
const noQueryUrl = stripQueryString(response.url);
|
|
2173
|
+
const contentTypeHeader = resource.headers.get("content-type") || "";
|
|
2174
|
+
const noQueryUrl = stripQueryString(resource.url);
|
|
2077
2175
|
return parseMIMEType(contentTypeHeader) || parseMIMETypeFromURL(noQueryUrl);
|
|
2078
2176
|
}
|
|
2079
2177
|
if (isBlob(resource)) {
|
|
2080
|
-
|
|
2081
|
-
return blob.type || "";
|
|
2178
|
+
return resource.type || "";
|
|
2082
2179
|
}
|
|
2083
2180
|
if (typeof resource === "string") {
|
|
2084
2181
|
return parseMIMETypeFromURL(resource);
|
|
@@ -2264,39 +2361,68 @@ var __exports__ = (() => {
|
|
|
2264
2361
|
|
|
2265
2362
|
// src/lib/loader-utils/option-defaults.ts
|
|
2266
2363
|
var DEFAULT_LOADER_OPTIONS = {
|
|
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
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
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
|
+
}
|
|
2294
2396
|
};
|
|
2295
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
|
|
2296
2422
|
throws: "nothrow",
|
|
2297
2423
|
dataType: "(no longer used)",
|
|
2298
2424
|
uri: "baseUri",
|
|
2299
|
-
// Warn if fetch options are used on
|
|
2425
|
+
// Warn if fetch options are used on toplevel
|
|
2300
2426
|
method: "fetch.method",
|
|
2301
2427
|
headers: "fetch.headers",
|
|
2302
2428
|
body: "fetch.body",
|
|
@@ -2312,6 +2438,29 @@ var __exports__ = (() => {
|
|
|
2312
2438
|
};
|
|
2313
2439
|
|
|
2314
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
|
+
];
|
|
2315
2464
|
function getGlobalLoaderState() {
|
|
2316
2465
|
globalThis.loaders = globalThis.loaders || {};
|
|
2317
2466
|
const { loaders } = globalThis;
|
|
@@ -2322,8 +2471,11 @@ var __exports__ = (() => {
|
|
|
2322
2471
|
}
|
|
2323
2472
|
function getGlobalLoaderOptions() {
|
|
2324
2473
|
const state = getGlobalLoaderState();
|
|
2325
|
-
state.globalOptions = state.globalOptions || {
|
|
2326
|
-
|
|
2474
|
+
state.globalOptions = state.globalOptions || {
|
|
2475
|
+
...DEFAULT_LOADER_OPTIONS,
|
|
2476
|
+
core: { ...DEFAULT_LOADER_OPTIONS.core }
|
|
2477
|
+
};
|
|
2478
|
+
return normalizeLoaderOptions(state.globalOptions);
|
|
2327
2479
|
}
|
|
2328
2480
|
function setGlobalOptions(options) {
|
|
2329
2481
|
const state = getGlobalLoaderState();
|
|
@@ -2335,7 +2487,20 @@ var __exports__ = (() => {
|
|
|
2335
2487
|
loaders = loaders || [];
|
|
2336
2488
|
loaders = Array.isArray(loaders) ? loaders : [loaders];
|
|
2337
2489
|
validateOptions(options, loaders);
|
|
2338
|
-
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;
|
|
2339
2504
|
}
|
|
2340
2505
|
function validateOptions(options, loaders) {
|
|
2341
2506
|
validateOptionsObject(options, null, DEFAULT_LOADER_OPTIONS, REMOVED_LOADER_OPTIONS, loaders);
|
|
@@ -2387,12 +2552,18 @@ var __exports__ = (() => {
|
|
|
2387
2552
|
function normalizeOptionsInternal(loader, options, url) {
|
|
2388
2553
|
const loaderDefaultOptions = loader.options || {};
|
|
2389
2554
|
const mergedOptions = { ...loaderDefaultOptions };
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
mergedOptions.log = new NullLog();
|
|
2555
|
+
if (loaderDefaultOptions.core) {
|
|
2556
|
+
mergedOptions.core = { ...loaderDefaultOptions.core };
|
|
2393
2557
|
}
|
|
2394
|
-
|
|
2395
|
-
|
|
2558
|
+
moveDeprecatedTopLevelOptionsToCore(mergedOptions);
|
|
2559
|
+
if (mergedOptions.core?.log === null) {
|
|
2560
|
+
mergedOptions.core = { ...mergedOptions.core, log: new NullLog() };
|
|
2561
|
+
}
|
|
2562
|
+
mergeNestedFields(mergedOptions, normalizeLoaderOptions(getGlobalLoaderOptions()));
|
|
2563
|
+
const userOptions = normalizeLoaderOptions(options);
|
|
2564
|
+
mergeNestedFields(mergedOptions, userOptions);
|
|
2565
|
+
addUrlOptions(mergedOptions, url);
|
|
2566
|
+
addDeprecatedTopLevelOptions(mergedOptions);
|
|
2396
2567
|
return mergedOptions;
|
|
2397
2568
|
}
|
|
2398
2569
|
function mergeNestedFields(mergedOptions, options) {
|
|
@@ -2411,8 +2582,50 @@ var __exports__ = (() => {
|
|
|
2411
2582
|
}
|
|
2412
2583
|
}
|
|
2413
2584
|
function addUrlOptions(options, url) {
|
|
2414
|
-
if (url
|
|
2415
|
-
|
|
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
|
+
}
|
|
2416
2629
|
}
|
|
2417
2630
|
}
|
|
2418
2631
|
|
|
@@ -2478,15 +2691,22 @@ var __exports__ = (() => {
|
|
|
2478
2691
|
if (!validHTTPResponse(data)) {
|
|
2479
2692
|
return null;
|
|
2480
2693
|
}
|
|
2481
|
-
|
|
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
|
+
);
|
|
2482
2702
|
if (loader) {
|
|
2483
2703
|
return loader;
|
|
2484
2704
|
}
|
|
2485
2705
|
if (isBlob(data)) {
|
|
2486
2706
|
data = await data.slice(0, 10).arrayBuffer();
|
|
2487
|
-
loader = selectLoaderSync(data, loaders,
|
|
2707
|
+
loader = selectLoaderSync(data, loaders, normalizedOptions, context);
|
|
2488
2708
|
}
|
|
2489
|
-
if (!loader && !
|
|
2709
|
+
if (!loader && !normalizedOptions.core.nothrow) {
|
|
2490
2710
|
throw new Error(getNoValidLoaderMessage(data));
|
|
2491
2711
|
}
|
|
2492
2712
|
return loader;
|
|
@@ -2495,6 +2715,8 @@ var __exports__ = (() => {
|
|
|
2495
2715
|
if (!validHTTPResponse(data)) {
|
|
2496
2716
|
return null;
|
|
2497
2717
|
}
|
|
2718
|
+
const normalizedOptions = normalizeLoaderOptions(options || {});
|
|
2719
|
+
normalizedOptions.core ||= {};
|
|
2498
2720
|
if (loaders && !Array.isArray(loaders)) {
|
|
2499
2721
|
return normalizeLoader(loaders);
|
|
2500
2722
|
}
|
|
@@ -2502,12 +2724,12 @@ var __exports__ = (() => {
|
|
|
2502
2724
|
if (loaders) {
|
|
2503
2725
|
candidateLoaders = candidateLoaders.concat(loaders);
|
|
2504
2726
|
}
|
|
2505
|
-
if (!
|
|
2727
|
+
if (!normalizedOptions.core.ignoreRegisteredLoaders) {
|
|
2506
2728
|
candidateLoaders.push(...getRegisteredLoaders());
|
|
2507
2729
|
}
|
|
2508
2730
|
normalizeLoaders(candidateLoaders);
|
|
2509
|
-
const loader = selectLoaderInternal(data, candidateLoaders,
|
|
2510
|
-
if (!loader && !
|
|
2731
|
+
const loader = selectLoaderInternal(data, candidateLoaders, normalizedOptions, context);
|
|
2732
|
+
if (!loader && !normalizedOptions.core.nothrow) {
|
|
2511
2733
|
throw new Error(getNoValidLoaderMessage(data));
|
|
2512
2734
|
}
|
|
2513
2735
|
return loader;
|
|
@@ -2518,9 +2740,9 @@ var __exports__ = (() => {
|
|
|
2518
2740
|
const testUrl = stripQueryString(url) || context?.url;
|
|
2519
2741
|
let loader = null;
|
|
2520
2742
|
let reason = "";
|
|
2521
|
-
if (options?.mimeType) {
|
|
2522
|
-
loader = findLoaderByMIMEType(loaders, options?.mimeType);
|
|
2523
|
-
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}`;
|
|
2524
2746
|
}
|
|
2525
2747
|
loader = loader || findLoaderByUrl(loaders, testUrl);
|
|
2526
2748
|
reason = reason || (loader ? `matched url ${testUrl}` : "");
|
|
@@ -2528,8 +2750,8 @@ var __exports__ = (() => {
|
|
|
2528
2750
|
reason = reason || (loader ? `matched MIME type ${type}` : "");
|
|
2529
2751
|
loader = loader || findLoaderByInitialBytes(loaders, data);
|
|
2530
2752
|
reason = reason || (loader ? `matched initial data ${getFirstCharacters(data)}` : "");
|
|
2531
|
-
if (options?.fallbackMimeType) {
|
|
2532
|
-
loader = loader || findLoaderByMIMEType(loaders, options?.fallbackMimeType);
|
|
2753
|
+
if (options?.core?.fallbackMimeType) {
|
|
2754
|
+
loader = loader || findLoaderByMIMEType(loaders, options?.core?.fallbackMimeType);
|
|
2533
2755
|
reason = reason || (loader ? `matched fallback MIME type ${type}` : "");
|
|
2534
2756
|
}
|
|
2535
2757
|
if (reason) {
|
|
@@ -2622,12 +2844,12 @@ var __exports__ = (() => {
|
|
|
2622
2844
|
return tests.some((test) => testBinary(data, byteOffset, loader, test));
|
|
2623
2845
|
}
|
|
2624
2846
|
function testBinary(data, byteOffset, loader, test) {
|
|
2625
|
-
if (test
|
|
2847
|
+
if (isArrayBufferLike(test)) {
|
|
2626
2848
|
return compareArrayBuffers(test, data, test.byteLength);
|
|
2627
2849
|
}
|
|
2628
2850
|
switch (typeof test) {
|
|
2629
2851
|
case "function":
|
|
2630
|
-
return test(data);
|
|
2852
|
+
return test(ensureArrayBuffer(data));
|
|
2631
2853
|
case "string":
|
|
2632
2854
|
const magic = getMagicString(data, byteOffset, test.length);
|
|
2633
2855
|
return test === magic;
|
|
@@ -2668,7 +2890,7 @@ var __exports__ = (() => {
|
|
|
2668
2890
|
const chunkLength = Math.min(string.length - offset, chunkSize);
|
|
2669
2891
|
const chunk = string.slice(offset, offset + chunkLength);
|
|
2670
2892
|
offset += chunkLength;
|
|
2671
|
-
yield textEncoder.encode(chunk);
|
|
2893
|
+
yield ensureArrayBuffer(textEncoder.encode(chunk));
|
|
2672
2894
|
}
|
|
2673
2895
|
}
|
|
2674
2896
|
|
|
@@ -2745,8 +2967,11 @@ var __exports__ = (() => {
|
|
|
2745
2967
|
return makeStreamIterator(data, options);
|
|
2746
2968
|
}
|
|
2747
2969
|
if (isResponse(data)) {
|
|
2748
|
-
const
|
|
2749
|
-
|
|
2970
|
+
const responseBody = data.body;
|
|
2971
|
+
if (!responseBody) {
|
|
2972
|
+
throw new Error("Readable stream not available on Response");
|
|
2973
|
+
}
|
|
2974
|
+
return makeStreamIterator(responseBody, options);
|
|
2750
2975
|
}
|
|
2751
2976
|
throw new Error("makeIterator");
|
|
2752
2977
|
}
|
|
@@ -2757,43 +2982,29 @@ var __exports__ = (() => {
|
|
|
2757
2982
|
if (loader.text && typeof data === "string") {
|
|
2758
2983
|
return data;
|
|
2759
2984
|
}
|
|
2760
|
-
if (
|
|
2985
|
+
if (isBuffer(data)) {
|
|
2761
2986
|
data = data.buffer;
|
|
2762
2987
|
}
|
|
2763
|
-
if (data
|
|
2764
|
-
const
|
|
2988
|
+
if (isArrayBufferLike(data)) {
|
|
2989
|
+
const bufferSource = toArrayBufferView(data);
|
|
2765
2990
|
if (loader.text && !loader.binary) {
|
|
2766
2991
|
const textDecoder = new TextDecoder("utf8");
|
|
2767
|
-
return textDecoder.decode(
|
|
2768
|
-
}
|
|
2769
|
-
return arrayBuffer;
|
|
2770
|
-
}
|
|
2771
|
-
if (ArrayBuffer.isView(data)) {
|
|
2772
|
-
if (loader.text && !loader.binary) {
|
|
2773
|
-
const textDecoder = new TextDecoder("utf8");
|
|
2774
|
-
return textDecoder.decode(data);
|
|
2775
|
-
}
|
|
2776
|
-
let arrayBuffer = data.buffer;
|
|
2777
|
-
const byteLength = data.byteLength || data.length;
|
|
2778
|
-
if (data.byteOffset !== 0 || byteLength !== arrayBuffer.byteLength) {
|
|
2779
|
-
arrayBuffer = arrayBuffer.slice(data.byteOffset, data.byteOffset + byteLength);
|
|
2992
|
+
return textDecoder.decode(bufferSource);
|
|
2780
2993
|
}
|
|
2781
|
-
return
|
|
2994
|
+
return toArrayBuffer2(bufferSource);
|
|
2782
2995
|
}
|
|
2783
2996
|
throw new Error(ERR_DATA);
|
|
2784
2997
|
}
|
|
2785
2998
|
async function getArrayBufferOrStringFromData(data, loader, options) {
|
|
2786
|
-
|
|
2787
|
-
if (typeof data === "string" || isArrayBuffer) {
|
|
2999
|
+
if (typeof data === "string" || isArrayBufferLike(data)) {
|
|
2788
3000
|
return getArrayBufferOrStringFromDataSync(data, loader, options);
|
|
2789
3001
|
}
|
|
2790
3002
|
if (isBlob(data)) {
|
|
2791
3003
|
data = await makeResponse(data);
|
|
2792
3004
|
}
|
|
2793
3005
|
if (isResponse(data)) {
|
|
2794
|
-
|
|
2795
|
-
await
|
|
2796
|
-
return loader.binary ? await response.arrayBuffer() : await response.text();
|
|
3006
|
+
await checkResponse(data);
|
|
3007
|
+
return loader.binary ? await data.arrayBuffer() : await data.text();
|
|
2797
3008
|
}
|
|
2798
3009
|
if (isReadableStream(data)) {
|
|
2799
3010
|
data = makeIterator(data, options);
|
|
@@ -2804,13 +3015,18 @@ var __exports__ = (() => {
|
|
|
2804
3015
|
throw new Error(ERR_DATA);
|
|
2805
3016
|
}
|
|
2806
3017
|
async function getAsyncIterableFromData(data, options) {
|
|
3018
|
+
if (isPromise(data)) {
|
|
3019
|
+
data = await data;
|
|
3020
|
+
}
|
|
2807
3021
|
if (isIterator(data)) {
|
|
2808
3022
|
return data;
|
|
2809
3023
|
}
|
|
2810
3024
|
if (isResponse(data)) {
|
|
2811
|
-
|
|
2812
|
-
await
|
|
2813
|
-
|
|
3025
|
+
await checkResponse(data);
|
|
3026
|
+
const body = await data.body;
|
|
3027
|
+
if (!body) {
|
|
3028
|
+
throw new Error(ERR_DATA);
|
|
3029
|
+
}
|
|
2814
3030
|
return makeIterator(body, options);
|
|
2815
3031
|
}
|
|
2816
3032
|
if (isBlob(data) || isReadableStream(data)) {
|
|
@@ -2819,17 +3035,20 @@ var __exports__ = (() => {
|
|
|
2819
3035
|
if (isAsyncIterable(data)) {
|
|
2820
3036
|
return data;
|
|
2821
3037
|
}
|
|
3038
|
+
if (isIterable(data)) {
|
|
3039
|
+
return data;
|
|
3040
|
+
}
|
|
2822
3041
|
return getIterableFromData(data);
|
|
2823
3042
|
}
|
|
2824
3043
|
function getIterableFromData(data) {
|
|
2825
3044
|
if (ArrayBuffer.isView(data)) {
|
|
2826
3045
|
return function* oneChunk() {
|
|
2827
|
-
yield data
|
|
3046
|
+
yield toArrayBuffer2(data);
|
|
2828
3047
|
}();
|
|
2829
3048
|
}
|
|
2830
|
-
if (data
|
|
3049
|
+
if (isArrayBufferLike(data)) {
|
|
2831
3050
|
return function* oneChunk() {
|
|
2832
|
-
yield data;
|
|
3051
|
+
yield toArrayBuffer2(data);
|
|
2833
3052
|
}();
|
|
2834
3053
|
}
|
|
2835
3054
|
if (isIterator(data)) {
|
|
@@ -2845,11 +3064,12 @@ var __exports__ = (() => {
|
|
|
2845
3064
|
function getFetchFunction(options, context) {
|
|
2846
3065
|
const globalOptions = getGlobalLoaderOptions();
|
|
2847
3066
|
const loaderOptions = options || globalOptions;
|
|
2848
|
-
|
|
2849
|
-
|
|
3067
|
+
const fetchOption = loaderOptions.fetch ?? loaderOptions.core?.fetch;
|
|
3068
|
+
if (typeof fetchOption === "function") {
|
|
3069
|
+
return fetchOption;
|
|
2850
3070
|
}
|
|
2851
|
-
if (isObject(
|
|
2852
|
-
return (url) => fetchFile(url,
|
|
3071
|
+
if (isObject(fetchOption)) {
|
|
3072
|
+
return (url) => fetchFile(url, fetchOption);
|
|
2853
3073
|
}
|
|
2854
3074
|
if (context?.fetch) {
|
|
2855
3075
|
return context?.fetch;
|
|
@@ -2909,22 +3129,21 @@ var __exports__ = (() => {
|
|
|
2909
3129
|
if (!loader) {
|
|
2910
3130
|
return null;
|
|
2911
3131
|
}
|
|
2912
|
-
|
|
3132
|
+
const strictOptions = normalizeOptions(options, loader, candidateLoaders, url);
|
|
2913
3133
|
context = getLoaderContext(
|
|
2914
3134
|
// @ts-expect-error
|
|
2915
3135
|
{ url, _parse: parse, loaders: candidateLoaders },
|
|
2916
|
-
|
|
3136
|
+
strictOptions,
|
|
2917
3137
|
context || null
|
|
2918
3138
|
);
|
|
2919
|
-
return await parseWithLoader(loader, data,
|
|
3139
|
+
return await parseWithLoader(loader, data, strictOptions, context);
|
|
2920
3140
|
}
|
|
2921
3141
|
async function parseWithLoader(loader, data, options, context) {
|
|
2922
3142
|
validateWorkerVersion(loader);
|
|
2923
3143
|
options = mergeOptions(loader.options, options);
|
|
2924
3144
|
if (isResponse(data)) {
|
|
2925
|
-
const
|
|
2926
|
-
const
|
|
2927
|
-
const headers = Object.fromEntries(response.headers.entries());
|
|
3145
|
+
const { ok, redirected, status, statusText, type, url } = data;
|
|
3146
|
+
const headers = Object.fromEntries(data.headers.entries());
|
|
2928
3147
|
context.response = { headers, ok, redirected, status, statusText, type, url };
|
|
2929
3148
|
}
|
|
2930
3149
|
data = await getArrayBufferOrStringFromData(data, loader, options);
|
|
@@ -2959,17 +3178,17 @@ var __exports__ = (() => {
|
|
|
2959
3178
|
if (!loader) {
|
|
2960
3179
|
return null;
|
|
2961
3180
|
}
|
|
2962
|
-
|
|
3181
|
+
const strictOptions = normalizeOptions(options, loader, candidateLoaders);
|
|
2963
3182
|
const url = getResourceUrl(data);
|
|
2964
3183
|
const parse2 = () => {
|
|
2965
3184
|
throw new Error("parseSync called parse (which is async");
|
|
2966
3185
|
};
|
|
2967
3186
|
context = getLoaderContext(
|
|
2968
3187
|
{ url, _parseSync: parse2, _parse: parse2, loaders },
|
|
2969
|
-
|
|
3188
|
+
strictOptions,
|
|
2970
3189
|
context || null
|
|
2971
3190
|
);
|
|
2972
|
-
return parseWithLoaderSync(loader, data,
|
|
3191
|
+
return parseWithLoaderSync(loader, data, strictOptions, context);
|
|
2973
3192
|
}
|
|
2974
3193
|
function parseWithLoaderSync(loader, data, options, context) {
|
|
2975
3194
|
data = getArrayBufferOrStringFromDataSync(data, loader, options);
|
|
@@ -3041,17 +3260,17 @@ var __exports__ = (() => {
|
|
|
3041
3260
|
if (!loader) {
|
|
3042
3261
|
return [];
|
|
3043
3262
|
}
|
|
3044
|
-
|
|
3263
|
+
const strictOptions = normalizeOptions(options, loader, loaderArray, url);
|
|
3045
3264
|
context = getLoaderContext(
|
|
3046
3265
|
{ url, _parseInBatches: parseInBatches, _parse: parse, loaders: loaderArray },
|
|
3047
|
-
|
|
3266
|
+
strictOptions,
|
|
3048
3267
|
context || null
|
|
3049
3268
|
);
|
|
3050
|
-
return await parseWithLoaderInBatches(loader, data,
|
|
3269
|
+
return await parseWithLoaderInBatches(loader, data, strictOptions, context);
|
|
3051
3270
|
}
|
|
3052
3271
|
async function parseWithLoaderInBatches(loader, data, options, context) {
|
|
3053
3272
|
const outputIterator = await parseToOutputIterator(loader, data, options, context);
|
|
3054
|
-
if (!options
|
|
3273
|
+
if (!options?.core?.metadata) {
|
|
3055
3274
|
return outputIterator;
|
|
3056
3275
|
}
|
|
3057
3276
|
const metadataBatch = {
|
|
@@ -3073,7 +3292,10 @@ var __exports__ = (() => {
|
|
|
3073
3292
|
}
|
|
3074
3293
|
async function parseToOutputIterator(loader, data, options, context) {
|
|
3075
3294
|
const inputIterator = await getAsyncIterableFromData(data, options);
|
|
3076
|
-
const transformedIterator = await applyInputTransforms(
|
|
3295
|
+
const transformedIterator = await applyInputTransforms(
|
|
3296
|
+
inputIterator,
|
|
3297
|
+
options?.core?.transforms || []
|
|
3298
|
+
);
|
|
3077
3299
|
if (loader.parseInBatches) {
|
|
3078
3300
|
return loader.parseInBatches(transformedIterator, options, context);
|
|
3079
3301
|
}
|
|
@@ -3085,7 +3307,7 @@ var __exports__ = (() => {
|
|
|
3085
3307
|
arrayBuffer,
|
|
3086
3308
|
loader,
|
|
3087
3309
|
// TODO - Hack: supply loaders MIME type to ensure we match it
|
|
3088
|
-
{ ...options, mimeType: loader.mimeTypes[0] },
|
|
3310
|
+
{ ...options, core: { ...options?.core, mimeType: loader.mimeTypes[0] } },
|
|
3089
3311
|
context
|
|
3090
3312
|
);
|
|
3091
3313
|
const batch = convertDataToBatch(parsedData, loader);
|
|
@@ -3167,7 +3389,7 @@ var __exports__ = (() => {
|
|
|
3167
3389
|
}
|
|
3168
3390
|
if (writer.encodeText) {
|
|
3169
3391
|
const text = await writer.encodeText(data, options);
|
|
3170
|
-
return new TextEncoder().encode(text);
|
|
3392
|
+
return ensureArrayBuffer(new TextEncoder().encode(text));
|
|
3171
3393
|
}
|
|
3172
3394
|
if (writer.encodeInBatches) {
|
|
3173
3395
|
const batches = encodeTableInBatches(data, writer, options);
|
|
@@ -3218,7 +3440,7 @@ var __exports__ = (() => {
|
|
|
3218
3440
|
return writer.encodeSync(data, options);
|
|
3219
3441
|
}
|
|
3220
3442
|
if (writer.encodeTextSync) {
|
|
3221
|
-
return new TextEncoder().encode(writer.encodeTextSync(data, options));
|
|
3443
|
+
return ensureArrayBuffer(new TextEncoder().encode(writer.encodeTextSync(data, options)));
|
|
3222
3444
|
}
|
|
3223
3445
|
throw new Error(`Writer ${writer.name} could not synchronously encode data`);
|
|
3224
3446
|
}
|