Skip to content

Commit 20ceedc

Browse files
committed
chore: vendor p3 WIT
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
1 parent e0e8f90 commit 20ceedc

23 files changed

+1874
-0
lines changed

ci/vendor-wit.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ make_vendor "wasi-config" "config@f4d699b"
6868

6969
make_vendor "wasi-keyvalue" "keyvalue@219ea36"
7070

71+
make_vendor "wasi/src/p3" "
72+
cli@939bd6d@wit-0.3.0-draft
73+
clocks@13d1c82@wit-0.3.0-draft
74+
filesystem@e2a2ddc@wit-0.3.0-draft
75+
random@4e94663@wit-0.3.0-draft
76+
sockets@bb247e2@wit-0.3.0-draft
77+
"
78+
7179
rm -rf $cache_dir
7280

7381
# Separately (for now), vendor the `wasi-nn` WIT files since their retrieval is
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package wasi:cli@0.3.0;
2+
3+
@since(version = 0.3.0)
4+
world command {
5+
@since(version = 0.3.0)
6+
include imports;
7+
8+
@since(version = 0.3.0)
9+
export run;
10+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@since(version = 0.3.0)
2+
interface environment {
3+
/// Get the POSIX-style environment variables.
4+
///
5+
/// Each environment variable is provided as a pair of string variable names
6+
/// and string value.
7+
///
8+
/// Morally, these are a value import, but until value imports are available
9+
/// in the component model, this import function should return the same
10+
/// values each time it is called.
11+
@since(version = 0.3.0)
12+
get-environment: func() -> list<tuple<string, string>>;
13+
14+
/// Get the POSIX-style arguments to the program.
15+
@since(version = 0.3.0)
16+
get-arguments: func() -> list<string>;
17+
18+
/// Return a path that programs should use as their initial current working
19+
/// directory, interpreting `.` as shorthand for this.
20+
@since(version = 0.3.0)
21+
initial-cwd: func() -> option<string>;
22+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@since(version = 0.3.0)
2+
interface exit {
3+
/// Exit the current instance and any linked instances.
4+
@since(version = 0.3.0)
5+
exit: func(status: result);
6+
7+
/// Exit the current instance and any linked instances, reporting the
8+
/// specified status code to the host.
9+
///
10+
/// The meaning of the code depends on the context, with 0 usually meaning
11+
/// "success", and other values indicating various types of failure.
12+
///
13+
/// This function does not return; the effect is analogous to a trap, but
14+
/// without the connotation that something bad has happened.
15+
@unstable(feature = cli-exit-with-code)
16+
exit-with-code: func(status-code: u8);
17+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package wasi:cli@0.3.0;
2+
3+
@since(version = 0.3.0)
4+
world imports {
5+
@since(version = 0.3.0)
6+
include wasi:clocks/imports@0.3.0;
7+
@since(version = 0.3.0)
8+
include wasi:filesystem/imports@0.3.0;
9+
@since(version = 0.3.0)
10+
include wasi:sockets/imports@0.3.0;
11+
@since(version = 0.3.0)
12+
include wasi:random/imports@0.3.0;
13+
14+
@since(version = 0.3.0)
15+
import environment;
16+
@since(version = 0.3.0)
17+
import exit;
18+
@since(version = 0.3.0)
19+
import stdin;
20+
@since(version = 0.3.0)
21+
import stdout;
22+
@since(version = 0.3.0)
23+
import stderr;
24+
@since(version = 0.3.0)
25+
import terminal-input;
26+
@since(version = 0.3.0)
27+
import terminal-output;
28+
@since(version = 0.3.0)
29+
import terminal-stdin;
30+
@since(version = 0.3.0)
31+
import terminal-stdout;
32+
@since(version = 0.3.0)
33+
import terminal-stderr;
34+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@since(version = 0.3.0)
2+
interface run {
3+
/// Run the program.
4+
@since(version = 0.3.0)
5+
run: func() -> result;
6+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@since(version = 0.3.0)
2+
interface stdin {
3+
@since(version = 0.3.0)
4+
get-stdin: func() -> stream<u8>;
5+
}
6+
7+
@since(version = 0.3.0)
8+
interface stdout {
9+
@since(version = 0.3.0)
10+
set-stdout: func(data: stream<u8>);
11+
}
12+
13+
@since(version = 0.3.0)
14+
interface stderr {
15+
@since(version = 0.3.0)
16+
set-stderr: func(data: stream<u8>);
17+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/// Terminal input.
2+
///
3+
/// In the future, this may include functions for disabling echoing,
4+
/// disabling input buffering so that keyboard events are sent through
5+
/// immediately, querying supported features, and so on.
6+
@since(version = 0.3.0)
7+
interface terminal-input {
8+
/// The input side of a terminal.
9+
@since(version = 0.3.0)
10+
resource terminal-input;
11+
}
12+
13+
/// Terminal output.
14+
///
15+
/// In the future, this may include functions for querying the terminal
16+
/// size, being notified of terminal size changes, querying supported
17+
/// features, and so on.
18+
@since(version = 0.3.0)
19+
interface terminal-output {
20+
/// The output side of a terminal.
21+
@since(version = 0.3.0)
22+
resource terminal-output;
23+
}
24+
25+
/// An interface providing an optional `terminal-input` for stdin as a
26+
/// link-time authority.
27+
@since(version = 0.3.0)
28+
interface terminal-stdin {
29+
@since(version = 0.3.0)
30+
use terminal-input.{terminal-input};
31+
32+
/// If stdin is connected to a terminal, return a `terminal-input` handle
33+
/// allowing further interaction with it.
34+
@since(version = 0.3.0)
35+
get-terminal-stdin: func() -> option<terminal-input>;
36+
}
37+
38+
/// An interface providing an optional `terminal-output` for stdout as a
39+
/// link-time authority.
40+
@since(version = 0.3.0)
41+
interface terminal-stdout {
42+
@since(version = 0.3.0)
43+
use terminal-output.{terminal-output};
44+
45+
/// If stdout is connected to a terminal, return a `terminal-output` handle
46+
/// allowing further interaction with it.
47+
@since(version = 0.3.0)
48+
get-terminal-stdout: func() -> option<terminal-output>;
49+
}
50+
51+
/// An interface providing an optional `terminal-output` for stderr as a
52+
/// link-time authority.
53+
@since(version = 0.3.0)
54+
interface terminal-stderr {
55+
@since(version = 0.3.0)
56+
use terminal-output.{terminal-output};
57+
58+
/// If stderr is connected to a terminal, return a `terminal-output` handle
59+
/// allowing further interaction with it.
60+
@since(version = 0.3.0)
61+
get-terminal-stderr: func() -> option<terminal-output>;
62+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package wasi:clocks@0.3.0;
2+
/// WASI Monotonic Clock is a clock API intended to let users measure elapsed
3+
/// time.
4+
///
5+
/// It is intended to be portable at least between Unix-family platforms and
6+
/// Windows.
7+
///
8+
/// A monotonic clock is a clock which has an unspecified initial value, and
9+
/// successive reads of the clock will produce non-decreasing values.
10+
@since(version = 0.3.0)
11+
interface monotonic-clock {
12+
/// An instant in time, in nanoseconds. An instant is relative to an
13+
/// unspecified initial value, and can only be compared to instances from
14+
/// the same monotonic-clock.
15+
@since(version = 0.3.0)
16+
type instant = u64;
17+
18+
/// A duration of time, in nanoseconds.
19+
@since(version = 0.3.0)
20+
type duration = u64;
21+
22+
/// Read the current value of the clock.
23+
///
24+
/// The clock is monotonic, therefore calling this function repeatedly will
25+
/// produce a sequence of non-decreasing values.
26+
@since(version = 0.3.0)
27+
now: func() -> instant;
28+
29+
/// Query the resolution of the clock. Returns the duration of time
30+
/// corresponding to a clock tick.
31+
@since(version = 0.3.0)
32+
resolution: func() -> duration;
33+
34+
/// Wait until the specified instant has occurred.
35+
@since(version = 0.3.0)
36+
wait-until: async func(
37+
when: instant,
38+
);
39+
40+
/// Wait for the specified duration has elapsed.
41+
@since(version = 0.3.0)
42+
wait-for: async func(
43+
how-long: duration,
44+
);
45+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package wasi:clocks@0.3.0;
2+
3+
@unstable(feature = clocks-timezone)
4+
interface timezone {
5+
@unstable(feature = clocks-timezone)
6+
use wall-clock.{datetime};
7+
8+
/// Return information needed to display the given `datetime`. This includes
9+
/// the UTC offset, the time zone name, and a flag indicating whether
10+
/// daylight saving time is active.
11+
///
12+
/// If the timezone cannot be determined for the given `datetime`, return a
13+
/// `timezone-display` for `UTC` with a `utc-offset` of 0 and no daylight
14+
/// saving time.
15+
@unstable(feature = clocks-timezone)
16+
display: func(when: datetime) -> timezone-display;
17+
18+
/// The same as `display`, but only return the UTC offset.
19+
@unstable(feature = clocks-timezone)
20+
utc-offset: func(when: datetime) -> s32;
21+
22+
/// Information useful for displaying the timezone of a specific `datetime`.
23+
///
24+
/// This information may vary within a single `timezone` to reflect daylight
25+
/// saving time adjustments.
26+
@unstable(feature = clocks-timezone)
27+
record timezone-display {
28+
/// The number of seconds difference between UTC time and the local
29+
/// time of the timezone.
30+
///
31+
/// The returned value will always be less than 86400 which is the
32+
/// number of seconds in a day (24*60*60).
33+
///
34+
/// In implementations that do not expose an actual time zone, this
35+
/// should return 0.
36+
utc-offset: s32,
37+
38+
/// The abbreviated name of the timezone to display to a user. The name
39+
/// `UTC` indicates Coordinated Universal Time. Otherwise, this should
40+
/// reference local standards for the name of the time zone.
41+
///
42+
/// In implementations that do not expose an actual time zone, this
43+
/// should be the string `UTC`.
44+
///
45+
/// In time zones that do not have an applicable name, a formatted
46+
/// representation of the UTC offset may be returned, such as `-04:00`.
47+
name: string,
48+
49+
/// Whether daylight saving time is active.
50+
///
51+
/// In implementations that do not expose an actual time zone, this
52+
/// should return false.
53+
in-daylight-saving-time: bool,
54+
}
55+
}

0 commit comments

Comments
 (0)