virtual-machine 0.2.0 → 0.2.2

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.
@@ -206,17 +206,17 @@ if (!("encodeInto" in cachedTextEncoder)) {
206
206
  };
207
207
  }
208
208
  var WASM_VECTOR_LEN = 0;
209
- function wasm_bindgen__convert__closures_____invoke__h50e72de47846ca00(arg0, arg1) {
210
- wasm.wasm_bindgen__convert__closures_____invoke__h50e72de47846ca00(arg0, arg1);
209
+ function wasm_bindgen__convert__closures_____invoke__h74d7f37f0b0d661d(arg0, arg1, arg2) {
210
+ wasm.wasm_bindgen__convert__closures_____invoke__h74d7f37f0b0d661d(arg0, arg1, arg2);
211
211
  }
212
- function wasm_bindgen__convert__closures_____invoke__h080c535c51d1ca28(arg0, arg1, arg2) {
213
- wasm.wasm_bindgen__convert__closures_____invoke__h080c535c51d1ca28(arg0, arg1, arg2);
212
+ function wasm_bindgen__convert__closures_____invoke__h9f0ee31d317d33d7(arg0, arg1) {
213
+ wasm.wasm_bindgen__convert__closures_____invoke__h9f0ee31d317d33d7(arg0, arg1);
214
214
  }
215
- function wasm_bindgen__convert__closures_____invoke__hc2505ab56e11573d(arg0, arg1) {
216
- wasm.wasm_bindgen__convert__closures_____invoke__hc2505ab56e11573d(arg0, arg1);
215
+ function wasm_bindgen__convert__closures_____invoke__h260170fb96639bcf(arg0, arg1, arg2) {
216
+ wasm.wasm_bindgen__convert__closures_____invoke__h260170fb96639bcf(arg0, arg1, arg2);
217
217
  }
218
- function wasm_bindgen__convert__closures_____invoke__h39d3e89751b07765(arg0, arg1, arg2) {
219
- wasm.wasm_bindgen__convert__closures_____invoke__h39d3e89751b07765(arg0, arg1, arg2);
218
+ function wasm_bindgen__convert__closures_____invoke__h97b9bec6245a8424(arg0, arg1) {
219
+ wasm.wasm_bindgen__convert__closures_____invoke__h97b9bec6245a8424(arg0, arg1);
220
220
  }
221
221
  var __wbindgen_enum_WorkerType = ["classic", "module"];
222
222
  var WasmVmFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
@@ -253,6 +253,22 @@ var WasmVm = class _WasmVm {
253
253
  const ptr = this.__destroy_into_raw();
254
254
  wasm.__wbg_wasmvm_free(ptr, 0);
255
255
  }
256
+ /**
257
+ * Enable VirtIO GPU device for graphics rendering.
258
+ *
259
+ * The GPU device allows the kernel to render to a framebuffer which can
260
+ * then be displayed in a Canvas element. Use `get_gpu_frame()` to retrieve
261
+ * the rendered frame pixels.
262
+ *
263
+ * # Arguments
264
+ * * `width` - Display width in pixels (default 800 if 0)
265
+ * * `height` - Display height in pixels (default 600 if 0)
266
+ * @param {number} width
267
+ * @param {number} height
268
+ */
269
+ enable_gpu(width, height) {
270
+ wasm.wasmvm_enable_gpu(this.__wbg_ptr, width, height);
271
+ }
256
272
  /**
257
273
  * Get a byte from the UART output buffer, if available.
258
274
  *
@@ -264,6 +280,24 @@ var WasmVm = class _WasmVm {
264
280
  const ret = wasm.wasmvm_get_output(this.__wbg_ptr);
265
281
  return ret === 16777215 ? void 0 : ret;
266
282
  }
283
+ /**
284
+ * Enable VirtIO Input device for keyboard input.
285
+ *
286
+ * After calling this, use `send_key_event()` to forward keyboard events
287
+ * from JavaScript to the guest kernel.
288
+ */
289
+ enable_input() {
290
+ wasm.wasmvm_enable_input(this.__wbg_ptr);
291
+ }
292
+ /**
293
+ * Get GPU display dimensions.
294
+ * Returns [width, height] or null if GPU is not enabled.
295
+ * @returns {Uint32Array | undefined}
296
+ */
297
+ get_gpu_size() {
298
+ const ret = wasm.wasmvm_get_gpu_size(this.__wbg_ptr);
299
+ return ret;
300
+ }
267
301
  /**
268
302
  * Print the VM banner to UART output (visible in browser).
269
303
  * Call this after creating the VM to show a boot banner.
@@ -288,6 +322,20 @@ var WasmVm = class _WasmVm {
288
322
  const ret = wasm.wasmvm_get_cpu_count(this.__wbg_ptr);
289
323
  return ret >>> 0;
290
324
  }
325
+ /**
326
+ * Get GPU frame data as RGBA pixels.
327
+ * Returns a Uint8Array of pixel data, or null if no frame is available.
328
+ *
329
+ * The frame data is in RGBA format with 4 bytes per pixel (800x600 = 1,920,000 bytes).
330
+ *
331
+ * This reads from a fixed framebuffer address in guest memory (0x8100_0000).
332
+ * The kernel GPU driver writes pixels there, and we read them here.
333
+ * @returns {Uint8Array | undefined}
334
+ */
335
+ get_gpu_frame() {
336
+ const ret = wasm.wasmvm_get_gpu_frame(this.__wbg_ptr);
337
+ return ret;
338
+ }
291
339
  /**
292
340
  * Get system uptime in milliseconds (from kernel-reported value).
293
341
  * @returns {bigint}
@@ -296,6 +344,17 @@ var WasmVm = class _WasmVm {
296
344
  const ret = wasm.wasmvm_get_uptime_ms(this.__wbg_ptr);
297
345
  return BigInt.asUintN(64, ret);
298
346
  }
347
+ /**
348
+ * Check if there's a GPU frame ready for rendering.
349
+ *
350
+ * With direct memory framebuffer, this always returns true when GPU is enabled.
351
+ * The framebuffer at FRAMEBUFFER_ADDR always contains the current frame.
352
+ * @returns {boolean}
353
+ */
354
+ has_gpu_frame() {
355
+ const ret = wasm.wasmvm_has_gpu_frame(this.__wbg_ptr);
356
+ return ret !== 0;
357
+ }
299
358
  /**
300
359
  * Start worker threads for secondary harts (1..num_harts).
301
360
  *
@@ -360,6 +419,22 @@ var WasmVm = class _WasmVm {
360
419
  }
361
420
  return _WasmVm.__wrap(ret[0]);
362
421
  }
422
+ /**
423
+ * Send a keyboard event to the guest.
424
+ *
425
+ * # Arguments
426
+ * * `key_code` - JavaScript keyCode (e.g., 65 for 'A')
427
+ * * `pressed` - true for keydown, false for keyup
428
+ *
429
+ * Returns true if the event was sent successfully.
430
+ * @param {number} key_code
431
+ * @param {boolean} pressed
432
+ * @returns {boolean}
433
+ */
434
+ send_key_event(key_code, pressed) {
435
+ const ret = wasm.wasmvm_send_key_event(this.__wbg_ptr, key_code, pressed);
436
+ return ret !== 0;
437
+ }
363
438
  /**
364
439
  * Get current memory usage (DRAM size) in bytes.
365
440
  * @returns {bigint}
@@ -941,6 +1016,10 @@ function __wbg_get_imports() {
941
1016
  const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
942
1017
  return ret;
943
1018
  };
1019
+ imports.wbg.__wbg_new_with_length_202b3db94ba5fc86 = function(arg0) {
1020
+ const ret = new Uint32Array(arg0 >>> 0);
1021
+ return ret;
1022
+ };
944
1023
  imports.wbg.__wbg_new_with_length_aa5eaf41d35235e5 = function(arg0) {
945
1024
  const ret = new Uint8Array(arg0 >>> 0);
946
1025
  return ret;
@@ -1036,6 +1115,9 @@ function __wbg_get_imports() {
1036
1115
  imports.wbg.__wbg_set_index_04c4b93e64d08a52 = function(arg0, arg1, arg2) {
1037
1116
  arg0[arg1 >>> 0] = arg2;
1038
1117
  };
1118
+ imports.wbg.__wbg_set_index_42abe35f117e614e = function(arg0, arg1, arg2) {
1119
+ arg0[arg1 >>> 0] = arg2 >>> 0;
1120
+ };
1039
1121
  imports.wbg.__wbg_set_onmessage_deb94985de696ac7 = function(arg0, arg1) {
1040
1122
  arg0.onmessage = arg1;
1041
1123
  };
@@ -1115,24 +1197,24 @@ function __wbg_get_imports() {
1115
1197
  return ret;
1116
1198
  }, arguments);
1117
1199
  };
1118
- imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
1119
- const ret = getStringFromWasm0(arg0, arg1);
1200
+ imports.wbg.__wbindgen_cast_1b00663567edb453 = function(arg0, arg1) {
1201
+ const ret = makeClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h01c75dc83ec8dfae, wasm_bindgen__convert__closures_____invoke__h9f0ee31d317d33d7);
1120
1202
  return ret;
1121
1203
  };
1122
- imports.wbg.__wbindgen_cast_9d58885f229d7092 = function(arg0, arg1) {
1123
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hf225e18fc5ab9bc1, wasm_bindgen__convert__closures_____invoke__h39d3e89751b07765);
1204
+ imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
1205
+ const ret = getStringFromWasm0(arg0, arg1);
1124
1206
  return ret;
1125
1207
  };
1126
- imports.wbg.__wbindgen_cast_af54cb5d64a8cc15 = function(arg0, arg1) {
1127
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h47fb8eb45dc69cb3, wasm_bindgen__convert__closures_____invoke__hc2505ab56e11573d);
1208
+ imports.wbg.__wbindgen_cast_3d2491109ac86f9d = function(arg0, arg1) {
1209
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h612f8e24953b61d5, wasm_bindgen__convert__closures_____invoke__h260170fb96639bcf);
1128
1210
  return ret;
1129
1211
  };
1130
- imports.wbg.__wbindgen_cast_bbd4dd9b33de0f05 = function(arg0, arg1) {
1131
- const ret = makeClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h47fb8eb45dc69cb3, wasm_bindgen__convert__closures_____invoke__h50e72de47846ca00);
1212
+ imports.wbg.__wbindgen_cast_a93ea42108a71f00 = function(arg0, arg1) {
1213
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h01c75dc83ec8dfae, wasm_bindgen__convert__closures_____invoke__h74d7f37f0b0d661d);
1132
1214
  return ret;
1133
1215
  };
1134
- imports.wbg.__wbindgen_cast_d0340162226d18f2 = function(arg0, arg1) {
1135
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h47fb8eb45dc69cb3, wasm_bindgen__convert__closures_____invoke__h080c535c51d1ca28);
1216
+ imports.wbg.__wbindgen_cast_af54cb5d64a8cc15 = function(arg0, arg1) {
1217
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h01c75dc83ec8dfae, wasm_bindgen__convert__closures_____invoke__h97b9bec6245a8424);
1136
1218
  return ret;
1137
1219
  };
1138
1220
  imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {