@bytecodealliance/jco 1.32.1 → 1.33.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 +12 -1
- package/dist/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -1
- package/dist/bundle.js +7 -0
- package/dist/bundle.js.map +1 -1
- package/dist/cmd/componentize.d.ts +24 -0
- package/dist/cmd/componentize.d.ts.map +1 -1
- package/dist/cmd/componentize.js +82 -8
- package/dist/cmd/componentize.js.map +1 -1
- package/dist/cmd/run.d.ts.map +1 -1
- package/dist/cmd/run.js +58 -1
- package/dist/cmd/run.js.map +1 -1
- package/dist/cmd/transpile.d.ts +5 -1
- package/dist/cmd/transpile.d.ts.map +1 -1
- package/dist/cmd/transpile.js +97 -0
- package/dist/cmd/transpile.js.map +1 -1
- package/dist/jco.js +8 -1
- package/dist/jco.js.map +1 -1
- package/dist/node-builtins.d.ts +127 -0
- package/dist/node-builtins.d.ts.map +1 -0
- package/dist/node-builtins.js +1085 -0
- package/dist/node-builtins.js.map +1 -0
- package/dist/node-wit.d.ts +67 -0
- package/dist/node-wit.d.ts.map +1 -0
- package/dist/node-wit.js +338 -0
- package/dist/node-wit.js.map +1 -0
- package/lib/wasi_snapshot_preview1.command.wasm +0 -0
- package/lib/wasi_snapshot_preview1.reactor.wasm +0 -0
- package/lib/wit/builtin/0.2.10/wasi-clocks/package.wit +35 -0
- package/lib/wit/builtin/0.2.10/wasi-io/package.wit +47 -0
- package/lib/wit/builtin/0.2.10/wasi-sockets/package.wit +168 -0
- package/lib/wit/builtin/jco-node-0.1.0/child-process.wit +42 -0
- package/lib/wit/builtin/jco-node-0.1.0/cluster.wit +111 -0
- package/lib/wit/builtin/jco-node-0.1.0/console.wit +12 -0
- package/lib/wit/builtin/jco-node-0.1.0/dns.wit +145 -0
- package/lib/wit/builtin/jco-node-0.1.0/ffi.wit +116 -0
- package/lib/wit/builtin/jco-node-0.1.0/fs.wit +208 -0
- package/lib/wit/builtin/jco-node-0.1.0/http.wit +144 -0
- package/lib/wit/builtin/jco-node-0.1.0/http2.wit +191 -0
- package/lib/wit/builtin/jco-node-0.1.0/inspector.wit +142 -0
- package/lib/wit/builtin/jco-node-0.1.0/os.wit +120 -0
- package/lib/wit/builtin/jco-node-0.1.0/types.wit +12 -0
- package/package.json +6 -4
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
package jco:node@0.1.0;
|
|
2
|
+
|
|
3
|
+
/// Typed, runtime-neutral host boundary for the supported Node filesystem API.
|
|
4
|
+
interface fs {
|
|
5
|
+
variant path {
|
|
6
|
+
text(string),
|
|
7
|
+
bytes(list<u8>),
|
|
8
|
+
file-url(string),
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
variant path-or-descriptor {
|
|
12
|
+
path(path),
|
|
13
|
+
descriptor(u32),
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
variant mode {
|
|
17
|
+
number(u32),
|
|
18
|
+
symbolic(string),
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
variant open-mode {
|
|
22
|
+
number(s32),
|
|
23
|
+
symbolic(string),
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
variant errno {
|
|
27
|
+
number(s64),
|
|
28
|
+
symbolic(string),
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
record error {
|
|
32
|
+
name: string,
|
|
33
|
+
message: string,
|
|
34
|
+
code: option<string>,
|
|
35
|
+
errno: option<errno>,
|
|
36
|
+
syscall: option<string>,
|
|
37
|
+
path: option<string>,
|
|
38
|
+
dest: option<string>,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
enum file-type {
|
|
42
|
+
block,
|
|
43
|
+
character,
|
|
44
|
+
directory,
|
|
45
|
+
fifo,
|
|
46
|
+
file,
|
|
47
|
+
socket,
|
|
48
|
+
symlink,
|
|
49
|
+
unknown,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
variant numeric {
|
|
53
|
+
number(f64),
|
|
54
|
+
bigint(s64),
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
record stats {
|
|
58
|
+
dev: numeric,
|
|
59
|
+
ino: numeric,
|
|
60
|
+
mode: numeric,
|
|
61
|
+
nlink: numeric,
|
|
62
|
+
uid: numeric,
|
|
63
|
+
gid: numeric,
|
|
64
|
+
rdev: numeric,
|
|
65
|
+
size: numeric,
|
|
66
|
+
blksize: numeric,
|
|
67
|
+
blocks: numeric,
|
|
68
|
+
atime-ms: numeric,
|
|
69
|
+
mtime-ms: numeric,
|
|
70
|
+
ctime-ms: numeric,
|
|
71
|
+
birthtime-ms: numeric,
|
|
72
|
+
atime-ns: option<s64>,
|
|
73
|
+
mtime-ns: option<s64>,
|
|
74
|
+
ctime-ns: option<s64>,
|
|
75
|
+
birthtime-ns: option<s64>,
|
|
76
|
+
file-type: file-type,
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
record statfs-result {
|
|
80
|
+
%type: numeric,
|
|
81
|
+
bsize: numeric,
|
|
82
|
+
blocks: numeric,
|
|
83
|
+
bfree: numeric,
|
|
84
|
+
bavail: numeric,
|
|
85
|
+
files: numeric,
|
|
86
|
+
ffree: numeric,
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
record dirent {
|
|
90
|
+
name: string,
|
|
91
|
+
parent-path: string,
|
|
92
|
+
file-type: file-type,
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
variant directory-entry {
|
|
96
|
+
name(string),
|
|
97
|
+
dirent(dirent),
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
variant glob-entry {
|
|
101
|
+
path(string),
|
|
102
|
+
dirent(dirent),
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
variant glob-exclude {
|
|
106
|
+
pattern(string),
|
|
107
|
+
patterns(list<string>),
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
record copy-options {
|
|
111
|
+
dereference: bool,
|
|
112
|
+
error-on-exist: bool,
|
|
113
|
+
force: bool,
|
|
114
|
+
preserve-timestamps: bool,
|
|
115
|
+
recursive: bool,
|
|
116
|
+
verbatim-symlinks: bool,
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
record glob-options {
|
|
120
|
+
cwd: option<path>,
|
|
121
|
+
exclude: option<glob-exclude>,
|
|
122
|
+
with-file-types: bool,
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
record mkdir-options {
|
|
126
|
+
recursive: bool,
|
|
127
|
+
mode: option<mode>,
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
record readdir-options {
|
|
131
|
+
recursive: bool,
|
|
132
|
+
with-file-types: bool,
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
record remove-options {
|
|
136
|
+
force: bool,
|
|
137
|
+
max-retries: u32,
|
|
138
|
+
recursive: bool,
|
|
139
|
+
retry-delay: u32,
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
record stat-options {
|
|
143
|
+
bigint: bool,
|
|
144
|
+
throw-if-no-entry: bool,
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
record read-file-options {
|
|
148
|
+
flag: option<string>,
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
record write-file-options {
|
|
152
|
+
flag: option<string>,
|
|
153
|
+
mode: option<mode>,
|
|
154
|
+
flush: bool,
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
record read-result {
|
|
158
|
+
bytes-read: u32,
|
|
159
|
+
data: list<u8>,
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
record readv-result {
|
|
163
|
+
bytes-read: u32,
|
|
164
|
+
buffers: list<list<u8>>,
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
access: func(path: path, mode: s32) -> result<_, error>;
|
|
168
|
+
append-file: func(file: path-or-descriptor, data: list<u8>, options: write-file-options) -> result<_, error>;
|
|
169
|
+
chmod: func(path: path, mode: mode) -> result<_, error>;
|
|
170
|
+
chown: func(path: path, uid: u32, gid: u32) -> result<_, error>;
|
|
171
|
+
close: func(descriptor: u32) -> result<_, error>;
|
|
172
|
+
copy-file: func(source: path, destination: path, mode: s32) -> result<_, error>;
|
|
173
|
+
cp: func(source: path, destination: path, options: copy-options) -> result<_, error>;
|
|
174
|
+
exists: func(path: path) -> result<bool, error>;
|
|
175
|
+
fchmod: func(descriptor: u32, mode: mode) -> result<_, error>;
|
|
176
|
+
fchown: func(descriptor: u32, uid: u32, gid: u32) -> result<_, error>;
|
|
177
|
+
fdatasync: func(descriptor: u32) -> result<_, error>;
|
|
178
|
+
fstat: func(descriptor: u32, options: stat-options) -> result<stats, error>;
|
|
179
|
+
fsync: func(descriptor: u32) -> result<_, error>;
|
|
180
|
+
ftruncate: func(descriptor: u32, length: u32) -> result<_, error>;
|
|
181
|
+
futimes: func(descriptor: u32, atime: f64, mtime: f64) -> result<_, error>;
|
|
182
|
+
glob: func(patterns: list<string>, options: glob-options) -> result<list<glob-entry>, error>;
|
|
183
|
+
lchown: func(path: path, uid: u32, gid: u32) -> result<_, error>;
|
|
184
|
+
link: func(existing-path: path, new-path: path) -> result<_, error>;
|
|
185
|
+
lstat: func(path: path, options: stat-options) -> result<option<stats>, error>;
|
|
186
|
+
lutimes: func(path: path, atime: f64, mtime: f64) -> result<_, error>;
|
|
187
|
+
mkdir: func(path: path, options: mkdir-options) -> result<option<string>, error>;
|
|
188
|
+
mkdtemp: func(prefix: string) -> result<string, error>;
|
|
189
|
+
open: func(path: path, %flags: open-mode, mode: mode) -> result<u32, error>;
|
|
190
|
+
read-file: func(file: path-or-descriptor, options: read-file-options) -> result<list<u8>, error>;
|
|
191
|
+
readdir: func(path: path, options: readdir-options) -> result<list<directory-entry>, error>;
|
|
192
|
+
readlink: func(path: path) -> result<string, error>;
|
|
193
|
+
realpath: func(path: path) -> result<string, error>;
|
|
194
|
+
rename: func(old-path: path, new-path: path) -> result<_, error>;
|
|
195
|
+
rm: func(path: path, options: remove-options) -> result<_, error>;
|
|
196
|
+
rmdir: func(path: path, options: remove-options) -> result<_, error>;
|
|
197
|
+
stat: func(path: path, options: stat-options) -> result<option<stats>, error>;
|
|
198
|
+
statfs: func(path: path, bigint: bool) -> result<statfs-result, error>;
|
|
199
|
+
symlink: func(target: path, path: path, %type: option<string>) -> result<_, error>;
|
|
200
|
+
truncate: func(path: path, length: u32) -> result<_, error>;
|
|
201
|
+
unlink: func(path: path) -> result<_, error>;
|
|
202
|
+
utimes: func(path: path, atime: f64, mtime: f64) -> result<_, error>;
|
|
203
|
+
write-file: func(file: path-or-descriptor, data: list<u8>, options: write-file-options) -> result<_, error>;
|
|
204
|
+
read: func(descriptor: u32, length: u32, position: option<u64>) -> result<read-result, error>;
|
|
205
|
+
write: func(descriptor: u32, data: list<u8>, position: option<u64>) -> result<u32, error>;
|
|
206
|
+
readv: func(descriptor: u32, lengths: list<u32>, position: option<u64>) -> result<readv-result, error>;
|
|
207
|
+
writev: func(descriptor: u32, buffers: list<list<u8>>, position: option<u64>) -> result<u32, error>;
|
|
208
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
package jco:node@0.1.0;
|
|
2
|
+
|
|
3
|
+
/// Guest-owned callback resources used by the direct Node-compatible HTTP implementation.
|
|
4
|
+
interface http-callbacks {
|
|
5
|
+
variant errno {
|
|
6
|
+
number(s64),
|
|
7
|
+
symbolic(string),
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
record error {
|
|
11
|
+
name: string,
|
|
12
|
+
message: string,
|
|
13
|
+
code: option<string>,
|
|
14
|
+
errno: option<errno>,
|
|
15
|
+
syscall: option<string>,
|
|
16
|
+
hostname: option<string>,
|
|
17
|
+
address: option<string>,
|
|
18
|
+
port: option<u16>,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
record header {
|
|
22
|
+
name: string,
|
|
23
|
+
value: list<u8>,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
record incoming-request {
|
|
27
|
+
method: string,
|
|
28
|
+
url: string,
|
|
29
|
+
http-version: string,
|
|
30
|
+
headers: list<header>,
|
|
31
|
+
body: list<u8>,
|
|
32
|
+
remote-address: option<string>,
|
|
33
|
+
remote-port: option<u16>,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
record outgoing-response {
|
|
37
|
+
status-code: u16,
|
|
38
|
+
status-message: string,
|
|
39
|
+
headers: list<header>,
|
|
40
|
+
body: list<u8>,
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
resource request-listener {
|
|
44
|
+
handle: func(request: incoming-request) -> result<outgoing-response, error>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/// Redeem a registration once. The host owns the returned listener until the server closes.
|
|
48
|
+
take-request-listener: func(id: u32) -> option<request-listener>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/// Typed host boundary for Node-compatible HTTP clients and servers.
|
|
52
|
+
interface http {
|
|
53
|
+
variant errno {
|
|
54
|
+
number(s64),
|
|
55
|
+
symbolic(string),
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
record error {
|
|
59
|
+
name: string,
|
|
60
|
+
message: string,
|
|
61
|
+
code: option<string>,
|
|
62
|
+
errno: option<errno>,
|
|
63
|
+
syscall: option<string>,
|
|
64
|
+
hostname: option<string>,
|
|
65
|
+
address: option<string>,
|
|
66
|
+
port: option<u16>,
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
record header {
|
|
70
|
+
name: string,
|
|
71
|
+
value: list<u8>,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
record request-options {
|
|
75
|
+
method: string,
|
|
76
|
+
scheme: string,
|
|
77
|
+
authority: string,
|
|
78
|
+
path-with-query: string,
|
|
79
|
+
headers: list<header>,
|
|
80
|
+
body: list<u8>,
|
|
81
|
+
connect-timeout-ms: option<u32>,
|
|
82
|
+
first-byte-timeout-ms: option<u32>,
|
|
83
|
+
between-bytes-timeout-ms: option<u32>,
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
record response {
|
|
87
|
+
status-code: u16,
|
|
88
|
+
status-message: string,
|
|
89
|
+
http-version: string,
|
|
90
|
+
headers: list<header>,
|
|
91
|
+
body: list<u8>,
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
record server-options {
|
|
95
|
+
request-timeout: option<u32>,
|
|
96
|
+
headers-timeout: option<u32>,
|
|
97
|
+
keep-alive-timeout: option<u32>,
|
|
98
|
+
keep-alive-timeout-buffer: option<u32>,
|
|
99
|
+
connections-checking-interval: option<u32>,
|
|
100
|
+
max-header-size: option<u32>,
|
|
101
|
+
join-duplicate-headers: option<bool>,
|
|
102
|
+
no-delay: option<bool>,
|
|
103
|
+
require-host-header: option<bool>,
|
|
104
|
+
keep-alive: option<bool>,
|
|
105
|
+
keep-alive-initial-delay: option<u32>,
|
|
106
|
+
reject-non-standard-body-writes: option<bool>,
|
|
107
|
+
optimize-empty-requests: option<bool>,
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
record listen-options {
|
|
111
|
+
port: option<u16>,
|
|
112
|
+
host: option<string>,
|
|
113
|
+
backlog: option<u32>,
|
|
114
|
+
path: option<string>,
|
|
115
|
+
exclusive: option<bool>,
|
|
116
|
+
ipv6-only: option<bool>,
|
|
117
|
+
reuse-port: option<bool>,
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
record tcp-address {
|
|
121
|
+
address: string,
|
|
122
|
+
family: string,
|
|
123
|
+
port: u16,
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
variant server-address {
|
|
127
|
+
tcp(tcp-address),
|
|
128
|
+
pipe(string),
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
request: func(options: request-options) -> result<response, error>;
|
|
132
|
+
|
|
133
|
+
resource server {
|
|
134
|
+
constructor(options: server-options, listener: u32);
|
|
135
|
+
listen: func(options: listen-options) -> result<server-address, error>;
|
|
136
|
+
close: func() -> result<bool, error>;
|
|
137
|
+
close-all-connections: func() -> result<_, error>;
|
|
138
|
+
close-idle-connections: func() -> result<_, error>;
|
|
139
|
+
get-connections: func() -> result<u64, error>;
|
|
140
|
+
address: func() -> option<server-address>;
|
|
141
|
+
ref: func();
|
|
142
|
+
unref: func();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/// Guest-owned callbacks used by the direct Node-compatible HTTP/2 implementation.
|
|
2
|
+
interface http2-callbacks {
|
|
3
|
+
variant errno {
|
|
4
|
+
number(s64),
|
|
5
|
+
symbolic(string),
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
record error {
|
|
9
|
+
name: string,
|
|
10
|
+
message: string,
|
|
11
|
+
code: option<string>,
|
|
12
|
+
errno: option<errno>,
|
|
13
|
+
syscall: option<string>,
|
|
14
|
+
hostname: option<string>,
|
|
15
|
+
address: option<string>,
|
|
16
|
+
port: option<u16>,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
record header {
|
|
20
|
+
name: string,
|
|
21
|
+
value: list<u8>,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
record incoming-stream {
|
|
25
|
+
session-id: u32,
|
|
26
|
+
id: u32,
|
|
27
|
+
headers: list<header>,
|
|
28
|
+
body: list<u8>,
|
|
29
|
+
remote-address: option<string>,
|
|
30
|
+
remote-port: option<u16>,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
record outgoing-response {
|
|
34
|
+
headers: list<header>,
|
|
35
|
+
body: list<u8>,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
resource stream-listener {
|
|
39
|
+
handle: func(input: incoming-stream) -> result<outgoing-response, error>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
resource server-error-listener {
|
|
43
|
+
handle: func(reason: error);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/// Redeem each registration once; the host owns the resources until the server closes.
|
|
47
|
+
take-stream-listener: func(id: u32) -> option<stream-listener>;
|
|
48
|
+
take-server-error-listener: func(id: u32) -> option<server-error-listener>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/// Typed host boundary for Node-compatible HTTP/2 clients and servers.
|
|
52
|
+
interface http2 {
|
|
53
|
+
variant errno {
|
|
54
|
+
number(s64),
|
|
55
|
+
symbolic(string),
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
record error {
|
|
59
|
+
name: string,
|
|
60
|
+
message: string,
|
|
61
|
+
code: option<string>,
|
|
62
|
+
errno: option<errno>,
|
|
63
|
+
syscall: option<string>,
|
|
64
|
+
hostname: option<string>,
|
|
65
|
+
address: option<string>,
|
|
66
|
+
port: option<u16>,
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
record header {
|
|
70
|
+
name: string,
|
|
71
|
+
value: list<u8>,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
record custom-setting {
|
|
75
|
+
id: u16,
|
|
76
|
+
value: u32,
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
record http2-settings {
|
|
80
|
+
header-table-size: option<u32>,
|
|
81
|
+
enable-push: option<bool>,
|
|
82
|
+
initial-window-size: option<u32>,
|
|
83
|
+
max-frame-size: option<u32>,
|
|
84
|
+
max-concurrent-streams: option<u32>,
|
|
85
|
+
max-header-list-size: option<u32>,
|
|
86
|
+
enable-connect-protocol: option<bool>,
|
|
87
|
+
custom-settings: list<custom-setting>,
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
record client-options {
|
|
91
|
+
settings: http2-settings,
|
|
92
|
+
reject-unauthorized: option<bool>,
|
|
93
|
+
server-name: option<string>,
|
|
94
|
+
ca: option<list<u8>>,
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
record request-options {
|
|
98
|
+
end-stream: option<bool>,
|
|
99
|
+
wait-for-trailers: option<bool>,
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
record response {
|
|
103
|
+
headers: list<header>,
|
|
104
|
+
trailers: list<header>,
|
|
105
|
+
body: list<u8>,
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
record stream-state {
|
|
109
|
+
state: option<u32>,
|
|
110
|
+
local-window-size: option<u32>,
|
|
111
|
+
local-close: option<u32>,
|
|
112
|
+
remote-close: option<u32>,
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
record ping-response {
|
|
116
|
+
duration-ms: f64,
|
|
117
|
+
payload: list<u8>,
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
record session-info {
|
|
121
|
+
alpn-protocol: option<string>,
|
|
122
|
+
encrypted: bool,
|
|
123
|
+
local-settings: http2-settings,
|
|
124
|
+
remote-settings: http2-settings,
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
record server-options {
|
|
128
|
+
secure: bool,
|
|
129
|
+
key: option<list<u8>>,
|
|
130
|
+
cert: option<list<u8>>,
|
|
131
|
+
settings: http2-settings,
|
|
132
|
+
allow-http1: option<bool>,
|
|
133
|
+
strict-field-whitespace-validation: option<bool>,
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
record listen-options {
|
|
137
|
+
port: option<u16>,
|
|
138
|
+
host: option<string>,
|
|
139
|
+
backlog: option<u32>,
|
|
140
|
+
path: option<string>,
|
|
141
|
+
exclusive: option<bool>,
|
|
142
|
+
ipv6-only: option<bool>,
|
|
143
|
+
reuse-port: option<bool>,
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
record tcp-address {
|
|
147
|
+
address: string,
|
|
148
|
+
family: string,
|
|
149
|
+
port: u16,
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
variant server-address {
|
|
153
|
+
tcp(tcp-address),
|
|
154
|
+
pipe(string),
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
resource client-stream {
|
|
158
|
+
write: func(chunk: list<u8>) -> result<bool, error>;
|
|
159
|
+
finish: func() -> result<response, error>;
|
|
160
|
+
close: func(code: u32) -> result<_, error>;
|
|
161
|
+
id: func() -> option<u32>;
|
|
162
|
+
state: func() -> stream-state;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
resource client-session {
|
|
166
|
+
constructor(authority: string, options: client-options);
|
|
167
|
+
ready: func() -> result<session-info, error>;
|
|
168
|
+
request: func(headers: list<header>, options: request-options) -> result<own<client-stream>, error>;
|
|
169
|
+
close: func() -> result<_, error>;
|
|
170
|
+
destroy: func(code: u32) -> result<_, error>;
|
|
171
|
+
settings: func(settings: http2-settings) -> result<http2-settings, error>;
|
|
172
|
+
ping: func(payload: list<u8>) -> result<ping-response, error>;
|
|
173
|
+
goaway: func(code: u32, last-stream-id: option<u32>, opaque-data: list<u8>) -> result<_, error>;
|
|
174
|
+
ref: func();
|
|
175
|
+
unref: func();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
resource server {
|
|
179
|
+
constructor(
|
|
180
|
+
options: server-options,
|
|
181
|
+
listener: u32,
|
|
182
|
+
error-listener: u32,
|
|
183
|
+
);
|
|
184
|
+
listen: func(options: listen-options) -> result<server-address, error>;
|
|
185
|
+
close: func() -> result<bool, error>;
|
|
186
|
+
address: func() -> option<server-address>;
|
|
187
|
+
update-settings: func(settings: http2-settings) -> result<_, error>;
|
|
188
|
+
ref: func();
|
|
189
|
+
unref: func();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
package jco:node@0.1.0;
|
|
2
|
+
|
|
3
|
+
/// Host-backed adapter for Node's `inspector` module (and `inspector/promises`).
|
|
4
|
+
///
|
|
5
|
+
/// The inspector is host machinery by definition: a V8 WebSocket server and a Chrome DevTools
|
|
6
|
+
/// Protocol dispatcher wired into the running isolate. WASI expresses none of it, so unlike Jco's
|
|
7
|
+
/// portable shims every observable operation forwards to the host's real `node:inspector` over
|
|
8
|
+
/// this interface. Guest-side code owns Node-faithful argument validation, session state, the
|
|
9
|
+
/// `EventEmitter` surface, and error reconstruction; the host owns the V8 machinery.
|
|
10
|
+
///
|
|
11
|
+
/// Protocol payloads are JSON by definition (CDP), so `session-post`, notifications, and the
|
|
12
|
+
/// broadcast namespaces carry their parameters and results as JSON strings without loss. The
|
|
13
|
+
/// `console` forwarder JSON-encodes its arguments, which is lossy for functions, symbols, and
|
|
14
|
+
/// cycles -- best-effort, and documented as such guest-side.
|
|
15
|
+
///
|
|
16
|
+
/// Callbacks run the other way: the host must call back into the component when a protocol
|
|
17
|
+
/// response or a notification arrives. A component cannot implement a resource declared in an
|
|
18
|
+
/// *imported* interface -- its methods would run host-side -- so the callback resources live in the
|
|
19
|
+
/// guest-*exported* `inspector-callbacks` interface below. This import carries only a `u32`
|
|
20
|
+
/// callback id; the host redeems it for an owned resource handle through the exported `take-*`
|
|
21
|
+
/// functions and invokes the resource method to re-enter the guest. The host must never do so while
|
|
22
|
+
/// a guest->host call is still on the stack (component re-entrance); the Node adapter queues
|
|
23
|
+
/// deliveries and flushes them on a later turn, which makes guest-side callbacks always
|
|
24
|
+
/// asynchronous even where Node fires them synchronously. Node does not promise synchronous
|
|
25
|
+
/// delivery.
|
|
26
|
+
///
|
|
27
|
+
/// The one exception is a `session-post` whose CDP command resolves in-isolate: the host returns
|
|
28
|
+
/// that response directly from the import call, so the promise-based `Session.post` can `await` it
|
|
29
|
+
/// without any callback re-entering a suspended task. The `post-callback` resource remains for
|
|
30
|
+
/// genuinely deferred responses, and notifications arrive between guest tasks.
|
|
31
|
+
///
|
|
32
|
+
/// Session ids are `u32` allocated guest-side (like `cluster`'s worker ids), so `new Session()`
|
|
33
|
+
/// touches no host state. Deny-by-default: declaring the import grants nothing; an application
|
|
34
|
+
/// opts in by mapping the interface to a host adapter at transpile time.
|
|
35
|
+
interface inspector {
|
|
36
|
+
/// A failure reported by the host, carrying Node's own error code where it has one.
|
|
37
|
+
record failure {
|
|
38
|
+
code: string,
|
|
39
|
+
message: string,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/// Why an operation the guest asked for cannot be carried out.
|
|
43
|
+
variant error {
|
|
44
|
+
/// No inspector capability was granted to this component.
|
|
45
|
+
denied(string),
|
|
46
|
+
/// The host runtime has no usable `node:inspector` (for example, a browser host).
|
|
47
|
+
unavailable(string),
|
|
48
|
+
/// No session with this id is connected.
|
|
49
|
+
no-such-session(u32),
|
|
50
|
+
/// The host's inspector call failed.
|
|
51
|
+
failed(failure),
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/// Which inspector a session attaches to. `main-thread` is `connectToMainThread`, valid only
|
|
55
|
+
/// from a worker.
|
|
56
|
+
enum connect-kind {
|
|
57
|
+
local,
|
|
58
|
+
main-thread,
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/// Which experimental broadcast namespace an `emit` targets.
|
|
62
|
+
enum broadcast-target {
|
|
63
|
+
network,
|
|
64
|
+
dom-storage,
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/// Activate the inspector, optionally waiting for a client to attach before returning.
|
|
68
|
+
open: func(port: option<u32>, host: option<string>, wait: bool) -> result<_, error>;
|
|
69
|
+
|
|
70
|
+
/// Deactivate the inspector.
|
|
71
|
+
close: func() -> result<_, error>;
|
|
72
|
+
|
|
73
|
+
/// The active inspector WebSocket URL, or none when it is not active.
|
|
74
|
+
url: func() -> result<option<string>, error>;
|
|
75
|
+
|
|
76
|
+
/// Block until a client has connected and is ready to step. Requires an active inspector.
|
|
77
|
+
wait-for-debugger: func() -> result<_, error>;
|
|
78
|
+
|
|
79
|
+
/// Emit through the inspector's own `console`, optionally into a named context. `args-json` is
|
|
80
|
+
/// the JSON-encoded argument list.
|
|
81
|
+
console-call: func(context: option<string>, method: string, args-json: string) -> result<_, error>;
|
|
82
|
+
|
|
83
|
+
/// Connect a session. `listener` is the id of the guest-exported `notification-listener` the
|
|
84
|
+
/// host redeems once and keeps for the session's lifetime, calling it per notification.
|
|
85
|
+
session-connect: func(session: u32, kind: connect-kind, listener: u32) -> result<_, error>;
|
|
86
|
+
|
|
87
|
+
/// The outcome of a CDP command the host resolved synchronously.
|
|
88
|
+
///
|
|
89
|
+
/// In-isolate protocol methods (`Runtime.evaluate`, `Debugger.*`, ...) resolve during the post
|
|
90
|
+
/// call, so their response is returned directly. This matters beyond efficiency: a guest that
|
|
91
|
+
/// `await`s the result would otherwise need the host to call back in while the guest is
|
|
92
|
+
/// suspended, which the component model forbids.
|
|
93
|
+
variant command-response {
|
|
94
|
+
/// Success: the JSON-encoded CDP result, absent when the result is empty.
|
|
95
|
+
ok(option<string>),
|
|
96
|
+
/// Failure: the protocol error, carrying Node's `ERR_INSPECTOR_COMMAND` code.
|
|
97
|
+
failed(failure),
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/// Post a CDP command on a session.
|
|
101
|
+
///
|
|
102
|
+
/// Returns `some(response)` when the command resolved synchronously (the common case), `none`
|
|
103
|
+
/// when the response is deferred. For a deferred response, if `callback` is present it is the id
|
|
104
|
+
/// of a guest-exported `post-callback` the host redeems and calls once the response arrives. A
|
|
105
|
+
/// guest must not `await` a deferred response -- delivery would re-enter a suspended task -- so
|
|
106
|
+
/// the promise-based `Session.post` only awaits synchronous responses.
|
|
107
|
+
session-post: func(session: u32, method: string, params-json: option<string>, callback: option<u32>) -> result<option<command-response>, error>;
|
|
108
|
+
|
|
109
|
+
/// Disconnect a session, releasing its notification listener.
|
|
110
|
+
session-disconnect: func(session: u32) -> result<_, error>;
|
|
111
|
+
|
|
112
|
+
/// Feed one event to an experimental broadcast namespace (`Network`, `DOMStorage`). `params-json`
|
|
113
|
+
/// is the JSON-encoded parameter object.
|
|
114
|
+
emit: func(target: broadcast-target, event: string, params-json: string) -> result<_, error>;
|
|
115
|
+
|
|
116
|
+
/// Register a network resource for the inspector to serve (`NetworkResources.put`).
|
|
117
|
+
put-network-resource: func(url: string, data: string) -> result<_, error>;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/// Callback channel the host uses to re-enter the component. Guest-*exported*: the component owns
|
|
121
|
+
/// the resource implementations, and the host redeems ids for handles through the `take-*`
|
|
122
|
+
/// functions. See the `inspector` interface docs for why the callbacks cannot live on the import.
|
|
123
|
+
interface inspector-callbacks {
|
|
124
|
+
/// A one-shot response to a `session-post`, matching Node's `(err, result)` callback.
|
|
125
|
+
resource post-callback {
|
|
126
|
+
/// Deliver the response. `error-json` is a JSON `{ code, message }` when the command
|
|
127
|
+
/// failed, otherwise absent; `result-json` is the JSON-encoded CDP result on success.
|
|
128
|
+
done: func(error-json: option<string>, result-json: option<string>);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/// The long-lived channel for one connected session's notifications.
|
|
132
|
+
resource notification-listener {
|
|
133
|
+
/// Deliver one CDP notification. `params-json` is the JSON-encoded parameter object.
|
|
134
|
+
notify: func(method: string, params-json: string);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/// Redeem a `session-post` callback id for its resource. Absent if the id is unknown.
|
|
138
|
+
take-post-callback: func(id: u32) -> option<post-callback>;
|
|
139
|
+
|
|
140
|
+
/// Redeem a session's notification-listener id for its resource. Absent if the id is unknown.
|
|
141
|
+
take-notification-listener: func(id: u32) -> option<notification-listener>;
|
|
142
|
+
}
|