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
119
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.7.9 to 0.8.0

17

CHANGELOG.md
# Change Log
- **Last updated**: 2024-11-09T16:30:54Z
- **Last updated**: 2024-11-10T17:11:51Z
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)

@@ -12,2 +12,17 @@

## [0.8.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/wasm-api-bindgen@0.8.0) (2024-11-10)
#### 🚀 Features
- update TypeScript codegen to use defType() ([1de3a70](https://github.com/thi-ng/umbrella/commit/1de3a70))
- re-use `defType()` for generated structs/unions (see [947e3fc1cc](https://github.com/thi-ng/umbrella/commit/947e3fc1cc)),
resulting in much smaller outputs
- update test snapshots
#### ♻️ Refactoring
- update TS code gen ([42c6fa3](https://github.com/thi-ng/umbrella/commit/42c6fa3))
- coalesce pointer & string var declarations
- update test snapshots
### [0.7.9](https://github.com/thi-ng/umbrella/tree/@thi.ng/wasm-api-bindgen@0.7.9) (2024-11-09)

@@ -14,0 +29,0 @@

32

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

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

"clean": "bun ../../tools/src/clean-package.ts",
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
"doc": "typedoc --options ../../typedoc.json --out doc src/index.ts",
"doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",

@@ -42,15 +42,15 @@ "doc:readme": "bun ../../tools/src/module-stats.ts && bun ../../tools/src/readme.ts",

"dependencies": {
"@thi.ng/api": "^8.11.11",
"@thi.ng/args": "^2.3.47",
"@thi.ng/arrays": "^2.10.4",
"@thi.ng/binary": "^3.4.34",
"@thi.ng/checks": "^3.6.13",
"@thi.ng/compare": "^2.4.3",
"@thi.ng/defmulti": "^3.0.49",
"@thi.ng/errors": "^2.5.17",
"@thi.ng/file-io": "^2.1.15",
"@thi.ng/logger": "^3.0.21",
"@thi.ng/paths": "^5.1.91",
"@thi.ng/strings": "^3.8.9",
"@thi.ng/wasm-api": "^2.1.0"
"@thi.ng/api": "^8.11.12",
"@thi.ng/args": "^2.3.48",
"@thi.ng/arrays": "^2.10.5",
"@thi.ng/binary": "^3.4.35",
"@thi.ng/checks": "^3.6.14",
"@thi.ng/compare": "^2.4.4",
"@thi.ng/defmulti": "^3.0.50",
"@thi.ng/errors": "^2.5.18",
"@thi.ng/file-io": "^2.1.16",
"@thi.ng/logger": "^3.0.22",
"@thi.ng/paths": "^5.1.92",
"@thi.ng/strings": "^3.8.10",
"@thi.ng/wasm-api": "^2.2.0"
},

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

},
"gitHead": "e84096f55842a5a028d5c5e7b776ddd49b79ea17\n"
"gitHead": "ef89090bb19fc5bca23be5da8cfce05b82ff4ad1\n"
}

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

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

@@ -946,0 +946,0 @@ ## Dependencies

@@ -36,3 +36,3 @@ import {

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

@@ -101,28 +101,13 @@ if (Object.values(coll).some(

const pointerDecls = fields.filter((f) => isPointer(f.field.tag) && f.field.len !== 0).map((f) => {
return `let $${f.field.name}: ${f.type} | null = null;`;
return `$${f.field.name}: ${f.type}`;
});
const stringDecls = fields.filter(
(f) => isWasmString(f.field.type) && !["array", "ptr", "slice"].includes(f.field.tag)
).map((f) => `let $${f.field.name}: ${strType} | null = null;`);
).map((f) => `$${f.field.name}: ${strType}`);
lines.push(
`export const $${struct.name}: WasmTypeConstructor<${struct.name}> = (mem) => ({`,
`get align() {`,
`return ${struct.__align};`,
`},`,
`get size() {`,
`return ${struct.__size};`,
`},`,
`instanceArray(base, num) {`,
`return __instanceArray<${struct.name}>(this, base, num);`,
`},`,
`instance: (base) => {`,
...pointerDecls,
...stringDecls,
`return {`,
`get __base() {`,
`return base;`,
`},`,
`get __bytes() {`,
`return mem.u8.subarray(base, base + ${struct.__size});`,
`},`
"// @ts-ignore possibly unused args",
`export const $${struct.name} = defType<${struct.name}>(${struct.__align}, ${struct.__size}, (mem, base) => {`,
...pointerDecls.length ? [`let ${pointerDecls.join(", ")};`] : [],
...stringDecls.length ? [`let ${stringDecls.join(", ")};`] : [],
`return {`
);

@@ -147,3 +132,3 @@ for (let f of fields) {

injectBody(lines, struct.body?.ts);
lines.push("};", "}", "});", "");
lines.push("};", "});", "");
acc.push(...withIndentation(lines, indent, ...SCOPES));

@@ -150,0 +135,0 @@ },

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