/** * Type declarations for the Vite plugin. The runtime lives in `vite.js` — * see that file for behavior, options, and the reasoning for splitting `.js` * + `.d.ts` instead of using a single `.ts` source. */ type UserConfig = { base?: string } type ResolvedConfig = { root: string; command: "serve" | "build" } type ServerLike = { middlewares: { use: (handler: MiddlewareHandler) => unknown } } type MiddlewareHandler = ( req: { url?: string }, res: { statusCode?: number setHeader: (name: string, value: string) => void end: (body?: string) => void }, next: () => void, ) => void type AssetEmitterContext = { emitFile: (file: { type: "asset" fileName: string source: string }) => string } export type NotionCustomBlockPlugin = { name: string config: (userConfig: UserConfig) => { base: string } configResolved: (config: ResolvedConfig) => void configureServer: (server: ServerLike) => void configurePreviewServer: (server: ServerLike) => void buildStart: (this: AssetEmitterContext) => void } /** * Vite plugin that serves the project's `custom_blocks.json` to the custom-block * bundle in dev and emits it as a separate asset on build. */ export function notionCustomBlock(): NotionCustomBlockPlugin