@loaders.gl/core 5.0.0-alpha.1 → 5.0.0-alpha.3
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/LICENSE +14 -3
- package/dist/dist.dev.js +416 -151
- package/dist/dist.min.js +3 -3
- package/dist/index.cjs +1944 -245
- package/dist/index.cjs.map +3 -4
- package/dist/iterators/make-iterator/make-stream-iterator.js +49 -10
- package/dist/iterators/make-iterator/make-stream-iterator.js.map +1 -1
- package/dist/lib/api/load-loader.js +1 -7
- package/dist/lib/api/load-loader.js.map +1 -1
- package/dist/lib/api/load.d.ts.map +1 -1
- package/dist/lib/api/load.js +24 -3
- package/dist/lib/api/load.js.map +1 -1
- package/dist/lib/api/parse.d.ts.map +1 -1
- package/dist/lib/api/parse.js +4 -1
- package/dist/lib/api/parse.js.map +1 -1
- package/dist/lib/filesystems/browser-filesystem.d.ts.map +1 -1
- package/dist/lib/filesystems/browser-filesystem.js +25 -11
- package/dist/lib/filesystems/browser-filesystem.js.map +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/lib/loader-utils/get-fetch-function.js +24 -10
- package/dist/lib/loader-utils/get-fetch-function.js.map +1 -1
- package/dist/null-loader.js +1 -1
- package/dist/null-worker-node.js +96 -56
- package/dist/null-worker.js +96 -56
- package/package.json +6 -6
- package/src/iterators/make-iterator/make-stream-iterator.ts +48 -10
- package/src/lib/api/load-loader.ts +2 -13
- package/src/lib/api/load.ts +44 -4
- package/src/lib/api/parse.ts +5 -0
- package/src/lib/filesystems/browser-filesystem.ts +25 -11
- package/src/lib/loader-utils/get-fetch-function.ts +23 -12
package/dist/dist.dev.js
CHANGED
|
@@ -10,7 +10,6 @@ var __exports__ = (() => {
|
|
|
10
10
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
11
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
14
13
|
var __export = (target, all) => {
|
|
15
14
|
for (var name in all)
|
|
16
15
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -24,10 +23,6 @@ var __exports__ = (() => {
|
|
|
24
23
|
return to;
|
|
25
24
|
};
|
|
26
25
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
-
var __publicField = (obj, key, value) => {
|
|
28
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
29
|
-
return value;
|
|
30
|
-
};
|
|
31
26
|
|
|
32
27
|
// bundle.ts
|
|
33
28
|
var bundle_exports = {};
|
|
@@ -686,7 +681,7 @@ var __exports__ = (() => {
|
|
|
686
681
|
}
|
|
687
682
|
const options = { ...baseOptions };
|
|
688
683
|
for (const [key, newValue] of Object.entries(newOptions)) {
|
|
689
|
-
if (
|
|
684
|
+
if (isPureObject(newValue)) {
|
|
690
685
|
options[key] = mergeOptionsRecursively(
|
|
691
686
|
options[key] || {},
|
|
692
687
|
newOptions[key],
|
|
@@ -784,7 +779,9 @@ var __exports__ = (() => {
|
|
|
784
779
|
* Call to resolve the `result` Promise with the supplied value
|
|
785
780
|
*/
|
|
786
781
|
done(value) {
|
|
787
|
-
|
|
782
|
+
if (!this.isRunning) {
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
788
785
|
this.isRunning = false;
|
|
789
786
|
this._resolve(value);
|
|
790
787
|
}
|
|
@@ -792,14 +789,42 @@ var __exports__ = (() => {
|
|
|
792
789
|
* Call to reject the `result` Promise with the supplied error
|
|
793
790
|
*/
|
|
794
791
|
error(error) {
|
|
795
|
-
|
|
792
|
+
if (!this.isRunning) {
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
796
795
|
this.isRunning = false;
|
|
797
796
|
this._reject(error);
|
|
798
797
|
}
|
|
798
|
+
/**
|
|
799
|
+
* Terminates the worker executing this job and rejects its result.
|
|
800
|
+
* @param reason Abort reason supplied by the caller, or a cross-runtime `AbortError`.
|
|
801
|
+
*/
|
|
802
|
+
abort(reason) {
|
|
803
|
+
if (!this.isRunning) {
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
const error = reason ?? createAbortError(`Worker job "${this.name}" was aborted`);
|
|
807
|
+
this.workerThread.destroy();
|
|
808
|
+
this.error(error);
|
|
809
|
+
}
|
|
799
810
|
};
|
|
811
|
+
function createAbortError(message) {
|
|
812
|
+
const error = new Error(message);
|
|
813
|
+
error.name = "AbortError";
|
|
814
|
+
return error;
|
|
815
|
+
}
|
|
800
816
|
|
|
801
817
|
// ../worker-utils/src/lib/node/worker_threads-browser.ts
|
|
802
818
|
var NodeWorker = class {
|
|
819
|
+
/** Restores the native worker constructor when this browser shim is embedded in a Node bundle. */
|
|
820
|
+
constructor(...arguments_) {
|
|
821
|
+
const runtimeProcess = globalThis.process;
|
|
822
|
+
const WorkerConstructor = runtimeProcess?.getBuiltinModule?.("node:worker_threads").Worker;
|
|
823
|
+
if (WorkerConstructor) {
|
|
824
|
+
return new WorkerConstructor(...arguments_);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
/** No-op browser fallback matching the native Worker API. */
|
|
803
828
|
terminate() {
|
|
804
829
|
}
|
|
805
830
|
};
|
|
@@ -998,8 +1023,9 @@ var __exports__ = (() => {
|
|
|
998
1023
|
if (this.url) {
|
|
999
1024
|
const absolute = this.url.includes(":/") || this.url.startsWith("/");
|
|
1000
1025
|
const url = absolute ? this.url : `./${this.url}`;
|
|
1026
|
+
const workerUrl = url.startsWith("file:") ? new URL(url) : url;
|
|
1001
1027
|
const type = this.url.endsWith(".ts") || this.url.endsWith(".mjs") ? "module" : "commonjs";
|
|
1002
|
-
worker = new NodeWorker(
|
|
1028
|
+
worker = new NodeWorker(workerUrl, { eval: false, type });
|
|
1003
1029
|
} else if (this.source) {
|
|
1004
1030
|
worker = new NodeWorker(this.source, { eval: true });
|
|
1005
1031
|
} else {
|
|
@@ -1124,13 +1150,16 @@ var __exports__ = (() => {
|
|
|
1124
1150
|
*/
|
|
1125
1151
|
returnWorkerToQueue(worker) {
|
|
1126
1152
|
const shouldDestroyWorker = (
|
|
1127
|
-
//
|
|
1153
|
+
// Aborted jobs terminate their worker immediately.
|
|
1154
|
+
worker.terminated || // If the pool is destroyed, there is no reason to keep the worker around
|
|
1128
1155
|
this.isDestroyed || // If the app has disabled worker reuse, any completed workers should be destroyed
|
|
1129
1156
|
!this.reuseWorkers || // If concurrency has been lowered, this worker might be surplus to requirements
|
|
1130
1157
|
this.count > this._getMaxConcurrency()
|
|
1131
1158
|
);
|
|
1132
1159
|
if (shouldDestroyWorker) {
|
|
1133
|
-
worker.
|
|
1160
|
+
if (!worker.terminated) {
|
|
1161
|
+
worker.destroy();
|
|
1162
|
+
}
|
|
1134
1163
|
this.count--;
|
|
1135
1164
|
} else {
|
|
1136
1165
|
worker.unref();
|
|
@@ -1167,9 +1196,11 @@ var __exports__ = (() => {
|
|
|
1167
1196
|
onDebug: () => {
|
|
1168
1197
|
}
|
|
1169
1198
|
};
|
|
1170
|
-
var
|
|
1199
|
+
var WorkerFarm = class _WorkerFarm {
|
|
1171
1200
|
props;
|
|
1172
1201
|
workerPools = /* @__PURE__ */ new Map();
|
|
1202
|
+
// singleton
|
|
1203
|
+
static _workerFarm;
|
|
1173
1204
|
/** Checks if workers are supported on this platform */
|
|
1174
1205
|
static isSupported() {
|
|
1175
1206
|
return WorkerThread.isSupported();
|
|
@@ -1238,9 +1269,6 @@ var __exports__ = (() => {
|
|
|
1238
1269
|
};
|
|
1239
1270
|
}
|
|
1240
1271
|
};
|
|
1241
|
-
var WorkerFarm = _WorkerFarm;
|
|
1242
|
-
// singleton
|
|
1243
|
-
__publicField(WorkerFarm, "_workerFarm");
|
|
1244
1272
|
|
|
1245
1273
|
// ../worker-utils/src/lib/worker-api/get-worker-url.ts
|
|
1246
1274
|
var warnedWorkerVersionFallbacks = /* @__PURE__ */ new Set();
|
|
@@ -1250,8 +1278,11 @@ var __exports__ = (() => {
|
|
|
1250
1278
|
}
|
|
1251
1279
|
function getWorkerURL(worker, options = {}) {
|
|
1252
1280
|
const workerOptions = options[worker.id] || {};
|
|
1253
|
-
const workerFile = isBrowser3 ? `${worker.id}-worker.js` : `${worker.id}-worker-node.js`;
|
|
1281
|
+
const workerFile = isBrowser3 ? `${worker.id}-worker.js` : worker.workerNode || `${worker.id}-worker-node.js`;
|
|
1254
1282
|
let url = workerOptions.workerUrl;
|
|
1283
|
+
if (!url && typeof worker.worker === "string") {
|
|
1284
|
+
url = worker.worker;
|
|
1285
|
+
}
|
|
1255
1286
|
if (!url && worker.id === "compression") {
|
|
1256
1287
|
url = options.workerUrl;
|
|
1257
1288
|
}
|
|
@@ -1294,9 +1325,11 @@ var __exports__ = (() => {
|
|
|
1294
1325
|
if (!WorkerFarm.isSupported()) {
|
|
1295
1326
|
return false;
|
|
1296
1327
|
}
|
|
1297
|
-
|
|
1328
|
+
const workerOptions = options?.[worker.id];
|
|
1329
|
+
return Boolean((worker.worker || workerOptions?.workerUrl) && options?.worker);
|
|
1298
1330
|
}
|
|
1299
1331
|
async function processOnWorker(worker, data, options = {}, context = {}, jobContext = {}) {
|
|
1332
|
+
throwIfAborted(options.signal);
|
|
1300
1333
|
const name = getWorkerName(worker);
|
|
1301
1334
|
const workerFarm = WorkerFarm.getWorkerFarm(options);
|
|
1302
1335
|
const { source } = options;
|
|
@@ -1311,15 +1344,41 @@ var __exports__ = (() => {
|
|
|
1311
1344
|
// eslint-disable-next-line
|
|
1312
1345
|
onMessage.bind(null, context)
|
|
1313
1346
|
);
|
|
1314
|
-
const
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1347
|
+
const abortJob = () => job.abort(getAbortReason(options.signal));
|
|
1348
|
+
options.signal?.addEventListener("abort", abortJob, { once: true });
|
|
1349
|
+
if (options.signal?.aborted) {
|
|
1350
|
+
abortJob();
|
|
1351
|
+
}
|
|
1352
|
+
try {
|
|
1353
|
+
const { signal: _signal, ...workerOptions } = options;
|
|
1354
|
+
const transferableOptions = getTransferListForWriter(workerOptions);
|
|
1355
|
+
const transferableContext = getTransferListForWriter(jobContext);
|
|
1356
|
+
if (job.isRunning) {
|
|
1357
|
+
job.postMessage("process", {
|
|
1358
|
+
input: data,
|
|
1359
|
+
options: transferableOptions,
|
|
1360
|
+
context: transferableContext
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
const result = await job.result;
|
|
1364
|
+
return result.result;
|
|
1365
|
+
} finally {
|
|
1366
|
+
options.signal?.removeEventListener("abort", abortJob);
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
function throwIfAborted(signal) {
|
|
1370
|
+
if (!signal?.aborted) {
|
|
1371
|
+
return;
|
|
1372
|
+
}
|
|
1373
|
+
throw getAbortReason(signal);
|
|
1374
|
+
}
|
|
1375
|
+
function getAbortReason(signal) {
|
|
1376
|
+
return signal?.reason ?? createAbortError2("Worker job was aborted");
|
|
1377
|
+
}
|
|
1378
|
+
function createAbortError2(message) {
|
|
1379
|
+
const error = new Error(message);
|
|
1380
|
+
error.name = "AbortError";
|
|
1381
|
+
return error;
|
|
1323
1382
|
}
|
|
1324
1383
|
async function onMessage(context, job, type, payload) {
|
|
1325
1384
|
switch (type) {
|
|
@@ -1373,11 +1432,12 @@ var __exports__ = (() => {
|
|
|
1373
1432
|
}
|
|
1374
1433
|
return Boolean(canProcessOnWorker(loader, workerOptions));
|
|
1375
1434
|
}
|
|
1376
|
-
async function parseWithWorker(loader, data, options, context, parseOnMainThread) {
|
|
1435
|
+
async function parseWithWorker(loader, data, options, context, parseOnMainThread, signal) {
|
|
1436
|
+
const workerSignal = signal || getWorkerAbortSignal(options);
|
|
1377
1437
|
const result = await processOnWorker(
|
|
1378
1438
|
loader,
|
|
1379
1439
|
data,
|
|
1380
|
-
getWorkerOptions(options),
|
|
1440
|
+
{ ...getWorkerOptions(options), signal: workerSignal },
|
|
1381
1441
|
{
|
|
1382
1442
|
process: async (input, processOptions, _workerContext, parseContext) => {
|
|
1383
1443
|
if (!parseOnMainThread) {
|
|
@@ -1396,6 +1456,13 @@ var __exports__ = (() => {
|
|
|
1396
1456
|
);
|
|
1397
1457
|
return isLoaderWithWorkerResultDeserializer(loader) ? loader.deserializeWorkerResult(result, options, context) : result;
|
|
1398
1458
|
}
|
|
1459
|
+
function getWorkerAbortSignal(options) {
|
|
1460
|
+
const parquetSignal = options?.parquet?.signal;
|
|
1461
|
+
if (typeof AbortSignal !== "undefined" && parquetSignal instanceof AbortSignal) {
|
|
1462
|
+
return parquetSignal;
|
|
1463
|
+
}
|
|
1464
|
+
return void 0;
|
|
1465
|
+
}
|
|
1399
1466
|
function callParseOnMainThread(parseOnMainThread, input, options, context) {
|
|
1400
1467
|
if (parseOnMainThread.length <= 2) {
|
|
1401
1468
|
return parseOnMainThread(input, options);
|
|
@@ -1917,6 +1984,114 @@ var __exports__ = (() => {
|
|
|
1917
1984
|
}
|
|
1918
1985
|
};
|
|
1919
1986
|
|
|
1987
|
+
// ../loader-utils/src/lib/request-utils/request-credentials.ts
|
|
1988
|
+
var AUTHENTICATED_FETCH = /* @__PURE__ */ Symbol("loaders.gl.authenticated-fetch");
|
|
1989
|
+
var refreshPromises = /* @__PURE__ */ new WeakMap();
|
|
1990
|
+
function createAuthenticatedFetch(options) {
|
|
1991
|
+
const baseFetch = options.fetch || ((url, requestOptions) => fetch(url, requestOptions));
|
|
1992
|
+
if (!options.credentials.length) return baseFetch;
|
|
1993
|
+
const existingMetadata = baseFetch[AUTHENTICATED_FETCH];
|
|
1994
|
+
if (existingMetadata === options.credentials) return baseFetch;
|
|
1995
|
+
const authenticatedFetch = async (url, requestOptions = {}) => {
|
|
1996
|
+
const resolvedURL = parseHTTPURL(url);
|
|
1997
|
+
if (!resolvedURL) return baseFetch(url, requestOptions);
|
|
1998
|
+
const authorization = await authorizeRequest(resolvedURL, requestOptions, options.credentials);
|
|
1999
|
+
const response = await baseFetch(authorization.url, authorization.options);
|
|
2000
|
+
const refreshableCredentials = authorization.credentials.filter(
|
|
2001
|
+
({ credential }) => typeof credential.token === "function" && credential.refreshStatusCodes.includes(response.status)
|
|
2002
|
+
);
|
|
2003
|
+
if (!refreshableCredentials.length || !isReplayableRequest(requestOptions)) return response;
|
|
2004
|
+
if (requestOptions.signal?.aborted) throw createAbortError3();
|
|
2005
|
+
const refreshedTokens = /* @__PURE__ */ new Map();
|
|
2006
|
+
await Promise.all(
|
|
2007
|
+
refreshableCredentials.map(async ({ credential }) => {
|
|
2008
|
+
const token = await refreshCredential(credential, url, response);
|
|
2009
|
+
if (token) refreshedTokens.set(credential, token);
|
|
2010
|
+
})
|
|
2011
|
+
);
|
|
2012
|
+
if (!refreshedTokens.size) return response;
|
|
2013
|
+
await response.body?.cancel().catch(() => {
|
|
2014
|
+
});
|
|
2015
|
+
if (requestOptions.signal?.aborted) throw createAbortError3();
|
|
2016
|
+
const replayAuthorization = await authorizeRequest(
|
|
2017
|
+
resolvedURL,
|
|
2018
|
+
requestOptions,
|
|
2019
|
+
options.credentials,
|
|
2020
|
+
refreshedTokens,
|
|
2021
|
+
authorization.credentials
|
|
2022
|
+
);
|
|
2023
|
+
return baseFetch(replayAuthorization.url, replayAuthorization.options);
|
|
2024
|
+
};
|
|
2025
|
+
Object.defineProperty(authenticatedFetch, AUTHENTICATED_FETCH, {
|
|
2026
|
+
value: options.credentials
|
|
2027
|
+
});
|
|
2028
|
+
return authenticatedFetch;
|
|
2029
|
+
}
|
|
2030
|
+
async function authorizeRequest(sourceURL, requestOptions, credentials, tokenOverrides = /* @__PURE__ */ new Map(), previousCredentials = []) {
|
|
2031
|
+
const url = new URL(sourceURL);
|
|
2032
|
+
const headers = new Headers(requestOptions.headers);
|
|
2033
|
+
const resolvedCredentials = [];
|
|
2034
|
+
const previousTokens = new Map(
|
|
2035
|
+
previousCredentials.map(({ credential, token }) => [credential, token])
|
|
2036
|
+
);
|
|
2037
|
+
for (const credential of credentials) {
|
|
2038
|
+
if (!credential.origins.includes(url.origin)) continue;
|
|
2039
|
+
const overrideToken = tokenOverrides.get(credential);
|
|
2040
|
+
const previousToken = previousTokens.get(credential);
|
|
2041
|
+
const ownsQueryParameter = credential.type === "query-parameter" && previousToken !== void 0;
|
|
2042
|
+
const ownsHeader = credential.type === "header" && previousToken !== void 0;
|
|
2043
|
+
if (credential.type === "query-parameter" && url.searchParams.has(credential.name) && !ownsQueryParameter || credential.type === "header" && headers.has(credential.name) && !ownsHeader) {
|
|
2044
|
+
continue;
|
|
2045
|
+
}
|
|
2046
|
+
const token = overrideToken ?? previousToken ?? await resolveToken(credential.token, { url: sourceURL.toString(), reason: "request" });
|
|
2047
|
+
if (!token) continue;
|
|
2048
|
+
if (credential.type === "query-parameter") {
|
|
2049
|
+
url.searchParams.set(credential.name, token);
|
|
2050
|
+
} else {
|
|
2051
|
+
headers.set(credential.name, `${credential.prefix || ""}${token}`);
|
|
2052
|
+
}
|
|
2053
|
+
resolvedCredentials.push({ credential, token });
|
|
2054
|
+
}
|
|
2055
|
+
return {
|
|
2056
|
+
url: url.toString(),
|
|
2057
|
+
options: { ...requestOptions, headers },
|
|
2058
|
+
credentials: resolvedCredentials
|
|
2059
|
+
};
|
|
2060
|
+
}
|
|
2061
|
+
async function refreshCredential(credential, url, response) {
|
|
2062
|
+
const existingPromise = refreshPromises.get(credential);
|
|
2063
|
+
if (existingPromise) return existingPromise;
|
|
2064
|
+
const tokenProvider = credential.token;
|
|
2065
|
+
const promise = Promise.resolve(
|
|
2066
|
+
tokenProvider({
|
|
2067
|
+
url,
|
|
2068
|
+
reason: "refresh",
|
|
2069
|
+
response: { status: response.status, headers: response.headers }
|
|
2070
|
+
})
|
|
2071
|
+
).finally(() => refreshPromises.delete(credential));
|
|
2072
|
+
refreshPromises.set(credential, promise);
|
|
2073
|
+
return promise;
|
|
2074
|
+
}
|
|
2075
|
+
async function resolveToken(token, context) {
|
|
2076
|
+
return typeof token === "function" ? token(context) : token;
|
|
2077
|
+
}
|
|
2078
|
+
function parseHTTPURL(url) {
|
|
2079
|
+
try {
|
|
2080
|
+
const parsedURL = new URL(url);
|
|
2081
|
+
return ["http:", "https:"].includes(parsedURL.protocol) ? parsedURL : null;
|
|
2082
|
+
} catch {
|
|
2083
|
+
return null;
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
function isReplayableRequest(options) {
|
|
2087
|
+
const method = (options.method || "GET").toUpperCase();
|
|
2088
|
+
if (!["GET", "HEAD", "OPTIONS", "PUT", "DELETE"].includes(method)) return false;
|
|
2089
|
+
return !(options.body && typeof ReadableStream !== "undefined" && options.body instanceof ReadableStream);
|
|
2090
|
+
}
|
|
2091
|
+
function createAbortError3() {
|
|
2092
|
+
return new DOMException("The operation was aborted.", "AbortError");
|
|
2093
|
+
}
|
|
2094
|
+
|
|
1920
2095
|
// ../loader-utils/src/lib/path-utils/file-aliases.ts
|
|
1921
2096
|
var pathPrefix = "";
|
|
1922
2097
|
var fileAliases = {};
|
|
@@ -1939,91 +2114,6 @@ var __exports__ = (() => {
|
|
|
1939
2114
|
return filename2;
|
|
1940
2115
|
}
|
|
1941
2116
|
|
|
1942
|
-
// ../loader-utils/src/json-loader.ts
|
|
1943
|
-
var VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
1944
|
-
var JSONLoader = {
|
|
1945
|
-
dataType: null,
|
|
1946
|
-
batchType: null,
|
|
1947
|
-
name: "JSON",
|
|
1948
|
-
id: "json",
|
|
1949
|
-
module: "json",
|
|
1950
|
-
version: VERSION4,
|
|
1951
|
-
encoding: "json",
|
|
1952
|
-
format: "json",
|
|
1953
|
-
extensions: ["json", "geojson"],
|
|
1954
|
-
mimeTypes: ["application/json"],
|
|
1955
|
-
category: "json",
|
|
1956
|
-
text: true,
|
|
1957
|
-
parseTextSync,
|
|
1958
|
-
parse: async (arrayBuffer) => parseTextSync(new TextDecoder().decode(arrayBuffer)),
|
|
1959
|
-
options: {}
|
|
1960
|
-
};
|
|
1961
|
-
function parseTextSync(text) {
|
|
1962
|
-
return JSON.parse(text);
|
|
1963
|
-
}
|
|
1964
|
-
|
|
1965
|
-
// ../loader-utils/src/lib/node/buffer.browser.ts
|
|
1966
|
-
function toArrayBuffer(buffer) {
|
|
1967
|
-
return buffer;
|
|
1968
|
-
}
|
|
1969
|
-
|
|
1970
|
-
// ../loader-utils/src/lib/binary-utils/memory-conversion-utils.ts
|
|
1971
|
-
function isBuffer(value) {
|
|
1972
|
-
return value && typeof value === "object" && value.isBuffer;
|
|
1973
|
-
}
|
|
1974
|
-
function toArrayBuffer2(data) {
|
|
1975
|
-
if (isBuffer(data)) {
|
|
1976
|
-
return toArrayBuffer(data);
|
|
1977
|
-
}
|
|
1978
|
-
if (data instanceof ArrayBuffer) {
|
|
1979
|
-
return data;
|
|
1980
|
-
}
|
|
1981
|
-
if (isSharedArrayBuffer(data)) {
|
|
1982
|
-
return copyToArrayBuffer2(data);
|
|
1983
|
-
}
|
|
1984
|
-
if (ArrayBuffer.isView(data)) {
|
|
1985
|
-
const buffer = data.buffer;
|
|
1986
|
-
if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
|
|
1987
|
-
return buffer;
|
|
1988
|
-
}
|
|
1989
|
-
return buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
1990
|
-
}
|
|
1991
|
-
if (typeof data === "string") {
|
|
1992
|
-
const text = data;
|
|
1993
|
-
const uint8Array = new TextEncoder().encode(text);
|
|
1994
|
-
return uint8Array.buffer;
|
|
1995
|
-
}
|
|
1996
|
-
if (data && typeof data === "object" && data._toArrayBuffer) {
|
|
1997
|
-
return data._toArrayBuffer();
|
|
1998
|
-
}
|
|
1999
|
-
throw new Error("toArrayBuffer");
|
|
2000
|
-
}
|
|
2001
|
-
function ensureArrayBuffer(bufferSource) {
|
|
2002
|
-
if (bufferSource instanceof ArrayBuffer) {
|
|
2003
|
-
return bufferSource;
|
|
2004
|
-
}
|
|
2005
|
-
if (isSharedArrayBuffer(bufferSource)) {
|
|
2006
|
-
return copyToArrayBuffer2(bufferSource);
|
|
2007
|
-
}
|
|
2008
|
-
const { buffer, byteOffset, byteLength } = bufferSource;
|
|
2009
|
-
if (buffer instanceof ArrayBuffer && byteOffset === 0 && byteLength === buffer.byteLength) {
|
|
2010
|
-
return buffer;
|
|
2011
|
-
}
|
|
2012
|
-
return copyToArrayBuffer2(buffer, byteOffset, byteLength);
|
|
2013
|
-
}
|
|
2014
|
-
function copyToArrayBuffer2(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
|
|
2015
|
-
const view = new Uint8Array(buffer, byteOffset, byteLength);
|
|
2016
|
-
const copy = new Uint8Array(view.length);
|
|
2017
|
-
copy.set(view);
|
|
2018
|
-
return copy.buffer;
|
|
2019
|
-
}
|
|
2020
|
-
function toArrayBufferView(data) {
|
|
2021
|
-
if (ArrayBuffer.isView(data)) {
|
|
2022
|
-
return data;
|
|
2023
|
-
}
|
|
2024
|
-
return new Uint8Array(data);
|
|
2025
|
-
}
|
|
2026
|
-
|
|
2027
2117
|
// ../loader-utils/src/lib/path-utils/path.ts
|
|
2028
2118
|
var path_exports = {};
|
|
2029
2119
|
__export(path_exports, {
|
|
@@ -2167,6 +2257,91 @@ var __exports__ = (() => {
|
|
|
2167
2257
|
return res;
|
|
2168
2258
|
}
|
|
2169
2259
|
|
|
2260
|
+
// ../loader-utils/src/json-loader.ts
|
|
2261
|
+
var VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
2262
|
+
var JSONLoader = {
|
|
2263
|
+
dataType: null,
|
|
2264
|
+
batchType: null,
|
|
2265
|
+
name: "JSON",
|
|
2266
|
+
id: "json",
|
|
2267
|
+
module: "json",
|
|
2268
|
+
version: VERSION4,
|
|
2269
|
+
encoding: "json",
|
|
2270
|
+
format: "json",
|
|
2271
|
+
extensions: ["json", "geojson"],
|
|
2272
|
+
mimeTypes: ["application/json"],
|
|
2273
|
+
category: "json",
|
|
2274
|
+
text: true,
|
|
2275
|
+
parseTextSync,
|
|
2276
|
+
parse: async (arrayBuffer) => parseTextSync(new TextDecoder().decode(arrayBuffer)),
|
|
2277
|
+
options: {}
|
|
2278
|
+
};
|
|
2279
|
+
function parseTextSync(text) {
|
|
2280
|
+
return JSON.parse(text);
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
// ../loader-utils/src/lib/node/buffer.browser.ts
|
|
2284
|
+
function toArrayBuffer(buffer) {
|
|
2285
|
+
return buffer;
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
// ../loader-utils/src/lib/binary-utils/memory-conversion-utils.ts
|
|
2289
|
+
function isBuffer(value) {
|
|
2290
|
+
return value && typeof value === "object" && value.isBuffer;
|
|
2291
|
+
}
|
|
2292
|
+
function toArrayBuffer2(data) {
|
|
2293
|
+
if (isBuffer(data)) {
|
|
2294
|
+
return toArrayBuffer(data);
|
|
2295
|
+
}
|
|
2296
|
+
if (data instanceof ArrayBuffer) {
|
|
2297
|
+
return data;
|
|
2298
|
+
}
|
|
2299
|
+
if (isSharedArrayBuffer(data)) {
|
|
2300
|
+
return copyToArrayBuffer2(data);
|
|
2301
|
+
}
|
|
2302
|
+
if (ArrayBuffer.isView(data)) {
|
|
2303
|
+
const buffer = data.buffer;
|
|
2304
|
+
if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
|
|
2305
|
+
return buffer;
|
|
2306
|
+
}
|
|
2307
|
+
return buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
2308
|
+
}
|
|
2309
|
+
if (typeof data === "string") {
|
|
2310
|
+
const text = data;
|
|
2311
|
+
const uint8Array = new TextEncoder().encode(text);
|
|
2312
|
+
return uint8Array.buffer;
|
|
2313
|
+
}
|
|
2314
|
+
if (data && typeof data === "object" && data._toArrayBuffer) {
|
|
2315
|
+
return data._toArrayBuffer();
|
|
2316
|
+
}
|
|
2317
|
+
throw new Error("toArrayBuffer");
|
|
2318
|
+
}
|
|
2319
|
+
function ensureArrayBuffer(bufferSource) {
|
|
2320
|
+
if (bufferSource instanceof ArrayBuffer) {
|
|
2321
|
+
return bufferSource;
|
|
2322
|
+
}
|
|
2323
|
+
if (isSharedArrayBuffer(bufferSource)) {
|
|
2324
|
+
return copyToArrayBuffer2(bufferSource);
|
|
2325
|
+
}
|
|
2326
|
+
const { buffer, byteOffset, byteLength } = bufferSource;
|
|
2327
|
+
if (buffer instanceof ArrayBuffer && byteOffset === 0 && byteLength === buffer.byteLength) {
|
|
2328
|
+
return buffer;
|
|
2329
|
+
}
|
|
2330
|
+
return copyToArrayBuffer2(buffer, byteOffset, byteLength);
|
|
2331
|
+
}
|
|
2332
|
+
function copyToArrayBuffer2(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
|
|
2333
|
+
const view = new Uint8Array(buffer, byteOffset, byteLength);
|
|
2334
|
+
const copy = new Uint8Array(view.length);
|
|
2335
|
+
copy.set(view);
|
|
2336
|
+
return copy.buffer;
|
|
2337
|
+
}
|
|
2338
|
+
function toArrayBufferView(data) {
|
|
2339
|
+
if (ArrayBuffer.isView(data)) {
|
|
2340
|
+
return data;
|
|
2341
|
+
}
|
|
2342
|
+
return new Uint8Array(data);
|
|
2343
|
+
}
|
|
2344
|
+
|
|
2170
2345
|
// ../loader-utils/src/lib/files/blob-file.ts
|
|
2171
2346
|
var BlobFile = class {
|
|
2172
2347
|
handle;
|
|
@@ -2188,8 +2363,14 @@ var __exports__ = (() => {
|
|
|
2188
2363
|
isDirectory: false
|
|
2189
2364
|
};
|
|
2190
2365
|
}
|
|
2191
|
-
async read(start, length) {
|
|
2366
|
+
async read(start, length, signal) {
|
|
2367
|
+
if (signal?.aborted) {
|
|
2368
|
+
throw new Error("Request aborted");
|
|
2369
|
+
}
|
|
2192
2370
|
const arrayBuffer = await this.handle.slice(Number(start), Number(start) + Number(length)).arrayBuffer();
|
|
2371
|
+
if (signal?.aborted) {
|
|
2372
|
+
throw new Error("Request aborted");
|
|
2373
|
+
}
|
|
2193
2374
|
return arrayBuffer;
|
|
2194
2375
|
}
|
|
2195
2376
|
};
|
|
@@ -3201,20 +3382,57 @@ var __exports__ = (() => {
|
|
|
3201
3382
|
async function* makeBrowserStreamIterator(stream, options) {
|
|
3202
3383
|
const reader = stream.getReader();
|
|
3203
3384
|
let nextBatchPromise;
|
|
3385
|
+
let streamFinished = false;
|
|
3386
|
+
let streamReadFailed = false;
|
|
3387
|
+
let iteratorFailed = false;
|
|
3204
3388
|
try {
|
|
3205
3389
|
while (true) {
|
|
3206
3390
|
const currentBatchPromise = nextBatchPromise || reader.read();
|
|
3207
|
-
|
|
3208
|
-
|
|
3391
|
+
nextBatchPromise = void 0;
|
|
3392
|
+
let batch;
|
|
3393
|
+
try {
|
|
3394
|
+
batch = await currentBatchPromise;
|
|
3395
|
+
} catch (error) {
|
|
3396
|
+
streamReadFailed = true;
|
|
3397
|
+
throw error;
|
|
3209
3398
|
}
|
|
3210
|
-
const { done, value } =
|
|
3399
|
+
const { done, value } = batch;
|
|
3211
3400
|
if (done) {
|
|
3401
|
+
streamFinished = true;
|
|
3212
3402
|
return;
|
|
3213
3403
|
}
|
|
3404
|
+
if (options?._streamReadAhead) {
|
|
3405
|
+
nextBatchPromise = reader.read();
|
|
3406
|
+
void nextBatchPromise.catch(() => {
|
|
3407
|
+
});
|
|
3408
|
+
}
|
|
3214
3409
|
yield toArrayBuffer2(value);
|
|
3215
3410
|
}
|
|
3216
|
-
} catch (
|
|
3217
|
-
|
|
3411
|
+
} catch (error) {
|
|
3412
|
+
iteratorFailed = true;
|
|
3413
|
+
throw error;
|
|
3414
|
+
} finally {
|
|
3415
|
+
let cleanupFailed = false;
|
|
3416
|
+
let cleanupError;
|
|
3417
|
+
if (!streamFinished && !streamReadFailed) {
|
|
3418
|
+
try {
|
|
3419
|
+
await reader.cancel();
|
|
3420
|
+
} catch (error) {
|
|
3421
|
+
cleanupFailed = true;
|
|
3422
|
+
cleanupError = error;
|
|
3423
|
+
}
|
|
3424
|
+
}
|
|
3425
|
+
try {
|
|
3426
|
+
reader.releaseLock();
|
|
3427
|
+
} catch (error) {
|
|
3428
|
+
if (!cleanupFailed) {
|
|
3429
|
+
cleanupFailed = true;
|
|
3430
|
+
cleanupError = error;
|
|
3431
|
+
}
|
|
3432
|
+
}
|
|
3433
|
+
if (!iteratorFailed && cleanupFailed) {
|
|
3434
|
+
throw cleanupError;
|
|
3435
|
+
}
|
|
3218
3436
|
}
|
|
3219
3437
|
}
|
|
3220
3438
|
async function* makeNodeStreamIterator(stream, options) {
|
|
@@ -3335,14 +3553,14 @@ var __exports__ = (() => {
|
|
|
3335
3553
|
}
|
|
3336
3554
|
function getIterableFromData(data) {
|
|
3337
3555
|
if (ArrayBuffer.isView(data)) {
|
|
3338
|
-
return function* oneChunk() {
|
|
3556
|
+
return (function* oneChunk() {
|
|
3339
3557
|
yield toArrayBuffer2(data);
|
|
3340
|
-
}();
|
|
3558
|
+
})();
|
|
3341
3559
|
}
|
|
3342
3560
|
if (isArrayBufferLike(data)) {
|
|
3343
|
-
return function* oneChunk() {
|
|
3561
|
+
return (function* oneChunk() {
|
|
3344
3562
|
yield toArrayBuffer2(data);
|
|
3345
|
-
}();
|
|
3563
|
+
})();
|
|
3346
3564
|
}
|
|
3347
3565
|
if (isIterator(data)) {
|
|
3348
3566
|
return data;
|
|
@@ -3358,16 +3576,29 @@ var __exports__ = (() => {
|
|
|
3358
3576
|
const globalOptions = getGlobalLoaderOptions();
|
|
3359
3577
|
const loaderOptions = options || globalOptions;
|
|
3360
3578
|
const fetchOption = loaderOptions.fetch ?? loaderOptions.core?.fetch;
|
|
3579
|
+
let fetchFunction;
|
|
3361
3580
|
if (typeof fetchOption === "function") {
|
|
3362
|
-
|
|
3363
|
-
}
|
|
3364
|
-
|
|
3365
|
-
|
|
3581
|
+
fetchFunction = fetchOption;
|
|
3582
|
+
} else if (isObject(fetchOption)) {
|
|
3583
|
+
fetchFunction = (url, requestOptions) => fetchFile(url, mergeFetchOptions(fetchOption, requestOptions));
|
|
3584
|
+
} else if (context?.fetch) {
|
|
3585
|
+
fetchFunction = context.fetch;
|
|
3586
|
+
} else {
|
|
3587
|
+
fetchFunction = fetchFile;
|
|
3366
3588
|
}
|
|
3367
|
-
|
|
3368
|
-
|
|
3589
|
+
return createAuthenticatedFetch({
|
|
3590
|
+
fetch: fetchFunction,
|
|
3591
|
+
credentials: loaderOptions.core?.credentials || []
|
|
3592
|
+
});
|
|
3593
|
+
}
|
|
3594
|
+
function mergeFetchOptions(defaultOptions, requestOptions) {
|
|
3595
|
+
const options = { ...defaultOptions, ...requestOptions };
|
|
3596
|
+
if (defaultOptions.headers || requestOptions?.headers) {
|
|
3597
|
+
const headers = new Headers(defaultOptions.headers);
|
|
3598
|
+
new Headers(requestOptions?.headers).forEach((value, key) => headers.set(key, value));
|
|
3599
|
+
options.headers = headers;
|
|
3369
3600
|
}
|
|
3370
|
-
return
|
|
3601
|
+
return options;
|
|
3371
3602
|
}
|
|
3372
3603
|
|
|
3373
3604
|
// src/lib/api/load-loader.ts
|
|
@@ -3451,12 +3682,7 @@ var __exports__ = (() => {
|
|
|
3451
3682
|
function getLoaderImplementationCacheKey(loader, options) {
|
|
3452
3683
|
const loaderOptions = options?.[loader.id];
|
|
3453
3684
|
const defaultLoaderOptions = loader.options?.[loader.id];
|
|
3454
|
-
return String(
|
|
3455
|
-
loaderOptions?.backend || getDeprecatedImplementationBackend(loaderOptions?.implementation) || defaultLoaderOptions?.backend || ""
|
|
3456
|
-
);
|
|
3457
|
-
}
|
|
3458
|
-
function getDeprecatedImplementationBackend(implementation) {
|
|
3459
|
-
return implementation === "js" ? "typescript" : implementation;
|
|
3685
|
+
return String(loaderOptions?.backend || defaultLoaderOptions?.backend || "");
|
|
3460
3686
|
}
|
|
3461
3687
|
async function importLoaderImplementation(implementationSpecifier, loaderId) {
|
|
3462
3688
|
const moduleExports = await import(
|
|
@@ -3587,7 +3813,7 @@ var __exports__ = (() => {
|
|
|
3587
3813
|
case "geojson-table":
|
|
3588
3814
|
return Array.isArray(table.features);
|
|
3589
3815
|
case "columnar-table":
|
|
3590
|
-
return table.data && typeof table.data === "object";
|
|
3816
|
+
return Boolean(table.data && typeof table.data === "object");
|
|
3591
3817
|
case "arrow-table":
|
|
3592
3818
|
return Boolean(table?.data?.numRows !== void 0);
|
|
3593
3819
|
default:
|
|
@@ -3747,6 +3973,7 @@ var __exports__ = (() => {
|
|
|
3747
3973
|
resolvedOptions = options;
|
|
3748
3974
|
}
|
|
3749
3975
|
if (!Array.isArray(resolvedLoaders) && isSourceLoader(resolvedLoaders)) {
|
|
3976
|
+
const sourceLoader = await resolveSourceLoader(resolvedLoaders, url, resolvedOptions);
|
|
3750
3977
|
const runtimeCoreApi = {
|
|
3751
3978
|
fetchFile,
|
|
3752
3979
|
parse,
|
|
@@ -3756,13 +3983,14 @@ var __exports__ = (() => {
|
|
|
3756
3983
|
load,
|
|
3757
3984
|
loadInBatches
|
|
3758
3985
|
};
|
|
3759
|
-
return
|
|
3986
|
+
return sourceLoader.createDataSource(
|
|
3760
3987
|
url,
|
|
3761
3988
|
resolvedOptions || {},
|
|
3762
3989
|
runtimeCoreApi
|
|
3763
3990
|
);
|
|
3764
3991
|
}
|
|
3765
3992
|
if (Array.isArray(resolvedLoaders) && resolvedLoaders.length === 1 && isSourceLoader(resolvedLoaders[0])) {
|
|
3993
|
+
const sourceLoader = await resolveSourceLoader(resolvedLoaders[0], url, resolvedOptions);
|
|
3766
3994
|
const runtimeCoreApi = {
|
|
3767
3995
|
fetchFile,
|
|
3768
3996
|
parse,
|
|
@@ -3772,7 +4000,7 @@ var __exports__ = (() => {
|
|
|
3772
4000
|
load,
|
|
3773
4001
|
loadInBatches
|
|
3774
4002
|
};
|
|
3775
|
-
return
|
|
4003
|
+
return sourceLoader.createDataSource(
|
|
3776
4004
|
url,
|
|
3777
4005
|
resolvedOptions || {},
|
|
3778
4006
|
runtimeCoreApi
|
|
@@ -3784,7 +4012,8 @@ var __exports__ = (() => {
|
|
|
3784
4012
|
core: { ...resolvedOptions?.core, nothrow: true }
|
|
3785
4013
|
});
|
|
3786
4014
|
if (selectedLoader && isSourceLoader(selectedLoader)) {
|
|
3787
|
-
|
|
4015
|
+
const sourceLoader = await resolveSourceLoader(selectedLoader, url, resolvedOptions);
|
|
4016
|
+
return sourceLoader.createDataSource(
|
|
3788
4017
|
url,
|
|
3789
4018
|
resolvedOptions || {},
|
|
3790
4019
|
{
|
|
@@ -3798,6 +4027,15 @@ var __exports__ = (() => {
|
|
|
3798
4027
|
}
|
|
3799
4028
|
);
|
|
3800
4029
|
}
|
|
4030
|
+
if (selectedLoader && typeof url === "string") {
|
|
4031
|
+
const loaderImplementation = await getLoaderImplementation(
|
|
4032
|
+
selectedLoader,
|
|
4033
|
+
resolvedOptions,
|
|
4034
|
+
url
|
|
4035
|
+
);
|
|
4036
|
+
const parseUrl = loaderImplementation.parseUrl;
|
|
4037
|
+
if (parseUrl) return await parseUrl(url, resolvedOptions, context);
|
|
4038
|
+
}
|
|
3801
4039
|
}
|
|
3802
4040
|
const fetch2 = getFetchFunction(resolvedOptions);
|
|
3803
4041
|
let data = url;
|
|
@@ -3821,6 +4059,16 @@ var __exports__ = (() => {
|
|
|
3821
4059
|
}
|
|
3822
4060
|
return Array.isArray(resolvedLoaders) ? await parse(data, resolvedLoaders, resolvedOptions, context) : await parse(data, resolvedLoaders, resolvedOptions, context);
|
|
3823
4061
|
}
|
|
4062
|
+
async function resolveSourceLoader(loader, url, options) {
|
|
4063
|
+
if (!loader.preload) {
|
|
4064
|
+
return loader;
|
|
4065
|
+
}
|
|
4066
|
+
const sourceLoader = await loader.preload(typeof url === "string" ? url : "", options);
|
|
4067
|
+
if (!isSourceLoader(sourceLoader)) {
|
|
4068
|
+
throw new Error(`${loader.id} source loader preload() did not return a runtime source loader`);
|
|
4069
|
+
}
|
|
4070
|
+
return sourceLoader;
|
|
4071
|
+
}
|
|
3824
4072
|
|
|
3825
4073
|
// src/lib/api/core-api.ts
|
|
3826
4074
|
var coreApi = Object.freeze({
|
|
@@ -3913,6 +4161,9 @@ var __exports__ = (() => {
|
|
|
3913
4161
|
data = await getArrayBufferFromData(data, options);
|
|
3914
4162
|
return await parseWithWorker(loaderWithParser, data, options, context, parse);
|
|
3915
4163
|
}
|
|
4164
|
+
if (isBlob(data) && loaderWithParser.parseBlob) {
|
|
4165
|
+
return await loaderWithParser.parseBlob(data, options, context);
|
|
4166
|
+
}
|
|
3916
4167
|
data = await getArrayBufferOrStringFromData(data, loader, options);
|
|
3917
4168
|
return await parseWithLoaderImplementation(loaderWithParser, data, options, context);
|
|
3918
4169
|
}
|
|
@@ -4267,18 +4518,29 @@ var __exports__ = (() => {
|
|
|
4267
4518
|
if (path.includes("://")) {
|
|
4268
4519
|
return this._fetch(path, options);
|
|
4269
4520
|
}
|
|
4270
|
-
const file = this.
|
|
4521
|
+
const file = this._getFile(path, true);
|
|
4271
4522
|
if (!file) {
|
|
4272
4523
|
return new Response(path, { status: 400, statusText: "NOT FOUND" });
|
|
4273
4524
|
}
|
|
4274
4525
|
const headers = new Headers(options?.headers);
|
|
4275
4526
|
const range = headers.get("Range");
|
|
4276
|
-
const bytes = range && /bytes=(
|
|
4527
|
+
const bytes = range && /bytes=(\d+)-(\d+)/.exec(range);
|
|
4277
4528
|
if (bytes) {
|
|
4278
4529
|
const start = parseInt(bytes[1]);
|
|
4279
|
-
const end = parseInt(bytes[2]);
|
|
4280
|
-
|
|
4281
|
-
|
|
4530
|
+
const end = Math.min(parseInt(bytes[2]), file.size - 1);
|
|
4531
|
+
if (start > end) {
|
|
4532
|
+
const response3 = new Response(null, {
|
|
4533
|
+
status: 416,
|
|
4534
|
+
headers: { "Content-Range": `bytes */${file.size}` }
|
|
4535
|
+
});
|
|
4536
|
+
Object.defineProperty(response3, "url", { value: path });
|
|
4537
|
+
return response3;
|
|
4538
|
+
}
|
|
4539
|
+
const data = await file.slice(start, end + 1).arrayBuffer();
|
|
4540
|
+
const response2 = new Response(data, {
|
|
4541
|
+
status: 206,
|
|
4542
|
+
headers: { "Content-Range": `bytes ${start}-${end}/${file.size}` }
|
|
4543
|
+
});
|
|
4282
4544
|
Object.defineProperty(response2, "url", { value: path });
|
|
4283
4545
|
return response2;
|
|
4284
4546
|
}
|
|
@@ -4302,7 +4564,7 @@ var __exports__ = (() => {
|
|
|
4302
4564
|
* Return information (size) about files in this file system
|
|
4303
4565
|
*/
|
|
4304
4566
|
async stat(path, options) {
|
|
4305
|
-
const file = this.
|
|
4567
|
+
const file = this._getFile(path, false);
|
|
4306
4568
|
if (!file) {
|
|
4307
4569
|
throw new Error(path);
|
|
4308
4570
|
}
|
|
@@ -4312,19 +4574,22 @@ var __exports__ = (() => {
|
|
|
4312
4574
|
* Just removes the file from the list
|
|
4313
4575
|
*/
|
|
4314
4576
|
async unlink(path) {
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4577
|
+
const file = this._getFile(path, false);
|
|
4578
|
+
if (file) {
|
|
4579
|
+
delete this.files[file.name];
|
|
4580
|
+
delete this.lowerCaseFiles[file.name.toLowerCase()];
|
|
4581
|
+
this.usedFiles[file.name] = true;
|
|
4582
|
+
}
|
|
4318
4583
|
}
|
|
4319
4584
|
// implements IRandomAccessFileSystem
|
|
4320
4585
|
// RANDOM ACCESS
|
|
4321
4586
|
async openReadableFile(pathname, flags) {
|
|
4322
|
-
return new BlobFile(this.
|
|
4587
|
+
return new BlobFile(this._getFile(pathname, true));
|
|
4323
4588
|
}
|
|
4324
4589
|
// PRIVATE
|
|
4325
4590
|
// Supports case independent paths, and file usage tracking
|
|
4326
4591
|
_getFile(path, used) {
|
|
4327
|
-
const file = this.files[path] || this.lowerCaseFiles[path];
|
|
4592
|
+
const file = this.files[path] || this.lowerCaseFiles[path.toLowerCase()];
|
|
4328
4593
|
if (file && used) {
|
|
4329
4594
|
this.usedFiles[path] = true;
|
|
4330
4595
|
}
|