@littlepress/renderer-web 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +20 -0
- package/README.md +229 -2
- package/dist/answer/answerComponents.d.ts +107 -0
- package/dist/answer/answerComponents.js +637 -0
- package/dist/answer/download.d.ts +63 -0
- package/dist/answer/download.js +109 -0
- package/dist/answer/downloadExport.d.ts +44 -0
- package/dist/answer/downloadExport.js +266 -0
- package/dist/answer/hostValues.d.ts +28 -0
- package/dist/answer/hostValues.js +379 -0
- package/dist/answer/mapComponent.d.ts +6 -0
- package/dist/answer/mapComponent.js +213 -0
- package/dist/answer/math.d.ts +57 -0
- package/dist/answer/math.js +168 -0
- package/dist/answer/surfaceStream.d.ts +51 -0
- package/dist/answer/surfaceStream.js +260 -0
- package/dist/answer/tableLayout.d.ts +42 -0
- package/dist/answer/tableLayout.js +89 -0
- package/dist/controls/ActionFeedback.d.ts +5 -0
- package/dist/controls/ActionFeedback.js +43 -0
- package/dist/controls/actionDispatch.d.ts +51 -0
- package/dist/controls/actionDispatch.js +211 -0
- package/dist/controls/actionOutcome.generated.d.ts +64 -0
- package/dist/controls/actionOutcome.generated.js +64 -0
- package/dist/controls/calculationPublisher.d.ts +14 -0
- package/dist/controls/calculationPublisher.js +6 -0
- package/dist/controls/calculations.d.ts +20 -0
- package/dist/controls/calculations.generated.d.ts +73 -0
- package/dist/controls/calculations.generated.js +85 -0
- package/dist/controls/calculations.js +208 -0
- package/dist/controls/controlState.d.ts +84 -0
- package/dist/controls/controlState.js +256 -0
- package/dist/controls/fieldMessages.d.ts +41 -0
- package/dist/controls/fieldMessages.js +81 -0
- package/dist/controls/fieldValidation.d.ts +19 -0
- package/dist/controls/fieldValidation.js +98 -0
- package/dist/controls/formComponents.d.ts +23 -0
- package/dist/controls/formComponents.js +738 -0
- package/dist/controls/formProgress.d.ts +63 -0
- package/dist/controls/formProgress.js +122 -0
- package/dist/controls/inputDrafts.d.ts +55 -0
- package/dist/controls/inputDrafts.js +183 -0
- package/dist/controls/inputValidation.d.ts +33 -0
- package/dist/controls/inputValidation.js +119 -0
- package/dist/controls/localWrites.d.ts +9 -0
- package/dist/controls/localWrites.js +29 -0
- package/dist/core/A2uiSurface.d.ts +13 -0
- package/dist/core/A2uiSurface.js +15 -0
- package/dist/core/AtlasIcon.d.ts +18 -0
- package/dist/core/AtlasIcon.js +22 -0
- package/dist/core/AtlasMedia.d.ts +22 -0
- package/dist/core/AtlasMedia.js +45 -0
- package/dist/core/Carousel.d.ts +61 -0
- package/dist/core/Carousel.js +183 -0
- package/dist/core/CoreMedia.d.ts +19 -0
- package/dist/core/CoreMedia.js +25 -0
- package/dist/core/FoundationA2uiSurface.d.ts +86 -0
- package/dist/core/FoundationA2uiSurface.js +440 -0
- package/dist/core/ImagePreview.d.ts +42 -0
- package/dist/core/ImagePreview.js +73 -0
- package/dist/core/LucideIcon.d.ts +19 -0
- package/dist/core/LucideIcon.js +42 -0
- package/dist/core/SurfaceLink.d.ts +35 -0
- package/dist/core/SurfaceLink.js +60 -0
- package/dist/core/appearance/aegis.d.ts +49 -0
- package/dist/core/appearance/aegis.js +34 -0
- package/dist/core/appearance/colour.d.ts +24 -0
- package/dist/core/appearance/colour.js +103 -0
- package/dist/core/appearance/css.d.ts +17 -0
- package/dist/core/appearance/css.js +153 -0
- package/dist/core/appearance/presets.generated.d.ts +4 -0
- package/dist/core/appearance/presets.generated.js +1184 -0
- package/dist/core/appearance/react.d.ts +29 -0
- package/dist/core/appearance/react.js +110 -0
- package/dist/core/appearance/resolve.d.ts +76 -0
- package/dist/core/appearance/resolve.js +127 -0
- package/dist/core/appearance/textScale.d.ts +11 -0
- package/dist/core/appearance/textScale.js +51 -0
- package/dist/core/appearance/theme.d.ts +138 -0
- package/dist/core/appearance/theme.js +274 -0
- package/dist/core/baseComponents.d.ts +53 -0
- package/dist/core/baseComponents.js +480 -0
- package/dist/core/binding.d.ts +46 -0
- package/dist/core/binding.js +118 -0
- package/dist/core/bundle.d.ts +23 -0
- package/dist/core/bundle.js +75 -0
- package/dist/core/catalog/catalog-index.generated.d.ts +44 -0
- package/dist/core/catalog/catalog-index.generated.js +79 -0
- package/dist/core/catalog/icons.generated.d.ts +6 -0
- package/dist/core/catalog/icons.generated.js +1788 -0
- package/dist/core/catalog.d.ts +6 -0
- package/dist/core/catalog.generated.d.ts +50 -0
- package/dist/core/catalog.generated.js +2174 -0
- package/dist/core/catalog.js +8 -0
- package/dist/core/chartRows.d.ts +7 -0
- package/dist/core/chartRows.js +38 -0
- package/dist/core/component-support.d.ts +39 -0
- package/dist/core/component-support.js +127 -0
- package/dist/core/components/actions.d.ts +4 -0
- package/dist/core/components/actions.js +21 -0
- package/dist/core/components/cards.d.ts +9 -0
- package/dist/core/components/cards.js +227 -0
- package/dist/core/components/charts.d.ts +18 -0
- package/dist/core/components/charts.js +412 -0
- package/dist/core/components/comparisonTable.d.ts +50 -0
- package/dist/core/components/comparisonTable.js +89 -0
- package/dist/core/components/content.d.ts +13 -0
- package/dist/core/components/content.js +108 -0
- package/dist/core/components/seriesCharts.d.ts +531 -0
- package/dist/core/components/seriesCharts.js +1053 -0
- package/dist/core/components/stepFlow.d.ts +7 -0
- package/dist/core/components/stepFlow.js +13 -0
- package/dist/core/components.full.d.ts +10 -0
- package/dist/core/components.full.js +41 -0
- package/dist/core/context.d.ts +207 -0
- package/dist/core/context.js +172 -0
- package/dist/core/coverage.d.ts +30 -0
- package/dist/core/coverage.js +93 -0
- package/dist/core/foundation.d.ts +21 -0
- package/dist/core/foundation.js +22 -0
- package/dist/core/fullTheme.d.ts +5 -0
- package/dist/core/fullTheme.js +9 -0
- package/dist/core/iconNodes.generated.d.ts +7 -0
- package/dist/core/iconNodes.generated.js +5 -0
- package/dist/core/lucideIcons.d.ts +5 -0
- package/dist/core/lucideIcons.js +7 -0
- package/dist/core/messages.d.ts +111 -0
- package/dist/core/messages.js +134 -0
- package/dist/core/pointer.d.ts +17 -0
- package/dist/core/pointer.js +104 -0
- package/dist/core/registry.d.ts +12 -0
- package/dist/core/registry.js +114 -0
- package/dist/core/runtime.d.ts +8 -0
- package/dist/core/runtime.js +6 -0
- package/dist/core/state.d.ts +73 -0
- package/dist/core/state.js +274 -0
- package/dist/core/surfaceMotion.d.ts +5 -0
- package/dist/core/surfaceMotion.js +46 -0
- package/dist/core/theme.d.ts +5 -0
- package/dist/core/theme.js +7 -0
- package/dist/core/useSurfaceImage.d.ts +20 -0
- package/dist/core/useSurfaceImage.js +65 -0
- package/dist/graph/RelationshipGraph.d.ts +14 -0
- package/dist/graph/RelationshipGraph.js +206 -0
- package/dist/graph/model.d.ts +20 -0
- package/dist/graph/model.js +36 -0
- package/dist/graph/program/assets.d.ts +3 -0
- package/dist/graph/program/assets.js +3 -0
- package/dist/graph/program/bridge.d.ts +6 -0
- package/dist/graph/program/bridge.generated.d.ts +136 -0
- package/dist/graph/program/bridge.generated.js +1 -0
- package/dist/graph/program/bridge.js +24 -0
- package/dist/graph/program/bridge.schema.json +717 -0
- package/dist/graph/program/bridgeValidator.cjs +2 -0
- package/dist/graph/program/bridgeValidator.d.cts +4 -0
- package/dist/graph/program/runner.d.ts +1 -0
- package/dist/graph/program/runner.html +2193 -0
- package/dist/graph/program/runner.js +157 -0
- package/dist/graph/program/runtime-manifest.json +1 -0
- package/dist/graph/program/view.d.ts +11 -0
- package/dist/graph/program/view.js +210 -0
- package/dist/graph/program/worker.d.ts +1 -0
- package/dist/graph/program/worker.js +2186 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +45 -0
- package/dist/internal/dsh.d.ts +4 -0
- package/dist/internal/dsh.js +3 -0
- package/dist/internal/relationship-graph.d.ts +4 -0
- package/dist/internal/relationship-graph.js +7202 -0
- package/dist/page/layoutComponents.d.ts +6 -0
- package/dist/page/layoutComponents.js +123 -0
- package/dist/page/layoutGeometry.d.ts +68 -0
- package/dist/page/layoutGeometry.js +174 -0
- package/dist/page/pageFormat.d.ts +34 -0
- package/dist/page/pageFormat.js +119 -0
- package/dist/page/printFit.d.ts +81 -0
- package/dist/page/printFit.js +338 -0
- package/dist/react/index.d.ts +5 -0
- package/dist/react/index.js +2 -0
- package/dist/report/locate.d.ts +42 -0
- package/dist/report/locate.js +34 -0
- package/dist/styles/renderer.css +4580 -0
- package/licenses/LUCIDE-LICENSE.txt +43 -0
- package/licenses/QUICKJS-EMSCRIPTEN-LICENSE.txt +21 -0
- package/licenses/QUICKJS-VARIANT-LICENSE.txt +47 -0
- package/package.json +68 -3
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { type A2uiComponent } from "../core/messages.ts";
|
|
3
|
+
import { type RenderContext } from "../core/context.ts";
|
|
4
|
+
export declare function renderLayoutPage(component: A2uiComponent, context: RenderContext): ReactNode;
|
|
5
|
+
export declare function renderLayoutGrid(component: A2uiComponent, context: RenderContext): ReactNode;
|
|
6
|
+
export declare function renderLayoutSlot(component: A2uiComponent, context: RenderContext): ReactNode;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { isRecord } from "../core/messages.js";
|
|
4
|
+
import { layoutGridStyle, layoutPageStyle, layoutSlotStyle, printPageSize, printSlotStyle, printTextAreaStyle, printTypeVariables, } from "./layoutGeometry.js";
|
|
5
|
+
import { measurePrintPage, observePrintSlot } from "./printFit.js";
|
|
6
|
+
import { childContext } from "../core/context.js";
|
|
7
|
+
import { renderChildren } from "../core/baseComponents.js";
|
|
8
|
+
import { RenderComponent } from "../core/registry.js";
|
|
9
|
+
function PrintLayoutPage({ component, context }) {
|
|
10
|
+
const ref = useRef(null);
|
|
11
|
+
const [zoom, setZoom] = useState(1);
|
|
12
|
+
const [fitReport, setFitReport] = useState(null);
|
|
13
|
+
const size = printPageSize(component);
|
|
14
|
+
const pageWidth = size?.width ?? null;
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const parent = ref.current?.parentElement;
|
|
17
|
+
if (!parent || pageWidth === null)
|
|
18
|
+
return;
|
|
19
|
+
const measure = () => {
|
|
20
|
+
if (parent.clientWidth > 0)
|
|
21
|
+
setZoom(parent.clientWidth / pageWidth);
|
|
22
|
+
};
|
|
23
|
+
measure();
|
|
24
|
+
const observer = new ResizeObserver(measure);
|
|
25
|
+
observer.observe(parent);
|
|
26
|
+
return () => observer.disconnect();
|
|
27
|
+
}, [pageWidth]);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
const node = ref.current;
|
|
30
|
+
if (!node)
|
|
31
|
+
return;
|
|
32
|
+
let frame = 0;
|
|
33
|
+
const measure = () => {
|
|
34
|
+
if (frame)
|
|
35
|
+
cancelAnimationFrame(frame);
|
|
36
|
+
frame = requestAnimationFrame(() => setFitReport(measurePrintPage(node)));
|
|
37
|
+
};
|
|
38
|
+
node.addEventListener("littlepress:slot-fit", measure);
|
|
39
|
+
const observer = new ResizeObserver(measure);
|
|
40
|
+
observer.observe(node);
|
|
41
|
+
measure();
|
|
42
|
+
return () => {
|
|
43
|
+
if (frame)
|
|
44
|
+
cancelAnimationFrame(frame);
|
|
45
|
+
observer.disconnect();
|
|
46
|
+
node.removeEventListener("littlepress:slot-fit", measure);
|
|
47
|
+
};
|
|
48
|
+
}, []);
|
|
49
|
+
if (!size) {
|
|
50
|
+
return _jsx("main", { className: "a2ui-layout-page", style: layoutPageStyle(component), children: renderChildren(component, context) });
|
|
51
|
+
}
|
|
52
|
+
const excluded = new Set(Array.isArray(component.excludedComponentIds)
|
|
53
|
+
? component.excludedComponentIds.filter((id) => typeof id === "string")
|
|
54
|
+
: []);
|
|
55
|
+
const childIds = Array.isArray(component.children)
|
|
56
|
+
? component.children.filter((id) => typeof id === "string")
|
|
57
|
+
: [];
|
|
58
|
+
const indexedChildren = childIds.map((id, index) => ({ id, index }));
|
|
59
|
+
const gridChildren = indexedChildren.filter(({ id }) => context.state.components[id]?.component === "LayoutGrid_Default");
|
|
60
|
+
const unplaced = indexedChildren.filter(({ id }) => context.state.components[id]?.component !== "LayoutGrid_Default" && !excluded.has(id));
|
|
61
|
+
return (_jsxs("main", { ref: ref, className: "a2ui-layout-page a2ui-print-page", style: { width: `${size.width}px`, height: `${size.height}px`, zoom, ...printTypeVariables(component) }, "data-template": typeof component.templateCode === "string" ? component.templateCode : undefined, "data-fit-status": fitReport?.status, children: [_jsx("div", { className: "a2ui-print-textarea", style: printTextAreaStyle(component), children: gridChildren.map(({ id, index }) => (_jsx(RenderComponent, { componentId: id, context: childContext(context, component.id, undefined, index) }, id))) }), unplaced.length > 0 ? (_jsxs("div", { className: "a2ui-print-unplaced", role: "status", children: [_jsx("p", { className: "lp-meta", children: "Did not fit this page" }), unplaced.map(({ id, index }) => (_jsx(RenderComponent, { componentId: id, context: childContext(context, component.id, undefined, index) }, id)))] })) : null, fitReport?.blocking ? _jsx("p", { className: "a2ui-print-fit-summary", "aria-hidden": "true", children: "Layout failed" }) : null] }));
|
|
62
|
+
}
|
|
63
|
+
function renderSizedSlotChildren(component, context) {
|
|
64
|
+
const rects = isRecord(component.childRects) ? component.childRects : null;
|
|
65
|
+
const heights = isRecord(component.childHeightsPt) ? component.childHeightsPt : null;
|
|
66
|
+
const childIds = Array.isArray(component.children)
|
|
67
|
+
? component.children.filter((entry) => typeof entry === "string")
|
|
68
|
+
: [];
|
|
69
|
+
const printMode = (childId) => {
|
|
70
|
+
const child = context.state.components[childId];
|
|
71
|
+
return child ? context.componentMetadata?.[child.component]?.printMode : undefined;
|
|
72
|
+
};
|
|
73
|
+
if (rects && Object.keys(rects).length > 0) {
|
|
74
|
+
return childIds.map((childId, index) => {
|
|
75
|
+
const child = context.state.components[childId];
|
|
76
|
+
const raw = rects[childId];
|
|
77
|
+
if (!isRecord(raw))
|
|
78
|
+
return null;
|
|
79
|
+
const xPt = typeof raw.xPt === "number" ? raw.xPt : null;
|
|
80
|
+
const yPt = typeof raw.yPt === "number" ? raw.yPt : null;
|
|
81
|
+
const widthPt = typeof raw.widthPt === "number" && raw.widthPt > 0 ? raw.widthPt : null;
|
|
82
|
+
const heightPt = typeof raw.heightPt === "number" && raw.heightPt > 0 ? raw.heightPt : null;
|
|
83
|
+
if (xPt === null || yPt === null || widthPt === null || heightPt === null)
|
|
84
|
+
return null;
|
|
85
|
+
return (_jsx("div", { className: "a2ui-print-sized a2ui-print-rect", style: { position: "absolute", left: `${xPt}px`, top: `${yPt}px`, width: `${widthPt}px`, height: `${heightPt}px` }, "data-child-id": childId, "data-child-component": child?.component, "data-print-mode": printMode(childId), "data-declared-width": String(widthPt), "data-declared-height": String(heightPt), children: _jsx(RenderComponent, { componentId: childId, context: childContext(context, component.id, undefined, index) }) }, childId));
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
if (!heights)
|
|
89
|
+
return renderChildren(component, context);
|
|
90
|
+
return childIds.map((childId, index) => {
|
|
91
|
+
const child = context.state.components[childId];
|
|
92
|
+
const declared = heights[childId];
|
|
93
|
+
const height = typeof declared === "number" && declared > 0 ? declared : null;
|
|
94
|
+
return (_jsx("div", { className: `a2ui-print-sized ${height === null ? "a2ui-print-elastic" : ""}`.trim(), style: height === null ? undefined : { height: `${height}px` }, "data-child-id": childId, "data-child-component": child?.component, "data-print-mode": printMode(childId), "data-declared-height": height === null ? undefined : String(height), children: _jsx(RenderComponent, { componentId: childId, context: childContext(context, component.id, undefined, index) }) }, childId));
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function PrintLayoutSlot({ component, context }) {
|
|
98
|
+
const ref = useRef(null);
|
|
99
|
+
const [fitReport, setFitReport] = useState(null);
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
const node = ref.current;
|
|
102
|
+
if (!node)
|
|
103
|
+
return;
|
|
104
|
+
return observePrintSlot(node, (report) => {
|
|
105
|
+
setFitReport(report);
|
|
106
|
+
node.dispatchEvent(new CustomEvent("littlepress:slot-fit", { bubbles: true, detail: report }));
|
|
107
|
+
});
|
|
108
|
+
}, []);
|
|
109
|
+
return (_jsx("section", { ref: ref, className: "a2ui-layout-slot a2ui-print-slot", style: printSlotStyle(component), "data-slot": typeof component.slotId === "string" ? component.slotId : undefined, "data-overlay": component.overlay === true ? "true" : undefined, "data-child-layout": isRecord(component.childRects) && Object.keys(component.childRects).length > 0 ? "rects" : "stack", "data-fit-status": fitReport?.status, "data-overset": fitReport?.blocking ? "true" : undefined, title: fitReport?.blocking ? `Layout failure: ${fitReport.status}` : undefined, children: renderSizedSlotChildren(component, context) }));
|
|
110
|
+
}
|
|
111
|
+
export function renderLayoutPage(component, context) {
|
|
112
|
+
return context.layout === "print"
|
|
113
|
+
? _jsx(PrintLayoutPage, { component: component, context: context })
|
|
114
|
+
: _jsx("main", { className: "a2ui-layout-page a2ui-flow-page", children: renderChildren(component, context) });
|
|
115
|
+
}
|
|
116
|
+
export function renderLayoutGrid(component, context) {
|
|
117
|
+
return (_jsx("div", { className: context.layout === "print" ? "a2ui-layout-grid a2ui-print-grid" : "a2ui-layout-grid a2ui-flow-grid", style: context.layout === "print" ? undefined : layoutGridStyle(component), children: renderChildren(component, context) }));
|
|
118
|
+
}
|
|
119
|
+
export function renderLayoutSlot(component, context) {
|
|
120
|
+
return context.layout === "print"
|
|
121
|
+
? _jsx(PrintLayoutSlot, { component: component, context: context })
|
|
122
|
+
: _jsx("section", { className: "a2ui-layout-slot a2ui-flow-slot", style: layoutSlotStyle(component), children: renderChildren(component, context) });
|
|
123
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure style math for the three layout containers the N2 engine emits
|
|
3
|
+
* (`LayoutPage_Default` / `LayoutGrid_Default` / `LayoutSlot_Default`).
|
|
4
|
+
*
|
|
5
|
+
* The engine ships absolute print geometry in points; the web preview renders
|
|
6
|
+
* proportionally inside the trim-ratio page frame, so everything is converted
|
|
7
|
+
* to percentages of the page (margins) or expressed through CSS grid tracks
|
|
8
|
+
* (columns and gutters). Row heights are intentionally left content-driven:
|
|
9
|
+
* the preview keeps the print grid's column structure and placement exact
|
|
10
|
+
* while letting text take the vertical space it needs on screen.
|
|
11
|
+
*
|
|
12
|
+
* Zero React on purpose — this module is unit-tested with node --test like the
|
|
13
|
+
* rest of the pure half of the package.
|
|
14
|
+
*/
|
|
15
|
+
type UnknownRecord = Record<string, unknown>;
|
|
16
|
+
/** Structurally assignable to React.CSSProperties without importing React here. */
|
|
17
|
+
export type StyleMap = {
|
|
18
|
+
display?: "grid";
|
|
19
|
+
paddingLeft?: string;
|
|
20
|
+
paddingRight?: string;
|
|
21
|
+
paddingTop?: string;
|
|
22
|
+
paddingBottom?: string;
|
|
23
|
+
gridTemplateColumns?: string;
|
|
24
|
+
columnGap?: string;
|
|
25
|
+
gridColumn?: string;
|
|
26
|
+
gridRow?: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Page margins as percentages of the trim box. Single-page preview assumption:
|
|
30
|
+
* inner margin = left, outer = right (recto); verso mirroring is a paged-media
|
|
31
|
+
* concern the preview does not model.
|
|
32
|
+
*/
|
|
33
|
+
export declare function layoutPageStyle(component: UnknownRecord): StyleMap;
|
|
34
|
+
/**
|
|
35
|
+
* Column tracks exactly as the engine computed them: N equal tracks separated
|
|
36
|
+
* by the gutter, both expressed as fractions of the text-area width so the
|
|
37
|
+
* grid scales with the page frame.
|
|
38
|
+
*/
|
|
39
|
+
export declare function layoutGridStyle(component: UnknownRecord): StyleMap;
|
|
40
|
+
/** Grid placement straight from the engine's slot coordinates (1-based). */
|
|
41
|
+
export declare function layoutSlotStyle(component: UnknownRecord): StyleMap;
|
|
42
|
+
export declare const layoutContainerComponents: readonly ["LayoutPage_Default", "LayoutGrid_Default", "LayoutSlot_Default"];
|
|
43
|
+
export declare function isLayoutContainer(component: string): boolean;
|
|
44
|
+
/** Page box in pt. Falls back to trim mm when an older bundle lacks pt dims. */
|
|
45
|
+
export declare function printPageSize(component: UnknownRecord): {
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
|
+
} | null;
|
|
49
|
+
export type PrintBoxStyle = {
|
|
50
|
+
position?: "absolute";
|
|
51
|
+
left?: string;
|
|
52
|
+
top?: string;
|
|
53
|
+
width?: string;
|
|
54
|
+
height?: string;
|
|
55
|
+
};
|
|
56
|
+
/** Text-area rectangle, absolute inside the page box (recto assumption: inner = left). */
|
|
57
|
+
export declare function printTextAreaStyle(component: UnknownRecord): PrintBoxStyle;
|
|
58
|
+
/** Slot rectangle, absolute inside the text area, straight from the engine. */
|
|
59
|
+
export declare function printSlotStyle(component: UnknownRecord): PrintBoxStyle;
|
|
60
|
+
/**
|
|
61
|
+
* Type scale derived from the engine's canvas: every role size is
|
|
62
|
+
* bodySizePt x modularRatio^n (C-12), leading follows print conventions
|
|
63
|
+
* (tighter as size grows), body leading is the engine's exact ratio so the
|
|
64
|
+
* baseline grid the slots were budgeted against is the one the text sets in.
|
|
65
|
+
* Emitted as CSS custom properties consumed by the print scope stylesheet.
|
|
66
|
+
*/
|
|
67
|
+
export declare function printTypeVariables(component: UnknownRecord): Record<string, string> | null;
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure style math for the three layout containers the N2 engine emits
|
|
3
|
+
* (`LayoutPage_Default` / `LayoutGrid_Default` / `LayoutSlot_Default`).
|
|
4
|
+
*
|
|
5
|
+
* The engine ships absolute print geometry in points; the web preview renders
|
|
6
|
+
* proportionally inside the trim-ratio page frame, so everything is converted
|
|
7
|
+
* to percentages of the page (margins) or expressed through CSS grid tracks
|
|
8
|
+
* (columns and gutters). Row heights are intentionally left content-driven:
|
|
9
|
+
* the preview keeps the print grid's column structure and placement exact
|
|
10
|
+
* while letting text take the vertical space it needs on screen.
|
|
11
|
+
*
|
|
12
|
+
* Zero React on purpose — this module is unit-tested with node --test like the
|
|
13
|
+
* rest of the pure half of the package.
|
|
14
|
+
*/
|
|
15
|
+
const MM_TO_PT = 72 / 25.4;
|
|
16
|
+
function num(component, key) {
|
|
17
|
+
const value = component[key];
|
|
18
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : null;
|
|
19
|
+
}
|
|
20
|
+
function pct(part, total) {
|
|
21
|
+
if (part === null || total === null || total <= 0)
|
|
22
|
+
return undefined;
|
|
23
|
+
return `${((part / total) * 100).toFixed(3)}%`;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Page margins as percentages of the trim box. Single-page preview assumption:
|
|
27
|
+
* inner margin = left, outer = right (recto); verso mirroring is a paged-media
|
|
28
|
+
* concern the preview does not model.
|
|
29
|
+
*/
|
|
30
|
+
export function layoutPageStyle(component) {
|
|
31
|
+
const pageWidthPt = num(component, "trimWidthMm") !== null ? num(component, "trimWidthMm") * MM_TO_PT : null;
|
|
32
|
+
const pageHeightPt = num(component, "trimHeightMm") !== null ? num(component, "trimHeightMm") * MM_TO_PT : null;
|
|
33
|
+
const style = {};
|
|
34
|
+
const left = pct(num(component, "marginInnerPt"), pageWidthPt);
|
|
35
|
+
const right = pct(num(component, "marginOuterPt"), pageWidthPt);
|
|
36
|
+
const top = pct(num(component, "marginTopPt"), pageHeightPt);
|
|
37
|
+
const bottom = pct(num(component, "marginBottomPt"), pageHeightPt);
|
|
38
|
+
if (left)
|
|
39
|
+
style.paddingLeft = left;
|
|
40
|
+
if (right)
|
|
41
|
+
style.paddingRight = right;
|
|
42
|
+
if (top)
|
|
43
|
+
style.paddingTop = top;
|
|
44
|
+
if (bottom)
|
|
45
|
+
style.paddingBottom = bottom;
|
|
46
|
+
return style;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Column tracks exactly as the engine computed them: N equal tracks separated
|
|
50
|
+
* by the gutter, both expressed as fractions of the text-area width so the
|
|
51
|
+
* grid scales with the page frame.
|
|
52
|
+
*/
|
|
53
|
+
export function layoutGridStyle(component) {
|
|
54
|
+
const columns = num(component, "columns");
|
|
55
|
+
const style = { display: "grid" };
|
|
56
|
+
if (columns === null || columns < 1)
|
|
57
|
+
return style;
|
|
58
|
+
style.gridTemplateColumns = `repeat(${Math.floor(columns)}, minmax(0, 1fr))`;
|
|
59
|
+
const gutterPt = num(component, "gutterPt");
|
|
60
|
+
const trackPt = num(component, "trackWidthPt");
|
|
61
|
+
if (gutterPt !== null && trackPt !== null) {
|
|
62
|
+
const total = Math.floor(columns) * trackPt + (Math.floor(columns) - 1) * gutterPt;
|
|
63
|
+
const gap = pct(gutterPt, total);
|
|
64
|
+
if (gap)
|
|
65
|
+
style.columnGap = gap;
|
|
66
|
+
}
|
|
67
|
+
return style;
|
|
68
|
+
}
|
|
69
|
+
/** Grid placement straight from the engine's slot coordinates (1-based). */
|
|
70
|
+
export function layoutSlotStyle(component) {
|
|
71
|
+
const style = {};
|
|
72
|
+
const col = num(component, "col");
|
|
73
|
+
const colSpan = num(component, "colSpan");
|
|
74
|
+
const row = num(component, "row");
|
|
75
|
+
const rowSpan = num(component, "rowSpan");
|
|
76
|
+
if (col !== null && colSpan !== null && colSpan >= 1) {
|
|
77
|
+
style.gridColumn = `${Math.floor(col)} / span ${Math.floor(colSpan)}`;
|
|
78
|
+
}
|
|
79
|
+
if (row !== null && rowSpan !== null && rowSpan >= 1) {
|
|
80
|
+
style.gridRow = `${Math.floor(row)} / span ${Math.floor(rowSpan)}`;
|
|
81
|
+
}
|
|
82
|
+
return style;
|
|
83
|
+
}
|
|
84
|
+
export const layoutContainerComponents = [
|
|
85
|
+
"LayoutPage_Default",
|
|
86
|
+
"LayoutGrid_Default",
|
|
87
|
+
"LayoutSlot_Default",
|
|
88
|
+
];
|
|
89
|
+
export function isLayoutContainer(component) {
|
|
90
|
+
return layoutContainerComponents.includes(component);
|
|
91
|
+
}
|
|
92
|
+
/* ------------------------------------------------------------- print mode --
|
|
93
|
+
* Print-true rendering: the page is a fixed box in points (1pt = 1px before
|
|
94
|
+
* zoom), the text area sits at the engine's margins, and every slot is an
|
|
95
|
+
* absolute rectangle. The react half owns the zoom-to-fit measurement; the
|
|
96
|
+
* math below stays pure so node --test covers it. */
|
|
97
|
+
/** Page box in pt. Falls back to trim mm when an older bundle lacks pt dims. */
|
|
98
|
+
export function printPageSize(component) {
|
|
99
|
+
const width = num(component, "pageWidthPt") ?? (num(component, "trimWidthMm") !== null ? num(component, "trimWidthMm") * MM_TO_PT : null);
|
|
100
|
+
const height = num(component, "pageHeightPt") ?? (num(component, "trimHeightMm") !== null ? num(component, "trimHeightMm") * MM_TO_PT : null);
|
|
101
|
+
if (width === null || height === null || width <= 0 || height <= 0)
|
|
102
|
+
return null;
|
|
103
|
+
return { width, height };
|
|
104
|
+
}
|
|
105
|
+
/** Text-area rectangle, absolute inside the page box (recto assumption: inner = left). */
|
|
106
|
+
export function printTextAreaStyle(component) {
|
|
107
|
+
const style = { position: "absolute" };
|
|
108
|
+
const left = num(component, "marginInnerPt");
|
|
109
|
+
const top = num(component, "marginTopPt");
|
|
110
|
+
const width = num(component, "textAreaWidthPt");
|
|
111
|
+
const height = num(component, "textAreaHeightPt");
|
|
112
|
+
if (left !== null)
|
|
113
|
+
style.left = `${left}px`;
|
|
114
|
+
if (top !== null)
|
|
115
|
+
style.top = `${top}px`;
|
|
116
|
+
if (width !== null)
|
|
117
|
+
style.width = `${width}px`;
|
|
118
|
+
if (height !== null)
|
|
119
|
+
style.height = `${height}px`;
|
|
120
|
+
return style;
|
|
121
|
+
}
|
|
122
|
+
/** Slot rectangle, absolute inside the text area, straight from the engine. */
|
|
123
|
+
export function printSlotStyle(component) {
|
|
124
|
+
const style = { position: "absolute" };
|
|
125
|
+
const x = num(component, "xPt");
|
|
126
|
+
const y = num(component, "yPt");
|
|
127
|
+
const width = num(component, "widthPt");
|
|
128
|
+
const height = num(component, "heightPt");
|
|
129
|
+
if (x !== null)
|
|
130
|
+
style.left = `${x}px`;
|
|
131
|
+
if (y !== null)
|
|
132
|
+
style.top = `${y}px`;
|
|
133
|
+
if (width !== null)
|
|
134
|
+
style.width = `${width}px`;
|
|
135
|
+
if (height !== null)
|
|
136
|
+
style.height = `${height}px`;
|
|
137
|
+
return style;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Type scale derived from the engine's canvas: every role size is
|
|
141
|
+
* bodySizePt x modularRatio^n (C-12), leading follows print conventions
|
|
142
|
+
* (tighter as size grows), body leading is the engine's exact ratio so the
|
|
143
|
+
* baseline grid the slots were budgeted against is the one the text sets in.
|
|
144
|
+
* Emitted as CSS custom properties consumed by the print scope stylesheet.
|
|
145
|
+
*/
|
|
146
|
+
export function printTypeVariables(component) {
|
|
147
|
+
const body = num(component, "bodySizePt");
|
|
148
|
+
if (body === null || body <= 0)
|
|
149
|
+
return null;
|
|
150
|
+
const ratioValue = num(component, "modularRatio");
|
|
151
|
+
const ratio = ratioValue !== null && ratioValue > 1 ? ratioValue : 1.2;
|
|
152
|
+
const bodyLh = num(component, "lineHeightRatio") ?? 1.45;
|
|
153
|
+
const baseline = num(component, "baselinePt") ?? body * bodyLh;
|
|
154
|
+
const size = (power) => `${(body * ratio ** power).toFixed(2)}px`;
|
|
155
|
+
return {
|
|
156
|
+
"--pp-body": `${body}px`,
|
|
157
|
+
"--pp-body-lh": `${bodyLh}`,
|
|
158
|
+
"--pp-baseline": `${baseline.toFixed(2)}px`,
|
|
159
|
+
"--pp-display": size(4),
|
|
160
|
+
"--pp-display-lh": "1.05",
|
|
161
|
+
"--pp-title": size(2),
|
|
162
|
+
"--pp-title-lh": "1.15",
|
|
163
|
+
"--pp-heading": size(1),
|
|
164
|
+
"--pp-heading-lh": "1.25",
|
|
165
|
+
"--pp-dek": size(1),
|
|
166
|
+
"--pp-dek-lh": "1.35",
|
|
167
|
+
"--pp-caption": size(-1),
|
|
168
|
+
"--pp-caption-lh": "1.35",
|
|
169
|
+
"--pp-meta": size(-1),
|
|
170
|
+
"--pp-meta-lh": "1.3",
|
|
171
|
+
"--pp-stat": size(2),
|
|
172
|
+
"--pp-stat-lh": "1.05",
|
|
173
|
+
};
|
|
174
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Page-format (trim) presets.
|
|
3
|
+
*
|
|
4
|
+
* A2UI has no typography engine — page geometry lives in the authoring plan and
|
|
5
|
+
* in the catalog's layout containers (ADR 0004, decision 8). The trim itself
|
|
6
|
+
* travels next to the messages on `bundle.a2ui.page_format`, and the renderer
|
|
7
|
+
* turns it into a fixed-ratio frame around the surface.
|
|
8
|
+
*
|
|
9
|
+
* Moved here from the playground's `withPageFrame` so the frame ships with the
|
|
10
|
+
* renderer and the future share page gets it for free.
|
|
11
|
+
*/
|
|
12
|
+
export type PageOrientation = "portrait" | "landscape" | "square";
|
|
13
|
+
export type SpreadPolicy = "single" | "spread";
|
|
14
|
+
export type PageFormatSpec = {
|
|
15
|
+
preset: string;
|
|
16
|
+
orientation: PageOrientation;
|
|
17
|
+
aspectWidth: number;
|
|
18
|
+
aspectHeight: number;
|
|
19
|
+
spreadPolicy: SpreadPolicy;
|
|
20
|
+
/** Print pages cannot scroll; a false here makes the preview clip honestly. */
|
|
21
|
+
pageScrollable: boolean;
|
|
22
|
+
/** Whether internally-scrolling components (carousels etc.) are allowed. */
|
|
23
|
+
allowsScrollableComponents: boolean;
|
|
24
|
+
};
|
|
25
|
+
/** The six trims the compiler stamps; kept client-side so a trim switch reframes before the next compile. */
|
|
26
|
+
export declare const pageFormatPresets: Readonly<Record<string, PageFormatSpec>>;
|
|
27
|
+
export declare function resolvePageFormat(preset: string | null | undefined): PageFormatSpec | null;
|
|
28
|
+
/**
|
|
29
|
+
* Reads `bundle.a2ui.page_format`. Accepts either the full compiler object or a
|
|
30
|
+
* bare preset id, so an early service build that only sends the name still
|
|
31
|
+
* frames correctly.
|
|
32
|
+
*/
|
|
33
|
+
export declare function readPageFormatSpec(value: unknown): PageFormatSpec | null;
|
|
34
|
+
export declare function formatAspectRatio(pageFormat: PageFormatSpec): string;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Page-format (trim) presets.
|
|
3
|
+
*
|
|
4
|
+
* A2UI has no typography engine — page geometry lives in the authoring plan and
|
|
5
|
+
* in the catalog's layout containers (ADR 0004, decision 8). The trim itself
|
|
6
|
+
* travels next to the messages on `bundle.a2ui.page_format`, and the renderer
|
|
7
|
+
* turns it into a fixed-ratio frame around the surface.
|
|
8
|
+
*
|
|
9
|
+
* Moved here from the playground's `withPageFrame` so the frame ships with the
|
|
10
|
+
* renderer and the future share page gets it for free.
|
|
11
|
+
*/
|
|
12
|
+
/** The six trims the compiler stamps; kept client-side so a trim switch reframes before the next compile. */
|
|
13
|
+
export const pageFormatPresets = {
|
|
14
|
+
mag_portrait_iso: {
|
|
15
|
+
preset: "mag_portrait_iso",
|
|
16
|
+
orientation: "portrait",
|
|
17
|
+
aspectWidth: 1.0,
|
|
18
|
+
aspectHeight: 1.414,
|
|
19
|
+
spreadPolicy: "single",
|
|
20
|
+
pageScrollable: false,
|
|
21
|
+
allowsScrollableComponents: false,
|
|
22
|
+
},
|
|
23
|
+
mag_portrait_letter: {
|
|
24
|
+
preset: "mag_portrait_letter",
|
|
25
|
+
orientation: "portrait",
|
|
26
|
+
aspectWidth: 1.0,
|
|
27
|
+
aspectHeight: 1.294,
|
|
28
|
+
spreadPolicy: "single",
|
|
29
|
+
pageScrollable: false,
|
|
30
|
+
allowsScrollableComponents: false,
|
|
31
|
+
},
|
|
32
|
+
book_landscape_iso: {
|
|
33
|
+
preset: "book_landscape_iso",
|
|
34
|
+
orientation: "landscape",
|
|
35
|
+
aspectWidth: 1.414,
|
|
36
|
+
aspectHeight: 1.0,
|
|
37
|
+
spreadPolicy: "spread",
|
|
38
|
+
pageScrollable: false,
|
|
39
|
+
allowsScrollableComponents: false,
|
|
40
|
+
},
|
|
41
|
+
book_landscape_letter: {
|
|
42
|
+
preset: "book_landscape_letter",
|
|
43
|
+
orientation: "landscape",
|
|
44
|
+
aspectWidth: 1.294,
|
|
45
|
+
aspectHeight: 1.0,
|
|
46
|
+
spreadPolicy: "spread",
|
|
47
|
+
pageScrollable: false,
|
|
48
|
+
allowsScrollableComponents: false,
|
|
49
|
+
},
|
|
50
|
+
book_square: {
|
|
51
|
+
preset: "book_square",
|
|
52
|
+
orientation: "square",
|
|
53
|
+
aspectWidth: 1.0,
|
|
54
|
+
aspectHeight: 1.0,
|
|
55
|
+
spreadPolicy: "single",
|
|
56
|
+
pageScrollable: false,
|
|
57
|
+
allowsScrollableComponents: false,
|
|
58
|
+
},
|
|
59
|
+
book_square_xl: {
|
|
60
|
+
preset: "book_square_xl",
|
|
61
|
+
orientation: "square",
|
|
62
|
+
aspectWidth: 1.0,
|
|
63
|
+
aspectHeight: 1.0,
|
|
64
|
+
spreadPolicy: "single",
|
|
65
|
+
pageScrollable: false,
|
|
66
|
+
allowsScrollableComponents: false,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
export function resolvePageFormat(preset) {
|
|
70
|
+
if (!preset)
|
|
71
|
+
return null;
|
|
72
|
+
return pageFormatPresets[preset] ?? null;
|
|
73
|
+
}
|
|
74
|
+
function isRecord(value) {
|
|
75
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
76
|
+
}
|
|
77
|
+
function asPositiveNumber(value) {
|
|
78
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : null;
|
|
79
|
+
}
|
|
80
|
+
function asOrientation(value, fallback) {
|
|
81
|
+
return value === "portrait" || value === "landscape" || value === "square" ? value : fallback;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Reads `bundle.a2ui.page_format`. Accepts either the full compiler object or a
|
|
85
|
+
* bare preset id, so an early service build that only sends the name still
|
|
86
|
+
* frames correctly.
|
|
87
|
+
*/
|
|
88
|
+
export function readPageFormatSpec(value) {
|
|
89
|
+
if (typeof value === "string")
|
|
90
|
+
return resolvePageFormat(value);
|
|
91
|
+
if (!isRecord(value))
|
|
92
|
+
return null;
|
|
93
|
+
const preset = typeof value.preset === "string" ? value.preset : null;
|
|
94
|
+
const aspectWidth = asPositiveNumber(value.aspectWidth);
|
|
95
|
+
const aspectHeight = asPositiveNumber(value.aspectHeight);
|
|
96
|
+
if (aspectWidth === null || aspectHeight === null)
|
|
97
|
+
return resolvePageFormat(preset);
|
|
98
|
+
const fromPreset = resolvePageFormat(preset);
|
|
99
|
+
return {
|
|
100
|
+
preset: preset ?? "custom",
|
|
101
|
+
orientation: asOrientation(value.orientation, aspectWidth > aspectHeight ? "landscape" : "portrait"),
|
|
102
|
+
aspectWidth,
|
|
103
|
+
aspectHeight,
|
|
104
|
+
spreadPolicy: value.spreadPolicy === "spread" ? "spread" : "single",
|
|
105
|
+
pageScrollable: typeof value.pageScrollable === "boolean" ? value.pageScrollable : (fromPreset?.pageScrollable ?? true),
|
|
106
|
+
allowsScrollableComponents: typeof value.allowsScrollableComponents === "boolean"
|
|
107
|
+
? value.allowsScrollableComponents
|
|
108
|
+
: (fromPreset?.allowsScrollableComponents ?? true),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export function formatAspectRatio(pageFormat) {
|
|
112
|
+
const normalized = pageFormat.aspectWidth / pageFormat.aspectHeight;
|
|
113
|
+
return normalized >= 1
|
|
114
|
+
? `${trimZeros(normalized)}:1`
|
|
115
|
+
: `1:${trimZeros(1 / normalized)}`;
|
|
116
|
+
}
|
|
117
|
+
function trimZeros(value) {
|
|
118
|
+
return value.toFixed(3).replace(/0+$/, "").replace(/\.$/, "");
|
|
119
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export type PrintPartPolicy = "clamp" | "crop" | "protected" | "content";
|
|
2
|
+
export type PrintPartFitStatus = "fit" | "declared-clamp" | "declared-crop" | "clipped" | "protected-hidden";
|
|
3
|
+
export type PrintPartFitReport = {
|
|
4
|
+
part: string;
|
|
5
|
+
policy: PrintPartPolicy;
|
|
6
|
+
status: PrintPartFitStatus;
|
|
7
|
+
offsetTopPx: number;
|
|
8
|
+
requiredBottomPx: number;
|
|
9
|
+
clientWidth: number;
|
|
10
|
+
clientHeight: number;
|
|
11
|
+
scrollWidth: number;
|
|
12
|
+
scrollHeight: number;
|
|
13
|
+
};
|
|
14
|
+
export type PrintRect = {
|
|
15
|
+
xPt: number;
|
|
16
|
+
yPt: number;
|
|
17
|
+
widthPt: number;
|
|
18
|
+
heightPt: number;
|
|
19
|
+
};
|
|
20
|
+
export type PrintChildFitStatus = "fit" | "declared-clamp" | "declared-crop" | "clipped" | "protected-hidden";
|
|
21
|
+
export type PrintChildFitReport = {
|
|
22
|
+
componentId: string;
|
|
23
|
+
component: string | null;
|
|
24
|
+
mode: string | null;
|
|
25
|
+
allocatedHeightPt: number;
|
|
26
|
+
allocatedRectPt: PrintRect;
|
|
27
|
+
clientWidth: number;
|
|
28
|
+
clientHeight: number;
|
|
29
|
+
scrollWidth: number;
|
|
30
|
+
scrollHeight: number;
|
|
31
|
+
measuredDemandWidthPx: number;
|
|
32
|
+
measuredDemandHeightPx: number;
|
|
33
|
+
measuredDemandRatio: number;
|
|
34
|
+
status: PrintChildFitStatus;
|
|
35
|
+
parts: PrintPartFitReport[];
|
|
36
|
+
};
|
|
37
|
+
export type SlotGeometryIssue = {
|
|
38
|
+
kind: "allocation-overflow" | "child-out-of-bounds" | "child-overlap" | "slot-out-of-page";
|
|
39
|
+
detail: string;
|
|
40
|
+
componentIds: string[];
|
|
41
|
+
};
|
|
42
|
+
export type SlotFitStatus = "fit" | "declared-clamp" | "declared-crop" | "clipped" | "protected-hidden" | "geometry-failure";
|
|
43
|
+
export type SlotFitReport = {
|
|
44
|
+
slotId: string;
|
|
45
|
+
slotRectPt: PrintRect;
|
|
46
|
+
widthPt: number;
|
|
47
|
+
heightPt: number;
|
|
48
|
+
allocatedHeightPt: number;
|
|
49
|
+
gapPt: number;
|
|
50
|
+
measuredDemandRatio: number;
|
|
51
|
+
measuredDemandHeightPx: number;
|
|
52
|
+
status: SlotFitStatus;
|
|
53
|
+
blocking: boolean;
|
|
54
|
+
geometryIssues: SlotGeometryIssue[];
|
|
55
|
+
children: PrintChildFitReport[];
|
|
56
|
+
};
|
|
57
|
+
export type PrintPageFitReport = {
|
|
58
|
+
status: "fit" | "declared-clipping" | "failed";
|
|
59
|
+
blocking: boolean;
|
|
60
|
+
slotCount: number;
|
|
61
|
+
failedSlotCount: number;
|
|
62
|
+
slots: SlotFitReport[];
|
|
63
|
+
geometryIssues: SlotGeometryIssue[];
|
|
64
|
+
};
|
|
65
|
+
export type SlotAllocationInput = {
|
|
66
|
+
slotWidthPt?: number;
|
|
67
|
+
slotHeightPt: number;
|
|
68
|
+
gapPt: number;
|
|
69
|
+
children: {
|
|
70
|
+
componentId: string;
|
|
71
|
+
heightPt: number;
|
|
72
|
+
mode?: string | null;
|
|
73
|
+
rect?: PrintRect;
|
|
74
|
+
}[];
|
|
75
|
+
};
|
|
76
|
+
/** Pure allocation check; the engine and DOM tests can exercise the same rule. */
|
|
77
|
+
export declare function validateSlotAllocation(input: SlotAllocationInput): SlotGeometryIssue[];
|
|
78
|
+
export declare function measurePrintSlot(slot: HTMLElement): SlotFitReport;
|
|
79
|
+
export declare function measurePrintPage(page: HTMLElement): PrintPageFitReport;
|
|
80
|
+
/** Observe the content that can change while its fixed wrapper stays the same size. */
|
|
81
|
+
export declare function observePrintSlot(slot: HTMLElement, onReport: (report: SlotFitReport) => void): () => void;
|