xterm-svelte 0.0.4
Install from the command line:
Learn more about npm packages
$ npm install @battlefieldduck/xterm-svelte@0.0.4
Install via package.json:
"@battlefieldduck/xterm-svelte": "0.0.4"
About this version
xterm-svelte is a wrapper for the xterm.js library, designed to work seamlessly with SvelteKit. This library allows you to embed a fully functional terminal in your SvelteKit application.
- Full integration with SvelteKit.
- Xterm addons is managed in xterm-svelte
- Continuous package updates: xterm-svelte is regularly updated to ensure compatibility with the latest versions of SvelteKit and Xterm.js.
To install Xterm-Svelte, run the following command in your project directory:
npm install xterm-svelte
Here's a basic example of how to use xterm-svelte in your SvelteKit application:
<script lang="ts">
import { Xterm } from 'xterm-svelte';
import type { ITerminalOptions, ITerminalInitOnlyOptions, Terminal } from 'xterm-svelte';
let options: ITerminalOptions & ITerminalInitOnlyOptions = {};
async function onLoad(event: CustomEvent<{ terminal: Terminal }>) {
console.log('Child component has loaded');
const terminal = event.detail.terminal;
// FitAddon Usage
const { FitAddon } = await XtermAddon.FitAddon();
const fitAddon = new FitAddon();
terminal.loadAddon(fitAddon);
fitAddon.fit();
terminal.write('Hello World');
}
function onData(event: CustomEvent<string>) {
const data = event.detail;
console.log('onData()', data);
}
function onKey(event: CustomEvent<{ key: string; domEvent: KeyboardEvent }>) {
const data = event.detail;
console.log('onKey()', data);
}
</script>
<Xterm {options} on:load={onLoad} on:data={onData} on:key={onKey} />
Contributions are welcome! Please feel free to submit pull requests or open issues.
xterm-svelte is licensed under the MIT License. See the LICENSE
file for more details.