tombi-wasm-lsp 0.0.0-bootstrap.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/dist/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # tombi-wasm
2
+
3
+ WebAssembly bindings for Tombi's formatter, linter, and Language Server.
4
+
5
+ This crate is built with [`wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen)
6
+ and exposes JavaScript-compatible APIs for browser environments. The functionality
7
+ is selected with Cargo features:
8
+
9
+ - `lib` (default) provides the formatter and linter APIs.
10
+ - `lsp` provides the Language Server runtime and workspace file APIs.
11
+
12
+ The `lib` and `lsp` features are mutually exclusive build variants. Build this
13
+ crate with `wasm-pack` and select the required feature explicitly:
14
+
15
+ ```sh
16
+ wasm-pack build \
17
+ --target web \
18
+ --no-default-features \
19
+ --features lib
20
+ ```
21
+
22
+ To build the Language Server variant:
23
+
24
+ ```sh
25
+ wasm-pack build \
26
+ --target web \
27
+ --no-default-features \
28
+ --features lsp
29
+ ```
30
+
31
+ The Language Server communicates through standard LSP JSON-RPC messages. Browser
32
+ hosts can use the exported `serve` API with Web Streams and use
33
+ `set_workspace_entries` to preload files that are not opened through LSP.
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "tombi-wasm",
3
+ "type": "module",
4
+ "collaborators": [
5
+ "ya7010 <ya7010@outlook.com>"
6
+ ],
7
+ "description": "Tombi formatter, linter, and language server for WebAssembly",
8
+ "version": "0.0.0-dev",
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/tombi-toml/tombi"
13
+ },
14
+ "files": [
15
+ "tombi_lsp_wasm_bg.wasm",
16
+ "tombi_lsp_wasm.js",
17
+ "tombi_lsp_wasm.d.ts"
18
+ ],
19
+ "main": "tombi_lsp_wasm.js",
20
+ "types": "tombi_lsp_wasm.d.ts",
21
+ "sideEffects": [
22
+ "./snippets/*"
23
+ ]
24
+ }
@@ -0,0 +1,117 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Serve Tombi LSP over byte streams using the standard LSP header framing.
5
+ */
6
+ export function serve(config: ServerConfig): Promise<void>;
7
+ /**
8
+ * Update one file in the browser-backed virtual workspace.
9
+ */
10
+ export function set_workspace_file(uri: string, text: string): void;
11
+ /**
12
+ * Remove one file from the browser-backed virtual workspace.
13
+ */
14
+ export function remove_workspace_file(uri: string): void;
15
+ /**
16
+ * Replace the virtual workspace entries visible to the WASM language server.
17
+ */
18
+ export function set_workspace_entries(entries: any): void;
19
+ /**
20
+ * Replace the virtual workspace files visible to the WASM language server.
21
+ */
22
+ export function set_workspace_files(files: any): void;
23
+ export function start(): void;
24
+ /**
25
+ * The `ReadableStreamType` enum.
26
+ *
27
+ * *This API requires the following crate features to be activated: `ReadableStreamType`*
28
+ */
29
+ type ReadableStreamType = "bytes";
30
+ export class IntoUnderlyingByteSource {
31
+ private constructor();
32
+ free(): void;
33
+ pull(controller: ReadableByteStreamController): Promise<any>;
34
+ start(controller: ReadableByteStreamController): void;
35
+ cancel(): void;
36
+ readonly autoAllocateChunkSize: number;
37
+ readonly type: ReadableStreamType;
38
+ }
39
+ export class IntoUnderlyingSink {
40
+ private constructor();
41
+ free(): void;
42
+ abort(reason: any): Promise<any>;
43
+ close(): Promise<any>;
44
+ write(chunk: any): Promise<any>;
45
+ }
46
+ export class IntoUnderlyingSource {
47
+ private constructor();
48
+ free(): void;
49
+ pull(controller: ReadableStreamDefaultController): Promise<any>;
50
+ cancel(): void;
51
+ }
52
+ /**
53
+ * Browser streams used to exchange LSP messages with a Web Worker.
54
+ */
55
+ export class ServerConfig {
56
+ free(): void;
57
+ constructor(into_server: AsyncIterator<any>, from_server: WritableStream);
58
+ }
59
+
60
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
61
+
62
+ export interface InitOutput {
63
+ readonly memory: WebAssembly.Memory;
64
+ readonly __wbg_serverconfig_free: (a: number, b: number) => void;
65
+ readonly remove_workspace_file: (a: number, b: number) => [number, number];
66
+ readonly serve: (a: number) => any;
67
+ readonly set_workspace_entries: (a: any) => [number, number];
68
+ readonly set_workspace_file: (a: number, b: number, c: number, d: number) => [number, number];
69
+ readonly set_workspace_files: (a: any) => [number, number];
70
+ readonly serverconfig_new: (a: any, b: any) => number;
71
+ readonly start: () => void;
72
+ readonly __wbg_intounderlyingsink_free: (a: number, b: number) => void;
73
+ readonly intounderlyingsink_abort: (a: number, b: any) => any;
74
+ readonly intounderlyingsink_close: (a: number) => any;
75
+ readonly intounderlyingsink_write: (a: number, b: any) => any;
76
+ readonly __wbg_intounderlyingsource_free: (a: number, b: number) => void;
77
+ readonly intounderlyingsource_cancel: (a: number) => void;
78
+ readonly intounderlyingsource_pull: (a: number, b: any) => any;
79
+ readonly __wbg_intounderlyingbytesource_free: (a: number, b: number) => void;
80
+ readonly intounderlyingbytesource_autoAllocateChunkSize: (a: number) => number;
81
+ readonly intounderlyingbytesource_cancel: (a: number) => void;
82
+ readonly intounderlyingbytesource_pull: (a: number, b: any) => any;
83
+ readonly intounderlyingbytesource_start: (a: number, b: any) => void;
84
+ readonly intounderlyingbytesource_type: (a: number) => number;
85
+ readonly __wbindgen_exn_store: (a: number) => void;
86
+ readonly __externref_table_alloc: () => number;
87
+ readonly __wbindgen_export_2: WebAssembly.Table;
88
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
89
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
90
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
91
+ readonly __wbindgen_export_6: WebAssembly.Table;
92
+ readonly __externref_table_dealloc: (a: number) => void;
93
+ readonly closure5184_externref_shim: (a: number, b: number, c: any) => void;
94
+ readonly closure5208_externref_shim: (a: number, b: number, c: any, d: any) => void;
95
+ readonly __wbindgen_start: () => void;
96
+ }
97
+
98
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
99
+ /**
100
+ * Instantiates the given `module`, which can either be bytes or
101
+ * a precompiled `WebAssembly.Module`.
102
+ *
103
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
104
+ *
105
+ * @returns {InitOutput}
106
+ */
107
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
108
+
109
+ /**
110
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
111
+ * for everything else, calls `WebAssembly.instantiate` directly.
112
+ *
113
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
114
+ *
115
+ * @returns {Promise<InitOutput>}
116
+ */
117
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,997 @@
1
+ let wasm;
2
+
3
+ function addToExternrefTable0(obj) {
4
+ const idx = wasm.__externref_table_alloc();
5
+ wasm.__wbindgen_export_2.set(idx, obj);
6
+ return idx;
7
+ }
8
+
9
+ function handleError(f, args) {
10
+ try {
11
+ return f.apply(this, args);
12
+ } catch (e) {
13
+ const idx = addToExternrefTable0(e);
14
+ wasm.__wbindgen_exn_store(idx);
15
+ }
16
+ }
17
+
18
+ function isLikeNone(x) {
19
+ return x === undefined || x === null;
20
+ }
21
+
22
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
23
+
24
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
25
+
26
+ let cachedUint8ArrayMemory0 = null;
27
+
28
+ function getUint8ArrayMemory0() {
29
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
30
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
31
+ }
32
+ return cachedUint8ArrayMemory0;
33
+ }
34
+
35
+ function getStringFromWasm0(ptr, len) {
36
+ ptr = ptr >>> 0;
37
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
38
+ }
39
+
40
+ function getArrayU8FromWasm0(ptr, len) {
41
+ ptr = ptr >>> 0;
42
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
43
+ }
44
+
45
+ let WASM_VECTOR_LEN = 0;
46
+
47
+ const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
48
+
49
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
50
+ ? function (arg, view) {
51
+ return cachedTextEncoder.encodeInto(arg, view);
52
+ }
53
+ : function (arg, view) {
54
+ const buf = cachedTextEncoder.encode(arg);
55
+ view.set(buf);
56
+ return {
57
+ read: arg.length,
58
+ written: buf.length
59
+ };
60
+ });
61
+
62
+ function passStringToWasm0(arg, malloc, realloc) {
63
+
64
+ if (realloc === undefined) {
65
+ const buf = cachedTextEncoder.encode(arg);
66
+ const ptr = malloc(buf.length, 1) >>> 0;
67
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
68
+ WASM_VECTOR_LEN = buf.length;
69
+ return ptr;
70
+ }
71
+
72
+ let len = arg.length;
73
+ let ptr = malloc(len, 1) >>> 0;
74
+
75
+ const mem = getUint8ArrayMemory0();
76
+
77
+ let offset = 0;
78
+
79
+ for (; offset < len; offset++) {
80
+ const code = arg.charCodeAt(offset);
81
+ if (code > 0x7F) break;
82
+ mem[ptr + offset] = code;
83
+ }
84
+
85
+ if (offset !== len) {
86
+ if (offset !== 0) {
87
+ arg = arg.slice(offset);
88
+ }
89
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
90
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
91
+ const ret = encodeString(arg, view);
92
+
93
+ offset += ret.written;
94
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
95
+ }
96
+
97
+ WASM_VECTOR_LEN = offset;
98
+ return ptr;
99
+ }
100
+
101
+ let cachedDataViewMemory0 = null;
102
+
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
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
111
+ ? { register: () => {}, unregister: () => {} }
112
+ : new FinalizationRegistry(state => {
113
+ wasm.__wbindgen_export_6.get(state.dtor)(state.a, state.b)
114
+ });
115
+
116
+ function makeMutClosure(arg0, arg1, dtor, f) {
117
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
118
+ const real = (...args) => {
119
+ // First up with a closure we increment the internal reference
120
+ // count. This ensures that the Rust closure environment won't
121
+ // be deallocated while we're invoking it.
122
+ state.cnt++;
123
+ const a = state.a;
124
+ state.a = 0;
125
+ try {
126
+ return f(a, state.b, ...args);
127
+ } finally {
128
+ if (--state.cnt === 0) {
129
+ wasm.__wbindgen_export_6.get(state.dtor)(a, state.b);
130
+ CLOSURE_DTORS.unregister(state);
131
+ } else {
132
+ state.a = a;
133
+ }
134
+ }
135
+ };
136
+ real.original = state;
137
+ CLOSURE_DTORS.register(real, state, state);
138
+ return real;
139
+ }
140
+
141
+ function debugString(val) {
142
+ // primitive types
143
+ const type = typeof val;
144
+ if (type == 'number' || type == 'boolean' || val == null) {
145
+ return `${val}`;
146
+ }
147
+ if (type == 'string') {
148
+ return `"${val}"`;
149
+ }
150
+ if (type == 'symbol') {
151
+ const description = val.description;
152
+ if (description == null) {
153
+ return 'Symbol';
154
+ } else {
155
+ return `Symbol(${description})`;
156
+ }
157
+ }
158
+ if (type == 'function') {
159
+ const name = val.name;
160
+ if (typeof name == 'string' && name.length > 0) {
161
+ return `Function(${name})`;
162
+ } else {
163
+ return 'Function';
164
+ }
165
+ }
166
+ // objects
167
+ if (Array.isArray(val)) {
168
+ const length = val.length;
169
+ let debug = '[';
170
+ if (length > 0) {
171
+ debug += debugString(val[0]);
172
+ }
173
+ for(let i = 1; i < length; i++) {
174
+ debug += ', ' + debugString(val[i]);
175
+ }
176
+ debug += ']';
177
+ return debug;
178
+ }
179
+ // Test for built-in
180
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
181
+ let className;
182
+ if (builtInMatches && builtInMatches.length > 1) {
183
+ className = builtInMatches[1];
184
+ } else {
185
+ // Failed to match the standard '[object ClassName]'
186
+ return toString.call(val);
187
+ }
188
+ if (className == 'Object') {
189
+ // we're a user defined class or Object
190
+ // JSON.stringify avoids problems with cycles, and is generally much
191
+ // easier than looping through ownProperties of `val`.
192
+ try {
193
+ return 'Object(' + JSON.stringify(val) + ')';
194
+ } catch (_) {
195
+ return 'Object';
196
+ }
197
+ }
198
+ // errors
199
+ if (val instanceof Error) {
200
+ return `${val.name}: ${val.message}\n${val.stack}`;
201
+ }
202
+ // TODO we could test for more things here, like `Set`s and `Map`s.
203
+ return className;
204
+ }
205
+
206
+ function _assertClass(instance, klass) {
207
+ if (!(instance instanceof klass)) {
208
+ throw new Error(`expected instance of ${klass.name}`);
209
+ }
210
+ }
211
+ /**
212
+ * Serve Tombi LSP over byte streams using the standard LSP header framing.
213
+ * @param {ServerConfig} config
214
+ * @returns {Promise<void>}
215
+ */
216
+ export function serve(config) {
217
+ _assertClass(config, ServerConfig);
218
+ var ptr0 = config.__destroy_into_raw();
219
+ const ret = wasm.serve(ptr0);
220
+ return ret;
221
+ }
222
+
223
+ function takeFromExternrefTable0(idx) {
224
+ const value = wasm.__wbindgen_export_2.get(idx);
225
+ wasm.__externref_table_dealloc(idx);
226
+ return value;
227
+ }
228
+ /**
229
+ * Update one file in the browser-backed virtual workspace.
230
+ * @param {string} uri
231
+ * @param {string} text
232
+ */
233
+ export function set_workspace_file(uri, text) {
234
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
235
+ const len0 = WASM_VECTOR_LEN;
236
+ const ptr1 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
237
+ const len1 = WASM_VECTOR_LEN;
238
+ const ret = wasm.set_workspace_file(ptr0, len0, ptr1, len1);
239
+ if (ret[1]) {
240
+ throw takeFromExternrefTable0(ret[0]);
241
+ }
242
+ }
243
+
244
+ /**
245
+ * Remove one file from the browser-backed virtual workspace.
246
+ * @param {string} uri
247
+ */
248
+ export function remove_workspace_file(uri) {
249
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
250
+ const len0 = WASM_VECTOR_LEN;
251
+ const ret = wasm.remove_workspace_file(ptr0, len0);
252
+ if (ret[1]) {
253
+ throw takeFromExternrefTable0(ret[0]);
254
+ }
255
+ }
256
+
257
+ /**
258
+ * Replace the virtual workspace entries visible to the WASM language server.
259
+ * @param {any} entries
260
+ */
261
+ export function set_workspace_entries(entries) {
262
+ const ret = wasm.set_workspace_entries(entries);
263
+ if (ret[1]) {
264
+ throw takeFromExternrefTable0(ret[0]);
265
+ }
266
+ }
267
+
268
+ /**
269
+ * Replace the virtual workspace files visible to the WASM language server.
270
+ * @param {any} files
271
+ */
272
+ export function set_workspace_files(files) {
273
+ const ret = wasm.set_workspace_files(files);
274
+ if (ret[1]) {
275
+ throw takeFromExternrefTable0(ret[0]);
276
+ }
277
+ }
278
+
279
+ export function start() {
280
+ wasm.start();
281
+ }
282
+
283
+ function __wbg_adapter_40(arg0, arg1, arg2) {
284
+ wasm.closure5184_externref_shim(arg0, arg1, arg2);
285
+ }
286
+
287
+ function __wbg_adapter_168(arg0, arg1, arg2, arg3) {
288
+ wasm.closure5208_externref_shim(arg0, arg1, arg2, arg3);
289
+ }
290
+
291
+ const __wbindgen_enum_ReadableStreamType = ["bytes"];
292
+
293
+ const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined')
294
+ ? { register: () => {}, unregister: () => {} }
295
+ : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0, 1));
296
+
297
+ export class IntoUnderlyingByteSource {
298
+
299
+ __destroy_into_raw() {
300
+ const ptr = this.__wbg_ptr;
301
+ this.__wbg_ptr = 0;
302
+ IntoUnderlyingByteSourceFinalization.unregister(this);
303
+ return ptr;
304
+ }
305
+
306
+ free() {
307
+ const ptr = this.__destroy_into_raw();
308
+ wasm.__wbg_intounderlyingbytesource_free(ptr, 0);
309
+ }
310
+ /**
311
+ * @returns {number}
312
+ */
313
+ get autoAllocateChunkSize() {
314
+ const ret = wasm.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr);
315
+ return ret >>> 0;
316
+ }
317
+ /**
318
+ * @param {ReadableByteStreamController} controller
319
+ * @returns {Promise<any>}
320
+ */
321
+ pull(controller) {
322
+ const ret = wasm.intounderlyingbytesource_pull(this.__wbg_ptr, controller);
323
+ return ret;
324
+ }
325
+ /**
326
+ * @param {ReadableByteStreamController} controller
327
+ */
328
+ start(controller) {
329
+ wasm.intounderlyingbytesource_start(this.__wbg_ptr, controller);
330
+ }
331
+ /**
332
+ * @returns {ReadableStreamType}
333
+ */
334
+ get type() {
335
+ const ret = wasm.intounderlyingbytesource_type(this.__wbg_ptr);
336
+ return __wbindgen_enum_ReadableStreamType[ret];
337
+ }
338
+ cancel() {
339
+ const ptr = this.__destroy_into_raw();
340
+ wasm.intounderlyingbytesource_cancel(ptr);
341
+ }
342
+ }
343
+
344
+ const IntoUnderlyingSinkFinalization = (typeof FinalizationRegistry === 'undefined')
345
+ ? { register: () => {}, unregister: () => {} }
346
+ : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsink_free(ptr >>> 0, 1));
347
+
348
+ export class IntoUnderlyingSink {
349
+
350
+ __destroy_into_raw() {
351
+ const ptr = this.__wbg_ptr;
352
+ this.__wbg_ptr = 0;
353
+ IntoUnderlyingSinkFinalization.unregister(this);
354
+ return ptr;
355
+ }
356
+
357
+ free() {
358
+ const ptr = this.__destroy_into_raw();
359
+ wasm.__wbg_intounderlyingsink_free(ptr, 0);
360
+ }
361
+ /**
362
+ * @param {any} reason
363
+ * @returns {Promise<any>}
364
+ */
365
+ abort(reason) {
366
+ const ptr = this.__destroy_into_raw();
367
+ const ret = wasm.intounderlyingsink_abort(ptr, reason);
368
+ return ret;
369
+ }
370
+ /**
371
+ * @returns {Promise<any>}
372
+ */
373
+ close() {
374
+ const ptr = this.__destroy_into_raw();
375
+ const ret = wasm.intounderlyingsink_close(ptr);
376
+ return ret;
377
+ }
378
+ /**
379
+ * @param {any} chunk
380
+ * @returns {Promise<any>}
381
+ */
382
+ write(chunk) {
383
+ const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, chunk);
384
+ return ret;
385
+ }
386
+ }
387
+
388
+ const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined')
389
+ ? { register: () => {}, unregister: () => {} }
390
+ : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0, 1));
391
+
392
+ export class IntoUnderlyingSource {
393
+
394
+ __destroy_into_raw() {
395
+ const ptr = this.__wbg_ptr;
396
+ this.__wbg_ptr = 0;
397
+ IntoUnderlyingSourceFinalization.unregister(this);
398
+ return ptr;
399
+ }
400
+
401
+ free() {
402
+ const ptr = this.__destroy_into_raw();
403
+ wasm.__wbg_intounderlyingsource_free(ptr, 0);
404
+ }
405
+ /**
406
+ * @param {ReadableStreamDefaultController} controller
407
+ * @returns {Promise<any>}
408
+ */
409
+ pull(controller) {
410
+ const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, controller);
411
+ return ret;
412
+ }
413
+ cancel() {
414
+ const ptr = this.__destroy_into_raw();
415
+ wasm.intounderlyingsource_cancel(ptr);
416
+ }
417
+ }
418
+
419
+ const ServerConfigFinalization = (typeof FinalizationRegistry === 'undefined')
420
+ ? { register: () => {}, unregister: () => {} }
421
+ : new FinalizationRegistry(ptr => wasm.__wbg_serverconfig_free(ptr >>> 0, 1));
422
+ /**
423
+ * Browser streams used to exchange LSP messages with a Web Worker.
424
+ */
425
+ export class ServerConfig {
426
+
427
+ __destroy_into_raw() {
428
+ const ptr = this.__wbg_ptr;
429
+ this.__wbg_ptr = 0;
430
+ ServerConfigFinalization.unregister(this);
431
+ return ptr;
432
+ }
433
+
434
+ free() {
435
+ const ptr = this.__destroy_into_raw();
436
+ wasm.__wbg_serverconfig_free(ptr, 0);
437
+ }
438
+ /**
439
+ * @param {AsyncIterator<any>} into_server
440
+ * @param {WritableStream} from_server
441
+ */
442
+ constructor(into_server, from_server) {
443
+ const ret = wasm.serverconfig_new(into_server, from_server);
444
+ this.__wbg_ptr = ret >>> 0;
445
+ ServerConfigFinalization.register(this, this.__wbg_ptr, this);
446
+ return this;
447
+ }
448
+ }
449
+
450
+ async function __wbg_load(module, imports) {
451
+ if (typeof Response === 'function' && module instanceof Response) {
452
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
453
+ try {
454
+ return await WebAssembly.instantiateStreaming(module, imports);
455
+
456
+ } catch (e) {
457
+ if (module.headers.get('Content-Type') != 'application/wasm') {
458
+ 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);
459
+
460
+ } else {
461
+ throw e;
462
+ }
463
+ }
464
+ }
465
+
466
+ const bytes = await module.arrayBuffer();
467
+ return await WebAssembly.instantiate(bytes, imports);
468
+
469
+ } else {
470
+ const instance = await WebAssembly.instantiate(module, imports);
471
+
472
+ if (instance instanceof WebAssembly.Instance) {
473
+ return { instance, module };
474
+
475
+ } else {
476
+ return instance;
477
+ }
478
+ }
479
+ }
480
+
481
+ function __wbg_get_imports() {
482
+ const imports = {};
483
+ imports.wbg = {};
484
+ imports.wbg.__wbg_arrayBuffer_d1b44c4390db422f = function() { return handleError(function (arg0) {
485
+ const ret = arg0.arrayBuffer();
486
+ return ret;
487
+ }, arguments) };
488
+ imports.wbg.__wbg_buffer_09165b52af8c5237 = function(arg0) {
489
+ const ret = arg0.buffer;
490
+ return ret;
491
+ };
492
+ imports.wbg.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
493
+ const ret = arg0.buffer;
494
+ return ret;
495
+ };
496
+ imports.wbg.__wbg_byobRequest_77d9adf63337edfb = function(arg0) {
497
+ const ret = arg0.byobRequest;
498
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
499
+ };
500
+ imports.wbg.__wbg_byteLength_e674b853d9c77e1d = function(arg0) {
501
+ const ret = arg0.byteLength;
502
+ return ret;
503
+ };
504
+ imports.wbg.__wbg_byteOffset_fd862df290ef848d = function(arg0) {
505
+ const ret = arg0.byteOffset;
506
+ return ret;
507
+ };
508
+ imports.wbg.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {
509
+ const ret = arg0.call(arg1);
510
+ return ret;
511
+ }, arguments) };
512
+ imports.wbg.__wbg_call_7cccdd69e0791ae2 = function() { return handleError(function (arg0, arg1, arg2) {
513
+ const ret = arg0.call(arg1, arg2);
514
+ return ret;
515
+ }, arguments) };
516
+ imports.wbg.__wbg_close_304cc1fef3466669 = function() { return handleError(function (arg0) {
517
+ arg0.close();
518
+ }, arguments) };
519
+ imports.wbg.__wbg_close_5ce03e29be453811 = function() { return handleError(function (arg0) {
520
+ arg0.close();
521
+ }, arguments) };
522
+ imports.wbg.__wbg_close_fa50b16598acbea1 = function(arg0) {
523
+ const ret = arg0.close();
524
+ return ret;
525
+ };
526
+ imports.wbg.__wbg_done_769e5ede4b31c67b = function(arg0) {
527
+ const ret = arg0.done;
528
+ return ret;
529
+ };
530
+ imports.wbg.__wbg_enqueue_bb16ba72f537dc9e = function() { return handleError(function (arg0, arg1) {
531
+ arg0.enqueue(arg1);
532
+ }, arguments) };
533
+ imports.wbg.__wbg_entries_3265d4158b33e5dc = function(arg0) {
534
+ const ret = Object.entries(arg0);
535
+ return ret;
536
+ };
537
+ imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
538
+ let deferred0_0;
539
+ let deferred0_1;
540
+ try {
541
+ deferred0_0 = arg0;
542
+ deferred0_1 = arg1;
543
+ console.error(getStringFromWasm0(arg0, arg1));
544
+ } finally {
545
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
546
+ }
547
+ };
548
+ imports.wbg.__wbg_fetch_a9bc66c159c18e19 = function(arg0) {
549
+ const ret = fetch(arg0);
550
+ return ret;
551
+ };
552
+ imports.wbg.__wbg_getRandomValues_3c9c0d586e575a16 = function() { return handleError(function (arg0, arg1) {
553
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
554
+ }, arguments) };
555
+ imports.wbg.__wbg_getTime_46267b1c24877e30 = function(arg0) {
556
+ const ret = arg0.getTime();
557
+ return ret;
558
+ };
559
+ imports.wbg.__wbg_getTimezoneOffset_6b5752021c499c47 = function(arg0) {
560
+ const ret = arg0.getTimezoneOffset();
561
+ return ret;
562
+ };
563
+ imports.wbg.__wbg_getWriter_6ce182d0adc3f96b = function() { return handleError(function (arg0) {
564
+ const ret = arg0.getWriter();
565
+ return ret;
566
+ }, arguments) };
567
+ imports.wbg.__wbg_get_67b2ba62fc30de12 = function() { return handleError(function (arg0, arg1) {
568
+ const ret = Reflect.get(arg0, arg1);
569
+ return ret;
570
+ }, arguments) };
571
+ imports.wbg.__wbg_get_b9b93047fe3cf45b = function(arg0, arg1) {
572
+ const ret = arg0[arg1 >>> 0];
573
+ return ret;
574
+ };
575
+ imports.wbg.__wbg_getwithrefkey_1dc361bd10053bfe = function(arg0, arg1) {
576
+ const ret = arg0[arg1];
577
+ return ret;
578
+ };
579
+ imports.wbg.__wbg_instanceof_ArrayBuffer_e14585432e3737fc = function(arg0) {
580
+ let result;
581
+ try {
582
+ result = arg0 instanceof ArrayBuffer;
583
+ } catch (_) {
584
+ result = false;
585
+ }
586
+ const ret = result;
587
+ return ret;
588
+ };
589
+ imports.wbg.__wbg_instanceof_Error_4d54113b22d20306 = function(arg0) {
590
+ let result;
591
+ try {
592
+ result = arg0 instanceof Error;
593
+ } catch (_) {
594
+ result = false;
595
+ }
596
+ const ret = result;
597
+ return ret;
598
+ };
599
+ imports.wbg.__wbg_instanceof_Response_f2cc20d9f7dfd644 = function(arg0) {
600
+ let result;
601
+ try {
602
+ result = arg0 instanceof Response;
603
+ } catch (_) {
604
+ result = false;
605
+ }
606
+ const ret = result;
607
+ return ret;
608
+ };
609
+ imports.wbg.__wbg_instanceof_Uint8Array_17156bcf118086a9 = function(arg0) {
610
+ let result;
611
+ try {
612
+ result = arg0 instanceof Uint8Array;
613
+ } catch (_) {
614
+ result = false;
615
+ }
616
+ const ret = result;
617
+ return ret;
618
+ };
619
+ imports.wbg.__wbg_isArray_a1eab7e0d067391b = function(arg0) {
620
+ const ret = Array.isArray(arg0);
621
+ return ret;
622
+ };
623
+ imports.wbg.__wbg_iterator_9a24c88df860dc65 = function() {
624
+ const ret = Symbol.iterator;
625
+ return ret;
626
+ };
627
+ imports.wbg.__wbg_length_a446193dc22c12f8 = function(arg0) {
628
+ const ret = arg0.length;
629
+ return ret;
630
+ };
631
+ imports.wbg.__wbg_length_e2d2a49132c1b256 = function(arg0) {
632
+ const ret = arg0.length;
633
+ return ret;
634
+ };
635
+ imports.wbg.__wbg_message_97a2af9b89d693a3 = function(arg0) {
636
+ const ret = arg0.message;
637
+ return ret;
638
+ };
639
+ imports.wbg.__wbg_name_0b327d569f00ebee = function(arg0) {
640
+ const ret = arg0.name;
641
+ return ret;
642
+ };
643
+ imports.wbg.__wbg_new0_f788a2397c7ca929 = function() {
644
+ const ret = new Date();
645
+ return ret;
646
+ };
647
+ imports.wbg.__wbg_new_018dcc2d6c8c2f6a = function() { return handleError(function () {
648
+ const ret = new Headers();
649
+ return ret;
650
+ }, arguments) };
651
+ imports.wbg.__wbg_new_23a2665fac83c611 = function(arg0, arg1) {
652
+ try {
653
+ var state0 = {a: arg0, b: arg1};
654
+ var cb0 = (arg0, arg1) => {
655
+ const a = state0.a;
656
+ state0.a = 0;
657
+ try {
658
+ return __wbg_adapter_168(a, state0.b, arg0, arg1);
659
+ } finally {
660
+ state0.a = a;
661
+ }
662
+ };
663
+ const ret = new Promise(cb0);
664
+ return ret;
665
+ } finally {
666
+ state0.a = state0.b = 0;
667
+ }
668
+ };
669
+ imports.wbg.__wbg_new_31a97dac4f10fab7 = function(arg0) {
670
+ const ret = new Date(arg0);
671
+ return ret;
672
+ };
673
+ imports.wbg.__wbg_new_405e22f390576ce2 = function() {
674
+ const ret = new Object();
675
+ return ret;
676
+ };
677
+ imports.wbg.__wbg_new_80bf4ee74f41ff92 = function() { return handleError(function () {
678
+ const ret = new URLSearchParams();
679
+ return ret;
680
+ }, arguments) };
681
+ imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
682
+ const ret = new Error();
683
+ return ret;
684
+ };
685
+ imports.wbg.__wbg_new_9ffbe0a71eff35e3 = function() { return handleError(function (arg0, arg1) {
686
+ const ret = new URL(getStringFromWasm0(arg0, arg1));
687
+ return ret;
688
+ }, arguments) };
689
+ imports.wbg.__wbg_new_a12002a7f91c75be = function(arg0) {
690
+ const ret = new Uint8Array(arg0);
691
+ return ret;
692
+ };
693
+ imports.wbg.__wbg_new_c68d7209be747379 = function(arg0, arg1) {
694
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
695
+ return ret;
696
+ };
697
+ imports.wbg.__wbg_newnoargs_105ed471475aaf50 = function(arg0, arg1) {
698
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
699
+ return ret;
700
+ };
701
+ imports.wbg.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function(arg0, arg1, arg2) {
702
+ const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
703
+ return ret;
704
+ };
705
+ imports.wbg.__wbg_newwithstr_78e86e03c4ae814e = function() { return handleError(function (arg0, arg1) {
706
+ const ret = new Request(getStringFromWasm0(arg0, arg1));
707
+ return ret;
708
+ }, arguments) };
709
+ imports.wbg.__wbg_newwithstrandinit_06c535e0a867c635 = function() { return handleError(function (arg0, arg1, arg2) {
710
+ const ret = new Request(getStringFromWasm0(arg0, arg1), arg2);
711
+ return ret;
712
+ }, arguments) };
713
+ imports.wbg.__wbg_newwithyearmonthdayhrminsec_72c204d952ef4426 = function(arg0, arg1, arg2, arg3, arg4, arg5) {
714
+ const ret = new Date(arg0 >>> 0, arg1, arg2, arg3, arg4, arg5);
715
+ return ret;
716
+ };
717
+ imports.wbg.__wbg_next_25feadfc0913fea9 = function(arg0) {
718
+ const ret = arg0.next;
719
+ return ret;
720
+ };
721
+ imports.wbg.__wbg_next_6574e1a8a62d1055 = function() { return handleError(function (arg0) {
722
+ const ret = arg0.next();
723
+ return ret;
724
+ }, arguments) };
725
+ imports.wbg.__wbg_next_c3ab0d59847b3b5c = function() { return handleError(function (arg0) {
726
+ const ret = arg0.next();
727
+ return ret;
728
+ }, arguments) };
729
+ imports.wbg.__wbg_queueMicrotask_97d92b4fcc8a61c5 = function(arg0) {
730
+ queueMicrotask(arg0);
731
+ };
732
+ imports.wbg.__wbg_queueMicrotask_d3219def82552485 = function(arg0) {
733
+ const ret = arg0.queueMicrotask;
734
+ return ret;
735
+ };
736
+ imports.wbg.__wbg_ready_480b0e63c18378c7 = function(arg0) {
737
+ const ret = arg0.ready;
738
+ return ret;
739
+ };
740
+ imports.wbg.__wbg_releaseLock_a389e6ea62ce0f4d = function(arg0) {
741
+ arg0.releaseLock();
742
+ };
743
+ imports.wbg.__wbg_resolve_4851785c9c5f573d = function(arg0) {
744
+ const ret = Promise.resolve(arg0);
745
+ return ret;
746
+ };
747
+ imports.wbg.__wbg_respond_1f279fa9f8edcb1c = function() { return handleError(function (arg0, arg1) {
748
+ arg0.respond(arg1 >>> 0);
749
+ }, arguments) };
750
+ imports.wbg.__wbg_search_e0e79cfe010c5c23 = function(arg0, arg1) {
751
+ const ret = arg1.search;
752
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
753
+ const len1 = WASM_VECTOR_LEN;
754
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
755
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
756
+ };
757
+ imports.wbg.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
758
+ arg0.set(arg1, arg2 >>> 0);
759
+ };
760
+ imports.wbg.__wbg_setheaders_834c0bdb6a8949ad = function(arg0, arg1) {
761
+ arg0.headers = arg1;
762
+ };
763
+ imports.wbg.__wbg_setmethod_3c5280fe5d890842 = function(arg0, arg1, arg2) {
764
+ arg0.method = getStringFromWasm0(arg1, arg2);
765
+ };
766
+ imports.wbg.__wbg_setsearch_609451e9e712f3c6 = function(arg0, arg1, arg2) {
767
+ arg0.search = getStringFromWasm0(arg1, arg2);
768
+ };
769
+ imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
770
+ const ret = arg1.stack;
771
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
772
+ const len1 = WASM_VECTOR_LEN;
773
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
774
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
775
+ };
776
+ imports.wbg.__wbg_static_accessor_GLOBAL_88a902d13a557d07 = function() {
777
+ const ret = typeof global === 'undefined' ? null : global;
778
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
779
+ };
780
+ imports.wbg.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0 = function() {
781
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
782
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
783
+ };
784
+ imports.wbg.__wbg_static_accessor_SELF_37c5d418e4bf5819 = function() {
785
+ const ret = typeof self === 'undefined' ? null : self;
786
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
787
+ };
788
+ imports.wbg.__wbg_static_accessor_WINDOW_5de37043a91a9c40 = function() {
789
+ const ret = typeof window === 'undefined' ? null : window;
790
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
791
+ };
792
+ imports.wbg.__wbg_status_f6360336ca686bf0 = function(arg0) {
793
+ const ret = arg0.status;
794
+ return ret;
795
+ };
796
+ imports.wbg.__wbg_then_44b73946d2fb3e7d = function(arg0, arg1) {
797
+ const ret = arg0.then(arg1);
798
+ return ret;
799
+ };
800
+ imports.wbg.__wbg_then_48b406749878a531 = function(arg0, arg1, arg2) {
801
+ const ret = arg0.then(arg1, arg2);
802
+ return ret;
803
+ };
804
+ imports.wbg.__wbg_toString_5285597960676b7b = function(arg0) {
805
+ const ret = arg0.toString();
806
+ return ret;
807
+ };
808
+ imports.wbg.__wbg_toString_c813bbd34d063839 = function(arg0) {
809
+ const ret = arg0.toString();
810
+ return ret;
811
+ };
812
+ imports.wbg.__wbg_url_8f9653b899456042 = function(arg0, arg1) {
813
+ const ret = arg1.url;
814
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
815
+ const len1 = WASM_VECTOR_LEN;
816
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
817
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
818
+ };
819
+ imports.wbg.__wbg_value_cd1ffa7b1ab794f1 = function(arg0) {
820
+ const ret = arg0.value;
821
+ return ret;
822
+ };
823
+ imports.wbg.__wbg_view_fd8a56e8983f448d = function(arg0) {
824
+ const ret = arg0.view;
825
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
826
+ };
827
+ imports.wbg.__wbg_write_311434e30ee214e5 = function(arg0, arg1) {
828
+ const ret = arg0.write(arg1);
829
+ return ret;
830
+ };
831
+ imports.wbg.__wbindgen_boolean_get = function(arg0) {
832
+ const v = arg0;
833
+ const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
834
+ return ret;
835
+ };
836
+ imports.wbg.__wbindgen_cb_drop = function(arg0) {
837
+ const obj = arg0.original;
838
+ if (obj.cnt-- == 1) {
839
+ obj.a = 0;
840
+ return true;
841
+ }
842
+ const ret = false;
843
+ return ret;
844
+ };
845
+ imports.wbg.__wbindgen_closure_wrapper15781 = function(arg0, arg1, arg2) {
846
+ const ret = makeMutClosure(arg0, arg1, 5185, __wbg_adapter_40);
847
+ return ret;
848
+ };
849
+ imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
850
+ const ret = debugString(arg1);
851
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
852
+ const len1 = WASM_VECTOR_LEN;
853
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
854
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
855
+ };
856
+ imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
857
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
858
+ return ret;
859
+ };
860
+ imports.wbg.__wbindgen_in = function(arg0, arg1) {
861
+ const ret = arg0 in arg1;
862
+ return ret;
863
+ };
864
+ imports.wbg.__wbindgen_init_externref_table = function() {
865
+ const table = wasm.__wbindgen_export_2;
866
+ const offset = table.grow(4);
867
+ table.set(0, undefined);
868
+ table.set(offset + 0, undefined);
869
+ table.set(offset + 1, null);
870
+ table.set(offset + 2, true);
871
+ table.set(offset + 3, false);
872
+ ;
873
+ };
874
+ imports.wbg.__wbindgen_is_function = function(arg0) {
875
+ const ret = typeof(arg0) === 'function';
876
+ return ret;
877
+ };
878
+ imports.wbg.__wbindgen_is_object = function(arg0) {
879
+ const val = arg0;
880
+ const ret = typeof(val) === 'object' && val !== null;
881
+ return ret;
882
+ };
883
+ imports.wbg.__wbindgen_is_string = function(arg0) {
884
+ const ret = typeof(arg0) === 'string';
885
+ return ret;
886
+ };
887
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
888
+ const ret = arg0 === undefined;
889
+ return ret;
890
+ };
891
+ imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
892
+ const ret = arg0 == arg1;
893
+ return ret;
894
+ };
895
+ imports.wbg.__wbindgen_memory = function() {
896
+ const ret = wasm.memory;
897
+ return ret;
898
+ };
899
+ imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
900
+ const obj = arg1;
901
+ const ret = typeof(obj) === 'number' ? obj : undefined;
902
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
903
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
904
+ };
905
+ imports.wbg.__wbindgen_number_new = function(arg0) {
906
+ const ret = arg0;
907
+ return ret;
908
+ };
909
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
910
+ const obj = arg1;
911
+ const ret = typeof(obj) === 'string' ? obj : undefined;
912
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
913
+ var len1 = WASM_VECTOR_LEN;
914
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
915
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
916
+ };
917
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
918
+ const ret = getStringFromWasm0(arg0, arg1);
919
+ return ret;
920
+ };
921
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
922
+ throw new Error(getStringFromWasm0(arg0, arg1));
923
+ };
924
+
925
+ return imports;
926
+ }
927
+
928
+ function __wbg_init_memory(imports, memory) {
929
+
930
+ }
931
+
932
+ function __wbg_finalize_init(instance, module) {
933
+ wasm = instance.exports;
934
+ __wbg_init.__wbindgen_wasm_module = module;
935
+ cachedDataViewMemory0 = null;
936
+ cachedUint8ArrayMemory0 = null;
937
+
938
+
939
+ wasm.__wbindgen_start();
940
+ return wasm;
941
+ }
942
+
943
+ function initSync(module) {
944
+ if (wasm !== undefined) return wasm;
945
+
946
+
947
+ if (typeof module !== 'undefined') {
948
+ if (Object.getPrototypeOf(module) === Object.prototype) {
949
+ ({module} = module)
950
+ } else {
951
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
952
+ }
953
+ }
954
+
955
+ const imports = __wbg_get_imports();
956
+
957
+ __wbg_init_memory(imports);
958
+
959
+ if (!(module instanceof WebAssembly.Module)) {
960
+ module = new WebAssembly.Module(module);
961
+ }
962
+
963
+ const instance = new WebAssembly.Instance(module, imports);
964
+
965
+ return __wbg_finalize_init(instance, module);
966
+ }
967
+
968
+ async function __wbg_init(module_or_path) {
969
+ if (wasm !== undefined) return wasm;
970
+
971
+
972
+ if (typeof module_or_path !== 'undefined') {
973
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
974
+ ({module_or_path} = module_or_path)
975
+ } else {
976
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
977
+ }
978
+ }
979
+
980
+ if (typeof module_or_path === 'undefined') {
981
+ module_or_path = new URL('tombi_lsp_wasm_bg.wasm', import.meta.url);
982
+ }
983
+ const imports = __wbg_get_imports();
984
+
985
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
986
+ module_or_path = fetch(module_or_path);
987
+ }
988
+
989
+ __wbg_init_memory(imports);
990
+
991
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
992
+
993
+ return __wbg_finalize_init(instance, module);
994
+ }
995
+
996
+ export { initSync };
997
+ export default __wbg_init;
Binary file
@@ -0,0 +1,35 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_serverconfig_free: (a: number, b: number) => void;
5
+ export const remove_workspace_file: (a: number, b: number) => [number, number];
6
+ export const serve: (a: number) => any;
7
+ export const set_workspace_entries: (a: any) => [number, number];
8
+ export const set_workspace_file: (a: number, b: number, c: number, d: number) => [number, number];
9
+ export const set_workspace_files: (a: any) => [number, number];
10
+ export const serverconfig_new: (a: any, b: any) => number;
11
+ export const start: () => void;
12
+ export const __wbg_intounderlyingsink_free: (a: number, b: number) => void;
13
+ export const intounderlyingsink_abort: (a: number, b: any) => any;
14
+ export const intounderlyingsink_close: (a: number) => any;
15
+ export const intounderlyingsink_write: (a: number, b: any) => any;
16
+ export const __wbg_intounderlyingsource_free: (a: number, b: number) => void;
17
+ export const intounderlyingsource_cancel: (a: number) => void;
18
+ export const intounderlyingsource_pull: (a: number, b: any) => any;
19
+ export const __wbg_intounderlyingbytesource_free: (a: number, b: number) => void;
20
+ export const intounderlyingbytesource_autoAllocateChunkSize: (a: number) => number;
21
+ export const intounderlyingbytesource_cancel: (a: number) => void;
22
+ export const intounderlyingbytesource_pull: (a: number, b: any) => any;
23
+ export const intounderlyingbytesource_start: (a: number, b: any) => void;
24
+ export const intounderlyingbytesource_type: (a: number) => number;
25
+ export const __wbindgen_exn_store: (a: number) => void;
26
+ export const __externref_table_alloc: () => number;
27
+ export const __wbindgen_export_2: WebAssembly.Table;
28
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
29
+ export const __wbindgen_malloc: (a: number, b: number) => number;
30
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
31
+ export const __wbindgen_export_6: WebAssembly.Table;
32
+ export const __externref_table_dealloc: (a: number) => void;
33
+ export const closure5184_externref_shim: (a: number, b: number, c: any) => void;
34
+ export const closure5208_externref_shim: (a: number, b: number, c: any, d: any) => void;
35
+ export const __wbindgen_start: () => void;
package/dist/worker.js ADDED
@@ -0,0 +1,119 @@
1
+ import init, {
2
+ ServerConfig,
3
+ remove_workspace_file,
4
+ serve,
5
+ set_workspace_file,
6
+ } from "./tombi_lsp_wasm.js";
7
+
8
+ class AsyncByteQueue {
9
+ #closed = false;
10
+ #items = [];
11
+ #waiters = [];
12
+
13
+ push(item) {
14
+ const waiter = this.#waiters.shift();
15
+ if (waiter) waiter({ done: false, value: item });
16
+ else this.#items.push(item);
17
+ }
18
+
19
+ close() {
20
+ this.#closed = true;
21
+ for (const waiter of this.#waiters.splice(0)) {
22
+ waiter({ done: true, value: undefined });
23
+ }
24
+ }
25
+
26
+ next() {
27
+ const item = this.#items.shift();
28
+ if (item) return Promise.resolve({ done: false, value: item });
29
+ if (this.#closed) return Promise.resolve({ done: true, value: undefined });
30
+ return new Promise((resolve) => this.#waiters.push(resolve));
31
+ }
32
+
33
+ [Symbol.asyncIterator]() {
34
+ return this;
35
+ }
36
+ }
37
+
38
+ const encoder = new TextEncoder();
39
+ const decoder = new TextDecoder();
40
+ const input = new AsyncByteQueue();
41
+ let outputBuffer = new Uint8Array();
42
+ let ready = false;
43
+ const pendingMessages = [];
44
+
45
+ function encode(message) {
46
+ const body = JSON.stringify(message);
47
+ const contentLength = encoder.encode(body).byteLength;
48
+ return encoder.encode(`Content-Length: ${contentLength}\r\n\r\n${body}`);
49
+ }
50
+
51
+ function emitMessages(chunk) {
52
+ const next = new Uint8Array(outputBuffer.byteLength + chunk.byteLength);
53
+ next.set(outputBuffer);
54
+ next.set(chunk, outputBuffer.byteLength);
55
+ outputBuffer = next;
56
+
57
+ while (true) {
58
+ const separator = decoder.decode(outputBuffer).indexOf("\r\n\r\n");
59
+ if (separator < 0) return;
60
+
61
+ const header = decoder.decode(outputBuffer.slice(0, separator));
62
+ const length = Number.parseInt(header.match(/Content-Length:\s*(\d+)/i)?.[1] ?? "", 10);
63
+ const bodyStart = separator + 4;
64
+ if (!Number.isFinite(length) || outputBuffer.byteLength < bodyStart + length) return;
65
+
66
+ const body = outputBuffer.slice(bodyStart, bodyStart + length);
67
+ self.postMessage(JSON.parse(decoder.decode(body)));
68
+ outputBuffer = outputBuffer.slice(bodyStart + length);
69
+ }
70
+ }
71
+
72
+ function handleMessage(message) {
73
+ if (message.method === "textDocument/didOpen") {
74
+ const document = message.params?.textDocument;
75
+ if (document?.uri?.startsWith("file:") && typeof document.text === "string") {
76
+ set_workspace_file(document.uri, document.text);
77
+ }
78
+ } else if (message.method === "textDocument/didChange") {
79
+ const uri = message.params?.textDocument?.uri;
80
+ const change = message.params?.contentChanges?.findLast(
81
+ (candidate) => candidate.range === undefined && typeof candidate.text === "string",
82
+ );
83
+ if (uri?.startsWith("file:") && change) {
84
+ set_workspace_file(uri, change.text);
85
+ }
86
+ } else if (message.method === "workspace/didChangeWatchedFiles") {
87
+ for (const change of message.params?.changes ?? []) {
88
+ if (change.type === 3 && change.uri?.startsWith("file:")) {
89
+ remove_workspace_file(change.uri);
90
+ }
91
+ }
92
+ }
93
+ input.push(encode(message));
94
+ }
95
+
96
+ self.addEventListener("message", (event) => {
97
+ if (ready) handleMessage(event.data);
98
+ else pendingMessages.push(event.data);
99
+ });
100
+
101
+ try {
102
+ await init();
103
+ const output = new WritableStream({ write: emitMessages });
104
+ void serve(new ServerConfig(input, output)).catch((error) => {
105
+ self.postMessage({
106
+ type: "error",
107
+ message: String(error),
108
+ });
109
+ });
110
+
111
+ ready = true;
112
+ for (const message of pendingMessages.splice(0)) handleMessage(message);
113
+ self.postMessage({ type: "ready" });
114
+ } catch (error) {
115
+ self.postMessage({
116
+ type: "error",
117
+ message: String(error),
118
+ });
119
+ }
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "tombi-wasm-lsp",
3
+ "version": "0.0.0-bootstrap.0",
4
+ "description": "Tombi Language Server for WebAssembly",
5
+ "type": "module",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/tombi_lsp_wasm.d.ts",
12
+ "import": "./dist/tombi_lsp_wasm.js"
13
+ },
14
+ "./worker": "./dist/worker.js"
15
+ },
16
+ "scripts": {
17
+ "build": "rm -rf dist && cd ../../../rust/tombi-wasm && wasm-pack build --locked --target web --out-dir ../../typescript/@tombi-toml/wasm-lsp/dist --out-name tombi_lsp_wasm -- --no-default-features --features lsp && rm ../../typescript/@tombi-toml/wasm-lsp/dist/.gitignore && cp src/lsp-worker.js ../../typescript/@tombi-toml/wasm-lsp/dist/worker.js",
18
+ "build:docs": "rm -f ../../../docs/public/wasm/tombi_lsp_wasm.d.ts ../../../docs/public/wasm/tombi_lsp_wasm.js ../../../docs/public/wasm/tombi_lsp_wasm_bg.wasm ../../../docs/public/wasm/tombi_lsp_wasm_bg.wasm.d.ts && cd ../../../rust/tombi-wasm && wasm-pack build --locked --target web --out-dir ../../docs/public/wasm --out-name tombi_lsp_wasm -- --no-default-features --features lsp && cp src/lsp-worker.js ../../docs/public/wasm/worker.js",
19
+ "test": "pnpm run build && node ../../../rust/tombi-wasm/tests/lsp-smoke.mjs",
20
+ "clean": "rm -rf dist"
21
+ },
22
+ "devDependencies": {
23
+ "wasm-pack": "^0.15.0"
24
+ }
25
+ }