├── dist ├── assets │ └── favicon.svg ├── stores.d.ts ├── index.d.ts ├── index.js ├── stores.js ├── utils.d.ts ├── types.js ├── utils.js ├── shell.d.ts ├── Terminal.svelte.d.ts ├── types.d.ts ├── shell.js └── Terminal.svelte ├── .npmrc ├── static ├── robots.txt └── svelte-bash.jpg ├── .vscode └── settings.json ├── src ├── routes │ ├── layout.css │ ├── +layout.svelte │ └── +page.svelte ├── lib │ ├── index.ts │ ├── stores.ts │ ├── utils.ts │ ├── types.ts │ ├── shell.ts │ └── Terminal.svelte ├── app.d.ts └── app.html ├── vite.config.ts ├── .gitignore ├── svelte.config.js ├── tsconfig.json ├── package.json └── README.md /dist/assets/favicon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | engine-strict=true 2 | -------------------------------------------------------------------------------- /dist/stores.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /static/robots.txt: -------------------------------------------------------------------------------- 1 | # allow crawling everything by default 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "*.css": "tailwindcss" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /static/svelte-bash.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YusufCeng1z/svelte-bash/HEAD/static/svelte-bash.jpg -------------------------------------------------------------------------------- /src/routes/layout.css: -------------------------------------------------------------------------------- 1 | @import 'tailwindcss'; 2 | @plugin '@tailwindcss/forms'; 3 | @plugin '@tailwindcss/typography'; 4 | -------------------------------------------------------------------------------- /dist/index.d.ts: -------------------------------------------------------------------------------- 1 | export { default as Terminal } from './Terminal.svelte'; 2 | export * from './types'; 3 | export { Shell } from './shell'; 4 | -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | export { default as Terminal } from './Terminal.svelte'; 2 | export * from './types'; 3 | export { Shell } from './shell'; 4 | -------------------------------------------------------------------------------- /src/lib/index.ts: -------------------------------------------------------------------------------- 1 | 2 | export { default as Terminal } from './Terminal.svelte'; 3 | export * from './types'; 4 | export { Shell } from './shell'; -------------------------------------------------------------------------------- /src/routes/+layout.svelte: -------------------------------------------------------------------------------- 1 | 5 | 6 | {@render children()} 7 | -------------------------------------------------------------------------------- /dist/stores.js: -------------------------------------------------------------------------------- 1 | // We are moving state to local component scope to support multiple instances. 2 | // This file is now deprecated or can be used for shared utilities if needed. 3 | // For now, exporting nothing to avoid confusion. 4 | export {}; 5 | -------------------------------------------------------------------------------- /vite.config.ts: -------------------------------------------------------------------------------- 1 | import tailwindcss from '@tailwindcss/vite'; 2 | import { sveltekit } from '@sveltejs/kit/vite'; 3 | import { defineConfig } from 'vite'; 4 | 5 | export default defineConfig({ 6 | plugins: [tailwindcss(), sveltekit()] 7 | }); 8 | -------------------------------------------------------------------------------- /dist/utils.d.ts: -------------------------------------------------------------------------------- 1 | import type { FileStructure } from './types'; 2 | export declare function resolvePath(structure: FileStructure, cwdParts: string[], targetPath: string): { 3 | node: string | FileStructure | undefined; 4 | name: string; 5 | }; 6 | -------------------------------------------------------------------------------- /src/lib/stores.ts: -------------------------------------------------------------------------------- 1 | 2 | // We are moving state to local component scope to support multiple instances. 3 | // This file is now deprecated or can be used for shared utilities if needed. 4 | // For now, exporting nothing to avoid confusion. 5 | export { }; 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | # Output 4 | .output 5 | .vercel 6 | .netlify 7 | .wrangler 8 | /.svelte-kit 9 | /build 10 | 11 | # OS 12 | .DS_Store 13 | Thumbs.db 14 | 15 | # Env 16 | .env 17 | .env.* 18 | !.env.example 19 | !.env.test 20 | 21 | # Vite 22 | vite.config.js.timestamp-* 23 | vite.config.ts.timestamp-* 24 | -------------------------------------------------------------------------------- /src/app.d.ts: -------------------------------------------------------------------------------- 1 | // See https://svelte.dev/docs/kit/types#app.d.ts 2 | // for information about these interfaces 3 | declare global { 4 | namespace App { 5 | // interface Error {} 6 | // interface Locals {} 7 | // interface PageData {} 8 | // interface PageState {} 9 | // interface Platform {} 10 | } 11 | } 12 | 13 | export {}; 14 | -------------------------------------------------------------------------------- /src/app.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | %sveltekit.head% 7 | 8 | 9 |
6 |
7 | 10 | The ultimate lightweight, fully typed, and customizable terminal component for Svelte 5. 11 |
12 | 13 |14 | Live Demo · 15 | NPM · 16 | GitHub 17 |
18 | 19 |
20 |
21 |
22 |
23 |
24 |
316 | Get started by installing the package via npm. It has zero 317 | dependencies other than Svelte itself. 318 |
319 |
349 | Import the component and pass a structure object
350 | to define your file system.
351 |
<script>
360 | import {`{`} Terminal {`}`} from 'svelte-bash';
361 |
362 | const files = {`{`}
363 | 'readme.md': '# Hello World',
364 | 'src': {`{`}
365 | 'app.js': 'console.log("Hi")'
366 | {`}`}
367 | {`}`};
368 | </script>
369 |
370 | <Terminal
371 | structure={`{`}files{`}`}
372 | user="alice"
373 | style="height: 300px"
374 | />
376 |
417 | Pass a commands object to handle custom
418 | logic. You can return a string, an array of lines,
419 | or even other Svelte components.
420 |
const cmds = {`{`}
429 | greet: (args) => `Hello ${`{`}args[0]{`}`}`,
431 | async: async () => {`{`}
432 | await fetch('/api');
433 | return 'Done!';
434 | {`}`}
435 | {`}`};
436 |
437 | <Terminal
438 | commands={`{`}cmds{`}`}
439 | style="height: 300px"
440 | />
442 | 483 | Great for tutorials. The terminal will type for 484 | you. 485 |
486 |<Terminal
492 | autoplay={`{[`}
493 | {`{`} command: 'git status' {`}`},
494 | {`{`}
495 | command: 'git commit -m "wip"',
496 | output: '...'
497 | {`}`}
498 | {`]}`}
499 | style="height: 300px"
500 | />
502 |
515 | Override standard colors with the theme prop.
518 |
<Terminal
525 | theme={`{{`}
526 | background: '#282a36',
527 | prompt: '#ff79c6',
528 | cursor: '#f8f8f2'
529 | {`}}`}
530 | style="height: 300px"
531 | />
533 | | Prop | 563 |Type | 566 |Default | 569 |Description | 572 |
|---|---|---|---|
| structure | 579 |FileStructure | 582 |{`{}`} |
585 | Virtual file system object key-value pairs. | 588 |
| commands | 593 |Record<string, Handler> | 596 |{`{}`} |
599 | Custom command handlers. | 600 |
| theme | 605 |string | Theme | 608 |'dark' | 609 |Preset name ('dark', 'light', 'dracula') or 611 | object. | 613 |
| autoplay | 618 |AutoplayItem[] | 621 |undefined | 623 |Array of commands to type automatically. | 626 |
| user | 631 |string | 632 |'user' | 633 |Username shown in prompt. | 634 |