smoldot 0.7.13 → 1.0.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/cjs/client.d.ts +61 -28
- package/dist/cjs/index-browser.js +66 -19
- package/dist/cjs/index-deno.js +85 -58
- package/dist/cjs/index-nodejs.js +91 -40
- package/dist/cjs/instance/autogen/wasm0.js +1 -1
- package/dist/cjs/instance/autogen/wasm1.js +1 -1
- package/dist/cjs/instance/autogen/wasm2.js +1 -1
- package/dist/cjs/instance/bindings-smoldot-light.d.ts +36 -2
- package/dist/cjs/instance/bindings-smoldot-light.js +18 -4
- package/dist/cjs/instance/bindings.d.ts +3 -2
- package/dist/mjs/client.d.ts +61 -28
- package/dist/mjs/index-browser.js +66 -19
- package/dist/mjs/index-deno.js +85 -58
- package/dist/mjs/index-nodejs.js +91 -40
- package/dist/mjs/instance/autogen/wasm0.js +1 -1
- package/dist/mjs/instance/autogen/wasm1.js +1 -1
- package/dist/mjs/instance/autogen/wasm2.js +1 -1
- package/dist/mjs/instance/bindings-smoldot-light.d.ts +36 -2
- package/dist/mjs/instance/bindings-smoldot-light.js +18 -4
- package/dist/mjs/instance/bindings.d.ts +3 -2
- package/package.json +2 -2
|
@@ -63,12 +63,33 @@ export interface Connection {
|
|
|
63
63
|
/**
|
|
64
64
|
* Queues data to be sent on the given connection.
|
|
65
65
|
*
|
|
66
|
-
* The connection must currently be in the `Open` state.
|
|
66
|
+
* The connection and stream must currently be in the `Open` state.
|
|
67
|
+
*
|
|
68
|
+
* The number of bytes most never exceed the number of "writable bytes" of the stream.
|
|
69
|
+
* `onWritableBytes` can be used in order to notify that more writable bytes are available.
|
|
67
70
|
*
|
|
68
71
|
* The `streamId` must be provided if and only if the connection is of type "multi-stream".
|
|
69
72
|
* It indicates which substream to send the data on.
|
|
73
|
+
*
|
|
74
|
+
* Must not be called after `closeSend` has been called.
|
|
70
75
|
*/
|
|
71
76
|
send(data: Uint8Array, streamId?: number): void;
|
|
77
|
+
/**
|
|
78
|
+
* Closes the writing side of the given stream of the given connection.
|
|
79
|
+
*
|
|
80
|
+
* Never called for connection types where this isn't possible to implement (i.e. WebSocket
|
|
81
|
+
* and WebRTC at the moment).
|
|
82
|
+
*
|
|
83
|
+
* The connection and stream must currently be in the `Open` state.
|
|
84
|
+
*
|
|
85
|
+
* Implicitly sets the "writable bytes" of the stream to zero.
|
|
86
|
+
*
|
|
87
|
+
* The `streamId` must be provided if and only if the connection is of type "multi-stream".
|
|
88
|
+
* It indicates which substream to send the data on.
|
|
89
|
+
*
|
|
90
|
+
* Must only be called once per stream.
|
|
91
|
+
*/
|
|
92
|
+
closeSend(streamId?: number): void;
|
|
72
93
|
/**
|
|
73
94
|
* Start opening an additional outbound substream on the given connection.
|
|
74
95
|
*
|
|
@@ -104,6 +125,8 @@ export interface ConnectionConfig {
|
|
|
104
125
|
onOpen: (info: {
|
|
105
126
|
type: 'single-stream';
|
|
106
127
|
handshake: 'multistream-select-noise-yamux';
|
|
128
|
+
initialWritableBytes: number;
|
|
129
|
+
writeClosable: boolean;
|
|
107
130
|
} | {
|
|
108
131
|
type: 'multi-stream';
|
|
109
132
|
handshake: 'webrtc';
|
|
@@ -121,7 +144,7 @@ export interface ConnectionConfig {
|
|
|
121
144
|
*
|
|
122
145
|
* This function must only be called for connections of type "multi-stream".
|
|
123
146
|
*/
|
|
124
|
-
onStreamOpened: (streamId: number, direction: 'inbound' | 'outbound') => void;
|
|
147
|
+
onStreamOpened: (streamId: number, direction: 'inbound' | 'outbound', initialWritableBytes: number) => void;
|
|
125
148
|
/**
|
|
126
149
|
* Callback called when a stream transitions to the `Reset` state.
|
|
127
150
|
*
|
|
@@ -130,6 +153,17 @@ export interface ConnectionConfig {
|
|
|
130
153
|
* This function must only be called for connections of type "multi-stream".
|
|
131
154
|
*/
|
|
132
155
|
onStreamReset: (streamId: number) => void;
|
|
156
|
+
/**
|
|
157
|
+
* Callback called when more data can be written on the stream.
|
|
158
|
+
*
|
|
159
|
+
* Can only happen while the connection is in the `Open` state.
|
|
160
|
+
*
|
|
161
|
+
* This callback must not be called after `closeSend` has been called.
|
|
162
|
+
*
|
|
163
|
+
* The `streamId` parameter must be provided if and only if the connection is of type
|
|
164
|
+
* "multi-stream".
|
|
165
|
+
*/
|
|
166
|
+
onWritableBytes: (numExtra: number, streamId?: number) => void;
|
|
133
167
|
/**
|
|
134
168
|
* Callback called when a message sent by the remote has been received.
|
|
135
169
|
*
|
|
@@ -93,7 +93,7 @@ export default function (config) {
|
|
|
93
93
|
// In browsers, `setTimeout` works as expected when `ms` equals 0. However, NodeJS
|
|
94
94
|
// requires a minimum of 1 millisecond (if `0` is passed, it is automatically replaced
|
|
95
95
|
// with `1`) and wants you to use `setImmediate` instead.
|
|
96
|
-
if (ms
|
|
96
|
+
if (ms < 1 && typeof setImmediate === "function") {
|
|
97
97
|
setImmediate(() => {
|
|
98
98
|
if (killedTracked.killed)
|
|
99
99
|
return;
|
|
@@ -136,7 +136,7 @@ export default function (config) {
|
|
|
136
136
|
try {
|
|
137
137
|
switch (info.type) {
|
|
138
138
|
case 'single-stream': {
|
|
139
|
-
instance.exports.connection_open_single_stream(connectionId, 0);
|
|
139
|
+
instance.exports.connection_open_single_stream(connectionId, 0, info.initialWritableBytes, info.writeClosable ? 1 : 0);
|
|
140
140
|
break;
|
|
141
141
|
}
|
|
142
142
|
case 'multi-stream': {
|
|
@@ -164,6 +164,14 @@ export default function (config) {
|
|
|
164
164
|
}
|
|
165
165
|
catch (_error) { }
|
|
166
166
|
},
|
|
167
|
+
onWritableBytes: (numExtra, streamId) => {
|
|
168
|
+
if (killedTracked.killed)
|
|
169
|
+
return;
|
|
170
|
+
try {
|
|
171
|
+
instance.exports.stream_writable_bytes(connectionId, streamId || 0, numExtra);
|
|
172
|
+
}
|
|
173
|
+
catch (_error) { }
|
|
174
|
+
},
|
|
167
175
|
onMessage: (message, streamId) => {
|
|
168
176
|
if (killedTracked.killed)
|
|
169
177
|
return;
|
|
@@ -174,11 +182,11 @@ export default function (config) {
|
|
|
174
182
|
}
|
|
175
183
|
catch (_error) { }
|
|
176
184
|
},
|
|
177
|
-
onStreamOpened: (streamId, direction) => {
|
|
185
|
+
onStreamOpened: (streamId, direction, initialWritableBytes) => {
|
|
178
186
|
if (killedTracked.killed)
|
|
179
187
|
return;
|
|
180
188
|
try {
|
|
181
|
-
instance.exports.connection_stream_opened(connectionId, streamId, direction === 'outbound' ? 1 : 0);
|
|
189
|
+
instance.exports.connection_stream_opened(connectionId, streamId, direction === 'outbound' ? 1 : 0, initialWritableBytes);
|
|
182
190
|
}
|
|
183
191
|
catch (_error) { }
|
|
184
192
|
},
|
|
@@ -240,6 +248,12 @@ export default function (config) {
|
|
|
240
248
|
const connection = connections[connectionId];
|
|
241
249
|
connection.send(data, streamId); // TODO: docs says the streamId is provided only for multi-stream connections, but here it's always provided
|
|
242
250
|
},
|
|
251
|
+
stream_send_close: (connectionId, streamId) => {
|
|
252
|
+
if (killedTracked.killed)
|
|
253
|
+
return;
|
|
254
|
+
const connection = connections[connectionId];
|
|
255
|
+
connection.closeSend(streamId); // TODO: docs says the streamId is provided only for multi-stream connections, but here it's always provided
|
|
256
|
+
},
|
|
243
257
|
current_task_entered: (ptr, len) => {
|
|
244
258
|
if (killedTracked.killed)
|
|
245
259
|
return;
|
|
@@ -19,10 +19,11 @@ export interface SmoldotWasmExports extends WebAssembly.Exports {
|
|
|
19
19
|
json_rpc_responses_peek: (chainId: number) => number;
|
|
20
20
|
json_rpc_responses_pop: (chainId: number) => void;
|
|
21
21
|
timer_finished: (timerId: number) => void;
|
|
22
|
-
connection_open_single_stream: (connectionId: number, handshakeTy: number) => void;
|
|
22
|
+
connection_open_single_stream: (connectionId: number, handshakeTy: number, initialWritableBytes: number, writeClosable: number) => void;
|
|
23
23
|
connection_open_multi_stream: (connectionId: number, handshakeTyPtr: number, handshakeTyLen: number) => void;
|
|
24
|
+
stream_writable_bytes: (connectionId: number, streamId: number, numBytes: number) => void;
|
|
24
25
|
stream_message: (connectionId: number, streamId: number, ptr: number, len: number) => void;
|
|
25
|
-
connection_stream_opened: (connectionId: number, streamId: number, outbound: number) => void;
|
|
26
|
+
connection_stream_opened: (connectionId: number, streamId: number, outbound: number, initialWritableBytes: number) => void;
|
|
26
27
|
connection_reset: (connectionId: number, ptr: number, len: number) => void;
|
|
27
28
|
stream_reset: (connectionId: number, streamId: number) => void;
|
|
28
29
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smoldot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Light client that connects to Polkadot and Substrate-based blockchains",
|
|
5
5
|
"author": "Parity Technologies <admin@parity.io>",
|
|
6
6
|
"license": "GPL-3.0-or-later WITH Classpath-exception-2.0",
|
|
@@ -48,6 +48,6 @@
|
|
|
48
48
|
"dtslint": "^4.0.6",
|
|
49
49
|
"rimraf": "^4.1.2",
|
|
50
50
|
"typedoc": "^0.23.15",
|
|
51
|
-
"typescript": "^
|
|
51
|
+
"typescript": "^5.0.2"
|
|
52
52
|
}
|
|
53
53
|
}
|