feat: begin autogenerating web-tree-sitter.d.ts
This commit is contained in:
parent
be7716dfa7
commit
10e6ecf162
14 changed files with 1082 additions and 343 deletions
|
|
@ -11,9 +11,12 @@ const QUERY_WORD_REGEX = /[\w-]+/g;
|
|||
const LANGUAGE_FUNCTION_REGEX = /^tree_sitter_\w+$/;
|
||||
|
||||
export class Language {
|
||||
private [0]: number; // Internal handle for WASM
|
||||
public types: string[];
|
||||
public fields: (string | null)[];
|
||||
/** @internal */
|
||||
private [0] = 0; // Internal handle for WASM
|
||||
|
||||
types: string[];
|
||||
|
||||
fields: (string | null)[];
|
||||
|
||||
constructor(internal: Internal, address: number) {
|
||||
assertInternal(internal);
|
||||
|
|
@ -449,7 +452,8 @@ export class Language {
|
|||
if (input instanceof Uint8Array) {
|
||||
bytes = Promise.resolve(input);
|
||||
} else {
|
||||
if (globalThis.process.versions.node) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
if (globalThis.process?.versions.node) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-require-imports
|
||||
const fs: typeof import('fs/promises') = require('fs/promises');
|
||||
bytes = fs.readFile(input);
|
||||
|
|
@ -469,7 +473,7 @@ export class Language {
|
|||
|
||||
const mod = await C.loadWebAssemblyModule(await bytes, { loadAsync: true });
|
||||
const symbolNames = Object.keys(mod);
|
||||
const functionName = symbolNames.find((key) => LANGUAGE_FUNCTION_REGEX.test(key) &&
|
||||
const functionName = symbolNames.find((key) => LANGUAGE_FUNCTION_REGEX.test(key) &&
|
||||
!key.includes('external_scanner_'));
|
||||
if (!functionName) {
|
||||
console.log(`Couldn't find language function in WASM file. Symbols:\n${JSON.stringify(symbolNames, null, 2)}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue