Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
feat(cli): stamp font compiler version in localized HTML
Miguel Ángeld6de083411d7
diff --git a/packages/cli/src/fontLocalize.test.ts b/packages/cli/src/fontLocalize.test.tsindex 43398d51c6..9637b2b0ea 100644--- a/packages/cli/src/fontLocalize.test.ts+++ b/packages/cli/src/fontLocalize.test.ts@@ -1,5 +1,5 @@import { describe, expect, it, vi } from "vitest";-import { runFontLocalize, type FontLocalizeIo } from "./fontLocalize.js";+import { runFontLocalize, stampFontCompilerVersion, type FontLocalizeIo } from "./fontLocalize.js";function makeIo(input: string): {io: FontLocalizeIo;@@ -70,3 +70,17 @@ describe("runFontLocalize", () => {expect(harness.errors.join(" ")).toContain("empty output");});});++describe("stampFontCompilerVersion", () => {+ it("records the compiler version inside the document head", () => {+ const stamped = stampFontCompilerVersion(+ "<!doctype html><html><head><title>x</title></head><body></body></html>",+ "0.8.15",+ );++ expect(stamped).toContain('<meta name="hyperframes-font-compiler-version" content="0.8.15">');+ expect(stamped.indexOf("hyperframes-font-compiler-version")).toBeLessThan(+ stamped.indexOf("</head>"),+ );+ });+});diff --git a/packages/cli/src/fontLocalize.ts b/packages/cli/src/fontLocalize.tsindex 4e01d71191..5dab4bdfed 100644--- a/packages/cli/src/fontLocalize.ts+++ b/packages/cli/src/fontLocalize.ts@@ -4,6 +4,17 @@ export interface FontLocalizeIo {writeError(value: string): void;}+export function stampFontCompilerVersion(html: string, version: string): string {+ const safeVersion = version.replace(/[^A-Za-z0-9.+-]/g, "") || "unknown";+ const tag = `<meta name="hyperframes-font-compiler-version" content="${safeVersion}">`;+ const headClose = html.search(/<\/head\s*>/i);+ if (headClose >= 0) return `${html.slice(0, headClose)}${tag}${html.slice(headClose)}`;+ const doctype = /^\s*<!doctype[^>]*>/i.exec(html);+ if (!doctype) return `${tag}${html}`;+ const insertAt = doctype.index + doctype[0].length;+ return `${html.slice(0, insertAt)}${tag}${html.slice(insertAt)}`;+}+function safeErrorName(error: unknown): string {const name = error instanceof Error ? error.name : "UnknownError";return /^[A-Za-z][A-Za-z0-9]*$/.test(name) ? name : "Error";diff --git a/packages/cli/src/fontLocalizeCli.ts b/packages/cli/src/fontLocalizeCli.tsindex eb6bef8aa7..50a7d3f20d 100644--- a/packages/cli/src/fontLocalizeCli.ts+++ b/packages/cli/src/fontLocalizeCli.ts@@ -1,6 +1,7 @@// fallow-ignore-file unused-fileimport { injectDeterministicFontFaces } from "@hyperframes/producer";-import { runFontLocalize } from "./fontLocalize.js";+import { runFontLocalize, stampFontCompilerVersion } from "./fontLocalize.js";+import { VERSION } from "./version.js";async function readStdin(): Promise<string> {const chunks: Buffer[] = [];@@ -18,10 +19,12 @@ export async function main(): Promise<number> {writeOutput: (value) => process.stdout.write(value),writeError: (value) => process.stderr.write(value),},- (html) =>- injectDeterministicFontFaces(html, {+ async (html) => {+ const localized = await injectDeterministicFontFaces(html, {failClosedFontFetch: true,allowSystemFontCapture: false,- }),+ });+ return stampFontCompilerVersion(localized, VERSION);+ },);}