/** * Pure helpers used by `buildDocument`. Extracted here purely to keep the * main pipeline function readable; no behavior changes. */ import type { ContentBlock } from '../parse/index.js'; import { type VDTBlock, type VDTPage, type BoundingBox, type ResolvedConfig } from '../vdt.js'; import type { BlockStyle } from './styles.js'; import type { MeasuredBlock } from '../measure/index.js'; export interface PageMetrics { trimWidthPx: number; trimHeightPx: number; /** The sheet (trim plus the cut-lines band on every side), physical. */ pageWidthPx: number; pageHeightPx: number; trimOffset: number; /** Content area of an odd (recto) page — the trim box inset by the * margins as written, in the flow frame (see `vertical`). Use * `contentAreaForPage` for a specific page so mirrored margins swap on * the pages that face the other way. */ contentArea: BoundingBox; /** The trim box (the final page after cutting) in flow px. */ trimBox: BoundingBox; /** The trim box expanded by `cutLines.bleed` on every side when cut lines * are enabled; equals `trimBox` otherwise. Design elements anchored to * `'bleed'` run to this frame. In flow px. */ bleedBox: BoundingBox; /** Whether the flow is set vertically (`layout.writingMode: * 'vertical-rl'`): `contentArea`, `trimBox` and `bleedBox` are then in * the flow frame (`flowWidthPx` = the sheet's height, `flowHeightPx` = * its width; see `VDTPage.flow`), and `physical` holds them on the * sheet. On a horizontal page the two frames are one. */ vertical: boolean; /** Whether the flow is laid out mirrored (a right-to-left document, * `resolvedDirection()`; see `VDTMirroredFlowFrame`): `contentArea`, * `trimBox` and `bleedBox` are then the sheet's rects turned over its * vertical axis (`x` → `pageWidthPx − x`), and `physical` holds them on * the sheet. Never set together with `vertical`, which wins. */ mirrored: boolean; flowWidthPx: number; flowHeightPx: number; physical: { contentArea: BoundingBox; trimBox: BoundingBox; bleedBox: BoundingBox; }; } /** A sheet rect in the flow frame of a vertical page `sheetWidthPx` wide * (see `pageRectToFlow`): `(x, y, w, h)` → `(y, W − x − w, h, w)`. */ export declare function sheetRectToFlow(rect: BoundingBox, sheetWidthPx: number): BoundingBox; /** A sheet rect in the flow frame a page of `metrics` lays its flow out in * (see `pageRectToFlow`): turned on a vertical page, mirrored on a * right-to-left one, as it is otherwise. */ export declare function sheetRectToPageFlow(rect: BoundingBox, metrics: Pick & Partial>): BoundingBox; /** The config a composed page is laid out with on a host's leaf * (`composedViewerLeaf`, #1045): the document's, with the leaf's size and * margins and no cut marks. Undefined without a leaf. */ export declare function composedLeafConfig(resolved: ResolvedConfig): ResolvedConfig | undefined; /** Whether `page` was laid out on the host's leaf (`composedViewerLeaf`, * #1045): a composed page of a document that has one. */ export declare function onComposedLeaf(resolved: ResolvedConfig, page: { composed?: unknown; comic?: unknown; }): boolean; export declare function computePageMetrics(resolved: ResolvedConfig): PageMetrics; /** Mirror a content area horizontally about the page's vertical centre line: * the inner margin becomes the outer one and vice versa. Vertical extent is * unchanged. */ export declare function mirrorContentArea(area: BoundingBox, pageWidthPx: number): BoundingBox; /** Mirror an area of a page's flow frame about the sheet's vertical centre * line (`pageWidthPx` = the physical sheet width): a horizontal flip on a * horizontal page, a flip of the flow's y axis on a vertical one (the * flow's y runs across the sheet). */ export declare function mirrorFlowArea(area: BoundingBox, pageWidthPx: number, vertical: boolean): BoundingBox; /** Whether the page at `pageIndex` (position in `doc.pages`; its number is * `pageIndex + pageIndexOffset + 1`) sets its mirrored margins swapped: * with `margins.mirror`, the pages whose spine is on their left in the * book's binding — the even pages of a left-bound book, the odd ones * (rectos, the left pages of a spread) of a right-bound one. */ export declare function pageMirrored(resolved: Pick, pageIndex: number, pageIndexOffset?: number, mirror?: boolean): boolean; /** Whether `page` swaps its mirrored margins as seen from its flow: the * parity the rules keyed to a page's spine side read (a callout's * `'outer'` corner icon, an `'outer'` side column, the flush end of a * turned float, a floated box's outer side). On a left-to-right page it * is {@link pageMirrored}. A right-to-left page's flow is turned over the * sheet (`VDTMirroredFlowFrame`), which puts the spine of a page whose * spine is on its right on the flow's left: there the flow parity is the * physical one inverted, so a right-bound right-to-left book behaves, in * its flow, as a left-bound left-to-right one. Without mirrored margins * no page swaps, in either direction. */ export declare function flowPageMirrored(resolved: Pick, page: Pick, pageIndexOffset?: number, mirror?: boolean): boolean; /** Content area for the page at `pageIndex` (position in `doc.pages`). With * `margins.mirror`, the pages {@link pageMirrored} names swap the inner and * outer margins so the inner margin always faces the spine. The area is in * the page's flow frame (vertical when `resolved.layout.writingMode` is). */ export declare function contentAreaForPage(metrics: Pick, resolved: ResolvedConfig, pageIndex: number, pageIndexOffset?: number): BoundingBox; /** `width` less the end indent of `blk`, never under 1 px. */ export declare function widthLessEndIndent(blk: VDTBlock, width: number): number; /** Give `to`, a copy of `from`, the end indent `from` was set with. */ export declare function copyBlockEndIndent(from: VDTBlock, to: VDTBlock): void; export declare function applyStyleAttrs(blk: VDTBlock, style: BlockStyle): void; /** * Resolve inline math in a parsed block: calls `renderMath` on every `span.math` * and attaches `mathRender` metadata. When math is disabled, drops the math * metadata so spans fall back to the raw TeX (visible as literal `$...$`). */ export declare function enrichMathSpans(contentBlock: ContentBlock, style: BlockStyle, resolved: ResolvedConfig): ContentBlock; export interface MeasureViewport { measureMaxWidth: number; lineXShift: number; measureFirstLineIndent: number; measureHangingIndent: boolean; /** Each line's indent (`MeasureBlockOptions.lineIndentsPx`) when the * style pairs a first-line indent with a hanging one (#620). */ measureLineIndents?: number[]; } /** Compute measurement viewport: list items reserve horizontal space for indent + bullet + gap. */ export declare function computeMeasureViewport(columnWidth: number, style: BlockStyle, listBullet: import('./lists.js').ListBulletStyle | undefined): MeasureViewport; /** * Stamps `plainStart` / `plainEnd` / `sourceStart` / `sourceEnd` on every line * of `measured`, accounting for any heading-number prefix that prepends chars * with no source. `source` is the markdown the block's offsets index (the * body, before `bodyOffset`): with it, a line that opens with a backslash * escape (`\$40`) starts at the backslash, which the plain text does not * print (EF-178). A block's `sourceMap` maps the escaped character itself. */ export declare function stampSourceRanges(measured: MeasuredBlock, rawBlock: ContentBlock, contentBlock: ContentBlock, bodyOffset: number, source?: string): { prefixLen: number; absoluteSourceMap: number[]; }; export declare function rollbackTrailingBlocks(curCol: { blocks: VDTBlock[]; availableHeight: number; bbox: BoundingBox; }, docBlocks: VDTBlock[], predicate: (b: VDTBlock) => boolean): VDTBlock[]; export declare function isMarkerBlock(block: ContentBlock | undefined): boolean; /** The next non-marker block after `idx`, or `undefined` at the end. */ export declare function nextNonMarkerBlock(blocks: readonly ContentBlock[], idx: number): ContentBlock | undefined; /** Body lines of the `:::space` directives right after `idx` (through * container markers and other directives, up to the next content block) — * the room keep-with-next must leave between a heading and its text. */ export declare function spaceLinesAfter(blocks: readonly ContentBlock[], idx: number): number; /** The previous non-marker block before `idx`, or `undefined` at the start. */ export declare function prevNonMarkerBlock(blocks: readonly ContentBlock[], idx: number): ContentBlock | undefined; //# sourceMappingURL=buildHelpers.d.ts.map