API reference

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

I

interfacePlatformAdapter

@codexo/exojs / core / stable

Everything the engine touches outside its own state: the drawing surface's focus, cursor, touch-action and geometry, pointer capture, gamepad polling, document visibility, frame scheduling, and the delivery of input events. One adapter serves the whole Application - `app.platform` - and both the InputSystem and the InteractionSystem read it from there, so there is exactly one seam between the engine and its host. BrowserPlatform is the default; pass your own through ApplicationOptions.platform to run the engine somewhere else, or to drive it from a test without monkey-patching globals. Deliberately not a platform kernel: there is nothing here for fetch, storage, audio, workers or display configuration. This adapter covers the mechanics the input and frame pipeline actually needs today, and grows only when a subsystem genuinely needs a seam. The adapter supplies mechanism, never policy. It reports that a pointer moved and captures it on request; whether that movement is a drag, a tap or an action is decided entirely by the input system above it.

6
props
20
methods
0
events
Import
import { PlatformAdapter } from '@codexo/exojs'

Everything the engine touches outside its own state: the drawing surface's focus, cursor, touch-action and geometry, pointer capture, gamepad polling, document visibility, frame scheduling, and the delivery of input events.

One adapter serves the whole Application - `app.platform` - and both the InputSystem and the InteractionSystem read it from there, so there is exactly one seam between the engine and its host. BrowserPlatform is the default; pass your own through ApplicationOptions.platform to run the engine somewhere else, or to drive it from a test without monkey-patching globals.

Deliberately not a platform kernel: there is nothing here for fetch, storage, audio, workers or display configuration. This adapter covers the mechanics the input and frame pipeline actually needs today, and grows only when a subsystem genuinely needs a seam.

The adapter supplies mechanism, never policy. It reports that a pointer moved and captures it on request; whether that movement is a drag, a tap or an action is decided entirely by the input system above it.

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.
A transport for text editing - keyboard and IME input routed as edit intents (insert, deleteContent, undo/redo) - or null where the host has no way to receive text. null is a supported outcome, not an error: a text widget renders and takes focus, but rejects edits.
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.
Subscribe to PlatformAdapter.devicePixelRatio changes. Optional: a host that cannot observe the ratio omits it, and everything derived from the ratio then keeps the value it was first resolved at.
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.
Properties6
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.
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