yrby-client 0.4.2 → 0.4.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"actioncable_provider.d.ts","sourceRoot":"","sources":["../src/actioncable_provider.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,gBAAgB,EAAe,KAAK,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAEtG,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,WAAW,GAAG,QAAQ,GAAG,cAAc,CAAC;AAEpF,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,cAAc,CAAC;CACxB;AAED,oFAAoF;AACpF,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IAC7B,wEAAwE;IACxE,OAAO,CAAC,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IACjC,sEAAsE;IACtE,WAAW,CAAC,IAAI,IAAI,CAAC;CACtB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE;QACb,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAAC;KACrE,CAAC;CACH;AAED,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAAC,uBAAuB,EAAE,gBAAgB,GAAG,SAAS,CAAC,CAAC;AAQrG,qBAAa,mBAAmB;;IAC9B,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,aAAa,EAA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30
  #statusListeners = new Set();
31
31
  #onUnload = null;
32
+ #onRestore = null;
33
+ #stashedPresence = null;
32
34
  constructor(doc, consumer, channelName, channelParams = {}, opts = {}) {
33
35
  this.doc = doc;
34
36
  this.consumer = consumer;
@@ -81,9 +83,11 @@ export class ActionCableProvider {
81
83
  const provider = this;
82
84
  this.#subscription = this.consumer.subscriptions.create({ channel: this.channelName, ...this.channelParams }, {
83
85
  received(message) {
84
- // Reliable-delivery ack: confirm + prune the local queue.
86
+ // Reliable-delivery ack: confirm + prune the local queue. `dropped`
87
+ // marks a settle-without-record (unhealable gap) — the session prunes
88
+ // either way but surfaces the drop via onError("ack-dropped").
85
89
  if (message && message.ack !== undefined) {
86
- provider.session.ack(message.ack);
90
+ provider.session.ack(message.ack, message.dropped === true);
87
91
  return;
88
92
  }
89
93
  const awarenessPayload = message && message.awareness;
@@ -119,6 +123,13 @@ export class ActionCableProvider {
119
123
  provider.session.onDisconnect(); // pause retransmits, clear remote presence
120
124
  provider.#refreshStatus(); // subscription still set -> "connecting" (retrying)
121
125
  },
126
+ rejected() {
127
+ // The channel refused the subscription (auth, missing doc). Surface
128
+ // it and tear down — otherwise the provider sits at "connecting"
129
+ // forever, silently queueing edits. The app decides what's next.
130
+ provider.#onError(new Error("subscription rejected by the server"), "rejected");
131
+ provider.disconnect();
132
+ },
122
133
  });
123
134
  this.#installUnloadHandler();
124
135
  this.#refreshStatus(); // -> "connecting"
@@ -163,21 +174,41 @@ export class ActionCableProvider {
163
174
  for (const listener of this.#statusListeners)
164
175
  listener({ status: next });
165
176
  }
166
- // Best-effort presence removal when the tab/page goes away (close, navigation,
167
- // bfcache). `pagehide` fires while the socket is still live and is bfcache-safe
168
- // (unlike `beforeunload`, which can block it). Sends are not guaranteed to
169
- // flush on unload, so the server-side awareness timeout remains the backstop.
177
+ // Presence teardown/restore around page lifecycle:
178
+ // - `pagehide`: remove local presence while the socket is still live so peers
179
+ // drop our cursor now (bfcache-safe; the awareness timeout is the backstop).
180
+ // - `pageshow` with `persisted`: the user came BACK (bfcache restore), so put
181
+ // their presence back — editors set awareness once at setup, so without
182
+ // this they'd rejoin as a ghost with no cursor.
170
183
  #installUnloadHandler() {
171
184
  if (typeof window === "undefined" || this.#onUnload)
172
185
  return;
173
- this.#onUnload = () => this.session.removeLocalAwareness();
186
+ this.#onUnload = () => {
187
+ this.#stashedPresence = this.awareness.getLocalState();
188
+ this.session.removeLocalAwareness();
189
+ };
190
+ this.#onRestore = (event) => {
191
+ if (!event.persisted || !this.#stashedPresence)
192
+ return;
193
+ if (this.awareness.getLocalState() === null) {
194
+ this.awareness.setLocalState(this.#stashedPresence);
195
+ }
196
+ this.#stashedPresence = null;
197
+ };
174
198
  window.addEventListener("pagehide", this.#onUnload);
199
+ window.addEventListener("pageshow", this.#onRestore);
175
200
  }
176
201
  #removeUnloadHandler() {
177
- if (typeof window === "undefined" || !this.#onUnload)
202
+ if (typeof window === "undefined")
178
203
  return;
179
- window.removeEventListener("pagehide", this.#onUnload);
180
- this.#onUnload = null;
204
+ if (this.#onUnload) {
205
+ window.removeEventListener("pagehide", this.#onUnload);
206
+ this.#onUnload = null;
207
+ }
208
+ if (this.#onRestore) {
209
+ window.removeEventListener("pageshow", this.#onRestore);
210
+ this.#onRestore = null;
211
+ }
181
212
  }
182
213
  // Send one raw protocol frame over the cable. Awareness frames are whispered
183
214
  // when AnyCable exposes `subscription.whisper`; otherwise they fall back to a
@@ -190,12 +221,28 @@ export class ActionCableProvider {
190
221
  return;
191
222
  const update = toBase64(frame);
192
223
  const isAwareness = frame[0] === MessageType.Awareness;
193
- if (isAwareness && typeof sub.whisper === "function") {
194
- sub.whisper({ awareness: update });
195
- return;
224
+ // Route transport failures (sync throws, or @anycable/web's rejected
225
+ // promises) to onError instead of letting them escape into update
226
+ // handlers. A failed send is recoverable: reliable frames stay queued
227
+ // until acked, and awareness is best-effort anyway.
228
+ try {
229
+ if (isAwareness && typeof sub.whisper === "function") {
230
+ this.#observe(sub.whisper({ awareness: update }));
231
+ return;
232
+ }
233
+ const payload = id === undefined ? { update } : { update, id };
234
+ this.#observe(sub.send(payload));
235
+ }
236
+ catch (error) {
237
+ this.#onError(error, "send");
238
+ }
239
+ }
240
+ // Attach a rejection handler when a transport returns a promise, so failures
241
+ // surface via onError instead of as unhandled rejections.
242
+ #observe(result) {
243
+ if (result instanceof Promise) {
244
+ result.catch((error) => this.#onError(error, "send"));
196
245
  }
197
- const payload = id === undefined ? { update } : { update, id };
198
- sub.send(payload);
199
246
  }
200
247
  }
201
248
  //# sourceMappingURL=actioncable_provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"actioncable_provider.js","sourceRoot":"","sources":["../src/actioncable_provider.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,kFAAkF;AAClF,kFAAkF;AAClF,qEAAqE;AACrE,gDAAgD;AAChD,EAAE;AACF,6EAA6E;AAC7E,gFAAgF;AAChF,qCAAqC;AACrC,EAAE;AACF,iFAAiF;AACjF,oFAAoF;AACpF,wEAAwE;AACxE,kFAAkF;AAClF,2DAA2D;AAC3D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAgC,MAAM,yBAAyB,CAAC;AACtG,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAkDlD,MAAM,OAAO,mBAAmB;IACrB,GAAG,CAAM;IACT,QAAQ,CAAgB;IACxB,WAAW,CAAS;IACpB,aAAa,CAAS;IACtB,SAAS,CAAY;IACrB,OAAO,CAAmB;IACnC,aAAa,GAA6B,IAAI,CAAC;IAC/C,QAAQ,CAA4C;IACpD,UAAU,GAAG,KAAK,CAAC;IACnB,OAAO,GAAmB,cAAc,CAAC;IACzC,gBAAgB,GAAG,IAAI,GAAG,EAAgC,CAAC;IAC3D,SAAS,GAAwB,IAAI,CAAC;IAEtC,YACE,GAAQ,EACR,QAAuB,EACvB,WAAmB,EACnB,gBAAwB,EAAE,EAC1B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AAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,6EAA6E;IAC7E,0DAA0D;IAC1D,QAAQ,CAAC,MAAe;QACtB,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;YAC9B,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,73 @@
1
+ import { YProtocolSession, type YProtocolSessionOptions } from "./y_protocol_session.js";
2
+ import { Awareness } from "y-protocols/awareness";
3
+ import type { Doc } from "yjs";
4
+ /**
5
+ * Connection lifecycle, folded into one signal (no separate "sync" event):
6
+ * connecting (subscription created, transport not up yet), connected (transport
7
+ * up, exchanging sync steps; UI: "syncing"), synced (caught up), and disconnected
8
+ * (torn down via disconnect()/destroy()). A dropped transport that ActionCable
9
+ * will retry shows as "connecting", not "disconnected".
10
+ */
11
+ export type ProviderStatus = "connecting" | "connected" | "synced" | "disconnected";
12
+ /** Payload passed to onStatusChange listeners. */
13
+ export interface StatusEvent {
14
+ status: ProviderStatus;
15
+ }
16
+ /** The minimal slice of an ActionCable/AnyCable subscription this provider uses. */
17
+ export interface CableSubscription {
18
+ send(data: unknown): unknown;
19
+ /** AnyCable client-to-client broadcast; absent on plain ActionCable. */
20
+ whisper?(data: unknown): unknown;
21
+ /** Teardown. Present on both @rails/actioncable and @anycable/web. */
22
+ unsubscribe?(): void;
23
+ }
24
+ /**
25
+ * The minimal slice of an ActionCable/AnyCable consumer this provider uses.
26
+ *
27
+ * Deliberately loose so the consumers from both `@rails/actioncable` and
28
+ * `@anycable/web` are directly assignable -- no adapter or casts. `create` is
29
+ * widened to the channel/params shapes both libs accept, with an optional mixin
30
+ * (the handlers object). There's no `subscriptions.remove`: the provider tears
31
+ * down via `subscription.unsubscribe()` (universal), and @anycable has no such
32
+ * method anyway.
33
+ */
34
+ export interface CableConsumer {
35
+ subscriptions: {
36
+ create(channel: string | object, mixin?: object): CableSubscription;
37
+ };
38
+ }
39
+ export type ActionCableProviderOptions = Pick<YProtocolSessionOptions, "resendInterval" | "onError">;
40
+ export declare class ActionCableProvider {
41
+ #private;
42
+ readonly doc: Doc;
43
+ readonly consumer: CableConsumer;
44
+ readonly channelName: string;
45
+ readonly channelParams: object;
46
+ readonly awareness: Awareness;
47
+ readonly session: YProtocolSession;
48
+ constructor(doc: Doc, consumer: CableConsumer, channelName: string, channelParams?: object, opts?: ActionCableProviderOptions);
49
+ /** True once the document has caught up with the server (received a SyncStep2). */
50
+ get synced(): boolean;
51
+ /** True while there are unacknowledged local document updates in flight. */
52
+ get hasPending(): boolean;
53
+ /**
54
+ * Apply a bootstrap/restore update (initial HTTP state, a server snapshot, an
55
+ * import) without re-sending it to the server as a local edit. Call it once per
56
+ * chunk of already-durable state when seeding the doc, before `connect()`:
57
+ *
58
+ * provider.applyRemoteUpdate(fromBase64(initialState));
59
+ * priorUpdates.forEach((u) => provider.applyRemoteUpdate(fromBase64(u)));
60
+ * provider.connect();
61
+ *
62
+ * See {@link YProtocolSession.applyRemoteUpdate} for why a bare `Y.applyUpdate`
63
+ * would be re-broadcast as a pending change instead.
64
+ */
65
+ applyRemoteUpdate(update: Uint8Array): void;
66
+ /** Current connection status. See {@link ProviderStatus}. */
67
+ get status(): ProviderStatus;
68
+ /** Subscribe to status changes. Returns an unsubscribe function. */
69
+ onStatusChange(listener: (event: StatusEvent) => void): () => void;
70
+ connect(): void;
71
+ disconnect(): void;
72
+ destroy(): void;
73
+ }
@@ -32,6 +32,8 @@ class ActionCableProvider {
32
32
  #status = "disconnected";
33
33
  #statusListeners = new Set();
34
34
  #onUnload = null;
35
+ #onRestore = null;
36
+ #stashedPresence = null;
35
37
  constructor(doc, consumer, channelName, channelParams = {}, opts = {}) {
36
38
  this.doc = doc;
37
39
  this.consumer = consumer;
@@ -84,9 +86,11 @@ class ActionCableProvider {
84
86
  const provider = this;
85
87
  this.#subscription = this.consumer.subscriptions.create({ channel: this.channelName, ...this.channelParams }, {
86
88
  received(message) {
87
- // Reliable-delivery ack: confirm + prune the local queue.
89
+ // Reliable-delivery ack: confirm + prune the local queue. `dropped`
90
+ // marks a settle-without-record (unhealable gap) — the session prunes
91
+ // either way but surfaces the drop via onError("ack-dropped").
88
92
  if (message && message.ack !== undefined) {
89
- provider.session.ack(message.ack);
93
+ provider.session.ack(message.ack, message.dropped === true);
90
94
  return;
91
95
  }
92
96
  const awarenessPayload = message && message.awareness;
@@ -122,6 +126,13 @@ class ActionCableProvider {
122
126
  provider.session.onDisconnect(); // pause retransmits, clear remote presence
123
127
  provider.#refreshStatus(); // subscription still set -> "connecting" (retrying)
124
128
  },
129
+ rejected() {
130
+ // The channel refused the subscription (auth, missing doc). Surface
131
+ // it and tear down — otherwise the provider sits at "connecting"
132
+ // forever, silently queueing edits. The app decides what's next.
133
+ provider.#onError(new Error("subscription rejected by the server"), "rejected");
134
+ provider.disconnect();
135
+ },
125
136
  });
126
137
  this.#installUnloadHandler();
127
138
  this.#refreshStatus(); // -> "connecting"
@@ -166,21 +177,41 @@ class ActionCableProvider {
166
177
  for (const listener of this.#statusListeners)
167
178
  listener({ status: next });
168
179
  }
169
- // Best-effort presence removal when the tab/page goes away (close, navigation,
170
- // bfcache). `pagehide` fires while the socket is still live and is bfcache-safe
171
- // (unlike `beforeunload`, which can block it). Sends are not guaranteed to
172
- // flush on unload, so the server-side awareness timeout remains the backstop.
180
+ // Presence teardown/restore around page lifecycle:
181
+ // - `pagehide`: remove local presence while the socket is still live so peers
182
+ // drop our cursor now (bfcache-safe; the awareness timeout is the backstop).
183
+ // - `pageshow` with `persisted`: the user came BACK (bfcache restore), so put
184
+ // their presence back — editors set awareness once at setup, so without
185
+ // this they'd rejoin as a ghost with no cursor.
173
186
  #installUnloadHandler() {
174
187
  if (typeof window === "undefined" || this.#onUnload)
175
188
  return;
176
- this.#onUnload = () => this.session.removeLocalAwareness();
189
+ this.#onUnload = () => {
190
+ this.#stashedPresence = this.awareness.getLocalState();
191
+ this.session.removeLocalAwareness();
192
+ };
193
+ this.#onRestore = (event) => {
194
+ if (!event.persisted || !this.#stashedPresence)
195
+ return;
196
+ if (this.awareness.getLocalState() === null) {
197
+ this.awareness.setLocalState(this.#stashedPresence);
198
+ }
199
+ this.#stashedPresence = null;
200
+ };
177
201
  window.addEventListener("pagehide", this.#onUnload);
202
+ window.addEventListener("pageshow", this.#onRestore);
178
203
  }
179
204
  #removeUnloadHandler() {
180
- if (typeof window === "undefined" || !this.#onUnload)
205
+ if (typeof window === "undefined")
181
206
  return;
182
- window.removeEventListener("pagehide", this.#onUnload);
183
- this.#onUnload = null;
207
+ if (this.#onUnload) {
208
+ window.removeEventListener("pagehide", this.#onUnload);
209
+ this.#onUnload = null;
210
+ }
211
+ if (this.#onRestore) {
212
+ window.removeEventListener("pageshow", this.#onRestore);
213
+ this.#onRestore = null;
214
+ }
184
215
  }
185
216
  // Send one raw protocol frame over the cable. Awareness frames are whispered
186
217
  // when AnyCable exposes `subscription.whisper`; otherwise they fall back to a
@@ -193,12 +224,28 @@ class ActionCableProvider {
193
224
  return;
194
225
  const update = (0, base64_js_1.toBase64)(frame);
195
226
  const isAwareness = frame[0] === y_protocol_session_js_1.MessageType.Awareness;
196
- if (isAwareness && typeof sub.whisper === "function") {
197
- sub.whisper({ awareness: update });
198
- return;
227
+ // Route transport failures (sync throws, or @anycable/web's rejected
228
+ // promises) to onError instead of letting them escape into update
229
+ // handlers. A failed send is recoverable: reliable frames stay queued
230
+ // until acked, and awareness is best-effort anyway.
231
+ try {
232
+ if (isAwareness && typeof sub.whisper === "function") {
233
+ this.#observe(sub.whisper({ awareness: update }));
234
+ return;
235
+ }
236
+ const payload = id === undefined ? { update } : { update, id };
237
+ this.#observe(sub.send(payload));
238
+ }
239
+ catch (error) {
240
+ this.#onError(error, "send");
241
+ }
242
+ }
243
+ // Attach a rejection handler when a transport returns a promise, so failures
244
+ // surface via onError instead of as unhandled rejections.
245
+ #observe(result) {
246
+ if (result instanceof Promise) {
247
+ result.catch((error) => this.#onError(error, "send"));
199
248
  }
200
- const payload = id === undefined ? { update } : { update, id };
201
- sub.send(payload);
202
249
  }
203
250
  }
204
251
  exports.ActionCableProvider = ActionCableProvider;
@@ -0,0 +1,2 @@
1
+ export declare const toBase64: (bytes: Uint8Array) => string;
2
+ export declare const fromBase64: (str: string) => Uint8Array;
@@ -0,0 +1,7 @@
1
+ export { ReliableSync } from "./reliable_sync.js";
2
+ export type { ReliableSyncOptions, TimerHandle } from "./reliable_sync.js";
3
+ export { YProtocolSession, MessageType } from "./y_protocol_session.js";
4
+ export type { YProtocolSessionOptions } from "./y_protocol_session.js";
5
+ export { ActionCableProvider } from "./actioncable_provider.js";
6
+ export type { ActionCableProviderOptions, ProviderStatus, StatusEvent, CableConsumer, CableSubscription, } from "./actioncable_provider.js";
7
+ export { toBase64, fromBase64 } from "./base64.js";
@@ -0,0 +1,58 @@
1
+ /** An opaque timer handle (number in browsers, Timeout in Node). */
2
+ export type TimerHandle = unknown;
3
+ export interface ReliableSyncOptions {
4
+ /**
5
+ * Transmit one update. `update` is the raw merged update bytes; `id` is the
6
+ * cumulative sequence to ack against.
7
+ */
8
+ send: (update: Uint8Array, id: number) => void;
9
+ /** Merge an array of update byte-arrays into one (typically Y.mergeUpdates). */
10
+ merge: (updates: Uint8Array[]) => Uint8Array;
11
+ /** Milliseconds between retransmits of the unacked tail (default 1000). */
12
+ resendInterval?: number;
13
+ /** Injectable timer hooks (default to globals); handy for tests. */
14
+ setInterval?: (handler: () => void, ms: number) => TimerHandle;
15
+ clearInterval?: (handle: TimerHandle) => void;
16
+ }
17
+ interface Pending {
18
+ seq: number;
19
+ update: Uint8Array;
20
+ }
21
+ export declare class ReliableSync {
22
+ #private;
23
+ /** Unacked local updates, in order. */
24
+ pending: Pending[];
25
+ constructor(opts: ReliableSyncOptions);
26
+ /** True while there are unacknowledged local updates. */
27
+ get hasPending(): boolean;
28
+ /**
29
+ * Record a local document update. It is queued and the unacked tail is
30
+ * flushed; the update remains retained until the server acknowledges it.
31
+ */
32
+ enqueue(update: Uint8Array): void;
33
+ /**
34
+ * Send the whole unacked tail as one merged delta. The id is the highest seq
35
+ * in the batch, so a single { ack } cumulatively confirms everything up to it.
36
+ * No-op while disconnected (the tail is replayed on the next onConnect).
37
+ */
38
+ flush(): void;
39
+ /**
40
+ * Confirm delivery up to `id`: prune every queued update with seq <= id.
41
+ * Acks arrive over the wire, so validate before pruning. A malformed value
42
+ * (NaN/string/negative) or an impossible future id must not silently drop the
43
+ * queue; invalid acks are ignored.
44
+ */
45
+ onAck(id: number): void;
46
+ /** Transport (re)connected: replay the unacked tail and resume retransmits. */
47
+ onConnect(): void;
48
+ /** Transport dropped: keep the queue (for reconnect replay), pause the timer. */
49
+ onDisconnect(): void;
50
+ /**
51
+ * One retransmit tick. Exposed for deterministic testing; normally driven by
52
+ * the internal timer.
53
+ */
54
+ onTick(): void;
55
+ /** Stop timers and drop references. Call when the provider is destroyed. */
56
+ destroy(): void;
57
+ }
58
+ export {};
@@ -0,0 +1,82 @@
1
+ import { Doc } from "yjs";
2
+ import { type Awareness } from "y-protocols/awareness";
3
+ import { type TimerHandle } from "./reliable_sync.js";
4
+ export declare const MessageType: {
5
+ readonly Sync: 0;
6
+ readonly Awareness: 1;
7
+ };
8
+ export interface YProtocolSessionOptions {
9
+ /**
10
+ * Transmit one raw protocol frame. `id` is set only for reliable document
11
+ * updates (tag it onto your envelope so the server can ack). Awareness frames
12
+ * are identifiable by their first byte (`MessageType.Awareness`) if a transport
13
+ * needs to route them separately.
14
+ */
15
+ send: (frame: Uint8Array, id: number | undefined) => void;
16
+ /** Optional awareness/presence. When omitted, awareness frames are ignored. */
17
+ awareness?: Awareness | null;
18
+ /** Forwarded to ReliableSync. */
19
+ resendInterval?: number;
20
+ /**
21
+ * Called when an incoming frame can't be decoded/applied (malformed bytes,
22
+ * truncated message, unexpected structure). The frame is dropped and the
23
+ * session keeps running. `context` names where it happened (e.g. "receive").
24
+ * Defaults to a `console.warn`.
25
+ */
26
+ onError?: (error: unknown, context: string) => void;
27
+ /** Injectable timer hooks (forwarded to ReliableSync); handy for tests. */
28
+ setInterval?: (handler: () => void, ms: number) => TimerHandle;
29
+ clearInterval?: (handle: TimerHandle) => void;
30
+ }
31
+ export declare class YProtocolSession {
32
+ #private;
33
+ readonly doc: Doc;
34
+ readonly awareness: Awareness | null;
35
+ constructor(doc: Doc, opts: YProtocolSessionOptions);
36
+ /** True once we've received the server's SyncStep2 (the document is caught up). */
37
+ get synced(): boolean;
38
+ /** True while there are unacknowledged local document updates in flight. */
39
+ get hasPending(): boolean;
40
+ /** Transport connected: send the opening handshake and replay the unacked tail. */
41
+ onConnect(): void;
42
+ /** Transport dropped: pause retransmits (queue kept) and clear remote presence. */
43
+ onDisconnect(): void;
44
+ /**
45
+ * Broadcast that our local presence is gone (sets local state to null, which
46
+ * emits a removal awareness frame through `send`). Call this while the
47
+ * transport is still live so peers drop our cursor immediately instead of
48
+ * waiting for the awareness timeout. A no-op when there's no local state.
49
+ */
50
+ removeLocalAwareness(): void;
51
+ /**
52
+ * A reliable-delivery `{ ack: id }` envelope arrived. `dropped` is set when
53
+ * the server settled the update WITHOUT recording it (rejected as an
54
+ * unhealable causal gap after repeated resyncs). The queue is pruned either
55
+ * way — retransmitting an unhealable update would loop forever — but a
56
+ * dropped settle is surfaced via onError ("ack-dropped") so the app can warn
57
+ * or reload instead of silently reporting synced over lost data.
58
+ */
59
+ ack(id: number, dropped?: boolean): void;
60
+ /**
61
+ * Apply an update without treating it as a local edit, so it isn't queued for
62
+ * re-delivery to the server. Use it for bootstrap/restore: initial state loaded
63
+ * over HTTP, a server snapshot, an import. These are bytes the server already
64
+ * has.
65
+ *
66
+ * The session re-sends any doc update whose origin isn't itself (that's how a
67
+ * keystroke becomes an outbound frame), so a bare `Y.applyUpdate(doc, update)`
68
+ * would look like a local edit and get echoed back on the next connect. Going
69
+ * through here applies under the session's own origin, which the outbound
70
+ * filter skips. Safe to call before `onConnect()`: the state folds into the
71
+ * SyncStep1 handshake instead of being re-sent.
72
+ */
73
+ applyRemoteUpdate(update: Uint8Array): void;
74
+ /**
75
+ * Decode and apply one incoming binary protocol frame (document sync or
76
+ * awareness). Returns a reply frame to transmit (e.g. SyncStep2 answering a
77
+ * SyncStep1), or null if there's nothing to send.
78
+ */
79
+ receive(frame: Uint8Array): Uint8Array | null;
80
+ /** Detach doc/awareness listeners and stop retransmits. */
81
+ destroy(): void;
82
+ }
@@ -136,9 +136,19 @@ class YProtocolSession {
136
136
  this.awareness.setLocalState(null); // fires "update" -> sends the removal frame
137
137
  }
138
138
  }
139
- /** A reliable-delivery `{ ack: id }` envelope arrived. */
140
- ack(id) {
139
+ /**
140
+ * A reliable-delivery `{ ack: id }` envelope arrived. `dropped` is set when
141
+ * the server settled the update WITHOUT recording it (rejected as an
142
+ * unhealable causal gap after repeated resyncs). The queue is pruned either
143
+ * way — retransmitting an unhealable update would loop forever — but a
144
+ * dropped settle is surfaced via onError ("ack-dropped") so the app can warn
145
+ * or reload instead of silently reporting synced over lost data.
146
+ */
147
+ ack(id, dropped = false) {
141
148
  this.#delivery.onAck(id);
149
+ if (dropped) {
150
+ this.#onError(new Error(`server dropped update ${id} as an unhealable causal gap; it was settled but NOT recorded`), "ack-dropped");
151
+ }
142
152
  }
143
153
  /**
144
154
  * Apply an update without treating it as a local edit, so it isn't queued for
@@ -235,7 +245,25 @@ class YProtocolSession {
235
245
  break;
236
246
  }
237
247
  case exports.MessageType.Awareness:
238
- decoding.readVarUint8Array(decoder);
248
+ // Validate the payload's CONTENTS, not just the envelope.
249
+ // applyAwarenessUpdate mutates state entry by entry and only notifies
250
+ // listeners at the end — a bad entry mid-payload would leave earlier
251
+ // entries applied with no event fired. Dry-running every entry here
252
+ // makes the real apply infallible (and catches trailing garbage
253
+ // inside the blob).
254
+ {
255
+ const payload = decoding.readVarUint8Array(decoder);
256
+ const inner = decoding.createDecoder(payload);
257
+ const count = decoding.readVarUint(inner);
258
+ for (let i = 0; i < count; i++) {
259
+ decoding.readVarUint(inner); // clientID
260
+ decoding.readVarUint(inner); // clock
261
+ JSON.parse(decoding.readVarString(inner)); // state (null on removal)
262
+ }
263
+ if (decoding.hasContent(inner)) {
264
+ throw new Error("awareness payload has trailing bytes");
265
+ }
266
+ }
239
267
  break;
240
268
  default:
241
269
  return null; // a y-protocols type yrby doesn't speak: ignore
@@ -48,8 +48,15 @@ export declare class YProtocolSession {
48
48
  * waiting for the awareness timeout. A no-op when there's no local state.
49
49
  */
50
50
  removeLocalAwareness(): void;
51
- /** A reliable-delivery `{ ack: id }` envelope arrived. */
52
- ack(id: number): void;
51
+ /**
52
+ * A reliable-delivery `{ ack: id }` envelope arrived. `dropped` is set when
53
+ * the server settled the update WITHOUT recording it (rejected as an
54
+ * unhealable causal gap after repeated resyncs). The queue is pruned either
55
+ * way — retransmitting an unhealable update would loop forever — but a
56
+ * dropped settle is surfaced via onError ("ack-dropped") so the app can warn
57
+ * or reload instead of silently reporting synced over lost data.
58
+ */
59
+ ack(id: number, dropped?: boolean): void;
53
60
  /**
54
61
  * Apply an update without treating it as a local edit, so it isn't queued for
55
62
  * re-delivery to the server. Use it for bootstrap/restore: initial state loaded
@@ -1 +1 @@
1
- {"version":3,"file":"y_protocol_session.d.ts","sourceRoot":"","sources":["../src/y_protocol_session.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,GAAG,EAA6B,MAAM,KAAK,CAAC;AAIrD,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAIpE,eAAO,MAAM,WAAW;;;CAAqC,CAAC;AAE9D,MAAM,WAAW,uBAAuB;IACtC;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AM,EAAE,OAAO,UAAQ,GAAG,IAAI;IAUtC;;;;;;;;;;;;OAYG;IACH,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAI3C;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI;IA8B7C,2DAA2D;IAC3D,OAAO,IAAI,IAAI;CA0EhB"}
@@ -100,9 +100,19 @@ export class YProtocolSession {
100
100
  this.awareness.setLocalState(null); // fires "update" -> sends the removal frame
101
101
  }
102
102
  }
103
- /** A reliable-delivery `{ ack: id }` envelope arrived. */
104
- ack(id) {
103
+ /**
104
+ * A reliable-delivery `{ ack: id }` envelope arrived. `dropped` is set when
105
+ * the server settled the update WITHOUT recording it (rejected as an
106
+ * unhealable causal gap after repeated resyncs). The queue is pruned either
107
+ * way — retransmitting an unhealable update would loop forever — but a
108
+ * dropped settle is surfaced via onError ("ack-dropped") so the app can warn
109
+ * or reload instead of silently reporting synced over lost data.
110
+ */
111
+ ack(id, dropped = false) {
105
112
  this.#delivery.onAck(id);
113
+ if (dropped) {
114
+ this.#onError(new Error(`server dropped update ${id} as an unhealable causal gap; it was settled but NOT recorded`), "ack-dropped");
115
+ }
106
116
  }
107
117
  /**
108
118
  * Apply an update without treating it as a local edit, so it isn't queued for
@@ -199,7 +209,25 @@ export class YProtocolSession {
199
209
  break;
200
210
  }
201
211
  case MessageType.Awareness:
202
- decoding.readVarUint8Array(decoder);
212
+ // Validate the payload's CONTENTS, not just the envelope.
213
+ // applyAwarenessUpdate mutates state entry by entry and only notifies
214
+ // listeners at the end — a bad entry mid-payload would leave earlier
215
+ // entries applied with no event fired. Dry-running every entry here
216
+ // makes the real apply infallible (and catches trailing garbage
217
+ // inside the blob).
218
+ {
219
+ const payload = decoding.readVarUint8Array(decoder);
220
+ const inner = decoding.createDecoder(payload);
221
+ const count = decoding.readVarUint(inner);
222
+ for (let i = 0; i < count; i++) {
223
+ decoding.readVarUint(inner); // clientID
224
+ decoding.readVarUint(inner); // clock
225
+ JSON.parse(decoding.readVarString(inner)); // state (null on removal)
226
+ }
227
+ if (decoding.hasContent(inner)) {
228
+ throw new Error("awareness payload has trailing bytes");
229
+ }
230
+ }
203
231
  break;
204
232
  default:
205
233
  return null; // a y-protocols type yrby doesn't speak: ignore
@@ -1 +1 @@
1
- {"version":3,"file":"y_protocol_session.js","sourceRoot":"","sources":["../src/y_protocol_session.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,kFAAkF;AAClF,2EAA2E;AAC3E,gFAAgF;AAChF,uEAAuE;AACvE,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAC9E,wEAAwE;AACxE,sCAAsC;AACtC,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACrG,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,GAEtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAoB,MAAM,oBAAoB,CAAC;AAEpE,2EAA2E;AAC3E,2EAA2E;AAC3E,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAW,CAAC;AA4B9D,MAAM,OAAO,gBAAgB;IAClB,GAAG,CAAM;IACT,SAAS,CAAmB;IAErC,KAAK,CAAkC;IACvC,QAAQ,CAA4C;IACpD,OAAO,GAAG,KAAK,CAAC;IAChB,SAAS,CAAe;IACxB,YAAY,CAAgD;IAC5D,kBAAkB,CAAsD;IAExE,YAAY,GAAQ,EAAE,IAA6B;QACjD,MAAM,EACJ,IAAI,EACJ,SAAS,GAAG,IAAI,EAChB,cAAc,EACd,OAAO,EAC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AAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ;wBACrC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,0BAA0B;oBACvE,CAAC;oBACD,IAAI,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;wBAC/B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;oBAC1D,CAAC;gBACH,CAAC;gBACD,MAAM;YACR;gBACE,OAAO,IAAI,CAAC,CAAC,gDAAgD;QACjE,CAAC;QACD,yEAAyE;QACzE,6EAA6E;QAC7E,sEAAsE;QACtE,IAAI,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yrby-client",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "JavaScript client for the yrby y-websocket protocol: a ready-made ActionCable/AnyCable provider, a transport-agnostic protocol session (sync steps, encode/decode, awareness), and a reliable-delivery core (ack-tracked queue, sync-since-last-ack, retransmit + reconnect replay). Written in TypeScript with bundled types; ESM + CommonJS, usable from plain JS.",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
@@ -8,19 +8,34 @@
8
8
  "types": "./dist/index.d.ts",
9
9
  "exports": {
10
10
  ".": {
11
- "types": "./dist/index.d.ts",
12
- "import": "./dist/index.js",
13
- "require": "./dist/cjs/index.js"
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/cjs/index.d.ts",
17
+ "default": "./dist/cjs/index.js"
18
+ }
14
19
  },
15
20
  "./reliable": {
16
- "types": "./dist/reliable_sync.d.ts",
17
- "import": "./dist/reliable_sync.js",
18
- "require": "./dist/cjs/reliable_sync.js"
21
+ "import": {
22
+ "types": "./dist/reliable_sync.d.ts",
23
+ "default": "./dist/reliable_sync.js"
24
+ },
25
+ "require": {
26
+ "types": "./dist/cjs/reliable_sync.d.ts",
27
+ "default": "./dist/cjs/reliable_sync.js"
28
+ }
19
29
  },
20
30
  "./base64": {
21
- "types": "./dist/base64.d.ts",
22
- "import": "./dist/base64.js",
23
- "require": "./dist/cjs/base64.js"
31
+ "import": {
32
+ "types": "./dist/base64.d.ts",
33
+ "default": "./dist/base64.js"
34
+ },
35
+ "require": {
36
+ "types": "./dist/cjs/base64.d.ts",
37
+ "default": "./dist/cjs/base64.js"
38
+ }
24
39
  }
25
40
  },
26
41
  "files": [