mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-02 11:47:13 +00:00
* fix(cli): a Chrome that fails to start says how it ended, and a slow start says so A failed launch only reported "Protocol error (Target.setDiscoverTargets): Target closed". It now runs the browser once more on its own with the same flags and reports its exit code (Windows codes named: missing runtime, out of memory, security software), its last stderr lines, or that it stayed up. The CLI and the engine's render launch both use it. A start slower than 5 s prints "Chrome is still starting...", and a --timeout that looks like seconds says it is milliseconds. * chore(cli): cut the Chrome launch diagnosis comments to the comment limit * fix(cli): the Chrome startup check runs Chrome as puppeteer does and can be cancelled The check started the browser with only the caller's flags, so a full Chrome ran headful and was blamed for a missing X server. It now uses puppeteer's default arguments (headless included). The check is stopped when the CLI is stopped, and the GPU probe, whose failure falls back to software anyway, skips it. * fix(cli): a Chrome launch error is never replaced by a failure to explain it The startup diagnosis asks puppeteer for its default arguments before re-running Chrome. If that call fails, its error used to replace the launch error the caller needed. The launch error is now reported as it was. The core package size budget rises to cover the new chromeStartup module (about 4.7 KB unpacked). * refactor(engine): the Chrome startup diagnosis lives in the engine, not core Both callers launch Chrome through the engine (the CLI already imports it), so the engine owns the diagnosis. Core's package size budget is back to its old value.
115 lines
4.0 KiB
TypeScript
115 lines
4.0 KiB
TypeScript
import { defineConfig } from "tsup";
|
|
import { resolve } from "node:path";
|
|
import { readFileSync } from "node:fs";
|
|
import { sourceAliases } from "../../scripts/package-subpaths.mjs";
|
|
|
|
const pkg = JSON.parse(readFileSync(new URL("./package.json", import.meta.url), "utf-8")) as {
|
|
version: string;
|
|
};
|
|
const producerPkg = JSON.parse(
|
|
readFileSync(new URL("../producer/package.json", import.meta.url), "utf-8"),
|
|
) as { version: string };
|
|
|
|
export default defineConfig({
|
|
entry: {
|
|
cli: "src/cli.ts",
|
|
fontLocalizeCli: "src/fontLocalizeCli.ts",
|
|
runtimeVersion: "src/runtimeVersion.ts",
|
|
hangReport: "src/hangReport.ts",
|
|
warmCheck: "src/warmCheck.ts",
|
|
warmCheckClient: "src/warmCheckClient.ts",
|
|
renderSetupWorker: "src/renderSetupWorker.ts",
|
|
backgroundChecksWorker: "src/backgroundChecksWorker.ts",
|
|
sherpaWorker: "src/whisper/sherpaWorker.ts",
|
|
shaderTransitionWorker: "../producer/src/services/shaderTransitionWorker.ts",
|
|
api: "src/api.ts",
|
|
},
|
|
format: ["esm"],
|
|
outDir: "dist",
|
|
target: "node22",
|
|
platform: "node",
|
|
bundle: true,
|
|
splitting: true,
|
|
sourcemap: false,
|
|
// Types for the `./api` export only; the other entries are programs, not libraries.
|
|
dts: { entry: { api: "src/api.ts" } },
|
|
clean: true,
|
|
banner: {
|
|
js: `import { createRequire as __hf_createRequire } from "node:module";
|
|
import { fileURLToPath as __hf_fileURLToPath } from "node:url";
|
|
import { dirname as __hf_dirname } from "node:path";
|
|
var require = __hf_createRequire(import.meta.url);
|
|
var __filename = __hf_fileURLToPath(import.meta.url);
|
|
var __dirname = __hf_dirname(__filename);`,
|
|
},
|
|
external: [
|
|
"puppeteer-core",
|
|
"puppeteer",
|
|
"@puppeteer/browsers",
|
|
// Native module — its platform binary (@img/sharp-<os>-<arch>) must be
|
|
// resolved from node_modules at runtime, never bundled. Loaded lazily by
|
|
// the capture pipeline; runtime resolution comes from the `dependencies`
|
|
// entry in package.json.
|
|
"sharp",
|
|
"open",
|
|
"hono",
|
|
"hono/*",
|
|
"@hono/node-server",
|
|
"adm-zip",
|
|
"esbuild",
|
|
"giget",
|
|
"postcss",
|
|
// aws-lambda transitively pulls @aws-sdk/* + @smithy/* which include
|
|
// .browser.js conditional exports esbuild can't bundle cleanly into
|
|
// a node binary. Keep it external; the lambda subverb files dynamic-
|
|
// import it only when the user runs `hyperframes lambda *`, so the
|
|
// CLI's cold start doesn't load it. Runtime resolution comes from
|
|
// @hyperframes/aws-lambda being a `dependencies` entry in package.json.
|
|
"@hyperframes/aws-lambda",
|
|
"@hyperframes/aws-lambda/sdk",
|
|
// Same treatment for the GCP adapter: the cloudrun subverb files
|
|
// dynamic-import `@hyperframes/gcp-cloud-run/sdk` only when the user runs
|
|
// `hyperframes cloudrun *`. Keep it external; runtime resolution comes
|
|
// from the `dependencies`/workspace entry, not the bundled CLI.
|
|
"@hyperframes/gcp-cloud-run",
|
|
"@hyperframes/gcp-cloud-run/sdk",
|
|
"@hyperframes/gcp-cloud-run/terraform",
|
|
],
|
|
noExternal: [
|
|
"@hyperframes/core",
|
|
"@hyperframes/parsers",
|
|
"@hyperframes/studio-server",
|
|
"@hyperframes/lint",
|
|
"@hyperframes/producer",
|
|
"@hyperframes/engine",
|
|
"@hyperframes/inspector",
|
|
"@clack/prompts",
|
|
"@clack/core",
|
|
"picocolors",
|
|
"linkedom",
|
|
"sisteransi",
|
|
"is-unicode-supported",
|
|
"citty",
|
|
],
|
|
define: {
|
|
__CLI_VERSION__: JSON.stringify(pkg.version),
|
|
__PRODUCER_VERSION__: JSON.stringify(producerPkg.version),
|
|
},
|
|
esbuildOptions(options) {
|
|
options.alias = {
|
|
// Exact subpaths are generated from the same contracts as package
|
|
// exports, avoiding esbuild's root-alias prefix substitution trap.
|
|
...sourceAliases(resolve(__dirname, "../producer"), [".", "./distributed"]),
|
|
...sourceAliases(resolve(__dirname, "../engine"), [
|
|
".",
|
|
"./chrome-host-ceiling",
|
|
"./chrome-startup",
|
|
"./shader-transitions",
|
|
"./system-memory",
|
|
"./wsl-host",
|
|
]),
|
|
};
|
|
options.loader = { ...options.loader, ".browser.js": "text" };
|
|
},
|
|
});
|