@hyperframes/studio 0.9.18 → 0.9.20
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-pLs7eSzg.js → hyperframes-player-ZQZslutT.js} +3 -3
- package/dist/assets/index-Bgfyny02.css +1 -0
- package/dist/assets/{index-DZ7OLB7p.js → index-Bn5atbhb.js} +1 -1
- package/dist/assets/{index-D_iVCwL3.js → index-Bz2pYyGM.js} +196 -196
- package/dist/index.d.ts +1 -4
- package/dist/index.html +2 -2
- package/dist/index.js +6571 -5519
- package/dist/styles.css +1 -1
- package/package.json +8 -8
- package/src/components/DesktopGuideCard.tsx +21 -4
- package/src/components/EditorShell.tsx +10 -7
- package/src/components/OpenInDesktopButton.dom.test.tsx +64 -8
- package/src/components/OpenInDesktopButton.tsx +31 -14
- package/src/components/editor/DomEditGestureReadout.test.tsx +177 -0
- package/src/components/editor/DomEditGestureReadout.tsx +58 -0
- package/src/components/editor/DomEditOverlay.tsx +6 -0
- package/src/components/editor/domEditGestureReadoutState.ts +55 -0
- package/src/components/editor/domEditOverlayGestures.ts +12 -0
- package/src/components/editor/domEditOverlayStartGesture.ts +2 -0
- package/src/components/editor/useDomEditOverlayGestures.ts +12 -13
- package/src/components/nle/NLEPreview.test.ts +72 -0
- package/src/components/nle/NLEPreview.tsx +8 -9
- package/src/components/nle/PreviewZoomOverlay.tsx +155 -9
- package/src/components/nle/previewZoom.test.ts +98 -0
- package/src/components/nle/previewZoom.ts +65 -1
- package/src/components/panels/MotionBlurPanel.test.tsx +4 -0
- package/src/components/panels/MotionBlurPanel.tsx +1 -1
- package/src/components/storyboard/ApproveBoardButton.dom.test.tsx +48 -0
- package/src/components/storyboard/ApproveBoardButton.tsx +33 -0
- package/src/components/storyboard/PreviewStage.dom.test.tsx +114 -0
- package/src/components/storyboard/PreviewStage.player.dom.test.tsx +72 -0
- package/src/components/storyboard/PreviewStage.tsx +93 -0
- package/src/components/storyboard/StoryboardBoardView.tsx +322 -0
- package/src/components/storyboard/storyboardBoard.test.ts +183 -0
- package/src/components/storyboard/storyboardBoard.ts +148 -0
- package/src/components/storyboard/useStoryboardBoard.ts +99 -0
- package/src/hooks/elementPickerHoverLabel.browser.test.ts +85 -0
- package/src/hooks/elementPickerHoverLabel.test.ts +106 -0
- package/src/hooks/elementPickerHoverLabel.ts +173 -0
- package/src/hooks/fileChangeFanout.test.ts +20 -0
- package/src/hooks/fileChangeFanout.ts +13 -0
- package/src/hooks/useElementPicker.test.ts +254 -3
- package/src/hooks/useElementPicker.ts +237 -48
- package/src/hooks/useExternalFileChangeCoordinator.ts +6 -1
- package/src/player/components/timelineProviderStateBuilders.test.ts +3 -6
- package/src/player/components/timelineProviderStateBuilders.ts +1 -2
- package/src/player/components/timelineShellMeta.tsx +0 -2
- package/src/player/components/useTimelineProviderState.tsx +1 -2
- package/src/player/components/useTimelineShiftModifier.test.tsx +40 -0
- package/src/player/components/useTimelineShiftModifier.ts +7 -7
- package/src/styles/theme.css +2 -0
- package/dist/assets/index-CNZk2EFC.css +0 -1
|
@@ -5,7 +5,8 @@ export interface PreviewZoomState {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export const MIN_PREVIEW_ZOOM_PERCENT = 25;
|
|
8
|
-
export const MAX_PREVIEW_ZOOM_PERCENT =
|
|
8
|
+
export const MAX_PREVIEW_ZOOM_PERCENT = 1600;
|
|
9
|
+
export const PREVIEW_PIXEL_GRID_MIN_ZOOM_PERCENT = 800;
|
|
9
10
|
export const PREVIEW_PAN_SURFACE_SELECTOR = '[data-preview-pan-surface="true"]';
|
|
10
11
|
export const PREVIEW_PAN_OVERSCROLL_PX = 48;
|
|
11
12
|
export const DEFAULT_PREVIEW_ZOOM: PreviewZoomState = {
|
|
@@ -32,6 +33,16 @@ export function clampPreviewZoomPercent(percent: number): number {
|
|
|
32
33
|
return Math.min(MAX_PREVIEW_ZOOM_PERCENT, Math.max(MIN_PREVIEW_ZOOM_PERCENT, percent));
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
export function parsePreviewZoomInput(text: string): number | null {
|
|
37
|
+
const match = /^\s*(\d+(?:\.\d*)?|\.\d+)\s*%?\s*$/.exec(text);
|
|
38
|
+
if (!match) return null;
|
|
39
|
+
return clampPreviewZoomPercent(Number(match[1]));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function showsPreviewPixelGrid(zoomPercent: number): boolean {
|
|
43
|
+
return zoomPercent > PREVIEW_PIXEL_GRID_MIN_ZOOM_PERCENT;
|
|
44
|
+
}
|
|
45
|
+
|
|
35
46
|
export function canStartPreviewPan(button: number): boolean {
|
|
36
47
|
return button === 1;
|
|
37
48
|
}
|
|
@@ -144,6 +155,29 @@ export function resolvePreviewWheelZoom(input: {
|
|
|
144
155
|
};
|
|
145
156
|
}
|
|
146
157
|
|
|
158
|
+
export function resolvePreviewTypedZoom(input: {
|
|
159
|
+
state: PreviewZoomState;
|
|
160
|
+
zoomPercent: number;
|
|
161
|
+
viewportWidth: number;
|
|
162
|
+
viewportHeight: number;
|
|
163
|
+
contentWidth?: number;
|
|
164
|
+
contentHeight?: number;
|
|
165
|
+
}): PreviewZoomState {
|
|
166
|
+
const oldZoom = clampPreviewZoomPercent(input.state.zoomPercent);
|
|
167
|
+
const nextZoomPercent = clampPreviewZoomPercent(input.zoomPercent);
|
|
168
|
+
const ratio = nextZoomPercent / oldZoom;
|
|
169
|
+
const pan = clampPreviewPanForZoom(
|
|
170
|
+
input.state.panX * ratio,
|
|
171
|
+
input.state.panY * ratio,
|
|
172
|
+
nextZoomPercent,
|
|
173
|
+
input.viewportWidth,
|
|
174
|
+
input.viewportHeight,
|
|
175
|
+
input.contentWidth ?? input.viewportWidth,
|
|
176
|
+
input.contentHeight ?? input.viewportHeight,
|
|
177
|
+
);
|
|
178
|
+
return { zoomPercent: nextZoomPercent, ...pan };
|
|
179
|
+
}
|
|
180
|
+
|
|
147
181
|
export function resolvePreviewWheelPan(input: {
|
|
148
182
|
state: PreviewZoomState;
|
|
149
183
|
deltaX: number;
|
|
@@ -169,6 +203,36 @@ export function resolvePreviewWheelPan(input: {
|
|
|
169
203
|
};
|
|
170
204
|
}
|
|
171
205
|
|
|
206
|
+
export interface PreviewPixelGridBox {
|
|
207
|
+
left: number;
|
|
208
|
+
top: number;
|
|
209
|
+
width: number;
|
|
210
|
+
height: number;
|
|
211
|
+
cellPx: number;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export function resolvePreviewPixelGrid(input: {
|
|
215
|
+
state: PreviewZoomState;
|
|
216
|
+
rect: { width: number; height: number };
|
|
217
|
+
stage: { width: number; height: number };
|
|
218
|
+
width: number;
|
|
219
|
+
}): PreviewPixelGridBox | null {
|
|
220
|
+
const zoomPercent = clampPreviewZoomPercent(input.state.zoomPercent);
|
|
221
|
+
if (!showsPreviewPixelGrid(zoomPercent) || !(input.width > 0) || !(input.stage.width > 0)) {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
const scale = zoomPercent / 100;
|
|
225
|
+
const width = input.stage.width * scale;
|
|
226
|
+
const height = input.stage.height * scale;
|
|
227
|
+
return {
|
|
228
|
+
left: toDomPrecision((input.rect.width - width) / 2 + input.state.panX),
|
|
229
|
+
top: toDomPrecision((input.rect.height - height) / 2 + input.state.panY),
|
|
230
|
+
width: toDomPrecision(width),
|
|
231
|
+
height: toDomPrecision(height),
|
|
232
|
+
cellPx: toDomPrecision(width / input.width),
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
172
236
|
export interface PreviewVisibleRegion {
|
|
173
237
|
left: number;
|
|
174
238
|
top: number;
|
|
@@ -95,6 +95,10 @@ describe("MotionBlurPanel", () => {
|
|
|
95
95
|
).toHaveLength(0);
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
+
it("labels itself Motion blur (Beta)", async () => {
|
|
99
|
+
expect((await mount()).textContent).toContain("Motion blur (Beta)");
|
|
100
|
+
});
|
|
101
|
+
|
|
98
102
|
it("shows the level the root is at", async () => {
|
|
99
103
|
expect(checked(await mount())).toEqual(["Off"]);
|
|
100
104
|
cleanup();
|
|
@@ -136,7 +136,7 @@ export const MotionBlurPanel = memo(function MotionBlurPanel({
|
|
|
136
136
|
|
|
137
137
|
return (
|
|
138
138
|
<div className="flex h-full flex-col gap-3 overflow-y-auto p-3 text-[11px] text-neutral-300">
|
|
139
|
-
<span className="text-[12px] font-medium text-neutral-100">Motion blur</span>
|
|
139
|
+
<span className="text-[12px] font-medium text-neutral-100">Motion blur (Beta)</span>
|
|
140
140
|
<div role="radiogroup" aria-label="Motion blur" className="flex gap-1.5">
|
|
141
141
|
{BLUR_LEVELS.map(({ level, label }) => (
|
|
142
142
|
<Button
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import React, { act } from "react";
|
|
3
|
+
import { createRoot } from "react-dom/client";
|
|
4
|
+
import { afterEach, expect, it, vi } from "vitest";
|
|
5
|
+
|
|
6
|
+
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
7
|
+
|
|
8
|
+
const showToast = vi.fn();
|
|
9
|
+
vi.mock("../../contexts/StudioContext", () => ({ useStudioShellContext: () => ({ showToast }) }));
|
|
10
|
+
const track = vi.fn();
|
|
11
|
+
vi.mock("../../utils/studioTelemetry", () => ({ trackStudioEvent: track }));
|
|
12
|
+
const copy = vi.fn(async (_text: string) => true);
|
|
13
|
+
vi.mock("../../utils/clipboard", () => ({ copyTextToClipboard: copy }));
|
|
14
|
+
|
|
15
|
+
const { APPROVE_WORDS, ApproveBoardButton } = await import("./ApproveBoardButton");
|
|
16
|
+
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
document.body.innerHTML = "";
|
|
19
|
+
vi.clearAllMocks();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
async function press() {
|
|
23
|
+
const host = document.createElement("div");
|
|
24
|
+
document.body.append(host);
|
|
25
|
+
const root = createRoot(host);
|
|
26
|
+
await act(async () => root.render(<ApproveBoardButton />));
|
|
27
|
+
await act(async () =>
|
|
28
|
+
document.querySelector<HTMLButtonElement>('[data-testid="storyboard-approve"]')!.click(),
|
|
29
|
+
);
|
|
30
|
+
await act(async () => root.unmount());
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
it("approves without the desktop app: copies the go for the person's own agent", async () => {
|
|
34
|
+
await press();
|
|
35
|
+
expect(copy).toHaveBeenCalledWith(APPROVE_WORDS);
|
|
36
|
+
expect(showToast).toHaveBeenCalledWith(
|
|
37
|
+
"Copied. Paste it to your agent to start the build.",
|
|
38
|
+
"info",
|
|
39
|
+
);
|
|
40
|
+
expect(track).toHaveBeenCalledWith("storyboard_action", { action: "approve_copied" });
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("spells the go out when the clipboard refuses, so the person can still type it", async () => {
|
|
44
|
+
copy.mockResolvedValueOnce(false);
|
|
45
|
+
await press();
|
|
46
|
+
expect(showToast).toHaveBeenCalledWith(expect.stringContaining(APPROVE_WORDS), "info");
|
|
47
|
+
expect(track).toHaveBeenCalledWith("storyboard_action", { action: "approve_copy_failed" });
|
|
48
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useStudioShellContext } from "../../contexts/StudioContext";
|
|
2
|
+
import { copyTextToClipboard } from "../../utils/clipboard";
|
|
3
|
+
import { trackStudioEvent } from "../../utils/studioTelemetry";
|
|
4
|
+
import { Button } from "../ui";
|
|
5
|
+
|
|
6
|
+
export const APPROVE_WORDS = "The storyboard is approved. Build the video from it.";
|
|
7
|
+
|
|
8
|
+
/** Studio talks to the person's own agent through their chat: Approve copies the go for them to paste there. */
|
|
9
|
+
export function ApproveBoardButton() {
|
|
10
|
+
const { showToast } = useStudioShellContext();
|
|
11
|
+
const approve = async () => {
|
|
12
|
+
const copied = await copyTextToClipboard(APPROVE_WORDS);
|
|
13
|
+
trackStudioEvent("storyboard_action", {
|
|
14
|
+
action: copied ? "approve_copied" : "approve_copy_failed",
|
|
15
|
+
});
|
|
16
|
+
showToast(
|
|
17
|
+
copied
|
|
18
|
+
? "Copied. Paste it to your agent to start the build."
|
|
19
|
+
: `Couldn't copy. Tell your agent: "${APPROVE_WORDS}"`,
|
|
20
|
+
"info",
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
return (
|
|
24
|
+
<Button
|
|
25
|
+
variant="primary"
|
|
26
|
+
size="sm"
|
|
27
|
+
onClick={() => void approve()}
|
|
28
|
+
data-testid="storyboard-approve"
|
|
29
|
+
>
|
|
30
|
+
Approve
|
|
31
|
+
</Button>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import React, { act, useEffect } from "react";
|
|
3
|
+
import { createRoot, type Root } from "react-dom/client";
|
|
4
|
+
import { create } from "zustand";
|
|
5
|
+
import { afterEach, beforeEach, expect, it, vi } from "vitest";
|
|
6
|
+
import type { StoryboardBoard } from "./useStoryboardBoard";
|
|
7
|
+
|
|
8
|
+
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
9
|
+
|
|
10
|
+
const pauses = vi.fn();
|
|
11
|
+
const player = create<{
|
|
12
|
+
isPlaying: boolean;
|
|
13
|
+
playLocked: boolean;
|
|
14
|
+
setPlayLocked: (locked: boolean) => void;
|
|
15
|
+
setIsPlaying: (playing: boolean) => void;
|
|
16
|
+
requestPlayback: (playing: boolean) => void;
|
|
17
|
+
requestSeek: (seconds: number) => void;
|
|
18
|
+
}>((set) => ({
|
|
19
|
+
isPlaying: false,
|
|
20
|
+
playLocked: false,
|
|
21
|
+
setPlayLocked: (playLocked) => set({ playLocked }),
|
|
22
|
+
setIsPlaying: (isPlaying) => set({ isPlaying }),
|
|
23
|
+
requestPlayback: (playing) => {
|
|
24
|
+
if (!playing) pauses();
|
|
25
|
+
},
|
|
26
|
+
requestSeek: () => {},
|
|
27
|
+
}));
|
|
28
|
+
vi.mock("../../player", () => ({ usePlayerStore: player }));
|
|
29
|
+
vi.mock("../../utils/studioTelemetry", () => ({ trackStudioEvent: vi.fn() }));
|
|
30
|
+
vi.mock("./StoryboardBoardView", () => ({
|
|
31
|
+
StoryboardBoardView: () => <div data-testid="board-view" />,
|
|
32
|
+
}));
|
|
33
|
+
let board: StoryboardBoard;
|
|
34
|
+
vi.mock("./useStoryboardBoard", () => ({ useStoryboardBoard: () => board }));
|
|
35
|
+
|
|
36
|
+
const { PreviewStage } = await import("./PreviewStage");
|
|
37
|
+
|
|
38
|
+
const noBoard: StoryboardBoard = {
|
|
39
|
+
path: null,
|
|
40
|
+
revision: 0,
|
|
41
|
+
read: { state: "loading" },
|
|
42
|
+
appeared: false,
|
|
43
|
+
};
|
|
44
|
+
const written: StoryboardBoard = { ...noBoard, path: "boards/storyboard.html", appeared: true };
|
|
45
|
+
|
|
46
|
+
let mounts = 0;
|
|
47
|
+
function Film() {
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
mounts += 1;
|
|
50
|
+
}, []);
|
|
51
|
+
return <div data-testid="film" />;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let root: Root;
|
|
55
|
+
const render = () =>
|
|
56
|
+
act(async () =>
|
|
57
|
+
root.render(
|
|
58
|
+
<PreviewStage projectId="p1">
|
|
59
|
+
<Film />
|
|
60
|
+
</PreviewStage>,
|
|
61
|
+
),
|
|
62
|
+
);
|
|
63
|
+
const boardShown = () => document.querySelector('[data-testid="board-view"]') !== null;
|
|
64
|
+
|
|
65
|
+
beforeEach(() => {
|
|
66
|
+
mounts = 0;
|
|
67
|
+
board = noBoard;
|
|
68
|
+
player.setState({ isPlaying: false, playLocked: false });
|
|
69
|
+
const host = document.createElement("div");
|
|
70
|
+
document.body.append(host);
|
|
71
|
+
root = createRoot(host);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
afterEach(async () => {
|
|
75
|
+
await act(async () => root.unmount());
|
|
76
|
+
document.body.innerHTML = "";
|
|
77
|
+
vi.clearAllMocks();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("keeps the film mounted and pauses it when the agent's board first appears", async () => {
|
|
81
|
+
player.setState({ isPlaying: true });
|
|
82
|
+
await render();
|
|
83
|
+
board = written;
|
|
84
|
+
await render();
|
|
85
|
+
expect(boardShown()).toBe(true);
|
|
86
|
+
expect(mounts).toBe(1);
|
|
87
|
+
expect(pauses).toHaveBeenCalled();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("keeps the film mounted when the board goes and comes back", async () => {
|
|
91
|
+
board = written;
|
|
92
|
+
await render();
|
|
93
|
+
board = noBoard;
|
|
94
|
+
await render();
|
|
95
|
+
expect(boardShown()).toBe(false);
|
|
96
|
+
board = written;
|
|
97
|
+
await render();
|
|
98
|
+
expect(mounts).toBe(1);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("holds the player while the board covers the film, and leaves another owner's hold alone", async () => {
|
|
102
|
+
board = written;
|
|
103
|
+
await render();
|
|
104
|
+
expect(player.getState().playLocked).toBe(true);
|
|
105
|
+
board = noBoard;
|
|
106
|
+
await render();
|
|
107
|
+
expect(player.getState().playLocked).toBe(false);
|
|
108
|
+
player.setState({ playLocked: true });
|
|
109
|
+
board = written;
|
|
110
|
+
await render();
|
|
111
|
+
board = noBoard;
|
|
112
|
+
await render();
|
|
113
|
+
expect(player.getState().playLocked).toBe(true);
|
|
114
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import React, { act } from "react";
|
|
3
|
+
import { createRoot, type Root } from "react-dom/client";
|
|
4
|
+
import { afterEach, expect, it, vi } from "vitest";
|
|
5
|
+
import {
|
|
6
|
+
makeAdapterWindow,
|
|
7
|
+
makeFakeIframe,
|
|
8
|
+
renderTimelinePlayerHarness,
|
|
9
|
+
resetPlayerStore,
|
|
10
|
+
} from "../../player/hooks/timelinePlayerTestHarness";
|
|
11
|
+
import { usePlayerStore } from "../../player/store/playerStore";
|
|
12
|
+
import type { StoryboardBoard } from "./useStoryboardBoard";
|
|
13
|
+
|
|
14
|
+
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
15
|
+
|
|
16
|
+
vi.mock("../../utils/studioTelemetry", () => ({ trackStudioEvent: vi.fn() }));
|
|
17
|
+
vi.mock("./StoryboardBoardView", () => ({
|
|
18
|
+
StoryboardBoardView: ({ onShowInPreview }: { onShowInPreview: (s: number | null) => void }) => (
|
|
19
|
+
<button data-testid="back-to-film" onClick={() => onShowInPreview(null)} />
|
|
20
|
+
),
|
|
21
|
+
}));
|
|
22
|
+
const board: StoryboardBoard = {
|
|
23
|
+
path: "boards/storyboard.html",
|
|
24
|
+
revision: 0,
|
|
25
|
+
read: { state: "loading" },
|
|
26
|
+
appeared: true,
|
|
27
|
+
};
|
|
28
|
+
vi.mock("./useStoryboardBoard", () => ({ useStoryboardBoard: () => board }));
|
|
29
|
+
|
|
30
|
+
const { PreviewStage } = await import("./PreviewStage");
|
|
31
|
+
|
|
32
|
+
let stage: Root | null = null;
|
|
33
|
+
afterEach(() => {
|
|
34
|
+
act(() => stage?.unmount());
|
|
35
|
+
stage = null;
|
|
36
|
+
document.body.innerHTML = "";
|
|
37
|
+
resetPlayerStore();
|
|
38
|
+
usePlayerStore.setState({ playLocked: false });
|
|
39
|
+
vi.restoreAllMocks();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const pressJ = () =>
|
|
43
|
+
act(() => {
|
|
44
|
+
window.dispatchEvent(new KeyboardEvent("keydown", { key: "j", code: "KeyJ" }));
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("J under the board leaves the hidden film where it was, and works again back on Preview", () => {
|
|
48
|
+
const frames: FrameRequestCallback[] = [];
|
|
49
|
+
vi.spyOn(window, "requestAnimationFrame").mockImplementation((tick) => frames.push(tick));
|
|
50
|
+
const { api, root } = renderTimelinePlayerHarness();
|
|
51
|
+
const { adapter, win } = makeAdapterWindow();
|
|
52
|
+
act(() => {
|
|
53
|
+
api.iframeRef.current = makeFakeIframe(win);
|
|
54
|
+
api.onIframeLoad();
|
|
55
|
+
usePlayerStore.setState({ timelineReady: true });
|
|
56
|
+
});
|
|
57
|
+
adapter.seek(10);
|
|
58
|
+
const host = document.createElement("div");
|
|
59
|
+
document.body.append(host);
|
|
60
|
+
stage = createRoot(host);
|
|
61
|
+
act(() => stage!.render(<PreviewStage projectId="p1">{null}</PreviewStage>));
|
|
62
|
+
|
|
63
|
+
pressJ();
|
|
64
|
+
for (const tick of frames.splice(0)) act(() => tick(1000));
|
|
65
|
+
expect(adapter.getTime()).toBe(10);
|
|
66
|
+
expect(frames).toHaveLength(0);
|
|
67
|
+
|
|
68
|
+
act(() => document.querySelector<HTMLButtonElement>('[data-testid="back-to-film"]')!.click());
|
|
69
|
+
pressJ();
|
|
70
|
+
expect(frames.length).toBeGreaterThan(0);
|
|
71
|
+
act(() => root.unmount());
|
|
72
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState, type ReactNode } from "react";
|
|
2
|
+
import { usePlayerStore } from "../../player";
|
|
3
|
+
import { trackStudioEvent } from "../../utils/studioTelemetry";
|
|
4
|
+
import { Tab, Tabs, TabsList, cn } from "../ui";
|
|
5
|
+
import { StoryboardBoardView } from "./StoryboardBoardView";
|
|
6
|
+
import { useStoryboardBoard } from "./useStoryboardBoard";
|
|
7
|
+
|
|
8
|
+
type StageTab = "preview" | "storyboard";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The preview panel's stage: the film, and beside it the storyboard once the project has one. With no board there
|
|
12
|
+
* is no strip at all. The film keeps one place in the tree whether or not a board exists, so a board appearing or
|
|
13
|
+
* going never remounts it, and it stays paused under the board so going back keeps its place.
|
|
14
|
+
*/
|
|
15
|
+
export function PreviewStage({ projectId, children }: { projectId: string; children: ReactNode }) {
|
|
16
|
+
const board = useStoryboardBoard(projectId);
|
|
17
|
+
const [tab, setTab] = useState<StageTab>("preview");
|
|
18
|
+
const [dotted, setDotted] = useState(false);
|
|
19
|
+
const shownRevision = useRef(board.revision);
|
|
20
|
+
const tabRef = useRef(tab);
|
|
21
|
+
tabRef.current = tab;
|
|
22
|
+
|
|
23
|
+
const show = useCallback((next: StageTab, action?: string) => {
|
|
24
|
+
if (next === tabRef.current) return;
|
|
25
|
+
if (next === "storyboard") usePlayerStore.getState().requestPlayback(false);
|
|
26
|
+
trackStudioEvent("storyboard_tab", {
|
|
27
|
+
action: action ?? (next === "storyboard" ? "open" : "close"),
|
|
28
|
+
});
|
|
29
|
+
setTab(next);
|
|
30
|
+
}, []);
|
|
31
|
+
|
|
32
|
+
// A board that appears while Studio is open is the agent's stop: show it, as Desktop does.
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (board.appeared) show("storyboard", "shown_on_write");
|
|
35
|
+
}, [board.appeared, show]);
|
|
36
|
+
|
|
37
|
+
// The film is hidden under the board: the player's own hold refuses a play from anywhere (J, Space, a request)
|
|
38
|
+
// before it starts. Another owner's hold is left as it is.
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (tab !== "storyboard" || usePlayerStore.getState().playLocked) return;
|
|
41
|
+
usePlayerStore.getState().setPlayLocked(true);
|
|
42
|
+
return () => usePlayerStore.getState().setPlayLocked(false);
|
|
43
|
+
}, [tab]);
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (tab === "storyboard") {
|
|
47
|
+
shownRevision.current = board.revision;
|
|
48
|
+
setDotted(false);
|
|
49
|
+
} else if (board.revision !== shownRevision.current) setDotted(true);
|
|
50
|
+
}, [tab, board.revision]);
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (!board.path) setTab("preview");
|
|
54
|
+
}, [board.path]);
|
|
55
|
+
|
|
56
|
+
const path = board.path;
|
|
57
|
+
const onBoard = path !== null && tab === "storyboard";
|
|
58
|
+
return (
|
|
59
|
+
<div className="flex h-full w-full min-w-0 flex-col">
|
|
60
|
+
{path !== null && (
|
|
61
|
+
<Tabs value={tab} onValueChange={(value) => show(value as StageTab)}>
|
|
62
|
+
<div className="flex h-9 shrink-0 items-center border-b border-border-strong bg-surface px-2">
|
|
63
|
+
<TabsList aria-label="Preview pages" className="bg-transparent p-0">
|
|
64
|
+
<Tab value="preview">Preview</Tab>
|
|
65
|
+
<Tab value="storyboard" data-testid="stage-tab-storyboard">
|
|
66
|
+
Storyboard
|
|
67
|
+
{dotted && (
|
|
68
|
+
<span
|
|
69
|
+
className="ml-1.5 inline-block h-1.5 w-1.5 rounded-full bg-accent"
|
|
70
|
+
aria-label=", updated"
|
|
71
|
+
/>
|
|
72
|
+
)}
|
|
73
|
+
</Tab>
|
|
74
|
+
</TabsList>
|
|
75
|
+
</div>
|
|
76
|
+
</Tabs>
|
|
77
|
+
)}
|
|
78
|
+
<div className={cn("relative min-h-0 flex-1", onBoard && "hidden")}>{children}</div>
|
|
79
|
+
{onBoard && (
|
|
80
|
+
<div className="min-h-0 flex-1">
|
|
81
|
+
<StoryboardBoardView
|
|
82
|
+
projectId={projectId}
|
|
83
|
+
board={{ ...board, path }}
|
|
84
|
+
onShowInPreview={(seconds) => {
|
|
85
|
+
setTab("preview");
|
|
86
|
+
if (seconds !== null) usePlayerStore.getState().requestSeek(seconds);
|
|
87
|
+
}}
|
|
88
|
+
/>
|
|
89
|
+
</div>
|
|
90
|
+
)}
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
}
|