@mrclrchtr/supi-code-intelligence 6.2.0 → 6.3.0

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.
Files changed (51) hide show
  1. package/README.md +2 -0
  2. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  3. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  4. package/node_modules/@mrclrchtr/supi-lsp/README.md +2 -0
  5. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  6. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  7. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/README.md +52 -0
  8. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/index.js +785 -129
  9. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/legacy.js +660 -98
  10. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/package.json +10 -4
  11. package/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
  12. package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +6 -2
  13. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-process-crash-report.ts +106 -0
  14. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-recovery.ts +4 -4
  15. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +348 -99
  16. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostics.ts +43 -15
  17. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +23 -32
  18. package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +4 -4
  19. package/node_modules/@mrclrchtr/supi-lsp/src/summary.ts +1 -1
  20. package/node_modules/@mrclrchtr/supi-lsp/src/workspace-path-policy.ts +18 -9
  21. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  22. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  23. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/README.md +29 -1
  24. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs +99 -19
  25. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs.map +4 -4
  26. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js +94 -18
  27. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js.map +4 -4
  28. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm +0 -0
  29. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm.map +14 -14
  30. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/package.json +13 -8
  31. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs +97 -19
  32. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs.map +4 -4
  33. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts +28 -8
  34. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts.map +1 -1
  35. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts +28 -8
  36. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts.map +1 -1
  37. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js +92 -18
  38. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js.map +4 -4
  39. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm +0 -0
  40. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm.map +17 -17
  41. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +7 -4
  42. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/kotlin/tree-sitter-kotlin.wasm +0 -0
  43. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/kotlin/tree-sitter-kotlin.wasm.json +2 -2
  44. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm +0 -0
  45. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm.json +2 -2
  46. package/package.json +5 -5
  47. package/src/session/health-refresh.ts +4 -2
  48. package/src/session/health-types.ts +3 -3
  49. package/src/substrate/lsp/settings.ts +2 -1
  50. package/src/tool/code_health/refresh-outcome.ts +37 -7
  51. package/src/tool/code_health/refresh-status.ts +58 -12
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-tree-sitter",
3
- "version": "0.26.13",
3
+ "version": "0.27.0",
4
4
  "description": "Tree-sitter bindings for the web",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,6 +43,11 @@
43
43
  },
44
44
  "./debug/web-tree-sitter.wasm": "./debug/web-tree-sitter.wasm"
45
45
  },
46
+ "browser": {
47
+ "fs": false,
48
+ "fs/promises": false,
49
+ "module": false
50
+ },
46
51
  "types": "web-tree-sitter.d.ts",
47
52
  "keywords": [
48
53
  "incremental",
@@ -71,15 +76,15 @@
71
76
  "devDependencies": {
72
77
  "@eslint/js": "^9.39.1",
73
78
  "@types/emscripten": "^1.41.5",
74
- "@types/node": "^24.10.1",
79
+ "@types/node": "^26.2.0",
75
80
  "@vitest/coverage-v8": "^3.0.5",
76
- "dts-buddy": "^0.6.2",
77
- "esbuild": "^0.27.1",
78
- "eslint": "^9.39.1",
79
- "source-map": "^0.7.4",
80
- "tsx": "^4.21.0",
81
+ "dts-buddy": "^0.8.3",
82
+ "esbuild": "^0.28.2",
83
+ "eslint": "^10.9.0",
84
+ "source-map": "^0.8.0",
85
+ "tsx": "^4.23.12",
81
86
  "typescript": "^5.7.3",
82
- "typescript-eslint": "^8.48.1",
87
+ "typescript-eslint": "^8.67.0",
83
88
  "vitest": "^3.0.5"
84
89
  },
85
90
  "scripts": {
@@ -7,7 +7,11 @@ var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
9
  var __commonJS = (cb, mod) => function __require() {
10
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ try {
11
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
+ } catch (e) {
13
+ throw mod = 0, e;
14
+ }
11
15
  };
12
16
  var __export = (target, all) => {
13
17
  for (var name2 in all)
@@ -553,7 +557,7 @@ var require_web_tree_sitter = __commonJS({
553
557
  newDSO("__main__", 0, wasmImports);
554
558
  }
555
559
  };
556
- var ___heap_base = 78240;
560
+ var ___heap_base = 82240;
557
561
  var alignMemory = /* @__PURE__ */ __name((size, alignment) => Math.ceil(size / alignment) * alignment, "alignMemory");
558
562
  var getMemory = /* @__PURE__ */ __name((size) => {
559
563
  if (runtimeInitialized) {
@@ -1118,12 +1122,12 @@ var require_web_tree_sitter = __commonJS({
1118
1122
  "value": "i32",
1119
1123
  "mutable": false
1120
1124
  }, 1024);
1121
- var ___stack_high = 78240;
1122
- var ___stack_low = 12704;
1125
+ var ___stack_high = 82240;
1126
+ var ___stack_low = 16704;
1123
1127
  var ___stack_pointer = new WebAssembly.Global({
1124
1128
  "value": "i32",
1125
1129
  "mutable": true
1126
- }, 78240);
1130
+ }, 82240);
1127
1131
  var ___table_base = new WebAssembly.Global({
1128
1132
  "value": "i32",
1129
1133
  "mutable": false
@@ -1384,7 +1388,7 @@ var require_web_tree_sitter = __commonJS({
1384
1388
  Module["loadWebAssemblyModule"] = loadWebAssemblyModule;
1385
1389
  Module["LE_HEAP_STORE_I64"] = LE_HEAP_STORE_I64;
1386
1390
  var ASM_CONSTS = {};
1387
- var _malloc, _calloc, _realloc, _free, _ts_range_edit, _memcmp, _ts_language_symbol_count, _ts_language_state_count, _ts_language_abi_version, _ts_language_name, _ts_language_field_count, _ts_language_next_state, _ts_language_symbol_name, _ts_language_symbol_for_name, _strncmp, _ts_language_symbol_type, _ts_language_field_name_for_id, _ts_lookahead_iterator_new, _ts_lookahead_iterator_delete, _ts_lookahead_iterator_reset_state, _ts_lookahead_iterator_reset, _ts_lookahead_iterator_next, _ts_lookahead_iterator_current_symbol, _ts_point_edit, _ts_parser_delete, _ts_parser_reset, _ts_parser_set_language, _ts_parser_set_included_ranges, _ts_query_new, _ts_query_delete, _iswspace, _iswalnum, _ts_query_pattern_count, _ts_query_capture_count, _ts_query_string_count, _ts_query_capture_name_for_id, _ts_query_capture_quantifier_for_id, _ts_query_string_value_for_id, _ts_query_predicates_for_pattern, _ts_query_start_byte_for_pattern, _ts_query_end_byte_for_pattern, _ts_query_is_pattern_rooted, _ts_query_is_pattern_non_local, _ts_query_is_pattern_guaranteed_at_step, _ts_query_disable_capture, _ts_query_disable_pattern, _ts_tree_copy, _ts_tree_delete, _ts_init, _ts_parser_new_wasm, _ts_parser_enable_logger_wasm, _ts_parser_parse_wasm, _ts_parser_included_ranges_wasm, _ts_language_type_is_named_wasm, _ts_language_type_is_visible_wasm, _ts_language_metadata_wasm, _ts_language_supertypes_wasm, _ts_language_subtypes_wasm, _ts_tree_root_node_wasm, _ts_tree_root_node_with_offset_wasm, _ts_tree_edit_wasm, _ts_tree_included_ranges_wasm, _ts_tree_get_changed_ranges_wasm, _ts_tree_cursor_new_wasm, _ts_tree_cursor_copy_wasm, _ts_tree_cursor_delete_wasm, _ts_tree_cursor_reset_wasm, _ts_tree_cursor_reset_to_wasm, _ts_tree_cursor_goto_first_child_wasm, _ts_tree_cursor_goto_last_child_wasm, _ts_tree_cursor_goto_first_child_for_index_wasm, _ts_tree_cursor_goto_first_child_for_position_wasm, _ts_tree_cursor_goto_next_sibling_wasm, _ts_tree_cursor_goto_previous_sibling_wasm, _ts_tree_cursor_goto_descendant_wasm, _ts_tree_cursor_goto_parent_wasm, _ts_tree_cursor_current_node_type_id_wasm, _ts_tree_cursor_current_node_state_id_wasm, _ts_tree_cursor_current_node_is_named_wasm, _ts_tree_cursor_current_node_is_missing_wasm, _ts_tree_cursor_current_node_id_wasm, _ts_tree_cursor_start_position_wasm, _ts_tree_cursor_end_position_wasm, _ts_tree_cursor_start_index_wasm, _ts_tree_cursor_end_index_wasm, _ts_tree_cursor_current_field_id_wasm, _ts_tree_cursor_current_depth_wasm, _ts_tree_cursor_current_descendant_index_wasm, _ts_tree_cursor_current_node_wasm, _ts_node_symbol_wasm, _ts_node_field_name_for_child_wasm, _ts_node_field_name_for_named_child_wasm, _ts_node_children_by_field_id_wasm, _ts_node_first_child_for_byte_wasm, _ts_node_first_named_child_for_byte_wasm, _ts_node_grammar_symbol_wasm, _ts_node_child_count_wasm, _ts_node_named_child_count_wasm, _ts_node_child_wasm, _ts_node_named_child_wasm, _ts_node_child_by_field_id_wasm, _ts_node_next_sibling_wasm, _ts_node_prev_sibling_wasm, _ts_node_next_named_sibling_wasm, _ts_node_prev_named_sibling_wasm, _ts_node_descendant_count_wasm, _ts_node_parent_wasm, _ts_node_child_with_descendant_wasm, _ts_node_descendant_for_index_wasm, _ts_node_named_descendant_for_index_wasm, _ts_node_descendant_for_position_wasm, _ts_node_named_descendant_for_position_wasm, _ts_node_start_point_wasm, _ts_node_end_point_wasm, _ts_node_start_index_wasm, _ts_node_end_index_wasm, _ts_node_to_string_wasm, _ts_node_children_wasm, _ts_node_named_children_wasm, _ts_node_descendants_of_type_wasm, _ts_node_is_named_wasm, _ts_node_has_changes_wasm, _ts_node_has_error_wasm, _ts_node_is_error_wasm, _ts_node_is_missing_wasm, _ts_node_is_extra_wasm, _ts_node_parse_state_wasm, _ts_node_next_parse_state_wasm, _ts_query_matches_wasm, _ts_query_captures_wasm, _memset, _memcpy, _memmove, _iswalpha, _iswblank, _iswdigit, _iswlower, _iswupper, _iswxdigit, _memchr, _strlen, _strcmp, _strncat, _strncpy, _towlower, _towupper, _setThrew, __emscripten_stack_restore, __emscripten_stack_alloc, _emscripten_stack_get_current, ___wasm_apply_data_relocs;
1391
+ var _malloc, _calloc, _realloc, _free, _ts_range_edit, _memcmp, _ts_language_symbol_count, _ts_language_state_count, _ts_language_abi_version, _ts_language_name, _ts_language_field_count, _ts_language_next_state, _ts_language_symbol_name, _ts_language_symbol_for_name, _strncmp, _ts_language_symbol_type, _ts_language_field_name_for_id, _ts_lookahead_iterator_new, _ts_lookahead_iterator_delete, _ts_lookahead_iterator_reset_state, _ts_lookahead_iterator_reset, _ts_lookahead_iterator_next, _ts_lookahead_iterator_current_symbol, _ts_point_edit, _ts_parser_delete, _ts_parser_reset, _ts_parser_set_language, _ts_parser_set_included_ranges, _ts_query_new, _ts_query_delete, _iswspace, _iswalnum, _ts_query_copy, _ts_query_pattern_count, _ts_query_capture_count, _ts_query_string_count, _ts_query_capture_name_for_id, _ts_query_capture_quantifier_for_id, _ts_query_string_value_for_id, _ts_query_predicates_for_pattern, _ts_query_start_byte_for_pattern, _ts_query_end_byte_for_pattern, _ts_query_is_pattern_rooted, _ts_query_is_pattern_non_local, _ts_query_is_pattern_guaranteed_at_step, _ts_query_disable_capture, _ts_query_disable_pattern, _ts_tree_copy, _ts_tree_delete, _ts_init, _ts_parser_new_wasm, _ts_parser_enable_logger_wasm, _ts_parser_parse_wasm, _ts_parser_included_ranges_wasm, _ts_language_type_is_named_wasm, _ts_language_type_is_visible_wasm, _ts_language_metadata_wasm, _ts_language_supertypes_wasm, _ts_language_subtypes_wasm, _ts_tree_root_node_wasm, _ts_tree_root_node_with_offset_wasm, _ts_tree_edit_wasm, _ts_tree_included_ranges_wasm, _ts_tree_get_changed_ranges_wasm, _ts_tree_cursor_new_wasm, _ts_tree_cursor_copy_wasm, _ts_tree_cursor_delete_wasm, _ts_tree_cursor_reset_wasm, _ts_tree_cursor_reset_to_wasm, _ts_tree_cursor_goto_first_child_wasm, _ts_tree_cursor_goto_last_child_wasm, _ts_tree_cursor_goto_first_child_for_index_wasm, _ts_tree_cursor_goto_first_child_for_position_wasm, _ts_tree_cursor_goto_next_sibling_wasm, _ts_tree_cursor_goto_previous_sibling_wasm, _ts_tree_cursor_goto_descendant_wasm, _ts_tree_cursor_goto_parent_wasm, _ts_tree_cursor_current_node_type_id_wasm, _ts_tree_cursor_current_node_state_id_wasm, _ts_tree_cursor_current_node_is_named_wasm, _ts_tree_cursor_current_node_is_missing_wasm, _ts_tree_cursor_current_node_id_wasm, _ts_tree_cursor_start_position_wasm, _ts_tree_cursor_end_position_wasm, _ts_tree_cursor_start_index_wasm, _ts_tree_cursor_end_index_wasm, _ts_tree_cursor_current_field_id_wasm, _ts_tree_cursor_current_depth_wasm, _ts_tree_cursor_current_descendant_index_wasm, _ts_tree_cursor_current_node_wasm, _ts_node_symbol_wasm, _ts_node_field_name_for_child_wasm, _ts_node_field_name_for_named_child_wasm, _ts_node_children_by_field_id_wasm, _ts_node_first_child_for_byte_wasm, _ts_node_first_named_child_for_byte_wasm, _ts_node_grammar_symbol_wasm, _ts_node_child_count_wasm, _ts_node_named_child_count_wasm, _ts_node_child_wasm, _ts_node_named_child_wasm, _ts_node_child_by_field_id_wasm, _ts_node_next_sibling_wasm, _ts_node_prev_sibling_wasm, _ts_node_next_named_sibling_wasm, _ts_node_prev_named_sibling_wasm, _ts_node_descendant_count_wasm, _ts_node_parent_wasm, _ts_node_child_with_descendant_wasm, _ts_node_descendant_for_index_wasm, _ts_node_named_descendant_for_index_wasm, _ts_node_descendant_for_position_wasm, _ts_node_named_descendant_for_position_wasm, _ts_node_start_point_wasm, _ts_node_end_point_wasm, _ts_node_start_index_wasm, _ts_node_end_index_wasm, _ts_node_to_string_wasm, _ts_node_children_wasm, _ts_node_named_children_wasm, _ts_node_descendants_of_type_wasm, _ts_node_is_named_wasm, _ts_node_has_changes_wasm, _ts_node_has_error_wasm, _ts_node_is_error_wasm, _ts_node_is_missing_wasm, _ts_node_is_extra_wasm, _ts_node_parse_state_wasm, _ts_node_next_parse_state_wasm, _ts_query_matches_wasm, _ts_query_captures_wasm, _memset, _memcpy, _memmove, _iswalpha, _iswblank, _iswdigit, _iswlower, _iswpunct, _iswupper, _iswxdigit, _memchr, _strlen, _strcmp, _strncat, _strncpy, _towlower, _towupper, _setThrew, __emscripten_stack_restore, __emscripten_stack_alloc, _emscripten_stack_get_current, ___wasm_apply_data_relocs;
1388
1392
  function assignWasmExports(wasmExports2) {
1389
1393
  Module["_malloc"] = _malloc = wasmExports2["malloc"];
1390
1394
  Module["_calloc"] = _calloc = wasmExports2["calloc"];
@@ -1418,6 +1422,7 @@ var require_web_tree_sitter = __commonJS({
1418
1422
  Module["_ts_query_delete"] = _ts_query_delete = wasmExports2["ts_query_delete"];
1419
1423
  Module["_iswspace"] = _iswspace = wasmExports2["iswspace"];
1420
1424
  Module["_iswalnum"] = _iswalnum = wasmExports2["iswalnum"];
1425
+ Module["_ts_query_copy"] = _ts_query_copy = wasmExports2["ts_query_copy"];
1421
1426
  Module["_ts_query_pattern_count"] = _ts_query_pattern_count = wasmExports2["ts_query_pattern_count"];
1422
1427
  Module["_ts_query_capture_count"] = _ts_query_capture_count = wasmExports2["ts_query_capture_count"];
1423
1428
  Module["_ts_query_string_count"] = _ts_query_string_count = wasmExports2["ts_query_string_count"];
@@ -1523,6 +1528,7 @@ var require_web_tree_sitter = __commonJS({
1523
1528
  Module["_iswblank"] = _iswblank = wasmExports2["iswblank"];
1524
1529
  Module["_iswdigit"] = _iswdigit = wasmExports2["iswdigit"];
1525
1530
  Module["_iswlower"] = _iswlower = wasmExports2["iswlower"];
1531
+ Module["_iswpunct"] = _iswpunct = wasmExports2["iswpunct"];
1526
1532
  Module["_iswupper"] = _iswupper = wasmExports2["iswupper"];
1527
1533
  Module["_iswxdigit"] = _iswxdigit = wasmExports2["iswxdigit"];
1528
1534
  Module["_memchr"] = _memchr = wasmExports2["memchr"];
@@ -1797,7 +1803,21 @@ function setModule(module2) {
1797
1803
  __name(setModule, "setModule");
1798
1804
  var C;
1799
1805
 
1806
+ // src/finalization_registry.ts
1807
+ function newFinalizer(handler) {
1808
+ try {
1809
+ return new FinalizationRegistry(handler);
1810
+ } catch (e) {
1811
+ console.error("Unsupported FinalizationRegistry:", e);
1812
+ return;
1813
+ }
1814
+ }
1815
+ __name(newFinalizer, "newFinalizer");
1816
+
1800
1817
  // src/lookahead_iterator.ts
1818
+ var finalizer = newFinalizer((address) => {
1819
+ C._ts_lookahead_iterator_delete(address);
1820
+ });
1801
1821
  var LookaheadIterator = class {
1802
1822
  static {
1803
1823
  __name(this, "LookaheadIterator");
@@ -1808,21 +1828,39 @@ var LookaheadIterator = class {
1808
1828
  /** @internal */
1809
1829
  language;
1810
1830
  /** @internal */
1831
+ positioned = false;
1832
+ /** @internal */
1811
1833
  constructor(internal, address, language) {
1812
1834
  assertInternal(internal);
1813
1835
  this[0] = address;
1814
1836
  this.language = language;
1837
+ finalizer?.register(this, address, this);
1815
1838
  }
1816
- /** Get the current symbol of the lookahead iterator. */
1839
+ /**
1840
+ * Get the current symbol of the lookahead iterator.
1841
+ *
1842
+ * Returns `null` if the iterator is not positioned on a symbol:
1843
+ *
1844
+ * - Before the first iteration step
1845
+ * - After the iterator is exhausted
1846
+ * - After a {@link reset} or {@link resetState} call
1847
+ */
1817
1848
  get currentTypeId() {
1818
- return C._ts_lookahead_iterator_current_symbol(this[0]);
1849
+ return this.positioned ? C._ts_lookahead_iterator_current_symbol(this[0]) : null;
1819
1850
  }
1820
- /** Get the current symbol name of the lookahead iterator. */
1851
+ /**
1852
+ * Get the current symbol name of the lookahead iterator.
1853
+ *
1854
+ * Returns `null` if the iterator is not positioned on a symbol.
1855
+ */
1821
1856
  get currentType() {
1822
- return this.language.types[this.currentTypeId] || "ERROR";
1857
+ const id = this.currentTypeId;
1858
+ if (id === null) return null;
1859
+ return this.language.types[id] ?? C.UTF8ToString(C._ts_language_symbol_name(this.language[0], id));
1823
1860
  }
1824
1861
  /** Delete the lookahead iterator, freeing its resources. */
1825
1862
  delete() {
1863
+ finalizer?.unregister(this);
1826
1864
  C._ts_lookahead_iterator_delete(this[0]);
1827
1865
  this[0] = 0;
1828
1866
  }
@@ -1835,6 +1873,7 @@ var LookaheadIterator = class {
1835
1873
  reset(language, stateId) {
1836
1874
  if (C._ts_lookahead_iterator_reset(this[0], language[0], stateId)) {
1837
1875
  this.language = language;
1876
+ this.positioned = false;
1838
1877
  return true;
1839
1878
  }
1840
1879
  return false;
@@ -1846,7 +1885,9 @@ var LookaheadIterator = class {
1846
1885
  * `false` otherwise.
1847
1886
  */
1848
1887
  resetState(stateId) {
1849
- return Boolean(C._ts_lookahead_iterator_reset_state(this[0], stateId));
1888
+ if (!C._ts_lookahead_iterator_reset_state(this[0], stateId)) return false;
1889
+ this.positioned = false;
1890
+ return true;
1850
1891
  }
1851
1892
  /**
1852
1893
  * Returns an iterator that iterates over the symbols of the lookahead iterator.
@@ -1857,10 +1898,9 @@ var LookaheadIterator = class {
1857
1898
  [Symbol.iterator]() {
1858
1899
  return {
1859
1900
  next: /* @__PURE__ */ __name(() => {
1860
- if (C._ts_lookahead_iterator_next(this[0])) {
1861
- return { done: false, value: this.currentType };
1862
- }
1863
- return { done: true, value: "" };
1901
+ this.positioned = Boolean(C._ts_lookahead_iterator_next(this[0]));
1902
+ const value = this.currentType;
1903
+ return value === null ? { done: true, value: "" } : { done: false, value };
1864
1904
  }, "next")
1865
1905
  };
1866
1906
  }
@@ -1888,6 +1928,9 @@ function getText(tree, startIndex, endIndex, startPosition) {
1888
1928
  return result ?? "";
1889
1929
  }
1890
1930
  __name(getText, "getText");
1931
+ var finalizer2 = newFinalizer((address) => {
1932
+ C._ts_tree_delete(address);
1933
+ });
1891
1934
  var Tree = class _Tree {
1892
1935
  static {
1893
1936
  __name(this, "Tree");
@@ -1905,6 +1948,7 @@ var Tree = class _Tree {
1905
1948
  this[0] = address;
1906
1949
  this.language = language;
1907
1950
  this.textCallback = textCallback;
1951
+ finalizer2?.register(this, address, this);
1908
1952
  }
1909
1953
  /** Create a shallow copy of the syntax tree. This is very fast. */
1910
1954
  copy() {
@@ -1913,6 +1957,7 @@ var Tree = class _Tree {
1913
1957
  }
1914
1958
  /** Delete the syntax tree, freeing its resources. */
1915
1959
  delete() {
1960
+ finalizer2?.unregister(this);
1916
1961
  C._ts_tree_delete(this[0]);
1917
1962
  this[0] = 0;
1918
1963
  }
@@ -1995,6 +2040,9 @@ var Tree = class _Tree {
1995
2040
  };
1996
2041
 
1997
2042
  // src/tree_cursor.ts
2043
+ var finalizer3 = newFinalizer((address) => {
2044
+ C._ts_tree_cursor_delete_wasm(address);
2045
+ });
1998
2046
  var TreeCursor = class _TreeCursor {
1999
2047
  static {
2000
2048
  __name(this, "TreeCursor");
@@ -2022,6 +2070,7 @@ var TreeCursor = class _TreeCursor {
2022
2070
  assertInternal(internal);
2023
2071
  this.tree = tree;
2024
2072
  unmarshalTreeCursor(this);
2073
+ finalizer3?.register(this, this.tree[0], this);
2025
2074
  }
2026
2075
  /** Creates a deep copy of the tree cursor. This allocates new memory. */
2027
2076
  copy() {
@@ -2032,6 +2081,7 @@ var TreeCursor = class _TreeCursor {
2032
2081
  }
2033
2082
  /** Delete the tree cursor, freeing its resources. */
2034
2083
  delete() {
2084
+ finalizer3?.unregister(this);
2035
2085
  marshalTreeCursor(this);
2036
2086
  C._ts_tree_cursor_delete_wasm(this.tree[0]);
2037
2087
  this[0] = this[1] = this[2] = 0;
@@ -3132,8 +3182,9 @@ var Language = class _Language {
3132
3182
  * This returns `null` if state is invalid for this language.
3133
3183
  *
3134
3184
  * Iterating {@link LookaheadIterator} will yield valid symbols in the given
3135
- * parse state. Newly created lookahead iterators will return the `ERROR`
3136
- * symbol from {@link LookaheadIterator#currentType}.
3185
+ * parse state. A newly created iterator is not positioned on a symbol, so
3186
+ * {@link LookaheadIterator#currentType} returns `null` until the first
3187
+ * iteration step.
3137
3188
  *
3138
3189
  * Lookahead iterators can be useful for generating suggestions and improving
3139
3190
  * syntax error diagnostics. To get symbols valid in an `ERROR` node, use the
@@ -3148,7 +3199,8 @@ var Language = class _Language {
3148
3199
  }
3149
3200
  /**
3150
3201
  * Load a language from a WebAssembly module.
3151
- * The module can be provided as a path to a file or as a buffer.
3202
+ * The module can be provided as a path to a file, a `URL` to a file, or as a
3203
+ * buffer.
3152
3204
  */
3153
3205
  static async load(input) {
3154
3206
  let binary2;
@@ -3175,16 +3227,27 @@ ${body2}`);
3175
3227
  }
3176
3228
  }
3177
3229
  const mod = await C.loadWebAssemblyModule(binary2, { loadAsync: true });
3230
+ return _Language.loadFromWasmExports(mod, { sync: false });
3231
+ }
3232
+ static loadFromWasmExports(mod, { sync }) {
3178
3233
  const symbolNames = Object.keys(mod);
3179
3234
  const functionName = symbolNames.find((key) => LANGUAGE_FUNCTION_REGEX.test(key) && !key.includes("external_scanner_"));
3180
3235
  if (!functionName) {
3181
3236
  console.log(`Couldn't find language function in Wasm file. Symbols:
3182
3237
  ${JSON.stringify(symbolNames, null, 2)}`);
3183
- throw new Error("Language.load failed: no language function found in Wasm file");
3238
+ throw new Error(`Language.${sync ? "loadSync" : "load"} failed: no language function found in Wasm file`);
3184
3239
  }
3185
3240
  const languageAddress = mod[functionName]();
3186
3241
  return new _Language(INTERNAL, languageAddress);
3187
3242
  }
3243
+ /**
3244
+ * Load a language synchronously from a pre-compiled WebAssembly module.
3245
+ * Use this when the host environment provides a `WebAssembly.Module` directly.
3246
+ */
3247
+ static loadSync(wasmModule) {
3248
+ const mod = C.loadWebAssemblyModule(wasmModule, { loadAsync: false });
3249
+ return _Language.loadFromWasmExports(mod, { sync: true });
3250
+ }
3188
3251
  };
3189
3252
 
3190
3253
  // src/bindings.ts
@@ -3203,6 +3266,10 @@ __name(checkModule, "checkModule");
3203
3266
  var TRANSFER_BUFFER;
3204
3267
  var LANGUAGE_VERSION;
3205
3268
  var MIN_COMPATIBLE_VERSION;
3269
+ var finalizer4 = newFinalizer((addresses) => {
3270
+ C._ts_parser_delete(addresses[0]);
3271
+ C._free(addresses[1]);
3272
+ });
3206
3273
  var Parser = class {
3207
3274
  static {
3208
3275
  __name(this, "Parser");
@@ -3234,6 +3301,7 @@ var Parser = class {
3234
3301
  */
3235
3302
  constructor() {
3236
3303
  this.initialize();
3304
+ finalizer4?.register(this, [this[0], this[1]], this);
3237
3305
  }
3238
3306
  /** @internal */
3239
3307
  initialize() {
@@ -3246,6 +3314,7 @@ var Parser = class {
3246
3314
  }
3247
3315
  /** Delete the parser, freeing its resources. */
3248
3316
  delete() {
3317
+ finalizer4?.unregister(this);
3249
3318
  C._ts_parser_delete(this[0]);
3250
3319
  C._free(this[1]);
3251
3320
  this[0] = 0;
@@ -3423,6 +3492,10 @@ var QueryError = class _QueryError extends Error {
3423
3492
  this.length = length;
3424
3493
  this.name = "QueryError";
3425
3494
  }
3495
+ kind;
3496
+ info;
3497
+ index;
3498
+ length;
3426
3499
  static {
3427
3500
  __name(this, "QueryError");
3428
3501
  }
@@ -3618,6 +3691,9 @@ function parsePattern(index, stepType, stepValueId, captureNames, stringValues,
3618
3691
  }
3619
3692
  }
3620
3693
  __name(parsePattern, "parsePattern");
3694
+ var finalizer5 = newFinalizer((address) => {
3695
+ C._ts_query_delete(address);
3696
+ });
3621
3697
  var Query = class {
3622
3698
  static {
3623
3699
  __name(this, "Query");
@@ -3772,9 +3848,11 @@ var Query = class {
3772
3848
  this.assertedProperties = assertedProperties;
3773
3849
  this.refutedProperties = refutedProperties;
3774
3850
  this.exceededMatchLimit = false;
3851
+ finalizer5?.register(this, address, this);
3775
3852
  }
3776
3853
  /** Delete the query, freeing its resources. */
3777
3854
  delete() {
3855
+ finalizer5?.unregister(this);
3778
3856
  C._ts_query_delete(this[0]);
3779
3857
  this[0] = 0;
3780
3858
  }