4.9 KiB
@suaveplan/controller - Universal input controller foundation — unified 32-field ControllerInput shape, BaseController abstract base with Clock-injected pollRate gating and threshold/deadzone normalisation, typed InputEventEmitter, stable CONTROLLER.* error code registry, and OpenTelemetry instrumentation. Chunk A of the @suaveplan/controller migration; device adapters and merger ship in follow-up chunks.
Universal input controller foundation. Ships the unified
ControllerInput shape (37 normalised fields in [0, 255]),
BaseController abstract base with injectable Clock/IdGenerator,
pollRate gating and per-input threshold/deadzone normalisation, the
typed InputEventEmitter, the stable CONTROLLER.* error-code
registry, and the package's OpenTelemetry instruments.
Device adapters (KeyboardController, GamepadController,
TouchController, MouseController) and ControllerMerger ship in
Chunks B and C.
Documentation tree
- base — Abstract base for every device-specific controller adapter shipped by this package. Owns the 37-field
ControllerInput…- base — Abstract base for every device-specific controller adapter shipped by this package. Owns the 37-field
ControllerInput…
- base — Abstract base for every device-specific controller adapter shipped by this package. Owns the 37-field
- error-codes — Defines the stable
CONTROLLER.*error-code registry and the typedControllerErrorclass used by every public surfac…- error-codes — Defines the stable
CONTROLLER.*error-code registry and the typedControllerErrorclass used by every public surfac…
- error-codes — Defines the stable
- events — Typed event dispatcher used by
BaseControllerto fan input, state and combo events out to listeners. Centralising the…- events — Typed event dispatcher used by
BaseControllerto fan input, state and combo events out to listeners. Centralising the…
- events — Typed event dispatcher used by
- gamepad — Browser-tier device adapter that polls the Web Gamepad API and normalises button + axis state into the canonical 37-fie…
- gamepad.internal — Module-private helpers used by
GamepadControllerto keep the main class file under the repository's 300-line hard cap… - gamepad — Browser-tier device adapter that polls the Web Gamepad API and normalises button + axis state into the canonical 37-fie…
- gamepad.internal — Module-private helpers used by
- keyboard — Browser-tier device adapter that normalises DOM
keydown/keyupevents into the canonical 37-fieldControllerInput…- keyboard — Browser-tier device adapter that normalises DOM
keydown/keyupevents into the canonical 37-fieldControllerInput…
- keyboard — Browser-tier device adapter that normalises DOM
- merger —
ControllerMergerfuses an ordered list ofBaseControllerchildren into a single virtual controller whose `Controlle…- merger —
ControllerMergerfuses an ordered list ofBaseControllerchildren into a single virtual controller whose `Controlle…
- merger —
- telemetry — Owns the OpenTelemetry instruments emitted by
@suaveplan/controller: two counters tracking input and state-change thr…- telemetry — Owns the OpenTelemetry instruments emitted by
@suaveplan/controller: two counters tracking input and state-change thr…
- telemetry — Owns the OpenTelemetry instruments emitted by
- types — Provides the canonical iteration order over the 37
ControllerInputkeys and acreateDefaultControllerInput()factor…- keys — Provides the canonical iteration order over the 37
ControllerInputkeys and acreateDefaultControllerInput()factor…
- keys — Provides the canonical iteration order over the 37
Modules
base/base.md—BaseControllerlifecycle, state, normalisation, pollRate gating.events/events.md—InputEventEmittertyped dispatcher with disposable listeners.error-codes.md—CONTROLLER_CODESregistry andControllerErrorclass.telemetry.md—controller_inputs_total,controller_state_changes_totalcounters and the pattern-match duration histogram.types/keys.md—CONTROLLER_INPUT_KEYSandcreateDefaultControllerInput.
Status
0.1.0 — Chunk A foundation. Chunks B (device adapters) and C
(merger) extend the barrel with additional named exports.
Verification
bunx turbo lint typecheck test --filter=@suaveplan/controller
bunx turbo test:coverage --filter=@suaveplan/controller
The coverage gate is 100/100/100/100 (istanbul). The package's
tests/setup/polyfills.ts registers an in-memory MeterProvider before
source modules import the OTel meter so the telemetry assertions resolve
against a real exporter, with no mocks.