mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-07 01:56:04 +00:00
* refactor: split useTimelinePlayer.ts and hyperframes-player.ts into focused modules (<500 LOC each) * fix(ci): scope 500 LOC check to packages/studio, add allowlist for grandfathered files * feat(cli): Linux ARM64 support — auto-install Chromium on DGX Spark / GB10 / Jetson Chrome Headless Shell has no Linux ARM64 binary. On arm64 Linux: - Detects the platform automatically - Tries to auto-install system Chromium via apt-get (works on Ubuntu/Debian ARM) - Falls back to clear manual instructions with exact commands - 'hyperframes browser ensure' guides through the setup interactively - After setup, all render commands work without any flags * fix(ci): disable Windows Defender real-time monitoring to prevent EPERM builds Path exclusions are insufficient — Defender re-scans new files created during bun install before the exclusion takes effect. Disable real-time monitoring for the entire job duration instead (standard CI practice). * refactor(studio): split all files >500 LOC + extract useToast, delete allowlist All 11 large files split into focused modules under 500 LOC. App.tsx extracted toast logic into useToast hook (493 LOC now). .filesize-allowlist deleted — no longer needed. * fix: remove unused imports from split files, extract useToast from App.tsx App.tsx: 504 → 493 lines (toast logic extracted to useToast hook) timelineDOM.ts: remove unused imports from re-export pattern MotionPanel.tsx: remove unused clampStudioCustomEasePoints import studioMotionOps.ts: remove unused StudioGsapMotionDirection import * fix(ci): use Set-MpPreference to fully disable Windows Defender (both jobs) * fix(producer): use node --experimental-strip-types instead of tsx for build:fonts Eliminates the tsx binary dependency that Windows Defender locks during bun install, causing EPERM errors. Node 22.6+ strips TypeScript types natively with no external binary. * chore: remove .filesize-allowlist — App.tsx is now 493 lines (<500) * fix(ci): disable Windows Defender before checkout to prevent all EPERM races * fix(producer): skip build:fonts if fontData.generated.ts already exists The generated file is tracked in git, so CI doesn't need to regenerate it. This avoids @fontsource/inter node_modules access on Windows which triggers EPERM from Defender scanning during bun install.
177 lines
5.7 KiB
TypeScript
177 lines
5.7 KiB
TypeScript
import { defineCommand } from "citty";
|
|
import type { Example } from "./_examples.js";
|
|
import * as clack from "@clack/prompts";
|
|
import { c } from "../ui/colors.js";
|
|
|
|
export const examples: Example[] = [
|
|
["Find or download Chrome for rendering", "hyperframes browser ensure"],
|
|
["Print the Chrome executable path", "hyperframes browser path"],
|
|
["Remove cached Chrome download", "hyperframes browser clear"],
|
|
];
|
|
import { formatBytes } from "../ui/format.js";
|
|
import {
|
|
ensureBrowser,
|
|
findBrowser,
|
|
clearBrowser,
|
|
CHROME_VERSION,
|
|
CACHE_DIR,
|
|
isLinuxArm,
|
|
} from "../browser/manager.js";
|
|
import { trackBrowserInstall } from "../telemetry/events.js";
|
|
|
|
async function runEnsure(): Promise<void> {
|
|
clack.intro(c.bold("hyperframes browser ensure"));
|
|
|
|
// ARM64 Linux: Chrome headless shell is not available.
|
|
// Try to find system Chromium first, then attempt auto-install via apt.
|
|
if (isLinuxArm()) {
|
|
const s = clack.spinner();
|
|
s.start("Linux ARM64 detected — looking for system Chromium...");
|
|
const existing = await findBrowser();
|
|
if (existing) {
|
|
s.stop(c.success("System Chromium found"));
|
|
console.log();
|
|
console.log(` ${c.dim("Source:")} ${c.bold(existing.source)}`);
|
|
console.log(` ${c.dim("Path:")} ${c.bold(existing.executablePath)}`);
|
|
console.log();
|
|
clack.outro(c.success("Ready to render."));
|
|
return;
|
|
}
|
|
|
|
s.stop(c.warn("No Chromium found — attempting auto-install via apt-get..."));
|
|
console.log();
|
|
|
|
// Delegate to ensureBrowser which handles the full ARM64 install flow.
|
|
try {
|
|
const result = await ensureBrowser();
|
|
console.log();
|
|
console.log(` ${c.dim("Source:")} ${c.bold(result.source)}`);
|
|
console.log(` ${c.dim("Path:")} ${c.bold(result.executablePath)}`);
|
|
console.log();
|
|
clack.outro(c.success("Chromium ready. You can now render on ARM64."));
|
|
} catch (err) {
|
|
clack.log.error(err instanceof Error ? err.message : String(err));
|
|
clack.outro(c.warn("Manual setup required (see instructions above)."));
|
|
}
|
|
return;
|
|
}
|
|
|
|
const s = clack.spinner();
|
|
s.start("Looking for an existing browser...");
|
|
|
|
const existing = await findBrowser();
|
|
if (existing) {
|
|
s.stop(c.success("Browser found"));
|
|
console.log();
|
|
console.log(` ${c.dim("Source:")} ${c.bold(existing.source)}`);
|
|
console.log(` ${c.dim("Path:")} ${c.bold(existing.executablePath)}`);
|
|
console.log();
|
|
clack.outro(c.success("Ready to render."));
|
|
return;
|
|
}
|
|
|
|
s.stop("No browser found — downloading");
|
|
|
|
const downloadSpinner = clack.spinner();
|
|
downloadSpinner.start(`Downloading Chrome Headless Shell ${c.dim("v" + CHROME_VERSION)}...`);
|
|
|
|
let lastPct = -1;
|
|
const result = await ensureBrowser({
|
|
onProgress: (downloaded, total) => {
|
|
if (total <= 0) return;
|
|
const pct = Math.floor((downloaded / total) * 100);
|
|
if (pct > lastPct) {
|
|
lastPct = pct;
|
|
downloadSpinner.message(
|
|
`Downloading Chrome Headless Shell ${c.dim("v" + CHROME_VERSION)} — ${c.progress(pct + "%")} ${c.dim("(" + formatBytes(downloaded) + " / " + formatBytes(total) + ")")}`,
|
|
);
|
|
}
|
|
},
|
|
});
|
|
|
|
downloadSpinner.stop(c.success("Download complete"));
|
|
trackBrowserInstall();
|
|
|
|
console.log();
|
|
console.log(` ${c.dim("Source:")} ${c.bold(result.source)}`);
|
|
console.log(` ${c.dim("Path:")} ${c.bold(result.executablePath)}`);
|
|
console.log();
|
|
|
|
clack.outro(c.success("Ready to render."));
|
|
}
|
|
|
|
async function runPath(): Promise<void> {
|
|
const result = await findBrowser();
|
|
if (!result) {
|
|
// Try a full ensure (which includes download) but write only the path
|
|
try {
|
|
const ensured = await ensureBrowser();
|
|
process.stdout.write(ensured.executablePath + "\n");
|
|
} catch (err: unknown) {
|
|
console.error(err instanceof Error ? err.message : "Failed to find browser");
|
|
process.exit(1);
|
|
}
|
|
return;
|
|
}
|
|
process.stdout.write(result.executablePath + "\n");
|
|
}
|
|
|
|
function runClear(): void {
|
|
clack.intro(c.bold("hyperframes browser clear"));
|
|
|
|
const removed = clearBrowser();
|
|
if (removed) {
|
|
clack.outro(c.success("Removed cached browser from ") + c.dim(CACHE_DIR));
|
|
} else {
|
|
clack.outro(c.dim("No cached browser to remove."));
|
|
}
|
|
}
|
|
|
|
export default defineCommand({
|
|
meta: { name: "browser", description: "Manage the Chrome browser used for rendering" },
|
|
args: {
|
|
subcommand: {
|
|
type: "positional",
|
|
description:
|
|
"ensure = find or download Chrome, path = print executable path, clear = remove cached download",
|
|
required: false,
|
|
},
|
|
},
|
|
async run({ args }) {
|
|
const subcommand = args.subcommand;
|
|
|
|
if (!subcommand || subcommand === "") {
|
|
console.log(`
|
|
${c.bold("hyperframes browser")} ${c.dim("<subcommand>")}
|
|
|
|
Manage the Chrome browser used for rendering.
|
|
|
|
${c.bold("SUBCOMMANDS:")}
|
|
${c.accent("ensure")} ${c.dim("Find or download Chrome for rendering")}
|
|
${c.accent("path")} ${c.dim("Print browser executable path (for scripting)")}
|
|
${c.accent("clear")} ${c.dim("Remove cached Chrome download")}
|
|
|
|
${c.bold("EXAMPLES:")}
|
|
${c.accent("npx hyperframes browser ensure")} ${c.dim("Download Chrome if needed")}
|
|
${c.accent("npx hyperframes browser path")} ${c.dim("Print path for scripts")}
|
|
${c.accent("npx hyperframes browser clear")} ${c.dim("Remove cached browser")}
|
|
`);
|
|
return;
|
|
}
|
|
|
|
switch (subcommand) {
|
|
case "ensure":
|
|
return runEnsure();
|
|
case "path":
|
|
return runPath();
|
|
case "clear":
|
|
return runClear();
|
|
default:
|
|
console.error(
|
|
`${c.error("Unknown subcommand:")} ${subcommand}\n\nRun ${c.accent("hyperframes browser --help")} for usage.`,
|
|
);
|
|
process.exit(1);
|
|
}
|
|
},
|
|
});
|