@hyperframes/studio 0.9.52 → 0.9.54
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-D7LhzIg1.js → hyperframes-player-Oju91F6x.js} +2 -2
- package/dist/assets/{index-D3WxJaqm.js → index-B0VEzzD2.js} +180 -180
- package/dist/assets/index-Dv67Vrl6.js +74 -0
- package/dist/assets/{index-CQ7o0CBU.js → index-XEm_N45R.js} +1 -1
- package/dist/assets/{pausedVideoDecoder-BVUmBgn0.js → pausedVideoDecoder-p6zibxVM.js} +1 -1
- package/dist/{chunk-F6EHWNZU.js → chunk-K3IOYISK.js} +121 -94
- package/dist/{chunk-VHV2ZDKY.js → chunk-OOGQ5KCC.js} +7 -0
- package/dist/{chunk-GVW7AU57.js → chunk-UM4CLD4M.js} +1 -1
- package/dist/chunk-USW3YBOG.js +70 -0
- package/dist/{domEditingLayers-SA5KLSSS.js → domEditingLayers-IHYA42AJ.js} +2 -2
- package/dist/index.d.ts +14 -7
- package/dist/index.html +1 -1
- package/dist/index.js +110 -98
- package/dist/keys.d.ts +72 -1
- package/dist/keys.js +5 -4
- package/dist/player.d.ts +1 -0
- package/dist/player.js +2 -2
- package/package.json +9 -9
- package/src/captions/keyboard.ts +1 -1
- package/src/components/RightPanelTabs.test.tsx +1 -1
- package/src/components/StudioHeader.dom.test.tsx +1 -1
- package/src/components/TimelineHistoryButtons.dom.test.tsx +1 -1
- package/src/components/TimelineToolbar.tsx +1 -1
- package/src/components/editor/SnapToolbar.tsx +1 -1
- package/src/components/editor/gsapLivePreview.test.ts +19 -0
- package/src/components/editor/gsapLivePreview.ts +2 -0
- package/src/components/editor/manualEditingAvailability.ts +7 -0
- package/src/components/editor/useDomEditNudge.ts +1 -1
- package/src/components/nle/NLEPreview.test.ts +25 -0
- package/src/components/nle/NLEPreview.tsx +5 -0
- package/src/components/nle/PreviewPane.tsx +2 -0
- package/src/components/panels/SlideshowPanel.tsx +1 -1
- package/src/components/renders/RenderQueue.test.tsx +1 -1
- package/src/components/sidebar/CompositionsTab.tsx +4 -8
- package/src/components/ui/Button.test.tsx +1 -1
- package/src/components/ui/Menu.test.tsx +1 -1
- package/src/components/ui/valueControls.test.tsx +1 -1
- package/src/hooks/appHotkeysDispatch.ts +1 -1
- package/src/hooks/gsapParsedTween.test.ts +19 -0
- package/src/hooks/gsapParsedTween.ts +3 -1
- package/src/hooks/linkShortcuts.ts +1 -1
- package/src/hooks/useAutomationSelectionKeyboard.ts +1 -1
- package/src/hooks/useConsoleErrorCapture.test.tsx +69 -1
- package/src/hooks/useConsoleErrorCapture.ts +47 -11
- package/src/hooks/useKeyframeKeyboard.ts +1 -1
- package/src/index.ts +3 -2
- package/src/keys.test.ts +5 -7
- package/src/keys.ts +1 -6
- package/src/player/components/Player.test.ts +49 -0
- package/src/player/components/Player.tsx +13 -4
- package/src/player/components/ShortcutsPanel.tsx +1 -1
- package/src/player/components/studioCombo.test.ts +1 -1
- package/src/player/components/studioShortcuts.ts +1 -1
- package/src/player/lib/frameToken.ts +20 -0
- package/src/player/lib/playbackShortcuts.ts +3 -28
- package/src/player/lib/previewChannel.ts +10 -0
- package/src/utils/studioHelpers.ts +1 -1
- package/src/utils/studioPendingEdits.ts +1 -1
- package/src/utils/timelineDiscovery.ts +1 -1
- package/src/utils/typingTarget.test.ts +1 -1
- package/src/webmcp/polyfill.transport.test.ts +13 -3
- package/src/webmcp/types.ts +3 -3
- package/src/webmcp/useStudioAgentTools.polyfill.test.tsx +89 -121
- package/src/webmcp/useStudioAgentTools.test.tsx +2 -2
- package/src/webmcp/useStudioAgentTools.ts +2 -3
- package/dist/assets/index-BX3KHhGX.js +0 -71
- package/dist/chunk-5ZHKYODQ.js +0 -149
- package/dist/keys-B163OjLN.d.ts +0 -87
- package/src/player/components/studioCombo.ts +0 -108
- package/src/utils/typingTarget.ts +0 -56
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/studio",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.54",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@codemirror/state": "^6.6.0",
|
|
57
57
|
"@codemirror/view": "6.40.0",
|
|
58
58
|
"@lezer/highlight": "^1.2.3",
|
|
59
|
-
"@mcp-b/global": "^
|
|
59
|
+
"@mcp-b/global": "^6.1.0",
|
|
60
60
|
"@phosphor-icons/react": "^2.1.10",
|
|
61
61
|
"@tanstack/react-virtual": "^3.14.13",
|
|
62
62
|
"acorn": "^8.17.0",
|
|
@@ -64,12 +64,12 @@
|
|
|
64
64
|
"dockview-react": "8.3.1",
|
|
65
65
|
"gsap": "^3.13.0",
|
|
66
66
|
"mediabunny": "^1.66.0",
|
|
67
|
-
"@hyperframes/core": "0.9.
|
|
68
|
-
"@hyperframes/parsers": "0.9.
|
|
69
|
-
"@hyperframes/player": "0.9.
|
|
70
|
-
"@hyperframes/sdk": "0.9.
|
|
71
|
-
"@hyperframes/shader-transitions": "0.9.
|
|
72
|
-
"@hyperframes/studio-server": "0.9.
|
|
67
|
+
"@hyperframes/core": "0.9.54",
|
|
68
|
+
"@hyperframes/parsers": "0.9.54",
|
|
69
|
+
"@hyperframes/player": "0.9.54",
|
|
70
|
+
"@hyperframes/sdk": "0.9.54",
|
|
71
|
+
"@hyperframes/shader-transitions": "0.9.54",
|
|
72
|
+
"@hyperframes/studio-server": "0.9.54"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"vite": "^6.4.5",
|
|
87
87
|
"vitest": "^4.1.12",
|
|
88
88
|
"zustand": "^5.0.0",
|
|
89
|
-
"@hyperframes/producer": "0.9.
|
|
89
|
+
"@hyperframes/producer": "0.9.54"
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|
|
92
92
|
"react": "19",
|
package/src/captions/keyboard.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isEditableTarget } from "../utils/timelineDiscovery";
|
|
2
|
-
import { ownsPlainKeys } from "
|
|
2
|
+
import { ownsPlainKeys } from "@hyperframes/core/typing-target";
|
|
3
3
|
import { resolveCanvasNudgeDelta } from "../components/editor/domEditNudge";
|
|
4
4
|
|
|
5
5
|
type CaptionNudgeKeyEvent = Parameters<typeof resolveCanvasNudgeDelta>[0];
|
|
@@ -8,7 +8,7 @@ import React, { act } from "react";
|
|
|
8
8
|
import { createRoot, type Root } from "react-dom/client";
|
|
9
9
|
import { afterEach, expect, it, vi } from "vitest";
|
|
10
10
|
import { RightPanelTabs, type RightPanelTabDescriptor } from "./RightPanelTabs";
|
|
11
|
-
import { isTypingTarget } from "
|
|
11
|
+
import { isTypingTarget } from "@hyperframes/core/typing-target";
|
|
12
12
|
import { shouldIgnorePlaybackShortcutTarget } from "../player/lib/playbackShortcuts";
|
|
13
13
|
|
|
14
14
|
(globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
@@ -8,7 +8,7 @@ import React, { act } from "react";
|
|
|
8
8
|
import { createRoot, type Root } from "react-dom/client";
|
|
9
9
|
import { afterEach, beforeEach, expect, it, vi } from "vitest";
|
|
10
10
|
import { buttonSizes, buttonVariants } from "./ui";
|
|
11
|
-
import { isTypingTarget } from "
|
|
11
|
+
import { isTypingTarget } from "@hyperframes/core/typing-target";
|
|
12
12
|
import { shouldIgnorePlaybackShortcutTarget } from "../player/lib/playbackShortcuts";
|
|
13
13
|
|
|
14
14
|
(globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { act } from "react";
|
|
4
4
|
import { afterEach, beforeEach, expect, it, vi } from "vitest";
|
|
5
5
|
import { cleanupMounted, mountHost } from "./ui/mountHost.testHelpers";
|
|
6
|
-
import { isTypingTarget } from "
|
|
6
|
+
import { isTypingTarget } from "@hyperframes/core/typing-target";
|
|
7
7
|
import { shouldIgnorePlaybackShortcutTarget } from "../player/lib/playbackShortcuts";
|
|
8
8
|
|
|
9
9
|
const editHistory = {
|
|
@@ -39,7 +39,7 @@ import { useAudioMetersVisible } from "../utils/audioMeterVisibility";
|
|
|
39
39
|
import { LinkedSelectionToggle } from "./LinkedSelectionToggle";
|
|
40
40
|
import { useProjectHasAudio } from "../utils/audioMeterMath";
|
|
41
41
|
import { canAddBeatAt, addBeatAtCompositionTime } from "../utils/beatEditActions";
|
|
42
|
-
import { isTypingTarget } from "
|
|
42
|
+
import { isTypingTarget } from "@hyperframes/core/typing-target";
|
|
43
43
|
import { keyHint, matchesKey, useStudioKeys } from "../player/components/studioShortcuts";
|
|
44
44
|
import type { TimelineProps } from "../player/components/TimelineTypes";
|
|
45
45
|
|
|
@@ -3,7 +3,7 @@ import { memo, useCallback, useEffect, useRef, useState } from "react";
|
|
|
3
3
|
import { MagnetStraight, GridFour, Path, Ruler, FrameCorners } from "@phosphor-icons/react";
|
|
4
4
|
import { usePlayerStore } from "../../player/store/playerStore";
|
|
5
5
|
import { usePreviewOverlayContext } from "./PreviewOverlayProvider";
|
|
6
|
-
import { ownsPlainKeys } from "
|
|
6
|
+
import { ownsPlainKeys } from "@hyperframes/core/typing-target";
|
|
7
7
|
import { keyHint, matchesKey, useStudioKeys } from "../../player/components/studioShortcuts";
|
|
8
8
|
|
|
9
9
|
// fallow-ignore-next-line complexity
|
|
@@ -106,3 +106,22 @@ it.each([
|
|
|
106
106
|
expect(props).toEqual(read);
|
|
107
107
|
},
|
|
108
108
|
);
|
|
109
|
+
|
|
110
|
+
/** A preview on an opaque origin: every read of its window but postMessage throws, as a browser's does. */
|
|
111
|
+
function sealedPreview(): HTMLIFrameElement {
|
|
112
|
+
const iframe = document.createElement("iframe");
|
|
113
|
+
const win = new Proxy({} as Record<string, unknown>, {
|
|
114
|
+
get: (_target, key) => {
|
|
115
|
+
if (key === "postMessage") return () => undefined;
|
|
116
|
+
throw new DOMException(`blocked read of ${String(key)}`, "SecurityError");
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
Object.defineProperty(iframe, "contentWindow", { value: win });
|
|
120
|
+
Object.defineProperty(iframe, "contentDocument", { value: null });
|
|
121
|
+
return iframe;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
it("draws nothing on a sealed preview, whose window refuses the read", () => {
|
|
125
|
+
const preview = createGsapLivePreview({ current: sealedPreview() });
|
|
126
|
+
expect(() => preview({ id: "card" } as DomEditSelection, { x: 10 })).not.toThrow();
|
|
127
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DomEditSelection } from "./domEditingTypes";
|
|
2
2
|
import { findPreviewNode } from "./domEditingElement";
|
|
3
|
+
import { previewFrameOpaque } from "../../player/lib/previewChannel";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Build the "live preview" callback the 3D-transform sub-view fires while a
|
|
@@ -12,6 +13,7 @@ import { findPreviewNode } from "./domEditingElement";
|
|
|
12
13
|
export function createGsapLivePreview(iframeRef: { readonly current: HTMLIFrameElement | null }) {
|
|
13
14
|
return (el: DomEditSelection, props: Record<string, number>) => {
|
|
14
15
|
const iframe = iframeRef.current;
|
|
16
|
+
if (!iframe || previewFrameOpaque(iframe)) return;
|
|
15
17
|
const win = iframe?.contentWindow as
|
|
16
18
|
| { gsap?: { set: (t: Element, v: Record<string, number>) => void } }
|
|
17
19
|
| null
|
|
@@ -86,4 +86,11 @@ export const STUDIO_API_SAME_ORIGIN_CREDENTIALS = resolveStudioBooleanEnvFlag(
|
|
|
86
86
|
false,
|
|
87
87
|
);
|
|
88
88
|
|
|
89
|
+
// Off until every Studio reader of the preview frame has its editing-port path.
|
|
90
|
+
export const STUDIO_OPAQUE_PREVIEW_ENABLED = resolveStudioBooleanEnvFlag(
|
|
91
|
+
env,
|
|
92
|
+
["VITE_STUDIO_OPAQUE_PREVIEW_ENABLED"],
|
|
93
|
+
false,
|
|
94
|
+
);
|
|
95
|
+
|
|
89
96
|
import { resolveEnabledSdkFamilies } from "../../utils/sdkCutoverPolicy";
|
|
@@ -8,7 +8,7 @@ import { trackPreviewEditResult } from "../../utils/previewFeatureUsage";
|
|
|
8
8
|
*/
|
|
9
9
|
import { useCallback, useEffect, useRef, type RefObject } from "react";
|
|
10
10
|
import { useMountEffect } from "../../hooks/useMountEffect";
|
|
11
|
-
import { ownsPlainKeys } from "
|
|
11
|
+
import { ownsPlainKeys } from "@hyperframes/core/typing-target";
|
|
12
12
|
import { acquireCanvasNudgeKeys } from "../../utils/canvasNudgeGate";
|
|
13
13
|
import {
|
|
14
14
|
addStudioPendingEditFlushListener,
|
|
@@ -29,6 +29,7 @@ vi.mock("../../player", async () => {
|
|
|
29
29
|
onReadyToShowChange?: (ready: boolean) => void;
|
|
30
30
|
suppressLoadingOverlay?: boolean;
|
|
31
31
|
style?: React.CSSProperties;
|
|
32
|
+
sandboxOrigin?: "opaque";
|
|
32
33
|
},
|
|
33
34
|
ref: React.ForwardedRef<HTMLIFrameElement>,
|
|
34
35
|
) {
|
|
@@ -41,6 +42,7 @@ vi.mock("../../player", async () => {
|
|
|
41
42
|
return React.createElement("div", {
|
|
42
43
|
ref: ref as React.ForwardedRef<HTMLDivElement>,
|
|
43
44
|
"data-testid": "mock-player",
|
|
45
|
+
"data-sandbox-origin": props.sandboxOrigin,
|
|
44
46
|
style: props.style,
|
|
45
47
|
});
|
|
46
48
|
}),
|
|
@@ -89,10 +91,12 @@ function renderPreview(
|
|
|
89
91
|
box = { width: 800, height: 600 },
|
|
90
92
|
fillBox,
|
|
91
93
|
compositionSizeHint,
|
|
94
|
+
sandboxOrigin,
|
|
92
95
|
}: {
|
|
93
96
|
box?: { width: number; height: number };
|
|
94
97
|
fillBox?: boolean;
|
|
95
98
|
compositionSizeHint?: { width: number; height: number };
|
|
99
|
+
sandboxOrigin?: "opaque";
|
|
96
100
|
} = {},
|
|
97
101
|
) {
|
|
98
102
|
resizeCallbacks = [];
|
|
@@ -116,6 +120,7 @@ function renderPreview(
|
|
|
116
120
|
resetPreviewSlots: () => {},
|
|
117
121
|
fillBox,
|
|
118
122
|
compositionSizeHint,
|
|
123
|
+
sandboxOrigin,
|
|
119
124
|
}),
|
|
120
125
|
);
|
|
121
126
|
});
|
|
@@ -533,6 +538,26 @@ describe("NLEPreview", () => {
|
|
|
533
538
|
view.cleanup();
|
|
534
539
|
});
|
|
535
540
|
|
|
541
|
+
it.each([["opaque" as const], [undefined]])(
|
|
542
|
+
"gives every player it draws the host's sandbox origin (%s)",
|
|
543
|
+
(sandboxOrigin) => {
|
|
544
|
+
const view = renderPreview(
|
|
545
|
+
[
|
|
546
|
+
{ gen: 0, role: "live" },
|
|
547
|
+
{ gen: 1, role: "shadow", url: "/api/projects/p/preview?_t=1" },
|
|
548
|
+
],
|
|
549
|
+
{ sandboxOrigin },
|
|
550
|
+
);
|
|
551
|
+
view.render("/api/projects/p/preview/components/card.html", "p");
|
|
552
|
+
const players = [...view.stage.querySelectorAll('[data-testid="mock-player"]')];
|
|
553
|
+
expect(players).toHaveLength(3);
|
|
554
|
+
for (const player of players) {
|
|
555
|
+
expect(player.getAttribute("data-sandbox-origin")).toBe(sandboxOrigin ?? null);
|
|
556
|
+
}
|
|
557
|
+
view.cleanup();
|
|
558
|
+
},
|
|
559
|
+
);
|
|
560
|
+
|
|
536
561
|
it("covers the live preview with the cached frame-0 poster until it is ready to show", () => {
|
|
537
562
|
const view = renderPreview();
|
|
538
563
|
const poster = () =>
|
|
@@ -58,6 +58,7 @@ interface NLEPreviewProps extends Pick<
|
|
|
58
58
|
/** Draws the picture edge to edge in this box, without Studio's inset band. */
|
|
59
59
|
fillBox?: boolean;
|
|
60
60
|
compositionSizeHint?: PreviewCompositionSize;
|
|
61
|
+
sandboxOrigin?: "opaque";
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
export function getPreviewPlayerKey({
|
|
@@ -92,6 +93,7 @@ export const NLEPreview = memo(function NLEPreview({
|
|
|
92
93
|
onCompositionSizeChange,
|
|
93
94
|
fillBox,
|
|
94
95
|
compositionSizeHint,
|
|
96
|
+
sandboxOrigin,
|
|
95
97
|
}: NLEPreviewProps) {
|
|
96
98
|
const activeKey = getPreviewPlayerKey({ projectId, directUrl });
|
|
97
99
|
const viewportRef = useRef<HTMLDivElement>(null);
|
|
@@ -487,6 +489,7 @@ export const NLEPreview = memo(function NLEPreview({
|
|
|
487
489
|
onLoad={() => {}}
|
|
488
490
|
portrait={portrait}
|
|
489
491
|
suppressLoadingOverlay
|
|
492
|
+
sandboxOrigin={sandboxOrigin}
|
|
490
493
|
style={{ position: "absolute", inset: 0, zIndex: 0 }}
|
|
491
494
|
/>
|
|
492
495
|
)}
|
|
@@ -509,6 +512,7 @@ export const NLEPreview = memo(function NLEPreview({
|
|
|
509
512
|
portrait={portrait}
|
|
510
513
|
suppressLoadingOverlay={suppressLoadingOverlay}
|
|
511
514
|
loadingUi={loadingUi}
|
|
515
|
+
sandboxOrigin={sandboxOrigin}
|
|
512
516
|
style={
|
|
513
517
|
directUrl?.includes("/components/")
|
|
514
518
|
? { position: "absolute", inset: 0, zIndex: 1 }
|
|
@@ -528,6 +532,7 @@ export const NLEPreview = memo(function NLEPreview({
|
|
|
528
532
|
portrait={portrait}
|
|
529
533
|
suppressLoadingOverlay
|
|
530
534
|
noLoadTimeout
|
|
535
|
+
sandboxOrigin={sandboxOrigin}
|
|
531
536
|
style={SHADOW_IFRAME_STYLE}
|
|
532
537
|
/>
|
|
533
538
|
),
|
|
@@ -8,6 +8,7 @@ import { useNLEContext } from "./NLEContext";
|
|
|
8
8
|
import { AssetPreviewOverlay } from "./AssetPreviewOverlay";
|
|
9
9
|
import { PreviewGuides } from "../editor/PreviewGuides";
|
|
10
10
|
import { PreviewOverlayProvider } from "../editor/PreviewOverlayProvider";
|
|
11
|
+
import { STUDIO_OPAQUE_PREVIEW_ENABLED } from "../editor/manualEditingAvailability";
|
|
11
12
|
|
|
12
13
|
function subscribeFullscreen(cb: () => void) {
|
|
13
14
|
document.addEventListener("fullscreenchange", cb);
|
|
@@ -150,6 +151,7 @@ export function PreviewPane({
|
|
|
150
151
|
suppressLoadingOverlay={hasLoadedOnceRef.current}
|
|
151
152
|
onStageRef={handleStageRef}
|
|
152
153
|
onCompositionSizeChange={setPreviewCompositionSize}
|
|
154
|
+
sandboxOrigin={STUDIO_OPAQUE_PREVIEW_ENABLED ? "opaque" : undefined}
|
|
153
155
|
/>
|
|
154
156
|
{previewDragOver && (
|
|
155
157
|
<div className="absolute inset-2 z-40 rounded-lg border-2 border-dashed border-studio-accent/50 bg-studio-accent/4 pointer-events-none" />
|
|
@@ -21,7 +21,7 @@ import { usePlayerStore } from "../../player";
|
|
|
21
21
|
import { useDomEditSelectionContext } from "../../contexts/DomEditContext";
|
|
22
22
|
import { useFileManagerContext } from "../../contexts/FileManagerContext";
|
|
23
23
|
import { generateId } from "../../utils/generateId";
|
|
24
|
-
import { isTypingTarget } from "
|
|
24
|
+
import { isTypingTarget } from "@hyperframes/core/typing-target";
|
|
25
25
|
import {
|
|
26
26
|
SectionHeader,
|
|
27
27
|
SlideList,
|
|
@@ -6,7 +6,7 @@ import { afterEach, beforeEach, describe, expect, it, vi, type Mock } from "vite
|
|
|
6
6
|
import { RenderQueue, type StartRenderHandler } from "./RenderQueue";
|
|
7
7
|
import { getPersistedRenderSettings } from "./renderSettings";
|
|
8
8
|
import { buttonBase, buttonSizes, buttonVariants, cn } from "../ui";
|
|
9
|
-
import { isTypingTarget } from "
|
|
9
|
+
import { isTypingTarget } from "@hyperframes/core/typing-target";
|
|
10
10
|
import { shouldIgnorePlaybackShortcutTarget } from "../../player/lib/playbackShortcuts";
|
|
11
11
|
import type { FfmpegStatus } from "./useFfmpegStatus";
|
|
12
12
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { buildProjectApiPath } from "../../utils/projectRouting";
|
|
2
|
-
import {
|
|
2
|
+
import { fetchFrameToken } from "../../player/lib/frameToken";
|
|
3
3
|
import { memo, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { useThumbnailLease } from "../../hooks/useThumbnailLease";
|
|
5
5
|
import {
|
|
@@ -72,13 +72,9 @@ function useFreshFrameToken(projectId: string, wanted: boolean): string | null |
|
|
|
72
72
|
useEffect(() => {
|
|
73
73
|
if (!wanted) return setKnown(undefined);
|
|
74
74
|
let live = true;
|
|
75
|
-
void
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
typeof body?.token === "string" ? body.token : null,
|
|
79
|
-
)
|
|
80
|
-
.catch(() => null)
|
|
81
|
-
.then((token) => live && setKnown({ token }));
|
|
75
|
+
void fetchFrameToken(buildProjectApiPath(projectId, "/frame-token")).then(
|
|
76
|
+
(token) => live && setKnown({ token }),
|
|
77
|
+
);
|
|
82
78
|
return () => {
|
|
83
79
|
live = false;
|
|
84
80
|
};
|
|
@@ -14,7 +14,7 @@ import { Button, type ButtonSize, type ButtonVariant } from "./Button";
|
|
|
14
14
|
import { IconButton } from "./IconButton";
|
|
15
15
|
import { Tab, Tabs, TabsList } from "./Tabs";
|
|
16
16
|
import { cleanupMounted, mountHost } from "./mountHost.testHelpers";
|
|
17
|
-
import { isTypingTarget } from "
|
|
17
|
+
import { isTypingTarget } from "@hyperframes/core/typing-target";
|
|
18
18
|
import { shouldIgnorePlaybackShortcutTarget } from "../../player/lib/playbackShortcuts";
|
|
19
19
|
|
|
20
20
|
const VARIANTS: ButtonVariant[] = ["primary", "secondary", "danger", "ghost"];
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
MenuSeparator,
|
|
17
17
|
} from "./Menu";
|
|
18
18
|
import { Popover } from "./Popover";
|
|
19
|
-
import { isTypingTarget } from "
|
|
19
|
+
import { isTypingTarget } from "@hyperframes/core/typing-target";
|
|
20
20
|
import { shouldIgnorePlaybackShortcutTarget } from "../../player/lib/playbackShortcuts";
|
|
21
21
|
import { cleanupMounted, mountHost as render } from "./mountHost.testHelpers";
|
|
22
22
|
|
|
@@ -17,7 +17,7 @@ import { NumberField } from "./NumberField";
|
|
|
17
17
|
import { Select } from "./Select";
|
|
18
18
|
import { Slider } from "./Slider";
|
|
19
19
|
import { Toggle } from "./Toggle";
|
|
20
|
-
import { isTypingTarget } from "
|
|
20
|
+
import { isTypingTarget } from "@hyperframes/core/typing-target";
|
|
21
21
|
import { shouldIgnorePlaybackShortcutTarget } from "../../player/lib/playbackShortcuts";
|
|
22
22
|
import { __resetDesignInputThrottle, trackDesignInput } from "../../utils/designInputTracking";
|
|
23
23
|
import { cleanupMounted, mountHost as render } from "./mountHost.testHelpers";
|
|
@@ -3,7 +3,7 @@ import { usePlayerStore } from "../player";
|
|
|
3
3
|
import type { TimelineElement } from "../player";
|
|
4
4
|
import type { DomEditSelection } from "../components/editor/domEditing";
|
|
5
5
|
import { useDockLayoutStore } from "../components/dock/dockLayoutStore";
|
|
6
|
-
import { isTypingTarget, ownsPlainKeys } from "
|
|
6
|
+
import { isTypingTarget, ownsPlainKeys } from "@hyperframes/core/typing-target";
|
|
7
7
|
import { isEditableTarget } from "../utils/timelineDiscovery";
|
|
8
8
|
import { shouldIgnoreHistoryShortcut } from "../utils/studioHelpers";
|
|
9
9
|
import { canSplitElement } from "../utils/timelineElementSplit";
|
|
@@ -60,3 +60,22 @@ describe("findParsedTween", () => {
|
|
|
60
60
|
timeline.kill();
|
|
61
61
|
});
|
|
62
62
|
});
|
|
63
|
+
|
|
64
|
+
/** A preview on an opaque origin: every read of its window but postMessage throws, as a browser's does. */
|
|
65
|
+
function sealedPreview(): HTMLIFrameElement {
|
|
66
|
+
const iframe = document.createElement("iframe");
|
|
67
|
+
const win = new Proxy({} as Record<string, unknown>, {
|
|
68
|
+
get: (_target, key) => {
|
|
69
|
+
if (key === "postMessage") return () => undefined;
|
|
70
|
+
throw new DOMException(`blocked read of ${String(key)}`, "SecurityError");
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(iframe, "contentWindow", { value: win });
|
|
74
|
+
Object.defineProperty(iframe, "contentDocument", { value: null });
|
|
75
|
+
return iframe;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
it("finds no tween in a sealed preview, whose window refuses the read", () => {
|
|
79
|
+
const edit = tween({ method: "to", properties: { x: 300 }, resolvedStart: 0, duration: 2 });
|
|
80
|
+
expect(findParsedTween(sealedPreview(), document.createElement("div"), edit)).toBeNull();
|
|
81
|
+
});
|
|
@@ -2,6 +2,7 @@ import type { GsapAnimation } from "@hyperframes/core/gsap-parser";
|
|
|
2
2
|
import { elementTargets } from "../utils/elementGsap";
|
|
3
3
|
import { resolveTweenStart } from "../utils/globalTimeCompiler";
|
|
4
4
|
import { KEYFRAME_PCT_MATCH } from "./gsapShared";
|
|
5
|
+
import { previewFrameOpaque } from "../player/lib/previewChannel";
|
|
5
6
|
import type { ImplicitEndValue } from "./gsapValueAtPlayhead";
|
|
6
7
|
import type { ReadTween } from "./gsapRuntimeKeyframes";
|
|
7
8
|
|
|
@@ -81,7 +82,8 @@ export function findParsedTween(
|
|
|
81
82
|
element: Element,
|
|
82
83
|
anim: GsapAnimation,
|
|
83
84
|
): ParsedTween | null {
|
|
84
|
-
|
|
85
|
+
if (!iframe || previewFrameOpaque(iframe)) return null;
|
|
86
|
+
const win = iframe.contentWindow as GsapWindow | null;
|
|
85
87
|
const start = resolveTweenStart(anim);
|
|
86
88
|
if (!win?.__timelines || start == null) return null;
|
|
87
89
|
const steps = anim.keyframes?.keyframes.map((kf) => kf.properties) ?? [anim.properties];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { usePlayerStore } from "../player";
|
|
2
2
|
import type { TimelineEditCallbacks } from "../player/components/timelineCallbacks";
|
|
3
3
|
import { resolveLinkMenuItems } from "../player/components/clipMenuLinkItems";
|
|
4
|
-
import { isTypingTarget } from "
|
|
4
|
+
import { isTypingTarget } from "@hyperframes/core/typing-target";
|
|
5
5
|
import { keyHint, matchesKey } from "../player/components/studioShortcuts";
|
|
6
6
|
|
|
7
7
|
export interface LinkShortcutCallbacks {
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
type HfAutomationLane,
|
|
32
32
|
} from "@hyperframes/core/audio-automation";
|
|
33
33
|
import { clampNumber } from "../utils/studioHelpers";
|
|
34
|
-
import { isTypingTarget } from "
|
|
34
|
+
import { isTypingTarget } from "@hyperframes/core/typing-target";
|
|
35
35
|
import { matchesKey } from "../player/components/studioShortcuts";
|
|
36
36
|
import type { AutomationSelection } from "../player/store/automationSelectionSlice";
|
|
37
37
|
import type {
|
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import React, { act } from "react";
|
|
4
4
|
import { createRoot, type Root } from "react-dom/client";
|
|
5
|
-
import { afterEach, expect, it } from "vitest";
|
|
5
|
+
import { afterEach, expect, it, vi } from "vitest";
|
|
6
6
|
import { STUDIO_PREVIEW_ERRORS } from "@hyperframes/core/studio-preview-mark";
|
|
7
7
|
import { announcePreviewDocumentLoaded } from "../player/sceneSwap";
|
|
8
8
|
import { useConsoleErrorCapture } from "./useConsoleErrorCapture";
|
|
9
|
+
import {
|
|
10
|
+
detachedFakeIframe,
|
|
11
|
+
serveEditingRequests,
|
|
12
|
+
} from "../player/hooks/timelinePlayerTestHarness";
|
|
9
13
|
|
|
10
14
|
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
|
|
11
15
|
|
|
@@ -24,10 +28,42 @@ function previewFrame() {
|
|
|
24
28
|
|
|
25
29
|
const shown = () => capture.consoleErrors?.map((finding) => finding.message);
|
|
26
30
|
|
|
31
|
+
/** A frame whose window refuses Studio's reads; its runtime answers `console-errors` from `raised`. */
|
|
32
|
+
function sealedFrame(
|
|
33
|
+
raised: string[],
|
|
34
|
+
page = (from: number) => {
|
|
35
|
+
const errors = raised.slice(from, from + 2);
|
|
36
|
+
return { errors, truncated: from + errors.length < raised.length };
|
|
37
|
+
},
|
|
38
|
+
) {
|
|
39
|
+
const frame: Record<string, unknown> = {};
|
|
40
|
+
const iframe = detachedFakeIframe(frame);
|
|
41
|
+
Object.defineProperty(iframe, "contentDocument", { value: null });
|
|
42
|
+
Object.defineProperty(frame, "document", {
|
|
43
|
+
get: () => {
|
|
44
|
+
throw new DOMException("blocked", "SecurityError");
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
const asked: number[] = [];
|
|
48
|
+
const askedAt: number[] = [];
|
|
49
|
+
closers.push(
|
|
50
|
+
serveEditingRequests(frame, (kind, params) => {
|
|
51
|
+
if (kind !== "console-errors") return null;
|
|
52
|
+
const { from } = params as { from: number };
|
|
53
|
+
asked.push(from);
|
|
54
|
+
askedAt.push(performance.now());
|
|
55
|
+
return page(from);
|
|
56
|
+
}),
|
|
57
|
+
);
|
|
58
|
+
return { iframe, asked, askedAt };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const closers: Array<() => void> = [];
|
|
27
62
|
let root: Root | null = null;
|
|
28
63
|
afterEach(async () => {
|
|
29
64
|
await act(async () => root?.unmount());
|
|
30
65
|
root = null;
|
|
66
|
+
closers.splice(0).forEach((close) => close());
|
|
31
67
|
});
|
|
32
68
|
|
|
33
69
|
it("shows the errors a preview raised before its load, once each", async () => {
|
|
@@ -104,3 +140,35 @@ it("keeps a page's errors through its own late load, and clears them for the nex
|
|
|
104
140
|
await act(async () => announcePreviewDocumentLoaded(iframe));
|
|
105
141
|
expect(shown()).toEqual(["Uncaught Error: new page"]);
|
|
106
142
|
});
|
|
143
|
+
|
|
144
|
+
it("shows a sealed preview's errors, read over its editing port a page at a time", async () => {
|
|
145
|
+
const raised = ["Uncaught Error: a", "Uncaught Error: b", "Uncaught Error: c"];
|
|
146
|
+
const { iframe, asked } = sealedFrame(raised);
|
|
147
|
+
root = createRoot(document.createElement("div"));
|
|
148
|
+
await act(async () => root?.render(React.createElement(Harness, { iframe })));
|
|
149
|
+
await act(async () => announcePreviewDocumentLoaded(iframe));
|
|
150
|
+
|
|
151
|
+
const shows = (expected: string[]) =>
|
|
152
|
+
vi.waitFor(
|
|
153
|
+
async () => {
|
|
154
|
+
await act(async () => {});
|
|
155
|
+
expect(shown()).toEqual(expected);
|
|
156
|
+
},
|
|
157
|
+
{ timeout: 3_000 },
|
|
158
|
+
);
|
|
159
|
+
await shows(raised);
|
|
160
|
+
expect(asked).toContain(2);
|
|
161
|
+
|
|
162
|
+
raised.push("Uncaught Error: later");
|
|
163
|
+
await shows(raised);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it("waits for its next read when a sealed preview's page says more but brings nothing", async () => {
|
|
167
|
+
const { iframe, askedAt } = sealedFrame([], () => ({ errors: [], truncated: true }));
|
|
168
|
+
root = createRoot(document.createElement("div"));
|
|
169
|
+
await act(async () => root?.render(React.createElement(Harness, { iframe })));
|
|
170
|
+
await act(async () => announcePreviewDocumentLoaded(iframe));
|
|
171
|
+
|
|
172
|
+
await vi.waitFor(() => expect(askedAt.length).toBeGreaterThanOrEqual(3), { timeout: 3_000 });
|
|
173
|
+
expect(askedAt[2] - askedAt[1]).toBeGreaterThan(500);
|
|
174
|
+
});
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
previewConsoleErrorText,
|
|
4
|
+
STUDIO_PREVIEW_ERRORS,
|
|
5
|
+
} from "@hyperframes/core/studio-preview-mark";
|
|
3
6
|
import { onPreviewDocumentLoaded } from "../player/sceneSwap";
|
|
7
|
+
import { previewConsoleErrors, previewFrameOpaque } from "../player/lib/previewChannel";
|
|
4
8
|
import type { LintFinding } from "../components/LintModal";
|
|
5
9
|
|
|
10
|
+
const SEALED_POLL_MS = 1_000;
|
|
11
|
+
|
|
6
12
|
/**
|
|
7
13
|
* Captures `console.error` and `window.onerror` events from a preview iframe
|
|
8
14
|
* and exposes them as LintFinding[] for the console errors modal.
|
|
@@ -24,8 +30,42 @@ export function useConsoleErrorCapture(previewIframe: HTMLIFrameElement | null)
|
|
|
24
30
|
let patchedWin: (Window & typeof globalThis) | null = null;
|
|
25
31
|
let origConsoleError: ((...args: unknown[]) => void) | null = null;
|
|
26
32
|
let errorHandler: ((e: ErrorEvent) => void) | null = null;
|
|
33
|
+
let stopSealedReads: (() => void) | null = null;
|
|
34
|
+
|
|
35
|
+
const record = (texts: readonly string[]) => {
|
|
36
|
+
if (texts.length === 0) return;
|
|
37
|
+
consoleErrorsRef.current = [
|
|
38
|
+
...consoleErrorsRef.current,
|
|
39
|
+
...texts.map((message) => ({ severity: "error" as const, message })),
|
|
40
|
+
];
|
|
41
|
+
setConsoleErrors([...consoleErrorsRef.current]);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const readSealedErrors = (iframe: HTMLIFrameElement) => {
|
|
45
|
+
let live = true;
|
|
46
|
+
let read = 0;
|
|
47
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
48
|
+
const poll = async () => {
|
|
49
|
+
for (;;) {
|
|
50
|
+
const page = await previewConsoleErrors(iframe, read);
|
|
51
|
+
if (!live) return;
|
|
52
|
+
if (!page) break;
|
|
53
|
+
read += page.errors.length;
|
|
54
|
+
record(page.errors);
|
|
55
|
+
if (!page.truncated || page.errors.length === 0) break;
|
|
56
|
+
}
|
|
57
|
+
timer = setTimeout(poll, SEALED_POLL_MS);
|
|
58
|
+
};
|
|
59
|
+
void poll();
|
|
60
|
+
return () => {
|
|
61
|
+
live = false;
|
|
62
|
+
clearTimeout(timer);
|
|
63
|
+
};
|
|
64
|
+
};
|
|
27
65
|
|
|
28
66
|
const detachErrorCapture = () => {
|
|
67
|
+
stopSealedReads?.();
|
|
68
|
+
stopSealedReads = null;
|
|
29
69
|
const win = patchedWin;
|
|
30
70
|
if (!win) return;
|
|
31
71
|
patchedWin = null;
|
|
@@ -44,25 +84,21 @@ export function useConsoleErrorCapture(previewIframe: HTMLIFrameElement | null)
|
|
|
44
84
|
const attachErrorCapture = () => {
|
|
45
85
|
detachErrorCapture();
|
|
46
86
|
resetErrors();
|
|
87
|
+
if (previewFrameOpaque(previewIframe)) {
|
|
88
|
+
stopSealedReads = readSealedErrors(previewIframe);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
47
91
|
try {
|
|
48
92
|
const win = previewIframe.contentWindow as (Window & typeof globalThis) | null;
|
|
49
93
|
if (!win) return;
|
|
50
94
|
if ((win as unknown as Record<string, unknown>).__hfErrorCapture) return;
|
|
51
95
|
(win as unknown as Record<string, unknown>).__hfErrorCapture = true;
|
|
52
96
|
patchedWin = win;
|
|
53
|
-
const record = (texts: readonly string[]) => {
|
|
54
|
-
if (texts.length === 0) return;
|
|
55
|
-
consoleErrorsRef.current = [
|
|
56
|
-
...consoleErrorsRef.current,
|
|
57
|
-
...texts.map((message) => ({ severity: "error" as const, message })),
|
|
58
|
-
];
|
|
59
|
-
setConsoleErrors([...consoleErrorsRef.current]);
|
|
60
|
-
};
|
|
61
97
|
origConsoleError = win.console.error.bind(win.console);
|
|
62
98
|
win.console.error = function (...args: unknown[]) {
|
|
63
99
|
origConsoleError!(...args);
|
|
64
|
-
const text = args
|
|
65
|
-
if (
|
|
100
|
+
const text = previewConsoleErrorText(args);
|
|
101
|
+
if (text !== null) record([text]);
|
|
66
102
|
};
|
|
67
103
|
errorHandler = (e: ErrorEvent) => record([e.message || String(e)]);
|
|
68
104
|
win.addEventListener("error", errorHandler);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useCallback } from "react";
|
|
2
2
|
import { matchesKey } from "../player/components/studioShortcuts";
|
|
3
|
-
import { isTypingTarget } from "
|
|
3
|
+
import { isTypingTarget } from "@hyperframes/core/typing-target";
|
|
4
4
|
|
|
5
5
|
interface KeyframeKeyboardOptions {
|
|
6
6
|
enabled: boolean;
|