@kreuzberg/tree-sitter-language-pack 1.8.1 → 1.9.0-rc.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/README.md ADDED
@@ -0,0 +1,189 @@
1
+ # TypeScript / Node.js
2
+
3
+ <div
4
+ align="center"
5
+ style="display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 20px 0"
6
+ >
7
+ <a href="https://github.com/kreuzberg-dev/alef">
8
+ <img
9
+ src="https://img.shields.io/badge/Bindings-alef%20%D7%90-007ec6"
10
+ alt="Bindings"
11
+ />
12
+ </a>
13
+ <!-- Language Bindings -->
14
+ <a href="https://crates.io/crates/tree-sitter-language-pack">
15
+ <img
16
+ src="https://img.shields.io/crates/v/tree-sitter-language-pack?label=Rust&color=007ec6"
17
+ alt="Rust"
18
+ />
19
+ </a>
20
+ <a href="https://pypi.org/project/tree-sitter-language-pack/">
21
+ <img
22
+ src="https://img.shields.io/pypi/v/tree-sitter-language-pack?label=Python&color=007ec6"
23
+ alt="Python"
24
+ />
25
+ </a>
26
+ <a href="https://www.npmjs.com/package/@kreuzberg/tree-sitter-language-pack">
27
+ <img
28
+ src="https://img.shields.io/npm/v/@kreuzberg/tree-sitter-language-pack?label=Node.js&color=007ec6"
29
+ alt="Node.js"
30
+ />
31
+ </a>
32
+ <a href="https://www.npmjs.com/package/@kreuzberg/tree-sitter-language-pack-wasm">
33
+ <img
34
+ src="https://img.shields.io/npm/v/@kreuzberg/tree-sitter-language-pack-wasm?label=WASM&color=007ec6"
35
+ alt="WASM"
36
+ />
37
+ </a>
38
+ <a
39
+ href="https://central.sonatype.com/artifact/dev.kreuzberg.treesitterlanguagepack/tree-sitter-language-pack"
40
+ >
41
+ <img
42
+ src="https://img.shields.io/maven-central/v/dev.kreuzberg.treesitterlanguagepack/tree-sitter-language-pack?label=Java&color=007ec6"
43
+ alt="Java"
44
+ />
45
+ </a>
46
+ <a href="https://pkg.go.dev/github.com/kreuzberg-dev/tree-sitter-language-pack/packages/go">
47
+ <img
48
+ src="https://img.shields.io/github/v/tag/kreuzberg-dev/tree-sitter-language-pack?label=Go&color=007ec6"
49
+ alt="Go"
50
+ />
51
+ </a>
52
+ <a href="https://www.nuget.org/packages/TreeSitterLanguagePack/">
53
+ <img
54
+ src="https://img.shields.io/nuget/v/TreeSitterLanguagePack?label=C%23&color=007ec6"
55
+ alt="C#"
56
+ />
57
+ </a>
58
+ <a href="https://packagist.org/packages/kreuzberg/tree-sitter-language-pack">
59
+ <img
60
+ src="https://img.shields.io/packagist/v/kreuzberg/tree-sitter-language-pack?label=PHP&color=007ec6"
61
+ alt="PHP"
62
+ />
63
+ </a>
64
+ <a href="https://rubygems.org/gems/tree_sitter_language_pack">
65
+ <img
66
+ src="https://img.shields.io/gem/v/tree_sitter_language_pack?label=Ruby&color=007ec6"
67
+ alt="Ruby"
68
+ />
69
+ </a>
70
+ <a href="https://hex.pm/packages/tree_sitter_language_pack">
71
+ <img
72
+ src="https://img.shields.io/hexpm/v/tree_sitter_language_pack?label=Elixir&color=007ec6"
73
+ alt="Elixir"
74
+ />
75
+ </a>
76
+ <a href="https://pub.dev/packages/tree_sitter_language_pack">
77
+ <img
78
+ src="https://img.shields.io/pub/v/tree_sitter_language_pack?label=Dart&color=007ec6"
79
+ alt="Dart"
80
+ />
81
+ </a>
82
+ <a
83
+ href="https://central.sonatype.com/artifact/dev.kreuzberg.tslp.android/tree-sitter-language-pack-android"
84
+ >
85
+ <img
86
+ src="https://img.shields.io/maven-central/v/dev.kreuzberg.tslp.android/tree-sitter-language-pack-android?label=Kotlin&color=007ec6"
87
+ alt="Kotlin"
88
+ />
89
+ </a>
90
+ <a href="https://github.com/kreuzberg-dev/tree-sitter-language-pack/tree/main/packages/swift">
91
+ <img src="https://img.shields.io/badge/Swift-SPM-007ec6" alt="Swift" />
92
+ </a>
93
+ <a href="https://github.com/kreuzberg-dev/tree-sitter-language-pack/tree/main/packages/zig">
94
+ <img src="https://img.shields.io/badge/Zig-package-007ec6" alt="Zig" />
95
+ </a>
96
+ <a href="https://github.com/kreuzberg-dev/tree-sitter-language-pack/releases">
97
+ <img src="https://img.shields.io/badge/C-FFI-007ec6" alt="C FFI" />
98
+ </a>
99
+
100
+ <!-- Project Info -->
101
+ <a href="https://github.com/kreuzberg-dev/tree-sitter-language-pack/blob/main/LICENSE">
102
+ <img src="https://img.shields.io/badge/License-MIT-007ec6" alt="License" />
103
+ </a>
104
+ <a href="https://docs.tree-sitter-language-pack.kreuzberg.dev">
105
+ <img src="https://img.shields.io/badge/Docs-tree--sitter--language--pack-007ec6" alt="Documentation" />
106
+ </a>
107
+ </div>
108
+
109
+ <div align="center" style="margin: 24px 0 0">
110
+ <a href="https://kreuzberg.dev">
111
+ <img alt="tree-sitter-language-pack" src="https:&#x2f;&#x2f;github.com&#x2f;user-attachments&#x2f;assets&#x2f;478a83da-237b-446b-b3a8-e564c13e00a8" />
112
+ </a>
113
+ </div>
114
+
115
+ <div
116
+ align="center"
117
+ style="display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 28px 0 24px"
118
+ >
119
+ <a href="https://discord.gg/xt9WY3GnKR">
120
+ <img
121
+ height="22"
122
+ src="https://img.shields.io/badge/Discord-Chat-007ec6?logo=discord&logoColor=white"
123
+ alt="Join Discord"
124
+ />
125
+ </a>
126
+ </div>
127
+
128
+ Pre-compiled tree-sitter grammars for 305 programming languages with TypeScript types.
129
+
130
+ ## What This Package Provides
131
+
132
+ - **Parser access** — load a tree-sitter language parser by name without wiring individual grammar crates or packages.
133
+ - **Code intelligence primitives** — parse trees, functions, classes, imports, exports, symbols, docstrings, diagnostics, and syntax-aware chunks.
134
+ - **Shared cache model** — parsers are fetched and cached once, then reused by every call in the process.
135
+ - **Same catalog as every binding** — Rust, Python, Node.js, Go, Java, PHP, Ruby, .NET, Elixir, WASM, Dart, Kotlin Android, Swift, Zig, and C FFI use the same grammar set.
136
+ - **Node-first TypeScript API** — native NAPI package with typed parser and query helpers.
137
+
138
+ ## Installation
139
+
140
+
141
+ ```bash
142
+ npm install @kreuzberg/tree-sitter-language-pack
143
+ ```
144
+
145
+
146
+ ## Quick Start
147
+
148
+
149
+ ```typescript
150
+ import { getParser } from "@kreuzberg/tree-sitter-language-pack";
151
+
152
+ const parser = getParser("python");
153
+ const tree = parser.parse("def hello(): pass");
154
+ console.log(tree.rootNode.toString());
155
+ ```
156
+
157
+
158
+ ## Features
159
+
160
+ - **300+ languages** — pre-compiled tree-sitter grammars covering every major programming language and many minor ones.
161
+ - **On-demand download + cache** — parsers fetched at first use; subsequent runs hit the local cache.
162
+ - **Code intelligence** — extract functions, classes, imports, exports, symbols, docstrings, and diagnostics with one API.
163
+ - **Syntax-aware chunking** — semantic chunks for RAG/LLM pipelines.
164
+ - **Polyglot bindings** — Rust core with native bindings for Python, TypeScript, Go, Java, C#, Ruby, PHP, Elixir, and WebAssembly via [alef](https://github.com/kreuzberg-dev/alef).
165
+
166
+ ## Documentation
167
+
168
+ - **[Documentation](https://docs.tree-sitter-language-pack.kreuzberg.dev)** -- Full docs and API reference
169
+ - **[GitHub Repository](https://github.com/kreuzberg-dev/tree-sitter-language-pack)** -- Source, issues, and discussions
170
+
171
+ ## Part of Kreuzberg.dev
172
+
173
+ - [Kreuzberg](https://github.com/kreuzberg-dev/kreuzberg) — document intelligence: text, tables, metadata from 90+ formats with optional OCR.
174
+ - [Kreuzberg Cloud](https://github.com/kreuzberg-dev/kreuzberg-cloud) — managed extraction API with SDKs, dashboards, and observability.
175
+ - [kreuzcrawl](https://github.com/kreuzberg-dev/kreuzcrawl) — web crawling and scraping with HTML→Markdown and headless-Chrome fallback.
176
+ - [html-to-markdown](https://github.com/kreuzberg-dev/html-to-markdown) — fast, lossless HTML→Markdown engine.
177
+ - [liter-llm](https://github.com/kreuzberg-dev/liter-llm) — universal LLM API client with native bindings for 14 languages and 143 providers.
178
+ - [alef](https://github.com/kreuzberg-dev/alef) — the polyglot binding generator that produces this README and all per-language bindings.
179
+ - [Discord](https://discord.gg/xt9WY3GnKR) — community, roadmap, announcements.
180
+
181
+ ## Contributing
182
+
183
+ Contributions are welcome! See [CONTRIBUTING.md](https://github.com/kreuzberg-dev/tree-sitter-language-pack/blob/main/CONTRIBUTING.md) for guidelines.
184
+
185
+ Join our [Discord community](https://discord.gg/xt9WY3GnKR) for questions and discussion.
186
+
187
+ ## License
188
+
189
+ MIT -- see [LICENSE](https://github.com/kreuzberg-dev/tree-sitter-language-pack/blob/main/LICENSE) for details.
package/index.d.ts CHANGED
@@ -1,25 +1,24 @@
1
1
  // This file is auto-generated by alef — DO NOT EDIT.
2
- // alef:hash:c0ee6526b4cf3c711d551e15e38d99f287ee84b2e323e9d57925ca62c77389e0
2
+ // alef:hash:eb942221e8ed2406fb12063e817b0beb5a7403bb320401b3280c538e2b34e217
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
7
  import type { Language } from "tree-sitter";
8
8
 
9
+ export type JsonValue =
10
+ | string
11
+ | number
12
+ | boolean
13
+ | null
14
+ | JsonValue[]
15
+ | { [key: string]: JsonValue };
16
+
9
17
  /**
10
18
  * List all available language names (sorted, deduplicated, includes aliases).
11
19
  *
12
20
  * Returns names of both statically compiled and dynamically loadable languages,
13
21
  * plus any configured aliases.
14
- * @example
15
- * ```typescript
16
- * use tree_sitter_language_pack::available_languages;
17
- *
18
- * let langs = available_languages();
19
- * for name in &langs {
20
- * println!("{}", name);
21
- * }
22
- * ```typescript
23
22
  */
24
23
  export declare function availableLanguages(): Array<string>;
25
24
 
@@ -29,14 +28,6 @@ export declare function availableLanguages(): Array<string>;
29
28
  * This is either the custom path set via [`configure`] / [`init`] or the
30
29
  * default: `~/.cache/tree-sitter-language-pack/v{version}/libs/`.
31
30
  * @throws Returns an error if the system cache directory cannot be determined.
32
- *
33
- * @example
34
- * ```typescript
35
- * use tree_sitter_language_pack::cache_dir;
36
- *
37
- * let dir = cache_dir().unwrap();
38
- * println!("Cache directory: {dir}");
39
- * ```typescript
40
31
  */
41
32
  export declare function cacheDir(): string;
42
33
 
@@ -46,14 +37,6 @@ export declare function cacheDir(): string;
46
37
  * Resets the cache registration so the next call to [`get_language`] or
47
38
  * a download function will re-register the (now empty) cache directory.
48
39
  * @throws Returns an error if the cache directory cannot be removed.
49
- *
50
- * @example
51
- * ```typescript
52
- * use tree_sitter_language_pack::clean_cache;
53
- *
54
- * clean_cache().unwrap();
55
- * println!("Cache cleared");
56
- * ```typescript
57
40
  */
58
41
  export declare function cleanCache(): void;
59
42
 
@@ -65,28 +48,15 @@ export declare function cleanCache(): void;
65
48
  * after languages have been registered has no effect on already-loaded
66
49
  * languages.
67
50
  * @throws Returns an error if the lock cannot be acquired.
68
- *
69
- * @example
70
- * ```typescript
71
- * use std::path::PathBuf;
72
- * use tree_sitter_language_pack::{PackConfig, configure};
73
- *
74
- * let config = PackConfig {
75
- * cache_dir: Some(PathBuf::from("/tmp/my-parsers")),
76
- * languages: None,
77
- * groups: None,
78
- * };
79
- * configure(&config).unwrap();
80
- * ```typescript
81
51
  */
82
- export declare function configure(config: JsPackConfig): void;
52
+ export declare function configure(config: PackConfig): void;
83
53
 
84
54
  /**
85
55
  * Detect language name from a file path or extension.
86
56
  *
87
57
  * This compatibility alias matches the pre-Alef Python binding API.
88
58
  */
89
- export declare function detectLanguage(path: string): string | undefined | null;
59
+ export declare function detectLanguage(path: string): string | null;
90
60
 
91
61
  /**
92
62
  * Detect language name from file content using the shebang line (`#!`).
@@ -112,7 +82,7 @@ export declare function detectLanguage(path: string): string | undefined | null;
112
82
  * assert_eq!(detect_language_from_content("no shebang here"), None);
113
83
  * ```
114
84
  */
115
- export declare function detectLanguageFromContent(content: string): string | undefined | null;
85
+ export declare function detectLanguageFromContent(content: string): string | null;
116
86
 
117
87
  /**
118
88
  * Detect language name from a file extension (without leading dot).
@@ -126,7 +96,7 @@ export declare function detectLanguageFromContent(content: string): string | und
126
96
  * assert_eq!(detect_language_from_extension("xyz"), None);
127
97
  * ```
128
98
  */
129
- export declare function detectLanguageFromExtension(ext: string): string | undefined | null;
99
+ export declare function detectLanguageFromExtension(ext: string): string | null;
130
100
 
131
101
  /**
132
102
  * Detect language name from a file path.
@@ -141,7 +111,7 @@ export declare function detectLanguageFromExtension(ext: string): string | undef
141
111
  * assert_eq!(detect_language_from_path("Makefile"), None);
142
112
  * ```
143
113
  */
144
- export declare function detectLanguageFromPath(path: string): string | undefined | null;
114
+ export declare function detectLanguageFromPath(path: string): string | null;
145
115
 
146
116
  /**
147
117
  * Download specific languages to the local cache.
@@ -150,14 +120,6 @@ export declare function detectLanguageFromPath(path: string): string | undefined
150
120
  * compiled or cached languages are included in the count.
151
121
  * @throws Returns an error if any language is not available in the manifest or if
152
122
  * the download fails.
153
- *
154
- * @example
155
- * ```typescript
156
- * use tree_sitter_language_pack::download;
157
- *
158
- * let count = download(&["python", "rust", "typescript"]).unwrap();
159
- * println!("Ensured {} languages", count);
160
- * ```typescript
161
123
  */
162
124
  export declare function download(names: Array<string>): number;
163
125
 
@@ -172,14 +134,6 @@ export declare function download(names: Array<string>): number;
172
134
  * Returns the total number of languages now available (statically compiled
173
135
  * plus downloaded and cached).
174
136
  * @throws Returns an error if the manifest cannot be fetched or the bundle download fails.
175
- *
176
- * @example
177
- * ```typescript
178
- * use tree_sitter_language_pack::download_all;
179
- *
180
- * let count = download_all().unwrap();
181
- * println!("{} languages available", count);
182
- * ```typescript
183
137
  */
184
138
  export declare function downloadAll(): number;
185
139
 
@@ -188,50 +142,38 @@ export declare function downloadAll(): number;
188
142
  *
189
143
  * Does not perform any network requests. Returns an empty list if the
190
144
  * cache directory does not exist or cannot be read.
191
- * @example
192
- * ```typescript
193
- * use tree_sitter_language_pack::downloaded_languages;
194
- *
195
- * let langs = downloaded_languages();
196
- * println!("{} languages already cached", langs.len());
197
- * ```typescript
198
145
  */
199
146
  export declare function downloadedLanguages(): Array<string>;
200
147
 
148
+ /**
149
+ * Download every language in a named group (e.g. `"web"`, `"data"`).
150
+ *
151
+ * Groups are defined in the remote manifest and let you ensure a curated
152
+ * set of related grammars in one call instead of listing each name to
153
+ * [`download`]. Already-cached languages are skipped.
154
+ *
155
+ * Returns the total number of languages now available (statically compiled
156
+ * plus downloaded and cached).
157
+ * @throws Returns an error if the manifest cannot be fetched, the group is unknown,
158
+ * or any constituent language fails to download.
159
+ */
160
+ export declare function downloadGroup(name: string): number;
161
+
201
162
  /**
202
163
  * Get the highlights query for a language, if bundled.
203
164
  *
204
165
  * Returns the contents of `highlights.scm` as a static string, or `None`
205
166
  * if no highlights query is bundled for this language.
206
- * @example
207
- * ```typescript
208
- * use tree_sitter_language_pack::get_highlights_query;
209
- *
210
- * // Returns Some(...) for languages with bundled queries
211
- * let query = get_highlights_query("python");
212
- * // Returns None for languages without bundled highlights queries
213
- * let missing = get_highlights_query("nonexistent_lang");
214
- * assert!(missing.is_none());
215
- * ```typescript
216
167
  */
217
- export declare function getHighlightsQuery(language: string): string | undefined | null;
168
+ export declare function getHighlightsQuery(language: string): string | null;
218
169
 
219
170
  /**
220
171
  * Get the injections query for a language, if bundled.
221
172
  *
222
173
  * Returns the contents of `injections.scm` as a static string, or `None`
223
174
  * if no injections query is bundled for this language.
224
- * @example
225
- * ```typescript
226
- * use tree_sitter_language_pack::get_injections_query;
227
- *
228
- * let query = get_injections_query("markdown");
229
- * // Returns None for languages without bundled injections queries
230
- * let missing = get_injections_query("nonexistent_lang");
231
- * assert!(missing.is_none());
232
- * ```typescript
233
175
  */
234
- export declare function getInjectionsQuery(language: string): string | undefined | null;
176
+ export declare function getInjectionsQuery(language: string): string | null;
235
177
 
236
178
  /**
237
179
  * Get a tree-sitter [`Language`] by name using the global registry.
@@ -241,18 +183,6 @@ export declare function getInjectionsQuery(language: string): string | undefined
241
183
  * the parser from GitHub releases if not found locally.
242
184
  * @throws Returns [`Error::LanguageNotFound`] if the language is not recognized,
243
185
  * or [`Error::Download`] if auto-download fails.
244
- *
245
- * @example
246
- * ```typescript
247
- * use tree_sitter_language_pack::{get_language, Parser};
248
- *
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
- * assert_eq!(tree.root_node().kind(), "module");
254
- * # Ok::<(), tree_sitter_language_pack::Error>(())
255
- * ```typescript
256
186
  */
257
187
  export declare function getLanguage(name: string): Language;
258
188
 
@@ -261,17 +191,8 @@ export declare function getLanguage(name: string): Language;
261
191
  *
262
192
  * Returns the contents of `locals.scm` as a static string, or `None`
263
193
  * if no locals query is bundled for this language.
264
- * @example
265
- * ```typescript
266
- * use tree_sitter_language_pack::get_locals_query;
267
- *
268
- * let query = get_locals_query("python");
269
- * // Returns None for languages without bundled locals queries
270
- * let missing = get_locals_query("nonexistent_lang");
271
- * assert!(missing.is_none());
272
- * ```typescript
273
194
  */
274
- export declare function getLocalsQuery(language: string): string | undefined | null;
195
+ export declare function getLocalsQuery(language: string): string | null;
275
196
 
276
197
  /**
277
198
  * Get a [`Parser`] pre-configured for the given language.
@@ -280,32 +201,14 @@ export declare function getLocalsQuery(language: string): string | undefined | n
280
201
  * a new parser in one step.
281
202
  * @throws Returns [`Error::LanguageNotFound`] if the language is not recognized, or
282
203
  * [`Error::ParserSetup`] if the language cannot be applied to the parser.
283
- *
284
- * @example
285
- * ```typescript
286
- * use tree_sitter_language_pack::get_parser;
287
- *
288
- * let mut parser = get_parser("rust")?;
289
- * let tree = parser.parse("fn main() {}").expect("parse failed");
290
- * assert!(!tree.root_node().has_error());
291
- * # Ok::<(), tree_sitter_language_pack::Error>(())
292
- * ```typescript
293
204
  */
294
- export declare function getParser(name: string): JsParser;
205
+ export declare function getParser(name: string): Parser;
295
206
 
296
207
  /**
297
208
  * Check if a language is available by name or alias.
298
209
  *
299
210
  * Returns `true` if the language can be loaded (statically compiled,
300
211
  * dynamically available, or a known alias for one of these).
301
- * @example
302
- * ```typescript
303
- * use tree_sitter_language_pack::has_language;
304
- *
305
- * assert!(has_language("python"));
306
- * assert!(has_language("shell")); // alias for "bash"
307
- * assert!(!has_language("nonexistent_language"));
308
- * ```typescript
309
212
  */
310
213
  export declare function hasLanguage(name: string): boolean;
311
214
 
@@ -316,58 +219,46 @@ export declare function hasLanguage(name: string): boolean;
316
219
  * specified in the config. This is the recommended entry point when you want
317
220
  * to pre-warm the cache before use.
318
221
  * @throws Returns an error if configuration cannot be applied or if downloads fail.
319
- *
320
- * @example
321
- * ```typescript
322
- * use tree_sitter_language_pack::{PackConfig, init};
323
- *
324
- * let config = PackConfig {
325
- * cache_dir: None,
326
- * languages: Some(vec!["python".to_string(), "rust".to_string()]),
327
- * groups: None,
328
- * };
329
- * init(&config).unwrap();
330
- * ```typescript
331
222
  */
332
- export declare function init(config: JsPackConfig): void;
223
+ export declare function init(config: PackConfig): void;
333
224
 
334
225
  /** A byte range — start (inclusive) to end (exclusive). */
335
- export interface JsByteRange {
226
+ export interface ByteRange {
336
227
  /** Inclusive start byte offset. */
337
- start: number;
228
+ readonly start: number;
338
229
  /** Exclusive end byte offset. */
339
- end: number;
230
+ readonly end: number;
340
231
  }
341
232
 
342
233
  /** Metadata for a single chunk of source code. */
343
- export interface JsChunkContext {
344
- language?: string;
345
- chunkIndex?: number;
346
- totalChunks?: number;
347
- nodeTypes?: Array<string>;
348
- contextPath?: Array<string>;
349
- symbolsDefined?: Array<string>;
350
- comments?: Array<JsCommentInfo>;
351
- docstrings?: Array<JsDocstringInfo>;
352
- hasErrorNodes?: boolean;
234
+ export interface ChunkContext {
235
+ readonly language?: string;
236
+ readonly chunkIndex?: number;
237
+ readonly totalChunks?: number;
238
+ readonly nodeTypes?: Array<string>;
239
+ readonly contextPath?: Array<string>;
240
+ readonly symbolsDefined?: Array<string>;
241
+ readonly comments?: Array<CommentInfo>;
242
+ readonly docstrings?: Array<DocstringInfo>;
243
+ readonly hasErrorNodes?: boolean;
353
244
  }
354
245
 
355
246
  /** A chunk of source code with rich metadata. */
356
- export interface JsCodeChunk {
357
- content?: string;
358
- startByte?: number;
359
- endByte?: number;
360
- startLine?: number;
361
- endLine?: number;
362
- metadata?: JsChunkContext;
247
+ export interface CodeChunk {
248
+ readonly content?: string;
249
+ readonly startByte?: number;
250
+ readonly endByte?: number;
251
+ readonly startLine?: number;
252
+ readonly endLine?: number;
253
+ readonly metadata?: ChunkContext;
363
254
  }
364
255
 
365
256
  /** A comment extracted from source code. */
366
- export interface JsCommentInfo {
367
- text?: string;
368
- kind?: JsCommentKind;
369
- span?: JsSpan;
370
- associatedNode?: string;
257
+ export interface CommentInfo {
258
+ readonly text?: string;
259
+ readonly kind?: CommentKind;
260
+ readonly span?: Span;
261
+ readonly associatedNode?: string;
371
262
  }
372
263
 
373
264
  /**
@@ -376,17 +267,17 @@ export interface JsCommentInfo {
376
267
  * Distinguishes between single-line comments, block (multi-line) comments,
377
268
  * and documentation comments.
378
269
  */
379
- export declare enum JsCommentKind {
270
+ export declare enum CommentKind {
380
271
  Line = "Line",
381
272
  Block = "Block",
382
273
  Doc = "Doc",
383
274
  }
384
275
 
385
276
  /** A diagnostic (syntax error, missing node, etc.) from parsing. */
386
- export interface JsDiagnostic {
387
- message?: string;
388
- severity?: JsDiagnosticSeverity;
389
- span?: JsSpan;
277
+ export interface Diagnostic {
278
+ readonly message?: string;
279
+ readonly severity?: DiagnosticSeverity;
280
+ readonly span?: Span;
390
281
  }
391
282
 
392
283
  /**
@@ -395,17 +286,17 @@ export interface JsDiagnostic {
395
286
  * Used to classify parse errors, warnings, and informational messages
396
287
  * found in the syntax tree.
397
288
  */
398
- export declare enum JsDiagnosticSeverity {
289
+ export declare enum DiagnosticSeverity {
399
290
  Error = "Error",
400
291
  Warning = "Warning",
401
292
  Info = "Info",
402
293
  }
403
294
 
404
295
  /** A section within a docstring (e.g., Args, Returns, Raises). */
405
- export interface JsDocSection {
406
- kind?: string;
407
- name?: string;
408
- description?: string;
296
+ export interface DocSection {
297
+ readonly kind?: string;
298
+ readonly name?: string;
299
+ readonly description?: string;
409
300
  }
410
301
 
411
302
  /**
@@ -414,7 +305,7 @@ export interface JsDocSection {
414
305
  * Identifies the docstring convention used, which varies by language
415
306
  * (e.g., Python triple-quoted strings, JSDoc, Rustdoc `///` comments).
416
307
  */
417
- export declare enum JsDocstringFormat {
308
+ export declare enum DocstringFormat {
418
309
  PythonTripleQuote = "PythonTripleQuote",
419
310
  JSDoc = "JSDoc",
420
311
  Rustdoc = "Rustdoc",
@@ -424,37 +315,22 @@ export declare enum JsDocstringFormat {
424
315
  }
425
316
 
426
317
  /** A docstring extracted from source code. */
427
- export interface JsDocstringInfo {
428
- text?: string;
429
- format?: JsDocstringFormat;
430
- span?: JsSpan;
431
- associatedItem?: string;
432
- parsedSections?: Array<JsDocSection>;
318
+ export interface DocstringInfo {
319
+ readonly text?: string;
320
+ readonly format?: DocstringFormat;
321
+ readonly span?: Span;
322
+ readonly associatedItem?: string;
323
+ readonly parsedSections?: Array<DocSection>;
433
324
  }
434
325
 
435
326
  /** Manages downloading and caching of pre-built parser shared libraries. */
436
- export declare class JsDownloadManager {
327
+ export declare class DownloadManager {
437
328
  /** Create a new download manager for the given version. */
438
- static new(version: string): JsDownloadManager;
329
+ static new(version: string): DownloadManager;
439
330
  /** Create a download manager with a custom cache directory. */
440
- static withCacheDir(version: string, cacheDir: string): JsDownloadManager;
441
- /** Default cache directory: `~/.cache/tree-sitter-language-pack/v{version}/libs/` */
442
- static defaultCacheDir(version: string): string;
443
- /** Return the path to the libs cache directory. */
444
- cacheDir(): string;
331
+ static withCacheDir(version: string, cacheDir: string): DownloadManager;
445
332
  /** List languages that are already downloaded and cached. */
446
333
  installedLanguages(): Array<string>;
447
- /**
448
- * Ensure the specified languages are available in the cache.
449
- * Downloads the platform bundle if any requested languages are missing.
450
- */
451
- ensureLanguages(names: Array<string>): void;
452
- /** Ensure all languages in a named group are available. */
453
- ensureGroup(group: string): void;
454
- /** Get the expected path for a language's shared library in the cache. */
455
- libPath(name: string): string;
456
- /** Fetch the parser manifest from GitHub Releases. */
457
- fetchManifest(): JsParserManifest;
458
334
  /**
459
335
  * Download the platform bundle and extract every library file it contains.
460
336
  *
@@ -466,15 +342,24 @@ export declare class JsDownloadManager {
466
342
  * Returns the number of library files extracted (including those already cached).
467
343
  */
468
344
  downloadAllBestEffort(): number;
469
- /** Remove all cached parser libraries. */
345
+ /**
346
+ * Remove all cached parser libraries.
347
+ *
348
+ * Acquires the cross-process lock so `clean_cache` cannot race a concurrent
349
+ * downloader (avoids Windows sharing-violation errors against an in-flight
350
+ * bundle write). The `.download.lock` file itself is **not** removed — it is
351
+ * permanent infrastructure; deleting it could allow a concurrent process that
352
+ * already opened the file to continue holding a stale lock handle while a new
353
+ * process opens a fresh inode, breaking the mutual-exclusion guarantee.
354
+ */
470
355
  cleanCache(): void;
471
356
  }
472
357
 
473
358
  /** An export statement extracted from source code. */
474
- export interface JsExportInfo {
475
- name?: string;
476
- kind?: JsExportKind;
477
- span?: JsSpan;
359
+ export interface ExportInfo {
360
+ readonly name?: string;
361
+ readonly kind?: ExportKind;
362
+ readonly span?: Span;
478
363
  }
479
364
 
480
365
  /**
@@ -482,36 +367,31 @@ export interface JsExportInfo {
482
367
  *
483
368
  * Covers named exports, default exports, and re-exports from other modules.
484
369
  */
485
- export declare enum JsExportKind {
370
+ export declare enum ExportKind {
486
371
  Named = "Named",
487
372
  Default = "Default",
488
373
  ReExport = "ReExport",
489
374
  }
490
375
 
491
376
  /** Aggregate metrics for a source file. */
492
- export interface JsFileMetrics {
493
- totalLines?: number;
494
- codeLines?: number;
495
- commentLines?: number;
496
- blankLines?: number;
497
- totalBytes?: number;
498
- nodeCount?: number;
499
- errorCount?: number;
500
- maxDepth?: number;
377
+ export interface FileMetrics {
378
+ readonly totalLines?: number;
379
+ readonly codeLines?: number;
380
+ readonly commentLines?: number;
381
+ readonly blankLines?: number;
382
+ readonly totalBytes?: number;
383
+ readonly nodeCount?: number;
384
+ readonly errorCount?: number;
385
+ readonly maxDepth?: number;
501
386
  }
502
387
 
503
388
  /** An import statement extracted from source code. */
504
- export interface JsImportInfo {
505
- source?: string;
506
- items?: Array<string>;
507
- alias?: string;
508
- isWildcard?: boolean;
509
- span?: JsSpan;
510
- }
511
-
512
- export interface JsLanguageInfo {
513
- group: string;
514
- size: number;
389
+ export interface ImportInfo {
390
+ readonly source?: string;
391
+ readonly items?: Array<string>;
392
+ readonly alias?: string;
393
+ readonly isWildcard?: boolean;
394
+ readonly span?: Span;
515
395
  }
516
396
 
517
397
  /**
@@ -521,39 +401,8 @@ export interface JsLanguageInfo {
521
401
  * Use [`LanguageRegistry::new()`] for the default registry, or access the
522
402
  * global instance via the module-level convenience functions
523
403
  * (`get_language`, `available_languages`, etc.).
524
- * @example
525
- * ```typescript
526
- * use tree_sitter_language_pack::{LanguageRegistry, ProcessConfig};
527
- *
528
- * let registry = LanguageRegistry::new();
529
- * let langs = registry.available_languages();
530
- * println!("Available: {:?}", langs);
531
- *
532
- * let config = ProcessConfig::new("python").all();
533
- * let result = registry.process("def hello(): pass", &config).unwrap();
534
- * println!("Structure: {:?}", result.structure);
535
- * ```typescript
536
404
  */
537
- export declare class JsLanguageRegistry {
538
- /**
539
- * Create a registry with a custom directory for dynamic libraries.
540
- *
541
- * Overrides the default build-time library directory. Useful when
542
- * dynamic grammar shared libraries are stored in a non-standard location.
543
- */
544
- static withLibsDir(libsDir: string): JsLanguageRegistry;
545
- /**
546
- * Add an additional directory to search for dynamic libraries.
547
- *
548
- * When [`get_language`](Self::get_language) cannot find a grammar in the
549
- * primary library directory, it searches these extra directories in order.
550
- * Typically used by the download system to register its cache directory.
551
- *
552
- * Takes `&self` (not `&mut self`) because `extra_lib_dirs` uses interior
553
- * mutability via an `Arc<RwLock<...>>`, so the outer registry can remain
554
- * immutable while the directory list is updated.
555
- */
556
- addExtraLibsDir(dir: string): void;
405
+ export declare class LanguageRegistry {
557
406
  /**
558
407
  * Get a tree-sitter [`Language`] by name.
559
408
  *
@@ -581,8 +430,8 @@ export declare class JsLanguageRegistry {
581
430
  /** Return the total number of available languages (including aliases). */
582
431
  languageCount(): number;
583
432
  /** Parse source code and extract file intelligence based on config in a single pass. */
584
- process(source: string, config: JsProcessConfig): JsProcessResult;
585
- static default(): JsLanguageRegistry;
433
+ process(source: string, config: ProcessConfig): ProcessResult;
434
+ static default(): LanguageRegistry;
586
435
  }
587
436
 
588
437
  /**
@@ -591,11 +440,17 @@ export declare class JsLanguageRegistry {
591
440
  * Nodes hold a strong reference to their parent tree so they remain valid
592
441
  * regardless of how the tree is moved or stored at the FFI boundary.
593
442
  */
594
- export declare class JsNode {
595
- clone(): JsNode;
443
+ export declare class Node {
444
+ clone(): Node;
596
445
  /** Return the node's kind name (e.g. `"function_definition"`). */
597
446
  kind(): string;
598
- /** Return the node's numeric kind ID. */
447
+ /**
448
+ * Return the node's numeric kind ID.
449
+ *
450
+ * Tree-sitter assigns a stable `u16` ID to every node kind in a grammar
451
+ * (e.g. `"function_definition" → 42`). Comparing `kind_id()` is cheaper
452
+ * than comparing the string [`kind()`](Self::kind) in tight AST loops.
453
+ */
599
454
  kindId(): number;
600
455
  /** Return the inclusive start byte offset of this node. */
601
456
  startByte(): number;
@@ -607,11 +462,11 @@ export declare class JsNode {
607
462
  * Callers should slice their own source bytes — this is a zero-copy
608
463
  * text accessor.
609
464
  */
610
- byteRange(): JsByteRange;
465
+ byteRange(): ByteRange;
611
466
  /** Return the start [`Point`] (row, column). */
612
- startPosition(): JsPoint;
467
+ startPosition(): Point;
613
468
  /** Return the end [`Point`] (row, column). */
614
- endPosition(): JsPoint;
469
+ endPosition(): Point;
615
470
  /** True when this node is named (not punctuation/whitespace). */
616
471
  isNamed(): boolean;
617
472
  /** True when this is an error node. */
@@ -623,21 +478,21 @@ export declare class JsNode {
623
478
  /** True when this node or any descendant is an error. */
624
479
  hasError(): boolean;
625
480
  /** Return this node's parent, if any. */
626
- parent(): JsNode | undefined | null;
481
+ parent(): Node | null;
627
482
  /** Return the i-th child of this node, if any. */
628
- child(index: number): JsNode | undefined | null;
483
+ child(index: number): Node | null;
629
484
  /** Total number of children (including unnamed). */
630
485
  childCount(): number;
631
486
  /** Return the i-th named child of this node, if any. */
632
- namedChild(index: number): JsNode | undefined | null;
487
+ namedChild(index: number): Node | null;
633
488
  /** Number of named children of this node. */
634
489
  namedChildCount(): number;
635
490
  /** Look up a child by its grammar-defined field name. */
636
- childByFieldName(name: string): JsNode | undefined | null;
491
+ childByFieldName(name: string): Node | null;
637
492
  /** Return the S-expression form of this node's subtree. */
638
493
  toSexp(): string;
639
494
  /** Return a [`TreeCursor`] positioned at this node. */
640
- walk(): JsTreeCursor;
495
+ walk(): TreeCursor;
641
496
  }
642
497
 
643
498
  /**
@@ -646,48 +501,26 @@ export declare class JsNode {
646
501
  * Controls cache directory and which languages to pre-download.
647
502
  * Can be loaded from a TOML file, constructed programmatically,
648
503
  * or passed as a dict/object from language bindings.
649
- * @example
650
- * ```typescript
651
- * use tree_sitter_language_pack::PackConfig;
652
- *
653
- * let config = PackConfig {
654
- * cache_dir: None,
655
- * languages: Some(vec!["python".to_string(), "rust".to_string()]),
656
- * groups: None,
657
- * };
658
- * ```typescript
659
- */
660
- export interface JsPackConfig {
504
+ */
505
+ export interface PackConfig {
661
506
  /**
662
507
  * Override default cache directory.
663
508
  *
664
509
  * Default: `~/.cache/tree-sitter-language-pack/v{version}/libs/`
665
510
  */
666
- cacheDir?: string;
511
+ readonly cacheDir?: string;
667
512
  /**
668
513
  * Languages to pre-download on init.
669
514
  *
670
515
  * Each entry is a language name (e.g. `"python"`, `"rust"`).
671
516
  */
672
- languages?: Array<string>;
517
+ readonly languages?: Array<string>;
673
518
  /** Language groups to pre-download (e.g. `"web"`, `"systems"`, `"scripting"`). */
674
- groups?: Array<string>;
519
+ readonly groups?: Array<string>;
675
520
  }
676
521
 
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 {
522
+ /** A tree-sitter parser configured for one language at a time. */
523
+ export declare class Parser {
691
524
  /**
692
525
  * Configure the parser to use the language identified by name (e.g. `"python"`).
693
526
  *
@@ -701,79 +534,52 @@ export declare class JsParser {
701
534
  * Parse a UTF-8 source string. Returns `None` if parsing was cancelled
702
535
  * or no language is set.
703
536
  */
704
- parse(source: string): JsTree | undefined | null;
537
+ parse(source: string): Tree | null;
705
538
  /**
706
539
  * Parse a raw byte slice. Returns `None` if parsing was cancelled or
707
540
  * no language is set.
708
541
  */
709
- parseBytes(source: Uint8Array): JsTree | undefined | null;
542
+ parseBytes(source: Uint8Array): Tree | null;
710
543
  /**
711
544
  * Reset internal state. The next call to [`parse`](Self::parse) will
712
545
  * not be incremental.
713
546
  */
714
547
  reset(): void;
715
- static default(): JsParser;
716
- }
717
-
718
- /** Manifest describing available parser downloads for a specific version. */
719
- export interface JsParserManifest {
720
- version: string;
721
- platforms: Record<string, JsPlatformBundle>;
722
- languages: Record<string, JsLanguageInfo>;
723
- groups: Record<string, Array<string>>;
724
- }
725
-
726
- export interface JsPlatformBundle {
727
- url: string;
728
- sha256: string;
729
- size: number;
548
+ static default(): Parser;
730
549
  }
731
550
 
732
551
  /** A source position — row + column, zero-indexed. */
733
- export interface JsPoint {
552
+ export interface Point {
734
553
  /** Zero-indexed row number. */
735
- row: number;
554
+ readonly row: number;
736
555
  /** Zero-indexed column number, in UTF-16 code units. */
737
- column: number;
556
+ readonly column: number;
738
557
  }
739
558
 
740
559
  /**
741
560
  * Configuration for the `process()` function.
742
561
  *
743
562
  * Controls which analysis features are enabled and whether chunking is performed.
744
- * @example
745
- * ```typescript
746
- * use tree_sitter_language_pack::ProcessConfig;
747
- *
748
- * // Defaults: structure + imports + exports enabled
749
- * let config = ProcessConfig::new("python");
750
- *
751
- * // With chunking
752
- * let config = ProcessConfig::new("python").with_chunking(1000);
753
- *
754
- * // Everything enabled
755
- * let config = ProcessConfig::new("python").all();
756
- * ```typescript
757
563
  */
758
- export interface JsProcessConfig {
564
+ export interface ProcessConfig {
759
565
  /** Language name (required). */
760
- language?: string;
566
+ readonly language?: string;
761
567
  /** Extract structural items (functions, classes, etc.). Default: true. */
762
- structure?: boolean;
568
+ readonly structure?: boolean;
763
569
  /** Extract import statements. Default: true. */
764
- imports?: boolean;
570
+ readonly imports?: boolean;
765
571
  /** Extract export statements. Default: true. */
766
- exports?: boolean;
572
+ readonly exports?: boolean;
767
573
  /** Extract comments. Default: false. */
768
- comments?: boolean;
574
+ readonly comments?: boolean;
769
575
  /** Extract docstrings. Default: false. */
770
- docstrings?: boolean;
576
+ readonly docstrings?: boolean;
771
577
  /** Extract symbol definitions. Default: false. */
772
- symbols?: boolean;
578
+ readonly symbols?: boolean;
773
579
  /** Include parse diagnostics. Default: false. */
774
- diagnostics?: boolean;
580
+ readonly diagnostics?: boolean;
775
581
  /** Maximum chunk size in bytes. `None` disables chunking. */
776
- chunkMaxSize?: number;
582
+ readonly chunkMaxSize?: number;
777
583
  }
778
584
 
779
585
  /**
@@ -796,17 +602,17 @@ export interface JsProcessConfig {
796
602
  * - `diagnostics` - Parse errors (when `config.diagnostics = true`)
797
603
  * - `chunks` - Chunked code segments (when `config.chunk_max_size` is set)
798
604
  */
799
- export interface JsProcessResult {
800
- language?: string;
801
- metrics?: JsFileMetrics;
802
- structure?: Array<JsStructureItem>;
803
- imports?: Array<JsImportInfo>;
804
- exports?: Array<JsExportInfo>;
805
- comments?: Array<JsCommentInfo>;
806
- docstrings?: Array<JsDocstringInfo>;
807
- symbols?: Array<JsSymbolInfo>;
808
- diagnostics?: Array<JsDiagnostic>;
809
- chunks?: Array<JsCodeChunk>;
605
+ export interface ProcessResult {
606
+ readonly language?: string;
607
+ readonly metrics?: FileMetrics;
608
+ readonly structure?: Array<StructureItem>;
609
+ readonly imports?: Array<ImportInfo>;
610
+ readonly exports?: Array<ExportInfo>;
611
+ readonly comments?: Array<CommentInfo>;
612
+ readonly docstrings?: Array<DocstringInfo>;
613
+ readonly symbols?: Array<SymbolInfo>;
614
+ readonly diagnostics?: Array<Diagnostic>;
615
+ readonly chunks?: Array<CodeChunk>;
810
616
  }
811
617
 
812
618
  /**
@@ -815,26 +621,26 @@ export interface JsProcessResult {
815
621
  * Represents both byte offsets (for slicing) and human-readable line/column
816
622
  * positions (for display and diagnostics).
817
623
  */
818
- export interface JsSpan {
819
- startByte?: number;
820
- endByte?: number;
821
- startLine?: number;
822
- startColumn?: number;
823
- endLine?: number;
824
- endColumn?: number;
624
+ export interface Span {
625
+ readonly startByte?: number;
626
+ readonly endByte?: number;
627
+ readonly startLine?: number;
628
+ readonly startColumn?: number;
629
+ readonly endLine?: number;
630
+ readonly endColumn?: number;
825
631
  }
826
632
 
827
633
  /** A structural item (function, class, struct, etc.) in source code. */
828
- export interface JsStructureItem {
829
- kind?: JsStructureKind;
830
- name?: string;
831
- visibility?: string;
832
- span?: JsSpan;
833
- children?: Array<JsStructureItem>;
834
- decorators?: Array<string>;
835
- docComment?: string;
836
- signature?: string;
837
- bodySpan?: JsSpan;
634
+ export interface StructureItem {
635
+ readonly kind?: StructureKind;
636
+ readonly name?: string;
637
+ readonly visibility?: string;
638
+ readonly span?: Span;
639
+ readonly children?: Array<StructureItem>;
640
+ readonly decorators?: Array<string>;
641
+ readonly docComment?: string;
642
+ readonly signature?: string;
643
+ readonly bodySpan?: Span;
838
644
  }
839
645
 
840
646
  /**
@@ -844,7 +650,7 @@ export interface JsStructureItem {
844
650
  * structs, enums, traits, and more. Use [`Other`](StructureKind::Other) for
845
651
  * language-specific constructs that do not fit a standard category.
846
652
  */
847
- export declare enum JsStructureKind {
653
+ export declare enum StructureKind {
848
654
  Function = "Function",
849
655
  Method = "Method",
850
656
  Class = "Class",
@@ -859,12 +665,12 @@ export declare enum JsStructureKind {
859
665
  }
860
666
 
861
667
  /** A symbol (variable, function, type, etc.) extracted from source code. */
862
- export interface JsSymbolInfo {
863
- name?: string;
864
- kind?: JsSymbolKind;
865
- span?: JsSpan;
866
- typeAnnotation?: string;
867
- doc?: string;
668
+ export interface SymbolInfo {
669
+ readonly name?: string;
670
+ readonly kind?: SymbolKind;
671
+ readonly span?: Span;
672
+ readonly typeAnnotation?: string;
673
+ readonly doc?: string;
868
674
  }
869
675
 
870
676
  /**
@@ -873,7 +679,7 @@ export interface JsSymbolInfo {
873
679
  * Categorizes symbol definitions such as variables, constants, functions,
874
680
  * classes, types, interfaces, enums, and modules.
875
681
  */
876
- export declare enum JsSymbolKind {
682
+ export declare enum SymbolKind {
877
683
  Variable = "Variable",
878
684
  Constant = "Constant",
879
685
  Function = "Function",
@@ -886,17 +692,17 @@ export declare enum JsSymbolKind {
886
692
  }
887
693
 
888
694
  /** A parsed syntax tree. Cheap to clone (refcount bump). */
889
- export declare class JsTree {
695
+ export declare class Tree {
890
696
  /** Return the root [`Node`] of this tree. */
891
- rootNode(): JsNode;
697
+ rootNode(): Node;
892
698
  /** Return a [`TreeCursor`] positioned at the root. */
893
- walk(): JsTreeCursor;
699
+ walk(): TreeCursor;
894
700
  }
895
701
 
896
702
  /** A cursor for traversing a [`Tree`]. */
897
- export declare class JsTreeCursor {
703
+ export declare class TreeCursor {
898
704
  /** Return the [`Node`] at the cursor's current position. */
899
- node(): JsNode;
705
+ node(): Node;
900
706
  /**
901
707
  * Move the cursor to the first child of the current node.
902
708
  * Returns `true` if a child existed.
@@ -913,7 +719,7 @@ export declare class JsTreeCursor {
913
719
  */
914
720
  gotoNextSibling(): boolean;
915
721
  /** Return the field name for the current node, if any. */
916
- fieldName(): string | undefined | null;
722
+ fieldName(): string | null;
917
723
  }
918
724
 
919
725
  /**
@@ -921,13 +727,6 @@ export declare class JsTreeCursor {
921
727
  *
922
728
  * Includes statically compiled languages, dynamically loadable languages,
923
729
  * and aliases.
924
- * @example
925
- * ```typescript
926
- * use tree_sitter_language_pack::language_count;
927
- *
928
- * let count = language_count();
929
- * println!("{} languages available", count);
930
- * ```typescript
931
730
  */
932
731
  export declare function languageCount(): number;
933
732
 
@@ -938,14 +737,6 @@ export declare function languageCount(): number;
938
737
  * downloadable languages. Use [`downloaded_languages`] to list what is
939
738
  * already cached locally.
940
739
  * @throws Returns an error if the manifest cannot be fetched.
941
- *
942
- * @example
943
- * ```typescript
944
- * use tree_sitter_language_pack::manifest_languages;
945
- *
946
- * let langs = manifest_languages().unwrap();
947
- * println!("{} languages available for download", langs.len());
948
- * ```typescript
949
740
  */
950
741
  export declare function manifestLanguages(): Array<string>;
951
742
 
@@ -956,16 +747,5 @@ export declare function manifestLanguages(): Array<string>;
956
747
  * exports, comments, docstrings, symbols, diagnostics, and/or chunks based on
957
748
  * the flags set in [`ProcessConfig`].
958
749
  * @throws Returns an error if the language is not found or parsing fails.
959
- *
960
- * @example
961
- * ```typescript
962
- * use tree_sitter_language_pack::{ProcessConfig, process};
963
- *
964
- * let config = ProcessConfig::new("python").all();
965
- * let result = process("def hello(): pass", &config).unwrap();
966
- * println!("Language: {}", result.language);
967
- * println!("Lines: {}", result.metrics.total_lines);
968
- * println!("Structures: {}", result.structure.len());
969
- * ```typescript
970
750
  */
971
- export declare function process(source: string, config: JsProcessConfig): JsProcessResult;
751
+ export declare function process(source: string, config: ProcessConfig): ProcessResult;
package/index.js CHANGED
@@ -3,14 +3,18 @@
3
3
  const { platform, arch } = process;
4
4
  const isWindows = platform === "win32";
5
5
  const isMusl = () => {
6
+ // Prefer the report-header `glibcVersion` string when present — fastest and
7
+ // unambiguous on Node builds that populate it. On Node 22+, certain CI
8
+ // environments leave `glibcVersion` undefined even on glibc systems, so the
9
+ // `=== undefined` branch from older napi-rs templates produces a false
10
+ // "is musl" positive. Fall through to the filesystem heuristic instead: on
11
+ // glibc systems `/lib64/ld-musl-x86_64.so.1` does not exist; on musl systems
12
+ // it always does. statSync errors → not musl.
6
13
  if (typeof process.report === "object" && typeof process.report.getReport === "function") {
7
14
  const report = process.report.getReport();
8
15
  if (report && report.header && typeof report.header.glibcVersion === "string") {
9
16
  return false;
10
17
  }
11
- if (report && report.header && report.header.glibcVersion === undefined) {
12
- return true;
13
- }
14
18
  }
15
19
  try {
16
20
  require("fs").statSync("/lib64/ld-musl-x86_64.so.1");
package/package.json CHANGED
@@ -1,20 +1,8 @@
1
1
  {
2
2
  "name": "@kreuzberg/tree-sitter-language-pack",
3
- "version": "1.8.1",
4
- "description": "Tree-sitter language pack - pre-compiled parsers for 305 languages (Node.js NAPI bindings)",
5
- "keywords": [
6
- "kreuzberg",
7
- "language-pack",
8
- "napi",
9
- "parser",
10
- "syntax",
11
- "tree-sitter"
12
- ],
3
+ "version": "1.9.0-rc.1",
4
+ "description": "Pre-compiled tree-sitter grammars for 305 programming languages",
13
5
  "license": "MIT",
14
- "repository": {
15
- "type": "git",
16
- "url": "https://github.com/kreuzberg-dev/tree-sitter-language-pack"
17
- },
18
6
  "files": [
19
7
  "index.js",
20
8
  "index.d.ts",
@@ -22,38 +10,26 @@
22
10
  ],
23
11
  "main": "index.js",
24
12
  "types": "index.d.ts",
25
- "publishConfig": {
26
- "access": "public",
27
- "registry": "https://registry.npmjs.org/"
28
- },
29
13
  "scripts": {
30
- "artifacts": "napi artifacts",
31
14
  "build": "napi build --platform --release",
15
+ "artifacts": "napi artifacts",
32
16
  "prepublishOnly": "napi prepublish -t npm --skip-optional-publish"
33
17
  },
34
18
  "devDependencies": {
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
- }
19
+ "@napi-rs/cli": "^3.6.2"
45
20
  },
46
21
  "napi": {
47
22
  "binaryName": "ts-pack-core-node",
48
23
  "targets": [
49
- "aarch64-apple-darwin",
50
24
  "x86_64-unknown-linux-gnu",
51
25
  "aarch64-unknown-linux-gnu",
26
+ "x86_64-apple-darwin",
27
+ "aarch64-apple-darwin",
52
28
  "x86_64-pc-windows-msvc",
53
29
  "aarch64-pc-windows-msvc"
54
30
  ]
55
31
  },
56
32
  "engines": {
57
- "node": ">= 16"
33
+ "node": ">= 18"
58
34
  }
59
35
  }
Binary file