@hyperframes/studio 0.8.222 → 0.8.224
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/dist/assets/hyperframes-player-Bzcd9O2g.js +478 -0
- package/dist/assets/{index-C8VIUiGz.js → index-CZI-XmnO.js} +119 -119
- package/dist/assets/{index-CVPNbydK.js → index-LW6kxYVF.js} +1 -1
- package/dist/{chunk-UNZTUFD7.js → chunk-2PQ3U3LU.js} +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.html +1 -1
- package/dist/index.js +19 -14
- package/dist/player.js +1 -1
- package/package.json +8 -8
- package/src/player/components/useSettledScrollLeft.test.tsx +41 -0
- package/src/player/components/useSettledScrollLeft.ts +5 -1
- package/src/player/components/useTimelineRowVirtualization.test.tsx +45 -0
- package/src/player/components/useTimelineRowVirtualization.ts +4 -1
- package/src/player/hooks/previewMessageRouter.test.ts +1 -0
- package/src/player/hooks/useTimelinePlayer.metadata.test.ts +149 -0
- package/src/player/hooks/useTimelinePlayer.ts +1 -1
- package/src/player/store/previewQualitySlice.ts +2 -0
- package/dist/assets/hyperframes-player-Dka6e1BG.js +0 -478
|
@@ -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
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-
|
|
17
|
+
<script type="module" crossorigin src="/assets/index-CZI-XmnO.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-
|
|
57
|
+
} from "./chunk-2PQ3U3LU.js";
|
|
58
58
|
import {
|
|
59
59
|
Button,
|
|
60
60
|
ContextMenu,
|
|
@@ -14397,6 +14397,16 @@ import {
|
|
|
14397
14397
|
useState as useState15
|
|
14398
14398
|
} from "react";
|
|
14399
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
|
+
|
|
14400
14410
|
// src/player/components/timelineFocusIdentity.ts
|
|
14401
14411
|
function resolveTimelineFocusIdentity(elements, elementId2) {
|
|
14402
14412
|
if (!elementId2) return null;
|
|
@@ -14511,6 +14521,7 @@ function getFocusedTimelineRowKey(target) {
|
|
|
14511
14521
|
const rowKey = Number(value);
|
|
14512
14522
|
return Number.isFinite(rowKey) ? rowKey : void 0;
|
|
14513
14523
|
}
|
|
14524
|
+
var rowTops = (g) => [g.rowKeys, g.rowOffsets, g.padding.top];
|
|
14514
14525
|
function useTimelineRowVirtualization({
|
|
14515
14526
|
scrollRef,
|
|
14516
14527
|
viewport: viewport2,
|
|
@@ -14583,7 +14594,7 @@ function useTimelineRowVirtualization({
|
|
|
14583
14594
|
scroll.scrollTop = 0;
|
|
14584
14595
|
syncScrollViewport(scroll);
|
|
14585
14596
|
}
|
|
14586
|
-
} else if (scroll && previousGeometry
|
|
14597
|
+
} else if (scroll && !sameData(rowTops(previousGeometry), rowTops(rowGeometry))) {
|
|
14587
14598
|
const nextScrollTop = getTimelineScrollTopForGeometryChange(
|
|
14588
14599
|
previousGeometry,
|
|
14589
14600
|
rowGeometry,
|
|
@@ -15236,9 +15247,12 @@ import { memo as memo10 } from "react";
|
|
|
15236
15247
|
import { useCallback as useCallback24, useRef as useRef28, useSyncExternalStore as useSyncExternalStore4 } from "react";
|
|
15237
15248
|
function useSettledScrollLeft(scrollRef) {
|
|
15238
15249
|
const scrollingRef = useRef28(false);
|
|
15250
|
+
const settledRef = useRef28(0);
|
|
15239
15251
|
const subscribe2 = useCallback24(
|
|
15240
15252
|
(onChange) => {
|
|
15241
15253
|
const el = scrollRef.current;
|
|
15254
|
+
settledRef.current = el?.scrollLeft ?? 0;
|
|
15255
|
+
onChange();
|
|
15242
15256
|
let settle;
|
|
15243
15257
|
const onScroll = () => {
|
|
15244
15258
|
if (!scrollingRef.current) {
|
|
@@ -15248,6 +15262,7 @@ function useSettledScrollLeft(scrollRef) {
|
|
|
15248
15262
|
clearTimeout(settle);
|
|
15249
15263
|
settle = setTimeout(() => {
|
|
15250
15264
|
scrollingRef.current = false;
|
|
15265
|
+
settledRef.current = el?.scrollLeft ?? 0;
|
|
15251
15266
|
onChange();
|
|
15252
15267
|
}, TIMELINE_SCROLL_SETTLE_MS);
|
|
15253
15268
|
};
|
|
@@ -15262,7 +15277,7 @@ function useSettledScrollLeft(scrollRef) {
|
|
|
15262
15277
|
);
|
|
15263
15278
|
return useSyncExternalStore4(
|
|
15264
15279
|
subscribe2,
|
|
15265
|
-
() => scrollingRef.current ? null :
|
|
15280
|
+
() => scrollingRef.current ? null : settledRef.current,
|
|
15266
15281
|
() => null
|
|
15267
15282
|
);
|
|
15268
15283
|
}
|
|
@@ -33068,7 +33083,7 @@ function useTimelinePlayer({
|
|
|
33068
33083
|
(key2, durationSeconds) => {
|
|
33069
33084
|
usePlayerStore.setState((state2) => {
|
|
33070
33085
|
const idx = state2.elements.findIndex((e) => (e.key ?? e.id) === key2);
|
|
33071
|
-
if (idx === -1 || state2.elements[idx].sourceDuration != null) return
|
|
33086
|
+
if (idx === -1 || state2.elements[idx].sourceDuration != null) return state2;
|
|
33072
33087
|
const patched = state2.elements.slice();
|
|
33073
33088
|
patched[idx] = { ...state2.elements[idx], sourceDuration: durationSeconds };
|
|
33074
33089
|
return { elements: patched };
|
|
@@ -47018,16 +47033,6 @@ function TopologyLens({ iframeRef, activeCompositionPath }) {
|
|
|
47018
47033
|
);
|
|
47019
47034
|
}
|
|
47020
47035
|
|
|
47021
|
-
// src/utils/sameData.ts
|
|
47022
|
-
function sameData(a, b) {
|
|
47023
|
-
if (Object.is(a, b)) return true;
|
|
47024
|
-
if (!a || !b || typeof a !== "object" || typeof b !== "object") return false;
|
|
47025
|
-
if ("nodeType" in a || "nodeType" in b || Array.isArray(a) !== Array.isArray(b)) return false;
|
|
47026
|
-
const keys = Object.keys(a);
|
|
47027
|
-
if (keys.length !== Object.keys(b).length) return false;
|
|
47028
|
-
return keys.every((key2) => sameData(a[key2], b[key2]));
|
|
47029
|
-
}
|
|
47030
|
-
|
|
47031
47036
|
// src/hooks/gsapKeyframeCacheHelpers.ts
|
|
47032
47037
|
function keepEqualEntries(before, draft) {
|
|
47033
47038
|
for (const [key2, value] of draft) {
|
package/dist/player.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/studio",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.224",
|
|
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.
|
|
64
|
-
"@hyperframes/parsers": "0.8.
|
|
65
|
-
"@hyperframes/player": "0.8.
|
|
66
|
-
"@hyperframes/
|
|
67
|
-
"@hyperframes/
|
|
68
|
-
"@hyperframes/
|
|
63
|
+
"@hyperframes/core": "0.8.224",
|
|
64
|
+
"@hyperframes/parsers": "0.8.224",
|
|
65
|
+
"@hyperframes/player": "0.8.224",
|
|
66
|
+
"@hyperframes/shader-transitions": "0.8.224",
|
|
67
|
+
"@hyperframes/studio-server": "0.8.224",
|
|
68
|
+
"@hyperframes/sdk": "0.8.224"
|
|
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.
|
|
85
|
+
"@hyperframes/producer": "0.8.224"
|
|
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 :
|
|
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
|
|
122
|
+
} else if (scroll && !sameData(rowTops(previousGeometry), rowTops(rowGeometry))) {
|
|
120
123
|
const nextScrollTop = getTimelineScrollTopForGeometryChange(
|
|
121
124
|
previousGeometry,
|
|
122
125
|
rowGeometry,
|
|
@@ -0,0 +1,149 @@
|
|
|
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 { useTimelinePlayer } from "./useTimelinePlayer";
|
|
6
|
+
import { usePlayerStore } from "../store/playerStore";
|
|
7
|
+
import { getMediaProbeDiagnostics, resetMediaProbeRegistry } from "../lib/mediaProbe";
|
|
8
|
+
|
|
9
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
|
|
10
|
+
|
|
11
|
+
it("publishes resolved metadata only for clips that still need it", async () => {
|
|
12
|
+
vi.useFakeTimers({
|
|
13
|
+
toFake: ["setInterval", "clearInterval", "requestAnimationFrame", "cancelAnimationFrame"],
|
|
14
|
+
});
|
|
15
|
+
const { promise: ready, resolve: release } = Promise.withResolvers<void>();
|
|
16
|
+
const requested = new Set<string>();
|
|
17
|
+
const bytes = new Uint8Array(44 + 192000);
|
|
18
|
+
const view = new DataView(bytes.buffer);
|
|
19
|
+
const word = (at: number, text: string) =>
|
|
20
|
+
[...text].forEach((c, i) => view.setUint8(at + i, c.charCodeAt(0)));
|
|
21
|
+
word(0, "RIFF");
|
|
22
|
+
view.setUint32(4, bytes.length - 8, true);
|
|
23
|
+
word(8, "WAVE");
|
|
24
|
+
word(12, "fmt ");
|
|
25
|
+
view.setUint32(16, 16, true);
|
|
26
|
+
view.setUint16(20, 1, true);
|
|
27
|
+
view.setUint16(22, 1, true);
|
|
28
|
+
view.setUint32(24, 8000, true);
|
|
29
|
+
view.setUint32(28, 16000, true);
|
|
30
|
+
view.setUint16(32, 2, true);
|
|
31
|
+
view.setUint16(34, 16, true);
|
|
32
|
+
word(36, "data");
|
|
33
|
+
view.setUint32(40, 192000, true);
|
|
34
|
+
vi.stubGlobal(
|
|
35
|
+
"fetch",
|
|
36
|
+
vi.fn(async (input: RequestInfo | URL) => {
|
|
37
|
+
requested.add(String(input));
|
|
38
|
+
await ready;
|
|
39
|
+
return new Response(bytes, {
|
|
40
|
+
headers: { "content-type": "audio/wav", "content-length": String(bytes.length) },
|
|
41
|
+
});
|
|
42
|
+
}),
|
|
43
|
+
);
|
|
44
|
+
resetMediaProbeRegistry();
|
|
45
|
+
usePlayerStore.getState().reset();
|
|
46
|
+
const host = document.createElement("div");
|
|
47
|
+
document.body.append(host);
|
|
48
|
+
const root = createRoot(host);
|
|
49
|
+
const current: { value?: ReturnType<typeof useTimelinePlayer> } = {};
|
|
50
|
+
function Harness() {
|
|
51
|
+
current.value = useTimelinePlayer();
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
act(() => root.render(React.createElement(Harness)));
|
|
55
|
+
const api = current.value;
|
|
56
|
+
if (!api) throw new Error("player hook did not mount");
|
|
57
|
+
const iframe = document.createElement("iframe");
|
|
58
|
+
document.body.append(iframe);
|
|
59
|
+
const frame = iframe.contentWindow;
|
|
60
|
+
if (!frame) throw new Error("preview frame did not attach");
|
|
61
|
+
Object.assign(frame, {
|
|
62
|
+
__player: {
|
|
63
|
+
play() {},
|
|
64
|
+
pause() {},
|
|
65
|
+
seek() {},
|
|
66
|
+
getTime: () => 0,
|
|
67
|
+
getDuration: () => 600,
|
|
68
|
+
isPlaying: () => false,
|
|
69
|
+
},
|
|
70
|
+
postMessage() {},
|
|
71
|
+
scrollTo() {},
|
|
72
|
+
});
|
|
73
|
+
act(() => {
|
|
74
|
+
api.iframeRef.current = iframe;
|
|
75
|
+
api.onIframeLoad();
|
|
76
|
+
});
|
|
77
|
+
const clips = Array.from({ length: 600 }, (_, index) => ({
|
|
78
|
+
id: `clip-${index}`,
|
|
79
|
+
label: `Clip ${index}`,
|
|
80
|
+
start: index,
|
|
81
|
+
duration: 1,
|
|
82
|
+
track: 0,
|
|
83
|
+
kind: "audio",
|
|
84
|
+
tagName: "audio",
|
|
85
|
+
compositionId: null,
|
|
86
|
+
parentCompositionId: null,
|
|
87
|
+
compositionSrc: null,
|
|
88
|
+
assetUrl: `https://example.test/source-${index % 30}.wav`,
|
|
89
|
+
}));
|
|
90
|
+
const dispatch = () =>
|
|
91
|
+
window.dispatchEvent(
|
|
92
|
+
new MessageEvent("message", {
|
|
93
|
+
source: frame,
|
|
94
|
+
data: { source: "hf-preview", type: "timeline", clips, durationInFrames: 18000, fps: 30 },
|
|
95
|
+
}),
|
|
96
|
+
);
|
|
97
|
+
let stop = () => {};
|
|
98
|
+
try {
|
|
99
|
+
act(() => {
|
|
100
|
+
dispatch();
|
|
101
|
+
dispatch();
|
|
102
|
+
});
|
|
103
|
+
expect(usePlayerStore.getState().elements).toHaveLength(600);
|
|
104
|
+
act(() => usePlayerStore.getState().setTimelineReady(true));
|
|
105
|
+
act(() =>
|
|
106
|
+
usePlayerStore.setState((state) => ({
|
|
107
|
+
elements: state.elements
|
|
108
|
+
.slice(20)
|
|
109
|
+
.map((element, index) => (index < 20 ? { ...element, sourceDuration: 99 } : element)),
|
|
110
|
+
})),
|
|
111
|
+
);
|
|
112
|
+
await act(async () => {
|
|
113
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
114
|
+
});
|
|
115
|
+
let changed = 0;
|
|
116
|
+
let unchanged = 0;
|
|
117
|
+
let other = 0;
|
|
118
|
+
stop = usePlayerStore.subscribe((state, before) => {
|
|
119
|
+
if (state.elements !== before.elements) changed++;
|
|
120
|
+
else if (Object.entries(state).every(([key, value]) => value === Reflect.get(before, key)))
|
|
121
|
+
unchanged++;
|
|
122
|
+
else other++;
|
|
123
|
+
});
|
|
124
|
+
await act(async () => {
|
|
125
|
+
release();
|
|
126
|
+
const started = Date.now();
|
|
127
|
+
while (getMediaProbeDiagnostics().cached < 30 && Date.now() - started < 4000)
|
|
128
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
129
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
130
|
+
});
|
|
131
|
+
const elements = usePlayerStore.getState().elements;
|
|
132
|
+
expect(elements).toHaveLength(580);
|
|
133
|
+
expect(requested.size).toBe(30);
|
|
134
|
+
expect(getMediaProbeDiagnostics()).toEqual({ cached: 30, failed: 0, inflight: 0 });
|
|
135
|
+
expect(elements.slice(0, 20).every((element) => element.sourceDuration === 99)).toBe(true);
|
|
136
|
+
expect(elements.slice(20).every((element) => element.sourceDuration === 12)).toBe(true);
|
|
137
|
+
expect(changed).toBe(560);
|
|
138
|
+
expect(unchanged).toBe(0);
|
|
139
|
+
expect(other).toBe(0);
|
|
140
|
+
} finally {
|
|
141
|
+
stop();
|
|
142
|
+
act(() => root.unmount());
|
|
143
|
+
usePlayerStore.getState().reset();
|
|
144
|
+
resetMediaProbeRegistry();
|
|
145
|
+
vi.unstubAllGlobals();
|
|
146
|
+
vi.useRealTimers();
|
|
147
|
+
document.body.innerHTML = "";
|
|
148
|
+
}
|
|
149
|
+
});
|
|
@@ -134,7 +134,7 @@ export function useTimelinePlayer({
|
|
|
134
134
|
(key, durationSeconds) => {
|
|
135
135
|
usePlayerStore.setState((state) => {
|
|
136
136
|
const idx = state.elements.findIndex((e) => (e.key ?? e.id) === key);
|
|
137
|
-
if (idx === -1 || state.elements[idx].sourceDuration != null) return
|
|
137
|
+
if (idx === -1 || state.elements[idx].sourceDuration != null) return state;
|
|
138
138
|
const patched = state.elements.slice();
|
|
139
139
|
patched[idx] = { ...state.elements[idx], sourceDuration: durationSeconds };
|
|
140
140
|
return { elements: patched };
|
|
@@ -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",
|