@willbooster/web-tree-sitter 10.0.5 → 11.0.1

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.
@@ -726,7 +726,7 @@
726
726
  gotoDescendant(goalDescendantIndex: number): void;
727
727
  /**
728
728
  * Move this cursor to the first child of its current node that contains or
729
- * starts after the given byte offset.
729
+ * starts after the given index.
730
730
  *
731
731
  * This returns `true` if the cursor successfully moved to a child node, and returns
732
732
  * `false` if no such child was found.
@@ -734,10 +734,10 @@
734
734
  gotoFirstChildForIndex(goalIndex: number): boolean;
735
735
  /**
736
736
  * Move this cursor to the first child of its current node that contains or
737
- * starts after the given byte offset.
737
+ * starts after the given position.
738
738
  *
739
- * This returns the index of the child node if one was found, and returns
740
- * `null` if no such child was found.
739
+ * This returns `true` if the cursor successfully moved to a child node, and returns
740
+ * `false` if no such child was found.
741
741
  */
742
742
  gotoFirstChildForPosition(goalPosition: Point): boolean;
743
743
  /**
@@ -990,9 +990,9 @@
990
990
  * of in-progress matches.
991
991
  */
992
992
  didExceedMatchLimit(): boolean;
993
- /** Get the byte offset where the given pattern starts in the query's source. */
993
+ /** Get the index where the given pattern starts in the query's source. */
994
994
  startIndexForPattern(patternIndex: number): number;
995
- /** Get the byte offset where the given pattern ends in the query's source. */
995
+ /** Get the index where the given pattern ends in the query's source. */
996
996
  endIndexForPattern(patternIndex: number): number;
997
997
  /** Get the number of patterns in the query. */
998
998
  patternCount(): number;
@@ -1003,12 +1003,12 @@
1003
1003
  /** Check if a given pattern within a query has a single root node. */
1004
1004
  isPatternNonLocal(patternIndex: number): boolean;
1005
1005
  /**
1006
- * Check if a given step in a query is 'definite'.
1006
+ * Check if the step at the given index in the query's source is 'definite'.
1007
1007
  *
1008
1008
  * A query step is 'definite' if its parent pattern will be guaranteed to
1009
1009
  * match successfully once it reaches the step.
1010
1010
  */
1011
- isPatternGuaranteedAtStep(byteIndex: number): boolean;
1011
+ isPatternGuaranteedAtStep(index: number): boolean;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;;;;;;;;;;;;;;;;;;cC1BJC,IAAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCIJC,UAAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBCENC,YAAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA2EZC,UAAUA;;;;;aAMfC,eAAeA;;;;kBAKVC,cAAcA;;;;;;;;;;kBAYdC,YAAYA;;;;;;;;;;;;;;;kBAqBZC,UAAUA;;;;;;;;;;;;;cA2BfC,iBAAiBA;;;;;;;;aAAjBA,iBAAiBA;;;;;;;;;;;;aAajBC,aAAaA;;;;;;WAORC,oBAAoBA;;;;;;;;;WAOpBC,mBAAmBA;;;;cAmVvBC,KAAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCxgBLC,iBAAiBA",
60
60
  "ignoreList": []
61
61
  }
@@ -726,7 +726,7 @@
726
726
  gotoDescendant(goalDescendantIndex: number): void;
727
727
  /**
728
728
  * Move this cursor to the first child of its current node that contains or
729
- * starts after the given byte offset.
729
+ * starts after the given index.
730
730
  *
731
731
  * This returns `true` if the cursor successfully moved to a child node, and returns
732
732
  * `false` if no such child was found.
@@ -734,10 +734,10 @@
734
734
  gotoFirstChildForIndex(goalIndex: number): boolean;
735
735
  /**
736
736
  * Move this cursor to the first child of its current node that contains or
737
- * starts after the given byte offset.
737
+ * starts after the given position.
738
738
  *
739
- * This returns the index of the child node if one was found, and returns
740
- * `null` if no such child was found.
739
+ * This returns `true` if the cursor successfully moved to a child node, and returns
740
+ * `false` if no such child was found.
741
741
  */
742
742
  gotoFirstChildForPosition(goalPosition: Point): boolean;
743
743
  /**
@@ -990,9 +990,9 @@
990
990
  * of in-progress matches.
991
991
  */
992
992
  didExceedMatchLimit(): boolean;
993
- /** Get the byte offset where the given pattern starts in the query's source. */
993
+ /** Get the index where the given pattern starts in the query's source. */
994
994
  startIndexForPattern(patternIndex: number): number;
995
- /** Get the byte offset where the given pattern ends in the query's source. */
995
+ /** Get the index where the given pattern ends in the query's source. */
996
996
  endIndexForPattern(patternIndex: number): number;
997
997
  /** Get the number of patterns in the query. */
998
998
  patternCount(): number;
@@ -1003,12 +1003,12 @@
1003
1003
  /** Check if a given pattern within a query has a single root node. */
1004
1004
  isPatternNonLocal(patternIndex: number): boolean;
1005
1005
  /**
1006
- * Check if a given step in a query is 'definite'.
1006
+ * Check if the step at the given index in the query's source is 'definite'.
1007
1007
  *
1008
1008
  * A query step is 'definite' if its parent pattern will be guaranteed to
1009
1009
  * match successfully once it reaches the step.
1010
1010
  */
1011
- isPatternGuaranteedAtStep(byteIndex: number): boolean;
1011
+ isPatternGuaranteedAtStep(index: number): boolean;
1012
1012
  }
1013
1013
  export class LookaheadIterator implements Iterable<string> {
1014
1014
  /**
@@ -56,6 +56,6 @@
56
56
  null,
57
57
  null
58
58
  ],
59
- "mappings": ";;;;;;kBASiBA,KAAKA;;;;;;;;;;kBAYLC,KAAKA;;;;;;;;;;;;;aAsCVC,aAAaA;;;;aAKbC,gBAAgBA;;;;;;aAOhBC,WAAWA;;kBChENC,iBAAiBA;;;;;;;cCLrBC,IAAIA;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;cCIJC,UAAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBCENC,YAAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA2EZC,UAAUA;;;;;aAMfC,eAAeA;;;;kBAKVC,cAAcA;;;;;;;;;;kBAYdC,YAAYA;;;;;;;;;;;;;;;kBAqBZC,UAAUA;;;;;;;;;;;;;cA2BfC,iBAAiBA;;;;;;;;aAAjBA,iBAAiBA;;;;;;;;;;;;aAajBC,aAAaA;;;;;;WAORC,oBAAoBA;;;;;;;;;WAOpBC,mBAAmBA;;;;cAmVvBC,KAAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCxgBLC,iBAAiBA",
60
60
  "ignoreList": []
61
61
  }
@@ -363,29 +363,17 @@ var Tree = class _Tree {
363
363
  };
364
364
 
365
365
  // src/tree_cursor.ts
366
- var finalizer3 = newFinalizer((address) => {
367
- C._ts_tree_cursor_delete_wasm(address);
366
+ var finalizer3 = newFinalizer((handles) => {
367
+ marshalTreeCursor({ handles });
368
+ C._ts_tree_cursor_delete_wasm(0);
368
369
  });
369
370
  var TreeCursor = class _TreeCursor {
370
371
  static {
371
372
  __name(this, "TreeCursor");
372
373
  }
373
374
  /** @internal */
374
- // @ts-expect-error: never read
375
- [0] = 0;
376
- // Internal handle for Wasm
377
- /** @internal */
378
- // @ts-expect-error: never read
379
- [1] = 0;
380
- // Internal handle for Wasm
381
- /** @internal */
382
- // @ts-expect-error: never read
383
- [2] = 0;
384
- // Internal handle for Wasm
385
- /** @internal */
386
- // @ts-expect-error: never read
387
- [3] = 0;
388
- // Internal handle for Wasm
375
+ handles = [0, 0, 0, 0];
376
+ // Internal handles for Wasm, shared with the finalizer.
389
377
  /** @internal */
390
378
  tree;
391
379
  /** @internal */
@@ -393,22 +381,20 @@ var TreeCursor = class _TreeCursor {
393
381
  assertInternal(internal);
394
382
  this.tree = tree;
395
383
  unmarshalTreeCursor(this);
396
- finalizer3?.register(this, this.tree[0], this);
384
+ finalizer3?.register(this, this.handles, this);
397
385
  }
398
386
  /** Creates a deep copy of the tree cursor. This allocates new memory. */
399
387
  copy() {
400
388
  marshalTreeCursor(this);
401
- const copy = new _TreeCursor(INTERNAL, this.tree);
402
389
  C._ts_tree_cursor_copy_wasm(this.tree[0]);
403
- unmarshalTreeCursor(copy);
404
- return copy;
390
+ return new _TreeCursor(INTERNAL, this.tree);
405
391
  }
406
392
  /** Delete the tree cursor, freeing its resources. */
407
393
  delete() {
408
394
  finalizer3?.unregister(this);
409
395
  marshalTreeCursor(this);
410
396
  C._ts_tree_cursor_delete_wasm(this.tree[0]);
411
- this[0] = this[1] = this[2] = 0;
397
+ this.handles.fill(0);
412
398
  }
413
399
  /** Get the tree cursor's current {@link Node}. */
414
400
  get currentNode() {
@@ -605,7 +591,7 @@ var TreeCursor = class _TreeCursor {
605
591
  }
606
592
  /**
607
593
  * Move this cursor to the first child of its current node that contains or
608
- * starts after the given byte offset.
594
+ * starts after the given index.
609
595
  *
610
596
  * This returns `true` if the cursor successfully moved to a child node, and returns
611
597
  * `false` if no such child was found.
@@ -619,10 +605,10 @@ var TreeCursor = class _TreeCursor {
619
605
  }
620
606
  /**
621
607
  * Move this cursor to the first child of its current node that contains or
622
- * starts after the given byte offset.
608
+ * starts after the given position.
623
609
  *
624
- * This returns the index of the child node if one was found, and returns
625
- * `null` if no such child was found.
610
+ * This returns `true` if the cursor successfully moved to a child node, and returns
611
+ * `false` if no such child was found.
626
612
  */
627
613
  gotoFirstChildForPosition(goalPosition) {
628
614
  marshalTreeCursor(this);
@@ -638,8 +624,9 @@ var TreeCursor = class _TreeCursor {
638
624
  reset(node) {
639
625
  marshalNode(node);
640
626
  marshalTreeCursor(this, TRANSFER_BUFFER + SIZE_OF_NODE);
641
- C._ts_tree_cursor_reset_wasm(this.tree[0]);
627
+ C._ts_tree_cursor_reset_wasm(node.tree[0]);
642
628
  unmarshalTreeCursor(this);
629
+ this.tree = node.tree;
643
630
  }
644
631
  /**
645
632
  * Re-initialize a tree cursor to the same position as another cursor.
@@ -652,6 +639,7 @@ var TreeCursor = class _TreeCursor {
652
639
  marshalTreeCursor(cursor, TRANSFER_BUFFER + SIZE_OF_CURSOR);
653
640
  C._ts_tree_cursor_reset_to_wasm(this.tree[0], cursor.tree[0]);
654
641
  unmarshalTreeCursor(this);
642
+ this.tree = cursor.tree;
655
643
  }
656
644
  };
657
645
 
@@ -1012,16 +1000,14 @@ var Node = class {
1012
1000
  if (!Array.isArray(types)) types = [types];
1013
1001
  const symbols = [];
1014
1002
  const typesBySymbol = this.tree.language.types;
1015
- for (const node_type of types) {
1016
- if (node_type == "ERROR") {
1017
- symbols.push(65535);
1018
- }
1019
- }
1020
1003
  for (let i2 = 0, n = typesBySymbol.length; i2 < n; i2++) {
1021
1004
  if (types.includes(typesBySymbol[i2])) {
1022
1005
  symbols.push(i2);
1023
1006
  }
1024
1007
  }
1008
+ if (types.includes("ERROR")) {
1009
+ symbols.push(65535);
1010
+ }
1025
1011
  const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length);
1026
1012
  for (let i2 = 0, n = symbols.length; i2 < n; i2++) {
1027
1013
  C.setValue(symbolsAddress + i2 * SIZE_OF_INT, symbols[i2], "i32");
@@ -1177,31 +1163,9 @@ var Node = class {
1177
1163
  * you want to keep and continue to use after an edit.
1178
1164
  */
1179
1165
  edit(edit) {
1180
- if (this.startIndex >= edit.oldEndIndex) {
1181
- this.startIndex = edit.newEndIndex + (this.startIndex - edit.oldEndIndex);
1182
- let subbedPointRow;
1183
- let subbedPointColumn;
1184
- if (this.startPosition.row > edit.oldEndPosition.row) {
1185
- subbedPointRow = this.startPosition.row - edit.oldEndPosition.row;
1186
- subbedPointColumn = this.startPosition.column;
1187
- } else {
1188
- subbedPointRow = 0;
1189
- subbedPointColumn = this.startPosition.column;
1190
- if (this.startPosition.column >= edit.oldEndPosition.column) {
1191
- subbedPointColumn = this.startPosition.column - edit.oldEndPosition.column;
1192
- }
1193
- }
1194
- if (subbedPointRow > 0) {
1195
- this.startPosition.row += subbedPointRow;
1196
- this.startPosition.column = subbedPointColumn;
1197
- } else {
1198
- this.startPosition.column += subbedPointColumn;
1199
- }
1200
- } else if (this.startIndex > edit.startIndex) {
1201
- this.startIndex = edit.newEndIndex;
1202
- this.startPosition.row = edit.newEndPosition.row;
1203
- this.startPosition.column = edit.newEndPosition.column;
1204
- }
1166
+ const { point, index } = edit.editPoint(this.startPosition, this.startIndex);
1167
+ this.startPosition = point;
1168
+ this.startIndex = index;
1205
1169
  }
1206
1170
  /** Get the S-expression representation of this node. */
1207
1171
  toString() {
@@ -1259,18 +1223,18 @@ function unmarshalNode(tree, address = TRANSFER_BUFFER) {
1259
1223
  return result;
1260
1224
  }
1261
1225
  __name(unmarshalNode, "unmarshalNode");
1262
- function marshalTreeCursor(cursor, address = TRANSFER_BUFFER) {
1263
- C.setValue(address + 0 * SIZE_OF_INT, cursor[0], "i32");
1264
- C.setValue(address + 1 * SIZE_OF_INT, cursor[1], "i32");
1265
- C.setValue(address + 2 * SIZE_OF_INT, cursor[2], "i32");
1266
- C.setValue(address + 3 * SIZE_OF_INT, cursor[3], "i32");
1226
+ function marshalTreeCursor({ handles }, address = TRANSFER_BUFFER) {
1227
+ C.setValue(address + 0 * SIZE_OF_INT, handles[0], "i32");
1228
+ C.setValue(address + 1 * SIZE_OF_INT, handles[1], "i32");
1229
+ C.setValue(address + 2 * SIZE_OF_INT, handles[2], "i32");
1230
+ C.setValue(address + 3 * SIZE_OF_INT, handles[3], "i32");
1267
1231
  }
1268
1232
  __name(marshalTreeCursor, "marshalTreeCursor");
1269
- function unmarshalTreeCursor(cursor) {
1270
- cursor[0] = C.getValue(TRANSFER_BUFFER + 0 * SIZE_OF_INT, "i32");
1271
- cursor[1] = C.getValue(TRANSFER_BUFFER + 1 * SIZE_OF_INT, "i32");
1272
- cursor[2] = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
1273
- cursor[3] = C.getValue(TRANSFER_BUFFER + 3 * SIZE_OF_INT, "i32");
1233
+ function unmarshalTreeCursor({ handles }) {
1234
+ handles[0] = C.getValue(TRANSFER_BUFFER + 0 * SIZE_OF_INT, "i32");
1235
+ handles[1] = C.getValue(TRANSFER_BUFFER + 1 * SIZE_OF_INT, "i32");
1236
+ handles[2] = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
1237
+ handles[3] = C.getValue(TRANSFER_BUFFER + 3 * SIZE_OF_INT, "i32");
1274
1238
  }
1275
1239
  __name(unmarshalTreeCursor, "unmarshalTreeCursor");
1276
1240
  function marshalPoint(address, point) {
@@ -3651,6 +3615,10 @@ function parsePattern(index, stepType, stepValueId, captureNames, stringValues,
3651
3615
  }
3652
3616
  }
3653
3617
  __name(parsePattern, "parsePattern");
3618
+ function indexForByteOffset(source, byteOffset) {
3619
+ return new TextEncoder().encodeInto(source, new Uint8Array(byteOffset)).read;
3620
+ }
3621
+ __name(indexForByteOffset, "indexForByteOffset");
3654
3622
  var finalizer5 = newFinalizer((address) => {
3655
3623
  C._ts_query_delete(address);
3656
3624
  });
@@ -3665,6 +3633,8 @@ var Query = class {
3665
3633
  exceededMatchLimit;
3666
3634
  /** @internal */
3667
3635
  textPredicates;
3636
+ /** @internal */
3637
+ source;
3668
3638
  /** The names of the captures used in the query. */
3669
3639
  captureNames;
3670
3640
  /** The quantifiers of the captures used in the query. */
@@ -3804,6 +3774,7 @@ var Query = class {
3804
3774
  this.captureNames = captureNames;
3805
3775
  this.captureQuantifiers = captureQuantifiers;
3806
3776
  this.textPredicates = textPredicates;
3777
+ this.source = source;
3807
3778
  this.predicates = predicates;
3808
3779
  this.setProperties = setProperties;
3809
3780
  this.assertedProperties = assertedProperties;
@@ -4014,23 +3985,25 @@ var Query = class {
4014
3985
  didExceedMatchLimit() {
4015
3986
  return this.exceededMatchLimit;
4016
3987
  }
4017
- /** Get the byte offset where the given pattern starts in the query's source. */
3988
+ /** Get the index where the given pattern starts in the query's source. */
4018
3989
  startIndexForPattern(patternIndex) {
4019
3990
  if (patternIndex >= this.predicates.length) {
4020
3991
  throw new Error(
4021
3992
  `Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`
4022
3993
  );
4023
3994
  }
4024
- return C._ts_query_start_byte_for_pattern(this[0], patternIndex);
3995
+ const byteOffset = C._ts_query_start_byte_for_pattern(this[0], patternIndex);
3996
+ return indexForByteOffset(this.source, byteOffset);
4025
3997
  }
4026
- /** Get the byte offset where the given pattern ends in the query's source. */
3998
+ /** Get the index where the given pattern ends in the query's source. */
4027
3999
  endIndexForPattern(patternIndex) {
4028
4000
  if (patternIndex >= this.predicates.length) {
4029
4001
  throw new Error(
4030
4002
  `Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`
4031
4003
  );
4032
4004
  }
4033
- return C._ts_query_end_byte_for_pattern(this[0], patternIndex);
4005
+ const byteOffset = C._ts_query_end_byte_for_pattern(this[0], patternIndex);
4006
+ return indexForByteOffset(this.source, byteOffset);
4034
4007
  }
4035
4008
  /** Get the number of patterns in the query. */
4036
4009
  patternCount() {
@@ -4049,13 +4022,14 @@ var Query = class {
4049
4022
  return C._ts_query_is_pattern_non_local(this[0], patternIndex) === 1;
4050
4023
  }
4051
4024
  /**
4052
- * Check if a given step in a query is 'definite'.
4025
+ * Check if the step at the given index in the query's source is 'definite'.
4053
4026
  *
4054
4027
  * A query step is 'definite' if its parent pattern will be guaranteed to
4055
4028
  * match successfully once it reaches the step.
4056
4029
  */
4057
- isPatternGuaranteedAtStep(byteIndex) {
4058
- return C._ts_query_is_pattern_guaranteed_at_step(this[0], byteIndex) === 1;
4030
+ isPatternGuaranteedAtStep(index) {
4031
+ const byteOffset = C.lengthBytesUTF8(this.source.slice(0, index));
4032
+ return C._ts_query_is_pattern_guaranteed_at_step(this[0], byteOffset) === 1;
4059
4033
  }
4060
4034
  };
4061
4035
  function prepareQuery(query, options) {