This page documents @lanexio/parser-wasm, the WASM bridge package that delegates to WASM-parsed grammar implementations. At v1.0, the WASM bridge is backed by pure TypeScript — WASM acceleration is a future optimization target.
Version: Stable
Module name: parser-wasm
Package: @lanexio/parser-wasm
Import path: @lanexio/parser-wasm
Layer: 4 (Bridge)
Runtime: Universal (requires WASM runtime support)
Module format: ESM
Stability: Stable
Primary use case: WASM-backed parser bridge for HTML and Markdown.
You want to use the WASM bridge interface for grammar parsing.
You need to load bundled WASM bytes for HTML or toy grammar.
You are building a custom integration that uses the WASM bridge pattern.
Boundary Description Inputs Uint8Array (source bytes)Outputs LexTreeSide effects WASM module instantiation on first use Determinism Yes External dependencies @lanexio/parser-core, @lanexio/parser-grammar-html, @lanexio/parser-grammar-markdownNever-throw guarantee Yes for parse functions. WASM instantiation may throw WasmLoaderError. Security surface None (delegates to grammar parsers)
Install the package.
pnpm add @lanexio/parser-wasm
npm install @lanexio/parser-wasm
yarn add @lanexio/parser-wasm
Import the named export.
import { createHtmlWasmBridgeParser } from ' @lanexio/parser-wasm ' ;
Requirement Required Layer Notes @lanexio/parser-coreYes 1 ^1.0.0@lanexio/parser-grammar-htmlYes 2 ^1.0.0@lanexio/parser-grammar-markdownYes 2 ^1.0.0
import { createHtmlWasmBridgeParser, parseHtml } from ' @lanexio/parser-wasm ' ;
const encoder = new TextEncoder ();
const tree = parseHtml (encoder . encode ( ' <p>Hello</p> ' ));
console . log (tree . nodeCount );
import { createHtmlWasmBridgeParser } from ' @lanexio/parser-wasm ' ;
const parser = createHtmlWasmBridgeParser ();
const tree = parser . parse (encoder . encode ( ' <p>Hello</p> ' ));
Export Type Description createHtmlWasmBridgeParser() => WasmBridgeParserCreate a WASM-backed HTML parser bridge. createMarkdownWasmBridgeParser() => WasmBridgeParserCreate a WASM-backed Markdown parser bridge (GFM enabled). parseHtml(bytes: Uint8Array) => LexTreeParse HTML via WASM bridge. parseMarkdown(bytes: Uint8Array) => LexTreeParse Markdown via WASM bridge. createToyWasmBridgeParser() => WasmBridgeParserCreate a WASM-backed toy grammar parser bridge. loadBundledHtmlWasmBytes() => Promise<Uint8Array>Load bundled HTML WASM bytes. loadBundledToyWasmBytes() => Promise<Uint8Array>Load bundled toy WASM bytes. instantiateToyWasm(bytes: Uint8Array) => ToyWasmParserExportsInstantiate toy WASM module from bytes. createReferenceWasmBridgeParser() => WasmBridgeParserCreate a reference WASM bridge parser. WasmLoaderErrorclassError thrown when WASM instantiation fails. WasmLoaderErrorCodeconst objectError code constants for WASM loader failures. WasmFallbackErrorclassError thrown when WASM fallback is unavailable. isWasmParserExports(exports: unknown) => exports is WasmParserExportsType guard for WASM parser exports. isToyWasmParserExports(exports: unknown) => exports is ToyWasmParserExportsType guard for toy WASM parser exports. TOY_GRAMMAR_NAMEstringName of the toy grammar. defineLanexioParserGrammar(name: string, source: LanexioParserGrammarSource) => LanexioParserGrammarDefine a WASM grammar descriptor. resolveGrammarSource(source: LanexioParserGrammarSource) => Uint8Array | nullResolve a grammar source to bytes. toyGrammarLanexioParserGrammarToy grammar descriptor.
No options. All WASM bridge functions accept only Uint8Array.
Type Purpose Notes WasmBridgeParserWASM bridge parser shape { runtime: string; parse: (bytes: Uint8Array) => LexTree }WasmParserExportsWASM parser exports interface Internal ToyWasmParserExportsToy WASM parser exports interface Internal LanexioParserGrammarWASM grammar descriptor Used for defining WASM grammars LanexioParserGrammarSourceGrammar source (bytes, path, or URL) Used for WASM grammar loading LanexioParserGrammarSourceLikeGrammar source-like Relaxed input type WasmLoaderErrorCodeError code type for WASM loader Union of error codes
At v1.0, the WASM bridge is backed by pure TypeScript. WASM acceleration is a future optimization target. If WASM instantiation fails (WasmLoaderError), callers should fall back to the grammar-specific parse functions from @lanexio/parser-grammar-html or @lanexio/parser-grammar-markdown.
No direct accessibility surface. The WASM bridge delegates to grammar parsers.
Concern Status Generated output semantics Delegated to grammar parsers ARIA attributes in serialized output Not applicable Semantic element round-trip Not applicable
All parse functions never throw.
WASM instantiation may throw WasmLoaderError if the WASM runtime is unavailable.
Threat Mitigation Status Malformed input byte sequence Delegates to grammar parsers (panic-free) Implemented WASM instantiation failure Throws WasmLoaderError with clear message Implemented
Package Relationship Layer Notes @lanexio/parser-coreRequires 1 Core tree and protocol @lanexio/parser-grammar-htmlRequires 2 HTML grammar delegation @lanexio/parser-grammar-markdownRequires 2 Markdown grammar delegation @lanexio/parserConsumes 6 Entry point uses WASM as optional backend @lanexio/parser-pureFallback 4 Pure TS fallback when WASM unavailable
Version Date Status Notable changes 1.0.02026-05-29Current Initial stable release. Apache-2.0.
Flat AST How the 16-byte node layout works.