@singapore-editor/tree-sitter-x 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/edit.ts", "../src/constants.ts", "../src/finalization_registry.ts", "../src/lookahead_iterator.ts", "../src/tree.ts", "../src/tree_cursor.ts", "../src/node.ts", "../src/marshal.ts", "../src/language.ts", "../src/wasi-module.ts", "../src/bindings.ts", "../src/text_buffer.ts", "../src/parser.ts", "../src/extension.ts", "../src/query.ts"],
4
+ "sourcesContent": ["import { Point, Range } from \"./constants\";\n\nexport class Edit {\n /** The start position of the change. */\n startPosition: Point;\n\n /** The end position of the change before the edit. */\n oldEndPosition: Point;\n\n /** The end position of the change after the edit. */\n newEndPosition: Point;\n\n /** The start index of the change. */\n startIndex: number;\n\n /** The end index of the change before the edit. */\n oldEndIndex: number;\n\n /** The end index of the change after the edit. */\n newEndIndex: number;\n\n constructor({\n startIndex,\n oldEndIndex,\n newEndIndex,\n startPosition,\n oldEndPosition,\n newEndPosition,\n }: {\n startIndex: number;\n oldEndIndex: number;\n newEndIndex: number;\n startPosition: Point;\n oldEndPosition: Point;\n newEndPosition: Point;\n }) {\n this.startIndex = startIndex >>> 0;\n this.oldEndIndex = oldEndIndex >>> 0;\n this.newEndIndex = newEndIndex >>> 0;\n this.startPosition = startPosition;\n this.oldEndPosition = oldEndPosition;\n this.newEndPosition = newEndPosition;\n }\n\n /**\n * Edit a point and index to keep it in-sync with source code that has been edited.\n *\n * This function updates a single point's byte offset and row/column position\n * based on an edit operation. This is useful for editing points without\n * requiring a tree or node instance.\n */\n editPoint(point: Point, index: number): { point: Point; index: number } {\n let newIndex = index;\n const newPoint = { ...point };\n\n if (index >= this.oldEndIndex) {\n newIndex = this.newEndIndex + (index - this.oldEndIndex);\n const originalRow = point.row;\n newPoint.row = this.newEndPosition.row + (point.row - this.oldEndPosition.row);\n newPoint.column = originalRow === this.oldEndPosition.row\n ? this.newEndPosition.column + (point.column - this.oldEndPosition.column)\n : point.column;\n } else if (index > this.startIndex) {\n newIndex = this.newEndIndex;\n newPoint.row = this.newEndPosition.row;\n newPoint.column = this.newEndPosition.column;\n }\n\n return { point: newPoint, index: newIndex };\n }\n\n /**\n * Edit a range to keep it in-sync with source code that has been edited.\n *\n * This function updates a range's start and end positions based on an edit\n * operation. This is useful for editing ranges without requiring a tree\n * or node instance.\n */\n editRange(range: Range): Range {\n const newRange: Range = {\n startIndex: range.startIndex,\n startPosition: { ...range.startPosition },\n endIndex: range.endIndex,\n endPosition: { ...range.endPosition }\n };\n\n if (range.endIndex >= this.oldEndIndex) {\n if (range.endIndex !== Number.MAX_SAFE_INTEGER) {\n newRange.endIndex = this.newEndIndex + (range.endIndex - this.oldEndIndex);\n newRange.endPosition = {\n row: this.newEndPosition.row + (range.endPosition.row - this.oldEndPosition.row),\n column: range.endPosition.row === this.oldEndPosition.row\n ? this.newEndPosition.column + (range.endPosition.column - this.oldEndPosition.column)\n : range.endPosition.column,\n };\n if (newRange.endIndex < this.newEndIndex) {\n newRange.endIndex = Number.MAX_SAFE_INTEGER;\n newRange.endPosition = { row: Number.MAX_SAFE_INTEGER, column: Number.MAX_SAFE_INTEGER };\n }\n }\n } else if (range.endIndex > this.startIndex) {\n newRange.endIndex = this.startIndex;\n newRange.endPosition = { ...this.startPosition };\n }\n\n if (range.startIndex >= this.oldEndIndex) {\n newRange.startIndex = this.newEndIndex + (range.startIndex - this.oldEndIndex);\n newRange.startPosition = {\n row: this.newEndPosition.row + (range.startPosition.row - this.oldEndPosition.row),\n column: range.startPosition.row === this.oldEndPosition.row\n ? this.newEndPosition.column + (range.startPosition.column - this.oldEndPosition.column)\n : range.startPosition.column,\n };\n if (newRange.startIndex < this.newEndIndex) {\n newRange.startIndex = Number.MAX_SAFE_INTEGER;\n newRange.startPosition = { row: Number.MAX_SAFE_INTEGER, column: Number.MAX_SAFE_INTEGER };\n }\n } else if (range.startIndex > this.startIndex) {\n newRange.startIndex = this.startIndex;\n newRange.startPosition = { ...this.startPosition };\n }\n\n return newRange;\n }\n}\n", "import { type MainModule } from '../lib/web-tree-sitter';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { ParseState, type Parser } from './parser';\n\n/**\n * A position in a multi-line text document, in terms of rows and columns.\n *\n * Rows and columns are zero-based.\n */\nexport interface Point {\n /** The zero-based row number. */\n row: number;\n\n /** The zero-based column number. */\n column: number;\n}\n\n/**\n * A range of positions in a multi-line text document, both in terms of bytes\n * and of rows and columns.\n */\nexport interface Range {\n /** The start position of the range. */\n startPosition: Point;\n\n /** The end position of the range. */\n endPosition: Point;\n\n /** The start index of the range. */\n startIndex: number;\n\n /** The end index of the range. */\n endIndex: number;\n}\n\n/** @internal */\nexport const SIZE_OF_SHORT = 2;\n\n/** @internal */\nexport const SIZE_OF_INT = 4;\n\n/** @internal */\nexport const SIZE_OF_CURSOR = 4 * SIZE_OF_INT;\n\n/** @internal */\nexport const SIZE_OF_NODE = 5 * SIZE_OF_INT;\n\n/** @internal */\nexport const SIZE_OF_POINT = 2 * SIZE_OF_INT;\n\n/** @internal */\nexport const SIZE_OF_RANGE = 2 * SIZE_OF_INT + 2 * SIZE_OF_POINT;\n\n/** @internal */\nexport const ZERO_POINT: Point = { row: 0, column: 0 };\n\n/**\n * A callback for parsing that takes an index and point, and should return a string.\n */\nexport type ParseCallback = (index: number, position: Point) => string | undefined;\n\n/**\n * A callback that receives the parse state during parsing.\n */\nexport type ProgressCallback = (progress: ParseState) => boolean;\n\n/**\n * A callback for logging messages.\n *\n * If `isLex` is `true`, the message is from the lexer, otherwise it's from the parser.\n */\nexport type LogCallback = (message: string, isLex: boolean) => void;\n\n// Helper type for internal use\n/** @internal */\nexport const INTERNAL = Symbol('INTERNAL');\n/** @internal */\nexport type Internal = typeof INTERNAL;\n\n// Helper functions for type checking\n/** @internal */\nexport function assertInternal(x: unknown): asserts x is Internal {\n if (x !== INTERNAL) throw new Error('Illegal constructor');\n}\n\n/** @internal */\nexport function isPoint(point?: Point): point is Point {\n return (\n !!point &&\n typeof (point).row === 'number' &&\n typeof (point).column === 'number'\n );\n}\n\n/**\n * @internal\n *\n * Sets the Tree-sitter Wasm module. This should only be called by the {@link Parser} class via {@link Parser.init}.\n */\nexport function setModule(module: MainModule) {\n C = module;\n}\n\n/**\n * @internal\n *\n * `C` is a convenient shorthand for the Tree-sitter Wasm module,\n * which allows us to call all of the exported functions.\n */\nexport let C: MainModule;\n", "export function newFinalizer<T>(handler: (value: T) => void): FinalizationRegistry<T> | undefined {\n try {\n return new FinalizationRegistry(handler);\n } catch(e) {\n console.error('Unsupported FinalizationRegistry:', e);\n return;\n }\n}\n", "import { C, Internal, assertInternal } from './constants';\nimport { Language } from './language';\nimport { newFinalizer } from './finalization_registry';\n\nconst finalizer = newFinalizer((address: number) => {\n C._ts_lookahead_iterator_delete(address);\n});\n\nexport class LookaheadIterator implements Iterable<string> {\n /** @internal */\n private [0] = 0; // Internal handle for Wasm\n\n /** @internal */\n private language: Language;\n\n /** @internal */\n private positioned = false;\n\n /** @internal */\n constructor(internal: Internal, address: number, language: Language) {\n assertInternal(internal);\n this[0] = address;\n this.language = language;\n finalizer?.register(this, address, this);\n }\n\n /**\n * Get the current symbol of the lookahead iterator.\n *\n * Returns `null` if the iterator is not positioned on a symbol:\n *\n * - Before the first iteration step\n * - After the iterator is exhausted\n * - After a {@link reset} or {@link resetState} call\n */\n get currentTypeId(): number | null {\n return this.positioned ?\n C._ts_lookahead_iterator_current_symbol(this[0]) : null;\n }\n\n /**\n * Get the current symbol name of the lookahead iterator.\n *\n * Returns `null` if the iterator is not positioned on a symbol.\n */\n get currentType(): string | null {\n const id = this.currentTypeId;\n if (id === null) return null;\n // `Language.types` only holds regular and anonymous symbols, so auxiliary\n // ones (i.e. `end`) fall back to the language's own name table.\n return this.language.types[id] ??\n C.UTF8ToString(C._ts_language_symbol_name(this.language[0], id));\n }\n\n /** Delete the lookahead iterator, freeing its resources. */\n delete(): void {\n finalizer?.unregister(this);\n C._ts_lookahead_iterator_delete(this[0]);\n this[0] = 0;\n }\n\n\n /**\n * Reset the lookahead iterator.\n *\n * This returns `true` if the language was set successfully and `false`\n * otherwise.\n */\n reset(language: Language, stateId: number): boolean {\n if (C._ts_lookahead_iterator_reset(this[0], language[0], stateId)) {\n this.language = language;\n this.positioned = false;\n return true;\n }\n return false;\n }\n\n /**\n * Reset the lookahead iterator to another state.\n *\n * This returns `true` if the iterator was reset to the given state and\n * `false` otherwise.\n */\n resetState(stateId: number): boolean {\n if (!C._ts_lookahead_iterator_reset_state(this[0], stateId)) return false;\n this.positioned = false;\n return true;\n }\n\n /**\n * Returns an iterator that iterates over the symbols of the lookahead iterator.\n *\n * The iterator will yield the current symbol name as a string for each step\n * until there are no more symbols to iterate over.\n */\n [Symbol.iterator](): Iterator<string> {\n return {\n next: (): IteratorResult<string> => {\n this.positioned = Boolean(C._ts_lookahead_iterator_next(this[0]));\n const value = this.currentType;\n return value === null\n ? { done: true, value: '' }\n : { done: false, value };\n }\n };\n }\n}\n", "import { INTERNAL, Internal, assertInternal, ParseCallback, Point, Range, SIZE_OF_NODE, SIZE_OF_INT, SIZE_OF_RANGE, C } from './constants';\nimport { Language } from './language';\nimport { Node } from './node';\nimport { TreeCursor } from './tree_cursor';\nimport { marshalEdit, marshalPoint, unmarshalNode, unmarshalRange } from './marshal';\nimport { TRANSFER_BUFFER } from './parser';\nimport { Edit } from './edit';\nimport { newFinalizer } from './finalization_registry';\n\n/** @internal */\nexport function getText(tree: Tree, startIndex: number, endIndex: number, startPosition: Point): string {\n const length = endIndex - startIndex;\n let result = tree.textCallback(startIndex, startPosition);\n if (result) {\n startIndex += result.length;\n while (startIndex < endIndex) {\n const string = tree.textCallback(startIndex, startPosition);\n if (string && string.length > 0) {\n startIndex += string.length;\n result += string;\n } else {\n break;\n }\n }\n if (startIndex > endIndex) {\n result = result.slice(0, length);\n }\n }\n return result ?? '';\n}\n\nconst finalizer = newFinalizer((address: number) => {\n C._ts_tree_delete(address);\n});\n\n/** A tree that represents the syntactic structure of a source code file. */\nexport class Tree {\n /** @internal */\n private [0] = 0; // Internal handle for Wasm\n\n /** @internal */\n textCallback: ParseCallback;\n\n /** The language that was used to parse the syntax tree. */\n language: Language;\n\n /** @internal */\n constructor(internal: Internal, address: number, language: Language, textCallback: ParseCallback) {\n assertInternal(internal);\n this[0] = address;\n this.language = language;\n this.textCallback = textCallback;\n finalizer?.register(this, address, this);\n }\n\n /** Create a shallow copy of the syntax tree. This is very fast. */\n copy(): Tree {\n const address = C._ts_tree_copy(this[0]);\n return new Tree(INTERNAL, address, this.language, this.textCallback);\n }\n\n /** Delete the syntax tree, freeing its resources. */\n delete(): void {\n finalizer?.unregister(this);\n C._ts_tree_delete(this[0]);\n this[0] = 0;\n }\n\n /** Get the root node of the syntax tree. */\n get rootNode(): Node {\n C._ts_tree_root_node_wasm(this[0]);\n return unmarshalNode(this)!;\n }\n\n /**\n * Get the root node of the syntax tree, but with its position shifted\n * forward by the given offset.\n */\n rootNodeWithOffset(offsetBytes: number, offsetExtent: Point): Node {\n const address = TRANSFER_BUFFER + SIZE_OF_NODE;\n C.setValue(address, offsetBytes, 'i32');\n marshalPoint(address + SIZE_OF_INT, offsetExtent);\n C._ts_tree_root_node_with_offset_wasm(this[0]);\n return unmarshalNode(this)!;\n }\n\n /**\n * Edit the syntax tree to keep it in sync with source code that has been\n * edited.\n *\n * You must describe the edit both in terms of byte offsets and in terms of\n * row/column coordinates.\n */\n edit(edit: Edit): void {\n marshalEdit(edit);\n C._ts_tree_edit_wasm(this[0]);\n }\n\n /** Create a new {@link TreeCursor} starting from the root of the tree. */\n walk(): TreeCursor {\n return this.rootNode.walk();\n }\n\n /**\n * Compare this old edited syntax tree to a new syntax tree representing\n * the same document, returning a sequence of ranges whose syntactic\n * structure has changed.\n *\n * For this to work correctly, this syntax tree must have been edited such\n * that its ranges match up to the new tree. Generally, you'll want to\n * call this method right after calling one of the [`Parser::parse`]\n * functions. Call it on the old tree that was passed to parse, and\n * pass the new tree that was returned from `parse`.\n */\n getChangedRanges(other: Tree): Range[] {\n if (!(other instanceof Tree)) {\n throw new TypeError('Argument must be a Tree');\n }\n\n C._ts_tree_get_changed_ranges_wasm(this[0], other[0]);\n const count = C.getValue(TRANSFER_BUFFER, 'i32');\n const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, 'i32');\n const result = new Array<Range>(count);\n\n if (count > 0) {\n let address = buffer;\n for (let i = 0; i < count; i++) {\n result[i] = unmarshalRange(address);\n address += SIZE_OF_RANGE;\n }\n C._free(buffer);\n }\n return result;\n }\n\n /** Get the included ranges that were used to parse the syntax tree. */\n getIncludedRanges(): Range[] {\n C._ts_tree_included_ranges_wasm(this[0]);\n const count = C.getValue(TRANSFER_BUFFER, 'i32');\n const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, 'i32');\n const result = new Array<Range>(count);\n\n if (count > 0) {\n let address = buffer;\n for (let i = 0; i < count; i++) {\n result[i] = unmarshalRange(address);\n address += SIZE_OF_RANGE;\n }\n C._free(buffer);\n }\n return result;\n }\n}\n", "import { INTERNAL, Internal, assertInternal, Point, SIZE_OF_NODE, SIZE_OF_CURSOR, C } from './constants';\nimport { marshalNode, marshalPoint, marshalTreeCursor, unmarshalNode, unmarshalPoint, unmarshalTreeCursor } from './marshal';\nimport { Node } from './node';\nimport { TRANSFER_BUFFER } from './parser';\nimport { getText, Tree } from './tree';\nimport { newFinalizer } from './finalization_registry';\n\nconst finalizer = newFinalizer((address: number) => {\n C._ts_tree_cursor_delete_wasm(address);\n});\n\n/** A stateful object for walking a syntax {@link Tree} efficiently. */\nexport class TreeCursor {\n /** @internal */\n // @ts-expect-error: never read\n private [0] = 0; // Internal handle for Wasm\n\n /** @internal */\n // @ts-expect-error: never read\n private [1] = 0; // Internal handle for Wasm\n\n /** @internal */\n // @ts-expect-error: never read\n private [2] = 0; // Internal handle for Wasm\n\n /** @internal */\n // @ts-expect-error: never read\n private [3] = 0; // Internal handle for Wasm\n\n /** @internal */\n private tree: Tree;\n\n /** @internal */\n constructor(internal: Internal, tree: Tree) {\n assertInternal(internal);\n this.tree = tree;\n unmarshalTreeCursor(this);\n finalizer?.register(this, this.tree[0], this);\n }\n\n /** Creates a deep copy of the tree cursor. This allocates new memory. */\n copy(): TreeCursor {\n const copy = new TreeCursor(INTERNAL, this.tree);\n C._ts_tree_cursor_copy_wasm(this.tree[0]);\n unmarshalTreeCursor(copy);\n return copy;\n }\n\n /** Delete the tree cursor, freeing its resources. */\n delete(): void {\n finalizer?.unregister(this);\n marshalTreeCursor(this);\n C._ts_tree_cursor_delete_wasm(this.tree[0]);\n this[0] = this[1] = this[2] = 0;\n }\n\n /** Get the tree cursor's current {@link Node}. */\n get currentNode(): Node {\n marshalTreeCursor(this);\n C._ts_tree_cursor_current_node_wasm(this.tree[0]);\n return unmarshalNode(this.tree)!;\n }\n\n /**\n * Get the numerical field id of this tree cursor's current node.\n *\n * See also {@link TreeCursor#currentFieldName}.\n */\n get currentFieldId(): number {\n marshalTreeCursor(this);\n return C._ts_tree_cursor_current_field_id_wasm(this.tree[0]);\n }\n\n /** Get the field name of this tree cursor's current node. */\n get currentFieldName(): string | null {\n return this.tree.language.fields[this.currentFieldId];\n }\n\n /**\n * Get the depth of the cursor's current node relative to the original\n * node that the cursor was constructed with.\n */\n get currentDepth(): number {\n marshalTreeCursor(this);\n return C._ts_tree_cursor_current_depth_wasm(this.tree[0]);\n }\n\n /**\n * Get the index of the cursor's current node out of all of the\n * descendants of the original node that the cursor was constructed with.\n */\n get currentDescendantIndex(): number {\n marshalTreeCursor(this);\n return C._ts_tree_cursor_current_descendant_index_wasm(this.tree[0]);\n }\n\n /** Get the type of the cursor's current node. */\n get nodeType(): string {\n return this.tree.language.types[this.nodeTypeId] || 'ERROR';\n }\n\n /** Get the type id of the cursor's current node. */\n get nodeTypeId(): number {\n marshalTreeCursor(this);\n return C._ts_tree_cursor_current_node_type_id_wasm(this.tree[0]);\n }\n\n /** Get the state id of the cursor's current node. */\n get nodeStateId(): number {\n marshalTreeCursor(this);\n return C._ts_tree_cursor_current_node_state_id_wasm(this.tree[0]);\n }\n\n /** Get the id of the cursor's current node. */\n get nodeId(): number {\n marshalTreeCursor(this);\n return C._ts_tree_cursor_current_node_id_wasm(this.tree[0]);\n }\n\n /**\n * Check if the cursor's current node is *named*.\n *\n * Named nodes correspond to named rules in the grammar, whereas\n * *anonymous* nodes correspond to string literals in the grammar.\n */\n get nodeIsNamed(): boolean {\n marshalTreeCursor(this);\n return C._ts_tree_cursor_current_node_is_named_wasm(this.tree[0]) === 1;\n }\n\n /**\n * Check if the cursor's current node is *missing*.\n *\n * Missing nodes are inserted by the parser in order to recover from\n * certain kinds of syntax errors.\n */\n get nodeIsMissing(): boolean {\n marshalTreeCursor(this);\n return C._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0]) === 1;\n }\n\n /** Get the string content of the cursor's current node. */\n get nodeText(): string {\n marshalTreeCursor(this);\n const startIndex = C._ts_tree_cursor_start_index_wasm(this.tree[0]);\n const endIndex = C._ts_tree_cursor_end_index_wasm(this.tree[0]);\n C._ts_tree_cursor_start_position_wasm(this.tree[0]);\n const startPosition = unmarshalPoint(TRANSFER_BUFFER);\n return getText(this.tree, startIndex, endIndex, startPosition);\n }\n\n /** Get the start position of the cursor's current node. */\n get startPosition(): Point {\n marshalTreeCursor(this);\n C._ts_tree_cursor_start_position_wasm(this.tree[0]);\n return unmarshalPoint(TRANSFER_BUFFER);\n }\n\n /** Get the end position of the cursor's current node. */\n get endPosition(): Point {\n marshalTreeCursor(this);\n C._ts_tree_cursor_end_position_wasm(this.tree[0]);\n return unmarshalPoint(TRANSFER_BUFFER);\n }\n\n /** Get the start index of the cursor's current node. */\n get startIndex(): number {\n marshalTreeCursor(this);\n return C._ts_tree_cursor_start_index_wasm(this.tree[0]);\n }\n\n /** Get the end index of the cursor's current node. */\n get endIndex(): number {\n marshalTreeCursor(this);\n return C._ts_tree_cursor_end_index_wasm(this.tree[0]);\n }\n\n /**\n * Move this cursor to the first child of its current node.\n *\n * This returns `true` if the cursor successfully moved, and returns\n * `false` if there were no children.\n */\n gotoFirstChild(): boolean {\n marshalTreeCursor(this);\n const result = C._ts_tree_cursor_goto_first_child_wasm(this.tree[0]);\n unmarshalTreeCursor(this);\n return result === 1;\n }\n\n /**\n * Move this cursor to the last child of its current node.\n *\n * This returns `true` if the cursor successfully moved, and returns\n * `false` if there were no children.\n *\n * Note that this function may be slower than\n * {@link TreeCursor#gotoFirstChild} because it needs to\n * iterate through all the children to compute the child's position.\n */\n gotoLastChild(): boolean {\n marshalTreeCursor(this);\n const result = C._ts_tree_cursor_goto_last_child_wasm(this.tree[0]);\n unmarshalTreeCursor(this);\n return result === 1;\n }\n\n /**\n * Move this cursor to the parent of its current node.\n *\n * This returns `true` if the cursor successfully moved, and returns\n * `false` if there was no parent node (the cursor was already on the\n * root node).\n *\n * Note that the node the cursor was constructed with is considered the root\n * of the cursor, and the cursor cannot walk outside this node.\n */\n gotoParent(): boolean {\n marshalTreeCursor(this);\n const result = C._ts_tree_cursor_goto_parent_wasm(this.tree[0]);\n unmarshalTreeCursor(this);\n return result === 1;\n }\n\n /**\n * Move this cursor to the next sibling of its current node.\n *\n * This returns `true` if the cursor successfully moved, and returns\n * `false` if there was no next sibling node.\n *\n * Note that the node the cursor was constructed with is considered the root\n * of the cursor, and the cursor cannot walk outside this node.\n */\n gotoNextSibling(): boolean {\n marshalTreeCursor(this);\n const result = C._ts_tree_cursor_goto_next_sibling_wasm(this.tree[0]);\n unmarshalTreeCursor(this);\n return result === 1;\n }\n\n /**\n * Move this cursor to the previous sibling of its current node.\n *\n * This returns `true` if the cursor successfully moved, and returns\n * `false` if there was no previous sibling node.\n *\n * Note that this function may be slower than\n * {@link TreeCursor#gotoNextSibling} due to how node\n * positions are stored. In the worst case, this will need to iterate\n * through all the children up to the previous sibling node to recalculate\n * its position. Also note that the node the cursor was constructed with is\n * considered the root of the cursor, and the cursor cannot walk outside this node.\n */\n gotoPreviousSibling(): boolean {\n marshalTreeCursor(this);\n const result = C._ts_tree_cursor_goto_previous_sibling_wasm(this.tree[0]);\n unmarshalTreeCursor(this);\n return result === 1;\n }\n\n /**\n * Move the cursor to the node that is the nth descendant of\n * the original node that the cursor was constructed with, where\n * zero represents the original node itself.\n */\n gotoDescendant(goalDescendantIndex: number): void {\n marshalTreeCursor(this);\n C._ts_tree_cursor_goto_descendant_wasm(this.tree[0], goalDescendantIndex);\n unmarshalTreeCursor(this);\n }\n\n /**\n * Move this cursor to the first child of its current node that contains or\n * starts after the given byte offset.\n *\n * This returns `true` if the cursor successfully moved to a child node, and returns\n * `false` if no such child was found.\n */\n gotoFirstChildForIndex(goalIndex: number): boolean {\n marshalTreeCursor(this);\n C.setValue(TRANSFER_BUFFER + SIZE_OF_CURSOR, goalIndex, 'i32');\n const result = C._ts_tree_cursor_goto_first_child_for_index_wasm(this.tree[0]);\n unmarshalTreeCursor(this);\n return result === 1;\n }\n\n /**\n * Move this cursor to the first child of its current node that contains or\n * starts after the given byte offset.\n *\n * This returns the index of the child node if one was found, and returns\n * `null` if no such child was found.\n */\n gotoFirstChildForPosition(goalPosition: Point): boolean {\n marshalTreeCursor(this);\n marshalPoint(TRANSFER_BUFFER + SIZE_OF_CURSOR, goalPosition);\n const result = C._ts_tree_cursor_goto_first_child_for_position_wasm(this.tree[0]);\n unmarshalTreeCursor(this);\n return result === 1;\n }\n\n /**\n * Re-initialize this tree cursor to start at the original node that the\n * cursor was constructed with.\n */\n reset(node: Node): void {\n marshalNode(node);\n marshalTreeCursor(this, TRANSFER_BUFFER + SIZE_OF_NODE);\n C._ts_tree_cursor_reset_wasm(this.tree[0]);\n unmarshalTreeCursor(this);\n }\n\n /**\n * Re-initialize a tree cursor to the same position as another cursor.\n *\n * Unlike {@link TreeCursor#reset}, this will not lose parent\n * information and allows reusing already created cursors.\n */\n resetTo(cursor: TreeCursor): void {\n marshalTreeCursor(this, TRANSFER_BUFFER);\n marshalTreeCursor(cursor, TRANSFER_BUFFER + SIZE_OF_CURSOR);\n C._ts_tree_cursor_reset_to_wasm(this.tree[0], cursor.tree[0]);\n unmarshalTreeCursor(this);\n }\n}\n", "import { INTERNAL, Internal, assertInternal, SIZE_OF_INT, SIZE_OF_NODE, SIZE_OF_POINT, ZERO_POINT, isPoint, C, Point } from './constants';\nimport { getText, Tree } from './tree';\nimport { TreeCursor } from './tree_cursor';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { Language } from './language';\nimport { marshalNode, marshalPoint, unmarshalNode, unmarshalPoint } from './marshal';\nimport { TRANSFER_BUFFER } from './parser';\nimport { Edit } from './edit';\n\n/** A single node within a syntax {@link Tree}. */\nexport class Node {\n /** @internal */\n // @ts-expect-error: never read\n private [0] = 0; // Internal handle for Wasm\n\n /** @internal */\n private _children?: Node[];\n\n /** @internal */\n private _namedChildren?: Node[];\n\n /** @internal */\n constructor(\n internal: Internal,\n {\n id,\n tree,\n startIndex,\n startPosition,\n other,\n }: {\n id: number;\n tree: Tree;\n startIndex: number;\n startPosition: Point;\n other: number;\n }\n ) {\n assertInternal(internal);\n this[0] = other;\n this.id = id;\n this.tree = tree;\n this.startIndex = startIndex;\n this.startPosition = startPosition;\n }\n\n /**\n * The numeric id for this node that is unique.\n *\n * Within a given syntax tree, no two nodes have the same id. However:\n *\n * * If a new tree is created based on an older tree, and a node from the old tree is reused in\n * the process, then that node will have the same id in both trees.\n *\n * * A node not marked as having changes does not guarantee it was reused.\n *\n * * If a node is marked as having changed in the old tree, it will not be reused.\n */\n id: number;\n\n /** The byte index where this node starts. */\n startIndex: number;\n\n /** The position where this node starts. */\n startPosition: Point;\n\n /** The tree that this node belongs to. */\n tree: Tree;\n\n /** Get this node's type as a numerical id. */\n get typeId(): number {\n marshalNode(this);\n return C._ts_node_symbol_wasm(this.tree[0]);\n }\n\n /**\n * Get the node's type as a numerical id as it appears in the grammar,\n * ignoring aliases.\n */\n get grammarId(): number {\n marshalNode(this);\n return C._ts_node_grammar_symbol_wasm(this.tree[0]);\n }\n\n /** Get this node's type as a string. */\n get type(): string {\n return this.tree.language.types[this.typeId] || 'ERROR';\n }\n\n /**\n * Get this node's symbol name as it appears in the grammar, ignoring\n * aliases as a string.\n */\n get grammarType(): string {\n return this.tree.language.types[this.grammarId] || 'ERROR';\n }\n\n /**\n * Check if this node is *named*.\n *\n * Named nodes correspond to named rules in the grammar, whereas\n * *anonymous* nodes correspond to string literals in the grammar.\n */\n get isNamed(): boolean {\n marshalNode(this);\n return C._ts_node_is_named_wasm(this.tree[0]) === 1;\n }\n\n /**\n * Check if this node is *extra*.\n *\n * Extra nodes represent things like comments, which are not required\n * by the grammar, but can appear anywhere.\n */\n get isExtra(): boolean {\n marshalNode(this);\n return C._ts_node_is_extra_wasm(this.tree[0]) === 1;\n }\n\n /**\n * Check if this node represents a syntax error.\n *\n * Syntax errors represent parts of the code that could not be incorporated\n * into a valid syntax tree.\n */\n get isError(): boolean {\n marshalNode(this);\n return C._ts_node_is_error_wasm(this.tree[0]) === 1;\n }\n\n /**\n * Check if this node is *missing*.\n *\n * Missing nodes are inserted by the parser in order to recover from\n * certain kinds of syntax errors.\n */\n get isMissing(): boolean {\n marshalNode(this);\n return C._ts_node_is_missing_wasm(this.tree[0]) === 1;\n }\n\n /** Check if this node has been edited. */\n get hasChanges(): boolean {\n marshalNode(this);\n return C._ts_node_has_changes_wasm(this.tree[0]) === 1;\n }\n\n /**\n * Check if this node represents a syntax error or contains any syntax\n * errors anywhere within it.\n */\n get hasError(): boolean {\n marshalNode(this);\n return C._ts_node_has_error_wasm(this.tree[0]) === 1;\n }\n\n /** Get the byte index where this node ends. */\n get endIndex(): number {\n marshalNode(this);\n return C._ts_node_end_index_wasm(this.tree[0]);\n }\n\n /** Get the position where this node ends. */\n get endPosition(): Point {\n marshalNode(this);\n C._ts_node_end_point_wasm(this.tree[0]);\n return unmarshalPoint(TRANSFER_BUFFER);\n }\n\n /** Get the string content of this node. */\n get text(): string {\n return getText(this.tree, this.startIndex, this.endIndex, this.startPosition);\n }\n\n /** Get this node's parse state. */\n get parseState(): number {\n marshalNode(this);\n return C._ts_node_parse_state_wasm(this.tree[0]);\n }\n\n /** Get the parse state after this node. */\n get nextParseState(): number {\n marshalNode(this);\n return C._ts_node_next_parse_state_wasm(this.tree[0]);\n }\n\n /** Check if this node is equal to another node. */\n equals(other: Node): boolean {\n return this.tree === other.tree && this.id === other.id;\n }\n\n /**\n * Get the node's child at the given index, where zero represents the first child.\n *\n * This method is fairly fast, but its cost is technically log(n), so if\n * you might be iterating over a long list of children, you should use\n * {@link Node#children} instead.\n */\n child(index: number): Node | null {\n marshalNode(this);\n C._ts_node_child_wasm(this.tree[0], index);\n return unmarshalNode(this.tree);\n }\n\n /**\n * Get this node's *named* child at the given index.\n *\n * See also {@link Node#isNamed}.\n * This method is fairly fast, but its cost is technically log(n), so if\n * you might be iterating over a long list of children, you should use\n * {@link Node#namedChildren} instead.\n */\n namedChild(index: number): Node | null {\n marshalNode(this);\n C._ts_node_named_child_wasm(this.tree[0], index);\n return unmarshalNode(this.tree);\n }\n\n /**\n * Get this node's child with the given numerical field id.\n *\n * See also {@link Node#childForFieldName}. You can\n * convert a field name to an id using {@link Language#fieldIdForName}.\n */\n childForFieldId(fieldId: number): Node | null {\n marshalNode(this);\n C._ts_node_child_by_field_id_wasm(this.tree[0], fieldId);\n return unmarshalNode(this.tree);\n }\n\n /**\n * Get the first child with the given field name.\n *\n * If multiple children may have the same field name, access them using\n * {@link Node#childrenForFieldName}.\n */\n childForFieldName(fieldName: string): Node | null {\n const fieldId = this.tree.language.fields.indexOf(fieldName);\n if (fieldId !== -1) return this.childForFieldId(fieldId);\n return null;\n }\n\n /** Get the field name of this node's child at the given index. */\n fieldNameForChild(index: number): string | null {\n marshalNode(this);\n const address = C._ts_node_field_name_for_child_wasm(this.tree[0], index);\n if (!address) return null;\n return C.AsciiToString(address);\n }\n\n /** Get the field name of this node's named child at the given index. */\n fieldNameForNamedChild(index: number): string | null {\n marshalNode(this);\n const address = C._ts_node_field_name_for_named_child_wasm(this.tree[0], index);\n if (!address) return null;\n return C.AsciiToString(address);\n }\n /**\n * Get an array of this node's children with a given field name.\n *\n * See also {@link Node#children}.\n */\n childrenForFieldName(fieldName: string): Node[] {\n const fieldId = this.tree.language.fields.indexOf(fieldName);\n if (fieldId !== -1 && fieldId !== 0) return this.childrenForFieldId(fieldId);\n return [];\n }\n\n /**\n * Get an array of this node's children with a given field id.\n *\n * See also {@link Node#childrenForFieldName}.\n */\n childrenForFieldId(fieldId: number): Node[] {\n marshalNode(this);\n C._ts_node_children_by_field_id_wasm(this.tree[0], fieldId);\n const count = C.getValue(TRANSFER_BUFFER, 'i32');\n const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, 'i32');\n const result = new Array<Node>(count);\n\n if (count > 0) {\n let address = buffer;\n for (let i = 0; i < count; i++) {\n result[i] = unmarshalNode(this.tree, address)!;\n address += SIZE_OF_NODE;\n }\n C._free(buffer);\n }\n return result;\n }\n\n /** Get the node's first child that contains or starts after the given byte offset. */\n firstChildForIndex(index: number): Node | null {\n marshalNode(this);\n const address = TRANSFER_BUFFER + SIZE_OF_NODE;\n C.setValue(address, index, 'i32');\n C._ts_node_first_child_for_byte_wasm(this.tree[0]);\n return unmarshalNode(this.tree);\n }\n\n /** Get the node's first named child that contains or starts after the given byte offset. */\n firstNamedChildForIndex(index: number): Node | null {\n marshalNode(this);\n const address = TRANSFER_BUFFER + SIZE_OF_NODE;\n C.setValue(address, index, 'i32');\n C._ts_node_first_named_child_for_byte_wasm(this.tree[0]);\n return unmarshalNode(this.tree);\n }\n\n /** Get this node's number of children. */\n get childCount(): number {\n marshalNode(this);\n return C._ts_node_child_count_wasm(this.tree[0]);\n }\n\n\n /**\n * Get this node's number of *named* children.\n *\n * See also {@link Node#isNamed}.\n */\n get namedChildCount(): number {\n marshalNode(this);\n return C._ts_node_named_child_count_wasm(this.tree[0]);\n }\n\n /** Get this node's first child. */\n get firstChild(): Node | null {\n return this.child(0);\n }\n\n /**\n * Get this node's first named child.\n *\n * See also {@link Node#isNamed}.\n */\n get firstNamedChild(): Node | null {\n return this.namedChild(0);\n }\n\n /** Get this node's last child. */\n get lastChild(): Node | null {\n return this.child(this.childCount - 1);\n }\n\n /**\n * Get this node's last named child.\n *\n * See also {@link Node#isNamed}.\n */\n get lastNamedChild(): Node | null {\n return this.namedChild(this.namedChildCount - 1);\n }\n\n /**\n * Iterate over this node's children.\n *\n * If you're walking the tree recursively, you may want to use the\n * {@link TreeCursor} APIs directly instead.\n */\n get children(): Node[] {\n if (!this._children) {\n marshalNode(this);\n C._ts_node_children_wasm(this.tree[0]);\n const count = C.getValue(TRANSFER_BUFFER, 'i32');\n const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, 'i32');\n this._children = new Array<Node>(count);\n if (count > 0) {\n let address = buffer;\n for (let i = 0; i < count; i++) {\n this._children[i] = unmarshalNode(this.tree, address)!;\n address += SIZE_OF_NODE;\n }\n C._free(buffer);\n }\n }\n return this._children;\n }\n\n /**\n * Iterate over this node's named children.\n *\n * See also {@link Node#children}.\n */\n get namedChildren(): Node[] {\n if (!this._namedChildren) {\n marshalNode(this);\n C._ts_node_named_children_wasm(this.tree[0]);\n const count = C.getValue(TRANSFER_BUFFER, 'i32');\n const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, 'i32');\n this._namedChildren = new Array<Node>(count);\n if (count > 0) {\n let address = buffer;\n for (let i = 0; i < count; i++) {\n this._namedChildren[i] = unmarshalNode(this.tree, address)!;\n address += SIZE_OF_NODE;\n }\n C._free(buffer);\n }\n }\n return this._namedChildren;\n }\n\n /**\n * Get the descendants of this node that are the given type, or in the given types array.\n *\n * The types array should contain node type strings, which can be retrieved from {@link Language#types}.\n *\n * Additionally, a `startPosition` and `endPosition` can be passed in to restrict the search to a byte range.\n */\n descendantsOfType(\n types: string | string[],\n startPosition: Point = ZERO_POINT,\n endPosition: Point = ZERO_POINT\n ): Node[] {\n if (!Array.isArray(types)) types = [types];\n\n // Convert the type strings to numeric type symbols\n const symbols: number[] = [];\n const typesBySymbol = this.tree.language.types;\n for (const node_type of types) {\n if (node_type == \"ERROR\") {\n symbols.push(65535); // Internally, ts_builtin_sym_error is -1, which is UINT_16MAX\n }\n }\n for (let i = 0, n = typesBySymbol.length; i < n; i++) {\n if (types.includes(typesBySymbol[i])) {\n symbols.push(i);\n }\n }\n\n // Copy the array of symbols to the Wasm heap\n const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length);\n for (let i = 0, n = symbols.length; i < n; i++) {\n C.setValue(symbolsAddress + i * SIZE_OF_INT, symbols[i], 'i32');\n }\n\n // Call the C API to compute the descendants\n marshalNode(this);\n C._ts_node_descendants_of_type_wasm(\n this.tree[0],\n symbolsAddress,\n symbols.length,\n startPosition.row,\n startPosition.column,\n endPosition.row,\n endPosition.column\n );\n\n // Instantiate the nodes based on the data returned\n const descendantCount = C.getValue(TRANSFER_BUFFER, 'i32');\n const descendantAddress = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, 'i32');\n const result = new Array<Node>(descendantCount);\n if (descendantCount > 0) {\n let address = descendantAddress;\n for (let i = 0; i < descendantCount; i++) {\n result[i] = unmarshalNode(this.tree, address)!;\n address += SIZE_OF_NODE;\n }\n }\n\n // Free the intermediate buffers\n C._free(descendantAddress);\n C._free(symbolsAddress);\n return result;\n }\n\n /** Get this node's next sibling. */\n get nextSibling(): Node | null {\n marshalNode(this);\n C._ts_node_next_sibling_wasm(this.tree[0]);\n return unmarshalNode(this.tree);\n }\n\n /** Get this node's previous sibling. */\n get previousSibling(): Node | null {\n marshalNode(this);\n C._ts_node_prev_sibling_wasm(this.tree[0]);\n return unmarshalNode(this.tree);\n }\n\n /**\n * Get this node's next *named* sibling.\n *\n * See also {@link Node#isNamed}.\n */\n get nextNamedSibling(): Node | null {\n marshalNode(this);\n C._ts_node_next_named_sibling_wasm(this.tree[0]);\n return unmarshalNode(this.tree);\n }\n\n /**\n * Get this node's previous *named* sibling.\n *\n * See also {@link Node#isNamed}.\n */\n get previousNamedSibling(): Node | null {\n marshalNode(this);\n C._ts_node_prev_named_sibling_wasm(this.tree[0]);\n return unmarshalNode(this.tree);\n }\n\n /** Get the node's number of descendants, including one for the node itself. */\n get descendantCount(): number {\n marshalNode(this);\n return C._ts_node_descendant_count_wasm(this.tree[0]);\n }\n\n /**\n * Get this node's immediate parent.\n * Prefer {@link Node#childWithDescendant} for iterating over this node's ancestors.\n */\n get parent(): Node | null {\n marshalNode(this);\n C._ts_node_parent_wasm(this.tree[0]);\n return unmarshalNode(this.tree);\n }\n\n /**\n * Get the node that contains `descendant`.\n *\n * Note that this can return `descendant` itself.\n */\n childWithDescendant(descendant: Node): Node | null {\n marshalNode(this);\n marshalNode(descendant, 1);\n C._ts_node_child_with_descendant_wasm(this.tree[0]);\n return unmarshalNode(this.tree);\n }\n\n /** Get the smallest node within this node that spans the given byte range. */\n descendantForIndex(start: number, end: number = start): Node | null {\n if (typeof start !== 'number' || typeof end !== 'number') {\n throw new Error('Arguments must be numbers');\n }\n\n marshalNode(this);\n const address = TRANSFER_BUFFER + SIZE_OF_NODE;\n C.setValue(address, start, 'i32');\n C.setValue(address + SIZE_OF_INT, end, 'i32');\n C._ts_node_descendant_for_index_wasm(this.tree[0]);\n return unmarshalNode(this.tree);\n }\n\n /** Get the smallest named node within this node that spans the given byte range. */\n namedDescendantForIndex(start: number, end: number = start): Node | null {\n if (typeof start !== 'number' || typeof end !== 'number') {\n throw new Error('Arguments must be numbers');\n }\n\n marshalNode(this);\n const address = TRANSFER_BUFFER + SIZE_OF_NODE;\n C.setValue(address, start, 'i32');\n C.setValue(address + SIZE_OF_INT, end, 'i32');\n C._ts_node_named_descendant_for_index_wasm(this.tree[0]);\n return unmarshalNode(this.tree);\n }\n\n /** Get the smallest node within this node that spans the given point range. */\n descendantForPosition(start: Point, end: Point = start) {\n if (!isPoint(start) || !isPoint(end)) {\n throw new Error('Arguments must be {row, column} objects');\n }\n\n marshalNode(this);\n const address = TRANSFER_BUFFER + SIZE_OF_NODE;\n marshalPoint(address, start);\n marshalPoint(address + SIZE_OF_POINT, end);\n C._ts_node_descendant_for_position_wasm(this.tree[0]);\n return unmarshalNode(this.tree);\n }\n\n /** Get the smallest named node within this node that spans the given point range. */\n namedDescendantForPosition(start: Point, end: Point = start) {\n if (!isPoint(start) || !isPoint(end)) {\n throw new Error('Arguments must be {row, column} objects');\n }\n\n marshalNode(this);\n const address = TRANSFER_BUFFER + SIZE_OF_NODE;\n marshalPoint(address, start);\n marshalPoint(address + SIZE_OF_POINT, end);\n C._ts_node_named_descendant_for_position_wasm(this.tree[0]);\n return unmarshalNode(this.tree);\n }\n\n /**\n * Create a new {@link TreeCursor} starting from this node.\n *\n * Note that the given node is considered the root of the cursor,\n * and the cursor cannot walk outside this node.\n */\n walk(): TreeCursor {\n marshalNode(this);\n C._ts_tree_cursor_new_wasm(this.tree[0]);\n return new TreeCursor(INTERNAL, this.tree);\n }\n\n /**\n * Edit this node to keep it in-sync with source code that has been edited.\n *\n * This function is only rarely needed. When you edit a syntax tree with\n * the {@link Tree#edit} method, all of the nodes that you retrieve from\n * the tree afterward will already reflect the edit. You only need to\n * use {@link Node#edit} when you have a specific {@link Node} instance that\n * you want to keep and continue to use after an edit.\n */\n edit(edit: Edit) {\n if (this.startIndex >= edit.oldEndIndex) {\n this.startIndex = edit.newEndIndex + (this.startIndex - edit.oldEndIndex);\n let subbedPointRow;\n let subbedPointColumn;\n if (this.startPosition.row > edit.oldEndPosition.row) {\n subbedPointRow = this.startPosition.row - edit.oldEndPosition.row;\n subbedPointColumn = this.startPosition.column;\n } else {\n subbedPointRow = 0;\n subbedPointColumn = this.startPosition.column;\n if (this.startPosition.column >= edit.oldEndPosition.column) {\n subbedPointColumn =\n this.startPosition.column - edit.oldEndPosition.column;\n }\n }\n\n if (subbedPointRow > 0) {\n this.startPosition.row += subbedPointRow;\n this.startPosition.column = subbedPointColumn;\n } else {\n this.startPosition.column += subbedPointColumn;\n }\n } else if (this.startIndex > edit.startIndex) {\n this.startIndex = edit.newEndIndex;\n this.startPosition.row = edit.newEndPosition.row;\n this.startPosition.column = edit.newEndPosition.column;\n }\n }\n\n /** Get the S-expression representation of this node. */\n toString(): string {\n marshalNode(this);\n const address = C._ts_node_to_string_wasm(this.tree[0]);\n const result = C.AsciiToString(address);\n C._free(address);\n return result;\n }\n}\n", "import { INTERNAL, Point, Range, SIZE_OF_INT, SIZE_OF_NODE, SIZE_OF_POINT, C } from \"./constants\";\nimport { Node } from \"./node\";\nimport { Tree } from \"./tree\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { Query, QueryCapture, type QueryMatch } from \"./query\";\nimport { TreeCursor } from \"./tree_cursor\";\nimport { TRANSFER_BUFFER } from \"./parser\";\nimport { LanguageMetadata } from \"./language\";\nimport { Edit } from \"./edit\";\n\n/**\n * @internal\n *\n * Unmarshals a {@link QueryMatch} to the transfer buffer.\n */\nexport function unmarshalCaptures(\n query: Query,\n tree: Tree,\n address: number,\n patternIndex: number,\n result: QueryCapture[]\n) {\n for (let i = 0, n = result.length; i < n; i++) {\n const captureIndex = C.getValue(address, 'i32');\n address += SIZE_OF_INT;\n const node = unmarshalNode(tree, address)!;\n address += SIZE_OF_NODE;\n result[i] = {patternIndex, name: query.captureNames[captureIndex], node};\n }\n return address;\n}\n\n/**\n * @internal\n *\n * Marshals a {@link Node} to the transfer buffer.\n */\nexport function marshalNode(node: Node, index = 0) {\n let address = TRANSFER_BUFFER + index * SIZE_OF_NODE;\n C.setValue(address, node.id, 'i32');\n address += SIZE_OF_INT;\n C.setValue(address, node.startIndex, 'i32');\n address += SIZE_OF_INT;\n C.setValue(address, node.startPosition.row, 'i32');\n address += SIZE_OF_INT;\n C.setValue(address, node.startPosition.column, 'i32');\n address += SIZE_OF_INT;\n C.setValue(address, node[0], 'i32');\n}\n\n/**\n * @internal\n *\n * Unmarshals a {@link Node} from the transfer buffer.\n */\nexport function unmarshalNode(tree: Tree, address = TRANSFER_BUFFER): Node | null {\n const id = C.getValue(address, 'i32');\n address += SIZE_OF_INT;\n if (id === 0) return null;\n\n const index = C.getValue(address, 'i32');\n address += SIZE_OF_INT;\n const row = C.getValue(address, 'i32');\n address += SIZE_OF_INT;\n const column = C.getValue(address, 'i32');\n address += SIZE_OF_INT;\n const other = C.getValue(address, 'i32');\n\n const result = new Node(INTERNAL, {\n id,\n tree,\n startIndex: index,\n startPosition: {row, column},\n other,\n });\n\n return result;\n}\n\n/**\n * @internal\n *\n * Marshals a {@link TreeCursor} to the transfer buffer.\n */\nexport function marshalTreeCursor(cursor: TreeCursor, address = TRANSFER_BUFFER) {\n C.setValue(address + 0 * SIZE_OF_INT, cursor[0], 'i32');\n C.setValue(address + 1 * SIZE_OF_INT, cursor[1], 'i32');\n C.setValue(address + 2 * SIZE_OF_INT, cursor[2], 'i32');\n C.setValue(address + 3 * SIZE_OF_INT, cursor[3], 'i32');\n}\n\n/**\n * @internal\n *\n * Unmarshals a {@link TreeCursor} from the transfer buffer.\n */\nexport function unmarshalTreeCursor(cursor: TreeCursor) {\n cursor[0] = C.getValue(TRANSFER_BUFFER + 0 * SIZE_OF_INT, 'i32');\n cursor[1] = C.getValue(TRANSFER_BUFFER + 1 * SIZE_OF_INT, 'i32');\n cursor[2] = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, 'i32');\n cursor[3] = C.getValue(TRANSFER_BUFFER + 3 * SIZE_OF_INT, 'i32');\n}\n\n/**\n * @internal\n *\n * Marshals a {@link Point} to the transfer buffer.\n */\nexport function marshalPoint(address: number, point: Point): void {\n C.setValue(address, point.row, 'i32');\n C.setValue(address + SIZE_OF_INT, point.column, 'i32');\n}\n\n/**\n * @internal\n *\n * Unmarshals a {@link Point} from the transfer buffer.\n */\nexport function unmarshalPoint(address: number): Point {\n const result = {\n row: C.getValue(address, 'i32') >>> 0,\n column: C.getValue(address + SIZE_OF_INT, 'i32') >>> 0,\n };\n return result;\n}\n\n/**\n * @internal\n *\n * Marshals a {@link Range} to the transfer buffer.\n */\nexport function marshalRange(address: number, range: Range): void {\n marshalPoint(address, range.startPosition); address += SIZE_OF_POINT;\n marshalPoint(address, range.endPosition); address += SIZE_OF_POINT;\n C.setValue(address, range.startIndex, 'i32'); address += SIZE_OF_INT;\n C.setValue(address, range.endIndex, 'i32'); address += SIZE_OF_INT;\n}\n\n/**\n * @internal\n *\n * Unmarshals a {@link Range} from the transfer buffer.\n */\nexport function unmarshalRange(address: number): Range {\n const result = {} as Range;\n result.startPosition = unmarshalPoint(address); address += SIZE_OF_POINT;\n result.endPosition = unmarshalPoint(address); address += SIZE_OF_POINT;\n result.startIndex = C.getValue(address, 'i32') >>> 0; address += SIZE_OF_INT;\n result.endIndex = C.getValue(address, 'i32') >>> 0;\n return result;\n}\n\n/**\n * @internal\n *\n * Marshals an {@link Edit} to the transfer buffer.\n */\nexport function marshalEdit(edit: Edit, address = TRANSFER_BUFFER) {\n marshalPoint(address, edit.startPosition); address += SIZE_OF_POINT;\n marshalPoint(address, edit.oldEndPosition); address += SIZE_OF_POINT;\n marshalPoint(address, edit.newEndPosition); address += SIZE_OF_POINT;\n C.setValue(address, edit.startIndex, 'i32'); address += SIZE_OF_INT;\n C.setValue(address, edit.oldEndIndex, 'i32'); address += SIZE_OF_INT;\n C.setValue(address, edit.newEndIndex, 'i32'); address += SIZE_OF_INT;\n}\n\n/**\n * @internal\n *\n * Unmarshals a {@link LanguageMetadata} from the transfer buffer.\n */\nexport function unmarshalLanguageMetadata(address: number): LanguageMetadata { \n const major_version = C.getValue(address, 'i32');\n const minor_version = C.getValue(address += SIZE_OF_INT, 'i32');\n const patch_version = C.getValue(address += SIZE_OF_INT, 'i32');\n return { major_version, minor_version, patch_version };\n}\n", "import { C, INTERNAL, Internal, assertInternal, SIZE_OF_INT, SIZE_OF_SHORT } from './constants';\nimport { LookaheadIterator } from './lookahead_iterator';\nimport { unmarshalLanguageMetadata } from './marshal';\nimport { TRANSFER_BUFFER } from './parser';\n\nconst LANGUAGE_FUNCTION_REGEX = /^tree_sitter_\\w+$/;\n\nexport interface LanguageMetadata {\n readonly major_version: number;\n readonly minor_version: number;\n readonly patch_version: number;\n}\n\ntype LanguageWasmExports = Record<string, () => number>;\n\n/**\n * An opaque object that defines how to parse a particular language.\n * The code for each `Language` is generated by the Tree-sitter CLI.\n */\nexport class Language {\n /** @internal */\n private [0] = 0; // Internal handle for Wasm\n\n /**\n * A list of all node types in the language. The index of each type in this\n * array is its node type id.\n */\n types: string[];\n\n /**\n * A list of all field names in the language. The index of each field name in\n * this array is its field id.\n */\n fields: (string | null)[];\n\n /** @internal */\n constructor(internal: Internal, address: number) {\n assertInternal(internal);\n this[0] = address;\n this.types = new Array<string>(C._ts_language_symbol_count(this[0]));\n for (let i = 0, n = this.types.length; i < n; i++) {\n if (C._ts_language_symbol_type(this[0], i) < 2) {\n this.types[i] = C.UTF8ToString(C._ts_language_symbol_name(this[0], i));\n }\n }\n this.fields = new Array<string>(C._ts_language_field_count(this[0]) + 1);\n for (let i = 0, n = this.fields.length; i < n; i++) {\n const fieldName = C._ts_language_field_name_for_id(this[0], i);\n if (fieldName !== 0) {\n this.fields[i] = C.UTF8ToString(fieldName);\n } else {\n this.fields[i] = null;\n }\n }\n }\n\n\n /**\n * Gets the name of the language.\n */\n get name(): string | null {\n const ptr = C._ts_language_name(this[0]);\n if (ptr === 0) return null;\n return C.UTF8ToString(ptr);\n }\n\n /**\n * Gets the ABI version of the language.\n */\n get abiVersion(): number {\n return C._ts_language_abi_version(this[0]);\n }\n\n /**\n * Get the metadata for this language. This information is generated by the\n * CLI, and relies on the language author providing the correct metadata in\n * the language's `tree-sitter.json` file.\n */\n get metadata(): LanguageMetadata | null {\n C._ts_language_metadata_wasm(this[0]);\n const length = C.getValue(TRANSFER_BUFFER, 'i32');\n if (length === 0) return null;\n return unmarshalLanguageMetadata(TRANSFER_BUFFER + SIZE_OF_INT);\n }\n\n /**\n * Gets the number of fields in the language.\n */\n get fieldCount(): number {\n return this.fields.length - 1;\n }\n\n /**\n * Gets the number of states in the language.\n */\n get stateCount(): number {\n return C._ts_language_state_count(this[0]);\n }\n\n /**\n * Get the field id for a field name.\n */\n fieldIdForName(fieldName: string): number | null {\n const result = this.fields.indexOf(fieldName);\n return result !== -1 ? result : null;\n }\n\n /**\n * Get the field name for a field id.\n */\n fieldNameForId(fieldId: number): string | null {\n return this.fields[fieldId] ?? null;\n }\n\n /**\n * Get the node type id for a node type name.\n */\n idForNodeType(type: string, named: boolean): number | null {\n const typeLength = C.lengthBytesUTF8(type);\n const typeAddress = C._malloc(typeLength + 1);\n C.stringToUTF8(type, typeAddress, typeLength + 1);\n const result = C._ts_language_symbol_for_name(this[0], typeAddress, typeLength, named ? 1 : 0);\n C._free(typeAddress);\n return result || null;\n }\n\n /**\n * Gets the number of node types in the language.\n */\n get nodeTypeCount(): number {\n return C._ts_language_symbol_count(this[0]);\n }\n\n /**\n * Get the node type name for a node type id.\n */\n nodeTypeForId(typeId: number): string | null {\n const name = C._ts_language_symbol_name(this[0], typeId);\n return name ? C.UTF8ToString(name) : null;\n }\n\n /**\n * Check if a node type is named.\n *\n * @see {@link https://tree-sitter.github.io/tree-sitter/using-parsers/2-basic-parsing.html#named-vs-anonymous-nodes}\n */\n nodeTypeIsNamed(typeId: number): boolean {\n return C._ts_language_type_is_named_wasm(this[0], typeId) ? true : false;\n }\n\n /**\n * Check if a node type is visible.\n */\n nodeTypeIsVisible(typeId: number): boolean {\n return C._ts_language_type_is_visible_wasm(this[0], typeId) ? true : false;\n }\n\n /**\n * Get the supertypes ids of this language.\n *\n * @see {@link https://tree-sitter.github.io/tree-sitter/using-parsers/6-static-node-types.html?highlight=supertype#supertype-nodes}\n */\n get supertypes(): number[] {\n C._ts_language_supertypes_wasm(this[0]);\n const count = C.getValue(TRANSFER_BUFFER, 'i32');\n const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, 'i32');\n const result = new Array<number>(count);\n\n if (count > 0) {\n let address = buffer;\n for (let i = 0; i < count; i++) {\n result[i] = C.getValue(address, 'i16');\n address += SIZE_OF_SHORT;\n }\n }\n\n return result;\n }\n\n /**\n * Get the subtype ids for a given supertype node id.\n */\n subtypes(supertype: number): number[] {\n C._ts_language_subtypes_wasm(this[0], supertype);\n const count = C.getValue(TRANSFER_BUFFER, 'i32');\n const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, 'i32');\n const result = new Array<number>(count);\n\n if (count > 0) {\n let address = buffer;\n for (let i = 0; i < count; i++) {\n result[i] = C.getValue(address, 'i16');\n address += SIZE_OF_SHORT;\n }\n }\n\n return result;\n }\n\n /**\n * Get the next state id for a given state id and node type id.\n */\n nextState(stateId: number, typeId: number): number {\n return C._ts_language_next_state(this[0], stateId, typeId);\n }\n\n /**\n * Create a new lookahead iterator for this language and parse state.\n *\n * This returns `null` if state is invalid for this language.\n *\n * Iterating {@link LookaheadIterator} will yield valid symbols in the given\n * parse state. A newly created iterator is not positioned on a symbol, so\n * {@link LookaheadIterator#currentType} returns `null` until the first\n * iteration step.\n *\n * Lookahead iterators can be useful for generating suggestions and improving\n * syntax error diagnostics. To get symbols valid in an `ERROR` node, use the\n * lookahead iterator on its first leaf node state. For `MISSING` nodes, a\n * lookahead iterator created on the previous non-extra leaf node may be\n * appropriate.\n */\n lookaheadIterator(stateId: number): LookaheadIterator | null {\n const address = C._ts_lookahead_iterator_new(this[0], stateId);\n if (address) return new LookaheadIterator(INTERNAL, address, this);\n return null;\n }\n\n /**\n * Load a language from a WebAssembly module.\n * The module can be provided as a path to a file, a `URL` to a file, or as a\n * buffer.\n */\n static async load(input: string | URL | Uint8Array): Promise<Language> {\n let binary: Uint8Array | WebAssembly.Module;\n if (input instanceof Uint8Array) {\n binary = input;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n } else if (globalThis.process?.versions.node) {\n const fs: typeof import('fs/promises') = await import('fs/promises');\n binary = await fs.readFile(input);\n } else {\n const response = await fetch(input);\n\n if (!response.ok){\n const body = await response.text();\n throw new Error(`Language.load failed with status ${response.status}.\\n\\n${body}`);\n }\n\n const retryResp = response.clone();\n try {\n binary = await WebAssembly.compileStreaming(response);\n } catch (reason) {\n console.error('wasm streaming compile failed:', reason);\n console.error('falling back to ArrayBuffer instantiation');\n // fallback, probably because of bad MIME type\n binary = new Uint8Array(await retryResp.arrayBuffer())\n }\n }\n\n const mod = await C.loadWebAssemblyModule(binary, { loadAsync: true });\n return Language.loadFromWasmExports(mod, { sync: false });\n }\n\n private static loadFromWasmExports(mod: LanguageWasmExports, { sync }: { sync: boolean }): Language {\n const symbolNames = Object.keys(mod);\n const functionName = symbolNames.find((key) => LANGUAGE_FUNCTION_REGEX.test(key) &&\n !key.includes('external_scanner_'));\n if (!functionName) {\n console.log(`Couldn't find language function in Wasm file. Symbols:\\n${JSON.stringify(symbolNames, null, 2)}`);\n throw new Error(`Language.${sync ? 'loadSync' : 'load'} failed: no language function found in Wasm file`);\n }\n const languageAddress = mod[functionName]();\n return new Language(INTERNAL, languageAddress);\n }\n\n /**\n * Load a language synchronously from a pre-compiled WebAssembly module.\n * Use this when the host environment provides a `WebAssembly.Module` directly.\n */\n static loadSync(wasmModule: WebAssembly.Module): Language {\n const mod = C.loadWebAssemblyModule(wasmModule, { loadAsync: false });\n return Language.loadFromWasmExports(mod, { sync: true });\n }\n}\n", "import type { MainModule } from '../lib/web-tree-sitter';\n\n/**\n * Options for {@link createModule}, a subset of Emscripten's module options.\n */\nexport interface ModuleOptions {\n /** Maps the runtime's file name to its URL or path. */\n locateFile?: (path: string, scriptDirectory: string) => string;\n /** The runtime's bytes, or a compiled module, instead of fetching it. */\n wasmBinary?: ArrayBufferView | ArrayBuffer | WebAssembly.Module;\n}\n\ntype Exports = Record<string, unknown> & {\n memory: WebAssembly.Memory;\n __indirect_function_table: WebAssembly.Table;\n __stack_pointer: WebAssembly.Global;\n _initialize: () => void;\n malloc: (size: number) => number;\n};\n\ntype SideExports = Record<string, unknown>;\n\n// wasi_snapshot_preview1 imports of the runtime. It has no files, clock or entropy:\n// file calls report a bad descriptor, anything else is unsupported, and exit traps.\nconst ERRNO_BADF = 8;\nconst ERRNO_NOSYS = 52;\nfunction wasiImports(module: WebAssembly.Module): Record<string, () => number> {\n const wasi: Record<string, () => number> = {};\n for (const { module: from, name } of WebAssembly.Module.imports(module)) {\n if (from !== 'wasi_snapshot_preview1') continue;\n if (name === 'proc_exit') {\n wasi[name] = () => { throw new Error('tree-sitter runtime exited'); };\n } else {\n wasi[name] = name.startsWith('fd_') ? () => ERRNO_BADF : () => ERRNO_NOSYS;\n }\n }\n return wasi;\n}\n\nconst utf8Decoder = new TextDecoder();\nconst utf8Encoder = new TextEncoder();\nconst INPUT_BUFFER_SIZE = 10 * 1024;\n\nfunction readLeb(bytes: Uint8Array, cursor: { at: number }): number {\n let result = 0;\n let shift = 0;\n let byte;\n do {\n byte = bytes[cursor.at++];\n result |= (byte & 0x7f) << shift;\n shift += 7;\n } while (byte & 0x80);\n return result >>> 0;\n}\n\n// The WASM_DYLINK_MEM_INFO subsection of a side module's `dylink.0` section.\nfunction dylinkInfo(module: WebAssembly.Module) {\n const info = { memorySize: 0, memoryAlign: 0, tableSize: 0, tableAlign: 0 };\n const sections = WebAssembly.Module.customSections(module, 'dylink.0');\n if (sections.length === 0) throw new Error('Language module has no dylink.0 section');\n const bytes = new Uint8Array(sections[0]);\n const cursor = { at: 0 };\n while (cursor.at < bytes.length) {\n const type = bytes[cursor.at++];\n const size = readLeb(bytes, cursor);\n const end = cursor.at + size;\n if (type === 1) {\n info.memorySize = readLeb(bytes, cursor);\n info.memoryAlign = readLeb(bytes, cursor);\n info.tableSize = readLeb(bytes, cursor);\n info.tableAlign = readLeb(bytes, cursor);\n }\n cursor.at = end;\n }\n return info;\n}\n\nasync function runtimeBytes(options: ModuleOptions): Promise<ArrayBufferView | ArrayBuffer | WebAssembly.Module> {\n if (options.wasmBinary) return options.wasmBinary;\n const base = new URL('.', import.meta.url).href;\n const location = options.locateFile?.('web-tree-sitter.wasm', base) ?? new URL('web-tree-sitter.wasm', import.meta.url).href;\n // Native paths preserve URL punctuation and resolve relative to Node's working directory.\n const isPath = /^[a-z]:/i.test(location) || !/^[a-z][a-z\\d+.-]*:/i.test(location);\n if (typeof process !== 'undefined' && process.versions.node && isPath) {\n const { readFile } = await import('fs/promises');\n return readFile(location);\n }\n const url = new URL(location, base);\n if (url.protocol === 'file:') {\n const { readFile } = await import('fs/promises');\n // The published bundle sits beside the runtime; the sources in src/ reach it in lib/.\n return readFile(url).catch((error: unknown) => {\n if (options.locateFile) throw error;\n return readFile(new URL('../lib/web-tree-sitter.wasm', import.meta.url));\n });\n }\n const response = await fetch(url);\n if (!response.ok) throw new Error(`Failed to load ${url.href}: ${response.status}`);\n return response.arrayBuffer();\n}\n\n/**\n * Instantiates the WASI-built runtime and returns the object the bindings call through,\n * shaped like the Emscripten module they were written against.\n */\nexport default async function createModule(options: ModuleOptions = {}): Promise<MainModule> {\n const module = {\n currentParseCallback: null,\n currentLogCallback: null,\n currentProgressCallback: null,\n currentQueryProgressCallback: null,\n } as unknown as MainModule & Record<string, unknown>;\n\n // Filled once the runtime is instantiated; the import callbacks run only after that.\n const runtime = { exports: undefined as unknown as Exports };\n let heapBuffer: ArrayBufferLike | null = null;\n let heap = new DataView(new ArrayBuffer(0));\n let heap8 = new Int8Array(0);\n let heapU8 = new Uint8Array(0);\n let heap16 = new Int16Array(0);\n let heap32 = new Int32Array(0);\n // Memory can grow during any call into the runtime, detaching earlier views.\n const refresh = () => {\n const buffer = runtime.exports.memory.buffer;\n if (buffer === heapBuffer) return;\n heapBuffer = buffer;\n heap = new DataView(buffer);\n heap8 = new Int8Array(buffer);\n heapU8 = new Uint8Array(buffer);\n heap16 = new Int16Array(buffer);\n heap32 = new Int32Array(buffer);\n };\n const bytes = () => {\n refresh();\n return heapU8;\n };\n\n // Typed-array reads, as Emscripten's getValue does: the bindings only pass aligned\n // addresses, and these calls are the hot path of query and node unmarshaling.\n const getValue = (ptr: number, type = 'i8'): number => {\n refresh();\n switch (type) {\n case 'i32': case '*': return heap32[ptr >> 2];\n case 'i16': return heap16[ptr >> 1];\n case 'i1':\n case 'i8': return heap8[ptr];\n case 'i64': return Number(heap.getBigInt64(ptr, true));\n case 'float': return heap.getFloat32(ptr, true);\n case 'double': return heap.getFloat64(ptr, true);\n default: throw new Error(`getValue: invalid type ${type}`);\n }\n };\n const setValue = (ptr: number, value: number, type = 'i8'): void => {\n refresh();\n switch (type) {\n case 'i32': case '*': heap32[ptr >> 2] = value; return;\n case 'i16': heap16[ptr >> 1] = value; return;\n case 'i1':\n case 'i8': heap8[ptr] = value; return;\n case 'i64': heap.setBigInt64(ptr, BigInt(value), true); return;\n case 'float': heap.setFloat32(ptr, value, true); return;\n case 'double': heap.setFloat64(ptr, value, true); return;\n default: throw new Error(`setValue: invalid type ${type}`);\n }\n };\n const UTF8ToString = (ptr: number, maxBytesToRead?: number, ignoreNul?: boolean): string => {\n if (!ptr) return '';\n const heapU8 = bytes();\n const limit = maxBytesToRead === undefined ? heapU8.length : Math.min(heapU8.length, ptr + maxBytesToRead);\n let end = ptr;\n if (ignoreNul) end = limit;\n else while (end < limit && heapU8[end]) end++;\n return utf8Decoder.decode(heapU8.subarray(ptr, end));\n };\n const AsciiToString = (ptr: number): string => {\n const heapU8 = bytes();\n let result = '';\n for (let at = ptr; heapU8[at]; at++) result += String.fromCharCode(heapU8[at]);\n return result;\n };\n const lengthBytesUTF8 = (str: string): number => utf8Encoder.encode(str).length;\n const stringToUTF8 = (str: string, outPtr: number, maxBytesToWrite: number): number => {\n if (maxBytesToWrite <= 0) return 0;\n const target = bytes().subarray(outPtr, outPtr + maxBytesToWrite - 1);\n const { written } = utf8Encoder.encodeInto(str, target);\n bytes()[outPtr + written] = 0;\n return written;\n };\n const stringToUTF16 = (str: string, outPtr: number, maxBytesToWrite = 0x7fffffff): number => {\n if (maxBytesToWrite < 2) return 0;\n const length = Math.min(str.length, (maxBytesToWrite - 2) >> 1);\n // wasm32 is little-endian, like every host that runs it, so a Uint16Array writes UTF-16LE.\n const units = new Uint16Array(bytes().buffer, outPtr, length + 1);\n for (let i = 0; i < length; i++) units[i] = str.charCodeAt(i);\n units[length] = 0;\n return 2 * length;\n };\n\n const imports = {\n env: {\n tree_sitter_parse_callback(inputBufferAddress: number, index: number, row: number, column: number, lengthAddress: number) {\n const text = module.currentParseCallback?.(index, { row, column });\n if (typeof text === 'string') {\n setValue(lengthAddress, text.length, 'i32');\n stringToUTF16(text, inputBufferAddress, INPUT_BUFFER_SIZE);\n } else {\n setValue(lengthAddress, 0, 'i32');\n }\n },\n tree_sitter_log_callback(isLexMessage: number, messageAddress: number) {\n module.currentLogCallback?.(UTF8ToString(messageAddress), isLexMessage !== 0);\n },\n // A progress callback returns true to cancel, although MainModule types it as void.\n tree_sitter_progress_callback(currentOffset: number, hasError: number) {\n const cancel = module.currentProgressCallback?.({ currentOffset, hasError: hasError !== 0 }) as unknown;\n return Number(!!cancel);\n },\n tree_sitter_query_progress_callback(currentOffset: number) {\n const cancel = module.currentQueryProgressCallback?.({ currentOffset }) as unknown;\n return Number(!!cancel);\n },\n },\n };\n\n const source = await runtimeBytes(options);\n const compiled = source instanceof WebAssembly.Module ? source : await WebAssembly.compile(source as BufferSource);\n const instance = await WebAssembly.instantiate(compiled, { ...imports, wasi_snapshot_preview1: wasiImports(compiled) });\n runtime.exports = instance.exports as unknown as Exports;\n const exports = runtime.exports;\n exports._initialize();\n\n // Links a grammar built as a dylink side module: its data goes in a block of the\n // runtime's heap, its functions in the runtime's table, and its libc imports\n // resolve to the runtime's exports.\n function link(wasmModule: WebAssembly.Module): SideExports {\n const info = dylinkInfo(wasmModule);\n const align = Math.max(2 ** info.memoryAlign, 16);\n const memoryBase = info.memorySize ? Math.ceil(exports.malloc(info.memorySize + align) / align) * align : 0;\n if (info.memorySize) bytes().fill(0, memoryBase, memoryBase + info.memorySize);\n const table = exports.__indirect_function_table;\n const tableBase = table.grow(info.tableSize);\n\n const env: Record<string, WebAssembly.ImportValue> = {\n memory: exports.memory,\n __indirect_function_table: table,\n __stack_pointer: exports.__stack_pointer,\n __memory_base: new WebAssembly.Global({ value: 'i32', mutable: false }, memoryBase),\n __table_base: new WebAssembly.Global({ value: 'i32', mutable: false }, tableBase),\n };\n // Addresses the module takes through its GOT, filled in once it has been instantiated.\n const memoryGot = new Map<string, WebAssembly.Global>();\n const functionGot = new Map<string, WebAssembly.Global>();\n const got = { 'GOT.mem': {} as Record<string, WebAssembly.Global>, 'GOT.func': {} as Record<string, WebAssembly.Global> };\n for (const { module: from, name, kind } of WebAssembly.Module.imports(wasmModule)) {\n if (from === 'env') {\n if (name in env) continue;\n if (kind !== 'function' || typeof exports[name] !== 'function') {\n throw new Error(`Language module imports ${name}, which the runtime does not provide`);\n }\n env[name] = exports[name];\n } else if (from === 'GOT.mem' || from === 'GOT.func') {\n const slot = new WebAssembly.Global({ value: 'i32', mutable: true }, 0);\n got[from][name] = slot;\n (from === 'GOT.mem' ? memoryGot : functionGot).set(name, slot);\n } else {\n throw new Error(`Language module imports ${from}.${name}, which the runtime does not provide`);\n }\n }\n\n const side = new WebAssembly.Instance(wasmModule, { env, ...got }).exports as SideExports;\n for (const [name, slot] of memoryGot) {\n const symbol = side[name];\n if (!(symbol instanceof WebAssembly.Global)) throw new Error(`Language module has no data symbol ${name}`);\n slot.value = memoryBase + (symbol.value as number);\n }\n for (const [name, slot] of functionGot) {\n const fn = side[name] ?? exports[name];\n if (typeof fn !== 'function') throw new Error(`Language module has no function ${name}`);\n const index = table.grow(1);\n table.set(index, fn);\n slot.value = index;\n }\n (side.__wasm_apply_data_relocs as (() => void) | undefined)?.();\n (side.__wasm_call_ctors as (() => void) | undefined)?.();\n return side;\n }\n\n function loadWebAssemblyModule(binary: Uint8Array | WebAssembly.Module, flags: { loadAsync: boolean }) {\n if (!flags.loadAsync) {\n return link(binary instanceof WebAssembly.Module ? binary : new WebAssembly.Module(binary as BufferSource));\n }\n const compiled = binary instanceof WebAssembly.Module ? Promise.resolve(binary) : WebAssembly.compile(binary as BufferSource);\n return compiled.then(link);\n }\n\n Object.assign(module, {\n getValue,\n setValue,\n UTF8ToString,\n AsciiToString,\n lengthBytesUTF8,\n stringToUTF8,\n stringToUTF16,\n loadWebAssemblyModule,\n });\n // Views over the current memory, which growth replaces.\n Object.defineProperty(module, 'HEAPU8', { get: bytes });\n for (const [name, value] of Object.entries(exports)) {\n if (typeof value === 'function') (module as Record<string, unknown>)[`_${name}`] = value;\n }\n return module;\n}\n", "import type { MainModule } from '../lib/web-tree-sitter';\nimport createModule, { type ModuleOptions } from './wasi-module';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type Parser } from './parser';\n\nexport let Module: MainModule | null = null;\nlet initialization: Promise<MainModule> | null = null;\n\n/**\n * @internal\n *\n * Initialize the Tree-sitter Wasm module. This should only be called by the {@link Parser} class via {@link Parser.init}.\n */\nexport async function initializeBinding(moduleOptions?: ModuleOptions): Promise<MainModule> {\n if (Module) return Module;\n initialization ??= createModule(moduleOptions).then((module) => {\n Module = module;\n return module;\n }).catch((error: unknown) => {\n initialization = null;\n throw error;\n });\n return initialization;\n}\n\n/**\n * @internal\n *\n * Checks if the Tree-sitter Wasm module has been initialized.\n */\nexport function checkModule(): boolean {\n return !!Module;\n}\n", "import { C } from './constants';\nimport { newFinalizer } from './finalization_registry';\n\nconst finalizer = newFinalizer((address: number) => {\n C._free(address);\n});\n\n// Code units decoded per String.fromCharCode call, below engines' argument limits.\nconst DECODE_CHUNK = 4096;\n\n/**\n * UTF-16 text kept in the parser's memory. {@link Parser#parse} reads it in place, and\n * {@link TextBuffer#edit} moves only the text after the edit, so a keystroke copies the\n * inserted characters instead of the whole document.\n *\n * Trees parsed from a buffer read their text from it, so they see later edits.\n */\nexport class TextBuffer {\n /** @internal */\n [0] = 0; // Address of the text\n\n /** @internal */\n private capacity = 0;\n\n /** The length of the text, in UTF-16 code units. */\n length = 0;\n\n constructor(text = '') {\n this.set(text);\n }\n\n /** Replace the whole text. */\n set(text: string): void {\n this.reserve(text.length);\n this.length = text.length;\n this.write(0, text);\n }\n\n /** Replace the code units in `[startIndex, oldEndIndex)` with `text`. */\n edit(startIndex: number, oldEndIndex: number, text: string): void {\n if (startIndex < 0 || oldEndIndex < startIndex || oldEndIndex > this.length) {\n throw new RangeError(`Invalid edit [${startIndex}, ${oldEndIndex}) of a buffer of length ${this.length}`);\n }\n const length = this.length + text.length - (oldEndIndex - startIndex);\n this.reserve(length);\n const units = this.units(Math.max(length, this.length));\n units.copyWithin(startIndex + text.length, oldEndIndex, this.length);\n this.length = length;\n this.write(startIndex, text);\n }\n\n /** The text in `[startIndex, endIndex)`. */\n slice(startIndex = 0, endIndex = this.length): string {\n const end = Math.min(endIndex, this.length);\n const units = this.units(this.length);\n let result = '';\n for (let at = startIndex; at < end; at += DECODE_CHUNK) {\n result += String.fromCharCode(...units.subarray(at, Math.min(end, at + DECODE_CHUNK)));\n }\n return result;\n }\n\n // The last chunk read decoded: node text for query predicates asks for many small\n // ranges near each other, and decoding a chunk per request dominated query time.\n private chunkStart = -1;\n private chunk = '';\n\n /** The text from `index` on, in chunks, for {@link Tree#textCallback}. */\n readonly read = (index: number): string => {\n const start = index - (index % DECODE_CHUNK);\n if (start !== this.chunkStart) {\n this.chunk = this.slice(start, Math.min(this.length, start + DECODE_CHUNK));\n this.chunkStart = start;\n }\n return this.chunk.slice(index - start);\n };\n\n /** Free the buffer's memory. */\n delete(): void {\n finalizer?.unregister(this);\n C._free(this[0]);\n this[0] = 0;\n this.capacity = 0;\n this.length = 0;\n }\n\n private units(length: number): Uint16Array {\n return new Uint16Array(C.HEAPU8.buffer, this[0], length);\n }\n\n private write(at: number, text: string): void {\n this.chunkStart = -1;\n const units = this.units(at + text.length);\n for (let i = 0; i < text.length; i++) units[at + i] = text.charCodeAt(i);\n }\n\n private reserve(length: number): void {\n if (length <= this.capacity && this[0]) return;\n const capacity = Math.max(length, this.capacity * 2, 64);\n const address = C._realloc(this[0], capacity * 2);\n if (!address) throw new Error(`Failed to allocate a text buffer of ${capacity} code units`);\n finalizer?.unregister(this);\n this[0] = address;\n this.capacity = capacity;\n finalizer?.register(this, address, this);\n }\n}\n", "import { C, INTERNAL, LogCallback, ParseCallback, Range, SIZE_OF_INT, SIZE_OF_RANGE, setModule } from './constants';\nimport { Language } from './language';\nimport { marshalRange, unmarshalRange } from './marshal';\nimport { checkModule, initializeBinding } from './bindings';\nimport type { ModuleOptions } from './wasi-module';\nimport { Tree } from './tree';\nimport { TextBuffer } from './text_buffer';\nimport { newFinalizer } from './finalization_registry';\n\n/**\n * Options for parsing\n *\n * The `includedRanges` property is an array of {@link Range} objects that\n * represent the ranges of text that the parser should include when parsing.\n *\n * The `progressCallback` property is a function that is called periodically\n * during parsing to check whether parsing should be cancelled.\n *\n * See {@link Parser#parse} for more information.\n */\nexport interface ParseOptions {\n /**\n * An array of {@link Range} objects that\n * represent the ranges of text that the parser should include when parsing.\n *\n * This sets the ranges of text that the parser should include when parsing.\n * By default, the parser will always include entire documents. This\n * function allows you to parse only a *portion* of a document but\n * still return a syntax tree whose ranges match up with the document\n * as a whole. You can also pass multiple disjoint ranges.\n * If `ranges` is empty, then the entire document will be parsed.\n * Otherwise, the given ranges must be ordered from earliest to latest\n * in the document, and they must not overlap. That is, the following\n * must hold for all `i` < `length - 1`:\n * ```text\n * ranges[i].end_byte <= ranges[i + 1].start_byte\n * ```\n */\n includedRanges?: Range[];\n\n /**\n * A function that is called periodically during parsing to check\n * whether parsing should be cancelled. If the progress callback returns\n * `true`, then parsing will be cancelled. You can also use this to instrument\n * parsing and check where the parser is at in the document. The progress callback\n * takes a single argument, which is a {@link ParseState} representing the current\n * state of the parser.\n */\n progressCallback?: (state: ParseState) => void;\n}\n\n/**\n * A stateful object that is passed into the progress callback {@link ParseOptions#progressCallback}\n * to provide the current state of the parser.\n */\nexport interface ParseState {\n /** The byte offset in the document that the parser is at. */\n currentOffset: number;\n\n /** Indicates whether the parser has encountered an error during parsing. */\n hasError: boolean;\n}\n\n/**\n * @internal\n *\n * Global variable for transferring data across the FFI boundary\n */\nexport let TRANSFER_BUFFER: number;\n\n/**\n * The latest ABI version that is supported by the current version of the\n * library.\n *\n * When Languages are generated by the Tree-sitter CLI, they are\n * assigned an ABI version number that corresponds to the current CLI version.\n * The Tree-sitter library is generally backwards-compatible with languages\n * generated using older CLI versions, but is not forwards-compatible.\n */\nexport let LANGUAGE_VERSION: number;\n\n/**\n * The earliest ABI version that is supported by the current version of the\n * library.\n */\nexport let MIN_COMPATIBLE_VERSION: number;\n\nconst finalizer = newFinalizer((addresses: number[]) => {\n C._ts_parser_delete(addresses[0]);\n C._free(addresses[1]);\n});\n\n/**\n * A stateful object that is used to produce a {@link Tree} based on some\n * source code.\n */\nexport class Parser {\n /** @internal */\n private [0] = 0; // Internal handle for Wasm\n\n /** @internal */\n private [1] = 0; // Internal handle for Wasm\n\n /** @internal */\n private logCallback: LogCallback | null = null;\n\n /** The parser's current language. */\n language: Language | null = null;\n\n /**\n * This must always be called before creating a Parser.\n *\n * You can optionally pass in options to configure the Wasm module, the most common\n * one being `locateFile` to help the module find the `.wasm` file.\n */\n static async init(moduleOptions?: ModuleOptions) {\n setModule(await initializeBinding(moduleOptions));\n TRANSFER_BUFFER = C._ts_init();\n LANGUAGE_VERSION = C.getValue(TRANSFER_BUFFER, 'i32');\n MIN_COMPATIBLE_VERSION = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, 'i32');\n }\n\n /**\n * Create a new parser.\n */\n constructor() {\n this.initialize();\n finalizer?.register(this, [this[0], this[1]], this);\n }\n\n /** @internal */\n initialize() {\n if (!checkModule()) {\n throw new Error(\"cannot construct a Parser before calling `init()`\");\n }\n C._ts_parser_new_wasm();\n this[0] = C.getValue(TRANSFER_BUFFER, 'i32');\n this[1] = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, 'i32');\n }\n\n /** Delete the parser, freeing its resources. */\n delete() {\n finalizer?.unregister(this);\n C._ts_parser_delete(this[0]);\n C._free(this[1]);\n this[0] = 0;\n this[1] = 0;\n }\n\n /**\n * Set the language that the parser should use for parsing.\n *\n * If the language was not successfully assigned, an error will be thrown.\n * This happens if the language was generated with an incompatible\n * version of the Tree-sitter CLI. Check the language's version using\n * {@link Language#version} and compare it to this library's\n * {@link LANGUAGE_VERSION} and {@link MIN_COMPATIBLE_VERSION} constants.\n */\n setLanguage(language: Language | null): this {\n let address: number;\n if (!language) {\n address = 0;\n this.language = null;\n } else if (language.constructor === Language) {\n address = language[0];\n const version = C._ts_language_abi_version(address);\n if (version < MIN_COMPATIBLE_VERSION || LANGUAGE_VERSION < version) {\n throw new Error(\n `Incompatible language version ${version}. ` +\n `Compatibility range ${MIN_COMPATIBLE_VERSION} through ${LANGUAGE_VERSION}.`\n );\n }\n this.language = language;\n } else {\n throw new Error('Argument must be a Language');\n }\n\n C._ts_parser_set_language(this[0], address);\n return this;\n }\n\n /**\n * Parse a slice of UTF8 text.\n *\n * @param {string | ParseCallback | TextBuffer} callback - The text to parse, a callback function, or a\n * {@link TextBuffer}, which is read in place.\n *\n * @param {Tree | null} [oldTree] - A previous syntax tree parsed from the same document. If the text of the\n * document has changed since `oldTree` was created, then you must edit `oldTree` to match\n * the new text using {@link Tree#edit}.\n *\n * @param {ParseOptions} [options] - Options for parsing the text.\n * This can be used to set the included ranges, or a progress callback.\n *\n * @returns {Tree | null} A {@link Tree} if parsing succeeded, or `null` if:\n * - The parser has not yet had a language assigned with {@link Parser#setLanguage}.\n * - The progress callback returned true.\n */\n parse(\n callback: string | ParseCallback | TextBuffer,\n oldTree?: Tree | null,\n options?: ParseOptions,\n ): Tree | null {\n if (callback instanceof TextBuffer) {\n C.currentParseCallback = callback.read;\n } else if (typeof callback === 'string') {\n C.currentParseCallback = (index: number) => callback.slice(index);\n } else if (typeof callback === 'function') {\n C.currentParseCallback = callback;\n } else {\n throw new Error('Argument must be a string or a function');\n }\n\n if (options?.progressCallback) {\n C.currentProgressCallback = options.progressCallback;\n } else {\n C.currentProgressCallback = null;\n }\n\n if (this.logCallback) {\n C.currentLogCallback = this.logCallback;\n C._ts_parser_enable_logger_wasm(this[0], 1);\n } else {\n C.currentLogCallback = null;\n C._ts_parser_enable_logger_wasm(this[0], 0);\n }\n\n let rangeCount = 0;\n let rangeAddress = 0;\n if (options?.includedRanges) {\n rangeCount = options.includedRanges.length;\n rangeAddress = C._calloc(rangeCount, SIZE_OF_RANGE);\n let address = rangeAddress;\n for (let i = 0; i < rangeCount; i++) {\n marshalRange(address, options.includedRanges[i]);\n address += SIZE_OF_RANGE;\n }\n }\n\n const treeAddress = callback instanceof TextBuffer\n ? C._ts_parser_parse_utf16_wasm(\n this[0],\n callback[0],\n callback.length * 2,\n oldTree ? oldTree[0] : 0,\n rangeAddress,\n rangeCount\n )\n : C._ts_parser_parse_wasm(\n this[0],\n this[1],\n oldTree ? oldTree[0] : 0,\n rangeAddress,\n rangeCount\n );\n\n if (!treeAddress) {\n C.currentParseCallback = null;\n C.currentLogCallback = null;\n C.currentProgressCallback = null;\n return null;\n }\n\n if (!this.language) {\n throw new Error('Parser must have a language to parse');\n }\n\n const result = new Tree(INTERNAL, treeAddress, this.language, C.currentParseCallback);\n C.currentParseCallback = null;\n C.currentLogCallback = null;\n C.currentProgressCallback = null;\n return result;\n }\n\n /**\n * Instruct the parser to start the next parse from the beginning.\n *\n * If the parser previously failed because of a callback, \n * then by default, it will resume where it left off on the\n * next call to {@link Parser#parse} or other parsing functions.\n * If you don't want to resume, and instead intend to use this parser to\n * parse some other document, you must call `reset` first.\n */\n reset(): void {\n C._ts_parser_reset(this[0]);\n }\n\n /** Get the ranges of text that the parser will include when parsing. */\n getIncludedRanges(): Range[] {\n C._ts_parser_included_ranges_wasm(this[0]);\n const count = C.getValue(TRANSFER_BUFFER, 'i32');\n const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, 'i32');\n const result = new Array<Range>(count);\n\n if (count > 0) {\n let address = buffer;\n for (let i = 0; i < count; i++) {\n result[i] = unmarshalRange(address);\n address += SIZE_OF_RANGE;\n }\n C._free(buffer);\n }\n\n return result;\n }\n\n /** Set the logging callback that a parser should use during parsing. */\n setLogger(callback: LogCallback | boolean | null): this {\n if (!callback) {\n this.logCallback = null;\n } else if (typeof callback !== 'function') {\n throw new Error('Logger callback must be a function');\n } else {\n this.logCallback = callback;\n }\n return this;\n }\n\n /** Get the parser's current logger. */\n getLogger(): LogCallback | null {\n return this.logCallback;\n }\n}\n", "import { C } from './constants';\n\n/** The functions an extension module exports. */\nexport type ExtensionExports = Record<string, unknown>;\n\n/**\n * Load a C extension: a module built like a grammar (`-fPIC -shared`, no libc) that calls\n * tree-sitter's C API directly. It shares the parser's memory, so it can read trees and\n * languages by address (`tree[0]`, `language[0]`) with no copying. Its imports resolve to\n * the runtime's exports: the public C API and the libc functions grammars may use.\n *\n * Call {@link Parser.init} first.\n */\nexport async function loadExtension(binary: Uint8Array | WebAssembly.Module): Promise<ExtensionExports> {\n return C.loadWebAssemblyModule(binary, { loadAsync: true });\n}\n\n/** The parser's memory, for exchanging data with extensions. Growth replaces the view. */\nexport function heap(): Uint8Array {\n return C.HEAPU8;\n}\n", "import { Point, ZERO_POINT, SIZE_OF_INT, C } from './constants';\nimport { Node } from './node';\nimport { marshalNode, unmarshalCaptures } from './marshal';\nimport { TRANSFER_BUFFER } from './parser';\nimport { Language } from './language';\nimport { newFinalizer } from './finalization_registry';\n\nconst PREDICATE_STEP_TYPE_CAPTURE = 1;\n\nconst PREDICATE_STEP_TYPE_STRING = 2;\n\nconst QUERY_WORD_REGEX = /[\\w-]+/g;\n\n/**\n * Options for query execution\n */\nexport interface QueryOptions {\n /** The start position of the range to query */\n startPosition?: Point;\n\n /** The end position of the range to query */\n endPosition?: Point;\n\n /** The start position of the range to query Only the matches that are fully\n * contained within provided range will be returned.\n **/\n startContainingPosition?: Point;\n\n /** The end position of the range to query Only the matches that are fully\n * contained within provided range will be returned.\n **/\n endContainingPosition?: Point;\n\n /** The start index of the range to query */\n startIndex?: number;\n\n /** The end index of the range to query */\n endIndex?: number;\n\n /** The start index of the range to query Only the matches that are fully\n * contained within provided range will be returned.\n **/\n startContainingIndex?: number;\n\n /** The end index of the range to query Only the matches that are fully\n * contained within provided range will be returned.\n **/\n endContainingIndex?: number;\n\n /**\n * The maximum number of in-progress matches for this query.\n * The limit must be > 0 and <= 65536.\n */\n matchLimit?: number;\n\n /**\n * The maximum start depth for a query cursor.\n *\n * This prevents cursors from exploring children nodes at a certain depth.\n * Note if a pattern includes many children, then they will still be\n * checked.\n *\n * The zero max start depth value can be used as a special behavior and\n * it helps to destructure a subtree by staying on a node and using\n * captures for interested parts. Note that the zero max start depth\n * only limit a search depth for a pattern's root node but other nodes\n * that are parts of the pattern may be searched at any depth what\n * defined by the pattern structure.\n *\n * Set to `null` to remove the maximum start depth.\n */\n maxStartDepth?: number;\n\n /**\n * A function that will be called periodically during the execution of the query to check\n * if query execution should be cancelled. You can also use this to instrument query execution\n * and check where the query is at in the document. The progress callback takes a single argument,\n * which is a {@link QueryState} representing the current state of the query.\n */\n progressCallback?: (state: QueryState) => void;\n}\n\n/**\n * A stateful object that is passed into the progress callback {@link QueryOptions#progressCallback}\n * to provide the current state of the query.\n */\nexport interface QueryState {\n /** The byte offset in the document that the query is at. */\n currentOffset: number;\n}\n\n/** A record of key-value pairs associated with a particular pattern in a {@link Query}. */\nexport type QueryProperties = Record<string, string | null>;\n\n/**\n * A predicate that contains an operator and list of operands.\n */\nexport interface QueryPredicate {\n /** The operator of the predicate, like `match?`, `eq?`, `set!`, etc. */\n operator: string;\n\n /** The operands of the predicate, which are either captures or strings. */\n operands: PredicateStep[];\n}\n\n/**\n * A particular {@link Node} that has been captured with a particular name within a\n * {@link Query}.\n */\nexport interface QueryCapture {\n /** The index of the pattern that matched. */\n patternIndex: number;\n\n /** The name of the capture */\n name: string;\n\n /** The captured node */\n node: Node;\n\n /** The properties for predicates declared with the operator `set!`. */\n setProperties?: QueryProperties;\n\n /** The properties for predicates declared with the operator `is?`. */\n assertedProperties?: QueryProperties;\n\n /** The properties for predicates declared with the operator `is-not?`. */\n refutedProperties?: QueryProperties;\n}\n\n/** A match of a {@link Query} to a particular set of {@link Node}s. */\nexport interface QueryMatch {\n /** The index of the pattern that matched. */\n patternIndex: number;\n\n /** The captures associated with the match. */\n captures: QueryCapture[];\n\n /** The properties for predicates declared with the operator `set!`. */\n setProperties?: QueryProperties;\n\n /** The properties for predicates declared with the operator `is?`. */\n assertedProperties?: QueryProperties;\n\n /** The properties for predicates declared with the operator `is-not?`. */\n refutedProperties?: QueryProperties;\n}\n\n/** A quantifier for captures */\nexport const CaptureQuantifier = {\n Zero: 0,\n ZeroOrOne: 1,\n ZeroOrMore: 2,\n One: 3,\n OneOrMore: 4\n} as const;\n\n/** A quantifier for captures */\nexport type CaptureQuantifier = typeof CaptureQuantifier[keyof typeof CaptureQuantifier];\n\n/**\n * Predicates are represented as a single array of steps. There are two\n * types of steps, which correspond to the two legal values for\n * the `type` field:\n *\n * - `CapturePredicateStep` - Steps with this type represent names\n * of captures.\n *\n * - `StringPredicateStep` - Steps with this type represent literal\n * strings.\n */\nexport type PredicateStep = CapturePredicateStep | StringPredicateStep;\n\n/**\n * A step in a predicate that refers to a capture.\n *\n * The `name` field is the name of the capture.\n */\nexport interface CapturePredicateStep { type: 'capture', name: string }\n\n/**\n * A step in a predicate that refers to a string.\n *\n * The `value` field is the string value.\n */\nexport interface StringPredicateStep { type: 'string', value: string }\n\nconst isCaptureStep = (step: PredicateStep): step is Extract<PredicateStep, { type: 'capture' }> =>\n step.type === 'capture';\n\nconst isStringStep = (step: PredicateStep): step is Extract<PredicateStep, { type: 'string' }> =>\n step.type === 'string';\n\n/**\n * @internal\n *\n * A function that checks if a given set of captures matches a particular\n * condition. This is used in the built-in `eq?`, `match?`, and `any-of?`\n * predicates.\n */\nexport type TextPredicate = (captures: QueryCapture[]) => boolean;\n\n/** Error codes returned from tree-sitter query parsing */\nexport const QueryErrorKind = {\n Syntax: 1,\n NodeName: 2,\n FieldName: 3,\n CaptureName: 4,\n PatternStructure: 5,\n} as const;\n\n/** An error that occurred while parsing a query string. */\nexport type QueryErrorKind = typeof QueryErrorKind[keyof typeof QueryErrorKind];\n\n/** Information about a {@link QueryError}. */\nexport interface QueryErrorInfo {\n [QueryErrorKind.NodeName]: { word: string };\n [QueryErrorKind.FieldName]: { word: string };\n [QueryErrorKind.CaptureName]: { word: string };\n [QueryErrorKind.PatternStructure]: { suffix: string };\n [QueryErrorKind.Syntax]: { suffix: string };\n}\n\n/** Error thrown when parsing a tree-sitter query fails */\nexport class QueryError extends Error {\n constructor(\n public kind: QueryErrorKind,\n public info: QueryErrorInfo[typeof kind],\n public index: number,\n public length: number\n ) {\n super(QueryError.formatMessage(kind, info));\n this.name = 'QueryError';\n }\n\n /** Formats an error message based on the error kind and info */\n private static formatMessage(kind: QueryErrorKind, info: QueryErrorInfo[QueryErrorKind]): string {\n switch (kind) {\n case QueryErrorKind.NodeName:\n return `Bad node name '${(info as QueryErrorInfo[2]).word}'`;\n case QueryErrorKind.FieldName:\n return `Bad field name '${(info as QueryErrorInfo[3]).word}'`;\n case QueryErrorKind.CaptureName:\n return `Bad capture name @${(info as QueryErrorInfo[4]).word}`;\n case QueryErrorKind.PatternStructure:\n return `Bad pattern structure at offset ${(info as QueryErrorInfo[5]).suffix}`;\n case QueryErrorKind.Syntax:\n return `Bad syntax at offset ${(info as QueryErrorInfo[1]).suffix}`;\n }\n }\n}\n\n/**\n * Parses the `eq?` and `not-eq?` predicates in a query, and updates the text predicates.\n */\nfunction parseAnyPredicate(\n steps: PredicateStep[],\n index: number,\n operator: string,\n textPredicates: TextPredicate[][],\n) {\n if (steps.length !== 3) {\n throw new Error(\n `Wrong number of arguments to \\`#${operator}\\` predicate. Expected 2, got ${steps.length - 1}`\n );\n }\n\n if (!isCaptureStep(steps[1])) {\n throw new Error(\n `First argument of \\`#${operator}\\` predicate must be a capture. Got \"${steps[1].value}\"`\n );\n }\n\n const isPositive = operator === 'eq?' || operator === 'any-eq?';\n const matchAll = !operator.startsWith('any-');\n\n if (isCaptureStep(steps[2])) {\n const captureName1 = steps[1].name;\n const captureName2 = steps[2].name;\n textPredicates[index].push((captures) => {\n const nodes1: Node[] = [];\n const nodes2: Node[] = [];\n for (const c of captures) {\n if (c.name === captureName1) nodes1.push(c.node);\n if (c.name === captureName2) nodes2.push(c.node);\n }\n const compare = (n1: { text: string }, n2: { text: string }, positive: boolean) => {\n return positive ? n1.text === n2.text : n1.text !== n2.text;\n };\n return matchAll\n ? nodes1.every((n1) => nodes2.some((n2) => compare(n1, n2, isPositive)))\n : nodes1.some((n1) => nodes2.some((n2) => compare(n1, n2, isPositive)));\n });\n } else {\n const captureName = steps[1].name;\n const stringValue = steps[2].value;\n const matches = (n: Node) => n.text === stringValue;\n const doesNotMatch = (n: Node) => n.text !== stringValue;\n textPredicates[index].push((captures) => {\n const nodes = [];\n for (const c of captures) {\n if (c.name === captureName) nodes.push(c.node);\n }\n const test = isPositive ? matches : doesNotMatch;\n return matchAll ? nodes.every(test) : nodes.some(test);\n });\n }\n}\n\n/**\n * Parses the `match?` and `not-match?` predicates in a query, and updates the text predicates.\n */\nfunction parseMatchPredicate(\n steps: PredicateStep[],\n index: number,\n operator: string,\n textPredicates: TextPredicate[][],\n) {\n if (steps.length !== 3) {\n throw new Error(\n `Wrong number of arguments to \\`#${operator}\\` predicate. Expected 2, got ${steps.length - 1}.`,\n );\n }\n\n if (steps[1].type !== 'capture') {\n throw new Error(\n `First argument of \\`#${operator}\\` predicate must be a capture. Got \"${steps[1].value}\".`,\n );\n }\n\n if (steps[2].type !== 'string') {\n throw new Error(\n `Second argument of \\`#${operator}\\` predicate must be a string. Got @${steps[2].name}.`,\n );\n }\n\n const isPositive = operator === 'match?' || operator === 'any-match?';\n const matchAll = !operator.startsWith('any-');\n const captureName = steps[1].name;\n const regex = new RegExp(steps[2].value);\n textPredicates[index].push((captures) => {\n const nodes = [];\n for (const c of captures) {\n if (c.name === captureName) nodes.push(c.node.text);\n }\n const test = (text: string, positive: boolean) => {\n return positive ?\n regex.test(text) :\n !regex.test(text);\n };\n if (nodes.length === 0) return !isPositive;\n return matchAll ?\n nodes.every((text) => test(text, isPositive)) :\n nodes.some((text) => test(text, isPositive));\n });\n}\n\n/**\n * Parses the `any-of?` and `not-any-of?` predicates in a query, and updates the text predicates.\n */\nfunction parseAnyOfPredicate(\n steps: PredicateStep[],\n index: number,\n operator: string,\n textPredicates: TextPredicate[][],\n) {\n if (steps.length < 2) {\n throw new Error(\n `Wrong number of arguments to \\`#${operator}\\` predicate. Expected at least 1. Got ${steps.length - 1}.`,\n );\n }\n\n if (steps[1].type !== 'capture') {\n throw new Error(\n `First argument of \\`#${operator}\\` predicate must be a capture. Got \"${steps[1].value}\".`,\n );\n }\n\n const isPositive = operator === 'any-of?';\n const captureName = steps[1].name;\n\n const stringSteps = steps.slice(2);\n if (!stringSteps.every(isStringStep)) {\n throw new Error(\n `Arguments to \\`#${operator}\\` predicate must be strings.\".`,\n );\n }\n const values = stringSteps.map((s) => s.value);\n\n textPredicates[index].push((captures) => {\n const nodes = [];\n for (const c of captures) {\n if (c.name === captureName) nodes.push(c.node.text);\n }\n if (nodes.length === 0) return !isPositive;\n return nodes.every((text) => values.includes(text)) === isPositive;\n });\n}\n\n/**\n * Parses the `is?` and `is-not?` predicates in a query, and updates the asserted or refuted properties,\n * depending on if the operator is positive or negative.\n */\nfunction parseIsPredicate(\n steps: PredicateStep[],\n index: number,\n operator: string,\n assertedProperties: QueryProperties[],\n refutedProperties: QueryProperties[],\n) {\n if (steps.length < 2 || steps.length > 3) {\n throw new Error(\n `Wrong number of arguments to \\`#${operator}\\` predicate. Expected 1 or 2. Got ${steps.length - 1}.`,\n );\n }\n\n if (!steps.every(isStringStep)) {\n throw new Error(\n `Arguments to \\`#${operator}\\` predicate must be strings.\".`,\n );\n }\n\n const properties = operator === 'is?' ? assertedProperties : refutedProperties;\n if (!properties[index]) properties[index] = {};\n properties[index][steps[1].value] = steps[2]?.value ?? null;\n}\n\n/**\n * Parses the `set!` directive in a query, and updates the set properties.\n */\nfunction parseSetDirective(\n steps: PredicateStep[],\n index: number,\n setProperties: QueryProperties[],\n) {\n if (steps.length < 2 || steps.length > 3) {\n throw new Error(`Wrong number of arguments to \\`#set!\\` predicate. Expected 1 or 2. Got ${steps.length - 1}.`);\n }\n if (!steps.every(isStringStep)) {\n throw new Error(`Arguments to \\`#set!\\` predicate must be strings.\".`);\n }\n if (!setProperties[index]) setProperties[index] = {};\n setProperties[index][steps[1].value] = steps[2]?.value ?? null;\n}\n\n/**\n * Parses the predicate at a given step in a pattern, and updates the appropriate\n * predicates or properties.\n */\nfunction parsePattern(\n index: number,\n stepType: number,\n stepValueId: number,\n captureNames: string[],\n stringValues: string[],\n steps: PredicateStep[],\n textPredicates: TextPredicate[][],\n predicates: QueryPredicate[][],\n setProperties: QueryProperties[],\n assertedProperties: QueryProperties[],\n refutedProperties: QueryProperties[],\n) {\n if (stepType === PREDICATE_STEP_TYPE_CAPTURE) {\n const name = captureNames[stepValueId];\n steps.push({ type: 'capture', name });\n } else if (stepType === PREDICATE_STEP_TYPE_STRING) {\n steps.push({ type: 'string', value: stringValues[stepValueId] });\n } else if (steps.length > 0) {\n if (steps[0].type !== 'string') {\n throw new Error('Predicates must begin with a literal value');\n }\n\n const operator = steps[0].value;\n switch (operator) {\n case 'any-not-eq?':\n case 'not-eq?':\n case 'any-eq?':\n case 'eq?':\n parseAnyPredicate(steps, index, operator, textPredicates);\n break;\n\n case 'any-not-match?':\n case 'not-match?':\n case 'any-match?':\n case 'match?':\n parseMatchPredicate(steps, index, operator, textPredicates);\n break;\n\n case 'not-any-of?':\n case 'any-of?':\n parseAnyOfPredicate(steps, index, operator, textPredicates);\n break;\n\n case 'is?':\n case 'is-not?':\n parseIsPredicate(steps, index, operator, assertedProperties, refutedProperties);\n break;\n\n case 'set!':\n parseSetDirective(steps, index, setProperties);\n break;\n\n default:\n predicates[index].push({ operator, operands: steps.slice(1) });\n }\n\n steps.length = 0;\n }\n}\n\nconst finalizer = newFinalizer((address: number) => {\n C._ts_query_delete(address);\n});\n\nexport class Query {\n /** @internal */\n private [0] = 0; // Internal handle for Wasm\n\n /** @internal */\n private exceededMatchLimit: boolean;\n\n /** @internal */\n private textPredicates: TextPredicate[][];\n\n /** The names of the captures used in the query. */\n readonly captureNames: string[];\n\n /** The quantifiers of the captures used in the query. */\n readonly captureQuantifiers: CaptureQuantifier[][];\n\n /**\n * The other user-defined predicates associated with the given index.\n *\n * This includes predicates with operators other than:\n * - `match?`\n * - `eq?` and `not-eq?`\n * - `any-of?` and `not-any-of?`\n * - `is?` and `is-not?`\n * - `set!`\n */\n readonly predicates: QueryPredicate[][];\n\n /** The properties for predicates with the operator `set!`. */\n readonly setProperties: QueryProperties[];\n\n /** The properties for predicates with the operator `is?`. */\n readonly assertedProperties: QueryProperties[];\n\n /** The properties for predicates with the operator `is-not?`. */\n readonly refutedProperties: QueryProperties[];\n\n /** The maximum number of in-progress matches for this cursor. */\n matchLimit?: number;\n\n /**\n * Create a new query from a string containing one or more S-expression\n * patterns.\n *\n * The query is associated with a particular language, and can only be run\n * on syntax nodes parsed with that language. References to Queries can be\n * shared between multiple threads.\n *\n * @link {@see https://tree-sitter.github.io/tree-sitter/using-parsers/queries}\n */\n constructor(language: Language, source: string) {\n const sourceLength = C.lengthBytesUTF8(source);\n const sourceAddress = C._malloc(sourceLength + 1);\n C.stringToUTF8(source, sourceAddress, sourceLength + 1);\n const address = C._ts_query_new(\n language[0],\n sourceAddress,\n sourceLength,\n TRANSFER_BUFFER,\n TRANSFER_BUFFER + SIZE_OF_INT\n );\n\n if (!address) {\n const errorId = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, 'i32') as QueryErrorKind;\n const errorByte = C.getValue(TRANSFER_BUFFER, 'i32');\n const errorIndex = C.UTF8ToString(sourceAddress, errorByte).length;\n const suffix = source.slice(errorIndex, errorIndex + 100).split('\\n')[0];\n const word = suffix.match(QUERY_WORD_REGEX)?.[0] ?? '';\n C._free(sourceAddress);\n\n switch (errorId) {\n case QueryErrorKind.Syntax:\n throw new QueryError(QueryErrorKind.Syntax, { suffix: `${errorIndex}: '${suffix}'...` }, errorIndex, 0);\n case QueryErrorKind.NodeName:\n throw new QueryError(errorId, { word }, errorIndex, word.length);\n case QueryErrorKind.FieldName:\n throw new QueryError(errorId, { word }, errorIndex, word.length);\n case QueryErrorKind.CaptureName:\n throw new QueryError(errorId, { word }, errorIndex, word.length);\n case QueryErrorKind.PatternStructure:\n throw new QueryError(errorId, { suffix: `${errorIndex}: '${suffix}'...` }, errorIndex, 0);\n }\n }\n\n const stringCount = C._ts_query_string_count(address);\n const captureCount = C._ts_query_capture_count(address);\n const patternCount = C._ts_query_pattern_count(address);\n const captureNames = new Array<string>(captureCount);\n const captureQuantifiers = new Array<CaptureQuantifier[]>(patternCount);\n const stringValues = new Array<string>(stringCount);\n\n // Fill in the capture names\n for (let i = 0; i < captureCount; i++) {\n const nameAddress = C._ts_query_capture_name_for_id(\n address,\n i,\n TRANSFER_BUFFER\n );\n const nameLength = C.getValue(TRANSFER_BUFFER, 'i32');\n captureNames[i] = C.UTF8ToString(nameAddress, nameLength);\n }\n\n // Fill in the capture quantifiers\n for (let i = 0; i < patternCount; i++) {\n const captureQuantifiersArray = new Array<CaptureQuantifier>(captureCount);\n for (let j = 0; j < captureCount; j++) {\n const quantifier = C._ts_query_capture_quantifier_for_id(address, i, j);\n captureQuantifiersArray[j] = quantifier as CaptureQuantifier;\n }\n captureQuantifiers[i] = captureQuantifiersArray;\n }\n\n // Fill in the string values\n for (let i = 0; i < stringCount; i++) {\n const valueAddress = C._ts_query_string_value_for_id(\n address,\n i,\n TRANSFER_BUFFER\n );\n const nameLength = C.getValue(TRANSFER_BUFFER, 'i32');\n stringValues[i] = C.UTF8ToString(valueAddress, nameLength);\n }\n\n const setProperties = new Array<QueryProperties>(patternCount);\n const assertedProperties = new Array<QueryProperties>(patternCount);\n const refutedProperties = new Array<QueryProperties>(patternCount);\n const predicates = new Array<QueryPredicate[]>(patternCount);\n const textPredicates = new Array<TextPredicate[]>(patternCount);\n\n // Parse the predicates, and add the appropriate predicates or properties\n for (let i = 0; i < patternCount; i++) {\n const predicatesAddress = C._ts_query_predicates_for_pattern(address, i, TRANSFER_BUFFER);\n const stepCount = C.getValue(TRANSFER_BUFFER, 'i32');\n\n predicates[i] = [];\n textPredicates[i] = [];\n\n const steps = new Array<PredicateStep>();\n\n let stepAddress = predicatesAddress;\n for (let j = 0; j < stepCount; j++) {\n const stepType = C.getValue(stepAddress, 'i32');\n stepAddress += SIZE_OF_INT;\n\n const stepValueId = C.getValue(stepAddress, 'i32');\n stepAddress += SIZE_OF_INT;\n\n parsePattern(\n i,\n stepType,\n stepValueId,\n captureNames,\n stringValues,\n steps,\n textPredicates,\n predicates,\n setProperties,\n assertedProperties,\n refutedProperties,\n );\n }\n\n Object.freeze(textPredicates[i]);\n Object.freeze(predicates[i]);\n Object.freeze(setProperties[i]);\n Object.freeze(assertedProperties[i]);\n Object.freeze(refutedProperties[i]);\n }\n\n C._free(sourceAddress);\n\n\n this[0] = address;\n this.captureNames = captureNames;\n this.captureQuantifiers = captureQuantifiers;\n this.textPredicates = textPredicates;\n this.predicates = predicates;\n this.setProperties = setProperties;\n this.assertedProperties = assertedProperties;\n this.refutedProperties = refutedProperties;\n this.exceededMatchLimit = false;\n finalizer?.register(this, address, this);\n }\n\n /** Delete the query, freeing its resources. */\n delete(): void {\n finalizer?.unregister(this);\n C._ts_query_delete(this[0]);\n this[0] = 0;\n }\n\n /**\n * Iterate over all of the matches in the order that they were found.\n *\n * Each match contains the index of the pattern that matched, and a list of\n * captures. Because multiple patterns can match the same set of nodes,\n * one match may contain captures that appear *before* some of the\n * captures from a previous match.\n *\n * @param {Node} node - The node to execute the query on.\n *\n * @param {QueryOptions} options - Options for query execution.\n */\n matches(\n node: Node,\n options: QueryOptions = {}\n ): QueryMatch[] {\n const startPosition = options.startPosition ?? ZERO_POINT;\n const endPosition = options.endPosition ?? ZERO_POINT;\n const startIndex = options.startIndex ?? 0;\n const endIndex = options.endIndex ?? 0;\n const startContainingPosition = options.startContainingPosition ?? ZERO_POINT;\n const endContainingPosition = options.endContainingPosition ?? ZERO_POINT;\n const startContainingIndex = options.startContainingIndex ?? 0;\n const endContainingIndex = options.endContainingIndex ?? 0;\n const matchLimit = options.matchLimit ?? 0xFFFFFFFF;\n const maxStartDepth = options.maxStartDepth ?? 0xFFFFFFFF;\n const progressCallback = options.progressCallback;\n\n if (typeof matchLimit !== 'number') {\n throw new Error('Arguments must be numbers');\n }\n this.matchLimit = matchLimit;\n\n if (endIndex !== 0 && startIndex > endIndex) {\n throw new Error('`startIndex` cannot be greater than `endIndex`');\n }\n\n if (endPosition !== ZERO_POINT && (\n startPosition.row > endPosition.row ||\n (startPosition.row === endPosition.row && startPosition.column > endPosition.column)\n )) {\n throw new Error('`startPosition` cannot be greater than `endPosition`');\n }\n\n if (endContainingIndex !== 0 && startContainingIndex > endContainingIndex) {\n throw new Error('`startContainingIndex` cannot be greater than `endContainingIndex`');\n }\n\n if (endContainingPosition !== ZERO_POINT && (\n startContainingPosition.row > endContainingPosition.row ||\n (startContainingPosition.row === endContainingPosition.row &&\n startContainingPosition.column > endContainingPosition.column)\n )) {\n throw new Error('`startContainingPosition` cannot be greater than `endContainingPosition`');\n }\n\n if (progressCallback) {\n C.currentQueryProgressCallback = progressCallback;\n }\n\n marshalNode(node);\n\n C._ts_query_matches_wasm(\n this[0],\n node.tree[0],\n startPosition.row,\n startPosition.column,\n endPosition.row,\n endPosition.column,\n startIndex,\n endIndex,\n startContainingPosition.row,\n startContainingPosition.column,\n endContainingPosition.row,\n endContainingPosition.column,\n startContainingIndex,\n endContainingIndex,\n matchLimit,\n maxStartDepth,\n );\n\n const rawCount = C.getValue(TRANSFER_BUFFER, 'i32');\n const startAddress = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, 'i32');\n const didExceedMatchLimit = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, 'i32');\n const result = new Array<QueryMatch>(rawCount);\n this.exceededMatchLimit = Boolean(didExceedMatchLimit);\n\n let filteredCount = 0;\n let address = startAddress;\n for (let i = 0; i < rawCount; i++) {\n const patternIndex = C.getValue(address, 'i32');\n address += SIZE_OF_INT;\n const captureCount = C.getValue(address, 'i32');\n address += SIZE_OF_INT;\n\n const captures = new Array<QueryCapture>(captureCount);\n address = unmarshalCaptures(this, node.tree, address, patternIndex, captures);\n\n if (this.textPredicates[patternIndex].every((p) => p(captures))) {\n result[filteredCount] = { patternIndex, captures };\n const setProperties = this.setProperties[patternIndex];\n result[filteredCount].setProperties = setProperties;\n const assertedProperties = this.assertedProperties[patternIndex];\n result[filteredCount].assertedProperties = assertedProperties;\n const refutedProperties = this.refutedProperties[patternIndex];\n result[filteredCount].refutedProperties = refutedProperties;\n filteredCount++;\n }\n }\n result.length = filteredCount;\n\n C._free(startAddress);\n C.currentQueryProgressCallback = null;\n return result;\n }\n\n /**\n * Iterate over all of the individual captures in the order that they\n * appear.\n *\n * This is useful if you don't care about which pattern matched, and just\n * want a single, ordered sequence of captures.\n *\n * @param {Node} node - The node to execute the query on.\n *\n * @param {QueryOptions} options - Options for query execution.\n */\n captures(\n node: Node,\n options: QueryOptions = {}\n ): QueryCapture[] {\n const startPosition = options.startPosition ?? ZERO_POINT;\n const endPosition = options.endPosition ?? ZERO_POINT;\n const startIndex = options.startIndex ?? 0;\n const endIndex = options.endIndex ?? 0;\n const startContainingPosition = options.startContainingPosition ?? ZERO_POINT;\n const endContainingPosition = options.endContainingPosition ?? ZERO_POINT;\n const startContainingIndex = options.startContainingIndex ?? 0;\n const endContainingIndex = options.endContainingIndex ?? 0;\n const matchLimit = options.matchLimit ?? 0xFFFFFFFF;\n const maxStartDepth = options.maxStartDepth ?? 0xFFFFFFFF;\n const progressCallback = options.progressCallback;\n\n if (typeof matchLimit !== 'number') {\n throw new Error('Arguments must be numbers');\n }\n this.matchLimit = matchLimit;\n\n if (endIndex !== 0 && startIndex > endIndex) {\n throw new Error('`startIndex` cannot be greater than `endIndex`');\n }\n\n if (endPosition !== ZERO_POINT && (\n startPosition.row > endPosition.row ||\n (startPosition.row === endPosition.row && startPosition.column > endPosition.column)\n )) {\n throw new Error('`startPosition` cannot be greater than `endPosition`');\n }\n\n if (endContainingIndex !== 0 && startContainingIndex > endContainingIndex) {\n throw new Error('`startContainingIndex` cannot be greater than `endContainingIndex`');\n }\n\n if (endContainingPosition !== ZERO_POINT && (\n startContainingPosition.row > endContainingPosition.row ||\n (startContainingPosition.row === endContainingPosition.row &&\n startContainingPosition.column > endContainingPosition.column)\n )) {\n throw new Error('`startContainingPosition` cannot be greater than `endContainingPosition`');\n }\n\n if (progressCallback) {\n C.currentQueryProgressCallback = progressCallback;\n }\n\n marshalNode(node);\n\n C._ts_query_captures_wasm(\n this[0],\n node.tree[0],\n startPosition.row,\n startPosition.column,\n endPosition.row,\n endPosition.column,\n startIndex,\n endIndex,\n startContainingPosition.row,\n startContainingPosition.column,\n endContainingPosition.row,\n endContainingPosition.column,\n startContainingIndex,\n endContainingIndex,\n matchLimit,\n maxStartDepth,\n );\n\n const count = C.getValue(TRANSFER_BUFFER, 'i32');\n const startAddress = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, 'i32');\n const didExceedMatchLimit = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, 'i32');\n const result = new Array<QueryCapture>();\n this.exceededMatchLimit = Boolean(didExceedMatchLimit);\n\n const captures = new Array<QueryCapture>();\n let address = startAddress;\n for (let i = 0; i < count; i++) {\n const patternIndex = C.getValue(address, 'i32');\n address += SIZE_OF_INT;\n const captureCount = C.getValue(address, 'i32');\n address += SIZE_OF_INT;\n const captureIndex = C.getValue(address, 'i32');\n address += SIZE_OF_INT;\n\n captures.length = captureCount;\n address = unmarshalCaptures(this, node.tree, address, patternIndex, captures);\n\n if (this.textPredicates[patternIndex].every(p => p(captures))) {\n const capture = captures[captureIndex];\n const setProperties = this.setProperties[patternIndex];\n capture.setProperties = setProperties;\n const assertedProperties = this.assertedProperties[patternIndex];\n capture.assertedProperties = assertedProperties;\n const refutedProperties = this.refutedProperties[patternIndex];\n capture.refutedProperties = refutedProperties;\n result.push(capture);\n }\n }\n\n C._free(startAddress);\n C.currentQueryProgressCallback = null;\n return result;\n }\n\n /** Get the predicates for a given pattern. */\n predicatesForPattern(patternIndex: number): QueryPredicate[] {\n return this.predicates[patternIndex];\n }\n\n /**\n * Disable a certain capture within a query.\n *\n * This prevents the capture from being returned in matches, and also\n * avoids any resource usage associated with recording the capture.\n */\n disableCapture(captureName: string): void {\n const captureNameLength = C.lengthBytesUTF8(captureName);\n const captureNameAddress = C._malloc(captureNameLength + 1);\n C.stringToUTF8(captureName, captureNameAddress, captureNameLength + 1);\n C._ts_query_disable_capture(this[0], captureNameAddress, captureNameLength);\n C._free(captureNameAddress);\n }\n\n /**\n * Disable a certain pattern within a query.\n *\n * This prevents the pattern from matching, and also avoids any resource\n * usage associated with the pattern. This throws an error if the pattern\n * index is out of bounds.\n */\n disablePattern(patternIndex: number): void {\n if (patternIndex >= this.predicates.length) {\n throw new Error(\n `Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`\n );\n }\n C._ts_query_disable_pattern(this[0], patternIndex);\n }\n\n /**\n * Check if, on its last execution, this cursor exceeded its maximum number\n * of in-progress matches.\n */\n didExceedMatchLimit(): boolean {\n return this.exceededMatchLimit;\n }\n\n /** Get the byte offset where the given pattern starts in the query's source. */\n startIndexForPattern(patternIndex: number): number {\n if (patternIndex >= this.predicates.length) {\n throw new Error(\n `Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`\n );\n }\n return C._ts_query_start_byte_for_pattern(this[0], patternIndex);\n }\n\n /** Get the byte offset where the given pattern ends in the query's source. */\n endIndexForPattern(patternIndex: number): number {\n if (patternIndex >= this.predicates.length) {\n throw new Error(\n `Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`\n );\n }\n return C._ts_query_end_byte_for_pattern(this[0], patternIndex);\n }\n\n /** Get the number of patterns in the query. */\n patternCount(): number {\n return C._ts_query_pattern_count(this[0]);\n }\n\n /** Get the index for a given capture name. */\n captureIndexForName(captureName: string): number {\n return this.captureNames.indexOf(captureName);\n }\n\n /** Check if a given pattern within a query has a single root node. */\n isPatternRooted(patternIndex: number): boolean {\n return C._ts_query_is_pattern_rooted(this[0], patternIndex) === 1;\n }\n\n /** Check if a given pattern within a query has a single root node. */\n isPatternNonLocal(patternIndex: number): boolean {\n return C._ts_query_is_pattern_non_local(this[0], patternIndex) === 1;\n }\n\n /**\n * Check if a given step in a query is 'definite'.\n *\n * A query step is 'definite' if its parent pattern will be guaranteed to\n * match successfully once it reaches the step.\n */\n isPatternGuaranteedAtStep(byteIndex: number): boolean {\n return C._ts_query_is_pattern_guaranteed_at_step(this[0], byteIndex) === 1;\n }\n}\n"],
5
+ "mappings": ";;;;AAEO,IAAM,OAAN,MAAW;AAAA,EAFlB,OAEkB;AAAA;AAAA;AAAA;AAAA,EAEhB;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA,EAEA,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAOG;AACD,SAAK,aAAa,eAAe;AACjC,SAAK,cAAc,gBAAgB;AACnC,SAAK,cAAc,gBAAgB;AACnC,SAAK,gBAAgB;AACrB,SAAK,iBAAiB;AACtB,SAAK,iBAAiB;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,UAAU,OAAc,OAAgD;AACtE,QAAI,WAAW;AACf,UAAM,WAAW,EAAE,GAAG,MAAM;AAE5B,QAAI,SAAS,KAAK,aAAa;AAC7B,iBAAW,KAAK,eAAe,QAAQ,KAAK;AAC5C,YAAM,cAAc,MAAM;AAC1B,eAAS,MAAM,KAAK,eAAe,OAAO,MAAM,MAAM,KAAK,eAAe;AAC1E,eAAS,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GA,gBAAgB,cAA+B;AAC7C,WAAO,EAAE,4BAA4B,KAAK,CAAC,GAAG,YAAY,MAAM;AAAA,EAClE;AAAA;AAAA,EAGA,kBAAkB,cAA+B;AAC/C,WAAO,EAAE,+BAA+B,KAAK,CAAC,GAAG,YAAY,MAAM;AAAA,EACrE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,0BAA0B,WAA4B;AACpD,WAAO,EAAE,wCAAwC,KAAK,CAAC,GAAG,SAAS,MAAM;AAAA,EAC3E;AACF;",
6
+ "names": ["finalizer", "finalizer", "heap", "heapU8", "compiled", "finalizer", "finalizer", "finalizer"]
7
+ }
Binary file
package/package.json ADDED
@@ -0,0 +1,108 @@
1
+ {
2
+ "name": "@singapore-editor/tree-sitter-x",
3
+ "version": "0.28.0",
4
+ "description": "Tree-sitter-x WASI runtime for JavaScript, with shared text buffers and C extensions",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/ShaulLavo/tree-sitter-x.git",
8
+ "directory": "lib/binding_web"
9
+ },
10
+ "license": "MIT",
11
+ "author": {
12
+ "name": "Max Brunsfeld",
13
+ "email": "maxbrunsfeld@gmail.com"
14
+ },
15
+ "maintainers": [
16
+ {
17
+ "name": "Amaan Qureshi",
18
+ "email": "amaanq12@gmail.com"
19
+ }
20
+ ],
21
+ "type": "module",
22
+ "exports": {
23
+ ".": {
24
+ "import": {
25
+ "types": "./web-tree-sitter.d.ts",
26
+ "default": "./web-tree-sitter.js"
27
+ },
28
+ "require": {
29
+ "types": "./web-tree-sitter.d.cts",
30
+ "default": "./web-tree-sitter.cjs"
31
+ }
32
+ },
33
+ "./web-tree-sitter.wasm": "./web-tree-sitter.wasm",
34
+ "./debug": {
35
+ "import": {
36
+ "types": "./web-tree-sitter.d.ts",
37
+ "default": "./debug/web-tree-sitter.js"
38
+ },
39
+ "require": {
40
+ "types": "./web-tree-sitter.d.cts",
41
+ "default": "./debug/web-tree-sitter.cjs"
42
+ }
43
+ },
44
+ "./debug/web-tree-sitter.wasm": "./debug/web-tree-sitter.wasm"
45
+ },
46
+ "browser": {
47
+ "fs": false,
48
+ "fs/promises": false,
49
+ "module": false
50
+ },
51
+ "types": "web-tree-sitter.d.ts",
52
+ "keywords": [
53
+ "incremental",
54
+ "parsing",
55
+ "tree-sitter",
56
+ "wasm"
57
+ ],
58
+ "files": [
59
+ "web-tree-sitter.cjs",
60
+ "web-tree-sitter.cjs.map",
61
+ "web-tree-sitter.js",
62
+ "web-tree-sitter.js.map",
63
+ "web-tree-sitter.wasm",
64
+ "debug/web-tree-sitter.cjs",
65
+ "debug/web-tree-sitter.cjs.map",
66
+ "debug/web-tree-sitter.js",
67
+ "debug/web-tree-sitter.js.map",
68
+ "debug/web-tree-sitter.wasm",
69
+ "web-tree-sitter.d.ts",
70
+ "web-tree-sitter.d.ts.map",
71
+ "web-tree-sitter.d.cts",
72
+ "web-tree-sitter.d.cts.map"
73
+ ],
74
+ "devDependencies": {
75
+ "@eslint/js": "^9.39.1",
76
+ "@types/emscripten": "^1.41.6",
77
+ "@types/node": "^26.6.1",
78
+ "@vitest/coverage-v8": "^3.0.5",
79
+ "dts-buddy": "^0.8.3",
80
+ "esbuild": "^0.28.2",
81
+ "eslint": "^10.11.0",
82
+ "source-map": "^0.8.0",
83
+ "tsx": "^4.23.13",
84
+ "typescript": "^5.7.3",
85
+ "typescript-eslint": "^8.70.0",
86
+ "vitest": "^3.0.5",
87
+ "web-tree-sitter-upstream": "npm:web-tree-sitter@^0.27.0"
88
+ },
89
+ "scripts": {
90
+ "build:ts": "tsc -b . && node script/build.js",
91
+ "build:wasm": "cd ../../ && cargo xtask build-wasm",
92
+ "build:wasm:debug": "cd ../../ && cargo xtask build-wasm --debug",
93
+ "build": "npm run build:wasm && npm run build:ts",
94
+ "build:debug": "npm run build:wasm:debug && npm run build:ts -- --debug",
95
+ "build:dts": "node script/generate-dts.js",
96
+ "lint": "eslint src/*.ts script/*.ts test/*.ts",
97
+ "lint:fix": "eslint src/*.ts script/*.ts test/*.ts --fix",
98
+ "test": "vitest run",
99
+ "test:watch": "vitest",
100
+ "prepack": "cp ../../LICENSE .",
101
+ "postpack": "rm LICENSE",
102
+ "prepublishOnly": "tsx script/check-artifacts-fresh.ts"
103
+ },
104
+ "publishConfig": {
105
+ "access": "public",
106
+ "registry": "https://registry.npmjs.org/"
107
+ }
108
+ }