diff --git a/.github/workflows/wapm.yml b/.github/workflows/wapm.yml new file mode 100644 index 000000000..10571523b --- /dev/null +++ b/.github/workflows/wapm.yml @@ -0,0 +1,30 @@ +name: CI +on: + push: + branches: [ wapm ] + pull_request: + branches: [ wapm ] + +env: + CARGO_TERM_COLOR: always + RUST_MIN_STACK: 20971520 + +jobs: + tokterm: + name: Build Wapm Shell + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - name: Build + run: | + cd tokterm + npm install + npm run build + cp -r public/* dist/ + - name: Publish documentation + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: tokterm/dist diff --git a/Cargo.toml b/Cargo.toml index 025c5aef6..361657fcc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,16 @@ members = [ [patch.crates-io] tokio = { git = "https://github.com/john-sharratt/tokio.git", branch = "wasix" } -wasmer-vfs = { path = "/prog/wasmer/lib/vfs" } + +wasmer = { path = "../../wasmer/lib/api" } +wasmer-wasi = { path = "../../wasmer/lib/wasi" } +wasmer-vfs = { path = "../../wasmer/lib/vfs" } +wasmer-compiler-cranelift = { path = "../../wasmer/lib/compiler-cranelift" } +wasmer-compiler-llvm = { path = "../../wasmer/lib/compiler-llvm" } +wasmer-compiler-singlepass = { path = "../../wasmer/lib/compiler-singlepass" } +wasmer-compiler = { path = "../../wasmer/lib/compiler" } +wasmer-emscripten = { path = "../../wasmer/lib/emscripten" } +wasmer-wasi-local-networking = { path = "../../wasmer/lib/wasi-local-networking" } + #tokio = { path = "/prog/tokio/tokio" } diff --git a/atedb/Cargo.toml b/atedb/Cargo.toml index 52148ff2b..bc7a0261f 100644 --- a/atedb/Cargo.toml +++ b/atedb/Cargo.toml @@ -7,7 +7,7 @@ description = "Distributed datachain (database) built on an immutable data store license = "MIT OR Apache-2.0" keywords = ["immutable", "database", "server", "async" ] categories = ["database", "cryptography", "database-implementations", "asynchronous"] -repository = "https://github.com/john-sharratt/ate/atedb" +repository = "https://github.com/wasmerio/ate/atedb" readme = "README.md" [features] diff --git a/comms/Cargo.toml b/comms/Cargo.toml index 2c5a79617..ff24148e8 100644 --- a/comms/Cargo.toml +++ b/comms/Cargo.toml @@ -7,7 +7,7 @@ description = "Provides the communication library integrates with ate" license = "MIT OR Apache-2.0" keywords = [ "networking" ] categories = [ "networking" ] -repository = "https://github.com/john-sharratt/ate" +repository = "https://github.com/wasmerio/ate" readme = "README.md" [features] diff --git a/crypto/Cargo.toml b/crypto/Cargo.toml index a9414588c..e3a0b61ac 100644 --- a/crypto/Cargo.toml +++ b/crypto/Cargo.toml @@ -7,7 +7,7 @@ description = "Provides all the cryptographic functions" license = "MIT OR Apache-2.0" keywords = [ "cryptography" ] categories = [ "cryptography" ] -repository = "https://github.com/john-sharratt/ate" +repository = "https://github.com/wasmerio/ate" readme = "README.md" [features] diff --git a/files/Cargo.toml b/files/Cargo.toml index 9b345782e..6e25006ca 100644 --- a/files/Cargo.toml +++ b/files/Cargo.toml @@ -7,7 +7,7 @@ description = "Model and helper functions for access files stored in ATEs" license = "MIT OR Apache-2.0" keywords = ["immutable", "filesystem", "fs" ] categories = ["filesystem", "database", "development-tools"] -repository = "https://github.com/john-sharratt/ate/tree/master/wasmer-dfs" +repository = "https://github.com/wasmerio/ate/tree/master/wasmer-dfs" readme = "README.md" [features] diff --git a/files/README.md b/files/README.md index 530a084e5..959921476 100644 --- a/files/README.md +++ b/files/README.md @@ -8,7 +8,7 @@ from the distributed redo log.. ## What is ATE -[See here](https://github.com/john-sharratt/ate/blob/master/README.md) +[See here](https://github.com/wasmerio/ate/blob/master/README.md) ## Contribution diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 205644929..378c8b6d2 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -7,7 +7,7 @@ description = "Distributed immutable data store with strong encryption and authe license = "MIT OR Apache-2.0" keywords = ["immutable", "database", "crypto", "nosql", "async"] categories = ["asynchronous", "caching", "cryptography", "database-implementations"] -repository = "https://github.com/john-sharratt/ate" +repository = "https://github.com/wasmerio/ate" readme = "../README.md" [features] diff --git a/wasmer-auth/Cargo.toml b/wasmer-auth/Cargo.toml index 6adf13422..feb742907 100644 --- a/wasmer-auth/Cargo.toml +++ b/wasmer-auth/Cargo.toml @@ -7,7 +7,7 @@ description = "Represents a standardized data model and API for authenticating a license = "MIT OR Apache-2.0" keywords = [ "authentication", "cli", "authorization", "crypto" ] categories = [ "data-structures", "command-line-utilities", "authentication", "cryptography" ] -repository = "https://github.com/john-sharratt/ate/auth" +repository = "https://github.com/wasmerio/ate/auth" readme = "README.md" [[bin]] diff --git a/wasmer-bus/deploy/Cargo.toml b/wasmer-bus/deploy/Cargo.toml index d3cf1f2be..971b4a04d 100644 --- a/wasmer-bus/deploy/Cargo.toml +++ b/wasmer-bus/deploy/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" description = "WebAssembly fuse bus interface" license = "MIT OR Apache-2.0" keywords = [ "wasi", "wasm", "bus", "fuse" ] -repository = "https://github.com/john-sharratt/ate" +repository = "https://github.com/wasmerio/ate" readme = "README.md" [features] diff --git a/wasmer-bus/fuse/Cargo.toml b/wasmer-bus/fuse/Cargo.toml index f3bf442de..fa461f2f8 100644 --- a/wasmer-bus/fuse/Cargo.toml +++ b/wasmer-bus/fuse/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" description = "WebAssembly fuse bus interface" license = "MIT OR Apache-2.0" keywords = [ "wasi", "wasm", "bus", "fuse" ] -repository = "https://github.com/john-sharratt/ate" +repository = "https://github.com/wasmerio/ate" readme = "README.md" [features] diff --git a/wasmer-bus/hello/Cargo.toml b/wasmer-bus/hello/Cargo.toml index dde6c8ed1..4957c7705 100644 --- a/wasmer-bus/hello/Cargo.toml +++ b/wasmer-bus/hello/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" description = "WebAssembly Bus Hello World" license = "MIT OR Apache-2.0" keywords = [ "wasi", "wasm", "bus", "time" ] -repository = "https://github.com/john-sharratt/ate" +repository = "https://github.com/wasmerio/ate" readme = "README.md" [features] diff --git a/wasmer-bus/lib/Cargo.toml b/wasmer-bus/lib/Cargo.toml index 513f427a9..42d46becb 100644 --- a/wasmer-bus/lib/Cargo.toml +++ b/wasmer-bus/lib/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" description = "Invocation bus for web assembly modules" license = "MIT OR Apache-2.0" keywords = [ "wasi", "wasm", "bus" ] -repository = "https://github.com/john-sharratt/ate" +repository = "https://github.com/wasmerio/ate" readme = "README.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/wasmer-bus/macros/Cargo.toml b/wasmer-bus/macros/Cargo.toml index 31a395caf..70bf1ed40 100644 --- a/wasmer-bus/macros/Cargo.toml +++ b/wasmer-bus/macros/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" description = "WebAssembly Bus Macros" license = "MIT OR Apache-2.0" keywords = [ "wasi", "wasm", "bus" ] -repository = "https://github.com/john-sharratt/ate" +repository = "https://github.com/wasmerio/ate" readme = "README.md" [lib] diff --git a/wasmer-bus/mio/Cargo.toml b/wasmer-bus/mio/Cargo.toml index 897091846..e08cae1f1 100644 --- a/wasmer-bus/mio/Cargo.toml +++ b/wasmer-bus/mio/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" description = "WebAssembly MIO" license = "MIT OR Apache-2.0" keywords = [ "wasi", "wasm", "opengl", "webgl" ] -repository = "https://github.com/john-sharratt/ate" +repository = "https://github.com/wasmerio/ate" readme = "README.md" [features] diff --git a/wasmer-bus/process/Cargo.toml b/wasmer-bus/process/Cargo.toml index 7e7cec1ab..5c8e85a34 100644 --- a/wasmer-bus/process/Cargo.toml +++ b/wasmer-bus/process/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" description = "WebAssembly Process Interface" license = "MIT OR Apache-2.0" keywords = [ "wasi", "wasm", "bus", "process" ] -repository = "https://github.com/john-sharratt/ate" +repository = "https://github.com/wasmerio/ate" readme = "README.md" [features] diff --git a/wasmer-bus/reqwest/Cargo.toml b/wasmer-bus/reqwest/Cargo.toml index 46fe090eb..edcec6a22 100644 --- a/wasmer-bus/reqwest/Cargo.toml +++ b/wasmer-bus/reqwest/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" description = "WebAssembly HTTP(s) Web Request Interface" license = "MIT OR Apache-2.0" keywords = [ "wasi", "wasm", "bus", "http", "api" ] -repository = "https://github.com/john-sharratt/ate" +repository = "https://github.com/wasmerio/ate" readme = "README.md" [features] diff --git a/wasmer-bus/time/Cargo.toml b/wasmer-bus/time/Cargo.toml index 068f967e8..a83cc13d0 100644 --- a/wasmer-bus/time/Cargo.toml +++ b/wasmer-bus/time/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" description = "WebAssembly Time Interface" license = "MIT OR Apache-2.0" keywords = [ "wasi", "wasm", "bus", "time" ] -repository = "https://github.com/john-sharratt/ate" +repository = "https://github.com/wasmerio/ate" readme = "README.md" [features] diff --git a/wasmer-bus/tty/Cargo.toml b/wasmer-bus/tty/Cargo.toml index 61950330e..4e091db7b 100644 --- a/wasmer-bus/tty/Cargo.toml +++ b/wasmer-bus/tty/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" description = "WebAssembly Terminal Interface" license = "MIT OR Apache-2.0" keywords = [ "wasi", "wasm", "bus", "websocket" ] -repository = "https://github.com/john-sharratt/ate" +repository = "https://github.com/wasmerio/ate" readme = "README.md" [features] diff --git a/wasmer-bus/types/Cargo.toml b/wasmer-bus/types/Cargo.toml index b0267fa8b..fe3d2c211 100644 --- a/wasmer-bus/types/Cargo.toml +++ b/wasmer-bus/types/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" description = "WebAssembly Bus Macros" license = "MIT OR Apache-2.0" keywords = [ "wasi", "wasm", "bus" ] -repository = "https://github.com/john-sharratt/ate" +repository = "https://github.com/wasmerio/ate" readme = "README.md" [features] diff --git a/wasmer-bus/webgl/Cargo.toml b/wasmer-bus/webgl/Cargo.toml index ab9c23493..dc281bbf6 100644 --- a/wasmer-bus/webgl/Cargo.toml +++ b/wasmer-bus/webgl/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" description = "WebAssembly WebGL Interface" license = "MIT OR Apache-2.0" keywords = [ "wasi", "wasm", "opengl", "webgl" ] -repository = "https://github.com/john-sharratt/ate" +repository = "https://github.com/wasmerio/ate" readme = "README.md" [features] diff --git a/wasmer-bus/ws/Cargo.toml b/wasmer-bus/ws/Cargo.toml index e025b9ee3..0d1f2dfd0 100644 --- a/wasmer-bus/ws/Cargo.toml +++ b/wasmer-bus/ws/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" description = "WebAssembly Web Socket Interface" license = "MIT OR Apache-2.0" keywords = [ "wasi", "wasm", "bus", "websocket" ] -repository = "https://github.com/john-sharratt/ate" +repository = "https://github.com/wasmerio/ate" readme = "README.md" [features] diff --git a/wasmer-dfs/README.md b/wasmer-dfs/README.md index 0c5e727f1..87c58b4d7 100644 --- a/wasmer-dfs/README.md +++ b/wasmer-dfs/README.md @@ -10,7 +10,7 @@ particular varient has some unique qualities that differentiate it from others. ## What is ATE -[See here](https://github.com/john-sharratt/ate/blob/master/README.md) +[See here](https://github.com/wasmerio/ate/blob/master/README.md) ## Summary diff --git a/wasmer-dnet/Cargo.toml b/wasmer-dnet/Cargo.toml index 492047548..2b67d02d1 100644 --- a/wasmer-dnet/Cargo.toml +++ b/wasmer-dnet/Cargo.toml @@ -11,7 +11,7 @@ keywords = [ "http-server", ] categories = ["network-programming", "web-programming::http-server"] -repository = "https://github.com/john-sharratt/ate/tree/master/wasmer-dfs" +repository = "https://github.com/wasmerio/ate/tree/master/wasmer-dfs" readme = "README.md" [features] diff --git a/wasmer-gw/Cargo.toml b/wasmer-gw/Cargo.toml index 0f06dc845..707b9b2d3 100644 --- a/wasmer-gw/Cargo.toml +++ b/wasmer-gw/Cargo.toml @@ -11,7 +11,7 @@ keywords = [ "http-server", ] categories = ["network-programming", "web-programming::http-server"] -repository = "https://github.com/john-sharratt/ate/tree/master/wasmer-dfs" +repository = "https://github.com/wasmerio/ate/tree/master/wasmer-dfs" readme = "README.md" [features] diff --git a/wasmer-gw/README.md b/wasmer-gw/README.md index 742b33d04..de66cdf0d 100644 --- a/wasmer-gw/README.md +++ b/wasmer-gw/README.md @@ -16,7 +16,7 @@ AteWeb also includes an automation certificate generation engine using LetsEncry ## What is ATE -[See here](https://github.com/john-sharratt/ate/blob/master/README.md) +[See here](https://github.com/wasmerio/ate/blob/master/README.md) ## Contribution diff --git a/wasmer-instance/Cargo.toml b/wasmer-instance/Cargo.toml index db53da74e..8ac68ba22 100644 --- a/wasmer-instance/Cargo.toml +++ b/wasmer-instance/Cargo.toml @@ -9,7 +9,7 @@ keywords = [ "ssh-server", "wasm" ] -repository = "https://github.com/john-sharratt/ate/tree/master/wasmer-instance" +repository = "https://github.com/wasmerio/ate/tree/master/wasmer-instance" readme = "README.md" [features] diff --git a/wasmer-instance/README.md b/wasmer-instance/README.md index ab718378c..9545838a2 100644 --- a/wasmer-instance/README.md +++ b/wasmer-instance/README.md @@ -17,7 +17,7 @@ running with full wasmer-bus support. ## What is ATE -[See here](https://github.com/john-sharratt/ate/blob/master/README.md) +[See here](https://github.com/wasmerio/ate/blob/master/README.md) ## Contribution diff --git a/wasmer-os-grammar/Cargo.toml b/wasmer-os-grammar/Cargo.toml index 9acc29b2d..4a90be50b 100644 --- a/wasmer-os-grammar/Cargo.toml +++ b/wasmer-os-grammar/Cargo.toml @@ -7,7 +7,7 @@ publish = true description = "Terminal Shell Grammar" license = "MIT OR Apache-2.0" keywords = [ "wasm", "browser", "terminal" ] -repository = "https://github.com/john-sharratt/ate" +repository = "https://github.com/wasmerio/ate" readme = "../README.md" [dependencies] diff --git a/wasmer-os/Cargo.toml b/wasmer-os/Cargo.toml index 5044c8dc6..08d8309a8 100644 --- a/wasmer-os/Cargo.toml +++ b/wasmer-os/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" description = "Terminal Library built on WASMER and ATE" license = "MIT OR Apache-2.0" keywords = [ "wasm", "browser", "terminal" ] -repository = "https://github.com/john-sharratt/ate" +repository = "https://github.com/wasmerio/ate" readme = "../README.md" [features] @@ -24,29 +24,30 @@ async_ws = [ ] [dependencies] wasmer-os-grammar = { version = "^0.1", path = "../wasmer-os-grammar", package = "wasmer-os-grammar" } -#wasmer = { version = "3.0.0-beta", git = "https://github.com/john-sharratt/wasmer.git", branch = "wasmer3-wasix", default-features = false, features = [ "wat"] } -#wasmer-wasi = { version = "3.0.0-beta", git = "https://github.com/john-sharratt/wasmer.git", branch = "wasmer3-wasix", default-features = false, features = [ "mem-fs" ] } -#wasmer-vfs = { version = "3.0.0-beta", git = "https://github.com/john-sharratt/wasmer.git", branch = "wasmer3-wasix", default-features = false, features = ["mem-fs"] } -#wasmer-vnet = { version = "3.0.0-beta", git = "https://github.com/john-sharratt/wasmer.git", branch = "wasmer3-wasix", default-features = false } -#wasmer-vbus = { version = "3.0.0-beta", git = "https://github.com/john-sharratt/wasmer.git", branch = "wasmer3-wasix", default-features = false } -#wasmer-compiler-cranelift = { version = "3.0.0-beta", git = "https://github.com/john-sharratt/wasmer.git", branch = "wasmer3-wasix", optional = true } -#wasmer-compiler-llvm = { version = "3.0.0-beta", git = "https://github.com/john-sharratt/wasmer.git", branch = "wasmer3-wasix", optional = true } -#wasmer-compiler-singlepass = { version = "3.0.0-beta", git = "https://github.com/john-sharratt/wasmer.git", branch = "wasmer3-wasix", optional = true } -#wasmer-compiler = { version = "3.0.0-beta", git = "https://github.com/john-sharratt/wasmer.git", branch = "wasmer3-wasix", features = [ "translator" ], optional = true } -#wasmer-wasi-local-networking = { version = "3.0.0-beta", git = "https://github.com/john-sharratt/wasmer.git", branch = "wasmer3-wasix", optional = true } +wasmer = { version = "3.0.0-beta", git = "https://github.com/wasmerio/wasmer.git", branch = "wasix", default-features = false, features = [ "wat"] } +wasmer-wasi = { version = "3.0.0-beta", git = "https://github.com/wasmerio/wasmer.git", branch = "wasix", default-features = false, features = [ "mem-fs" ] } +wasmer-vfs = { version = "3.0.0-beta", git = "https://github.com/wasmerio/wasmer.git", branch = "wasix", default-features = false, features = ["mem-fs"] } +wasmer-vnet = { version = "3.0.0-beta", git = "https://github.com/wasmerio/wasmer.git", branch = "wasix", default-features = false } +wasmer-vbus = { version = "3.0.0-beta", git = "https://github.com/wasmerio/wasmer.git", branch = "wasix", default-features = false } +wasmer-compiler-cranelift = { version = "3.0.0-beta", git = "https://github.com/wasmerio/wasmer.git", branch = "wasix", optional = true } +wasmer-compiler-llvm = { version = "3.0.0-beta", git = "https://github.com/wasmerio/wasmer.git", branch = "wasix", optional = true } +wasmer-compiler-singlepass = { version = "3.0.0-beta", git = "https://github.com/wasmerio/wasmer.git", branch = "wasix", optional = true } +wasmer-compiler = { version = "3.0.0-beta", git = "https://github.com/wasmerio/wasmer.git", branch = "wasix", features = [ "translator" ], optional = true } +wasmer-wasi-local-networking = { version = "3.0.0-beta", git = "https://github.com/wasmerio/wasmer.git", branch = "wasix", optional = true } -wasmer = { version = "3.0.0-beta", path = "../../wasmer/lib/api", default-features = false, features = [ "wat", "tracing" ] } -wasmer-wasi = { version = "3.0.0-beta", path = "../../wasmer/lib/wasi", default-features = false, features = [ "mem-fs" ] } -wasmer-vfs = { version = "3.0.0-beta", path = "../../wasmer/lib/vfs", default-features = false, features = ["mem-fs"] } -wasmer-vnet = { version = "3.0.0-beta", path = "../../wasmer/lib/vnet", default-features = false } -wasmer-vbus = { version = "3.0.0-beta", path = "../../wasmer/lib/vbus", default-features = false } -wasmer-compiler-cranelift = { version = "3.0.0-beta", path = "../../wasmer/lib/compiler-cranelift", optional = true } -wasmer-compiler-llvm = { version = "3.0.0-beta", path = "../../wasmer/lib/compiler-llvm", optional = true } -wasmer-compiler-singlepass = { version = "3.0.0-beta", path = "../../wasmer/lib/compiler-singlepass", optional = true } -wasmer-compiler = { version = "3.0.0-beta", path = "../../wasmer/lib/compiler", features = [ "translator" ], optional = true } -wasmer-wasi-local-networking = { version = "3.0.0-beta", path = "../../wasmer/lib/wasi-local-networking", optional = true } -webc = { version = "0.1", path = "../../pirita/crates/webc" } -webc-vfs = { version = "0.1", path = "../../pirita/crates/webc-vfs" } +# wasmer = { version = "3.0.0-beta", path = "../../../wasmer/lib/api", default-features = false, features = [ "wat", "tracing" ] } +# wasmer-wasi = { version = "3.0.0-beta", path = "../../../wasmer/lib/wasi", default-features = false, features = [ "mem-fs" ] } +# wasmer-vfs = { version = "3.0.0-beta", path = "../../../wasmer/lib/vfs", default-features = false, features = ["mem-fs"] } +# wasmer-vnet = { version = "3.0.0-beta", path = "../../../wasmer/lib/vnet", default-features = false } +# wasmer-vbus = { version = "3.0.0-beta", path = "../../../wasmer/lib/vbus", default-features = false } +# wasmer-compiler-cranelift = { version = "3.0.0-beta", path = "../../../wasmer/lib/compiler-cranelift", optional = true } +# wasmer-compiler-llvm = { version = "3.0.0-beta", path = "../../../wasmer/lib/compiler-llvm", optional = true } +# wasmer-compiler-singlepass = { version = "3.0.0-beta", path = "../../../wasmer/lib/compiler-singlepass", optional = true } +# wasmer-compiler = { version = "3.0.0-beta", path = "../../../wasmer/lib/compiler", features = [ "translator" ], optional = true } +# wasmer-wasi-local-networking = { version = "3.0.0-beta", path = "../../../wasmer/lib/wasi-local-networking", optional = true } + +webc = { version = "0.1", path = "../../../pirita/crates/webc" } +webc-vfs = { version = "0.1", path = "../../../pirita/crates/webc-vfs" } chrono = { version = "^0.4", git = "https://github.com/john-sharratt/chrono.git" } tracing = { version = "^0.1" } diff --git a/wasmer-os/src/builtins/export.rs b/wasmer-os/src/builtins/export.rs index f33c7b419..455212d8d 100644 --- a/wasmer-os/src/builtins/export.rs +++ b/wasmer-os/src/builtins/export.rs @@ -33,9 +33,9 @@ pub(super) fn export( for arg in &args[1..] { if arg.contains('=') { - let key = ctx.env.parse_key(arg); + let (key, value) = ctx.env.parse_key_value(arg); ctx.env.export(key.as_str()); - ctx.env.set_vareq_with_key(key, arg.clone()); + ctx.env.set_var(&key, value); } else { ctx.env.export(arg.as_str()) } diff --git a/wasmer-os/src/builtins/readonly.rs b/wasmer-os/src/builtins/readonly.rs index 39ab4ab81..3c2d466c5 100644 --- a/wasmer-os/src/builtins/readonly.rs +++ b/wasmer-os/src/builtins/readonly.rs @@ -33,9 +33,9 @@ pub(super) fn readonly( for arg in &args[1..] { if arg.contains('=') { - let key = ctx.env.parse_key(arg); + let (key, value) = ctx.env.parse_key_value(arg); ctx.env.readonly(key.as_str()); - ctx.env.set_vareq_with_key(key, arg.clone()); + ctx.env.set_var(&key, value); } else { ctx.env.readonly(arg.as_str()) } diff --git a/wasmer-os/src/builtins/wax.rs b/wasmer-os/src/builtins/wax.rs index a148754e8..4f2daaef4 100644 --- a/wasmer-os/src/builtins/wax.rs +++ b/wasmer-os/src/builtins/wax.rs @@ -44,8 +44,8 @@ pub(super) fn wax( ctx.stdio.stdin = stdin_fd; ctx.stdio.stdout = tty.clone(); ctx.stdio.stderr = tty.clone(); - - let eval_cmd = format!("wapm install {}", cmd); + + let eval_cmd = format!("wapm install {}", cmd); let mut process = eval(eval_cmd, ctx); let result = process.recv().await; @@ -64,9 +64,9 @@ pub(super) fn wax( // Now actually run the main script ctx.stdio = stdio; - + let cmd = script; - + let mut stdout = ctx.stdio.stdout.clone(); let mut stderr = ctx.stdio.stderr.clone(); diff --git a/wasmer-os/src/cconst.rs b/wasmer-os/src/cconst.rs index 514f9f145..a60521e35 100644 --- a/wasmer-os/src/cconst.rs +++ b/wasmer-os/src/cconst.rs @@ -55,6 +55,7 @@ impl Tty { pub const TERM_NO_WRAPAROUND: &'static str = "\x1b[?7l"; pub const TERM_NO_REVERSE_WRAPAROUND: &'static str = "\x1b[?45l"; + pub const COL_BOLD: &'static str = "\x1B[34;1m"; pub const COL_RESET: &'static str = "\x1B[0m"; pub const COL_BLACK: &'static str = "\x1B[0;30m"; pub const COL_GRAY: &'static str = "\x1B[1;30m"; diff --git a/wasmer-os/src/console.rs b/wasmer-os/src/console.rs index f9cc9e5c2..5cd811a5d 100644 --- a/wasmer-os/src/console.rs +++ b/wasmer-os/src/console.rs @@ -2,10 +2,11 @@ #![allow(dead_code)] use std::collections::HashMap; use std::path::Path; +use std::sync::atomic::AtomicBool; use std::sync::Arc; use std::sync::Mutex; -use std::sync::atomic::AtomicBool; use tokio::sync::mpsc; +use tokio::sync::oneshot; use tokio::sync::RwLock; #[allow(unused_imports, dead_code)] use tracing::{debug, error, info, trace, warn}; @@ -55,9 +56,7 @@ pub struct Console { exit_on_return_to_shell: bool } -impl Drop -for Console -{ +impl Drop for Console { fn drop(&mut self) { let state = self.state.clone(); let reactor = self.reactor.clone(); @@ -92,7 +91,7 @@ impl Console { cache_webc_dir ); let reactor = Arc::new(RwLock::new(Reactor::new())); - + Self::new_ext( location, user_agent, @@ -213,7 +212,11 @@ impl Console { Console::update_prompt(false, &self.state, &self.tty).await; } - pub async fn init(&mut self) { + pub async fn init( + &mut self, + run_command: Option, + callback: Option>, + ) { let mut location_file = self .state .lock() @@ -229,13 +232,6 @@ impl Console { .write_all(self.location.as_str().as_bytes()) .unwrap(); - let run_command = self - .location - .query_pairs() - .filter(|(key, _)| key == "run-command" || key == "init") - .next() - .map(|(_, val)| val.to_string()); - if let Some(run_command) = &run_command { let mut init_file = self .state @@ -255,11 +251,11 @@ impl Console { if self.wizard.is_some() { self.on_wizard(None).await; } else { - self.start_shell().await; + self.start_shell(callback).await; } } - pub async fn start_shell(&mut self) { + pub async fn start_shell(&mut self, callback: Option>) { if self.whitelabel == false && self.no_welcome == false { self.tty.draw_welcome().await; } @@ -278,9 +274,9 @@ impl Console { } else { format!("login --token {}", token) }; - self.on_enter_internal(cmd, false).await; + self.on_enter_internal(cmd, false, callback).await; } else if has_init { - self.on_enter_internal("source /bin/init".to_string(), false) + self.on_enter_internal("source /bin/init".to_string(), false, callback) .await; } else { self.tty.draw_prompt().await; @@ -358,8 +354,6 @@ impl Console { state.path.clone(), Vec::new(), state.rootfs.clone(), - #[cfg(feature = "sys")] - self.engine.clone(), self.compiler, ) }; @@ -386,7 +380,7 @@ impl Console { } } - self.start_shell().await; + self.start_shell(None).await; return; } } @@ -394,6 +388,10 @@ impl Console { } pub async fn on_enter(&mut self) { + self.on_enter_with_callback(None).await; + } + + pub async fn on_enter_with_callback(&mut self, callback: Option>) { self.tty.set_cursor_to_end().await; let cmd = self.tty.get_paragraph().await; @@ -404,10 +402,29 @@ impl Console { self.tty.draw("\r\n").await; - self.on_enter_internal(cmd, true).await + self.on_enter_internal(cmd, true, callback).await + } + + pub fn set_env(&mut self, key: &str, value: &str) { + let mut state = self.state.lock().unwrap(); + state.env.set_var(key, value.to_string()); + state.env.export(key); + } + + pub fn set_envs(&mut self, envs: &HashMap) { + let mut state = self.state.lock().unwrap(); + envs.iter().for_each(|(k, v)| { + state.env.set_var(k, v.to_string()); + state.env.export(k); + }); } - pub async fn on_enter_internal(&mut self, mut cmd: String, record_history: bool) { + pub async fn on_enter_internal( + &mut self, + mut cmd: String, + record_history: bool, + callback: Option>, + ) { let mode = self.tty.mode().await; if let TtyMode::StdIn(job) = mode { cmd += "\n"; @@ -452,6 +469,15 @@ impl Console { let state = self.state.clone(); let mut stdout = ctx.stdout.clone(); let mut stderr = ctx.stderr.clone(); + + let (code_sender, code_receiver) = oneshot::channel::(); + + if let Some(callback) = callback { + system.fork_local(code_receiver.map(|code| { + callback(code.unwrap()); + })); + } + let abi = ctx.abi.clone(); let exit_on_return_to_shell = self.exit_on_return_to_shell; system.fork_dedicated_async(move || { @@ -474,13 +500,15 @@ impl Console { // Process the result let mut multiline_input = false; - if let Some(rx) = rx { - match rx.status { + let finished = if let Some(rx) = rx { + let code = match rx.status { EvalStatus::Executed { code, show_result } => { debug!("eval executed (code={})", code); let should_line_feed = { let state = state.lock().unwrap(); - state.unfinished_line.load(std::sync::atomic::Ordering::Acquire) + state + .unfinished_line + .load(std::sync::atomic::Ordering::Acquire) }; if record_history { @@ -495,21 +523,25 @@ impl Console { } else if should_line_feed { tty.draw("\r\n").await; } + Some(code) } EvalStatus::InternalError => { debug!("eval internal error"); tty.draw("term: internal error\r\n").await; + None } EvalStatus::MoreInput => { debug!("eval more input"); multiline_input = true; tty.add(cmd.as_str()).await; + None } EvalStatus::Invalid => { debug!("eval invalid"); tty.draw("term: invalid command\r\n").await; + None } - } + }; // Process any changes to the global state { @@ -522,11 +554,13 @@ impl Console { state.path = ctx.working_dir; state.last_return = ctx.last_return; } + code } else { debug!("eval recv erro"); abi.exit_code(1u32).await; tty.draw(format!("term: command failed\r\n").as_str()).await; - } + None + }; // If we are to exit then do so if exit_on_return_to_shell { @@ -536,6 +570,9 @@ impl Console { tty.reset_line().await; Console::update_prompt(multiline_input, &state, &tty).await; tty.draw_prompt().await; + if let Some(code) = finished { + code_sender.send(code).unwrap(); + } } } }); @@ -696,6 +733,24 @@ impl Console { // Do nothing for now } + pub async fn stop_maybe_running_job(&mut self) { + let mode = self.tty.mode().await; + match mode { + TtyMode::StdIn(job) => { + // let mut reactor = self.reactor.write().await; + // job.terminate( + // &mut reactor, + // std::num::NonZeroU32::new(err::ERR_TERMINATED).unwrap(), + // ); + self.on_ctrl_c(Some(job)).await; + // let forced_exit = caller_ctx.get_forced_exit(); + // let forced_exit = forced_exit.load(Ordering::Acquire); + // self.reactor.write().await.clear(); + } + _ => {} + } + } + /// Puts the console into RAW mode which will send the /// bytes to the subprocess without changing the, pub fn set_raw_mode(&self, val: bool) { @@ -733,8 +788,7 @@ impl Console { // Ctrl-C is not fed to the process and always actioned if data == b"0x03" { self.on_ctrl_c(Some(job)).await - } - else { + } else { self.on_parse(&data, Some(job)).await } diff --git a/wasmer-os/src/environment.rs b/wasmer-os/src/environment.rs index 09066aa4e..115847fc2 100644 --- a/wasmer-os/src/environment.rs +++ b/wasmer-os/src/environment.rs @@ -19,12 +19,12 @@ pub struct Environment { impl Environment { pub fn set_var(&mut self, key: &str, val: String) { - self.set_vareq_with_key(key.to_string(), format!("{}={}", key, val)); + self.set_vareq_with_key(key.to_string(), val); } pub fn set_vareq(&mut self, var_eq: String) { - let key: String = self.parse_key(&var_eq); - self.set_vareq_with_key(key, var_eq); + let (key, value) = self.parse_key_value(&var_eq); + self.set_vareq_with_key(key, value); } pub fn set_vareq_with_key(&mut self, key: String, var_eq: String) { @@ -74,13 +74,7 @@ impl Environment { let entry = self.vars.get(key)?; return if let Some(var_eq) = &entry.var_eq { - let mut split = var_eq.as_bytes().split(|b| *b == b'='); - let _entry_key = split.next().unwrap(); - if let Some(value) = split.next() { - Some(String::from_utf8_lossy(value).to_string()) - } else { - Some(String::new()) - } + return Some(var_eq.clone()); } else { None }; @@ -98,9 +92,11 @@ impl Environment { self.vars.iter() } - pub fn parse_key(&self, var_eq: &String) -> String { + pub fn parse_key_value(&self, var_eq: &String) -> (String, String) { let mut split = var_eq.as_bytes().split(|b| *b == b'='); - String::from_utf8_lossy(split.next().unwrap()).to_string() + let key = String::from_utf8_lossy(split.next().unwrap()).to_string(); + let value = String::from_utf8_lossy(split.next().unwrap()).to_string(); + (key, value) } } diff --git a/wasmer-os/src/state.rs b/wasmer-os/src/state.rs index cecdf6269..18e26ed38 100644 --- a/wasmer-os/src/state.rs +++ b/wasmer-os/src/state.rs @@ -2,6 +2,7 @@ #![allow(dead_code)] use bytes::{Buf, BytesMut}; use std::collections::HashMap; +use std::path::Path; use std::sync::Arc; use std::sync::Mutex; use std::sync::atomic::AtomicBool; @@ -52,24 +53,30 @@ impl ConsoleState { if need_more_text { ">".to_string() } else { - "$".to_string() + "→".to_string() } }; + let path = Path::new(&self.path); + let parent_root = if self.path == "/" || path.parent() == Some(Path::new("/")) { + "/" + } else { + "" + }; + let end_path = path.file_name().map(|s| s.to_str().unwrap()).unwrap_or(""); if color { format!( - "{}{}{}:{}{}{}{} {}", - Tty::COL_GREEN, - self.user, - Tty::COL_WHITE, + "{}{} {}{}{}{} {}", Tty::COL_BLUE, - self.path, - Tty::COL_WHITE, prompt_symbol, + Tty::COL_BOLD, + parent_root, + end_path, + Tty::COL_WHITE, Tty::COL_RESET ) } else { - format!("{}:{}{} ", self.user, self.path, prompt_symbol) + format!("{} ", prompt_symbol) } } } diff --git a/wasmer-ssh/Cargo.toml b/wasmer-ssh/Cargo.toml index 83a560cae..310aaf9d9 100644 --- a/wasmer-ssh/Cargo.toml +++ b/wasmer-ssh/Cargo.toml @@ -9,7 +9,7 @@ keywords = [ "ssh-server", "wasm" ] -repository = "https://github.com/john-sharratt/ate/tree/master/wasmer-ssh" +repository = "https://github.com/wasmerio/ate/tree/master/wasmer-ssh" readme = "README.md" [features] diff --git a/wasmer-ssh/README.md b/wasmer-ssh/README.md index ab718378c..9545838a2 100644 --- a/wasmer-ssh/README.md +++ b/wasmer-ssh/README.md @@ -17,7 +17,7 @@ running with full wasmer-bus support. ## What is ATE -[See here](https://github.com/john-sharratt/ate/blob/master/README.md) +[See here](https://github.com/wasmerio/ate/blob/master/README.md) ## Contribution diff --git a/wasmer-term/Cargo.toml b/wasmer-term/Cargo.toml index 61f13f974..a48345000 100644 --- a/wasmer-term/Cargo.toml +++ b/wasmer-term/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" description = "Wasmer Terminal built on WASMER and ATE that runs locally" license = "MIT OR Apache-2.0" keywords = [ "wasm", "browser", "terminal" ] -repository = "https://github.com/john-sharratt/ate" +repository = "https://github.com/wasmerio/ate" readme = "../README.md" [features] diff --git a/wasmer-web/Cargo.toml b/wasmer-web/Cargo.toml index 9c262f9c0..8216028da 100644 --- a/wasmer-web/Cargo.toml +++ b/wasmer-web/Cargo.toml @@ -7,7 +7,7 @@ publish = false description = "Wasmer Web Terminal built on WASMER and ATE" license = "MIT OR Apache-2.0" keywords = [ "wasm", "browser", "terminal" ] -repository = "https://github.com/john-sharratt/ate" +repository = "https://github.com/wasmerio/ate" readme = "../README.md" [dependencies] diff --git a/wasmer-web/js/fit.ts b/wasmer-web/js/fit.ts index 826370752..f3b71d35b 100644 --- a/wasmer-web/js/fit.ts +++ b/wasmer-web/js/fit.ts @@ -3,64 +3,83 @@ * @license MIT */ - import { Terminal } from 'xterm'; - - const MINIMUM_COLS = 2; - const MINIMUM_ROWS = 1; +import { Terminal } from "xterm"; - // The purpose of this file is two-fold: +const MINIMUM_COLS = 2; +const MINIMUM_ROWS = 1; + +// The purpose of this file is two-fold: // First: Expose a function to start a web worker. This function must // not be inlined into the Rust lib, as otherwise bundlers could not // bundle it -- huh. -export function termFit(terminal, front) -{ +export function termFit(terminal, front) { if (!terminal) { return undefined; } - + if (!terminal.element || !terminal.element.parentElement) { return undefined; } - + // TODO: Remove reliance on private API //const core = (terminal as any)._core; let core = terminal._core; - - if (core._renderService.dimensions.actualCellWidth === 0 || core._renderService.dimensions.actualCellHeight === 0) { + + if ( + core._renderService.dimensions.actualCellWidth === 0 || + core._renderService.dimensions.actualCellHeight === 0 + ) { return undefined; } - - //const parentElementStyle = window.getComputedStyle(terminal.element.parentElement); - //const parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height')); - //const parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width'))); - - var parentElementHeight = document.body.clientHeight - 10; - var parentElementWidth = document.body.clientWidth - 10; + + const parentElementStyle = window.getComputedStyle( + terminal.element.parentElement + ); + const parentElementHeight = + parseInt(parentElementStyle.getPropertyValue("height")) || 0; + const parentElementWidth = + Math.max(0, parseInt(parentElementStyle.getPropertyValue("width"))) || 0; + + // var parentElementHeight = document.body.clientHeight - 10; + // var parentElementWidth = document.body.clientWidth - 10; const elementStyle = window.getComputedStyle(terminal.element); const elementPadding = { - top: parseInt(elementStyle.getPropertyValue('padding-top')), - bottom: parseInt(elementStyle.getPropertyValue('padding-bottom')), - right: parseInt(elementStyle.getPropertyValue('padding-right')), - left: parseInt(elementStyle.getPropertyValue('padding-left')) + top: parseInt(elementStyle.getPropertyValue("padding-top")) || 0, + bottom: parseInt(elementStyle.getPropertyValue("padding-bottom")) || 0, + right: parseInt(elementStyle.getPropertyValue("padding-right")) || 0, + left: parseInt(elementStyle.getPropertyValue("padding-left")) || 0, }; const elementPaddingVer = elementPadding.top + elementPadding.bottom; const elementPaddingHor = elementPadding.right + elementPadding.left; const availableHeight = parentElementHeight - elementPaddingVer; - const availableWidth = parentElementWidth - elementPaddingHor - core.viewport.scrollBarWidth; + const availableWidth = + parentElementWidth - elementPaddingHor - core.viewport.scrollBarWidth; const dims = { - cols: Math.max(MINIMUM_COLS, Math.floor(availableWidth / core._renderService.dimensions.actualCellWidth)), - rows: Math.max(MINIMUM_ROWS, Math.floor(availableHeight / core._renderService.dimensions.actualCellHeight)) + cols: Math.max( + MINIMUM_COLS, + Math.floor( + availableWidth / core._renderService.dimensions.actualCellWidth + ) + ), + rows: Math.max( + MINIMUM_ROWS, + Math.floor( + availableHeight / core._renderService.dimensions.actualCellHeight + ) + ), }; // Also update the front buffer - front.width = document.body.clientWidth; - front.height = document.body.clientHeight; - document.getElementById(front.id).style.width = document.body.clientWidth + 'px'; - document.getElementById(front.id).style.height = document.body.clientHeight + 'px'; + front.width = availableWidth; + front.height = availableHeight; + front.style.width = availableWidth + "px"; + front.style.height = availableHeight + "px"; // Force a full render if (terminal.rows !== dims.rows || terminal.cols !== dims.cols) { - terminal.resize(dims.cols, dims.rows); + if (dims.rows !== NaN && dims.cols !== NaN) { + terminal.resize(dims.cols, dims.rows); + } } -} \ No newline at end of file +} diff --git a/wasmer-web/js/gl.js b/wasmer-web/js/gl.js index 0f4e15b08..583013c7c 100644 --- a/wasmer-web/js/gl.js +++ b/wasmer-web/js/gl.js @@ -1,9 +1,9 @@ export function showCanvas() { - document.getElementById("terminal").style.display='none'; - document.getElementById("frontBuffer").style.display='inline'; + // document.getElementById("terminal").style.display='none'; + // document.getElementById("frontBuffer").style.display='inline'; } export function showTerminal() { - document.getElementById("terminal").style.display='inline'; - document.getElementById("frontBuffer").style.display='none'; -} \ No newline at end of file + // document.getElementById("terminal").style.display='inline'; + // document.getElementById("frontBuffer").style.display='none'; +} diff --git a/wasmer-web/js/index.js b/wasmer-web/js/index.js index abf6eafd7..471c6a86e 100644 --- a/wasmer-web/js/index.js +++ b/wasmer-web/js/index.js @@ -1,11 +1,13 @@ -import init, { start } from '../pkg/index.js'; -import 'regenerator-runtime/runtime.js' -import './workers-polyfill.js' +import init, { start, resize } from "../pkg/index.js"; +import "regenerator-runtime/runtime.js"; +import "./workers-polyfill.js"; async function run() { Error.stackTraceLimit = 20; await init(); - await start(); + let terminal = document.getElementById("terminal"); + let frontBuffer = document.getElementById("frontBuffer"); + await start(terminal, frontBuffer); } run(); diff --git a/wasmer-web/public/404.html b/wasmer-web/public/404.html new file mode 100644 index 000000000..c60208995 --- /dev/null +++ b/wasmer-web/public/404.html @@ -0,0 +1,60 @@ + + + + + + + + + +
+
+

Error 404

+
+
+ + + \ No newline at end of file diff --git a/wasmer-web/public/_headers b/wasmer-web/public/_headers new file mode 100644 index 000000000..4e0098fe5 --- /dev/null +++ b/wasmer-web/public/_headers @@ -0,0 +1,3 @@ +/* + cross-origin-embedder-policy: require-corp + cross-origin-opener-policy: same-origin diff --git a/wasmer-web/public/assets/favicon.ico b/wasmer-web/public/assets/favicon.ico new file mode 100755 index 000000000..8f4afe75e Binary files /dev/null and b/wasmer-web/public/assets/favicon.ico differ diff --git a/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Bold.eot b/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Bold.eot new file mode 100755 index 000000000..f98c03f9b Binary files /dev/null and b/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Bold.eot differ diff --git a/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Bold.ttf b/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Bold.ttf new file mode 100755 index 000000000..50d6969cf Binary files /dev/null and b/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Bold.ttf differ diff --git a/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Bold.woff b/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Bold.woff new file mode 100755 index 000000000..5c2f87ef2 Binary files /dev/null and b/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Bold.woff differ diff --git a/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Medium.eot b/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Medium.eot new file mode 100755 index 000000000..aae518837 Binary files /dev/null and b/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Medium.eot differ diff --git a/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Medium.ttf b/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Medium.ttf new file mode 100755 index 000000000..1fb880d44 Binary files /dev/null and b/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Medium.ttf differ diff --git a/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Medium.woff b/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Medium.woff new file mode 100755 index 000000000..a8beb227b Binary files /dev/null and b/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Medium.woff differ diff --git a/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Semibold.eot b/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Semibold.eot new file mode 100755 index 000000000..4797e15fe Binary files /dev/null and b/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Semibold.eot differ diff --git a/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Semibold.ttf b/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Semibold.ttf new file mode 100755 index 000000000..4c0d0e402 Binary files /dev/null and b/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Semibold.ttf differ diff --git a/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Semibold.woff b/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Semibold.woff new file mode 100755 index 000000000..1551d14a4 Binary files /dev/null and b/wasmer-web/public/assets/fonts/Gilroy/Gilroy-Semibold.woff differ diff --git a/wasmer-web/public/assets/fonts/Gilroy/Gilroy.css b/wasmer-web/public/assets/fonts/Gilroy/Gilroy.css new file mode 100644 index 000000000..f583ed008 --- /dev/null +++ b/wasmer-web/public/assets/fonts/Gilroy/Gilroy.css @@ -0,0 +1,32 @@ +@font-face { + font-family: 'Gilroy'; + src: url('Gilroy-Semibold.eot'); + src: url('Gilroy-Semibold.eot?#iefix') format('embedded-opentype'), + url('Gilroy-Semibold.woff') format('woff'), + url('Gilroy-Semibold.ttf') format('truetype'); + font-weight: 600; + font-style: normal; + font-display: swap; +} + +@font-face { + font-family: 'Gilroy'; + src: url('Gilroy-Medium.eot'); + src: url('Gilroy-Medium.eot?#iefix') format('embedded-opentype'), + url('Gilroy-Medium.woff') format('woff'), + url('Gilroy-Medium.ttf') format('truetype'); + font-weight: 500; + font-style: normal; + font-display: swap; +} + +@font-face { + font-family: 'Gilroy'; + src: url('./Gilroy-Bold.eot'); + src: url('./Gilroy-Bold.eot?#iefix') format('embedded-opentype'), + url('./Gilroy-Bold.woff') format('woff'), + url('./Gilroy-Bold.ttf') format('truetype'); + font-weight: 700; + font-style: normal; + font-display: swap; +} diff --git a/wasmer-web/public/assets/fonts/Zeitung/Zeitung.css b/wasmer-web/public/assets/fonts/Zeitung/Zeitung.css new file mode 100644 index 000000000..564ed8f1b --- /dev/null +++ b/wasmer-web/public/assets/fonts/Zeitung/Zeitung.css @@ -0,0 +1,9 @@ +@font-face { + font-family: 'Zeitung Mono Pro'; + src: url('ZeitungMonoPro-Regular.eot?#iefix') format('embedded-opentype'), + url('ZeitungMonoPro-Regular.woff') format('woff'), + url('ZeitungMonoPro-Regular.ttf') format('truetype'); + font-display: swap; + font-style: normal; + font-weight: 400; +} diff --git a/wasmer-web/public/assets/fonts/Zeitung/ZeitungMonoPro-Regular.eot b/wasmer-web/public/assets/fonts/Zeitung/ZeitungMonoPro-Regular.eot new file mode 100644 index 000000000..586d22ed0 Binary files /dev/null and b/wasmer-web/public/assets/fonts/Zeitung/ZeitungMonoPro-Regular.eot differ diff --git a/wasmer-web/public/assets/fonts/Zeitung/ZeitungMonoPro-Regular.ttf b/wasmer-web/public/assets/fonts/Zeitung/ZeitungMonoPro-Regular.ttf new file mode 100644 index 000000000..495f32f26 Binary files /dev/null and b/wasmer-web/public/assets/fonts/Zeitung/ZeitungMonoPro-Regular.ttf differ diff --git a/wasmer-web/public/assets/fonts/Zeitung/ZeitungMonoPro-Regular.woff b/wasmer-web/public/assets/fonts/Zeitung/ZeitungMonoPro-Regular.woff new file mode 100644 index 000000000..5f2d63726 Binary files /dev/null and b/wasmer-web/public/assets/fonts/Zeitung/ZeitungMonoPro-Regular.woff differ diff --git a/wasmer-web/public/assets/icon.png b/wasmer-web/public/assets/icon.png new file mode 100644 index 000000000..8428cdb73 Binary files /dev/null and b/wasmer-web/public/assets/icon.png differ diff --git a/wasmer-web/public/assets/logos/android-chrome-192x192.png b/wasmer-web/public/assets/logos/android-chrome-192x192.png new file mode 100755 index 000000000..92e646dfa Binary files /dev/null and b/wasmer-web/public/assets/logos/android-chrome-192x192.png differ diff --git a/wasmer-web/public/assets/logos/android-chrome-512x512.png b/wasmer-web/public/assets/logos/android-chrome-512x512.png new file mode 100755 index 000000000..cae9ae47d Binary files /dev/null and b/wasmer-web/public/assets/logos/android-chrome-512x512.png differ diff --git a/wasmer-web/public/assets/logos/apple-touch-icon.png b/wasmer-web/public/assets/logos/apple-touch-icon.png new file mode 100755 index 000000000..2ee074120 Binary files /dev/null and b/wasmer-web/public/assets/logos/apple-touch-icon.png differ diff --git a/wasmer-web/public/assets/logos/favicon-16x16.png b/wasmer-web/public/assets/logos/favicon-16x16.png new file mode 100755 index 000000000..5155d5157 Binary files /dev/null and b/wasmer-web/public/assets/logos/favicon-16x16.png differ diff --git a/wasmer-web/public/assets/logos/favicon-32x32.png b/wasmer-web/public/assets/logos/favicon-32x32.png new file mode 100755 index 000000000..2b91f8b9c Binary files /dev/null and b/wasmer-web/public/assets/logos/favicon-32x32.png differ diff --git a/wasmer-web/public/assets/logos/favicon.ico b/wasmer-web/public/assets/logos/favicon.ico new file mode 100755 index 000000000..8f4afe75e Binary files /dev/null and b/wasmer-web/public/assets/logos/favicon.ico differ diff --git a/wasmer-web/public/favicon-tok.png b/wasmer-web/public/favicon-tok.png deleted file mode 100644 index 0c6b2fcd3..000000000 Binary files a/wasmer-web/public/favicon-tok.png and /dev/null differ diff --git a/wasmer-web/public/index.html b/wasmer-web/public/index.html index 0dab10908..9f586de4d 100644 --- a/wasmer-web/public/index.html +++ b/wasmer-web/public/index.html @@ -2,24 +2,28 @@ - - - - - + + + + + + + - - - wasmer.sh + + + + + WAPM Shell - +
diff --git a/wasmer-web/public/manifest.json b/wasmer-web/public/manifest.json new file mode 100644 index 000000000..2e5d5eeb8 --- /dev/null +++ b/wasmer-web/public/manifest.json @@ -0,0 +1,17 @@ +{ + "name": "WebAssembly.sh", + "short_name": "WebAssembly.sh", + "start_url": "/", + "display": "standalone", + "orientation": "portrait", + "background_color": "#000", + "theme_color": "#000", + "icons": [ + { + "src": "/assets/icon.png", + "type": "image/png", + "sizes": "512x512" + } + ] + } + \ No newline at end of file diff --git a/wasmer-web/public/wasmer.css b/wasmer-web/public/wasmer.css index 475cebb66..64614a02f 100644 --- a/wasmer-web/public/wasmer.css +++ b/wasmer-web/public/wasmer.css @@ -4,7 +4,7 @@ html, body { margin: 0px; height: 100%; width: 100%; - background: black; + background: #231044; } #frontBuffer { @@ -18,7 +18,7 @@ html, body { height: 100%; font-size: 16px; line-height: 17px; - background: black; + background: radial-gradient(101.72% 666.84% at 2.15% 0%, rgba(73, 70, 221, 0.25) 0%, rgba(73, 70, 221, 0) 100%), #231044; } html { diff --git a/wasmer-web/public/worker.js b/wasmer-web/public/worker.js index 79cb7cef5..2292788e2 100644 --- a/wasmer-web/public/worker.js +++ b/wasmer-web/public/worker.js @@ -41,6 +41,11 @@ export function startWasm(module, memory, ctx, opts, helper, wasm_module, wasm_m }); } + +export function sleep(ms) { +return new Promise((resolve) => setTimeout(resolve, ms)); +} + export function isWorker() { return 'WorkerGlobalScope' in self && self instanceof WorkerGlobalScope; } diff --git a/wasmer-web/src/glue.rs b/wasmer-web/src/glue.rs index c4f4c72ad..10e5b7a1f 100644 --- a/wasmer-web/src/glue.rs +++ b/wasmer-web/src/glue.rs @@ -1,4 +1,5 @@ use chrono::prelude::*; +use std::collections::HashMap; use wasmer_os::bin_factory::CachedCompiledModules; use std::sync::Arc; use wasmer_os::api::*; @@ -43,18 +44,54 @@ pub fn main() { #[derive(Debug)] pub enum InputEvent { Key(KeyboardEvent), + Command(String, Option, Option), Data(String), } #[wasm_bindgen] -pub fn start() -> Result<(), JsValue> { +pub struct ConsoleInput { + tx: mpsc::Sender, + terminal: Terminal, +} + +#[wasm_bindgen] +impl ConsoleInput { + #[wasm_bindgen] + pub fn send_command( + &self, + data: String, + func: Option, + env: Option, + ) { + self.tx + .blocking_send(InputEvent::Command(data, func, env)) + .unwrap(); + } + + #[wasm_bindgen] + pub fn send_data(&self, data: String) { + self.tx.blocking_send(InputEvent::Data(data)).unwrap(); + } + + #[wasm_bindgen(method, getter)] + pub fn terminal(&self) -> JsValue { + self.terminal.clone() + } +} + +#[wasm_bindgen] +pub fn start( + terminal_element: web_sys::Element, + front_buffer: HtmlCanvasElement, + init_command: Option, + on_ready: Option, +) -> Result { #[wasm_bindgen] extern "C" { #[wasm_bindgen(js_namespace = navigator, js_name = userAgent)] static USER_AGENT: String; } - //ate::log_init(0i32, false); tracing_wasm::set_as_global_default_with_config( tracing_wasm::WASMLayerConfigBuilder::new() .set_report_logs_in_timings(false) @@ -73,7 +110,17 @@ pub fn start() -> Result<(), JsValue> { .with_font_size(16u32) .with_draw_bold_text_in_bright_colors(true) .with_right_click_selects_word(true) - .with_theme(&Theme::new()), + .with_transparency(true) + .with_font_size(17) + .with_font_family("Zeitung Mono Pro") + .with_theme( + &Theme::new() + .with_background("#23104400") + .with_foreground("#ffffff") + .with_black("#fdf6e3") + .with_green("#02C39A") + .with_cyan("#4AB3FF"), + ), ); let window = web_sys::window().unwrap(); @@ -83,13 +130,7 @@ pub fn start() -> Result<(), JsValue> { let is_mobile = wasmer_os::common::is_mobile(&user_agent); debug!("user_agent: {}", user_agent); - let elem = window - .document() - .unwrap() - .get_element_by_id("terminal") - .unwrap(); - - terminal.open(elem.clone().dyn_into()?); + terminal.open(terminal_element.dyn_into()?); let (term_tx, mut term_rx) = mpsc::channel(MAX_MPSC); { @@ -116,15 +157,6 @@ pub fn start() -> Result<(), JsValue> { }); } - let front_buffer = window - .document() - .unwrap() - .get_element_by_id("frontBuffer") - .unwrap(); - let front_buffer: HtmlCanvasElement = front_buffer - .dyn_into::() - .map_err(|_| ()) - .unwrap(); let webgl2 = front_buffer .get_context("webgl2")? .unwrap() @@ -231,7 +263,18 @@ pub fn start() -> Result<(), JsValue> { terminal.focus(); system.fork_local(async move { - console.init().await; + let x = on_ready.clone(); + console + .init( + init_command, + Some(Box::new(move |code: u32| { + if let Some(on_ready) = on_ready { + let this = JsValue::null(); + on_ready.call1(&this, &code.into()); + } + })), + ) + .await; crate::glue::show_terminal(); @@ -249,6 +292,35 @@ pub fn start() -> Result<(), JsValue> { ) .await; } + InputEvent::Command(data, func, envs) => { + console.stop_maybe_running_job().await; + if let Some(envs) = envs { + let hashmap_envs: HashMap = js_sys::Object::entries(&envs) + .to_vec() + .into_iter() + .map(|entry| { + let entry_as_jsarray: js_sys::Array = entry.dyn_into().unwrap(); + let key = entry_as_jsarray.get(0).as_string().unwrap(); + ( + key.clone(), + entry_as_jsarray.get(1).as_string().expect( + format!("They value for {} is not a string", &key).as_str(), + ), + ) + }) + .collect(); + console.set_envs(&hashmap_envs); + } + console.on_data(data).await; + console + .on_enter_with_callback(Some(Box::new(move |code: u32| { + let this = JsValue::null(); + if let Some(func) = func { + func.call1(&this, &code.into()); + } + }))) + .await + } InputEvent::Data(data) => { // Due to a nasty bug in xterm.js on Android mobile it sends the keys you press // twice in a row with a short interval between - this hack will avoid that bug @@ -270,7 +342,7 @@ pub fn start() -> Result<(), JsValue> { } }); - Ok(()) + Ok(ConsoleInput { tx: tx, terminal }) } #[wasm_bindgen(module = "/js/fit.ts")]