Plugin Types
TypeScript type definitions for Frame-Master plugin development.
FrameMasterPlugin
Main plugin type definition.
types
type FrameMasterPlugin<Options extends PluginOptions = Required<PluginOptions>> =Required<{name: string; // Unique plugin nameversion: string; // Semver version}> &Partial<{router: RouterPlugin; // Request handling hooksserverStart: ServerStart; // Server startup hookspriority: number; // Execution order (0 = highest)requirement: Requirement; // Dependencies & version requirementsruntimePlugins: Bun.BunPlugin[];// Bun plugins for runtimedirectives: Directive[]; // File directivesserverConfig: ServerConfig; // Server configuration overridesfileSystemWatchDir: string[]; // Directories to watch (dev only)onFileSystemChange: FileChangeCallback; // File change handlerwebsocket: WebSocketHandlers; // WebSocket event handlersbuild: BuildOptionsPlugin; // Build hookscli: CLIExtension; // CLI commands}>;
Router Plugin
Request lifecycle hooks.
types
type RouterPlugin = Partial<{// Before request processingbefore_request: (master: masterRequest) => void | Promise<void>;// Main request handlerrequest: (master: masterRequest) => void | Promise<void>;// After request processingafter_request: (master: masterRequest) => void | Response | Promise<void | Response>;// HTML transformationhtml_rewrite: {initContext?: (req: masterRequest) => unknown;rewrite?: (reWriter: HTMLRewriter, master: masterRequest, context: unknown) => void | Promise<void>;after?: (HTML: string, master: masterRequest, context: unknown) => void | Promise<void>;};}>;
ServerStart
Server startup hooks.
types
type ServerStart = Partial<{/*** Executed on the main thread when server starts*/main: () => Promise<unknown> | unknown;/*** Executed only in development mode on main thread* ONLY DEV MODE*/dev_main: () => Promise<unknown> | unknown;}>;
BuildOptionsPlugin
Build lifecycle hooks.
types
type BuildOptionsPlugin = {/*** Build configuration - static object or dynamic function*/buildConfig?:| Partial<Bun.BuildConfig>| ((builder: Builder) => Partial<Bun.BuildConfig> | Promise<Partial<Bun.BuildConfig>>);/*** Called before Bun.build() - setup, validation*/beforeBuild?: (buildConfig: Bun.BuildConfig,builder: Builder) => void | Promise<void>;/*** Called after Bun.build() - post-processing*/afterBuild?: (buildConfig: Bun.BuildConfig,result: Bun.BuildOutput,builder: Builder) => void | Promise<void>;/*** Enable build logging*/enableLoging?: boolean;};
Requirement
Plugin dependency requirements.
types
type Requirement = Partial<{/*** Required Frame-Master plugins with versions* @example { "frame-master-auth": "^1.0.0" }*/frameMasterPlugins: Record<string, string>;/*** Required Frame-Master version* @example "^2.0.0"*/frameMasterVersion: string;/*** Required Bun runtime version* @example ">=1.0.0 <2.0.0"*/bunVersion: string;}>;
WebSocket Handlers
WebSocket event handlers.
types
type WebSocketHandlers = Partial<{onOpen: (ws: Bun.ServerWebSocket<undefined>) => Promise<void> | void;onMessage: (ws: Bun.ServerWebSocket<undefined>,message: string | ArrayBufferView) => Promise<void> | void;onClose: (ws: Bun.ServerWebSocket<undefined>) => Promise<void> | void;}>;
FileChangeCallback
File system change handler.
types
type WatchEventType = "change" | "rename";type FileChangeCallback = (eventType: WatchEventType,filePath: string,absolutePath: string) => void | Promise<void>;
CLI Extension
Commander.js CLI extension.
types
import type { Command } from "commander";type CLIExtension = (command: Command) => Command;
💡
CLI extensions are available under
frame-master extended-cli <command>