Updated xterm-svelte example
$state + Type-Safe options + Null-Safe Calls
<script lang="ts">
import { Xterm, XtermAddon } from '@battlefieldduck/xterm-svelte';
import type {
ITerminalOptions,
ITerminalInitOnlyOptions,
Terminal
} from '@battlefieldduck/xterm-svelte';
+ let terminal = $state<Terminal>();
- let terminal: Terminal;
+ const options: ITerminalOptions & ITerminalInitOnlyOptions = {
- let options: ITerminalOptions & ITerminalInitOnlyOptions = {
fontFamily: 'Consolas'
};
async function onLoad() {
console.log('Child component has loaded');
// FitAddon Usage
const fitAddon = new (await XtermAddon.FitAddon()).FitAddon();
+ terminal?.loadAddon(fitAddon);
- terminal.loadAddon(fitAddon);
fitAddon.fit();
+ terminal?.write('Hello World');
- terminal.write('Hello World');
}
function onData(data: string) {
console.log('onData()', data);
}
function onKey(data: { key: string; domEvent: KeyboardEvent }) {
console.log('onKey()', data);
}
</script>
<Xterm bind:terminal {options} {onLoad} {onData} {onKey} />What's Changed
- Bump svelte from 5.2.2 to 5.20.0 by @dependabot[bot] in #202
- Bump svelte-check from 4.0.8 to 4.1.4 by @dependabot[bot] in #177
- Bump @sveltejs/kit from 2.8.0 to 2.17.1 by @dependabot[bot] in #194
- Bump vitest from 2.1.4 to 2.1.9 in the npm_and_yarn group across 1 directory by @dependabot[bot] in #203
- Bump eslint-plugin-svelte from 2.46.0 to 3.12.4 by @dependabot[bot] in #206
- Bump publint from 0.2.12 to 0.3.13 by @dependabot[bot] in #207
- Bump svelte from 5.20.0 to 5.39.6 by @dependabot[bot] in #208
- Bump prettier from 3.3.3 to 3.6.2 by @dependabot[bot] in #210
- Bump @types/node from 22.18.6 to 24.5.2 by @dependabot[bot] in #211
Full Changelog: 2.1.0...2.1.1