@willbooster/web-tree-sitter 19.0.2 → 19.1.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.
@@ -202,8 +202,8 @@ var require_web_tree_sitter = __commonJS({
202
202
  if (max == 0) {
203
203
  max += 4;
204
204
  }
205
- LE_HEAP_STORE_U32(SAFE_HEAP_INDEX(HEAPU32, max >> 2, "storing") * 4, 34821223);
206
- LE_HEAP_STORE_U32(SAFE_HEAP_INDEX(HEAPU32, max + 4 >> 2, "storing") * 4, 2310721022);
205
+ HEAPU32[SAFE_HEAP_INDEX(HEAPU32, max >> 2, "storing")] = 34821223;
206
+ HEAPU32[SAFE_HEAP_INDEX(HEAPU32, max + 4 >> 2, "storing")] = 2310721022;
207
207
  }
208
208
  __name(writeStackCookie, "writeStackCookie");
209
209
  function checkStackCookie() {
@@ -212,8 +212,8 @@ var require_web_tree_sitter = __commonJS({
212
212
  if (max == 0) {
213
213
  max += 4;
214
214
  }
215
- var cookie1 = LE_HEAP_LOAD_U32(SAFE_HEAP_INDEX(HEAPU32, max >> 2, "loading") * 4);
216
- var cookie2 = LE_HEAP_LOAD_U32(SAFE_HEAP_INDEX(HEAPU32, max + 4 >> 2, "loading") * 4);
215
+ var cookie1 = HEAPU32[SAFE_HEAP_INDEX(HEAPU32, max >> 2, "loading")];
216
+ var cookie2 = HEAPU32[SAFE_HEAP_INDEX(HEAPU32, max + 4 >> 2, "loading")];
217
217
  if (cookie1 != 34821223 || cookie2 != 2310721022) {
218
218
  abort(`Stack overflow! Stack cookie has been overwritten at ${ptrToString(max)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${ptrToString(cookie2)} ${ptrToString(cookie1)}`);
219
219
  }
@@ -225,6 +225,12 @@ var require_web_tree_sitter = __commonJS({
225
225
  console.warn(...args2);
226
226
  }
227
227
  __name(dbg, "dbg");
228
+ (() => {
229
+ var h16 = new Int16Array(1);
230
+ var h8 = new Int8Array(h16.buffer);
231
+ h16[0] = 25459;
232
+ if (h8[0] !== 115 || h8[1] !== 99) abort("Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)");
233
+ })();
228
234
  function consumedModuleProp(prop) {
229
235
  if (!Object.getOwnPropertyDescriptor(Module, prop)) {
230
236
  Object.defineProperty(Module, prop, {
@@ -295,29 +301,26 @@ var require_web_tree_sitter = __commonJS({
295
301
  var wasmMemory;
296
302
  var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
297
303
  var HEAP64, HEAPU64;
298
- var HEAP_DATA_VIEW;
299
304
  var runtimeInitialized = false;
300
305
  function updateMemoryViews() {
301
306
  var b = wasmMemory.buffer;
302
- Module["HEAP8"] = HEAP8 = new Int8Array(b);
303
- Module["HEAP16"] = HEAP16 = new Int16Array(b);
304
- Module["HEAPU8"] = HEAPU8 = new Uint8Array(b);
307
+ HEAP8 = new Int8Array(b);
308
+ HEAP16 = new Int16Array(b);
309
+ HEAPU8 = new Uint8Array(b);
305
310
  Module["HEAPU16"] = HEAPU16 = new Uint16Array(b);
306
311
  Module["HEAP32"] = HEAP32 = new Int32Array(b);
307
312
  Module["HEAPU32"] = HEAPU32 = new Uint32Array(b);
308
- Module["HEAPF32"] = HEAPF32 = new Float32Array(b);
309
- Module["HEAPF64"] = HEAPF64 = new Float64Array(b);
310
- Module["HEAP64"] = HEAP64 = new BigInt64Array(b);
311
- Module["HEAPU64"] = HEAPU64 = new BigUint64Array(b);
312
- Module["HEAP_DATA_VIEW"] = HEAP_DATA_VIEW = new DataView(b);
313
- LE_HEAP_UPDATE();
313
+ HEAPF32 = new Float32Array(b);
314
+ HEAPF64 = new Float64Array(b);
315
+ HEAP64 = new BigInt64Array(b);
316
+ HEAPU64 = new BigUint64Array(b);
314
317
  }
315
318
  __name(updateMemoryViews, "updateMemoryViews");
316
319
  function initMemory() {
317
320
  if (Module["wasmMemory"]) {
318
321
  wasmMemory = Module["wasmMemory"];
319
322
  } else {
320
- var INITIAL_MEMORY = Module["INITIAL_MEMORY"] || 33554432;
323
+ var INITIAL_MEMORY = Module["INITIAL_MEMORY"] || 4194304;
321
324
  assert(INITIAL_MEMORY >= 65536, "INITIAL_MEMORY should be larger than STACK_SIZE, was " + INITIAL_MEMORY + "! (STACK_SIZE=65536)");
322
325
  wasmMemory = new WebAssembly.Memory({
323
326
  "initial": INITIAL_MEMORY / 65536,
@@ -559,77 +562,6 @@ var require_web_tree_sitter = __commonJS({
559
562
  return rtn;
560
563
  }
561
564
  };
562
- var LE_ATOMICS_ADD = /* @__PURE__ */ __name((heap, offset, value) => {
563
- const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
564
- const res = order(Atomics.add(heap, offset, order(value)));
565
- return heap.unsigned ? heap.unsigned(res) : res;
566
- }, "LE_ATOMICS_ADD");
567
- var LE_ATOMICS_AND = /* @__PURE__ */ __name((heap, offset, value) => {
568
- const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
569
- const res = order(Atomics.and(heap, offset, order(value)));
570
- return heap.unsigned ? heap.unsigned(res) : res;
571
- }, "LE_ATOMICS_AND");
572
- var LE_ATOMICS_COMPAREEXCHANGE = /* @__PURE__ */ __name((heap, offset, expected, replacement) => {
573
- const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
574
- const res = order(Atomics.compareExchange(heap, offset, order(expected), order(replacement)));
575
- return heap.unsigned ? heap.unsigned(res) : res;
576
- }, "LE_ATOMICS_COMPAREEXCHANGE");
577
- var LE_ATOMICS_EXCHANGE = /* @__PURE__ */ __name((heap, offset, value) => {
578
- const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
579
- const res = order(Atomics.exchange(heap, offset, order(value)));
580
- return heap.unsigned ? heap.unsigned(res) : res;
581
- }, "LE_ATOMICS_EXCHANGE");
582
- var LE_ATOMICS_ISLOCKFREE = /* @__PURE__ */ __name((size) => Atomics.isLockFree(size), "LE_ATOMICS_ISLOCKFREE");
583
- var LE_ATOMICS_LOAD = /* @__PURE__ */ __name((heap, offset) => {
584
- const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
585
- const res = order(Atomics.load(heap, offset));
586
- return heap.unsigned ? heap.unsigned(res) : res;
587
- }, "LE_ATOMICS_LOAD");
588
- var LE_ATOMICS_NATIVE_BYTE_ORDER = [];
589
- var LE_ATOMICS_NOTIFY = /* @__PURE__ */ __name((heap, offset, count) => Atomics.notify(heap, offset, count), "LE_ATOMICS_NOTIFY");
590
- var LE_ATOMICS_OR = /* @__PURE__ */ __name((heap, offset, value) => {
591
- const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
592
- const res = order(Atomics.or(heap, offset, order(value)));
593
- return heap.unsigned ? heap.unsigned(res) : res;
594
- }, "LE_ATOMICS_OR");
595
- var LE_ATOMICS_STORE = /* @__PURE__ */ __name((heap, offset, value) => {
596
- const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
597
- Atomics.store(heap, offset, order(value));
598
- }, "LE_ATOMICS_STORE");
599
- var LE_ATOMICS_SUB = /* @__PURE__ */ __name((heap, offset, value) => {
600
- const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
601
- const res = order(Atomics.sub(heap, offset, order(value)));
602
- return heap.unsigned ? heap.unsigned(res) : res;
603
- }, "LE_ATOMICS_SUB");
604
- var LE_ATOMICS_WAIT = /* @__PURE__ */ __name((heap, offset, value, timeout) => {
605
- const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
606
- return Atomics.wait(heap, offset, order(value), timeout);
607
- }, "LE_ATOMICS_WAIT");
608
- var LE_ATOMICS_WAITASYNC = /* @__PURE__ */ __name((heap, offset, value, timeout) => {
609
- const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
610
- return Atomics.waitAsync(heap, offset, order(value), timeout);
611
- }, "LE_ATOMICS_WAITASYNC");
612
- var LE_ATOMICS_XOR = /* @__PURE__ */ __name((heap, offset, value) => {
613
- const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
614
- const res = order(Atomics.xor(heap, offset, order(value)));
615
- return heap.unsigned ? heap.unsigned(res) : res;
616
- }, "LE_ATOMICS_XOR");
617
- var LE_HEAP_LOAD_F32 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getFloat32(byteOffset, true), "LE_HEAP_LOAD_F32");
618
- var LE_HEAP_LOAD_F64 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getFloat64(byteOffset, true), "LE_HEAP_LOAD_F64");
619
- var LE_HEAP_LOAD_I16 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getInt16(byteOffset, true), "LE_HEAP_LOAD_I16");
620
- var LE_HEAP_LOAD_I32 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getInt32(byteOffset, true), "LE_HEAP_LOAD_I32");
621
- var LE_HEAP_LOAD_I64 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getBigInt64(byteOffset, true), "LE_HEAP_LOAD_I64");
622
- var LE_HEAP_LOAD_U16 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getUint16(byteOffset, true), "LE_HEAP_LOAD_U16");
623
- var LE_HEAP_LOAD_U32 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getUint32(byteOffset, true), "LE_HEAP_LOAD_U32");
624
- var LE_HEAP_LOAD_U64 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getBigUint64(byteOffset, true), "LE_HEAP_LOAD_U64");
625
- var LE_HEAP_STORE_F32 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setFloat32(byteOffset, value, true), "LE_HEAP_STORE_F32");
626
- var LE_HEAP_STORE_F64 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setFloat64(byteOffset, value, true), "LE_HEAP_STORE_F64");
627
- var LE_HEAP_STORE_I16 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setInt16(byteOffset, value, true), "LE_HEAP_STORE_I16");
628
- var LE_HEAP_STORE_I32 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setInt32(byteOffset, value, true), "LE_HEAP_STORE_I32");
629
- var LE_HEAP_STORE_I64 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setBigInt64(byteOffset, value, true), "LE_HEAP_STORE_I64");
630
- var LE_HEAP_STORE_U16 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setUint16(byteOffset, value, true), "LE_HEAP_STORE_U16");
631
- var LE_HEAP_STORE_U32 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setUint32(byteOffset, value, true), "LE_HEAP_STORE_U32");
632
- var LE_HEAP_STORE_U64 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setBigUint64(byteOffset, value, true), "LE_HEAP_STORE_U64");
633
565
  var callRuntimeCallbacks = /* @__PURE__ */ __name((callbacks) => {
634
566
  while (callbacks.length > 0) {
635
567
  callbacks.shift()(Module);
@@ -730,7 +662,7 @@ var require_web_tree_sitter = __commonJS({
730
662
  end = binary2.length;
731
663
  } else {
732
664
  var int32View = new Uint32Array(new Uint8Array(binary2.subarray(0, 24)).buffer);
733
- var magicNumberFound = int32View[0] == 1836278016 || int32View[0] == 6386541;
665
+ var magicNumberFound = int32View[0] == 1836278016;
734
666
  failIf(!magicNumberFound, "need to see wasm magic number");
735
667
  failIf(binary2[8] !== 0, "need the dylink section to be first");
736
668
  offset = 9;
@@ -802,17 +734,17 @@ var require_web_tree_sitter = __commonJS({
802
734
  case "i8":
803
735
  return HEAP8[SAFE_HEAP_INDEX(HEAP8, ptr, "loading")];
804
736
  case "i16":
805
- return LE_HEAP_LOAD_I16(SAFE_HEAP_INDEX(HEAP16, ptr >> 1, "loading") * 2);
737
+ return HEAP16[SAFE_HEAP_INDEX(HEAP16, ptr >> 1, "loading")];
806
738
  case "i32":
807
- return LE_HEAP_LOAD_I32(SAFE_HEAP_INDEX(HEAP32, ptr >> 2, "loading") * 4);
739
+ return HEAP32[SAFE_HEAP_INDEX(HEAP32, ptr >> 2, "loading")];
808
740
  case "i64":
809
- return LE_HEAP_LOAD_I64(SAFE_HEAP_INDEX(HEAP64, ptr >> 3, "loading") * 8);
741
+ return HEAP64[SAFE_HEAP_INDEX(HEAP64, ptr >> 3, "loading")];
810
742
  case "float":
811
- return LE_HEAP_LOAD_F32(SAFE_HEAP_INDEX(HEAPF32, ptr >> 2, "loading") * 4);
743
+ return HEAPF32[SAFE_HEAP_INDEX(HEAPF32, ptr >> 2, "loading")];
812
744
  case "double":
813
- return LE_HEAP_LOAD_F64(SAFE_HEAP_INDEX(HEAPF64, ptr >> 3, "loading") * 8);
745
+ return HEAPF64[SAFE_HEAP_INDEX(HEAPF64, ptr >> 3, "loading")];
814
746
  case "*":
815
- return LE_HEAP_LOAD_U32(SAFE_HEAP_INDEX(HEAPU32, ptr >> 2, "loading") * 4);
747
+ return HEAPU32[SAFE_HEAP_INDEX(HEAPU32, ptr >> 2, "loading")];
816
748
  default:
817
749
  abort(`invalid type for getValue: ${type}`);
818
750
  }
@@ -839,7 +771,7 @@ var require_web_tree_sitter = __commonJS({
839
771
  newDSO("__main__", 0, wasmImports);
840
772
  }
841
773
  };
842
- var ___heap_base = 82480;
774
+ var ___heap_base = 82464;
843
775
  var alignMemory = /* @__PURE__ */ __name((size, alignment) => {
844
776
  assert(alignment, "alignment argument is required");
845
777
  return Math.ceil(size / alignment) * alignment;
@@ -934,7 +866,7 @@ var require_web_tree_sitter = __commonJS({
934
866
  }, "convertJsFunctionToWasm");
935
867
  var wasmTableMirror = [];
936
868
  var wasmTable = new WebAssembly.Table({
937
- "initial": 58,
869
+ "initial": 59,
938
870
  "element": "anyfunc"
939
871
  });
940
872
  var getWasmTableEntry = /* @__PURE__ */ __name((funcPtr) => {
@@ -1095,10 +1027,10 @@ var require_web_tree_sitter = __commonJS({
1095
1027
  var tableBase = metadata.tableSize ? wasmTable.length : 0;
1096
1028
  if (handle) {
1097
1029
  HEAP8[SAFE_HEAP_INDEX(HEAP8, handle + 8, "storing")] = 1;
1098
- LE_HEAP_STORE_U32(SAFE_HEAP_INDEX(HEAPU32, handle + 12 >> 2, "storing") * 4, memoryBase);
1099
- LE_HEAP_STORE_I32(SAFE_HEAP_INDEX(HEAP32, handle + 16 >> 2, "storing") * 4, metadata.memorySize);
1100
- LE_HEAP_STORE_U32(SAFE_HEAP_INDEX(HEAPU32, handle + 20 >> 2, "storing") * 4, tableBase);
1101
- LE_HEAP_STORE_I32(SAFE_HEAP_INDEX(HEAP32, handle + 24 >> 2, "storing") * 4, metadata.tableSize);
1030
+ HEAPU32[SAFE_HEAP_INDEX(HEAPU32, handle + 12 >> 2, "storing")] = memoryBase;
1031
+ HEAP32[SAFE_HEAP_INDEX(HEAP32, handle + 16 >> 2, "storing")] = metadata.memorySize;
1032
+ HEAPU32[SAFE_HEAP_INDEX(HEAPU32, handle + 20 >> 2, "storing")] = tableBase;
1033
+ HEAP32[SAFE_HEAP_INDEX(HEAP32, handle + 24 >> 2, "storing")] = metadata.tableSize;
1102
1034
  }
1103
1035
  if (metadata.tableSize) {
1104
1036
  assert(wasmTable.length == tableBase, `unexpected table size while loading ${libName}: ${wasmTable.length}`);
@@ -1300,8 +1232,8 @@ var require_web_tree_sitter = __commonJS({
1300
1232
  dso.global = flags2.global;
1301
1233
  function loadLibData() {
1302
1234
  if (handle2) {
1303
- var data = LE_HEAP_LOAD_U32(SAFE_HEAP_INDEX(HEAPU32, handle2 + 28 >> 2, "loading") * 4);
1304
- var dataSize = LE_HEAP_LOAD_U32(SAFE_HEAP_INDEX(HEAPU32, handle2 + 32 >> 2, "loading") * 4);
1235
+ var data = HEAPU32[SAFE_HEAP_INDEX(HEAPU32, handle2 + 28 >> 2, "loading")];
1236
+ var dataSize = HEAPU32[SAFE_HEAP_INDEX(HEAPU32, handle2 + 32 >> 2, "loading")];
1305
1237
  if (data && dataSize) {
1306
1238
  var libData = HEAP8.slice(data, data + dataSize);
1307
1239
  return flags2.loadAsync ? Promise.resolve(libData) : libData;
@@ -1444,22 +1376,22 @@ var require_web_tree_sitter = __commonJS({
1444
1376
  HEAP8[SAFE_HEAP_INDEX(HEAP8, ptr, "storing")] = value;
1445
1377
  break;
1446
1378
  case "i16":
1447
- LE_HEAP_STORE_I16(SAFE_HEAP_INDEX(HEAP16, ptr >> 1, "storing") * 2, value);
1379
+ HEAP16[SAFE_HEAP_INDEX(HEAP16, ptr >> 1, "storing")] = value;
1448
1380
  break;
1449
1381
  case "i32":
1450
- LE_HEAP_STORE_I32(SAFE_HEAP_INDEX(HEAP32, ptr >> 2, "storing") * 4, value);
1382
+ HEAP32[SAFE_HEAP_INDEX(HEAP32, ptr >> 2, "storing")] = value;
1451
1383
  break;
1452
1384
  case "i64":
1453
- LE_HEAP_STORE_I64(SAFE_HEAP_INDEX(HEAP64, ptr >> 3, "storing") * 8, BigInt(value));
1385
+ HEAP64[SAFE_HEAP_INDEX(HEAP64, ptr >> 3, "storing")] = BigInt(value);
1454
1386
  break;
1455
1387
  case "float":
1456
- LE_HEAP_STORE_F32(SAFE_HEAP_INDEX(HEAPF32, ptr >> 2, "storing") * 4, value);
1388
+ HEAPF32[SAFE_HEAP_INDEX(HEAPF32, ptr >> 2, "storing")] = value;
1457
1389
  break;
1458
1390
  case "double":
1459
- LE_HEAP_STORE_F64(SAFE_HEAP_INDEX(HEAPF64, ptr >> 3, "storing") * 8, value);
1391
+ HEAPF64[SAFE_HEAP_INDEX(HEAPF64, ptr >> 3, "storing")] = value;
1460
1392
  break;
1461
1393
  case "*":
1462
- LE_HEAP_STORE_U32(SAFE_HEAP_INDEX(HEAPU32, ptr >> 2, "storing") * 4, value);
1394
+ HEAPU32[SAFE_HEAP_INDEX(HEAPU32, ptr >> 2, "storing")] = value;
1463
1395
  break;
1464
1396
  default:
1465
1397
  abort(`invalid type for setValue: ${type}`);
@@ -1470,18 +1402,16 @@ var require_web_tree_sitter = __commonJS({
1470
1402
  "value": "i32",
1471
1403
  "mutable": false
1472
1404
  }, 1024);
1473
- var ___stack_high = 82480;
1474
- var ___stack_low = 16944;
1405
+ var ___stack_high = 82464;
1406
+ var ___stack_low = 16928;
1475
1407
  var ___stack_pointer = new WebAssembly.Global({
1476
1408
  "value": "i32",
1477
1409
  "mutable": true
1478
- }, 82480);
1410
+ }, 82464);
1479
1411
  var ___table_base = new WebAssembly.Global({
1480
1412
  "value": "i32",
1481
1413
  "mutable": false
1482
1414
  }, 1);
1483
- var __abort_js = /* @__PURE__ */ __name(() => abort("native code called abort()"), "__abort_js");
1484
- __abort_js.sig = "v";
1485
1415
  var __emscripten_throw_longjmp = /* @__PURE__ */ __name(() => {
1486
1416
  throw Infinity;
1487
1417
  }, "__emscripten_throw_longjmp");
@@ -1565,15 +1495,15 @@ var require_web_tree_sitter = __commonJS({
1565
1495
  var _fd_write = /* @__PURE__ */ __name((fd, iov, iovcnt, pnum) => {
1566
1496
  var num = 0;
1567
1497
  for (var i2 = 0; i2 < iovcnt; i2++) {
1568
- var ptr = LE_HEAP_LOAD_U32(SAFE_HEAP_INDEX(HEAPU32, iov >> 2, "loading") * 4);
1569
- var len = LE_HEAP_LOAD_U32(SAFE_HEAP_INDEX(HEAPU32, iov + 4 >> 2, "loading") * 4);
1498
+ var ptr = HEAPU32[SAFE_HEAP_INDEX(HEAPU32, iov >> 2, "loading")];
1499
+ var len = HEAPU32[SAFE_HEAP_INDEX(HEAPU32, iov + 4 >> 2, "loading")];
1570
1500
  iov += 8;
1571
1501
  for (var j = 0; j < len; j++) {
1572
1502
  printChar(fd, HEAPU8[SAFE_HEAP_INDEX(HEAPU8, ptr + j, "loading")]);
1573
1503
  }
1574
1504
  num += len;
1575
1505
  }
1576
- LE_HEAP_STORE_U32(SAFE_HEAP_INDEX(HEAPU32, pnum >> 2, "storing") * 4, num);
1506
+ HEAPU32[SAFE_HEAP_INDEX(HEAPU32, pnum >> 2, "storing")] = num;
1577
1507
  return 0;
1578
1508
  }, "_fd_write");
1579
1509
  _fd_write.sig = "iippp";
@@ -1584,18 +1514,29 @@ var require_web_tree_sitter = __commonJS({
1584
1514
  }
1585
1515
  }
1586
1516
  __name(_tree_sitter_log_callback, "_tree_sitter_log_callback");
1587
- function _tree_sitter_parse_callback(inputBufferAddress, index, row, column, lengthAddress) {
1588
- const INPUT_BUFFER_SIZE = 10 * 1024;
1589
- const string = Module.currentParseCallback(index, {
1517
+ function _tree_sitter_parse_callback(inputBufferAddress, maxCodeUnits, index, row, column, lengthAddress) {
1518
+ const source = Module.currentParseCallback;
1519
+ const isString = typeof source === "string";
1520
+ const chunk = isString ? source : source(index, {
1590
1521
  row,
1591
1522
  column
1592
1523
  });
1593
- if (typeof string === "string") {
1594
- setValue(lengthAddress, string.length, "i32");
1595
- stringToUTF16(string, inputBufferAddress, INPUT_BUFFER_SIZE);
1596
- } else {
1597
- setValue(lengthAddress, 0, "i32");
1524
+ const offset = isString ? index : 0;
1525
+ const remaining = typeof chunk === "string" ? chunk.length - offset : 0;
1526
+ if (remaining <= 0) {
1527
+ HEAP32[SAFE_HEAP_INDEX(HEAP32, lengthAddress >>> 2, "storing")] = 0;
1528
+ return;
1529
+ }
1530
+ let count = remaining < maxCodeUnits ? remaining : maxCodeUnits;
1531
+ if (count < remaining && count > 1) {
1532
+ const last = chunk.charCodeAt(offset + count - 1);
1533
+ if (last >= 55296 && last <= 56319) count--;
1598
1534
  }
1535
+ const base = inputBufferAddress >>> 1;
1536
+ for (let i2 = 0; i2 < count; i2++) {
1537
+ HEAPU16[SAFE_HEAP_INDEX(HEAPU16, base + i2, "storing")] = chunk.charCodeAt(offset + i2);
1538
+ }
1539
+ HEAP32[SAFE_HEAP_INDEX(HEAP32, lengthAddress >>> 2, "storing")] = count;
1599
1540
  }
1600
1541
  __name(_tree_sitter_parse_callback, "_tree_sitter_parse_callback");
1601
1542
  function _tree_sitter_progress_callback(currentOffset, hasError) {
@@ -1709,40 +1650,6 @@ var require_web_tree_sitter = __commonJS({
1709
1650
  str += String.fromCharCode(ch);
1710
1651
  }
1711
1652
  }, "AsciiToString");
1712
- var stringToUTF16 = /* @__PURE__ */ __name((str, outPtr, maxBytesToWrite) => {
1713
- assert(outPtr % 2 == 0, "Pointer passed to stringToUTF16 must be aligned to two bytes!");
1714
- assert(typeof maxBytesToWrite == "number", "stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!");
1715
- maxBytesToWrite ??= 2147483647;
1716
- if (maxBytesToWrite < 2) return 0;
1717
- maxBytesToWrite -= 2;
1718
- var startPtr = outPtr;
1719
- var numCharsToWrite = maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length;
1720
- for (var i2 = 0; i2 < numCharsToWrite; ++i2) {
1721
- var codeUnit = str.charCodeAt(i2);
1722
- LE_HEAP_STORE_I16(SAFE_HEAP_INDEX(HEAP16, outPtr >> 1, "storing") * 2, codeUnit);
1723
- outPtr += 2;
1724
- }
1725
- LE_HEAP_STORE_I16(SAFE_HEAP_INDEX(HEAP16, outPtr >> 1, "storing") * 2, 0);
1726
- return outPtr - startPtr;
1727
- }, "stringToUTF16");
1728
- LE_ATOMICS_NATIVE_BYTE_ORDER = new Int8Array(new Int16Array([1]).buffer)[0] === 1 ? [
1729
- /* little endian */
1730
- ((x) => x),
1731
- ((x) => x),
1732
- void 0,
1733
- ((x) => x)
1734
- ] : [
1735
- /* big endian */
1736
- ((x) => x),
1737
- ((x) => ((x & 65280) << 8 | (x & 255) << 24) >> 16),
1738
- void 0,
1739
- ((x) => x >> 24 & 255 | x >> 8 & 65280 | (x & 65280) << 8 | (x & 255) << 24)
1740
- ];
1741
- function LE_HEAP_UPDATE() {
1742
- HEAPU16.unsigned = ((x) => x & 65535);
1743
- HEAPU32.unsigned = ((x) => x >>> 0);
1744
- }
1745
- __name(LE_HEAP_UPDATE, "LE_HEAP_UPDATE");
1746
1653
  {
1747
1654
  initMemory();
1748
1655
  if (Module["noExitRuntime"]) noExitRuntime = Module["noExitRuntime"];
@@ -1774,18 +1681,14 @@ var require_web_tree_sitter = __commonJS({
1774
1681
  }
1775
1682
  consumedModuleProp("preInit");
1776
1683
  }
1777
- Module["setValue"] = setValue;
1778
- Module["getValue"] = getValue;
1779
1684
  Module["UTF8ToString"] = UTF8ToString;
1780
1685
  Module["stringToUTF8"] = stringToUTF8;
1781
1686
  Module["lengthBytesUTF8"] = lengthBytesUTF8;
1782
1687
  Module["AsciiToString"] = AsciiToString;
1783
- Module["stringToUTF16"] = stringToUTF16;
1784
1688
  Module["loadWebAssemblyModule"] = loadWebAssemblyModule;
1785
- Module["LE_HEAP_STORE_I64"] = LE_HEAP_STORE_I64;
1786
- var missingLibrarySymbols = ["writeI53ToI64", "writeI53ToI64Clamped", "writeI53ToI64Signaling", "writeI53ToU64Clamped", "writeI53ToU64Signaling", "readI53FromI64", "readI53FromU64", "convertI32PairToI53", "convertI32PairToI53Checked", "convertU32PairToI53", "getTempRet0", "setTempRet0", "zeroMemory", "withStackSave", "strError", "inetPton4", "inetNtop4", "inetPton6", "inetNtop6", "readSockaddr", "writeSockaddr", "readEmAsmArgs", "runEmAsmFunction", "runMainThreadEmAsm", "jstoi_q", "getExecutableName", "autoResumeAudioContext", "getDynCaller", "runtimeKeepalivePush", "runtimeKeepalivePop", "callUserCallback", "maybeExit", "asmjsMangle", "mmapAlloc", "HandleAllocator", "getNativeTypeSize", "getUniqueRunDependency", "addOnInit", "addOnPreMain", "addOnExit", "STACK_SIZE", "STACK_ALIGN", "POINTER_SIZE", "ASSERTIONS", "ccall", "cwrap", "removeFunction", "intArrayFromString", "intArrayToString", "stringToAscii", "UTF16ToString", "lengthBytesUTF16", "UTF32ToString", "stringToUTF32", "lengthBytesUTF32", "stringToNewUTF8", "writeArrayToMemory", "registerKeyEventCallback", "maybeCStringToJsString", "findEventTarget", "getBoundingClientRect", "fillMouseEventData", "registerMouseEventCallback", "registerWheelEventCallback", "registerUiEventCallback", "registerFocusEventCallback", "fillDeviceOrientationEventData", "registerDeviceOrientationEventCallback", "fillDeviceMotionEventData", "registerDeviceMotionEventCallback", "screenOrientation", "fillOrientationChangeEventData", "registerOrientationChangeEventCallback", "fillFullscreenChangeEventData", "registerFullscreenChangeEventCallback", "JSEvents_requestFullscreen", "JSEvents_resizeCanvasForFullscreen", "registerRestoreOldStyle", "hideEverythingExceptGivenElement", "restoreHiddenElements", "setLetterbox", "softFullscreenResizeWebGLRenderTarget", "doRequestFullscreen", "fillPointerlockChangeEventData", "registerPointerlockChangeEventCallback", "registerPointerlockErrorEventCallback", "requestPointerLock", "fillVisibilityChangeEventData", "registerVisibilityChangeEventCallback", "registerTouchEventCallback", "fillGamepadEventData", "registerGamepadEventCallback", "registerBeforeUnloadEventCallback", "fillBatteryEventData", "registerBatteryEventCallback", "setCanvasElementSize", "getCanvasElementSize", "jsStackTrace", "getCallstack", "convertPCtoSourceLocation", "getEnvStrings", "checkWasiClock", "wasiRightsToMuslOFlags", "wasiOFlagsToMuslOFlags", "initRandomFill", "randomFill", "safeSetTimeout", "setImmediateWrapped", "safeRequestAnimationFrame", "clearImmediateWrapped", "registerPostMainLoop", "registerPreMainLoop", "getPromise", "makePromise", "idsToPromises", "makePromiseCallback", "Browser_asyncPrepareDataCounter", "isLeapYear", "ydayFromDate", "arraySum", "addDays", "getSocketFromFD", "getSocketAddress", "dlopenInternal", "heapObjectForWebGLType", "toTypedArrayIndex", "webgl_enable_ANGLE_instanced_arrays", "webgl_enable_OES_vertex_array_object", "webgl_enable_WEBGL_draw_buffers", "webgl_enable_WEBGL_multi_draw", "webgl_enable_EXT_polygon_offset_clamp", "webgl_enable_EXT_clip_control", "webgl_enable_WEBGL_polygon_mode", "emscriptenWebGLGet", "computeUnpackAlignedImageSize", "colorChannelsInGlTextureFormat", "emscriptenWebGLGetTexPixelData", "emscriptenWebGLGetUniform", "webglGetUniformLocation", "webglPrepareUniformLocationsBeforeFirstUse", "webglGetLeftBracePos", "emscriptenWebGLGetVertexAttrib", "__glGetActiveAttribOrUniform", "writeGLArray", "registerWebGlEventCallback", "runAndAbortIfError", "ALLOC_NORMAL", "ALLOC_STACK", "allocate", "writeStringToMemory", "writeAsciiToMemory", "demangle", "stackTrace"];
1689
+ var missingLibrarySymbols = ["writeI53ToI64", "writeI53ToI64Clamped", "writeI53ToI64Signaling", "writeI53ToU64Clamped", "writeI53ToU64Signaling", "readI53FromI64", "readI53FromU64", "convertI32PairToI53", "convertI32PairToI53Checked", "convertU32PairToI53", "getTempRet0", "setTempRet0", "zeroMemory", "withStackSave", "strError", "inetPton4", "inetNtop4", "inetPton6", "inetNtop6", "readSockaddr", "writeSockaddr", "readEmAsmArgs", "runEmAsmFunction", "runMainThreadEmAsm", "jstoi_q", "getExecutableName", "autoResumeAudioContext", "getDynCaller", "runtimeKeepalivePush", "runtimeKeepalivePop", "callUserCallback", "maybeExit", "asmjsMangle", "mmapAlloc", "HandleAllocator", "getNativeTypeSize", "getUniqueRunDependency", "addOnInit", "addOnPreMain", "addOnExit", "STACK_SIZE", "STACK_ALIGN", "POINTER_SIZE", "ASSERTIONS", "ccall", "cwrap", "removeFunction", "intArrayFromString", "intArrayToString", "stringToAscii", "UTF16ToString", "stringToUTF16", "lengthBytesUTF16", "UTF32ToString", "stringToUTF32", "lengthBytesUTF32", "stringToNewUTF8", "writeArrayToMemory", "registerKeyEventCallback", "maybeCStringToJsString", "findEventTarget", "getBoundingClientRect", "fillMouseEventData", "registerMouseEventCallback", "registerWheelEventCallback", "registerUiEventCallback", "registerFocusEventCallback", "fillDeviceOrientationEventData", "registerDeviceOrientationEventCallback", "fillDeviceMotionEventData", "registerDeviceMotionEventCallback", "screenOrientation", "fillOrientationChangeEventData", "registerOrientationChangeEventCallback", "fillFullscreenChangeEventData", "registerFullscreenChangeEventCallback", "JSEvents_requestFullscreen", "JSEvents_resizeCanvasForFullscreen", "registerRestoreOldStyle", "hideEverythingExceptGivenElement", "restoreHiddenElements", "setLetterbox", "softFullscreenResizeWebGLRenderTarget", "doRequestFullscreen", "fillPointerlockChangeEventData", "registerPointerlockChangeEventCallback", "registerPointerlockErrorEventCallback", "requestPointerLock", "fillVisibilityChangeEventData", "registerVisibilityChangeEventCallback", "registerTouchEventCallback", "fillGamepadEventData", "registerGamepadEventCallback", "registerBeforeUnloadEventCallback", "fillBatteryEventData", "registerBatteryEventCallback", "setCanvasElementSize", "getCanvasElementSize", "jsStackTrace", "getCallstack", "convertPCtoSourceLocation", "getEnvStrings", "checkWasiClock", "wasiRightsToMuslOFlags", "wasiOFlagsToMuslOFlags", "initRandomFill", "randomFill", "safeSetTimeout", "setImmediateWrapped", "safeRequestAnimationFrame", "clearImmediateWrapped", "registerPostMainLoop", "registerPreMainLoop", "getPromise", "makePromise", "idsToPromises", "makePromiseCallback", "Browser_asyncPrepareDataCounter", "isLeapYear", "ydayFromDate", "arraySum", "addDays", "getSocketFromFD", "getSocketAddress", "dlopenInternal", "heapObjectForWebGLType", "toTypedArrayIndex", "webgl_enable_ANGLE_instanced_arrays", "webgl_enable_OES_vertex_array_object", "webgl_enable_WEBGL_draw_buffers", "webgl_enable_WEBGL_multi_draw", "webgl_enable_EXT_polygon_offset_clamp", "webgl_enable_EXT_clip_control", "webgl_enable_WEBGL_polygon_mode", "emscriptenWebGLGet", "computeUnpackAlignedImageSize", "colorChannelsInGlTextureFormat", "emscriptenWebGLGetTexPixelData", "emscriptenWebGLGetUniform", "webglGetUniformLocation", "webglPrepareUniformLocationsBeforeFirstUse", "webglGetLeftBracePos", "emscriptenWebGLGetVertexAttrib", "__glGetActiveAttribOrUniform", "writeGLArray", "registerWebGlEventCallback", "runAndAbortIfError", "ALLOC_NORMAL", "ALLOC_STACK", "allocate", "writeStringToMemory", "writeAsciiToMemory", "demangle", "stackTrace"];
1787
1690
  missingLibrarySymbols.forEach(missingLibrarySymbol);
1788
- var unexportedSymbols = ["run", "out", "err", "callMain", "abort", "wasmMemory", "wasmExports", "writeStackCookie", "checkStackCookie", "INT53_MAX", "INT53_MIN", "bigintToI53Checked", "stackSave", "stackRestore", "stackAlloc", "ptrToString", "exitJS", "getHeapMax", "growMemory", "ENV", "ERRNO_CODES", "DNS", "Protocols", "Sockets", "timers", "warnOnce", "readEmAsmArgsArray", "dynCall", "handleException", "keepRuntimeAlive", "asyncLoad", "alignMemory", "wasmTable", "noExitRuntime", "addRunDependency", "removeRunDependency", "addOnPreRun", "addOnPostCtor", "addOnPostRun", "convertJsFunctionToWasm", "freeTableIndexes", "functionsInTableMap", "getEmptyTableSlot", "updateTableMap", "getFunctionAddress", "addFunction", "PATH", "PATH_FS", "UTF8Decoder", "UTF8ArrayToString", "stringToUTF8Array", "UTF16Decoder", "stringToUTF8OnStack", "JSEvents", "specialHTMLTargets", "findCanvasEventTarget", "currentFullscreenStrategy", "restoreOldWindowedStyle", "UNWIND_CACHE", "ExitStatus", "flush_NO_FILESYSTEM", "emSetImmediate", "emClearImmediate_deps", "emClearImmediate", "promiseMap", "Browser", "requestFullscreen", "requestFullScreen", "setCanvasSize", "getUserMedia", "createContext", "getPreloadedImageData__data", "wget", "MONTH_DAYS_REGULAR", "MONTH_DAYS_LEAP", "MONTH_DAYS_REGULAR_CUMULATIVE", "MONTH_DAYS_LEAP_CUMULATIVE", "SYSCALLS", "isSymbolDefined", "GOT", "currentModuleWeakSymbols", "LDSO", "getMemory", "mergeLibSymbols", "newDSO", "loadDynamicLibrary", "tempFixedLengthArray", "miniTempWebGLFloatBuffers", "miniTempWebGLIntBuffers", "GL", "AL", "GLUT", "EGL", "GLEW", "IDBStore", "SDL", "SDL_gfx", "allocateUTF8", "allocateUTF8OnStack", "print", "printErr", "jstoi_s", "LE_HEAP_STORE_U16", "LE_HEAP_STORE_I16", "LE_HEAP_STORE_U32", "LE_HEAP_STORE_I32", "LE_HEAP_STORE_U64", "LE_HEAP_STORE_F32", "LE_HEAP_STORE_F64", "LE_HEAP_LOAD_U16", "LE_HEAP_LOAD_I16", "LE_HEAP_LOAD_U32", "LE_HEAP_LOAD_I32", "LE_HEAP_LOAD_U64", "LE_HEAP_LOAD_I64", "LE_HEAP_LOAD_F32", "LE_HEAP_LOAD_F64", "LE_ATOMICS_NATIVE_BYTE_ORDER", "LE_ATOMICS_ADD", "LE_ATOMICS_AND", "LE_ATOMICS_COMPAREEXCHANGE", "LE_ATOMICS_EXCHANGE", "LE_ATOMICS_ISLOCKFREE", "LE_ATOMICS_LOAD", "LE_ATOMICS_NOTIFY", "LE_ATOMICS_OR", "LE_ATOMICS_STORE", "LE_ATOMICS_SUB", "LE_ATOMICS_WAIT", "LE_ATOMICS_WAITASYNC", "LE_ATOMICS_XOR"];
1691
+ var unexportedSymbols = ["run", "out", "err", "callMain", "abort", "wasmMemory", "wasmExports", "HEAPF32", "HEAPF64", "HEAP8", "HEAPU8", "HEAP16", "HEAP64", "HEAPU64", "writeStackCookie", "checkStackCookie", "INT53_MAX", "INT53_MIN", "bigintToI53Checked", "stackSave", "stackRestore", "stackAlloc", "ptrToString", "exitJS", "getHeapMax", "growMemory", "ENV", "ERRNO_CODES", "DNS", "Protocols", "Sockets", "timers", "warnOnce", "readEmAsmArgsArray", "dynCall", "handleException", "keepRuntimeAlive", "asyncLoad", "alignMemory", "wasmTable", "noExitRuntime", "addRunDependency", "removeRunDependency", "addOnPreRun", "addOnPostCtor", "addOnPostRun", "convertJsFunctionToWasm", "freeTableIndexes", "functionsInTableMap", "getEmptyTableSlot", "updateTableMap", "getFunctionAddress", "addFunction", "setValue", "getValue", "PATH", "PATH_FS", "UTF8Decoder", "UTF8ArrayToString", "stringToUTF8Array", "UTF16Decoder", "stringToUTF8OnStack", "JSEvents", "specialHTMLTargets", "findCanvasEventTarget", "currentFullscreenStrategy", "restoreOldWindowedStyle", "UNWIND_CACHE", "ExitStatus", "flush_NO_FILESYSTEM", "emSetImmediate", "emClearImmediate_deps", "emClearImmediate", "promiseMap", "Browser", "requestFullscreen", "requestFullScreen", "setCanvasSize", "getUserMedia", "createContext", "getPreloadedImageData__data", "wget", "MONTH_DAYS_REGULAR", "MONTH_DAYS_LEAP", "MONTH_DAYS_REGULAR_CUMULATIVE", "MONTH_DAYS_LEAP_CUMULATIVE", "SYSCALLS", "isSymbolDefined", "GOT", "currentModuleWeakSymbols", "LDSO", "getMemory", "mergeLibSymbols", "newDSO", "loadDynamicLibrary", "tempFixedLengthArray", "miniTempWebGLFloatBuffers", "miniTempWebGLIntBuffers", "GL", "AL", "GLUT", "EGL", "GLEW", "IDBStore", "SDL", "SDL_gfx", "allocateUTF8", "allocateUTF8OnStack", "print", "printErr", "jstoi_s"];
1789
1692
  unexportedSymbols.forEach(unexportedRuntimeSymbol);
1790
1693
  function checkIncomingModuleAPI() {
1791
1694
  ignoredModuleProp("fetchSettings");
@@ -1796,7 +1699,6 @@ var require_web_tree_sitter = __commonJS({
1796
1699
  var _calloc = Module["_calloc"] = makeInvalidEarlyAccess("_calloc");
1797
1700
  var _realloc = Module["_realloc"] = makeInvalidEarlyAccess("_realloc");
1798
1701
  var _free = Module["_free"] = makeInvalidEarlyAccess("_free");
1799
- var _ts_range_edit = Module["_ts_range_edit"] = makeInvalidEarlyAccess("_ts_range_edit");
1800
1702
  var _ts_language_symbol_count = Module["_ts_language_symbol_count"] = makeInvalidEarlyAccess("_ts_language_symbol_count");
1801
1703
  var _ts_language_state_count = Module["_ts_language_state_count"] = makeInvalidEarlyAccess("_ts_language_state_count");
1802
1704
  var _ts_language_abi_version = Module["_ts_language_abi_version"] = makeInvalidEarlyAccess("_ts_language_abi_version");
@@ -1814,12 +1716,12 @@ var require_web_tree_sitter = __commonJS({
1814
1716
  var _ts_lookahead_iterator_reset = Module["_ts_lookahead_iterator_reset"] = makeInvalidEarlyAccess("_ts_lookahead_iterator_reset");
1815
1717
  var _ts_lookahead_iterator_next = Module["_ts_lookahead_iterator_next"] = makeInvalidEarlyAccess("_ts_lookahead_iterator_next");
1816
1718
  var _ts_lookahead_iterator_current_symbol = Module["_ts_lookahead_iterator_current_symbol"] = makeInvalidEarlyAccess("_ts_lookahead_iterator_current_symbol");
1817
- var _ts_point_edit = Module["_ts_point_edit"] = makeInvalidEarlyAccess("_ts_point_edit");
1818
1719
  var _ts_parser_delete = Module["_ts_parser_delete"] = makeInvalidEarlyAccess("_ts_parser_delete");
1819
1720
  var _ts_parser_set_language = Module["_ts_parser_set_language"] = makeInvalidEarlyAccess("_ts_parser_set_language");
1820
1721
  var _ts_parser_reset = Module["_ts_parser_reset"] = makeInvalidEarlyAccess("_ts_parser_reset");
1821
- var _ts_parser_set_included_ranges = Module["_ts_parser_set_included_ranges"] = makeInvalidEarlyAccess("_ts_parser_set_included_ranges");
1822
1722
  var _memcmp = Module["_memcmp"] = makeInvalidEarlyAccess("_memcmp");
1723
+ var _ts_tree_cursor_current_descendant_index = Module["_ts_tree_cursor_current_descendant_index"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_descendant_index");
1724
+ var _ts_tree_cursor_current_depth = Module["_ts_tree_cursor_current_depth"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_depth");
1823
1725
  var _ts_tree_copy = Module["_ts_tree_copy"] = makeInvalidEarlyAccess("_ts_tree_copy");
1824
1726
  var _ts_tree_delete = Module["_ts_tree_delete"] = makeInvalidEarlyAccess("_ts_tree_delete");
1825
1727
  var _ts_init = Module["_ts_init"] = makeInvalidEarlyAccess("_ts_init");
@@ -1831,6 +1733,7 @@ var require_web_tree_sitter = __commonJS({
1831
1733
  var _ts_parser_enable_logger_wasm = Module["_ts_parser_enable_logger_wasm"] = makeInvalidEarlyAccess("_ts_parser_enable_logger_wasm");
1832
1734
  var _ts_parser_parse_wasm = Module["_ts_parser_parse_wasm"] = makeInvalidEarlyAccess("_ts_parser_parse_wasm");
1833
1735
  var _ts_parser_parse_limited_wasm = Module["_ts_parser_parse_limited_wasm"] = makeInvalidEarlyAccess("_ts_parser_parse_limited_wasm");
1736
+ var _ts_parser_last_parse_operations_wasm = Module["_ts_parser_last_parse_operations_wasm"] = makeInvalidEarlyAccess("_ts_parser_last_parse_operations_wasm");
1834
1737
  var _ts_parser_abort_limited_wasm = Module["_ts_parser_abort_limited_wasm"] = makeInvalidEarlyAccess("_ts_parser_abort_limited_wasm");
1835
1738
  var _ts_parser_included_ranges_wasm = Module["_ts_parser_included_ranges_wasm"] = makeInvalidEarlyAccess("_ts_parser_included_ranges_wasm");
1836
1739
  var _ts_language_type_is_named_wasm = Module["_ts_language_type_is_named_wasm"] = makeInvalidEarlyAccess("_ts_language_type_is_named_wasm");
@@ -1856,18 +1759,12 @@ var require_web_tree_sitter = __commonJS({
1856
1759
  var _ts_tree_cursor_goto_previous_sibling_wasm = Module["_ts_tree_cursor_goto_previous_sibling_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_previous_sibling_wasm");
1857
1760
  var _ts_tree_cursor_goto_descendant_wasm = Module["_ts_tree_cursor_goto_descendant_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_descendant_wasm");
1858
1761
  var _ts_tree_cursor_goto_parent_wasm = Module["_ts_tree_cursor_goto_parent_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_parent_wasm");
1859
- var _ts_tree_cursor_current_node_type_id_wasm = Module["_ts_tree_cursor_current_node_type_id_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_node_type_id_wasm");
1860
1762
  var _ts_tree_cursor_current_node_state_id_wasm = Module["_ts_tree_cursor_current_node_state_id_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_node_state_id_wasm");
1861
- var _ts_tree_cursor_current_node_is_named_wasm = Module["_ts_tree_cursor_current_node_is_named_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_node_is_named_wasm");
1862
- var _ts_tree_cursor_current_node_is_missing_wasm = Module["_ts_tree_cursor_current_node_is_missing_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_node_is_missing_wasm");
1863
1763
  var _ts_tree_cursor_current_node_id_wasm = Module["_ts_tree_cursor_current_node_id_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_node_id_wasm");
1864
1764
  var _ts_tree_cursor_start_position_wasm = Module["_ts_tree_cursor_start_position_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_start_position_wasm");
1865
1765
  var _ts_tree_cursor_end_position_wasm = Module["_ts_tree_cursor_end_position_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_end_position_wasm");
1866
1766
  var _ts_tree_cursor_start_index_wasm = Module["_ts_tree_cursor_start_index_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_start_index_wasm");
1867
1767
  var _ts_tree_cursor_end_index_wasm = Module["_ts_tree_cursor_end_index_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_end_index_wasm");
1868
- var _ts_tree_cursor_current_field_id_wasm = Module["_ts_tree_cursor_current_field_id_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_field_id_wasm");
1869
- var _ts_tree_cursor_current_depth_wasm = Module["_ts_tree_cursor_current_depth_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_depth_wasm");
1870
- var _ts_tree_cursor_current_descendant_index_wasm = Module["_ts_tree_cursor_current_descendant_index_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_descendant_index_wasm");
1871
1768
  var _ts_tree_cursor_current_node_wasm = Module["_ts_tree_cursor_current_node_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_node_wasm");
1872
1769
  var _ts_node_symbol_wasm = Module["_ts_node_symbol_wasm"] = makeInvalidEarlyAccess("_ts_node_symbol_wasm");
1873
1770
  var _ts_node_field_name_for_child_wasm = Module["_ts_node_field_name_for_child_wasm"] = makeInvalidEarlyAccess("_ts_node_field_name_for_child_wasm");
@@ -1892,9 +1789,7 @@ var require_web_tree_sitter = __commonJS({
1892
1789
  var _ts_node_named_descendant_for_index_wasm = Module["_ts_node_named_descendant_for_index_wasm"] = makeInvalidEarlyAccess("_ts_node_named_descendant_for_index_wasm");
1893
1790
  var _ts_node_descendant_for_position_wasm = Module["_ts_node_descendant_for_position_wasm"] = makeInvalidEarlyAccess("_ts_node_descendant_for_position_wasm");
1894
1791
  var _ts_node_named_descendant_for_position_wasm = Module["_ts_node_named_descendant_for_position_wasm"] = makeInvalidEarlyAccess("_ts_node_named_descendant_for_position_wasm");
1895
- var _ts_node_start_point_wasm = Module["_ts_node_start_point_wasm"] = makeInvalidEarlyAccess("_ts_node_start_point_wasm");
1896
1792
  var _ts_node_end_point_wasm = Module["_ts_node_end_point_wasm"] = makeInvalidEarlyAccess("_ts_node_end_point_wasm");
1897
- var _ts_node_start_index_wasm = Module["_ts_node_start_index_wasm"] = makeInvalidEarlyAccess("_ts_node_start_index_wasm");
1898
1793
  var _ts_node_end_index_wasm = Module["_ts_node_end_index_wasm"] = makeInvalidEarlyAccess("_ts_node_end_index_wasm");
1899
1794
  var _ts_node_to_string_wasm = Module["_ts_node_to_string_wasm"] = makeInvalidEarlyAccess("_ts_node_to_string_wasm");
1900
1795
  var _ts_node_children_wasm = Module["_ts_node_children_wasm"] = makeInvalidEarlyAccess("_ts_node_children_wasm");
@@ -1908,9 +1803,9 @@ var require_web_tree_sitter = __commonJS({
1908
1803
  var _ts_node_is_extra_wasm = Module["_ts_node_is_extra_wasm"] = makeInvalidEarlyAccess("_ts_node_is_extra_wasm");
1909
1804
  var _ts_node_parse_state_wasm = Module["_ts_node_parse_state_wasm"] = makeInvalidEarlyAccess("_ts_node_parse_state_wasm");
1910
1805
  var _ts_node_next_parse_state_wasm = Module["_ts_node_next_parse_state_wasm"] = makeInvalidEarlyAccess("_ts_node_next_parse_state_wasm");
1911
- var _memset = Module["_memset"] = makeInvalidEarlyAccess("_memset");
1912
1806
  var _memcpy = Module["_memcpy"] = makeInvalidEarlyAccess("_memcpy");
1913
1807
  var _memmove = Module["_memmove"] = makeInvalidEarlyAccess("_memmove");
1808
+ var _memset = Module["_memset"] = makeInvalidEarlyAccess("_memset");
1914
1809
  var _fflush = makeInvalidEarlyAccess("_fflush");
1915
1810
  var _strlen = Module["_strlen"] = makeInvalidEarlyAccess("_strlen");
1916
1811
  var _iswalnum = Module["_iswalnum"] = makeInvalidEarlyAccess("_iswalnum");
@@ -1944,7 +1839,6 @@ var require_web_tree_sitter = __commonJS({
1944
1839
  Module["_calloc"] = _calloc = createExportWrapper("calloc", 2);
1945
1840
  Module["_realloc"] = _realloc = createExportWrapper("realloc", 2);
1946
1841
  Module["_free"] = _free = createExportWrapper("free", 1);
1947
- Module["_ts_range_edit"] = _ts_range_edit = createExportWrapper("ts_range_edit", 2);
1948
1842
  Module["_ts_language_symbol_count"] = _ts_language_symbol_count = createExportWrapper("ts_language_symbol_count", 1);
1949
1843
  Module["_ts_language_state_count"] = _ts_language_state_count = createExportWrapper("ts_language_state_count", 1);
1950
1844
  Module["_ts_language_abi_version"] = _ts_language_abi_version = createExportWrapper("ts_language_abi_version", 1);
@@ -1962,12 +1856,12 @@ var require_web_tree_sitter = __commonJS({
1962
1856
  Module["_ts_lookahead_iterator_reset"] = _ts_lookahead_iterator_reset = createExportWrapper("ts_lookahead_iterator_reset", 3);
1963
1857
  Module["_ts_lookahead_iterator_next"] = _ts_lookahead_iterator_next = createExportWrapper("ts_lookahead_iterator_next", 1);
1964
1858
  Module["_ts_lookahead_iterator_current_symbol"] = _ts_lookahead_iterator_current_symbol = createExportWrapper("ts_lookahead_iterator_current_symbol", 1);
1965
- Module["_ts_point_edit"] = _ts_point_edit = createExportWrapper("ts_point_edit", 3);
1966
1859
  Module["_ts_parser_delete"] = _ts_parser_delete = createExportWrapper("ts_parser_delete", 1);
1967
1860
  Module["_ts_parser_set_language"] = _ts_parser_set_language = createExportWrapper("ts_parser_set_language", 2);
1968
1861
  Module["_ts_parser_reset"] = _ts_parser_reset = createExportWrapper("ts_parser_reset", 1);
1969
- Module["_ts_parser_set_included_ranges"] = _ts_parser_set_included_ranges = createExportWrapper("ts_parser_set_included_ranges", 3);
1970
1862
  Module["_memcmp"] = _memcmp = createExportWrapper("memcmp", 3);
1863
+ Module["_ts_tree_cursor_current_descendant_index"] = _ts_tree_cursor_current_descendant_index = createExportWrapper("ts_tree_cursor_current_descendant_index", 1);
1864
+ Module["_ts_tree_cursor_current_depth"] = _ts_tree_cursor_current_depth = createExportWrapper("ts_tree_cursor_current_depth", 1);
1971
1865
  Module["_ts_tree_copy"] = _ts_tree_copy = createExportWrapper("ts_tree_copy", 1);
1972
1866
  Module["_ts_tree_delete"] = _ts_tree_delete = createExportWrapper("ts_tree_delete", 1);
1973
1867
  Module["_ts_init"] = _ts_init = createExportWrapper("ts_init", 0);
@@ -1977,8 +1871,9 @@ var require_web_tree_sitter = __commonJS({
1977
1871
  Module["_ts_scanner_realloc_wasm"] = _ts_scanner_realloc_wasm = createExportWrapper("ts_scanner_realloc_wasm", 2);
1978
1872
  Module["_ts_parser_new_wasm"] = _ts_parser_new_wasm = createExportWrapper("ts_parser_new_wasm", 0);
1979
1873
  Module["_ts_parser_enable_logger_wasm"] = _ts_parser_enable_logger_wasm = createExportWrapper("ts_parser_enable_logger_wasm", 2);
1980
- Module["_ts_parser_parse_wasm"] = _ts_parser_parse_wasm = createExportWrapper("ts_parser_parse_wasm", 5);
1981
- Module["_ts_parser_parse_limited_wasm"] = _ts_parser_parse_limited_wasm = createExportWrapper("ts_parser_parse_limited_wasm", 4);
1874
+ Module["_ts_parser_parse_wasm"] = _ts_parser_parse_wasm = createExportWrapper("ts_parser_parse_wasm", 3);
1875
+ Module["_ts_parser_parse_limited_wasm"] = _ts_parser_parse_limited_wasm = createExportWrapper("ts_parser_parse_limited_wasm", 2);
1876
+ Module["_ts_parser_last_parse_operations_wasm"] = _ts_parser_last_parse_operations_wasm = createExportWrapper("ts_parser_last_parse_operations_wasm", 1);
1982
1877
  Module["_ts_parser_abort_limited_wasm"] = _ts_parser_abort_limited_wasm = createExportWrapper("ts_parser_abort_limited_wasm", 0);
1983
1878
  Module["_ts_parser_included_ranges_wasm"] = _ts_parser_included_ranges_wasm = createExportWrapper("ts_parser_included_ranges_wasm", 1);
1984
1879
  Module["_ts_language_type_is_named_wasm"] = _ts_language_type_is_named_wasm = createExportWrapper("ts_language_type_is_named_wasm", 2);
@@ -1994,28 +1889,22 @@ var require_web_tree_sitter = __commonJS({
1994
1889
  Module["_ts_tree_cursor_new_wasm"] = _ts_tree_cursor_new_wasm = createExportWrapper("ts_tree_cursor_new_wasm", 1);
1995
1890
  Module["_ts_tree_cursor_copy_wasm"] = _ts_tree_cursor_copy_wasm = createExportWrapper("ts_tree_cursor_copy_wasm", 1);
1996
1891
  Module["_ts_tree_cursor_delete_wasm"] = _ts_tree_cursor_delete_wasm = createExportWrapper("ts_tree_cursor_delete_wasm", 1);
1997
- Module["_ts_tree_cursor_reset_wasm"] = _ts_tree_cursor_reset_wasm = createExportWrapper("ts_tree_cursor_reset_wasm", 1);
1892
+ Module["_ts_tree_cursor_reset_wasm"] = _ts_tree_cursor_reset_wasm = createExportWrapper("ts_tree_cursor_reset_wasm", 2);
1998
1893
  Module["_ts_tree_cursor_reset_to_wasm"] = _ts_tree_cursor_reset_to_wasm = createExportWrapper("ts_tree_cursor_reset_to_wasm", 2);
1999
1894
  Module["_ts_tree_cursor_goto_first_child_wasm"] = _ts_tree_cursor_goto_first_child_wasm = createExportWrapper("ts_tree_cursor_goto_first_child_wasm", 1);
2000
1895
  Module["_ts_tree_cursor_goto_last_child_wasm"] = _ts_tree_cursor_goto_last_child_wasm = createExportWrapper("ts_tree_cursor_goto_last_child_wasm", 1);
2001
- Module["_ts_tree_cursor_goto_first_child_for_index_wasm"] = _ts_tree_cursor_goto_first_child_for_index_wasm = createExportWrapper("ts_tree_cursor_goto_first_child_for_index_wasm", 1);
2002
- Module["_ts_tree_cursor_goto_first_child_for_position_wasm"] = _ts_tree_cursor_goto_first_child_for_position_wasm = createExportWrapper("ts_tree_cursor_goto_first_child_for_position_wasm", 1);
1896
+ Module["_ts_tree_cursor_goto_first_child_for_index_wasm"] = _ts_tree_cursor_goto_first_child_for_index_wasm = createExportWrapper("ts_tree_cursor_goto_first_child_for_index_wasm", 2);
1897
+ Module["_ts_tree_cursor_goto_first_child_for_position_wasm"] = _ts_tree_cursor_goto_first_child_for_position_wasm = createExportWrapper("ts_tree_cursor_goto_first_child_for_position_wasm", 3);
2003
1898
  Module["_ts_tree_cursor_goto_next_sibling_wasm"] = _ts_tree_cursor_goto_next_sibling_wasm = createExportWrapper("ts_tree_cursor_goto_next_sibling_wasm", 1);
2004
1899
  Module["_ts_tree_cursor_goto_previous_sibling_wasm"] = _ts_tree_cursor_goto_previous_sibling_wasm = createExportWrapper("ts_tree_cursor_goto_previous_sibling_wasm", 1);
2005
1900
  Module["_ts_tree_cursor_goto_descendant_wasm"] = _ts_tree_cursor_goto_descendant_wasm = createExportWrapper("ts_tree_cursor_goto_descendant_wasm", 2);
2006
1901
  Module["_ts_tree_cursor_goto_parent_wasm"] = _ts_tree_cursor_goto_parent_wasm = createExportWrapper("ts_tree_cursor_goto_parent_wasm", 1);
2007
- Module["_ts_tree_cursor_current_node_type_id_wasm"] = _ts_tree_cursor_current_node_type_id_wasm = createExportWrapper("ts_tree_cursor_current_node_type_id_wasm", 1);
2008
1902
  Module["_ts_tree_cursor_current_node_state_id_wasm"] = _ts_tree_cursor_current_node_state_id_wasm = createExportWrapper("ts_tree_cursor_current_node_state_id_wasm", 1);
2009
- Module["_ts_tree_cursor_current_node_is_named_wasm"] = _ts_tree_cursor_current_node_is_named_wasm = createExportWrapper("ts_tree_cursor_current_node_is_named_wasm", 1);
2010
- Module["_ts_tree_cursor_current_node_is_missing_wasm"] = _ts_tree_cursor_current_node_is_missing_wasm = createExportWrapper("ts_tree_cursor_current_node_is_missing_wasm", 1);
2011
1903
  Module["_ts_tree_cursor_current_node_id_wasm"] = _ts_tree_cursor_current_node_id_wasm = createExportWrapper("ts_tree_cursor_current_node_id_wasm", 1);
2012
1904
  Module["_ts_tree_cursor_start_position_wasm"] = _ts_tree_cursor_start_position_wasm = createExportWrapper("ts_tree_cursor_start_position_wasm", 1);
2013
1905
  Module["_ts_tree_cursor_end_position_wasm"] = _ts_tree_cursor_end_position_wasm = createExportWrapper("ts_tree_cursor_end_position_wasm", 1);
2014
1906
  Module["_ts_tree_cursor_start_index_wasm"] = _ts_tree_cursor_start_index_wasm = createExportWrapper("ts_tree_cursor_start_index_wasm", 1);
2015
1907
  Module["_ts_tree_cursor_end_index_wasm"] = _ts_tree_cursor_end_index_wasm = createExportWrapper("ts_tree_cursor_end_index_wasm", 1);
2016
- Module["_ts_tree_cursor_current_field_id_wasm"] = _ts_tree_cursor_current_field_id_wasm = createExportWrapper("ts_tree_cursor_current_field_id_wasm", 1);
2017
- Module["_ts_tree_cursor_current_depth_wasm"] = _ts_tree_cursor_current_depth_wasm = createExportWrapper("ts_tree_cursor_current_depth_wasm", 1);
2018
- Module["_ts_tree_cursor_current_descendant_index_wasm"] = _ts_tree_cursor_current_descendant_index_wasm = createExportWrapper("ts_tree_cursor_current_descendant_index_wasm", 1);
2019
1908
  Module["_ts_tree_cursor_current_node_wasm"] = _ts_tree_cursor_current_node_wasm = createExportWrapper("ts_tree_cursor_current_node_wasm", 1);
2020
1909
  Module["_ts_node_symbol_wasm"] = _ts_node_symbol_wasm = createExportWrapper("ts_node_symbol_wasm", 1);
2021
1910
  Module["_ts_node_field_name_for_child_wasm"] = _ts_node_field_name_for_child_wasm = createExportWrapper("ts_node_field_name_for_child_wasm", 2);
@@ -2040,14 +1929,12 @@ var require_web_tree_sitter = __commonJS({
2040
1929
  Module["_ts_node_named_descendant_for_index_wasm"] = _ts_node_named_descendant_for_index_wasm = createExportWrapper("ts_node_named_descendant_for_index_wasm", 1);
2041
1930
  Module["_ts_node_descendant_for_position_wasm"] = _ts_node_descendant_for_position_wasm = createExportWrapper("ts_node_descendant_for_position_wasm", 1);
2042
1931
  Module["_ts_node_named_descendant_for_position_wasm"] = _ts_node_named_descendant_for_position_wasm = createExportWrapper("ts_node_named_descendant_for_position_wasm", 1);
2043
- Module["_ts_node_start_point_wasm"] = _ts_node_start_point_wasm = createExportWrapper("ts_node_start_point_wasm", 1);
2044
1932
  Module["_ts_node_end_point_wasm"] = _ts_node_end_point_wasm = createExportWrapper("ts_node_end_point_wasm", 1);
2045
- Module["_ts_node_start_index_wasm"] = _ts_node_start_index_wasm = createExportWrapper("ts_node_start_index_wasm", 1);
2046
1933
  Module["_ts_node_end_index_wasm"] = _ts_node_end_index_wasm = createExportWrapper("ts_node_end_index_wasm", 1);
2047
1934
  Module["_ts_node_to_string_wasm"] = _ts_node_to_string_wasm = createExportWrapper("ts_node_to_string_wasm", 1);
2048
1935
  Module["_ts_node_children_wasm"] = _ts_node_children_wasm = createExportWrapper("ts_node_children_wasm", 1);
2049
1936
  Module["_ts_node_named_children_wasm"] = _ts_node_named_children_wasm = createExportWrapper("ts_node_named_children_wasm", 1);
2050
- Module["_ts_node_descendants_of_type_wasm"] = _ts_node_descendants_of_type_wasm = createExportWrapper("ts_node_descendants_of_type_wasm", 7);
1937
+ Module["_ts_node_descendants_of_type_wasm"] = _ts_node_descendants_of_type_wasm = createExportWrapper("ts_node_descendants_of_type_wasm", 3);
2051
1938
  Module["_ts_node_is_named_wasm"] = _ts_node_is_named_wasm = createExportWrapper("ts_node_is_named_wasm", 1);
2052
1939
  Module["_ts_node_has_changes_wasm"] = _ts_node_has_changes_wasm = createExportWrapper("ts_node_has_changes_wasm", 1);
2053
1940
  Module["_ts_node_has_error_wasm"] = _ts_node_has_error_wasm = createExportWrapper("ts_node_has_error_wasm", 1);
@@ -2056,9 +1943,9 @@ var require_web_tree_sitter = __commonJS({
2056
1943
  Module["_ts_node_is_extra_wasm"] = _ts_node_is_extra_wasm = createExportWrapper("ts_node_is_extra_wasm", 1);
2057
1944
  Module["_ts_node_parse_state_wasm"] = _ts_node_parse_state_wasm = createExportWrapper("ts_node_parse_state_wasm", 1);
2058
1945
  Module["_ts_node_next_parse_state_wasm"] = _ts_node_next_parse_state_wasm = createExportWrapper("ts_node_next_parse_state_wasm", 1);
2059
- Module["_memset"] = _memset = createExportWrapper("memset", 3);
2060
1946
  Module["_memcpy"] = _memcpy = createExportWrapper("memcpy", 3);
2061
1947
  Module["_memmove"] = _memmove = createExportWrapper("memmove", 3);
1948
+ Module["_memset"] = _memset = createExportWrapper("memset", 3);
2062
1949
  _fflush = createExportWrapper("fflush", 1);
2063
1950
  Module["_strlen"] = _strlen = createExportWrapper("strlen", 1);
2064
1951
  Module["_iswalnum"] = _iswalnum = createExportWrapper("iswalnum", 1);
@@ -2105,8 +1992,6 @@ var require_web_tree_sitter = __commonJS({
2105
1992
  /** @export */
2106
1993
  __table_base: ___table_base,
2107
1994
  /** @export */
2108
- _abort_js: __abort_js,
2109
- /** @export */
2110
1995
  _emscripten_throw_longjmp: __emscripten_throw_longjmp,
2111
1996
  /** @export */
2112
1997
  alignfault,
@@ -2119,8 +2004,6 @@ var require_web_tree_sitter = __commonJS({
2119
2004
  /** @export */
2120
2005
  fd_write: _fd_write,
2121
2006
  /** @export */
2122
- invoke_i,
2123
- /** @export */
2124
2007
  invoke_ii,
2125
2008
  /** @export */
2126
2009
  invoke_iii,
@@ -2129,9 +2012,11 @@ var require_web_tree_sitter = __commonJS({
2129
2012
  /** @export */
2130
2013
  invoke_iiiii,
2131
2014
  /** @export */
2015
+ invoke_ji,
2016
+ /** @export */
2132
2017
  invoke_vi,
2133
2018
  /** @export */
2134
- invoke_vii,
2019
+ invoke_vj,
2135
2020
  /** @export */
2136
2021
  memory: wasmMemory,
2137
2022
  /** @export */
@@ -2154,17 +2039,6 @@ var require_web_tree_sitter = __commonJS({
2154
2039
  }
2155
2040
  }
2156
2041
  __name(invoke_vi, "invoke_vi");
2157
- function invoke_i(index) {
2158
- var sp = stackSave();
2159
- try {
2160
- return getWasmTableEntry(index)();
2161
- } catch (e) {
2162
- stackRestore(sp);
2163
- if (e !== e + 0) throw e;
2164
- _setThrew(1, 0);
2165
- }
2166
- }
2167
- __name(invoke_i, "invoke_i");
2168
2042
  function invoke_ii(index, a1) {
2169
2043
  var sp = stackSave();
2170
2044
  try {
@@ -2176,28 +2050,29 @@ var require_web_tree_sitter = __commonJS({
2176
2050
  }
2177
2051
  }
2178
2052
  __name(invoke_ii, "invoke_ii");
2179
- function invoke_iii(index, a1, a2) {
2053
+ function invoke_vj(index, a1) {
2180
2054
  var sp = stackSave();
2181
2055
  try {
2182
- return getWasmTableEntry(index)(a1, a2);
2056
+ getWasmTableEntry(index)(a1);
2183
2057
  } catch (e) {
2184
2058
  stackRestore(sp);
2185
2059
  if (e !== e + 0) throw e;
2186
2060
  _setThrew(1, 0);
2187
2061
  }
2188
2062
  }
2189
- __name(invoke_iii, "invoke_iii");
2190
- function invoke_vii(index, a1, a2) {
2063
+ __name(invoke_vj, "invoke_vj");
2064
+ function invoke_ji(index, a1) {
2191
2065
  var sp = stackSave();
2192
2066
  try {
2193
- getWasmTableEntry(index)(a1, a2);
2067
+ return getWasmTableEntry(index)(a1);
2194
2068
  } catch (e) {
2195
2069
  stackRestore(sp);
2196
2070
  if (e !== e + 0) throw e;
2197
2071
  _setThrew(1, 0);
2072
+ return 0n;
2198
2073
  }
2199
2074
  }
2200
- __name(invoke_vii, "invoke_vii");
2075
+ __name(invoke_ji, "invoke_ji");
2201
2076
  function invoke_iiii(index, a1, a2, a3) {
2202
2077
  var sp = stackSave();
2203
2078
  try {
@@ -2220,6 +2095,17 @@ var require_web_tree_sitter = __commonJS({
2220
2095
  }
2221
2096
  }
2222
2097
  __name(invoke_iiiii, "invoke_iiiii");
2098
+ function invoke_iii(index, a1, a2) {
2099
+ var sp = stackSave();
2100
+ try {
2101
+ return getWasmTableEntry(index)(a1, a2);
2102
+ } catch (e) {
2103
+ stackRestore(sp);
2104
+ if (e !== e + 0) throw e;
2105
+ _setThrew(1, 0);
2106
+ }
2107
+ }
2108
+ __name(invoke_iii, "invoke_iii");
2223
2109
  var calledRun;
2224
2110
  function callMain(args2 = []) {
2225
2111
  assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on Module["onRuntimeInitialized"])');
@@ -2231,10 +2117,10 @@ var require_web_tree_sitter = __commonJS({
2231
2117
  var argv = stackAlloc((argc + 1) * 4);
2232
2118
  var argv_ptr = argv;
2233
2119
  args2.forEach((arg) => {
2234
- LE_HEAP_STORE_U32(SAFE_HEAP_INDEX(HEAPU32, argv_ptr >> 2, "storing") * 4, stringToUTF8OnStack(arg));
2120
+ HEAPU32[SAFE_HEAP_INDEX(HEAPU32, argv_ptr >> 2, "storing")] = stringToUTF8OnStack(arg);
2235
2121
  argv_ptr += 4;
2236
2122
  });
2237
- LE_HEAP_STORE_U32(SAFE_HEAP_INDEX(HEAPU32, argv_ptr >> 2, "storing") * 4, 0);
2123
+ HEAPU32[SAFE_HEAP_INDEX(HEAPU32, argv_ptr >> 2, "storing")] = 0;
2238
2124
  try {
2239
2125
  var ret = entryFunction(argc, argv);
2240
2126
  exitJS(
@@ -2249,7 +2135,7 @@ var require_web_tree_sitter = __commonJS({
2249
2135
  }
2250
2136
  __name(callMain, "callMain");
2251
2137
  function stackCheckInit() {
2252
- _emscripten_stack_set_limits(82480, 16944);
2138
+ _emscripten_stack_set_limits(82464, 16928);
2253
2139
  writeStackCookie();
2254
2140
  }
2255
2141
  __name(stackCheckInit, "stackCheckInit");
@@ -2352,7 +2238,7 @@ __export(index_exports, {
2352
2238
  MIN_COMPATIBLE_VERSION: () => MIN_COMPATIBLE_VERSION,
2353
2239
  Node: () => Node,
2354
2240
  Parser: () => Parser,
2355
- Tree: () => Tree,
2241
+ Tree: () => Tree2,
2356
2242
  TreeCursor: () => TreeCursor
2357
2243
  });
2358
2244
  module.exports = __toCommonJS(index_exports);
@@ -2460,9 +2346,7 @@ var Edit = class {
2460
2346
  };
2461
2347
 
2462
2348
  // src/constants.ts
2463
- var SIZE_OF_SHORT = 2;
2464
2349
  var SIZE_OF_INT = 4;
2465
- var SIZE_OF_CURSOR = 4 * SIZE_OF_INT;
2466
2350
  var SIZE_OF_NODE = 5 * SIZE_OF_INT;
2467
2351
  var SIZE_OF_POINT = 2 * SIZE_OF_INT;
2468
2352
  var SIZE_OF_RANGE = 2 * SIZE_OF_INT + 2 * SIZE_OF_POINT;
@@ -2585,177 +2469,53 @@ var LookaheadIterator = class {
2585
2469
  }
2586
2470
  };
2587
2471
 
2588
- // src/tree.ts
2589
- function getText(tree, startIndex, endIndex, startPosition) {
2590
- const length = endIndex - startIndex;
2591
- let result = tree.textCallback(startIndex, startPosition);
2592
- if (result) {
2593
- startIndex += result.length;
2594
- while (startIndex < endIndex) {
2595
- const string = tree.textCallback(startIndex, startPosition);
2596
- if (string && string.length > 0) {
2597
- startIndex += string.length;
2598
- result += string;
2599
- } else {
2600
- break;
2601
- }
2602
- }
2603
- if (startIndex > endIndex) {
2604
- result = result.slice(0, length);
2605
- }
2606
- }
2607
- return result ?? "";
2608
- }
2609
- __name(getText, "getText");
2472
+ // src/tree_cursor.ts
2610
2473
  var finalizer2 = newFinalizer((address) => {
2611
- C._ts_tree_delete(address);
2474
+ C._ts_tree_cursor_delete_wasm(address);
2612
2475
  });
2613
- var Tree = class _Tree {
2476
+ var TreeCursor = class _TreeCursor {
2614
2477
  static {
2615
- __name(this, "Tree");
2478
+ __name(this, "TreeCursor");
2616
2479
  }
2617
2480
  /** @internal */
2618
2481
  [0] = 0;
2619
2482
  // Internal handle for Wasm
2620
2483
  /** @internal */
2621
- textCallback;
2622
- /** The language that was used to parse the syntax tree. */
2623
- language;
2484
+ tree;
2624
2485
  /** @internal */
2625
- constructor(internal, address, language, textCallback) {
2626
- assertInternal(internal);
2627
- this[0] = address;
2628
- this.language = language;
2629
- this.textCallback = textCallback;
2630
- finalizer2?.register(this, address, this);
2631
- }
2632
- /** Create a shallow copy of the syntax tree. This is very fast. */
2633
- copy() {
2634
- const address = C._ts_tree_copy(this[0]);
2635
- return new _Tree(INTERNAL, address, this.language, this.textCallback);
2636
- }
2637
- /** Delete the syntax tree, freeing its resources. */
2638
- delete() {
2639
- finalizer2?.unregister(this);
2640
- C._ts_tree_delete(this[0]);
2641
- this[0] = 0;
2642
- }
2643
- /** Get the root node of the syntax tree. */
2644
- get rootNode() {
2645
- C._ts_tree_root_node_wasm(this[0]);
2646
- return unmarshalNode(this);
2647
- }
2648
- /**
2649
- * Get the root node of the syntax tree, but with its position shifted
2650
- * forward by the given offset.
2651
- */
2652
- rootNodeWithOffset(offsetBytes, offsetExtent) {
2653
- const address = TRANSFER_BUFFER + SIZE_OF_NODE;
2654
- C.setValue(address, offsetBytes, "i32");
2655
- marshalPoint(address + SIZE_OF_INT, offsetExtent);
2656
- C._ts_tree_root_node_with_offset_wasm(this[0]);
2657
- return unmarshalNode(this);
2658
- }
2659
- /**
2660
- * Edit the syntax tree to keep it in sync with source code that has been
2661
- * edited.
2662
- *
2663
- * You must describe the edit both in terms of byte offsets and in terms of
2664
- * row/column coordinates.
2665
- */
2666
- edit(edit) {
2667
- marshalEdit(edit);
2668
- C._ts_tree_edit_wasm(this[0]);
2669
- }
2670
- /** Create a new {@link TreeCursor} starting from the root of the tree. */
2671
- walk() {
2672
- return this.rootNode.walk();
2673
- }
2674
- /**
2675
- * Compare this old edited syntax tree to a new syntax tree representing
2676
- * the same document, returning a sequence of ranges whose syntactic
2677
- * structure has changed.
2678
- *
2679
- * For this to work correctly, this syntax tree must have been edited such
2680
- * that its ranges match up to the new tree. Generally, you'll want to
2681
- * call this method right after calling one of the [`Parser::parse`]
2682
- * functions. Call it on the old tree that was passed to parse, and
2683
- * pass the new tree that was returned from `parse`.
2684
- */
2685
- getChangedRanges(other) {
2686
- if (!(other instanceof _Tree)) {
2687
- throw new TypeError("Argument must be a Tree");
2688
- }
2689
- C._ts_tree_get_changed_ranges_wasm(this[0], other[0]);
2690
- const count = C.getValue(TRANSFER_BUFFER, "i32");
2691
- const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
2692
- const result = new Array(count);
2693
- if (count > 0) {
2694
- let address = buffer;
2695
- for (let i2 = 0; i2 < count; i2++) {
2696
- result[i2] = unmarshalRange(address);
2697
- address += SIZE_OF_RANGE;
2698
- }
2699
- C._ts_free_wasm(buffer);
2700
- }
2701
- return result;
2702
- }
2703
- /** Get the included ranges that were used to parse the syntax tree. */
2704
- getIncludedRanges() {
2705
- C._ts_tree_included_ranges_wasm(this[0]);
2706
- const count = C.getValue(TRANSFER_BUFFER, "i32");
2707
- const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
2708
- const result = new Array(count);
2709
- if (count > 0) {
2710
- let address = buffer;
2711
- for (let i2 = 0; i2 < count; i2++) {
2712
- result[i2] = unmarshalRange(address);
2713
- address += SIZE_OF_RANGE;
2714
- }
2715
- C._ts_free_wasm(buffer);
2716
- }
2717
- return result;
2718
- }
2719
- };
2720
-
2721
- // src/tree_cursor.ts
2722
- var finalizer3 = newFinalizer((handles) => {
2723
- marshalTreeCursor({ handles });
2724
- C._ts_tree_cursor_delete_wasm(0);
2725
- });
2726
- var TreeCursor = class _TreeCursor {
2727
- static {
2728
- __name(this, "TreeCursor");
2729
- }
2486
+ editVersion = -1;
2730
2487
  /** @internal */
2731
- handles = [0, 0, 0, 0];
2732
- // Internal handles for Wasm, shared with the finalizer.
2488
+ _nodeTypeId = 0;
2733
2489
  /** @internal */
2734
- tree;
2490
+ _fieldId = 0;
2491
+ /** @internal */
2492
+ _startIndex = 0;
2735
2493
  /** @internal */
2736
- constructor(internal, tree) {
2494
+ _endIndex = 0;
2495
+ /** @internal */
2496
+ _flags = 0;
2497
+ /** @internal */
2498
+ constructor(internal, tree, address) {
2737
2499
  assertInternal(internal);
2500
+ this[0] = address;
2738
2501
  this.tree = tree;
2739
- unmarshalTreeCursor(this);
2740
- finalizer3?.register(this, this.handles, this);
2502
+ this.readNodeCache();
2503
+ finalizer2?.register(this, address, this);
2741
2504
  }
2742
2505
  /** Creates a deep copy of the tree cursor. This allocates new memory. */
2743
2506
  copy() {
2744
- marshalTreeCursor(this);
2745
- C._ts_tree_cursor_copy_wasm(this.tree[0]);
2746
- return new _TreeCursor(INTERNAL, this.tree);
2507
+ const address = C._ts_tree_cursor_copy_wasm(this[0]);
2508
+ return new _TreeCursor(INTERNAL, this.tree, address);
2747
2509
  }
2748
2510
  /** Delete the tree cursor, freeing its resources. */
2749
2511
  delete() {
2750
- finalizer3?.unregister(this);
2751
- marshalTreeCursor(this);
2752
- C._ts_tree_cursor_delete_wasm(this.tree[0]);
2753
- this.handles.fill(0);
2512
+ finalizer2?.unregister(this);
2513
+ C._ts_tree_cursor_delete_wasm(this[0]);
2514
+ this[0] = 0;
2754
2515
  }
2755
2516
  /** Get the tree cursor's current {@link Node}. */
2756
2517
  get currentNode() {
2757
- marshalTreeCursor(this);
2758
- C._ts_tree_cursor_current_node_wasm(this.tree[0]);
2518
+ C._ts_tree_cursor_current_node_wasm(this[0]);
2759
2519
  return unmarshalNode(this.tree);
2760
2520
  }
2761
2521
  /**
@@ -2764,47 +2524,41 @@ var TreeCursor = class _TreeCursor {
2764
2524
  * See also {@link TreeCursor#currentFieldName}.
2765
2525
  */
2766
2526
  get currentFieldId() {
2767
- marshalTreeCursor(this);
2768
- return C._ts_tree_cursor_current_field_id_wasm(this.tree[0]);
2527
+ return this._fieldId;
2769
2528
  }
2770
2529
  /** Get the field name of this tree cursor's current node. */
2771
2530
  get currentFieldName() {
2772
- return this.tree.language.fields[this.currentFieldId];
2531
+ return this.tree.language.fields[this._fieldId] ?? null;
2773
2532
  }
2774
2533
  /**
2775
2534
  * Get the depth of the cursor's current node relative to the original
2776
2535
  * node that the cursor was constructed with.
2777
2536
  */
2778
2537
  get currentDepth() {
2779
- marshalTreeCursor(this);
2780
- return C._ts_tree_cursor_current_depth_wasm(this.tree[0]);
2538
+ return C._ts_tree_cursor_current_depth(this[0]) >>> 0;
2781
2539
  }
2782
2540
  /**
2783
2541
  * Get the index of the cursor's current node out of all of the
2784
2542
  * descendants of the original node that the cursor was constructed with.
2785
2543
  */
2786
2544
  get currentDescendantIndex() {
2787
- marshalTreeCursor(this);
2788
- return C._ts_tree_cursor_current_descendant_index_wasm(this.tree[0]);
2545
+ return C._ts_tree_cursor_current_descendant_index(this[0]) >>> 0;
2789
2546
  }
2790
2547
  /** Get the type of the cursor's current node. */
2791
2548
  get nodeType() {
2792
- return this.tree.language.types[this.nodeTypeId] || "ERROR";
2549
+ return this.tree.language.types[this._nodeTypeId] || "ERROR";
2793
2550
  }
2794
2551
  /** Get the type id of the cursor's current node. */
2795
2552
  get nodeTypeId() {
2796
- marshalTreeCursor(this);
2797
- return C._ts_tree_cursor_current_node_type_id_wasm(this.tree[0]);
2553
+ return this._nodeTypeId;
2798
2554
  }
2799
2555
  /** Get the state id of the cursor's current node. */
2800
2556
  get nodeStateId() {
2801
- marshalTreeCursor(this);
2802
- return C._ts_tree_cursor_current_node_state_id_wasm(this.tree[0]);
2557
+ return C._ts_tree_cursor_current_node_state_id_wasm(this[0]);
2803
2558
  }
2804
2559
  /** Get the id of the cursor's current node. */
2805
2560
  get nodeId() {
2806
- marshalTreeCursor(this);
2807
- return C._ts_tree_cursor_current_node_id_wasm(this.tree[0]);
2561
+ return C._ts_tree_cursor_current_node_id_wasm(this[0]);
2808
2562
  }
2809
2563
  /**
2810
2564
  * Check if the cursor's current node is *named*.
@@ -2813,8 +2567,7 @@ var TreeCursor = class _TreeCursor {
2813
2567
  * *anonymous* nodes correspond to string literals in the grammar.
2814
2568
  */
2815
2569
  get nodeIsNamed() {
2816
- marshalTreeCursor(this);
2817
- return C._ts_tree_cursor_current_node_is_named_wasm(this.tree[0]) === 1;
2570
+ return (this._flags & 1) !== 0;
2818
2571
  }
2819
2572
  /**
2820
2573
  * Check if the cursor's current node is *missing*.
@@ -2823,39 +2576,33 @@ var TreeCursor = class _TreeCursor {
2823
2576
  * certain kinds of syntax errors.
2824
2577
  */
2825
2578
  get nodeIsMissing() {
2826
- marshalTreeCursor(this);
2827
- return C._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0]) === 1;
2579
+ return (this._flags & 2) !== 0;
2828
2580
  }
2829
2581
  /** Get the string content of the cursor's current node. */
2830
2582
  get nodeText() {
2831
- marshalTreeCursor(this);
2832
- const startIndex = C._ts_tree_cursor_start_index_wasm(this.tree[0]);
2833
- const endIndex = C._ts_tree_cursor_end_index_wasm(this.tree[0]);
2834
- C._ts_tree_cursor_start_position_wasm(this.tree[0]);
2835
- const startPosition = unmarshalPoint(TRANSFER_BUFFER);
2836
- return getText(this.tree, startIndex, endIndex, startPosition);
2583
+ this.syncIndices();
2584
+ const { textSource } = this.tree;
2585
+ return typeof textSource === "string" ? textSource.slice(this._startIndex, this._endIndex) : getCallbackText(textSource, this._startIndex, this._endIndex, this.startPosition);
2837
2586
  }
2838
2587
  /** Get the start position of the cursor's current node. */
2839
2588
  get startPosition() {
2840
- marshalTreeCursor(this);
2841
- C._ts_tree_cursor_start_position_wasm(this.tree[0]);
2589
+ C._ts_tree_cursor_start_position_wasm(this[0]);
2842
2590
  return unmarshalPoint(TRANSFER_BUFFER);
2843
2591
  }
2844
2592
  /** Get the end position of the cursor's current node. */
2845
2593
  get endPosition() {
2846
- marshalTreeCursor(this);
2847
- C._ts_tree_cursor_end_position_wasm(this.tree[0]);
2594
+ C._ts_tree_cursor_end_position_wasm(this[0]);
2848
2595
  return unmarshalPoint(TRANSFER_BUFFER);
2849
2596
  }
2850
2597
  /** Get the start index of the cursor's current node. */
2851
2598
  get startIndex() {
2852
- marshalTreeCursor(this);
2853
- return C._ts_tree_cursor_start_index_wasm(this.tree[0]);
2599
+ this.syncIndices();
2600
+ return this._startIndex;
2854
2601
  }
2855
2602
  /** Get the end index of the cursor's current node. */
2856
2603
  get endIndex() {
2857
- marshalTreeCursor(this);
2858
- return C._ts_tree_cursor_end_index_wasm(this.tree[0]);
2604
+ this.syncIndices();
2605
+ return this._endIndex;
2859
2606
  }
2860
2607
  /**
2861
2608
  * Move this cursor to the first child of its current node.
@@ -2864,10 +2611,9 @@ var TreeCursor = class _TreeCursor {
2864
2611
  * `false` if there were no children.
2865
2612
  */
2866
2613
  gotoFirstChild() {
2867
- marshalTreeCursor(this);
2868
- const result = C._ts_tree_cursor_goto_first_child_wasm(this.tree[0]);
2869
- unmarshalTreeCursor(this);
2870
- return result === 1;
2614
+ if (!C._ts_tree_cursor_goto_first_child_wasm(this[0])) return false;
2615
+ this.readNodeCache();
2616
+ return true;
2871
2617
  }
2872
2618
  /**
2873
2619
  * Move this cursor to the last child of its current node.
@@ -2880,10 +2626,9 @@ var TreeCursor = class _TreeCursor {
2880
2626
  * iterate through all the children to compute the child's position.
2881
2627
  */
2882
2628
  gotoLastChild() {
2883
- marshalTreeCursor(this);
2884
- const result = C._ts_tree_cursor_goto_last_child_wasm(this.tree[0]);
2885
- unmarshalTreeCursor(this);
2886
- return result === 1;
2629
+ if (!C._ts_tree_cursor_goto_last_child_wasm(this[0])) return false;
2630
+ this.readNodeCache();
2631
+ return true;
2887
2632
  }
2888
2633
  /**
2889
2634
  * Move this cursor to the parent of its current node.
@@ -2896,10 +2641,9 @@ var TreeCursor = class _TreeCursor {
2896
2641
  * of the cursor, and the cursor cannot walk outside this node.
2897
2642
  */
2898
2643
  gotoParent() {
2899
- marshalTreeCursor(this);
2900
- const result = C._ts_tree_cursor_goto_parent_wasm(this.tree[0]);
2901
- unmarshalTreeCursor(this);
2902
- return result === 1;
2644
+ if (!C._ts_tree_cursor_goto_parent_wasm(this[0])) return false;
2645
+ this.readNodeCache();
2646
+ return true;
2903
2647
  }
2904
2648
  /**
2905
2649
  * Move this cursor to the next sibling of its current node.
@@ -2911,10 +2655,9 @@ var TreeCursor = class _TreeCursor {
2911
2655
  * of the cursor, and the cursor cannot walk outside this node.
2912
2656
  */
2913
2657
  gotoNextSibling() {
2914
- marshalTreeCursor(this);
2915
- const result = C._ts_tree_cursor_goto_next_sibling_wasm(this.tree[0]);
2916
- unmarshalTreeCursor(this);
2917
- return result === 1;
2658
+ if (!C._ts_tree_cursor_goto_next_sibling_wasm(this[0])) return false;
2659
+ this.readNodeCache();
2660
+ return true;
2918
2661
  }
2919
2662
  /**
2920
2663
  * Move this cursor to the previous sibling of its current node.
@@ -2930,10 +2673,9 @@ var TreeCursor = class _TreeCursor {
2930
2673
  * considered the root of the cursor, and the cursor cannot walk outside this node.
2931
2674
  */
2932
2675
  gotoPreviousSibling() {
2933
- marshalTreeCursor(this);
2934
- const result = C._ts_tree_cursor_goto_previous_sibling_wasm(this.tree[0]);
2935
- unmarshalTreeCursor(this);
2936
- return result === 1;
2676
+ if (!C._ts_tree_cursor_goto_previous_sibling_wasm(this[0])) return false;
2677
+ this.readNodeCache();
2678
+ return true;
2937
2679
  }
2938
2680
  /**
2939
2681
  * Move the cursor to the node that is the nth descendant of
@@ -2941,9 +2683,8 @@ var TreeCursor = class _TreeCursor {
2941
2683
  * zero represents the original node itself.
2942
2684
  */
2943
2685
  gotoDescendant(goalDescendantIndex) {
2944
- marshalTreeCursor(this);
2945
- C._ts_tree_cursor_goto_descendant_wasm(this.tree[0], goalDescendantIndex);
2946
- unmarshalTreeCursor(this);
2686
+ C._ts_tree_cursor_goto_descendant_wasm(this[0], goalDescendantIndex);
2687
+ this.readNodeCache();
2947
2688
  }
2948
2689
  /**
2949
2690
  * Move this cursor to the first child of its current node that contains or
@@ -2953,11 +2694,9 @@ var TreeCursor = class _TreeCursor {
2953
2694
  * `false` if no such child was found.
2954
2695
  */
2955
2696
  gotoFirstChildForIndex(goalIndex) {
2956
- marshalTreeCursor(this);
2957
- C.setValue(TRANSFER_BUFFER + SIZE_OF_CURSOR, goalIndex, "i32");
2958
- const result = C._ts_tree_cursor_goto_first_child_for_index_wasm(this.tree[0]);
2959
- unmarshalTreeCursor(this);
2960
- return result === 1;
2697
+ if (!C._ts_tree_cursor_goto_first_child_for_index_wasm(this[0], goalIndex)) return false;
2698
+ this.readNodeCache();
2699
+ return true;
2961
2700
  }
2962
2701
  /**
2963
2702
  * Move this cursor to the first child of its current node that contains or
@@ -2967,11 +2706,15 @@ var TreeCursor = class _TreeCursor {
2967
2706
  * `false` if no such child was found.
2968
2707
  */
2969
2708
  gotoFirstChildForPosition(goalPosition) {
2970
- marshalTreeCursor(this);
2971
- marshalPoint(TRANSFER_BUFFER + SIZE_OF_CURSOR, goalPosition);
2972
- const result = C._ts_tree_cursor_goto_first_child_for_position_wasm(this.tree[0]);
2973
- unmarshalTreeCursor(this);
2974
- return result === 1;
2709
+ if (!C._ts_tree_cursor_goto_first_child_for_position_wasm(
2710
+ this[0],
2711
+ goalPosition.row,
2712
+ goalPosition.column
2713
+ )) {
2714
+ return false;
2715
+ }
2716
+ this.readNodeCache();
2717
+ return true;
2975
2718
  }
2976
2719
  /**
2977
2720
  * Re-initialize this tree cursor to start at the original node that the
@@ -2979,10 +2722,9 @@ var TreeCursor = class _TreeCursor {
2979
2722
  */
2980
2723
  reset(node) {
2981
2724
  marshalNode(node);
2982
- marshalTreeCursor(this, TRANSFER_BUFFER + SIZE_OF_NODE);
2983
- C._ts_tree_cursor_reset_wasm(node.tree[0]);
2984
- unmarshalTreeCursor(this);
2985
2725
  this.tree = node.tree;
2726
+ C._ts_tree_cursor_reset_wasm(this[0], node.tree[0]);
2727
+ this.readNodeCache();
2986
2728
  }
2987
2729
  /**
2988
2730
  * Re-initialize a tree cursor to the same position as another cursor.
@@ -2991,11 +2733,145 @@ var TreeCursor = class _TreeCursor {
2991
2733
  * information and allows reusing already created cursors.
2992
2734
  */
2993
2735
  resetTo(cursor) {
2994
- marshalTreeCursor(this, TRANSFER_BUFFER);
2995
- marshalTreeCursor(cursor, TRANSFER_BUFFER + SIZE_OF_CURSOR);
2996
- C._ts_tree_cursor_reset_to_wasm(this.tree[0], cursor.tree[0]);
2997
- unmarshalTreeCursor(this);
2736
+ if (this[0] === cursor[0]) return;
2998
2737
  this.tree = cursor.tree;
2738
+ C._ts_tree_cursor_reset_to_wasm(this[0], cursor[0]);
2739
+ this.readNodeCache();
2740
+ }
2741
+ /** @internal */
2742
+ readNodeCache() {
2743
+ const base = TRANSFER_BUFFER >>> 2;
2744
+ const heap = C.HEAPU32;
2745
+ this._nodeTypeId = heap[base];
2746
+ this._fieldId = heap[base + 1];
2747
+ this._startIndex = heap[base + 2];
2748
+ this._endIndex = heap[base + 3];
2749
+ this._flags = heap[base + 4];
2750
+ this.editVersion = this.tree.editVersion;
2751
+ }
2752
+ /** @internal */
2753
+ syncIndices() {
2754
+ if (this.editVersion !== this.tree.editVersion) {
2755
+ this._startIndex = C._ts_tree_cursor_start_index_wasm(this[0]) >>> 0;
2756
+ this._endIndex = C._ts_tree_cursor_end_index_wasm(this[0]) >>> 0;
2757
+ this.editVersion = this.tree.editVersion;
2758
+ }
2759
+ }
2760
+ };
2761
+
2762
+ // src/tree.ts
2763
+ function getCallbackText(textSource, startIndex, endIndex, startPosition) {
2764
+ const length = endIndex - startIndex;
2765
+ let result = textSource(startIndex, startPosition);
2766
+ if (result) {
2767
+ startIndex += result.length;
2768
+ while (startIndex < endIndex) {
2769
+ const string = textSource(startIndex, startPosition);
2770
+ if (string && string.length > 0) {
2771
+ startIndex += string.length;
2772
+ result += string;
2773
+ } else {
2774
+ break;
2775
+ }
2776
+ }
2777
+ if (startIndex > endIndex) {
2778
+ result = result.slice(0, length);
2779
+ }
2780
+ }
2781
+ return result ?? "";
2782
+ }
2783
+ __name(getCallbackText, "getCallbackText");
2784
+ var finalizer3 = newFinalizer((address) => {
2785
+ C._ts_tree_delete(address);
2786
+ });
2787
+ var Tree2 = class _Tree {
2788
+ static {
2789
+ __name(this, "Tree");
2790
+ }
2791
+ /** @internal */
2792
+ [0] = 0;
2793
+ // Internal handle for Wasm
2794
+ /** @internal */
2795
+ textSource;
2796
+ /** @internal */
2797
+ editVersion = 0;
2798
+ /** The language that was used to parse the syntax tree. */
2799
+ language;
2800
+ /** @internal */
2801
+ constructor(internal, address, language, textSource) {
2802
+ assertInternal(internal);
2803
+ this[0] = address;
2804
+ this.language = language;
2805
+ this.textSource = textSource;
2806
+ finalizer3?.register(this, address, this);
2807
+ }
2808
+ /** Create a shallow copy of the syntax tree. This is very fast. */
2809
+ copy() {
2810
+ const address = C._ts_tree_copy(this[0]);
2811
+ return new _Tree(INTERNAL, address, this.language, this.textSource);
2812
+ }
2813
+ /** Delete the syntax tree, freeing its resources. */
2814
+ delete() {
2815
+ finalizer3?.unregister(this);
2816
+ C._ts_tree_delete(this[0]);
2817
+ this[0] = 0;
2818
+ }
2819
+ /** Get the root node of the syntax tree. */
2820
+ get rootNode() {
2821
+ C._ts_tree_root_node_wasm(this[0]);
2822
+ return unmarshalNode(this);
2823
+ }
2824
+ /**
2825
+ * Get the root node of the syntax tree, but with its position shifted
2826
+ * forward by the given offset.
2827
+ */
2828
+ rootNodeWithOffset(offsetBytes, offsetExtent) {
2829
+ const address = TRANSFER_BUFFER + SIZE_OF_NODE;
2830
+ C.HEAP32[address >>> 2] = offsetBytes;
2831
+ marshalPoint(address + SIZE_OF_INT, offsetExtent);
2832
+ C._ts_tree_root_node_with_offset_wasm(this[0]);
2833
+ return unmarshalNode(this);
2834
+ }
2835
+ /**
2836
+ * Edit the syntax tree to keep it in sync with source code that has been
2837
+ * edited.
2838
+ *
2839
+ * You must describe the edit both in terms of byte offsets and in terms of
2840
+ * row/column coordinates.
2841
+ */
2842
+ edit(edit) {
2843
+ marshalEdit(edit);
2844
+ C._ts_tree_edit_wasm(this[0]);
2845
+ this.editVersion++;
2846
+ }
2847
+ /** Create a new {@link TreeCursor} starting from the root of the tree. */
2848
+ walk() {
2849
+ C._ts_tree_root_node_wasm(this[0]);
2850
+ const address = C._ts_tree_cursor_new_wasm(this[0]);
2851
+ return new TreeCursor(INTERNAL, this, address);
2852
+ }
2853
+ /**
2854
+ * Compare this old edited syntax tree to a new syntax tree representing
2855
+ * the same document, returning a sequence of ranges whose syntactic
2856
+ * structure has changed.
2857
+ *
2858
+ * For this to work correctly, this syntax tree must have been edited such
2859
+ * that its ranges match up to the new tree. Generally, you'll want to
2860
+ * call this method right after calling one of the [`Parser::parse`]
2861
+ * functions. Call it on the old tree that was passed to parse, and
2862
+ * pass the new tree that was returned from `parse`.
2863
+ */
2864
+ getChangedRanges(other) {
2865
+ if (!(other instanceof _Tree)) {
2866
+ throw new TypeError("Argument must be a Tree");
2867
+ }
2868
+ C._ts_tree_get_changed_ranges_wasm(this[0], other[0]);
2869
+ return unmarshalRanges();
2870
+ }
2871
+ /** Get the included ranges that were used to parse the syntax tree. */
2872
+ getIncludedRanges() {
2873
+ C._ts_tree_included_ranges_wasm(this[0]);
2874
+ return unmarshalRanges();
2999
2875
  }
3000
2876
  };
3001
2877
 
@@ -3136,7 +3012,8 @@ var Node = class {
3136
3012
  }
3137
3013
  /** Get the string content of this node. */
3138
3014
  get text() {
3139
- return getText(this.tree, this.startIndex, this.endIndex, this.startPosition);
3015
+ const { textSource } = this.tree;
3016
+ return typeof textSource === "string" ? textSource.slice(this.startIndex, this.endIndex) : getCallbackText(textSource, this.startIndex, this.endIndex, this.startPosition);
3140
3017
  }
3141
3018
  /** Get this node's parse state. */
3142
3019
  get parseState() {
@@ -3231,24 +3108,13 @@ var Node = class {
3231
3108
  childrenForFieldId(fieldId) {
3232
3109
  marshalNode(this);
3233
3110
  C._ts_node_children_by_field_id_wasm(this.tree[0], fieldId);
3234
- const count = C.getValue(TRANSFER_BUFFER, "i32");
3235
- const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
3236
- const result = new Array(count);
3237
- if (count > 0) {
3238
- let address = buffer;
3239
- for (let i2 = 0; i2 < count; i2++) {
3240
- result[i2] = unmarshalNode(this.tree, address);
3241
- address += SIZE_OF_NODE;
3242
- }
3243
- C._ts_free_wasm(buffer);
3244
- }
3245
- return result;
3111
+ return unmarshalNodeArray(this.tree, true);
3246
3112
  }
3247
3113
  /** Get the node's first child that contains or starts after the given byte offset. */
3248
3114
  firstChildForIndex(index) {
3249
3115
  marshalNode(this);
3250
3116
  const address = TRANSFER_BUFFER + SIZE_OF_NODE;
3251
- C.setValue(address, index, "i32");
3117
+ C.HEAP32[address >>> 2] = index;
3252
3118
  C._ts_node_first_child_for_byte_wasm(this.tree[0]);
3253
3119
  return unmarshalNode(this.tree);
3254
3120
  }
@@ -3256,7 +3122,7 @@ var Node = class {
3256
3122
  firstNamedChildForIndex(index) {
3257
3123
  marshalNode(this);
3258
3124
  const address = TRANSFER_BUFFER + SIZE_OF_NODE;
3259
- C.setValue(address, index, "i32");
3125
+ C.HEAP32[address >>> 2] = index;
3260
3126
  C._ts_node_first_named_child_for_byte_wasm(this.tree[0]);
3261
3127
  return unmarshalNode(this.tree);
3262
3128
  }
@@ -3308,17 +3174,7 @@ var Node = class {
3308
3174
  if (!this._children) {
3309
3175
  marshalNode(this);
3310
3176
  C._ts_node_children_wasm(this.tree[0]);
3311
- const count = C.getValue(TRANSFER_BUFFER, "i32");
3312
- const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
3313
- this._children = new Array(count);
3314
- if (count > 0) {
3315
- let address = buffer;
3316
- for (let i2 = 0; i2 < count; i2++) {
3317
- this._children[i2] = unmarshalNode(this.tree, address);
3318
- address += SIZE_OF_NODE;
3319
- }
3320
- C._free(buffer);
3321
- }
3177
+ this._children = unmarshalNodeArray(this.tree);
3322
3178
  }
3323
3179
  return this._children;
3324
3180
  }
@@ -3331,17 +3187,7 @@ var Node = class {
3331
3187
  if (!this._namedChildren) {
3332
3188
  marshalNode(this);
3333
3189
  C._ts_node_named_children_wasm(this.tree[0]);
3334
- const count = C.getValue(TRANSFER_BUFFER, "i32");
3335
- const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
3336
- this._namedChildren = new Array(count);
3337
- if (count > 0) {
3338
- let address = buffer;
3339
- for (let i2 = 0; i2 < count; i2++) {
3340
- this._namedChildren[i2] = unmarshalNode(this.tree, address);
3341
- address += SIZE_OF_NODE;
3342
- }
3343
- C._free(buffer);
3344
- }
3190
+ this._namedChildren = unmarshalNodeArray(this.tree);
3345
3191
  }
3346
3192
  return this._namedChildren;
3347
3193
  }
@@ -3365,30 +3211,21 @@ var Node = class {
3365
3211
  symbols.push(65535);
3366
3212
  }
3367
3213
  const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length);
3214
+ const symbolsHeap = C.HEAPU32;
3215
+ const symbolsBase = symbolsAddress >>> 2;
3368
3216
  for (let i2 = 0, n = symbols.length; i2 < n; i2++) {
3369
- C.setValue(symbolsAddress + i2 * SIZE_OF_INT, symbols[i2], "i32");
3217
+ symbolsHeap[symbolsBase + i2] = symbols[i2];
3370
3218
  }
3371
3219
  marshalNode(this);
3220
+ const pointAddress = TRANSFER_BUFFER + SIZE_OF_NODE;
3221
+ marshalPoint(pointAddress, startPosition);
3222
+ marshalPoint(pointAddress + SIZE_OF_POINT, endPosition);
3372
3223
  C._ts_node_descendants_of_type_wasm(
3373
3224
  this.tree[0],
3374
3225
  symbolsAddress,
3375
- symbols.length,
3376
- startPosition.row,
3377
- startPosition.column,
3378
- endPosition.row,
3379
- endPosition.column
3226
+ symbols.length
3380
3227
  );
3381
- const descendantCount = C.getValue(TRANSFER_BUFFER, "i32");
3382
- const descendantAddress = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
3383
- const result = new Array(descendantCount);
3384
- if (descendantCount > 0) {
3385
- let address = descendantAddress;
3386
- for (let i2 = 0; i2 < descendantCount; i2++) {
3387
- result[i2] = unmarshalNode(this.tree, address);
3388
- address += SIZE_OF_NODE;
3389
- }
3390
- }
3391
- C._ts_free_wasm(descendantAddress);
3228
+ const result = unmarshalNodeArray(this.tree, true);
3392
3229
  C._free(symbolsAddress);
3393
3230
  return result;
3394
3231
  }
@@ -3456,9 +3293,10 @@ var Node = class {
3456
3293
  throw new Error("Arguments must be numbers");
3457
3294
  }
3458
3295
  marshalNode(this);
3459
- const address = TRANSFER_BUFFER + SIZE_OF_NODE;
3460
- C.setValue(address, start2, "i32");
3461
- C.setValue(address + SIZE_OF_INT, end, "i32");
3296
+ const base = TRANSFER_BUFFER + SIZE_OF_NODE >>> 2;
3297
+ const heap = C.HEAP32;
3298
+ heap[base] = start2;
3299
+ heap[base + 1] = end;
3462
3300
  C._ts_node_descendant_for_index_wasm(this.tree[0]);
3463
3301
  return unmarshalNode(this.tree);
3464
3302
  }
@@ -3468,9 +3306,10 @@ var Node = class {
3468
3306
  throw new Error("Arguments must be numbers");
3469
3307
  }
3470
3308
  marshalNode(this);
3471
- const address = TRANSFER_BUFFER + SIZE_OF_NODE;
3472
- C.setValue(address, start2, "i32");
3473
- C.setValue(address + SIZE_OF_INT, end, "i32");
3309
+ const base = TRANSFER_BUFFER + SIZE_OF_NODE >>> 2;
3310
+ const heap = C.HEAP32;
3311
+ heap[base] = start2;
3312
+ heap[base + 1] = end;
3474
3313
  C._ts_node_named_descendant_for_index_wasm(this.tree[0]);
3475
3314
  return unmarshalNode(this.tree);
3476
3315
  }
@@ -3506,8 +3345,8 @@ var Node = class {
3506
3345
  */
3507
3346
  walk() {
3508
3347
  marshalNode(this);
3509
- C._ts_tree_cursor_new_wasm(this.tree[0]);
3510
- return new TreeCursor(INTERNAL, this.tree);
3348
+ const address = C._ts_tree_cursor_new_wasm(this.tree[0]);
3349
+ return new TreeCursor(INTERNAL, this.tree, address);
3511
3350
  }
3512
3351
  /**
3513
3352
  * Edit this node to keep it in-sync with source code that has been edited.
@@ -3535,109 +3374,130 @@ var Node = class {
3535
3374
 
3536
3375
  // src/marshal.ts
3537
3376
  function marshalNode(node, index = 0) {
3538
- let address = TRANSFER_BUFFER + index * SIZE_OF_NODE;
3539
- C.setValue(address, node.id, "i32");
3540
- address += SIZE_OF_INT;
3541
- C.setValue(address, node.startIndex, "i32");
3542
- address += SIZE_OF_INT;
3543
- C.setValue(address, node.startPosition.row, "i32");
3544
- address += SIZE_OF_INT;
3545
- C.setValue(address, node.startPosition.column, "i32");
3546
- address += SIZE_OF_INT;
3547
- C.setValue(address, node[0], "i32");
3377
+ const base = TRANSFER_BUFFER + index * SIZE_OF_NODE >>> 2;
3378
+ const heap = C.HEAP32;
3379
+ heap[base] = node.id;
3380
+ heap[base + 1] = node.startIndex;
3381
+ heap[base + 2] = node.startPosition.row;
3382
+ heap[base + 3] = node.startPosition.column;
3383
+ heap[base + 4] = node[0];
3548
3384
  }
3549
3385
  __name(marshalNode, "marshalNode");
3550
3386
  function unmarshalNode(tree, address = TRANSFER_BUFFER) {
3551
- const id = C.getValue(address, "i32");
3552
- address += SIZE_OF_INT;
3387
+ const base = address >>> 2;
3388
+ const heap = C.HEAP32;
3389
+ const id = heap[base];
3553
3390
  if (id === 0) return null;
3554
- const index = C.getValue(address, "i32");
3555
- address += SIZE_OF_INT;
3556
- const row = C.getValue(address, "i32");
3557
- address += SIZE_OF_INT;
3558
- const column = C.getValue(address, "i32");
3559
- address += SIZE_OF_INT;
3560
- const other = C.getValue(address, "i32");
3561
- const result = new Node(INTERNAL, {
3391
+ const heapU32 = C.HEAPU32;
3392
+ return new Node(INTERNAL, {
3562
3393
  id,
3563
3394
  tree,
3564
- startIndex: index,
3565
- startPosition: { row, column },
3566
- other
3395
+ startIndex: heapU32[base + 1],
3396
+ startPosition: { row: heapU32[base + 2], column: heapU32[base + 3] },
3397
+ other: heap[base + 4]
3567
3398
  });
3568
- return result;
3569
3399
  }
3570
3400
  __name(unmarshalNode, "unmarshalNode");
3571
- function marshalTreeCursor({ handles }, address = TRANSFER_BUFFER) {
3572
- C.setValue(address + 0 * SIZE_OF_INT, handles[0], "i32");
3573
- C.setValue(address + 1 * SIZE_OF_INT, handles[1], "i32");
3574
- C.setValue(address + 2 * SIZE_OF_INT, handles[2], "i32");
3575
- C.setValue(address + 3 * SIZE_OF_INT, handles[3], "i32");
3576
- }
3577
- __name(marshalTreeCursor, "marshalTreeCursor");
3578
- function unmarshalTreeCursor({ handles }) {
3579
- handles[0] = C.getValue(TRANSFER_BUFFER + 0 * SIZE_OF_INT, "i32");
3580
- handles[1] = C.getValue(TRANSFER_BUFFER + 1 * SIZE_OF_INT, "i32");
3581
- handles[2] = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
3582
- handles[3] = C.getValue(TRANSFER_BUFFER + 3 * SIZE_OF_INT, "i32");
3583
- }
3584
- __name(unmarshalTreeCursor, "unmarshalTreeCursor");
3585
3401
  function marshalPoint(address, point) {
3586
- C.setValue(address, point.row, "i32");
3587
- C.setValue(address + SIZE_OF_INT, point.column, "i32");
3402
+ const base = address >>> 2;
3403
+ const heap = C.HEAP32;
3404
+ heap[base] = point.row;
3405
+ heap[base + 1] = point.column;
3588
3406
  }
3589
3407
  __name(marshalPoint, "marshalPoint");
3590
3408
  function unmarshalPoint(address) {
3591
- const result = {
3592
- row: C.getValue(address, "i32") >>> 0,
3593
- column: C.getValue(address + SIZE_OF_INT, "i32") >>> 0
3409
+ const base = address >>> 2;
3410
+ const heap = C.HEAPU32;
3411
+ return {
3412
+ row: heap[base],
3413
+ column: heap[base + 1]
3594
3414
  };
3595
- return result;
3596
3415
  }
3597
3416
  __name(unmarshalPoint, "unmarshalPoint");
3598
3417
  function marshalRange(address, range) {
3599
- marshalPoint(address, range.startPosition);
3600
- address += SIZE_OF_POINT;
3601
- marshalPoint(address, range.endPosition);
3602
- address += SIZE_OF_POINT;
3603
- C.setValue(address, range.startIndex, "i32");
3604
- address += SIZE_OF_INT;
3605
- C.setValue(address, range.endIndex, "i32");
3418
+ const base = address >>> 2;
3419
+ const heap = C.HEAP32;
3420
+ heap[base] = range.startPosition.row;
3421
+ heap[base + 1] = range.startPosition.column;
3422
+ heap[base + 2] = range.endPosition.row;
3423
+ heap[base + 3] = range.endPosition.column;
3424
+ heap[base + 4] = range.startIndex;
3425
+ heap[base + 5] = range.endIndex;
3606
3426
  }
3607
3427
  __name(marshalRange, "marshalRange");
3608
3428
  function unmarshalRange(address) {
3609
- const result = {};
3610
- result.startPosition = unmarshalPoint(address);
3611
- address += SIZE_OF_POINT;
3612
- result.endPosition = unmarshalPoint(address);
3613
- address += SIZE_OF_POINT;
3614
- result.startIndex = C.getValue(address, "i32") >>> 0;
3615
- address += SIZE_OF_INT;
3616
- result.endIndex = C.getValue(address, "i32") >>> 0;
3617
- return result;
3429
+ const base = address >>> 2;
3430
+ const heap = C.HEAPU32;
3431
+ return {
3432
+ startPosition: { row: heap[base], column: heap[base + 1] },
3433
+ endPosition: { row: heap[base + 2], column: heap[base + 3] },
3434
+ startIndex: heap[base + 4],
3435
+ endIndex: heap[base + 5]
3436
+ };
3618
3437
  }
3619
3438
  __name(unmarshalRange, "unmarshalRange");
3620
3439
  function marshalEdit(edit, address = TRANSFER_BUFFER) {
3621
- marshalPoint(address, edit.startPosition);
3622
- address += SIZE_OF_POINT;
3623
- marshalPoint(address, edit.oldEndPosition);
3624
- address += SIZE_OF_POINT;
3625
- marshalPoint(address, edit.newEndPosition);
3626
- address += SIZE_OF_POINT;
3627
- C.setValue(address, edit.startIndex, "i32");
3628
- address += SIZE_OF_INT;
3629
- C.setValue(address, edit.oldEndIndex, "i32");
3630
- address += SIZE_OF_INT;
3631
- C.setValue(address, edit.newEndIndex, "i32");
3440
+ const base = address >>> 2;
3441
+ const heap = C.HEAP32;
3442
+ heap[base] = edit.startPosition.row;
3443
+ heap[base + 1] = edit.startPosition.column;
3444
+ heap[base + 2] = edit.oldEndPosition.row;
3445
+ heap[base + 3] = edit.oldEndPosition.column;
3446
+ heap[base + 4] = edit.newEndPosition.row;
3447
+ heap[base + 5] = edit.newEndPosition.column;
3448
+ heap[base + 6] = edit.startIndex;
3449
+ heap[base + 7] = edit.oldEndIndex;
3450
+ heap[base + 8] = edit.newEndIndex;
3632
3451
  }
3633
3452
  __name(marshalEdit, "marshalEdit");
3634
3453
  function unmarshalLanguageMetadata(address) {
3635
- const major_version = C.getValue(address, "i32");
3636
- const minor_version = C.getValue(address += SIZE_OF_INT, "i32");
3637
- const patch_version = C.getValue(address + SIZE_OF_INT, "i32");
3638
- return { major_version, minor_version, patch_version };
3454
+ const base = address >>> 2;
3455
+ const heap = C.HEAP32;
3456
+ return {
3457
+ major_version: heap[base],
3458
+ minor_version: heap[base + 1],
3459
+ patch_version: heap[base + 2]
3460
+ };
3639
3461
  }
3640
3462
  __name(unmarshalLanguageMetadata, "unmarshalLanguageMetadata");
3463
+ function unmarshalSymbols() {
3464
+ const base = TRANSFER_BUFFER >>> 2;
3465
+ const count = C.HEAPU32[base];
3466
+ const buffer = C.HEAPU32[base + 1];
3467
+ const result = new Array(count);
3468
+ if (count > 0) {
3469
+ const symbolBase = buffer >>> 1;
3470
+ const heapU16 = C.HEAPU16;
3471
+ for (let i2 = 0; i2 < count; i2++) {
3472
+ result[i2] = heapU16[symbolBase + i2];
3473
+ }
3474
+ }
3475
+ return result;
3476
+ }
3477
+ __name(unmarshalSymbols, "unmarshalSymbols");
3478
+ function unmarshalRanges(useTsFree = true) {
3479
+ return unmarshalArray(SIZE_OF_RANGE, unmarshalRange, useTsFree);
3480
+ }
3481
+ __name(unmarshalRanges, "unmarshalRanges");
3482
+ function unmarshalNodeArray(tree, useTsFree = false) {
3483
+ return unmarshalArray(SIZE_OF_NODE, (address) => unmarshalNode(tree, address), useTsFree);
3484
+ }
3485
+ __name(unmarshalNodeArray, "unmarshalNodeArray");
3486
+ function unmarshalArray(stride, readItem, useTsFree) {
3487
+ const base = TRANSFER_BUFFER >>> 2;
3488
+ const count = C.HEAPU32[base];
3489
+ const buffer = C.HEAP32[base + 1];
3490
+ const result = new Array(count);
3491
+ for (let i2 = 0, address = buffer; i2 < count; i2++, address += stride) {
3492
+ result[i2] = readItem(address);
3493
+ }
3494
+ if (buffer) {
3495
+ if (useTsFree) C._ts_free_wasm(buffer);
3496
+ else C._free(buffer);
3497
+ }
3498
+ return result;
3499
+ }
3500
+ __name(unmarshalArray, "unmarshalArray");
3641
3501
 
3642
3502
  // src/language.ts
3643
3503
  var LANGUAGE_FUNCTION_REGEX = /^tree_sitter_\w+$/;
@@ -3699,7 +3559,7 @@ var Language = class {
3699
3559
  */
3700
3560
  get metadata() {
3701
3561
  C._ts_language_metadata_wasm(this[0]);
3702
- const length = C.getValue(TRANSFER_BUFFER, "i32");
3562
+ const length = C.HEAP32[TRANSFER_BUFFER >>> 2];
3703
3563
  if (length === 0) return null;
3704
3564
  return unmarshalLanguageMetadata(TRANSFER_BUFFER + SIZE_OF_INT);
3705
3565
  }
@@ -3773,34 +3633,14 @@ var Language = class {
3773
3633
  */
3774
3634
  get supertypes() {
3775
3635
  C._ts_language_supertypes_wasm(this[0]);
3776
- const count = C.getValue(TRANSFER_BUFFER, "i32");
3777
- const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
3778
- const result = new Array(count);
3779
- if (count > 0) {
3780
- let address = buffer;
3781
- for (let i2 = 0; i2 < count; i2++) {
3782
- result[i2] = C.getValue(address, "i16");
3783
- address += SIZE_OF_SHORT;
3784
- }
3785
- }
3786
- return result;
3636
+ return unmarshalSymbols();
3787
3637
  }
3788
3638
  /**
3789
3639
  * Get the subtype ids for a given supertype node id.
3790
3640
  */
3791
3641
  subtypes(supertype) {
3792
3642
  C._ts_language_subtypes_wasm(this[0], supertype);
3793
- const count = C.getValue(TRANSFER_BUFFER, "i32");
3794
- const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
3795
- const result = new Array(count);
3796
- if (count > 0) {
3797
- let address = buffer;
3798
- for (let i2 = 0; i2 < count; i2++) {
3799
- result[i2] = C.getValue(address, "i16");
3800
- address += SIZE_OF_SHORT;
3801
- }
3802
- }
3803
- return result;
3643
+ return unmarshalSymbols();
3804
3644
  }
3805
3645
  /**
3806
3646
  * Get the next state id for a given state id and node type id.
@@ -3908,8 +3748,10 @@ function checkModule() {
3908
3748
  __name(checkModule, "checkModule");
3909
3749
 
3910
3750
  // src/parser.ts
3751
+ var TWO_POW_32 = 4294967296;
3911
3752
  var TRANSFER_BUFFER;
3912
3753
  var LANGUAGE_VERSION;
3754
+ var MIN_COMPATIBLE_VERSION;
3913
3755
  function assertSupportedLanguage(language) {
3914
3756
  const version = C._ts_language_abi_version(language[0]);
3915
3757
  if (version < MIN_COMPATIBLE_VERSION || version > LANGUAGE_VERSION) {
@@ -3919,7 +3761,6 @@ function assertSupportedLanguage(language) {
3919
3761
  }
3920
3762
  }
3921
3763
  __name(assertSupportedLanguage, "assertSupportedLanguage");
3922
- var MIN_COMPATIBLE_VERSION;
3923
3764
  var finalizer4 = newFinalizer((addresses) => {
3924
3765
  C._ts_parser_delete(addresses[0]);
3925
3766
  C._free(addresses[1]);
@@ -3936,8 +3777,12 @@ var Parser = class {
3936
3777
  // Internal handle for Wasm
3937
3778
  /** @internal */
3938
3779
  logCallback = null;
3780
+ /** @internal */
3781
+ loggerEnabled = false;
3939
3782
  /** The parser's current language. */
3940
3783
  language = null;
3784
+ /** The number of parse operations executed by the most recent {@link Parser#parse} call. */
3785
+ lastParseOperations = 0;
3941
3786
  /**
3942
3787
  * This must always be called before creating a Parser.
3943
3788
  *
@@ -3948,8 +3793,9 @@ var Parser = class {
3948
3793
  static async init(options) {
3949
3794
  setModule(await initializeBinding(options));
3950
3795
  TRANSFER_BUFFER = C._ts_init();
3951
- LANGUAGE_VERSION = C.getValue(TRANSFER_BUFFER, "i32");
3952
- MIN_COMPATIBLE_VERSION = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
3796
+ const base = TRANSFER_BUFFER >>> 2;
3797
+ LANGUAGE_VERSION = C.HEAP32[base];
3798
+ MIN_COMPATIBLE_VERSION = C.HEAP32[base + 1];
3953
3799
  }
3954
3800
  /**
3955
3801
  * Create a new parser.
@@ -3964,8 +3810,10 @@ var Parser = class {
3964
3810
  throw new Error("cannot construct a Parser before calling `init()`");
3965
3811
  }
3966
3812
  C._ts_parser_new_wasm();
3967
- this[0] = C.getValue(TRANSFER_BUFFER, "i32");
3968
- this[1] = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
3813
+ const base = TRANSFER_BUFFER >>> 2;
3814
+ this[0] = C.HEAP32[base];
3815
+ this[1] = C.HEAP32[base + 1];
3816
+ this.loggerEnabled = false;
3969
3817
  }
3970
3818
  /** Delete the parser, freeing its resources. */
3971
3819
  delete() {
@@ -4014,42 +3862,84 @@ var Parser = class {
4014
3862
  * @returns {Tree | null} A {@link Tree} if parsing succeeded, or `null` if:
4015
3863
  * - The parser has not yet had a language assigned with {@link Parser#setLanguage}.
4016
3864
  * - The progress callback returned true.
4017
- * - The memory limit was reached.
3865
+ * - The memory limit was reached or the operation limit was exceeded.
4018
3866
  */
4019
3867
  parse(callback, oldTree, options) {
4020
3868
  const maxMemoryBytes = validateMemoryLimit(options?.maxMemoryBytes);
4021
- if (typeof callback === "string") {
4022
- C.currentParseCallback = (index) => callback.slice(index);
4023
- } else if (typeof callback === "function") {
4024
- C.currentParseCallback = callback;
4025
- } else {
3869
+ const maxOperations = validateOperationLimit(options?.maxOperations);
3870
+ if (typeof callback !== "string" && typeof callback !== "function") {
4026
3871
  throw new Error("Argument must be a string or a function");
4027
3872
  }
4028
- if (options?.progressCallback) {
4029
- C.currentProgressCallback = options.progressCallback;
4030
- } else {
4031
- C.currentProgressCallback = null;
3873
+ const progressCallback = options?.progressCallback ?? null;
3874
+ C.currentParseCallback = callback;
3875
+ C.currentProgressCallback = progressCallback;
3876
+ this.syncLogger();
3877
+ this.lastParseOperations = 0;
3878
+ try {
3879
+ const treeAddress = this.runParse(oldTree, options, maxMemoryBytes, maxOperations);
3880
+ if (!treeAddress) return null;
3881
+ if (!this.language) throw new Error("Parser must have a language to parse");
3882
+ return new Tree2(INTERNAL, treeAddress, this.language, callback);
3883
+ } finally {
3884
+ clearCallbacks();
4032
3885
  }
3886
+ }
3887
+ /** @internal */
3888
+ syncLogger() {
4033
3889
  if (this.logCallback) {
4034
3890
  C.currentLogCallback = this.logCallback;
4035
- C._ts_parser_enable_logger_wasm(this[0], 1);
3891
+ if (!this.loggerEnabled) {
3892
+ C._ts_parser_enable_logger_wasm(this[0], 1);
3893
+ this.loggerEnabled = true;
3894
+ }
4036
3895
  } else {
4037
3896
  C.currentLogCallback = null;
4038
- C._ts_parser_enable_logger_wasm(this[0], 0);
3897
+ if (this.loggerEnabled) {
3898
+ C._ts_parser_enable_logger_wasm(this[0], 0);
3899
+ this.loggerEnabled = false;
3900
+ }
3901
+ }
3902
+ }
3903
+ /** @internal */
3904
+ runParse(oldTree, options, maxMemoryBytes, maxOperations) {
3905
+ if (maxMemoryBytes !== void 0 && !C.treeSitterSetMemoryLimit(maxMemoryBytes)) {
3906
+ return 0;
4039
3907
  }
4040
3908
  try {
4041
- const treeAddress = maxMemoryBytes === void 0 ? parseOrdinaryWasm(this[0], this[1], oldTree ? oldTree[0] : 0, options?.includedRanges) : parseLimitedWasm(this[0], this[1], options?.includedRanges, maxMemoryBytes);
4042
- if (!treeAddress) return null;
4043
- if (!this.language) throw new Error("Parser must have a language to parse");
4044
- return new Tree(INTERNAL, treeAddress, this.language, C.currentParseCallback);
3909
+ const [rangeAddress, rangeCount] = prepareRanges(options?.includedRanges);
3910
+ if (rangeCount && !rangeAddress) return 0;
3911
+ marshalParseInputs(maxOperations, rangeAddress, rangeCount, options?.progressCallback ? 1 : 0);
3912
+ try {
3913
+ return maxMemoryBytes === void 0 ? this.executeOrdinaryParse(oldTree ? oldTree[0] : 0) : this.executeLimitedParse();
3914
+ } finally {
3915
+ this.lastParseOperations = unmarshalOperationCount();
3916
+ }
4045
3917
  } finally {
4046
- clearCallbacks();
3918
+ if (maxMemoryBytes !== void 0) C.treeSitterSetMemoryLimit(0);
3919
+ }
3920
+ }
3921
+ /** @internal */
3922
+ executeOrdinaryParse(oldTreeAddress) {
3923
+ try {
3924
+ return C._ts_parser_parse_wasm(this[0], this[1], oldTreeAddress);
3925
+ } catch (error) {
3926
+ C._ts_parser_last_parse_operations_wasm(this[0]);
3927
+ throw error;
3928
+ }
3929
+ }
3930
+ /** @internal */
3931
+ executeLimitedParse() {
3932
+ try {
3933
+ return C._ts_parser_parse_limited_wasm(this[0], this[1]);
3934
+ } catch (error) {
3935
+ C._ts_parser_abort_limited_wasm();
3936
+ throw error;
4047
3937
  }
4048
3938
  }
4049
3939
  /**
4050
3940
  * Instruct the parser to start the next parse from the beginning.
4051
3941
  *
4052
- * If the parser previously failed because of a callback,
3942
+ * If the parser previously failed because of a callback,
4053
3943
  * then by default, it will resume where it left off on the
4054
3944
  * next call to {@link Parser#parse} or other parsing functions.
4055
3945
  * If you don't want to resume, and instead intend to use this parser to
@@ -4061,18 +3951,7 @@ var Parser = class {
4061
3951
  /** Get the ranges of text that the parser will include when parsing. */
4062
3952
  getIncludedRanges() {
4063
3953
  C._ts_parser_included_ranges_wasm(this[0]);
4064
- const count = C.getValue(TRANSFER_BUFFER, "i32");
4065
- const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
4066
- const result = new Array(count);
4067
- if (count > 0) {
4068
- let address = buffer;
4069
- for (let i2 = 0; i2 < count; i2++) {
4070
- result[i2] = unmarshalRange(address);
4071
- address += SIZE_OF_RANGE;
4072
- }
4073
- C._free(buffer);
4074
- }
4075
- return result;
3954
+ return unmarshalRanges(false);
4076
3955
  }
4077
3956
  /** Set the logging callback that a parser should use during parsing. */
4078
3957
  setLogger(callback) {
@@ -4097,43 +3976,46 @@ function validateMemoryLimit(maxMemoryBytes) {
4097
3976
  return maxMemoryBytes;
4098
3977
  }
4099
3978
  __name(validateMemoryLimit, "validateMemoryLimit");
3979
+ function validateOperationLimit(maxOperations) {
3980
+ if (maxOperations !== void 0 && (!Number.isSafeInteger(maxOperations) || maxOperations <= 0)) {
3981
+ throw new RangeError("maxOperations must be a positive safe integer");
3982
+ }
3983
+ return maxOperations;
3984
+ }
3985
+ __name(validateOperationLimit, "validateOperationLimit");
4100
3986
  function prepareRanges(ranges) {
4101
3987
  if (!ranges?.length) return [0, 0];
4102
3988
  const rangeAddress = C._calloc(ranges.length, SIZE_OF_RANGE);
4103
3989
  if (!rangeAddress) return [0, ranges.length];
4104
- let address = rangeAddress;
4105
- for (const range of ranges) {
4106
- marshalRange(address, range);
4107
- address += SIZE_OF_RANGE;
3990
+ try {
3991
+ let address = rangeAddress;
3992
+ for (const range of ranges) {
3993
+ marshalRange(address, range);
3994
+ address += SIZE_OF_RANGE;
3995
+ }
3996
+ return [rangeAddress, ranges.length];
3997
+ } catch (error) {
3998
+ C._free(rangeAddress);
3999
+ throw error;
4108
4000
  }
4109
- return [rangeAddress, ranges.length];
4110
4001
  }
4111
4002
  __name(prepareRanges, "prepareRanges");
4112
- function parseOrdinaryWasm(parserAddress, inputBuffer, oldTreeAddress, ranges) {
4113
- const [rangeAddress, rangeCount] = prepareRanges(ranges);
4114
- if (rangeCount && !rangeAddress) return 0;
4115
- return C._ts_parser_parse_wasm(parserAddress, inputBuffer, oldTreeAddress, rangeAddress, rangeCount);
4003
+ function marshalParseInputs(maxOperations, rangeAddress, rangeCount, hasProgressCallback) {
4004
+ const base = TRANSFER_BUFFER >>> 2;
4005
+ const heapU32 = C.HEAPU32;
4006
+ heapU32[base] = maxOperations === void 0 ? 0 : maxOperations >>> 0;
4007
+ heapU32[base + 1] = maxOperations === void 0 ? 0 : Math.floor(maxOperations / TWO_POW_32) >>> 0;
4008
+ heapU32[base + 2] = rangeAddress;
4009
+ heapU32[base + 3] = rangeCount;
4010
+ heapU32[base + 4] = hasProgressCallback;
4116
4011
  }
4117
- __name(parseOrdinaryWasm, "parseOrdinaryWasm");
4118
- function parseLimitedWasm(parserAddress, inputBuffer, ranges, maxMemoryBytes) {
4119
- if (!C.treeSitterSetMemoryLimit(maxMemoryBytes)) return 0;
4120
- let rangeAddress = 0;
4121
- try {
4122
- const [address, rangeCount] = prepareRanges(ranges);
4123
- rangeAddress = address;
4124
- if (rangeCount && !address) return 0;
4125
- try {
4126
- return C._ts_parser_parse_limited_wasm(parserAddress, inputBuffer, address, rangeCount);
4127
- } catch (error) {
4128
- C._ts_parser_abort_limited_wasm();
4129
- throw error;
4130
- }
4131
- } finally {
4132
- if (rangeAddress) C._free(rangeAddress);
4133
- C.treeSitterSetMemoryLimit(0);
4134
- }
4012
+ __name(marshalParseInputs, "marshalParseInputs");
4013
+ function unmarshalOperationCount() {
4014
+ const base = TRANSFER_BUFFER >>> 2;
4015
+ const heapU32 = C.HEAPU32;
4016
+ return heapU32[base] + heapU32[base + 1] * TWO_POW_32;
4135
4017
  }
4136
- __name(parseLimitedWasm, "parseLimitedWasm");
4018
+ __name(unmarshalOperationCount, "unmarshalOperationCount");
4137
4019
  function clearCallbacks() {
4138
4020
  C.currentParseCallback = null;
4139
4021
  C.currentLogCallback = null;