@thi.ng/wasm-api 2.2.7 → 2.3.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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2025-01-04T21:07:38Z
3
+ - **Last updated**: 2025-01-14T12:23:33Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,18 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ### [2.3.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/wasm-api@2.3.1) (2025-01-14)
13
+
14
+ #### ♻️ Refactoring
15
+
16
+ - use optional chaining & nullish coalescing ([c5a0a13](https://github.com/thi-ng/umbrella/commit/c5a0a13))
17
+
18
+ ## [2.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/wasm-api@2.3.0) (2025-01-10)
19
+
20
+ #### 🚀 Features
21
+
22
+ - add WasmTypeKeys helper type ([7e293ce](https://github.com/thi-ng/umbrella/commit/7e293ce))
23
+
12
24
  ### [2.2.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/wasm-api@2.2.1) (2024-11-10)
13
25
 
14
26
  #### 🩹 Bug fixes
package/README.md CHANGED
@@ -27,6 +27,7 @@
27
27
  - [Naming & structural conventions](#naming--structural-conventions)
28
28
  - [Status](#status)
29
29
  - [Support packages](#support-packages)
30
+ - [Third party modules](#third-party-modules)
30
31
  - [Installation](#installation)
31
32
  - [Dependencies](#dependencies)
32
33
  - [Usage examples](#usage-examples)
@@ -440,6 +441,10 @@ please also consult the information in
440
441
  - [@thi.ng/wasm-api-schedule](https://github.com/thi-ng/umbrella/tree/develop/packages/wasm-api-schedule) - Delayed & scheduled function execution (via setTimeout() etc.) for hybrid WASM apps
441
442
  - [@thi.ng/wasm-api-webgl](https://github.com/thi-ng/umbrella/tree/develop/packages/wasm-api-webgl) - WebGL bridge API for hybrid TypeScript & WASM (Zig) applications
442
443
 
444
+ ### Third party modules
445
+
446
+ - [@genart-api/wasm](https://github.com/thi-ng/genart-api/tree/main/packages/wasm) — WASM/Zig bindings for [GenArtAPI](https://thi.ng/genart-api)
447
+
443
448
  ## Installation
444
449
 
445
450
  ```bash
package/api.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { BigTypedArray, EVENT_ALL, Fn, IDeref, ILength, TypedArray, Values } from "@thi.ng/api";
1
+ import type { BigTypedArray, EVENT_ALL, Fn, IDeref, ILength, Keys, TypedArray, Values } from "@thi.ng/api";
2
2
  import type { WasmBridge } from "./bridge.js";
3
3
  export declare const EVENT_MEMORY_CHANGED = "memory-changed";
4
4
  export declare const EVENT_PANIC = "panic";
@@ -17,6 +17,11 @@ export interface WasmTypeBase {
17
17
  */
18
18
  readonly __bytes: Uint8Array;
19
19
  }
20
+ /**
21
+ * Helper type to extract field names of structs/unions based on
22
+ * {@link WasmTypeBase} (e.g. those generated by thi.ng/wasm-api-bindgen).
23
+ */
24
+ export type WasmTypeKeys<T extends WasmTypeBase> = Keys<Omit<T, Keys<WasmTypeBase>>>;
20
25
  export interface WasmType<T> {
21
26
  /**
22
27
  * Type alignment (in bytes)
package/bridge.d.ts CHANGED
@@ -120,8 +120,8 @@ export declare class WasmBridge<T extends WasmExports = WasmExports> implements
120
120
  * @remarks
121
121
  * Each API module's imports will be in their own WASM import object/table,
122
122
  * named using the same key which is defined by the JS side of the module
123
- * via {@link IWasmAPI.id}. The bridge's core API is named `wasmapi` and is
124
- * reserved.
123
+ * via {@link WasmModuleSpec.id}. The bridge's core API is named `wasmapi`
124
+ * and is reserved.
125
125
  *
126
126
  * @example
127
127
  * The following creates a bridge with a fictional `custom` API module:
package/bridge.js CHANGED
@@ -180,7 +180,7 @@ let WasmBridge = class {
180
180
  */
181
181
  ensureMemory(notify = true) {
182
182
  const buf = this.exports.memory.buffer;
183
- if (this.u8 && this.u8.buffer === buf) return;
183
+ if (this.u8?.buffer === buf) return;
184
184
  this.i8 = new Int8Array(buf);
185
185
  this.u8 = new Uint8Array(buf);
186
186
  this.i16 = new Int16Array(buf);
@@ -204,8 +204,8 @@ let WasmBridge = class {
204
204
  * @remarks
205
205
  * Each API module's imports will be in their own WASM import object/table,
206
206
  * named using the same key which is defined by the JS side of the module
207
- * via {@link IWasmAPI.id}. The bridge's core API is named `wasmapi` and is
208
- * reserved.
207
+ * via {@link WasmModuleSpec.id}. The bridge's core API is named `wasmapi`
208
+ * and is reserved.
209
209
  *
210
210
  * @example
211
211
  * The following creates a bridge with a fictional `custom` API module:
package/object-index.js CHANGED
@@ -27,7 +27,7 @@ class ObjectIndex {
27
27
  */
28
28
  add(item) {
29
29
  const id = this.idgen.next();
30
- this.logger && this.logger.debug(`adding ${this.name} ID: ${id}`);
30
+ this.logger?.debug(`adding ${this.name} ID: ${id}`);
31
31
  this.items[id] = item;
32
32
  return id;
33
33
  }
@@ -65,7 +65,7 @@ class ObjectIndex {
65
65
  */
66
66
  delete(id, ensure = true) {
67
67
  if (this.idgen.has(id)) {
68
- this.logger && this.logger.debug(`deleting ${this.name} ID: ${id}`);
68
+ this.logger?.debug(`deleting ${this.name} ID: ${id}`);
69
69
  this.idgen.free(id);
70
70
  delete this.items[id];
71
71
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/wasm-api",
3
- "version": "2.2.7",
3
+ "version": "2.3.1",
4
4
  "description": "Generic, modular, extensible API bridge and infrastructure for hybrid JS & WebAssembly projects",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -44,12 +44,12 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@thi.ng/api": "^8.11.16",
47
- "@thi.ng/arrays": "^2.10.9",
48
- "@thi.ng/checks": "^3.6.18",
47
+ "@thi.ng/arrays": "^2.10.10",
48
+ "@thi.ng/checks": "^3.6.19",
49
49
  "@thi.ng/errors": "^2.5.22",
50
50
  "@thi.ng/hex": "^2.3.60",
51
51
  "@thi.ng/idgen": "^2.2.56",
52
- "@thi.ng/logger": "^3.0.26"
52
+ "@thi.ng/logger": "^3.0.27"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@microsoft/api-extractor": "^7.48.1",
@@ -128,5 +128,5 @@
128
128
  "status": "alpha",
129
129
  "year": 2022
130
130
  },
131
- "gitHead": "56c1d57a96565bbcc8c06c73779a619bba0db368\n"
131
+ "gitHead": "6542b842120bef47cc18d45a1b1db68307a7f04b\n"
132
132
  }