Skip to content

Latest commit

 

History

History
117 lines (79 loc) · 5.22 KB

CHANGELOG.md

File metadata and controls

117 lines (79 loc) · 5.22 KB

0.0.7 (2025-04-11)

Features

  • Export VersionedMessage type (ac60200)

0.0.6 (2025-04-10)

Relaxes Message type to make version optional. This allows to send messages without versioning by default.

Introduces the ability to configure how messages are validated with messageCheckStragegy option:

const peer = new MessagePeer({
  id: 'one',
  messsageCheckStrategy: 'version',
});

Check strategy can be one of default | type | version. By default, only the message structure is checked, with type it is checked that the message type is known to the peer upn reception, with version it is checked that the message type is known to the peer and the version is compatible with the peer.

With default check strategy, the knownMessages becomes optional.

Features

  • Make version optional in the Message interface (d7d671b)
  • Allow changing how messages are checked upon reception (1175331)

Fixes

  • Handle calling .connect() twice correctly (2fca710)
  • Handle calling .listen() twice correctly (c76367f)
  • Don't queue service messages like disconnect at peer level (3ba12a8)

BREAKING CHANGES

  • You might want to use Required<Message> instead of Message if you want to ensure version is mandatory for your message handling.
  • By default, message version and type checks are optional. Previous behaviour can be restored by setting messageCheckStrategy to version:
const peer = new MessagePeer({
  id: 'one',
  messageCheckStrategy: 'version',
  knownMessages: [],
});

0.0.5 (2025-04-03)

New .messages, .serviceMessages and .errors API that make it easier to dissociate peer creation with and places where messages might be consumed. It uses Obsevable and rxjs compatible implementation for streams of messages.

Features

  • Introduce new APIs for message consumption (1216d49)

Fixes

  • Throw an error if provided origin is invalid in .connect() or .listen() calls (db062bf)

BREAKING CHANGES

  • No longer possible to get messages via onMessage, onServiceMessage and onErrorat construction time, one should use.messages, .serviceMessages and .errors subscribable streams:
// BEFORE
const peer = new MessagePeer({
  id: 'one',
  onMessage: (m) => {},
  onServiceMessage: (m) => {},
  onError: (e) => {},
});

// AFTER
const peer = new MessagePeer({ id: 'one' });

peer.messages.subscribe((m) => {});
peer.serviceMessages.subscribe((m) => {});
peer.errors.subscribe((e) => {});

0.0.4 (2025-03-14)

Features

  • Exception during message validation upon reception now reported back to original sender via ErrorMessage (db468df)

Fixes

  • Messages .send() before connection is established are now cached and sent after connection is established (8e6b7cf)
  • Fixed throwing errors when receiving a postMessage from 3rd party libraries (bb41141 )
  • ConnectMessage now is sent before any queued user messages, not after (d02ef3d )

0.0.3 (2025-03-03)

Features

  • Publish CommonJS, ESM and minified bundle (c3a84f9)
  • Add enableLogging() method to configure debugging logging that is off by default(b81ad27)

BREAKING CHANGES

  • Service messages like ConnectMessage, DisconnectMessage have their own callback now:
// Before
let peer = new MessagePeer<M>({
  onMessage: (m: M) => {}, // both user and service messages
});

// After
let peer = new MessagePeer<M>({
  onMessage: (m: M) => {}, // only user messages
  onServiceMessage: (m: ServiceMessage) => {}, // only service messages
});