@sema-lang/sema-wasm 1.18.0 → 1.19.1
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 +35 -2
- package/sema_wasm.js +93 -5
- package/sema_wasm_bg.wasm +0 -0
package/package.json
CHANGED
package/sema_wasm.d.ts
CHANGED
|
@@ -34,6 +34,13 @@ 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": "..."}
|
|
@@ -65,6 +72,16 @@ export class SemaInterpreter {
|
|
|
65
72
|
* Returns a JS array of line numbers (sorted). Returns empty array on parse/compile error.
|
|
66
73
|
*/
|
|
67
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;
|
|
68
85
|
/**
|
|
69
86
|
* Check if a path is a directory in the virtual filesystem.
|
|
70
87
|
*/
|
|
@@ -73,6 +90,11 @@ export class SemaInterpreter {
|
|
|
73
90
|
* List files and directories in the given directory path.
|
|
74
91
|
*/
|
|
75
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;
|
|
76
98
|
/**
|
|
77
99
|
* Create a directory in the virtual filesystem.
|
|
78
100
|
*/
|
|
@@ -94,6 +116,13 @@ export class SemaInterpreter {
|
|
|
94
116
|
* Clear all files and directories from the virtual filesystem.
|
|
95
117
|
*/
|
|
96
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;
|
|
97
126
|
/**
|
|
98
127
|
* Get the Sema version
|
|
99
128
|
*/
|
|
@@ -134,6 +163,7 @@ export interface InitOutput {
|
|
|
134
163
|
readonly semainterpreter_debugStepOver: (a: number) => any;
|
|
135
164
|
readonly semainterpreter_debugStop: (a: number) => void;
|
|
136
165
|
readonly semainterpreter_deleteFile: (a: number, b: number, c: number) => number;
|
|
166
|
+
readonly semainterpreter_dumpVfs: (a: number) => any;
|
|
137
167
|
readonly semainterpreter_eval: (a: number, b: number, c: number) => any;
|
|
138
168
|
readonly semainterpreter_evalAsync: (a: number, b: number, c: number) => any;
|
|
139
169
|
readonly semainterpreter_evalGlobal: (a: number, b: number, c: number) => any;
|
|
@@ -141,22 +171,25 @@ export interface InitOutput {
|
|
|
141
171
|
readonly semainterpreter_evalVMAsync: (a: number, b: number, c: number) => any;
|
|
142
172
|
readonly semainterpreter_fileExists: (a: number, b: number, c: number) => number;
|
|
143
173
|
readonly semainterpreter_getValidBreakpointLines: (a: number, b: number, c: number) => any;
|
|
174
|
+
readonly semainterpreter_installAtomicsSleep: (a: number, b: any) => void;
|
|
144
175
|
readonly semainterpreter_isDirectory: (a: number, b: number, c: number) => number;
|
|
145
176
|
readonly semainterpreter_listFiles: (a: number, b: number, c: number) => any;
|
|
177
|
+
readonly semainterpreter_loadVfs: (a: number, b: any) => void;
|
|
146
178
|
readonly semainterpreter_mkdir: (a: number, b: number, c: number) => void;
|
|
147
179
|
readonly semainterpreter_new: () => number;
|
|
148
180
|
readonly semainterpreter_preloadModule: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
149
181
|
readonly semainterpreter_readFile: (a: number, b: number, c: number) => any;
|
|
150
182
|
readonly semainterpreter_registerFunction: (a: number, b: number, c: number, d: any) => void;
|
|
151
183
|
readonly semainterpreter_resetVFS: (a: number) => void;
|
|
184
|
+
readonly semainterpreter_setOutputSink: (a: number, b: any) => void;
|
|
152
185
|
readonly semainterpreter_version: (a: number) => [number, number];
|
|
153
186
|
readonly semainterpreter_vfsStats: (a: number) => any;
|
|
154
187
|
readonly semainterpreter_writeFile: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
155
|
-
readonly
|
|
188
|
+
readonly wasm_bindgen__closure__destroy__he3ae2e6f5beb0d28: (a: number, b: number) => void;
|
|
156
189
|
readonly wasm_bindgen__closure__destroy__h9d93f7a1700d9cb1: (a: number, b: number) => void;
|
|
157
190
|
readonly wasm_bindgen__convert__closures_____invoke__h657571cdcabda118: (a: number, b: number, c: any) => [number, number];
|
|
158
191
|
readonly wasm_bindgen__convert__closures_____invoke__h11cf443fa67993f6: (a: number, b: number, c: any, d: any) => void;
|
|
159
|
-
readonly
|
|
192
|
+
readonly wasm_bindgen__convert__closures_____invoke__h9fac141a297d59fb: (a: number, b: number) => void;
|
|
160
193
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
161
194
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
162
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": "..."}
|
|
@@ -210,6 +221,19 @@ export class SemaInterpreter {
|
|
|
210
221
|
const ret = wasm.semainterpreter_getValidBreakpointLines(this.__wbg_ptr, ptr0, len0);
|
|
211
222
|
return ret;
|
|
212
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
|
+
}
|
|
213
237
|
/**
|
|
214
238
|
* Check if a path is a directory in the virtual filesystem.
|
|
215
239
|
* @param {string} path
|
|
@@ -232,6 +256,14 @@ export class SemaInterpreter {
|
|
|
232
256
|
const ret = wasm.semainterpreter_listFiles(this.__wbg_ptr, ptr0, len0);
|
|
233
257
|
return ret;
|
|
234
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
|
+
}
|
|
235
267
|
/**
|
|
236
268
|
* Create a directory in the virtual filesystem.
|
|
237
269
|
* @param {string} path
|
|
@@ -288,6 +320,16 @@ export class SemaInterpreter {
|
|
|
288
320
|
resetVFS() {
|
|
289
321
|
wasm.semainterpreter_resetVFS(this.__wbg_ptr);
|
|
290
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
|
+
}
|
|
291
333
|
/**
|
|
292
334
|
* Get the Sema version
|
|
293
335
|
* @returns {string}
|
|
@@ -424,6 +466,13 @@ function __wbg_get_imports() {
|
|
|
424
466
|
const ret = arg0.fetch(arg1);
|
|
425
467
|
return ret;
|
|
426
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); },
|
|
427
476
|
__wbg_getRandomValues_76dfc69825c9c552: function() { return handleError(function (arg0, arg1) {
|
|
428
477
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
429
478
|
}, arguments); },
|
|
@@ -486,10 +535,18 @@ function __wbg_get_imports() {
|
|
|
486
535
|
const ret = Symbol.iterator;
|
|
487
536
|
return ret;
|
|
488
537
|
},
|
|
538
|
+
__wbg_keys_ab0d051a1c55236d: function(arg0) {
|
|
539
|
+
const ret = Object.keys(arg0);
|
|
540
|
+
return ret;
|
|
541
|
+
},
|
|
489
542
|
__wbg_length_b3416cf66a5452c8: function(arg0) {
|
|
490
543
|
const ret = arg0.length;
|
|
491
544
|
return ret;
|
|
492
545
|
},
|
|
546
|
+
__wbg_load_d8bce92127bf3f7d: function() { return handleError(function (arg0, arg1) {
|
|
547
|
+
const ret = Atomics.load(arg0, arg1 >>> 0);
|
|
548
|
+
return ret;
|
|
549
|
+
}, arguments); },
|
|
493
550
|
__wbg_new_0_1dcafdf5e786e876: function() {
|
|
494
551
|
const ret = new Date();
|
|
495
552
|
return ret;
|
|
@@ -506,6 +563,10 @@ function __wbg_get_imports() {
|
|
|
506
563
|
const ret = new AbortController();
|
|
507
564
|
return ret;
|
|
508
565
|
}, arguments); },
|
|
566
|
+
__wbg_new_cb1d07f18f0aae72: function() { return handleError(function () {
|
|
567
|
+
const ret = new XMLHttpRequest();
|
|
568
|
+
return ret;
|
|
569
|
+
}, arguments); },
|
|
509
570
|
__wbg_new_typed_aaaeaf29cf802876: function(arg0, arg1) {
|
|
510
571
|
try {
|
|
511
572
|
var state0 = {a: arg0, b: arg1};
|
|
@@ -540,6 +601,9 @@ function __wbg_get_imports() {
|
|
|
540
601
|
const ret = Date.now();
|
|
541
602
|
return ret;
|
|
542
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); },
|
|
543
607
|
__wbg_parse_e9eddd2a82c706eb: function() { return handleError(function (arg0, arg1) {
|
|
544
608
|
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
545
609
|
return ret;
|
|
@@ -559,6 +623,22 @@ function __wbg_get_imports() {
|
|
|
559
623
|
const ret = Promise.resolve(arg0);
|
|
560
624
|
return ret;
|
|
561
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); },
|
|
562
642
|
__wbg_setTimeout_7f7035ad0b026458: function() { return handleError(function (arg0, arg1, arg2) {
|
|
563
643
|
const ret = arg0.setTimeout(arg1, arg2);
|
|
564
644
|
return ret;
|
|
@@ -606,6 +686,10 @@ function __wbg_get_imports() {
|
|
|
606
686
|
const ret = arg0.status;
|
|
607
687
|
return ret;
|
|
608
688
|
},
|
|
689
|
+
__wbg_status_d5251b0ac97c56d5: function() { return handleError(function (arg0) {
|
|
690
|
+
const ret = arg0.status;
|
|
691
|
+
return ret;
|
|
692
|
+
}, arguments); },
|
|
609
693
|
__wbg_stringify_5ae93966a84901ac: function() { return handleError(function (arg0) {
|
|
610
694
|
const ret = JSON.stringify(arg0);
|
|
611
695
|
return ret;
|
|
@@ -626,13 +710,17 @@ function __wbg_get_imports() {
|
|
|
626
710
|
const ret = arg0.value;
|
|
627
711
|
return ret;
|
|
628
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); },
|
|
629
717
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
630
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
631
|
-
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__he3ae2e6f5beb0d28, wasm_bindgen__convert__closures_____invoke__h9fac141a297d59fb);
|
|
632
720
|
return ret;
|
|
633
721
|
},
|
|
634
722
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
635
|
-
// 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`.
|
|
636
724
|
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h9d93f7a1700d9cb1, wasm_bindgen__convert__closures_____invoke__h657571cdcabda118);
|
|
637
725
|
return ret;
|
|
638
726
|
},
|
|
@@ -662,8 +750,8 @@ function __wbg_get_imports() {
|
|
|
662
750
|
};
|
|
663
751
|
}
|
|
664
752
|
|
|
665
|
-
function
|
|
666
|
-
wasm.
|
|
753
|
+
function wasm_bindgen__convert__closures_____invoke__h9fac141a297d59fb(arg0, arg1) {
|
|
754
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h9fac141a297d59fb(arg0, arg1);
|
|
667
755
|
}
|
|
668
756
|
|
|
669
757
|
function wasm_bindgen__convert__closures_____invoke__h657571cdcabda118(arg0, arg1, arg2) {
|
package/sema_wasm_bg.wasm
CHANGED
|
Binary file
|