@willbooster/web-tree-sitter 19.1.0 → 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.
@@ -286,21 +286,21 @@ var TreeCursor = class _TreeCursor {
286
286
  }
287
287
  /** Get the field name of this tree cursor's current node. */
288
288
  get currentFieldName() {
289
- return this.tree.language.fields[this._fieldId];
289
+ return this.tree.language.fields[this._fieldId] ?? null;
290
290
  }
291
291
  /**
292
292
  * Get the depth of the cursor's current node relative to the original
293
293
  * node that the cursor was constructed with.
294
294
  */
295
295
  get currentDepth() {
296
- return C._ts_tree_cursor_current_depth_wasm(this[0]);
296
+ return C._ts_tree_cursor_current_depth(this[0]) >>> 0;
297
297
  }
298
298
  /**
299
299
  * Get the index of the cursor's current node out of all of the
300
300
  * descendants of the original node that the cursor was constructed with.
301
301
  */
302
302
  get currentDescendantIndex() {
303
- return C._ts_tree_cursor_current_descendant_index_wasm(this[0]);
303
+ return C._ts_tree_cursor_current_descendant_index(this[0]) >>> 0;
304
304
  }
305
305
  /** Get the type of the cursor's current node. */
306
306
  get nodeType() {
@@ -339,7 +339,8 @@ var TreeCursor = class _TreeCursor {
339
339
  /** Get the string content of the cursor's current node. */
340
340
  get nodeText() {
341
341
  this.syncIndices();
342
- return getText(this.tree, this._startIndex, this._endIndex, () => this.startPosition);
342
+ const { textSource } = this.tree;
343
+ return typeof textSource === "string" ? textSource.slice(this._startIndex, this._endIndex) : getCallbackText(textSource, this._startIndex, this._endIndex, this.startPosition);
343
344
  }
344
345
  /** Get the start position of the cursor's current node. */
345
346
  get startPosition() {
@@ -463,8 +464,13 @@ var TreeCursor = class _TreeCursor {
463
464
  * `false` if no such child was found.
464
465
  */
465
466
  gotoFirstChildForPosition(goalPosition) {
466
- marshalPoint(TRANSFER_BUFFER, goalPosition);
467
- if (!C._ts_tree_cursor_goto_first_child_for_position_wasm(this[0])) return false;
467
+ if (!C._ts_tree_cursor_goto_first_child_for_position_wasm(
468
+ this[0],
469
+ goalPosition.row,
470
+ goalPosition.column
471
+ )) {
472
+ return false;
473
+ }
468
474
  this.readNodeCache();
469
475
  return true;
470
476
  }
@@ -485,7 +491,7 @@ var TreeCursor = class _TreeCursor {
485
491
  * information and allows reusing already created cursors.
486
492
  */
487
493
  resetTo(cursor) {
488
- if (cursor === this) return;
494
+ if (this[0] === cursor[0]) return;
489
495
  this.tree = cursor.tree;
490
496
  C._ts_tree_cursor_reset_to_wasm(this[0], cursor[0]);
491
497
  this.readNodeCache();
@@ -512,17 +518,13 @@ var TreeCursor = class _TreeCursor {
512
518
  };
513
519
 
514
520
  // src/tree.ts
515
- function getText(tree, startIndex, endIndex, getStartPosition) {
516
- if (tree.sourceText !== void 0) {
517
- return tree.sourceText.slice(startIndex, endIndex);
518
- }
519
- const startPosition = getStartPosition();
521
+ function getCallbackText(textSource, startIndex, endIndex, startPosition) {
520
522
  const length = endIndex - startIndex;
521
- let result = tree.textCallback(startIndex, startPosition);
523
+ let result = textSource(startIndex, startPosition);
522
524
  if (result) {
523
525
  startIndex += result.length;
524
526
  while (startIndex < endIndex) {
525
- const string = tree.textCallback(startIndex, startPosition);
527
+ const string = textSource(startIndex, startPosition);
526
528
  if (string && string.length > 0) {
527
529
  startIndex += string.length;
528
530
  result += string;
@@ -536,7 +538,7 @@ function getText(tree, startIndex, endIndex, getStartPosition) {
536
538
  }
537
539
  return result ?? "";
538
540
  }
539
- __name(getText, "getText");
541
+ __name(getCallbackText, "getCallbackText");
540
542
  var finalizer3 = newFinalizer((address) => {
541
543
  C._ts_tree_delete(address);
542
544
  });
@@ -548,26 +550,23 @@ var Tree2 = class _Tree {
548
550
  [0] = 0;
549
551
  // Internal handle for Wasm
550
552
  /** @internal */
551
- textCallback;
552
- /** @internal */
553
- sourceText;
553
+ textSource;
554
554
  /** @internal */
555
555
  editVersion = 0;
556
556
  /** The language that was used to parse the syntax tree. */
557
557
  language;
558
558
  /** @internal */
559
- constructor(internal, address, language, textCallback, sourceText) {
559
+ constructor(internal, address, language, textSource) {
560
560
  assertInternal(internal);
561
561
  this[0] = address;
562
562
  this.language = language;
563
- this.textCallback = textCallback;
564
- this.sourceText = sourceText;
563
+ this.textSource = textSource;
565
564
  finalizer3?.register(this, address, this);
566
565
  }
567
566
  /** Create a shallow copy of the syntax tree. This is very fast. */
568
567
  copy() {
569
568
  const address = C._ts_tree_copy(this[0]);
570
- return new _Tree(INTERNAL, address, this.language, this.textCallback, this.sourceText);
569
+ return new _Tree(INTERNAL, address, this.language, this.textSource);
571
570
  }
572
571
  /** Delete the syntax tree, freeing its resources. */
573
572
  delete() {
@@ -771,7 +770,8 @@ var Node = class {
771
770
  }
772
771
  /** Get the string content of this node. */
773
772
  get text() {
774
- return getText(this.tree, this.startIndex, this.endIndex, () => this.startPosition);
773
+ const { textSource } = this.tree;
774
+ return typeof textSource === "string" ? textSource.slice(this.startIndex, this.endIndex) : getCallbackText(textSource, this.startIndex, this.endIndex, this.startPosition);
775
775
  }
776
776
  /** Get this node's parse state. */
777
777
  get parseState() {
@@ -969,21 +969,21 @@ var Node = class {
969
969
  symbols.push(65535);
970
970
  }
971
971
  const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length);
972
+ const symbolsHeap = C.HEAPU32;
972
973
  const symbolsBase = symbolsAddress >>> 2;
973
974
  for (let i2 = 0, n = symbols.length; i2 < n; i2++) {
974
- C.HEAPU32[symbolsBase + i2] = symbols[i2];
975
+ symbolsHeap[symbolsBase + i2] = symbols[i2];
975
976
  }
976
977
  marshalNode(this);
978
+ const pointAddress = TRANSFER_BUFFER + SIZE_OF_NODE;
979
+ marshalPoint(pointAddress, startPosition);
980
+ marshalPoint(pointAddress + SIZE_OF_POINT, endPosition);
977
981
  C._ts_node_descendants_of_type_wasm(
978
982
  this.tree[0],
979
983
  symbolsAddress,
980
- symbols.length,
981
- startPosition.row,
982
- startPosition.column,
983
- endPosition.row,
984
- endPosition.column
984
+ symbols.length
985
985
  );
986
- const result = unmarshalNodeArray(this.tree, true, true);
986
+ const result = unmarshalNodeArray(this.tree, true);
987
987
  C._free(symbolsAddress);
988
988
  return result;
989
989
  }
@@ -1052,8 +1052,9 @@ var Node = class {
1052
1052
  }
1053
1053
  marshalNode(this);
1054
1054
  const base = TRANSFER_BUFFER + SIZE_OF_NODE >>> 2;
1055
- C.HEAP32[base] = start2;
1056
- C.HEAP32[base + 1] = end;
1055
+ const heap = C.HEAP32;
1056
+ heap[base] = start2;
1057
+ heap[base + 1] = end;
1057
1058
  C._ts_node_descendant_for_index_wasm(this.tree[0]);
1058
1059
  return unmarshalNode(this.tree);
1059
1060
  }
@@ -1064,8 +1065,9 @@ var Node = class {
1064
1065
  }
1065
1066
  marshalNode(this);
1066
1067
  const base = TRANSFER_BUFFER + SIZE_OF_NODE >>> 2;
1067
- C.HEAP32[base] = start2;
1068
- C.HEAP32[base + 1] = end;
1068
+ const heap = C.HEAP32;
1069
+ heap[base] = start2;
1070
+ heap[base + 1] = end;
1069
1071
  C._ts_node_named_descendant_for_index_wasm(this.tree[0]);
1070
1072
  return unmarshalNode(this.tree);
1071
1073
  }
@@ -1193,16 +1195,17 @@ function unmarshalRange(address) {
1193
1195
  }
1194
1196
  __name(unmarshalRange, "unmarshalRange");
1195
1197
  function marshalEdit(edit, address = TRANSFER_BUFFER) {
1196
- marshalPoint(address, edit.startPosition);
1197
- address += SIZE_OF_POINT;
1198
- marshalPoint(address, edit.oldEndPosition);
1199
- address += SIZE_OF_POINT;
1200
- marshalPoint(address, edit.newEndPosition);
1201
- const base = address + SIZE_OF_POINT >>> 2;
1198
+ const base = address >>> 2;
1202
1199
  const heap = C.HEAP32;
1203
- heap[base] = edit.startIndex;
1204
- heap[base + 1] = edit.oldEndIndex;
1205
- heap[base + 2] = edit.newEndIndex;
1200
+ heap[base] = edit.startPosition.row;
1201
+ heap[base + 1] = edit.startPosition.column;
1202
+ heap[base + 2] = edit.oldEndPosition.row;
1203
+ heap[base + 3] = edit.oldEndPosition.column;
1204
+ heap[base + 4] = edit.newEndPosition.row;
1205
+ heap[base + 5] = edit.newEndPosition.column;
1206
+ heap[base + 6] = edit.startIndex;
1207
+ heap[base + 7] = edit.oldEndIndex;
1208
+ heap[base + 8] = edit.newEndIndex;
1206
1209
  }
1207
1210
  __name(marshalEdit, "marshalEdit");
1208
1211
  function unmarshalLanguageMetadata(address) {
@@ -1231,14 +1234,14 @@ function unmarshalSymbols() {
1231
1234
  }
1232
1235
  __name(unmarshalSymbols, "unmarshalSymbols");
1233
1236
  function unmarshalRanges(useTsFree = true) {
1234
- return unmarshalArray(SIZE_OF_RANGE, unmarshalRange, useTsFree, false);
1237
+ return unmarshalArray(SIZE_OF_RANGE, unmarshalRange, useTsFree);
1235
1238
  }
1236
1239
  __name(unmarshalRanges, "unmarshalRanges");
1237
- function unmarshalNodeArray(tree, useTsFree = false, alwaysFree = false) {
1238
- return unmarshalArray(SIZE_OF_NODE, (address) => unmarshalNode(tree, address), useTsFree, alwaysFree);
1240
+ function unmarshalNodeArray(tree, useTsFree = false) {
1241
+ return unmarshalArray(SIZE_OF_NODE, (address) => unmarshalNode(tree, address), useTsFree);
1239
1242
  }
1240
1243
  __name(unmarshalNodeArray, "unmarshalNodeArray");
1241
- function unmarshalArray(stride, readItem, useTsFree, alwaysFree) {
1244
+ function unmarshalArray(stride, readItem, useTsFree) {
1242
1245
  const base = TRANSFER_BUFFER >>> 2;
1243
1246
  const count = C.HEAPU32[base];
1244
1247
  const buffer = C.HEAP32[base + 1];
@@ -1246,7 +1249,7 @@ function unmarshalArray(stride, readItem, useTsFree, alwaysFree) {
1246
1249
  for (let i2 = 0, address = buffer; i2 < count; i2++, address += stride) {
1247
1250
  result[i2] = readItem(address);
1248
1251
  }
1249
- if (count > 0 || alwaysFree) {
1252
+ if (buffer) {
1250
1253
  if (useTsFree) C._ts_free_wasm(buffer);
1251
1254
  else C._free(buffer);
1252
1255
  }
@@ -1747,7 +1750,7 @@ async function Module2(moduleArg = {}) {
1747
1750
  var b = wasmMemory.buffer;
1748
1751
  HEAP8 = new Int8Array(b);
1749
1752
  HEAP16 = new Int16Array(b);
1750
- Module["HEAPU8"] = HEAPU8 = new Uint8Array(b);
1753
+ HEAPU8 = new Uint8Array(b);
1751
1754
  Module["HEAPU16"] = HEAPU16 = new Uint16Array(b);
1752
1755
  Module["HEAP32"] = HEAP32 = new Int32Array(b);
1753
1756
  Module["HEAPU32"] = HEAPU32 = new Uint32Array(b);
@@ -2856,8 +2859,6 @@ async function Module2(moduleArg = {}) {
2856
2859
  "value": "i32",
2857
2860
  "mutable": false
2858
2861
  }, 1);
2859
- var __abort_js = /* @__PURE__ */ __name(() => abort("native code called abort()"), "__abort_js");
2860
- __abort_js.sig = "v";
2861
2862
  var __emscripten_throw_longjmp = /* @__PURE__ */ __name(() => {
2862
2863
  throw Infinity;
2863
2864
  }, "__emscripten_throw_longjmp");
@@ -2960,18 +2961,29 @@ async function Module2(moduleArg = {}) {
2960
2961
  }
2961
2962
  }
2962
2963
  __name(_tree_sitter_log_callback, "_tree_sitter_log_callback");
2963
- function _tree_sitter_parse_callback(inputBufferAddress, index, row, column, lengthAddress) {
2964
- const INPUT_BUFFER_SIZE = 10 * 1024;
2965
- const string = Module.currentParseCallback(index, {
2964
+ function _tree_sitter_parse_callback(inputBufferAddress, maxCodeUnits, index, row, column, lengthAddress) {
2965
+ const source = Module.currentParseCallback;
2966
+ const isString = typeof source === "string";
2967
+ const chunk = isString ? source : source(index, {
2966
2968
  row,
2967
2969
  column
2968
2970
  });
2969
- if (typeof string === "string") {
2970
- HEAP32[SAFE_HEAP_INDEX(HEAP32, lengthAddress >> 2, "storing")] = string.length;
2971
- stringToUTF16(string, inputBufferAddress, INPUT_BUFFER_SIZE);
2972
- } else {
2973
- HEAP32[SAFE_HEAP_INDEX(HEAP32, lengthAddress >> 2, "storing")] = 0;
2971
+ const offset = isString ? index : 0;
2972
+ const remaining = typeof chunk === "string" ? chunk.length - offset : 0;
2973
+ if (remaining <= 0) {
2974
+ HEAP32[SAFE_HEAP_INDEX(HEAP32, lengthAddress >>> 2, "storing")] = 0;
2975
+ return;
2974
2976
  }
2977
+ let count = remaining < maxCodeUnits ? remaining : maxCodeUnits;
2978
+ if (count < remaining && count > 1) {
2979
+ const last = chunk.charCodeAt(offset + count - 1);
2980
+ if (last >= 55296 && last <= 56319) count--;
2981
+ }
2982
+ const base = inputBufferAddress >>> 1;
2983
+ for (let i2 = 0; i2 < count; i2++) {
2984
+ HEAPU16[SAFE_HEAP_INDEX(HEAPU16, base + i2, "storing")] = chunk.charCodeAt(offset + i2);
2985
+ }
2986
+ HEAP32[SAFE_HEAP_INDEX(HEAP32, lengthAddress >>> 2, "storing")] = count;
2975
2987
  }
2976
2988
  __name(_tree_sitter_parse_callback, "_tree_sitter_parse_callback");
2977
2989
  function _tree_sitter_progress_callback(currentOffset, hasError) {
@@ -3085,22 +3097,6 @@ async function Module2(moduleArg = {}) {
3085
3097
  str += String.fromCharCode(ch);
3086
3098
  }
3087
3099
  }, "AsciiToString");
3088
- var stringToUTF16 = /* @__PURE__ */ __name((str, outPtr, maxBytesToWrite) => {
3089
- assert(outPtr % 2 == 0, "Pointer passed to stringToUTF16 must be aligned to two bytes!");
3090
- assert(typeof maxBytesToWrite == "number", "stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!");
3091
- maxBytesToWrite ??= 2147483647;
3092
- if (maxBytesToWrite < 2) return 0;
3093
- maxBytesToWrite -= 2;
3094
- var startPtr = outPtr;
3095
- var numCharsToWrite = maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length;
3096
- for (var i2 = 0; i2 < numCharsToWrite; ++i2) {
3097
- var codeUnit = str.charCodeAt(i2);
3098
- HEAP16[SAFE_HEAP_INDEX(HEAP16, outPtr >> 1, "storing")] = codeUnit;
3099
- outPtr += 2;
3100
- }
3101
- HEAP16[SAFE_HEAP_INDEX(HEAP16, outPtr >> 1, "storing")] = 0;
3102
- return outPtr - startPtr;
3103
- }, "stringToUTF16");
3104
3100
  {
3105
3101
  initMemory();
3106
3102
  if (Module["noExitRuntime"]) noExitRuntime = Module["noExitRuntime"];
@@ -3136,11 +3132,10 @@ async function Module2(moduleArg = {}) {
3136
3132
  Module["stringToUTF8"] = stringToUTF8;
3137
3133
  Module["lengthBytesUTF8"] = lengthBytesUTF8;
3138
3134
  Module["AsciiToString"] = AsciiToString;
3139
- Module["stringToUTF16"] = stringToUTF16;
3140
3135
  Module["loadWebAssemblyModule"] = loadWebAssemblyModule;
3141
- 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"];
3136
+ 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"];
3142
3137
  missingLibrarySymbols.forEach(missingLibrarySymbol);
3143
- var unexportedSymbols = ["run", "out", "err", "callMain", "abort", "wasmMemory", "wasmExports", "HEAPF32", "HEAPF64", "HEAP8", "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"];
3138
+ 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"];
3144
3139
  unexportedSymbols.forEach(unexportedRuntimeSymbol);
3145
3140
  function checkIncomingModuleAPI() {
3146
3141
  ignoredModuleProp("fetchSettings");
@@ -3151,7 +3146,6 @@ async function Module2(moduleArg = {}) {
3151
3146
  var _calloc = Module["_calloc"] = makeInvalidEarlyAccess("_calloc");
3152
3147
  var _realloc = Module["_realloc"] = makeInvalidEarlyAccess("_realloc");
3153
3148
  var _free = Module["_free"] = makeInvalidEarlyAccess("_free");
3154
- var _ts_range_edit = Module["_ts_range_edit"] = makeInvalidEarlyAccess("_ts_range_edit");
3155
3149
  var _ts_language_symbol_count = Module["_ts_language_symbol_count"] = makeInvalidEarlyAccess("_ts_language_symbol_count");
3156
3150
  var _ts_language_state_count = Module["_ts_language_state_count"] = makeInvalidEarlyAccess("_ts_language_state_count");
3157
3151
  var _ts_language_abi_version = Module["_ts_language_abi_version"] = makeInvalidEarlyAccess("_ts_language_abi_version");
@@ -3169,12 +3163,12 @@ async function Module2(moduleArg = {}) {
3169
3163
  var _ts_lookahead_iterator_reset = Module["_ts_lookahead_iterator_reset"] = makeInvalidEarlyAccess("_ts_lookahead_iterator_reset");
3170
3164
  var _ts_lookahead_iterator_next = Module["_ts_lookahead_iterator_next"] = makeInvalidEarlyAccess("_ts_lookahead_iterator_next");
3171
3165
  var _ts_lookahead_iterator_current_symbol = Module["_ts_lookahead_iterator_current_symbol"] = makeInvalidEarlyAccess("_ts_lookahead_iterator_current_symbol");
3172
- var _ts_point_edit = Module["_ts_point_edit"] = makeInvalidEarlyAccess("_ts_point_edit");
3173
3166
  var _ts_parser_delete = Module["_ts_parser_delete"] = makeInvalidEarlyAccess("_ts_parser_delete");
3174
3167
  var _ts_parser_set_language = Module["_ts_parser_set_language"] = makeInvalidEarlyAccess("_ts_parser_set_language");
3175
3168
  var _ts_parser_reset = Module["_ts_parser_reset"] = makeInvalidEarlyAccess("_ts_parser_reset");
3176
- var _ts_parser_set_included_ranges = Module["_ts_parser_set_included_ranges"] = makeInvalidEarlyAccess("_ts_parser_set_included_ranges");
3177
3169
  var _memcmp = Module["_memcmp"] = makeInvalidEarlyAccess("_memcmp");
3170
+ var _ts_tree_cursor_current_descendant_index = Module["_ts_tree_cursor_current_descendant_index"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_descendant_index");
3171
+ var _ts_tree_cursor_current_depth = Module["_ts_tree_cursor_current_depth"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_depth");
3178
3172
  var _ts_tree_copy = Module["_ts_tree_copy"] = makeInvalidEarlyAccess("_ts_tree_copy");
3179
3173
  var _ts_tree_delete = Module["_ts_tree_delete"] = makeInvalidEarlyAccess("_ts_tree_delete");
3180
3174
  var _ts_init = Module["_ts_init"] = makeInvalidEarlyAccess("_ts_init");
@@ -3218,8 +3212,6 @@ async function Module2(moduleArg = {}) {
3218
3212
  var _ts_tree_cursor_end_position_wasm = Module["_ts_tree_cursor_end_position_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_end_position_wasm");
3219
3213
  var _ts_tree_cursor_start_index_wasm = Module["_ts_tree_cursor_start_index_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_start_index_wasm");
3220
3214
  var _ts_tree_cursor_end_index_wasm = Module["_ts_tree_cursor_end_index_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_end_index_wasm");
3221
- var _ts_tree_cursor_current_depth_wasm = Module["_ts_tree_cursor_current_depth_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_depth_wasm");
3222
- var _ts_tree_cursor_current_descendant_index_wasm = Module["_ts_tree_cursor_current_descendant_index_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_descendant_index_wasm");
3223
3215
  var _ts_tree_cursor_current_node_wasm = Module["_ts_tree_cursor_current_node_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_node_wasm");
3224
3216
  var _ts_node_symbol_wasm = Module["_ts_node_symbol_wasm"] = makeInvalidEarlyAccess("_ts_node_symbol_wasm");
3225
3217
  var _ts_node_field_name_for_child_wasm = Module["_ts_node_field_name_for_child_wasm"] = makeInvalidEarlyAccess("_ts_node_field_name_for_child_wasm");
@@ -3244,9 +3236,7 @@ async function Module2(moduleArg = {}) {
3244
3236
  var _ts_node_named_descendant_for_index_wasm = Module["_ts_node_named_descendant_for_index_wasm"] = makeInvalidEarlyAccess("_ts_node_named_descendant_for_index_wasm");
3245
3237
  var _ts_node_descendant_for_position_wasm = Module["_ts_node_descendant_for_position_wasm"] = makeInvalidEarlyAccess("_ts_node_descendant_for_position_wasm");
3246
3238
  var _ts_node_named_descendant_for_position_wasm = Module["_ts_node_named_descendant_for_position_wasm"] = makeInvalidEarlyAccess("_ts_node_named_descendant_for_position_wasm");
3247
- var _ts_node_start_point_wasm = Module["_ts_node_start_point_wasm"] = makeInvalidEarlyAccess("_ts_node_start_point_wasm");
3248
3239
  var _ts_node_end_point_wasm = Module["_ts_node_end_point_wasm"] = makeInvalidEarlyAccess("_ts_node_end_point_wasm");
3249
- var _ts_node_start_index_wasm = Module["_ts_node_start_index_wasm"] = makeInvalidEarlyAccess("_ts_node_start_index_wasm");
3250
3240
  var _ts_node_end_index_wasm = Module["_ts_node_end_index_wasm"] = makeInvalidEarlyAccess("_ts_node_end_index_wasm");
3251
3241
  var _ts_node_to_string_wasm = Module["_ts_node_to_string_wasm"] = makeInvalidEarlyAccess("_ts_node_to_string_wasm");
3252
3242
  var _ts_node_children_wasm = Module["_ts_node_children_wasm"] = makeInvalidEarlyAccess("_ts_node_children_wasm");
@@ -3260,9 +3250,9 @@ async function Module2(moduleArg = {}) {
3260
3250
  var _ts_node_is_extra_wasm = Module["_ts_node_is_extra_wasm"] = makeInvalidEarlyAccess("_ts_node_is_extra_wasm");
3261
3251
  var _ts_node_parse_state_wasm = Module["_ts_node_parse_state_wasm"] = makeInvalidEarlyAccess("_ts_node_parse_state_wasm");
3262
3252
  var _ts_node_next_parse_state_wasm = Module["_ts_node_next_parse_state_wasm"] = makeInvalidEarlyAccess("_ts_node_next_parse_state_wasm");
3263
- var _memset = Module["_memset"] = makeInvalidEarlyAccess("_memset");
3264
3253
  var _memcpy = Module["_memcpy"] = makeInvalidEarlyAccess("_memcpy");
3265
3254
  var _memmove = Module["_memmove"] = makeInvalidEarlyAccess("_memmove");
3255
+ var _memset = Module["_memset"] = makeInvalidEarlyAccess("_memset");
3266
3256
  var _fflush = makeInvalidEarlyAccess("_fflush");
3267
3257
  var _strlen = Module["_strlen"] = makeInvalidEarlyAccess("_strlen");
3268
3258
  var _iswalnum = Module["_iswalnum"] = makeInvalidEarlyAccess("_iswalnum");
@@ -3296,7 +3286,6 @@ async function Module2(moduleArg = {}) {
3296
3286
  Module["_calloc"] = _calloc = createExportWrapper("calloc", 2);
3297
3287
  Module["_realloc"] = _realloc = createExportWrapper("realloc", 2);
3298
3288
  Module["_free"] = _free = createExportWrapper("free", 1);
3299
- Module["_ts_range_edit"] = _ts_range_edit = createExportWrapper("ts_range_edit", 2);
3300
3289
  Module["_ts_language_symbol_count"] = _ts_language_symbol_count = createExportWrapper("ts_language_symbol_count", 1);
3301
3290
  Module["_ts_language_state_count"] = _ts_language_state_count = createExportWrapper("ts_language_state_count", 1);
3302
3291
  Module["_ts_language_abi_version"] = _ts_language_abi_version = createExportWrapper("ts_language_abi_version", 1);
@@ -3314,12 +3303,12 @@ async function Module2(moduleArg = {}) {
3314
3303
  Module["_ts_lookahead_iterator_reset"] = _ts_lookahead_iterator_reset = createExportWrapper("ts_lookahead_iterator_reset", 3);
3315
3304
  Module["_ts_lookahead_iterator_next"] = _ts_lookahead_iterator_next = createExportWrapper("ts_lookahead_iterator_next", 1);
3316
3305
  Module["_ts_lookahead_iterator_current_symbol"] = _ts_lookahead_iterator_current_symbol = createExportWrapper("ts_lookahead_iterator_current_symbol", 1);
3317
- Module["_ts_point_edit"] = _ts_point_edit = createExportWrapper("ts_point_edit", 3);
3318
3306
  Module["_ts_parser_delete"] = _ts_parser_delete = createExportWrapper("ts_parser_delete", 1);
3319
3307
  Module["_ts_parser_set_language"] = _ts_parser_set_language = createExportWrapper("ts_parser_set_language", 2);
3320
3308
  Module["_ts_parser_reset"] = _ts_parser_reset = createExportWrapper("ts_parser_reset", 1);
3321
- Module["_ts_parser_set_included_ranges"] = _ts_parser_set_included_ranges = createExportWrapper("ts_parser_set_included_ranges", 3);
3322
3309
  Module["_memcmp"] = _memcmp = createExportWrapper("memcmp", 3);
3310
+ Module["_ts_tree_cursor_current_descendant_index"] = _ts_tree_cursor_current_descendant_index = createExportWrapper("ts_tree_cursor_current_descendant_index", 1);
3311
+ Module["_ts_tree_cursor_current_depth"] = _ts_tree_cursor_current_depth = createExportWrapper("ts_tree_cursor_current_depth", 1);
3323
3312
  Module["_ts_tree_copy"] = _ts_tree_copy = createExportWrapper("ts_tree_copy", 1);
3324
3313
  Module["_ts_tree_delete"] = _ts_tree_delete = createExportWrapper("ts_tree_delete", 1);
3325
3314
  Module["_ts_init"] = _ts_init = createExportWrapper("ts_init", 0);
@@ -3352,7 +3341,7 @@ async function Module2(moduleArg = {}) {
3352
3341
  Module["_ts_tree_cursor_goto_first_child_wasm"] = _ts_tree_cursor_goto_first_child_wasm = createExportWrapper("ts_tree_cursor_goto_first_child_wasm", 1);
3353
3342
  Module["_ts_tree_cursor_goto_last_child_wasm"] = _ts_tree_cursor_goto_last_child_wasm = createExportWrapper("ts_tree_cursor_goto_last_child_wasm", 1);
3354
3343
  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);
3355
- 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);
3344
+ 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);
3356
3345
  Module["_ts_tree_cursor_goto_next_sibling_wasm"] = _ts_tree_cursor_goto_next_sibling_wasm = createExportWrapper("ts_tree_cursor_goto_next_sibling_wasm", 1);
3357
3346
  Module["_ts_tree_cursor_goto_previous_sibling_wasm"] = _ts_tree_cursor_goto_previous_sibling_wasm = createExportWrapper("ts_tree_cursor_goto_previous_sibling_wasm", 1);
3358
3347
  Module["_ts_tree_cursor_goto_descendant_wasm"] = _ts_tree_cursor_goto_descendant_wasm = createExportWrapper("ts_tree_cursor_goto_descendant_wasm", 2);
@@ -3363,8 +3352,6 @@ async function Module2(moduleArg = {}) {
3363
3352
  Module["_ts_tree_cursor_end_position_wasm"] = _ts_tree_cursor_end_position_wasm = createExportWrapper("ts_tree_cursor_end_position_wasm", 1);
3364
3353
  Module["_ts_tree_cursor_start_index_wasm"] = _ts_tree_cursor_start_index_wasm = createExportWrapper("ts_tree_cursor_start_index_wasm", 1);
3365
3354
  Module["_ts_tree_cursor_end_index_wasm"] = _ts_tree_cursor_end_index_wasm = createExportWrapper("ts_tree_cursor_end_index_wasm", 1);
3366
- Module["_ts_tree_cursor_current_depth_wasm"] = _ts_tree_cursor_current_depth_wasm = createExportWrapper("ts_tree_cursor_current_depth_wasm", 1);
3367
- Module["_ts_tree_cursor_current_descendant_index_wasm"] = _ts_tree_cursor_current_descendant_index_wasm = createExportWrapper("ts_tree_cursor_current_descendant_index_wasm", 1);
3368
3355
  Module["_ts_tree_cursor_current_node_wasm"] = _ts_tree_cursor_current_node_wasm = createExportWrapper("ts_tree_cursor_current_node_wasm", 1);
3369
3356
  Module["_ts_node_symbol_wasm"] = _ts_node_symbol_wasm = createExportWrapper("ts_node_symbol_wasm", 1);
3370
3357
  Module["_ts_node_field_name_for_child_wasm"] = _ts_node_field_name_for_child_wasm = createExportWrapper("ts_node_field_name_for_child_wasm", 2);
@@ -3389,14 +3376,12 @@ async function Module2(moduleArg = {}) {
3389
3376
  Module["_ts_node_named_descendant_for_index_wasm"] = _ts_node_named_descendant_for_index_wasm = createExportWrapper("ts_node_named_descendant_for_index_wasm", 1);
3390
3377
  Module["_ts_node_descendant_for_position_wasm"] = _ts_node_descendant_for_position_wasm = createExportWrapper("ts_node_descendant_for_position_wasm", 1);
3391
3378
  Module["_ts_node_named_descendant_for_position_wasm"] = _ts_node_named_descendant_for_position_wasm = createExportWrapper("ts_node_named_descendant_for_position_wasm", 1);
3392
- Module["_ts_node_start_point_wasm"] = _ts_node_start_point_wasm = createExportWrapper("ts_node_start_point_wasm", 1);
3393
3379
  Module["_ts_node_end_point_wasm"] = _ts_node_end_point_wasm = createExportWrapper("ts_node_end_point_wasm", 1);
3394
- Module["_ts_node_start_index_wasm"] = _ts_node_start_index_wasm = createExportWrapper("ts_node_start_index_wasm", 1);
3395
3380
  Module["_ts_node_end_index_wasm"] = _ts_node_end_index_wasm = createExportWrapper("ts_node_end_index_wasm", 1);
3396
3381
  Module["_ts_node_to_string_wasm"] = _ts_node_to_string_wasm = createExportWrapper("ts_node_to_string_wasm", 1);
3397
3382
  Module["_ts_node_children_wasm"] = _ts_node_children_wasm = createExportWrapper("ts_node_children_wasm", 1);
3398
3383
  Module["_ts_node_named_children_wasm"] = _ts_node_named_children_wasm = createExportWrapper("ts_node_named_children_wasm", 1);
3399
- Module["_ts_node_descendants_of_type_wasm"] = _ts_node_descendants_of_type_wasm = createExportWrapper("ts_node_descendants_of_type_wasm", 7);
3384
+ Module["_ts_node_descendants_of_type_wasm"] = _ts_node_descendants_of_type_wasm = createExportWrapper("ts_node_descendants_of_type_wasm", 3);
3400
3385
  Module["_ts_node_is_named_wasm"] = _ts_node_is_named_wasm = createExportWrapper("ts_node_is_named_wasm", 1);
3401
3386
  Module["_ts_node_has_changes_wasm"] = _ts_node_has_changes_wasm = createExportWrapper("ts_node_has_changes_wasm", 1);
3402
3387
  Module["_ts_node_has_error_wasm"] = _ts_node_has_error_wasm = createExportWrapper("ts_node_has_error_wasm", 1);
@@ -3405,9 +3390,9 @@ async function Module2(moduleArg = {}) {
3405
3390
  Module["_ts_node_is_extra_wasm"] = _ts_node_is_extra_wasm = createExportWrapper("ts_node_is_extra_wasm", 1);
3406
3391
  Module["_ts_node_parse_state_wasm"] = _ts_node_parse_state_wasm = createExportWrapper("ts_node_parse_state_wasm", 1);
3407
3392
  Module["_ts_node_next_parse_state_wasm"] = _ts_node_next_parse_state_wasm = createExportWrapper("ts_node_next_parse_state_wasm", 1);
3408
- Module["_memset"] = _memset = createExportWrapper("memset", 3);
3409
3393
  Module["_memcpy"] = _memcpy = createExportWrapper("memcpy", 3);
3410
3394
  Module["_memmove"] = _memmove = createExportWrapper("memmove", 3);
3395
+ Module["_memset"] = _memset = createExportWrapper("memset", 3);
3411
3396
  _fflush = createExportWrapper("fflush", 1);
3412
3397
  Module["_strlen"] = _strlen = createExportWrapper("strlen", 1);
3413
3398
  Module["_iswalnum"] = _iswalnum = createExportWrapper("iswalnum", 1);
@@ -3454,8 +3439,6 @@ async function Module2(moduleArg = {}) {
3454
3439
  /** @export */
3455
3440
  __table_base: ___table_base,
3456
3441
  /** @export */
3457
- _abort_js: __abort_js,
3458
- /** @export */
3459
3442
  _emscripten_throw_longjmp: __emscripten_throw_longjmp,
3460
3443
  /** @export */
3461
3444
  alignfault,
@@ -3468,6 +3451,8 @@ async function Module2(moduleArg = {}) {
3468
3451
  /** @export */
3469
3452
  fd_write: _fd_write,
3470
3453
  /** @export */
3454
+ invoke_ii,
3455
+ /** @export */
3471
3456
  invoke_iii,
3472
3457
  /** @export */
3473
3458
  invoke_iiii,
@@ -3478,8 +3463,6 @@ async function Module2(moduleArg = {}) {
3478
3463
  /** @export */
3479
3464
  invoke_vi,
3480
3465
  /** @export */
3481
- invoke_vii,
3482
- /** @export */
3483
3466
  invoke_vj,
3484
3467
  /** @export */
3485
3468
  memory: wasmMemory,
@@ -3492,28 +3475,28 @@ async function Module2(moduleArg = {}) {
3492
3475
  /** @export */
3493
3476
  tree_sitter_progress_callback: _tree_sitter_progress_callback
3494
3477
  };
3495
- function invoke_vii(index, a1, a2) {
3478
+ function invoke_vi(index, a1) {
3496
3479
  var sp = stackSave();
3497
3480
  try {
3498
- getWasmTableEntry(index)(a1, a2);
3481
+ getWasmTableEntry(index)(a1);
3499
3482
  } catch (e) {
3500
3483
  stackRestore(sp);
3501
3484
  if (e !== e + 0) throw e;
3502
3485
  _setThrew(1, 0);
3503
3486
  }
3504
3487
  }
3505
- __name(invoke_vii, "invoke_vii");
3506
- function invoke_iii(index, a1, a2) {
3488
+ __name(invoke_vi, "invoke_vi");
3489
+ function invoke_ii(index, a1) {
3507
3490
  var sp = stackSave();
3508
3491
  try {
3509
- return getWasmTableEntry(index)(a1, a2);
3492
+ return getWasmTableEntry(index)(a1);
3510
3493
  } catch (e) {
3511
3494
  stackRestore(sp);
3512
3495
  if (e !== e + 0) throw e;
3513
3496
  _setThrew(1, 0);
3514
3497
  }
3515
3498
  }
3516
- __name(invoke_iii, "invoke_iii");
3499
+ __name(invoke_ii, "invoke_ii");
3517
3500
  function invoke_vj(index, a1) {
3518
3501
  var sp = stackSave();
3519
3502
  try {
@@ -3537,39 +3520,39 @@ async function Module2(moduleArg = {}) {
3537
3520
  }
3538
3521
  }
3539
3522
  __name(invoke_ji, "invoke_ji");
3540
- function invoke_iiiii(index, a1, a2, a3, a4) {
3523
+ function invoke_iiii(index, a1, a2, a3) {
3541
3524
  var sp = stackSave();
3542
3525
  try {
3543
- return getWasmTableEntry(index)(a1, a2, a3, a4);
3526
+ return getWasmTableEntry(index)(a1, a2, a3);
3544
3527
  } catch (e) {
3545
3528
  stackRestore(sp);
3546
3529
  if (e !== e + 0) throw e;
3547
3530
  _setThrew(1, 0);
3548
3531
  }
3549
3532
  }
3550
- __name(invoke_iiiii, "invoke_iiiii");
3551
- function invoke_iiii(index, a1, a2, a3) {
3533
+ __name(invoke_iiii, "invoke_iiii");
3534
+ function invoke_iiiii(index, a1, a2, a3, a4) {
3552
3535
  var sp = stackSave();
3553
3536
  try {
3554
- return getWasmTableEntry(index)(a1, a2, a3);
3537
+ return getWasmTableEntry(index)(a1, a2, a3, a4);
3555
3538
  } catch (e) {
3556
3539
  stackRestore(sp);
3557
3540
  if (e !== e + 0) throw e;
3558
3541
  _setThrew(1, 0);
3559
3542
  }
3560
3543
  }
3561
- __name(invoke_iiii, "invoke_iiii");
3562
- function invoke_vi(index, a1) {
3544
+ __name(invoke_iiiii, "invoke_iiiii");
3545
+ function invoke_iii(index, a1, a2) {
3563
3546
  var sp = stackSave();
3564
3547
  try {
3565
- getWasmTableEntry(index)(a1);
3548
+ return getWasmTableEntry(index)(a1, a2);
3566
3549
  } catch (e) {
3567
3550
  stackRestore(sp);
3568
3551
  if (e !== e + 0) throw e;
3569
3552
  _setThrew(1, 0);
3570
3553
  }
3571
3554
  }
3572
- __name(invoke_vi, "invoke_vi");
3555
+ __name(invoke_iii, "invoke_iii");
3573
3556
  var calledRun;
3574
3557
  function callMain(args2 = []) {
3575
3558
  assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on Module["onRuntimeInitialized"])');
@@ -3738,6 +3721,8 @@ var Parser = class {
3738
3721
  // Internal handle for Wasm
3739
3722
  /** @internal */
3740
3723
  logCallback = null;
3724
+ /** @internal */
3725
+ loggerEnabled = false;
3741
3726
  /** The parser's current language. */
3742
3727
  language = null;
3743
3728
  /** The number of parse operations executed by the most recent {@link Parser#parse} call. */
@@ -3772,6 +3757,7 @@ var Parser = class {
3772
3757
  const base = TRANSFER_BUFFER >>> 2;
3773
3758
  this[0] = C.HEAP32[base];
3774
3759
  this[1] = C.HEAP32[base + 1];
3760
+ this.loggerEnabled = false;
3775
3761
  }
3776
3762
  /** Delete the parser, freeing its resources. */
3777
3763
  delete() {
@@ -3825,38 +3811,75 @@ var Parser = class {
3825
3811
  parse(callback, oldTree, options) {
3826
3812
  const maxMemoryBytes = validateMemoryLimit(options?.maxMemoryBytes);
3827
3813
  const maxOperations = validateOperationLimit(options?.maxOperations);
3828
- const { sourceText, textCallback } = resolveInput(callback);
3829
- C.currentParseCallback = sourceText === void 0 ? textCallback : null;
3830
- C.currentProgressCallback = options?.progressCallback ?? null;
3831
- if (this.logCallback) {
3832
- C.currentLogCallback = this.logCallback;
3833
- C._ts_parser_enable_logger_wasm(this[0], 1);
3834
- } else {
3835
- C.currentLogCallback = null;
3836
- C._ts_parser_enable_logger_wasm(this[0], 0);
3814
+ if (typeof callback !== "string" && typeof callback !== "function") {
3815
+ throw new Error("Argument must be a string or a function");
3837
3816
  }
3817
+ const progressCallback = options?.progressCallback ?? null;
3818
+ C.currentParseCallback = callback;
3819
+ C.currentProgressCallback = progressCallback;
3820
+ this.syncLogger();
3838
3821
  this.lastParseOperations = 0;
3839
- const request = {
3840
- parserAddress: this[0],
3841
- callbackBuffer: this[1],
3842
- sourceText,
3843
- oldTreeAddress: oldTree ? oldTree[0] : 0,
3844
- ranges: options?.includedRanges,
3845
- maxOperations,
3846
- hasProgressCallback: options?.progressCallback ? 1 : 0,
3847
- onOperations: /* @__PURE__ */ __name((operations) => {
3848
- this.lastParseOperations = operations;
3849
- }, "onOperations")
3850
- };
3851
3822
  try {
3852
- const treeAddress = maxMemoryBytes === void 0 ? parseOrdinaryWasm(request) : parseLimitedWasm(request, maxMemoryBytes);
3823
+ const treeAddress = this.runParse(oldTree, options, maxMemoryBytes, maxOperations);
3853
3824
  if (!treeAddress) return null;
3854
3825
  if (!this.language) throw new Error("Parser must have a language to parse");
3855
- return new Tree2(INTERNAL, treeAddress, this.language, textCallback, sourceText);
3826
+ return new Tree2(INTERNAL, treeAddress, this.language, callback);
3856
3827
  } finally {
3857
3828
  clearCallbacks();
3858
3829
  }
3859
3830
  }
3831
+ /** @internal */
3832
+ syncLogger() {
3833
+ if (this.logCallback) {
3834
+ C.currentLogCallback = this.logCallback;
3835
+ if (!this.loggerEnabled) {
3836
+ C._ts_parser_enable_logger_wasm(this[0], 1);
3837
+ this.loggerEnabled = true;
3838
+ }
3839
+ } else {
3840
+ C.currentLogCallback = null;
3841
+ if (this.loggerEnabled) {
3842
+ C._ts_parser_enable_logger_wasm(this[0], 0);
3843
+ this.loggerEnabled = false;
3844
+ }
3845
+ }
3846
+ }
3847
+ /** @internal */
3848
+ runParse(oldTree, options, maxMemoryBytes, maxOperations) {
3849
+ if (maxMemoryBytes !== void 0 && !C.treeSitterSetMemoryLimit(maxMemoryBytes)) {
3850
+ return 0;
3851
+ }
3852
+ try {
3853
+ const [rangeAddress, rangeCount] = prepareRanges(options?.includedRanges);
3854
+ if (rangeCount && !rangeAddress) return 0;
3855
+ marshalParseInputs(maxOperations, rangeAddress, rangeCount, options?.progressCallback ? 1 : 0);
3856
+ try {
3857
+ return maxMemoryBytes === void 0 ? this.executeOrdinaryParse(oldTree ? oldTree[0] : 0) : this.executeLimitedParse();
3858
+ } finally {
3859
+ this.lastParseOperations = unmarshalOperationCount();
3860
+ }
3861
+ } finally {
3862
+ if (maxMemoryBytes !== void 0) C.treeSitterSetMemoryLimit(0);
3863
+ }
3864
+ }
3865
+ /** @internal */
3866
+ executeOrdinaryParse(oldTreeAddress) {
3867
+ try {
3868
+ return C._ts_parser_parse_wasm(this[0], this[1], oldTreeAddress);
3869
+ } catch (error) {
3870
+ C._ts_parser_last_parse_operations_wasm(this[0]);
3871
+ throw error;
3872
+ }
3873
+ }
3874
+ /** @internal */
3875
+ executeLimitedParse() {
3876
+ try {
3877
+ return C._ts_parser_parse_limited_wasm(this[0], this[1]);
3878
+ } catch (error) {
3879
+ C._ts_parser_abort_limited_wasm();
3880
+ throw error;
3881
+ }
3882
+ }
3860
3883
  /**
3861
3884
  * Instruct the parser to start the next parse from the beginning.
3862
3885
  *
@@ -3904,102 +3927,31 @@ function validateOperationLimit(maxOperations) {
3904
3927
  return maxOperations;
3905
3928
  }
3906
3929
  __name(validateOperationLimit, "validateOperationLimit");
3907
- function resolveInput(callback) {
3908
- if (typeof callback === "string") {
3909
- return { sourceText: callback, textCallback: /* @__PURE__ */ __name((index) => callback.slice(index), "textCallback") };
3910
- }
3911
- if (typeof callback === "function") {
3912
- return { sourceText: void 0, textCallback: callback };
3913
- }
3914
- throw new Error("Argument must be a string or a function");
3915
- }
3916
- __name(resolveInput, "resolveInput");
3917
- function parseOrdinaryWasm(request) {
3918
- return withPreparedParse(request, (inputBuffer) => {
3919
- try {
3920
- return C._ts_parser_parse_wasm(request.parserAddress, inputBuffer, request.oldTreeAddress);
3921
- } catch (error) {
3922
- C._ts_parser_last_parse_operations_wasm(request.parserAddress);
3923
- throw error;
3924
- }
3925
- });
3926
- }
3927
- __name(parseOrdinaryWasm, "parseOrdinaryWasm");
3928
- function parseLimitedWasm(request, maxMemoryBytes) {
3929
- if (!C.treeSitterSetMemoryLimit(maxMemoryBytes)) return 0;
3930
- try {
3931
- return withPreparedParse(request, (inputBuffer) => {
3932
- try {
3933
- return C._ts_parser_parse_limited_wasm(request.parserAddress, inputBuffer);
3934
- } catch (error) {
3935
- C._ts_parser_abort_limited_wasm();
3936
- throw error;
3937
- }
3938
- });
3939
- } finally {
3940
- C.treeSitterSetMemoryLimit(0);
3941
- }
3942
- }
3943
- __name(parseLimitedWasm, "parseLimitedWasm");
3944
- function withPreparedParse(request, execute) {
3945
- let sourceAddress = 0;
3946
- let rangeAddress = 0;
3947
- let executed = false;
3948
- try {
3949
- const [allocatedSource, byteLength, ok] = prepareSourceBuffer(request.sourceText);
3950
- sourceAddress = allocatedSource;
3951
- if (!ok) return 0;
3952
- const [allocatedRanges, rangeCount] = prepareRanges(request.ranges);
3953
- rangeAddress = allocatedRanges;
3954
- if (rangeCount && !allocatedRanges) return 0;
3955
- const isStringInput = request.sourceText !== void 0;
3956
- marshalParseInputs(request.maxOperations, byteLength, allocatedRanges, rangeCount, isStringInput, request.hasProgressCallback);
3957
- executed = true;
3958
- return execute(isStringInput ? allocatedSource : request.callbackBuffer);
3959
- } finally {
3960
- if (executed) request.onOperations(unmarshalOperationCount());
3961
- if (rangeAddress) C._free(rangeAddress);
3962
- if (sourceAddress) C._free(sourceAddress);
3963
- }
3964
- }
3965
- __name(withPreparedParse, "withPreparedParse");
3966
- function prepareSourceBuffer(sourceText) {
3967
- if (sourceText === void 0) return [0, 0, true];
3968
- const codeUnits = sourceText.length;
3969
- if (codeUnits === 0) return [0, 0, true];
3970
- if (codeUnits > 1073741823) return [0, 0, false];
3971
- const byteLength = codeUnits * 2;
3972
- const address = C._malloc(byteLength);
3973
- if (!address) return [0, 0, false];
3974
- const heapU16 = C.HEAPU16;
3975
- const base = address >>> 1;
3976
- for (let i2 = 0; i2 < codeUnits; i2++) {
3977
- heapU16[base + i2] = sourceText.charCodeAt(i2);
3978
- }
3979
- return [address, byteLength, true];
3980
- }
3981
- __name(prepareSourceBuffer, "prepareSourceBuffer");
3982
3930
  function prepareRanges(ranges) {
3983
3931
  if (!ranges?.length) return [0, 0];
3984
3932
  const rangeAddress = C._calloc(ranges.length, SIZE_OF_RANGE);
3985
3933
  if (!rangeAddress) return [0, ranges.length];
3986
- let address = rangeAddress;
3987
- for (const range of ranges) {
3988
- marshalRange(address, range);
3989
- address += SIZE_OF_RANGE;
3934
+ try {
3935
+ let address = rangeAddress;
3936
+ for (const range of ranges) {
3937
+ marshalRange(address, range);
3938
+ address += SIZE_OF_RANGE;
3939
+ }
3940
+ return [rangeAddress, ranges.length];
3941
+ } catch (error) {
3942
+ C._free(rangeAddress);
3943
+ throw error;
3990
3944
  }
3991
- return [rangeAddress, ranges.length];
3992
3945
  }
3993
3946
  __name(prepareRanges, "prepareRanges");
3994
- function marshalParseInputs(maxOperations, byteLength, rangeAddress, rangeCount, isStringInput, hasProgressCallback) {
3947
+ function marshalParseInputs(maxOperations, rangeAddress, rangeCount, hasProgressCallback) {
3995
3948
  const base = TRANSFER_BUFFER >>> 2;
3996
3949
  const heapU32 = C.HEAPU32;
3997
3950
  heapU32[base] = maxOperations === void 0 ? 0 : maxOperations >>> 0;
3998
3951
  heapU32[base + 1] = maxOperations === void 0 ? 0 : Math.floor(maxOperations / TWO_POW_32) >>> 0;
3999
- heapU32[base + 2] = byteLength;
4000
- heapU32[base + 3] = rangeAddress;
4001
- heapU32[base + 4] = rangeCount;
4002
- heapU32[base + 5] = (isStringInput ? 1 : 0) | (hasProgressCallback ? 2 : 0);
3952
+ heapU32[base + 2] = rangeAddress;
3953
+ heapU32[base + 3] = rangeCount;
3954
+ heapU32[base + 4] = hasProgressCallback;
4003
3955
  }
4004
3956
  __name(marshalParseInputs, "marshalParseInputs");
4005
3957
  function unmarshalOperationCount() {