feat(cli): bake proxies into published archives (#2595)

* feat(studio-server): serve H.264 proxies from the preview route

Wires the codec manifest and the transcoder into the preview surface: the route
negotiates a proxy via a query param and serves it through the existing range
and ETag machinery, composition HTML carries a codec map for the runtime, and
hostile assets pre-warm so a first play does not wait on a cold transcode.
Exposes the three subpath exports the CLI surfaces consume upstack.

Drops the TEMP fallow entry added with the transcoder: it has real importers now.

* fix(studio-server): publish media proxy exports

* fix(parsers): scan HTML comments linearly

* feat(cli): let projects opt out of automatic proxying

Adds media.autoProxy to hyperframes.json plus --proxy/--no-proxy flags, and
forwards the resolved value into the studio and preview servers and the vite
adapter. Lands before the runtime slice that turns auto-proxying on, so the
switch exists before there is any behavior to switch off.

* fix(cli): align media config schema

* feat(core): swap undecodable video to its proxy at runtime

Adds the browser-side half: before first load the runtime consults the injected
codec map and swaps a hostile source to its proxy, and if a video still reports
zero decodable width it rescues it reactively. An HEVC file carrying AAC fires
no error event, so zero videoWidth, not the error event, is the reliable signal.
Audio elements and alpha sources are never proxied, render mode never proxies,
and each swap evicts the element's stale sync state and reports once.

This completes the loop: auto-proxying is live for preview and studio from here.
The opt-out (media.autoProxy, --no-proxy) shipped in the previous slice.

* feat(cli): serve proxies from play, present, and the static project server

Adds proxy negotiation to the CLI-side servers and gives play byte-range
serving it never had, so a swapped video can seek. The static project server
behind check, snapshot, compare and friends injects the codec map once, so all
of its callers inherit the behavior; snapshot forwards its own proxy flag.

* fix(cli): serve proxies for camera formats

* feat(cli): resolve proxies before check's timed browser phase

check pre-resolves hostile assets so a cold transcode cannot exhaust the
render-ready budget, and surfaces the runtime's proxy diagnostics as findings
so a swap is visible rather than silent.

* feat(cli): bake proxies into published archives

Published pages are static, so there is no server to negotiate with: publish
transcodes proxies for hostile assets into the archive and rewrites the video
sources that point at them. Audio elements keep their originals, since audio
decodes independently of the video codec.

Splits the archive build from the zip step so publish can transform between
them. cloud render keeps calling the unchanged composition and still uploads
originals, which its regression test pins.

* fix(cli): harden proxy pre-resolution

* fix(cli): surface publish proxy outcomes

* test(cli): remove ffmpeg from archive guard

* test(cli): normalize publish fixture path
This commit is contained in:
Miguel Ángel
2026-07-17 02:50:28 -04:00
committed by GitHub
parent 4ad582606b
commit 35eff5038b
5 changed files with 574 additions and 10 deletions
+36 -2
View File
@@ -7,7 +7,13 @@ import type { Example } from "./_examples.js";
import { c } from "../ui/colors.js";
import { lintProject } from "../utils/lintProject.js";
import { formatLintFindings } from "../utils/lintFormat.js";
import { publishProjectArchive } from "../utils/publishProject.js";
import {
buildPublishFileMap,
publishProjectArchive,
zipPublishFileMap,
} from "../utils/publishProject.js";
import { bakeMediaProxies } from "../utils/publishProxyBake.js";
import { resolveAutoProxy } from "../utils/projectConfig.js";
import { tryResolveCredential } from "../auth/index.js";
import {
ensureProjectId,
@@ -23,6 +29,7 @@ export const examples: Example[] = [
["Update an existing published project in place", "hyperframes publish --update <url|id>"],
["Publish to a shared team space", "hyperframes publish --space <space-id>"],
["Skip the consent prompt (scripts)", "hyperframes publish --yes"],
["Skip baking H.264 proxies for browser-hostile video codecs", "hyperframes publish --no-proxy"],
];
/** Extract a project id from a published URL (with or without scheme, query, or hash) or accept a bare id. */
@@ -67,6 +74,11 @@ export default defineCommand({
type: "string",
description: "Publish into a shared team space (its id) so teammates update one link",
},
proxy: {
type: "boolean",
description:
"Bake H.264 proxies for browser-hostile video codecs (e.g. HEVC) into the published archive. Default: on, unless disabled via hyperframes.json media.autoProxy. Pass --no-proxy to skip.",
},
},
async run({ args }) {
const rawArg = args.dir;
@@ -137,19 +149,41 @@ export default defineCommand({
clack.intro(c.bold("hyperframes publish"));
const publishSpinner = clack.spinner();
publishSpinner.start("Uploading project...");
publishSpinner.start("Preparing project...");
try {
// Resolution order (per hyperframes.json's `media.autoProxy`): an
// explicit --proxy/--no-proxy flag wins in either direction, else the
// committed config, else on by default.
const proxyFlagValue = typeof args.proxy === "boolean" ? args.proxy : undefined;
const autoProxy = resolveAutoProxy(dir, proxyFlagValue);
const fileMap = buildPublishFileMap(dir);
let proxyBakeManifest: Awaited<ReturnType<typeof bakeMediaProxies>> | undefined;
if (autoProxy) {
proxyBakeManifest = await bakeMediaProxies(dir, fileMap);
}
const archive = zipPublishFileMap(fileMap);
publishSpinner.message("Uploading project...");
const published = await publishProjectArchive(dir, {
public: args.public === true,
projectId: requestedProjectId,
spaceId,
archive,
});
publishSpinner.stop(c.success("Project published"));
console.log();
console.log(` ${c.dim("Project")} ${c.accent(published.title)}`);
console.log(` ${c.dim("Files")} ${String(published.fileCount)}`);
if (proxyBakeManifest) {
console.log(` ${c.dim("Proxies")} ${String(proxyBakeManifest.proxied.length)} baked`);
if (proxyBakeManifest.skippedAlpha.length > 0) {
console.log(
` ${c.dim("Proxy note")} ${String(proxyBakeManifest.skippedAlpha.length)} alpha source(s) kept original`,
);
}
}
if (published.claimed) {
// The server returns the same id on an in-place update, a fresh id on create.