@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/web-tree-sitter.web.js
CHANGED
|
@@ -395,29 +395,17 @@ var Tree = class _Tree {
|
|
|
395
395
|
};
|
|
396
396
|
|
|
397
397
|
// src/tree_cursor.ts
|
|
398
|
-
var finalizer3 = newFinalizer((
|
|
399
|
-
|
|
398
|
+
var finalizer3 = newFinalizer((handles) => {
|
|
399
|
+
marshalTreeCursor({ handles });
|
|
400
|
+
C._ts_tree_cursor_delete_wasm(0);
|
|
400
401
|
});
|
|
401
402
|
var TreeCursor = class _TreeCursor {
|
|
402
403
|
static {
|
|
403
404
|
__name(this, "TreeCursor");
|
|
404
405
|
}
|
|
405
406
|
/** @internal */
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
// Internal handle for Wasm
|
|
409
|
-
/** @internal */
|
|
410
|
-
// @ts-expect-error: never read
|
|
411
|
-
[1] = 0;
|
|
412
|
-
// Internal handle for Wasm
|
|
413
|
-
/** @internal */
|
|
414
|
-
// @ts-expect-error: never read
|
|
415
|
-
[2] = 0;
|
|
416
|
-
// Internal handle for Wasm
|
|
417
|
-
/** @internal */
|
|
418
|
-
// @ts-expect-error: never read
|
|
419
|
-
[3] = 0;
|
|
420
|
-
// Internal handle for Wasm
|
|
407
|
+
handles = [0, 0, 0, 0];
|
|
408
|
+
// Internal handles for Wasm, shared with the finalizer.
|
|
421
409
|
/** @internal */
|
|
422
410
|
tree;
|
|
423
411
|
/** @internal */
|
|
@@ -425,22 +413,20 @@ var TreeCursor = class _TreeCursor {
|
|
|
425
413
|
assertInternal(internal);
|
|
426
414
|
this.tree = tree;
|
|
427
415
|
unmarshalTreeCursor(this);
|
|
428
|
-
finalizer3?.register(this, this.
|
|
416
|
+
finalizer3?.register(this, this.handles, this);
|
|
429
417
|
}
|
|
430
418
|
/** Creates a deep copy of the tree cursor. This allocates new memory. */
|
|
431
419
|
copy() {
|
|
432
420
|
marshalTreeCursor(this);
|
|
433
|
-
const copy = new _TreeCursor(INTERNAL, this.tree);
|
|
434
421
|
C._ts_tree_cursor_copy_wasm(this.tree[0]);
|
|
435
|
-
|
|
436
|
-
return copy;
|
|
422
|
+
return new _TreeCursor(INTERNAL, this.tree);
|
|
437
423
|
}
|
|
438
424
|
/** Delete the tree cursor, freeing its resources. */
|
|
439
425
|
delete() {
|
|
440
426
|
finalizer3?.unregister(this);
|
|
441
427
|
marshalTreeCursor(this);
|
|
442
428
|
C._ts_tree_cursor_delete_wasm(this.tree[0]);
|
|
443
|
-
this
|
|
429
|
+
this.handles.fill(0);
|
|
444
430
|
}
|
|
445
431
|
/** Get the tree cursor's current {@link Node}. */
|
|
446
432
|
get currentNode() {
|
|
@@ -637,7 +623,7 @@ var TreeCursor = class _TreeCursor {
|
|
|
637
623
|
}
|
|
638
624
|
/**
|
|
639
625
|
* Move this cursor to the first child of its current node that contains or
|
|
640
|
-
* starts after the given
|
|
626
|
+
* starts after the given index.
|
|
641
627
|
*
|
|
642
628
|
* This returns `true` if the cursor successfully moved to a child node, and returns
|
|
643
629
|
* `false` if no such child was found.
|
|
@@ -651,10 +637,10 @@ var TreeCursor = class _TreeCursor {
|
|
|
651
637
|
}
|
|
652
638
|
/**
|
|
653
639
|
* Move this cursor to the first child of its current node that contains or
|
|
654
|
-
* starts after the given
|
|
640
|
+
* starts after the given position.
|
|
655
641
|
*
|
|
656
|
-
* This returns
|
|
657
|
-
* `
|
|
642
|
+
* This returns `true` if the cursor successfully moved to a child node, and returns
|
|
643
|
+
* `false` if no such child was found.
|
|
658
644
|
*/
|
|
659
645
|
gotoFirstChildForPosition(goalPosition) {
|
|
660
646
|
marshalTreeCursor(this);
|
|
@@ -670,8 +656,9 @@ var TreeCursor = class _TreeCursor {
|
|
|
670
656
|
reset(node) {
|
|
671
657
|
marshalNode(node);
|
|
672
658
|
marshalTreeCursor(this, TRANSFER_BUFFER + SIZE_OF_NODE);
|
|
673
|
-
C._ts_tree_cursor_reset_wasm(
|
|
659
|
+
C._ts_tree_cursor_reset_wasm(node.tree[0]);
|
|
674
660
|
unmarshalTreeCursor(this);
|
|
661
|
+
this.tree = node.tree;
|
|
675
662
|
}
|
|
676
663
|
/**
|
|
677
664
|
* Re-initialize a tree cursor to the same position as another cursor.
|
|
@@ -684,6 +671,7 @@ var TreeCursor = class _TreeCursor {
|
|
|
684
671
|
marshalTreeCursor(cursor, TRANSFER_BUFFER + SIZE_OF_CURSOR);
|
|
685
672
|
C._ts_tree_cursor_reset_to_wasm(this.tree[0], cursor.tree[0]);
|
|
686
673
|
unmarshalTreeCursor(this);
|
|
674
|
+
this.tree = cursor.tree;
|
|
687
675
|
}
|
|
688
676
|
};
|
|
689
677
|
|
|
@@ -1044,16 +1032,14 @@ var Node = class {
|
|
|
1044
1032
|
if (!Array.isArray(types)) types = [types];
|
|
1045
1033
|
const symbols = [];
|
|
1046
1034
|
const typesBySymbol = this.tree.language.types;
|
|
1047
|
-
for (const node_type of types) {
|
|
1048
|
-
if (node_type == "ERROR") {
|
|
1049
|
-
symbols.push(65535);
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
1035
|
for (let i2 = 0, n = typesBySymbol.length; i2 < n; i2++) {
|
|
1053
1036
|
if (types.includes(typesBySymbol[i2])) {
|
|
1054
1037
|
symbols.push(i2);
|
|
1055
1038
|
}
|
|
1056
1039
|
}
|
|
1040
|
+
if (types.includes("ERROR")) {
|
|
1041
|
+
symbols.push(65535);
|
|
1042
|
+
}
|
|
1057
1043
|
const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length);
|
|
1058
1044
|
for (let i2 = 0, n = symbols.length; i2 < n; i2++) {
|
|
1059
1045
|
C.setValue(symbolsAddress + i2 * SIZE_OF_INT, symbols[i2], "i32");
|
|
@@ -1209,31 +1195,9 @@ var Node = class {
|
|
|
1209
1195
|
* you want to keep and continue to use after an edit.
|
|
1210
1196
|
*/
|
|
1211
1197
|
edit(edit) {
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
let subbedPointColumn;
|
|
1216
|
-
if (this.startPosition.row > edit.oldEndPosition.row) {
|
|
1217
|
-
subbedPointRow = this.startPosition.row - edit.oldEndPosition.row;
|
|
1218
|
-
subbedPointColumn = this.startPosition.column;
|
|
1219
|
-
} else {
|
|
1220
|
-
subbedPointRow = 0;
|
|
1221
|
-
subbedPointColumn = this.startPosition.column;
|
|
1222
|
-
if (this.startPosition.column >= edit.oldEndPosition.column) {
|
|
1223
|
-
subbedPointColumn = this.startPosition.column - edit.oldEndPosition.column;
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
if (subbedPointRow > 0) {
|
|
1227
|
-
this.startPosition.row += subbedPointRow;
|
|
1228
|
-
this.startPosition.column = subbedPointColumn;
|
|
1229
|
-
} else {
|
|
1230
|
-
this.startPosition.column += subbedPointColumn;
|
|
1231
|
-
}
|
|
1232
|
-
} else if (this.startIndex > edit.startIndex) {
|
|
1233
|
-
this.startIndex = edit.newEndIndex;
|
|
1234
|
-
this.startPosition.row = edit.newEndPosition.row;
|
|
1235
|
-
this.startPosition.column = edit.newEndPosition.column;
|
|
1236
|
-
}
|
|
1198
|
+
const { point, index } = edit.editPoint(this.startPosition, this.startIndex);
|
|
1199
|
+
this.startPosition = point;
|
|
1200
|
+
this.startIndex = index;
|
|
1237
1201
|
}
|
|
1238
1202
|
/** Get the S-expression representation of this node. */
|
|
1239
1203
|
toString() {
|
|
@@ -1291,18 +1255,18 @@ function unmarshalNode(tree, address = TRANSFER_BUFFER) {
|
|
|
1291
1255
|
return result;
|
|
1292
1256
|
}
|
|
1293
1257
|
__name(unmarshalNode, "unmarshalNode");
|
|
1294
|
-
function marshalTreeCursor(
|
|
1295
|
-
C.setValue(address + 0 * SIZE_OF_INT,
|
|
1296
|
-
C.setValue(address + 1 * SIZE_OF_INT,
|
|
1297
|
-
C.setValue(address + 2 * SIZE_OF_INT,
|
|
1298
|
-
C.setValue(address + 3 * SIZE_OF_INT,
|
|
1258
|
+
function marshalTreeCursor({ handles }, address = TRANSFER_BUFFER) {
|
|
1259
|
+
C.setValue(address + 0 * SIZE_OF_INT, handles[0], "i32");
|
|
1260
|
+
C.setValue(address + 1 * SIZE_OF_INT, handles[1], "i32");
|
|
1261
|
+
C.setValue(address + 2 * SIZE_OF_INT, handles[2], "i32");
|
|
1262
|
+
C.setValue(address + 3 * SIZE_OF_INT, handles[3], "i32");
|
|
1299
1263
|
}
|
|
1300
1264
|
__name(marshalTreeCursor, "marshalTreeCursor");
|
|
1301
|
-
function unmarshalTreeCursor(
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1265
|
+
function unmarshalTreeCursor({ handles }) {
|
|
1266
|
+
handles[0] = C.getValue(TRANSFER_BUFFER + 0 * SIZE_OF_INT, "i32");
|
|
1267
|
+
handles[1] = C.getValue(TRANSFER_BUFFER + 1 * SIZE_OF_INT, "i32");
|
|
1268
|
+
handles[2] = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
|
|
1269
|
+
handles[3] = C.getValue(TRANSFER_BUFFER + 3 * SIZE_OF_INT, "i32");
|
|
1306
1270
|
}
|
|
1307
1271
|
__name(unmarshalTreeCursor, "unmarshalTreeCursor");
|
|
1308
1272
|
function marshalPoint(address, point) {
|
|
@@ -2129,7 +2093,7 @@ async function Module2(moduleArg = {}) {
|
|
|
2129
2093
|
newDSO("__main__", 0, wasmImports);
|
|
2130
2094
|
}
|
|
2131
2095
|
};
|
|
2132
|
-
var ___heap_base =
|
|
2096
|
+
var ___heap_base = 82384;
|
|
2133
2097
|
var alignMemory = /* @__PURE__ */ __name((size, alignment) => Math.ceil(size / alignment) * alignment, "alignMemory");
|
|
2134
2098
|
var getMemory = /* @__PURE__ */ __name((size) => {
|
|
2135
2099
|
if (runtimeInitialized) {
|
|
@@ -2694,12 +2658,12 @@ async function Module2(moduleArg = {}) {
|
|
|
2694
2658
|
"value": "i32",
|
|
2695
2659
|
"mutable": false
|
|
2696
2660
|
}, 1024);
|
|
2697
|
-
var ___stack_high =
|
|
2698
|
-
var ___stack_low =
|
|
2661
|
+
var ___stack_high = 82384;
|
|
2662
|
+
var ___stack_low = 16848;
|
|
2699
2663
|
var ___stack_pointer = new WebAssembly.Global({
|
|
2700
2664
|
"value": "i32",
|
|
2701
2665
|
"mutable": true
|
|
2702
|
-
},
|
|
2666
|
+
}, 82384);
|
|
2703
2667
|
var ___table_base = new WebAssembly.Global({
|
|
2704
2668
|
"value": "i32",
|
|
2705
2669
|
"mutable": false
|
|
@@ -3683,6 +3647,10 @@ function parsePattern(index, stepType, stepValueId, captureNames, stringValues,
|
|
|
3683
3647
|
}
|
|
3684
3648
|
}
|
|
3685
3649
|
__name(parsePattern, "parsePattern");
|
|
3650
|
+
function indexForByteOffset(source, byteOffset) {
|
|
3651
|
+
return new TextEncoder().encodeInto(source, new Uint8Array(byteOffset)).read;
|
|
3652
|
+
}
|
|
3653
|
+
__name(indexForByteOffset, "indexForByteOffset");
|
|
3686
3654
|
var finalizer5 = newFinalizer((address) => {
|
|
3687
3655
|
C._ts_query_delete(address);
|
|
3688
3656
|
});
|
|
@@ -3697,6 +3665,8 @@ var Query = class {
|
|
|
3697
3665
|
exceededMatchLimit;
|
|
3698
3666
|
/** @internal */
|
|
3699
3667
|
textPredicates;
|
|
3668
|
+
/** @internal */
|
|
3669
|
+
source;
|
|
3700
3670
|
/** The names of the captures used in the query. */
|
|
3701
3671
|
captureNames;
|
|
3702
3672
|
/** The quantifiers of the captures used in the query. */
|
|
@@ -3836,6 +3806,7 @@ var Query = class {
|
|
|
3836
3806
|
this.captureNames = captureNames;
|
|
3837
3807
|
this.captureQuantifiers = captureQuantifiers;
|
|
3838
3808
|
this.textPredicates = textPredicates;
|
|
3809
|
+
this.source = source;
|
|
3839
3810
|
this.predicates = predicates;
|
|
3840
3811
|
this.setProperties = setProperties;
|
|
3841
3812
|
this.assertedProperties = assertedProperties;
|
|
@@ -4046,23 +4017,25 @@ var Query = class {
|
|
|
4046
4017
|
didExceedMatchLimit() {
|
|
4047
4018
|
return this.exceededMatchLimit;
|
|
4048
4019
|
}
|
|
4049
|
-
/** Get the
|
|
4020
|
+
/** Get the index where the given pattern starts in the query's source. */
|
|
4050
4021
|
startIndexForPattern(patternIndex) {
|
|
4051
4022
|
if (patternIndex >= this.predicates.length) {
|
|
4052
4023
|
throw new Error(
|
|
4053
4024
|
`Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`
|
|
4054
4025
|
);
|
|
4055
4026
|
}
|
|
4056
|
-
|
|
4027
|
+
const byteOffset = C._ts_query_start_byte_for_pattern(this[0], patternIndex);
|
|
4028
|
+
return indexForByteOffset(this.source, byteOffset);
|
|
4057
4029
|
}
|
|
4058
|
-
/** Get the
|
|
4030
|
+
/** Get the index where the given pattern ends in the query's source. */
|
|
4059
4031
|
endIndexForPattern(patternIndex) {
|
|
4060
4032
|
if (patternIndex >= this.predicates.length) {
|
|
4061
4033
|
throw new Error(
|
|
4062
4034
|
`Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`
|
|
4063
4035
|
);
|
|
4064
4036
|
}
|
|
4065
|
-
|
|
4037
|
+
const byteOffset = C._ts_query_end_byte_for_pattern(this[0], patternIndex);
|
|
4038
|
+
return indexForByteOffset(this.source, byteOffset);
|
|
4066
4039
|
}
|
|
4067
4040
|
/** Get the number of patterns in the query. */
|
|
4068
4041
|
patternCount() {
|
|
@@ -4081,13 +4054,14 @@ var Query = class {
|
|
|
4081
4054
|
return C._ts_query_is_pattern_non_local(this[0], patternIndex) === 1;
|
|
4082
4055
|
}
|
|
4083
4056
|
/**
|
|
4084
|
-
* Check if
|
|
4057
|
+
* Check if the step at the given index in the query's source is 'definite'.
|
|
4085
4058
|
*
|
|
4086
4059
|
* A query step is 'definite' if its parent pattern will be guaranteed to
|
|
4087
4060
|
* match successfully once it reaches the step.
|
|
4088
4061
|
*/
|
|
4089
|
-
isPatternGuaranteedAtStep(
|
|
4090
|
-
|
|
4062
|
+
isPatternGuaranteedAtStep(index) {
|
|
4063
|
+
const byteOffset = C.lengthBytesUTF8(this.source.slice(0, index));
|
|
4064
|
+
return C._ts_query_is_pattern_guaranteed_at_step(this[0], byteOffset) === 1;
|
|
4091
4065
|
}
|
|
4092
4066
|
};
|
|
4093
4067
|
function prepareQuery(query, options) {
|