Skip to content

feat: Svelte 5 integration#34

Open
ivanbanov wants to merge 6 commits into
mainfrom
svelte
Open

feat: Svelte 5 integration#34
ivanbanov wants to merge 6 commits into
mainfrom
svelte

Conversation

@ivanbanov

Copy link
Copy Markdown
Contributor

Summary

Adds a Svelte 5 integration mirroring the React package, plus a sandbox demo.

@dunky.dev/state-machine-svelte (new package)

A thin, runes-based edge layer with the same export names as the React binding:

  • useMachine — build-once bridge + lifecycle + prop-scoped substrate effects, returning a reactive { api, machine }. Takes props as a getter (() => props) since Svelte props are reactive bindings.
  • useSelector — fine-grained leaf subscription returning { current }.
  • normalize / mergeProps — Svelte's DOM idiom (lowercase on* event props, class/style string merge).

The package ships its src uncompiled (svelte export condition) so the consumer's Svelte compiler processes the .svelte.ts runes modules — it's excluded from the tsdown bundle for that reason. Vitest gains a scoped svelte project (svelte plugin + svelteTesting + jsdom) so runes tests run without disturbing the other packages.

Includes docs (libs/svelte.mdx + sidebar entry) and a changeset.

sandbox/svelte (new)

A fourth renderer for the shared @sandbox/cmdk-core command palette. Unlike the React/OpenTUI/Native apps — which all render through a React reconciler and share React's useMachine — the Svelte app brings its own runes-based useMachine, yet runs the exact same machine and connect() unchanged. Same behavior, different framework.

Verification

  • pnpm typecheck
  • pnpm lint
  • pnpm test:ci ✅ 351 passed (44 new svelte tests)
  • pnpm build ✅ (svelte correctly excluded from tsdown)
  • pnpm -C sandbox/svelte build ✅ — Svelte compiler processes the binding's runes source via alias
  • pnpm website:prod ✅ — 30 pages incl. /libs/svelte

Notes

  • useMachine takes props as a value in React, but () => props (a getter) in Svelte — unavoidable given Svelte's reactivity model; export name kept consistent. Documented in the README and docs page.
  • The sandbox is verified by a clean production build + dev-server compilation; I could not drive it in a live browser (the MCP Chrome session was locked to an external instance), so interactive click-through is unverified — though the underlying machine is covered by the test suite.

🤖 Generated with Claude Code

ivanbanov and others added 2 commits June 23, 2026 22:22
Add @dunky.dev/state-machine-svelte, a thin runes-based edge layer
mirroring the React package:

- useMachine: build-once bridge + lifecycle + prop-scoped substrate
  effects, returning a reactive { api, machine }. Takes props as a
  getter (() => props) since Svelte props are reactive bindings.
- useSelector: fine-grained leaf subscription returning { current }.
- normalize/mergeProps: Svelte DOM idiom (lowercase on* event props,
  class/style string merge).

The package ships its src uncompiled (svelte export condition) so the
consumer's Svelte compiler processes the .svelte.ts runes modules; it's
excluded from the tsdown bundle for that reason. Vitest gains a scoped
svelte project (svelte plugin + svelteTesting + jsdom) so runes tests
run without disturbing the other packages.

Adds docs (libs/svelte.mdx + sidebar entry) and a changeset.

Co-authored-by: Claude <noreply@anthropic.com>
A fourth renderer for the shared @sandbox/cmdk-core command palette,
driven by the Svelte binding. Unlike the React/OpenTUI/Native apps —
which all render through a React reconciler and share React's useMachine
— the Svelte app brings its own runes-based useMachine from
@dunky.dev/state-machine-svelte, yet runs the exact same machine and
connect() unchanged. Same behavior, different framework.

- Vite + vite-plugin-svelte, aliasing every @dunky.dev/* package (and the
  svelte binding's .svelte.ts runes source) to src for a live, no-build
  workspace run.
- app.svelte / command-palette.svelte port the React demo to Svelte 5:
  useMachine over the shared machine, normalize → lowercase DOM props,
  the ⌘K shortcut as a ComponentEffect, input-focus as an $effect.
- Updates sandbox/README.md to four substrates.

Co-authored-by: Claude <noreply@anthropic.com>
@ivanbanov ivanbanov added the 🚧 WIP This will not be worked on label Jun 23, 2026
@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dunky-state-machine Ready Ready Preview, Comment Jun 25, 2026 12:13pm
state-machine-website Ready Ready Preview, Comment Jun 25, 2026 12:13pm

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🚧 WIP This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant