UNPKG

@docuify/engine

Version:

A flexible, pluggable engine for building and transforming documentation content from source files.

59 lines (57 loc) 1.87 kB
type GetContentReturnType = string | Promise<string>; type TransformerFunction = (content: string) => Promise<string> | string; type SourceFile = { path: string; type: "folder" | "file"; content?: string; extension?: string | null; metadata?: Record<string, any>; loadContent?: () => string | Promise<string>; }; /** * @deprecated * Old shape for grouped file source entries. Not needed in the new system. */ type SourceFileData = { source: string; items: SourceFile[]; }; interface DocuifyNode { id: string; fullPath: string; name: string; type: "folder" | "file"; parentId?: string; metadata?: Record<string, any>; extension?: string | null; children?: DocuifyNode[]; _contentTransformQueue?: TransformerFunction[]; /** * Public content actions exposed to plugins or consumers. * Includes ability to register transforms, apply them, and load content. */ actions?: { /** * Adds a content transformation function to the internal queue. * These will be applied in the order they are added. */ useTransform?: (fn: TransformerFunction) => void; /** * Applies all registered transformations to raw content. * Useful when you already have content and just want to process it. */ transformContent?: (rawContent: string) => Promise<string>; /** * Loads and transforms the file content via `getContent`. * Throws if no loader is defined. */ loadContent?(): Promise<string>; }; /** * Extensibility hook for plugins. * Arbitrary keys can be attached to the node. * Example: node.myPluginData = { ... } */ [key: string]: any; } export type { DocuifyNode, GetContentReturnType, SourceFile, SourceFileData, TransformerFunction };