├── .gitattributes ├── .gitignore ├── .prettierignore ├── .prettierrc.json ├── README.md ├── examples ├── 1-directly-in-the-browser │ ├── README.md │ ├── binaries │ ├── index.html │ ├── package-lock.json │ └── package.json ├── 2-nodejs-with-parcel │ ├── .parcelrc │ ├── .proxyrc.json │ ├── README.md │ ├── index.html │ ├── index.js │ ├── package-lock.json │ └── package.json ├── 3-react-with-webpack │ ├── README.md │ ├── index.css │ ├── index.html │ ├── index.js │ ├── package-lock.json │ ├── package.json │ ├── webpack.config.js │ └── xterm-for-react.js ├── README.md └── binaries │ ├── base32.lnk │ ├── base64.lnk │ ├── basename.lnk │ ├── cat.lnk │ ├── coreutils.wasm │ ├── dirname.lnk │ ├── echo.lnk │ ├── env.lnk │ ├── ls.lnk │ ├── mkdir.lnk │ ├── mv.lnk │ ├── openssl.js │ ├── openssl.wasm │ ├── printf.lnk │ ├── pwd.lnk │ ├── sum.lnk │ └── wc.lnk ├── package-lock.json ├── package.json ├── src ├── History.js ├── LineBuffer.js ├── WapmFetchUtil.js ├── WasmWebTerm.js ├── WasmWebTerm.md ├── runnables │ ├── EmscriptenRunnable.js │ └── WasmerRunnable.js └── runners │ ├── ImportInjectedModules.js │ ├── WasmRunner.js │ └── WasmWorker.js ├── webpack.config.js ├── webterm.bundle.js ├── webterm.bundle.js.map └── worker.loader.js /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .cache 3 | dist 4 | .DS_Store 5 | .parcel-cache 6 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .github 3 | .git 4 | examples/ 5 | webterm.bundle.js* 6 | *.md 7 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": false, 6 | "singleQuote": false, 7 | "trailingComma": "es5", 8 | "bracketSpacing": true, 9 | "bracketSameLine": false, 10 | "arrowParens": "always", 11 | "proseWrap": "always", 12 | "endOfLine": "lf", 13 | "embeddedLanguageFormatting": "off" 14 | } 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
8 | 9 | 10 | Run your [WebAssembly](https://webassembly.org) binaries on a terminal/tty emulation in your browser. [Emscripten](https://emscripten.org) and [WASI](https://github.com/WebAssembly/WASI) are supported. This project is developed as an addon for [xterm.js](https://github.com/xtermjs/xterm.js) v4, so you can easily use it in your own projects. 11 | 12 | > It originated from the [CrypTool project](https://www.cryptool.org) in 2022 for [running OpenSSL v3 in a browser](https://github.com/cryptool-org/openssl-webterm). 13 | 14 | Please note that xterm.js and this addon need a browser to run. 15 | 16 | 17 | 18 | 19 | ----- 20 | 21 | 22 | ## Readme Contents 23 | 24 | * [Installation](#installation) and [Usage](#usage) (via [`script` tag](#variant-1-load-via-plain-js-script-tag), [Node.js](#variant-2-import-as-nodejs-module-and-use-a-web-bundler), or [React](#variant-3-using-react-and-a-web-bundler)) 25 | * [Binaries](#binaries) ([Predelivery](#predelivering-binaries), [Compiling C/C++](#compiling-cc-to-wasm-binaries), and [Compiling Rust](#compiling-rust-to-wasm-binaries)) 26 | * [Internal workings](#internal-procedure-flow), [JS commands](#defining-custom-js-commands), and [`WasmWebTerm.js` Code API](#wasmwebtermjs-code-api) 27 | * [Contributing](#contributing) and [License](#license) 28 | 29 | 30 | ----- 31 | 32 | 33 | ## Installation 34 | 35 | First, [install Node.js and npm](https://nodejs.org). Then install xterm.js and wasm-webterm: 36 | 37 | ```shell 38 | npm install xterm cryptool-org/wasm-webterm --save 39 | ``` 40 | 41 | ## Usage 42 | 43 | JavaScript can be written for browsers or nodes, but this addon needs a browser to run (or at least a DOM and Workers or a `window` object). So if you use Node.js, you have to also use a web bundler like [Webpack](https://webpack.js.org) or [Parcel](https://parceljs.org). Using plain JS does not require a bundler. 44 | 45 | > Please note: To make use of WebWorkers you will need to configure your server or web bundler to use [custom HTTPS headers for cross-origin isolation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements). You can find an [example using Webpack in the examples folder](./examples/3-react-with-webpack/webpack.config.js#L14-L18). 46 | 47 | Choose the variant that works best for your existing setup: 48 | 49 | 50 | ### Variant 1: Load via plain JS ` 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 72 | 73 | 77 | 78 |