85453da49f
regression / regression-shards (style-16-prod style-9-prod style-17-prod iframe-render-compat variables-prod mp4-h265-sdr, shard-4) (push) Has been cancelled
regression / regression-shards (style-4-prod style-11-prod style-2-prod animejs-adapter typegpu-adapter parallel-capture-regression, shard-5) (push) Has been cancelled
regression / regression-shards (style-7-prod style-8-prod style-10-prod css-spinner-render-compat webm-transparency mp4-h264-sdr webm-vp9, shard-3) (push) Has been cancelled
regression / regression-shards (sub-composition-video style-18-prod raf-ball-render-compat font-variant-numeric sub-comp-t0 sub-comp-id-selector, shard-7) (push) Has been cancelled
Windows render verification / Detect changes (push) Has been cancelled
Windows render verification / Preflight (lint + format) (push) Has been cancelled
Windows render verification / Render on windows-latest (push) Has been cancelled
Windows render verification / Tests on windows-latest (push) Has been cancelled
CI / Detect changes (push) Has been cancelled
CI / Build (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Fallow audit (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / Typecheck (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Producer: integration tests (push) Has been cancelled
CI / Producer: unit tests (push) Has been cancelled
CI / File size check (push) Has been cancelled
CI / Test: skills (push) Has been cancelled
CI / Skills: manifest in sync (push) Has been cancelled
CI / CLI: npx shim (macos-latest) (push) Has been cancelled
CI / CLI: npx shim (ubuntu-latest) (push) Has been cancelled
CI / CLI: npx shim (windows-latest) (push) Has been cancelled
CI / SDK: unit + contract + smoke (push) Has been cancelled
CI / Test: runtime contract (push) Has been cancelled
CI / Studio: load smoke (push) Has been cancelled
CI / Smoke: global install (push) Has been cancelled
CI / CLI smoke (required) (push) Has been cancelled
CI / Semantic PR title (push) Has been cancelled
Player perf / Detect changes (push) Has been cancelled
Player perf / Preflight (lint + format) (push) Has been cancelled
Player perf / player-perf (push) Has been cancelled
Player perf / Perf: drift (push) Has been cancelled
Player perf / Perf: fps (push) Has been cancelled
Player perf / Perf: parity (push) Has been cancelled
Player perf / Perf: scrub (push) Has been cancelled
Player perf / Perf: load (push) Has been cancelled
preview-regression / Detect changes (push) Has been cancelled
preview-regression / Preflight (lint + format) (push) Has been cancelled
preview-regression / Preview parity (push) Has been cancelled
preview-regression / preview-regression (push) Has been cancelled
regression / regression (push) Has been cancelled
regression / Detect changes (push) Has been cancelled
regression / Preflight (lint + format) (push) Has been cancelled
regression / regression-shards (hdr-regression style-5-prod style-3-prod mov-prores, shard-1) (push) Has been cancelled
regression / regression-shards (overlay-montage-prod style-12-prod chat missing-host-comp-id png-sequence portrait-edge-bleed, shard-6) (push) Has been cancelled
regression / regression-shards (style-13-prod style-6-prod vignelli-stacking gsap-letters-render-compat audio-mux-parity, shard-8) (push) Has been cancelled
regression / regression-shards (style-15-prod hdr-hlg-regression style-1-prod many-cuts vfr-screen-recording render-symlinked-assets, shard-2) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Docs / Validate docs (push) Has been cancelled
Sync skills to ClawHub / Publish changed skills (push) Has been cancelled
118 lines
4.1 KiB
TypeScript
118 lines
4.1 KiB
TypeScript
import { defineCommand } from "citty";
|
|
import type { Example } from "./_examples.js";
|
|
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
|
|
export const examples: Example[] = [
|
|
["Show project metadata", "hyperframes info"],
|
|
["Output as JSON", "hyperframes info --json"],
|
|
];
|
|
import { join } from "node:path";
|
|
import { parseHtml, CANVAS_DIMENSIONS } from "@hyperframes/core";
|
|
import { c } from "../ui/colors.js";
|
|
import { formatBytes, label } from "../ui/format.js";
|
|
import { ensureDOMParser } from "../utils/dom.js";
|
|
import { resolveProject } from "../utils/project.js";
|
|
import { withMeta } from "../utils/updateCheck.js";
|
|
|
|
/** Derive orientation label from actual pixel dimensions. */
|
|
export function orientation(width: number, height: number): "landscape" | "portrait" | "square" {
|
|
if (width > height) return "landscape";
|
|
if (height > width) return "portrait";
|
|
return "square";
|
|
}
|
|
|
|
/**
|
|
* Duration of the composition: prefer the root element's data-duration,
|
|
* fall back to the computed timeline end.
|
|
*/
|
|
export function durationFromHtml(html: string, fallback: number): number {
|
|
const match =
|
|
html.match(/data-composition-id[^>]*data-duration=["']([\d.]+)["']/) ||
|
|
html.match(/data-duration=["']([\d.]+)["'][^>]*data-composition-id/);
|
|
const value = match?.[1] ? parseFloat(match[1]) : NaN;
|
|
return Number.isFinite(value) ? value : fallback;
|
|
}
|
|
|
|
function totalSize(dir: string): number {
|
|
let total = 0;
|
|
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
const path = join(dir, entry.name);
|
|
if (entry.isDirectory()) {
|
|
total += totalSize(path);
|
|
} else {
|
|
total += statSync(path).size;
|
|
}
|
|
}
|
|
return total;
|
|
}
|
|
|
|
export default defineCommand({
|
|
meta: { name: "info", description: "Print project metadata" },
|
|
args: {
|
|
dir: { type: "positional", description: "Project directory", required: false },
|
|
json: { type: "boolean", description: "Output as JSON", default: false },
|
|
},
|
|
async run({ args }) {
|
|
const project = resolveProject(args.dir);
|
|
const html = readFileSync(project.indexPath, "utf-8");
|
|
|
|
ensureDOMParser();
|
|
const parsed = parseHtml(html);
|
|
|
|
const tracks = new Set(parsed.elements.map((el) => el.zIndex));
|
|
const maxEnd = parsed.elements.reduce(
|
|
(max, el) => Math.max(max, el.startTime + el.duration),
|
|
0,
|
|
);
|
|
// Read actual dimensions from root composition element
|
|
const widthMatch =
|
|
html.match(/data-composition-id[^>]*data-width=["'](\d+)["']/) ||
|
|
html.match(/data-width=["'](\d+)["'][^>]*data-composition-id/);
|
|
const heightMatch =
|
|
html.match(/data-composition-id[^>]*data-height=["'](\d+)["']/) ||
|
|
html.match(/data-height=["'](\d+)["'][^>]*data-composition-id/);
|
|
const fallback = CANVAS_DIMENSIONS[parsed.resolution];
|
|
const width = widthMatch?.[1] ? parseInt(widthMatch[1], 10) : fallback.width;
|
|
const height = heightMatch?.[1] ? parseInt(heightMatch[1], 10) : fallback.height;
|
|
const resolution = `${width}x${height}`;
|
|
const duration = durationFromHtml(html, maxEnd);
|
|
const size = totalSize(project.dir);
|
|
|
|
const typeCounts: Record<string, number> = {};
|
|
for (const el of parsed.elements) {
|
|
typeCounts[el.type] = (typeCounts[el.type] ?? 0) + 1;
|
|
}
|
|
const typeStr = Object.entries(typeCounts)
|
|
.map(([t, count]) => `${count} ${t}`)
|
|
.join(", ");
|
|
|
|
if (args.json) {
|
|
console.log(
|
|
JSON.stringify(
|
|
withMeta({
|
|
name: project.name,
|
|
resolution: orientation(width, height),
|
|
width,
|
|
height,
|
|
duration,
|
|
elements: parsed.elements.length,
|
|
tracks: tracks.size,
|
|
types: typeCounts,
|
|
size,
|
|
}),
|
|
null,
|
|
2,
|
|
),
|
|
);
|
|
return;
|
|
}
|
|
|
|
console.log(`${c.success("◇")} ${c.accent(project.name)}`);
|
|
console.log(label("Resolution", resolution));
|
|
console.log(label("Duration", `${duration.toFixed(1)}s`));
|
|
console.log(label("Elements", `${parsed.elements.length}${typeStr ? ` (${typeStr})` : ""}`));
|
|
console.log(label("Tracks", `${tracks.size}`));
|
|
console.log(label("Size", formatBytes(size)));
|
|
},
|
|
});
|