@benrogmans/lemma-engine 0.6.9 → 0.7.4

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/lemma.js CHANGED
@@ -1,305 +1,1087 @@
1
- let wasm;
1
+ /* @ts-self-types="./lemma.d.ts" */
2
+ import { bytes_literal } from './snippets/wasm-streams-42e57edbcd526312/inline0.js';
2
3
 
3
- let cachedUint8ArrayMemory0 = null;
4
-
5
- function getUint8ArrayMemory0() {
6
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
7
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
4
+ export class IntoUnderlyingByteSource {
5
+ __destroy_into_raw() {
6
+ const ptr = this.__wbg_ptr;
7
+ this.__wbg_ptr = 0;
8
+ IntoUnderlyingByteSourceFinalization.unregister(this);
9
+ return ptr;
10
+ }
11
+ free() {
12
+ const ptr = this.__destroy_into_raw();
13
+ wasm.__wbg_intounderlyingbytesource_free(ptr, 0);
14
+ }
15
+ /**
16
+ * @returns {number}
17
+ */
18
+ get autoAllocateChunkSize() {
19
+ const ret = wasm.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr);
20
+ return ret >>> 0;
21
+ }
22
+ cancel() {
23
+ const ptr = this.__destroy_into_raw();
24
+ wasm.intounderlyingbytesource_cancel(ptr);
25
+ }
26
+ /**
27
+ * @param {any} controller
28
+ * @returns {Promise<any>}
29
+ */
30
+ pull(controller) {
31
+ const ret = wasm.intounderlyingbytesource_pull(this.__wbg_ptr, addHeapObject(controller));
32
+ return takeObject(ret);
33
+ }
34
+ /**
35
+ * @param {any} controller
36
+ */
37
+ start(controller) {
38
+ wasm.intounderlyingbytesource_start(this.__wbg_ptr, addHeapObject(controller));
39
+ }
40
+ /**
41
+ * @returns {any}
42
+ */
43
+ get type() {
44
+ const ret = wasm.intounderlyingbytesource_type(this.__wbg_ptr);
45
+ return takeObject(ret);
8
46
  }
9
- return cachedUint8ArrayMemory0;
10
47
  }
48
+ if (Symbol.dispose) IntoUnderlyingByteSource.prototype[Symbol.dispose] = IntoUnderlyingByteSource.prototype.free;
11
49
 
12
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
13
-
14
- cachedTextDecoder.decode();
15
-
16
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
17
- let numBytesDecoded = 0;
18
- function decodeText(ptr, len) {
19
- numBytesDecoded += len;
20
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
21
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
22
- cachedTextDecoder.decode();
23
- numBytesDecoded = len;
50
+ export class IntoUnderlyingSink {
51
+ __destroy_into_raw() {
52
+ const ptr = this.__wbg_ptr;
53
+ this.__wbg_ptr = 0;
54
+ IntoUnderlyingSinkFinalization.unregister(this);
55
+ return ptr;
56
+ }
57
+ free() {
58
+ const ptr = this.__destroy_into_raw();
59
+ wasm.__wbg_intounderlyingsink_free(ptr, 0);
60
+ }
61
+ /**
62
+ * @param {any} reason
63
+ * @returns {Promise<any>}
64
+ */
65
+ abort(reason) {
66
+ const ptr = this.__destroy_into_raw();
67
+ const ret = wasm.intounderlyingsink_abort(ptr, addHeapObject(reason));
68
+ return takeObject(ret);
69
+ }
70
+ /**
71
+ * @returns {Promise<any>}
72
+ */
73
+ close() {
74
+ const ptr = this.__destroy_into_raw();
75
+ const ret = wasm.intounderlyingsink_close(ptr);
76
+ return takeObject(ret);
77
+ }
78
+ /**
79
+ * @param {any} chunk
80
+ * @returns {Promise<any>}
81
+ */
82
+ write(chunk) {
83
+ const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, addHeapObject(chunk));
84
+ return takeObject(ret);
24
85
  }
25
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
26
86
  }
87
+ if (Symbol.dispose) IntoUnderlyingSink.prototype[Symbol.dispose] = IntoUnderlyingSink.prototype.free;
27
88
 
28
- function getStringFromWasm0(ptr, len) {
29
- ptr = ptr >>> 0;
30
- return decodeText(ptr, len);
89
+ export class IntoUnderlyingSource {
90
+ __destroy_into_raw() {
91
+ const ptr = this.__wbg_ptr;
92
+ this.__wbg_ptr = 0;
93
+ IntoUnderlyingSourceFinalization.unregister(this);
94
+ return ptr;
95
+ }
96
+ free() {
97
+ const ptr = this.__destroy_into_raw();
98
+ wasm.__wbg_intounderlyingsource_free(ptr, 0);
99
+ }
100
+ cancel() {
101
+ const ptr = this.__destroy_into_raw();
102
+ wasm.intounderlyingsource_cancel(ptr);
103
+ }
104
+ /**
105
+ * @param {any} controller
106
+ * @returns {Promise<any>}
107
+ */
108
+ pull(controller) {
109
+ const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, addHeapObject(controller));
110
+ return takeObject(ret);
111
+ }
31
112
  }
113
+ if (Symbol.dispose) IntoUnderlyingSource.prototype[Symbol.dispose] = IntoUnderlyingSource.prototype.free;
32
114
 
33
- let WASM_VECTOR_LEN = 0;
34
-
35
- const cachedTextEncoder = new TextEncoder();
36
-
37
- if (!('encodeInto' in cachedTextEncoder)) {
38
- cachedTextEncoder.encodeInto = function (arg, view) {
39
- const buf = cachedTextEncoder.encode(arg);
40
- view.set(buf);
41
- return {
42
- read: arg.length,
43
- written: buf.length
44
- };
115
+ /**
116
+ * Raw options for [`pipeTo()`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/pipeTo).
117
+ */
118
+ export class PipeOptions {
119
+ __destroy_into_raw() {
120
+ const ptr = this.__wbg_ptr;
121
+ this.__wbg_ptr = 0;
122
+ PipeOptionsFinalization.unregister(this);
123
+ return ptr;
124
+ }
125
+ free() {
126
+ const ptr = this.__destroy_into_raw();
127
+ wasm.__wbg_pipeoptions_free(ptr, 0);
128
+ }
129
+ /**
130
+ * @returns {boolean}
131
+ */
132
+ get preventAbort() {
133
+ const ret = wasm.pipeoptions_preventAbort(this.__wbg_ptr);
134
+ return ret !== 0;
135
+ }
136
+ /**
137
+ * @returns {boolean}
138
+ */
139
+ get preventCancel() {
140
+ const ret = wasm.pipeoptions_preventCancel(this.__wbg_ptr);
141
+ return ret !== 0;
142
+ }
143
+ /**
144
+ * @returns {boolean}
145
+ */
146
+ get preventClose() {
147
+ const ret = wasm.pipeoptions_preventClose(this.__wbg_ptr);
148
+ return ret !== 0;
149
+ }
150
+ /**
151
+ * @returns {AbortSignal | undefined}
152
+ */
153
+ get signal() {
154
+ const ret = wasm.pipeoptions_signal(this.__wbg_ptr);
155
+ return takeObject(ret);
45
156
  }
46
157
  }
158
+ if (Symbol.dispose) PipeOptions.prototype[Symbol.dispose] = PipeOptions.prototype.free;
47
159
 
48
- function passStringToWasm0(arg, malloc, realloc) {
49
-
50
- if (realloc === undefined) {
51
- const buf = cachedTextEncoder.encode(arg);
52
- const ptr = malloc(buf.length, 1) >>> 0;
53
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
54
- WASM_VECTOR_LEN = buf.length;
160
+ export class QueuingStrategy {
161
+ __destroy_into_raw() {
162
+ const ptr = this.__wbg_ptr;
163
+ this.__wbg_ptr = 0;
164
+ QueuingStrategyFinalization.unregister(this);
55
165
  return ptr;
56
166
  }
57
-
58
- let len = arg.length;
59
- let ptr = malloc(len, 1) >>> 0;
60
-
61
- const mem = getUint8ArrayMemory0();
62
-
63
- let offset = 0;
64
-
65
- for (; offset < len; offset++) {
66
- const code = arg.charCodeAt(offset);
67
- if (code > 0x7F) break;
68
- mem[ptr + offset] = code;
167
+ free() {
168
+ const ptr = this.__destroy_into_raw();
169
+ wasm.__wbg_queuingstrategy_free(ptr, 0);
69
170
  }
70
-
71
- if (offset !== len) {
72
- if (offset !== 0) {
73
- arg = arg.slice(offset);
74
- }
75
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
76
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
77
- const ret = cachedTextEncoder.encodeInto(arg, view);
78
-
79
- offset += ret.written;
80
- ptr = realloc(ptr, len, offset, 1) >>> 0;
171
+ /**
172
+ * @returns {number}
173
+ */
174
+ get highWaterMark() {
175
+ const ret = wasm.queuingstrategy_highWaterMark(this.__wbg_ptr);
176
+ return ret;
81
177
  }
82
-
83
- WASM_VECTOR_LEN = offset;
84
- return ptr;
85
178
  }
179
+ if (Symbol.dispose) QueuingStrategy.prototype[Symbol.dispose] = QueuingStrategy.prototype.free;
86
180
 
87
- let cachedDataViewMemory0 = null;
88
-
89
- function getDataViewMemory0() {
90
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
91
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
181
+ /**
182
+ * Raw options for [`getReader()`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/getReader).
183
+ */
184
+ export class ReadableStreamGetReaderOptions {
185
+ __destroy_into_raw() {
186
+ const ptr = this.__wbg_ptr;
187
+ this.__wbg_ptr = 0;
188
+ ReadableStreamGetReaderOptionsFinalization.unregister(this);
189
+ return ptr;
190
+ }
191
+ free() {
192
+ const ptr = this.__destroy_into_raw();
193
+ wasm.__wbg_readablestreamgetreaderoptions_free(ptr, 0);
194
+ }
195
+ /**
196
+ * @returns {ReadableStreamReaderMode}
197
+ */
198
+ get mode() {
199
+ const ret = wasm.readablestreamgetreaderoptions_mode(this.__wbg_ptr);
200
+ return __wbindgen_enum_ReadableStreamReaderMode[ret];
92
201
  }
93
- return cachedDataViewMemory0;
94
202
  }
203
+ if (Symbol.dispose) ReadableStreamGetReaderOptions.prototype[Symbol.dispose] = ReadableStreamGetReaderOptions.prototype.free;
95
204
 
96
- const WasmEngineFinalization = (typeof FinalizationRegistry === 'undefined')
97
- ? { register: () => {}, unregister: () => {} }
98
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmengine_free(ptr >>> 0, 1));
205
+ export class ServerConfig {
206
+ __destroy_into_raw() {
207
+ const ptr = this.__wbg_ptr;
208
+ this.__wbg_ptr = 0;
209
+ ServerConfigFinalization.unregister(this);
210
+ return ptr;
211
+ }
212
+ free() {
213
+ const ptr = this.__destroy_into_raw();
214
+ wasm.__wbg_serverconfig_free(ptr, 0);
215
+ }
216
+ /**
217
+ * @param {AsyncIterator<any>} into_server
218
+ * @param {WritableStream} from_server
219
+ */
220
+ constructor(into_server, from_server) {
221
+ const ret = wasm.serverconfig_new(addHeapObject(into_server), addHeapObject(from_server));
222
+ this.__wbg_ptr = ret >>> 0;
223
+ ServerConfigFinalization.register(this, this.__wbg_ptr, this);
224
+ return this;
225
+ }
226
+ }
227
+ if (Symbol.dispose) ServerConfig.prototype[Symbol.dispose] = ServerConfig.prototype.free;
99
228
 
100
229
  export class WasmEngine {
101
-
102
230
  __destroy_into_raw() {
103
231
  const ptr = this.__wbg_ptr;
104
232
  this.__wbg_ptr = 0;
105
233
  WasmEngineFinalization.unregister(this);
106
234
  return ptr;
107
235
  }
108
-
109
236
  free() {
110
237
  const ptr = this.__destroy_into_raw();
111
238
  wasm.__wbg_wasmengine_free(ptr, 0);
112
239
  }
113
240
  /**
241
+ * Add Lemma source (e.g. file contents). Returns a Promise that resolves to a JSON string result.
114
242
  * @param {string} code
115
243
  * @param {string} source
244
+ * @returns {Promise<any>}
245
+ */
246
+ addLemmaFile(code, source) {
247
+ const ptr0 = passStringToWasm0(code, wasm.__wbindgen_export, wasm.__wbindgen_export2);
248
+ const len0 = WASM_VECTOR_LEN;
249
+ const ptr1 = passStringToWasm0(source, wasm.__wbindgen_export, wasm.__wbindgen_export2);
250
+ const len1 = WASM_VECTOR_LEN;
251
+ const ret = wasm.wasmengine_addLemmaFile(this.__wbg_ptr, ptr0, len0, ptr1, len1);
252
+ return takeObject(ret);
253
+ }
254
+ /**
255
+ * Evaluate rules in a document.
256
+ *
257
+ * Pass `rule_names_json` as `"[]"` or `""` to evaluate all rules.
258
+ * Pass a JSON array like `'["total","discount"]'` to evaluate specific rules.
259
+ * @param {string} doc_name
260
+ * @param {string} rule_names_json
261
+ * @param {string} fact_values_json
262
+ * @returns {string}
263
+ */
264
+ evaluate(doc_name, rule_names_json, fact_values_json) {
265
+ let deferred4_0;
266
+ let deferred4_1;
267
+ try {
268
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
269
+ const ptr0 = passStringToWasm0(doc_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
270
+ const len0 = WASM_VECTOR_LEN;
271
+ const ptr1 = passStringToWasm0(rule_names_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
272
+ const len1 = WASM_VECTOR_LEN;
273
+ const ptr2 = passStringToWasm0(fact_values_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
274
+ const len2 = WASM_VECTOR_LEN;
275
+ wasm.wasmengine_evaluate(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
276
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
277
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
278
+ deferred4_0 = r0;
279
+ deferred4_1 = r1;
280
+ return getStringFromWasm0(r0, r1);
281
+ } finally {
282
+ wasm.__wbindgen_add_to_stack_pointer(16);
283
+ wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
284
+ }
285
+ }
286
+ /**
287
+ * Format Lemma source code. Returns a JSON string: `{ "success": true, "formatted": "..." }`
288
+ * or `{ "success": false, "error": "..." }`. Only formats if the source parses successfully.
289
+ * Call from JS (e.g. Monaco playground) to implement "Format" without an LSP; there is no on-save in the browser.
290
+ * @param {string} code
291
+ * @param {string} source_attribute
116
292
  * @returns {string}
117
293
  */
118
- addLemmaCode(code, source) {
294
+ formatSource(code, source_attribute) {
119
295
  let deferred3_0;
120
296
  let deferred3_1;
121
297
  try {
122
- const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
298
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
299
+ const ptr0 = passStringToWasm0(code, wasm.__wbindgen_export, wasm.__wbindgen_export2);
123
300
  const len0 = WASM_VECTOR_LEN;
124
- const ptr1 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
301
+ const ptr1 = passStringToWasm0(source_attribute, wasm.__wbindgen_export, wasm.__wbindgen_export2);
125
302
  const len1 = WASM_VECTOR_LEN;
126
- const ret = wasm.wasmengine_addLemmaCode(this.__wbg_ptr, ptr0, len0, ptr1, len1);
127
- deferred3_0 = ret[0];
128
- deferred3_1 = ret[1];
129
- return getStringFromWasm0(ret[0], ret[1]);
303
+ wasm.wasmengine_formatSource(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
304
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
305
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
306
+ deferred3_0 = r0;
307
+ deferred3_1 = r1;
308
+ return getStringFromWasm0(r0, r1);
130
309
  } finally {
131
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
310
+ wasm.__wbindgen_add_to_stack_pointer(16);
311
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
132
312
  }
133
313
  }
134
314
  /**
315
+ * Return the full document schema: all facts and rules with their types.
316
+ *
317
+ * Returns the `DocumentSchema` used by all Lemma interfaces, serialized as
318
+ * JSON. Use `getSchema` with specific rule names to get only the facts
319
+ * required by those rules.
320
+ * @param {string} doc_name
321
+ * @param {string} rule_names_json
135
322
  * @returns {string}
136
323
  */
137
- listDocuments() {
138
- let deferred1_0;
139
- let deferred1_1;
324
+ getSchema(doc_name, rule_names_json) {
325
+ let deferred3_0;
326
+ let deferred3_1;
140
327
  try {
141
- const ret = wasm.wasmengine_listDocuments(this.__wbg_ptr);
142
- deferred1_0 = ret[0];
143
- deferred1_1 = ret[1];
144
- return getStringFromWasm0(ret[0], ret[1]);
328
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
329
+ const ptr0 = passStringToWasm0(doc_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
330
+ const len0 = WASM_VECTOR_LEN;
331
+ const ptr1 = passStringToWasm0(rule_names_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
332
+ const len1 = WASM_VECTOR_LEN;
333
+ wasm.wasmengine_getSchema(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
334
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
335
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
336
+ deferred3_0 = r0;
337
+ deferred3_1 = r1;
338
+ return getStringFromWasm0(r0, r1);
145
339
  } finally {
146
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
340
+ wasm.__wbindgen_add_to_stack_pointer(16);
341
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
147
342
  }
148
343
  }
149
- constructor() {
150
- const ret = wasm.wasmengine_new();
151
- this.__wbg_ptr = ret >>> 0;
152
- WasmEngineFinalization.register(this, this.__wbg_ptr, this);
153
- return this;
154
- }
155
344
  /**
156
- * @param {string} doc_name
157
- * @param {string} rule_name
158
- * @param {string} target_json
159
- * @param {string} given_facts_json
345
+ * @param {string} _doc_name
346
+ * @param {string} _rule_name
347
+ * @param {string} _target_json
348
+ * @param {string} _provided_values_json
160
349
  * @returns {string}
161
350
  */
162
- invert(doc_name, rule_name, target_json, given_facts_json) {
351
+ invert(_doc_name, _rule_name, _target_json, _provided_values_json) {
163
352
  let deferred5_0;
164
353
  let deferred5_1;
165
354
  try {
166
- const ptr0 = passStringToWasm0(doc_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
355
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
356
+ const ptr0 = passStringToWasm0(_doc_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
167
357
  const len0 = WASM_VECTOR_LEN;
168
- const ptr1 = passStringToWasm0(rule_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
358
+ const ptr1 = passStringToWasm0(_rule_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
169
359
  const len1 = WASM_VECTOR_LEN;
170
- const ptr2 = passStringToWasm0(target_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
360
+ const ptr2 = passStringToWasm0(_target_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
171
361
  const len2 = WASM_VECTOR_LEN;
172
- const ptr3 = passStringToWasm0(given_facts_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
362
+ const ptr3 = passStringToWasm0(_provided_values_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
173
363
  const len3 = WASM_VECTOR_LEN;
174
- const ret = wasm.wasmengine_invert(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
175
- deferred5_0 = ret[0];
176
- deferred5_1 = ret[1];
177
- return getStringFromWasm0(ret[0], ret[1]);
364
+ wasm.wasmengine_invert(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
365
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
366
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
367
+ deferred5_0 = r0;
368
+ deferred5_1 = r1;
369
+ return getStringFromWasm0(r0, r1);
178
370
  } finally {
179
- wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
371
+ wasm.__wbindgen_add_to_stack_pointer(16);
372
+ wasm.__wbindgen_export4(deferred5_0, deferred5_1, 1);
180
373
  }
181
374
  }
182
375
  /**
183
- * @param {string} doc_name
184
- * @param {string} fact_values_json
376
+ * List all loaded documents with their full schemas.
377
+ *
378
+ * Returns `{ success: true, documents: [DocumentSchema, ...] }` sorted by
379
+ * document name, consistent with the HTTP and MCP interfaces.
185
380
  * @returns {string}
186
381
  */
187
- evaluate(doc_name, fact_values_json) {
188
- let deferred3_0;
189
- let deferred3_1;
382
+ listDocuments() {
383
+ let deferred1_0;
384
+ let deferred1_1;
190
385
  try {
191
- const ptr0 = passStringToWasm0(doc_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
192
- const len0 = WASM_VECTOR_LEN;
193
- const ptr1 = passStringToWasm0(fact_values_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
194
- const len1 = WASM_VECTOR_LEN;
195
- const ret = wasm.wasmengine_evaluate(this.__wbg_ptr, ptr0, len0, ptr1, len1);
196
- deferred3_0 = ret[0];
197
- deferred3_1 = ret[1];
198
- return getStringFromWasm0(ret[0], ret[1]);
386
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
387
+ wasm.wasmengine_listDocuments(retptr, this.__wbg_ptr);
388
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
389
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
390
+ deferred1_0 = r0;
391
+ deferred1_1 = r1;
392
+ return getStringFromWasm0(r0, r1);
199
393
  } finally {
200
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
394
+ wasm.__wbindgen_add_to_stack_pointer(16);
395
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
201
396
  }
202
397
  }
398
+ constructor() {
399
+ const ret = wasm.wasmengine_new();
400
+ this.__wbg_ptr = ret >>> 0;
401
+ WasmEngineFinalization.register(this, this.__wbg_ptr, this);
402
+ return this;
403
+ }
203
404
  }
204
405
  if (Symbol.dispose) WasmEngine.prototype[Symbol.dispose] = WasmEngine.prototype.free;
205
406
 
206
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
407
+ /**
408
+ * Run the Lemma LSP over the given streams. Call from JS after creating
409
+ * an AsyncIterator (client → server messages) and a WritableStream (server → client).
410
+ * @param {ServerConfig} config
411
+ * @returns {Promise<void>}
412
+ */
413
+ export function serve(config) {
414
+ _assertClass(config, ServerConfig);
415
+ var ptr0 = config.__destroy_into_raw();
416
+ const ret = wasm.serve(ptr0);
417
+ return takeObject(ret);
418
+ }
207
419
 
208
- async function __wbg_load(module, imports) {
209
- if (typeof Response === 'function' && module instanceof Response) {
210
- if (typeof WebAssembly.instantiateStreaming === 'function') {
420
+ function __wbg_get_imports() {
421
+ const import0 = {
422
+ __proto__: null,
423
+ __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
424
+ const ret = debugString(getObject(arg1));
425
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
426
+ const len1 = WASM_VECTOR_LEN;
427
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
428
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
429
+ },
430
+ __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
431
+ const ret = typeof(getObject(arg0)) === 'function';
432
+ return ret;
433
+ },
434
+ __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
435
+ const val = getObject(arg0);
436
+ const ret = typeof(val) === 'object' && val !== null;
437
+ return ret;
438
+ },
439
+ __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
440
+ const ret = getObject(arg0) === undefined;
441
+ return ret;
442
+ },
443
+ __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
444
+ const obj = getObject(arg1);
445
+ const ret = typeof(obj) === 'string' ? obj : undefined;
446
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
447
+ var len1 = WASM_VECTOR_LEN;
448
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
449
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
450
+ },
451
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
452
+ throw new Error(getStringFromWasm0(arg0, arg1));
453
+ },
454
+ __wbg__wbg_cb_unref_d9b87ff7982e3b21: function(arg0) {
455
+ getObject(arg0)._wbg_cb_unref();
456
+ },
457
+ __wbg_buffer_e0346dab6225d121: function(arg0) {
458
+ const ret = getObject(arg0).buffer;
459
+ return addHeapObject(ret);
460
+ },
461
+ __wbg_byobRequest_338ee64e53ddd87b: function(arg0) {
462
+ const ret = getObject(arg0).byobRequest;
463
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
464
+ },
465
+ __wbg_byteLength_96fd6c084c1a7a0d: function(arg0) {
466
+ const ret = getObject(arg0).byteLength;
467
+ return ret;
468
+ },
469
+ __wbg_byteOffset_c9e81ef47dca6819: function(arg0) {
470
+ const ret = getObject(arg0).byteOffset;
471
+ return ret;
472
+ },
473
+ __wbg_bytes_literal_aea1dac9bf84850e: function() {
474
+ const ret = bytes_literal();
475
+ return addHeapObject(ret);
476
+ },
477
+ __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
478
+ const ret = getObject(arg0).call(getObject(arg1));
479
+ return addHeapObject(ret);
480
+ }, arguments); },
481
+ __wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {
482
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
483
+ return addHeapObject(ret);
484
+ }, arguments); },
485
+ __wbg_close_7c18aa67b8539098: function(arg0) {
486
+ getObject(arg0).close();
487
+ },
488
+ __wbg_close_7c324b6e045f281a: function(arg0) {
489
+ getObject(arg0).close();
490
+ },
491
+ __wbg_close_c40d5219e03385a2: function(arg0) {
492
+ const ret = getObject(arg0).close();
493
+ return addHeapObject(ret);
494
+ },
495
+ __wbg_done_57b39ecd9addfe81: function(arg0) {
496
+ const ret = getObject(arg0).done;
497
+ return ret;
498
+ },
499
+ __wbg_enqueue_6c79790ce6e00627: function(arg0, arg1) {
500
+ getObject(arg0).enqueue(getObject(arg1));
501
+ },
502
+ __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
503
+ let deferred0_0;
504
+ let deferred0_1;
211
505
  try {
212
- return await WebAssembly.instantiateStreaming(module, imports);
506
+ deferred0_0 = arg0;
507
+ deferred0_1 = arg1;
508
+ console.error(getStringFromWasm0(arg0, arg1));
509
+ } finally {
510
+ wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
511
+ }
512
+ },
513
+ __wbg_fetch_a9bc66c159c18e19: function(arg0) {
514
+ const ret = fetch(getObject(arg0));
515
+ return addHeapObject(ret);
516
+ },
517
+ __wbg_getWriter_1d11da1210cc84ba: function() { return handleError(function (arg0) {
518
+ const ret = getObject(arg0).getWriter();
519
+ return addHeapObject(ret);
520
+ }, arguments); },
521
+ __wbg_instanceof_Error_8573fe0b0b480f46: function(arg0) {
522
+ let result;
523
+ try {
524
+ result = getObject(arg0) instanceof Error;
525
+ } catch (_) {
526
+ result = false;
527
+ }
528
+ const ret = result;
529
+ return ret;
530
+ },
531
+ __wbg_instanceof_Response_ee1d54d79ae41977: function(arg0) {
532
+ let result;
533
+ try {
534
+ result = getObject(arg0) instanceof Response;
535
+ } catch (_) {
536
+ result = false;
537
+ }
538
+ const ret = result;
539
+ return ret;
540
+ },
541
+ __wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
542
+ let result;
543
+ try {
544
+ result = getObject(arg0) instanceof Uint8Array;
545
+ } catch (_) {
546
+ result = false;
547
+ }
548
+ const ret = result;
549
+ return ret;
550
+ },
551
+ __wbg_length_32ed9a279acd054c: function(arg0) {
552
+ const ret = getObject(arg0).length;
553
+ return ret;
554
+ },
555
+ __wbg_message_9ddc4b9a62a7c379: function(arg0) {
556
+ const ret = getObject(arg0).message;
557
+ return addHeapObject(ret);
558
+ },
559
+ __wbg_name_446e25ef2cfdab5a: function(arg0) {
560
+ const ret = getObject(arg0).name;
561
+ return addHeapObject(ret);
562
+ },
563
+ __wbg_new_074b505417ada2d9: function() { return handleError(function () {
564
+ const ret = new URLSearchParams();
565
+ return addHeapObject(ret);
566
+ }, arguments); },
567
+ __wbg_new_361308b2356cecd0: function() {
568
+ const ret = new Object();
569
+ return addHeapObject(ret);
570
+ },
571
+ __wbg_new_64284bd487f9d239: function() { return handleError(function () {
572
+ const ret = new Headers();
573
+ return addHeapObject(ret);
574
+ }, arguments); },
575
+ __wbg_new_72b49615380db768: function(arg0, arg1) {
576
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
577
+ return addHeapObject(ret);
578
+ },
579
+ __wbg_new_8a6f238a6ece86ea: function() {
580
+ const ret = new Error();
581
+ return addHeapObject(ret);
582
+ },
583
+ __wbg_new_b5d9e2fb389fef91: function(arg0, arg1) {
584
+ try {
585
+ var state0 = {a: arg0, b: arg1};
586
+ var cb0 = (arg0, arg1) => {
587
+ const a = state0.a;
588
+ state0.a = 0;
589
+ try {
590
+ return __wasm_bindgen_func_elem_9930(a, state0.b, arg0, arg1);
591
+ } finally {
592
+ state0.a = a;
593
+ }
594
+ };
595
+ const ret = new Promise(cb0);
596
+ return addHeapObject(ret);
597
+ } finally {
598
+ state0.a = state0.b = 0;
599
+ }
600
+ },
601
+ __wbg_new_c2f21774701ddac7: function() { return handleError(function (arg0, arg1) {
602
+ const ret = new URL(getStringFromWasm0(arg0, arg1));
603
+ return addHeapObject(ret);
604
+ }, arguments); },
605
+ __wbg_new_from_slice_a3d2629dc1826784: function(arg0, arg1) {
606
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
607
+ return addHeapObject(ret);
608
+ },
609
+ __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
610
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
611
+ return addHeapObject(ret);
612
+ },
613
+ __wbg_new_with_byte_offset_and_length_aa261d9c9da49eb1: function(arg0, arg1, arg2) {
614
+ const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
615
+ return addHeapObject(ret);
616
+ },
617
+ __wbg_new_with_str_a7c7f835549b152a: function() { return handleError(function (arg0, arg1) {
618
+ const ret = new Request(getStringFromWasm0(arg0, arg1));
619
+ return addHeapObject(ret);
620
+ }, arguments); },
621
+ __wbg_new_with_str_and_init_a61cbc6bdef21614: function() { return handleError(function (arg0, arg1, arg2) {
622
+ const ret = new Request(getStringFromWasm0(arg0, arg1), getObject(arg2));
623
+ return addHeapObject(ret);
624
+ }, arguments); },
625
+ __wbg_next_0a5e0f8af98146aa: function() { return handleError(function (arg0) {
626
+ const ret = getObject(arg0).next();
627
+ return addHeapObject(ret);
628
+ }, arguments); },
629
+ __wbg_ok_87f537440a0acf85: function(arg0) {
630
+ const ret = getObject(arg0).ok;
631
+ return ret;
632
+ },
633
+ __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
634
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
635
+ },
636
+ __wbg_queueMicrotask_0aa0a927f78f5d98: function(arg0) {
637
+ const ret = getObject(arg0).queueMicrotask;
638
+ return addHeapObject(ret);
639
+ },
640
+ __wbg_queueMicrotask_5bb536982f78a56f: function(arg0) {
641
+ queueMicrotask(getObject(arg0));
642
+ },
643
+ __wbg_ready_2258e8118fee9761: function(arg0) {
644
+ const ret = getObject(arg0).ready;
645
+ return addHeapObject(ret);
646
+ },
647
+ __wbg_releaseLock_aea38d9ddf66ea11: function(arg0) {
648
+ getObject(arg0).releaseLock();
649
+ },
650
+ __wbg_resolve_002c4b7d9d8f6b64: function(arg0) {
651
+ const ret = Promise.resolve(getObject(arg0));
652
+ return addHeapObject(ret);
653
+ },
654
+ __wbg_respond_f90c76a13ed2dae9: function(arg0, arg1) {
655
+ getObject(arg0).respond(arg1 >>> 0);
656
+ },
657
+ __wbg_search_143f09a35047e800: function(arg0, arg1) {
658
+ const ret = getObject(arg1).search;
659
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
660
+ const len1 = WASM_VECTOR_LEN;
661
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
662
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
663
+ },
664
+ __wbg_set_cc56eefd2dd91957: function(arg0, arg1, arg2) {
665
+ getObject(arg0).set(getArrayU8FromWasm0(arg1, arg2));
666
+ },
667
+ __wbg_set_headers_cfc5f4b2c1f20549: function(arg0, arg1) {
668
+ getObject(arg0).headers = getObject(arg1);
669
+ },
670
+ __wbg_set_method_c3e20375f5ae7fac: function(arg0, arg1, arg2) {
671
+ getObject(arg0).method = getStringFromWasm0(arg1, arg2);
672
+ },
673
+ __wbg_set_search_1d369b0f3868e132: function(arg0, arg1, arg2) {
674
+ getObject(arg0).search = getStringFromWasm0(arg1, arg2);
675
+ },
676
+ __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
677
+ const ret = getObject(arg1).stack;
678
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
679
+ const len1 = WASM_VECTOR_LEN;
680
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
681
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
682
+ },
683
+ __wbg_static_accessor_GLOBAL_12837167ad935116: function() {
684
+ const ret = typeof global === 'undefined' ? null : global;
685
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
686
+ },
687
+ __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
688
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
689
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
690
+ },
691
+ __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
692
+ const ret = typeof self === 'undefined' ? null : self;
693
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
694
+ },
695
+ __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
696
+ const ret = typeof window === 'undefined' ? null : window;
697
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
698
+ },
699
+ __wbg_status_89d7e803db911ee7: function(arg0) {
700
+ const ret = getObject(arg0).status;
701
+ return ret;
702
+ },
703
+ __wbg_text_083b8727c990c8c0: function() { return handleError(function (arg0) {
704
+ const ret = getObject(arg0).text();
705
+ return addHeapObject(ret);
706
+ }, arguments); },
707
+ __wbg_then_0d9fe2c7b1857d32: function(arg0, arg1, arg2) {
708
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
709
+ return addHeapObject(ret);
710
+ },
711
+ __wbg_then_b9e7b3b5f1a9e1b5: function(arg0, arg1) {
712
+ const ret = getObject(arg0).then(getObject(arg1));
713
+ return addHeapObject(ret);
714
+ },
715
+ __wbg_toString_029ac24421fd7a24: function(arg0) {
716
+ const ret = getObject(arg0).toString();
717
+ return addHeapObject(ret);
718
+ },
719
+ __wbg_toString_964ff7fe6eca8362: function(arg0) {
720
+ const ret = getObject(arg0).toString();
721
+ return addHeapObject(ret);
722
+ },
723
+ __wbg_url_36c39f6580d05409: function(arg0, arg1) {
724
+ const ret = getObject(arg1).url;
725
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
726
+ const len1 = WASM_VECTOR_LEN;
727
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
728
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
729
+ },
730
+ __wbg_value_0546255b415e96c1: function(arg0) {
731
+ const ret = getObject(arg0).value;
732
+ return addHeapObject(ret);
733
+ },
734
+ __wbg_view_b29b448440a527c0: function(arg0) {
735
+ const ret = getObject(arg0).view;
736
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
737
+ },
738
+ __wbg_write_c4a2180120884395: function(arg0, arg1) {
739
+ const ret = getObject(arg0).write(takeObject(arg1));
740
+ return addHeapObject(ret);
741
+ },
742
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
743
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1159, function: Function { arguments: [Externref], shim_idx: 1160, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
744
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_8774, __wasm_bindgen_func_elem_8789);
745
+ return addHeapObject(ret);
746
+ },
747
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
748
+ // Cast intrinsic for `Ref(String) -> Externref`.
749
+ const ret = getStringFromWasm0(arg0, arg1);
750
+ return addHeapObject(ret);
751
+ },
752
+ __wbindgen_object_clone_ref: function(arg0) {
753
+ const ret = getObject(arg0);
754
+ return addHeapObject(ret);
755
+ },
756
+ __wbindgen_object_drop_ref: function(arg0) {
757
+ takeObject(arg0);
758
+ },
759
+ };
760
+ return {
761
+ __proto__: null,
762
+ "./lemma_bg.js": import0,
763
+ };
764
+ }
213
765
 
214
- } catch (e) {
215
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
766
+ function __wasm_bindgen_func_elem_8789(arg0, arg1, arg2) {
767
+ wasm.__wasm_bindgen_func_elem_8789(arg0, arg1, addHeapObject(arg2));
768
+ }
216
769
 
217
- if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
218
- 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);
770
+ function __wasm_bindgen_func_elem_9930(arg0, arg1, arg2, arg3) {
771
+ wasm.__wasm_bindgen_func_elem_9930(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
772
+ }
219
773
 
220
- } else {
221
- throw e;
222
- }
223
- }
224
- }
225
774
 
226
- const bytes = await module.arrayBuffer();
227
- return await WebAssembly.instantiate(bytes, imports);
775
+ const __wbindgen_enum_ReadableStreamReaderMode = ["byob"];
776
+ const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined')
777
+ ? { register: () => {}, unregister: () => {} }
778
+ : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0, 1));
779
+ const IntoUnderlyingSinkFinalization = (typeof FinalizationRegistry === 'undefined')
780
+ ? { register: () => {}, unregister: () => {} }
781
+ : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsink_free(ptr >>> 0, 1));
782
+ const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined')
783
+ ? { register: () => {}, unregister: () => {} }
784
+ : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0, 1));
785
+ const PipeOptionsFinalization = (typeof FinalizationRegistry === 'undefined')
786
+ ? { register: () => {}, unregister: () => {} }
787
+ : new FinalizationRegistry(ptr => wasm.__wbg_pipeoptions_free(ptr >>> 0, 1));
788
+ const QueuingStrategyFinalization = (typeof FinalizationRegistry === 'undefined')
789
+ ? { register: () => {}, unregister: () => {} }
790
+ : new FinalizationRegistry(ptr => wasm.__wbg_queuingstrategy_free(ptr >>> 0, 1));
791
+ const ReadableStreamGetReaderOptionsFinalization = (typeof FinalizationRegistry === 'undefined')
792
+ ? { register: () => {}, unregister: () => {} }
793
+ : new FinalizationRegistry(ptr => wasm.__wbg_readablestreamgetreaderoptions_free(ptr >>> 0, 1));
794
+ const ServerConfigFinalization = (typeof FinalizationRegistry === 'undefined')
795
+ ? { register: () => {}, unregister: () => {} }
796
+ : new FinalizationRegistry(ptr => wasm.__wbg_serverconfig_free(ptr >>> 0, 1));
797
+ const WasmEngineFinalization = (typeof FinalizationRegistry === 'undefined')
798
+ ? { register: () => {}, unregister: () => {} }
799
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmengine_free(ptr >>> 0, 1));
228
800
 
229
- } else {
230
- const instance = await WebAssembly.instantiate(module, imports);
801
+ function addHeapObject(obj) {
802
+ if (heap_next === heap.length) heap.push(heap.length + 1);
803
+ const idx = heap_next;
804
+ heap_next = heap[idx];
231
805
 
232
- if (instance instanceof WebAssembly.Instance) {
233
- return { instance, module };
806
+ heap[idx] = obj;
807
+ return idx;
808
+ }
809
+
810
+ function _assertClass(instance, klass) {
811
+ if (!(instance instanceof klass)) {
812
+ throw new Error(`expected instance of ${klass.name}`);
813
+ }
814
+ }
815
+
816
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
817
+ ? { register: () => {}, unregister: () => {} }
818
+ : new FinalizationRegistry(state => state.dtor(state.a, state.b));
234
819
 
820
+ function debugString(val) {
821
+ // primitive types
822
+ const type = typeof val;
823
+ if (type == 'number' || type == 'boolean' || val == null) {
824
+ return `${val}`;
825
+ }
826
+ if (type == 'string') {
827
+ return `"${val}"`;
828
+ }
829
+ if (type == 'symbol') {
830
+ const description = val.description;
831
+ if (description == null) {
832
+ return 'Symbol';
235
833
  } else {
236
- return instance;
834
+ return `Symbol(${description})`;
237
835
  }
238
836
  }
837
+ if (type == 'function') {
838
+ const name = val.name;
839
+ if (typeof name == 'string' && name.length > 0) {
840
+ return `Function(${name})`;
841
+ } else {
842
+ return 'Function';
843
+ }
844
+ }
845
+ // objects
846
+ if (Array.isArray(val)) {
847
+ const length = val.length;
848
+ let debug = '[';
849
+ if (length > 0) {
850
+ debug += debugString(val[0]);
851
+ }
852
+ for(let i = 1; i < length; i++) {
853
+ debug += ', ' + debugString(val[i]);
854
+ }
855
+ debug += ']';
856
+ return debug;
857
+ }
858
+ // Test for built-in
859
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
860
+ let className;
861
+ if (builtInMatches && builtInMatches.length > 1) {
862
+ className = builtInMatches[1];
863
+ } else {
864
+ // Failed to match the standard '[object ClassName]'
865
+ return toString.call(val);
866
+ }
867
+ if (className == 'Object') {
868
+ // we're a user defined class or Object
869
+ // JSON.stringify avoids problems with cycles, and is generally much
870
+ // easier than looping through ownProperties of `val`.
871
+ try {
872
+ return 'Object(' + JSON.stringify(val) + ')';
873
+ } catch (_) {
874
+ return 'Object';
875
+ }
876
+ }
877
+ // errors
878
+ if (val instanceof Error) {
879
+ return `${val.name}: ${val.message}\n${val.stack}`;
880
+ }
881
+ // TODO we could test for more things here, like `Set`s and `Map`s.
882
+ return className;
239
883
  }
240
884
 
241
- function __wbg_get_imports() {
242
- const imports = {};
243
- imports.wbg = {};
244
- imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
245
- let deferred0_0;
246
- let deferred0_1;
885
+ function dropObject(idx) {
886
+ if (idx < 132) return;
887
+ heap[idx] = heap_next;
888
+ heap_next = idx;
889
+ }
890
+
891
+ function getArrayU8FromWasm0(ptr, len) {
892
+ ptr = ptr >>> 0;
893
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
894
+ }
895
+
896
+ let cachedDataViewMemory0 = null;
897
+ function getDataViewMemory0() {
898
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
899
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
900
+ }
901
+ return cachedDataViewMemory0;
902
+ }
903
+
904
+ function getStringFromWasm0(ptr, len) {
905
+ ptr = ptr >>> 0;
906
+ return decodeText(ptr, len);
907
+ }
908
+
909
+ let cachedUint8ArrayMemory0 = null;
910
+ function getUint8ArrayMemory0() {
911
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
912
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
913
+ }
914
+ return cachedUint8ArrayMemory0;
915
+ }
916
+
917
+ function getObject(idx) { return heap[idx]; }
918
+
919
+ function handleError(f, args) {
920
+ try {
921
+ return f.apply(this, args);
922
+ } catch (e) {
923
+ wasm.__wbindgen_export3(addHeapObject(e));
924
+ }
925
+ }
926
+
927
+ let heap = new Array(128).fill(undefined);
928
+ heap.push(undefined, null, true, false);
929
+
930
+ let heap_next = heap.length;
931
+
932
+ function isLikeNone(x) {
933
+ return x === undefined || x === null;
934
+ }
935
+
936
+ function makeMutClosure(arg0, arg1, dtor, f) {
937
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
938
+ const real = (...args) => {
939
+
940
+ // First up with a closure we increment the internal reference
941
+ // count. This ensures that the Rust closure environment won't
942
+ // be deallocated while we're invoking it.
943
+ state.cnt++;
944
+ const a = state.a;
945
+ state.a = 0;
247
946
  try {
248
- deferred0_0 = arg0;
249
- deferred0_1 = arg1;
250
- console.error(getStringFromWasm0(arg0, arg1));
947
+ return f(a, state.b, ...args);
251
948
  } finally {
252
- wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
949
+ state.a = a;
950
+ real._wbg_cb_unref();
253
951
  }
254
952
  };
255
- imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
256
- const ret = new Error();
257
- return ret;
258
- };
259
- imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
260
- const ret = arg1.stack;
261
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
262
- const len1 = WASM_VECTOR_LEN;
263
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
264
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
265
- };
266
- imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function(arg0, arg1) {
267
- throw new Error(getStringFromWasm0(arg0, arg1));
268
- };
269
- imports.wbg.__wbindgen_init_externref_table = function() {
270
- const table = wasm.__wbindgen_export_3;
271
- const offset = table.grow(4);
272
- table.set(0, undefined);
273
- table.set(offset + 0, undefined);
274
- table.set(offset + 1, null);
275
- table.set(offset + 2, true);
276
- table.set(offset + 3, false);
277
- ;
953
+ real._wbg_cb_unref = () => {
954
+ if (--state.cnt === 0) {
955
+ state.dtor(state.a, state.b);
956
+ state.a = 0;
957
+ CLOSURE_DTORS.unregister(state);
958
+ }
278
959
  };
960
+ CLOSURE_DTORS.register(real, state, state);
961
+ return real;
962
+ }
963
+
964
+ function passStringToWasm0(arg, malloc, realloc) {
965
+ if (realloc === undefined) {
966
+ const buf = cachedTextEncoder.encode(arg);
967
+ const ptr = malloc(buf.length, 1) >>> 0;
968
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
969
+ WASM_VECTOR_LEN = buf.length;
970
+ return ptr;
971
+ }
972
+
973
+ let len = arg.length;
974
+ let ptr = malloc(len, 1) >>> 0;
975
+
976
+ const mem = getUint8ArrayMemory0();
977
+
978
+ let offset = 0;
279
979
 
280
- return imports;
980
+ for (; offset < len; offset++) {
981
+ const code = arg.charCodeAt(offset);
982
+ if (code > 0x7F) break;
983
+ mem[ptr + offset] = code;
984
+ }
985
+ if (offset !== len) {
986
+ if (offset !== 0) {
987
+ arg = arg.slice(offset);
988
+ }
989
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
990
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
991
+ const ret = cachedTextEncoder.encodeInto(arg, view);
992
+
993
+ offset += ret.written;
994
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
995
+ }
996
+
997
+ WASM_VECTOR_LEN = offset;
998
+ return ptr;
999
+ }
1000
+
1001
+ function takeObject(idx) {
1002
+ const ret = getObject(idx);
1003
+ dropObject(idx);
1004
+ return ret;
1005
+ }
1006
+
1007
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1008
+ cachedTextDecoder.decode();
1009
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1010
+ let numBytesDecoded = 0;
1011
+ function decodeText(ptr, len) {
1012
+ numBytesDecoded += len;
1013
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1014
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1015
+ cachedTextDecoder.decode();
1016
+ numBytesDecoded = len;
1017
+ }
1018
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
281
1019
  }
282
1020
 
283
- function __wbg_init_memory(imports, memory) {
1021
+ const cachedTextEncoder = new TextEncoder();
284
1022
 
1023
+ if (!('encodeInto' in cachedTextEncoder)) {
1024
+ cachedTextEncoder.encodeInto = function (arg, view) {
1025
+ const buf = cachedTextEncoder.encode(arg);
1026
+ view.set(buf);
1027
+ return {
1028
+ read: arg.length,
1029
+ written: buf.length
1030
+ };
1031
+ };
285
1032
  }
286
1033
 
1034
+ let WASM_VECTOR_LEN = 0;
1035
+
1036
+ let wasmModule, wasm;
287
1037
  function __wbg_finalize_init(instance, module) {
288
1038
  wasm = instance.exports;
289
- __wbg_init.__wbindgen_wasm_module = module;
1039
+ wasmModule = module;
290
1040
  cachedDataViewMemory0 = null;
291
1041
  cachedUint8ArrayMemory0 = null;
1042
+ return wasm;
1043
+ }
1044
+
1045
+ async function __wbg_load(module, imports) {
1046
+ if (typeof Response === 'function' && module instanceof Response) {
1047
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1048
+ try {
1049
+ return await WebAssembly.instantiateStreaming(module, imports);
1050
+ } catch (e) {
1051
+ const validResponse = module.ok && expectedResponseType(module.type);
292
1052
 
1053
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1054
+ 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);
293
1055
 
294
- wasm.__wbindgen_start();
295
- return wasm;
1056
+ } else { throw e; }
1057
+ }
1058
+ }
1059
+
1060
+ const bytes = await module.arrayBuffer();
1061
+ return await WebAssembly.instantiate(bytes, imports);
1062
+ } else {
1063
+ const instance = await WebAssembly.instantiate(module, imports);
1064
+
1065
+ if (instance instanceof WebAssembly.Instance) {
1066
+ return { instance, module };
1067
+ } else {
1068
+ return instance;
1069
+ }
1070
+ }
1071
+
1072
+ function expectedResponseType(type) {
1073
+ switch (type) {
1074
+ case 'basic': case 'cors': case 'default': return true;
1075
+ }
1076
+ return false;
1077
+ }
296
1078
  }
297
1079
 
298
1080
  function initSync(module) {
299
1081
  if (wasm !== undefined) return wasm;
300
1082
 
301
1083
 
302
- if (typeof module !== 'undefined') {
1084
+ if (module !== undefined) {
303
1085
  if (Object.getPrototypeOf(module) === Object.prototype) {
304
1086
  ({module} = module)
305
1087
  } else {
@@ -308,15 +1090,10 @@ function initSync(module) {
308
1090
  }
309
1091
 
310
1092
  const imports = __wbg_get_imports();
311
-
312
- __wbg_init_memory(imports);
313
-
314
1093
  if (!(module instanceof WebAssembly.Module)) {
315
1094
  module = new WebAssembly.Module(module);
316
1095
  }
317
-
318
1096
  const instance = new WebAssembly.Instance(module, imports);
319
-
320
1097
  return __wbg_finalize_init(instance, module);
321
1098
  }
322
1099
 
@@ -324,7 +1101,7 @@ async function __wbg_init(module_or_path) {
324
1101
  if (wasm !== undefined) return wasm;
325
1102
 
326
1103
 
327
- if (typeof module_or_path !== 'undefined') {
1104
+ if (module_or_path !== undefined) {
328
1105
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
329
1106
  ({module_or_path} = module_or_path)
330
1107
  } else {
@@ -332,7 +1109,7 @@ async function __wbg_init(module_or_path) {
332
1109
  }
333
1110
  }
334
1111
 
335
- if (typeof module_or_path === 'undefined') {
1112
+ if (module_or_path === undefined) {
336
1113
  module_or_path = new URL('lemma_bg.wasm', import.meta.url);
337
1114
  }
338
1115
  const imports = __wbg_get_imports();
@@ -341,12 +1118,9 @@ async function __wbg_init(module_or_path) {
341
1118
  module_or_path = fetch(module_or_path);
342
1119
  }
343
1120
 
344
- __wbg_init_memory(imports);
345
-
346
1121
  const { instance, module } = await __wbg_load(await module_or_path, imports);
347
1122
 
348
1123
  return __wbg_finalize_init(instance, module);
349
1124
  }
350
1125
 
351
- export { initSync };
352
- export default __wbg_init;
1126
+ export { initSync, __wbg_init as default };