@vedivad/typst-web-service 0.15.3 → 0.17.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.
@@ -1,1045 +0,0 @@
1
- // src/analyzer-worker.ts
2
- import * as Comlink from "comlink";
3
-
4
- // ../../node_modules/.bun/tinymist-web@https+++github.com+Myriad-Dreamin+tinymist+releases+download+v0.14.10+tinymist-web.tar.gz/node_modules/tinymist-web/pkg/tinymist.js
5
- var wasm;
6
- function addToExternrefTable0(obj) {
7
- const idx = wasm.__externref_table_alloc();
8
- wasm.__wbindgen_externrefs.set(idx, obj);
9
- return idx;
10
- }
11
- var CLOSURE_DTORS = typeof FinalizationRegistry === "undefined" ? { register: () => {
12
- }, unregister: () => {
13
- } } : new FinalizationRegistry((state) => state.dtor(state.a, state.b));
14
- function debugString(val) {
15
- const type = typeof val;
16
- if (type == "number" || type == "boolean" || val == null) {
17
- return `${val}`;
18
- }
19
- if (type == "string") {
20
- return `"${val}"`;
21
- }
22
- if (type == "symbol") {
23
- const description = val.description;
24
- if (description == null) {
25
- return "Symbol";
26
- } else {
27
- return `Symbol(${description})`;
28
- }
29
- }
30
- if (type == "function") {
31
- const name = val.name;
32
- if (typeof name == "string" && name.length > 0) {
33
- return `Function(${name})`;
34
- } else {
35
- return "Function";
36
- }
37
- }
38
- if (Array.isArray(val)) {
39
- const length = val.length;
40
- let debug = "[";
41
- if (length > 0) {
42
- debug += debugString(val[0]);
43
- }
44
- for (let i = 1; i < length; i++) {
45
- debug += ", " + debugString(val[i]);
46
- }
47
- debug += "]";
48
- return debug;
49
- }
50
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
51
- let className;
52
- if (builtInMatches && builtInMatches.length > 1) {
53
- className = builtInMatches[1];
54
- } else {
55
- return toString.call(val);
56
- }
57
- if (className == "Object") {
58
- try {
59
- return "Object(" + JSON.stringify(val) + ")";
60
- } catch (_) {
61
- return "Object";
62
- }
63
- }
64
- if (val instanceof Error) {
65
- return `${val.name}: ${val.message}
66
- ${val.stack}`;
67
- }
68
- return className;
69
- }
70
- function getArrayU8FromWasm0(ptr, len) {
71
- ptr = ptr >>> 0;
72
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
73
- }
74
- var cachedDataViewMemory0 = null;
75
- function getDataViewMemory0() {
76
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
77
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
78
- }
79
- return cachedDataViewMemory0;
80
- }
81
- function getStringFromWasm0(ptr, len) {
82
- ptr = ptr >>> 0;
83
- return decodeText(ptr, len);
84
- }
85
- var cachedUint8ArrayMemory0 = null;
86
- function getUint8ArrayMemory0() {
87
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
88
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
89
- }
90
- return cachedUint8ArrayMemory0;
91
- }
92
- function handleError(f, args) {
93
- try {
94
- return f.apply(this, args);
95
- } catch (e) {
96
- const idx = addToExternrefTable0(e);
97
- wasm.__wbindgen_exn_store(idx);
98
- }
99
- }
100
- function isLikeNone(x) {
101
- return x === void 0 || x === null;
102
- }
103
- function makeMutClosure(arg0, arg1, dtor, f) {
104
- const state = { a: arg0, b: arg1, cnt: 1, dtor };
105
- const real = (...args) => {
106
- state.cnt++;
107
- const a = state.a;
108
- state.a = 0;
109
- try {
110
- return f(a, state.b, ...args);
111
- } finally {
112
- state.a = a;
113
- real._wbg_cb_unref();
114
- }
115
- };
116
- real._wbg_cb_unref = () => {
117
- if (--state.cnt === 0) {
118
- state.dtor(state.a, state.b);
119
- state.a = 0;
120
- CLOSURE_DTORS.unregister(state);
121
- }
122
- };
123
- CLOSURE_DTORS.register(real, state, state);
124
- return real;
125
- }
126
- function passArray8ToWasm0(arg, malloc) {
127
- const ptr = malloc(arg.length * 1, 1) >>> 0;
128
- getUint8ArrayMemory0().set(arg, ptr / 1);
129
- WASM_VECTOR_LEN = arg.length;
130
- return ptr;
131
- }
132
- function passStringToWasm0(arg, malloc, realloc) {
133
- if (realloc === void 0) {
134
- const buf = cachedTextEncoder.encode(arg);
135
- const ptr2 = malloc(buf.length, 1) >>> 0;
136
- getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
137
- WASM_VECTOR_LEN = buf.length;
138
- return ptr2;
139
- }
140
- let len = arg.length;
141
- let ptr = malloc(len, 1) >>> 0;
142
- const mem = getUint8ArrayMemory0();
143
- let offset = 0;
144
- for (; offset < len; offset++) {
145
- const code = arg.charCodeAt(offset);
146
- if (code > 127) break;
147
- mem[ptr + offset] = code;
148
- }
149
- if (offset !== len) {
150
- if (offset !== 0) {
151
- arg = arg.slice(offset);
152
- }
153
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
154
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
155
- const ret = cachedTextEncoder.encodeInto(arg, view);
156
- offset += ret.written;
157
- ptr = realloc(ptr, len, offset, 1) >>> 0;
158
- }
159
- WASM_VECTOR_LEN = offset;
160
- return ptr;
161
- }
162
- function takeFromExternrefTable0(idx) {
163
- const value = wasm.__wbindgen_externrefs.get(idx);
164
- wasm.__externref_table_dealloc(idx);
165
- return value;
166
- }
167
- var cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
168
- cachedTextDecoder.decode();
169
- var MAX_SAFARI_DECODE_BYTES = 2146435072;
170
- var numBytesDecoded = 0;
171
- function decodeText(ptr, len) {
172
- numBytesDecoded += len;
173
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
174
- cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
175
- cachedTextDecoder.decode();
176
- numBytesDecoded = len;
177
- }
178
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
179
- }
180
- var cachedTextEncoder = new TextEncoder();
181
- if (!("encodeInto" in cachedTextEncoder)) {
182
- cachedTextEncoder.encodeInto = function(arg, view) {
183
- const buf = cachedTextEncoder.encode(arg);
184
- view.set(buf);
185
- return {
186
- read: arg.length,
187
- written: buf.length
188
- };
189
- };
190
- }
191
- var WASM_VECTOR_LEN = 0;
192
- function wasm_bindgen__convert__closures_____invoke__h4b569589ab16bc8b(arg0, arg1, arg2) {
193
- wasm.wasm_bindgen__convert__closures_____invoke__h4b569589ab16bc8b(arg0, arg1, arg2);
194
- }
195
- function wasm_bindgen__convert__closures_____invoke__h298f91ca76697d7d(arg0, arg1, arg2, arg3) {
196
- wasm.wasm_bindgen__convert__closures_____invoke__h298f91ca76697d7d(arg0, arg1, arg2, arg3);
197
- }
198
- var IndividualLanguagesFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
199
- }, unregister: () => {
200
- } } : new FinalizationRegistry((ptr) => wasm.__wbg_individuallanguages_free(ptr >>> 0, 1));
201
- var LanguageCodeFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
202
- }, unregister: () => {
203
- } } : new FinalizationRegistry((ptr) => wasm.__wbg_languagecode_free(ptr >>> 0, 1));
204
- var ProxyContextFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
205
- }, unregister: () => {
206
- } } : new FinalizationRegistry((ptr) => wasm.__wbg_proxycontext_free(ptr >>> 0, 1));
207
- var TinymistLanguageServerFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
208
- }, unregister: () => {
209
- } } : new FinalizationRegistry((ptr) => wasm.__wbg_tinymistlanguageserver_free(ptr >>> 0, 1));
210
- var IndividualLanguages = class _IndividualLanguages {
211
- static __wrap(ptr) {
212
- ptr = ptr >>> 0;
213
- const obj = Object.create(_IndividualLanguages.prototype);
214
- obj.__wbg_ptr = ptr;
215
- IndividualLanguagesFinalization.register(obj, obj.__wbg_ptr, obj);
216
- return obj;
217
- }
218
- __destroy_into_raw() {
219
- const ptr = this.__wbg_ptr;
220
- this.__wbg_ptr = 0;
221
- IndividualLanguagesFinalization.unregister(this);
222
- return ptr;
223
- }
224
- free() {
225
- const ptr = this.__destroy_into_raw();
226
- wasm.__wbg_individuallanguages_free(ptr, 0);
227
- }
228
- /**
229
- * @returns {string}
230
- */
231
- get name() {
232
- let deferred1_0;
233
- let deferred1_1;
234
- try {
235
- const ret = wasm.individuallanguages_name(this.__wbg_ptr);
236
- deferred1_0 = ret[0];
237
- deferred1_1 = ret[1];
238
- return getStringFromWasm0(ret[0], ret[1]);
239
- } finally {
240
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
241
- }
242
- }
243
- /**
244
- * @returns {string}
245
- */
246
- get code() {
247
- let deferred1_0;
248
- let deferred1_1;
249
- try {
250
- const ret = wasm.individuallanguages_code(this.__wbg_ptr);
251
- deferred1_0 = ret[0];
252
- deferred1_1 = ret[1];
253
- return getStringFromWasm0(ret[0], ret[1]);
254
- } finally {
255
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
256
- }
257
- }
258
- };
259
- if (Symbol.dispose) IndividualLanguages.prototype[Symbol.dispose] = IndividualLanguages.prototype.free;
260
- var LanguageCode = class _LanguageCode {
261
- static __wrap(ptr) {
262
- ptr = ptr >>> 0;
263
- const obj = Object.create(_LanguageCode.prototype);
264
- obj.__wbg_ptr = ptr;
265
- LanguageCodeFinalization.register(obj, obj.__wbg_ptr, obj);
266
- return obj;
267
- }
268
- __destroy_into_raw() {
269
- const ptr = this.__wbg_ptr;
270
- this.__wbg_ptr = 0;
271
- LanguageCodeFinalization.unregister(this);
272
- return ptr;
273
- }
274
- free() {
275
- const ptr = this.__destroy_into_raw();
276
- wasm.__wbg_languagecode_free(ptr, 0);
277
- }
278
- /**
279
- * @returns {string}
280
- */
281
- get name() {
282
- let deferred1_0;
283
- let deferred1_1;
284
- try {
285
- const ret = wasm.languagecode_name(this.__wbg_ptr);
286
- deferred1_0 = ret[0];
287
- deferred1_1 = ret[1];
288
- return getStringFromWasm0(ret[0], ret[1]);
289
- } finally {
290
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
291
- }
292
- }
293
- /**
294
- * @returns {string}
295
- */
296
- get code() {
297
- let deferred1_0;
298
- let deferred1_1;
299
- try {
300
- const ret = wasm.languagecode_code(this.__wbg_ptr);
301
- deferred1_0 = ret[0];
302
- deferred1_1 = ret[1];
303
- return getStringFromWasm0(ret[0], ret[1]);
304
- } finally {
305
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
306
- }
307
- }
308
- /**
309
- * @returns {string}
310
- */
311
- get code_2t() {
312
- let deferred1_0;
313
- let deferred1_1;
314
- try {
315
- const ret = wasm.languagecode_code_2t(this.__wbg_ptr);
316
- deferred1_0 = ret[0];
317
- deferred1_1 = ret[1];
318
- return getStringFromWasm0(ret[0], ret[1]);
319
- } finally {
320
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
321
- }
322
- }
323
- /**
324
- * @returns {string}
325
- */
326
- get code_2b() {
327
- let deferred1_0;
328
- let deferred1_1;
329
- try {
330
- const ret = wasm.languagecode_code_2b(this.__wbg_ptr);
331
- deferred1_0 = ret[0];
332
- deferred1_1 = ret[1];
333
- return getStringFromWasm0(ret[0], ret[1]);
334
- } finally {
335
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
336
- }
337
- }
338
- /**
339
- * @returns {string}
340
- */
341
- get code_3() {
342
- let deferred1_0;
343
- let deferred1_1;
344
- try {
345
- const ret = wasm.languagecode_code_3(this.__wbg_ptr);
346
- deferred1_0 = ret[0];
347
- deferred1_1 = ret[1];
348
- return getStringFromWasm0(ret[0], ret[1]);
349
- } finally {
350
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
351
- }
352
- }
353
- /**
354
- * @returns {Array<any>}
355
- */
356
- get individual_languages() {
357
- const ret = wasm.languagecode_individual_languages(this.__wbg_ptr);
358
- return ret;
359
- }
360
- };
361
- if (Symbol.dispose) LanguageCode.prototype[Symbol.dispose] = LanguageCode.prototype.free;
362
- var ProxyContext = class _ProxyContext {
363
- static __wrap(ptr) {
364
- ptr = ptr >>> 0;
365
- const obj = Object.create(_ProxyContext.prototype);
366
- obj.__wbg_ptr = ptr;
367
- ProxyContextFinalization.register(obj, obj.__wbg_ptr, obj);
368
- return obj;
369
- }
370
- __destroy_into_raw() {
371
- const ptr = this.__wbg_ptr;
372
- this.__wbg_ptr = 0;
373
- ProxyContextFinalization.unregister(this);
374
- return ptr;
375
- }
376
- free() {
377
- const ptr = this.__destroy_into_raw();
378
- wasm.__wbg_proxycontext_free(ptr, 0);
379
- }
380
- /**
381
- * Creates a new `ProxyContext` instance.
382
- * @param {any} context
383
- */
384
- constructor(context) {
385
- const ret = wasm.proxycontext_new(context);
386
- this.__wbg_ptr = ret >>> 0;
387
- ProxyContextFinalization.register(this, this.__wbg_ptr, this);
388
- return this;
389
- }
390
- /**
391
- * Returns the JavaScript this.
392
- * @returns {any}
393
- */
394
- get context() {
395
- const ret = wasm.proxycontext_context(this.__wbg_ptr);
396
- return ret;
397
- }
398
- /**
399
- * A convenience function to untar a tarball and call a callback for each
400
- * entry.
401
- * @param {Uint8Array} data
402
- * @param {Function} cb
403
- */
404
- untar(data, cb) {
405
- const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
406
- const len0 = WASM_VECTOR_LEN;
407
- const ret = wasm.proxycontext_untar(this.__wbg_ptr, ptr0, len0, cb);
408
- if (ret[1]) {
409
- throw takeFromExternrefTable0(ret[0]);
410
- }
411
- }
412
- };
413
- if (Symbol.dispose) ProxyContext.prototype[Symbol.dispose] = ProxyContext.prototype.free;
414
- var TinymistLanguageServer = class {
415
- __destroy_into_raw() {
416
- const ptr = this.__wbg_ptr;
417
- this.__wbg_ptr = 0;
418
- TinymistLanguageServerFinalization.unregister(this);
419
- return ptr;
420
- }
421
- free() {
422
- const ptr = this.__destroy_into_raw();
423
- wasm.__wbg_tinymistlanguageserver_free(ptr, 0);
424
- }
425
- /**
426
- * Creates a new language server.
427
- * @param {any} init_opts
428
- */
429
- constructor(init_opts) {
430
- const ret = wasm.tinymistlanguageserver_new(init_opts);
431
- if (ret[2]) {
432
- throw takeFromExternrefTable0(ret[1]);
433
- }
434
- this.__wbg_ptr = ret[0] >>> 0;
435
- TinymistLanguageServerFinalization.register(this, this.__wbg_ptr, this);
436
- return this;
437
- }
438
- /**
439
- * Handles internal events.
440
- * @param {number} event_id
441
- */
442
- on_event(event_id) {
443
- wasm.tinymistlanguageserver_on_event(this.__wbg_ptr, event_id);
444
- }
445
- /**
446
- * Handles incoming requests.
447
- * @param {string} method
448
- * @param {any} js_params
449
- * @returns {any}
450
- */
451
- on_request(method, js_params) {
452
- const ptr0 = passStringToWasm0(method, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
453
- const len0 = WASM_VECTOR_LEN;
454
- const ret = wasm.tinymistlanguageserver_on_request(this.__wbg_ptr, ptr0, len0, js_params);
455
- return ret;
456
- }
457
- /**
458
- * Handles incoming notifications.
459
- * @param {string} method
460
- * @param {any} js_params
461
- */
462
- on_notification(method, js_params) {
463
- const ptr0 = passStringToWasm0(method, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
464
- const len0 = WASM_VECTOR_LEN;
465
- wasm.tinymistlanguageserver_on_notification(this.__wbg_ptr, ptr0, len0, js_params);
466
- }
467
- /**
468
- * Handles incoming responses.
469
- * @param {any} js_result
470
- */
471
- on_response(js_result) {
472
- wasm.tinymistlanguageserver_on_response(this.__wbg_ptr, js_result);
473
- }
474
- /**
475
- * Get the version of the language server.
476
- * @returns {string}
477
- */
478
- static version() {
479
- let deferred1_0;
480
- let deferred1_1;
481
- try {
482
- const ret = wasm.tinymistlanguageserver_version();
483
- deferred1_0 = ret[0];
484
- deferred1_1 = ret[1];
485
- return getStringFromWasm0(ret[0], ret[1]);
486
- } finally {
487
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
488
- }
489
- }
490
- };
491
- if (Symbol.dispose) TinymistLanguageServer.prototype[Symbol.dispose] = TinymistLanguageServer.prototype.free;
492
- var EXPECTED_RESPONSE_TYPES = /* @__PURE__ */ new Set(["basic", "cors", "default"]);
493
- async function __wbg_load(module, imports) {
494
- if (typeof Response === "function" && module instanceof Response) {
495
- if (typeof WebAssembly.instantiateStreaming === "function") {
496
- try {
497
- return await WebAssembly.instantiateStreaming(module, imports);
498
- } catch (e) {
499
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
500
- if (validResponse && module.headers.get("Content-Type") !== "application/wasm") {
501
- 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);
502
- } else {
503
- throw e;
504
- }
505
- }
506
- }
507
- const bytes = await module.arrayBuffer();
508
- return await WebAssembly.instantiate(bytes, imports);
509
- } else {
510
- const instance = await WebAssembly.instantiate(module, imports);
511
- if (instance instanceof WebAssembly.Instance) {
512
- return { instance, module };
513
- } else {
514
- return instance;
515
- }
516
- }
517
- }
518
- function __wbg_get_imports() {
519
- const imports = {};
520
- imports.wbg = {};
521
- imports.wbg.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
522
- const ret = Error(getStringFromWasm0(arg0, arg1));
523
- return ret;
524
- };
525
- imports.wbg.__wbg_Number_2d1dcfcf4ec51736 = function(arg0) {
526
- const ret = Number(arg0);
527
- return ret;
528
- };
529
- imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
530
- const ret = String(arg1);
531
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
532
- const len1 = WASM_VECTOR_LEN;
533
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
534
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
535
- };
536
- imports.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d = function(arg0, arg1) {
537
- const v = arg1;
538
- const ret = typeof v === "bigint" ? v : void 0;
539
- getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
540
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
541
- };
542
- imports.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b = function(arg0) {
543
- const v = arg0;
544
- const ret = typeof v === "boolean" ? v : void 0;
545
- return isLikeNone(ret) ? 16777215 : ret ? 1 : 0;
546
- };
547
- imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
548
- const ret = debugString(arg1);
549
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
550
- const len1 = WASM_VECTOR_LEN;
551
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
552
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
553
- };
554
- imports.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317 = function(arg0, arg1) {
555
- const ret = arg0 in arg1;
556
- return ret;
557
- };
558
- imports.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27 = function(arg0) {
559
- const ret = typeof arg0 === "bigint";
560
- return ret;
561
- };
562
- imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
563
- const ret = typeof arg0 === "function";
564
- return ret;
565
- };
566
- imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
567
- const val = arg0;
568
- const ret = typeof val === "object" && val !== null;
569
- return ret;
570
- };
571
- imports.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030 = function(arg0) {
572
- const ret = typeof arg0 === "string";
573
- return ret;
574
- };
575
- imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
576
- const ret = arg0 === void 0;
577
- return ret;
578
- };
579
- imports.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36 = function(arg0, arg1) {
580
- const ret = arg0 === arg1;
581
- return ret;
582
- };
583
- imports.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d = function(arg0, arg1) {
584
- const ret = arg0 == arg1;
585
- return ret;
586
- };
587
- imports.wbg.__wbg___wbindgen_number_get_9619185a74197f95 = function(arg0, arg1) {
588
- const obj = arg1;
589
- const ret = typeof obj === "number" ? obj : void 0;
590
- getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
591
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
592
- };
593
- imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
594
- const obj = arg1;
595
- const ret = typeof obj === "string" ? obj : void 0;
596
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
597
- var len1 = WASM_VECTOR_LEN;
598
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
599
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
600
- };
601
- imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
602
- throw new Error(getStringFromWasm0(arg0, arg1));
603
- };
604
- imports.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7 = function(arg0) {
605
- arg0._wbg_cb_unref();
606
- };
607
- imports.wbg.__wbg_call_3020136f7a2d6e44 = function() {
608
- return handleError(function(arg0, arg1, arg2) {
609
- const ret = arg0.call(arg1, arg2);
610
- return ret;
611
- }, arguments);
612
- };
613
- imports.wbg.__wbg_call_78f94eb02ec7f9b2 = function() {
614
- return handleError(function(arg0, arg1, arg2, arg3, arg4) {
615
- const ret = arg0.call(arg1, arg2, arg3, arg4);
616
- return ret;
617
- }, arguments);
618
- };
619
- imports.wbg.__wbg_call_abb4ff46ce38be40 = function() {
620
- return handleError(function(arg0, arg1) {
621
- const ret = arg0.call(arg1);
622
- return ret;
623
- }, arguments);
624
- };
625
- imports.wbg.__wbg_done_62ea16af4ce34b24 = function(arg0) {
626
- const ret = arg0.done;
627
- return ret;
628
- };
629
- imports.wbg.__wbg_entries_83c79938054e065f = function(arg0) {
630
- const ret = Object.entries(arg0);
631
- return ret;
632
- };
633
- imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
634
- let deferred0_0;
635
- let deferred0_1;
636
- try {
637
- deferred0_0 = arg0;
638
- deferred0_1 = arg1;
639
- console.error(getStringFromWasm0(arg0, arg1));
640
- } finally {
641
- wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
642
- }
643
- };
644
- imports.wbg.__wbg_getTimezoneOffset_45389e26d6f46823 = function(arg0) {
645
- const ret = arg0.getTimezoneOffset();
646
- return ret;
647
- };
648
- imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
649
- const ret = arg0[arg1 >>> 0];
650
- return ret;
651
- };
652
- imports.wbg.__wbg_get_af9dab7e9603ea93 = function() {
653
- return handleError(function(arg0, arg1) {
654
- const ret = Reflect.get(arg0, arg1);
655
- return ret;
656
- }, arguments);
657
- };
658
- imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) {
659
- const ret = arg0[arg1];
660
- return ret;
661
- };
662
- imports.wbg.__wbg_individuallanguages_new = function(arg0) {
663
- const ret = IndividualLanguages.__wrap(arg0);
664
- return ret;
665
- };
666
- imports.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355 = function(arg0) {
667
- let result;
668
- try {
669
- result = arg0 instanceof ArrayBuffer;
670
- } catch (_) {
671
- result = false;
672
- }
673
- const ret = result;
674
- return ret;
675
- };
676
- imports.wbg.__wbg_instanceof_Map_084be8da74364158 = function(arg0) {
677
- let result;
678
- try {
679
- result = arg0 instanceof Map;
680
- } catch (_) {
681
- result = false;
682
- }
683
- const ret = result;
684
- return ret;
685
- };
686
- imports.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434 = function(arg0) {
687
- let result;
688
- try {
689
- result = arg0 instanceof Uint8Array;
690
- } catch (_) {
691
- result = false;
692
- }
693
- const ret = result;
694
- return ret;
695
- };
696
- imports.wbg.__wbg_isArray_51fd9e6422c0a395 = function(arg0) {
697
- const ret = Array.isArray(arg0);
698
- return ret;
699
- };
700
- imports.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16 = function(arg0) {
701
- const ret = Number.isSafeInteger(arg0);
702
- return ret;
703
- };
704
- imports.wbg.__wbg_iterator_27b7c8b35ab3e86b = function() {
705
- const ret = Symbol.iterator;
706
- return ret;
707
- };
708
- imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
709
- const ret = arg0.length;
710
- return ret;
711
- };
712
- imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
713
- const ret = arg0.length;
714
- return ret;
715
- };
716
- imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
717
- const ret = new Object();
718
- return ret;
719
- };
720
- imports.wbg.__wbg_new_25f239778d6112b9 = function() {
721
- const ret = new Array();
722
- return ret;
723
- };
724
- imports.wbg.__wbg_new_6421f6084cc5bc5a = function(arg0) {
725
- const ret = new Uint8Array(arg0);
726
- return ret;
727
- };
728
- imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
729
- const ret = new Error();
730
- return ret;
731
- };
732
- imports.wbg.__wbg_new_b2db8aa2650f793a = function(arg0) {
733
- const ret = new Date(arg0);
734
- return ret;
735
- };
736
- imports.wbg.__wbg_new_b546ae120718850e = function() {
737
- const ret = /* @__PURE__ */ new Map();
738
- return ret;
739
- };
740
- imports.wbg.__wbg_new_ff12d2b041fb48f1 = function(arg0, arg1) {
741
- try {
742
- var state0 = { a: arg0, b: arg1 };
743
- var cb0 = (arg02, arg12) => {
744
- const a = state0.a;
745
- state0.a = 0;
746
- try {
747
- return wasm_bindgen__convert__closures_____invoke__h298f91ca76697d7d(a, state0.b, arg02, arg12);
748
- } finally {
749
- state0.a = a;
750
- }
751
- };
752
- const ret = new Promise(cb0);
753
- return ret;
754
- } finally {
755
- state0.a = state0.b = 0;
756
- }
757
- };
758
- imports.wbg.__wbg_new_from_slice_f9c22b9153b26992 = function(arg0, arg1) {
759
- const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
760
- return ret;
761
- };
762
- imports.wbg.__wbg_new_no_args_cb138f77cf6151ee = function(arg0, arg1) {
763
- const ret = new Function(getStringFromWasm0(arg0, arg1));
764
- return ret;
765
- };
766
- imports.wbg.__wbg_next_138a17bbf04e926c = function(arg0) {
767
- const ret = arg0.next;
768
- return ret;
769
- };
770
- imports.wbg.__wbg_next_3cfe5c0fe2a4cc53 = function() {
771
- return handleError(function(arg0) {
772
- const ret = arg0.next();
773
- return ret;
774
- }, arguments);
775
- };
776
- imports.wbg.__wbg_now_2c95c9de01293173 = function(arg0) {
777
- const ret = arg0.now();
778
- return ret;
779
- };
780
- imports.wbg.__wbg_now_69d776cd24f5215b = function() {
781
- const ret = Date.now();
782
- return ret;
783
- };
784
- imports.wbg.__wbg_performance_7a3ffd0b17f663ad = function(arg0) {
785
- const ret = arg0.performance;
786
- return ret;
787
- };
788
- imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
789
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
790
- };
791
- imports.wbg.__wbg_proxycontext_new = function(arg0) {
792
- const ret = ProxyContext.__wrap(arg0);
793
- return ret;
794
- };
795
- imports.wbg.__wbg_push_7d9be8f38fc13975 = function(arg0, arg1) {
796
- const ret = arg0.push(arg1);
797
- return ret;
798
- };
799
- imports.wbg.__wbg_queueMicrotask_9b549dfce8865860 = function(arg0) {
800
- const ret = arg0.queueMicrotask;
801
- return ret;
802
- };
803
- imports.wbg.__wbg_queueMicrotask_fca69f5bfad613a5 = function(arg0) {
804
- queueMicrotask(arg0);
805
- };
806
- imports.wbg.__wbg_resolve_fd5bfbaa4ce36e1e = function(arg0) {
807
- const ret = Promise.resolve(arg0);
808
- return ret;
809
- };
810
- imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
811
- arg0[arg1] = arg2;
812
- };
813
- imports.wbg.__wbg_set_781438a03c0c3c81 = function() {
814
- return handleError(function(arg0, arg1, arg2) {
815
- const ret = Reflect.set(arg0, arg1, arg2);
816
- return ret;
817
- }, arguments);
818
- };
819
- imports.wbg.__wbg_set_7df433eea03a5c14 = function(arg0, arg1, arg2) {
820
- arg0[arg1 >>> 0] = arg2;
821
- };
822
- imports.wbg.__wbg_set_efaaf145b9377369 = function(arg0, arg1, arg2) {
823
- const ret = arg0.set(arg1, arg2);
824
- return ret;
825
- };
826
- imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
827
- const ret = arg1.stack;
828
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
829
- const len1 = WASM_VECTOR_LEN;
830
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
831
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
832
- };
833
- imports.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335 = function() {
834
- const ret = typeof global === "undefined" ? null : global;
835
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
836
- };
837
- imports.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1 = function() {
838
- const ret = typeof globalThis === "undefined" ? null : globalThis;
839
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
840
- };
841
- imports.wbg.__wbg_static_accessor_SELF_08f5a74c69739274 = function() {
842
- const ret = typeof self === "undefined" ? null : self;
843
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
844
- };
845
- imports.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024 = function() {
846
- const ret = typeof window === "undefined" ? null : window;
847
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
848
- };
849
- imports.wbg.__wbg_then_4f95312d68691235 = function(arg0, arg1) {
850
- const ret = arg0.then(arg1);
851
- return ret;
852
- };
853
- imports.wbg.__wbg_value_57b7b035e117f7ee = function(arg0) {
854
- const ret = arg0.value;
855
- return ret;
856
- };
857
- imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
858
- const ret = getStringFromWasm0(arg0, arg1);
859
- return ret;
860
- };
861
- imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
862
- const ret = BigInt.asUintN(64, arg0);
863
- return ret;
864
- };
865
- imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
866
- const ret = arg0;
867
- return ret;
868
- };
869
- imports.wbg.__wbindgen_cast_b5bc9a99b1b9b782 = function(arg0, arg1) {
870
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h21ca932816a58917, wasm_bindgen__convert__closures_____invoke__h4b569589ab16bc8b);
871
- return ret;
872
- };
873
- imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
874
- const ret = arg0;
875
- return ret;
876
- };
877
- imports.wbg.__wbindgen_init_externref_table = function() {
878
- const table = wasm.__wbindgen_externrefs;
879
- const offset = table.grow(4);
880
- table.set(0, void 0);
881
- table.set(offset + 0, void 0);
882
- table.set(offset + 1, null);
883
- table.set(offset + 2, true);
884
- table.set(offset + 3, false);
885
- };
886
- return imports;
887
- }
888
- function __wbg_finalize_init(instance, module) {
889
- wasm = instance.exports;
890
- __wbg_init.__wbindgen_wasm_module = module;
891
- cachedDataViewMemory0 = null;
892
- cachedUint8ArrayMemory0 = null;
893
- wasm.__wbindgen_start();
894
- return wasm;
895
- }
896
- async function __wbg_init(module_or_path) {
897
- if (wasm !== void 0) return wasm;
898
- if (typeof module_or_path !== "undefined") {
899
- if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
900
- ({ module_or_path } = module_or_path);
901
- } else {
902
- console.warn("using deprecated parameters for the initialization function; pass a single object instead");
903
- }
904
- }
905
- if (typeof module_or_path === "undefined") {
906
- module_or_path = new URL("tinymist_bg.wasm", import.meta.url);
907
- }
908
- const imports = __wbg_get_imports();
909
- if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) {
910
- module_or_path = fetch(module_or_path);
911
- }
912
- const { instance, module } = await __wbg_load(await module_or_path, imports);
913
- return __wbg_finalize_init(instance, module);
914
- }
915
- var tinymist_default = __wbg_init;
916
-
917
- // src/analyzer-worker.ts
918
- var AnalyzerWorker = class {
919
- #server = null;
920
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- events are opaque values from WASM
921
- #events = [];
922
- #ensureServer() {
923
- if (!this.#server) throw new Error("Analyzer not initialized");
924
- return this.#server;
925
- }
926
- #notifyDidOpen(uri, content) {
927
- this.#ensureServer().on_notification("textDocument/didOpen", {
928
- textDocument: { uri, languageId: "typst", version: 1, text: content }
929
- });
930
- }
931
- #notifyDidClose(uri) {
932
- this.#ensureServer().on_notification("textDocument/didClose", {
933
- textDocument: { uri }
934
- });
935
- }
936
- #notifyDidChange(uri, version, content) {
937
- this.#ensureServer().on_notification("textDocument/didChange", {
938
- textDocument: { uri, version },
939
- contentChanges: [{ text: content }]
940
- });
941
- }
942
- #flushEvents() {
943
- if (!this.#server) return;
944
- while (this.#events.length > 0) {
945
- for (const event of this.#events.splice(0)) {
946
- this.#server.on_event(event);
947
- }
948
- }
949
- }
950
- async init(wasmUrl) {
951
- await tinymist_default({ module_or_path: wasmUrl });
952
- this.#server = new TinymistLanguageServer({
953
- sendEvent: (event) => {
954
- this.#events.push(event);
955
- },
956
- sendRequest: ({
957
- id
958
- }) => {
959
- this.#server.on_response({ id, result: null });
960
- },
961
- sendNotification: () => {
962
- },
963
- resolveFn: () => void 0
964
- });
965
- const initResult = this.#server.on_request("initialize", {
966
- capabilities: {
967
- textDocument: {
968
- completion: { completionItem: { snippetSupport: true } },
969
- hover: { contentFormat: ["markdown", "plaintext"] }
970
- }
971
- },
972
- rootUri: "file:///"
973
- });
974
- if (initResult && typeof initResult === "object" && "then" in initResult) {
975
- await initResult;
976
- }
977
- this.#flushEvents();
978
- this.#server.on_notification("initialized", {});
979
- this.#flushEvents();
980
- }
981
- async didOpen(uri, content) {
982
- this.#notifyDidOpen(uri, content);
983
- this.#flushEvents();
984
- }
985
- async didClose(uri) {
986
- this.#notifyDidClose(uri);
987
- this.#flushEvents();
988
- }
989
- async didChange(uri, version, content) {
990
- this.#notifyDidChange(uri, version, content);
991
- this.#flushEvents();
992
- }
993
- async didChangeMany(opens, changes) {
994
- this.#ensureServer();
995
- for (const { uri, content } of opens) {
996
- this.#notifyDidOpen(uri, content);
997
- }
998
- for (const { uri, version, content } of changes) {
999
- this.#notifyDidChange(uri, version, content);
1000
- }
1001
- this.#flushEvents();
1002
- }
1003
- async didCloseMany(uris) {
1004
- this.#ensureServer();
1005
- for (const uri of uris) {
1006
- this.#notifyDidClose(uri);
1007
- }
1008
- this.#flushEvents();
1009
- }
1010
- async completion(uri, position) {
1011
- const resolved = await this.#ensureServer().on_request(
1012
- "textDocument/completion",
1013
- { textDocument: { uri }, position }
1014
- );
1015
- this.#flushEvents();
1016
- return resolved ?? null;
1017
- }
1018
- async hover(uri, position) {
1019
- const resolved = await this.#ensureServer().on_request(
1020
- "textDocument/hover",
1021
- { textDocument: { uri }, position }
1022
- );
1023
- this.#flushEvents();
1024
- return resolved ?? null;
1025
- }
1026
- async completionWithDoc(uri, version, content, position, kind) {
1027
- if (kind === "open") this.#notifyDidOpen(uri, content);
1028
- else this.#notifyDidChange(uri, version, content);
1029
- return this.completion(uri, position);
1030
- }
1031
- async hoverWithDoc(uri, version, content, position, kind) {
1032
- if (kind === "open") this.#notifyDidOpen(uri, content);
1033
- else this.#notifyDidChange(uri, version, content);
1034
- return this.hover(uri, position);
1035
- }
1036
- destroy() {
1037
- this.#server?.free();
1038
- this.#server = null;
1039
- }
1040
- };
1041
- Comlink.expose(new AnalyzerWorker());
1042
- export {
1043
- AnalyzerWorker
1044
- };
1045
- //# sourceMappingURL=analyzer-worker.js.map