Skip to content

Commit ba65bb2

Browse files
committed
configure knitwit
Signed-off-by: karthik2804 <[email protected]>
1 parent 6b8a266 commit ba65bb2

37 files changed

+2944
-2
lines changed

package-lock.json

Lines changed: 80 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"main": "lib/index.js",
66
"scripts": {
77
"test": "(cd tests && ./test.sh)",
8-
"build": "tsc"
8+
"build": "tsc",
9+
"postinstall": "knitwit-postinstall"
910
},
1011
"repository": {
1112
"type": "git",
@@ -26,6 +27,13 @@
2627
"buffer": "^6.0.3",
2728
"path-browserify": "^1.0.1",
2829
"process": "^0.11.10",
29-
"webpack": "^5.92.0"
30+
"webpack": "^5.92.0",
31+
"@fermyon/knitwit": "https://github.com/fermyon/knitwit"
32+
},
33+
"config": {
34+
"knitwit": {
35+
"witPath": "../../wit",
36+
"world": "js-wasi-ext"
37+
}
3038
}
3139
}

wit/deps/cli/command.wit

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package wasi:cli@0.2.0;
2+
3+
world command {
4+
include imports;
5+
6+
export run;
7+
}

wit/deps/cli/environment.wit

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
interface environment {
2+
/// Get the POSIX-style environment variables.
3+
///
4+
/// Each environment variable is provided as a pair of string variable names
5+
/// and string value.
6+
///
7+
/// Morally, these are a value import, but until value imports are available
8+
/// in the component model, this import function should return the same
9+
/// values each time it is called.
10+
get-environment: func() -> list<tuple<string, string>>;
11+
12+
/// Get the POSIX-style arguments to the program.
13+
get-arguments: func() -> list<string>;
14+
15+
/// Return a path that programs should use as their initial current working
16+
/// directory, interpreting `.` as shorthand for this.
17+
initial-cwd: func() -> option<string>;
18+
}

wit/deps/cli/exit.wit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
interface exit {
2+
/// Exit the current instance and any linked instances.
3+
exit: func(status: result);
4+
}

wit/deps/cli/imports.wit

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package wasi:cli@0.2.0;
2+
3+
world imports {
4+
include wasi:clocks/imports@0.2.0;
5+
include wasi:filesystem/imports@0.2.0;
6+
include wasi:sockets/imports@0.2.0;
7+
include wasi:random/imports@0.2.0;
8+
include wasi:io/imports@0.2.0;
9+
10+
import environment;
11+
import exit;
12+
import stdin;
13+
import stdout;
14+
import stderr;
15+
import terminal-input;
16+
import terminal-output;
17+
import terminal-stdin;
18+
import terminal-stdout;
19+
import terminal-stderr;
20+
}

wit/deps/cli/run.wit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
interface run {
2+
/// Run the program.
3+
run: func() -> result;
4+
}

wit/deps/cli/stdio.wit

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
interface stdin {
2+
use wasi:io/streams@0.2.0.{input-stream};
3+
4+
get-stdin: func() -> input-stream;
5+
}
6+
7+
interface stdout {
8+
use wasi:io/streams@0.2.0.{output-stream};
9+
10+
get-stdout: func() -> output-stream;
11+
}
12+
13+
interface stderr {
14+
use wasi:io/streams@0.2.0.{output-stream};
15+
16+
get-stderr: func() -> output-stream;
17+
}

wit/deps/cli/terminal.wit

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
interface terminal-input {
7+
/// The input side of a terminal.
8+
resource terminal-input;
9+
}
10+
11+
/// Terminal output.
12+
///
13+
/// In the future, this may include functions for querying the terminal
14+
/// size, being notified of terminal size changes, querying supported
15+
/// features, and so on.
16+
interface terminal-output {
17+
/// The output side of a terminal.
18+
resource terminal-output;
19+
}
20+
21+
/// An interface providing an optional `terminal-input` for stdin as a
22+
/// link-time authority.
23+
interface terminal-stdin {
24+
use terminal-input.{terminal-input};
25+
26+
/// If stdin is connected to a terminal, return a `terminal-input` handle
27+
/// allowing further interaction with it.
28+
get-terminal-stdin: func() -> option<terminal-input>;
29+
}
30+
31+
/// An interface providing an optional `terminal-output` for stdout as a
32+
/// link-time authority.
33+
interface terminal-stdout {
34+
use terminal-output.{terminal-output};
35+
36+
/// If stdout is connected to a terminal, return a `terminal-output` handle
37+
/// allowing further interaction with it.
38+
get-terminal-stdout: func() -> option<terminal-output>;
39+
}
40+
41+
/// An interface providing an optional `terminal-output` for stderr as a
42+
/// link-time authority.
43+
interface terminal-stderr {
44+
use terminal-output.{terminal-output};
45+
46+
/// If stderr is connected to a terminal, return a `terminal-output` handle
47+
/// allowing further interaction with it.
48+
get-terminal-stderr: func() -> option<terminal-output>;
49+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package wasi:clocks@0.2.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+
///
11+
/// It is intended for measuring elapsed time.
12+
interface monotonic-clock {
13+
use wasi:io/poll@0.2.0.{pollable};
14+
15+
/// An instant in time, in nanoseconds. An instant is relative to an
16+
/// unspecified initial value, and can only be compared to instances from
17+
/// the same monotonic-clock.
18+
type instant = u64;
19+
20+
/// A duration of time, in nanoseconds.
21+
type duration = u64;
22+
23+
/// Read the current value of the clock.
24+
///
25+
/// The clock is monotonic, therefore calling this function repeatedly will
26+
/// produce a sequence of non-decreasing values.
27+
now: func() -> instant;
28+
29+
/// Query the resolution of the clock. Returns the duration of time
30+
/// corresponding to a clock tick.
31+
resolution: func() -> duration;
32+
33+
/// Create a `pollable` which will resolve once the specified instant
34+
/// occured.
35+
subscribe-instant: func(
36+
when: instant,
37+
) -> pollable;
38+
39+
/// Create a `pollable` which will resolve once the given duration has
40+
/// elapsed, starting at the time at which this function was called.
41+
/// occured.
42+
subscribe-duration: func(
43+
when: duration,
44+
) -> pollable;
45+
}

0 commit comments

Comments
 (0)