pantoken / packages/plugin-kit/src / runPluginHook
Function: runPluginHook()
runPluginHook<
T>(entry,stage,ctx):Promise<T|null>
Beta
Run a single hook of a sandboxed plugin entry. The hook receives a serializable context and returns a serializable result; function references in the context are not supported.
Type Parameters
T
T
Parameters
entry
The sandboxed plugin entry.
stage
The hook to run.
ctx
unknown
A serializable context object (no function references).
Returns
Promise<T | null>
The hook's return value, or null if the hook is absent or returns undefined.
Example
Run the token hook of a sandboxed plugin
ts
import { runPluginHook } from "@pantoken/plugin-kit";
import type { TokenHookContext } from "@pantoken/model";
const entry = { path: "/abs/path/to/my-plugin.js", sandbox: "thread" as const };
const ctx: TokenHookContext = { tokens: [], theme: "rebrand" };
const result = await runPluginHook(entry, "tokens", ctx);