virtual-machine 0.0.32 → 0.0.36

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
@@ -80,6 +80,46 @@ declare class WasmVm {
80
80
  * Note: Connection is asynchronous. Check network_status() to monitor connection state.
81
81
  */
82
82
  connect_webtransport(url: string, cert_hash?: string | null): void;
83
+ /**
84
+ * Inject a network packet to be received by the guest.
85
+ * Called from JavaScript when the native WebTransport addon receives a packet.
86
+ */
87
+ inject_network_packet(packet: Uint8Array): boolean;
88
+ /**
89
+ * Extract a network packet sent by the guest.
90
+ * Returns the packet data or null if no packet is pending.
91
+ */
92
+ extract_network_packet(): Uint8Array | undefined;
93
+ /**
94
+ * Set up an external network backend for packet bridging.
95
+ * This is used by the Node.js CLI to bridge packets between the native
96
+ * WebTransport addon and the WASM VM.
97
+ *
98
+ * @param mac_bytes - MAC address as 6 bytes [0x52, 0x54, 0x00, 0x12, 0x34, 0x56]
99
+ */
100
+ setup_external_network(mac_bytes: Uint8Array): void;
101
+ /**
102
+ * Set the assigned IP address for the external network.
103
+ * Called when the native WebTransport addon receives an IP assignment.
104
+ */
105
+ set_external_network_ip(ip_bytes: Uint8Array): boolean;
106
+ /**
107
+ * Get the number of pending RX packets.
108
+ */
109
+ external_network_rx_pending(): number;
110
+ /**
111
+ * Get the number of pending TX packets.
112
+ */
113
+ external_network_tx_pending(): number;
114
+ /**
115
+ * Extract all pending network packets sent by the guest.
116
+ * Returns an array of packet data.
117
+ */
118
+ extract_all_network_packets(): Array<any>;
119
+ /**
120
+ * Check if external network is connected (has IP assigned).
121
+ */
122
+ is_external_network_connected(): boolean;
83
123
  /**
84
124
  * Create a new VM instance and load a kernel (ELF or raw binary).
85
125
  *
@@ -209,11 +249,17 @@ interface InitOutput {
209
249
  readonly __wbg_workerstate_free: (a: number, b: number) => void;
210
250
  readonly wasmvm_connect_webtransport: (a: number, b: number, c: number, d: number, e: number) => [number, number];
211
251
  readonly wasmvm_disconnect_network: (a: number) => void;
252
+ readonly wasmvm_external_network_rx_pending: (a: number) => number;
253
+ readonly wasmvm_external_network_tx_pending: (a: number) => number;
254
+ readonly wasmvm_extract_all_network_packets: (a: number) => any;
255
+ readonly wasmvm_extract_network_packet: (a: number) => any;
212
256
  readonly wasmvm_get_memory_usage: (a: number) => bigint;
213
257
  readonly wasmvm_get_output: (a: number) => number;
214
258
  readonly wasmvm_get_shared_buffer: (a: number) => any;
215
259
  readonly wasmvm_halt_code: (a: number) => bigint;
260
+ readonly wasmvm_inject_network_packet: (a: number, b: any) => number;
216
261
  readonly wasmvm_input: (a: number, b: number) => void;
262
+ readonly wasmvm_is_external_network_connected: (a: number) => number;
217
263
  readonly wasmvm_is_halted: (a: number) => number;
218
264
  readonly wasmvm_is_smp: (a: number) => number;
219
265
  readonly wasmvm_load_disk: (a: number, b: number, c: number) => void;
@@ -223,6 +269,8 @@ interface InitOutput {
223
269
  readonly wasmvm_num_harts: (a: number) => number;
224
270
  readonly wasmvm_print_banner: (a: number) => void;
225
271
  readonly wasmvm_print_status: (a: number, b: number, c: number) => void;
272
+ readonly wasmvm_set_external_network_ip: (a: number, b: any) => number;
273
+ readonly wasmvm_setup_external_network: (a: number, b: any) => [number, number];
226
274
  readonly wasmvm_start_workers: (a: number, b: number, c: number) => [number, number];
227
275
  readonly wasmvm_step: (a: number) => number;
228
276
  readonly wasmvm_step_n: (a: number, b: number) => number;
@@ -236,10 +284,10 @@ interface InitOutput {
236
284
  readonly workerstate_step_count: (a: number) => bigint;
237
285
  readonly wasm_bindgen__convert__closures_____invoke__h39d3e89751b07765: (a: number, b: number, c: any) => void;
238
286
  readonly wasm_bindgen__closure__destroy__hf225e18fc5ab9bc1: (a: number, b: number) => void;
239
- readonly wasm_bindgen__convert__closures_____invoke__h67573e759d30b522: (a: number, b: number) => void;
240
- readonly wasm_bindgen__closure__destroy__h1c929db64e64ab27: (a: number, b: number) => void;
241
- readonly wasm_bindgen__convert__closures_____invoke__hb59a63b35a5a8674: (a: number, b: number, c: any) => void;
242
- readonly wasm_bindgen__convert__closures_____invoke__hf580618779cd5844: (a: number, b: number) => void;
287
+ readonly wasm_bindgen__convert__closures_____invoke__h2d5a3433881a07dc: (a: number, b: number) => void;
288
+ readonly wasm_bindgen__closure__destroy__h4a8089319832ef98: (a: number, b: number) => void;
289
+ readonly wasm_bindgen__convert__closures_____invoke__hd016cca7bbf341cd: (a: number, b: number) => void;
290
+ readonly wasm_bindgen__convert__closures_____invoke__h07c9b936df37d4f2: (a: number, b: number, c: any) => void;
243
291
  readonly __wbindgen_malloc: (a: number, b: number) => number;
244
292
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
245
293
  readonly __wbindgen_exn_store: (a: number) => void;