virtual-machine 0.3.0 → 0.3.3
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-7SVGV3JI.mjs → chunk-YXBSW6PP.mjs} +107 -39
- package/build/cli.js +303 -88
- package/build/index.d.ts +95 -14
- package/build/index.js +188 -40
- package/build/index.mjs +83 -3
- package/build/node-worker.js +141 -48
- package/build/{riscv_vm-B72XE6VL.mjs → riscv_vm-2B2CO6XX.mjs} +1 -1
- package/build/worker.js +48 -37
- package/native/index.d.ts +0 -3
- package/native/index.mjs +1 -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 +1 -1
|
@@ -206,17 +206,17 @@ if (!("encodeInto" in cachedTextEncoder)) {
|
|
|
206
206
|
};
|
|
207
207
|
}
|
|
208
208
|
var WASM_VECTOR_LEN = 0;
|
|
209
|
-
function
|
|
210
|
-
wasm.
|
|
209
|
+
function wasm_bindgen__convert__closures_____invoke__hf9330c20899fe446(arg0, arg1) {
|
|
210
|
+
wasm.wasm_bindgen__convert__closures_____invoke__hf9330c20899fe446(arg0, arg1);
|
|
211
211
|
}
|
|
212
212
|
function wasm_bindgen__convert__closures_____invoke__h260170fb96639bcf(arg0, arg1, arg2) {
|
|
213
213
|
wasm.wasm_bindgen__convert__closures_____invoke__h260170fb96639bcf(arg0, arg1, arg2);
|
|
214
214
|
}
|
|
215
|
-
function
|
|
216
|
-
wasm.
|
|
215
|
+
function wasm_bindgen__convert__closures_____invoke__h201459934189f4a1(arg0, arg1, arg2) {
|
|
216
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h201459934189f4a1(arg0, arg1, arg2);
|
|
217
217
|
}
|
|
218
|
-
function
|
|
219
|
-
wasm.
|
|
218
|
+
function wasm_bindgen__convert__closures_____invoke__h6b88ef80ef3d6675(arg0, arg1) {
|
|
219
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h6b88ef80ef3d6675(arg0, arg1);
|
|
220
220
|
}
|
|
221
221
|
var __wbindgen_enum_WorkerType = ["classic", "module"];
|
|
222
222
|
var WasmVmFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
@@ -254,20 +254,20 @@ var WasmVm = class _WasmVm {
|
|
|
254
254
|
wasm.__wbg_wasmvm_free(ptr, 0);
|
|
255
255
|
}
|
|
256
256
|
/**
|
|
257
|
-
* Enable
|
|
257
|
+
* Enable D1 Display device for graphics rendering.
|
|
258
258
|
*
|
|
259
|
-
* The
|
|
259
|
+
* The display device allows the kernel to render to a framebuffer which can
|
|
260
260
|
* then be displayed in a Canvas element. Use `get_gpu_frame()` to retrieve
|
|
261
261
|
* the rendered frame pixels.
|
|
262
262
|
*
|
|
263
263
|
* # Arguments
|
|
264
|
-
* * `width` - Display width in pixels (
|
|
265
|
-
* * `height` - Display height in pixels (
|
|
266
|
-
* @param {number}
|
|
267
|
-
* @param {number}
|
|
264
|
+
* * `width` - Display width in pixels (ignored, uses 1024x768)
|
|
265
|
+
* * `height` - Display height in pixels (ignored, uses 1024x768)
|
|
266
|
+
* @param {number} _width
|
|
267
|
+
* @param {number} _height
|
|
268
268
|
*/
|
|
269
|
-
enable_gpu(
|
|
270
|
-
wasm.wasmvm_enable_gpu(this.__wbg_ptr,
|
|
269
|
+
enable_gpu(_width, _height) {
|
|
270
|
+
wasm.wasmvm_enable_gpu(this.__wbg_ptr, _width, _height);
|
|
271
271
|
}
|
|
272
272
|
/**
|
|
273
273
|
* Get a byte from the UART output buffer, if available.
|
|
@@ -326,7 +326,7 @@ var WasmVm = class _WasmVm {
|
|
|
326
326
|
* Get GPU frame data as RGBA pixels.
|
|
327
327
|
* Returns a Uint8Array of pixel data, or null if no frame is available.
|
|
328
328
|
*
|
|
329
|
-
* The frame data is in RGBA format with 4 bytes per pixel (
|
|
329
|
+
* The frame data is in RGBA format with 4 bytes per pixel (1024×768 = 3,145,728 bytes).
|
|
330
330
|
*
|
|
331
331
|
* This reads from a fixed framebuffer address in guest memory (0x8100_0000).
|
|
332
332
|
* The kernel GPU driver writes pixels there, and we read them here.
|
|
@@ -393,7 +393,7 @@ var WasmVm = class _WasmVm {
|
|
|
393
393
|
}
|
|
394
394
|
/**
|
|
395
395
|
* Get the current network connection status.
|
|
396
|
-
* This checks the actual connection state by seeing if
|
|
396
|
+
* This checks the actual connection state by seeing if D1 EMAC is enabled.
|
|
397
397
|
* @returns {NetworkStatus}
|
|
398
398
|
*/
|
|
399
399
|
network_status() {
|
|
@@ -462,6 +462,24 @@ var WasmVm = class _WasmVm {
|
|
|
462
462
|
const ret = wasm.wasmvm_send_mouse_event(this.__wbg_ptr, x, y, buttons);
|
|
463
463
|
return ret !== 0;
|
|
464
464
|
}
|
|
465
|
+
/**
|
|
466
|
+
* Send a touch event to the D1 GT911 touchscreen controller.
|
|
467
|
+
*
|
|
468
|
+
* # Arguments
|
|
469
|
+
* * `x` - X position (0 to display width)
|
|
470
|
+
* * `y` - Y position (0 to display height)
|
|
471
|
+
* * `pressed` - true for touch down/move, false for touch up
|
|
472
|
+
*
|
|
473
|
+
* Returns true if the event was sent successfully.
|
|
474
|
+
* @param {number} x
|
|
475
|
+
* @param {number} y
|
|
476
|
+
* @param {boolean} pressed
|
|
477
|
+
* @returns {boolean}
|
|
478
|
+
*/
|
|
479
|
+
send_touch_event(x, y, pressed) {
|
|
480
|
+
const ret = wasm.wasmvm_send_touch_event(this.__wbg_ptr, x, y, pressed);
|
|
481
|
+
return ret !== 0;
|
|
482
|
+
}
|
|
465
483
|
/**
|
|
466
484
|
* Get the total disk capacity from attached VirtIO block devices.
|
|
467
485
|
* Returns total bytes across all block devices.
|
|
@@ -531,6 +549,30 @@ var WasmVm = class _WasmVm {
|
|
|
531
549
|
throw takeFromExternrefTable0(ret[0]);
|
|
532
550
|
}
|
|
533
551
|
}
|
|
552
|
+
/**
|
|
553
|
+
* Get a direct zero-copy view into the framebuffer in SharedArrayBuffer.
|
|
554
|
+
*
|
|
555
|
+
* This eliminates all memory copies by creating a Uint8Array view directly
|
|
556
|
+
* into the SharedArrayBuffer at the framebuffer offset. The browser can
|
|
557
|
+
* pass this directly to WebGPU's writeTexture for zero-copy rendering.
|
|
558
|
+
*
|
|
559
|
+
* Returns None if SharedArrayBuffer is not available (single-threaded mode).
|
|
560
|
+
* @returns {Uint8Array | undefined}
|
|
561
|
+
*/
|
|
562
|
+
get_framebuffer_view() {
|
|
563
|
+
const ret = wasm.wasmvm_get_framebuffer_view(this.__wbg_ptr);
|
|
564
|
+
return ret;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Get the current frame version from kernel memory.
|
|
568
|
+
* Returns a u32 that increments each time the kernel flushes dirty pixels.
|
|
569
|
+
* Browser can compare this to skip fetching unchanged frames.
|
|
570
|
+
* @returns {number}
|
|
571
|
+
*/
|
|
572
|
+
get_gpu_frame_version() {
|
|
573
|
+
const ret = wasm.wasmvm_get_gpu_frame_version(this.__wbg_ptr);
|
|
574
|
+
return ret >>> 0;
|
|
575
|
+
}
|
|
534
576
|
/**
|
|
535
577
|
* Inject a network packet to be received by the guest.
|
|
536
578
|
* Called from JavaScript when the native WebTransport addon receives a packet.
|
|
@@ -704,7 +746,7 @@ var WasmVm = class _WasmVm {
|
|
|
704
746
|
return ret !== 0;
|
|
705
747
|
}
|
|
706
748
|
/**
|
|
707
|
-
* Load a disk image and attach it as a
|
|
749
|
+
* Load a disk image and attach it as a D1 MMC device.
|
|
708
750
|
* This should be called before starting execution if the kernel needs a filesystem.
|
|
709
751
|
* @param {Uint8Array} disk_image
|
|
710
752
|
*/
|
|
@@ -762,6 +804,22 @@ var WorkerState = class {
|
|
|
762
804
|
const ret = wasm.workerstate_step_count(this.__wbg_ptr);
|
|
763
805
|
return BigInt.asUintN(64, ret);
|
|
764
806
|
}
|
|
807
|
+
/**
|
|
808
|
+
* Check if MSIP is pending for this hart (for debugging).
|
|
809
|
+
* @returns {boolean}
|
|
810
|
+
*/
|
|
811
|
+
is_msip_pending() {
|
|
812
|
+
const ret = wasm.workerstate_is_msip_pending(this.__wbg_ptr);
|
|
813
|
+
return ret !== 0;
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Check if timer is pending for this hart (for debugging).
|
|
817
|
+
* @returns {boolean}
|
|
818
|
+
*/
|
|
819
|
+
is_timer_pending() {
|
|
820
|
+
const ret = wasm.workerstate_is_timer_pending(this.__wbg_ptr);
|
|
821
|
+
return ret !== 0;
|
|
822
|
+
}
|
|
765
823
|
/**
|
|
766
824
|
* Create a new worker state for a secondary hart.
|
|
767
825
|
* @param {number} hart_id
|
|
@@ -774,6 +832,14 @@ var WorkerState = class {
|
|
|
774
832
|
WorkerStateFinalization.register(this, this.__wbg_ptr, this);
|
|
775
833
|
return this;
|
|
776
834
|
}
|
|
835
|
+
/**
|
|
836
|
+
* Get the a0 register value (for debugging hart ID passing).
|
|
837
|
+
* @returns {bigint}
|
|
838
|
+
*/
|
|
839
|
+
get_a0() {
|
|
840
|
+
const ret = wasm.workerstate_get_a0(this.__wbg_ptr);
|
|
841
|
+
return BigInt.asUintN(64, ret);
|
|
842
|
+
}
|
|
777
843
|
/**
|
|
778
844
|
* Get the hart ID.
|
|
779
845
|
* @returns {number}
|
|
@@ -804,7 +870,13 @@ var WorkerStepResult = Object.freeze({
|
|
|
804
870
|
* Fatal error occurred
|
|
805
871
|
*/
|
|
806
872
|
Error: 3,
|
|
807
|
-
"3": "Error"
|
|
873
|
+
"3": "Error",
|
|
874
|
+
/**
|
|
875
|
+
* WFI executed - worker should yield to prevent busy loop
|
|
876
|
+
* TypeScript should add a small delay before calling step_batch again
|
|
877
|
+
*/
|
|
878
|
+
Wfi: 4,
|
|
879
|
+
"4": "Wfi"
|
|
808
880
|
});
|
|
809
881
|
function worker_check_interrupts(hart_id, shared_mem) {
|
|
810
882
|
const ret = wasm.worker_check_interrupts(hart_id, shared_mem);
|
|
@@ -958,14 +1030,6 @@ function __wbg_get_imports() {
|
|
|
958
1030
|
const ret = arg0.getReader();
|
|
959
1031
|
return ret;
|
|
960
1032
|
};
|
|
961
|
-
imports.wbg.__wbg_getUint16_cb7a6e659d68e5a6 = function(arg0, arg1, arg2) {
|
|
962
|
-
const ret = arg0.getUint16(arg1 >>> 0, arg2 !== 0);
|
|
963
|
-
return ret;
|
|
964
|
-
};
|
|
965
|
-
imports.wbg.__wbg_getUint8_f42915a9262518eb = function(arg0, arg1) {
|
|
966
|
-
const ret = arg0.getUint8(arg1 >>> 0);
|
|
967
|
-
return ret;
|
|
968
|
-
};
|
|
969
1033
|
imports.wbg.__wbg_getWriter_bbffb7cf601bec61 = function() {
|
|
970
1034
|
return handleError(function(arg0) {
|
|
971
1035
|
const ret = arg0.getWriter();
|
|
@@ -1073,12 +1137,22 @@ function __wbg_get_imports() {
|
|
|
1073
1137
|
const ret = new DataView(arg0, arg1 >>> 0, arg2 >>> 0);
|
|
1074
1138
|
return ret;
|
|
1075
1139
|
};
|
|
1140
|
+
imports.wbg.__wbg_notify_65c8811cd7c0cdea = function() {
|
|
1141
|
+
return handleError(function(arg0, arg1, arg2) {
|
|
1142
|
+
const ret = Atomics.notify(arg0, arg1 >>> 0, arg2 >>> 0);
|
|
1143
|
+
return ret;
|
|
1144
|
+
}, arguments);
|
|
1145
|
+
};
|
|
1076
1146
|
imports.wbg.__wbg_notify_f7e901980222d3e0 = function() {
|
|
1077
1147
|
return handleError(function(arg0, arg1) {
|
|
1078
1148
|
const ret = Atomics.notify(arg0, arg1 >>> 0);
|
|
1079
1149
|
return ret;
|
|
1080
1150
|
}, arguments);
|
|
1081
1151
|
};
|
|
1152
|
+
imports.wbg.__wbg_now_69d776cd24f5215b = function() {
|
|
1153
|
+
const ret = Date.now();
|
|
1154
|
+
return ret;
|
|
1155
|
+
};
|
|
1082
1156
|
imports.wbg.__wbg_or_eb11de0669782b52 = function() {
|
|
1083
1157
|
return handleError(function(arg0, arg1, arg2) {
|
|
1084
1158
|
const ret = Atomics.or(arg0, arg1 >>> 0, arg2);
|
|
@@ -1124,12 +1198,6 @@ function __wbg_get_imports() {
|
|
|
1124
1198
|
const ret = Promise.resolve(arg0);
|
|
1125
1199
|
return ret;
|
|
1126
1200
|
};
|
|
1127
|
-
imports.wbg.__wbg_setUint16_ff3205ca61800a91 = function(arg0, arg1, arg2, arg3) {
|
|
1128
|
-
arg0.setUint16(arg1 >>> 0, arg2, arg3 !== 0);
|
|
1129
|
-
};
|
|
1130
|
-
imports.wbg.__wbg_setUint8_71dd48d3e18e4e40 = function(arg0, arg1, arg2) {
|
|
1131
|
-
arg0.setUint8(arg1 >>> 0, arg2);
|
|
1132
|
-
};
|
|
1133
1201
|
imports.wbg.__wbg_set_169e13b608078b7b = function(arg0, arg1, arg2) {
|
|
1134
1202
|
arg0.set(getArrayU8FromWasm0(arg1, arg2));
|
|
1135
1203
|
};
|
|
@@ -1234,20 +1302,20 @@ function __wbg_get_imports() {
|
|
|
1234
1302
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
1235
1303
|
return ret;
|
|
1236
1304
|
};
|
|
1237
|
-
imports.wbg.
|
|
1238
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1305
|
+
imports.wbg.__wbindgen_cast_a107920d366c625a = function(arg0, arg1) {
|
|
1306
|
+
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h1f949ca759a20457, wasm_bindgen__convert__closures_____invoke__h6b88ef80ef3d6675);
|
|
1239
1307
|
return ret;
|
|
1240
1308
|
};
|
|
1241
|
-
imports.wbg.
|
|
1309
|
+
imports.wbg.__wbindgen_cast_abf350a606387627 = function(arg0, arg1) {
|
|
1242
1310
|
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h612f8e24953b61d5, wasm_bindgen__convert__closures_____invoke__h260170fb96639bcf);
|
|
1243
1311
|
return ret;
|
|
1244
1312
|
};
|
|
1245
|
-
imports.wbg.
|
|
1246
|
-
const ret = makeClosure(arg0, arg1, wasm.
|
|
1313
|
+
imports.wbg.__wbindgen_cast_d1d368b2b68538d7 = function(arg0, arg1) {
|
|
1314
|
+
const ret = makeClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h1f949ca759a20457, wasm_bindgen__convert__closures_____invoke__hf9330c20899fe446);
|
|
1247
1315
|
return ret;
|
|
1248
1316
|
};
|
|
1249
|
-
imports.wbg.
|
|
1250
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1317
|
+
imports.wbg.__wbindgen_cast_d3f7166d7f91ad34 = function(arg0, arg1) {
|
|
1318
|
+
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h1f949ca759a20457, wasm_bindgen__convert__closures_____invoke__h201459934189f4a1);
|
|
1251
1319
|
return ret;
|
|
1252
1320
|
};
|
|
1253
1321
|
imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|