From 304e56850ffb5fc6359b9288ace93936cb45aac3 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Tue, 28 Jan 2025 19:34:05 -0500 Subject: [PATCH] chore(web): update type definitions --- lib/binding_web/web-tree-sitter.d.ts | 46 +++++++++++++++++++----- lib/binding_web/web-tree-sitter.d.ts.map | 5 ++- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/lib/binding_web/web-tree-sitter.d.ts b/lib/binding_web/web-tree-sitter.d.ts index e4b564e6..ec65825c 100644 --- a/lib/binding_web/web-tree-sitter.d.ts +++ b/lib/binding_web/web-tree-sitter.d.ts @@ -88,7 +88,7 @@ declare module 'web-tree-sitter' { /** * A function that is called periodically during parsing to check * whether parsing should be cancelled. If the progress callback returns - * `false`, then parsing will be cancelled. You can also use this to instrument + * `true`, then parsing will be cancelled. You can also use this to instrument * parsing and check where the parser is at in the document. The progress callback * takes a single argument, which is a {@link ParseState} representing the current * state of the parser. @@ -102,6 +102,8 @@ declare module 'web-tree-sitter' { export interface ParseState { /** The byte offset in the document that the parser is at. */ currentOffset: number; + /** Indicates whether the parser has encountered an error during parsing. */ + hasError: boolean; } /** * The latest ABI version that is supported by the current version of the @@ -200,6 +202,11 @@ declare module 'web-tree-sitter' { /** Get the parser's current logger. */ getLogger(): LogCallback | null; } + class LanguageMetadata { + readonly major_version: number; + readonly minor_version: number; + readonly patch_version: number; + } /** * An opaque object that defines how to parse a particular language. * The code for each `Language` is generated by the Tree-sitter CLI. @@ -220,9 +227,20 @@ declare module 'web-tree-sitter' { */ get name(): string | null; /** + * @deprecated since version 0.25.0, use {@link Language#abiVersion} instead * Gets the version of the language. */ get version(): number; + /** + * Gets the ABI version of the language. + */ + get abiVersion(): number; + /** + * Get the metadata for this language. This information is generated by the + * CLI, and relies on the language author providing the correct metadata in + * the language's `tree-sitter.json` file. + */ + get metadata(): LanguageMetadata | null; /** * Gets the number of fields in the language. */ @@ -847,19 +865,31 @@ declare module 'web-tree-sitter' { * types of steps, which correspond to the two legal values for * the `type` field: * - * - `capture` - Steps with this type represent names - * of captures. The `name` field is the name of the capture. + * - `CapturePredicateStep` - Steps with this type represent names + * of captures. * - * - `string` - Steps with this type represent literal - * strings. The `value` field is the string value. + * - `StringPredicateStep` - Steps with this type represent literal + * strings. */ - export type PredicateStep = { + export type PredicateStep = CapturePredicateStep | StringPredicateStep; + /** + * A step in a predicate that refers to a capture. + * + * The `name` field is the name of the capture. + */ + interface CapturePredicateStep { type: 'capture'; name: string; - } | { + } + /** + * A step in a predicate that refers to a string. + * + * The `value` field is the string value. + */ + interface StringPredicateStep { type: 'string'; value: string; - }; + } export class Query { /** The names of the captures used in the query. */ readonly captureNames: string[]; diff --git a/lib/binding_web/web-tree-sitter.d.ts.map b/lib/binding_web/web-tree-sitter.d.ts.map index 56bb49b4..9e56d793 100644 --- a/lib/binding_web/web-tree-sitter.d.ts.map +++ b/lib/binding_web/web-tree-sitter.d.ts.map @@ -13,6 +13,7 @@ "LANGUAGE_VERSION", "MIN_COMPATIBLE_VERSION", "Parser", + "LanguageMetadata", "Language", "Tree", "Node", @@ -25,6 +26,8 @@ "QueryMatch", "CaptureQuantifier", "PredicateStep", + "CapturePredicateStep", + "StringPredicateStep", "Query", "LookaheadIterator" ], @@ -48,6 +51,6 @@ null, null ], - "mappings": ";;;;;;mBASiBA,KAAKA;;;;;;;;;;mBAYLC,KAAKA;;;;;;;;;;;;;mBAiBLC,IAAIA;;;;;;;;;;;;;;;;;cA4CTC,aAAaA;;;;cAKbC,gBAAgBA;;;;;;cAOhBC,WAAWA;;;;;;;;;;;;kBC7ENC,YAAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAmCZC,UAAUA;;;;;;;;;;;;;YAqBhBC,gBAAgBA;;;;;YAMhBC,sBAAsBA;;;;;cAMpBC,MAAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCrENC,QAAQA;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