swls-wasm 0.3.2-alpha.1 → 0.3.2-alpha.2

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/swls_wasm.js CHANGED
@@ -1,9 +1,692 @@
1
1
  /* @ts-self-types="./swls_wasm.d.ts" */
2
- import * as wasm from "./swls_wasm_bg.wasm";
3
- import { __wbg_set_wasm } from "./swls_wasm_bg.js";
4
-
5
- __wbg_set_wasm(wasm);
6
- wasm.__wbindgen_start();
7
- export {
8
- WasmLsp, start_wasm_lsp
9
- } from "./swls_wasm_bg.js";
2
+
3
+ /**
4
+ * A self-contained WASM LSP instance that JS can create.
5
+ *
6
+ * Both directions exchange whole JSON-RPC messages (no `Content-Length` framing):
7
+ * JS calls [`WasmLsp::send`] with a raw message string, and the `post_message_cb`
8
+ * receives raw message strings. Inbound requests/notifications are processed in
9
+ * order by a single consumer task; responses to server-initiated requests are
10
+ * resolved inline so they never queue behind an in-flight handler.
11
+ */
12
+ export class WasmLsp {
13
+ __destroy_into_raw() {
14
+ const ptr = this.__wbg_ptr;
15
+ this.__wbg_ptr = 0;
16
+ WasmLspFinalization.unregister(this);
17
+ return ptr;
18
+ }
19
+ free() {
20
+ const ptr = this.__destroy_into_raw();
21
+ wasm.__wbg_wasmlsp_free(ptr, 0);
22
+ }
23
+ /**
24
+ * JS must pass a callback for receiving messages from Rust/WASM.
25
+ * @param {Function} post_message_cb
26
+ * @param {Function | null} [debug_cb]
27
+ */
28
+ constructor(post_message_cb, debug_cb) {
29
+ const ret = wasm.wasmlsp_new(post_message_cb, isLikeNone(debug_cb) ? 0 : addToExternrefTable0(debug_cb));
30
+ this.__wbg_ptr = ret;
31
+ WasmLspFinalization.register(this, this.__wbg_ptr, this);
32
+ return this;
33
+ }
34
+ /**
35
+ * Send a message from JS → LSP. `msg` is a raw JSON-RPC message.
36
+ * @param {string} msg
37
+ */
38
+ send(msg) {
39
+ const ptr0 = passStringToWasm0(msg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
40
+ const len0 = WASM_VECTOR_LEN;
41
+ wasm.wasmlsp_send(this.__wbg_ptr, ptr0, len0);
42
+ }
43
+ }
44
+ if (Symbol.dispose) WasmLsp.prototype[Symbol.dispose] = WasmLsp.prototype.free;
45
+
46
+ /**
47
+ * @returns {Promise<void>}
48
+ */
49
+ export function start_wasm_lsp() {
50
+ wasm.start_wasm_lsp();
51
+ }
52
+ function __wbg_get_imports() {
53
+ const import0 = {
54
+ __proto__: null,
55
+ __wbg_Error_fdd633d4bb5dd76a: function(arg0, arg1) {
56
+ const ret = Error(getStringFromWasm0(arg0, arg1));
57
+ return ret;
58
+ },
59
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
60
+ const ret = String(arg1);
61
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
62
+ const len1 = WASM_VECTOR_LEN;
63
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
64
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
65
+ },
66
+ __wbg___wbindgen_boolean_get_edaed31a367ce1bd: function(arg0) {
67
+ const v = arg0;
68
+ const ret = typeof(v) === 'boolean' ? v : undefined;
69
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
70
+ },
71
+ __wbg___wbindgen_debug_string_8a447059637473e2: function(arg0, arg1) {
72
+ const ret = debugString(arg1);
73
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
74
+ const len1 = WASM_VECTOR_LEN;
75
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
76
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
77
+ },
78
+ __wbg___wbindgen_is_function_acc5528be2b923f2: function(arg0) {
79
+ const ret = typeof(arg0) === 'function';
80
+ return ret;
81
+ },
82
+ __wbg___wbindgen_is_object_0beba4a1980d3eea: function(arg0) {
83
+ const val = arg0;
84
+ const ret = typeof(val) === 'object' && val !== null;
85
+ return ret;
86
+ },
87
+ __wbg___wbindgen_is_string_1fca8072260dd261: function(arg0) {
88
+ const ret = typeof(arg0) === 'string';
89
+ return ret;
90
+ },
91
+ __wbg___wbindgen_is_undefined_721f8decd50c87a3: function(arg0) {
92
+ const ret = arg0 === undefined;
93
+ return ret;
94
+ },
95
+ __wbg___wbindgen_jsval_loose_eq_4b9aba9e5b3c4582: function(arg0, arg1) {
96
+ const ret = arg0 == arg1;
97
+ return ret;
98
+ },
99
+ __wbg___wbindgen_number_get_1cc01dd708740256: function(arg0, arg1) {
100
+ const obj = arg1;
101
+ const ret = typeof(obj) === 'number' ? obj : undefined;
102
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
103
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
104
+ },
105
+ __wbg___wbindgen_string_get_71bb4348194e31f0: function(arg0, arg1) {
106
+ const obj = arg1;
107
+ const ret = typeof(obj) === 'string' ? obj : undefined;
108
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
109
+ var len1 = WASM_VECTOR_LEN;
110
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
111
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
112
+ },
113
+ __wbg___wbindgen_throw_ea4887a5f8f9a9db: function(arg0, arg1) {
114
+ throw new Error(getStringFromWasm0(arg0, arg1));
115
+ },
116
+ __wbg__wbg_cb_unref_33c39e13d73b25f6: function(arg0) {
117
+ arg0._wbg_cb_unref();
118
+ },
119
+ __wbg_call_5575218572ead796: function() { return handleError(function (arg0, arg1, arg2) {
120
+ const ret = arg0.call(arg1, arg2);
121
+ return ret;
122
+ }, arguments); },
123
+ __wbg_call_8e98ed2f3c86c4b5: function() { return handleError(function (arg0, arg1) {
124
+ const ret = arg0.call(arg1);
125
+ return ret;
126
+ }, arguments); },
127
+ __wbg_done_b62d4a7d2286852a: function(arg0) {
128
+ const ret = arg0.done;
129
+ return ret;
130
+ },
131
+ __wbg_entries_c261c3fa1f281256: function(arg0) {
132
+ const ret = Object.entries(arg0);
133
+ return ret;
134
+ },
135
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
136
+ let deferred0_0;
137
+ let deferred0_1;
138
+ try {
139
+ deferred0_0 = arg0;
140
+ deferred0_1 = arg1;
141
+ console.error(getStringFromWasm0(arg0, arg1));
142
+ } finally {
143
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
144
+ }
145
+ },
146
+ __wbg_fetch_660fc96ce2bfaa9c: function() { return handleError(function (arg0, arg1) {
147
+ const ret = fetch(arg0, arg1);
148
+ return ret;
149
+ }, arguments); },
150
+ __wbg_getRandomValues_3f44b700395062e5: function() { return handleError(function (arg0, arg1) {
151
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
152
+ }, arguments); },
153
+ __wbg_get_197a3fe98f169e38: function(arg0, arg1) {
154
+ const ret = arg0[arg1 >>> 0];
155
+ return ret;
156
+ },
157
+ __wbg_get_9a29be2cb383ed9a: function() { return handleError(function (arg0, arg1) {
158
+ const ret = Reflect.get(arg0, arg1);
159
+ return ret;
160
+ }, arguments); },
161
+ __wbg_get_unchecked_54a4374c38e08460: function(arg0, arg1) {
162
+ const ret = arg0[arg1 >>> 0];
163
+ return ret;
164
+ },
165
+ __wbg_headers_d9123c649c85d441: function(arg0) {
166
+ const ret = arg0.headers;
167
+ return ret;
168
+ },
169
+ __wbg_instanceof_ArrayBuffer_2a7bb09fee70c2da: function(arg0) {
170
+ let result;
171
+ try {
172
+ result = arg0 instanceof ArrayBuffer;
173
+ } catch (_) {
174
+ result = false;
175
+ }
176
+ const ret = result;
177
+ return ret;
178
+ },
179
+ __wbg_instanceof_Response_79948c98d1d2ba75: function(arg0) {
180
+ let result;
181
+ try {
182
+ result = arg0 instanceof Response;
183
+ } catch (_) {
184
+ result = false;
185
+ }
186
+ const ret = result;
187
+ return ret;
188
+ },
189
+ __wbg_instanceof_Uint8Array_f080092dc70f5d58: function(arg0) {
190
+ let result;
191
+ try {
192
+ result = arg0 instanceof Uint8Array;
193
+ } catch (_) {
194
+ result = false;
195
+ }
196
+ const ret = result;
197
+ return ret;
198
+ },
199
+ __wbg_iterator_cc47ba25a2be735a: function() {
200
+ const ret = Symbol.iterator;
201
+ return ret;
202
+ },
203
+ __wbg_length_589238bdcf171f0e: function(arg0) {
204
+ const ret = arg0.length;
205
+ return ret;
206
+ },
207
+ __wbg_length_c6054974c0a6cdb9: function(arg0) {
208
+ const ret = arg0.length;
209
+ return ret;
210
+ },
211
+ __wbg_log_6b5af08dd293697f: function(arg0) {
212
+ console.log(arg0);
213
+ },
214
+ __wbg_new_227d7c05414eb861: function() {
215
+ const ret = new Error();
216
+ return ret;
217
+ },
218
+ __wbg_new_2e117a478906f062: function() {
219
+ const ret = new Object();
220
+ return ret;
221
+ },
222
+ __wbg_new_3444eb7412549f0b: function() {
223
+ const ret = new Map();
224
+ return ret;
225
+ },
226
+ __wbg_new_36e147a8ced3c6e0: function() {
227
+ const ret = new Array();
228
+ return ret;
229
+ },
230
+ __wbg_new_81880fb5002cb255: function(arg0) {
231
+ const ret = new Uint8Array(arg0);
232
+ return ret;
233
+ },
234
+ __wbg_new_typed_00a409eb4ec4f2d9: function(arg0, arg1) {
235
+ try {
236
+ var state0 = {a: arg0, b: arg1};
237
+ var cb0 = (arg0, arg1) => {
238
+ const a = state0.a;
239
+ state0.a = 0;
240
+ try {
241
+ return wasm_bindgen__convert__closures_____invoke__h0a08a9b6706aa208(a, state0.b, arg0, arg1);
242
+ } finally {
243
+ state0.a = a;
244
+ }
245
+ };
246
+ const ret = new Promise(cb0);
247
+ return ret;
248
+ } finally {
249
+ state0.a = 0;
250
+ }
251
+ },
252
+ __wbg_next_0c4066e251d2eff9: function() { return handleError(function (arg0) {
253
+ const ret = arg0.next();
254
+ return ret;
255
+ }, arguments); },
256
+ __wbg_next_402fa10b59ab20c3: function(arg0) {
257
+ const ret = arg0.next;
258
+ return ret;
259
+ },
260
+ __wbg_now_d2e0afbad4edbe82: function() {
261
+ const ret = Date.now();
262
+ return ret;
263
+ },
264
+ __wbg_prototypesetcall_d721637c7ca66eb8: function(arg0, arg1, arg2) {
265
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
266
+ },
267
+ __wbg_queueMicrotask_1c9b3800e321a967: function(arg0) {
268
+ const ret = arg0.queueMicrotask;
269
+ return ret;
270
+ },
271
+ __wbg_queueMicrotask_311744e534a929a3: function(arg0) {
272
+ queueMicrotask(arg0);
273
+ },
274
+ __wbg_resolve_d82363d90af6928a: function(arg0) {
275
+ const ret = Promise.resolve(arg0);
276
+ return ret;
277
+ },
278
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
279
+ arg0[arg1] = arg2;
280
+ },
281
+ __wbg_set_9a1d61e17de7054c: function(arg0, arg1, arg2) {
282
+ const ret = arg0.set(arg1, arg2);
283
+ return ret;
284
+ },
285
+ __wbg_set_dc601f4a69da0bc2: function(arg0, arg1, arg2) {
286
+ arg0[arg1 >>> 0] = arg2;
287
+ },
288
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
289
+ const ret = arg1.stack;
290
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
291
+ const len1 = WASM_VECTOR_LEN;
292
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
293
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
294
+ },
295
+ __wbg_static_accessor_GLOBAL_THIS_2fee5048bcca5938: function() {
296
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
297
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
298
+ },
299
+ __wbg_static_accessor_GLOBAL_ce44e66a4935da8c: function() {
300
+ const ret = typeof global === 'undefined' ? null : global;
301
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
302
+ },
303
+ __wbg_static_accessor_SELF_44f6e0cb5e67cdad: function() {
304
+ const ret = typeof self === 'undefined' ? null : self;
305
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
306
+ },
307
+ __wbg_static_accessor_WINDOW_168f178805d978fe: function() {
308
+ const ret = typeof window === 'undefined' ? null : window;
309
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
310
+ },
311
+ __wbg_status_0053aa6239760447: function(arg0) {
312
+ const ret = arg0.status;
313
+ return ret;
314
+ },
315
+ __wbg_text_68ea00f7126f2706: function() { return handleError(function (arg0) {
316
+ const ret = arg0.text();
317
+ return ret;
318
+ }, arguments); },
319
+ __wbg_then_05edfc8a4fea5106: function(arg0, arg1, arg2) {
320
+ const ret = arg0.then(arg1, arg2);
321
+ return ret;
322
+ },
323
+ __wbg_then_591b6b3a75ee817a: function(arg0, arg1) {
324
+ const ret = arg0.then(arg1);
325
+ return ret;
326
+ },
327
+ __wbg_value_49f783bb59765962: function(arg0) {
328
+ const ret = arg0.value;
329
+ return ret;
330
+ },
331
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
332
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 4783, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
333
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h5d8169a9c6a0716a);
334
+ return ret;
335
+ },
336
+ __wbindgen_cast_0000000000000002: function(arg0) {
337
+ // Cast intrinsic for `F64 -> Externref`.
338
+ const ret = arg0;
339
+ return ret;
340
+ },
341
+ __wbindgen_cast_0000000000000003: function(arg0) {
342
+ // Cast intrinsic for `I64 -> Externref`.
343
+ const ret = arg0;
344
+ return ret;
345
+ },
346
+ __wbindgen_cast_0000000000000004: function(arg0, arg1) {
347
+ // Cast intrinsic for `Ref(String) -> Externref`.
348
+ const ret = getStringFromWasm0(arg0, arg1);
349
+ return ret;
350
+ },
351
+ __wbindgen_cast_0000000000000005: function(arg0) {
352
+ // Cast intrinsic for `U64 -> Externref`.
353
+ const ret = BigInt.asUintN(64, arg0);
354
+ return ret;
355
+ },
356
+ __wbindgen_init_externref_table: function() {
357
+ const table = wasm.__wbindgen_externrefs;
358
+ const offset = table.grow(4);
359
+ table.set(0, undefined);
360
+ table.set(offset + 0, undefined);
361
+ table.set(offset + 1, null);
362
+ table.set(offset + 2, true);
363
+ table.set(offset + 3, false);
364
+ },
365
+ };
366
+ return {
367
+ __proto__: null,
368
+ "./swls_wasm_bg.js": import0,
369
+ };
370
+ }
371
+
372
+ function wasm_bindgen__convert__closures_____invoke__h5d8169a9c6a0716a(arg0, arg1, arg2) {
373
+ const ret = wasm.wasm_bindgen__convert__closures_____invoke__h5d8169a9c6a0716a(arg0, arg1, arg2);
374
+ if (ret[1]) {
375
+ throw takeFromExternrefTable0(ret[0]);
376
+ }
377
+ }
378
+
379
+ function wasm_bindgen__convert__closures_____invoke__h0a08a9b6706aa208(arg0, arg1, arg2, arg3) {
380
+ wasm.wasm_bindgen__convert__closures_____invoke__h0a08a9b6706aa208(arg0, arg1, arg2, arg3);
381
+ }
382
+
383
+ const WasmLspFinalization = (typeof FinalizationRegistry === 'undefined')
384
+ ? { register: () => {}, unregister: () => {} }
385
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmlsp_free(ptr, 1));
386
+
387
+ function addToExternrefTable0(obj) {
388
+ const idx = wasm.__externref_table_alloc();
389
+ wasm.__wbindgen_externrefs.set(idx, obj);
390
+ return idx;
391
+ }
392
+
393
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
394
+ ? { register: () => {}, unregister: () => {} }
395
+ : new FinalizationRegistry(state => wasm.__wbindgen_destroy_closure(state.a, state.b));
396
+
397
+ function debugString(val) {
398
+ // primitive types
399
+ const type = typeof val;
400
+ if (type == 'number' || type == 'boolean' || val == null) {
401
+ return `${val}`;
402
+ }
403
+ if (type == 'string') {
404
+ return `"${val}"`;
405
+ }
406
+ if (type == 'symbol') {
407
+ const description = val.description;
408
+ if (description == null) {
409
+ return 'Symbol';
410
+ } else {
411
+ return `Symbol(${description})`;
412
+ }
413
+ }
414
+ if (type == 'function') {
415
+ const name = val.name;
416
+ if (typeof name == 'string' && name.length > 0) {
417
+ return `Function(${name})`;
418
+ } else {
419
+ return 'Function';
420
+ }
421
+ }
422
+ // objects
423
+ if (Array.isArray(val)) {
424
+ const length = val.length;
425
+ let debug = '[';
426
+ if (length > 0) {
427
+ debug += debugString(val[0]);
428
+ }
429
+ for(let i = 1; i < length; i++) {
430
+ debug += ', ' + debugString(val[i]);
431
+ }
432
+ debug += ']';
433
+ return debug;
434
+ }
435
+ // Test for built-in
436
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
437
+ let className;
438
+ if (builtInMatches && builtInMatches.length > 1) {
439
+ className = builtInMatches[1];
440
+ } else {
441
+ // Failed to match the standard '[object ClassName]'
442
+ return toString.call(val);
443
+ }
444
+ if (className == 'Object') {
445
+ // we're a user defined class or Object
446
+ // JSON.stringify avoids problems with cycles, and is generally much
447
+ // easier than looping through ownProperties of `val`.
448
+ try {
449
+ return 'Object(' + JSON.stringify(val) + ')';
450
+ } catch (_) {
451
+ return 'Object';
452
+ }
453
+ }
454
+ // errors
455
+ if (val instanceof Error) {
456
+ return `${val.name}: ${val.message}\n${val.stack}`;
457
+ }
458
+ // TODO we could test for more things here, like `Set`s and `Map`s.
459
+ return className;
460
+ }
461
+
462
+ function getArrayU8FromWasm0(ptr, len) {
463
+ ptr = ptr >>> 0;
464
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
465
+ }
466
+
467
+ let cachedDataViewMemory0 = null;
468
+ function getDataViewMemory0() {
469
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
470
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
471
+ }
472
+ return cachedDataViewMemory0;
473
+ }
474
+
475
+ function getStringFromWasm0(ptr, len) {
476
+ return decodeText(ptr >>> 0, len);
477
+ }
478
+
479
+ let cachedUint8ArrayMemory0 = null;
480
+ function getUint8ArrayMemory0() {
481
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
482
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
483
+ }
484
+ return cachedUint8ArrayMemory0;
485
+ }
486
+
487
+ function handleError(f, args) {
488
+ try {
489
+ return f.apply(this, args);
490
+ } catch (e) {
491
+ const idx = addToExternrefTable0(e);
492
+ wasm.__wbindgen_exn_store(idx);
493
+ }
494
+ }
495
+
496
+ function isLikeNone(x) {
497
+ return x === undefined || x === null;
498
+ }
499
+
500
+ function makeMutClosure(arg0, arg1, f) {
501
+ const state = { a: arg0, b: arg1, cnt: 1 };
502
+ const real = (...args) => {
503
+
504
+ // First up with a closure we increment the internal reference
505
+ // count. This ensures that the Rust closure environment won't
506
+ // be deallocated while we're invoking it.
507
+ state.cnt++;
508
+ const a = state.a;
509
+ state.a = 0;
510
+ try {
511
+ return f(a, state.b, ...args);
512
+ } finally {
513
+ state.a = a;
514
+ real._wbg_cb_unref();
515
+ }
516
+ };
517
+ real._wbg_cb_unref = () => {
518
+ if (--state.cnt === 0) {
519
+ wasm.__wbindgen_destroy_closure(state.a, state.b);
520
+ state.a = 0;
521
+ CLOSURE_DTORS.unregister(state);
522
+ }
523
+ };
524
+ CLOSURE_DTORS.register(real, state, state);
525
+ return real;
526
+ }
527
+
528
+ function passStringToWasm0(arg, malloc, realloc) {
529
+ if (realloc === undefined) {
530
+ const buf = cachedTextEncoder.encode(arg);
531
+ const ptr = malloc(buf.length, 1) >>> 0;
532
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
533
+ WASM_VECTOR_LEN = buf.length;
534
+ return ptr;
535
+ }
536
+
537
+ let len = arg.length;
538
+ let ptr = malloc(len, 1) >>> 0;
539
+
540
+ const mem = getUint8ArrayMemory0();
541
+
542
+ let offset = 0;
543
+
544
+ for (; offset < len; offset++) {
545
+ const code = arg.charCodeAt(offset);
546
+ if (code > 0x7F) break;
547
+ mem[ptr + offset] = code;
548
+ }
549
+ if (offset !== len) {
550
+ if (offset !== 0) {
551
+ arg = arg.slice(offset);
552
+ }
553
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
554
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
555
+ const ret = cachedTextEncoder.encodeInto(arg, view);
556
+
557
+ offset += ret.written;
558
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
559
+ }
560
+
561
+ WASM_VECTOR_LEN = offset;
562
+ return ptr;
563
+ }
564
+
565
+ function takeFromExternrefTable0(idx) {
566
+ const value = wasm.__wbindgen_externrefs.get(idx);
567
+ wasm.__externref_table_dealloc(idx);
568
+ return value;
569
+ }
570
+
571
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
572
+ cachedTextDecoder.decode();
573
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
574
+ let numBytesDecoded = 0;
575
+ function decodeText(ptr, len) {
576
+ numBytesDecoded += len;
577
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
578
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
579
+ cachedTextDecoder.decode();
580
+ numBytesDecoded = len;
581
+ }
582
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
583
+ }
584
+
585
+ const cachedTextEncoder = new TextEncoder();
586
+
587
+ if (!('encodeInto' in cachedTextEncoder)) {
588
+ cachedTextEncoder.encodeInto = function (arg, view) {
589
+ const buf = cachedTextEncoder.encode(arg);
590
+ view.set(buf);
591
+ return {
592
+ read: arg.length,
593
+ written: buf.length
594
+ };
595
+ };
596
+ }
597
+
598
+ let WASM_VECTOR_LEN = 0;
599
+
600
+ let wasmModule, wasmInstance, wasm;
601
+ function __wbg_finalize_init(instance, module) {
602
+ wasmInstance = instance;
603
+ wasm = instance.exports;
604
+ wasmModule = module;
605
+ cachedDataViewMemory0 = null;
606
+ cachedUint8ArrayMemory0 = null;
607
+ wasm.__wbindgen_start();
608
+ return wasm;
609
+ }
610
+
611
+ async function __wbg_load(module, imports) {
612
+ if (typeof Response === 'function' && module instanceof Response) {
613
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
614
+ try {
615
+ return await WebAssembly.instantiateStreaming(module, imports);
616
+ } catch (e) {
617
+ const validResponse = module.ok && expectedResponseType(module.type);
618
+
619
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
620
+ 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);
621
+
622
+ } else { throw e; }
623
+ }
624
+ }
625
+
626
+ const bytes = await module.arrayBuffer();
627
+ return await WebAssembly.instantiate(bytes, imports);
628
+ } else {
629
+ const instance = await WebAssembly.instantiate(module, imports);
630
+
631
+ if (instance instanceof WebAssembly.Instance) {
632
+ return { instance, module };
633
+ } else {
634
+ return instance;
635
+ }
636
+ }
637
+
638
+ function expectedResponseType(type) {
639
+ switch (type) {
640
+ case 'basic': case 'cors': case 'default': return true;
641
+ }
642
+ return false;
643
+ }
644
+ }
645
+
646
+ function initSync(module) {
647
+ if (wasm !== undefined) return wasm;
648
+
649
+
650
+ if (module !== undefined) {
651
+ if (Object.getPrototypeOf(module) === Object.prototype) {
652
+ ({module} = module)
653
+ } else {
654
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
655
+ }
656
+ }
657
+
658
+ const imports = __wbg_get_imports();
659
+ if (!(module instanceof WebAssembly.Module)) {
660
+ module = new WebAssembly.Module(module);
661
+ }
662
+ const instance = new WebAssembly.Instance(module, imports);
663
+ return __wbg_finalize_init(instance, module);
664
+ }
665
+
666
+ async function __wbg_init(module_or_path) {
667
+ if (wasm !== undefined) return wasm;
668
+
669
+
670
+ if (module_or_path !== undefined) {
671
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
672
+ ({module_or_path} = module_or_path)
673
+ } else {
674
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
675
+ }
676
+ }
677
+
678
+ if (module_or_path === undefined) {
679
+ module_or_path = new URL('swls_wasm_bg.wasm', import.meta.url);
680
+ }
681
+ const imports = __wbg_get_imports();
682
+
683
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
684
+ module_or_path = fetch(module_or_path);
685
+ }
686
+
687
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
688
+
689
+ return __wbg_finalize_init(instance, module);
690
+ }
691
+
692
+ export { initSync, __wbg_init as default };
package/swls_wasm_bg.wasm CHANGED
Binary file