feat(01-15): singleton PiP session with body-level custodial host
Demo images / Build & push demo images (push) Successful in 3m44s
Demo images / Build & push demo images (push) Successful in 3m44s
usePipSession() owns an off-screen div under document.body; adopt(video) moves the element there so it survives the unmount of whatever view rendered it (a Teleport and a KeepAlive'd view both move their subtree on deactivation, which the picture-in-picture spec treats as removal). release() tears down playback and detaches the element; a leavepictureinpicture listener on the adopted element is the primary release path so an orphaned owner can never leak it. Also adds isPipSupported() to pip.ts — a call-time version of the existing import-time pipSupported const, needed because a test can't restub document.pictureInPictureEnabled after import. togglePip and pipSupported are unchanged. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
ceafbcb596
commit
3288a02df8
@@ -8,6 +8,17 @@ export const pipSupported =
|
||||
'pictureInPictureEnabled' in document &&
|
||||
document.pictureInPictureEnabled
|
||||
|
||||
/** Same three checks as `pipSupported`, but evaluated at call time rather
|
||||
* than import time — lets a test stub support before or after this module
|
||||
* is imported, and lets a component re-check support on demand. */
|
||||
export function isPipSupported(): boolean {
|
||||
return (
|
||||
typeof document !== 'undefined' &&
|
||||
'pictureInPictureEnabled' in document &&
|
||||
document.pictureInPictureEnabled
|
||||
)
|
||||
}
|
||||
|
||||
export async function togglePip(video: HTMLVideoElement | null | undefined): Promise<void> {
|
||||
if (!video || !pipSupported) return
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user