statewire 0.23.0 → 0.24.1

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.
Files changed (43) hide show
  1. package/dist/client/core.d.ts +4 -3
  2. package/dist/client/core.d.ts.map +1 -1
  3. package/dist/client/core.js +56 -45
  4. package/dist/client/core.js.map +1 -1
  5. package/dist/client/session.d.ts +56 -12
  6. package/dist/client/session.d.ts.map +1 -1
  7. package/dist/client/session.js +632 -260
  8. package/dist/client/session.js.map +1 -1
  9. package/dist/client/sessionStore.d.ts +1 -0
  10. package/dist/client/sessionStore.d.ts.map +1 -1
  11. package/dist/client/sessionStore.js +1 -0
  12. package/dist/client/sessionStore.js.map +1 -1
  13. package/dist/host/host.d.ts +6 -5
  14. package/dist/host/host.d.ts.map +1 -1
  15. package/dist/host/host.js.map +1 -1
  16. package/dist/indexedDb.d.ts +15 -0
  17. package/dist/indexedDb.d.ts.map +1 -0
  18. package/dist/indexedDb.js +171 -0
  19. package/dist/indexedDb.js.map +1 -0
  20. package/dist/statewire.d.ts +117 -59
  21. package/dist/statewire.d.ts.map +1 -1
  22. package/dist/statewire.js +13 -25
  23. package/dist/statewire.js.map +1 -1
  24. package/dist/storage.d.ts +42 -0
  25. package/dist/storage.d.ts.map +1 -1
  26. package/dist/storage.js +387 -125
  27. package/dist/storage.js.map +1 -1
  28. package/dist/transports/remote.d.ts.map +1 -1
  29. package/dist/transports/remote.js +7 -9
  30. package/dist/transports/remote.js.map +1 -1
  31. package/dist/types.d.ts +6 -7
  32. package/dist/types.d.ts.map +1 -1
  33. package/dist/types.js.map +1 -1
  34. package/package.json +2 -1
  35. package/src/client/core.ts +81 -64
  36. package/src/client/session.ts +886 -424
  37. package/src/client/sessionStore.ts +2 -0
  38. package/src/host/host.ts +10 -3
  39. package/src/indexedDb.ts +167 -0
  40. package/src/statewire.ts +133 -86
  41. package/src/storage.ts +548 -112
  42. package/src/transports/remote.ts +13 -14
  43. package/src/types.ts +6 -7
@@ -18,9 +18,6 @@ export declare class StatewireClient<TState, TCommands extends Statewire.Command
18
18
  invoke(protocol: string, method: string, params: readonly unknown[], options?: StatewireClient.InvokeOptions): Promise<unknown>;
19
19
  setContext(protocol: string, value: Statewire.Context): void;
20
20
  get isBusy(): boolean;
21
- get failed(): readonly StatewireClient.FailedCommand[];
22
- retryFailed(entry: StatewireClient.FailedCommand): Promise<unknown>;
23
- discardFailed(entry: StatewireClient.FailedCommand): void;
24
21
  get outbox(): StatewireClient.Outbox;
25
22
  subscribe(listener: () => void): () => void;
26
23
  dispose(): void;
@@ -51,13 +48,18 @@ export declare namespace StatewireClient {
51
48
  onStateChange?: (state: NonNullable<TState>, ctx: {
52
49
  changes: Statewire.Changes;
53
50
  }) => void;
51
+ /**
52
+ * queued, posted and applied updates are best-effort and in memory. A
53
+ * durable session persists each `settled` update before the command leaves
54
+ * the record and delivers it to one sharer at a time: at-least-once under
55
+ * the same `id`, acked once the returned promise resolves; a pending
56
+ * delivery blocks later ones for the same session.
57
+ */
54
58
  onCommandChange?: (update: Statewire.CommandUpdate<TCommands>, ctx: {
55
59
  state: NonNullable<TState>;
56
- }) => void;
60
+ }) => unknown;
57
61
  onConnectionChange?: (connection: Connection) => void;
58
62
  onError?: (error: ConnectionError) => void;
59
- /** Drops a retained failed entry once a canonical snapshot shows its effect landed; checked against each new snapshot. */
60
- failureCovered?: (state: NonNullable<TState>, entry: FailedCommand) => boolean;
61
63
  };
62
64
  type Helpers<TState, TCommands extends Statewire.Commands = Statewire.Commands> = {
63
65
  /** The statewire's state type — remote statewires include `undefined` until the first attach snapshot applies. */
@@ -72,24 +74,42 @@ export declare namespace StatewireClient {
72
74
  commands: Statewire.CommandsProxy<TCommands>;
73
75
  /** Negation of the server's broadcast idle level (a transport without idle is always busy). */
74
76
  isBusy: boolean;
75
- /** Non-accepted sends retained in the session record; reload with it. */
76
- failed: readonly FailedCommand[];
77
- /** Re-enqueues the entry's command on fresh clocks and removes the entry. */
78
- retryFailed: (entry: FailedCommand) => Promise<unknown>;
79
- /** Removes the entry. */
80
- discardFailed: (entry: FailedCommand) => void;
81
- /** Commands queued without a seq yet; a transport without a session has an empty outbox whose methods throw. */
77
+ /** Unsettled commands in queue order; a transport without a session has an empty outbox whose methods throw. */
82
78
  outbox: Outbox;
83
79
  };
84
- /** The queued commands no sharer has stamped yet, and the operations on them. */
80
+ /** The unsettled commands across sharers, and the operations on them; every verb throws `outbox: no entry <id>` or `outbox: <id> is in flight`. */
85
81
  type Outbox = {
86
82
  readonly entries: readonly OutboxEntry[];
87
- /** Keeps the entry out of every flush until released; `meta` persists with it. */
88
- hold: (entry: OutboxEntry, meta?: unknown) => Promise<"held" | "stamped">;
89
- /** Lets the next flush stamp the entry. */
90
- release: (entry: OutboxEntry) => Promise<"released" | "stamped">;
91
- /** Drops the entry; its send rejects `{ fate: "aborted", cause: "removed" }`. */
92
- remove: (entry: OutboxEntry) => Promise<"removed" | "stamped">;
83
+ /** queued → held: no flush stamps it until released. */
84
+ hold: (id: string) => void;
85
+ /** held → queued; settles with the command's outcome. */
86
+ release: (id: string) => Promise<unknown>;
87
+ /** Drops a queued or held entry; its pending send rejects `{ fate: "aborted", cause: "removed" }`. */
88
+ remove: (id: string) => void;
89
+ /** Patches the entry under the storage lock; `fn` gets the current entry. */
90
+ update: (id: string, fn: (entry: OutboxEntry) => OutboxPatch) => void;
91
+ /** Adds a command no send awaits, at the lane's tail or next to `after`/`before`; returns its id. */
92
+ insert: (entry: OutboxInsert) => string;
93
+ };
94
+ type OutboxPatch = {
95
+ held?: boolean;
96
+ localMeta?: unknown;
97
+ command?: {
98
+ params: readonly unknown[];
99
+ };
100
+ };
101
+ type OutboxInsert = {
102
+ /** The `settled` update this re-inserts: the insert acks it in the same write, so a redelivery never inserts twice. */
103
+ from?: string;
104
+ protocol: string;
105
+ command: {
106
+ method: string;
107
+ params: readonly unknown[];
108
+ };
109
+ held?: boolean;
110
+ localMeta?: unknown;
111
+ after?: string;
112
+ before?: string;
93
113
  };
94
114
  /** Connection lifecycle and whether its current state warrants a problem indicator. */
95
115
  type ConnectionState = {
@@ -130,20 +150,19 @@ export declare namespace StatewireClient {
130
150
  */
131
151
  type Optimistic<TState, TCommands extends Statewire.Commands = Statewire.Commands> = (draft: TState, command: Statewire.Command<TCommands>, ctx: OptimisticContext) => void;
132
152
  type OptimisticContext = {
153
+ /** Enqueue time. */
133
154
  ts: number;
134
155
  /** Absent while the command waits in the outbox. */
135
156
  seq?: number;
136
157
  clientId?: string;
137
- /** The outbox hold, with its meta; null when not held. */
138
- held: null | {
139
- meta: unknown;
140
- };
158
+ state: OutboxState;
159
+ localMeta: unknown;
141
160
  };
142
161
  type InvokeOptions = {
143
- /** Enqueue the command already held, with the hold's meta. */
144
- hold?: {
145
- meta?: unknown;
146
- };
162
+ /** Enqueue the command held. */
163
+ hold?: boolean;
164
+ /** Client-only data persisted with the entry, never sent. */
165
+ localMeta?: unknown;
147
166
  };
148
167
  /**
149
168
  * Why an entry is about to be stamped: "enqueue" = queued since the last
@@ -152,7 +171,7 @@ export declare namespace StatewireClient {
152
171
  * hold was released.
153
172
  */
154
173
  type FlushReason = "enqueue" | "reconnect" | "reload" | "release";
155
- /** Runs in the sharer about to stamp, under the storage lock, once per reason; `outbox.hold` and `outbox.remove` on these entries apply synchronously. */
174
+ /** Runs in the sharer about to stamp, under the storage lock, once per reason; outbox verbs on these entries apply synchronously before stamping. */
156
175
  type OnFlush = (flush: {
157
176
  commands: readonly OutboxEntry[];
158
177
  reason: FlushReason;
@@ -194,33 +213,35 @@ export declare namespace StatewireClient {
194
213
  cause: "server";
195
214
  } | {
196
215
  fate: "aborted";
197
- cause: "unmount" | "stream-gone" | "session-lost" | "removed";
216
+ cause: "unmount" | "stream-gone" | "session-lost" | "removed" | "quota";
198
217
  predecessorLost?: true;
199
218
  } | {
200
219
  fate: "lost";
201
220
  cause: "unmount" | "stream-gone" | "session-lost";
202
221
  };
203
- /** Held commands a proven record gap settled `{fate: "lost", cause: "session-lost"}`; return "requeue" to re-enqueue them on the reset clocks. */
222
+ /**
223
+ * Temporary and discouraged; removed in a later release. A proven record gap
224
+ * settles the lane's commands `{ fate: "lost", cause: "session-lost" }` and
225
+ * drops its outbox. Returning "requeue" instead re-enqueues this client's
226
+ * lost stamps (fresh ids, at the tail) and keeps the outbox.
227
+ */
204
228
  type OnSessionLost = (pending: ReadonlyArray<{
205
- id?: string;
229
+ id: string;
206
230
  method: string;
207
231
  params: readonly unknown[];
208
232
  ts: number;
209
233
  seq: number;
210
234
  clientId?: string;
211
235
  }>) => "requeue" | "drop";
212
- /** A non-accepted send retained for the user: the wire statement, its failure, and its original clocks. */
213
- type FailedCommand = {
214
- readonly protocol: string;
215
- readonly produced?: SessionCommand["produced"];
216
- readonly command: string;
217
- readonly params: readonly unknown[];
218
- readonly meta?: unknown;
219
- readonly failure: SendFailure;
220
- readonly ts: number;
221
- readonly seq: number;
222
- };
223
- /** A queued command without a seq, as persisted. */
236
+ /** Reports a deprecated code path firing, so its use can be measured before removal. */
237
+ type OnDeprecatedPath = (event: {
238
+ kind: "session-lost-requeue";
239
+ count: number;
240
+ }) => void;
241
+ /** Delivers one durable `settled` update; acked once the returned promise resolves. */
242
+ type OnSettled = (update: Statewire.CommandUpdate) => unknown;
243
+ type OutboxState = "queued" | "held" | "sending";
244
+ /** A queued command as persisted. */
224
245
  type OutboxCommand = {
225
246
  id: string;
226
247
  produced?: {
@@ -229,34 +250,38 @@ export declare namespace StatewireClient {
229
250
  };
230
251
  method: string;
231
252
  params: unknown[];
253
+ /** Encoding of non-JSON params. */
232
254
  meta?: unknown;
255
+ /** Enqueue time. */
233
256
  ts: number;
234
257
  /** Present while held. */
235
- hold?: {
236
- meta?: unknown;
237
- };
258
+ held?: true;
259
+ localMeta?: unknown;
238
260
  /** Its hold was released; the next flush reports reason "release". */
239
261
  released?: true;
240
262
  /** The enqueuing sharer's `SessionStorage.owner.id` (shared storage only). */
241
263
  by?: string;
242
264
  };
243
- /** A queued command without a seq, in queue order. */
265
+ /** An unsettled command, in queue order. */
244
266
  type OutboxEntry = {
245
267
  readonly id: string;
246
268
  readonly protocol: string;
247
269
  readonly command: {
248
- method: string;
249
- params: readonly unknown[];
250
- };
251
- /** The hold, with its meta; null when not held. */
252
- readonly held: null | {
253
- readonly meta: unknown;
270
+ readonly method: string;
271
+ readonly params: readonly unknown[];
254
272
  };
273
+ /** Enqueue time. */
274
+ readonly ts: number;
275
+ readonly state: OutboxState;
276
+ /** Client-only, persisted, never sent. */
277
+ readonly localMeta: unknown;
278
+ /** False when the entry lives in page memory only. */
279
+ readonly durable: boolean;
255
280
  };
256
- /** Whether `entry` may move ahead of `ahead`, a held entry or one waiting behind a hold. */
281
+ /** Whether `entry` may move ahead of `ahead`, a held entry or one waiting behind one. */
257
282
  type CanOvertake = (entry: OutboxEntry, ahead: OutboxEntry) => boolean;
258
283
  /** A stamped command as persisted while un-durable: its lane seq, the sharer that stamped it, plus the wire statement. */
259
- type SessionCommand = Omit<OutboxCommand, "hold" | "released"> & {
284
+ type SessionCommand = Omit<OutboxCommand, "held" | "released"> & {
260
285
  seq: number;
261
286
  /** The stamping sharer's `SessionStorage.owner.id` (shared storage only). */
262
287
  owner?: string;
@@ -266,15 +291,32 @@ export declare namespace StatewireClient {
266
291
  nextSeq: number;
267
292
  commands: readonly SessionCommand[];
268
293
  outbox?: readonly OutboxCommand[];
269
- /** Entries another sharer removed, kept until their enqueuer (`by`) rejects them or is gone (shared storage only). */
294
+ /** Entries another sharer settled unsent, kept until their enqueuer (`by`) rejects them or is gone (shared storage only); no failure means removed. */
270
295
  removed?: readonly {
271
296
  id: string;
272
297
  by: string;
298
+ failure?: SendFailure;
273
299
  }[];
274
300
  /** Terminal verdicts parked for the sharer that minted the seq (shared storage only). */
275
301
  verdicts?: readonly SessionVerdict[];
276
- /** Non-accepted sends retained for the user; survive record rebases and resets. */
277
- failed?: readonly FailedCommand[];
302
+ /** Terminal `settled` updates awaiting their `onCommandChange` ack. */
303
+ inbox?: readonly StoredSettled[];
304
+ };
305
+ /** A terminal update as persisted: the stored command plus its outcome. */
306
+ type StoredSettled = {
307
+ id: string;
308
+ method: string;
309
+ params: unknown[];
310
+ meta?: unknown;
311
+ ts: number;
312
+ seq?: number;
313
+ localMeta?: unknown;
314
+ /** The accepted result, encoded as a one-element param list. */
315
+ result?: {
316
+ value: unknown[];
317
+ meta?: unknown;
318
+ };
319
+ failure?: SendFailure;
278
320
  };
279
321
  /** The persisted session: the client identity plus one lane per durable protocol. */
280
322
  type SessionRecord = {
@@ -294,6 +336,10 @@ export declare namespace StatewireClient {
294
336
  };
295
337
  /** Session storage seam with optional asynchronous hydration and persistence. */
296
338
  type SessionStorage = {
339
+ /** False when the record lives in page memory only. */
340
+ durable?: boolean;
341
+ /** Re-reads the stored record; awaited under `lock` when present. */
342
+ read?: () => Promise<SessionRecord | null>;
297
343
  /** Resolves when a synchronous load can return the hydrated record. */
298
344
  ready?: Promise<void>;
299
345
  /** Resolves after all queued saves are persisted; awaited before sending statements. */
@@ -311,6 +357,16 @@ export declare namespace StatewireClient {
311
357
  id: string;
312
358
  whenGone: (id: string, signal: AbortSignal) => Promise<void>;
313
359
  };
360
+ /** Exclusive across sharers while a durable `settled` update is delivered; required alongside `lock`. */
361
+ notifyLock?: <T>(fn: () => Promise<T>) => Promise<T>;
362
+ /** Reports failure notices the session dropped. */
363
+ onEvict?: (event: Omit<EvictEvent, "key">) => void;
364
+ };
365
+ type EvictEvent = {
366
+ key: string;
367
+ reason: "expired" | "overflow" | "quota" | "inbox";
368
+ /** The undelivered `settled` updates that went with it. */
369
+ dropped: readonly Statewire.CommandUpdate[];
314
370
  };
315
371
  /** Static headers, or a resolver invoked per request/attach; `staleAuth` is true right after an auth rejection. */
316
372
  type ConnectionError = Error & {
@@ -327,6 +383,7 @@ export declare namespace StatewireClient {
327
383
  headers?: HeadersOption;
328
384
  fetch?: typeof globalThis.fetch;
329
385
  onSessionLost?: OnSessionLost;
386
+ onDeprecatedPath?: OnDeprecatedPath;
330
387
  onFlush?: OnFlush;
331
388
  /** Per protocol: lets an outbox entry move ahead of held or waiting ones; default never. */
332
389
  canOvertake?: Readonly<Record<string, CanOvertake>>;
@@ -345,6 +402,7 @@ export declare namespace StatewireClient {
345
402
  query?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
346
403
  webSocket?: new (url: string, protocols?: string | string[]) => WebSocket;
347
404
  onSessionLost?: OnSessionLost;
405
+ onDeprecatedPath?: OnDeprecatedPath;
348
406
  onFlush?: OnFlush;
349
407
  /** Per protocol: lets an outbox entry move ahead of held or waiting ones; default never. */
350
408
  canOvertake?: Readonly<Record<string, CanOvertake>>;
@@ -1 +1 @@
1
- {"version":3,"file":"statewire.d.ts","sourceRoot":"","sources":["../src/statewire.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,4BAAyB;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,2BAAwB;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAe;AAkB5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAgB;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,+BAA4B;AA6CpD,eAAO,MAAM,YAAY,GACvB,MAAM,EACN,SAAS,SAAS,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,EAEzD,SAAS,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,KAClD,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS,CAgK3C,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,MAAM,EACN,SAAS,SAAS,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,EAEzD,SAAS,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,KAClD,eAAe,CAAC,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CACT,CAAC;AA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EAAE,KAAK,SAAS,CAAC;QAC1E,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;QACpC,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,4FAA4F;QAC5F,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;QACpD,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;QAC5C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;QAC3C,sEAAsE;QACtE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;KACrB,CAAC;CACH"}
package/dist/statewire.js CHANGED
@@ -16,14 +16,18 @@ const useStatewire = (options) => {
16
16
  ...options.applicationProtocols !== void 0 && { applicationProtocols: options.applicationProtocols },
17
17
  ...options.keyPrefixes !== void 0 && { keyPrefixes: options.keyPrefixes }
18
18
  };
19
+ const handlesUpdates = options.onCommandChange !== void 0;
20
+ const coreRef = useRef(null);
19
21
  const link = useMemo(() => ({
20
22
  ...options.isNew === void 0 ? {} : { isNew: options.isNew },
21
23
  ...options.context === void 0 ? {} : { context: options.context },
22
- ...options.canOvertake === void 0 ? {} : { canOvertake: options.canOvertake }
24
+ ...options.canOvertake === void 0 ? {} : { canOvertake: options.canOvertake },
25
+ ...handlesUpdates && { onSettled: (update) => latest.current.onCommandChange?.(update, { state: coreRef.current?.getState() }) }
23
26
  }), [
24
27
  options.isNew,
25
28
  options.context,
26
- options.canOvertake
29
+ options.canOvertake,
30
+ handlesUpdates
27
31
  ]);
28
32
  const value = useResource(SessionTransport({
29
33
  transport: options.transport,
@@ -39,14 +43,14 @@ const useStatewire = (options) => {
39
43
  for (const [protocol_0, context] of Object.entries(current.context)) localContext(protocol_0, context);
40
44
  }, [options.context, localContext]);
41
45
  const core = useStatewireCore(() => latest.current, value);
46
+ coreRef.current = core;
42
47
  useEffect(() => core.rematerialize(), [core, options.materializeKey]);
43
48
  const [subscribe] = useState(() => (listener) => core.subscribe(() => flushTapSync(listener)));
44
49
  const state = useSyncExternalStore(subscribe, core.getState, core.getState);
45
50
  const isBusy = useSyncExternalStore(subscribe, core.getBusy, core.getBusy);
46
- const failed = useSyncExternalStore(subscribe, core.getFailed, core.getFailed);
47
51
  const outboxEntries = useSyncExternalStore(subscribe, core.getOutbox, core.getOutbox);
48
52
  const connection = value.connection ?? CONNECTED_CONNECTION;
49
- const { documents: source, selection, invoke: transportInvoke, setContext: transportSetContext, failures: transportFailures, outbox: transportOutbox } = value;
53
+ const { documents: source, selection, invoke: transportInvoke, setContext: transportSetContext, outbox: transportOutbox } = value;
50
54
  const invoke = useCallback((protocol_1, method, params, options_0) => {
51
55
  if (!transportInvoke) throw new Error("statewire: transport does not support protocol commands");
52
56
  return transportInvoke(protocol_1, method, params, options_0);
@@ -56,10 +60,6 @@ const useStatewire = (options) => {
56
60
  transportSetContext(protocol_2, value_0);
57
61
  }, [transportSetContext]);
58
62
  return useMemo(() => {
59
- const failures = () => {
60
- if (!transportFailures) throw new Error("statewire: this transport has no failed-send lane");
61
- return transportFailures;
62
- };
63
63
  const outbox = () => {
64
64
  if (!transportOutbox) throw new Error("statewire: this transport has no outbox");
65
65
  return transportOutbox;
@@ -74,14 +74,13 @@ const useStatewire = (options) => {
74
74
  connection,
75
75
  commands: core.commands,
76
76
  isBusy,
77
- failed,
78
- retryFailed: (entry) => failures().retry(entry),
79
- discardFailed: (entry_0) => failures().discard(entry_0),
80
77
  outbox: {
81
78
  entries: outboxEntries,
82
- hold: (entry_1, meta) => outbox().hold(entry_1, meta),
83
- release: (entry_2) => outbox().release(entry_2),
84
- remove: (entry_3) => outbox().remove(entry_3)
79
+ hold: (id) => outbox().hold(id),
80
+ release: (id_0) => outbox().release(id_0),
81
+ remove: (id_1) => outbox().remove(id_1),
82
+ update: (id_2, fn) => outbox().update(id_2, fn),
83
+ insert: (entry) => outbox().insert(entry)
85
84
  }
86
85
  };
87
86
  }, [
@@ -89,13 +88,11 @@ const useStatewire = (options) => {
89
88
  transportOutbox,
90
89
  state,
91
90
  isBusy,
92
- failed,
93
91
  connection,
94
92
  core,
95
93
  source,
96
94
  selection,
97
95
  invoke,
98
- transportFailures,
99
96
  setContext
100
97
  ]);
101
98
  };
@@ -131,15 +128,6 @@ var StatewireClient = class {
131
128
  get isBusy() {
132
129
  return this.root.getValue().isBusy;
133
130
  }
134
- get failed() {
135
- return this.root.getValue().failed;
136
- }
137
- retryFailed(entry) {
138
- return this.root.getValue().retryFailed(entry);
139
- }
140
- discardFailed(entry) {
141
- this.root.getValue().discardFailed(entry);
142
- }
143
131
  get outbox() {
144
132
  return this.root.getValue().outbox;
145
133
  }
@@ -1 +1 @@
1
- {"version":3,"file":"statewire.js","names":["StatewireDocuments","StatewireProtocol","StatewireHost","useCallback","useEffect","useMemo","useRef","useState","useSyncExternalStore","createTapRoot","flushTapSync","resource","useContextProvider","useResource","useResources","withKey","ResourceElement","CONNECTED_CONNECTION","useStatewireCore","Statewire","TERMINAL","DocumentStorageContext","LinkContext","ProtocolContext","SessionStorageContext","useSessionTransport","transport","session","documents","protocol","link","StatewireClient","SessionStorage","Storage","Options","isNew","context","Readonly","Record","Context","canOvertake","CanOvertake","SessionTransport","useStatewire","Commands","options","TState","TCommands","Helpers","latest","current","storage","undefined","wireVersion","applicationProtocols","keyPrefixes","value","localContext","connection","setContext","Object","entries","core","rematerialize","materializeKey","subscribe","listener","state","getState","isBusy","getBusy","failed","getFailed","outboxEntries","getOutbox","source","selection","invoke","transportInvoke","transportSetContext","failures","transportFailures","outbox","transportOutbox","method","params","InvokeOptions","Error","NonNullable","commands","CommandsProxy","retryFailed","entry","FailedCommand","retry","discardFailed","discard","hold","meta","release","remove","StatewireResource","root","disposed","constructor","ClientRoot","getValue","Connection","Source","Selection","Promise","Outbox","dispose","unmount","Range","Offer","initialState","optimistic","Optimistic","materialize","Materialize","onStateChange","ctx","changes","Changes","onCommandChange","update","CommandUpdate","onConnectionChange","onError","error","ConnectionError","failureCovered","OutboxEntry","ConnectionState","status","reason","degraded","attempt","cause","code","nextRetryAt","lastError","message","payload","reconnect","ConnectionStatus","draft","command","Command","OptimisticContext","ts","seq","clientId","held","FlushReason","OnFlush","flush","SendFailure","fate","predecessorLost","OnSessionLost","pending","ReadonlyArray","id","produced","SessionCommand","failure","OutboxCommand","wire","protocols","released","by","ahead","Omit","owner","SessionLane","nextSeq","removed","verdicts","SessionVerdict","SessionRecord","lanes","type","ready","load","save","record","migrate","lock","fn","T","whenGone","signal","AbortSignal","fin","Fin","HeadersOption","HeadersInit","staleAuth","HttpOptions","sessionStore","url","headers","fetch","globalThis","onSessionLost","onFlush","onChange","onDone","WebsocketOptions","query","webSocket","WebSocket"],"sources":["../src/statewire.ts"],"sourcesContent":["import type { StatewireDocuments } from \"./wire/documents\";\nimport type { StatewireProtocol } from \"./wire/protocol\";\nimport type { StatewireHost } from \"./host\";\nimport {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\nimport {\n createTapRoot,\n flushTapSync,\n resource,\n useContextProvider,\n useResource,\n useResources,\n withKey,\n} from \"@assistant-ui/tap\";\nimport type { ResourceElement } from \"@assistant-ui/tap\";\nimport { CONNECTED_CONNECTION, useStatewireCore } from \"./client/core\";\nimport type { Statewire } from \"./types\";\nimport type { TERMINAL } from \"./client/connection\";\nimport {\n DocumentStorageContext,\n LinkContext,\n ProtocolContext,\n SessionStorageContext,\n} from \"./client/sessionStore\";\n\nconst useSessionTransport = ({\n transport,\n session,\n documents,\n protocol,\n link,\n}: {\n transport: ResourceElement<Statewire<any, any>>;\n session: StatewireClient.SessionStorage | undefined;\n documents: StatewireDocuments.Storage | undefined;\n protocol: StatewireProtocol.Options;\n link: {\n isNew?: boolean | undefined;\n context?: Readonly<Record<string, Statewire.Context>> | undefined;\n canOvertake?:\n | Readonly<Record<string, StatewireClient.CanOvertake>>\n | undefined;\n };\n}): Statewire<unknown> =>\n useContextProvider(SessionStorageContext, session, () =>\n // oxlint-disable-next-line react-hooks/rules-of-hooks\n useContextProvider(DocumentStorageContext, documents, () =>\n // oxlint-disable-next-line react-hooks/rules-of-hooks\n useContextProvider(ProtocolContext, protocol, () =>\n // oxlint-disable-next-line react-hooks/rules-of-hooks\n useContextProvider(LinkContext, link, () =>\n // oxlint-disable-next-line react-hooks/rules-of-hooks\n useResource(transport),\n ),\n ),\n ),\n );\n\n// The transport owns the session; it reads the storage off the context this\n// wrapper's own fiber provides, so plain-React callers get a provider too.\nconst SessionTransport = resource(useSessionTransport);\n\nexport const useStatewire = <\n TState,\n TCommands extends Statewire.Commands = Statewire.Commands,\n>(\n options: StatewireClient.Options<TState, TCommands>,\n): StatewireClient.Helpers<TState, TCommands> => {\n const latest = useRef(options);\n latest.current = options;\n\n const session = useResources(\n options.storage?.session !== undefined\n ? [withKey(\"session\", options.storage.session)]\n : [],\n )[0];\n const documents = useResources(\n options.storage?.documents === undefined\n ? []\n : [withKey(\"documents\", options.storage.documents)],\n )[0];\n const protocol: StatewireProtocol.Options = {\n ...(options.protocol !== undefined && { protocol: options.protocol }),\n ...(options.wireVersion !== undefined && {\n wireVersion: options.wireVersion,\n }),\n ...(options.applicationProtocols !== undefined && {\n applicationProtocols: options.applicationProtocols,\n }),\n ...(options.keyPrefixes !== undefined && {\n keyPrefixes: options.keyPrefixes,\n }),\n };\n const link = useMemo(\n () => ({\n ...(options.isNew === undefined ? {} : { isNew: options.isNew }),\n ...(options.context === undefined ? {} : { context: options.context }),\n ...(options.canOvertake === undefined\n ? {}\n : { canOvertake: options.canOvertake }),\n }),\n [options.isNew, options.context, options.canOvertake],\n );\n const value = useResource(\n SessionTransport({\n transport: options.transport,\n session,\n documents,\n protocol,\n link,\n }),\n );\n const localContext =\n value.connection === undefined ? value.setContext : undefined;\n useEffect(() => {\n const current = latest.current;\n if (localContext === undefined || current.context === undefined) return;\n for (const [protocol, context] of Object.entries(current.context))\n localContext(protocol, context);\n }, [options.context, localContext]);\n const core = useStatewireCore(() => latest.current, value);\n useEffect(() => core.rematerialize(), [core, options.materializeKey]);\n const [subscribe] = useState(\n () => (listener: () => void) =>\n core.subscribe(() => flushTapSync(listener)),\n );\n\n const state = useSyncExternalStore(\n subscribe,\n core.getState,\n core.getState,\n ) as TState;\n const isBusy = useSyncExternalStore(subscribe, core.getBusy, core.getBusy);\n const failed = useSyncExternalStore(\n subscribe,\n core.getFailed,\n core.getFailed,\n );\n const outboxEntries = useSyncExternalStore(\n subscribe,\n core.getOutbox,\n core.getOutbox,\n );\n const connection = value.connection ?? CONNECTED_CONNECTION;\n const {\n documents: source,\n selection,\n invoke: transportInvoke,\n setContext: transportSetContext,\n failures: transportFailures,\n outbox: transportOutbox,\n } = value;\n\n const invoke = useCallback(\n (\n protocol: string,\n method: string,\n params: readonly unknown[],\n options?: StatewireClient.InvokeOptions,\n ) => {\n if (!transportInvoke)\n throw new Error(\n \"statewire: transport does not support protocol commands\",\n );\n return transportInvoke(protocol, method, params, options);\n },\n [transportInvoke],\n );\n\n const setContext = useCallback(\n (protocol: string, value: Statewire.Context) => {\n if (!transportSetContext)\n throw new Error(\"statewire: transport does not support context\");\n transportSetContext(protocol, value);\n },\n [transportSetContext],\n );\n\n return useMemo(() => {\n const failures = (): NonNullable<typeof transportFailures> => {\n if (!transportFailures) {\n throw new Error(\"statewire: this transport has no failed-send lane\");\n }\n return transportFailures;\n };\n const outbox = (): NonNullable<typeof transportOutbox> => {\n if (!transportOutbox) {\n throw new Error(\"statewire: this transport has no outbox\");\n }\n return transportOutbox;\n };\n return {\n state,\n documents: source,\n selection,\n invoke,\n setContext,\n getState: core.getState as () => TState,\n connection,\n commands: core.commands as Statewire.CommandsProxy<TCommands>,\n isBusy,\n failed,\n retryFailed: (entry: StatewireClient.FailedCommand) =>\n failures().retry(entry),\n discardFailed: (entry: StatewireClient.FailedCommand) =>\n failures().discard(entry),\n outbox: {\n entries: outboxEntries,\n hold: (entry, meta) => outbox().hold(entry, meta),\n release: (entry) => outbox().release(entry),\n remove: (entry) => outbox().remove(entry),\n },\n };\n }, [\n outboxEntries,\n transportOutbox,\n state,\n isBusy,\n failed,\n connection,\n core,\n source,\n selection,\n invoke,\n transportFailures,\n setContext,\n ]);\n};\n\nexport const StatewireResource = <\n TState,\n TCommands extends Statewire.Commands = Statewire.Commands,\n>(\n options: StatewireClient.Options<TState, TCommands>,\n): ResourceElement<StatewireClient.Helpers<TState, TCommands>> =>\n resource(useStatewire<TState, TCommands>)(options);\n\nexport class StatewireClient<\n TState,\n TCommands extends Statewire.Commands = Statewire.Commands,\n> {\n private readonly root;\n private disposed = false;\n\n constructor(options: StatewireClient.Options<TState, TCommands>) {\n const ClientRoot = () => useStatewire<TState, TCommands>(options);\n this.root = createTapRoot(ClientRoot);\n }\n\n get state(): TState {\n return this.root.getValue().getState();\n }\n\n get connection(): StatewireClient.Connection {\n return this.root.getValue().connection;\n }\n\n get commands(): Statewire.CommandsProxy<TCommands> {\n return this.root.getValue().commands;\n }\n\n get documents(): StatewireDocuments.Source | undefined {\n return this.root.getValue().documents;\n }\n get selection(): StatewireProtocol.Selection | undefined {\n return this.root.getValue().selection;\n }\n invoke(\n protocol: string,\n method: string,\n params: readonly unknown[],\n options?: StatewireClient.InvokeOptions,\n ): Promise<unknown> {\n return this.root.getValue().invoke(protocol, method, params, options);\n }\n setContext(protocol: string, value: Statewire.Context): void {\n this.root.getValue().setContext(protocol, value);\n }\n get isBusy(): boolean {\n return this.root.getValue().isBusy;\n }\n\n get failed(): readonly StatewireClient.FailedCommand[] {\n return this.root.getValue().failed;\n }\n\n retryFailed(entry: StatewireClient.FailedCommand): Promise<unknown> {\n return this.root.getValue().retryFailed(entry);\n }\n\n discardFailed(entry: StatewireClient.FailedCommand): void {\n this.root.getValue().discardFailed(entry);\n }\n\n get outbox(): StatewireClient.Outbox {\n return this.root.getValue().outbox;\n }\n\n subscribe(listener: () => void): () => void {\n return this.root.subscribe(listener);\n }\n\n dispose(): void {\n if (this.disposed) return;\n this.disposed = true;\n this.root.unmount();\n }\n}\n\nexport namespace StatewireClient {\n export type Options<\n TState,\n TCommands extends Statewire.Commands = Statewire.Commands,\n > = {\n protocol?: string;\n context?: Readonly<Record<string, Statewire.Context>>;\n keyPrefixes?: Readonly<Record<string, readonly string[]>>;\n wireVersion?: StatewireProtocol.Range;\n applicationProtocols?: readonly StatewireProtocol.Offer[] | \"*\";\n transport: ResourceElement<Statewire<TState, TCommands>>;\n /** The session does not exist on the server yet: the transport's first attach waits for the first command send; the transport's own `isNew` wins. */\n isNew?: boolean;\n /** Per protocol: lets an outbox entry move ahead of held or waiting ones; the transport's own `canOvertake` wins. */\n canOvertake?: Readonly<Record<string, CanOvertake>>;\n /** Durable session: the mounted storage holds this client's lane identity and its un-durable commands, which resend on the next attach. */\n storage?:\n | {\n session?: ResourceElement<SessionStorage> | undefined;\n documents?: ResourceElement<StatewireDocuments.Storage> | undefined;\n }\n | undefined;\n /** Served as the canonical state until the attach snapshot; own commands fold over it. */\n initialState?: TState;\n optimistic?: Optimistic<NonNullable<TState>, TCommands>;\n materialize?: Materialize<NonNullable<TState>>;\n /** Republishes through `materialize` when it changes (`Object.is`); `materialize` itself is read fresh on every publish. */\n materializeKey?: unknown;\n onStateChange?: (\n state: NonNullable<TState>,\n ctx: { changes: Statewire.Changes },\n ) => void;\n onCommandChange?: (\n update: Statewire.CommandUpdate<TCommands>,\n ctx: { state: NonNullable<TState> },\n ) => void;\n onConnectionChange?: (connection: Connection) => void;\n onError?: (error: ConnectionError) => void;\n /** Drops a retained failed entry once a canonical snapshot shows its effect landed; checked against each new snapshot. */\n failureCovered?: (\n state: NonNullable<TState>,\n entry: FailedCommand,\n ) => boolean;\n };\n\n export type Helpers<\n TState,\n TCommands extends Statewire.Commands = Statewire.Commands,\n > = {\n /** The statewire's state type — remote statewires include `undefined` until the first attach snapshot applies. */\n state: TState;\n documents: StatewireDocuments.Source | undefined;\n selection: StatewireProtocol.Selection | undefined;\n setContext: (protocol: string, value: Statewire.Context) => void;\n invoke: (\n protocol: string,\n method: string,\n params: readonly unknown[],\n options?: InvokeOptions,\n ) => Promise<unknown>;\n /** Identity-stable across renders; reads the current canonical state without subscribing the caller. */\n getState: () => TState;\n connection: Connection;\n commands: Statewire.CommandsProxy<TCommands>;\n /** Negation of the server's broadcast idle level (a transport without idle is always busy). */\n isBusy: boolean;\n /** Non-accepted sends retained in the session record; reload with it. */\n failed: readonly FailedCommand[];\n /** Re-enqueues the entry's command on fresh clocks and removes the entry. */\n retryFailed: (entry: FailedCommand) => Promise<unknown>;\n /** Removes the entry. */\n discardFailed: (entry: FailedCommand) => void;\n /** Commands queued without a seq yet; a transport without a session has an empty outbox whose methods throw. */\n outbox: Outbox;\n };\n\n /** The queued commands no sharer has stamped yet, and the operations on them. */\n export type Outbox = {\n readonly entries: readonly OutboxEntry[];\n /** Keeps the entry out of every flush until released; `meta` persists with it. */\n hold: (entry: OutboxEntry, meta?: unknown) => Promise<\"held\" | \"stamped\">;\n /** Lets the next flush stamp the entry. */\n release: (entry: OutboxEntry) => Promise<\"released\" | \"stamped\">;\n /** Drops the entry; its send rejects `{ fate: \"aborted\", cause: \"removed\" }`. */\n remove: (entry: OutboxEntry) => Promise<\"removed\" | \"stamped\">;\n };\n\n /** Connection lifecycle and whether its current state warrants a problem indicator. */\n export type ConnectionState =\n | { status: \"standby\"; reason: \"deferred\" | \"idle\"; degraded: false }\n | { status: \"connecting\"; degraded: false }\n | { status: \"connected\"; degraded: false }\n | {\n status: \"retrying\";\n degraded: true;\n attempt: number;\n /** Backoff details are absent while the retry dial is in flight. */\n cause?: \"dropped\" | \"reconnect\" | \"error\" | \"unauthorized\";\n code?: string;\n nextRetryAt?: number;\n lastError?: string;\n message?: string;\n }\n | {\n status: \"stopped\";\n degraded: true;\n reason:\n | \"gone\"\n | \"forbidden\"\n | \"protocol-error\"\n | \"unauthorized\"\n | \"storage-error\";\n message?: string;\n payload?: unknown;\n };\n export type Connection = ConnectionState & {\n error?: ConnectionError;\n reconnect: () => void;\n };\n export type ConnectionStatus = Connection[\"status\"];\n\n /**\n * Mutate the draft in place; the client records the next state plus the exact\n * changed paths. Re-run against the new base on every rebase.\n */\n export type Optimistic<\n TState,\n TCommands extends Statewire.Commands = Statewire.Commands,\n > = (\n draft: TState,\n command: Statewire.Command<TCommands>,\n ctx: OptimisticContext,\n ) => void;\n\n export type OptimisticContext = {\n ts: number;\n /** Absent while the command waits in the outbox. */\n seq?: number;\n clientId?: string;\n /** The outbox hold, with its meta; null when not held. */\n held: null | { meta: unknown };\n };\n\n export type InvokeOptions = {\n /** Enqueue the command already held, with the hold's meta. */\n hold?: { meta?: unknown };\n };\n\n /**\n * Why an entry is about to be stamped: \"enqueue\" = queued since the last\n * flush, \"reconnect\" = its seq never reached the server and was freed on\n * reattach, \"reload\" = queued before this client mounted, \"release\" = its\n * hold was released.\n */\n export type FlushReason = \"enqueue\" | \"reconnect\" | \"reload\" | \"release\";\n\n /** Runs in the sharer about to stamp, under the storage lock, once per reason; `outbox.hold` and `outbox.remove` on these entries apply synchronously. */\n export type OnFlush = (flush: {\n commands: readonly OutboxEntry[];\n reason: FlushReason;\n }) => void;\n\n /**\n * Mutate the draft to fold client-known facts into the state: server-accepted,\n * still-uncommitted intents (e.g. dispatch records into messages) or the live\n * state of a sibling statewire. Runs after the optimistic folds on every\n * published state; `materializeKey` republishes when the facts change.\n */\n export type Materialize<TState> = (draft: TState) => void;\n\n /**\n * fate: \"aborted\" = never sent (\"removed\" = taken out of the outbox), \"rejected\" = the server refused it\n * (`code` \"unknown-command\" | \"invalid-params\" for the static rejects,\n * code-less for handler rejects), \"lost\" = sent but no verdict will ever\n * arrive — the record is gone (a proven seq gap) or the channel died: it\n * may or may not have run, \"failed\" = the handler ran and threw,\n * \"crashed\" = the handler died involuntarily, \"expired\" = settled —\n * result, rejected, failed, or crashed — but the verdict outlived the\n * server's retention.\n * cause is which channel settled it: \"server\" = the server's answer;\n * the rest are channel deaths the client settled locally.\n */\n export type SendFailure =\n | {\n fate: \"rejected\";\n cause: \"server\";\n code?: string;\n message?: string;\n payload?: unknown;\n }\n | { fate: \"failed\"; cause: \"server\"; message?: string }\n | { fate: \"crashed\"; cause: \"server\" }\n | { fate: \"expired\"; cause: \"server\" }\n | {\n fate: \"aborted\";\n cause: \"unmount\" | \"stream-gone\" | \"session-lost\" | \"removed\";\n predecessorLost?: true;\n }\n | {\n fate: \"lost\";\n cause: \"unmount\" | \"stream-gone\" | \"session-lost\";\n };\n\n /** Held commands a proven record gap settled `{fate: \"lost\", cause: \"session-lost\"}`; return \"requeue\" to re-enqueue them on the reset clocks. */\n export type OnSessionLost = (\n pending: ReadonlyArray<{\n id?: string;\n method: string;\n params: readonly unknown[];\n ts: number;\n seq: number;\n clientId?: string;\n }>,\n ) => \"requeue\" | \"drop\";\n\n /** A non-accepted send retained for the user: the wire statement, its failure, and its original clocks. */\n export type FailedCommand = {\n readonly protocol: string;\n readonly produced?: SessionCommand[\"produced\"];\n readonly command: string;\n readonly params: readonly unknown[];\n readonly meta?: unknown;\n readonly failure: SendFailure;\n readonly ts: number;\n readonly seq: number;\n };\n\n /** A queued command without a seq, as persisted. */\n export type OutboxCommand = {\n id: string;\n produced?: {\n wire: StatewireProtocol.Range;\n protocols: readonly StatewireProtocol.Offer[] | \"*\";\n };\n method: string;\n params: unknown[];\n meta?: unknown;\n ts: number;\n /** Present while held. */\n hold?: { meta?: unknown };\n /** Its hold was released; the next flush reports reason \"release\". */\n released?: true;\n /** The enqueuing sharer's `SessionStorage.owner.id` (shared storage only). */\n by?: string;\n };\n\n /** A queued command without a seq, in queue order. */\n export type OutboxEntry = {\n readonly id: string;\n readonly protocol: string;\n readonly command: { method: string; params: readonly unknown[] };\n /** The hold, with its meta; null when not held. */\n readonly held: null | { readonly meta: unknown };\n };\n\n /** Whether `entry` may move ahead of `ahead`, a held entry or one waiting behind a hold. */\n export type CanOvertake = (entry: OutboxEntry, ahead: OutboxEntry) => boolean;\n\n /** A stamped command as persisted while un-durable: its lane seq, the sharer that stamped it, plus the wire statement. */\n export type SessionCommand = Omit<OutboxCommand, \"hold\" | \"released\"> & {\n seq: number;\n /** The stamping sharer's `SessionStorage.owner.id` (shared storage only). */\n owner?: string;\n };\n\n /** A durable lane: its cmd clock, the outbox, and the stamped commands not yet settled. */\n export type SessionLane = {\n nextSeq: number;\n commands: readonly SessionCommand[];\n outbox?: readonly OutboxCommand[];\n /** Entries another sharer removed, kept until their enqueuer (`by`) rejects them or is gone (shared storage only). */\n removed?: readonly { id: string; by: string }[];\n /** Terminal verdicts parked for the sharer that minted the seq (shared storage only). */\n verdicts?: readonly SessionVerdict[];\n /** Non-accepted sends retained for the user; survive record rebases and resets. */\n failed?: readonly FailedCommand[];\n };\n\n /** The persisted session: the client identity plus one lane per durable protocol. */\n export type SessionRecord = {\n clientId: string;\n lanes: Readonly<Record<string, SessionLane>>;\n };\n\n /** A terminal verdict one sharer's connection carried, parked for the sharer awaiting the seq. */\n export type SessionVerdict = {\n seq: number;\n /** Set when parked for the sharer that enqueued the command rather than the one that stamped it. */\n id?: string;\n type: (typeof TERMINAL)[number];\n code?: string;\n message?: string;\n payload?: unknown;\n meta?: unknown;\n };\n\n /** Session storage seam with optional asynchronous hydration and persistence. */\n export type SessionStorage = {\n /** Resolves when a synchronous load can return the hydrated record. */\n ready?: Promise<void>;\n /** Resolves after all queued saves are persisted; awaited before sending statements. */\n flush?: () => void | Promise<void>;\n load: () => SessionRecord | null;\n save: (record: SessionRecord) => void;\n /** Upgrade incompatible stored commands; null discards the old record and starts a new client identity. */\n migrate?: (\n record: SessionRecord,\n current: NonNullable<SessionCommand[\"produced\"]>,\n ) => SessionRecord | null;\n /** Serializes record mutations across sharers; presence marks the storage shared. */\n lock?: <T>(fn: () => T | Promise<T>) => Promise<T>;\n /** Notifies of record saves by other sharers; returns unsubscribe. Required alongside `lock`. */\n subscribe?: (listener: () => void) => () => void;\n /** This sharer's identity, stamped on the commands it sends; `whenGone` resolves once the sharer with that id is gone. Required alongside `lock`. */\n owner?: {\n id: string;\n whenGone: (id: string, signal: AbortSignal) => Promise<void>;\n };\n };\n\n /** Static headers, or a resolver invoked per request/attach; `staleAuth` is true right after an auth rejection. */\n export type ConnectionError = Error & { fin?: StatewireHost.Fin };\n\n export type HeadersOption =\n | HeadersInit\n | ((ctx: { staleAuth: boolean }) => HeadersInit | Promise<HeadersInit>);\n\n export type HttpOptions = StatewireProtocol.Options & {\n sessionStore?: SessionStorage | undefined;\n url: string;\n /** The session does not exist on the server yet: the first attach waits for the first command send (or an explicit `reconnect()`). */\n isNew?: boolean;\n headers?: HeadersOption;\n fetch?: typeof globalThis.fetch;\n onSessionLost?: OnSessionLost;\n onFlush?: OnFlush;\n /** Per protocol: lets an outbox entry move ahead of held or waiting ones; default never. */\n canOvertake?: Readonly<Record<string, CanOvertake>>;\n onChange?: (connection: Connection) => void;\n onError?: (error: ConnectionError) => void;\n /** The broadcast idle flag's rising edge: the instance went quiet. */\n onDone?: () => void;\n };\n\n export type WebsocketOptions = StatewireProtocol.Options & {\n sessionStore?: SessionStorage | undefined;\n url: string;\n /** The session does not exist on the server yet: the first attach waits for the first command send (or an explicit `reconnect()`). */\n isNew?: boolean;\n headers?: HeadersOption;\n protocols?: string | string[];\n query?:\n | Record<string, string>\n | (() => Record<string, string> | Promise<Record<string, string>>);\n webSocket?: new (url: string, protocols?: string | string[]) => WebSocket;\n onSessionLost?: OnSessionLost;\n onFlush?: OnFlush;\n /** Per protocol: lets an outbox entry move ahead of held or waiting ones; default never. */\n canOvertake?: Readonly<Record<string, CanOvertake>>;\n onChange?: (connection: Connection) => void;\n onError?: (error: ConnectionError) => void;\n /** The broadcast idle flag's rising edge: the instance went quiet. */\n onDone?: () => void;\n };\n}\n"],"mappings":";;;;;AA+BA,MAAMyB,uBAAuB,EAC3BC,WACAC,SACAC,WACAC,UACAC,WAcAlB,mBAAmBY,uBAAuBG,eAExCf,mBAAmBS,wBAAwBO,iBAEzChB,mBAAmBW,iBAAiBM,gBAElCj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KI,SAAS,CAAC,CAACjB;CAC9B;CAEA,IAAI7D,YAAmD;EACrD,OAAO,KAAK0E,KAAKI,SAAS,CAAC,CAAC9E;CAC9B;CACA,IAAIgD,YAAqD;EACvD,OAAO,KAAK0B,KAAKI,SAAS,CAAC,CAAC9B;CAC9B;CACAC,OACEhD,UACAuD,QACAC,QACAxC,SACkB;EAClB,OAAO,KAAKyD,KAAKI,SAAS,CAAC,CAAC7B,OAAOhD,UAAUuD,QAAQC,QAAQxC,OAAO;CACtE;CACAc,WAAW9B,UAAkB2B,OAAgC;EAC3D,KAAK8C,KAAKI,SAAS,CAAC,CAAC/C,WAAW9B,UAAU2B,KAAK;CACjD;CACA,IAAIa,SAAkB;EACpB,OAAO,KAAKiC,KAAKI,SAAS,CAAC,CAACrC;CAC9B;CAEA,IAAIE,SAAmD;EACrD,OAAO,KAAK+B,KAAKI,SAAS,CAAC,CAACnC;CAC9B;CAEAoB,YAAYC,OAAwD;EAClE,OAAO,KAAKU,KAAKI,SAAS,CAAC,CAACf,YAAYC,KAAK;CAC/C;CAEAG,cAAcH,OAA4C;EACxD,KAAKU,KAAKI,SAAS,CAAC,CAACX,cAAcH,KAAK;CAC1C;CAEA,IAAIV,SAAiC;EACnC,OAAO,KAAKoB,KAAKI,SAAS,CAAC,CAACxB;CAC9B;CAEAjB,UAAUC,UAAkC;EAC1C,OAAO,KAAKoC,KAAKrC,UAAUC,QAAQ;CACrC;CAEA8C,UAAgB;EACd,IAAI,KAAKT,UAAU;EACnB,KAAKA,WAAW;EAChB,KAAKD,KAAKW,QAAQ;CACpB;AACF"}
1
+ {"version":3,"file":"statewire.js","names":["StatewireDocuments","StatewireProtocol","StatewireHost","useCallback","useEffect","useMemo","useRef","useState","useSyncExternalStore","createTapRoot","flushTapSync","resource","useContextProvider","useResource","useResources","withKey","ResourceElement","CONNECTED_CONNECTION","useStatewireCore","Statewire","TERMINAL","DocumentStorageContext","LinkContext","ProtocolContext","SessionStorageContext","useSessionTransport","transport","session","documents","protocol","link","StatewireClient","SessionStorage","Storage","Options","isNew","context","Readonly","Record","Context","canOvertake","CanOvertake","onSettled","OnSettled","SessionTransport","useStatewire","Commands","options","TState","TCommands","Helpers","latest","current","storage","undefined","wireVersion","applicationProtocols","keyPrefixes","handlesUpdates","onCommandChange","coreRef","ReturnType","update","CommandUpdate","state","getState","value","localContext","connection","setContext","Object","entries","core","rematerialize","materializeKey","subscribe","listener","isBusy","getBusy","outboxEntries","getOutbox","source","selection","invoke","transportInvoke","transportSetContext","outbox","transportOutbox","method","params","InvokeOptions","Error","NonNullable","commands","CommandsProxy","hold","id","release","remove","fn","insert","entry","StatewireResource","root","disposed","constructor","ClientRoot","getValue","Connection","Source","Selection","Promise","Outbox","dispose","unmount","Range","Offer","initialState","optimistic","Optimistic","materialize","Materialize","onStateChange","ctx","changes","Changes","onConnectionChange","onError","error","ConnectionError","OutboxEntry","OutboxPatch","OutboxInsert","held","localMeta","command","from","after","before","ConnectionState","status","reason","degraded","attempt","cause","code","nextRetryAt","lastError","message","payload","reconnect","ConnectionStatus","draft","Command","OptimisticContext","ts","seq","clientId","OutboxState","FlushReason","OnFlush","flush","SendFailure","fate","predecessorLost","OnSessionLost","pending","ReadonlyArray","OnDeprecatedPath","event","kind","count","OutboxCommand","produced","wire","protocols","meta","released","by","durable","ahead","SessionCommand","Omit","owner","SessionLane","nextSeq","removed","failure","verdicts","SessionVerdict","inbox","StoredSettled","result","SessionRecord","lanes","type","read","ready","load","save","record","migrate","lock","T","whenGone","signal","AbortSignal","notifyLock","onEvict","EvictEvent","key","dropped","fin","Fin","HeadersOption","HeadersInit","staleAuth","HttpOptions","sessionStore","url","headers","fetch","globalThis","onSessionLost","onDeprecatedPath","onFlush","onChange","onDone","WebsocketOptions","query","webSocket","WebSocket"],"sources":["../src/statewire.ts"],"sourcesContent":["import type { StatewireDocuments } from \"./wire/documents\";\nimport type { StatewireProtocol } from \"./wire/protocol\";\nimport type { StatewireHost } from \"./host\";\nimport {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\nimport {\n createTapRoot,\n flushTapSync,\n resource,\n useContextProvider,\n useResource,\n useResources,\n withKey,\n} from \"@assistant-ui/tap\";\nimport type { ResourceElement } from \"@assistant-ui/tap\";\nimport { CONNECTED_CONNECTION, useStatewireCore } from \"./client/core\";\nimport type { Statewire } from \"./types\";\nimport type { TERMINAL } from \"./client/connection\";\nimport {\n DocumentStorageContext,\n LinkContext,\n ProtocolContext,\n SessionStorageContext,\n} from \"./client/sessionStore\";\n\nconst useSessionTransport = ({\n transport,\n session,\n documents,\n protocol,\n link,\n}: {\n transport: ResourceElement<Statewire<any, any>>;\n session: StatewireClient.SessionStorage | undefined;\n documents: StatewireDocuments.Storage | undefined;\n protocol: StatewireProtocol.Options;\n link: {\n isNew?: boolean | undefined;\n context?: Readonly<Record<string, Statewire.Context>> | undefined;\n canOvertake?:\n | Readonly<Record<string, StatewireClient.CanOvertake>>\n | undefined;\n onSettled?: StatewireClient.OnSettled | undefined;\n };\n}): Statewire<unknown> =>\n useContextProvider(SessionStorageContext, session, () =>\n // oxlint-disable-next-line react-hooks/rules-of-hooks\n useContextProvider(DocumentStorageContext, documents, () =>\n // oxlint-disable-next-line react-hooks/rules-of-hooks\n useContextProvider(ProtocolContext, protocol, () =>\n // oxlint-disable-next-line react-hooks/rules-of-hooks\n useContextProvider(LinkContext, link, () =>\n // oxlint-disable-next-line react-hooks/rules-of-hooks\n useResource(transport),\n ),\n ),\n ),\n );\n\n// The transport owns the session; it reads the storage off the context this\n// wrapper's own fiber provides, so plain-React callers get a provider too.\nconst SessionTransport = resource(useSessionTransport);\n\nexport const useStatewire = <\n TState,\n TCommands extends Statewire.Commands = Statewire.Commands,\n>(\n options: StatewireClient.Options<TState, TCommands>,\n): StatewireClient.Helpers<TState, TCommands> => {\n const latest = useRef(options);\n latest.current = options;\n\n const session = useResources(\n options.storage?.session !== undefined\n ? [withKey(\"session\", options.storage.session)]\n : [],\n )[0];\n const documents = useResources(\n options.storage?.documents === undefined\n ? []\n : [withKey(\"documents\", options.storage.documents)],\n )[0];\n const protocol: StatewireProtocol.Options = {\n ...(options.protocol !== undefined && { protocol: options.protocol }),\n ...(options.wireVersion !== undefined && {\n wireVersion: options.wireVersion,\n }),\n ...(options.applicationProtocols !== undefined && {\n applicationProtocols: options.applicationProtocols,\n }),\n ...(options.keyPrefixes !== undefined && {\n keyPrefixes: options.keyPrefixes,\n }),\n };\n const handlesUpdates = options.onCommandChange !== undefined;\n const coreRef = useRef<ReturnType<typeof useStatewireCore> | null>(null);\n const link = useMemo(\n () => ({\n ...(options.isNew === undefined ? {} : { isNew: options.isNew }),\n ...(options.context === undefined ? {} : { context: options.context }),\n ...(options.canOvertake === undefined\n ? {}\n : { canOvertake: options.canOvertake }),\n ...(handlesUpdates && {\n onSettled: (update: Statewire.CommandUpdate) =>\n latest.current.onCommandChange?.(update as never, {\n state: coreRef.current?.getState() as never,\n }),\n }),\n }),\n [options.isNew, options.context, options.canOvertake, handlesUpdates],\n );\n const value = useResource(\n SessionTransport({\n transport: options.transport,\n session,\n documents,\n protocol,\n link,\n }),\n );\n const localContext =\n value.connection === undefined ? value.setContext : undefined;\n useEffect(() => {\n const current = latest.current;\n if (localContext === undefined || current.context === undefined) return;\n for (const [protocol, context] of Object.entries(current.context))\n localContext(protocol, context);\n }, [options.context, localContext]);\n const core = useStatewireCore(() => latest.current, value);\n coreRef.current = core;\n useEffect(() => core.rematerialize(), [core, options.materializeKey]);\n const [subscribe] = useState(\n () => (listener: () => void) =>\n core.subscribe(() => flushTapSync(listener)),\n );\n\n const state = useSyncExternalStore(\n subscribe,\n core.getState,\n core.getState,\n ) as TState;\n const isBusy = useSyncExternalStore(subscribe, core.getBusy, core.getBusy);\n const outboxEntries = useSyncExternalStore(\n subscribe,\n core.getOutbox,\n core.getOutbox,\n );\n const connection = value.connection ?? CONNECTED_CONNECTION;\n const {\n documents: source,\n selection,\n invoke: transportInvoke,\n setContext: transportSetContext,\n outbox: transportOutbox,\n } = value;\n\n const invoke = useCallback(\n (\n protocol: string,\n method: string,\n params: readonly unknown[],\n options?: StatewireClient.InvokeOptions,\n ) => {\n if (!transportInvoke)\n throw new Error(\n \"statewire: transport does not support protocol commands\",\n );\n return transportInvoke(protocol, method, params, options);\n },\n [transportInvoke],\n );\n\n const setContext = useCallback(\n (protocol: string, value: Statewire.Context) => {\n if (!transportSetContext)\n throw new Error(\"statewire: transport does not support context\");\n transportSetContext(protocol, value);\n },\n [transportSetContext],\n );\n\n return useMemo(() => {\n const outbox = (): NonNullable<typeof transportOutbox> => {\n if (!transportOutbox) {\n throw new Error(\"statewire: this transport has no outbox\");\n }\n return transportOutbox;\n };\n return {\n state,\n documents: source,\n selection,\n invoke,\n setContext,\n getState: core.getState as () => TState,\n connection,\n commands: core.commands as Statewire.CommandsProxy<TCommands>,\n isBusy,\n outbox: {\n entries: outboxEntries,\n hold: (id) => outbox().hold(id),\n release: (id) => outbox().release(id),\n remove: (id) => outbox().remove(id),\n update: (id, fn) => outbox().update(id, fn),\n insert: (entry) => outbox().insert(entry),\n },\n };\n }, [\n outboxEntries,\n transportOutbox,\n state,\n isBusy,\n connection,\n core,\n source,\n selection,\n invoke,\n setContext,\n ]);\n};\n\nexport const StatewireResource = <\n TState,\n TCommands extends Statewire.Commands = Statewire.Commands,\n>(\n options: StatewireClient.Options<TState, TCommands>,\n): ResourceElement<StatewireClient.Helpers<TState, TCommands>> =>\n resource(useStatewire<TState, TCommands>)(options);\n\nexport class StatewireClient<\n TState,\n TCommands extends Statewire.Commands = Statewire.Commands,\n> {\n private readonly root;\n private disposed = false;\n\n constructor(options: StatewireClient.Options<TState, TCommands>) {\n const ClientRoot = () => useStatewire<TState, TCommands>(options);\n this.root = createTapRoot(ClientRoot);\n }\n\n get state(): TState {\n return this.root.getValue().getState();\n }\n\n get connection(): StatewireClient.Connection {\n return this.root.getValue().connection;\n }\n\n get commands(): Statewire.CommandsProxy<TCommands> {\n return this.root.getValue().commands;\n }\n\n get documents(): StatewireDocuments.Source | undefined {\n return this.root.getValue().documents;\n }\n get selection(): StatewireProtocol.Selection | undefined {\n return this.root.getValue().selection;\n }\n invoke(\n protocol: string,\n method: string,\n params: readonly unknown[],\n options?: StatewireClient.InvokeOptions,\n ): Promise<unknown> {\n return this.root.getValue().invoke(protocol, method, params, options);\n }\n setContext(protocol: string, value: Statewire.Context): void {\n this.root.getValue().setContext(protocol, value);\n }\n get isBusy(): boolean {\n return this.root.getValue().isBusy;\n }\n\n get outbox(): StatewireClient.Outbox {\n return this.root.getValue().outbox;\n }\n\n subscribe(listener: () => void): () => void {\n return this.root.subscribe(listener);\n }\n\n dispose(): void {\n if (this.disposed) return;\n this.disposed = true;\n this.root.unmount();\n }\n}\n\nexport namespace StatewireClient {\n export type Options<\n TState,\n TCommands extends Statewire.Commands = Statewire.Commands,\n > = {\n protocol?: string;\n context?: Readonly<Record<string, Statewire.Context>>;\n keyPrefixes?: Readonly<Record<string, readonly string[]>>;\n wireVersion?: StatewireProtocol.Range;\n applicationProtocols?: readonly StatewireProtocol.Offer[] | \"*\";\n transport: ResourceElement<Statewire<TState, TCommands>>;\n /** The session does not exist on the server yet: the transport's first attach waits for the first command send; the transport's own `isNew` wins. */\n isNew?: boolean;\n /** Per protocol: lets an outbox entry move ahead of held or waiting ones; the transport's own `canOvertake` wins. */\n canOvertake?: Readonly<Record<string, CanOvertake>>;\n /** Durable session: the mounted storage holds this client's lane identity and its un-durable commands, which resend on the next attach. */\n storage?:\n | {\n session?: ResourceElement<SessionStorage> | undefined;\n documents?: ResourceElement<StatewireDocuments.Storage> | undefined;\n }\n | undefined;\n /** Served as the canonical state until the attach snapshot; own commands fold over it. */\n initialState?: TState;\n optimistic?: Optimistic<NonNullable<TState>, TCommands>;\n materialize?: Materialize<NonNullable<TState>>;\n /** Republishes through `materialize` when it changes (`Object.is`); `materialize` itself is read fresh on every publish. */\n materializeKey?: unknown;\n onStateChange?: (\n state: NonNullable<TState>,\n ctx: { changes: Statewire.Changes },\n ) => void;\n /**\n * queued, posted and applied updates are best-effort and in memory. A\n * durable session persists each `settled` update before the command leaves\n * the record and delivers it to one sharer at a time: at-least-once under\n * the same `id`, acked once the returned promise resolves; a pending\n * delivery blocks later ones for the same session.\n */\n onCommandChange?: (\n update: Statewire.CommandUpdate<TCommands>,\n ctx: { state: NonNullable<TState> },\n ) => unknown;\n onConnectionChange?: (connection: Connection) => void;\n onError?: (error: ConnectionError) => void;\n };\n\n export type Helpers<\n TState,\n TCommands extends Statewire.Commands = Statewire.Commands,\n > = {\n /** The statewire's state type — remote statewires include `undefined` until the first attach snapshot applies. */\n state: TState;\n documents: StatewireDocuments.Source | undefined;\n selection: StatewireProtocol.Selection | undefined;\n setContext: (protocol: string, value: Statewire.Context) => void;\n invoke: (\n protocol: string,\n method: string,\n params: readonly unknown[],\n options?: InvokeOptions,\n ) => Promise<unknown>;\n /** Identity-stable across renders; reads the current canonical state without subscribing the caller. */\n getState: () => TState;\n connection: Connection;\n commands: Statewire.CommandsProxy<TCommands>;\n /** Negation of the server's broadcast idle level (a transport without idle is always busy). */\n isBusy: boolean;\n /** Unsettled commands in queue order; a transport without a session has an empty outbox whose methods throw. */\n outbox: Outbox;\n };\n\n /** The unsettled commands across sharers, and the operations on them; every verb throws `outbox: no entry <id>` or `outbox: <id> is in flight`. */\n export type Outbox = {\n readonly entries: readonly OutboxEntry[];\n /** queued → held: no flush stamps it until released. */\n hold: (id: string) => void;\n /** held → queued; settles with the command's outcome. */\n release: (id: string) => Promise<unknown>;\n /** Drops a queued or held entry; its pending send rejects `{ fate: \"aborted\", cause: \"removed\" }`. */\n remove: (id: string) => void;\n /** Patches the entry under the storage lock; `fn` gets the current entry. */\n update: (id: string, fn: (entry: OutboxEntry) => OutboxPatch) => void;\n /** Adds a command no send awaits, at the lane's tail or next to `after`/`before`; returns its id. */\n insert: (entry: OutboxInsert) => string;\n };\n\n export type OutboxPatch = {\n held?: boolean;\n localMeta?: unknown;\n command?: { params: readonly unknown[] };\n };\n\n export type OutboxInsert = {\n /** The `settled` update this re-inserts: the insert acks it in the same write, so a redelivery never inserts twice. */\n from?: string;\n protocol: string;\n command: { method: string; params: readonly unknown[] };\n held?: boolean;\n localMeta?: unknown;\n after?: string;\n before?: string;\n };\n\n /** Connection lifecycle and whether its current state warrants a problem indicator. */\n export type ConnectionState =\n | { status: \"standby\"; reason: \"deferred\" | \"idle\"; degraded: false }\n | { status: \"connecting\"; degraded: false }\n | { status: \"connected\"; degraded: false }\n | {\n status: \"retrying\";\n degraded: true;\n attempt: number;\n /** Backoff details are absent while the retry dial is in flight. */\n cause?: \"dropped\" | \"reconnect\" | \"error\" | \"unauthorized\";\n code?: string;\n nextRetryAt?: number;\n lastError?: string;\n message?: string;\n }\n | {\n status: \"stopped\";\n degraded: true;\n reason:\n | \"gone\"\n | \"forbidden\"\n | \"protocol-error\"\n | \"unauthorized\"\n | \"storage-error\";\n message?: string;\n payload?: unknown;\n };\n export type Connection = ConnectionState & {\n error?: ConnectionError;\n reconnect: () => void;\n };\n export type ConnectionStatus = Connection[\"status\"];\n\n /**\n * Mutate the draft in place; the client records the next state plus the exact\n * changed paths. Re-run against the new base on every rebase.\n */\n export type Optimistic<\n TState,\n TCommands extends Statewire.Commands = Statewire.Commands,\n > = (\n draft: TState,\n command: Statewire.Command<TCommands>,\n ctx: OptimisticContext,\n ) => void;\n\n export type OptimisticContext = {\n /** Enqueue time. */\n ts: number;\n /** Absent while the command waits in the outbox. */\n seq?: number;\n clientId?: string;\n state: OutboxState;\n localMeta: unknown;\n };\n\n export type InvokeOptions = {\n /** Enqueue the command held. */\n hold?: boolean;\n /** Client-only data persisted with the entry, never sent. */\n localMeta?: unknown;\n };\n\n /**\n * Why an entry is about to be stamped: \"enqueue\" = queued since the last\n * flush, \"reconnect\" = its seq never reached the server and was freed on\n * reattach, \"reload\" = queued before this client mounted, \"release\" = its\n * hold was released.\n */\n export type FlushReason = \"enqueue\" | \"reconnect\" | \"reload\" | \"release\";\n\n /** Runs in the sharer about to stamp, under the storage lock, once per reason; outbox verbs on these entries apply synchronously before stamping. */\n export type OnFlush = (flush: {\n commands: readonly OutboxEntry[];\n reason: FlushReason;\n }) => void;\n\n /**\n * Mutate the draft to fold client-known facts into the state: server-accepted,\n * still-uncommitted intents (e.g. dispatch records into messages) or the live\n * state of a sibling statewire. Runs after the optimistic folds on every\n * published state; `materializeKey` republishes when the facts change.\n */\n export type Materialize<TState> = (draft: TState) => void;\n\n /**\n * fate: \"aborted\" = never sent (\"removed\" = taken out of the outbox), \"rejected\" = the server refused it\n * (`code` \"unknown-command\" | \"invalid-params\" for the static rejects,\n * code-less for handler rejects), \"lost\" = sent but no verdict will ever\n * arrive — the record is gone (a proven seq gap) or the channel died: it\n * may or may not have run, \"failed\" = the handler ran and threw,\n * \"crashed\" = the handler died involuntarily, \"expired\" = settled —\n * result, rejected, failed, or crashed — but the verdict outlived the\n * server's retention.\n * cause is which channel settled it: \"server\" = the server's answer;\n * the rest are channel deaths the client settled locally.\n */\n export type SendFailure =\n | {\n fate: \"rejected\";\n cause: \"server\";\n code?: string;\n message?: string;\n payload?: unknown;\n }\n | { fate: \"failed\"; cause: \"server\"; message?: string }\n | { fate: \"crashed\"; cause: \"server\" }\n | { fate: \"expired\"; cause: \"server\" }\n | {\n fate: \"aborted\";\n cause: \"unmount\" | \"stream-gone\" | \"session-lost\" | \"removed\" | \"quota\";\n predecessorLost?: true;\n }\n | {\n fate: \"lost\";\n cause: \"unmount\" | \"stream-gone\" | \"session-lost\";\n };\n\n /**\n * Temporary and discouraged; removed in a later release. A proven record gap\n * settles the lane's commands `{ fate: \"lost\", cause: \"session-lost\" }` and\n * drops its outbox. Returning \"requeue\" instead re-enqueues this client's\n * lost stamps (fresh ids, at the tail) and keeps the outbox.\n */\n export type OnSessionLost = (\n pending: ReadonlyArray<{\n id: string;\n method: string;\n params: readonly unknown[];\n ts: number;\n seq: number;\n clientId?: string;\n }>,\n ) => \"requeue\" | \"drop\";\n\n /** Reports a deprecated code path firing, so its use can be measured before removal. */\n export type OnDeprecatedPath = (event: {\n kind: \"session-lost-requeue\";\n count: number;\n }) => void;\n\n /** Delivers one durable `settled` update; acked once the returned promise resolves. */\n export type OnSettled = (update: Statewire.CommandUpdate) => unknown;\n\n export type OutboxState = \"queued\" | \"held\" | \"sending\";\n\n /** A queued command as persisted. */\n export type OutboxCommand = {\n id: string;\n produced?: {\n wire: StatewireProtocol.Range;\n protocols: readonly StatewireProtocol.Offer[] | \"*\";\n };\n method: string;\n params: unknown[];\n /** Encoding of non-JSON params. */\n meta?: unknown;\n /** Enqueue time. */\n ts: number;\n /** Present while held. */\n held?: true;\n localMeta?: unknown;\n /** Its hold was released; the next flush reports reason \"release\". */\n released?: true;\n /** The enqueuing sharer's `SessionStorage.owner.id` (shared storage only). */\n by?: string;\n };\n\n /** An unsettled command, in queue order. */\n export type OutboxEntry = {\n readonly id: string;\n readonly protocol: string;\n readonly command: {\n readonly method: string;\n readonly params: readonly unknown[];\n };\n /** Enqueue time. */\n readonly ts: number;\n readonly state: OutboxState;\n /** Client-only, persisted, never sent. */\n readonly localMeta: unknown;\n /** False when the entry lives in page memory only. */\n readonly durable: boolean;\n };\n\n /** Whether `entry` may move ahead of `ahead`, a held entry or one waiting behind one. */\n export type CanOvertake = (entry: OutboxEntry, ahead: OutboxEntry) => boolean;\n\n /** A stamped command as persisted while un-durable: its lane seq, the sharer that stamped it, plus the wire statement. */\n export type SessionCommand = Omit<OutboxCommand, \"held\" | \"released\"> & {\n seq: number;\n /** The stamping sharer's `SessionStorage.owner.id` (shared storage only). */\n owner?: string;\n };\n\n /** A durable lane: its cmd clock, the outbox, and the stamped commands not yet settled. */\n export type SessionLane = {\n nextSeq: number;\n commands: readonly SessionCommand[];\n outbox?: readonly OutboxCommand[];\n /** Entries another sharer settled unsent, kept until their enqueuer (`by`) rejects them or is gone (shared storage only); no failure means removed. */\n removed?: readonly { id: string; by: string; failure?: SendFailure }[];\n /** Terminal verdicts parked for the sharer that minted the seq (shared storage only). */\n verdicts?: readonly SessionVerdict[];\n /** Terminal `settled` updates awaiting their `onCommandChange` ack. */\n inbox?: readonly StoredSettled[];\n };\n\n /** A terminal update as persisted: the stored command plus its outcome. */\n export type StoredSettled = {\n id: string;\n method: string;\n params: unknown[];\n meta?: unknown;\n ts: number;\n seq?: number;\n localMeta?: unknown;\n /** The accepted result, encoded as a one-element param list. */\n result?: { value: unknown[]; meta?: unknown };\n failure?: SendFailure;\n };\n\n /** The persisted session: the client identity plus one lane per durable protocol. */\n export type SessionRecord = {\n clientId: string;\n lanes: Readonly<Record<string, SessionLane>>;\n };\n\n /** A terminal verdict one sharer's connection carried, parked for the sharer awaiting the seq. */\n export type SessionVerdict = {\n seq: number;\n /** Set when parked for the sharer that enqueued the command rather than the one that stamped it. */\n id?: string;\n type: (typeof TERMINAL)[number];\n code?: string;\n message?: string;\n payload?: unknown;\n meta?: unknown;\n };\n\n /** Session storage seam with optional asynchronous hydration and persistence. */\n export type SessionStorage = {\n /** False when the record lives in page memory only. */\n durable?: boolean;\n /** Re-reads the stored record; awaited under `lock` when present. */\n read?: () => Promise<SessionRecord | null>;\n /** Resolves when a synchronous load can return the hydrated record. */\n ready?: Promise<void>;\n /** Resolves after all queued saves are persisted; awaited before sending statements. */\n flush?: () => void | Promise<void>;\n load: () => SessionRecord | null;\n save: (record: SessionRecord) => void;\n /** Upgrade incompatible stored commands; null discards the old record and starts a new client identity. */\n migrate?: (\n record: SessionRecord,\n current: NonNullable<SessionCommand[\"produced\"]>,\n ) => SessionRecord | null;\n /** Serializes record mutations across sharers; presence marks the storage shared. */\n lock?: <T>(fn: () => T | Promise<T>) => Promise<T>;\n /** Notifies of record saves by other sharers; returns unsubscribe. Required alongside `lock`. */\n subscribe?: (listener: () => void) => () => void;\n /** This sharer's identity, stamped on the commands it sends; `whenGone` resolves once the sharer with that id is gone. Required alongside `lock`. */\n owner?: {\n id: string;\n whenGone: (id: string, signal: AbortSignal) => Promise<void>;\n };\n /** Exclusive across sharers while a durable `settled` update is delivered; required alongside `lock`. */\n notifyLock?: <T>(fn: () => Promise<T>) => Promise<T>;\n /** Reports failure notices the session dropped. */\n onEvict?: (event: Omit<EvictEvent, \"key\">) => void;\n };\n\n export type EvictEvent = {\n key: string;\n reason: \"expired\" | \"overflow\" | \"quota\" | \"inbox\";\n /** The undelivered `settled` updates that went with it. */\n dropped: readonly Statewire.CommandUpdate[];\n };\n\n /** Static headers, or a resolver invoked per request/attach; `staleAuth` is true right after an auth rejection. */\n export type ConnectionError = Error & { fin?: StatewireHost.Fin };\n\n export type HeadersOption =\n | HeadersInit\n | ((ctx: { staleAuth: boolean }) => HeadersInit | Promise<HeadersInit>);\n\n export type HttpOptions = StatewireProtocol.Options & {\n sessionStore?: SessionStorage | undefined;\n url: string;\n /** The session does not exist on the server yet: the first attach waits for the first command send (or an explicit `reconnect()`). */\n isNew?: boolean;\n headers?: HeadersOption;\n fetch?: typeof globalThis.fetch;\n onSessionLost?: OnSessionLost;\n onDeprecatedPath?: OnDeprecatedPath;\n onFlush?: OnFlush;\n /** Per protocol: lets an outbox entry move ahead of held or waiting ones; default never. */\n canOvertake?: Readonly<Record<string, CanOvertake>>;\n onChange?: (connection: Connection) => void;\n onError?: (error: ConnectionError) => void;\n /** The broadcast idle flag's rising edge: the instance went quiet. */\n onDone?: () => void;\n };\n\n export type WebsocketOptions = StatewireProtocol.Options & {\n sessionStore?: SessionStorage | undefined;\n url: string;\n /** The session does not exist on the server yet: the first attach waits for the first command send (or an explicit `reconnect()`). */\n isNew?: boolean;\n headers?: HeadersOption;\n protocols?: string | string[];\n query?:\n | Record<string, string>\n | (() => Record<string, string> | Promise<Record<string, string>>);\n webSocket?: new (url: string, protocols?: string | string[]) => WebSocket;\n onSessionLost?: OnSessionLost;\n onDeprecatedPath?: OnDeprecatedPath;\n onFlush?: OnFlush;\n /** Per protocol: lets an outbox entry move ahead of held or waiting ones; default never. */\n canOvertake?: Readonly<Record<string, CanOvertake>>;\n onChange?: (connection: Connection) => void;\n onError?: (error: ConnectionError) => void;\n /** The broadcast idle flag's rising edge: the instance went quiet. */\n onDone?: () => void;\n };\n}\n"],"mappings":";;;;;AA+BA,MAAMyB,uBAAuB,EAC3BC,WACAC,SACAC,WACAC,UACAC,WAeAlB,mBAAmBY,uBAAuBG,eAExCf,mBAAmBS,wBAAwBO,iBAEzChB,mBAAmBW,iBAAiBM,gBAElCjB,mBAAmBU,aAAaQ,YAE9BjB,YAAYa,SAAS,CACvB,CACF,CACF,CACF;AAIF,MAAMkB,mBAAmBjC,SAASc,mBAAmB;AAErD,MAAaoB,gBAIXE,YAC+C;CAC/C,MAAMI,SAAS7C,OAAOyC,OAAO;CAC7BI,OAAOC,UAAUL;CAEjB,MAAMpB,UAAUb,aACdiC,QAAQM,SAAS1B,YAAY2B,KAAAA,IACzB,CAACvC,QAAQ,WAAWgC,QAAQM,QAAQ1B,OAAO,CAAC,IAC5C,CAAA,CACN,CAAC,CAAC;CACF,MAAMC,YAAYd,aAChBiC,QAAQM,SAASzB,cAAc0B,KAAAA,IAC3B,CAAA,IACA,CAACvC,QAAQ,aAAagC,QAAQM,QAAQzB,SAAS,CAAC,CACtD,CAAC,CAAC;CACF,MAAMC,WAAsC;EAC1C,GAAIkB,QAAQlB,aAAayB,KAAAA,KAAa,EAAEzB,UAAUkB,QAAQlB,SAAS;EACnE,GAAIkB,QAAQQ,gBAAgBD,KAAAA,KAAa,EACvCC,aAAaR,QAAQQ,YACvB;EACA,GAAIR,QAAQS,yBAAyBF,KAAAA,KAAa,EAChDE,sBAAsBT,QAAQS,qBAChC;EACA,GAAIT,QAAQU,gBAAgBH,KAAAA,KAAa,EACvCG,aAAaV,QAAQU,YACvB;CACF;CACA,MAAMC,iBAAiBX,QAAQY,oBAAoBL,KAAAA;CACnD,MAAMM,UAAUtD,OAAmD,IAAI;CACvE,MAAMwB,OAAOzB,eACJ;EACL,GAAI0C,QAAQZ,UAAUmB,KAAAA,IAAY,CAAC,IAAI,EAAEnB,OAAOY,QAAQZ,MAAM;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