@willbooster/web-tree-sitter 2.0.19 → 2.0.21
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 +194 -145
- package/debug/web-tree-sitter.cjs.map +2 -2
- package/debug/web-tree-sitter.js +194 -145
- package/debug/web-tree-sitter.js.map +2 -2
- package/debug/web-tree-sitter.wasm +0 -0
- package/debug/web-tree-sitter.wasm.map +2 -2
- package/package.json +1 -1
- package/web-tree-sitter.cjs +194 -145
- package/web-tree-sitter.cjs.map +2 -2
- package/web-tree-sitter.d.cts +5 -0
- package/web-tree-sitter.d.cts.map +1 -1
- package/web-tree-sitter.d.ts +5 -0
- package/web-tree-sitter.d.ts.map +1 -1
- package/web-tree-sitter.js +194 -145
- package/web-tree-sitter.js.map +2 -2
- package/web-tree-sitter.wasm +0 -0
- package/web-tree-sitter.wasm.map +2 -2
- package/web-tree-sitter.web.js +194 -145
- package/web-tree-sitter.web.js.map +2 -2
|
@@ -4487,84 +4487,72 @@ var Query = class {
|
|
|
4487
4487
|
* @param {QueryOptions} options - Options for query execution.
|
|
4488
4488
|
*/
|
|
4489
4489
|
matches(node, options = {}) {
|
|
4490
|
-
const
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
const endIndex = options.endIndex ?? 0;
|
|
4494
|
-
const startContainingPosition = options.startContainingPosition ?? ZERO_POINT;
|
|
4495
|
-
const endContainingPosition = options.endContainingPosition ?? ZERO_POINT;
|
|
4496
|
-
const startContainingIndex = options.startContainingIndex ?? 0;
|
|
4497
|
-
const endContainingIndex = options.endContainingIndex ?? 0;
|
|
4498
|
-
const matchLimit = options.matchLimit ?? 4294967295;
|
|
4499
|
-
const maxStartDepth = options.maxStartDepth ?? 4294967295;
|
|
4500
|
-
const progressCallback = options.progressCallback;
|
|
4501
|
-
if (typeof matchLimit !== "number") {
|
|
4502
|
-
throw new Error("Arguments must be numbers");
|
|
4503
|
-
}
|
|
4504
|
-
this.matchLimit = matchLimit;
|
|
4505
|
-
if (endIndex !== 0 && startIndex > endIndex) {
|
|
4506
|
-
throw new Error("`startIndex` cannot be greater than `endIndex`");
|
|
4507
|
-
}
|
|
4508
|
-
if (endPosition !== ZERO_POINT && (startPosition.row > endPosition.row || startPosition.row === endPosition.row && startPosition.column > endPosition.column)) {
|
|
4509
|
-
throw new Error("`startPosition` cannot be greater than `endPosition`");
|
|
4510
|
-
}
|
|
4511
|
-
if (endContainingIndex !== 0 && startContainingIndex > endContainingIndex) {
|
|
4512
|
-
throw new Error("`startContainingIndex` cannot be greater than `endContainingIndex`");
|
|
4513
|
-
}
|
|
4514
|
-
if (endContainingPosition !== ZERO_POINT && (startContainingPosition.row > endContainingPosition.row || startContainingPosition.row === endContainingPosition.row && startContainingPosition.column > endContainingPosition.column)) {
|
|
4515
|
-
throw new Error("`startContainingPosition` cannot be greater than `endContainingPosition`");
|
|
4516
|
-
}
|
|
4517
|
-
if (progressCallback) {
|
|
4518
|
-
C.currentQueryProgressCallback = progressCallback;
|
|
4519
|
-
}
|
|
4520
|
-
marshalNode(node);
|
|
4521
|
-
C._ts_query_matches_wasm(
|
|
4522
|
-
this[0],
|
|
4523
|
-
node.tree[0],
|
|
4524
|
-
startPosition.row,
|
|
4525
|
-
startPosition.column,
|
|
4526
|
-
endPosition.row,
|
|
4527
|
-
endPosition.column,
|
|
4490
|
+
const {
|
|
4491
|
+
startPosition,
|
|
4492
|
+
endPosition,
|
|
4528
4493
|
startIndex,
|
|
4529
4494
|
endIndex,
|
|
4530
|
-
startContainingPosition
|
|
4531
|
-
|
|
4532
|
-
endContainingPosition.row,
|
|
4533
|
-
endContainingPosition.column,
|
|
4495
|
+
startContainingPosition,
|
|
4496
|
+
endContainingPosition,
|
|
4534
4497
|
startContainingIndex,
|
|
4535
4498
|
endContainingIndex,
|
|
4536
4499
|
matchLimit,
|
|
4537
|
-
maxStartDepth
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4500
|
+
maxStartDepth,
|
|
4501
|
+
progressCallback
|
|
4502
|
+
} = prepareQuery(this, options);
|
|
4503
|
+
return executeQuery(
|
|
4504
|
+
progressCallback,
|
|
4505
|
+
() => {
|
|
4506
|
+
marshalNode(node);
|
|
4507
|
+
C._ts_query_matches_wasm(
|
|
4508
|
+
this[0],
|
|
4509
|
+
node.tree[0],
|
|
4510
|
+
startPosition.row,
|
|
4511
|
+
startPosition.column,
|
|
4512
|
+
endPosition.row,
|
|
4513
|
+
endPosition.column,
|
|
4514
|
+
startIndex,
|
|
4515
|
+
endIndex,
|
|
4516
|
+
startContainingPosition.row,
|
|
4517
|
+
startContainingPosition.column,
|
|
4518
|
+
endContainingPosition.row,
|
|
4519
|
+
endContainingPosition.column,
|
|
4520
|
+
startContainingIndex,
|
|
4521
|
+
endContainingIndex,
|
|
4522
|
+
matchLimit,
|
|
4523
|
+
maxStartDepth
|
|
4524
|
+
);
|
|
4525
|
+
},
|
|
4526
|
+
(exceededMatchLimit) => {
|
|
4527
|
+
this.matchLimit = matchLimit;
|
|
4528
|
+
this.exceededMatchLimit = exceededMatchLimit;
|
|
4529
|
+
},
|
|
4530
|
+
(rawCount, startAddress) => {
|
|
4531
|
+
const result = new Array(rawCount);
|
|
4532
|
+
let filteredCount = 0;
|
|
4533
|
+
let address = startAddress;
|
|
4534
|
+
for (let i2 = 0; i2 < rawCount; i2++) {
|
|
4535
|
+
const patternIndex = C.getValue(address, "i32");
|
|
4536
|
+
address += SIZE_OF_INT;
|
|
4537
|
+
const captureCount = C.getValue(address, "i32");
|
|
4538
|
+
address += SIZE_OF_INT;
|
|
4539
|
+
const captures = new Array(captureCount);
|
|
4540
|
+
address = unmarshalCaptures(this, node.tree, address, patternIndex, captures);
|
|
4541
|
+
if (this.textPredicates[patternIndex].every((p) => p(captures))) {
|
|
4542
|
+
result[filteredCount] = { patternIndex, captures };
|
|
4543
|
+
const setProperties = this.setProperties[patternIndex];
|
|
4544
|
+
result[filteredCount].setProperties = setProperties;
|
|
4545
|
+
const assertedProperties = this.assertedProperties[patternIndex];
|
|
4546
|
+
result[filteredCount].assertedProperties = assertedProperties;
|
|
4547
|
+
const refutedProperties = this.refutedProperties[patternIndex];
|
|
4548
|
+
result[filteredCount].refutedProperties = refutedProperties;
|
|
4549
|
+
filteredCount++;
|
|
4550
|
+
}
|
|
4551
|
+
}
|
|
4552
|
+
result.length = filteredCount;
|
|
4553
|
+
return result;
|
|
4562
4554
|
}
|
|
4563
|
-
|
|
4564
|
-
result.length = filteredCount;
|
|
4565
|
-
C._free(startAddress);
|
|
4566
|
-
C.currentQueryProgressCallback = null;
|
|
4567
|
-
return result;
|
|
4555
|
+
);
|
|
4568
4556
|
}
|
|
4569
4557
|
/**
|
|
4570
4558
|
* Iterate over all of the individual captures in the order that they
|
|
@@ -4578,85 +4566,71 @@ var Query = class {
|
|
|
4578
4566
|
* @param {QueryOptions} options - Options for query execution.
|
|
4579
4567
|
*/
|
|
4580
4568
|
captures(node, options = {}) {
|
|
4581
|
-
const
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
const endIndex = options.endIndex ?? 0;
|
|
4585
|
-
const startContainingPosition = options.startContainingPosition ?? ZERO_POINT;
|
|
4586
|
-
const endContainingPosition = options.endContainingPosition ?? ZERO_POINT;
|
|
4587
|
-
const startContainingIndex = options.startContainingIndex ?? 0;
|
|
4588
|
-
const endContainingIndex = options.endContainingIndex ?? 0;
|
|
4589
|
-
const matchLimit = options.matchLimit ?? 4294967295;
|
|
4590
|
-
const maxStartDepth = options.maxStartDepth ?? 4294967295;
|
|
4591
|
-
const progressCallback = options.progressCallback;
|
|
4592
|
-
if (typeof matchLimit !== "number") {
|
|
4593
|
-
throw new Error("Arguments must be numbers");
|
|
4594
|
-
}
|
|
4595
|
-
this.matchLimit = matchLimit;
|
|
4596
|
-
if (endIndex !== 0 && startIndex > endIndex) {
|
|
4597
|
-
throw new Error("`startIndex` cannot be greater than `endIndex`");
|
|
4598
|
-
}
|
|
4599
|
-
if (endPosition !== ZERO_POINT && (startPosition.row > endPosition.row || startPosition.row === endPosition.row && startPosition.column > endPosition.column)) {
|
|
4600
|
-
throw new Error("`startPosition` cannot be greater than `endPosition`");
|
|
4601
|
-
}
|
|
4602
|
-
if (endContainingIndex !== 0 && startContainingIndex > endContainingIndex) {
|
|
4603
|
-
throw new Error("`startContainingIndex` cannot be greater than `endContainingIndex`");
|
|
4604
|
-
}
|
|
4605
|
-
if (endContainingPosition !== ZERO_POINT && (startContainingPosition.row > endContainingPosition.row || startContainingPosition.row === endContainingPosition.row && startContainingPosition.column > endContainingPosition.column)) {
|
|
4606
|
-
throw new Error("`startContainingPosition` cannot be greater than `endContainingPosition`");
|
|
4607
|
-
}
|
|
4608
|
-
if (progressCallback) {
|
|
4609
|
-
C.currentQueryProgressCallback = progressCallback;
|
|
4610
|
-
}
|
|
4611
|
-
marshalNode(node);
|
|
4612
|
-
C._ts_query_captures_wasm(
|
|
4613
|
-
this[0],
|
|
4614
|
-
node.tree[0],
|
|
4615
|
-
startPosition.row,
|
|
4616
|
-
startPosition.column,
|
|
4617
|
-
endPosition.row,
|
|
4618
|
-
endPosition.column,
|
|
4569
|
+
const {
|
|
4570
|
+
startPosition,
|
|
4571
|
+
endPosition,
|
|
4619
4572
|
startIndex,
|
|
4620
4573
|
endIndex,
|
|
4621
|
-
startContainingPosition
|
|
4622
|
-
|
|
4623
|
-
endContainingPosition.row,
|
|
4624
|
-
endContainingPosition.column,
|
|
4574
|
+
startContainingPosition,
|
|
4575
|
+
endContainingPosition,
|
|
4625
4576
|
startContainingIndex,
|
|
4626
4577
|
endContainingIndex,
|
|
4627
4578
|
matchLimit,
|
|
4628
|
-
maxStartDepth
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
const
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4579
|
+
maxStartDepth,
|
|
4580
|
+
progressCallback
|
|
4581
|
+
} = prepareQuery(this, options);
|
|
4582
|
+
const callback = progressCallback;
|
|
4583
|
+
return executeQuery(
|
|
4584
|
+
callback ? (state) => callback(state) === true : void 0,
|
|
4585
|
+
() => {
|
|
4586
|
+
marshalNode(node);
|
|
4587
|
+
C._ts_query_captures_wasm(
|
|
4588
|
+
this[0],
|
|
4589
|
+
node.tree[0],
|
|
4590
|
+
startPosition.row,
|
|
4591
|
+
startPosition.column,
|
|
4592
|
+
endPosition.row,
|
|
4593
|
+
endPosition.column,
|
|
4594
|
+
startIndex,
|
|
4595
|
+
endIndex,
|
|
4596
|
+
startContainingPosition.row,
|
|
4597
|
+
startContainingPosition.column,
|
|
4598
|
+
endContainingPosition.row,
|
|
4599
|
+
endContainingPosition.column,
|
|
4600
|
+
startContainingIndex,
|
|
4601
|
+
endContainingIndex,
|
|
4602
|
+
matchLimit,
|
|
4603
|
+
maxStartDepth
|
|
4604
|
+
);
|
|
4605
|
+
},
|
|
4606
|
+
(exceededMatchLimit) => {
|
|
4607
|
+
this.matchLimit = matchLimit;
|
|
4608
|
+
this.exceededMatchLimit = exceededMatchLimit;
|
|
4609
|
+
},
|
|
4610
|
+
(count, startAddress) => {
|
|
4611
|
+
const result = new Array();
|
|
4612
|
+
const captures = new Array();
|
|
4613
|
+
let address = startAddress;
|
|
4614
|
+
for (let i2 = 0; i2 < count; i2++) {
|
|
4615
|
+
const patternIndex = C.getValue(address, "i32");
|
|
4616
|
+
address += SIZE_OF_INT;
|
|
4617
|
+
const captureCount = C.getValue(address, "i32");
|
|
4618
|
+
address += SIZE_OF_INT;
|
|
4619
|
+
const captureIndex = C.getValue(address, "i32");
|
|
4620
|
+
address += SIZE_OF_INT;
|
|
4621
|
+
captures.length = captureCount;
|
|
4622
|
+
address = unmarshalCaptures(this, node.tree, address, patternIndex, captures);
|
|
4623
|
+
if (this.textPredicates[patternIndex].every((p) => p(captures))) {
|
|
4624
|
+
const capture = captures[captureIndex];
|
|
4625
|
+
capture.setProperties = this.setProperties[patternIndex];
|
|
4626
|
+
capture.assertedProperties = this.assertedProperties[patternIndex];
|
|
4627
|
+
capture.refutedProperties = this.refutedProperties[patternIndex];
|
|
4628
|
+
result.push(capture);
|
|
4629
|
+
}
|
|
4630
|
+
}
|
|
4631
|
+
return result;
|
|
4655
4632
|
}
|
|
4656
|
-
|
|
4657
|
-
C._free(startAddress);
|
|
4658
|
-
C.currentQueryProgressCallback = null;
|
|
4659
|
-
return result;
|
|
4633
|
+
);
|
|
4660
4634
|
}
|
|
4661
4635
|
/** Get the predicates for a given pattern. */
|
|
4662
4636
|
predicatesForPattern(patternIndex) {
|
|
@@ -4741,6 +4715,81 @@ var Query = class {
|
|
|
4741
4715
|
return C._ts_query_is_pattern_guaranteed_at_step(this[0], byteIndex) === 1;
|
|
4742
4716
|
}
|
|
4743
4717
|
};
|
|
4718
|
+
function prepareQuery(query, options) {
|
|
4719
|
+
const parameters = {
|
|
4720
|
+
startPosition: options.startPosition ?? ZERO_POINT,
|
|
4721
|
+
endPosition: options.endPosition ?? ZERO_POINT,
|
|
4722
|
+
startIndex: options.startIndex ?? 0,
|
|
4723
|
+
endIndex: options.endIndex ?? 0,
|
|
4724
|
+
startContainingPosition: options.startContainingPosition ?? ZERO_POINT,
|
|
4725
|
+
endContainingPosition: options.endContainingPosition ?? ZERO_POINT,
|
|
4726
|
+
startContainingIndex: options.startContainingIndex ?? 0,
|
|
4727
|
+
endContainingIndex: options.endContainingIndex ?? 0,
|
|
4728
|
+
matchLimit: options.matchLimit ?? 4294967295,
|
|
4729
|
+
maxStartDepth: options.maxStartDepth ?? 4294967295,
|
|
4730
|
+
progressCallback: options.progressCallback
|
|
4731
|
+
};
|
|
4732
|
+
const {
|
|
4733
|
+
startPosition,
|
|
4734
|
+
endPosition,
|
|
4735
|
+
startIndex,
|
|
4736
|
+
endIndex,
|
|
4737
|
+
startContainingPosition,
|
|
4738
|
+
endContainingPosition,
|
|
4739
|
+
startContainingIndex,
|
|
4740
|
+
endContainingIndex,
|
|
4741
|
+
matchLimit
|
|
4742
|
+
} = parameters;
|
|
4743
|
+
if (typeof matchLimit !== "number") {
|
|
4744
|
+
throw new Error("Arguments must be numbers");
|
|
4745
|
+
}
|
|
4746
|
+
query.matchLimit = matchLimit;
|
|
4747
|
+
if (endIndex !== 0 && startIndex > endIndex) {
|
|
4748
|
+
throw new Error("`startIndex` cannot be greater than `endIndex`");
|
|
4749
|
+
}
|
|
4750
|
+
if (endPosition !== ZERO_POINT && (startPosition.row > endPosition.row || startPosition.row === endPosition.row && startPosition.column > endPosition.column)) {
|
|
4751
|
+
throw new Error("`startPosition` cannot be greater than `endPosition`");
|
|
4752
|
+
}
|
|
4753
|
+
if (endContainingIndex !== 0 && startContainingIndex > endContainingIndex) {
|
|
4754
|
+
throw new Error("`startContainingIndex` cannot be greater than `endContainingIndex`");
|
|
4755
|
+
}
|
|
4756
|
+
if (endContainingPosition !== ZERO_POINT && (startContainingPosition.row > endContainingPosition.row || startContainingPosition.row === endContainingPosition.row && startContainingPosition.column > endContainingPosition.column)) {
|
|
4757
|
+
throw new Error("`startContainingPosition` cannot be greater than `endContainingPosition`");
|
|
4758
|
+
}
|
|
4759
|
+
return parameters;
|
|
4760
|
+
}
|
|
4761
|
+
__name(prepareQuery, "prepareQuery");
|
|
4762
|
+
function executeQuery(progressCallback, execute, updateState, readResult) {
|
|
4763
|
+
const previousCallback = C.currentQueryProgressCallback;
|
|
4764
|
+
let callbackFailure;
|
|
4765
|
+
C.currentQueryProgressCallback = progressCallback ? (state) => {
|
|
4766
|
+
try {
|
|
4767
|
+
return progressCallback(state);
|
|
4768
|
+
} catch (error) {
|
|
4769
|
+
callbackFailure = { error };
|
|
4770
|
+
return true;
|
|
4771
|
+
}
|
|
4772
|
+
} : null;
|
|
4773
|
+
try {
|
|
4774
|
+
execute();
|
|
4775
|
+
} finally {
|
|
4776
|
+
C.currentQueryProgressCallback = previousCallback;
|
|
4777
|
+
}
|
|
4778
|
+
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
4779
|
+
const address = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
4780
|
+
const exceededMatchLimit = Boolean(C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32"));
|
|
4781
|
+
try {
|
|
4782
|
+
updateState(exceededMatchLimit);
|
|
4783
|
+
if (callbackFailure) {
|
|
4784
|
+
throw callbackFailure.error;
|
|
4785
|
+
}
|
|
4786
|
+
return readResult(count, address);
|
|
4787
|
+
} finally {
|
|
4788
|
+
C._free(address);
|
|
4789
|
+
updateState(exceededMatchLimit);
|
|
4790
|
+
}
|
|
4791
|
+
}
|
|
4792
|
+
__name(executeQuery, "executeQuery");
|
|
4744
4793
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4745
4794
|
0 && (module.exports = {
|
|
4746
4795
|
CaptureQuantifier,
|