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.
- package/dist/client/core.d.ts +4 -3
- package/dist/client/core.d.ts.map +1 -1
- package/dist/client/core.js +56 -45
- package/dist/client/core.js.map +1 -1
- package/dist/client/session.d.ts +56 -12
- package/dist/client/session.d.ts.map +1 -1
- package/dist/client/session.js +632 -260
- package/dist/client/session.js.map +1 -1
- package/dist/client/sessionStore.d.ts +1 -0
- package/dist/client/sessionStore.d.ts.map +1 -1
- package/dist/client/sessionStore.js +1 -0
- package/dist/client/sessionStore.js.map +1 -1
- package/dist/host/host.d.ts +6 -5
- package/dist/host/host.d.ts.map +1 -1
- package/dist/host/host.js.map +1 -1
- package/dist/indexedDb.d.ts +15 -0
- package/dist/indexedDb.d.ts.map +1 -0
- package/dist/indexedDb.js +171 -0
- package/dist/indexedDb.js.map +1 -0
- package/dist/statewire.d.ts +117 -59
- package/dist/statewire.d.ts.map +1 -1
- package/dist/statewire.js +13 -25
- package/dist/statewire.js.map +1 -1
- package/dist/storage.d.ts +42 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +387 -125
- package/dist/storage.js.map +1 -1
- package/dist/transports/remote.d.ts.map +1 -1
- package/dist/transports/remote.js +7 -9
- package/dist/transports/remote.js.map +1 -1
- package/dist/types.d.ts +6 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -1
- package/src/client/core.ts +81 -64
- package/src/client/session.ts +886 -424
- package/src/client/sessionStore.ts +2 -0
- package/src/host/host.ts +10 -3
- package/src/indexedDb.ts +167 -0
- package/src/statewire.ts +133 -86
- package/src/storage.ts +548 -112
- package/src/transports/remote.ts +13 -14
- package/src/types.ts +6 -7
package/src/transports/remote.ts
CHANGED
|
@@ -4,13 +4,12 @@ import type { Statewire } from "../types";
|
|
|
4
4
|
import {
|
|
5
5
|
documentSource,
|
|
6
6
|
invokeProtocol,
|
|
7
|
-
discardFailed,
|
|
8
|
-
failedCommands,
|
|
9
7
|
holdOutbox,
|
|
8
|
+
insertOutbox,
|
|
10
9
|
outboxEntries,
|
|
11
10
|
releaseOutbox,
|
|
12
11
|
removeOutbox,
|
|
13
|
-
|
|
12
|
+
updateOutbox,
|
|
14
13
|
setTransport,
|
|
15
14
|
useStatewireSession,
|
|
16
15
|
setContext,
|
|
@@ -48,19 +47,19 @@ export const useStatewireRemote = <
|
|
|
48
47
|
params: readonly unknown[],
|
|
49
48
|
options?: StatewireClient.InvokeOptions,
|
|
50
49
|
) => invokeProtocol(s, protocol, method, params, options),
|
|
51
|
-
failures: {
|
|
52
|
-
list: () => failedCommands(s),
|
|
53
|
-
retry: (entry: StatewireClient.FailedCommand) => retryFailed(s, entry),
|
|
54
|
-
discard: (entry: StatewireClient.FailedCommand) =>
|
|
55
|
-
discardFailed(s, entry),
|
|
56
|
-
},
|
|
57
50
|
outbox: {
|
|
58
51
|
list: () => outboxEntries(s),
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
release: (
|
|
62
|
-
|
|
63
|
-
|
|
52
|
+
clientId: () => s.record.clientId,
|
|
53
|
+
hold: (id: string) => holdOutbox(s, id),
|
|
54
|
+
release: (id: string) => releaseOutbox(s, id),
|
|
55
|
+
remove: (id: string) => removeOutbox(s, id),
|
|
56
|
+
update: (
|
|
57
|
+
id: string,
|
|
58
|
+
fn: (
|
|
59
|
+
entry: StatewireClient.OutboxEntry,
|
|
60
|
+
) => StatewireClient.OutboxPatch,
|
|
61
|
+
) => updateOutbox(s, id, fn),
|
|
62
|
+
insert: (entry: StatewireClient.OutboxInsert) => insertOutbox(s, entry),
|
|
64
63
|
},
|
|
65
64
|
}),
|
|
66
65
|
[s],
|
package/src/types.ts
CHANGED
|
@@ -30,6 +30,8 @@ export namespace Statewire {
|
|
|
30
30
|
status: "queued" | "posted" | "applied" | "settled";
|
|
31
31
|
result?: unknown;
|
|
32
32
|
failure?: StatewireClient.SendFailure;
|
|
33
|
+
/** The command's client-only `localMeta`. */
|
|
34
|
+
localMeta?: unknown;
|
|
33
35
|
};
|
|
34
36
|
}[keyof TCommands];
|
|
35
37
|
|
|
@@ -87,18 +89,15 @@ export interface Statewire<
|
|
|
87
89
|
attaching?: (attach: StatewireHost.Attach) => void;
|
|
88
90
|
/** Called by the serving host when an attach ends; its ephemeral documents and includes are gone. */
|
|
89
91
|
detached?: (attach: StatewireHost.Attach) => void;
|
|
90
|
-
/** The
|
|
91
|
-
failures?: {
|
|
92
|
-
list: () => readonly StatewireClient.FailedCommand[];
|
|
93
|
-
retry: (entry: StatewireClient.FailedCommand) => Promise<unknown>;
|
|
94
|
-
discard: (entry: StatewireClient.FailedCommand) => void;
|
|
95
|
-
};
|
|
96
|
-
/** The outbox of commands without a seq; present on transports with a durable session. */
|
|
92
|
+
/** The outbox; present on transports with a durable session. */
|
|
97
93
|
outbox?: {
|
|
98
94
|
list: () => readonly StatewireClient.OutboxEntry[];
|
|
95
|
+
clientId: () => string;
|
|
99
96
|
hold: StatewireClient.Outbox["hold"];
|
|
100
97
|
release: StatewireClient.Outbox["release"];
|
|
101
98
|
remove: StatewireClient.Outbox["remove"];
|
|
99
|
+
update: StatewireClient.Outbox["update"];
|
|
100
|
+
insert: StatewireClient.Outbox["insert"];
|
|
102
101
|
};
|
|
103
102
|
}
|
|
104
103
|
|