@hyperframes/studio 0.9.40 → 0.9.42
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/{codec-BPK_2CLL.js → codec-CKqLGYc6.js} +1 -1
- package/dist/assets/{hyperframes-player-D7qTTDIp.js → hyperframes-player-DoEYqOIa.js} +1 -1
- package/dist/assets/{index-CdA00Ybn.js → index-DLyQ91Ek.js} +166 -166
- package/dist/assets/{index-QS-DuxAU.js → index-s9iqoWnr.js} +1 -1
- package/dist/assets/{pausedVideoDecoder-Byzz98Gb.js → pausedVideoDecoder-B-ReRg6i.js} +1 -1
- package/dist/{chunk-KF6YVXJP.js → chunk-4QQMX4BX.js} +6 -3
- package/dist/{chunk-VZ5MD32A.js → chunk-GVW7AU57.js} +190 -254
- package/dist/{chunk-AV2PV7NE.js → chunk-VHV2ZDKY.js} +4 -40
- package/dist/{domEditingLayers-4KRREI5C.js → domEditingLayers-SA5KLSSS.js} +4 -2
- package/dist/index.d.ts +12 -0
- package/dist/index.html +1 -1
- package/dist/index.js +1501 -818
- package/dist/player.js +2 -2
- package/package.json +10 -10
- package/src/components/editor/DomEditOverlay.tsx +3 -15
- package/src/components/editor/LayersPanel.opaque.test.ts +176 -0
- package/src/components/editor/LayersPanel.tsx +41 -10
- package/src/components/editor/clickAfterPreventedPress.test.tsx +17 -1
- package/src/components/editor/domEditInlineText.ts +1 -16
- package/src/components/editor/domEditOverlayBasis.ts +7 -2
- package/src/components/editor/domEditOverlayCrop.test.ts +1 -1
- package/src/components/editor/domEditOverlayCrop.ts +17 -3
- package/src/components/editor/domEditOverlayGeometry.ts +64 -139
- package/src/components/editor/domEditSelectionRules.ts +138 -0
- package/src/components/editor/domEditing.test.ts +6 -28
- package/src/components/editor/domEditingDom.preview.test.ts +3 -3
- package/src/components/editor/domEditingDom.ts +3 -76
- package/src/components/editor/domEditingElement.ts +19 -240
- package/src/components/editor/domEditingGroups.ts +0 -31
- package/src/components/editor/domEditingLayers.ts +95 -100
- package/src/components/editor/domEditingRootLayer.ts +35 -30
- package/src/components/editor/domEditingTypes.ts +10 -0
- package/src/components/editor/gestureUndoRevert.ts +18 -1
- package/src/components/editor/inlineTextStyleRange.fill.test.ts +129 -0
- package/src/components/editor/inlineTextStyleRange.test.ts +0 -82
- package/src/components/editor/layerKind.ts +2 -19
- package/src/components/editor/layersPanelSort.ts +2 -2
- package/src/components/editor/manualEdits.ts +1 -0
- package/src/components/editor/manualEditsSnapshot.ts +10 -0
- package/src/components/editor/manualOffsetDrag.test.ts +1 -1
- package/src/components/editor/manualOffsetDrag.ts +7 -1
- package/src/components/editor/marqueeCommit.ts +47 -4
- package/src/components/editor/plainTranslate.ts +35 -16
- package/src/components/editor/previewDrafts.test.ts +263 -0
- package/src/components/editor/previewDrafts.ts +73 -0
- package/src/components/editor/previewGestureStarts.ts +73 -10
- package/src/components/editor/previewLayers.test.ts +308 -0
- package/src/components/editor/previewLayers.ts +164 -0
- package/src/components/editor/previewOverlayRects.test.ts +316 -0
- package/src/components/editor/previewOverlayRects.ts +150 -0
- package/src/components/editor/previewPointerTargets.test.ts +327 -0
- package/src/components/editor/previewSelection.test.ts +481 -0
- package/src/components/editor/previewSelection.ts +516 -0
- package/src/components/editor/probeSourceElement.ts +19 -1
- package/src/components/editor/propertyPanelFill.tsx +5 -1
- package/src/components/editor/resizeDraft.ts +38 -0
- package/src/components/editor/useDomEditOverlayGestures.ts +2 -2
- package/src/components/editor/useDomEditOverlayRects.ts +80 -1
- package/src/components/editor/useInlineTextEditing.tsx +1 -6
- package/src/components/editor/useLayerDrag.ts +1 -1
- package/src/components/nle/NLEPreview.slowBoot.test.ts +0 -1
- package/src/hooks/domEditDeleteMembers.test.ts +7 -0
- package/src/hooks/domSelectionTestHarness.ts +1 -1
- package/src/hooks/domSelectionTimelineMirror.ts +3 -1
- package/src/hooks/timelineTimingSync.ts +4 -1
- package/src/hooks/useDomEditSession.test.tsx +23 -1
- package/src/hooks/useDomEditSession.ts +2 -1
- package/src/hooks/useDomSelection.ts +63 -47
- package/src/hooks/useEditorSave.test.tsx +22 -1
- package/src/hooks/useEditorSave.ts +3 -1
- package/src/hooks/useGsapSelectionHandlers.test.tsx +17 -0
- package/src/hooks/useGsapSelectionHandlers.ts +2 -1
- package/src/hooks/usePreviewInteraction.test.ts +10 -2
- package/src/hooks/usePreviewInteraction.ts +9 -5
- package/src/hooks/useProjectFileWriter.ts +7 -3
- package/src/hooks/useStudioSelectionPublisher.test.tsx +50 -0
- package/src/hooks/useStudioSelectionPublisher.ts +9 -7
- package/src/hooks/useTimelineSelectionPreviewSync.test.tsx +30 -0
- package/src/hooks/useTimelineSelectionPreviewSync.ts +7 -2
- package/src/player/lib/layerOrdering.ts +2 -11
- package/src/player/lib/previewChannel.ts +4 -3
- package/src/player/lib/previewElements.ts +143 -3
- package/src/styles/hex-baseline.json +1 -2
- package/src/test-setup.ts +2 -0
- package/src/utils/gsapSoftReload.ts +1 -1
- package/src/utils/studioFileHistory.ts +1 -1
- package/src/utils/studioHelpers.ts +27 -17
- package/src/utils/studioPreviewHelpers.test.ts +8 -8
- package/src/utils/studioPreviewHelpers.ts +26 -242
- package/src/utils/studioSaveDiagnostics.test.ts +34 -0
- package/src/utils/studioSaveDiagnostics.ts +35 -6
- package/src/utils/timelineCompositionInsert.ts +3 -1
- package/src/components/editor/domEditOverlayTransform.ts +0 -126
package/dist/player.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/studio",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.42",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -64,12 +64,12 @@
|
|
|
64
64
|
"dockview-react": "8.3.1",
|
|
65
65
|
"gsap": "^3.13.0",
|
|
66
66
|
"mediabunny": "^1.65.2",
|
|
67
|
-
"@hyperframes/
|
|
68
|
-
"@hyperframes/
|
|
69
|
-
"@hyperframes/
|
|
70
|
-
"@hyperframes/core": "0.9.
|
|
71
|
-
"@hyperframes/
|
|
72
|
-
"@hyperframes/
|
|
67
|
+
"@hyperframes/player": "0.9.42",
|
|
68
|
+
"@hyperframes/parsers": "0.9.42",
|
|
69
|
+
"@hyperframes/shader-transitions": "0.9.42",
|
|
70
|
+
"@hyperframes/core": "0.9.42",
|
|
71
|
+
"@hyperframes/studio-server": "0.9.42",
|
|
72
|
+
"@hyperframes/sdk": "0.9.42"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -83,10 +83,10 @@
|
|
|
83
83
|
"tailwindcss": "^4.3.3",
|
|
84
84
|
"tsup": "^8.0.0",
|
|
85
85
|
"typescript": "^5.0.0",
|
|
86
|
-
"vite": "^6.4.
|
|
87
|
-
"vitest": "^4.1.
|
|
86
|
+
"vite": "^6.4.5",
|
|
87
|
+
"vitest": "^4.1.12",
|
|
88
88
|
"zustand": "^5.0.0",
|
|
89
|
-
"@hyperframes/producer": "0.9.
|
|
89
|
+
"@hyperframes/producer": "0.9.42"
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|
|
92
92
|
"react": "19",
|
|
@@ -38,6 +38,7 @@ import { useMountEffect } from "../../hooks/useMountEffect";
|
|
|
38
38
|
import { countStudioManualEditSave as counted } from "./manualEditsDom";
|
|
39
39
|
import type { ZOrderAction, ZOrderPatch } from "./canvasContextMenuZOrder";
|
|
40
40
|
import { getPreviewTargetFromPointer } from "../../utils/studioPreviewHelpers";
|
|
41
|
+
import { pointerMayHitElement } from "./previewSelection";
|
|
41
42
|
import { logSelect } from "../../utils/selectDebug";
|
|
42
43
|
import { useOffCanvasIndicators } from "./useOffCanvasIndicators";
|
|
43
44
|
import { DomEditGestureReadout } from "./DomEditGestureReadout";
|
|
@@ -382,12 +383,7 @@ export const DomEditOverlay = memo(function DomEditOverlay({
|
|
|
382
383
|
const candidate = resolveShiftClickCandidate({
|
|
383
384
|
cached: hoverSelectionRef.current,
|
|
384
385
|
elementAtPoint: shiftIframe
|
|
385
|
-
? getPreviewTargetFromPointer(
|
|
386
|
-
shiftIframe,
|
|
387
|
-
event.clientX,
|
|
388
|
-
event.clientY,
|
|
389
|
-
activeCompositionPathRef.current,
|
|
390
|
-
)
|
|
386
|
+
? getPreviewTargetFromPointer(shiftIframe, event.clientX, event.clientY)
|
|
391
387
|
: null,
|
|
392
388
|
});
|
|
393
389
|
// Not confident: fall through untouched — no preventDefault, no suppression —
|
|
@@ -421,15 +417,7 @@ export const DomEditOverlay = memo(function DomEditOverlay({
|
|
|
421
417
|
// Confirm emptiness with a fresh SYNCHRONOUS hit-test before committing.
|
|
422
418
|
if (!hoverSelectionRef.current && onMarqueeSelectRef.current && compRect.width > 0) {
|
|
423
419
|
const iframe = iframeRef.current;
|
|
424
|
-
|
|
425
|
-
? getPreviewTargetFromPointer(
|
|
426
|
-
iframe,
|
|
427
|
-
event.clientX,
|
|
428
|
-
event.clientY,
|
|
429
|
-
activeCompositionPathRef.current,
|
|
430
|
-
)
|
|
431
|
-
: null;
|
|
432
|
-
if (freshTarget) return;
|
|
420
|
+
if (iframe && pointerMayHitElement(iframe, event.clientX, event.clientY)) return;
|
|
433
421
|
if (overlayRef.current) {
|
|
434
422
|
// Anywhere empty on the overlay starts one, not just inside the frame.
|
|
435
423
|
// An element dragged past the edge sits OUT there in the grey, and a
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
|
|
3
|
+
import { act, createElement } from "react";
|
|
4
|
+
import { createRoot } from "react-dom/client";
|
|
5
|
+
import { afterEach, expect, it, vi } from "vitest";
|
|
6
|
+
// The frame's real runtime agent, serving the opaque frame from this document.
|
|
7
|
+
import { installEditingAgent } from "../../../../core/src/runtime/editingAgent";
|
|
8
|
+
import { installReactActEnvironment } from "../../hooks/domSelectionTestHarness";
|
|
9
|
+
import { detachedFakeIframe } from "../../player/hooks/timelinePlayerTestHarness";
|
|
10
|
+
import { usePreviewIframeStore } from "../../player/store/previewIframeStore";
|
|
11
|
+
import type { DomEditSelection } from "./domEditing";
|
|
12
|
+
import { LayersPanel } from "./LayersPanel";
|
|
13
|
+
import { announcePreviewDocumentLoaded } from "../../player/sceneSwap";
|
|
14
|
+
import { describePreviewElements, queryPreviewElements } from "../../player/lib/previewElements";
|
|
15
|
+
import { standInFor } from "./previewSelection";
|
|
16
|
+
|
|
17
|
+
installReactActEnvironment();
|
|
18
|
+
|
|
19
|
+
const mocks = vi.hoisted(() => ({
|
|
20
|
+
previewIframeRef: { current: null } as { current: unknown },
|
|
21
|
+
activeGroupElement: null as HTMLElement | null,
|
|
22
|
+
applyDomSelection: vi.fn(),
|
|
23
|
+
setActiveGroupElement: vi.fn(),
|
|
24
|
+
// While set, a layers read waits on it after the frame answers.
|
|
25
|
+
hold: null as Promise<void> | null,
|
|
26
|
+
answered: 0,
|
|
27
|
+
}));
|
|
28
|
+
vi.mock("../../player/lib/previewElements", async (importOriginal) => {
|
|
29
|
+
const actual = await importOriginal<typeof import("../../player/lib/previewElements")>();
|
|
30
|
+
return {
|
|
31
|
+
...actual,
|
|
32
|
+
previewLayers: async (...args: Parameters<typeof actual.previewLayers>) => {
|
|
33
|
+
const reply = await actual.previewLayers(...args);
|
|
34
|
+
mocks.answered += 1;
|
|
35
|
+
await mocks.hold;
|
|
36
|
+
return reply;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
vi.mock("../../contexts/StudioContext", () => ({
|
|
41
|
+
useStudioShellContextOptional: () => ({
|
|
42
|
+
previewIframeRef: mocks.previewIframeRef,
|
|
43
|
+
activeCompPath: "index.html",
|
|
44
|
+
showToast: vi.fn(),
|
|
45
|
+
}),
|
|
46
|
+
useStudioPlaybackContextOptional: () => ({
|
|
47
|
+
refreshKey: 0,
|
|
48
|
+
compositionLoading: false,
|
|
49
|
+
timelineElements: [],
|
|
50
|
+
isPlaying: false,
|
|
51
|
+
}),
|
|
52
|
+
}));
|
|
53
|
+
vi.mock("../../contexts/DomEditContext", () => ({
|
|
54
|
+
useDomEditContext: () => ({
|
|
55
|
+
domEditSelection: null,
|
|
56
|
+
activeGroupElement: mocks.activeGroupElement,
|
|
57
|
+
applyDomSelection: mocks.applyDomSelection,
|
|
58
|
+
updateDomEditHoverSelection: vi.fn(),
|
|
59
|
+
handleDomZIndexReorderCommit: vi.fn(),
|
|
60
|
+
setActiveGroupElement: mocks.setActiveGroupElement,
|
|
61
|
+
}),
|
|
62
|
+
}));
|
|
63
|
+
vi.mock("../nle/useCanvasZOrderTimelineMirror", () => ({
|
|
64
|
+
useLayerReorderTimelineMirror: () => vi.fn(),
|
|
65
|
+
}));
|
|
66
|
+
|
|
67
|
+
const closers: Array<() => void> = [];
|
|
68
|
+
afterEach(() => {
|
|
69
|
+
closers.splice(0).forEach((close) => close());
|
|
70
|
+
mocks.activeGroupElement = null;
|
|
71
|
+
mocks.hold = null;
|
|
72
|
+
mocks.answered = 0;
|
|
73
|
+
vi.clearAllMocks();
|
|
74
|
+
usePreviewIframeStore.setState({ iframe: null });
|
|
75
|
+
document.body.innerHTML = "";
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
/** A frame Studio cannot read, whose runtime is the real editing agent over this document. */
|
|
79
|
+
function opaqueFrame() {
|
|
80
|
+
const frame: Record<string, unknown> = {};
|
|
81
|
+
const iframe = detachedFakeIframe(frame);
|
|
82
|
+
Object.defineProperty(iframe, "contentDocument", { value: null });
|
|
83
|
+
Object.defineProperty(frame, "document", {
|
|
84
|
+
get: () => {
|
|
85
|
+
throw new DOMException("blocked", "SecurityError");
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
const parent = {
|
|
89
|
+
postMessage: (data: unknown, _origin: string, ports: MessagePort[]) =>
|
|
90
|
+
window.dispatchEvent(
|
|
91
|
+
new MessageEvent("message", { source: frame as unknown as Window, data, ports }),
|
|
92
|
+
),
|
|
93
|
+
} as unknown as Window;
|
|
94
|
+
const agent = installEditingAgent(parent);
|
|
95
|
+
frame.postMessage = (data: unknown) =>
|
|
96
|
+
window.dispatchEvent(new MessageEvent("message", { source: parent, data }));
|
|
97
|
+
closers.push(() => agent.dispose());
|
|
98
|
+
return iframe;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
it("lists an opaque frame's layers, selects a row, and drills into a group row", async () => {
|
|
102
|
+
document.body.innerHTML = `<main data-composition-id="main">
|
|
103
|
+
<div id="card"><h1 id="title">Hi</h1></div>
|
|
104
|
+
<div id="pair" data-hf-group="pair"><i id="a"></i></div>
|
|
105
|
+
<div id="host" data-composition-src="compositions/intro-card.html"></div></main>`;
|
|
106
|
+
const iframe = opaqueFrame();
|
|
107
|
+
mocks.previewIframeRef.current = iframe;
|
|
108
|
+
usePreviewIframeStore.setState({ iframe });
|
|
109
|
+
const host = document.createElement("div");
|
|
110
|
+
document.body.append(host);
|
|
111
|
+
const root = createRoot(host);
|
|
112
|
+
act(() => root.render(createElement(LayersPanel)));
|
|
113
|
+
closers.push(() => act(() => root.unmount()));
|
|
114
|
+
|
|
115
|
+
const rows = () => [...host.querySelectorAll<HTMLElement>("[data-layer-index]")];
|
|
116
|
+
await vi.waitFor(() => expect(rows()).toHaveLength(5));
|
|
117
|
+
const named = (label: string) => rows().find((r) => r.textContent?.includes(label))!;
|
|
118
|
+
expect(named("Title").querySelector("[data-layer-kind]")!.getAttribute("data-layer-kind")).toBe(
|
|
119
|
+
"text",
|
|
120
|
+
);
|
|
121
|
+
expect(named("pair").title).toBe("This layer can't be reordered");
|
|
122
|
+
const hostIcon = named("Intro").querySelector("[data-layer-kind]")!;
|
|
123
|
+
expect(hostIcon.className).toContain("bg-on");
|
|
124
|
+
|
|
125
|
+
act(() => named("Title").click());
|
|
126
|
+
await vi.waitFor(() => expect(mocks.applyDomSelection).toHaveBeenCalled());
|
|
127
|
+
const picked = mocks.applyDomSelection.mock.calls[0]![0] as DomEditSelection;
|
|
128
|
+
expect(picked).toMatchObject({ id: "title", selector: "#title" });
|
|
129
|
+
expect(picked.handle).toBeTruthy();
|
|
130
|
+
|
|
131
|
+
act(() => void named("pair").dispatchEvent(new MouseEvent("dblclick", { bubbles: true })));
|
|
132
|
+
await vi.waitFor(() => expect(mocks.setActiveGroupElement).toHaveBeenCalledOnce());
|
|
133
|
+
const group = mocks.setActiveGroupElement.mock.calls[0]![0] as HTMLElement;
|
|
134
|
+
expect(group.hasAttribute("data-hf-group")).toBe(false);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
function renderPanel(iframe: HTMLIFrameElement) {
|
|
138
|
+
mocks.previewIframeRef.current = iframe;
|
|
139
|
+
usePreviewIframeStore.setState({ iframe });
|
|
140
|
+
const host = document.createElement("div");
|
|
141
|
+
document.body.append(host);
|
|
142
|
+
const root = createRoot(host);
|
|
143
|
+
act(() => root.render(createElement(LayersPanel)));
|
|
144
|
+
closers.push(() => act(() => root.unmount()));
|
|
145
|
+
return () =>
|
|
146
|
+
[...host.querySelectorAll<HTMLElement>("[data-layer-index]")].map((r) => r.textContent);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
it("leaves a drill-in whose group a reload took, rather than list the whole page under it", async () => {
|
|
150
|
+
document.body.innerHTML = `<main data-composition-id="main">
|
|
151
|
+
<div id="card"></div><div id="pair" data-hf-group="pair"><i id="a"></i></div></main>`;
|
|
152
|
+
const iframe = opaqueFrame();
|
|
153
|
+
const [pair] = (await queryPreviewElements(iframe, "#pair"))!.matches;
|
|
154
|
+
const [described] = (await describePreviewElements(iframe, [pair!.handle]))!;
|
|
155
|
+
mocks.activeGroupElement = standInFor(iframe, described!);
|
|
156
|
+
document.getElementById("pair")!.remove();
|
|
157
|
+
const rows = renderPanel(iframe);
|
|
158
|
+
await vi.waitFor(() => expect(mocks.setActiveGroupElement).toHaveBeenCalledWith(null));
|
|
159
|
+
expect(rows()).toEqual([]);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it("reads the layers once more when a refresh lands while a read is in flight", async () => {
|
|
163
|
+
document.body.innerHTML = `<main data-composition-id="main"><div id="card"></div></main>`;
|
|
164
|
+
let release!: () => void;
|
|
165
|
+
mocks.hold = new Promise<void>((resolve) => (release = resolve));
|
|
166
|
+
const iframe = opaqueFrame();
|
|
167
|
+
const rows = renderPanel(iframe);
|
|
168
|
+
await vi.waitFor(() => expect(mocks.answered).toBe(1));
|
|
169
|
+
// Past the panel's settle timer, so only the announced refresh can bring the new layer.
|
|
170
|
+
await new Promise((resolve) => setTimeout(resolve, 150));
|
|
171
|
+
// The first read has its answer and is waiting; the page changes and announces it.
|
|
172
|
+
document.querySelector("main")!.insertAdjacentHTML("beforeend", `<div id="late"></div>`);
|
|
173
|
+
act(() => announcePreviewDocumentLoaded(iframe));
|
|
174
|
+
act(() => release());
|
|
175
|
+
await vi.waitFor(() => expect(rows()).toEqual(["Late", "Card"]));
|
|
176
|
+
});
|
|
@@ -40,6 +40,10 @@ import { zReorderCoalesceKey } from "../../hooks/useElementLifecycleOps";
|
|
|
40
40
|
import { useLayerReorderTimelineMirror } from "../nle/useCanvasZOrderTimelineMirror";
|
|
41
41
|
import { runZLaneGesture } from "../nle/zLaneGesture";
|
|
42
42
|
import { useLayerRevealOverride } from "./useLayerRevealOverride";
|
|
43
|
+
import { previewFrameOpaque } from "../../player/lib/previewChannel";
|
|
44
|
+
import { describePreviewElements } from "../../player/lib/previewElements";
|
|
45
|
+
import { collectPreviewLayerItems, layerDataAttribute } from "./previewLayers";
|
|
46
|
+
import { resolvePreviewSelection, selectionDataAttribute } from "./previewSelection";
|
|
43
47
|
|
|
44
48
|
// Rows this panel renders before it stops. A display budget, not a document limit.
|
|
45
49
|
const LAYERS_PANEL_MAX_ROWS = 80;
|
|
@@ -146,9 +150,26 @@ export const LayersPanel = memo(function LayersPanel({ host }: { host?: LayersPa
|
|
|
146
150
|
const isMasterView = !activeCompPath || activeCompPath === "index.html";
|
|
147
151
|
|
|
148
152
|
const livePreviewIframe = useLivePreviewIframe();
|
|
153
|
+
// The opaque read in flight; `again` holds a refresh that arrived meanwhile, run once it settles.
|
|
154
|
+
const opaqueRead = useRef<{ again: boolean } | null>(null);
|
|
149
155
|
const collectLayers = useCallback(() => {
|
|
150
156
|
const iframe = previewIframeRef.current;
|
|
151
157
|
if (!iframe) return;
|
|
158
|
+
if (previewFrameOpaque(iframe)) {
|
|
159
|
+
if (opaqueRead.current) return void (opaqueRead.current.again = true);
|
|
160
|
+
const read = { again: false };
|
|
161
|
+
opaqueRead.current = read;
|
|
162
|
+
const scope = { activeCompositionPath: activeCompPath, activeGroupElement };
|
|
163
|
+
void collectPreviewLayerItems(iframe, scope, LAYERS_PANEL_MAX_ROWS).then((reply) => {
|
|
164
|
+
if (opaqueRead.current !== read) return;
|
|
165
|
+
opaqueRead.current = null;
|
|
166
|
+
// A reload took the drilled-into group; leave it as same-origin does below.
|
|
167
|
+
if (reply?.missingGroup) return setActiveGroupElement(null);
|
|
168
|
+
if (reply) setLayers(sortLayersByZIndex(reply.items));
|
|
169
|
+
if (read.again) collectLayers();
|
|
170
|
+
});
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
152
173
|
let doc: Document | null = null;
|
|
153
174
|
try {
|
|
154
175
|
doc = iframe.contentDocument;
|
|
@@ -175,6 +196,7 @@ export const LayersPanel = memo(function LayersPanel({ host }: { host?: LayersPa
|
|
|
175
196
|
}, [previewIframeRef, activeCompPath, isMasterView, activeGroupElement, setActiveGroupElement]);
|
|
176
197
|
|
|
177
198
|
useEffect(() => {
|
|
199
|
+
opaqueRead.current = null;
|
|
178
200
|
collectLayers();
|
|
179
201
|
}, [collectLayers, refreshKey, zEditVersion, livePreviewIframe]);
|
|
180
202
|
|
|
@@ -210,15 +232,20 @@ export const LayersPanel = memo(function LayersPanel({ host }: { host?: LayersPa
|
|
|
210
232
|
}, [collectLayers]);
|
|
211
233
|
|
|
212
234
|
const resolveSelection = useCallback(
|
|
213
|
-
(layer: DomEditLayerItem) => {
|
|
214
|
-
const
|
|
215
|
-
const
|
|
216
|
-
return resolveDomEditSelection(el, {
|
|
235
|
+
async (layer: DomEditLayerItem) => {
|
|
236
|
+
const iframe = previewIframeRef.current;
|
|
237
|
+
const options = {
|
|
217
238
|
activeCompositionPath: activeCompPath,
|
|
218
239
|
isMasterView,
|
|
219
240
|
preferClipAncestor: false,
|
|
220
241
|
activeGroupElement,
|
|
221
|
-
}
|
|
242
|
+
};
|
|
243
|
+
if (layer.preview && iframe) {
|
|
244
|
+
const [described] = (await describePreviewElements(iframe, [layer.preview.handle])) ?? [];
|
|
245
|
+
return described ? resolvePreviewSelection(iframe, described, options) : null;
|
|
246
|
+
}
|
|
247
|
+
const el = liveLayerElement(layer, iframe?.contentDocument, activeCompPath);
|
|
248
|
+
return resolveDomEditSelection(el, options);
|
|
222
249
|
},
|
|
223
250
|
[activeCompPath, isMasterView, previewIframeRef, activeGroupElement],
|
|
224
251
|
);
|
|
@@ -228,7 +255,8 @@ export const LayersPanel = memo(function LayersPanel({ host }: { host?: LayersPa
|
|
|
228
255
|
const selection = await resolveSelection(layer);
|
|
229
256
|
if (!selection) return;
|
|
230
257
|
|
|
231
|
-
|
|
258
|
+
const scope = activeCompPath || "index.html";
|
|
259
|
+
let matchedId = findMatchingTimelineElementId(selection, timelineElements, scope);
|
|
232
260
|
|
|
233
261
|
if (!matchedId) {
|
|
234
262
|
const sourceFile = selection.sourceFile ?? "index.html";
|
|
@@ -253,7 +281,7 @@ export const LayersPanel = memo(function LayersPanel({ host }: { host?: LayersPa
|
|
|
253
281
|
}
|
|
254
282
|
}
|
|
255
283
|
},
|
|
256
|
-
[currentTime, resolveSelection, timelineElements],
|
|
284
|
+
[activeCompPath, currentTime, resolveSelection, timelineElements],
|
|
257
285
|
);
|
|
258
286
|
|
|
259
287
|
const handleSelectLayer = useCallback(
|
|
@@ -275,7 +303,7 @@ export const LayersPanel = memo(function LayersPanel({ host }: { host?: LayersPa
|
|
|
275
303
|
const handleLayerDoubleClick = useCallback(
|
|
276
304
|
async (layer: DomEditLayerItem) => {
|
|
277
305
|
const selection = await resolveSelection(layer);
|
|
278
|
-
if (selection
|
|
306
|
+
if (selection && selectionDataAttribute(selection, "data-hf-group") !== null) {
|
|
279
307
|
setActiveGroupElement(selection.element);
|
|
280
308
|
} else {
|
|
281
309
|
await handleSelectLayer(layer);
|
|
@@ -456,8 +484,11 @@ export const LayersPanel = memo(function LayersPanel({ host }: { host?: LayersPa
|
|
|
456
484
|
const draggable = isLayerDraggable(layer);
|
|
457
485
|
const isCollapsed = collapsed[layer.key] ?? false;
|
|
458
486
|
const hasChildren = layer.childCount > 0;
|
|
459
|
-
const isCompHost =
|
|
460
|
-
|
|
487
|
+
const isCompHost = layer.preview
|
|
488
|
+
? layerDataAttribute(layer, "data-composition-src") !== null ||
|
|
489
|
+
layerDataAttribute(layer, "data-composition-file") !== null
|
|
490
|
+
: isCompositionHost(layer.element);
|
|
491
|
+
const kind = layer.preview?.kind ?? layerKindOf(layer.element, hasChildren);
|
|
461
492
|
const KindIcon = KIND_ICON[kind];
|
|
462
493
|
const kindName = kind[0].toUpperCase() + kind.slice(1);
|
|
463
494
|
const hint = draggable
|
|
@@ -47,11 +47,12 @@ function mount() {
|
|
|
47
47
|
function render(
|
|
48
48
|
hoverSelection: DomEditSelection | null,
|
|
49
49
|
selection: DomEditSelection | null = null,
|
|
50
|
+
iframe = document.createElement("iframe"),
|
|
50
51
|
) {
|
|
51
52
|
act(() =>
|
|
52
53
|
root.render(
|
|
53
54
|
<DomEditOverlay
|
|
54
|
-
iframeRef={{ current:
|
|
55
|
+
iframeRef={{ current: iframe }}
|
|
55
56
|
activeCompositionPath={null}
|
|
56
57
|
selection={selection}
|
|
57
58
|
hoverSelection={hoverSelection}
|
|
@@ -120,3 +121,18 @@ it("a shift+click on a selected box that cannot move toggles it once", () => {
|
|
|
120
121
|
expect(onSelectionChange).toHaveBeenCalledTimes(1);
|
|
121
122
|
expect(onCanvasMouseDown).not.toHaveBeenCalled();
|
|
122
123
|
});
|
|
124
|
+
|
|
125
|
+
it("on a frame Studio cannot script, a press with no pointer answer yet selects, not starts a band", () => {
|
|
126
|
+
const { host } = mount();
|
|
127
|
+
const frame = {};
|
|
128
|
+
Object.defineProperty(frame, "document", {
|
|
129
|
+
get: () => {
|
|
130
|
+
throw new DOMException("blocked", "SecurityError");
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
const opaque = document.createElement("iframe");
|
|
134
|
+
Object.defineProperty(opaque, "contentWindow", { value: frame });
|
|
135
|
+
render(null, null, opaque);
|
|
136
|
+
press(host.firstElementChild!);
|
|
137
|
+
expect(onCanvasMouseDown).toHaveBeenCalledTimes(1);
|
|
138
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hasOnlyFormattingChildren } from "@hyperframes/core/runtime/editing-port";
|
|
2
2
|
import type { DomEditSelection } from "./domEditingTypes";
|
|
3
3
|
import { isTextEditableSelection } from "./domEditingLayers";
|
|
4
4
|
|
|
@@ -53,21 +53,6 @@ export function canEditElementTextInline(element: HTMLElement | null): boolean {
|
|
|
53
53
|
return (element.textContent ?? "").trim().length > 0;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
export function hasOnlyFormattingChildren(element: HTMLElement): boolean {
|
|
57
|
-
for (const child of Array.from(element.children)) {
|
|
58
|
-
if (!isRichTextFormattingTag(child.tagName)) return false;
|
|
59
|
-
if (!isHtmlFromAnyWindow(child)) return false;
|
|
60
|
-
// Formatting nests, and a structural child hidden inside a span is still
|
|
61
|
-
// structural.
|
|
62
|
-
if (!hasOnlyFormattingChildren(child as HTMLElement)) return false;
|
|
63
|
-
}
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function isHtmlFromAnyWindow(node: Element): boolean {
|
|
68
|
-
return node.namespaceURI === "http://www.w3.org/1999/xhtml";
|
|
69
|
-
}
|
|
70
|
-
|
|
71
56
|
/** Where and when a press landed, for recognising the next one as a pair. */
|
|
72
57
|
export interface PressMark {
|
|
73
58
|
x: number;
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
* Its own module because it is the one piece of that file every other piece
|
|
12
12
|
* depends on and nothing in it is about a single element's geometry.
|
|
13
13
|
*/
|
|
14
|
+
import { previewStageSize } from "../../player/lib/bridgePlayback";
|
|
15
|
+
import { previewFrameOpaque } from "../../player/lib/previewChannel";
|
|
14
16
|
|
|
15
17
|
/** iframe→overlay mapping basis shared by every overlay-geometry function. */
|
|
16
18
|
export interface OverlayRootScale {
|
|
@@ -52,7 +54,8 @@ function resolveRootDimensions(root: HTMLElement | null): { width: number; heigh
|
|
|
52
54
|
* instead of rootRect.width/height: when GSAP applies transforms (scale,
|
|
53
55
|
* translate) to the root, rootRect dimensions change but the composition's
|
|
54
56
|
* canonical size stays fixed, and using rootRect misaligns the overlay during
|
|
55
|
-
* animated playback.
|
|
57
|
+
* animated playback. A frame Studio cannot script is scaled by the size its
|
|
58
|
+
* runtime posts. Returns null when the geometry is unmeasurable.
|
|
56
59
|
*/
|
|
57
60
|
export function computeOverlayRootScale(
|
|
58
61
|
overlayEl: HTMLDivElement,
|
|
@@ -61,7 +64,9 @@ export function computeOverlayRootScale(
|
|
|
61
64
|
): OverlayRootScale | null {
|
|
62
65
|
const iframeRect = iframe.getBoundingClientRect();
|
|
63
66
|
const overlayRect = overlayEl.getBoundingClientRect();
|
|
64
|
-
const dims =
|
|
67
|
+
const dims = previewFrameOpaque(iframe)
|
|
68
|
+
? previewStageSize(iframe)
|
|
69
|
+
: resolveRootDimensions(findOverlayRootElement(doc));
|
|
65
70
|
if (!dims) return null;
|
|
66
71
|
return {
|
|
67
72
|
iframeRect,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
resolveCropInsetFromMoveDrag,
|
|
9
9
|
rotateDeltaIntoFrame,
|
|
10
10
|
} from "./domEditOverlayCrop";
|
|
11
|
-
import { individualRotateDegrees } from "
|
|
11
|
+
import { individualRotateDegrees } from "@hyperframes/core/runtime/editing-port";
|
|
12
12
|
|
|
13
13
|
describe("resolveCropInsetFromEdgeDrag", () => {
|
|
14
14
|
const startInsets = { top: 10, right: 20, bottom: 30, left: 40 };
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
composeElementTransform,
|
|
3
|
+
type PlanarTransformOps,
|
|
4
|
+
} from "@hyperframes/core/runtime/editing-port";
|
|
2
5
|
import {
|
|
3
6
|
parseInsetClipPathSides,
|
|
4
7
|
type ClipPathInsetSides,
|
|
@@ -167,8 +170,19 @@ export function hugRectForElement(
|
|
|
167
170
|
rect: CropScreenRect & { editScaleX: number; editScaleY: number },
|
|
168
171
|
element: HTMLElement,
|
|
169
172
|
): CropScreenRect {
|
|
170
|
-
|
|
171
|
-
|
|
173
|
+
// A lifted clip shows the full element rect.
|
|
174
|
+
return isElementCropLifted(element)
|
|
175
|
+
? rect
|
|
176
|
+
: hugRectForClipPath(rect, readElementClipPath(element));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** `hugRectForElement` for a clip-path read elsewhere; null is one that could not be read. */
|
|
180
|
+
export function hugRectForClipPath(
|
|
181
|
+
rect: CropScreenRect & { editScaleX: number; editScaleY: number },
|
|
182
|
+
clipPath: string | null,
|
|
183
|
+
): CropScreenRect {
|
|
184
|
+
const insets = clipPath === null ? null : parseCropClipPath(clipPath);
|
|
185
|
+
// Uneditable clip — show the full element rect.
|
|
172
186
|
if (!insets || (insets.top <= 0 && insets.right <= 0 && insets.bottom <= 0 && insets.left <= 0))
|
|
173
187
|
return rect;
|
|
174
188
|
return cropRectFromInsets(rect, insets, rect.editScaleX, rect.editScaleY);
|