0.0.7 (2025-04-11)
- 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.
- Make
version
optional in theMessage
interface (d7d671b) - Allow changing how messages are checked upon reception (1175331)
- Handle calling
.connect()
twice correctly (2fca710) - Handle calling
.listen()
twice correctly (c76367f) - Don't queue service messages like
disconnect
at peer level (3ba12a8)
- You might want to use
Required<Message>
instead ofMessage
if you want to ensureversion
is mandatory for your message handling. - By default, message version and type checks are optional. Previous behaviour can be restored by setting
messageCheckStrategy
toversion
:
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.
- Introduce new APIs for message consumption (1216d49)
- Throw an error if provided origin is invalid in
.connect()
or.listen()
calls (db062bf)
- No longer possible to get messages via
onMessage
,onServiceMessage
andonError
at 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)
- Exception during message validation upon reception now reported back to original sender via
ErrorMessage
(db468df)
- 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)
- Publish CommonJS, ESM and minified bundle (c3a84f9)
- Add
enableLogging()
method to configure debugging logging that is off by default(b81ad27)
- 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
});