Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@thi.ng/wasm-api-bindgen

Package Overview
Dependencies
Maintainers
0
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/wasm-api-bindgen - npm Package Compare versions

Comparing version 0.8.1 to 0.8.2

2

CHANGELOG.md
# Change Log
- **Last updated**: 2024-11-10T17:11:51Z
- **Last updated**: 2024-11-13T12:46:52Z
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)

@@ -5,0 +5,0 @@

{
"name": "@thi.ng/wasm-api-bindgen",
"version": "0.8.1",
"version": "0.8.2",
"description": "Polyglot bindings code generators (TS/JS, Zig, C11) for hybrid WebAssembly projects",

@@ -53,3 +53,3 @@ "type": "module",

"@thi.ng/strings": "^3.8.10",
"@thi.ng/wasm-api": "^2.2.1"
"@thi.ng/wasm-api": "^2.2.2"
},

@@ -129,3 +129,3 @@ "devDependencies": {

},
"gitHead": "49023d7517c20e18bc0612051059f9f971372b4c\n"
"gitHead": "10a1633519e744335853d3c64d9d23d06d63cda4\n"
}

@@ -381,3 +381,3 @@ <!-- This file is generated - DO NOT EDIT! -->

/**
* Generated by @thi.ng/wasm-api-bindgen at 2024-08-18T11:18:16.006Z
* Generated by @thi.ng/wasm-api-bindgen at 2024-11-10T21:39:49.822Z
* DO NOT EDIT!

@@ -387,3 +387,3 @@ */

// @ts-ignore possibly includes unused imports
import { Pointer, WasmStringPtr, type IWasmMemoryAccess, type MemorySlice, type MemoryView, type WasmType, type WasmTypeBase, type WasmTypeConstructor } from "@thi.ng/wasm-api";
import { defType, Pointer, WasmStringPtr, type IWasmMemoryAccess, type MemorySlice, type MemoryView, type WasmTypeBase } from "@thi.ng/wasm-api";
// @ts-ignore

@@ -411,34 +411,18 @@ import { __array, __instanceArray, __slice32, __primslice32 } from "@thi.ng/wasm-api/memory";

export const $TestOpts: WasmTypeConstructor<TestOpts> = (mem) => ({
get align() {
return 4;
},
get size() {
return 16;
},
instanceArray(base, num) {
return __instanceArray<TestOpts>(this, base, num);
},
instance: (base) => {
return {
get __base() {
return base;
},
get __bytes() {
return mem.u8.subarray(base, base + 16);
},
get a(): number {
return mem.i32[base >>> 2];
},
set a(x: number) {
mem.i32[base >>> 2] = x;
},
set b(x: number) {
mem.i32[(base + 4) >>> 2] = x;
},
get c(): number {
return mem.i32[(base + 8) >>> 2];
},
};
}
// @ts-ignore possibly unused args
export const $TestOpts = defType<TestOpts>(4, 16, (mem, base) => {
return {
get a(): number {
return mem.i32[base >>> 2];
},
set a(x: number) {
mem.i32[base >>> 2] = x;
},
set b(x: number) {
mem.i32[(base + 4) >>> 2] = x;
},
get c(): number {
return mem.i32[(base + 8) >>> 2];
},
};
});

@@ -451,3 +435,3 @@ ```

```zig
//! Generated by @thi.ng/wasm-api-bindgen at 2024-08-18T11:18:12.197Z
//! Generated by @thi.ng/wasm-api-bindgen at 2024-11-10T21:41:09.049Z
//! DO NOT EDIT!

@@ -641,3 +625,3 @@

/**
* Generated by @thi.ng/wasm-api-bindgen at 2024-08-18T11:20:15.332Z
* Generated by @thi.ng/wasm-api-bindgen at 2024-11-10T21:41:59.477Z
* DO NOT EDIT!

@@ -647,6 +631,9 @@ */

// @ts-ignore possibly includes unused imports
import { Pointer, WasmStringPtr, type IWasmMemoryAccess, type MemorySlice, type MemoryView, type WasmType, type WasmTypeBase, type WasmTypeConstructor } from "@thi.ng/wasm-api";
import { defType, Pointer, WasmStringPtr, type IWasmMemoryAccess, type MemorySlice, type MemoryView, type WasmTypeBase } from "@thi.ng/wasm-api";
// @ts-ignore
import { __array, __instanceArray, __slice32, __primslice32 } from "@thi.ng/wasm-api/memory";
// @ts-ignore possibly unused
const __str = (mem: IWasmMemoryAccess, base: number, isConst = true) => new WasmStringPtr(mem, base, isConst);
/**

@@ -678,32 +665,16 @@ * Supported event types

export const $MouseEvent: WasmTypeConstructor<MouseEvent> = (mem) => ({
get align() {
return 2;
},
get size() {
return 6;
},
instanceArray(base, num) {
return __instanceArray<MouseEvent>(this, base, num);
},
instance: (base) => {
return {
get __base() {
return base;
},
get __bytes() {
return mem.u8.subarray(base, base + 6);
},
get type(): EventType {
return mem.u8[base];
},
set type(x: EventType) {
mem.u8[base] = x;
},
get pos(): Uint16Array {
const addr = (base + 2) >>> 1;
return mem.u16.subarray(addr, addr + 2);
},
};
}
// @ts-ignore possibly unused args
export const $MouseEvent = defType<MouseEvent>(2, 6, (mem, base) => {
return {
get type(): EventType {
return mem.u8[base];
},
set type(x: EventType) {
mem.u8[base] = x;
},
get pos(): Uint16Array {
const addr = (base + 2) >>> 1;
return mem.u16.subarray(addr, addr + 2);
},
};
});

@@ -729,38 +700,22 @@

export const $KeyEvent: WasmTypeConstructor<KeyEvent> = (mem) => ({
get align() {
return 4;
},
get size() {
return 12;
},
instanceArray(base, num) {
return __instanceArray<KeyEvent>(this, base, num);
},
instance: (base) => {
let $key: WasmStringPtr | null = null;
return {
get __base() {
return base;
},
get __bytes() {
return mem.u8.subarray(base, base + 12);
},
get type(): EventType {
return mem.u8[base];
},
set type(x: EventType) {
mem.u8[base] = x;
},
get key(): WasmStringPtr {
return $key || ($key = new WasmStringPtr(mem, (base + 4), true));
},
get modifiers(): number {
return mem.u8[(base + 8)];
},
set modifiers(x: number) {
mem.u8[(base + 8)] = x;
},
};
}
// @ts-ignore possibly unused args
export const $KeyEvent = defType<KeyEvent>(4, 12, (mem, base) => {
let $key: WasmStringPtr;
return {
get type(): EventType {
return mem.u8[base];
},
set type(x: EventType) {
mem.u8[base] = x;
},
get key(): WasmStringPtr {
return $key || ($key = __str(mem, (base + 4)));
},
get modifiers(): number {
return mem.u8[(base + 8)];
},
set modifiers(x: number) {
mem.u8[(base + 8)] = x;
},
};
});

@@ -773,34 +728,18 @@

export const $Event: WasmTypeConstructor<Event> = (mem) => ({
get align() {
return 4;
},
get size() {
return 12;
},
instanceArray(base, num) {
return __instanceArray<Event>(this, base, num);
},
instance: (base) => {
return {
get __base() {
return base;
},
get __bytes() {
return mem.u8.subarray(base, base + 12);
},
get mouse(): MouseEvent {
return $MouseEvent(mem).instance(base);
},
set mouse(x: MouseEvent) {
mem.u8.set(x.__bytes, base);
},
get key(): KeyEvent {
return $KeyEvent(mem).instance(base);
},
set key(x: KeyEvent) {
mem.u8.set(x.__bytes, base);
},
};
}
// @ts-ignore possibly unused args
export const $Event = defType<Event>(4, 12, (mem, base) => {
return {
get mouse(): MouseEvent {
return $MouseEvent(mem).instance(base);
},
set mouse(x: MouseEvent) {
mem.u8.set(x.__bytes, base);
},
get key(): KeyEvent {
return $KeyEvent(mem).instance(base);
},
set key(x: KeyEvent) {
mem.u8.set(x.__bytes, base);
},
};
});

@@ -815,3 +754,3 @@ ```

```zig
//! Generated by @thi.ng/wasm-api-bindgen at 2024-08-18T11:20:28.120Z
//! Generated by @thi.ng/wasm-api-bindgen at 2024-11-10T21:43:40.567Z
//! DO NOT EDIT!

@@ -855,16 +794,19 @@

The following command shows how to build a Zig WASM module and define a package
for the supplied type wrappers:
The following command shows how to build a Zig WASM module and include the
`wasm-api-bindgen` Zig definitions for the supplied type wrappers:
```bash
zig build-lib \
--pkg-begin wasm-api-bindgen node_modules/@thi.ng/wasm-api-bindgen/zig/lib.zig --pkg-end \
-target wasm32-freestanding \
-O ReleaseSmall -dynamic \
main.zig
# compile WASM binary (zig v0.13)
zig build-exe \
-fno-entry -fstrip -OReleaseSmall -target wasm32-freestanding \
--name test -rdynamic --import-symbols \
--dep wasm-api-bindgen \
-Mroot=main.zig \
-Mwasm-api-bindgen=node_modules/@thi.ng/wasm-api-bindgen/zig/lib.zig
```
Alternatively, use a [more elaborate setup used by various example
projects](https://github.com/thi-ng/umbrella/blob/develop/examples/zig-todo-list/build.zig)
in this repo, using Zig's native build system...
Alternatively, use Zig's native build system with the [build file bundled with
the thi.ng/wasm-api main
package](https://github.com/thi-ng/umbrella/blob/develop/packages/wasm-api/README.md#using-the-zig-build-system)
and which is being used by various example projects in this repo...

@@ -954,3 +896,3 @@ ### Runtime example

Package sizes (brotli'd, pre-treeshake): ESM: 6.24 KB
Package sizes (brotli'd, pre-treeshake): ESM: 6.25 KB

@@ -957,0 +899,0 @@ ## Dependencies

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc