@kreuzberg/tree-sitter-language-pack 1.8.0 → 1.8.1
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.
- package/index.d.ts +155 -16
- package/package.json +11 -2
- package/ts-pack-core-node.darwin-arm64.node +0 -0
- package/ts-pack-core-node.linux-arm64-gnu.node +0 -0
- package/ts-pack-core-node.linux-x64-gnu.node +0 -0
- package/ts-pack-core-node.win32-arm64-msvc.node +0 -0
- package/ts-pack-core-node.win32-x64-msvc.node +0 -0
package/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// This file is auto-generated by alef — DO NOT EDIT.
|
|
2
|
-
// alef:hash:
|
|
2
|
+
// alef:hash:c0ee6526b4cf3c711d551e15e38d99f287ee84b2e323e9d57925ca62c77389e0
|
|
3
3
|
// To regenerate: alef generate
|
|
4
4
|
// To verify freshness: alef verify --exit-code
|
|
5
5
|
// Issues & docs: https://github.com/kreuzberg-dev/alef
|
|
6
6
|
/* eslint-disable */
|
|
7
|
+
import type { Language } from "tree-sitter";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* List all available language names (sorted, deduplicated, includes aliases).
|
|
@@ -243,17 +244,17 @@ export declare function getInjectionsQuery(language: string): string | undefined
|
|
|
243
244
|
*
|
|
244
245
|
* @example
|
|
245
246
|
* ```typescript
|
|
246
|
-
* use tree_sitter_language_pack::get_language;
|
|
247
|
+
* use tree_sitter_language_pack::{get_language, Parser};
|
|
247
248
|
*
|
|
248
|
-
* let
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
* parser.
|
|
252
|
-
* let tree = parser.parse("x = 1", None).unwrap();
|
|
249
|
+
* let _lang = get_language("python")?;
|
|
250
|
+
* let mut parser = Parser::new();
|
|
251
|
+
* parser.set_language("python")?;
|
|
252
|
+
* let tree = parser.parse("x = 1").expect("parse failed");
|
|
253
253
|
* assert_eq!(tree.root_node().kind(), "module");
|
|
254
|
+
* # Ok::<(), tree_sitter_language_pack::Error>(())
|
|
254
255
|
* ```typescript
|
|
255
256
|
*/
|
|
256
|
-
export declare function getLanguage(name: string):
|
|
257
|
+
export declare function getLanguage(name: string): Language;
|
|
257
258
|
|
|
258
259
|
/**
|
|
259
260
|
* Get the locals query for a language, if bundled.
|
|
@@ -273,7 +274,7 @@ export declare function getLanguage(name: string): JsLanguage;
|
|
|
273
274
|
export declare function getLocalsQuery(language: string): string | undefined | null;
|
|
274
275
|
|
|
275
276
|
/**
|
|
276
|
-
* Get a
|
|
277
|
+
* Get a [`Parser`] pre-configured for the given language.
|
|
277
278
|
*
|
|
278
279
|
* This is a convenience function that calls [`get_language`] and configures
|
|
279
280
|
* a new parser in one step.
|
|
@@ -284,9 +285,10 @@ export declare function getLocalsQuery(language: string): string | undefined | n
|
|
|
284
285
|
* ```typescript
|
|
285
286
|
* use tree_sitter_language_pack::get_parser;
|
|
286
287
|
*
|
|
287
|
-
* let mut parser = get_parser("rust")
|
|
288
|
-
* let tree = parser.parse("fn main() {}"
|
|
288
|
+
* let mut parser = get_parser("rust")?;
|
|
289
|
+
* let tree = parser.parse("fn main() {}").expect("parse failed");
|
|
289
290
|
* assert!(!tree.root_node().has_error());
|
|
291
|
+
* # Ok::<(), tree_sitter_language_pack::Error>(())
|
|
290
292
|
* ```typescript
|
|
291
293
|
*/
|
|
292
294
|
export declare function getParser(name: string): JsParser;
|
|
@@ -329,6 +331,14 @@ export declare function hasLanguage(name: string): boolean;
|
|
|
329
331
|
*/
|
|
330
332
|
export declare function init(config: JsPackConfig): void;
|
|
331
333
|
|
|
334
|
+
/** A byte range — start (inclusive) to end (exclusive). */
|
|
335
|
+
export interface JsByteRange {
|
|
336
|
+
/** Inclusive start byte offset. */
|
|
337
|
+
start: number;
|
|
338
|
+
/** Exclusive end byte offset. */
|
|
339
|
+
end: number;
|
|
340
|
+
}
|
|
341
|
+
|
|
332
342
|
/** Metadata for a single chunk of source code. */
|
|
333
343
|
export interface JsChunkContext {
|
|
334
344
|
language?: string;
|
|
@@ -499,8 +509,6 @@ export interface JsImportInfo {
|
|
|
499
509
|
span?: JsSpan;
|
|
500
510
|
}
|
|
501
511
|
|
|
502
|
-
export declare class JsLanguage {}
|
|
503
|
-
|
|
504
512
|
export interface JsLanguageInfo {
|
|
505
513
|
group: string;
|
|
506
514
|
size: number;
|
|
@@ -555,7 +563,7 @@ export declare class JsLanguageRegistry {
|
|
|
555
563
|
* @throws Returns [`Error::LanguageNotFound`] if the name (after alias resolution)
|
|
556
564
|
* does not match any known grammar.
|
|
557
565
|
*/
|
|
558
|
-
getLanguage(name: string):
|
|
566
|
+
getLanguage(name: string): Language;
|
|
559
567
|
/**
|
|
560
568
|
* List all available language names, sorted and deduplicated.
|
|
561
569
|
*
|
|
@@ -577,6 +585,61 @@ export declare class JsLanguageRegistry {
|
|
|
577
585
|
static default(): JsLanguageRegistry;
|
|
578
586
|
}
|
|
579
587
|
|
|
588
|
+
/**
|
|
589
|
+
* A single syntax node within a [`Tree`].
|
|
590
|
+
*
|
|
591
|
+
* Nodes hold a strong reference to their parent tree so they remain valid
|
|
592
|
+
* regardless of how the tree is moved or stored at the FFI boundary.
|
|
593
|
+
*/
|
|
594
|
+
export declare class JsNode {
|
|
595
|
+
clone(): JsNode;
|
|
596
|
+
/** Return the node's kind name (e.g. `"function_definition"`). */
|
|
597
|
+
kind(): string;
|
|
598
|
+
/** Return the node's numeric kind ID. */
|
|
599
|
+
kindId(): number;
|
|
600
|
+
/** Return the inclusive start byte offset of this node. */
|
|
601
|
+
startByte(): number;
|
|
602
|
+
/** Return the exclusive end byte offset of this node. */
|
|
603
|
+
endByte(): number;
|
|
604
|
+
/**
|
|
605
|
+
* Return the node's byte range as a [`ByteRange`].
|
|
606
|
+
*
|
|
607
|
+
* Callers should slice their own source bytes — this is a zero-copy
|
|
608
|
+
* text accessor.
|
|
609
|
+
*/
|
|
610
|
+
byteRange(): JsByteRange;
|
|
611
|
+
/** Return the start [`Point`] (row, column). */
|
|
612
|
+
startPosition(): JsPoint;
|
|
613
|
+
/** Return the end [`Point`] (row, column). */
|
|
614
|
+
endPosition(): JsPoint;
|
|
615
|
+
/** True when this node is named (not punctuation/whitespace). */
|
|
616
|
+
isNamed(): boolean;
|
|
617
|
+
/** True when this is an error node. */
|
|
618
|
+
isError(): boolean;
|
|
619
|
+
/** True when this is a missing-token node. */
|
|
620
|
+
isMissing(): boolean;
|
|
621
|
+
/** True when this is an "extra" node (e.g. a comment). */
|
|
622
|
+
isExtra(): boolean;
|
|
623
|
+
/** True when this node or any descendant is an error. */
|
|
624
|
+
hasError(): boolean;
|
|
625
|
+
/** Return this node's parent, if any. */
|
|
626
|
+
parent(): JsNode | undefined | null;
|
|
627
|
+
/** Return the i-th child of this node, if any. */
|
|
628
|
+
child(index: number): JsNode | undefined | null;
|
|
629
|
+
/** Total number of children (including unnamed). */
|
|
630
|
+
childCount(): number;
|
|
631
|
+
/** Return the i-th named child of this node, if any. */
|
|
632
|
+
namedChild(index: number): JsNode | undefined | null;
|
|
633
|
+
/** Number of named children of this node. */
|
|
634
|
+
namedChildCount(): number;
|
|
635
|
+
/** Look up a child by its grammar-defined field name. */
|
|
636
|
+
childByFieldName(name: string): JsNode | undefined | null;
|
|
637
|
+
/** Return the S-expression form of this node's subtree. */
|
|
638
|
+
toSexp(): string;
|
|
639
|
+
/** Return a [`TreeCursor`] positioned at this node. */
|
|
640
|
+
walk(): JsTreeCursor;
|
|
641
|
+
}
|
|
642
|
+
|
|
580
643
|
/**
|
|
581
644
|
* Configuration for the tree-sitter language pack.
|
|
582
645
|
*
|
|
@@ -611,7 +674,46 @@ export interface JsPackConfig {
|
|
|
611
674
|
groups?: Array<string>;
|
|
612
675
|
}
|
|
613
676
|
|
|
614
|
-
|
|
677
|
+
/**
|
|
678
|
+
* A tree-sitter parser configured for one language at a time.
|
|
679
|
+
* @example
|
|
680
|
+
* ```typescript
|
|
681
|
+
* use tree_sitter_language_pack::Parser;
|
|
682
|
+
*
|
|
683
|
+
* let mut parser = Parser::new();
|
|
684
|
+
* parser.set_language("python")?;
|
|
685
|
+
* let tree = parser.parse("def hello(): pass").expect("parse failed");
|
|
686
|
+
* assert_eq!(tree.root_node().kind(), "module");
|
|
687
|
+
* # Ok::<(), tree_sitter_language_pack::Error>(())
|
|
688
|
+
* ```typescript
|
|
689
|
+
*/
|
|
690
|
+
export declare class JsParser {
|
|
691
|
+
/**
|
|
692
|
+
* Configure the parser to use the language identified by name (e.g. `"python"`).
|
|
693
|
+
*
|
|
694
|
+
* Resolves the language through the global registry — auto-downloading
|
|
695
|
+
* if necessary, when the `download` feature is enabled.
|
|
696
|
+
* @throws Returns [`Error::LanguageNotFound`] if the language is not recognized,
|
|
697
|
+
* or [`Error::ParserSetup`] if the language ABI is incompatible.
|
|
698
|
+
*/
|
|
699
|
+
setLanguage(name: string): void;
|
|
700
|
+
/**
|
|
701
|
+
* Parse a UTF-8 source string. Returns `None` if parsing was cancelled
|
|
702
|
+
* or no language is set.
|
|
703
|
+
*/
|
|
704
|
+
parse(source: string): JsTree | undefined | null;
|
|
705
|
+
/**
|
|
706
|
+
* Parse a raw byte slice. Returns `None` if parsing was cancelled or
|
|
707
|
+
* no language is set.
|
|
708
|
+
*/
|
|
709
|
+
parseBytes(source: Uint8Array): JsTree | undefined | null;
|
|
710
|
+
/**
|
|
711
|
+
* Reset internal state. The next call to [`parse`](Self::parse) will
|
|
712
|
+
* not be incremental.
|
|
713
|
+
*/
|
|
714
|
+
reset(): void;
|
|
715
|
+
static default(): JsParser;
|
|
716
|
+
}
|
|
615
717
|
|
|
616
718
|
/** Manifest describing available parser downloads for a specific version. */
|
|
617
719
|
export interface JsParserManifest {
|
|
@@ -627,6 +729,14 @@ export interface JsPlatformBundle {
|
|
|
627
729
|
size: number;
|
|
628
730
|
}
|
|
629
731
|
|
|
732
|
+
/** A source position — row + column, zero-indexed. */
|
|
733
|
+
export interface JsPoint {
|
|
734
|
+
/** Zero-indexed row number. */
|
|
735
|
+
row: number;
|
|
736
|
+
/** Zero-indexed column number, in UTF-16 code units. */
|
|
737
|
+
column: number;
|
|
738
|
+
}
|
|
739
|
+
|
|
630
740
|
/**
|
|
631
741
|
* Configuration for the `process()` function.
|
|
632
742
|
*
|
|
@@ -775,7 +885,36 @@ export declare enum JsSymbolKind {
|
|
|
775
885
|
Other = "Other",
|
|
776
886
|
}
|
|
777
887
|
|
|
778
|
-
|
|
888
|
+
/** A parsed syntax tree. Cheap to clone (refcount bump). */
|
|
889
|
+
export declare class JsTree {
|
|
890
|
+
/** Return the root [`Node`] of this tree. */
|
|
891
|
+
rootNode(): JsNode;
|
|
892
|
+
/** Return a [`TreeCursor`] positioned at the root. */
|
|
893
|
+
walk(): JsTreeCursor;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
/** A cursor for traversing a [`Tree`]. */
|
|
897
|
+
export declare class JsTreeCursor {
|
|
898
|
+
/** Return the [`Node`] at the cursor's current position. */
|
|
899
|
+
node(): JsNode;
|
|
900
|
+
/**
|
|
901
|
+
* Move the cursor to the first child of the current node.
|
|
902
|
+
* Returns `true` if a child existed.
|
|
903
|
+
*/
|
|
904
|
+
gotoFirstChild(): boolean;
|
|
905
|
+
/**
|
|
906
|
+
* Move the cursor to the parent of the current node.
|
|
907
|
+
* Returns `true` if a parent existed.
|
|
908
|
+
*/
|
|
909
|
+
gotoParent(): boolean;
|
|
910
|
+
/**
|
|
911
|
+
* Move the cursor to the next sibling of the current node.
|
|
912
|
+
* Returns `true` if a sibling existed.
|
|
913
|
+
*/
|
|
914
|
+
gotoNextSibling(): boolean;
|
|
915
|
+
/** Return the field name for the current node, if any. */
|
|
916
|
+
fieldName(): string | undefined | null;
|
|
917
|
+
}
|
|
779
918
|
|
|
780
919
|
/**
|
|
781
920
|
* Return the number of available languages.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kreuzberg/tree-sitter-language-pack",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "Tree-sitter language pack - pre-compiled parsers for 305 languages (Node.js NAPI bindings)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kreuzberg",
|
|
@@ -32,7 +32,16 @@
|
|
|
32
32
|
"prepublishOnly": "napi prepublish -t npm --skip-optional-publish"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@napi-rs/cli": "^3.6.2"
|
|
35
|
+
"@napi-rs/cli": "^3.6.2",
|
|
36
|
+
"tree-sitter": "^0.25.0"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"tree-sitter": "^0.25.0"
|
|
40
|
+
},
|
|
41
|
+
"peerDependenciesMeta": {
|
|
42
|
+
"tree-sitter": {
|
|
43
|
+
"optional": true
|
|
44
|
+
}
|
|
36
45
|
},
|
|
37
46
|
"napi": {
|
|
38
47
|
"binaryName": "ts-pack-core-node",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|