@mmstack/mesh 21.14.0 → 21.15.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/fesm2022/mmstack-mesh.mjs +478 -52
- package/fesm2022/mmstack-mesh.mjs.map +1 -1
- package/package.json +3 -3
- package/types/mmstack-mesh.d.ts +69 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mmstack/mesh",
|
|
3
|
-
"version": "21.
|
|
3
|
+
"version": "21.15.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.25 <22",
|
|
24
|
+
"@mmstack/mesh-protocol": ">=0.15 <1"
|
|
25
25
|
},
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"module": "fesm2022/mmstack-mesh.mjs",
|
package/types/mmstack-mesh.d.ts
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import { ClientMsg, ServerMsg, Relay, PrincipalCtx, IceServer, ClientSignalMsg, PresenceState, OpPolicy } from '@mmstack/mesh-protocol';
|
|
2
|
-
import { OpSync, MergePolicyEntry, DiffOpsOptions,
|
|
1
|
+
import { StoreOp, ClientMsg, ServerMsg, Relay, PrincipalCtx, IceServer, ClientSignalMsg, PresenceState, OpPolicy } from '@mmstack/mesh-protocol';
|
|
2
|
+
import { OpEnvelope, OpSync, MergePolicyEntry, DiffOpsOptions, AsyncStore, ForkStoreOptions, SyncedFork, WritableSignalStore, StoreOp as StoreOp$1, toStoreOptions } from '@mmstack/primitives/core';
|
|
3
3
|
import { Signal, Injector, WritableSignal } from '@angular/core';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* The authored intent of an envelope: its raw op list and one bump flag, what a re-author rebuilds
|
|
7
|
+
* from. The raws are the stamped ops without their expansion clears (a diffed write never emits a
|
|
8
|
+
* `clear` of its own, so every `clear` is one) and without cites and epoch. The envelope bumped when
|
|
9
|
+
* an op's epoch rises above the register baseline at its path as the client held it before the
|
|
10
|
+
* envelope (the relay's own test for a bump).
|
|
11
|
+
*/
|
|
12
|
+
type Intent = {
|
|
13
|
+
readonly raws: readonly StoreOp[];
|
|
14
|
+
readonly bump: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
5
17
|
/**
|
|
6
18
|
* One live connection to a relay. `meshSync` calls the factory per (re)connect; a transport
|
|
7
19
|
* represents a single connection and never reconnects itself.
|
|
@@ -22,9 +34,43 @@ declare function webSocketTransport(url: string, protocols?: string | string[]):
|
|
|
22
34
|
/**
|
|
23
35
|
* Connects directly to an in-process `createRelay` — no network. The backbone of full-loop
|
|
24
36
|
* tests, and handy for single-process demos or an SSR-side room.
|
|
37
|
+
*
|
|
38
|
+
* Messages cross as JSON in both directions, as they would over a socket, so a direct peer holds
|
|
39
|
+
* exactly what a socket peer would. Handed over by reference, an `undefined` an emitter wrote
|
|
40
|
+
* would reach relay memory where a socket peer's would have been dropped.
|
|
25
41
|
*/
|
|
26
42
|
declare function directTransport(relay: Relay, ctx: PrincipalCtx): MeshTransportFactory;
|
|
27
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Why a write is a conflict: its replay into a new generation cites something the generation does
|
|
46
|
+
* not hold (`'uncovered'`, never sent), or the relay refused it — a cite it does not cover
|
|
47
|
+
* (`'citation'`) or an epoch raised without the authority to (`'epoch-bump'`).
|
|
48
|
+
*/
|
|
49
|
+
type ConflictCause = 'uncovered' | 'citation' | 'epoch-bump';
|
|
50
|
+
/**
|
|
51
|
+
* A write that will never be admitted as it stands. Its local effect is retracted (a replay that
|
|
52
|
+
* failed its pre-check is never applied; a refused write is dropped by the snapshot that follows).
|
|
53
|
+
* The two verbs are the whole surface: `discard()` lets it go, `reauthor()` writes its raw ops again
|
|
54
|
+
* as a new write citing the current state. Neither can submit the original envelope.
|
|
55
|
+
*/
|
|
56
|
+
type MeshConflict = {
|
|
57
|
+
/** The envelope as it was authored (its values, cites and epoch). */
|
|
58
|
+
readonly env: OpEnvelope;
|
|
59
|
+
readonly intent: Intent;
|
|
60
|
+
readonly cause: ConflictCause;
|
|
61
|
+
discard(): void;
|
|
62
|
+
/** Write the raw ops again as a new write; false when the shell cannot write (no `reauthor`). */
|
|
63
|
+
reauthor(): boolean;
|
|
64
|
+
};
|
|
65
|
+
/** The room's compaction state, as the relay last announced it. */
|
|
66
|
+
type CompactionState = {
|
|
67
|
+
/** Droppable tombstones counted against the budget. */
|
|
68
|
+
readonly count: number;
|
|
69
|
+
/** The hard budget, 0 when the room arms none. */
|
|
70
|
+
readonly budget: number;
|
|
71
|
+
/** Origins of the members currently declared ready for a consensus cut. */
|
|
72
|
+
readonly ready: readonly string[];
|
|
73
|
+
};
|
|
28
74
|
type MeshStatus = 'connecting'
|
|
29
75
|
/** Queued behind another tab that owns this key's durable outbox (`crossTab: 'queue'`). */
|
|
30
76
|
| 'waiting' | 'live' | 'reconnecting' | 'ejected' | 'closed';
|
|
@@ -378,6 +424,20 @@ type MeshSyncRef<T extends object = Record<string, unknown>> = {
|
|
|
378
424
|
fork(opt?: ForkStoreOptions<T & Record<string, any>>): SyncedFork<T & Record<string, any>>;
|
|
379
425
|
/** Authority surface over the CURRENT op-sync (it is rebuilt on restore); see {@link SeatSync}. */
|
|
380
426
|
readonly sync: SeatSync<T>;
|
|
427
|
+
/**
|
|
428
|
+
* Writes that will never be admitted as they stand: a write a compaction cut could not replay
|
|
429
|
+
* (it cites something the cut folded away) or one the relay refused. Each offers `discard()` or
|
|
430
|
+
* `reauthor()` (write its values again, citing the current state). Persisted with the outbox.
|
|
431
|
+
*/
|
|
432
|
+
readonly conflicts: Signal<readonly MeshConflict[]>;
|
|
433
|
+
/** The room's compaction state as the relay last announced it; undefined before any notice. */
|
|
434
|
+
readonly compaction: Signal<CompactionState | undefined>;
|
|
435
|
+
/**
|
|
436
|
+
* The member pressed (`true`) or released Compact: the client declares itself ready for a
|
|
437
|
+
* consensus cut whenever nothing it wrote is outstanding, re-declaring on every change. A
|
|
438
|
+
* reconnect or a new generation releases it.
|
|
439
|
+
*/
|
|
440
|
+
declareReady(pressed: boolean): void;
|
|
381
441
|
close(): void;
|
|
382
442
|
};
|
|
383
443
|
/**
|
|
@@ -395,7 +455,7 @@ type SeatChange = {
|
|
|
395
455
|
/** The relay's total-order stamp. Strictly increasing across `change` events between resyncs. */
|
|
396
456
|
readonly seq: number;
|
|
397
457
|
readonly writer: string;
|
|
398
|
-
readonly ops: readonly StoreOp[];
|
|
458
|
+
readonly ops: readonly StoreOp$1[];
|
|
399
459
|
};
|
|
400
460
|
/**
|
|
401
461
|
* Seq continuity broke: the seat re-established state from a room snapshot (a reconnect past
|
|
@@ -466,6 +526,11 @@ type AgentSeat<T extends object> = {
|
|
|
466
526
|
stableSnapshot(): StableSnapshot<T> | null;
|
|
467
527
|
/** Run local writes and emit them to the room as one envelope, like any peer's edit. */
|
|
468
528
|
write(fn: () => void): void;
|
|
529
|
+
/**
|
|
530
|
+
* The seat's writes that will never be admitted as they stand (a replay a compaction cut could not
|
|
531
|
+
* carry, or a relay refusal), each with `discard()` and `reauthor()`.
|
|
532
|
+
*/
|
|
533
|
+
conflicts(): readonly MeshConflict[];
|
|
469
534
|
/** Path-addressed write (`'a.b.c'` or segments), emitted immediately. */
|
|
470
535
|
setAtPath(path: string | readonly (string | number)[], value: unknown): void;
|
|
471
536
|
/**
|
|
@@ -535,7 +600,7 @@ declare function setAtPath(node: unknown, path: string | readonly PathSegment[],
|
|
|
535
600
|
* activity feeds and model context. Values render as truncated JSON. Pair with a seat's
|
|
536
601
|
* `changes` stream: narrating each batch's ops yields an append-only account of the room.
|
|
537
602
|
*/
|
|
538
|
-
declare function describeOp(op: StoreOp, writer: string): string;
|
|
603
|
+
declare function describeOp(op: StoreOp$1, writer: string): string;
|
|
539
604
|
|
|
540
605
|
type WebRtcMeshOptions = {
|
|
541
606
|
readonly room: string;
|