@bytecodealliance/preview2-shim 0.0.12 → 0.0.14

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 (91) hide show
  1. package/README.md +2 -2
  2. package/lib/browser/cli.js +87 -0
  3. package/lib/browser/filesystem.js +216 -18
  4. package/lib/browser/http.js +4 -7
  5. package/lib/browser/index.js +2 -2
  6. package/lib/browser/io.js +76 -17
  7. package/lib/browser/logging.js +2 -2
  8. package/lib/browser/poll.js +48 -4
  9. package/lib/http/error.js +1 -1
  10. package/lib/http/make-request.js +3 -2
  11. package/lib/http/wasi-http.js +52 -40
  12. package/lib/nodejs/cli.js +75 -0
  13. package/lib/nodejs/filesystem.js +93 -3
  14. package/lib/nodejs/http.js +4 -7
  15. package/lib/nodejs/index.js +2 -2
  16. package/lib/nodejs/logging.js +2 -2
  17. package/package.json +1 -1
  18. package/types/{imports/environment.d.ts → exports/wasi-cli-environment.d.ts} +6 -1
  19. package/types/{imports/exit.d.ts → exports/wasi-cli-exit.d.ts} +2 -2
  20. package/types/exports/wasi-cli-run.d.ts +6 -0
  21. package/types/exports/wasi-cli-stderr.d.ts +5 -0
  22. package/types/exports/wasi-cli-stdin.d.ts +5 -0
  23. package/types/exports/wasi-cli-stdout.d.ts +5 -0
  24. package/types/exports/wasi-cli-terminal-input.d.ts +13 -0
  25. package/types/exports/wasi-cli-terminal-output.d.ts +13 -0
  26. package/types/exports/wasi-cli-terminal-stderr.d.ts +9 -0
  27. package/types/exports/wasi-cli-terminal-stdin.d.ts +9 -0
  28. package/types/exports/wasi-cli-terminal-stdout.d.ts +9 -0
  29. package/types/{imports/monotonic-clock.d.ts → exports/wasi-clocks-monotonic-clock.d.ts} +2 -2
  30. package/types/{imports/timezone.d.ts → exports/wasi-clocks-timezone.d.ts} +15 -15
  31. package/types/{imports/wall-clock.d.ts → exports/wasi-clocks-wall-clock.d.ts} +1 -1
  32. package/types/exports/wasi-filesystem-preopens.d.ts +8 -0
  33. package/types/{imports/filesystem.d.ts → exports/wasi-filesystem-types.d.ts} +293 -307
  34. package/types/exports/wasi-http-incoming-handler.d.ts +3 -3
  35. package/types/exports/wasi-http-outgoing-handler.d.ts +9 -0
  36. package/types/{imports/types.d.ts → exports/wasi-http-types.d.ts} +40 -41
  37. package/types/exports/wasi-io-streams.d.ts +220 -0
  38. package/types/{imports/poll.d.ts → exports/wasi-poll-poll.d.ts} +6 -8
  39. package/types/{imports/insecure-seed.d.ts → exports/wasi-random-insecure-seed.d.ts} +1 -1
  40. package/types/exports/wasi-random-insecure.d.ts +20 -0
  41. package/types/exports/wasi-random-random.d.ts +22 -0
  42. package/types/{imports/instance-network.d.ts → exports/wasi-sockets-instance-network.d.ts} +2 -2
  43. package/types/{imports/ip-name-lookup.d.ts → exports/wasi-sockets-ip-name-lookup.d.ts} +9 -9
  44. package/types/{imports/network.d.ts → exports/wasi-sockets-network.d.ts} +43 -75
  45. package/types/{imports/tcp-create-socket.d.ts → exports/wasi-sockets-tcp-create-socket.d.ts} +5 -5
  46. package/types/{imports/tcp.d.ts → exports/wasi-sockets-tcp.d.ts} +38 -38
  47. package/types/{imports/udp-create-socket.d.ts → exports/wasi-sockets-udp-create-socket.d.ts} +5 -5
  48. package/types/{imports/udp.d.ts → exports/wasi-sockets-udp.d.ts} +41 -32
  49. package/types/imports/wasi-cli-environment.d.ts +22 -0
  50. package/types/imports/wasi-cli-exit.d.ts +7 -0
  51. package/types/imports/wasi-cli-stderr.d.ts +5 -0
  52. package/types/imports/wasi-cli-stdin.d.ts +5 -0
  53. package/types/imports/wasi-cli-stdout.d.ts +5 -0
  54. package/types/imports/wasi-cli-terminal-input.d.ts +13 -0
  55. package/types/imports/wasi-cli-terminal-output.d.ts +13 -0
  56. package/types/imports/wasi-cli-terminal-stderr.d.ts +9 -0
  57. package/types/imports/wasi-cli-terminal-stdin.d.ts +9 -0
  58. package/types/imports/wasi-cli-terminal-stdout.d.ts +9 -0
  59. package/types/imports/wasi-clocks-monotonic-clock.d.ts +24 -0
  60. package/types/imports/wasi-clocks-timezone.d.ts +71 -0
  61. package/types/imports/wasi-clocks-wall-clock.d.ts +31 -0
  62. package/types/imports/wasi-filesystem-preopens.d.ts +8 -0
  63. package/types/imports/wasi-filesystem-types.d.ts +843 -0
  64. package/types/imports/wasi-http-outgoing-handler.d.ts +9 -0
  65. package/types/imports/wasi-http-types.d.ts +118 -0
  66. package/types/imports/wasi-io-streams.d.ts +220 -0
  67. package/types/imports/wasi-poll-poll.d.ts +39 -0
  68. package/types/imports/wasi-random-insecure-seed.d.ts +22 -0
  69. package/types/imports/{insecure.d.ts → wasi-random-insecure.d.ts} +1 -1
  70. package/types/imports/{random.d.ts → wasi-random-random.d.ts} +1 -1
  71. package/types/imports/wasi-sockets-instance-network.d.ts +8 -0
  72. package/types/imports/wasi-sockets-ip-name-lookup.d.ts +76 -0
  73. package/types/imports/wasi-sockets-network.d.ts +180 -0
  74. package/types/imports/wasi-sockets-tcp-create-socket.d.ts +33 -0
  75. package/types/imports/wasi-sockets-tcp.d.ts +285 -0
  76. package/types/imports/wasi-sockets-udp-create-socket.d.ts +33 -0
  77. package/types/imports/wasi-sockets-udp.d.ts +228 -0
  78. package/types/wasi-cli-command.d.ts +29 -0
  79. package/types/wasi-http-proxy.d.ts +13 -0
  80. package/lib/browser/cli-base.js +0 -48
  81. package/lib/nodejs/cli-base.js +0 -99
  82. package/types/imports/handler.d.ts +0 -40
  83. package/types/imports/outgoing-handler.d.ts +0 -9
  84. package/types/imports/preopens.d.ts +0 -12
  85. package/types/imports/stderr.d.ts +0 -5
  86. package/types/imports/stdin.d.ts +0 -5
  87. package/types/imports/stdout.d.ts +0 -5
  88. package/types/imports/streams.d.ts +0 -180
  89. package/types/wasi-command.d.ts +0 -23
  90. package/types/wasi-proxy.d.ts +0 -10
  91. package/types/wasi-reactor.d.ts +0 -23
@@ -1,10 +1,10 @@
1
- export namespace ImportsNetwork {
1
+ export namespace WasiSocketsNetwork {
2
2
  /**
3
3
  * Dispose of the specified `network`, after which it may no longer be used.
4
4
  *
5
5
  * Note: this function is scheduled to be removed when Resources are natively supported in Wit.
6
6
  */
7
- export function dropNetwork(this: Network): void;
7
+ export function dropNetwork(this_: Network): void;
8
8
  }
9
9
  /**
10
10
  * An opaque resource that represents access to (a subset of) the network.
@@ -14,48 +14,6 @@ export namespace ImportsNetwork {
14
14
  * FYI, In the future this will be replaced by handle types.
15
15
  */
16
16
  export type Network = number;
17
- export type Ipv6Address = [number, number, number, number, number, number, number, number];
18
- export interface Ipv6SocketAddress {
19
- port: number,
20
- flowInfo: number,
21
- address: Ipv6Address,
22
- scopeId: number,
23
- }
24
- export type Ipv4Address = [number, number, number, number];
25
- export interface Ipv4SocketAddress {
26
- port: number,
27
- address: Ipv4Address,
28
- }
29
- export type IpSocketAddress = IpSocketAddressIpv4 | IpSocketAddressIpv6;
30
- export interface IpSocketAddressIpv4 {
31
- tag: 'ipv4',
32
- val: Ipv4SocketAddress,
33
- }
34
- export interface IpSocketAddressIpv6 {
35
- tag: 'ipv6',
36
- val: Ipv6SocketAddress,
37
- }
38
- /**
39
- * # Variants
40
- *
41
- * ## `"ipv4"`
42
- *
43
- * Similar to `AF_INET` in POSIX.
44
- *
45
- * ## `"ipv6"`
46
- *
47
- * Similar to `AF_INET6` in POSIX.
48
- */
49
- export type IpAddressFamily = 'ipv4' | 'ipv6';
50
- export type IpAddress = IpAddressIpv4 | IpAddressIpv6;
51
- export interface IpAddressIpv4 {
52
- tag: 'ipv4',
53
- val: Ipv4Address,
54
- }
55
- export interface IpAddressIpv6 {
56
- tag: 'ipv6',
57
- val: Ipv6Address,
58
- }
59
17
  /**
60
18
  * Error codes.
61
19
  *
@@ -68,39 +26,32 @@ export interface IpAddressIpv6 {
68
26
  * - `out-of-memory`
69
27
  *
70
28
  * See each individual API for what the POSIX equivalents are. They sometimes differ per API.
71
- *
72
29
  * # Variants
73
30
  *
74
31
  * ## `"unknown"`
75
32
  *
76
33
  * Unknown error
77
- *
78
34
  * ## `"access-denied"`
79
35
  *
80
36
  * Access denied.
81
37
  *
82
38
  * POSIX equivalent: EACCES, EPERM
83
- *
84
39
  * ## `"not-supported"`
85
40
  *
86
41
  * The operation is not supported.
87
42
  *
88
43
  * POSIX equivalent: EOPNOTSUPP
89
- *
90
44
  * ## `"out-of-memory"`
91
45
  *
92
46
  * Not enough memory to complete the operation.
93
47
  *
94
48
  * POSIX equivalent: ENOMEM, ENOBUFS, EAI_MEMORY
95
- *
96
49
  * ## `"timeout"`
97
50
  *
98
51
  * The operation timed out before it could finish completely.
99
- *
100
52
  * ## `"concurrency-conflict"`
101
53
  *
102
54
  * This operation is incompatible with another asynchronous operation that is already in progress.
103
- *
104
55
  * ## `"not-in-progress"`
105
56
  *
106
57
  * Trying to finish an asynchronous operation that:
@@ -108,105 +59,122 @@ export interface IpAddressIpv6 {
108
59
  * - was already finished by a previous `finish-*` call.
109
60
  *
110
61
  * Note: this is scheduled to be removed when `future`s are natively supported.
111
- *
112
62
  * ## `"would-block"`
113
63
  *
114
64
  * The operation has been aborted because it could not be completed immediately.
115
65
  *
116
66
  * Note: this is scheduled to be removed when `future`s are natively supported.
117
- *
118
67
  * ## `"address-family-not-supported"`
119
68
  *
120
69
  * The specified address-family is not supported.
121
- *
122
70
  * ## `"address-family-mismatch"`
123
71
  *
124
72
  * An IPv4 address was passed to an IPv6 resource, or vice versa.
125
- *
126
73
  * ## `"invalid-remote-address"`
127
74
  *
128
75
  * The socket address is not a valid remote address. E.g. the IP address is set to INADDR_ANY, or the port is set to 0.
129
- *
130
76
  * ## `"ipv4-only-operation"`
131
77
  *
132
78
  * The operation is only supported on IPv4 resources.
133
- *
134
79
  * ## `"ipv6-only-operation"`
135
80
  *
136
81
  * The operation is only supported on IPv6 resources.
137
- *
138
82
  * ## `"new-socket-limit"`
139
83
  *
140
84
  * A new socket resource could not be created because of a system limit.
141
- *
142
85
  * ## `"already-attached"`
143
86
  *
144
87
  * The socket is already attached to another network.
145
- *
146
88
  * ## `"already-bound"`
147
89
  *
148
90
  * The socket is already bound.
149
- *
150
91
  * ## `"already-connected"`
151
92
  *
152
93
  * The socket is already in the Connection state.
153
- *
154
94
  * ## `"not-bound"`
155
95
  *
156
96
  * The socket is not bound to any local address.
157
- *
158
97
  * ## `"not-connected"`
159
98
  *
160
99
  * The socket is not in the Connection state.
161
- *
162
100
  * ## `"address-not-bindable"`
163
101
  *
164
102
  * A bind operation failed because the provided address is not an address that the `network` can bind to.
165
- *
166
103
  * ## `"address-in-use"`
167
104
  *
168
105
  * A bind operation failed because the provided address is already in use.
169
- *
170
106
  * ## `"ephemeral-ports-exhausted"`
171
107
  *
172
108
  * A bind operation failed because there are no ephemeral ports available.
173
- *
174
109
  * ## `"remote-unreachable"`
175
110
  *
176
111
  * The remote address is not reachable
177
- *
178
112
  * ## `"already-listening"`
179
113
  *
180
114
  * The socket is already in the Listener state.
181
- *
182
115
  * ## `"not-listening"`
183
116
  *
184
117
  * The socket is already in the Listener state.
185
- *
186
118
  * ## `"connection-refused"`
187
119
  *
188
120
  * The connection was forcefully rejected
189
- *
190
121
  * ## `"connection-reset"`
191
122
  *
192
123
  * The connection was reset.
193
- *
194
124
  * ## `"datagram-too-large"`
195
125
  *
196
126
  * ## `"invalid-name"`
197
127
  *
198
128
  * The provided name is a syntactically invalid domain name.
199
- *
200
129
  * ## `"name-unresolvable"`
201
130
  *
202
131
  * Name does not exist or has no suitable associated IP addresses.
203
- *
204
132
  * ## `"temporary-resolver-failure"`
205
133
  *
206
134
  * A temporary failure in name resolution occurred.
207
- *
208
135
  * ## `"permanent-resolver-failure"`
209
136
  *
210
137
  * A permanent failure in name resolution occurred.
211
138
  */
212
139
  export type ErrorCode = 'unknown' | 'access-denied' | 'not-supported' | 'out-of-memory' | 'timeout' | 'concurrency-conflict' | 'not-in-progress' | 'would-block' | 'address-family-not-supported' | 'address-family-mismatch' | 'invalid-remote-address' | 'ipv4-only-operation' | 'ipv6-only-operation' | 'new-socket-limit' | 'already-attached' | 'already-bound' | 'already-connected' | 'not-bound' | 'not-connected' | 'address-not-bindable' | 'address-in-use' | 'ephemeral-ports-exhausted' | 'remote-unreachable' | 'already-listening' | 'not-listening' | 'connection-refused' | 'connection-reset' | 'datagram-too-large' | 'invalid-name' | 'name-unresolvable' | 'temporary-resolver-failure' | 'permanent-resolver-failure';
140
+ /**
141
+ * # Variants
142
+ *
143
+ * ## `"ipv4"`
144
+ *
145
+ * Similar to `AF_INET` in POSIX.
146
+ * ## `"ipv6"`
147
+ *
148
+ * Similar to `AF_INET6` in POSIX.
149
+ */
150
+ export type IpAddressFamily = 'ipv4' | 'ipv6';
151
+ export type Ipv4Address = [number, number, number, number];
152
+ export type Ipv6Address = [number, number, number, number, number, number, number, number];
153
+ export type IpAddress = IpAddressIpv4 | IpAddressIpv6;
154
+ export interface IpAddressIpv4 {
155
+ tag: 'ipv4',
156
+ val: Ipv4Address,
157
+ }
158
+ export interface IpAddressIpv6 {
159
+ tag: 'ipv6',
160
+ val: Ipv6Address,
161
+ }
162
+ export interface Ipv4SocketAddress {
163
+ port: number,
164
+ address: Ipv4Address,
165
+ }
166
+ export interface Ipv6SocketAddress {
167
+ port: number,
168
+ flowInfo: number,
169
+ address: Ipv6Address,
170
+ scopeId: number,
171
+ }
172
+ export type IpSocketAddress = IpSocketAddressIpv4 | IpSocketAddressIpv6;
173
+ export interface IpSocketAddressIpv4 {
174
+ tag: 'ipv4',
175
+ val: Ipv4SocketAddress,
176
+ }
177
+ export interface IpSocketAddressIpv6 {
178
+ tag: 'ipv6',
179
+ val: Ipv6SocketAddress,
180
+ }
@@ -1,4 +1,4 @@
1
- export namespace ImportsTcpCreateSocket {
1
+ export namespace WasiSocketsTcpCreateSocket {
2
2
  /**
3
3
  * Create a new TCP socket.
4
4
  *
@@ -23,11 +23,11 @@ export namespace ImportsTcpCreateSocket {
23
23
  */
24
24
  export function createTcpSocket(addressFamily: IpAddressFamily): TcpSocket;
25
25
  }
26
- import type { Network } from '../imports/network';
26
+ import type { Network } from '../exports/wasi-sockets-network';
27
27
  export { Network };
28
- import type { ErrorCode } from '../imports/network';
28
+ import type { ErrorCode } from '../exports/wasi-sockets-network';
29
29
  export { ErrorCode };
30
- import type { IpAddressFamily } from '../imports/network';
30
+ import type { IpAddressFamily } from '../exports/wasi-sockets-network';
31
31
  export { IpAddressFamily };
32
- import type { TcpSocket } from '../imports/tcp';
32
+ import type { TcpSocket } from '../exports/wasi-sockets-tcp';
33
33
  export { TcpSocket };
@@ -1,4 +1,4 @@
1
- export namespace ImportsTcp {
1
+ export namespace WasiSocketsTcp {
2
2
  /**
3
3
  * Bind the socket to a specific network on the provided IP address and port.
4
4
  *
@@ -29,8 +29,8 @@ export namespace ImportsTcp {
29
29
  * - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-bind>
30
30
  * - <https://man.freebsd.org/cgi/man.cgi?query=bind&sektion=2&format=html>
31
31
  */
32
- export function startBind(this: TcpSocket, network: Network, localAddress: IpSocketAddress): void;
33
- export function finishBind(this: TcpSocket): void;
32
+ export function startBind(this_: TcpSocket, network: Network, localAddress: IpSocketAddress): void;
33
+ export function finishBind(this_: TcpSocket): void;
34
34
  /**
35
35
  * Connect to a remote endpoint.
36
36
  *
@@ -62,17 +62,19 @@ export namespace ImportsTcp {
62
62
  * - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-connect>
63
63
  * - <https://man.freebsd.org/cgi/man.cgi?connect>
64
64
  */
65
- export function startConnect(this: TcpSocket, network: Network, remoteAddress: IpSocketAddress): void;
66
- export function finishConnect(this: TcpSocket): [InputStream, OutputStream];
65
+ export function startConnect(this_: TcpSocket, network: Network, remoteAddress: IpSocketAddress): void;
66
+ export function finishConnect(this_: TcpSocket): [InputStream, OutputStream];
67
67
  /**
68
68
  * Start listening for new connections.
69
69
  *
70
70
  * Transitions the socket into the Listener state.
71
71
  *
72
- * Unlike in POSIX, this function is async. This enables interactive WASI hosts to inject permission prompts.
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.
73
75
  *
74
76
  * # Typical `start` errors
75
- * - `already-attached`: The socket is already attached to a different network. The `network` passed to `listen` must be identical to the one passed to `bind`.
77
+ * - `not-bound`: The socket is not bound to any local address. (EDESTADDRREQ)
76
78
  * - `already-connected`: The socket is already in the Connection state. (EISCONN, EINVAL on BSD)
77
79
  * - `already-listening`: The socket is already in the Listener state.
78
80
  * - `concurrency-conflict`: Another `bind`, `connect` or `listen` operation is already in progress. (EINVAL on BSD)
@@ -88,8 +90,8 @@ export namespace ImportsTcp {
88
90
  * - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-listen>
89
91
  * - <https://man.freebsd.org/cgi/man.cgi?query=listen&sektion=2>
90
92
  */
91
- export function startListen(this: TcpSocket, network: Network): void;
92
- export function finishListen(this: TcpSocket): void;
93
+ export function startListen(this_: TcpSocket): void;
94
+ export function finishListen(this_: TcpSocket): void;
93
95
  /**
94
96
  * Accept a new client socket.
95
97
  *
@@ -110,7 +112,7 @@ export namespace ImportsTcp {
110
112
  * - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-accept>
111
113
  * - <https://man.freebsd.org/cgi/man.cgi?query=accept&sektion=2>
112
114
  */
113
- export function accept(this: TcpSocket): [TcpSocket, InputStream, OutputStream];
115
+ export function accept(this_: TcpSocket): [TcpSocket, InputStream, OutputStream];
114
116
  /**
115
117
  * Get the bound local address.
116
118
  *
@@ -123,7 +125,7 @@ export namespace ImportsTcp {
123
125
  * - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-getsockname>
124
126
  * - <https://man.freebsd.org/cgi/man.cgi?getsockname>
125
127
  */
126
- export function localAddress(this: TcpSocket): IpSocketAddress;
128
+ export function localAddress(this_: TcpSocket): IpSocketAddress;
127
129
  /**
128
130
  * Get the bound remote address.
129
131
  *
@@ -136,13 +138,13 @@ export namespace ImportsTcp {
136
138
  * - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-getpeername>
137
139
  * - <https://man.freebsd.org/cgi/man.cgi?query=getpeername&sektion=2&n=1>
138
140
  */
139
- export function remoteAddress(this: TcpSocket): IpSocketAddress;
141
+ export function remoteAddress(this_: TcpSocket): IpSocketAddress;
140
142
  /**
141
143
  * Whether this is a IPv4 or IPv6 socket.
142
144
  *
143
145
  * Equivalent to the SO_DOMAIN socket option.
144
146
  */
145
- export function addressFamily(this: TcpSocket): IpAddressFamily;
147
+ export function addressFamily(this_: TcpSocket): IpAddressFamily;
146
148
  /**
147
149
  * Whether IPv4 compatibility (dual-stack) mode is disabled or not.
148
150
  *
@@ -154,8 +156,8 @@ export namespace ImportsTcp {
154
156
  * - `not-supported`: (set) Host does not support dual-stack sockets. (Implementations are not required to.)
155
157
  * - `concurrency-conflict`: (set) A `bind`, `connect` or `listen` operation is already in progress. (EALREADY)
156
158
  */
157
- export function ipv6Only(this: TcpSocket): boolean;
158
- export function setIpv6Only(this: TcpSocket, value: boolean): void;
159
+ export function ipv6Only(this_: TcpSocket): boolean;
160
+ export function setIpv6Only(this_: TcpSocket, value: boolean): void;
159
161
  /**
160
162
  * Hints the desired listen queue size. Implementations are free to ignore this.
161
163
  *
@@ -163,23 +165,23 @@ export namespace ImportsTcp {
163
165
  * - `already-connected`: (set) The socket is already in the Connection state.
164
166
  * - `concurrency-conflict`: (set) A `bind`, `connect` or `listen` operation is already in progress. (EALREADY)
165
167
  */
166
- export function setListenBacklogSize(this: TcpSocket, value: bigint): void;
168
+ export function setListenBacklogSize(this_: TcpSocket, value: bigint): void;
167
169
  /**
168
170
  * Equivalent to the SO_KEEPALIVE socket option.
169
171
  *
170
172
  * # Typical errors
171
173
  * - `concurrency-conflict`: (set) A `bind`, `connect` or `listen` operation is already in progress. (EALREADY)
172
174
  */
173
- export function keepAlive(this: TcpSocket): boolean;
174
- export function setKeepAlive(this: TcpSocket, value: boolean): void;
175
+ export function keepAlive(this_: TcpSocket): boolean;
176
+ export function setKeepAlive(this_: TcpSocket, value: boolean): void;
175
177
  /**
176
178
  * Equivalent to the TCP_NODELAY socket option.
177
179
  *
178
180
  * # Typical errors
179
181
  * - `concurrency-conflict`: (set) A `bind`, `connect` or `listen` operation is already in progress. (EALREADY)
180
182
  */
181
- export function noDelay(this: TcpSocket): boolean;
182
- export function setNoDelay(this: TcpSocket, value: boolean): void;
183
+ export function noDelay(this_: TcpSocket): boolean;
184
+ export function setNoDelay(this_: TcpSocket, value: boolean): void;
183
185
  /**
184
186
  * Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options.
185
187
  *
@@ -188,8 +190,8 @@ export namespace ImportsTcp {
188
190
  * - `already-listening`: (set) The socket is already in the Listener state.
189
191
  * - `concurrency-conflict`: (set) A `bind`, `connect` or `listen` operation is already in progress. (EALREADY)
190
192
  */
191
- export function unicastHopLimit(this: TcpSocket): number;
192
- export function setUnicastHopLimit(this: TcpSocket, value: number): void;
193
+ export function unicastHopLimit(this_: TcpSocket): number;
194
+ export function setUnicastHopLimit(this_: TcpSocket, value: number): void;
193
195
  /**
194
196
  * The kernel buffer space reserved for sends/receives on this socket.
195
197
  *
@@ -207,17 +209,17 @@ export namespace ImportsTcp {
207
209
  * - `already-listening`: (set) The socket is already in the Listener state.
208
210
  * - `concurrency-conflict`: (set) A `bind`, `connect` or `listen` operation is already in progress. (EALREADY)
209
211
  */
210
- export function receiveBufferSize(this: TcpSocket): bigint;
211
- export function setReceiveBufferSize(this: TcpSocket, value: bigint): void;
212
- export function sendBufferSize(this: TcpSocket): bigint;
213
- export function setSendBufferSize(this: TcpSocket, value: bigint): void;
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;
214
216
  /**
215
217
  * Create a `pollable` which will resolve once the socket is ready for I/O.
216
218
  *
217
219
  * Note: this function is here for WASI Preview2 only.
218
220
  * It's planned to be removed when `future` is natively supported in Preview3.
219
221
  */
220
- export function subscribe(this: TcpSocket): Pollable;
222
+ export function subscribe(this_: TcpSocket): Pollable;
221
223
  /**
222
224
  * Initiate a graceful shutdown.
223
225
  *
@@ -239,7 +241,7 @@ export namespace ImportsTcp {
239
241
  * - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-shutdown>
240
242
  * - <https://man.freebsd.org/cgi/man.cgi?query=shutdown&sektion=2>
241
243
  */
242
- export function shutdown(this: TcpSocket, shutdownType: ShutdownType): void;
244
+ export function shutdown(this_: TcpSocket, shutdownType: ShutdownType): void;
243
245
  /**
244
246
  * Dispose of the specified `tcp-socket`, after which it may no longer be used.
245
247
  *
@@ -247,21 +249,21 @@ export namespace ImportsTcp {
247
249
  *
248
250
  * Note: this function is scheduled to be removed when Resources are natively supported in Wit.
249
251
  */
250
- export function dropTcpSocket(this: TcpSocket): void;
252
+ export function dropTcpSocket(this_: TcpSocket): void;
251
253
  }
252
- import type { InputStream } from '../imports/streams';
254
+ import type { InputStream } from '../exports/wasi-io-streams';
253
255
  export { InputStream };
254
- import type { OutputStream } from '../imports/streams';
256
+ import type { OutputStream } from '../exports/wasi-io-streams';
255
257
  export { OutputStream };
256
- import type { Pollable } from '../imports/poll';
258
+ import type { Pollable } from '../exports/wasi-poll-poll';
257
259
  export { Pollable };
258
- import type { Network } from '../imports/network';
260
+ import type { Network } from '../exports/wasi-sockets-network';
259
261
  export { Network };
260
- import type { ErrorCode } from '../imports/network';
262
+ import type { ErrorCode } from '../exports/wasi-sockets-network';
261
263
  export { ErrorCode };
262
- import type { IpSocketAddress } from '../imports/network';
264
+ import type { IpSocketAddress } from '../exports/wasi-sockets-network';
263
265
  export { IpSocketAddress };
264
- import type { IpAddressFamily } from '../imports/network';
266
+ import type { IpAddressFamily } from '../exports/wasi-sockets-network';
265
267
  export { IpAddressFamily };
266
268
  /**
267
269
  * A TCP socket handle.
@@ -273,11 +275,9 @@ export type TcpSocket = number;
273
275
  * ## `"receive"`
274
276
  *
275
277
  * Similar to `SHUT_RD` in POSIX.
276
- *
277
278
  * ## `"send"`
278
279
  *
279
280
  * Similar to `SHUT_WR` in POSIX.
280
- *
281
281
  * ## `"both"`
282
282
  *
283
283
  * Similar to `SHUT_RDWR` in POSIX.
@@ -1,4 +1,4 @@
1
- export namespace ImportsUdpCreateSocket {
1
+ export namespace WasiSocketsUdpCreateSocket {
2
2
  /**
3
3
  * Create a new UDP socket.
4
4
  *
@@ -23,11 +23,11 @@ export namespace ImportsUdpCreateSocket {
23
23
  */
24
24
  export function createUdpSocket(addressFamily: IpAddressFamily): UdpSocket;
25
25
  }
26
- import type { Network } from '../imports/network';
26
+ import type { Network } from '../exports/wasi-sockets-network';
27
27
  export { Network };
28
- import type { ErrorCode } from '../imports/network';
28
+ import type { ErrorCode } from '../exports/wasi-sockets-network';
29
29
  export { ErrorCode };
30
- import type { IpAddressFamily } from '../imports/network';
30
+ import type { IpAddressFamily } from '../exports/wasi-sockets-network';
31
31
  export { IpAddressFamily };
32
- import type { UdpSocket } from '../imports/udp';
32
+ import type { UdpSocket } from '../exports/wasi-sockets-udp';
33
33
  export { UdpSocket };