Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
By vadirnMITIn 1 marketplace
Gives Claude guidance for writing, reviewing and testing @muxmuxmux/machine code, where leaving a state aborts the async work it owns. The author claims zero dependencies, and the library ships Svelte and React bindings.
Trending plugins
7-day copy clicks
Claude loads one when your task matches it, or you run it by name.
1 marketplace, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
State machines whose states own their work. Leaving a state aborts that work. Zero dependencies.
pnpm add @muxmuxmux/machine
import { machine } from "@muxmuxmux/machine";
const upload = machine("idle", {
idle: { start: (visit) => visit.to("sending") },
sending: {
enter: async (visit) => {
try {
await post(file, { signal: visit.signal });
visit.to("idle");
} catch {
visit.to("failed");
}
},
cancel: (visit) => visit.to("idle"),
},
failed: { retry: (visit) => visit.to("sending") },
});
upload.start(); // idle → sending; enter starts the request
upload.cancel(); // sending → idle; the request aborts
upload.cancel(); // does nothing: "idle" has no cancel
A machine is a store of the state name, plus one method per name that any state declares. A call runs the current state's version. If the current state lacks that method, the call does nothing and returns undefined.
upload.start(e) takes the event first.visit.to(target) moves only while the visit is current. After the machine leaves, a late visit.to does nothing. So a request that fails after a cancel cannot move the machine to failed.enter(visit) runs on every entry into its state. visit.signal aborts when the visit ends.readable store, the machine works only while used. The first subscriber or call starts it. The last unsubscribe aborts the current visit. get() never starts it.once(m, method, { signal }) resolves with the arguments of the next call to method. Pass a visit as the options, so leaving the state rejects the wait.when(m, state, { signal }) resolves once the store is in state. It works on any { get, subscribe }, including a core controller.const confirm = machine("closed", {
closed: {
// The return annotation breaks a type cycle
ask: (visit): Promise<[ok: boolean]> =>
once(confirm, "answer", visit.to("open")),
},
open: {
answer: (visit, _ok: boolean) => visit.to("closed"),
dismiss: (visit) => visit.to("closed"),
},
});
const answer = await confirm.ask(); // [true] after answer(true); dismiss() rejects it
hold(child, visit) keeps a child machine running for exactly as long as the visit lasts. It is safe after an await, when the visit may already be over.
const player = machine("stopped", {
stopped: { play: (visit) => visit.to("playing") },
playing: {
enter: (visit) => hold(volume, visit),
stop: (visit) => visit.to("stopped"),
},
});
An optional third argument lists each state's allowed targets. Each state's visit.to then accepts only those targets. An unlisted move also throws at runtime, and a bad graph throws at creation.
machine("idle", states, {
idle: ["sending"],
sending: ["idle", "failed"],
failed: ["sending"],
});
The machine is a readable store, so $upload works in a component with no adapter. Mounting subscribes and starts it, and unmounting aborts the current visit.
upload.get(), not get(upload) from svelte/store. That helper subscribes and unsubscribes at once, so it runs enter and aborts it.enter runs on the server until its first await, and the end of the render aborts the visit. Moves made before that await show in the server HTML.enter, and start work from an event or onMount. Otherwise, keep browser-only code after an await, and tie every request and timer to visit.signal.import { useMachine } from "@muxmuxmux/machine/react";
function Upload({ file }: { file: File }) {
const upload = useMachine("idle", {
idle: { start: (visit) => visit.to("sending") },
sending: {
enter: async (visit) => {
await post(file, { signal: visit.signal });
visit.to("idle");
},
cancel: (visit) => visit.to("idle"),
},
});
return upload.get() === "idle" ? (
<button onClick={upload.start}>Upload</button>
) : (
<button onClick={upload.cancel}>Cancel</button>
);
}
enter keeps the props from when it entered.enter and runs it again.React is an optional peer dependency: install it only to use @muxmuxmux/machine/react.
Built from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
npx claudepluginhub vadirn/muxmuxmux --plugin muxmuxmux-machinePlugins from other owners that cover similar ground