@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/iceberg.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) */
@@ -6680,6 +6852,9 @@ function getDataTypeFromArray(array) {
6680
6852
  return { type: "null", nullable: true };
6681
6853
  }
6682
6854
  function getDataTypeFromTypedArray(array) {
6855
+ if (typeof Float16Array !== "undefined" && array instanceof Float16Array) {
6856
+ return "float16";
6857
+ }
6683
6858
  switch (array.constructor) {
6684
6859
  case Int8Array:
6685
6860
  return "int8";
@@ -6694,6 +6869,10 @@ function getDataTypeFromTypedArray(array) {
6694
6869
  return "int32";
6695
6870
  case Uint32Array:
6696
6871
  return "uint32";
6872
+ case BigInt64Array:
6873
+ return "int64";
6874
+ case BigUint64Array:
6875
+ return "uint64";
6697
6876
  case Float32Array:
6698
6877
  return "float32";
6699
6878
  case Float64Array:
@@ -6721,15 +6900,19 @@ function getArrayTypeFromDataType(type, nullable) {
6721
6900
  return Float32Array;
6722
6901
  case "float64":
6723
6902
  return Float64Array;
6903
+ case "float16":
6904
+ return (0, import_types.getFloat16ArrayConstructor)();
6724
6905
  default:
6725
6906
  break;
6726
6907
  }
6727
6908
  }
6728
6909
  return Array;
6729
6910
  }
6911
+ var import_types;
6730
6912
  var init_data_type = __esm({
6731
6913
  "../schema-utils/src/lib/schema/data-type.ts"() {
6732
6914
  "use strict";
6915
+ import_types = require("@math.gl/types");
6733
6916
  }
6734
6917
  });
6735
6918
 
@@ -6778,6 +6961,13 @@ function serializeArrowType(arrowType) {
6778
6961
  if (isArrowViewType(arrowType, "Utf8View")) {
6779
6962
  return "utf8-view";
6780
6963
  }
6964
+ if (isOptionalArrowType(arrowType, "LargeList")) {
6965
+ const largeListType = arrowType;
6966
+ return {
6967
+ type: "large-list",
6968
+ children: [serializeArrowField(largeListType.valueField)]
6969
+ };
6970
+ }
6781
6971
  switch (arrowType.constructor) {
6782
6972
  case arrow2.Null:
6783
6973
  return "null";
@@ -6916,12 +7106,6 @@ function serializeArrowType(arrowType) {
6916
7106
  type: "list",
6917
7107
  children: [serializeArrowField(listField)]
6918
7108
  };
6919
- case arrow2.LargeList:
6920
- const largeListType = arrowType;
6921
- return {
6922
- type: "large-list",
6923
- children: [serializeArrowField(largeListType.valueField)]
6924
- };
6925
7109
  case arrow2.FixedSizeList:
6926
7110
  const fixedSizeList = arrowType;
6927
7111
  return {
@@ -6974,7 +7158,13 @@ function deserializeArrowType(dataType, options) {
6974
7158
  }
6975
7159
  case "large-list": {
6976
7160
  const field = deserializeArrowField(dataType.children[0], options);
6977
- return new arrow2.LargeList(field);
7161
+ const LargeList = getOptionalArrowConstructor("LargeList");
7162
+ if (!LargeList) {
7163
+ throw new Error(
7164
+ "LargeList requires an Apache Arrow runtime that exports the LargeList constructor"
7165
+ );
7166
+ }
7167
+ return new LargeList(field);
6978
7168
  }
6979
7169
  case "fixed-size-list": {
6980
7170
  const child = deserializeArrowField(dataType.children[0], options);
@@ -7070,11 +7260,11 @@ function deserializeArrowType(dataType, options) {
7070
7260
  throw new Error("array type not supported");
7071
7261
  }
7072
7262
  }
7073
- function getArrowViewConstructors() {
7074
- return arrow2;
7263
+ function getOptionalArrowConstructor(typeName) {
7264
+ return arrow2[typeName];
7075
7265
  }
7076
7266
  function isArrowViewType(arrowType, viewTypeName) {
7077
- const constructor = getArrowViewConstructors()[viewTypeName];
7267
+ const constructor = getOptionalArrowConstructor(viewTypeName);
7078
7268
  if (constructor && arrowType instanceof constructor) {
7079
7269
  return true;
7080
7270
  }
@@ -7082,12 +7272,16 @@ function isArrowViewType(arrowType, viewTypeName) {
7082
7272
  const guard = viewTypeName === "BinaryView" ? guards.isBinaryView : guards.isUtf8View;
7083
7273
  return Boolean(guard == null ? void 0 : guard(arrowType));
7084
7274
  }
7275
+ function isOptionalArrowType(arrowType, typeName) {
7276
+ const constructor = getOptionalArrowConstructor(typeName);
7277
+ return Boolean(constructor && arrowType instanceof constructor);
7278
+ }
7085
7279
  function makeVariableWidthArrowType(viewTypeName, fallbackType, options) {
7086
7280
  const viewTypeMode = (options == null ? void 0 : options.viewTypes) || "never";
7087
7281
  if (viewTypeMode === "never") {
7088
7282
  return fallbackType;
7089
7283
  }
7090
- const constructor = getArrowViewConstructors()[viewTypeName];
7284
+ const constructor = getOptionalArrowConstructor(viewTypeName);
7091
7285
  if (constructor) {
7092
7286
  return new constructor();
7093
7287
  }
@@ -7099,7 +7293,7 @@ function makeVariableWidthArrowType(viewTypeName, fallbackType, options) {
7099
7293
  return fallbackType;
7100
7294
  }
7101
7295
  function makeRequiredArrowViewType(viewTypeName) {
7102
- const constructor = getArrowViewConstructors()[viewTypeName];
7296
+ const constructor = getOptionalArrowConstructor(viewTypeName);
7103
7297
  if (!constructor) {
7104
7298
  throw new Error(
7105
7299
  `${viewTypeName} requires apache-arrow 21.2.0 or later; the installed runtime does not support it`
@@ -16596,7 +16790,7 @@ var init_parquet_loader_options = __esm({
16596
16790
  PARQUET_LOADER_DEFAULT_OPTIONS = {
16597
16791
  columns: void 0,
16598
16792
  preserveBinary: false,
16599
- shape: "object-row-table"
16793
+ shape: "arrow-table"
16600
16794
  };
16601
16795
  }
16602
16796
  });
@@ -16625,6 +16819,15 @@ var init_parquet_loader_base = __esm({
16625
16819
  }
16626
16820
  });
16627
16821
 
16822
+ // ../parquet/src/parquet-source-worker-factory.ts
16823
+ var PARQUET_SOURCE_WORKER_LOAD_WORKER;
16824
+ var init_parquet_source_worker_factory = __esm({
16825
+ "../parquet/src/parquet-source-worker-factory.ts"() {
16826
+ "use strict";
16827
+ PARQUET_SOURCE_WORKER_LOAD_WORKER = void 0;
16828
+ }
16829
+ });
16830
+
16628
16831
  // ../parquet/src/parquet-source-worker-url.ts
16629
16832
  function resolveParquetSourceWorkerUrl() {
16630
16833
  if (!import_meta.url) {
@@ -16665,12 +16868,14 @@ var init_parquet_source_worker_client = __esm({
16665
16868
  "use strict";
16666
16869
  init_src2();
16667
16870
  init_parquet_loader_base();
16871
+ init_parquet_source_worker_factory();
16668
16872
  init_parquet_source_worker_url();
16669
16873
  PARQUET_SOURCE_WORKER = {
16670
16874
  ...PARQUET_LOADER_BASE,
16671
16875
  id: "parquet-source",
16672
16876
  name: "ParquetSource",
16673
- worker: PARQUET_SOURCE_WORKER_URL
16877
+ worker: PARQUET_SOURCE_WORKER_URL,
16878
+ loadWorker: PARQUET_SOURCE_WORKER_LOAD_WORKER
16674
16879
  };
16675
16880
  }
16676
16881
  });
@@ -18267,6 +18472,18 @@ function readUnsignedVarIntNumber(cursor) {
18267
18472
  }
18268
18473
  throw new Error("invalid RLE run header");
18269
18474
  }
18475
+ function encodeUnsignedVarIntNumber(value) {
18476
+ if (!Number.isSafeInteger(value) || value < 0) {
18477
+ throw new Error("RLE run header must be a non-negative safe integer");
18478
+ }
18479
+ const bytes = [];
18480
+ while (value >= 128) {
18481
+ bytes.push(value % 128 | 128);
18482
+ value = Math.floor(value / 128);
18483
+ }
18484
+ bytes.push(value);
18485
+ return Uint8Array.from(bytes);
18486
+ }
18270
18487
  function assertReadable(cursor, byteLength) {
18271
18488
  const size = cursor.size ?? cursor.buffer.length;
18272
18489
  if (byteLength < 0 || cursor.offset + byteLength > size) {
@@ -18288,10 +18505,7 @@ function encodeRunBitpacked(values, opts) {
18288
18505
  buf[Math.floor(b / 8)] |= 1 << b % 8;
18289
18506
  }
18290
18507
  }
18291
- return concatUint8Arrays([
18292
- Uint8Array.from(import_varint.default.encode(paddedValues.length / 8 << 1 | 1)),
18293
- buf
18294
- ]);
18508
+ return concatUint8Arrays([encodeUnsignedVarIntNumber(paddedValues.length / 8 << 1 | 1), buf]);
18295
18509
  }
18296
18510
  function encodeRunRepeated(value, count, opts) {
18297
18511
  const bitWidth = opts.bitWidth;
@@ -18300,15 +18514,13 @@ function encodeRunRepeated(value, count, opts) {
18300
18514
  buf[i] = value & 255;
18301
18515
  value = Math.floor(value / 256);
18302
18516
  }
18303
- return concatUint8Arrays([Uint8Array.from(import_varint.default.encode(count << 1)), buf]);
18517
+ return concatUint8Arrays([encodeUnsignedVarIntNumber(count << 1), buf]);
18304
18518
  }
18305
- var import_varint;
18306
18519
  var init_rle = __esm({
18307
18520
  "../parquet/src/parquetjs/codecs/rle.ts"() {
18308
18521
  "use strict";
18309
18522
  init_declare();
18310
18523
  init_binary_utils();
18311
- import_varint = __toESM(require("varint"), 1);
18312
18524
  }
18313
18525
  });
18314
18526
 
@@ -26416,7 +26628,7 @@ var IcebergRestCatalog = class {
26416
26628
  getSourceOptions() {
26417
26629
  const options = { iceberg: { headers: this.options.headers } };
26418
26630
  if (this.options.fetch) {
26419
- options.core = { loadOptions: { core: { fetch: this.options.fetch } } };
26631
+ options.core = { fetch: this.options.fetch };
26420
26632
  }
26421
26633
  return options;
26422
26634
  }