Skip to content

The open-source full-stack studio for Opus 5.5 motion video. Reverse engineering for any video. Code video with HTML: recreate, edit and render. BYOA + BYOK · Motion.md · Images, Video, Music & Voice.

771 B
Raw Blame
import type { TimelineElement } from "../player";

type SceneHoldingWindow = Window & { __hfHoldScenes?: (names: string[]) => Promise<void> };

/** Mounts the scenes holding a timeline element; undefined, so no wait, where the preview mounts every scene. */
export function holdScenesOf(
  iframe: HTMLIFrameElement | null,
  element: TimelineElement | null,
): Promise<void> | undefined {
  let hold: SceneHoldingWindow["__hfHoldScenes"];
  try {
    hold = (iframe?.contentWindow as SceneHoldingWindow | null)?.__hfHoldScenes;
  } catch {
    return undefined;
  }
  if (!hold) return undefined;
  const names = element
    ? [...(element.compositionAncestors ?? []), element.parentCompositionId ?? ""]
    : [];
  return hold(names.filter(Boolean)).catch(() => {});
}