import type { GCPMContext } from "./gcpm.js"; import { Processor } from "./process.js"; import { events, rects } from "./util.js"; import Mutations from "./mutations.js"; import type { Fragmentor } from "./fragments"; import type { Unbreakable } from "./breaks.js"; import { type Point } from "./util/ranges.js"; import type { Process, ProcessorEvents, ProcessorOptions } from "./process.js"; export declare class Box { range: Range; inlinesRange?: Range; unbreakable?: Unbreakable; avoidBreakBefore: boolean; avoidBreakAfter: boolean; mainBlock?: HTMLElement; floats?: Float[]; bottomOffset?: BottomOffset; startBlock: HTMLElement; endBlock: HTMLElement; bottom?: number; top?: number; inlinesRangeRect?: rects.Rect; inlinesStartBoundary?: boolean; inlineStart: number; hasInlineBlocks: boolean; isRepeated?: HTMLElement; mutations: Mutations; } export interface LayoutContextEvents extends ProcessorEvents { 'float-move': { float: Float; area: HTMLElement; areaBody: HTMLElement; areaBodyRect: rects.Rect; newAreaBodyRect: rects.Rect; }; 'body-bottom-change': { oldBottom: number; newBottom: number; }; } export declare class LayoutContext extends events.EventEmitter { root: HTMLElement; body: HTMLElement; areas: Areas; parentCtx?: LayoutContext; boxes: Box[]; floats: Float[]; overflowPoint: Point; overflowBox: Box; breakPoint?: Point; breakBox?: Box; bottomOffsets: Map; mutations: Mutations; _bodyBottom: number; constructor(root: HTMLElement, body: HTMLElement, areas: Areas, parentCtx?: LayoutContext); get bodyBottom(): number; set bodyBottom(val: number); } export type FloatAlignment = "auto" | "none" | "baseline" | "block-start-edge" | "block-end-edge" | "inline-start-edge" | "inline-end-edge"; export type Areas = { [areaName: string]: HTMLElement; }; export interface Float { base: HTMLElement | SVGSVGElement; call: HTMLElement | SVGSVGElement; body: HTMLElement | SVGSVGElement; areaName: string; alignment: FloatAlignment; } export interface LayoutProcessorOptions extends ProcessorOptions { plugins: (string | [string, null | object])[] | Record; } export interface LayoutProcessorEvents extends ProcessorEvents { 'contents-start': Record; 'contents-end': Record; 'new-layout-context': { layoutContext: LayoutContext; previousContext: LayoutContext; }; 'box-start': { layoutContext: LayoutContext; box: Box; }; 'box-end': { layoutContext: LayoutContext; box: Box; }; 'overflow-detected': { layoutContext: LayoutContext; }; 'no-overflow': { layoutContext: LayoutContext; }; 'no-break-point': { layoutContext: LayoutContext; }; 'valid-break-point': { layoutContext: LayoutContext; }; 'new-break-point-to-valid': { layoutContext: LayoutContext; }; } export interface BottomOffset { after: number; inside: number; currentMargin: number; } export declare abstract class LayoutProcessor extends Processor { static defaultOptions: { plugins: (string | [string, null | object])[] | Record; logLevel: "error" | "warn" | "info" | "debug" | "trace"; pluginsUri: string | null; }; source: HTMLElement; doc: Document; subProcessors: SubProcessor[]; gcpmContext: GCPMContext; layoutContext: LayoutContext; avoidBreakTypes: string[]; logNoValidBreakPoint: boolean; lastEvent: keyof Events; startOnRoot: boolean; get mutations(): Mutations; protected constructor(source: string | HTMLElement, gcpmCtx: GCPMContext, options?: Partial); addSubProcessor(subProcessor: SubProcessor): this; prependSubProcessor(subProcessor: SubProcessor): this; contentsProcess(root: HTMLElement, areas: Areas, parentCtx?: LayoutContext): Process; boxesProcess(root: HTMLElement): Process; createLayoutContext(root: HTMLElement, areas: Areas, parentCtx: LayoutContext): LayoutContext; fixWidth(elem: HTMLElement, style: CSSStyleDeclaration, ctx: LayoutContext): void; } export declare function updateBottomOffsets(bottomOffsets: BottomOffset[], style: CSSStyleDeclaration): BottomOffset; export declare function testBoxOverflow(box: Box, bodyBottom: number): Point; export declare function testInlineOverflow(box: Box, bodyBottom: number, maxBottom?: number): Point; export declare function testLinesOverflow(box: Box, lines: rects.Rect[], maxBottom: number): Point; export declare function testAvoidBreakInside(fromNode: Node, ctx: LayoutContext, avoidBreakValues: string[], breakPoint?: Point, heightAtBreakElem?: boolean): Element | false; export declare function moveFloat(float: Float, ctx: LayoutContext, gcpmContext: GCPMContext, box?: Box): boolean; export declare function removeFloats(floats: Float[], stopPoint?: Point): void; export interface SubProcessorContext { currentElement: HTMLElement; currentStyle: CSSStyleDeclaration; walker: TreeWalker; currentBox: Box; } export interface SubFragmentor { parentFragmentor: Fragmentor; } export declare function isSubFragmentor(object: any): object is SubFragmentor; export type SubLayoutProcessResult = { event: 'valid-break-point' | 'no-break-point' | 'no-overflow'; breakPoint?: Point; }; export type SubProcessorResult = false | Promise; export type SubProcessor = (ctx: SubProcessorContext) => SubProcessorResult;