Merge pull request #922 from heygen-com/fix/css-import-inlining

fix(core): resolve CSS @import and rebase url() paths during bundling
This commit is contained in:
Miguel Ángel
2026-05-17 23:28:36 +02:00
committed by GitHub
108 changed files with 230 additions and 238248 deletions
@@ -725,4 +725,177 @@ describe("bundleToSingleHtml", () => {
expect(bundled).toContain('url("fonts/brand.woff2")');
expect(bundled).not.toContain('url("../fonts/brand.woff2")');
});
it("resolves CSS @import statements when inlining stylesheets", async () => {
const dir = makeTempProject({
"index.html": `<!doctype html>
<html><body>
<link rel="stylesheet" href="styles/canvas.css">
<div data-composition-id="root" data-width="320" data-height="180"></div>
<script>window.__timelines = window.__timelines || {}; window.__timelines.root = {}</script>
</body></html>`,
"styles/canvas.css": `@import url('./tokens.css');\nbody { margin: 0; }`,
"styles/tokens.css": `:root { --brand: #ff5728; }`,
});
const bundled = await bundleToSingleHtml(dir);
expect(bundled).toContain("--brand: #ff5728");
expect(bundled).not.toContain("@import");
expect(bundled).toContain("margin: 0");
});
it("resolves nested CSS @import chains", async () => {
const dir = makeTempProject({
"index.html": `<!doctype html>
<html><body>
<link rel="stylesheet" href="styles/main.css">
<div data-composition-id="root" data-width="320" data-height="180"></div>
<script>window.__timelines = window.__timelines || {}; window.__timelines.root = {}</script>
</body></html>`,
"styles/main.css": `@import url('./base.css');\n.main { color: red; }`,
"styles/base.css": `@import url('../tokens.css');\n.base { display: flex; }`,
"tokens.css": `:root { --tk-teal: #1a3540; }`,
});
const bundled = await bundleToSingleHtml(dir);
expect(bundled).toContain("--tk-teal: #1a3540");
expect(bundled).toContain("display: flex");
expect(bundled).toContain("color: red");
expect(bundled).not.toContain("@import");
});
it("wraps @import with media query in @media block", async () => {
const dir = makeTempProject({
"index.html": `<!doctype html>
<html><body>
<link rel="stylesheet" href="print.css">
<div data-composition-id="root" data-width="320" data-height="180"></div>
<script>window.__timelines = window.__timelines || {}; window.__timelines.root = {}</script>
</body></html>`,
"print.css": `@import url('./print-tokens.css') print;\nbody { font-size: 12pt; }`,
"print-tokens.css": `.print-only { display: block; }`,
});
const bundled = await bundleToSingleHtml(dir);
expect(bundled).toContain("@media print");
expect(bundled).toContain("display: block");
expect(bundled).not.toContain("@import");
});
it("preserves @import for absolute URLs", async () => {
const dir = makeTempProject({
"index.html": `<!doctype html>
<html><body>
<link rel="stylesheet" href="app.css">
<div data-composition-id="root" data-width="320" data-height="180"></div>
<script>window.__timelines = window.__timelines || {}; window.__timelines.root = {}</script>
</body></html>`,
"app.css": `@import url('https://fonts.googleapis.com/css2?family=Inter');\nbody { margin: 0; }`,
});
const bundled = await bundleToSingleHtml(dir);
expect(bundled).toContain("@import url('https://fonts.googleapis.com/css2?family=Inter')");
expect(bundled).toContain("margin: 0");
});
it("rebases url() paths in @import-resolved CSS to project root", async () => {
const dir = makeTempProject({
"index.html": `<!doctype html>
<html><body>
<link rel="stylesheet" href="styles/canvas.css">
<div data-composition-id="root" data-width="320" data-height="180"></div>
<script>window.__timelines = window.__timelines || {}; window.__timelines.root = {}</script>
</body></html>`,
"styles/canvas.css": `@import url('./tokens.css');\nbody { margin: 0; }`,
"styles/tokens.css": `@font-face { src: url('assets/fonts/brand.woff2') format('woff2'); }`,
"styles/assets/fonts/brand.woff2": "fake-font-data",
});
const bundled = await bundleToSingleHtml(dir);
expect(bundled).toContain("url('styles/assets/fonts/brand.woff2')");
expect(bundled).not.toContain("url('assets/fonts/brand.woff2')");
expect(bundled).not.toContain("@import");
});
it("rebases url() paths in <link>-inlined CSS from subdirectories", async () => {
const dir = makeTempProject({
"index.html": `<!doctype html>
<html><body>
<link rel="stylesheet" href="theme/styles.css">
<div data-composition-id="root" data-width="320" data-height="180"></div>
<script>window.__timelines = window.__timelines || {}; window.__timelines.root = {}</script>
</body></html>`,
"theme/styles.css": `.bg { background: url('./images/grain.png'); }`,
"theme/images/grain.png": "fake-image-data",
});
const bundled = await bundleToSingleHtml(dir);
expect(bundled).toContain("url('theme/images/grain.png')");
expect(bundled).not.toContain("url('./images/grain.png')");
});
it("rebases url() paths with ../ traversal in nested @import", async () => {
const dir = makeTempProject({
"index.html": `<!doctype html>
<html><body>
<link rel="stylesheet" href="styles/main.css">
<div data-composition-id="root" data-width="320" data-height="180"></div>
<script>window.__timelines = window.__timelines || {}; window.__timelines.root = {}</script>
</body></html>`,
"styles/main.css": `@import url('./base/reset.css');`,
"styles/base/reset.css": `body { background: url('../../assets/bg.png'); }`,
"assets/bg.png": "fake-image",
});
const bundled = await bundleToSingleHtml(dir);
expect(bundled).toContain("url('assets/bg.png')");
expect(bundled).not.toContain("url('../../assets/bg.png')");
});
it("preserves absolute and data url() references during rebasing", async () => {
const dir = makeTempProject({
"index.html": `<!doctype html>
<html><body>
<link rel="stylesheet" href="styles/app.css">
<div data-composition-id="root" data-width="320" data-height="180"></div>
<script>window.__timelines = window.__timelines || {}; window.__timelines.root = {}</script>
</body></html>`,
"styles/app.css": [
`@font-face { src: url('https://cdn.example.com/font.woff2'); }`,
`.icon { background: url('data:image/svg+xml,<svg/>'); }`,
`.local { background: url('./img/bg.png'); }`,
].join("\n"),
"styles/img/bg.png": "fake",
});
const bundled = await bundleToSingleHtml(dir);
expect(bundled).toContain("url('https://cdn.example.com/font.woff2')");
expect(bundled).toContain("url('data:image/svg+xml,<svg/>')");
expect(bundled).toContain("url('styles/img/bg.png')");
});
it("preserves url() query strings and hash fragments during rebasing", async () => {
const dir = makeTempProject({
"index.html": `<!doctype html>
<html><body>
<link rel="stylesheet" href="styles/icons.css">
<div data-composition-id="root" data-width="320" data-height="180"></div>
<script>window.__timelines = window.__timelines || {}; window.__timelines.root = {}</script>
</body></html>`,
"styles/icons.css": `.icon { background: url('./sprite.png?v=2#section'); }`,
"styles/sprite.png": "fake-sprite",
});
const bundled = await bundleToSingleHtml(dir);
expect(bundled).toContain("url('styles/sprite.png?v=2#section')");
});
});
+57 -3
View File
@@ -1,5 +1,5 @@
import { readFileSync, existsSync } from "fs";
import { join, resolve, isAbsolute, sep } from "path";
import { join, resolve, relative, dirname, isAbsolute, sep } from "path";
import { transformSync } from "esbuild";
import { compileHtml, type MediaDurationProber } from "./htmlCompiler";
import {
@@ -87,6 +87,59 @@ function safeReadFile(filePath: string): string | null {
}
}
const CSS_IMPORT_RE =
/@import\s+(?:url\(\s*(["']?)([^)"']+)\1\s*\)|(["'])([^"']+)\3)\s*([^;]*);\s*/g;
const REBASE_URL_RE = /\burl\(\s*(["']?)([^)"']+)\1\s*\)/g;
function rebaseCssUrls(css: string, cssFileDir: string, projectDir: string): string {
const resolvedRoot = resolve(projectDir);
const resolvedDir = resolve(cssFileDir);
if (resolvedDir === resolvedRoot) return css;
return css.replace(REBASE_URL_RE, (full, quote: string, urlValue: string) => {
if (!urlValue || !isRelativeUrl(urlValue)) return full;
const { basePath, suffix } = splitUrlSuffix(urlValue.trim());
if (!basePath) return full;
const absolutePath = resolve(resolvedDir, basePath);
const rebased = relative(resolvedRoot, absolutePath);
if (rebased === basePath) return full;
return `url(${quote || ""}${rebased}${suffix}${quote || ""})`;
});
}
function inlineCssFile(
css: string,
cssFileDir: string,
projectDir: string,
visited: Set<string> = new Set(),
): string {
const placeholders: string[] = [];
const withPlaceholders = css.replace(
CSS_IMPORT_RE,
(full, _q1, urlPath, _q2, barePath, mediaQuery) => {
const importPath = urlPath ?? barePath;
if (!importPath || !isRelativeUrl(importPath)) return full;
const resolved = resolve(cssFileDir, importPath);
const normalizedBase = resolve(projectDir) + sep;
if (!resolved.startsWith(normalizedBase) || visited.has(resolved)) return full;
const content = safeReadFile(resolved);
if (content == null) return full;
visited.add(resolved);
const inlined = inlineCssFile(content, dirname(resolved), projectDir, visited);
const trimmedMedia = (mediaQuery || "").trim();
const block = trimmedMedia ? `@media ${trimmedMedia} {\n${inlined}\n}\n` : inlined + "\n";
const idx = placeholders.length;
placeholders.push(block);
return `/*__hf_import_${idx}__*/`;
},
);
let rebased = rebaseCssUrls(withPlaceholders, cssFileDir, projectDir);
for (let i = 0; i < placeholders.length; i++) {
rebased = rebased.replace(`/*__hf_import_${i}__*/`, placeholders[i]!);
}
return rebased;
}
function safeReadFileBuffer(filePath: string): Buffer | null {
if (!existsSync(filePath)) return null;
try {
@@ -522,9 +575,10 @@ export async function bundleToSingleHtml(
const href = el.getAttribute("href");
if (!href || !isRelativeUrl(href)) continue;
const cssPath = safePath(projectDir, href);
const css = cssPath ? safeReadFile(cssPath) : null;
if (!cssPath) continue;
const css = safeReadFile(cssPath);
if (css == null) continue;
localCssChunks.push(css);
localCssChunks.push(inlineCssFile(css, dirname(cssPath), projectDir));
if (!cssAnchorPlaced) {
const anchor = document.createElement("style");
anchor.setAttribute("data-hf-bundled-local-css", "1");
-22
View File
@@ -1,22 +0,0 @@
#!/usr/bin/env tsx
/**
* Render Benchmark
*
* Runs each test fixture multiple times and records per-stage timing
* plus peak heap/RSS memory. Results are saved to
* producer/tests/perf/benchmark-results.json.
*
* Usage:
* bun run benchmark # 3 runs per fixture (default)
* bun run benchmark -- --runs 5 # 5 runs per fixture
* bun run benchmark -- --only chat # single fixture
* bun run benchmark -- --exclude-tags slow
* bun run benchmark -- --tags hdr # only fixtures tagged "hdr"
* bun run bench:hdr # convenience: --tags hdr
*
* `--tags` and `--exclude-tags` may be passed together; a fixture must match
* at least one positive tag (when `--tags` is provided) AND must not match
* any excluded tag.
*/
export {};
//# sourceMappingURL=benchmark.d.ts.map
-1
View File
@@ -1 +0,0 @@
{"version":3,"file":"benchmark.d.ts","sourceRoot":"","sources":["../src/benchmark.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;GAkBG"}
-6
View File
@@ -1,6 +0,0 @@
/**
* Re-exported from @hyperframes/engine with ProducerConfig alias.
* @see engine/src/config.ts for implementation.
*/
export { type EngineConfig, type EngineConfig as ProducerConfig, DEFAULT_CONFIG, resolveConfig, } from "@hyperframes/engine";
//# sourceMappingURL=config.d.ts.map
-1
View File
@@ -1 +0,0 @@
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,YAAY,IAAI,cAAc,EACnC,cAAc,EACd,aAAa,GACd,MAAM,qBAAqB,CAAC"}
-22
View File
@@ -1,22 +0,0 @@
{
"version": "0.1.0",
"buildId": "dev",
"sha256": "147830645adb8c8685de33ef21787131394e176a7d711b3d3c0bdd7cac865aeb",
"artifacts": {
"iife": "hyperframe.runtime.iife.js",
"esm": "hyperframe.runtime.mjs"
},
"contract": {
"globals": {
"player": "__player",
"playerReady": "__playerReady",
"renderReady": "__renderReady",
"timelines": "__timelines",
"clipManifest": "__clipManifest"
},
"messageSources": {
"parent": "hf-parent",
"preview": "hf-preview"
}
}
}
File diff suppressed because one or more lines are too long
-18
View File
@@ -1,18 +0,0 @@
/**
* @hyperframes/producer
*
* Generic HTML-to-video rendering engine using Chrome's BeginFrame API.
* Framework-agnostic: works with GSAP, Lottie, Three.js, CSS animations,
* or any web content via configurable page contracts and hooks.
*/
export { createRenderJob, executeRenderJob, RenderCancelledError, type RenderConfig, type RenderJob, type RenderStatus, type RenderPerfSummary, type ProgressCallback, } from "./services/renderOrchestrator.js";
export { createCaptureSession, initializeSession, closeCaptureSession, captureFrame, captureFrameToBuffer, getCompositionDuration, getCapturePerfSummary, prepareCaptureSessionForReuse, type CaptureOptions, type CaptureSession, type CaptureResult, type CapturePerfSummary, type BeforeCaptureHook, } from "./services/frameCapture.js";
export { createFileServer, type FileServerOptions, type FileServerHandle, } from "./services/fileServer.js";
export { createVideoFrameInjector } from "./services/videoFrameInjector.js";
export { resolveConfig, DEFAULT_CONFIG, type ProducerConfig } from "./config.js";
export { type ProducerLogger, type LogLevel, createConsoleLogger, defaultLogger, } from "./logger.js";
export { createRenderHandlers, createProducerApp, startServer, type HandlerOptions, type ServerOptions, type RenderHandlers, } from "./server.js";
export { quantizeTimeToFrame } from "./utils/parityContract.js";
export { resolveRenderPaths, type RenderPaths } from "./utils/paths.js";
export { prepareHyperframeLintBody, runHyperframeLint, type PreparedHyperframeLintInput, } from "./services/hyperframeLint.js";
//# sourceMappingURL=index.d.ts.map
-1
View File
@@ -1 +0,0 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,6BAA6B,EAC7B,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,GACvB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAG5E,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAGjF,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,mBAAmB,EACnB,aAAa,GACd,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,WAAW,EACX,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,cAAc,GACpB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAExE,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EACjB,KAAK,2BAA2B,GACjC,MAAM,8BAA8B,CAAC"}
-117956
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-45
View File
@@ -1,45 +0,0 @@
/**
* Pluggable Producer Logger
*
* Lightweight pluggable logger with zero dependencies.
* Default implementation writes to console with level filtering.
*
* Users can provide their own logger (e.g. Winston, Pino) by
* implementing the ProducerLogger interface.
*/
export type LogLevel = "error" | "warn" | "info" | "debug";
export interface ProducerLogger {
error(message: string, meta?: Record<string, unknown>): void;
warn(message: string, meta?: Record<string, unknown>): void;
info(message: string, meta?: Record<string, unknown>): void;
debug(message: string, meta?: Record<string, unknown>): void;
/**
* Optional fast level check used to skip expensive metadata construction
* at the call site. When the call site needs to build a non-trivial meta
* object (e.g. snapshot a struct, format numbers, run `Array.find` over
* scene state) just to attach to a debug log, gate it with this method:
*
* ```ts
* if (log.isLevelEnabled?.("debug") ?? true) {
* const meta = buildExpensiveMeta();
* log.debug("hot-path event", meta);
* }
* ```
*
* The default coalescence (`?? true`) preserves today's behavior for
* loggers that omit this method — they keep building the meta object as
* before. Custom integrations (Pino, Winston, structured loggers) should
* implement this to enable the optimization.
*/
isLevelEnabled?(level: LogLevel): boolean;
}
/**
* Create a console-based logger with level filtering.
*
* Messages at or below the configured level are printed;
* everything else is silently dropped.
*/
export declare function createConsoleLogger(level?: LogLevel): ProducerLogger;
/** Default logger singleton (level: "info"). */
export declare const defaultLogger: ProducerLogger;
//# sourceMappingURL=logger.d.ts.map
-1
View File
@@ -1 +0,0 @@
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3D,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC7D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC5D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC5D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAE7D;;;;;;;;;;;;;;;;;OAiBG;IACH,cAAc,CAAC,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC3C;AASD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,GAAE,QAAiB,GAAG,cAAc,CAiC5E;AAED,gDAAgD;AAChD,eAAO,MAAM,aAAa,EAAE,cAA4C,CAAC"}
-2
View File
@@ -1,2 +0,0 @@
export {};
//# sourceMappingURL=parity-fixtures.d.ts.map
-1
View File
@@ -1 +0,0 @@
{"version":3,"file":"parity-fixtures.d.ts","sourceRoot":"","sources":["../src/parity-fixtures.ts"],"names":[],"mappings":""}
-2
View File
@@ -1,2 +0,0 @@
export {};
//# sourceMappingURL=parity-harness.d.ts.map
-1
View File
@@ -1 +0,0 @@
{"version":3,"file":"parity-harness.d.ts","sourceRoot":"","sources":["../src/parity-harness.ts"],"names":[],"mappings":""}
-2
View File
@@ -1,2 +0,0 @@
export {};
//# sourceMappingURL=perf-gate.d.ts.map
-1
View File
@@ -1 +0,0 @@
{"version":3,"file":"perf-gate.d.ts","sourceRoot":"","sources":["../src/perf-gate.ts"],"names":[],"mappings":""}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-2
View File
@@ -1,2 +0,0 @@
export {};
//# sourceMappingURL=regression-harness.d.ts.map
-1
View File
@@ -1 +0,0 @@
{"version":3,"file":"regression-harness.d.ts","sourceRoot":"","sources":["../src/regression-harness.ts"],"names":[],"mappings":""}
-2
View File
@@ -1,2 +0,0 @@
export {};
//# sourceMappingURL=runtime-conformance.d.ts.map
-1
View File
@@ -1 +0,0 @@
{"version":3,"file":"runtime-conformance.d.ts","sourceRoot":"","sources":["../src/runtime-conformance.ts"],"names":[],"mappings":""}
-57
View File
@@ -1,57 +0,0 @@
#!/usr/bin/env node
/**
* @hyperframes/producer — Public Server
*
* Clean HTTP API for rendering HTML compositions to video.
*
* Routes:
* POST /render — blocking render, returns JSON
* POST /render/stream — SSE streaming render with progress
* GET /render/queue — current render queue status
* POST /lint — blocking Hyperframe lint
* GET /health — health check
* GET /outputs/:token — download rendered MP4
*/
import { Hono, type Context } from "hono";
import { type ProducerLogger } from "./logger.js";
export interface HandlerOptions {
/** Custom logger. Defaults to console-based defaultLogger. */
logger?: ProducerLogger;
/** Extract or generate a request ID. Defaults to x-request-id header or random UUID. */
getRequestId?: (c: Context) => string;
/** Directory for rendered output files. Defaults to PRODUCER_RENDERS_DIR or /tmp. */
rendersDir?: string;
/** Prefix for output URLs in responses. Default: "/outputs". */
outputUrlPrefix?: string;
/** TTL for output artifact download tokens (ms). Default: 15 minutes. */
artifactTtlMs?: number;
/** Max renders that execute simultaneously. Queued requests wait FIFO. Default: 2. */
maxConcurrentRenders?: number;
}
export interface ServerOptions extends HandlerOptions {
/** Port to listen on. Default: 9847. */
port?: number;
}
export interface RenderHandlers {
render: (c: Context) => Promise<Response>;
renderStream: (c: Context) => Response | Promise<Response>;
lint: (c: Context) => Promise<Response>;
health: (c: Context) => Response;
outputs: (c: Context) => Response;
queue: (c: Context) => Response;
}
/**
* Create route handler functions for the producer server.
*
* These can be mounted on any Hono app at any path prefix.
*/
export declare function createRenderHandlers(options?: HandlerOptions): RenderHandlers;
/**
* Create a Hono app with clean public routes for OSS use.
*/
export declare function createProducerApp(options?: HandlerOptions): Hono;
/**
* Start the producer HTTP server with graceful shutdown.
*/
export declare function startServer(options?: ServerOptions): import("@hono/node-server").ServerType;
//# sourceMappingURL=server.d.ts.map
-1
View File
@@ -1 +0,0 @@
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG;AAeH,OAAO,EAAE,IAAI,EAAE,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AAU1C,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAOjE,MAAM,WAAW,cAAc;IAC7B,8DAA8D;IAC9D,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,wFAAwF;IACxF,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC;IACtC,qFAAqF;IACrF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yEAAyE;IACzE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sFAAsF;IACtF,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,aAAc,SAAQ,cAAc;IACnD,wCAAwC;IACxC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAiLD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC1C,YAAY,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3D,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxC,MAAM,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,QAAQ,CAAC;IACjC,OAAO,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,QAAQ,CAAC;IAClC,KAAK,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,QAAQ,CAAC;CACjC;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,cAAmB,GAAG,cAAc,CA4UjF;AAMD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,cAAmB,GAAG,IAAI,CAYpE;AAMD;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,GAAE,aAAkB,0CA8BtD"}
-39
View File
@@ -1,39 +0,0 @@
/**
* Audio Extractor Service
*
* Extracts audio from media elements in the composition HTML,
* applies timeline positioning, and mixes into a single audio track.
*/
export interface AudioElement {
id: string;
src: string;
start: number;
duration: number;
mediaStart: number;
volume: number;
tagName: "audio" | "video";
}
export interface AudioTrack {
id: string;
srcPath: string;
start: number;
duration: number;
mediaStart: number;
volume: number;
}
/**
* Parse audio/video elements from HTML to find media with audio.
*/
export declare function parseAudioElements(html: string): AudioElement[];
/**
* Process all audio for a composition.
*
* @param htmlPath - Path to the composition HTML (for parsing media elements)
* @param projectDir - Base directory for resolving relative media paths
* @param workDir - Temporary working directory for intermediate files
* @param outputPath - Final mixed audio output path
* @param totalDuration - Total composition duration in seconds
* @returns true if audio was produced, false if no audio elements found
*/
export declare function processAudio(htmlPath: string, projectDir: string, workDir: string, outputPath: string, totalDuration: number): Promise<boolean>;
//# sourceMappingURL=audioExtractor.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"audioExtractor.d.ts","sourceRoot":"","sources":["../../src/services/audioExtractor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,EAAE,CA2C/D;AA6JD;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,OAAO,CAAC,CA6DlB"}
-6
View File
@@ -1,6 +0,0 @@
/**
* Re-exported from @hyperframes/engine.
* @see engine/src/services/audioMixer.ts for implementation.
*/
export { parseAudioElements, processCompositionAudio, type AudioElement, type AudioTrack, type MixResult, } from "@hyperframes/engine";
//# sourceMappingURL=audioMixer.d.ts.map
-1
View File
@@ -1 +0,0 @@
{"version":3,"file":"audioMixer.d.ts","sourceRoot":"","sources":["../../src/services/audioMixer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,SAAS,GACf,MAAM,qBAAqB,CAAC"}
-6
View File
@@ -1,6 +0,0 @@
/**
* Re-exported from @hyperframes/engine.
* @see engine/src/services/browserManager.ts for implementation.
*/
export { acquireBrowser, releaseBrowser, resolveHeadlessShellPath, buildChromeArgs, ENABLE_BROWSER_POOL, type BuildChromeArgsOptions, type CaptureMode, type AcquiredBrowser, } from "@hyperframes/engine";
//# sourceMappingURL=browserManager.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"browserManager.d.ts","sourceRoot":"","sources":["../../src/services/browserManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,cAAc,EACd,cAAc,EACd,wBAAwB,EACxB,eAAe,EACf,mBAAmB,EACnB,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EAChB,KAAK,eAAe,GACrB,MAAM,qBAAqB,CAAC"}
-6
View File
@@ -1,6 +0,0 @@
/**
* Re-exported from @hyperframes/engine.
* @see engine/src/services/chunkEncoder.ts for implementation.
*/
export { encodeFramesFromDir, encodeFramesChunkedConcat, muxVideoWithAudio, applyFaststart, detectGpuEncoder, ENCODER_PRESETS, type EncoderOptions, type EncodeResult, type MuxResult, type GpuEncoder, } from "@hyperframes/engine";
//# sourceMappingURL=chunkEncoder.d.ts.map
-1
View File
@@ -1 +0,0 @@
{"version":3,"file":"chunkEncoder.d.ts","sourceRoot":"","sources":["../../src/services/chunkEncoder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,UAAU,GAChB,MAAM,qBAAqB,CAAC"}
-32
View File
@@ -1,32 +0,0 @@
/**
* Compilation Test Runner
*
* Orchestrates compilation tests: compiles input HTML, compares to golden files.
*/
import { type CompilationValidationResult } from "./compilationTester.js";
export interface CompilationTestResult {
testId: string;
passed: boolean;
validation: CompilationValidationResult;
compilationTimeMs: number;
compiledHtmlPath?: string;
}
interface TestSuite {
id: string;
dir: string;
srcDir: string;
goldenMp4: string;
meta: Record<string, unknown>;
}
/**
* Run compilation test for a test suite.
* Compiles src/index.html and compares against compiled.html golden file.
*/
export declare function runCompilationTest(suite: TestSuite, keepTemp: boolean): Promise<CompilationTestResult>;
/**
* Generate or update compiled.html golden file for a test suite.
* Compiles src/index.html and writes to compiled.html.
*/
export declare function updateCompiledGolden(suite: TestSuite): Promise<void>;
export {};
//# sourceMappingURL=compilationRunner.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"compilationRunner.d.ts","sourceRoot":"","sources":["../../src/services/compilationRunner.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EAAuB,KAAK,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE/F,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,2BAA2B,CAAC;IACxC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,UAAU,SAAS;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,OAAO,GAChB,OAAO,CAAC,qBAAqB,CAAC,CAkEhC;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAoC1E"}
-35
View File
@@ -1,35 +0,0 @@
/**
* Compilation Testing Service
*
* Validates that HTML compilation produces correct timing attributes.
* Compares compiled HTML against golden files using semantic attribute matching.
*/
export interface CompiledElement {
id: string;
tagName: "video" | "audio" | "div";
src?: string;
dataStart: number;
dataEnd: number | null;
dataDuration: number | null;
dataHasAudio?: boolean;
dataMediaStart?: number;
compositionSrc?: string;
}
export interface CompilationValidationResult {
passed: boolean;
actualElements: CompiledElement[];
goldenElements: CompiledElement[];
errors: string[];
warnings: string[];
}
/**
* Parse HTML and extract all elements with timing attributes.
* Includes <video>, <audio>, and <div data-composition-src>.
*/
export declare function extractTimedElements(html: string): CompiledElement[];
/**
* Validate compiled HTML against golden HTML.
* Returns detailed validation result with errors and warnings.
*/
export declare function validateCompilation(actualHtml: string, goldenHtml: string): CompilationValidationResult;
//# sourceMappingURL=compilationTester.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"compilationTester.d.ts","sourceRoot":"","sources":["../../src/services/compilationTester.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;IACnC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,EAAE,eAAe,EAAE,CAAC;IAClC,cAAc,EAAE,eAAe,EAAE,CAAC;IAClC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAUD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,EAAE,CA8EpE;AAyHD;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,2BAA2B,CAkG7B"}
@@ -1,2 +0,0 @@
export declare function injectDeterministicFontFaces(html: string): Promise<string>;
//# sourceMappingURL=deterministicFonts.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"deterministicFonts.d.ts","sourceRoot":"","sources":["../../src/services/deterministicFonts.ts"],"names":[],"mappings":"AA0XA,wBAAsB,4BAA4B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA0ChF"}
-78
View File
@@ -1,78 +0,0 @@
/**
* File Server for Render Mode
*
* Lightweight HTTP server that serves the project directory inside Docker.
* Key responsibility: inject the verified Hyperframe runtime + render mode extension
* into index.html on-the-fly, so Puppeteer can load the composition with
* all relative URLs (compositions, CSS, JS, assets) resolving correctly.
*/
import { injectScriptsAtHeadStart, injectScriptsIntoHtml } from "@hyperframes/core/compiler";
export { injectScriptsAtHeadStart, injectScriptsIntoHtml };
type PathModuleLike = {
resolve: (...segments: string[]) => string;
sep: string;
};
type IsPathInsideOptions = {
resolveSymlinks?: boolean;
/**
* Path module used for resolution and separator comparison. Defaults to
* `node:path` for the running platform. Tests inject `path.win32` /
* `path.posix` to exercise cross-platform behavior on a single OS.
*/
pathModule?: PathModuleLike;
};
/**
* Returns true iff `child` is the same as, or nested inside, `parent` after
* path normalization. Used to reject path-traversal attempts (e.g.
* GET `/../etc/passwd`) before opening any file.
*
* `path.join(root, "..")` normalizes traversal segments and can escape `root`
* entirely, so the join return value alone is not a safe guard. Callers must
* resolve both sides and compare prefixes with the platform separator
* appended to `parent` to avoid `/foo` matching `/foobar`.
*
* Exported for unit tests; not part of the public package surface.
*/
export declare function isPathInside(child: string, parent: string, options?: IsPathInsideOptions): boolean;
declare const VIRTUAL_TIME_SHIM: string;
/**
* Early stub: ensures `window.__hf` exists *before* any user `<script>` in
* `<body>` executes. Without this, libraries that opportunistically write to
* `__hf` during page-script execution (notably `@hyperframes/shader-transitions`,
* which writes the active transition map to `__hf.transitions` inside its
* `init()` call) silently no-op because `__hf` hasn't been created yet — the
* full bridge script is injected at end-of-body and runs *after* user scripts.
*
* Injected at the very start of `<head>` so it runs before all other scripts.
*/
declare const HF_EARLY_STUB = "(function() {\n if (typeof window === \"undefined\") return;\n if (!window.__hf) window.__hf = {};\n})();";
/**
* Bridge script: maps window.__player (Hyperframe runtime) → window.__hf (engine protocol).
* Injected after RENDER_MODE_SCRIPT so the engine's frameCapture can find window.__hf.
*
* This script *patches* the existing __hf object rather than replacing it, so
* fields written during page-script execution (e.g. transitions metadata from
* @hyperframes/shader-transitions) are preserved through to engine query time.
*/
declare const HF_BRIDGE_SCRIPT = "(function() {\n var __realSetInterval =\n window.__HF_VIRTUAL_TIME__ && typeof window.__HF_VIRTUAL_TIME__.originalSetInterval === \"function\"\n ? window.__HF_VIRTUAL_TIME__.originalSetInterval\n : window.setInterval.bind(window);\n var __realClearInterval =\n window.__HF_VIRTUAL_TIME__ && typeof window.__HF_VIRTUAL_TIME__.originalClearInterval === \"function\"\n ? window.__HF_VIRTUAL_TIME__.originalClearInterval\n : window.clearInterval.bind(window);\n function getDeclaredDuration() {\n var root = document.querySelector('[data-composition-id]');\n if (!root) return 0;\n var d = Number(root.getAttribute('data-duration'));\n return Number.isFinite(d) && d > 0 ? d : 0;\n }\n function seekSameOriginChildFrames(frameWindow, nextTimeMs) {\n var frames;\n try {\n frames = frameWindow.frames;\n } catch (_error) {\n return;\n }\n if (!frames || typeof frames.length !== \"number\") return;\n for (var i = 0; i < frames.length; i++) {\n var childWindow = null;\n try {\n childWindow = frames[i];\n if (!childWindow || childWindow === frameWindow) continue;\n if (\n childWindow.__HF_VIRTUAL_TIME__ &&\n typeof childWindow.__HF_VIRTUAL_TIME__.seekToTime === \"function\"\n ) {\n childWindow.__HF_VIRTUAL_TIME__.seekToTime(nextTimeMs);\n }\n } catch (_error) {\n continue;\n }\n seekSameOriginChildFrames(childWindow, nextTimeMs);\n }\n }\n function bridge() {\n var p = window.__player;\n if (!p || typeof p.renderSeek !== \"function\" || typeof p.getDuration !== \"function\") {\n return false;\n }\n var hf = window.__hf || {};\n Object.defineProperty(hf, \"duration\", {\n configurable: true,\n enumerable: true,\n get: function() {\n var d = p.getDuration();\n return d > 0 ? d : getDeclaredDuration();\n },\n });\n hf.seek = function(t) {\n p.renderSeek(t);\n var nextTimeMs = (Math.max(0, Number(t) || 0)) * 1000;\n if (window.__HF_VIRTUAL_TIME__ && typeof window.__HF_VIRTUAL_TIME__.seekToTime === \"function\") {\n window.__HF_VIRTUAL_TIME__.seekToTime(nextTimeMs);\n }\n seekSameOriginChildFrames(window, nextTimeMs);\n };\n window.__hf = hf;\n return true;\n }\n if (bridge()) return;\n var iv = __realSetInterval(function() {\n if (bridge()) __realClearInterval(iv);\n }, 50);\n})();";
export interface FileServerOptions {
projectDir: string;
compiledDir?: string;
port?: number;
/** Scripts injected into <head> of every served HTML file before authored scripts. */
preHeadScripts?: string[];
/** Scripts injected into <head> of index.html. Default: verified Hyperframe runtime. */
headScripts?: string[];
/** Scripts injected before </body> of index.html. Default: render mode extension. */
bodyScripts?: string[];
/** Strip embedded runtime scripts from HTML before injection. Default: true. */
stripEmbeddedRuntime?: boolean;
}
export interface FileServerHandle {
url: string;
port: number;
close: () => void;
}
export declare function createFileServer(options: FileServerOptions): Promise<FileServerHandle>;
export { HF_BRIDGE_SCRIPT, HF_EARLY_STUB, VIRTUAL_TIME_SHIM };
//# sourceMappingURL=fileServer.d.ts.map
-1
View File
@@ -1 +0,0 @@
{"version":3,"file":"fileServer.d.ts","sourceRoot":"","sources":["../../src/services/fileServer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAG7F,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,CAAC;AAE3D,KAAK,cAAc,GAAG;IACpB,OAAO,EAAE,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC;IAC3C,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAmBT;AAyBD,QAAA,MAAM,iBAAiB,QA+FjB,CAAC;AAiIP;;;;;;;;;GASG;AACH,QAAA,MAAM,aAAa,gHAGb,CAAC;AAEP;;;;;;;GAOG;AACH,QAAA,MAAM,gBAAgB,+6EAqEhB,CAAC;AAEP,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sFAAsF;IACtF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,wFAAwF;IACxF,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,qFAAqF;IACrF,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,gFAAgF;IAChF,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAqHtF;AAED,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAC"}
@@ -1,7 +0,0 @@
/**
* AUTO-GENERATED — do not edit manually.
* Generated by: scripts/generate-font-data.ts
* 42 font faces, 718KB raw woff2
*/
export declare const EMBEDDED_FONT_DATA: ReadonlyMap<string, string>;
//# sourceMappingURL=fontData.generated.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"fontData.generated.d.ts","sourceRoot":"","sources":["../../src/services/fontData.generated.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CA2CzD,CAAC"}
-6
View File
@@ -1,6 +0,0 @@
/**
* Re-exported from @hyperframes/engine.
* @see engine/src/services/frameCapture.ts for implementation.
*/
export { createCaptureSession, initializeSession, closeCaptureSession, captureFrame, captureFrameToBuffer, getCompositionDuration, getCapturePerfSummary, prepareCaptureSessionForReuse, type CaptureOptions, type CaptureResult, type CaptureBufferResult, type CapturePerfSummary, type CaptureSession, type BeforeCaptureHook, } from "@hyperframes/engine";
//# sourceMappingURL=frameCapture.d.ts.map
-1
View File
@@ -1 +0,0 @@
{"version":3,"file":"frameCapture.d.ts","sourceRoot":"","sources":["../../src/services/frameCapture.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,6BAA6B,EAC7B,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,qBAAqB,CAAC"}
-76
View File
@@ -1,76 +0,0 @@
/**
* Frame Directory Max-Index Cache
*
* Module-scoped cache of the maximum 1-based frame index present in each
* pre-extracted frame directory (e.g. `frame_0001.png … frame_0150.png` → 150).
* The directory is read once on first access and the max is computed by parsing
* filenames.
*
* Used by the render orchestrator to bounds-check `videoFrameIndex` against
* the directory size before calling `existsSync` per frame, which avoids
* redundant filesystem syscalls when the requested time falls past the last
* extracted frame (e.g. a clip shorter than the composition's effective video
* range).
*
* The cache is module-scoped on purpose: it must be shared across the many
* frame-capture call sites within a single render job. To prevent it from
* growing monotonically across jobs (Chunk 5B), callers MUST invoke
* `clearMaxFrameIndex(frameDir)` for every directory they registered, in their
* cleanup path. The render orchestrator does this in its outer `finally`.
*
* As defense in depth (PR #381 review feedback), the cache also enforces a
* hard MAX_ENTRIES cap with LRU eviction. The orchestrator's `finally`
* remains the primary boundedness mechanism; the LRU cap exists so that a
* future code path which forgets to call `clearMaxFrameIndex` cannot leak
* memory without bound — it self-limits to a working set ~100× larger than a
* single job needs.
*
* Lives in its own module (rather than as a private to renderOrchestrator.ts)
* so the cross-job isolation contract can be unit-tested directly.
*/
/**
* Hard upper bound on cached entries. Sized at ~100× the working set of a
* single render job (which typically registers <10 frame directories, one
* per HDR video source) so that well-behaved callers never trip the cap.
*
* Worst-case resident size: 1000 × (~64-byte path string + ~24-byte map
* entry) ≈ 88 KB. Cheap insurance.
*
* Exported for observability and tests. Production code MUST NOT branch on
* this value to gate behavior — the cap is intentionally invisible to
* callers that follow the clearMaxFrameIndex contract.
*/
export declare const MAX_ENTRIES = 1000;
/**
* Returns the maximum 1-based frame index found in `frameDir`, computed by
* parsing `frame_NNNN.png` filenames. Subsequent calls with the same path
* return the cached value without touching the filesystem. Returns 0 if the
* directory is missing, unreadable, or contains no frame files.
*
* On every access (hit or miss), the entry is bumped to most-recently-used so
* that the LRU-eviction path under cache pressure removes the entry that has
* been idle longest, not whichever one happened to be inserted earliest.
*/
export declare function getMaxFrameIndex(frameDir: string): number;
/**
* Removes the cached max-index for a single directory. Called by the render
* orchestrator in its cleanup path so that subsequent jobs do not inherit
* stale entries (or worse, hold references to torn-down workDir paths).
*
* Returns `true` if an entry was removed, `false` if the path was not cached.
*/
export declare function clearMaxFrameIndex(frameDir: string): boolean;
/**
* Returns the current number of cached entries. Intended for tests and
* diagnostic logging only — production code should not branch on this value.
*/
export declare function getMaxFrameIndexCacheSize(): number;
/**
* Drops every cached entry. Intended exclusively for tests that need to
* reset module state between cases. Production code MUST use
* `clearMaxFrameIndex` for the directories it owns.
*
* @internal
*/
export declare function __resetMaxFrameIndexCacheForTests(): void;
//# sourceMappingURL=frameDirCache.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"frameDirCache.d.ts","sourceRoot":"","sources":["../../src/services/frameDirCache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAQH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,WAAW,OAAO,CAAC;AAEhC;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAgCzD;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAElD;AAED;;;;;;GAMG;AACH,wBAAgB,iCAAiC,IAAI,IAAI,CAExD"}
@@ -1,17 +0,0 @@
import { type HdrTransfer } from "@hyperframes/engine";
export interface HdrImageTransferCache {
getConverted(imageId: string, sourceTransfer: HdrTransfer, targetTransfer: HdrTransfer, source: Buffer): Buffer;
size(): number;
bytesUsed(): number;
}
export interface HdrImageTransferCacheOptions {
/**
* Maximum bytes of converted buffers to retain before evicting the
* least-recently-used entries. Defaults to 200 MB. At 1080p (~12 MB/entry)
* that fits ~16 entries; at 4K (~50 MB/entry) it naturally caps at ~4.
* Set to `0` to disable caching entirely (every call allocates fresh).
*/
maxBytes?: number;
}
export declare function createHdrImageTransferCache(options?: HdrImageTransferCacheOptions): HdrImageTransferCache;
//# sourceMappingURL=hdrImageTransferCache.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"hdrImageTransferCache.d.ts","sourceRoot":"","sources":["../../src/services/hdrImageTransferCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAmB,MAAM,qBAAqB,CAAC;AAExE,MAAM,WAAW,qBAAqB;IACpC,YAAY,CACV,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,WAAW,EAC3B,cAAc,EAAE,WAAW,EAC3B,MAAM,EAAE,MAAM,GACb,MAAM,CAAC;IAEV,IAAI,IAAI,MAAM,CAAC;IAEf,SAAS,IAAI,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,4BAA4B;IAC3C;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAID,wBAAgB,2BAA2B,CACzC,OAAO,GAAE,4BAAiC,GACzC,qBAAqB,CAkEvB"}
-90
View File
@@ -1,90 +0,0 @@
/**
* HTML Compiler for Producer
*
* Two-phase compilation that guarantees every media element has data-end:
* 1. Static pass via core's compileTimingAttrs() (data-start + data-duration → data-end)
* 2. ffprobe resolution for elements without data-duration
*
* Also handles sub-compositions referenced via data-composition-src,
* recursively extracting nested media from sub-sub-compositions.
*/
import { type ResolvedDuration, type UnresolvedElement } from "@hyperframes/core";
import { type VideoElement, type ImageElement, type AudioElement } from "@hyperframes/engine";
import type { Page } from "puppeteer-core";
export interface CompiledComposition {
html: string;
subCompositions: Map<string, string>;
videos: VideoElement[];
audios: AudioElement[];
images: ImageElement[];
unresolvedCompositions: UnresolvedElement[];
/** Assets that resolve outside projectDir. Keys are the path used in HTML, values are absolute filesystem paths. */
externalAssets: Map<string, string>;
width: number;
height: number;
staticDuration: number;
renderModeHints: RenderModeHints;
hasShaderTransitions: boolean;
}
export type RenderModeHintCode = "iframe" | "requestAnimationFrame";
export interface RenderModeHint {
code: RenderModeHintCode;
message: string;
}
export interface RenderModeHints {
recommendScreenshot: boolean;
reasons: RenderModeHint[];
}
export declare function detectRenderModeHints(html: string): RenderModeHints;
export declare function detectShaderTransitionUsage(html: string): boolean;
/**
* Download external CDN scripts and inline them into the HTML so rendering
* works without network access (Docker, CI, restricted environments).
*/
export declare function inlineExternalScripts(html: string): Promise<string>;
/**
* Scan compiled HTML for asset references that resolve outside projectDir.
* For each, map the normalized in-HTML path to the real filesystem path so
* the orchestrator can copy them into the compiled output directory.
*
* Handles: src/href attributes, CSS url(), inline style url().
*/
export declare function collectExternalAssets(html: string, projectDir: string): {
html: string;
externalAssets: Map<string, string>;
};
/**
* Compile an HTML composition project into a single self-contained HTML string
* with all media metadata resolved.
*/
export declare function compileForRender(projectDir: string, htmlPath: string, downloadDir: string): Promise<CompiledComposition>;
/**
* Discover media elements from the browser DOM after JavaScript has run.
* This catches videos/audios whose `src` is set dynamically via JS
* (e.g. `document.getElementById("pip-video").src = URL`), which the
* static regex parsers miss because the HTML has `src=""`.
*/
export interface BrowserMediaElement {
id: string;
tagName: "video" | "audio";
src: string;
start: number;
end: number;
duration: number;
mediaStart: number;
loop: boolean;
hasAudio: boolean;
volume: number;
}
export declare function discoverMediaFromBrowser(page: Page): Promise<BrowserMediaElement[]>;
/**
* Resolve composition durations via Puppeteer by querying window.__timelines.
* The page must already have the interceptor loaded and timelines registered.
*/
export declare function resolveCompositionDurations(page: Page, unresolved: UnresolvedElement[]): Promise<ResolvedDuration[]>;
/**
* Re-compile after composition durations are resolved.
* Injects durations into the HTML and re-parses sub-composition media with proper bounds.
*/
export declare function recompileWithResolutions(compiled: CompiledComposition, resolutions: ResolvedDuration[], projectDir: string, downloadDir: string): Promise<CompiledComposition>;
//# sourceMappingURL=htmlCompiler.d.ts.map
-1
View File
@@ -1 +0,0 @@
{"version":3,"file":"htmlCompiler.d.ts","sourceRoot":"","sources":["../../src/services/htmlCompiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EAML,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAGvB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,YAAY,EAEjB,KAAK,YAAY,EAElB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAG3C,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,sBAAsB,EAAE,iBAAiB,EAAE,CAAC;IAC5C,oHAAoH;IACpH,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,eAAe,CAAC;IACjC,oBAAoB,EAAE,OAAO,CAAC;CAC/B;AAED,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,uBAAuB,CAAC;AAEpE,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,kBAAkB,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,OAAO,EAAE,cAAc,EAAE,CAAC;CAC3B;AA4BD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CA+BnE;AAKD,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAWjE;AAonBD;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAoDzE;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GACjB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CA6EvD;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,mBAAmB,CAAC,CAyH9B;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAgDzF;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,iBAAiB,EAAE,GAC9B,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAiD7B;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,mBAAmB,EAC7B,WAAW,EAAE,gBAAgB,EAAE,EAC/B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,mBAAmB,CAAC,CAsC9B"}
-13
View File
@@ -1,13 +0,0 @@
import { type HyperframeLintResult } from "@hyperframes/core/lint";
export interface PreparedHyperframeLintInput {
entryFile: string;
html: string;
source: "projectDir" | "files" | "html";
}
export declare function prepareHyperframeLintBody(body: Record<string, unknown>): {
prepared: PreparedHyperframeLintInput;
} | {
error: string;
};
export declare function runHyperframeLint(prepared: PreparedHyperframeLintInput): HyperframeLintResult;
//# sourceMappingURL=hyperframeLint.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"hyperframeLint.d.ts","sourceRoot":"","sources":["../../src/services/hyperframeLint.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEvF,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,GAAG,OAAO,GAAG,MAAM,CAAC;CACzC;AAgED,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B;IAAE,QAAQ,EAAE,2BAA2B,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAuC/D;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,2BAA2B,GAAG,oBAAoB,CAE7F"}
@@ -1,11 +0,0 @@
export type ResolvedHyperframeRuntime = {
manifestPath: string;
runtimePath: string;
expectedSha256: string;
actualSha256: string;
runtimeSource: string;
};
export declare function resolveHyperframeManifestPath(): string;
export declare function getVerifiedHyperframeRuntimeSource(): string;
export declare function resolveVerifiedHyperframeRuntime(): ResolvedHyperframeRuntime;
//# sourceMappingURL=hyperframeRuntimeLoader.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"hyperframeRuntimeLoader.d.ts","sourceRoot":"","sources":["../../src/services/hyperframeRuntimeLoader.ts"],"names":[],"mappings":"AA2BA,MAAM,MAAM,yBAAyB,GAAG;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,wBAAgB,6BAA6B,IAAI,MAAM,CAetD;AAED,wBAAgB,kCAAkC,IAAI,MAAM,CAE3D;AAED,wBAAgB,gCAAgC,IAAI,yBAAyB,CAoC5E"}
@@ -1,6 +0,0 @@
/**
* Re-exported from @hyperframes/engine.
* @see engine/src/services/parallelCoordinator.ts for implementation.
*/
export { calculateOptimalWorkers, distributeFrames, executeParallelCapture, mergeWorkerFrames, getSystemResources, type WorkerTask, type WorkerResult, type ParallelProgress, } from "@hyperframes/engine";
//# sourceMappingURL=parallelCoordinator.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"parallelCoordinator.d.ts","sourceRoot":"","sources":["../../src/services/parallelCoordinator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAC"}
-84
View File
@@ -1,84 +0,0 @@
/**
* Shared types and pure helpers used by the staged render pipeline.
*
* Lives in its own module so the stage files in `./stages/` can import the
* helpers they need without reaching back into `renderOrchestrator.ts` —
* the orchestrator imports the stage functions, so a runtime cycle would
* otherwise form (and grow as more stages are extracted).
*
* `renderOrchestrator.ts` re-exports everything declared here for
* backwards compatibility with existing test files and external callers.
*/
import { type CanvasResolution } from "@hyperframes/core";
import type { AudioElement, EngineConfig, ImageElement, VideoElement } from "@hyperframes/engine";
import type { CompiledComposition } from "../htmlCompiler.js";
import { type ProducerLogger } from "../../logger.js";
import type { ProgressCallback, RenderJob, RenderStatus } from "../renderOrchestrator.js";
export interface CompositionMetadata {
duration: number;
videos: VideoElement[];
audios: AudioElement[];
images: ImageElement[];
width: number;
height: number;
}
/**
* Floating-point tolerance for reconciling browser-discovered media timing
* against statically-parsed metadata. Used when the browser reports a
* slightly different `end` / `mediaStart` / `volume` than the compiled
* HTML and we want to ignore sub-millisecond float noise.
*/
export declare const BROWSER_MEDIA_EPSILON = 0.0001;
/**
* Browser-discovered media inside inlined sub-compositions can still report
* scene-local timing from the merged DOM (e.g. start=0, end=85.52) while the
* compiled metadata is already offset into the parent host timeline
* (e.g. start=4.417, end=89.937). Reproject browser end-time into the
* compiled element's time origin before reconciling it back into the render
* metadata.
*/
export declare function projectBrowserEndToCompositionTimeline(existingStart: number, browserStart: number, browserEnd: number): number;
/**
* Translate the user-facing `--resolution` flag into a Chrome
* `deviceScaleFactor`. The composition's intrinsic dimensions stay the
* page-layout viewport; the screenshot lands at output dims via DPR.
*
* The scale must be a positive integer ≥ 1 — fractional DPRs introduce
* visible aliasing and we'd rather fail loudly than produce a blurry
* 4K render. Downsampling (output < composition) is rejected because
* the user is unlikely to have intended it; if the use case appears
* we can plumb a separate flag.
*
* Throws on:
* - HDR + outputResolution (HDR compositor processes raw pixel buffers
* at composition dimensions and would need parallel scaling).
* - Aspect-ratio mismatch (e.g. landscape composition → portrait-4k).
* - Non-integer scale ratio.
* - Downsampling (output dimensions smaller than composition).
*/
export declare function resolveDeviceScaleFactor(input: {
compositionWidth: number;
compositionHeight: number;
outputResolution: CanvasResolution | undefined;
hdrRequested: boolean;
alphaRequested: boolean;
}): number;
/**
* Write compiled HTML and sub-compositions to the work directory.
*
* Exported for integration tests. Not part of the stable public API —
* callers outside this package should use `executeRenderJob` instead.
*/
export declare function writeCompiledArtifacts(compiled: CompiledComposition, workDir: string, includeSummary: boolean): void;
export declare function applyRenderModeHints(cfg: EngineConfig, compiled: CompiledComposition, log?: ProducerLogger): void;
/**
* Mutate the `RenderJob` view of the pipeline's progress and fire the
* caller's `onProgress` callback. Hoisted here (out of `renderOrchestrator.ts`)
* so the stage modules can call it without forming a runtime cycle.
*
* `completedAt` is stamped on the terminal `"failed"` / `"complete"`
* transitions so callers that poll the job state can tell when the
* pipeline finished.
*/
export declare function updateJobStatus(job: RenderJob, status: RenderStatus, stage: string, progress: number, onProgress?: ProgressCallback): void;
//# sourceMappingURL=shared.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/services/render/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAClG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAErE,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE1F,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,SAAS,CAAC;AAE5C;;;;;;;GAOG;AACH,wBAAgB,sCAAsC,CACpD,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,MAAM,CAER;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE;IAC9C,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAC/C,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,EAAE,OAAO,CAAC;CACzB,GAAG,MAAM,CAgDT;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,OAAO,GACtB,IAAI,CAoDN;AAED,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,YAAY,EACjB,QAAQ,EAAE,mBAAmB,EAC7B,GAAG,GAAE,cAA8B,GAClC,IAAI,CAQN;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,gBAAgB,GAC5B,IAAI,CAMN"}
@@ -1,37 +0,0 @@
/**
* assembleStage — Stage 6 of `executeRenderJob`. Final mux + faststart.
*
* Skipped entirely for png-sequence (there's no container to mux; the
* frames were copied directly to `outputPath` by `encodeStage`).
*
* When the composition has audio, runs `muxVideoWithAudio(videoOnlyPath,
* audioOutputPath, outputPath)`. When it doesn't, runs
* `applyFaststart(videoOnlyPath, outputPath)` to move the `moov` atom to
* the front so the file plays from a partial download.
*
* Hard constraints preserved verbatim:
* - The "Assembling final video" `updateJobStatus` payload fires at
* 90% at the start of the stage.
* - "Audio muxing failed: <err>" / "Faststart failed: <err>" throw
* verbatim on the respective `success: false` results.
*/
import type { ProgressCallback, RenderJob } from "../../renderOrchestrator.js";
export interface AssembleStageInput {
job: RenderJob;
/** Encoded video produced by `encodeStage` or `captureStreamingStage`. */
videoOnlyPath: string;
/** Mixed audio path (only read when `hasAudio` is true). */
audioOutputPath: string;
/** Final on-disk output. */
outputPath: string;
hasAudio: boolean;
abortSignal: AbortSignal | undefined;
assertNotAborted: () => void;
onProgress?: ProgressCallback;
}
export interface AssembleStageResult {
/** Wall-clock ms for the assemble phase. */
assembleMs: number;
}
export declare function runAssembleStage(input: AssembleStageInput): Promise<AssembleStageResult>;
//# sourceMappingURL=assembleStage.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"assembleStage.d.ts","sourceRoot":"","sources":["../../../../src/services/render/stages/assembleStage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAG/E,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,SAAS,CAAC;IACf,0EAA0E;IAC1E,aAAa,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,eAAe,EAAE,MAAM,CAAC;IACxB,4BAA4B;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,WAAW,GAAG,SAAS,CAAC;IACrC,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAED,MAAM,WAAW,mBAAmB;IAClC,4CAA4C;IAC5C,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAmC9F"}
@@ -1,39 +0,0 @@
/**
* audioStage — mix the composition's audio tracks into `workDir/audio.aac`.
*
* Trivial wrapper around `processCompositionAudio`. The stage is skipped
* (no ffmpeg invocation) when the composition has no audio elements; the
* timer is still set so the perf summary stays consistent across renders.
*
* Hard constraints preserved verbatim:
* - `audioOutputPath` is always `join(workDir, "audio.aac")`, regardless
* of whether any audio was actually produced.
* - `hasAudio` reflects `audioResult.success` from
* `processCompositionAudio`; it is `false` when there are no audio
* elements (skips the call entirely) and also when the call returns
* `success: false`.
* - `perfStages.audioProcessMs` is set whether or not the call ran.
*/
import type { CompositionMetadata } from "../shared.js";
export interface AudioStageInput {
projectDir: string;
workDir: string;
/** `join(workDir, "compiled")`; passed through to the audio mixer for asset resolution. */
compiledDir: string;
/** Composition duration (post-probe). Must be > 0 — probeStage guarantees this. */
duration: number;
/** Read-only view of `composition.audios`. */
audios: CompositionMetadata["audios"];
abortSignal: AbortSignal | undefined;
assertNotAborted: () => void;
}
export interface AudioStageResult {
/** Always `join(workDir, "audio.aac")`. */
audioOutputPath: string;
/** True iff the audio mix actually produced a file. False when there are no audio elements. */
hasAudio: boolean;
/** Wall-clock ms for the audio mix phase. Zero-elements path is near-zero but always set. */
audioProcessMs: number;
}
export declare function runAudioStage(input: AudioStageInput): Promise<AudioStageResult>;
//# sourceMappingURL=audioStage.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"audioStage.d.ts","sourceRoot":"","sources":["../../../../src/services/render/stages/audioStage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,2FAA2F;IAC3F,WAAW,EAAE,MAAM,CAAC;IACpB,mFAAmF;IACnF,QAAQ,EAAE,MAAM,CAAC;IACjB,8CAA8C;IAC9C,MAAM,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACtC,WAAW,EAAE,WAAW,GAAG,SAAS,CAAC;IACrC,gBAAgB,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,gBAAgB;IAC/B,2CAA2C;IAC3C,eAAe,EAAE,MAAM,CAAC;IACxB,+FAA+F;IAC/F,QAAQ,EAAE,OAAO,CAAC;IAClB,6FAA6F;IAC7F,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA0BrF"}
@@ -1,78 +0,0 @@
/**
* captureHdrStage — Z-ordered HDR / shader-transition layered composite.
*
* The most complex capture path:
* - Spawns a dedicated `domSession` for transparent-background screenshots.
* - Spawns an `hdrEncoder` (`spawnStreamingEncoder` with
* `rawInputFormat: "rgb48le"`) accepting pre-composited HDR frames.
* - Opens raw HDR video frame files (`hdrVideoFrameSources`) and reads
* them per-frame for native-HDR video layers.
* - Decodes 16-bit HDR PNGs once and blits them as image layers.
* - Queries Chrome z-order at layout-change boundaries and groups
* elements into DOM / HDR video / HDR image layers.
* - Composites bottom-to-top in Node memory, writing rgb48le buffers
* to the encoder's stdin.
*
* Cleanup invariants the design doc explicitly flags as risky —
* preserved verbatim from the in-process renderer:
* - `hdrEncoderClosed` / `domSessionClosed` flags gate defensive-close
* paths so they don't run twice when the success path already closed.
* - `hdrVideoFrameSources` is drained + cleared in the outer `finally`
* regardless of how the body exits.
* - `cfg.forceScreenshot = true` is set unconditionally inside the
* layered path because `captureAlphaPng` hangs under
* `--enable-begin-frame-control`.
*
* Known follow-up: same runtime import cycle pattern as the other
* capture stages — the stage imports HDR helpers from
* `renderOrchestrator.ts` (runtime), which imports the stage back.
* Safe at runtime; a future PR will consolidate these helpers.
*/
import { type BeforeCaptureHook, type CaptureOptions, type EngineConfig, type HdrTransfer, getEncoderPreset } from "@hyperframes/engine";
import type { FileServerHandle } from "../../fileServer.js";
import type { ProducerLogger } from "../../../logger.js";
import { type HdrDiagnostics, type HdrPerfCollector, type ProgressCallback, type RenderJob } from "../../renderOrchestrator.js";
import { type CompositionMetadata } from "../shared.js";
export interface CaptureHdrStageInput {
job: RenderJob;
cfg: EngineConfig;
log: ProducerLogger;
projectDir: string;
compiledDir: string;
framesDir: string;
videoOnlyPath: string;
width: number;
height: number;
totalFrames: number;
composition: CompositionMetadata;
hasHdrContent: boolean;
effectiveHdr: {
transfer: HdrTransfer;
} | undefined;
nativeHdrVideoIds: Set<string>;
nativeHdrImageIds: Set<string>;
videoTransfers: Map<string, HdrTransfer>;
imageTransfers: Map<string, HdrTransfer>;
hdrImageSrcPaths: Map<string, string>;
preset: ReturnType<typeof getEncoderPreset>;
effectiveQuality: number;
effectiveBitrate: string | undefined;
fileServer: FileServerHandle;
buildCaptureOptions: () => CaptureOptions;
createRenderVideoFrameInjector: () => BeforeCaptureHook | null;
/** Mutated in place (counters incremented). */
hdrDiagnostics: HdrDiagnostics;
abortSignal: AbortSignal | undefined;
assertNotAborted: () => void;
onProgress?: ProgressCallback;
}
export interface CaptureHdrStageResult {
lastBrowserConsole: string[];
hdrPerf: HdrPerfCollector | undefined;
/** Wall-clock ms for the HDR capture phase. */
captureDurationMs: number;
/** ffmpeg-reported encode duration; overlapped with capture. */
encodeMs: number;
}
export declare function runCaptureHdrStage(input: CaptureHdrStageInput): Promise<CaptureHdrStageResult>;
//# sourceMappingURL=captureHdrStage.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"captureHdrStage.d.ts","sourceRoot":"","sources":["../../../../src/services/render/stages/captureHdrStage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAYH,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,WAAW,EAYhB,gBAAgB,EASjB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAEL,KAAK,cAAc,EAEnB,KAAK,gBAAgB,EAGrB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EASf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAmB,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEzE,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,SAAS,CAAC;IACf,GAAG,EAAE,YAAY,CAAC;IAClB,GAAG,EAAE,cAAc,CAAC;IAEpB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IAEtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IAEpB,WAAW,EAAE,mBAAmB,CAAC;IACjC,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE;QAAE,QAAQ,EAAE,WAAW,CAAA;KAAE,GAAG,SAAS,CAAC;IACpD,iBAAiB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,iBAAiB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACzC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACzC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEtC,MAAM,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;IAC5C,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IAErC,UAAU,EAAE,gBAAgB,CAAC;IAC7B,mBAAmB,EAAE,MAAM,cAAc,CAAC;IAC1C,8BAA8B,EAAE,MAAM,iBAAiB,GAAG,IAAI,CAAC;IAE/D,+CAA+C;IAC/C,cAAc,EAAE,cAAc,CAAC;IAE/B,WAAW,EAAE,WAAW,GAAG,SAAS,CAAC;IACrC,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAED,MAAM,WAAW,qBAAqB;IACpC,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,OAAO,EAAE,gBAAgB,GAAG,SAAS,CAAC;IACtC,+CAA+C;IAC/C,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,qBAAqB,CAAC,CA2wBhC"}
@@ -1,79 +0,0 @@
/**
* captureStage — SDR disk-capture path of `executeRenderJob`.
*
* Handles both branches of the SDR / DOM-only-HDR disk-capture flow:
* - `workerCount > 1`: parallel capture with adaptive retry via
* `executeDiskCaptureWithAdaptiveRetry`.
* - `workerCount === 1`: sequential capture in the orchestrator process,
* reusing `probeSession` when available.
*
* The HDR layered branch (`useLayeredComposite === true`) and the streaming
* encode fusion path (`useStreamingEncode === true` with successful encoder
* spawn) live in separate stages.
*
* Hard constraints preserved verbatim:
* - `probeSession` is closed (and the local binding nulled) once the
* stage no longer needs it. The sequencer's `let probeSession` is
* updated via the returned result.
* - `captureAttempts` is mutated in place — the parallel path appends
* each retry attempt to the array the sequencer owns.
* - `workerCount` may be reduced by an adaptive retry; the returned
* value reflects the final worker count for the perf summary.
* - `lastBrowserConsole` is set to the buffer of whichever session was
* active last (probe session in the parallel close path; sequential
* session in the sequential path).
* - `job.framesRendered` is updated at the same per-frame / per-progress
* points; the same `Capturing frame N/M` `updateJobStatus` payloads
* fire at 30-frame and completion checkpoints (parallel) or every
* frame (sequential).
*
* Known follow-up: this stage imports `executeDiskCaptureWithAdaptiveRetry`
* from `renderOrchestrator.ts`, which itself imports the stage — a runtime
* cycle that resolves at module-init time because no stage function is
* invoked during load. A subsequent PR will consolidate the capture
* helpers (`executeDiskCaptureWithAdaptiveRetry`, `countFrameRanges`,
* `safeCleanup`, `sampleDirectoryBytes`, etc.) into a shared module so
* the stages can import them without reaching back into the orchestrator.
*/
import { type BeforeCaptureHook, type CaptureOptions, type CaptureSession, type EngineConfig } from "@hyperframes/engine";
import type { FileServerHandle } from "../../fileServer.js";
import type { ProducerLogger } from "../../../logger.js";
import { type CaptureAttemptSummary, type ProgressCallback, type RenderJob } from "../../renderOrchestrator.js";
export interface CaptureStageInput {
fileServer: FileServerHandle;
workDir: string;
framesDir: string;
job: RenderJob;
/**
* `job.totalFrames` is `number | undefined` in the public type — the
* sequencer narrows it to a `number` via the probeStage result before
* calling this stage. Passed in explicitly here so the stage doesn't
* have to re-narrow on every reference.
*/
totalFrames: number;
cfg: EngineConfig;
log: ProducerLogger;
/** Initial worker count from `resolveRenderWorkerCount`; adaptive retry may reduce it. */
workerCount: number;
/** Reused for the sequential path's first session if non-null. */
probeSession: CaptureSession | null;
/** True for webm / mov / png-sequence (controls capture format + extension). */
needsAlpha: boolean;
/** Mutated in place — each parallel retry attempt is appended. */
captureAttempts: CaptureAttemptSummary[];
buildCaptureOptions: () => CaptureOptions;
createRenderVideoFrameInjector: () => BeforeCaptureHook | null;
abortSignal: AbortSignal | undefined;
assertNotAborted: () => void;
onProgress?: ProgressCallback;
}
export interface CaptureStageResult {
/** Final worker count after any adaptive retry. */
workerCount: number;
/** Always `null` after the stage — the probe session is closed before the stage returns. */
probeSession: CaptureSession | null;
/** Browser console buffer from whichever session was active last. */
lastBrowserConsole: string[];
}
export declare function runCaptureStage(input: CaptureStageInput): Promise<CaptureStageResult>;
//# sourceMappingURL=captureStage.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"captureStage.d.ts","sourceRoot":"","sources":["../../../../src/services/render/stages/captureStage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,EAMlB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACf,MAAM,6BAA6B,CAAC;AAGrC,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,gBAAgB,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,SAAS,CAAC;IACf;;;;;OAKG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,YAAY,CAAC;IAClB,GAAG,EAAE,cAAc,CAAC;IACpB,0FAA0F;IAC1F,WAAW,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,YAAY,EAAE,cAAc,GAAG,IAAI,CAAC;IACpC,gFAAgF;IAChF,UAAU,EAAE,OAAO,CAAC;IACpB,kEAAkE;IAClE,eAAe,EAAE,qBAAqB,EAAE,CAAC;IACzC,mBAAmB,EAAE,MAAM,cAAc,CAAC;IAC1C,8BAA8B,EAAE,MAAM,iBAAiB,GAAG,IAAI,CAAC;IAC/D,WAAW,EAAE,WAAW,GAAG,SAAS,CAAC;IACrC,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAED,MAAM,WAAW,kBAAkB;IACjC,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,4FAA4F;IAC5F,YAAY,EAAE,cAAc,GAAG,IAAI,CAAC;IACpC,qEAAqE;IACrE,kBAAkB,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED,wBAAsB,eAAe,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAiH3F"}
@@ -1,92 +0,0 @@
/**
* captureStreamingStage — single-machine fused capture + encode path.
*
* Streaming mode pipes captured frame buffers directly into ffmpeg's stdin
* via `spawnStreamingEncoder`, skipping disk writes and the separate
* Stage 5 encode step. In effect, Stage 4 (capture) absorbs Stage 5
* (encode) for renders that fit the single-machine fusion path.
*
* The streaming path is gated by `shouldUseStreamingEncode(...)` upstream:
* - Disabled when output is png-sequence (no encoder).
* - Disabled for parallel renders auto-selected by calibration where the
* ordered streaming writer would stall later workers behind earlier
* ranges (the orchestrator decides this; the stage is told via input).
* - Disabled in distributed mode (which writes chunks to disk).
*
* If `spawnStreamingEncoder` fails for any non-abort reason, the stage
* returns `{ success: false }` and the sequencer falls back to the disk
* capture path. This mirrors the original orchestrator's flag-flip
* (`useStreamingEncode = false`).
*
* Hard constraints preserved verbatim from the in-process renderer:
* - `probeSession` is closed when the parallel path takes over, OR in
* the sequential session's `finally`. Either way the local binding
* is nulled and the result returns the updated value.
* - `lastBrowserConsole` is set to the buffer of whichever session
* was active last (probe close path, or sequential session finally).
* - `job.framesRendered` is updated per-frame; `Streaming frame N/M`
* `updateJobStatus` payloads fire at the same 30-frame and
* completion checkpoints (parallel) or every frame (sequential).
* - Encoder close + result inspection happens inside the stage; a
* `Streaming encode failed: ...` error throws on `success: false`.
* - Defensive cleanup of `streamingEncoder` happens in the stage's
* own `finally` regardless of success/failure, gated on
* `streamingEncoderClosed` so it's idempotent.
*
* Known follow-up (same as captureStage): this stage imports
* `updateJobStatus` from `renderOrchestrator.ts`, forming a runtime
* cycle with the orchestrator's import of `runCaptureStreamingStage`.
* Safe at runtime; a subsequent change will move the capture helpers
* into a shared module so the stages can import without reaching back.
*/
import { type BeforeCaptureHook, type CaptureOptions, type CaptureSession, type EngineConfig, spawnStreamingEncoder } from "@hyperframes/engine";
import type { FileServerHandle } from "../../fileServer.js";
import type { ProducerLogger } from "../../../logger.js";
import type { ProgressCallback, RenderJob } from "../../renderOrchestrator.js";
/**
* Pre-built ffmpeg streaming-encoder options, exactly matching the
* second argument to `spawnStreamingEncoder`. The sequencer constructs
* this from its in-scope preset / dimensions / quality fields and
* passes it through so the stage doesn't have to reach back for the
* preset's internal shape.
*/
export type StreamingEncoderOptions = Parameters<typeof spawnStreamingEncoder>[1];
export interface CaptureStreamingStageInput {
fileServer: FileServerHandle;
workDir: string;
framesDir: string;
videoOnlyPath: string;
job: RenderJob;
/**
* `job.totalFrames` is `number | undefined` in the public type — the
* sequencer narrows it via the probeStage result before calling here.
*/
totalFrames: number;
cfg: EngineConfig;
log: ProducerLogger;
workerCount: number;
probeSession: CaptureSession | null;
/** For the spawn-failure log message context only. */
outputFormat: string;
/** Pre-built encoder options; passed straight to `spawnStreamingEncoder`. */
streamingEncoderOptions: StreamingEncoderOptions;
buildCaptureOptions: () => CaptureOptions;
createRenderVideoFrameInjector: () => BeforeCaptureHook | null;
abortSignal: AbortSignal | undefined;
assertNotAborted: () => void;
onProgress?: ProgressCallback;
}
export type CaptureStreamingStageResult = {
/** Streaming path ran successfully — sequencer should skip the disk path AND Stage 5 encode. */
success: true;
/** Wall-clock ms for the encode phase (overlapped with capture; from the encoder's own report). */
encodeMs: number;
probeSession: CaptureSession | null;
lastBrowserConsole: string[];
workerCount: number;
} | {
/** Spawn failed (non-abort) — sequencer should fall back to the disk path. */
success: false;
};
export declare function runCaptureStreamingStage(input: CaptureStreamingStageInput): Promise<CaptureStreamingStageResult>;
//# sourceMappingURL=captureStreamingStage.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"captureStreamingStage.d.ts","sourceRoot":"","sources":["../../../../src/services/render/stages/captureStreamingStage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,EAUjB,qBAAqB,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAG/E;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC;AAElF,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,gBAAgB,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,SAAS,CAAC;IACf;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,YAAY,CAAC;IAClB,GAAG,EAAE,cAAc,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,cAAc,GAAG,IAAI,CAAC;IACpC,sDAAsD;IACtD,YAAY,EAAE,MAAM,CAAC;IACrB,6EAA6E;IAC7E,uBAAuB,EAAE,uBAAuB,CAAC;IACjD,mBAAmB,EAAE,MAAM,cAAc,CAAC;IAC1C,8BAA8B,EAAE,MAAM,iBAAiB,GAAG,IAAI,CAAC;IAC/D,WAAW,EAAE,WAAW,GAAG,SAAS,CAAC;IACrC,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAED,MAAM,MAAM,2BAA2B,GACnC;IACE,gGAAgG;IAChG,OAAO,EAAE,IAAI,CAAC;IACd,mGAAmG;IACnG,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,cAAc,GAAG,IAAI,CAAC;IACpC,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB,GACD;IACE,8EAA8E;IAC9E,OAAO,EAAE,KAAK,CAAC;CAChB,CAAC;AAEN,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,0BAA0B,GAChC,OAAO,CAAC,2BAA2B,CAAC,CAuLtC"}
@@ -1,55 +0,0 @@
/**
* compileStage — pure compile pass of `executeRenderJob`.
*
* Runs `compileForRender` on the entry HTML, applies render-mode hints
* (which may flip `cfg.forceScreenshot` on for compositions that need it),
* writes compiled artifacts to `workDir/compiled/`, builds the
* `CompositionMetadata` view of the result, and resolves the
* `deviceScaleFactor` for supersampling.
*
* The probe sub-stage (browser launch, duration discovery, recompile,
* media reconciliation) lives in a sibling stage. This stage stops at
* the point where the in-process renderer enters the `if (needsBrowser)`
* branch.
*
* Hard constraints preserved verbatim from the in-process renderer:
* - `applyRenderModeHints(cfg, ...)` is allowed to mutate `cfg.forceScreenshot`.
* - `perfStages.compileOnlyMs` is set to wall-clock ms around the
* `compileForRender` call only.
* - The `log.info("Compiled composition metadata", ...)` line is emitted
* after writing artifacts, with the same payload shape as before.
* - The `log.info("Supersampling composition via deviceScaleFactor", ...)`
* line is emitted only when `deviceScaleFactor > 1`.
*/
import type { EngineConfig } from "@hyperframes/engine";
import type { CompiledComposition } from "../../htmlCompiler.js";
import type { ProducerLogger } from "../../../logger.js";
import { type CompositionMetadata } from "../shared.js";
import type { RenderJob } from "../../renderOrchestrator.js";
export interface CompileStageInput {
projectDir: string;
workDir: string;
/** Absolute path to the entry HTML (already resolved to standalone-entry if needed). */
htmlPath: string;
/** The relative `entryFile` string, used only for log payloads. */
entryFile: string;
job: RenderJob;
/** EngineConfig — may be mutated via `cfg.forceScreenshot = true`. */
cfg: EngineConfig;
/** True when the output format requires an alpha channel (webm/mov/png-sequence). */
needsAlpha: boolean;
log: ProducerLogger;
/** Cooperative-cancellation probe; throws `RenderCancelledError` when aborted. */
assertNotAborted: () => void;
}
export interface CompileStageResult {
compiled: CompiledComposition;
composition: CompositionMetadata;
deviceScaleFactor: number;
outputWidth: number;
outputHeight: number;
/** Wall-clock ms for the pure `compileForRender` call only (excludes artifact writes). */
compileOnlyMs: number;
}
export declare function runCompileStage(input: CompileStageInput): Promise<CompileStageResult>;
//# sourceMappingURL=compileStage.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"compileStage.d.ts","sourceRoot":"","sources":["../../../../src/services/render/stages/compileStage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAIL,KAAK,mBAAmB,EACzB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,wFAAwF;IACxF,QAAQ,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,SAAS,CAAC;IACf,sEAAsE;IACtE,GAAG,EAAE,YAAY,CAAC;IAClB,qFAAqF;IACrF,UAAU,EAAE,OAAO,CAAC;IACpB,GAAG,EAAE,cAAc,CAAC;IACpB,kFAAkF;IAClF,gBAAgB,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,WAAW,EAAE,mBAAmB,CAAC;IACjC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,0FAA0F;IAC1F,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,wBAAsB,eAAe,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAwD3F"}
@@ -1,67 +0,0 @@
/**
* encodeStage — Stage 5 of `executeRenderJob`. Two paths share the stage:
*
* 1. png-sequence: no encoder. Captured PNGs are renamed to
* `frame_NNNNNN.png` and copied to `outputPath`. Audio (if any) is
* written as an `audio.aac` sidecar.
* 2. mp4 / webm / mov: invokes `encodeFramesFromDir` (or the chunked-
* concat variant when `enableChunkedEncode` is on) to produce
* `videoOnlyPath`. The mux + faststart pass lives in `assembleStage`.
*
* Skipped entirely when the streaming-encode fusion path
* (`captureStreamingStage`) already produced `videoOnlyPath` — the
* sequencer gates the call on `!streamingHandled`.
*
* Hard constraints preserved verbatim:
* - The "Writing PNG sequence" / "Encoding video" `updateJobStatus`
* payload fires at 75% from inside the stage.
* - The png-sequence path throws "png-sequence output requested but no
* PNGs were captured to ..." if `framesDir` is empty.
* - The png-sequence audio sidecar is only written when
* `hasAudio && existsSync(audioOutputPath)`.
* - For encoded output, `enableChunkedEncode` selects
* `encodeFramesChunkedConcat` vs `encodeFramesFromDir` — same
* branch + same args.
* - `Encoding failed: <err>` throws on the encoder's
* `success: false`.
*/
import { getEncoderPreset } from "@hyperframes/engine";
import type { ProducerLogger } from "../../../logger.js";
import type { ProgressCallback, RenderJob } from "../../renderOrchestrator.js";
export interface EncodeStageInput {
job: RenderJob;
log: ProducerLogger;
/** Output path: a directory for png-sequence, a file for everything else. */
outputPath: string;
/** Where captured frames live on disk. */
framesDir: string;
/** Encoded video output (ignored on the png-sequence path). */
videoOnlyPath: string;
/** Output dimensions (post-deviceScaleFactor). */
width: number;
height: number;
/** True when the output format requires an alpha channel; selects frame extension. */
needsAlpha: boolean;
/** True iff the composition has audio. Drives the sidecar copy. */
hasAudio: boolean;
/** Path to the mixed audio (only read when `hasAudio` is true). */
audioOutputPath: string;
/** Mp4 vs png-sequence vs … gates the entire stage branch. */
isPngSequence: boolean;
/** Encoder preset (codec, preset, pixelFormat, hdr). Only used on the non-png path. */
preset: ReturnType<typeof getEncoderPreset>;
effectiveQuality: number;
effectiveBitrate: string | undefined;
/** Producer config — enables the chunked-concat encoder when on. */
enableChunkedEncode: boolean;
chunkedEncodeSize: number;
abortSignal: AbortSignal | undefined;
assertNotAborted: () => void;
onProgress?: ProgressCallback;
}
export interface EncodeStageResult {
/** Wall-clock ms for the encode (or png-copy) phase. */
encodeMs: number;
}
export declare function runEncodeStage(input: EncodeStageInput): Promise<EncodeStageResult>;
//# sourceMappingURL=encodeStage.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"encodeStage.d.ts","sourceRoot":"","sources":["../../../../src/services/render/stages/encodeStage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,OAAO,EAGL,gBAAgB,EACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAG/E,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,SAAS,CAAC;IACf,GAAG,EAAE,cAAc,CAAC;IACpB,6EAA6E;IAC7E,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,aAAa,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,sFAAsF;IACtF,UAAU,EAAE,OAAO,CAAC;IACpB,mEAAmE;IACnE,QAAQ,EAAE,OAAO,CAAC;IAClB,mEAAmE;IACnE,eAAe,EAAE,MAAM,CAAC;IACxB,8DAA8D;IAC9D,aAAa,EAAE,OAAO,CAAC;IACvB,uFAAuF;IACvF,MAAM,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;IAC5C,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,oEAAoE;IACpE,mBAAmB,EAAE,OAAO,CAAC;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,WAAW,GAAG,SAAS,CAAC;IACrC,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAED,MAAM,WAAW,iBAAiB;IAChC,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,cAAc,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAyFxF"}
@@ -1,74 +0,0 @@
/**
* extractVideosStage — pre-extract source-video JPEG sequences, plus the
* HDR color-space pre-detection that runs against the originals.
*
* The stage runs the existing video-frame extraction pipeline
* (`extractAllVideoFrames`) but also probes BOTH videos and images for
* native HDR color spaces before extraction (since extraction may convert
* SDR → HDR). The HDR maps are returned so the downstream HDR auto-detect
* block and the HDR composite path can identify which sources are natively
* HDR vs. converted-SDR.
*
* Hard constraints preserved verbatim from the in-process renderer:
* - `composition.audios` is mutated in place to add audio entries
* auto-discovered from video files via ffprobe (preserves the
* "video had audio, no explicit <audio> tag" path).
* - `perfStages.videoExtractMs` is set at the same end-of-stage point.
* - `materializeExtractedFramesForCompiledDir` is still called once
* when `extractionResult.extracted` is non-empty.
* - `force-sdr` mode still skips ALL ffprobe overhead.
*
* New for distributed mode:
* - `materializeSymlinks` (default `false`) — when `true`, the stage
* instructs `materializeExtractedFramesForCompiledDir` to recursively
* copy frames into `compiledDir/__hyperframes_video_frames/<videoId>/`
* instead of creating a single symlink. Required for distributed
* plan() output where the planDir must be self-contained across
* machines (symlinks don't survive S3 / GCS round-trips). Default
* `false` preserves the in-process renderer's symlink behavior.
*/
import { type CaptureVideoMetadataHint, type EngineConfig, type FrameLookupTable, type HdrTransfer, type VideoColorSpace, extractAllVideoFrames } from "@hyperframes/engine";
import { type RenderJob } from "../../renderOrchestrator.js";
import { type CompositionMetadata } from "../shared.js";
export interface ExtractVideosStageInput {
projectDir: string;
/** `join(workDir, "compiled")`; the directory the file server roots at. */
compiledDir: string;
job: RenderJob;
cfg: EngineConfig;
/** Mutated in place — audio entries auto-discovered from video files are pushed onto `composition.audios`. */
composition: CompositionMetadata;
abortSignal: AbortSignal | undefined;
assertNotAborted: () => void;
/**
* Whether to materialize symlinks into real files when staging extracted
* frames inside `compiledDir`. Default `false` preserves the in-process
* renderer's behavior (single symlink per video). Distributed `plan()`
* passes `true` so the planDir is self-contained.
*/
materializeSymlinks?: boolean;
}
export interface ExtractVideosStageResult {
/** Result of `extractAllVideoFrames`, or `null` if the composition has no videos. */
extractionResult: Awaited<ReturnType<typeof extractAllVideoFrames>> | null;
/** Frame-lookup table for the runtime video-frame injector, or `null` if no frames were extracted. */
frameLookup: FrameLookupTable | null;
videoReadinessSkipIds: string[];
videoMetadataHints: CaptureVideoMetadataHint[];
/** Set of video IDs whose ORIGINAL color space was HDR (pre-extraction). */
nativeHdrVideoIds: Set<string>;
/** Per-video original transfer function (BT.2020 PQ/HLG). */
videoTransfers: Map<string, HdrTransfer>;
/** Set of image IDs whose ORIGINAL color space was HDR. */
nativeHdrImageIds: Set<string>;
/** Per-image original transfer function. */
imageTransfers: Map<string, HdrTransfer>;
/** Per-image resolved on-disk source path (used by the HDR composite path). */
hdrImageSrcPaths: Map<string, string>;
/** Per-image probed color space, or `null` for images that couldn't be probed. */
imageColorSpaces: (VideoColorSpace | null)[];
/** Wall-clock ms for the video extraction phase. */
videoExtractMs: number;
}
export declare function runExtractVideosStage(input: ExtractVideosStageInput): Promise<ExtractVideosStageResult>;
//# sourceMappingURL=extractVideosStage.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"extractVideosStage.d.ts","sourceRoot":"","sources":["../../../../src/services/render/stages/extractVideosStage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,eAAe,EAGpB,qBAAqB,EAItB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,2EAA2E;IAC3E,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,SAAS,CAAC;IACf,GAAG,EAAE,YAAY,CAAC;IAClB,8GAA8G;IAC9G,WAAW,EAAE,mBAAmB,CAAC;IACjC,WAAW,EAAE,WAAW,GAAG,SAAS,CAAC;IACrC,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,wBAAwB;IACvC,qFAAqF;IACrF,gBAAgB,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC,GAAG,IAAI,CAAC;IAC3E,sGAAsG;IACtG,WAAW,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACrC,qBAAqB,EAAE,MAAM,EAAE,CAAC;IAChC,kBAAkB,EAAE,wBAAwB,EAAE,CAAC;IAC/C,4EAA4E;IAC5E,iBAAiB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,6DAA6D;IAC7D,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACzC,2DAA2D;IAC3D,iBAAiB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,4CAA4C;IAC5C,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACzC,+EAA+E;IAC/E,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,kFAAkF;IAClF,gBAAgB,EAAE,CAAC,eAAe,GAAG,IAAI,CAAC,EAAE,CAAC;IAC7C,oDAAoD;IACpD,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,uBAAuB,GAC7B,OAAO,CAAC,wBAAwB,CAAC,CAiJnC"}
@@ -1,87 +0,0 @@
/**
* freezePlan — write the meta/{composition,encoder,chunks}.json + plan.json
* manifest at the end of `plan()`, compute the planHash from the frozen
* artifacts, and return the manifest path.
*
* Signature-only skeleton: there are no callers yet. The function body
* lands when `services/distributed/plan.ts` is added and composes the
* stage primitives.
*
* See DISTRIBUTED-RENDERING-PLAN.md §2.1 phase 6, §4.1 directory layout,
* §4.3 LockedRenderConfig.
*/
import type { Fps } from "@hyperframes/core";
import type { PlanDimensions } from "./planHash.js";
/**
* The encoder configuration locked in at plan time. Mirrors §4.3
* LockedRenderConfig in the design doc.
*/
export interface LockedRenderConfig {
captureMode: "beginframe" | "screenshot";
forceScreenshot: boolean;
deviceScaleFactor: number;
useLayeredHdrComposite: boolean;
/** Hard-pinned to "software" in v1 distributed renders. */
browserGpuMode: "software";
warmupTicks: number;
encoder: "libx264-software" | "libx265-software" | "prores-software" | "png-sequence";
ffmpegVersion: string;
preset: string;
crf?: number;
bitrate?: string;
/** Equal to chunkSize for closed-GOP concat-copy. */
gopSize: number;
closedGop: true;
forceKeyframes: "n=0";
pixelFormat: string;
chunkSize: number;
chunkCount: number;
/** Snapshot of `PRODUCER_RUNTIME_*` env vars at plan time. */
runtimeEnv: Record<string, string>;
}
export interface CompositionMetadataJson {
durationSeconds: number;
width: number;
height: number;
fps: Fps;
videoCount: number;
audioCount: number;
imageCount: number;
}
export interface ChunkSliceJson {
index: number;
startFrame: number;
/** Inclusive end frame for the chunk. */
endFrame: number;
}
/**
* Inputs to `freezePlan`. `planDir` already contains `compiled/`,
* `video-frames/`, and (optionally) `audio.aac` by the time freezePlan
* runs — see §2.1 phases 1-5.
*/
export interface FreezePlanInput {
/** Absolute path to the plan directory being frozen. */
planDir: string;
composition: CompositionMetadataJson;
encoder: LockedRenderConfig;
chunks: readonly ChunkSliceJson[];
dimensions: PlanDimensions;
producerVersion: string;
/** Hash of the deterministic-font snapshot baked into the plan. */
fontSnapshotSha: string;
}
export interface FreezePlanResult {
/** Absolute path to `plan.json`. */
planJsonPath: string;
/** Content-addressed planHash; see §4.2. */
planHash: string;
}
/**
* Freeze a plan directory: write `meta/*.json` + top-level `plan.json`, then
* compute `planHash` over the canonicalized contents.
*
* Skeleton — body lands when the distributed-render primitives compose the
* stage functions.
*/
export declare function freezePlan(_input: FreezePlanInput): Promise<FreezePlanResult>;
//# sourceMappingURL=freezePlan.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"freezePlan.d.ts","sourceRoot":"","sources":["../../../../src/services/render/stages/freezePlan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IAEjC,WAAW,EAAE,YAAY,GAAG,YAAY,CAAC;IACzC,eAAe,EAAE,OAAO,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sBAAsB,EAAE,OAAO,CAAC;IAChC,2DAA2D;IAC3D,cAAc,EAAE,UAAU,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IAGpB,OAAO,EAAE,kBAAkB,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,cAAc,CAAC;IACtF,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,cAAc,EAAE,KAAK,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IAGpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IAEnB,8DAA8D;IAC9D,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,uBAAuB;IACtC,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,GAAG,CAAC;IACT,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,uBAAuB,CAAC;IACrC,OAAO,EAAE,kBAAkB,CAAC;IAC5B,MAAM,EAAE,SAAS,cAAc,EAAE,CAAC;IAClC,UAAU,EAAE,cAAc,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,mEAAmE;IACnE,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB;IAC/B,oCAAoC;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAEnF"}
@@ -1,95 +0,0 @@
/**
* planHash — content-addressed hash for distributed render plans.
*
* See DISTRIBUTED-RENDERING-PLAN.md §4.2 for the contract:
*
* planHash = sha256(
* SCHEMA_PREFIX
* ⊕ composition_html_bytes
* ⊕ asset_shas (sorted by relative path)
* ⊕ font_snapshot_sha
* ⊕ encoder_config_canonical_json
* ⊕ producer_version
* ⊕ ffmpeg_version
* ⊕ fps ⊕ width ⊕ height ⊕ format
* )
*
* Two invocations with identical inputs MUST produce the same hash. Adapters
* use this to short-circuit `plan()` on workflow replay and to detect
* cross-version mismatches (§9.3 PLAN_HASH_MISMATCH).
*
* Pure utility; no caller exists yet — the distributed-render
* `services/distributed/plan.ts` will compose it.
*
* ## Encoding contract
*
* Every string-typed component (`fontSnapshotSha`,
* `encoderConfigCanonicalJson`, `producerVersion`, `ffmpegVersion`, asset
* paths and shas, the dimensions tuple) is hashed as UTF-8. External
* verifiers must encode the same way. Binary fields (`compositionHtml`)
* are hashed verbatim.
*/
/**
* SHA-256 hex digest of an asset, paired with its plan-relative path. Sort
* order across an asset list is by `path` (byte-wise ascending) to keep the
* digest deterministic regardless of filesystem walk order.
*/
export interface PlanAssetHash {
/** Plan-relative path. Stable across machines (no absolute paths). */
path: string;
/** Hex-encoded sha256 of the asset bytes. */
sha256: string;
}
/**
* Render dimensions + frame rate that affect the encoded output. Kept as a
* separate type so callers can reuse it for log lines and adapter payloads.
*/
export interface PlanDimensions {
/** Frame rate numerator (e.g. 30 or 30000 for NTSC). */
fpsNum: number;
/** Frame rate denominator (e.g. 1 or 1001 for NTSC). */
fpsDen: number;
width: number;
height: number;
format: "mp4" | "mov" | "png-sequence" | "webm";
}
export interface PlanHashInput {
/** Raw bytes of `compiled/index.html` after recompile. */
compositionHtml: Uint8Array;
/** All non-HTML assets referenced from the composition, in any order. */
assets: readonly PlanAssetHash[];
/** Hash of the deterministic-font snapshot used to render. */
fontSnapshotSha: string;
/** Canonical-JSON serialization of `meta/encoder.json` (LockedRenderConfig). */
encoderConfigCanonicalJson: string;
/** `@hyperframes/producer` package version that produced the plan. */
producerVersion: string;
/** ffmpeg `--version` line (e.g. "ffmpeg version 6.1.1"). */
ffmpegVersion: string;
dimensions: PlanDimensions;
}
/**
* Compute the content-addressed planHash for a frozen plan.
*
* The hash incorporates each component as a separate `update()` call after a
* fixed delimiter byte; that prevents two distinct inputs from accidentally
* sharing a hash if their concatenation happens to collide (e.g. asset count
* vs. asset bytes).
*/
export declare function computePlanHash(input: PlanHashInput): string;
/**
* Canonical-JSON serialization helper. JSON keys are emitted in
* byte-wise-sorted order recursively, with no whitespace. Used to feed the
* encoder config into `computePlanHash` such that semantically-equal configs
* produce equal hashes regardless of source key ordering.
*
* Supports the subset that LockedRenderConfig values use: primitives, plain
* objects, and arrays. Throws on functions, symbols, BigInts, and Maps.
*/
export declare function canonicalJsonStringify(value: unknown): string;
/**
* Convenience helper: sha256 a file path or buffer, return hex digest. Used
* by the eventual `freezePlan` to hash assets on disk.
*/
export declare function sha256Hex(bytes: Uint8Array | string): string;
//# sourceMappingURL=planHash.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"planHash.d.ts","sourceRoot":"","sources":["../../../../src/services/render/stages/planHash.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAmBH;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,wDAAwD;IACxD,MAAM,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,KAAK,GAAG,KAAK,GAAG,cAAc,GAAG,MAAM,CAAC;CACjD;AAED,MAAM,WAAW,aAAa;IAC5B,0DAA0D;IAC1D,eAAe,EAAE,UAAU,CAAC;IAC5B,yEAAyE;IACzE,MAAM,EAAE,SAAS,aAAa,EAAE,CAAC;IACjC,8DAA8D;IAC9D,eAAe,EAAE,MAAM,CAAC;IACxB,gFAAgF;IAChF,0BAA0B,EAAE,MAAM,CAAC;IACnC,sEAAsE;IACtE,eAAe,EAAE,MAAM,CAAC;IACxB,6DAA6D;IAC7D,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,cAAc,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CA+B5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAoB7D;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,CAI5D"}
@@ -1,65 +0,0 @@
/**
* probeStage — browser probe + recompile + media reconciliation.
*
* Runs only when `needsBrowser` is true (root duration unknown OR there are
* unresolved nested compositions). Owns the `FileServerHandle` and the
* `CaptureSession` it creates and returns them so the sequencer can both
* reuse them downstream (the capture stage reuses the probe session) and
* clean them up in its `finally` block.
*
* Hard constraints preserved verbatim from the in-process renderer:
* - `recompileWithResolutions` runs inside this stage because it depends
* on browser-resolved durations, even though §2.1 of the distributed
* plan lists recompile as a sibling phase.
* - `composition` (videos/audios/duration) is mutated in place — callers
* downstream see the reconciled view through the same object reference.
* - The stage computes the final composition `duration` and `totalFrames`
* and returns them. Assigning those values onto the `RenderJob` is the
* sequencer's responsibility — a future chunk worker can't mutate the
* orchestrator's `job` object, and keeping the assignment in one place
* prevents the same value living in two writers.
* - The "Composition duration is 0" diagnostic builds the same hint
* string from the same console-buffer regex and `__timelines` probe.
* - The post-probe "failed network requests" warning fires with the same
* regex, the same first-10/first-5 slicing, and the same `console.warn`
* prefix.
*/
import { type CaptureSession, type EngineConfig } from "@hyperframes/engine";
import type { CompiledComposition } from "../../htmlCompiler.js";
import { type FileServerHandle } from "../../fileServer.js";
import type { ProducerLogger } from "../../../logger.js";
import { type CompositionMetadata } from "../shared.js";
import type { RenderJob } from "../../renderOrchestrator.js";
export interface ProbeStageInput {
projectDir: string;
workDir: string;
job: RenderJob;
cfg: EngineConfig;
log: ProducerLogger;
assertNotAborted: () => void;
/** From compileStage. May be replaced via `recompileWithResolutions`. */
compiled: CompiledComposition;
/** From compileStage. Mutated in place (videos/audios pushed, duration set). */
composition: CompositionMetadata;
width: number;
height: number;
needsAlpha: boolean;
deviceScaleFactor: number;
}
export interface ProbeStageResult {
/** May be reassigned from `recompileWithResolutions`. */
compiled: CompiledComposition;
/** Created when `needsBrowser` was true; `null` otherwise. */
fileServer: FileServerHandle | null;
/** Created when `needsBrowser` was true; `null` otherwise. */
probeSession: CaptureSession | null;
/** The probeSession's `browserConsoleBuffer`, or `[]` if no probe ran. */
lastBrowserConsole: string[];
/** Composition duration (post-probe). Guaranteed > 0 — the stage throws on <= 0. */
duration: number;
totalFrames: number;
/** Wall-clock ms for the entire probe phase (near-zero when `needsBrowser` was false). */
browserProbeMs: number;
}
export declare function runProbeStage(input: ProbeStageInput): Promise<ProbeStageResult>;
//# sourceMappingURL=probeStage.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"probeStage.d.ts","sourceRoot":"","sources":["../../../../src/services/render/stages/probeStage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,YAAY,EAIlB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAMjE,OAAO,EAAoB,KAAK,gBAAgB,EAAqB,MAAM,qBAAqB,CAAC;AACjG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAIL,KAAK,mBAAmB,EACzB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,SAAS,CAAC;IACf,GAAG,EAAE,YAAY,CAAC;IAClB,GAAG,EAAE,cAAc,CAAC;IACpB,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,yEAAyE;IACzE,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,gFAAgF;IAChF,WAAW,EAAE,mBAAmB,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,yDAAyD;IACzD,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,8DAA8D;IAC9D,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACpC,8DAA8D;IAC9D,YAAY,EAAE,cAAc,GAAG,IAAI,CAAC;IACpC,0EAA0E;IAC1E,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,oFAAoF;IACpF,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,0FAA0F;IAC1F,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA0RrF"}
-446
View File
@@ -1,446 +0,0 @@
/**
* Render Orchestrator Service
*
* `executeRenderJob` is the in-process entry point that composes the
* pipeline's six stages. Each stage lives in its own module under
* `./render/stages/` so the pure-function primitives can be reused by
* the distributed render path without dragging the orchestrator's
* cleanup and observability scaffolding with them.
*
* Stage 1 compile → services/render/stages/compileStage.ts
* Stage 1b probe → services/render/stages/probeStage.ts
* (browser-driven duration discovery + media reconciliation;
* grouped with Stage 1 in the perf summary)
* Stage 2 extract videos → services/render/stages/extractVideosStage.ts
* Stage 3 audio → services/render/stages/audioStage.ts
* Stage 4 capture → services/render/stages/captureStage.ts
* services/render/stages/captureStreamingStage.ts
* services/render/stages/captureHdrStage.ts
* Stage 5 encode → services/render/stages/encodeStage.ts
* Stage 6 assemble → services/render/stages/assembleStage.ts
*
* Resources spawned by stages (file server, capture sessions, streaming
* encoders, raw HDR frame files) are tracked in the orchestrator's
* `try/finally` so a stage throwing mid-pipeline doesn't leak Chrome
* processes or ffmpeg subprocesses.
*
* Heavy observability: every stage records timing into `perfStages`,
* errors carry full context, and failures produce a diagnostic summary
* (browser console tail, memory peaks, capture attempts, HDR
* diagnostics).
*/
import { type CanvasResolution, type Fps } from "@hyperframes/core";
import { type EngineConfig, type ExtractedFrames, type ExtractionPhaseBreakdown, type HdrTransfer, type CaptureOptions, type CaptureVideoMetadataHint, type CaptureSession, type BeforeCaptureHook, type ParallelProgress, type WorkerTask, type ElementStackingInfo, type HfTransitionMeta } from "@hyperframes/engine";
import { type CompiledComposition } from "./htmlCompiler.js";
import { type ProducerLogger } from "../logger.js";
import { type HdrImageTransferCache } from "./hdrImageTransferCache.js";
/**
* Metadata for a shader transition between two scenes, extracted from
* `window.__hf.transitions`. Re-exported from the engine so the producer
* shares the contract with composition runtime code.
*/
export type HdrTransitionMeta = HfTransitionMeta;
/** Pre-computed frame range for an active transition. */
export interface TransitionRange extends HdrTransitionMeta {
startFrame: number;
endFrame: number;
}
export type RenderStatus = "queued" | "preprocessing" | "rendering" | "encoding" | "assembling" | "complete" | "failed" | "cancelled";
export interface RenderConfig {
/**
* Frame rate as an exact rational. Integer fps is `{ num: 30, den: 1 }`;
* NTSC is `{ num: 30000, den: 1001 }`. This shape lets the orchestrator
* pass the exact rational through to FFmpeg's `-r` / `-framerate` flags
* without a decimal round-trip — see `fpsToFfmpegArg` in @hyperframes/core.
*
* Use `fpsToNumber(config.fps)` at any site that needs a `number` for
* arithmetic (frame-index → time, telemetry, frame-interval ms). Decimal
* precision at our scales is more than sufficient.
*/
fps: Fps;
quality: "draft" | "standard" | "high";
/**
* Output container format. Defaults to `"mp4"`; existing renders are
* unaffected unless this field is set explicitly.
*
* - `"mp4"`: H.264 by default, or H.265 + HDR10 when HDR auto-detect
* engages or `hdrMode: "force-hdr"` is set. Opaque. The
* default streaming/social deliverable. Faststart is applied so the
* `moov` atom sits at the file start and the file plays from a
* partial download.
* - `"webm"`: VP9 + `yuva420p` pixel format → **true alpha channel**, no
* chroma key. Plays in Chrome, Edge, and Firefox; Safari support for
* alpha-WebM is incomplete. Use this when the output should drop
* straight into a `<video>` over a colored background on the web.
* Audio is muxed as Opus.
* - `"mov"`: ProRes 4444 + `yuva444p10le` → **true alpha channel +
* 10-bit color**. Sized for editor ingest (Premiere, Final Cut Pro,
* DaVinci Resolve), not direct web playback. Audio is muxed as AAC.
* - `"png-sequence"`: a directory of zero-padded RGBA PNGs
* (`frame_000001.png` …). Lossless alpha, largest on disk, no muxed
* audio (an `audio.aac` sidecar is written alongside the PNGs when
* the composition has audio elements). Use for After Effects / Nuke
* / Fusion ingest, or when frames need post-processing before
* encoding. `outputPath` is treated as a directory; it is created if
* it doesn't exist.
*
* Alpha output (`"webm"`, `"mov"`, `"png-sequence"`) automatically
* forces screenshot capture (Chrome's BeginFrame compositor does not
* preserve alpha on Linux headless-shell) and disables HDR — HDR +
* alpha is not a supported combination, a warning is logged and HDR
* falls back to SDR. The transparent-background CSS is injected by
* the engine's `initTransparentBackground` helper, so authors should
* not paint a fullscreen `body` / `#root` background in their
* compositions when targeting alpha output.
*/
format?: "mp4" | "webm" | "mov" | "png-sequence";
workers?: number;
useGpu?: boolean;
debug?: boolean;
/** Entry HTML file relative to projectDir. Defaults to "index.html". */
entryFile?: string;
/** Full producer config. When provided, env vars are not read. */
producerConfig?: EngineConfig;
/** Custom logger. Defaults to console-based defaultLogger. */
logger?: ProducerLogger;
/** Override CRF for the video encoder. Mutually exclusive with `videoBitrate`. */
crf?: number;
/** Target video bitrate (e.g. "10M"). Mutually exclusive with `crf`. */
videoBitrate?: string;
/** HDR rendering mode.
* - `auto` (default): probe sources; enable HDR if any HDR content is found.
* - `force-hdr`: enable HDR even on SDR-only compositions (falls back to HLG transfer).
* - `force-sdr`: skip probing entirely; always render SDR.
*/
hdrMode?: "auto" | "force-hdr" | "force-sdr";
/**
* Render-time variable overrides for the composition. Injected as
* `window.__hfVariables` before any page script runs and consumed by the
* runtime helper `getVariables()`, which merges them over the declared
* defaults from `<html data-composition-variables="...">`.
*
* Populated by the CLI from `--variables '<json>'` /
* `--variables-file <path>`. Must be a JSON-serializable plain object.
*/
variables?: Record<string, unknown>;
/**
* Override the output resolution via Chrome `deviceScaleFactor` (DPR).
* The composition's authored dimensions are unchanged. See
* {@link resolveDeviceScaleFactor} for the integer-scale, aspect, and
* HDR constraints.
*/
outputResolution?: CanvasResolution;
}
export interface RenderPerfSummary {
renderId: string;
totalElapsedMs: number;
fps: number;
quality: string;
workers: number;
chunkedEncode: boolean;
chunkSizeFrames: number | null;
compositionDurationSeconds: number;
totalFrames: number;
resolution: {
width: number;
height: number;
};
videoCount: number;
audioCount: number;
stages: Record<string, number>;
/** Per-phase breakdown of the Phase 2 video extraction (resolve, HDR probe, HDR preflight, VFR probe/preflight, per-video extract). Undefined when the composition has no videos. */
videoExtractBreakdown?: ExtractionPhaseBreakdown;
/** Bytes on disk in the render's workDir at assembly time (sampled before cleanup). Lets callers correlate peak temp usage with render duration. */
tmpPeakBytes?: number;
captureAvgMs?: number;
capturePeakMs?: number;
captureCalibration?: {
sampledFrames: number[];
p95Ms?: number;
multiplier: number;
reasons: string[];
};
captureAttempts?: CaptureAttemptSummary[];
/**
* Peak resident set size (RSS) observed during the render, in MiB.
*
* Sampled every 250ms by a process-wide poller; surfaces gross memory
* regressions (e.g. unbounded image-cache growth) that wall-clock numbers
* miss. Optional because callers can serialize older `RenderPerfSummary`
* shapes back into this type.
*/
peakRssMb?: number;
/**
* Peak V8 heap used observed during the render, in MiB.
*
* Useful as a finer-grained complement to {@link peakRssMb} — RSS includes
* native ffmpeg/Chrome allocations, while heapUsed isolates JS-object growth
* inside the orchestrator. Optional for the same back-compat reason.
*/
peakHeapUsedMb?: number;
hdrDiagnostics?: HdrDiagnostics;
hdrPerf?: HdrPerfSummary;
}
export interface HdrDiagnostics {
videoExtractionFailures: number;
imageDecodeFailures: number;
}
export interface HdrPerfSummary {
frames: number;
normalFrames: number;
transitionFrames: number;
domLayerCaptures: number;
hdrVideoLayerBlits: number;
hdrImageLayerBlits: number;
timings: Record<string, number>;
avgMs: Record<string, number>;
}
export type HdrPerfTimingKey = "frameSeekMs" | "frameInjectMs" | "stackingQueryMs" | "canvasClearMs" | "normalCompositeMs" | "transitionCompositeMs" | "encoderWriteMs" | "hdrVideoReadDecodeMs" | "hdrVideoTransferMs" | "hdrVideoBlitMs" | "hdrImageTransferMs" | "hdrImageBlitMs" | "domLayerSeekMs" | "domLayerInjectMs" | "domMaskApplyMs" | "domScreenshotMs" | "domMaskRemoveMs" | "domPngDecodeMs" | "domBlitMs";
export interface HdrPerfCollector {
frames: number;
normalFrames: number;
transitionFrames: number;
domLayerCaptures: number;
hdrVideoLayerBlits: number;
hdrImageLayerBlits: number;
timings: Record<HdrPerfTimingKey, number>;
}
export declare function createHdrPerfCollector(): HdrPerfCollector;
export declare function addHdrTiming(perf: HdrPerfCollector | undefined, key: HdrPerfTimingKey, startMs: number): void;
export interface CaptureCostEstimate {
multiplier: number;
reasons: string[];
p95Ms?: number;
}
export interface CaptureCalibrationSample {
frameIndex: number;
captureTimeMs: number;
}
export interface FrameRange {
startFrame: number;
endFrame: number;
}
export interface CaptureAttemptSummary {
attempt: number;
workers: number;
frameCount: number;
reason: "initial" | "retry";
}
export interface RenderJob {
id: string;
config: RenderConfig;
status: RenderStatus;
progress: number;
currentStage: string;
createdAt: Date;
startedAt?: Date;
completedAt?: Date;
error?: string;
outputPath?: string;
duration?: number;
totalFrames?: number;
framesRendered?: number;
perfSummary?: RenderPerfSummary;
failedStage?: string;
errorDetails?: {
message: string;
stack?: string;
elapsedMs: number;
freeMemoryMB: number;
browserConsoleTail?: string[];
perfStages?: Record<string, number>;
hdrDiagnostics?: HdrDiagnostics;
};
}
export type ProgressCallback = (job: RenderJob, message: string) => void;
export declare class RenderCancelledError extends Error {
reason: "user_cancelled" | "timeout" | "aborted";
constructor(message?: string, reason?: "user_cancelled" | "timeout" | "aborted");
}
export declare function createCompiledFrameSrcResolver(compiledDir: string): (framePath: string) => string | null;
type MaterializedExtractedFrames = Pick<ExtractedFrames, "videoId" | "outputDir" | "framePaths">;
type MaterializePathModule = {
resolve: (...segments: string[]) => string;
join: (...segments: string[]) => string;
dirname: (path: string) => string;
basename: (path: string) => string;
relative: (from: string, to: string) => string;
isAbsolute: (path: string) => boolean;
};
type MaterializeFileSystem = {
existsSync: (path: string) => boolean;
mkdirSync: (path: string, options: {
recursive: true;
}) => unknown;
symlinkSync: (target: string, path: string) => unknown;
cpSync: (src: string, dest: string, options: {
recursive: true;
}) => unknown;
};
type MaterializeExtractedFramesOptions = {
pathModule?: MaterializePathModule;
fileSystem?: MaterializeFileSystem;
/**
* When `true`, recursively copy frames into `compiledDir` as real files
* instead of creating a single symlink per video. Required for
* distributed plan() output where the planDir must be self-contained
* across machines (symlinks don't survive S3 / GCS round-trips).
* Default `false` preserves the in-process renderer's symlink behavior.
*/
materializeSymlinks?: boolean;
};
export declare function materializeExtractedFramesForCompiledDir(extracted: MaterializedExtractedFrames[], compiledDir: string, options?: MaterializeExtractedFramesOptions): void;
export declare function collectVideoReadinessSkipIds(nativeHdrVideoIds: ReadonlySet<string>, extractedVideos: readonly ExtractedVideoReadinessInput[]): string[];
interface ExtractedVideoReadinessInput {
videoId: string;
metadata: {
width: number;
height: number;
};
}
export declare function collectVideoMetadataHints(extractedVideos: readonly ExtractedVideoReadinessInput[]): CaptureVideoMetadataHint[];
export declare function resolveRenderWorkerCount(totalFrames: number, requestedWorkers: number | undefined, cfg: EngineConfig, compiled: Pick<CompiledComposition, "hasShaderTransitions" | "renderModeHints">, log?: ProducerLogger, measuredCaptureCost?: CaptureCostEstimate): number;
export declare function estimateCaptureCostMultiplier(compiled: Pick<CompiledComposition, "hasShaderTransitions" | "renderModeHints">): CaptureCostEstimate;
export declare function createCaptureCalibrationConfig(cfg: EngineConfig): EngineConfig;
export declare function estimateMeasuredCaptureCostMultiplier(samples: CaptureCalibrationSample[]): CaptureCostEstimate;
export declare function selectCaptureCalibrationFrames(totalFrames: number): number[];
export declare function findMissingFrameRanges(totalFrames: number, framesDir: string, frameExt: "jpg" | "png"): FrameRange[];
export declare function buildMissingFrameRetryBatches(ranges: FrameRange[], maxWorkers: number, workDir: string, attempt: number): WorkerTask[][];
export declare function getNextRetryWorkerCount(currentWorkers: number): number;
export declare function isRecoverableParallelCaptureError(error: unknown): boolean;
export declare function shouldFallbackToScreenshotAfterCalibrationError(error: unknown): boolean;
export declare function executeDiskCaptureWithAdaptiveRetry(options: {
serverUrl: string;
workDir: string;
framesDir: string;
totalFrames: number;
initialWorkerCount: number;
allowRetry: boolean;
frameExt: "jpg" | "png";
captureOptions: CaptureOptions;
createBeforeCaptureHook: () => BeforeCaptureHook | null;
abortSignal?: AbortSignal;
onProgress?: (progress: ParallelProgress) => void;
cfg: EngineConfig;
log: ProducerLogger;
}): Promise<CaptureAttemptSummary[]>;
/**
* Blit a single HDR video layer onto an rgb48le canvas.
*
* Shared between the normal-frame compositing path (compositeToBuffer)
* and the transition dual-scene compositing loop to avoid duplicating
* the frame lookup, raw read, transfer, transform, and blit logic.
*/
export interface HdrVideoFrameSource {
dir: string;
rawPath: string;
fd: number;
width: number;
height: number;
frameSize: number;
frameCount: number;
scratch: Buffer;
}
export declare function closeHdrVideoFrameSource(source: HdrVideoFrameSource, log?: ProducerLogger): void;
export declare function blitHdrVideoLayer(canvas: Buffer, el: ElementStackingInfo, time: number, fps: number, hdrVideoFrameSources: Map<string, HdrVideoFrameSource>, hdrStartTimes: Map<string, number>, width: number, height: number, log?: ProducerLogger, sourceTransfer?: HdrTransfer, targetTransfer?: HdrTransfer, hdrPerf?: HdrPerfCollector): void;
/**
* Pre-decoded HDR image buffer with its native pixel dimensions.
*
* Static images decode exactly once at setup time and are blitted on every
* visible frame, unlike video frames which are read fresh per timestamp.
*/
export interface HdrImageBuffer {
data: Buffer;
width: number;
height: number;
}
/**
* Blit a single HDR image layer onto an rgb48le canvas.
*
* Image-equivalent of `blitHdrVideoLayer` — the buffer is pre-decoded and
* static, so there's no time-based frame lookup or per-frame PNG read.
*/
export declare function blitHdrImageLayer(canvas: Buffer, el: ElementStackingInfo, hdrImageBuffers: Map<string, HdrImageBuffer>, hdrImageTransferCache: HdrImageTransferCache, width: number, height: number, log?: ProducerLogger, sourceTransfer?: HdrTransfer, targetTransfer?: HdrTransfer, hdrPerf?: HdrPerfCollector): void;
/**
* Dependencies passed to `compositeHdrFrame`.
*
* Every field except the per-frame arguments is captured once when the HDR
* render path opens its `try { ... }` block and reused across every frame —
* extracting them into an explicit struct lets the helper live at module
* scope (no closure-over-renderJob) and keeps the per-call signature small.
*/
type CompositeTransfer = HdrTransfer | "srgb";
export declare function shouldUseLayeredComposite(options: {
hasHdrContent: boolean;
hasShaderTransitions: boolean;
isPngSequence: boolean;
}): boolean;
export declare function resolveCompositeTransfer(hasHdrContent: boolean, effectiveHdr: {
transfer: HdrTransfer;
} | undefined): CompositeTransfer;
export interface HdrCompositeContext {
log: ProducerLogger;
domSession: CaptureSession;
beforeCaptureHook: BeforeCaptureHook | null;
width: number;
height: number;
fps: number;
compositeTransfer: CompositeTransfer;
nativeHdrImageIds: Set<string>;
hdrImageBuffers: Map<string, HdrImageBuffer>;
hdrImageTransferCache: HdrImageTransferCache;
hdrVideoFrameSources: Map<string, HdrVideoFrameSource>;
hdrVideoStartTimes: Map<string, number>;
imageTransfers: Map<string, HdrTransfer>;
videoTransfers: Map<string, HdrTransfer>;
debugDumpEnabled: boolean;
debugDumpDir: string | null;
hdrPerf?: HdrPerfCollector;
}
/**
* Composite a single HDR frame into a pre-allocated `rgb48le` canvas.
*
* Bottom-to-top z-order: HDR layers are blitted directly from cached image
* buffers / extracted video frames; DOM layers are screenshotted with a
* mass-hide mask (so each layer paints only its own elements) and then
* blended into the canvas via `blitRgba8OverRgb48le` in the active HDR
* transfer space.
*
* The `elementFilter` parameter exists so the transition path can composite
* each scene independently; pass `undefined` for whole-stack rendering.
*
* @param ctx - Long-lived dependencies (logger, browser session, dimensions,
* HDR layer maps). Captured once per render — see
* {@link HdrCompositeContext}.
* @param canvas - Pre-allocated `width * height * 6` byte buffer. Caller must
* zero-fill before every frame (this helper does not).
* @param time - Seek time in seconds.
* @param fullStacking - Stacking info for ALL elements at this time. Even when
* filtering, every other element id is needed to build
* the DOM-layer hide-list.
* @param elementFilter - When set, only elements whose id is in the set are
* composited.
* @param debugFrameIndex - Frame index used to label per-layer diagnostic
* dumps. Pass `-1` to disable per-layer dumps even
* when `KEEP_TEMP=1` (e.g. for warmup frames).
*/
export declare function compositeHdrFrame(ctx: HdrCompositeContext, canvas: Buffer, time: number, fullStacking: ElementStackingInfo[], elementFilter?: Set<string>, debugFrameIndex?: number): Promise<void>;
export declare function createRenderJob(config: RenderConfig): RenderJob;
export declare function shouldUseStreamingEncode(cfg: Pick<EngineConfig, "enableStreamingEncode" | "streamingEncodeMaxDurationSeconds">, outputFormat: NonNullable<RenderConfig["format"]>, workerCount: number, durationSeconds: number): boolean;
/**
* Main render pipeline
*/
export declare function extractStandaloneEntryFromIndex(indexHtml: string, entryFile: string): string | null;
/**
* Render a `RenderJob` end-to-end: compile → probe → extract videos →
* audio → capture → encode → assemble. The function body is a thin
* sequencer over the eight stage modules in `./render/stages/`; the
* orchestrator owns shared resources (work dir, file server, probe
* session, browser console buffer, perf counters, peak-memory sampler)
* and the `try/finally` cleanup. Returns once the final output exists at
* `outputPath`; throws on cancellation, encoder failure, or a stage
* error (with a diagnostic summary written to `perf-summary.json`).
*/
export declare function executeRenderJob(job: RenderJob, projectDir: string, outputPath: string, onProgress?: ProgressCallback, abortSignal?: AbortSignal): Promise<void>;
export {};
//# sourceMappingURL=renderOrchestrator.d.ts.map
File diff suppressed because one or more lines are too long
@@ -1,6 +0,0 @@
/**
* Re-exported from @hyperframes/engine.
* @see engine/src/services/screenshotService.ts for implementation.
*/
export { beginFrameCapture, pageScreenshotCapture, getCdpSession, injectVideoFramesBatch, syncVideoFrameVisibility, cdpSessionCache, type BeginFrameResult, } from "@hyperframes/engine";
//# sourceMappingURL=screenshotService.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"screenshotService.d.ts","sourceRoot":"","sources":["../../src/services/screenshotService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,aAAa,EACb,sBAAsB,EACtB,wBAAwB,EACxB,eAAe,EACf,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAC"}
-6
View File
@@ -1,6 +0,0 @@
/**
* Re-exported from @hyperframes/engine.
* @see engine/src/services/streamingEncoder.ts for implementation.
*/
export { spawnStreamingEncoder, createFrameReorderBuffer, type StreamingEncoder, type StreamingEncoderOptions, type StreamingEncoderResult, type FrameReorderBuffer, } from "@hyperframes/engine";
//# sourceMappingURL=streamingEncoder.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"streamingEncoder.d.ts","sourceRoot":"","sources":["../../src/services/streamingEncoder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,GACxB,MAAM,qBAAqB,CAAC"}
@@ -1,6 +0,0 @@
/**
* Re-exported from @hyperframes/engine.
* @see engine/src/services/videoFrameExtractor.ts for implementation.
*/
export { parseVideoElements, extractVideoFramesRange, extractAllVideoFrames, getFrameAtTime, createFrameLookupTable, FrameLookupTable, type VideoElement, type ExtractedFrames, type ExtractionOptions, type ExtractionResult, type ExtractionPhaseBreakdown, } from "@hyperframes/engine";
//# sourceMappingURL=videoFrameExtractor.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"videoFrameExtractor.d.ts","sourceRoot":"","sources":["../../src/services/videoFrameExtractor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,GAC9B,MAAM,qBAAqB,CAAC"}
@@ -1,6 +0,0 @@
/**
* Re-exported from @hyperframes/engine.
* @see engine/src/services/videoFrameInjector.ts for implementation.
*/
export { createVideoFrameInjector } from "@hyperframes/engine";
//# sourceMappingURL=videoFrameInjector.d.ts.map
@@ -1 +0,0 @@
{"version":3,"file":"videoFrameInjector.d.ts","sourceRoot":"","sources":["../../src/services/videoFrameInjector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC"}
-19
View File
@@ -1,19 +0,0 @@
/**
* Transparency Regression Test
*
* Exercises the alpha-output pipelines (webm + png-sequence) end-to-end
* against `tests/transparency-regression/`. Asserts that:
*
* 1. Pixels that were transparent in the browser stay transparent in the
* output (alpha = 0).
* 2. Pixels covered by the opaque red `.card` element stay fully opaque
* (alpha = 255) and keep their red color.
*
* This is intentionally NOT wired into `regression-harness.ts` — the harness
* compares each fixture against a golden MP4, but transparency requires a
* different validation strategy (pixel inspection of the alpha channel). Run
* this script via `bun run --filter @hyperframes/producer test:transparency`
* or directly via `tsx src/transparency-test.ts` from this package.
*/
export {};
//# sourceMappingURL=transparency-test.d.ts.map
-1
View File
@@ -1 +0,0 @@
{"version":3,"file":"transparency-test.d.ts","sourceRoot":"","sources":["../src/transparency-test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG"}
-6
View File
@@ -1,6 +0,0 @@
export declare function buildRmsEnvelope(samples: Int16Array, windowSize?: number, hopSize?: number): number[];
export declare function compareAudioEnvelopes(rendered: number[], snapshot: number[], maxLagWindows: number): {
correlation: number;
lagWindows: number;
};
//# sourceMappingURL=audioRegression.d.ts.map
-1
View File
@@ -1 +0,0 @@
{"version":3,"file":"audioRegression.d.ts","sourceRoot":"","sources":["../../src/utils/audioRegression.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,SAAO,EAAE,OAAO,SAAO,GAAG,MAAM,EAAE,CAYjG;AAoDD,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAAE,EAClB,QAAQ,EAAE,MAAM,EAAE,EAClB,aAAa,EAAE,MAAM,GACpB;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAU7C"}
-6
View File
@@ -1,6 +0,0 @@
/**
* Re-exported from @hyperframes/engine.
* @see engine/src/utils/ffprobe.ts for implementation.
*/
export { extractMediaMetadata, extractVideoMetadata, extractAudioMetadata, type VideoMetadata, type AudioMetadata, } from "@hyperframes/engine";
//# sourceMappingURL=ffprobe.d.ts.map
-1
View File
@@ -1 +0,0 @@
{"version":3,"file":"ffprobe.d.ts","sourceRoot":"","sources":["../../src/utils/ffprobe.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,qBAAqB,CAAC"}

Some files were not shown because too many files have changed in this diff Show More