feat(web)!: use the WASM module in the bindings, and not the other way around
Parser is no longer the default export, but you *must* call `Parser.init()` before doing anything still
This commit is contained in:
parent
b1e39d2dba
commit
be7716dfa7
29 changed files with 613 additions and 662 deletions
14
lib/binding_web/src/bindings.ts
Normal file
14
lib/binding_web/src/bindings.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import createModule, { type MainModule } from '../lib/tree-sitter';
|
||||
|
||||
export let Module: MainModule | null = null;
|
||||
|
||||
export async function initializeBinding(moduleOptions: EmscriptenModule): Promise<MainModule> {
|
||||
if (!Module) {
|
||||
Module = await createModule(moduleOptions);
|
||||
}
|
||||
return Module;
|
||||
}
|
||||
|
||||
export function checkModule(): boolean {
|
||||
return !!Module;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue