@wasmer/wasm-terminal
Do you want to run a full terminal with WebAssembly files? This is your package!
WasmTerminal
import { WasmTerminal } from "@wasmer/wasm-terminal"
.
Constructor
new WasmTerminal(jsObject: WasmTerminalConfig): WasmTerminal
Constructor that returns an instance of the WasmTerminal
.
The WasmTerminalConfig can be described as the following:
callbackCommands
are functions that can be returned in the fetchCommand
config property. They are simply Javascript callbacks that take in the command name, command arguments, environment variables, and return a Promise
that resolves stdout
.
Since these callback commands handle stdin
and stdout
, they can be used as normal commands that can be piped!
Instance Properties
open
wasmTerminal.open(containerElement: Element): void
Sets the container of the wasmTerminal.
The containerElement
can be any Element.
fit
wasmTerminal.fit()
: void
Resizes the terminal to fit the size of its container.
focus
wasmTerminal.focus()
: void
Gives the wasmTerminal
element focus, and allows input into the shell.
print
wasmTerminal.print(message: string)
: void
Prints text to the wasmTerminal
.
Useful for things such as showing a welcome message before the wasmTerminal
is opened.
scrollToCursor
wasmTerminal.scrollToCursor()
:void
Scrolls the terminal cursor into view.
runCommand
wasmTerminal.runCommand(commandString: string)
: void
Runs the supplied string as if it had been entered as a command, typed into the Wasm terminal.
fetchCommandFromWAPM
Exported function from the @wasmer/wasm-terminal
package. This function is meant to be returned in the fetchCommand
config property of the WasmTerminal
Class. This takes in the name of command, the command arguments, and the environment variables, and returns a Promise
that resolves a Uint8Array
of binary Wasm bytes from WAPM.
Last updated