Anatomy of a plugin
Typical layout for a Node plugin:
my-plugin/
manifest.json # Plugin metadata (required)
main.ts # Plugin source (TypeScript)
main.js # Compiled entry point (built by esbuild)
package.json # npm project file
README.mdFor Deno plugins, main.js is replaced by running main.ts directly — no build step needed.
Key files
manifest.json: All required fields includingid,name,version,description,author,dotxVersion,permissions, andmain.main.ts: ExtendsPlugin, callsrunPlugin(YourClass).
Minimal entry (Node)
ts
import Plugin, { runPlugin } from "@dotmatrixlabs/dotx-plugin-sdk";
class MyPlugin extends Plugin {
async onLoad() {
this.config.init({ defaults: { enabled: true } });
}
}
if (require.main === module) {
runPlugin(MyPlugin);
}Minimal entry (Deno)
ts
import Plugin, { runPlugin } from "npm:@dotmatrixlabs/dotx-plugin-sdk";
class MyPlugin extends Plugin {
async onLoad() {
this.config.init({ defaults: { enabled: true } });
}
}
runPlugin(MyPlugin);Lifecycle hooks
| Hook | When called |
|---|---|
onLoad() | After successful registration with the host |
onUnload() | On graceful shutdown (SIGINT / SIGTERM) |