The global the runtime installs before a widget loads. See The window.PERCH API for narrative usage.
Methods
// Data in
PERCH.onData(cb: (payload: any) => void): void
PERCH.ready(): void
// Signals out (post over the native bridge — not network)
PERCH.trigger(actionId: string, args?: object): void // debug builds only
PERCH.pulse(detail?: object): void // all builds
// Capabilities
PERCH.onPermission(cb: (status: Record<string, "granted" | "denied" | "notDetermined">) => void): void
PERCH.requestPermission(name: string): void
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) | Bird beat on the Mac (+ notification if granted). Always available. |
requestPermission(name) | e.g. "notifications"; result delivered via onPermission. |
Reserved internals — do not use
__cb · __last · __deliver(payload) · __perm · __permCb ·
__deliverPermission(p)
These are how the native side delivers data and permissions. A widget should only ever call the six public methods above.