virtual-machine 0.0.2 → 0.0.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.
@@ -0,0 +1,12 @@
1
+ import {
2
+ NetworkStatus,
3
+ WasmVm,
4
+ initSync,
5
+ riscv_vm_default
6
+ } from "./chunk-LJUNPJTY.mjs";
7
+ export {
8
+ NetworkStatus,
9
+ WasmVm,
10
+ riscv_vm_default as default,
11
+ initSync
12
+ };
package/cli.ts CHANGED
@@ -38,9 +38,26 @@ async function createVm(
38
38
  certHash?: string;
39
39
  },
40
40
  ) {
41
- const resolvedKernel = path.resolve(kernelPath);
42
- const kernelBuf = fs.readFileSync(resolvedKernel);
43
- const kernelBytes = new Uint8Array(kernelBuf);
41
+ let kernelBytes: Uint8Array;
42
+
43
+ if (kernelPath.startsWith('http://') || kernelPath.startsWith('https://')) {
44
+ console.error(`[CLI] Downloading kernel from ${kernelPath}...`);
45
+ const response = await fetch(kernelPath);
46
+ if (!response.ok) {
47
+ throw new Error(
48
+ `Failed to fetch kernel from ${kernelPath}: ${response.statusText}`,
49
+ );
50
+ }
51
+ const arrayBuffer = await response.arrayBuffer();
52
+ kernelBytes = new Uint8Array(arrayBuffer);
53
+ } else {
54
+ const resolvedKernel = path.resolve(kernelPath);
55
+ if (!fs.existsSync(resolvedKernel)) {
56
+ throw new Error(`Kernel file not found at ${resolvedKernel}`);
57
+ }
58
+ const kernelBuf = fs.readFileSync(resolvedKernel);
59
+ kernelBytes = new Uint8Array(kernelBuf);
60
+ }
44
61
 
45
62
  const { WasmInternal } = await import('./');
46
63
  const wasm = await WasmInternal();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "virtual-machine",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "",
5
5
  "bin": "build/cli.js",
6
6
  "publishConfig": {