@hyperframes/studio 0.9.42 → 0.9.44

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 (48) hide show
  1. package/dist/assets/{codec-CKqLGYc6.js → codec-DYhkxayl.js} +1 -1
  2. package/dist/assets/{hyperframes-player-DoEYqOIa.js → hyperframes-player-pPwFQY2W.js} +1 -1
  3. package/dist/assets/{index-4VGEAZyf.css → index-CU24FmKd.css} +1 -1
  4. package/dist/assets/{index-DLyQ91Ek.js → index-Crhhpl7F.js} +133 -133
  5. package/dist/assets/{index-s9iqoWnr.js → index-Cv1BkoPn.js} +1 -1
  6. package/dist/assets/{pausedVideoDecoder-B-ReRg6i.js → pausedVideoDecoder-Cns-60-8.js} +1 -1
  7. package/dist/{chunk-4QQMX4BX.js → chunk-67DSVBEI.js} +1 -1
  8. package/dist/{chunk-52AJB4PN.js → chunk-ZNUWV4FN.js} +1 -1
  9. package/dist/index.html +2 -2
  10. package/dist/index.js +790 -709
  11. package/dist/player.js +2 -2
  12. package/dist/styles.css +1 -1
  13. package/dist/ui.js +1 -1
  14. package/package.json +8 -8
  15. package/src/components/StudioOverlays.tsx +15 -13
  16. package/src/components/StudioToast.test.tsx +41 -0
  17. package/src/components/StudioToast.tsx +23 -39
  18. package/src/components/editor/domEditOverlayGeometry.ts +2 -0
  19. package/src/components/editor/domEditOverlayStartGesture.ts +31 -7
  20. package/src/components/editor/manualOffsetDrag.ts +10 -5
  21. package/src/components/editor/plainTranslate.ts +2 -0
  22. package/src/components/editor/previewGestureStartRead.test.ts +279 -0
  23. package/src/components/editor/previewGestureStartRead.ts +67 -0
  24. package/src/components/editor/previewGestureStarts.ts +21 -15
  25. package/src/components/editor/previewOverlayRects.test.ts +62 -0
  26. package/src/components/editor/previewOverlayRects.ts +8 -20
  27. package/src/components/editor/snapTargetCollection.ts +26 -62
  28. package/src/components/feedback/StudioFeedbackCard.tsx +5 -2
  29. package/src/components/ui/Menu.test.tsx +30 -1
  30. package/src/components/ui/Menu.tsx +1 -1
  31. package/src/hooks/timelineEditingHelpers.test.ts +48 -0
  32. package/src/hooks/timelineEditingHelpers.ts +2 -0
  33. package/src/hooks/timelineElementsAttribute.test.ts +46 -0
  34. package/src/hooks/timelineElementsAttribute.ts +14 -16
  35. package/src/hooks/timelineTrackVisibility.test.ts +34 -0
  36. package/src/hooks/useElementPicker.test.ts +9 -2
  37. package/src/hooks/useElementPicker.ts +4 -2
  38. package/src/hooks/useToast.ts +6 -18
  39. package/src/player/lib/previewElements.ts +37 -0
  40. package/src/player/lib/thumbnailFrameSink.test.ts +92 -0
  41. package/src/player/lib/thumbnailFrameSink.ts +83 -0
  42. package/src/player/lib/thumbnailVideoDecoder.test.ts +43 -16
  43. package/src/player/lib/thumbnailVideoDecoder.ts +6 -6
  44. package/src/styles/components.css +19 -1
  45. package/src/styles/theme.css +3 -0
  46. package/src/utils/previewSafeMargins.ts +6 -10
  47. package/src/utils/sourcePatcher.test.ts +21 -0
  48. package/src/utils/sourcePatcher.ts +16 -8
package/dist/ui.js CHANGED
@@ -30,7 +30,7 @@ import {
30
30
  fieldBase,
31
31
  fieldText,
32
32
  popupSurface
33
- } from "./chunk-52AJB4PN.js";
33
+ } from "./chunk-ZNUWV4FN.js";
34
34
  import "./chunk-MLKGABMK.js";
35
35
  export {
36
36
  Button,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/studio",
3
- "version": "0.9.42",
3
+ "version": "0.9.44",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -64,12 +64,12 @@
64
64
  "dockview-react": "8.3.1",
65
65
  "gsap": "^3.13.0",
66
66
  "mediabunny": "^1.65.2",
67
- "@hyperframes/player": "0.9.42",
68
- "@hyperframes/parsers": "0.9.42",
69
- "@hyperframes/shader-transitions": "0.9.42",
70
- "@hyperframes/core": "0.9.42",
71
- "@hyperframes/studio-server": "0.9.42",
72
- "@hyperframes/sdk": "0.9.42"
67
+ "@hyperframes/core": "0.9.44",
68
+ "@hyperframes/parsers": "0.9.44",
69
+ "@hyperframes/player": "0.9.44",
70
+ "@hyperframes/shader-transitions": "0.9.44",
71
+ "@hyperframes/studio-server": "0.9.44",
72
+ "@hyperframes/sdk": "0.9.44"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@tailwindcss/vite": "^4.3.3",
@@ -86,7 +86,7 @@
86
86
  "vite": "^6.4.5",
87
87
  "vitest": "^4.1.12",
88
88
  "zustand": "^5.0.0",
89
- "@hyperframes/producer": "0.9.42"
89
+ "@hyperframes/producer": "0.9.44"
90
90
  },
91
91
  "peerDependencies": {
92
92
  "react": "19",
@@ -75,19 +75,21 @@ export const StudioOverlays = memo(function StudioOverlays({
75
75
  }}
76
76
  />
77
77
  )}
78
- {/* One bottom-right stack so the feedback card and toasts queue instead
79
- of covering each other. Empty when nothing is showing. */}
80
- <div className="absolute bottom-6 right-6 z-91 flex flex-col items-end gap-2">
81
- {toasts.map((toast) => (
82
- <StudioToast
83
- key={toast.id}
84
- message={toast.message}
85
- tone={toast.tone}
86
- leaving={toast.leaving}
87
- onDismiss={() => dismissToast(toast.id)}
88
- />
89
- ))}
90
- <StudioFeedbackCard />
78
+ {/* Toasts centre in the room the feedback card leaves, so the two never cover each other. */}
79
+ <div className="pointer-events-none absolute inset-x-6 bottom-6 z-91 flex items-end gap-2">
80
+ <div className="flex min-w-0 flex-1 flex-col items-center gap-2 *:pointer-events-auto">
81
+ {toasts.map((toast) => (
82
+ <StudioToast
83
+ key={toast.id}
84
+ message={toast.message}
85
+ tone={toast.tone}
86
+ onDismiss={() => dismissToast(toast.id)}
87
+ />
88
+ ))}
89
+ </div>
90
+ <div className="pointer-events-auto">
91
+ <StudioFeedbackCard />
92
+ </div>
91
93
  </div>
92
94
  </>
93
95
  );
@@ -0,0 +1,41 @@
1
+ // @vitest-environment happy-dom
2
+
3
+ import React, { act } from "react";
4
+ import { afterEach, describe, expect, it } from "vitest";
5
+ import { mountReactHarness } from "../hooks/domSelectionTestHarness";
6
+ import { StudioToast } from "./StudioToast";
7
+
8
+ (globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
9
+
10
+ afterEach(() => {
11
+ document.body.innerHTML = "";
12
+ });
13
+
14
+ function mount(tone: "error" | "info") {
15
+ const dismissed: string[] = [];
16
+ mountReactHarness(
17
+ <StudioToast message="Saved" tone={tone} onDismiss={() => dismissed.push(tone)} />,
18
+ );
19
+ return dismissed;
20
+ }
21
+
22
+ describe("StudioToast", () => {
23
+ it("dismisses an info toast on a click anywhere on it, with no Dismiss button", () => {
24
+ const dismissed = mount("info");
25
+ expect(document.querySelector("button")).toBeNull();
26
+ act(() => document.querySelector<HTMLElement>("[role=status]")?.click());
27
+ expect(dismissed).toEqual(["info"]);
28
+ });
29
+
30
+ it("keeps an error toast up on a click on it, so its text can be selected and copied", () => {
31
+ const dismissed = mount("error");
32
+ act(() => document.querySelector<HTMLElement>("[role=alert]")?.click());
33
+ expect(dismissed).toEqual([]);
34
+ });
35
+
36
+ it("gives a persisting error toast a Dismiss button that dismisses it once", () => {
37
+ const dismissed = mount("error");
38
+ act(() => document.querySelector<HTMLElement>("[aria-label=Dismiss]")?.click());
39
+ expect(dismissed).toEqual(["error"]);
40
+ });
41
+ });
@@ -1,50 +1,34 @@
1
+ import { X } from "../icons/SystemIcons";
2
+ import { toastPersists } from "../hooks/useToast";
3
+
1
4
  interface StudioToastProps {
2
5
  message: string;
3
- tone?: "error" | "info";
4
- /** Plays the exit animation when true (owner removes the node after ~160ms). */
5
- leaving?: boolean;
6
- onDismiss?: () => void;
6
+ tone: "error" | "info";
7
+ onDismiss: () => void;
7
8
  }
8
9
 
9
- export function StudioToast({ message, tone, leaving, onDismiss }: StudioToastProps) {
10
- const isError = tone === "error";
10
+ export function StudioToast({ message, tone, onDismiss }: StudioToastProps) {
11
+ const persists = toastPersists(tone);
11
12
  return (
12
13
  <div
13
- role={isError ? "alert" : "status"}
14
- className={`motion-reduce:animate-none ${leaving ? "hf-toast-exit" : "hf-toast-enter"}`}
14
+ role={tone === "error" ? "alert" : "status"}
15
+ onClick={persists ? undefined : onDismiss}
16
+ onKeyDown={(event) => {
17
+ if (event.key === "Escape") onDismiss();
18
+ }}
19
+ className={`hf-notice-in flex min-h-12 w-fit max-w-[min(680px,100%)] items-center gap-1.5 rounded-3xl bg-text-0 py-1.5 pr-1.5 pl-5 text-[14px] leading-5 font-medium wrap-anywhere text-bg-0 shadow-notice not-has-[button]:pr-5 ${persists ? "" : "cursor-pointer"}`}
15
20
  >
16
- <div
17
- className={`relative flex max-w-[min(420px,calc(100vw-48px))] items-center gap-3 overflow-hidden rounded-2xl py-3 pl-4 pr-2 text-[12px] ${toastSurface(isError)}`}
18
- >
19
- <span
20
- className={`min-w-0 wrap-break-word leading-5 ${isError ? "text-danger-ink" : "text-text-0"}`}
21
+ <span className="min-w-0 flex-1 text-pretty">{message}</span>
22
+ {persists && (
23
+ <button
24
+ type="button"
25
+ onClick={onDismiss}
26
+ className="relative ml-2 grid h-9 w-9 shrink-0 place-items-center rounded-full text-bg-0/72 transition-[background-color,color,scale] duration-hover ease-out hover:bg-bg-0/16 hover:text-bg-0 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-bg-0 active:scale-[0.96]"
27
+ aria-label="Dismiss"
21
28
  >
22
- {message}
23
- </span>
24
- {onDismiss && (
25
- <button
26
- type="button"
27
- onClick={onDismiss}
28
- className="flex h-5 w-5 shrink-0 items-center justify-center rounded-md text-neutral-500 transition-colors hover:bg-hover hover:text-neutral-300"
29
- aria-label="Dismiss"
30
- >
31
- <svg
32
- width="10"
33
- height="10"
34
- viewBox="0 0 10 10"
35
- fill="none"
36
- stroke="currentColor"
37
- strokeWidth="1.5"
38
- >
39
- <path d="M2 2l6 6M8 2l-6 6" />
40
- </svg>
41
- </button>
42
- )}
43
- </div>
29
+ <X size={14} />
30
+ </button>
31
+ )}
44
32
  </div>
45
33
  );
46
34
  }
47
-
48
- export function toastSurface(isError: boolean): string {
49
- return `border shadow-popover bg-raised ${isError ? "border-danger/40" : "border-border"}`;
50
- }
@@ -15,6 +15,7 @@ import {
15
15
  type ElementTransformSnapshot,
16
16
  } from "@hyperframes/core/runtime/editing-port";
17
17
  import { type OverlayMeasurePass, readThroughPass } from "./domEditOverlayMeasurePass";
18
+ import type { PreviewGestureStart } from "./previewGestureStartRead";
18
19
 
19
20
  export const RESIZE_HANDLE_HIT_PX = 16;
20
21
 
@@ -40,6 +41,7 @@ export interface GroupOverlayItem {
40
41
  selection: DomEditSelection;
41
42
  element: HTMLElement;
42
43
  rect: OverlayRect;
44
+ start?: PreviewGestureStart;
43
45
  }
44
46
 
45
47
  export type ResolvedElementRef = {
@@ -34,7 +34,9 @@ import {
34
34
  type ResizeHandle,
35
35
  type UseDomEditOverlayGesturesOptions,
36
36
  } from "./domEditOverlayGestures";
37
- import { collectSnapContext, buildExcludeElements } from "./snapTargetCollection";
37
+ import { collectSnapContext, buildExcludeElements, type SnapContext } from "./snapTargetCollection";
38
+ import { MOVING_LAYER_UNREADABLE } from "./plainTranslate";
39
+ import type { PreviewGestureStart } from "./previewGestureStartRead";
38
40
  import { editsPlainCss } from "../../hooks/gsapRuntimeKeyframes";
39
41
  import { logResize, resetResizeMoveLog } from "../../utils/resizeDebug";
40
42
  import { logDrag, readDragPositions, resetDragMoveLog } from "../../utils/dragDebug";
@@ -52,6 +54,7 @@ export function startGroupDrag(
52
54
  e: React.PointerEvent<HTMLElement>,
53
55
  opts: UseDomEditOverlayGesturesOptions,
54
56
  at?: EditMoment,
57
+ snap?: SnapContext,
55
58
  ): boolean {
56
59
  const items = opts.groupOverlayItemsRef.current;
57
60
  if (items.length <= 1) return false;
@@ -65,6 +68,13 @@ export function startGroupDrag(
65
68
  notifyBlockedPress(e, opts, blockedSelection);
66
69
  return false;
67
70
  }
71
+ const moving = items.find((item) => item.start?.gsap?.moving)?.selection;
72
+ if (moving) {
73
+ e.preventDefault();
74
+ e.stopPropagation();
75
+ opts.onBlockedMoveRef.current(moving, MOVING_LAYER_UNREADABLE);
76
+ return false;
77
+ }
68
78
 
69
79
  opts.onManualDragStartRef.current?.();
70
80
  const dragItems = filterNestedDomEditGroupItems(items);
@@ -77,6 +87,7 @@ export function startGroupDrag(
77
87
  rect: item.rect,
78
88
  gesture: "drag",
79
89
  at,
90
+ start: item.start,
80
91
  });
81
92
  if (!result.ok) {
82
93
  restoreManualOffsetDragMembers(members);
@@ -108,7 +119,8 @@ export function startGroupDrag(
108
119
  const overlayEl = opts.overlayRef.current;
109
120
  const iframe = opts.iframeRef.current;
110
121
  const snapContext =
111
- overlayEl && iframe
122
+ snap ??
123
+ (overlayEl && iframe
112
124
  ? collectSnapContext({
113
125
  overlayEl,
114
126
  iframe,
@@ -117,7 +129,7 @@ export function startGroupDrag(
117
129
  groupSelections: items.map((i) => i.selection),
118
130
  }),
119
131
  })
120
- : undefined;
132
+ : undefined);
121
133
 
122
134
  e.preventDefault();
123
135
  e.stopPropagation();
@@ -150,9 +162,13 @@ export function startGesture(
150
162
  resizeHandle?: ResizeHandle;
151
163
  resizeCorner?: { x: number; y: number };
152
164
  at?: EditMoment;
165
+ /** Read off a frame Studio cannot script at the press: the element's start and the snap targets. */
166
+ start?: PreviewGestureStart;
167
+ snap?: SnapContext;
153
168
  },
154
169
  ): boolean {
155
170
  const at = options?.at;
171
+ const start = options?.start;
156
172
  const sel = options?.selection ?? opts.selectionRef.current;
157
173
  const rect = options?.rect ?? opts.overlayRectRef.current;
158
174
  const box = opts.boxRef.current;
@@ -172,8 +188,8 @@ export function startGesture(
172
188
  // layout size. offsetWidth/Height are transform-free; the overlay-rect
173
189
  // fallback (rect / editScale) includes the element's own GSAP scale and
174
190
  // would make a rescaled element's draft grow from the RENDERED size.
175
- const layoutWidth = sel.element.offsetWidth;
176
- const layoutHeight = sel.element.offsetHeight;
191
+ const layoutWidth = start?.layout.width ?? sel.element.offsetWidth;
192
+ const layoutHeight = start?.layout.height ?? sel.element.offsetHeight;
177
193
  const actualWidth =
178
194
  size.width > 0 ? size.width : layoutWidth > 0 ? layoutWidth : rect.width / rect.editScaleX;
179
195
  const actualHeight =
@@ -196,6 +212,11 @@ export function startGesture(
196
212
  let pathOffsetMember: ManualOffsetDragMember | undefined;
197
213
 
198
214
  if (kind === "drag") {
215
+ if (start?.gsap?.moving) {
216
+ opts.onBlockedMoveRef.current(sel, MOVING_LAYER_UNREADABLE);
217
+ e.preventDefault();
218
+ return false;
219
+ }
199
220
  opts.onManualDragStartRef.current?.();
200
221
  const result = createManualOffsetDragMember({
201
222
  key: selectionCacheKey(sel),
@@ -204,6 +225,7 @@ export function startGesture(
204
225
  rect,
205
226
  gesture: "drag",
206
227
  at,
228
+ start,
207
229
  });
208
230
  if (!result.ok) {
209
231
  opts.onBlockedMoveRef.current(result.selection, result.reason);
@@ -226,6 +248,7 @@ export function startGesture(
226
248
  rect,
227
249
  gesture: "resize",
228
250
  at,
251
+ start,
229
252
  });
230
253
  if (result.ok) {
231
254
  pathOffsetMember = result.member;
@@ -267,11 +290,12 @@ export function startGesture(
267
290
  }
268
291
  const snapContext =
269
292
  (kind === "drag" || kind === "resize") && overlayEl && iframe
270
- ? collectSnapContext({
293
+ ? (options?.snap ??
294
+ collectSnapContext({
271
295
  overlayEl,
272
296
  iframe,
273
297
  excludeElements: buildExcludeElements({ iframe, selection: sel }),
274
- })
298
+ }))
275
299
  : undefined;
276
300
  e.preventDefault();
277
301
  e.stopPropagation();
@@ -18,6 +18,7 @@ import { computeDraggedGsapPosition } from "../../hooks/draggedGsapPosition";
18
18
  import { editsPlainCss } from "../../hooks/gsapRuntimeKeyframes";
19
19
  import { readTranslatePx, UNREADABLE_TRANSLATE, writeTranslatePx } from "./plainTranslate";
20
20
  import { drawPreviewDraft, endPreviewDraft } from "./previewDrafts";
21
+ import type { PreviewGestureStart } from "./previewGestureStartRead";
21
22
 
22
23
  interface OffsetDragGsap {
23
24
  set: (el: Element, vars: Record<string, number | string>) => void;
@@ -320,9 +321,13 @@ export function createManualOffsetDragMember(input: {
320
321
  rect: ManualOffsetDragRect;
321
322
  gesture?: "drag" | "nudge" | "resize"; // resize: the anchor that keeps its centre planted
322
323
  at?: EditMoment;
324
+ start?: PreviewGestureStart;
323
325
  }): ManualOffsetDragMemberResult {
326
+ const { start, gesture } = input;
324
327
  const plainTranslate =
325
- !!input.gesture && editsPlainCss(input.element, input.gesture === "resize" ? "resize" : "move");
328
+ start && gesture !== "resize"
329
+ ? !start.gsap
330
+ : !!gesture && editsPlainCss(input.element, gesture === "resize" ? "resize" : "move");
326
331
  // The APPLIED offset, never a dormant var, so a stale one can't fling the element off-screen.
327
332
  const initialOffset = plainTranslate
328
333
  ? readTranslatePx(input.element)
@@ -338,7 +343,7 @@ export function createManualOffsetDragMember(input: {
338
343
  // getProperty makes GSAP bake the CSS translate into its transform, so a plain move never reads it.
339
344
  const gsapX = (!plainTranslate && win?.gsap?.getProperty?.(input.element, "x")) || 0;
340
345
  const gsapY = (!plainTranslate && win?.gsap?.getProperty?.(input.element, "y")) || 0;
341
- const baseGsap = { x: gsapX, y: gsapY };
346
+ const baseGsap = start?.gsap ? { x: start.gsap.x, y: start.gsap.y } : { x: gsapX, y: gsapY };
342
347
  if (!plainTranslate) stampGestureBase(input.element, initialOffset, baseGsap);
343
348
 
344
349
  if (win?.__timelines) {
@@ -371,8 +376,8 @@ export function createManualOffsetDragMember(input: {
371
376
  });
372
377
  endPreviewDraft(input.element, "keep");
373
378
  if (!measured.ok) {
374
- // GSAP transforms can defeat the probe: approximate with the preview scale. The commit
375
- // reads GSAP's real position, so only the drag preview is imprecise.
379
+ // A stand-in has no box: the frame probed its element at the press. GSAP transforms can defeat
380
+ // the probe: approximate with the preview scale; the commit reads GSAP's real position.
376
381
  const scaleX = input.rect.editScaleX || 1;
377
382
  const scaleY = input.rect.editScaleY || 1;
378
383
  const w = readTransformWDivisor(input.element);
@@ -387,7 +392,7 @@ export function createManualOffsetDragMember(input: {
387
392
  baseGsap,
388
393
  initialPathOffset,
389
394
  gestureToken,
390
- screenToOffset: { a: w / scaleX, b: 0, c: 0, d: w / scaleY },
395
+ screenToOffset: start?.screenToOffset ?? { a: w / scaleX, b: 0, c: 0, d: w / scaleY },
391
396
  originRect: input.rect,
392
397
  },
393
398
  };
@@ -128,6 +128,8 @@ export function readTranslatePxLeavingPercent(el: HTMLElement): Point {
128
128
 
129
129
  export const UNREADABLE_TRANSLATE =
130
130
  "Studio can't read this layer's translate. Move it in the Code tab.";
131
+ export const MOVING_LAYER_UNREADABLE =
132
+ "This preview can't save a move of a layer its animation moves yet. Move it in the Code tab.";
131
133
 
132
134
  /** Plain px only: GSAP's CSSPlugin splits `translate` on spaces and drops a calc(). */
133
135
  function formatTranslatePx(p: Point): string {