@xberg-io/tree-sitter-language-pack 1.15.7 → 1.16.2

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/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <!-- This file is auto-generated by alef — DO NOT EDIT. -->
2
- <!-- alef:hash:bf28c5e6b12322464ec328f30dd1b6fb67bc0739d83fdfc2d451339934443028 -->
2
+ <!-- alef:hash:f02cf7eadee2e2005e0a0a46e7b2ae062a6cce92548b232119aa872449076c1a -->
3
3
  <!-- To regenerate: alef readme -->
4
4
  <!-- To verify freshness: alef verify -->
5
5
 
@@ -119,10 +119,16 @@ npm install @xberg-io/tree-sitter-language-pack
119
119
  ## Quick Start
120
120
 
121
121
  ```typescript title="TypeScript"
122
- import { process } from "@xberg-io/tree-sitter-language-pack";
122
+ import { ProcessConfig, process } from "@xberg-io/tree-sitter-language-pack";
123
123
  function main() {
124
- const result = process("# A comment\ndef greet(name):\n \"\"\"Say hello.\"\"\"\n return f'Hi {name}'\n\nimport os\n", { language: "python" });
125
- console.log(result);
124
+ const config: ProcessConfig = { language: "python" };
125
+ const result = process("# A comment\ndef greet(name):\n \"\"\"Say hello.\"\"\"\n return f'Hi {name}'\n\nimport os\n", config);
126
+ console.log(result.language);
127
+ console.log(result.structure);
128
+ console.log(result.structure?.[0]?.kind);
129
+ console.log(result.imports);
130
+ console.log(result.metrics?.totalLines);
131
+ console.log(result.metrics?.errorCount);
126
132
  }
127
133
 
128
134
  void main();
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // This file is auto-generated by alef — DO NOT EDIT.
2
- // alef:hash:af19e53619993c70375251f0e7b888e7eb1c7d2eda4f85efb6399f6dca682a08
2
+ // alef:hash:78d8af075d33d367ecac6d93cf1ff2224cc8ca072b49392de478f0d3a15dc3fd
3
3
  // To regenerate: alef generate
4
4
  // To verify freshness: alef verify
5
5
  /* eslint-disable */
@@ -248,27 +248,27 @@ export declare function init(config?: PackConfig | undefined | null): void;
248
248
  /** A byte range — start (inclusive) to end (exclusive). */
249
249
  export interface ByteRange {
250
250
  /** Inclusive start byte offset. */
251
- readonly start: number
251
+ readonly start: number;
252
252
  /** Exclusive end byte offset. */
253
- readonly end: number
253
+ readonly end: number;
254
254
  }
255
255
 
256
256
  /** Metadata for a single chunk of source code. */
257
257
  export interface ChunkContext {
258
258
  /** Language name used to parse this chunk. */
259
- readonly language?: string
259
+ readonly language?: string;
260
260
  /** Zero-indexed position of this chunk within the file's chunk list. */
261
- readonly chunkIndex?: number
261
+ readonly chunkIndex?: number;
262
262
  /** Total number of chunks the file was split into. */
263
- readonly totalChunks?: number
263
+ readonly totalChunks?: number;
264
264
  /** Tree-sitter node kinds that appear at the top level of this chunk. */
265
- readonly nodeTypes?: Array<string>
265
+ readonly nodeTypes?: Array<string>;
266
266
  /** Hierarchical path of enclosing structural items (e.g., `["MyClass", "my_method"]`). */
267
- readonly contextPath?: Array<string>
267
+ readonly contextPath?: Array<string>;
268
268
  /** Names of symbols defined within this chunk. */
269
- readonly symbolsDefined?: Array<string>
269
+ readonly symbolsDefined?: Array<string>;
270
270
  /** Comments contained within this chunk. */
271
- readonly comments?: Array<CommentInfo>
271
+ readonly comments?: Array<CommentInfo>;
272
272
  /**
273
273
  * Docstrings contained within this chunk.
274
274
  *
@@ -276,21 +276,21 @@ export interface ChunkContext {
276
276
  * `ProcessResult.docstrings` is populated, and by the same
277
277
  * classifier. Always empty for every other language.
278
278
  */
279
- readonly docstrings?: Array<DocstringInfo>
279
+ readonly docstrings?: Array<DocstringInfo>;
280
280
  /** Whether this chunk contains any tree-sitter error nodes. */
281
- readonly hasErrorNodes?: boolean
281
+ readonly hasErrorNodes?: boolean;
282
282
  }
283
283
 
284
284
  /** A chunk of source code with rich metadata. */
285
285
  export interface CodeChunk {
286
286
  /** The raw source text of this chunk. */
287
- readonly content?: string
287
+ readonly content?: string;
288
288
  /** Inclusive start byte offset of this chunk in the original source. */
289
- readonly startByte?: number
289
+ readonly startByte?: number;
290
290
  /** Exclusive end byte offset of this chunk in the original source. */
291
- readonly endByte?: number
291
+ readonly endByte?: number;
292
292
  /** Zero-indexed start line of this chunk. */
293
- readonly startLine?: number
293
+ readonly startLine?: number;
294
294
  /**
295
295
  * Zero-indexed row of the last byte actually included in this chunk
296
296
  * (inclusive — the same row a `Span.end_line` would report for a node
@@ -298,21 +298,21 @@ export interface CodeChunk {
298
298
  * source has a trailing newline: it is always the row of `end_byte - 1`,
299
299
  * never a phantom row past the file's real content.
300
300
  */
301
- readonly endLine?: number
301
+ readonly endLine?: number;
302
302
  /** Contextual metadata about this chunk. */
303
- readonly metadata?: ChunkContext
303
+ readonly metadata?: ChunkContext;
304
304
  }
305
305
 
306
306
  /** A comment extracted from source code. */
307
307
  export interface CommentInfo {
308
308
  /** The raw text content of the comment. */
309
- readonly text?: string
309
+ readonly text?: string;
310
310
  /** The kind of comment (line, block, or doc). */
311
- readonly kind?: CommentKind
311
+ readonly kind?: CommentKind;
312
312
  /** Source span covering the comment. */
313
- readonly span?: Span
313
+ readonly span?: Span;
314
314
  /** Name of the syntax node this comment is directly associated with. */
315
- readonly associatedNode?: string
315
+ readonly associatedNode?: string;
316
316
  }
317
317
 
318
318
  /**
@@ -338,11 +338,11 @@ export declare enum CommentKind {
338
338
  */
339
339
  export interface DataAttribute {
340
340
  /** Attribute name (e.g. `"class"`, `"href"`). */
341
- readonly name?: string
341
+ readonly name?: string;
342
342
  /** Attribute value as a raw string (quotes stripped). */
343
- readonly value?: string
343
+ readonly value?: string;
344
344
  /** Source span covering the entire `name="value"` attribute token. */
345
- readonly span?: Span
345
+ readonly span?: Span;
346
346
  }
347
347
 
348
348
  /**
@@ -362,23 +362,23 @@ export interface DataAttribute {
362
362
  */
363
363
  export interface DataNode {
364
364
  /** Whether this node is a key/value pair, XML element, or sequence item. */
365
- readonly kind?: DataNodeKind
365
+ readonly kind?: DataNodeKind;
366
366
  /**
367
367
  * Key, attribute name, tag name, or positional index (`"0"`, `"1"`, …).
368
368
  * `None` at the document root.
369
369
  */
370
- readonly key?: string
370
+ readonly key?: string;
371
371
  /**
372
372
  * Leaf scalar value, if any. `None` for containers (objects, arrays, XML elements
373
373
  * with child elements).
374
374
  */
375
- readonly value?: string
375
+ readonly value?: string;
376
376
  /** Attributes on element-shape nodes (XML `STag` attributes). Empty for all other kinds. */
377
- readonly attributes?: Array<DataAttribute>
377
+ readonly attributes?: Array<DataAttribute>;
378
378
  /** Children for nested containers and XML element bodies. */
379
- readonly children?: Array<DataNode>
379
+ readonly children?: Array<DataNode>;
380
380
  /** Source span covering this node in the original source file. */
381
- readonly span?: Span
381
+ readonly span?: Span;
382
382
  }
383
383
 
384
384
  /**
@@ -413,11 +413,11 @@ export declare enum DataNodeKind {
413
413
  /** A diagnostic (syntax error, missing node, etc.) from parsing. */
414
414
  export interface Diagnostic {
415
415
  /** Human-readable description of the diagnostic. */
416
- readonly message?: string
416
+ readonly message?: string;
417
417
  /** Severity of the diagnostic. */
418
- readonly severity?: DiagnosticSeverity
418
+ readonly severity?: DiagnosticSeverity;
419
419
  /** Source span where the diagnostic was detected. */
420
- readonly span?: Span
420
+ readonly span?: Span;
421
421
  }
422
422
 
423
423
  /**
@@ -438,11 +438,11 @@ export declare enum DiagnosticSeverity {
438
438
  /** A section within a docstring (e.g., Args, Returns, Raises). */
439
439
  export interface DocSection {
440
440
  /** Section kind (e.g., `"args"`, `"returns"`, `"raises"`). */
441
- readonly kind?: string
441
+ readonly kind?: string;
442
442
  /** Parameter or return value name, if applicable. */
443
- readonly name?: string
443
+ readonly name?: string;
444
444
  /** Description text for this section. */
445
- readonly description?: string
445
+ readonly description?: string;
446
446
  }
447
447
 
448
448
  /**
@@ -457,37 +457,24 @@ export interface DocSection {
457
457
  * variant serializes as a single-keyed object (`{"Other": "rst"}`). DO
458
458
  * NOT add `#[serde(tag = "...")]`. Covered by `tests/wire_format.rs`.
459
459
  */
460
- export declare enum DocstringFormat {
461
- /** Python triple-quoted string docstring (`"""..."""`). */
462
- PythonTripleQuote = "PythonTripleQuote",
463
- /**
464
- * JavaScript/TypeScript JSDoc block comment (opens with two stars, closes
465
- * with star-slash).
466
- */
467
- JSDoc = "JSDoc",
468
- /** Rust `///` or `//!` doc comment. */
469
- Rustdoc = "Rustdoc",
470
- /** Go doc comment (a comment block immediately preceding a declaration). */
471
- GoDoc = "GoDoc",
472
- /**
473
- * Java Javadoc block comment (opens with two stars, closes with
474
- * star-slash).
475
- */
476
- JavaDoc = "JavaDoc",
477
- /** A language-specific docstring format not covered by the standard variants. */
478
- Other = "Other",
479
- }
460
+ export type DocstringFormat =
461
+ | { type: "PythonTripleQuote" }
462
+ | { type: "JSDoc" }
463
+ | { type: "Rustdoc" }
464
+ | { type: "GoDoc" }
465
+ | { type: "JavaDoc" }
466
+ | { type: "Other"; other: string };
480
467
 
481
468
  /** A docstring extracted from source code. */
482
469
  export interface DocstringInfo {
483
470
  /** The raw text of the docstring. */
484
- readonly text?: string
471
+ readonly text?: string;
485
472
  /** The docstring format (Python, JSDoc, Rustdoc, etc.). */
486
- readonly format?: DocstringFormat
473
+ readonly format?: DocstringFormat;
487
474
  /** Source span covering the docstring. */
488
- readonly span?: Span
475
+ readonly span?: Span;
489
476
  /** Name of the item this docstring documents. */
490
- readonly associatedItem?: string
477
+ readonly associatedItem?: string;
491
478
  /**
492
479
  * Parsed sections of the docstring (Args, Returns, Raises, etc.).
493
480
  *
@@ -498,7 +485,7 @@ export interface DocstringInfo {
498
485
  * no extractor here does yet. The field is kept rather than removed so
499
486
  * a consumer's deserializer does not need updating once it is.
500
487
  */
501
- readonly parsedSections?: Array<DocSection>
488
+ readonly parsedSections?: Array<DocSection>;
502
489
  }
503
490
 
504
491
  /** Manages downloading and caching of pre-built parser shared libraries. */
@@ -510,7 +497,7 @@ export declare class DownloadManager {
510
497
  * `validate_version` — or if no cache directory can be resolved (see
511
498
  * `Self.default_cache_dir`).
512
499
  */
513
- static new(version: string): DownloadManager
500
+ static new(version: string): DownloadManager;
514
501
  /**
515
502
  * List languages that are already downloaded and cached.
516
503
  *
@@ -528,7 +515,7 @@ export declare class DownloadManager {
528
515
  * language binding — but logs a `tracing.warn!` so the failure is not
529
516
  * silently indistinguishable from "nothing installed".
530
517
  */
531
- installedLanguages(): Array<string>
518
+ installedLanguages(): Array<string>;
532
519
  /**
533
520
  * Download the platform bundle and extract every library file it contains.
534
521
  *
@@ -539,7 +526,7 @@ export declare class DownloadManager {
539
526
  *
540
527
  * Returns the number of library files extracted (including those already cached).
541
528
  */
542
- downloadAllBestEffort(): number
529
+ downloadAllBestEffort(): number;
543
530
  /**
544
531
  * Remove all cached parser libraries.
545
532
  *
@@ -550,17 +537,17 @@ export declare class DownloadManager {
550
537
  * already opened the file to continue holding a stale lock handle while a new
551
538
  * process opens a fresh inode, breaking the mutual-exclusion guarantee.
552
539
  */
553
- cleanCache(): void
540
+ cleanCache(): void;
554
541
  }
555
542
 
556
543
  /** An export statement extracted from source code. */
557
544
  export interface ExportInfo {
558
545
  /** The exported name. */
559
- readonly name?: string
546
+ readonly name?: string;
560
547
  /** The kind of export (named, default, or re-export). */
561
- readonly kind?: ExportKind
548
+ readonly kind?: ExportKind;
562
549
  /** Source span covering the export statement. */
563
- readonly span?: Span
550
+ readonly span?: Span;
564
551
  }
565
552
 
566
553
  /**
@@ -580,27 +567,27 @@ export declare enum ExportKind {
580
567
  /** Aggregate metrics for a source file. */
581
568
  export interface FileMetrics {
582
569
  /** Total number of lines (including blank and comment lines). */
583
- readonly totalLines?: number
570
+ readonly totalLines?: number;
584
571
  /** Number of lines containing non-blank, non-comment source code. */
585
- readonly codeLines?: number
572
+ readonly codeLines?: number;
586
573
  /** Number of lines that are entirely comments. */
587
- readonly commentLines?: number
574
+ readonly commentLines?: number;
588
575
  /** Number of blank (whitespace-only) lines. */
589
- readonly blankLines?: number
576
+ readonly blankLines?: number;
590
577
  /** Total byte length of the source file. */
591
- readonly totalBytes?: number
578
+ readonly totalBytes?: number;
592
579
  /** Total number of nodes in the syntax tree. */
593
- readonly nodeCount?: number
580
+ readonly nodeCount?: number;
594
581
  /** Number of error nodes in the syntax tree (parse errors). */
595
- readonly errorCount?: number
582
+ readonly errorCount?: number;
596
583
  /** Maximum nesting depth reached in the syntax tree. */
597
- readonly maxDepth?: number
584
+ readonly maxDepth?: number;
598
585
  }
599
586
 
600
587
  /** An import statement extracted from source code. */
601
588
  export interface ImportInfo {
602
589
  /** The module or path being imported from. */
603
- readonly source?: string
590
+ readonly source?: string;
604
591
  /**
605
592
  * Specific names imported from the source module.
606
593
  *
@@ -614,7 +601,7 @@ export interface ImportInfo {
614
601
  * — and for a JS/TS namespace import (`import * as ns`) or default
615
602
  * import (`import x from 'm'`), neither of which names individual items.
616
603
  */
617
- readonly items?: Array<string>
604
+ readonly items?: Array<string>;
618
605
  /**
619
606
  * Alias assigned to the import (e.g., `import numpy as np`).
620
607
  *
@@ -628,7 +615,7 @@ export interface ImportInfo {
628
615
  * where there is no single alias to report for the statement as a
629
616
  * whole, so only `items` is populated for it.
630
617
  */
631
- readonly alias?: string
618
+ readonly alias?: string;
632
619
  /**
633
620
  * Whether this is a wildcard import (e.g., `import *` or `use foo.*`).
634
621
  *
@@ -638,9 +625,9 @@ export interface ImportInfo {
638
625
  * import's source text for a `*` character, so a glob in an import path
639
626
  * string (`import a from './glob*.js'`) is not mistaken for one.
640
627
  */
641
- readonly isWildcard?: boolean
628
+ readonly isWildcard?: boolean;
642
629
  /** Source span covering the import statement. */
643
- readonly span?: Span
630
+ readonly span?: Span;
644
631
  }
645
632
 
646
633
  /**
@@ -658,14 +645,14 @@ export declare class LanguageRegistry {
658
645
  * When the `dynamic-loading` feature is enabled, the registry also knows
659
646
  * about dynamically loadable grammars and will load them on demand.
660
647
  */
661
- static new(): LanguageRegistry
648
+ static new(): LanguageRegistry;
662
649
  /**
663
650
  * List all available language names, sorted and deduplicated.
664
651
  *
665
652
  * Includes statically compiled languages, dynamically loadable languages
666
653
  * (if the `dynamic-loading` feature is enabled), and all configured aliases.
667
654
  */
668
- availableLanguages(): Array<string>
655
+ availableLanguages(): Array<string>;
669
656
  /**
670
657
  * Check whether this language can be parsed right now, without downloading.
671
658
  *
@@ -690,7 +677,7 @@ export declare class LanguageRegistry {
690
677
  * or wrong-architecture library exists on disk but cannot parse. Loads are
691
678
  * cached process-wide, so repeat calls are cheap.
692
679
  */
693
- hasParser(name: string): boolean
680
+ hasParser(name: string): boolean;
694
681
  /**
695
682
  * Check whether a language is available by name or alias.
696
683
  *
@@ -703,14 +690,14 @@ export declare class LanguageRegistry {
703
690
  * of the `stat` calls is what keeps this off the syscall path for the
704
691
  * languages a process actually uses.
705
692
  */
706
- hasLanguage(name: string): boolean
693
+ hasLanguage(name: string): boolean;
707
694
  /**
708
695
  * Return the total number of available languages (including aliases).
709
696
  *
710
697
  * Counts the same set `available_languages`
711
698
  * lists, without materialising or sorting it.
712
699
  */
713
- languageCount(): number
700
+ languageCount(): number;
714
701
  /**
715
702
  * Parse source code and extract file intelligence based on config in a single pass.
716
703
  * @throws Returns `Error.InvalidRange` if the config is invalid (see
@@ -720,8 +707,8 @@ export declare class LanguageRegistry {
720
707
  * `Error.LanguageNotFound` if the language is unknown; or
721
708
  * `Error.ParseFailed` if parsing produces no tree.
722
709
  */
723
- process(source: string, config?: ProcessConfig | undefined | null): ProcessResult
724
- static default(): LanguageRegistry
710
+ process(source: string, config?: ProcessConfig | undefined | null): ProcessResult;
711
+ static default(): LanguageRegistry;
725
712
  }
726
713
 
727
714
  /**
@@ -732,7 +719,7 @@ export declare class LanguageRegistry {
732
719
  */
733
720
  export declare class Node {
734
721
  /** Return the node's kind name (e.g. `"function_definition"`). */
735
- kind(): string
722
+ kind(): string;
736
723
  /**
737
724
  * Return the node's numeric kind ID.
738
725
  *
@@ -740,48 +727,48 @@ export declare class Node {
740
727
  * (e.g. `"function_definition" → 42`). Comparing `kind_id()` is cheaper
741
728
  * than comparing the string `kind()` in tight AST loops.
742
729
  */
743
- kindId(): number
730
+ kindId(): number;
744
731
  /** Return the inclusive start byte offset of this node. */
745
- startByte(): number
732
+ startByte(): number;
746
733
  /** Return the exclusive end byte offset of this node. */
747
- endByte(): number
734
+ endByte(): number;
748
735
  /**
749
736
  * Return the node's byte range as a `ByteRange`.
750
737
  *
751
738
  * Callers should slice their own source bytes — this is a zero-copy
752
739
  * text accessor.
753
740
  */
754
- byteRange(): ByteRange
741
+ byteRange(): ByteRange;
755
742
  /** Return the start `Point` (row, column). */
756
- startPosition(): Point
743
+ startPosition(): Point;
757
744
  /** Return the end `Point` (row, column). */
758
- endPosition(): Point
745
+ endPosition(): Point;
759
746
  /** True when this node is named (not punctuation/whitespace). */
760
- isNamed(): boolean
747
+ isNamed(): boolean;
761
748
  /** True when this is an error node. */
762
- isError(): boolean
749
+ isError(): boolean;
763
750
  /** True when this is a missing-token node. */
764
- isMissing(): boolean
751
+ isMissing(): boolean;
765
752
  /** True when this is an "extra" node (e.g. a comment). */
766
- isExtra(): boolean
753
+ isExtra(): boolean;
767
754
  /** True when this node or any descendant is an error. */
768
- hasError(): boolean
755
+ hasError(): boolean;
769
756
  /** Return this node's parent, if any. */
770
- parent(): Node | null
757
+ parent(): Node | null;
771
758
  /** Return the i-th child of this node, if any. */
772
- child(index: number): Node | null
759
+ child(index: number): Node | null;
773
760
  /** Total number of children (including unnamed). */
774
- childCount(): number
761
+ childCount(): number;
775
762
  /** Return the i-th named child of this node, if any. */
776
- namedChild(index: number): Node | null
763
+ namedChild(index: number): Node | null;
777
764
  /** Number of named children of this node. */
778
- namedChildCount(): number
765
+ namedChildCount(): number;
779
766
  /** Look up a child by its grammar-defined field name. */
780
- childByFieldName(name: string): Node | null
767
+ childByFieldName(name: string): Node | null;
781
768
  /** Return the S-expression form of this node's subtree. */
782
- toSexp(): string
769
+ toSexp(): string;
783
770
  /** Return a `TreeCursor` positioned at this node. */
784
- walk(): TreeCursor
771
+ walk(): TreeCursor;
785
772
  }
786
773
 
787
774
  /**
@@ -808,13 +795,13 @@ export interface PackConfig {
808
795
  *
809
796
  * Default base: the platform cache dir, e.g. `~/.cache` on Linux.
810
797
  */
811
- readonly cacheDir?: string
798
+ readonly cacheDir?: string;
812
799
  /**
813
800
  * Languages to pre-download on init.
814
801
  *
815
802
  * Each entry is a language name (e.g. `"python"`, `"rust"`).
816
803
  */
817
- readonly languages?: Array<string>
804
+ readonly languages?: Array<string>;
818
805
  /**
819
806
  * Language groups to pre-download.
820
807
  *
@@ -823,7 +810,7 @@ export interface PackConfig {
823
810
  * Call `manifest_groups` to enumerate them.
824
811
  * An unknown name makes `init` fail.
825
812
  */
826
- readonly groups?: Array<string>
813
+ readonly groups?: Array<string>;
827
814
  }
828
815
 
829
816
  /** A tree-sitter parser configured for one language at a time. */
@@ -836,7 +823,7 @@ export declare class Parser {
836
823
  * `set_parse_timeout_ms`; both default to
837
824
  * unbounded so that existing callers are unaffected.
838
825
  */
839
- static new(): Parser
826
+ static new(): Parser;
840
827
  /**
841
828
  * Refuse to parse sources longer than `max_bytes`.
842
829
  *
@@ -846,7 +833,7 @@ export declare class Parser {
846
833
  *
847
834
  * See `RECOMMENDED_MAX_SOURCE_BYTES`.
848
835
  */
849
- setMaxSourceBytes(maxBytes?: number | undefined | null): void
836
+ setMaxSourceBytes(maxBytes?: number | undefined | null): void;
850
837
  /**
851
838
  * Cancel a parse that exceeds `timeout_ms` milliseconds of wall clock.
852
839
  *
@@ -856,7 +843,7 @@ export declare class Parser {
856
843
  *
857
844
  * See `RECOMMENDED_PARSE_TIMEOUT_MS`.
858
845
  */
859
- setParseTimeoutMs(timeoutMs?: number | undefined | null): void
846
+ setParseTimeoutMs(timeoutMs?: number | undefined | null): void;
860
847
  /**
861
848
  * Configure the parser to use the language identified by name (e.g. `"python"`).
862
849
  *
@@ -865,7 +852,7 @@ export declare class Parser {
865
852
  * @throws Returns `Error.LanguageNotFound` if the language is not recognized,
866
853
  * or `Error.ParserSetup` if the language ABI is incompatible.
867
854
  */
868
- setLanguage(name: string): void
855
+ setLanguage(name: string): void;
869
856
  /**
870
857
  * Parse a UTF-8 source string.
871
858
  *
@@ -883,26 +870,26 @@ export declare class Parser {
883
870
  * threads can't corrupt shared scanner state. Every other language is unaffected by that
884
871
  * lock and never waits on it.
885
872
  */
886
- parse(source: string): Tree | null
873
+ parse(source: string): Tree | null;
887
874
  /**
888
875
  * Parse a raw byte slice.
889
876
  *
890
877
  * Same outcomes as `parse`, including the concurrency behaviour documented
891
878
  * there.
892
879
  */
893
- parseBytes(source: Uint8Array): Tree | null
880
+ parseBytes(source: Uint8Array): Tree | null;
894
881
  /**
895
882
  * Reset internal state. The next call to `parse` will
896
883
  * not be incremental.
897
884
  */
898
- reset(): void
899
- static default(): Parser
885
+ reset(): void;
886
+ static default(): Parser;
900
887
  }
901
888
 
902
889
  /** A source position — row + column, zero-indexed. */
903
890
  export interface Point {
904
891
  /** Zero-indexed row number. */
905
- readonly row: number
892
+ readonly row: number;
906
893
  /**
907
894
  * Zero-indexed column, counted in **bytes** from the start of the row.
908
895
  *
@@ -919,7 +906,7 @@ export interface Point {
919
906
  * instead. Earlier releases documented this field as UTF-16 code units;
920
907
  * that was never what the value contained.
921
908
  */
922
- readonly column: number
909
+ readonly column: number;
923
910
  }
924
911
 
925
912
  /**
@@ -929,21 +916,21 @@ export interface Point {
929
916
  */
930
917
  export interface ProcessConfig {
931
918
  /** Language name (required). */
932
- readonly language?: string
919
+ readonly language?: string;
933
920
  /** Extract structural items (functions, classes, etc.). Default: true. */
934
- readonly structure?: boolean
921
+ readonly structure?: boolean;
935
922
  /** Extract import statements. Default: true. */
936
- readonly imports?: boolean
923
+ readonly imports?: boolean;
937
924
  /** Extract export statements. Default: true. */
938
- readonly exports?: boolean
925
+ readonly exports?: boolean;
939
926
  /** Extract comments. Default: false. */
940
- readonly comments?: boolean
927
+ readonly comments?: boolean;
941
928
  /** Extract docstrings. Default: false. */
942
- readonly docstrings?: boolean
929
+ readonly docstrings?: boolean;
943
930
  /** Extract symbol definitions. Default: false. */
944
- readonly symbols?: boolean
931
+ readonly symbols?: boolean;
945
932
  /** Include parse diagnostics. Default: false. */
946
- readonly diagnostics?: boolean
933
+ readonly diagnostics?: boolean;
947
934
  /**
948
935
  * Maximum chunk size in bytes. `None` disables chunking.
949
936
  *
@@ -952,7 +939,7 @@ export interface ProcessConfig {
952
939
  * limit previously produced an empty chunk list and silently discarded the
953
940
  * whole source; use `None` to mean "do not chunk".
954
941
  */
955
- readonly chunkMaxSize?: number
942
+ readonly chunkMaxSize?: number;
956
943
  /**
957
944
  * Extract hierarchical key/value data tree from data-format files. Default: false.
958
945
  *
@@ -963,7 +950,7 @@ export interface ProcessConfig {
963
950
  *
964
951
  * For languages outside this set the field is left as `None`.
965
952
  */
966
- readonly dataExtraction?: boolean
953
+ readonly dataExtraction?: boolean;
967
954
  /**
968
955
  * Reject source longer than this many bytes instead of parsing it.
969
956
  * Default: `None` (unbounded).
@@ -978,7 +965,7 @@ export interface ProcessConfig {
978
965
  * `Error.InvalidRange` — the source is never
979
966
  * silently truncated.
980
967
  */
981
- readonly maxSourceBytes?: number
968
+ readonly maxSourceBytes?: number;
982
969
  /**
983
970
  * Wall-clock budget for the parse step, in milliseconds.
984
971
  * Default: `None` (no timeout).
@@ -988,7 +975,7 @@ export interface ProcessConfig {
988
975
  * interval rather than exact. A parse that exceeds the budget fails with
989
976
  * `Error.ParseTimeout`.
990
977
  */
991
- readonly parseTimeoutMs?: number
978
+ readonly parseTimeoutMs?: number;
992
979
  }
993
980
 
994
981
  /**
@@ -1013,25 +1000,25 @@ export interface ProcessConfig {
1013
1000
  */
1014
1001
  export interface ProcessResult {
1015
1002
  /** The language name used to parse the source file. */
1016
- readonly language?: string
1003
+ readonly language?: string;
1017
1004
  /** File-level metrics (line counts, byte size, error count). */
1018
- readonly metrics?: FileMetrics
1005
+ readonly metrics?: FileMetrics;
1019
1006
  /** Top-level structural items (functions, classes, etc.). */
1020
- readonly structure?: Array<StructureItem>
1007
+ readonly structure?: Array<StructureItem>;
1021
1008
  /** Import statements extracted from the source. */
1022
- readonly imports?: Array<ImportInfo>
1009
+ readonly imports?: Array<ImportInfo>;
1023
1010
  /** Export statements extracted from the source. */
1024
- readonly exports?: Array<ExportInfo>
1011
+ readonly exports?: Array<ExportInfo>;
1025
1012
  /** Comments extracted from the source. */
1026
- readonly comments?: Array<CommentInfo>
1013
+ readonly comments?: Array<CommentInfo>;
1027
1014
  /** Docstrings extracted from the source. */
1028
- readonly docstrings?: Array<DocstringInfo>
1015
+ readonly docstrings?: Array<DocstringInfo>;
1029
1016
  /** Symbol definitions (variables, types, functions) extracted from the source. */
1030
- readonly symbols?: Array<SymbolInfo>
1017
+ readonly symbols?: Array<SymbolInfo>;
1031
1018
  /** Parse diagnostics (syntax errors, missing nodes) from tree-sitter. */
1032
- readonly diagnostics?: Array<Diagnostic>
1019
+ readonly diagnostics?: Array<Diagnostic>;
1033
1020
  /** Syntax-aware code chunks produced when chunking is enabled. */
1034
- readonly chunks?: Array<CodeChunk>
1021
+ readonly chunks?: Array<CodeChunk>;
1035
1022
  /**
1036
1023
  * Hierarchical data tree extracted when `config.data_extraction` is `true`.
1037
1024
  *
@@ -1041,7 +1028,7 @@ export interface ProcessResult {
1041
1028
  *
1042
1029
  * See `DataNode` for the shape of the returned tree.
1043
1030
  */
1044
- readonly data?: DataNode
1031
+ readonly data?: DataNode;
1045
1032
  }
1046
1033
 
1047
1034
  /**
@@ -1052,37 +1039,37 @@ export interface ProcessResult {
1052
1039
  */
1053
1040
  export interface Span {
1054
1041
  /** Inclusive start byte offset in the source. */
1055
- readonly startByte?: number
1042
+ readonly startByte?: number;
1056
1043
  /** Exclusive end byte offset in the source. */
1057
- readonly endByte?: number
1044
+ readonly endByte?: number;
1058
1045
  /** Zero-indexed line number of the span's start. */
1059
- readonly startLine?: number
1046
+ readonly startLine?: number;
1060
1047
  /**
1061
1048
  * Zero-indexed column of the span's start, counted in **bytes** from the
1062
1049
  * start of the line — not characters, not UTF-16 code units.
1063
1050
  */
1064
- readonly startColumn?: number
1051
+ readonly startColumn?: number;
1065
1052
  /** Zero-indexed line number of the span's end. */
1066
- readonly endLine?: number
1053
+ readonly endLine?: number;
1067
1054
  /**
1068
1055
  * Zero-indexed column of the span's end, counted in **bytes** from the
1069
1056
  * start of the line — not characters, not UTF-16 code units.
1070
1057
  */
1071
- readonly endColumn?: number
1058
+ readonly endColumn?: number;
1072
1059
  }
1073
1060
 
1074
1061
  /** A structural item (function, class, struct, etc.) in source code. */
1075
1062
  export interface StructureItem {
1076
1063
  /** The kind of structural item. */
1077
- readonly kind?: StructureKind
1064
+ readonly kind?: StructureKind;
1078
1065
  /** The declared name of the item, if present. */
1079
- readonly name?: string
1066
+ readonly name?: string;
1080
1067
  /** Visibility modifier (e.g., `"pub"`, `"public"`, `"private"`). */
1081
- readonly visibility?: string
1068
+ readonly visibility?: string;
1082
1069
  /** Source span covering the entire item declaration. */
1083
- readonly span?: Span
1070
+ readonly span?: Span;
1084
1071
  /** Nested structural items (e.g., methods within a class). */
1085
- readonly children?: Array<StructureItem>
1072
+ readonly children?: Array<StructureItem>;
1086
1073
  /**
1087
1074
  * Decorator or attribute names applied to the item.
1088
1075
  *
@@ -1093,7 +1080,7 @@ export interface StructureItem {
1093
1080
  * implements yet. The field is kept rather than removed so a consumer's
1094
1081
  * deserializer does not need updating once it is.
1095
1082
  */
1096
- readonly decorators?: Array<string>
1083
+ readonly decorators?: Array<string>;
1097
1084
  /**
1098
1085
  * Documentation comment attached to the item, if any.
1099
1086
  *
@@ -1108,7 +1095,7 @@ export interface StructureItem {
1108
1095
  * comment in Python, Ruby, or Elixir) — Python's docstring convention is
1109
1096
  * captured separately, as `DocstringInfo`, not through this field.
1110
1097
  */
1111
- readonly docComment?: string
1098
+ readonly docComment?: string;
1112
1099
  /**
1113
1100
  * Full signature text of the item (e.g., function parameters and return type).
1114
1101
  *
@@ -1121,9 +1108,9 @@ export interface StructureItem {
1121
1108
  * it is derived from `body_span`'s boundary rather than per-language
1122
1109
  * syntax.
1123
1110
  */
1124
- readonly signature?: string
1111
+ readonly signature?: string;
1125
1112
  /** Source span covering only the body of the item, if distinct from the declaration. */
1126
- readonly bodySpan?: Span
1113
+ readonly bodySpan?: Span;
1127
1114
  }
1128
1115
 
1129
1116
  /**
@@ -1142,41 +1129,29 @@ export interface StructureItem {
1142
1129
  * any change breaks all bindings' `process()` tests simultaneously.
1143
1130
  * Covered by `tests/wire_format.rs`.
1144
1131
  */
1145
- export declare enum StructureKind {
1146
- /** A free-standing or associated function. */
1147
- Function = "Function",
1148
- /** A method defined inside a class, struct, trait, or impl block. */
1149
- Method = "Method",
1150
- /** A class definition. */
1151
- Class = "Class",
1152
- /** A struct definition. */
1153
- Struct = "Struct",
1154
- /** An interface or protocol definition. */
1155
- Interface = "Interface",
1156
- /** An enum definition. */
1157
- Enum = "Enum",
1158
- /** A module or package declaration. */
1159
- Module = "Module",
1160
- /** A trait definition. */
1161
- Trait = "Trait",
1162
- /** An impl block (Rust) or similar implementation block. */
1163
- Impl = "Impl",
1164
- /** A namespace declaration. */
1165
- Namespace = "Namespace",
1166
- /** A language-specific construct that does not fit any standard category. */
1167
- Other = "Other",
1168
- }
1132
+ export type StructureKind =
1133
+ | { type: "Function" }
1134
+ | { type: "Method" }
1135
+ | { type: "Class" }
1136
+ | { type: "Struct" }
1137
+ | { type: "Interface" }
1138
+ | { type: "Enum" }
1139
+ | { type: "Module" }
1140
+ | { type: "Trait" }
1141
+ | { type: "Impl" }
1142
+ | { type: "Namespace" }
1143
+ | { type: "Other"; other: string };
1169
1144
 
1170
1145
  /** A symbol (variable, function, type, etc.) extracted from source code. */
1171
1146
  export interface SymbolInfo {
1172
1147
  /** The name of the symbol. */
1173
- readonly name?: string
1148
+ readonly name?: string;
1174
1149
  /** The kind of symbol (variable, function, class, etc.). */
1175
- readonly kind?: SymbolKind
1150
+ readonly kind?: SymbolKind;
1176
1151
  /** Source span covering the symbol definition. */
1177
- readonly span?: Span
1152
+ readonly span?: Span;
1178
1153
  /** Explicit type annotation, if present in the source. */
1179
- readonly typeAnnotation?: string
1154
+ readonly typeAnnotation?: string;
1180
1155
  /**
1181
1156
  * Documentation comment immediately preceding this symbol, resolved by
1182
1157
  * the same walk `StructureItem.doc_comment` uses (see
@@ -1189,7 +1164,7 @@ export interface SymbolInfo {
1189
1164
  * also `None` when a symbol in a supported language simply has no doc
1190
1165
  * comment immediately above it.
1191
1166
  */
1192
- readonly doc?: string
1167
+ readonly doc?: string;
1193
1168
  }
1194
1169
 
1195
1170
  /**
@@ -1204,56 +1179,46 @@ export interface SymbolInfo {
1204
1179
  * variant serializes as a single-keyed object (`{"Other": "macro"}`). DO
1205
1180
  * NOT add `#[serde(tag = "...")]`. Covered by `tests/wire_format.rs`.
1206
1181
  */
1207
- export declare enum SymbolKind {
1208
- /** A variable binding. */
1209
- Variable = "Variable",
1210
- /** A constant (immutable binding). */
1211
- Constant = "Constant",
1212
- /** A function definition. */
1213
- Function = "Function",
1214
- /** A class definition. */
1215
- Class = "Class",
1216
- /** A type alias or typedef. */
1217
- Type = "Type",
1218
- /** An interface definition. */
1219
- Interface = "Interface",
1220
- /** An enum definition. */
1221
- Enum = "Enum",
1222
- /** A module declaration. */
1223
- Module = "Module",
1224
- /** A symbol kind not covered by the standard variants. */
1225
- Other = "Other",
1226
- }
1182
+ export type SymbolKind =
1183
+ | { type: "Variable" }
1184
+ | { type: "Constant" }
1185
+ | { type: "Function" }
1186
+ | { type: "Class" }
1187
+ | { type: "Type" }
1188
+ | { type: "Interface" }
1189
+ | { type: "Enum" }
1190
+ | { type: "Module" }
1191
+ | { type: "Other"; other: string };
1227
1192
 
1228
1193
  /** A parsed syntax tree. Cheap to clone (refcount bump). */
1229
1194
  export declare class Tree {
1230
1195
  /** Return the root `Node` of this tree. */
1231
- rootNode(): Node
1196
+ rootNode(): Node;
1232
1197
  /** Return a `TreeCursor` positioned at the root. */
1233
- walk(): TreeCursor
1198
+ walk(): TreeCursor;
1234
1199
  }
1235
1200
 
1236
1201
  /** A cursor for traversing a `Tree`. */
1237
1202
  export declare class TreeCursor {
1238
1203
  /** Return the `Node` at the cursor's current position. */
1239
- node(): Node
1204
+ node(): Node;
1240
1205
  /**
1241
1206
  * Move the cursor to the first child of the current node.
1242
1207
  * Returns `true` if a child existed.
1243
1208
  */
1244
- gotoFirstChild(): boolean
1209
+ gotoFirstChild(): boolean;
1245
1210
  /**
1246
1211
  * Move the cursor to the parent of the current node.
1247
1212
  * Returns `true` if a parent existed.
1248
1213
  */
1249
- gotoParent(): boolean
1214
+ gotoParent(): boolean;
1250
1215
  /**
1251
1216
  * Move the cursor to the next sibling of the current node.
1252
1217
  * Returns `true` if a sibling existed.
1253
1218
  */
1254
- gotoNextSibling(): boolean
1219
+ gotoNextSibling(): boolean;
1255
1220
  /** Return the field name for the current node, if any. */
1256
- fieldName(): string | null
1221
+ fieldName(): string | null;
1257
1222
  }
1258
1223
 
1259
1224
  /**
package/index.js CHANGED
@@ -9,16 +9,9 @@ const isMusl = () => {
9
9
  // "is musl" positive. Fall through to the filesystem heuristic instead: on
10
10
  // glibc systems `/lib64/ld-musl-x86_64.so.1` does not exist; on musl systems
11
11
  // it always does. statSync errors → not musl.
12
- if (
13
- typeof process.report === "object" &&
14
- typeof process.report.getReport === "function"
15
- ) {
12
+ if (typeof process.report === "object" && typeof process.report.getReport === "function") {
16
13
  const report = process.report.getReport();
17
- if (
18
- report &&
19
- report.header &&
20
- typeof report.header.glibcVersion === "string"
21
- ) {
14
+ if (report && report.header && typeof report.header.glibcVersion === "string") {
22
15
  return false;
23
16
  }
24
17
  }
@@ -47,14 +40,56 @@ const tryLoadBinding = () => {
47
40
  // Optional-dep packages are named after `napi.packageName` (npm subpackage names),
48
41
  // which inherits any scope prefix from the parent package.
49
42
  const targets = [
50
- ["linux", "x64", "gnu", "./ts-pack-core-node.linux-x64-gnu.node", "@xberg-io/tree-sitter-language-pack-linux-x64-gnu"],
51
- ["linux", "arm64", "gnu", "./ts-pack-core-node.linux-arm64-gnu.node", "@xberg-io/tree-sitter-language-pack-linux-arm64-gnu"],
52
- ["linux", "x64", "musl", "./ts-pack-core-node.linux-x64-musl.node", "@xberg-io/tree-sitter-language-pack-linux-x64-musl"],
53
- ["linux", "arm64", "musl", "./ts-pack-core-node.linux-arm64-musl.node", "@xberg-io/tree-sitter-language-pack-linux-arm64-musl"],
43
+ [
44
+ "linux",
45
+ "x64",
46
+ "gnu",
47
+ "./ts-pack-core-node.linux-x64-gnu.node",
48
+ "@xberg-io/tree-sitter-language-pack-linux-x64-gnu",
49
+ ],
50
+ [
51
+ "linux",
52
+ "arm64",
53
+ "gnu",
54
+ "./ts-pack-core-node.linux-arm64-gnu.node",
55
+ "@xberg-io/tree-sitter-language-pack-linux-arm64-gnu",
56
+ ],
57
+ [
58
+ "linux",
59
+ "x64",
60
+ "musl",
61
+ "./ts-pack-core-node.linux-x64-musl.node",
62
+ "@xberg-io/tree-sitter-language-pack-linux-x64-musl",
63
+ ],
64
+ [
65
+ "linux",
66
+ "arm64",
67
+ "musl",
68
+ "./ts-pack-core-node.linux-arm64-musl.node",
69
+ "@xberg-io/tree-sitter-language-pack-linux-arm64-musl",
70
+ ],
54
71
  ["darwin", "x64", null, "./ts-pack-core-node.darwin-x64.node", "@xberg-io/tree-sitter-language-pack-darwin-x64"],
55
- ["darwin", "arm64", null, "./ts-pack-core-node.darwin-arm64.node", "@xberg-io/tree-sitter-language-pack-darwin-arm64"],
56
- ["win32", "x64", null, "./ts-pack-core-node.win32-x64-msvc.node", "@xberg-io/tree-sitter-language-pack-win32-x64-msvc"],
57
- ["win32", "arm64", null, "./ts-pack-core-node.win32-arm64-msvc.node", "@xberg-io/tree-sitter-language-pack-win32-arm64-msvc"],
72
+ [
73
+ "darwin",
74
+ "arm64",
75
+ null,
76
+ "./ts-pack-core-node.darwin-arm64.node",
77
+ "@xberg-io/tree-sitter-language-pack-darwin-arm64",
78
+ ],
79
+ [
80
+ "win32",
81
+ "x64",
82
+ null,
83
+ "./ts-pack-core-node.win32-x64-msvc.node",
84
+ "@xberg-io/tree-sitter-language-pack-win32-x64-msvc",
85
+ ],
86
+ [
87
+ "win32",
88
+ "arm64",
89
+ null,
90
+ "./ts-pack-core-node.win32-arm64-msvc.node",
91
+ "@xberg-io/tree-sitter-language-pack-win32-arm64-msvc",
92
+ ],
58
93
  ];
59
94
 
60
95
  for (const [plat, a, abi, localPath, optionalDep] of targets) {
@@ -93,9 +128,7 @@ const tryLoadBinding = () => {
93
128
  tryLoadBinding();
94
129
 
95
130
  if (!nativeBinding) {
96
- throw new Error(
97
- `Failed to load native binding for ${platform}-${arch}. Errors: ${loadErrors.join(", ")}`
98
- );
131
+ throw new Error(`Failed to load native binding for ${platform}-${arch}. Errors: ${loadErrors.join(", ")}`);
99
132
  }
100
133
 
101
134
  module.exports = nativeBinding;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xberg-io/tree-sitter-language-pack",
3
- "version": "1.15.7",
3
+ "version": "1.16.2",
4
4
  "description": "Pre-compiled tree-sitter grammars for 371 programming languages",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -18,14 +18,14 @@
18
18
  },
19
19
  "files": ["index.js", "index.d.ts", "*.node"],
20
20
  "optionalDependencies": {
21
- "@xberg-io/tree-sitter-language-pack-linux-x64-gnu": "1.15.7",
22
- "@xberg-io/tree-sitter-language-pack-linux-arm64-gnu": "1.15.7",
23
- "@xberg-io/tree-sitter-language-pack-linux-x64-musl": "1.15.7",
24
- "@xberg-io/tree-sitter-language-pack-linux-arm64-musl": "1.15.7",
25
- "@xberg-io/tree-sitter-language-pack-darwin-x64": "1.15.7",
26
- "@xberg-io/tree-sitter-language-pack-darwin-arm64": "1.15.7",
27
- "@xberg-io/tree-sitter-language-pack-win32-x64-msvc": "1.15.7",
28
- "@xberg-io/tree-sitter-language-pack-win32-arm64-msvc": "1.15.7"
21
+ "@xberg-io/tree-sitter-language-pack-darwin-arm64": "1.16.2",
22
+ "@xberg-io/tree-sitter-language-pack-darwin-x64": "1.16.2",
23
+ "@xberg-io/tree-sitter-language-pack-linux-arm64-gnu": "1.16.2",
24
+ "@xberg-io/tree-sitter-language-pack-linux-arm64-musl": "1.16.2",
25
+ "@xberg-io/tree-sitter-language-pack-linux-x64-gnu": "1.16.2",
26
+ "@xberg-io/tree-sitter-language-pack-linux-x64-musl": "1.16.2",
27
+ "@xberg-io/tree-sitter-language-pack-win32-arm64-msvc": "1.16.2",
28
+ "@xberg-io/tree-sitter-language-pack-win32-x64-msvc": "1.16.2"
29
29
  },
30
30
  "napi": {
31
31
  "packageName": "@xberg-io/tree-sitter-language-pack",
@@ -46,7 +46,13 @@
46
46
  "artifacts": "npx --yes -p @napi-rs/cli@^3.7.3 napi artifacts",
47
47
  "prepublishOnly": "npx --yes -p @napi-rs/cli@^3.7.3 napi prepublish -t npm --skip-optional-publish"
48
48
  },
49
- "engines": { "node": ">= 22" },
50
- "publishConfig": { "access": "public" },
51
- "devDependencies": { "@napi-rs/cli": "^3.7.3" }
49
+ "engines": {
50
+ "node": ">= 22"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public"
54
+ },
55
+ "devDependencies": {
56
+ "@napi-rs/cli": "^3.8.6"
57
+ }
52
58
  }
Binary file
Binary file