@bytecodealliance/preview2-shim 0.0.11 → 0.0.13

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 (37) hide show
  1. package/lib/browser/{cli-base.js → cli.js} +30 -6
  2. package/lib/browser/filesystem.js +16 -2
  3. package/lib/browser/index.js +2 -2
  4. package/lib/nodejs/cli.js +65 -0
  5. package/lib/nodejs/filesystem.js +93 -3
  6. package/lib/nodejs/index.js +2 -2
  7. package/package.json +1 -1
  8. package/lib/nodejs/cli-base.js +0 -99
  9. package/types/exports/wasi-http-incoming-handler.d.ts +0 -7
  10. package/types/imports/environment.d.ts +0 -17
  11. package/types/imports/exit.d.ts +0 -7
  12. package/types/imports/filesystem.d.ts +0 -857
  13. package/types/imports/handler.d.ts +0 -40
  14. package/types/imports/insecure-seed.d.ts +0 -22
  15. package/types/imports/insecure.d.ts +0 -20
  16. package/types/imports/instance-network.d.ts +0 -8
  17. package/types/imports/ip-name-lookup.d.ts +0 -76
  18. package/types/imports/monotonic-clock.d.ts +0 -24
  19. package/types/imports/network.d.ts +0 -212
  20. package/types/imports/outgoing-handler.d.ts +0 -9
  21. package/types/imports/poll.d.ts +0 -41
  22. package/types/imports/preopens.d.ts +0 -12
  23. package/types/imports/random.d.ts +0 -22
  24. package/types/imports/stderr.d.ts +0 -5
  25. package/types/imports/stdin.d.ts +0 -5
  26. package/types/imports/stdout.d.ts +0 -5
  27. package/types/imports/streams.d.ts +0 -180
  28. package/types/imports/tcp-create-socket.d.ts +0 -33
  29. package/types/imports/tcp.d.ts +0 -285
  30. package/types/imports/timezone.d.ts +0 -71
  31. package/types/imports/types.d.ts +0 -119
  32. package/types/imports/udp-create-socket.d.ts +0 -33
  33. package/types/imports/udp.d.ts +0 -219
  34. package/types/imports/wall-clock.d.ts +0 -31
  35. package/types/wasi-command.d.ts +0 -23
  36. package/types/wasi-proxy.d.ts +0 -10
  37. package/types/wasi-reactor.d.ts +0 -23
@@ -1,40 +0,0 @@
1
- export namespace ImportsHandler {
2
- /**
3
- * Emit a log message.
4
- *
5
- * A log message has a `level` describing what kind of message is being
6
- * sent, a context, which is an uninterpreted string meant to help
7
- * consumers group similar messages, and a string containing the message
8
- * text.
9
- */
10
- export function log(level: Level, context: string, message: string): void;
11
- }
12
- /**
13
- * A log level, describing a kind of message.
14
- *
15
- * # Variants
16
- *
17
- * ## `"trace"`
18
- *
19
- * Describes messages about the values of variables and the flow of
20
- * control within a program.
21
- *
22
- * ## `"debug"`
23
- *
24
- * Describes messages likely to be of interest to someone debugging a
25
- * program.
26
- *
27
- * ## `"info"`
28
- *
29
- * Describes messages likely to be of interest to someone monitoring a
30
- * program.
31
- *
32
- * ## `"warn"`
33
- *
34
- * Describes messages indicating hazardous situations.
35
- *
36
- * ## `"error"`
37
- *
38
- * Describes messages indicating serious errors.
39
- */
40
- export type Level = 'trace' | 'debug' | 'info' | 'warn' | 'error';
@@ -1,22 +0,0 @@
1
- export namespace ImportsInsecureSeed {
2
- /**
3
- * Return a 128-bit value that may contain a pseudo-random value.
4
- *
5
- * The returned value is not required to be computed from a CSPRNG, and may
6
- * even be entirely deterministic. Host implementations are encouraged to
7
- * provide pseudo-random values to any program exposed to
8
- * attacker-controlled content, to enable DoS protection built into many
9
- * languages' hash-map implementations.
10
- *
11
- * This function is intended to only be called once, by a source language
12
- * to initialize Denial Of Service (DoS) protection in its hash-map
13
- * implementation.
14
- *
15
- * # Expected future evolution
16
- *
17
- * This will likely be changed to a value import, to prevent it from being
18
- * called multiple times and potentially used for purposes other than DoS
19
- * protection.
20
- */
21
- export function insecureSeed(): [bigint, bigint];
22
- }
@@ -1,20 +0,0 @@
1
- export namespace ImportsInsecure {
2
- /**
3
- * Return `len` insecure pseudo-random bytes.
4
- *
5
- * This function is not cryptographically secure. Do not use it for
6
- * anything related to security.
7
- *
8
- * There are no requirements on the values of the returned bytes, however
9
- * implementations are encouraged to return evenly distributed values with
10
- * a long period.
11
- */
12
- export function getInsecureRandomBytes(len: bigint): Uint8Array | ArrayBuffer;
13
- /**
14
- * Return an insecure pseudo-random `u64` value.
15
- *
16
- * This function returns the same type of pseudo-random data as
17
- * `get-insecure-random-bytes`, represented as a `u64`.
18
- */
19
- export function getInsecureRandomU64(): bigint;
20
- }
@@ -1,8 +0,0 @@
1
- export namespace ImportsInstanceNetwork {
2
- /**
3
- * Get a handle to the default network.
4
- */
5
- export function instanceNetwork(): Network;
6
- }
7
- import type { Network } from '../imports/network';
8
- export { Network };
@@ -1,76 +0,0 @@
1
- export namespace ImportsIpNameLookup {
2
- /**
3
- * Resolve an internet host name to a list of IP addresses.
4
- *
5
- * See the wasi-socket proposal README.md for a comparison with getaddrinfo.
6
- *
7
- * # Parameters
8
- * - `name`: The name to look up. IP addresses are not allowed. Unicode domain names are automatically converted
9
- * to ASCII using IDNA encoding.
10
- * - `address-family`: If provided, limit the results to addresses of this specific address family.
11
- * - `include-unavailable`: When set to true, this function will also return addresses of which the runtime
12
- * thinks (or knows) can't be connected to at the moment. For example, this will return IPv6 addresses on
13
- * systems without an active IPv6 interface. Notes:
14
- * - Even when no public IPv6 interfaces are present or active, names like "localhost" can still resolve to an IPv6 address.
15
- * - Whatever is "available" or "unavailable" is volatile and can change everytime a network cable is unplugged.
16
- *
17
- * This function never blocks. It either immediately fails or immediately returns successfully with a `resolve-address-stream`
18
- * that can be used to (asynchronously) fetch the results.
19
- *
20
- * At the moment, the stream never completes successfully with 0 items. Ie. the first call
21
- * to `resolve-next-address` never returns `ok(none)`. This may change in the future.
22
- *
23
- * # Typical errors
24
- * - `invalid-name`: `name` is a syntactically invalid domain name.
25
- * - `invalid-name`: `name` is an IP address.
26
- * - `address-family-not-supported`: The specified `address-family` is not supported. (EAI_FAMILY)
27
- *
28
- * # References:
29
- * - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html>
30
- * - <https://man7.org/linux/man-pages/man3/getaddrinfo.3.html>
31
- * - <https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo>
32
- * - <https://man.freebsd.org/cgi/man.cgi?query=getaddrinfo&sektion=3>
33
- */
34
- export function resolveAddresses(network: Network, name: string, addressFamily: IpAddressFamily | null, includeUnavailable: boolean): ResolveAddressStream;
35
- /**
36
- * Returns the next address from the resolver.
37
- *
38
- * This function should be called multiple times. On each call, it will
39
- * return the next address in connection order preference. If all
40
- * addresses have been exhausted, this function returns `none`.
41
- * After which, you should release the stream with `drop-resolve-address-stream`.
42
- *
43
- * This function never returns IPv4-mapped IPv6 addresses.
44
- *
45
- * # Typical errors
46
- * - `name-unresolvable`: Name does not exist or has no suitable associated IP addresses. (EAI_NONAME, EAI_NODATA, EAI_ADDRFAMILY)
47
- * - `temporary-resolver-failure`: A temporary failure in name resolution occurred. (EAI_AGAIN)
48
- * - `permanent-resolver-failure`: A permanent failure in name resolution occurred. (EAI_FAIL)
49
- * - `would-block`: A result is not available yet. (EWOULDBLOCK, EAGAIN)
50
- */
51
- export function resolveNextAddress(this: ResolveAddressStream): IpAddress | null;
52
- /**
53
- * Dispose of the specified `resolve-address-stream`, after which it may no longer be used.
54
- *
55
- * Note: this function is scheduled to be removed when Resources are natively supported in Wit.
56
- */
57
- export function dropResolveAddressStream(this: ResolveAddressStream): void;
58
- /**
59
- * Create a `pollable` which will resolve once the stream is ready for I/O.
60
- *
61
- * Note: this function is here for WASI Preview2 only.
62
- * It's planned to be removed when `future` is natively supported in Preview3.
63
- */
64
- export function subscribe(this: ResolveAddressStream): Pollable;
65
- }
66
- import type { Pollable } from '../imports/poll';
67
- export { Pollable };
68
- import type { Network } from '../imports/network';
69
- export { Network };
70
- import type { ErrorCode } from '../imports/network';
71
- export { ErrorCode };
72
- import type { IpAddress } from '../imports/network';
73
- export { IpAddress };
74
- import type { IpAddressFamily } from '../imports/network';
75
- export { IpAddressFamily };
76
- export type ResolveAddressStream = number;
@@ -1,24 +0,0 @@
1
- export namespace ImportsMonotonicClock {
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/poll';
20
- export { Pollable };
21
- /**
22
- * A timestamp in nanoseconds.
23
- */
24
- export type Instant = bigint;
@@ -1,212 +0,0 @@
1
- export namespace ImportsNetwork {
2
- /**
3
- * Dispose of the specified `network`, after which it may no longer be used.
4
- *
5
- * Note: this function is scheduled to be removed when Resources are natively supported in Wit.
6
- */
7
- export function dropNetwork(this: Network): void;
8
- }
9
- /**
10
- * An opaque resource that represents access to (a subset of) the network.
11
- * This enables context-based security for networking.
12
- * There is no need for this to map 1:1 to a physical network interface.
13
- *
14
- * FYI, In the future this will be replaced by handle types.
15
- */
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
- /**
60
- * Error codes.
61
- *
62
- * In theory, every API can return any error code.
63
- * In practice, API's typically only return the errors documented per API
64
- * combined with a couple of errors that are always possible:
65
- * - `unknown`
66
- * - `access-denied`
67
- * - `not-supported`
68
- * - `out-of-memory`
69
- *
70
- * See each individual API for what the POSIX equivalents are. They sometimes differ per API.
71
- *
72
- * # Variants
73
- *
74
- * ## `"unknown"`
75
- *
76
- * Unknown error
77
- *
78
- * ## `"access-denied"`
79
- *
80
- * Access denied.
81
- *
82
- * POSIX equivalent: EACCES, EPERM
83
- *
84
- * ## `"not-supported"`
85
- *
86
- * The operation is not supported.
87
- *
88
- * POSIX equivalent: EOPNOTSUPP
89
- *
90
- * ## `"out-of-memory"`
91
- *
92
- * Not enough memory to complete the operation.
93
- *
94
- * POSIX equivalent: ENOMEM, ENOBUFS, EAI_MEMORY
95
- *
96
- * ## `"timeout"`
97
- *
98
- * The operation timed out before it could finish completely.
99
- *
100
- * ## `"concurrency-conflict"`
101
- *
102
- * This operation is incompatible with another asynchronous operation that is already in progress.
103
- *
104
- * ## `"not-in-progress"`
105
- *
106
- * Trying to finish an asynchronous operation that:
107
- * - has not been started yet, or:
108
- * - was already finished by a previous `finish-*` call.
109
- *
110
- * Note: this is scheduled to be removed when `future`s are natively supported.
111
- *
112
- * ## `"would-block"`
113
- *
114
- * The operation has been aborted because it could not be completed immediately.
115
- *
116
- * Note: this is scheduled to be removed when `future`s are natively supported.
117
- *
118
- * ## `"address-family-not-supported"`
119
- *
120
- * The specified address-family is not supported.
121
- *
122
- * ## `"address-family-mismatch"`
123
- *
124
- * An IPv4 address was passed to an IPv6 resource, or vice versa.
125
- *
126
- * ## `"invalid-remote-address"`
127
- *
128
- * 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
- * ## `"ipv4-only-operation"`
131
- *
132
- * The operation is only supported on IPv4 resources.
133
- *
134
- * ## `"ipv6-only-operation"`
135
- *
136
- * The operation is only supported on IPv6 resources.
137
- *
138
- * ## `"new-socket-limit"`
139
- *
140
- * A new socket resource could not be created because of a system limit.
141
- *
142
- * ## `"already-attached"`
143
- *
144
- * The socket is already attached to another network.
145
- *
146
- * ## `"already-bound"`
147
- *
148
- * The socket is already bound.
149
- *
150
- * ## `"already-connected"`
151
- *
152
- * The socket is already in the Connection state.
153
- *
154
- * ## `"not-bound"`
155
- *
156
- * The socket is not bound to any local address.
157
- *
158
- * ## `"not-connected"`
159
- *
160
- * The socket is not in the Connection state.
161
- *
162
- * ## `"address-not-bindable"`
163
- *
164
- * A bind operation failed because the provided address is not an address that the `network` can bind to.
165
- *
166
- * ## `"address-in-use"`
167
- *
168
- * A bind operation failed because the provided address is already in use.
169
- *
170
- * ## `"ephemeral-ports-exhausted"`
171
- *
172
- * A bind operation failed because there are no ephemeral ports available.
173
- *
174
- * ## `"remote-unreachable"`
175
- *
176
- * The remote address is not reachable
177
- *
178
- * ## `"already-listening"`
179
- *
180
- * The socket is already in the Listener state.
181
- *
182
- * ## `"not-listening"`
183
- *
184
- * The socket is already in the Listener state.
185
- *
186
- * ## `"connection-refused"`
187
- *
188
- * The connection was forcefully rejected
189
- *
190
- * ## `"connection-reset"`
191
- *
192
- * The connection was reset.
193
- *
194
- * ## `"datagram-too-large"`
195
- *
196
- * ## `"invalid-name"`
197
- *
198
- * The provided name is a syntactically invalid domain name.
199
- *
200
- * ## `"name-unresolvable"`
201
- *
202
- * Name does not exist or has no suitable associated IP addresses.
203
- *
204
- * ## `"temporary-resolver-failure"`
205
- *
206
- * A temporary failure in name resolution occurred.
207
- *
208
- * ## `"permanent-resolver-failure"`
209
- *
210
- * A permanent failure in name resolution occurred.
211
- */
212
- 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';
@@ -1,9 +0,0 @@
1
- export namespace ImportsOutgoingHandler {
2
- export function handle(request: OutgoingRequest, options: RequestOptions | null): FutureIncomingResponse;
3
- }
4
- import type { OutgoingRequest } from '../imports/types';
5
- export { OutgoingRequest };
6
- import type { RequestOptions } from '../imports/types';
7
- export { RequestOptions };
8
- import type { FutureIncomingResponse } from '../imports/types';
9
- export { FutureIncomingResponse };
@@ -1,41 +0,0 @@
1
- export namespace ImportsPoll {
2
- /**
3
- * Dispose of the specified `pollable`, after which it may no longer
4
- * be used.
5
- */
6
- export function dropPollable(this: Pollable): void;
7
- /**
8
- * Poll for completion on a set of pollables.
9
- *
10
- * The "oneoff" in the name refers to the fact that this function must do a
11
- * linear scan through the entire list of subscriptions, which may be
12
- * inefficient if the number is large and the same subscriptions are used
13
- * many times. In the future, this is expected to be obsoleted by the
14
- * component model async proposal, which will include a scalable waiting
15
- * facility.
16
- *
17
- * Note that the return type would ideally be `list<bool>`, but that would
18
- * be more difficult to polyfill given the current state of `wit-bindgen`.
19
- * See <https://github.com/bytecodealliance/preview2-prototyping/pull/11#issuecomment-1329873061>
20
- * for details. For now, we use zero to mean "not ready" and non-zero to
21
- * mean "ready".
22
- */
23
- export function pollOneoff(in: Uint32Array): Uint8Array | ArrayBuffer;
24
- }
25
- /**
26
- * A "pollable" handle.
27
- *
28
- * This is conceptually represents a `stream<_, _>`, or in other words,
29
- * a stream that one can wait on, repeatedly, but which does not itself
30
- * produce any data. It's temporary scaffolding until component-model's
31
- * async features are ready.
32
- *
33
- * And at present, it is a `u32` instead of being an actual handle, until
34
- * the wit-bindgen implementation of handles and resources is ready.
35
- *
36
- * `pollable` lifetimes are not automatically managed. Users must ensure
37
- * that they do not outlive the resource they reference.
38
- *
39
- * This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources).
40
- */
41
- export type Pollable = number;
@@ -1,12 +0,0 @@
1
- export namespace ImportsPreopens {
2
- /**
3
- * Return the set of of preopened directories, and their path.
4
- */
5
- export function getDirectories(): [Descriptor, string][];
6
- }
7
- import type { Descriptor } from '../imports/filesystem';
8
- export { Descriptor };
9
- import type { InputStream } from '../imports/streams';
10
- export { InputStream };
11
- import type { OutputStream } from '../imports/streams';
12
- export { OutputStream };
@@ -1,22 +0,0 @@
1
- export namespace ImportsRandom {
2
- /**
3
- * Return `len` cryptographically-secure pseudo-random bytes.
4
- *
5
- * This function must produce data from an adequately seeded
6
- * cryptographically-secure pseudo-random number generator (CSPRNG), so it
7
- * must not block, from the perspective of the calling program, and the
8
- * returned data is always unpredictable.
9
- *
10
- * This function must always return fresh pseudo-random data. Deterministic
11
- * environments must omit this function, rather than implementing it with
12
- * deterministic data.
13
- */
14
- export function getRandomBytes(len: bigint): Uint8Array | ArrayBuffer;
15
- /**
16
- * Return a cryptographically-secure pseudo-random `u64` value.
17
- *
18
- * This function returns the same type of pseudo-random data as
19
- * `get-random-bytes`, represented as a `u64`.
20
- */
21
- export function getRandomU64(): bigint;
22
- }
@@ -1,5 +0,0 @@
1
- export namespace ImportsStderr {
2
- export function getStderr(): OutputStream;
3
- }
4
- import type { OutputStream } from '../imports/streams';
5
- export { OutputStream };
@@ -1,5 +0,0 @@
1
- export namespace ImportsStdin {
2
- export function getStdin(): InputStream;
3
- }
4
- import type { InputStream } from '../imports/streams';
5
- export { InputStream };
@@ -1,5 +0,0 @@
1
- export namespace ImportsStdout {
2
- export function getStdout(): OutputStream;
3
- }
4
- import type { OutputStream } from '../imports/streams';
5
- export { OutputStream };