@hyperframes/aws-lambda 0.6.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +191 -0
- package/dist/cdk/HyperframesRenderStack.d.ts +65 -0
- package/dist/cdk/HyperframesRenderStack.d.ts.map +1 -0
- package/dist/cdk/index.d.ts +10 -0
- package/dist/cdk/index.d.ts.map +1 -0
- package/dist/cdk/index.js +263 -0
- package/dist/cdk/index.js.map +7 -0
- package/dist/chromium.d.ts +77 -0
- package/dist/chromium.d.ts.map +1 -0
- package/dist/events.d.ts +120 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/formatExtension.d.ts +10 -0
- package/dist/formatExtension.d.ts.map +1 -0
- package/dist/handler.d.ts +42 -0
- package/dist/handler.d.ts.map +1 -0
- package/dist/handler.js +432 -0
- package/dist/handler.js.map +7 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +951 -0
- package/dist/index.js.map +7 -0
- package/dist/s3Transport.d.ts +55 -0
- package/dist/s3Transport.d.ts.map +1 -0
- package/dist/sdk/costAccounting.d.ts +51 -0
- package/dist/sdk/costAccounting.d.ts.map +1 -0
- package/dist/sdk/deploySite.d.ts +55 -0
- package/dist/sdk/deploySite.d.ts.map +1 -0
- package/dist/sdk/getRenderProgress.d.ts +72 -0
- package/dist/sdk/getRenderProgress.d.ts.map +1 -0
- package/dist/sdk/index.d.ts +16 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/dist/sdk/index.js +578 -0
- package/dist/sdk/index.js.map +7 -0
- package/dist/sdk/renderToLambda.d.ts +66 -0
- package/dist/sdk/renderToLambda.d.ts.map +1 -0
- package/dist/sdk/validateConfig.d.ts +35 -0
- package/dist/sdk/validateConfig.d.ts.map +1 -0
- package/package.json +84 -0
- package/scripts/_formatBytes.ts +15 -0
- package/scripts/build-zip.ts +480 -0
- package/scripts/probe-beginframe.dockerfile +61 -0
- package/scripts/probe-beginframe.ts +157 -0
- package/scripts/verify-zip-size.ts +83 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/handler.ts", "../src/chromium.ts", "../src/formatExtension.ts", "../src/s3Transport.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * AWS Lambda handler for HyperFrames distributed rendering.\n *\n * One Lambda function, three roles. Step Functions dispatches by setting\n * `event.Action`; the handler unwraps Map-state envelopes, primes the\n * Lambda environment (Chrome path, ffmpeg path, tmpdir), and forwards to\n * the matching OSS primitive from `@hyperframes/producer/distributed`.\n *\n * Everything heavy \u2014 capture, encode, audio mix \u2014 happens inside the OSS\n * primitives. The handler is thin glue: parse event \u2192 S3 download \u2192 call\n * primitive \u2192 S3 upload \u2192 return small JSON result.\n */\n\nimport { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, statSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { basename, join } from \"node:path\";\nimport { S3Client } from \"@aws-sdk/client-s3\";\nimport {\n assemble,\n type AssembleResult,\n type ChunkResult,\n type DistributedRenderConfig,\n plan,\n type PlanResult,\n renderChunk,\n} from \"@hyperframes/producer/distributed\";\nimport { resolveChromeExecutablePath } from \"./chromium.js\";\nimport { formatExtension } from \"./formatExtension.js\";\nimport type {\n AssembleEvent,\n AssembleLambdaResult,\n LambdaAction,\n LambdaEvent,\n LambdaResult,\n PlanEvent,\n PlanLambdaResult,\n RenderChunkEvent,\n RenderChunkLambdaResult,\n} from \"./events.js\";\nimport {\n downloadS3ObjectToFile,\n parseS3Uri,\n tarDirectory,\n untarDirectory,\n uploadFileToS3,\n} from \"./s3Transport.js\";\n\n/**\n * Lazily-constructed S3 client. Cached at module scope so warm Lambda\n * containers reuse the underlying HTTP keep-alive pool across invocations.\n */\nlet cachedS3Client: S3Client | null = null;\nfunction getS3Client(): S3Client {\n if (cachedS3Client) return cachedS3Client;\n cachedS3Client = new S3Client({});\n return cachedS3Client;\n}\n\n/**\n * Optional injection points used by the handler's unit tests. Production\n * callers leave these unset; the real OSS primitives are used. Tests\n * inject `s3` and `primitives` directly rather than mutating module\n * state \u2014 the dependency-injection seam is sufficient and avoids a\n * second leak point for cross-test contamination.\n */\nexport interface HandlerDeps {\n s3?: S3Client;\n primitives?: {\n plan: typeof plan;\n renderChunk: typeof renderChunk;\n assemble: typeof assemble;\n };\n /** Override the per-invocation `/tmp` workdir root (defaults to Lambda's `/tmp`). */\n tmpRoot?: string;\n /** Skip Chrome resolution (used by handler dispatch tests that mock renderChunk). */\n skipChromeResolution?: boolean;\n}\n\n/**\n * Lambda entry. Step Functions sometimes wraps the event in\n * `{ Payload: ... }` or `{ Input: ... }` depending on the state machine\n * shape; unwrap until we hit a discriminated event.\n */\nexport async function handler(event: LambdaEvent, deps?: HandlerDeps): Promise<LambdaResult> {\n const unwrapped = unwrapEvent(event);\n primeRuntimeEnv();\n // Single structured boot log line \u2014 CloudWatch Logs Insights queries\n // key off `event=handler_start` to grep for a specific Action / S3 URI\n // when triaging without attaching a debugger.\n logEvent({ event: \"handler_start\", action: unwrapped.Action, input: summarizeEvent(unwrapped) });\n try {\n switch (unwrapped.Action) {\n case \"plan\":\n return await handlePlan(unwrapped, deps);\n case \"renderChunk\":\n return await handleRenderChunk(unwrapped, deps);\n case \"assemble\":\n return await handleAssemble(unwrapped, deps);\n default: {\n // Compile-time exhaustiveness: a new LambdaAction member trips\n // the `never` assignment before the runtime error is reachable.\n const _exhaustive: never = unwrapped;\n throw new Error(\n `[handler] unknown Action: ${JSON.stringify(\n (_exhaustive as { Action?: string }).Action,\n )}. Expected one of \"plan\", \"renderChunk\", \"assemble\".`,\n );\n }\n }\n } catch (err) {\n // Log before re-throwing so CloudWatch captures the structured\n // error context alongside Lambda's default stack trace. Otherwise\n // ops only sees the trace and has to correlate with execution\n // history to recover the action + input.\n logEvent({\n event: \"handler_error\",\n action: unwrapped.Action,\n message: err instanceof Error ? err.message : String(err),\n name: err instanceof Error ? err.name : undefined,\n });\n throw err;\n }\n}\n\n/**\n * Walk through Step Functions' Map-state and Task-state envelopes until\n * the discriminated event is found.\n */\n// Step Functions wraps at most `{Payload: {Input: ...}}` in our state\n// machine; 4 levels is 2\u00D7 headroom for unusual Map / Wait state\n// configurations and prevents infinite loops on malformed input.\nconst MAX_ENVELOPE_DEPTH = 4;\n\nexport function unwrapEvent(event: LambdaEvent): PlanEvent | RenderChunkEvent | AssembleEvent {\n let cursor: LambdaEvent = event;\n for (let i = 0; i < MAX_ENVELOPE_DEPTH; i++) {\n if (cursor && typeof cursor === \"object\") {\n const obj = cursor as Record<string, unknown>;\n if (typeof obj.Action === \"string\" && isLambdaAction(obj.Action)) {\n return cursor as PlanEvent | RenderChunkEvent | AssembleEvent;\n }\n if (\"Payload\" in obj) {\n cursor = obj.Payload as LambdaEvent;\n continue;\n }\n if (\"Input\" in obj) {\n cursor = obj.Input as LambdaEvent;\n continue;\n }\n }\n break;\n }\n throw new Error(\n `[handler] event has no recognised Action; unwrapped ${MAX_ENVELOPE_DEPTH} levels of Payload/Input without finding one.`,\n );\n}\n\nfunction isLambdaAction(value: string): value is LambdaAction {\n return value === \"plan\" || value === \"renderChunk\" || value === \"assemble\";\n}\n\n/**\n * Emit a single JSON line to stdout. CloudWatch ingests each line as a\n * structured event; Logs Insights queries can `filter event=\"...\"` and\n * project specific fields. We write to stdout (not stderr) because\n * Lambda's default destination for both is the same log group, and\n * Logs Insights' INFO/ERROR level parser keys off the JSON `level`\n * field, not the stream.\n */\nfunction logEvent(payload: Record<string, unknown>): void {\n console.log(JSON.stringify(payload));\n}\n\n/**\n * Compact, non-PII summary of a Lambda event for logging. The full\n * event payload can include the entire project config; we only emit\n * the routable fields (S3 URIs, chunk index, format) needed to triage\n * a failure from CloudWatch.\n */\nfunction summarizeEvent(\n event: PlanEvent | RenderChunkEvent | AssembleEvent,\n): Record<string, unknown> {\n switch (event.Action) {\n case \"plan\":\n return {\n projectS3Uri: event.ProjectS3Uri,\n planOutputS3Prefix: event.PlanOutputS3Prefix,\n format: event.Config.format,\n fps: event.Config.fps,\n };\n case \"renderChunk\":\n return {\n planS3Uri: event.PlanS3Uri,\n chunkIndex: event.ChunkIndex,\n format: event.Format,\n };\n case \"assemble\":\n return {\n planS3Uri: event.PlanS3Uri,\n chunkCount: event.ChunkS3Uris.length,\n hasAudio: event.AudioS3Uri !== null,\n outputS3Uri: event.OutputS3Uri,\n format: event.Format,\n };\n }\n}\n\n/**\n * Lambda sets `TMPDIR` to `/tmp` already, but the bundled binaries (Chrome\n * + ffmpeg) live alongside the handler at `/var/task/bin/`. Add that to\n * PATH the first time the handler runs so spawn(\"ffmpeg\", \u2026) inside the\n * OSS primitives resolves to the bundled binary.\n */\nlet runtimeEnvPrimed = false;\nfunction primeRuntimeEnv(): void {\n if (runtimeEnvPrimed) return;\n runtimeEnvPrimed = true;\n const taskRoot = process.env.LAMBDA_TASK_ROOT ?? \"/var/task\";\n const bin = join(taskRoot, \"bin\");\n if (existsSync(bin)) {\n process.env.PATH = `${bin}:${process.env.PATH ?? \"\"}`;\n }\n}\n\n// \u2500\u2500 Plan \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nasync function handlePlan(event: PlanEvent, deps?: HandlerDeps): Promise<PlanLambdaResult> {\n const started = Date.now();\n const s3 = deps?.s3 ?? getS3Client();\n const primitive = deps?.primitives?.plan ?? plan;\n\n const work = mkdtempSync(join(deps?.tmpRoot ?? tmpdir(), \"hf-lambda-plan-\"));\n // We use `.tar.gz` (not `.zip`) as the project archive's on-the-wire\n // format because Lambda's Amazon Linux base image ships GNU `tar` but\n // not `unzip` in `/usr/bin`. The smoke script + future CLI both\n // produce tar.gz uploads.\n const projectArchive = join(work, \"project.tar.gz\");\n const projectDir = join(work, \"project\");\n const planDir = join(work, \"plan\");\n\n try {\n await downloadS3ObjectToFile(s3, event.ProjectS3Uri, projectArchive);\n await untarDirectory(projectArchive, projectDir);\n\n const config: DistributedRenderConfig = {\n ...event.Config,\n };\n const result: PlanResult = await primitive(projectDir, config, planDir);\n\n // Upload the planDir as a single tarball. Step Functions cannot pass\n // a directory-shaped artifact between states; we serialize and rely on\n // the consumer (renderChunk / assemble) to untar. Audio is co-located\n // alongside the plan so RenderChunk doesn't have to pull the whole\n // plan tarball when audio isn't relevant to the chunk.\n const planTar = join(work, \"plan.tar.gz\");\n await tarDirectory(planDir, planTar);\n const planTarUri = `${trimTrailingSlash(event.PlanOutputS3Prefix)}/plan.tar.gz`;\n const audioPath = join(planDir, \"audio.aac\");\n const hasAudio = existsSync(audioPath) && statSync(audioPath).size > 0;\n const audioUri = hasAudio ? `${trimTrailingSlash(event.PlanOutputS3Prefix)}/audio.aac` : null;\n // Plan and audio are independent S3 PUTs; run them in parallel so\n // the response returns as soon as the slower of the two completes.\n await Promise.all([\n uploadFileToS3(s3, planTar, planTarUri, \"application/gzip\"),\n hasAudio && audioUri ? uploadFileToS3(s3, audioPath, audioUri, \"audio/aac\") : null,\n ]);\n\n return {\n Action: \"plan\",\n PlanS3Uri: planTarUri,\n PlanHash: result.planHash,\n ChunkCount: result.chunkCount,\n TotalFrames: result.totalFrames,\n Fps: result.fps,\n Width: result.width,\n Height: result.height,\n Format: result.format,\n HasAudio: audioUri !== null,\n AudioS3Uri: audioUri,\n FfmpegVersion: result.ffmpegVersion,\n ProducerVersion: result.producerVersion,\n DurationMs: Date.now() - started,\n };\n } finally {\n cleanupDir(work);\n }\n}\n\n// \u2500\u2500 RenderChunk \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nasync function handleRenderChunk(\n event: RenderChunkEvent,\n deps?: HandlerDeps,\n): Promise<RenderChunkLambdaResult> {\n const started = Date.now();\n const s3 = deps?.s3 ?? getS3Client();\n const primitive = deps?.primitives?.renderChunk ?? renderChunk;\n\n // Sparticuz decompresses Chromium into /tmp on first call; warm starts\n // skip the work (path already cached). Guard the env-var mutation too so\n // a caller-supplied PRODUCER_HEADLESS_SHELL_PATH (e.g. the SAM-local\n // RIE smoke) wins over the auto-resolution.\n if (!deps?.skipChromeResolution && !process.env.PRODUCER_HEADLESS_SHELL_PATH) {\n const chromePath = await resolveChromeExecutablePath();\n // The OSS engine resolves Chrome via `PRODUCER_HEADLESS_SHELL_PATH`\n // first (see `browserManager.resolveHeadlessShellPath`); set it before\n // invoking the primitive so launch picks up the bundled binary.\n process.env.PRODUCER_HEADLESS_SHELL_PATH = chromePath;\n }\n\n const work = mkdtempSync(join(deps?.tmpRoot ?? tmpdir(), \"hf-lambda-chunk-\"));\n const planTar = join(work, \"plan.tar.gz\");\n const planDir = join(work, \"plan\");\n\n try {\n await downloadS3ObjectToFile(s3, event.PlanS3Uri, planTar);\n await untarDirectory(planTar, planDir);\n\n // Verify the plan's hash matches what Step Functions told us to render.\n // The producer's renderChunk re-checks internally (defense-in-depth),\n // but doing it here at the handler boundary lets us fail before paying\n // the Chrome-launch + render cost on a misrouted chunk. Throws a\n // typed PLAN_HASH_MISMATCH that Step Functions can route as\n // non-retryable.\n verifyPlanHash(planDir, event.PlanHash);\n\n const chunkOutputBase = join(\n work,\n event.Format === \"png-sequence\"\n ? `chunk-${pad(event.ChunkIndex)}`\n : `chunk-${pad(event.ChunkIndex)}${formatExtension(event.Format)}`,\n );\n\n const result: ChunkResult = await primitive(planDir, event.ChunkIndex, chunkOutputBase);\n\n const chunkUri = await uploadChunkOutput(\n s3,\n result,\n event.ChunkOutputS3Prefix,\n event.ChunkIndex,\n );\n\n return {\n Action: \"renderChunk\",\n ChunkS3Uri: chunkUri,\n ChunkIndex: event.ChunkIndex,\n Sha256: result.sha256,\n FramesEncoded: result.framesEncoded,\n DurationMs: Date.now() - started,\n };\n } finally {\n cleanupDir(work);\n }\n}\n\nasync function uploadChunkOutput(\n s3: S3Client,\n result: ChunkResult,\n prefix: string,\n chunkIndex: number,\n): Promise<string> {\n const trimmed = trimTrailingSlash(prefix);\n if (result.outputKind === \"file\") {\n const ext = result.outputPath.slice(result.outputPath.lastIndexOf(\".\"));\n const uri = `${trimmed}/chunks/${pad(chunkIndex)}${ext}`;\n await uploadFileToS3(s3, result.outputPath, uri);\n return uri;\n }\n // frame-dir: upload as a tarball so a single S3 object represents the chunk.\n // Assemble's png-sequence path expects a directory per chunk; it untars on\n // its end.\n const tarball = `${result.outputPath}.tar.gz`;\n await tarDirectory(result.outputPath, tarball);\n const uri = `${trimmed}/chunks/${pad(chunkIndex)}.tar.gz`;\n await uploadFileToS3(s3, tarball, uri, \"application/gzip\");\n return uri;\n}\n\n// \u2500\u2500 Assemble \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nasync function handleAssemble(\n event: AssembleEvent,\n deps?: HandlerDeps,\n): Promise<AssembleLambdaResult> {\n const started = Date.now();\n const s3 = deps?.s3 ?? getS3Client();\n const primitive = deps?.primitives?.assemble ?? assemble;\n\n const work = mkdtempSync(join(deps?.tmpRoot ?? tmpdir(), \"hf-lambda-assemble-\"));\n const planTar = join(work, \"plan.tar.gz\");\n const planDir = join(work, \"plan\");\n\n try {\n await downloadS3ObjectToFile(s3, event.PlanS3Uri, planTar);\n await untarDirectory(planTar, planDir);\n\n const chunkPaths = await downloadChunkObjects(s3, event.ChunkS3Uris, work, event.Format);\n\n let audioPath: string | null = null;\n if (event.AudioS3Uri) {\n audioPath = join(planDir, \"audio.aac\");\n await downloadS3ObjectToFile(s3, event.AudioS3Uri, audioPath);\n }\n\n const finalOutput =\n event.Format === \"png-sequence\"\n ? join(work, \"output-frames\")\n : join(work, `output${formatExtension(event.Format)}`);\n\n const result: AssembleResult = await primitive(planDir, chunkPaths, audioPath, finalOutput);\n\n if (event.Format === \"png-sequence\") {\n const tarball = `${finalOutput}.tar.gz`;\n await tarDirectory(finalOutput, tarball);\n await uploadFileToS3(s3, tarball, event.OutputS3Uri, \"application/gzip\");\n } else {\n await uploadFileToS3(s3, finalOutput, event.OutputS3Uri);\n }\n\n return {\n Action: \"assemble\",\n OutputS3Uri: event.OutputS3Uri,\n FramesEncoded: result.framesEncoded,\n FileSize: result.fileSize,\n DurationMs: Date.now() - started,\n };\n } finally {\n cleanupDir(work);\n }\n}\n\nasync function downloadChunkObjects(\n s3: S3Client,\n uris: string[],\n workDir: string,\n format: \"mp4\" | \"mov\" | \"png-sequence\",\n): Promise<string[]> {\n const chunksDir = join(workDir, \"chunks\");\n mkdirSync(chunksDir, { recursive: true });\n // Each chunk is an independent S3 GET (+ untar for png-sequence). Run\n // them in parallel \u2014 assemble's wall-clock is otherwise dominated by\n // `\u03A3 chunk-download-ms` instead of `max(chunk-download-ms)`. Preserve\n // the input order by writing into a pre-sized array rather than\n // pushing as each task settles.\n const local: string[] = new Array<string>(uris.length);\n await Promise.all(\n uris.map(async (uri, i) => {\n if (!uri) {\n throw new Error(`[handler] chunk URI at index ${i} is empty`);\n }\n const { key } = parseS3Uri(uri);\n const localPath = join(chunksDir, basename(key));\n await downloadS3ObjectToFile(s3, uri, localPath);\n if (format === \"png-sequence\") {\n const dirPath = join(chunksDir, `frames-${pad(i)}`);\n await untarDirectory(localPath, dirPath);\n local[i] = dirPath;\n } else {\n local[i] = localPath;\n }\n }),\n );\n return local;\n}\n\n// \u2500\u2500 Helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction pad(n: number): string {\n return n.toString().padStart(4, \"0\");\n}\n\nfunction trimTrailingSlash(prefix: string): string {\n return prefix.endsWith(\"/\") ? prefix.slice(0, -1) : prefix;\n}\n\nfunction cleanupDir(dir: string): void {\n try {\n // Lambda warm starts can reuse `/tmp` across invocations; clean up\n // aggressively so we don't leak a chunk-sized footprint between renders.\n rmSync(dir, { recursive: true, force: true });\n } catch {\n // Best-effort \u2014 leak is preferable to crashing on success path.\n }\n}\n\n/**\n * Read the untarred planDir's `plan.json` and assert its `planHash`\n * matches what the Step Functions event claims. Throws on mismatch with\n * a typed `PLAN_HASH_MISMATCH` error name so the state machine's typed\n * non-retryable list routes it correctly.\n *\n * This is defense-in-depth \u2014 the producer's `renderChunk` does the same\n * check internally \u2014 but performing it here lets us fail before paying\n * the Chrome-launch + per-frame capture cost on a misrouted chunk.\n */\nfunction verifyPlanHash(planDir: string, expected: string): void {\n const planJsonPath = join(planDir, \"plan.json\");\n let parsed: { planHash?: unknown };\n try {\n parsed = JSON.parse(readFileSync(planJsonPath, \"utf-8\")) as { planHash?: unknown };\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n const error = new Error(`PLAN_HASH_MISMATCH: failed to read ${planJsonPath}: ${msg}`);\n error.name = \"PLAN_HASH_MISMATCH\";\n throw error;\n }\n const actual = parsed.planHash;\n if (typeof actual !== \"string\" || actual !== expected) {\n const error = new Error(\n `PLAN_HASH_MISMATCH: event PlanHash=${expected} did not match plan.json planHash=${String(actual)}`,\n );\n error.name = \"PLAN_HASH_MISMATCH\";\n throw error;\n }\n}\n", "/**\n * Lambda-runtime Chrome resolver.\n *\n * `renderChunk()` (the only primitive that needs a browser) launches Chrome\n * via the engine's `BrowserManager`. In Lambda we can't ship the full\n * Puppeteer-managed Chrome download \u2014 Puppeteer's Chrome binary is ~330 MB\n * unzipped, well over Lambda's 250 MB ZIP-deploy ceiling.\n *\n * Two valid runtime sources:\n *\n * 1. `@sparticuz/chromium` (primary). Decompresses a Lambda-optimised\n * `chrome-headless-shell` build into `/tmp` at runtime. ~70 MB\n * compressed; the same binary the rest of the ecosystem uses for\n * headless-Chrome-in-Lambda. CDP-level BeginFrame works because the\n * command lives in the protocol, not the binary; the\n * `scripts/probe-beginframe.ts` regression guard pins this.\n *\n * 2. A bundled `chrome-headless-shell` binary (fallback). If\n * `@sparticuz/chromium`'s build ever drops `HeadlessExperimental`\n * support, we fall back to the same `chrome-headless-shell` build\n * the K8s deploy uses. The fallback raises the ZIP from ~70 MB\n * Chrome to ~140 MB Chrome \u2014 still well under 250 MB.\n *\n * The runtime path is selected by the `HYPERFRAMES_LAMBDA_CHROME_SOURCE`\n * env var (set by `build-zip.ts`):\n *\n * \"sparticuz\" \u2192 use `@sparticuz/chromium.executablePath()`\n * \"chrome-headless-shell\" \u2192 use `process.env.HYPERFRAMES_LAMBDA_CHROME_PATH`\n *\n * Adapters that bundle this package can override\n * `HYPERFRAMES_LAMBDA_CHROME_PATH` directly when running outside Lambda\n * (e.g. the SAM-local RIE smoke).\n */\n\nimport { existsSync } from \"node:fs\";\n\n/** Discriminator for the two supported Chrome sources. */\nexport type ChromeSource = \"sparticuz\" | \"chrome-headless-shell\";\n\n/**\n * Read which Chrome source the bundled ZIP was built against. Defaults to\n * `\"sparticuz\"` so a fresh build with no env override picks the primary\n * path.\n */\nexport function resolveChromeSource(): ChromeSource {\n const raw = process.env.HYPERFRAMES_LAMBDA_CHROME_SOURCE?.toLowerCase();\n if (raw === \"chrome-headless-shell\" || raw === \"shell\") return \"chrome-headless-shell\";\n return \"sparticuz\";\n}\n\n/**\n * Resolve the absolute path to a Chrome binary suitable for BeginFrame.\n *\n * For `\"sparticuz\"`: dynamically import `@sparticuz/chromium` and call\n * `chromium.executablePath()`. The module is dynamic so a build-zip that\n * never reaches the import (because the fallback Chrome is bundled) can\n * tree-shake it out.\n *\n * For `\"chrome-headless-shell\"`: read the path from\n * `HYPERFRAMES_LAMBDA_CHROME_PATH`. Throws if absent or non-existent so a\n * misconfigured deploy fails loudly at boot rather than at first frame.\n */\nexport async function resolveChromeExecutablePath(): Promise<string> {\n const source = resolveChromeSource();\n if (source === \"sparticuz\") {\n const mod = await loadSparticuzChromium();\n return mod.executablePath();\n }\n const explicit = process.env.HYPERFRAMES_LAMBDA_CHROME_PATH;\n if (!explicit) {\n throw new Error(\n \"[chromium] HYPERFRAMES_LAMBDA_CHROME_SOURCE=chrome-headless-shell requires \" +\n \"HYPERFRAMES_LAMBDA_CHROME_PATH to be set to the absolute path of the bundled binary.\",\n );\n }\n if (!existsSync(explicit)) {\n throw new Error(\n `[chromium] HYPERFRAMES_LAMBDA_CHROME_PATH=${JSON.stringify(explicit)} does not exist`,\n );\n }\n return explicit;\n}\n\n/**\n * Resolve the Chromium launch args for the selected source. For\n * `@sparticuz/chromium` we forward `chromium.args` (Lambda-tuned defaults\n * \u2014 single-process, no-sandbox, /tmp paths). For the shell fallback the\n * engine's own arg builder owns it; we return an empty array so the\n * engine's defaults apply.\n */\nexport async function resolveChromeArgs(): Promise<string[]> {\n if (resolveChromeSource() !== \"sparticuz\") return [];\n const mod = await loadSparticuzChromium();\n return mod.args;\n}\n\n/**\n * Dynamic import wrapper isolated so unit tests can stub the module without\n * jest-style module mocking gymnastics. The narrow type here pins the\n * subset of `@sparticuz/chromium`'s surface this package depends on; if\n * the upstream module ever changes shape the type error here surfaces\n * before runtime.\n */\ninterface SparticuzChromiumModule {\n args: string[];\n executablePath(): Promise<string>;\n}\n\nlet cachedSparticuz: SparticuzChromiumModule | null = null;\n\nasync function loadSparticuzChromium(): Promise<SparticuzChromiumModule> {\n if (cachedSparticuz) return cachedSparticuz;\n const mod = (await import(\"@sparticuz/chromium\")) as\n | SparticuzChromiumModule\n | { default: SparticuzChromiumModule };\n const resolved = \"default\" in mod ? mod.default : mod;\n cachedSparticuz = resolved;\n return resolved;\n}\n\n/** Test-only seam: replace the cached `@sparticuz/chromium` module. */\nexport function _setSparticuzChromiumForTests(mod: SparticuzChromiumModule | null): void {\n cachedSparticuz = mod;\n}\n", "/**\n * Map a distributed `format` to the file extension the assembled output\n * should carry on disk + in S3. Shared by `src/handler.ts` (chunk +\n * assemble output paths) and `src/sdk/renderToLambda.ts` (final\n * output key construction) so the two sides agree on what an mp4\n * looks like vs a png-sequence.\n */\n\nexport type DistributedFormat = \"mp4\" | \"mov\" | \"png-sequence\";\n\nexport function formatExtension(format: DistributedFormat): string {\n switch (format) {\n case \"mp4\":\n return \".mp4\";\n case \"mov\":\n return \".mov\";\n case \"png-sequence\":\n return \"\";\n default: {\n const _exhaustive: never = format;\n throw new Error(`[formatExtension] unsupported format: ${_exhaustive as string}`);\n }\n }\n}\n", "/**\n * Thin S3 transport for the Lambda handler.\n *\n * The OSS distributed primitives are pure functions over local file paths;\n * the Lambda handler bridges S3 \u2194 Lambda's `/tmp` filesystem on each\n * invocation. Functions here are intentionally narrow: parse a URI, download\n * an object to a local path, upload a path/directory, tar-extract a planDir,\n * tar-pack a planDir back out.\n *\n * Tar (not zip) for planDir transit:\n * - planDirs contain symlinks (extract stage materializes them but the\n * compiled/ subtree may include linked assets); tar preserves them, zip\n * does not.\n * - We use the `tar` npm package (pure JS over `node:zlib`) \u2014 AWS\n * Lambda's `nodejs:22` base image ships neither `tar` nor `unzip` in\n * `/usr/bin`, so a system-binary tar would ENOENT in the actual\n * deployment.\n */\n\nimport {\n createReadStream,\n createWriteStream,\n existsSync,\n mkdirSync,\n readdirSync,\n rmSync,\n statSync,\n} from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { pipeline } from \"node:stream/promises\";\nimport { GetObjectCommand, PutObjectCommand, type S3Client } from \"@aws-sdk/client-s3\";\nimport * as tar from \"tar\";\n\n/** Parsed `s3://bucket/key` URI. */\nexport interface S3Location {\n bucket: string;\n key: string;\n}\n\n/** Parse `s3://bucket/key/path` \u2192 `{ bucket, key }`. Throws on malformed input. */\nexport function parseS3Uri(uri: string): S3Location {\n if (!uri.startsWith(\"s3://\")) {\n throw new Error(`[s3Transport] expected s3:// URI, got: ${JSON.stringify(uri)}`);\n }\n const rest = uri.slice(\"s3://\".length);\n const slash = rest.indexOf(\"/\");\n if (slash === -1) {\n throw new Error(`[s3Transport] missing key in s3 URI: ${JSON.stringify(uri)}`);\n }\n const bucket = rest.slice(0, slash);\n const key = rest.slice(slash + 1);\n if (!bucket || !key) {\n throw new Error(`[s3Transport] empty bucket or key in s3 URI: ${JSON.stringify(uri)}`);\n }\n return { bucket, key };\n}\n\n/** Build `s3://bucket/key` from a location. */\nexport function formatS3Uri(loc: S3Location): string {\n return `s3://${loc.bucket}/${loc.key}`;\n}\n\n/** Stream an S3 object to a local file path. Throws if the body is missing. */\nexport async function downloadS3ObjectToFile(\n client: S3Client,\n uri: string,\n destPath: string,\n): Promise<void> {\n const { bucket, key } = parseS3Uri(uri);\n const response = await client.send(new GetObjectCommand({ Bucket: bucket, Key: key }));\n const body = response.Body as NodeJS.ReadableStream | undefined;\n if (!body) {\n throw new Error(`[s3Transport] s3 GetObject returned empty body for ${uri}`);\n }\n mkdirSync(dirname(destPath), { recursive: true });\n await pipeline(body, createWriteStream(destPath));\n}\n\n/**\n * Upload a local file's contents to an S3 URI using a streaming\n * `PutObjectCommand`. PutObject's 5 GB cap comfortably exceeds the\n * distributed pipeline's 2 GB planDir limit and the typical\n * chunk size (\u2264 200 MB), so a single PUT works for every artifact this\n * adapter handles.\n */\nexport async function uploadFileToS3(\n client: S3Client,\n localPath: string,\n uri: string,\n contentType?: string,\n): Promise<void> {\n if (!existsSync(localPath)) {\n throw new Error(`[s3Transport] upload source missing: ${localPath}`);\n }\n const { bucket, key } = parseS3Uri(uri);\n const size = statSync(localPath).size;\n await client.send(\n new PutObjectCommand({\n Bucket: bucket,\n Key: key,\n Body: createReadStream(localPath),\n ContentType: contentType,\n ContentLength: size,\n }),\n );\n}\n\n/**\n * Pack a directory into a `.tar.gz` at `destTarball`. Uses the `tar` npm\n * package (pure JS over `node:zlib`) rather than spawning a system tar\n * binary \u2014 the AWS Lambda Node 22 base image ships a minimal set of\n * userland tools and does NOT include `tar` in `/usr/bin`.\n */\nexport async function tarDirectory(sourceDir: string, destTarball: string): Promise<void> {\n if (!existsSync(sourceDir) || !statSync(sourceDir).isDirectory()) {\n throw new Error(`[s3Transport] tar source must be an existing directory: ${sourceDir}`);\n }\n mkdirSync(dirname(destTarball), { recursive: true });\n await tar.create({ gzip: true, file: destTarball, cwd: sourceDir }, [\".\"]);\n}\n\n/**\n * Extract a `.tar.gz` produced by {@link tarDirectory} into `destDir`.\n * The directory is created (or cleared) before extraction so a retried\n * invocation doesn't observe stale files from a prior run on the same\n * warm Lambda container.\n */\nexport async function untarDirectory(tarballPath: string, destDir: string): Promise<void> {\n if (!existsSync(tarballPath)) {\n throw new Error(`[s3Transport] tarball missing: ${tarballPath}`);\n }\n // Wipe target so the warm container's prior planDir doesn't bleed into\n // the new invocation. Lambda re-uses /tmp across invocations on the same\n // container.\n if (existsSync(destDir)) {\n rmSync(destDir, { recursive: true, force: true });\n }\n mkdirSync(destDir, { recursive: true });\n await tar.extract({ file: tarballPath, cwd: destDir });\n}\n\n/** List all regular files under a directory, sorted, returned as absolute paths. */\nexport function listFilesInDirectory(dir: string): string[] {\n const out: string[] = [];\n function walk(d: string): void {\n for (const entry of readdirSync(d, { withFileTypes: true }).sort((a, b) =>\n a.name < b.name ? -1 : a.name > b.name ? 1 : 0,\n )) {\n const full = join(d, entry.name);\n if (entry.isDirectory()) walk(full);\n else if (entry.isFile()) out.push(full);\n }\n }\n walk(dir);\n return out;\n}\n"],
|
|
5
|
+
"mappings": ";AAaA,SAAS,cAAAA,aAAY,aAAAC,YAAW,aAAa,cAAc,UAAAC,SAAQ,YAAAC,iBAAgB;AACnF,SAAS,cAAc;AACvB,SAAS,UAAU,QAAAC,aAAY;AAC/B,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,EAIA;AAAA,EAEA;AAAA,OACK;;;ACSP,SAAS,kBAAkB;AAUpB,SAAS,sBAAoC;AAClD,QAAM,MAAM,QAAQ,IAAI,kCAAkC,YAAY;AACtE,MAAI,QAAQ,2BAA2B,QAAQ,QAAS,QAAO;AAC/D,SAAO;AACT;AAcA,eAAsB,8BAA+C;AACnE,QAAM,SAAS,oBAAoB;AACnC,MAAI,WAAW,aAAa;AAC1B,UAAM,MAAM,MAAM,sBAAsB;AACxC,WAAO,IAAI,eAAe;AAAA,EAC5B;AACA,QAAM,WAAW,QAAQ,IAAI;AAC7B,MAAI,CAAC,UAAU;AACb,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AACA,MAAI,CAAC,WAAW,QAAQ,GAAG;AACzB,UAAM,IAAI;AAAA,MACR,6CAA6C,KAAK,UAAU,QAAQ,CAAC;AAAA,IACvE;AAAA,EACF;AACA,SAAO;AACT;AA2BA,IAAI,kBAAkD;AAEtD,eAAe,wBAA0D;AACvE,MAAI,gBAAiB,QAAO;AAC5B,QAAM,MAAO,MAAM,OAAO,qBAAqB;AAG/C,QAAM,WAAW,aAAa,MAAM,IAAI,UAAU;AAClD,oBAAkB;AAClB,SAAO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F,aAAS,KAAK,MAAM,aAAa,cAAc,OAAO,CAAC;AAAA,EACzD,SAAS,KAAK;AACZ,UAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC3D,UAAM,QAAQ,IAAI,MAAM,sCAAsC,YAAY,KAAK,GAAG,EAAE;AACpF,UAAM,OAAO;AACb,UAAM;AAAA,EACR;AACA,QAAM,SAAS,OAAO;AACtB,MAAI,OAAO,WAAW,YAAY,WAAW,UAAU;AACrD,UAAM,QAAQ,IAAI;AAAA,MAChB,sCAAsC,QAAQ,qCAAqC,OAAO,MAAM,CAAC;AAAA,IACnG;AACA,UAAM,OAAO;AACb,UAAM;AAAA,EACR;AACF;",
|
|
6
|
+
"names": ["existsSync", "mkdirSync", "rmSync", "statSync", "join", "existsSync", "existsSync", "join", "existsSync", "statSync", "uri", "mkdirSync", "rmSync"]
|
|
7
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@hyperframes/aws-lambda` — Lambda adapter for the HyperFrames
|
|
3
|
+
* distributed render pipeline.
|
|
4
|
+
*
|
|
5
|
+
* Two surfaces, one package:
|
|
6
|
+
*
|
|
7
|
+
* - **Server-side handler.** `handler`, the Step Functions event/result
|
|
8
|
+
* types, Chrome resolution, and S3 transport. These power the Lambda
|
|
9
|
+
* function bundled into `dist/handler.zip`.
|
|
10
|
+
* - **Client-side SDK.** `renderToLambda`, `getRenderProgress`,
|
|
11
|
+
* `deploySite`, `validateDistributedRenderConfig`, and `computeRenderCost`.
|
|
12
|
+
* Adopters call these from their Node process (CI scripts, CLIs, CDK
|
|
13
|
+
* pipelines) to drive a deployed stack without writing AWS-SDK
|
|
14
|
+
* boilerplate.
|
|
15
|
+
*
|
|
16
|
+
* The CDK L2 construct lives at the `./cdk` subpath export so SDK-only
|
|
17
|
+
* consumers don't pull `aws-cdk-lib` into their runtime graph:
|
|
18
|
+
*
|
|
19
|
+
* import { HyperframesRenderStack } from "@hyperframes/aws-lambda/cdk";
|
|
20
|
+
*
|
|
21
|
+
* The package is NOT a dependency of `@hyperframes/producer`; consumers
|
|
22
|
+
* install it separately.
|
|
23
|
+
*/
|
|
24
|
+
export { handler, type HandlerDeps, unwrapEvent } from "./handler.js";
|
|
25
|
+
export { type AssembleEvent, type AssembleLambdaResult, type LambdaAction, type LambdaEvent, type LambdaResult, type PlanEvent, type PlanLambdaResult, type RenderChunkEvent, type RenderChunkLambdaResult, type SerializableDistributedRenderConfig, } from "./events.js";
|
|
26
|
+
export { type ChromeSource, resolveChromeArgs, resolveChromeExecutablePath, resolveChromeSource, } from "./chromium.js";
|
|
27
|
+
export { downloadS3ObjectToFile, formatS3Uri, parseS3Uri, type S3Location, tarDirectory, untarDirectory, uploadFileToS3, } from "./s3Transport.js";
|
|
28
|
+
export { deploySite, type DeploySiteOptions, type SiteHandle } from "./sdk/deploySite.js";
|
|
29
|
+
export { renderToLambda, type RenderHandle, type RenderToLambdaOptions, } from "./sdk/renderToLambda.js";
|
|
30
|
+
export { getRenderProgress, type GetRenderProgressOptions, type RenderError, type RenderProgress, type RenderStatus, } from "./sdk/getRenderProgress.js";
|
|
31
|
+
export { type BilledLambdaInvocation, computeRenderCost, type RenderCost, } from "./sdk/costAccounting.js";
|
|
32
|
+
export { InvalidConfigError, validateDistributedRenderConfig } from "./sdk/validateConfig.js";
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,OAAO,EAAE,KAAK,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,mCAAmC,GACzC,MAAM,aAAa,CAAC;AAIrB,OAAO,EACL,KAAK,YAAY,EACjB,iBAAiB,EACjB,2BAA2B,EAC3B,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,sBAAsB,EACtB,WAAW,EACX,UAAU,EACV,KAAK,UAAU,EACf,YAAY,EACZ,cAAc,EACd,cAAc,GACf,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC1F,OAAO,EACL,cAAc,EACd,KAAK,YAAY,EACjB,KAAK,qBAAqB,GAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,YAAY,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,KAAK,sBAAsB,EAC3B,iBAAiB,EACjB,KAAK,UAAU,GAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC"}
|