OMNI-CORE LogoOMNI-CORE
omni-mdxomni-3D (soon)Open SourceAbout
GitHubDocumentation
OMNI-CORE

Knowledge must flow freely to shape the future.

Ecosystem

  • omni-mdx
  • omni-3D

Resources

  • Documentation
  • Interactive Playground

Legal & Open Source

  • GitHub Organization
  • Notice

TOAQ GROUP © 2024 - 2026

Released under the MIT License.

Navigation

Getting Started

  • Introduction
    • Web & Next.js
    • Python Engine
    • Build from Source
  • Syntax Guide

Web Integration

  • Next.js Integration
  • Binary AST Transfer
  • Custom Components
  • Unified & Plugins Ecosystem Integration
    • Basic App Router
    • Advanced Rendering
    • Live Client Editor

Python

  • Introduction & Core Engine
    • Basic Parsing & Traversal
    • Advanced Analysis & RAG
    • Native Qt Rendering
    • HTML & Web Rendering
    • Basic Parsing
    • Advanced Analysis
    • HTML Rendering
    • Qt Rendering

Architecture & Core

    • Design Philosophy
    • The Rendering Pipeline
    • Lexing & Tokenization
    • AST Node Design
    • Math & JSX Handling
    • Protocol Specification
    • Zero-Copy Decoding
    • Memory Lifecycle
    • WASM Bindings (Browser)
    • Node.js Native Addons
    • Python Bindings (PyO3)
  • Security
    • Benchmarks
    • Fuzzing Results
Docs
Architecture
Ffi
WASM Bindings (Browser)

WASM Bindings (wasm-bindgen)

Last Updated March 24, 2026

The primary environment for MDX is JavaScript. Whether you are building a static site with Next.js or a real-time collaborative editor in React, you need to parse MDX in a JavaScript thread.

To achieve native parsing speeds inside a web browser without writing slow JavaScript, we compile the Omni-Core Rust engine to WebAssembly (WASM) using wasm-bindgen.

WebAssembly Linear Memory Map (64KB Page)
OCP Payload
0x0000
0xFFFF
Pointer: 0x4000
JavaScript / TypeScript SDK
// Hover over the OCP Payload in WASM memory to create the link

The WASM Paradigm

WebAssembly is not a programming language; it is a binary instruction format for a stack-based virtual machine. It allows code written in languages like Rust or C++ to run in web browsers at near-native speed.

wasm-bindgen is the toolchain we use to facilitate high-level communication between Rust and JavaScript. It automatically generates the JavaScript glue code needed to load the .wasm binary, instantiate it, and call its exported functions.

When your React component calls:

typescript
import { parseMdx } from '@toaq-oss/omni-mdx/client';

const ast = parseMdx("# Hello from WASM");

You are executing pre-compiled Rust bytecode inside the browser’s WASM virtual machine.

Linear Memory & Shared Buffers

WebAssembly operates on a fundamentally different memory model than JavaScript. WASM does not have access to the JavaScript heap. Instead, it has its own, contiguous block of raw memory called Linear Memory.

This is where Omni-MDX’s architecture truly shines.

As we discussed in the Zero-Copy section, when the Rust engine finishes parsing:

  1. It allocates the OCP Binary payload inside its WASM Linear Memory.
  2. It returns the memory pointer (usize) and the length to JavaScript.
  3. The JavaScript SDK creates a view over that exact memory segment:
typescript
// Inside the JS SDK
const buffer = new Uint8Array(wasm.memory.buffer, ptr, length);

Because JavaScript is looking directly into WASM’s RAM, we achieve true Zero-Copy data transfer. The host language can start reading the AST instructions without moving a single byte of data.

Deployment with wasm-pack

Packaging a WASM module for use in a modern web application (with tools like Webpack, Vite, or Next.js) can be complex. We simplify this process using wasm-pack.

In our CI/CD pipeline, wasm-pack automatically:

  • Compiles the Rust core to wasm32-unknown-unknown.
  • Generates the TypeScript definition files (.d.ts).
  • Generates the package.json for the @omni-mdx/wasm package.

For web developers, Omni-MDX feels like any other npm package. They don’t need to know Rust or configure complex WASM loaders; they just install it and profit from sub-millisecond parsing speed.

Boosted by omni-mdx native node

On this page

  • The WASM Paradigm
  • Linear Memory & Shared Buffers
  • Deployment with wasm-pack
Edit this page on GitHub

Caught a typo or want to improve the docs? Submitting a PR is the best way to help!