@hyperframes/studio 0.8.140 → 0.8.141

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/studio",
3
- "version": "0.8.140",
3
+ "version": "0.8.141",
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.140",
64
- "@hyperframes/parsers": "0.8.140",
65
- "@hyperframes/sdk": "0.8.140",
66
- "@hyperframes/player": "0.8.140",
67
- "@hyperframes/studio-server": "0.8.140",
68
- "@hyperframes/shader-transitions": "0.8.140"
63
+ "@hyperframes/core": "0.8.141",
64
+ "@hyperframes/player": "0.8.141",
65
+ "@hyperframes/parsers": "0.8.141",
66
+ "@hyperframes/sdk": "0.8.141",
67
+ "@hyperframes/shader-transitions": "0.8.141",
68
+ "@hyperframes/studio-server": "0.8.141"
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.140"
85
+ "@hyperframes/producer": "0.8.141"
86
86
  },
87
87
  "peerDependencies": {
88
88
  "react": "19",
@@ -344,6 +344,22 @@ describe("NLEPreview", () => {
344
344
  view.cleanup();
345
345
  });
346
346
 
347
+ it("tells the preview how large it shows once a zoom settles, which the player cannot see", () => {
348
+ const view = renderPreview();
349
+ const frame = view.host.querySelector<HTMLElement>('[data-testid="mock-player"]')!;
350
+ const postMessage = vi.fn();
351
+ Object.defineProperty(frame, "contentWindow", { value: { postMessage } });
352
+ Object.defineProperty(frame, "offsetWidth", { value: 800 });
353
+ frame.getBoundingClientRect = () => ({ width: 1600 }) as DOMRect;
354
+
355
+ pinchIn(view, 10);
356
+ expect(postMessage).toHaveBeenLastCalledWith(
357
+ expect.objectContaining({ action: "set-display-scale", scale: 2 }),
358
+ "*",
359
+ );
360
+ view.cleanup();
361
+ });
362
+
347
363
  it("says how far it is zoomed, shows where in the frame, and Fit puts it back", () => {
348
364
  const view = renderPreview();
349
365
  expect([chip(view), navigator(view)]).toEqual([null, null]);
@@ -12,6 +12,7 @@ import {
12
12
  type RefObject,
13
13
  } from "react";
14
14
  import { Player } from "../../player";
15
+ import { postFrameDisplayScale } from "../../player/lib/runtimeProtocol";
15
16
  import type { NLEContextValue } from "./NLEContext";
16
17
  import {
17
18
  DEFAULT_PREVIEW_ZOOM,
@@ -158,6 +159,7 @@ export const NLEPreview = memo(function NLEPreview({
158
159
 
159
160
  const zoomRef = useRef<PreviewZoomState>(DEFAULT_PREVIEW_ZOOM);
160
161
  const [settledZoom, setSettledZoom] = useState<PreviewZoomState>(DEFAULT_PREVIEW_ZOOM);
162
+ useEffect(() => postFrameDisplayScale(previewIframeRef.current), [settledZoom]);
161
163
  const hudRef = useRef<HTMLDivElement>(null);
162
164
  const hudTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
163
165
  const settleTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
@@ -247,6 +247,49 @@ describe("composition card thumbnails", () => {
247
247
  expect(URL.revokeObjectURL).not.toHaveBeenCalledWith("blob:frame-2");
248
248
  });
249
249
 
250
+ it("tell a hover preview how large it shows, so its videos are not copied at source size", () => {
251
+ vi.useFakeTimers();
252
+ try {
253
+ const host = mount();
254
+ const card = host.querySelector<HTMLElement>('[aria-label^="Open composition"]')!;
255
+ act(() => {
256
+ card.dispatchEvent(
257
+ new MouseEvent("pointerover", { bubbles: true, relatedTarget: document.body }),
258
+ );
259
+ });
260
+ act(() => vi.advanceTimersByTime(300));
261
+ const frame = host.querySelector("iframe")!;
262
+ const postMessage = vi.fn();
263
+ Object.defineProperty(frame, "contentWindow", { value: { postMessage } });
264
+ Object.defineProperty(frame, "offsetWidth", { value: 1920 });
265
+ frame.getBoundingClientRect = () => ({ width: 80 }) as DOMRect;
266
+ act(() => {
267
+ frame.dispatchEvent(new Event("load"));
268
+ });
269
+ expect(postMessage).toHaveBeenCalledWith(
270
+ expect.objectContaining({ action: "set-display-scale", scale: 80 / 1920 }),
271
+ "*",
272
+ );
273
+
274
+ // A module-script composition starts listening only after load, then says it is ready.
275
+ postMessage.mockClear();
276
+ act(() => {
277
+ window.dispatchEvent(
278
+ new MessageEvent("message", {
279
+ source: frame.contentWindow,
280
+ data: { source: "hf-preview", type: "ready" },
281
+ }),
282
+ );
283
+ });
284
+ expect(postMessage).toHaveBeenCalledWith(
285
+ expect.objectContaining({ action: "set-display-scale", scale: 80 / 1920 }),
286
+ "*",
287
+ );
288
+ } finally {
289
+ vi.useRealTimers();
290
+ }
291
+ });
292
+
250
293
  it("show a fallback when the render fails, and retry it at the next content revision", async () => {
251
294
  const host = mount();
252
295
  renders[0]!.answer(500);
@@ -13,6 +13,7 @@ import {
13
13
  THUMBNAIL_SEEK_TIME_SECONDS,
14
14
  } from "../../player/components/CompositionThumbnail";
15
15
  import { setPreviewMediaMuted } from "../../player/lib/timelineIframeHelpers";
16
+ import { postFrameDisplayScale } from "../../player/lib/runtimeProtocol";
16
17
  import { usePlayerStore } from "../../player/store/playerStore";
17
18
  import { thumbnailRevisionOf } from "../../player/store/thumbnailSlice";
18
19
  import { encodePreviewPath } from "../../player/components/thumbnailUtils";
@@ -258,6 +259,22 @@ function CompCard({
258
259
  if (hovered) requestIframePlaybackSync(true);
259
260
  }, [hovered, requestIframePlaybackSync]);
260
261
 
262
+ useEffect(() => {
263
+ if (livePreviewLoaded) postFrameDisplayScale(iframeRef.current);
264
+ }, [livePreviewLoaded, previewScale]);
265
+
266
+ useEffect(() => {
267
+ if (!hovered) return;
268
+ const onRuntimeReady = (event: MessageEvent) => {
269
+ const frame = iframeRef.current;
270
+ if (frame && event.source === frame.contentWindow && event.data?.type === "ready") {
271
+ postFrameDisplayScale(frame);
272
+ }
273
+ };
274
+ window.addEventListener("message", onRuntimeReady);
275
+ return () => window.removeEventListener("message", onRuntimeReady);
276
+ }, [hovered]);
277
+
261
278
  useEffect(() => {
262
279
  return () => {
263
280
  if (hoverTimer.current) clearTimeout(hoverTimer.current);
@@ -1,4 +1,5 @@
1
1
  import {
2
+ frameDisplayScale,
2
3
  inspectRuntimeProtocol,
3
4
  runtimeProtocolMetadata,
4
5
  type RuntimeProtocolInspection,
@@ -34,6 +35,11 @@ export function postRuntimeControlMessage(
34
35
  target?.postMessage(createRuntimeControlMessage(action, payload, fps), "*");
35
36
  }
36
37
 
38
+ export function postFrameDisplayScale(iframe: HTMLIFrameElement | null | undefined): void {
39
+ const scale = iframe && frameDisplayScale(iframe);
40
+ if (scale) postRuntimeControlMessage(iframe.contentWindow, "set-display-scale", { scale });
41
+ }
42
+
37
43
  export function inspectStudioRuntimeMessage(value: unknown): RuntimeProtocolInspection {
38
44
  return inspectRuntimeProtocol(value, 30);
39
45
  }