ts-pack-wasm
v1.0.0-rc.8
Published
WebAssembly bindings for tree-sitter language pack
Readme
tree-sitter-language-pack — WebAssembly
WebAssembly bindings for tree-sitter-language-pack with browser caching support.
Installation
npm install @kreuzberg/tree-sitter-language-pack-wasmpnpm add @kreuzberg/tree-sitter-language-pack-wasmyarn add @kreuzberg/tree-sitter-language-pack-wasmQuick Start
import init, { availableLanguages, hasLanguage, init as initLanguages, download } from "@kreuzberg/tree-sitter-language-pack-wasm";
await init();
// Optional: Pre-download specific languages for offline use
initLanguages(["python", "javascript", "typescript"]);
console.log(availableLanguages());
console.log(hasLanguage("python")); // true
import { process } from '@kreuzberg/tree-sitter-language-pack-wasm';
// Auto-downloads language if not cached in IndexedDB
const result = process(source, { language: 'javascript' });
console.log('Structure:', result.structure);
// Pre-download languages for offline use
download(["python", "javascript"]);API Reference
Language Discovery
available_languages()-- list all supported language nameshas_language(name)-- check if a language is availablelanguage_count()-- total number of supported languages
Parsing
get_parser(name)/parse_string(source, language)-- parse source code into a syntax tree
Download API
init(languages)-- pre-download specific languages for offline usedownload(languages)-- download parsers on demand
Intelligence
process(source, config)-- extract structured analysis (functions, classes, imports, comments, chunks) from source code
For detailed API documentation, see the WebAssembly package.
License
MIT OR Apache-2.0 -- see LICENSE for details.
Part of tree-sitter-language-pack -- A comprehensive collection of tree-sitter language parsers with polyglot bindings.
