import type { CSSProperties, ReactElement } from 'react' /** * ViewStage (API §10) — the fixed-positioning layer that physically owns every * iframe for the `ViewHost`/`AppHost`s in the tree. Mount it ONCE near the root. * Reordering / re-parenting / re-keying hosts never reloads a healthy iframe: * each iframe lives in a stage slot (imperative DOM), insulated from React * reconciliation of the hosts; only the slot's box is repositioned. */ import { useEffect, useMemo, useRef } from 'react' import { useShell } from '../session/shell.hook.js' import { getStageHub } from './hub.js' import { createStageController } from './placement.js' /** * A full-viewport overlay that does not intercept pointer events — individual * slots re-enable them, so only the iframes are interactive, not the gaps. */ const STAGE_STYLE: CSSProperties = { position: 'fixed', top: 0, left: 0, right: 0, bottom: 0, zIndex: 20, pointerEvents: 'none', } export function ViewStage(): ReactElement { const shell = useShell() const hub = useMemo(() => getStageHub(shell), [shell]) const containerRef = useRef(null) useEffect(() => { const container = containerRef.current if (container === null) return const controller = createStageController(container) hub.setController(controller) return () => { hub.setController(null) controller.dispose() } }, [hub]) return
}