@thi.ng/wasm-api 1.2.1 → 1.2.3
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 +1 -1
- package/README.md +22 -16
- package/api.d.ts +4 -4
- package/package.json +15 -15
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<!-- This file is generated - DO NOT EDIT! -->
|
|
2
2
|
|
|
3
|
-
# 
|
|
3
|
+
# 
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@thi.ng/wasm-api)
|
|
6
6
|

|
|
7
|
-
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
This project is part of the
|
|
10
10
|
[@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo.
|
|
@@ -31,7 +31,7 @@ This project is part of the
|
|
|
31
31
|
|
|
32
32
|
## About
|
|
33
33
|
|
|
34
|
-
Generic, modular, extensible API bridge and infrastructure for hybrid JS & WebAssembly projects
|
|
34
|
+
Generic, modular, extensible API bridge and infrastructure for hybrid JS & WebAssembly projects
|
|
35
35
|
|
|
36
36
|
This package provides the following:
|
|
37
37
|
|
|
@@ -56,8 +56,8 @@ WebGL, WebGPU, WebAudio etc. is being actively worked on.
|
|
|
56
56
|
defining glue code for the TypeScript [core
|
|
57
57
|
API](https://docs.thi.ng/umbrella/wasm-api/interfaces/CoreAPI.html) defined
|
|
58
58
|
by this package
|
|
59
|
-
7. [Zig build files]() to simplify using hybrid
|
|
60
|
-
built-in build system
|
|
59
|
+
7. [Zig build files](#using-the-zig-build-system) to simplify using hybrid
|
|
60
|
+
TS/Zig packages with the built-in build system
|
|
61
61
|
8. Extensible shared [datatype code generator
|
|
62
62
|
infrastructure](https://github.com/thi-ng/umbrella/tree/develop/packages/wasm-api-bindgen/)
|
|
63
63
|
for (currently) Zig & TypeScript and C11. For TS fully type checked and
|
|
@@ -305,13 +305,17 @@ packages this is used to manage Zig-side event listeners.
|
|
|
305
305
|
|
|
306
306
|
## Using the Zig build system
|
|
307
307
|
|
|
308
|
-
This package provides utilities to simplify using hybrid TS/Zig WASM API modules
|
|
308
|
+
This package provides utilities to simplify using hybrid TS/Zig WASM API modules
|
|
309
|
+
which are distributed as NPM packages. Using these utils, a build file for Zig's
|
|
310
|
+
built-in build system is as simple as:
|
|
309
311
|
|
|
310
312
|
```zig
|
|
311
313
|
const std = @import("std");
|
|
312
314
|
|
|
313
315
|
pub fn build(b: *std.build.Builder) void {
|
|
314
|
-
|
|
316
|
+
// obtain a standard std.build.LibExeObjStep, pre-configured w/ given options
|
|
317
|
+
// see source comments in imported build.zig for further details...
|
|
318
|
+
var lib = @import("node_modules/@thi.ng/wasm-api/zig/build.zig").wasmLib(b, .{
|
|
315
319
|
// Declare extra WASM API packages to use
|
|
316
320
|
// Each package can also declare dependencies to other such packages
|
|
317
321
|
// (wasm-api and wasm-api-bindgen are made available everywhere)
|
|
@@ -320,9 +324,14 @@ pub fn build(b: *std.build.Builder) void {
|
|
|
320
324
|
.{ .id = "wasm-api-schedule", .path = "@thi.ng/wasm-api-schedule/zig/lib.zig" },
|
|
321
325
|
},
|
|
322
326
|
// (optional) build mode override
|
|
323
|
-
|
|
327
|
+
// if commented out, we can pass CLI args to choose build mode (default: .Debug)
|
|
324
328
|
.mode = .ReleaseSmall,
|
|
325
|
-
})
|
|
329
|
+
});
|
|
330
|
+
// optionally, add further custom configuration
|
|
331
|
+
// ...
|
|
332
|
+
|
|
333
|
+
// finally trigger build
|
|
334
|
+
lib.install();
|
|
326
335
|
}
|
|
327
336
|
```
|
|
328
337
|
|
|
@@ -365,11 +374,8 @@ ES module import:
|
|
|
365
374
|
|
|
366
375
|
For Node.js REPL:
|
|
367
376
|
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
node --experimental-repl-await
|
|
371
|
-
|
|
372
|
-
> const wasmApi = await import("@thi.ng/wasm-api");
|
|
377
|
+
```js
|
|
378
|
+
const wasmApi = await import("@thi.ng/wasm-api");
|
|
373
379
|
```
|
|
374
380
|
|
|
375
381
|
Package sizes (brotli'd, pre-treeshake): ESM: 2.47 KB
|
|
@@ -512,7 +518,7 @@ emcc -Os -Inode_modules/@thi.ng/wasm-api/include \
|
|
|
512
518
|
|
|
513
519
|
## Authors
|
|
514
520
|
|
|
515
|
-
Karsten Schmidt
|
|
521
|
+
- [Karsten Schmidt](https://thi.ng)
|
|
516
522
|
|
|
517
523
|
If this project contributes to an academic publication, please cite it as:
|
|
518
524
|
|
|
@@ -527,4 +533,4 @@ If this project contributes to an academic publication, please cite it as:
|
|
|
527
533
|
|
|
528
534
|
## License
|
|
529
535
|
|
|
530
|
-
© 2022 Karsten Schmidt // Apache
|
|
536
|
+
© 2022 Karsten Schmidt // Apache License 2.0
|
package/api.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import type { Fn, IDeref, ILength } 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";
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export type BigIntArray = bigint[] | BigInt64Array | BigUint64Array;
|
|
6
|
+
export type ReadonlyWasmString = IDeref<string> & ILength & {
|
|
7
7
|
readonly addr: number;
|
|
8
8
|
};
|
|
9
9
|
export interface WasmTypeBase {
|
|
@@ -21,7 +21,7 @@ export interface WasmType<T> {
|
|
|
21
21
|
readonly size: number;
|
|
22
22
|
instance: Fn<number, T>;
|
|
23
23
|
}
|
|
24
|
-
export
|
|
24
|
+
export type WasmTypeConstructor<T> = Fn<IWasmMemoryAccess, WasmType<T>>;
|
|
25
25
|
/**
|
|
26
26
|
* Common interface for WASM/JS child APIs which will be used in combination
|
|
27
27
|
* with a parent {@link WasmBridge}.
|
|
@@ -111,7 +111,7 @@ export interface WasmExports {
|
|
|
111
111
|
*/
|
|
112
112
|
_wasm_free(addr: number, numBytes: number): void;
|
|
113
113
|
}
|
|
114
|
-
export
|
|
114
|
+
export type MemorySlice = [addr: number, len: number];
|
|
115
115
|
export interface IWasmMemoryAccess {
|
|
116
116
|
i8: Int8Array;
|
|
117
117
|
u8: Uint8Array;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/wasm-api",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Generic, modular, extensible API bridge and infrastructure for hybrid JS & WebAssembly projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/thi-ng/umbrella.git"
|
|
12
12
|
},
|
|
13
|
-
"homepage": "https://github.com/thi-ng/umbrella/tree/
|
|
13
|
+
"homepage": "https://github.com/thi-ng/umbrella/tree/develop/packages/wasm-api#readme",
|
|
14
14
|
"funding": [
|
|
15
15
|
{
|
|
16
16
|
"type": "github",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "https://patreon.com/thing_umbrella"
|
|
22
22
|
}
|
|
23
23
|
],
|
|
24
|
-
"author": "Karsten Schmidt
|
|
24
|
+
"author": "Karsten Schmidt (https://thi.ng)",
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "yarn clean && tsc --declaration",
|
|
@@ -35,21 +35,21 @@
|
|
|
35
35
|
"test:build-zig": "zig build-lib -O ReleaseSmall -target wasm32-freestanding -dynamic --strip --pkg-begin wasmapi zig/lib.zig --pkg-end test/custom.zig && wasm-dis -o custom.wast custom.wasm && cp custom.wasm test"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@thi.ng/api": "^8.
|
|
39
|
-
"@thi.ng/arrays": "^2.4.
|
|
40
|
-
"@thi.ng/checks": "^3.3.
|
|
41
|
-
"@thi.ng/errors": "^2.2.
|
|
42
|
-
"@thi.ng/hex": "^2.3.
|
|
43
|
-
"@thi.ng/idgen": "^2.1.
|
|
44
|
-
"@thi.ng/logger": "^1.4.
|
|
38
|
+
"@thi.ng/api": "^8.6.0",
|
|
39
|
+
"@thi.ng/arrays": "^2.4.5",
|
|
40
|
+
"@thi.ng/checks": "^3.3.5",
|
|
41
|
+
"@thi.ng/errors": "^2.2.6",
|
|
42
|
+
"@thi.ng/hex": "^2.3.2",
|
|
43
|
+
"@thi.ng/idgen": "^2.1.21",
|
|
44
|
+
"@thi.ng/logger": "^1.4.5"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@microsoft/api-extractor": "^7.33.
|
|
48
|
-
"@thi.ng/testament": "^0.3.
|
|
47
|
+
"@microsoft/api-extractor": "^7.33.7",
|
|
48
|
+
"@thi.ng/testament": "^0.3.7",
|
|
49
49
|
"rimraf": "^3.0.2",
|
|
50
50
|
"tools": "^0.0.1",
|
|
51
|
-
"typedoc": "^0.23.
|
|
52
|
-
"typescript": "^4.
|
|
51
|
+
"typedoc": "^0.23.22",
|
|
52
|
+
"typescript": "^4.9.4"
|
|
53
53
|
},
|
|
54
54
|
"keywords": [
|
|
55
55
|
"allocator",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"status": "alpha",
|
|
116
116
|
"year": 2022
|
|
117
117
|
},
|
|
118
|
-
"gitHead": "
|
|
118
|
+
"gitHead": "f445a9cc8022bcdebbf6ff91fd66ced016d72f01\n"
|
|
119
119
|
}
|