@kreuzberg/tree-sitter-language-pack-wasm 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/ts_pack_wasm.d.ts +36 -0
- package/ts_pack_wasm.js +105 -0
- package/ts_pack_wasm_bg.wasm +0 -0
package/package.json
CHANGED
package/ts_pack_wasm.d.ts
CHANGED
|
@@ -41,6 +41,18 @@ export function detectLanguage(path: string): string | undefined;
|
|
|
41
41
|
*/
|
|
42
42
|
export function detectLanguageFromContent(content: string): string | undefined;
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Detect language name from a file extension (without leading dot).
|
|
46
|
+
* Returns null if the extension is not recognized.
|
|
47
|
+
*/
|
|
48
|
+
export function detectLanguageFromExtension(ext: string): string | undefined;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Detect language name from a file path.
|
|
52
|
+
* Returns null if the path has no extension or the extension is not recognized.
|
|
53
|
+
*/
|
|
54
|
+
export function detectLanguageFromPath(path: string): string | undefined;
|
|
55
|
+
|
|
44
56
|
/**
|
|
45
57
|
* Download specific languages (not supported in WASM).
|
|
46
58
|
*/
|
|
@@ -64,6 +76,17 @@ export function downloadedLanguages(): Array<any>;
|
|
|
64
76
|
*/
|
|
65
77
|
export function extensionAmbiguity(ext: string): string | undefined;
|
|
66
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Extract patterns from source code using a JavaScript config object.
|
|
81
|
+
*
|
|
82
|
+
* `config` is a JS object with fields:
|
|
83
|
+
* - `language` (string, required): the language name
|
|
84
|
+
* - `patterns` (object, required): named patterns to extract
|
|
85
|
+
*
|
|
86
|
+
* Returns a JavaScript object with the extraction results.
|
|
87
|
+
*/
|
|
88
|
+
export function extract(source: string, config: any): any;
|
|
89
|
+
|
|
67
90
|
/**
|
|
68
91
|
* Free the tree handle (called automatically by JS GC, but can be called manually).
|
|
69
92
|
*/
|
|
@@ -148,6 +171,15 @@ export function treeRootChildCount(tree: WasmTree): number;
|
|
|
148
171
|
*/
|
|
149
172
|
export function treeRootNodeType(tree: WasmTree): string;
|
|
150
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Validate extraction patterns without running them.
|
|
176
|
+
*
|
|
177
|
+
* `config` is a JS object with the same shape as for `extract`.
|
|
178
|
+
*
|
|
179
|
+
* Returns a JavaScript object with validation results.
|
|
180
|
+
*/
|
|
181
|
+
export function validateExtraction(config: any): any;
|
|
182
|
+
|
|
151
183
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
152
184
|
|
|
153
185
|
export interface InitOutput {
|
|
@@ -159,10 +191,12 @@ export interface InitOutput {
|
|
|
159
191
|
readonly configure: (a: number, b: number, c: number) => void;
|
|
160
192
|
readonly detectLanguage: (a: number, b: number, c: number) => void;
|
|
161
193
|
readonly detectLanguageFromContent: (a: number, b: number, c: number) => void;
|
|
194
|
+
readonly detectLanguageFromExtension: (a: number, b: number, c: number) => void;
|
|
162
195
|
readonly download: (a: number, b: number) => void;
|
|
163
196
|
readonly downloadAll: (a: number) => void;
|
|
164
197
|
readonly downloadedLanguages: (a: number) => void;
|
|
165
198
|
readonly extensionAmbiguity: (a: number, b: number, c: number) => void;
|
|
199
|
+
readonly extract: (a: number, b: number, c: number, d: number) => void;
|
|
166
200
|
readonly freeTree: (a: number) => void;
|
|
167
201
|
readonly getHighlightsQuery: (a: number, b: number, c: number) => void;
|
|
168
202
|
readonly getInjectionsQuery: (a: number, b: number, c: number) => void;
|
|
@@ -181,6 +215,8 @@ export interface InitOutput {
|
|
|
181
215
|
readonly treeHasErrorNodes: (a: number, b: number) => void;
|
|
182
216
|
readonly treeRootChildCount: (a: number, b: number) => void;
|
|
183
217
|
readonly treeRootNodeType: (a: number, b: number) => void;
|
|
218
|
+
readonly validateExtraction: (a: number, b: number) => void;
|
|
219
|
+
readonly detectLanguageFromPath: (a: number, b: number, c: number) => void;
|
|
184
220
|
readonly languageCount: () => number;
|
|
185
221
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
186
222
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
package/ts_pack_wasm.js
CHANGED
|
@@ -157,6 +157,56 @@ export function detectLanguageFromContent(content) {
|
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Detect language name from a file extension (without leading dot).
|
|
162
|
+
* Returns null if the extension is not recognized.
|
|
163
|
+
* @param {string} ext
|
|
164
|
+
* @returns {string | undefined}
|
|
165
|
+
*/
|
|
166
|
+
export function detectLanguageFromExtension(ext) {
|
|
167
|
+
try {
|
|
168
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
169
|
+
const ptr0 = passStringToWasm0(ext, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
170
|
+
const len0 = WASM_VECTOR_LEN;
|
|
171
|
+
wasm.detectLanguageFromExtension(retptr, ptr0, len0);
|
|
172
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
173
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
174
|
+
let v2;
|
|
175
|
+
if (r0 !== 0) {
|
|
176
|
+
v2 = getStringFromWasm0(r0, r1).slice();
|
|
177
|
+
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
178
|
+
}
|
|
179
|
+
return v2;
|
|
180
|
+
} finally {
|
|
181
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Detect language name from a file path.
|
|
187
|
+
* Returns null if the path has no extension or the extension is not recognized.
|
|
188
|
+
* @param {string} path
|
|
189
|
+
* @returns {string | undefined}
|
|
190
|
+
*/
|
|
191
|
+
export function detectLanguageFromPath(path) {
|
|
192
|
+
try {
|
|
193
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
194
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
195
|
+
const len0 = WASM_VECTOR_LEN;
|
|
196
|
+
wasm.detectLanguageFromPath(retptr, ptr0, len0);
|
|
197
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
198
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
199
|
+
let v2;
|
|
200
|
+
if (r0 !== 0) {
|
|
201
|
+
v2 = getStringFromWasm0(r0, r1).slice();
|
|
202
|
+
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
203
|
+
}
|
|
204
|
+
return v2;
|
|
205
|
+
} finally {
|
|
206
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
160
210
|
/**
|
|
161
211
|
* Download specific languages (not supported in WASM).
|
|
162
212
|
* @param {Array<any>} _languages
|
|
@@ -245,6 +295,36 @@ export function extensionAmbiguity(ext) {
|
|
|
245
295
|
}
|
|
246
296
|
}
|
|
247
297
|
|
|
298
|
+
/**
|
|
299
|
+
* Extract patterns from source code using a JavaScript config object.
|
|
300
|
+
*
|
|
301
|
+
* `config` is a JS object with fields:
|
|
302
|
+
* - `language` (string, required): the language name
|
|
303
|
+
* - `patterns` (object, required): named patterns to extract
|
|
304
|
+
*
|
|
305
|
+
* Returns a JavaScript object with the extraction results.
|
|
306
|
+
* @param {string} source
|
|
307
|
+
* @param {any} config
|
|
308
|
+
* @returns {any}
|
|
309
|
+
*/
|
|
310
|
+
export function extract(source, config) {
|
|
311
|
+
try {
|
|
312
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
313
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
314
|
+
const len0 = WASM_VECTOR_LEN;
|
|
315
|
+
wasm.extract(retptr, ptr0, len0, addHeapObject(config));
|
|
316
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
317
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
318
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
319
|
+
if (r2) {
|
|
320
|
+
throw takeObject(r1);
|
|
321
|
+
}
|
|
322
|
+
return takeObject(r0);
|
|
323
|
+
} finally {
|
|
324
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
248
328
|
/**
|
|
249
329
|
* Free the tree handle (called automatically by JS GC, but can be called manually).
|
|
250
330
|
* @param {WasmTree} _tree
|
|
@@ -569,6 +649,31 @@ export function treeRootNodeType(tree) {
|
|
|
569
649
|
wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
570
650
|
}
|
|
571
651
|
}
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Validate extraction patterns without running them.
|
|
655
|
+
*
|
|
656
|
+
* `config` is a JS object with the same shape as for `extract`.
|
|
657
|
+
*
|
|
658
|
+
* Returns a JavaScript object with validation results.
|
|
659
|
+
* @param {any} config
|
|
660
|
+
* @returns {any}
|
|
661
|
+
*/
|
|
662
|
+
export function validateExtraction(config) {
|
|
663
|
+
try {
|
|
664
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
665
|
+
wasm.validateExtraction(retptr, addHeapObject(config));
|
|
666
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
667
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
668
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
669
|
+
if (r2) {
|
|
670
|
+
throw takeObject(r1);
|
|
671
|
+
}
|
|
672
|
+
return takeObject(r0);
|
|
673
|
+
} finally {
|
|
674
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
572
677
|
import * as import1 from "env"
|
|
573
678
|
import * as import2 from "env"
|
|
574
679
|
import * as import3 from "env"
|
package/ts_pack_wasm_bg.wasm
CHANGED
|
Binary file
|