@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
|
@@ -818,7 +818,7 @@ var require_web_tree_sitter = __commonJS({
|
|
|
818
818
|
newDSO("__main__", 0, wasmImports);
|
|
819
819
|
}
|
|
820
820
|
};
|
|
821
|
-
var ___heap_base =
|
|
821
|
+
var ___heap_base = 82384;
|
|
822
822
|
var alignMemory = /* @__PURE__ */ __name((size, alignment) => {
|
|
823
823
|
assert(alignment, "alignment argument is required");
|
|
824
824
|
return Math.ceil(size / alignment) * alignment;
|
|
@@ -1449,12 +1449,12 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1449
1449
|
"value": "i32",
|
|
1450
1450
|
"mutable": false
|
|
1451
1451
|
}, 1024);
|
|
1452
|
-
var ___stack_high =
|
|
1453
|
-
var ___stack_low =
|
|
1452
|
+
var ___stack_high = 82384;
|
|
1453
|
+
var ___stack_low = 16848;
|
|
1454
1454
|
var ___stack_pointer = new WebAssembly.Global({
|
|
1455
1455
|
"value": "i32",
|
|
1456
1456
|
"mutable": true
|
|
1457
|
-
},
|
|
1457
|
+
}, 82384);
|
|
1458
1458
|
var ___table_base = new WebAssembly.Global({
|
|
1459
1459
|
"value": "i32",
|
|
1460
1460
|
"mutable": false
|
|
@@ -2168,7 +2168,7 @@ var require_web_tree_sitter = __commonJS({
|
|
|
2168
2168
|
}
|
|
2169
2169
|
__name(callMain, "callMain");
|
|
2170
2170
|
function stackCheckInit() {
|
|
2171
|
-
_emscripten_stack_set_limits(
|
|
2171
|
+
_emscripten_stack_set_limits(82384, 16848);
|
|
2172
2172
|
writeStackCookie();
|
|
2173
2173
|
}
|
|
2174
2174
|
__name(stackCheckInit, "stackCheckInit");
|
|
@@ -2640,29 +2640,17 @@ var Tree = class _Tree {
|
|
|
2640
2640
|
};
|
|
2641
2641
|
|
|
2642
2642
|
// src/tree_cursor.ts
|
|
2643
|
-
var finalizer3 = newFinalizer((
|
|
2644
|
-
|
|
2643
|
+
var finalizer3 = newFinalizer((handles) => {
|
|
2644
|
+
marshalTreeCursor({ handles });
|
|
2645
|
+
C._ts_tree_cursor_delete_wasm(0);
|
|
2645
2646
|
});
|
|
2646
2647
|
var TreeCursor = class _TreeCursor {
|
|
2647
2648
|
static {
|
|
2648
2649
|
__name(this, "TreeCursor");
|
|
2649
2650
|
}
|
|
2650
2651
|
/** @internal */
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
// Internal handle for Wasm
|
|
2654
|
-
/** @internal */
|
|
2655
|
-
// @ts-expect-error: never read
|
|
2656
|
-
[1] = 0;
|
|
2657
|
-
// Internal handle for Wasm
|
|
2658
|
-
/** @internal */
|
|
2659
|
-
// @ts-expect-error: never read
|
|
2660
|
-
[2] = 0;
|
|
2661
|
-
// Internal handle for Wasm
|
|
2662
|
-
/** @internal */
|
|
2663
|
-
// @ts-expect-error: never read
|
|
2664
|
-
[3] = 0;
|
|
2665
|
-
// Internal handle for Wasm
|
|
2652
|
+
handles = [0, 0, 0, 0];
|
|
2653
|
+
// Internal handles for Wasm, shared with the finalizer.
|
|
2666
2654
|
/** @internal */
|
|
2667
2655
|
tree;
|
|
2668
2656
|
/** @internal */
|
|
@@ -2670,22 +2658,20 @@ var TreeCursor = class _TreeCursor {
|
|
|
2670
2658
|
assertInternal(internal);
|
|
2671
2659
|
this.tree = tree;
|
|
2672
2660
|
unmarshalTreeCursor(this);
|
|
2673
|
-
finalizer3?.register(this, this.
|
|
2661
|
+
finalizer3?.register(this, this.handles, this);
|
|
2674
2662
|
}
|
|
2675
2663
|
/** Creates a deep copy of the tree cursor. This allocates new memory. */
|
|
2676
2664
|
copy() {
|
|
2677
2665
|
marshalTreeCursor(this);
|
|
2678
|
-
const copy = new _TreeCursor(INTERNAL, this.tree);
|
|
2679
2666
|
C._ts_tree_cursor_copy_wasm(this.tree[0]);
|
|
2680
|
-
|
|
2681
|
-
return copy;
|
|
2667
|
+
return new _TreeCursor(INTERNAL, this.tree);
|
|
2682
2668
|
}
|
|
2683
2669
|
/** Delete the tree cursor, freeing its resources. */
|
|
2684
2670
|
delete() {
|
|
2685
2671
|
finalizer3?.unregister(this);
|
|
2686
2672
|
marshalTreeCursor(this);
|
|
2687
2673
|
C._ts_tree_cursor_delete_wasm(this.tree[0]);
|
|
2688
|
-
this
|
|
2674
|
+
this.handles.fill(0);
|
|
2689
2675
|
}
|
|
2690
2676
|
/** Get the tree cursor's current {@link Node}. */
|
|
2691
2677
|
get currentNode() {
|
|
@@ -2882,7 +2868,7 @@ var TreeCursor = class _TreeCursor {
|
|
|
2882
2868
|
}
|
|
2883
2869
|
/**
|
|
2884
2870
|
* Move this cursor to the first child of its current node that contains or
|
|
2885
|
-
* starts after the given
|
|
2871
|
+
* starts after the given index.
|
|
2886
2872
|
*
|
|
2887
2873
|
* This returns `true` if the cursor successfully moved to a child node, and returns
|
|
2888
2874
|
* `false` if no such child was found.
|
|
@@ -2896,10 +2882,10 @@ var TreeCursor = class _TreeCursor {
|
|
|
2896
2882
|
}
|
|
2897
2883
|
/**
|
|
2898
2884
|
* Move this cursor to the first child of its current node that contains or
|
|
2899
|
-
* starts after the given
|
|
2885
|
+
* starts after the given position.
|
|
2900
2886
|
*
|
|
2901
|
-
* This returns
|
|
2902
|
-
* `
|
|
2887
|
+
* This returns `true` if the cursor successfully moved to a child node, and returns
|
|
2888
|
+
* `false` if no such child was found.
|
|
2903
2889
|
*/
|
|
2904
2890
|
gotoFirstChildForPosition(goalPosition) {
|
|
2905
2891
|
marshalTreeCursor(this);
|
|
@@ -2915,8 +2901,9 @@ var TreeCursor = class _TreeCursor {
|
|
|
2915
2901
|
reset(node) {
|
|
2916
2902
|
marshalNode(node);
|
|
2917
2903
|
marshalTreeCursor(this, TRANSFER_BUFFER + SIZE_OF_NODE);
|
|
2918
|
-
C._ts_tree_cursor_reset_wasm(
|
|
2904
|
+
C._ts_tree_cursor_reset_wasm(node.tree[0]);
|
|
2919
2905
|
unmarshalTreeCursor(this);
|
|
2906
|
+
this.tree = node.tree;
|
|
2920
2907
|
}
|
|
2921
2908
|
/**
|
|
2922
2909
|
* Re-initialize a tree cursor to the same position as another cursor.
|
|
@@ -2929,6 +2916,7 @@ var TreeCursor = class _TreeCursor {
|
|
|
2929
2916
|
marshalTreeCursor(cursor, TRANSFER_BUFFER + SIZE_OF_CURSOR);
|
|
2930
2917
|
C._ts_tree_cursor_reset_to_wasm(this.tree[0], cursor.tree[0]);
|
|
2931
2918
|
unmarshalTreeCursor(this);
|
|
2919
|
+
this.tree = cursor.tree;
|
|
2932
2920
|
}
|
|
2933
2921
|
};
|
|
2934
2922
|
|
|
@@ -3289,16 +3277,14 @@ var Node = class {
|
|
|
3289
3277
|
if (!Array.isArray(types)) types = [types];
|
|
3290
3278
|
const symbols = [];
|
|
3291
3279
|
const typesBySymbol = this.tree.language.types;
|
|
3292
|
-
for (const node_type of types) {
|
|
3293
|
-
if (node_type == "ERROR") {
|
|
3294
|
-
symbols.push(65535);
|
|
3295
|
-
}
|
|
3296
|
-
}
|
|
3297
3280
|
for (let i2 = 0, n = typesBySymbol.length; i2 < n; i2++) {
|
|
3298
3281
|
if (types.includes(typesBySymbol[i2])) {
|
|
3299
3282
|
symbols.push(i2);
|
|
3300
3283
|
}
|
|
3301
3284
|
}
|
|
3285
|
+
if (types.includes("ERROR")) {
|
|
3286
|
+
symbols.push(65535);
|
|
3287
|
+
}
|
|
3302
3288
|
const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length);
|
|
3303
3289
|
for (let i2 = 0, n = symbols.length; i2 < n; i2++) {
|
|
3304
3290
|
C.setValue(symbolsAddress + i2 * SIZE_OF_INT, symbols[i2], "i32");
|
|
@@ -3454,31 +3440,9 @@ var Node = class {
|
|
|
3454
3440
|
* you want to keep and continue to use after an edit.
|
|
3455
3441
|
*/
|
|
3456
3442
|
edit(edit) {
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
let subbedPointColumn;
|
|
3461
|
-
if (this.startPosition.row > edit.oldEndPosition.row) {
|
|
3462
|
-
subbedPointRow = this.startPosition.row - edit.oldEndPosition.row;
|
|
3463
|
-
subbedPointColumn = this.startPosition.column;
|
|
3464
|
-
} else {
|
|
3465
|
-
subbedPointRow = 0;
|
|
3466
|
-
subbedPointColumn = this.startPosition.column;
|
|
3467
|
-
if (this.startPosition.column >= edit.oldEndPosition.column) {
|
|
3468
|
-
subbedPointColumn = this.startPosition.column - edit.oldEndPosition.column;
|
|
3469
|
-
}
|
|
3470
|
-
}
|
|
3471
|
-
if (subbedPointRow > 0) {
|
|
3472
|
-
this.startPosition.row += subbedPointRow;
|
|
3473
|
-
this.startPosition.column = subbedPointColumn;
|
|
3474
|
-
} else {
|
|
3475
|
-
this.startPosition.column += subbedPointColumn;
|
|
3476
|
-
}
|
|
3477
|
-
} else if (this.startIndex > edit.startIndex) {
|
|
3478
|
-
this.startIndex = edit.newEndIndex;
|
|
3479
|
-
this.startPosition.row = edit.newEndPosition.row;
|
|
3480
|
-
this.startPosition.column = edit.newEndPosition.column;
|
|
3481
|
-
}
|
|
3443
|
+
const { point, index } = edit.editPoint(this.startPosition, this.startIndex);
|
|
3444
|
+
this.startPosition = point;
|
|
3445
|
+
this.startIndex = index;
|
|
3482
3446
|
}
|
|
3483
3447
|
/** Get the S-expression representation of this node. */
|
|
3484
3448
|
toString() {
|
|
@@ -3536,18 +3500,18 @@ function unmarshalNode(tree, address = TRANSFER_BUFFER) {
|
|
|
3536
3500
|
return result;
|
|
3537
3501
|
}
|
|
3538
3502
|
__name(unmarshalNode, "unmarshalNode");
|
|
3539
|
-
function marshalTreeCursor(
|
|
3540
|
-
C.setValue(address + 0 * SIZE_OF_INT,
|
|
3541
|
-
C.setValue(address + 1 * SIZE_OF_INT,
|
|
3542
|
-
C.setValue(address + 2 * SIZE_OF_INT,
|
|
3543
|
-
C.setValue(address + 3 * SIZE_OF_INT,
|
|
3503
|
+
function marshalTreeCursor({ handles }, address = TRANSFER_BUFFER) {
|
|
3504
|
+
C.setValue(address + 0 * SIZE_OF_INT, handles[0], "i32");
|
|
3505
|
+
C.setValue(address + 1 * SIZE_OF_INT, handles[1], "i32");
|
|
3506
|
+
C.setValue(address + 2 * SIZE_OF_INT, handles[2], "i32");
|
|
3507
|
+
C.setValue(address + 3 * SIZE_OF_INT, handles[3], "i32");
|
|
3544
3508
|
}
|
|
3545
3509
|
__name(marshalTreeCursor, "marshalTreeCursor");
|
|
3546
|
-
function unmarshalTreeCursor(
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3510
|
+
function unmarshalTreeCursor({ handles }) {
|
|
3511
|
+
handles[0] = C.getValue(TRANSFER_BUFFER + 0 * SIZE_OF_INT, "i32");
|
|
3512
|
+
handles[1] = C.getValue(TRANSFER_BUFFER + 1 * SIZE_OF_INT, "i32");
|
|
3513
|
+
handles[2] = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
|
|
3514
|
+
handles[3] = C.getValue(TRANSFER_BUFFER + 3 * SIZE_OF_INT, "i32");
|
|
3551
3515
|
}
|
|
3552
3516
|
__name(unmarshalTreeCursor, "unmarshalTreeCursor");
|
|
3553
3517
|
function marshalPoint(address, point) {
|
|
@@ -4309,6 +4273,10 @@ function parsePattern(index, stepType, stepValueId, captureNames, stringValues,
|
|
|
4309
4273
|
}
|
|
4310
4274
|
}
|
|
4311
4275
|
__name(parsePattern, "parsePattern");
|
|
4276
|
+
function indexForByteOffset(source, byteOffset) {
|
|
4277
|
+
return new TextEncoder().encodeInto(source, new Uint8Array(byteOffset)).read;
|
|
4278
|
+
}
|
|
4279
|
+
__name(indexForByteOffset, "indexForByteOffset");
|
|
4312
4280
|
var finalizer5 = newFinalizer((address) => {
|
|
4313
4281
|
C._ts_query_delete(address);
|
|
4314
4282
|
});
|
|
@@ -4323,6 +4291,8 @@ var Query = class {
|
|
|
4323
4291
|
exceededMatchLimit;
|
|
4324
4292
|
/** @internal */
|
|
4325
4293
|
textPredicates;
|
|
4294
|
+
/** @internal */
|
|
4295
|
+
source;
|
|
4326
4296
|
/** The names of the captures used in the query. */
|
|
4327
4297
|
captureNames;
|
|
4328
4298
|
/** The quantifiers of the captures used in the query. */
|
|
@@ -4462,6 +4432,7 @@ var Query = class {
|
|
|
4462
4432
|
this.captureNames = captureNames;
|
|
4463
4433
|
this.captureQuantifiers = captureQuantifiers;
|
|
4464
4434
|
this.textPredicates = textPredicates;
|
|
4435
|
+
this.source = source;
|
|
4465
4436
|
this.predicates = predicates;
|
|
4466
4437
|
this.setProperties = setProperties;
|
|
4467
4438
|
this.assertedProperties = assertedProperties;
|
|
@@ -4672,23 +4643,25 @@ var Query = class {
|
|
|
4672
4643
|
didExceedMatchLimit() {
|
|
4673
4644
|
return this.exceededMatchLimit;
|
|
4674
4645
|
}
|
|
4675
|
-
/** Get the
|
|
4646
|
+
/** Get the index where the given pattern starts in the query's source. */
|
|
4676
4647
|
startIndexForPattern(patternIndex) {
|
|
4677
4648
|
if (patternIndex >= this.predicates.length) {
|
|
4678
4649
|
throw new Error(
|
|
4679
4650
|
`Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`
|
|
4680
4651
|
);
|
|
4681
4652
|
}
|
|
4682
|
-
|
|
4653
|
+
const byteOffset = C._ts_query_start_byte_for_pattern(this[0], patternIndex);
|
|
4654
|
+
return indexForByteOffset(this.source, byteOffset);
|
|
4683
4655
|
}
|
|
4684
|
-
/** Get the
|
|
4656
|
+
/** Get the index where the given pattern ends in the query's source. */
|
|
4685
4657
|
endIndexForPattern(patternIndex) {
|
|
4686
4658
|
if (patternIndex >= this.predicates.length) {
|
|
4687
4659
|
throw new Error(
|
|
4688
4660
|
`Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`
|
|
4689
4661
|
);
|
|
4690
4662
|
}
|
|
4691
|
-
|
|
4663
|
+
const byteOffset = C._ts_query_end_byte_for_pattern(this[0], patternIndex);
|
|
4664
|
+
return indexForByteOffset(this.source, byteOffset);
|
|
4692
4665
|
}
|
|
4693
4666
|
/** Get the number of patterns in the query. */
|
|
4694
4667
|
patternCount() {
|
|
@@ -4707,13 +4680,14 @@ var Query = class {
|
|
|
4707
4680
|
return C._ts_query_is_pattern_non_local(this[0], patternIndex) === 1;
|
|
4708
4681
|
}
|
|
4709
4682
|
/**
|
|
4710
|
-
* Check if
|
|
4683
|
+
* Check if the step at the given index in the query's source is 'definite'.
|
|
4711
4684
|
*
|
|
4712
4685
|
* A query step is 'definite' if its parent pattern will be guaranteed to
|
|
4713
4686
|
* match successfully once it reaches the step.
|
|
4714
4687
|
*/
|
|
4715
|
-
isPatternGuaranteedAtStep(
|
|
4716
|
-
|
|
4688
|
+
isPatternGuaranteedAtStep(index) {
|
|
4689
|
+
const byteOffset = C.lengthBytesUTF8(this.source.slice(0, index));
|
|
4690
|
+
return C._ts_query_is_pattern_guaranteed_at_step(this[0], byteOffset) === 1;
|
|
4717
4691
|
}
|
|
4718
4692
|
};
|
|
4719
4693
|
function prepareQuery(query, options) {
|