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