@mmstack/mesh 21.12.0 → 21.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -1
- package/fesm2022/mmstack-mesh.mjs +94 -7
- package/fesm2022/mmstack-mesh.mjs.map +1 -1
- package/package.json +3 -3
- package/types/mmstack-mesh.d.ts +31 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mmstack/mesh",
|
|
3
|
-
"version": "21.
|
|
3
|
+
"version": "21.14.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"angular",
|
|
6
6
|
"signals",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"homepage": "https://github.com/mihajm/mmstack/blob/master/packages/mesh/client",
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"@angular/core": ">=21 <22",
|
|
23
|
-
"@mmstack/primitives": ">=21.
|
|
24
|
-
"@mmstack/mesh-protocol": ">=0.
|
|
23
|
+
"@mmstack/primitives": ">=21.24 <22",
|
|
24
|
+
"@mmstack/mesh-protocol": ">=0.14 <1"
|
|
25
25
|
},
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"module": "fesm2022/mmstack-mesh.mjs",
|
package/types/mmstack-mesh.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ import { Signal, Injector, WritableSignal } from '@angular/core';
|
|
|
9
9
|
type MeshTransport = {
|
|
10
10
|
send(msg: ClientMsg): void;
|
|
11
11
|
onMessage(cb: (msg: ServerMsg) => void): () => void;
|
|
12
|
-
|
|
12
|
+
/** `code` and `reason` are the close frame's (1006 for a dropped connection, 1000 for a normal close). */
|
|
13
|
+
onClose(cb: (code: number, reason: string) => void): () => void;
|
|
13
14
|
close(): void;
|
|
14
15
|
};
|
|
15
16
|
type MeshTransportFactory = () => MeshTransport;
|
|
@@ -27,6 +28,12 @@ declare function directTransport(relay: Relay, ctx: PrincipalCtx): MeshTransport
|
|
|
27
28
|
type MeshStatus = 'connecting'
|
|
28
29
|
/** Queued behind another tab that owns this key's durable outbox (`crossTab: 'queue'`). */
|
|
29
30
|
| 'waiting' | 'live' | 'reconnecting' | 'ejected' | 'closed';
|
|
31
|
+
/** A `direct` frame as a seat or a synced store hands it over: `from` is the sender's origin. */
|
|
32
|
+
type MeshDirect = {
|
|
33
|
+
readonly from: string;
|
|
34
|
+
readonly v: number;
|
|
35
|
+
readonly data: unknown;
|
|
36
|
+
};
|
|
30
37
|
|
|
31
38
|
/** A data channel as the P2P engine needs it; opens later, buffers nothing itself. */
|
|
32
39
|
type DataChannelLike = {
|
|
@@ -269,6 +276,8 @@ type MeshSyncOptions = {
|
|
|
269
276
|
/** Register with the nearest transition scope so (re)connection surfaces as `pending`. */
|
|
270
277
|
readonly register?: 'track' | 'suspend';
|
|
271
278
|
readonly onEject?: (reason: string) => void;
|
|
279
|
+
/** The connection dropped and a reconnect is scheduled; `code` is the close code (1009 = message too big, 1006 = dropped). */
|
|
280
|
+
readonly onDisconnect?: (code: number, reason: string) => void;
|
|
272
281
|
/** A write the relay refused (see `MeshSessionHooks.onRefused`); the envelope carries its values. */
|
|
273
282
|
readonly onRefused?: (env: OpEnvelope, reason: 'generation' | 'schema' | 'order') => void;
|
|
274
283
|
/**
|
|
@@ -349,6 +358,16 @@ type MeshSyncRef<T extends object = Record<string, unknown>> = {
|
|
|
349
358
|
readonly peers: Signal<readonly MeshPeer[]>;
|
|
350
359
|
/** Publish this client's ephemeral presence payload (cursor, section, activity…). */
|
|
351
360
|
setPresence(data: unknown): void;
|
|
361
|
+
/**
|
|
362
|
+
* Send an ephemeral payload to one member, by origin. The relay routes it to that member only
|
|
363
|
+
* and never persists it; with no connection, or `to` not in the room, it is lost.
|
|
364
|
+
*/
|
|
365
|
+
send(to: string, data: unknown): void;
|
|
366
|
+
/**
|
|
367
|
+
* Listen for `direct` frames addressed to this client; returns the unsubscribe. A frame that
|
|
368
|
+
* arrives with no listener is lost. Peer links on {@link MeshSyncRef.signaling} never see them.
|
|
369
|
+
*/
|
|
370
|
+
direct(cb: (msg: MeshDirect) => void): () => void;
|
|
352
371
|
/**
|
|
353
372
|
* Fork the synced store for isolated, reviewable edits (an agent branch, a staged change). The
|
|
354
373
|
* fork observes the room as it is now; committing emits its diff citing only those observed
|
|
@@ -478,6 +497,16 @@ type AgentSeat<T extends object> = {
|
|
|
478
497
|
whenAcked(): Promise<void>;
|
|
479
498
|
/** Publish this seat's ephemeral presence payload (e.g. `{ name, kind: 'agent' }`). */
|
|
480
499
|
setPresence(data: unknown): void;
|
|
500
|
+
/**
|
|
501
|
+
* Send an ephemeral payload to one member, by origin. The relay routes it to that member only
|
|
502
|
+
* and never persists it; with no connection, or `to` not in the room, it is lost.
|
|
503
|
+
*/
|
|
504
|
+
send(to: string, data: unknown): void;
|
|
505
|
+
/**
|
|
506
|
+
* Listen for `direct` frames addressed to this seat; returns the unsubscribe. A frame that
|
|
507
|
+
* arrives with no listener is lost.
|
|
508
|
+
*/
|
|
509
|
+
direct(cb: (msg: MeshDirect) => void): () => void;
|
|
481
510
|
/** Authority surface over this seat's op-sync; see {@link SeatSync}. */
|
|
482
511
|
readonly sync: SeatSync<T>;
|
|
483
512
|
close(): void;
|
|
@@ -622,4 +651,4 @@ type RtcPresenceRef<T> = {
|
|
|
622
651
|
declare function rtcPresence<T>(links: PeerLinks, opt: RtcPresenceOptions): RtcPresenceRef<T>;
|
|
623
652
|
|
|
624
653
|
export { agentSeat, defaultPeerChannels, describeOp, directTransport, meshSync, peerLinks, presenceChannel, rtcPeerConnector, rtcPresence, setAtPath, webRtcMesh, webSocketTransport };
|
|
625
|
-
export type { AgentSeat, AgentSeatOptions, DataChannelLike, MeshPeer, MeshStatus, MeshSyncOptions, MeshSyncRef, MeshTransport, MeshTransportFactory, PeerChannelSpec, PeerConnector, PeerLinks, PeerLinksOptions, PresenceFrame, RtcPresenceOptions, RtcPresenceRef, SeatChange, SeatEvent, SeatResync, SeatSync, SignalingPort, StableSnapshot, SyncHealth, SyncHealthStatus, WebRtcMeshOptions, WebRtcMeshRef };
|
|
654
|
+
export type { AgentSeat, AgentSeatOptions, DataChannelLike, MeshDirect, MeshPeer, MeshStatus, MeshSyncOptions, MeshSyncRef, MeshTransport, MeshTransportFactory, PeerChannelSpec, PeerConnector, PeerLinks, PeerLinksOptions, PresenceFrame, RtcPresenceOptions, RtcPresenceRef, SeatChange, SeatEvent, SeatResync, SeatSync, SignalingPort, StableSnapshot, SyncHealth, SyncHealthStatus, WebRtcMeshOptions, WebRtcMeshRef };
|