UNPKG

mancha

Version:

Javscript HTML rendering engine

78 lines (76 loc) 3.49 kB
import { a as StoreState, i as IRenderer, n as RenderParams, r as RendererPlugin, t as ParserParams } from "./interfaces-Dizh9utI.js"; import { SafeStyleSheet } from "safevalues"; //#region src/css_gen_basic.d.ts declare function rules(): SafeStyleSheet; //#endregion //#region src/css_gen_minimal.d.ts declare function rules$1(): SafeStyleSheet; //#endregion //#region src/css_gen_utils.d.ts declare function rules$2(): string; //#endregion //#region src/browser.d.ts declare class Renderer<T extends StoreState = StoreState> extends IRenderer<T> { readonly impl = "browser"; protected readonly dirpath: string; parseHTML(content: string, params?: ParserParams): Document | DocumentFragment; serializeHTML(root: Node | DocumentFragment): string; preprocessLocal(fpath: string, params?: RenderParams & ParserParams): Promise<Document | DocumentFragment>; createElement(tag: string, owner?: Document | null): Element; createComment(content: string, owner?: Document | null): Node; textContent(node: Node, content: string): void; } declare const Mancha: Renderer<StoreState>; /** Options for CSS injection. */ type CssName = "minimal" | "utils" | "basic"; /** * Injects CSS rules into the document head. * @param names - Array of CSS names to inject ("minimal", "utils", "basic"). */ declare function injectCss(names: CssName[]): void; /** Options for cloaking (hiding content until rendered). */ interface CloakOptions { /** Selector(s) for elements to cloak. Defaults to `target` option or 'body'. */ selector?: string | string[]; /** Fade-in animation duration in ms. Defaults to 0 (no animation). */ duration?: number; } /** Options for initializing Mancha. */ interface InitManchaOptions { /** Use an existing Renderer instance instead of creating a new one. */ renderer?: Renderer; /** CSS styles to inject before mounting. */ css?: CssName[]; /** Target selector(s) to mount the renderer to. */ target?: string | string[]; /** Enable debug mode. */ debug?: boolean; /** Cache policy for fetch requests. */ cache?: RequestCache; /** Initial state to set before mounting. */ state?: Record<string, unknown>; /** * Cloak (hide) content until rendering is complete. * - `true`: cloak with no animation (instant reveal) * - `CloakOptions`: advanced options with custom selector and/or fade-in duration */ cloak?: boolean | CloakOptions; /** * Callback invoked after CSS injection and state setup, but before mounting. * If provided, automatic mounting to `target` is skipped; call `renderer.mount()` manually. * The `uncloak` function is provided to reveal content (called automatically after this resolves). * @param renderer - The initialized Renderer instance. * @param uncloak - Function to reveal cloaked content with optional animation. */ callback?: (renderer: Renderer) => void | Promise<void>; } /** * Initializes Mancha with the provided options. * This is a convenience function for bundled environments. * * @param options - Initialization options. * @returns A promise that resolves to the Renderer instance. */ declare function initMancha<T extends StoreState = StoreState>(options?: InitManchaOptions): Promise<Renderer<T>>; //#endregion export { CloakOptions, CssName, IRenderer, InitManchaOptions, Mancha, type ParserParams, type RenderParams, Renderer, type RendererPlugin, rules as basicCssRules, initMancha, injectCss, rules$1 as minimalCssRules, rules$2 as utilsCssRules };