Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.
TypeScript agentic-aiaiai-agentsai-videocompilerdslffmpeggenerative-aillmmarkup-languagemonorepoplugin-systemprogramming-languagetext-to-videotypescriptvideovideo-automationvideo-clonevideo-editingvideo-generation
fix: scan compiled HTML and Windows arguments linearly
kashorinb37bdc199243
diff --git a/packages/hyperframes/src/html-project.ts b/packages/hyperframes/src/html-project.tsindex e4038537..b48804c2 100644--- a/packages/hyperframes/src/html-project.ts+++ b/packages/hyperframes/src/html-project.ts@@ -10,10 +10,30 @@ export type HyperframesHtmlProject = {/** Read the exact clock emitted by this package. Seconds never reconstruct frame identity. */export function hyperframesHtmlDomain(html: string): HyperframesFrameDomain & { readonly canvas: HyperframesCanvas } {- const roots = [...html.matchAll(/<[^!][^>]*\sdata-composition-id="[^"]*"[^>]*>/gu)];- if (roots.length !== 1) throw new Error("Snapshot HTML needs exactly one compiled HyperFrames composition root");+ const attributeValue = (tag: string, name: string): string | undefined => {+ const marker = `${name}="`;+ for (let at = tag.indexOf(marker); at !== -1; at = tag.indexOf(marker, at + marker.length)) {+ const previous = tag[at - 1];+ if (previous === undefined || !" \t\r\n\f".includes(previous)) continue;+ const start = at + marker.length;+ const end = tag.indexOf('"', start);+ return end === -1 ? undefined : tag.slice(start, end);+ }+ return undefined;+ };+ let root: string | undefined;+ for (let at = html.indexOf("<div"); at !== -1; at = html.indexOf("<div", at)) {+ const end = html.indexOf(">", at + 4);+ if (end === -1) break;+ const tag = html.slice(at, end + 1);+ at = end + 1;+ if (attributeValue(tag, "data-composition-id") === undefined) continue;+ if (root !== undefined) throw new Error("Snapshot HTML needs exactly one compiled HyperFrames composition root");+ root = tag;+ }+ if (root === undefined) throw new Error("Snapshot HTML needs exactly one compiled HyperFrames composition root");const attribute = (name: string) => {- const value = new RegExp(`\\s${name}="([^"]*)"`, "u").exec(roots[0]![0])?.[1];+ const value = attributeValue(root, name);if (value === undefined) throw new Error(`Snapshot HTML lacks ${name}; use the compiled HyperFrames HTML`);return value;};diff --git a/packages/hyperframes/test/html-project.test.ts b/packages/hyperframes/test/html-project.test.tsindex e0b5a78d..b62bcd2d 100644--- a/packages/hyperframes/test/html-project.test.ts+++ b/packages/hyperframes/test/html-project.test.ts@@ -1,6 +1,16 @@import assert from "node:assert/strict";import test from "node:test";-import { hyperframesHtmlAssetUrls, mapHyperframesHtmlUrls } from "../src/index.js";+import { hyperframesHtmlAssetUrls, hyperframesHtmlDomain, mapHyperframesHtmlUrls } from "../src/index.js";++test("materialized composition HTML retains its exact frame domain", () => {+ const root = '<div data-composition-id="main" data-width="1080" data-height="1920" data-fps="30000/1001" data-hypit-frame-count="90">';+ assert.deepEqual(hyperframesHtmlDomain(`<style>.a{color:red}</style>${root}</div>`), {+ frameRate: { numerator: 30000, denominator: 1001 },+ frameCount: 90,+ canvas: { width: 1080, height: 1920 },+ });+ assert.throws(() => hyperframesHtmlDomain(`${root}</div>${root}</div>`), /exactly one compiled HyperFrames composition root/u);+});test("materialized HTML preserves CSS attribute quoting and internal SVG references while relocating media", () => {const html = '<style>@font-face{src:url("./font.woff2")}</style><div style="background-image:url("./picture.png");filter:url(#mask)">'diff --git a/packages/runtime-local/src/programs.ts b/packages/runtime-local/src/programs.tsindex 21e40604..e820cf0e 100644--- a/packages/runtime-local/src/programs.ts+++ b/packages/runtime-local/src/programs.ts@@ -196,13 +196,25 @@ function powershellLiteral(value: string): string {* as `-e` followed by the first word of the script, and node exits on the syntax error. Given one* string it passes that string through as the command line, which is what this builds.*/-function windowsCommandLine(args: readonly string[]): string {+export function windowsCommandLine(args: readonly string[]): string {return args.map((value) => {if (value !== "" && !/[\s"]/u.test(value)) return value;// A quote is escaped by the backslashes before it, so those double; a trailing run doubles too,// because the closing quote would otherwise escape itself against them.- const escaped = value.replace(/(\\*)"/gu, '$1$1\\"').replace(/(\\*)$/u, "$1$1");- return `"${escaped}"`;+ let escaped = '"';+ let backslashes = 0;+ for (const character of value) {+ if (character === "\\") {+ backslashes++;+ } else if (character === '"') {+ escaped += "\\".repeat(backslashes * 2 + 1) + '"';+ backslashes = 0;+ } else {+ escaped += "\\".repeat(backslashes) + character;+ backslashes = 0;+ }+ }+ return escaped + "\\".repeat(backslashes * 2) + '"';}).join(" ");}diff --git a/packages/runtime-local/test/windows-command-line.test.ts b/packages/runtime-local/test/windows-command-line.test.tsnew file mode 100644index 00000000..3b8a0aea--- /dev/null+++ b/packages/runtime-local/test/windows-command-line.test.ts@@ -0,0 +1,10 @@+import assert from "node:assert/strict";+import test from "node:test";+import { windowsCommandLine } from "../src/programs.js";++test("Windows arguments preserve spaces, quotes and trailing backslashes", () => {+ assert.equal(windowsCommandLine(["plain", "", "two words"]), 'plain "" "two words"');+ assert.equal(windowsCommandLine(['say "hi"']), String.raw`"say \"hi\""`);+ assert.equal(windowsCommandLine(["C:\\Program Files\\"]), String.raw`"C:\Program Files\\"`);+ assert.equal(windowsCommandLine([`prefix ${"\\".repeat(2)}"suffix`]), `"prefix ${"\\".repeat(5)}"suffix"`);+});