@bytecodealliance/preview2-shim 0.0.14 → 0.0.16
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/lib/browser/http.js +1 -1
- package/lib/browser/io.js +14 -3
- package/lib/http/error.js +1 -1
- package/lib/http/make-request.js +2 -2
- package/lib/http/wasi-http.js +62 -39
- package/lib/nodejs/io.js +16 -5
- package/package.json +1 -1
- package/types/{exports → interfaces}/wasi-cli-environment.d.ts +1 -1
- package/types/{imports → interfaces}/wasi-cli-stderr.d.ts +1 -1
- package/types/{exports → interfaces}/wasi-cli-stdin.d.ts +1 -1
- package/types/{imports → interfaces}/wasi-cli-stdout.d.ts +1 -1
- package/types/{imports → interfaces}/wasi-cli-terminal-stderr.d.ts +2 -2
- package/types/{imports → interfaces}/wasi-cli-terminal-stdin.d.ts +2 -2
- package/types/{imports → interfaces}/wasi-cli-terminal-stdout.d.ts +2 -2
- package/types/{imports → interfaces}/wasi-clocks-monotonic-clock.d.ts +1 -1
- package/types/{exports → interfaces}/wasi-clocks-timezone.d.ts +1 -1
- package/types/{exports → interfaces}/wasi-filesystem-preopens.d.ts +1 -1
- package/types/{imports → interfaces}/wasi-filesystem-types.d.ts +5 -5
- package/types/interfaces/wasi-io-streams.d.ts +274 -0
- package/types/{imports → interfaces}/wasi-sockets-instance-network.d.ts +1 -1
- package/types/{exports → interfaces}/wasi-sockets-ip-name-lookup.d.ts +7 -7
- package/types/{imports → interfaces}/wasi-sockets-tcp-create-socket.d.ts +4 -4
- package/types/{imports → interfaces}/wasi-sockets-tcp.d.ts +20 -7
- package/types/{exports → interfaces}/wasi-sockets-udp-create-socket.d.ts +4 -4
- package/types/{exports → interfaces}/wasi-sockets-udp.d.ts +5 -5
- package/types/wasi-cli-command.d.ts +28 -28
- package/types/exports/wasi-cli-stderr.d.ts +0 -5
- package/types/exports/wasi-cli-stdout.d.ts +0 -5
- package/types/exports/wasi-cli-terminal-stderr.d.ts +0 -9
- package/types/exports/wasi-cli-terminal-stdin.d.ts +0 -9
- package/types/exports/wasi-cli-terminal-stdout.d.ts +0 -9
- package/types/exports/wasi-clocks-monotonic-clock.d.ts +0 -24
- package/types/exports/wasi-filesystem-types.d.ts +0 -843
- package/types/exports/wasi-http-incoming-handler.d.ts +0 -7
- package/types/exports/wasi-http-outgoing-handler.d.ts +0 -9
- package/types/exports/wasi-http-types.d.ts +0 -118
- package/types/exports/wasi-io-streams.d.ts +0 -220
- package/types/exports/wasi-sockets-instance-network.d.ts +0 -8
- package/types/exports/wasi-sockets-tcp-create-socket.d.ts +0 -33
- package/types/exports/wasi-sockets-tcp.d.ts +0 -285
- package/types/imports/wasi-cli-environment.d.ts +0 -22
- package/types/imports/wasi-cli-exit.d.ts +0 -7
- package/types/imports/wasi-cli-stdin.d.ts +0 -5
- package/types/imports/wasi-cli-terminal-input.d.ts +0 -13
- package/types/imports/wasi-cli-terminal-output.d.ts +0 -13
- package/types/imports/wasi-clocks-timezone.d.ts +0 -71
- package/types/imports/wasi-clocks-wall-clock.d.ts +0 -31
- package/types/imports/wasi-filesystem-preopens.d.ts +0 -8
- package/types/imports/wasi-http-outgoing-handler.d.ts +0 -9
- package/types/imports/wasi-http-types.d.ts +0 -118
- package/types/imports/wasi-io-streams.d.ts +0 -220
- package/types/imports/wasi-poll-poll.d.ts +0 -39
- package/types/imports/wasi-random-insecure-seed.d.ts +0 -22
- package/types/imports/wasi-random-insecure.d.ts +0 -20
- package/types/imports/wasi-random-random.d.ts +0 -22
- package/types/imports/wasi-sockets-ip-name-lookup.d.ts +0 -76
- package/types/imports/wasi-sockets-network.d.ts +0 -180
- package/types/imports/wasi-sockets-udp-create-socket.d.ts +0 -33
- package/types/imports/wasi-sockets-udp.d.ts +0 -228
- package/types/wasi-http-proxy.d.ts +0 -13
- /package/types/{exports → interfaces}/wasi-cli-exit.d.ts +0 -0
- /package/types/{exports → interfaces}/wasi-cli-run.d.ts +0 -0
- /package/types/{exports → interfaces}/wasi-cli-terminal-input.d.ts +0 -0
- /package/types/{exports → interfaces}/wasi-cli-terminal-output.d.ts +0 -0
- /package/types/{exports → interfaces}/wasi-clocks-wall-clock.d.ts +0 -0
- /package/types/{exports → interfaces}/wasi-poll-poll.d.ts +0 -0
- /package/types/{exports → interfaces}/wasi-random-insecure-seed.d.ts +0 -0
- /package/types/{exports → interfaces}/wasi-random-insecure.d.ts +0 -0
- /package/types/{exports → interfaces}/wasi-random-random.d.ts +0 -0
- /package/types/{exports → interfaces}/wasi-sockets-network.d.ts +0 -0
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
export namespace WasiSocketsTcp {
|
|
2
|
-
/**
|
|
3
|
-
* Bind the socket to a specific network on the provided IP address and port.
|
|
4
|
-
*
|
|
5
|
-
* If the IP address is zero (`0.0.0.0` in IPv4, `::` in IPv6), it is left to the implementation to decide which
|
|
6
|
-
* network interface(s) to bind to.
|
|
7
|
-
* If the TCP/UDP port is zero, the socket will be bound to a random free port.
|
|
8
|
-
*
|
|
9
|
-
* When a socket is not explicitly bound, the first invocation to a listen or connect operation will
|
|
10
|
-
* implicitly bind the socket.
|
|
11
|
-
*
|
|
12
|
-
* Unlike in POSIX, this function is async. This enables interactive WASI hosts to inject permission prompts.
|
|
13
|
-
*
|
|
14
|
-
* # Typical `start` errors
|
|
15
|
-
* - `address-family-mismatch`: The `local-address` has the wrong address family. (EINVAL)
|
|
16
|
-
* - `already-bound`: The socket is already bound. (EINVAL)
|
|
17
|
-
* - `concurrency-conflict`: Another `bind`, `connect` or `listen` operation is already in progress. (EALREADY)
|
|
18
|
-
*
|
|
19
|
-
* # Typical `finish` errors
|
|
20
|
-
* - `ephemeral-ports-exhausted`: No ephemeral ports available. (EADDRINUSE, ENOBUFS on Windows)
|
|
21
|
-
* - `address-in-use`: Address is already in use. (EADDRINUSE)
|
|
22
|
-
* - `address-not-bindable`: `local-address` is not an address that the `network` can bind to. (EADDRNOTAVAIL)
|
|
23
|
-
* - `not-in-progress`: A `bind` operation is not in progress.
|
|
24
|
-
* - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN)
|
|
25
|
-
*
|
|
26
|
-
* # References
|
|
27
|
-
* - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html>
|
|
28
|
-
* - <https://man7.org/linux/man-pages/man2/bind.2.html>
|
|
29
|
-
* - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-bind>
|
|
30
|
-
* - <https://man.freebsd.org/cgi/man.cgi?query=bind&sektion=2&format=html>
|
|
31
|
-
*/
|
|
32
|
-
export function startBind(this_: TcpSocket, network: Network, localAddress: IpSocketAddress): void;
|
|
33
|
-
export function finishBind(this_: TcpSocket): void;
|
|
34
|
-
/**
|
|
35
|
-
* Connect to a remote endpoint.
|
|
36
|
-
*
|
|
37
|
-
* On success:
|
|
38
|
-
* - the socket is transitioned into the Connection state
|
|
39
|
-
* - a pair of streams is returned that can be used to read & write to the connection
|
|
40
|
-
*
|
|
41
|
-
* # Typical `start` errors
|
|
42
|
-
* - `address-family-mismatch`: The `remote-address` has the wrong address family. (EAFNOSUPPORT)
|
|
43
|
-
* - `invalid-remote-address`: The IP address in `remote-address` is set to INADDR_ANY (`0.0.0.0` / `::`). (EADDRNOTAVAIL on Windows)
|
|
44
|
-
* - `invalid-remote-address`: The port in `remote-address` is set to 0. (EADDRNOTAVAIL on Windows)
|
|
45
|
-
* - `already-attached`: The socket is already attached to a different network. The `network` passed to `connect` must be identical to the one passed to `bind`.
|
|
46
|
-
* - `already-connected`: The socket is already in the Connection state. (EISCONN)
|
|
47
|
-
* - `already-listening`: The socket is already in the Listener state. (EOPNOTSUPP, EINVAL on Windows)
|
|
48
|
-
* - `concurrency-conflict`: Another `bind`, `connect` or `listen` operation is already in progress. (EALREADY)
|
|
49
|
-
*
|
|
50
|
-
* # Typical `finish` errors
|
|
51
|
-
* - `timeout`: Connection timed out. (ETIMEDOUT)
|
|
52
|
-
* - `connection-refused`: The connection was forcefully rejected. (ECONNREFUSED)
|
|
53
|
-
* - `connection-reset`: The connection was reset. (ECONNRESET)
|
|
54
|
-
* - `remote-unreachable`: The remote address is not reachable. (EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN)
|
|
55
|
-
* - `ephemeral-ports-exhausted`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE, EADDRNOTAVAIL on Linux, EAGAIN on BSD)
|
|
56
|
-
* - `not-in-progress`: A `connect` operation is not in progress.
|
|
57
|
-
* - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN)
|
|
58
|
-
*
|
|
59
|
-
* # References
|
|
60
|
-
* - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/connect.html>
|
|
61
|
-
* - <https://man7.org/linux/man-pages/man2/connect.2.html>
|
|
62
|
-
* - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-connect>
|
|
63
|
-
* - <https://man.freebsd.org/cgi/man.cgi?connect>
|
|
64
|
-
*/
|
|
65
|
-
export function startConnect(this_: TcpSocket, network: Network, remoteAddress: IpSocketAddress): void;
|
|
66
|
-
export function finishConnect(this_: TcpSocket): [InputStream, OutputStream];
|
|
67
|
-
/**
|
|
68
|
-
* Start listening for new connections.
|
|
69
|
-
*
|
|
70
|
-
* Transitions the socket into the Listener state.
|
|
71
|
-
*
|
|
72
|
-
* Unlike POSIX:
|
|
73
|
-
* - this function is async. This enables interactive WASI hosts to inject permission prompts.
|
|
74
|
-
* - the socket must already be explicitly bound.
|
|
75
|
-
*
|
|
76
|
-
* # Typical `start` errors
|
|
77
|
-
* - `not-bound`: The socket is not bound to any local address. (EDESTADDRREQ)
|
|
78
|
-
* - `already-connected`: The socket is already in the Connection state. (EISCONN, EINVAL on BSD)
|
|
79
|
-
* - `already-listening`: The socket is already in the Listener state.
|
|
80
|
-
* - `concurrency-conflict`: Another `bind`, `connect` or `listen` operation is already in progress. (EINVAL on BSD)
|
|
81
|
-
*
|
|
82
|
-
* # Typical `finish` errors
|
|
83
|
-
* - `ephemeral-ports-exhausted`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE)
|
|
84
|
-
* - `not-in-progress`: A `listen` operation is not in progress.
|
|
85
|
-
* - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN)
|
|
86
|
-
*
|
|
87
|
-
* # References
|
|
88
|
-
* - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/listen.html>
|
|
89
|
-
* - <https://man7.org/linux/man-pages/man2/listen.2.html>
|
|
90
|
-
* - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-listen>
|
|
91
|
-
* - <https://man.freebsd.org/cgi/man.cgi?query=listen&sektion=2>
|
|
92
|
-
*/
|
|
93
|
-
export function startListen(this_: TcpSocket): void;
|
|
94
|
-
export function finishListen(this_: TcpSocket): void;
|
|
95
|
-
/**
|
|
96
|
-
* Accept a new client socket.
|
|
97
|
-
*
|
|
98
|
-
* The returned socket is bound and in the Connection state.
|
|
99
|
-
*
|
|
100
|
-
* On success, this function returns the newly accepted client socket along with
|
|
101
|
-
* a pair of streams that can be used to read & write to the connection.
|
|
102
|
-
*
|
|
103
|
-
* # Typical errors
|
|
104
|
-
* - `not-listening`: Socket is not in the Listener state. (EINVAL)
|
|
105
|
-
* - `would-block`: No pending connections at the moment. (EWOULDBLOCK, EAGAIN)
|
|
106
|
-
*
|
|
107
|
-
* Host implementations must skip over transient errors returned by the native accept syscall.
|
|
108
|
-
*
|
|
109
|
-
* # References
|
|
110
|
-
* - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/accept.html>
|
|
111
|
-
* - <https://man7.org/linux/man-pages/man2/accept.2.html>
|
|
112
|
-
* - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-accept>
|
|
113
|
-
* - <https://man.freebsd.org/cgi/man.cgi?query=accept&sektion=2>
|
|
114
|
-
*/
|
|
115
|
-
export function accept(this_: TcpSocket): [TcpSocket, InputStream, OutputStream];
|
|
116
|
-
/**
|
|
117
|
-
* Get the bound local address.
|
|
118
|
-
*
|
|
119
|
-
* # Typical errors
|
|
120
|
-
* - `not-bound`: The socket is not bound to any local address.
|
|
121
|
-
*
|
|
122
|
-
* # References
|
|
123
|
-
* - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockname.html>
|
|
124
|
-
* - <https://man7.org/linux/man-pages/man2/getsockname.2.html>
|
|
125
|
-
* - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-getsockname>
|
|
126
|
-
* - <https://man.freebsd.org/cgi/man.cgi?getsockname>
|
|
127
|
-
*/
|
|
128
|
-
export function localAddress(this_: TcpSocket): IpSocketAddress;
|
|
129
|
-
/**
|
|
130
|
-
* Get the bound remote address.
|
|
131
|
-
*
|
|
132
|
-
* # Typical errors
|
|
133
|
-
* - `not-connected`: The socket is not connected to a remote address. (ENOTCONN)
|
|
134
|
-
*
|
|
135
|
-
* # References
|
|
136
|
-
* - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getpeername.html>
|
|
137
|
-
* - <https://man7.org/linux/man-pages/man2/getpeername.2.html>
|
|
138
|
-
* - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-getpeername>
|
|
139
|
-
* - <https://man.freebsd.org/cgi/man.cgi?query=getpeername&sektion=2&n=1>
|
|
140
|
-
*/
|
|
141
|
-
export function remoteAddress(this_: TcpSocket): IpSocketAddress;
|
|
142
|
-
/**
|
|
143
|
-
* Whether this is a IPv4 or IPv6 socket.
|
|
144
|
-
*
|
|
145
|
-
* Equivalent to the SO_DOMAIN socket option.
|
|
146
|
-
*/
|
|
147
|
-
export function addressFamily(this_: TcpSocket): IpAddressFamily;
|
|
148
|
-
/**
|
|
149
|
-
* Whether IPv4 compatibility (dual-stack) mode is disabled or not.
|
|
150
|
-
*
|
|
151
|
-
* Equivalent to the IPV6_V6ONLY socket option.
|
|
152
|
-
*
|
|
153
|
-
* # Typical errors
|
|
154
|
-
* - `ipv6-only-operation`: (get/set) `this` socket is an IPv4 socket.
|
|
155
|
-
* - `already-bound`: (set) The socket is already bound.
|
|
156
|
-
* - `not-supported`: (set) Host does not support dual-stack sockets. (Implementations are not required to.)
|
|
157
|
-
* - `concurrency-conflict`: (set) A `bind`, `connect` or `listen` operation is already in progress. (EALREADY)
|
|
158
|
-
*/
|
|
159
|
-
export function ipv6Only(this_: TcpSocket): boolean;
|
|
160
|
-
export function setIpv6Only(this_: TcpSocket, value: boolean): void;
|
|
161
|
-
/**
|
|
162
|
-
* Hints the desired listen queue size. Implementations are free to ignore this.
|
|
163
|
-
*
|
|
164
|
-
* # Typical errors
|
|
165
|
-
* - `already-connected`: (set) The socket is already in the Connection state.
|
|
166
|
-
* - `concurrency-conflict`: (set) A `bind`, `connect` or `listen` operation is already in progress. (EALREADY)
|
|
167
|
-
*/
|
|
168
|
-
export function setListenBacklogSize(this_: TcpSocket, value: bigint): void;
|
|
169
|
-
/**
|
|
170
|
-
* Equivalent to the SO_KEEPALIVE socket option.
|
|
171
|
-
*
|
|
172
|
-
* # Typical errors
|
|
173
|
-
* - `concurrency-conflict`: (set) A `bind`, `connect` or `listen` operation is already in progress. (EALREADY)
|
|
174
|
-
*/
|
|
175
|
-
export function keepAlive(this_: TcpSocket): boolean;
|
|
176
|
-
export function setKeepAlive(this_: TcpSocket, value: boolean): void;
|
|
177
|
-
/**
|
|
178
|
-
* Equivalent to the TCP_NODELAY socket option.
|
|
179
|
-
*
|
|
180
|
-
* # Typical errors
|
|
181
|
-
* - `concurrency-conflict`: (set) A `bind`, `connect` or `listen` operation is already in progress. (EALREADY)
|
|
182
|
-
*/
|
|
183
|
-
export function noDelay(this_: TcpSocket): boolean;
|
|
184
|
-
export function setNoDelay(this_: TcpSocket, value: boolean): void;
|
|
185
|
-
/**
|
|
186
|
-
* Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options.
|
|
187
|
-
*
|
|
188
|
-
* # Typical errors
|
|
189
|
-
* - `already-connected`: (set) The socket is already in the Connection state.
|
|
190
|
-
* - `already-listening`: (set) The socket is already in the Listener state.
|
|
191
|
-
* - `concurrency-conflict`: (set) A `bind`, `connect` or `listen` operation is already in progress. (EALREADY)
|
|
192
|
-
*/
|
|
193
|
-
export function unicastHopLimit(this_: TcpSocket): number;
|
|
194
|
-
export function setUnicastHopLimit(this_: TcpSocket, value: number): void;
|
|
195
|
-
/**
|
|
196
|
-
* The kernel buffer space reserved for sends/receives on this socket.
|
|
197
|
-
*
|
|
198
|
-
* Note #1: an implementation may choose to cap or round the buffer size when setting the value.
|
|
199
|
-
* In other words, after setting a value, reading the same setting back may return a different value.
|
|
200
|
-
*
|
|
201
|
-
* Note #2: there is not necessarily a direct relationship between the kernel buffer size and the bytes of
|
|
202
|
-
* actual data to be sent/received by the application, because the kernel might also use the buffer space
|
|
203
|
-
* for internal metadata structures.
|
|
204
|
-
*
|
|
205
|
-
* Equivalent to the SO_RCVBUF and SO_SNDBUF socket options.
|
|
206
|
-
*
|
|
207
|
-
* # Typical errors
|
|
208
|
-
* - `already-connected`: (set) The socket is already in the Connection state.
|
|
209
|
-
* - `already-listening`: (set) The socket is already in the Listener state.
|
|
210
|
-
* - `concurrency-conflict`: (set) A `bind`, `connect` or `listen` operation is already in progress. (EALREADY)
|
|
211
|
-
*/
|
|
212
|
-
export function receiveBufferSize(this_: TcpSocket): bigint;
|
|
213
|
-
export function setReceiveBufferSize(this_: TcpSocket, value: bigint): void;
|
|
214
|
-
export function sendBufferSize(this_: TcpSocket): bigint;
|
|
215
|
-
export function setSendBufferSize(this_: TcpSocket, value: bigint): void;
|
|
216
|
-
/**
|
|
217
|
-
* Create a `pollable` which will resolve once the socket is ready for I/O.
|
|
218
|
-
*
|
|
219
|
-
* Note: this function is here for WASI Preview2 only.
|
|
220
|
-
* It's planned to be removed when `future` is natively supported in Preview3.
|
|
221
|
-
*/
|
|
222
|
-
export function subscribe(this_: TcpSocket): Pollable;
|
|
223
|
-
/**
|
|
224
|
-
* Initiate a graceful shutdown.
|
|
225
|
-
*
|
|
226
|
-
* - receive: the socket is not expecting to receive any more data from the peer. All subsequent read
|
|
227
|
-
* operations on the `input-stream` associated with this socket will return an End Of Stream indication.
|
|
228
|
-
* Any data still in the receive queue at time of calling `shutdown` will be discarded.
|
|
229
|
-
* - send: the socket is not expecting to send any more data to the peer. All subsequent write
|
|
230
|
-
* operations on the `output-stream` associated with this socket will return an error.
|
|
231
|
-
* - both: same effect as receive & send combined.
|
|
232
|
-
*
|
|
233
|
-
* The shutdown function does not close (drop) the socket.
|
|
234
|
-
*
|
|
235
|
-
* # Typical errors
|
|
236
|
-
* - `not-connected`: The socket is not in the Connection state. (ENOTCONN)
|
|
237
|
-
*
|
|
238
|
-
* # References
|
|
239
|
-
* - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/shutdown.html>
|
|
240
|
-
* - <https://man7.org/linux/man-pages/man2/shutdown.2.html>
|
|
241
|
-
* - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-shutdown>
|
|
242
|
-
* - <https://man.freebsd.org/cgi/man.cgi?query=shutdown&sektion=2>
|
|
243
|
-
*/
|
|
244
|
-
export function shutdown(this_: TcpSocket, shutdownType: ShutdownType): void;
|
|
245
|
-
/**
|
|
246
|
-
* Dispose of the specified `tcp-socket`, after which it may no longer be used.
|
|
247
|
-
*
|
|
248
|
-
* Similar to the POSIX `close` function.
|
|
249
|
-
*
|
|
250
|
-
* Note: this function is scheduled to be removed when Resources are natively supported in Wit.
|
|
251
|
-
*/
|
|
252
|
-
export function dropTcpSocket(this_: TcpSocket): void;
|
|
253
|
-
}
|
|
254
|
-
import type { InputStream } from '../exports/wasi-io-streams';
|
|
255
|
-
export { InputStream };
|
|
256
|
-
import type { OutputStream } from '../exports/wasi-io-streams';
|
|
257
|
-
export { OutputStream };
|
|
258
|
-
import type { Pollable } from '../exports/wasi-poll-poll';
|
|
259
|
-
export { Pollable };
|
|
260
|
-
import type { Network } from '../exports/wasi-sockets-network';
|
|
261
|
-
export { Network };
|
|
262
|
-
import type { ErrorCode } from '../exports/wasi-sockets-network';
|
|
263
|
-
export { ErrorCode };
|
|
264
|
-
import type { IpSocketAddress } from '../exports/wasi-sockets-network';
|
|
265
|
-
export { IpSocketAddress };
|
|
266
|
-
import type { IpAddressFamily } from '../exports/wasi-sockets-network';
|
|
267
|
-
export { IpAddressFamily };
|
|
268
|
-
/**
|
|
269
|
-
* A TCP socket handle.
|
|
270
|
-
*/
|
|
271
|
-
export type TcpSocket = number;
|
|
272
|
-
/**
|
|
273
|
-
* # Variants
|
|
274
|
-
*
|
|
275
|
-
* ## `"receive"`
|
|
276
|
-
*
|
|
277
|
-
* Similar to `SHUT_RD` in POSIX.
|
|
278
|
-
* ## `"send"`
|
|
279
|
-
*
|
|
280
|
-
* Similar to `SHUT_WR` in POSIX.
|
|
281
|
-
* ## `"both"`
|
|
282
|
-
*
|
|
283
|
-
* Similar to `SHUT_RDWR` in POSIX.
|
|
284
|
-
*/
|
|
285
|
-
export type ShutdownType = 'receive' | 'send' | 'both';
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export namespace WasiCliEnvironment {
|
|
2
|
-
/**
|
|
3
|
-
* Get the POSIX-style environment variables.
|
|
4
|
-
*
|
|
5
|
-
* Each environment variable is provided as a pair of string variable names
|
|
6
|
-
* and string value.
|
|
7
|
-
*
|
|
8
|
-
* Morally, these are a value import, but until value imports are available
|
|
9
|
-
* in the component model, this import function should return the same
|
|
10
|
-
* values each time it is called.
|
|
11
|
-
*/
|
|
12
|
-
export function getEnvironment(): [string, string][];
|
|
13
|
-
/**
|
|
14
|
-
* Get the POSIX-style arguments to the program.
|
|
15
|
-
*/
|
|
16
|
-
export function getArguments(): string[];
|
|
17
|
-
/**
|
|
18
|
-
* Return a path that programs should use as their initial current working
|
|
19
|
-
* directory, interpreting `.` as shorthand for this.
|
|
20
|
-
*/
|
|
21
|
-
export function initialCwd(): string | null;
|
|
22
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export namespace WasiCliTerminalInput {
|
|
2
|
-
/**
|
|
3
|
-
* Dispose of the specified terminal-input after which it may no longer
|
|
4
|
-
* be used.
|
|
5
|
-
*/
|
|
6
|
-
export function dropTerminalInput(this_: TerminalInput): void;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* The input side of a terminal.
|
|
10
|
-
*
|
|
11
|
-
* This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources).
|
|
12
|
-
*/
|
|
13
|
-
export type TerminalInput = number;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export namespace WasiCliTerminalOutput {
|
|
2
|
-
/**
|
|
3
|
-
* Dispose of the specified terminal-output, after which it may no longer
|
|
4
|
-
* be used.
|
|
5
|
-
*/
|
|
6
|
-
export function dropTerminalOutput(this_: TerminalOutput): void;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* The output side of a terminal.
|
|
10
|
-
*
|
|
11
|
-
* This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources).
|
|
12
|
-
*/
|
|
13
|
-
export type TerminalOutput = number;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
export namespace WasiClocksTimezone {
|
|
2
|
-
/**
|
|
3
|
-
* Return information needed to display the given `datetime`. This includes
|
|
4
|
-
* the UTC offset, the time zone name, and a flag indicating whether
|
|
5
|
-
* daylight saving time is active.
|
|
6
|
-
*
|
|
7
|
-
* If the timezone cannot be determined for the given `datetime`, return a
|
|
8
|
-
* `timezone-display` for `UTC` with a `utc-offset` of 0 and no daylight
|
|
9
|
-
* saving time.
|
|
10
|
-
*/
|
|
11
|
-
export function display(this_: Timezone, when: Datetime): TimezoneDisplay;
|
|
12
|
-
/**
|
|
13
|
-
* The same as `display`, but only return the UTC offset.
|
|
14
|
-
*/
|
|
15
|
-
export function utcOffset(this_: Timezone, when: Datetime): number;
|
|
16
|
-
/**
|
|
17
|
-
* Dispose of the specified input-stream, after which it may no longer
|
|
18
|
-
* be used.
|
|
19
|
-
*/
|
|
20
|
-
export function dropTimezone(this_: Timezone): void;
|
|
21
|
-
}
|
|
22
|
-
import type { Datetime } from '../imports/wasi-clocks-wall-clock';
|
|
23
|
-
export { Datetime };
|
|
24
|
-
/**
|
|
25
|
-
* A timezone.
|
|
26
|
-
*
|
|
27
|
-
* In timezones that recognize daylight saving time, also known as daylight
|
|
28
|
-
* time and summer time, the information returned from the functions varies
|
|
29
|
-
* over time to reflect these adjustments.
|
|
30
|
-
*
|
|
31
|
-
* This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources).
|
|
32
|
-
*/
|
|
33
|
-
export type Timezone = number;
|
|
34
|
-
/**
|
|
35
|
-
* Information useful for displaying the timezone of a specific `datetime`.
|
|
36
|
-
*
|
|
37
|
-
* This information may vary within a single `timezone` to reflect daylight
|
|
38
|
-
* saving time adjustments.
|
|
39
|
-
*/
|
|
40
|
-
export interface TimezoneDisplay {
|
|
41
|
-
/**
|
|
42
|
-
* The number of seconds difference between UTC time and the local
|
|
43
|
-
* time of the timezone.
|
|
44
|
-
*
|
|
45
|
-
* The returned value will always be less than 86400 which is the
|
|
46
|
-
* number of seconds in a day (24*60*60).
|
|
47
|
-
*
|
|
48
|
-
* In implementations that do not expose an actual time zone, this
|
|
49
|
-
* should return 0.
|
|
50
|
-
*/
|
|
51
|
-
utcOffset: number,
|
|
52
|
-
/**
|
|
53
|
-
* The abbreviated name of the timezone to display to a user. The name
|
|
54
|
-
* `UTC` indicates Coordinated Universal Time. Otherwise, this should
|
|
55
|
-
* reference local standards for the name of the time zone.
|
|
56
|
-
*
|
|
57
|
-
* In implementations that do not expose an actual time zone, this
|
|
58
|
-
* should be the string `UTC`.
|
|
59
|
-
*
|
|
60
|
-
* In time zones that do not have an applicable name, a formatted
|
|
61
|
-
* representation of the UTC offset may be returned, such as `-04:00`.
|
|
62
|
-
*/
|
|
63
|
-
name: string,
|
|
64
|
-
/**
|
|
65
|
-
* Whether daylight saving time is active.
|
|
66
|
-
*
|
|
67
|
-
* In implementations that do not expose an actual time zone, this
|
|
68
|
-
* should return false.
|
|
69
|
-
*/
|
|
70
|
-
inDaylightSavingTime: boolean,
|
|
71
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export namespace WasiClocksWallClock {
|
|
2
|
-
/**
|
|
3
|
-
* Read the current value of the clock.
|
|
4
|
-
*
|
|
5
|
-
* This clock is not monotonic, therefore calling this function repeatedly
|
|
6
|
-
* will not necessarily produce a sequence of non-decreasing values.
|
|
7
|
-
*
|
|
8
|
-
* The returned timestamps represent the number of seconds since
|
|
9
|
-
* 1970-01-01T00:00:00Z, also known as [POSIX's Seconds Since the Epoch],
|
|
10
|
-
* also known as [Unix Time].
|
|
11
|
-
*
|
|
12
|
-
* The nanoseconds field of the output is always less than 1000000000.
|
|
13
|
-
*
|
|
14
|
-
* [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16
|
|
15
|
-
* [Unix Time]: https://en.wikipedia.org/wiki/Unix_time
|
|
16
|
-
*/
|
|
17
|
-
export function now(): Datetime;
|
|
18
|
-
/**
|
|
19
|
-
* Query the resolution of the clock.
|
|
20
|
-
*
|
|
21
|
-
* The nanoseconds field of the output is always less than 1000000000.
|
|
22
|
-
*/
|
|
23
|
-
export function resolution(): Datetime;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* A time and date in seconds plus nanoseconds.
|
|
27
|
-
*/
|
|
28
|
-
export interface Datetime {
|
|
29
|
-
seconds: bigint,
|
|
30
|
-
nanoseconds: number,
|
|
31
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export namespace WasiFilesystemPreopens {
|
|
2
|
-
/**
|
|
3
|
-
* Return the set of preopened directories, and their path.
|
|
4
|
-
*/
|
|
5
|
-
export function getDirectories(): [Descriptor, string][];
|
|
6
|
-
}
|
|
7
|
-
import type { Descriptor } from '../imports/wasi-filesystem-types';
|
|
8
|
-
export { Descriptor };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export namespace WasiHttpOutgoingHandler {
|
|
2
|
-
export function handle(request: OutgoingRequest, options: RequestOptions | null): FutureIncomingResponse;
|
|
3
|
-
}
|
|
4
|
-
import type { OutgoingRequest } from '../imports/wasi-http-types';
|
|
5
|
-
export { OutgoingRequest };
|
|
6
|
-
import type { RequestOptions } from '../imports/wasi-http-types';
|
|
7
|
-
export { RequestOptions };
|
|
8
|
-
import type { FutureIncomingResponse } from '../imports/wasi-http-types';
|
|
9
|
-
export { FutureIncomingResponse };
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
export namespace WasiHttpTypes {
|
|
2
|
-
export function dropFields(fields: Fields): void;
|
|
3
|
-
export function newFields(entries: [string, string][]): Fields;
|
|
4
|
-
export function fieldsGet(fields: Fields, name: string): Uint8Array | ArrayBuffer[];
|
|
5
|
-
export function fieldsSet(fields: Fields, name: string, value: Uint8Array[]): void;
|
|
6
|
-
export function fieldsDelete(fields: Fields, name: string): void;
|
|
7
|
-
export function fieldsAppend(fields: Fields, name: string, value: Uint8Array): void;
|
|
8
|
-
export function fieldsEntries(fields: Fields): [string, Uint8Array | ArrayBuffer][];
|
|
9
|
-
export function fieldsClone(fields: Fields): Fields;
|
|
10
|
-
export function finishIncomingStream(s: IncomingStream): Trailers | null;
|
|
11
|
-
export function finishOutgoingStream(s: OutgoingStream, trailers: Trailers | null): void;
|
|
12
|
-
export function dropIncomingRequest(request: IncomingRequest): void;
|
|
13
|
-
export function dropOutgoingRequest(request: OutgoingRequest): void;
|
|
14
|
-
export function incomingRequestMethod(request: IncomingRequest): Method;
|
|
15
|
-
export function incomingRequestPathWithQuery(request: IncomingRequest): string | null;
|
|
16
|
-
export function incomingRequestScheme(request: IncomingRequest): Scheme | null;
|
|
17
|
-
export function incomingRequestAuthority(request: IncomingRequest): string | null;
|
|
18
|
-
export function incomingRequestHeaders(request: IncomingRequest): Headers;
|
|
19
|
-
export function incomingRequestConsume(request: IncomingRequest): IncomingStream;
|
|
20
|
-
export function newOutgoingRequest(method: Method, pathWithQuery: string | null, scheme: Scheme | null, authority: string | null, headers: Headers): OutgoingRequest;
|
|
21
|
-
export function outgoingRequestWrite(request: OutgoingRequest): OutgoingStream;
|
|
22
|
-
export function dropResponseOutparam(response: ResponseOutparam): void;
|
|
23
|
-
export function setResponseOutparam(param: ResponseOutparam, response: Result<OutgoingResponse, Error>): void;
|
|
24
|
-
export function dropIncomingResponse(response: IncomingResponse): void;
|
|
25
|
-
export function dropOutgoingResponse(response: OutgoingResponse): void;
|
|
26
|
-
export function incomingResponseStatus(response: IncomingResponse): StatusCode;
|
|
27
|
-
export function incomingResponseHeaders(response: IncomingResponse): Headers;
|
|
28
|
-
export function incomingResponseConsume(response: IncomingResponse): IncomingStream;
|
|
29
|
-
export function newOutgoingResponse(statusCode: StatusCode, headers: Headers): OutgoingResponse;
|
|
30
|
-
export function outgoingResponseWrite(response: OutgoingResponse): OutgoingStream;
|
|
31
|
-
export function dropFutureIncomingResponse(f: FutureIncomingResponse): void;
|
|
32
|
-
export function futureIncomingResponseGet(f: FutureIncomingResponse): Result<IncomingResponse, Error> | null;
|
|
33
|
-
export function listenToFutureIncomingResponse(f: FutureIncomingResponse): Pollable;
|
|
34
|
-
}
|
|
35
|
-
import type { InputStream } from '../imports/wasi-io-streams';
|
|
36
|
-
export { InputStream };
|
|
37
|
-
import type { OutputStream } from '../imports/wasi-io-streams';
|
|
38
|
-
export { OutputStream };
|
|
39
|
-
import type { Pollable } from '../imports/wasi-poll-poll';
|
|
40
|
-
export { Pollable };
|
|
41
|
-
export type Method = MethodGet | MethodHead | MethodPost | MethodPut | MethodDelete | MethodConnect | MethodOptions | MethodTrace | MethodPatch | MethodOther;
|
|
42
|
-
export interface MethodGet {
|
|
43
|
-
tag: 'get',
|
|
44
|
-
}
|
|
45
|
-
export interface MethodHead {
|
|
46
|
-
tag: 'head',
|
|
47
|
-
}
|
|
48
|
-
export interface MethodPost {
|
|
49
|
-
tag: 'post',
|
|
50
|
-
}
|
|
51
|
-
export interface MethodPut {
|
|
52
|
-
tag: 'put',
|
|
53
|
-
}
|
|
54
|
-
export interface MethodDelete {
|
|
55
|
-
tag: 'delete',
|
|
56
|
-
}
|
|
57
|
-
export interface MethodConnect {
|
|
58
|
-
tag: 'connect',
|
|
59
|
-
}
|
|
60
|
-
export interface MethodOptions {
|
|
61
|
-
tag: 'options',
|
|
62
|
-
}
|
|
63
|
-
export interface MethodTrace {
|
|
64
|
-
tag: 'trace',
|
|
65
|
-
}
|
|
66
|
-
export interface MethodPatch {
|
|
67
|
-
tag: 'patch',
|
|
68
|
-
}
|
|
69
|
-
export interface MethodOther {
|
|
70
|
-
tag: 'other',
|
|
71
|
-
val: string,
|
|
72
|
-
}
|
|
73
|
-
export type Scheme = SchemeHttp | SchemeHttps | SchemeOther;
|
|
74
|
-
export interface SchemeHttp {
|
|
75
|
-
tag: 'HTTP',
|
|
76
|
-
}
|
|
77
|
-
export interface SchemeHttps {
|
|
78
|
-
tag: 'HTTPS',
|
|
79
|
-
}
|
|
80
|
-
export interface SchemeOther {
|
|
81
|
-
tag: 'other',
|
|
82
|
-
val: string,
|
|
83
|
-
}
|
|
84
|
-
export type Error = ErrorInvalidUrl | ErrorTimeoutError | ErrorProtocolError | ErrorUnexpectedError;
|
|
85
|
-
export interface ErrorInvalidUrl {
|
|
86
|
-
tag: 'invalid-url',
|
|
87
|
-
val: string,
|
|
88
|
-
}
|
|
89
|
-
export interface ErrorTimeoutError {
|
|
90
|
-
tag: 'timeout-error',
|
|
91
|
-
val: string,
|
|
92
|
-
}
|
|
93
|
-
export interface ErrorProtocolError {
|
|
94
|
-
tag: 'protocol-error',
|
|
95
|
-
val: string,
|
|
96
|
-
}
|
|
97
|
-
export interface ErrorUnexpectedError {
|
|
98
|
-
tag: 'unexpected-error',
|
|
99
|
-
val: string,
|
|
100
|
-
}
|
|
101
|
-
export type Fields = number;
|
|
102
|
-
export type Headers = Fields;
|
|
103
|
-
export type Trailers = Fields;
|
|
104
|
-
export type IncomingStream = InputStream;
|
|
105
|
-
export type OutgoingStream = OutputStream;
|
|
106
|
-
export type IncomingRequest = number;
|
|
107
|
-
export type OutgoingRequest = number;
|
|
108
|
-
export interface RequestOptions {
|
|
109
|
-
connectTimeoutMs?: number,
|
|
110
|
-
firstByteTimeoutMs?: number,
|
|
111
|
-
betweenBytesTimeoutMs?: number,
|
|
112
|
-
}
|
|
113
|
-
export type ResponseOutparam = number;
|
|
114
|
-
export type StatusCode = number;
|
|
115
|
-
export type IncomingResponse = number;
|
|
116
|
-
export type OutgoingResponse = number;
|
|
117
|
-
export type FutureIncomingResponse = number;
|
|
118
|
-
export type Result<T, E> = { tag: 'ok', val: T } | { tag: 'err', val: E };
|