|
| 1 | +/** |
| 2 | + * `@hyperframes/producer/distributed` — the distributed render primitives. |
| 3 | + * |
| 4 | + * See `DISTRIBUTED-RENDERING-PLAN.md` for the full architecture. The three |
| 5 | + * activities (`plan` → `renderChunk` × N → `assemble`) are pure functions |
| 6 | + * over local file paths; networking + orchestration live in adapters. |
| 7 | + * |
| 8 | + * Adopters (AWS Lambda, Cloud Run Jobs, Temporal, K8s Jobs, plain SSH): |
| 9 | + * |
| 10 | + * ```ts |
| 11 | + * import { |
| 12 | + * plan, |
| 13 | + * renderChunk, |
| 14 | + * assemble, |
| 15 | + * } from "@hyperframes/producer/distributed"; |
| 16 | + * |
| 17 | + * // Controller-side: produce a self-contained planDir + content-addressed planHash. |
| 18 | + * const planResult = await plan(projectDir, config, planDir); |
| 19 | + * |
| 20 | + * // Worker-side: render one chunk. Byte-identical retries on the same |
| 21 | + * // (planDir, chunkIndex) — Temporal / Step Functions retry policies are |
| 22 | + * // safe to point at this. |
| 23 | + * const chunk = await renderChunk(planDir, chunkIndex, outputChunkPath); |
| 24 | + * |
| 25 | + * // Controller-side: stitch chunks into the final deliverable. |
| 26 | + * await assemble(planDir, chunkPaths, audioPath, outputPath); |
| 27 | + * ``` |
| 28 | + * |
| 29 | + * No networking, no AWS SDK, no Temporal SDK — those live in adapter |
| 30 | + * packages. This module is library code only. |
| 31 | + */ |
| 32 | + |
| 33 | +// ── Plan (Activity A) ─────────────────────────────────────────────────────── |
| 34 | +export { |
| 35 | + // Functions |
| 36 | + buildChunkSlices, |
| 37 | + measurePlanDirBytes, |
| 38 | + plan, |
| 39 | + rejectUnsupportedDistributedFormat, |
| 40 | + resolveChunkPlan, |
| 41 | + // Types |
| 42 | + type DistributedRenderConfig, |
| 43 | + type PlanResult, |
| 44 | + // Constants |
| 45 | + DEFAULT_CHUNK_SIZE, |
| 46 | + DEFAULT_MAX_PARALLEL_CHUNKS, |
| 47 | + PLAN_DIR_SIZE_LIMIT_BYTES, |
| 48 | + // Error codes + classes |
| 49 | + FORMAT_NOT_SUPPORTED_IN_DISTRIBUTED, |
| 50 | + FormatNotSupportedInDistributedError, |
| 51 | + PLAN_TOO_LARGE, |
| 52 | + PlanTooLargeError, |
| 53 | +} from "./services/distributed/plan.js"; |
| 54 | + |
| 55 | +// ── RenderChunk (Activity B) ──────────────────────────────────────────────── |
| 56 | +export { |
| 57 | + applyRuntimeEnvSnapshot, |
| 58 | + readWebGlVendorInfoFromCanvas, |
| 59 | + renderChunk, |
| 60 | + // Types |
| 61 | + type ChunkResult, |
| 62 | + // Error codes + classes |
| 63 | + FFMPEG_VERSION_MISMATCH, |
| 64 | + PLAN_HASH_MISMATCH, |
| 65 | + RenderChunkValidationError, |
| 66 | +} from "./services/distributed/renderChunk.js"; |
| 67 | + |
| 68 | +// ── Assemble (Activity C) ─────────────────────────────────────────────────── |
| 69 | +export { assemble, type AssembleResult } from "./services/distributed/assemble.js"; |
| 70 | + |
| 71 | +// ── Plan-time shared types from `freezePlan` ─────────────────────────────── |
| 72 | +// Re-exported so adopters that deserialize a planDir's `meta/encoder.json` |
| 73 | +// or `meta/chunks.json` see the same shapes the producer wrote them as. |
| 74 | +export type { |
| 75 | + ChunkSliceJson, |
| 76 | + CompositionMetadataJson, |
| 77 | + LockedRenderConfig, |
| 78 | +} from "./services/render/stages/freezePlan.js"; |
0 commit comments