@sourcenetwork/wasm-bridge
v1.0.2
Published
A lightweight WASM instantiation bridge for Go-compiled WebAssembly modules
Readme
Wasm Bridge
A lightweight bridge for instantiating Go-compiled WebAssembly modules in JavaScript environments.
Features
- URL-based and byte-based instantiation
- Browser and Node.js compatible
- Includes Go
wasm_exec.jsruntime
Installation
npm install @sourcenetwork/wasm-bridge
# or
yarn add @sourcenetwork/wasm-bridgeUsage
Basic Usage (from URL)
import { instantiate } from '@sourcenetwork/wasm-bridge';
// Instantiate a WASM module from a URL or path
await instantiate('/path/to/your/module.wasm');From Bytes
import { instantiateFromBytes } from '@sourcenetwork/wasm-bridge';
// Load WASM bytes
const wasmBytes = await fetch('/path/to/module.wasm').then(r => r.arrayBuffer());
// Instantiate from the raw bytes
await instantiateFromBytes(wasmBytes);Requirements
- Modern browser with WebAssembly support, or Node.js 16+
- Your WASM binary must be compiled from Go using the
wasmtarget
License
Apache-2.0
