Skip to content

Commit 26fe3e7

Browse files
committed
fix(studio): clean next alpha inspector artifacts
1 parent 0e0f1dd commit 26fe3e7

20 files changed

Lines changed: 89 additions & 18 deletions

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ packages/core/src/generated/
6363
packages/producer/src/services/fontData.generated.ts
6464

6565
# Test artifacts
66+
qa-artifacts/
6667
my-video/
6768
examples/
6869
packages/studio/data/

‎packages/core/src/core.types.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export const CANVAS_DIMENSIONS = {
2424
portrait: { width: 1080, height: 1920 },
2525
"landscape-4k": { width: 3840, height: 2160 },
2626
"portrait-4k": { width: 2160, height: 3840 },
27+
square: { width: 1080, height: 1080 },
28+
"square-4k": { width: 2160, height: 2160 },
2729
} as const;
2830

2931
// Single source of truth: derive the type from the table so adding a preset
@@ -47,6 +49,9 @@ const RESOLUTION_ALIASES: Record<string, CanvasResolution> = {
4749
"4k": "landscape-4k",
4850
uhd: "landscape-4k",
4951
"4k-portrait": "portrait-4k",
52+
"1080p-square": "square",
53+
"square-1080p": "square",
54+
"4k-square": "square-4k",
5055
};
5156

5257
/**

‎packages/core/src/index.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ describe("@hyperframes/core public API exports", () => {
1010
expect(core.CANVAS_DIMENSIONS.portrait).toEqual({ width: 1080, height: 1920 });
1111
expect(core.CANVAS_DIMENSIONS["landscape-4k"]).toEqual({ width: 3840, height: 2160 });
1212
expect(core.CANVAS_DIMENSIONS["portrait-4k"]).toEqual({ width: 2160, height: 3840 });
13+
expect(core.CANVAS_DIMENSIONS.square).toEqual({ width: 1080, height: 1080 });
14+
expect(core.CANVAS_DIMENSIONS["square-4k"]).toEqual({ width: 2160, height: 2160 });
1315
});
1416

1517
it("exports VALID_CANVAS_RESOLUTIONS derived from CANVAS_DIMENSIONS", () => {
@@ -18,6 +20,8 @@ describe("@hyperframes/core public API exports", () => {
1820
"portrait",
1921
"landscape-4k",
2022
"portrait-4k",
23+
"square",
24+
"square-4k",
2125
]);
2226
});
2327

@@ -27,6 +31,10 @@ describe("@hyperframes/core public API exports", () => {
2731
expect(core.normalizeResolutionFlag("1080p")).toBe("landscape");
2832
expect(core.normalizeResolutionFlag("landscape-4k")).toBe("landscape-4k");
2933
expect(core.normalizeResolutionFlag("UHD")).toBe("landscape-4k");
34+
expect(core.normalizeResolutionFlag("square")).toBe("square");
35+
expect(core.normalizeResolutionFlag("square-4k")).toBe("square-4k");
36+
expect(core.normalizeResolutionFlag("1080p-square")).toBe("square");
37+
expect(core.normalizeResolutionFlag("4k-square")).toBe("square-4k");
3038
expect(core.normalizeResolutionFlag("8k")).toBeUndefined();
3139
expect(core.normalizeResolutionFlag(undefined)).toBeUndefined();
3240
});

‎packages/core/src/parsers/htmlParser.test.ts‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,7 @@ describe("parseHtml", () => {
275275
expect(result.resolution).toBe("landscape");
276276
});
277277

278-
it("classifies square compositions as portrait by convention", () => {
279-
// 1080×1080 has no obvious orientation. The parser collapses the tie to
280-
// portrait — same bias the prior `w > h ? landscape : portrait` ternary
281-
// had. Pinning so a future refactor doesn't silently flip it.
278+
it("infers square resolution from equal width/height", () => {
282279
const html = `
283280
<html data-composition-width="1080" data-composition-height="1080">
284281
<body>
@@ -290,7 +287,22 @@ describe("parseHtml", () => {
290287
`;
291288
const result = parseHtml(html);
292289

293-
expect(result.resolution).toBe("portrait");
290+
expect(result.resolution).toBe("square");
291+
});
292+
293+
it("infers square-4k from equal width/height >= 2160", () => {
294+
const html = `
295+
<html data-composition-width="2160" data-composition-height="2160">
296+
<body>
297+
<div id="stage">
298+
<div id="text1" data-start="0" data-end="5"><div>Hello</div></div>
299+
</div>
300+
</body>
301+
</html>
302+
`;
303+
const result = parseHtml(html);
304+
305+
expect(result.resolution).toBe("square-4k");
294306
});
295307

296308
it("extracts x, y, scale, opacity from data attributes", () => {

‎packages/core/src/parsers/htmlParser.ts‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ function parseResolutionFromHtml(doc: Document): CanvasResolution | null {
124124
resolutionAttr === "landscape" ||
125125
resolutionAttr === "portrait" ||
126126
resolutionAttr === "landscape-4k" ||
127-
resolutionAttr === "portrait-4k"
127+
resolutionAttr === "portrait-4k" ||
128+
resolutionAttr === "square" ||
129+
resolutionAttr === "square-4k"
128130
) {
129131
return resolutionAttr;
130132
}
@@ -143,17 +145,17 @@ function parseResolutionFromHtml(doc: Document): CanvasResolution | null {
143145
}
144146

145147
function resolveResolutionFromDimensions(width: number, height: number): CanvasResolution {
146-
// `width === height` (square) falls into the portrait branch by convention —
147-
// the same bias the previous `w > h ? landscape : portrait` ternary used.
148-
// Square compositions are rare; pick portrait-as-default so we don't surprise
149-
// the existing call sites that depend on this behavior.
150-
const isLandscape = width > height;
151148
const longSide = Math.max(width, height);
152-
// UHD cutoff is the long side of `landscape-4k` / `portrait-4k` (3840). A
153-
// looser threshold (e.g. ≥ 2560) would silently misclassify QHD/1440p
154-
// (2560×1440) as 4K, which is the wrong default for a common authoring
155-
// resolution closer to 1080p than to UHD. Authors who genuinely want the
156-
// 4K preset can still set `data-resolution="landscape-4k"` explicitly.
149+
// UHD cutoff is the long side of the 4K presets (3840 for `landscape-4k` /
150+
// `portrait-4k`, 2160 for `square-4k`). A looser threshold (e.g. >= 2560)
151+
// would silently misclassify QHD/1440p (2560x1440) as 4K, which is the
152+
// wrong default for a common authoring resolution closer to 1080p than to
153+
// UHD. Authors who genuinely want the 4K preset can still set
154+
// `data-resolution="..."` explicitly.
155+
if (width === height) {
156+
return longSide >= 2160 ? "square-4k" : "square";
157+
}
158+
const isLandscape = width > height;
157159
const isUhd = longSide >= 3840;
158160
if (isLandscape) return isUhd ? "landscape-4k" : "landscape";
159161
return isUhd ? "portrait-4k" : "portrait";

‎packages/studio/src/App.tsx‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ function getTimelineElementLabel(element: TimelineElement): string {
157157
return element.label || element.id || element.tag;
158158
}
159159

160+
function confirmElementDelete(label: string, kind: "timeline clip" | "element"): boolean {
161+
return window.confirm(
162+
`Delete ${kind} "${label}"?\n\nThis removes it from the project source. You can use Undo to restore it.`,
163+
);
164+
}
165+
160166
type RightPanelTab = "design" | "motion" | "renders";
161167

162168
const GENERIC_FONT_FAMILIES = new Set([
@@ -1780,6 +1786,8 @@ export function StudioApp() {
17801786
async (element: TimelineElement) => {
17811787
const pid = projectIdRef.current;
17821788
if (!pid) throw new Error("No active project");
1789+
const label = getTimelineElementLabel(element);
1790+
if (!confirmElementDelete(label, "timeline clip")) return;
17831791

17841792
const targetPath = element.sourceFile || activeCompPath || "index.html";
17851793
try {
@@ -1877,6 +1885,7 @@ export function StudioApp() {
18771885
);
18781886
usePlayerStore.getState().setSelectedElementId(null);
18791887
setRefreshKey((k) => k + 1);
1888+
showToast(`Deleted ${label}. Use Undo to restore it.`, "info");
18801889
} catch (error) {
18811890
const message = error instanceof Error ? error.message : "Failed to delete timeline clip";
18821891
showToast(message);
@@ -1889,6 +1898,8 @@ export function StudioApp() {
18891898
async (selection: DomEditSelection) => {
18901899
const pid = projectIdRef.current;
18911900
if (!pid) return;
1901+
const label = selection.label || selection.id || selection.selector || selection.tagName;
1902+
if (!confirmElementDelete(label, "element")) return;
18921903

18931904
const targetPath = selection.sourceFile || activeCompPath || "index.html";
18941905
try {
@@ -1946,6 +1957,7 @@ export function StudioApp() {
19461957
setDomEditGroupSelections([]);
19471958
usePlayerStore.getState().setSelectedElementId(null);
19481959
setRefreshKey((k) => k + 1);
1960+
showToast(`Deleted ${label}. Use Undo to restore it.`, "info");
19491961
} catch (error) {
19501962
const message = error instanceof Error ? error.message : "Failed to delete element";
19511963
showToast(message);

‎packages/studio/src/components/editor/PropertyPanel.tsx‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,31 @@ export function buildStrokeStyleUpdates(
336336
return updates;
337337
}
338338

339+
export function isPropertyPanelMediaLikeSelection(input: {
340+
tagName: string;
341+
styles: Record<string, string | undefined>;
342+
}): boolean {
343+
const tagName = input.tagName.toLowerCase();
344+
if (tagName === "img" || tagName === "video") return true;
345+
const backgroundImage = input.styles["background-image"]?.trim();
346+
return Boolean(backgroundImage && backgroundImage !== "none");
347+
}
348+
349+
export function getPropertyPanelVisibleSections(input: {
350+
hasSelection: boolean;
351+
canEditStyles: boolean;
352+
hasTextControls: boolean;
353+
hasColorControls: boolean;
354+
}): string[] {
355+
if (!input.hasSelection || !input.canEditStyles) return [];
356+
const sections: string[] = [];
357+
if (input.hasTextControls) sections.push("Text");
358+
sections.push("Layout");
359+
if (input.hasColorControls) sections.push("Colors");
360+
sections.push("Radius", "Shadow");
361+
return sections;
362+
}
363+
339364
function buildClipPathValue(
340365
preset: "none" | "inset" | "circle" | "custom",
341366
radiusValue: number,

‎packages/studio/src/components/renders/useRenderQueue.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@ export interface RenderJob {
1414
// Mirrors `CanvasResolution` from @hyperframes/core. Kept local because
1515
// studio's tsconfig doesn't include node types, and the core barrel
1616
// transitively pulls in modules with `node:fs` imports. Drift risk is
17-
// low (4 string literals tied to a stable enum).
18-
export type ResolutionPreset = "landscape" | "portrait" | "landscape-4k" | "portrait-4k";
17+
// low (string literals tied to a stable enum).
18+
export type ResolutionPreset =
19+
| "landscape"
20+
| "portrait"
21+
| "landscape-4k"
22+
| "portrait-4k"
23+
| "square"
24+
| "square-4k";
1925

2026
export interface StartRenderOptions {
2127
fps?: number;
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)