@vidocsecurity/cli 0.1.12

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 (67) hide show
  1. package/dist/index.js +4115 -0
  2. package/dist/markdown.css +132 -0
  3. package/dist/node_modules/@node-rs/crc32/LICENSE +21 -0
  4. package/dist/node_modules/@node-rs/crc32/README.md +61 -0
  5. package/dist/node_modules/@node-rs/crc32/browser.js +1 -0
  6. package/dist/node_modules/@node-rs/crc32/index.d.ts +5 -0
  7. package/dist/node_modules/@node-rs/crc32/index.js +368 -0
  8. package/dist/node_modules/@node-rs/crc32/package.json +97 -0
  9. package/dist/node_modules/@vidocsecurity/code-context/languages.yaml +8332 -0
  10. package/dist/node_modules/@vidocsecurity/code-context/package.json +83 -0
  11. package/dist/node_modules/@vidocsecurity/code-context/wasm/tree-sitter-c-sharp.wasm +0 -0
  12. package/dist/node_modules/@vidocsecurity/code-context/wasm/tree-sitter-c.wasm +0 -0
  13. package/dist/node_modules/@vidocsecurity/code-context/wasm/tree-sitter-cpp.wasm +0 -0
  14. package/dist/node_modules/@vidocsecurity/code-context/wasm/tree-sitter-css.wasm +0 -0
  15. package/dist/node_modules/@vidocsecurity/code-context/wasm/tree-sitter-go.wasm +0 -0
  16. package/dist/node_modules/@vidocsecurity/code-context/wasm/tree-sitter-hcl.wasm +0 -0
  17. package/dist/node_modules/@vidocsecurity/code-context/wasm/tree-sitter-ini.wasm +0 -0
  18. package/dist/node_modules/@vidocsecurity/code-context/wasm/tree-sitter-java.wasm +0 -0
  19. package/dist/node_modules/@vidocsecurity/code-context/wasm/tree-sitter-javascript.wasm +0 -0
  20. package/dist/node_modules/@vidocsecurity/code-context/wasm/tree-sitter-python.wasm +0 -0
  21. package/dist/node_modules/@vidocsecurity/code-context/wasm/tree-sitter-regex.wasm +0 -0
  22. package/dist/node_modules/@vidocsecurity/code-context/wasm/tree-sitter-ruby.wasm +0 -0
  23. package/dist/node_modules/@vidocsecurity/code-context/wasm/tree-sitter-rust.wasm +0 -0
  24. package/dist/node_modules/@vidocsecurity/code-context/wasm/tree-sitter-tsx.wasm +0 -0
  25. package/dist/node_modules/@vidocsecurity/code-context/wasm/tree-sitter-typescript.wasm +0 -0
  26. package/dist/node_modules/@vidocsecurity/code-context/wasm/tree-sitter.js +4074 -0
  27. package/dist/node_modules/@vidocsecurity/code-context/wasm/tree-sitter.wasm +0 -0
  28. package/dist/node_modules/@vidocsecurity/code-context/wasm/web-tree-sitter.d.ts +1027 -0
  29. package/dist/node_modules/yoga-layout/README.md +40 -0
  30. package/dist/node_modules/yoga-layout/dist/binaries/yoga-wasm-base64-esm.js +75 -0
  31. package/dist/node_modules/yoga-layout/dist/src/generated/YGEnums.d.ts +189 -0
  32. package/dist/node_modules/yoga-layout/dist/src/generated/YGEnums.js +211 -0
  33. package/dist/node_modules/yoga-layout/dist/src/generated/YGEnums.js.map +1 -0
  34. package/dist/node_modules/yoga-layout/dist/src/index.d.ts +12 -0
  35. package/dist/node_modules/yoga-layout/dist/src/index.js +16 -0
  36. package/dist/node_modules/yoga-layout/dist/src/index.js.map +1 -0
  37. package/dist/node_modules/yoga-layout/dist/src/load.d.ts +11 -0
  38. package/dist/node_modules/yoga-layout/dist/src/load.js +17 -0
  39. package/dist/node_modules/yoga-layout/dist/src/load.js.map +1 -0
  40. package/dist/node_modules/yoga-layout/dist/src/wrapAssembly.d.ts +155 -0
  41. package/dist/node_modules/yoga-layout/dist/src/wrapAssembly.js +125 -0
  42. package/dist/node_modules/yoga-layout/dist/src/wrapAssembly.js.map +1 -0
  43. package/dist/node_modules/yoga-layout/package.json +53 -0
  44. package/dist/node_modules/yoga-layout/src/Config.cpp +54 -0
  45. package/dist/node_modules/yoga-layout/src/Config.h +44 -0
  46. package/dist/node_modules/yoga-layout/src/Layout.h +19 -0
  47. package/dist/node_modules/yoga-layout/src/Node.cpp +507 -0
  48. package/dist/node_modules/yoga-layout/src/Node.h +239 -0
  49. package/dist/node_modules/yoga-layout/src/Size.h +17 -0
  50. package/dist/node_modules/yoga-layout/src/Value.h +23 -0
  51. package/dist/node_modules/yoga-layout/src/embind.cpp +207 -0
  52. package/dist/node_modules/yoga-layout/src/generated/YGEnums.ts +210 -0
  53. package/dist/node_modules/yoga-layout/src/index.ts +23 -0
  54. package/dist/node_modules/yoga-layout/src/load.ts +25 -0
  55. package/dist/node_modules/yoga-layout/src/wrapAssembly.ts +336 -0
  56. package/dist/prebuilds/android-arm/classic-level.armv7.node +0 -0
  57. package/dist/prebuilds/android-arm64/classic-level.armv8.node +0 -0
  58. package/dist/prebuilds/darwin-x64+arm64/classic-level.node +0 -0
  59. package/dist/prebuilds/linux-arm/classic-level.armv6.node +0 -0
  60. package/dist/prebuilds/linux-arm/classic-level.armv7.node +0 -0
  61. package/dist/prebuilds/linux-arm64/classic-level.armv8.node +0 -0
  62. package/dist/prebuilds/linux-x64/classic-level.musl.node +0 -0
  63. package/dist/prebuilds/linux-x64/classic-level.node +0 -0
  64. package/dist/prebuilds/win32-ia32/classic-level.node +0 -0
  65. package/dist/prebuilds/win32-x64/classic-level.node +0 -0
  66. package/dist/version.txt +1 -0
  67. package/package.json +23 -0
@@ -0,0 +1,4074 @@
1
+ (function (global, factory) {
2
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
3
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Parser = {}));
5
+ })(this, (function () {
6
+
7
+ // Helper to replace import.meta.url
8
+ function getCurrentScriptUrl() {
9
+ if (typeof __filename !== 'undefined') {
10
+ // Node.js environment
11
+ return require('url').pathToFileURL(__filename).href;
12
+ }
13
+
14
+ if (typeof document !== 'undefined') {
15
+ // Browser environment
16
+ const script = document.currentScript;
17
+ return script ? script.src : undefined;
18
+ }
19
+
20
+ throw new Error('Unable to determine script URL');
21
+ }
22
+
23
+ var __defProp = Object.defineProperty;
24
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
25
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
26
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
27
+ }) : x)(function(x) {
28
+ if (typeof require !== "undefined") return require.apply(this, arguments);
29
+ throw Error('Dynamic require of "' + x + '" is not supported');
30
+ });
31
+
32
+ // src/constants.ts
33
+ var SIZE_OF_SHORT = 2;
34
+ var SIZE_OF_INT = 4;
35
+ var SIZE_OF_CURSOR = 4 * SIZE_OF_INT;
36
+ var SIZE_OF_NODE = 5 * SIZE_OF_INT;
37
+ var SIZE_OF_POINT = 2 * SIZE_OF_INT;
38
+ var SIZE_OF_RANGE = 2 * SIZE_OF_INT + 2 * SIZE_OF_POINT;
39
+ var ZERO_POINT = { row: 0, column: 0 };
40
+ var INTERNAL = Symbol("INTERNAL");
41
+ function assertInternal(x) {
42
+ if (x !== INTERNAL) throw new Error("Illegal constructor");
43
+ }
44
+ __name(assertInternal, "assertInternal");
45
+ function isPoint(point) {
46
+ return !!point && typeof point.row === "number" && typeof point.column === "number";
47
+ }
48
+ __name(isPoint, "isPoint");
49
+ function setModule(module2) {
50
+ C = module2;
51
+ }
52
+ __name(setModule, "setModule");
53
+ var C;
54
+
55
+ // src/lookahead_iterator.ts
56
+ var LookaheadIterator = class {
57
+ static {
58
+ __name(this, "LookaheadIterator");
59
+ }
60
+ /** @internal */
61
+ [0] = 0;
62
+ // Internal handle for WASM
63
+ /** @internal */
64
+ language;
65
+ /** @internal */
66
+ constructor(internal, address, language) {
67
+ assertInternal(internal);
68
+ this[0] = address;
69
+ this.language = language;
70
+ }
71
+ /** Get the current symbol of the lookahead iterator. */
72
+ get currentTypeId() {
73
+ return C._ts_lookahead_iterator_current_symbol(this[0]);
74
+ }
75
+ /** Get the current symbol name of the lookahead iterator. */
76
+ get currentType() {
77
+ return this.language.types[this.currentTypeId] || "ERROR";
78
+ }
79
+ /** Delete the lookahead iterator, freeing its resources. */
80
+ delete() {
81
+ C._ts_lookahead_iterator_delete(this[0]);
82
+ this[0] = 0;
83
+ }
84
+ /**
85
+ * Reset the lookahead iterator.
86
+ *
87
+ * This returns `true` if the language was set successfully and `false`
88
+ * otherwise.
89
+ */
90
+ reset(language, stateId) {
91
+ if (C._ts_lookahead_iterator_reset(this[0], language[0], stateId)) {
92
+ this.language = language;
93
+ return true;
94
+ }
95
+ return false;
96
+ }
97
+ /**
98
+ * Reset the lookahead iterator to another state.
99
+ *
100
+ * This returns `true` if the iterator was reset to the given state and
101
+ * `false` otherwise.
102
+ */
103
+ resetState(stateId) {
104
+ return Boolean(C._ts_lookahead_iterator_reset_state(this[0], stateId));
105
+ }
106
+ /**
107
+ * Returns an iterator that iterates over the symbols of the lookahead iterator.
108
+ *
109
+ * The iterator will yield the current symbol name as a string for each step
110
+ * until there are no more symbols to iterate over.
111
+ */
112
+ [Symbol.iterator]() {
113
+ return {
114
+ next: /* @__PURE__ */ __name(() => {
115
+ if (C._ts_lookahead_iterator_next(this[0])) {
116
+ return { done: false, value: this.currentType };
117
+ }
118
+ return { done: true, value: "" };
119
+ }, "next")
120
+ };
121
+ }
122
+ };
123
+
124
+ // src/tree.ts
125
+ function getText(tree, startIndex, endIndex, startPosition) {
126
+ const length = endIndex - startIndex;
127
+ let result = tree.textCallback(startIndex, startPosition);
128
+ if (result) {
129
+ startIndex += result.length;
130
+ while (startIndex < endIndex) {
131
+ const string = tree.textCallback(startIndex, startPosition);
132
+ if (string && string.length > 0) {
133
+ startIndex += string.length;
134
+ result += string;
135
+ } else {
136
+ break;
137
+ }
138
+ }
139
+ if (startIndex > endIndex) {
140
+ result = result.slice(0, length);
141
+ }
142
+ }
143
+ return result ?? "";
144
+ }
145
+ __name(getText, "getText");
146
+ var Tree = class _Tree {
147
+ static {
148
+ __name(this, "Tree");
149
+ }
150
+ /** @internal */
151
+ [0] = 0;
152
+ // Internal handle for WASM
153
+ /** @internal */
154
+ textCallback;
155
+ /** The language that was used to parse the syntax tree. */
156
+ language;
157
+ /** @internal */
158
+ constructor(internal, address, language, textCallback) {
159
+ assertInternal(internal);
160
+ this[0] = address;
161
+ this.language = language;
162
+ this.textCallback = textCallback;
163
+ }
164
+ /** Create a shallow copy of the syntax tree. This is very fast. */
165
+ copy() {
166
+ const address = C._ts_tree_copy(this[0]);
167
+ return new _Tree(INTERNAL, address, this.language, this.textCallback);
168
+ }
169
+ /** Delete the syntax tree, freeing its resources. */
170
+ delete() {
171
+ C._ts_tree_delete(this[0]);
172
+ this[0] = 0;
173
+ }
174
+ /** Get the root node of the syntax tree. */
175
+ get rootNode() {
176
+ C._ts_tree_root_node_wasm(this[0]);
177
+ return unmarshalNode(this);
178
+ }
179
+ /**
180
+ * Get the root node of the syntax tree, but with its position shifted
181
+ * forward by the given offset.
182
+ */
183
+ rootNodeWithOffset(offsetBytes, offsetExtent) {
184
+ const address = TRANSFER_BUFFER + SIZE_OF_NODE;
185
+ C.setValue(address, offsetBytes, "i32");
186
+ marshalPoint(address + SIZE_OF_INT, offsetExtent);
187
+ C._ts_tree_root_node_with_offset_wasm(this[0]);
188
+ return unmarshalNode(this);
189
+ }
190
+ /**
191
+ * Edit the syntax tree to keep it in sync with source code that has been
192
+ * edited.
193
+ *
194
+ * You must describe the edit both in terms of byte offsets and in terms of
195
+ * row/column coordinates.
196
+ */
197
+ edit(edit) {
198
+ marshalEdit(edit);
199
+ C._ts_tree_edit_wasm(this[0]);
200
+ }
201
+ /** Create a new {@link TreeCursor} starting from the root of the tree. */
202
+ walk() {
203
+ return this.rootNode.walk();
204
+ }
205
+ /**
206
+ * Compare this old edited syntax tree to a new syntax tree representing
207
+ * the same document, returning a sequence of ranges whose syntactic
208
+ * structure has changed.
209
+ *
210
+ * For this to work correctly, this syntax tree must have been edited such
211
+ * that its ranges match up to the new tree. Generally, you'll want to
212
+ * call this method right after calling one of the [`Parser::parse`]
213
+ * functions. Call it on the old tree that was passed to parse, and
214
+ * pass the new tree that was returned from `parse`.
215
+ */
216
+ getChangedRanges(other) {
217
+ if (!(other instanceof _Tree)) {
218
+ throw new TypeError("Argument must be a Tree");
219
+ }
220
+ C._ts_tree_get_changed_ranges_wasm(this[0], other[0]);
221
+ const count = C.getValue(TRANSFER_BUFFER, "i32");
222
+ const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
223
+ const result = new Array(count);
224
+ if (count > 0) {
225
+ let address = buffer;
226
+ for (let i2 = 0; i2 < count; i2++) {
227
+ result[i2] = unmarshalRange(address);
228
+ address += SIZE_OF_RANGE;
229
+ }
230
+ C._free(buffer);
231
+ }
232
+ return result;
233
+ }
234
+ /** Get the included ranges that were used to parse the syntax tree. */
235
+ getIncludedRanges() {
236
+ C._ts_tree_included_ranges_wasm(this[0]);
237
+ const count = C.getValue(TRANSFER_BUFFER, "i32");
238
+ const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
239
+ const result = new Array(count);
240
+ if (count > 0) {
241
+ let address = buffer;
242
+ for (let i2 = 0; i2 < count; i2++) {
243
+ result[i2] = unmarshalRange(address);
244
+ address += SIZE_OF_RANGE;
245
+ }
246
+ C._free(buffer);
247
+ }
248
+ return result;
249
+ }
250
+ };
251
+
252
+ // src/tree_cursor.ts
253
+ var TreeCursor = class _TreeCursor {
254
+ static {
255
+ __name(this, "TreeCursor");
256
+ }
257
+ /** @internal */
258
+ [0] = 0;
259
+ // Internal handle for WASM
260
+ /** @internal */
261
+ [1] = 0;
262
+ // Internal handle for WASM
263
+ /** @internal */
264
+ [2] = 0;
265
+ // Internal handle for WASM
266
+ /** @internal */
267
+ [3] = 0;
268
+ // Internal handle for WASM
269
+ /** @internal */
270
+ tree;
271
+ /** @internal */
272
+ constructor(internal, tree) {
273
+ assertInternal(internal);
274
+ this.tree = tree;
275
+ unmarshalTreeCursor(this);
276
+ }
277
+ /** Creates a deep copy of the tree cursor. This allocates new memory. */
278
+ copy() {
279
+ const copy = new _TreeCursor(INTERNAL, this.tree);
280
+ C._ts_tree_cursor_copy_wasm(this.tree[0]);
281
+ unmarshalTreeCursor(copy);
282
+ return copy;
283
+ }
284
+ /** Delete the tree cursor, freeing its resources. */
285
+ delete() {
286
+ marshalTreeCursor(this);
287
+ C._ts_tree_cursor_delete_wasm(this.tree[0]);
288
+ this[0] = this[1] = this[2] = 0;
289
+ }
290
+ /** Get the tree cursor's current {@link Node}. */
291
+ get currentNode() {
292
+ marshalTreeCursor(this);
293
+ C._ts_tree_cursor_current_node_wasm(this.tree[0]);
294
+ return unmarshalNode(this.tree);
295
+ }
296
+ /**
297
+ * Get the numerical field id of this tree cursor's current node.
298
+ *
299
+ * See also {@link TreeCursor#currentFieldName}.
300
+ */
301
+ get currentFieldId() {
302
+ marshalTreeCursor(this);
303
+ return C._ts_tree_cursor_current_field_id_wasm(this.tree[0]);
304
+ }
305
+ /** Get the field name of this tree cursor's current node. */
306
+ get currentFieldName() {
307
+ return this.tree.language.fields[this.currentFieldId];
308
+ }
309
+ /**
310
+ * Get the depth of the cursor's current node relative to the original
311
+ * node that the cursor was constructed with.
312
+ */
313
+ get currentDepth() {
314
+ marshalTreeCursor(this);
315
+ return C._ts_tree_cursor_current_depth_wasm(this.tree[0]);
316
+ }
317
+ /**
318
+ * Get the index of the cursor's current node out of all of the
319
+ * descendants of the original node that the cursor was constructed with.
320
+ */
321
+ get currentDescendantIndex() {
322
+ marshalTreeCursor(this);
323
+ return C._ts_tree_cursor_current_descendant_index_wasm(this.tree[0]);
324
+ }
325
+ /** Get the type of the cursor's current node. */
326
+ get nodeType() {
327
+ return this.tree.language.types[this.nodeTypeId] || "ERROR";
328
+ }
329
+ /** Get the type id of the cursor's current node. */
330
+ get nodeTypeId() {
331
+ marshalTreeCursor(this);
332
+ return C._ts_tree_cursor_current_node_type_id_wasm(this.tree[0]);
333
+ }
334
+ /** Get the state id of the cursor's current node. */
335
+ get nodeStateId() {
336
+ marshalTreeCursor(this);
337
+ return C._ts_tree_cursor_current_node_state_id_wasm(this.tree[0]);
338
+ }
339
+ /** Get the id of the cursor's current node. */
340
+ get nodeId() {
341
+ marshalTreeCursor(this);
342
+ return C._ts_tree_cursor_current_node_id_wasm(this.tree[0]);
343
+ }
344
+ /**
345
+ * Check if the cursor's current node is *named*.
346
+ *
347
+ * Named nodes correspond to named rules in the grammar, whereas
348
+ * *anonymous* nodes correspond to string literals in the grammar.
349
+ */
350
+ get nodeIsNamed() {
351
+ marshalTreeCursor(this);
352
+ return C._ts_tree_cursor_current_node_is_named_wasm(this.tree[0]) === 1;
353
+ }
354
+ /**
355
+ * Check if the cursor's current node is *missing*.
356
+ *
357
+ * Missing nodes are inserted by the parser in order to recover from
358
+ * certain kinds of syntax errors.
359
+ */
360
+ get nodeIsMissing() {
361
+ marshalTreeCursor(this);
362
+ return C._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0]) === 1;
363
+ }
364
+ /** Get the string content of the cursor's current node. */
365
+ get nodeText() {
366
+ marshalTreeCursor(this);
367
+ const startIndex = C._ts_tree_cursor_start_index_wasm(this.tree[0]);
368
+ const endIndex = C._ts_tree_cursor_end_index_wasm(this.tree[0]);
369
+ C._ts_tree_cursor_start_position_wasm(this.tree[0]);
370
+ const startPosition = unmarshalPoint(TRANSFER_BUFFER);
371
+ return getText(this.tree, startIndex, endIndex, startPosition);
372
+ }
373
+ /** Get the start position of the cursor's current node. */
374
+ get startPosition() {
375
+ marshalTreeCursor(this);
376
+ C._ts_tree_cursor_start_position_wasm(this.tree[0]);
377
+ return unmarshalPoint(TRANSFER_BUFFER);
378
+ }
379
+ /** Get the end position of the cursor's current node. */
380
+ get endPosition() {
381
+ marshalTreeCursor(this);
382
+ C._ts_tree_cursor_end_position_wasm(this.tree[0]);
383
+ return unmarshalPoint(TRANSFER_BUFFER);
384
+ }
385
+ /** Get the start index of the cursor's current node. */
386
+ get startIndex() {
387
+ marshalTreeCursor(this);
388
+ return C._ts_tree_cursor_start_index_wasm(this.tree[0]);
389
+ }
390
+ /** Get the end index of the cursor's current node. */
391
+ get endIndex() {
392
+ marshalTreeCursor(this);
393
+ return C._ts_tree_cursor_end_index_wasm(this.tree[0]);
394
+ }
395
+ /**
396
+ * Move this cursor to the first child of its current node.
397
+ *
398
+ * This returns `true` if the cursor successfully moved, and returns
399
+ * `false` if there were no children.
400
+ */
401
+ gotoFirstChild() {
402
+ marshalTreeCursor(this);
403
+ const result = C._ts_tree_cursor_goto_first_child_wasm(this.tree[0]);
404
+ unmarshalTreeCursor(this);
405
+ return result === 1;
406
+ }
407
+ /**
408
+ * Move this cursor to the last child of its current node.
409
+ *
410
+ * This returns `true` if the cursor successfully moved, and returns
411
+ * `false` if there were no children.
412
+ *
413
+ * Note that this function may be slower than
414
+ * {@link TreeCursor#gotoFirstChild} because it needs to
415
+ * iterate through all the children to compute the child's position.
416
+ */
417
+ gotoLastChild() {
418
+ marshalTreeCursor(this);
419
+ const result = C._ts_tree_cursor_goto_last_child_wasm(this.tree[0]);
420
+ unmarshalTreeCursor(this);
421
+ return result === 1;
422
+ }
423
+ /**
424
+ * Move this cursor to the parent of its current node.
425
+ *
426
+ * This returns `true` if the cursor successfully moved, and returns
427
+ * `false` if there was no parent node (the cursor was already on the
428
+ * root node).
429
+ *
430
+ * Note that the node the cursor was constructed with is considered the root
431
+ * of the cursor, and the cursor cannot walk outside this node.
432
+ */
433
+ gotoParent() {
434
+ marshalTreeCursor(this);
435
+ const result = C._ts_tree_cursor_goto_parent_wasm(this.tree[0]);
436
+ unmarshalTreeCursor(this);
437
+ return result === 1;
438
+ }
439
+ /**
440
+ * Move this cursor to the next sibling of its current node.
441
+ *
442
+ * This returns `true` if the cursor successfully moved, and returns
443
+ * `false` if there was no next sibling node.
444
+ *
445
+ * Note that the node the cursor was constructed with is considered the root
446
+ * of the cursor, and the cursor cannot walk outside this node.
447
+ */
448
+ gotoNextSibling() {
449
+ marshalTreeCursor(this);
450
+ const result = C._ts_tree_cursor_goto_next_sibling_wasm(this.tree[0]);
451
+ unmarshalTreeCursor(this);
452
+ return result === 1;
453
+ }
454
+ /**
455
+ * Move this cursor to the previous sibling of its current node.
456
+ *
457
+ * This returns `true` if the cursor successfully moved, and returns
458
+ * `false` if there was no previous sibling node.
459
+ *
460
+ * Note that this function may be slower than
461
+ * {@link TreeCursor#gotoNextSibling} due to how node
462
+ * positions are stored. In the worst case, this will need to iterate
463
+ * through all the children up to the previous sibling node to recalculate
464
+ * its position. Also note that the node the cursor was constructed with is
465
+ * considered the root of the cursor, and the cursor cannot walk outside this node.
466
+ */
467
+ gotoPreviousSibling() {
468
+ marshalTreeCursor(this);
469
+ const result = C._ts_tree_cursor_goto_previous_sibling_wasm(this.tree[0]);
470
+ unmarshalTreeCursor(this);
471
+ return result === 1;
472
+ }
473
+ /**
474
+ * Move the cursor to the node that is the nth descendant of
475
+ * the original node that the cursor was constructed with, where
476
+ * zero represents the original node itself.
477
+ */
478
+ gotoDescendant(goalDescendantIndex) {
479
+ marshalTreeCursor(this);
480
+ C._ts_tree_cursor_goto_descendant_wasm(this.tree[0], goalDescendantIndex);
481
+ unmarshalTreeCursor(this);
482
+ }
483
+ /**
484
+ * Move this cursor to the first child of its current node that contains or
485
+ * starts after the given byte offset.
486
+ *
487
+ * This returns `true` if the cursor successfully moved to a child node, and returns
488
+ * `false` if no such child was found.
489
+ */
490
+ gotoFirstChildForIndex(goalIndex) {
491
+ marshalTreeCursor(this);
492
+ C.setValue(TRANSFER_BUFFER + SIZE_OF_CURSOR, goalIndex, "i32");
493
+ const result = C._ts_tree_cursor_goto_first_child_for_index_wasm(this.tree[0]);
494
+ unmarshalTreeCursor(this);
495
+ return result === 1;
496
+ }
497
+ /**
498
+ * Move this cursor to the first child of its current node that contains or
499
+ * starts after the given byte offset.
500
+ *
501
+ * This returns the index of the child node if one was found, and returns
502
+ * `null` if no such child was found.
503
+ */
504
+ gotoFirstChildForPosition(goalPosition) {
505
+ marshalTreeCursor(this);
506
+ marshalPoint(TRANSFER_BUFFER + SIZE_OF_CURSOR, goalPosition);
507
+ const result = C._ts_tree_cursor_goto_first_child_for_position_wasm(this.tree[0]);
508
+ unmarshalTreeCursor(this);
509
+ return result === 1;
510
+ }
511
+ /**
512
+ * Re-initialize this tree cursor to start at the original node that the
513
+ * cursor was constructed with.
514
+ */
515
+ reset(node) {
516
+ marshalNode(node);
517
+ marshalTreeCursor(this, TRANSFER_BUFFER + SIZE_OF_NODE);
518
+ C._ts_tree_cursor_reset_wasm(this.tree[0]);
519
+ unmarshalTreeCursor(this);
520
+ }
521
+ /**
522
+ * Re-initialize a tree cursor to the same position as another cursor.
523
+ *
524
+ * Unlike {@link TreeCursor#reset}, this will not lose parent
525
+ * information and allows reusing already created cursors.
526
+ */
527
+ resetTo(cursor) {
528
+ marshalTreeCursor(this, TRANSFER_BUFFER);
529
+ marshalTreeCursor(cursor, TRANSFER_BUFFER + SIZE_OF_CURSOR);
530
+ C._ts_tree_cursor_reset_to_wasm(this.tree[0], cursor.tree[0]);
531
+ unmarshalTreeCursor(this);
532
+ }
533
+ };
534
+
535
+ // src/node.ts
536
+ var Node = class {
537
+ static {
538
+ __name(this, "Node");
539
+ }
540
+ /** @internal */
541
+ [0] = 0;
542
+ // Internal handle for WASM
543
+ /** @internal */
544
+ _children;
545
+ /** @internal */
546
+ _namedChildren;
547
+ /** @internal */
548
+ constructor(internal, {
549
+ id,
550
+ tree,
551
+ startIndex,
552
+ startPosition,
553
+ other
554
+ }) {
555
+ assertInternal(internal);
556
+ this[0] = other;
557
+ this.id = id;
558
+ this.tree = tree;
559
+ this.startIndex = startIndex;
560
+ this.startPosition = startPosition;
561
+ }
562
+ /**
563
+ * The numeric id for this node that is unique.
564
+ *
565
+ * Within a given syntax tree, no two nodes have the same id. However:
566
+ *
567
+ * * If a new tree is created based on an older tree, and a node from the old tree is reused in
568
+ * the process, then that node will have the same id in both trees.
569
+ *
570
+ * * A node not marked as having changes does not guarantee it was reused.
571
+ *
572
+ * * If a node is marked as having changed in the old tree, it will not be reused.
573
+ */
574
+ id;
575
+ /** The byte index where this node starts. */
576
+ startIndex;
577
+ /** The position where this node starts. */
578
+ startPosition;
579
+ /** The tree that this node belongs to. */
580
+ tree;
581
+ /** Get this node's type as a numerical id. */
582
+ get typeId() {
583
+ marshalNode(this);
584
+ return C._ts_node_symbol_wasm(this.tree[0]);
585
+ }
586
+ /**
587
+ * Get the node's type as a numerical id as it appears in the grammar,
588
+ * ignoring aliases.
589
+ */
590
+ get grammarId() {
591
+ marshalNode(this);
592
+ return C._ts_node_grammar_symbol_wasm(this.tree[0]);
593
+ }
594
+ /** Get this node's type as a string. */
595
+ get type() {
596
+ return this.tree.language.types[this.typeId] || "ERROR";
597
+ }
598
+ /**
599
+ * Get this node's symbol name as it appears in the grammar, ignoring
600
+ * aliases as a string.
601
+ */
602
+ get grammarType() {
603
+ return this.tree.language.types[this.grammarId] || "ERROR";
604
+ }
605
+ /**
606
+ * Check if this node is *named*.
607
+ *
608
+ * Named nodes correspond to named rules in the grammar, whereas
609
+ * *anonymous* nodes correspond to string literals in the grammar.
610
+ */
611
+ get isNamed() {
612
+ marshalNode(this);
613
+ return C._ts_node_is_named_wasm(this.tree[0]) === 1;
614
+ }
615
+ /**
616
+ * Check if this node is *extra*.
617
+ *
618
+ * Extra nodes represent things like comments, which are not required
619
+ * by the grammar, but can appear anywhere.
620
+ */
621
+ get isExtra() {
622
+ marshalNode(this);
623
+ return C._ts_node_is_extra_wasm(this.tree[0]) === 1;
624
+ }
625
+ /**
626
+ * Check if this node represents a syntax error.
627
+ *
628
+ * Syntax errors represent parts of the code that could not be incorporated
629
+ * into a valid syntax tree.
630
+ */
631
+ get isError() {
632
+ marshalNode(this);
633
+ return C._ts_node_is_error_wasm(this.tree[0]) === 1;
634
+ }
635
+ /**
636
+ * Check if this node is *missing*.
637
+ *
638
+ * Missing nodes are inserted by the parser in order to recover from
639
+ * certain kinds of syntax errors.
640
+ */
641
+ get isMissing() {
642
+ marshalNode(this);
643
+ return C._ts_node_is_missing_wasm(this.tree[0]) === 1;
644
+ }
645
+ /** Check if this node has been edited. */
646
+ get hasChanges() {
647
+ marshalNode(this);
648
+ return C._ts_node_has_changes_wasm(this.tree[0]) === 1;
649
+ }
650
+ /**
651
+ * Check if this node represents a syntax error or contains any syntax
652
+ * errors anywhere within it.
653
+ */
654
+ get hasError() {
655
+ marshalNode(this);
656
+ return C._ts_node_has_error_wasm(this.tree[0]) === 1;
657
+ }
658
+ /** Get the byte index where this node ends. */
659
+ get endIndex() {
660
+ marshalNode(this);
661
+ return C._ts_node_end_index_wasm(this.tree[0]);
662
+ }
663
+ /** Get the position where this node ends. */
664
+ get endPosition() {
665
+ marshalNode(this);
666
+ C._ts_node_end_point_wasm(this.tree[0]);
667
+ return unmarshalPoint(TRANSFER_BUFFER);
668
+ }
669
+ /** Get the string content of this node. */
670
+ get text() {
671
+ return getText(this.tree, this.startIndex, this.endIndex, this.startPosition);
672
+ }
673
+ /** Get this node's parse state. */
674
+ get parseState() {
675
+ marshalNode(this);
676
+ return C._ts_node_parse_state_wasm(this.tree[0]);
677
+ }
678
+ /** Get the parse state after this node. */
679
+ get nextParseState() {
680
+ marshalNode(this);
681
+ return C._ts_node_next_parse_state_wasm(this.tree[0]);
682
+ }
683
+ /** Check if this node is equal to another node. */
684
+ equals(other) {
685
+ return this.tree === other.tree && this.id === other.id;
686
+ }
687
+ /**
688
+ * Get the node's child at the given index, where zero represents the first child.
689
+ *
690
+ * This method is fairly fast, but its cost is technically log(n), so if
691
+ * you might be iterating over a long list of children, you should use
692
+ * {@link Node#children} instead.
693
+ */
694
+ child(index) {
695
+ marshalNode(this);
696
+ C._ts_node_child_wasm(this.tree[0], index);
697
+ return unmarshalNode(this.tree);
698
+ }
699
+ /**
700
+ * Get this node's *named* child at the given index.
701
+ *
702
+ * See also {@link Node#isNamed}.
703
+ * This method is fairly fast, but its cost is technically log(n), so if
704
+ * you might be iterating over a long list of children, you should use
705
+ * {@link Node#namedChildren} instead.
706
+ */
707
+ namedChild(index) {
708
+ marshalNode(this);
709
+ C._ts_node_named_child_wasm(this.tree[0], index);
710
+ return unmarshalNode(this.tree);
711
+ }
712
+ /**
713
+ * Get this node's child with the given numerical field id.
714
+ *
715
+ * See also {@link Node#childForFieldName}. You can
716
+ * convert a field name to an id using {@link Language#fieldIdForName}.
717
+ */
718
+ childForFieldId(fieldId) {
719
+ marshalNode(this);
720
+ C._ts_node_child_by_field_id_wasm(this.tree[0], fieldId);
721
+ return unmarshalNode(this.tree);
722
+ }
723
+ /**
724
+ * Get the first child with the given field name.
725
+ *
726
+ * If multiple children may have the same field name, access them using
727
+ * {@link Node#childrenForFieldName}.
728
+ */
729
+ childForFieldName(fieldName) {
730
+ const fieldId = this.tree.language.fields.indexOf(fieldName);
731
+ if (fieldId !== -1) return this.childForFieldId(fieldId);
732
+ return null;
733
+ }
734
+ /** Get the field name of this node's child at the given index. */
735
+ fieldNameForChild(index) {
736
+ marshalNode(this);
737
+ const address = C._ts_node_field_name_for_child_wasm(this.tree[0], index);
738
+ if (!address) return null;
739
+ return C.AsciiToString(address);
740
+ }
741
+ /** Get the field name of this node's named child at the given index. */
742
+ fieldNameForNamedChild(index) {
743
+ marshalNode(this);
744
+ const address = C._ts_node_field_name_for_named_child_wasm(this.tree[0], index);
745
+ if (!address) return null;
746
+ return C.AsciiToString(address);
747
+ }
748
+ /**
749
+ * Get an array of this node's children with a given field name.
750
+ *
751
+ * See also {@link Node#children}.
752
+ */
753
+ childrenForFieldName(fieldName) {
754
+ const fieldId = this.tree.language.fields.indexOf(fieldName);
755
+ if (fieldId !== -1 && fieldId !== 0) return this.childrenForFieldId(fieldId);
756
+ return [];
757
+ }
758
+ /**
759
+ * Get an array of this node's children with a given field id.
760
+ *
761
+ * See also {@link Node#childrenForFieldName}.
762
+ */
763
+ childrenForFieldId(fieldId) {
764
+ marshalNode(this);
765
+ C._ts_node_children_by_field_id_wasm(this.tree[0], fieldId);
766
+ const count = C.getValue(TRANSFER_BUFFER, "i32");
767
+ const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
768
+ const result = new Array(count);
769
+ if (count > 0) {
770
+ let address = buffer;
771
+ for (let i2 = 0; i2 < count; i2++) {
772
+ result[i2] = unmarshalNode(this.tree, address);
773
+ address += SIZE_OF_NODE;
774
+ }
775
+ C._free(buffer);
776
+ }
777
+ return result;
778
+ }
779
+ /** Get the node's first child that contains or starts after the given byte offset. */
780
+ firstChildForIndex(index) {
781
+ marshalNode(this);
782
+ const address = TRANSFER_BUFFER + SIZE_OF_NODE;
783
+ C.setValue(address, index, "i32");
784
+ C._ts_node_first_child_for_byte_wasm(this.tree[0]);
785
+ return unmarshalNode(this.tree);
786
+ }
787
+ /** Get the node's first named child that contains or starts after the given byte offset. */
788
+ firstNamedChildForIndex(index) {
789
+ marshalNode(this);
790
+ const address = TRANSFER_BUFFER + SIZE_OF_NODE;
791
+ C.setValue(address, index, "i32");
792
+ C._ts_node_first_named_child_for_byte_wasm(this.tree[0]);
793
+ return unmarshalNode(this.tree);
794
+ }
795
+ /** Get this node's number of children. */
796
+ get childCount() {
797
+ marshalNode(this);
798
+ return C._ts_node_child_count_wasm(this.tree[0]);
799
+ }
800
+ /**
801
+ * Get this node's number of *named* children.
802
+ *
803
+ * See also {@link Node#isNamed}.
804
+ */
805
+ get namedChildCount() {
806
+ marshalNode(this);
807
+ return C._ts_node_named_child_count_wasm(this.tree[0]);
808
+ }
809
+ /** Get this node's first child. */
810
+ get firstChild() {
811
+ return this.child(0);
812
+ }
813
+ /**
814
+ * Get this node's first named child.
815
+ *
816
+ * See also {@link Node#isNamed}.
817
+ */
818
+ get firstNamedChild() {
819
+ return this.namedChild(0);
820
+ }
821
+ /** Get this node's last child. */
822
+ get lastChild() {
823
+ return this.child(this.childCount - 1);
824
+ }
825
+ /**
826
+ * Get this node's last named child.
827
+ *
828
+ * See also {@link Node#isNamed}.
829
+ */
830
+ get lastNamedChild() {
831
+ return this.namedChild(this.namedChildCount - 1);
832
+ }
833
+ /**
834
+ * Iterate over this node's children.
835
+ *
836
+ * If you're walking the tree recursively, you may want to use the
837
+ * {@link TreeCursor} APIs directly instead.
838
+ */
839
+ get children() {
840
+ if (!this._children) {
841
+ marshalNode(this);
842
+ C._ts_node_children_wasm(this.tree[0]);
843
+ const count = C.getValue(TRANSFER_BUFFER, "i32");
844
+ const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
845
+ this._children = new Array(count);
846
+ if (count > 0) {
847
+ let address = buffer;
848
+ for (let i2 = 0; i2 < count; i2++) {
849
+ this._children[i2] = unmarshalNode(this.tree, address);
850
+ address += SIZE_OF_NODE;
851
+ }
852
+ C._free(buffer);
853
+ }
854
+ }
855
+ return this._children;
856
+ }
857
+ /**
858
+ * Iterate over this node's named children.
859
+ *
860
+ * See also {@link Node#children}.
861
+ */
862
+ get namedChildren() {
863
+ if (!this._namedChildren) {
864
+ marshalNode(this);
865
+ C._ts_node_named_children_wasm(this.tree[0]);
866
+ const count = C.getValue(TRANSFER_BUFFER, "i32");
867
+ const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
868
+ this._namedChildren = new Array(count);
869
+ if (count > 0) {
870
+ let address = buffer;
871
+ for (let i2 = 0; i2 < count; i2++) {
872
+ this._namedChildren[i2] = unmarshalNode(this.tree, address);
873
+ address += SIZE_OF_NODE;
874
+ }
875
+ C._free(buffer);
876
+ }
877
+ }
878
+ return this._namedChildren;
879
+ }
880
+ /**
881
+ * Get the descendants of this node that are the given type, or in the given types array.
882
+ *
883
+ * The types array should contain node type strings, which can be retrieved from {@link Language#types}.
884
+ *
885
+ * Additionally, a `startPosition` and `endPosition` can be passed in to restrict the search to a byte range.
886
+ */
887
+ descendantsOfType(types, startPosition = ZERO_POINT, endPosition = ZERO_POINT) {
888
+ if (!Array.isArray(types)) types = [types];
889
+ const symbols = [];
890
+ const typesBySymbol = this.tree.language.types;
891
+ for (let i2 = 0, n = typesBySymbol.length; i2 < n; i2++) {
892
+ if (types.includes(typesBySymbol[i2])) {
893
+ symbols.push(i2);
894
+ }
895
+ }
896
+ const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length);
897
+ for (let i2 = 0, n = symbols.length; i2 < n; i2++) {
898
+ C.setValue(symbolsAddress + i2 * SIZE_OF_INT, symbols[i2], "i32");
899
+ }
900
+ marshalNode(this);
901
+ C._ts_node_descendants_of_type_wasm(
902
+ this.tree[0],
903
+ symbolsAddress,
904
+ symbols.length,
905
+ startPosition.row,
906
+ startPosition.column,
907
+ endPosition.row,
908
+ endPosition.column
909
+ );
910
+ const descendantCount = C.getValue(TRANSFER_BUFFER, "i32");
911
+ const descendantAddress = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
912
+ const result = new Array(descendantCount);
913
+ if (descendantCount > 0) {
914
+ let address = descendantAddress;
915
+ for (let i2 = 0; i2 < descendantCount; i2++) {
916
+ result[i2] = unmarshalNode(this.tree, address);
917
+ address += SIZE_OF_NODE;
918
+ }
919
+ }
920
+ C._free(descendantAddress);
921
+ C._free(symbolsAddress);
922
+ return result;
923
+ }
924
+ /** Get this node's next sibling. */
925
+ get nextSibling() {
926
+ marshalNode(this);
927
+ C._ts_node_next_sibling_wasm(this.tree[0]);
928
+ return unmarshalNode(this.tree);
929
+ }
930
+ /** Get this node's previous sibling. */
931
+ get previousSibling() {
932
+ marshalNode(this);
933
+ C._ts_node_prev_sibling_wasm(this.tree[0]);
934
+ return unmarshalNode(this.tree);
935
+ }
936
+ /**
937
+ * Get this node's next *named* sibling.
938
+ *
939
+ * See also {@link Node#isNamed}.
940
+ */
941
+ get nextNamedSibling() {
942
+ marshalNode(this);
943
+ C._ts_node_next_named_sibling_wasm(this.tree[0]);
944
+ return unmarshalNode(this.tree);
945
+ }
946
+ /**
947
+ * Get this node's previous *named* sibling.
948
+ *
949
+ * See also {@link Node#isNamed}.
950
+ */
951
+ get previousNamedSibling() {
952
+ marshalNode(this);
953
+ C._ts_node_prev_named_sibling_wasm(this.tree[0]);
954
+ return unmarshalNode(this.tree);
955
+ }
956
+ /** Get the node's number of descendants, including one for the node itself. */
957
+ get descendantCount() {
958
+ marshalNode(this);
959
+ return C._ts_node_descendant_count_wasm(this.tree[0]);
960
+ }
961
+ /**
962
+ * Get this node's immediate parent.
963
+ * Prefer {@link Node#childWithDescendant} for iterating over this node's ancestors.
964
+ */
965
+ get parent() {
966
+ marshalNode(this);
967
+ C._ts_node_parent_wasm(this.tree[0]);
968
+ return unmarshalNode(this.tree);
969
+ }
970
+ /**
971
+ * Get the node that contains `descendant`.
972
+ *
973
+ * Note that this can return `descendant` itself.
974
+ */
975
+ childWithDescendant(descendant) {
976
+ marshalNode(this);
977
+ marshalNode(descendant);
978
+ C._ts_node_child_with_descendant_wasm(this.tree[0]);
979
+ return unmarshalNode(this.tree);
980
+ }
981
+ /** Get the smallest node within this node that spans the given byte range. */
982
+ descendantForIndex(start2, end = start2) {
983
+ if (typeof start2 !== "number" || typeof end !== "number") {
984
+ throw new Error("Arguments must be numbers");
985
+ }
986
+ marshalNode(this);
987
+ const address = TRANSFER_BUFFER + SIZE_OF_NODE;
988
+ C.setValue(address, start2, "i32");
989
+ C.setValue(address + SIZE_OF_INT, end, "i32");
990
+ C._ts_node_descendant_for_index_wasm(this.tree[0]);
991
+ return unmarshalNode(this.tree);
992
+ }
993
+ /** Get the smallest named node within this node that spans the given byte range. */
994
+ namedDescendantForIndex(start2, end = start2) {
995
+ if (typeof start2 !== "number" || typeof end !== "number") {
996
+ throw new Error("Arguments must be numbers");
997
+ }
998
+ marshalNode(this);
999
+ const address = TRANSFER_BUFFER + SIZE_OF_NODE;
1000
+ C.setValue(address, start2, "i32");
1001
+ C.setValue(address + SIZE_OF_INT, end, "i32");
1002
+ C._ts_node_named_descendant_for_index_wasm(this.tree[0]);
1003
+ return unmarshalNode(this.tree);
1004
+ }
1005
+ /** Get the smallest node within this node that spans the given point range. */
1006
+ descendantForPosition(start2, end = start2) {
1007
+ if (!isPoint(start2) || !isPoint(end)) {
1008
+ throw new Error("Arguments must be {row, column} objects");
1009
+ }
1010
+ marshalNode(this);
1011
+ const address = TRANSFER_BUFFER + SIZE_OF_NODE;
1012
+ marshalPoint(address, start2);
1013
+ marshalPoint(address + SIZE_OF_POINT, end);
1014
+ C._ts_node_descendant_for_position_wasm(this.tree[0]);
1015
+ return unmarshalNode(this.tree);
1016
+ }
1017
+ /** Get the smallest named node within this node that spans the given point range. */
1018
+ namedDescendantForPosition(start2, end = start2) {
1019
+ if (!isPoint(start2) || !isPoint(end)) {
1020
+ throw new Error("Arguments must be {row, column} objects");
1021
+ }
1022
+ marshalNode(this);
1023
+ const address = TRANSFER_BUFFER + SIZE_OF_NODE;
1024
+ marshalPoint(address, start2);
1025
+ marshalPoint(address + SIZE_OF_POINT, end);
1026
+ C._ts_node_named_descendant_for_position_wasm(this.tree[0]);
1027
+ return unmarshalNode(this.tree);
1028
+ }
1029
+ /**
1030
+ * Create a new {@link TreeCursor} starting from this node.
1031
+ *
1032
+ * Note that the given node is considered the root of the cursor,
1033
+ * and the cursor cannot walk outside this node.
1034
+ */
1035
+ walk() {
1036
+ marshalNode(this);
1037
+ C._ts_tree_cursor_new_wasm(this.tree[0]);
1038
+ return new TreeCursor(INTERNAL, this.tree);
1039
+ }
1040
+ /**
1041
+ * Edit this node to keep it in-sync with source code that has been edited.
1042
+ *
1043
+ * This function is only rarely needed. When you edit a syntax tree with
1044
+ * the {@link Tree#edit} method, all of the nodes that you retrieve from
1045
+ * the tree afterward will already reflect the edit. You only need to
1046
+ * use {@link Node#edit} when you have a specific {@link Node} instance that
1047
+ * you want to keep and continue to use after an edit.
1048
+ */
1049
+ edit(edit) {
1050
+ if (this.startIndex >= edit.oldEndIndex) {
1051
+ this.startIndex = edit.newEndIndex + (this.startIndex - edit.oldEndIndex);
1052
+ let subbedPointRow;
1053
+ let subbedPointColumn;
1054
+ if (this.startPosition.row > edit.oldEndPosition.row) {
1055
+ subbedPointRow = this.startPosition.row - edit.oldEndPosition.row;
1056
+ subbedPointColumn = this.startPosition.column;
1057
+ } else {
1058
+ subbedPointRow = 0;
1059
+ subbedPointColumn = this.startPosition.column;
1060
+ if (this.startPosition.column >= edit.oldEndPosition.column) {
1061
+ subbedPointColumn = this.startPosition.column - edit.oldEndPosition.column;
1062
+ }
1063
+ }
1064
+ if (subbedPointRow > 0) {
1065
+ this.startPosition.row += subbedPointRow;
1066
+ this.startPosition.column = subbedPointColumn;
1067
+ } else {
1068
+ this.startPosition.column += subbedPointColumn;
1069
+ }
1070
+ } else if (this.startIndex > edit.startIndex) {
1071
+ this.startIndex = edit.newEndIndex;
1072
+ this.startPosition.row = edit.newEndPosition.row;
1073
+ this.startPosition.column = edit.newEndPosition.column;
1074
+ }
1075
+ }
1076
+ /** Get the S-expression representation of this node. */
1077
+ toString() {
1078
+ marshalNode(this);
1079
+ const address = C._ts_node_to_string_wasm(this.tree[0]);
1080
+ const result = C.AsciiToString(address);
1081
+ C._free(address);
1082
+ return result;
1083
+ }
1084
+ };
1085
+
1086
+ // src/marshal.ts
1087
+ function unmarshalCaptures(query, tree, address, patternIndex, result) {
1088
+ for (let i2 = 0, n = result.length; i2 < n; i2++) {
1089
+ const captureIndex = C.getValue(address, "i32");
1090
+ address += SIZE_OF_INT;
1091
+ const node = unmarshalNode(tree, address);
1092
+ address += SIZE_OF_NODE;
1093
+ result[i2] = { patternIndex, name: query.captureNames[captureIndex], node };
1094
+ }
1095
+ return address;
1096
+ }
1097
+ __name(unmarshalCaptures, "unmarshalCaptures");
1098
+ function marshalNode(node) {
1099
+ let address = TRANSFER_BUFFER;
1100
+ C.setValue(address, node.id, "i32");
1101
+ address += SIZE_OF_INT;
1102
+ C.setValue(address, node.startIndex, "i32");
1103
+ address += SIZE_OF_INT;
1104
+ C.setValue(address, node.startPosition.row, "i32");
1105
+ address += SIZE_OF_INT;
1106
+ C.setValue(address, node.startPosition.column, "i32");
1107
+ address += SIZE_OF_INT;
1108
+ C.setValue(address, node[0], "i32");
1109
+ }
1110
+ __name(marshalNode, "marshalNode");
1111
+ function unmarshalNode(tree, address = TRANSFER_BUFFER) {
1112
+ const id = C.getValue(address, "i32");
1113
+ address += SIZE_OF_INT;
1114
+ if (id === 0) return null;
1115
+ const index = C.getValue(address, "i32");
1116
+ address += SIZE_OF_INT;
1117
+ const row = C.getValue(address, "i32");
1118
+ address += SIZE_OF_INT;
1119
+ const column = C.getValue(address, "i32");
1120
+ address += SIZE_OF_INT;
1121
+ const other = C.getValue(address, "i32");
1122
+ const result = new Node(INTERNAL, {
1123
+ id,
1124
+ tree,
1125
+ startIndex: index,
1126
+ startPosition: { row, column },
1127
+ other
1128
+ });
1129
+ return result;
1130
+ }
1131
+ __name(unmarshalNode, "unmarshalNode");
1132
+ function marshalTreeCursor(cursor, address = TRANSFER_BUFFER) {
1133
+ C.setValue(address + 0 * SIZE_OF_INT, cursor[0], "i32");
1134
+ C.setValue(address + 1 * SIZE_OF_INT, cursor[1], "i32");
1135
+ C.setValue(address + 2 * SIZE_OF_INT, cursor[2], "i32");
1136
+ C.setValue(address + 3 * SIZE_OF_INT, cursor[3], "i32");
1137
+ }
1138
+ __name(marshalTreeCursor, "marshalTreeCursor");
1139
+ function unmarshalTreeCursor(cursor) {
1140
+ cursor[0] = C.getValue(TRANSFER_BUFFER + 0 * SIZE_OF_INT, "i32");
1141
+ cursor[1] = C.getValue(TRANSFER_BUFFER + 1 * SIZE_OF_INT, "i32");
1142
+ cursor[2] = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
1143
+ cursor[3] = C.getValue(TRANSFER_BUFFER + 3 * SIZE_OF_INT, "i32");
1144
+ }
1145
+ __name(unmarshalTreeCursor, "unmarshalTreeCursor");
1146
+ function marshalPoint(address, point) {
1147
+ C.setValue(address, point.row, "i32");
1148
+ C.setValue(address + SIZE_OF_INT, point.column, "i32");
1149
+ }
1150
+ __name(marshalPoint, "marshalPoint");
1151
+ function unmarshalPoint(address) {
1152
+ const result = {
1153
+ row: C.getValue(address, "i32") >>> 0,
1154
+ column: C.getValue(address + SIZE_OF_INT, "i32") >>> 0
1155
+ };
1156
+ return result;
1157
+ }
1158
+ __name(unmarshalPoint, "unmarshalPoint");
1159
+ function marshalRange(address, range) {
1160
+ marshalPoint(address, range.startPosition);
1161
+ address += SIZE_OF_POINT;
1162
+ marshalPoint(address, range.endPosition);
1163
+ address += SIZE_OF_POINT;
1164
+ C.setValue(address, range.startIndex, "i32");
1165
+ address += SIZE_OF_INT;
1166
+ C.setValue(address, range.endIndex, "i32");
1167
+ address += SIZE_OF_INT;
1168
+ }
1169
+ __name(marshalRange, "marshalRange");
1170
+ function unmarshalRange(address) {
1171
+ const result = {};
1172
+ result.startPosition = unmarshalPoint(address);
1173
+ address += SIZE_OF_POINT;
1174
+ result.endPosition = unmarshalPoint(address);
1175
+ address += SIZE_OF_POINT;
1176
+ result.startIndex = C.getValue(address, "i32") >>> 0;
1177
+ address += SIZE_OF_INT;
1178
+ result.endIndex = C.getValue(address, "i32") >>> 0;
1179
+ return result;
1180
+ }
1181
+ __name(unmarshalRange, "unmarshalRange");
1182
+ function marshalEdit(edit, address = TRANSFER_BUFFER) {
1183
+ marshalPoint(address, edit.startPosition);
1184
+ address += SIZE_OF_POINT;
1185
+ marshalPoint(address, edit.oldEndPosition);
1186
+ address += SIZE_OF_POINT;
1187
+ marshalPoint(address, edit.newEndPosition);
1188
+ address += SIZE_OF_POINT;
1189
+ C.setValue(address, edit.startIndex, "i32");
1190
+ address += SIZE_OF_INT;
1191
+ C.setValue(address, edit.oldEndIndex, "i32");
1192
+ address += SIZE_OF_INT;
1193
+ C.setValue(address, edit.newEndIndex, "i32");
1194
+ address += SIZE_OF_INT;
1195
+ }
1196
+ __name(marshalEdit, "marshalEdit");
1197
+ function unmarshalLanguageMetadata(address) {
1198
+ const result = {};
1199
+ result.major_version = C.getValue(address, "i32");
1200
+ address += SIZE_OF_INT;
1201
+ result.minor_version = C.getValue(address, "i32");
1202
+ address += SIZE_OF_INT;
1203
+ result.field_count = C.getValue(address, "i32");
1204
+ return result;
1205
+ }
1206
+ __name(unmarshalLanguageMetadata, "unmarshalLanguageMetadata");
1207
+
1208
+ // src/query.ts
1209
+ var PREDICATE_STEP_TYPE_CAPTURE = 1;
1210
+ var PREDICATE_STEP_TYPE_STRING = 2;
1211
+ var QUERY_WORD_REGEX = /[\w-]+/g;
1212
+ var CaptureQuantifier = {
1213
+ Zero: 0,
1214
+ ZeroOrOne: 1,
1215
+ ZeroOrMore: 2,
1216
+ One: 3,
1217
+ OneOrMore: 4
1218
+ };
1219
+ var isCaptureStep = /* @__PURE__ */ __name((step) => step.type === "capture", "isCaptureStep");
1220
+ var isStringStep = /* @__PURE__ */ __name((step) => step.type === "string", "isStringStep");
1221
+ var QueryErrorKind = {
1222
+ Syntax: 1,
1223
+ NodeName: 2,
1224
+ FieldName: 3,
1225
+ CaptureName: 4,
1226
+ PatternStructure: 5
1227
+ };
1228
+ var QueryError = class _QueryError extends Error {
1229
+ constructor(kind, info2, index, length) {
1230
+ super(_QueryError.formatMessage(kind, info2));
1231
+ this.kind = kind;
1232
+ this.info = info2;
1233
+ this.index = index;
1234
+ this.length = length;
1235
+ this.name = "QueryError";
1236
+ }
1237
+ static {
1238
+ __name(this, "QueryError");
1239
+ }
1240
+ /** Formats an error message based on the error kind and info */
1241
+ static formatMessage(kind, info2) {
1242
+ switch (kind) {
1243
+ case QueryErrorKind.NodeName:
1244
+ return `Bad node name '${info2.word}'`;
1245
+ case QueryErrorKind.FieldName:
1246
+ return `Bad field name '${info2.word}'`;
1247
+ case QueryErrorKind.CaptureName:
1248
+ return `Bad capture name @${info2.word}`;
1249
+ case QueryErrorKind.PatternStructure:
1250
+ return `Bad pattern structure at offset ${info2.suffix}`;
1251
+ case QueryErrorKind.Syntax:
1252
+ return `Bad syntax at offset ${info2.suffix}`;
1253
+ }
1254
+ }
1255
+ };
1256
+ function parseAnyPredicate(steps, index, operator, textPredicates) {
1257
+ if (steps.length !== 3) {
1258
+ throw new Error(
1259
+ `Wrong number of arguments to \`#${operator}\` predicate. Expected 2, got ${steps.length - 1}`
1260
+ );
1261
+ }
1262
+ if (!isCaptureStep(steps[1])) {
1263
+ throw new Error(
1264
+ `First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}"`
1265
+ );
1266
+ }
1267
+ const isPositive = operator === "eq?" || operator === "any-eq?";
1268
+ const matchAll = !operator.startsWith("any-");
1269
+ if (isCaptureStep(steps[2])) {
1270
+ const captureName1 = steps[1].name;
1271
+ const captureName2 = steps[2].name;
1272
+ textPredicates[index].push((captures) => {
1273
+ const nodes1 = [];
1274
+ const nodes2 = [];
1275
+ for (const c of captures) {
1276
+ if (c.name === captureName1) nodes1.push(c.node);
1277
+ if (c.name === captureName2) nodes2.push(c.node);
1278
+ }
1279
+ const compare = /* @__PURE__ */ __name((n1, n2, positive) => {
1280
+ return positive ? n1.text === n2.text : n1.text !== n2.text;
1281
+ }, "compare");
1282
+ return matchAll ? nodes1.every((n1) => nodes2.some((n2) => compare(n1, n2, isPositive))) : nodes1.some((n1) => nodes2.some((n2) => compare(n1, n2, isPositive)));
1283
+ });
1284
+ } else {
1285
+ const captureName = steps[1].name;
1286
+ const stringValue = steps[2].value;
1287
+ const matches = /* @__PURE__ */ __name((n) => n.text === stringValue, "matches");
1288
+ const doesNotMatch = /* @__PURE__ */ __name((n) => n.text !== stringValue, "doesNotMatch");
1289
+ textPredicates[index].push((captures) => {
1290
+ const nodes = [];
1291
+ for (const c of captures) {
1292
+ if (c.name === captureName) nodes.push(c.node);
1293
+ }
1294
+ const test = isPositive ? matches : doesNotMatch;
1295
+ return matchAll ? nodes.every(test) : nodes.some(test);
1296
+ });
1297
+ }
1298
+ }
1299
+ __name(parseAnyPredicate, "parseAnyPredicate");
1300
+ function parseMatchPredicate(steps, index, operator, textPredicates) {
1301
+ if (steps.length !== 3) {
1302
+ throw new Error(
1303
+ `Wrong number of arguments to \`#${operator}\` predicate. Expected 2, got ${steps.length - 1}.`
1304
+ );
1305
+ }
1306
+ if (steps[1].type !== "capture") {
1307
+ throw new Error(
1308
+ `First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}".`
1309
+ );
1310
+ }
1311
+ if (steps[2].type !== "string") {
1312
+ throw new Error(
1313
+ `Second argument of \`#${operator}\` predicate must be a string. Got @${steps[2].name}.`
1314
+ );
1315
+ }
1316
+ const isPositive = operator === "match?" || operator === "any-match?";
1317
+ const matchAll = !operator.startsWith("any-");
1318
+ const captureName = steps[1].name;
1319
+ const regex = new RegExp(steps[2].value);
1320
+ textPredicates[index].push((captures) => {
1321
+ const nodes = [];
1322
+ for (const c of captures) {
1323
+ if (c.name === captureName) nodes.push(c.node.text);
1324
+ }
1325
+ const test = /* @__PURE__ */ __name((text, positive) => {
1326
+ return positive ? regex.test(text) : !regex.test(text);
1327
+ }, "test");
1328
+ if (nodes.length === 0) return !isPositive;
1329
+ return matchAll ? nodes.every((text) => test(text, isPositive)) : nodes.some((text) => test(text, isPositive));
1330
+ });
1331
+ }
1332
+ __name(parseMatchPredicate, "parseMatchPredicate");
1333
+ function parseAnyOfPredicate(steps, index, operator, textPredicates) {
1334
+ if (steps.length < 2) {
1335
+ throw new Error(
1336
+ `Wrong number of arguments to \`#${operator}\` predicate. Expected at least 1. Got ${steps.length - 1}.`
1337
+ );
1338
+ }
1339
+ if (steps[1].type !== "capture") {
1340
+ throw new Error(
1341
+ `First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}".`
1342
+ );
1343
+ }
1344
+ const isPositive = operator === "any-of?";
1345
+ const captureName = steps[1].name;
1346
+ const stringSteps = steps.slice(2);
1347
+ if (!stringSteps.every(isStringStep)) {
1348
+ throw new Error(
1349
+ `Arguments to \`#${operator}\` predicate must be strings.".`
1350
+ );
1351
+ }
1352
+ const values = stringSteps.map((s) => s.value);
1353
+ textPredicates[index].push((captures) => {
1354
+ const nodes = [];
1355
+ for (const c of captures) {
1356
+ if (c.name === captureName) nodes.push(c.node.text);
1357
+ }
1358
+ if (nodes.length === 0) return !isPositive;
1359
+ return nodes.every((text) => values.includes(text)) === isPositive;
1360
+ });
1361
+ }
1362
+ __name(parseAnyOfPredicate, "parseAnyOfPredicate");
1363
+ function parseIsPredicate(steps, index, operator, assertedProperties, refutedProperties) {
1364
+ if (steps.length < 2 || steps.length > 3) {
1365
+ throw new Error(
1366
+ `Wrong number of arguments to \`#${operator}\` predicate. Expected 1 or 2. Got ${steps.length - 1}.`
1367
+ );
1368
+ }
1369
+ if (!steps.every(isStringStep)) {
1370
+ throw new Error(
1371
+ `Arguments to \`#${operator}\` predicate must be strings.".`
1372
+ );
1373
+ }
1374
+ const properties = operator === "is?" ? assertedProperties : refutedProperties;
1375
+ if (!properties[index]) properties[index] = {};
1376
+ properties[index][steps[1].value] = steps[2]?.value ?? null;
1377
+ }
1378
+ __name(parseIsPredicate, "parseIsPredicate");
1379
+ function parseSetDirective(steps, index, setProperties) {
1380
+ if (steps.length < 2 || steps.length > 3) {
1381
+ throw new Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${steps.length - 1}.`);
1382
+ }
1383
+ if (!steps.every(isStringStep)) {
1384
+ throw new Error(`Arguments to \`#set!\` predicate must be strings.".`);
1385
+ }
1386
+ if (!setProperties[index]) setProperties[index] = {};
1387
+ setProperties[index][steps[1].value] = steps[2]?.value ?? null;
1388
+ }
1389
+ __name(parseSetDirective, "parseSetDirective");
1390
+ function parsePattern(index, stepType, stepValueId, captureNames, stringValues, steps, textPredicates, predicates, setProperties, assertedProperties, refutedProperties) {
1391
+ if (stepType === PREDICATE_STEP_TYPE_CAPTURE) {
1392
+ const name2 = captureNames[stepValueId];
1393
+ steps.push({ type: "capture", name: name2 });
1394
+ } else if (stepType === PREDICATE_STEP_TYPE_STRING) {
1395
+ steps.push({ type: "string", value: stringValues[stepValueId] });
1396
+ } else if (steps.length > 0) {
1397
+ if (steps[0].type !== "string") {
1398
+ throw new Error("Predicates must begin with a literal value");
1399
+ }
1400
+ const operator = steps[0].value;
1401
+ switch (operator) {
1402
+ case "any-not-eq?":
1403
+ case "not-eq?":
1404
+ case "any-eq?":
1405
+ case "eq?":
1406
+ parseAnyPredicate(steps, index, operator, textPredicates);
1407
+ break;
1408
+ case "any-not-match?":
1409
+ case "not-match?":
1410
+ case "any-match?":
1411
+ case "match?":
1412
+ parseMatchPredicate(steps, index, operator, textPredicates);
1413
+ break;
1414
+ case "not-any-of?":
1415
+ case "any-of?":
1416
+ parseAnyOfPredicate(steps, index, operator, textPredicates);
1417
+ break;
1418
+ case "is?":
1419
+ case "is-not?":
1420
+ parseIsPredicate(steps, index, operator, assertedProperties, refutedProperties);
1421
+ break;
1422
+ case "set!":
1423
+ parseSetDirective(steps, index, setProperties);
1424
+ break;
1425
+ default:
1426
+ predicates[index].push({ operator, operands: steps.slice(1) });
1427
+ }
1428
+ steps.length = 0;
1429
+ }
1430
+ }
1431
+ __name(parsePattern, "parsePattern");
1432
+ var Query = class {
1433
+ static {
1434
+ __name(this, "Query");
1435
+ }
1436
+ /** @internal */
1437
+ [0] = 0;
1438
+ // Internal handle for WASM
1439
+ /** @internal */
1440
+ exceededMatchLimit;
1441
+ /** @internal */
1442
+ textPredicates;
1443
+ /** The names of the captures used in the query. */
1444
+ captureNames;
1445
+ /** The quantifiers of the captures used in the query. */
1446
+ captureQuantifiers;
1447
+ /**
1448
+ * The other user-defined predicates associated with the given index.
1449
+ *
1450
+ * This includes predicates with operators other than:
1451
+ * - `match?`
1452
+ * - `eq?` and `not-eq?`
1453
+ * - `any-of?` and `not-any-of?`
1454
+ * - `is?` and `is-not?`
1455
+ * - `set!`
1456
+ */
1457
+ predicates;
1458
+ /** The properties for predicates with the operator `set!`. */
1459
+ setProperties;
1460
+ /** The properties for predicates with the operator `is?`. */
1461
+ assertedProperties;
1462
+ /** The properties for predicates with the operator `is-not?`. */
1463
+ refutedProperties;
1464
+ /** The maximum number of in-progress matches for this cursor. */
1465
+ matchLimit;
1466
+ /**
1467
+ * Create a new query from a string containing one or more S-expression
1468
+ * patterns.
1469
+ *
1470
+ * The query is associated with a particular language, and can only be run
1471
+ * on syntax nodes parsed with that language. References to Queries can be
1472
+ * shared between multiple threads.
1473
+ *
1474
+ * @link {@see https://tree-sitter.github.io/tree-sitter/using-parsers/queries}
1475
+ */
1476
+ constructor(language, source) {
1477
+ const sourceLength = C.lengthBytesUTF8(source);
1478
+ const sourceAddress = C._malloc(sourceLength + 1);
1479
+ C.stringToUTF8(source, sourceAddress, sourceLength + 1);
1480
+ const address = C._ts_query_new(
1481
+ language[0],
1482
+ sourceAddress,
1483
+ sourceLength,
1484
+ TRANSFER_BUFFER,
1485
+ TRANSFER_BUFFER + SIZE_OF_INT
1486
+ );
1487
+ if (!address) {
1488
+ const errorId = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
1489
+ const errorByte = C.getValue(TRANSFER_BUFFER, "i32");
1490
+ const errorIndex = C.UTF8ToString(sourceAddress, errorByte).length;
1491
+ const suffix = source.slice(errorIndex, errorIndex + 100).split("\n")[0];
1492
+ const word = suffix.match(QUERY_WORD_REGEX)?.[0] ?? "";
1493
+ C._free(sourceAddress);
1494
+ switch (errorId) {
1495
+ case QueryErrorKind.Syntax:
1496
+ throw new QueryError(QueryErrorKind.Syntax, { suffix: `${errorIndex}: '${suffix}'...` }, errorIndex, 0);
1497
+ case QueryErrorKind.NodeName:
1498
+ throw new QueryError(errorId, { word }, errorIndex, word.length);
1499
+ case QueryErrorKind.FieldName:
1500
+ throw new QueryError(errorId, { word }, errorIndex, word.length);
1501
+ case QueryErrorKind.CaptureName:
1502
+ throw new QueryError(errorId, { word }, errorIndex, word.length);
1503
+ case QueryErrorKind.PatternStructure:
1504
+ throw new QueryError(errorId, { suffix: `${errorIndex}: '${suffix}'...` }, errorIndex, 0);
1505
+ }
1506
+ }
1507
+ const stringCount = C._ts_query_string_count(address);
1508
+ const captureCount = C._ts_query_capture_count(address);
1509
+ const patternCount = C._ts_query_pattern_count(address);
1510
+ const captureNames = new Array(captureCount);
1511
+ const captureQuantifiers = new Array(patternCount);
1512
+ const stringValues = new Array(stringCount);
1513
+ for (let i2 = 0; i2 < captureCount; i2++) {
1514
+ const nameAddress = C._ts_query_capture_name_for_id(
1515
+ address,
1516
+ i2,
1517
+ TRANSFER_BUFFER
1518
+ );
1519
+ const nameLength = C.getValue(TRANSFER_BUFFER, "i32");
1520
+ captureNames[i2] = C.UTF8ToString(nameAddress, nameLength);
1521
+ }
1522
+ for (let i2 = 0; i2 < patternCount; i2++) {
1523
+ const captureQuantifiersArray = new Array(captureCount);
1524
+ for (let j = 0; j < captureCount; j++) {
1525
+ const quantifier = C._ts_query_capture_quantifier_for_id(address, i2, j);
1526
+ captureQuantifiersArray[j] = quantifier;
1527
+ }
1528
+ captureQuantifiers[i2] = captureQuantifiersArray;
1529
+ }
1530
+ for (let i2 = 0; i2 < stringCount; i2++) {
1531
+ const valueAddress = C._ts_query_string_value_for_id(
1532
+ address,
1533
+ i2,
1534
+ TRANSFER_BUFFER
1535
+ );
1536
+ const nameLength = C.getValue(TRANSFER_BUFFER, "i32");
1537
+ stringValues[i2] = C.UTF8ToString(valueAddress, nameLength);
1538
+ }
1539
+ const setProperties = new Array(patternCount);
1540
+ const assertedProperties = new Array(patternCount);
1541
+ const refutedProperties = new Array(patternCount);
1542
+ const predicates = new Array(patternCount);
1543
+ const textPredicates = new Array(patternCount);
1544
+ for (let i2 = 0; i2 < patternCount; i2++) {
1545
+ const predicatesAddress = C._ts_query_predicates_for_pattern(address, i2, TRANSFER_BUFFER);
1546
+ const stepCount = C.getValue(TRANSFER_BUFFER, "i32");
1547
+ predicates[i2] = [];
1548
+ textPredicates[i2] = [];
1549
+ const steps = new Array();
1550
+ let stepAddress = predicatesAddress;
1551
+ for (let j = 0; j < stepCount; j++) {
1552
+ const stepType = C.getValue(stepAddress, "i32");
1553
+ stepAddress += SIZE_OF_INT;
1554
+ const stepValueId = C.getValue(stepAddress, "i32");
1555
+ stepAddress += SIZE_OF_INT;
1556
+ parsePattern(
1557
+ i2,
1558
+ stepType,
1559
+ stepValueId,
1560
+ captureNames,
1561
+ stringValues,
1562
+ steps,
1563
+ textPredicates,
1564
+ predicates,
1565
+ setProperties,
1566
+ assertedProperties,
1567
+ refutedProperties
1568
+ );
1569
+ }
1570
+ Object.freeze(textPredicates[i2]);
1571
+ Object.freeze(predicates[i2]);
1572
+ Object.freeze(setProperties[i2]);
1573
+ Object.freeze(assertedProperties[i2]);
1574
+ Object.freeze(refutedProperties[i2]);
1575
+ }
1576
+ C._free(sourceAddress);
1577
+ this[0] = address;
1578
+ this.captureNames = captureNames;
1579
+ this.captureQuantifiers = captureQuantifiers;
1580
+ this.textPredicates = textPredicates;
1581
+ this.predicates = predicates;
1582
+ this.setProperties = setProperties;
1583
+ this.assertedProperties = assertedProperties;
1584
+ this.refutedProperties = refutedProperties;
1585
+ this.exceededMatchLimit = false;
1586
+ }
1587
+ /** Delete the query, freeing its resources. */
1588
+ delete() {
1589
+ C._ts_query_delete(this[0]);
1590
+ this[0] = 0;
1591
+ }
1592
+ /**
1593
+ * Iterate over all of the matches in the order that they were found.
1594
+ *
1595
+ * Each match contains the index of the pattern that matched, and a list of
1596
+ * captures. Because multiple patterns can match the same set of nodes,
1597
+ * one match may contain captures that appear *before* some of the
1598
+ * captures from a previous match.
1599
+ *
1600
+ * @param {Node} node - The node to execute the query on.
1601
+ *
1602
+ * @param {QueryOptions} options - Options for query execution.
1603
+ */
1604
+ matches(node, options = {}) {
1605
+ const startPosition = options.startPosition ?? ZERO_POINT;
1606
+ const endPosition = options.endPosition ?? ZERO_POINT;
1607
+ const startIndex = options.startIndex ?? 0;
1608
+ const endIndex = options.endIndex ?? 0;
1609
+ const matchLimit = options.matchLimit ?? 4294967295;
1610
+ const maxStartDepth = options.maxStartDepth ?? 4294967295;
1611
+ const timeoutMicros = options.timeoutMicros ?? 0;
1612
+ const progressCallback = options.progressCallback;
1613
+ if (typeof matchLimit !== "number") {
1614
+ throw new Error("Arguments must be numbers");
1615
+ }
1616
+ this.matchLimit = matchLimit;
1617
+ if (endIndex !== 0 && startIndex > endIndex) {
1618
+ throw new Error("`startIndex` cannot be greater than `endIndex`");
1619
+ }
1620
+ if (endPosition !== ZERO_POINT && (startPosition.row > endPosition.row || startPosition.row === endPosition.row && startPosition.column > endPosition.column)) {
1621
+ throw new Error("`startPosition` cannot be greater than `endPosition`");
1622
+ }
1623
+ if (progressCallback) {
1624
+ C.currentQueryProgressCallback = progressCallback;
1625
+ }
1626
+ marshalNode(node);
1627
+ C._ts_query_matches_wasm(
1628
+ this[0],
1629
+ node.tree[0],
1630
+ startPosition.row,
1631
+ startPosition.column,
1632
+ endPosition.row,
1633
+ endPosition.column,
1634
+ startIndex,
1635
+ endIndex,
1636
+ matchLimit,
1637
+ maxStartDepth,
1638
+ timeoutMicros
1639
+ );
1640
+ const rawCount = C.getValue(TRANSFER_BUFFER, "i32");
1641
+ const startAddress = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
1642
+ const didExceedMatchLimit = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
1643
+ const result = new Array(rawCount);
1644
+ this.exceededMatchLimit = Boolean(didExceedMatchLimit);
1645
+ let filteredCount = 0;
1646
+ let address = startAddress;
1647
+ for (let i2 = 0; i2 < rawCount; i2++) {
1648
+ const patternIndex = C.getValue(address, "i32");
1649
+ address += SIZE_OF_INT;
1650
+ const captureCount = C.getValue(address, "i32");
1651
+ address += SIZE_OF_INT;
1652
+ const captures = new Array(captureCount);
1653
+ address = unmarshalCaptures(this, node.tree, address, patternIndex, captures);
1654
+ if (this.textPredicates[patternIndex].every((p) => p(captures))) {
1655
+ result[filteredCount] = { pattern: patternIndex, patternIndex, captures };
1656
+ const setProperties = this.setProperties[patternIndex];
1657
+ result[filteredCount].setProperties = setProperties;
1658
+ const assertedProperties = this.assertedProperties[patternIndex];
1659
+ result[filteredCount].assertedProperties = assertedProperties;
1660
+ const refutedProperties = this.refutedProperties[patternIndex];
1661
+ result[filteredCount].refutedProperties = refutedProperties;
1662
+ filteredCount++;
1663
+ }
1664
+ }
1665
+ result.length = filteredCount;
1666
+ C._free(startAddress);
1667
+ C.currentQueryProgressCallback = null;
1668
+ return result;
1669
+ }
1670
+ /**
1671
+ * Iterate over all of the individual captures in the order that they
1672
+ * appear.
1673
+ *
1674
+ * This is useful if you don't care about which pattern matched, and just
1675
+ * want a single, ordered sequence of captures.
1676
+ *
1677
+ * @param {Node} node - The node to execute the query on.
1678
+ *
1679
+ * @param {QueryOptions} options - Options for query execution.
1680
+ */
1681
+ captures(node, options = {}) {
1682
+ const startPosition = options.startPosition ?? ZERO_POINT;
1683
+ const endPosition = options.endPosition ?? ZERO_POINT;
1684
+ const startIndex = options.startIndex ?? 0;
1685
+ const endIndex = options.endIndex ?? 0;
1686
+ const matchLimit = options.matchLimit ?? 4294967295;
1687
+ const maxStartDepth = options.maxStartDepth ?? 4294967295;
1688
+ const timeoutMicros = options.timeoutMicros ?? 0;
1689
+ const progressCallback = options.progressCallback;
1690
+ if (typeof matchLimit !== "number") {
1691
+ throw new Error("Arguments must be numbers");
1692
+ }
1693
+ this.matchLimit = matchLimit;
1694
+ if (endIndex !== 0 && startIndex > endIndex) {
1695
+ throw new Error("`startIndex` cannot be greater than `endIndex`");
1696
+ }
1697
+ if (endPosition !== ZERO_POINT && (startPosition.row > endPosition.row || startPosition.row === endPosition.row && startPosition.column > endPosition.column)) {
1698
+ throw new Error("`startPosition` cannot be greater than `endPosition`");
1699
+ }
1700
+ if (progressCallback) {
1701
+ C.currentQueryProgressCallback = progressCallback;
1702
+ }
1703
+ marshalNode(node);
1704
+ C._ts_query_captures_wasm(
1705
+ this[0],
1706
+ node.tree[0],
1707
+ startPosition.row,
1708
+ startPosition.column,
1709
+ endPosition.row,
1710
+ endPosition.column,
1711
+ startIndex,
1712
+ endIndex,
1713
+ matchLimit,
1714
+ maxStartDepth,
1715
+ timeoutMicros
1716
+ );
1717
+ const count = C.getValue(TRANSFER_BUFFER, "i32");
1718
+ const startAddress = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
1719
+ const didExceedMatchLimit = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
1720
+ const result = new Array();
1721
+ this.exceededMatchLimit = Boolean(didExceedMatchLimit);
1722
+ const captures = new Array();
1723
+ let address = startAddress;
1724
+ for (let i2 = 0; i2 < count; i2++) {
1725
+ const patternIndex = C.getValue(address, "i32");
1726
+ address += SIZE_OF_INT;
1727
+ const captureCount = C.getValue(address, "i32");
1728
+ address += SIZE_OF_INT;
1729
+ const captureIndex = C.getValue(address, "i32");
1730
+ address += SIZE_OF_INT;
1731
+ captures.length = captureCount;
1732
+ address = unmarshalCaptures(this, node.tree, address, patternIndex, captures);
1733
+ if (this.textPredicates[patternIndex].every((p) => p(captures))) {
1734
+ const capture = captures[captureIndex];
1735
+ const setProperties = this.setProperties[patternIndex];
1736
+ capture.setProperties = setProperties;
1737
+ const assertedProperties = this.assertedProperties[patternIndex];
1738
+ capture.assertedProperties = assertedProperties;
1739
+ const refutedProperties = this.refutedProperties[patternIndex];
1740
+ capture.refutedProperties = refutedProperties;
1741
+ result.push(capture);
1742
+ }
1743
+ }
1744
+ C._free(startAddress);
1745
+ C.currentQueryProgressCallback = null;
1746
+ return result;
1747
+ }
1748
+ /** Get the predicates for a given pattern. */
1749
+ predicatesForPattern(patternIndex) {
1750
+ return this.predicates[patternIndex];
1751
+ }
1752
+ /**
1753
+ * Disable a certain capture within a query.
1754
+ *
1755
+ * This prevents the capture from being returned in matches, and also
1756
+ * avoids any resource usage associated with recording the capture.
1757
+ */
1758
+ disableCapture(captureName) {
1759
+ const captureNameLength = C.lengthBytesUTF8(captureName);
1760
+ const captureNameAddress = C._malloc(captureNameLength + 1);
1761
+ C.stringToUTF8(captureName, captureNameAddress, captureNameLength + 1);
1762
+ C._ts_query_disable_capture(this[0], captureNameAddress, captureNameLength);
1763
+ C._free(captureNameAddress);
1764
+ }
1765
+ /**
1766
+ * Disable a certain pattern within a query.
1767
+ *
1768
+ * This prevents the pattern from matching, and also avoids any resource
1769
+ * usage associated with the pattern. This throws an error if the pattern
1770
+ * index is out of bounds.
1771
+ */
1772
+ disablePattern(patternIndex) {
1773
+ if (patternIndex >= this.predicates.length) {
1774
+ throw new Error(
1775
+ `Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`
1776
+ );
1777
+ }
1778
+ C._ts_query_disable_pattern(this[0], patternIndex);
1779
+ }
1780
+ /**
1781
+ * Check if, on its last execution, this cursor exceeded its maximum number
1782
+ * of in-progress matches.
1783
+ */
1784
+ didExceedMatchLimit() {
1785
+ return this.exceededMatchLimit;
1786
+ }
1787
+ /** Get the byte offset where the given pattern starts in the query's source. */
1788
+ startIndexForPattern(patternIndex) {
1789
+ if (patternIndex >= this.predicates.length) {
1790
+ throw new Error(
1791
+ `Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`
1792
+ );
1793
+ }
1794
+ return C._ts_query_start_byte_for_pattern(this[0], patternIndex);
1795
+ }
1796
+ /** Get the byte offset where the given pattern ends in the query's source. */
1797
+ endIndexForPattern(patternIndex) {
1798
+ if (patternIndex >= this.predicates.length) {
1799
+ throw new Error(
1800
+ `Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`
1801
+ );
1802
+ }
1803
+ return C._ts_query_end_byte_for_pattern(this[0], patternIndex);
1804
+ }
1805
+ /** Get the number of patterns in the query. */
1806
+ patternCount() {
1807
+ return C._ts_query_pattern_count(this[0]);
1808
+ }
1809
+ /** Get the index for a given capture name. */
1810
+ captureIndexForName(captureName) {
1811
+ return this.captureNames.indexOf(captureName);
1812
+ }
1813
+ /** Check if a given pattern within a query has a single root node. */
1814
+ isPatternRooted(patternIndex) {
1815
+ return C._ts_query_is_pattern_rooted(this[0], patternIndex) === 1;
1816
+ }
1817
+ /** Check if a given pattern within a query has a single root node. */
1818
+ isPatternNonLocal(patternIndex) {
1819
+ return C._ts_query_is_pattern_non_local(this[0], patternIndex) === 1;
1820
+ }
1821
+ /**
1822
+ * Check if a given step in a query is 'definite'.
1823
+ *
1824
+ * A query step is 'definite' if its parent pattern will be guaranteed to
1825
+ * match successfully once it reaches the step.
1826
+ */
1827
+ isPatternGuaranteedAtStep(byteIndex) {
1828
+ return C._ts_query_is_pattern_guaranteed_at_step(this[0], byteIndex) === 1;
1829
+ }
1830
+ };
1831
+
1832
+ // src/language.ts
1833
+ var LANGUAGE_FUNCTION_REGEX = /^tree_sitter_\w+$/;
1834
+ var Language = class _Language {
1835
+ static {
1836
+ __name(this, "Language");
1837
+ }
1838
+ /** @internal */
1839
+ [0] = 0;
1840
+ // Internal handle for WASM
1841
+ /**
1842
+ * A list of all node types in the language. The index of each type in this
1843
+ * array is its node type id.
1844
+ */
1845
+ types;
1846
+ /**
1847
+ * A list of all field names in the language. The index of each field name in
1848
+ * this array is its field id.
1849
+ */
1850
+ fields;
1851
+ /** @internal */
1852
+ constructor(internal, address) {
1853
+ assertInternal(internal);
1854
+ this[0] = address;
1855
+ this.types = new Array(C._ts_language_symbol_count(this[0]));
1856
+ for (let i2 = 0, n = this.types.length; i2 < n; i2++) {
1857
+ if (C._ts_language_symbol_type(this[0], i2) < 2) {
1858
+ this.types[i2] = C.UTF8ToString(C._ts_language_symbol_name(this[0], i2));
1859
+ }
1860
+ }
1861
+ this.fields = new Array(C._ts_language_field_count(this[0]) + 1);
1862
+ for (let i2 = 0, n = this.fields.length; i2 < n; i2++) {
1863
+ const fieldName = C._ts_language_field_name_for_id(this[0], i2);
1864
+ if (fieldName !== 0) {
1865
+ this.fields[i2] = C.UTF8ToString(fieldName);
1866
+ } else {
1867
+ this.fields[i2] = null;
1868
+ }
1869
+ }
1870
+ }
1871
+ /**
1872
+ * Gets the name of the language.
1873
+ */
1874
+ get name() {
1875
+ const ptr = C._ts_language_name(this[0]);
1876
+ if (ptr === 0) return null;
1877
+ return C.UTF8ToString(ptr);
1878
+ }
1879
+ /**
1880
+ * @deprecated since version 0.25.0, use {@link Language#abiVersion} instead
1881
+ * Gets the version of the language.
1882
+ */
1883
+ get version() {
1884
+ return C._ts_language_version(this[0]);
1885
+ }
1886
+ /**
1887
+ * Gets the ABI version of the language.
1888
+ */
1889
+ get abiVersion() {
1890
+ return C._ts_language_abi_version(this[0]);
1891
+ }
1892
+ /**
1893
+ * Get the metadata for this language. This information is generated by the
1894
+ * CLI, and relies on the language author providing the correct metadata in
1895
+ * the language's `tree-sitter.json` file.
1896
+ */
1897
+ get metadata() {
1898
+ C._ts_language_metadata(this[0]);
1899
+ const length = C.getValue(TRANSFER_BUFFER, "i32");
1900
+ const address = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
1901
+ if (length === 0) return null;
1902
+ return unmarshalLanguageMetadata(address);
1903
+ }
1904
+ /**
1905
+ * Gets the number of fields in the language.
1906
+ */
1907
+ get fieldCount() {
1908
+ return this.fields.length - 1;
1909
+ }
1910
+ /**
1911
+ * Gets the number of states in the language.
1912
+ */
1913
+ get stateCount() {
1914
+ return C._ts_language_state_count(this[0]);
1915
+ }
1916
+ /**
1917
+ * Get the field id for a field name.
1918
+ */
1919
+ fieldIdForName(fieldName) {
1920
+ const result = this.fields.indexOf(fieldName);
1921
+ return result !== -1 ? result : null;
1922
+ }
1923
+ /**
1924
+ * Get the field name for a field id.
1925
+ */
1926
+ fieldNameForId(fieldId) {
1927
+ return this.fields[fieldId] ?? null;
1928
+ }
1929
+ /**
1930
+ * Get the node type id for a node type name.
1931
+ */
1932
+ idForNodeType(type, named) {
1933
+ const typeLength = C.lengthBytesUTF8(type);
1934
+ const typeAddress = C._malloc(typeLength + 1);
1935
+ C.stringToUTF8(type, typeAddress, typeLength + 1);
1936
+ const result = C._ts_language_symbol_for_name(this[0], typeAddress, typeLength, named ? 1 : 0);
1937
+ C._free(typeAddress);
1938
+ return result || null;
1939
+ }
1940
+ /**
1941
+ * Gets the number of node types in the language.
1942
+ */
1943
+ get nodeTypeCount() {
1944
+ return C._ts_language_symbol_count(this[0]);
1945
+ }
1946
+ /**
1947
+ * Get the node type name for a node type id.
1948
+ */
1949
+ nodeTypeForId(typeId) {
1950
+ const name2 = C._ts_language_symbol_name(this[0], typeId);
1951
+ return name2 ? C.UTF8ToString(name2) : null;
1952
+ }
1953
+ /**
1954
+ * Check if a node type is named.
1955
+ *
1956
+ * @see {@link https://tree-sitter.github.io/tree-sitter/using-parsers/2-basic-parsing.html#named-vs-anonymous-nodes}
1957
+ */
1958
+ nodeTypeIsNamed(typeId) {
1959
+ return C._ts_language_type_is_named_wasm(this[0], typeId) ? true : false;
1960
+ }
1961
+ /**
1962
+ * Check if a node type is visible.
1963
+ */
1964
+ nodeTypeIsVisible(typeId) {
1965
+ return C._ts_language_type_is_visible_wasm(this[0], typeId) ? true : false;
1966
+ }
1967
+ /**
1968
+ * Get the supertypes ids of this language.
1969
+ *
1970
+ * @see {@link https://tree-sitter.github.io/tree-sitter/using-parsers/6-static-node-types.html?highlight=supertype#supertype-nodes}
1971
+ */
1972
+ get supertypes() {
1973
+ C._ts_language_supertypes_wasm(this[0]);
1974
+ const count = C.getValue(TRANSFER_BUFFER, "i32");
1975
+ const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
1976
+ const result = new Array(count);
1977
+ if (count > 0) {
1978
+ let address = buffer;
1979
+ for (let i2 = 0; i2 < count; i2++) {
1980
+ result[i2] = C.getValue(address, "i16");
1981
+ address += SIZE_OF_SHORT;
1982
+ }
1983
+ }
1984
+ return result;
1985
+ }
1986
+ /**
1987
+ * Get the subtype ids for a given supertype node id.
1988
+ */
1989
+ subtypes(supertype) {
1990
+ C._ts_language_subtypes_wasm(this[0], supertype);
1991
+ const count = C.getValue(TRANSFER_BUFFER, "i32");
1992
+ const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
1993
+ const result = new Array(count);
1994
+ if (count > 0) {
1995
+ let address = buffer;
1996
+ for (let i2 = 0; i2 < count; i2++) {
1997
+ result[i2] = C.getValue(address, "i16");
1998
+ address += SIZE_OF_SHORT;
1999
+ }
2000
+ }
2001
+ return result;
2002
+ }
2003
+ /**
2004
+ * Get the next state id for a given state id and node type id.
2005
+ */
2006
+ nextState(stateId, typeId) {
2007
+ return C._ts_language_next_state(this[0], stateId, typeId);
2008
+ }
2009
+ /**
2010
+ * Create a new lookahead iterator for this language and parse state.
2011
+ *
2012
+ * This returns `null` if state is invalid for this language.
2013
+ *
2014
+ * Iterating {@link LookaheadIterator} will yield valid symbols in the given
2015
+ * parse state. Newly created lookahead iterators will return the `ERROR`
2016
+ * symbol from {@link LookaheadIterator#currentType}.
2017
+ *
2018
+ * Lookahead iterators can be useful for generating suggestions and improving
2019
+ * syntax error diagnostics. To get symbols valid in an `ERROR` node, use the
2020
+ * lookahead iterator on its first leaf node state. For `MISSING` nodes, a
2021
+ * lookahead iterator created on the previous non-extra leaf node may be
2022
+ * appropriate.
2023
+ */
2024
+ lookaheadIterator(stateId) {
2025
+ const address = C._ts_lookahead_iterator_new(this[0], stateId);
2026
+ if (address) return new LookaheadIterator(INTERNAL, address, this);
2027
+ return null;
2028
+ }
2029
+ /**
2030
+ * @deprecated since version 0.25.0, call `new` on a {@link Query} instead
2031
+ *
2032
+ * Create a new query from a string containing one or more S-expression
2033
+ * patterns.
2034
+ *
2035
+ * The query is associated with a particular language, and can only be run
2036
+ * on syntax nodes parsed with that language. References to Queries can be
2037
+ * shared between multiple threads.
2038
+ *
2039
+ * @link {@see https://tree-sitter.github.io/tree-sitter/using-parsers/queries}
2040
+ */
2041
+ query(source) {
2042
+ console.warn("Language.query is deprecated. Use new Query(language, source) instead.");
2043
+ return new Query(this, source);
2044
+ }
2045
+ /**
2046
+ * Load a language from a WebAssembly module.
2047
+ * The module can be provided as a path to a file or as a buffer.
2048
+ */
2049
+ static async load(input) {
2050
+ let bytes;
2051
+ if (input instanceof Uint8Array) {
2052
+ bytes = Promise.resolve(input);
2053
+ } else {
2054
+ if (globalThis.process?.versions.node) {
2055
+ const fs2 = __require("fs/promises");
2056
+ bytes = fs2.readFile(input);
2057
+ } else {
2058
+ bytes = fetch(input).then((response) => response.arrayBuffer().then((buffer) => {
2059
+ if (response.ok) {
2060
+ return new Uint8Array(buffer);
2061
+ } else {
2062
+ const body2 = new TextDecoder("utf-8").decode(buffer);
2063
+ throw new Error(`Language.load failed with status ${response.status}.
2064
+
2065
+ ${body2}`);
2066
+ }
2067
+ }));
2068
+ }
2069
+ }
2070
+ const mod = await C.loadWebAssemblyModule(await bytes, { loadAsync: true });
2071
+ const symbolNames = Object.keys(mod);
2072
+ const functionName = symbolNames.find((key) => LANGUAGE_FUNCTION_REGEX.test(key) && !key.includes("external_scanner_"));
2073
+ if (!functionName) {
2074
+ console.log(`Couldn't find language function in WASM file. Symbols:
2075
+ ${JSON.stringify(symbolNames, null, 2)}`);
2076
+ throw new Error("Language.load failed: no language function found in WASM file");
2077
+ }
2078
+ const languageAddress = mod[functionName]();
2079
+ return new _Language(INTERNAL, languageAddress);
2080
+ }
2081
+ };
2082
+
2083
+ // lib/tree-sitter.mjs
2084
+ var Module2 = (() => {
2085
+ var _scriptName = getCurrentScriptUrl();
2086
+ return async function(moduleArg = {}) {
2087
+ var moduleRtn;
2088
+ var Module = moduleArg;
2089
+ var readyPromiseResolve, readyPromiseReject;
2090
+ var readyPromise = new Promise((resolve, reject) => {
2091
+ readyPromiseResolve = resolve;
2092
+ readyPromiseReject = reject;
2093
+ });
2094
+ var ENVIRONMENT_IS_WEB = typeof window == "object";
2095
+ var ENVIRONMENT_IS_WORKER = typeof importScripts == "function";
2096
+ var ENVIRONMENT_IS_NODE = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string";
2097
+ var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
2098
+ if (ENVIRONMENT_IS_NODE) {
2099
+ const { createRequire } = await import("module");
2100
+ var require = createRequire(getCurrentScriptUrl());
2101
+ }
2102
+ Module.currentQueryProgressCallback = null;
2103
+ Module.currentProgressCallback = null;
2104
+ Module.currentLogCallback = null;
2105
+ Module.currentParseCallback = null;
2106
+ var moduleOverrides = Object.assign({}, Module);
2107
+ var arguments_ = [];
2108
+ var thisProgram = "./this.program";
2109
+ var quit_ = /* @__PURE__ */ __name((status, toThrow) => {
2110
+ throw toThrow;
2111
+ }, "quit_");
2112
+ var scriptDirectory = "";
2113
+ function locateFile(path) {
2114
+ if (Module["locateFile"]) {
2115
+ return Module["locateFile"](path, scriptDirectory);
2116
+ }
2117
+ return scriptDirectory + path;
2118
+ }
2119
+ __name(locateFile, "locateFile");
2120
+ var readAsync, readBinary;
2121
+ if (ENVIRONMENT_IS_NODE) {
2122
+ var fs = require("fs");
2123
+ var nodePath = require("path");
2124
+ scriptDirectory = require("url").fileURLToPath(new URL("./", getCurrentScriptUrl()));
2125
+ readBinary = /* @__PURE__ */ __name((filename) => {
2126
+ filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
2127
+ var ret = fs.readFileSync(filename);
2128
+ return ret;
2129
+ }, "readBinary");
2130
+ readAsync = /* @__PURE__ */ __name((filename, binary2 = true) => {
2131
+ filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
2132
+ return new Promise((resolve, reject) => {
2133
+ fs.readFile(filename, binary2 ? void 0 : "utf8", (err2, data) => {
2134
+ if (err2) reject(err2);
2135
+ else resolve(binary2 ? data.buffer : data);
2136
+ });
2137
+ });
2138
+ }, "readAsync");
2139
+ if (!Module["thisProgram"] && process.argv.length > 1) {
2140
+ thisProgram = process.argv[1].replace(/\\/g, "/");
2141
+ }
2142
+ arguments_ = process.argv.slice(2);
2143
+ quit_ = /* @__PURE__ */ __name((status, toThrow) => {
2144
+ process.exitCode = status;
2145
+ throw toThrow;
2146
+ }, "quit_");
2147
+ } else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
2148
+ if (ENVIRONMENT_IS_WORKER) {
2149
+ scriptDirectory = self.location.href;
2150
+ } else if (typeof document != "undefined" && document.currentScript) {
2151
+ scriptDirectory = document.currentScript.src;
2152
+ }
2153
+ if (_scriptName) {
2154
+ scriptDirectory = _scriptName;
2155
+ }
2156
+ if (scriptDirectory.startsWith("blob:")) {
2157
+ scriptDirectory = "";
2158
+ } else {
2159
+ scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1);
2160
+ }
2161
+ {
2162
+ if (ENVIRONMENT_IS_WORKER) {
2163
+ readBinary = /* @__PURE__ */ __name((url) => {
2164
+ var xhr = new XMLHttpRequest();
2165
+ xhr.open("GET", url, false);
2166
+ xhr.responseType = "arraybuffer";
2167
+ xhr.send(null);
2168
+ return new Uint8Array(
2169
+ /** @type{!ArrayBuffer} */
2170
+ xhr.response
2171
+ );
2172
+ }, "readBinary");
2173
+ }
2174
+ readAsync = /* @__PURE__ */ __name((url) => {
2175
+ if (isFileURI(url)) {
2176
+ return new Promise((reject, resolve) => {
2177
+ var xhr = new XMLHttpRequest();
2178
+ xhr.open("GET", url, true);
2179
+ xhr.responseType = "arraybuffer";
2180
+ xhr.onload = () => {
2181
+ if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
2182
+ resolve(xhr.response);
2183
+ }
2184
+ reject(xhr.status);
2185
+ };
2186
+ xhr.onerror = reject;
2187
+ xhr.send(null);
2188
+ });
2189
+ }
2190
+ return fetch(url, {
2191
+ credentials: "same-origin"
2192
+ }).then((response) => {
2193
+ if (response.ok) {
2194
+ return response.arrayBuffer();
2195
+ }
2196
+ return Promise.reject(new Error(response.status + " : " + response.url));
2197
+ });
2198
+ }, "readAsync");
2199
+ }
2200
+ } else {
2201
+ }
2202
+ var out = Module["print"] || console.log.bind(console);
2203
+ var err = Module["printErr"] || console.error.bind(console);
2204
+ Object.assign(Module, moduleOverrides);
2205
+ moduleOverrides = null;
2206
+ if (Module["arguments"]) arguments_ = Module["arguments"];
2207
+ if (Module["thisProgram"]) thisProgram = Module["thisProgram"];
2208
+ if (Module["quit"]) quit_ = Module["quit"];
2209
+ var dynamicLibraries = Module["dynamicLibraries"] || [];
2210
+ var wasmBinary;
2211
+ if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"];
2212
+ var wasmMemory;
2213
+ var ABORT = false;
2214
+ var EXITSTATUS;
2215
+ function assert(condition, text) {
2216
+ if (!condition) {
2217
+ abort(text);
2218
+ }
2219
+ }
2220
+ __name(assert, "assert");
2221
+ var HEAP, HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
2222
+ var HEAP_DATA_VIEW;
2223
+ function updateMemoryViews() {
2224
+ var b = wasmMemory.buffer;
2225
+ Module["HEAP_DATA_VIEW"] = HEAP_DATA_VIEW = new DataView(b);
2226
+ Module["HEAP8"] = HEAP8 = new Int8Array(b);
2227
+ Module["HEAP16"] = HEAP16 = new Int16Array(b);
2228
+ Module["HEAPU8"] = HEAPU8 = new Uint8Array(b);
2229
+ Module["HEAPU16"] = HEAPU16 = new Uint16Array(b);
2230
+ Module["HEAP32"] = HEAP32 = new Int32Array(b);
2231
+ Module["HEAPU32"] = HEAPU32 = new Uint32Array(b);
2232
+ Module["HEAPF32"] = HEAPF32 = new Float32Array(b);
2233
+ Module["HEAPF64"] = HEAPF64 = new Float64Array(b);
2234
+ }
2235
+ __name(updateMemoryViews, "updateMemoryViews");
2236
+ if (Module["wasmMemory"]) {
2237
+ wasmMemory = Module["wasmMemory"];
2238
+ } else {
2239
+ var INITIAL_MEMORY = Module["INITIAL_MEMORY"] || 33554432;
2240
+ wasmMemory = new WebAssembly.Memory({
2241
+ "initial": INITIAL_MEMORY / 65536,
2242
+ // In theory we should not need to emit the maximum if we want "unlimited"
2243
+ // or 4GB of memory, but VMs error on that atm, see
2244
+ // https://github.com/emscripten-core/emscripten/issues/14130
2245
+ // And in the pthreads case we definitely need to emit a maximum. So
2246
+ // always emit one.
2247
+ "maximum": 2147483648 / 65536
2248
+ });
2249
+ }
2250
+ updateMemoryViews();
2251
+ var __ATPRERUN__ = [];
2252
+ var __ATINIT__ = [];
2253
+ var __ATMAIN__ = [];
2254
+ var __ATEXIT__ = [];
2255
+ var __ATPOSTRUN__ = [];
2256
+ var __RELOC_FUNCS__ = [];
2257
+ var runtimeInitialized = false;
2258
+ function preRun() {
2259
+ if (Module["preRun"]) {
2260
+ if (typeof Module["preRun"] == "function") Module["preRun"] = [Module["preRun"]];
2261
+ while (Module["preRun"].length) {
2262
+ addOnPreRun(Module["preRun"].shift());
2263
+ }
2264
+ }
2265
+ callRuntimeCallbacks(__ATPRERUN__);
2266
+ }
2267
+ __name(preRun, "preRun");
2268
+ function initRuntime() {
2269
+ runtimeInitialized = true;
2270
+ callRuntimeCallbacks(__RELOC_FUNCS__);
2271
+ callRuntimeCallbacks(__ATINIT__);
2272
+ }
2273
+ __name(initRuntime, "initRuntime");
2274
+ function preMain() {
2275
+ callRuntimeCallbacks(__ATMAIN__);
2276
+ }
2277
+ __name(preMain, "preMain");
2278
+ function postRun() {
2279
+ if (Module["postRun"]) {
2280
+ if (typeof Module["postRun"] == "function") Module["postRun"] = [Module["postRun"]];
2281
+ while (Module["postRun"].length) {
2282
+ addOnPostRun(Module["postRun"].shift());
2283
+ }
2284
+ }
2285
+ callRuntimeCallbacks(__ATPOSTRUN__);
2286
+ }
2287
+ __name(postRun, "postRun");
2288
+ function addOnPreRun(cb) {
2289
+ __ATPRERUN__.unshift(cb);
2290
+ }
2291
+ __name(addOnPreRun, "addOnPreRun");
2292
+ function addOnInit(cb) {
2293
+ __ATINIT__.unshift(cb);
2294
+ }
2295
+ __name(addOnInit, "addOnInit");
2296
+ function addOnPreMain(cb) {
2297
+ __ATMAIN__.unshift(cb);
2298
+ }
2299
+ __name(addOnPreMain, "addOnPreMain");
2300
+ function addOnExit(cb) {
2301
+ }
2302
+ __name(addOnExit, "addOnExit");
2303
+ function addOnPostRun(cb) {
2304
+ __ATPOSTRUN__.unshift(cb);
2305
+ }
2306
+ __name(addOnPostRun, "addOnPostRun");
2307
+ var runDependencies = 0;
2308
+ var runDependencyWatcher = null;
2309
+ var dependenciesFulfilled = null;
2310
+ function getUniqueRunDependency(id) {
2311
+ return id;
2312
+ }
2313
+ __name(getUniqueRunDependency, "getUniqueRunDependency");
2314
+ function addRunDependency(id) {
2315
+ runDependencies++;
2316
+ Module["monitorRunDependencies"]?.(runDependencies);
2317
+ }
2318
+ __name(addRunDependency, "addRunDependency");
2319
+ function removeRunDependency(id) {
2320
+ runDependencies--;
2321
+ Module["monitorRunDependencies"]?.(runDependencies);
2322
+ if (runDependencies == 0) {
2323
+ if (runDependencyWatcher !== null) {
2324
+ clearInterval(runDependencyWatcher);
2325
+ runDependencyWatcher = null;
2326
+ }
2327
+ if (dependenciesFulfilled) {
2328
+ var callback = dependenciesFulfilled;
2329
+ dependenciesFulfilled = null;
2330
+ callback();
2331
+ }
2332
+ }
2333
+ }
2334
+ __name(removeRunDependency, "removeRunDependency");
2335
+ function abort(what) {
2336
+ Module["onAbort"]?.(what);
2337
+ what = "Aborted(" + what + ")";
2338
+ err(what);
2339
+ ABORT = true;
2340
+ EXITSTATUS = 1;
2341
+ what += ". Build with -sASSERTIONS for more info.";
2342
+ var e = new WebAssembly.RuntimeError(what);
2343
+ readyPromiseReject(e);
2344
+ throw e;
2345
+ }
2346
+ __name(abort, "abort");
2347
+ var dataURIPrefix = "data:application/octet-stream;base64,";
2348
+ var isDataURI = /* @__PURE__ */ __name((filename) => filename.startsWith(dataURIPrefix), "isDataURI");
2349
+ var isFileURI = /* @__PURE__ */ __name((filename) => filename.startsWith("file://"), "isFileURI");
2350
+ function findWasmBinary() {
2351
+ if (Module["locateFile"]) {
2352
+ var f = "tree-sitter.wasm";
2353
+ if (!isDataURI(f)) {
2354
+ return locateFile(f);
2355
+ }
2356
+ return f;
2357
+ }
2358
+ return new URL("tree-sitter.wasm", getCurrentScriptUrl()).href;
2359
+ }
2360
+ __name(findWasmBinary, "findWasmBinary");
2361
+ var wasmBinaryFile;
2362
+ function getBinarySync(file) {
2363
+ if (file == wasmBinaryFile && wasmBinary) {
2364
+ return new Uint8Array(wasmBinary);
2365
+ }
2366
+ if (readBinary) {
2367
+ return readBinary(file);
2368
+ }
2369
+ throw "both async and sync fetching of the wasm failed";
2370
+ }
2371
+ __name(getBinarySync, "getBinarySync");
2372
+ function getBinaryPromise(binaryFile) {
2373
+ if (!wasmBinary) {
2374
+ return readAsync(binaryFile).then(
2375
+ (response) => new Uint8Array(
2376
+ /** @type{!ArrayBuffer} */
2377
+ response
2378
+ ),
2379
+ // Fall back to getBinarySync if readAsync fails
2380
+ () => getBinarySync(binaryFile)
2381
+ );
2382
+ }
2383
+ return Promise.resolve().then(() => getBinarySync(binaryFile));
2384
+ }
2385
+ __name(getBinaryPromise, "getBinaryPromise");
2386
+ function instantiateArrayBuffer(binaryFile, imports, receiver) {
2387
+ return getBinaryPromise(binaryFile).then((binary2) => WebAssembly.instantiate(binary2, imports)).then(receiver, (reason) => {
2388
+ err(`failed to asynchronously prepare wasm: ${reason}`);
2389
+ abort(reason);
2390
+ });
2391
+ }
2392
+ __name(instantiateArrayBuffer, "instantiateArrayBuffer");
2393
+ function instantiateAsync(binary2, binaryFile, imports, callback) {
2394
+ if (!binary2 && typeof WebAssembly.instantiateStreaming == "function" && !isDataURI(binaryFile) && // Don't use streaming for file:// delivered objects in a webview, fetch them synchronously.
2395
+ !isFileURI(binaryFile) && // Avoid instantiateStreaming() on Node.js environment for now, as while
2396
+ // Node.js v18.1.0 implements it, it does not have a full fetch()
2397
+ // implementation yet.
2398
+ // Reference:
2399
+ // https://github.com/emscripten-core/emscripten/pull/16917
2400
+ !ENVIRONMENT_IS_NODE && typeof fetch == "function") {
2401
+ return fetch(binaryFile, {
2402
+ credentials: "same-origin"
2403
+ }).then((response) => {
2404
+ var result = WebAssembly.instantiateStreaming(response, imports);
2405
+ return result.then(callback, function(reason) {
2406
+ err(`wasm streaming compile failed: ${reason}`);
2407
+ err("falling back to ArrayBuffer instantiation");
2408
+ return instantiateArrayBuffer(binaryFile, imports, callback);
2409
+ });
2410
+ });
2411
+ }
2412
+ return instantiateArrayBuffer(binaryFile, imports, callback);
2413
+ }
2414
+ __name(instantiateAsync, "instantiateAsync");
2415
+ function getWasmImports() {
2416
+ return {
2417
+ "env": wasmImports,
2418
+ "wasi_snapshot_preview1": wasmImports,
2419
+ "GOT.mem": new Proxy(wasmImports, GOTHandler),
2420
+ "GOT.func": new Proxy(wasmImports, GOTHandler)
2421
+ };
2422
+ }
2423
+ __name(getWasmImports, "getWasmImports");
2424
+ function createWasm() {
2425
+ var info2 = getWasmImports();
2426
+ function receiveInstance(instance2, module2) {
2427
+ wasmExports = instance2.exports;
2428
+ wasmExports = relocateExports(wasmExports, 1024);
2429
+ var metadata2 = getDylinkMetadata(module2);
2430
+ if (metadata2.neededDynlibs) {
2431
+ dynamicLibraries = metadata2.neededDynlibs.concat(dynamicLibraries);
2432
+ }
2433
+ mergeLibSymbols(wasmExports, "main");
2434
+ LDSO.init();
2435
+ loadDylibs();
2436
+ addOnInit(wasmExports["__wasm_call_ctors"]);
2437
+ __RELOC_FUNCS__.push(wasmExports["__wasm_apply_data_relocs"]);
2438
+ removeRunDependency("wasm-instantiate");
2439
+ return wasmExports;
2440
+ }
2441
+ __name(receiveInstance, "receiveInstance");
2442
+ addRunDependency("wasm-instantiate");
2443
+ function receiveInstantiationResult(result) {
2444
+ receiveInstance(result["instance"], result["module"]);
2445
+ }
2446
+ __name(receiveInstantiationResult, "receiveInstantiationResult");
2447
+ if (Module["instantiateWasm"]) {
2448
+ try {
2449
+ return Module["instantiateWasm"](info2, receiveInstance);
2450
+ } catch (e) {
2451
+ err(`Module.instantiateWasm callback failed with error: ${e}`);
2452
+ readyPromiseReject(e);
2453
+ }
2454
+ }
2455
+ if (!wasmBinaryFile) wasmBinaryFile = findWasmBinary();
2456
+ instantiateAsync(wasmBinary, wasmBinaryFile, info2, receiveInstantiationResult).catch(readyPromiseReject);
2457
+ return {};
2458
+ }
2459
+ __name(createWasm, "createWasm");
2460
+ var tempDouble;
2461
+ var tempI64;
2462
+ var ASM_CONSTS = {};
2463
+ function ExitStatus(status) {
2464
+ this.name = "ExitStatus";
2465
+ this.message = `Program terminated with exit(${status})`;
2466
+ this.status = status;
2467
+ }
2468
+ __name(ExitStatus, "ExitStatus");
2469
+ var GOT = {};
2470
+ var currentModuleWeakSymbols = /* @__PURE__ */ new Set([]);
2471
+ var GOTHandler = {
2472
+ get(obj, symName) {
2473
+ var rtn = GOT[symName];
2474
+ if (!rtn) {
2475
+ rtn = GOT[symName] = new WebAssembly.Global({
2476
+ "value": "i32",
2477
+ "mutable": true
2478
+ });
2479
+ }
2480
+ if (!currentModuleWeakSymbols.has(symName)) {
2481
+ rtn.required = true;
2482
+ }
2483
+ return rtn;
2484
+ }
2485
+ };
2486
+ var LE_HEAP_LOAD_F32 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getFloat32(byteOffset, true), "LE_HEAP_LOAD_F32");
2487
+ var LE_HEAP_LOAD_F64 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getFloat64(byteOffset, true), "LE_HEAP_LOAD_F64");
2488
+ var LE_HEAP_LOAD_I16 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getInt16(byteOffset, true), "LE_HEAP_LOAD_I16");
2489
+ var LE_HEAP_LOAD_I32 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getInt32(byteOffset, true), "LE_HEAP_LOAD_I32");
2490
+ var LE_HEAP_LOAD_U16 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getUint16(byteOffset, true), "LE_HEAP_LOAD_U16");
2491
+ var LE_HEAP_LOAD_U32 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getUint32(byteOffset, true), "LE_HEAP_LOAD_U32");
2492
+ var LE_HEAP_STORE_F32 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setFloat32(byteOffset, value, true), "LE_HEAP_STORE_F32");
2493
+ var LE_HEAP_STORE_F64 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setFloat64(byteOffset, value, true), "LE_HEAP_STORE_F64");
2494
+ var LE_HEAP_STORE_I16 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setInt16(byteOffset, value, true), "LE_HEAP_STORE_I16");
2495
+ var LE_HEAP_STORE_I32 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setInt32(byteOffset, value, true), "LE_HEAP_STORE_I32");
2496
+ var LE_HEAP_STORE_U16 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setUint16(byteOffset, value, true), "LE_HEAP_STORE_U16");
2497
+ var LE_HEAP_STORE_U32 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setUint32(byteOffset, value, true), "LE_HEAP_STORE_U32");
2498
+ var callRuntimeCallbacks = /* @__PURE__ */ __name((callbacks) => {
2499
+ while (callbacks.length > 0) {
2500
+ callbacks.shift()(Module);
2501
+ }
2502
+ }, "callRuntimeCallbacks");
2503
+ var UTF8Decoder = typeof TextDecoder != "undefined" ? new TextDecoder() : void 0;
2504
+ var UTF8ArrayToString = /* @__PURE__ */ __name((heapOrArray, idx, maxBytesToRead) => {
2505
+ var endIdx = idx + maxBytesToRead;
2506
+ var endPtr = idx;
2507
+ while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr;
2508
+ if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
2509
+ return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
2510
+ }
2511
+ var str = "";
2512
+ while (idx < endPtr) {
2513
+ var u0 = heapOrArray[idx++];
2514
+ if (!(u0 & 128)) {
2515
+ str += String.fromCharCode(u0);
2516
+ continue;
2517
+ }
2518
+ var u1 = heapOrArray[idx++] & 63;
2519
+ if ((u0 & 224) == 192) {
2520
+ str += String.fromCharCode((u0 & 31) << 6 | u1);
2521
+ continue;
2522
+ }
2523
+ var u2 = heapOrArray[idx++] & 63;
2524
+ if ((u0 & 240) == 224) {
2525
+ u0 = (u0 & 15) << 12 | u1 << 6 | u2;
2526
+ } else {
2527
+ u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heapOrArray[idx++] & 63;
2528
+ }
2529
+ if (u0 < 65536) {
2530
+ str += String.fromCharCode(u0);
2531
+ } else {
2532
+ var ch = u0 - 65536;
2533
+ str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);
2534
+ }
2535
+ }
2536
+ return str;
2537
+ }, "UTF8ArrayToString");
2538
+ var getDylinkMetadata = /* @__PURE__ */ __name((binary2) => {
2539
+ var offset = 0;
2540
+ var end = 0;
2541
+ function getU8() {
2542
+ return binary2[offset++];
2543
+ }
2544
+ __name(getU8, "getU8");
2545
+ function getLEB() {
2546
+ var ret = 0;
2547
+ var mul = 1;
2548
+ while (1) {
2549
+ var byte = binary2[offset++];
2550
+ ret += (byte & 127) * mul;
2551
+ mul *= 128;
2552
+ if (!(byte & 128)) break;
2553
+ }
2554
+ return ret;
2555
+ }
2556
+ __name(getLEB, "getLEB");
2557
+ function getString() {
2558
+ var len = getLEB();
2559
+ offset += len;
2560
+ return UTF8ArrayToString(binary2, offset - len, len);
2561
+ }
2562
+ __name(getString, "getString");
2563
+ function failIf(condition, message) {
2564
+ if (condition) throw new Error(message);
2565
+ }
2566
+ __name(failIf, "failIf");
2567
+ var name2 = "dylink.0";
2568
+ if (binary2 instanceof WebAssembly.Module) {
2569
+ var dylinkSection = WebAssembly.Module.customSections(binary2, name2);
2570
+ if (dylinkSection.length === 0) {
2571
+ name2 = "dylink";
2572
+ dylinkSection = WebAssembly.Module.customSections(binary2, name2);
2573
+ }
2574
+ failIf(dylinkSection.length === 0, "need dylink section");
2575
+ binary2 = new Uint8Array(dylinkSection[0]);
2576
+ end = binary2.length;
2577
+ } else {
2578
+ var int32View = new Uint32Array(new Uint8Array(binary2.subarray(0, 24)).buffer);
2579
+ var magicNumberFound = int32View[0] == 1836278016 || int32View[0] == 6386541;
2580
+ failIf(!magicNumberFound, "need to see wasm magic number");
2581
+ failIf(binary2[8] !== 0, "need the dylink section to be first");
2582
+ offset = 9;
2583
+ var section_size = getLEB();
2584
+ end = offset + section_size;
2585
+ name2 = getString();
2586
+ }
2587
+ var customSection = {
2588
+ neededDynlibs: [],
2589
+ tlsExports: /* @__PURE__ */ new Set(),
2590
+ weakImports: /* @__PURE__ */ new Set()
2591
+ };
2592
+ if (name2 == "dylink") {
2593
+ customSection.memorySize = getLEB();
2594
+ customSection.memoryAlign = getLEB();
2595
+ customSection.tableSize = getLEB();
2596
+ customSection.tableAlign = getLEB();
2597
+ var neededDynlibsCount = getLEB();
2598
+ for (var i2 = 0; i2 < neededDynlibsCount; ++i2) {
2599
+ var libname = getString();
2600
+ customSection.neededDynlibs.push(libname);
2601
+ }
2602
+ } else {
2603
+ failIf(name2 !== "dylink.0");
2604
+ var WASM_DYLINK_MEM_INFO = 1;
2605
+ var WASM_DYLINK_NEEDED = 2;
2606
+ var WASM_DYLINK_EXPORT_INFO = 3;
2607
+ var WASM_DYLINK_IMPORT_INFO = 4;
2608
+ var WASM_SYMBOL_TLS = 256;
2609
+ var WASM_SYMBOL_BINDING_MASK = 3;
2610
+ var WASM_SYMBOL_BINDING_WEAK = 1;
2611
+ while (offset < end) {
2612
+ var subsectionType = getU8();
2613
+ var subsectionSize = getLEB();
2614
+ if (subsectionType === WASM_DYLINK_MEM_INFO) {
2615
+ customSection.memorySize = getLEB();
2616
+ customSection.memoryAlign = getLEB();
2617
+ customSection.tableSize = getLEB();
2618
+ customSection.tableAlign = getLEB();
2619
+ } else if (subsectionType === WASM_DYLINK_NEEDED) {
2620
+ var neededDynlibsCount = getLEB();
2621
+ for (var i2 = 0; i2 < neededDynlibsCount; ++i2) {
2622
+ libname = getString();
2623
+ customSection.neededDynlibs.push(libname);
2624
+ }
2625
+ } else if (subsectionType === WASM_DYLINK_EXPORT_INFO) {
2626
+ var count = getLEB();
2627
+ while (count--) {
2628
+ var symname = getString();
2629
+ var flags2 = getLEB();
2630
+ if (flags2 & WASM_SYMBOL_TLS) {
2631
+ customSection.tlsExports.add(symname);
2632
+ }
2633
+ }
2634
+ } else if (subsectionType === WASM_DYLINK_IMPORT_INFO) {
2635
+ var count = getLEB();
2636
+ while (count--) {
2637
+ var modname = getString();
2638
+ var symname = getString();
2639
+ var flags2 = getLEB();
2640
+ if ((flags2 & WASM_SYMBOL_BINDING_MASK) == WASM_SYMBOL_BINDING_WEAK) {
2641
+ customSection.weakImports.add(symname);
2642
+ }
2643
+ }
2644
+ } else {
2645
+ offset += subsectionSize;
2646
+ }
2647
+ }
2648
+ }
2649
+ return customSection;
2650
+ }, "getDylinkMetadata");
2651
+ function getValue(ptr, type = "i8") {
2652
+ if (type.endsWith("*")) type = "*";
2653
+ switch (type) {
2654
+ case "i1":
2655
+ return HEAP8[ptr];
2656
+ case "i8":
2657
+ return HEAP8[ptr];
2658
+ case "i16":
2659
+ return LE_HEAP_LOAD_I16((ptr >> 1) * 2);
2660
+ case "i32":
2661
+ return LE_HEAP_LOAD_I32((ptr >> 2) * 4);
2662
+ case "i64":
2663
+ abort("to do getValue(i64) use WASM_BIGINT");
2664
+ case "float":
2665
+ return LE_HEAP_LOAD_F32((ptr >> 2) * 4);
2666
+ case "double":
2667
+ return LE_HEAP_LOAD_F64((ptr >> 3) * 8);
2668
+ case "*":
2669
+ return LE_HEAP_LOAD_U32((ptr >> 2) * 4);
2670
+ default:
2671
+ abort(`invalid type for getValue: ${type}`);
2672
+ }
2673
+ }
2674
+ __name(getValue, "getValue");
2675
+ var newDSO = /* @__PURE__ */ __name((name2, handle2, syms) => {
2676
+ var dso = {
2677
+ refcount: Infinity,
2678
+ name: name2,
2679
+ exports: syms,
2680
+ global: true
2681
+ };
2682
+ LDSO.loadedLibsByName[name2] = dso;
2683
+ if (handle2 != void 0) {
2684
+ LDSO.loadedLibsByHandle[handle2] = dso;
2685
+ }
2686
+ return dso;
2687
+ }, "newDSO");
2688
+ var LDSO = {
2689
+ loadedLibsByName: {},
2690
+ loadedLibsByHandle: {},
2691
+ init() {
2692
+ newDSO("__main__", 0, wasmImports);
2693
+ }
2694
+ };
2695
+ var ___heap_base = 78160;
2696
+ var zeroMemory = /* @__PURE__ */ __name((address, size) => {
2697
+ HEAPU8.fill(0, address, address + size);
2698
+ return address;
2699
+ }, "zeroMemory");
2700
+ var alignMemory = /* @__PURE__ */ __name((size, alignment) => Math.ceil(size / alignment) * alignment, "alignMemory");
2701
+ var getMemory = /* @__PURE__ */ __name((size) => {
2702
+ if (runtimeInitialized) {
2703
+ return zeroMemory(_malloc(size), size);
2704
+ }
2705
+ var ret = ___heap_base;
2706
+ var end = ret + alignMemory(size, 16);
2707
+ ___heap_base = end;
2708
+ GOT["__heap_base"].value = end;
2709
+ return ret;
2710
+ }, "getMemory");
2711
+ var isInternalSym = /* @__PURE__ */ __name((symName) => ["__cpp_exception", "__c_longjmp", "__wasm_apply_data_relocs", "__dso_handle", "__tls_size", "__tls_align", "__set_stack_limits", "_emscripten_tls_init", "__wasm_init_tls", "__wasm_call_ctors", "__start_em_asm", "__stop_em_asm", "__start_em_js", "__stop_em_js"].includes(symName) || symName.startsWith("__em_js__"), "isInternalSym");
2712
+ var uleb128Encode = /* @__PURE__ */ __name((n, target) => {
2713
+ if (n < 128) {
2714
+ target.push(n);
2715
+ } else {
2716
+ target.push(n % 128 | 128, n >> 7);
2717
+ }
2718
+ }, "uleb128Encode");
2719
+ var sigToWasmTypes = /* @__PURE__ */ __name((sig) => {
2720
+ var typeNames = {
2721
+ "i": "i32",
2722
+ "j": "i64",
2723
+ "f": "f32",
2724
+ "d": "f64",
2725
+ "e": "externref",
2726
+ "p": "i32"
2727
+ };
2728
+ var type = {
2729
+ parameters: [],
2730
+ results: sig[0] == "v" ? [] : [typeNames[sig[0]]]
2731
+ };
2732
+ for (var i2 = 1; i2 < sig.length; ++i2) {
2733
+ type.parameters.push(typeNames[sig[i2]]);
2734
+ }
2735
+ return type;
2736
+ }, "sigToWasmTypes");
2737
+ var generateFuncType = /* @__PURE__ */ __name((sig, target) => {
2738
+ var sigRet = sig.slice(0, 1);
2739
+ var sigParam = sig.slice(1);
2740
+ var typeCodes = {
2741
+ "i": 127,
2742
+ // i32
2743
+ "p": 127,
2744
+ // i32
2745
+ "j": 126,
2746
+ // i64
2747
+ "f": 125,
2748
+ // f32
2749
+ "d": 124,
2750
+ // f64
2751
+ "e": 111
2752
+ };
2753
+ target.push(96);
2754
+ uleb128Encode(sigParam.length, target);
2755
+ for (var i2 = 0; i2 < sigParam.length; ++i2) {
2756
+ target.push(typeCodes[sigParam[i2]]);
2757
+ }
2758
+ if (sigRet == "v") {
2759
+ target.push(0);
2760
+ } else {
2761
+ target.push(1, typeCodes[sigRet]);
2762
+ }
2763
+ }, "generateFuncType");
2764
+ var convertJsFunctionToWasm = /* @__PURE__ */ __name((func2, sig) => {
2765
+ if (typeof WebAssembly.Function == "function") {
2766
+ return new WebAssembly.Function(sigToWasmTypes(sig), func2);
2767
+ }
2768
+ var typeSectionBody = [1];
2769
+ generateFuncType(sig, typeSectionBody);
2770
+ var bytes = [
2771
+ 0,
2772
+ 97,
2773
+ 115,
2774
+ 109,
2775
+ // magic ("\0asm")
2776
+ 1,
2777
+ 0,
2778
+ 0,
2779
+ 0,
2780
+ // version: 1
2781
+ 1
2782
+ ];
2783
+ uleb128Encode(typeSectionBody.length, bytes);
2784
+ bytes.push(...typeSectionBody);
2785
+ bytes.push(
2786
+ 2,
2787
+ 7,
2788
+ // import section
2789
+ // (import "e" "f" (func 0 (type 0)))
2790
+ 1,
2791
+ 1,
2792
+ 101,
2793
+ 1,
2794
+ 102,
2795
+ 0,
2796
+ 0,
2797
+ 7,
2798
+ 5,
2799
+ // export section
2800
+ // (export "f" (func 0 (type 0)))
2801
+ 1,
2802
+ 1,
2803
+ 102,
2804
+ 0,
2805
+ 0
2806
+ );
2807
+ var module2 = new WebAssembly.Module(new Uint8Array(bytes));
2808
+ var instance2 = new WebAssembly.Instance(module2, {
2809
+ "e": {
2810
+ "f": func2
2811
+ }
2812
+ });
2813
+ var wrappedFunc = instance2.exports["f"];
2814
+ return wrappedFunc;
2815
+ }, "convertJsFunctionToWasm");
2816
+ var wasmTableMirror = [];
2817
+ var wasmTable = new WebAssembly.Table({
2818
+ "initial": 31,
2819
+ "element": "anyfunc"
2820
+ });
2821
+ var getWasmTableEntry = /* @__PURE__ */ __name((funcPtr) => {
2822
+ var func2 = wasmTableMirror[funcPtr];
2823
+ if (!func2) {
2824
+ if (funcPtr >= wasmTableMirror.length) wasmTableMirror.length = funcPtr + 1;
2825
+ wasmTableMirror[funcPtr] = func2 = wasmTable.get(funcPtr);
2826
+ }
2827
+ return func2;
2828
+ }, "getWasmTableEntry");
2829
+ var updateTableMap = /* @__PURE__ */ __name((offset, count) => {
2830
+ if (functionsInTableMap) {
2831
+ for (var i2 = offset; i2 < offset + count; i2++) {
2832
+ var item = getWasmTableEntry(i2);
2833
+ if (item) {
2834
+ functionsInTableMap.set(item, i2);
2835
+ }
2836
+ }
2837
+ }
2838
+ }, "updateTableMap");
2839
+ var functionsInTableMap;
2840
+ var getFunctionAddress = /* @__PURE__ */ __name((func2) => {
2841
+ if (!functionsInTableMap) {
2842
+ functionsInTableMap = /* @__PURE__ */ new WeakMap();
2843
+ updateTableMap(0, wasmTable.length);
2844
+ }
2845
+ return functionsInTableMap.get(func2) || 0;
2846
+ }, "getFunctionAddress");
2847
+ var freeTableIndexes = [];
2848
+ var getEmptyTableSlot = /* @__PURE__ */ __name(() => {
2849
+ if (freeTableIndexes.length) {
2850
+ return freeTableIndexes.pop();
2851
+ }
2852
+ try {
2853
+ wasmTable.grow(1);
2854
+ } catch (err2) {
2855
+ if (!(err2 instanceof RangeError)) {
2856
+ throw err2;
2857
+ }
2858
+ throw "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.";
2859
+ }
2860
+ return wasmTable.length - 1;
2861
+ }, "getEmptyTableSlot");
2862
+ var setWasmTableEntry = /* @__PURE__ */ __name((idx, func2) => {
2863
+ wasmTable.set(idx, func2);
2864
+ wasmTableMirror[idx] = wasmTable.get(idx);
2865
+ }, "setWasmTableEntry");
2866
+ var addFunction = /* @__PURE__ */ __name((func2, sig) => {
2867
+ var rtn = getFunctionAddress(func2);
2868
+ if (rtn) {
2869
+ return rtn;
2870
+ }
2871
+ var ret = getEmptyTableSlot();
2872
+ try {
2873
+ setWasmTableEntry(ret, func2);
2874
+ } catch (err2) {
2875
+ if (!(err2 instanceof TypeError)) {
2876
+ throw err2;
2877
+ }
2878
+ var wrapped = convertJsFunctionToWasm(func2, sig);
2879
+ setWasmTableEntry(ret, wrapped);
2880
+ }
2881
+ functionsInTableMap.set(func2, ret);
2882
+ return ret;
2883
+ }, "addFunction");
2884
+ var updateGOT = /* @__PURE__ */ __name((exports, replace) => {
2885
+ for (var symName in exports) {
2886
+ if (isInternalSym(symName)) {
2887
+ continue;
2888
+ }
2889
+ var value = exports[symName];
2890
+ if (symName.startsWith("orig$")) {
2891
+ symName = symName.split("$")[1];
2892
+ replace = true;
2893
+ }
2894
+ GOT[symName] ||= new WebAssembly.Global({
2895
+ "value": "i32",
2896
+ "mutable": true
2897
+ });
2898
+ if (replace || GOT[symName].value == 0) {
2899
+ if (typeof value == "function") {
2900
+ GOT[symName].value = addFunction(value);
2901
+ } else if (typeof value == "number") {
2902
+ GOT[symName].value = value;
2903
+ } else {
2904
+ err(`unhandled export type for '${symName}': ${typeof value}`);
2905
+ }
2906
+ }
2907
+ }
2908
+ }, "updateGOT");
2909
+ var relocateExports = /* @__PURE__ */ __name((exports, memoryBase2, replace) => {
2910
+ var relocated = {};
2911
+ for (var e in exports) {
2912
+ var value = exports[e];
2913
+ if (typeof value == "object") {
2914
+ value = value.value;
2915
+ }
2916
+ if (typeof value == "number") {
2917
+ value += memoryBase2;
2918
+ }
2919
+ relocated[e] = value;
2920
+ }
2921
+ updateGOT(relocated, replace);
2922
+ return relocated;
2923
+ }, "relocateExports");
2924
+ var isSymbolDefined = /* @__PURE__ */ __name((symName) => {
2925
+ var existing = wasmImports[symName];
2926
+ if (!existing || existing.stub) {
2927
+ return false;
2928
+ }
2929
+ return true;
2930
+ }, "isSymbolDefined");
2931
+ var dynCallLegacy = /* @__PURE__ */ __name((sig, ptr, args2) => {
2932
+ sig = sig.replace(/p/g, "i");
2933
+ var f = Module["dynCall_" + sig];
2934
+ return f(ptr, ...args2);
2935
+ }, "dynCallLegacy");
2936
+ var dynCall = /* @__PURE__ */ __name((sig, ptr, args2 = []) => {
2937
+ if (sig.includes("j")) {
2938
+ return dynCallLegacy(sig, ptr, args2);
2939
+ }
2940
+ var rtn = getWasmTableEntry(ptr)(...args2);
2941
+ return rtn;
2942
+ }, "dynCall");
2943
+ var stackSave = /* @__PURE__ */ __name(() => _emscripten_stack_get_current(), "stackSave");
2944
+ var stackRestore = /* @__PURE__ */ __name((val) => __emscripten_stack_restore(val), "stackRestore");
2945
+ var createInvokeFunction = /* @__PURE__ */ __name((sig) => (ptr, ...args2) => {
2946
+ var sp = stackSave();
2947
+ try {
2948
+ return dynCall(sig, ptr, args2);
2949
+ } catch (e) {
2950
+ stackRestore(sp);
2951
+ if (e !== e + 0) throw e;
2952
+ _setThrew(1, 0);
2953
+ }
2954
+ }, "createInvokeFunction");
2955
+ var resolveGlobalSymbol = /* @__PURE__ */ __name((symName, direct = false) => {
2956
+ var sym;
2957
+ if (direct && "orig$" + symName in wasmImports) {
2958
+ symName = "orig$" + symName;
2959
+ }
2960
+ if (isSymbolDefined(symName)) {
2961
+ sym = wasmImports[symName];
2962
+ } else if (symName.startsWith("invoke_")) {
2963
+ sym = wasmImports[symName] = createInvokeFunction(symName.split("_")[1]);
2964
+ }
2965
+ return {
2966
+ sym,
2967
+ name: symName
2968
+ };
2969
+ }, "resolveGlobalSymbol");
2970
+ var UTF8ToString = /* @__PURE__ */ __name((ptr, maxBytesToRead) => ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : "", "UTF8ToString");
2971
+ var loadWebAssemblyModule = /* @__PURE__ */ __name((binary, flags, libName, localScope, handle) => {
2972
+ var metadata = getDylinkMetadata(binary);
2973
+ currentModuleWeakSymbols = metadata.weakImports;
2974
+ function loadModule() {
2975
+ var firstLoad = !handle || !HEAP8[handle + 8];
2976
+ if (firstLoad) {
2977
+ var memAlign = Math.pow(2, metadata.memoryAlign);
2978
+ var memoryBase = metadata.memorySize ? alignMemory(getMemory(metadata.memorySize + memAlign), memAlign) : 0;
2979
+ var tableBase = metadata.tableSize ? wasmTable.length : 0;
2980
+ if (handle) {
2981
+ HEAP8[handle + 8] = 1;
2982
+ LE_HEAP_STORE_U32((handle + 12 >> 2) * 4, memoryBase);
2983
+ LE_HEAP_STORE_I32((handle + 16 >> 2) * 4, metadata.memorySize);
2984
+ LE_HEAP_STORE_U32((handle + 20 >> 2) * 4, tableBase);
2985
+ LE_HEAP_STORE_I32((handle + 24 >> 2) * 4, metadata.tableSize);
2986
+ }
2987
+ } else {
2988
+ memoryBase = LE_HEAP_LOAD_U32((handle + 12 >> 2) * 4);
2989
+ tableBase = LE_HEAP_LOAD_U32((handle + 20 >> 2) * 4);
2990
+ }
2991
+ var tableGrowthNeeded = tableBase + metadata.tableSize - wasmTable.length;
2992
+ if (tableGrowthNeeded > 0) {
2993
+ wasmTable.grow(tableGrowthNeeded);
2994
+ }
2995
+ var moduleExports;
2996
+ function resolveSymbol(sym) {
2997
+ var resolved = resolveGlobalSymbol(sym).sym;
2998
+ if (!resolved && localScope) {
2999
+ resolved = localScope[sym];
3000
+ }
3001
+ if (!resolved) {
3002
+ resolved = moduleExports[sym];
3003
+ }
3004
+ return resolved;
3005
+ }
3006
+ __name(resolveSymbol, "resolveSymbol");
3007
+ var proxyHandler = {
3008
+ get(stubs, prop) {
3009
+ switch (prop) {
3010
+ case "__memory_base":
3011
+ return memoryBase;
3012
+ case "__table_base":
3013
+ return tableBase;
3014
+ }
3015
+ if (prop in wasmImports && !wasmImports[prop].stub) {
3016
+ return wasmImports[prop];
3017
+ }
3018
+ if (!(prop in stubs)) {
3019
+ var resolved;
3020
+ stubs[prop] = (...args2) => {
3021
+ resolved ||= resolveSymbol(prop);
3022
+ return resolved(...args2);
3023
+ };
3024
+ }
3025
+ return stubs[prop];
3026
+ }
3027
+ };
3028
+ var proxy = new Proxy({}, proxyHandler);
3029
+ var info = {
3030
+ "GOT.mem": new Proxy({}, GOTHandler),
3031
+ "GOT.func": new Proxy({}, GOTHandler),
3032
+ "env": proxy,
3033
+ "wasi_snapshot_preview1": proxy
3034
+ };
3035
+ function postInstantiation(module, instance) {
3036
+ updateTableMap(tableBase, metadata.tableSize);
3037
+ moduleExports = relocateExports(instance.exports, memoryBase);
3038
+ if (!flags.allowUndefined) {
3039
+ reportUndefinedSymbols();
3040
+ }
3041
+ function addEmAsm(addr, body) {
3042
+ var args = [];
3043
+ var arity = 0;
3044
+ for (; arity < 16; arity++) {
3045
+ if (body.indexOf("$" + arity) != -1) {
3046
+ args.push("$" + arity);
3047
+ } else {
3048
+ break;
3049
+ }
3050
+ }
3051
+ args = args.join(",");
3052
+ var func = `(${args}) => { ${body} };`;
3053
+ ASM_CONSTS[start] = eval(func);
3054
+ }
3055
+ __name(addEmAsm, "addEmAsm");
3056
+ if ("__start_em_asm" in moduleExports) {
3057
+ var start = moduleExports["__start_em_asm"];
3058
+ var stop = moduleExports["__stop_em_asm"];
3059
+ while (start < stop) {
3060
+ var jsString = UTF8ToString(start);
3061
+ addEmAsm(start, jsString);
3062
+ start = HEAPU8.indexOf(0, start) + 1;
3063
+ }
3064
+ }
3065
+ function addEmJs(name, cSig, body) {
3066
+ var jsArgs = [];
3067
+ cSig = cSig.slice(1, -1);
3068
+ if (cSig != "void") {
3069
+ cSig = cSig.split(",");
3070
+ for (var i in cSig) {
3071
+ var jsArg = cSig[i].split(" ").pop();
3072
+ jsArgs.push(jsArg.replace("*", ""));
3073
+ }
3074
+ }
3075
+ var func = `(${jsArgs}) => ${body};`;
3076
+ moduleExports[name] = eval(func);
3077
+ }
3078
+ __name(addEmJs, "addEmJs");
3079
+ for (var name in moduleExports) {
3080
+ if (name.startsWith("__em_js__")) {
3081
+ var start = moduleExports[name];
3082
+ var jsString = UTF8ToString(start);
3083
+ var parts = jsString.split("<::>");
3084
+ addEmJs(name.replace("__em_js__", ""), parts[0], parts[1]);
3085
+ delete moduleExports[name];
3086
+ }
3087
+ }
3088
+ var applyRelocs = moduleExports["__wasm_apply_data_relocs"];
3089
+ if (applyRelocs) {
3090
+ if (runtimeInitialized) {
3091
+ applyRelocs();
3092
+ } else {
3093
+ __RELOC_FUNCS__.push(applyRelocs);
3094
+ }
3095
+ }
3096
+ var init = moduleExports["__wasm_call_ctors"];
3097
+ if (init) {
3098
+ if (runtimeInitialized) {
3099
+ init();
3100
+ } else {
3101
+ __ATINIT__.push(init);
3102
+ }
3103
+ }
3104
+ return moduleExports;
3105
+ }
3106
+ __name(postInstantiation, "postInstantiation");
3107
+ if (flags.loadAsync) {
3108
+ if (binary instanceof WebAssembly.Module) {
3109
+ var instance = new WebAssembly.Instance(binary, info);
3110
+ return Promise.resolve(postInstantiation(binary, instance));
3111
+ }
3112
+ return WebAssembly.instantiate(binary, info).then((result) => postInstantiation(result.module, result.instance));
3113
+ }
3114
+ var module = binary instanceof WebAssembly.Module ? binary : new WebAssembly.Module(binary);
3115
+ var instance = new WebAssembly.Instance(module, info);
3116
+ return postInstantiation(module, instance);
3117
+ }
3118
+ __name(loadModule, "loadModule");
3119
+ if (flags.loadAsync) {
3120
+ return metadata.neededDynlibs.reduce((chain, dynNeeded) => chain.then(() => loadDynamicLibrary(dynNeeded, flags, localScope)), Promise.resolve()).then(loadModule);
3121
+ }
3122
+ metadata.neededDynlibs.forEach((needed) => loadDynamicLibrary(needed, flags, localScope));
3123
+ return loadModule();
3124
+ }, "loadWebAssemblyModule");
3125
+ var mergeLibSymbols = /* @__PURE__ */ __name((exports, libName2) => {
3126
+ for (var [sym, exp] of Object.entries(exports)) {
3127
+ const setImport = /* @__PURE__ */ __name((target) => {
3128
+ if (!isSymbolDefined(target)) {
3129
+ wasmImports[target] = exp;
3130
+ }
3131
+ }, "setImport");
3132
+ setImport(sym);
3133
+ const main_alias = "__main_argc_argv";
3134
+ if (sym == "main") {
3135
+ setImport(main_alias);
3136
+ }
3137
+ if (sym == main_alias) {
3138
+ setImport("main");
3139
+ }
3140
+ if (sym.startsWith("dynCall_") && !Module.hasOwnProperty(sym)) {
3141
+ Module[sym] = exp;
3142
+ }
3143
+ }
3144
+ }, "mergeLibSymbols");
3145
+ var asyncLoad = /* @__PURE__ */ __name((url, onload, onerror, noRunDep) => {
3146
+ var dep = !noRunDep ? getUniqueRunDependency(`al ${url}`) : "";
3147
+ readAsync(url).then((arrayBuffer) => {
3148
+ onload(new Uint8Array(arrayBuffer));
3149
+ if (dep) removeRunDependency(dep);
3150
+ }, (err2) => {
3151
+ if (onerror) {
3152
+ onerror();
3153
+ } else {
3154
+ throw `Loading data file "${url}" failed.`;
3155
+ }
3156
+ });
3157
+ if (dep) addRunDependency(dep);
3158
+ }, "asyncLoad");
3159
+ function loadDynamicLibrary(libName2, flags2 = {
3160
+ global: true,
3161
+ nodelete: true
3162
+ }, localScope2, handle2) {
3163
+ var dso = LDSO.loadedLibsByName[libName2];
3164
+ if (dso) {
3165
+ if (!flags2.global) {
3166
+ if (localScope2) {
3167
+ Object.assign(localScope2, dso.exports);
3168
+ }
3169
+ } else if (!dso.global) {
3170
+ dso.global = true;
3171
+ mergeLibSymbols(dso.exports, libName2);
3172
+ }
3173
+ if (flags2.nodelete && dso.refcount !== Infinity) {
3174
+ dso.refcount = Infinity;
3175
+ }
3176
+ dso.refcount++;
3177
+ if (handle2) {
3178
+ LDSO.loadedLibsByHandle[handle2] = dso;
3179
+ }
3180
+ return flags2.loadAsync ? Promise.resolve(true) : true;
3181
+ }
3182
+ dso = newDSO(libName2, handle2, "loading");
3183
+ dso.refcount = flags2.nodelete ? Infinity : 1;
3184
+ dso.global = flags2.global;
3185
+ function loadLibData() {
3186
+ if (handle2) {
3187
+ var data = LE_HEAP_LOAD_U32((handle2 + 28 >> 2) * 4);
3188
+ var dataSize = LE_HEAP_LOAD_U32((handle2 + 32 >> 2) * 4);
3189
+ if (data && dataSize) {
3190
+ var libData = HEAP8.slice(data, data + dataSize);
3191
+ return flags2.loadAsync ? Promise.resolve(libData) : libData;
3192
+ }
3193
+ }
3194
+ var libFile = locateFile(libName2);
3195
+ if (flags2.loadAsync) {
3196
+ return new Promise(function(resolve, reject) {
3197
+ asyncLoad(libFile, resolve, reject);
3198
+ });
3199
+ }
3200
+ if (!readBinary) {
3201
+ throw new Error(`${libFile}: file not found, and synchronous loading of external files is not available`);
3202
+ }
3203
+ return readBinary(libFile);
3204
+ }
3205
+ __name(loadLibData, "loadLibData");
3206
+ function getExports() {
3207
+ if (flags2.loadAsync) {
3208
+ return loadLibData().then((libData) => loadWebAssemblyModule(libData, flags2, libName2, localScope2, handle2));
3209
+ }
3210
+ return loadWebAssemblyModule(loadLibData(), flags2, libName2, localScope2, handle2);
3211
+ }
3212
+ __name(getExports, "getExports");
3213
+ function moduleLoaded(exports) {
3214
+ if (dso.global) {
3215
+ mergeLibSymbols(exports, libName2);
3216
+ } else if (localScope2) {
3217
+ Object.assign(localScope2, exports);
3218
+ }
3219
+ dso.exports = exports;
3220
+ }
3221
+ __name(moduleLoaded, "moduleLoaded");
3222
+ if (flags2.loadAsync) {
3223
+ return getExports().then((exports) => {
3224
+ moduleLoaded(exports);
3225
+ return true;
3226
+ });
3227
+ }
3228
+ moduleLoaded(getExports());
3229
+ return true;
3230
+ }
3231
+ __name(loadDynamicLibrary, "loadDynamicLibrary");
3232
+ var reportUndefinedSymbols = /* @__PURE__ */ __name(() => {
3233
+ for (var [symName, entry] of Object.entries(GOT)) {
3234
+ if (entry.value == 0) {
3235
+ var value = resolveGlobalSymbol(symName, true).sym;
3236
+ if (!value && !entry.required) {
3237
+ continue;
3238
+ }
3239
+ if (typeof value == "function") {
3240
+ entry.value = addFunction(value, value.sig);
3241
+ } else if (typeof value == "number") {
3242
+ entry.value = value;
3243
+ } else {
3244
+ throw new Error(`bad export type for '${symName}': ${typeof value}`);
3245
+ }
3246
+ }
3247
+ }
3248
+ }, "reportUndefinedSymbols");
3249
+ var loadDylibs = /* @__PURE__ */ __name(() => {
3250
+ if (!dynamicLibraries.length) {
3251
+ reportUndefinedSymbols();
3252
+ return;
3253
+ }
3254
+ addRunDependency("loadDylibs");
3255
+ dynamicLibraries.reduce((chain, lib) => chain.then(() => loadDynamicLibrary(lib, {
3256
+ loadAsync: true,
3257
+ global: true,
3258
+ nodelete: true,
3259
+ allowUndefined: true
3260
+ })), Promise.resolve()).then(() => {
3261
+ reportUndefinedSymbols();
3262
+ removeRunDependency("loadDylibs");
3263
+ });
3264
+ }, "loadDylibs");
3265
+ var noExitRuntime = Module["noExitRuntime"] || true;
3266
+ function setValue(ptr, value, type = "i8") {
3267
+ if (type.endsWith("*")) type = "*";
3268
+ switch (type) {
3269
+ case "i1":
3270
+ HEAP8[ptr] = value;
3271
+ break;
3272
+ case "i8":
3273
+ HEAP8[ptr] = value;
3274
+ break;
3275
+ case "i16":
3276
+ LE_HEAP_STORE_I16((ptr >> 1) * 2, value);
3277
+ break;
3278
+ case "i32":
3279
+ LE_HEAP_STORE_I32((ptr >> 2) * 4, value);
3280
+ break;
3281
+ case "i64":
3282
+ abort("to do setValue(i64) use WASM_BIGINT");
3283
+ case "float":
3284
+ LE_HEAP_STORE_F32((ptr >> 2) * 4, value);
3285
+ break;
3286
+ case "double":
3287
+ LE_HEAP_STORE_F64((ptr >> 3) * 8, value);
3288
+ break;
3289
+ case "*":
3290
+ LE_HEAP_STORE_U32((ptr >> 2) * 4, value);
3291
+ break;
3292
+ default:
3293
+ abort(`invalid type for setValue: ${type}`);
3294
+ }
3295
+ }
3296
+ __name(setValue, "setValue");
3297
+ var ___memory_base = new WebAssembly.Global({
3298
+ "value": "i32",
3299
+ "mutable": false
3300
+ }, 1024);
3301
+ var ___stack_pointer = new WebAssembly.Global({
3302
+ "value": "i32",
3303
+ "mutable": true
3304
+ }, 78160);
3305
+ var ___table_base = new WebAssembly.Global({
3306
+ "value": "i32",
3307
+ "mutable": false
3308
+ }, 1);
3309
+ var __abort_js = /* @__PURE__ */ __name(() => {
3310
+ abort("");
3311
+ }, "__abort_js");
3312
+ __abort_js.sig = "v";
3313
+ var nowIsMonotonic = 1;
3314
+ var __emscripten_get_now_is_monotonic = /* @__PURE__ */ __name(() => nowIsMonotonic, "__emscripten_get_now_is_monotonic");
3315
+ __emscripten_get_now_is_monotonic.sig = "i";
3316
+ var __emscripten_memcpy_js = /* @__PURE__ */ __name((dest, src, num) => HEAPU8.copyWithin(dest, src, src + num), "__emscripten_memcpy_js");
3317
+ __emscripten_memcpy_js.sig = "vppp";
3318
+ var _emscripten_date_now = /* @__PURE__ */ __name(() => Date.now(), "_emscripten_date_now");
3319
+ _emscripten_date_now.sig = "d";
3320
+ var _emscripten_get_now;
3321
+ _emscripten_get_now = /* @__PURE__ */ __name(() => performance.now(), "_emscripten_get_now");
3322
+ _emscripten_get_now.sig = "d";
3323
+ var getHeapMax = /* @__PURE__ */ __name(() => (
3324
+ // Stay one Wasm page short of 4GB: while e.g. Chrome is able to allocate
3325
+ // full 4GB Wasm memories, the size will wrap back to 0 bytes in Wasm side
3326
+ // for any code that deals with heap sizes, which would require special
3327
+ // casing all heap size related code to treat 0 specially.
3328
+ 2147483648
3329
+ ), "getHeapMax");
3330
+ var growMemory = /* @__PURE__ */ __name((size) => {
3331
+ var b = wasmMemory.buffer;
3332
+ var pages = (size - b.byteLength + 65535) / 65536;
3333
+ try {
3334
+ wasmMemory.grow(pages);
3335
+ updateMemoryViews();
3336
+ return 1;
3337
+ } catch (e) {
3338
+ }
3339
+ }, "growMemory");
3340
+ var _emscripten_resize_heap = /* @__PURE__ */ __name((requestedSize) => {
3341
+ var oldSize = HEAPU8.length;
3342
+ requestedSize >>>= 0;
3343
+ var maxHeapSize = getHeapMax();
3344
+ if (requestedSize > maxHeapSize) {
3345
+ return false;
3346
+ }
3347
+ var alignUp = /* @__PURE__ */ __name((x, multiple) => x + (multiple - x % multiple) % multiple, "alignUp");
3348
+ for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {
3349
+ var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown);
3350
+ overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);
3351
+ var newSize = Math.min(maxHeapSize, alignUp(Math.max(requestedSize, overGrownHeapSize), 65536));
3352
+ var replacement = growMemory(newSize);
3353
+ if (replacement) {
3354
+ return true;
3355
+ }
3356
+ }
3357
+ return false;
3358
+ }, "_emscripten_resize_heap");
3359
+ _emscripten_resize_heap.sig = "ip";
3360
+ var _fd_close = /* @__PURE__ */ __name((fd) => 52, "_fd_close");
3361
+ _fd_close.sig = "ii";
3362
+ var convertI32PairToI53Checked = /* @__PURE__ */ __name((lo, hi) => hi + 2097152 >>> 0 < 4194305 - !!lo ? (lo >>> 0) + hi * 4294967296 : NaN, "convertI32PairToI53Checked");
3363
+ function _fd_seek(fd, offset_low, offset_high, whence, newOffset) {
3364
+ var offset = convertI32PairToI53Checked(offset_low, offset_high);
3365
+ return 70;
3366
+ }
3367
+ __name(_fd_seek, "_fd_seek");
3368
+ _fd_seek.sig = "iiiiip";
3369
+ var printCharBuffers = [null, [], []];
3370
+ var printChar = /* @__PURE__ */ __name((stream, curr) => {
3371
+ var buffer = printCharBuffers[stream];
3372
+ if (curr === 0 || curr === 10) {
3373
+ (stream === 1 ? out : err)(UTF8ArrayToString(buffer, 0));
3374
+ buffer.length = 0;
3375
+ } else {
3376
+ buffer.push(curr);
3377
+ }
3378
+ }, "printChar");
3379
+ var flush_NO_FILESYSTEM = /* @__PURE__ */ __name(() => {
3380
+ if (printCharBuffers[1].length) printChar(1, 10);
3381
+ if (printCharBuffers[2].length) printChar(2, 10);
3382
+ }, "flush_NO_FILESYSTEM");
3383
+ var SYSCALLS = {
3384
+ varargs: void 0,
3385
+ getStr(ptr) {
3386
+ var ret = UTF8ToString(ptr);
3387
+ return ret;
3388
+ }
3389
+ };
3390
+ var _fd_write = /* @__PURE__ */ __name((fd, iov, iovcnt, pnum) => {
3391
+ var num = 0;
3392
+ for (var i2 = 0; i2 < iovcnt; i2++) {
3393
+ var ptr = LE_HEAP_LOAD_U32((iov >> 2) * 4);
3394
+ var len = LE_HEAP_LOAD_U32((iov + 4 >> 2) * 4);
3395
+ iov += 8;
3396
+ for (var j = 0; j < len; j++) {
3397
+ printChar(fd, HEAPU8[ptr + j]);
3398
+ }
3399
+ num += len;
3400
+ }
3401
+ LE_HEAP_STORE_U32((pnum >> 2) * 4, num);
3402
+ return 0;
3403
+ }, "_fd_write");
3404
+ _fd_write.sig = "iippp";
3405
+ function _tree_sitter_log_callback(isLexMessage, messageAddress) {
3406
+ if (Module.currentLogCallback) {
3407
+ const message = UTF8ToString(messageAddress);
3408
+ Module.currentLogCallback(message, isLexMessage !== 0);
3409
+ }
3410
+ }
3411
+ __name(_tree_sitter_log_callback, "_tree_sitter_log_callback");
3412
+ function _tree_sitter_parse_callback(inputBufferAddress, index, row, column, lengthAddress) {
3413
+ const INPUT_BUFFER_SIZE = 10 * 1024;
3414
+ const string = Module.currentParseCallback(index, {
3415
+ row,
3416
+ column
3417
+ });
3418
+ if (typeof string === "string") {
3419
+ setValue(lengthAddress, string.length, "i32");
3420
+ stringToUTF16(string, inputBufferAddress, INPUT_BUFFER_SIZE);
3421
+ } else {
3422
+ setValue(lengthAddress, 0, "i32");
3423
+ }
3424
+ }
3425
+ __name(_tree_sitter_parse_callback, "_tree_sitter_parse_callback");
3426
+ function _tree_sitter_progress_callback(currentOffset, hasError) {
3427
+ if (Module.currentProgressCallback) {
3428
+ return Module.currentProgressCallback({
3429
+ currentOffset,
3430
+ hasError
3431
+ });
3432
+ }
3433
+ return false;
3434
+ }
3435
+ __name(_tree_sitter_progress_callback, "_tree_sitter_progress_callback");
3436
+ function _tree_sitter_query_progress_callback(currentOffset) {
3437
+ if (Module.currentQueryProgressCallback) {
3438
+ return Module.currentQueryProgressCallback({
3439
+ currentOffset
3440
+ });
3441
+ }
3442
+ return false;
3443
+ }
3444
+ __name(_tree_sitter_query_progress_callback, "_tree_sitter_query_progress_callback");
3445
+ var runtimeKeepaliveCounter = 0;
3446
+ var keepRuntimeAlive = /* @__PURE__ */ __name(() => noExitRuntime || runtimeKeepaliveCounter > 0, "keepRuntimeAlive");
3447
+ var _proc_exit = /* @__PURE__ */ __name((code) => {
3448
+ EXITSTATUS = code;
3449
+ if (!keepRuntimeAlive()) {
3450
+ Module["onExit"]?.(code);
3451
+ ABORT = true;
3452
+ }
3453
+ quit_(code, new ExitStatus(code));
3454
+ }, "_proc_exit");
3455
+ _proc_exit.sig = "vi";
3456
+ var exitJS = /* @__PURE__ */ __name((status, implicit) => {
3457
+ EXITSTATUS = status;
3458
+ _proc_exit(status);
3459
+ }, "exitJS");
3460
+ var handleException = /* @__PURE__ */ __name((e) => {
3461
+ if (e instanceof ExitStatus || e == "unwind") {
3462
+ return EXITSTATUS;
3463
+ }
3464
+ quit_(1, e);
3465
+ }, "handleException");
3466
+ var lengthBytesUTF8 = /* @__PURE__ */ __name((str) => {
3467
+ var len = 0;
3468
+ for (var i2 = 0; i2 < str.length; ++i2) {
3469
+ var c = str.charCodeAt(i2);
3470
+ if (c <= 127) {
3471
+ len++;
3472
+ } else if (c <= 2047) {
3473
+ len += 2;
3474
+ } else if (c >= 55296 && c <= 57343) {
3475
+ len += 4;
3476
+ ++i2;
3477
+ } else {
3478
+ len += 3;
3479
+ }
3480
+ }
3481
+ return len;
3482
+ }, "lengthBytesUTF8");
3483
+ var stringToUTF8Array = /* @__PURE__ */ __name((str, heap, outIdx, maxBytesToWrite) => {
3484
+ if (!(maxBytesToWrite > 0)) return 0;
3485
+ var startIdx = outIdx;
3486
+ var endIdx = outIdx + maxBytesToWrite - 1;
3487
+ for (var i2 = 0; i2 < str.length; ++i2) {
3488
+ var u = str.charCodeAt(i2);
3489
+ if (u >= 55296 && u <= 57343) {
3490
+ var u1 = str.charCodeAt(++i2);
3491
+ u = 65536 + ((u & 1023) << 10) | u1 & 1023;
3492
+ }
3493
+ if (u <= 127) {
3494
+ if (outIdx >= endIdx) break;
3495
+ heap[outIdx++] = u;
3496
+ } else if (u <= 2047) {
3497
+ if (outIdx + 1 >= endIdx) break;
3498
+ heap[outIdx++] = 192 | u >> 6;
3499
+ heap[outIdx++] = 128 | u & 63;
3500
+ } else if (u <= 65535) {
3501
+ if (outIdx + 2 >= endIdx) break;
3502
+ heap[outIdx++] = 224 | u >> 12;
3503
+ heap[outIdx++] = 128 | u >> 6 & 63;
3504
+ heap[outIdx++] = 128 | u & 63;
3505
+ } else {
3506
+ if (outIdx + 3 >= endIdx) break;
3507
+ heap[outIdx++] = 240 | u >> 18;
3508
+ heap[outIdx++] = 128 | u >> 12 & 63;
3509
+ heap[outIdx++] = 128 | u >> 6 & 63;
3510
+ heap[outIdx++] = 128 | u & 63;
3511
+ }
3512
+ }
3513
+ heap[outIdx] = 0;
3514
+ return outIdx - startIdx;
3515
+ }, "stringToUTF8Array");
3516
+ var stringToUTF8 = /* @__PURE__ */ __name((str, outPtr, maxBytesToWrite) => stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite), "stringToUTF8");
3517
+ var stackAlloc = /* @__PURE__ */ __name((sz) => __emscripten_stack_alloc(sz), "stackAlloc");
3518
+ var stringToUTF8OnStack = /* @__PURE__ */ __name((str) => {
3519
+ var size = lengthBytesUTF8(str) + 1;
3520
+ var ret = stackAlloc(size);
3521
+ stringToUTF8(str, ret, size);
3522
+ return ret;
3523
+ }, "stringToUTF8OnStack");
3524
+ var AsciiToString = /* @__PURE__ */ __name((ptr) => {
3525
+ var str = "";
3526
+ while (1) {
3527
+ var ch = HEAPU8[ptr++];
3528
+ if (!ch) return str;
3529
+ str += String.fromCharCode(ch);
3530
+ }
3531
+ }, "AsciiToString");
3532
+ var stringToUTF16 = /* @__PURE__ */ __name((str, outPtr, maxBytesToWrite) => {
3533
+ maxBytesToWrite ??= 2147483647;
3534
+ if (maxBytesToWrite < 2) return 0;
3535
+ maxBytesToWrite -= 2;
3536
+ var startPtr = outPtr;
3537
+ var numCharsToWrite = maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length;
3538
+ for (var i2 = 0; i2 < numCharsToWrite; ++i2) {
3539
+ var codeUnit = str.charCodeAt(i2);
3540
+ LE_HEAP_STORE_I16((outPtr >> 1) * 2, codeUnit);
3541
+ outPtr += 2;
3542
+ }
3543
+ LE_HEAP_STORE_I16((outPtr >> 1) * 2, 0);
3544
+ return outPtr - startPtr;
3545
+ }, "stringToUTF16");
3546
+ var wasmImports = {
3547
+ /** @export */
3548
+ __heap_base: ___heap_base,
3549
+ /** @export */
3550
+ __indirect_function_table: wasmTable,
3551
+ /** @export */
3552
+ __memory_base: ___memory_base,
3553
+ /** @export */
3554
+ __stack_pointer: ___stack_pointer,
3555
+ /** @export */
3556
+ __table_base: ___table_base,
3557
+ /** @export */
3558
+ _abort_js: __abort_js,
3559
+ /** @export */
3560
+ _emscripten_get_now_is_monotonic: __emscripten_get_now_is_monotonic,
3561
+ /** @export */
3562
+ _emscripten_memcpy_js: __emscripten_memcpy_js,
3563
+ /** @export */
3564
+ emscripten_date_now: _emscripten_date_now,
3565
+ /** @export */
3566
+ emscripten_get_now: _emscripten_get_now,
3567
+ /** @export */
3568
+ emscripten_resize_heap: _emscripten_resize_heap,
3569
+ /** @export */
3570
+ fd_close: _fd_close,
3571
+ /** @export */
3572
+ fd_seek: _fd_seek,
3573
+ /** @export */
3574
+ fd_write: _fd_write,
3575
+ /** @export */
3576
+ memory: wasmMemory,
3577
+ /** @export */
3578
+ tree_sitter_log_callback: _tree_sitter_log_callback,
3579
+ /** @export */
3580
+ tree_sitter_parse_callback: _tree_sitter_parse_callback,
3581
+ /** @export */
3582
+ tree_sitter_progress_callback: _tree_sitter_progress_callback,
3583
+ /** @export */
3584
+ tree_sitter_query_progress_callback: _tree_sitter_query_progress_callback
3585
+ };
3586
+ var wasmExports = createWasm();
3587
+ var ___wasm_call_ctors = /* @__PURE__ */ __name(() => (___wasm_call_ctors = wasmExports["__wasm_call_ctors"])(), "___wasm_call_ctors");
3588
+ var ___wasm_apply_data_relocs = /* @__PURE__ */ __name(() => (___wasm_apply_data_relocs = wasmExports["__wasm_apply_data_relocs"])(), "___wasm_apply_data_relocs");
3589
+ var _malloc = Module["_malloc"] = (a0) => (_malloc = Module["_malloc"] = wasmExports["malloc"])(a0);
3590
+ var _calloc = Module["_calloc"] = (a0, a1) => (_calloc = Module["_calloc"] = wasmExports["calloc"])(a0, a1);
3591
+ var _realloc = Module["_realloc"] = (a0, a1) => (_realloc = Module["_realloc"] = wasmExports["realloc"])(a0, a1);
3592
+ var _free = Module["_free"] = (a0) => (_free = Module["_free"] = wasmExports["free"])(a0);
3593
+ var _ts_language_symbol_count = Module["_ts_language_symbol_count"] = (a0) => (_ts_language_symbol_count = Module["_ts_language_symbol_count"] = wasmExports["ts_language_symbol_count"])(a0);
3594
+ var _ts_language_state_count = Module["_ts_language_state_count"] = (a0) => (_ts_language_state_count = Module["_ts_language_state_count"] = wasmExports["ts_language_state_count"])(a0);
3595
+ var _ts_language_version = Module["_ts_language_version"] = (a0) => (_ts_language_version = Module["_ts_language_version"] = wasmExports["ts_language_version"])(a0);
3596
+ var _ts_language_abi_version = Module["_ts_language_abi_version"] = (a0) => (_ts_language_abi_version = Module["_ts_language_abi_version"] = wasmExports["ts_language_abi_version"])(a0);
3597
+ var _ts_language_metadata = Module["_ts_language_metadata"] = (a0) => (_ts_language_metadata = Module["_ts_language_metadata"] = wasmExports["ts_language_metadata"])(a0);
3598
+ var _ts_language_name = Module["_ts_language_name"] = (a0) => (_ts_language_name = Module["_ts_language_name"] = wasmExports["ts_language_name"])(a0);
3599
+ var _ts_language_field_count = Module["_ts_language_field_count"] = (a0) => (_ts_language_field_count = Module["_ts_language_field_count"] = wasmExports["ts_language_field_count"])(a0);
3600
+ var _ts_language_next_state = Module["_ts_language_next_state"] = (a0, a1, a2) => (_ts_language_next_state = Module["_ts_language_next_state"] = wasmExports["ts_language_next_state"])(a0, a1, a2);
3601
+ var _ts_language_symbol_name = Module["_ts_language_symbol_name"] = (a0, a1) => (_ts_language_symbol_name = Module["_ts_language_symbol_name"] = wasmExports["ts_language_symbol_name"])(a0, a1);
3602
+ var _ts_language_symbol_for_name = Module["_ts_language_symbol_for_name"] = (a0, a1, a2, a3) => (_ts_language_symbol_for_name = Module["_ts_language_symbol_for_name"] = wasmExports["ts_language_symbol_for_name"])(a0, a1, a2, a3);
3603
+ var _strncmp = Module["_strncmp"] = (a0, a1, a2) => (_strncmp = Module["_strncmp"] = wasmExports["strncmp"])(a0, a1, a2);
3604
+ var _ts_language_symbol_type = Module["_ts_language_symbol_type"] = (a0, a1) => (_ts_language_symbol_type = Module["_ts_language_symbol_type"] = wasmExports["ts_language_symbol_type"])(a0, a1);
3605
+ var _ts_language_field_name_for_id = Module["_ts_language_field_name_for_id"] = (a0, a1) => (_ts_language_field_name_for_id = Module["_ts_language_field_name_for_id"] = wasmExports["ts_language_field_name_for_id"])(a0, a1);
3606
+ var _ts_lookahead_iterator_new = Module["_ts_lookahead_iterator_new"] = (a0, a1) => (_ts_lookahead_iterator_new = Module["_ts_lookahead_iterator_new"] = wasmExports["ts_lookahead_iterator_new"])(a0, a1);
3607
+ var _ts_lookahead_iterator_delete = Module["_ts_lookahead_iterator_delete"] = (a0) => (_ts_lookahead_iterator_delete = Module["_ts_lookahead_iterator_delete"] = wasmExports["ts_lookahead_iterator_delete"])(a0);
3608
+ var _ts_lookahead_iterator_reset_state = Module["_ts_lookahead_iterator_reset_state"] = (a0, a1) => (_ts_lookahead_iterator_reset_state = Module["_ts_lookahead_iterator_reset_state"] = wasmExports["ts_lookahead_iterator_reset_state"])(a0, a1);
3609
+ var _ts_lookahead_iterator_reset = Module["_ts_lookahead_iterator_reset"] = (a0, a1, a2) => (_ts_lookahead_iterator_reset = Module["_ts_lookahead_iterator_reset"] = wasmExports["ts_lookahead_iterator_reset"])(a0, a1, a2);
3610
+ var _ts_lookahead_iterator_next = Module["_ts_lookahead_iterator_next"] = (a0) => (_ts_lookahead_iterator_next = Module["_ts_lookahead_iterator_next"] = wasmExports["ts_lookahead_iterator_next"])(a0);
3611
+ var _ts_lookahead_iterator_current_symbol = Module["_ts_lookahead_iterator_current_symbol"] = (a0) => (_ts_lookahead_iterator_current_symbol = Module["_ts_lookahead_iterator_current_symbol"] = wasmExports["ts_lookahead_iterator_current_symbol"])(a0);
3612
+ var _memset = Module["_memset"] = (a0, a1, a2) => (_memset = Module["_memset"] = wasmExports["memset"])(a0, a1, a2);
3613
+ var _memcpy = Module["_memcpy"] = (a0, a1, a2) => (_memcpy = Module["_memcpy"] = wasmExports["memcpy"])(a0, a1, a2);
3614
+ var _ts_parser_delete = Module["_ts_parser_delete"] = (a0) => (_ts_parser_delete = Module["_ts_parser_delete"] = wasmExports["ts_parser_delete"])(a0);
3615
+ var _ts_parser_reset = Module["_ts_parser_reset"] = (a0) => (_ts_parser_reset = Module["_ts_parser_reset"] = wasmExports["ts_parser_reset"])(a0);
3616
+ var _ts_parser_set_language = Module["_ts_parser_set_language"] = (a0, a1) => (_ts_parser_set_language = Module["_ts_parser_set_language"] = wasmExports["ts_parser_set_language"])(a0, a1);
3617
+ var _ts_parser_timeout_micros = Module["_ts_parser_timeout_micros"] = (a0) => (_ts_parser_timeout_micros = Module["_ts_parser_timeout_micros"] = wasmExports["ts_parser_timeout_micros"])(a0);
3618
+ var _ts_parser_set_timeout_micros = Module["_ts_parser_set_timeout_micros"] = (a0, a1, a2) => (_ts_parser_set_timeout_micros = Module["_ts_parser_set_timeout_micros"] = wasmExports["ts_parser_set_timeout_micros"])(a0, a1, a2);
3619
+ var _ts_parser_set_included_ranges = Module["_ts_parser_set_included_ranges"] = (a0, a1, a2) => (_ts_parser_set_included_ranges = Module["_ts_parser_set_included_ranges"] = wasmExports["ts_parser_set_included_ranges"])(a0, a1, a2);
3620
+ var _memmove = Module["_memmove"] = (a0, a1, a2) => (_memmove = Module["_memmove"] = wasmExports["memmove"])(a0, a1, a2);
3621
+ var _memcmp = Module["_memcmp"] = (a0, a1, a2) => (_memcmp = Module["_memcmp"] = wasmExports["memcmp"])(a0, a1, a2);
3622
+ var _ts_query_new = Module["_ts_query_new"] = (a0, a1, a2, a3, a4) => (_ts_query_new = Module["_ts_query_new"] = wasmExports["ts_query_new"])(a0, a1, a2, a3, a4);
3623
+ var _ts_query_delete = Module["_ts_query_delete"] = (a0) => (_ts_query_delete = Module["_ts_query_delete"] = wasmExports["ts_query_delete"])(a0);
3624
+ var _iswspace = Module["_iswspace"] = (a0) => (_iswspace = Module["_iswspace"] = wasmExports["iswspace"])(a0);
3625
+ var _iswalnum = Module["_iswalnum"] = (a0) => (_iswalnum = Module["_iswalnum"] = wasmExports["iswalnum"])(a0);
3626
+ var _ts_query_pattern_count = Module["_ts_query_pattern_count"] = (a0) => (_ts_query_pattern_count = Module["_ts_query_pattern_count"] = wasmExports["ts_query_pattern_count"])(a0);
3627
+ var _ts_query_capture_count = Module["_ts_query_capture_count"] = (a0) => (_ts_query_capture_count = Module["_ts_query_capture_count"] = wasmExports["ts_query_capture_count"])(a0);
3628
+ var _ts_query_string_count = Module["_ts_query_string_count"] = (a0) => (_ts_query_string_count = Module["_ts_query_string_count"] = wasmExports["ts_query_string_count"])(a0);
3629
+ var _ts_query_capture_name_for_id = Module["_ts_query_capture_name_for_id"] = (a0, a1, a2) => (_ts_query_capture_name_for_id = Module["_ts_query_capture_name_for_id"] = wasmExports["ts_query_capture_name_for_id"])(a0, a1, a2);
3630
+ var _ts_query_capture_quantifier_for_id = Module["_ts_query_capture_quantifier_for_id"] = (a0, a1, a2) => (_ts_query_capture_quantifier_for_id = Module["_ts_query_capture_quantifier_for_id"] = wasmExports["ts_query_capture_quantifier_for_id"])(a0, a1, a2);
3631
+ var _ts_query_string_value_for_id = Module["_ts_query_string_value_for_id"] = (a0, a1, a2) => (_ts_query_string_value_for_id = Module["_ts_query_string_value_for_id"] = wasmExports["ts_query_string_value_for_id"])(a0, a1, a2);
3632
+ var _ts_query_predicates_for_pattern = Module["_ts_query_predicates_for_pattern"] = (a0, a1, a2) => (_ts_query_predicates_for_pattern = Module["_ts_query_predicates_for_pattern"] = wasmExports["ts_query_predicates_for_pattern"])(a0, a1, a2);
3633
+ var _ts_query_start_byte_for_pattern = Module["_ts_query_start_byte_for_pattern"] = (a0, a1) => (_ts_query_start_byte_for_pattern = Module["_ts_query_start_byte_for_pattern"] = wasmExports["ts_query_start_byte_for_pattern"])(a0, a1);
3634
+ var _ts_query_end_byte_for_pattern = Module["_ts_query_end_byte_for_pattern"] = (a0, a1) => (_ts_query_end_byte_for_pattern = Module["_ts_query_end_byte_for_pattern"] = wasmExports["ts_query_end_byte_for_pattern"])(a0, a1);
3635
+ var _ts_query_is_pattern_rooted = Module["_ts_query_is_pattern_rooted"] = (a0, a1) => (_ts_query_is_pattern_rooted = Module["_ts_query_is_pattern_rooted"] = wasmExports["ts_query_is_pattern_rooted"])(a0, a1);
3636
+ var _ts_query_is_pattern_non_local = Module["_ts_query_is_pattern_non_local"] = (a0, a1) => (_ts_query_is_pattern_non_local = Module["_ts_query_is_pattern_non_local"] = wasmExports["ts_query_is_pattern_non_local"])(a0, a1);
3637
+ var _ts_query_is_pattern_guaranteed_at_step = Module["_ts_query_is_pattern_guaranteed_at_step"] = (a0, a1) => (_ts_query_is_pattern_guaranteed_at_step = Module["_ts_query_is_pattern_guaranteed_at_step"] = wasmExports["ts_query_is_pattern_guaranteed_at_step"])(a0, a1);
3638
+ var _ts_query_disable_capture = Module["_ts_query_disable_capture"] = (a0, a1, a2) => (_ts_query_disable_capture = Module["_ts_query_disable_capture"] = wasmExports["ts_query_disable_capture"])(a0, a1, a2);
3639
+ var _ts_query_disable_pattern = Module["_ts_query_disable_pattern"] = (a0, a1) => (_ts_query_disable_pattern = Module["_ts_query_disable_pattern"] = wasmExports["ts_query_disable_pattern"])(a0, a1);
3640
+ var _ts_tree_copy = Module["_ts_tree_copy"] = (a0) => (_ts_tree_copy = Module["_ts_tree_copy"] = wasmExports["ts_tree_copy"])(a0);
3641
+ var _ts_tree_delete = Module["_ts_tree_delete"] = (a0) => (_ts_tree_delete = Module["_ts_tree_delete"] = wasmExports["ts_tree_delete"])(a0);
3642
+ var _ts_init = Module["_ts_init"] = () => (_ts_init = Module["_ts_init"] = wasmExports["ts_init"])();
3643
+ var _ts_parser_new_wasm = Module["_ts_parser_new_wasm"] = () => (_ts_parser_new_wasm = Module["_ts_parser_new_wasm"] = wasmExports["ts_parser_new_wasm"])();
3644
+ var _ts_parser_enable_logger_wasm = Module["_ts_parser_enable_logger_wasm"] = (a0, a1) => (_ts_parser_enable_logger_wasm = Module["_ts_parser_enable_logger_wasm"] = wasmExports["ts_parser_enable_logger_wasm"])(a0, a1);
3645
+ var _ts_parser_parse_wasm = Module["_ts_parser_parse_wasm"] = (a0, a1, a2, a3, a4) => (_ts_parser_parse_wasm = Module["_ts_parser_parse_wasm"] = wasmExports["ts_parser_parse_wasm"])(a0, a1, a2, a3, a4);
3646
+ var _ts_parser_included_ranges_wasm = Module["_ts_parser_included_ranges_wasm"] = (a0) => (_ts_parser_included_ranges_wasm = Module["_ts_parser_included_ranges_wasm"] = wasmExports["ts_parser_included_ranges_wasm"])(a0);
3647
+ var _ts_language_type_is_named_wasm = Module["_ts_language_type_is_named_wasm"] = (a0, a1) => (_ts_language_type_is_named_wasm = Module["_ts_language_type_is_named_wasm"] = wasmExports["ts_language_type_is_named_wasm"])(a0, a1);
3648
+ var _ts_language_type_is_visible_wasm = Module["_ts_language_type_is_visible_wasm"] = (a0, a1) => (_ts_language_type_is_visible_wasm = Module["_ts_language_type_is_visible_wasm"] = wasmExports["ts_language_type_is_visible_wasm"])(a0, a1);
3649
+ var _ts_language_supertypes_wasm = Module["_ts_language_supertypes_wasm"] = (a0) => (_ts_language_supertypes_wasm = Module["_ts_language_supertypes_wasm"] = wasmExports["ts_language_supertypes_wasm"])(a0);
3650
+ var _ts_language_subtypes_wasm = Module["_ts_language_subtypes_wasm"] = (a0, a1) => (_ts_language_subtypes_wasm = Module["_ts_language_subtypes_wasm"] = wasmExports["ts_language_subtypes_wasm"])(a0, a1);
3651
+ var _ts_tree_root_node_wasm = Module["_ts_tree_root_node_wasm"] = (a0) => (_ts_tree_root_node_wasm = Module["_ts_tree_root_node_wasm"] = wasmExports["ts_tree_root_node_wasm"])(a0);
3652
+ var _ts_tree_root_node_with_offset_wasm = Module["_ts_tree_root_node_with_offset_wasm"] = (a0) => (_ts_tree_root_node_with_offset_wasm = Module["_ts_tree_root_node_with_offset_wasm"] = wasmExports["ts_tree_root_node_with_offset_wasm"])(a0);
3653
+ var _ts_tree_edit_wasm = Module["_ts_tree_edit_wasm"] = (a0) => (_ts_tree_edit_wasm = Module["_ts_tree_edit_wasm"] = wasmExports["ts_tree_edit_wasm"])(a0);
3654
+ var _ts_tree_included_ranges_wasm = Module["_ts_tree_included_ranges_wasm"] = (a0) => (_ts_tree_included_ranges_wasm = Module["_ts_tree_included_ranges_wasm"] = wasmExports["ts_tree_included_ranges_wasm"])(a0);
3655
+ var _ts_tree_get_changed_ranges_wasm = Module["_ts_tree_get_changed_ranges_wasm"] = (a0, a1) => (_ts_tree_get_changed_ranges_wasm = Module["_ts_tree_get_changed_ranges_wasm"] = wasmExports["ts_tree_get_changed_ranges_wasm"])(a0, a1);
3656
+ var _ts_tree_cursor_new_wasm = Module["_ts_tree_cursor_new_wasm"] = (a0) => (_ts_tree_cursor_new_wasm = Module["_ts_tree_cursor_new_wasm"] = wasmExports["ts_tree_cursor_new_wasm"])(a0);
3657
+ var _ts_tree_cursor_copy_wasm = Module["_ts_tree_cursor_copy_wasm"] = (a0) => (_ts_tree_cursor_copy_wasm = Module["_ts_tree_cursor_copy_wasm"] = wasmExports["ts_tree_cursor_copy_wasm"])(a0);
3658
+ var _ts_tree_cursor_delete_wasm = Module["_ts_tree_cursor_delete_wasm"] = (a0) => (_ts_tree_cursor_delete_wasm = Module["_ts_tree_cursor_delete_wasm"] = wasmExports["ts_tree_cursor_delete_wasm"])(a0);
3659
+ var _ts_tree_cursor_reset_wasm = Module["_ts_tree_cursor_reset_wasm"] = (a0) => (_ts_tree_cursor_reset_wasm = Module["_ts_tree_cursor_reset_wasm"] = wasmExports["ts_tree_cursor_reset_wasm"])(a0);
3660
+ var _ts_tree_cursor_reset_to_wasm = Module["_ts_tree_cursor_reset_to_wasm"] = (a0, a1) => (_ts_tree_cursor_reset_to_wasm = Module["_ts_tree_cursor_reset_to_wasm"] = wasmExports["ts_tree_cursor_reset_to_wasm"])(a0, a1);
3661
+ var _ts_tree_cursor_goto_first_child_wasm = Module["_ts_tree_cursor_goto_first_child_wasm"] = (a0) => (_ts_tree_cursor_goto_first_child_wasm = Module["_ts_tree_cursor_goto_first_child_wasm"] = wasmExports["ts_tree_cursor_goto_first_child_wasm"])(a0);
3662
+ var _ts_tree_cursor_goto_last_child_wasm = Module["_ts_tree_cursor_goto_last_child_wasm"] = (a0) => (_ts_tree_cursor_goto_last_child_wasm = Module["_ts_tree_cursor_goto_last_child_wasm"] = wasmExports["ts_tree_cursor_goto_last_child_wasm"])(a0);
3663
+ var _ts_tree_cursor_goto_first_child_for_index_wasm = Module["_ts_tree_cursor_goto_first_child_for_index_wasm"] = (a0) => (_ts_tree_cursor_goto_first_child_for_index_wasm = Module["_ts_tree_cursor_goto_first_child_for_index_wasm"] = wasmExports["ts_tree_cursor_goto_first_child_for_index_wasm"])(a0);
3664
+ var _ts_tree_cursor_goto_first_child_for_position_wasm = Module["_ts_tree_cursor_goto_first_child_for_position_wasm"] = (a0) => (_ts_tree_cursor_goto_first_child_for_position_wasm = Module["_ts_tree_cursor_goto_first_child_for_position_wasm"] = wasmExports["ts_tree_cursor_goto_first_child_for_position_wasm"])(a0);
3665
+ var _ts_tree_cursor_goto_next_sibling_wasm = Module["_ts_tree_cursor_goto_next_sibling_wasm"] = (a0) => (_ts_tree_cursor_goto_next_sibling_wasm = Module["_ts_tree_cursor_goto_next_sibling_wasm"] = wasmExports["ts_tree_cursor_goto_next_sibling_wasm"])(a0);
3666
+ var _ts_tree_cursor_goto_previous_sibling_wasm = Module["_ts_tree_cursor_goto_previous_sibling_wasm"] = (a0) => (_ts_tree_cursor_goto_previous_sibling_wasm = Module["_ts_tree_cursor_goto_previous_sibling_wasm"] = wasmExports["ts_tree_cursor_goto_previous_sibling_wasm"])(a0);
3667
+ var _ts_tree_cursor_goto_descendant_wasm = Module["_ts_tree_cursor_goto_descendant_wasm"] = (a0, a1) => (_ts_tree_cursor_goto_descendant_wasm = Module["_ts_tree_cursor_goto_descendant_wasm"] = wasmExports["ts_tree_cursor_goto_descendant_wasm"])(a0, a1);
3668
+ var _ts_tree_cursor_goto_parent_wasm = Module["_ts_tree_cursor_goto_parent_wasm"] = (a0) => (_ts_tree_cursor_goto_parent_wasm = Module["_ts_tree_cursor_goto_parent_wasm"] = wasmExports["ts_tree_cursor_goto_parent_wasm"])(a0);
3669
+ var _ts_tree_cursor_current_node_type_id_wasm = Module["_ts_tree_cursor_current_node_type_id_wasm"] = (a0) => (_ts_tree_cursor_current_node_type_id_wasm = Module["_ts_tree_cursor_current_node_type_id_wasm"] = wasmExports["ts_tree_cursor_current_node_type_id_wasm"])(a0);
3670
+ var _ts_tree_cursor_current_node_state_id_wasm = Module["_ts_tree_cursor_current_node_state_id_wasm"] = (a0) => (_ts_tree_cursor_current_node_state_id_wasm = Module["_ts_tree_cursor_current_node_state_id_wasm"] = wasmExports["ts_tree_cursor_current_node_state_id_wasm"])(a0);
3671
+ var _ts_tree_cursor_current_node_is_named_wasm = Module["_ts_tree_cursor_current_node_is_named_wasm"] = (a0) => (_ts_tree_cursor_current_node_is_named_wasm = Module["_ts_tree_cursor_current_node_is_named_wasm"] = wasmExports["ts_tree_cursor_current_node_is_named_wasm"])(a0);
3672
+ var _ts_tree_cursor_current_node_is_missing_wasm = Module["_ts_tree_cursor_current_node_is_missing_wasm"] = (a0) => (_ts_tree_cursor_current_node_is_missing_wasm = Module["_ts_tree_cursor_current_node_is_missing_wasm"] = wasmExports["ts_tree_cursor_current_node_is_missing_wasm"])(a0);
3673
+ var _ts_tree_cursor_current_node_id_wasm = Module["_ts_tree_cursor_current_node_id_wasm"] = (a0) => (_ts_tree_cursor_current_node_id_wasm = Module["_ts_tree_cursor_current_node_id_wasm"] = wasmExports["ts_tree_cursor_current_node_id_wasm"])(a0);
3674
+ var _ts_tree_cursor_start_position_wasm = Module["_ts_tree_cursor_start_position_wasm"] = (a0) => (_ts_tree_cursor_start_position_wasm = Module["_ts_tree_cursor_start_position_wasm"] = wasmExports["ts_tree_cursor_start_position_wasm"])(a0);
3675
+ var _ts_tree_cursor_end_position_wasm = Module["_ts_tree_cursor_end_position_wasm"] = (a0) => (_ts_tree_cursor_end_position_wasm = Module["_ts_tree_cursor_end_position_wasm"] = wasmExports["ts_tree_cursor_end_position_wasm"])(a0);
3676
+ var _ts_tree_cursor_start_index_wasm = Module["_ts_tree_cursor_start_index_wasm"] = (a0) => (_ts_tree_cursor_start_index_wasm = Module["_ts_tree_cursor_start_index_wasm"] = wasmExports["ts_tree_cursor_start_index_wasm"])(a0);
3677
+ var _ts_tree_cursor_end_index_wasm = Module["_ts_tree_cursor_end_index_wasm"] = (a0) => (_ts_tree_cursor_end_index_wasm = Module["_ts_tree_cursor_end_index_wasm"] = wasmExports["ts_tree_cursor_end_index_wasm"])(a0);
3678
+ var _ts_tree_cursor_current_field_id_wasm = Module["_ts_tree_cursor_current_field_id_wasm"] = (a0) => (_ts_tree_cursor_current_field_id_wasm = Module["_ts_tree_cursor_current_field_id_wasm"] = wasmExports["ts_tree_cursor_current_field_id_wasm"])(a0);
3679
+ var _ts_tree_cursor_current_depth_wasm = Module["_ts_tree_cursor_current_depth_wasm"] = (a0) => (_ts_tree_cursor_current_depth_wasm = Module["_ts_tree_cursor_current_depth_wasm"] = wasmExports["ts_tree_cursor_current_depth_wasm"])(a0);
3680
+ var _ts_tree_cursor_current_descendant_index_wasm = Module["_ts_tree_cursor_current_descendant_index_wasm"] = (a0) => (_ts_tree_cursor_current_descendant_index_wasm = Module["_ts_tree_cursor_current_descendant_index_wasm"] = wasmExports["ts_tree_cursor_current_descendant_index_wasm"])(a0);
3681
+ var _ts_tree_cursor_current_node_wasm = Module["_ts_tree_cursor_current_node_wasm"] = (a0) => (_ts_tree_cursor_current_node_wasm = Module["_ts_tree_cursor_current_node_wasm"] = wasmExports["ts_tree_cursor_current_node_wasm"])(a0);
3682
+ var _ts_node_symbol_wasm = Module["_ts_node_symbol_wasm"] = (a0) => (_ts_node_symbol_wasm = Module["_ts_node_symbol_wasm"] = wasmExports["ts_node_symbol_wasm"])(a0);
3683
+ var _ts_node_field_name_for_child_wasm = Module["_ts_node_field_name_for_child_wasm"] = (a0, a1) => (_ts_node_field_name_for_child_wasm = Module["_ts_node_field_name_for_child_wasm"] = wasmExports["ts_node_field_name_for_child_wasm"])(a0, a1);
3684
+ var _ts_node_field_name_for_named_child_wasm = Module["_ts_node_field_name_for_named_child_wasm"] = (a0, a1) => (_ts_node_field_name_for_named_child_wasm = Module["_ts_node_field_name_for_named_child_wasm"] = wasmExports["ts_node_field_name_for_named_child_wasm"])(a0, a1);
3685
+ var _ts_node_children_by_field_id_wasm = Module["_ts_node_children_by_field_id_wasm"] = (a0, a1) => (_ts_node_children_by_field_id_wasm = Module["_ts_node_children_by_field_id_wasm"] = wasmExports["ts_node_children_by_field_id_wasm"])(a0, a1);
3686
+ var _ts_node_first_child_for_byte_wasm = Module["_ts_node_first_child_for_byte_wasm"] = (a0) => (_ts_node_first_child_for_byte_wasm = Module["_ts_node_first_child_for_byte_wasm"] = wasmExports["ts_node_first_child_for_byte_wasm"])(a0);
3687
+ var _ts_node_first_named_child_for_byte_wasm = Module["_ts_node_first_named_child_for_byte_wasm"] = (a0) => (_ts_node_first_named_child_for_byte_wasm = Module["_ts_node_first_named_child_for_byte_wasm"] = wasmExports["ts_node_first_named_child_for_byte_wasm"])(a0);
3688
+ var _ts_node_grammar_symbol_wasm = Module["_ts_node_grammar_symbol_wasm"] = (a0) => (_ts_node_grammar_symbol_wasm = Module["_ts_node_grammar_symbol_wasm"] = wasmExports["ts_node_grammar_symbol_wasm"])(a0);
3689
+ var _ts_node_child_count_wasm = Module["_ts_node_child_count_wasm"] = (a0) => (_ts_node_child_count_wasm = Module["_ts_node_child_count_wasm"] = wasmExports["ts_node_child_count_wasm"])(a0);
3690
+ var _ts_node_named_child_count_wasm = Module["_ts_node_named_child_count_wasm"] = (a0) => (_ts_node_named_child_count_wasm = Module["_ts_node_named_child_count_wasm"] = wasmExports["ts_node_named_child_count_wasm"])(a0);
3691
+ var _ts_node_child_wasm = Module["_ts_node_child_wasm"] = (a0, a1) => (_ts_node_child_wasm = Module["_ts_node_child_wasm"] = wasmExports["ts_node_child_wasm"])(a0, a1);
3692
+ var _ts_node_named_child_wasm = Module["_ts_node_named_child_wasm"] = (a0, a1) => (_ts_node_named_child_wasm = Module["_ts_node_named_child_wasm"] = wasmExports["ts_node_named_child_wasm"])(a0, a1);
3693
+ var _ts_node_child_by_field_id_wasm = Module["_ts_node_child_by_field_id_wasm"] = (a0, a1) => (_ts_node_child_by_field_id_wasm = Module["_ts_node_child_by_field_id_wasm"] = wasmExports["ts_node_child_by_field_id_wasm"])(a0, a1);
3694
+ var _ts_node_next_sibling_wasm = Module["_ts_node_next_sibling_wasm"] = (a0) => (_ts_node_next_sibling_wasm = Module["_ts_node_next_sibling_wasm"] = wasmExports["ts_node_next_sibling_wasm"])(a0);
3695
+ var _ts_node_prev_sibling_wasm = Module["_ts_node_prev_sibling_wasm"] = (a0) => (_ts_node_prev_sibling_wasm = Module["_ts_node_prev_sibling_wasm"] = wasmExports["ts_node_prev_sibling_wasm"])(a0);
3696
+ var _ts_node_next_named_sibling_wasm = Module["_ts_node_next_named_sibling_wasm"] = (a0) => (_ts_node_next_named_sibling_wasm = Module["_ts_node_next_named_sibling_wasm"] = wasmExports["ts_node_next_named_sibling_wasm"])(a0);
3697
+ var _ts_node_prev_named_sibling_wasm = Module["_ts_node_prev_named_sibling_wasm"] = (a0) => (_ts_node_prev_named_sibling_wasm = Module["_ts_node_prev_named_sibling_wasm"] = wasmExports["ts_node_prev_named_sibling_wasm"])(a0);
3698
+ var _ts_node_descendant_count_wasm = Module["_ts_node_descendant_count_wasm"] = (a0) => (_ts_node_descendant_count_wasm = Module["_ts_node_descendant_count_wasm"] = wasmExports["ts_node_descendant_count_wasm"])(a0);
3699
+ var _ts_node_parent_wasm = Module["_ts_node_parent_wasm"] = (a0) => (_ts_node_parent_wasm = Module["_ts_node_parent_wasm"] = wasmExports["ts_node_parent_wasm"])(a0);
3700
+ var _ts_node_child_with_descendant_wasm = Module["_ts_node_child_with_descendant_wasm"] = (a0) => (_ts_node_child_with_descendant_wasm = Module["_ts_node_child_with_descendant_wasm"] = wasmExports["ts_node_child_with_descendant_wasm"])(a0);
3701
+ var _ts_node_descendant_for_index_wasm = Module["_ts_node_descendant_for_index_wasm"] = (a0) => (_ts_node_descendant_for_index_wasm = Module["_ts_node_descendant_for_index_wasm"] = wasmExports["ts_node_descendant_for_index_wasm"])(a0);
3702
+ var _ts_node_named_descendant_for_index_wasm = Module["_ts_node_named_descendant_for_index_wasm"] = (a0) => (_ts_node_named_descendant_for_index_wasm = Module["_ts_node_named_descendant_for_index_wasm"] = wasmExports["ts_node_named_descendant_for_index_wasm"])(a0);
3703
+ var _ts_node_descendant_for_position_wasm = Module["_ts_node_descendant_for_position_wasm"] = (a0) => (_ts_node_descendant_for_position_wasm = Module["_ts_node_descendant_for_position_wasm"] = wasmExports["ts_node_descendant_for_position_wasm"])(a0);
3704
+ var _ts_node_named_descendant_for_position_wasm = Module["_ts_node_named_descendant_for_position_wasm"] = (a0) => (_ts_node_named_descendant_for_position_wasm = Module["_ts_node_named_descendant_for_position_wasm"] = wasmExports["ts_node_named_descendant_for_position_wasm"])(a0);
3705
+ var _ts_node_start_point_wasm = Module["_ts_node_start_point_wasm"] = (a0) => (_ts_node_start_point_wasm = Module["_ts_node_start_point_wasm"] = wasmExports["ts_node_start_point_wasm"])(a0);
3706
+ var _ts_node_end_point_wasm = Module["_ts_node_end_point_wasm"] = (a0) => (_ts_node_end_point_wasm = Module["_ts_node_end_point_wasm"] = wasmExports["ts_node_end_point_wasm"])(a0);
3707
+ var _ts_node_start_index_wasm = Module["_ts_node_start_index_wasm"] = (a0) => (_ts_node_start_index_wasm = Module["_ts_node_start_index_wasm"] = wasmExports["ts_node_start_index_wasm"])(a0);
3708
+ var _ts_node_end_index_wasm = Module["_ts_node_end_index_wasm"] = (a0) => (_ts_node_end_index_wasm = Module["_ts_node_end_index_wasm"] = wasmExports["ts_node_end_index_wasm"])(a0);
3709
+ var _ts_node_to_string_wasm = Module["_ts_node_to_string_wasm"] = (a0) => (_ts_node_to_string_wasm = Module["_ts_node_to_string_wasm"] = wasmExports["ts_node_to_string_wasm"])(a0);
3710
+ var _ts_node_children_wasm = Module["_ts_node_children_wasm"] = (a0) => (_ts_node_children_wasm = Module["_ts_node_children_wasm"] = wasmExports["ts_node_children_wasm"])(a0);
3711
+ var _ts_node_named_children_wasm = Module["_ts_node_named_children_wasm"] = (a0) => (_ts_node_named_children_wasm = Module["_ts_node_named_children_wasm"] = wasmExports["ts_node_named_children_wasm"])(a0);
3712
+ var _ts_node_descendants_of_type_wasm = Module["_ts_node_descendants_of_type_wasm"] = (a0, a1, a2, a3, a4, a5, a6) => (_ts_node_descendants_of_type_wasm = Module["_ts_node_descendants_of_type_wasm"] = wasmExports["ts_node_descendants_of_type_wasm"])(a0, a1, a2, a3, a4, a5, a6);
3713
+ var _ts_node_is_named_wasm = Module["_ts_node_is_named_wasm"] = (a0) => (_ts_node_is_named_wasm = Module["_ts_node_is_named_wasm"] = wasmExports["ts_node_is_named_wasm"])(a0);
3714
+ var _ts_node_has_changes_wasm = Module["_ts_node_has_changes_wasm"] = (a0) => (_ts_node_has_changes_wasm = Module["_ts_node_has_changes_wasm"] = wasmExports["ts_node_has_changes_wasm"])(a0);
3715
+ var _ts_node_has_error_wasm = Module["_ts_node_has_error_wasm"] = (a0) => (_ts_node_has_error_wasm = Module["_ts_node_has_error_wasm"] = wasmExports["ts_node_has_error_wasm"])(a0);
3716
+ var _ts_node_is_error_wasm = Module["_ts_node_is_error_wasm"] = (a0) => (_ts_node_is_error_wasm = Module["_ts_node_is_error_wasm"] = wasmExports["ts_node_is_error_wasm"])(a0);
3717
+ var _ts_node_is_missing_wasm = Module["_ts_node_is_missing_wasm"] = (a0) => (_ts_node_is_missing_wasm = Module["_ts_node_is_missing_wasm"] = wasmExports["ts_node_is_missing_wasm"])(a0);
3718
+ var _ts_node_is_extra_wasm = Module["_ts_node_is_extra_wasm"] = (a0) => (_ts_node_is_extra_wasm = Module["_ts_node_is_extra_wasm"] = wasmExports["ts_node_is_extra_wasm"])(a0);
3719
+ var _ts_node_parse_state_wasm = Module["_ts_node_parse_state_wasm"] = (a0) => (_ts_node_parse_state_wasm = Module["_ts_node_parse_state_wasm"] = wasmExports["ts_node_parse_state_wasm"])(a0);
3720
+ var _ts_node_next_parse_state_wasm = Module["_ts_node_next_parse_state_wasm"] = (a0) => (_ts_node_next_parse_state_wasm = Module["_ts_node_next_parse_state_wasm"] = wasmExports["ts_node_next_parse_state_wasm"])(a0);
3721
+ var _ts_query_matches_wasm = Module["_ts_query_matches_wasm"] = (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) => (_ts_query_matches_wasm = Module["_ts_query_matches_wasm"] = wasmExports["ts_query_matches_wasm"])(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
3722
+ var _ts_query_captures_wasm = Module["_ts_query_captures_wasm"] = (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) => (_ts_query_captures_wasm = Module["_ts_query_captures_wasm"] = wasmExports["ts_query_captures_wasm"])(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
3723
+ var _iswalpha = Module["_iswalpha"] = (a0) => (_iswalpha = Module["_iswalpha"] = wasmExports["iswalpha"])(a0);
3724
+ var _iswblank = Module["_iswblank"] = (a0) => (_iswblank = Module["_iswblank"] = wasmExports["iswblank"])(a0);
3725
+ var _iswdigit = Module["_iswdigit"] = (a0) => (_iswdigit = Module["_iswdigit"] = wasmExports["iswdigit"])(a0);
3726
+ var _iswlower = Module["_iswlower"] = (a0) => (_iswlower = Module["_iswlower"] = wasmExports["iswlower"])(a0);
3727
+ var _iswupper = Module["_iswupper"] = (a0) => (_iswupper = Module["_iswupper"] = wasmExports["iswupper"])(a0);
3728
+ var _iswxdigit = Module["_iswxdigit"] = (a0) => (_iswxdigit = Module["_iswxdigit"] = wasmExports["iswxdigit"])(a0);
3729
+ var _memchr = Module["_memchr"] = (a0, a1, a2) => (_memchr = Module["_memchr"] = wasmExports["memchr"])(a0, a1, a2);
3730
+ var _strlen = Module["_strlen"] = (a0) => (_strlen = Module["_strlen"] = wasmExports["strlen"])(a0);
3731
+ var _strcmp = Module["_strcmp"] = (a0, a1) => (_strcmp = Module["_strcmp"] = wasmExports["strcmp"])(a0, a1);
3732
+ var _strncat = Module["_strncat"] = (a0, a1, a2) => (_strncat = Module["_strncat"] = wasmExports["strncat"])(a0, a1, a2);
3733
+ var _strncpy = Module["_strncpy"] = (a0, a1, a2) => (_strncpy = Module["_strncpy"] = wasmExports["strncpy"])(a0, a1, a2);
3734
+ var _towlower = Module["_towlower"] = (a0) => (_towlower = Module["_towlower"] = wasmExports["towlower"])(a0);
3735
+ var _towupper = Module["_towupper"] = (a0) => (_towupper = Module["_towupper"] = wasmExports["towupper"])(a0);
3736
+ var _setThrew = /* @__PURE__ */ __name((a0, a1) => (_setThrew = wasmExports["setThrew"])(a0, a1), "_setThrew");
3737
+ var __emscripten_stack_restore = /* @__PURE__ */ __name((a0) => (__emscripten_stack_restore = wasmExports["_emscripten_stack_restore"])(a0), "__emscripten_stack_restore");
3738
+ var __emscripten_stack_alloc = /* @__PURE__ */ __name((a0) => (__emscripten_stack_alloc = wasmExports["_emscripten_stack_alloc"])(a0), "__emscripten_stack_alloc");
3739
+ var _emscripten_stack_get_current = /* @__PURE__ */ __name(() => (_emscripten_stack_get_current = wasmExports["emscripten_stack_get_current"])(), "_emscripten_stack_get_current");
3740
+ var dynCall_jiji = Module["dynCall_jiji"] = (a0, a1, a2, a3, a4) => (dynCall_jiji = Module["dynCall_jiji"] = wasmExports["dynCall_jiji"])(a0, a1, a2, a3, a4);
3741
+ var _orig$ts_parser_timeout_micros = Module["_orig$ts_parser_timeout_micros"] = (a0) => (_orig$ts_parser_timeout_micros = Module["_orig$ts_parser_timeout_micros"] = wasmExports["orig$ts_parser_timeout_micros"])(a0);
3742
+ var _orig$ts_parser_set_timeout_micros = Module["_orig$ts_parser_set_timeout_micros"] = (a0, a1) => (_orig$ts_parser_set_timeout_micros = Module["_orig$ts_parser_set_timeout_micros"] = wasmExports["orig$ts_parser_set_timeout_micros"])(a0, a1);
3743
+ Module["setValue"] = setValue;
3744
+ Module["getValue"] = getValue;
3745
+ Module["UTF8ToString"] = UTF8ToString;
3746
+ Module["stringToUTF8"] = stringToUTF8;
3747
+ Module["lengthBytesUTF8"] = lengthBytesUTF8;
3748
+ Module["AsciiToString"] = AsciiToString;
3749
+ Module["stringToUTF16"] = stringToUTF16;
3750
+ Module["loadWebAssemblyModule"] = loadWebAssemblyModule;
3751
+ var calledRun;
3752
+ dependenciesFulfilled = /* @__PURE__ */ __name(function runCaller() {
3753
+ if (!calledRun) run();
3754
+ if (!calledRun) dependenciesFulfilled = runCaller;
3755
+ }, "runCaller");
3756
+ function callMain(args2 = []) {
3757
+ var entryFunction = resolveGlobalSymbol("main").sym;
3758
+ if (!entryFunction) return;
3759
+ args2.unshift(thisProgram);
3760
+ var argc = args2.length;
3761
+ var argv = stackAlloc((argc + 1) * 4);
3762
+ var argv_ptr = argv;
3763
+ args2.forEach((arg) => {
3764
+ LE_HEAP_STORE_U32((argv_ptr >> 2) * 4, stringToUTF8OnStack(arg));
3765
+ argv_ptr += 4;
3766
+ });
3767
+ LE_HEAP_STORE_U32((argv_ptr >> 2) * 4, 0);
3768
+ try {
3769
+ var ret = entryFunction(argc, argv);
3770
+ exitJS(
3771
+ ret,
3772
+ /* implicit = */
3773
+ true
3774
+ );
3775
+ return ret;
3776
+ } catch (e) {
3777
+ return handleException(e);
3778
+ }
3779
+ }
3780
+ __name(callMain, "callMain");
3781
+ function run(args2 = arguments_) {
3782
+ if (runDependencies > 0) {
3783
+ return;
3784
+ }
3785
+ preRun();
3786
+ if (runDependencies > 0) {
3787
+ return;
3788
+ }
3789
+ function doRun() {
3790
+ if (calledRun) return;
3791
+ calledRun = true;
3792
+ Module["calledRun"] = true;
3793
+ if (ABORT) return;
3794
+ initRuntime();
3795
+ preMain();
3796
+ readyPromiseResolve(Module);
3797
+ Module["onRuntimeInitialized"]?.();
3798
+ if (shouldRunNow) callMain(args2);
3799
+ postRun();
3800
+ }
3801
+ __name(doRun, "doRun");
3802
+ if (Module["setStatus"]) {
3803
+ Module["setStatus"]("Running...");
3804
+ setTimeout(function() {
3805
+ setTimeout(function() {
3806
+ Module["setStatus"]("");
3807
+ }, 1);
3808
+ doRun();
3809
+ }, 1);
3810
+ } else {
3811
+ doRun();
3812
+ }
3813
+ }
3814
+ __name(run, "run");
3815
+ if (Module["preInit"]) {
3816
+ if (typeof Module["preInit"] == "function") Module["preInit"] = [Module["preInit"]];
3817
+ while (Module["preInit"].length > 0) {
3818
+ Module["preInit"].pop()();
3819
+ }
3820
+ }
3821
+ var shouldRunNow = true;
3822
+ if (Module["noInitialRun"]) shouldRunNow = false;
3823
+ run();
3824
+ moduleRtn = readyPromise;
3825
+ return moduleRtn;
3826
+ };
3827
+ })();
3828
+ var tree_sitter_default = Module2;
3829
+
3830
+ // src/bindings.ts
3831
+ var Module3 = null;
3832
+ async function initializeBinding(moduleOptions) {
3833
+ if (!Module3) {
3834
+ Module3 = await tree_sitter_default(moduleOptions);
3835
+ }
3836
+ return Module3;
3837
+ }
3838
+ __name(initializeBinding, "initializeBinding");
3839
+ function checkModule() {
3840
+ return !!Module3;
3841
+ }
3842
+ __name(checkModule, "checkModule");
3843
+
3844
+ // src/parser.ts
3845
+ var TRANSFER_BUFFER;
3846
+ var LANGUAGE_VERSION;
3847
+ var MIN_COMPATIBLE_VERSION;
3848
+ var Parser = class {
3849
+ static {
3850
+ __name(this, "Parser");
3851
+ }
3852
+ /** @internal */
3853
+ [0] = 0;
3854
+ // Internal handle for WASM
3855
+ /** @internal */
3856
+ [1] = 0;
3857
+ // Internal handle for WASM
3858
+ /** @internal */
3859
+ logCallback = null;
3860
+ /** The parser's current language. */
3861
+ language = null;
3862
+ /**
3863
+ * This must always be called before creating a Parser.
3864
+ *
3865
+ * You can optionally pass in options to configure the WASM module, the most common
3866
+ * one being `locateFile` to help the module find the `.wasm` file.
3867
+ */
3868
+ static async init(moduleOptions) {
3869
+ setModule(await initializeBinding(moduleOptions));
3870
+ TRANSFER_BUFFER = C._ts_init();
3871
+ LANGUAGE_VERSION = C.getValue(TRANSFER_BUFFER, "i32");
3872
+ MIN_COMPATIBLE_VERSION = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
3873
+ }
3874
+ /**
3875
+ * Create a new parser.
3876
+ */
3877
+ constructor() {
3878
+ this.initialize();
3879
+ }
3880
+ /** @internal */
3881
+ initialize() {
3882
+ if (!checkModule()) {
3883
+ throw new Error("cannot construct a Parser before calling `init()`");
3884
+ }
3885
+ C._ts_parser_new_wasm();
3886
+ this[0] = C.getValue(TRANSFER_BUFFER, "i32");
3887
+ this[1] = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
3888
+ }
3889
+ /** Delete the parser, freeing its resources. */
3890
+ delete() {
3891
+ C._ts_parser_delete(this[0]);
3892
+ C._free(this[1]);
3893
+ this[0] = 0;
3894
+ this[1] = 0;
3895
+ }
3896
+ /**
3897
+ * Set the language that the parser should use for parsing.
3898
+ *
3899
+ * If the language was not successfully assigned, an error will be thrown.
3900
+ * This happens if the language was generated with an incompatible
3901
+ * version of the Tree-sitter CLI. Check the language's version using
3902
+ * {@link Language#version} and compare it to this library's
3903
+ * {@link LANGUAGE_VERSION} and {@link MIN_COMPATIBLE_VERSION} constants.
3904
+ */
3905
+ setLanguage(language) {
3906
+ let address;
3907
+ if (!language) {
3908
+ address = 0;
3909
+ this.language = null;
3910
+ } else if (language.constructor === Language) {
3911
+ address = language[0];
3912
+ const version = C._ts_language_version(address);
3913
+ if (version < MIN_COMPATIBLE_VERSION || LANGUAGE_VERSION < version) {
3914
+ throw new Error(
3915
+ `Incompatible language version ${version}. Compatibility range ${MIN_COMPATIBLE_VERSION} through ${LANGUAGE_VERSION}.`
3916
+ );
3917
+ }
3918
+ this.language = language;
3919
+ } else {
3920
+ throw new Error("Argument must be a Language");
3921
+ }
3922
+ C._ts_parser_set_language(this[0], address);
3923
+ return this;
3924
+ }
3925
+ /**
3926
+ * Parse a slice of UTF8 text.
3927
+ *
3928
+ * @param {string | ParseCallback} callback - The UTF8-encoded text to parse or a callback function.
3929
+ *
3930
+ * @param {Tree | null} [oldTree] - A previous syntax tree parsed from the same document. If the text of the
3931
+ * document has changed since `oldTree` was created, then you must edit `oldTree` to match
3932
+ * the new text using {@link Tree#edit}.
3933
+ *
3934
+ * @param {ParseOptions} [options] - Options for parsing the text.
3935
+ * This can be used to set the included ranges, or a progress callback.
3936
+ *
3937
+ * @returns {Tree | null} A {@link Tree} if parsing succeeded, or `null` if:
3938
+ * - The parser has not yet had a language assigned with {@link Parser#setLanguage}.
3939
+ * - The progress callback returned true.
3940
+ */
3941
+ parse(callback, oldTree, options) {
3942
+ if (typeof callback === "string") {
3943
+ C.currentParseCallback = (index) => callback.slice(index);
3944
+ } else if (typeof callback === "function") {
3945
+ C.currentParseCallback = callback;
3946
+ } else {
3947
+ throw new Error("Argument must be a string or a function");
3948
+ }
3949
+ if (options?.progressCallback) {
3950
+ C.currentProgressCallback = options.progressCallback;
3951
+ } else {
3952
+ C.currentProgressCallback = null;
3953
+ }
3954
+ if (this.logCallback) {
3955
+ C.currentLogCallback = this.logCallback;
3956
+ C._ts_parser_enable_logger_wasm(this[0], 1);
3957
+ } else {
3958
+ C.currentLogCallback = null;
3959
+ C._ts_parser_enable_logger_wasm(this[0], 0);
3960
+ }
3961
+ let rangeCount = 0;
3962
+ let rangeAddress = 0;
3963
+ if (options?.includedRanges) {
3964
+ rangeCount = options.includedRanges.length;
3965
+ rangeAddress = C._calloc(rangeCount, SIZE_OF_RANGE);
3966
+ let address = rangeAddress;
3967
+ for (let i2 = 0; i2 < rangeCount; i2++) {
3968
+ marshalRange(address, options.includedRanges[i2]);
3969
+ address += SIZE_OF_RANGE;
3970
+ }
3971
+ }
3972
+ const treeAddress = C._ts_parser_parse_wasm(
3973
+ this[0],
3974
+ this[1],
3975
+ oldTree ? oldTree[0] : 0,
3976
+ rangeAddress,
3977
+ rangeCount
3978
+ );
3979
+ if (!treeAddress) {
3980
+ C.currentParseCallback = null;
3981
+ C.currentLogCallback = null;
3982
+ C.currentProgressCallback = null;
3983
+ return null;
3984
+ }
3985
+ if (!this.language) {
3986
+ throw new Error("Parser must have a language to parse");
3987
+ }
3988
+ const result = new Tree(INTERNAL, treeAddress, this.language, C.currentParseCallback);
3989
+ C.currentParseCallback = null;
3990
+ C.currentLogCallback = null;
3991
+ C.currentProgressCallback = null;
3992
+ return result;
3993
+ }
3994
+ /**
3995
+ * Instruct the parser to start the next parse from the beginning.
3996
+ *
3997
+ * If the parser previously failed because of a timeout, cancellation,
3998
+ * or callback, then by default, it will resume where it left off on the
3999
+ * next call to {@link Parser#parse} or other parsing functions.
4000
+ * If you don't want to resume, and instead intend to use this parser to
4001
+ * parse some other document, you must call `reset` first.
4002
+ */
4003
+ reset() {
4004
+ C._ts_parser_reset(this[0]);
4005
+ }
4006
+ /** Get the ranges of text that the parser will include when parsing. */
4007
+ getIncludedRanges() {
4008
+ C._ts_parser_included_ranges_wasm(this[0]);
4009
+ const count = C.getValue(TRANSFER_BUFFER, "i32");
4010
+ const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
4011
+ const result = new Array(count);
4012
+ if (count > 0) {
4013
+ let address = buffer;
4014
+ for (let i2 = 0; i2 < count; i2++) {
4015
+ result[i2] = unmarshalRange(address);
4016
+ address += SIZE_OF_RANGE;
4017
+ }
4018
+ C._free(buffer);
4019
+ }
4020
+ return result;
4021
+ }
4022
+ /**
4023
+ * @deprecated since version 0.25.0, prefer passing a progress callback to {@link Parser#parse}
4024
+ *
4025
+ * Get the duration in microseconds that parsing is allowed to take.
4026
+ *
4027
+ * This is set via {@link Parser#setTimeoutMicros}.
4028
+ */
4029
+ getTimeoutMicros() {
4030
+ return C._ts_parser_timeout_micros(this[0]);
4031
+ }
4032
+ /**
4033
+ * @deprecated since version 0.25.0, prefer passing a progress callback to {@link Parser#parse}
4034
+ *
4035
+ * Set the maximum duration in microseconds that parsing should be allowed
4036
+ * to take before halting.
4037
+ *
4038
+ * If parsing takes longer than this, it will halt early, returning `null`.
4039
+ * See {@link Parser#parse} for more information.
4040
+ */
4041
+ setTimeoutMicros(timeout) {
4042
+ C._ts_parser_set_timeout_micros(this[0], 0, timeout);
4043
+ }
4044
+ /** Set the logging callback that a parser should use during parsing. */
4045
+ setLogger(callback) {
4046
+ if (!callback) {
4047
+ this.logCallback = null;
4048
+ } else if (typeof callback !== "function") {
4049
+ throw new Error("Logger callback must be a function");
4050
+ } else {
4051
+ this.logCallback = callback;
4052
+ }
4053
+ return this;
4054
+ }
4055
+ /** Get the parser's current logger. */
4056
+ getLogger() {
4057
+ return this.logCallback;
4058
+ }
4059
+ };
4060
+
4061
+
4062
+ return {
4063
+ CaptureQuantifier,
4064
+ LANGUAGE_VERSION,
4065
+ Language,
4066
+ LookaheadIterator,
4067
+ MIN_COMPATIBLE_VERSION,
4068
+ Node,
4069
+ Parser,
4070
+ Query,
4071
+ Tree,
4072
+ TreeCursor
4073
+ };
4074
+ }));