@hyperframes/studio 0.9.65 → 0.9.67
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-DHYu0XuV.js +573 -0
- package/dist/assets/{index-tvLrzMBv.js → index-BBKHfua5.js} +180 -180
- package/dist/assets/{index-CAjz3b83.js → index-DqND4rHq.js} +1 -1
- package/dist/assets/{pausedVideoDecoder-xC5IGkfB.js → pausedVideoDecoder-B1FNXBMe.js} +1 -1
- package/dist/{chunk-VDDEXNVX.js → chunk-LR3VT3EF.js} +20 -0
- package/dist/index.html +1 -1
- package/dist/index.js +396 -160
- package/dist/player.js +1 -1
- package/package.json +8 -8
- package/src/captions/components/CaptionOverlay.sealed.test.ts +2 -25
- package/src/components/editor/LayersPanel.opaque.test.ts +4 -29
- package/src/components/editor/domEditOverlayCrop.ts +78 -15
- package/src/components/editor/domEditOverlayCropFrameLift.test.ts +64 -0
- package/src/components/editor/gsapLivePreview.sealed.test.ts +35 -0
- package/src/components/editor/gsapLivePreview.ts +6 -2
- package/src/components/editor/gsapMoveSealedPreview.test.ts +3 -23
- package/src/components/editor/previewDrafts.test.ts +13 -39
- package/src/components/editor/previewDrafts.ts +2 -0
- package/src/components/editor/previewGestureStartRead.test.ts +59 -21
- package/src/components/editor/previewGestureStartRead.ts +9 -0
- package/src/components/editor/previewLayers.test.ts +3 -20
- package/src/components/editor/previewOverlayRects.test.ts +3 -20
- package/src/components/editor/previewPointerTargets.test.ts +3 -20
- package/src/components/editor/previewSelection.test.ts +51 -35
- package/src/components/editor/previewSelection.ts +17 -0
- package/src/components/editor/useColorGradingController.sealed.test.ts +5 -30
- package/src/components/editor/useMotionPathData.sealed.test.ts +2 -29
- package/src/components/nle/NLEContext.drillDown.test.ts +85 -0
- package/src/components/nle/NLEContext.tsx +21 -23
- package/src/components/nle/NLEPreview.test.ts +18 -3
- package/src/components/nle/NLEPreview.tsx +10 -1
- package/src/components/nle/audioSealedPreview.test.ts +5 -32
- package/src/hooks/appHotkeysDispatch.ts +38 -1
- package/src/hooks/domEditCommits.sealed.test.ts +191 -0
- package/src/hooks/domStyleCommit.ts +18 -7
- package/src/hooks/gsapMutationClient.test.ts +32 -0
- package/src/hooks/gsapMutationClient.ts +6 -3
- package/src/hooks/gsapResizeIntercept.ts +7 -2
- package/src/hooks/timelineTimingSync.test.ts +1 -1
- package/src/hooks/useAppHotkeys.previewForwarding.test.tsx +134 -0
- package/src/hooks/useAppHotkeys.ts +36 -1
- package/src/hooks/useDomEditAttributeCommits.ts +43 -19
- package/src/hooks/useEnableKeyframes.sealed.test.ts +2 -29
- package/src/hooks/useFreezeFrame.test.ts +3 -2
- package/src/hooks/useFreezeFrame.ts +2 -2
- package/src/hooks/useGroupCommits.ts +7 -2
- package/src/hooks/useSlideshowTabState.test.ts +47 -3
- package/src/hooks/useSlideshowTabState.ts +32 -16
- package/src/player/hooks/timelinePlayerTestHarness.ts +2 -1
- package/src/player/hooks/usePlaybackKeyboard.ts +1 -1
- package/src/player/hooks/usePreviewFirstFrameTelemetry.sealed.test.ts +43 -0
- package/src/player/hooks/usePreviewFirstFrameTelemetry.ts +11 -7
- package/src/player/hooks/useTimelineSyncCallbacks.sealed.test.ts +39 -31
- package/src/player/hooks/useTimelineSyncCallbacks.ts +21 -11
- package/src/player/lib/previewChannel.test.ts +10 -0
- package/src/player/lib/previewChannel.ts +21 -0
- package/src/player/lib/previewElements.test.ts +34 -1
- package/src/player/lib/previewElements.ts +99 -16
- package/src/player/lib/sealedPreviewFrame.test-helpers.ts +38 -0
- package/src/player/lib/timelineIframeHelpers.ts +1 -1
- package/src/utils/blockInstaller.test.ts +82 -48
- package/src/utils/blockInstaller.ts +6 -14
- package/src/utils/previewCompositionSize.test.ts +61 -0
- package/src/utils/previewCompositionSize.ts +21 -1
- package/src/utils/studioSaveDiagnostics.ts +2 -0
- package/dist/assets/hyperframes-player-Dscc6yHD.js +0 -573
|
@@ -1,64 +1,74 @@
|
|
|
1
1
|
// @vitest-environment happy-dom
|
|
2
2
|
|
|
3
3
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
4
|
+
import { previewRequest } from "../player/lib/previewChannel";
|
|
4
5
|
import { addBlockToProject } from "./blockInstaller";
|
|
5
6
|
|
|
7
|
+
vi.mock("../player/lib/previewChannel", async (importOriginal) => {
|
|
8
|
+
const actual = await importOriginal<typeof import("../player/lib/previewChannel")>();
|
|
9
|
+
return { ...actual, previewRequest: vi.fn(async () => null) };
|
|
10
|
+
});
|
|
11
|
+
|
|
6
12
|
afterEach(() => {
|
|
7
13
|
vi.unstubAllGlobals();
|
|
8
14
|
});
|
|
9
15
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
}),
|
|
16
|
+
async function addHud(extra: Partial<Parameters<typeof addBlockToProject>[0]> = {}) {
|
|
17
|
+
const componentPath = "compositions/camcorder-hud.html";
|
|
18
|
+
const targetPath = "compositions/scene.html";
|
|
19
|
+
const files = new Map([
|
|
20
|
+
[
|
|
21
|
+
componentPath,
|
|
22
|
+
`<body><div data-composition-id="camcorder-hud"><div class="hud"></div></div></body>`,
|
|
23
|
+
],
|
|
24
|
+
[
|
|
25
|
+
targetPath,
|
|
26
|
+
`<main data-composition-id="scene" data-duration="10" data-width="1920" data-height="1080"></main>`,
|
|
27
|
+
],
|
|
28
|
+
]);
|
|
29
|
+
vi.stubGlobal(
|
|
30
|
+
"fetch",
|
|
31
|
+
vi.fn().mockResolvedValue({
|
|
32
|
+
ok: true,
|
|
33
|
+
json: async () => ({
|
|
34
|
+
written: [componentPath],
|
|
35
|
+
block: {
|
|
36
|
+
name: "camcorder-hud",
|
|
37
|
+
title: "Camcorder HUD",
|
|
38
|
+
description: "HUD",
|
|
39
|
+
type: "hyperframes:block",
|
|
40
|
+
files: [],
|
|
41
|
+
dimensions: { width: 1920, height: 1080 },
|
|
42
|
+
duration: 4,
|
|
43
|
+
},
|
|
40
44
|
}),
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
}),
|
|
46
|
+
);
|
|
47
|
+
const writeProjectFile = vi.fn(async (path: string, content: string) => {
|
|
48
|
+
files.set(path, content);
|
|
49
|
+
});
|
|
45
50
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
const result = await addBlockToProject({
|
|
52
|
+
projectId: "project",
|
|
53
|
+
blockName: "camcorder-hud",
|
|
54
|
+
activeCompPath: targetPath,
|
|
55
|
+
placement: { start: 2.5, duration: 4.25, track: 3 },
|
|
56
|
+
timelineElements: [],
|
|
57
|
+
readProjectFile: async (path) => files.get(path) ?? "",
|
|
58
|
+
writeProjectFile,
|
|
59
|
+
recordEdit: vi.fn().mockResolvedValue(undefined),
|
|
60
|
+
refreshFileTree: vi.fn().mockResolvedValue(undefined),
|
|
61
|
+
reloadPreview: vi.fn(),
|
|
62
|
+
showToast: vi.fn(),
|
|
63
|
+
...extra,
|
|
64
|
+
});
|
|
65
|
+
return { result, source: files.get(targetPath) };
|
|
66
|
+
}
|
|
59
67
|
|
|
68
|
+
describe("addBlockToProject", () => {
|
|
69
|
+
it("uses an explicit selected-media duration and track for a Registry overlay block", async () => {
|
|
70
|
+
const { result, source } = await addHud();
|
|
60
71
|
expect(result?.block.name).toBe("camcorder-hud");
|
|
61
|
-
const source = files.get(targetPath);
|
|
62
72
|
expect(source).toContain('data-composition-src="compositions/camcorder-hud.html"');
|
|
63
73
|
expect(source).toContain('data-start="2.5"');
|
|
64
74
|
expect(source).toContain('data-duration="4.25"');
|
|
@@ -68,4 +78,28 @@ describe("addBlockToProject", () => {
|
|
|
68
78
|
expect(result?.hostKey).toBe("compositions/scene.html#camcorder-hud");
|
|
69
79
|
expect(source).toContain('id="camcorder-hud"');
|
|
70
80
|
});
|
|
81
|
+
|
|
82
|
+
it("stacks the block above everything a sealed preview paints, read over its editing port", async () => {
|
|
83
|
+
const iframe = document.createElement("iframe");
|
|
84
|
+
Object.defineProperty(iframe, "contentDocument", {
|
|
85
|
+
get() {
|
|
86
|
+
throw new DOMException(
|
|
87
|
+
"Blocked a frame from accessing a cross-origin frame.",
|
|
88
|
+
"SecurityError",
|
|
89
|
+
);
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
vi.mocked(previewRequest).mockResolvedValueOnce({ zIndex: 41 });
|
|
93
|
+
const { source } = await addHud({ previewIframe: iframe });
|
|
94
|
+
expect(vi.mocked(previewRequest)).toHaveBeenCalledWith(iframe, "max-z-index", {});
|
|
95
|
+
expect(source).toContain("z-index: 42");
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("stacks at 1 when the preview's z-index is not a whole number of zero or more", async () => {
|
|
99
|
+
for (const zIndex of [-5, 0.5, 1e308]) {
|
|
100
|
+
vi.mocked(previewRequest).mockResolvedValueOnce({ zIndex });
|
|
101
|
+
const { source } = await addHud({ previewIframe: document.createElement("iframe") });
|
|
102
|
+
expect(source).toContain('z-index: 1"');
|
|
103
|
+
}
|
|
104
|
+
});
|
|
71
105
|
});
|
|
@@ -13,20 +13,11 @@ import { serializeStudioFileMutation } from "./studioFileMutationCoordinator";
|
|
|
13
13
|
import { extendRootDurationInSource } from "./rootDuration";
|
|
14
14
|
import { deriveTimelineStoreKeyForDomId } from "../player/lib/timelineElementHelpers";
|
|
15
15
|
import { studioApiFetch } from "./studioApiFetch";
|
|
16
|
+
import { previewRequest } from "../player/lib/previewChannel";
|
|
16
17
|
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (!doc) return 0;
|
|
21
|
-
let max = 0;
|
|
22
|
-
for (const el of doc.body.querySelectorAll("*")) {
|
|
23
|
-
const z = parseInt(getComputedStyle(el).zIndex, 10);
|
|
24
|
-
if (Number.isFinite(z) && z > max) max = z;
|
|
25
|
-
}
|
|
26
|
-
return max;
|
|
27
|
-
} catch {
|
|
28
|
-
return 0;
|
|
29
|
-
}
|
|
18
|
+
async function previewMaxZIndex(iframe: HTMLIFrameElement | null): Promise<number> {
|
|
19
|
+
const zIndex = iframe ? (await previewRequest(iframe, "max-z-index", {}))?.zIndex : undefined;
|
|
20
|
+
return Number.isSafeInteger(zIndex) && (zIndex as number) >= 0 ? (zIndex as number) : 0;
|
|
30
21
|
}
|
|
31
22
|
|
|
32
23
|
interface AddBlockOptions {
|
|
@@ -214,6 +205,7 @@ export async function addBlockToProject(
|
|
|
214
205
|
timelineElements: relevantElements,
|
|
215
206
|
currentTime: opts.currentTime ?? 0,
|
|
216
207
|
});
|
|
208
|
+
const zIndex = (await previewMaxZIndex(opts.previewIframe ?? null)) + 1;
|
|
217
209
|
let hostId = "";
|
|
218
210
|
const insertHost = (originalContent: string) => {
|
|
219
211
|
const { width, height } = resolveTimelineAssetCompositionSize(originalContent);
|
|
@@ -228,7 +220,7 @@ export async function addBlockToProject(
|
|
|
228
220
|
height,
|
|
229
221
|
left: visualPosition ? Math.round(visualPosition.left) : 0,
|
|
230
222
|
top: visualPosition ? Math.round(visualPosition.top) : 0,
|
|
231
|
-
zIndex
|
|
223
|
+
zIndex,
|
|
232
224
|
});
|
|
233
225
|
return extendRootDurationInSource(
|
|
234
226
|
insertTimelineAssetIntoSource(originalContent, subComposition),
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
|
|
3
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
4
|
+
import { readPreviewCompositionSize } from "./previewCompositionSize";
|
|
5
|
+
|
|
6
|
+
type Player = HTMLElement & {
|
|
7
|
+
ready?: boolean;
|
|
8
|
+
compositionWidth?: number;
|
|
9
|
+
compositionHeight?: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/** A frame in a player's shadow root, as <hyperframes-player> holds it; a sealed one refuses its document. */
|
|
13
|
+
function frameInPlayer(sealed: boolean, player: Partial<Player>) {
|
|
14
|
+
const host = Object.assign(document.createElement("div"), player) as Player;
|
|
15
|
+
document.body.append(host);
|
|
16
|
+
const iframe = document.createElement("iframe");
|
|
17
|
+
host.attachShadow({ mode: "open" }).append(iframe);
|
|
18
|
+
if (sealed) {
|
|
19
|
+
const refusing = {
|
|
20
|
+
get document(): Document {
|
|
21
|
+
throw new DOMException("Blocked a frame with origin", "SecurityError");
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(iframe, "contentWindow", { get: () => refusing });
|
|
25
|
+
Object.defineProperty(iframe, "contentDocument", { get: () => null });
|
|
26
|
+
}
|
|
27
|
+
return iframe;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
afterEach(() => document.body.replaceChildren());
|
|
31
|
+
|
|
32
|
+
describe("readPreviewCompositionSize", () => {
|
|
33
|
+
it("reads a sealed frame's size from its player once the player is ready", () => {
|
|
34
|
+
const iframe = frameInPlayer(true, {
|
|
35
|
+
ready: true,
|
|
36
|
+
compositionWidth: 1080,
|
|
37
|
+
compositionHeight: 1920,
|
|
38
|
+
});
|
|
39
|
+
expect(readPreviewCompositionSize(iframe)).toEqual({ width: 1080, height: 1920 });
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("reads no size from a sealed frame's player before it is ready, whose numbers are only defaults", () => {
|
|
43
|
+
const iframe = frameInPlayer(true, {
|
|
44
|
+
ready: false,
|
|
45
|
+
compositionWidth: 1920,
|
|
46
|
+
compositionHeight: 1080,
|
|
47
|
+
});
|
|
48
|
+
expect(readPreviewCompositionSize(iframe)).toBeNull();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("reads a frame Studio can script from its document, not its player", () => {
|
|
52
|
+
const iframe = frameInPlayer(false, {
|
|
53
|
+
ready: true,
|
|
54
|
+
compositionWidth: 1920,
|
|
55
|
+
compositionHeight: 1080,
|
|
56
|
+
});
|
|
57
|
+
iframe.contentDocument!.body.innerHTML =
|
|
58
|
+
'<div data-composition-id="main" data-width="720" data-height="1280"></div>';
|
|
59
|
+
expect(readPreviewCompositionSize(iframe)).toEqual({ width: 720, height: 1280 });
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -1,13 +1,33 @@
|
|
|
1
|
+
import { previewFrameOpaque } from "../player/lib/previewChannel";
|
|
2
|
+
import { resolvePreviewPlayerHost } from "../player/lib/timelineIframeHelpers";
|
|
3
|
+
|
|
1
4
|
export interface PreviewCompositionSize {
|
|
2
5
|
width: number;
|
|
3
6
|
height: number;
|
|
4
7
|
}
|
|
5
8
|
|
|
6
|
-
|
|
9
|
+
type SizedPlayer = HTMLElement & {
|
|
10
|
+
ready?: boolean;
|
|
11
|
+
compositionWidth?: number;
|
|
12
|
+
compositionHeight?: number;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const isPositive = (value: unknown): value is number =>
|
|
16
|
+
typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
17
|
+
|
|
18
|
+
function readyPlayerCompositionSize(iframe: HTMLIFrameElement): PreviewCompositionSize | null {
|
|
19
|
+
const player = resolvePreviewPlayerHost(iframe) as SizedPlayer | null;
|
|
20
|
+
if (!player?.ready) return null;
|
|
21
|
+
const { compositionWidth: width, compositionHeight: height } = player;
|
|
22
|
+
return isPositive(width) && isPositive(height) ? { width, height } : null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** The root composition's authored size, from the preview document, or from its player when the frame is sealed. */
|
|
7
26
|
// fallow-ignore-next-line complexity
|
|
8
27
|
export function readPreviewCompositionSize(
|
|
9
28
|
iframe: HTMLIFrameElement | null,
|
|
10
29
|
): PreviewCompositionSize | null {
|
|
30
|
+
if (iframe && previewFrameOpaque(iframe)) return readyPlayerCompositionSize(iframe);
|
|
11
31
|
try {
|
|
12
32
|
const doc = iframe?.contentDocument;
|
|
13
33
|
const root =
|
|
@@ -262,6 +262,8 @@ function heldFileMessage(body: string, path: string | undefined): string | null
|
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
+
export const withStatus = (words: string, response: Response) => `${words} (${response.status})`;
|
|
266
|
+
|
|
265
267
|
export async function heldFileWordsOf(response: Response, path: string): Promise<string | null> {
|
|
266
268
|
return heldFileMessage(
|
|
267
269
|
await response
|