@thi.ng/wasm-api
Advanced tools
Comparing version
@@ -95,2 +95,7 @@ import type { BigType, FloatType, Fn, IDeref, ILength, IObjectOf } from "@thi.ng/api"; | ||
/** | ||
* Initializes and/or updates the various typed WASM memory views (e.g. | ||
* after growing the WASM memory and the previous buffer becoming detached). | ||
*/ | ||
ensureMemory(): void; | ||
/** | ||
* Reads UTF-8 encoded string from given address and optional byte length. | ||
@@ -97,0 +102,0 @@ * The default length is 0, which will be interpreted as a zero-terminated |
@@ -417,2 +417,3 @@ import { __decorate } from "tslib"; | ||
setString(str, addr, maxBytes, terminate = true) { | ||
this.ensureMemory(); | ||
maxBytes = Math.min(maxBytes, this.u8.length - addr); | ||
@@ -419,0 +420,0 @@ const len = this.utf8Encoder.encodeInto(str, this.u8.subarray(addr, addr + maxBytes)).written; |
# Change Log | ||
- **Last updated**: 2022-10-04T17:35:45Z | ||
- **Last updated**: 2022-10-17T12:08:09Z | ||
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub) | ||
@@ -12,2 +12,14 @@ | ||
## [0.14.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/wasm-api@0.14.0) (2022-10-17) | ||
#### 🚀 Features | ||
- add ptrCast() zig helper ([72a9406](https://github.com/thi-ng/umbrella/commit/72a9406)) | ||
- add Zig Slice & String wrappers ([28d057e](https://github.com/thi-ng/umbrella/commit/28d057e)) | ||
- allows expressing & converting slices for `extern struct`s | ||
- ensure memory in WasmStringSlice/Ptr ([c55c6f0](https://github.com/thi-ng/umbrella/commit/c55c6f0)) | ||
- update IWasmMemoryAccess ([28bfff6](https://github.com/thi-ng/umbrella/commit/28bfff6)) | ||
- add IWasmMemoryAccess.ensureMemory() | ||
- update WasmBridge.setString() to ensure memory | ||
## [0.13.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/wasm-api@0.13.0) (2022-10-04) | ||
@@ -14,0 +26,0 @@ |
{ | ||
"name": "@thi.ng/wasm-api", | ||
"version": "0.13.1", | ||
"version": "0.14.0", | ||
"description": "Generic, modular, extensible API bridge, polyglot glue code and bindings code generators for hybrid JS & WebAssembly projects", | ||
@@ -40,13 +40,13 @@ "type": "module", | ||
"@thi.ng/api": "^8.4.3", | ||
"@thi.ng/args": "^2.2.4", | ||
"@thi.ng/args": "^2.2.5", | ||
"@thi.ng/binary": "^3.3.6", | ||
"@thi.ng/checks": "^3.2.6", | ||
"@thi.ng/checks": "^3.3.0", | ||
"@thi.ng/compare": "^2.1.13", | ||
"@thi.ng/defmulti": "^2.1.17", | ||
"@thi.ng/defmulti": "^2.1.18", | ||
"@thi.ng/errors": "^2.2.2", | ||
"@thi.ng/file-io": "^0.3.14", | ||
"@thi.ng/file-io": "^0.3.15", | ||
"@thi.ng/hex": "^2.2.1", | ||
"@thi.ng/idgen": "^2.1.15", | ||
"@thi.ng/logger": "^1.4.0", | ||
"@thi.ng/paths": "^5.1.17", | ||
"@thi.ng/logger": "^1.4.1", | ||
"@thi.ng/paths": "^5.1.18", | ||
"@thi.ng/strings": "^3.3.14" | ||
@@ -56,3 +56,3 @@ }, | ||
"@microsoft/api-extractor": "^7.31.1", | ||
"@thi.ng/testament": "^0.3.2", | ||
"@thi.ng/testament": "^0.3.3", | ||
"rimraf": "^3.0.2", | ||
@@ -67,2 +67,3 @@ "tools": "^0.0.1", | ||
"bindings", | ||
"browser", | ||
"c", | ||
@@ -72,5 +73,6 @@ "codegen", | ||
"event", | ||
"id", | ||
"interop", | ||
"logger", | ||
"memory", | ||
"modular", | ||
"polyglot", | ||
@@ -84,3 +86,2 @@ "string", | ||
"webassembly", | ||
"wrapper", | ||
"ziglang" | ||
@@ -102,4 +103,4 @@ ], | ||
"bin", | ||
"include", | ||
"codegen" | ||
"codegen", | ||
"include" | ||
], | ||
@@ -145,3 +146,3 @@ "exports": { | ||
}, | ||
"gitHead": "c3f7d6598c7d7d0c61ba87150a56deac12649d7b\n" | ||
"gitHead": "612b1b0bdf442473f04c2edac3012975a6ca28bb\n" | ||
} |
@@ -18,2 +18,3 @@ import { unsupported } from "@thi.ng/errors/unsupported"; | ||
get addr() { | ||
this.mem.ensureMemory(); | ||
return this.mem.u32[this.base >>> 2]; | ||
@@ -25,2 +26,3 @@ } | ||
get length() { | ||
this.mem.ensureMemory(); | ||
return this.mem.u32[(this.base + 4) >>> 2]; | ||
@@ -53,2 +55,3 @@ } | ||
set(str) { | ||
this.mem.ensureMemory(); | ||
if (typeof str === "string") { | ||
@@ -71,2 +74,3 @@ if (this.isConst) | ||
setSlice(addr, len) { | ||
this.mem.ensureMemory(); | ||
this.mem.u32[this.base >>> 2] = addr; | ||
@@ -100,5 +104,7 @@ this.mem.u32[(this.base + 4) >>> 2] = len; | ||
get addr() { | ||
this.mem.ensureMemory(); | ||
return this.mem.u32[this.base >>> 2]; | ||
} | ||
set addr(addr) { | ||
this.mem.ensureMemory(); | ||
this.mem.u32[this.base >>> 2] = addr; | ||
@@ -110,5 +116,5 @@ } | ||
get length() { | ||
const addr = this.addr; | ||
const idx = this.mem.u8.indexOf(0, addr); | ||
return idx >= 0 ? idx - addr : 0; | ||
this.mem.ensureMemory(); | ||
const idx = this.mem.u8.indexOf(0, this.addr); | ||
return idx >= 0 ? idx - this.addr : 0; | ||
} | ||
@@ -146,2 +152,3 @@ /** | ||
unsupported("can't mutate const string"); | ||
this.mem.ensureMemory(); | ||
this.mem.setString(str, addr, this.mem.u8.byteLength - addr, true); | ||
@@ -148,0 +155,0 @@ } |
Sorry, the diff of this file is not supported yet
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
163840
1.5%2815
0.46%+ Added
- Removed
Updated
Updated
Updated
Updated
Updated
Updated