@hyperframes/studio 0.8.223 → 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-DD9KJoEr.js → index-CZI-XmnO.js} +4 -4
- package/dist/assets/{index-mbwAH5iR.js → index-LW6kxYVF.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/index.js +1 -1
- package/package.json +8 -8
- package/src/player/hooks/useTimelinePlayer.metadata.test.ts +149 -0
- package/src/player/hooks/useTimelinePlayer.ts +1 -1
- package/dist/assets/hyperframes-player-D0W1SNqK.js +0 -478
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
|
@@ -33083,7 +33083,7 @@ function useTimelinePlayer({
|
|
|
33083
33083
|
(key2, durationSeconds) => {
|
|
33084
33084
|
usePlayerStore.setState((state2) => {
|
|
33085
33085
|
const idx = state2.elements.findIndex((e) => (e.key ?? e.id) === key2);
|
|
33086
|
-
if (idx === -1 || state2.elements[idx].sourceDuration != null) return
|
|
33086
|
+
if (idx === -1 || state2.elements[idx].sourceDuration != null) return state2;
|
|
33087
33087
|
const patched = state2.elements.slice();
|
|
33088
33088
|
patched[idx] = { ...state2.elements[idx], sourceDuration: durationSeconds };
|
|
33089
33089
|
return { elements: patched };
|
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/
|
|
65
|
-
"@hyperframes/
|
|
66
|
-
"@hyperframes/shader-transitions": "0.8.
|
|
67
|
-
"@hyperframes/studio-server": "0.8.
|
|
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,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 };
|