fix: resolve format and lint errors

- Fix unnecessary escape characters in template literal (no-useless-escape)
- Apply oxfmt formatting

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Miguel Ángel
2026-03-26 18:47:51 -04:00
co-authored by Claude Opus 4.6
parent e2061694f2
commit ab54952c26
2 changed files with 31 additions and 18 deletions
+8 -12
View File
@@ -391,27 +391,23 @@ export function lintHyperframeHtml(
}
}
// #3.7: Fabricated inline base64 media — CRITICAL
// Inline base64 audio/video data is almost always fabricated garbage that
// won't play. Real audio files are 100KB+ when base64-encoded.
// #3.7: Inline base64 audio/video — PROHIBITED
// Base64 audio/video bloats file size and breaks rendering. Use URLs or relative paths.
{
const base64MediaRe =
/src\s*=\s*["'](data:(?:audio|video)\/[^;]+;base64,([A-Za-z0-9+/=]{100,}))["']/gi;
/src\s*=\s*["'](data:(?:audio|video)\/[^;]+;base64,([A-Za-z0-9+/=]{20,}))["']/gi;
let b64Match: RegExpExecArray | null;
while ((b64Match = base64MediaRe.exec(source)) !== null) {
// Check if it's suspiciously repetitive (fake data has long runs of repeated chars)
const sample = (b64Match[2] || "").slice(0, 200);
const uniqueChars = new Set(sample.replace(/[A-Za-z0-9+/=]/g, (c) => c)).size;
const dataSize = Math.round(((b64Match[2] || "").length * 3) / 4);
const isSuspicious = uniqueChars < 15 || (dataSize > 1000 && dataSize < 50000);
// Any embedded base64 audio is suspicious — real audio should be a file
pushFinding({
code: "fabricated_inline_media",
severity: isSuspicious ? "error" : "warning",
message: isSuspicious
? `Fabricated base64 media detected (${(dataSize / 1024).toFixed(0)} KB). This is almost certainly fake data that won't play.`
: `Embedded base64 audio/video detected (${(dataSize / 1024).toFixed(0)} KB). Consider using a file URL instead.`,
fixHint: "Remove the data: URI and use a real media file URL instead.",
code: "base64_media_prohibited",
severity: "error",
message: `Inline base64 audio/video detected (${(dataSize / 1024).toFixed(0)} KB)${isSuspicious ? " — likely fabricated data" : ""}. Base64 media is prohibited — it bloats file size and breaks rendering.`,
fixHint:
"Use a relative path (assets/music.mp3) or HTTPS URL for the audio/video src. Never embed media as base64.",
snippet: truncateSnippet((b64Match[1] ?? "").slice(0, 80) + "..."),
});
}
@@ -13,7 +13,15 @@
* full context, and failures produce a diagnostic summary.
*/
import { existsSync, mkdirSync, rmSync, readFileSync, writeFileSync, copyFileSync, appendFileSync } from "fs";
import {
existsSync,
mkdirSync,
rmSync,
readFileSync,
writeFileSync,
copyFileSync,
appendFileSync,
} from "fs";
import {
type EngineConfig,
resolveConfig,
@@ -281,7 +289,11 @@ export function createRenderJob(config: RenderConfig): RenderJob {
* Wraps a <template>-based sub-composition into a standalone HTML document
* that can be rendered independently by the producer.
*/
function wrapSubCompositionAsStandalone(templateHtml: string, compositionId: string, _srcPath: string): string {
function wrapSubCompositionAsStandalone(
templateHtml: string,
compositionId: string,
_srcPath: string,
): string {
// Extract the inner content from the <template> wrapper
const templateMatch = templateHtml.match(/<template[^>]*>([\s\S]*)<\/template>/i);
const inner = templateMatch?.[1]?.trim() ?? templateHtml;
@@ -311,7 +323,7 @@ function wrapSubCompositionAsStandalone(templateHtml: string, compositionId: str
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: #000; overflow: hidden; width: ${width}px; height: ${height}px; }
</style>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.12.7/dist/gsap.min.js"><\/script>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.12.7/dist/gsap.min.js"></script>
</head>
<body>
<div id="main-comp" data-composition-id="${compositionId}" data-start="0"${dataDuration} data-width="${width}" data-height="${height}" style="position:relative;width:${width}px;height:${height}px;overflow:hidden;">
@@ -319,7 +331,7 @@ ${withoutScripts}
<script>
window.__timelines = window.__timelines || {};
${scripts.map((s) => s.replace(/<\/?script[^>]*>/gi, "")).join("\n")}
<\/script>
</script>
</div>
</body>
</html>`;
@@ -454,10 +466,15 @@ export async function executeRenderJob(
if (composition.duration <= 0) {
const discoveredDuration = await getCompositionDuration(probeSession);
assertNotAborted();
log.info("Probed composition duration from browser", { discoveredDuration, staticDuration: compiled.staticDuration });
log.info("Probed composition duration from browser", {
discoveredDuration,
staticDuration: compiled.staticDuration,
});
composition.duration = discoveredDuration;
} else {
log.info("Using static duration from data-duration attribute", { duration: composition.duration });
log.info("Using static duration from data-duration attribute", {
duration: composition.duration,
});
}
// Resolve unresolved composition durations via window.__timelines