From 0bf11a08681ae4c465f26245b11f0b51dafcd340 Mon Sep 17 00:00:00 2001 From: "vitalii.semianchuk" Date: Wed, 1 Jul 2026 18:21:31 +0100 Subject: [PATCH] fix: dead code cleanup, missing MIME types, partial download leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - formatSpeed had identical branches in its ternary — simplified - file server was missing MIME types for avif, flac, m4a, mov, ico so those files got served as application/octet-stream - removed unreachable guard in parseObjectPositionAxis - partial downloads weren't cleaned up on failure so the next call would find and use the corrupted file — now removes partials in catch block - added description to @hyperframes/core package.json --- packages/core/package.json | 2 +- packages/engine/src/services/fileServer.ts | 5 +++++ packages/engine/src/utils/alphaBlit.ts | 1 - packages/engine/src/utils/urlDownloader.ts | 3 ++- packages/player/src/controls.ts | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index df54267a48..9fb8474dc6 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,7 +1,7 @@ { "name": "@hyperframes/core", "version": "0.7.22", - "description": "", + "description": "Types, parsers, generators, linter, and runtime for HyperFrames", "repository": { "type": "git", "url": "https://github.com/heygen-com/hyperframes", diff --git a/packages/engine/src/services/fileServer.ts b/packages/engine/src/services/fileServer.ts index f7d5acd76a..dd5f269736 100644 --- a/packages/engine/src/services/fileServer.ts +++ b/packages/engine/src/services/fileServer.ts @@ -33,6 +33,11 @@ const MIME_TYPES: Record = { ".woff2": "font/woff2", ".ttf": "font/ttf", ".otf": "font/otf", + ".avif": "image/avif", + ".flac": "audio/flac", + ".m4a": "audio/mp4", + ".mov": "video/quicktime", + ".ico": "image/x-icon", }; export interface FileServerOptions { diff --git a/packages/engine/src/utils/alphaBlit.ts b/packages/engine/src/utils/alphaBlit.ts index b7a0dba5ae..337dfc51a8 100644 --- a/packages/engine/src/utils/alphaBlit.ts +++ b/packages/engine/src/utils/alphaBlit.ts @@ -687,7 +687,6 @@ function parseObjectPositionAxis(value: string, axis: "x" | "y"): number { // Pixel values (e.g. "10px") aren't fractional; without the slack-space // numerator we can't honor them precisely. Fall back to center — this is // strictly worse than the browser but matches what we'd render today. - if (axis === "x" || axis === "y") return 0.5; return 0.5; } diff --git a/packages/engine/src/utils/urlDownloader.ts b/packages/engine/src/utils/urlDownloader.ts index 3dbd65321d..3ac799d99b 100644 --- a/packages/engine/src/utils/urlDownloader.ts +++ b/packages/engine/src/utils/urlDownloader.ts @@ -1,4 +1,4 @@ -import { createWriteStream, existsSync, mkdirSync } from "fs"; +import { createWriteStream, existsSync, mkdirSync, rmSync } from "fs"; import { createHash } from "crypto"; import { join, extname } from "path"; import { Readable } from "stream"; @@ -125,6 +125,7 @@ export async function downloadToTemp( downloadPathCache.set(url, localPath); return localPath; } catch (err) { + try { rmSync(localPath, { force: true }); } catch {} const message = err instanceof Error ? err.message : String(err); if (message.includes("aborted")) { throw new Error(`[URLDownloader] Download timeout after ${timeoutMs / 1000}s: ${url}`); diff --git a/packages/player/src/controls.ts b/packages/player/src/controls.ts index 466bdd2138..8d24b45574 100644 --- a/packages/player/src/controls.ts +++ b/packages/player/src/controls.ts @@ -32,7 +32,7 @@ export interface ControlsOptions { } export function formatSpeed(speed: number): string { - return Number.isInteger(speed) ? `${speed}x` : `${speed}x`; + return `${speed}x`; } export function formatTime(seconds: number): string {