@willbooster/web-tree-sitter 10.0.4 → 11.0.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/debug/web-tree-sitter.cjs +53 -79
- package/debug/web-tree-sitter.cjs.map +2 -2
- package/debug/web-tree-sitter.js +53 -79
- package/debug/web-tree-sitter.js.map +2 -2
- package/debug/web-tree-sitter.wasm +0 -0
- package/debug/web-tree-sitter.wasm.map +3 -3
- package/package.json +1 -1
- package/web-tree-sitter.cjs +52 -78
- package/web-tree-sitter.cjs.map +2 -2
- package/web-tree-sitter.d.cts +8 -8
- package/web-tree-sitter.d.cts.map +1 -1
- package/web-tree-sitter.d.ts +8 -8
- package/web-tree-sitter.d.ts.map +1 -1
- package/web-tree-sitter.js +52 -78
- package/web-tree-sitter.js.map +2 -2
- package/web-tree-sitter.wasm +0 -0
- package/web-tree-sitter.wasm.map +3 -3
- package/web-tree-sitter.web.js +52 -78
- package/web-tree-sitter.web.js.map +2 -2
package/package.json
CHANGED
package/web-tree-sitter.cjs
CHANGED
|
@@ -557,7 +557,7 @@ var require_web_tree_sitter = __commonJS({
|
|
|
557
557
|
newDSO("__main__", 0, wasmImports);
|
|
558
558
|
}
|
|
559
559
|
};
|
|
560
|
-
var ___heap_base =
|
|
560
|
+
var ___heap_base = 82384;
|
|
561
561
|
var alignMemory = /* @__PURE__ */ __name((size, alignment) => Math.ceil(size / alignment) * alignment, "alignMemory");
|
|
562
562
|
var getMemory = /* @__PURE__ */ __name((size) => {
|
|
563
563
|
if (runtimeInitialized) {
|
|
@@ -1122,12 +1122,12 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1122
1122
|
"value": "i32",
|
|
1123
1123
|
"mutable": false
|
|
1124
1124
|
}, 1024);
|
|
1125
|
-
var ___stack_high =
|
|
1126
|
-
var ___stack_low =
|
|
1125
|
+
var ___stack_high = 82384;
|
|
1126
|
+
var ___stack_low = 16848;
|
|
1127
1127
|
var ___stack_pointer = new WebAssembly.Global({
|
|
1128
1128
|
"value": "i32",
|
|
1129
1129
|
"mutable": true
|
|
1130
|
-
},
|
|
1130
|
+
}, 82384);
|
|
1131
1131
|
var ___table_base = new WebAssembly.Global({
|
|
1132
1132
|
"value": "i32",
|
|
1133
1133
|
"mutable": false
|
|
@@ -2040,29 +2040,17 @@ var Tree = class _Tree {
|
|
|
2040
2040
|
};
|
|
2041
2041
|
|
|
2042
2042
|
// src/tree_cursor.ts
|
|
2043
|
-
var finalizer3 = newFinalizer((
|
|
2044
|
-
|
|
2043
|
+
var finalizer3 = newFinalizer((handles) => {
|
|
2044
|
+
marshalTreeCursor({ handles });
|
|
2045
|
+
C._ts_tree_cursor_delete_wasm(0);
|
|
2045
2046
|
});
|
|
2046
2047
|
var TreeCursor = class _TreeCursor {
|
|
2047
2048
|
static {
|
|
2048
2049
|
__name(this, "TreeCursor");
|
|
2049
2050
|
}
|
|
2050
2051
|
/** @internal */
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
// Internal handle for Wasm
|
|
2054
|
-
/** @internal */
|
|
2055
|
-
// @ts-expect-error: never read
|
|
2056
|
-
[1] = 0;
|
|
2057
|
-
// Internal handle for Wasm
|
|
2058
|
-
/** @internal */
|
|
2059
|
-
// @ts-expect-error: never read
|
|
2060
|
-
[2] = 0;
|
|
2061
|
-
// Internal handle for Wasm
|
|
2062
|
-
/** @internal */
|
|
2063
|
-
// @ts-expect-error: never read
|
|
2064
|
-
[3] = 0;
|
|
2065
|
-
// Internal handle for Wasm
|
|
2052
|
+
handles = [0, 0, 0, 0];
|
|
2053
|
+
// Internal handles for Wasm, shared with the finalizer.
|
|
2066
2054
|
/** @internal */
|
|
2067
2055
|
tree;
|
|
2068
2056
|
/** @internal */
|
|
@@ -2070,22 +2058,20 @@ var TreeCursor = class _TreeCursor {
|
|
|
2070
2058
|
assertInternal(internal);
|
|
2071
2059
|
this.tree = tree;
|
|
2072
2060
|
unmarshalTreeCursor(this);
|
|
2073
|
-
finalizer3?.register(this, this.
|
|
2061
|
+
finalizer3?.register(this, this.handles, this);
|
|
2074
2062
|
}
|
|
2075
2063
|
/** Creates a deep copy of the tree cursor. This allocates new memory. */
|
|
2076
2064
|
copy() {
|
|
2077
2065
|
marshalTreeCursor(this);
|
|
2078
|
-
const copy = new _TreeCursor(INTERNAL, this.tree);
|
|
2079
2066
|
C._ts_tree_cursor_copy_wasm(this.tree[0]);
|
|
2080
|
-
|
|
2081
|
-
return copy;
|
|
2067
|
+
return new _TreeCursor(INTERNAL, this.tree);
|
|
2082
2068
|
}
|
|
2083
2069
|
/** Delete the tree cursor, freeing its resources. */
|
|
2084
2070
|
delete() {
|
|
2085
2071
|
finalizer3?.unregister(this);
|
|
2086
2072
|
marshalTreeCursor(this);
|
|
2087
2073
|
C._ts_tree_cursor_delete_wasm(this.tree[0]);
|
|
2088
|
-
this
|
|
2074
|
+
this.handles.fill(0);
|
|
2089
2075
|
}
|
|
2090
2076
|
/** Get the tree cursor's current {@link Node}. */
|
|
2091
2077
|
get currentNode() {
|
|
@@ -2282,7 +2268,7 @@ var TreeCursor = class _TreeCursor {
|
|
|
2282
2268
|
}
|
|
2283
2269
|
/**
|
|
2284
2270
|
* Move this cursor to the first child of its current node that contains or
|
|
2285
|
-
* starts after the given
|
|
2271
|
+
* starts after the given index.
|
|
2286
2272
|
*
|
|
2287
2273
|
* This returns `true` if the cursor successfully moved to a child node, and returns
|
|
2288
2274
|
* `false` if no such child was found.
|
|
@@ -2296,10 +2282,10 @@ var TreeCursor = class _TreeCursor {
|
|
|
2296
2282
|
}
|
|
2297
2283
|
/**
|
|
2298
2284
|
* Move this cursor to the first child of its current node that contains or
|
|
2299
|
-
* starts after the given
|
|
2285
|
+
* starts after the given position.
|
|
2300
2286
|
*
|
|
2301
|
-
* This returns
|
|
2302
|
-
* `
|
|
2287
|
+
* This returns `true` if the cursor successfully moved to a child node, and returns
|
|
2288
|
+
* `false` if no such child was found.
|
|
2303
2289
|
*/
|
|
2304
2290
|
gotoFirstChildForPosition(goalPosition) {
|
|
2305
2291
|
marshalTreeCursor(this);
|
|
@@ -2315,8 +2301,9 @@ var TreeCursor = class _TreeCursor {
|
|
|
2315
2301
|
reset(node) {
|
|
2316
2302
|
marshalNode(node);
|
|
2317
2303
|
marshalTreeCursor(this, TRANSFER_BUFFER + SIZE_OF_NODE);
|
|
2318
|
-
C._ts_tree_cursor_reset_wasm(
|
|
2304
|
+
C._ts_tree_cursor_reset_wasm(node.tree[0]);
|
|
2319
2305
|
unmarshalTreeCursor(this);
|
|
2306
|
+
this.tree = node.tree;
|
|
2320
2307
|
}
|
|
2321
2308
|
/**
|
|
2322
2309
|
* Re-initialize a tree cursor to the same position as another cursor.
|
|
@@ -2329,6 +2316,7 @@ var TreeCursor = class _TreeCursor {
|
|
|
2329
2316
|
marshalTreeCursor(cursor, TRANSFER_BUFFER + SIZE_OF_CURSOR);
|
|
2330
2317
|
C._ts_tree_cursor_reset_to_wasm(this.tree[0], cursor.tree[0]);
|
|
2331
2318
|
unmarshalTreeCursor(this);
|
|
2319
|
+
this.tree = cursor.tree;
|
|
2332
2320
|
}
|
|
2333
2321
|
};
|
|
2334
2322
|
|
|
@@ -2689,16 +2677,14 @@ var Node = class {
|
|
|
2689
2677
|
if (!Array.isArray(types)) types = [types];
|
|
2690
2678
|
const symbols = [];
|
|
2691
2679
|
const typesBySymbol = this.tree.language.types;
|
|
2692
|
-
for (const node_type of types) {
|
|
2693
|
-
if (node_type == "ERROR") {
|
|
2694
|
-
symbols.push(65535);
|
|
2695
|
-
}
|
|
2696
|
-
}
|
|
2697
2680
|
for (let i2 = 0, n = typesBySymbol.length; i2 < n; i2++) {
|
|
2698
2681
|
if (types.includes(typesBySymbol[i2])) {
|
|
2699
2682
|
symbols.push(i2);
|
|
2700
2683
|
}
|
|
2701
2684
|
}
|
|
2685
|
+
if (types.includes("ERROR")) {
|
|
2686
|
+
symbols.push(65535);
|
|
2687
|
+
}
|
|
2702
2688
|
const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length);
|
|
2703
2689
|
for (let i2 = 0, n = symbols.length; i2 < n; i2++) {
|
|
2704
2690
|
C.setValue(symbolsAddress + i2 * SIZE_OF_INT, symbols[i2], "i32");
|
|
@@ -2854,31 +2840,9 @@ var Node = class {
|
|
|
2854
2840
|
* you want to keep and continue to use after an edit.
|
|
2855
2841
|
*/
|
|
2856
2842
|
edit(edit) {
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
let subbedPointColumn;
|
|
2861
|
-
if (this.startPosition.row > edit.oldEndPosition.row) {
|
|
2862
|
-
subbedPointRow = this.startPosition.row - edit.oldEndPosition.row;
|
|
2863
|
-
subbedPointColumn = this.startPosition.column;
|
|
2864
|
-
} else {
|
|
2865
|
-
subbedPointRow = 0;
|
|
2866
|
-
subbedPointColumn = this.startPosition.column;
|
|
2867
|
-
if (this.startPosition.column >= edit.oldEndPosition.column) {
|
|
2868
|
-
subbedPointColumn = this.startPosition.column - edit.oldEndPosition.column;
|
|
2869
|
-
}
|
|
2870
|
-
}
|
|
2871
|
-
if (subbedPointRow > 0) {
|
|
2872
|
-
this.startPosition.row += subbedPointRow;
|
|
2873
|
-
this.startPosition.column = subbedPointColumn;
|
|
2874
|
-
} else {
|
|
2875
|
-
this.startPosition.column += subbedPointColumn;
|
|
2876
|
-
}
|
|
2877
|
-
} else if (this.startIndex > edit.startIndex) {
|
|
2878
|
-
this.startIndex = edit.newEndIndex;
|
|
2879
|
-
this.startPosition.row = edit.newEndPosition.row;
|
|
2880
|
-
this.startPosition.column = edit.newEndPosition.column;
|
|
2881
|
-
}
|
|
2843
|
+
const { point, index } = edit.editPoint(this.startPosition, this.startIndex);
|
|
2844
|
+
this.startPosition = point;
|
|
2845
|
+
this.startIndex = index;
|
|
2882
2846
|
}
|
|
2883
2847
|
/** Get the S-expression representation of this node. */
|
|
2884
2848
|
toString() {
|
|
@@ -2936,18 +2900,18 @@ function unmarshalNode(tree, address = TRANSFER_BUFFER) {
|
|
|
2936
2900
|
return result;
|
|
2937
2901
|
}
|
|
2938
2902
|
__name(unmarshalNode, "unmarshalNode");
|
|
2939
|
-
function marshalTreeCursor(
|
|
2940
|
-
C.setValue(address + 0 * SIZE_OF_INT,
|
|
2941
|
-
C.setValue(address + 1 * SIZE_OF_INT,
|
|
2942
|
-
C.setValue(address + 2 * SIZE_OF_INT,
|
|
2943
|
-
C.setValue(address + 3 * SIZE_OF_INT,
|
|
2903
|
+
function marshalTreeCursor({ handles }, address = TRANSFER_BUFFER) {
|
|
2904
|
+
C.setValue(address + 0 * SIZE_OF_INT, handles[0], "i32");
|
|
2905
|
+
C.setValue(address + 1 * SIZE_OF_INT, handles[1], "i32");
|
|
2906
|
+
C.setValue(address + 2 * SIZE_OF_INT, handles[2], "i32");
|
|
2907
|
+
C.setValue(address + 3 * SIZE_OF_INT, handles[3], "i32");
|
|
2944
2908
|
}
|
|
2945
2909
|
__name(marshalTreeCursor, "marshalTreeCursor");
|
|
2946
|
-
function unmarshalTreeCursor(
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2910
|
+
function unmarshalTreeCursor({ handles }) {
|
|
2911
|
+
handles[0] = C.getValue(TRANSFER_BUFFER + 0 * SIZE_OF_INT, "i32");
|
|
2912
|
+
handles[1] = C.getValue(TRANSFER_BUFFER + 1 * SIZE_OF_INT, "i32");
|
|
2913
|
+
handles[2] = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
|
|
2914
|
+
handles[3] = C.getValue(TRANSFER_BUFFER + 3 * SIZE_OF_INT, "i32");
|
|
2951
2915
|
}
|
|
2952
2916
|
__name(unmarshalTreeCursor, "unmarshalTreeCursor");
|
|
2953
2917
|
function marshalPoint(address, point) {
|
|
@@ -3709,6 +3673,10 @@ function parsePattern(index, stepType, stepValueId, captureNames, stringValues,
|
|
|
3709
3673
|
}
|
|
3710
3674
|
}
|
|
3711
3675
|
__name(parsePattern, "parsePattern");
|
|
3676
|
+
function indexForByteOffset(source, byteOffset) {
|
|
3677
|
+
return new TextEncoder().encodeInto(source, new Uint8Array(byteOffset)).read;
|
|
3678
|
+
}
|
|
3679
|
+
__name(indexForByteOffset, "indexForByteOffset");
|
|
3712
3680
|
var finalizer5 = newFinalizer((address) => {
|
|
3713
3681
|
C._ts_query_delete(address);
|
|
3714
3682
|
});
|
|
@@ -3723,6 +3691,8 @@ var Query = class {
|
|
|
3723
3691
|
exceededMatchLimit;
|
|
3724
3692
|
/** @internal */
|
|
3725
3693
|
textPredicates;
|
|
3694
|
+
/** @internal */
|
|
3695
|
+
source;
|
|
3726
3696
|
/** The names of the captures used in the query. */
|
|
3727
3697
|
captureNames;
|
|
3728
3698
|
/** The quantifiers of the captures used in the query. */
|
|
@@ -3862,6 +3832,7 @@ var Query = class {
|
|
|
3862
3832
|
this.captureNames = captureNames;
|
|
3863
3833
|
this.captureQuantifiers = captureQuantifiers;
|
|
3864
3834
|
this.textPredicates = textPredicates;
|
|
3835
|
+
this.source = source;
|
|
3865
3836
|
this.predicates = predicates;
|
|
3866
3837
|
this.setProperties = setProperties;
|
|
3867
3838
|
this.assertedProperties = assertedProperties;
|
|
@@ -4072,23 +4043,25 @@ var Query = class {
|
|
|
4072
4043
|
didExceedMatchLimit() {
|
|
4073
4044
|
return this.exceededMatchLimit;
|
|
4074
4045
|
}
|
|
4075
|
-
/** Get the
|
|
4046
|
+
/** Get the index where the given pattern starts in the query's source. */
|
|
4076
4047
|
startIndexForPattern(patternIndex) {
|
|
4077
4048
|
if (patternIndex >= this.predicates.length) {
|
|
4078
4049
|
throw new Error(
|
|
4079
4050
|
`Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`
|
|
4080
4051
|
);
|
|
4081
4052
|
}
|
|
4082
|
-
|
|
4053
|
+
const byteOffset = C._ts_query_start_byte_for_pattern(this[0], patternIndex);
|
|
4054
|
+
return indexForByteOffset(this.source, byteOffset);
|
|
4083
4055
|
}
|
|
4084
|
-
/** Get the
|
|
4056
|
+
/** Get the index where the given pattern ends in the query's source. */
|
|
4085
4057
|
endIndexForPattern(patternIndex) {
|
|
4086
4058
|
if (patternIndex >= this.predicates.length) {
|
|
4087
4059
|
throw new Error(
|
|
4088
4060
|
`Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`
|
|
4089
4061
|
);
|
|
4090
4062
|
}
|
|
4091
|
-
|
|
4063
|
+
const byteOffset = C._ts_query_end_byte_for_pattern(this[0], patternIndex);
|
|
4064
|
+
return indexForByteOffset(this.source, byteOffset);
|
|
4092
4065
|
}
|
|
4093
4066
|
/** Get the number of patterns in the query. */
|
|
4094
4067
|
patternCount() {
|
|
@@ -4107,13 +4080,14 @@ var Query = class {
|
|
|
4107
4080
|
return C._ts_query_is_pattern_non_local(this[0], patternIndex) === 1;
|
|
4108
4081
|
}
|
|
4109
4082
|
/**
|
|
4110
|
-
* Check if
|
|
4083
|
+
* Check if the step at the given index in the query's source is 'definite'.
|
|
4111
4084
|
*
|
|
4112
4085
|
* A query step is 'definite' if its parent pattern will be guaranteed to
|
|
4113
4086
|
* match successfully once it reaches the step.
|
|
4114
4087
|
*/
|
|
4115
|
-
isPatternGuaranteedAtStep(
|
|
4116
|
-
|
|
4088
|
+
isPatternGuaranteedAtStep(index) {
|
|
4089
|
+
const byteOffset = C.lengthBytesUTF8(this.source.slice(0, index));
|
|
4090
|
+
return C._ts_query_is_pattern_guaranteed_at_step(this[0], byteOffset) === 1;
|
|
4117
4091
|
}
|
|
4118
4092
|
};
|
|
4119
4093
|
function prepareQuery(query, options) {
|