uhuu-components 0.2.87 → 0.2.88

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/index.d.ts CHANGED
@@ -105,6 +105,46 @@ export interface StaticFlowMeasurement {
105
105
  unplaceableItems?: StaticFlowUnplaceableItem[];
106
106
  }
107
107
 
108
+ /**
109
+ * Diagnostic counters for one pagination pass. They never influence a
110
+ * pagination decision; pass one in to assert cost budgets in tests or to
111
+ * profile a slow document.
112
+ */
113
+ export interface StaticFlowPlanMetrics {
114
+ /** Leaf items the chunker walked, summed across every call. */
115
+ scannedItems: number;
116
+ /** Calls into the leaf chunker: one per page per track, plus retries. */
117
+ chunkerCalls: number;
118
+ /** Fresh-page retries computed, whether or not the retry was taken. */
119
+ freshPageAttempts: number;
120
+ /** Output pages produced. */
121
+ pages: number;
122
+ }
123
+
124
+ /**
125
+ * The DOM reads `Static.FlowArea` measures a laid-out Flow with. Hosts that run
126
+ * their own Flow canvas (an editor drawing the same document) must use these
127
+ * instead of re-deriving them: the planner is deterministic, so a difference in
128
+ * how height or transform scale is read here is the one thing that can still
129
+ * move a page boundary between an editor and its delivered document.
130
+ */
131
+ export interface StaticFlowMeasureApi {
132
+ /** Product of every ancestor CSS transform, so heights normalize to layout space. */
133
+ getEffectiveScale: (element: HTMLElement) => number;
134
+ /** Border-box height plus vertical margins, in layout space. */
135
+ getOuterHeight: (element: HTMLElement, scale?: number) => number;
136
+ readItemMeta: (element: HTMLElement) => StaticFlowItemMeta;
137
+ readHeaderGroupKey: (element: HTMLElement) => string | undefined;
138
+ readHeaderGroupRepeats: (itemElements: HTMLElement[]) => Record<string, boolean>;
139
+ readHeaderGroupHeights: (root: HTMLElement, scale?: number) => Record<string, number>;
140
+ /** Every measured leaf under `root`, in document order. */
141
+ readFlowItemElements: (root: HTMLElement) => HTMLElement[];
142
+ parseKeepWithNext: (value: string | undefined) => boolean | number;
143
+ serializeKeepWithNext: (value: StaticFlowItemMeta['keepWithNext']) => string | undefined;
144
+ /** FNV-1a. For opaque change-detection tokens compared only for equality. */
145
+ hashString: (value: string) => string;
146
+ }
147
+
108
148
  /** Input for `Static.planFlowChunks`, using heights measured by the consumer. */
109
149
  export interface StaticFlowPlanInput {
110
150
  heights?: number[];
@@ -115,6 +155,7 @@ export interface StaticFlowPlanInput {
115
155
  headerGroupHeights?: Record<string, number>;
116
156
  headerGroupRepeats?: Record<string, boolean>;
117
157
  onUnplaceableItem?: (item: StaticFlowUnplaceableItem) => void;
158
+ metrics?: StaticFlowPlanMetrics;
118
159
  }
119
160
 
120
161
  /** Input for `Static.planFlowColumnChunks`, using globally indexed leaf measurements. */
@@ -423,6 +464,8 @@ export const Static: {
423
464
  FlowColumns: <TItem = unknown>(props: StaticFlowColumnsProps<TItem>) => ReactElement | null;
424
465
  planFlowChunks: (input?: StaticFlowPlanInput) => StaticFlowChunk[];
425
466
  planFlowColumnChunks: (input?: StaticFlowColumnPlanInput) => StaticFlowChunk[];
467
+ createFlowPlanMetrics: () => StaticFlowPlanMetrics;
468
+ flowMeasure: StaticFlowMeasureApi;
426
469
  FlowDocument: ComponentType<StaticFlowDocumentProps>;
427
470
  markdownToFlowItems: (
428
471
  markdown?: string,
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.87",
2
+ "version": "0.2.88",
3
3
  "name": "uhuu-components",
4
4
  "main": "uhuu-components.umd.cjs",
5
5
  "module": "uhuu-components.es.js",