@emnudge/wat-lsp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +119 -0
- package/dist/index.d.ts +216 -0
- package/dist/index.js +201 -0
- package/dist/wasm/tree-sitter.wasm +0 -0
- package/dist/wasm/wat_lsp_rust.d.ts +132 -0
- package/dist/wasm/wat_lsp_rust.js +811 -0
- package/dist/wasm/wat_lsp_rust_bg.wasm +0 -0
- package/package.json +60 -0
|
@@ -0,0 +1,811 @@
|
|
|
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
|
+
const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
|
|
12
|
+
? { register: () => {}, unregister: () => {} }
|
|
13
|
+
: new FinalizationRegistry(state => state.dtor(state.a, state.b));
|
|
14
|
+
|
|
15
|
+
function debugString(val) {
|
|
16
|
+
// primitive types
|
|
17
|
+
const type = typeof val;
|
|
18
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
19
|
+
return `${val}`;
|
|
20
|
+
}
|
|
21
|
+
if (type == 'string') {
|
|
22
|
+
return `"${val}"`;
|
|
23
|
+
}
|
|
24
|
+
if (type == 'symbol') {
|
|
25
|
+
const description = val.description;
|
|
26
|
+
if (description == null) {
|
|
27
|
+
return 'Symbol';
|
|
28
|
+
} else {
|
|
29
|
+
return `Symbol(${description})`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (type == 'function') {
|
|
33
|
+
const name = val.name;
|
|
34
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
35
|
+
return `Function(${name})`;
|
|
36
|
+
} else {
|
|
37
|
+
return 'Function';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// objects
|
|
41
|
+
if (Array.isArray(val)) {
|
|
42
|
+
const length = val.length;
|
|
43
|
+
let debug = '[';
|
|
44
|
+
if (length > 0) {
|
|
45
|
+
debug += debugString(val[0]);
|
|
46
|
+
}
|
|
47
|
+
for(let i = 1; i < length; i++) {
|
|
48
|
+
debug += ', ' + debugString(val[i]);
|
|
49
|
+
}
|
|
50
|
+
debug += ']';
|
|
51
|
+
return debug;
|
|
52
|
+
}
|
|
53
|
+
// Test for built-in
|
|
54
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
55
|
+
let className;
|
|
56
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
57
|
+
className = builtInMatches[1];
|
|
58
|
+
} else {
|
|
59
|
+
// Failed to match the standard '[object ClassName]'
|
|
60
|
+
return toString.call(val);
|
|
61
|
+
}
|
|
62
|
+
if (className == 'Object') {
|
|
63
|
+
// we're a user defined class or Object
|
|
64
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
65
|
+
// easier than looping through ownProperties of `val`.
|
|
66
|
+
try {
|
|
67
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
68
|
+
} catch (_) {
|
|
69
|
+
return 'Object';
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// errors
|
|
73
|
+
if (val instanceof Error) {
|
|
74
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
75
|
+
}
|
|
76
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
77
|
+
return className;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
81
|
+
ptr = ptr >>> 0;
|
|
82
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
86
|
+
ptr = ptr >>> 0;
|
|
87
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
let cachedDataViewMemory0 = null;
|
|
91
|
+
function getDataViewMemory0() {
|
|
92
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
93
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
94
|
+
}
|
|
95
|
+
return cachedDataViewMemory0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function getStringFromWasm0(ptr, len) {
|
|
99
|
+
ptr = ptr >>> 0;
|
|
100
|
+
return decodeText(ptr, len);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
let cachedUint32ArrayMemory0 = null;
|
|
104
|
+
function getUint32ArrayMemory0() {
|
|
105
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
106
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
107
|
+
}
|
|
108
|
+
return cachedUint32ArrayMemory0;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
let cachedUint8ArrayMemory0 = null;
|
|
112
|
+
function getUint8ArrayMemory0() {
|
|
113
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
114
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
115
|
+
}
|
|
116
|
+
return cachedUint8ArrayMemory0;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function handleError(f, args) {
|
|
120
|
+
try {
|
|
121
|
+
return f.apply(this, args);
|
|
122
|
+
} catch (e) {
|
|
123
|
+
const idx = addToExternrefTable0(e);
|
|
124
|
+
wasm.__wbindgen_exn_store(idx);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function isLikeNone(x) {
|
|
129
|
+
return x === undefined || x === null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function makeMutClosure(arg0, arg1, dtor, f) {
|
|
133
|
+
const state = { a: arg0, b: arg1, cnt: 1, dtor };
|
|
134
|
+
const real = (...args) => {
|
|
135
|
+
|
|
136
|
+
// First up with a closure we increment the internal reference
|
|
137
|
+
// count. This ensures that the Rust closure environment won't
|
|
138
|
+
// be deallocated while we're invoking it.
|
|
139
|
+
state.cnt++;
|
|
140
|
+
const a = state.a;
|
|
141
|
+
state.a = 0;
|
|
142
|
+
try {
|
|
143
|
+
return f(a, state.b, ...args);
|
|
144
|
+
} finally {
|
|
145
|
+
state.a = a;
|
|
146
|
+
real._wbg_cb_unref();
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
real._wbg_cb_unref = () => {
|
|
150
|
+
if (--state.cnt === 0) {
|
|
151
|
+
state.dtor(state.a, state.b);
|
|
152
|
+
state.a = 0;
|
|
153
|
+
CLOSURE_DTORS.unregister(state);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
CLOSURE_DTORS.register(real, state, state);
|
|
157
|
+
return real;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
161
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
162
|
+
for (let i = 0; i < array.length; i++) {
|
|
163
|
+
const add = addToExternrefTable0(array[i]);
|
|
164
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
165
|
+
}
|
|
166
|
+
WASM_VECTOR_LEN = array.length;
|
|
167
|
+
return ptr;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
171
|
+
if (realloc === undefined) {
|
|
172
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
173
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
174
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
175
|
+
WASM_VECTOR_LEN = buf.length;
|
|
176
|
+
return ptr;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
let len = arg.length;
|
|
180
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
181
|
+
|
|
182
|
+
const mem = getUint8ArrayMemory0();
|
|
183
|
+
|
|
184
|
+
let offset = 0;
|
|
185
|
+
|
|
186
|
+
for (; offset < len; offset++) {
|
|
187
|
+
const code = arg.charCodeAt(offset);
|
|
188
|
+
if (code > 0x7F) break;
|
|
189
|
+
mem[ptr + offset] = code;
|
|
190
|
+
}
|
|
191
|
+
if (offset !== len) {
|
|
192
|
+
if (offset !== 0) {
|
|
193
|
+
arg = arg.slice(offset);
|
|
194
|
+
}
|
|
195
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
196
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
197
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
198
|
+
|
|
199
|
+
offset += ret.written;
|
|
200
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
WASM_VECTOR_LEN = offset;
|
|
204
|
+
return ptr;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
208
|
+
cachedTextDecoder.decode();
|
|
209
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
210
|
+
let numBytesDecoded = 0;
|
|
211
|
+
function decodeText(ptr, len) {
|
|
212
|
+
numBytesDecoded += len;
|
|
213
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
214
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
215
|
+
cachedTextDecoder.decode();
|
|
216
|
+
numBytesDecoded = len;
|
|
217
|
+
}
|
|
218
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const cachedTextEncoder = new TextEncoder();
|
|
222
|
+
|
|
223
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
224
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
225
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
226
|
+
view.set(buf);
|
|
227
|
+
return {
|
|
228
|
+
read: arg.length,
|
|
229
|
+
written: buf.length
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
let WASM_VECTOR_LEN = 0;
|
|
235
|
+
|
|
236
|
+
function wasm_bindgen__convert__closures_____invoke__hc43d41e9321ebc8f(arg0, arg1, arg2) {
|
|
237
|
+
wasm.wasm_bindgen__convert__closures_____invoke__hc43d41e9321ebc8f(arg0, arg1, arg2);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function wasm_bindgen__convert__closures_____invoke__h17d4e94d5fe1e6e2(arg0, arg1, arg2, arg3) {
|
|
241
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h17d4e94d5fe1e6e2(arg0, arg1, arg2, arg3);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const WatLSPFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
245
|
+
? { register: () => {}, unregister: () => {} }
|
|
246
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_watlsp_free(ptr >>> 0, 1));
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* WAT Language Server for browser use
|
|
250
|
+
*/
|
|
251
|
+
export class WatLSP {
|
|
252
|
+
__destroy_into_raw() {
|
|
253
|
+
const ptr = this.__wbg_ptr;
|
|
254
|
+
this.__wbg_ptr = 0;
|
|
255
|
+
WatLSPFinalization.unregister(this);
|
|
256
|
+
return ptr;
|
|
257
|
+
}
|
|
258
|
+
free() {
|
|
259
|
+
const ptr = this.__destroy_into_raw();
|
|
260
|
+
wasm.__wbg_watlsp_free(ptr, 0);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Initialize the LSP (initializes tree-sitter). Returns true if successful.
|
|
264
|
+
* @returns {Promise<boolean>}
|
|
265
|
+
*/
|
|
266
|
+
initialize() {
|
|
267
|
+
const ret = wasm.watlsp_initialize(this.__wbg_ptr);
|
|
268
|
+
return ret;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Debug: get info about a word at position
|
|
272
|
+
* @param {number} line
|
|
273
|
+
* @param {number} col
|
|
274
|
+
* @returns {any}
|
|
275
|
+
*/
|
|
276
|
+
debugWordAt(line, col) {
|
|
277
|
+
const ret = wasm.watlsp_debugWordAt(this.__wbg_ptr, line, col);
|
|
278
|
+
return ret;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Provide hover information at the given position (uses tree-sitter based hover)
|
|
282
|
+
* @param {number} line
|
|
283
|
+
* @param {number} col
|
|
284
|
+
* @returns {any}
|
|
285
|
+
*/
|
|
286
|
+
provideHover(line, col) {
|
|
287
|
+
const ret = wasm.watlsp_provideHover(this.__wbg_ptr, line, col);
|
|
288
|
+
return ret;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Provide code completion items at the given position
|
|
292
|
+
* Returns an array of completion item objects
|
|
293
|
+
* @param {number} line
|
|
294
|
+
* @param {number} col
|
|
295
|
+
* @returns {any}
|
|
296
|
+
*/
|
|
297
|
+
provideCompletion(line, col) {
|
|
298
|
+
const ret = wasm.watlsp_provideCompletion(this.__wbg_ptr, line, col);
|
|
299
|
+
return ret;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Provide go-to-definition at the given position
|
|
303
|
+
* @param {number} line
|
|
304
|
+
* @param {number} col
|
|
305
|
+
* @returns {any}
|
|
306
|
+
*/
|
|
307
|
+
provideDefinition(line, col) {
|
|
308
|
+
const ret = wasm.watlsp_provideDefinition(this.__wbg_ptr, line, col);
|
|
309
|
+
return ret;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Provide find-references at the given position
|
|
313
|
+
* @param {number} line
|
|
314
|
+
* @param {number} col
|
|
315
|
+
* @param {boolean} include_declaration
|
|
316
|
+
* @returns {any}
|
|
317
|
+
*/
|
|
318
|
+
provideReferences(line, col, include_declaration) {
|
|
319
|
+
const ret = wasm.watlsp_provideReferences(this.__wbg_ptr, line, col, include_declaration);
|
|
320
|
+
return ret;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Get diagnostics (syntax errors) for the current document
|
|
324
|
+
* @returns {any}
|
|
325
|
+
*/
|
|
326
|
+
provideDiagnostics() {
|
|
327
|
+
const ret = wasm.watlsp_provideDiagnostics(this.__wbg_ptr);
|
|
328
|
+
return ret;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Get symbol table as HTML for debugging
|
|
332
|
+
* @returns {string}
|
|
333
|
+
*/
|
|
334
|
+
getSymbolTableHTML() {
|
|
335
|
+
let deferred1_0;
|
|
336
|
+
let deferred1_1;
|
|
337
|
+
try {
|
|
338
|
+
const ret = wasm.watlsp_getSymbolTableHTML(this.__wbg_ptr);
|
|
339
|
+
deferred1_0 = ret[0];
|
|
340
|
+
deferred1_1 = ret[1];
|
|
341
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
342
|
+
} finally {
|
|
343
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Provide folding ranges for the current document
|
|
348
|
+
* Returns an array of folding range objects with startLine, endLine, and kind
|
|
349
|
+
* @returns {any}
|
|
350
|
+
*/
|
|
351
|
+
provideFoldingRanges() {
|
|
352
|
+
const ret = wasm.watlsp_provideFoldingRanges(this.__wbg_ptr);
|
|
353
|
+
return ret;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Provide semantic tokens for syntax highlighting
|
|
357
|
+
* Returns a flat array of u32 values in Monaco's delta-encoded format:
|
|
358
|
+
* [deltaLine, deltaStartChar, length, tokenType, tokenModifiers, ...]
|
|
359
|
+
* @returns {Uint32Array}
|
|
360
|
+
*/
|
|
361
|
+
provideSemanticTokens() {
|
|
362
|
+
const ret = wasm.watlsp_provideSemanticTokens(this.__wbg_ptr);
|
|
363
|
+
return ret;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Provide document symbols (outline) for the current document
|
|
367
|
+
* Returns a hierarchical array of symbols matching the LSP DocumentSymbol structure
|
|
368
|
+
* @returns {any}
|
|
369
|
+
*/
|
|
370
|
+
provideDocumentSymbols() {
|
|
371
|
+
const ret = wasm.watlsp_provideDocumentSymbols(this.__wbg_ptr);
|
|
372
|
+
return ret;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Get the semantic token legend (token types and modifiers)
|
|
376
|
+
* @returns {any}
|
|
377
|
+
*/
|
|
378
|
+
getSemanticTokensLegend() {
|
|
379
|
+
const ret = wasm.watlsp_getSemanticTokensLegend(this.__wbg_ptr);
|
|
380
|
+
return ret;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Create a new WAT LSP instance
|
|
384
|
+
*/
|
|
385
|
+
constructor() {
|
|
386
|
+
const ret = wasm.watlsp_new();
|
|
387
|
+
this.__wbg_ptr = ret >>> 0;
|
|
388
|
+
WatLSPFinalization.register(this, this.__wbg_ptr, this);
|
|
389
|
+
return this;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Parse a WAT document and build symbol table using tree-sitter
|
|
393
|
+
* @param {string} document
|
|
394
|
+
*/
|
|
395
|
+
parse(document) {
|
|
396
|
+
const ptr0 = passStringToWasm0(document, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
397
|
+
const len0 = WASM_VECTOR_LEN;
|
|
398
|
+
wasm.watlsp_parse(this.__wbg_ptr, ptr0, len0);
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Check if the LSP is ready
|
|
402
|
+
* @returns {boolean}
|
|
403
|
+
*/
|
|
404
|
+
get ready() {
|
|
405
|
+
const ret = wasm.watlsp_ready(this.__wbg_ptr);
|
|
406
|
+
return ret !== 0;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
if (Symbol.dispose) WatLSP.prototype[Symbol.dispose] = WatLSP.prototype.free;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Initialize panic hook for better error messages in the browser console
|
|
413
|
+
*/
|
|
414
|
+
export function init() {
|
|
415
|
+
wasm.init();
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
419
|
+
|
|
420
|
+
async function __wbg_load(module, imports) {
|
|
421
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
422
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
423
|
+
try {
|
|
424
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
425
|
+
} catch (e) {
|
|
426
|
+
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
|
427
|
+
|
|
428
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
429
|
+
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);
|
|
430
|
+
|
|
431
|
+
} else {
|
|
432
|
+
throw e;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
const bytes = await module.arrayBuffer();
|
|
438
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
439
|
+
} else {
|
|
440
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
441
|
+
|
|
442
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
443
|
+
return { instance, module };
|
|
444
|
+
} else {
|
|
445
|
+
return instance;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function __wbg_get_imports() {
|
|
451
|
+
const imports = {};
|
|
452
|
+
imports.wbg = {};
|
|
453
|
+
imports.wbg.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
|
|
454
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
455
|
+
return ret;
|
|
456
|
+
};
|
|
457
|
+
imports.wbg.__wbg___new_102c599293914cb9 = function() { return handleError(function () {
|
|
458
|
+
const ret = new Parser();
|
|
459
|
+
return ret;
|
|
460
|
+
}, arguments) };
|
|
461
|
+
imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
|
|
462
|
+
const ret = debugString(arg1);
|
|
463
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
464
|
+
const len1 = WASM_VECTOR_LEN;
|
|
465
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
466
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
467
|
+
};
|
|
468
|
+
imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
|
|
469
|
+
const ret = typeof(arg0) === 'function';
|
|
470
|
+
return ret;
|
|
471
|
+
};
|
|
472
|
+
imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
|
|
473
|
+
const ret = arg0 === undefined;
|
|
474
|
+
return ret;
|
|
475
|
+
};
|
|
476
|
+
imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
|
|
477
|
+
const obj = arg1;
|
|
478
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
479
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
480
|
+
var len1 = WASM_VECTOR_LEN;
|
|
481
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
482
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
483
|
+
};
|
|
484
|
+
imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
|
|
485
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
486
|
+
};
|
|
487
|
+
imports.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7 = function(arg0) {
|
|
488
|
+
arg0._wbg_cb_unref();
|
|
489
|
+
};
|
|
490
|
+
imports.wbg.__wbg_call_3020136f7a2d6e44 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
491
|
+
const ret = arg0.call(arg1, arg2);
|
|
492
|
+
return ret;
|
|
493
|
+
}, arguments) };
|
|
494
|
+
imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
|
|
495
|
+
const ret = arg0.call(arg1);
|
|
496
|
+
return ret;
|
|
497
|
+
}, arguments) };
|
|
498
|
+
imports.wbg.__wbg_captures_861522549c4a72d0 = function(arg0, arg1, arg2, arg3, arg4) {
|
|
499
|
+
const ret = arg1.captures(arg2, arg3, arg4);
|
|
500
|
+
const ptr1 = passArrayJsValueToWasm0(ret, wasm.__wbindgen_malloc);
|
|
501
|
+
const len1 = WASM_VECTOR_LEN;
|
|
502
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
503
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
504
|
+
};
|
|
505
|
+
imports.wbg.__wbg_childCount_227026df032ed192 = function(arg0) {
|
|
506
|
+
const ret = arg0.childCount;
|
|
507
|
+
return ret;
|
|
508
|
+
};
|
|
509
|
+
imports.wbg.__wbg_child_76b89ba03f9b2bac = function(arg0, arg1) {
|
|
510
|
+
const ret = arg0.child(arg1 >>> 0);
|
|
511
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
512
|
+
};
|
|
513
|
+
imports.wbg.__wbg_column_7c928f46de069eb4 = function(arg0) {
|
|
514
|
+
const ret = arg0.column;
|
|
515
|
+
return ret;
|
|
516
|
+
};
|
|
517
|
+
imports.wbg.__wbg_endIndex_7257cc0375fd3743 = function(arg0) {
|
|
518
|
+
const ret = arg0.endIndex;
|
|
519
|
+
return ret;
|
|
520
|
+
};
|
|
521
|
+
imports.wbg.__wbg_endPosition_1c33c931f8ff42b8 = function(arg0) {
|
|
522
|
+
const ret = arg0.endPosition;
|
|
523
|
+
return ret;
|
|
524
|
+
};
|
|
525
|
+
imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
|
|
526
|
+
let deferred0_0;
|
|
527
|
+
let deferred0_1;
|
|
528
|
+
try {
|
|
529
|
+
deferred0_0 = arg0;
|
|
530
|
+
deferred0_1 = arg1;
|
|
531
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
532
|
+
} finally {
|
|
533
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
imports.wbg.__wbg_error_7bc7d576a6aaf855 = function(arg0) {
|
|
537
|
+
console.error(arg0);
|
|
538
|
+
};
|
|
539
|
+
imports.wbg.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) {
|
|
540
|
+
const ret = Reflect.get(arg0, arg1);
|
|
541
|
+
return ret;
|
|
542
|
+
}, arguments) };
|
|
543
|
+
imports.wbg.__wbg_init_8ab98dde6e4ecb43 = function() {
|
|
544
|
+
const ret = Parser.init();
|
|
545
|
+
return ret;
|
|
546
|
+
};
|
|
547
|
+
imports.wbg.__wbg_instanceof_Error_3443650560328fa9 = function(arg0) {
|
|
548
|
+
let result;
|
|
549
|
+
try {
|
|
550
|
+
result = arg0 instanceof Error;
|
|
551
|
+
} catch (_) {
|
|
552
|
+
result = false;
|
|
553
|
+
}
|
|
554
|
+
const ret = result;
|
|
555
|
+
return ret;
|
|
556
|
+
};
|
|
557
|
+
imports.wbg.__wbg_instanceof_Object_577e21051f7bcb79 = function(arg0) {
|
|
558
|
+
let result;
|
|
559
|
+
try {
|
|
560
|
+
result = arg0 instanceof Object;
|
|
561
|
+
} catch (_) {
|
|
562
|
+
result = false;
|
|
563
|
+
}
|
|
564
|
+
const ret = result;
|
|
565
|
+
return ret;
|
|
566
|
+
};
|
|
567
|
+
imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
|
|
568
|
+
const ret = arg0.length;
|
|
569
|
+
return ret;
|
|
570
|
+
};
|
|
571
|
+
imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
|
|
572
|
+
const ret = arg0.length;
|
|
573
|
+
return ret;
|
|
574
|
+
};
|
|
575
|
+
imports.wbg.__wbg_load_90a535c2f576cb1a = function(arg0) {
|
|
576
|
+
const ret = Language.load(arg0);
|
|
577
|
+
return ret;
|
|
578
|
+
};
|
|
579
|
+
imports.wbg.__wbg_message_0305fa7903f4b3d9 = function(arg0) {
|
|
580
|
+
const ret = arg0.message;
|
|
581
|
+
return ret;
|
|
582
|
+
};
|
|
583
|
+
imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
|
|
584
|
+
const ret = new Object();
|
|
585
|
+
return ret;
|
|
586
|
+
};
|
|
587
|
+
imports.wbg.__wbg_new_25f239778d6112b9 = function() {
|
|
588
|
+
const ret = new Array();
|
|
589
|
+
return ret;
|
|
590
|
+
};
|
|
591
|
+
imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
|
|
592
|
+
const ret = new Error();
|
|
593
|
+
return ret;
|
|
594
|
+
};
|
|
595
|
+
imports.wbg.__wbg_new_ff12d2b041fb48f1 = function(arg0, arg1) {
|
|
596
|
+
try {
|
|
597
|
+
var state0 = {a: arg0, b: arg1};
|
|
598
|
+
var cb0 = (arg0, arg1) => {
|
|
599
|
+
const a = state0.a;
|
|
600
|
+
state0.a = 0;
|
|
601
|
+
try {
|
|
602
|
+
return wasm_bindgen__convert__closures_____invoke__h17d4e94d5fe1e6e2(a, state0.b, arg0, arg1);
|
|
603
|
+
} finally {
|
|
604
|
+
state0.a = a;
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
const ret = new Promise(cb0);
|
|
608
|
+
return ret;
|
|
609
|
+
} finally {
|
|
610
|
+
state0.a = state0.b = 0;
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
imports.wbg.__wbg_new_from_slice_db0691b69e9d3891 = function(arg0, arg1) {
|
|
614
|
+
const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
|
|
615
|
+
return ret;
|
|
616
|
+
};
|
|
617
|
+
imports.wbg.__wbg_new_no_args_cb138f77cf6151ee = function(arg0, arg1) {
|
|
618
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
619
|
+
return ret;
|
|
620
|
+
};
|
|
621
|
+
imports.wbg.__wbg_new_with_length_202b3db94ba5fc86 = function(arg0) {
|
|
622
|
+
const ret = new Uint32Array(arg0 >>> 0);
|
|
623
|
+
return ret;
|
|
624
|
+
};
|
|
625
|
+
imports.wbg.__wbg_new_with_length_aa5eaf41d35235e5 = function(arg0) {
|
|
626
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
627
|
+
return ret;
|
|
628
|
+
};
|
|
629
|
+
imports.wbg.__wbg_parent_0c158a1af187043f = function(arg0) {
|
|
630
|
+
const ret = arg0.parent;
|
|
631
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
632
|
+
};
|
|
633
|
+
imports.wbg.__wbg_parse_ead60c7b277a53cf = function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
634
|
+
const ret = arg0.parse(arg1, arg2, arg3);
|
|
635
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
636
|
+
}, arguments) };
|
|
637
|
+
imports.wbg.__wbg_push_7d9be8f38fc13975 = function(arg0, arg1) {
|
|
638
|
+
const ret = arg0.push(arg1);
|
|
639
|
+
return ret;
|
|
640
|
+
};
|
|
641
|
+
imports.wbg.__wbg_query_39f1b36324c250e6 = function() { return handleError(function (arg0, arg1) {
|
|
642
|
+
const ret = arg0.query(arg1);
|
|
643
|
+
return ret;
|
|
644
|
+
}, arguments) };
|
|
645
|
+
imports.wbg.__wbg_queueMicrotask_9b549dfce8865860 = function(arg0) {
|
|
646
|
+
const ret = arg0.queueMicrotask;
|
|
647
|
+
return ret;
|
|
648
|
+
};
|
|
649
|
+
imports.wbg.__wbg_queueMicrotask_fca69f5bfad613a5 = function(arg0) {
|
|
650
|
+
queueMicrotask(arg0);
|
|
651
|
+
};
|
|
652
|
+
imports.wbg.__wbg_resolve_fd5bfbaa4ce36e1e = function(arg0) {
|
|
653
|
+
const ret = Promise.resolve(arg0);
|
|
654
|
+
return ret;
|
|
655
|
+
};
|
|
656
|
+
imports.wbg.__wbg_rootNode_b758185675662b53 = function(arg0) {
|
|
657
|
+
const ret = arg0.rootNode;
|
|
658
|
+
return ret;
|
|
659
|
+
};
|
|
660
|
+
imports.wbg.__wbg_row_d8b2314e5bc8ceac = function(arg0) {
|
|
661
|
+
const ret = arg0.row;
|
|
662
|
+
return ret;
|
|
663
|
+
};
|
|
664
|
+
imports.wbg.__wbg_setLanguage_738d2a8b70bfaf7e = function() { return handleError(function (arg0, arg1) {
|
|
665
|
+
arg0.setLanguage(arg1);
|
|
666
|
+
}, arguments) };
|
|
667
|
+
imports.wbg.__wbg_set_169e13b608078b7b = function(arg0, arg1, arg2) {
|
|
668
|
+
arg0.set(getArrayU8FromWasm0(arg1, arg2));
|
|
669
|
+
};
|
|
670
|
+
imports.wbg.__wbg_set_781438a03c0c3c81 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
671
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
672
|
+
return ret;
|
|
673
|
+
}, arguments) };
|
|
674
|
+
imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
|
|
675
|
+
const ret = arg1.stack;
|
|
676
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
677
|
+
const len1 = WASM_VECTOR_LEN;
|
|
678
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
679
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
680
|
+
};
|
|
681
|
+
imports.wbg.__wbg_startIndex_5fe710498cd325dc = function(arg0) {
|
|
682
|
+
const ret = arg0.startIndex;
|
|
683
|
+
return ret;
|
|
684
|
+
};
|
|
685
|
+
imports.wbg.__wbg_startPosition_47d9e145e6657457 = function(arg0) {
|
|
686
|
+
const ret = arg0.startPosition;
|
|
687
|
+
return ret;
|
|
688
|
+
};
|
|
689
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335 = function() {
|
|
690
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
691
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
692
|
+
};
|
|
693
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1 = function() {
|
|
694
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
695
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
696
|
+
};
|
|
697
|
+
imports.wbg.__wbg_static_accessor_SELF_08f5a74c69739274 = function() {
|
|
698
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
699
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
700
|
+
};
|
|
701
|
+
imports.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024 = function() {
|
|
702
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
703
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
704
|
+
};
|
|
705
|
+
imports.wbg.__wbg_then_429f7caf1026411d = function(arg0, arg1, arg2) {
|
|
706
|
+
const ret = arg0.then(arg1, arg2);
|
|
707
|
+
return ret;
|
|
708
|
+
};
|
|
709
|
+
imports.wbg.__wbg_then_4f95312d68691235 = function(arg0, arg1) {
|
|
710
|
+
const ret = arg0.then(arg1);
|
|
711
|
+
return ret;
|
|
712
|
+
};
|
|
713
|
+
imports.wbg.__wbg_type_33a08ad0de93bb8f = function(arg0) {
|
|
714
|
+
const ret = arg0.type;
|
|
715
|
+
return ret;
|
|
716
|
+
};
|
|
717
|
+
imports.wbg.__wbg_walk_6dedb17450b3edb6 = function(arg0) {
|
|
718
|
+
const ret = arg0.walk();
|
|
719
|
+
return ret;
|
|
720
|
+
};
|
|
721
|
+
imports.wbg.__wbg_warn_6e567d0d926ff881 = function(arg0) {
|
|
722
|
+
console.warn(arg0);
|
|
723
|
+
};
|
|
724
|
+
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
725
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
726
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
727
|
+
return ret;
|
|
728
|
+
};
|
|
729
|
+
imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
730
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
731
|
+
const ret = arg0;
|
|
732
|
+
return ret;
|
|
733
|
+
};
|
|
734
|
+
imports.wbg.__wbindgen_cast_fd0d4a93a13375b7 = function(arg0, arg1) {
|
|
735
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 1403, function: Function { arguments: [Externref], shim_idx: 1404, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
736
|
+
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hb94a2c2b7eee95bf, wasm_bindgen__convert__closures_____invoke__hc43d41e9321ebc8f);
|
|
737
|
+
return ret;
|
|
738
|
+
};
|
|
739
|
+
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
740
|
+
const table = wasm.__wbindgen_externrefs;
|
|
741
|
+
const offset = table.grow(4);
|
|
742
|
+
table.set(0, undefined);
|
|
743
|
+
table.set(offset + 0, undefined);
|
|
744
|
+
table.set(offset + 1, null);
|
|
745
|
+
table.set(offset + 2, true);
|
|
746
|
+
table.set(offset + 3, false);
|
|
747
|
+
};
|
|
748
|
+
|
|
749
|
+
return imports;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
function __wbg_finalize_init(instance, module) {
|
|
753
|
+
wasm = instance.exports;
|
|
754
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
755
|
+
cachedDataViewMemory0 = null;
|
|
756
|
+
cachedUint32ArrayMemory0 = null;
|
|
757
|
+
cachedUint8ArrayMemory0 = null;
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
wasm.__wbindgen_start();
|
|
761
|
+
return wasm;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
function initSync(module) {
|
|
765
|
+
if (wasm !== undefined) return wasm;
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
if (typeof module !== 'undefined') {
|
|
769
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
770
|
+
({module} = module)
|
|
771
|
+
} else {
|
|
772
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
const imports = __wbg_get_imports();
|
|
777
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
778
|
+
module = new WebAssembly.Module(module);
|
|
779
|
+
}
|
|
780
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
781
|
+
return __wbg_finalize_init(instance, module);
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
async function __wbg_init(module_or_path) {
|
|
785
|
+
if (wasm !== undefined) return wasm;
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
if (typeof module_or_path !== 'undefined') {
|
|
789
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
790
|
+
({module_or_path} = module_or_path)
|
|
791
|
+
} else {
|
|
792
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
if (typeof module_or_path === 'undefined') {
|
|
797
|
+
module_or_path = new URL('wat_lsp_rust_bg.wasm', import.meta.url);
|
|
798
|
+
}
|
|
799
|
+
const imports = __wbg_get_imports();
|
|
800
|
+
|
|
801
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
802
|
+
module_or_path = fetch(module_or_path);
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
806
|
+
|
|
807
|
+
return __wbg_finalize_init(instance, module);
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
export { initSync };
|
|
811
|
+
export default __wbg_init;
|