getViewportSize
Overview
Lynx has no window.innerWidth; the background thread exposes physical pixels via SystemInfo.pixelWidth / pixelHeight plus pixelRatio. getViewportSize does the division:
import { getViewportSize } from '@vyui/core'
const size = getViewportSize() // { width: 390, height: 844 } — or null
Returns null off-Lynx (web / vitest) or before SystemInfo resolves, so callers pick their own fallback:
const height = getViewportSize()?.height ?? 800
This is what VySheet and VyScrollView use internally for their viewport estimates.
Not reactive
SystemInfo is a static snapshot — it doesn't update on rotation or split screen. Re-read it when layout actually changes: VyApp emits viewport-change from the root layoutchange event for exactly this.
Main-thread worklets can't call this (cross-file worklet calls don't resolve on Lynx); read SystemInfo inline in the worklet instead.
Signature
getViewportSize(): ViewportSize | null — { width: number, height: number } in logical px.