From 55291c00c26b83d8a72c1a16fb957d0dcb7735aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Tue, 17 Nov 2026 08:46:24 +0000 Subject: [PATCH] fix(core): only Studio's own preview pages get the editing port, and undo sets only safe attributes (#8057) * fix(core): only Studio's own preview pages get the editing port, and undo sets only safe attributes restore-attributes now changes only class, style and the editor's timing, layout, audio and label data- attributes, and drops only data- ones; any other change answers applied: false and Studio reloads the preview. The editing agent hands its port over only when the page carries Studio's preview mark and not the another-site mark, so a page no Studio marked never offers it. * fix(core): undo on a lazily loaded image still applies in place The preview server adds loading="lazy" to timed images and the saved file does not have it, so the restore now may drop loading; dropping it loads nothing new. * style(core): keep the restore plan's doc comment within the line limit --- .../src/runtime/editing/color-grading.test.ts | 4 +- .../runtime/editing/restoreAttributes.test.ts | 26 ++++++++++++ .../src/runtime/editing/restoreAttributes.ts | 42 +++++++++++++++---- .../src/runtime/editingAgent.test-helpers.ts | 16 +++++++ .../core/src/runtime/editingAgent.test.ts | 17 +++++++- packages/core/src/runtime/editingAgent.ts | 4 +- .../core/src/runtime/editingGeometry.test.ts | 4 +- .../core/src/runtime/editingHandles.test.ts | 4 +- packages/core/src/runtime/editingPort.test.ts | 8 ++-- packages/core/src/studioPreviewMark.ts | 7 ++++ .../components/CaptionOverlay.sealed.test.ts | 4 +- .../editor/LayersPanel.opaque.test.ts | 4 +- .../components/editor/previewDrafts.test.ts | 4 +- .../editor/previewGestureStartRead.test.ts | 4 +- .../components/editor/previewLayers.test.ts | 4 +- .../editor/previewOverlayRects.test.ts | 4 +- .../editor/previewPointerTargets.test.ts | 4 +- .../editor/previewSelection.test.ts | 4 +- .../useColorGradingController.sealed.test.ts | 4 +- 19 files changed, 129 insertions(+), 39 deletions(-) create mode 100644 packages/core/src/runtime/editingAgent.test-helpers.ts diff --git a/packages/core/src/runtime/editing/color-grading.test.ts b/packages/core/src/runtime/editing/color-grading.test.ts index 4642d427ec..95c373e11f 100644 --- a/packages/core/src/runtime/editing/color-grading.test.ts +++ b/packages/core/src/runtime/editing/color-grading.test.ts @@ -1,5 +1,5 @@ import { afterEach, describe, expect, it, vi } from "vitest"; -import { installEditingAgent } from "../editingAgent"; +import { installMarkedEditingAgent } from "../editingAgent.test-helpers"; const CONNECT = { source: "hf-parent", type: "editing-connect", v: 1 }; const target = { id: "clip", hfId: null, selector: "#clip", selectorIndex: 0 }; @@ -16,7 +16,7 @@ function connect(): MessagePort { const parent = document.body.appendChild(document.createElement("iframe")).contentWindow!; const handoff = vi.fn(); parent.postMessage = handoff as unknown as Window["postMessage"]; - agent = installEditingAgent(parent); + agent = installMarkedEditingAgent(parent); window.dispatchEvent(new MessageEvent("message", { source: parent, data: CONNECT })); return (handoff.mock.calls[0]![2] as MessagePort[])[0]!; } diff --git a/packages/core/src/runtime/editing/restoreAttributes.test.ts b/packages/core/src/runtime/editing/restoreAttributes.test.ts index 3e510f3b72..66cfa18af7 100644 --- a/packages/core/src/runtime/editing/restoreAttributes.test.ts +++ b/packages/core/src/runtime/editing/restoreAttributes.test.ts @@ -73,6 +73,32 @@ describe("restore-attributes", () => { expect(rebind).not.toHaveBeenCalled(); }); + it("changes no handler, URL or sandbox-style attribute, and leaves an unchanged one alone", () => { + const refused = (html: string, attributes: [string, string][]) => { + document.body.innerHTML = html; + player(); + const before = document.body.innerHTML; + expect(restoreAttributes(restore("hf:box", attributes))).toEqual({ applied: false }); + expect(document.body.innerHTML).toBe(before); + }; + const box = '
'; + const id: [string, string] = ["data-hf-id", "box"]; + for (const name of ["onclick", "ONCLICK", "href", "src", "srcdoc", "xlink:href", "sandbox"]) + refused(box, [id, [name, "alert(1)"]]); + refused(box, [id, ["data-composition-src", "https://example.com/a.html"]]); + refused('', [id]); + + document.body.innerHTML = + ''; + player(); + const img = document.querySelector("img")!; + const setAttribute = vi.spyOn(img, "setAttribute"); + const params = restore("hf:box", [id, ["src", "a.png"], ["style", "left: 0px"]]); + expect(restoreAttributes(params)).toEqual({ applied: true }); + expect(setAttribute.mock.calls).toEqual([["style", "left: 0px"]]); + expect(img.hasAttribute("loading")).toBe(false); + }); + it("accepts only bounded, well-formed params", () => { const ok = restore("hf:box", [["style", "left: 0"]]); expect(parseRestoreAttributes(ok)).toEqual(ok); diff --git a/packages/core/src/runtime/editing/restoreAttributes.ts b/packages/core/src/runtime/editing/restoreAttributes.ts index 542a11dfeb..4f8ca0637e 100644 --- a/packages/core/src/runtime/editing/restoreAttributes.ts +++ b/packages/core/src/runtime/editing/restoreAttributes.ts @@ -19,6 +19,29 @@ const MAX_KEY_LENGTH = 512; const MAX_VALUE_LENGTH = 200_000; const ATTRIBUTE_NAME = /^[^\s"'>/=]{1,256}$/; const IDENTITY_SELECTOR = "[id], [data-hf-id]"; +const SAFE_TO_SET = new Set([ + "class", + "style", + "data-start", + "data-end", + "data-duration", + "data-track-index", + "data-media-start", + "data-playback-start", + "data-playback-rate", + "data-volume", + "data-audio-muted", + "data-hidden", + "data-label", + "data-timeline-label", + "data-width", + "data-height", + "data-x", + "data-y", + "data-hf-group", +]); +const safeToDrop = (name: string) => + SAFE_TO_SET.has(name) || name === "loading" || name.startsWith("data-"); const isRecord = (value: unknown): value is Record => Object.prototype.toString.call(value) === "[object Object]"; @@ -96,9 +119,9 @@ function scopeRoots(file: string | null): ParentNode[] { ); } -type RestorePlan = [Element, RestoreAttribute[]][]; +type RestorePlan = [Element, drop: string[], set: RestoreAttribute[]][]; -/** Adds `root`'s live elements to `plan`; false when any is missing or not the file's own. */ +/** Adds `root`'s live elements to `plan`; false when any is missing, not the file's own, or unsafe to change. */ function planRoot( root: ParentNode, elements: RestoreScope["elements"], @@ -110,12 +133,16 @@ function planRoot( const el = live.get(key); // The preview rewrites a sub-composition's own root, so its attributes are not the file's. if (!el || el.hasAttribute("data-hf-inner-root")) return false; - plan.push([el, attributes]); + const keep = new Set(attributes.map(([name]) => name)); + const drop = el.getAttributeNames().filter((name) => !keep.has(name)); + const set = attributes.filter(([name, value]) => el.getAttribute(name) !== value); + if (!drop.every(safeToDrop) || !set.every(([name]) => SAFE_TO_SET.has(name))) return false; + plan.push([el, drop, set]); } return true; } -/** Each live element with the attributes it takes, or null when any is missing or not the file's own. */ +/** Each live element with the attributes it drops and sets, or null when the restore cannot apply in place. */ function planRestore(scopes: RestoreScope[]): RestorePlan | null { const plan: RestorePlan = []; for (const { file, elements } of scopes) { @@ -153,10 +180,9 @@ export function restoreAttributes({ scopes, scripted, time }: RestoreAttributesP const plan = planRestore(scopes); if (!plan || typeof win.__player?.seek !== "function") return { applied: false }; if (scripted && plan.some(([el]) => "_gsap" in el)) return { applied: false }; - for (const [el, attributes] of plan) { - const keep = new Set(attributes.map(([name]) => name)); - for (const name of el.getAttributeNames()) if (!keep.has(name)) el.removeAttribute(name); - for (const [name, value] of attributes) el.setAttribute(name, value); + for (const [el, drop, set] of plan) { + for (const name of drop) el.removeAttribute(name); + for (const [name, value] of set) el.setAttribute(name, value); } rebindAt(win, time); return { applied: true }; diff --git a/packages/core/src/runtime/editingAgent.test-helpers.ts b/packages/core/src/runtime/editingAgent.test-helpers.ts new file mode 100644 index 0000000000..62075b447f --- /dev/null +++ b/packages/core/src/runtime/editingAgent.test-helpers.ts @@ -0,0 +1,16 @@ +import { STUDIO_PREVIEW_MARK_META } from "../studioPreviewMark"; +import { installEditingAgent } from "./editingAgent"; + +/** The agent in a page Studio's preview server marked, the only page it hands a port to. */ +export function installMarkedEditingAgent(parent: Window): { dispose: () => void } { + const mark = document.createElement("meta"); + mark.name = STUDIO_PREVIEW_MARK_META; + document.head.append(mark); + const agent = installEditingAgent(parent); + return { + dispose() { + agent.dispose(); + mark.remove(); + }, + }; +} diff --git a/packages/core/src/runtime/editingAgent.test.ts b/packages/core/src/runtime/editingAgent.test.ts index 4138f5966d..e0a72969cf 100644 --- a/packages/core/src/runtime/editingAgent.test.ts +++ b/packages/core/src/runtime/editingAgent.test.ts @@ -1,9 +1,12 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { installEditingAgent } from "./editingAgent"; -import { PREVIEW_FOR_ANOTHER_SITE_META } from "../studioPreviewMark"; +import { PREVIEW_FOR_ANOTHER_SITE_META, STUDIO_PREVIEW_MARK_META } from "../studioPreviewMark"; const CONNECT = { source: "hf-parent", type: "editing-connect", v: 1 }; const H = "0123456789abcdef:1"; +const studioMark = document.createElement("meta"); +studioMark.name = STUDIO_PREVIEW_MARK_META; +document.head.append(studioMark); function frameWindow(): Window { const iframe = document.createElement("iframe"); @@ -126,6 +129,18 @@ describe("installEditingAgent", () => { expect(handoff).toHaveBeenCalledOnce(); }); + it("never hands off in a document Studio's preview server did not mark", () => { + studioMark.remove(); + try { + post(parent, CONNECT); + expect(handoff).not.toHaveBeenCalled(); + } finally { + document.head.append(studioMark); + } + post(parent, CONNECT); + expect(handoff).toHaveBeenCalledOnce(); + }); + it("stops listening for a connect once disposed", () => { agent.dispose(); post(parent, CONNECT); diff --git a/packages/core/src/runtime/editingAgent.ts b/packages/core/src/runtime/editingAgent.ts index 4e1685a30e..493933e5a2 100644 --- a/packages/core/src/runtime/editingAgent.ts +++ b/packages/core/src/runtime/editingAgent.ts @@ -36,8 +36,8 @@ import { restoreAttributes } from "./editing/restoreAttributes"; import { gestureStart } from "./editingGestureStart"; import { getLogicalOpacity, + markedForStudio, previewConsoleErrorText, - servedToAnotherSite, STUDIO_PREVIEW_ERRORS, } from "../studioPreviewMark"; import { MAX_QUERY_MATCHES } from "./editingElement"; @@ -251,7 +251,7 @@ export function installEditingAgent(parent: Window = window.parent): { dispose: const data = event.data; if (!isPlainRecord(data) || data.source !== "hf-parent" || data.type !== EDITING_CONNECT) return; - if (data.v !== EDITING_PROTOCOL_VERSION || servedToAnotherSite(document)) return; + if (data.v !== EDITING_PROTOCOL_VERSION || !markedForStudio(document)) return; const channel = new MessageChannel(); const port = channel.port1; ports.add(port); diff --git a/packages/core/src/runtime/editingGeometry.test.ts b/packages/core/src/runtime/editingGeometry.test.ts index c518d777c3..a26737e3b4 100644 --- a/packages/core/src/runtime/editingGeometry.test.ts +++ b/packages/core/src/runtime/editingGeometry.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import { installEditingAgent } from "./editingAgent"; +import { installMarkedEditingAgent } from "./editingAgent.test-helpers"; import { MAX_ELEMENT_VALUE, MAX_GEOMETRY_CHILDREN, @@ -86,7 +86,7 @@ describe("overlay geometry over the editing port", () => { const parent = iframe.contentWindow!; const handoff = vi.fn(); parent.postMessage = handoff as unknown as Window["postMessage"]; - agent = installEditingAgent(parent); + agent = installMarkedEditingAgent(parent); window.dispatchEvent(new MessageEvent("message", { source: parent, data: CONNECT })); port = (handoff.mock.calls[0]![2] as MessagePort[])[0]!; }); diff --git a/packages/core/src/runtime/editingHandles.test.ts b/packages/core/src/runtime/editingHandles.test.ts index 69212972bf..f91b219e16 100644 --- a/packages/core/src/runtime/editingHandles.test.ts +++ b/packages/core/src/runtime/editingHandles.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import { installEditingAgent } from "./editingAgent"; +import { installMarkedEditingAgent } from "./editingAgent.test-helpers"; import { trackedHandleCount } from "./editingHandles"; import { EDITING_ELEMENT_HANDLE, @@ -46,7 +46,7 @@ describe("element handles over the editing port", () => { const parent = iframe.contentWindow!; const handoff = vi.fn(); parent.postMessage = handoff as unknown as Window["postMessage"]; - agent = installEditingAgent(parent); + agent = installMarkedEditingAgent(parent); window.dispatchEvent(new MessageEvent("message", { source: parent, data: CONNECT })); port = (handoff.mock.calls[0]![2] as MessagePort[])[0]!; }); diff --git a/packages/core/src/runtime/editingPort.test.ts b/packages/core/src/runtime/editingPort.test.ts index 9bb1f27349..4ecd1fe023 100644 --- a/packages/core/src/runtime/editingPort.test.ts +++ b/packages/core/src/runtime/editingPort.test.ts @@ -1,5 +1,5 @@ import { afterEach, describe, expect, it, vi } from "vitest"; -import { installEditingAgent } from "./editingAgent"; +import { installMarkedEditingAgent } from "./editingAgent.test-helpers"; import { createEditingPortClient, EditingPortError, type EditingPortClient } from "./editingPort"; type Listener = (event: Partial) => void; @@ -53,7 +53,7 @@ describe("createEditingPortClient", () => { window.dispatchEvent( new MessageEvent("message", { source: parent, data }), )) as Window["postMessage"]; - const agent = installEditingAgent(parent); + const agent = installMarkedEditingAgent(parent); try { const client = createEditingPortClient({ iframe, host }); clients.push(client); @@ -142,7 +142,7 @@ describe("createEditingPortClient", () => { window.dispatchEvent( new MessageEvent("message", { source: parent, data }), )) as Window["postMessage"]; - const agent = installEditingAgent(parent); + const agent = installMarkedEditingAgent(parent); try { const first = createEditingPortClient({ iframe, host }); await first.ready; @@ -173,7 +173,7 @@ describe("createEditingPortClient", () => { toHost.push({ source: frame, data, ports: transfer }); }) as Window["postMessage"]; frame.postMessage = ((data: unknown) => toAgent.push(data)) as Window["postMessage"]; - const agent = installEditingAgent(parent); + const agent = installMarkedEditingAgent(parent); try { const client = createEditingPortClient({ iframe, host, timeoutMs: 300 }); clients.push(client); diff --git a/packages/core/src/studioPreviewMark.ts b/packages/core/src/studioPreviewMark.ts index 418a36b945..2e0db151eb 100644 --- a/packages/core/src/studioPreviewMark.ts +++ b/packages/core/src/studioPreviewMark.ts @@ -12,6 +12,13 @@ export function servedToAnotherSite(doc: Document): boolean { return doc.querySelector(`meta[name="${PREVIEW_FOR_ANOTHER_SITE_META}"]`) !== null; } +export function markedForStudio(doc: Document): boolean { + return ( + doc.querySelector(`meta[name="${STUDIO_PREVIEW_MARK_META}"]`) !== null && + !servedToAnotherSite(doc) + ); +} + export function getLogicalOpacity(el: Element, computed: CSSStyleDeclaration): string { const overlay = el.previousElementSibling; if ( diff --git a/packages/studio/src/captions/components/CaptionOverlay.sealed.test.ts b/packages/studio/src/captions/components/CaptionOverlay.sealed.test.ts index c231f332fa..16443a1cae 100644 --- a/packages/studio/src/captions/components/CaptionOverlay.sealed.test.ts +++ b/packages/studio/src/captions/components/CaptionOverlay.sealed.test.ts @@ -3,7 +3,7 @@ import { act, createElement, Fragment, useRef } from "react"; import { createRoot } from "react-dom/client"; import { afterEach, expect, it, vi } from "vitest"; // The frame's real runtime agent, serving the opaque frame from this document. -import { installEditingAgent } from "../../../../core/src/runtime/editingAgent"; +import { installMarkedEditingAgent } from "../../../../core/src/runtime/editingAgent.test-helpers"; import { installReactActEnvironment } from "../../hooks/domSelectionTestHarness"; import { detachedFakeIframe } from "../../player/hooks/timelinePlayerTestHarness"; import { previewRequest } from "../../player/lib/previewChannel"; @@ -77,7 +77,7 @@ function opaqueFrame() { }), ), } as unknown as Window; - const agent = installEditingAgent(parent); + const agent = installMarkedEditingAgent(parent); frame.postMessage = (data: unknown) => window.dispatchEvent(new MessageEvent("message", { source: parent, data })); closers.push(() => agent.dispose()); diff --git a/packages/studio/src/components/editor/LayersPanel.opaque.test.ts b/packages/studio/src/components/editor/LayersPanel.opaque.test.ts index 0da5e8e939..a4088431a7 100644 --- a/packages/studio/src/components/editor/LayersPanel.opaque.test.ts +++ b/packages/studio/src/components/editor/LayersPanel.opaque.test.ts @@ -4,7 +4,7 @@ import { act, createElement } from "react"; import { createRoot } from "react-dom/client"; import { afterEach, expect, it, vi } from "vitest"; // The frame's real runtime agent, serving the opaque frame from this document. -import { installEditingAgent } from "../../../../core/src/runtime/editingAgent"; +import { installMarkedEditingAgent } from "../../../../core/src/runtime/editingAgent.test-helpers"; import { installReactActEnvironment } from "../../hooks/domSelectionTestHarness"; import { detachedFakeIframe } from "../../player/hooks/timelinePlayerTestHarness"; import { usePreviewIframeStore } from "../../player/store/previewIframeStore"; @@ -91,7 +91,7 @@ function opaqueFrame() { new MessageEvent("message", { source: frame as unknown as Window, data, ports }), ), } as unknown as Window; - const agent = installEditingAgent(parent); + const agent = installMarkedEditingAgent(parent); frame.postMessage = (data: unknown) => window.dispatchEvent(new MessageEvent("message", { source: parent, data })); closers.push(() => agent.dispose()); diff --git a/packages/studio/src/components/editor/previewDrafts.test.ts b/packages/studio/src/components/editor/previewDrafts.test.ts index 264b3eb507..d09aa644be 100644 --- a/packages/studio/src/components/editor/previewDrafts.test.ts +++ b/packages/studio/src/components/editor/previewDrafts.test.ts @@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; // The frame's real runtime agent, serving the opaque frame from this document. -import { installEditingAgent } from "../../../../core/src/runtime/editingAgent"; +import { installMarkedEditingAgent } from "../../../../core/src/runtime/editingAgent.test-helpers"; import { detachedFakeIframe } from "../../player/hooks/timelinePlayerTestHarness"; import { describePreviewElements, queryPreviewElements } from "../../player/lib/previewElements"; import { resolvePreviewSelection, standInFor } from "./previewSelection"; @@ -61,7 +61,7 @@ function opaqueFrame(): HTMLIFrameElement { new MessageEvent("message", { source: frame as unknown as Window, data, ports }), ), } as unknown as Window; - const agent = installEditingAgent(parent); + const agent = installMarkedEditingAgent(parent); target.postMessage = (data: unknown) => window.dispatchEvent(new MessageEvent("message", { source: parent, data })); closers.push(() => agent.dispose()); diff --git a/packages/studio/src/components/editor/previewGestureStartRead.test.ts b/packages/studio/src/components/editor/previewGestureStartRead.test.ts index 4a48d0d71d..f4f47cf534 100644 --- a/packages/studio/src/components/editor/previewGestureStartRead.test.ts +++ b/packages/studio/src/components/editor/previewGestureStartRead.test.ts @@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; // The frame's real runtime agent, serving the opaque frame from this document. -import { installEditingAgent } from "../../../../core/src/runtime/editingAgent"; +import { installMarkedEditingAgent } from "../../../../core/src/runtime/editingAgent.test-helpers"; import { makeSelection } from "../../hooks/domSelectionTestHarness"; import { computeDraggedGsapPosition } from "../../hooks/draggedGsapPosition"; import { watchPreviewFrame } from "../../player/lib/bridgePlayback"; @@ -100,7 +100,7 @@ function opaqueFrame() { new MessageEvent("message", { source: frame as unknown as Window, data, ports }), ), } as unknown as Window; - const agent = installEditingAgent(parent); + const agent = installMarkedEditingAgent(parent); frame.postMessage = (data: unknown) => window.dispatchEvent(new MessageEvent("message", { source: parent, data })); closers.push(() => agent.dispose()); diff --git a/packages/studio/src/components/editor/previewLayers.test.ts b/packages/studio/src/components/editor/previewLayers.test.ts index a521c8e53e..2ae6df434c 100644 --- a/packages/studio/src/components/editor/previewLayers.test.ts +++ b/packages/studio/src/components/editor/previewLayers.test.ts @@ -5,7 +5,7 @@ import { MAX_QUERY_MATCHES } from "@hyperframes/core/runtime/editing-port"; import { createRoot } from "react-dom/client"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; // The frame's real runtime agent, serving the opaque frame from this document. -import { installEditingAgent } from "../../../../core/src/runtime/editingAgent"; +import { installMarkedEditingAgent } from "../../../../core/src/runtime/editingAgent.test-helpers"; import { installReactActEnvironment } from "../../hooks/domSelectionTestHarness"; import { watchPreviewFrame } from "../../player/lib/bridgePlayback"; import { getElementZIndex } from "../../player/lib/layerOrdering"; @@ -97,7 +97,7 @@ function opaqueFrame() { new MessageEvent("message", { source: frame as unknown as Window, data, ports }), ), } as unknown as Window; - const agent = installEditingAgent(parent); + const agent = installMarkedEditingAgent(parent); frame.postMessage = (data: unknown) => window.dispatchEvent(new MessageEvent("message", { source: parent, data })); closers.push(() => agent.dispose()); diff --git a/packages/studio/src/components/editor/previewOverlayRects.test.ts b/packages/studio/src/components/editor/previewOverlayRects.test.ts index ad8a1bfc8f..57a8d9021a 100644 --- a/packages/studio/src/components/editor/previewOverlayRects.test.ts +++ b/packages/studio/src/components/editor/previewOverlayRects.test.ts @@ -4,7 +4,7 @@ import React, { act } from "react"; import { createRoot } from "react-dom/client"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; // The frame's real runtime agent, serving the opaque frame from this document. -import { installEditingAgent } from "../../../../core/src/runtime/editingAgent"; +import { installMarkedEditingAgent } from "../../../../core/src/runtime/editingAgent.test-helpers"; import { makeSelection, installReactActEnvironment } from "../../hooks/domSelectionTestHarness"; import { watchPreviewFrame } from "../../player/lib/bridgePlayback"; import { queryPreviewElements } from "../../player/lib/previewElements"; @@ -131,7 +131,7 @@ function opaqueFrame() { new MessageEvent("message", { source: frame as unknown as Window, data, ports }), ), } as unknown as Window; - const agent = installEditingAgent(parent); + const agent = installMarkedEditingAgent(parent); frame.postMessage = (data: unknown) => window.dispatchEvent(new MessageEvent("message", { source: parent, data })); closers.push(() => agent.dispose()); diff --git a/packages/studio/src/components/editor/previewPointerTargets.test.ts b/packages/studio/src/components/editor/previewPointerTargets.test.ts index ace505d8dc..1f547dafbb 100644 --- a/packages/studio/src/components/editor/previewPointerTargets.test.ts +++ b/packages/studio/src/components/editor/previewPointerTargets.test.ts @@ -4,7 +4,7 @@ import React, { act } from "react"; import { createRoot } from "react-dom/client"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; // The frame's real runtime agent, serving the opaque frame from this document. -import { installEditingAgent } from "../../../../core/src/runtime/editingAgent"; +import { installMarkedEditingAgent } from "../../../../core/src/runtime/editingAgent.test-helpers"; import { getAllPreviewTargetsFromPointer, getPreviewTargetFromPointer, @@ -106,7 +106,7 @@ function opaqueFrame(): HTMLIFrameElement { new MessageEvent("message", { source: frame as unknown as Window, data, ports }), ), } as unknown as Window; - const agent = installEditingAgent(parent); + const agent = installMarkedEditingAgent(parent); frame.postMessage = (data: unknown) => window.dispatchEvent(new MessageEvent("message", { source: parent, data })); closers.push(() => agent.dispose()); diff --git a/packages/studio/src/components/editor/previewSelection.test.ts b/packages/studio/src/components/editor/previewSelection.test.ts index 83426ea3b2..817b23d01f 100644 --- a/packages/studio/src/components/editor/previewSelection.test.ts +++ b/packages/studio/src/components/editor/previewSelection.test.ts @@ -5,7 +5,7 @@ import { createRoot } from "react-dom/client"; import { afterEach, describe, expect, it, vi } from "vitest"; import { EDITING_ELEMENT_HANDLE, MAX_ELEMENT_TEXT } from "@hyperframes/core/runtime/editing-port"; // The frame's real runtime agent, serving the opaque frame from this document. -import { installEditingAgent } from "../../../../core/src/runtime/editingAgent"; +import { installMarkedEditingAgent } from "../../../../core/src/runtime/editingAgent.test-helpers"; import { findElementForSelection, findElementForTimelineElement, @@ -68,7 +68,7 @@ function opaqueFrame(): HTMLIFrameElement { new MessageEvent("message", { source: frame as unknown as Window, data, ports }), ), } as unknown as Window; - const agent = installEditingAgent(parent); + const agent = installMarkedEditingAgent(parent); frame.postMessage = (data: unknown) => window.dispatchEvent(new MessageEvent("message", { source: parent, data })); closers.push(() => agent.dispose()); diff --git a/packages/studio/src/components/editor/useColorGradingController.sealed.test.ts b/packages/studio/src/components/editor/useColorGradingController.sealed.test.ts index 6a0e251e36..2720057737 100644 --- a/packages/studio/src/components/editor/useColorGradingController.sealed.test.ts +++ b/packages/studio/src/components/editor/useColorGradingController.sealed.test.ts @@ -5,7 +5,7 @@ import { createRoot } from "react-dom/client"; import { afterEach, describe, expect, it, vi } from "vitest"; import { normalizeHfColorGrading } from "@hyperframes/core/color-grading"; // The frame's real runtime agent, serving the opaque frame from this document. -import { installEditingAgent } from "../../../../core/src/runtime/editingAgent"; +import { installMarkedEditingAgent } from "../../../../core/src/runtime/editingAgent.test-helpers"; import { installReactActEnvironment } from "../../hooks/domSelectionTestHarness"; import { detachedFakeIframe } from "../../player/hooks/timelinePlayerTestHarness"; import type { DomEditSelection } from "./domEditing"; @@ -36,7 +36,7 @@ function opaqueFrame(): HTMLIFrameElement { new MessageEvent("message", { source: frame as unknown as Window, data, ports }), ), } as unknown as Window; - const agent = installEditingAgent(parent); + const agent = installMarkedEditingAgent(parent); frame.postMessage = (data: unknown) => window.dispatchEvent(new MessageEvent("message", { source: parent, data })); closers.push(() => agent.dispose());