@bytecodealliance/jco 1.30.0 → 1.32.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 +47 -0
- package/dist/cmd/new/builtin-wit.d.ts +13 -0
- package/dist/cmd/new/builtin-wit.d.ts.map +1 -0
- package/dist/cmd/new/builtin-wit.js +53 -0
- package/dist/cmd/new/builtin-wit.js.map +1 -0
- package/dist/cmd/new/oci-wit.d.ts +5 -0
- package/dist/cmd/new/oci-wit.d.ts.map +1 -0
- package/dist/cmd/new/oci-wit.js +124 -0
- package/dist/cmd/new/oci-wit.js.map +1 -0
- package/dist/cmd/new.d.ts.map +1 -1
- package/dist/cmd/new.js +58 -39
- package/dist/cmd/new.js.map +1 -1
- package/dist/cmd/run.d.ts +8 -0
- package/dist/cmd/run.d.ts.map +1 -1
- package/dist/cmd/run.js +202 -6
- package/dist/cmd/run.js.map +1 -1
- package/dist/cmd/transpile.d.ts +3 -0
- package/dist/cmd/transpile.d.ts.map +1 -1
- package/dist/cmd/transpile.js +3 -0
- package/dist/cmd/transpile.js.map +1 -1
- package/dist/cmd/types.d.ts +3 -0
- package/dist/cmd/types.d.ts.map +1 -1
- package/dist/cmd/types.js +6 -1
- package/dist/cmd/types.js.map +1 -1
- package/dist/jco.js +22 -3
- package/dist/jco.js.map +1 -1
- package/lib/wit/builtin/0.2.12/wasi-cli/package.wit +64 -0
- package/lib/wit/builtin/0.2.12/wasi-clocks/package.wit +43 -0
- package/lib/wit/builtin/0.2.12/wasi-filesystem/package.wit +196 -0
- package/lib/wit/builtin/0.2.12/wasi-http/package.wit +205 -0
- package/lib/wit/builtin/0.2.12/wasi-io/package.wit +66 -0
- package/lib/wit/builtin/0.2.12/wasi-random/package.wit +17 -0
- package/lib/wit/builtin/0.2.12/wasi-sockets/package.wit +164 -0
- package/lib/wit/builtin/0.3.0/wasi-cli/package.wit +70 -0
- package/lib/wit/builtin/0.3.0/wasi-clocks/package.wit +42 -0
- package/lib/wit/builtin/0.3.0/wasi-filesystem/package.wit +184 -0
- package/lib/wit/builtin/0.3.0/wasi-http/package.wit +170 -0
- package/lib/wit/builtin/0.3.0/wasi-random/package.wit +17 -0
- package/lib/wit/builtin/0.3.0/wasi-sockets/package.wit +105 -0
- package/lib/wit/builtin/LICENSE.md +8 -0
- package/lib/wit/builtin/README.md +12 -0
- package/package.json +4 -4
- package/LICENSE +0 -220
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
package wasi:filesystem@0.2.12;
|
|
2
|
+
interface preopens {
|
|
3
|
+
use types.{descriptor};
|
|
4
|
+
get-directories: func() -> list<tuple<descriptor, string>>;
|
|
5
|
+
}
|
|
6
|
+
interface types {
|
|
7
|
+
use wasi:io/streams@0.2.12.{input-stream, output-stream, error};
|
|
8
|
+
use wasi:clocks/wall-clock@0.2.12.{datetime};
|
|
9
|
+
type filesize = u64;
|
|
10
|
+
enum descriptor-type {
|
|
11
|
+
unknown,
|
|
12
|
+
block-device,
|
|
13
|
+
character-device,
|
|
14
|
+
directory,
|
|
15
|
+
fifo,
|
|
16
|
+
symbolic-link,
|
|
17
|
+
regular-file,
|
|
18
|
+
socket,
|
|
19
|
+
}
|
|
20
|
+
flags descriptor-flags {
|
|
21
|
+
read,
|
|
22
|
+
write,
|
|
23
|
+
file-integrity-sync,
|
|
24
|
+
data-integrity-sync,
|
|
25
|
+
requested-write-sync,
|
|
26
|
+
mutate-directory,
|
|
27
|
+
}
|
|
28
|
+
record descriptor-stat {
|
|
29
|
+
%type: descriptor-type,
|
|
30
|
+
link-count: link-count,
|
|
31
|
+
size: filesize,
|
|
32
|
+
data-access-timestamp: option<datetime>,
|
|
33
|
+
data-modification-timestamp: option<datetime>,
|
|
34
|
+
status-change-timestamp: option<datetime>,
|
|
35
|
+
}
|
|
36
|
+
flags path-flags {
|
|
37
|
+
symlink-follow,
|
|
38
|
+
}
|
|
39
|
+
flags open-flags {
|
|
40
|
+
create,
|
|
41
|
+
directory,
|
|
42
|
+
exclusive,
|
|
43
|
+
truncate,
|
|
44
|
+
}
|
|
45
|
+
type link-count = u64;
|
|
46
|
+
variant new-timestamp {
|
|
47
|
+
no-change,
|
|
48
|
+
now,
|
|
49
|
+
timestamp(datetime),
|
|
50
|
+
}
|
|
51
|
+
record directory-entry {
|
|
52
|
+
%type: descriptor-type,
|
|
53
|
+
name: string,
|
|
54
|
+
}
|
|
55
|
+
enum error-code {
|
|
56
|
+
access,
|
|
57
|
+
would-block,
|
|
58
|
+
already,
|
|
59
|
+
bad-descriptor,
|
|
60
|
+
busy,
|
|
61
|
+
deadlock,
|
|
62
|
+
quota,
|
|
63
|
+
exist,
|
|
64
|
+
file-too-large,
|
|
65
|
+
illegal-byte-sequence,
|
|
66
|
+
in-progress,
|
|
67
|
+
interrupted,
|
|
68
|
+
invalid,
|
|
69
|
+
io,
|
|
70
|
+
is-directory,
|
|
71
|
+
loop,
|
|
72
|
+
too-many-links,
|
|
73
|
+
message-size,
|
|
74
|
+
name-too-long,
|
|
75
|
+
no-device,
|
|
76
|
+
no-entry,
|
|
77
|
+
no-lock,
|
|
78
|
+
insufficient-memory,
|
|
79
|
+
insufficient-space,
|
|
80
|
+
not-directory,
|
|
81
|
+
not-empty,
|
|
82
|
+
not-recoverable,
|
|
83
|
+
unsupported,
|
|
84
|
+
no-tty,
|
|
85
|
+
no-such-device,
|
|
86
|
+
overflow,
|
|
87
|
+
not-permitted,
|
|
88
|
+
pipe,
|
|
89
|
+
read-only,
|
|
90
|
+
invalid-seek,
|
|
91
|
+
text-file-busy,
|
|
92
|
+
cross-device,
|
|
93
|
+
}
|
|
94
|
+
enum advice {
|
|
95
|
+
normal,
|
|
96
|
+
sequential,
|
|
97
|
+
random,
|
|
98
|
+
will-need,
|
|
99
|
+
dont-need,
|
|
100
|
+
no-reuse,
|
|
101
|
+
}
|
|
102
|
+
record metadata-hash-value {
|
|
103
|
+
lower: u64,
|
|
104
|
+
upper: u64,
|
|
105
|
+
}
|
|
106
|
+
resource descriptor {
|
|
107
|
+
read-via-stream: func(
|
|
108
|
+
offset: filesize,
|
|
109
|
+
) -> result<input-stream, error-code>;
|
|
110
|
+
write-via-stream: func(
|
|
111
|
+
offset: filesize,
|
|
112
|
+
) -> result<output-stream, error-code>;
|
|
113
|
+
append-via-stream: func() -> result<output-stream, error-code>;
|
|
114
|
+
advise: func(
|
|
115
|
+
offset: filesize,
|
|
116
|
+
length: filesize,
|
|
117
|
+
advice: advice
|
|
118
|
+
) -> result<_, error-code>;
|
|
119
|
+
sync-data: func() -> result<_, error-code>;
|
|
120
|
+
get-flags: func() -> result<descriptor-flags, error-code>;
|
|
121
|
+
get-type: func() -> result<descriptor-type, error-code>;
|
|
122
|
+
set-size: func(size: filesize) -> result<_, error-code>;
|
|
123
|
+
set-times: func(
|
|
124
|
+
data-access-timestamp: new-timestamp,
|
|
125
|
+
data-modification-timestamp: new-timestamp,
|
|
126
|
+
) -> result<_, error-code>;
|
|
127
|
+
read: func(
|
|
128
|
+
length: filesize,
|
|
129
|
+
offset: filesize,
|
|
130
|
+
) -> result<tuple<list<u8>, bool>, error-code>;
|
|
131
|
+
write: func(
|
|
132
|
+
buffer: list<u8>,
|
|
133
|
+
offset: filesize,
|
|
134
|
+
) -> result<filesize, error-code>;
|
|
135
|
+
read-directory: func() -> result<directory-entry-stream, error-code>;
|
|
136
|
+
sync: func() -> result<_, error-code>;
|
|
137
|
+
create-directory-at: func(
|
|
138
|
+
path: string,
|
|
139
|
+
) -> result<_, error-code>;
|
|
140
|
+
stat: func() -> result<descriptor-stat, error-code>;
|
|
141
|
+
stat-at: func(
|
|
142
|
+
path-flags: path-flags,
|
|
143
|
+
path: string,
|
|
144
|
+
) -> result<descriptor-stat, error-code>;
|
|
145
|
+
set-times-at: func(
|
|
146
|
+
path-flags: path-flags,
|
|
147
|
+
path: string,
|
|
148
|
+
data-access-timestamp: new-timestamp,
|
|
149
|
+
data-modification-timestamp: new-timestamp,
|
|
150
|
+
) -> result<_, error-code>;
|
|
151
|
+
link-at: func(
|
|
152
|
+
old-path-flags: path-flags,
|
|
153
|
+
old-path: string,
|
|
154
|
+
new-descriptor: borrow<descriptor>,
|
|
155
|
+
new-path: string,
|
|
156
|
+
) -> result<_, error-code>;
|
|
157
|
+
open-at: func(
|
|
158
|
+
path-flags: path-flags,
|
|
159
|
+
path: string,
|
|
160
|
+
open-flags: open-flags,
|
|
161
|
+
%flags: descriptor-flags,
|
|
162
|
+
) -> result<descriptor, error-code>;
|
|
163
|
+
readlink-at: func(
|
|
164
|
+
path: string,
|
|
165
|
+
) -> result<string, error-code>;
|
|
166
|
+
remove-directory-at: func(
|
|
167
|
+
path: string,
|
|
168
|
+
) -> result<_, error-code>;
|
|
169
|
+
rename-at: func(
|
|
170
|
+
old-path: string,
|
|
171
|
+
new-descriptor: borrow<descriptor>,
|
|
172
|
+
new-path: string,
|
|
173
|
+
) -> result<_, error-code>;
|
|
174
|
+
symlink-at: func(
|
|
175
|
+
old-path: string,
|
|
176
|
+
new-path: string,
|
|
177
|
+
) -> result<_, error-code>;
|
|
178
|
+
unlink-file-at: func(
|
|
179
|
+
path: string,
|
|
180
|
+
) -> result<_, error-code>;
|
|
181
|
+
is-same-object: func(other: borrow<descriptor>) -> bool;
|
|
182
|
+
metadata-hash: func() -> result<metadata-hash-value, error-code>;
|
|
183
|
+
metadata-hash-at: func(
|
|
184
|
+
path-flags: path-flags,
|
|
185
|
+
path: string,
|
|
186
|
+
) -> result<metadata-hash-value, error-code>;
|
|
187
|
+
}
|
|
188
|
+
resource directory-entry-stream {
|
|
189
|
+
read-directory-entry: func() -> result<option<directory-entry>, error-code>;
|
|
190
|
+
}
|
|
191
|
+
filesystem-error-code: func(err: borrow<error>) -> option<error-code>;
|
|
192
|
+
}
|
|
193
|
+
world imports {
|
|
194
|
+
import types;
|
|
195
|
+
import preopens;
|
|
196
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
package wasi:http@0.2.12;
|
|
2
|
+
interface incoming-handler {
|
|
3
|
+
use types.{incoming-request, response-outparam};
|
|
4
|
+
handle: func(
|
|
5
|
+
request: incoming-request,
|
|
6
|
+
response-out: response-outparam
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
interface outgoing-handler {
|
|
10
|
+
use types.{
|
|
11
|
+
outgoing-request, request-options, future-incoming-response, error-code
|
|
12
|
+
};
|
|
13
|
+
handle: func(
|
|
14
|
+
request: outgoing-request,
|
|
15
|
+
options: option<request-options>
|
|
16
|
+
) -> result<future-incoming-response, error-code>;
|
|
17
|
+
}
|
|
18
|
+
world imports {
|
|
19
|
+
import wasi:clocks/monotonic-clock@0.2.12;
|
|
20
|
+
import wasi:clocks/wall-clock@0.2.12;
|
|
21
|
+
import wasi:random/random@0.2.12;
|
|
22
|
+
import wasi:cli/stdout@0.2.12;
|
|
23
|
+
import wasi:cli/stderr@0.2.12;
|
|
24
|
+
import wasi:cli/stdin@0.2.12;
|
|
25
|
+
import outgoing-handler;
|
|
26
|
+
}
|
|
27
|
+
world proxy {
|
|
28
|
+
include imports;
|
|
29
|
+
export incoming-handler;
|
|
30
|
+
}
|
|
31
|
+
interface types {
|
|
32
|
+
use wasi:clocks/monotonic-clock@0.2.12.{duration};
|
|
33
|
+
use wasi:io/streams@0.2.12.{input-stream, output-stream};
|
|
34
|
+
use wasi:io/error@0.2.12.{error as io-error};
|
|
35
|
+
use wasi:io/poll@0.2.12.{pollable};
|
|
36
|
+
variant method {
|
|
37
|
+
get,
|
|
38
|
+
head,
|
|
39
|
+
post,
|
|
40
|
+
put,
|
|
41
|
+
delete,
|
|
42
|
+
connect,
|
|
43
|
+
options,
|
|
44
|
+
trace,
|
|
45
|
+
patch,
|
|
46
|
+
other(string)
|
|
47
|
+
}
|
|
48
|
+
variant scheme {
|
|
49
|
+
HTTP,
|
|
50
|
+
HTTPS,
|
|
51
|
+
other(string)
|
|
52
|
+
}
|
|
53
|
+
variant error-code {
|
|
54
|
+
DNS-timeout,
|
|
55
|
+
DNS-error(DNS-error-payload),
|
|
56
|
+
destination-not-found,
|
|
57
|
+
destination-unavailable,
|
|
58
|
+
destination-IP-prohibited,
|
|
59
|
+
destination-IP-unroutable,
|
|
60
|
+
connection-refused,
|
|
61
|
+
connection-terminated,
|
|
62
|
+
connection-timeout,
|
|
63
|
+
connection-read-timeout,
|
|
64
|
+
connection-write-timeout,
|
|
65
|
+
connection-limit-reached,
|
|
66
|
+
TLS-protocol-error,
|
|
67
|
+
TLS-certificate-error,
|
|
68
|
+
TLS-alert-received(TLS-alert-received-payload),
|
|
69
|
+
HTTP-request-denied,
|
|
70
|
+
HTTP-request-length-required,
|
|
71
|
+
HTTP-request-body-size(option<u64>),
|
|
72
|
+
HTTP-request-method-invalid,
|
|
73
|
+
HTTP-request-URI-invalid,
|
|
74
|
+
HTTP-request-URI-too-long,
|
|
75
|
+
HTTP-request-header-section-size(option<u32>),
|
|
76
|
+
HTTP-request-header-size(option<field-size-payload>),
|
|
77
|
+
HTTP-request-trailer-section-size(option<u32>),
|
|
78
|
+
HTTP-request-trailer-size(field-size-payload),
|
|
79
|
+
HTTP-response-incomplete,
|
|
80
|
+
HTTP-response-header-section-size(option<u32>),
|
|
81
|
+
HTTP-response-header-size(field-size-payload),
|
|
82
|
+
HTTP-response-body-size(option<u64>),
|
|
83
|
+
HTTP-response-trailer-section-size(option<u32>),
|
|
84
|
+
HTTP-response-trailer-size(field-size-payload),
|
|
85
|
+
HTTP-response-transfer-coding(option<string>),
|
|
86
|
+
HTTP-response-content-coding(option<string>),
|
|
87
|
+
HTTP-response-timeout,
|
|
88
|
+
HTTP-upgrade-failed,
|
|
89
|
+
HTTP-protocol-error,
|
|
90
|
+
loop-detected,
|
|
91
|
+
configuration-error,
|
|
92
|
+
internal-error(option<string>)
|
|
93
|
+
}
|
|
94
|
+
record DNS-error-payload {
|
|
95
|
+
rcode: option<string>,
|
|
96
|
+
info-code: option<u16>
|
|
97
|
+
}
|
|
98
|
+
record TLS-alert-received-payload {
|
|
99
|
+
alert-id: option<u8>,
|
|
100
|
+
alert-message: option<string>
|
|
101
|
+
}
|
|
102
|
+
record field-size-payload {
|
|
103
|
+
field-name: option<string>,
|
|
104
|
+
field-size: option<u32>
|
|
105
|
+
}
|
|
106
|
+
http-error-code: func(err: borrow<io-error>) -> option<error-code>;
|
|
107
|
+
variant header-error {
|
|
108
|
+
invalid-syntax,
|
|
109
|
+
forbidden,
|
|
110
|
+
immutable,
|
|
111
|
+
}
|
|
112
|
+
type field-name = field-key;
|
|
113
|
+
type field-key = string;
|
|
114
|
+
type field-value = list<u8>;
|
|
115
|
+
resource fields {
|
|
116
|
+
constructor();
|
|
117
|
+
from-list: static func(
|
|
118
|
+
entries: list<tuple<field-name,field-value>>
|
|
119
|
+
) -> result<fields, header-error>;
|
|
120
|
+
get: func(name: field-name) -> list<field-value>;
|
|
121
|
+
has: func(name: field-name) -> bool;
|
|
122
|
+
set: func(name: field-name, value: list<field-value>) -> result<_, header-error>;
|
|
123
|
+
delete: func(name: field-name) -> result<_, header-error>;
|
|
124
|
+
append: func(name: field-name, value: field-value) -> result<_, header-error>;
|
|
125
|
+
entries: func() -> list<tuple<field-name,field-value>>;
|
|
126
|
+
clone: func() -> fields;
|
|
127
|
+
}
|
|
128
|
+
type headers = fields;
|
|
129
|
+
type trailers = fields;
|
|
130
|
+
resource incoming-request {
|
|
131
|
+
method: func() -> method;
|
|
132
|
+
path-with-query: func() -> option<string>;
|
|
133
|
+
scheme: func() -> option<scheme>;
|
|
134
|
+
authority: func() -> option<string>;
|
|
135
|
+
headers: func() -> headers;
|
|
136
|
+
consume: func() -> result<incoming-body>;
|
|
137
|
+
}
|
|
138
|
+
resource outgoing-request {
|
|
139
|
+
constructor(
|
|
140
|
+
headers: headers
|
|
141
|
+
);
|
|
142
|
+
body: func() -> result<outgoing-body>;
|
|
143
|
+
method: func() -> method;
|
|
144
|
+
set-method: func(method: method) -> result;
|
|
145
|
+
path-with-query: func() -> option<string>;
|
|
146
|
+
set-path-with-query: func(path-with-query: option<string>) -> result;
|
|
147
|
+
scheme: func() -> option<scheme>;
|
|
148
|
+
set-scheme: func(scheme: option<scheme>) -> result;
|
|
149
|
+
authority: func() -> option<string>;
|
|
150
|
+
set-authority: func(authority: option<string>) -> result;
|
|
151
|
+
headers: func() -> headers;
|
|
152
|
+
}
|
|
153
|
+
resource request-options {
|
|
154
|
+
constructor();
|
|
155
|
+
connect-timeout: func() -> option<duration>;
|
|
156
|
+
set-connect-timeout: func(duration: option<duration>) -> result;
|
|
157
|
+
first-byte-timeout: func() -> option<duration>;
|
|
158
|
+
set-first-byte-timeout: func(duration: option<duration>) -> result;
|
|
159
|
+
between-bytes-timeout: func() -> option<duration>;
|
|
160
|
+
set-between-bytes-timeout: func(duration: option<duration>) -> result;
|
|
161
|
+
}
|
|
162
|
+
resource response-outparam {
|
|
163
|
+
@unstable(feature = informational-outbound-responses)
|
|
164
|
+
send-informational: func(
|
|
165
|
+
status: u16,
|
|
166
|
+
headers: headers
|
|
167
|
+
) -> result<_, error-code>;
|
|
168
|
+
set: static func(
|
|
169
|
+
param: response-outparam,
|
|
170
|
+
response: result<outgoing-response, error-code>,
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
type status-code = u16;
|
|
174
|
+
resource incoming-response {
|
|
175
|
+
status: func() -> status-code;
|
|
176
|
+
headers: func() -> headers;
|
|
177
|
+
consume: func() -> result<incoming-body>;
|
|
178
|
+
}
|
|
179
|
+
resource incoming-body {
|
|
180
|
+
%stream: func() -> result<input-stream>;
|
|
181
|
+
finish: static func(this: incoming-body) -> future-trailers;
|
|
182
|
+
}
|
|
183
|
+
resource future-trailers {
|
|
184
|
+
subscribe: func() -> pollable;
|
|
185
|
+
get: func() -> option<result<result<option<trailers>, error-code>>>;
|
|
186
|
+
}
|
|
187
|
+
resource outgoing-response {
|
|
188
|
+
constructor(headers: headers);
|
|
189
|
+
status-code: func() -> status-code;
|
|
190
|
+
set-status-code: func(status-code: status-code) -> result;
|
|
191
|
+
headers: func() -> headers;
|
|
192
|
+
body: func() -> result<outgoing-body>;
|
|
193
|
+
}
|
|
194
|
+
resource outgoing-body {
|
|
195
|
+
write: func() -> result<output-stream>;
|
|
196
|
+
finish: static func(
|
|
197
|
+
this: outgoing-body,
|
|
198
|
+
trailers: option<trailers>
|
|
199
|
+
) -> result<_, error-code>;
|
|
200
|
+
}
|
|
201
|
+
resource future-incoming-response {
|
|
202
|
+
subscribe: func() -> pollable;
|
|
203
|
+
get: func() -> option<result<result<incoming-response, error-code>>>;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
package wasi:io@0.2.12;
|
|
2
|
+
interface error {
|
|
3
|
+
resource error {
|
|
4
|
+
to-debug-string: func() -> string;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
interface poll {
|
|
8
|
+
resource pollable {
|
|
9
|
+
ready: func() -> bool;
|
|
10
|
+
block: func();
|
|
11
|
+
}
|
|
12
|
+
poll: func(in: list<borrow<pollable>>) -> list<u32>;
|
|
13
|
+
}
|
|
14
|
+
interface streams {
|
|
15
|
+
use error.{error};
|
|
16
|
+
use poll.{pollable};
|
|
17
|
+
variant stream-error {
|
|
18
|
+
last-operation-failed(error),
|
|
19
|
+
closed
|
|
20
|
+
}
|
|
21
|
+
resource input-stream {
|
|
22
|
+
read: func(
|
|
23
|
+
len: u64
|
|
24
|
+
) -> result<list<u8>, stream-error>;
|
|
25
|
+
blocking-read: func(
|
|
26
|
+
len: u64
|
|
27
|
+
) -> result<list<u8>, stream-error>;
|
|
28
|
+
skip: func(
|
|
29
|
+
len: u64,
|
|
30
|
+
) -> result<u64, stream-error>;
|
|
31
|
+
blocking-skip: func(
|
|
32
|
+
len: u64,
|
|
33
|
+
) -> result<u64, stream-error>;
|
|
34
|
+
subscribe: func() -> pollable;
|
|
35
|
+
}
|
|
36
|
+
resource output-stream {
|
|
37
|
+
check-write: func() -> result<u64, stream-error>;
|
|
38
|
+
write: func(
|
|
39
|
+
contents: list<u8>
|
|
40
|
+
) -> result<_, stream-error>;
|
|
41
|
+
blocking-write-and-flush: func(
|
|
42
|
+
contents: list<u8>
|
|
43
|
+
) -> result<_, stream-error>;
|
|
44
|
+
flush: func() -> result<_, stream-error>;
|
|
45
|
+
blocking-flush: func() -> result<_, stream-error>;
|
|
46
|
+
subscribe: func() -> pollable;
|
|
47
|
+
write-zeroes: func(
|
|
48
|
+
len: u64
|
|
49
|
+
) -> result<_, stream-error>;
|
|
50
|
+
blocking-write-zeroes-and-flush: func(
|
|
51
|
+
len: u64
|
|
52
|
+
) -> result<_, stream-error>;
|
|
53
|
+
splice: func(
|
|
54
|
+
src: borrow<input-stream>,
|
|
55
|
+
len: u64,
|
|
56
|
+
) -> result<u64, stream-error>;
|
|
57
|
+
blocking-splice: func(
|
|
58
|
+
src: borrow<input-stream>,
|
|
59
|
+
len: u64,
|
|
60
|
+
) -> result<u64, stream-error>;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
world imports {
|
|
64
|
+
import streams;
|
|
65
|
+
import poll;
|
|
66
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package wasi:random@0.2.12;
|
|
2
|
+
interface insecure-seed {
|
|
3
|
+
insecure-seed: func() -> tuple<u64, u64>;
|
|
4
|
+
}
|
|
5
|
+
interface insecure {
|
|
6
|
+
get-insecure-random-bytes: func(len: u64) -> list<u8>;
|
|
7
|
+
get-insecure-random-u64: func() -> u64;
|
|
8
|
+
}
|
|
9
|
+
interface random {
|
|
10
|
+
get-random-bytes: func(len: u64) -> list<u8>;
|
|
11
|
+
get-random-u64: func() -> u64;
|
|
12
|
+
}
|
|
13
|
+
world imports {
|
|
14
|
+
import random;
|
|
15
|
+
import insecure;
|
|
16
|
+
import insecure-seed;
|
|
17
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
package wasi:sockets@0.2.12;
|
|
2
|
+
interface instance-network {
|
|
3
|
+
use network.{network};
|
|
4
|
+
instance-network: func() -> network;
|
|
5
|
+
}
|
|
6
|
+
interface ip-name-lookup {
|
|
7
|
+
use wasi:io/poll@0.2.12.{pollable};
|
|
8
|
+
use network.{network, error-code, ip-address};
|
|
9
|
+
resolve-addresses: func(network: borrow<network>, name: string) -> result<resolve-address-stream, error-code>;
|
|
10
|
+
resource resolve-address-stream {
|
|
11
|
+
resolve-next-address: func() -> result<option<ip-address>, error-code>;
|
|
12
|
+
subscribe: func() -> pollable;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
interface network {
|
|
16
|
+
@unstable(feature = network-error-code)
|
|
17
|
+
use wasi:io/error@0.2.12.{error};
|
|
18
|
+
resource network;
|
|
19
|
+
enum error-code {
|
|
20
|
+
unknown,
|
|
21
|
+
access-denied,
|
|
22
|
+
not-supported,
|
|
23
|
+
invalid-argument,
|
|
24
|
+
out-of-memory,
|
|
25
|
+
timeout,
|
|
26
|
+
concurrency-conflict,
|
|
27
|
+
not-in-progress,
|
|
28
|
+
would-block,
|
|
29
|
+
invalid-state,
|
|
30
|
+
new-socket-limit,
|
|
31
|
+
address-not-bindable,
|
|
32
|
+
address-in-use,
|
|
33
|
+
remote-unreachable,
|
|
34
|
+
connection-refused,
|
|
35
|
+
connection-reset,
|
|
36
|
+
connection-aborted,
|
|
37
|
+
datagram-too-large,
|
|
38
|
+
name-unresolvable,
|
|
39
|
+
temporary-resolver-failure,
|
|
40
|
+
permanent-resolver-failure,
|
|
41
|
+
}
|
|
42
|
+
@unstable(feature = network-error-code)
|
|
43
|
+
network-error-code: func(err: borrow<error>) -> option<error-code>;
|
|
44
|
+
enum ip-address-family {
|
|
45
|
+
ipv4,
|
|
46
|
+
ipv6,
|
|
47
|
+
}
|
|
48
|
+
type ipv4-address = tuple<u8, u8, u8, u8>;
|
|
49
|
+
type ipv6-address = tuple<u16, u16, u16, u16, u16, u16, u16, u16>;
|
|
50
|
+
variant ip-address {
|
|
51
|
+
ipv4(ipv4-address),
|
|
52
|
+
ipv6(ipv6-address),
|
|
53
|
+
}
|
|
54
|
+
record ipv4-socket-address {
|
|
55
|
+
port: u16,
|
|
56
|
+
address: ipv4-address,
|
|
57
|
+
}
|
|
58
|
+
record ipv6-socket-address {
|
|
59
|
+
port: u16,
|
|
60
|
+
flow-info: u32,
|
|
61
|
+
address: ipv6-address,
|
|
62
|
+
scope-id: u32,
|
|
63
|
+
}
|
|
64
|
+
variant ip-socket-address {
|
|
65
|
+
ipv4(ipv4-socket-address),
|
|
66
|
+
ipv6(ipv6-socket-address),
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
interface tcp-create-socket {
|
|
70
|
+
use network.{network, error-code, ip-address-family};
|
|
71
|
+
use tcp.{tcp-socket};
|
|
72
|
+
create-tcp-socket: func(address-family: ip-address-family) -> result<tcp-socket, error-code>;
|
|
73
|
+
}
|
|
74
|
+
interface tcp {
|
|
75
|
+
use wasi:io/streams@0.2.12.{input-stream, output-stream};
|
|
76
|
+
use wasi:io/poll@0.2.12.{pollable};
|
|
77
|
+
use wasi:clocks/monotonic-clock@0.2.12.{duration};
|
|
78
|
+
use network.{network, error-code, ip-socket-address, ip-address-family};
|
|
79
|
+
enum shutdown-type {
|
|
80
|
+
receive,
|
|
81
|
+
send,
|
|
82
|
+
both,
|
|
83
|
+
}
|
|
84
|
+
resource tcp-socket {
|
|
85
|
+
start-bind: func(network: borrow<network>, local-address: ip-socket-address) -> result<_, error-code>;
|
|
86
|
+
finish-bind: func() -> result<_, error-code>;
|
|
87
|
+
start-connect: func(network: borrow<network>, remote-address: ip-socket-address) -> result<_, error-code>;
|
|
88
|
+
finish-connect: func() -> result<tuple<input-stream, output-stream>, error-code>;
|
|
89
|
+
start-listen: func() -> result<_, error-code>;
|
|
90
|
+
finish-listen: func() -> result<_, error-code>;
|
|
91
|
+
accept: func() -> result<tuple<tcp-socket, input-stream, output-stream>, error-code>;
|
|
92
|
+
local-address: func() -> result<ip-socket-address, error-code>;
|
|
93
|
+
remote-address: func() -> result<ip-socket-address, error-code>;
|
|
94
|
+
is-listening: func() -> bool;
|
|
95
|
+
address-family: func() -> ip-address-family;
|
|
96
|
+
set-listen-backlog-size: func(value: u64) -> result<_, error-code>;
|
|
97
|
+
keep-alive-enabled: func() -> result<bool, error-code>;
|
|
98
|
+
set-keep-alive-enabled: func(value: bool) -> result<_, error-code>;
|
|
99
|
+
keep-alive-idle-time: func() -> result<duration, error-code>;
|
|
100
|
+
set-keep-alive-idle-time: func(value: duration) -> result<_, error-code>;
|
|
101
|
+
keep-alive-interval: func() -> result<duration, error-code>;
|
|
102
|
+
set-keep-alive-interval: func(value: duration) -> result<_, error-code>;
|
|
103
|
+
keep-alive-count: func() -> result<u32, error-code>;
|
|
104
|
+
set-keep-alive-count: func(value: u32) -> result<_, error-code>;
|
|
105
|
+
hop-limit: func() -> result<u8, error-code>;
|
|
106
|
+
set-hop-limit: func(value: u8) -> result<_, error-code>;
|
|
107
|
+
receive-buffer-size: func() -> result<u64, error-code>;
|
|
108
|
+
set-receive-buffer-size: func(value: u64) -> result<_, error-code>;
|
|
109
|
+
send-buffer-size: func() -> result<u64, error-code>;
|
|
110
|
+
set-send-buffer-size: func(value: u64) -> result<_, error-code>;
|
|
111
|
+
subscribe: func() -> pollable;
|
|
112
|
+
shutdown: func(shutdown-type: shutdown-type) -> result<_, error-code>;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
interface udp-create-socket {
|
|
116
|
+
use network.{network, error-code, ip-address-family};
|
|
117
|
+
use udp.{udp-socket};
|
|
118
|
+
create-udp-socket: func(address-family: ip-address-family) -> result<udp-socket, error-code>;
|
|
119
|
+
}
|
|
120
|
+
interface udp {
|
|
121
|
+
use wasi:io/poll@0.2.12.{pollable};
|
|
122
|
+
use network.{network, error-code, ip-socket-address, ip-address-family};
|
|
123
|
+
record incoming-datagram {
|
|
124
|
+
data: list<u8>,
|
|
125
|
+
remote-address: ip-socket-address,
|
|
126
|
+
}
|
|
127
|
+
record outgoing-datagram {
|
|
128
|
+
data: list<u8>,
|
|
129
|
+
remote-address: option<ip-socket-address>,
|
|
130
|
+
}
|
|
131
|
+
resource udp-socket {
|
|
132
|
+
start-bind: func(network: borrow<network>, local-address: ip-socket-address) -> result<_, error-code>;
|
|
133
|
+
finish-bind: func() -> result<_, error-code>;
|
|
134
|
+
%stream: func(remote-address: option<ip-socket-address>) -> result<tuple<incoming-datagram-stream, outgoing-datagram-stream>, error-code>;
|
|
135
|
+
local-address: func() -> result<ip-socket-address, error-code>;
|
|
136
|
+
remote-address: func() -> result<ip-socket-address, error-code>;
|
|
137
|
+
address-family: func() -> ip-address-family;
|
|
138
|
+
unicast-hop-limit: func() -> result<u8, error-code>;
|
|
139
|
+
set-unicast-hop-limit: func(value: u8) -> result<_, error-code>;
|
|
140
|
+
receive-buffer-size: func() -> result<u64, error-code>;
|
|
141
|
+
set-receive-buffer-size: func(value: u64) -> result<_, error-code>;
|
|
142
|
+
send-buffer-size: func() -> result<u64, error-code>;
|
|
143
|
+
set-send-buffer-size: func(value: u64) -> result<_, error-code>;
|
|
144
|
+
subscribe: func() -> pollable;
|
|
145
|
+
}
|
|
146
|
+
resource incoming-datagram-stream {
|
|
147
|
+
receive: func(max-results: u64) -> result<list<incoming-datagram>, error-code>;
|
|
148
|
+
subscribe: func() -> pollable;
|
|
149
|
+
}
|
|
150
|
+
resource outgoing-datagram-stream {
|
|
151
|
+
check-send: func() -> result<u64, error-code>;
|
|
152
|
+
send: func(datagrams: list<outgoing-datagram>) -> result<u64, error-code>;
|
|
153
|
+
subscribe: func() -> pollable;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
world imports {
|
|
157
|
+
import instance-network;
|
|
158
|
+
import network;
|
|
159
|
+
import udp;
|
|
160
|
+
import udp-create-socket;
|
|
161
|
+
import tcp;
|
|
162
|
+
import tcp-create-socket;
|
|
163
|
+
import ip-name-lookup;
|
|
164
|
+
}
|