Skip to content

Commit 9a063e3

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/ci-chrome-pin-and-psnr-harness
2 parents 070d40f + 4f274d3 commit 9a063e3

14 files changed

Lines changed: 182 additions & 49 deletions

File tree

.github/workflows/publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ jobs:
130130
publish_pkg "@hyperframes/producer" "@hyperframes/producer"
131131
publish_pkg "@hyperframes/shader-transitions" "@hyperframes/shader-transitions"
132132
publish_pkg "@hyperframes/studio" "@hyperframes/studio"
133+
publish_pkg "@hyperframes/aws-lambda" "@hyperframes/aws-lambda"
133134
134135
# CLI is @hyperframes/cli in the monorepo but published as unscoped "hyperframes" on npm.
135136
# Rewrite the name in package.json before publishing, then use npm publish directly

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"type": "module",
1212
"scripts": {
1313
"dev": "bun run studio",
14-
"build": "bun run --filter @hyperframes/core build && bun run --filter '@hyperframes/{core,engine,producer,player,studio,shader-transitions}' build && bun run --filter @hyperframes/cli build",
14+
"build": "bun run --filter @hyperframes/core build && bun run --filter '@hyperframes/{core,engine,producer,player,studio,shader-transitions,aws-lambda}' build && bun run --filter @hyperframes/cli build",
1515
"build:producer": "bun run --filter @hyperframes/producer build",
1616
"studio": "bun run --filter @hyperframes/studio dev",
1717
"build:hyperframes-runtime": "bun run --filter @hyperframes/core build:hyperframes-runtime",

packages/aws-lambda/build.mjs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env node
2+
/**
3+
* Build script for @hyperframes/aws-lambda (public OSS package).
4+
*
5+
* Bundles each subpath barrel via esbuild → dist/, then emits .d.ts via tsc.
6+
*
7+
* Subpaths (each gets its own dist entry so adopters that import one path
8+
* don't load the others' transitive graphs at module-load time):
9+
*
10+
* . (the umbrella barrel: handler + sdk + cdk types re-exported)
11+
* ./handler (the Lambda runtime entry — what `scripts/build-zip.ts` ZIPs)
12+
* ./sdk (client-side helpers — AWS-SDK only, no chromium/puppeteer)
13+
* ./cdk (CDK L2 construct — aws-cdk-lib is a peer dep)
14+
*
15+
* All production deps and peer deps are kept external so consumers resolve
16+
* them via their own node_modules.
17+
*/
18+
19+
import { build } from "esbuild";
20+
import { execSync } from "node:child_process";
21+
import { mkdirSync, rmSync } from "node:fs";
22+
23+
rmSync("dist", { recursive: true, force: true });
24+
mkdirSync("dist", { recursive: true });
25+
26+
const sharedOpts = {
27+
bundle: true,
28+
platform: "node",
29+
target: "node22",
30+
format: "esm",
31+
minify: false,
32+
sourcemap: true,
33+
external: [
34+
"@aws-sdk/client-s3",
35+
"@aws-sdk/client-sfn",
36+
"@hyperframes/producer",
37+
"@hyperframes/producer/distributed",
38+
"@sparticuz/chromium",
39+
"aws-cdk-lib",
40+
"constructs",
41+
"ffmpeg-static",
42+
"ffprobe-static",
43+
"puppeteer-core",
44+
"tar",
45+
],
46+
};
47+
48+
await Promise.all([
49+
build({ ...sharedOpts, entryPoints: ["src/index.ts"], outfile: "dist/index.js" }),
50+
build({ ...sharedOpts, entryPoints: ["src/handler.ts"], outfile: "dist/handler.js" }),
51+
build({ ...sharedOpts, entryPoints: ["src/sdk/index.ts"], outfile: "dist/sdk/index.js" }),
52+
build({ ...sharedOpts, entryPoints: ["src/cdk/index.ts"], outfile: "dist/cdk/index.js" }),
53+
]);
54+
55+
// esbuild doesn't emit .d.ts. tsc does, with a build-only tsconfig that
56+
// drops the workspace `paths` overrides so `@hyperframes/producer` resolves
57+
// through node_modules to the sibling package's already-built `dist/`
58+
// types instead of pulling its full source tree into emit (which would
59+
// violate rootDir).
60+
execSync("tsc -p tsconfig.build.json --emitDeclarationOnly", { stdio: "inherit" });
61+
62+
console.log("[Build] Complete: dist/{index,handler,sdk/index,cdk/index}.js + .d.ts");

packages/aws-lambda/package.json

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,44 @@
11
{
22
"name": "@hyperframes/aws-lambda",
3-
"version": "0.0.1",
3+
"version": "0.6.20",
44
"description": "AWS Lambda adapter for HyperFrames distributed rendering — handler, client-side SDK, and CDK construct.",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/heygen-com/hyperframes",
88
"directory": "packages/aws-lambda"
99
},
1010
"files": [
11-
"src/",
11+
"dist/",
1212
"scripts/",
1313
"README.md"
1414
],
1515
"type": "module",
16-
"main": "./src/index.ts",
17-
"types": "./src/index.ts",
16+
"main": "./dist/index.js",
17+
"types": "./dist/index.d.ts",
1818
"exports": {
19-
".": "./src/index.ts",
20-
"./handler": "./src/handler.ts",
21-
"./sdk": "./src/sdk/index.ts",
22-
"./cdk": "./src/cdk/index.ts"
19+
".": {
20+
"import": "./dist/index.js",
21+
"types": "./dist/index.d.ts"
22+
},
23+
"./handler": {
24+
"import": "./dist/handler.js",
25+
"types": "./dist/handler.d.ts"
26+
},
27+
"./sdk": {
28+
"import": "./dist/sdk/index.js",
29+
"types": "./dist/sdk/index.d.ts"
30+
},
31+
"./cdk": {
32+
"import": "./dist/cdk/index.js",
33+
"types": "./dist/cdk/index.d.ts"
34+
}
2335
},
2436
"publishConfig": {
2537
"access": "public",
2638
"registry": "https://registry.npmjs.org/"
2739
},
2840
"scripts": {
29-
"build": "tsc --noEmit",
41+
"build": "node build.mjs",
3042
"build:zip": "tsx scripts/build-zip.ts",
3143
"probe:beginframe": "tsx scripts/probe-beginframe.ts",
3244
"probe:beginframe:docker": "docker build -f scripts/probe-beginframe.dockerfile -t hyperframes-lambda-probe:local ../.. && docker run --rm hyperframes-lambda-probe:local",
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"paths": {},
5+
"noEmit": false,
6+
"outDir": "./dist",
7+
"rootDir": "./src",
8+
"declaration": true,
9+
"declarationMap": true,
10+
"sourceMap": true
11+
}
12+
}

packages/aws-lambda/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
}
1616
},
1717
"include": ["src/**/*"],
18-
"exclude": ["node_modules", "dist", "src/**/*.test.ts", "scripts"]
18+
"exclude": ["node_modules", "dist", "src/**/*.test.ts", "src/**/__fixtures__/**", "scripts"]
1919
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Public-facing types for `./regression-harness-lambda-local.ts`.
3+
*
4+
* Kept in its own file because the implementation imports
5+
* `@hyperframes/aws-lambda`, which can't be resolved by producer's
6+
* tsc emit pass until aws-lambda's own dist/ is built. Splitting the
7+
* types out lets producer's regression harness reference the lambda
8+
* adapter's shape without pulling the aws-lambda graph into producer's
9+
* type-check pass.
10+
*/
11+
12+
/** Inputs for {@link runLambdaLocalRender}. Same contract as `runDistributedSimulatedRender`. */
13+
export interface RunLambdaLocalInput {
14+
projectDir: string;
15+
tempRoot: string;
16+
renderedOutputPath: string;
17+
fps: 24 | 30 | 60;
18+
/**
19+
* Width/height from the fixture's renderConfig. Forwarded directly to
20+
* the Lambda event so this mode catches drift if the handler ever
21+
* starts honouring `Config.width/height` for canvas sizing rather
22+
* than reading the composition's `data-width`/`data-height`. The
23+
* `distributed-simulated` mode hardcodes 1920×1080 because it
24+
* bypasses the event-serialization boundary; lambda-local goes
25+
* through it, which is the whole point.
26+
*/
27+
width: number;
28+
height: number;
29+
format: "mp4" | "mov" | "png-sequence";
30+
codec?: "h264" | "h265";
31+
chunkSize?: number;
32+
maxParallelChunks?: number;
33+
variables?: Record<string, unknown>;
34+
}
35+
36+
/** Public signature of the dynamically-loaded `runLambdaLocalRender`. */
37+
export type RunLambdaLocalRender = (input: RunLambdaLocalInput) => Promise<void>;

packages/producer/src/regression-harness-lambda-local.ts

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,8 @@ import type {
4646
SerializableDistributedRenderConfig,
4747
} from "@hyperframes/aws-lambda";
4848

49-
/** Inputs for {@link runLambdaLocalRender}. Same contract as `runDistributedSimulatedRender`. */
50-
export interface RunLambdaLocalInput {
51-
projectDir: string;
52-
tempRoot: string;
53-
renderedOutputPath: string;
54-
fps: 24 | 30 | 60;
55-
/**
56-
* Width/height from the fixture's renderConfig. Forwarded directly to
57-
* the Lambda event so this mode catches drift if the handler ever
58-
* starts honouring `Config.width/height` for canvas sizing rather
59-
* than reading the composition's `data-width`/`data-height`. The
60-
* `distributed-simulated` mode hardcodes 1920×1080 because it
61-
* bypasses the event-serialization boundary; lambda-local goes
62-
* through it, which is the whole point.
63-
*/
64-
width: number;
65-
height: number;
66-
format: "mp4" | "mov" | "png-sequence";
67-
codec?: "h264" | "h265";
68-
chunkSize?: number;
69-
maxParallelChunks?: number;
70-
variables?: Record<string, unknown>;
71-
}
49+
export type { RunLambdaLocalInput } from "./regression-harness-lambda-local-types.js";
50+
import type { RunLambdaLocalInput } from "./regression-harness-lambda-local-types.js";
7251

7352
const FAKE_BUCKET = "harness-lambda-local";
7453

packages/producer/src/regression-harness.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,27 @@ import {
3737
// In Dockerfile.test the workspace copy of aws-lambda's src isn't present,
3838
// so a static import here would fail at module-load time even when
3939
// running `--mode=in-process`. Load it on demand instead.
40-
async function loadLambdaLocalRender(): Promise<
41-
typeof import("./regression-harness-lambda-local.js").runLambdaLocalRender
42-
> {
43-
const mod = await import("./regression-harness-lambda-local.js");
40+
//
41+
// The signature is typed via `RunLambdaLocalRender` (in its own types-only
42+
// file) instead of `typeof import(...)` so producer's tsc doesn't have to
43+
// type-check the implementation. The implementation imports
44+
// `@hyperframes/aws-lambda`, whose types come from `dist/index.d.ts` after
45+
// aws-lambda's build runs — a chicken-and-egg with producer's tsc that
46+
// would otherwise fail the whole-repo build.
47+
//
48+
// The dynamic import path is indirected through a variable so tsc can't
49+
// statically resolve the target file. Without this indirection tsc still
50+
// pulls `regression-harness-lambda-local.ts` (and its `@hyperframes/aws-lambda`
51+
// imports) into the program even though the tsconfig `exclude` list
52+
// nominally hides it. `tsx` resolves the path normally at runtime.
53+
import type { RunLambdaLocalRender } from "./regression-harness-lambda-local-types.js";
54+
55+
const LAMBDA_LOCAL_MODULE = "./regression-harness-lambda-local.js";
56+
57+
async function loadLambdaLocalRender(): Promise<RunLambdaLocalRender> {
58+
const mod = (await import(LAMBDA_LOCAL_MODULE)) as {
59+
runLambdaLocalRender: RunLambdaLocalRender;
60+
};
4461
return mod.runLambdaLocalRender;
4562
}
4663

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:6aba60a5a3919132986e785b89f4b3434d23d337d95958a515b1fe2e11906721
3-
size 5154704
2+
oid sha256:821a6b69e412a09560e9412ce0faaa0b1fe78163a2c520173408d6ac19129d3c
3+
size 8383424

0 commit comments

Comments
 (0)