dsh-magpie-connect 0.7.1 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dsh.plugin.json +1 -1
- package/lib/client.js +82 -45
- package/lib/index.js +83 -25
- package/lib/index.js.map +2 -2
- package/lib/types/client/trace-format.d.ts +27 -11
- package/lib/types/client/trace-wires.d.ts +65 -0
- package/lib/types/trace.d.ts +2 -0
- package/package.json +1 -1
package/dsh.plugin.json
CHANGED
package/lib/client.js
CHANGED
|
@@ -157,12 +157,10 @@ var EN = {
|
|
|
157
157
|
"trace.quotaReset": "reset in {d}",
|
|
158
158
|
"trace.candidate.used": "{n}% used",
|
|
159
159
|
"trace.candidate.amount": "{amount} / {limit} {unit}",
|
|
160
|
+
"trace.candidate.amountPct": "{amount} / {limit} {unit} \xB7 {n}% used",
|
|
160
161
|
"trace.unit.credits": "credits",
|
|
161
|
-
"trace.unit.credits.total": "total credits",
|
|
162
162
|
"trace.unit.tokens": "tokens",
|
|
163
|
-
"trace.unit.tokens.total": "total tokens",
|
|
164
163
|
"trace.unit.requests": "requests",
|
|
165
|
-
"trace.unit.requests.total": "total requests",
|
|
166
164
|
"trace.webTraceMissing": "Save the Magpie Web Key for full routing-group detail.",
|
|
167
165
|
"trace.webTraceUnauthorized": "Magpie Web Key was refused; the simplified routing view remains.",
|
|
168
166
|
"trace.webTraceUnavailable": "Full routing-group detail is unavailable; showing the simplified view.",
|
|
@@ -301,16 +299,14 @@ var ZH = {
|
|
|
301
299
|
"trace.reason.windowSize": "\u8D85\u51FA\u5176 {n}K \u4E0A\u4E0B\u6587",
|
|
302
300
|
"trace.reason.noURL": "\u7F3A\u5C11 API \u5730\u5740",
|
|
303
301
|
"trace.reason.other": "\u6682\u4E0D\u53EF\u7528",
|
|
304
|
-
"trace.restUntil": "{d}
|
|
305
|
-
"trace.quotaReset": "{d}
|
|
302
|
+
"trace.restUntil": "{d}\u540E\u6062\u590D",
|
|
303
|
+
"trace.quotaReset": "{d}\u540E\u91CD\u7F6E",
|
|
306
304
|
"trace.candidate.used": "\u5DF2\u7528 {n}%",
|
|
307
305
|
"trace.candidate.amount": "{amount} / {limit} {unit}",
|
|
306
|
+
"trace.candidate.amountPct": "{amount} / {limit} {unit} \xB7 \u5DF2\u7528 {n}%",
|
|
308
307
|
"trace.unit.credits": "\u79EF\u5206",
|
|
309
|
-
"trace.unit.credits.total": "\u603B\u79EF\u5206",
|
|
310
308
|
"trace.unit.tokens": "tokens",
|
|
311
|
-
"trace.unit.tokens.total": "\u603B tokens",
|
|
312
309
|
"trace.unit.requests": "\u6B21",
|
|
313
|
-
"trace.unit.requests.total": "\u603B\u6B21\u6570",
|
|
314
310
|
"trace.webTraceMissing": "\u4FDD\u5B58 Magpie Web Key \u540E\u53EF\u663E\u793A\u5B8C\u6574\u8DEF\u7531\u7EC4\u8BE6\u60C5\u3002",
|
|
315
311
|
"trace.webTraceUnauthorized": "Magpie Web Key \u88AB\u62D2\u7EDD\uFF1B\u5F53\u524D\u663E\u793A\u7B80\u5316\u8DEF\u7531\u89C6\u56FE\u3002",
|
|
316
312
|
"trace.webTraceUnavailable": "\u5B8C\u6574\u8DEF\u7531\u7EC4\u8BE6\u60C5\u6682\u4E0D\u53EF\u7528\uFF1B\u5F53\u524D\u663E\u793A\u7B80\u5316\u89C6\u56FE\u3002",
|
|
@@ -781,7 +777,7 @@ function shouldRetryPending(snapshot2, attempts, limit = PENDING_RETRY_LIMIT) {
|
|
|
781
777
|
|
|
782
778
|
// src/client/page.tsx
|
|
783
779
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
784
|
-
var PLUGIN_VERSION = "0.7.
|
|
780
|
+
var PLUGIN_VERSION = "0.7.3";
|
|
785
781
|
var REPO_URL = "https://github.com/bitxeno/dsh-magpie-connect";
|
|
786
782
|
var css2 = {
|
|
787
783
|
section: { display: "flex", flexDirection: "column", gap: 16, maxWidth: 780, paddingBottom: 32 },
|
|
@@ -1281,16 +1277,24 @@ function resetParts(resetsAt, now = Date.now()) {
|
|
|
1281
1277
|
if (resetsAt === void 0) return void 0;
|
|
1282
1278
|
const at = Date.parse(resetsAt);
|
|
1283
1279
|
if (!Number.isFinite(at) || at <= now) return void 0;
|
|
1284
|
-
const
|
|
1285
|
-
const minutes = Math.ceil(ms / 6e4);
|
|
1280
|
+
const minutes = Math.max(1, Math.round((at - now) / 6e4));
|
|
1286
1281
|
if (minutes < 60) return { n: minutes, unit: "m" };
|
|
1287
|
-
const hours = Math.
|
|
1282
|
+
const hours = Math.round(minutes / 60);
|
|
1288
1283
|
if (hours < 48) return { n: hours, unit: "h" };
|
|
1289
|
-
return { n: Math.
|
|
1284
|
+
return { n: Math.round(hours / 24), unit: "d" };
|
|
1290
1285
|
}
|
|
1291
|
-
function
|
|
1292
|
-
|
|
1293
|
-
|
|
1286
|
+
function roundAmount(value) {
|
|
1287
|
+
return value !== void 0 && Number.isFinite(value) ? Math.round(value * 100) / 100 : void 0;
|
|
1288
|
+
}
|
|
1289
|
+
function usageText(facts) {
|
|
1290
|
+
const amount = roundAmount(facts.amount);
|
|
1291
|
+
const limit = roundAmount(facts.limit);
|
|
1292
|
+
const usedPct = facts.usedPct;
|
|
1293
|
+
const unit = facts.unit ?? "";
|
|
1294
|
+
if (amount !== void 0 && limit !== void 0) {
|
|
1295
|
+
return usedPct !== void 0 ? { template: "trace.candidate.amountPct", params: { amount, limit, unit, n: usedPct } } : { template: "trace.candidate.amount", params: { amount, limit, unit } };
|
|
1296
|
+
}
|
|
1297
|
+
return usedPct !== void 0 ? { template: "trace.candidate.used", params: { n: usedPct } } : void 0;
|
|
1294
1298
|
}
|
|
1295
1299
|
function maskUser(user) {
|
|
1296
1300
|
if (user === void 0) return void 0;
|
|
@@ -1401,6 +1405,34 @@ function prefersCoarsePointer(target) {
|
|
|
1401
1405
|
return matchMedia("(pointer: coarse)").matches;
|
|
1402
1406
|
}
|
|
1403
1407
|
|
|
1408
|
+
// src/client/trace-wires.ts
|
|
1409
|
+
var WIRE_GUTTER = 34;
|
|
1410
|
+
var WIRE_X0 = 10;
|
|
1411
|
+
var WIRE_X1 = 26;
|
|
1412
|
+
var WIRE_Y0 = 16;
|
|
1413
|
+
var NO_WIRES = { width: 0, height: 0, paths: [] };
|
|
1414
|
+
function buildWireState(group, cards, activeIndex, outcomes) {
|
|
1415
|
+
const midX = (WIRE_X0 + WIRE_X1) / 2;
|
|
1416
|
+
const paths = cards.map((card, index) => {
|
|
1417
|
+
const y3 = card.top - group.top + card.height / 2;
|
|
1418
|
+
return {
|
|
1419
|
+
// The S curve: leave the header horizontally, bend through the gutter,
|
|
1420
|
+
// and meet the card horizontally at its mid-height.
|
|
1421
|
+
d: `M${WIRE_X0} ${WIRE_Y0} C${midX} ${WIRE_Y0} ${midX} ${y3} ${WIRE_X1} ${y3}`,
|
|
1422
|
+
active: index === activeIndex,
|
|
1423
|
+
live: outcomes[index] === "processing"
|
|
1424
|
+
};
|
|
1425
|
+
});
|
|
1426
|
+
return { width: WIRE_GUTTER, height: group.height, paths };
|
|
1427
|
+
}
|
|
1428
|
+
function sameWires(a, b) {
|
|
1429
|
+
if (a.width !== b.width || a.height !== b.height || a.paths.length !== b.paths.length) return false;
|
|
1430
|
+
return a.paths.every((path, index) => {
|
|
1431
|
+
const other = b.paths[index];
|
|
1432
|
+
return other !== void 0 && other.d === path.d && other.active === path.active && other.live === path.live;
|
|
1433
|
+
});
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1404
1436
|
// src/client/trace-button.tsx
|
|
1405
1437
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1406
1438
|
var DESKTOP_REFRESH_MS = 5e3;
|
|
@@ -1704,9 +1736,7 @@ var candidateDetailStyle = {
|
|
|
1704
1736
|
fontSize: "11px",
|
|
1705
1737
|
lineHeight: "16px",
|
|
1706
1738
|
color: "var(--dsw-alias-label-tertiary, #8a94a6)",
|
|
1707
|
-
|
|
1708
|
-
textOverflow: "ellipsis",
|
|
1709
|
-
whiteSpace: "nowrap"
|
|
1739
|
+
overflowWrap: "break-word"
|
|
1710
1740
|
};
|
|
1711
1741
|
var candidateGaugeStyle = {
|
|
1712
1742
|
marginTop: "6px",
|
|
@@ -1792,42 +1822,49 @@ function RoutingGroupCard(props) {
|
|
|
1792
1822
|
const showHeader = section.hideHeader !== true;
|
|
1793
1823
|
const activeIndex = section.candidates.findIndex((candidate) => candidate.outcome === "answered" || candidate.outcome === "processing");
|
|
1794
1824
|
const groupRef = (0, import_react4.useRef)(null);
|
|
1795
|
-
const [wires, setWires] = (0, import_react4.useState)(
|
|
1825
|
+
const [wires, setWires] = (0, import_react4.useState)(NO_WIRES);
|
|
1796
1826
|
(0, import_react4.useLayoutEffect)(() => {
|
|
1797
1827
|
const container = groupRef.current;
|
|
1798
1828
|
if (container === null || !showHeader) {
|
|
1799
|
-
setWires(
|
|
1829
|
+
setWires(NO_WIRES);
|
|
1800
1830
|
return;
|
|
1801
1831
|
}
|
|
1802
1832
|
const measure = () => {
|
|
1803
|
-
const rect = container.getBoundingClientRect();
|
|
1804
1833
|
const rows = Array.from(container.querySelectorAll("[data-magpie-candidate]"));
|
|
1805
|
-
const
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
return {
|
|
1813
|
-
d: `M${x0} ${y0} C${mx} ${y0} ${mx} ${y3} ${x3} ${y3}`,
|
|
1814
|
-
active: index === activeIndex,
|
|
1815
|
-
live: section.candidates[index]?.outcome === "processing"
|
|
1816
|
-
};
|
|
1817
|
-
});
|
|
1818
|
-
setWires({ width: rect.width, height: rect.height, paths });
|
|
1834
|
+
const next = buildWireState(
|
|
1835
|
+
container.getBoundingClientRect(),
|
|
1836
|
+
rows.map((row) => row.getBoundingClientRect()),
|
|
1837
|
+
activeIndex,
|
|
1838
|
+
section.candidates.map((candidate) => candidate.outcome)
|
|
1839
|
+
);
|
|
1840
|
+
setWires((current) => sameWires(current, next) ? current : next);
|
|
1819
1841
|
};
|
|
1820
1842
|
measure();
|
|
1821
1843
|
window.addEventListener("resize", measure);
|
|
1822
|
-
|
|
1844
|
+
const observer = new ResizeObserver(measure);
|
|
1845
|
+
observer.observe(container);
|
|
1846
|
+
return () => {
|
|
1847
|
+
observer.disconnect();
|
|
1848
|
+
window.removeEventListener("resize", measure);
|
|
1849
|
+
};
|
|
1823
1850
|
}, [showHeader, activeIndex, section.candidates]);
|
|
1824
1851
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { ref: groupRef, style: traceGroupStyle, children: [
|
|
1825
|
-
showHeader && wires.
|
|
1852
|
+
showHeader && wires.height > 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1826
1853
|
"svg",
|
|
1827
1854
|
{
|
|
1828
1855
|
"aria-hidden": "true",
|
|
1829
|
-
viewBox: `0 0 ${
|
|
1830
|
-
style: {
|
|
1856
|
+
viewBox: `0 0 ${WIRE_GUTTER} ${wires.height}`,
|
|
1857
|
+
style: {
|
|
1858
|
+
position: "absolute",
|
|
1859
|
+
top: 0,
|
|
1860
|
+
left: 0,
|
|
1861
|
+
// An explicit box equal to the viewBox: no aspect-ratio fitting,
|
|
1862
|
+
// so no scale — a stroke stays 1.5px and a wire stays put.
|
|
1863
|
+
width: `${WIRE_GUTTER}px`,
|
|
1864
|
+
height: `${wires.height}px`,
|
|
1865
|
+
overflow: "visible",
|
|
1866
|
+
pointerEvents: "none"
|
|
1867
|
+
},
|
|
1831
1868
|
children: wires.paths.map((wire, index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1832
1869
|
"path",
|
|
1833
1870
|
{
|
|
@@ -1907,12 +1944,12 @@ function candidateDetail(candidate) {
|
|
|
1907
1944
|
const resetText2 = renew2 !== void 0 ? text("trace.quotaReset", { d: formatDuration(renew2, "reset") }) : "";
|
|
1908
1945
|
return [reason, resetText2].filter(Boolean).join(" \xB7 ");
|
|
1909
1946
|
}
|
|
1910
|
-
const amount = candidate.amount
|
|
1911
|
-
const limit = candidate.limit
|
|
1912
|
-
const windowName = candidate.windowName;
|
|
1947
|
+
const amount = candidate.amount;
|
|
1948
|
+
const limit = candidate.limit;
|
|
1913
1949
|
const unitKey = candidate.unit !== void 0 && candidate.unit !== "" ? `trace.unit.${candidate.unit}` : "";
|
|
1914
|
-
const unit =
|
|
1915
|
-
const
|
|
1950
|
+
const unit = unitKey !== "" && text(unitKey) !== unitKey ? text(unitKey) : candidate.unit ?? "";
|
|
1951
|
+
const usage = usageText({ amount, limit, unit, usedPct: candidate.usedPct });
|
|
1952
|
+
const amountText = usage !== void 0 ? text(usage.template, usage.params).trim() : "";
|
|
1916
1953
|
const renew = candidate.renews?.[0] !== void 0 ? resetParts(candidate.renews[0]) : void 0;
|
|
1917
1954
|
const resetText = renew !== void 0 ? text("trace.quotaReset", { d: formatDuration(renew, "reset") }) : "";
|
|
1918
1955
|
return [amountText, resetText].filter(Boolean).join(" \xB7 ");
|
package/lib/index.js
CHANGED
|
@@ -1717,14 +1717,65 @@ function statusForStatusCode(code) {
|
|
|
1717
1717
|
if (code >= 500) return "network";
|
|
1718
1718
|
return "unknown";
|
|
1719
1719
|
}
|
|
1720
|
+
var WEB_PROBE_TIMEOUT_MS = 1500;
|
|
1721
|
+
var WEB_COOKIE_FALLBACK_PORTS = ["3430", "443", "80"];
|
|
1722
|
+
function guessedWebCookie(base) {
|
|
1723
|
+
try {
|
|
1724
|
+
const url = new URL(base);
|
|
1725
|
+
return `magpie_web_${url.port || (url.protocol === "https:" ? "443" : "80")}`;
|
|
1726
|
+
} catch {
|
|
1727
|
+
return "magpie_web_3430";
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
var webCookieNames = /* @__PURE__ */ new Map();
|
|
1731
|
+
var webBasesResolved = /* @__PURE__ */ new Map();
|
|
1732
|
+
async function discoverWebCookieName(base, webKey, signal) {
|
|
1733
|
+
try {
|
|
1734
|
+
const response = await fetch(`${base.replace(/\/+$/, "")}/?k=${encodeURIComponent(webKey)}`, {
|
|
1735
|
+
redirect: "manual",
|
|
1736
|
+
cache: "no-store",
|
|
1737
|
+
signal
|
|
1738
|
+
});
|
|
1739
|
+
const match = /magpie_web_[A-Za-z0-9._-]+/.exec(response.headers.get("set-cookie") ?? "");
|
|
1740
|
+
return match?.[0];
|
|
1741
|
+
} catch {
|
|
1742
|
+
return void 0;
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
async function fetchWebResponse(base, webKey, path, accept, signal) {
|
|
1746
|
+
const tried = [];
|
|
1747
|
+
const attempt = (name2) => {
|
|
1748
|
+
tried.push(name2);
|
|
1749
|
+
return fetch(`${base}${path}`, {
|
|
1750
|
+
headers: { cookie: `${name2}=${webKey}`, accept },
|
|
1751
|
+
cache: "no-store",
|
|
1752
|
+
signal
|
|
1753
|
+
});
|
|
1754
|
+
};
|
|
1755
|
+
const cached = webCookieNames.get(base);
|
|
1756
|
+
let response = await attempt(cached ?? guessedWebCookie(base));
|
|
1757
|
+
if (response.status === 401) {
|
|
1758
|
+
const discovered = await discoverWebCookieName(base, webKey, signal);
|
|
1759
|
+
if (discovered !== void 0 && !tried.includes(discovered)) {
|
|
1760
|
+
response = await attempt(discovered);
|
|
1761
|
+
}
|
|
1762
|
+
if (response.status === 401) {
|
|
1763
|
+
for (const port of WEB_COOKIE_FALLBACK_PORTS) {
|
|
1764
|
+
const name2 = `magpie_web_${port}`;
|
|
1765
|
+
if (tried.includes(name2)) continue;
|
|
1766
|
+
response = await attempt(name2);
|
|
1767
|
+
if (response.status !== 401) break;
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
if (response.ok) {
|
|
1772
|
+
const winner = tried[tried.length - 1];
|
|
1773
|
+
if (winner !== void 0) webCookieNames.set(base, winner);
|
|
1774
|
+
}
|
|
1775
|
+
return response;
|
|
1776
|
+
}
|
|
1720
1777
|
async function fetchWebJson(base, webKey, path, signal) {
|
|
1721
|
-
const
|
|
1722
|
-
const port = url.port || (url.protocol === "https:" ? "443" : "80");
|
|
1723
|
-
const response = await fetch(`${base}${path}`, {
|
|
1724
|
-
headers: { cookie: `magpie_web_${port}=${webKey}`, accept: "application/json" },
|
|
1725
|
-
cache: "no-store",
|
|
1726
|
-
signal
|
|
1727
|
-
});
|
|
1778
|
+
const response = await fetchWebResponse(base, webKey, path, "application/json", signal);
|
|
1728
1779
|
if (!response.ok) {
|
|
1729
1780
|
const error = new Error(`Magpie Web HTTP ${response.status} ${path}`);
|
|
1730
1781
|
error.statusCode = response.status;
|
|
@@ -1733,29 +1784,40 @@ async function fetchWebJson(base, webKey, path, signal) {
|
|
|
1733
1784
|
return await response.json();
|
|
1734
1785
|
}
|
|
1735
1786
|
function webBases(base) {
|
|
1736
|
-
const candidates = [];
|
|
1787
|
+
const candidates = [base];
|
|
1737
1788
|
try {
|
|
1738
1789
|
const url = new URL(base);
|
|
1739
|
-
if (url.port
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1790
|
+
if (url.port !== "3430") {
|
|
1791
|
+
url.port = "3430";
|
|
1792
|
+
candidates.push(`${url.origin}${url.pathname.replace(/\/+$/, "")}`);
|
|
1793
|
+
}
|
|
1743
1794
|
} catch {
|
|
1744
1795
|
return [base];
|
|
1745
1796
|
}
|
|
1746
1797
|
return [...new Set(candidates)];
|
|
1747
1798
|
}
|
|
1799
|
+
function orderedWebBases(base) {
|
|
1800
|
+
const bases = webBases(base);
|
|
1801
|
+
const known = webBasesResolved.get(base);
|
|
1802
|
+
return known !== void 0 && bases.includes(known) ? [known, ...bases.filter((b) => b !== known)] : bases;
|
|
1803
|
+
}
|
|
1804
|
+
function webTrySignal(signal, index) {
|
|
1805
|
+
if (index === 0) return signal;
|
|
1806
|
+
const budget = AbortSignal.timeout(WEB_PROBE_TIMEOUT_MS);
|
|
1807
|
+
return typeof AbortSignal.any === "function" ? AbortSignal.any([signal, budget]) : budget;
|
|
1808
|
+
}
|
|
1748
1809
|
async function fetchFullWebTrace(base, webKey, signal) {
|
|
1749
1810
|
let lastError;
|
|
1750
|
-
for (const candidate of
|
|
1811
|
+
for (const [index, candidate] of orderedWebBases(base).entries()) {
|
|
1751
1812
|
try {
|
|
1752
|
-
const trace = await fetchWebJson(candidate, webKey, `${WEB_TRACE_PATH}?after=0`, signal);
|
|
1813
|
+
const trace = await fetchWebJson(candidate, webKey, `${WEB_TRACE_PATH}?after=0`, webTrySignal(signal, index));
|
|
1753
1814
|
if (!Array.isArray(trace.routes)) {
|
|
1754
1815
|
throw new Error("Magpie Web returned an unexpected trace shape");
|
|
1755
1816
|
}
|
|
1817
|
+
webBasesResolved.set(base, candidate);
|
|
1756
1818
|
return { trace, base: candidate };
|
|
1757
1819
|
} catch (error) {
|
|
1758
|
-
if (
|
|
1820
|
+
if (signal.aborted) throw error;
|
|
1759
1821
|
lastError = error;
|
|
1760
1822
|
}
|
|
1761
1823
|
}
|
|
@@ -1765,13 +1827,7 @@ function routingUrlFor(base) {
|
|
|
1765
1827
|
return `${base.replace(/\/+$/, "")}/?view=routing`;
|
|
1766
1828
|
}
|
|
1767
1829
|
async function fetchWebBinary(base, webKey, path, signal) {
|
|
1768
|
-
const
|
|
1769
|
-
const port = url.port || (url.protocol === "https:" ? "443" : "80");
|
|
1770
|
-
const response = await fetch(`${base}${path}`, {
|
|
1771
|
-
headers: { cookie: `magpie_web_${port}=${webKey}`, accept: "image/svg+xml,image/png,*/*" },
|
|
1772
|
-
cache: "no-store",
|
|
1773
|
-
signal
|
|
1774
|
-
});
|
|
1830
|
+
const response = await fetchWebResponse(base, webKey, path, "image/svg+xml,image/png,*/*", signal);
|
|
1775
1831
|
if (!response.ok) {
|
|
1776
1832
|
const error = new Error(`Magpie Web HTTP ${response.status} ${path}`);
|
|
1777
1833
|
error.statusCode = response.status;
|
|
@@ -1803,11 +1859,13 @@ async function fetchWebIcon(base, webKey, name2, signal) {
|
|
|
1803
1859
|
const ext = PNG_ICONS.has(safe) ? "png" : "svg";
|
|
1804
1860
|
const path = `/icons/${safe}.${ext}`;
|
|
1805
1861
|
let lastError;
|
|
1806
|
-
for (const candidate of
|
|
1862
|
+
for (const [index, candidate] of orderedWebBases(base).entries()) {
|
|
1807
1863
|
try {
|
|
1808
|
-
|
|
1864
|
+
const icon = await fetchWebBinary(candidate, webKey, path, webTrySignal(signal, index));
|
|
1865
|
+
webBasesResolved.set(base, candidate);
|
|
1866
|
+
return icon;
|
|
1809
1867
|
} catch (error) {
|
|
1810
|
-
if (
|
|
1868
|
+
if (signal.aborted) throw error;
|
|
1811
1869
|
lastError = error;
|
|
1812
1870
|
}
|
|
1813
1871
|
}
|