@sema-lang/sema-wasm 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Helge Sverre
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @sema-lang/sema-wasm
2
+
3
+ Low-level WebAssembly bindings for the Sema Lisp interpreter.
4
+
5
+ > **Most users should use [`@sema-lang/sema`](https://www.npmjs.com/package/@sema-lang/sema) instead**, which provides a higher-level API.
6
+
7
+ This package contains the raw wasm-bindgen output and is a dependency of `@sema-lang/sema`.
8
+
9
+ ## License
10
+
11
+ MIT
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@sema-lang/sema-wasm",
3
+ "type": "module",
4
+ "description": "WebAssembly bindings for the Sema Lisp interpreter",
5
+ "version": "1.9.0",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/helgesverre/sema"
10
+ },
11
+ "files": [
12
+ "sema_wasm_bg.wasm",
13
+ "sema_wasm.js",
14
+ "sema_wasm.d.ts"
15
+ ],
16
+ "main": "sema_wasm.js",
17
+ "homepage": "https://sema-lang.com",
18
+ "types": "sema_wasm.d.ts",
19
+ "sideEffects": [
20
+ "./snippets/*"
21
+ ]
22
+ }
package/sema_wasm.d.ts ADDED
@@ -0,0 +1,141 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export class SemaInterpreter {
5
+ free(): void;
6
+ [Symbol.dispose](): void;
7
+ /**
8
+ * Create interpreter with options: {stdlib: false, deny: ["network", "fs-write"]}
9
+ */
10
+ static createWithOptions(opts: any): SemaInterpreter;
11
+ /**
12
+ * Delete a file from the virtual filesystem. Returns true if the file existed.
13
+ */
14
+ deleteFile(path: string): boolean;
15
+ /**
16
+ * Evaluate code, returns JSON: {"value": "...", "output": ["...", ...], "error": null}
17
+ * or {"value": null, "output": [...], "error": "..."}
18
+ */
19
+ eval(code: string): any;
20
+ /**
21
+ * Evaluate code with async HTTP support (tree-walker, global env)
22
+ */
23
+ evalAsync(code: string): Promise<any>;
24
+ /**
25
+ * Evaluate in the global env so defines persist
26
+ */
27
+ evalGlobal(code: string): any;
28
+ /**
29
+ * Evaluate code via the bytecode VM, returns same JSON format as eval_global
30
+ */
31
+ evalVM(code: string): any;
32
+ /**
33
+ * Evaluate code with async HTTP support (bytecode VM)
34
+ */
35
+ evalVMAsync(code: string): Promise<any>;
36
+ /**
37
+ * Check if a path exists in the virtual filesystem (file or directory).
38
+ */
39
+ fileExists(path: string): boolean;
40
+ /**
41
+ * Check if a path is a directory in the virtual filesystem.
42
+ */
43
+ isDirectory(path: string): boolean;
44
+ /**
45
+ * List files and directories in the given directory path.
46
+ */
47
+ listFiles(dir: string): any;
48
+ /**
49
+ * Create a directory in the virtual filesystem.
50
+ */
51
+ mkdir(path: string): void;
52
+ constructor();
53
+ /**
54
+ * Inject a virtual module so that `(import "name")` resolves without a file.
55
+ */
56
+ preloadModule(name: string, source: string): any;
57
+ /**
58
+ * Read a file from the virtual filesystem.
59
+ */
60
+ readFile(path: string): any;
61
+ /**
62
+ * Register a JavaScript function callable from Sema code.
63
+ */
64
+ registerFunction(name: string, callback: Function): void;
65
+ /**
66
+ * Clear all files and directories from the virtual filesystem.
67
+ */
68
+ resetVFS(): void;
69
+ /**
70
+ * Get the Sema version
71
+ */
72
+ version(): string;
73
+ /**
74
+ * Get VFS usage statistics.
75
+ */
76
+ vfsStats(): any;
77
+ /**
78
+ * Write a file to the virtual filesystem.
79
+ */
80
+ writeFile(path: string, content: string): any;
81
+ }
82
+
83
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
84
+
85
+ export interface InitOutput {
86
+ readonly memory: WebAssembly.Memory;
87
+ readonly __wbg_semainterpreter_free: (a: number, b: number) => void;
88
+ readonly semainterpreter_createWithOptions: (a: any) => number;
89
+ readonly semainterpreter_deleteFile: (a: number, b: number, c: number) => number;
90
+ readonly semainterpreter_eval: (a: number, b: number, c: number) => any;
91
+ readonly semainterpreter_evalAsync: (a: number, b: number, c: number) => any;
92
+ readonly semainterpreter_evalGlobal: (a: number, b: number, c: number) => any;
93
+ readonly semainterpreter_evalVM: (a: number, b: number, c: number) => any;
94
+ readonly semainterpreter_evalVMAsync: (a: number, b: number, c: number) => any;
95
+ readonly semainterpreter_fileExists: (a: number, b: number, c: number) => number;
96
+ readonly semainterpreter_isDirectory: (a: number, b: number, c: number) => number;
97
+ readonly semainterpreter_listFiles: (a: number, b: number, c: number) => any;
98
+ readonly semainterpreter_mkdir: (a: number, b: number, c: number) => void;
99
+ readonly semainterpreter_new: () => number;
100
+ readonly semainterpreter_preloadModule: (a: number, b: number, c: number, d: number, e: number) => any;
101
+ readonly semainterpreter_readFile: (a: number, b: number, c: number) => any;
102
+ readonly semainterpreter_registerFunction: (a: number, b: number, c: number, d: any) => void;
103
+ readonly semainterpreter_resetVFS: (a: number) => void;
104
+ readonly semainterpreter_version: (a: number) => [number, number];
105
+ readonly semainterpreter_vfsStats: (a: number) => any;
106
+ readonly semainterpreter_writeFile: (a: number, b: number, c: number, d: number, e: number) => any;
107
+ readonly wasm_bindgen__closure__destroy__h314ef490acbd67e8: (a: number, b: number) => void;
108
+ readonly wasm_bindgen__closure__destroy__hb68fa90d76766184: (a: number, b: number) => void;
109
+ readonly wasm_bindgen__convert__closures_____invoke__h093bbd4247ddbb1f: (a: number, b: number, c: any, d: any) => void;
110
+ readonly wasm_bindgen__convert__closures_____invoke__h673540737fa6ed2e: (a: number, b: number, c: any) => void;
111
+ readonly wasm_bindgen__convert__closures_____invoke__h7778f7020d33629c: (a: number, b: number) => void;
112
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
113
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
114
+ readonly __wbindgen_exn_store: (a: number) => void;
115
+ readonly __externref_table_alloc: () => number;
116
+ readonly __wbindgen_externrefs: WebAssembly.Table;
117
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
118
+ readonly __wbindgen_start: () => void;
119
+ }
120
+
121
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
122
+
123
+ /**
124
+ * Instantiates the given `module`, which can either be bytes or
125
+ * a precompiled `WebAssembly.Module`.
126
+ *
127
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
128
+ *
129
+ * @returns {InitOutput}
130
+ */
131
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
132
+
133
+ /**
134
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
135
+ * for everything else, calls `WebAssembly.instantiate` directly.
136
+ *
137
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
138
+ *
139
+ * @returns {Promise<InitOutput>}
140
+ */
141
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
package/sema_wasm.js ADDED
@@ -0,0 +1,853 @@
1
+ /* @ts-self-types="./sema_wasm.d.ts" */
2
+
3
+ export class SemaInterpreter {
4
+ static __wrap(ptr) {
5
+ ptr = ptr >>> 0;
6
+ const obj = Object.create(SemaInterpreter.prototype);
7
+ obj.__wbg_ptr = ptr;
8
+ SemaInterpreterFinalization.register(obj, obj.__wbg_ptr, obj);
9
+ return obj;
10
+ }
11
+ __destroy_into_raw() {
12
+ const ptr = this.__wbg_ptr;
13
+ this.__wbg_ptr = 0;
14
+ SemaInterpreterFinalization.unregister(this);
15
+ return ptr;
16
+ }
17
+ free() {
18
+ const ptr = this.__destroy_into_raw();
19
+ wasm.__wbg_semainterpreter_free(ptr, 0);
20
+ }
21
+ /**
22
+ * Create interpreter with options: {stdlib: false, deny: ["network", "fs-write"]}
23
+ * @param {any} opts
24
+ * @returns {SemaInterpreter}
25
+ */
26
+ static createWithOptions(opts) {
27
+ const ret = wasm.semainterpreter_createWithOptions(opts);
28
+ return SemaInterpreter.__wrap(ret);
29
+ }
30
+ /**
31
+ * Delete a file from the virtual filesystem. Returns true if the file existed.
32
+ * @param {string} path
33
+ * @returns {boolean}
34
+ */
35
+ deleteFile(path) {
36
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
37
+ const len0 = WASM_VECTOR_LEN;
38
+ const ret = wasm.semainterpreter_deleteFile(this.__wbg_ptr, ptr0, len0);
39
+ return ret !== 0;
40
+ }
41
+ /**
42
+ * Evaluate code, returns JSON: {"value": "...", "output": ["...", ...], "error": null}
43
+ * or {"value": null, "output": [...], "error": "..."}
44
+ * @param {string} code
45
+ * @returns {any}
46
+ */
47
+ eval(code) {
48
+ const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
49
+ const len0 = WASM_VECTOR_LEN;
50
+ const ret = wasm.semainterpreter_eval(this.__wbg_ptr, ptr0, len0);
51
+ return ret;
52
+ }
53
+ /**
54
+ * Evaluate code with async HTTP support (tree-walker, global env)
55
+ * @param {string} code
56
+ * @returns {Promise<any>}
57
+ */
58
+ evalAsync(code) {
59
+ const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
60
+ const len0 = WASM_VECTOR_LEN;
61
+ const ret = wasm.semainterpreter_evalAsync(this.__wbg_ptr, ptr0, len0);
62
+ return ret;
63
+ }
64
+ /**
65
+ * Evaluate in the global env so defines persist
66
+ * @param {string} code
67
+ * @returns {any}
68
+ */
69
+ evalGlobal(code) {
70
+ const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
71
+ const len0 = WASM_VECTOR_LEN;
72
+ const ret = wasm.semainterpreter_evalGlobal(this.__wbg_ptr, ptr0, len0);
73
+ return ret;
74
+ }
75
+ /**
76
+ * Evaluate code via the bytecode VM, returns same JSON format as eval_global
77
+ * @param {string} code
78
+ * @returns {any}
79
+ */
80
+ evalVM(code) {
81
+ const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
82
+ const len0 = WASM_VECTOR_LEN;
83
+ const ret = wasm.semainterpreter_evalVM(this.__wbg_ptr, ptr0, len0);
84
+ return ret;
85
+ }
86
+ /**
87
+ * Evaluate code with async HTTP support (bytecode VM)
88
+ * @param {string} code
89
+ * @returns {Promise<any>}
90
+ */
91
+ evalVMAsync(code) {
92
+ const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
93
+ const len0 = WASM_VECTOR_LEN;
94
+ const ret = wasm.semainterpreter_evalVMAsync(this.__wbg_ptr, ptr0, len0);
95
+ return ret;
96
+ }
97
+ /**
98
+ * Check if a path exists in the virtual filesystem (file or directory).
99
+ * @param {string} path
100
+ * @returns {boolean}
101
+ */
102
+ fileExists(path) {
103
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
104
+ const len0 = WASM_VECTOR_LEN;
105
+ const ret = wasm.semainterpreter_fileExists(this.__wbg_ptr, ptr0, len0);
106
+ return ret !== 0;
107
+ }
108
+ /**
109
+ * Check if a path is a directory in the virtual filesystem.
110
+ * @param {string} path
111
+ * @returns {boolean}
112
+ */
113
+ isDirectory(path) {
114
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
115
+ const len0 = WASM_VECTOR_LEN;
116
+ const ret = wasm.semainterpreter_isDirectory(this.__wbg_ptr, ptr0, len0);
117
+ return ret !== 0;
118
+ }
119
+ /**
120
+ * List files and directories in the given directory path.
121
+ * @param {string} dir
122
+ * @returns {any}
123
+ */
124
+ listFiles(dir) {
125
+ const ptr0 = passStringToWasm0(dir, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
126
+ const len0 = WASM_VECTOR_LEN;
127
+ const ret = wasm.semainterpreter_listFiles(this.__wbg_ptr, ptr0, len0);
128
+ return ret;
129
+ }
130
+ /**
131
+ * Create a directory in the virtual filesystem.
132
+ * @param {string} path
133
+ */
134
+ mkdir(path) {
135
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136
+ const len0 = WASM_VECTOR_LEN;
137
+ wasm.semainterpreter_mkdir(this.__wbg_ptr, ptr0, len0);
138
+ }
139
+ constructor() {
140
+ const ret = wasm.semainterpreter_new();
141
+ this.__wbg_ptr = ret >>> 0;
142
+ SemaInterpreterFinalization.register(this, this.__wbg_ptr, this);
143
+ return this;
144
+ }
145
+ /**
146
+ * Inject a virtual module so that `(import "name")` resolves without a file.
147
+ * @param {string} name
148
+ * @param {string} source
149
+ * @returns {any}
150
+ */
151
+ preloadModule(name, source) {
152
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
153
+ const len0 = WASM_VECTOR_LEN;
154
+ const ptr1 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
155
+ const len1 = WASM_VECTOR_LEN;
156
+ const ret = wasm.semainterpreter_preloadModule(this.__wbg_ptr, ptr0, len0, ptr1, len1);
157
+ return ret;
158
+ }
159
+ /**
160
+ * Read a file from the virtual filesystem.
161
+ * @param {string} path
162
+ * @returns {any}
163
+ */
164
+ readFile(path) {
165
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
166
+ const len0 = WASM_VECTOR_LEN;
167
+ const ret = wasm.semainterpreter_readFile(this.__wbg_ptr, ptr0, len0);
168
+ return ret;
169
+ }
170
+ /**
171
+ * Register a JavaScript function callable from Sema code.
172
+ * @param {string} name
173
+ * @param {Function} callback
174
+ */
175
+ registerFunction(name, callback) {
176
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
177
+ const len0 = WASM_VECTOR_LEN;
178
+ wasm.semainterpreter_registerFunction(this.__wbg_ptr, ptr0, len0, callback);
179
+ }
180
+ /**
181
+ * Clear all files and directories from the virtual filesystem.
182
+ */
183
+ resetVFS() {
184
+ wasm.semainterpreter_resetVFS(this.__wbg_ptr);
185
+ }
186
+ /**
187
+ * Get the Sema version
188
+ * @returns {string}
189
+ */
190
+ version() {
191
+ let deferred1_0;
192
+ let deferred1_1;
193
+ try {
194
+ const ret = wasm.semainterpreter_version(this.__wbg_ptr);
195
+ deferred1_0 = ret[0];
196
+ deferred1_1 = ret[1];
197
+ return getStringFromWasm0(ret[0], ret[1]);
198
+ } finally {
199
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
200
+ }
201
+ }
202
+ /**
203
+ * Get VFS usage statistics.
204
+ * @returns {any}
205
+ */
206
+ vfsStats() {
207
+ const ret = wasm.semainterpreter_vfsStats(this.__wbg_ptr);
208
+ return ret;
209
+ }
210
+ /**
211
+ * Write a file to the virtual filesystem.
212
+ * @param {string} path
213
+ * @param {string} content
214
+ * @returns {any}
215
+ */
216
+ writeFile(path, content) {
217
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
218
+ const len0 = WASM_VECTOR_LEN;
219
+ const ptr1 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
220
+ const len1 = WASM_VECTOR_LEN;
221
+ const ret = wasm.semainterpreter_writeFile(this.__wbg_ptr, ptr0, len0, ptr1, len1);
222
+ return ret;
223
+ }
224
+ }
225
+ if (Symbol.dispose) SemaInterpreter.prototype[Symbol.dispose] = SemaInterpreter.prototype.free;
226
+
227
+ function __wbg_get_imports() {
228
+ const import0 = {
229
+ __proto__: null,
230
+ __wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
231
+ const v = arg0;
232
+ const ret = typeof(v) === 'boolean' ? v : undefined;
233
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
234
+ },
235
+ __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
236
+ const ret = debugString(arg1);
237
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
238
+ const len1 = WASM_VECTOR_LEN;
239
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
240
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
241
+ },
242
+ __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
243
+ const ret = typeof(arg0) === 'function';
244
+ return ret;
245
+ },
246
+ __wbg___wbindgen_is_null_ac34f5003991759a: function(arg0) {
247
+ const ret = arg0 === null;
248
+ return ret;
249
+ },
250
+ __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
251
+ const val = arg0;
252
+ const ret = typeof(val) === 'object' && val !== null;
253
+ return ret;
254
+ },
255
+ __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
256
+ const ret = arg0 === undefined;
257
+ return ret;
258
+ },
259
+ __wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
260
+ const obj = arg1;
261
+ const ret = typeof(obj) === 'number' ? obj : undefined;
262
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
263
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
264
+ },
265
+ __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
266
+ const obj = arg1;
267
+ const ret = typeof(obj) === 'string' ? obj : undefined;
268
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
269
+ var len1 = WASM_VECTOR_LEN;
270
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
271
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
272
+ },
273
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
274
+ throw new Error(getStringFromWasm0(arg0, arg1));
275
+ },
276
+ __wbg__wbg_cb_unref_d9b87ff7982e3b21: function(arg0) {
277
+ arg0._wbg_cb_unref();
278
+ },
279
+ __wbg_abort_2f0584e03e8e3950: function(arg0) {
280
+ arg0.abort();
281
+ },
282
+ __wbg_apply_ada2ee1a60ac7b3c: function() { return handleError(function (arg0, arg1, arg2) {
283
+ const ret = arg0.apply(arg1, arg2);
284
+ return ret;
285
+ }, arguments); },
286
+ __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
287
+ const ret = arg0.call(arg1);
288
+ return ret;
289
+ }, arguments); },
290
+ __wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {
291
+ const ret = arg0.call(arg1, arg2);
292
+ return ret;
293
+ }, arguments); },
294
+ __wbg_done_57b39ecd9addfe81: function(arg0) {
295
+ const ret = arg0.done;
296
+ return ret;
297
+ },
298
+ __wbg_eval_3f0b9f0cbaf45a34: function() { return handleError(function (arg0, arg1) {
299
+ const ret = eval(getStringFromWasm0(arg0, arg1));
300
+ return ret;
301
+ }, arguments); },
302
+ __wbg_fetch_e6e8e0a221783759: function(arg0, arg1) {
303
+ const ret = arg0.fetch(arg1);
304
+ return ret;
305
+ },
306
+ __wbg_getRandomValues_2a91986308c74a93: function() { return handleError(function (arg0, arg1) {
307
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
308
+ }, arguments); },
309
+ __wbg_getRandomValues_9c5c1b115e142bb8: function() { return handleError(function (arg0, arg1) {
310
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
311
+ }, arguments); },
312
+ __wbg_getTime_1e3cd1391c5c3995: function(arg0) {
313
+ const ret = arg0.getTime();
314
+ return ret;
315
+ },
316
+ __wbg_get_9b94d73e6221f75c: function(arg0, arg1) {
317
+ const ret = arg0[arg1 >>> 0];
318
+ return ret;
319
+ },
320
+ __wbg_get_b3ed3ad4be2bc8ac: function() { return handleError(function (arg0, arg1) {
321
+ const ret = Reflect.get(arg0, arg1);
322
+ return ret;
323
+ }, arguments); },
324
+ __wbg_headers_59a2938db9f80985: function(arg0) {
325
+ const ret = arg0.headers;
326
+ return ret;
327
+ },
328
+ __wbg_headers_5a897f7fee9a0571: function(arg0) {
329
+ const ret = arg0.headers;
330
+ return ret;
331
+ },
332
+ __wbg_instanceof_Response_ee1d54d79ae41977: function(arg0) {
333
+ let result;
334
+ try {
335
+ result = arg0 instanceof Response;
336
+ } catch (_) {
337
+ result = false;
338
+ }
339
+ const ret = result;
340
+ return ret;
341
+ },
342
+ __wbg_instanceof_Window_ed49b2db8df90359: function(arg0) {
343
+ let result;
344
+ try {
345
+ result = arg0 instanceof Window;
346
+ } catch (_) {
347
+ result = false;
348
+ }
349
+ const ret = result;
350
+ return ret;
351
+ },
352
+ __wbg_isArray_d314bb98fcf08331: function(arg0) {
353
+ const ret = Array.isArray(arg0);
354
+ return ret;
355
+ },
356
+ __wbg_iterator_6ff6560ca1568e55: function() {
357
+ const ret = Symbol.iterator;
358
+ return ret;
359
+ },
360
+ __wbg_length_35a7bace40f36eac: function(arg0) {
361
+ const ret = arg0.length;
362
+ return ret;
363
+ },
364
+ __wbg_new_0_73afc35eb544e539: function() {
365
+ const ret = new Date();
366
+ return ret;
367
+ },
368
+ __wbg_new_361308b2356cecd0: function() {
369
+ const ret = new Object();
370
+ return ret;
371
+ },
372
+ __wbg_new_3eb36ae241fe6f44: function() {
373
+ const ret = new Array();
374
+ return ret;
375
+ },
376
+ __wbg_new_b5d9e2fb389fef91: function(arg0, arg1) {
377
+ try {
378
+ var state0 = {a: arg0, b: arg1};
379
+ var cb0 = (arg0, arg1) => {
380
+ const a = state0.a;
381
+ state0.a = 0;
382
+ try {
383
+ return wasm_bindgen__convert__closures_____invoke__h093bbd4247ddbb1f(a, state0.b, arg0, arg1);
384
+ } finally {
385
+ state0.a = a;
386
+ }
387
+ };
388
+ const ret = new Promise(cb0);
389
+ return ret;
390
+ } finally {
391
+ state0.a = state0.b = 0;
392
+ }
393
+ },
394
+ __wbg_new_b949e7f56150a5d1: function() { return handleError(function () {
395
+ const ret = new AbortController();
396
+ return ret;
397
+ }, arguments); },
398
+ __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
399
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
400
+ return ret;
401
+ },
402
+ __wbg_new_with_str_and_init_a61cbc6bdef21614: function() { return handleError(function (arg0, arg1, arg2) {
403
+ const ret = new Request(getStringFromWasm0(arg0, arg1), arg2);
404
+ return ret;
405
+ }, arguments); },
406
+ __wbg_next_3482f54c49e8af19: function() { return handleError(function (arg0) {
407
+ const ret = arg0.next();
408
+ return ret;
409
+ }, arguments); },
410
+ __wbg_next_418f80d8f5303233: function(arg0) {
411
+ const ret = arg0.next;
412
+ return ret;
413
+ },
414
+ __wbg_now_a3af9a2f4bbaa4d1: function() {
415
+ const ret = Date.now();
416
+ return ret;
417
+ },
418
+ __wbg_parse_708461a1feddfb38: function() { return handleError(function (arg0, arg1) {
419
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
420
+ return ret;
421
+ }, arguments); },
422
+ __wbg_push_8ffdcb2063340ba5: function(arg0, arg1) {
423
+ const ret = arg0.push(arg1);
424
+ return ret;
425
+ },
426
+ __wbg_queueMicrotask_0aa0a927f78f5d98: function(arg0) {
427
+ const ret = arg0.queueMicrotask;
428
+ return ret;
429
+ },
430
+ __wbg_queueMicrotask_5bb536982f78a56f: function(arg0) {
431
+ queueMicrotask(arg0);
432
+ },
433
+ __wbg_resolve_002c4b7d9d8f6b64: function(arg0) {
434
+ const ret = Promise.resolve(arg0);
435
+ return ret;
436
+ },
437
+ __wbg_setTimeout_eff32631ea138533: function() { return handleError(function (arg0, arg1, arg2) {
438
+ const ret = arg0.setTimeout(arg1, arg2);
439
+ return ret;
440
+ }, arguments); },
441
+ __wbg_set_body_9a7e00afe3cfe244: function(arg0, arg1) {
442
+ arg0.body = arg1;
443
+ },
444
+ __wbg_set_db769d02949a271d: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
445
+ arg0.set(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
446
+ }, arguments); },
447
+ __wbg_set_method_c3e20375f5ae7fac: function(arg0, arg1, arg2) {
448
+ arg0.method = getStringFromWasm0(arg1, arg2);
449
+ },
450
+ __wbg_set_mode_b13642c312648202: function(arg0, arg1) {
451
+ arg0.mode = __wbindgen_enum_RequestMode[arg1];
452
+ },
453
+ __wbg_set_signal_f2d3f8599248896d: function(arg0, arg1) {
454
+ arg0.signal = arg1;
455
+ },
456
+ __wbg_signal_d1285ecab4ebc5ad: function(arg0) {
457
+ const ret = arg0.signal;
458
+ return ret;
459
+ },
460
+ __wbg_static_accessor_GLOBAL_12837167ad935116: function() {
461
+ const ret = typeof global === 'undefined' ? null : global;
462
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
463
+ },
464
+ __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
465
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
466
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
467
+ },
468
+ __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
469
+ const ret = typeof self === 'undefined' ? null : self;
470
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
471
+ },
472
+ __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
473
+ const ret = typeof window === 'undefined' ? null : window;
474
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
475
+ },
476
+ __wbg_status_89d7e803db911ee7: function(arg0) {
477
+ const ret = arg0.status;
478
+ return ret;
479
+ },
480
+ __wbg_stringify_8d1cc6ff383e8bae: function() { return handleError(function (arg0) {
481
+ const ret = JSON.stringify(arg0);
482
+ return ret;
483
+ }, arguments); },
484
+ __wbg_text_083b8727c990c8c0: function() { return handleError(function (arg0) {
485
+ const ret = arg0.text();
486
+ return ret;
487
+ }, arguments); },
488
+ __wbg_then_0d9fe2c7b1857d32: function(arg0, arg1, arg2) {
489
+ const ret = arg0.then(arg1, arg2);
490
+ return ret;
491
+ },
492
+ __wbg_then_b9e7b3b5f1a9e1b5: function(arg0, arg1) {
493
+ const ret = arg0.then(arg1);
494
+ return ret;
495
+ },
496
+ __wbg_value_0546255b415e96c1: function(arg0) {
497
+ const ret = arg0.value;
498
+ return ret;
499
+ },
500
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
501
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1405, function: Function { arguments: [], shim_idx: 1406, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
502
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h314ef490acbd67e8, wasm_bindgen__convert__closures_____invoke__h7778f7020d33629c);
503
+ return ret;
504
+ },
505
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
506
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1588, function: Function { arguments: [Externref], shim_idx: 1589, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
507
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hb68fa90d76766184, wasm_bindgen__convert__closures_____invoke__h673540737fa6ed2e);
508
+ return ret;
509
+ },
510
+ __wbindgen_cast_0000000000000003: function(arg0) {
511
+ // Cast intrinsic for `F64 -> Externref`.
512
+ const ret = arg0;
513
+ return ret;
514
+ },
515
+ __wbindgen_cast_0000000000000004: function(arg0, arg1) {
516
+ // Cast intrinsic for `Ref(String) -> Externref`.
517
+ const ret = getStringFromWasm0(arg0, arg1);
518
+ return ret;
519
+ },
520
+ __wbindgen_init_externref_table: function() {
521
+ const table = wasm.__wbindgen_externrefs;
522
+ const offset = table.grow(4);
523
+ table.set(0, undefined);
524
+ table.set(offset + 0, undefined);
525
+ table.set(offset + 1, null);
526
+ table.set(offset + 2, true);
527
+ table.set(offset + 3, false);
528
+ },
529
+ };
530
+ return {
531
+ __proto__: null,
532
+ "./sema_wasm_bg.js": import0,
533
+ };
534
+ }
535
+
536
+ function wasm_bindgen__convert__closures_____invoke__h7778f7020d33629c(arg0, arg1) {
537
+ wasm.wasm_bindgen__convert__closures_____invoke__h7778f7020d33629c(arg0, arg1);
538
+ }
539
+
540
+ function wasm_bindgen__convert__closures_____invoke__h673540737fa6ed2e(arg0, arg1, arg2) {
541
+ wasm.wasm_bindgen__convert__closures_____invoke__h673540737fa6ed2e(arg0, arg1, arg2);
542
+ }
543
+
544
+ function wasm_bindgen__convert__closures_____invoke__h093bbd4247ddbb1f(arg0, arg1, arg2, arg3) {
545
+ wasm.wasm_bindgen__convert__closures_____invoke__h093bbd4247ddbb1f(arg0, arg1, arg2, arg3);
546
+ }
547
+
548
+
549
+ const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"];
550
+ const SemaInterpreterFinalization = (typeof FinalizationRegistry === 'undefined')
551
+ ? { register: () => {}, unregister: () => {} }
552
+ : new FinalizationRegistry(ptr => wasm.__wbg_semainterpreter_free(ptr >>> 0, 1));
553
+
554
+ function addToExternrefTable0(obj) {
555
+ const idx = wasm.__externref_table_alloc();
556
+ wasm.__wbindgen_externrefs.set(idx, obj);
557
+ return idx;
558
+ }
559
+
560
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
561
+ ? { register: () => {}, unregister: () => {} }
562
+ : new FinalizationRegistry(state => state.dtor(state.a, state.b));
563
+
564
+ function debugString(val) {
565
+ // primitive types
566
+ const type = typeof val;
567
+ if (type == 'number' || type == 'boolean' || val == null) {
568
+ return `${val}`;
569
+ }
570
+ if (type == 'string') {
571
+ return `"${val}"`;
572
+ }
573
+ if (type == 'symbol') {
574
+ const description = val.description;
575
+ if (description == null) {
576
+ return 'Symbol';
577
+ } else {
578
+ return `Symbol(${description})`;
579
+ }
580
+ }
581
+ if (type == 'function') {
582
+ const name = val.name;
583
+ if (typeof name == 'string' && name.length > 0) {
584
+ return `Function(${name})`;
585
+ } else {
586
+ return 'Function';
587
+ }
588
+ }
589
+ // objects
590
+ if (Array.isArray(val)) {
591
+ const length = val.length;
592
+ let debug = '[';
593
+ if (length > 0) {
594
+ debug += debugString(val[0]);
595
+ }
596
+ for(let i = 1; i < length; i++) {
597
+ debug += ', ' + debugString(val[i]);
598
+ }
599
+ debug += ']';
600
+ return debug;
601
+ }
602
+ // Test for built-in
603
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
604
+ let className;
605
+ if (builtInMatches && builtInMatches.length > 1) {
606
+ className = builtInMatches[1];
607
+ } else {
608
+ // Failed to match the standard '[object ClassName]'
609
+ return toString.call(val);
610
+ }
611
+ if (className == 'Object') {
612
+ // we're a user defined class or Object
613
+ // JSON.stringify avoids problems with cycles, and is generally much
614
+ // easier than looping through ownProperties of `val`.
615
+ try {
616
+ return 'Object(' + JSON.stringify(val) + ')';
617
+ } catch (_) {
618
+ return 'Object';
619
+ }
620
+ }
621
+ // errors
622
+ if (val instanceof Error) {
623
+ return `${val.name}: ${val.message}\n${val.stack}`;
624
+ }
625
+ // TODO we could test for more things here, like `Set`s and `Map`s.
626
+ return className;
627
+ }
628
+
629
+ function getArrayU8FromWasm0(ptr, len) {
630
+ ptr = ptr >>> 0;
631
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
632
+ }
633
+
634
+ let cachedDataViewMemory0 = null;
635
+ function getDataViewMemory0() {
636
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
637
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
638
+ }
639
+ return cachedDataViewMemory0;
640
+ }
641
+
642
+ function getStringFromWasm0(ptr, len) {
643
+ ptr = ptr >>> 0;
644
+ return decodeText(ptr, len);
645
+ }
646
+
647
+ let cachedUint8ArrayMemory0 = null;
648
+ function getUint8ArrayMemory0() {
649
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
650
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
651
+ }
652
+ return cachedUint8ArrayMemory0;
653
+ }
654
+
655
+ function handleError(f, args) {
656
+ try {
657
+ return f.apply(this, args);
658
+ } catch (e) {
659
+ const idx = addToExternrefTable0(e);
660
+ wasm.__wbindgen_exn_store(idx);
661
+ }
662
+ }
663
+
664
+ function isLikeNone(x) {
665
+ return x === undefined || x === null;
666
+ }
667
+
668
+ function makeMutClosure(arg0, arg1, dtor, f) {
669
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
670
+ const real = (...args) => {
671
+
672
+ // First up with a closure we increment the internal reference
673
+ // count. This ensures that the Rust closure environment won't
674
+ // be deallocated while we're invoking it.
675
+ state.cnt++;
676
+ const a = state.a;
677
+ state.a = 0;
678
+ try {
679
+ return f(a, state.b, ...args);
680
+ } finally {
681
+ state.a = a;
682
+ real._wbg_cb_unref();
683
+ }
684
+ };
685
+ real._wbg_cb_unref = () => {
686
+ if (--state.cnt === 0) {
687
+ state.dtor(state.a, state.b);
688
+ state.a = 0;
689
+ CLOSURE_DTORS.unregister(state);
690
+ }
691
+ };
692
+ CLOSURE_DTORS.register(real, state, state);
693
+ return real;
694
+ }
695
+
696
+ function passStringToWasm0(arg, malloc, realloc) {
697
+ if (realloc === undefined) {
698
+ const buf = cachedTextEncoder.encode(arg);
699
+ const ptr = malloc(buf.length, 1) >>> 0;
700
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
701
+ WASM_VECTOR_LEN = buf.length;
702
+ return ptr;
703
+ }
704
+
705
+ let len = arg.length;
706
+ let ptr = malloc(len, 1) >>> 0;
707
+
708
+ const mem = getUint8ArrayMemory0();
709
+
710
+ let offset = 0;
711
+
712
+ for (; offset < len; offset++) {
713
+ const code = arg.charCodeAt(offset);
714
+ if (code > 0x7F) break;
715
+ mem[ptr + offset] = code;
716
+ }
717
+ if (offset !== len) {
718
+ if (offset !== 0) {
719
+ arg = arg.slice(offset);
720
+ }
721
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
722
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
723
+ const ret = cachedTextEncoder.encodeInto(arg, view);
724
+
725
+ offset += ret.written;
726
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
727
+ }
728
+
729
+ WASM_VECTOR_LEN = offset;
730
+ return ptr;
731
+ }
732
+
733
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
734
+ cachedTextDecoder.decode();
735
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
736
+ let numBytesDecoded = 0;
737
+ function decodeText(ptr, len) {
738
+ numBytesDecoded += len;
739
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
740
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
741
+ cachedTextDecoder.decode();
742
+ numBytesDecoded = len;
743
+ }
744
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
745
+ }
746
+
747
+ const cachedTextEncoder = new TextEncoder();
748
+
749
+ if (!('encodeInto' in cachedTextEncoder)) {
750
+ cachedTextEncoder.encodeInto = function (arg, view) {
751
+ const buf = cachedTextEncoder.encode(arg);
752
+ view.set(buf);
753
+ return {
754
+ read: arg.length,
755
+ written: buf.length
756
+ };
757
+ };
758
+ }
759
+
760
+ let WASM_VECTOR_LEN = 0;
761
+
762
+ let wasmModule, wasm;
763
+ function __wbg_finalize_init(instance, module) {
764
+ wasm = instance.exports;
765
+ wasmModule = module;
766
+ cachedDataViewMemory0 = null;
767
+ cachedUint8ArrayMemory0 = null;
768
+ wasm.__wbindgen_start();
769
+ return wasm;
770
+ }
771
+
772
+ async function __wbg_load(module, imports) {
773
+ if (typeof Response === 'function' && module instanceof Response) {
774
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
775
+ try {
776
+ return await WebAssembly.instantiateStreaming(module, imports);
777
+ } catch (e) {
778
+ const validResponse = module.ok && expectedResponseType(module.type);
779
+
780
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
781
+ 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);
782
+
783
+ } else { throw e; }
784
+ }
785
+ }
786
+
787
+ const bytes = await module.arrayBuffer();
788
+ return await WebAssembly.instantiate(bytes, imports);
789
+ } else {
790
+ const instance = await WebAssembly.instantiate(module, imports);
791
+
792
+ if (instance instanceof WebAssembly.Instance) {
793
+ return { instance, module };
794
+ } else {
795
+ return instance;
796
+ }
797
+ }
798
+
799
+ function expectedResponseType(type) {
800
+ switch (type) {
801
+ case 'basic': case 'cors': case 'default': return true;
802
+ }
803
+ return false;
804
+ }
805
+ }
806
+
807
+ function initSync(module) {
808
+ if (wasm !== undefined) return wasm;
809
+
810
+
811
+ if (module !== undefined) {
812
+ if (Object.getPrototypeOf(module) === Object.prototype) {
813
+ ({module} = module)
814
+ } else {
815
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
816
+ }
817
+ }
818
+
819
+ const imports = __wbg_get_imports();
820
+ if (!(module instanceof WebAssembly.Module)) {
821
+ module = new WebAssembly.Module(module);
822
+ }
823
+ const instance = new WebAssembly.Instance(module, imports);
824
+ return __wbg_finalize_init(instance, module);
825
+ }
826
+
827
+ async function __wbg_init(module_or_path) {
828
+ if (wasm !== undefined) return wasm;
829
+
830
+
831
+ if (module_or_path !== undefined) {
832
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
833
+ ({module_or_path} = module_or_path)
834
+ } else {
835
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
836
+ }
837
+ }
838
+
839
+ if (module_or_path === undefined) {
840
+ module_or_path = new URL('sema_wasm_bg.wasm', import.meta.url);
841
+ }
842
+ const imports = __wbg_get_imports();
843
+
844
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
845
+ module_or_path = fetch(module_or_path);
846
+ }
847
+
848
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
849
+
850
+ return __wbg_finalize_init(instance, module);
851
+ }
852
+
853
+ export { initSync, __wbg_init as default };
Binary file