@hyperframes/studio 0.8.199 → 0.8.200
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-BDtBfwof.js → hyperframes-player-LmRUJE8q.js} +1 -1
- package/dist/assets/{index-BFfBBQMu.js → index-BmTWk8xf.js} +108 -108
- package/dist/assets/{index--W_0fuR8.js → index-CKNiEwbW.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/index.js +25 -3
- package/package.json +8 -8
- package/src/hooks/useDomSelection.ts +5 -1
- package/src/player/hooks/timelineSyncHydration.test.ts +20 -0
- package/src/player/hooks/timelineSyncHydration.ts +13 -2
- package/src/utils/sceneHold.test.ts +29 -0
- package/src/utils/sceneHold.ts +21 -0
package/dist/index.html
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
document.documentElement.dataset.theme = "paper";
|
|
15
15
|
}
|
|
16
16
|
</script>
|
|
17
|
-
<script type="module" crossorigin src="/assets/index-
|
|
17
|
+
<script type="module" crossorigin src="/assets/index-BmTWk8xf.js"></script>
|
|
18
18
|
<link rel="stylesheet" crossorigin href="/assets/index-CYbvOVp-.css">
|
|
19
19
|
</head>
|
|
20
20
|
<body>
|
package/dist/index.js
CHANGED
|
@@ -30007,12 +30007,17 @@ function collectHostDomChildren(hostId, parentEl, parentId, parentMap, out) {
|
|
|
30007
30007
|
if (isGroup) collectHostDomChildren(hostId, child, child.id, parentMap, out);
|
|
30008
30008
|
}
|
|
30009
30009
|
}
|
|
30010
|
+
function clipHostOf(iframeDoc, clip) {
|
|
30011
|
+
const host = findClipElementById(iframeDoc, clip);
|
|
30012
|
+
const view = iframeDoc.defaultView;
|
|
30013
|
+
return (host && view?.__hfParkedSceneMarkup?.(host)) ?? host;
|
|
30014
|
+
}
|
|
30010
30015
|
function collectSubCompositionDomChildren(iframeDoc, clips, parentMap) {
|
|
30011
30016
|
const out = [];
|
|
30012
30017
|
if (!iframeDoc) return out;
|
|
30013
30018
|
for (const clip of clips) {
|
|
30014
30019
|
if (clip.kind !== "composition" || !clip.id) continue;
|
|
30015
|
-
const hostEl =
|
|
30020
|
+
const hostEl = clipHostOf(iframeDoc, clip);
|
|
30016
30021
|
if (!hostEl) continue;
|
|
30017
30022
|
const innerRoot = hostEl.querySelector("[data-hf-inner-root]") ?? hostEl;
|
|
30018
30023
|
collectHostDomChildren(clip.id, innerRoot, clip.id, parentMap, out);
|
|
@@ -30036,7 +30041,7 @@ function collectSubCompositionHostState(iframeDoc, clips) {
|
|
|
30036
30041
|
if (!iframeDoc) return out;
|
|
30037
30042
|
for (const clip of clips) {
|
|
30038
30043
|
if (clip.kind !== "composition" || !clip.id) continue;
|
|
30039
|
-
const hostEl =
|
|
30044
|
+
const hostEl = clipHostOf(iframeDoc, clip);
|
|
30040
30045
|
if (!hostEl) continue;
|
|
30041
30046
|
for (const el of Array.from(hostEl.querySelectorAll("[id]"))) {
|
|
30042
30047
|
const state = readSubCompositionHostState(el);
|
|
@@ -79623,6 +79628,20 @@ function seedDomEditGroupWithSelection(group, selection) {
|
|
|
79623
79628
|
return [selection, ...group];
|
|
79624
79629
|
}
|
|
79625
79630
|
|
|
79631
|
+
// src/utils/sceneHold.ts
|
|
79632
|
+
function holdScenesOf(iframe, element) {
|
|
79633
|
+
let hold;
|
|
79634
|
+
try {
|
|
79635
|
+
hold = iframe?.contentWindow?.__hfHoldScenes;
|
|
79636
|
+
} catch {
|
|
79637
|
+
return void 0;
|
|
79638
|
+
}
|
|
79639
|
+
if (!hold) return void 0;
|
|
79640
|
+
const names = element ? [...element.compositionAncestors ?? [], element.parentCompositionId ?? ""] : [];
|
|
79641
|
+
return hold(names.filter(Boolean)).catch(() => {
|
|
79642
|
+
});
|
|
79643
|
+
}
|
|
79644
|
+
|
|
79626
79645
|
// src/hooks/useStudioTestHooks.ts
|
|
79627
79646
|
import { useEffect as useEffect116 } from "react";
|
|
79628
79647
|
|
|
@@ -79995,6 +80014,8 @@ function useDomSelection({
|
|
|
79995
80014
|
return null;
|
|
79996
80015
|
}
|
|
79997
80016
|
if (!doc) return null;
|
|
80017
|
+
const held = holdScenesOf(iframe, element);
|
|
80018
|
+
if (held) await held;
|
|
79998
80019
|
reapplyPositionEditsAfterSeek(doc);
|
|
79999
80020
|
const targetElement = findElementForTimelineElement(doc, element, {
|
|
80000
80021
|
activeCompositionPath: activeCompPath,
|
|
@@ -80011,6 +80032,7 @@ function useDomSelection({
|
|
|
80011
80032
|
async (element) => {
|
|
80012
80033
|
const seq = ++timelineSelectSeqRef.current;
|
|
80013
80034
|
if (!element) {
|
|
80035
|
+
void holdScenesOf(previewIframeRef.current, null);
|
|
80014
80036
|
applyDomSelection(null, { revealPanel: false });
|
|
80015
80037
|
return;
|
|
80016
80038
|
}
|
|
@@ -80022,7 +80044,7 @@ function useDomSelection({
|
|
|
80022
80044
|
}
|
|
80023
80045
|
applyDomSelection(null, { revealPanel: false, announce: false });
|
|
80024
80046
|
},
|
|
80025
|
-
[applyDomSelection, buildDomSelectionForTimelineElement]
|
|
80047
|
+
[applyDomSelection, buildDomSelectionForTimelineElement, previewIframeRef]
|
|
80026
80048
|
);
|
|
80027
80049
|
const refreshDomEditGroupSelectionsFromPreviewRef = useRef143(async () => {
|
|
80028
80050
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/studio",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.200",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -60,12 +60,12 @@
|
|
|
60
60
|
"dockview-react": "8.3.1",
|
|
61
61
|
"gsap": "^3.13.0",
|
|
62
62
|
"mediabunny": "^1.45.3",
|
|
63
|
-
"@hyperframes/
|
|
64
|
-
"@hyperframes/
|
|
65
|
-
"@hyperframes/sdk": "0.8.
|
|
66
|
-
"@hyperframes/
|
|
67
|
-
"@hyperframes/shader-transitions": "0.8.
|
|
68
|
-
"@hyperframes/
|
|
63
|
+
"@hyperframes/player": "0.8.200",
|
|
64
|
+
"@hyperframes/core": "0.8.200",
|
|
65
|
+
"@hyperframes/sdk": "0.8.200",
|
|
66
|
+
"@hyperframes/studio-server": "0.8.200",
|
|
67
|
+
"@hyperframes/shader-transitions": "0.8.200",
|
|
68
|
+
"@hyperframes/parsers": "0.8.200"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"vite": "^6.4.2",
|
|
83
83
|
"vitest": "^4.1.11",
|
|
84
84
|
"zustand": "^5.0.0",
|
|
85
|
-
"@hyperframes/producer": "0.8.
|
|
85
|
+
"@hyperframes/producer": "0.8.200"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"react": "19",
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
type DomEditSelection,
|
|
20
20
|
} from "../components/editor/domEditing";
|
|
21
21
|
import { reapplyPositionEditsAfterSeek } from "../components/editor/manualEdits";
|
|
22
|
+
import { holdScenesOf } from "../utils/sceneHold";
|
|
22
23
|
import { useStudioTestHooks } from "./useStudioTestHooks";
|
|
23
24
|
import { logSelect } from "../utils/selectDebug";
|
|
24
25
|
import { announceTimelineSelection as announceSelectionToTimeline } from "./domSelectionTimelineMirror";
|
|
@@ -308,6 +309,8 @@ export function useDomSelection({
|
|
|
308
309
|
}
|
|
309
310
|
if (!doc) return null;
|
|
310
311
|
|
|
312
|
+
const held = holdScenesOf(iframe, element);
|
|
313
|
+
if (held) await held;
|
|
311
314
|
reapplyPositionEditsAfterSeek(doc);
|
|
312
315
|
|
|
313
316
|
const targetElement = findElementForTimelineElement(doc, element, {
|
|
@@ -328,6 +331,7 @@ export function useDomSelection({
|
|
|
328
331
|
async (element: TimelineElement | null) => {
|
|
329
332
|
const seq = ++timelineSelectSeqRef.current;
|
|
330
333
|
if (!element) {
|
|
334
|
+
void holdScenesOf(previewIframeRef.current, null);
|
|
331
335
|
applyDomSelection(null, { revealPanel: false });
|
|
332
336
|
return;
|
|
333
337
|
}
|
|
@@ -344,7 +348,7 @@ export function useDomSelection({
|
|
|
344
348
|
// and Delete acts on the canvas first — so it removed that, not the clip.
|
|
345
349
|
applyDomSelection(null, { revealPanel: false, announce: false });
|
|
346
350
|
},
|
|
347
|
-
[applyDomSelection, buildDomSelectionForTimelineElement],
|
|
351
|
+
[applyDomSelection, buildDomSelectionForTimelineElement, previewIframeRef],
|
|
348
352
|
);
|
|
349
353
|
|
|
350
354
|
// Forward handle to the group refresher defined below: the single-selection
|
|
@@ -107,6 +107,26 @@ describe("collectSubCompositionHostState", () => {
|
|
|
107
107
|
expect(rows.map((child) => child.id)).toEqual(["scene-2-title"]);
|
|
108
108
|
});
|
|
109
109
|
|
|
110
|
+
it("reads a scene the preview unmounted from the markup it mounts with", () => {
|
|
111
|
+
const markup = mountScene().getElementById("scene-2-slot")!.cloneNode(true) as Element;
|
|
112
|
+
document.body.innerHTML = `<div id="scene-2-slot" data-composition-id="scene-2" data-hf-parked-scene></div>`;
|
|
113
|
+
const view = window as Window & { __hfParkedSceneMarkup?: (el: Element) => Element | null };
|
|
114
|
+
view.__hfParkedSceneMarkup = (el) => (el.hasAttribute("data-hf-parked-scene") ? markup : null);
|
|
115
|
+
try {
|
|
116
|
+
const rows = collectSubCompositionDomChildren(document, sceneClips, new Map());
|
|
117
|
+
expect(rows.map((child) => child.id)).toEqual([
|
|
118
|
+
"scene-2-video-region",
|
|
119
|
+
"scene-2-title",
|
|
120
|
+
"scene-2-caption",
|
|
121
|
+
]);
|
|
122
|
+
expect(collectSubCompositionHostState(document, sceneClips).get("scene-2-video")).toEqual({
|
|
123
|
+
hidden: true,
|
|
124
|
+
});
|
|
125
|
+
} finally {
|
|
126
|
+
delete view.__hfParkedSceneMarkup;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
110
130
|
it("returns empty without a document, rather than throwing", () => {
|
|
111
131
|
expect(collectSubCompositionHostState(null, sceneClips).size).toBe(0);
|
|
112
132
|
});
|
|
@@ -112,6 +112,17 @@ function collectHostDomChildren(
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
type SceneMarkupWindow = Window & {
|
|
116
|
+
__hfParkedSceneMarkup?: (placeholder: Element) => Element | null;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/** A clip's host; for a scene the preview unmounted, the markup it mounts with. */
|
|
120
|
+
function clipHostOf(iframeDoc: Document, clip: ClipManifestClip): Element | null {
|
|
121
|
+
const host = findClipElementById(iframeDoc, clip);
|
|
122
|
+
const view = iframeDoc.defaultView as SceneMarkupWindow | null;
|
|
123
|
+
return (host && view?.__hfParkedSceneMarkup?.(host)) ?? host;
|
|
124
|
+
}
|
|
125
|
+
|
|
115
126
|
/**
|
|
116
127
|
* Every sub-composition's internal elements, across the whole manifest.
|
|
117
128
|
*
|
|
@@ -129,7 +140,7 @@ export function collectSubCompositionDomChildren(
|
|
|
129
140
|
if (!iframeDoc) return out;
|
|
130
141
|
for (const clip of clips) {
|
|
131
142
|
if (clip.kind !== "composition" || !clip.id) continue;
|
|
132
|
-
const hostEl =
|
|
143
|
+
const hostEl = clipHostOf(iframeDoc, clip);
|
|
133
144
|
if (!hostEl) continue;
|
|
134
145
|
const innerRoot = hostEl.querySelector("[data-hf-inner-root]") ?? hostEl;
|
|
135
146
|
collectHostDomChildren(clip.id, innerRoot, clip.id, parentMap, out);
|
|
@@ -173,7 +184,7 @@ export function collectSubCompositionHostState(
|
|
|
173
184
|
if (!iframeDoc) return out;
|
|
174
185
|
for (const clip of clips) {
|
|
175
186
|
if (clip.kind !== "composition" || !clip.id) continue;
|
|
176
|
-
const hostEl =
|
|
187
|
+
const hostEl = clipHostOf(iframeDoc, clip);
|
|
177
188
|
if (!hostEl) continue;
|
|
178
189
|
for (const el of Array.from(hostEl.querySelectorAll("[id]"))) {
|
|
179
190
|
const state = readSubCompositionHostState(el);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import type { TimelineElement } from "../player";
|
|
3
|
+
import { holdScenesOf } from "./sceneHold";
|
|
4
|
+
|
|
5
|
+
const previewWith = (hold?: (names: string[]) => Promise<void>) =>
|
|
6
|
+
({ contentWindow: { __hfHoldScenes: hold } }) as unknown as HTMLIFrameElement;
|
|
7
|
+
|
|
8
|
+
describe("holdScenesOf", () => {
|
|
9
|
+
it("has the preview mount the scenes holding the element, and releases them for no element", async () => {
|
|
10
|
+
const hold = vi.fn(async () => {});
|
|
11
|
+
const element = {
|
|
12
|
+
id: "word",
|
|
13
|
+
tag: "span",
|
|
14
|
+
start: 700,
|
|
15
|
+
duration: 1,
|
|
16
|
+
track: 0,
|
|
17
|
+
compositionAncestors: ["main", "s23"],
|
|
18
|
+
parentCompositionId: "s23",
|
|
19
|
+
} as TimelineElement;
|
|
20
|
+
await holdScenesOf(previewWith(hold), element);
|
|
21
|
+
await holdScenesOf(previewWith(hold), null);
|
|
22
|
+
expect(hold.mock.calls).toEqual([[["main", "s23", "s23"]], [[]]]);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("gives nothing to wait for in a preview that mounts every scene", () => {
|
|
26
|
+
expect(holdScenesOf(previewWith(), null)).toBeUndefined();
|
|
27
|
+
expect(holdScenesOf(null, null)).toBeUndefined();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TimelineElement } from "../player";
|
|
2
|
+
|
|
3
|
+
type SceneHoldingWindow = Window & { __hfHoldScenes?: (names: string[]) => Promise<void> };
|
|
4
|
+
|
|
5
|
+
/** Mounts the scenes holding a timeline element; undefined, so no wait, where the preview mounts every scene. */
|
|
6
|
+
export function holdScenesOf(
|
|
7
|
+
iframe: HTMLIFrameElement | null,
|
|
8
|
+
element: TimelineElement | null,
|
|
9
|
+
): Promise<void> | undefined {
|
|
10
|
+
let hold: SceneHoldingWindow["__hfHoldScenes"];
|
|
11
|
+
try {
|
|
12
|
+
hold = (iframe?.contentWindow as SceneHoldingWindow | null)?.__hfHoldScenes;
|
|
13
|
+
} catch {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
if (!hold) return undefined;
|
|
17
|
+
const names = element
|
|
18
|
+
? [...(element.compositionAncestors ?? []), element.parentCompositionId ?? ""]
|
|
19
|
+
: [];
|
|
20
|
+
return hold(names.filter(Boolean)).catch(() => {});
|
|
21
|
+
}
|