API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classBrowserPlatform

@codexo/exojs / core / stable

The PlatformAdapter backed by the browser: a canvas element for the drawing surface, `window` for keyboard and blur, `document` for visibility, `navigator` for gamepads, and `navigator.onLine` plus the `online`/`offline` window events for the network hint. Used automatically by Application when no adapter was injected. Every capability degrades rather than throws when the host does not provide it - pointer capture is rejected by jsdom and by browsers asked to release a pointer they never captured, `navigator.getGamepads` is missing on locked-down hosts, and `document` is absent under SSR. None of those are worth failing an application over, so each is caught and reported as "unavailable".

7
props
20
methods
0
events
Import
import { BrowserPlatform } from '@codexo/exojs'

The PlatformAdapter backed by the browser: a canvas element for the drawing surface, `window` for keyboard and blur, `document` for visibility, `navigator` for gamepads, and `navigator.onLine` plus the `online`/`offline` window events for the network hint. Used automatically by Application when no adapter was injected.

Every capability degrades rather than throws when the host does not provide it - pointer capture is rejected by jsdom and by browsers asked to release a pointer they never captured, `navigator.getGamepads` is missing on locked-down hosts, and `document` is absent under SSR. None of those are worth failing an application over, so each is caught and reported as "unavailable".

Constructors1
new(canvas: HTMLCanvasElement): BrowserPlatform
Methods20
cancelFrame(handle: number): void
Cancel a frame scheduled by FrameScheduler.requestFrame.
capturePointer(pointerId: number): void
Route all further events for pointerId to the surface. Best-effort.
Builds a text-input transport: EditContext where the host has it, a hidden <textarea> everywhere else. Created per call, so a text widget owns its transport's lifetime; callers that never ask for one never create the element.
destroy(): void
Release everything the adapter itself holds. Called by Application.destroy only for an adapter the application created; an injected adapter stays the caller's to dispose.
focusSurface(): void
Give the drawing surface host focus, so it starts receiving keyboard input.
Current position, display size and backing-store resolution of the drawing surface. Read per pointer event, so implementations should keep it cheap.
lockPointer(): void
Ask the host for a pointer lock on the surface. Best-effort and asynchronous: hosts grant it only from a user gesture, may deny it outright, and never report the outcome here - PlatformAdapter.onPointerLockChange does.
now(): number
Milliseconds elapsed since this source's own origin.
Watches the ratio through a (resolution: Ndppx) media query rather than a resize listener: a ratio change caused by dragging the window to another display, or by an OS scaling change, raises no resize event at all.
Subscribe to PlatformAdapter.pointerLocked changes. Also the only report of a lock the user ended themselves, which every host allows.
Subscribe to PlatformAdapter.documentVisible changes.
releasePointer(pointerId: number): void
Undo PlatformAdapter.capturePointer. Best-effort.
requestFrame(callback: (timestamp: number) => void): number
Schedule callback for the next display frame and return a handle for FrameScheduler.cancelFrame. One-shot - a frame loop reschedules itself every frame. timestamp is the host's frame time. It is the time the frame was *scheduled for*, not the time the callback happened to run, so deltas derived from it are free of the jitter that reading a clock at the top of the callback introduces.
setCursor(value: string): void
Set the cursor shown over the surface. Empty string restores the default.
setTouchAction(value: string): void
Set the surface's touch-action policy - 'none' keeps native pan/zoom out of the way.
unlockPointer(): void
Release a pointer lock this surface holds. No-op while it holds none.
Properties7
devicePixelRatio: number
Device pixels the host currently packs into one CSS pixel. 1 where the host reports nothing. A property of the display the surface is shown on, not of the surface: it changes when the window moves to a different monitor or the page is zoomed, which is what PlatformAdapter.onPixelRatioChange reports.
documentVisible: boolean
Whether the document showing the surface is currently visible to the user.
What the host reports about network reachability. A hint, and nothing more: a host saying 'online' has a network interface, not a route to any particular origin. 'unknown' is what a host that reports nothing means, and is deliberately not folded into 'online'.
pointerLocked: boolean
Whether the host currently routes pointer input to the surface exclusively - no cursor, no position, motion reported as relative deltas only.
surface: HTMLCanvasElement
The canvas this adapter drives.
surfaceFocused: boolean
Whether the drawing surface currently holds host focus.
textInputFocused: boolean
Whether a text transport this adapter created currently holds host keyboard focus - a focused text field, whose transport necessarily takes focus away from the drawing surface. Host focus on anything else, including a foreign element of the embedding page, is not this. The input pipeline reads it to tell "focus moved inside the application" from "focus left it", so an adapter that reports it too liberally makes the application swallow keys meant for the page. Optional: an adapter without a text transport never lends focus away and can leave it undefined.
Source