Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions packages/cli/src/commands/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,20 @@ export default defineCommand({
ensureDOMParser();
const parsed = parseHtml(html);

// Read actual dimensions from root composition element via DOM query
// (same approach as compositions.ts — avoids regex matching wrong element)
const parser = new DOMParser();
const doc = parser.parseFromString(html, "text/html");
const root = doc.querySelector("[data-composition-id]");
const width = parseInt(root?.getAttribute("data-width") ?? "1920", 10);
const height = parseInt(root?.getAttribute("data-height") ?? "1080", 10);
const resolution = width > height ? "landscape" : "portrait";

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,
);
const resolution = parsed.resolution === "portrait" ? "1080x1920" : "1920x1080";
const size = totalSize(project.dir);

const typeCounts: Record<string, number> = {};
Expand All @@ -55,9 +63,9 @@ export default defineCommand({
JSON.stringify(
withMeta({
name: project.name,
resolution: parsed.resolution,
width: parsed.resolution === "portrait" ? 1080 : 1920,
height: parsed.resolution === "portrait" ? 1920 : 1080,
resolution: resolution as "landscape" | "portrait",
width,
height,
duration: maxEnd,
elements: parsed.elements.length,
tracks: tracks.size,
Expand All @@ -72,7 +80,7 @@ export default defineCommand({
}

console.log(`${c.success("◇")} ${c.accent(project.name)}`);
console.log(label("Resolution", resolution));
console.log(label("Resolution", `${width}x${height}`));
console.log(label("Duration", `${maxEnd.toFixed(1)}s`));
console.log(label("Elements", `${parsed.elements.length}${typeStr ? ` (${typeStr})` : ""}`));
console.log(label("Tracks", `${tracks.size}`));
Expand Down
Loading