The global the runtime installs before a widget loads. See The window.PREEN API for narrative usage.
Methods
// Data in
PREEN.onData(cb: (payload: any) => void): void
PREEN.ready(): void
// Signals out (post over the native bridge — not network)
PREEN.trigger(actionId: string, args?: object): void // debug builds only
PREEN.pulse(detail?: object): void // all builds
// Per-widget datastore (durable SQLite on the Mac) — all return Promises
type Record = { id: number; ts: number; body: any }
PREEN.db.put(collection: string, body: object): Promise<{ id: number; ts: number }>
PREEN.db.get(collection: string, query?: { limit?: number; since?: number; order?: "asc" | "desc" }): Promise<Record[]>
PREEN.db.update(collection: string, id: number, body: object): Promise<{ id: number; ts: number }>
PREEN.db.delete(collection: string, id: number): Promise<{ deleted: number }>
PREEN.db.clear(collection: string): Promise<{ deleted: number }>
Behavior notes
| Method | Notes |
|---|---|
onData(cb) | cb fires once per update with the full payload; replays the last payload if registered after data already arrived. |
ready() | Idempotent; also called automatically after each onData delivery. |
trigger(id, args) | Fires only actions registered against this widget’s id. No-op in release builds. |
pulse(detail) | Chirps this phone’s bird on the Mac (one bird per paired device). Always available. |
db.* | This widget’s own datastore. Async; scoped to this widget. Works in all builds. Collection names: [A-Za-z0-9_-], ≤64; get limit default 100 / max 1000; 5,000 rows per collection. |
Reserved internals — do not use
__cb · __last · __deliver(payload) · __dbReq · __dbPending · __dbResolve(reqId, ok, payload)
These are how the native side delivers data. A widget should only ever call the four public methods above.