2025-02-08 13:06:44 -05:00
|
|
|
import createModule, { type MainModule } from '../lib/web-tree-sitter';
|
2025-01-20 02:43:52 -05:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
|
import { type Parser } from './parser';
|
2025-01-19 15:15:01 -05:00
|
|
|
|
|
|
|
|
export let Module: MainModule | null = null;
|
|
|
|
|
|
2025-01-20 02:43:52 -05:00
|
|
|
/**
|
|
|
|
|
* @internal
|
|
|
|
|
*
|
2025-08-19 12:32:46 +03:00
|
|
|
* Initialize the Tree-sitter Wasm module. This should only be called by the {@link Parser} class via {@link Parser.init}.
|
2025-01-20 02:43:52 -05:00
|
|
|
*/
|
2025-06-15 12:41:21 +03:00
|
|
|
export async function initializeBinding(moduleOptions?: Partial<EmscriptenModule>): Promise<MainModule> {
|
2025-08-31 00:41:29 +03:00
|
|
|
return Module ??= await createModule(moduleOptions);
|
2025-01-19 15:15:01 -05:00
|
|
|
}
|
|
|
|
|
|
2025-01-20 02:43:52 -05:00
|
|
|
/**
|
|
|
|
|
* @internal
|
|
|
|
|
*
|
2025-08-19 12:32:46 +03:00
|
|
|
* Checks if the Tree-sitter Wasm module has been initialized.
|
2025-01-20 02:43:52 -05:00
|
|
|
*/
|
2025-01-19 15:15:01 -05:00
|
|
|
export function checkModule(): boolean {
|
|
|
|
|
return !!Module;
|
|
|
|
|
}
|