@thi.ng/wasm-api 2.1.0 → 2.2.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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-11-09T15:34:31Z
3
+ - **Last updated**: 2024-11-10T17:11:51Z
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,12 @@ 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.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/wasm-api@2.2.0) (2024-11-10)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add defType() construction helper ([947e3fc](https://github.com/thi-ng/umbrella/commit/947e3fc))
17
+
12
18
  ## [2.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/wasm-api@2.1.0) (2024-11-09)
13
19
 
14
20
  #### 🚀 Features
package/README.md CHANGED
@@ -460,7 +460,7 @@ Browser ESM import:
460
460
 
461
461
  [JSDelivr documentation](https://www.jsdelivr.com/)
462
462
 
463
- Package sizes (brotli'd, pre-treeshake): ESM: 3.05 KB
463
+ Package sizes (brotli'd, pre-treeshake): ESM: 3.11 KB
464
464
 
465
465
  ## Dependencies
466
466
 
package/deftype.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import type { Fn2 } from "@thi.ng/api";
2
+ import type { IWasmMemoryAccess, WasmTypeBase, WasmTypeConstructor } from "./api.js";
3
+ /**
4
+ * Shared construction helper for types generated by
5
+ * [thi.ng/wasm-api-bindgen](https://thi.ng/wasm-api-bindgen).
6
+ *
7
+ * @param align
8
+ * @param size
9
+ * @param instance
10
+ */
11
+ export declare const defType: <T extends WasmTypeBase>(align: number, size: number, instance: Fn2<IWasmMemoryAccess, number, Omit<T, keyof WasmTypeBase>>) => WasmTypeConstructor<T>;
12
+ //# sourceMappingURL=deftype.d.ts.map
package/deftype.js ADDED
@@ -0,0 +1,24 @@
1
+ import { __instanceArray } from "./memory.js";
2
+ const defType = (align, size, instance) => (mem) => ({
3
+ get align() {
4
+ return align;
5
+ },
6
+ get size() {
7
+ return size;
8
+ },
9
+ instanceArray(base, num) {
10
+ return __instanceArray(this, base, num);
11
+ },
12
+ instance: (base) => ({
13
+ get __base() {
14
+ return base;
15
+ },
16
+ get __bytes() {
17
+ return mem.u8.subarray(base, base + size);
18
+ },
19
+ ...instance(mem, base)
20
+ })
21
+ });
22
+ export {
23
+ defType
24
+ };
package/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./api.js";
2
2
  export * from "./bridge.js";
3
+ export * from "./deftype.js";
3
4
  export * from "./memory.js";
4
5
  export * from "./object-index.js";
5
6
  export * from "./pointer.js";
package/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./api.js";
2
2
  export * from "./bridge.js";
3
+ export * from "./deftype.js";
3
4
  export * from "./memory.js";
4
5
  export * from "./object-index.js";
5
6
  export * from "./pointer.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/wasm-api",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Generic, modular, extensible API bridge and infrastructure for hybrid JS & WebAssembly projects",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -28,7 +28,7 @@
28
28
  "build:decl": "tsc --declaration --emitDeclarationOnly",
29
29
  "build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
30
30
  "clean": "bun ../../tools/src/clean-package.ts",
31
- "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
31
+ "doc": "typedoc --options ../../typedoc.json --out doc src/index.ts",
32
32
  "doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
33
33
  "doc:readme": "bun ../../tools/src/module-stats.ts && bun ../../tools/src/readme.ts",
34
34
  "pub": "yarn npm publish --access public",
@@ -39,13 +39,13 @@
39
39
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@thi.ng/api": "^8.11.11",
43
- "@thi.ng/arrays": "^2.10.4",
44
- "@thi.ng/checks": "^3.6.13",
45
- "@thi.ng/errors": "^2.5.17",
46
- "@thi.ng/hex": "^2.3.55",
47
- "@thi.ng/idgen": "^2.2.51",
48
- "@thi.ng/logger": "^3.0.21"
42
+ "@thi.ng/api": "^8.11.12",
43
+ "@thi.ng/arrays": "^2.10.5",
44
+ "@thi.ng/checks": "^3.6.14",
45
+ "@thi.ng/errors": "^2.5.18",
46
+ "@thi.ng/hex": "^2.3.56",
47
+ "@thi.ng/idgen": "^2.2.52",
48
+ "@thi.ng/logger": "^3.0.22"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@microsoft/api-extractor": "^7.47.9",
@@ -104,6 +104,9 @@
104
104
  "./bridge": {
105
105
  "default": "./bridge.js"
106
106
  },
107
+ "./deftype": {
108
+ "default": "./deftype.js"
109
+ },
107
110
  "./memory": {
108
111
  "default": "./memory.js"
109
112
  },
@@ -121,5 +124,5 @@
121
124
  "status": "alpha",
122
125
  "year": 2022
123
126
  },
124
- "gitHead": "c2c371069911fdae138149fdcf937c4ad7a8c71e\n"
127
+ "gitHead": "ef89090bb19fc5bca23be5da8cfce05b82ff4ad1\n"
125
128
  }