@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wasi-gfx/js-webgpu",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "WebGPU JavaScript API on top of wasi-gfx",
5
5
  "exports": {
6
6
  "./canvas": {
@@ -21,26 +21,32 @@
21
21
  "wit/",
22
22
  "types/"
23
23
  ],
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/wasi-gfx/wasi-gfx-js.git"
27
+ },
24
28
  "type": "module",
25
29
  "scripts": {
26
30
  "build": "cd src && tsc",
27
31
  "check": "cd src && tsc --noEmit && cd ../examples && tsc --noEmit",
28
- "generate-types": "rm -rf types && jco types wit --out-dir=types",
32
+ "wit": "npm run wit:fetch && npm run wit:bindings",
33
+ "wit:fetch": "wkg fetch --config ./wkg-config.toml",
34
+ "wit:bindings": "rm -rf types && jco types wit --out-dir=types",
29
35
  "test": "npm run test:generate-spec-list && npm run test:rollup && npm run test:jco && echo 'Test wasm built but not run temp/tests.wasm'",
30
36
  "test:generate-spec-list": "node tests/generate-spec-list.js",
31
37
  "test:rollup": "rollup --config './tests/rollup.config.js'",
32
- "test:jco": "jco componentize ./temp/tests.js --wit ./wit -n imports -o out/tests.wasm --disable 'http'",
38
+ "test:jco": "jco componentize --backend qjs ./temp/tests.js --wit ./wit -n imports -o out/tests.wasm --disable 'http'",
33
39
  "example": "npm run example:rollup && npm run example:jco",
34
40
  "example:rollup": "rollup --config './examples/rollup.config.js' --configExample=$npm_config_example",
35
- "example:jco": "mkdir -p out && jco componentize temp/$npm_config_example.js --wit ./wit -n imports -o out/$npm_config_example.wasm --disable 'http' --debug-starlingmonkey-build"
41
+ "example:jco": "mkdir -p out && jco componentize --backend qjs temp/$npm_config_example.js --wit ./wit -n imports -o out/$npm_config_example.wasm"
36
42
  },
37
43
  "devDependencies": {
38
- "@bytecodealliance/jco": "^1.11.2",
44
+ "@bytecodealliance/jco": "^1.40.0",
39
45
  "@rollup/plugin-typescript": "^12.1.1",
40
46
  "@types/dom-mediacapture-transform": "^0.1.10",
41
47
  "@types/node": "22.15.7",
42
48
  "@types/w3c-image-capture": "^1.0.10",
43
- "@webgpu/types": "^0.1.52",
49
+ "@webgpu/types": "^0.1.74",
44
50
  "rollup": "^4.12.0",
45
51
  "tslib": "^2.8.1",
46
52
  "typescript": "^5.7.2"
@@ -1,5 +1,5 @@
1
- /** @module Interface wasi:cli/run@0.2.0 **/
1
+ /** @module Interface wasi:cli/run@0.3.0 **/
2
2
  /**
3
3
  * Run the program.
4
4
  */
5
- export function run(): void;
5
+ export function run(): Promise<void>;
@@ -1,3 +1,14 @@
1
- /** @module Interface wasi:cli/stdout@0.2.0 **/
2
- export function getStdout(): OutputStream;
3
- export type OutputStream = import('./wasi-io-streams.js').OutputStream;
1
+ /** @module Interface wasi:cli/stdout@0.3.0 **/
2
+ /**
3
+ * Write the given stream to stdout.
4
+ *
5
+ * If the stream's writable end is dropped this function will either return
6
+ * success once the entire contents of the stream have been written or an
7
+ * error-code representing a failure.
8
+ *
9
+ * Otherwise if there is an error the readable end of the stream will be
10
+ * dropped and this function will return an error-code.
11
+ */
12
+ export function writeViaStream(data: AsyncIterable<number>): PromiseLike<Result<void, ErrorCode>>;
13
+ export type ErrorCode = import('./wasi-cli-types.js').ErrorCode;
14
+ export type Result<T, E> = { tag: 'ok', val: T } | { tag: 'err', val: E };
@@ -0,0 +1,15 @@
1
+ /** @module Interface wasi:cli/types@0.3.0 **/
2
+ /**
3
+ * # Variants
4
+ *
5
+ * ## `"io"`
6
+ *
7
+ * Input/output error
8
+ * ## `"illegal-byte-sequence"`
9
+ *
10
+ * Invalid or incomplete multibyte or wide character
11
+ * ## `"pipe"`
12
+ *
13
+ * Broken pipe
14
+ */
15
+ export type ErrorCode = 'io' | 'illegal-byte-sequence' | 'pipe';
@@ -0,0 +1,13 @@
1
+ /** @module Interface wasi-gfx:frame-buffer/frame-buffer@0.2.0 **/
2
+
3
+ export class Buffer {
4
+ /**
5
+ * This type does not have a public constructor.
6
+ */
7
+ private constructor();
8
+ /**
9
+ * TODO: This should be replaced with something that doesn't require a copy.
10
+ */
11
+ getWithCopy(): Uint8Array;
12
+ setWithCopy(val: Uint8Array): void;
13
+ }
@@ -0,0 +1,12 @@
1
+ /** @module Interface wasi-gfx:surface/surface-frame-buffer@0.2.0 **/
2
+ export type Buffer = import('./wasi-gfx-frame-buffer-frame-buffer.js').Buffer;
3
+ export type Surface = import('./wasi-gfx-surface-surface.js').Surface;
4
+
5
+ export class Context {
6
+ constructor(surface: Surface)
7
+ getCurrentBuffer(): Buffer;
8
+ /**
9
+ * TODO: consider if needed
10
+ */
11
+ present(): void;
12
+ }
@@ -0,0 +1,29 @@
1
+ /** @module Interface wasi-gfx:surface/surface-webgpu@0.2.0 **/
2
+ export type GpuDevice = import('./wasi-webgpu-webgpu.js').GpuDevice;
3
+ export type GpuTexture = import('./wasi-webgpu-webgpu.js').GpuTexture;
4
+ export type GpuTextureFormat = import('./wasi-webgpu-webgpu.js').GpuTextureFormat;
5
+ export type GpuTextureUsage = import('./wasi-webgpu-webgpu.js').GpuTextureUsage;
6
+ export type PredefinedColorSpace = import('./wasi-webgpu-webgpu.js').PredefinedColorSpace;
7
+ export type GpuCanvasToneMapping = import('./wasi-webgpu-webgpu.js').GpuCanvasToneMapping;
8
+ export type GpuCanvasAlphaMode = import('./wasi-webgpu-webgpu.js').GpuCanvasAlphaMode;
9
+ export type Surface = import('./wasi-gfx-surface-surface.js').Surface;
10
+ export interface ContextConfiguration {
11
+ device: GpuDevice,
12
+ format: GpuTextureFormat,
13
+ usage?: GpuTextureUsage,
14
+ viewFormats?: Array<GpuTextureFormat>,
15
+ colorSpace?: PredefinedColorSpace,
16
+ toneMapping?: GpuCanvasToneMapping,
17
+ alphaMode?: GpuCanvasAlphaMode,
18
+ }
19
+
20
+ export class Context {
21
+ constructor(surface: Surface)
22
+ configure(configuration: ContextConfiguration): void;
23
+ unconfigure(): void;
24
+ getCurrentTexture(): GpuTexture;
25
+ /**
26
+ * TODO: consider if needed
27
+ */
28
+ present(): void;
29
+ }
@@ -1,6 +1,4 @@
1
- /** @module Interface wasi:surface/surface@0.0.1 **/
2
- export type Context = import('./wasi-graphics-context-graphics-context.js').Context;
3
- export type Pollable = import('./wasi-io-poll.js').Pollable;
1
+ /** @module Interface wasi-gfx:surface/surface@0.2.0 **/
4
2
  export interface CreateDesc {
5
3
  height?: number,
6
4
  width?: number,
@@ -379,22 +377,14 @@ export interface KeyEvent {
379
377
 
380
378
  export class Surface {
381
379
  constructor(desc: CreateDesc)
382
- connectGraphicsContext(context: Context): void;
383
380
  height(): number;
384
381
  width(): number;
385
382
  requestSetSize(height: number | undefined, width: number | undefined): void;
386
- subscribeResize(): Pollable;
387
- getResize(): ResizeEvent | undefined;
388
- subscribeFrame(): Pollable;
389
- getFrame(): FrameEvent | undefined;
390
- subscribePointerUp(): Pollable;
391
- getPointerUp(): PointerEvent | undefined;
392
- subscribePointerDown(): Pollable;
393
- getPointerDown(): PointerEvent | undefined;
394
- subscribePointerMove(): Pollable;
395
- getPointerMove(): PointerEvent | undefined;
396
- subscribeKeyUp(): Pollable;
397
- getKeyUp(): KeyEvent | undefined;
398
- subscribeKeyDown(): Pollable;
399
- getKeyDown(): KeyEvent | undefined;
383
+ onResize(): AsyncIterable<ResizeEvent>;
384
+ onFrame(): AsyncIterable<FrameEvent>;
385
+ onPointerUp(): AsyncIterable<PointerEvent>;
386
+ onPointerDown(): AsyncIterable<PointerEvent>;
387
+ onPointerMove(): AsyncIterable<PointerEvent>;
388
+ onKeyUp(): AsyncIterable<KeyEvent>;
389
+ onKeyDown(): AsyncIterable<KeyEvent>;
400
390
  }