@thi.ng/wasm-api
Advanced tools
Comparing version 1.0.1 to 1.1.0
import type { Fn, IDeref, ILength } from "@thi.ng/api"; | ||
import type { WasmBridge } from "./bridge.js"; | ||
export declare const EVENT_MEMORY_CHANGED = "memory-changed"; | ||
export declare const EVENT_PANIC = "panic"; | ||
export declare type BigIntArray = bigint[] | BigInt64Array | BigUint64Array; | ||
@@ -5,0 +6,0 @@ export declare type ReadonlyWasmString = IDeref<string> & ILength & { |
export const EVENT_MEMORY_CHANGED = "memory-changed"; | ||
export const EVENT_PANIC = "panic"; |
@@ -184,4 +184,4 @@ /// <reference types="node" /> | ||
/** {@inheritDoc @thi.ng/api#INotify.notify} */ | ||
notify(event: Event): void; | ||
notify(event: Event): boolean; | ||
} | ||
//# sourceMappingURL=bridge.d.ts.map |
@@ -8,3 +8,3 @@ import { __decorate } from "tslib"; | ||
import { ConsoleLogger } from "@thi.ng/logger/console"; | ||
import { EVENT_MEMORY_CHANGED, } from "./api.js"; | ||
import { EVENT_MEMORY_CHANGED, EVENT_PANIC, } from "./api.js"; | ||
export const Panic = defError(() => "Panic"); | ||
@@ -73,3 +73,6 @@ export const OutOfMemoryError = defError(() => "Out of memory"); | ||
_panic: (addr, len) => { | ||
throw new Panic(this.getString(addr, len)); | ||
const msg = this.getString(addr, len); | ||
if (!this.notify({ id: EVENT_PANIC, value: msg })) { | ||
throw new Panic(msg); | ||
} | ||
}, | ||
@@ -76,0 +79,0 @@ timer: () => performance.now(), |
# Change Log | ||
- **Last updated**: 2022-11-24T12:23:48Z | ||
- **Last updated**: 2022-11-28T13:36:49Z | ||
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub) | ||
@@ -12,2 +12,11 @@ | ||
## [1.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/wasm-api@1.1.0) (2022-11-28) | ||
#### 🚀 Features | ||
- update panic handler, add event support ([ab940d9](https://github.com/thi-ng/umbrella/commit/ab940d9)) | ||
- update panic handler to broadcast event w/ panic message | ||
- only throw Panic error if no listeners could be notified | ||
- add `EVENT_PANIC` constant | ||
# [1.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/wasm-api@1.0.0) (2022-11-23) | ||
@@ -14,0 +23,0 @@ |
{ | ||
"name": "@thi.ng/wasm-api", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Generic, modular, extensible API bridge and infrastructure for hybrid JS & WebAssembly projects", | ||
@@ -38,8 +38,8 @@ "type": "module", | ||
"dependencies": { | ||
"@thi.ng/api": "^8.4.6", | ||
"@thi.ng/arrays": "^2.4.2", | ||
"@thi.ng/api": "^8.5.0", | ||
"@thi.ng/arrays": "^2.4.3", | ||
"@thi.ng/checks": "^3.3.3", | ||
"@thi.ng/errors": "^2.2.4", | ||
"@thi.ng/hex": "^2.3.0", | ||
"@thi.ng/idgen": "^2.1.18", | ||
"@thi.ng/idgen": "^2.1.19", | ||
"@thi.ng/logger": "^1.4.3" | ||
@@ -114,3 +114,3 @@ }, | ||
}, | ||
"gitHead": "8d59e559a576ecb3d2c2d13edf5c3146df95d6ac\n" | ||
"gitHead": "75ec32ff7f1b7b5e72e7a04ace24732cd5d6c774\n" | ||
} |
@@ -13,7 +13,8 @@ <!-- This file is generated - DO NOT EDIT! --> | ||
- [About](#about) | ||
- [Custom API modules](#custom-api-modules) | ||
- [Custom API modules](#custom-api-modules) | ||
- [Building Zig projects with these hybrid API modules](#building-zig-projects-with-these-hybrid-api-modules) | ||
- [String handling](#string-handling) | ||
- [Memory allocations](#memory-allocations) | ||
- [Object indices & handles](#object-indices--handles) | ||
- [String handling](#string-handling) | ||
- [Memory allocations](#memory-allocations) | ||
- [API module auto-initialization](#api-module-auto-initialization) | ||
- [Object indices & handles](#object-indices--handles) | ||
- [Status](#status) | ||
@@ -68,3 +69,3 @@ - [Support packages](#support-packages) | ||
### Custom API modules | ||
## Custom API modules | ||
@@ -131,3 +132,4 @@ The | ||
In Zig (or any other language of your choice) we can then utilize this custom | ||
API like so (Please also see [example projects](https://github.com/thi-ng/umbrella/tree/develop/examples/zig-canvas/) | ||
API like so (Please also see [example | ||
projects](https://github.com/thi-ng/umbrella/tree/develop/examples/zig-canvas/) | ||
& other example snippets in this readme): | ||
@@ -182,3 +184,3 @@ | ||
### String handling | ||
## String handling | ||
@@ -205,3 +207,3 @@ Most low-level languages deal with strings very differently and alas there's no | ||
### Memory allocations | ||
## Memory allocations | ||
@@ -252,4 +254,15 @@ If explicitly enabled on the WASM side, the `WasmBridge` includes support for | ||
### Object indices & handles | ||
### API module auto-initialization | ||
The supplied child APIs | ||
([wasm-api-dom](https://github.com/thi-ng/umbrella/tree/develop/packages/wasm-api-dom), | ||
[wasm-api-schedule](https://github.com/thi-ng/umbrella/tree/develop/packages/wasm-api-schedule) | ||
etc.) use an auto-intialization hook related to the above `WASM_ALLOCATOR` | ||
mechanism: If that allocator is available, the WASM side of these modules will | ||
auto initialize and thus reduce boilerplate. However, if no such central | ||
allocator is defined and/or a custom allocator should be used, then these API | ||
modules will be have to be initialized manually. | ||
## Object indices & handles | ||
Since only numeric values can be exchanged between the WASM module and the JS | ||
@@ -300,9 +313,10 @@ host, any JS native objects the WASM side might want to be working with must be | ||
Since v0.15.0, the supplied Zig core bindings lib also includes a | ||
The supplied Zig core library also includes a | ||
[`ManagedIndex`](https://github.com/thi-ng/umbrella/blob/develop/packages/wasm-api/zig/managed-index.zig) | ||
for similar dealings on the Zig side of the application. For example, in the | ||
for similar resource management on the Zig side of the application. For example, | ||
in the | ||
[@thi.ng/wasm-api-dom](https://github.com/thi-ng/umbrella/blob/develop/packages/wasm-api-dom/) | ||
& | ||
[@thi.ng/wasm-api-schedule](https://github.com/thi-ng/umbrella/blob/develop/packages/wasm-api-schedule/) | ||
packages this is used to manage Zig event listeners. | ||
packages this is used to manage Zig-side event listeners. | ||
@@ -344,3 +358,3 @@ ## Status | ||
Package sizes (gzipped, pre-treeshake): ESM: 2.70 KB | ||
Package sizes (gzipped, pre-treeshake): ESM: 2.73 KB | ||
@@ -347,0 +361,0 @@ ## Dependencies |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
124856
1429
506
Updated@thi.ng/api@^8.5.0
Updated@thi.ng/arrays@^2.4.3
Updated@thi.ng/idgen@^2.1.19