Add pagination blocks, renderCore, layout audit and react-pdf quirk tests

TableGuard, BottomSpacer, FirstPageHeader and PageChrome implement the
verified pagination rules; renderCore returns bytes, a normalised layout
tree, audit issues and a layout fingerprint. auditLayout detects overlaps,
ink overflow, truncation, header-only pages and split blocks. Quirk tests
pin the react-pdf behaviours the design depends on, and a child-process
test pins the page-level absolute Svg hang.
This commit is contained in:
2026-10-04 05:05:51 +05:30
parent 3818b1eeed
commit e2032a3f9c
24 changed files with 2187 additions and 5 deletions
+4 -2
View File
@@ -8,6 +8,8 @@ export interface RenderTxtProps extends TxtStyleProps, PdfFlagsInput {
/** Receives { pageNumber, totalPages, subPageNumber, ... } from react-pdf. */
render: (info: { pageNumber: number; totalPages: number; subPageNumber: number; subPageTotalPages: number }) => string;
role: RoleName | TypeToken;
/** react-pdf copies the id into the layout tree (the audit finds chrome nodes by it). */
id?: string;
width?: number;
grow?: boolean;
style?: Record<string, unknown>;
@@ -20,7 +22,7 @@ export interface RenderTxtProps extends TxtStyleProps, PdfFlagsInput {
* metrics, never a fixed height. No maxLines: a clamped render-prop Text draws nothing.
* `totalPages` is undefined on the first layout pass, so the render function must cope with that.
*/
export function RenderTxt({ role, render, color, align, weight, italic, width, grow, style, faceOverrides, fixed, wrap, minPresenceAhead }: RenderTxtProps) {
export function RenderTxt({ id, role, render, color, align, weight, italic, width, grow, style, faceOverrides, fixed, wrap, minPresenceAhead }: RenderTxtProps) {
const token = roleToken(role);
assertNoLineHeight(style, "RenderTxt");
const merged = {
@@ -29,5 +31,5 @@ export function RenderTxt({ role, render, color, align, weight, italic, width, g
...(grow ? FILL : {}),
...style,
};
return <Text style={merged as never} render={render as never} {...pdfFlags({ fixed, wrap, minPresenceAhead })} />;
return <Text {...(id !== undefined ? { id } : {})} style={merged as never} render={render as never} {...pdfFlags({ fixed, wrap, minPresenceAhead })} />;
}