mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 23:03:09 +00:00
refactor: dedupe resolution presets and clean up 4k stack
This commit is contained in:
@@ -3,6 +3,9 @@ import { streamSSE } from "hono/streaming";
|
||||
import { existsSync, readFileSync, mkdirSync, unlinkSync, readdirSync, statSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import type { StudioApiAdapter, RenderJobState } from "../types.js";
|
||||
import { VALID_CANVAS_RESOLUTIONS, type CanvasResolution } from "../../core.types.js";
|
||||
|
||||
const VALID_RESOLUTIONS = new Set<string>(VALID_CANVAS_RESOLUTIONS);
|
||||
|
||||
export function registerRenderRoutes(api: Hono, adapter: StudioApiAdapter): void {
|
||||
// Scoped job store — not shared across createStudioApi() calls
|
||||
@@ -59,9 +62,8 @@ export function registerRenderRoutes(api: Hono, adapter: StudioApiAdapter): void
|
||||
const quality = ["draft", "standard", "high"].includes(body.quality ?? "")
|
||||
? (body.quality as string)
|
||||
: "standard";
|
||||
const VALID_RESOLUTIONS = new Set(["landscape", "portrait", "landscape-4k", "portrait-4k"]);
|
||||
const outputResolution = VALID_RESOLUTIONS.has(body.resolution ?? "")
|
||||
? (body.resolution as "landscape" | "portrait" | "landscape-4k" | "portrait-4k")
|
||||
? (body.resolution as CanvasResolution)
|
||||
: undefined;
|
||||
|
||||
const now = new Date();
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { CanvasResolution } from "../core.types.js";
|
||||
|
||||
/** Resolved info about a single project. */
|
||||
export interface ResolvedProject {
|
||||
id: string;
|
||||
@@ -65,12 +67,10 @@ export interface StudioApiAdapter {
|
||||
quality: string;
|
||||
jobId: string;
|
||||
/**
|
||||
* Optional output resolution preset (e.g. "landscape-4k"). When set, the
|
||||
* producer supersamples the composition via Chrome `deviceScaleFactor`.
|
||||
* The composition's authored dimensions are unchanged. See the
|
||||
* `resolveDeviceScaleFactor` constraints in the producer.
|
||||
* Optional output resolution preset. See `resolveDeviceScaleFactor` in
|
||||
* the producer for the integer-scale + aspect + HDR constraints.
|
||||
*/
|
||||
outputResolution?: "landscape" | "portrait" | "landscape-4k" | "portrait-4k";
|
||||
outputResolution?: CanvasResolution;
|
||||
}): RenderJobState;
|
||||
|
||||
/** Optional: generate a JPEG thumbnail via Puppeteer or similar. */
|
||||
|
||||
Reference in New Issue
Block a user