@bytecodealliance/jco 1.32.0 → 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/opt.d.ts.map +1 -1
- package/dist/cmd/opt.js +102 -130
- package/dist/cmd/opt.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 +98 -4
- package/dist/cmd/transpile.js.map +1 -1
- package/dist/common.d.ts +0 -2
- package/dist/common.d.ts.map +1 -1
- package/dist/common.js +0 -9
- package/dist/common.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 -12
- package/dist/ora-shim.d.ts +0 -9
- package/dist/ora-shim.d.ts.map +0 -1
- package/dist/ora-shim.js +0 -10
- package/dist/ora-shim.js.map +0 -1
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
package wasi:sockets@0.2.10;
|
|
2
|
+
|
|
3
|
+
interface network {
|
|
4
|
+
use wasi:io/error@0.2.10.{error};
|
|
5
|
+
|
|
6
|
+
resource network {
|
|
7
|
+
/// Work around a ComponentizeJS 0.22 bindings bug: it omits the wrapper
|
|
8
|
+
/// class for a methodless resource when that resource crosses interfaces.
|
|
9
|
+
/// This method is deliberately never called and can be removed once the
|
|
10
|
+
/// bindings generator handles the canonical methodless WIT declaration.
|
|
11
|
+
noop: func();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
enum error-code {
|
|
15
|
+
unknown,
|
|
16
|
+
access-denied,
|
|
17
|
+
not-supported,
|
|
18
|
+
invalid-argument,
|
|
19
|
+
out-of-memory,
|
|
20
|
+
timeout,
|
|
21
|
+
concurrency-conflict,
|
|
22
|
+
not-in-progress,
|
|
23
|
+
would-block,
|
|
24
|
+
invalid-state,
|
|
25
|
+
new-socket-limit,
|
|
26
|
+
address-not-bindable,
|
|
27
|
+
address-in-use,
|
|
28
|
+
remote-unreachable,
|
|
29
|
+
connection-refused,
|
|
30
|
+
connection-reset,
|
|
31
|
+
connection-aborted,
|
|
32
|
+
datagram-too-large,
|
|
33
|
+
name-unresolvable,
|
|
34
|
+
temporary-resolver-failure,
|
|
35
|
+
permanent-resolver-failure,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
enum ip-address-family { ipv4, ipv6 }
|
|
39
|
+
type ipv4-address = tuple<u8, u8, u8, u8>;
|
|
40
|
+
type ipv6-address = tuple<u16, u16, u16, u16, u16, u16, u16, u16>;
|
|
41
|
+
variant ip-address { ipv4(ipv4-address), ipv6(ipv6-address) }
|
|
42
|
+
|
|
43
|
+
record ipv4-socket-address {
|
|
44
|
+
port: u16,
|
|
45
|
+
address: ipv4-address,
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
record ipv6-socket-address {
|
|
49
|
+
port: u16,
|
|
50
|
+
flow-info: u32,
|
|
51
|
+
address: ipv6-address,
|
|
52
|
+
scope-id: u32,
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
variant ip-socket-address { ipv4(ipv4-socket-address), ipv6(ipv6-socket-address) }
|
|
56
|
+
network-error-code: func(err: borrow<error>) -> option<error-code>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface instance-network {
|
|
60
|
+
use network.{network};
|
|
61
|
+
instance-network: func() -> network;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface udp {
|
|
65
|
+
use wasi:io/poll@0.2.10.{pollable};
|
|
66
|
+
use network.{network, error-code, ip-socket-address, ip-address-family};
|
|
67
|
+
|
|
68
|
+
record incoming-datagram {
|
|
69
|
+
data: list<u8>,
|
|
70
|
+
remote-address: ip-socket-address,
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
record outgoing-datagram {
|
|
74
|
+
data: list<u8>,
|
|
75
|
+
remote-address: option<ip-socket-address>,
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
resource udp-socket {
|
|
79
|
+
start-bind: func(network: borrow<network>, local-address: ip-socket-address) -> result<_, error-code>;
|
|
80
|
+
finish-bind: func() -> result<_, error-code>;
|
|
81
|
+
%stream: func(remote-address: option<ip-socket-address>) -> result<tuple<incoming-datagram-stream, outgoing-datagram-stream>, error-code>;
|
|
82
|
+
local-address: func() -> result<ip-socket-address, error-code>;
|
|
83
|
+
remote-address: func() -> result<ip-socket-address, error-code>;
|
|
84
|
+
address-family: func() -> ip-address-family;
|
|
85
|
+
unicast-hop-limit: func() -> result<u8, error-code>;
|
|
86
|
+
set-unicast-hop-limit: func(value: u8) -> result<_, error-code>;
|
|
87
|
+
receive-buffer-size: func() -> result<u64, error-code>;
|
|
88
|
+
set-receive-buffer-size: func(value: u64) -> result<_, error-code>;
|
|
89
|
+
send-buffer-size: func() -> result<u64, error-code>;
|
|
90
|
+
set-send-buffer-size: func(value: u64) -> result<_, error-code>;
|
|
91
|
+
subscribe: func() -> pollable;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
resource incoming-datagram-stream {
|
|
95
|
+
receive: func(max-results: u64) -> result<list<incoming-datagram>, error-code>;
|
|
96
|
+
subscribe: func() -> pollable;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
resource outgoing-datagram-stream {
|
|
100
|
+
check-send: func() -> result<u64, error-code>;
|
|
101
|
+
send: func(datagrams: list<outgoing-datagram>) -> result<u64, error-code>;
|
|
102
|
+
subscribe: func() -> pollable;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
interface udp-create-socket {
|
|
107
|
+
use network.{network, error-code, ip-address-family};
|
|
108
|
+
use udp.{udp-socket};
|
|
109
|
+
create-udp-socket: func(address-family: ip-address-family) -> result<udp-socket, error-code>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
interface tcp {
|
|
113
|
+
use wasi:io/streams@0.2.10.{input-stream, output-stream};
|
|
114
|
+
use wasi:io/poll@0.2.10.{pollable};
|
|
115
|
+
use wasi:clocks/monotonic-clock@0.2.10.{duration};
|
|
116
|
+
use network.{network, error-code, ip-socket-address, ip-address-family};
|
|
117
|
+
|
|
118
|
+
enum shutdown-type { receive, send, both }
|
|
119
|
+
|
|
120
|
+
resource tcp-socket {
|
|
121
|
+
start-bind: func(network: borrow<network>, local-address: ip-socket-address) -> result<_, error-code>;
|
|
122
|
+
finish-bind: func() -> result<_, error-code>;
|
|
123
|
+
start-connect: func(network: borrow<network>, remote-address: ip-socket-address) -> result<_, error-code>;
|
|
124
|
+
finish-connect: func() -> result<tuple<input-stream, output-stream>, error-code>;
|
|
125
|
+
start-listen: func() -> result<_, error-code>;
|
|
126
|
+
finish-listen: func() -> result<_, error-code>;
|
|
127
|
+
accept: func() -> result<tuple<tcp-socket, input-stream, output-stream>, error-code>;
|
|
128
|
+
local-address: func() -> result<ip-socket-address, error-code>;
|
|
129
|
+
remote-address: func() -> result<ip-socket-address, error-code>;
|
|
130
|
+
is-listening: func() -> bool;
|
|
131
|
+
address-family: func() -> ip-address-family;
|
|
132
|
+
set-listen-backlog-size: func(value: u64) -> result<_, error-code>;
|
|
133
|
+
keep-alive-enabled: func() -> result<bool, error-code>;
|
|
134
|
+
set-keep-alive-enabled: func(value: bool) -> result<_, error-code>;
|
|
135
|
+
keep-alive-idle-time: func() -> result<duration, error-code>;
|
|
136
|
+
set-keep-alive-idle-time: func(value: duration) -> result<_, error-code>;
|
|
137
|
+
keep-alive-interval: func() -> result<duration, error-code>;
|
|
138
|
+
set-keep-alive-interval: func(value: duration) -> result<_, error-code>;
|
|
139
|
+
keep-alive-count: func() -> result<u32, error-code>;
|
|
140
|
+
set-keep-alive-count: func(value: u32) -> result<_, error-code>;
|
|
141
|
+
hop-limit: func() -> result<u8, error-code>;
|
|
142
|
+
set-hop-limit: func(value: u8) -> result<_, error-code>;
|
|
143
|
+
receive-buffer-size: func() -> result<u64, error-code>;
|
|
144
|
+
set-receive-buffer-size: func(value: u64) -> result<_, error-code>;
|
|
145
|
+
send-buffer-size: func() -> result<u64, error-code>;
|
|
146
|
+
set-send-buffer-size: func(value: u64) -> result<_, error-code>;
|
|
147
|
+
subscribe: func() -> pollable;
|
|
148
|
+
shutdown: func(shutdown-type: shutdown-type) -> result<_, error-code>;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
interface tcp-create-socket {
|
|
153
|
+
use network.{network, error-code, ip-address-family};
|
|
154
|
+
use tcp.{tcp-socket};
|
|
155
|
+
create-tcp-socket: func(address-family: ip-address-family) -> result<tcp-socket, error-code>;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
interface ip-name-lookup {
|
|
159
|
+
use wasi:io/poll@0.2.10.{pollable};
|
|
160
|
+
use network.{network, error-code, ip-address};
|
|
161
|
+
|
|
162
|
+
resource resolve-address-stream {
|
|
163
|
+
resolve-next-address: func() -> result<option<ip-address>, error-code>;
|
|
164
|
+
subscribe: func() -> pollable;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
resolve-addresses: func(network: borrow<network>, name: string) -> result<resolve-address-stream, error-code>;
|
|
168
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
package jco:node@0.1.0;
|
|
2
|
+
|
|
3
|
+
interface child-process {
|
|
4
|
+
use types.{env-vars};
|
|
5
|
+
|
|
6
|
+
record process-error {
|
|
7
|
+
name: string,
|
|
8
|
+
message: string,
|
|
9
|
+
code: option<string>,
|
|
10
|
+
errno: option<s32>,
|
|
11
|
+
syscall: option<string>,
|
|
12
|
+
path: option<string>,
|
|
13
|
+
spawnargs: list<string>,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
record spawn-options {
|
|
17
|
+
cwd: option<string>,
|
|
18
|
+
cwd-is-url: bool,
|
|
19
|
+
env: option<env-vars>,
|
|
20
|
+
input: option<list<u8>>,
|
|
21
|
+
timeout: u64,
|
|
22
|
+
kill-signal: string,
|
|
23
|
+
max-buffer: u64,
|
|
24
|
+
shell: option<string>,
|
|
25
|
+
stdio: option<list<string>>,
|
|
26
|
+
windows-hide: bool,
|
|
27
|
+
windows-verbatim-arguments: bool,
|
|
28
|
+
uid: option<u32>,
|
|
29
|
+
gid: option<u32>,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
record spawn-output {
|
|
33
|
+
pid: option<u32>,
|
|
34
|
+
status: option<s32>,
|
|
35
|
+
signal: option<string>,
|
|
36
|
+
stdout: option<list<u8>>,
|
|
37
|
+
stderr: option<list<u8>>,
|
|
38
|
+
error: option<process-error>,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
spawn-sync: func(command: string, args: list<string>, options: spawn-options) -> spawn-output;
|
|
42
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
package jco:node@0.1.0;
|
|
2
|
+
|
|
3
|
+
/// Host-backed adapter for Node's `cluster` module.
|
|
4
|
+
///
|
|
5
|
+
/// WASI has no process model, so unlike Jco's other Node builtins this cannot be a portable
|
|
6
|
+
/// shim. The host owns a real `node:cluster` and this interface exposes just enough of it to
|
|
7
|
+
/// rebuild the observable JS surface guest-side.
|
|
8
|
+
///
|
|
9
|
+
/// Cluster is push-based and WIT is pull-based, so host events are queued and the guest drains
|
|
10
|
+
/// them with `drain-events`. See `docs/src/interop/nodejs-builtins.md` for the delivery-timing
|
|
11
|
+
/// difference this creates.
|
|
12
|
+
interface cluster {
|
|
13
|
+
use types.{env-vars};
|
|
14
|
+
|
|
15
|
+
/// Lifecycle state of a worker, mirroring Node's `worker.state`.
|
|
16
|
+
enum worker-state {
|
|
17
|
+
none,
|
|
18
|
+
online,
|
|
19
|
+
listening,
|
|
20
|
+
disconnected,
|
|
21
|
+
dead,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/// Snapshot of a worker. `process` is deliberately absent: it is a `ChildProcess`, which
|
|
25
|
+
/// cannot cross this boundary. The guest surfaces an explicit error for it instead.
|
|
26
|
+
record worker-info {
|
|
27
|
+
id: u32,
|
|
28
|
+
state: worker-state,
|
|
29
|
+
exited-after-disconnect: bool,
|
|
30
|
+
connected: bool,
|
|
31
|
+
dead: bool,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/// How a worker exited. `signal` is empty when the worker exited normally.
|
|
35
|
+
record exit-info {
|
|
36
|
+
id: u32,
|
|
37
|
+
code: s32,
|
|
38
|
+
signal: string,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/// A message sent by a worker, carried as JSON because WIT has no dynamic value type.
|
|
42
|
+
record message-info {
|
|
43
|
+
id: u32,
|
|
44
|
+
json: string,
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/// Settings the host applies to newly forked workers.
|
|
48
|
+
record settings {
|
|
49
|
+
silent: bool,
|
|
50
|
+
args: list<string>,
|
|
51
|
+
cwd: string,
|
|
52
|
+
scheduling-policy: u8,
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/// An event the host observed since the last drain, in emission order.
|
|
56
|
+
variant event {
|
|
57
|
+
fork(u32),
|
|
58
|
+
online(u32),
|
|
59
|
+
disconnect(u32),
|
|
60
|
+
exit(exit-info),
|
|
61
|
+
message(message-info),
|
|
62
|
+
setup,
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/// Why an operation the guest asked for cannot be carried out.
|
|
66
|
+
variant error {
|
|
67
|
+
/// The runtime has no process model at all (for example, a browser host).
|
|
68
|
+
unsupported(string),
|
|
69
|
+
/// No worker with this id is known.
|
|
70
|
+
no-such-worker(u32),
|
|
71
|
+
/// The host's cluster call failed.
|
|
72
|
+
failed(string),
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/// Whether this instance is the cluster primary. False in a forked worker.
|
|
76
|
+
is-primary: func() -> bool;
|
|
77
|
+
|
|
78
|
+
/// The current worker's info, or none when running as the primary.
|
|
79
|
+
current-worker: func() -> option<worker-info>;
|
|
80
|
+
|
|
81
|
+
/// Fork a worker, re-executing the host entry so the component runs again as a worker.
|
|
82
|
+
fork: func(env: env-vars) -> result<worker-info, error>;
|
|
83
|
+
|
|
84
|
+
/// Every worker the host currently knows about.
|
|
85
|
+
list-workers: func() -> list<worker-info>;
|
|
86
|
+
|
|
87
|
+
/// Re-read one worker, so guest-side state can be refreshed after events.
|
|
88
|
+
get-worker: func(id: u32) -> result<worker-info, error>;
|
|
89
|
+
|
|
90
|
+
/// Send a JSON-encoded message to a worker, or to the primary when called from a worker.
|
|
91
|
+
send: func(id: u32, json: string) -> result<_, error>;
|
|
92
|
+
|
|
93
|
+
/// Disconnect one worker.
|
|
94
|
+
disconnect-worker: func(id: u32) -> result<_, error>;
|
|
95
|
+
|
|
96
|
+
/// Disconnect every worker.
|
|
97
|
+
disconnect-all: func() -> result<_, error>;
|
|
98
|
+
|
|
99
|
+
/// Signal a worker. An empty signal means the host default (`SIGTERM`).
|
|
100
|
+
kill: func(id: u32, signal: string) -> result<_, error>;
|
|
101
|
+
|
|
102
|
+
/// Read the settings the host will apply to new workers.
|
|
103
|
+
get-settings: func() -> settings;
|
|
104
|
+
|
|
105
|
+
/// Apply settings for subsequent forks. Fails for settings the host cannot honour, such as
|
|
106
|
+
/// `exec`, which is the host runner rather than a guest file.
|
|
107
|
+
set-settings: func(value: settings) -> result<_, error>;
|
|
108
|
+
|
|
109
|
+
/// Take every event queued since the last call, oldest first.
|
|
110
|
+
drain-events: func() -> list<event>;
|
|
111
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package jco:node@0.1.0;
|
|
2
|
+
|
|
3
|
+
interface console {
|
|
4
|
+
enum output-destination {
|
|
5
|
+
stdout,
|
|
6
|
+
stderr,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
write: func(destination: output-destination, value: string);
|
|
10
|
+
is-terminal: func(destination: output-destination) -> bool;
|
|
11
|
+
color-depth: func(destination: output-destination) -> u8;
|
|
12
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
package jco:node@0.1.0;
|
|
2
|
+
|
|
3
|
+
/// Typed, runtime-neutral host boundary for Node-compatible DNS operations.
|
|
4
|
+
interface dns {
|
|
5
|
+
enum family {
|
|
6
|
+
unspecified,
|
|
7
|
+
ipv4,
|
|
8
|
+
ipv6,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
enum result-order {
|
|
12
|
+
ipv4-first,
|
|
13
|
+
ipv6-first,
|
|
14
|
+
verbatim,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
variant errno {
|
|
18
|
+
number(s64),
|
|
19
|
+
symbolic(string),
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
record error {
|
|
23
|
+
name: string,
|
|
24
|
+
message: string,
|
|
25
|
+
code: option<string>,
|
|
26
|
+
errno: option<errno>,
|
|
27
|
+
syscall: option<string>,
|
|
28
|
+
hostname: option<string>,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
record resolver-options {
|
|
32
|
+
timeout: option<s32>,
|
|
33
|
+
tries: option<u32>,
|
|
34
|
+
max-timeout: option<u32>,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
record resolver-config {
|
|
38
|
+
options: resolver-options,
|
|
39
|
+
servers: option<list<string>>,
|
|
40
|
+
local-address: option<tuple<string, string>>,
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
record lookup-options {
|
|
44
|
+
family: family,
|
|
45
|
+
hints: u32,
|
|
46
|
+
all: bool,
|
|
47
|
+
order: result-order,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
record lookup-address {
|
|
51
|
+
address: string,
|
|
52
|
+
family: family,
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
record lookup-service-result {
|
|
56
|
+
hostname: string,
|
|
57
|
+
service: string,
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
record address-with-ttl {
|
|
61
|
+
address: string,
|
|
62
|
+
ttl: u32,
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
record caa-record {
|
|
66
|
+
critical: u32,
|
|
67
|
+
issue: option<string>,
|
|
68
|
+
issuewild: option<string>,
|
|
69
|
+
iodef: option<string>,
|
|
70
|
+
contactemail: option<string>,
|
|
71
|
+
contactphone: option<string>,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
record mx-record {
|
|
75
|
+
priority: u32,
|
|
76
|
+
exchange: string,
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
record naptr-record {
|
|
80
|
+
%flags: string,
|
|
81
|
+
service: string,
|
|
82
|
+
regexp: string,
|
|
83
|
+
replacement: string,
|
|
84
|
+
order: u32,
|
|
85
|
+
preference: u32,
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
record soa-record {
|
|
89
|
+
nsname: string,
|
|
90
|
+
hostmaster: string,
|
|
91
|
+
serial: u32,
|
|
92
|
+
refresh: u32,
|
|
93
|
+
retry: u32,
|
|
94
|
+
expire: u32,
|
|
95
|
+
minttl: u32,
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
record srv-record {
|
|
99
|
+
priority: u32,
|
|
100
|
+
weight: u32,
|
|
101
|
+
port: u16,
|
|
102
|
+
name: string,
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
record tlsa-record {
|
|
106
|
+
cert-usage: u8,
|
|
107
|
+
selector: u8,
|
|
108
|
+
match: u8,
|
|
109
|
+
data: list<u8>,
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
variant any-record {
|
|
113
|
+
a(address-with-ttl),
|
|
114
|
+
aaaa(address-with-ttl),
|
|
115
|
+
caa(caa-record),
|
|
116
|
+
cname(string),
|
|
117
|
+
mx(mx-record),
|
|
118
|
+
naptr(naptr-record),
|
|
119
|
+
ns(string),
|
|
120
|
+
ptr(string),
|
|
121
|
+
soa(soa-record),
|
|
122
|
+
srv(srv-record),
|
|
123
|
+
tlsa(tlsa-record),
|
|
124
|
+
txt(list<string>),
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
get-servers: func() -> result<list<string>, error>;
|
|
128
|
+
validate-servers: func(servers: list<string>) -> result<list<string>, error>;
|
|
129
|
+
lookup: func(hostname: string, options: lookup-options) -> result<list<lookup-address>, error>;
|
|
130
|
+
lookup-service: func(address: string, port: u16) -> result<lookup-service-result, error>;
|
|
131
|
+
resolve4: func(hostname: string, ttl: bool, resolver: option<resolver-config>) -> result<list<address-with-ttl>, error>;
|
|
132
|
+
resolve6: func(hostname: string, ttl: bool, resolver: option<resolver-config>) -> result<list<address-with-ttl>, error>;
|
|
133
|
+
resolve-any: func(hostname: string, resolver: option<resolver-config>) -> result<list<any-record>, error>;
|
|
134
|
+
resolve-caa: func(hostname: string, resolver: option<resolver-config>) -> result<list<caa-record>, error>;
|
|
135
|
+
resolve-cname: func(hostname: string, resolver: option<resolver-config>) -> result<list<string>, error>;
|
|
136
|
+
resolve-mx: func(hostname: string, resolver: option<resolver-config>) -> result<list<mx-record>, error>;
|
|
137
|
+
resolve-naptr: func(hostname: string, resolver: option<resolver-config>) -> result<list<naptr-record>, error>;
|
|
138
|
+
resolve-ns: func(hostname: string, resolver: option<resolver-config>) -> result<list<string>, error>;
|
|
139
|
+
resolve-ptr: func(hostname: string, resolver: option<resolver-config>) -> result<list<string>, error>;
|
|
140
|
+
resolve-soa: func(hostname: string, resolver: option<resolver-config>) -> result<soa-record, error>;
|
|
141
|
+
resolve-srv: func(hostname: string, resolver: option<resolver-config>) -> result<list<srv-record>, error>;
|
|
142
|
+
resolve-tlsa: func(hostname: string, resolver: option<resolver-config>) -> result<list<tlsa-record>, error>;
|
|
143
|
+
resolve-txt: func(hostname: string, resolver: option<resolver-config>) -> result<list<list<string>>, error>;
|
|
144
|
+
reverse: func(ip: string, resolver: option<resolver-config>) -> result<list<string>, error>;
|
|
145
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
package jco:node@0.1.0;
|
|
2
|
+
|
|
3
|
+
/// Host-backed adapter for Node's `ffi` module.
|
|
4
|
+
///
|
|
5
|
+
/// `node:ffi` arrived in Node 26.1.0 (Stability 1, behind `--experimental-ffi`), so unlike the
|
|
6
|
+
/// other Node builtins this one has no Node 24 equivalent at all. WASI has nothing like it: there
|
|
7
|
+
/// is no dynamic loader and no host address space to reach. The host owns a real `node:ffi` and
|
|
8
|
+
/// this interface exposes enough of it to rebuild the observable JS surface guest-side.
|
|
9
|
+
///
|
|
10
|
+
/// Pointers cross as `u64` and become JavaScript `bigint`s, matching what Node hands back.
|
|
11
|
+
///
|
|
12
|
+
/// Parts of Node's surface deliberately have no representation here, because a component cannot
|
|
13
|
+
/// express them and a silently wrong answer would be worse than an error. Each is refused
|
|
14
|
+
/// guest-side; see the matching `TODO(ffi)` in jco-std for what lifting it would take.
|
|
15
|
+
///
|
|
16
|
+
/// - **Guest memory has no host address.** `ffi.getRawPointer()` asks for the address of a
|
|
17
|
+
/// JavaScript buffer; guest memory is not mapped into the host, so the guest refuses instead.
|
|
18
|
+
/// - **The host cannot call back into the guest.** `register-callback` would need a `callback`
|
|
19
|
+
/// resource for the trampoline's lifetime *and* a guest export for the host to invoke when
|
|
20
|
+
/// native code fires. Resources alone would not do it: their methods run host-side.
|
|
21
|
+
/// - **Buffer-shaped arguments** would be copied, so a native function writing through the pointer
|
|
22
|
+
/// writes into a copy the guest never sees. Callers pass a `pointer` and use
|
|
23
|
+
/// `read-bytes`/`write-bytes`, which is explicit about the copy. Adding copy-out results to
|
|
24
|
+
/// `call` would make out-parameters work.
|
|
25
|
+
///
|
|
26
|
+
/// The library handle is a `u32` rather than a `resource`, matching `cluster`'s worker ids, which
|
|
27
|
+
/// is the shape componentize-js is known to handle. A resource would give it a drop and remove the
|
|
28
|
+
/// stale-handle case; worth revisiting when guest-side resource support is proven.
|
|
29
|
+
interface ffi {
|
|
30
|
+
/// A value crossing the boundary, tagged by the type it was declared as.
|
|
31
|
+
///
|
|
32
|
+
/// `nothing` is Node's `void`. There is no buffer case on purpose -- see the interface docs.
|
|
33
|
+
variant value {
|
|
34
|
+
nothing,
|
|
35
|
+
boolean(bool),
|
|
36
|
+
int8(s8),
|
|
37
|
+
uint8(u8),
|
|
38
|
+
int16(s16),
|
|
39
|
+
uint16(u16),
|
|
40
|
+
int32(s32),
|
|
41
|
+
uint32(u32),
|
|
42
|
+
int64(s64),
|
|
43
|
+
uint64(u64),
|
|
44
|
+
float32(f32),
|
|
45
|
+
float64(f64),
|
|
46
|
+
pointer(u64),
|
|
47
|
+
text(string),
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/// A failure reported by the host's `node:ffi`, carrying Node's own code where it has one.
|
|
51
|
+
record failure {
|
|
52
|
+
code: string,
|
|
53
|
+
message: string,
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
variant error {
|
|
57
|
+
/// No FFI capability was granted to this component.
|
|
58
|
+
denied(string),
|
|
59
|
+
/// The host runtime has no `node:ffi`: it predates Node 26.1.0, or the flag is missing.
|
|
60
|
+
unavailable(string),
|
|
61
|
+
/// The library handle is not open.
|
|
62
|
+
no-such-library(u32),
|
|
63
|
+
/// The symbol has not been defined on that library.
|
|
64
|
+
no-such-symbol(string),
|
|
65
|
+
/// The signature names a type this boundary cannot carry.
|
|
66
|
+
unsupported-type(string),
|
|
67
|
+
/// The underlying call failed.
|
|
68
|
+
failed(failure),
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/// A function signature. Type names are Node's own: `int32`, `pointer`, `string`, `void`, ...
|
|
72
|
+
record signature {
|
|
73
|
+
arguments: list<string>,
|
|
74
|
+
returns: string,
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/// The host platform's shared-library suffix: `so`, `dylib`, or `dll`.
|
|
78
|
+
suffix: func() -> string;
|
|
79
|
+
|
|
80
|
+
/// Load a shared library. A missing path resolves symbols from the host process image.
|
|
81
|
+
open: func(path: option<string>) -> result<u32, error>;
|
|
82
|
+
|
|
83
|
+
/// Release a library handle.
|
|
84
|
+
close: func(handle: u32) -> result<_, error>;
|
|
85
|
+
|
|
86
|
+
/// Resolve a symbol's address.
|
|
87
|
+
symbol: func(handle: u32, name: string) -> result<u64, error>;
|
|
88
|
+
|
|
89
|
+
/// Declare a function so it can be called. Separate from `call` so a signature is validated
|
|
90
|
+
/// once, where Node validates it, rather than on every invocation.
|
|
91
|
+
define: func(handle: u32, name: string, sig: signature) -> result<_, error>;
|
|
92
|
+
|
|
93
|
+
/// Call a previously declared function.
|
|
94
|
+
call: func(handle: u32, name: string, args: list<value>) -> result<value, error>;
|
|
95
|
+
|
|
96
|
+
/// Read one primitive from host memory. `kind` is a Node type name.
|
|
97
|
+
read: func(pointer: u64, offset: u64, kind: string) -> result<value, error>;
|
|
98
|
+
|
|
99
|
+
/// Write one primitive into host memory.
|
|
100
|
+
write: func(pointer: u64, offset: u64, kind: string, data: value) -> result<_, error>;
|
|
101
|
+
|
|
102
|
+
/// Read a NUL-terminated string. Absent for a null pointer, which is what Node returns.
|
|
103
|
+
read-text: func(pointer: u64) -> result<option<string>, error>;
|
|
104
|
+
|
|
105
|
+
/// Copy bytes out of host memory. Always a copy: a component cannot hold a live view.
|
|
106
|
+
read-bytes: func(pointer: u64, length: u64) -> result<list<u8>, error>;
|
|
107
|
+
|
|
108
|
+
/// Copy bytes into host memory.
|
|
109
|
+
write-bytes: func(pointer: u64, length: u64, data: list<u8>) -> result<_, error>;
|
|
110
|
+
|
|
111
|
+
/// Encode a string into host memory.
|
|
112
|
+
write-text: func(pointer: u64, length: u64, data: string, encoding: string) -> result<_, error>;
|
|
113
|
+
|
|
114
|
+
/// The host's libuv event loop address.
|
|
115
|
+
current-event-loop: func() -> result<u64, error>;
|
|
116
|
+
}
|