Skip to main content

Module sdk_event_model

Module sdk_event_model 

Source
Expand description

Typed host-event and error model for the FrankenTermJS SDK, with a TypeScript-definition generator kept in lockstep (bd-2vr05.9.2).

§Why this exists

The FrankenTermJS browser SDK promises host integrators a stable, typed event and error surface (see [docs/spec/frankenterm-web-api.md] — the canonical contract). xterm.js integrators reach for term.onData, term.onKey, typed event payloads, and predictable error shapes; the FrankenTermJS replacement must offer the same with a single, versioned taxonomy.

The original apiContract() constants from bd-2vr05.9.1 shipped inside the frankenterm-web WASM-packaging crate, which is transient and not vendored in this checkout. This module is therefore the durable, in-tree source of truth for the event/error model: pure Rust enums that mirror the documented taxonomy, plus a deterministic typescript_definitions generator so the runtime payloads and the shipped .d.ts can never drift.

 HostEventClass / SdkErrorKind (Rust, single source of truth)
       │
       ├── as_str()/code()  ──> runtime JSONL payloads (host-observable)
       └── typescript_definitions() ──> sdk/frankenterm-js-events.d.ts (golden)

§Determinism

Everything here is pure: the taxonomy order, the generated .d.ts, and the buffer-policy snapshot are byte-for-byte reproducible for a fixed crate version. The conformance harness (crates/ftui-web/tests/frankenterm_js_sdk_contract_compat.rs) asserts the Rust model and the committed .d.ts stay in lockstep.

Structs§

EventBufferPolicy
Bounded host-drained queue policy (drop-oldest), mirroring the Bounded Buffering Contract in docs/spec/frankenterm-web-api.md.

Enums§

HostEventClass
Canonical, host-observable event classes (eventSchemaVersion = 1.0.0).
SdkErrorKind
Typed SDK error taxonomy.

Constants§

EVENT_SCHEMA_VERSION
Event-schema version of the host-observable taxonomy. Mirrors eventSchemaVersion in the web API contract.

Functions§

typescript_definitions
Generate the TypeScript definition file for the SDK event/error model.