Skip to content

Conversation

@dirkwa
Copy link
Contributor

@dirkwa dirkwa commented Jan 26, 2026

Description:

Completes the serverEvents capability for WASM plugins, enabling them to receive both
server events and NMEA data stream events, and emit events back to the Signal K pipeline.

Changes

Generic event mechanism:

  • Add nmea0183, nmea0183out, nmea2000JsonOut, nmea2000out, nmea2000OutAvailable,
    canboatjs:* to allowed event types
  • Subscribe plugins to generic events via app.on() in lifecycle
  • Allow sk_emit_event to emit standard event names (no PLUGIN_ prefix for generic events)
  • Fix serverEvents capability not being loaded from package.json

TypeScript strict mode:

  • Enable noUnusedLocals, noUnusedParameters, noImplicitReturns, etc.
  • No eslint-disable workarounds, no _prefix hiding

Documentation:

  • Add serverEvents section to capabilities.md with event types table and usage examples

Testing

  • 382 tests pass
  • Example plugin demonstrates nmea0183 → nmea2000JsonOut conversion (RMC/GGA → PGN
    129025/129026)
  • Verified event delivery with sample NMEA data

  Remove eslint-disable directives for no-explicit-any and replace generic
  any types with proper TypeScript interfaces throughout the WASM subsystem.

  Changes:
  - Add SignalKApp interface for type-safe app object access
  - Add WasmRawExports interface for WASM module exports
  - Add WasmDelta, WasmCapabilities, and related interfaces
  - Replace any with Record<string, unknown> for dynamic objects
  - Replace any with unknown for truly unknown values
  - Remove unused variables and imports
  - Add proper type imports across binding files
@dirkwa dirkwa force-pushed the feature/wasm-strict-and-events branch 2 times, most recently from 408bf0e to 3692ed5 Compare January 26, 2026 20:04
Enable WASM plugins to subscribe to server events and emit custom
plugin events via FFI bindings:
- sk_subscribe_events: subscribe to specific event types
- sk_emit_event: emit PLUGIN_* prefixed events
- sk_get_allowed_event_types: query available event types

Add WasmEventManager for subscription filtering, buffering during
plugin startup, and event routing.

Add example-event-handler-rust demonstrating server statistics
monitoring with HIGH_DELTA_RATE alert emission.
@dirkwa dirkwa force-pushed the feature/wasm-strict-and-events branch from 3692ed5 to 933cf5a Compare January 26, 2026 20:33
@tkurki
Copy link
Member

tkurki commented Jan 27, 2026

I am afraid this is still addressing just serverevents and not the generic event mechanism documented a bit at https://github.com/SignalK/signalk-server/wiki/Events-and-Outputting-Data. See also 6768da9.

A good idea for demo wasm plugin event handling would be something that listens for for example nmea0183 data and emits nmea2000

  Enable WASM plugins to subscribe to and emit NMEA data stream events
  (nmea0183, nmea2000JsonOut, etc.) in addition to server events.

  - Add nmea0183, nmea0183out, nmea2000JsonOut, nmea2000out,
    nmea2000OutAvailable, and canboatjs:* to allowed event types
  - Subscribe plugins to generic events via app.on() lifecycle
  - Allow sk_emit_event to emit standard event names without PLUGIN_ prefix
  - Fix missing serverEvents capability loading from package.json
  - Add unit tests for event manager
  - Document serverEvents capability in capabilities.md

  Generic events are emitted directly to the server bus for interop with
  other plugins and the Signal K data pipeline. Custom plugin events
  still receive PLUGIN_ prefix for security.

  Example plugin demonstrates NMEA 0183 to NMEA 2000 PGN conversion.
@dirkwa dirkwa changed the title Refactor WASM and Feature/wasm strict and events feat: WASM serverEvents capability with generic event mechanism Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants