@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.
- package/README.md +2 -2
- package/lib/browser/cli.js +87 -0
- package/lib/browser/filesystem.js +216 -18
- package/lib/browser/http.js +4 -7
- package/lib/browser/index.js +2 -2
- package/lib/browser/io.js +76 -17
- package/lib/browser/logging.js +2 -2
- package/lib/browser/poll.js +48 -4
- package/lib/http/error.js +1 -1
- package/lib/http/make-request.js +3 -2
- package/lib/http/wasi-http.js +52 -40
- package/lib/nodejs/cli.js +75 -0
- package/lib/nodejs/filesystem.js +93 -3
- package/lib/nodejs/http.js +4 -7
- package/lib/nodejs/index.js +2 -2
- package/lib/nodejs/logging.js +2 -2
- package/package.json +1 -1
- package/types/{imports/environment.d.ts → exports/wasi-cli-environment.d.ts} +6 -1
- package/types/{imports/exit.d.ts → exports/wasi-cli-exit.d.ts} +2 -2
- package/types/exports/wasi-cli-run.d.ts +6 -0
- package/types/exports/wasi-cli-stderr.d.ts +5 -0
- package/types/exports/wasi-cli-stdin.d.ts +5 -0
- package/types/exports/wasi-cli-stdout.d.ts +5 -0
- package/types/exports/wasi-cli-terminal-input.d.ts +13 -0
- package/types/exports/wasi-cli-terminal-output.d.ts +13 -0
- package/types/exports/wasi-cli-terminal-stderr.d.ts +9 -0
- package/types/exports/wasi-cli-terminal-stdin.d.ts +9 -0
- package/types/exports/wasi-cli-terminal-stdout.d.ts +9 -0
- package/types/{imports/monotonic-clock.d.ts → exports/wasi-clocks-monotonic-clock.d.ts} +2 -2
- package/types/{imports/timezone.d.ts → exports/wasi-clocks-timezone.d.ts} +15 -15
- package/types/{imports/wall-clock.d.ts → exports/wasi-clocks-wall-clock.d.ts} +1 -1
- package/types/exports/wasi-filesystem-preopens.d.ts +8 -0
- package/types/{imports/filesystem.d.ts → exports/wasi-filesystem-types.d.ts} +293 -307
- package/types/exports/wasi-http-incoming-handler.d.ts +3 -3
- package/types/exports/wasi-http-outgoing-handler.d.ts +9 -0
- package/types/{imports/types.d.ts → exports/wasi-http-types.d.ts} +40 -41
- package/types/exports/wasi-io-streams.d.ts +220 -0
- package/types/{imports/poll.d.ts → exports/wasi-poll-poll.d.ts} +6 -8
- package/types/{imports/insecure-seed.d.ts → exports/wasi-random-insecure-seed.d.ts} +1 -1
- package/types/exports/wasi-random-insecure.d.ts +20 -0
- package/types/exports/wasi-random-random.d.ts +22 -0
- package/types/{imports/instance-network.d.ts → exports/wasi-sockets-instance-network.d.ts} +2 -2
- package/types/{imports/ip-name-lookup.d.ts → exports/wasi-sockets-ip-name-lookup.d.ts} +9 -9
- package/types/{imports/network.d.ts → exports/wasi-sockets-network.d.ts} +43 -75
- package/types/{imports/tcp-create-socket.d.ts → exports/wasi-sockets-tcp-create-socket.d.ts} +5 -5
- package/types/{imports/tcp.d.ts → exports/wasi-sockets-tcp.d.ts} +38 -38
- package/types/{imports/udp-create-socket.d.ts → exports/wasi-sockets-udp-create-socket.d.ts} +5 -5
- package/types/{imports/udp.d.ts → exports/wasi-sockets-udp.d.ts} +41 -32
- package/types/imports/wasi-cli-environment.d.ts +22 -0
- package/types/imports/wasi-cli-exit.d.ts +7 -0
- package/types/imports/wasi-cli-stderr.d.ts +5 -0
- package/types/imports/wasi-cli-stdin.d.ts +5 -0
- package/types/imports/wasi-cli-stdout.d.ts +5 -0
- package/types/imports/wasi-cli-terminal-input.d.ts +13 -0
- package/types/imports/wasi-cli-terminal-output.d.ts +13 -0
- package/types/imports/wasi-cli-terminal-stderr.d.ts +9 -0
- package/types/imports/wasi-cli-terminal-stdin.d.ts +9 -0
- package/types/imports/wasi-cli-terminal-stdout.d.ts +9 -0
- package/types/imports/wasi-clocks-monotonic-clock.d.ts +24 -0
- package/types/imports/wasi-clocks-timezone.d.ts +71 -0
- package/types/imports/wasi-clocks-wall-clock.d.ts +31 -0
- package/types/imports/wasi-filesystem-preopens.d.ts +8 -0
- package/types/imports/wasi-filesystem-types.d.ts +843 -0
- package/types/imports/wasi-http-outgoing-handler.d.ts +9 -0
- package/types/imports/wasi-http-types.d.ts +118 -0
- package/types/imports/wasi-io-streams.d.ts +220 -0
- package/types/imports/wasi-poll-poll.d.ts +39 -0
- package/types/imports/wasi-random-insecure-seed.d.ts +22 -0
- package/types/imports/{insecure.d.ts → wasi-random-insecure.d.ts} +1 -1
- package/types/imports/{random.d.ts → wasi-random-random.d.ts} +1 -1
- package/types/imports/wasi-sockets-instance-network.d.ts +8 -0
- package/types/imports/wasi-sockets-ip-name-lookup.d.ts +76 -0
- package/types/imports/wasi-sockets-network.d.ts +180 -0
- package/types/imports/wasi-sockets-tcp-create-socket.d.ts +33 -0
- package/types/imports/wasi-sockets-tcp.d.ts +285 -0
- package/types/imports/wasi-sockets-udp-create-socket.d.ts +33 -0
- package/types/imports/wasi-sockets-udp.d.ts +228 -0
- package/types/wasi-cli-command.d.ts +29 -0
- package/types/wasi-http-proxy.d.ts +13 -0
- package/lib/browser/cli-base.js +0 -48
- package/lib/nodejs/cli-base.js +0 -99
- package/types/imports/handler.d.ts +0 -40
- package/types/imports/outgoing-handler.d.ts +0 -9
- package/types/imports/preopens.d.ts +0 -12
- package/types/imports/stderr.d.ts +0 -5
- package/types/imports/stdin.d.ts +0 -5
- package/types/imports/stdout.d.ts +0 -5
- package/types/imports/streams.d.ts +0 -180
- package/types/wasi-command.d.ts +0 -23
- package/types/wasi-proxy.d.ts +0 -10
- package/types/wasi-reactor.d.ts +0 -23
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export namespace
|
|
1
|
+
export namespace WasiSocketsUdp {
|
|
2
2
|
/**
|
|
3
3
|
* Bind the socket to a specific network on the provided IP address and port.
|
|
4
4
|
*
|
|
@@ -28,8 +28,8 @@ export namespace ImportsUdp {
|
|
|
28
28
|
* - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-bind>
|
|
29
29
|
* - <https://man.freebsd.org/cgi/man.cgi?query=bind&sektion=2&format=html>
|
|
30
30
|
*/
|
|
31
|
-
export function startBind(
|
|
32
|
-
export function finishBind(
|
|
31
|
+
export function startBind(this_: UdpSocket, network: Network, localAddress: IpSocketAddress): void;
|
|
32
|
+
export function finishBind(this_: UdpSocket): void;
|
|
33
33
|
/**
|
|
34
34
|
* Set the destination address.
|
|
35
35
|
*
|
|
@@ -61,14 +61,14 @@ export namespace ImportsUdp {
|
|
|
61
61
|
* - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-connect>
|
|
62
62
|
* - <https://man.freebsd.org/cgi/man.cgi?connect>
|
|
63
63
|
*/
|
|
64
|
-
export function startConnect(
|
|
65
|
-
export function finishConnect(
|
|
64
|
+
export function startConnect(this_: UdpSocket, network: Network, remoteAddress: IpSocketAddress): void;
|
|
65
|
+
export function finishConnect(this_: UdpSocket): void;
|
|
66
66
|
/**
|
|
67
|
-
* Receive
|
|
67
|
+
* Receive messages on the socket.
|
|
68
68
|
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* -
|
|
69
|
+
* This function attempts to receive up to `max-results` datagrams on the socket without blocking.
|
|
70
|
+
* The returned list may contain fewer elements than requested, but never more.
|
|
71
|
+
* If `max-results` is 0, this function returns successfully with an empty list.
|
|
72
72
|
*
|
|
73
73
|
* # Typical errors
|
|
74
74
|
* - `not-bound`: The socket is not bound to any local address. (EINVAL)
|
|
@@ -79,14 +79,24 @@ export namespace ImportsUdp {
|
|
|
79
79
|
* - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/recvfrom.html>
|
|
80
80
|
* - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/recvmsg.html>
|
|
81
81
|
* - <https://man7.org/linux/man-pages/man2/recv.2.html>
|
|
82
|
+
* - <https://man7.org/linux/man-pages/man2/recvmmsg.2.html>
|
|
82
83
|
* - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-recv>
|
|
83
84
|
* - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-recvfrom>
|
|
84
85
|
* - <https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms741687(v=vs.85)>
|
|
85
86
|
* - <https://man.freebsd.org/cgi/man.cgi?query=recv&sektion=2>
|
|
86
87
|
*/
|
|
87
|
-
export function receive(
|
|
88
|
+
export function receive(this_: UdpSocket, maxResults: bigint): Datagram[];
|
|
88
89
|
/**
|
|
89
|
-
* Send
|
|
90
|
+
* Send messages on the socket.
|
|
91
|
+
*
|
|
92
|
+
* This function attempts to send all provided `datagrams` on the socket without blocking and
|
|
93
|
+
* returns how many messages were actually sent (or queued for sending).
|
|
94
|
+
*
|
|
95
|
+
* This function semantically behaves the same as iterating the `datagrams` list and sequentially
|
|
96
|
+
* sending each individual datagram until either the end of the list has been reached or the first error occurred.
|
|
97
|
+
* If at least one datagram has been sent successfully, this function never returns an error.
|
|
98
|
+
*
|
|
99
|
+
* If the input list is empty, the function returns `ok(0)`.
|
|
90
100
|
*
|
|
91
101
|
* The remote address option is required. To send a message to the "connected" peer,
|
|
92
102
|
* call `remote-address` to get their address.
|
|
@@ -105,12 +115,13 @@ export namespace ImportsUdp {
|
|
|
105
115
|
* - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/sendto.html>
|
|
106
116
|
* - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/sendmsg.html>
|
|
107
117
|
* - <https://man7.org/linux/man-pages/man2/send.2.html>
|
|
118
|
+
* - <https://man7.org/linux/man-pages/man2/sendmmsg.2.html>
|
|
108
119
|
* - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-send>
|
|
109
120
|
* - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendto>
|
|
110
121
|
* - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasendmsg>
|
|
111
122
|
* - <https://man.freebsd.org/cgi/man.cgi?query=send&sektion=2>
|
|
112
123
|
*/
|
|
113
|
-
export function send(
|
|
124
|
+
export function send(this_: UdpSocket, datagrams: Datagram[]): bigint;
|
|
114
125
|
/**
|
|
115
126
|
* Get the current bound address.
|
|
116
127
|
*
|
|
@@ -123,7 +134,7 @@ export namespace ImportsUdp {
|
|
|
123
134
|
* - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-getsockname>
|
|
124
135
|
* - <https://man.freebsd.org/cgi/man.cgi?getsockname>
|
|
125
136
|
*/
|
|
126
|
-
export function localAddress(
|
|
137
|
+
export function localAddress(this_: UdpSocket): IpSocketAddress;
|
|
127
138
|
/**
|
|
128
139
|
* Get the address set with `connect`.
|
|
129
140
|
*
|
|
@@ -136,13 +147,13 @@ export namespace ImportsUdp {
|
|
|
136
147
|
* - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-getpeername>
|
|
137
148
|
* - <https://man.freebsd.org/cgi/man.cgi?query=getpeername&sektion=2&n=1>
|
|
138
149
|
*/
|
|
139
|
-
export function remoteAddress(
|
|
150
|
+
export function remoteAddress(this_: UdpSocket): IpSocketAddress;
|
|
140
151
|
/**
|
|
141
152
|
* Whether this is a IPv4 or IPv6 socket.
|
|
142
153
|
*
|
|
143
154
|
* Equivalent to the SO_DOMAIN socket option.
|
|
144
155
|
*/
|
|
145
|
-
export function addressFamily(
|
|
156
|
+
export function addressFamily(this_: UdpSocket): IpAddressFamily;
|
|
146
157
|
/**
|
|
147
158
|
* Whether IPv4 compatibility (dual-stack) mode is disabled or not.
|
|
148
159
|
*
|
|
@@ -154,16 +165,16 @@ export namespace ImportsUdp {
|
|
|
154
165
|
* - `not-supported`: (set) Host does not support dual-stack sockets. (Implementations are not required to.)
|
|
155
166
|
* - `concurrency-conflict`: (set) Another `bind` or `connect` operation is already in progress. (EALREADY)
|
|
156
167
|
*/
|
|
157
|
-
export function ipv6Only(
|
|
158
|
-
export function setIpv6Only(
|
|
168
|
+
export function ipv6Only(this_: UdpSocket): boolean;
|
|
169
|
+
export function setIpv6Only(this_: UdpSocket, value: boolean): void;
|
|
159
170
|
/**
|
|
160
171
|
* Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options.
|
|
161
172
|
*
|
|
162
173
|
* # Typical errors
|
|
163
174
|
* - `concurrency-conflict`: (set) Another `bind` or `connect` operation is already in progress. (EALREADY)
|
|
164
175
|
*/
|
|
165
|
-
export function unicastHopLimit(
|
|
166
|
-
export function setUnicastHopLimit(
|
|
176
|
+
export function unicastHopLimit(this_: UdpSocket): number;
|
|
177
|
+
export function setUnicastHopLimit(this_: UdpSocket, value: number): void;
|
|
167
178
|
/**
|
|
168
179
|
* The kernel buffer space reserved for sends/receives on this socket.
|
|
169
180
|
*
|
|
@@ -174,40 +185,38 @@ export namespace ImportsUdp {
|
|
|
174
185
|
* actual data to be sent/received by the application, because the kernel might also use the buffer space
|
|
175
186
|
* for internal metadata structures.
|
|
176
187
|
*
|
|
177
|
-
* Fails when this socket is in the Listening state.
|
|
178
|
-
*
|
|
179
188
|
* Equivalent to the SO_RCVBUF and SO_SNDBUF socket options.
|
|
180
189
|
*
|
|
181
190
|
* # Typical errors
|
|
182
191
|
* - `concurrency-conflict`: (set) Another `bind` or `connect` operation is already in progress. (EALREADY)
|
|
183
192
|
*/
|
|
184
|
-
export function receiveBufferSize(
|
|
185
|
-
export function setReceiveBufferSize(
|
|
186
|
-
export function sendBufferSize(
|
|
187
|
-
export function setSendBufferSize(
|
|
193
|
+
export function receiveBufferSize(this_: UdpSocket): bigint;
|
|
194
|
+
export function setReceiveBufferSize(this_: UdpSocket, value: bigint): void;
|
|
195
|
+
export function sendBufferSize(this_: UdpSocket): bigint;
|
|
196
|
+
export function setSendBufferSize(this_: UdpSocket, value: bigint): void;
|
|
188
197
|
/**
|
|
189
198
|
* Create a `pollable` which will resolve once the socket is ready for I/O.
|
|
190
199
|
*
|
|
191
200
|
* Note: this function is here for WASI Preview2 only.
|
|
192
201
|
* It's planned to be removed when `future` is natively supported in Preview3.
|
|
193
202
|
*/
|
|
194
|
-
export function subscribe(
|
|
203
|
+
export function subscribe(this_: UdpSocket): Pollable;
|
|
195
204
|
/**
|
|
196
205
|
* Dispose of the specified `udp-socket`, after which it may no longer be used.
|
|
197
206
|
*
|
|
198
207
|
* Note: this function is scheduled to be removed when Resources are natively supported in Wit.
|
|
199
208
|
*/
|
|
200
|
-
export function dropUdpSocket(
|
|
209
|
+
export function dropUdpSocket(this_: UdpSocket): void;
|
|
201
210
|
}
|
|
202
|
-
import type { Pollable } from '../
|
|
211
|
+
import type { Pollable } from '../exports/wasi-poll-poll';
|
|
203
212
|
export { Pollable };
|
|
204
|
-
import type { Network } from '../
|
|
213
|
+
import type { Network } from '../exports/wasi-sockets-network';
|
|
205
214
|
export { Network };
|
|
206
|
-
import type { ErrorCode } from '../
|
|
215
|
+
import type { ErrorCode } from '../exports/wasi-sockets-network';
|
|
207
216
|
export { ErrorCode };
|
|
208
|
-
import type { IpSocketAddress } from '../
|
|
217
|
+
import type { IpSocketAddress } from '../exports/wasi-sockets-network';
|
|
209
218
|
export { IpSocketAddress };
|
|
210
|
-
import type { IpAddressFamily } from '../
|
|
219
|
+
import type { IpAddressFamily } from '../exports/wasi-sockets-network';
|
|
211
220
|
export { IpAddressFamily };
|
|
212
221
|
/**
|
|
213
222
|
* A UDP socket handle.
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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;
|
|
@@ -0,0 +1,13 @@
|
|
|
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;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export namespace WasiCliTerminalStderr {
|
|
2
|
+
/**
|
|
3
|
+
* If stderr is connected to a terminal, return a `terminal-output` handle
|
|
4
|
+
* allowing further interaction with it.
|
|
5
|
+
*/
|
|
6
|
+
export function getTerminalStderr(): TerminalOutput | null;
|
|
7
|
+
}
|
|
8
|
+
import type { TerminalOutput } from '../imports/wasi-cli-terminal-output';
|
|
9
|
+
export { TerminalOutput };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export namespace WasiCliTerminalStdin {
|
|
2
|
+
/**
|
|
3
|
+
* If stdin is connected to a terminal, return a `terminal-input` handle
|
|
4
|
+
* allowing further interaction with it.
|
|
5
|
+
*/
|
|
6
|
+
export function getTerminalStdin(): TerminalInput | null;
|
|
7
|
+
}
|
|
8
|
+
import type { TerminalInput } from '../imports/wasi-cli-terminal-input';
|
|
9
|
+
export { TerminalInput };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export namespace WasiCliTerminalStdout {
|
|
2
|
+
/**
|
|
3
|
+
* If stdout is connected to a terminal, return a `terminal-output` handle
|
|
4
|
+
* allowing further interaction with it.
|
|
5
|
+
*/
|
|
6
|
+
export function getTerminalStdout(): TerminalOutput | null;
|
|
7
|
+
}
|
|
8
|
+
import type { TerminalOutput } from '../imports/wasi-cli-terminal-output';
|
|
9
|
+
export { TerminalOutput };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export namespace WasiClocksMonotonicClock {
|
|
2
|
+
/**
|
|
3
|
+
* Read the current value of the clock.
|
|
4
|
+
*
|
|
5
|
+
* The clock is monotonic, therefore calling this function repeatedly will
|
|
6
|
+
* produce a sequence of non-decreasing values.
|
|
7
|
+
*/
|
|
8
|
+
export function now(): Instant;
|
|
9
|
+
/**
|
|
10
|
+
* Query the resolution of the clock.
|
|
11
|
+
*/
|
|
12
|
+
export function resolution(): Instant;
|
|
13
|
+
/**
|
|
14
|
+
* Create a `pollable` which will resolve once the specified time has been
|
|
15
|
+
* reached.
|
|
16
|
+
*/
|
|
17
|
+
export function subscribe(when: Instant, absolute: boolean): Pollable;
|
|
18
|
+
}
|
|
19
|
+
import type { Pollable } from '../imports/wasi-poll-poll';
|
|
20
|
+
export { Pollable };
|
|
21
|
+
/**
|
|
22
|
+
* A timestamp in nanoseconds.
|
|
23
|
+
*/
|
|
24
|
+
export type Instant = bigint;
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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 };
|