OpenTUI integration for Svelte 5 using DOM shims (DOM-Only approach).
✅ Working - Implementation complete (571 lines)
- DOM API shimming: 60 operations
- Real Svelte 5 runtime + OpenTUI rendering layer
- Reactive state, effects, and component composition
Run a Svelte component:
cd packages/svelte
bun --conditions=browser examples/hello-svelte.svelte--conditions=browser flag (Svelte 5 requirement)
- Bun Plugin: Automatically compiles
.sveltefiles (via bunfig.toml preload) - Svelte Compiler: Generates standard Svelte 5 runtime code
- DOM Shims:
installDOMShims()replaces global DOM APIs with OpenTUI wrappers - Runtime: Svelte calls DOM → Our shims → OpenTUI Renderables
hello-svelte.svelte:
<script>
let name = 'World';
let count = $state(0);
setInterval(() => {
count += 1;
}, 1000);
</script>
<div>
<div>Hello {name}!</div>
<div>Count: {count}</div>
</div>Run:
bun --conditions=browser examples/hello-svelte.svelte- src/dom.ts (489 lines): TUINode, TUIElement, TUIDocument classes
- index.ts (82 lines): render(), testRender(), installDOMShims()
- scripts/svelte-plugin.ts: Bun plugin for .svelte compilation
- scripts/preload.ts: Plugin registration (loaded via bunfig.toml)
import { render } from "@opentui/svelte"
import MyComponent from "./MyComponent.svelte"
await render(MyComponent, {
exitOnCtrlC: true,
targetFps: 30,
})examples/- Working examples (hello-svelte.svelte, child.svelte, counter.svelte)src/dom.ts- DOM API implementationsindex.ts- Public APIscripts/- Build and compilation toolinganalysis/- Implementation analysis (DOM-Only approach chosen)