On this page (8) Expand
ManualCode is a local-first web playground that runs in the browser with no backend server, accounts, or cloud database. It pairs Svelte 5 runes, CodeMirror 6, and an isolated sandbox iframe so you can write, preview, and test multi-file projects offline.
Technical details
| Layer | Implementation |
|---|---|
| Framework | Svelte 5 ($state, $derived, $effect) with SvelteKit 2 and @sveltejs/adapter-node |
| Runtime & build | Bun with Vite 8 and TypeScript 6 |
| Editor | Modular CodeMirror 6 setup covering 78 languages with lazy syntax loaders |
| Starter templates | 39 built-in language templates and multi-project workspace switching |
| Preprocessors | Sucrase (TypeScript/TSX), in-browser Svelte 5 compiler, Dart Sass, Less, Pug |
| SQL runner | Vendored sql.js WebAssembly inside a dedicated Web Worker with a 15-second timeout |
| Sandbox | Iframe with sandbox="allow-scripts" (no allow-same-origin) and import-map support |
| Storage | Dual-store IndexedDB (projects and assets) plus localStorage for workbench layout |
How the workspace is structured
The host workbench is kept separate from untrusted user code:
src/
├── routes/
│ ├── +layout.svelte # Workbench shell, theme state, modals
│ └── +page.svelte # Editor panes, splitters, active workspace
├── lib/
│ ├── editor/ # CodeMirror 6 setup, themes, lazy language modes
│ ├── files/ # File tree, drag-and-drop, PDF/Excel/media previews
│ ├── preview/ # Document builder, console bridge, preprocessors, runners
│ ├── sql/ # Web Worker SQLite engine and paginated results table
│ ├── project/ # Local project store, 39 templates, IndexedDB, zip export
│ ├── palette/ # Command palette (Ctrl+K / Cmd+K)
│ └── console/ # Throttled log stream and error reporting
└── hooks.server.ts # CSP, COOP, HSTS, nosniff, and referrer headers
Key subsystems
Local persistence and multi-project workspaces
Files, folders, and uploaded binary assets are stored locally in IndexedDB under manualcode (split across projects and assets stores). Per-file, file-count, and total-size limits guard against runaway storage usage, and quota failures roll back in-memory state cleanly. Layout state (open tabs, pane splits, collapsed folders, theme) lives in localStorage.
In-browser compilation and import maps
TypeScript and TSX compile via Sucrase, Svelte components compile in-browser through @sveltejs/compiler, and SCSS/Less/Pug are loaded lazily only when a project uses them. Import-map support lets browser modules resolve cleanly inside the preview without an external bundler server. For Pug, the host thread only parses and generates client template code; execution happens inside the sandboxed iframe.
Sandboxed preview and console bridge
User HTML, CSS, and scripts run inside an iframe configured with sandbox="allow-scripts" and no allow-same-origin, giving the preview an opaque origin so it cannot read host storage or DOM state. Uploaded assets are converted to data: URLs for offline rendering.
An injected console bridge captures log, warn, error, info, debug, and uncaught exceptions with line numbers, handles circular objects safely, and uses a token-bucket rate limiter (100 logs/s, 200 burst) with requestAnimationFrame batching so infinite loops do not freeze the tab.
Isolated SQLite studio
SQL queries run against a same-origin vendored sql.js WebAssembly build inside a dedicated Web Worker. A 15-second watchdog terminates and respawns the worker if a query hangs, and result tables truncate at 2,000 rows with 200-row pagination.
Markdown preview and export
Markdown files render with GitHub Flavored Markdown, KaTeX math, task lists, footnotes, and syntax-highlighted code blocks, sanitized through a DOMPurify deny-list before mounting in the host DOM. Projects export to clean .zip archives with path normalization to reject directory traversal.