mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 04:38:33 +00:00
Run `fallow fix --auto-fixable` to remove `export` keywords from symbols fallow's reachability analysis identifies as unused. Keeps only the cases where the symbol is still referenced internally in its own file (so removing `export` doesn't surface a new oxlint `no-unused-vars` error). Result: fallow dead-code findings drop from 276 → 208 (68 fewer unused exports), with no behavior change — each symbol is still defined and used exactly the same way within its file. Reverted ~20 files where fallow's auto-fix would have created cascading "declared but never used" lint errors — those are cases where the symbol isn't used at all, and properly cleaning them up means deleting the declaration, not just dropping `export`. Better to land that as a separate, narrower PR rather than mixing it into a mechanical de-export. Also reverted four false positives where fallow missed real consumers: - `captureCost.ts` (renderOrchestrator has two separate import blocks from the same module; fallow only saw the first) - `propertyPanelHelpers.ts`, `domEditingLayers.ts` (real internal uses fallow's reachability missed) - `render.ts` (functions imported via `await import()` dynamic import, which fallow's static analysis doesn't follow) Test plan: bun run --filter '*' typecheck (clean), oxlint + oxfmt clean, cli/core/studio/engine vitest suites pass (335 + 917 + 576 + 605 tests).
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
export interface ImportedFontAsset {
|
|
family: string;
|
|
path: string;
|
|
url: string;
|
|
}
|
|
|
|
const FONT_EXT_RE = /\.(eot|otf|ttc|ttf|woff2?)$/i;
|
|
const FONT_STYLE_SUFFIX_RE =
|
|
/\s+(thin|extralight|extra light|light|regular|roman|medium|semibold|semi bold|bold|extrabold|extra bold|black|italic|oblique|variable)$/i;
|
|
|
|
function cssString(value: string): string {
|
|
return JSON.stringify(value);
|
|
}
|
|
|
|
export function fontFamilyFromAssetPath(path: string): string {
|
|
const fileName = decodeURIComponent(path.split(/[\\/]/).pop() ?? path).replace(FONT_EXT_RE, "");
|
|
let family = fileName
|
|
.replace(/[_-]+/g, " ")
|
|
.replace(/([a-z])([A-Z])/g, "$1 $2")
|
|
.replace(/\s+/g, " ")
|
|
.trim();
|
|
|
|
while (FONT_STYLE_SUFFIX_RE.test(family)) {
|
|
family = family.replace(FONT_STYLE_SUFFIX_RE, "").trim();
|
|
}
|
|
|
|
return family || fileName;
|
|
}
|
|
|
|
export function importedFontFaceCss(asset: ImportedFontAsset, url: string = asset.url): string {
|
|
return `@font-face { font-family: ${cssString(asset.family)}; src: url(${cssString(url)}); font-display: swap; }`;
|
|
}
|