@willbooster/web-tree-sitter 2.0.20 → 2.0.22
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
package/package.json
CHANGED
package/web-tree-sitter.cjs
CHANGED
|
@@ -3887,84 +3887,72 @@ var Query = class {
|
|
|
3887
3887
|
* @param {QueryOptions} options - Options for query execution.
|
|
3888
3888
|
*/
|
|
3889
3889
|
matches(node, options = {}) {
|
|
3890
|
-
const
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
const endIndex = options.endIndex ?? 0;
|
|
3894
|
-
const startContainingPosition = options.startContainingPosition ?? ZERO_POINT;
|
|
3895
|
-
const endContainingPosition = options.endContainingPosition ?? ZERO_POINT;
|
|
3896
|
-
const startContainingIndex = options.startContainingIndex ?? 0;
|
|
3897
|
-
const endContainingIndex = options.endContainingIndex ?? 0;
|
|
3898
|
-
const matchLimit = options.matchLimit ?? 4294967295;
|
|
3899
|
-
const maxStartDepth = options.maxStartDepth ?? 4294967295;
|
|
3900
|
-
const progressCallback = options.progressCallback;
|
|
3901
|
-
if (typeof matchLimit !== "number") {
|
|
3902
|
-
throw new Error("Arguments must be numbers");
|
|
3903
|
-
}
|
|
3904
|
-
this.matchLimit = matchLimit;
|
|
3905
|
-
if (endIndex !== 0 && startIndex > endIndex) {
|
|
3906
|
-
throw new Error("`startIndex` cannot be greater than `endIndex`");
|
|
3907
|
-
}
|
|
3908
|
-
if (endPosition !== ZERO_POINT && (startPosition.row > endPosition.row || startPosition.row === endPosition.row && startPosition.column > endPosition.column)) {
|
|
3909
|
-
throw new Error("`startPosition` cannot be greater than `endPosition`");
|
|
3910
|
-
}
|
|
3911
|
-
if (endContainingIndex !== 0 && startContainingIndex > endContainingIndex) {
|
|
3912
|
-
throw new Error("`startContainingIndex` cannot be greater than `endContainingIndex`");
|
|
3913
|
-
}
|
|
3914
|
-
if (endContainingPosition !== ZERO_POINT && (startContainingPosition.row > endContainingPosition.row || startContainingPosition.row === endContainingPosition.row && startContainingPosition.column > endContainingPosition.column)) {
|
|
3915
|
-
throw new Error("`startContainingPosition` cannot be greater than `endContainingPosition`");
|
|
3916
|
-
}
|
|
3917
|
-
if (progressCallback) {
|
|
3918
|
-
C.currentQueryProgressCallback = progressCallback;
|
|
3919
|
-
}
|
|
3920
|
-
marshalNode(node);
|
|
3921
|
-
C._ts_query_matches_wasm(
|
|
3922
|
-
this[0],
|
|
3923
|
-
node.tree[0],
|
|
3924
|
-
startPosition.row,
|
|
3925
|
-
startPosition.column,
|
|
3926
|
-
endPosition.row,
|
|
3927
|
-
endPosition.column,
|
|
3890
|
+
const {
|
|
3891
|
+
startPosition,
|
|
3892
|
+
endPosition,
|
|
3928
3893
|
startIndex,
|
|
3929
3894
|
endIndex,
|
|
3930
|
-
startContainingPosition
|
|
3931
|
-
|
|
3932
|
-
endContainingPosition.row,
|
|
3933
|
-
endContainingPosition.column,
|
|
3895
|
+
startContainingPosition,
|
|
3896
|
+
endContainingPosition,
|
|
3934
3897
|
startContainingIndex,
|
|
3935
3898
|
endContainingIndex,
|
|
3936
3899
|
matchLimit,
|
|
3937
|
-
maxStartDepth
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3900
|
+
maxStartDepth,
|
|
3901
|
+
progressCallback
|
|
3902
|
+
} = prepareQuery(this, options);
|
|
3903
|
+
return executeQuery(
|
|
3904
|
+
progressCallback,
|
|
3905
|
+
() => {
|
|
3906
|
+
marshalNode(node);
|
|
3907
|
+
C._ts_query_matches_wasm(
|
|
3908
|
+
this[0],
|
|
3909
|
+
node.tree[0],
|
|
3910
|
+
startPosition.row,
|
|
3911
|
+
startPosition.column,
|
|
3912
|
+
endPosition.row,
|
|
3913
|
+
endPosition.column,
|
|
3914
|
+
startIndex,
|
|
3915
|
+
endIndex,
|
|
3916
|
+
startContainingPosition.row,
|
|
3917
|
+
startContainingPosition.column,
|
|
3918
|
+
endContainingPosition.row,
|
|
3919
|
+
endContainingPosition.column,
|
|
3920
|
+
startContainingIndex,
|
|
3921
|
+
endContainingIndex,
|
|
3922
|
+
matchLimit,
|
|
3923
|
+
maxStartDepth
|
|
3924
|
+
);
|
|
3925
|
+
},
|
|
3926
|
+
(exceededMatchLimit) => {
|
|
3927
|
+
this.matchLimit = matchLimit;
|
|
3928
|
+
this.exceededMatchLimit = exceededMatchLimit;
|
|
3929
|
+
},
|
|
3930
|
+
(rawCount, startAddress) => {
|
|
3931
|
+
const result = new Array(rawCount);
|
|
3932
|
+
let filteredCount = 0;
|
|
3933
|
+
let address = startAddress;
|
|
3934
|
+
for (let i2 = 0; i2 < rawCount; i2++) {
|
|
3935
|
+
const patternIndex = C.getValue(address, "i32");
|
|
3936
|
+
address += SIZE_OF_INT;
|
|
3937
|
+
const captureCount = C.getValue(address, "i32");
|
|
3938
|
+
address += SIZE_OF_INT;
|
|
3939
|
+
const captures = new Array(captureCount);
|
|
3940
|
+
address = unmarshalCaptures(this, node.tree, address, patternIndex, captures);
|
|
3941
|
+
if (this.textPredicates[patternIndex].every((p) => p(captures))) {
|
|
3942
|
+
result[filteredCount] = { patternIndex, captures };
|
|
3943
|
+
const setProperties = this.setProperties[patternIndex];
|
|
3944
|
+
result[filteredCount].setProperties = setProperties;
|
|
3945
|
+
const assertedProperties = this.assertedProperties[patternIndex];
|
|
3946
|
+
result[filteredCount].assertedProperties = assertedProperties;
|
|
3947
|
+
const refutedProperties = this.refutedProperties[patternIndex];
|
|
3948
|
+
result[filteredCount].refutedProperties = refutedProperties;
|
|
3949
|
+
filteredCount++;
|
|
3950
|
+
}
|
|
3951
|
+
}
|
|
3952
|
+
result.length = filteredCount;
|
|
3953
|
+
return result;
|
|
3962
3954
|
}
|
|
3963
|
-
|
|
3964
|
-
result.length = filteredCount;
|
|
3965
|
-
C._free(startAddress);
|
|
3966
|
-
C.currentQueryProgressCallback = null;
|
|
3967
|
-
return result;
|
|
3955
|
+
);
|
|
3968
3956
|
}
|
|
3969
3957
|
/**
|
|
3970
3958
|
* Iterate over all of the individual captures in the order that they
|
|
@@ -3978,85 +3966,71 @@ var Query = class {
|
|
|
3978
3966
|
* @param {QueryOptions} options - Options for query execution.
|
|
3979
3967
|
*/
|
|
3980
3968
|
captures(node, options = {}) {
|
|
3981
|
-
const
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
const endIndex = options.endIndex ?? 0;
|
|
3985
|
-
const startContainingPosition = options.startContainingPosition ?? ZERO_POINT;
|
|
3986
|
-
const endContainingPosition = options.endContainingPosition ?? ZERO_POINT;
|
|
3987
|
-
const startContainingIndex = options.startContainingIndex ?? 0;
|
|
3988
|
-
const endContainingIndex = options.endContainingIndex ?? 0;
|
|
3989
|
-
const matchLimit = options.matchLimit ?? 4294967295;
|
|
3990
|
-
const maxStartDepth = options.maxStartDepth ?? 4294967295;
|
|
3991
|
-
const progressCallback = options.progressCallback;
|
|
3992
|
-
if (typeof matchLimit !== "number") {
|
|
3993
|
-
throw new Error("Arguments must be numbers");
|
|
3994
|
-
}
|
|
3995
|
-
this.matchLimit = matchLimit;
|
|
3996
|
-
if (endIndex !== 0 && startIndex > endIndex) {
|
|
3997
|
-
throw new Error("`startIndex` cannot be greater than `endIndex`");
|
|
3998
|
-
}
|
|
3999
|
-
if (endPosition !== ZERO_POINT && (startPosition.row > endPosition.row || startPosition.row === endPosition.row && startPosition.column > endPosition.column)) {
|
|
4000
|
-
throw new Error("`startPosition` cannot be greater than `endPosition`");
|
|
4001
|
-
}
|
|
4002
|
-
if (endContainingIndex !== 0 && startContainingIndex > endContainingIndex) {
|
|
4003
|
-
throw new Error("`startContainingIndex` cannot be greater than `endContainingIndex`");
|
|
4004
|
-
}
|
|
4005
|
-
if (endContainingPosition !== ZERO_POINT && (startContainingPosition.row > endContainingPosition.row || startContainingPosition.row === endContainingPosition.row && startContainingPosition.column > endContainingPosition.column)) {
|
|
4006
|
-
throw new Error("`startContainingPosition` cannot be greater than `endContainingPosition`");
|
|
4007
|
-
}
|
|
4008
|
-
if (progressCallback) {
|
|
4009
|
-
C.currentQueryProgressCallback = progressCallback;
|
|
4010
|
-
}
|
|
4011
|
-
marshalNode(node);
|
|
4012
|
-
C._ts_query_captures_wasm(
|
|
4013
|
-
this[0],
|
|
4014
|
-
node.tree[0],
|
|
4015
|
-
startPosition.row,
|
|
4016
|
-
startPosition.column,
|
|
4017
|
-
endPosition.row,
|
|
4018
|
-
endPosition.column,
|
|
3969
|
+
const {
|
|
3970
|
+
startPosition,
|
|
3971
|
+
endPosition,
|
|
4019
3972
|
startIndex,
|
|
4020
3973
|
endIndex,
|
|
4021
|
-
startContainingPosition
|
|
4022
|
-
|
|
4023
|
-
endContainingPosition.row,
|
|
4024
|
-
endContainingPosition.column,
|
|
3974
|
+
startContainingPosition,
|
|
3975
|
+
endContainingPosition,
|
|
4025
3976
|
startContainingIndex,
|
|
4026
3977
|
endContainingIndex,
|
|
4027
3978
|
matchLimit,
|
|
4028
|
-
maxStartDepth
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
const
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
3979
|
+
maxStartDepth,
|
|
3980
|
+
progressCallback
|
|
3981
|
+
} = prepareQuery(this, options);
|
|
3982
|
+
const callback = progressCallback;
|
|
3983
|
+
return executeQuery(
|
|
3984
|
+
callback ? (state) => callback(state) === true : void 0,
|
|
3985
|
+
() => {
|
|
3986
|
+
marshalNode(node);
|
|
3987
|
+
C._ts_query_captures_wasm(
|
|
3988
|
+
this[0],
|
|
3989
|
+
node.tree[0],
|
|
3990
|
+
startPosition.row,
|
|
3991
|
+
startPosition.column,
|
|
3992
|
+
endPosition.row,
|
|
3993
|
+
endPosition.column,
|
|
3994
|
+
startIndex,
|
|
3995
|
+
endIndex,
|
|
3996
|
+
startContainingPosition.row,
|
|
3997
|
+
startContainingPosition.column,
|
|
3998
|
+
endContainingPosition.row,
|
|
3999
|
+
endContainingPosition.column,
|
|
4000
|
+
startContainingIndex,
|
|
4001
|
+
endContainingIndex,
|
|
4002
|
+
matchLimit,
|
|
4003
|
+
maxStartDepth
|
|
4004
|
+
);
|
|
4005
|
+
},
|
|
4006
|
+
(exceededMatchLimit) => {
|
|
4007
|
+
this.matchLimit = matchLimit;
|
|
4008
|
+
this.exceededMatchLimit = exceededMatchLimit;
|
|
4009
|
+
},
|
|
4010
|
+
(count, startAddress) => {
|
|
4011
|
+
const result = new Array();
|
|
4012
|
+
const captures = new Array();
|
|
4013
|
+
let address = startAddress;
|
|
4014
|
+
for (let i2 = 0; i2 < count; i2++) {
|
|
4015
|
+
const patternIndex = C.getValue(address, "i32");
|
|
4016
|
+
address += SIZE_OF_INT;
|
|
4017
|
+
const captureCount = C.getValue(address, "i32");
|
|
4018
|
+
address += SIZE_OF_INT;
|
|
4019
|
+
const captureIndex = C.getValue(address, "i32");
|
|
4020
|
+
address += SIZE_OF_INT;
|
|
4021
|
+
captures.length = captureCount;
|
|
4022
|
+
address = unmarshalCaptures(this, node.tree, address, patternIndex, captures);
|
|
4023
|
+
if (this.textPredicates[patternIndex].every((p) => p(captures))) {
|
|
4024
|
+
const capture = captures[captureIndex];
|
|
4025
|
+
capture.setProperties = this.setProperties[patternIndex];
|
|
4026
|
+
capture.assertedProperties = this.assertedProperties[patternIndex];
|
|
4027
|
+
capture.refutedProperties = this.refutedProperties[patternIndex];
|
|
4028
|
+
result.push(capture);
|
|
4029
|
+
}
|
|
4030
|
+
}
|
|
4031
|
+
return result;
|
|
4055
4032
|
}
|
|
4056
|
-
|
|
4057
|
-
C._free(startAddress);
|
|
4058
|
-
C.currentQueryProgressCallback = null;
|
|
4059
|
-
return result;
|
|
4033
|
+
);
|
|
4060
4034
|
}
|
|
4061
4035
|
/** Get the predicates for a given pattern. */
|
|
4062
4036
|
predicatesForPattern(patternIndex) {
|
|
@@ -4141,6 +4115,81 @@ var Query = class {
|
|
|
4141
4115
|
return C._ts_query_is_pattern_guaranteed_at_step(this[0], byteIndex) === 1;
|
|
4142
4116
|
}
|
|
4143
4117
|
};
|
|
4118
|
+
function prepareQuery(query, options) {
|
|
4119
|
+
const parameters = {
|
|
4120
|
+
startPosition: options.startPosition ?? ZERO_POINT,
|
|
4121
|
+
endPosition: options.endPosition ?? ZERO_POINT,
|
|
4122
|
+
startIndex: options.startIndex ?? 0,
|
|
4123
|
+
endIndex: options.endIndex ?? 0,
|
|
4124
|
+
startContainingPosition: options.startContainingPosition ?? ZERO_POINT,
|
|
4125
|
+
endContainingPosition: options.endContainingPosition ?? ZERO_POINT,
|
|
4126
|
+
startContainingIndex: options.startContainingIndex ?? 0,
|
|
4127
|
+
endContainingIndex: options.endContainingIndex ?? 0,
|
|
4128
|
+
matchLimit: options.matchLimit ?? 4294967295,
|
|
4129
|
+
maxStartDepth: options.maxStartDepth ?? 4294967295,
|
|
4130
|
+
progressCallback: options.progressCallback
|
|
4131
|
+
};
|
|
4132
|
+
const {
|
|
4133
|
+
startPosition,
|
|
4134
|
+
endPosition,
|
|
4135
|
+
startIndex,
|
|
4136
|
+
endIndex,
|
|
4137
|
+
startContainingPosition,
|
|
4138
|
+
endContainingPosition,
|
|
4139
|
+
startContainingIndex,
|
|
4140
|
+
endContainingIndex,
|
|
4141
|
+
matchLimit
|
|
4142
|
+
} = parameters;
|
|
4143
|
+
if (typeof matchLimit !== "number") {
|
|
4144
|
+
throw new Error("Arguments must be numbers");
|
|
4145
|
+
}
|
|
4146
|
+
query.matchLimit = matchLimit;
|
|
4147
|
+
if (endIndex !== 0 && startIndex > endIndex) {
|
|
4148
|
+
throw new Error("`startIndex` cannot be greater than `endIndex`");
|
|
4149
|
+
}
|
|
4150
|
+
if (endPosition !== ZERO_POINT && (startPosition.row > endPosition.row || startPosition.row === endPosition.row && startPosition.column > endPosition.column)) {
|
|
4151
|
+
throw new Error("`startPosition` cannot be greater than `endPosition`");
|
|
4152
|
+
}
|
|
4153
|
+
if (endContainingIndex !== 0 && startContainingIndex > endContainingIndex) {
|
|
4154
|
+
throw new Error("`startContainingIndex` cannot be greater than `endContainingIndex`");
|
|
4155
|
+
}
|
|
4156
|
+
if (endContainingPosition !== ZERO_POINT && (startContainingPosition.row > endContainingPosition.row || startContainingPosition.row === endContainingPosition.row && startContainingPosition.column > endContainingPosition.column)) {
|
|
4157
|
+
throw new Error("`startContainingPosition` cannot be greater than `endContainingPosition`");
|
|
4158
|
+
}
|
|
4159
|
+
return parameters;
|
|
4160
|
+
}
|
|
4161
|
+
__name(prepareQuery, "prepareQuery");
|
|
4162
|
+
function executeQuery(progressCallback, execute, updateState, readResult) {
|
|
4163
|
+
const previousCallback = C.currentQueryProgressCallback;
|
|
4164
|
+
let callbackFailure;
|
|
4165
|
+
C.currentQueryProgressCallback = progressCallback ? (state) => {
|
|
4166
|
+
try {
|
|
4167
|
+
return progressCallback(state);
|
|
4168
|
+
} catch (error) {
|
|
4169
|
+
callbackFailure = { error };
|
|
4170
|
+
return true;
|
|
4171
|
+
}
|
|
4172
|
+
} : null;
|
|
4173
|
+
try {
|
|
4174
|
+
execute();
|
|
4175
|
+
} finally {
|
|
4176
|
+
C.currentQueryProgressCallback = previousCallback;
|
|
4177
|
+
}
|
|
4178
|
+
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
4179
|
+
const address = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
4180
|
+
const exceededMatchLimit = Boolean(C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32"));
|
|
4181
|
+
try {
|
|
4182
|
+
updateState(exceededMatchLimit);
|
|
4183
|
+
if (callbackFailure) {
|
|
4184
|
+
throw callbackFailure.error;
|
|
4185
|
+
}
|
|
4186
|
+
return readResult(count, address);
|
|
4187
|
+
} finally {
|
|
4188
|
+
C._free(address);
|
|
4189
|
+
updateState(exceededMatchLimit);
|
|
4190
|
+
}
|
|
4191
|
+
}
|
|
4192
|
+
__name(executeQuery, "executeQuery");
|
|
4144
4193
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4145
4194
|
0 && (module.exports = {
|
|
4146
4195
|
CaptureQuantifier,
|