@symbiosis-lab/moss-api
v0.21.0
Published
Official API for building moss plugins - types and utilities for plugin development
Maintainers
Readme
@symbiosis-lab/moss-api
TypeScript API for writing moss plugins.
moss turns a folder of markdown into a website, wherever you write; this package is its plugin API. Plugins run in moss's embedded QuickJS environment, which has no DOM. Use it to write plugins that publish posts, manage site assets, or extend the build.
Quickstart
npm install @symbiosis-lab/moss-apiA plugin is an object whose methods are hooks; moss calls them with a typed context:
import type { DeployContext, HookResult } from "@symbiosis-lab/moss-api";
import { reportProgress } from "@symbiosis-lab/moss-api";
export default {
async deploy(context: DeployContext): Promise<HookResult> {
await reportProgress("deploying", 0, 100, "Initializing");
// ... deployment logic
return { success: true, message: "Deployed successfully" };
},
};Test plugins without a running moss app via the mock layer:
import { setupMockTauri } from "@symbiosis-lab/moss-api/testing";Anatomy of a plugin
A plugin is three things:
- A manifest (
assets/manifest.json) — who you are, what the user gains by installing you, and what they're trusting you with. See the manifest reference. - A bundle (
dist/main.bundle.js) — one IIFE built with esbuild, exposing your plugin object under the manifest'sglobal_name. - An icon (
assets/icon.svg).
Ship the manifest, the bundle and the icon together; that trio is what moss installs.
Your code runs in QuickJS, not a browser — no DOM, no crypto.subtle, no
Web Streams, and fetch is a buffered shim. Read
the runtime environment before you reach for a
web API; green Node-mock tests do not prove QuickJS compatibility.
API reference
The full reference — every hook context, utility, and testing mock, generated from the source doc comments — lives in docs/api.
Topic guides: the plugin runtime environment (what globals exist under QuickJS, fetch limits, config merge rules — read this first), the plugin manifest, plugin authentication.
Regenerate after an API change with pnpm run docs (CI flags a reference that has drifted from the source).
Stability
This package is 0.x. The API may change between minor versions until 1.0. Breaking changes are documented in CHANGELOG.md.
License
MIT — see LICENSE.
