How shikijs/shiki-magic-move works
Project type and purpose
• Project type: An open-source, framework-agnostic library for animating syntax-highlighted code blocks on the client (browser).
• Purpose: Provide a core engine plus renderer abstractions and framework-specific wrappers (Vue, React, Solid, Svelte, Web Component) that use Shiki for syntax highlighting, animate diffs of code, and ship styles. Also includes a Playground example app.
File structure
• Top-level:
· config (build.config.ts, eslint.config.js, netlify.toml, CI workflows)
· package.json, pnpm-workspace.yaml (monorepo style)
· src/ (core library code)
· test/ (unit tests)
· playground/ (demo app)
• src/:
· core.ts + renderer.ts — framework-agnostic engine + renderer
· framework folders (react/, vue/, solid/, svelte/, web-component/) each with:
– ShikiMagicMove.ts(x/.svelte) – main component
– ShikiMagicMovePrecompiled.ts(x/.svelte) – precompiled variant
– ShikiMagicMoveRenderer.ts(x/.svelte) – low-level renderer
– index.ts and utils.ts
· entry points (react.ts, vue.ts, etc.) that re-export each wrapper
· types.ts — shared TypeScript types
• playground/:
· Vite-based sample application demonstrating each renderer
· index.html, App.vue, and multiple renderer examples
• CI/CD:
· GitHub workflows for testing & release, Netlify config for hosting Playground
README for additional insights
• Describes core and renderer as framework-agnostic foundation
• Lists each wrapper’s components and usage patterns
• Notes external dependency: Shiki highlighter
• Shows how Precompiled component bypasses Shiki to animate serialized tokens
• Points to an online demo and blog post for deeper explanation