@wasi-gfx/js-webgpu 0.4.0 → 0.4.1

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 (2) hide show
  1. package/dist/webgpu.js +13 -3
  2. package/package.json +1 -1
package/dist/webgpu.js CHANGED
@@ -774,9 +774,19 @@ export class GPUDevice extends EventTarget {
774
774
  this[inner].setLabel(value);
775
775
  }
776
776
  get lost() {
777
- if (!this.#lost)
778
- this.#lost = Promise.resolve(this[inner].lost())
779
- .then(info => new GPUDeviceLostInfo(key, info));
777
+ if (!this.#lost) {
778
+ // The generated types declare `lost()` as `PromiseLike`, but componentize-qjs returns a non-thenable future reader (`.read()` yields the value). So read it only if it isn't thenable.
779
+ // See https://github.com/bytecodealliance/jco/issues/2532
780
+ const lost = this[inner].lost();
781
+ let info;
782
+ if ('then' in lost && typeof lost.then === 'function') {
783
+ info = Promise.resolve(lost);
784
+ }
785
+ else {
786
+ info = lost.read();
787
+ }
788
+ this.#lost = info.then(info => new GPUDeviceLostInfo(key, info));
789
+ }
780
790
  return this.#lost;
781
791
  }
782
792
  get features() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wasi-gfx/js-webgpu",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "WebGPU JavaScript API on top of wasi-gfx",
5
5
  "exports": {
6
6
  "./canvas": {