npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ozymandros/electron-message-bridge-adapter-assemblyscript

v0.3.0

Published

Optional AssemblyScript / WebAssembly adapter for @ozymandros/electron-message-bridge. Bridges WASM exports into typed IPC handlers.

Readme

@ozymandros/electron-message-bridge-adapter-assemblyscript

Optional AssemblyScript / WebAssembly adapter for @ozymandros/electron-message-bridge.

Bridges AssemblyScript WASM module exports into typed IPC handlers that slot directly into the existing defineIpcApi / exposeApiToRenderer pipeline — with zero mandatory runtime dependencies.


Why a separate package?

The core @ozymandros/electron-message-bridge is intentionally lean. AssemblyScript support is an advanced, optional use-case; keeping it separate:

  • Keeps the core bundle small for users who don't need WASM.
  • Allows the adapter to evolve independently.
  • Makes the optional dependency on @assemblyscript/loader explicit.

This package depends on @ozymandros/electron-message-bridge as a peer dependency, so your application owns the core version and can keep core and adapter aligned.


Installation

npm install @ozymandros/electron-message-bridge-adapter-assemblyscript
# peer deps (if not already installed)
npm install @ozymandros/electron-message-bridge electron

Quick start

// main.ts
import { createAssemblyScriptAdapter, asc } from '@ozymandros/electron-message-bridge-adapter-assemblyscript';
import { defineIpcApi } from '@ozymandros/electron-message-bridge';
import { exposeApiToRenderer } from '@ozymandros/electron-message-bridge/preload';

// 1. Define the schema (mirrors your AssemblyScript exports)
const schema = {
  add:   asc.fn(['i32', 'i32'], 'i32'),
  greet: asc.fn(['string'], 'string'),
};

// 2. Load the WASM module and create typed handlers
const adapter = await createAssemblyScriptAdapter('./math.wasm', schema);

// 3. Register IPC handlers on ipcMain
const api = defineIpcApi(adapter.handlers);

// 4. Expose to renderer via contextBridge (in preload.ts)
exposeApiToRenderer(api);
// renderer.ts
const result = await window.api.add(3, 4);        // => 7
const msg   = await window.api.greet('World');    // => 'Hello, World!'

API reference

createAssemblyScriptAdapter(source, schema, options?)

Loads a WASM module and returns typed async handlers.

| Parameter | Type | Description | |-----------|------|-------------| | source | string \| Buffer \| ArrayBuffer \| WebAssembly.Module \| WebAssembly.Instance | Path to .wasm file, raw bytes, pre-compiled module, or existing instance | | schema | AscSchema | Descriptor map of function signatures | | options | AssemblyScriptAdapterOptions | Optional: imports, logger, warnOnMissingRuntime |

Returns Promise<AssemblyScriptAdapter<S>>:

interface AssemblyScriptAdapter<S> {
  handlers: InferAscHandlers<S>;   // Pass to defineIpcApi()
  instance: WebAssembly.Instance;  // The raw WASM instance
  runtime: AscRuntimeExports | null;
  dispose(): void;
}

AssemblyScriptPlugin

Lifecycle-managed plugin for use with PluginHost:

import { PluginHost } from '@ozymandros/electron-message-bridge/plugins';
import { AssemblyScriptPlugin } from '@ozymandros/electron-message-bridge-adapter-assemblyscript';

const host = new PluginHost();
host.register(new AssemblyScriptPlugin({
  name: 'math',
  source: './math.wasm',
  schema: { add: asc.fn(['i32', 'i32'], 'i32') },
  onReady: (api) => { /* store api reference */ },
}));

await host.init();   // loads WASM, registers IPC handlers
await host.start();
// on shutdown:
await host.stop();
await host.dispose();

wrapLoaderInstance(loaderExports)

Compatibility shim for @assemblyscript/loader:

import { instantiate } from '@assemblyscript/loader';
import { wrapLoaderInstance, createAssemblyScriptAdapter } from '@ozymandros/electron-message-bridge-adapter-assemblyscript';

const { exports } = await instantiate(fs.readFileSync('./math.wasm'));
const adapter = await createAssemblyScriptAdapter(
  wrapLoaderInstance(exports),
  schema,
  { warnOnMissingRuntime: false },
);

Supported types

| Schema type | JS type | Notes | |-------------|---------|-------| | i32, u32, f32, f64 | number | Direct numeric mapping | | i64, u64 | bigint | Requires BigInt support | | bool | boolean | Encoded as 0/1 on the WASM side | | string | string | Requires AssemblyScript runtime (--runtime full) | | bytes | Uint8Array | Requires AssemblyScript runtime | | void | undefined | Return-only |


Migrating from the old import path

In @ozymandros/[email protected] a compatibility shim re-exports this package from @ozymandros/electron-message-bridge/adapters/assemblyscript. That shim is deprecated and will be removed in the next major release.

Update your imports:

// ❌ Old (deprecated)
import { createAssemblyScriptAdapter } from '@ozymandros/electron-message-bridge/adapters/assemblyscript';

// ✅ New
import { createAssemblyScriptAdapter } from '@ozymandros/electron-message-bridge-adapter-assemblyscript';

License

MIT