@bytecodealliance/preview2-shim 0.0.14 → 0.0.16
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/http.js +1 -1
- package/lib/browser/io.js +14 -3
- package/lib/http/error.js +1 -1
- package/lib/http/make-request.js +2 -2
- package/lib/http/wasi-http.js +62 -39
- package/lib/nodejs/io.js +16 -5
- package/package.json +1 -1
- package/types/{exports → interfaces}/wasi-cli-environment.d.ts +1 -1
- package/types/{imports → interfaces}/wasi-cli-stderr.d.ts +1 -1
- package/types/{exports → interfaces}/wasi-cli-stdin.d.ts +1 -1
- package/types/{imports → interfaces}/wasi-cli-stdout.d.ts +1 -1
- package/types/{imports → interfaces}/wasi-cli-terminal-stderr.d.ts +2 -2
- package/types/{imports → interfaces}/wasi-cli-terminal-stdin.d.ts +2 -2
- package/types/{imports → interfaces}/wasi-cli-terminal-stdout.d.ts +2 -2
- package/types/{imports → interfaces}/wasi-clocks-monotonic-clock.d.ts +1 -1
- package/types/{exports → interfaces}/wasi-clocks-timezone.d.ts +1 -1
- package/types/{exports → interfaces}/wasi-filesystem-preopens.d.ts +1 -1
- package/types/{imports → interfaces}/wasi-filesystem-types.d.ts +5 -5
- package/types/interfaces/wasi-io-streams.d.ts +274 -0
- package/types/{imports → interfaces}/wasi-sockets-instance-network.d.ts +1 -1
- package/types/{exports → interfaces}/wasi-sockets-ip-name-lookup.d.ts +7 -7
- package/types/{imports → interfaces}/wasi-sockets-tcp-create-socket.d.ts +4 -4
- package/types/{imports → interfaces}/wasi-sockets-tcp.d.ts +20 -7
- package/types/{exports → interfaces}/wasi-sockets-udp-create-socket.d.ts +4 -4
- package/types/{exports → interfaces}/wasi-sockets-udp.d.ts +5 -5
- package/types/wasi-cli-command.d.ts +28 -28
- package/types/exports/wasi-cli-stderr.d.ts +0 -5
- package/types/exports/wasi-cli-stdout.d.ts +0 -5
- package/types/exports/wasi-cli-terminal-stderr.d.ts +0 -9
- package/types/exports/wasi-cli-terminal-stdin.d.ts +0 -9
- package/types/exports/wasi-cli-terminal-stdout.d.ts +0 -9
- package/types/exports/wasi-clocks-monotonic-clock.d.ts +0 -24
- package/types/exports/wasi-filesystem-types.d.ts +0 -843
- package/types/exports/wasi-http-incoming-handler.d.ts +0 -7
- package/types/exports/wasi-http-outgoing-handler.d.ts +0 -9
- package/types/exports/wasi-http-types.d.ts +0 -118
- package/types/exports/wasi-io-streams.d.ts +0 -220
- package/types/exports/wasi-sockets-instance-network.d.ts +0 -8
- package/types/exports/wasi-sockets-tcp-create-socket.d.ts +0 -33
- package/types/exports/wasi-sockets-tcp.d.ts +0 -285
- package/types/imports/wasi-cli-environment.d.ts +0 -22
- package/types/imports/wasi-cli-exit.d.ts +0 -7
- package/types/imports/wasi-cli-stdin.d.ts +0 -5
- package/types/imports/wasi-cli-terminal-input.d.ts +0 -13
- package/types/imports/wasi-cli-terminal-output.d.ts +0 -13
- package/types/imports/wasi-clocks-timezone.d.ts +0 -71
- package/types/imports/wasi-clocks-wall-clock.d.ts +0 -31
- package/types/imports/wasi-filesystem-preopens.d.ts +0 -8
- package/types/imports/wasi-http-outgoing-handler.d.ts +0 -9
- package/types/imports/wasi-http-types.d.ts +0 -118
- package/types/imports/wasi-io-streams.d.ts +0 -220
- package/types/imports/wasi-poll-poll.d.ts +0 -39
- package/types/imports/wasi-random-insecure-seed.d.ts +0 -22
- package/types/imports/wasi-random-insecure.d.ts +0 -20
- package/types/imports/wasi-random-random.d.ts +0 -22
- package/types/imports/wasi-sockets-ip-name-lookup.d.ts +0 -76
- package/types/imports/wasi-sockets-network.d.ts +0 -180
- package/types/imports/wasi-sockets-udp-create-socket.d.ts +0 -33
- package/types/imports/wasi-sockets-udp.d.ts +0 -228
- package/types/wasi-http-proxy.d.ts +0 -13
- /package/types/{exports → interfaces}/wasi-cli-exit.d.ts +0 -0
- /package/types/{exports → interfaces}/wasi-cli-run.d.ts +0 -0
- /package/types/{exports → interfaces}/wasi-cli-terminal-input.d.ts +0 -0
- /package/types/{exports → interfaces}/wasi-cli-terminal-output.d.ts +0 -0
- /package/types/{exports → interfaces}/wasi-clocks-wall-clock.d.ts +0 -0
- /package/types/{exports → interfaces}/wasi-poll-poll.d.ts +0 -0
- /package/types/{exports → interfaces}/wasi-random-insecure-seed.d.ts +0 -0
- /package/types/{exports → interfaces}/wasi-random-insecure.d.ts +0 -0
- /package/types/{exports → interfaces}/wasi-random-random.d.ts +0 -0
- /package/types/{exports → interfaces}/wasi-sockets-network.d.ts +0 -0
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export namespace WasiHttpIncomingHandler {
|
|
2
|
-
export function handle(request: IncomingRequest, responseOut: ResponseOutparam): void;
|
|
3
|
-
}
|
|
4
|
-
import type { IncomingRequest } from '../exports/wasi-http-types';
|
|
5
|
-
export { IncomingRequest };
|
|
6
|
-
import type { ResponseOutparam } from '../exports/wasi-http-types';
|
|
7
|
-
export { ResponseOutparam };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export namespace WasiHttpOutgoingHandler {
|
|
2
|
-
export function handle(request: OutgoingRequest, options: RequestOptions | null): FutureIncomingResponse;
|
|
3
|
-
}
|
|
4
|
-
import type { OutgoingRequest } from '../exports/wasi-http-types';
|
|
5
|
-
export { OutgoingRequest };
|
|
6
|
-
import type { RequestOptions } from '../exports/wasi-http-types';
|
|
7
|
-
export { RequestOptions };
|
|
8
|
-
import type { FutureIncomingResponse } from '../exports/wasi-http-types';
|
|
9
|
-
export { FutureIncomingResponse };
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
export namespace WasiHttpTypes {
|
|
2
|
-
export function dropFields(fields: Fields): void;
|
|
3
|
-
export function newFields(entries: [string, string][]): Fields;
|
|
4
|
-
export function fieldsGet(fields: Fields, name: string): Uint8Array[];
|
|
5
|
-
export function fieldsSet(fields: Fields, name: string, value: Uint8Array | ArrayBuffer[]): void;
|
|
6
|
-
export function fieldsDelete(fields: Fields, name: string): void;
|
|
7
|
-
export function fieldsAppend(fields: Fields, name: string, value: Uint8Array | ArrayBuffer): void;
|
|
8
|
-
export function fieldsEntries(fields: Fields): [string, Uint8Array][];
|
|
9
|
-
export function fieldsClone(fields: Fields): Fields;
|
|
10
|
-
export function finishIncomingStream(s: IncomingStream): Trailers | null;
|
|
11
|
-
export function finishOutgoingStream(s: OutgoingStream, trailers: Trailers | null): void;
|
|
12
|
-
export function dropIncomingRequest(request: IncomingRequest): void;
|
|
13
|
-
export function dropOutgoingRequest(request: OutgoingRequest): void;
|
|
14
|
-
export function incomingRequestMethod(request: IncomingRequest): Method;
|
|
15
|
-
export function incomingRequestPathWithQuery(request: IncomingRequest): string | null;
|
|
16
|
-
export function incomingRequestScheme(request: IncomingRequest): Scheme | null;
|
|
17
|
-
export function incomingRequestAuthority(request: IncomingRequest): string | null;
|
|
18
|
-
export function incomingRequestHeaders(request: IncomingRequest): Headers;
|
|
19
|
-
export function incomingRequestConsume(request: IncomingRequest): IncomingStream;
|
|
20
|
-
export function newOutgoingRequest(method: Method, pathWithQuery: string | null, scheme: Scheme | null, authority: string | null, headers: Headers): OutgoingRequest;
|
|
21
|
-
export function outgoingRequestWrite(request: OutgoingRequest): OutgoingStream;
|
|
22
|
-
export function dropResponseOutparam(response: ResponseOutparam): void;
|
|
23
|
-
export function setResponseOutparam(param: ResponseOutparam, response: Result<OutgoingResponse, Error>): void;
|
|
24
|
-
export function dropIncomingResponse(response: IncomingResponse): void;
|
|
25
|
-
export function dropOutgoingResponse(response: OutgoingResponse): void;
|
|
26
|
-
export function incomingResponseStatus(response: IncomingResponse): StatusCode;
|
|
27
|
-
export function incomingResponseHeaders(response: IncomingResponse): Headers;
|
|
28
|
-
export function incomingResponseConsume(response: IncomingResponse): IncomingStream;
|
|
29
|
-
export function newOutgoingResponse(statusCode: StatusCode, headers: Headers): OutgoingResponse;
|
|
30
|
-
export function outgoingResponseWrite(response: OutgoingResponse): OutgoingStream;
|
|
31
|
-
export function dropFutureIncomingResponse(f: FutureIncomingResponse): void;
|
|
32
|
-
export function futureIncomingResponseGet(f: FutureIncomingResponse): Result<IncomingResponse, Error> | null;
|
|
33
|
-
export function listenToFutureIncomingResponse(f: FutureIncomingResponse): Pollable;
|
|
34
|
-
}
|
|
35
|
-
import type { InputStream } from '../exports/wasi-io-streams';
|
|
36
|
-
export { InputStream };
|
|
37
|
-
import type { OutputStream } from '../exports/wasi-io-streams';
|
|
38
|
-
export { OutputStream };
|
|
39
|
-
import type { Pollable } from '../exports/wasi-poll-poll';
|
|
40
|
-
export { Pollable };
|
|
41
|
-
export type Method = MethodGet | MethodHead | MethodPost | MethodPut | MethodDelete | MethodConnect | MethodOptions | MethodTrace | MethodPatch | MethodOther;
|
|
42
|
-
export interface MethodGet {
|
|
43
|
-
tag: 'get',
|
|
44
|
-
}
|
|
45
|
-
export interface MethodHead {
|
|
46
|
-
tag: 'head',
|
|
47
|
-
}
|
|
48
|
-
export interface MethodPost {
|
|
49
|
-
tag: 'post',
|
|
50
|
-
}
|
|
51
|
-
export interface MethodPut {
|
|
52
|
-
tag: 'put',
|
|
53
|
-
}
|
|
54
|
-
export interface MethodDelete {
|
|
55
|
-
tag: 'delete',
|
|
56
|
-
}
|
|
57
|
-
export interface MethodConnect {
|
|
58
|
-
tag: 'connect',
|
|
59
|
-
}
|
|
60
|
-
export interface MethodOptions {
|
|
61
|
-
tag: 'options',
|
|
62
|
-
}
|
|
63
|
-
export interface MethodTrace {
|
|
64
|
-
tag: 'trace',
|
|
65
|
-
}
|
|
66
|
-
export interface MethodPatch {
|
|
67
|
-
tag: 'patch',
|
|
68
|
-
}
|
|
69
|
-
export interface MethodOther {
|
|
70
|
-
tag: 'other',
|
|
71
|
-
val: string,
|
|
72
|
-
}
|
|
73
|
-
export type Scheme = SchemeHttp | SchemeHttps | SchemeOther;
|
|
74
|
-
export interface SchemeHttp {
|
|
75
|
-
tag: 'HTTP',
|
|
76
|
-
}
|
|
77
|
-
export interface SchemeHttps {
|
|
78
|
-
tag: 'HTTPS',
|
|
79
|
-
}
|
|
80
|
-
export interface SchemeOther {
|
|
81
|
-
tag: 'other',
|
|
82
|
-
val: string,
|
|
83
|
-
}
|
|
84
|
-
export type Error = ErrorInvalidUrl | ErrorTimeoutError | ErrorProtocolError | ErrorUnexpectedError;
|
|
85
|
-
export interface ErrorInvalidUrl {
|
|
86
|
-
tag: 'invalid-url',
|
|
87
|
-
val: string,
|
|
88
|
-
}
|
|
89
|
-
export interface ErrorTimeoutError {
|
|
90
|
-
tag: 'timeout-error',
|
|
91
|
-
val: string,
|
|
92
|
-
}
|
|
93
|
-
export interface ErrorProtocolError {
|
|
94
|
-
tag: 'protocol-error',
|
|
95
|
-
val: string,
|
|
96
|
-
}
|
|
97
|
-
export interface ErrorUnexpectedError {
|
|
98
|
-
tag: 'unexpected-error',
|
|
99
|
-
val: string,
|
|
100
|
-
}
|
|
101
|
-
export type Fields = number;
|
|
102
|
-
export type Headers = Fields;
|
|
103
|
-
export type Trailers = Fields;
|
|
104
|
-
export type IncomingStream = InputStream;
|
|
105
|
-
export type OutgoingStream = OutputStream;
|
|
106
|
-
export type IncomingRequest = number;
|
|
107
|
-
export type OutgoingRequest = number;
|
|
108
|
-
export interface RequestOptions {
|
|
109
|
-
connectTimeoutMs?: number,
|
|
110
|
-
firstByteTimeoutMs?: number,
|
|
111
|
-
betweenBytesTimeoutMs?: number,
|
|
112
|
-
}
|
|
113
|
-
export type ResponseOutparam = number;
|
|
114
|
-
export type StatusCode = number;
|
|
115
|
-
export type IncomingResponse = number;
|
|
116
|
-
export type OutgoingResponse = number;
|
|
117
|
-
export type FutureIncomingResponse = number;
|
|
118
|
-
export type Result<T, E> = { tag: 'ok', val: T } | { tag: 'err', val: E };
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
export namespace WasiIoStreams {
|
|
2
|
-
/**
|
|
3
|
-
* Perform a non-blocking read from the stream.
|
|
4
|
-
*
|
|
5
|
-
* This function returns a list of bytes containing the data that was
|
|
6
|
-
* read, along with a `stream-status` which, indicates whether further
|
|
7
|
-
* reads are expected to produce data. The returned list will contain up to
|
|
8
|
-
* `len` bytes; it may return fewer than requested, but not more. An
|
|
9
|
-
* empty list and `stream-status:open` indicates no more data is
|
|
10
|
-
* available at this time, and that the pollable given by
|
|
11
|
-
* `subscribe-to-input-stream` will be ready when more data is available.
|
|
12
|
-
*
|
|
13
|
-
* Once a stream has reached the end, subsequent calls to `read` or
|
|
14
|
-
* `skip` will always report `stream-status:ended` rather than producing more
|
|
15
|
-
* data.
|
|
16
|
-
*
|
|
17
|
-
* When the caller gives a `len` of 0, it represents a request to read 0
|
|
18
|
-
* bytes. This read should always succeed and return an empty list and
|
|
19
|
-
* the current `stream-status`.
|
|
20
|
-
*
|
|
21
|
-
* The `len` parameter is a `u64`, which could represent a list of u8 which
|
|
22
|
-
* is not possible to allocate in wasm32, or not desirable to allocate as
|
|
23
|
-
* as a return value by the callee. The callee may return a list of bytes
|
|
24
|
-
* less than `len` in size while more bytes are available for reading.
|
|
25
|
-
*/
|
|
26
|
-
export function read(this_: InputStream, len: bigint): [Uint8Array, StreamStatus];
|
|
27
|
-
/**
|
|
28
|
-
* Read bytes from a stream, after blocking until at least one byte can
|
|
29
|
-
* be read. Except for blocking, identical to `read`.
|
|
30
|
-
*/
|
|
31
|
-
export function blockingRead(this_: InputStream, len: bigint): [Uint8Array, StreamStatus];
|
|
32
|
-
/**
|
|
33
|
-
* Skip bytes from a stream.
|
|
34
|
-
*
|
|
35
|
-
* This is similar to the `read` function, but avoids copying the
|
|
36
|
-
* bytes into the instance.
|
|
37
|
-
*
|
|
38
|
-
* Once a stream has reached the end, subsequent calls to read or
|
|
39
|
-
* `skip` will always report end-of-stream rather than producing more
|
|
40
|
-
* data.
|
|
41
|
-
*
|
|
42
|
-
* This function returns the number of bytes skipped, along with a
|
|
43
|
-
* `stream-status` indicating whether the end of the stream was
|
|
44
|
-
* reached. The returned value will be at most `len`; it may be less.
|
|
45
|
-
*/
|
|
46
|
-
export function skip(this_: InputStream, len: bigint): [bigint, StreamStatus];
|
|
47
|
-
/**
|
|
48
|
-
* Skip bytes from a stream, after blocking until at least one byte
|
|
49
|
-
* can be skipped. Except for blocking behavior, identical to `skip`.
|
|
50
|
-
*/
|
|
51
|
-
export function blockingSkip(this_: InputStream, len: bigint): [bigint, StreamStatus];
|
|
52
|
-
/**
|
|
53
|
-
* Create a `pollable` which will resolve once either the specified stream
|
|
54
|
-
* has bytes available to read or the other end of the stream has been
|
|
55
|
-
* closed.
|
|
56
|
-
* The created `pollable` is a child resource of the `input-stream`.
|
|
57
|
-
* Implementations may trap if the `input-stream` is dropped before
|
|
58
|
-
* all derived `pollable`s created with this function are dropped.
|
|
59
|
-
*/
|
|
60
|
-
export function subscribeToInputStream(this_: InputStream): Pollable;
|
|
61
|
-
/**
|
|
62
|
-
* Dispose of the specified `input-stream`, after which it may no longer
|
|
63
|
-
* be used.
|
|
64
|
-
* Implementations may trap if this `input-stream` is dropped while child
|
|
65
|
-
* `pollable` resources are still alive.
|
|
66
|
-
* After this `input-stream` is dropped, implementations may report any
|
|
67
|
-
* corresponding `output-stream` has `stream-state.closed`.
|
|
68
|
-
*/
|
|
69
|
-
export function dropInputStream(this_: InputStream): void;
|
|
70
|
-
/**
|
|
71
|
-
* Perform a non-blocking write of bytes to a stream.
|
|
72
|
-
*
|
|
73
|
-
* This function returns a `u64` and a `stream-status`. The `u64` indicates
|
|
74
|
-
* the number of bytes from `buf` that were written, which may be less than
|
|
75
|
-
* the length of `buf`. The `stream-status` indicates if further writes to
|
|
76
|
-
* the stream are expected to be read.
|
|
77
|
-
*
|
|
78
|
-
* When the returned `stream-status` is `open`, the `u64` return value may
|
|
79
|
-
* be less than the length of `buf`. This indicates that no more bytes may
|
|
80
|
-
* be written to the stream promptly. In that case the
|
|
81
|
-
* `subscribe-to-output-stream` pollable will indicate when additional bytes
|
|
82
|
-
* may be promptly written.
|
|
83
|
-
*
|
|
84
|
-
* Writing an empty list must return a non-error result with `0` for the
|
|
85
|
-
* `u64` return value, and the current `stream-status`.
|
|
86
|
-
*/
|
|
87
|
-
export function write(this_: OutputStream, buf: Uint8Array | ArrayBuffer): [bigint, StreamStatus];
|
|
88
|
-
/**
|
|
89
|
-
* Blocking write of bytes to a stream.
|
|
90
|
-
*
|
|
91
|
-
* This is similar to `write`, except that it blocks until at least one
|
|
92
|
-
* byte can be written.
|
|
93
|
-
*/
|
|
94
|
-
export function blockingWrite(this_: OutputStream, buf: Uint8Array | ArrayBuffer): [bigint, StreamStatus];
|
|
95
|
-
/**
|
|
96
|
-
* Write multiple zero-bytes to a stream.
|
|
97
|
-
*
|
|
98
|
-
* This function returns a `u64` indicating the number of zero-bytes
|
|
99
|
-
* that were written; it may be less than `len`. Equivelant to a call to
|
|
100
|
-
* `write` with a list of zeroes of the given length.
|
|
101
|
-
*/
|
|
102
|
-
export function writeZeroes(this_: OutputStream, len: bigint): [bigint, StreamStatus];
|
|
103
|
-
/**
|
|
104
|
-
* Write multiple zero bytes to a stream, with blocking.
|
|
105
|
-
*
|
|
106
|
-
* This is similar to `write-zeroes`, except that it blocks until at least
|
|
107
|
-
* one byte can be written. Equivelant to a call to `blocking-write` with
|
|
108
|
-
* a list of zeroes of the given length.
|
|
109
|
-
*/
|
|
110
|
-
export function blockingWriteZeroes(this_: OutputStream, len: bigint): [bigint, StreamStatus];
|
|
111
|
-
/**
|
|
112
|
-
* Read from one stream and write to another.
|
|
113
|
-
*
|
|
114
|
-
* This function returns the number of bytes transferred; it may be less
|
|
115
|
-
* than `len`.
|
|
116
|
-
*
|
|
117
|
-
* Unlike other I/O functions, this function blocks until all the data
|
|
118
|
-
* read from the input stream has been written to the output stream.
|
|
119
|
-
*/
|
|
120
|
-
export function splice(this_: OutputStream, src: InputStream, len: bigint): [bigint, StreamStatus];
|
|
121
|
-
/**
|
|
122
|
-
* Read from one stream and write to another, with blocking.
|
|
123
|
-
*
|
|
124
|
-
* This is similar to `splice`, except that it blocks until at least
|
|
125
|
-
* one byte can be read.
|
|
126
|
-
*/
|
|
127
|
-
export function blockingSplice(this_: OutputStream, src: InputStream, len: bigint): [bigint, StreamStatus];
|
|
128
|
-
/**
|
|
129
|
-
* Forward the entire contents of an input stream to an output stream.
|
|
130
|
-
*
|
|
131
|
-
* This function repeatedly reads from the input stream and writes
|
|
132
|
-
* the data to the output stream, until the end of the input stream
|
|
133
|
-
* is reached, or an error is encountered.
|
|
134
|
-
*
|
|
135
|
-
* Unlike other I/O functions, this function blocks until the end
|
|
136
|
-
* of the input stream is seen and all the data has been written to
|
|
137
|
-
* the output stream.
|
|
138
|
-
*
|
|
139
|
-
* This function returns the number of bytes transferred, and the status of
|
|
140
|
-
* the output stream.
|
|
141
|
-
*/
|
|
142
|
-
export function forward(this_: OutputStream, src: InputStream): [bigint, StreamStatus];
|
|
143
|
-
/**
|
|
144
|
-
* Create a `pollable` which will resolve once either the specified stream
|
|
145
|
-
* is ready to accept bytes or the `stream-state` has become closed.
|
|
146
|
-
*
|
|
147
|
-
* Once the stream-state is closed, this pollable is always ready
|
|
148
|
-
* immediately.
|
|
149
|
-
*
|
|
150
|
-
* The created `pollable` is a child resource of the `output-stream`.
|
|
151
|
-
* Implementations may trap if the `output-stream` is dropped before
|
|
152
|
-
* all derived `pollable`s created with this function are dropped.
|
|
153
|
-
*/
|
|
154
|
-
export function subscribeToOutputStream(this_: OutputStream): Pollable;
|
|
155
|
-
/**
|
|
156
|
-
* Dispose of the specified `output-stream`, after which it may no longer
|
|
157
|
-
* be used.
|
|
158
|
-
* Implementations may trap if this `output-stream` is dropped while
|
|
159
|
-
* child `pollable` resources are still alive.
|
|
160
|
-
* After this `output-stream` is dropped, implementations may report any
|
|
161
|
-
* corresponding `input-stream` has `stream-state.closed`.
|
|
162
|
-
*/
|
|
163
|
-
export function dropOutputStream(this_: OutputStream): void;
|
|
164
|
-
}
|
|
165
|
-
import type { Pollable } from '../exports/wasi-poll-poll';
|
|
166
|
-
export { Pollable };
|
|
167
|
-
/**
|
|
168
|
-
* Streams provide a sequence of data and then end; once they end, they
|
|
169
|
-
* no longer provide any further data.
|
|
170
|
-
*
|
|
171
|
-
* For example, a stream reading from a file ends when the stream reaches
|
|
172
|
-
* the end of the file. For another example, a stream reading from a
|
|
173
|
-
* socket ends when the socket is closed.
|
|
174
|
-
* # Variants
|
|
175
|
-
*
|
|
176
|
-
* ## `"open"`
|
|
177
|
-
*
|
|
178
|
-
* The stream is open and may produce further data.
|
|
179
|
-
* ## `"ended"`
|
|
180
|
-
*
|
|
181
|
-
* When reading, this indicates that the stream will not produce
|
|
182
|
-
* further data.
|
|
183
|
-
* When writing, this indicates that the stream will no longer be read.
|
|
184
|
-
* Further writes are still permitted.
|
|
185
|
-
*/
|
|
186
|
-
export type StreamStatus = 'open' | 'ended';
|
|
187
|
-
/**
|
|
188
|
-
* An input bytestream. In the future, this will be replaced by handle
|
|
189
|
-
* types.
|
|
190
|
-
*
|
|
191
|
-
* `input-stream`s are *non-blocking* to the extent practical on underlying
|
|
192
|
-
* platforms. I/O operations always return promptly; if fewer bytes are
|
|
193
|
-
* promptly available than requested, they return the number of bytes promptly
|
|
194
|
-
* available, which could even be zero. To wait for data to be available,
|
|
195
|
-
* use the `subscribe-to-input-stream` function to obtain a `pollable` which
|
|
196
|
-
* can be polled for using `wasi:poll/poll.poll_oneoff`.
|
|
197
|
-
*
|
|
198
|
-
* And at present, it is a `u32` instead of being an actual handle, until
|
|
199
|
-
* the wit-bindgen implementation of handles and resources is ready.
|
|
200
|
-
*
|
|
201
|
-
* This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources).
|
|
202
|
-
*/
|
|
203
|
-
export type InputStream = number;
|
|
204
|
-
/**
|
|
205
|
-
* An output bytestream. In the future, this will be replaced by handle
|
|
206
|
-
* types.
|
|
207
|
-
*
|
|
208
|
-
* `output-stream`s are *non-blocking* to the extent practical on
|
|
209
|
-
* underlying platforms. Except where specified otherwise, I/O operations also
|
|
210
|
-
* always return promptly, after the number of bytes that can be written
|
|
211
|
-
* promptly, which could even be zero. To wait for the stream to be ready to
|
|
212
|
-
* accept data, the `subscribe-to-output-stream` function to obtain a
|
|
213
|
-
* `pollable` which can be polled for using `wasi:poll`.
|
|
214
|
-
*
|
|
215
|
-
* And at present, it is a `u32` instead of being an actual handle, until
|
|
216
|
-
* the wit-bindgen implementation of handles and resources is ready.
|
|
217
|
-
*
|
|
218
|
-
* This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources).
|
|
219
|
-
*/
|
|
220
|
-
export type OutputStream = number;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export namespace WasiSocketsTcpCreateSocket {
|
|
2
|
-
/**
|
|
3
|
-
* Create a new TCP socket.
|
|
4
|
-
*
|
|
5
|
-
* Similar to `socket(AF_INET or AF_INET6, SOCK_STREAM, IPPROTO_TCP)` in POSIX.
|
|
6
|
-
*
|
|
7
|
-
* This function does not require a network capability handle. This is considered to be safe because
|
|
8
|
-
* at time of creation, the socket is not bound to any `network` yet. Up to the moment `bind`/`listen`/`connect`
|
|
9
|
-
* is called, the socket is effectively an in-memory configuration object, unable to communicate with the outside world.
|
|
10
|
-
*
|
|
11
|
-
* All sockets are non-blocking. Use the wasi-poll interface to block on asynchronous operations.
|
|
12
|
-
*
|
|
13
|
-
* # Typical errors
|
|
14
|
-
* - `not-supported`: The host does not support TCP sockets. (EOPNOTSUPP)
|
|
15
|
-
* - `address-family-not-supported`: The specified `address-family` is not supported. (EAFNOSUPPORT)
|
|
16
|
-
* - `new-socket-limit`: The new socket resource could not be created because of a system limit. (EMFILE, ENFILE)
|
|
17
|
-
*
|
|
18
|
-
* # References
|
|
19
|
-
* - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/socket.html>
|
|
20
|
-
* - <https://man7.org/linux/man-pages/man2/socket.2.html>
|
|
21
|
-
* - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasocketw>
|
|
22
|
-
* - <https://man.freebsd.org/cgi/man.cgi?query=socket&sektion=2>
|
|
23
|
-
*/
|
|
24
|
-
export function createTcpSocket(addressFamily: IpAddressFamily): TcpSocket;
|
|
25
|
-
}
|
|
26
|
-
import type { Network } from '../exports/wasi-sockets-network';
|
|
27
|
-
export { Network };
|
|
28
|
-
import type { ErrorCode } from '../exports/wasi-sockets-network';
|
|
29
|
-
export { ErrorCode };
|
|
30
|
-
import type { IpAddressFamily } from '../exports/wasi-sockets-network';
|
|
31
|
-
export { IpAddressFamily };
|
|
32
|
-
import type { TcpSocket } from '../exports/wasi-sockets-tcp';
|
|
33
|
-
export { TcpSocket };
|