@wasi-gfx/js-webgpu 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/canvas.d.ts +45 -0
- package/dist/canvas.js +125 -0
- package/dist/common.d.ts +17 -0
- package/dist/common.js +33 -0
- package/dist/globals.d.ts +1 -0
- package/dist/globals.js +52 -0
- package/dist/webgpu.d.ts +380 -0
- package/dist/{index.js → webgpu.js} +243 -177
- package/package.json +26 -7
- package/types/interfaces/wasi-cli-run.d.ts +2 -2
- package/types/interfaces/wasi-cli-stdout.d.ts +14 -3
- package/types/interfaces/wasi-cli-types.d.ts +15 -0
- package/types/interfaces/wasi-gfx-frame-buffer-frame-buffer.d.ts +13 -0
- package/types/interfaces/wasi-gfx-surface-surface-frame-buffer.d.ts +12 -0
- package/types/interfaces/wasi-gfx-surface-surface-webgpu.d.ts +29 -0
- package/types/interfaces/{wasi-surface-surface.d.ts → wasi-gfx-surface-surface.d.ts} +8 -18
- package/types/interfaces/wasi-webgpu-webgpu.d.ts +809 -810
- package/types/wit.d.ts +9 -10
- package/wit/deps/wasi-cli-0.3.0/package.wit +256 -0
- package/wit/deps/wasi-clocks-0.3.0/package.wit +43 -0
- package/wit/deps/wasi-filesystem-0.3.0/package.wit +149 -0
- package/wit/deps/wasi-gfx-frame-buffer-0.2.0/package.wit +13 -0
- package/wit/deps/{surface/surface.wit → wasi-gfx-surface-0.2.0/package.wit} +69 -44
- package/wit/deps/wasi-random-0.3.0/package.wit +18 -0
- package/wit/deps/wasi-sockets-0.3.0/package.wit +116 -0
- package/wit/deps/{webgpu/webgpu.wit → wasi-webgpu-0.3.0-rc.2/package.wit} +1007 -836
- package/wit/world.wit +8 -7
- package/types/interfaces/wasi-frame-buffer-frame-buffer.d.ts +0 -21
- package/types/interfaces/wasi-graphics-context-graphics-context.d.ts +0 -17
- package/types/interfaces/wasi-io-error.d.ts +0 -18
- package/types/interfaces/wasi-io-poll.d.ts +0 -43
- package/types/interfaces/wasi-io-streams.d.ts +0 -240
- package/wit/deps/cli/command.wit +0 -7
- package/wit/deps/cli/environment.wit +0 -18
- package/wit/deps/cli/exit.wit +0 -4
- package/wit/deps/cli/imports.wit +0 -20
- package/wit/deps/cli/run.wit +0 -4
- package/wit/deps/cli/stdio.wit +0 -17
- package/wit/deps/cli/terminal.wit +0 -49
- package/wit/deps/clocks/monotonic-clock.wit +0 -45
- package/wit/deps/clocks/wall-clock.wit +0 -42
- package/wit/deps/clocks/world.wit +0 -6
- package/wit/deps/filesystem/preopens.wit +0 -8
- package/wit/deps/filesystem/types.wit +0 -634
- package/wit/deps/filesystem/world.wit +0 -6
- package/wit/deps/frame-buffer/frame-buffer.wit +0 -23
- package/wit/deps/graphics-context/graphics-context.wit +0 -18
- package/wit/deps/io/error.wit +0 -34
- package/wit/deps/io/poll.wit +0 -41
- package/wit/deps/io/streams.wit +0 -262
- package/wit/deps/io/world.wit +0 -6
- package/wit/deps/random/insecure-seed.wit +0 -25
- package/wit/deps/random/insecure.wit +0 -22
- package/wit/deps/random/random.wit +0 -26
- package/wit/deps/random/world.wit +0 -7
- package/wit/deps/sockets/instance-network.wit +0 -9
- package/wit/deps/sockets/ip-name-lookup.wit +0 -51
- package/wit/deps/sockets/network.wit +0 -145
- package/wit/deps/sockets/tcp-create-socket.wit +0 -27
- package/wit/deps/sockets/tcp.wit +0 -353
- package/wit/deps/sockets/udp-create-socket.wit +0 -27
- package/wit/deps/sockets/udp.wit +0 -266
- package/wit/deps/sockets/world.wit +0 -11
- package/wit/deps/webgpu/imports.wit +0 -5
- package/wit/deps.lock +0 -51
- package/wit/deps.toml +0 -18
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
package wasi:graphics-context@0.0.1;
|
|
2
|
-
|
|
3
|
-
world imports {
|
|
4
|
-
import graphics-context;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
interface graphics-context {
|
|
8
|
-
resource context {
|
|
9
|
-
constructor();
|
|
10
|
-
|
|
11
|
-
get-current-buffer: func() -> abstract-buffer;
|
|
12
|
-
|
|
13
|
-
// TODO: might want to remove this.
|
|
14
|
-
present: func();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
resource abstract-buffer { }
|
|
18
|
-
}
|
package/wit/deps/io/error.wit
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
package wasi:io@0.2.0;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
interface error {
|
|
5
|
-
/// A resource which represents some error information.
|
|
6
|
-
///
|
|
7
|
-
/// The only method provided by this resource is `to-debug-string`,
|
|
8
|
-
/// which provides some human-readable information about the error.
|
|
9
|
-
///
|
|
10
|
-
/// In the `wasi:io` package, this resource is returned through the
|
|
11
|
-
/// `wasi:io/streams/stream-error` type.
|
|
12
|
-
///
|
|
13
|
-
/// To provide more specific error information, other interfaces may
|
|
14
|
-
/// provide functions to further "downcast" this error into more specific
|
|
15
|
-
/// error information. For example, `error`s returned in streams derived
|
|
16
|
-
/// from filesystem types to be described using the filesystem's own
|
|
17
|
-
/// error-code type, using the function
|
|
18
|
-
/// `wasi:filesystem/types/filesystem-error-code`, which takes a parameter
|
|
19
|
-
/// `borrow<error>` and returns
|
|
20
|
-
/// `option<wasi:filesystem/types/error-code>`.
|
|
21
|
-
///
|
|
22
|
-
/// The set of functions which can "downcast" an `error` into a more
|
|
23
|
-
/// concrete type is open.
|
|
24
|
-
resource error {
|
|
25
|
-
/// Returns a string that is suitable to assist humans in debugging
|
|
26
|
-
/// this error.
|
|
27
|
-
///
|
|
28
|
-
/// WARNING: The returned string should not be consumed mechanically!
|
|
29
|
-
/// It may change across platforms, hosts, or other implementation
|
|
30
|
-
/// details. Parsing this string is a major platform-compatibility
|
|
31
|
-
/// hazard.
|
|
32
|
-
to-debug-string: func() -> string;
|
|
33
|
-
}
|
|
34
|
-
}
|
package/wit/deps/io/poll.wit
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
package wasi:io@0.2.0;
|
|
2
|
-
|
|
3
|
-
/// A poll API intended to let users wait for I/O events on multiple handles
|
|
4
|
-
/// at once.
|
|
5
|
-
interface poll {
|
|
6
|
-
/// `pollable` represents a single I/O event which may be ready, or not.
|
|
7
|
-
resource pollable {
|
|
8
|
-
|
|
9
|
-
/// Return the readiness of a pollable. This function never blocks.
|
|
10
|
-
///
|
|
11
|
-
/// Returns `true` when the pollable is ready, and `false` otherwise.
|
|
12
|
-
ready: func() -> bool;
|
|
13
|
-
|
|
14
|
-
/// `block` returns immediately if the pollable is ready, and otherwise
|
|
15
|
-
/// blocks until ready.
|
|
16
|
-
///
|
|
17
|
-
/// This function is equivalent to calling `poll.poll` on a list
|
|
18
|
-
/// containing only this pollable.
|
|
19
|
-
block: func();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/// Poll for completion on a set of pollables.
|
|
23
|
-
///
|
|
24
|
-
/// This function takes a list of pollables, which identify I/O sources of
|
|
25
|
-
/// interest, and waits until one or more of the events is ready for I/O.
|
|
26
|
-
///
|
|
27
|
-
/// The result `list<u32>` contains one or more indices of handles in the
|
|
28
|
-
/// argument list that is ready for I/O.
|
|
29
|
-
///
|
|
30
|
-
/// If the list contains more elements than can be indexed with a `u32`
|
|
31
|
-
/// value, this function traps.
|
|
32
|
-
///
|
|
33
|
-
/// A timeout can be implemented by adding a pollable from the
|
|
34
|
-
/// wasi-clocks API to the list.
|
|
35
|
-
///
|
|
36
|
-
/// This function does not return a `result`; polling in itself does not
|
|
37
|
-
/// do any I/O so it doesn't fail. If any of the I/O sources identified by
|
|
38
|
-
/// the pollables has an error, it is indicated by marking the source as
|
|
39
|
-
/// being reaedy for I/O.
|
|
40
|
-
poll: func(in: list<borrow<pollable>>) -> list<u32>;
|
|
41
|
-
}
|
package/wit/deps/io/streams.wit
DELETED
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
package wasi:io@0.2.0;
|
|
2
|
-
|
|
3
|
-
/// WASI I/O is an I/O abstraction API which is currently focused on providing
|
|
4
|
-
/// stream types.
|
|
5
|
-
///
|
|
6
|
-
/// In the future, the component model is expected to add built-in stream types;
|
|
7
|
-
/// when it does, they are expected to subsume this API.
|
|
8
|
-
interface streams {
|
|
9
|
-
use error.{error};
|
|
10
|
-
use poll.{pollable};
|
|
11
|
-
|
|
12
|
-
/// An error for input-stream and output-stream operations.
|
|
13
|
-
variant stream-error {
|
|
14
|
-
/// The last operation (a write or flush) failed before completion.
|
|
15
|
-
///
|
|
16
|
-
/// More information is available in the `error` payload.
|
|
17
|
-
last-operation-failed(error),
|
|
18
|
-
/// The stream is closed: no more input will be accepted by the
|
|
19
|
-
/// stream. A closed output-stream will return this error on all
|
|
20
|
-
/// future operations.
|
|
21
|
-
closed
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/// An input bytestream.
|
|
25
|
-
///
|
|
26
|
-
/// `input-stream`s are *non-blocking* to the extent practical on underlying
|
|
27
|
-
/// platforms. I/O operations always return promptly; if fewer bytes are
|
|
28
|
-
/// promptly available than requested, they return the number of bytes promptly
|
|
29
|
-
/// available, which could even be zero. To wait for data to be available,
|
|
30
|
-
/// use the `subscribe` function to obtain a `pollable` which can be polled
|
|
31
|
-
/// for using `wasi:io/poll`.
|
|
32
|
-
resource input-stream {
|
|
33
|
-
/// Perform a non-blocking read from the stream.
|
|
34
|
-
///
|
|
35
|
-
/// When the source of a `read` is binary data, the bytes from the source
|
|
36
|
-
/// are returned verbatim. When the source of a `read` is known to the
|
|
37
|
-
/// implementation to be text, bytes containing the UTF-8 encoding of the
|
|
38
|
-
/// text are returned.
|
|
39
|
-
///
|
|
40
|
-
/// This function returns a list of bytes containing the read data,
|
|
41
|
-
/// when successful. The returned list will contain up to `len` bytes;
|
|
42
|
-
/// it may return fewer than requested, but not more. The list is
|
|
43
|
-
/// empty when no bytes are available for reading at this time. The
|
|
44
|
-
/// pollable given by `subscribe` will be ready when more bytes are
|
|
45
|
-
/// available.
|
|
46
|
-
///
|
|
47
|
-
/// This function fails with a `stream-error` when the operation
|
|
48
|
-
/// encounters an error, giving `last-operation-failed`, or when the
|
|
49
|
-
/// stream is closed, giving `closed`.
|
|
50
|
-
///
|
|
51
|
-
/// When the caller gives a `len` of 0, it represents a request to
|
|
52
|
-
/// read 0 bytes. If the stream is still open, this call should
|
|
53
|
-
/// succeed and return an empty list, or otherwise fail with `closed`.
|
|
54
|
-
///
|
|
55
|
-
/// The `len` parameter is a `u64`, which could represent a list of u8 which
|
|
56
|
-
/// is not possible to allocate in wasm32, or not desirable to allocate as
|
|
57
|
-
/// as a return value by the callee. The callee may return a list of bytes
|
|
58
|
-
/// less than `len` in size while more bytes are available for reading.
|
|
59
|
-
read: func(
|
|
60
|
-
/// The maximum number of bytes to read
|
|
61
|
-
len: u64
|
|
62
|
-
) -> result<list<u8>, stream-error>;
|
|
63
|
-
|
|
64
|
-
/// Read bytes from a stream, after blocking until at least one byte can
|
|
65
|
-
/// be read. Except for blocking, behavior is identical to `read`.
|
|
66
|
-
blocking-read: func(
|
|
67
|
-
/// The maximum number of bytes to read
|
|
68
|
-
len: u64
|
|
69
|
-
) -> result<list<u8>, stream-error>;
|
|
70
|
-
|
|
71
|
-
/// Skip bytes from a stream. Returns number of bytes skipped.
|
|
72
|
-
///
|
|
73
|
-
/// Behaves identical to `read`, except instead of returning a list
|
|
74
|
-
/// of bytes, returns the number of bytes consumed from the stream.
|
|
75
|
-
skip: func(
|
|
76
|
-
/// The maximum number of bytes to skip.
|
|
77
|
-
len: u64,
|
|
78
|
-
) -> result<u64, stream-error>;
|
|
79
|
-
|
|
80
|
-
/// Skip bytes from a stream, after blocking until at least one byte
|
|
81
|
-
/// can be skipped. Except for blocking behavior, identical to `skip`.
|
|
82
|
-
blocking-skip: func(
|
|
83
|
-
/// The maximum number of bytes to skip.
|
|
84
|
-
len: u64,
|
|
85
|
-
) -> result<u64, stream-error>;
|
|
86
|
-
|
|
87
|
-
/// Create a `pollable` which will resolve once either the specified stream
|
|
88
|
-
/// has bytes available to read or the other end of the stream has been
|
|
89
|
-
/// closed.
|
|
90
|
-
/// The created `pollable` is a child resource of the `input-stream`.
|
|
91
|
-
/// Implementations may trap if the `input-stream` is dropped before
|
|
92
|
-
/// all derived `pollable`s created with this function are dropped.
|
|
93
|
-
subscribe: func() -> pollable;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
/// An output bytestream.
|
|
98
|
-
///
|
|
99
|
-
/// `output-stream`s are *non-blocking* to the extent practical on
|
|
100
|
-
/// underlying platforms. Except where specified otherwise, I/O operations also
|
|
101
|
-
/// always return promptly, after the number of bytes that can be written
|
|
102
|
-
/// promptly, which could even be zero. To wait for the stream to be ready to
|
|
103
|
-
/// accept data, the `subscribe` function to obtain a `pollable` which can be
|
|
104
|
-
/// polled for using `wasi:io/poll`.
|
|
105
|
-
resource output-stream {
|
|
106
|
-
/// Check readiness for writing. This function never blocks.
|
|
107
|
-
///
|
|
108
|
-
/// Returns the number of bytes permitted for the next call to `write`,
|
|
109
|
-
/// or an error. Calling `write` with more bytes than this function has
|
|
110
|
-
/// permitted will trap.
|
|
111
|
-
///
|
|
112
|
-
/// When this function returns 0 bytes, the `subscribe` pollable will
|
|
113
|
-
/// become ready when this function will report at least 1 byte, or an
|
|
114
|
-
/// error.
|
|
115
|
-
check-write: func() -> result<u64, stream-error>;
|
|
116
|
-
|
|
117
|
-
/// Perform a write. This function never blocks.
|
|
118
|
-
///
|
|
119
|
-
/// When the destination of a `write` is binary data, the bytes from
|
|
120
|
-
/// `contents` are written verbatim. When the destination of a `write` is
|
|
121
|
-
/// known to the implementation to be text, the bytes of `contents` are
|
|
122
|
-
/// transcoded from UTF-8 into the encoding of the destination and then
|
|
123
|
-
/// written.
|
|
124
|
-
///
|
|
125
|
-
/// Precondition: check-write gave permit of Ok(n) and contents has a
|
|
126
|
-
/// length of less than or equal to n. Otherwise, this function will trap.
|
|
127
|
-
///
|
|
128
|
-
/// returns Err(closed) without writing if the stream has closed since
|
|
129
|
-
/// the last call to check-write provided a permit.
|
|
130
|
-
write: func(
|
|
131
|
-
contents: list<u8>
|
|
132
|
-
) -> result<_, stream-error>;
|
|
133
|
-
|
|
134
|
-
/// Perform a write of up to 4096 bytes, and then flush the stream. Block
|
|
135
|
-
/// until all of these operations are complete, or an error occurs.
|
|
136
|
-
///
|
|
137
|
-
/// This is a convenience wrapper around the use of `check-write`,
|
|
138
|
-
/// `subscribe`, `write`, and `flush`, and is implemented with the
|
|
139
|
-
/// following pseudo-code:
|
|
140
|
-
///
|
|
141
|
-
/// ```text
|
|
142
|
-
/// let pollable = this.subscribe();
|
|
143
|
-
/// while !contents.is_empty() {
|
|
144
|
-
/// // Wait for the stream to become writable
|
|
145
|
-
/// pollable.block();
|
|
146
|
-
/// let Ok(n) = this.check-write(); // eliding error handling
|
|
147
|
-
/// let len = min(n, contents.len());
|
|
148
|
-
/// let (chunk, rest) = contents.split_at(len);
|
|
149
|
-
/// this.write(chunk ); // eliding error handling
|
|
150
|
-
/// contents = rest;
|
|
151
|
-
/// }
|
|
152
|
-
/// this.flush();
|
|
153
|
-
/// // Wait for completion of `flush`
|
|
154
|
-
/// pollable.block();
|
|
155
|
-
/// // Check for any errors that arose during `flush`
|
|
156
|
-
/// let _ = this.check-write(); // eliding error handling
|
|
157
|
-
/// ```
|
|
158
|
-
blocking-write-and-flush: func(
|
|
159
|
-
contents: list<u8>
|
|
160
|
-
) -> result<_, stream-error>;
|
|
161
|
-
|
|
162
|
-
/// Request to flush buffered output. This function never blocks.
|
|
163
|
-
///
|
|
164
|
-
/// This tells the output-stream that the caller intends any buffered
|
|
165
|
-
/// output to be flushed. the output which is expected to be flushed
|
|
166
|
-
/// is all that has been passed to `write` prior to this call.
|
|
167
|
-
///
|
|
168
|
-
/// Upon calling this function, the `output-stream` will not accept any
|
|
169
|
-
/// writes (`check-write` will return `ok(0)`) until the flush has
|
|
170
|
-
/// completed. The `subscribe` pollable will become ready when the
|
|
171
|
-
/// flush has completed and the stream can accept more writes.
|
|
172
|
-
flush: func() -> result<_, stream-error>;
|
|
173
|
-
|
|
174
|
-
/// Request to flush buffered output, and block until flush completes
|
|
175
|
-
/// and stream is ready for writing again.
|
|
176
|
-
blocking-flush: func() -> result<_, stream-error>;
|
|
177
|
-
|
|
178
|
-
/// Create a `pollable` which will resolve once the output-stream
|
|
179
|
-
/// is ready for more writing, or an error has occured. When this
|
|
180
|
-
/// pollable is ready, `check-write` will return `ok(n)` with n>0, or an
|
|
181
|
-
/// error.
|
|
182
|
-
///
|
|
183
|
-
/// If the stream is closed, this pollable is always ready immediately.
|
|
184
|
-
///
|
|
185
|
-
/// The created `pollable` is a child resource of the `output-stream`.
|
|
186
|
-
/// Implementations may trap if the `output-stream` is dropped before
|
|
187
|
-
/// all derived `pollable`s created with this function are dropped.
|
|
188
|
-
subscribe: func() -> pollable;
|
|
189
|
-
|
|
190
|
-
/// Write zeroes to a stream.
|
|
191
|
-
///
|
|
192
|
-
/// This should be used precisely like `write` with the exact same
|
|
193
|
-
/// preconditions (must use check-write first), but instead of
|
|
194
|
-
/// passing a list of bytes, you simply pass the number of zero-bytes
|
|
195
|
-
/// that should be written.
|
|
196
|
-
write-zeroes: func(
|
|
197
|
-
/// The number of zero-bytes to write
|
|
198
|
-
len: u64
|
|
199
|
-
) -> result<_, stream-error>;
|
|
200
|
-
|
|
201
|
-
/// Perform a write of up to 4096 zeroes, and then flush the stream.
|
|
202
|
-
/// Block until all of these operations are complete, or an error
|
|
203
|
-
/// occurs.
|
|
204
|
-
///
|
|
205
|
-
/// This is a convenience wrapper around the use of `check-write`,
|
|
206
|
-
/// `subscribe`, `write-zeroes`, and `flush`, and is implemented with
|
|
207
|
-
/// the following pseudo-code:
|
|
208
|
-
///
|
|
209
|
-
/// ```text
|
|
210
|
-
/// let pollable = this.subscribe();
|
|
211
|
-
/// while num_zeroes != 0 {
|
|
212
|
-
/// // Wait for the stream to become writable
|
|
213
|
-
/// pollable.block();
|
|
214
|
-
/// let Ok(n) = this.check-write(); // eliding error handling
|
|
215
|
-
/// let len = min(n, num_zeroes);
|
|
216
|
-
/// this.write-zeroes(len); // eliding error handling
|
|
217
|
-
/// num_zeroes -= len;
|
|
218
|
-
/// }
|
|
219
|
-
/// this.flush();
|
|
220
|
-
/// // Wait for completion of `flush`
|
|
221
|
-
/// pollable.block();
|
|
222
|
-
/// // Check for any errors that arose during `flush`
|
|
223
|
-
/// let _ = this.check-write(); // eliding error handling
|
|
224
|
-
/// ```
|
|
225
|
-
blocking-write-zeroes-and-flush: func(
|
|
226
|
-
/// The number of zero-bytes to write
|
|
227
|
-
len: u64
|
|
228
|
-
) -> result<_, stream-error>;
|
|
229
|
-
|
|
230
|
-
/// Read from one stream and write to another.
|
|
231
|
-
///
|
|
232
|
-
/// The behavior of splice is equivelant to:
|
|
233
|
-
/// 1. calling `check-write` on the `output-stream`
|
|
234
|
-
/// 2. calling `read` on the `input-stream` with the smaller of the
|
|
235
|
-
/// `check-write` permitted length and the `len` provided to `splice`
|
|
236
|
-
/// 3. calling `write` on the `output-stream` with that read data.
|
|
237
|
-
///
|
|
238
|
-
/// Any error reported by the call to `check-write`, `read`, or
|
|
239
|
-
/// `write` ends the splice and reports that error.
|
|
240
|
-
///
|
|
241
|
-
/// This function returns the number of bytes transferred; it may be less
|
|
242
|
-
/// than `len`.
|
|
243
|
-
splice: func(
|
|
244
|
-
/// The stream to read from
|
|
245
|
-
src: borrow<input-stream>,
|
|
246
|
-
/// The number of bytes to splice
|
|
247
|
-
len: u64,
|
|
248
|
-
) -> result<u64, stream-error>;
|
|
249
|
-
|
|
250
|
-
/// Read from one stream and write to another, with blocking.
|
|
251
|
-
///
|
|
252
|
-
/// This is similar to `splice`, except that it blocks until the
|
|
253
|
-
/// `output-stream` is ready for writing, and the `input-stream`
|
|
254
|
-
/// is ready for reading, before performing the `splice`.
|
|
255
|
-
blocking-splice: func(
|
|
256
|
-
/// The stream to read from
|
|
257
|
-
src: borrow<input-stream>,
|
|
258
|
-
/// The number of bytes to splice
|
|
259
|
-
len: u64,
|
|
260
|
-
) -> result<u64, stream-error>;
|
|
261
|
-
}
|
|
262
|
-
}
|
package/wit/deps/io/world.wit
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
package wasi:random@0.2.0;
|
|
2
|
-
/// The insecure-seed interface for seeding hash-map DoS resistance.
|
|
3
|
-
///
|
|
4
|
-
/// It is intended to be portable at least between Unix-family platforms and
|
|
5
|
-
/// Windows.
|
|
6
|
-
interface insecure-seed {
|
|
7
|
-
/// Return a 128-bit value that may contain a pseudo-random value.
|
|
8
|
-
///
|
|
9
|
-
/// The returned value is not required to be computed from a CSPRNG, and may
|
|
10
|
-
/// even be entirely deterministic. Host implementations are encouraged to
|
|
11
|
-
/// provide pseudo-random values to any program exposed to
|
|
12
|
-
/// attacker-controlled content, to enable DoS protection built into many
|
|
13
|
-
/// languages' hash-map implementations.
|
|
14
|
-
///
|
|
15
|
-
/// This function is intended to only be called once, by a source language
|
|
16
|
-
/// to initialize Denial Of Service (DoS) protection in its hash-map
|
|
17
|
-
/// implementation.
|
|
18
|
-
///
|
|
19
|
-
/// # Expected future evolution
|
|
20
|
-
///
|
|
21
|
-
/// This will likely be changed to a value import, to prevent it from being
|
|
22
|
-
/// called multiple times and potentially used for purposes other than DoS
|
|
23
|
-
/// protection.
|
|
24
|
-
insecure-seed: func() -> tuple<u64, u64>;
|
|
25
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
package wasi:random@0.2.0;
|
|
2
|
-
/// The insecure interface for insecure pseudo-random numbers.
|
|
3
|
-
///
|
|
4
|
-
/// It is intended to be portable at least between Unix-family platforms and
|
|
5
|
-
/// Windows.
|
|
6
|
-
interface insecure {
|
|
7
|
-
/// Return `len` insecure pseudo-random bytes.
|
|
8
|
-
///
|
|
9
|
-
/// This function is not cryptographically secure. Do not use it for
|
|
10
|
-
/// anything related to security.
|
|
11
|
-
///
|
|
12
|
-
/// There are no requirements on the values of the returned bytes, however
|
|
13
|
-
/// implementations are encouraged to return evenly distributed values with
|
|
14
|
-
/// a long period.
|
|
15
|
-
get-insecure-random-bytes: func(len: u64) -> list<u8>;
|
|
16
|
-
|
|
17
|
-
/// Return an insecure pseudo-random `u64` value.
|
|
18
|
-
///
|
|
19
|
-
/// This function returns the same type of pseudo-random data as
|
|
20
|
-
/// `get-insecure-random-bytes`, represented as a `u64`.
|
|
21
|
-
get-insecure-random-u64: func() -> u64;
|
|
22
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
package wasi:random@0.2.0;
|
|
2
|
-
/// WASI Random is a random data API.
|
|
3
|
-
///
|
|
4
|
-
/// It is intended to be portable at least between Unix-family platforms and
|
|
5
|
-
/// Windows.
|
|
6
|
-
interface random {
|
|
7
|
-
/// Return `len` cryptographically-secure random or pseudo-random bytes.
|
|
8
|
-
///
|
|
9
|
-
/// This function must produce data at least as cryptographically secure and
|
|
10
|
-
/// fast as an adequately seeded cryptographically-secure pseudo-random
|
|
11
|
-
/// number generator (CSPRNG). It must not block, from the perspective of
|
|
12
|
-
/// the calling program, under any circumstances, including on the first
|
|
13
|
-
/// request and on requests for numbers of bytes. The returned data must
|
|
14
|
-
/// always be unpredictable.
|
|
15
|
-
///
|
|
16
|
-
/// This function must always return fresh data. Deterministic environments
|
|
17
|
-
/// must omit this function, rather than implementing it with deterministic
|
|
18
|
-
/// data.
|
|
19
|
-
get-random-bytes: func(len: u64) -> list<u8>;
|
|
20
|
-
|
|
21
|
-
/// Return a cryptographically-secure random or pseudo-random `u64` value.
|
|
22
|
-
///
|
|
23
|
-
/// This function returns the same type of data as `get-random-bytes`,
|
|
24
|
-
/// represented as a `u64`.
|
|
25
|
-
get-random-u64: func() -> u64;
|
|
26
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
interface ip-name-lookup {
|
|
3
|
-
use wasi:io/poll@0.2.0.{pollable};
|
|
4
|
-
use network.{network, error-code, ip-address};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/// Resolve an internet host name to a list of IP addresses.
|
|
8
|
-
///
|
|
9
|
-
/// Unicode domain names are automatically converted to ASCII using IDNA encoding.
|
|
10
|
-
/// If the input is an IP address string, the address is parsed and returned
|
|
11
|
-
/// as-is without making any external requests.
|
|
12
|
-
///
|
|
13
|
-
/// See the wasi-socket proposal README.md for a comparison with getaddrinfo.
|
|
14
|
-
///
|
|
15
|
-
/// This function never blocks. It either immediately fails or immediately
|
|
16
|
-
/// returns successfully with a `resolve-address-stream` that can be used
|
|
17
|
-
/// to (asynchronously) fetch the results.
|
|
18
|
-
///
|
|
19
|
-
/// # Typical errors
|
|
20
|
-
/// - `invalid-argument`: `name` is a syntactically invalid domain name or IP address.
|
|
21
|
-
///
|
|
22
|
-
/// # References:
|
|
23
|
-
/// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html>
|
|
24
|
-
/// - <https://man7.org/linux/man-pages/man3/getaddrinfo.3.html>
|
|
25
|
-
/// - <https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo>
|
|
26
|
-
/// - <https://man.freebsd.org/cgi/man.cgi?query=getaddrinfo&sektion=3>
|
|
27
|
-
resolve-addresses: func(network: borrow<network>, name: string) -> result<resolve-address-stream, error-code>;
|
|
28
|
-
|
|
29
|
-
resource resolve-address-stream {
|
|
30
|
-
/// Returns the next address from the resolver.
|
|
31
|
-
///
|
|
32
|
-
/// This function should be called multiple times. On each call, it will
|
|
33
|
-
/// return the next address in connection order preference. If all
|
|
34
|
-
/// addresses have been exhausted, this function returns `none`.
|
|
35
|
-
///
|
|
36
|
-
/// This function never returns IPv4-mapped IPv6 addresses.
|
|
37
|
-
///
|
|
38
|
-
/// # Typical errors
|
|
39
|
-
/// - `name-unresolvable`: Name does not exist or has no suitable associated IP addresses. (EAI_NONAME, EAI_NODATA, EAI_ADDRFAMILY)
|
|
40
|
-
/// - `temporary-resolver-failure`: A temporary failure in name resolution occurred. (EAI_AGAIN)
|
|
41
|
-
/// - `permanent-resolver-failure`: A permanent failure in name resolution occurred. (EAI_FAIL)
|
|
42
|
-
/// - `would-block`: A result is not available yet. (EWOULDBLOCK, EAGAIN)
|
|
43
|
-
resolve-next-address: func() -> result<option<ip-address>, error-code>;
|
|
44
|
-
|
|
45
|
-
/// Create a `pollable` which will resolve once the stream is ready for I/O.
|
|
46
|
-
///
|
|
47
|
-
/// Note: this function is here for WASI Preview2 only.
|
|
48
|
-
/// It's planned to be removed when `future` is natively supported in Preview3.
|
|
49
|
-
subscribe: func() -> pollable;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
interface network {
|
|
3
|
-
/// An opaque resource that represents access to (a subset of) the network.
|
|
4
|
-
/// This enables context-based security for networking.
|
|
5
|
-
/// There is no need for this to map 1:1 to a physical network interface.
|
|
6
|
-
resource network;
|
|
7
|
-
|
|
8
|
-
/// Error codes.
|
|
9
|
-
///
|
|
10
|
-
/// In theory, every API can return any error code.
|
|
11
|
-
/// In practice, API's typically only return the errors documented per API
|
|
12
|
-
/// combined with a couple of errors that are always possible:
|
|
13
|
-
/// - `unknown`
|
|
14
|
-
/// - `access-denied`
|
|
15
|
-
/// - `not-supported`
|
|
16
|
-
/// - `out-of-memory`
|
|
17
|
-
/// - `concurrency-conflict`
|
|
18
|
-
///
|
|
19
|
-
/// See each individual API for what the POSIX equivalents are. They sometimes differ per API.
|
|
20
|
-
enum error-code {
|
|
21
|
-
/// Unknown error
|
|
22
|
-
unknown,
|
|
23
|
-
|
|
24
|
-
/// Access denied.
|
|
25
|
-
///
|
|
26
|
-
/// POSIX equivalent: EACCES, EPERM
|
|
27
|
-
access-denied,
|
|
28
|
-
|
|
29
|
-
/// The operation is not supported.
|
|
30
|
-
///
|
|
31
|
-
/// POSIX equivalent: EOPNOTSUPP
|
|
32
|
-
not-supported,
|
|
33
|
-
|
|
34
|
-
/// One of the arguments is invalid.
|
|
35
|
-
///
|
|
36
|
-
/// POSIX equivalent: EINVAL
|
|
37
|
-
invalid-argument,
|
|
38
|
-
|
|
39
|
-
/// Not enough memory to complete the operation.
|
|
40
|
-
///
|
|
41
|
-
/// POSIX equivalent: ENOMEM, ENOBUFS, EAI_MEMORY
|
|
42
|
-
out-of-memory,
|
|
43
|
-
|
|
44
|
-
/// The operation timed out before it could finish completely.
|
|
45
|
-
timeout,
|
|
46
|
-
|
|
47
|
-
/// This operation is incompatible with another asynchronous operation that is already in progress.
|
|
48
|
-
///
|
|
49
|
-
/// POSIX equivalent: EALREADY
|
|
50
|
-
concurrency-conflict,
|
|
51
|
-
|
|
52
|
-
/// Trying to finish an asynchronous operation that:
|
|
53
|
-
/// - has not been started yet, or:
|
|
54
|
-
/// - was already finished by a previous `finish-*` call.
|
|
55
|
-
///
|
|
56
|
-
/// Note: this is scheduled to be removed when `future`s are natively supported.
|
|
57
|
-
not-in-progress,
|
|
58
|
-
|
|
59
|
-
/// The operation has been aborted because it could not be completed immediately.
|
|
60
|
-
///
|
|
61
|
-
/// Note: this is scheduled to be removed when `future`s are natively supported.
|
|
62
|
-
would-block,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
/// The operation is not valid in the socket's current state.
|
|
66
|
-
invalid-state,
|
|
67
|
-
|
|
68
|
-
/// A new socket resource could not be created because of a system limit.
|
|
69
|
-
new-socket-limit,
|
|
70
|
-
|
|
71
|
-
/// A bind operation failed because the provided address is not an address that the `network` can bind to.
|
|
72
|
-
address-not-bindable,
|
|
73
|
-
|
|
74
|
-
/// A bind operation failed because the provided address is already in use or because there are no ephemeral ports available.
|
|
75
|
-
address-in-use,
|
|
76
|
-
|
|
77
|
-
/// The remote address is not reachable
|
|
78
|
-
remote-unreachable,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
/// The TCP connection was forcefully rejected
|
|
82
|
-
connection-refused,
|
|
83
|
-
|
|
84
|
-
/// The TCP connection was reset.
|
|
85
|
-
connection-reset,
|
|
86
|
-
|
|
87
|
-
/// A TCP connection was aborted.
|
|
88
|
-
connection-aborted,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
/// The size of a datagram sent to a UDP socket exceeded the maximum
|
|
92
|
-
/// supported size.
|
|
93
|
-
datagram-too-large,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
/// Name does not exist or has no suitable associated IP addresses.
|
|
97
|
-
name-unresolvable,
|
|
98
|
-
|
|
99
|
-
/// A temporary failure in name resolution occurred.
|
|
100
|
-
temporary-resolver-failure,
|
|
101
|
-
|
|
102
|
-
/// A permanent failure in name resolution occurred.
|
|
103
|
-
permanent-resolver-failure,
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
enum ip-address-family {
|
|
107
|
-
/// Similar to `AF_INET` in POSIX.
|
|
108
|
-
ipv4,
|
|
109
|
-
|
|
110
|
-
/// Similar to `AF_INET6` in POSIX.
|
|
111
|
-
ipv6,
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
type ipv4-address = tuple<u8, u8, u8, u8>;
|
|
115
|
-
type ipv6-address = tuple<u16, u16, u16, u16, u16, u16, u16, u16>;
|
|
116
|
-
|
|
117
|
-
variant ip-address {
|
|
118
|
-
ipv4(ipv4-address),
|
|
119
|
-
ipv6(ipv6-address),
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
record ipv4-socket-address {
|
|
123
|
-
/// sin_port
|
|
124
|
-
port: u16,
|
|
125
|
-
/// sin_addr
|
|
126
|
-
address: ipv4-address,
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
record ipv6-socket-address {
|
|
130
|
-
/// sin6_port
|
|
131
|
-
port: u16,
|
|
132
|
-
/// sin6_flowinfo
|
|
133
|
-
flow-info: u32,
|
|
134
|
-
/// sin6_addr
|
|
135
|
-
address: ipv6-address,
|
|
136
|
-
/// sin6_scope_id
|
|
137
|
-
scope-id: u32,
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
variant ip-socket-address {
|
|
141
|
-
ipv4(ipv4-socket-address),
|
|
142
|
-
ipv6(ipv6-socket-address),
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
}
|