@midnightcrafters/mcs-plugin-sdk
v0.1.1
Published
SDK for authoring Midnight Cutter Studio plugins — types + Vite build preset.
Maintainers
Readme
@midnightcrafters/mcs-plugin-sdk
SDK for authoring Midnight Cutter Studio plugins.
A plugin is a single ESM file exporting a PluginModule. It is loaded into MCS
at runtime and talks to the app only through the PluginAPI it receives in
init(api) — never by importing app internals.
Why this SDK exists
The host ships its own React, jotai and konva. A plugin must reuse those
singletons (a second React copy breaks hooks). This SDK's Vite preset marks
those modules external; at runtime MCS resolves them via an import map to its
own instances. Your plugin bundle therefore contains only your code.
Usage
// src/index.ts
import { definePlugin } from "@midnightcrafters/mcs-plugin-sdk";
export default definePlugin({
manifest: { id: "acme.hello", name: "Hello", version: "1.0.0" },
init: (api) => {
api.panels.register({ /* ... */ });
return () => { /* cleanup */ };
},
});// vite.config.ts
import { defineConfig } from "vite";
import { definePluginConfig } from "@midnightcrafters/mcs-plugin-sdk/vite";
export default defineConfig(definePluginConfig());npm run build → dist/index.js: one self-contained ESM file with React /
jotai / konva left external. Package it as .mcsplugin (see the plugin
distribution docs) and publish.
Types are re-exported from the running app's single source of truth, so the SDK contract can never drift from the host. Part of epic #175.
