virtual-machine 0.3.7 → 0.4.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/build/{chunk-P2CNJWOJ.mjs → chunk-EEMRZD25.mjs} +93 -11
- package/build/cli.js +276 -18
- package/build/index.d.ts +51 -4
- package/build/index.js +95 -13
- package/build/index.mjs +3 -3
- package/build/node-worker.js +94 -12
- package/build/{riscv_vm-ZETNI7VC.mjs → riscv_vm-5BTJBU2J.mjs} +1 -1
- package/build/worker.js +35 -12
- package/native/index.mjs +2 -0
- package/native/riscv-vm-native.darwin-arm64.node +0 -0
- package/native/riscv-vm-native.darwin-x64.node +0 -0
- package/native/riscv-vm-native.linux-arm64-gnu.node +0 -0
- package/native/riscv-vm-native.linux-arm64-musl.node +0 -0
- package/native/riscv-vm-native.linux-x64-gnu.node +0 -0
- package/native/riscv-vm-native.linux-x64-musl.node +0 -0
- package/native/riscv-vm-native.win32-x64-msvc.node +0 -0
- package/package.json +6 -2
|
@@ -64,6 +64,10 @@ ${val.stack}`;
|
|
|
64
64
|
}
|
|
65
65
|
return className;
|
|
66
66
|
}
|
|
67
|
+
function getArrayF32FromWasm0(ptr, len) {
|
|
68
|
+
ptr = ptr >>> 0;
|
|
69
|
+
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
70
|
+
}
|
|
67
71
|
function getArrayU8FromWasm0(ptr, len) {
|
|
68
72
|
ptr = ptr >>> 0;
|
|
69
73
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
@@ -75,6 +79,13 @@ function getDataViewMemory0() {
|
|
|
75
79
|
}
|
|
76
80
|
return cachedDataViewMemory0;
|
|
77
81
|
}
|
|
82
|
+
var cachedFloat32ArrayMemory0 = null;
|
|
83
|
+
function getFloat32ArrayMemory0() {
|
|
84
|
+
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
|
85
|
+
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
|
86
|
+
}
|
|
87
|
+
return cachedFloat32ArrayMemory0;
|
|
88
|
+
}
|
|
78
89
|
function getStringFromWasm0(ptr, len) {
|
|
79
90
|
ptr = ptr >>> 0;
|
|
80
91
|
return decodeText(ptr, len);
|
|
@@ -206,17 +217,17 @@ if (!("encodeInto" in cachedTextEncoder)) {
|
|
|
206
217
|
};
|
|
207
218
|
}
|
|
208
219
|
var WASM_VECTOR_LEN = 0;
|
|
209
|
-
function
|
|
210
|
-
wasm.
|
|
220
|
+
function wasm_bindgen__convert__closures_____invoke__h0d61c5f880e0f000(arg0, arg1, arg2) {
|
|
221
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h0d61c5f880e0f000(arg0, arg1, arg2);
|
|
211
222
|
}
|
|
212
|
-
function
|
|
213
|
-
wasm.
|
|
223
|
+
function wasm_bindgen__convert__closures_____invoke__h784f747aa05330df(arg0, arg1) {
|
|
224
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h784f747aa05330df(arg0, arg1);
|
|
214
225
|
}
|
|
215
|
-
function
|
|
216
|
-
wasm.
|
|
226
|
+
function wasm_bindgen__convert__closures_____invoke__hb71c6b908e43b529(arg0, arg1) {
|
|
227
|
+
wasm.wasm_bindgen__convert__closures_____invoke__hb71c6b908e43b529(arg0, arg1);
|
|
217
228
|
}
|
|
218
|
-
function
|
|
219
|
-
wasm.
|
|
229
|
+
function wasm_bindgen__convert__closures_____invoke__h260170fb96639bcf(arg0, arg1, arg2) {
|
|
230
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h260170fb96639bcf(arg0, arg1, arg2);
|
|
220
231
|
}
|
|
221
232
|
var __wbindgen_enum_WorkerType = ["classic", "module"];
|
|
222
233
|
var WasmVmFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
@@ -280,6 +291,29 @@ var WasmVm = class _WasmVm {
|
|
|
280
291
|
const ret = wasm.wasmvm_get_output(this.__wbg_ptr);
|
|
281
292
|
return ret === 16777215 ? void 0 : ret;
|
|
282
293
|
}
|
|
294
|
+
/**
|
|
295
|
+
* Enable D1 EMAC (Ethernet MAC) device for network hardware access.
|
|
296
|
+
*
|
|
297
|
+
* This initializes the D1 EMAC device so the kernel can probe and find
|
|
298
|
+
* network hardware during boot. Should be called before the kernel starts
|
|
299
|
+
* executing if network support is desired.
|
|
300
|
+
*
|
|
301
|
+
* Note: This only enables the EMAC hardware emulation. To actually connect
|
|
302
|
+
* to a network, use `connect_webtransport()` or `setup_external_network()`.
|
|
303
|
+
*/
|
|
304
|
+
enable_emac() {
|
|
305
|
+
wasm.wasmvm_enable_emac(this.__wbg_ptr);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Enable D1 Audio Codec device for audio playback.
|
|
309
|
+
*
|
|
310
|
+
* The audio device allows the kernel to write audio samples which can
|
|
311
|
+
* then be played via WebAudio in the browser. Use `get_audio_samples()`
|
|
312
|
+
* to retrieve buffered samples for playback.
|
|
313
|
+
*/
|
|
314
|
+
enable_audio() {
|
|
315
|
+
wasm.wasmvm_enable_audio(this.__wbg_ptr);
|
|
316
|
+
}
|
|
283
317
|
/**
|
|
284
318
|
* Enable VirtIO Input device for keyboard input.
|
|
285
319
|
*
|
|
@@ -480,6 +514,21 @@ var WasmVm = class _WasmVm {
|
|
|
480
514
|
const ret = wasm.wasmvm_send_touch_event(this.__wbg_ptr, x, y, pressed);
|
|
481
515
|
return ret !== 0;
|
|
482
516
|
}
|
|
517
|
+
/**
|
|
518
|
+
* Get buffered audio samples for playback.
|
|
519
|
+
*
|
|
520
|
+
* Returns a Float32Array of interleaved stereo samples (left, right, left, right, ...).
|
|
521
|
+
* Sample values are in the range [-1.0, 1.0].
|
|
522
|
+
*
|
|
523
|
+
* Call this periodically (e.g., from an AudioWorklet) to drain the audio buffer.
|
|
524
|
+
* Returns None if no audio device is enabled or no samples are available.
|
|
525
|
+
* @param {number} max_samples
|
|
526
|
+
* @returns {Float32Array | undefined}
|
|
527
|
+
*/
|
|
528
|
+
get_audio_samples(max_samples) {
|
|
529
|
+
const ret = wasm.wasmvm_get_audio_samples(this.__wbg_ptr, max_samples);
|
|
530
|
+
return ret;
|
|
531
|
+
}
|
|
483
532
|
/**
|
|
484
533
|
* Get the total disk capacity from attached VirtIO block devices.
|
|
485
534
|
* Returns total bytes across all block devices.
|
|
@@ -575,6 +624,16 @@ var WasmVm = class _WasmVm {
|
|
|
575
624
|
const ret = wasm.wasmvm_get_framebuffer_view(this.__wbg_ptr);
|
|
576
625
|
return ret;
|
|
577
626
|
}
|
|
627
|
+
/**
|
|
628
|
+
* Get audio sample rate.
|
|
629
|
+
*
|
|
630
|
+
* Returns the sample rate configured by the kernel (default: 48000 Hz).
|
|
631
|
+
* @returns {number}
|
|
632
|
+
*/
|
|
633
|
+
get_audio_sample_rate() {
|
|
634
|
+
const ret = wasm.wasmvm_get_audio_sample_rate(this.__wbg_ptr);
|
|
635
|
+
return ret >>> 0;
|
|
636
|
+
}
|
|
578
637
|
/**
|
|
579
638
|
* Get the current frame version from kernel memory.
|
|
580
639
|
* Returns a u32 that increments each time the kernel flushes dirty pixels.
|
|
@@ -612,6 +671,17 @@ var WasmVm = class _WasmVm {
|
|
|
612
671
|
const ret = wasm.wasmvm_extract_network_packet(this.__wbg_ptr);
|
|
613
672
|
return ret;
|
|
614
673
|
}
|
|
674
|
+
/**
|
|
675
|
+
* Get current audio buffer fill level.
|
|
676
|
+
*
|
|
677
|
+
* Returns the number of sample pairs (stereo frames) currently buffered.
|
|
678
|
+
* Useful for monitoring buffer health in the JavaScript audio worklet.
|
|
679
|
+
* @returns {number}
|
|
680
|
+
*/
|
|
681
|
+
get_audio_buffer_level() {
|
|
682
|
+
const ret = wasm.wasmvm_get_audio_buffer_level(this.__wbg_ptr);
|
|
683
|
+
return ret >>> 0;
|
|
684
|
+
}
|
|
615
685
|
/**
|
|
616
686
|
* Set up an external network backend for packet bridging.
|
|
617
687
|
* This is used by the Node.js CLI to bridge packets between the native
|
|
@@ -1076,6 +1146,10 @@ function __wbg_get_imports() {
|
|
|
1076
1146
|
const ret = arg0.length;
|
|
1077
1147
|
return ret;
|
|
1078
1148
|
};
|
|
1149
|
+
imports.wbg.__wbg_length_86ce4877baf913bb = function(arg0) {
|
|
1150
|
+
const ret = arg0.length;
|
|
1151
|
+
return ret;
|
|
1152
|
+
};
|
|
1079
1153
|
imports.wbg.__wbg_load_f1dd26e734971d92 = function() {
|
|
1080
1154
|
return handleError(function(arg0, arg1) {
|
|
1081
1155
|
const ret = Atomics.load(arg0, arg1 >>> 0);
|
|
@@ -1129,6 +1203,10 @@ function __wbg_get_imports() {
|
|
|
1129
1203
|
const ret = new Uint32Array(arg0 >>> 0);
|
|
1130
1204
|
return ret;
|
|
1131
1205
|
};
|
|
1206
|
+
imports.wbg.__wbg_new_with_length_95ba657dfb7d3dfb = function(arg0) {
|
|
1207
|
+
const ret = new Float32Array(arg0 >>> 0);
|
|
1208
|
+
return ret;
|
|
1209
|
+
};
|
|
1132
1210
|
imports.wbg.__wbg_new_with_length_aa5eaf41d35235e5 = function(arg0) {
|
|
1133
1211
|
const ret = new Uint8Array(arg0 >>> 0);
|
|
1134
1212
|
return ret;
|
|
@@ -1225,6 +1303,9 @@ function __wbg_get_imports() {
|
|
|
1225
1303
|
imports.wbg.__wbg_set_bc3a432bdcd60886 = function(arg0, arg1, arg2) {
|
|
1226
1304
|
arg0.set(arg1, arg2 >>> 0);
|
|
1227
1305
|
};
|
|
1306
|
+
imports.wbg.__wbg_set_cb0e657d1901c8d8 = function(arg0, arg1, arg2) {
|
|
1307
|
+
arg0.set(getArrayF32FromWasm0(arg1, arg2));
|
|
1308
|
+
};
|
|
1228
1309
|
imports.wbg.__wbg_set_index_04c4b93e64d08a52 = function(arg0, arg1, arg2) {
|
|
1229
1310
|
arg0[arg1 >>> 0] = arg2;
|
|
1230
1311
|
};
|
|
@@ -1315,11 +1396,11 @@ function __wbg_get_imports() {
|
|
|
1315
1396
|
return ret;
|
|
1316
1397
|
};
|
|
1317
1398
|
imports.wbg.__wbindgen_cast_a107920d366c625a = function(arg0, arg1) {
|
|
1318
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1399
|
+
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h063f9d0e4e6d3305, wasm_bindgen__convert__closures_____invoke__hb71c6b908e43b529);
|
|
1319
1400
|
return ret;
|
|
1320
1401
|
};
|
|
1321
1402
|
imports.wbg.__wbindgen_cast_a9e9434264708752 = function(arg0, arg1) {
|
|
1322
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1403
|
+
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h063f9d0e4e6d3305, wasm_bindgen__convert__closures_____invoke__h0d61c5f880e0f000);
|
|
1323
1404
|
return ret;
|
|
1324
1405
|
};
|
|
1325
1406
|
imports.wbg.__wbindgen_cast_abf350a606387627 = function(arg0, arg1) {
|
|
@@ -1327,7 +1408,7 @@ function __wbg_get_imports() {
|
|
|
1327
1408
|
return ret;
|
|
1328
1409
|
};
|
|
1329
1410
|
imports.wbg.__wbindgen_cast_b33b7ab8ffafb5fe = function(arg0, arg1) {
|
|
1330
|
-
const ret = makeClosure(arg0, arg1, wasm.
|
|
1411
|
+
const ret = makeClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h063f9d0e4e6d3305, wasm_bindgen__convert__closures_____invoke__h784f747aa05330df);
|
|
1331
1412
|
return ret;
|
|
1332
1413
|
};
|
|
1333
1414
|
imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
@@ -1349,6 +1430,7 @@ function __wbg_finalize_init(instance, module) {
|
|
|
1349
1430
|
wasm = instance.exports;
|
|
1350
1431
|
__wbg_init.__wbindgen_wasm_module = module;
|
|
1351
1432
|
cachedDataViewMemory0 = null;
|
|
1433
|
+
cachedFloat32ArrayMemory0 = null;
|
|
1352
1434
|
cachedUint8ArrayMemory0 = null;
|
|
1353
1435
|
wasm.__wbindgen_start();
|
|
1354
1436
|
return wasm;
|