Skip to content

Commit 43146fb

Browse files
committed
refactor(media-use): name the header wait and restore the variants note
Renames the freeze timeout controller to headerWait so it no longer reads as HTTP headers, puts the theSVG variants fact dropped by the comment trim next to the line that picks the default mark, and keeps thesvgMatch on the file's JSDoc style.
1 parent 8a1becd commit 43146fb

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

‎packages/cli/src/media-use/lib/freeze.mjs‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,17 @@ function writeFrozen(destPath, buffer) {
2222

2323
export async function freezeUrl(url, destPath) {
2424
const where = String(url).slice(0, 80);
25-
const headers = new AbortController();
25+
const headerWait = new AbortController();
2626
const timer = setTimeout(
2727
() =>
28-
headers.abort(
28+
headerWait.abort(
2929
new Error(`freeze failed: no response within ${FREEZE_HEADERS_TIMEOUT_MS} ms for ${where}`),
3030
),
3131
FREEZE_HEADERS_TIMEOUT_MS,
3232
);
33-
const res = await fetchMedia(url, { signal: headers.signal }).finally(() => clearTimeout(timer));
33+
const res = await fetchMedia(url, { signal: headerWait.signal }).finally(() =>
34+
clearTimeout(timer),
35+
);
3436
if (!res.ok) throw new Error(`freeze failed: HTTP ${res.status} for ${where}`);
3537

3638
const body = await readCappedBody(res, MAX_FREEZE_BYTES, `freeze failed for ${where}`);

‎packages/cli/src/media-use/lib/logo-provider.mjs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,8 @@ export function titleMatches(title, entity) {
8888
return norm(title) === norm(entity);
8989
}
9090

91-
// The best theSVG manifest entry for an entity, or null. Exact slug beats exact title
92-
// beats alias; ties go to the brands collection. An entry whose license isn't in
93-
// THESVG_ACCEPTED_LICENSES is never returned.
91+
/** Best theSVG entry for an entity, or null: slug > title > alias, ties to the brands
92+
* collection; entries outside THESVG_ACCEPTED_LICENSES are never returned. */
9493
export function thesvgMatch(icons, entity) {
9594
const want = norm(entity);
9695
if (!want || !Array.isArray(icons)) return null;
@@ -169,6 +168,7 @@ export async function thesvgSearch(intent, ctx = {}) {
169168
}
170169
const hit = thesvgMatch(icons, entity);
171170
if (!hit) return null;
171+
// theSVG also ships mono, light/dark and wordmark variants; default is the full-color mark.
172172
const route = hit.variants.default;
173173
return {
174174
url: `${THESVG_CDN}/public${route.startsWith("/") ? "" : "/"}${route}`,

0 commit comments

Comments
 (0)