Skip to content

Commit

Permalink
Merge pull request #334 from wasmerio/fs
Browse files Browse the repository at this point in the history
Access a WASIX instance's filesystem
  • Loading branch information
Michael Bryan authored Nov 24, 2023
2 parents f2c3204 + b6726d9 commit 571c431
Show file tree
Hide file tree
Showing 16 changed files with 715 additions and 137 deletions.
116 changes: 58 additions & 58 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 12 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "wasmer-wasix-js"
name = "wasmer-js"
version = "0.0.0"
authors = ["Syrus Akbary <syrus@wasmer.io>"]
edition = "2021"
Expand Down Expand Up @@ -48,8 +48,14 @@ features = [
"BlobPropertyBag",
"console",
"DedicatedWorkerGlobalScope",
"DomException",
"ErrorEvent",
"File",
"FileReader",
"FileSystemDirectoryHandle",
"FileSystemFileHandle",
"FileSystemGetDirectoryOptions",
"FileSystemHandle",
"Headers",
"MessageEvent",
"Navigator",
Expand All @@ -63,6 +69,7 @@ features = [
"RequestInit",
"RequestMode",
"Response",
"StorageManager",
"Url",
"WebSocket",
"Window",
Expand Down Expand Up @@ -92,10 +99,10 @@ dwarf-debug-info = false
wasm-opt = ["--enable-threads", "--enable-bulk-memory", "-Oz"]

[patch.crates-io]
virtual-net = { git = "https://github.com/wasmerio/wasmer", branch = "master" }
virtual-fs = { git = "https://github.com/wasmerio/wasmer", branch = "master" }
wasmer-wasix = { git = "https://github.com/wasmerio/wasmer", branch = "master" }
wasmer = { git = "https://github.com/wasmerio/wasmer", branch = "master" }
virtual-net = { git = "https://github.com/wasmerio/wasmer", branch = "wasi-runner-mount-fs-instances" }
virtual-fs = { git = "https://github.com/wasmerio/wasmer", branch = "wasi-runner-mount-fs-instances" }
wasmer-wasix = { git = "https://github.com/wasmerio/wasmer", branch = "wasi-runner-mount-fs-instances" }
wasmer = { git = "https://github.com/wasmerio/wasmer", branch = "wasi-runner-mount-fs-instances" }
# virtual-net = { path = "../wasmer/lib/virtual-net" }
# virtual-fs = { path = "../wasmer/lib/virtual-fs" }
# wasmer-wasix = { path = "../wasmer/lib/wasix" }
Expand Down
6 changes: 3 additions & 3 deletions lib.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Buffer } from "buffer";
export * from "./pkg/wasmer_wasix_js";
export * from "./pkg/wasmer_js";
// @ts-ignore
import load, { ThreadPoolWorker } from "./pkg/wasmer_wasix_js";
import wasm_bytes from "./pkg/wasmer_wasix_js_bg.wasm";
import load, { ThreadPoolWorker } from "./pkg/wasmer_js";
import wasm_bytes from "./pkg/wasmer_js_bg.wasm";

interface MimeBuffer extends Buffer {
type: string;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"access": "public"
},
"scripts": {
"build": "wasm-pack build --release --target=web --weak-refs --no-pack && wasm-opt pkg/wasmer_wasix_js_bg.wasm -O2 -o pkg/wasmer_wasix_js_bg.wasm && rollup -c --environment BUILD:production",
"build": "wasm-pack build --release --target=web --weak-refs --no-pack && wasm-opt pkg/wasmer_js_bg.wasm -O2 -o pkg/wasmer_js_bg.wasm && rollup -c --environment BUILD:production",
"build:dev": "wasm-pack build --dev --target=web --weak-refs --no-pack && rollup -c --environment BUILD:development",
"dev": "rollup -c -w",
"test": "web-test-runner 'tests/**/*.test.ts' --node-resolve --esbuild-target auto --config ./web-dev-server.config.mjs",
"test": "web-test-runner --node-resolve --esbuild-target auto --config ./web-dev-server.config.mjs",
"clean": "rimraf dist coverage pkg target"
},
"files": [
Expand Down
4 changes: 2 additions & 2 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export default commandLineArgs => {
const configs = [
makeConfig(),
{
input: "./pkg/wasmer_wasix_js.d.ts",
output: [{ file: "dist/pkg/wasmer_wasix_js.d.ts", format: "es" }],
input: "./pkg/wasmer_js.d.ts",
output: [{ file: "dist/pkg/wasmer_js.d.ts", format: "es" }],
plugins: [dts()],
}
];
Expand Down
4 changes: 4 additions & 0 deletions src/facade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ impl SpawnConfig {
let env = self.parse_env()?;
runner.set_envs(env);

for (dest, dir) in self.mounted_directories()? {
runner.mount(dest, Arc::new(dir));
}

if let Some(uses) = self.uses() {
let uses = crate::utils::js_string_array(uses)?;
let packages = load_injected_packages(uses, runtime).await?;
Expand Down
Loading

0 comments on commit 571c431

Please sign in to comment.