import type { MediaPosition } from './specs/types.nitro'; /** * Zeroed media position — the default before any playback, and the sentinel * value the scoped position hooks return when their item is not the engine's * active content. Hooks compare against this by reference identity, so it must * stay a single shared instance. */ export const IDLE_POSITION: MediaPosition = { currentMs: 0, durationMs: 0, seekableStartMs: 0, seekableEndMs: 0, isLive: false, progress: 0, liveEdgeOffsetMs: 0, isAtLiveEdge: false, }; /** * Whether two media positions are equal on the fields the position hooks * render from. `MediaPosition` arrives from native as a fresh object every * tick, so this drives the "reuse previous snapshot" fast path that keeps * `useSyncExternalStore` from re-rendering on identical positions. */ export function samePosition(a: MediaPosition, b: MediaPosition): boolean { return ( a.currentMs === b.currentMs && a.durationMs === b.durationMs && a.seekableStartMs === b.seekableStartMs && a.seekableEndMs === b.seekableEndMs && a.isLive === b.isLive && a.isAtLiveEdge === b.isAtLiveEdge ); }