@bytecodealliance/preview2-shim 0.17.0 → 0.17.2
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 +7 -4
- package/lib/io/worker-socket-tcp.js +2 -2
- package/lib/io/worker-thread.js +66 -13
- package/lib/nodejs/cli.js +3 -0
- package/lib/nodejs/filesystem.js +5 -7
- package/package.json +1 -1
- 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 +7 -15
- 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 -39
- 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 +94 -66
- 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 +27 -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 +33 -35
- 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 +18 -24
- package/types/interfaces/wasi-sockets-udp-create-socket.d.ts +28 -33
- package/types/interfaces/wasi-sockets-udp.d.ts +23 -20
- 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,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
|
/**
|
|
@@ -569,12 +566,6 @@ export class Descriptor {
|
|
|
569
566
|
/**
|
|
570
567
|
* Open a file or directory.
|
|
571
568
|
*
|
|
572
|
-
* The returned descriptor is not guaranteed to be the lowest-numbered
|
|
573
|
-
* descriptor not currently open/ it is randomized to prevent applications
|
|
574
|
-
* from depending on making assumptions about indexes, since this is
|
|
575
|
-
* error-prone in multi-threaded contexts. The returned descriptor is
|
|
576
|
-
* guaranteed to be less than 2**31.
|
|
577
|
-
*
|
|
578
569
|
* If `flags` contains `descriptor-flags::mutate-directory`, and the base
|
|
579
570
|
* descriptor doesn't have `descriptor-flags::mutate-directory` set,
|
|
580
571
|
* `open-at` fails with `error-code::read-only`.
|
|
@@ -645,14 +636,14 @@ export class Descriptor {
|
|
|
645
636
|
* replaced. It may also include a secret value chosen by the
|
|
646
637
|
* implementation and not otherwise exposed.
|
|
647
638
|
*
|
|
648
|
-
* Implementations are
|
|
639
|
+
* Implementations are encouraged to provide the following properties:
|
|
649
640
|
*
|
|
650
|
-
*
|
|
651
|
-
*
|
|
652
|
-
*
|
|
653
|
-
*
|
|
654
|
-
*
|
|
655
|
-
*
|
|
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.
|
|
656
647
|
*
|
|
657
648
|
* However, none of these is required.
|
|
658
649
|
*/
|
|
@@ -667,6 +658,10 @@ export class Descriptor {
|
|
|
667
658
|
}
|
|
668
659
|
|
|
669
660
|
export class DirectoryEntryStream {
|
|
661
|
+
/**
|
|
662
|
+
* This type does not have a public constructor.
|
|
663
|
+
*/
|
|
664
|
+
private constructor();
|
|
670
665
|
/**
|
|
671
666
|
* Read a single directory entry from a `directory-entry-stream`.
|
|
672
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 {
|
|
@@ -255,7 +238,7 @@ export interface ErrorCodeInternalError {
|
|
|
255
238
|
*/
|
|
256
239
|
export type HeaderError = HeaderErrorInvalidSyntax | HeaderErrorForbidden | HeaderErrorImmutable;
|
|
257
240
|
/**
|
|
258
|
-
* This error indicates that a `field-
|
|
241
|
+
* This error indicates that a `field-name` or `field-value` was
|
|
259
242
|
* syntactically invalid when used with an operation that sets headers in a
|
|
260
243
|
* `fields`.
|
|
261
244
|
*/
|
|
@@ -263,7 +246,7 @@ export interface HeaderErrorInvalidSyntax {
|
|
|
263
246
|
tag: 'invalid-syntax',
|
|
264
247
|
}
|
|
265
248
|
/**
|
|
266
|
-
* This error indicates that a forbidden `field-
|
|
249
|
+
* This error indicates that a forbidden `field-name` was used when trying
|
|
267
250
|
* to set a header in a `fields`.
|
|
268
251
|
*/
|
|
269
252
|
export interface HeaderErrorForbidden {
|
|
@@ -278,8 +261,22 @@ export interface HeaderErrorImmutable {
|
|
|
278
261
|
}
|
|
279
262
|
/**
|
|
280
263
|
* Field keys are always strings.
|
|
264
|
+
*
|
|
265
|
+
* Field keys should always be treated as case insensitive by the `fields`
|
|
266
|
+
* resource for the purposes of equality checking.
|
|
267
|
+
*
|
|
268
|
+
* # Deprecation
|
|
269
|
+
*
|
|
270
|
+
* This type has been deprecated in favor of the `field-name` type.
|
|
281
271
|
*/
|
|
282
272
|
export type FieldKey = string;
|
|
273
|
+
/**
|
|
274
|
+
* Field names are always strings.
|
|
275
|
+
*
|
|
276
|
+
* Field names should always be treated as case insensitive by the `fields`
|
|
277
|
+
* resource for the purposes of equality checking.
|
|
278
|
+
*/
|
|
279
|
+
export type FieldName = FieldKey;
|
|
283
280
|
/**
|
|
284
281
|
* Field values should always be ASCII strings. However, in
|
|
285
282
|
* reality, HTTP implementations often have to interpret malformed values,
|
|
@@ -312,68 +309,71 @@ export class Fields {
|
|
|
312
309
|
*
|
|
313
310
|
* The resulting `fields` is mutable.
|
|
314
311
|
*
|
|
315
|
-
* The list represents each
|
|
312
|
+
* The list represents each name-value pair in the Fields. Names
|
|
316
313
|
* which have multiple values are represented by multiple entries in this
|
|
317
|
-
* list with the same
|
|
314
|
+
* list with the same name.
|
|
318
315
|
*
|
|
319
|
-
* The tuple is a pair of the field
|
|
316
|
+
* The tuple is a pair of the field name, represented as a string, and
|
|
320
317
|
* Value, represented as a list of bytes.
|
|
321
318
|
*
|
|
322
|
-
* An error result will be returned if any `field-
|
|
319
|
+
* An error result will be returned if any `field-name` or `field-value` is
|
|
323
320
|
* syntactically invalid, or if a field is forbidden.
|
|
324
321
|
*/
|
|
325
|
-
static fromList(entries: Array<[
|
|
322
|
+
static fromList(entries: Array<[FieldName, FieldValue]>): Fields;
|
|
326
323
|
/**
|
|
327
|
-
* Get all of the values corresponding to a
|
|
324
|
+
* Get all of the values corresponding to a name. If the name is not present
|
|
328
325
|
* in this `fields` or is syntactically invalid, an empty list is returned.
|
|
329
|
-
* However, if the
|
|
326
|
+
* However, if the name is present but empty, this is represented by a list
|
|
330
327
|
* with one or more empty field-values present.
|
|
331
328
|
*/
|
|
332
|
-
get(name:
|
|
329
|
+
get(name: FieldName): Array<FieldValue>;
|
|
333
330
|
/**
|
|
334
|
-
* Returns `true` when the
|
|
331
|
+
* Returns `true` when the name is present in this `fields`. If the name is
|
|
335
332
|
* syntactically invalid, `false` is returned.
|
|
336
333
|
*/
|
|
337
|
-
has(name:
|
|
334
|
+
has(name: FieldName): boolean;
|
|
338
335
|
/**
|
|
339
|
-
* Set all of the values for a
|
|
340
|
-
*
|
|
336
|
+
* Set all of the values for a name. Clears any existing values for that
|
|
337
|
+
* name, if they have been set.
|
|
341
338
|
*
|
|
342
339
|
* Fails with `header-error.immutable` if the `fields` are immutable.
|
|
343
340
|
*
|
|
344
|
-
* Fails with `header-error.invalid-syntax` if the `field-
|
|
341
|
+
* Fails with `header-error.invalid-syntax` if the `field-name` or any of
|
|
345
342
|
* the `field-value`s are syntactically invalid.
|
|
346
343
|
*/
|
|
347
|
-
set(name:
|
|
344
|
+
set(name: FieldName, value: Array<FieldValue>): void;
|
|
348
345
|
/**
|
|
349
|
-
* Delete all values for a
|
|
346
|
+
* Delete all values for a name. Does nothing if no values for the name
|
|
350
347
|
* exist.
|
|
351
348
|
*
|
|
352
349
|
* Fails with `header-error.immutable` if the `fields` are immutable.
|
|
353
350
|
*
|
|
354
|
-
* Fails with `header-error.invalid-syntax` if the `field-
|
|
351
|
+
* Fails with `header-error.invalid-syntax` if the `field-name` is
|
|
355
352
|
* syntactically invalid.
|
|
356
353
|
*/
|
|
357
|
-
'delete'(name:
|
|
354
|
+
'delete'(name: FieldName): void;
|
|
358
355
|
/**
|
|
359
|
-
* Append a value for a
|
|
360
|
-
* values for that
|
|
356
|
+
* Append a value for a name. Does not change or delete any existing
|
|
357
|
+
* values for that name.
|
|
361
358
|
*
|
|
362
359
|
* Fails with `header-error.immutable` if the `fields` are immutable.
|
|
363
360
|
*
|
|
364
|
-
* Fails with `header-error.invalid-syntax` if the `field-
|
|
361
|
+
* Fails with `header-error.invalid-syntax` if the `field-name` or
|
|
365
362
|
* `field-value` are syntactically invalid.
|
|
366
363
|
*/
|
|
367
|
-
append(name:
|
|
364
|
+
append(name: FieldName, value: FieldValue): void;
|
|
368
365
|
/**
|
|
369
|
-
* Retrieve the full set of
|
|
370
|
-
* constructor, the list represents each
|
|
366
|
+
* Retrieve the full set of names and values in the Fields. Like the
|
|
367
|
+
* constructor, the list represents each name-value pair.
|
|
371
368
|
*
|
|
372
|
-
* The outer list represents each
|
|
369
|
+
* The outer list represents each name-value pair in the Fields. Names
|
|
373
370
|
* which have multiple values are represented by multiple entries in this
|
|
374
|
-
* list with the same
|
|
371
|
+
* list with the same name.
|
|
372
|
+
*
|
|
373
|
+
* The names and values are always returned in the original casing and in
|
|
374
|
+
* the order in which they will be serialized for transport.
|
|
375
375
|
*/
|
|
376
|
-
entries(): Array<[
|
|
376
|
+
entries(): Array<[FieldName, FieldValue]>;
|
|
377
377
|
/**
|
|
378
378
|
* Make a deep copy of the Fields. Equivalent in behavior to calling the
|
|
379
379
|
* `fields` constructor on the return value of `entries`. The resulting
|
|
@@ -383,6 +383,10 @@ export class Fields {
|
|
|
383
383
|
}
|
|
384
384
|
|
|
385
385
|
export class FutureIncomingResponse {
|
|
386
|
+
/**
|
|
387
|
+
* This type does not have a public constructor.
|
|
388
|
+
*/
|
|
389
|
+
private constructor();
|
|
386
390
|
/**
|
|
387
391
|
* Returns a pollable which becomes ready when either the Response has
|
|
388
392
|
* been received, or an error has occurred. When this pollable is ready,
|
|
@@ -409,6 +413,10 @@ export class FutureIncomingResponse {
|
|
|
409
413
|
}
|
|
410
414
|
|
|
411
415
|
export class FutureTrailers {
|
|
416
|
+
/**
|
|
417
|
+
* This type does not have a public constructor.
|
|
418
|
+
*/
|
|
419
|
+
private constructor();
|
|
412
420
|
/**
|
|
413
421
|
* Returns a pollable which becomes ready when either the trailers have
|
|
414
422
|
* been received, or an error has occurred. When this pollable is ready,
|
|
@@ -440,6 +448,10 @@ export class FutureTrailers {
|
|
|
440
448
|
}
|
|
441
449
|
|
|
442
450
|
export class IncomingBody {
|
|
451
|
+
/**
|
|
452
|
+
* This type does not have a public constructor.
|
|
453
|
+
*/
|
|
454
|
+
private constructor();
|
|
443
455
|
/**
|
|
444
456
|
* Returns the contents of the body, as a stream of bytes.
|
|
445
457
|
*
|
|
@@ -466,6 +478,10 @@ export class IncomingBody {
|
|
|
466
478
|
}
|
|
467
479
|
|
|
468
480
|
export class IncomingRequest {
|
|
481
|
+
/**
|
|
482
|
+
* This type does not have a public constructor.
|
|
483
|
+
*/
|
|
484
|
+
private constructor();
|
|
469
485
|
/**
|
|
470
486
|
* Returns the method of the incoming request.
|
|
471
487
|
*/
|
|
@@ -501,6 +517,10 @@ export class IncomingRequest {
|
|
|
501
517
|
}
|
|
502
518
|
|
|
503
519
|
export class IncomingResponse {
|
|
520
|
+
/**
|
|
521
|
+
* This type does not have a public constructor.
|
|
522
|
+
*/
|
|
523
|
+
private constructor();
|
|
504
524
|
/**
|
|
505
525
|
* Returns the status code from the incoming response.
|
|
506
526
|
*/
|
|
@@ -523,6 +543,10 @@ export class IncomingResponse {
|
|
|
523
543
|
}
|
|
524
544
|
|
|
525
545
|
export class OutgoingBody {
|
|
546
|
+
/**
|
|
547
|
+
* This type does not have a public constructor.
|
|
548
|
+
*/
|
|
549
|
+
private constructor();
|
|
526
550
|
/**
|
|
527
551
|
* Returns a stream for writing the body contents.
|
|
528
552
|
*
|
|
@@ -705,6 +729,10 @@ export class RequestOptions {
|
|
|
705
729
|
}
|
|
706
730
|
|
|
707
731
|
export class ResponseOutparam {
|
|
732
|
+
/**
|
|
733
|
+
* This type does not have a public constructor.
|
|
734
|
+
*/
|
|
735
|
+
private constructor();
|
|
708
736
|
/**
|
|
709
737
|
* Set the value of the `response-outparam` to either send a response,
|
|
710
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
|
*/
|
|
@@ -14,6 +9,9 @@ export type StreamError = StreamErrorLastOperationFailed | StreamErrorClosed;
|
|
|
14
9
|
* The last operation (a write or flush) failed before completion.
|
|
15
10
|
*
|
|
16
11
|
* More information is available in the `error` payload.
|
|
12
|
+
*
|
|
13
|
+
* After this, the stream will be closed. All future operations return
|
|
14
|
+
* `stream-error::closed`.
|
|
17
15
|
*/
|
|
18
16
|
export interface StreamErrorLastOperationFailed {
|
|
19
17
|
tag: 'last-operation-failed',
|
|
@@ -29,6 +27,10 @@ export interface StreamErrorClosed {
|
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
export class InputStream {
|
|
30
|
+
/**
|
|
31
|
+
* This type does not have a public constructor.
|
|
32
|
+
*/
|
|
33
|
+
private constructor();
|
|
32
34
|
/**
|
|
33
35
|
* Perform a non-blocking read from the stream.
|
|
34
36
|
*
|
|
@@ -87,6 +89,10 @@ export class InputStream {
|
|
|
87
89
|
}
|
|
88
90
|
|
|
89
91
|
export class OutputStream {
|
|
92
|
+
/**
|
|
93
|
+
* This type does not have a public constructor.
|
|
94
|
+
*/
|
|
95
|
+
private constructor();
|
|
90
96
|
/**
|
|
91
97
|
* Check readiness for writing. This function never blocks.
|
|
92
98
|
*
|
|
@@ -126,13 +132,13 @@ export class OutputStream {
|
|
|
126
132
|
* ```text
|
|
127
133
|
* let pollable = this.subscribe();
|
|
128
134
|
* while !contents.is_empty() {
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
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;
|
|
136
142
|
* }
|
|
137
143
|
* this.flush();
|
|
138
144
|
* // Wait for completion of `flush`
|
|
@@ -194,12 +200,12 @@ export class OutputStream {
|
|
|
194
200
|
* ```text
|
|
195
201
|
* let pollable = this.subscribe();
|
|
196
202
|
* while num_zeroes != 0 {
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
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;
|
|
203
209
|
* }
|
|
204
210
|
* this.flush();
|
|
205
211
|
* // Wait for completion of `flush`
|