@sema-lang/sema-wasm 1.17.0 → 1.19.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/package.json +1 -1
- package/sema_wasm.d.ts +37 -3
- package/sema_wasm.js +95 -6
- package/sema_wasm_bg.wasm +0 -0
package/package.json
CHANGED
package/sema_wasm.d.ts
CHANGED
|
@@ -34,13 +34,21 @@ export class SemaInterpreter {
|
|
|
34
34
|
* Delete a file from the virtual filesystem. Returns true if the file existed.
|
|
35
35
|
*/
|
|
36
36
|
deleteFile(path: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Snapshot the entire VFS as a plain JS object `{ files: {path: content},
|
|
39
|
+
* dirs: [path] }` — structured-clonable across `postMessage`. Used by the
|
|
40
|
+
* playground to mirror the worker's VFS back to the main thread after each
|
|
41
|
+
* eval (and to seed the worker before one). See `loadVfs`.
|
|
42
|
+
*/
|
|
43
|
+
dumpVfs(): any;
|
|
37
44
|
/**
|
|
38
45
|
* Evaluate code, returns JSON: {"value": "...", "output": ["...", ...], "error": null}
|
|
39
46
|
* or {"value": null, "output": [...], "error": "..."}
|
|
40
47
|
*/
|
|
41
48
|
eval(code: string): any;
|
|
42
49
|
/**
|
|
43
|
-
* Evaluate code with async HTTP support
|
|
50
|
+
* Evaluate code with async HTTP support in the persistent global env
|
|
51
|
+
* (top-level defines persist across calls). Runs on the bytecode VM.
|
|
44
52
|
*/
|
|
45
53
|
evalAsync(code: string): Promise<any>;
|
|
46
54
|
/**
|
|
@@ -64,6 +72,16 @@ export class SemaInterpreter {
|
|
|
64
72
|
* Returns a JS array of line numbers (sorted). Returns empty array on parse/compile error.
|
|
65
73
|
*/
|
|
66
74
|
getValidBreakpointLines(code: string): Array<any>;
|
|
75
|
+
/**
|
|
76
|
+
* Enable real wall-clock `async/sleep` via `Atomics.wait` on the given
|
|
77
|
+
* control buffer. Call this once from a Web Worker (where blocking is
|
|
78
|
+
* allowed), passing an `Int32Array` over a `SharedArrayBuffer` shared with
|
|
79
|
+
* the main thread. After this, the scheduler's virtual-clock advances also
|
|
80
|
+
* block the worker for the real duration. Do NOT call on the main thread —
|
|
81
|
+
* `Atomics.wait` is illegal there; leaving it uninstalled keeps the
|
|
82
|
+
* instant virtual-clock behavior.
|
|
83
|
+
*/
|
|
84
|
+
installAtomicsSleep(view: Int32Array): void;
|
|
67
85
|
/**
|
|
68
86
|
* Check if a path is a directory in the virtual filesystem.
|
|
69
87
|
*/
|
|
@@ -72,6 +90,11 @@ export class SemaInterpreter {
|
|
|
72
90
|
* List files and directories in the given directory path.
|
|
73
91
|
*/
|
|
74
92
|
listFiles(dir: string): any;
|
|
93
|
+
/**
|
|
94
|
+
* Replace the entire VFS from a snapshot produced by `dumpVfs`. Resets
|
|
95
|
+
* first, so the VFS exactly matches the snapshot.
|
|
96
|
+
*/
|
|
97
|
+
loadVfs(snapshot: any): void;
|
|
75
98
|
/**
|
|
76
99
|
* Create a directory in the virtual filesystem.
|
|
77
100
|
*/
|
|
@@ -93,6 +116,13 @@ export class SemaInterpreter {
|
|
|
93
116
|
* Clear all files and directories from the virtual filesystem.
|
|
94
117
|
*/
|
|
95
118
|
resetVFS(): void;
|
|
119
|
+
/**
|
|
120
|
+
* Install a sink called with each completed output line as it is produced,
|
|
121
|
+
* so the Web Worker can stream `println` output to the main thread live
|
|
122
|
+
* (a long-running / sleeping program shows output as it happens). Pass a
|
|
123
|
+
* JS function `(line: string) => void`.
|
|
124
|
+
*/
|
|
125
|
+
setOutputSink(sink: Function): void;
|
|
96
126
|
/**
|
|
97
127
|
* Get the Sema version
|
|
98
128
|
*/
|
|
@@ -133,6 +163,7 @@ export interface InitOutput {
|
|
|
133
163
|
readonly semainterpreter_debugStepOver: (a: number) => any;
|
|
134
164
|
readonly semainterpreter_debugStop: (a: number) => void;
|
|
135
165
|
readonly semainterpreter_deleteFile: (a: number, b: number, c: number) => number;
|
|
166
|
+
readonly semainterpreter_dumpVfs: (a: number) => any;
|
|
136
167
|
readonly semainterpreter_eval: (a: number, b: number, c: number) => any;
|
|
137
168
|
readonly semainterpreter_evalAsync: (a: number, b: number, c: number) => any;
|
|
138
169
|
readonly semainterpreter_evalGlobal: (a: number, b: number, c: number) => any;
|
|
@@ -140,22 +171,25 @@ export interface InitOutput {
|
|
|
140
171
|
readonly semainterpreter_evalVMAsync: (a: number, b: number, c: number) => any;
|
|
141
172
|
readonly semainterpreter_fileExists: (a: number, b: number, c: number) => number;
|
|
142
173
|
readonly semainterpreter_getValidBreakpointLines: (a: number, b: number, c: number) => any;
|
|
174
|
+
readonly semainterpreter_installAtomicsSleep: (a: number, b: any) => void;
|
|
143
175
|
readonly semainterpreter_isDirectory: (a: number, b: number, c: number) => number;
|
|
144
176
|
readonly semainterpreter_listFiles: (a: number, b: number, c: number) => any;
|
|
177
|
+
readonly semainterpreter_loadVfs: (a: number, b: any) => void;
|
|
145
178
|
readonly semainterpreter_mkdir: (a: number, b: number, c: number) => void;
|
|
146
179
|
readonly semainterpreter_new: () => number;
|
|
147
180
|
readonly semainterpreter_preloadModule: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
148
181
|
readonly semainterpreter_readFile: (a: number, b: number, c: number) => any;
|
|
149
182
|
readonly semainterpreter_registerFunction: (a: number, b: number, c: number, d: any) => void;
|
|
150
183
|
readonly semainterpreter_resetVFS: (a: number) => void;
|
|
184
|
+
readonly semainterpreter_setOutputSink: (a: number, b: any) => void;
|
|
151
185
|
readonly semainterpreter_version: (a: number) => [number, number];
|
|
152
186
|
readonly semainterpreter_vfsStats: (a: number) => any;
|
|
153
187
|
readonly semainterpreter_writeFile: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
154
|
-
readonly
|
|
188
|
+
readonly wasm_bindgen__closure__destroy__he66a5a361c9d594c: (a: number, b: number) => void;
|
|
155
189
|
readonly wasm_bindgen__closure__destroy__h9d93f7a1700d9cb1: (a: number, b: number) => void;
|
|
156
190
|
readonly wasm_bindgen__convert__closures_____invoke__h657571cdcabda118: (a: number, b: number, c: any) => [number, number];
|
|
157
191
|
readonly wasm_bindgen__convert__closures_____invoke__h11cf443fa67993f6: (a: number, b: number, c: any, d: any) => void;
|
|
158
|
-
readonly
|
|
192
|
+
readonly wasm_bindgen__convert__closures_____invoke__h570a435bff50d28f: (a: number, b: number) => void;
|
|
159
193
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
160
194
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
161
195
|
readonly __wbindgen_exn_store: (a: number) => void;
|
package/sema_wasm.js
CHANGED
|
@@ -130,6 +130,17 @@ export class SemaInterpreter {
|
|
|
130
130
|
const ret = wasm.semainterpreter_deleteFile(this.__wbg_ptr, ptr0, len0);
|
|
131
131
|
return ret !== 0;
|
|
132
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Snapshot the entire VFS as a plain JS object `{ files: {path: content},
|
|
135
|
+
* dirs: [path] }` — structured-clonable across `postMessage`. Used by the
|
|
136
|
+
* playground to mirror the worker's VFS back to the main thread after each
|
|
137
|
+
* eval (and to seed the worker before one). See `loadVfs`.
|
|
138
|
+
* @returns {any}
|
|
139
|
+
*/
|
|
140
|
+
dumpVfs() {
|
|
141
|
+
const ret = wasm.semainterpreter_dumpVfs(this.__wbg_ptr);
|
|
142
|
+
return ret;
|
|
143
|
+
}
|
|
133
144
|
/**
|
|
134
145
|
* Evaluate code, returns JSON: {"value": "...", "output": ["...", ...], "error": null}
|
|
135
146
|
* or {"value": null, "output": [...], "error": "..."}
|
|
@@ -143,7 +154,8 @@ export class SemaInterpreter {
|
|
|
143
154
|
return ret;
|
|
144
155
|
}
|
|
145
156
|
/**
|
|
146
|
-
* Evaluate code with async HTTP support
|
|
157
|
+
* Evaluate code with async HTTP support in the persistent global env
|
|
158
|
+
* (top-level defines persist across calls). Runs on the bytecode VM.
|
|
147
159
|
* @param {string} code
|
|
148
160
|
* @returns {Promise<any>}
|
|
149
161
|
*/
|
|
@@ -209,6 +221,19 @@ export class SemaInterpreter {
|
|
|
209
221
|
const ret = wasm.semainterpreter_getValidBreakpointLines(this.__wbg_ptr, ptr0, len0);
|
|
210
222
|
return ret;
|
|
211
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Enable real wall-clock `async/sleep` via `Atomics.wait` on the given
|
|
226
|
+
* control buffer. Call this once from a Web Worker (where blocking is
|
|
227
|
+
* allowed), passing an `Int32Array` over a `SharedArrayBuffer` shared with
|
|
228
|
+
* the main thread. After this, the scheduler's virtual-clock advances also
|
|
229
|
+
* block the worker for the real duration. Do NOT call on the main thread —
|
|
230
|
+
* `Atomics.wait` is illegal there; leaving it uninstalled keeps the
|
|
231
|
+
* instant virtual-clock behavior.
|
|
232
|
+
* @param {Int32Array} view
|
|
233
|
+
*/
|
|
234
|
+
installAtomicsSleep(view) {
|
|
235
|
+
wasm.semainterpreter_installAtomicsSleep(this.__wbg_ptr, view);
|
|
236
|
+
}
|
|
212
237
|
/**
|
|
213
238
|
* Check if a path is a directory in the virtual filesystem.
|
|
214
239
|
* @param {string} path
|
|
@@ -231,6 +256,14 @@ export class SemaInterpreter {
|
|
|
231
256
|
const ret = wasm.semainterpreter_listFiles(this.__wbg_ptr, ptr0, len0);
|
|
232
257
|
return ret;
|
|
233
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* Replace the entire VFS from a snapshot produced by `dumpVfs`. Resets
|
|
261
|
+
* first, so the VFS exactly matches the snapshot.
|
|
262
|
+
* @param {any} snapshot
|
|
263
|
+
*/
|
|
264
|
+
loadVfs(snapshot) {
|
|
265
|
+
wasm.semainterpreter_loadVfs(this.__wbg_ptr, snapshot);
|
|
266
|
+
}
|
|
234
267
|
/**
|
|
235
268
|
* Create a directory in the virtual filesystem.
|
|
236
269
|
* @param {string} path
|
|
@@ -287,6 +320,16 @@ export class SemaInterpreter {
|
|
|
287
320
|
resetVFS() {
|
|
288
321
|
wasm.semainterpreter_resetVFS(this.__wbg_ptr);
|
|
289
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* Install a sink called with each completed output line as it is produced,
|
|
325
|
+
* so the Web Worker can stream `println` output to the main thread live
|
|
326
|
+
* (a long-running / sleeping program shows output as it happens). Pass a
|
|
327
|
+
* JS function `(line: string) => void`.
|
|
328
|
+
* @param {Function} sink
|
|
329
|
+
*/
|
|
330
|
+
setOutputSink(sink) {
|
|
331
|
+
wasm.semainterpreter_setOutputSink(this.__wbg_ptr, sink);
|
|
332
|
+
}
|
|
290
333
|
/**
|
|
291
334
|
* Get the Sema version
|
|
292
335
|
* @returns {string}
|
|
@@ -423,6 +466,13 @@ function __wbg_get_imports() {
|
|
|
423
466
|
const ret = arg0.fetch(arg1);
|
|
424
467
|
return ret;
|
|
425
468
|
},
|
|
469
|
+
__wbg_getAllResponseHeaders_0d155233eff8d5a4: function() { return handleError(function (arg0, arg1) {
|
|
470
|
+
const ret = arg1.getAllResponseHeaders();
|
|
471
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
472
|
+
const len1 = WASM_VECTOR_LEN;
|
|
473
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
474
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
475
|
+
}, arguments); },
|
|
426
476
|
__wbg_getRandomValues_76dfc69825c9c552: function() { return handleError(function (arg0, arg1) {
|
|
427
477
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
428
478
|
}, arguments); },
|
|
@@ -485,10 +535,18 @@ function __wbg_get_imports() {
|
|
|
485
535
|
const ret = Symbol.iterator;
|
|
486
536
|
return ret;
|
|
487
537
|
},
|
|
538
|
+
__wbg_keys_ab0d051a1c55236d: function(arg0) {
|
|
539
|
+
const ret = Object.keys(arg0);
|
|
540
|
+
return ret;
|
|
541
|
+
},
|
|
488
542
|
__wbg_length_b3416cf66a5452c8: function(arg0) {
|
|
489
543
|
const ret = arg0.length;
|
|
490
544
|
return ret;
|
|
491
545
|
},
|
|
546
|
+
__wbg_load_d8bce92127bf3f7d: function() { return handleError(function (arg0, arg1) {
|
|
547
|
+
const ret = Atomics.load(arg0, arg1 >>> 0);
|
|
548
|
+
return ret;
|
|
549
|
+
}, arguments); },
|
|
492
550
|
__wbg_new_0_1dcafdf5e786e876: function() {
|
|
493
551
|
const ret = new Date();
|
|
494
552
|
return ret;
|
|
@@ -505,6 +563,10 @@ function __wbg_get_imports() {
|
|
|
505
563
|
const ret = new AbortController();
|
|
506
564
|
return ret;
|
|
507
565
|
}, arguments); },
|
|
566
|
+
__wbg_new_cb1d07f18f0aae72: function() { return handleError(function () {
|
|
567
|
+
const ret = new XMLHttpRequest();
|
|
568
|
+
return ret;
|
|
569
|
+
}, arguments); },
|
|
508
570
|
__wbg_new_typed_aaaeaf29cf802876: function(arg0, arg1) {
|
|
509
571
|
try {
|
|
510
572
|
var state0 = {a: arg0, b: arg1};
|
|
@@ -539,6 +601,9 @@ function __wbg_get_imports() {
|
|
|
539
601
|
const ret = Date.now();
|
|
540
602
|
return ret;
|
|
541
603
|
},
|
|
604
|
+
__wbg_open_ab5f9641f561c051: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5) {
|
|
605
|
+
arg0.open(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), arg5 !== 0);
|
|
606
|
+
}, arguments); },
|
|
542
607
|
__wbg_parse_e9eddd2a82c706eb: function() { return handleError(function (arg0, arg1) {
|
|
543
608
|
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
544
609
|
return ret;
|
|
@@ -558,6 +623,22 @@ function __wbg_get_imports() {
|
|
|
558
623
|
const ret = Promise.resolve(arg0);
|
|
559
624
|
return ret;
|
|
560
625
|
},
|
|
626
|
+
__wbg_responseText_3ee457c31fe90e0e: function() { return handleError(function (arg0, arg1) {
|
|
627
|
+
const ret = arg1.responseText;
|
|
628
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
629
|
+
var len1 = WASM_VECTOR_LEN;
|
|
630
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
631
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
632
|
+
}, arguments); },
|
|
633
|
+
__wbg_send_442fe07c698a9f29: function() { return handleError(function (arg0) {
|
|
634
|
+
arg0.send();
|
|
635
|
+
}, arguments); },
|
|
636
|
+
__wbg_send_7aad46f9e0f7ecca: function() { return handleError(function (arg0, arg1, arg2) {
|
|
637
|
+
arg0.send(arg1 === 0 ? undefined : getStringFromWasm0(arg1, arg2));
|
|
638
|
+
}, arguments); },
|
|
639
|
+
__wbg_setRequestHeader_4d392f8eb9f8a78b: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
|
640
|
+
arg0.setRequestHeader(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
|
|
641
|
+
}, arguments); },
|
|
561
642
|
__wbg_setTimeout_7f7035ad0b026458: function() { return handleError(function (arg0, arg1, arg2) {
|
|
562
643
|
const ret = arg0.setTimeout(arg1, arg2);
|
|
563
644
|
return ret;
|
|
@@ -605,6 +686,10 @@ function __wbg_get_imports() {
|
|
|
605
686
|
const ret = arg0.status;
|
|
606
687
|
return ret;
|
|
607
688
|
},
|
|
689
|
+
__wbg_status_d5251b0ac97c56d5: function() { return handleError(function (arg0) {
|
|
690
|
+
const ret = arg0.status;
|
|
691
|
+
return ret;
|
|
692
|
+
}, arguments); },
|
|
608
693
|
__wbg_stringify_5ae93966a84901ac: function() { return handleError(function (arg0) {
|
|
609
694
|
const ret = JSON.stringify(arg0);
|
|
610
695
|
return ret;
|
|
@@ -625,13 +710,17 @@ function __wbg_get_imports() {
|
|
|
625
710
|
const ret = arg0.value;
|
|
626
711
|
return ret;
|
|
627
712
|
},
|
|
713
|
+
__wbg_wait_764625a35886f35b: function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
714
|
+
const ret = Atomics.wait(arg0, arg1 >>> 0, arg2, arg3);
|
|
715
|
+
return ret;
|
|
716
|
+
}, arguments); },
|
|
628
717
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
629
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
630
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
718
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 1580, function: Function { arguments: [], shim_idx: 1581, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
719
|
+
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__he66a5a361c9d594c, wasm_bindgen__convert__closures_____invoke__h570a435bff50d28f);
|
|
631
720
|
return ret;
|
|
632
721
|
},
|
|
633
722
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
634
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
723
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 1886, function: Function { arguments: [Externref], shim_idx: 1887, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
635
724
|
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h9d93f7a1700d9cb1, wasm_bindgen__convert__closures_____invoke__h657571cdcabda118);
|
|
636
725
|
return ret;
|
|
637
726
|
},
|
|
@@ -661,8 +750,8 @@ function __wbg_get_imports() {
|
|
|
661
750
|
};
|
|
662
751
|
}
|
|
663
752
|
|
|
664
|
-
function
|
|
665
|
-
wasm.
|
|
753
|
+
function wasm_bindgen__convert__closures_____invoke__h570a435bff50d28f(arg0, arg1) {
|
|
754
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h570a435bff50d28f(arg0, arg1);
|
|
666
755
|
}
|
|
667
756
|
|
|
668
757
|
function wasm_bindgen__convert__closures_____invoke__h657571cdcabda118(arg0, arg1, arg2) {
|
package/sema_wasm_bg.wasm
CHANGED
|
Binary file
|