@kreuzberg/tree-sitter-language-pack 1.0.0-rc.3

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,100 @@
1
+ <!-- Generated by scripts/generate_readme.py. DO NOT EDIT. -->
2
+
3
+ # Node.js
4
+
5
+ <div align="center" style="display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 20px 0;">
6
+ <!-- Language Bindings --> <a href="https://crates.io/crates/tree-sitter-language-pack">
7
+ <img src="https://img.shields.io/crates/v/tree-sitter-language-pack?label=Rust&color=007ec6" alt="Rust">
8
+ </a> <a href="https://pypi.org/project/tree-sitter-language-pack/">
9
+ <img src="https://img.shields.io/pypi/v/tree-sitter-language-pack?label=Python&color=007ec6" alt="Python">
10
+ </a> <a href="https://www.npmjs.com/package/@kreuzberg/tree-sitter-language-pack">
11
+ <img src="https://img.shields.io/npm/v/@kreuzberg/tree-sitter-language-pack?label=Node.js&color=007ec6" alt="Node">
12
+ </a> <a href="https://github.com/kreuzberg-dev/tree-sitter-language-pack/tree/main/packages/go/v1">
13
+ <img src="https://img.shields.io/github/v/tag/kreuzberg-dev/tree-sitter-language-pack?label=Go&color=007ec6" alt="Go">
14
+ </a> <a href="https://central.sonatype.com/artifact/dev.kreuzberg/tree-sitter-language-pack">
15
+ <img src="https://img.shields.io/maven-central/v/dev.kreuzberg/tree-sitter-language-pack?label=Java&color=007ec6" alt="Java">
16
+ </a> <a href="https://hex.pm/packages/tree_sitter_language_pack">
17
+ <img src="https://img.shields.io/hexpm/v/tree_sitter_language_pack?label=Elixir&color=007ec6" alt="Elixir">
18
+ </a> <a href="https://rubygems.org/gems/tree_sitter_language_pack">
19
+ <img src="https://img.shields.io/gem/v/tree_sitter_language_pack?label=Ruby&color=007ec6" alt="Ruby">
20
+ </a> <a href="https://www.npmjs.com/package/@kreuzberg/tree-sitter-language-pack-wasm">
21
+ <img src="https://img.shields.io/npm/v/@kreuzberg/tree-sitter-language-pack-wasm?label=WASM&color=007ec6" alt="Wasm">
22
+ </a> <a href="https://packagist.org/packages/kreuzberg/tree-sitter-language-pack">
23
+ <img src="https://img.shields.io/packagist/v/kreuzberg/tree-sitter-language-pack?label=PHP&color=007ec6" alt="Php">
24
+ </a> <a href="https://www.nuget.org/packages/TreeSitterLanguagePack">
25
+ <img src="https://img.shields.io/nuget/v/TreeSitterLanguagePack?label=C%23&color=007ec6" alt="Csharp">
26
+ </a>
27
+ <!-- Project Info -->
28
+ <a href="https://github.com/kreuzberg-dev/tree-sitter-language-pack/actions">
29
+ <img src="https://img.shields.io/github/actions/workflow/status/kreuzberg-dev/tree-sitter-language-pack/ci.yaml?branch=main&label=CI" alt="CI">
30
+ </a>
31
+ <a href="https://github.com/kreuzberg-dev/tree-sitter-language-pack/blob/main/LICENSE">
32
+ <img src="https://img.shields.io/badge/License-MIT%20%7C%20Apache--2.0-blue" alt="License">
33
+ </a>
34
+ </div>
35
+
36
+ <div align="center">
37
+ <a href="https://discord.gg/xt9WY3GnKR">
38
+ <img height="22" src="https://img.shields.io/badge/Discord-Join%20our%20community-7289da?logo=discord&logoColor=white" alt="Discord">
39
+ </a>
40
+ </div>
41
+
42
+ Node.js NAPI bindings for tree-sitter-language-pack.
43
+
44
+ ## Installation
45
+
46
+ ```sh
47
+ npm install @kreuzberg/tree-sitter-language-pack
48
+ ```
49
+
50
+ ```sh
51
+ pnpm add @kreuzberg/tree-sitter-language-pack
52
+ ```
53
+
54
+ ```sh
55
+ yarn add @kreuzberg/tree-sitter-language-pack
56
+ ```
57
+
58
+ ## Quick Start
59
+
60
+ ```javascript
61
+ const { availableLanguages, hasLanguage, getLanguagePtr } = require("@kreuzberg/tree-sitter-language-pack");
62
+
63
+ console.log(availableLanguages());
64
+ console.log(hasLanguage("python")); // true
65
+
66
+ const { process } = require('@kreuzberg/tree-sitter-language-pack');
67
+
68
+ const result = process('function hello() {}', { language: 'javascript' });
69
+ console.log('Functions:', result.structure.length);
70
+
71
+ // With chunking
72
+ const result2 = process(source, { language: 'javascript', chunkMaxSize: 1000 });
73
+ console.log('Chunks:', result2.chunks.length);
74
+ ```
75
+
76
+ ## API Reference
77
+
78
+ ### Language Discovery
79
+
80
+ - `available_languages()` -- list all supported language names
81
+ - `has_language(name)` -- check if a language is available
82
+ - `language_count()` -- total number of supported languages
83
+
84
+ ### Parsing
85
+
86
+ - `get_parser(name)` / `parse_string(source, language)` -- parse source code into a syntax tree
87
+
88
+ ### Intelligence
89
+
90
+ - `process(source, config)` -- extract structured analysis (functions, classes, imports, comments, chunks) from source code
91
+
92
+ For detailed API documentation, see the [Node.js package](https://github.com/kreuzberg-dev/tree-sitter-language-pack/tree/main/crates/ts-pack-node).
93
+
94
+ ## License
95
+
96
+ MIT OR Apache-2.0 -- see [LICENSE](https://github.com/kreuzberg-dev/tree-sitter-language-pack/blob/main/LICENSE) for details.
97
+
98
+ ---
99
+
100
+ Part of [tree-sitter-language-pack](https://github.com/kreuzberg-dev/tree-sitter-language-pack) -- A comprehensive collection of tree-sitter language parsers with polyglot bindings.
package/index.d.ts ADDED
@@ -0,0 +1,65 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+
4
+ export declare class ExternalObject<T> {
5
+ readonly "": {
6
+ readonly "": unique symbol;
7
+ [K: symbol]: T;
8
+ };
9
+ }
10
+ /** Returns an array of all available language names. */
11
+ export declare function availableLanguages(): Array<string>;
12
+
13
+ /**
14
+ * Returns the raw TSLanguage pointer for interop with node-tree-sitter.
15
+ *
16
+ * Throws an error if the language is not found.
17
+ */
18
+ export declare function getLanguagePtr(name: string): number;
19
+
20
+ /** Checks whether a language with the given name is available. */
21
+ export declare function hasLanguage(name: string): boolean;
22
+
23
+ /** Returns the number of available languages. */
24
+ export declare function languageCount(): number;
25
+
26
+ /**
27
+ * Parse a source string using the named language and return an opaque tree handle.
28
+ *
29
+ * Throws an error if the language is not found or parsing fails.
30
+ */
31
+ export declare function parseString(
32
+ language: string,
33
+ source: string,
34
+ ): ExternalObject<Tree>;
35
+
36
+ /** Check whether any node in the tree has the given type name. */
37
+ export declare function treeContainsNodeType(
38
+ tree: ExternalObject<Tree>,
39
+ nodeType: string,
40
+ ): boolean;
41
+
42
+ /** Check whether the tree contains any ERROR or MISSING nodes. */
43
+ export declare function treeHasErrorNodes(tree: ExternalObject<Tree>): boolean;
44
+
45
+ /** Get the number of named children of the root node. */
46
+ export declare function treeRootChildCount(tree: ExternalObject<Tree>): number;
47
+
48
+ /** Get the type name of the root node. */
49
+ export declare function treeRootNodeType(tree: ExternalObject<Tree>): string;
50
+
51
+ /** Process source code and extract file intelligence as a JavaScript object. */
52
+ export declare function process(
53
+ source: string,
54
+ config: {
55
+ language: string;
56
+ structure?: boolean;
57
+ imports?: boolean;
58
+ exports?: boolean;
59
+ comments?: boolean;
60
+ docstrings?: boolean;
61
+ symbols?: boolean;
62
+ diagnostics?: boolean;
63
+ chunkMaxSize?: number;
64
+ },
65
+ ): Record<string, unknown>;
package/index.js ADDED
@@ -0,0 +1,32 @@
1
+ /* eslint-disable no-undef */
2
+
3
+ const { platform, arch } = process;
4
+
5
+ const PLATFORM_ARCH = `${platform}-${arch}`;
6
+
7
+ const NATIVE_BINDING_MAP = {
8
+ "darwin-x64": "ts-pack-node.darwin-x64.node",
9
+ "darwin-arm64": "ts-pack-node.darwin-arm64.node",
10
+ "linux-x64": "ts-pack-node.linux-x64-gnu.node",
11
+ "linux-arm64": "ts-pack-node.linux-arm64-gnu.node",
12
+ "win32-x64": "ts-pack-node.win32-x64-msvc.node",
13
+ "win32-arm64": "ts-pack-node.win32-arm64-msvc.node",
14
+ };
15
+
16
+ let native;
17
+
18
+ const bindingFile = NATIVE_BINDING_MAP[PLATFORM_ARCH];
19
+
20
+ if (bindingFile) {
21
+ try {
22
+ native = require(`./${bindingFile}`);
23
+ } catch {
24
+ // Fall back to unqualified name (local dev builds)
25
+ native = require("./ts-pack-node.node");
26
+ }
27
+ } else {
28
+ // Fall back to unqualified name for unknown platforms
29
+ native = require("./ts-pack-node.node");
30
+ }
31
+
32
+ module.exports = native;
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@kreuzberg/tree-sitter-language-pack",
3
+ "version": "1.0.0-rc.3",
4
+ "description": "Tree-sitter language pack - pre-compiled parsers for 170+ languages (Node.js NAPI bindings)",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "files": [
8
+ "index.js",
9
+ "index.d.ts",
10
+ "*.node"
11
+ ],
12
+ "napi": {
13
+ "binaryName": "ts-pack-node",
14
+ "targets": [
15
+ "x86_64-apple-darwin",
16
+ "aarch64-apple-darwin",
17
+ "x86_64-unknown-linux-gnu",
18
+ "aarch64-unknown-linux-gnu",
19
+ "x86_64-pc-windows-msvc"
20
+ ]
21
+ },
22
+ "engines": {
23
+ "node": ">= 16"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/kreuzberg-dev/tree-sitter-language-pack"
28
+ },
29
+ "keywords": [
30
+ "tree-sitter",
31
+ "parser",
32
+ "syntax",
33
+ "napi",
34
+ "language-pack",
35
+ "kreuzberg"
36
+ ],
37
+ "license": "MIT OR Apache-2.0"
38
+ }
Binary file