# SDK API summary

Checked 2026-11-17 against SDK `@evenrealities/even_hub_sdk` 0.0.16 (npm, minAppVersion 2.2.10) and the official docs. Re-check the installed `*.d.ts` before relying on any signature. Paraphrased summary; read the linked page for the full rules.

## Bridge and pages ([Page Lifecycle](https://hub.evenrealities.com/docs/build/page-lifecycle))

| Call | Use | Returns |
| --- | --- | --- |
| `waitForEvenAppBridge()` | Await first; everything else depends on it | bridge |
| `createStartUpPageContainer` | First page, once | int: 0 ok, 1 invalid params, 2 oversize, 3 out of memory |
| `rebuildPageContainer` | Replace the whole page (state lost, brief flicker) | boolean |
| `textContainerUpgrade` | Flicker-free text update; `containerID` and `containerName` must match or it silently no-ops | boolean |
| `updateImageRawData` | Push pixels to an image container; never send concurrently | status string |
| `shutDownPageContainer(mode)` | `1` = system exit dialog (root page), `0` = immediate (inner pages only) | boolean |

## Containers ([Display & UI System](https://hub.evenrealities.com/docs/build/display))

- Canvas 576x288, origin top-left. Max 4 image + 8 other containers per page. Exactly one `isEventCapture: 1`.
- `containerName` max 16 characters, unique per page; `containerID` unique per page.
- `zOrderIndex` (SDK 0.0.12+): all-or-nothing per page, unique values, larger draws in front.
- Text: plain, top-left aligned. Content limits differ per call (1,000 for create/rebuild, 2,000 for upgrade). Other official sources state these limits in bytes (999 / 1,999); budget in UTF-8 bytes to be safe (Korean is 3 bytes per syllable). Overflow scrolls only on the capturing container. `textColor` 0-4 (SDK 0.0.14+) is brightness, separate from `borderColor` 0-15.
- List: up to 20 items, 64 characters each (63 bytes in some official sources), no in-place update (rebuild the page).
- Image: up to 288x144 per container, greyscale; create an empty container first, then call `updateImageRawData`. Sends are paced (SDK 0.0.14+).
- Single firmware font, not monospaced, no size control; glyphs outside the set are dropped.

## Events ([Device APIs](https://hub.evenrealities.com/docs/build/device-apis))

- One subscription: `bridge.onEvenHubEvent(event => ...)`.
- Capturing text container -> `event.textEvent`; capturing list -> `event.listEvent`.
- `OsEventTypeList`: `CLICK_EVENT` (0), `SCROLL_TOP_EVENT` (1), `SCROLL_BOTTOM_EVENT` (2), `DOUBLE_CLICK_EVENT` (3), `LONG_PRESS_EVENT` (9), `LONG_PRESS_RELEASE_EVENT` (10), plus `IMU_DATA_REPORT`.
- Click may arrive with the `eventType` key missing, and taps may arrive on `sysEvent` instead of `textEvent`; normalise all envelopes (see `knowhow.md`).
- Long press pair (SDK 0.0.14+, Even App 2.2.9+) always arrives on `event.sysEvent`. SDK 0.0.15+ keeps `eventSource` on it according to the SDK README; handle both cases. The OS can claim tap-then-hold for its contextual menu, so do not make long press the only path to a feature.
- Contextual menu (SDK 0.0.14+): pass `menuObject` with up to 10 items (`itemName` max 32 UTF-8 bytes, `itemID` non-zero) on create/rebuild; selections arrive as `event.menuItemClickEvent.itemID`. A rebuild without `menuObject` clears your items ([Contextual Menu](https://hub.evenrealities.com/docs/build/contextual-menu)).

## Device features ([Device APIs](https://hub.evenrealities.com/docs/build/device-apis))

| Feature | Calls | Permission in app.json |
| --- | --- | --- |
| Audio | `audioControl(true, AudioInputSource.Glasses or .Phone)`, `audioControl(false)`; data on `event.audioEvent.audioPcm` (16 kHz, s16le, mono) | `g2-microphone` / `phone-microphone` |
| Location | `getAppLocation`, `startAppLocationUpdates` + `onAppLocationChanged`, `stopAppLocationUpdates`; null-check results | `location` |
| Photos | `pickImageFromAlbum`, `captureImageFromCamera` (phone hardware, returns base64 or null) | `album` / `camera` |
| IMU | `imuControl(true, ImuReportPace.P100..P1000)`; samples on `event.sysEvent.imuData` | none listed |
| Device / user | `getDeviceInfo`, `onDeviceStatusChanged`, `getUserInfo` | none listed |
| Storage | `setLocalStorage`, `getLocalStorage` (strings only, no delete); prefer over browser `localStorage`, see `knowhow.md` | none listed |

Glasses microphone capture needs the startup page created first. Downscale photos before sending them to an image container.

Use these bridge calls instead of `getUserMedia` and `navigator.geolocation`, which are blocked in the plugin WebView (community reports).

Not available: Bluetooth access, arbitrary pixel drawing, audio output, text alignment, fonts, background colours, animations, glasses camera.

## Minimal shape (own example, verify names against your SDK)

```ts
import { waitForEvenAppBridge, OsEventTypeList } from '@evenrealities/even_hub_sdk'

const bridge = await waitForEvenAppBridge()
// create one full-screen text container with isEventCapture: 1, then:
bridge.onEvenHubEvent((event) => {
  const type = event.textEvent?.eventType
  if (type === OsEventTypeList.DOUBLE_CLICK_EVENT) bridge.shutDownPageContainer(1)
})
```

The official step-by-step version is in [Your First App](https://hub.evenrealities.com/docs/get-started/quickstart/first-app).
