@bytecodealliance/preview2-shim 0.17.1 → 0.17.3
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/cli.js +91 -94
- package/lib/browser/clocks.js +30 -29
- package/lib/browser/filesystem.js +298 -251
- package/lib/browser/http.js +129 -128
- package/lib/browser/index.js +8 -16
- package/lib/browser/io.js +143 -135
- package/lib/browser/random.js +44 -42
- package/lib/browser/sockets.js +68 -166
- package/lib/common/instantiation.js +127 -0
- package/lib/io/calls.js +7 -5
- package/lib/io/worker-http.js +175 -157
- package/lib/io/worker-io.js +402 -386
- package/lib/io/worker-socket-tcp.js +271 -219
- package/lib/io/worker-socket-udp.js +494 -429
- package/lib/io/worker-sockets.js +276 -262
- package/lib/io/worker-thread.js +946 -815
- package/lib/nodejs/cli.js +64 -63
- package/lib/nodejs/clocks.js +51 -45
- package/lib/nodejs/filesystem.js +788 -654
- package/lib/nodejs/http.js +693 -617
- package/lib/nodejs/index.js +8 -16
- package/lib/nodejs/random.js +32 -28
- package/lib/nodejs/sockets.js +538 -474
- package/lib/synckit/index.js +94 -85
- package/package.json +9 -5
- package/types/cli.d.ts +11 -23
- package/types/clocks.d.ts +2 -5
- package/types/filesystem.d.ts +2 -5
- package/types/http.d.ts +3 -7
- package/types/index.d.ts +6 -15
- package/types/instantiation.d.ts +112 -0
- package/types/interfaces/wasi-cli-environment.d.ts +21 -22
- package/types/interfaces/wasi-cli-exit.d.ts +5 -6
- package/types/interfaces/wasi-cli-run.d.ts +5 -6
- package/types/interfaces/wasi-cli-stderr.d.ts +3 -5
- package/types/interfaces/wasi-cli-stdin.d.ts +3 -5
- package/types/interfaces/wasi-cli-stdout.d.ts +3 -5
- package/types/interfaces/wasi-cli-terminal-input.d.ts +5 -3
- package/types/interfaces/wasi-cli-terminal-output.d.ts +5 -3
- package/types/interfaces/wasi-cli-terminal-stderr.d.ts +7 -9
- package/types/interfaces/wasi-cli-terminal-stdin.d.ts +7 -9
- package/types/interfaces/wasi-cli-terminal-stdout.d.ts +7 -9
- package/types/interfaces/wasi-clocks-monotonic-clock.d.ts +24 -26
- package/types/interfaces/wasi-clocks-wall-clock.d.ts +23 -24
- package/types/interfaces/wasi-filesystem-preopens.d.ts +6 -8
- package/types/interfaces/wasi-filesystem-types.d.ts +34 -33
- package/types/interfaces/wasi-http-incoming-handler.d.ts +16 -19
- package/types/interfaces/wasi-http-outgoing-handler.d.ts +18 -23
- package/types/interfaces/wasi-http-types.d.ts +49 -38
- package/types/interfaces/wasi-io-error.d.ts +5 -3
- package/types/interfaces/wasi-io-poll.d.ts +27 -25
- package/types/interfaces/wasi-io-streams.d.ts +24 -21
- package/types/interfaces/wasi-random-insecure-seed.d.ts +21 -22
- package/types/interfaces/wasi-random-insecure.d.ts +19 -20
- package/types/interfaces/wasi-random-random.d.ts +23 -24
- package/types/interfaces/wasi-sockets-instance-network.d.ts +6 -8
- package/types/interfaces/wasi-sockets-ip-name-lookup.d.ts +32 -34
- package/types/interfaces/wasi-sockets-network.d.ts +5 -3
- package/types/interfaces/wasi-sockets-tcp-create-socket.d.ts +28 -33
- package/types/interfaces/wasi-sockets-tcp.d.ts +17 -23
- package/types/interfaces/wasi-sockets-udp-create-socket.d.ts +28 -33
- package/types/interfaces/wasi-sockets-udp.d.ts +20 -17
- package/types/io.d.ts +3 -7
- package/types/random.d.ts +3 -7
- package/types/sockets.d.ts +7 -15
- package/types/wasi-cli-command.d.ts +29 -29
- package/types/wasi-http-proxy.d.ts +13 -13
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
import type { Pollable } from './wasi-io-poll.js';
|
|
26
|
-
export { Pollable };
|
|
1
|
+
/** @module Interface wasi:clocks/monotonic-clock@0.2.3 **/
|
|
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. Returns the duration of time
|
|
11
|
+
* corresponding to a clock tick.
|
|
12
|
+
*/
|
|
13
|
+
export function resolution(): Duration;
|
|
14
|
+
/**
|
|
15
|
+
* Create a `pollable` which will resolve once the specified instant
|
|
16
|
+
* has occurred.
|
|
17
|
+
*/
|
|
18
|
+
export function subscribeInstant(when: Instant): Pollable;
|
|
19
|
+
/**
|
|
20
|
+
* Create a `pollable` that will resolve after the specified duration has
|
|
21
|
+
* elapsed from the time this function is invoked.
|
|
22
|
+
*/
|
|
23
|
+
export function subscribeDuration(when: Duration): Pollable;
|
|
24
|
+
export type Pollable = import('./wasi-io-poll.js').Pollable;
|
|
27
25
|
/**
|
|
28
26
|
* An instant in time, in nanoseconds. An instant is relative to an
|
|
29
27
|
* unspecified initial value, and can only be compared to instances from
|
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
1
|
+
/** @module Interface wasi:clocks/wall-clock@0.2.3 **/
|
|
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;
|
|
25
24
|
/**
|
|
26
25
|
* A time and date in seconds plus nanoseconds.
|
|
27
26
|
*/
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import type { Descriptor } from './wasi-filesystem-types.js';
|
|
8
|
-
export { Descriptor };
|
|
1
|
+
/** @module Interface wasi:filesystem/preopens@0.2.3 **/
|
|
2
|
+
/**
|
|
3
|
+
* Return the set of preopened directories, and their paths.
|
|
4
|
+
*/
|
|
5
|
+
export function getDirectories(): Array<[Descriptor, string]>;
|
|
6
|
+
export type Descriptor = import('./wasi-filesystem-types.js').Descriptor;
|
|
@@ -1,28 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export { InputStream };
|
|
20
|
-
import type { OutputStream } from './wasi-io-streams.js';
|
|
21
|
-
export { OutputStream };
|
|
22
|
-
import type { Error } from './wasi-io-streams.js';
|
|
23
|
-
export { Error };
|
|
24
|
-
import type { Datetime } from './wasi-clocks-wall-clock.js';
|
|
25
|
-
export { Datetime };
|
|
1
|
+
/** @module Interface wasi:filesystem/types@0.2.3 **/
|
|
2
|
+
/**
|
|
3
|
+
* Attempts to extract a filesystem-related `error-code` from the stream
|
|
4
|
+
* `error` provided.
|
|
5
|
+
*
|
|
6
|
+
* Stream operations which return `stream-error::last-operation-failed`
|
|
7
|
+
* have a payload with more information about the operation that failed.
|
|
8
|
+
* This payload can be passed through to this function to see if there's
|
|
9
|
+
* filesystem-related information about the error to return.
|
|
10
|
+
*
|
|
11
|
+
* Note that this function is fallible because not all stream-related
|
|
12
|
+
* errors are filesystem-related errors.
|
|
13
|
+
*/
|
|
14
|
+
export function filesystemErrorCode(err: Error): ErrorCode | undefined;
|
|
15
|
+
export type InputStream = import('./wasi-io-streams.js').InputStream;
|
|
16
|
+
export type OutputStream = import('./wasi-io-streams.js').OutputStream;
|
|
17
|
+
export type Error = import('./wasi-io-streams.js').Error;
|
|
18
|
+
export type Datetime = import('./wasi-clocks-wall-clock.js').Datetime;
|
|
26
19
|
/**
|
|
27
20
|
* File size or length of a region within a file.
|
|
28
21
|
*/
|
|
@@ -395,6 +388,10 @@ export interface MetadataHashValue {
|
|
|
395
388
|
}
|
|
396
389
|
|
|
397
390
|
export class Descriptor {
|
|
391
|
+
/**
|
|
392
|
+
* This type does not have a public constructor.
|
|
393
|
+
*/
|
|
394
|
+
private constructor();
|
|
398
395
|
/**
|
|
399
396
|
* Return a stream for reading from a file, if available.
|
|
400
397
|
*
|
|
@@ -421,7 +418,7 @@ export class Descriptor {
|
|
|
421
418
|
* May fail with an error-code describing why the file cannot be appended.
|
|
422
419
|
*
|
|
423
420
|
* Note: This allows using `write-stream`, which is similar to `write` with
|
|
424
|
-
* `O_APPEND` in
|
|
421
|
+
* `O_APPEND` in POSIX.
|
|
425
422
|
*/
|
|
426
423
|
appendViaStream(): OutputStream;
|
|
427
424
|
/**
|
|
@@ -639,14 +636,14 @@ export class Descriptor {
|
|
|
639
636
|
* replaced. It may also include a secret value chosen by the
|
|
640
637
|
* implementation and not otherwise exposed.
|
|
641
638
|
*
|
|
642
|
-
* Implementations are
|
|
639
|
+
* Implementations are encouraged to provide the following properties:
|
|
643
640
|
*
|
|
644
|
-
*
|
|
645
|
-
*
|
|
646
|
-
*
|
|
647
|
-
*
|
|
648
|
-
*
|
|
649
|
-
*
|
|
641
|
+
* - If the file is not modified or replaced, the computed hash value should
|
|
642
|
+
* usually not change.
|
|
643
|
+
* - If the object is modified or replaced, the computed hash value should
|
|
644
|
+
* usually change.
|
|
645
|
+
* - The inputs to the hash should not be easily computable from the
|
|
646
|
+
* computed hash.
|
|
650
647
|
*
|
|
651
648
|
* However, none of these is required.
|
|
652
649
|
*/
|
|
@@ -661,6 +658,10 @@ export class Descriptor {
|
|
|
661
658
|
}
|
|
662
659
|
|
|
663
660
|
export class DirectoryEntryStream {
|
|
661
|
+
/**
|
|
662
|
+
* This type does not have a public constructor.
|
|
663
|
+
*/
|
|
664
|
+
private constructor();
|
|
664
665
|
/**
|
|
665
666
|
* Read a single directory entry from a `directory-entry-stream`.
|
|
666
667
|
*/
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export { IncomingRequest };
|
|
18
|
-
import type { ResponseOutparam } from './wasi-http-types.js';
|
|
19
|
-
export { ResponseOutparam };
|
|
1
|
+
/** @module Interface wasi:http/incoming-handler@0.2.3 **/
|
|
2
|
+
/**
|
|
3
|
+
* This function is invoked with an incoming HTTP Request, and a resource
|
|
4
|
+
* `response-outparam` which provides the capability to reply with an HTTP
|
|
5
|
+
* Response. The response is sent by calling the `response-outparam.set`
|
|
6
|
+
* method, which allows execution to continue after the response has been
|
|
7
|
+
* sent. This enables both streaming to the response body, and performing other
|
|
8
|
+
* work.
|
|
9
|
+
*
|
|
10
|
+
* The implementor of this function must write a response to the
|
|
11
|
+
* `response-outparam` before returning, or else the caller will respond
|
|
12
|
+
* with an error on its behalf.
|
|
13
|
+
*/
|
|
14
|
+
export function handle(request: IncomingRequest, responseOut: ResponseOutparam): void;
|
|
15
|
+
export type IncomingRequest = import('./wasi-http-types.js').IncomingRequest;
|
|
16
|
+
export type ResponseOutparam = import('./wasi-http-types.js').ResponseOutparam;
|
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
export { RequestOptions };
|
|
20
|
-
import type { FutureIncomingResponse } from './wasi-http-types.js';
|
|
21
|
-
export { FutureIncomingResponse };
|
|
22
|
-
import type { ErrorCode } from './wasi-http-types.js';
|
|
23
|
-
export { ErrorCode };
|
|
1
|
+
/** @module Interface wasi:http/outgoing-handler@0.2.3 **/
|
|
2
|
+
/**
|
|
3
|
+
* This function is invoked with an outgoing HTTP Request, and it returns
|
|
4
|
+
* a resource `future-incoming-response` which represents an HTTP Response
|
|
5
|
+
* which may arrive in the future.
|
|
6
|
+
*
|
|
7
|
+
* The `options` argument accepts optional parameters for the HTTP
|
|
8
|
+
* protocol's transport layer.
|
|
9
|
+
*
|
|
10
|
+
* This function may return an error if the `outgoing-request` is invalid
|
|
11
|
+
* or not allowed to be made. Otherwise, protocol errors are reported
|
|
12
|
+
* through the `future-incoming-response`.
|
|
13
|
+
*/
|
|
14
|
+
export function handle(request: OutgoingRequest, options: RequestOptions | undefined): FutureIncomingResponse;
|
|
15
|
+
export type OutgoingRequest = import('./wasi-http-types.js').OutgoingRequest;
|
|
16
|
+
export type RequestOptions = import('./wasi-http-types.js').RequestOptions;
|
|
17
|
+
export type FutureIncomingResponse = import('./wasi-http-types.js').FutureIncomingResponse;
|
|
18
|
+
export type ErrorCode = import('./wasi-http-types.js').ErrorCode;
|
|
@@ -1,40 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export { IncomingResponse };
|
|
22
|
-
export { IncomingBody };
|
|
23
|
-
export { FutureTrailers };
|
|
24
|
-
export { OutgoingResponse };
|
|
25
|
-
export { OutgoingBody };
|
|
26
|
-
export { FutureIncomingResponse };
|
|
27
|
-
}
|
|
28
|
-
import type { Duration } from './wasi-clocks-monotonic-clock.js';
|
|
29
|
-
export { Duration };
|
|
30
|
-
import type { InputStream } from './wasi-io-streams.js';
|
|
31
|
-
export { InputStream };
|
|
32
|
-
import type { OutputStream } from './wasi-io-streams.js';
|
|
33
|
-
export { OutputStream };
|
|
34
|
-
import type { Error as IoError } from './wasi-io-error.js';
|
|
35
|
-
export { IoError };
|
|
36
|
-
import type { Pollable } from './wasi-io-poll.js';
|
|
37
|
-
export { Pollable };
|
|
1
|
+
/** @module Interface wasi:http/types@0.2.3 **/
|
|
2
|
+
/**
|
|
3
|
+
* Attempts to extract a http-related `error` from the wasi:io `error`
|
|
4
|
+
* provided.
|
|
5
|
+
*
|
|
6
|
+
* Stream operations which return
|
|
7
|
+
* `wasi:io/stream/stream-error::last-operation-failed` have a payload of
|
|
8
|
+
* type `wasi:io/error/error` with more information about the operation
|
|
9
|
+
* that failed. This payload can be passed through to this function to see
|
|
10
|
+
* if there's http-related information about the error to return.
|
|
11
|
+
*
|
|
12
|
+
* Note that this function is fallible because not all io-errors are
|
|
13
|
+
* http-related errors.
|
|
14
|
+
*/
|
|
15
|
+
export function httpErrorCode(err: IoError): ErrorCode | undefined;
|
|
16
|
+
export type Duration = import('./wasi-clocks-monotonic-clock.js').Duration;
|
|
17
|
+
export type InputStream = import('./wasi-io-streams.js').InputStream;
|
|
18
|
+
export type OutputStream = import('./wasi-io-streams.js').OutputStream;
|
|
19
|
+
export type IoError = import('./wasi-io-error.js').Error;
|
|
20
|
+
export type Pollable = import('./wasi-io-poll.js').Pollable;
|
|
38
21
|
/**
|
|
39
22
|
* This type corresponds to HTTP standard Methods.
|
|
40
23
|
*/
|
|
@@ -107,7 +90,7 @@ export interface FieldSizePayload {
|
|
|
107
90
|
}
|
|
108
91
|
/**
|
|
109
92
|
* These cases are inspired by the IANA HTTP Proxy Error Types:
|
|
110
|
-
*
|
|
93
|
+
* <https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types>
|
|
111
94
|
*/
|
|
112
95
|
export type ErrorCode = ErrorCodeDnsTimeout | ErrorCodeDnsError | ErrorCodeDestinationNotFound | ErrorCodeDestinationUnavailable | ErrorCodeDestinationIpProhibited | ErrorCodeDestinationIpUnroutable | ErrorCodeConnectionRefused | ErrorCodeConnectionTerminated | ErrorCodeConnectionTimeout | ErrorCodeConnectionReadTimeout | ErrorCodeConnectionWriteTimeout | ErrorCodeConnectionLimitReached | ErrorCodeTlsProtocolError | ErrorCodeTlsCertificateError | ErrorCodeTlsAlertReceived | ErrorCodeHttpRequestDenied | ErrorCodeHttpRequestLengthRequired | ErrorCodeHttpRequestBodySize | ErrorCodeHttpRequestMethodInvalid | ErrorCodeHttpRequestUriInvalid | ErrorCodeHttpRequestUriTooLong | ErrorCodeHttpRequestHeaderSectionSize | ErrorCodeHttpRequestHeaderSize | ErrorCodeHttpRequestTrailerSectionSize | ErrorCodeHttpRequestTrailerSize | ErrorCodeHttpResponseIncomplete | ErrorCodeHttpResponseHeaderSectionSize | ErrorCodeHttpResponseHeaderSize | ErrorCodeHttpResponseBodySize | ErrorCodeHttpResponseTrailerSectionSize | ErrorCodeHttpResponseTrailerSize | ErrorCodeHttpResponseTransferCoding | ErrorCodeHttpResponseContentCoding | ErrorCodeHttpResponseTimeout | ErrorCodeHttpUpgradeFailed | ErrorCodeHttpProtocolError | ErrorCodeLoopDetected | ErrorCodeConfigurationError | ErrorCodeInternalError;
|
|
113
96
|
export interface ErrorCodeDnsTimeout {
|
|
@@ -400,6 +383,10 @@ export class Fields {
|
|
|
400
383
|
}
|
|
401
384
|
|
|
402
385
|
export class FutureIncomingResponse {
|
|
386
|
+
/**
|
|
387
|
+
* This type does not have a public constructor.
|
|
388
|
+
*/
|
|
389
|
+
private constructor();
|
|
403
390
|
/**
|
|
404
391
|
* Returns a pollable which becomes ready when either the Response has
|
|
405
392
|
* been received, or an error has occurred. When this pollable is ready,
|
|
@@ -426,6 +413,10 @@ export class FutureIncomingResponse {
|
|
|
426
413
|
}
|
|
427
414
|
|
|
428
415
|
export class FutureTrailers {
|
|
416
|
+
/**
|
|
417
|
+
* This type does not have a public constructor.
|
|
418
|
+
*/
|
|
419
|
+
private constructor();
|
|
429
420
|
/**
|
|
430
421
|
* Returns a pollable which becomes ready when either the trailers have
|
|
431
422
|
* been received, or an error has occurred. When this pollable is ready,
|
|
@@ -457,6 +448,10 @@ export class FutureTrailers {
|
|
|
457
448
|
}
|
|
458
449
|
|
|
459
450
|
export class IncomingBody {
|
|
451
|
+
/**
|
|
452
|
+
* This type does not have a public constructor.
|
|
453
|
+
*/
|
|
454
|
+
private constructor();
|
|
460
455
|
/**
|
|
461
456
|
* Returns the contents of the body, as a stream of bytes.
|
|
462
457
|
*
|
|
@@ -483,6 +478,10 @@ export class IncomingBody {
|
|
|
483
478
|
}
|
|
484
479
|
|
|
485
480
|
export class IncomingRequest {
|
|
481
|
+
/**
|
|
482
|
+
* This type does not have a public constructor.
|
|
483
|
+
*/
|
|
484
|
+
private constructor();
|
|
486
485
|
/**
|
|
487
486
|
* Returns the method of the incoming request.
|
|
488
487
|
*/
|
|
@@ -518,6 +517,10 @@ export class IncomingRequest {
|
|
|
518
517
|
}
|
|
519
518
|
|
|
520
519
|
export class IncomingResponse {
|
|
520
|
+
/**
|
|
521
|
+
* This type does not have a public constructor.
|
|
522
|
+
*/
|
|
523
|
+
private constructor();
|
|
521
524
|
/**
|
|
522
525
|
* Returns the status code from the incoming response.
|
|
523
526
|
*/
|
|
@@ -540,6 +543,10 @@ export class IncomingResponse {
|
|
|
540
543
|
}
|
|
541
544
|
|
|
542
545
|
export class OutgoingBody {
|
|
546
|
+
/**
|
|
547
|
+
* This type does not have a public constructor.
|
|
548
|
+
*/
|
|
549
|
+
private constructor();
|
|
543
550
|
/**
|
|
544
551
|
* Returns a stream for writing the body contents.
|
|
545
552
|
*
|
|
@@ -722,6 +729,10 @@ export class RequestOptions {
|
|
|
722
729
|
}
|
|
723
730
|
|
|
724
731
|
export class ResponseOutparam {
|
|
732
|
+
/**
|
|
733
|
+
* This type does not have a public constructor.
|
|
734
|
+
*/
|
|
735
|
+
private constructor();
|
|
725
736
|
/**
|
|
726
737
|
* Set the value of the `response-outparam` to either send a response,
|
|
727
738
|
* or indicate an error.
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export { Error };
|
|
3
|
-
}
|
|
1
|
+
/** @module Interface wasi:io/error@0.2.3 **/
|
|
4
2
|
|
|
5
3
|
export class Error {
|
|
4
|
+
/**
|
|
5
|
+
* This type does not have a public constructor.
|
|
6
|
+
*/
|
|
7
|
+
private constructor();
|
|
6
8
|
/**
|
|
7
9
|
* Returns a string that is suitable to assist humans in debugging
|
|
8
10
|
* this error.
|
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export function poll(in_: Array<Pollable>): Uint32Array;
|
|
25
|
-
}
|
|
1
|
+
/** @module Interface wasi:io/poll@0.2.3 **/
|
|
2
|
+
/**
|
|
3
|
+
* Poll for completion on a set of pollables.
|
|
4
|
+
*
|
|
5
|
+
* This function takes a list of pollables, which identify I/O sources of
|
|
6
|
+
* interest, and waits until one or more of the events is ready for I/O.
|
|
7
|
+
*
|
|
8
|
+
* The result `list<u32>` contains one or more indices of handles in the
|
|
9
|
+
* argument list that is ready for I/O.
|
|
10
|
+
*
|
|
11
|
+
* This function traps if either:
|
|
12
|
+
* - the list is empty, or:
|
|
13
|
+
* - the list contains more elements than can be indexed with a `u32` value.
|
|
14
|
+
*
|
|
15
|
+
* A timeout can be implemented by adding a pollable from the
|
|
16
|
+
* wasi-clocks API to the list.
|
|
17
|
+
*
|
|
18
|
+
* This function does not return a `result`; polling in itself does not
|
|
19
|
+
* do any I/O so it doesn't fail. If any of the I/O sources identified by
|
|
20
|
+
* the pollables has an error, it is indicated by marking the source as
|
|
21
|
+
* being ready for I/O.
|
|
22
|
+
*/
|
|
23
|
+
export function poll(in_: Array<Pollable>): Uint32Array;
|
|
26
24
|
|
|
27
25
|
export class Pollable {
|
|
26
|
+
/**
|
|
27
|
+
* This type does not have a public constructor.
|
|
28
|
+
*/
|
|
29
|
+
private constructor();
|
|
28
30
|
/**
|
|
29
31
|
* Return the readiness of a pollable. This function never blocks.
|
|
30
32
|
*
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
import type { Error } from './wasi-io-error.js';
|
|
6
|
-
export { Error };
|
|
7
|
-
import type { Pollable } from './wasi-io-poll.js';
|
|
8
|
-
export { Pollable };
|
|
1
|
+
/** @module Interface wasi:io/streams@0.2.3 **/
|
|
2
|
+
export type Error = import('./wasi-io-error.js').Error;
|
|
3
|
+
export type Pollable = import('./wasi-io-poll.js').Pollable;
|
|
9
4
|
/**
|
|
10
5
|
* An error for input-stream and output-stream operations.
|
|
11
6
|
*/
|
|
@@ -32,6 +27,10 @@ export interface StreamErrorClosed {
|
|
|
32
27
|
}
|
|
33
28
|
|
|
34
29
|
export class InputStream {
|
|
30
|
+
/**
|
|
31
|
+
* This type does not have a public constructor.
|
|
32
|
+
*/
|
|
33
|
+
private constructor();
|
|
35
34
|
/**
|
|
36
35
|
* Perform a non-blocking read from the stream.
|
|
37
36
|
*
|
|
@@ -90,6 +89,10 @@ export class InputStream {
|
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
export class OutputStream {
|
|
92
|
+
/**
|
|
93
|
+
* This type does not have a public constructor.
|
|
94
|
+
*/
|
|
95
|
+
private constructor();
|
|
93
96
|
/**
|
|
94
97
|
* Check readiness for writing. This function never blocks.
|
|
95
98
|
*
|
|
@@ -129,13 +132,13 @@ export class OutputStream {
|
|
|
129
132
|
* ```text
|
|
130
133
|
* let pollable = this.subscribe();
|
|
131
134
|
* while !contents.is_empty() {
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
135
|
+
* // Wait for the stream to become writable
|
|
136
|
+
* pollable.block();
|
|
137
|
+
* let Ok(n) = this.check-write(); // eliding error handling
|
|
138
|
+
* let len = min(n, contents.len());
|
|
139
|
+
* let (chunk, rest) = contents.split_at(len);
|
|
140
|
+
* this.write(chunk ); // eliding error handling
|
|
141
|
+
* contents = rest;
|
|
139
142
|
* }
|
|
140
143
|
* this.flush();
|
|
141
144
|
* // Wait for completion of `flush`
|
|
@@ -197,12 +200,12 @@ export class OutputStream {
|
|
|
197
200
|
* ```text
|
|
198
201
|
* let pollable = this.subscribe();
|
|
199
202
|
* while num_zeroes != 0 {
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
203
|
+
* // Wait for the stream to become writable
|
|
204
|
+
* pollable.block();
|
|
205
|
+
* let Ok(n) = this.check-write(); // eliding error handling
|
|
206
|
+
* let len = min(n, num_zeroes);
|
|
207
|
+
* this.write-zeroes(len); // eliding error handling
|
|
208
|
+
* num_zeroes -= len;
|
|
206
209
|
* }
|
|
207
210
|
* this.flush();
|
|
208
211
|
* // Wait for completion of `flush`
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
1
|
+
/** @module Interface wasi:random/insecure-seed@0.2.3 **/
|
|
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];
|