@miraiclip/core
v0.3.0
Published
Headless, command-driven engine for building video editors — state, commands, history, patches, events.
Maintainers
Readme
@miraiclip/core
Headless, command-driven engine for building video editors in the browser (and Node). The core of Miraiclip: it manages project state, a microsecond-precision timeline, and full command history — rendering is delivered by separate packages.
- Command-driven — every mutation is a descriptive, Zod-validated, undoable command
- AI-native —
commandCatalog()exports one JSON Schema per command, ready as LLM tool definitions - Time travel — undo/redo with atomic transactions, backed by inverse patches
- Collaboration-ready — changes emitted as RFC-6902 JSON patches;
applyJsonPatchesreplays them on a follower - Framework agnostic — a vanilla Zustand store underneath; zero UI dependencies
Install
npm install @miraiclip/coreUsage
import { createProject } from "@miraiclip/core";
const project = createProject({ width: 1920, height: 1080, fps: 30 });
project.dispatch({
type: "asset/add",
payload: { id: "intro", kind: "video", src: "/media/intro.mp4", durationUs: 12_000_000 },
});
project.dispatch({ type: "track/add", payload: { id: "v1", kind: "video" } });
project.dispatch({
type: "clip/add",
payload: { kind: "video", id: "c1", trackId: "v1", assetId: "intro", startUs: 0, durationUs: 5_000_000 },
});
project.transaction(() => {
project.dispatch({ type: "clip/split", payload: { clipId: "c1", atUs: 2_000_000, newClipId: "c1b" } });
project.dispatch({ type: "clip/move", payload: { clipId: "c1b", startUs: 3_000_000 } });
});
project.undo();
project.redo();
project.events.on("patches", ({ patches }) => {
// RFC-6902 ops, e.g. [{ op: "replace", path: "/clips/c1/startUs", value: 1000000 }]
});
const saved = project.toJSON();Documentation — quickstart, core concepts, and the command catalog: comaniacs.github.io/miraiclip · Source
License
MIT
