virtual-machine 0.3.6 → 0.3.8

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/index.d.ts CHANGED
@@ -33,6 +33,25 @@ declare class WasmVm {
33
33
  * and the local UART buffer (for hart 0 output).
34
34
  */
35
35
  get_output(): number | undefined;
36
+ /**
37
+ * Enable D1 EMAC (Ethernet MAC) device for network hardware access.
38
+ *
39
+ * This initializes the D1 EMAC device so the kernel can probe and find
40
+ * network hardware during boot. Should be called before the kernel starts
41
+ * executing if network support is desired.
42
+ *
43
+ * Note: This only enables the EMAC hardware emulation. To actually connect
44
+ * to a network, use `connect_webtransport()` or `setup_external_network()`.
45
+ */
46
+ enable_emac(): void;
47
+ /**
48
+ * Enable D1 Audio Codec device for audio playback.
49
+ *
50
+ * The audio device allows the kernel to write audio samples which can
51
+ * then be played via WebAudio in the browser. Use `get_audio_samples()`
52
+ * to retrieve buffered samples for playback.
53
+ */
54
+ enable_audio(): void;
36
55
  /**
37
56
  * Enable VirtIO Input device for keyboard input.
38
57
  *
@@ -149,6 +168,16 @@ declare class WasmVm {
149
168
  * Returns true if the event was sent successfully.
150
169
  */
151
170
  send_touch_event(x: number, y: number, pressed: boolean): boolean;
171
+ /**
172
+ * Get buffered audio samples for playback.
173
+ *
174
+ * Returns a Float32Array of interleaved stereo samples (left, right, left, right, ...).
175
+ * Sample values are in the range [-1.0, 1.0].
176
+ *
177
+ * Call this periodically (e.g., from an AudioWorklet) to drain the audio buffer.
178
+ * Returns None if no audio device is enabled or no samples are available.
179
+ */
180
+ get_audio_samples(max_samples: number): Float32Array | undefined;
152
181
  /**
153
182
  * Get the total disk capacity from attached VirtIO block devices.
154
183
  * Returns total bytes across all block devices.
@@ -203,6 +232,12 @@ declare class WasmVm {
203
232
  * Returns None if SharedArrayBuffer is not available (single-threaded mode).
204
233
  */
205
234
  get_framebuffer_view(): Uint8Array | undefined;
235
+ /**
236
+ * Get audio sample rate.
237
+ *
238
+ * Returns the sample rate configured by the kernel (default: 48000 Hz).
239
+ */
240
+ get_audio_sample_rate(): number;
206
241
  /**
207
242
  * Get the current frame version from kernel memory.
208
243
  * Returns a u32 that increments each time the kernel flushes dirty pixels.
@@ -225,6 +260,13 @@ declare class WasmVm {
225
260
  * Returns the packet data or null if no packet is pending.
226
261
  */
227
262
  extract_network_packet(): Uint8Array | undefined;
263
+ /**
264
+ * Get current audio buffer fill level.
265
+ *
266
+ * Returns the number of sample pairs (stereo frames) currently buffered.
267
+ * Useful for monitoring buffer health in the JavaScript audio worklet.
268
+ */
269
+ get_audio_buffer_level(): number;
228
270
  /**
229
271
  * Set up an external network backend for packet bridging.
230
272
  * This is used by the Node.js CLI to bridge packets between the native
@@ -412,6 +454,8 @@ interface InitOutput {
412
454
  readonly wasmvm_allow_workers_to_start: (a: number) => void;
413
455
  readonly wasmvm_connect_webtransport: (a: number, b: number, c: number, d: number, e: number) => [number, number];
414
456
  readonly wasmvm_disconnect_network: (a: number) => void;
457
+ readonly wasmvm_enable_audio: (a: number) => void;
458
+ readonly wasmvm_enable_emac: (a: number) => void;
415
459
  readonly wasmvm_enable_gpu: (a: number, b: number, c: number) => void;
416
460
  readonly wasmvm_enable_input: (a: number) => void;
417
461
  readonly wasmvm_entry_pc: (a: number) => bigint;
@@ -419,6 +463,9 @@ interface InitOutput {
419
463
  readonly wasmvm_external_network_tx_pending: (a: number) => number;
420
464
  readonly wasmvm_extract_all_network_packets: (a: number) => any;
421
465
  readonly wasmvm_extract_network_packet: (a: number) => any;
466
+ readonly wasmvm_get_audio_buffer_level: (a: number) => number;
467
+ readonly wasmvm_get_audio_sample_rate: (a: number) => number;
468
+ readonly wasmvm_get_audio_samples: (a: number, b: number) => any;
422
469
  readonly wasmvm_get_cpu_count: (a: number) => number;
423
470
  readonly wasmvm_get_disk_capacity: (a: number) => bigint;
424
471
  readonly wasmvm_get_disk_usage: (a: number) => any;
@@ -466,12 +513,12 @@ interface InitOutput {
466
513
  readonly workerstate_step_batch: (a: number, b: number) => number;
467
514
  readonly workerstate_step_count: (a: number) => bigint;
468
515
  readonly worker_entry: (a: number, b: any, c: bigint) => void;
469
- readonly wasm_bindgen__convert__closures_____invoke__h927a3e68f2df660d: (a: number, b: number) => void;
470
- readonly wasm_bindgen__closure__destroy__hb58c972534bceec0: (a: number, b: number) => void;
471
- readonly wasm_bindgen__convert__closures_____invoke__h65568fa7dcc5b42c: (a: number, b: number, c: any) => void;
516
+ readonly wasm_bindgen__convert__closures_____invoke__hc5b8c13000acc255: (a: number, b: number, c: any) => void;
517
+ readonly wasm_bindgen__closure__destroy__h1fe9f7c0c3fcba87: (a: number, b: number) => void;
472
518
  readonly wasm_bindgen__convert__closures_____invoke__h260170fb96639bcf: (a: number, b: number, c: any) => void;
473
519
  readonly wasm_bindgen__closure__destroy__h612f8e24953b61d5: (a: number, b: number) => void;
474
- readonly wasm_bindgen__convert__closures_____invoke__h6348bc2e0e4ff171: (a: number, b: number) => void;
520
+ readonly wasm_bindgen__convert__closures_____invoke__h383863cda42dd205: (a: number, b: number) => void;
521
+ readonly wasm_bindgen__convert__closures_____invoke__h68e5328ec502c4d7: (a: number, b: number) => void;
475
522
  readonly __wbindgen_malloc: (a: number, b: number) => number;
476
523
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
477
524
  readonly __wbindgen_exn_store: (a: number) => void;