@loaders.gl/core 5.0.0-alpha.1 → 5.0.0-alpha.2

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 CHANGED
@@ -24,8 +24,20 @@ THE SOFTWARE.
24
24
 
25
25
  Copyright (c) 2015 Uber Technologies, Inc.
26
26
 
27
- loaders.gl includes certain files from Cesium (https://github.com/AnalyticalGraphicsInc/cesium)
28
- under the Apache 2 License (found in the submodule: modules/3d-tiles):)
27
+ Portions of modules/images/src/lib/category-api/binary-image-api.ts are based on
28
+ binary-gltf-utils (https://github.com/Qantas94Heavy/binary-gltf-utils) under the
29
+ MIT License reproduced above.
30
+
31
+ Copyright (c) 2016-17 Karl Cheng
32
+
33
+ Portions of modules/schema-utils/src/lib/utils/async-queue.ts are adapted from
34
+ async-iter-demo (https://github.com/rauschma/async-iter-demo) under the MIT
35
+ License reproduced above.
36
+
37
+ Copyright (c) 2016 Axel Rauschmayer
38
+
39
+ loaders.gl includes certain files from Cesium (https://github.com/CesiumGS/cesium)
40
+ under the Apache 2.0 License, including files in modules/3d-tiles and modules/math.
29
41
 
30
42
  Copyright 2011-2018 CesiumJS Contributors
31
43
 
@@ -38,4 +50,3 @@ Unless required by applicable law or agreed to in writing, software
38
50
  distributed under the License is distributed on an "AS IS" BASIS,
39
51
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
40
52
  See the License for the specific language governing permissions and limitations under the License.
41
-
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 (newValue && typeof newValue === "object" && !Array.isArray(newValue)) {
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
- assert3(this.isRunning);
782
+ if (!this.isRunning) {
783
+ return;
784
+ }
788
785
  this.isRunning = false;
789
786
  this._resolve(value);
790
787
  }
@@ -792,14 +789,35 @@ var __exports__ = (() => {
792
789
  * Call to reject the `result` Promise with the supplied error
793
790
  */
794
791
  error(error) {
795
- assert3(this.isRunning);
792
+ if (!this.isRunning) {
793
+ return;
794
+ }
796
795
  this.isRunning = false;
797
796
  this._reject(error);
798
797
  }
798
+ /** Terminates the worker executing this job and rejects its result with an abort error. */
799
+ abort() {
800
+ if (!this.isRunning) {
801
+ return;
802
+ }
803
+ const error = new Error(`Worker job "${this.name}" was aborted`);
804
+ error.name = "AbortError";
805
+ this.workerThread.destroy();
806
+ this.error(error);
807
+ }
799
808
  };
800
809
 
801
810
  // ../worker-utils/src/lib/node/worker_threads-browser.ts
802
811
  var NodeWorker = class {
812
+ /** Restores the native worker constructor when this browser shim is embedded in a Node bundle. */
813
+ constructor(...arguments_) {
814
+ const runtimeProcess = globalThis.process;
815
+ const WorkerConstructor = runtimeProcess?.getBuiltinModule?.("node:worker_threads").Worker;
816
+ if (WorkerConstructor) {
817
+ return new WorkerConstructor(...arguments_);
818
+ }
819
+ }
820
+ /** No-op browser fallback matching the native Worker API. */
803
821
  terminate() {
804
822
  }
805
823
  };
@@ -998,8 +1016,9 @@ var __exports__ = (() => {
998
1016
  if (this.url) {
999
1017
  const absolute = this.url.includes(":/") || this.url.startsWith("/");
1000
1018
  const url = absolute ? this.url : `./${this.url}`;
1019
+ const workerUrl = url.startsWith("file:") ? new URL(url) : url;
1001
1020
  const type = this.url.endsWith(".ts") || this.url.endsWith(".mjs") ? "module" : "commonjs";
1002
- worker = new NodeWorker(url, { eval: false, type });
1021
+ worker = new NodeWorker(workerUrl, { eval: false, type });
1003
1022
  } else if (this.source) {
1004
1023
  worker = new NodeWorker(this.source, { eval: true });
1005
1024
  } else {
@@ -1124,13 +1143,16 @@ var __exports__ = (() => {
1124
1143
  */
1125
1144
  returnWorkerToQueue(worker) {
1126
1145
  const shouldDestroyWorker = (
1127
- // If the pool is destroyed, there is no reason to keep the worker around
1146
+ // Aborted jobs terminate their worker immediately.
1147
+ worker.terminated || // If the pool is destroyed, there is no reason to keep the worker around
1128
1148
  this.isDestroyed || // If the app has disabled worker reuse, any completed workers should be destroyed
1129
1149
  !this.reuseWorkers || // If concurrency has been lowered, this worker might be surplus to requirements
1130
1150
  this.count > this._getMaxConcurrency()
1131
1151
  );
1132
1152
  if (shouldDestroyWorker) {
1133
- worker.destroy();
1153
+ if (!worker.terminated) {
1154
+ worker.destroy();
1155
+ }
1134
1156
  this.count--;
1135
1157
  } else {
1136
1158
  worker.unref();
@@ -1167,9 +1189,11 @@ var __exports__ = (() => {
1167
1189
  onDebug: () => {
1168
1190
  }
1169
1191
  };
1170
- var _WorkerFarm = class {
1192
+ var WorkerFarm = class _WorkerFarm {
1171
1193
  props;
1172
1194
  workerPools = /* @__PURE__ */ new Map();
1195
+ // singleton
1196
+ static _workerFarm;
1173
1197
  /** Checks if workers are supported on this platform */
1174
1198
  static isSupported() {
1175
1199
  return WorkerThread.isSupported();
@@ -1238,9 +1262,6 @@ var __exports__ = (() => {
1238
1262
  };
1239
1263
  }
1240
1264
  };
1241
- var WorkerFarm = _WorkerFarm;
1242
- // singleton
1243
- __publicField(WorkerFarm, "_workerFarm");
1244
1265
 
1245
1266
  // ../worker-utils/src/lib/worker-api/get-worker-url.ts
1246
1267
  var warnedWorkerVersionFallbacks = /* @__PURE__ */ new Set();
@@ -1252,6 +1273,9 @@ var __exports__ = (() => {
1252
1273
  const workerOptions = options[worker.id] || {};
1253
1274
  const workerFile = isBrowser3 ? `${worker.id}-worker.js` : `${worker.id}-worker-node.js`;
1254
1275
  let url = workerOptions.workerUrl;
1276
+ if (!url && typeof worker.worker === "string") {
1277
+ url = worker.worker;
1278
+ }
1255
1279
  if (!url && worker.id === "compression") {
1256
1280
  url = options.workerUrl;
1257
1281
  }
@@ -1294,9 +1318,11 @@ var __exports__ = (() => {
1294
1318
  if (!WorkerFarm.isSupported()) {
1295
1319
  return false;
1296
1320
  }
1297
- return worker.worker && options?.worker;
1321
+ const workerOptions = options?.[worker.id];
1322
+ return Boolean((worker.worker || workerOptions?.workerUrl) && options?.worker);
1298
1323
  }
1299
1324
  async function processOnWorker(worker, data, options = {}, context = {}, jobContext = {}) {
1325
+ throwIfAborted(options.signal);
1300
1326
  const name = getWorkerName(worker);
1301
1327
  const workerFarm = WorkerFarm.getWorkerFarm(options);
1302
1328
  const { source } = options;
@@ -1311,15 +1337,35 @@ var __exports__ = (() => {
1311
1337
  // eslint-disable-next-line
1312
1338
  onMessage.bind(null, context)
1313
1339
  );
1314
- const transferableOptions = getTransferListForWriter(options);
1315
- const transferableContext = getTransferListForWriter(jobContext);
1316
- job.postMessage("process", {
1317
- input: data,
1318
- options: transferableOptions,
1319
- context: transferableContext
1320
- });
1321
- const result = await job.result;
1322
- return result.result;
1340
+ const abortJob = () => job.abort();
1341
+ options.signal?.addEventListener("abort", abortJob, { once: true });
1342
+ if (options.signal?.aborted) {
1343
+ abortJob();
1344
+ }
1345
+ try {
1346
+ const { signal: _signal, ...workerOptions } = options;
1347
+ const transferableOptions = getTransferListForWriter(workerOptions);
1348
+ const transferableContext = getTransferListForWriter(jobContext);
1349
+ if (job.isRunning) {
1350
+ job.postMessage("process", {
1351
+ input: data,
1352
+ options: transferableOptions,
1353
+ context: transferableContext
1354
+ });
1355
+ }
1356
+ const result = await job.result;
1357
+ return result.result;
1358
+ } finally {
1359
+ options.signal?.removeEventListener("abort", abortJob);
1360
+ }
1361
+ }
1362
+ function throwIfAborted(signal) {
1363
+ if (!signal?.aborted) {
1364
+ return;
1365
+ }
1366
+ const error = new Error("Worker job was aborted");
1367
+ error.name = "AbortError";
1368
+ throw error;
1323
1369
  }
1324
1370
  async function onMessage(context, job, type, payload) {
1325
1371
  switch (type) {
@@ -1374,10 +1420,11 @@ var __exports__ = (() => {
1374
1420
  return Boolean(canProcessOnWorker(loader, workerOptions));
1375
1421
  }
1376
1422
  async function parseWithWorker(loader, data, options, context, parseOnMainThread) {
1423
+ const signal = getWorkerAbortSignal(options);
1377
1424
  const result = await processOnWorker(
1378
1425
  loader,
1379
1426
  data,
1380
- getWorkerOptions(options),
1427
+ { ...getWorkerOptions(options), signal },
1381
1428
  {
1382
1429
  process: async (input, processOptions, _workerContext, parseContext) => {
1383
1430
  if (!parseOnMainThread) {
@@ -1396,6 +1443,13 @@ var __exports__ = (() => {
1396
1443
  );
1397
1444
  return isLoaderWithWorkerResultDeserializer(loader) ? loader.deserializeWorkerResult(result, options, context) : result;
1398
1445
  }
1446
+ function getWorkerAbortSignal(options) {
1447
+ const parquetSignal = options?.parquet?.signal;
1448
+ if (typeof AbortSignal !== "undefined" && parquetSignal instanceof AbortSignal) {
1449
+ return parquetSignal;
1450
+ }
1451
+ return void 0;
1452
+ }
1399
1453
  function callParseOnMainThread(parseOnMainThread, input, options, context) {
1400
1454
  if (parseOnMainThread.length <= 2) {
1401
1455
  return parseOnMainThread(input, options);
@@ -1939,91 +1993,6 @@ var __exports__ = (() => {
1939
1993
  return filename2;
1940
1994
  }
1941
1995
 
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
1996
  // ../loader-utils/src/lib/path-utils/path.ts
2028
1997
  var path_exports = {};
2029
1998
  __export(path_exports, {
@@ -2167,6 +2136,91 @@ var __exports__ = (() => {
2167
2136
  return res;
2168
2137
  }
2169
2138
 
2139
+ // ../loader-utils/src/json-loader.ts
2140
+ var VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
2141
+ var JSONLoader = {
2142
+ dataType: null,
2143
+ batchType: null,
2144
+ name: "JSON",
2145
+ id: "json",
2146
+ module: "json",
2147
+ version: VERSION4,
2148
+ encoding: "json",
2149
+ format: "json",
2150
+ extensions: ["json", "geojson"],
2151
+ mimeTypes: ["application/json"],
2152
+ category: "json",
2153
+ text: true,
2154
+ parseTextSync,
2155
+ parse: async (arrayBuffer) => parseTextSync(new TextDecoder().decode(arrayBuffer)),
2156
+ options: {}
2157
+ };
2158
+ function parseTextSync(text) {
2159
+ return JSON.parse(text);
2160
+ }
2161
+
2162
+ // ../loader-utils/src/lib/node/buffer.browser.ts
2163
+ function toArrayBuffer(buffer) {
2164
+ return buffer;
2165
+ }
2166
+
2167
+ // ../loader-utils/src/lib/binary-utils/memory-conversion-utils.ts
2168
+ function isBuffer(value) {
2169
+ return value && typeof value === "object" && value.isBuffer;
2170
+ }
2171
+ function toArrayBuffer2(data) {
2172
+ if (isBuffer(data)) {
2173
+ return toArrayBuffer(data);
2174
+ }
2175
+ if (data instanceof ArrayBuffer) {
2176
+ return data;
2177
+ }
2178
+ if (isSharedArrayBuffer(data)) {
2179
+ return copyToArrayBuffer2(data);
2180
+ }
2181
+ if (ArrayBuffer.isView(data)) {
2182
+ const buffer = data.buffer;
2183
+ if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
2184
+ return buffer;
2185
+ }
2186
+ return buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
2187
+ }
2188
+ if (typeof data === "string") {
2189
+ const text = data;
2190
+ const uint8Array = new TextEncoder().encode(text);
2191
+ return uint8Array.buffer;
2192
+ }
2193
+ if (data && typeof data === "object" && data._toArrayBuffer) {
2194
+ return data._toArrayBuffer();
2195
+ }
2196
+ throw new Error("toArrayBuffer");
2197
+ }
2198
+ function ensureArrayBuffer(bufferSource) {
2199
+ if (bufferSource instanceof ArrayBuffer) {
2200
+ return bufferSource;
2201
+ }
2202
+ if (isSharedArrayBuffer(bufferSource)) {
2203
+ return copyToArrayBuffer2(bufferSource);
2204
+ }
2205
+ const { buffer, byteOffset, byteLength } = bufferSource;
2206
+ if (buffer instanceof ArrayBuffer && byteOffset === 0 && byteLength === buffer.byteLength) {
2207
+ return buffer;
2208
+ }
2209
+ return copyToArrayBuffer2(buffer, byteOffset, byteLength);
2210
+ }
2211
+ function copyToArrayBuffer2(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
2212
+ const view = new Uint8Array(buffer, byteOffset, byteLength);
2213
+ const copy = new Uint8Array(view.length);
2214
+ copy.set(view);
2215
+ return copy.buffer;
2216
+ }
2217
+ function toArrayBufferView(data) {
2218
+ if (ArrayBuffer.isView(data)) {
2219
+ return data;
2220
+ }
2221
+ return new Uint8Array(data);
2222
+ }
2223
+
2170
2224
  // ../loader-utils/src/lib/files/blob-file.ts
2171
2225
  var BlobFile = class {
2172
2226
  handle;
@@ -2188,8 +2242,14 @@ var __exports__ = (() => {
2188
2242
  isDirectory: false
2189
2243
  };
2190
2244
  }
2191
- async read(start, length) {
2245
+ async read(start, length, signal) {
2246
+ if (signal?.aborted) {
2247
+ throw new Error("Request aborted");
2248
+ }
2192
2249
  const arrayBuffer = await this.handle.slice(Number(start), Number(start) + Number(length)).arrayBuffer();
2250
+ if (signal?.aborted) {
2251
+ throw new Error("Request aborted");
2252
+ }
2193
2253
  return arrayBuffer;
2194
2254
  }
2195
2255
  };
@@ -3201,20 +3261,57 @@ var __exports__ = (() => {
3201
3261
  async function* makeBrowserStreamIterator(stream, options) {
3202
3262
  const reader = stream.getReader();
3203
3263
  let nextBatchPromise;
3264
+ let streamFinished = false;
3265
+ let streamReadFailed = false;
3266
+ let iteratorFailed = false;
3204
3267
  try {
3205
3268
  while (true) {
3206
3269
  const currentBatchPromise = nextBatchPromise || reader.read();
3207
- if (options?._streamReadAhead) {
3208
- nextBatchPromise = reader.read();
3270
+ nextBatchPromise = void 0;
3271
+ let batch;
3272
+ try {
3273
+ batch = await currentBatchPromise;
3274
+ } catch (error) {
3275
+ streamReadFailed = true;
3276
+ throw error;
3209
3277
  }
3210
- const { done, value } = await currentBatchPromise;
3278
+ const { done, value } = batch;
3211
3279
  if (done) {
3280
+ streamFinished = true;
3212
3281
  return;
3213
3282
  }
3283
+ if (options?._streamReadAhead) {
3284
+ nextBatchPromise = reader.read();
3285
+ void nextBatchPromise.catch(() => {
3286
+ });
3287
+ }
3214
3288
  yield toArrayBuffer2(value);
3215
3289
  }
3216
- } catch (_error) {
3217
- reader.releaseLock();
3290
+ } catch (error) {
3291
+ iteratorFailed = true;
3292
+ throw error;
3293
+ } finally {
3294
+ let cleanupFailed = false;
3295
+ let cleanupError;
3296
+ if (!streamFinished && !streamReadFailed) {
3297
+ try {
3298
+ await reader.cancel();
3299
+ } catch (error) {
3300
+ cleanupFailed = true;
3301
+ cleanupError = error;
3302
+ }
3303
+ }
3304
+ try {
3305
+ reader.releaseLock();
3306
+ } catch (error) {
3307
+ if (!cleanupFailed) {
3308
+ cleanupFailed = true;
3309
+ cleanupError = error;
3310
+ }
3311
+ }
3312
+ if (!iteratorFailed && cleanupFailed) {
3313
+ throw cleanupError;
3314
+ }
3218
3315
  }
3219
3316
  }
3220
3317
  async function* makeNodeStreamIterator(stream, options) {
@@ -3335,14 +3432,14 @@ var __exports__ = (() => {
3335
3432
  }
3336
3433
  function getIterableFromData(data) {
3337
3434
  if (ArrayBuffer.isView(data)) {
3338
- return function* oneChunk() {
3435
+ return (function* oneChunk() {
3339
3436
  yield toArrayBuffer2(data);
3340
- }();
3437
+ })();
3341
3438
  }
3342
3439
  if (isArrayBufferLike(data)) {
3343
- return function* oneChunk() {
3440
+ return (function* oneChunk() {
3344
3441
  yield toArrayBuffer2(data);
3345
- }();
3442
+ })();
3346
3443
  }
3347
3444
  if (isIterator(data)) {
3348
3445
  return data;
@@ -3451,12 +3548,7 @@ var __exports__ = (() => {
3451
3548
  function getLoaderImplementationCacheKey(loader, options) {
3452
3549
  const loaderOptions = options?.[loader.id];
3453
3550
  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;
3551
+ return String(loaderOptions?.backend || defaultLoaderOptions?.backend || "");
3460
3552
  }
3461
3553
  async function importLoaderImplementation(implementationSpecifier, loaderId) {
3462
3554
  const moduleExports = await import(
@@ -3747,6 +3839,7 @@ var __exports__ = (() => {
3747
3839
  resolvedOptions = options;
3748
3840
  }
3749
3841
  if (!Array.isArray(resolvedLoaders) && isSourceLoader(resolvedLoaders)) {
3842
+ const sourceLoader = await resolveSourceLoader(resolvedLoaders, url, resolvedOptions);
3750
3843
  const runtimeCoreApi = {
3751
3844
  fetchFile,
3752
3845
  parse,
@@ -3756,13 +3849,14 @@ var __exports__ = (() => {
3756
3849
  load,
3757
3850
  loadInBatches
3758
3851
  };
3759
- return resolvedLoaders.createDataSource(
3852
+ return sourceLoader.createDataSource(
3760
3853
  url,
3761
3854
  resolvedOptions || {},
3762
3855
  runtimeCoreApi
3763
3856
  );
3764
3857
  }
3765
3858
  if (Array.isArray(resolvedLoaders) && resolvedLoaders.length === 1 && isSourceLoader(resolvedLoaders[0])) {
3859
+ const sourceLoader = await resolveSourceLoader(resolvedLoaders[0], url, resolvedOptions);
3766
3860
  const runtimeCoreApi = {
3767
3861
  fetchFile,
3768
3862
  parse,
@@ -3772,7 +3866,7 @@ var __exports__ = (() => {
3772
3866
  load,
3773
3867
  loadInBatches
3774
3868
  };
3775
- return resolvedLoaders[0].createDataSource(
3869
+ return sourceLoader.createDataSource(
3776
3870
  url,
3777
3871
  resolvedOptions || {},
3778
3872
  runtimeCoreApi
@@ -3784,7 +3878,8 @@ var __exports__ = (() => {
3784
3878
  core: { ...resolvedOptions?.core, nothrow: true }
3785
3879
  });
3786
3880
  if (selectedLoader && isSourceLoader(selectedLoader)) {
3787
- return selectedLoader.createDataSource(
3881
+ const sourceLoader = await resolveSourceLoader(selectedLoader, url, resolvedOptions);
3882
+ return sourceLoader.createDataSource(
3788
3883
  url,
3789
3884
  resolvedOptions || {},
3790
3885
  {
@@ -3821,6 +3916,16 @@ var __exports__ = (() => {
3821
3916
  }
3822
3917
  return Array.isArray(resolvedLoaders) ? await parse(data, resolvedLoaders, resolvedOptions, context) : await parse(data, resolvedLoaders, resolvedOptions, context);
3823
3918
  }
3919
+ async function resolveSourceLoader(loader, url, options) {
3920
+ if (!loader.preload) {
3921
+ return loader;
3922
+ }
3923
+ const sourceLoader = await loader.preload(typeof url === "string" ? url : "", options);
3924
+ if (!isSourceLoader(sourceLoader)) {
3925
+ throw new Error(`${loader.id} source loader preload() did not return a runtime source loader`);
3926
+ }
3927
+ return sourceLoader;
3928
+ }
3824
3929
 
3825
3930
  // src/lib/api/core-api.ts
3826
3931
  var coreApi = Object.freeze({
@@ -3913,6 +4018,9 @@ var __exports__ = (() => {
3913
4018
  data = await getArrayBufferFromData(data, options);
3914
4019
  return await parseWithWorker(loaderWithParser, data, options, context, parse);
3915
4020
  }
4021
+ if (isBlob(data) && loaderWithParser.parseBlob) {
4022
+ return await loaderWithParser.parseBlob(data, options, context);
4023
+ }
3916
4024
  data = await getArrayBufferOrStringFromData(data, loader, options);
3917
4025
  return await parseWithLoaderImplementation(loaderWithParser, data, options, context);
3918
4026
  }