@loaders.gl/scan 5.0.0-alpha.6 → 5.0.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/delta.cjs CHANGED
@@ -593,6 +593,7 @@ var init_worker_pool = __esm({
593
593
  props = {};
594
594
  jobQueue = [];
595
595
  idleQueue = [];
596
+ activeJobs = /* @__PURE__ */ new Set();
596
597
  count = 0;
597
598
  isDestroyed = false;
598
599
  /** Checks if workers are supported on this platform */
@@ -611,10 +612,14 @@ var init_worker_pool = __esm({
611
612
  this.setProps(props);
612
613
  }
613
614
  /**
614
- * Terminates all workers in the pool
615
+ * Terminates all workers in the pool and aborts active jobs.
616
+ * @param reason Optional error delivered to active jobs.
615
617
  * @note Can free up significant memory
616
618
  */
617
- destroy() {
619
+ destroy(reason = new Error("Worker pool was destroyed")) {
620
+ this.activeJobs.forEach((job) => job.abort(reason));
621
+ const queuedJobs = this.jobQueue.splice(0);
622
+ queuedJobs.forEach((queuedJob) => queuedJob.onReject(reason));
618
623
  this.idleQueue.forEach((worker) => worker.destroy());
619
624
  this.isDestroyed = true;
620
625
  }
@@ -637,8 +642,11 @@ var init_worker_pool = __esm({
637
642
  }
638
643
  }
639
644
  async startJob(name, onMessage2 = (job, type, data) => job.done(data), onError = (job, error) => job.error(error)) {
640
- const startPromise = new Promise((onStart) => {
641
- this.jobQueue.push({ name, onMessage: onMessage2, onError, onStart });
645
+ if (this.isDestroyed) {
646
+ return Promise.reject(new Error("Worker pool was destroyed"));
647
+ }
648
+ const startPromise = new Promise((onStart, onReject) => {
649
+ this.jobQueue.push({ name, onMessage: onMessage2, onError, onStart, onReject });
642
650
  return this;
643
651
  });
644
652
  this._startQueuedJob();
@@ -666,6 +674,7 @@ var init_worker_pool = __esm({
666
674
  backlog: this.jobQueue.length
667
675
  });
668
676
  const job = new WorkerJob(queuedJob.name, workerThread);
677
+ this.activeJobs.add(job);
669
678
  workerThread.ref();
670
679
  workerThread.onMessage = (data) => queuedJob.onMessage(job, data.type, data.payload);
671
680
  workerThread.onError = (error) => queuedJob.onError(job, error);
@@ -674,6 +683,7 @@ var init_worker_pool = __esm({
674
683
  await job.result;
675
684
  } catch {
676
685
  } finally {
686
+ this.activeJobs.delete(job);
677
687
  this.returnWorkerToQueue(workerThread);
678
688
  }
679
689
  }
@@ -787,12 +797,13 @@ var init_worker_farm = __esm({
787
797
  this.workerPools = /* @__PURE__ */ new Map();
788
798
  }
789
799
  /**
790
- * Terminate all workers in the farm
800
+ * Terminate all workers in the farm and abort active jobs.
801
+ * @param reason Optional error delivered to active jobs.
791
802
  * @note Can free up significant memory
792
803
  */
793
- destroy() {
804
+ destroy(reason) {
794
805
  for (const workerPool of this.workerPools.values()) {
795
- workerPool.destroy();
806
+ workerPool.destroy(reason);
796
807
  }
797
808
  this.workerPools = /* @__PURE__ */ new Map();
798
809
  }
@@ -1036,13 +1047,17 @@ var init_src = __esm({
1036
1047
 
1037
1048
  // ../loader-utils/src/lib/worker-loader-utils/parse-with-worker.ts
1038
1049
  function canParseWithWorker(loader, options) {
1039
- var _a, _b;
1050
+ var _a, _b, _c;
1051
+ if ((_b = (_a = options == null ? void 0 : options.core) == null ? void 0 : _a.credentials) == null ? void 0 : _b.some(
1052
+ (credential) => credential.type === "request" || "token" in credential && typeof credential.token === "function"
1053
+ ))
1054
+ return false;
1040
1055
  const workerOptions = getWorkerOptions(options);
1041
1056
  const nodeWorkers = workerOptions._nodeWorkers;
1042
1057
  if (!isBrowser2 && !nodeWorkers) {
1043
1058
  return false;
1044
1059
  }
1045
- if (loader.id === "excel" && ((_a = options == null ? void 0 : options.excel) == null ? void 0 : _a.shape) === "arrow-table" || loader.id === "ply" && ((_b = options == null ? void 0 : options.ply) == null ? void 0 : _b.shape) === "arrow-table") {
1060
+ if (loader.id === "las" && (((_c = options == null ? void 0 : options.las) == null ? void 0 : _c.shape) ?? "arrow-table") === "arrow-table") {
1046
1061
  return false;
1047
1062
  }
1048
1063
  if (loader.id === "csv" && !shouldParseCSVWithWorker(options)) {
@@ -1089,7 +1104,12 @@ function callParseOnMainThread(parseOnMainThread, input, options, context) {
1089
1104
  return parseOnMainThread(input, void 0, options, context);
1090
1105
  }
1091
1106
  function getWorkerOptions(options = {}, loader) {
1092
- const serializedOptions = JSON.parse(JSON.stringify(options));
1107
+ const serializedOptions = JSON.parse(
1108
+ JSON.stringify({
1109
+ ...options,
1110
+ ...options.core ? { core: { ...options.core, authentications: void 0 } } : {}
1111
+ })
1112
+ );
1093
1113
  const workerOptions = {
1094
1114
  ...serializedOptions.core,
1095
1115
  ...serializedOptions
@@ -1178,6 +1198,48 @@ var init_async_iteration = __esm({
1178
1198
  }
1179
1199
  });
1180
1200
 
1201
+ // ../loader-utils/src/lib/request-utils/authentication.ts
1202
+ function resolveCredentials(credentials, authentications = []) {
1203
+ if (credentials.every(isAuthentication)) return credentials;
1204
+ return credentials.map((credential, index) => {
1205
+ if (isAuthentication(credential)) return credential;
1206
+ const AuthenticationClass = authentications.find(
1207
+ (authentication2) => authentication2.type === (credential == null ? void 0 : credential.type)
1208
+ );
1209
+ if (!AuthenticationClass) {
1210
+ throw new Error(`No authentication class registered for credential at index ${index}.`);
1211
+ }
1212
+ let authentication;
1213
+ try {
1214
+ authentication = new AuthenticationClass(credential);
1215
+ } catch {
1216
+ throw new Error(`Invalid authentication configuration at index ${index}.`);
1217
+ }
1218
+ if (!isAuthentication(authentication)) {
1219
+ throw new Error(`Authentication class returned an invalid credential at index ${index}.`);
1220
+ }
1221
+ return authentication;
1222
+ });
1223
+ }
1224
+ function resolveAuthenticationOptions(options) {
1225
+ var _a, _b;
1226
+ if (!((_b = (_a = options.core) == null ? void 0 : _a.credentials) == null ? void 0 : _b.length)) return options;
1227
+ const credentials = resolveCredentials(options.core.credentials, options.core.authentications);
1228
+ if (credentials === options.core.credentials) return options;
1229
+ return { ...options, core: { ...options.core, credentials } };
1230
+ }
1231
+ function isAuthentication(credential) {
1232
+ if (!credential || typeof credential !== "object") return false;
1233
+ if (typeof credential.id !== "string" || !Array.isArray(credential.origins)) return false;
1234
+ if (credential.type === "request") return typeof credential.authenticate === "function";
1235
+ return (credential.type === "header" || credential.type === "query-parameter") && typeof credential.name === "string" && (typeof credential.token === "string" || typeof credential.token === "function") && Array.isArray(credential.refreshStatusCodes);
1236
+ }
1237
+ var init_authentication = __esm({
1238
+ "../loader-utils/src/lib/request-utils/authentication.ts"() {
1239
+ "use strict";
1240
+ }
1241
+ });
1242
+
1181
1243
  // ../loader-utils/src/lib/request-utils/request-cache.ts
1182
1244
  function createAbortError3() {
1183
1245
  const error = new Error("Request aborted");
@@ -1412,21 +1474,54 @@ var init_request_cache = __esm({
1412
1474
 
1413
1475
  // ../loader-utils/src/lib/request-utils/request-credentials.ts
1414
1476
  function createAuthenticatedFetch(options) {
1415
- const baseFetch = options.fetch || ((url, requestOptions) => fetch(url, requestOptions));
1416
- if (!options.credentials.length) return baseFetch;
1417
- const existingMetadata = baseFetch[AUTHENTICATED_FETCH];
1418
- if (existingMetadata === options.credentials) return baseFetch;
1477
+ const suppliedFetch = options.fetch || ((url, requestOptions) => fetch(url, requestOptions));
1478
+ const existingMetadata = suppliedFetch[AUTHENTICATED_FETCH];
1479
+ const credentialResolutions = new Map(existingMetadata == null ? void 0 : existingMetadata.credentialResolutions);
1480
+ const resolvedCredentials = resolveCredentials(
1481
+ options.credentials.map((credential) => credentialResolutions.get(credential) || credential),
1482
+ options.authentications
1483
+ );
1484
+ options.credentials.forEach((credential, index) => {
1485
+ credentialResolutions.set(credential, resolvedCredentials[index]);
1486
+ });
1487
+ if (!options.fetchOptions && (!resolvedCredentials.length || (existingMetadata == null ? void 0 : existingMetadata.credentials.length) === resolvedCredentials.length && resolvedCredentials.every(
1488
+ (credential, index) => credential === existingMetadata.credentials[index]
1489
+ )))
1490
+ return suppliedFetch;
1491
+ const baseFetch = (existingMetadata == null ? void 0 : existingMetadata.fetch) || suppliedFetch;
1492
+ const credentials = existingMetadata ? [.../* @__PURE__ */ new Set([...resolvedCredentials, ...existingMetadata.credentials])] : resolvedCredentials;
1493
+ const fetchOptions = mergeFetchOptions(
1494
+ (existingMetadata == null ? void 0 : existingMetadata.fetchOptions) || {},
1495
+ options.fetchOptions
1496
+ );
1497
+ const tokenCredentials = credentials.filter(
1498
+ (credential) => credential.type !== "request"
1499
+ );
1500
+ const requestCredentials = credentials.filter(
1501
+ (credential) => credential.type === "request"
1502
+ );
1503
+ for (const credential of requestCredentials) normalizeRequestOrigins(credential.origins);
1419
1504
  const authenticatedFetch = async (url, requestOptions = {}) => {
1420
- var _a, _b, _c;
1505
+ var _a, _b, _c, _d;
1506
+ requestOptions = mergeFetchOptions(fetchOptions, requestOptions);
1507
+ if ((_a = requestOptions.signal) == null ? void 0 : _a.aborted) throw createAbortError4();
1508
+ if (!credentials.length) return baseFetch(url, requestOptions);
1421
1509
  const resolvedURL = parseHTTPURL(url);
1422
- if (!resolvedURL) return baseFetch(url, requestOptions);
1423
- const authorization = await authorizeRequest(resolvedURL, requestOptions, options.credentials);
1424
- const response = await baseFetch(authorization.url, authorization.options);
1510
+ const authorization = resolvedURL ? await authorizeRequest(resolvedURL, requestOptions, tokenCredentials) : { url, options: requestOptions, credentials: [] };
1511
+ const signedRequest = await authenticateRequest(authorization, requestCredentials, "request");
1512
+ const response = await baseFetch(signedRequest.url, signedRequest.options);
1425
1513
  const refreshableCredentials = authorization.credentials.filter(
1426
1514
  ({ credential }) => typeof credential.token === "function" && credential.refreshStatusCodes.includes(response.status)
1427
1515
  );
1428
- if (!refreshableCredentials.length || !isReplayableRequest(requestOptions)) return response;
1429
- if ((_a = requestOptions.signal) == null ? void 0 : _a.aborted) throw createAbortError4();
1516
+ const shouldRetrySignature = signedRequest.credentials.some(
1517
+ (credential) => {
1518
+ var _a2;
1519
+ return (_a2 = credential.refreshStatusCodes) == null ? void 0 : _a2.includes(response.status);
1520
+ }
1521
+ );
1522
+ if (!refreshableCredentials.length && !shouldRetrySignature || !isReplayableRequest(requestOptions) || !isReplayableRequest(signedRequest.options))
1523
+ return response;
1524
+ if ((_b = requestOptions.signal) == null ? void 0 : _b.aborted) throw createAbortError4();
1430
1525
  const refreshedTokens = /* @__PURE__ */ new Map();
1431
1526
  await Promise.all(
1432
1527
  refreshableCredentials.map(async ({ credential }) => {
@@ -1434,24 +1529,111 @@ function createAuthenticatedFetch(options) {
1434
1529
  if (token) refreshedTokens.set(credential, token);
1435
1530
  })
1436
1531
  );
1437
- if (!refreshedTokens.size) return response;
1438
- await ((_b = response.body) == null ? void 0 : _b.cancel().catch(() => {
1532
+ if (!refreshedTokens.size && !shouldRetrySignature) return response;
1533
+ await ((_c = response.body) == null ? void 0 : _c.cancel().catch(() => {
1439
1534
  }));
1440
- if ((_c = requestOptions.signal) == null ? void 0 : _c.aborted) throw createAbortError4();
1441
- const replayAuthorization = await authorizeRequest(
1535
+ if ((_d = requestOptions.signal) == null ? void 0 : _d.aborted) throw createAbortError4();
1536
+ const replayAuthorization = resolvedURL ? await authorizeRequest(
1442
1537
  resolvedURL,
1443
1538
  requestOptions,
1444
- options.credentials,
1539
+ tokenCredentials,
1445
1540
  refreshedTokens,
1446
1541
  authorization.credentials
1542
+ ) : { url, options: requestOptions };
1543
+ const replayRequest = await authenticateRequest(
1544
+ replayAuthorization,
1545
+ requestCredentials,
1546
+ "retry",
1547
+ response
1447
1548
  );
1448
- return baseFetch(replayAuthorization.url, replayAuthorization.options);
1549
+ return baseFetch(replayRequest.url, replayRequest.options);
1449
1550
  };
1450
1551
  Object.defineProperty(authenticatedFetch, AUTHENTICATED_FETCH, {
1451
- value: options.credentials
1552
+ value: {
1553
+ fetch: baseFetch,
1554
+ credentials,
1555
+ credentialResolutions,
1556
+ fetchOptions
1557
+ }
1452
1558
  });
1453
1559
  return authenticatedFetch;
1454
1560
  }
1561
+ function getAuthenticatedFetch(options = {}) {
1562
+ var _a, _b, _c;
1563
+ const fetchOption = options.fetch ?? ((_a = options.core) == null ? void 0 : _a.fetch);
1564
+ let fetchFunction;
1565
+ if (typeof fetchOption === "function") {
1566
+ fetchFunction = fetchOption;
1567
+ } else {
1568
+ fetchFunction = (url, requestOptions) => fetch(url, requestOptions);
1569
+ }
1570
+ return createAuthenticatedFetch({
1571
+ fetch: fetchFunction,
1572
+ fetchOptions: typeof fetchOption === "object" && fetchOption ? fetchOption : void 0,
1573
+ credentials: ((_b = options.core) == null ? void 0 : _b.credentials) || [],
1574
+ authentications: (_c = options.core) == null ? void 0 : _c.authentications
1575
+ });
1576
+ }
1577
+ function mergeFetchOptions(defaultOptions, requestOptions) {
1578
+ const mergedOptions = { ...defaultOptions, ...requestOptions };
1579
+ if (defaultOptions.headers || (requestOptions == null ? void 0 : requestOptions.headers)) {
1580
+ const headers = new Headers(defaultOptions.headers);
1581
+ new Headers(requestOptions == null ? void 0 : requestOptions.headers).forEach((value, key) => headers.set(key, value));
1582
+ mergedOptions.headers = headers;
1583
+ }
1584
+ return mergedOptions;
1585
+ }
1586
+ async function authenticateRequest(request, credentials, reason, response) {
1587
+ const appliedCredentials = [];
1588
+ const signal = request.options.signal;
1589
+ for (const credential of credentials) {
1590
+ const origin = getRequestOrigin(request.url);
1591
+ if (!origin || !normalizeRequestOrigins(credential.origins).includes(origin)) continue;
1592
+ if (signal == null ? void 0 : signal.aborted) throw createAbortError4();
1593
+ const authenticatedRequest = await credential.authenticate({
1594
+ url: request.url,
1595
+ options: { ...request.options, headers: new Headers(request.options.headers) },
1596
+ reason,
1597
+ response: response ? { status: response.status, headers: new Headers(response.headers) } : void 0
1598
+ });
1599
+ if (!authenticatedRequest || typeof authenticatedRequest.url !== "string" || !authenticatedRequest.options || typeof authenticatedRequest.options !== "object") {
1600
+ throw new Error("Authentication callback returned an invalid request.");
1601
+ }
1602
+ request = {
1603
+ url: authenticatedRequest.url,
1604
+ options: { ...authenticatedRequest.options, ...signal ? { signal } : {} }
1605
+ };
1606
+ appliedCredentials.push(credential);
1607
+ }
1608
+ if (signal == null ? void 0 : signal.aborted) throw createAbortError4();
1609
+ return { ...request, credentials: appliedCredentials };
1610
+ }
1611
+ function getRequestOrigin(url) {
1612
+ try {
1613
+ const parsedURL = new URL(url);
1614
+ if (!parsedURL.host || parsedURL.username || parsedURL.password) return null;
1615
+ return parsedURL.origin !== "null" ? parsedURL.origin : `${parsedURL.protocol}//${parsedURL.host}`;
1616
+ } catch {
1617
+ return null;
1618
+ }
1619
+ }
1620
+ function normalizeRequestOrigins(origins) {
1621
+ if (!origins.length)
1622
+ throw new Error("Request authentication requires at least one exact origin.");
1623
+ return origins.map((origin) => {
1624
+ const resolvedOrigin = getRequestOrigin(origin);
1625
+ let url;
1626
+ try {
1627
+ url = new URL(origin);
1628
+ } catch {
1629
+ throw new Error("Invalid request authentication origin.");
1630
+ }
1631
+ if (!resolvedOrigin || url.pathname && url.pathname !== "/" || url.search || url.hash) {
1632
+ throw new Error("Invalid request authentication origin.");
1633
+ }
1634
+ return resolvedOrigin;
1635
+ });
1636
+ }
1455
1637
  async function authorizeRequest(sourceURL, requestOptions, credentials, tokenOverrides = /* @__PURE__ */ new Map(), previousCredentials = []) {
1456
1638
  const url = new URL(sourceURL);
1457
1639
  const headers = new Headers(requestOptions.headers);
@@ -1520,6 +1702,7 @@ var AUTHENTICATED_FETCH, refreshPromises;
1520
1702
  var init_request_credentials = __esm({
1521
1703
  "../loader-utils/src/lib/request-utils/request-credentials.ts"() {
1522
1704
  "use strict";
1705
+ init_authentication();
1523
1706
  AUTHENTICATED_FETCH = /* @__PURE__ */ Symbol("loaders.gl.authenticated-fetch");
1524
1707
  refreshPromises = /* @__PURE__ */ new WeakMap();
1525
1708
  }
@@ -1765,6 +1948,7 @@ var init_range_request_scheduler = __esm({
1765
1948
  /** Optional event callback for range batching diagnostics. */
1766
1949
  onEvent;
1767
1950
  pendingRequests = [];
1951
+ /** Pending batch window, independent of in-flight transport requests. */
1768
1952
  flushTimer = null;
1769
1953
  /** Creates a scheduler for one group of byte-range-addressable resources. */
1770
1954
  constructor(props = {}) {
@@ -1841,7 +2025,7 @@ var init_range_request_scheduler = __esm({
1841
2025
  }
1842
2026
  /** Immediately starts loading the currently queued requests. */
1843
2027
  flush() {
1844
- if (this.flushTimer) {
2028
+ if (this.flushTimer !== null) {
1845
2029
  clearTimeout(this.flushTimer);
1846
2030
  this.flushTimer = null;
1847
2031
  }
@@ -1863,9 +2047,9 @@ var init_range_request_scheduler = __esm({
1863
2047
  this.fetchMergedRequest(mergedRequest);
1864
2048
  }
1865
2049
  }
1866
- /** Schedules the next pending-request flush. */
2050
+ /** Starts a fixed batch window only when no flush is already scheduled. */
1867
2051
  scheduleFlush() {
1868
- if (this.flushTimer) {
2052
+ if (this.flushTimer !== null) {
1869
2053
  return;
1870
2054
  }
1871
2055
  this.flushTimer = setTimeout(() => this.flush(), this.props.batchDelayMs);
@@ -2385,39 +2569,25 @@ var init_blob_file = __esm({
2385
2569
 
2386
2570
  // ../loader-utils/src/lib/sources/data-source.ts
2387
2571
  function getFetchFunction(options) {
2388
- var _a, _b;
2389
- const fetchOption = (options == null ? void 0 : options.fetch) ?? ((_a = options == null ? void 0 : options.core) == null ? void 0 : _a.fetch);
2390
- let fetchFunction;
2391
- if (typeof fetchOption === "function") {
2392
- fetchFunction = (url, fetchOptions) => fetchOption(url, fetchOptions);
2393
- } else if (fetchOption) {
2394
- fetchFunction = (url, requestOptions) => fetch(url, mergeFetchOptions(fetchOption, requestOptions));
2395
- } else {
2396
- fetchFunction = (url, requestOptions) => fetch(url, requestOptions);
2397
- }
2398
- return createAuthenticatedFetch({
2399
- fetch: fetchFunction,
2400
- credentials: ((_b = options == null ? void 0 : options.core) == null ? void 0 : _b.credentials) || []
2401
- });
2572
+ return getAuthenticatedFetch(options);
2402
2573
  }
2403
- function mergeFetchOptions(fetchOptions, requestOptions) {
2404
- const mergedOptions = { ...fetchOptions, ...requestOptions };
2405
- if (fetchOptions.headers || (requestOptions == null ? void 0 : requestOptions.headers)) {
2406
- mergedOptions.headers = mergeHeaders(fetchOptions.headers, requestOptions == null ? void 0 : requestOptions.headers);
2407
- }
2408
- return mergedOptions;
2409
- }
2410
- function mergeHeaders(defaultHeaders, requestHeaders) {
2411
- const headers = new Headers(defaultHeaders);
2412
- if (requestHeaders) {
2413
- new Headers(requestHeaders).forEach((value, key) => headers.set(key, value));
2574
+ function getSourceLoaderOptions(options) {
2575
+ var _a;
2576
+ if (options.loadOptions !== void 0 || ((_a = options.core) == null ? void 0 : _a.loadOptions) !== void 0) {
2577
+ throw new Error(
2578
+ "Source loadOptions and core.loadOptions were removed. Use core and root loader namespaces directly."
2579
+ );
2414
2580
  }
2415
- return headers;
2416
- }
2417
- function normalizeDirectLoaderOptions(options) {
2418
2581
  const loadOptions = { ...options };
2419
2582
  if (options == null ? void 0 : options.core) {
2420
2583
  loadOptions.core = { ...options.core };
2584
+ const parserCore = loadOptions.core;
2585
+ for (const key of ["type", "attributions", "loaders", "onError", "loadOptions"]) {
2586
+ delete parserCore[key];
2587
+ }
2588
+ if (Object.keys(parserCore).length === 0) {
2589
+ delete loadOptions.core;
2590
+ }
2421
2591
  }
2422
2592
  const topLevelBaseUri = typeof loadOptions.baseUri === "string" ? loadOptions.baseUri : void 0;
2423
2593
  const topLevelBaseUrl = typeof loadOptions.baseUrl === "string" ? loadOptions.baseUrl : void 0;
@@ -2455,6 +2625,7 @@ var init_data_source = __esm({
2455
2625
  init_file_aliases();
2456
2626
  init_log();
2457
2627
  init_request_credentials();
2628
+ init_authentication();
2458
2629
  UNAVAILABLE_CORE_API = {
2459
2630
  fetchFile: unavailableCoreApiMethod("fetchFile"),
2460
2631
  parse: unavailableCoreApiMethod("parse"),
@@ -2469,7 +2640,6 @@ var init_data_source = __esm({
2469
2640
  core: {
2470
2641
  type: "auto",
2471
2642
  attributions: [],
2472
- loadOptions: {},
2473
2643
  loaders: [],
2474
2644
  onError: void 0
2475
2645
  }
@@ -2478,9 +2648,9 @@ var init_data_source = __esm({
2478
2648
  options;
2479
2649
  data;
2480
2650
  url;
2481
- /** The actual load options, if calling a loaders.gl loader */
2651
+ /** Shared parser options derived from the source options, excluding source-only core controls. */
2482
2652
  loadOptions;
2483
- /** A resolved fetch function extracted from loadOptions prop */
2653
+ /** A resolved fetch function extracted from the shared core options. */
2484
2654
  fetch;
2485
2655
  /** Shared source-level runtime hooks, when supplied by the source factory. */
2486
2656
  coreApi;
@@ -2488,15 +2658,13 @@ var init_data_source = __esm({
2488
2658
  hasCoreApi;
2489
2659
  _needsRefresh = true;
2490
2660
  constructor(data, options, defaultOptions, coreApi) {
2491
- var _a;
2492
- if (defaultOptions) {
2493
- this.options = mergeOptions({ ...defaultOptions, core: _DataSource.defaultOptions }, options);
2494
- } else {
2495
- this.options = { ...options };
2496
- }
2661
+ this.options = mergeOptions(
2662
+ mergeOptions(_DataSource.defaultOptions, defaultOptions || {}),
2663
+ options
2664
+ );
2497
2665
  this.data = data;
2498
2666
  this.url = typeof data === "string" ? resolvePath(data) : "";
2499
- const loadOptions = normalizeDirectLoaderOptions((_a = this.options.core) == null ? void 0 : _a.loadOptions);
2667
+ const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(this.options));
2500
2668
  this.loadOptions = loadOptions;
2501
2669
  const fetch2 = getFetchFunction(loadOptions);
2502
2670
  this.coreApi = coreApi || UNAVAILABLE_CORE_API;
@@ -2504,7 +2672,11 @@ var init_data_source = __esm({
2504
2672
  this.fetch = fetch2;
2505
2673
  }
2506
2674
  setProps(options) {
2507
- this.options = Object.assign(this.options, options);
2675
+ const mergedOptions = mergeOptions(this.options, options);
2676
+ const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(mergedOptions));
2677
+ this.options = mergedOptions;
2678
+ this.loadOptions = loadOptions;
2679
+ this.fetch = getFetchFunction(loadOptions);
2508
2680
  this.setNeedsRefresh();
2509
2681
  }
2510
2682
  /** Mark this data source as needing a refresh (redraw) */
@@ -2986,6 +3158,9 @@ function getDataTypeFromArray(array) {
2986
3158
  return { type: "null", nullable: true };
2987
3159
  }
2988
3160
  function getDataTypeFromTypedArray(array) {
3161
+ if (typeof Float16Array !== "undefined" && array instanceof Float16Array) {
3162
+ return "float16";
3163
+ }
2989
3164
  switch (array.constructor) {
2990
3165
  case Int8Array:
2991
3166
  return "int8";
@@ -3000,6 +3175,10 @@ function getDataTypeFromTypedArray(array) {
3000
3175
  return "int32";
3001
3176
  case Uint32Array:
3002
3177
  return "uint32";
3178
+ case BigInt64Array:
3179
+ return "int64";
3180
+ case BigUint64Array:
3181
+ return "uint64";
3003
3182
  case Float32Array:
3004
3183
  return "float32";
3005
3184
  case Float64Array:
@@ -3027,15 +3206,19 @@ function getArrayTypeFromDataType(type, nullable) {
3027
3206
  return Float32Array;
3028
3207
  case "float64":
3029
3208
  return Float64Array;
3209
+ case "float16":
3210
+ return (0, import_types.getFloat16ArrayConstructor)();
3030
3211
  default:
3031
3212
  break;
3032
3213
  }
3033
3214
  }
3034
3215
  return Array;
3035
3216
  }
3217
+ var import_types;
3036
3218
  var init_data_type = __esm({
3037
3219
  "../schema-utils/src/lib/schema/data-type.ts"() {
3038
3220
  "use strict";
3221
+ import_types = require("@math.gl/types");
3039
3222
  }
3040
3223
  });
3041
3224
 
@@ -3084,6 +3267,13 @@ function serializeArrowType(arrowType) {
3084
3267
  if (isArrowViewType(arrowType, "Utf8View")) {
3085
3268
  return "utf8-view";
3086
3269
  }
3270
+ if (isOptionalArrowType(arrowType, "LargeList")) {
3271
+ const largeListType = arrowType;
3272
+ return {
3273
+ type: "large-list",
3274
+ children: [serializeArrowField(largeListType.valueField)]
3275
+ };
3276
+ }
3087
3277
  switch (arrowType.constructor) {
3088
3278
  case arrow.Null:
3089
3279
  return "null";
@@ -3222,12 +3412,6 @@ function serializeArrowType(arrowType) {
3222
3412
  type: "list",
3223
3413
  children: [serializeArrowField(listField)]
3224
3414
  };
3225
- case arrow.LargeList:
3226
- const largeListType = arrowType;
3227
- return {
3228
- type: "large-list",
3229
- children: [serializeArrowField(largeListType.valueField)]
3230
- };
3231
3415
  case arrow.FixedSizeList:
3232
3416
  const fixedSizeList = arrowType;
3233
3417
  return {
@@ -3280,7 +3464,13 @@ function deserializeArrowType(dataType, options) {
3280
3464
  }
3281
3465
  case "large-list": {
3282
3466
  const field = deserializeArrowField(dataType.children[0], options);
3283
- return new arrow.LargeList(field);
3467
+ const LargeList = getOptionalArrowConstructor("LargeList");
3468
+ if (!LargeList) {
3469
+ throw new Error(
3470
+ "LargeList requires an Apache Arrow runtime that exports the LargeList constructor"
3471
+ );
3472
+ }
3473
+ return new LargeList(field);
3284
3474
  }
3285
3475
  case "fixed-size-list": {
3286
3476
  const child = deserializeArrowField(dataType.children[0], options);
@@ -3376,11 +3566,11 @@ function deserializeArrowType(dataType, options) {
3376
3566
  throw new Error("array type not supported");
3377
3567
  }
3378
3568
  }
3379
- function getArrowViewConstructors() {
3380
- return arrow;
3569
+ function getOptionalArrowConstructor(typeName) {
3570
+ return arrow[typeName];
3381
3571
  }
3382
3572
  function isArrowViewType(arrowType, viewTypeName) {
3383
- const constructor = getArrowViewConstructors()[viewTypeName];
3573
+ const constructor = getOptionalArrowConstructor(viewTypeName);
3384
3574
  if (constructor && arrowType instanceof constructor) {
3385
3575
  return true;
3386
3576
  }
@@ -3388,12 +3578,16 @@ function isArrowViewType(arrowType, viewTypeName) {
3388
3578
  const guard = viewTypeName === "BinaryView" ? guards.isBinaryView : guards.isUtf8View;
3389
3579
  return Boolean(guard == null ? void 0 : guard(arrowType));
3390
3580
  }
3581
+ function isOptionalArrowType(arrowType, typeName) {
3582
+ const constructor = getOptionalArrowConstructor(typeName);
3583
+ return Boolean(constructor && arrowType instanceof constructor);
3584
+ }
3391
3585
  function makeVariableWidthArrowType(viewTypeName, fallbackType, options) {
3392
3586
  const viewTypeMode = (options == null ? void 0 : options.viewTypes) || "never";
3393
3587
  if (viewTypeMode === "never") {
3394
3588
  return fallbackType;
3395
3589
  }
3396
- const constructor = getArrowViewConstructors()[viewTypeName];
3590
+ const constructor = getOptionalArrowConstructor(viewTypeName);
3397
3591
  if (constructor) {
3398
3592
  return new constructor();
3399
3593
  }
@@ -3405,7 +3599,7 @@ function makeVariableWidthArrowType(viewTypeName, fallbackType, options) {
3405
3599
  return fallbackType;
3406
3600
  }
3407
3601
  function makeRequiredArrowViewType(viewTypeName) {
3408
- const constructor = getArrowViewConstructors()[viewTypeName];
3602
+ const constructor = getOptionalArrowConstructor(viewTypeName);
3409
3603
  if (!constructor) {
3410
3604
  throw new Error(
3411
3605
  `${viewTypeName} requires apache-arrow 21.2.0 or later; the installed runtime does not support it`
@@ -13295,7 +13489,7 @@ var init_parquet_loader_options = __esm({
13295
13489
  PARQUET_LOADER_DEFAULT_OPTIONS = {
13296
13490
  columns: void 0,
13297
13491
  preserveBinary: false,
13298
- shape: "object-row-table"
13492
+ shape: "arrow-table"
13299
13493
  };
13300
13494
  }
13301
13495
  });
@@ -13324,6 +13518,15 @@ var init_parquet_loader_base = __esm({
13324
13518
  }
13325
13519
  });
13326
13520
 
13521
+ // ../parquet/src/parquet-source-worker-factory.ts
13522
+ var PARQUET_SOURCE_WORKER_LOAD_WORKER;
13523
+ var init_parquet_source_worker_factory = __esm({
13524
+ "../parquet/src/parquet-source-worker-factory.ts"() {
13525
+ "use strict";
13526
+ PARQUET_SOURCE_WORKER_LOAD_WORKER = void 0;
13527
+ }
13528
+ });
13529
+
13327
13530
  // ../parquet/src/parquet-source-worker-url.ts
13328
13531
  function resolveParquetSourceWorkerUrl() {
13329
13532
  if (!import_meta.url) {
@@ -13364,12 +13567,14 @@ var init_parquet_source_worker_client = __esm({
13364
13567
  "use strict";
13365
13568
  init_src2();
13366
13569
  init_parquet_loader_base();
13570
+ init_parquet_source_worker_factory();
13367
13571
  init_parquet_source_worker_url();
13368
13572
  PARQUET_SOURCE_WORKER = {
13369
13573
  ...PARQUET_LOADER_BASE,
13370
13574
  id: "parquet-source",
13371
13575
  name: "ParquetSource",
13372
- worker: PARQUET_SOURCE_WORKER_URL
13576
+ worker: PARQUET_SOURCE_WORKER_URL,
13577
+ loadWorker: PARQUET_SOURCE_WORKER_LOAD_WORKER
13373
13578
  };
13374
13579
  }
13375
13580
  });
@@ -17841,6 +18046,18 @@ function readUnsignedVarIntNumber(cursor) {
17841
18046
  }
17842
18047
  throw new Error("invalid RLE run header");
17843
18048
  }
18049
+ function encodeUnsignedVarIntNumber(value) {
18050
+ if (!Number.isSafeInteger(value) || value < 0) {
18051
+ throw new Error("RLE run header must be a non-negative safe integer");
18052
+ }
18053
+ const bytes = [];
18054
+ while (value >= 128) {
18055
+ bytes.push(value % 128 | 128);
18056
+ value = Math.floor(value / 128);
18057
+ }
18058
+ bytes.push(value);
18059
+ return Uint8Array.from(bytes);
18060
+ }
17844
18061
  function assertReadable(cursor, byteLength) {
17845
18062
  const size = cursor.size ?? cursor.buffer.length;
17846
18063
  if (byteLength < 0 || cursor.offset + byteLength > size) {
@@ -17862,10 +18079,7 @@ function encodeRunBitpacked(values, opts) {
17862
18079
  buf[Math.floor(b / 8)] |= 1 << b % 8;
17863
18080
  }
17864
18081
  }
17865
- return concatUint8Arrays([
17866
- Uint8Array.from(import_varint.default.encode(paddedValues.length / 8 << 1 | 1)),
17867
- buf
17868
- ]);
18082
+ return concatUint8Arrays([encodeUnsignedVarIntNumber(paddedValues.length / 8 << 1 | 1), buf]);
17869
18083
  }
17870
18084
  function encodeRunRepeated(value, count, opts) {
17871
18085
  const bitWidth = opts.bitWidth;
@@ -17874,15 +18088,13 @@ function encodeRunRepeated(value, count, opts) {
17874
18088
  buf[i] = value & 255;
17875
18089
  value = Math.floor(value / 256);
17876
18090
  }
17877
- return concatUint8Arrays([Uint8Array.from(import_varint.default.encode(count << 1)), buf]);
18091
+ return concatUint8Arrays([encodeUnsignedVarIntNumber(count << 1), buf]);
17878
18092
  }
17879
- var import_varint;
17880
18093
  var init_rle = __esm({
17881
18094
  "../parquet/src/parquetjs/codecs/rle.ts"() {
17882
18095
  "use strict";
17883
18096
  init_declare();
17884
18097
  init_binary_utils();
17885
- import_varint = __toESM(require("varint"), 1);
17886
18098
  }
17887
18099
  });
17888
18100