@hyperframes/studio 0.8.199 → 0.8.201

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/assets/{hyperframes-player-BDtBfwof.js → hyperframes-player-BNeO6YSP.js} +1 -1
  2. package/dist/assets/{index-BFfBBQMu.js → index-CZWE0FI8.js} +162 -162
  3. package/dist/assets/{index--W_0fuR8.js → index-DiNYtcMK.js} +1 -1
  4. package/dist/{chunk-ORLUDHTU.js → chunk-J6T4KD7Y.js} +33 -0
  5. package/dist/index.html +1 -1
  6. package/dist/index.js +227 -110
  7. package/dist/player.js +1 -1
  8. package/package.json +8 -8
  9. package/src/components/TimelineToolbar.test.tsx +117 -3
  10. package/src/components/TimelineToolbar.tsx +32 -1
  11. package/src/components/panels/VariablesBindElement.test.tsx +105 -0
  12. package/src/components/panels/VariablesBindElement.tsx +2 -2
  13. package/src/components/panels/VariablesDeclarationForm.test.ts +106 -0
  14. package/src/components/panels/VariablesDeclarationForm.tsx +21 -3
  15. package/src/components/panels/VariablesValueControls.tsx +6 -0
  16. package/src/components/ui/VideoFrameThumbnail.test.tsx +9 -0
  17. package/src/components/ui/VideoFrameThumbnail.tsx +1 -3
  18. package/src/hooks/appHotkeysDispatch.ts +7 -0
  19. package/src/hooks/useAppHotkeys.test.ts +75 -0
  20. package/src/hooks/useDomSelection.ts +5 -1
  21. package/src/player/components/EditModal.test.tsx +34 -0
  22. package/src/player/components/EditModal.tsx +4 -2
  23. package/src/player/components/studioShortcuts.ts +3 -0
  24. package/src/player/components/timelineMotion.test.ts +13 -0
  25. package/src/player/components/timelineMotion.ts +12 -6
  26. package/src/player/components/timelineZoom.test.ts +48 -0
  27. package/src/player/components/timelineZoom.ts +55 -0
  28. package/src/player/components/timelineZoomInput.test.ts +27 -0
  29. package/src/player/components/timelineZoomInput.ts +55 -8
  30. package/src/player/hooks/timelineSyncHydration.test.ts +20 -0
  31. package/src/player/hooks/timelineSyncHydration.ts +13 -2
  32. package/src/player/lib/timelineIframeHelpers.test.ts +41 -0
  33. package/src/player/lib/timelineIframeHelpers.ts +5 -2
  34. package/src/utils/sceneHold.test.ts +29 -0
  35. package/src/utils/sceneHold.ts +21 -0
package/dist/player.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Player
3
- } from "./chunk-ORLUDHTU.js";
3
+ } from "./chunk-J6T4KD7Y.js";
4
4
  import "./chunk-7HZGKFFU.js";
5
5
  import "./chunk-T43DM7Q6.js";
6
6
  import "./chunk-MLKGABMK.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/studio",
3
- "version": "0.8.199",
3
+ "version": "0.8.201",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -60,12 +60,12 @@
60
60
  "dockview-react": "8.3.1",
61
61
  "gsap": "^3.13.0",
62
62
  "mediabunny": "^1.45.3",
63
- "@hyperframes/core": "0.8.199",
64
- "@hyperframes/parsers": "0.8.199",
65
- "@hyperframes/sdk": "0.8.199",
66
- "@hyperframes/player": "0.8.199",
67
- "@hyperframes/shader-transitions": "0.8.199",
68
- "@hyperframes/studio-server": "0.8.199"
63
+ "@hyperframes/core": "0.8.201",
64
+ "@hyperframes/player": "0.8.201",
65
+ "@hyperframes/parsers": "0.8.201",
66
+ "@hyperframes/sdk": "0.8.201",
67
+ "@hyperframes/shader-transitions": "0.8.201",
68
+ "@hyperframes/studio-server": "0.8.201"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@tailwindcss/vite": "^4.3.3",
@@ -82,7 +82,7 @@
82
82
  "vite": "^6.4.2",
83
83
  "vitest": "^4.1.11",
84
84
  "zustand": "^5.0.0",
85
- "@hyperframes/producer": "0.8.199"
85
+ "@hyperframes/producer": "0.8.201"
86
86
  },
87
87
  "peerDependencies": {
88
88
  "react": "19",
@@ -271,11 +271,18 @@ describe("TimelineToolbar Fit", () => {
271
271
  timelineFitPps: 10,
272
272
  timelinePps: 10,
273
273
  });
274
- return registerTimelineZoomViewport({ scroll, contentOrigin: 32, publishScroll: () => {} });
274
+ return {
275
+ scroll,
276
+ unregister: registerTimelineZoomViewport({
277
+ scroll,
278
+ contentOrigin: 32,
279
+ publishScroll: () => {},
280
+ }),
281
+ };
275
282
  }
276
283
 
277
284
  it("moves the slider and its readout with a zoom while it is previewed", () => {
278
- const unregister = mountTimelineViewport();
285
+ const { unregister } = mountTimelineViewport();
279
286
  const { host, root } = renderToolbar();
280
287
  const slider = host.querySelector<HTMLInputElement>('input[aria-label="Timeline zoom"]')!;
281
288
  const before = slider.value;
@@ -296,7 +303,7 @@ describe("TimelineToolbar Fit", () => {
296
303
  });
297
304
 
298
305
  it("keeps Fit when it is picked while a zoom waits to be laid out", () => {
299
- const unregister = mountTimelineViewport();
306
+ const { unregister } = mountTimelineViewport();
300
307
  const { host, root } = renderToolbar();
301
308
  act(() =>
302
309
  host
@@ -315,6 +322,113 @@ describe("TimelineToolbar Fit", () => {
315
322
  act(() => unregister());
316
323
  });
317
324
 
325
+ it("disables zoom-to-selection until a clip is selected", () => {
326
+ usePlayerStore.setState({ selectedElementId: null, selectedElementIds: new Set() });
327
+ const { host, root } = renderToolbar();
328
+ const button = host.querySelector<HTMLButtonElement>(
329
+ 'button[aria-label="Select a clip to zoom the timeline"]',
330
+ );
331
+ expect(button?.disabled).toBe(true);
332
+ act(() => root.unmount());
333
+ });
334
+
335
+ it("disables zoom-to-selection when the selection is not a timeline clip", () => {
336
+ usePlayerStore.setState({
337
+ elements: [{ id: "a", key: "a", tag: "div", start: 0, duration: 4, track: 0 }],
338
+ selectedElementId: "scene.html#child",
339
+ selectedElementIds: new Set(["scene.html#child"]),
340
+ });
341
+ const { host, root } = renderToolbar();
342
+ expect(
343
+ host.querySelector<HTMLButtonElement>(
344
+ 'button[aria-label="Select a clip to zoom the timeline"]',
345
+ )?.disabled,
346
+ ).toBe(true);
347
+ act(() => root.unmount());
348
+ });
349
+
350
+ it("disables zoom-to-selection when every selected clip has no duration", () => {
351
+ usePlayerStore.setState({
352
+ elements: [{ id: "a", key: "a", tag: "div", start: 2, duration: 0, track: 0 }],
353
+ selectedElementId: "a",
354
+ selectedElementIds: new Set(["a"]),
355
+ });
356
+ const { host, root } = renderToolbar();
357
+ expect(
358
+ host.querySelector<HTMLButtonElement>(
359
+ 'button[aria-label="Select a clip to zoom the timeline"]',
360
+ )?.disabled,
361
+ ).toBe(true);
362
+ act(() => root.unmount());
363
+ });
364
+
365
+ function clickZoom(host: HTMLElement) {
366
+ act(() => {
367
+ host
368
+ .querySelector('button[aria-label="Zoom to selected clips"]')
369
+ ?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
370
+ });
371
+ act(() => {
372
+ for (let i = 0; i < 30; i++) vi.advanceTimersToNextFrame();
373
+ });
374
+ }
375
+
376
+ it("zooms the mounted timeline so the selected clips fill the width between the margins", () => {
377
+ const { scroll, unregister } = mountTimelineViewport();
378
+ usePlayerStore.setState({
379
+ elements: [{ id: "a", key: "a", tag: "div", start: 10, duration: 20, track: 0 }],
380
+ selectedElementId: "a",
381
+ selectedElementIds: new Set(["a"]),
382
+ });
383
+ const { host, root } = renderToolbar();
384
+ clickZoom(host);
385
+ const pps = usePlayerStore.getState().timelinePps;
386
+ expect(pps).toBeCloseTo(50);
387
+ expect(32 + 10 * pps - scroll.scrollLeft).toBeCloseTo(56);
388
+ expect(32 + 30 * pps - scroll.scrollLeft).toBeCloseTo(1056);
389
+ act(() => root.unmount());
390
+ act(() => unregister());
391
+ usePlayerStore.setState({
392
+ elements: [],
393
+ selectedElementId: null,
394
+ selectedElementIds: new Set(),
395
+ });
396
+ });
397
+
398
+ it("keeps a clip at the start on screen without scrolling past zero", () => {
399
+ const { scroll, unregister } = mountTimelineViewport();
400
+ usePlayerStore.setState({
401
+ elements: [{ id: "a", key: "a", tag: "div", start: 0, duration: 10, track: 0 }],
402
+ selectedElementId: "a",
403
+ selectedElementIds: new Set(["a"]),
404
+ });
405
+ const { host, root } = renderToolbar();
406
+ clickZoom(host);
407
+ expect(scroll.scrollLeft).toBe(0);
408
+ const pps = usePlayerStore.getState().timelinePps;
409
+ expect(32 + 10 * pps).toBeLessThanOrEqual(1080);
410
+ act(() => root.unmount());
411
+ act(() => unregister());
412
+ });
413
+
414
+ it("keeps a clip at the end of the fit span inside the viewport", () => {
415
+ const end = (1080 - 32 - 2) / 10;
416
+ const { scroll, unregister } = mountTimelineViewport();
417
+ usePlayerStore.setState({
418
+ elements: [{ id: "a", key: "a", tag: "div", start: end - 10, duration: 10, track: 0 }],
419
+ selectedElementId: "a",
420
+ selectedElementIds: new Set(["a"]),
421
+ });
422
+ const { host, root } = renderToolbar();
423
+ clickZoom(host);
424
+ const pps = usePlayerStore.getState().timelinePps;
425
+ expect(scroll.scrollLeft).toBeGreaterThan(0);
426
+ expect(32 + (end - 10) * pps - scroll.scrollLeft).toBeGreaterThanOrEqual(0);
427
+ expect(32 + end * pps - scroll.scrollLeft).toBeLessThanOrEqual(1080);
428
+ act(() => root.unmount());
429
+ act(() => unregister());
430
+ });
431
+
318
432
  it("shows Fit as a named icon and says whether fit is on", () => {
319
433
  const { host, root } = renderToolbar();
320
434
  const fit = () => host.querySelector('button[aria-label="Fit timeline to width"]');
@@ -1,6 +1,7 @@
1
1
  import { memo, useEffect, useRef, type ReactNode } from "react";
2
2
  import {
3
3
  ArrowsOutLineHorizontal,
4
+ FrameCorners,
4
5
  Image,
5
6
  Magnet,
6
7
  MagnifyingGlassMinus,
@@ -19,8 +20,10 @@ import {
19
20
  } from "../player/components/timelineZoom";
20
21
  import { useTimelineZoom } from "../player/components/useTimelineZoom";
21
22
  import {
23
+ canZoomToSelectedClips,
22
24
  useShownTimelineZoomPercent,
23
25
  zoomTimelineStep,
26
+ zoomTimelineToSelectedClips,
24
27
  } from "../player/components/timelineZoomInput";
25
28
  import { usePlayerStore, type TimelineElement } from "../player";
26
29
  import { Tooltip } from "./ui";
@@ -37,7 +40,10 @@ import { LinkedSelectionToggle } from "./LinkedSelectionToggle";
37
40
  import { useProjectHasAudio } from "../utils/audioMeterMath";
38
41
  import { canAddBeatAt, addBeatAtCompositionTime } from "../utils/beatEditActions";
39
42
  import { isTypingTarget } from "../utils/typingTarget";
40
- import { SPLIT_SHORTCUT_HINT } from "../player/components/studioShortcuts";
43
+ import {
44
+ SPLIT_SHORTCUT_HINT,
45
+ ZOOM_SELECTION_SHORTCUT_HINT,
46
+ } from "../player/components/studioShortcuts";
41
47
  import type { TimelineProps } from "../player/components/TimelineTypes";
42
48
 
43
49
  interface DomEditSessionSlice extends EnableKeyframesSession {
@@ -174,7 +180,13 @@ export const TimelineToolbar = memo(function TimelineToolbar({
174
180
  const beatAnalysisReady = usePlayerStore((s) => s.beatAnalysis !== null);
175
181
  // Subscribed, so the split button follows the selection, not only playhead ticks.
176
182
  const selectedElementId = usePlayerStore((s) => s.selectedElementId);
183
+ const selectedElementIds = usePlayerStore((s) => s.selectedElementIds);
177
184
  const elements = usePlayerStore((s) => s.elements);
185
+ const canZoomSelection = canZoomToSelectedClips({
186
+ elements,
187
+ selectedElementId,
188
+ selectedElementIds,
189
+ });
178
190
  const timelineFitPps = usePlayerStore((s) => s.timelineFitPps);
179
191
  const { zoomMode, setZoomMode, setManualZoomPercent } = useTimelineZoom();
180
192
  const displayedTimelineZoomPercent = useShownTimelineZoomPercent();
@@ -487,6 +499,25 @@ export const TimelineToolbar = memo(function TimelineToolbar({
487
499
  <Image size={16} aria-hidden="true" />
488
500
  </button>
489
501
  </Tooltip>
502
+ <Tooltip
503
+ label={
504
+ canZoomSelection
505
+ ? `Zoom to selected clips (${ZOOM_SELECTION_SHORTCUT_HINT})`
506
+ : "Select a clip to zoom the timeline"
507
+ }
508
+ >
509
+ <button
510
+ type="button"
511
+ disabled={!canZoomSelection}
512
+ aria-label={
513
+ canZoomSelection ? "Zoom to selected clips" : "Select a clip to zoom the timeline"
514
+ }
515
+ onClick={() => zoomTimelineToSelectedClips()}
516
+ className={canZoomSelection ? flatIdle : flatDisabled}
517
+ >
518
+ <FrameCorners size={16} aria-hidden="true" />
519
+ </button>
520
+ </Tooltip>
490
521
  <Tooltip label="Fit timeline to width">
491
522
  <button
492
523
  type="button"
@@ -0,0 +1,105 @@
1
+ // @vitest-environment happy-dom
2
+
3
+ import { act } from "react";
4
+ import { createRoot } from "react-dom/client";
5
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
6
+ import { openComposition } from "@hyperframes/sdk";
7
+ import type { CompositionVariable } from "@hyperframes/sdk";
8
+ import type { DomEditSelection } from "../editor/domEditingTypes";
9
+ import { VariablesBindElement } from "./VariablesBindElement";
10
+
11
+ beforeEach(() => vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true));
12
+ afterEach(() => vi.unstubAllGlobals());
13
+
14
+ const cases = [
15
+ {
16
+ declaration: {
17
+ id: "selected-font",
18
+ label: "Brand font",
19
+ type: "font",
20
+ default: { name: "Brand Sans", source: "assets/brand.css" },
21
+ },
22
+ expected: "Brand Sans",
23
+ },
24
+ {
25
+ declaration: {
26
+ id: "selected",
27
+ label: "Brand logo",
28
+ type: "image",
29
+ default: { url: "assets/logo.svg", alt: "Brand logo", fit: "contain" },
30
+ },
31
+ expected: "assets/logo.svg",
32
+ },
33
+ {
34
+ declaration: { id: "selected-font", label: "Font", type: "font", default: "serif" },
35
+ expected: "serif",
36
+ },
37
+ {
38
+ declaration: { id: "selected", label: "Logo", type: "image", default: "fallback.svg" },
39
+ expected: "fallback.svg",
40
+ },
41
+ ] satisfies { declaration: CompositionVariable; expected: string }[];
42
+
43
+ describe("VariablesBindElement existing defaults", () => {
44
+ it.each(cases)(
45
+ "shows $expected when binding to a $declaration.type",
46
+ async ({ declaration, expected }) => {
47
+ const session = await openComposition(
48
+ '<html><body><img id="selected" data-hf-id="hf-selected" src="own.svg"></body></html>',
49
+ );
50
+ session.declareVariable(declaration);
51
+ const selection: DomEditSelection = {
52
+ hfId: "hf-selected",
53
+ element: document.createElement("img"),
54
+ label: "Selected image",
55
+ tagName: "IMG",
56
+ sourceFile: "index.html",
57
+ compositionPath: "index.html",
58
+ isCompositionHost: false,
59
+ isInsideLockedComposition: false,
60
+ boundingBox: { x: 0, y: 0, width: 100, height: 100 },
61
+ textContent: null,
62
+ dataAttributes: {},
63
+ inlineStyles: {},
64
+ computedStyles: {},
65
+ textFields: [],
66
+ capabilities: {
67
+ canSelect: true,
68
+ canEditStyles: true,
69
+ canCrop: false,
70
+ canMove: false,
71
+ canResize: false,
72
+ canApplyManualOffset: false,
73
+ canApplyManualSize: false,
74
+ canApplyManualRotation: false,
75
+ },
76
+ };
77
+ const host = document.createElement("div");
78
+ document.body.append(host);
79
+ const root = createRoot(host);
80
+ const onBind = vi.fn();
81
+ try {
82
+ await act(async () => {
83
+ root.render(
84
+ <VariablesBindElement selection={selection} sdkSession={session} onBind={onBind} />,
85
+ );
86
+ });
87
+ const label = declaration.type === "font" ? "Font" : "Image source";
88
+ const action = [...host.querySelectorAll("button")].find((button) =>
89
+ button.textContent?.startsWith(label),
90
+ );
91
+ if (!action) throw new Error(`Missing ${label} bind action`);
92
+ await act(async () => action.click());
93
+ const warning = host.querySelector("p.text-warning-ink");
94
+ expect(warning?.textContent).toContain(`"${declaration.id}" already exists.`);
95
+ expect(warning?.querySelector("span")?.textContent).toBe(` (${expected})`);
96
+ expect(onBind).not.toHaveBeenCalled();
97
+ expect(session.getVariableDeclarations()).toEqual([declaration]);
98
+ } finally {
99
+ await act(async () => root.unmount());
100
+ host.remove();
101
+ session.dispose();
102
+ }
103
+ },
104
+ );
105
+ });
@@ -13,7 +13,7 @@ import { useMemo, useState } from "react";
13
13
  import type { Composition, CompositionVariable } from "@hyperframes/sdk";
14
14
  import type { DomEditSelection } from "../editor/domEditingTypes";
15
15
 
16
- import { VARIABLES_INPUT_CLASS } from "./VariablesValueControls";
16
+ import { variableDefaultText, VARIABLES_INPUT_CLASS } from "./VariablesValueControls";
17
17
 
18
18
  // <source> is deliberately excluded: rewriting a <source> child's src after
19
19
  // the parent media element ran resource selection is a spec no-op.
@@ -218,7 +218,7 @@ export function VariablesBindElement({
218
218
  <p className="text-[9px] leading-snug text-warning-ink">
219
219
  "{trimmedId}" already exists. This element will use its current value
220
220
  {existingDecl.default !== undefined && (
221
- <span className="font-mono"> ({String(existingDecl.default)})</span>
221
+ <span className="font-mono"> ({variableDefaultText(existingDecl)})</span>
222
222
  )}
223
223
  , not the element's own, so binding won't change "{trimmedId}".
224
224
  </p>
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import { describe, it, expect } from "vitest";
8
+ import { createMemoryAdapter, openComposition } from "@hyperframes/sdk";
8
9
  import {
9
10
  mergeDeclarationEdit,
10
11
  declarationFromDraft,
@@ -13,6 +14,32 @@ import {
13
14
  } from "./VariablesDeclarationForm.js";
14
15
  import type { CompositionVariable } from "@hyperframes/core/variables";
15
16
 
17
+ const fontDefault = {
18
+ name: "monospace",
19
+ source: "assets/brand.css",
20
+ vendor: { familyId: "brand", weights: [400, 700] },
21
+ };
22
+ const imageDefault = {
23
+ url: "assets/logo.svg",
24
+ alt: "Brand logo",
25
+ fit: "contain" as const,
26
+ vendor: { assetId: "logo", crop: { x: 0, y: 1 } },
27
+ };
28
+ const objectDeclarations = [
29
+ {
30
+ id: "font",
31
+ type: "font",
32
+ label: "Brand font",
33
+ default: fontDefault,
34
+ },
35
+ {
36
+ id: "logo",
37
+ type: "image",
38
+ label: "Brand logo",
39
+ default: imageDefault,
40
+ },
41
+ ] satisfies CompositionVariable[];
42
+
16
43
  describe("mergeDeclarationEdit", () => {
17
44
  it("preserves unmodeled keys on a same-type edit", () => {
18
45
  // The form owns id/label/type/default/description/min/max/step/options; every
@@ -64,6 +91,85 @@ describe("mergeDeclarationEdit", () => {
64
91
  });
65
92
 
66
93
  describe("declarationFromDraft", () => {
94
+ for (const original of objectDeclarations) {
95
+ it.each(["label", "description"])(
96
+ `preserves the ${original.type} object on a %s-only edit through save/reopen`,
97
+ async (field) => {
98
+ const draft = draftFromDeclaration(original);
99
+ expect(draft.defaultRaw).toBe(
100
+ original.type === "font" ? original.default.name : original.default.url,
101
+ );
102
+ const edited = declarationFromDraft({ ...draft, [field]: "Updated metadata" });
103
+ if (typeof edited === "string") throw new Error(edited);
104
+ const merged = mergeDeclarationEdit(original, edited);
105
+ expect(merged).toEqual({ ...original, [field]: "Updated metadata" });
106
+
107
+ const persist = createMemoryAdapter();
108
+ const session = await openComposition("<html><body></body></html>", {
109
+ persist,
110
+ coalesceMs: 0,
111
+ });
112
+ session.declareVariable(original);
113
+ session.updateVariableDeclaration(original.id, merged);
114
+ await session.flush();
115
+ const reopened = await openComposition(await persist.read("composition.html"));
116
+ try {
117
+ expect(reopened.getVariableValue(original.id)).toEqual(original.default);
118
+ expect(reopened.getVariableDeclarations()).toEqual([merged]);
119
+ } finally {
120
+ reopened.dispose();
121
+ session.dispose();
122
+ }
123
+ },
124
+ );
125
+
126
+ it(`edits only the primary ${original.type} value`, () => {
127
+ const edited = declarationFromDraft({
128
+ ...draftFromDeclaration(original),
129
+ defaultRaw: "replacement",
130
+ });
131
+ if (typeof edited === "string") throw new Error(edited);
132
+ expect(mergeDeclarationEdit(original, edited).default).toEqual({
133
+ ...original.default,
134
+ ...(original.type === "font" ? { name: "replacement" } : { url: "replacement" }),
135
+ });
136
+ });
137
+
138
+ it(`drops the ${original.type} object when changing type`, () => {
139
+ const edited = declarationFromDraft({
140
+ ...draftFromDeclaration(original),
141
+ type: original.type === "font" ? "image" : "font",
142
+ defaultRaw: "replacement",
143
+ });
144
+ if (typeof edited === "string") throw new Error(edited);
145
+ expect(mergeDeclarationEdit(original, edited)).toEqual({
146
+ id: original.id,
147
+ label: original.label,
148
+ type: original.type === "font" ? "image" : "font",
149
+ default: "replacement",
150
+ });
151
+ });
152
+ }
153
+
154
+ it.each(["font", "image"] as const)("keeps %s string defaults scalar", (type) => {
155
+ const original: CompositionVariable = {
156
+ id: "brand",
157
+ label: "Brand",
158
+ type,
159
+ default: "fallback",
160
+ };
161
+ expect(declarationFromDraft(draftFromDeclaration(original))).toEqual(original);
162
+ expect(
163
+ declarationFromDraft({
164
+ ...EMPTY_DRAFT,
165
+ id: "brand",
166
+ label: "Brand",
167
+ type,
168
+ defaultRaw: "fallback",
169
+ }),
170
+ ).toEqual(original);
171
+ });
172
+
67
173
  it("requires a non-empty id", () => {
68
174
  expect(declarationFromDraft({ ...EMPTY_DRAFT, id: " " })).toBe("Variable id is required.");
69
175
  });
@@ -6,7 +6,7 @@
6
6
 
7
7
  import { useState } from "react";
8
8
  import type { CompositionVariable, CompositionVariableType } from "@hyperframes/sdk";
9
- import { VARIABLES_INPUT_CLASS } from "./VariablesValueControls";
9
+ import { variableDefaultText, VARIABLES_INPUT_CLASS } from "./VariablesValueControls";
10
10
 
11
11
  const VARIABLE_TYPES: CompositionVariableType[] = [
12
12
  "string",
@@ -19,6 +19,7 @@ const VARIABLE_TYPES: CompositionVariableType[] = [
19
19
  ];
20
20
 
21
21
  export interface DeclarationDraft {
22
+ original?: CompositionVariable;
22
23
  id: string;
23
24
  label: string;
24
25
  type: CompositionVariableType;
@@ -48,10 +49,11 @@ export function draftFromDeclaration(decl: CompositionVariable): DeclarationDraf
48
49
  const numeric = decl.type === "number" ? decl : null;
49
50
  return {
50
51
  ...EMPTY_DRAFT,
52
+ original: decl,
51
53
  id: decl.id,
52
54
  label: decl.label,
53
55
  type: decl.type,
54
- defaultRaw: String(decl.default),
56
+ defaultRaw: variableDefaultText(decl),
55
57
  description: decl.description ?? "",
56
58
  min: numeric?.min !== undefined ? String(numeric.min) : "",
57
59
  max: numeric?.max !== undefined ? String(numeric.max) : "",
@@ -153,8 +155,24 @@ export function declarationFromDraft(draft: DeclarationDraft): CompositionVariab
153
155
  return { ...base, type: "boolean", default: draft.defaultRaw.trim() === "true" };
154
156
  case "enum":
155
157
  return enumDeclFromDraft(base, draft);
158
+ case "font": {
159
+ const value = draft.original?.type === "font" ? draft.original.default : undefined;
160
+ return {
161
+ ...base,
162
+ type: "font",
163
+ default:
164
+ typeof value === "object" ? { ...value, name: draft.defaultRaw } : draft.defaultRaw,
165
+ };
166
+ }
167
+ case "image": {
168
+ const value = draft.original?.type === "image" ? draft.original.default : undefined;
169
+ return {
170
+ ...base,
171
+ type: "image",
172
+ default: typeof value === "object" ? { ...value, url: draft.defaultRaw } : draft.defaultRaw,
173
+ };
174
+ }
156
175
  default:
157
- // string / color / font / image — string default, verbatim.
158
176
  return { ...base, type: draft.type, default: draft.defaultRaw };
159
177
  }
160
178
  }
@@ -16,6 +16,12 @@ import type {
16
16
  export const VARIABLES_INPUT_CLASS =
17
17
  "w-full bg-neutral-900 border border-neutral-800 rounded-sm px-2 py-1 text-[10px] text-neutral-200 focus:outline-hidden focus:border-neutral-700";
18
18
 
19
+ export function variableDefaultText(decl: CompositionVariable): string {
20
+ if (decl.type === "font" && typeof decl.default === "object") return decl.default.name;
21
+ if (decl.type === "image" && typeof decl.default === "object") return decl.default.url;
22
+ return String(decl.default);
23
+ }
24
+
19
25
  /** Text input that drafts locally and commits on blur/Enter. */
20
26
  function DraftTextInput({
21
27
  value,
@@ -161,6 +161,15 @@ describe("VideoFrameThumbnail", () => {
161
161
  expect(video.loadCalls).toBe(2);
162
162
  });
163
163
 
164
+ it("shows a still, full-size placeholder while the frame loads", () => {
165
+ render({ src: "clip.mp4" });
166
+ const placeholder = container.querySelector("[data-thumbnail-loading]");
167
+ expect(placeholder).not.toBeNull();
168
+ expect(placeholder?.className).not.toMatch(/\banimate-/);
169
+ expect(placeholder?.classList.contains("w-full")).toBe(true);
170
+ expect(placeholder?.classList.contains("h-full")).toBe(true);
171
+ });
172
+
164
173
  it("retries with a fresh video element when src changes", () => {
165
174
  render({ src: "a.mp4" });
166
175
  act(() => root.render(<VideoFrameThumbnail src="b.mp4" />));
@@ -69,9 +69,7 @@ export function VideoFrameThumbnail({
69
69
  }
70
70
 
71
71
  if (!frame) {
72
- return (
73
- <div className="w-full h-full bg-neutral-800 animate-pulse motion-reduce:animate-none" />
74
- );
72
+ return <div data-thumbnail-loading className="w-full h-full bg-panel-surface" />;
75
73
  }
76
74
 
77
75
  return <img src={frame} alt="" draggable={false} className="w-full h-full object-contain" />;
@@ -9,6 +9,7 @@ import { shouldIgnoreHistoryShortcut } from "../utils/studioHelpers";
9
9
  import { canSplitElement } from "../utils/timelineElementSplit";
10
10
  import { trackStudioEvent } from "../utils/studioTelemetry";
11
11
  import { STUDIO_PLAIN_KEYS } from "../player/components/studioShortcuts";
12
+ import { zoomTimelineToSelectedClips } from "../player/components/timelineZoomInput";
12
13
  import { openAudioGainDialog } from "../player/components/audioGainDialogStore";
13
14
  import type { LinkShortcutCallbacks } from "./linkShortcuts";
14
15
 
@@ -156,6 +157,12 @@ export function dispatchModifierKey(
156
157
  * be asserted without standing up the whole hook. */
157
158
  export function dispatchPlainKey(event: KeyboardEvent, key: string, cb: HotkeyCallbacks): void {
158
159
  if (ownsPlainKeys(event.target)) return;
160
+ if (key === STUDIO_PLAIN_KEYS.zoomSelection && !event.shiftKey && !event.altKey) {
161
+ if (!zoomTimelineToSelectedClips()) return;
162
+ event.preventDefault();
163
+ return;
164
+ }
165
+
159
166
  if (key === STUDIO_PLAIN_KEYS.fullscreen && !event.shiftKey && !event.altKey) {
160
167
  event.preventDefault();
161
168
  if (document.fullscreenElement) void document.exitFullscreen();