@ast-grep/wasm 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -0
- package/package.json +31 -0
- package/wasm.d.ts +244 -0
- package/wasm.js +1531 -0
- package/wasm_bg.wasm +0 -0
package/wasm.js
ADDED
|
@@ -0,0 +1,1531 @@
|
|
|
1
|
+
import { Parser, Language } from 'web-tree-sitter';
|
|
2
|
+
|
|
3
|
+
let wasm;
|
|
4
|
+
|
|
5
|
+
function addToExternrefTable0(obj) {
|
|
6
|
+
const idx = wasm.__externref_table_alloc();
|
|
7
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
8
|
+
return idx;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function _assertClass(instance, klass) {
|
|
12
|
+
if (!(instance instanceof klass)) {
|
|
13
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
|
|
18
|
+
? { register: () => {}, unregister: () => {} }
|
|
19
|
+
: new FinalizationRegistry(state => state.dtor(state.a, state.b));
|
|
20
|
+
|
|
21
|
+
function debugString(val) {
|
|
22
|
+
// primitive types
|
|
23
|
+
const type = typeof val;
|
|
24
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
25
|
+
return `${val}`;
|
|
26
|
+
}
|
|
27
|
+
if (type == 'string') {
|
|
28
|
+
return `"${val}"`;
|
|
29
|
+
}
|
|
30
|
+
if (type == 'symbol') {
|
|
31
|
+
const description = val.description;
|
|
32
|
+
if (description == null) {
|
|
33
|
+
return 'Symbol';
|
|
34
|
+
} else {
|
|
35
|
+
return `Symbol(${description})`;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (type == 'function') {
|
|
39
|
+
const name = val.name;
|
|
40
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
41
|
+
return `Function(${name})`;
|
|
42
|
+
} else {
|
|
43
|
+
return 'Function';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// objects
|
|
47
|
+
if (Array.isArray(val)) {
|
|
48
|
+
const length = val.length;
|
|
49
|
+
let debug = '[';
|
|
50
|
+
if (length > 0) {
|
|
51
|
+
debug += debugString(val[0]);
|
|
52
|
+
}
|
|
53
|
+
for(let i = 1; i < length; i++) {
|
|
54
|
+
debug += ', ' + debugString(val[i]);
|
|
55
|
+
}
|
|
56
|
+
debug += ']';
|
|
57
|
+
return debug;
|
|
58
|
+
}
|
|
59
|
+
// Test for built-in
|
|
60
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
61
|
+
let className;
|
|
62
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
63
|
+
className = builtInMatches[1];
|
|
64
|
+
} else {
|
|
65
|
+
// Failed to match the standard '[object ClassName]'
|
|
66
|
+
return toString.call(val);
|
|
67
|
+
}
|
|
68
|
+
if (className == 'Object') {
|
|
69
|
+
// we're a user defined class or Object
|
|
70
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
71
|
+
// easier than looping through ownProperties of `val`.
|
|
72
|
+
try {
|
|
73
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
74
|
+
} catch (_) {
|
|
75
|
+
return 'Object';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// errors
|
|
79
|
+
if (val instanceof Error) {
|
|
80
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
81
|
+
}
|
|
82
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
83
|
+
return className;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
87
|
+
ptr = ptr >>> 0;
|
|
88
|
+
const mem = getDataViewMemory0();
|
|
89
|
+
const result = [];
|
|
90
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
91
|
+
result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
92
|
+
}
|
|
93
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
98
|
+
ptr = ptr >>> 0;
|
|
99
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
let cachedDataViewMemory0 = null;
|
|
103
|
+
function getDataViewMemory0() {
|
|
104
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
105
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
106
|
+
}
|
|
107
|
+
return cachedDataViewMemory0;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function getStringFromWasm0(ptr, len) {
|
|
111
|
+
ptr = ptr >>> 0;
|
|
112
|
+
return decodeText(ptr, len);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
let cachedUint8ArrayMemory0 = null;
|
|
116
|
+
function getUint8ArrayMemory0() {
|
|
117
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
118
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
119
|
+
}
|
|
120
|
+
return cachedUint8ArrayMemory0;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function handleError(f, args) {
|
|
124
|
+
try {
|
|
125
|
+
return f.apply(this, args);
|
|
126
|
+
} catch (e) {
|
|
127
|
+
const idx = addToExternrefTable0(e);
|
|
128
|
+
wasm.__wbindgen_exn_store(idx);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function isLikeNone(x) {
|
|
133
|
+
return x === undefined || x === null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function makeMutClosure(arg0, arg1, dtor, f) {
|
|
137
|
+
const state = { a: arg0, b: arg1, cnt: 1, dtor };
|
|
138
|
+
const real = (...args) => {
|
|
139
|
+
|
|
140
|
+
// First up with a closure we increment the internal reference
|
|
141
|
+
// count. This ensures that the Rust closure environment won't
|
|
142
|
+
// be deallocated while we're invoking it.
|
|
143
|
+
state.cnt++;
|
|
144
|
+
const a = state.a;
|
|
145
|
+
state.a = 0;
|
|
146
|
+
try {
|
|
147
|
+
return f(a, state.b, ...args);
|
|
148
|
+
} finally {
|
|
149
|
+
state.a = a;
|
|
150
|
+
real._wbg_cb_unref();
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
real._wbg_cb_unref = () => {
|
|
154
|
+
if (--state.cnt === 0) {
|
|
155
|
+
state.dtor(state.a, state.b);
|
|
156
|
+
state.a = 0;
|
|
157
|
+
CLOSURE_DTORS.unregister(state);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
CLOSURE_DTORS.register(real, state, state);
|
|
161
|
+
return real;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
165
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
166
|
+
for (let i = 0; i < array.length; i++) {
|
|
167
|
+
const add = addToExternrefTable0(array[i]);
|
|
168
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
169
|
+
}
|
|
170
|
+
WASM_VECTOR_LEN = array.length;
|
|
171
|
+
return ptr;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
175
|
+
if (realloc === undefined) {
|
|
176
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
177
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
178
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
179
|
+
WASM_VECTOR_LEN = buf.length;
|
|
180
|
+
return ptr;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
let len = arg.length;
|
|
184
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
185
|
+
|
|
186
|
+
const mem = getUint8ArrayMemory0();
|
|
187
|
+
|
|
188
|
+
let offset = 0;
|
|
189
|
+
|
|
190
|
+
for (; offset < len; offset++) {
|
|
191
|
+
const code = arg.charCodeAt(offset);
|
|
192
|
+
if (code > 0x7F) break;
|
|
193
|
+
mem[ptr + offset] = code;
|
|
194
|
+
}
|
|
195
|
+
if (offset !== len) {
|
|
196
|
+
if (offset !== 0) {
|
|
197
|
+
arg = arg.slice(offset);
|
|
198
|
+
}
|
|
199
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
200
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
201
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
202
|
+
|
|
203
|
+
offset += ret.written;
|
|
204
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
WASM_VECTOR_LEN = offset;
|
|
208
|
+
return ptr;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function takeFromExternrefTable0(idx) {
|
|
212
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
213
|
+
wasm.__externref_table_dealloc(idx);
|
|
214
|
+
return value;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
218
|
+
cachedTextDecoder.decode();
|
|
219
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
220
|
+
let numBytesDecoded = 0;
|
|
221
|
+
function decodeText(ptr, len) {
|
|
222
|
+
numBytesDecoded += len;
|
|
223
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
224
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
225
|
+
cachedTextDecoder.decode();
|
|
226
|
+
numBytesDecoded = len;
|
|
227
|
+
}
|
|
228
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const cachedTextEncoder = new TextEncoder();
|
|
232
|
+
|
|
233
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
234
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
235
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
236
|
+
view.set(buf);
|
|
237
|
+
return {
|
|
238
|
+
read: arg.length,
|
|
239
|
+
written: buf.length
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
let WASM_VECTOR_LEN = 0;
|
|
245
|
+
|
|
246
|
+
function wasm_bindgen__convert__closures_____invoke__hf6abb6e10d012239(arg0, arg1, arg2) {
|
|
247
|
+
wasm.wasm_bindgen__convert__closures_____invoke__hf6abb6e10d012239(arg0, arg1, arg2);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function wasm_bindgen__convert__closures_____invoke__h626c386f4a0f1908(arg0, arg1, arg2, arg3) {
|
|
251
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h626c386f4a0f1908(arg0, arg1, arg2, arg3);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const PosFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
255
|
+
? { register: () => {}, unregister: () => {} }
|
|
256
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_pos_free(ptr >>> 0, 1));
|
|
257
|
+
|
|
258
|
+
const RangeFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
259
|
+
? { register: () => {}, unregister: () => {} }
|
|
260
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_range_free(ptr >>> 0, 1));
|
|
261
|
+
|
|
262
|
+
const SgNodeFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
263
|
+
? { register: () => {}, unregister: () => {} }
|
|
264
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_sgnode_free(ptr >>> 0, 1));
|
|
265
|
+
|
|
266
|
+
const SgRootFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
267
|
+
? { register: () => {}, unregister: () => {} }
|
|
268
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_sgroot_free(ptr >>> 0, 1));
|
|
269
|
+
|
|
270
|
+
const WasmEditFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
271
|
+
? { register: () => {}, unregister: () => {} }
|
|
272
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmedit_free(ptr >>> 0, 1));
|
|
273
|
+
|
|
274
|
+
export class Pos {
|
|
275
|
+
static __wrap(ptr) {
|
|
276
|
+
ptr = ptr >>> 0;
|
|
277
|
+
const obj = Object.create(Pos.prototype);
|
|
278
|
+
obj.__wbg_ptr = ptr;
|
|
279
|
+
PosFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
280
|
+
return obj;
|
|
281
|
+
}
|
|
282
|
+
__destroy_into_raw() {
|
|
283
|
+
const ptr = this.__wbg_ptr;
|
|
284
|
+
this.__wbg_ptr = 0;
|
|
285
|
+
PosFinalization.unregister(this);
|
|
286
|
+
return ptr;
|
|
287
|
+
}
|
|
288
|
+
free() {
|
|
289
|
+
const ptr = this.__destroy_into_raw();
|
|
290
|
+
wasm.__wbg_pos_free(ptr, 0);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* line number starting from 0
|
|
294
|
+
* @returns {number}
|
|
295
|
+
*/
|
|
296
|
+
get line() {
|
|
297
|
+
const ret = wasm.__wbg_get_pos_line(this.__wbg_ptr);
|
|
298
|
+
return ret >>> 0;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* line number starting from 0
|
|
302
|
+
* @param {number} arg0
|
|
303
|
+
*/
|
|
304
|
+
set line(arg0) {
|
|
305
|
+
wasm.__wbg_set_pos_line(this.__wbg_ptr, arg0);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* column number starting from 0
|
|
309
|
+
* @returns {number}
|
|
310
|
+
*/
|
|
311
|
+
get column() {
|
|
312
|
+
const ret = wasm.__wbg_get_pos_column(this.__wbg_ptr);
|
|
313
|
+
return ret >>> 0;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* column number starting from 0
|
|
317
|
+
* @param {number} arg0
|
|
318
|
+
*/
|
|
319
|
+
set column(arg0) {
|
|
320
|
+
wasm.__wbg_set_pos_column(this.__wbg_ptr, arg0);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* character offset of the position
|
|
324
|
+
* @returns {number}
|
|
325
|
+
*/
|
|
326
|
+
get index() {
|
|
327
|
+
const ret = wasm.__wbg_get_pos_index(this.__wbg_ptr);
|
|
328
|
+
return ret >>> 0;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* character offset of the position
|
|
332
|
+
* @param {number} arg0
|
|
333
|
+
*/
|
|
334
|
+
set index(arg0) {
|
|
335
|
+
wasm.__wbg_set_pos_index(this.__wbg_ptr, arg0);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
if (Symbol.dispose) Pos.prototype[Symbol.dispose] = Pos.prototype.free;
|
|
339
|
+
|
|
340
|
+
export class Range {
|
|
341
|
+
static __wrap(ptr) {
|
|
342
|
+
ptr = ptr >>> 0;
|
|
343
|
+
const obj = Object.create(Range.prototype);
|
|
344
|
+
obj.__wbg_ptr = ptr;
|
|
345
|
+
RangeFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
346
|
+
return obj;
|
|
347
|
+
}
|
|
348
|
+
__destroy_into_raw() {
|
|
349
|
+
const ptr = this.__wbg_ptr;
|
|
350
|
+
this.__wbg_ptr = 0;
|
|
351
|
+
RangeFinalization.unregister(this);
|
|
352
|
+
return ptr;
|
|
353
|
+
}
|
|
354
|
+
free() {
|
|
355
|
+
const ptr = this.__destroy_into_raw();
|
|
356
|
+
wasm.__wbg_range_free(ptr, 0);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* starting position of the range
|
|
360
|
+
* @returns {Pos}
|
|
361
|
+
*/
|
|
362
|
+
get start() {
|
|
363
|
+
const ret = wasm.__wbg_get_range_start(this.__wbg_ptr);
|
|
364
|
+
return Pos.__wrap(ret);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* starting position of the range
|
|
368
|
+
* @param {Pos} arg0
|
|
369
|
+
*/
|
|
370
|
+
set start(arg0) {
|
|
371
|
+
_assertClass(arg0, Pos);
|
|
372
|
+
var ptr0 = arg0.__destroy_into_raw();
|
|
373
|
+
wasm.__wbg_set_range_start(this.__wbg_ptr, ptr0);
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* ending position of the range
|
|
377
|
+
* @returns {Pos}
|
|
378
|
+
*/
|
|
379
|
+
get end() {
|
|
380
|
+
const ret = wasm.__wbg_get_range_end(this.__wbg_ptr);
|
|
381
|
+
return Pos.__wrap(ret);
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* ending position of the range
|
|
385
|
+
* @param {Pos} arg0
|
|
386
|
+
*/
|
|
387
|
+
set end(arg0) {
|
|
388
|
+
_assertClass(arg0, Pos);
|
|
389
|
+
var ptr0 = arg0.__destroy_into_raw();
|
|
390
|
+
wasm.__wbg_set_range_end(this.__wbg_ptr, ptr0);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
if (Symbol.dispose) Range.prototype[Symbol.dispose] = Range.prototype.free;
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Represents a single AST node.
|
|
397
|
+
*/
|
|
398
|
+
export class SgNode {
|
|
399
|
+
static __wrap(ptr) {
|
|
400
|
+
ptr = ptr >>> 0;
|
|
401
|
+
const obj = Object.create(SgNode.prototype);
|
|
402
|
+
obj.__wbg_ptr = ptr;
|
|
403
|
+
SgNodeFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
404
|
+
return obj;
|
|
405
|
+
}
|
|
406
|
+
__destroy_into_raw() {
|
|
407
|
+
const ptr = this.__wbg_ptr;
|
|
408
|
+
this.__wbg_ptr = 0;
|
|
409
|
+
SgNodeFinalization.unregister(this);
|
|
410
|
+
return ptr;
|
|
411
|
+
}
|
|
412
|
+
free() {
|
|
413
|
+
const ptr = this.__destroy_into_raw();
|
|
414
|
+
wasm.__wbg_sgnode_free(ptr, 0);
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* @returns {Range}
|
|
418
|
+
*/
|
|
419
|
+
range() {
|
|
420
|
+
const ret = wasm.sgnode_range(this.__wbg_ptr);
|
|
421
|
+
return Range.__wrap(ret);
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* @returns {boolean}
|
|
425
|
+
*/
|
|
426
|
+
isLeaf() {
|
|
427
|
+
const ret = wasm.sgnode_isLeaf(this.__wbg_ptr);
|
|
428
|
+
return ret !== 0;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* @returns {boolean}
|
|
432
|
+
*/
|
|
433
|
+
isNamed() {
|
|
434
|
+
const ret = wasm.sgnode_isNamed(this.__wbg_ptr);
|
|
435
|
+
return ret !== 0;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* @returns {boolean}
|
|
439
|
+
*/
|
|
440
|
+
isNamedLeaf() {
|
|
441
|
+
const ret = wasm.sgnode_isNamedLeaf(this.__wbg_ptr);
|
|
442
|
+
return ret !== 0;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* @returns {string}
|
|
446
|
+
*/
|
|
447
|
+
kind() {
|
|
448
|
+
let deferred1_0;
|
|
449
|
+
let deferred1_1;
|
|
450
|
+
try {
|
|
451
|
+
const ret = wasm.sgnode_kind(this.__wbg_ptr);
|
|
452
|
+
deferred1_0 = ret[0];
|
|
453
|
+
deferred1_1 = ret[1];
|
|
454
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
455
|
+
} finally {
|
|
456
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* @param {string} kind
|
|
461
|
+
* @returns {boolean}
|
|
462
|
+
*/
|
|
463
|
+
is(kind) {
|
|
464
|
+
const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
465
|
+
const len0 = WASM_VECTOR_LEN;
|
|
466
|
+
const ret = wasm.sgnode_is(this.__wbg_ptr, ptr0, len0);
|
|
467
|
+
return ret !== 0;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* @returns {string}
|
|
471
|
+
*/
|
|
472
|
+
text() {
|
|
473
|
+
let deferred1_0;
|
|
474
|
+
let deferred1_1;
|
|
475
|
+
try {
|
|
476
|
+
const ret = wasm.sgnode_text(this.__wbg_ptr);
|
|
477
|
+
deferred1_0 = ret[0];
|
|
478
|
+
deferred1_1 = ret[1];
|
|
479
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
480
|
+
} finally {
|
|
481
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* @returns {number}
|
|
486
|
+
*/
|
|
487
|
+
id() {
|
|
488
|
+
const ret = wasm.sgnode_id(this.__wbg_ptr);
|
|
489
|
+
return ret >>> 0;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* @param {any} m
|
|
493
|
+
* @returns {boolean}
|
|
494
|
+
*/
|
|
495
|
+
matches(m) {
|
|
496
|
+
const ret = wasm.sgnode_matches(this.__wbg_ptr, m);
|
|
497
|
+
if (ret[2]) {
|
|
498
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
499
|
+
}
|
|
500
|
+
return ret[0] !== 0;
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* @param {any} m
|
|
504
|
+
* @returns {boolean}
|
|
505
|
+
*/
|
|
506
|
+
inside(m) {
|
|
507
|
+
const ret = wasm.sgnode_inside(this.__wbg_ptr, m);
|
|
508
|
+
if (ret[2]) {
|
|
509
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
510
|
+
}
|
|
511
|
+
return ret[0] !== 0;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* @param {any} m
|
|
515
|
+
* @returns {boolean}
|
|
516
|
+
*/
|
|
517
|
+
has(m) {
|
|
518
|
+
const ret = wasm.sgnode_has(this.__wbg_ptr, m);
|
|
519
|
+
if (ret[2]) {
|
|
520
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
521
|
+
}
|
|
522
|
+
return ret[0] !== 0;
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* @param {any} m
|
|
526
|
+
* @returns {boolean}
|
|
527
|
+
*/
|
|
528
|
+
precedes(m) {
|
|
529
|
+
const ret = wasm.sgnode_precedes(this.__wbg_ptr, m);
|
|
530
|
+
if (ret[2]) {
|
|
531
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
532
|
+
}
|
|
533
|
+
return ret[0] !== 0;
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* @param {any} m
|
|
537
|
+
* @returns {boolean}
|
|
538
|
+
*/
|
|
539
|
+
follows(m) {
|
|
540
|
+
const ret = wasm.sgnode_follows(this.__wbg_ptr, m);
|
|
541
|
+
if (ret[2]) {
|
|
542
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
543
|
+
}
|
|
544
|
+
return ret[0] !== 0;
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* @param {string} m
|
|
548
|
+
* @returns {SgNode | undefined}
|
|
549
|
+
*/
|
|
550
|
+
getMatch(m) {
|
|
551
|
+
const ptr0 = passStringToWasm0(m, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
552
|
+
const len0 = WASM_VECTOR_LEN;
|
|
553
|
+
const ret = wasm.sgnode_getMatch(this.__wbg_ptr, ptr0, len0);
|
|
554
|
+
return ret === 0 ? undefined : SgNode.__wrap(ret);
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* @param {string} m
|
|
558
|
+
* @returns {SgNode[]}
|
|
559
|
+
*/
|
|
560
|
+
getMultipleMatches(m) {
|
|
561
|
+
const ptr0 = passStringToWasm0(m, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
562
|
+
const len0 = WASM_VECTOR_LEN;
|
|
563
|
+
const ret = wasm.sgnode_getMultipleMatches(this.__wbg_ptr, ptr0, len0);
|
|
564
|
+
var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
565
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
566
|
+
return v2;
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* @param {string} m
|
|
570
|
+
* @returns {string | undefined}
|
|
571
|
+
*/
|
|
572
|
+
getTransformed(m) {
|
|
573
|
+
const ptr0 = passStringToWasm0(m, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
574
|
+
const len0 = WASM_VECTOR_LEN;
|
|
575
|
+
const ret = wasm.sgnode_getTransformed(this.__wbg_ptr, ptr0, len0);
|
|
576
|
+
let v2;
|
|
577
|
+
if (ret[0] !== 0) {
|
|
578
|
+
v2 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
579
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
580
|
+
}
|
|
581
|
+
return v2;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* @returns {SgNode[]}
|
|
585
|
+
*/
|
|
586
|
+
children_nodes() {
|
|
587
|
+
const ret = wasm.sgnode_children_nodes(this.__wbg_ptr);
|
|
588
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
589
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
590
|
+
return v1;
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* @returns {SgNode | undefined}
|
|
594
|
+
*/
|
|
595
|
+
parent_node() {
|
|
596
|
+
const ret = wasm.sgnode_parent_node(this.__wbg_ptr);
|
|
597
|
+
return ret === 0 ? undefined : SgNode.__wrap(ret);
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* @param {number} nth
|
|
601
|
+
* @returns {SgNode | undefined}
|
|
602
|
+
*/
|
|
603
|
+
child(nth) {
|
|
604
|
+
const ret = wasm.sgnode_child(this.__wbg_ptr, nth);
|
|
605
|
+
return ret === 0 ? undefined : SgNode.__wrap(ret);
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* @returns {SgNode[]}
|
|
609
|
+
*/
|
|
610
|
+
ancestors() {
|
|
611
|
+
const ret = wasm.sgnode_ancestors(this.__wbg_ptr);
|
|
612
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
613
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
614
|
+
return v1;
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* @returns {SgNode | undefined}
|
|
618
|
+
*/
|
|
619
|
+
next_node() {
|
|
620
|
+
const ret = wasm.sgnode_next_node(this.__wbg_ptr);
|
|
621
|
+
return ret === 0 ? undefined : SgNode.__wrap(ret);
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* @returns {SgNode[]}
|
|
625
|
+
*/
|
|
626
|
+
nextAll() {
|
|
627
|
+
const ret = wasm.sgnode_nextAll(this.__wbg_ptr);
|
|
628
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
629
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
630
|
+
return v1;
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* @returns {SgNode | undefined}
|
|
634
|
+
*/
|
|
635
|
+
prev() {
|
|
636
|
+
const ret = wasm.sgnode_prev(this.__wbg_ptr);
|
|
637
|
+
return ret === 0 ? undefined : SgNode.__wrap(ret);
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* @returns {SgNode[]}
|
|
641
|
+
*/
|
|
642
|
+
prevAll() {
|
|
643
|
+
const ret = wasm.sgnode_prevAll(this.__wbg_ptr);
|
|
644
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
645
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
646
|
+
return v1;
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* @param {any} matcher
|
|
650
|
+
* @returns {SgNode | undefined}
|
|
651
|
+
*/
|
|
652
|
+
find(matcher) {
|
|
653
|
+
const ret = wasm.sgnode_find(this.__wbg_ptr, matcher);
|
|
654
|
+
if (ret[2]) {
|
|
655
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
656
|
+
}
|
|
657
|
+
return ret[0] === 0 ? undefined : SgNode.__wrap(ret[0]);
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* @param {any} matcher
|
|
661
|
+
* @returns {SgNode[]}
|
|
662
|
+
*/
|
|
663
|
+
findAll(matcher) {
|
|
664
|
+
const ret = wasm.sgnode_findAll(this.__wbg_ptr, matcher);
|
|
665
|
+
if (ret[3]) {
|
|
666
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
667
|
+
}
|
|
668
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
669
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
670
|
+
return v1;
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* @param {string} name
|
|
674
|
+
* @returns {SgNode | undefined}
|
|
675
|
+
*/
|
|
676
|
+
field(name) {
|
|
677
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
678
|
+
const len0 = WASM_VECTOR_LEN;
|
|
679
|
+
const ret = wasm.sgnode_field(this.__wbg_ptr, ptr0, len0);
|
|
680
|
+
return ret === 0 ? undefined : SgNode.__wrap(ret);
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* @param {string} name
|
|
684
|
+
* @returns {SgNode[]}
|
|
685
|
+
*/
|
|
686
|
+
fieldChildren(name) {
|
|
687
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
688
|
+
const len0 = WASM_VECTOR_LEN;
|
|
689
|
+
const ret = wasm.sgnode_fieldChildren(this.__wbg_ptr, ptr0, len0);
|
|
690
|
+
var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
691
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
692
|
+
return v2;
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* @param {string} text
|
|
696
|
+
* @returns {WasmEdit}
|
|
697
|
+
*/
|
|
698
|
+
replace(text) {
|
|
699
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
700
|
+
const len0 = WASM_VECTOR_LEN;
|
|
701
|
+
const ret = wasm.sgnode_replace(this.__wbg_ptr, ptr0, len0);
|
|
702
|
+
return WasmEdit.__wrap(ret);
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* @param {any} edits
|
|
706
|
+
* @returns {string}
|
|
707
|
+
*/
|
|
708
|
+
commitEdits(edits) {
|
|
709
|
+
let deferred2_0;
|
|
710
|
+
let deferred2_1;
|
|
711
|
+
try {
|
|
712
|
+
const ret = wasm.sgnode_commitEdits(this.__wbg_ptr, edits);
|
|
713
|
+
var ptr1 = ret[0];
|
|
714
|
+
var len1 = ret[1];
|
|
715
|
+
if (ret[3]) {
|
|
716
|
+
ptr1 = 0; len1 = 0;
|
|
717
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
718
|
+
}
|
|
719
|
+
deferred2_0 = ptr1;
|
|
720
|
+
deferred2_1 = len1;
|
|
721
|
+
return getStringFromWasm0(ptr1, len1);
|
|
722
|
+
} finally {
|
|
723
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
if (Symbol.dispose) SgNode.prototype[Symbol.dispose] = SgNode.prototype.free;
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Represents the parsed tree of code.
|
|
731
|
+
*/
|
|
732
|
+
export class SgRoot {
|
|
733
|
+
static __wrap(ptr) {
|
|
734
|
+
ptr = ptr >>> 0;
|
|
735
|
+
const obj = Object.create(SgRoot.prototype);
|
|
736
|
+
obj.__wbg_ptr = ptr;
|
|
737
|
+
SgRootFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
738
|
+
return obj;
|
|
739
|
+
}
|
|
740
|
+
__destroy_into_raw() {
|
|
741
|
+
const ptr = this.__wbg_ptr;
|
|
742
|
+
this.__wbg_ptr = 0;
|
|
743
|
+
SgRootFinalization.unregister(this);
|
|
744
|
+
return ptr;
|
|
745
|
+
}
|
|
746
|
+
free() {
|
|
747
|
+
const ptr = this.__destroy_into_raw();
|
|
748
|
+
wasm.__wbg_sgroot_free(ptr, 0);
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Returns the root SgNode of the ast-grep instance.
|
|
752
|
+
* @returns {SgNode}
|
|
753
|
+
*/
|
|
754
|
+
root() {
|
|
755
|
+
const ret = wasm.sgroot_root(this.__wbg_ptr);
|
|
756
|
+
return SgNode.__wrap(ret);
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Returns the path of the file if it is discovered by ast-grep's `findInFiles`.
|
|
760
|
+
* Returns `"anonymous"` if the instance is created by `parse`.
|
|
761
|
+
* @returns {string}
|
|
762
|
+
*/
|
|
763
|
+
filename() {
|
|
764
|
+
let deferred1_0;
|
|
765
|
+
let deferred1_1;
|
|
766
|
+
try {
|
|
767
|
+
const ret = wasm.sgroot_filename(this.__wbg_ptr);
|
|
768
|
+
deferred1_0 = ret[0];
|
|
769
|
+
deferred1_1 = ret[1];
|
|
770
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
771
|
+
} finally {
|
|
772
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* This method is mainly for debugging tree parsing result.
|
|
777
|
+
* @returns {any}
|
|
778
|
+
*/
|
|
779
|
+
getInnerTree() {
|
|
780
|
+
const ret = wasm.sgroot_getInnerTree(this.__wbg_ptr);
|
|
781
|
+
return ret;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
if (Symbol.dispose) SgRoot.prototype[Symbol.dispose] = SgRoot.prototype.free;
|
|
785
|
+
|
|
786
|
+
export class WasmEdit {
|
|
787
|
+
static __wrap(ptr) {
|
|
788
|
+
ptr = ptr >>> 0;
|
|
789
|
+
const obj = Object.create(WasmEdit.prototype);
|
|
790
|
+
obj.__wbg_ptr = ptr;
|
|
791
|
+
WasmEditFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
792
|
+
return obj;
|
|
793
|
+
}
|
|
794
|
+
__destroy_into_raw() {
|
|
795
|
+
const ptr = this.__wbg_ptr;
|
|
796
|
+
this.__wbg_ptr = 0;
|
|
797
|
+
WasmEditFinalization.unregister(this);
|
|
798
|
+
return ptr;
|
|
799
|
+
}
|
|
800
|
+
free() {
|
|
801
|
+
const ptr = this.__destroy_into_raw();
|
|
802
|
+
wasm.__wbg_wasmedit_free(ptr, 0);
|
|
803
|
+
}
|
|
804
|
+
/**
|
|
805
|
+
* The start position of the edit (character offset)
|
|
806
|
+
* @returns {number}
|
|
807
|
+
*/
|
|
808
|
+
get start_pos() {
|
|
809
|
+
const ret = wasm.__wbg_get_wasmedit_start_pos(this.__wbg_ptr);
|
|
810
|
+
return ret >>> 0;
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* The start position of the edit (character offset)
|
|
814
|
+
* @param {number} arg0
|
|
815
|
+
*/
|
|
816
|
+
set start_pos(arg0) {
|
|
817
|
+
wasm.__wbg_set_wasmedit_start_pos(this.__wbg_ptr, arg0);
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* The end position of the edit (character offset)
|
|
821
|
+
* @returns {number}
|
|
822
|
+
*/
|
|
823
|
+
get end_pos() {
|
|
824
|
+
const ret = wasm.__wbg_get_wasmedit_end_pos(this.__wbg_ptr);
|
|
825
|
+
return ret >>> 0;
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* The end position of the edit (character offset)
|
|
829
|
+
* @param {number} arg0
|
|
830
|
+
*/
|
|
831
|
+
set end_pos(arg0) {
|
|
832
|
+
wasm.__wbg_set_wasmedit_end_pos(this.__wbg_ptr, arg0);
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* The text to be inserted
|
|
836
|
+
* @returns {string}
|
|
837
|
+
*/
|
|
838
|
+
get inserted_text() {
|
|
839
|
+
let deferred1_0;
|
|
840
|
+
let deferred1_1;
|
|
841
|
+
try {
|
|
842
|
+
const ret = wasm.__wbg_get_wasmedit_inserted_text(this.__wbg_ptr);
|
|
843
|
+
deferred1_0 = ret[0];
|
|
844
|
+
deferred1_1 = ret[1];
|
|
845
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
846
|
+
} finally {
|
|
847
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* The text to be inserted
|
|
852
|
+
* @param {string} arg0
|
|
853
|
+
*/
|
|
854
|
+
set inserted_text(arg0) {
|
|
855
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
856
|
+
const len0 = WASM_VECTOR_LEN;
|
|
857
|
+
wasm.__wbg_set_wasmedit_inserted_text(this.__wbg_ptr, ptr0, len0);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
if (Symbol.dispose) WasmEdit.prototype[Symbol.dispose] = WasmEdit.prototype.free;
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Dump a pattern's internal structure for inspection.
|
|
864
|
+
* `selector` is an optional kind name for contextual patterns.
|
|
865
|
+
* `strictness` is one of: "cst", "smart", "ast", "relaxed", "signature", "template".
|
|
866
|
+
* Returns a tree structure showing how ast-grep parses the pattern, including source positions.
|
|
867
|
+
* @param {string} lang
|
|
868
|
+
* @param {string} pattern_str
|
|
869
|
+
* @param {string | null} [selector]
|
|
870
|
+
* @param {string | null} [strictness]
|
|
871
|
+
* @returns {any}
|
|
872
|
+
*/
|
|
873
|
+
export function dumpPattern(lang, pattern_str, selector, strictness) {
|
|
874
|
+
const ptr0 = passStringToWasm0(lang, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
875
|
+
const len0 = WASM_VECTOR_LEN;
|
|
876
|
+
const ptr1 = passStringToWasm0(pattern_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
877
|
+
const len1 = WASM_VECTOR_LEN;
|
|
878
|
+
var ptr2 = isLikeNone(selector) ? 0 : passStringToWasm0(selector, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
879
|
+
var len2 = WASM_VECTOR_LEN;
|
|
880
|
+
var ptr3 = isLikeNone(strictness) ? 0 : passStringToWasm0(strictness, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
881
|
+
var len3 = WASM_VECTOR_LEN;
|
|
882
|
+
const ret = wasm.dumpPattern(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
883
|
+
if (ret[2]) {
|
|
884
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
885
|
+
}
|
|
886
|
+
return takeFromExternrefTable0(ret[0]);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* Initialize the tree-sitter WASM runtime.
|
|
891
|
+
* Must be called before any other function.
|
|
892
|
+
* @returns {Promise<void>}
|
|
893
|
+
*/
|
|
894
|
+
export function initializeTreeSitter() {
|
|
895
|
+
const ret = wasm.initializeTreeSitter();
|
|
896
|
+
return ret;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* Get the `kind` number from its string name.
|
|
901
|
+
* @param {string} lang
|
|
902
|
+
* @param {string} kind_name
|
|
903
|
+
* @returns {number}
|
|
904
|
+
*/
|
|
905
|
+
export function kind(lang, kind_name) {
|
|
906
|
+
const ptr0 = passStringToWasm0(lang, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
907
|
+
const len0 = WASM_VECTOR_LEN;
|
|
908
|
+
const ptr1 = passStringToWasm0(kind_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
909
|
+
const len1 = WASM_VECTOR_LEN;
|
|
910
|
+
const ret = wasm.kind(ptr0, len0, ptr1, len1);
|
|
911
|
+
if (ret[2]) {
|
|
912
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
913
|
+
}
|
|
914
|
+
return ret[0];
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* Parse a string to an ast-grep instance.
|
|
919
|
+
* @param {string} lang
|
|
920
|
+
* @param {string} src
|
|
921
|
+
* @returns {SgRoot}
|
|
922
|
+
*/
|
|
923
|
+
export function parse(lang, src) {
|
|
924
|
+
const ptr0 = passStringToWasm0(lang, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
925
|
+
const len0 = WASM_VECTOR_LEN;
|
|
926
|
+
const ptr1 = passStringToWasm0(src, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
927
|
+
const len1 = WASM_VECTOR_LEN;
|
|
928
|
+
const ret = wasm.parse(ptr0, len0, ptr1, len1);
|
|
929
|
+
if (ret[2]) {
|
|
930
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
931
|
+
}
|
|
932
|
+
return SgRoot.__wrap(ret[0]);
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* Compile a string to ast-grep Pattern config.
|
|
937
|
+
* @param {string} lang
|
|
938
|
+
* @param {string} pattern_str
|
|
939
|
+
* @returns {any}
|
|
940
|
+
*/
|
|
941
|
+
export function pattern(lang, pattern_str) {
|
|
942
|
+
const ptr0 = passStringToWasm0(lang, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
943
|
+
const len0 = WASM_VECTOR_LEN;
|
|
944
|
+
const ptr1 = passStringToWasm0(pattern_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
945
|
+
const len1 = WASM_VECTOR_LEN;
|
|
946
|
+
const ret = wasm.pattern(ptr0, len0, ptr1, len1);
|
|
947
|
+
if (ret[2]) {
|
|
948
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
949
|
+
}
|
|
950
|
+
return takeFromExternrefTable0(ret[0]);
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
/**
|
|
954
|
+
* Register dynamic languages for parsing.
|
|
955
|
+
* `langs` is a Map of language name to its registration config
|
|
956
|
+
* (with `libraryPath` and optional `expandoChar`).
|
|
957
|
+
* Can be called multiple times; existing languages are updated.
|
|
958
|
+
* @param {any} langs
|
|
959
|
+
* @returns {Promise<void>}
|
|
960
|
+
*/
|
|
961
|
+
export function registerDynamicLanguage(langs) {
|
|
962
|
+
const ret = wasm.registerDynamicLanguage(langs);
|
|
963
|
+
return ret;
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
967
|
+
|
|
968
|
+
async function __wbg_load(module, imports) {
|
|
969
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
970
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
971
|
+
try {
|
|
972
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
973
|
+
} catch (e) {
|
|
974
|
+
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
|
975
|
+
|
|
976
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
977
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
978
|
+
|
|
979
|
+
} else {
|
|
980
|
+
throw e;
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
const bytes = await module.arrayBuffer();
|
|
986
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
987
|
+
} else {
|
|
988
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
989
|
+
|
|
990
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
991
|
+
return { instance, module };
|
|
992
|
+
} else {
|
|
993
|
+
return instance;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
function __wbg_get_imports() {
|
|
999
|
+
const imports = {};
|
|
1000
|
+
imports.wbg = {};
|
|
1001
|
+
imports.wbg.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
|
|
1002
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
1003
|
+
return ret;
|
|
1004
|
+
};
|
|
1005
|
+
imports.wbg.__wbg_Number_2d1dcfcf4ec51736 = function(arg0) {
|
|
1006
|
+
const ret = Number(arg0);
|
|
1007
|
+
return ret;
|
|
1008
|
+
};
|
|
1009
|
+
imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
|
|
1010
|
+
const ret = String(arg1);
|
|
1011
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1012
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1013
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1014
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1015
|
+
};
|
|
1016
|
+
imports.wbg.__wbg___new_787f13d59e3c27b3 = function() { return handleError(function () {
|
|
1017
|
+
const ret = new Parser();
|
|
1018
|
+
return ret;
|
|
1019
|
+
}, arguments) };
|
|
1020
|
+
imports.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d = function(arg0, arg1) {
|
|
1021
|
+
const v = arg1;
|
|
1022
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
1023
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
1024
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
1025
|
+
};
|
|
1026
|
+
imports.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b = function(arg0) {
|
|
1027
|
+
const v = arg0;
|
|
1028
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
1029
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
1030
|
+
};
|
|
1031
|
+
imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
|
|
1032
|
+
const ret = debugString(arg1);
|
|
1033
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1034
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1035
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1036
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1037
|
+
};
|
|
1038
|
+
imports.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317 = function(arg0, arg1) {
|
|
1039
|
+
const ret = arg0 in arg1;
|
|
1040
|
+
return ret;
|
|
1041
|
+
};
|
|
1042
|
+
imports.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27 = function(arg0) {
|
|
1043
|
+
const ret = typeof(arg0) === 'bigint';
|
|
1044
|
+
return ret;
|
|
1045
|
+
};
|
|
1046
|
+
imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
|
|
1047
|
+
const ret = typeof(arg0) === 'function';
|
|
1048
|
+
return ret;
|
|
1049
|
+
};
|
|
1050
|
+
imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
|
|
1051
|
+
const val = arg0;
|
|
1052
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
1053
|
+
return ret;
|
|
1054
|
+
};
|
|
1055
|
+
imports.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030 = function(arg0) {
|
|
1056
|
+
const ret = typeof(arg0) === 'string';
|
|
1057
|
+
return ret;
|
|
1058
|
+
};
|
|
1059
|
+
imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
|
|
1060
|
+
const ret = arg0 === undefined;
|
|
1061
|
+
return ret;
|
|
1062
|
+
};
|
|
1063
|
+
imports.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36 = function(arg0, arg1) {
|
|
1064
|
+
const ret = arg0 === arg1;
|
|
1065
|
+
return ret;
|
|
1066
|
+
};
|
|
1067
|
+
imports.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d = function(arg0, arg1) {
|
|
1068
|
+
const ret = arg0 == arg1;
|
|
1069
|
+
return ret;
|
|
1070
|
+
};
|
|
1071
|
+
imports.wbg.__wbg___wbindgen_number_get_9619185a74197f95 = function(arg0, arg1) {
|
|
1072
|
+
const obj = arg1;
|
|
1073
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
1074
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
1075
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
1076
|
+
};
|
|
1077
|
+
imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
|
|
1078
|
+
const obj = arg1;
|
|
1079
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
1080
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1081
|
+
var len1 = WASM_VECTOR_LEN;
|
|
1082
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1083
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1084
|
+
};
|
|
1085
|
+
imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
|
|
1086
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1087
|
+
};
|
|
1088
|
+
imports.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7 = function(arg0) {
|
|
1089
|
+
arg0._wbg_cb_unref();
|
|
1090
|
+
};
|
|
1091
|
+
imports.wbg.__wbg_call_3020136f7a2d6e44 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
1092
|
+
const ret = arg0.call(arg1, arg2);
|
|
1093
|
+
return ret;
|
|
1094
|
+
}, arguments) };
|
|
1095
|
+
imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
|
|
1096
|
+
const ret = arg0.call(arg1);
|
|
1097
|
+
return ret;
|
|
1098
|
+
}, arguments) };
|
|
1099
|
+
imports.wbg.__wbg_childCount_de07bc245a25eb3f = function(arg0) {
|
|
1100
|
+
const ret = arg0.childCount;
|
|
1101
|
+
return ret;
|
|
1102
|
+
};
|
|
1103
|
+
imports.wbg.__wbg_childForFieldId_92fba831e1930465 = function(arg0, arg1) {
|
|
1104
|
+
const ret = arg0.childForFieldId(arg1);
|
|
1105
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1106
|
+
};
|
|
1107
|
+
imports.wbg.__wbg_childForFieldName_f5298e0a204706be = function(arg0, arg1, arg2) {
|
|
1108
|
+
const ret = arg0.childForFieldName(getStringFromWasm0(arg1, arg2));
|
|
1109
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1110
|
+
};
|
|
1111
|
+
imports.wbg.__wbg_child_029ab0e6576f3dcf = function(arg0, arg1) {
|
|
1112
|
+
const ret = arg0.child(arg1 >>> 0);
|
|
1113
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1114
|
+
};
|
|
1115
|
+
imports.wbg.__wbg_children_a37ba2dfb6b80464 = function(arg0, arg1) {
|
|
1116
|
+
const ret = arg1.children;
|
|
1117
|
+
const ptr1 = passArrayJsValueToWasm0(ret, wasm.__wbindgen_malloc);
|
|
1118
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1119
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1120
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1121
|
+
};
|
|
1122
|
+
imports.wbg.__wbg_codePointAt_6fd4439a1e465afd = function(arg0, arg1) {
|
|
1123
|
+
const ret = arg0.codePointAt(arg1 >>> 0);
|
|
1124
|
+
return ret;
|
|
1125
|
+
};
|
|
1126
|
+
imports.wbg.__wbg_column_3b3995b31a48ebcc = function(arg0) {
|
|
1127
|
+
const ret = arg0.column;
|
|
1128
|
+
return ret;
|
|
1129
|
+
};
|
|
1130
|
+
imports.wbg.__wbg_copy_68df1bc34d02d02a = function(arg0) {
|
|
1131
|
+
const ret = arg0.copy();
|
|
1132
|
+
return ret;
|
|
1133
|
+
};
|
|
1134
|
+
imports.wbg.__wbg_currentFieldId_60b5b0d9edc1c661 = function(arg0) {
|
|
1135
|
+
const ret = arg0.currentFieldId;
|
|
1136
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret;
|
|
1137
|
+
};
|
|
1138
|
+
imports.wbg.__wbg_currentNode_b02c22c493777936 = function(arg0) {
|
|
1139
|
+
const ret = arg0.currentNode;
|
|
1140
|
+
return ret;
|
|
1141
|
+
};
|
|
1142
|
+
imports.wbg.__wbg_done_62ea16af4ce34b24 = function(arg0) {
|
|
1143
|
+
const ret = arg0.done;
|
|
1144
|
+
return ret;
|
|
1145
|
+
};
|
|
1146
|
+
imports.wbg.__wbg_endIndex_e331f33af12fd45d = function(arg0) {
|
|
1147
|
+
const ret = arg0.endIndex;
|
|
1148
|
+
return ret;
|
|
1149
|
+
};
|
|
1150
|
+
imports.wbg.__wbg_endPosition_8b1d937cdfde90c4 = function(arg0) {
|
|
1151
|
+
const ret = arg0.endPosition;
|
|
1152
|
+
return ret;
|
|
1153
|
+
};
|
|
1154
|
+
imports.wbg.__wbg_entries_83c79938054e065f = function(arg0) {
|
|
1155
|
+
const ret = Object.entries(arg0);
|
|
1156
|
+
return ret;
|
|
1157
|
+
};
|
|
1158
|
+
imports.wbg.__wbg_fieldIdForName_98fb27f403bafa78 = function(arg0, arg1, arg2) {
|
|
1159
|
+
const ret = arg0.fieldIdForName(getStringFromWasm0(arg1, arg2));
|
|
1160
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret;
|
|
1161
|
+
};
|
|
1162
|
+
imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
|
|
1163
|
+
const ret = arg0[arg1 >>> 0];
|
|
1164
|
+
return ret;
|
|
1165
|
+
};
|
|
1166
|
+
imports.wbg.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) {
|
|
1167
|
+
const ret = Reflect.get(arg0, arg1);
|
|
1168
|
+
return ret;
|
|
1169
|
+
}, arguments) };
|
|
1170
|
+
imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) {
|
|
1171
|
+
const ret = arg0[arg1];
|
|
1172
|
+
return ret;
|
|
1173
|
+
};
|
|
1174
|
+
imports.wbg.__wbg_gotoFirstChild_4e19624eb2d02fd7 = function(arg0) {
|
|
1175
|
+
const ret = arg0.gotoFirstChild();
|
|
1176
|
+
return ret;
|
|
1177
|
+
};
|
|
1178
|
+
imports.wbg.__wbg_gotoNextSibling_cf4d88ae7ca14b4f = function(arg0) {
|
|
1179
|
+
const ret = arg0.gotoNextSibling();
|
|
1180
|
+
return ret;
|
|
1181
|
+
};
|
|
1182
|
+
imports.wbg.__wbg_idForNodeType_db9e5a2898894254 = function(arg0, arg1, arg2, arg3) {
|
|
1183
|
+
const ret = arg0.idForNodeType(getStringFromWasm0(arg1, arg2), arg3 !== 0);
|
|
1184
|
+
return ret;
|
|
1185
|
+
};
|
|
1186
|
+
imports.wbg.__wbg_id_8d04333487f5302a = function(arg0) {
|
|
1187
|
+
const ret = arg0.id;
|
|
1188
|
+
return ret;
|
|
1189
|
+
};
|
|
1190
|
+
imports.wbg.__wbg_init_30097ed011ec5213 = function() {
|
|
1191
|
+
const ret = Parser.init();
|
|
1192
|
+
return ret;
|
|
1193
|
+
};
|
|
1194
|
+
imports.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355 = function(arg0) {
|
|
1195
|
+
let result;
|
|
1196
|
+
try {
|
|
1197
|
+
result = arg0 instanceof ArrayBuffer;
|
|
1198
|
+
} catch (_) {
|
|
1199
|
+
result = false;
|
|
1200
|
+
}
|
|
1201
|
+
const ret = result;
|
|
1202
|
+
return ret;
|
|
1203
|
+
};
|
|
1204
|
+
imports.wbg.__wbg_instanceof_Error_3443650560328fa9 = function(arg0) {
|
|
1205
|
+
let result;
|
|
1206
|
+
try {
|
|
1207
|
+
result = arg0 instanceof Error;
|
|
1208
|
+
} catch (_) {
|
|
1209
|
+
result = false;
|
|
1210
|
+
}
|
|
1211
|
+
const ret = result;
|
|
1212
|
+
return ret;
|
|
1213
|
+
};
|
|
1214
|
+
imports.wbg.__wbg_instanceof_Map_084be8da74364158 = function(arg0) {
|
|
1215
|
+
let result;
|
|
1216
|
+
try {
|
|
1217
|
+
result = arg0 instanceof Map;
|
|
1218
|
+
} catch (_) {
|
|
1219
|
+
result = false;
|
|
1220
|
+
}
|
|
1221
|
+
const ret = result;
|
|
1222
|
+
return ret;
|
|
1223
|
+
};
|
|
1224
|
+
imports.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434 = function(arg0) {
|
|
1225
|
+
let result;
|
|
1226
|
+
try {
|
|
1227
|
+
result = arg0 instanceof Uint8Array;
|
|
1228
|
+
} catch (_) {
|
|
1229
|
+
result = false;
|
|
1230
|
+
}
|
|
1231
|
+
const ret = result;
|
|
1232
|
+
return ret;
|
|
1233
|
+
};
|
|
1234
|
+
imports.wbg.__wbg_isArray_51fd9e6422c0a395 = function(arg0) {
|
|
1235
|
+
const ret = Array.isArray(arg0);
|
|
1236
|
+
return ret;
|
|
1237
|
+
};
|
|
1238
|
+
imports.wbg.__wbg_isMissing_983f1550905ddf15 = function(arg0) {
|
|
1239
|
+
const ret = arg0.isMissing;
|
|
1240
|
+
return ret;
|
|
1241
|
+
};
|
|
1242
|
+
imports.wbg.__wbg_isNamed_42df2e4d523acc82 = function(arg0) {
|
|
1243
|
+
const ret = arg0.isNamed;
|
|
1244
|
+
return ret;
|
|
1245
|
+
};
|
|
1246
|
+
imports.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16 = function(arg0) {
|
|
1247
|
+
const ret = Number.isSafeInteger(arg0);
|
|
1248
|
+
return ret;
|
|
1249
|
+
};
|
|
1250
|
+
imports.wbg.__wbg_iterator_27b7c8b35ab3e86b = function() {
|
|
1251
|
+
const ret = Symbol.iterator;
|
|
1252
|
+
return ret;
|
|
1253
|
+
};
|
|
1254
|
+
imports.wbg.__wbg_language_9d81a7eea18cfdea = function(arg0) {
|
|
1255
|
+
const ret = arg0.language;
|
|
1256
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1257
|
+
};
|
|
1258
|
+
imports.wbg.__wbg_length_1f83b8e5895c84aa = function(arg0) {
|
|
1259
|
+
const ret = arg0.length;
|
|
1260
|
+
return ret;
|
|
1261
|
+
};
|
|
1262
|
+
imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
|
|
1263
|
+
const ret = arg0.length;
|
|
1264
|
+
return ret;
|
|
1265
|
+
};
|
|
1266
|
+
imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
|
|
1267
|
+
const ret = arg0.length;
|
|
1268
|
+
return ret;
|
|
1269
|
+
};
|
|
1270
|
+
imports.wbg.__wbg_load_850a812d025212cb = function(arg0, arg1) {
|
|
1271
|
+
const ret = Language.load(getStringFromWasm0(arg0, arg1));
|
|
1272
|
+
return ret;
|
|
1273
|
+
};
|
|
1274
|
+
imports.wbg.__wbg_message_0305fa7903f4b3d9 = function(arg0) {
|
|
1275
|
+
const ret = arg0.message;
|
|
1276
|
+
return ret;
|
|
1277
|
+
};
|
|
1278
|
+
imports.wbg.__wbg_namedChildCount_51d6be816895dd05 = function(arg0) {
|
|
1279
|
+
const ret = arg0.namedChildCount;
|
|
1280
|
+
return ret;
|
|
1281
|
+
};
|
|
1282
|
+
imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
|
|
1283
|
+
const ret = new Object();
|
|
1284
|
+
return ret;
|
|
1285
|
+
};
|
|
1286
|
+
imports.wbg.__wbg_new_25f239778d6112b9 = function() {
|
|
1287
|
+
const ret = new Array();
|
|
1288
|
+
return ret;
|
|
1289
|
+
};
|
|
1290
|
+
imports.wbg.__wbg_new_6421f6084cc5bc5a = function(arg0) {
|
|
1291
|
+
const ret = new Uint8Array(arg0);
|
|
1292
|
+
return ret;
|
|
1293
|
+
};
|
|
1294
|
+
imports.wbg.__wbg_new_b546ae120718850e = function() {
|
|
1295
|
+
const ret = new Map();
|
|
1296
|
+
return ret;
|
|
1297
|
+
};
|
|
1298
|
+
imports.wbg.__wbg_new_ff12d2b041fb48f1 = function(arg0, arg1) {
|
|
1299
|
+
try {
|
|
1300
|
+
var state0 = {a: arg0, b: arg1};
|
|
1301
|
+
var cb0 = (arg0, arg1) => {
|
|
1302
|
+
const a = state0.a;
|
|
1303
|
+
state0.a = 0;
|
|
1304
|
+
try {
|
|
1305
|
+
return wasm_bindgen__convert__closures_____invoke__h626c386f4a0f1908(a, state0.b, arg0, arg1);
|
|
1306
|
+
} finally {
|
|
1307
|
+
state0.a = a;
|
|
1308
|
+
}
|
|
1309
|
+
};
|
|
1310
|
+
const ret = new Promise(cb0);
|
|
1311
|
+
return ret;
|
|
1312
|
+
} finally {
|
|
1313
|
+
state0.a = state0.b = 0;
|
|
1314
|
+
}
|
|
1315
|
+
};
|
|
1316
|
+
imports.wbg.__wbg_new_no_args_cb138f77cf6151ee = function(arg0, arg1) {
|
|
1317
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
1318
|
+
return ret;
|
|
1319
|
+
};
|
|
1320
|
+
imports.wbg.__wbg_nextSibling_c710343c141256ca = function(arg0) {
|
|
1321
|
+
const ret = arg0.nextSibling;
|
|
1322
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1323
|
+
};
|
|
1324
|
+
imports.wbg.__wbg_next_138a17bbf04e926c = function(arg0) {
|
|
1325
|
+
const ret = arg0.next;
|
|
1326
|
+
return ret;
|
|
1327
|
+
};
|
|
1328
|
+
imports.wbg.__wbg_next_3cfe5c0fe2a4cc53 = function() { return handleError(function (arg0) {
|
|
1329
|
+
const ret = arg0.next();
|
|
1330
|
+
return ret;
|
|
1331
|
+
}, arguments) };
|
|
1332
|
+
imports.wbg.__wbg_parent_ed63212d972ff74e = function(arg0) {
|
|
1333
|
+
const ret = arg0.parent;
|
|
1334
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1335
|
+
};
|
|
1336
|
+
imports.wbg.__wbg_parse_48a41e718e39deaf = function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
1337
|
+
const ret = arg0.parse(arg1, arg2, arg3);
|
|
1338
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1339
|
+
}, arguments) };
|
|
1340
|
+
imports.wbg.__wbg_previousSibling_6475f5ddc9f696a8 = function(arg0) {
|
|
1341
|
+
const ret = arg0.previousSibling;
|
|
1342
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1343
|
+
};
|
|
1344
|
+
imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
|
|
1345
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
1346
|
+
};
|
|
1347
|
+
imports.wbg.__wbg_queueMicrotask_9b549dfce8865860 = function(arg0) {
|
|
1348
|
+
const ret = arg0.queueMicrotask;
|
|
1349
|
+
return ret;
|
|
1350
|
+
};
|
|
1351
|
+
imports.wbg.__wbg_queueMicrotask_fca69f5bfad613a5 = function(arg0) {
|
|
1352
|
+
queueMicrotask(arg0);
|
|
1353
|
+
};
|
|
1354
|
+
imports.wbg.__wbg_resolve_fd5bfbaa4ce36e1e = function(arg0) {
|
|
1355
|
+
const ret = Promise.resolve(arg0);
|
|
1356
|
+
return ret;
|
|
1357
|
+
};
|
|
1358
|
+
imports.wbg.__wbg_rootNode_cccf4744f06730de = function(arg0) {
|
|
1359
|
+
const ret = arg0.rootNode;
|
|
1360
|
+
return ret;
|
|
1361
|
+
};
|
|
1362
|
+
imports.wbg.__wbg_row_9fd693dd91b8903d = function(arg0) {
|
|
1363
|
+
const ret = arg0.row;
|
|
1364
|
+
return ret;
|
|
1365
|
+
};
|
|
1366
|
+
imports.wbg.__wbg_setLanguage_5c317d6d3b5f6e7e = function() { return handleError(function (arg0, arg1) {
|
|
1367
|
+
arg0.setLanguage(arg1);
|
|
1368
|
+
}, arguments) };
|
|
1369
|
+
imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
|
|
1370
|
+
arg0[arg1] = arg2;
|
|
1371
|
+
};
|
|
1372
|
+
imports.wbg.__wbg_set_7df433eea03a5c14 = function(arg0, arg1, arg2) {
|
|
1373
|
+
arg0[arg1 >>> 0] = arg2;
|
|
1374
|
+
};
|
|
1375
|
+
imports.wbg.__wbg_set_efaaf145b9377369 = function(arg0, arg1, arg2) {
|
|
1376
|
+
const ret = arg0.set(arg1, arg2);
|
|
1377
|
+
return ret;
|
|
1378
|
+
};
|
|
1379
|
+
imports.wbg.__wbg_sgnode_new = function(arg0) {
|
|
1380
|
+
const ret = SgNode.__wrap(arg0);
|
|
1381
|
+
return ret;
|
|
1382
|
+
};
|
|
1383
|
+
imports.wbg.__wbg_startIndex_da1f81c7b30c778b = function(arg0) {
|
|
1384
|
+
const ret = arg0.startIndex;
|
|
1385
|
+
return ret;
|
|
1386
|
+
};
|
|
1387
|
+
imports.wbg.__wbg_startPosition_728789ee60487a49 = function(arg0) {
|
|
1388
|
+
const ret = arg0.startPosition;
|
|
1389
|
+
return ret;
|
|
1390
|
+
};
|
|
1391
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335 = function() {
|
|
1392
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
1393
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1394
|
+
};
|
|
1395
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1 = function() {
|
|
1396
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
1397
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1398
|
+
};
|
|
1399
|
+
imports.wbg.__wbg_static_accessor_SELF_08f5a74c69739274 = function() {
|
|
1400
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
1401
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1402
|
+
};
|
|
1403
|
+
imports.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024 = function() {
|
|
1404
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
1405
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1406
|
+
};
|
|
1407
|
+
imports.wbg.__wbg_text_337784c9e9f2fce3 = function(arg0) {
|
|
1408
|
+
const ret = arg0.text;
|
|
1409
|
+
return ret;
|
|
1410
|
+
};
|
|
1411
|
+
imports.wbg.__wbg_then_429f7caf1026411d = function(arg0, arg1, arg2) {
|
|
1412
|
+
const ret = arg0.then(arg1, arg2);
|
|
1413
|
+
return ret;
|
|
1414
|
+
};
|
|
1415
|
+
imports.wbg.__wbg_then_4f95312d68691235 = function(arg0, arg1) {
|
|
1416
|
+
const ret = arg0.then(arg1);
|
|
1417
|
+
return ret;
|
|
1418
|
+
};
|
|
1419
|
+
imports.wbg.__wbg_typeId_48f8b33db59279a4 = function(arg0) {
|
|
1420
|
+
const ret = arg0.typeId;
|
|
1421
|
+
return ret;
|
|
1422
|
+
};
|
|
1423
|
+
imports.wbg.__wbg_type_87e9aaf85e23c978 = function(arg0) {
|
|
1424
|
+
const ret = arg0.type;
|
|
1425
|
+
return ret;
|
|
1426
|
+
};
|
|
1427
|
+
imports.wbg.__wbg_value_57b7b035e117f7ee = function(arg0) {
|
|
1428
|
+
const ret = arg0.value;
|
|
1429
|
+
return ret;
|
|
1430
|
+
};
|
|
1431
|
+
imports.wbg.__wbg_walk_4950d9be6e9dd147 = function(arg0) {
|
|
1432
|
+
const ret = arg0.walk();
|
|
1433
|
+
return ret;
|
|
1434
|
+
};
|
|
1435
|
+
imports.wbg.__wbindgen_cast_06201bfef2cbb1e4 = function(arg0, arg1) {
|
|
1436
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 329, function: Function { arguments: [Externref], shim_idx: 330, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1437
|
+
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hfe03ac61b9e9de77, wasm_bindgen__convert__closures_____invoke__hf6abb6e10d012239);
|
|
1438
|
+
return ret;
|
|
1439
|
+
};
|
|
1440
|
+
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
1441
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
1442
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
1443
|
+
return ret;
|
|
1444
|
+
};
|
|
1445
|
+
imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
|
|
1446
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
1447
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
1448
|
+
return ret;
|
|
1449
|
+
};
|
|
1450
|
+
imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
|
|
1451
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
1452
|
+
const ret = arg0;
|
|
1453
|
+
return ret;
|
|
1454
|
+
};
|
|
1455
|
+
imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
1456
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
1457
|
+
const ret = arg0;
|
|
1458
|
+
return ret;
|
|
1459
|
+
};
|
|
1460
|
+
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
1461
|
+
const table = wasm.__wbindgen_externrefs;
|
|
1462
|
+
const offset = table.grow(4);
|
|
1463
|
+
table.set(0, undefined);
|
|
1464
|
+
table.set(offset + 0, undefined);
|
|
1465
|
+
table.set(offset + 1, null);
|
|
1466
|
+
table.set(offset + 2, true);
|
|
1467
|
+
table.set(offset + 3, false);
|
|
1468
|
+
};
|
|
1469
|
+
|
|
1470
|
+
return imports;
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
function __wbg_finalize_init(instance, module) {
|
|
1474
|
+
wasm = instance.exports;
|
|
1475
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
1476
|
+
cachedDataViewMemory0 = null;
|
|
1477
|
+
cachedUint8ArrayMemory0 = null;
|
|
1478
|
+
|
|
1479
|
+
|
|
1480
|
+
wasm.__wbindgen_start();
|
|
1481
|
+
return wasm;
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
function initSync(module) {
|
|
1485
|
+
if (wasm !== undefined) return wasm;
|
|
1486
|
+
|
|
1487
|
+
|
|
1488
|
+
if (typeof module !== 'undefined') {
|
|
1489
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
1490
|
+
({module} = module)
|
|
1491
|
+
} else {
|
|
1492
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
const imports = __wbg_get_imports();
|
|
1497
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
1498
|
+
module = new WebAssembly.Module(module);
|
|
1499
|
+
}
|
|
1500
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
1501
|
+
return __wbg_finalize_init(instance, module);
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
async function __wbg_init(module_or_path) {
|
|
1505
|
+
if (wasm !== undefined) return wasm;
|
|
1506
|
+
|
|
1507
|
+
|
|
1508
|
+
if (typeof module_or_path !== 'undefined') {
|
|
1509
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
1510
|
+
({module_or_path} = module_or_path)
|
|
1511
|
+
} else {
|
|
1512
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
if (typeof module_or_path === 'undefined') {
|
|
1517
|
+
module_or_path = new URL('wasm_bg.wasm', import.meta.url);
|
|
1518
|
+
}
|
|
1519
|
+
const imports = __wbg_get_imports();
|
|
1520
|
+
|
|
1521
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
1522
|
+
module_or_path = fetch(module_or_path);
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
1526
|
+
|
|
1527
|
+
return __wbg_finalize_init(instance, module);
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
export { initSync };
|
|
1531
|
+
export default __wbg_init;
|