statewire 0.21.0 → 0.22.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.
- package/dist/client/changes.d.ts +3 -6
- package/dist/client/changes.d.ts.map +1 -1
- package/dist/client/changes.js +1 -2
- package/dist/client/connection.d.ts +80 -83
- package/dist/client/connection.d.ts.map +1 -1
- package/dist/client/connection.js +2 -3
- package/dist/client/connection.js.map +1 -1
- package/dist/client/core.d.ts +39 -41
- package/dist/client/core.d.ts.map +1 -1
- package/dist/client/core.js +2 -3
- package/dist/client/session.d.ts +93 -95
- package/dist/client/session.d.ts.map +1 -1
- package/dist/client/session.js +6 -7
- package/dist/client/session.js.map +1 -1
- package/dist/client/sessionStore.d.ts +11 -14
- package/dist/client/sessionStore.d.ts.map +1 -1
- package/dist/client/sessionStore.js +1 -2
- package/dist/client/storageError.d.ts +2 -5
- package/dist/client/storageError.d.ts.map +1 -1
- package/dist/client/storageError.js +1 -2
- package/dist/client/timing.d.ts +11 -14
- package/dist/client/timing.d.ts.map +1 -1
- package/dist/client/timing.js +1 -2
- package/dist/document.d.ts +17 -20
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +1 -2
- package/dist/host/adapter.d.ts +4 -7
- package/dist/host/adapter.d.ts.map +1 -1
- package/dist/host/adapter.js +1 -2
- package/dist/host/draft.d.ts +13 -16
- package/dist/host/draft.d.ts.map +1 -1
- package/dist/host/draft.js +1 -2
- package/dist/host/engine.d.ts +7 -10
- package/dist/host/engine.d.ts.map +1 -1
- package/dist/host/engine.js +1 -2
- package/dist/host/host.d.ts +42 -45
- package/dist/host/host.d.ts.map +1 -1
- package/dist/host/host.js +1 -2
- package/dist/host/http.d.ts +4 -7
- package/dist/host/http.d.ts.map +1 -1
- package/dist/host/http.js +2 -3
- package/dist/host/socket.d.ts +148 -145
- package/dist/host/socket.d.ts.map +1 -1
- package/dist/host/socket.js +30 -12
- package/dist/host/socket.js.map +1 -1
- package/dist/host/synced.d.ts +3 -6
- package/dist/host/synced.d.ts.map +1 -1
- package/dist/host/synced.js +1 -2
- package/dist/host/work.d.ts +2 -5
- package/dist/host/work.d.ts.map +1 -1
- package/dist/host/work.js +1 -2
- package/dist/host-internal.d.ts +101 -93
- package/dist/host-internal.d.ts.map +1 -1
- package/dist/host.d.ts +90 -91
- package/dist/host.d.ts.map +1 -1
- package/dist/index.d.ts +11 -8
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -1
- package/dist/statewire.d.ts +265 -268
- package/dist/statewire.d.ts.map +1 -1
- package/dist/statewire.js +1 -2
- package/dist/storage.d.ts +23 -26
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +1 -2
- package/dist/transports/fake-sse.d.ts +7 -10
- package/dist/transports/fake-sse.d.ts.map +1 -1
- package/dist/transports/fake-sse.js +1 -2
- package/dist/transports/fixtures.d.ts +19 -25
- package/dist/transports/fixtures.d.ts.map +1 -1
- package/dist/transports/fixtures.js +1 -2
- package/dist/transports/remote.d.ts +8 -11
- package/dist/transports/remote.d.ts.map +1 -1
- package/dist/transports/remote.js +1 -2
- package/dist/transports/sse-parser.d.ts +1 -4
- package/dist/transports/sse-parser.d.ts.map +1 -1
- package/dist/transports/sse-parser.js +1 -2
- package/dist/transports/sse.d.ts +50 -53
- package/dist/transports/sse.d.ts.map +1 -1
- package/dist/transports/sse.js +2 -3
- package/dist/transports/testing.d.ts +31 -34
- package/dist/transports/testing.d.ts.map +1 -1
- package/dist/transports/testing.js +1 -2
- package/dist/transports/ws.d.ts +5 -7
- package/dist/transports/ws.d.ts.map +1 -1
- package/dist/transports/ws.js +3 -4
- package/dist/transports/ws.js.map +1 -1
- package/dist/types.d.ts +81 -78
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -2
- package/dist/util/draftTraps.d.ts +2 -4
- package/dist/util/draftTraps.d.ts.map +1 -1
- package/dist/util/draftTraps.js +1 -2
- package/dist/util/macrotask.d.ts +1 -4
- package/dist/util/macrotask.d.ts.map +1 -1
- package/dist/util/macrotask.js +1 -2
- package/dist/util/methodProxy.d.ts +1 -4
- package/dist/util/methodProxy.d.ts.map +1 -1
- package/dist/util/methodProxy.js +1 -2
- package/dist/util/randomId.d.ts +1 -4
- package/dist/util/randomId.d.ts.map +1 -1
- package/dist/util/randomId.js +1 -2
- package/dist/util/recordMutations.d.ts +5 -7
- package/dist/util/recordMutations.d.ts.map +1 -1
- package/dist/util/recordMutations.js +1 -2
- package/dist/util/statePath.d.ts +9 -12
- package/dist/util/statePath.d.ts.map +1 -1
- package/dist/util/statePath.js +1 -2
- package/dist/wire/context.d.ts +7 -12
- package/dist/wire/context.d.ts.map +1 -1
- package/dist/wire/context.js +2 -3
- package/dist/wire/documents.d.ts +36 -39
- package/dist/wire/documents.d.ts.map +1 -1
- package/dist/wire/documents.js +2 -3
- package/dist/wire/documents.js.map +1 -1
- package/dist/wire/limits.d.ts +7 -10
- package/dist/wire/limits.d.ts.map +1 -1
- package/dist/wire/limits.js +1 -2
- package/dist/wire/meta.d.ts +9 -11
- package/dist/wire/meta.d.ts.map +1 -1
- package/dist/wire/meta.js +1 -2
- package/dist/wire/meta.js.map +1 -1
- package/dist/wire/ops.d.ts +9 -12
- package/dist/wire/ops.d.ts.map +1 -1
- package/dist/wire/ops.js +1 -2
- package/dist/wire/protocol.d.ts +53 -56
- package/dist/wire/protocol.d.ts.map +1 -1
- package/dist/wire/protocol.js +1 -2
- package/dist/wire/version.d.ts +1 -4
- package/dist/wire/version.d.ts.map +1 -1
- package/dist/wire/version.js +1 -2
- package/package.json +6 -6
- package/src/client/connection.ts +13 -15
- package/src/host/socket.ts +63 -6
- package/src/host-internal.ts +12 -0
package/dist/statewire.d.ts
CHANGED
|
@@ -1,272 +1,269 @@
|
|
|
1
|
-
import { StatewireDocuments } from "./wire/documents.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { Statewire } from "./types.js";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
declare const
|
|
9
|
-
declare
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
dispose(): void;
|
|
1
|
+
import type { StatewireDocuments } from "./wire/documents.js";
|
|
2
|
+
import type { StatewireProtocol } from "./wire/protocol.js";
|
|
3
|
+
import type { StatewireHost } from "./host.js";
|
|
4
|
+
import type { ResourceElement } from "@assistant-ui/tap";
|
|
5
|
+
import type { Statewire } from "./types.js";
|
|
6
|
+
import type { TERMINAL } from "./client/connection.js";
|
|
7
|
+
export declare const useStatewire: <TState, TCommands extends Statewire.Commands = Statewire.Commands>(options: StatewireClient.Options<TState, TCommands>) => StatewireClient.Helpers<TState, TCommands>;
|
|
8
|
+
export declare const StatewireResource: <TState, TCommands extends Statewire.Commands = Statewire.Commands>(options: StatewireClient.Options<TState, TCommands>) => ResourceElement<StatewireClient.Helpers<TState, TCommands>>;
|
|
9
|
+
export declare class StatewireClient<TState, TCommands extends Statewire.Commands = Statewire.Commands> {
|
|
10
|
+
private readonly root;
|
|
11
|
+
private disposed;
|
|
12
|
+
constructor(options: StatewireClient.Options<TState, TCommands>);
|
|
13
|
+
get state(): TState;
|
|
14
|
+
get connection(): StatewireClient.Connection;
|
|
15
|
+
get commands(): Statewire.CommandsProxy<TCommands>;
|
|
16
|
+
get documents(): StatewireDocuments.Source | undefined;
|
|
17
|
+
get selection(): StatewireProtocol.Selection | undefined;
|
|
18
|
+
invoke(protocol: string, method: string, params: readonly unknown[]): Promise<unknown>;
|
|
19
|
+
setContext(protocol: string, value: Statewire.Context): void;
|
|
20
|
+
get isBusy(): boolean;
|
|
21
|
+
get failed(): readonly StatewireClient.FailedCommand[];
|
|
22
|
+
retryFailed(entry: StatewireClient.FailedCommand): Promise<unknown>;
|
|
23
|
+
discardFailed(entry: StatewireClient.FailedCommand): void;
|
|
24
|
+
subscribe(listener: () => void): () => void;
|
|
25
|
+
dispose(): void;
|
|
27
26
|
}
|
|
28
|
-
declare namespace StatewireClient {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
27
|
+
export declare namespace StatewireClient {
|
|
28
|
+
type Options<TState, TCommands extends Statewire.Commands = Statewire.Commands> = {
|
|
29
|
+
protocol?: string;
|
|
30
|
+
context?: Readonly<Record<string, Statewire.Context>>;
|
|
31
|
+
keyPrefixes?: Readonly<Record<string, readonly string[]>>;
|
|
32
|
+
wireVersion?: StatewireProtocol.Range;
|
|
33
|
+
applicationProtocols?: readonly StatewireProtocol.Offer[] | "*";
|
|
34
|
+
transport: ResourceElement<Statewire<TState, TCommands>>;
|
|
35
|
+
/** 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. */
|
|
36
|
+
isNew?: boolean;
|
|
37
|
+
/** Durable session: the mounted storage holds this client's lane identity and its un-durable commands, which resend on the next attach. */
|
|
38
|
+
storage?: {
|
|
39
|
+
session?: ResourceElement<SessionStorage> | undefined;
|
|
40
|
+
documents?: ResourceElement<StatewireDocuments.Storage> | undefined;
|
|
41
|
+
} | undefined;
|
|
42
|
+
/** Served as the canonical state until the attach snapshot; own commands fold over it. */
|
|
43
|
+
initialState?: TState;
|
|
44
|
+
optimistic?: Optimistic<NonNullable<TState>, TCommands>;
|
|
45
|
+
materialize?: Materialize<NonNullable<TState>>;
|
|
46
|
+
/** Republishes through `materialize` when it changes (`Object.is`); `materialize` itself is read fresh on every publish. */
|
|
47
|
+
materializeKey?: unknown;
|
|
48
|
+
onStateChange?: (state: NonNullable<TState>, ctx: {
|
|
49
|
+
changes: Statewire.Changes;
|
|
50
|
+
}) => void;
|
|
51
|
+
onCommandChange?: (update: Statewire.CommandUpdate<TCommands>, ctx: {
|
|
52
|
+
state: NonNullable<TState>;
|
|
53
|
+
}) => void;
|
|
54
|
+
onConnectionChange?: (connection: Connection) => void;
|
|
55
|
+
onError?: (error: ConnectionError) => void;
|
|
56
|
+
/** Drops a retained failed entry once a canonical snapshot shows its effect landed; checked against each new snapshot. */
|
|
57
|
+
failureCovered?: (state: NonNullable<TState>, entry: FailedCommand) => boolean;
|
|
58
|
+
};
|
|
59
|
+
type Helpers<TState, TCommands extends Statewire.Commands = Statewire.Commands> = {
|
|
60
|
+
/** The statewire's state type — remote statewires include `undefined` until the first attach snapshot applies. */
|
|
61
|
+
state: TState;
|
|
62
|
+
documents: StatewireDocuments.Source | undefined;
|
|
63
|
+
selection: StatewireProtocol.Selection | undefined;
|
|
64
|
+
setContext: (protocol: string, value: Statewire.Context) => void;
|
|
65
|
+
invoke: (protocol: string, method: string, params: readonly unknown[]) => Promise<unknown>;
|
|
66
|
+
/** Identity-stable across renders; reads the current canonical state without subscribing the caller. */
|
|
67
|
+
getState: () => TState;
|
|
68
|
+
connection: Connection;
|
|
69
|
+
commands: Statewire.CommandsProxy<TCommands>;
|
|
70
|
+
/** Negation of the server's broadcast idle level (a transport without idle is always busy). */
|
|
71
|
+
isBusy: boolean;
|
|
72
|
+
/** Non-accepted sends retained in the session record; reload with it. */
|
|
73
|
+
failed: readonly FailedCommand[];
|
|
74
|
+
/** Re-enqueues the entry's command on fresh clocks and removes the entry. */
|
|
75
|
+
retryFailed: (entry: FailedCommand) => Promise<unknown>;
|
|
76
|
+
/** Removes the entry. */
|
|
77
|
+
discardFailed: (entry: FailedCommand) => void;
|
|
78
|
+
};
|
|
79
|
+
/** Connection lifecycle and whether its current state warrants a problem indicator. */
|
|
80
|
+
type ConnectionState = {
|
|
81
|
+
status: "standby";
|
|
82
|
+
reason: "deferred" | "idle";
|
|
83
|
+
degraded: false;
|
|
84
|
+
} | {
|
|
85
|
+
status: "connecting";
|
|
86
|
+
degraded: false;
|
|
87
|
+
} | {
|
|
88
|
+
status: "connected";
|
|
89
|
+
degraded: false;
|
|
90
|
+
} | {
|
|
91
|
+
status: "retrying";
|
|
92
|
+
degraded: true;
|
|
93
|
+
attempt: number;
|
|
94
|
+
/** Backoff details are absent while the retry dial is in flight. */
|
|
95
|
+
cause?: "dropped" | "reconnect" | "error" | "unauthorized";
|
|
96
|
+
code?: string;
|
|
97
|
+
nextRetryAt?: number;
|
|
98
|
+
lastError?: string;
|
|
99
|
+
message?: string;
|
|
100
|
+
} | {
|
|
101
|
+
status: "stopped";
|
|
102
|
+
degraded: true;
|
|
103
|
+
reason: "gone" | "forbidden" | "protocol-error" | "unauthorized" | "storage-error";
|
|
104
|
+
message?: string;
|
|
105
|
+
payload?: unknown;
|
|
106
|
+
};
|
|
107
|
+
type Connection = ConnectionState & {
|
|
108
|
+
error?: ConnectionError;
|
|
109
|
+
reconnect: () => void;
|
|
110
|
+
};
|
|
111
|
+
type ConnectionStatus = Connection["status"];
|
|
112
|
+
/**
|
|
113
|
+
* Mutate the draft in place; the client records the next state plus the exact
|
|
114
|
+
* changed paths. Re-run against the new base on every rebase.
|
|
115
|
+
*/
|
|
116
|
+
type Optimistic<TState, TCommands extends Statewire.Commands = Statewire.Commands> = (draft: TState, command: Statewire.Command<TCommands>, ctx: OptimisticContext) => void;
|
|
117
|
+
type OptimisticContext = {
|
|
118
|
+
ts: number;
|
|
119
|
+
seq: number;
|
|
120
|
+
clientId?: string;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Mutate the draft to fold client-known facts into the state: server-accepted,
|
|
124
|
+
* still-uncommitted intents (e.g. dispatch records into messages) or the live
|
|
125
|
+
* state of a sibling statewire. Runs after the optimistic folds on every
|
|
126
|
+
* published state; `materializeKey` republishes when the facts change.
|
|
127
|
+
*/
|
|
128
|
+
type Materialize<TState> = (draft: TState) => void;
|
|
129
|
+
/**
|
|
130
|
+
* fate: "aborted" = never sent, "rejected" = the server refused it
|
|
131
|
+
* (`code` "unknown-command" | "invalid-params" for the static rejects,
|
|
132
|
+
* code-less for handler rejects), "lost" = sent but no verdict will ever
|
|
133
|
+
* arrive — the record is gone (a proven seq gap) or the channel died: it
|
|
134
|
+
* may or may not have run, "failed" = the handler ran and threw,
|
|
135
|
+
* "crashed" = the handler died involuntarily, "expired" = settled —
|
|
136
|
+
* result, rejected, failed, or crashed — but the verdict outlived the
|
|
137
|
+
* server's retention.
|
|
138
|
+
* cause is which channel settled it: "server" = the server's answer;
|
|
139
|
+
* the rest are channel deaths the client settled locally.
|
|
140
|
+
*/
|
|
141
|
+
type SendFailure = {
|
|
142
|
+
fate: "rejected";
|
|
143
|
+
cause: "server";
|
|
144
|
+
code?: string;
|
|
145
|
+
message?: string;
|
|
146
|
+
payload?: unknown;
|
|
147
|
+
} | {
|
|
148
|
+
fate: "failed";
|
|
149
|
+
cause: "server";
|
|
150
|
+
message?: string;
|
|
151
|
+
} | {
|
|
152
|
+
fate: "crashed";
|
|
153
|
+
cause: "server";
|
|
154
|
+
} | {
|
|
155
|
+
fate: "expired";
|
|
156
|
+
cause: "server";
|
|
157
|
+
} | {
|
|
158
|
+
fate: "aborted";
|
|
159
|
+
cause: "unmount" | "stream-gone" | "session-lost";
|
|
160
|
+
predecessorLost?: true;
|
|
161
|
+
} | {
|
|
162
|
+
fate: "lost";
|
|
163
|
+
cause: "unmount" | "stream-gone" | "session-lost";
|
|
164
|
+
};
|
|
165
|
+
/** Held commands a proven record gap settled `{fate: "lost", cause: "session-lost"}`; return "requeue" to re-enqueue them on the reset clocks. */
|
|
166
|
+
type OnSessionLost = (pending: ReadonlyArray<{
|
|
167
|
+
method: string;
|
|
168
|
+
params: readonly unknown[];
|
|
169
|
+
ts: number;
|
|
170
|
+
seq: number;
|
|
171
|
+
clientId?: string;
|
|
172
|
+
}>) => "requeue" | "drop";
|
|
173
|
+
/** A non-accepted send retained for the user: the wire statement, its failure, and its original clocks. */
|
|
174
|
+
type FailedCommand = {
|
|
175
|
+
readonly protocol: string;
|
|
176
|
+
readonly produced?: SessionCommand["produced"];
|
|
177
|
+
readonly command: string;
|
|
178
|
+
readonly params: readonly unknown[];
|
|
179
|
+
readonly meta?: unknown;
|
|
180
|
+
readonly failure: SendFailure;
|
|
181
|
+
readonly ts: number;
|
|
182
|
+
readonly seq: number;
|
|
183
|
+
};
|
|
184
|
+
/** A command as persisted while un-durable: its lane seq plus the wire statement. */
|
|
185
|
+
type SessionCommand = {
|
|
186
|
+
seq: number;
|
|
187
|
+
produced?: {
|
|
188
|
+
wire: StatewireProtocol.Range;
|
|
189
|
+
protocols: readonly StatewireProtocol.Offer[] | "*";
|
|
190
|
+
};
|
|
191
|
+
method: string;
|
|
192
|
+
params: unknown[];
|
|
193
|
+
meta?: unknown;
|
|
194
|
+
};
|
|
195
|
+
/** A durable lane: its cmd clock and the commands the server has not marked durable. */
|
|
196
|
+
type SessionLane = {
|
|
197
|
+
nextSeq: number;
|
|
198
|
+
commands: readonly SessionCommand[];
|
|
199
|
+
/** Terminal verdicts parked for the sharer that minted the seq (shared storage only). */
|
|
200
|
+
verdicts?: readonly SessionVerdict[];
|
|
201
|
+
/** Non-accepted sends retained for the user; survive record rebases and resets. */
|
|
202
|
+
failed?: readonly FailedCommand[];
|
|
203
|
+
};
|
|
204
|
+
/** The persisted session: the client identity plus one lane per durable protocol. */
|
|
205
|
+
type SessionRecord = {
|
|
206
|
+
clientId: string;
|
|
207
|
+
lanes: Readonly<Record<string, SessionLane>>;
|
|
208
|
+
};
|
|
209
|
+
/** A terminal verdict one sharer's connection carried, parked for the sharer awaiting the seq. */
|
|
210
|
+
type SessionVerdict = {
|
|
211
|
+
seq: number;
|
|
212
|
+
type: (typeof TERMINAL)[number];
|
|
213
|
+
code?: string;
|
|
214
|
+
message?: string;
|
|
215
|
+
payload?: unknown;
|
|
216
|
+
meta?: unknown;
|
|
217
|
+
};
|
|
218
|
+
/** Session storage seam with optional asynchronous hydration and persistence. */
|
|
219
|
+
type SessionStorage = {
|
|
220
|
+
/** Resolves when a synchronous load can return the hydrated record. */
|
|
221
|
+
ready?: Promise<void>;
|
|
222
|
+
/** Resolves after all queued saves are persisted; awaited before sending statements. */
|
|
223
|
+
flush?: () => void | Promise<void>;
|
|
224
|
+
load: () => SessionRecord | null;
|
|
225
|
+
save: (record: SessionRecord) => void;
|
|
226
|
+
/** Upgrade incompatible stored commands; null discards the old record and starts a new client identity. */
|
|
227
|
+
migrate?: (record: SessionRecord, current: NonNullable<SessionCommand["produced"]>) => SessionRecord | null;
|
|
228
|
+
/** Serializes record mutations across sharers; presence marks the storage shared. */
|
|
229
|
+
lock?: <T>(fn: () => T | Promise<T>) => Promise<T>;
|
|
230
|
+
/** Notifies of record saves by other sharers; returns unsubscribe. Required alongside `lock`. */
|
|
231
|
+
subscribe?: (listener: () => void) => () => void;
|
|
232
|
+
};
|
|
233
|
+
/** Static headers, or a resolver invoked per request/attach; `staleAuth` is true right after an auth rejection. */
|
|
234
|
+
type ConnectionError = Error & {
|
|
235
|
+
fin?: StatewireHost.Fin;
|
|
236
|
+
};
|
|
237
|
+
type HeadersOption = HeadersInit | ((ctx: {
|
|
238
|
+
staleAuth: boolean;
|
|
239
|
+
}) => HeadersInit | Promise<HeadersInit>);
|
|
240
|
+
type HttpOptions = StatewireProtocol.Options & {
|
|
241
|
+
sessionStore?: SessionStorage | undefined;
|
|
242
|
+
url: string;
|
|
243
|
+
/** The session does not exist on the server yet: the first attach waits for the first command send (or an explicit `reconnect()`). */
|
|
244
|
+
isNew?: boolean;
|
|
245
|
+
headers?: HeadersOption;
|
|
246
|
+
fetch?: typeof globalThis.fetch;
|
|
247
|
+
onSessionLost?: OnSessionLost;
|
|
248
|
+
onChange?: (connection: Connection) => void;
|
|
249
|
+
onError?: (error: ConnectionError) => void;
|
|
250
|
+
/** The broadcast idle flag's rising edge: the instance went quiet. */
|
|
251
|
+
onDone?: () => void;
|
|
252
|
+
};
|
|
253
|
+
type WebsocketOptions = StatewireProtocol.Options & {
|
|
254
|
+
sessionStore?: SessionStorage | undefined;
|
|
255
|
+
url: string;
|
|
256
|
+
/** The session does not exist on the server yet: the first attach waits for the first command send (or an explicit `reconnect()`). */
|
|
257
|
+
isNew?: boolean;
|
|
258
|
+
headers?: HeadersOption;
|
|
259
|
+
protocols?: string | string[];
|
|
260
|
+
query?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
261
|
+
webSocket?: new (url: string, protocols?: string | string[]) => WebSocket;
|
|
262
|
+
onSessionLost?: OnSessionLost;
|
|
263
|
+
onChange?: (connection: Connection) => void;
|
|
264
|
+
onError?: (error: ConnectionError) => void;
|
|
265
|
+
/** The broadcast idle flag's rising edge: the instance went quiet. */
|
|
266
|
+
onDone?: () => void;
|
|
191
267
|
};
|
|
192
|
-
method: string;
|
|
193
|
-
params: unknown[];
|
|
194
|
-
meta?: unknown;
|
|
195
|
-
};
|
|
196
|
-
/** A durable lane: its cmd clock and the commands the server has not marked durable. */
|
|
197
|
-
type SessionLane = {
|
|
198
|
-
nextSeq: number;
|
|
199
|
-
commands: readonly SessionCommand[];
|
|
200
|
-
/** Terminal verdicts parked for the sharer that minted the seq (shared storage only). */
|
|
201
|
-
verdicts?: readonly SessionVerdict[];
|
|
202
|
-
/** Non-accepted sends retained for the user; survive record rebases and resets. */
|
|
203
|
-
failed?: readonly FailedCommand[];
|
|
204
|
-
};
|
|
205
|
-
/** The persisted session: the client identity plus one lane per durable protocol. */
|
|
206
|
-
type SessionRecord = {
|
|
207
|
-
clientId: string;
|
|
208
|
-
lanes: Readonly<Record<string, SessionLane>>;
|
|
209
|
-
};
|
|
210
|
-
/** A terminal verdict one sharer's connection carried, parked for the sharer awaiting the seq. */
|
|
211
|
-
type SessionVerdict = {
|
|
212
|
-
seq: number;
|
|
213
|
-
type: (typeof TERMINAL)[number];
|
|
214
|
-
code?: string;
|
|
215
|
-
message?: string;
|
|
216
|
-
payload?: unknown;
|
|
217
|
-
meta?: unknown;
|
|
218
|
-
};
|
|
219
|
-
/** Session storage seam with optional asynchronous hydration and persistence. */
|
|
220
|
-
type SessionStorage = {
|
|
221
|
-
/** Resolves when a synchronous load can return the hydrated record. */
|
|
222
|
-
ready?: Promise<void>;
|
|
223
|
-
/** Resolves after all queued saves are persisted; awaited before sending statements. */
|
|
224
|
-
flush?: () => void | Promise<void>;
|
|
225
|
-
load: () => SessionRecord | null;
|
|
226
|
-
save: (record: SessionRecord) => void;
|
|
227
|
-
/** Upgrade incompatible stored commands; null discards the old record and starts a new client identity. */
|
|
228
|
-
migrate?: (record: SessionRecord, current: NonNullable<SessionCommand["produced"]>) => SessionRecord | null;
|
|
229
|
-
/** Serializes record mutations across sharers; presence marks the storage shared. */
|
|
230
|
-
lock?: <T>(fn: () => T | Promise<T>) => Promise<T>;
|
|
231
|
-
/** Notifies of record saves by other sharers; returns unsubscribe. Required alongside `lock`. */
|
|
232
|
-
subscribe?: (listener: () => void) => () => void;
|
|
233
|
-
};
|
|
234
|
-
/** Static headers, or a resolver invoked per request/attach; `staleAuth` is true right after an auth rejection. */
|
|
235
|
-
type ConnectionError = Error & {
|
|
236
|
-
fin?: StatewireHost.Fin;
|
|
237
|
-
};
|
|
238
|
-
type HeadersOption = HeadersInit | ((ctx: {
|
|
239
|
-
staleAuth: boolean;
|
|
240
|
-
}) => HeadersInit | Promise<HeadersInit>);
|
|
241
|
-
type HttpOptions = StatewireProtocol.Options & {
|
|
242
|
-
sessionStore?: SessionStorage | undefined;
|
|
243
|
-
url: string;
|
|
244
|
-
/** The session does not exist on the server yet: the first attach waits for the first command send (or an explicit `reconnect()`). */
|
|
245
|
-
isNew?: boolean;
|
|
246
|
-
headers?: HeadersOption;
|
|
247
|
-
fetch?: typeof globalThis.fetch;
|
|
248
|
-
onSessionLost?: OnSessionLost;
|
|
249
|
-
onChange?: (connection: Connection) => void;
|
|
250
|
-
onError?: (error: ConnectionError) => void;
|
|
251
|
-
/** The broadcast idle flag's rising edge: the instance went quiet. */
|
|
252
|
-
onDone?: () => void;
|
|
253
|
-
};
|
|
254
|
-
type WebsocketOptions = StatewireProtocol.Options & {
|
|
255
|
-
sessionStore?: SessionStorage | undefined;
|
|
256
|
-
url: string;
|
|
257
|
-
/** The session does not exist on the server yet: the first attach waits for the first command send (or an explicit `reconnect()`). */
|
|
258
|
-
isNew?: boolean;
|
|
259
|
-
headers?: HeadersOption;
|
|
260
|
-
protocols?: string | string[];
|
|
261
|
-
query?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
262
|
-
webSocket?: new (url: string, protocols?: string | string[]) => WebSocket;
|
|
263
|
-
onSessionLost?: OnSessionLost;
|
|
264
|
-
onChange?: (connection: Connection) => void;
|
|
265
|
-
onError?: (error: ConnectionError) => void;
|
|
266
|
-
/** The broadcast idle flag's rising edge: the instance went quiet. */
|
|
267
|
-
onDone?: () => void;
|
|
268
|
-
};
|
|
269
268
|
}
|
|
270
|
-
//#endregion
|
|
271
|
-
export { StatewireClient, StatewireResource, useStatewire };
|
|
272
269
|
//# sourceMappingURL=statewire.d.ts.map
|
package/dist/statewire.d.ts.map
CHANGED
|
@@ -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AAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;QAC3C,sEAAsE;QACtE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;KACrB,CAAC;IAEF,KAAY,gBAAgB,GAAG,iBAAiB,CAAC,OAAO,GAAG;QACzD,YAAY,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;QAC1C,GAAG,EAAE,MAAM,CAAC;QACZ,sIAAsI;QACtI,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,OAAO,CAAC,EAAE,aAAa,CAAC;QACxB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAC9B,KAAK,CAAC,EACF,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACtB,CAAC,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;QACrE,SAAS,CAAC,EAAE,KAAK,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,SAAS,CAAC;QAC1E,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,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
|
@@ -2,7 +2,7 @@ import { CONNECTED_CONNECTION, useStatewireCore } from "./client/core.js";
|
|
|
2
2
|
import { DocumentStorageContext, LinkContext, ProtocolContext, SessionStorageContext } from "./client/sessionStore.js";
|
|
3
3
|
import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "@assistant-ui/tap/react-shim";
|
|
4
4
|
import { createTapRoot, flushTapSync, resource, useContextProvider, useResource, useResources, withKey } from "@assistant-ui/tap";
|
|
5
|
-
|
|
5
|
+
// src/statewire.ts
|
|
6
6
|
const useSessionTransport = ({ transport, session, documents, protocol, link }) => useContextProvider(SessionStorageContext, session, () => useContextProvider(DocumentStorageContext, documents, () => useContextProvider(ProtocolContext, protocol, () => useContextProvider(LinkContext, link, () => useResource(transport)))));
|
|
7
7
|
const SessionTransport = resource(useSessionTransport);
|
|
8
8
|
const useStatewire = (options) => {
|
|
@@ -131,7 +131,6 @@ var StatewireClient = class {
|
|
|
131
131
|
this.root.unmount();
|
|
132
132
|
}
|
|
133
133
|
};
|
|
134
|
-
//#endregion
|
|
135
134
|
export { StatewireClient, StatewireResource, useStatewire };
|
|
136
135
|
|
|
137
136
|
//# sourceMappingURL=statewire.js.map
|