@thi.ng/wasm-api 1.5.0 → 1.5.2
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 +30 -33
- package/package.json +10 -11
- package/zig/build-v0.10.zig +4 -2
- package/zig/build-v0.11.zig +3 -3
- package/zig/build.zig +2 -2
- package/zig/zig-cache/tmp/2dfe9a721aef8bbd/build +0 -0
- package/zig/zig-cache/tmp/306b574d8ec701bf/build +0 -0
- package/zig/zig-cache/tmp/7556d654f70c4ae9/build +0 -0
- package/zig/zig-cache/tmp/b5906f3589d7a44e/build +0 -0
- package/zig/zig-cache/tmp/e02fe3c9c8a1234f/build +0 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
- [API module auto-initialization](#api-module-auto-initialization)
|
|
22
22
|
- [Object indices & handles](#object-indices--handles)
|
|
23
23
|
- [Using the Zig build system](#using-the-zig-build-system)
|
|
24
|
-
- [Zig v0.
|
|
24
|
+
- [Zig v0.12 or newer](#zig-v012-or-newer)
|
|
25
25
|
- [Example projects](#example-projects)
|
|
26
26
|
- [Naming & structural conventions](#naming--structural-conventions)
|
|
27
27
|
- [Status](#status)
|
|
@@ -315,11 +315,12 @@ This package provides utilities to simplify using hybrid TS/Zig WASM API modules
|
|
|
315
315
|
which are distributed as NPM packages. Using these utils, a build file for Zig's
|
|
316
316
|
built-in build system is as simple as:
|
|
317
317
|
|
|
318
|
-
### Zig v0.
|
|
318
|
+
### Zig v0.12 or newer
|
|
319
319
|
|
|
320
320
|
**IMPORTANT:** Due to recent [syntax & build system changes in Zig
|
|
321
|
-
v0.
|
|
322
|
-
|
|
321
|
+
v0.12.0](https://ziglang.org/download/0.12.0/release-notes.html), older Zig
|
|
322
|
+
versions are not actively unsupported (however build files for v0.10 and v0.11
|
|
323
|
+
are still included)
|
|
323
324
|
|
|
324
325
|
```zig
|
|
325
326
|
const std = @import("std");
|
|
@@ -470,12 +471,13 @@ scenarios add the supplied .zig file(s) to your `build.zig` and/or source
|
|
|
470
471
|
folder):
|
|
471
472
|
|
|
472
473
|
```bash
|
|
473
|
-
# compile WASM binary
|
|
474
|
-
zig build-
|
|
475
|
-
|
|
476
|
-
-
|
|
477
|
-
|
|
478
|
-
hello.zig
|
|
474
|
+
# compile WASM binary (zig v0.12)
|
|
475
|
+
zig build-exe \
|
|
476
|
+
-fno-entry -fstrip -OReleaseSmall -target wasm32-freestanding \
|
|
477
|
+
--name hello -rdynamic --import-symbols \
|
|
478
|
+
--dep wasm-api \
|
|
479
|
+
-Mroot=hello.zig \
|
|
480
|
+
-Mwasm-api=node_modules/@thi.ng/wasm-api/zig/lib.zig
|
|
479
481
|
|
|
480
482
|
# disassemble WASM
|
|
481
483
|
wasm-dis -o hello.wast hello.wasm
|
|
@@ -485,29 +487,24 @@ The resulting WASM:
|
|
|
485
487
|
|
|
486
488
|
```wasm
|
|
487
489
|
(module
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
(
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
(
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
)
|
|
504
|
-
)
|
|
505
|
-
|
|
506
|
-
(i32.const 0)
|
|
507
|
-
)
|
|
508
|
-
(func $2 (param $0 i32) (param $1 i32)
|
|
509
|
-
)
|
|
510
|
-
)
|
|
490
|
+
(type $t0 (func (param i32 i32)))
|
|
491
|
+
(type $t1 (func))
|
|
492
|
+
(type $t2 (func (param i32) (result i32)))
|
|
493
|
+
(import "wasmapi" "_printStr" (func $wasmapi._printStr (type $t0)))
|
|
494
|
+
(func $start (type $t1)
|
|
495
|
+
(call $wasmapi._printStr
|
|
496
|
+
(i32.const 1048576)
|
|
497
|
+
(i32.const 12)))
|
|
498
|
+
(func $_wasm_allocate (type $t2) (param $p0 i32) (result i32)
|
|
499
|
+
(i32.const 0))
|
|
500
|
+
(func $_wasm_free (type $t0) (param $p0 i32) (param $p1 i32))
|
|
501
|
+
(memory $memory 17)
|
|
502
|
+
(global $g0 (mut i32) (i32.const 1048576))
|
|
503
|
+
(export "memory" (memory $memory))
|
|
504
|
+
(export "start" (func $start))
|
|
505
|
+
(export "_wasm_allocate" (func $_wasm_allocate))
|
|
506
|
+
(export "_wasm_free" (func $_wasm_free))
|
|
507
|
+
(data $d0 (i32.const 1048576) "hello world!\00"))
|
|
511
508
|
```
|
|
512
509
|
|
|
513
510
|
### C version
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/wasm-api",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "Generic, modular, extensible API bridge and infrastructure for hybrid JS & WebAssembly projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"build": "yarn build:esbuild && yarn build:decl",
|
|
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
|
-
"clean": "
|
|
30
|
+
"clean": "bun ../../tools/src/clean-package.ts",
|
|
31
31
|
"doc": "typedoc --excludePrivate --excludeInternal --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",
|
|
@@ -37,18 +37,17 @@
|
|
|
37
37
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@thi.ng/api": "^8.11.
|
|
41
|
-
"@thi.ng/arrays": "^2.9.
|
|
42
|
-
"@thi.ng/checks": "^3.6.
|
|
43
|
-
"@thi.ng/errors": "^2.5.
|
|
44
|
-
"@thi.ng/hex": "^2.3.
|
|
45
|
-
"@thi.ng/idgen": "^2.2.
|
|
46
|
-
"@thi.ng/logger": "^3.0.
|
|
40
|
+
"@thi.ng/api": "^8.11.1",
|
|
41
|
+
"@thi.ng/arrays": "^2.9.5",
|
|
42
|
+
"@thi.ng/checks": "^3.6.3",
|
|
43
|
+
"@thi.ng/errors": "^2.5.6",
|
|
44
|
+
"@thi.ng/hex": "^2.3.45",
|
|
45
|
+
"@thi.ng/idgen": "^2.2.40",
|
|
46
|
+
"@thi.ng/logger": "^3.0.11"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@microsoft/api-extractor": "^7.43.0",
|
|
50
50
|
"esbuild": "^0.20.2",
|
|
51
|
-
"rimraf": "^5.0.5",
|
|
52
51
|
"typedoc": "^0.25.12",
|
|
53
52
|
"typescript": "^5.4.3"
|
|
54
53
|
},
|
|
@@ -116,5 +115,5 @@
|
|
|
116
115
|
"status": "alpha",
|
|
117
116
|
"year": 2022
|
|
118
117
|
},
|
|
119
|
-
"gitHead": "
|
|
118
|
+
"gitHead": "5dd66c18a3862a3af69a5b2f49563f7cbdd960c2\n"
|
|
120
119
|
}
|
package/zig/build-v0.10.zig
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
//! DEPRECATED build helpers for using modules/packages distributed via NPM
|
|
2
2
|
//! Intended for use with https://thi.ng/wasm-api and support packages
|
|
3
3
|
//!
|
|
4
|
-
//! This version of the script is only compatible with
|
|
5
|
-
//!
|
|
4
|
+
//! This version of the script is only compatible with:
|
|
5
|
+
//! Zig v0.10.1 or older
|
|
6
|
+
//!
|
|
7
|
+
//! Use other build.zig files in this same directory for newer Zig versions
|
|
6
8
|
|
|
7
9
|
const std = @import("std");
|
|
8
10
|
|
package/zig/build-v0.11.zig
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
//!
|
|
1
|
+
//! DEPRECATED build helpers for using modules/packages distributed via NPM
|
|
2
2
|
//! Intended for use with https://thi.ng/wasm-api and support packages
|
|
3
3
|
//!
|
|
4
4
|
//! This version of the script is only compatible with:
|
|
5
|
-
//! Zig
|
|
5
|
+
//! Zig v0.11.0
|
|
6
6
|
//!
|
|
7
|
-
//! Use build.zig
|
|
7
|
+
//! Use other build.zig files in this same directory for other Zig versions
|
|
8
8
|
|
|
9
9
|
const std = @import("std");
|
|
10
10
|
const Build = std.Build;
|
package/zig/build.zig
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
//! Intended for use with https://thi.ng/wasm-api and support packages
|
|
3
3
|
//!
|
|
4
4
|
//! This version of the script is only compatible with:
|
|
5
|
-
//! Zig
|
|
5
|
+
//! Zig v0.12.0 or newer
|
|
6
6
|
//!
|
|
7
|
-
//! Use build.zig
|
|
7
|
+
//! Use other build.zig files in this same directory for older Zig versions
|
|
8
8
|
|
|
9
9
|
const std = @import("std");
|
|
10
10
|
const Build = std.Build;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|