@automerge/subduction 0.8.0-alpha.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/wasm-base64.cjs +1 -1
- package/dist/cjs/web-bindings.cjs +308 -87
- package/dist/cjs/web.cjs +309 -88
- package/dist/esm/wasm-base64.js +1 -1
- package/dist/iife/index.js +309 -88
- package/dist/index.d.ts +87 -24
- package/dist/subduction.wasm +0 -0
- package/dist/wasm_bindgen/bundler/snippets/subduction_wasm-0ed7fd66cebca59f/inline0.js +9 -0
- package/dist/wasm_bindgen/bundler/subduction_wasm.d.ts +87 -24
- package/dist/wasm_bindgen/bundler/subduction_wasm_bg.js +294 -96
- package/dist/wasm_bindgen/bundler/subduction_wasm_bg.wasm +0 -0
- package/dist/wasm_bindgen/bundler/subduction_wasm_bg.wasm.d.ts +28 -20
- package/dist/wasm_bindgen/nodejs/snippets/subduction_wasm-0ed7fd66cebca59f/inline0.js +9 -0
- package/dist/wasm_bindgen/nodejs/subduction_wasm.cjs +296 -96
- package/dist/wasm_bindgen/nodejs/subduction_wasm.d.ts +87 -24
- package/dist/wasm_bindgen/nodejs/subduction_wasm_bg.wasm +0 -0
- package/dist/wasm_bindgen/nodejs/subduction_wasm_bg.wasm.d.ts +28 -20
- package/dist/wasm_bindgen/web/snippets/subduction_wasm-0ed7fd66cebca59f/inline0.js +9 -0
- package/dist/wasm_bindgen/web/subduction_wasm.d.ts +115 -44
- package/dist/wasm_bindgen/web/subduction_wasm.js +296 -96
- package/dist/wasm_bindgen/web/subduction_wasm_bg.wasm +0 -0
- package/dist/wasm_bindgen/web/subduction_wasm_bg.wasm.d.ts +28 -20
- package/package.json +1 -1
- /package/dist/wasm_bindgen/bundler/snippets/{sedimentree_wasm-68c0499598a3382c → sedimentree_wasm-1de4a01519b0f11f}/inline0.js +0 -0
- /package/dist/wasm_bindgen/bundler/snippets/{sedimentree_wasm-68c0499598a3382c → sedimentree_wasm-1de4a01519b0f11f}/inline1.js +0 -0
- /package/dist/wasm_bindgen/bundler/snippets/{sedimentree_wasm-68c0499598a3382c → sedimentree_wasm-1de4a01519b0f11f}/inline2.js +0 -0
- /package/dist/wasm_bindgen/nodejs/snippets/{sedimentree_wasm-68c0499598a3382c → sedimentree_wasm-1de4a01519b0f11f}/inline0.js +0 -0
- /package/dist/wasm_bindgen/nodejs/snippets/{sedimentree_wasm-68c0499598a3382c → sedimentree_wasm-1de4a01519b0f11f}/inline1.js +0 -0
- /package/dist/wasm_bindgen/nodejs/snippets/{sedimentree_wasm-68c0499598a3382c → sedimentree_wasm-1de4a01519b0f11f}/inline2.js +0 -0
- /package/dist/wasm_bindgen/web/snippets/{sedimentree_wasm-68c0499598a3382c → sedimentree_wasm-1de4a01519b0f11f}/inline0.js +0 -0
- /package/dist/wasm_bindgen/web/snippets/{sedimentree_wasm-68c0499598a3382c → sedimentree_wasm-1de4a01519b0f11f}/inline1.js +0 -0
- /package/dist/wasm_bindgen/web/snippets/{sedimentree_wasm-68c0499598a3382c → sedimentree_wasm-1de4a01519b0f11f}/inline2.js +0 -0
|
@@ -29,6 +29,7 @@ export interface Transport {
|
|
|
29
29
|
sendBytes(bytes: Uint8Array): Promise<void>;
|
|
30
30
|
recvBytes(): Promise<Uint8Array>;
|
|
31
31
|
disconnect(): Promise<void>;
|
|
32
|
+
onDisconnect(callback: () => void): void;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
|
|
@@ -70,23 +71,30 @@ export class AuthenticatedLongPoll {
|
|
|
70
71
|
* There are three ways to obtain an `AuthenticatedTransport`:
|
|
71
72
|
*
|
|
72
73
|
* 1. **Custom transport** — implement the `Transport` interface
|
|
73
|
-
* (`sendBytes`/`recvBytes`/`disconnect`) and call
|
|
74
|
+
* (`sendBytes`/`recvBytes`/`disconnect`/`onDisconnect`) and call
|
|
75
|
+
* [`setup`](Self::setup):
|
|
74
76
|
*
|
|
75
77
|
* ```js
|
|
76
|
-
* const auth = await AuthenticatedTransport.setup(myTransport, signer, peerId)
|
|
78
|
+
* const auth = await AuthenticatedTransport.setup(myTransport, signer, peerId, (peerId) => {
|
|
79
|
+
* console.log(`${peerId} disconnected`);
|
|
80
|
+
* });
|
|
77
81
|
* ```
|
|
78
82
|
*
|
|
79
83
|
* 2. **From WebSocket** — authenticate via [`SubductionWebSocket`] then convert:
|
|
80
84
|
*
|
|
81
85
|
* ```js
|
|
82
|
-
* const wsAuth = await SubductionWebSocket.tryConnect(url, signer, peerId,
|
|
86
|
+
* const wsAuth = await SubductionWebSocket.tryConnect(url, signer, peerId, (peerId) => {
|
|
87
|
+
* console.log(`${peerId} disconnected`);
|
|
88
|
+
* });
|
|
83
89
|
* const auth = wsAuth.toTransport();
|
|
84
90
|
* ```
|
|
85
91
|
*
|
|
86
92
|
* 3. **From HTTP long-poll** — same pattern via [`SubductionLongPoll`]:
|
|
87
93
|
*
|
|
88
94
|
* ```js
|
|
89
|
-
* const lpAuth = await SubductionLongPoll.tryConnect(url, signer, peerId,
|
|
95
|
+
* const lpAuth = await SubductionLongPoll.tryConnect(url, signer, peerId, (peerId) => {
|
|
96
|
+
* console.log(`${peerId} disconnected`);
|
|
97
|
+
* });
|
|
90
98
|
* const auth = lpAuth.toTransport();
|
|
91
99
|
* ```
|
|
92
100
|
*/
|
|
@@ -102,7 +110,7 @@ export class AuthenticatedTransport {
|
|
|
102
110
|
*
|
|
103
111
|
* # Arguments
|
|
104
112
|
*
|
|
105
|
-
* * `transport` - A `Transport` implementing `sendBytes`/`recvBytes`/`disconnect`
|
|
113
|
+
* * `transport` - A `Transport` implementing `sendBytes`/`recvBytes`/`disconnect`/`onDisconnect`
|
|
106
114
|
* * `signer` - The responder's signer for authentication
|
|
107
115
|
* * `max_drift_seconds` - Maximum acceptable clock drift in seconds (default: 600)
|
|
108
116
|
*
|
|
@@ -110,19 +118,19 @@ export class AuthenticatedTransport {
|
|
|
110
118
|
*
|
|
111
119
|
* Returns a [`HandshakeError`](WasmHandshakeError) if the handshake fails.
|
|
112
120
|
*/
|
|
113
|
-
static accept(transport: Transport, signer: any, max_drift_seconds?: number | null): Promise<AuthenticatedTransport>;
|
|
121
|
+
static accept(transport: Transport, signer: any, max_drift_seconds?: number | null, on_disconnect?: Function | null): Promise<AuthenticatedTransport>;
|
|
114
122
|
/**
|
|
115
123
|
* Run the Subduction handshake over a custom transport, producing an
|
|
116
124
|
* authenticated transport.
|
|
117
125
|
*
|
|
118
126
|
* The `transport` object must implement the `Transport` interface
|
|
119
|
-
* (`sendBytes`/`recvBytes`/`disconnect`).
|
|
127
|
+
* (`sendBytes`/`recvBytes`/`disconnect`/`onDisconnect`).
|
|
120
128
|
* The same object is used for both the handshake phase and post-handshake
|
|
121
129
|
* communication.
|
|
122
130
|
*
|
|
123
131
|
* # Arguments
|
|
124
132
|
*
|
|
125
|
-
* * `transport` - A `Transport` implementing `sendBytes`/`recvBytes`/`disconnect`
|
|
133
|
+
* * `transport` - A `Transport` implementing `sendBytes`/`recvBytes`/`disconnect`/`onDisconnect`
|
|
126
134
|
* * `signer` - The client's signer for authentication
|
|
127
135
|
* * `expected_peer_id` - The expected server peer ID (verified during handshake)
|
|
128
136
|
*
|
|
@@ -130,7 +138,7 @@ export class AuthenticatedTransport {
|
|
|
130
138
|
*
|
|
131
139
|
* Returns a [`HandshakeError`](WasmHandshakeError) if the handshake fails.
|
|
132
140
|
*/
|
|
133
|
-
static setup(transport: Transport, signer: any, expected_peer_id: PeerId): Promise<AuthenticatedTransport>;
|
|
141
|
+
static setup(transport: Transport, signer: any, expected_peer_id: PeerId, on_disconnect?: Function | null): Promise<AuthenticatedTransport>;
|
|
134
142
|
/**
|
|
135
143
|
* Run the Subduction handshake over a custom transport using discovery
|
|
136
144
|
* mode, producing an authenticated transport.
|
|
@@ -141,7 +149,7 @@ export class AuthenticatedTransport {
|
|
|
141
149
|
*
|
|
142
150
|
* # Arguments
|
|
143
151
|
*
|
|
144
|
-
* * `transport` - A `Transport` implementing `sendBytes`/`recvBytes`/`disconnect`
|
|
152
|
+
* * `transport` - A `Transport` implementing `sendBytes`/`recvBytes`/`disconnect`/`onDisconnect`
|
|
145
153
|
* * `signer` - The client's signer for authentication
|
|
146
154
|
* * `service_name` - Shared service name for discovery.
|
|
147
155
|
* Defaults to [`DEFAULT_LOCAL_SERVICE_NAME`] (`"subduction:local"`) if omitted.
|
|
@@ -150,7 +158,7 @@ export class AuthenticatedTransport {
|
|
|
150
158
|
*
|
|
151
159
|
* Returns a [`HandshakeError`](WasmHandshakeError) if the handshake fails.
|
|
152
160
|
*/
|
|
153
|
-
static setupDiscover(transport: Transport, signer: any, service_name?: string | null): Promise<AuthenticatedTransport>;
|
|
161
|
+
static setupDiscover(transport: Transport, signer: any, service_name?: string | null, on_disconnect?: Function | null): Promise<AuthenticatedTransport>;
|
|
154
162
|
/**
|
|
155
163
|
* The verified peer identity.
|
|
156
164
|
*/
|
|
@@ -639,13 +647,20 @@ export class MessagePortTransport {
|
|
|
639
647
|
free(): void;
|
|
640
648
|
[Symbol.dispose](): void;
|
|
641
649
|
/**
|
|
642
|
-
* Disconnect (close the port).
|
|
650
|
+
* Disconnect (close the port) and fire the `onDisconnect` callback if registered.
|
|
643
651
|
*/
|
|
644
652
|
disconnect(): Promise<any>;
|
|
645
653
|
/**
|
|
646
654
|
* Create a new connection wrapping the given `MessagePort`.
|
|
647
655
|
*/
|
|
648
656
|
constructor(port: any);
|
|
657
|
+
/**
|
|
658
|
+
* Register a callback to be invoked when the transport disconnects.
|
|
659
|
+
*
|
|
660
|
+
* Part of the [`Transport`](super::JsTransport) interface contract.
|
|
661
|
+
* Typically called by internal wiring rather than directly by user code.
|
|
662
|
+
*/
|
|
663
|
+
onDisconnect(callback: Function): void;
|
|
649
664
|
/**
|
|
650
665
|
* Receive raw bytes (for the handshake phase).
|
|
651
666
|
*/
|
|
@@ -1136,7 +1151,7 @@ export class Subduction {
|
|
|
1136
1151
|
*
|
|
1137
1152
|
* Returns [`WasmHydrationError`] if hydration fails.
|
|
1138
1153
|
*/
|
|
1139
|
-
static hydrate(signer: any, storage: SedimentreeStorage, service_name?: string | null, hash_metric_override?: (digest: Digest) => Depth | null, max_pending_blob_requests?: number | null): Promise<Subduction>;
|
|
1154
|
+
static hydrate(signer: any, storage: SedimentreeStorage, service_name?: string | null, hash_metric_override?: (digest: Digest) => Depth | null, max_pending_blob_requests?: number | null, policy?: any | null, on_remote_heads?: Function | null, on_ephemeral?: Function | null): Promise<Subduction>;
|
|
1140
1155
|
/**
|
|
1141
1156
|
* Link two local [`Subduction`](WasmSubduction) instances over a
|
|
1142
1157
|
* [`MessageChannel`](web_sys::MessageChannel).
|
|
@@ -1161,13 +1176,23 @@ export class Subduction {
|
|
|
1161
1176
|
* When set, clients can connect without knowing the server's peer ID.
|
|
1162
1177
|
* * `hash_metric_override` - Optional custom depth metric function
|
|
1163
1178
|
* * `max_pending_blob_requests` - Optional maximum number of pending blob requests (default: 10,000)
|
|
1179
|
+
* * `policy` - Optional JS object implementing authorization.
|
|
1180
|
+
* Must have `authorizeConnect(...)`, `authorizeFetch(...)`, `authorizePut(...)`,
|
|
1181
|
+
* `filterAuthorizedFetch(...)`. Defaults to allow-all.
|
|
1164
1182
|
*
|
|
1165
1183
|
* # Panics
|
|
1166
1184
|
*
|
|
1167
1185
|
* Panics if `hash_metric_override` is `Some` but the underlying JS value
|
|
1168
1186
|
* cannot be cast to a `Function`.
|
|
1169
1187
|
*/
|
|
1170
|
-
constructor(signer: any, storage: SedimentreeStorage, service_name?: string | null, hash_metric_override?: (digest: Digest) => Depth | null, max_pending_blob_requests?: number | null);
|
|
1188
|
+
constructor(signer: any, storage: SedimentreeStorage, service_name?: string | null, hash_metric_override?: (digest: Digest) => Depth | null, max_pending_blob_requests?: number | null, policy?: any | null, on_remote_heads?: Function | null, on_ephemeral?: Function | null);
|
|
1189
|
+
/**
|
|
1190
|
+
* Publish an ephemeral message to all subscribers of a sedimentree.
|
|
1191
|
+
*
|
|
1192
|
+
* The payload is opaque bytes — encoding is the caller's responsibility.
|
|
1193
|
+
* Messages are fire-and-forget; delivery is best-effort.
|
|
1194
|
+
*/
|
|
1195
|
+
publishEphemeral(id: SedimentreeId, payload: Uint8Array): Promise<void>;
|
|
1171
1196
|
/**
|
|
1172
1197
|
* Remove a Sedimentree and all associated data.
|
|
1173
1198
|
*
|
|
@@ -1184,6 +1209,11 @@ export class Subduction {
|
|
|
1184
1209
|
* Get all known Sedimentree IDs
|
|
1185
1210
|
*/
|
|
1186
1211
|
sedimentreeIds(): Promise<SedimentreeId[]>;
|
|
1212
|
+
/**
|
|
1213
|
+
* Subscribe to ephemeral messages for the given sedimentree IDs
|
|
1214
|
+
* from all connected peers.
|
|
1215
|
+
*/
|
|
1216
|
+
subscribeEphemeral(ids: SedimentreeId[]): Promise<void>;
|
|
1187
1217
|
/**
|
|
1188
1218
|
* Request batch sync for a given Sedimentree ID from all connected peers.
|
|
1189
1219
|
*
|
|
@@ -1213,6 +1243,11 @@ export class Subduction {
|
|
|
1213
1243
|
* Returns a [`WasmIoError`] if storage or networking fail.
|
|
1214
1244
|
*/
|
|
1215
1245
|
syncWithPeer(to_ask: PeerId, id: SedimentreeId, subscribe: boolean, timeout_milliseconds?: bigint | null): Promise<PeerBatchSyncResult>;
|
|
1246
|
+
/**
|
|
1247
|
+
* Unsubscribe from ephemeral messages for the given sedimentree IDs
|
|
1248
|
+
* from all connected peers.
|
|
1249
|
+
*/
|
|
1250
|
+
unsubscribeEphemeral(ids: SedimentreeId[]): Promise<void>;
|
|
1216
1251
|
/**
|
|
1217
1252
|
* Get the backing storage.
|
|
1218
1253
|
*/
|
|
@@ -1222,7 +1257,7 @@ export class Subduction {
|
|
|
1222
1257
|
/**
|
|
1223
1258
|
* JS-facing wrapper around [`HttpLongPollTransport`] that exposes the
|
|
1224
1259
|
* byte-oriented [`Transport`](super::JsTransport) interface
|
|
1225
|
-
* (`sendBytes`/`recvBytes`/`disconnect`) so it can be used as a
|
|
1260
|
+
* (`sendBytes`/`recvBytes`/`disconnect`/`onDisconnect`) so it can be used as a
|
|
1226
1261
|
* duck-typed `JsTransport` from JavaScript.
|
|
1227
1262
|
*/
|
|
1228
1263
|
export class SubductionHttpLongPoll {
|
|
@@ -1232,11 +1267,20 @@ export class SubductionHttpLongPoll {
|
|
|
1232
1267
|
/**
|
|
1233
1268
|
* Disconnect from the peer gracefully.
|
|
1234
1269
|
*
|
|
1270
|
+
* Fires the `onDisconnect` callback if one is registered.
|
|
1271
|
+
*
|
|
1235
1272
|
* # Errors
|
|
1236
1273
|
*
|
|
1237
1274
|
* Returns an error if the disconnect fails.
|
|
1238
1275
|
*/
|
|
1239
1276
|
disconnect(): Promise<void>;
|
|
1277
|
+
/**
|
|
1278
|
+
* Register a callback to be invoked when the transport disconnects.
|
|
1279
|
+
*
|
|
1280
|
+
* Part of the [`Transport`](super::JsTransport) interface contract.
|
|
1281
|
+
* Typically called by internal wiring rather than directly by user code.
|
|
1282
|
+
*/
|
|
1283
|
+
onDisconnect(callback: Function): void;
|
|
1240
1284
|
/**
|
|
1241
1285
|
* Receive the next message frame as raw bytes.
|
|
1242
1286
|
*
|
|
@@ -1272,13 +1316,13 @@ export class SubductionLongPoll {
|
|
|
1272
1316
|
* * `base_url` - The server's HTTP base URL (e.g., `http://localhost:8080`)
|
|
1273
1317
|
* * `signer` - The client's signer for authentication
|
|
1274
1318
|
* * `expected_peer_id` - The expected server peer ID (verified during handshake)
|
|
1275
|
-
* * `
|
|
1319
|
+
* * `on_disconnect` - Optional callback invoked with the peer's [`PeerId`] when the connection closes
|
|
1276
1320
|
*
|
|
1277
1321
|
* # Errors
|
|
1278
1322
|
*
|
|
1279
1323
|
* Returns [`LongPollTransportError`] if connection or handshake fails.
|
|
1280
1324
|
*/
|
|
1281
|
-
static tryConnect(base_url: string, signer: any, expected_peer_id: PeerId): Promise<AuthenticatedLongPoll>;
|
|
1325
|
+
static tryConnect(base_url: string, signer: any, expected_peer_id: PeerId, on_disconnect?: Function | null): Promise<AuthenticatedLongPoll>;
|
|
1282
1326
|
/**
|
|
1283
1327
|
* Connect to a server using discovery mode.
|
|
1284
1328
|
*
|
|
@@ -1292,7 +1336,7 @@ export class SubductionLongPoll {
|
|
|
1292
1336
|
*
|
|
1293
1337
|
* Returns [`LongPollTransportError`] if connection or handshake fails.
|
|
1294
1338
|
*/
|
|
1295
|
-
static tryDiscover(base_url: string, signer: any, service_name?: string | null): Promise<AuthenticatedLongPoll>;
|
|
1339
|
+
static tryDiscover(base_url: string, signer: any, service_name?: string | null, on_disconnect?: Function | null): Promise<AuthenticatedLongPoll>;
|
|
1296
1340
|
}
|
|
1297
1341
|
|
|
1298
1342
|
/**
|
|
@@ -1311,6 +1355,16 @@ export class SubductionWebSocket {
|
|
|
1311
1355
|
* Disconnect from the peer gracefully.
|
|
1312
1356
|
*/
|
|
1313
1357
|
disconnect(): Promise<void>;
|
|
1358
|
+
/**
|
|
1359
|
+
* Register a callback to be invoked when the WebSocket closes.
|
|
1360
|
+
*
|
|
1361
|
+
* Part of the [`Transport`](super::JsTransport) interface contract.
|
|
1362
|
+
* Typically called by internal wiring (factory methods like `tryConnect`
|
|
1363
|
+
* and `tryDiscover`) rather than directly by user code.
|
|
1364
|
+
*
|
|
1365
|
+
* The callback is fired from the browser WebSocket's `onclose` handler.
|
|
1366
|
+
*/
|
|
1367
|
+
onDisconnect(callback: Function): void;
|
|
1314
1368
|
/**
|
|
1315
1369
|
* Receive the next message frame as raw bytes.
|
|
1316
1370
|
*
|
|
@@ -1338,13 +1392,13 @@ export class SubductionWebSocket {
|
|
|
1338
1392
|
* * `ws` - An existing WebSocket (CONNECTING or OPEN)
|
|
1339
1393
|
* * `signer` - The client's signer for authentication
|
|
1340
1394
|
* * `expected_peer_id` - The expected server peer ID (verified during handshake)
|
|
1341
|
-
* * `
|
|
1395
|
+
* * `on_disconnect` - Optional callback invoked with the peer's [`PeerId`] when the connection closes
|
|
1342
1396
|
*
|
|
1343
1397
|
* # Errors
|
|
1344
1398
|
*
|
|
1345
1399
|
* Returns an error if the handshake fails (signature invalid, wrong peer, etc.)
|
|
1346
1400
|
*/
|
|
1347
|
-
static setup(ws: WebSocket, signer: any, expected_peer_id: PeerId): Promise<AuthenticatedWebSocket>;
|
|
1401
|
+
static setup(ws: WebSocket, signer: any, expected_peer_id: PeerId, on_disconnect?: Function | null): Promise<AuthenticatedWebSocket>;
|
|
1348
1402
|
/**
|
|
1349
1403
|
* Connect to a WebSocket server with mutual authentication via handshake.
|
|
1350
1404
|
*
|
|
@@ -1353,13 +1407,15 @@ export class SubductionWebSocket {
|
|
|
1353
1407
|
* * `address` - The WebSocket URL to connect to
|
|
1354
1408
|
* * `signer` - The client's signer for authentication
|
|
1355
1409
|
* * `expected_peer_id` - The expected server peer ID (verified during handshake)
|
|
1410
|
+
* * `on_disconnect` - Optional callback invoked with the peer's [`PeerId`] when the connection closes
|
|
1411
|
+
*
|
|
1356
1412
|
* # Errors
|
|
1357
1413
|
*
|
|
1358
1414
|
* Returns an error if:
|
|
1359
1415
|
* - The WebSocket connection could not be established
|
|
1360
1416
|
* - The handshake fails (signature invalid, wrong server, clock drift, etc.)
|
|
1361
1417
|
*/
|
|
1362
|
-
static tryConnect(address: URL, signer: any, expected_peer_id: PeerId): Promise<AuthenticatedWebSocket>;
|
|
1418
|
+
static tryConnect(address: URL, signer: any, expected_peer_id: PeerId, on_disconnect?: Function | null): Promise<AuthenticatedWebSocket>;
|
|
1363
1419
|
/**
|
|
1364
1420
|
* Connect to a WebSocket server using discovery mode.
|
|
1365
1421
|
*
|
|
@@ -1371,9 +1427,9 @@ export class SubductionWebSocket {
|
|
|
1371
1427
|
*
|
|
1372
1428
|
* * `address` - The WebSocket URL to connect to
|
|
1373
1429
|
* * `signer` - The client's signer for authentication
|
|
1374
|
-
* * `timeout_milliseconds` - Request timeout in milliseconds. Defaults to 30000 (30s).
|
|
1375
1430
|
* * `service_name` - The service name for discovery (e.g., `localhost:8080`).
|
|
1376
1431
|
* If omitted, the host is extracted from the URL.
|
|
1432
|
+
* * `on_disconnect` - Optional callback invoked with the peer's [`PeerId`] when the connection closes
|
|
1377
1433
|
*
|
|
1378
1434
|
* # Errors
|
|
1379
1435
|
*
|
|
@@ -1381,7 +1437,7 @@ export class SubductionWebSocket {
|
|
|
1381
1437
|
* - The WebSocket connection could not be established
|
|
1382
1438
|
* - The handshake fails (signature invalid, clock drift, etc.)
|
|
1383
1439
|
*/
|
|
1384
|
-
static tryDiscover(address: URL, signer: any, service_name?: string | null): Promise<AuthenticatedWebSocket>;
|
|
1440
|
+
static tryDiscover(address: URL, signer: any, service_name?: string | null, on_disconnect?: Function | null): Promise<AuthenticatedWebSocket>;
|
|
1385
1441
|
}
|
|
1386
1442
|
|
|
1387
1443
|
/**
|
|
@@ -1492,9 +1548,16 @@ export class SyncStats {
|
|
|
1492
1548
|
*/
|
|
1493
1549
|
readonly fragmentsSent: number;
|
|
1494
1550
|
/**
|
|
1495
|
-
* Returns true if no
|
|
1551
|
+
* Returns true if no commits or fragments were transferred.
|
|
1552
|
+
*
|
|
1553
|
+
* Note: `remoteHeads` may still be non-empty (heads metadata is not
|
|
1554
|
+
* considered "data" for this check).
|
|
1496
1555
|
*/
|
|
1497
1556
|
readonly isEmpty: boolean;
|
|
1557
|
+
/**
|
|
1558
|
+
* The remote peer's heads for this sedimentree.
|
|
1559
|
+
*/
|
|
1560
|
+
readonly remoteHeads: Digest[];
|
|
1498
1561
|
/**
|
|
1499
1562
|
* Total items received (commits + fragments).
|
|
1500
1563
|
*/
|
|
@@ -1594,8 +1657,8 @@ export interface InitOutput {
|
|
|
1594
1657
|
readonly webcryptosigner_verifyingKey: (a: number) => any;
|
|
1595
1658
|
readonly webcryptosigner_peerId: (a: number) => number;
|
|
1596
1659
|
readonly __wbg_subduction_free: (a: number, b: number) => void;
|
|
1597
|
-
readonly subduction_new: (a: any, b: any, c: number, d: number, e: number, f: number) => number;
|
|
1598
|
-
readonly subduction_hydrate: (a: any, b: any, c: number, d: number, e: number, f: number) => any;
|
|
1660
|
+
readonly subduction_new: (a: any, b: any, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => number;
|
|
1661
|
+
readonly subduction_hydrate: (a: any, b: any, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => any;
|
|
1599
1662
|
readonly subduction_addSedimentree: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
1600
1663
|
readonly subduction_removeSedimentree: (a: number, b: number) => any;
|
|
1601
1664
|
readonly subduction_connect: (a: number, b: any, c: number) => any;
|
|
@@ -1618,6 +1681,9 @@ export interface InitOutput {
|
|
|
1618
1681
|
readonly subduction_syncWithAllPeers: (a: number, b: number, c: number, d: number, e: bigint) => any;
|
|
1619
1682
|
readonly subduction_fullSyncWithPeer: (a: number, b: number, c: number, d: number, e: bigint) => any;
|
|
1620
1683
|
readonly subduction_fullSyncWithAllPeers: (a: number, b: number, c: bigint) => any;
|
|
1684
|
+
readonly subduction_publishEphemeral: (a: number, b: number, c: number, d: number) => any;
|
|
1685
|
+
readonly subduction_subscribeEphemeral: (a: number, b: number, c: number) => any;
|
|
1686
|
+
readonly subduction_unsubscribeEphemeral: (a: number, b: number, c: number) => any;
|
|
1621
1687
|
readonly subduction_sedimentreeIds: (a: number) => any;
|
|
1622
1688
|
readonly subduction_getCommits: (a: number, b: number) => any;
|
|
1623
1689
|
readonly subduction_getFragments: (a: number, b: number) => any;
|
|
@@ -1641,17 +1707,24 @@ export interface InitOutput {
|
|
|
1641
1707
|
readonly syncstats_totalReceived: (a: number) => number;
|
|
1642
1708
|
readonly syncstats_totalSent: (a: number) => number;
|
|
1643
1709
|
readonly syncstats_isEmpty: (a: number) => number;
|
|
1710
|
+
readonly syncstats_remoteHeads: (a: number) => [number, number];
|
|
1711
|
+
readonly __wbg_authenticatedtransport_free: (a: number, b: number) => void;
|
|
1712
|
+
readonly authenticatedtransport_setup: (a: any, b: any, c: number, d: number) => any;
|
|
1713
|
+
readonly authenticatedtransport_setupDiscover: (a: any, b: any, c: number, d: number, e: number) => any;
|
|
1714
|
+
readonly authenticatedtransport_accept: (a: any, b: any, c: number, d: number) => any;
|
|
1715
|
+
readonly authenticatedtransport_peerId: (a: number) => number;
|
|
1644
1716
|
readonly __wbg_subductionhttplongpoll_free: (a: number, b: number) => void;
|
|
1645
1717
|
readonly subductionhttplongpoll_sendBytes: (a: number, b: number, c: number) => any;
|
|
1646
1718
|
readonly subductionhttplongpoll_recvBytes: (a: number) => any;
|
|
1647
1719
|
readonly subductionhttplongpoll_disconnect: (a: number) => any;
|
|
1720
|
+
readonly subductionhttplongpoll_onDisconnect: (a: number, b: any) => void;
|
|
1648
1721
|
readonly __wbg_authenticatedlongpoll_free: (a: number, b: number) => void;
|
|
1649
1722
|
readonly authenticatedlongpoll_peerId: (a: number) => number;
|
|
1650
1723
|
readonly authenticatedlongpoll_sessionId: (a: number) => [number, number];
|
|
1651
1724
|
readonly authenticatedlongpoll_toTransport: (a: number) => number;
|
|
1652
1725
|
readonly __wbg_subductionlongpoll_free: (a: number, b: number) => void;
|
|
1653
|
-
readonly subductionlongpoll_tryConnect: (a: number, b: number, c: any, d: number) => any;
|
|
1654
|
-
readonly subductionlongpoll_tryDiscover: (a: number, b: number, c: any, d: number, e: number) => any;
|
|
1726
|
+
readonly subductionlongpoll_tryConnect: (a: number, b: number, c: any, d: number, e: number) => any;
|
|
1727
|
+
readonly subductionlongpoll_tryDiscover: (a: number, b: number, c: any, d: number, e: number, f: number) => any;
|
|
1655
1728
|
readonly __wbg_syncmessage_free: (a: number, b: number) => void;
|
|
1656
1729
|
readonly syncmessage_toBytes: (a: number) => [number, number];
|
|
1657
1730
|
readonly syncmessage_fromBytes: (a: number, b: number) => [number, number, number];
|
|
@@ -1673,18 +1746,20 @@ export interface InitOutput {
|
|
|
1673
1746
|
readonly messageporttransport_sendBytes: (a: number, b: number, c: number) => any;
|
|
1674
1747
|
readonly messageporttransport_recvBytes: (a: number) => any;
|
|
1675
1748
|
readonly messageporttransport_disconnect: (a: number) => any;
|
|
1749
|
+
readonly messageporttransport_onDisconnect: (a: number, b: any) => void;
|
|
1676
1750
|
readonly makeMessagePortTransport: (a: any) => number;
|
|
1677
1751
|
readonly __wbg_nonce_free: (a: number, b: number) => void;
|
|
1678
1752
|
readonly nonce_new: (a: number, b: number) => [number, number, number];
|
|
1679
1753
|
readonly nonce_random: () => number;
|
|
1680
1754
|
readonly nonce_bytes: (a: number) => [number, number];
|
|
1681
1755
|
readonly __wbg_subductionwebsocket_free: (a: number, b: number) => void;
|
|
1682
|
-
readonly subductionwebsocket_setup: (a: any, b: any, c: number) => any;
|
|
1683
|
-
readonly subductionwebsocket_tryConnect: (a: any, b: any, c: number) => any;
|
|
1684
|
-
readonly subductionwebsocket_tryDiscover: (a: any, b: any, c: number, d: number) => any;
|
|
1756
|
+
readonly subductionwebsocket_setup: (a: any, b: any, c: number, d: number) => any;
|
|
1757
|
+
readonly subductionwebsocket_tryConnect: (a: any, b: any, c: number, d: number) => any;
|
|
1758
|
+
readonly subductionwebsocket_tryDiscover: (a: any, b: any, c: number, d: number, e: number) => any;
|
|
1685
1759
|
readonly subductionwebsocket_sendBytes: (a: number, b: number, c: number) => any;
|
|
1686
1760
|
readonly subductionwebsocket_recvBytes: (a: number) => any;
|
|
1687
1761
|
readonly subductionwebsocket_disconnect: (a: number) => any;
|
|
1762
|
+
readonly subductionwebsocket_onDisconnect: (a: number, b: any) => void;
|
|
1688
1763
|
readonly __wbg_authenticatedwebsocket_free: (a: number, b: number) => void;
|
|
1689
1764
|
readonly authenticatedwebsocket_peerId: (a: number) => number;
|
|
1690
1765
|
readonly authenticatedwebsocket_toTransport: (a: number) => number;
|
|
@@ -1701,11 +1776,6 @@ export interface InitOutput {
|
|
|
1701
1776
|
readonly batchsyncresponse_id: (a: number) => number;
|
|
1702
1777
|
readonly batchsyncresponse_request_id: (a: number) => number;
|
|
1703
1778
|
readonly batchsyncresponse___wasm_refgen_toWasmBatchSyncResponse: (a: number) => number;
|
|
1704
|
-
readonly __wbg_authenticatedtransport_free: (a: number, b: number) => void;
|
|
1705
|
-
readonly authenticatedtransport_setup: (a: any, b: any, c: number) => any;
|
|
1706
|
-
readonly authenticatedtransport_setupDiscover: (a: any, b: any, c: number, d: number) => any;
|
|
1707
|
-
readonly authenticatedtransport_accept: (a: any, b: any, c: number) => any;
|
|
1708
|
-
readonly authenticatedtransport_peerId: (a: number) => number;
|
|
1709
1779
|
readonly memorysigner_new: () => number;
|
|
1710
1780
|
readonly messageporttransport_new: (a: any) => number;
|
|
1711
1781
|
readonly __wbg_webcryptosigner_free: (a: number, b: number) => void;
|
|
@@ -1788,14 +1858,15 @@ export interface InitOutput {
|
|
|
1788
1858
|
readonly sedimentreeid___wasm_refgen_toWasmSedimentreeId: (a: number) => number;
|
|
1789
1859
|
readonly sedimentreeid_toBytes: (a: number) => [number, number];
|
|
1790
1860
|
readonly fragmentwithblob_blob: (a: number) => any;
|
|
1791
|
-
readonly
|
|
1792
|
-
readonly
|
|
1793
|
-
readonly
|
|
1794
|
-
readonly
|
|
1795
|
-
readonly
|
|
1796
|
-
readonly
|
|
1797
|
-
readonly
|
|
1798
|
-
readonly
|
|
1861
|
+
readonly __wasm_bindgen_func_elem_274: (a: number, b: number) => void;
|
|
1862
|
+
readonly __wasm_bindgen_func_elem_1605: (a: number, b: number, c: any) => [number, number];
|
|
1863
|
+
readonly __wasm_bindgen_func_elem_1605_191: (a: number, b: number, c: any, d: any) => void;
|
|
1864
|
+
readonly __wasm_bindgen_func_elem_1605_192: (a: number, b: number, c: any, d: any) => void;
|
|
1865
|
+
readonly __wasm_bindgen_func_elem_590: (a: number, b: number, c: any) => void;
|
|
1866
|
+
readonly __wasm_bindgen_func_elem_590_1: (a: number, b: number, c: any) => void;
|
|
1867
|
+
readonly __wasm_bindgen_func_elem_590_2: (a: number, b: number, c: any) => void;
|
|
1868
|
+
readonly __wasm_bindgen_func_elem_590_3: (a: number, b: number, c: any) => void;
|
|
1869
|
+
readonly __wasm_bindgen_func_elem_589: (a: number, b: number) => void;
|
|
1799
1870
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
1800
1871
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
1801
1872
|
readonly __wbindgen_export3: (a: number) => void;
|