smoldot 0.3.6 → 0.7.11

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 (74) hide show
  1. package/README.md +18 -21
  2. package/dist/cjs/base64.d.ts +22 -0
  3. package/dist/cjs/base64.js +104 -0
  4. package/dist/cjs/client.d.ts +287 -0
  5. package/dist/cjs/client.js +175 -0
  6. package/dist/cjs/index-browser.d.ts +11 -0
  7. package/dist/cjs/index-browser.js +465 -0
  8. package/dist/cjs/index-deno.d.ts +10 -0
  9. package/dist/cjs/index-deno.js +263 -0
  10. package/dist/cjs/index-nodejs.d.ts +10 -0
  11. package/dist/cjs/index-nodejs.js +174 -0
  12. package/dist/cjs/instance/autogen/wasm.d.ts +2 -0
  13. package/dist/cjs/instance/autogen/wasm.js +6 -0
  14. package/dist/cjs/instance/autogen/wasm0.d.ts +1 -0
  15. package/dist/cjs/instance/autogen/wasm0.js +4 -0
  16. package/dist/cjs/instance/autogen/wasm1.d.ts +1 -0
  17. package/dist/cjs/instance/autogen/wasm1.js +4 -0
  18. package/dist/cjs/instance/autogen/wasm2.d.ts +1 -0
  19. package/dist/cjs/instance/autogen/wasm2.js +4 -0
  20. package/dist/cjs/instance/bindings-smoldot-light.d.ts +154 -0
  21. package/dist/cjs/instance/bindings-smoldot-light.js +266 -0
  22. package/dist/cjs/instance/bindings-wasi.d.ts +23 -0
  23. package/dist/cjs/instance/bindings-wasi.js +142 -0
  24. package/dist/cjs/instance/bindings.d.ts +31 -0
  25. package/dist/cjs/instance/bindings.js +5 -0
  26. package/dist/cjs/instance/buffer.d.ts +10 -0
  27. package/dist/cjs/instance/buffer.js +53 -0
  28. package/dist/cjs/instance/instance.d.ts +45 -0
  29. package/dist/cjs/instance/instance.js +301 -0
  30. package/dist/cjs/instance/raw-instance.d.ts +65 -0
  31. package/dist/cjs/instance/raw-instance.js +72 -0
  32. package/dist/cjs/package.json +3 -0
  33. package/dist/mjs/base64.d.ts +22 -0
  34. package/dist/mjs/base64.js +97 -0
  35. package/dist/mjs/client.d.ts +287 -0
  36. package/dist/mjs/client.js +165 -0
  37. package/dist/mjs/index-browser.d.ts +11 -0
  38. package/dist/mjs/index-browser.js +455 -0
  39. package/dist/mjs/index-deno.d.ts +10 -0
  40. package/dist/mjs/index-deno.js +253 -0
  41. package/dist/mjs/index-nodejs.d.ts +10 -0
  42. package/dist/mjs/index-nodejs.js +164 -0
  43. package/dist/mjs/instance/autogen/wasm.d.ts +2 -0
  44. package/dist/mjs/instance/autogen/wasm.js +4 -0
  45. package/dist/mjs/instance/autogen/wasm0.d.ts +1 -0
  46. package/dist/mjs/instance/autogen/wasm0.js +1 -0
  47. package/dist/mjs/instance/autogen/wasm1.d.ts +1 -0
  48. package/dist/mjs/instance/autogen/wasm1.js +1 -0
  49. package/dist/mjs/instance/autogen/wasm2.d.ts +1 -0
  50. package/dist/mjs/instance/autogen/wasm2.js +1 -0
  51. package/dist/mjs/instance/bindings-smoldot-light.d.ts +154 -0
  52. package/dist/mjs/instance/bindings-smoldot-light.js +261 -0
  53. package/dist/mjs/instance/bindings-wasi.d.ts +23 -0
  54. package/{src → dist/mjs/instance}/bindings-wasi.js +47 -58
  55. package/dist/mjs/instance/bindings.d.ts +31 -0
  56. package/dist/mjs/instance/bindings.js +4 -0
  57. package/dist/mjs/instance/buffer.d.ts +10 -0
  58. package/dist/mjs/instance/buffer.js +46 -0
  59. package/dist/mjs/instance/instance.d.ts +45 -0
  60. package/dist/mjs/instance/instance.js +293 -0
  61. package/dist/mjs/instance/raw-instance.d.ts +65 -0
  62. package/dist/mjs/instance/raw-instance.js +67 -0
  63. package/dist/mjs/package.json +3 -0
  64. package/package.json +35 -19
  65. package/src/autogen/wasm.js +0 -1
  66. package/src/bindings-smoldot-js.js +0 -223
  67. package/src/compat-browser.js +0 -25
  68. package/src/compat-nodejs.js +0 -30
  69. package/src/health.js +0 -206
  70. package/src/index.d.ts +0 -68
  71. package/src/index.js +0 -192
  72. package/src/index.test-d.ts +0 -36
  73. package/src/tsconfig.json +0 -13
  74. package/src/worker.js +0 -151
@@ -0,0 +1,253 @@
1
+ // Smoldot
2
+ // Copyright (C) 2019-2022 Parity Technologies (UK) Ltd.
3
+ // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
4
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6
+ return new (P || (P = Promise))(function (resolve, reject) {
7
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
8
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
9
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
10
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
11
+ });
12
+ };
13
+ // This program is free software: you can redistribute it and/or modify
14
+ // it under the terms of the GNU General Public License as published by
15
+ // the Free Software Foundation, either version 3 of the License, or
16
+ // (at your option) any later version.
17
+ // This program is distributed in the hope that it will be useful,
18
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
+ // GNU General Public License for more details.
21
+ // You should have received a copy of the GNU General Public License
22
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
23
+ import { start as innerStart } from './client.js';
24
+ import { ConnectionError } from './instance/instance.js';
25
+ export { AddChainError, AlreadyDestroyedError, CrashError, MalformedJsonRpcError, QueueFullError, JsonRpcDisabledError } from './client.js';
26
+ /**
27
+ * Initializes a new client. This is a pre-requisite to connecting to a blockchain.
28
+ *
29
+ * Can never fail.
30
+ *
31
+ * @param options Configuration of the client. Defaults to `{}`.
32
+ */
33
+ export function start(options) {
34
+ options = options || {};
35
+ return innerStart(options || {}, {
36
+ trustedBase64DecodeAndZlibInflate: (input) => __awaiter(this, void 0, void 0, function* () {
37
+ const buffer = trustedBase64Decode(input);
38
+ // This code has been copy-pasted from the official streams draft specification.
39
+ // At the moment, it is found here: https://wicg.github.io/compression/#example-deflate-compress
40
+ const ds = new DecompressionStream('deflate');
41
+ const writer = ds.writable.getWriter();
42
+ writer.write(buffer);
43
+ writer.close();
44
+ const output = [];
45
+ const reader = ds.readable.getReader();
46
+ let totalSize = 0;
47
+ while (true) {
48
+ const { value, done } = yield reader.read();
49
+ if (done)
50
+ break;
51
+ output.push(value);
52
+ totalSize += value.byteLength;
53
+ }
54
+ const concatenated = new Uint8Array(totalSize);
55
+ let offset = 0;
56
+ for (const array of output) {
57
+ concatenated.set(array, offset);
58
+ offset += array.byteLength;
59
+ }
60
+ return concatenated;
61
+ }),
62
+ registerShouldPeriodicallyYield: (_callback) => {
63
+ return [true, () => { }];
64
+ },
65
+ performanceNow: () => {
66
+ return performance.now();
67
+ },
68
+ getRandomValues: (buffer) => {
69
+ const crypto = globalThis.crypto;
70
+ if (!crypto)
71
+ throw new Error('randomness not available');
72
+ crypto.getRandomValues(buffer);
73
+ },
74
+ connect: (config) => {
75
+ return connect(config, (options === null || options === void 0 ? void 0 : options.forbidTcp) || false, (options === null || options === void 0 ? void 0 : options.forbidWs) || false, (options === null || options === void 0 ? void 0 : options.forbidNonLocalWs) || false, (options === null || options === void 0 ? void 0 : options.forbidWss) || false);
76
+ }
77
+ });
78
+ }
79
+ /**
80
+ * Decodes a base64 string.
81
+ *
82
+ * The input is assumed to be correct.
83
+ */
84
+ function trustedBase64Decode(base64) {
85
+ // This code is a bit sketchy due to the fact that we decode into a string, but it seems to
86
+ // work.
87
+ const binaryString = atob(base64);
88
+ const size = binaryString.length;
89
+ const bytes = new Uint8Array(size);
90
+ for (let i = 0; i < size; i++) {
91
+ bytes[i] = binaryString.charCodeAt(i);
92
+ }
93
+ return bytes;
94
+ }
95
+ /**
96
+ * Tries to open a new connection using the given configuration.
97
+ *
98
+ * @see Connection
99
+ * @throws {@link ConnectionError} If the multiaddress couldn't be parsed or contains an invalid protocol.
100
+ */
101
+ function connect(config, forbidTcp, forbidWs, forbidNonLocalWs, forbidWss) {
102
+ let connection;
103
+ // Attempt to parse the multiaddress.
104
+ // TODO: remove support for `/wss` in a long time (https://github.com/paritytech/smoldot/issues/1940)
105
+ const wsParsed = config.address.match(/^\/(ip4|ip6|dns4|dns6|dns)\/(.*?)\/tcp\/(.*?)\/(ws|wss|tls\/ws)$/);
106
+ const tcpParsed = config.address.match(/^\/(ip4|ip6|dns4|dns6|dns)\/(.*?)\/tcp\/(.*?)$/);
107
+ if (wsParsed != null) {
108
+ const proto = (wsParsed[4] == 'ws') ? 'ws' : 'wss';
109
+ if ((proto == 'ws' && forbidWs) ||
110
+ (proto == 'ws' && wsParsed[2] != 'localhost' && wsParsed[2] != '127.0.0.1' && forbidNonLocalWs) ||
111
+ (proto == 'wss' && forbidWss)) {
112
+ throw new ConnectionError('Connection type not allowed');
113
+ }
114
+ const url = (wsParsed[1] == 'ip6') ?
115
+ (proto + "://[" + wsParsed[2] + "]:" + wsParsed[3]) :
116
+ (proto + "://" + wsParsed[2] + ":" + wsParsed[3]);
117
+ connection = {
118
+ ty: 'websocket',
119
+ socket: new WebSocket(url)
120
+ };
121
+ connection.socket.binaryType = 'arraybuffer';
122
+ connection.socket.onopen = () => {
123
+ config.onOpen({ type: 'single-stream', handshake: 'multistream-select-noise-yamux' });
124
+ };
125
+ connection.socket.onclose = (event) => {
126
+ const message = "Error code " + event.code + (!!event.reason ? (": " + event.reason) : "");
127
+ config.onConnectionReset(message);
128
+ };
129
+ connection.socket.onmessage = (msg) => {
130
+ config.onMessage(new Uint8Array(msg.data));
131
+ };
132
+ }
133
+ else if (tcpParsed != null) {
134
+ // `net` module will be missing when we're not in NodeJS.
135
+ if (forbidTcp) {
136
+ throw new ConnectionError('TCP connections not available');
137
+ }
138
+ const socket = {
139
+ destroyed: false,
140
+ inner: Deno.connect({
141
+ hostname: tcpParsed[2],
142
+ port: parseInt(tcpParsed[3], 10),
143
+ })
144
+ };
145
+ connection = { ty: 'tcp', socket };
146
+ socket.inner = socket.inner.then((established) => {
147
+ // TODO: at the time of writing of this comment, `setNoDelay` is still unstable
148
+ //established.setNoDelay();
149
+ if (socket.destroyed)
150
+ return established;
151
+ config.onOpen({ type: 'single-stream', handshake: 'multistream-select-noise-yamux' });
152
+ // Spawns an asynchronous task that continuously reads from the socket.
153
+ // Every time data is read, the task re-executes itself in order to continue reading.
154
+ // The task ends automatically if an EOF or error is detected, which should also happen
155
+ // if the user calls `close()`.
156
+ const read = (readBuffer) => __awaiter(this, void 0, void 0, function* () {
157
+ if (socket.destroyed)
158
+ return;
159
+ let outcome = null;
160
+ try {
161
+ outcome = yield established.read(readBuffer);
162
+ }
163
+ catch (error) {
164
+ // The type of `error` is unclear, but we assume that it implements `Error`
165
+ outcome = error.toString();
166
+ }
167
+ if (socket.destroyed)
168
+ return;
169
+ if (typeof outcome !== 'number' || outcome === null) {
170
+ // The socket is reported closed, but `socket.destroyed` is still `false` (see
171
+ // check above). As such, we must inform the inner layers.
172
+ socket.destroyed = true;
173
+ config.onConnectionReset(outcome === null ? "EOF when reading socket" : outcome);
174
+ return;
175
+ }
176
+ console.assert(outcome !== 0); // `read` guarantees to return a non-zero value.
177
+ config.onMessage(readBuffer.slice(0, outcome));
178
+ return read(readBuffer);
179
+ });
180
+ read(new Uint8Array(1024));
181
+ return established;
182
+ });
183
+ }
184
+ else {
185
+ throw new ConnectionError('Unrecognized multiaddr format');
186
+ }
187
+ return {
188
+ reset: () => {
189
+ if (connection.ty == 'websocket') {
190
+ // WebSocket
191
+ // We can't set these fields to null because the TypeScript definitions don't
192
+ // allow it, but we can set them to dummy values.
193
+ connection.socket.onopen = () => { };
194
+ connection.socket.onclose = () => { };
195
+ connection.socket.onmessage = () => { };
196
+ connection.socket.onerror = () => { };
197
+ connection.socket.close();
198
+ }
199
+ else {
200
+ // TCP
201
+ connection.socket.destroyed = true;
202
+ connection.socket.inner.then((connec) => connec.close());
203
+ }
204
+ },
205
+ send: (data) => {
206
+ if (connection.ty == 'websocket') {
207
+ // WebSocket
208
+ // The WebSocket library that we use seems to spontaneously transition connections
209
+ // to the "closed" state but not call the `onclosed` callback immediately. Calling
210
+ // `send` on that object throws an exception. In order to avoid panicking smoldot,
211
+ // we thus absorb any exception thrown here.
212
+ // See also <https://github.com/paritytech/smoldot/issues/2937>.
213
+ try {
214
+ connection.socket.send(data);
215
+ }
216
+ catch (_error) { }
217
+ }
218
+ else {
219
+ // TCP
220
+ // TODO: at the moment, sending data doesn't have any back-pressure mechanism; as such, we just buffer data indefinitely
221
+ let dataCopy = Uint8Array.from(data); // Deep copy of the data
222
+ const socket = connection.socket;
223
+ connection.socket.inner = connection.socket.inner.then((c) => __awaiter(this, void 0, void 0, function* () {
224
+ while (dataCopy.length > 0) {
225
+ if (socket.destroyed)
226
+ return c;
227
+ let outcome;
228
+ try {
229
+ outcome = yield c.write(dataCopy);
230
+ }
231
+ catch (error) {
232
+ // The type of `error` is unclear, but we assume that it implements `Error`
233
+ outcome = error.toString();
234
+ }
235
+ if (typeof outcome !== 'number') {
236
+ // The socket is reported closed, but `socket.destroyed` is still
237
+ // `false` (see check above). As such, we must inform the inner layers.
238
+ socket.destroyed = true;
239
+ config.onConnectionReset(outcome);
240
+ return c;
241
+ }
242
+ // Note that, contrary to `read`, it is possible for `outcome` to be 0.
243
+ // This happen if the write had to be interrupted, and the only thing
244
+ // we have to do is try writing again.
245
+ dataCopy = dataCopy.slice(outcome);
246
+ }
247
+ return c;
248
+ }));
249
+ }
250
+ },
251
+ openOutSubstream: () => { throw new Error('Wrong connection type'); }
252
+ };
253
+ }
@@ -0,0 +1,10 @@
1
+ import { Client, ClientOptions } from './client.js';
2
+ export { AddChainError, AddChainOptions, AlreadyDestroyedError, Chain, Client, ClientOptions, CrashError, MalformedJsonRpcError, QueueFullError, JsonRpcDisabledError, LogCallback } from './client.js';
3
+ /**
4
+ * Initializes a new client. This is a pre-requisite to connecting to a blockchain.
5
+ *
6
+ * Can never fail.
7
+ *
8
+ * @param options Configuration of the client. Defaults to `{}`.
9
+ */
10
+ export declare function start(options?: ClientOptions): Client;
@@ -0,0 +1,164 @@
1
+ // Smoldot
2
+ // Copyright (C) 2019-2022 Parity Technologies (UK) Ltd.
3
+ // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
4
+ // This program is free software: you can redistribute it and/or modify
5
+ // it under the terms of the GNU General Public License as published by
6
+ // the Free Software Foundation, either version 3 of the License, or
7
+ // (at your option) any later version.
8
+ // This program is distributed in the hope that it will be useful,
9
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ // GNU General Public License for more details.
12
+ // You should have received a copy of the GNU General Public License
13
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
14
+ // Note: if you modify these imports, please test both the ModuleJS and CommonJS generated
15
+ // bindings. JavaScript being JavaScript, some libraries (such as `websocket`) have issues working
16
+ // with both at the same time.
17
+ import { start as innerStart } from './client.js';
18
+ import { ConnectionError } from './instance/instance.js';
19
+ import { WebSocket } from 'ws';
20
+ import { inflate } from 'pako';
21
+ import { performance } from 'node:perf_hooks';
22
+ import { createConnection as nodeCreateConnection } from 'node:net';
23
+ import { randomFillSync } from 'node:crypto';
24
+ export { AddChainError, AlreadyDestroyedError, CrashError, MalformedJsonRpcError, QueueFullError, JsonRpcDisabledError } from './client.js';
25
+ /**
26
+ * Initializes a new client. This is a pre-requisite to connecting to a blockchain.
27
+ *
28
+ * Can never fail.
29
+ *
30
+ * @param options Configuration of the client. Defaults to `{}`.
31
+ */
32
+ export function start(options) {
33
+ options = options || {};
34
+ return innerStart(options || {}, {
35
+ trustedBase64DecodeAndZlibInflate: (input) => {
36
+ return Promise.resolve(inflate(Buffer.from(input, 'base64')));
37
+ },
38
+ registerShouldPeriodicallyYield: (_callback) => {
39
+ return [true, () => { }];
40
+ },
41
+ performanceNow: () => {
42
+ return performance.now();
43
+ },
44
+ getRandomValues: (buffer) => {
45
+ if (buffer.length >= 65536)
46
+ throw new Error('getRandomValues buffer too large');
47
+ randomFillSync(buffer);
48
+ },
49
+ connect: (config) => {
50
+ return connect(config, (options === null || options === void 0 ? void 0 : options.forbidTcp) || false, (options === null || options === void 0 ? void 0 : options.forbidWs) || false, (options === null || options === void 0 ? void 0 : options.forbidNonLocalWs) || false, (options === null || options === void 0 ? void 0 : options.forbidWss) || false);
51
+ }
52
+ });
53
+ }
54
+ /**
55
+ * Tries to open a new connection using the given configuration.
56
+ *
57
+ * @see Connection
58
+ * @throws {@link ConnectionError} If the multiaddress couldn't be parsed or contains an invalid protocol.
59
+ */
60
+ function connect(config, forbidTcp, forbidWs, forbidNonLocalWs, forbidWss) {
61
+ let connection;
62
+ // Attempt to parse the multiaddress.
63
+ // TODO: remove support for `/wss` in a long time (https://github.com/paritytech/smoldot/issues/1940)
64
+ const wsParsed = config.address.match(/^\/(ip4|ip6|dns4|dns6|dns)\/(.*?)\/tcp\/(.*?)\/(ws|wss|tls\/ws)$/);
65
+ const tcpParsed = config.address.match(/^\/(ip4|ip6|dns4|dns6|dns)\/(.*?)\/tcp\/(.*?)$/);
66
+ if (wsParsed != null) {
67
+ const proto = (wsParsed[4] == 'ws') ? 'ws' : 'wss';
68
+ if ((proto == 'ws' && forbidWs) ||
69
+ (proto == 'ws' && wsParsed[2] != 'localhost' && wsParsed[2] != '127.0.0.1' && forbidNonLocalWs) ||
70
+ (proto == 'wss' && forbidWss)) {
71
+ throw new ConnectionError('Connection type not allowed');
72
+ }
73
+ const url = (wsParsed[1] == 'ip6') ?
74
+ (proto + "://[" + wsParsed[2] + "]:" + wsParsed[3]) :
75
+ (proto + "://" + wsParsed[2] + ":" + wsParsed[3]);
76
+ const socket = new WebSocket(url);
77
+ socket.binaryType = 'arraybuffer';
78
+ socket.onopen = () => {
79
+ config.onOpen({ type: 'single-stream', handshake: 'multistream-select-noise-yamux' });
80
+ };
81
+ socket.onclose = (event) => {
82
+ const message = "Error code " + event.code + (!!event.reason ? (": " + event.reason) : "");
83
+ config.onConnectionReset(message);
84
+ socket.onopen = () => { };
85
+ socket.onclose = () => { };
86
+ socket.onmessage = () => { };
87
+ socket.onerror = () => { };
88
+ };
89
+ socket.onerror = (event) => {
90
+ config.onConnectionReset(event.message);
91
+ socket.onopen = () => { };
92
+ socket.onclose = () => { };
93
+ socket.onmessage = () => { };
94
+ socket.onerror = () => { };
95
+ };
96
+ socket.onmessage = (msg) => {
97
+ config.onMessage(new Uint8Array(msg.data));
98
+ };
99
+ connection = { ty: 'websocket', socket };
100
+ }
101
+ else if (tcpParsed != null) {
102
+ // `net` module will be missing when we're not in NodeJS.
103
+ if (forbidTcp) {
104
+ throw new ConnectionError('TCP connections not available');
105
+ }
106
+ const socket = nodeCreateConnection({
107
+ host: tcpParsed[2],
108
+ port: parseInt(tcpParsed[3], 10),
109
+ });
110
+ connection = { ty: 'tcp', socket };
111
+ connection.socket.setNoDelay();
112
+ connection.socket.on('connect', () => {
113
+ if (socket.destroyed)
114
+ return;
115
+ config.onOpen({ type: 'single-stream', handshake: 'multistream-select-noise-yamux' });
116
+ });
117
+ connection.socket.on('close', (hasError) => {
118
+ if (socket.destroyed)
119
+ return;
120
+ // NodeJS doesn't provide a reason why the closing happened, but only
121
+ // whether it was caused by an error.
122
+ const message = hasError ? "Error" : "Closed gracefully";
123
+ config.onConnectionReset(message);
124
+ });
125
+ connection.socket.on('error', () => { });
126
+ connection.socket.on('data', (message) => {
127
+ if (socket.destroyed)
128
+ return;
129
+ config.onMessage(new Uint8Array(message.buffer));
130
+ });
131
+ }
132
+ else {
133
+ throw new ConnectionError('Unrecognized multiaddr format');
134
+ }
135
+ return {
136
+ reset: () => {
137
+ if (connection.ty == 'websocket') {
138
+ // WebSocket
139
+ // We can't set these fields to null because the TypeScript definitions don't
140
+ // allow it, but we can set them to dummy values.
141
+ connection.socket.onopen = () => { };
142
+ connection.socket.onclose = () => { };
143
+ connection.socket.onmessage = () => { };
144
+ connection.socket.onerror = () => { };
145
+ connection.socket.close();
146
+ }
147
+ else {
148
+ // TCP
149
+ connection.socket.destroy();
150
+ }
151
+ },
152
+ send: (data) => {
153
+ if (connection.ty == 'websocket') {
154
+ // WebSocket
155
+ connection.socket.send(data);
156
+ }
157
+ else {
158
+ // TCP
159
+ connection.socket.write(data);
160
+ }
161
+ },
162
+ openOutSubstream: () => { throw new Error('Wrong connection type'); }
163
+ };
164
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: string;
2
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import { default as wasm0 } from './wasm0.js';
2
+ import { default as wasm1 } from './wasm1.js';
3
+ import { default as wasm2 } from './wasm2.js';
4
+ export default "" + wasm0() + wasm1() + wasm2();
@@ -0,0 +1 @@
1
+ export default function (): string;