Interactive ABI

This ABI is for stateful, event-driven modules that render an output frame. We prefer a small host/module contract over protocol complexity: send key and pointer events directly, advance state with tick, then pull pixels with render_output.

The design goal is practical interoperability: browser and native hosts can adapt input to this ABI, and modules stay tiny.

Core Contract

Required exports:

Output Format

Little-endian note:

Event Semantics

key_event(...):

pointer_event(...):

Tick + Render Flow

We intentionally split simulation from rendering.

tick(now_ms) return value:

This dirty bit pattern is common in interactive systems and helps avoid unnecessary redraw work.

Time source requirements:

Sizing Variants

Use the same core ABI for both variants.

Static Size Variant

Module decides size at instantiation and keeps it fixed.

Additional required exports:

Rules:

Dynamic Size Variant

Host/user can request size changes within declared limits.

Additional required exports:

Rules:

Host Loop Pattern

Typical host flow:

  1. Deliver input as it arrives via key_event(...) / pointer_event(...).
  2. On frame callback (for example requestAnimationFrame), call tick(now_ms).
  3. If tick returns 1, call render_output() and read output_ptr() bytes.

This gives low-latency input handling while keeping frame scheduling host-driven.

Why This Shape

Claim: this ABI is a better default than embedding a full protocol stream.

Reason:

Tradeoff: