mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-19 11:26:02 +00:00
- build-zip --source=chrome-headless-shell stages only the repo's pinned build (managedChromeVersion) and only when its folder matches the pinned digest (isPinnedHeadlessShell), instead of the newest folder in the cache. The folder cannot fit a ZIP function, so lambda deploy refuses --chrome-source chrome-headless-shell up front on either arch, and the docs say the arm64 video image is where the shell runs. - build-zip prints the headroom under the unzipped gate, and a new "Lambda handler ZIP" workflow builds the ZIP on PRs that touch the code it bundles, so growth fails before merge rather than in the release job. - The arm64 image keeps @sparticuz/chromium's fonts and fonts.conf from the handler ZIP (FONTCONFIG_PATH=/var/task/fonts) instead of liberation-fonts, so text falls back to the same fonts as on x86. The image workflow renders a mixed-script page on both arches and fails when any line resolves to different platform fonts. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
46 lines
1.7 KiB
TypeScript
46 lines
1.7 KiB
TypeScript
import { cpSync, existsSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
import {
|
|
isPinnedHeadlessShell,
|
|
managedChromeVersion,
|
|
} from "@hyperframes/engine/chrome-host-ceiling";
|
|
import { BUNDLED_SHELL_DIR } from "../src/chromium.js";
|
|
|
|
/**
|
|
* Stage the repo's pinned linux64 chrome-headless-shell from the Puppeteer cache under `home` into
|
|
* `<stagingDir>/<BUNDLED_SHELL_DIR>/`. The whole folder: the executable alone exits at launch
|
|
* ("Invalid file descriptor to ICU data received") without icudtl.dat and its .pak files.
|
|
* Only the pinned build, and only when its folder matches the pinned digest. Returns the version.
|
|
*/
|
|
export function stageChromeHeadlessShell(
|
|
stagingDir: string,
|
|
home = process.env.HOME ?? "/root",
|
|
isPinned: (executable: string) => boolean = isPinnedHeadlessShell,
|
|
): string {
|
|
const version = managedChromeVersion("linux");
|
|
const cache = join(home, ".cache", "puppeteer");
|
|
const folder = join(
|
|
cache,
|
|
"chrome-headless-shell",
|
|
`linux-${version}`,
|
|
"chrome-headless-shell-linux64",
|
|
);
|
|
const executable = join(folder, "chrome-headless-shell");
|
|
if (!existsSync(executable)) {
|
|
throw new Error(
|
|
`[build-zip] chrome-headless-shell ${version} is not in ${cache}. Run\n` +
|
|
` npx --yes @puppeteer/browsers install chrome-headless-shell@${version} --path ${cache}\n` +
|
|
`before --source=chrome-headless-shell.`,
|
|
);
|
|
}
|
|
if (!isPinned(executable)) {
|
|
throw new Error(
|
|
`[build-zip] ${folder} does not match the pinned chrome-headless-shell ${version} digest. ` +
|
|
`Delete it and install it again.`,
|
|
);
|
|
}
|
|
// cpSync keeps each file's mode, so the executable stays executable.
|
|
cpSync(folder, join(stagingDir, BUNDLED_SHELL_DIR), { recursive: true });
|
|
return version;
|
|
}
|