@wasi-gfx/js-webgpu 0.2.0 → 0.4.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.
Files changed (64) hide show
  1. package/README.md +3 -3
  2. package/dist/canvas.d.ts +3 -3
  3. package/dist/canvas.js +36 -23
  4. package/dist/globals.js +12 -10
  5. package/dist/webgpu.d.ts +68 -12
  6. package/dist/webgpu.js +340 -48
  7. package/package.json +12 -6
  8. package/types/interfaces/wasi-cli-run.d.ts +2 -2
  9. package/types/interfaces/wasi-cli-stdout.d.ts +14 -3
  10. package/types/interfaces/wasi-cli-types.d.ts +15 -0
  11. package/types/interfaces/wasi-gfx-frame-buffer-frame-buffer.d.ts +13 -0
  12. package/types/interfaces/wasi-gfx-surface-surface-frame-buffer.d.ts +12 -0
  13. package/types/interfaces/wasi-gfx-surface-surface-webgpu.d.ts +29 -0
  14. package/types/interfaces/{wasi-surface-surface.d.ts → wasi-gfx-surface-surface.d.ts} +8 -18
  15. package/types/interfaces/wasi-webgpu-webgpu.d.ts +809 -810
  16. package/types/wit.d.ts +9 -10
  17. package/wit/deps/wasi-cli-0.3.0/package.wit +256 -0
  18. package/wit/deps/wasi-clocks-0.3.0/package.wit +43 -0
  19. package/wit/deps/wasi-filesystem-0.3.0/package.wit +149 -0
  20. package/wit/deps/wasi-gfx-frame-buffer-0.2.0/package.wit +13 -0
  21. package/wit/deps/{surface/surface.wit → wasi-gfx-surface-0.2.0/package.wit} +69 -44
  22. package/wit/deps/wasi-random-0.3.0/package.wit +18 -0
  23. package/wit/deps/wasi-sockets-0.3.0/package.wit +116 -0
  24. package/wit/deps/{webgpu/webgpu.wit → wasi-webgpu-0.3.0-rc.2/package.wit} +1007 -836
  25. package/wit/world.wit +8 -7
  26. package/types/interfaces/wasi-frame-buffer-frame-buffer.d.ts +0 -21
  27. package/types/interfaces/wasi-graphics-context-graphics-context.d.ts +0 -17
  28. package/types/interfaces/wasi-io-error.d.ts +0 -18
  29. package/types/interfaces/wasi-io-poll.d.ts +0 -43
  30. package/types/interfaces/wasi-io-streams.d.ts +0 -240
  31. package/wit/deps/cli/command.wit +0 -7
  32. package/wit/deps/cli/environment.wit +0 -18
  33. package/wit/deps/cli/exit.wit +0 -4
  34. package/wit/deps/cli/imports.wit +0 -20
  35. package/wit/deps/cli/run.wit +0 -4
  36. package/wit/deps/cli/stdio.wit +0 -17
  37. package/wit/deps/cli/terminal.wit +0 -49
  38. package/wit/deps/clocks/monotonic-clock.wit +0 -45
  39. package/wit/deps/clocks/wall-clock.wit +0 -42
  40. package/wit/deps/clocks/world.wit +0 -6
  41. package/wit/deps/filesystem/preopens.wit +0 -8
  42. package/wit/deps/filesystem/types.wit +0 -634
  43. package/wit/deps/filesystem/world.wit +0 -6
  44. package/wit/deps/frame-buffer/frame-buffer.wit +0 -23
  45. package/wit/deps/graphics-context/graphics-context.wit +0 -18
  46. package/wit/deps/io/error.wit +0 -34
  47. package/wit/deps/io/poll.wit +0 -41
  48. package/wit/deps/io/streams.wit +0 -262
  49. package/wit/deps/io/world.wit +0 -6
  50. package/wit/deps/random/insecure-seed.wit +0 -25
  51. package/wit/deps/random/insecure.wit +0 -22
  52. package/wit/deps/random/random.wit +0 -26
  53. package/wit/deps/random/world.wit +0 -7
  54. package/wit/deps/sockets/instance-network.wit +0 -9
  55. package/wit/deps/sockets/ip-name-lookup.wit +0 -51
  56. package/wit/deps/sockets/network.wit +0 -145
  57. package/wit/deps/sockets/tcp-create-socket.wit +0 -27
  58. package/wit/deps/sockets/tcp.wit +0 -353
  59. package/wit/deps/sockets/udp-create-socket.wit +0 -27
  60. package/wit/deps/sockets/udp.wit +0 -266
  61. package/wit/deps/sockets/world.wit +0 -11
  62. package/wit/deps/webgpu/imports.wit +0 -5
  63. package/wit/deps.lock +0 -51
  64. package/wit/deps.toml +0 -18
package/types/wit.d.ts CHANGED
@@ -1,10 +1,9 @@
1
- // world wasi-gfx:js-webgpu/imports@0.1.0
2
- export type * as WasiCliStdout020 from './interfaces/wasi-cli-stdout.js'; // import wasi:cli/stdout@0.2.0
3
- export type * as WasiFrameBufferFrameBuffer001 from './interfaces/wasi-frame-buffer-frame-buffer.js'; // import wasi:frame-buffer/frame-buffer@0.0.1
4
- export type * as WasiGraphicsContextGraphicsContext001 from './interfaces/wasi-graphics-context-graphics-context.js'; // import wasi:graphics-context/graphics-context@0.0.1
5
- export type * as WasiIoError020 from './interfaces/wasi-io-error.js'; // import wasi:io/error@0.2.0
6
- export type * as WasiIoPoll020 from './interfaces/wasi-io-poll.js'; // import wasi:io/poll@0.2.0
7
- export type * as WasiIoStreams020 from './interfaces/wasi-io-streams.js'; // import wasi:io/streams@0.2.0
8
- export type * as WasiSurfaceSurface001 from './interfaces/wasi-surface-surface.js'; // import wasi:surface/surface@0.0.1
9
- export type * as WasiWebgpuWebgpu001 from './interfaces/wasi-webgpu-webgpu.js'; // import wasi:webgpu/webgpu@0.0.1
10
- export * as run from './interfaces/wasi-cli-run.js'; // export wasi:cli/run@0.2.0
1
+ // world wasi-gfx:js-webgpu/imports
2
+ export type * as WasiGfxFrameBufferFrameBuffer020 from './interfaces/wasi-gfx-frame-buffer-frame-buffer.js'; // import wasi-gfx:frame-buffer/frame-buffer@0.2.0
3
+ export type * as WasiGfxSurfaceSurfaceFrameBuffer020 from './interfaces/wasi-gfx-surface-surface-frame-buffer.js'; // import wasi-gfx:surface/surface-frame-buffer@0.2.0
4
+ export type * as WasiGfxSurfaceSurfaceWebgpu020 from './interfaces/wasi-gfx-surface-surface-webgpu.js'; // import wasi-gfx:surface/surface-webgpu@0.2.0
5
+ export type * as WasiGfxSurfaceSurface020 from './interfaces/wasi-gfx-surface-surface.js'; // import wasi-gfx:surface/surface@0.2.0
6
+ export type * as WasiCliStdout030 from './interfaces/wasi-cli-stdout.js'; // import wasi:cli/stdout@0.3.0
7
+ export type * as WasiCliTypes030 from './interfaces/wasi-cli-types.js'; // import wasi:cli/types@0.3.0
8
+ export type * as WasiWebgpuWebgpu030Rc2 from './interfaces/wasi-webgpu-webgpu.js'; // import wasi:webgpu/webgpu@0.3.0-rc.2
9
+ export * as run from './interfaces/wasi-cli-run.js'; // export wasi:cli/run@0.3.0
@@ -0,0 +1,256 @@
1
+ package wasi:cli@0.3.0;
2
+
3
+ @since(version = 0.3.0)
4
+ interface environment {
5
+ /// Get the POSIX-style environment variables.
6
+ ///
7
+ /// Each environment variable is provided as a pair of string variable names
8
+ /// and string value.
9
+ ///
10
+ /// Morally, these are a value import, but until value imports are available
11
+ /// in the component model, this import function should return the same
12
+ /// values each time it is called.
13
+ @since(version = 0.3.0)
14
+ get-environment: func() -> list<tuple<string, string>>;
15
+
16
+ /// Get the POSIX-style arguments to the program.
17
+ @since(version = 0.3.0)
18
+ get-arguments: func() -> list<string>;
19
+
20
+ /// Return a path that programs should use as their initial current working
21
+ /// directory, interpreting `.` as shorthand for this.
22
+ @since(version = 0.3.0)
23
+ get-initial-cwd: func() -> option<string>;
24
+ }
25
+
26
+ @since(version = 0.3.0)
27
+ interface exit {
28
+ /// Exit the current instance and any linked instances.
29
+ @since(version = 0.3.0)
30
+ exit: func(status: result);
31
+
32
+ /// Exit the current instance and any linked instances, reporting the
33
+ /// specified status code to the host.
34
+ ///
35
+ /// The meaning of the code depends on the context, with 0 usually meaning
36
+ /// "success", and other values indicating various types of failure.
37
+ ///
38
+ /// This function does not return; the effect is analogous to a trap, but
39
+ /// without the connotation that something bad has happened.
40
+ @since(version = 0.3.0)
41
+ exit-with-code: func(status-code: u8);
42
+ }
43
+
44
+ @since(version = 0.3.0)
45
+ interface run {
46
+ /// Run the program.
47
+ @since(version = 0.3.0)
48
+ run: async func() -> result;
49
+ }
50
+
51
+ @since(version = 0.3.0)
52
+ interface types {
53
+ @since(version = 0.3.0)
54
+ enum error-code {
55
+ /// Input/output error
56
+ io,
57
+ /// Invalid or incomplete multibyte or wide character
58
+ illegal-byte-sequence,
59
+ /// Broken pipe
60
+ pipe,
61
+ }
62
+ }
63
+
64
+ @since(version = 0.3.0)
65
+ interface stdin {
66
+ use types.{error-code};
67
+
68
+ /// Return a stream for reading from stdin.
69
+ ///
70
+ /// This function returns a stream which provides data read from stdin,
71
+ /// and a future to signal read results.
72
+ ///
73
+ /// If the stream's readable end is dropped the future will resolve to success.
74
+ ///
75
+ /// If the stream's writable end is dropped the future will either resolve to
76
+ /// success if stdin was closed by the writer or to an error-code if reading
77
+ /// failed for some other reason.
78
+ ///
79
+ /// Multiple streams may be active at the same time. The behavior of concurrent
80
+ /// reads is implementation-specific.
81
+ @since(version = 0.3.0)
82
+ read-via-stream: func() -> tuple<stream<u8>, future<result<_, error-code>>>;
83
+ }
84
+
85
+ @since(version = 0.3.0)
86
+ interface stdout {
87
+ use types.{error-code};
88
+
89
+ /// Write the given stream to stdout.
90
+ ///
91
+ /// If the stream's writable end is dropped this function will either return
92
+ /// success once the entire contents of the stream have been written or an
93
+ /// error-code representing a failure.
94
+ ///
95
+ /// Otherwise if there is an error the readable end of the stream will be
96
+ /// dropped and this function will return an error-code.
97
+ @since(version = 0.3.0)
98
+ write-via-stream: func(data: stream<u8>) -> future<result<_, error-code>>;
99
+ }
100
+
101
+ @since(version = 0.3.0)
102
+ interface stderr {
103
+ use types.{error-code};
104
+
105
+ /// Write the given stream to stderr.
106
+ ///
107
+ /// If the stream's writable end is dropped this function will either return
108
+ /// success once the entire contents of the stream have been written or an
109
+ /// error-code representing a failure.
110
+ ///
111
+ /// Otherwise if there is an error the readable end of the stream will be
112
+ /// dropped and this function will return an error-code.
113
+ @since(version = 0.3.0)
114
+ write-via-stream: func(data: stream<u8>) -> future<result<_, error-code>>;
115
+ }
116
+
117
+ /// Terminal input.
118
+ ///
119
+ /// In the future, this may include functions for disabling echoing,
120
+ /// disabling input buffering so that keyboard events are sent through
121
+ /// immediately, querying supported features, and so on.
122
+ @since(version = 0.3.0)
123
+ interface terminal-input {
124
+ /// The input side of a terminal.
125
+ @since(version = 0.3.0)
126
+ resource terminal-input;
127
+ }
128
+
129
+ /// Terminal output.
130
+ ///
131
+ /// In the future, this may include functions for querying the terminal
132
+ /// size, being notified of terminal size changes, querying supported
133
+ /// features, and so on.
134
+ @since(version = 0.3.0)
135
+ interface terminal-output {
136
+ /// The output side of a terminal.
137
+ @since(version = 0.3.0)
138
+ resource terminal-output;
139
+ }
140
+
141
+ /// An interface providing an optional `terminal-input` for stdin as a
142
+ /// link-time authority.
143
+ @since(version = 0.3.0)
144
+ interface terminal-stdin {
145
+ @since(version = 0.3.0)
146
+ use terminal-input.{terminal-input};
147
+
148
+ /// If stdin is connected to a terminal, return a `terminal-input` handle
149
+ /// allowing further interaction with it.
150
+ @since(version = 0.3.0)
151
+ get-terminal-stdin: func() -> option<terminal-input>;
152
+ }
153
+
154
+ /// An interface providing an optional `terminal-output` for stdout as a
155
+ /// link-time authority.
156
+ @since(version = 0.3.0)
157
+ interface terminal-stdout {
158
+ @since(version = 0.3.0)
159
+ use terminal-output.{terminal-output};
160
+
161
+ /// If stdout is connected to a terminal, return a `terminal-output` handle
162
+ /// allowing further interaction with it.
163
+ @since(version = 0.3.0)
164
+ get-terminal-stdout: func() -> option<terminal-output>;
165
+ }
166
+
167
+ /// An interface providing an optional `terminal-output` for stderr as a
168
+ /// link-time authority.
169
+ @since(version = 0.3.0)
170
+ interface terminal-stderr {
171
+ @since(version = 0.3.0)
172
+ use terminal-output.{terminal-output};
173
+
174
+ /// If stderr is connected to a terminal, return a `terminal-output` handle
175
+ /// allowing further interaction with it.
176
+ @since(version = 0.3.0)
177
+ get-terminal-stderr: func() -> option<terminal-output>;
178
+ }
179
+
180
+ @since(version = 0.3.0)
181
+ world imports {
182
+ @since(version = 0.3.0)
183
+ import environment;
184
+ @since(version = 0.3.0)
185
+ import exit;
186
+ @since(version = 0.3.0)
187
+ import types;
188
+ @since(version = 0.3.0)
189
+ import stdin;
190
+ @since(version = 0.3.0)
191
+ import stdout;
192
+ @since(version = 0.3.0)
193
+ import stderr;
194
+ @since(version = 0.3.0)
195
+ import terminal-input;
196
+ @since(version = 0.3.0)
197
+ import terminal-output;
198
+ @since(version = 0.3.0)
199
+ import terminal-stdin;
200
+ @since(version = 0.3.0)
201
+ import terminal-stdout;
202
+ @since(version = 0.3.0)
203
+ import terminal-stderr;
204
+ import wasi:clocks/types@0.3.0;
205
+ import wasi:clocks/monotonic-clock@0.3.0;
206
+ import wasi:clocks/system-clock@0.3.0;
207
+ @unstable(feature = clocks-timezone)
208
+ import wasi:clocks/timezone@0.3.0;
209
+ import wasi:filesystem/types@0.3.0;
210
+ import wasi:filesystem/preopens@0.3.0;
211
+ import wasi:sockets/types@0.3.0;
212
+ import wasi:sockets/ip-name-lookup@0.3.0;
213
+ import wasi:random/random@0.3.0;
214
+ import wasi:random/insecure@0.3.0;
215
+ import wasi:random/insecure-seed@0.3.0;
216
+ }
217
+ @since(version = 0.3.0)
218
+ world command {
219
+ @since(version = 0.3.0)
220
+ import environment;
221
+ @since(version = 0.3.0)
222
+ import exit;
223
+ @since(version = 0.3.0)
224
+ import types;
225
+ @since(version = 0.3.0)
226
+ import stdin;
227
+ @since(version = 0.3.0)
228
+ import stdout;
229
+ @since(version = 0.3.0)
230
+ import stderr;
231
+ @since(version = 0.3.0)
232
+ import terminal-input;
233
+ @since(version = 0.3.0)
234
+ import terminal-output;
235
+ @since(version = 0.3.0)
236
+ import terminal-stdin;
237
+ @since(version = 0.3.0)
238
+ import terminal-stdout;
239
+ @since(version = 0.3.0)
240
+ import terminal-stderr;
241
+ import wasi:clocks/types@0.3.0;
242
+ import wasi:clocks/monotonic-clock@0.3.0;
243
+ import wasi:clocks/system-clock@0.3.0;
244
+ @unstable(feature = clocks-timezone)
245
+ import wasi:clocks/timezone@0.3.0;
246
+ import wasi:filesystem/types@0.3.0;
247
+ import wasi:filesystem/preopens@0.3.0;
248
+ import wasi:sockets/types@0.3.0;
249
+ import wasi:sockets/ip-name-lookup@0.3.0;
250
+ import wasi:random/random@0.3.0;
251
+ import wasi:random/insecure@0.3.0;
252
+ import wasi:random/insecure-seed@0.3.0;
253
+
254
+ @since(version = 0.3.0)
255
+ export run;
256
+ }
@@ -0,0 +1,43 @@
1
+ package wasi:clocks@0.3.0;
2
+
3
+ interface types {
4
+ type duration = u64;
5
+ }
6
+
7
+ interface monotonic-clock {
8
+ use types.{duration};
9
+
10
+ type mark = u64;
11
+
12
+ now: func() -> mark;
13
+
14
+ get-resolution: func() -> duration;
15
+
16
+ wait-until: async func(when: mark);
17
+
18
+ wait-for: async func(how-long: duration);
19
+ }
20
+
21
+ interface system-clock {
22
+ use types.{duration};
23
+
24
+ record instant {
25
+ seconds: s64,
26
+ nanoseconds: u32,
27
+ }
28
+
29
+ now: func() -> instant;
30
+
31
+ get-resolution: func() -> duration;
32
+ }
33
+
34
+ interface timezone {
35
+ use system-clock.{instant};
36
+
37
+ iana-id: func() -> option<string>;
38
+
39
+ utc-offset: func(when: instant) -> option<s64>;
40
+
41
+ to-debug-string: func() -> string;
42
+ }
43
+
@@ -0,0 +1,149 @@
1
+ package wasi:filesystem@0.3.0;
2
+
3
+ interface types {
4
+ use wasi:clocks/system-clock@0.3.0.{instant};
5
+
6
+ type filesize = u64;
7
+
8
+ variant descriptor-type {
9
+ block-device,
10
+ character-device,
11
+ directory,
12
+ fifo,
13
+ symbolic-link,
14
+ regular-file,
15
+ socket,
16
+ other(option<string>),
17
+ }
18
+
19
+ flags descriptor-flags {
20
+ read,
21
+ write,
22
+ file-integrity-sync,
23
+ data-integrity-sync,
24
+ requested-write-sync,
25
+ mutate-directory,
26
+ }
27
+
28
+ flags path-flags {
29
+ symlink-follow,
30
+ }
31
+
32
+ flags open-flags {
33
+ create,
34
+ directory,
35
+ exclusive,
36
+ truncate,
37
+ }
38
+
39
+ type link-count = u64;
40
+
41
+ record descriptor-stat {
42
+ %type: descriptor-type,
43
+ link-count: link-count,
44
+ size: filesize,
45
+ data-access-timestamp: option<instant>,
46
+ data-modification-timestamp: option<instant>,
47
+ status-change-timestamp: option<instant>,
48
+ }
49
+
50
+ variant new-timestamp {
51
+ no-change,
52
+ now,
53
+ timestamp(instant),
54
+ }
55
+
56
+ record directory-entry {
57
+ %type: descriptor-type,
58
+ name: string,
59
+ }
60
+
61
+ variant error-code {
62
+ access,
63
+ already,
64
+ bad-descriptor,
65
+ busy,
66
+ deadlock,
67
+ quota,
68
+ exist,
69
+ file-too-large,
70
+ illegal-byte-sequence,
71
+ in-progress,
72
+ interrupted,
73
+ invalid,
74
+ io,
75
+ is-directory,
76
+ loop,
77
+ too-many-links,
78
+ message-size,
79
+ name-too-long,
80
+ no-device,
81
+ no-entry,
82
+ no-lock,
83
+ insufficient-memory,
84
+ insufficient-space,
85
+ not-directory,
86
+ not-empty,
87
+ not-recoverable,
88
+ unsupported,
89
+ no-tty,
90
+ no-such-device,
91
+ overflow,
92
+ not-permitted,
93
+ pipe,
94
+ read-only,
95
+ invalid-seek,
96
+ text-file-busy,
97
+ cross-device,
98
+ other(option<string>),
99
+ }
100
+
101
+ enum advice {
102
+ normal,
103
+ sequential,
104
+ random,
105
+ will-need,
106
+ dont-need,
107
+ no-reuse,
108
+ }
109
+
110
+ record metadata-hash-value {
111
+ lower: u64,
112
+ upper: u64,
113
+ }
114
+
115
+ resource descriptor {
116
+ read-via-stream: func(offset: filesize) -> tuple<stream<u8>, future<result<_, error-code>>>;
117
+ write-via-stream: func(data: stream<u8>, offset: filesize) -> future<result<_, error-code>>;
118
+ append-via-stream: func(data: stream<u8>) -> future<result<_, error-code>>;
119
+ advise: async func(offset: filesize, length: filesize, advice: advice) -> result<_, error-code>;
120
+ sync-data: async func() -> result<_, error-code>;
121
+ get-flags: async func() -> result<descriptor-flags, error-code>;
122
+ get-type: async func() -> result<descriptor-type, error-code>;
123
+ set-size: async func(size: filesize) -> result<_, error-code>;
124
+ set-times: async func(data-access-timestamp: new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code>;
125
+ read-directory: func() -> tuple<stream<directory-entry>, future<result<_, error-code>>>;
126
+ sync: async func() -> result<_, error-code>;
127
+ create-directory-at: async func(path: string) -> result<_, error-code>;
128
+ stat: async func() -> result<descriptor-stat, error-code>;
129
+ stat-at: async func(path-flags: path-flags, path: string) -> result<descriptor-stat, error-code>;
130
+ set-times-at: async func(path-flags: path-flags, path: string, data-access-timestamp: new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code>;
131
+ link-at: async func(old-path-flags: path-flags, old-path: string, new-descriptor: borrow<descriptor>, new-path: string) -> result<_, error-code>;
132
+ open-at: async func(path-flags: path-flags, path: string, open-flags: open-flags, %flags: descriptor-flags) -> result<descriptor, error-code>;
133
+ readlink-at: async func(path: string) -> result<string, error-code>;
134
+ remove-directory-at: async func(path: string) -> result<_, error-code>;
135
+ rename-at: async func(old-path: string, new-descriptor: borrow<descriptor>, new-path: string) -> result<_, error-code>;
136
+ symlink-at: async func(old-path: string, new-path: string) -> result<_, error-code>;
137
+ unlink-file-at: async func(path: string) -> result<_, error-code>;
138
+ is-same-object: async func(other: borrow<descriptor>) -> bool;
139
+ metadata-hash: async func() -> result<metadata-hash-value, error-code>;
140
+ metadata-hash-at: async func(path-flags: path-flags, path: string) -> result<metadata-hash-value, error-code>;
141
+ }
142
+ }
143
+
144
+ interface preopens {
145
+ use types.{descriptor};
146
+
147
+ get-directories: func() -> list<tuple<descriptor, string>>;
148
+ }
149
+
@@ -0,0 +1,13 @@
1
+ package wasi-gfx:frame-buffer@0.2.0;
2
+
3
+ interface frame-buffer {
4
+ resource buffer {
5
+ /// TODO: This should be replaced with something that doesn't require a copy.
6
+ get-with-copy: func() -> list<u8>;
7
+ set-with-copy: func(val: list<u8>);
8
+ }
9
+ }
10
+
11
+ world imports {
12
+ import frame-buffer;
13
+ }
@@ -1,13 +1,6 @@
1
- package wasi:surface@0.0.1;
2
-
3
- world imports {
4
- import surface;
5
- }
1
+ package wasi-gfx:surface@0.2.0;
6
2
 
7
3
  interface surface {
8
- use wasi:graphics-context/graphics-context@0.0.1.{context};
9
- use wasi:io/poll@0.2.0.{pollable};
10
-
11
4
  record create-desc {
12
5
  height: option<u32>,
13
6
  width: option<u32>,
@@ -15,34 +8,16 @@ interface surface {
15
8
 
16
9
  resource surface {
17
10
  constructor(desc: create-desc);
18
-
19
- connect-graphics-context: func(context: borrow<context>);
20
-
21
11
  height: func() -> u32;
22
12
  width: func() -> u32;
23
-
24
13
  request-set-size: func(height: option<u32>, width: option<u32>);
25
-
26
- subscribe-resize: func() -> pollable;
27
- get-resize: func() -> option<resize-event>;
28
-
29
- subscribe-frame: func() -> pollable;
30
- get-frame: func() -> option<frame-event>;
31
-
32
- subscribe-pointer-up: func() -> pollable;
33
- get-pointer-up: func() -> option<pointer-event>;
34
-
35
- subscribe-pointer-down: func() -> pollable;
36
- get-pointer-down: func() -> option<pointer-event>;
37
-
38
- subscribe-pointer-move: func() -> pollable;
39
- get-pointer-move: func() -> option<pointer-event>;
40
-
41
- subscribe-key-up: func() -> pollable;
42
- get-key-up: func() -> option<key-event>;
43
-
44
- subscribe-key-down: func() -> pollable;
45
- get-key-down: func() -> option<key-event>;
14
+ on-resize: func() -> stream<resize-event>;
15
+ on-frame: func() -> stream<frame-event>;
16
+ on-pointer-up: func() -> stream<pointer-event>;
17
+ on-pointer-down: func() -> stream<pointer-event>;
18
+ on-pointer-move: func() -> stream<pointer-event>;
19
+ on-key-up: func() -> stream<key-event>;
20
+ on-key-down: func() -> stream<key-event>;
46
21
  }
47
22
 
48
23
  record resize-event {
@@ -61,17 +36,8 @@ interface surface {
61
36
  y: f64,
62
37
  }
63
38
 
64
- record key-event {
65
- key: option<key>,
66
- text: option<string>,
67
- alt-key: bool,
68
- ctrl-key: bool,
69
- meta-key: bool,
70
- shift-key: bool,
71
- }
72
-
73
- // corresponds with https://w3c.github.io/uievents-code/#code-value-tables
74
- // `Unidentified` is not included, use `option<key>` instead.
39
+ /// corresponds with https://w3c.github.io/uievents-code/#code-value-tables
40
+ /// `Unidentified` is not included, use `option<key>` instead.
75
41
  enum key {
76
42
  backquote,
77
43
  backslash,
@@ -245,4 +211,63 @@ interface surface {
245
211
  hiragana,
246
212
  katakana,
247
213
  }
214
+
215
+ record key-event {
216
+ key: option<key>,
217
+ text: option<string>,
218
+ alt-key: bool,
219
+ ctrl-key: bool,
220
+ meta-key: bool,
221
+ shift-key: bool,
222
+ }
223
+ }
224
+
225
+ interface surface-frame-buffer {
226
+ use wasi-gfx:frame-buffer/frame-buffer@0.2.0.{buffer};
227
+ use surface.{surface};
228
+
229
+ resource context {
230
+ constructor(surface: borrow<surface>);
231
+ get-current-buffer: func() -> buffer;
232
+ /// TODO: consider if needed
233
+ present: func();
234
+ }
235
+ }
236
+
237
+ interface surface-webgpu {
238
+ use wasi:webgpu/webgpu@0.3.0-rc.2.{gpu-device, gpu-texture, gpu-texture-format, gpu-texture-usage, predefined-color-space, gpu-canvas-tone-mapping, gpu-canvas-alpha-mode};
239
+ use surface.{surface};
240
+
241
+ record context-configuration {
242
+ device: borrow<gpu-device>,
243
+ format: gpu-texture-format,
244
+ usage: option<gpu-texture-usage>,
245
+ view-formats: option<list<gpu-texture-format>>,
246
+ color-space: option<predefined-color-space>,
247
+ tone-mapping: option<gpu-canvas-tone-mapping>,
248
+ alpha-mode: option<gpu-canvas-alpha-mode>,
249
+ }
250
+
251
+ resource context {
252
+ constructor(surface: borrow<surface>);
253
+ configure: func(configuration: context-configuration);
254
+ unconfigure: func();
255
+ get-current-texture: func() -> gpu-texture;
256
+ /// TODO: consider if needed
257
+ present: func();
258
+ }
259
+ }
260
+
261
+ world frame-buffer-imports {
262
+ import wasi-gfx:frame-buffer/frame-buffer@0.2.0;
263
+ import surface;
264
+ import surface-frame-buffer;
265
+ }
266
+ world webgpu-imports {
267
+ import wasi:webgpu/webgpu@0.3.0-rc.2;
268
+ import surface;
269
+ import surface-webgpu;
270
+ }
271
+ world imports {
272
+ import surface;
248
273
  }
@@ -0,0 +1,18 @@
1
+ package wasi:random@0.3.0;
2
+
3
+ interface random {
4
+ get-random-bytes: func(max-len: u64) -> list<u8>;
5
+
6
+ get-random-u64: func() -> u64;
7
+ }
8
+
9
+ interface insecure {
10
+ get-insecure-random-bytes: func(max-len: u64) -> list<u8>;
11
+
12
+ get-insecure-random-u64: func() -> u64;
13
+ }
14
+
15
+ interface insecure-seed {
16
+ get-insecure-seed: func() -> tuple<u64, u64>;
17
+ }
18
+