virtual-machine 0.0.0 → 0.0.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.
@@ -0,0 +1,12 @@
1
+ import {
2
+ NetworkStatus,
3
+ WasmVm,
4
+ initSync,
5
+ riscv_vm_default
6
+ } from "./chunk-GZ343GYI.mjs";
7
+ export {
8
+ NetworkStatus,
9
+ WasmVm,
10
+ riscv_vm_default as default,
11
+ initSync
12
+ };
@@ -0,0 +1,12 @@
1
+ import {
2
+ NetworkStatus,
3
+ WasmVm,
4
+ initSync,
5
+ riscv_vm_default
6
+ } from "./chunk-Q7TFYQ5G.mjs";
7
+ export {
8
+ NetworkStatus,
9
+ WasmVm,
10
+ riscv_vm_default as default,
11
+ initSync
12
+ };
package/build.sh CHANGED
@@ -5,7 +5,6 @@ is_mac() {
5
5
  [[ "$OSTYPE" == "darwin"* ]]
6
6
  }
7
7
 
8
-
9
8
  PACKAGEJSON=./pkg/package.json
10
9
  IMPORTFILE=./pkg/riscv_vm.js
11
10
 
@@ -13,14 +12,14 @@ echo "Building the rust library"
13
12
  RUSTFLAGS=--cfg=web_sys_unstable_apis npx wasm-pack build --target web
14
13
 
15
14
  if is_mac; then
16
- sed -i '' 's/"module": "riscv_vm.js",/"main": "riscv_vm.js",/' $PACKAGEJSON
17
- sed -i '' "/if (typeof input === 'undefined') {/,/}/d" $IMPORTFILE
15
+ sed -i '' 's/"module": "ridb_core.js",/"main": "ridb_core.js",/' $PACKAGEJSON
16
+ sed -i '' "/if (typeof module_or_path === 'undefined') {/,/}/d" $IMPORTFILE
18
17
  else
19
- sed -i 's/"module": "riscv_vm.js",/"main": "riscv_vm.js",/' $PACKAGEJSON
20
- sed -i "/if (typeof input === 'undefined') {/,/}/d" $IMPORTFILE
18
+ sed -i 's/"module": "ridb_core.js",/"main": "ridb_core.js",/' $PACKAGEJSON
19
+ sed -i "/if (typeof module_or_path === 'undefined') {/,/}/d" $IMPORTFILE
21
20
  fi
22
21
 
23
22
  npx tsup --config tsup/tsup.cli.ts
24
23
  npx tsup --config tsup/tsup.core.cjs.ts
25
24
  npx tsup --config tsup/tsup.core.esm.ts
26
- npx tsup --config tsup/tsup.core.cjs.ts --dts-only
25
+ npx tsup --config tsup/tsup.core.cjs.ts --dts-only
package/index.ts CHANGED
@@ -13,3 +13,4 @@ export async function WasmInternal() {
13
13
  }
14
14
 
15
15
 
16
+ export { NetworkStatus, WasmVm } from "./pkg/riscv_vm";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "virtual-machine",
3
- "version": "0.0.0",
3
+ "version": "0.0.2",
4
4
  "description": "",
5
5
  "bin": "build/cli.js",
6
6
  "publishConfig": {
package/src/main.rs CHANGED
@@ -13,9 +13,9 @@ use riscv_vm::console::Console;
13
13
  #[derive(Parser, Debug)]
14
14
  #[command(author, version, about, long_about = None)]
15
15
  struct Args {
16
- /// Path to binary to load
16
+ /// Path or URL to binary to load
17
17
  #[arg(short, long)]
18
- kernel: PathBuf,
18
+ kernel: String,
19
19
 
20
20
  /// Address to load kernel at (default 0x8000_0000)
21
21
  #[arg(long, default_value_t = 0x8000_0000)]
@@ -74,9 +74,19 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
74
74
  env_logger::init();
75
75
  let args = Args::parse();
76
76
 
77
- let mut file = File::open(&args.kernel)?;
78
- let mut buffer = Vec::new();
79
- file.read_to_end(&mut buffer)?;
77
+ let buffer = if args.kernel.starts_with("http://") || args.kernel.starts_with("https://") {
78
+ println!("Downloading kernel from {}...", args.kernel);
79
+ let response = reqwest::blocking::get(&args.kernel)?;
80
+ if !response.status().is_success() {
81
+ return Err(format!("Failed to download kernel: {}", response.status()).into());
82
+ }
83
+ response.bytes()?.to_vec()
84
+ } else {
85
+ let mut file = File::open(&args.kernel)?;
86
+ let mut buffer = Vec::new();
87
+ file.read_to_end(&mut buffer)?;
88
+ buffer
89
+ };
80
90
 
81
91
  let dram_size_bytes = args
82
92
  .mem_mib
package/tsup/index.ts CHANGED
@@ -73,7 +73,6 @@ export default function createConfig({
73
73
  "react-server-dom-webpack",
74
74
  "tsup",
75
75
  "react-server-dom-webpack/client.edge",
76
- "@trust0/ridb/worker",
77
76
  ...(external ?? [])
78
77
  ],
79
78
  }));