@loaders.gl/core 5.0.0-alpha.7 → 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/dist.dev.js +294 -43
- package/dist/dist.min.js +3 -3
- package/dist/index.cjs +279 -51
- package/dist/index.cjs.map +3 -3
- package/dist/lib/api/create-data-source.d.ts +1 -1
- package/dist/lib/api/create-data-source.d.ts.map +1 -1
- package/dist/lib/api/create-data-source.js +23 -2
- package/dist/lib/api/create-data-source.js.map +1 -1
- package/dist/lib/api/load-in-batches.d.ts.map +1 -1
- package/dist/lib/api/load-in-batches.js +17 -6
- package/dist/lib/api/load-in-batches.js.map +1 -1
- package/dist/lib/api/load.d.ts +3 -3
- package/dist/lib/api/load.d.ts.map +1 -1
- package/dist/lib/api/load.js +14 -5
- package/dist/lib/api/load.js.map +1 -1
- package/dist/lib/api/parse-file.d.ts.map +1 -1
- package/dist/lib/api/parse-file.js +6 -2
- package/dist/lib/api/parse-file.js.map +1 -1
- package/dist/lib/api/parse-in-batches.d.ts.map +1 -1
- package/dist/lib/api/parse-in-batches.js +6 -1
- package/dist/lib/api/parse-in-batches.js.map +1 -1
- package/dist/lib/api/parse.d.ts.map +1 -1
- package/dist/lib/api/parse.js +6 -1
- package/dist/lib/api/parse.js.map +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/lib/loader-utils/get-fetch-function.js +4 -13
- package/dist/lib/loader-utils/get-fetch-function.js.map +1 -1
- package/dist/lib/loader-utils/option-defaults.d.ts.map +1 -1
- package/dist/lib/loader-utils/option-defaults.js +1 -0
- package/dist/lib/loader-utils/option-defaults.js.map +1 -1
- package/dist/lib/loader-utils/option-utils.d.ts +7 -0
- package/dist/lib/loader-utils/option-utils.d.ts.map +1 -1
- package/dist/lib/loader-utils/option-utils.js +29 -0
- package/dist/lib/loader-utils/option-utils.js.map +1 -1
- package/dist/null-loader.js +1 -1
- package/dist/null-worker-node.js +1 -1
- package/dist/null-worker.js +1 -1
- package/package.json +6 -6
- package/src/lib/api/create-data-source.ts +31 -2
- package/src/lib/api/load-in-batches.ts +18 -11
- package/src/lib/api/load.ts +44 -6
- package/src/lib/api/parse-file.ts +15 -2
- package/src/lib/api/parse-in-batches.ts +11 -1
- package/src/lib/api/parse.ts +11 -1
- package/src/lib/loader-utils/get-fetch-function.ts +4 -15
- package/src/lib/loader-utils/option-defaults.ts +1 -0
- package/src/lib/loader-utils/option-utils.ts +34 -0
package/dist/index.cjs
CHANGED
|
@@ -1181,13 +1181,17 @@ function validateWorkerVersion(worker, coreVersion = VERSION2) {
|
|
|
1181
1181
|
|
|
1182
1182
|
// ../loader-utils/src/lib/worker-loader-utils/parse-with-worker.ts
|
|
1183
1183
|
function canParseWithWorker(loader, options) {
|
|
1184
|
-
var _a;
|
|
1184
|
+
var _a, _b, _c;
|
|
1185
|
+
if ((_b = (_a = options == null ? void 0 : options.core) == null ? void 0 : _a.credentials) == null ? void 0 : _b.some(
|
|
1186
|
+
(credential) => credential.type === "request" || "token" in credential && typeof credential.token === "function"
|
|
1187
|
+
))
|
|
1188
|
+
return false;
|
|
1185
1189
|
const workerOptions = getWorkerOptions(options);
|
|
1186
1190
|
const nodeWorkers = workerOptions._nodeWorkers;
|
|
1187
1191
|
if (!isBrowser2 && !nodeWorkers) {
|
|
1188
1192
|
return false;
|
|
1189
1193
|
}
|
|
1190
|
-
if (loader.id === "las" && (((
|
|
1194
|
+
if (loader.id === "las" && (((_c = options == null ? void 0 : options.las) == null ? void 0 : _c.shape) ?? "arrow-table") === "arrow-table") {
|
|
1191
1195
|
return false;
|
|
1192
1196
|
}
|
|
1193
1197
|
if (loader.id === "csv" && !shouldParseCSVWithWorker(options)) {
|
|
@@ -1278,7 +1282,12 @@ function callParseOnMainThread(parseOnMainThread, input, options, context) {
|
|
|
1278
1282
|
return parseOnMainThread(input, void 0, options, context);
|
|
1279
1283
|
}
|
|
1280
1284
|
function getWorkerOptions(options = {}, loader) {
|
|
1281
|
-
const serializedOptions = JSON.parse(
|
|
1285
|
+
const serializedOptions = JSON.parse(
|
|
1286
|
+
JSON.stringify({
|
|
1287
|
+
...options,
|
|
1288
|
+
...options.core ? { core: { ...options.core, authentications: void 0 } } : {}
|
|
1289
|
+
})
|
|
1290
|
+
);
|
|
1282
1291
|
const workerOptions = {
|
|
1283
1292
|
...serializedOptions.core,
|
|
1284
1293
|
...serializedOptions
|
|
@@ -1487,6 +1496,7 @@ var RequestScheduler = class {
|
|
|
1487
1496
|
/** Tracks the number of active requests and prioritizes/cancels queued requests. */
|
|
1488
1497
|
requestQueue = [];
|
|
1489
1498
|
requestMap = /* @__PURE__ */ new Map();
|
|
1499
|
+
/** Pending arrival debounce or next-tick refill; only new arrivals replace this timer. */
|
|
1490
1500
|
updateTimer = null;
|
|
1491
1501
|
constructor(props = {}) {
|
|
1492
1502
|
this.props = { ...DEFAULT_PROPS2, ...props };
|
|
@@ -1554,20 +1564,27 @@ var RequestScheduler = class {
|
|
|
1554
1564
|
isDone = true;
|
|
1555
1565
|
this.requestMap.delete(handle);
|
|
1556
1566
|
this.activeRequestCount--;
|
|
1557
|
-
this.
|
|
1567
|
+
this.scheduleRefill();
|
|
1558
1568
|
}
|
|
1559
1569
|
};
|
|
1560
1570
|
this.activeRequestCount++;
|
|
1561
1571
|
return resolve2 ? resolve2({ done }) : Promise.resolve({ done });
|
|
1562
1572
|
}
|
|
1563
|
-
/**
|
|
1573
|
+
/** Refills freed slots on the next tick while preserving any pending arrival debounce. */
|
|
1574
|
+
scheduleRefill() {
|
|
1575
|
+
if (this.updateTimer !== null) {
|
|
1576
|
+
return;
|
|
1577
|
+
}
|
|
1578
|
+
this.updateTimer = setTimeout(() => this._issueNewRequestsAsync(), 0);
|
|
1579
|
+
}
|
|
1580
|
+
/** Restarts the quiet period when a new request enters the queue. */
|
|
1564
1581
|
_issueNewRequests() {
|
|
1565
1582
|
if (this.updateTimer !== null) {
|
|
1566
1583
|
clearTimeout(this.updateTimer);
|
|
1567
1584
|
}
|
|
1568
1585
|
this.updateTimer = setTimeout(() => this._issueNewRequestsAsync(), this.props.debounceTime);
|
|
1569
1586
|
}
|
|
1570
|
-
/**
|
|
1587
|
+
/** Clears timer ownership before updating priorities and dispatching queued requests. */
|
|
1571
1588
|
_issueNewRequestsAsync() {
|
|
1572
1589
|
if (this.updateTimer !== null) {
|
|
1573
1590
|
clearTimeout(this.updateTimer);
|
|
@@ -1609,25 +1626,110 @@ var RequestScheduler = class {
|
|
|
1609
1626
|
}
|
|
1610
1627
|
};
|
|
1611
1628
|
|
|
1629
|
+
// ../loader-utils/src/lib/request-utils/authentication.ts
|
|
1630
|
+
function resolveCredentials(credentials, authentications = []) {
|
|
1631
|
+
if (credentials.every(isAuthentication)) return credentials;
|
|
1632
|
+
return credentials.map((credential, index) => {
|
|
1633
|
+
if (isAuthentication(credential)) return credential;
|
|
1634
|
+
const AuthenticationClass = authentications.find(
|
|
1635
|
+
(authentication2) => authentication2.type === (credential == null ? void 0 : credential.type)
|
|
1636
|
+
);
|
|
1637
|
+
if (!AuthenticationClass) {
|
|
1638
|
+
throw new Error(`No authentication class registered for credential at index ${index}.`);
|
|
1639
|
+
}
|
|
1640
|
+
let authentication;
|
|
1641
|
+
try {
|
|
1642
|
+
authentication = new AuthenticationClass(credential);
|
|
1643
|
+
} catch {
|
|
1644
|
+
throw new Error(`Invalid authentication configuration at index ${index}.`);
|
|
1645
|
+
}
|
|
1646
|
+
if (!isAuthentication(authentication)) {
|
|
1647
|
+
throw new Error(`Authentication class returned an invalid credential at index ${index}.`);
|
|
1648
|
+
}
|
|
1649
|
+
return authentication;
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
function resolveAuthenticationOptions(options) {
|
|
1653
|
+
var _a, _b;
|
|
1654
|
+
if (!((_b = (_a = options.core) == null ? void 0 : _a.credentials) == null ? void 0 : _b.length)) return options;
|
|
1655
|
+
const credentials = resolveCredentials(options.core.credentials, options.core.authentications);
|
|
1656
|
+
if (credentials === options.core.credentials) return options;
|
|
1657
|
+
return { ...options, core: { ...options.core, credentials } };
|
|
1658
|
+
}
|
|
1659
|
+
async function resolveLoaderAuthenticationOptions(loader, url, options) {
|
|
1660
|
+
var _a, _b, _c, _d;
|
|
1661
|
+
if (!((_b = (_a = options.core) == null ? void 0 : _a.credentials) == null ? void 0 : _b.length) || options.core.credentials.every(isAuthentication)) {
|
|
1662
|
+
return options;
|
|
1663
|
+
}
|
|
1664
|
+
const contributions = await ((_c = loader == null ? void 0 : loader.getAuthentications) == null ? void 0 : _c.call(loader, url, options));
|
|
1665
|
+
if (!(contributions == null ? void 0 : contributions.length)) return resolveAuthenticationOptions(options);
|
|
1666
|
+
return resolveAuthenticationOptions({
|
|
1667
|
+
...options,
|
|
1668
|
+
core: {
|
|
1669
|
+
...options.core,
|
|
1670
|
+
authentications: [...((_d = options.core) == null ? void 0 : _d.authentications) || [], ...contributions]
|
|
1671
|
+
}
|
|
1672
|
+
});
|
|
1673
|
+
}
|
|
1674
|
+
function isAuthentication(credential) {
|
|
1675
|
+
if (!credential || typeof credential !== "object") return false;
|
|
1676
|
+
if (typeof credential.id !== "string" || !Array.isArray(credential.origins)) return false;
|
|
1677
|
+
if (credential.type === "request") return typeof credential.authenticate === "function";
|
|
1678
|
+
return (credential.type === "header" || credential.type === "query-parameter") && typeof credential.name === "string" && (typeof credential.token === "string" || typeof credential.token === "function") && Array.isArray(credential.refreshStatusCodes);
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1612
1681
|
// ../loader-utils/src/lib/request-utils/request-credentials.ts
|
|
1613
1682
|
var AUTHENTICATED_FETCH = /* @__PURE__ */ Symbol("loaders.gl.authenticated-fetch");
|
|
1614
1683
|
var refreshPromises = /* @__PURE__ */ new WeakMap();
|
|
1615
1684
|
function createAuthenticatedFetch(options) {
|
|
1616
|
-
const
|
|
1617
|
-
|
|
1618
|
-
const
|
|
1619
|
-
|
|
1685
|
+
const suppliedFetch = options.fetch || ((url, requestOptions) => fetch(url, requestOptions));
|
|
1686
|
+
const existingMetadata = suppliedFetch[AUTHENTICATED_FETCH];
|
|
1687
|
+
const credentialResolutions = new Map(existingMetadata == null ? void 0 : existingMetadata.credentialResolutions);
|
|
1688
|
+
const resolvedCredentials = resolveCredentials(
|
|
1689
|
+
options.credentials.map((credential) => credentialResolutions.get(credential) || credential),
|
|
1690
|
+
options.authentications
|
|
1691
|
+
);
|
|
1692
|
+
options.credentials.forEach((credential, index) => {
|
|
1693
|
+
credentialResolutions.set(credential, resolvedCredentials[index]);
|
|
1694
|
+
});
|
|
1695
|
+
if (!options.fetchOptions && (!resolvedCredentials.length || (existingMetadata == null ? void 0 : existingMetadata.credentials.length) === resolvedCredentials.length && resolvedCredentials.every(
|
|
1696
|
+
(credential, index) => credential === existingMetadata.credentials[index]
|
|
1697
|
+
)))
|
|
1698
|
+
return suppliedFetch;
|
|
1699
|
+
const baseFetch = (existingMetadata == null ? void 0 : existingMetadata.fetch) || suppliedFetch;
|
|
1700
|
+
const credentials = existingMetadata ? [.../* @__PURE__ */ new Set([...resolvedCredentials, ...existingMetadata.credentials])] : resolvedCredentials;
|
|
1701
|
+
const fetchOptions = mergeFetchOptions(
|
|
1702
|
+
(existingMetadata == null ? void 0 : existingMetadata.fetchOptions) || {},
|
|
1703
|
+
options.fetchOptions
|
|
1704
|
+
);
|
|
1705
|
+
const tokenCredentials = credentials.filter(
|
|
1706
|
+
(credential) => credential.type !== "request"
|
|
1707
|
+
);
|
|
1708
|
+
const requestCredentials = credentials.filter(
|
|
1709
|
+
(credential) => credential.type === "request"
|
|
1710
|
+
);
|
|
1711
|
+
for (const credential of requestCredentials) normalizeRequestOrigins(credential.origins);
|
|
1620
1712
|
const authenticatedFetch = async (url, requestOptions = {}) => {
|
|
1621
|
-
var _a, _b, _c;
|
|
1713
|
+
var _a, _b, _c, _d;
|
|
1714
|
+
requestOptions = mergeFetchOptions(fetchOptions, requestOptions);
|
|
1715
|
+
if ((_a = requestOptions.signal) == null ? void 0 : _a.aborted) throw createAbortError3();
|
|
1716
|
+
if (!credentials.length) return baseFetch(url, requestOptions);
|
|
1622
1717
|
const resolvedURL = parseHTTPURL(url);
|
|
1623
|
-
|
|
1624
|
-
const
|
|
1625
|
-
const response = await baseFetch(
|
|
1718
|
+
const authorization = resolvedURL ? await authorizeRequest(resolvedURL, requestOptions, tokenCredentials) : { url, options: requestOptions, credentials: [] };
|
|
1719
|
+
const signedRequest = await authenticateRequest(authorization, requestCredentials, "request");
|
|
1720
|
+
const response = await baseFetch(signedRequest.url, signedRequest.options);
|
|
1626
1721
|
const refreshableCredentials = authorization.credentials.filter(
|
|
1627
1722
|
({ credential }) => typeof credential.token === "function" && credential.refreshStatusCodes.includes(response.status)
|
|
1628
1723
|
);
|
|
1629
|
-
|
|
1630
|
-
|
|
1724
|
+
const shouldRetrySignature = signedRequest.credentials.some(
|
|
1725
|
+
(credential) => {
|
|
1726
|
+
var _a2;
|
|
1727
|
+
return (_a2 = credential.refreshStatusCodes) == null ? void 0 : _a2.includes(response.status);
|
|
1728
|
+
}
|
|
1729
|
+
);
|
|
1730
|
+
if (!refreshableCredentials.length && !shouldRetrySignature || !isReplayableRequest(requestOptions) || !isReplayableRequest(signedRequest.options))
|
|
1731
|
+
return response;
|
|
1732
|
+
if ((_b = requestOptions.signal) == null ? void 0 : _b.aborted) throw createAbortError3();
|
|
1631
1733
|
const refreshedTokens = /* @__PURE__ */ new Map();
|
|
1632
1734
|
await Promise.all(
|
|
1633
1735
|
refreshableCredentials.map(async ({ credential }) => {
|
|
@@ -1635,24 +1737,95 @@ function createAuthenticatedFetch(options) {
|
|
|
1635
1737
|
if (token) refreshedTokens.set(credential, token);
|
|
1636
1738
|
})
|
|
1637
1739
|
);
|
|
1638
|
-
if (!refreshedTokens.size) return response;
|
|
1639
|
-
await ((
|
|
1740
|
+
if (!refreshedTokens.size && !shouldRetrySignature) return response;
|
|
1741
|
+
await ((_c = response.body) == null ? void 0 : _c.cancel().catch(() => {
|
|
1640
1742
|
}));
|
|
1641
|
-
if ((
|
|
1642
|
-
const replayAuthorization = await authorizeRequest(
|
|
1743
|
+
if ((_d = requestOptions.signal) == null ? void 0 : _d.aborted) throw createAbortError3();
|
|
1744
|
+
const replayAuthorization = resolvedURL ? await authorizeRequest(
|
|
1643
1745
|
resolvedURL,
|
|
1644
1746
|
requestOptions,
|
|
1645
|
-
|
|
1747
|
+
tokenCredentials,
|
|
1646
1748
|
refreshedTokens,
|
|
1647
1749
|
authorization.credentials
|
|
1750
|
+
) : { url, options: requestOptions };
|
|
1751
|
+
const replayRequest = await authenticateRequest(
|
|
1752
|
+
replayAuthorization,
|
|
1753
|
+
requestCredentials,
|
|
1754
|
+
"retry",
|
|
1755
|
+
response
|
|
1648
1756
|
);
|
|
1649
|
-
return baseFetch(
|
|
1757
|
+
return baseFetch(replayRequest.url, replayRequest.options);
|
|
1650
1758
|
};
|
|
1651
1759
|
Object.defineProperty(authenticatedFetch, AUTHENTICATED_FETCH, {
|
|
1652
|
-
value:
|
|
1760
|
+
value: {
|
|
1761
|
+
fetch: baseFetch,
|
|
1762
|
+
credentials,
|
|
1763
|
+
credentialResolutions,
|
|
1764
|
+
fetchOptions
|
|
1765
|
+
}
|
|
1653
1766
|
});
|
|
1654
1767
|
return authenticatedFetch;
|
|
1655
1768
|
}
|
|
1769
|
+
function mergeFetchOptions(defaultOptions, requestOptions) {
|
|
1770
|
+
const mergedOptions = { ...defaultOptions, ...requestOptions };
|
|
1771
|
+
if (defaultOptions.headers || (requestOptions == null ? void 0 : requestOptions.headers)) {
|
|
1772
|
+
const headers = new Headers(defaultOptions.headers);
|
|
1773
|
+
new Headers(requestOptions == null ? void 0 : requestOptions.headers).forEach((value, key) => headers.set(key, value));
|
|
1774
|
+
mergedOptions.headers = headers;
|
|
1775
|
+
}
|
|
1776
|
+
return mergedOptions;
|
|
1777
|
+
}
|
|
1778
|
+
async function authenticateRequest(request, credentials, reason, response) {
|
|
1779
|
+
const appliedCredentials = [];
|
|
1780
|
+
const signal = request.options.signal;
|
|
1781
|
+
for (const credential of credentials) {
|
|
1782
|
+
const origin = getRequestOrigin(request.url);
|
|
1783
|
+
if (!origin || !normalizeRequestOrigins(credential.origins).includes(origin)) continue;
|
|
1784
|
+
if (signal == null ? void 0 : signal.aborted) throw createAbortError3();
|
|
1785
|
+
const authenticatedRequest = await credential.authenticate({
|
|
1786
|
+
url: request.url,
|
|
1787
|
+
options: { ...request.options, headers: new Headers(request.options.headers) },
|
|
1788
|
+
reason,
|
|
1789
|
+
response: response ? { status: response.status, headers: new Headers(response.headers) } : void 0
|
|
1790
|
+
});
|
|
1791
|
+
if (!authenticatedRequest || typeof authenticatedRequest.url !== "string" || !authenticatedRequest.options || typeof authenticatedRequest.options !== "object") {
|
|
1792
|
+
throw new Error("Authentication callback returned an invalid request.");
|
|
1793
|
+
}
|
|
1794
|
+
request = {
|
|
1795
|
+
url: authenticatedRequest.url,
|
|
1796
|
+
options: { ...authenticatedRequest.options, ...signal ? { signal } : {} }
|
|
1797
|
+
};
|
|
1798
|
+
appliedCredentials.push(credential);
|
|
1799
|
+
}
|
|
1800
|
+
if (signal == null ? void 0 : signal.aborted) throw createAbortError3();
|
|
1801
|
+
return { ...request, credentials: appliedCredentials };
|
|
1802
|
+
}
|
|
1803
|
+
function getRequestOrigin(url) {
|
|
1804
|
+
try {
|
|
1805
|
+
const parsedURL = new URL(url);
|
|
1806
|
+
if (!parsedURL.host || parsedURL.username || parsedURL.password) return null;
|
|
1807
|
+
return parsedURL.origin !== "null" ? parsedURL.origin : `${parsedURL.protocol}//${parsedURL.host}`;
|
|
1808
|
+
} catch {
|
|
1809
|
+
return null;
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
function normalizeRequestOrigins(origins) {
|
|
1813
|
+
if (!origins.length)
|
|
1814
|
+
throw new Error("Request authentication requires at least one exact origin.");
|
|
1815
|
+
return origins.map((origin) => {
|
|
1816
|
+
const resolvedOrigin = getRequestOrigin(origin);
|
|
1817
|
+
let url;
|
|
1818
|
+
try {
|
|
1819
|
+
url = new URL(origin);
|
|
1820
|
+
} catch {
|
|
1821
|
+
throw new Error("Invalid request authentication origin.");
|
|
1822
|
+
}
|
|
1823
|
+
if (!resolvedOrigin || url.pathname && url.pathname !== "/" || url.search || url.hash) {
|
|
1824
|
+
throw new Error("Invalid request authentication origin.");
|
|
1825
|
+
}
|
|
1826
|
+
return resolvedOrigin;
|
|
1827
|
+
});
|
|
1828
|
+
}
|
|
1656
1829
|
async function authorizeRequest(sourceURL, requestOptions, credentials, tokenOverrides = /* @__PURE__ */ new Map(), previousCredentials = []) {
|
|
1657
1830
|
const url = new URL(sourceURL);
|
|
1658
1831
|
const headers = new Headers(requestOptions.headers);
|
|
@@ -2349,6 +2522,7 @@ var ConsoleLog = class {
|
|
|
2349
2522
|
|
|
2350
2523
|
// dist/lib/loader-utils/option-defaults.js
|
|
2351
2524
|
var DEFAULT_LOADER_OPTIONS = {
|
|
2525
|
+
searchParams: void 0,
|
|
2352
2526
|
core: {
|
|
2353
2527
|
baseUrl: void 0,
|
|
2354
2528
|
// baseUrl
|
|
@@ -2455,6 +2629,27 @@ var CORE_LOADER_OPTION_KEYS = [
|
|
|
2455
2629
|
"metadata",
|
|
2456
2630
|
"transforms"
|
|
2457
2631
|
];
|
|
2632
|
+
function applySearchParamsToUrl(url, options) {
|
|
2633
|
+
const searchParams = options == null ? void 0 : options.searchParams;
|
|
2634
|
+
if (!searchParams || Object.keys(searchParams).length === 0 || /^(?:data|blob):/i.test(url)) {
|
|
2635
|
+
return url;
|
|
2636
|
+
}
|
|
2637
|
+
const hashIndex = url.indexOf("#");
|
|
2638
|
+
const hash = hashIndex >= 0 ? url.slice(hashIndex) : "";
|
|
2639
|
+
const urlWithoutHash = hashIndex >= 0 ? url.slice(0, hashIndex) : url;
|
|
2640
|
+
const queryIndex = urlWithoutHash.indexOf("?");
|
|
2641
|
+
const path = queryIndex >= 0 ? urlWithoutHash.slice(0, queryIndex) : urlWithoutHash;
|
|
2642
|
+
const query = queryIndex >= 0 ? urlWithoutHash.slice(queryIndex + 1) : "";
|
|
2643
|
+
const existingSearchParams = new URLSearchParams(query);
|
|
2644
|
+
const appendedSearchParams = new URLSearchParams();
|
|
2645
|
+
for (const [key, value] of Object.entries(searchParams)) {
|
|
2646
|
+
if (!existingSearchParams.has(key)) {
|
|
2647
|
+
appendedSearchParams.set(key, String(value));
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
const serializedAppendedSearchParams = appendedSearchParams.toString();
|
|
2651
|
+
return `${path}${queryIndex >= 0 ? `?${query}` : ""}${serializedAppendedSearchParams ? `${queryIndex >= 0 ? "&" : "?"}${serializedAppendedSearchParams}` : ""}${hash}`;
|
|
2652
|
+
}
|
|
2458
2653
|
function getGlobalLoaderState() {
|
|
2459
2654
|
globalThis.loaders = globalThis.loaders || {};
|
|
2460
2655
|
const { loaders } = globalThis;
|
|
@@ -3211,7 +3406,7 @@ function getIterableFromData(data) {
|
|
|
3211
3406
|
|
|
3212
3407
|
// dist/lib/loader-utils/get-fetch-function.js
|
|
3213
3408
|
function getFetchFunction(options, context) {
|
|
3214
|
-
var _a, _b;
|
|
3409
|
+
var _a, _b, _c;
|
|
3215
3410
|
const globalOptions = getGlobalLoaderOptions();
|
|
3216
3411
|
const loaderOptions = options || globalOptions;
|
|
3217
3412
|
const fetchOption = loaderOptions.fetch ?? ((_a = loaderOptions.core) == null ? void 0 : _a.fetch);
|
|
@@ -3219,8 +3414,7 @@ function getFetchFunction(options, context) {
|
|
|
3219
3414
|
if (typeof fetchOption === "function") {
|
|
3220
3415
|
fetchFunction = fetchOption;
|
|
3221
3416
|
} else if (isObject(fetchOption)) {
|
|
3222
|
-
|
|
3223
|
-
fetchFunction = (url, requestOptions) => baseFetch(url, mergeFetchOptions(fetchOption, requestOptions));
|
|
3417
|
+
fetchFunction = (context == null ? void 0 : context.fetch) || fetchFile;
|
|
3224
3418
|
} else if (context == null ? void 0 : context.fetch) {
|
|
3225
3419
|
fetchFunction = context.fetch;
|
|
3226
3420
|
} else {
|
|
@@ -3228,18 +3422,11 @@ function getFetchFunction(options, context) {
|
|
|
3228
3422
|
}
|
|
3229
3423
|
return createAuthenticatedFetch({
|
|
3230
3424
|
fetch: fetchFunction,
|
|
3231
|
-
credentials: ((_b = loaderOptions.core) == null ? void 0 : _b.credentials) || []
|
|
3425
|
+
credentials: ((_b = loaderOptions.core) == null ? void 0 : _b.credentials) || [],
|
|
3426
|
+
authentications: (_c = loaderOptions.core) == null ? void 0 : _c.authentications,
|
|
3427
|
+
fetchOptions: isObject(fetchOption) ? fetchOption : void 0
|
|
3232
3428
|
});
|
|
3233
3429
|
}
|
|
3234
|
-
function mergeFetchOptions(defaultOptions, requestOptions) {
|
|
3235
|
-
const options = { ...defaultOptions, ...requestOptions };
|
|
3236
|
-
if (defaultOptions.headers || (requestOptions == null ? void 0 : requestOptions.headers)) {
|
|
3237
|
-
const headers = new Headers(defaultOptions.headers);
|
|
3238
|
-
new Headers(requestOptions == null ? void 0 : requestOptions.headers).forEach((value, key) => headers.set(key, value));
|
|
3239
|
-
options.headers = headers;
|
|
3240
|
-
}
|
|
3241
|
-
return options;
|
|
3242
|
-
}
|
|
3243
3430
|
|
|
3244
3431
|
// dist/lib/api/load-loader.js
|
|
3245
3432
|
var loaderImplementationPromises = /* @__PURE__ */ new Map();
|
|
@@ -3340,6 +3527,7 @@ async function importLoaderImplementation(implementationSpecifier, loaderId) {
|
|
|
3340
3527
|
|
|
3341
3528
|
// dist/lib/api/parse-file.js
|
|
3342
3529
|
async function parseFile(file, loaders, options, context) {
|
|
3530
|
+
var _a, _b;
|
|
3343
3531
|
if (loaders && !Array.isArray(loaders) && !isLoaderObject(loaders)) {
|
|
3344
3532
|
context = void 0;
|
|
3345
3533
|
options = loaders;
|
|
@@ -3356,7 +3544,9 @@ async function parseFile(file, loaders, options, context) {
|
|
|
3356
3544
|
if (isSourceLoader(loader)) {
|
|
3357
3545
|
throw new Error(`${loader.id} is a SourceLoader. Use load() to create a runtime source object instead of parseFile().`);
|
|
3358
3546
|
}
|
|
3359
|
-
const
|
|
3547
|
+
const normalizedOptions = normalizeOptions(options, loader, candidateLoaders, url);
|
|
3548
|
+
const authenticationLoader = !loader.getAuthentications && ((_b = (_a = normalizedOptions.core) == null ? void 0 : _a.credentials) == null ? void 0 : _b.length) ? await getLoaderImplementation(loader, normalizedOptions, url || (context == null ? void 0 : context.url)) : loader;
|
|
3549
|
+
const strictOptions = await resolveLoaderAuthenticationOptions(authenticationLoader, url, normalizedOptions);
|
|
3360
3550
|
context = getLoaderContext(
|
|
3361
3551
|
// @ts-expect-error candidateLoaders may be a single forced loader
|
|
3362
3552
|
{ url, _parse: parse, loaders: candidateLoaders },
|
|
@@ -3469,6 +3659,7 @@ function makeBatchFromTable(table) {
|
|
|
3469
3659
|
|
|
3470
3660
|
// dist/lib/api/parse-in-batches.js
|
|
3471
3661
|
async function parseInBatches(data, loaders, options, context) {
|
|
3662
|
+
var _a, _b;
|
|
3472
3663
|
const loaderArray = Array.isArray(loaders) ? loaders : void 0;
|
|
3473
3664
|
if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {
|
|
3474
3665
|
context = void 0;
|
|
@@ -3482,7 +3673,9 @@ async function parseInBatches(data, loaders, options, context) {
|
|
|
3482
3673
|
if (!loader) {
|
|
3483
3674
|
return [];
|
|
3484
3675
|
}
|
|
3485
|
-
const
|
|
3676
|
+
const normalizedOptions = normalizeOptions(options, loader, loaderArray, url);
|
|
3677
|
+
const authenticationLoader = !loader.getAuthentications && ((_b = (_a = normalizedOptions.core) == null ? void 0 : _a.credentials) == null ? void 0 : _b.length) ? await getLoaderImplementation(loader, normalizedOptions, url || (context == null ? void 0 : context.url)) : loader;
|
|
3678
|
+
const strictOptions = await resolveLoaderAuthenticationOptions(authenticationLoader, url || "", normalizedOptions);
|
|
3486
3679
|
context = getLoaderContext({ url, _parseInBatches: parseInBatches, _parse: parse, loaders: loaderArray }, strictOptions, context || null);
|
|
3487
3680
|
const loaderWithParser = await getLoaderImplementation(loader, strictOptions, context.url);
|
|
3488
3681
|
return await parseWithLoaderInBatches(loader, loaderWithParser, data, strictOptions, context);
|
|
@@ -3562,17 +3755,24 @@ function loadInBatches(files, loaders, options, context) {
|
|
|
3562
3755
|
} else {
|
|
3563
3756
|
loadersArray = loaders;
|
|
3564
3757
|
}
|
|
3565
|
-
const fetch2 = getFetchFunction(options || {});
|
|
3566
3758
|
if (!Array.isArray(files)) {
|
|
3567
|
-
return loadOneFileInBatches(files, loadersArray, options || {}
|
|
3759
|
+
return loadOneFileInBatches(files, loadersArray, options || {});
|
|
3568
3760
|
}
|
|
3569
|
-
const promises = files.map((file) => loadOneFileInBatches(file, loadersArray, options || {}
|
|
3761
|
+
const promises = files.map((file) => loadOneFileInBatches(file, loadersArray, options || {}));
|
|
3570
3762
|
return promises;
|
|
3571
3763
|
}
|
|
3572
|
-
async function loadOneFileInBatches(file, loaders, options
|
|
3764
|
+
async function loadOneFileInBatches(file, loaders, options) {
|
|
3765
|
+
var _a, _b;
|
|
3573
3766
|
if (typeof file === "string") {
|
|
3574
3767
|
const url = file;
|
|
3575
|
-
const
|
|
3768
|
+
const loader = await selectLoader(url, loaders, {
|
|
3769
|
+
...options,
|
|
3770
|
+
core: { ...options.core, nothrow: true }
|
|
3771
|
+
});
|
|
3772
|
+
const authenticationLoader = loader && !loader.getAuthentications && ((_b = (_a = options.core) == null ? void 0 : _a.credentials) == null ? void 0 : _b.length) ? await getLoaderImplementation(loader, options, url) : loader;
|
|
3773
|
+
options = await resolveLoaderAuthenticationOptions(authenticationLoader, url, options);
|
|
3774
|
+
const fetch2 = getFetchFunction(options);
|
|
3775
|
+
const response = await fetch2(applySearchParamsToUrl(url, options));
|
|
3576
3776
|
return Array.isArray(loaders) ? await parseInBatches(response, loaders, options) : await parseInBatches(response, loaders, options);
|
|
3577
3777
|
}
|
|
3578
3778
|
return Array.isArray(loaders) ? await parseInBatches(file, loaders, options) : await parseInBatches(file, loaders, options);
|
|
@@ -3591,8 +3791,10 @@ async function load(url, loaders, options, context) {
|
|
|
3591
3791
|
resolvedLoaders = loaders;
|
|
3592
3792
|
resolvedOptions = options;
|
|
3593
3793
|
}
|
|
3794
|
+
resolvedOptions ||= getGlobalLoaderOptions();
|
|
3594
3795
|
if (!Array.isArray(resolvedLoaders) && isSourceLoader(resolvedLoaders)) {
|
|
3595
3796
|
const sourceLoader = await resolveSourceLoader(resolvedLoaders, url, resolvedOptions);
|
|
3797
|
+
resolvedOptions = await resolveLoaderAuthenticationOptions(resolvedLoaders.getAuthentications ? resolvedLoaders : sourceLoader, typeof url === "string" ? url : "", resolvedOptions || {});
|
|
3596
3798
|
const runtimeCoreApi = {
|
|
3597
3799
|
fetchFile,
|
|
3598
3800
|
parse,
|
|
@@ -3606,6 +3808,7 @@ async function load(url, loaders, options, context) {
|
|
|
3606
3808
|
}
|
|
3607
3809
|
if (Array.isArray(resolvedLoaders) && resolvedLoaders.length === 1 && isSourceLoader(resolvedLoaders[0])) {
|
|
3608
3810
|
const sourceLoader = await resolveSourceLoader(resolvedLoaders[0], url, resolvedOptions);
|
|
3811
|
+
resolvedOptions = await resolveLoaderAuthenticationOptions(resolvedLoaders[0].getAuthentications ? resolvedLoaders[0] : sourceLoader, typeof url === "string" ? url : "", resolvedOptions || {});
|
|
3609
3812
|
const runtimeCoreApi = {
|
|
3610
3813
|
fetchFile,
|
|
3611
3814
|
parse,
|
|
@@ -3624,6 +3827,7 @@ async function load(url, loaders, options, context) {
|
|
|
3624
3827
|
});
|
|
3625
3828
|
if (selectedLoader && isSourceLoader(selectedLoader)) {
|
|
3626
3829
|
const sourceLoader = await resolveSourceLoader(selectedLoader, url, resolvedOptions);
|
|
3830
|
+
resolvedOptions = await resolveLoaderAuthenticationOptions(selectedLoader.getAuthentications ? selectedLoader : sourceLoader, typeof url === "string" ? url : "", resolvedOptions || {});
|
|
3627
3831
|
return sourceLoader.createDataSource(url, resolvedOptions || {}, {
|
|
3628
3832
|
fetchFile,
|
|
3629
3833
|
parse,
|
|
@@ -3636,15 +3840,20 @@ async function load(url, loaders, options, context) {
|
|
|
3636
3840
|
}
|
|
3637
3841
|
if (selectedLoader && typeof url === "string") {
|
|
3638
3842
|
const loaderImplementation = await getLoaderImplementation(selectedLoader, resolvedOptions, url);
|
|
3843
|
+
resolvedOptions = await resolveLoaderAuthenticationOptions(selectedLoader.getAuthentications ? selectedLoader : loaderImplementation, url, resolvedOptions || {});
|
|
3639
3844
|
const parseUrl = loaderImplementation.parseUrl;
|
|
3640
|
-
if (parseUrl)
|
|
3641
|
-
|
|
3845
|
+
if (parseUrl) {
|
|
3846
|
+
const requestUrl = applySearchParamsToUrl(url, resolvedOptions);
|
|
3847
|
+
return await parseUrl(requestUrl, resolvedOptions, context);
|
|
3848
|
+
}
|
|
3642
3849
|
}
|
|
3643
3850
|
}
|
|
3851
|
+
if (resolvedOptions)
|
|
3852
|
+
resolvedOptions = resolveAuthenticationOptions(resolvedOptions);
|
|
3644
3853
|
const fetch2 = getFetchFunction(resolvedOptions);
|
|
3645
3854
|
let data = url;
|
|
3646
3855
|
if (typeof url === "string") {
|
|
3647
|
-
data = await fetch2(url);
|
|
3856
|
+
data = await fetch2(applySearchParamsToUrl(url, resolvedOptions));
|
|
3648
3857
|
}
|
|
3649
3858
|
if (isBlob(url)) {
|
|
3650
3859
|
data = await fetch2(url);
|
|
@@ -3727,6 +3936,7 @@ function getLoadersFromContext(loaders, context) {
|
|
|
3727
3936
|
|
|
3728
3937
|
// dist/lib/api/parse.js
|
|
3729
3938
|
async function parse(data, loaders, options, context) {
|
|
3939
|
+
var _a, _b;
|
|
3730
3940
|
if (loaders && !Array.isArray(loaders) && !isLoaderObject(loaders)) {
|
|
3731
3941
|
context = void 0;
|
|
3732
3942
|
options = loaders;
|
|
@@ -3744,7 +3954,9 @@ async function parse(data, loaders, options, context) {
|
|
|
3744
3954
|
if (isSourceLoader(loader)) {
|
|
3745
3955
|
throw new Error(`${loader.id} is a SourceLoader. Use load() to create a runtime source object instead of parse().`);
|
|
3746
3956
|
}
|
|
3747
|
-
const
|
|
3957
|
+
const normalizedOptions = normalizeOptions(options, loader, candidateLoaders, url);
|
|
3958
|
+
const authenticationLoader = !loader.getAuthentications && ((_b = (_a = normalizedOptions.core) == null ? void 0 : _a.credentials) == null ? void 0 : _b.length) ? await getLoaderImplementation(loader, normalizedOptions, url || (context == null ? void 0 : context.url)) : loader;
|
|
3959
|
+
const strictOptions = await resolveLoaderAuthenticationOptions(authenticationLoader, url || "", normalizedOptions);
|
|
3748
3960
|
context = getLoaderContext(
|
|
3749
3961
|
// @ts-expect-error
|
|
3750
3962
|
{ url, _parse: parse, loaders: candidateLoaders },
|
|
@@ -3918,8 +4130,8 @@ function getTemporaryFilename(filename2) {
|
|
|
3918
4130
|
}
|
|
3919
4131
|
|
|
3920
4132
|
// dist/lib/api/create-data-source.js
|
|
3921
|
-
function createDataSource(data, sources, options) {
|
|
3922
|
-
var _a;
|
|
4133
|
+
function createDataSource(data, sources, options = {}) {
|
|
4134
|
+
var _a, _b, _c, _d, _e;
|
|
3923
4135
|
const resolvedOptions = options || {};
|
|
3924
4136
|
const type = ((_a = resolvedOptions == null ? void 0 : resolvedOptions.core) == null ? void 0 : _a.type) || resolvedOptions.type || "auto";
|
|
3925
4137
|
const source = sources.length === 1 ? sources[0] : type === "auto" ? selectLoaderSync(data, sources, {
|
|
@@ -3931,7 +4143,23 @@ function createDataSource(data, sources, options) {
|
|
|
3931
4143
|
if (!source) {
|
|
3932
4144
|
throw new Error("Not a valid source type");
|
|
3933
4145
|
}
|
|
3934
|
-
|
|
4146
|
+
const contributions = ((_c = (_b = resolvedOptions.core) == null ? void 0 : _b.credentials) == null ? void 0 : _c.length) ? (_d = source.getAuthentications) == null ? void 0 : _d.call(source, typeof data === "string" ? data : "", resolvedOptions) : void 0;
|
|
4147
|
+
if (contributions && "then" in contributions) {
|
|
4148
|
+
void contributions.catch(() => {
|
|
4149
|
+
});
|
|
4150
|
+
throw new Error("Use load() with an asynchronous getAuthentications() hook.");
|
|
4151
|
+
}
|
|
4152
|
+
const authenticatedOptions = resolveAuthenticationOptions((contributions == null ? void 0 : contributions.length) ? {
|
|
4153
|
+
...resolvedOptions,
|
|
4154
|
+
core: {
|
|
4155
|
+
...resolvedOptions.core,
|
|
4156
|
+
authentications: [
|
|
4157
|
+
...((_e = resolvedOptions.core) == null ? void 0 : _e.authentications) || [],
|
|
4158
|
+
...contributions || []
|
|
4159
|
+
]
|
|
4160
|
+
}
|
|
4161
|
+
} : resolvedOptions);
|
|
4162
|
+
return source.createDataSource(data, authenticatedOptions, coreApi);
|
|
3935
4163
|
}
|
|
3936
4164
|
function getSourceOfType(type, sources) {
|
|
3937
4165
|
for (const service of sources) {
|
|
@@ -4005,7 +4233,7 @@ function makeStream(source, options) {
|
|
|
4005
4233
|
}
|
|
4006
4234
|
|
|
4007
4235
|
// dist/null-loader.js
|
|
4008
|
-
var VERSION4 = true ? "5.0.0-alpha.
|
|
4236
|
+
var VERSION4 = true ? "5.0.0-alpha.8" : "latest";
|
|
4009
4237
|
var NullWorkerLoader = {
|
|
4010
4238
|
dataType: null,
|
|
4011
4239
|
batchType: null,
|