@hyperframes/studio 0.8.221 → 0.8.223

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.
@@ -1,4 +1,4 @@
1
- import{n as Qi}from"./index-BDE7dwov.js";/*!
1
+ import{n as Qi}from"./index-DD9KJoEr.js";/*!
2
2
  * Copyright (c) 2026-present, Vanilagy and contributors
3
3
  *
4
4
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -599,6 +599,7 @@ function parsePlaybackHealth(value) {
599
599
  worstFrameMs,
600
600
  skippedShare: optionalNumber(extra.skippedShare),
601
601
  waitingShare: optionalNumber(extra.waitingShare),
602
+ frozenShare: optionalNumber(extra.frozenShare),
602
603
  gapP50Ms: optionalNumber(extra.gapP50Ms),
603
604
  gapP95Ms: optionalNumber(extra.gapP95Ms),
604
605
  mode: "play"
package/dist/index.d.ts CHANGED
@@ -262,6 +262,7 @@ interface PlaybackHealth {
262
262
  worstFrameMs: number;
263
263
  skippedShare?: number;
264
264
  waitingShare?: number;
265
+ frozenShare?: number;
265
266
  gapP50Ms?: number;
266
267
  gapP95Ms?: number;
267
268
  mode: "play";
package/dist/index.html CHANGED
@@ -14,7 +14,7 @@
14
14
  document.documentElement.dataset.theme = "paper";
15
15
  }
16
16
  </script>
17
- <script type="module" crossorigin src="/assets/index-BDE7dwov.js"></script>
17
+ <script type="module" crossorigin src="/assets/index-DD9KJoEr.js"></script>
18
18
  <link rel="stylesheet" crossorigin href="/assets/index-RUPGNyct.css">
19
19
  </head>
20
20
  <body>
package/dist/index.js CHANGED
@@ -54,7 +54,7 @@ import {
54
54
  whenPreviewBooted,
55
55
  writeStudioUiPreferences,
56
56
  zoomToSelectedClips
57
- } from "./chunk-UNZTUFD7.js";
57
+ } from "./chunk-2PQ3U3LU.js";
58
58
  import {
59
59
  Button,
60
60
  ContextMenu,
@@ -178,6 +178,7 @@ import {
178
178
  splitTimelineElementKey,
179
179
  studioApiFetch,
180
180
  toHexColor,
181
+ withSelectorIndexPass,
181
182
  wrapTimeline
182
183
  } from "./chunk-OGIOFEC7.js";
183
184
  import "./chunk-MLKGABMK.js";
@@ -14396,6 +14397,16 @@ import {
14396
14397
  useState as useState15
14397
14398
  } from "react";
14398
14399
 
14400
+ // src/utils/sameData.ts
14401
+ function sameData(a, b) {
14402
+ if (Object.is(a, b)) return true;
14403
+ if (!a || !b || typeof a !== "object" || typeof b !== "object") return false;
14404
+ if ("nodeType" in a || "nodeType" in b || Array.isArray(a) !== Array.isArray(b)) return false;
14405
+ const keys = Object.keys(a);
14406
+ if (keys.length !== Object.keys(b).length) return false;
14407
+ return keys.every((key2) => sameData(a[key2], b[key2]));
14408
+ }
14409
+
14399
14410
  // src/player/components/timelineFocusIdentity.ts
14400
14411
  function resolveTimelineFocusIdentity(elements, elementId2) {
14401
14412
  if (!elementId2) return null;
@@ -14510,6 +14521,7 @@ function getFocusedTimelineRowKey(target) {
14510
14521
  const rowKey = Number(value);
14511
14522
  return Number.isFinite(rowKey) ? rowKey : void 0;
14512
14523
  }
14524
+ var rowTops = (g) => [g.rowKeys, g.rowOffsets, g.padding.top];
14513
14525
  function useTimelineRowVirtualization({
14514
14526
  scrollRef,
14515
14527
  viewport: viewport2,
@@ -14582,7 +14594,7 @@ function useTimelineRowVirtualization({
14582
14594
  scroll.scrollTop = 0;
14583
14595
  syncScrollViewport(scroll);
14584
14596
  }
14585
- } else if (scroll && previousGeometry !== rowGeometry) {
14597
+ } else if (scroll && !sameData(rowTops(previousGeometry), rowTops(rowGeometry))) {
14586
14598
  const nextScrollTop = getTimelineScrollTopForGeometryChange(
14587
14599
  previousGeometry,
14588
14600
  rowGeometry,
@@ -15235,9 +15247,12 @@ import { memo as memo10 } from "react";
15235
15247
  import { useCallback as useCallback24, useRef as useRef28, useSyncExternalStore as useSyncExternalStore4 } from "react";
15236
15248
  function useSettledScrollLeft(scrollRef) {
15237
15249
  const scrollingRef = useRef28(false);
15250
+ const settledRef = useRef28(0);
15238
15251
  const subscribe2 = useCallback24(
15239
15252
  (onChange) => {
15240
15253
  const el = scrollRef.current;
15254
+ settledRef.current = el?.scrollLeft ?? 0;
15255
+ onChange();
15241
15256
  let settle;
15242
15257
  const onScroll = () => {
15243
15258
  if (!scrollingRef.current) {
@@ -15247,6 +15262,7 @@ function useSettledScrollLeft(scrollRef) {
15247
15262
  clearTimeout(settle);
15248
15263
  settle = setTimeout(() => {
15249
15264
  scrollingRef.current = false;
15265
+ settledRef.current = el?.scrollLeft ?? 0;
15250
15266
  onChange();
15251
15267
  }, TIMELINE_SCROLL_SETTLE_MS);
15252
15268
  };
@@ -15261,7 +15277,7 @@ function useSettledScrollLeft(scrollRef) {
15261
15277
  );
15262
15278
  return useSyncExternalStore4(
15263
15279
  subscribe2,
15264
- () => scrollingRef.current ? null : scrollRef.current?.scrollLeft ?? 0,
15280
+ () => scrollingRef.current ? null : settledRef.current,
15265
15281
  () => null
15266
15282
  );
15267
15283
  }
@@ -19758,7 +19774,7 @@ var TimelineClip = memo14(function TimelineClip2({
19758
19774
  });
19759
19775
 
19760
19776
  // src/utils/timelineElementSplit.ts
19761
- var SPLIT_BOUNDARY_EPSILON_S = 0.03;
19777
+ import { SPLIT_BOUNDARY_EPSILON_S } from "@hyperframes/core/composition-contract";
19762
19778
  function isSplitTimeWithinBounds(splitTime, clipStart2, clipDuration2) {
19763
19779
  return splitTime >= clipStart2 + SPLIT_BOUNDARY_EPSILON_S && splitTime <= clipStart2 + clipDuration2 - SPLIT_BOUNDARY_EPSILON_S;
19764
19780
  }
@@ -30390,6 +30406,9 @@ function createTimelineElementFromManifestClip(params) {
30390
30406
  return entry3;
30391
30407
  }
30392
30408
  function parseTimelineFromDOM(doc, rootDuration, timelines) {
30409
+ return withSelectorIndexPass(doc, () => scanTimelineFromDOM(doc, rootDuration, timelines));
30410
+ }
30411
+ function scanTimelineFromDOM(doc, rootDuration, timelines) {
30393
30412
  const rootComp = doc.querySelector("[data-composition-id]");
30394
30413
  const nodes = doc.querySelectorAll("[data-start]");
30395
30414
  const els = [];
@@ -30665,7 +30684,7 @@ function safeContentDocument(iframe) {
30665
30684
  }
30666
30685
  function buildTimelineElementsFromClips(clips, iframeDoc) {
30667
30686
  const resolveHost = iframeDoc ? createTimelineDomNodeResolver(iframeDoc) : null;
30668
- return clips.map((clip, index2) => {
30687
+ const build = () => clips.map((clip, index2) => {
30669
30688
  const hostEl = resolveHost?.(clip, index2) ?? null;
30670
30689
  return createTimelineElementFromManifestClip({
30671
30690
  clip,
@@ -30674,6 +30693,7 @@ function buildTimelineElementsFromClips(clips, iframeDoc) {
30674
30693
  hostEl
30675
30694
  });
30676
30695
  });
30696
+ return iframeDoc ? withSelectorIndexPass(iframeDoc, build) : build();
30677
30697
  }
30678
30698
  function syncManifestTimeline(els, manifestDuration, storeDuration, sync) {
30679
30699
  const hasDuration = manifestDuration > 0 && els.length > 0;
@@ -47013,16 +47033,6 @@ function TopologyLens({ iframeRef, activeCompositionPath }) {
47013
47033
  );
47014
47034
  }
47015
47035
 
47016
- // src/utils/sameData.ts
47017
- function sameData(a, b) {
47018
- if (Object.is(a, b)) return true;
47019
- if (!a || !b || typeof a !== "object" || typeof b !== "object") return false;
47020
- if ("nodeType" in a || "nodeType" in b || Array.isArray(a) !== Array.isArray(b)) return false;
47021
- const keys = Object.keys(a);
47022
- if (keys.length !== Object.keys(b).length) return false;
47023
- return keys.every((key2) => sameData(a[key2], b[key2]));
47024
- }
47025
-
47026
47036
  // src/hooks/gsapKeyframeCacheHelpers.ts
47027
47037
  function keepEqualEntries(before, draft) {
47028
47038
  for (const [key2, value] of draft) {
package/dist/player.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Player
3
- } from "./chunk-UNZTUFD7.js";
3
+ } from "./chunk-2PQ3U3LU.js";
4
4
  import "./chunk-7HZGKFFU.js";
5
5
  import "./chunk-OGIOFEC7.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.221",
3
+ "version": "0.8.223",
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.221",
64
- "@hyperframes/parsers": "0.8.221",
65
- "@hyperframes/player": "0.8.221",
66
- "@hyperframes/sdk": "0.8.221",
67
- "@hyperframes/studio-server": "0.8.221",
68
- "@hyperframes/shader-transitions": "0.8.221"
63
+ "@hyperframes/core": "0.8.223",
64
+ "@hyperframes/player": "0.8.223",
65
+ "@hyperframes/sdk": "0.8.223",
66
+ "@hyperframes/shader-transitions": "0.8.223",
67
+ "@hyperframes/studio-server": "0.8.223",
68
+ "@hyperframes/parsers": "0.8.223"
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.221"
85
+ "@hyperframes/producer": "0.8.223"
86
86
  },
87
87
  "peerDependencies": {
88
88
  "react": "19",
@@ -0,0 +1,41 @@
1
+ // @vitest-environment happy-dom
2
+ import React, { act } from "react";
3
+ import { createRoot } from "react-dom/client";
4
+ import { expect, it, vi } from "vitest";
5
+ import { useSettledScrollLeft } from "./useSettledScrollLeft";
6
+ import { TIMELINE_SCROLL_SETTLE_MS } from "./useTimelineScrollViewport";
7
+
8
+ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
9
+
10
+ // The ruler's label read scrollLeft on every commit while a long project settled, each read a layout of the whole
11
+ // timeline.
12
+ it("reads scrollLeft when a scroll settles, never on a render", () => {
13
+ vi.useFakeTimers();
14
+ const scroll = document.createElement("div");
15
+ let reads = 0;
16
+ let left = 120;
17
+ Object.defineProperty(scroll, "scrollLeft", { get: () => (reads++, left) });
18
+ const scrollRef = { current: scroll };
19
+ const seen: (number | null)[] = [];
20
+ function Probe({ tick }: { tick: number }) {
21
+ seen.push(useSettledScrollLeft(scrollRef));
22
+ return <i data-tick={tick} />;
23
+ }
24
+ const root = createRoot(document.createElement("div"));
25
+ try {
26
+ act(() => root.render(<Probe tick={0} />));
27
+ expect(seen.at(-1)).toBe(120);
28
+ reads = 0;
29
+ for (let tick = 1; tick <= 3; tick += 1) act(() => root.render(<Probe tick={tick} />));
30
+ expect(reads, "no layout read on a render").toBe(0);
31
+ left = 300;
32
+ act(() => void scroll.dispatchEvent(new Event("scroll")));
33
+ expect(seen.at(-1)).toBeNull();
34
+ act(() => void vi.advanceTimersByTime(TIMELINE_SCROLL_SETTLE_MS + 1));
35
+ expect(seen.at(-1)).toBe(300);
36
+ expect(reads, "one read when the scroll settles").toBe(1);
37
+ } finally {
38
+ act(() => root.unmount());
39
+ vi.useRealTimers();
40
+ }
41
+ });
@@ -6,9 +6,12 @@ import { TIMELINE_SCROLL_SETTLE_MS } from "./useTimelineScrollViewport";
6
6
  // on a large unvirtualized timeline.
7
7
  export function useSettledScrollLeft(scrollRef: RefObject<HTMLDivElement | null>): number | null {
8
8
  const scrollingRef = useRef(false);
9
+ const settledRef = useRef(0);
9
10
  const subscribe = useCallback(
10
11
  (onChange: () => void) => {
11
12
  const el = scrollRef.current;
13
+ settledRef.current = el?.scrollLeft ?? 0;
14
+ onChange();
12
15
  let settle: ReturnType<typeof setTimeout> | undefined;
13
16
  const onScroll = () => {
14
17
  if (!scrollingRef.current) {
@@ -18,6 +21,7 @@ export function useSettledScrollLeft(scrollRef: RefObject<HTMLDivElement | null>
18
21
  clearTimeout(settle);
19
22
  settle = setTimeout(() => {
20
23
  scrollingRef.current = false;
24
+ settledRef.current = el?.scrollLeft ?? 0;
21
25
  onChange();
22
26
  }, TIMELINE_SCROLL_SETTLE_MS);
23
27
  };
@@ -32,7 +36,7 @@ export function useSettledScrollLeft(scrollRef: RefObject<HTMLDivElement | null>
32
36
  );
33
37
  return useSyncExternalStore(
34
38
  subscribe,
35
- () => (scrollingRef.current ? null : (scrollRef.current?.scrollLeft ?? 0)),
39
+ () => (scrollingRef.current ? null : settledRef.current),
36
40
  () => null,
37
41
  );
38
42
  }
@@ -54,3 +54,48 @@ it("leaves the viewport still when a live preview lane is removed before the com
54
54
  expect(scroll.scrollTop).toBe(160);
55
55
  act(() => root.unmount());
56
56
  });
57
+
58
+ // A long project settling hands the rows a new geometry with the same rows on many commits; each scrollTop read
59
+ // forced a layout of every clip.
60
+ it("reads no scroll position for a new geometry that places every row where it was", () => {
61
+ const scroll = document.createElement("div");
62
+ let reads = 0;
63
+ let top = 160;
64
+ Object.defineProperty(scroll, "scrollTop", {
65
+ get: () => (reads++, top),
66
+ set: (value: number) => void (top = value),
67
+ });
68
+ const scrollRef = { current: scroll };
69
+ const root = createRoot(document.createElement("div"));
70
+ function Probe({ geometry }: { geometry: TimelineRowGeometry }) {
71
+ useTimelineRowVirtualization({
72
+ scrollRef,
73
+ rowGeometry: geometry,
74
+ sessionEpoch: 0,
75
+ viewport: {
76
+ scrollTop: 160,
77
+ scrollLeft: 0,
78
+ clientWidth: 800,
79
+ clientHeight: 200,
80
+ scrollWidth: 800,
81
+ scrollHeight: 600,
82
+ isScrolling: false,
83
+ },
84
+ elements: [],
85
+ selectedElementId: null,
86
+ lastScrollLeftRef: { current: 0 },
87
+ syncScrollViewport: () => {},
88
+ });
89
+ return null;
90
+ }
91
+ const rows = () => createTimelineRowGeometry([0, 1, 2], [48, 48, 48]);
92
+ act(() => root.render(<Probe geometry={rows()} />));
93
+ reads = 0;
94
+ for (let i = 0; i < 3; i += 1) act(() => root.render(<Probe geometry={rows()} />));
95
+ expect(reads, "no layout read for the same rows").toBe(0);
96
+ act(() =>
97
+ root.render(<Probe geometry={createTimelineRowGeometry([0, 9, 1, 2], [48, 48, 48, 48])} />),
98
+ );
99
+ expect(reads, "a row added still keeps the view anchored").toBeGreaterThan(0);
100
+ act(() => root.unmount());
101
+ });
@@ -8,6 +8,7 @@ import {
8
8
  type RefObject,
9
9
  } from "react";
10
10
  import type { TimelineElement } from "../store/playerStore";
11
+ import { sameData } from "../../utils/sameData";
11
12
  import { resolveTimelineFocusIdentity } from "./timelineFocusIdentity";
12
13
  import { getTimelineScrollTopForGeometryChange } from "./timelineViewportGeometry";
13
14
  import type { TimelineRowGeometry } from "./timelineLayout";
@@ -39,6 +40,8 @@ function getFocusedTimelineRowKey(target: EventTarget | null): number | undefine
39
40
  return Number.isFinite(rowKey) ? rowKey : undefined;
40
41
  }
41
42
 
43
+ const rowTops = (g: TimelineRowGeometry) => [g.rowKeys, g.rowOffsets, g.padding.top];
44
+
42
45
  export function useTimelineRowVirtualization({
43
46
  scrollRef,
44
47
  viewport,
@@ -116,7 +119,7 @@ export function useTimelineRowVirtualization({
116
119
  scroll.scrollTop = 0;
117
120
  syncScrollViewport(scroll);
118
121
  }
119
- } else if (scroll && previousGeometry !== rowGeometry) {
122
+ } else if (scroll && !sameData(rowTops(previousGeometry), rowTops(rowGeometry))) {
120
123
  const nextScrollTop = getTimelineScrollTopForGeometryChange(
121
124
  previousGeometry,
122
125
  rowGeometry,
@@ -97,6 +97,7 @@ describe("preview quality messages", () => {
97
97
  worstFrameMs: 90,
98
98
  skippedShare: 0.1,
99
99
  waitingShare: 0.4,
100
+ frozenShare: 0.2,
100
101
  gapP50Ms: 17,
101
102
  gapP95Ms: 66,
102
103
  mode: "play",
@@ -167,3 +167,24 @@ describe("live DOM manifest hydration", () => {
167
167
  expect(findTimelineDomNodeForClip(doc, clip({ start: 9 }), 0)?.id).toBe("stable");
168
168
  });
169
169
  });
170
+
171
+ describe("selector occurrence indexes while hydrating many clips", () => {
172
+ it("queries the document once for a class many clips share, not once per clip", () => {
173
+ const count = 200;
174
+ const spans = Array.from(
175
+ { length: count },
176
+ (_, i) =>
177
+ `<span class="clip w" data-start="${i}" data-duration="1" data-track-index="0"></span>`,
178
+ ).join("");
179
+ const doc = documentWith(spans);
180
+ const query = vi.spyOn(doc, "querySelectorAll");
181
+ const clips = Array.from({ length: count }, (_, i) => clip({ tagName: "span", start: i }));
182
+
183
+ const elements = buildTimelineElementsFromClips(clips, doc);
184
+
185
+ expect(elements).toHaveLength(count);
186
+ expect(query.mock.calls.filter(([selector]) => selector === ".w").length).toBeLessThanOrEqual(
187
+ 1,
188
+ );
189
+ });
190
+ });
@@ -9,6 +9,7 @@
9
9
  * an argument, so each is callable — and readable — on its own.
10
10
  */
11
11
 
12
+ import { withSelectorIndexPass } from "../../utils/sourceScopedSelectorIndex";
12
13
  import { createTimelineDomNodeResolver, findClipElementById } from "../lib/timelineElementHelpers";
13
14
  import { usePlayerStore } from "../store/playerStore";
14
15
  import type { TimelineElement, DomClipChild, SubCompositionHostState } from "../store/playerStore";
@@ -214,15 +215,17 @@ export function buildTimelineElementsFromClips(
214
215
  iframeDoc: Document | null,
215
216
  ): TimelineElement[] {
216
217
  const resolveHost = iframeDoc ? createTimelineDomNodeResolver(iframeDoc) : null;
217
- return clips.map((clip, index) => {
218
- const hostEl = resolveHost?.(clip, index) ?? null;
219
- return createTimelineElementFromManifestClip({
220
- clip,
221
- fallbackIndex: index,
222
- doc: iframeDoc,
223
- hostEl,
218
+ const build = () =>
219
+ clips.map((clip, index) => {
220
+ const hostEl = resolveHost?.(clip, index) ?? null;
221
+ return createTimelineElementFromManifestClip({
222
+ clip,
223
+ fallbackIndex: index,
224
+ doc: iframeDoc,
225
+ hostEl,
226
+ });
224
227
  });
225
- });
228
+ return iframeDoc ? withSelectorIndexPass(iframeDoc, build) : build();
226
229
  }
227
230
 
228
231
  /**
@@ -10,6 +10,7 @@
10
10
 
11
11
  import type { TimelineElement } from "../store/playerStore";
12
12
  import type { ClipManifestClip, IframeWindow, TimelineLike } from "./playbackTypes";
13
+ import { withSelectorIndexPass } from "../../utils/sourceScopedSelectorIndex";
13
14
  import { resolveCssStackingContextId } from "@hyperframes/core/runtime/stacking-context";
14
15
  import { readClipTiming } from "@hyperframes/core/composition-contract";
15
16
  import { readMasterFxChain } from "@hyperframes/core/audio-groups";
@@ -234,6 +235,14 @@ export function parseTimelineFromDOM(
234
235
  doc: Document,
235
236
  rootDuration: number,
236
237
  timelines?: Readonly<Record<string, TimelineLike>>,
238
+ ): TimelineElement[] {
239
+ return withSelectorIndexPass(doc, () => scanTimelineFromDOM(doc, rootDuration, timelines));
240
+ }
241
+
242
+ function scanTimelineFromDOM(
243
+ doc: Document,
244
+ rootDuration: number,
245
+ timelines?: Readonly<Record<string, TimelineLike>>,
237
246
  ): TimelineElement[] {
238
247
  const rootComp = doc.querySelector("[data-composition-id]");
239
248
  const nodes = doc.querySelectorAll("[data-start]");
@@ -21,6 +21,7 @@ export interface PlaybackHealth {
21
21
  worstFrameMs: number;
22
22
  skippedShare?: number;
23
23
  waitingShare?: number;
24
+ frozenShare?: number;
24
25
  gapP50Ms?: number;
25
26
  gapP95Ms?: number;
26
27
  mode: "play";
@@ -129,6 +130,7 @@ export function parsePlaybackHealth(value: unknown): PlaybackHealth | null {
129
130
  worstFrameMs: worstFrameMs as number,
130
131
  skippedShare: optionalNumber(extra.skippedShare),
131
132
  waitingShare: optionalNumber(extra.waitingShare),
133
+ frozenShare: optionalNumber(extra.frozenShare),
132
134
  gapP50Ms: optionalNumber(extra.gapP50Ms),
133
135
  gapP95Ms: optionalNumber(extra.gapP95Ms),
134
136
  mode: "play",
@@ -1,9 +1,8 @@
1
+ import { SPLIT_BOUNDARY_EPSILON_S } from "@hyperframes/core/composition-contract";
1
2
  import type { TimelineElement } from "../player/store/playerStore";
2
3
 
3
4
  export { buildPatchTarget, readFileContent } from "../hooks/timelineEditingHelpers";
4
-
5
- /** Minimum distance (seconds) from clip boundaries to allow a split. */
6
- export const SPLIT_BOUNDARY_EPSILON_S = 0.03;
5
+ export { SPLIT_BOUNDARY_EPSILON_S };
7
6
 
8
7
  /**
9
8
  * True when splitTime leaves at least SPLIT_BOUNDARY_EPSILON_S on both sides