paged-react 0.2.6 → 0.3.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.
Files changed (87) hide show
  1. package/README.md +78 -6
  2. package/dist/components/context.d.ts +4 -0
  3. package/dist/components/context.d.ts.map +1 -0
  4. package/dist/components/context.js +3 -0
  5. package/dist/components/context.js.map +1 -0
  6. package/dist/components/document.d.ts +6 -2
  7. package/dist/components/document.d.ts.map +1 -1
  8. package/dist/components/document.js +6 -6
  9. package/dist/components/document.js.map +1 -1
  10. package/dist/components/page-number.d.ts +19 -2
  11. package/dist/components/page-number.d.ts.map +1 -1
  12. package/dist/components/page-number.js +11 -4
  13. package/dist/components/page-number.js.map +1 -1
  14. package/dist/core/avoid-break.d.ts +2 -0
  15. package/dist/core/avoid-break.d.ts.map +1 -1
  16. package/dist/core/avoid-break.js +22 -9
  17. package/dist/core/avoid-break.js.map +1 -1
  18. package/dist/core/computed-style.d.ts +2 -0
  19. package/dist/core/computed-style.d.ts.map +1 -1
  20. package/dist/core/computed-style.js +4 -0
  21. package/dist/core/computed-style.js.map +1 -1
  22. package/dist/core/ir-extract.d.ts +5 -0
  23. package/dist/core/ir-extract.d.ts.map +1 -0
  24. package/dist/core/ir-extract.js +152 -0
  25. package/dist/core/ir-extract.js.map +1 -0
  26. package/dist/core/ir-style.d.ts +9 -0
  27. package/dist/core/ir-style.d.ts.map +1 -0
  28. package/dist/core/ir-style.js +136 -0
  29. package/dist/core/ir-style.js.map +1 -0
  30. package/dist/core/ir-types.d.ts +87 -0
  31. package/dist/core/ir-types.d.ts.map +1 -0
  32. package/dist/core/ir-types.js +2 -0
  33. package/dist/core/ir-types.js.map +1 -0
  34. package/dist/core/ir.d.ts +4 -0
  35. package/dist/core/ir.d.ts.map +1 -0
  36. package/dist/core/ir.js +3 -0
  37. package/dist/core/ir.js.map +1 -0
  38. package/dist/core/line-boxes.d.ts +22 -0
  39. package/dist/core/line-boxes.d.ts.map +1 -0
  40. package/dist/core/line-boxes.js +48 -0
  41. package/dist/core/line-boxes.js.map +1 -0
  42. package/dist/core/measure-range.d.ts +7 -0
  43. package/dist/core/measure-range.d.ts.map +1 -0
  44. package/dist/core/measure-range.js +15 -0
  45. package/dist/core/measure-range.js.map +1 -0
  46. package/dist/core/page-number-format.d.ts +28 -0
  47. package/dist/core/page-number-format.d.ts.map +1 -0
  48. package/dist/core/page-number-format.js +63 -0
  49. package/dist/core/page-number-format.js.map +1 -0
  50. package/dist/core/paginate-ir.d.ts +3 -0
  51. package/dist/core/paginate-ir.d.ts.map +1 -0
  52. package/dist/core/paginate-ir.js +116 -0
  53. package/dist/core/paginate-ir.js.map +1 -0
  54. package/dist/core/paginate.d.ts.map +1 -1
  55. package/dist/core/paginate.js +670 -86
  56. package/dist/core/paginate.js.map +1 -1
  57. package/dist/core/table-window.d.ts +8 -0
  58. package/dist/core/table-window.d.ts.map +1 -0
  59. package/dist/core/table-window.js +119 -0
  60. package/dist/core/table-window.js.map +1 -0
  61. package/dist/core/text-break.d.ts +6 -4
  62. package/dist/core/text-break.d.ts.map +1 -1
  63. package/dist/core/text-break.js +24 -61
  64. package/dist/core/text-break.js.map +1 -1
  65. package/dist/core/utils.d.ts.map +1 -1
  66. package/dist/core/utils.js +2 -1
  67. package/dist/core/utils.js.map +1 -1
  68. package/dist/export-pdf.d.ts +5 -0
  69. package/dist/export-pdf.d.ts.map +1 -0
  70. package/dist/export-pdf.js +7 -0
  71. package/dist/export-pdf.js.map +1 -0
  72. package/dist/index.d.ts +3 -2
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.js +1 -1
  75. package/dist/index.js.map +1 -1
  76. package/dist/styles.css +16 -9
  77. package/dist/types.d.ts +17 -3
  78. package/dist/types.d.ts.map +1 -1
  79. package/dist/writers/pdf-color.d.ts +7 -0
  80. package/dist/writers/pdf-color.d.ts.map +1 -0
  81. package/dist/writers/pdf-color.js +80 -0
  82. package/dist/writers/pdf-color.js.map +1 -0
  83. package/dist/writers/pdf.d.ts +9 -0
  84. package/dist/writers/pdf.d.ts.map +1 -0
  85. package/dist/writers/pdf.js +193 -0
  86. package/dist/writers/pdf.js.map +1 -0
  87. package/package.json +1 -1
package/README.md CHANGED
@@ -150,12 +150,13 @@ The package CSS handles the document structure. Add this optional CSS in your ap
150
150
 
151
151
  - `Document`: the root component. Attach your print ref here.
152
152
  - `Document.Segment`: one paginated section with its own page size.
153
- - `Document.Header`: repeated at the top of every generated page in the segment.
153
+ - `Document.Header`: repeated at the top of every generated page in the segment; `pages="first" | "odd" | "even"` adds a variant for those pages.
154
154
  - `Document.Body`: the content that gets split across pages.
155
- - `Document.Footer`: repeated at the bottom of every generated page in the segment.
155
+ - `Document.Footer`: repeated at the bottom of every generated page in the segment; takes the same `pages` variants.
156
156
  - `PageBreak`: starts following content on a new page.
157
157
  - `PageNumber`: renders the current page number.
158
158
  - `TotalPages`: renders the total number of generated pages.
159
+ - `TargetPageNumber`: renders the page another element starts on, for a table of contents.
159
160
  - `Watermark`: renders a watermark inside one document segment.
160
161
  - `pageSizes`: built-in page sizes, including A-series, B4, B5, Letter, Legal, and Ledger.
161
162
 
@@ -177,7 +178,7 @@ Use `Watermark` as a direct child of `Document.Segment` for static page decorati
177
178
  </Document>
178
179
  ```
179
180
 
180
- Use `PageNumber` and `TotalPages` anywhere in document content, including headers, footers, and watermarks. They render as spans and accept normal span props.
181
+ Use `PageNumber` and `TotalPages` anywhere in document content, including headers, footers, and watermarks. They render as spans and accept normal span props. The numbers are written into them as text once pagination is done (earlier versions used CSS counters in `::before`, so styles that targeted `::before` no longer apply).
181
182
 
182
183
  ```tsx
183
184
  <Document.Footer>
@@ -185,6 +186,75 @@ Use `PageNumber` and `TotalPages` anywhere in document content, including header
185
186
  </Document.Footer>
186
187
  ```
187
188
 
189
+ Pass `format` to write a number in a CSS counter style: `decimal` (default), `decimal-leading-zero`, `lower-roman`, `upper-roman`, `lower-alpha`, `upper-alpha`, or native digits such as `bengali`, `devanagari`, `arabic-indic`, `persian`, `thai`. Numbers outside a style's range are written in decimal.
190
+
191
+ Page numbers run on across segments. Set `pageNumberStart` on a `Document.Segment` to restart them, for example after roman-numbered front matter. `TotalPages` always counts every page.
192
+
193
+ ```tsx
194
+ <Document.Segment pageSize={pageSizes.A4} pageNumberStart={1}>
195
+ <Document.Footer>
196
+ <PageNumber format="lower-roman" />
197
+ </Document.Footer>
198
+ <Document.Body>Preface</Document.Body>
199
+ </Document.Segment>
200
+ <Document.Segment pageSize={pageSizes.A4} pageNumberStart={1}>
201
+ <Document.Body>Chapter 1</Document.Body>
202
+ </Document.Segment>
203
+ ```
204
+
205
+ ## Header and Footer Placement
206
+
207
+ By default the header and footer sit inside the page margins, right above and below the body. Set `bandPlacement="margin"` on `Document.Segment` to put them in the top and bottom margins instead, from the page edge, as Chrome's print headers do. The body then starts and ends exactly at the margins; a header or footer taller than its margin grows that margin.
208
+
209
+ ```tsx
210
+ <Document.Segment pageSize={pageSizes.A4} pageMargins={{ top: "20mm", right: "15mm", bottom: "15mm", left: "15mm" }} bandPlacement="margin">
211
+ <Document.Header>Annual report</Document.Header>
212
+ <Document.Body>Report content</Document.Body>
213
+ </Document.Segment>
214
+ ```
215
+
216
+ ## First, Odd, and Even Pages
217
+
218
+ Add a `Document.Header` or `Document.Footer` with `pages="first"`, `"odd"`, or `"even"` next to the default one. A `first` variant is used on the segment's first page, then `odd`/`even` by page number, then the default. An empty variant leaves that page without a header or footer. Each page's body gets the height its own header and footer leave.
219
+
220
+ ```tsx
221
+ <Document.Segment pageSize={pageSizes.A4}>
222
+ <Document.Header>Annual report 2026</Document.Header>
223
+ <Document.Header pages="first" />
224
+ <Document.Footer pages="odd" style={{ textAlign: "right" }}>
225
+ <PageNumber />
226
+ </Document.Footer>
227
+ <Document.Footer pages="even">
228
+ <PageNumber />
229
+ </Document.Footer>
230
+ <Document.Body>Report content</Document.Body>
231
+ </Document.Segment>
232
+ ```
233
+
234
+ ## Table of Contents
235
+
236
+ `TargetPageNumber` renders the page that the element with the given `id` starts on.
237
+
238
+ ```tsx
239
+ <Document.Body>
240
+ <nav>
241
+ {chapters.map((chapter) => (
242
+ <a key={chapter.id} href={`#${chapter.id}`}>
243
+ {chapter.title} <TargetPageNumber href={`#${chapter.id}`} />
244
+ </a>
245
+ ))}
246
+ </nav>
247
+ {chapters.map((chapter) => (
248
+ <section key={chapter.id}>
249
+ <h2 id={chapter.id}>{chapter.title}</h2>
250
+ {chapter.content}
251
+ </section>
252
+ ))}
253
+ </Document.Body>
254
+ ```
255
+
256
+ Give the number a fixed width (for example `display: inline-block; width: 3ch; font-variant-numeric: tabular-nums`) so a longer number does not rewrap its line. If a number does rewrap a line and a page overflows, the document is paginated again with the numbers in place (up to three passes). A target that is not in the document keeps the placeholder `0`.
257
+
188
258
  ## Tables
189
259
 
190
260
  Direct child `<table>` elements inside `Document.Body` can be split by row when they overflow a page.
@@ -197,15 +267,17 @@ Direct child `<table>` elements inside `Document.Body` can be split by row when
197
267
  </Document.Segment>
198
268
  ```
199
269
 
200
- If a table has a `<thead>`, the first table fragment keeps that header even when `repeatTableHeader` is not set. Use `repeatTableHeader` on `Document.Segment` when continuation pages should also repeat the original `<thead>`.
270
+ If a table has a `<thead>`, only the first table fragment shows it when `repeatTableHeader` is not set. Use `repeatTableHeader` on `Document.Segment` when continuation pages should also repeat the original `<thead>`; a `<tfoot>` is then repeated at the bottom of every fragment too, like Chrome prints it.
201
271
 
202
272
  ## Page Breaks
203
273
 
204
274
  Use `PageBreak` for an explicit new page. This is the supported way to force a page break.
205
275
 
206
- `page-break-inside: avoid` is supported as a keep-together hint. Use it when a block should move to the next page instead of being split across pages.
276
+ `break-inside: avoid` / `page-break-inside: avoid` is supported as a keep-together hint. Use it when a block should move to the next page instead of being split across pages. A block taller than a page is still split, starting on a fresh page.
277
+
278
+ `break-before: avoid` and `break-after: avoid` keep blocks together (for example a heading with the paragraph after it), and `orphans` / `widows` set the minimum lines of a paragraph at the bottom and top of a page.
207
279
 
208
- `break-before`, `page-break-before`, `break-after`, and `page-break-after` are intentionally ignored. Use `PageBreak` so there is only one explicit way to force a new page.
280
+ Forcing values of `break-before`, `page-break-before`, `break-after`, and `page-break-after` (such as `page`) are intentionally ignored. Use `PageBreak` so there is only one explicit way to force a new page.
209
281
 
210
282
  ## Limitations
211
283
 
@@ -0,0 +1,4 @@
1
+ export declare const context: import("react").Context<{
2
+ pages: HTMLElement[] | null;
3
+ } | null>;
4
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/components/context.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO;WAA0B,WAAW,EAAE,GAAG,IAAI;SAAgB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { createContext } from "react";
2
+ export const context = createContext(null);
3
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/components/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAyC,IAAI,CAAC,CAAC"}
@@ -11,15 +11,19 @@ export declare const DocumentSegment: import("react").ForwardRefExoticComponent<
11
11
  pageSize: import("../types.js").PageSize;
12
12
  pageMargins?: import("../types.js").PageMargins;
13
13
  repeatTableHeader?: boolean;
14
+ pageNumberStart?: number;
15
+ bandPlacement?: "content" | "margin";
14
16
  } & import("react").RefAttributes<HTMLDivElement>>;
15
17
  export declare const DocumentHeader: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
16
- children: import("react").ReactNode;
18
+ children?: import("react").ReactNode;
19
+ pages?: import("../types.js").BandPages;
17
20
  } & import("react").RefAttributes<HTMLDivElement>>;
18
21
  export declare const DocumentBody: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
19
22
  children: import("react").ReactNode;
20
23
  } & import("react").RefAttributes<HTMLDivElement>>;
21
24
  export declare const DocumentFooter: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
22
- children: import("react").ReactNode;
25
+ children?: import("react").ReactNode;
26
+ pages?: import("../types.js").BandPages;
23
27
  } & import("react").RefAttributes<HTMLDivElement>>;
24
28
  export declare const Document: DocumentComponent;
25
29
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/components/document.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA8B,MAAM,OAAO,CAAC;AAG/D,OAAO,KAAK,EAIV,aAAa,EAEd,MAAM,aAAa,CAAC;AAErB,KAAK,iBAAiB,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC,GAAG;IACtF,OAAO,EAAE,OAAO,eAAe,CAAC;IAChC,MAAM,EAAE,OAAO,cAAc,CAAC;IAC9B,IAAI,EAAE,OAAO,YAAY,CAAC;IAC1B,MAAM,EAAE,OAAO,cAAc,CAAC;CAC/B,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;kDAoC1B,CAAC;AAEH,eAAO,MAAM,cAAc;;kDASzB,CAAC;AAEH,eAAO,MAAM,YAAY;;kDASvB,CAAC;AAEH,eAAO,MAAM,cAAc;;kDASzB,CAAC;AA8DH,eAAO,MAAM,QAAQ,EAKf,iBAAiB,CAAC"}
1
+ {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/components/document.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA8B,MAAM,OAAO,CAAC;AAG/D,OAAO,KAAK,EAIV,aAAa,EAEd,MAAM,aAAa,CAAC;AAErB,KAAK,iBAAiB,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC,GAAG;IACtF,OAAO,EAAE,OAAO,eAAe,CAAC;IAChC,MAAM,EAAE,OAAO,cAAc,CAAC;IAC9B,IAAI,EAAE,OAAO,YAAY,CAAC;IAC1B,MAAM,EAAE,OAAO,cAAc,CAAC;CAC/B,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;kDAsC1B,CAAC;AAEH,eAAO,MAAM,cAAc;;;kDASzB,CAAC;AAEH,eAAO,MAAM,YAAY;;kDASvB,CAAC;AAEH,eAAO,MAAM,cAAc;;;kDASzB,CAAC;AA8DH,eAAO,MAAM,QAAQ,EAKf,iBAAiB,CAAC"}
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef, useEffect, useMemo, useRef } from "react";
3
3
  import { paginateDocument } from "../core/paginate.js";
4
4
  import { resolvePageSize } from "../utils/page-size.js";
5
- export const DocumentSegment = forwardRef(function DocumentSegment({ children, pageSize, pageMargins, repeatTableHeader, style, ...props }, ref) {
5
+ export const DocumentSegment = forwardRef(function DocumentSegment({ children, pageSize, pageMargins, repeatTableHeader, pageNumberStart, bandPlacement, style, ...props }, ref) {
6
6
  const resolvedPageSize = resolvePageSize(pageSize);
7
7
  const segmentStyle = { ...style };
8
8
  if (pageMargins) {
@@ -15,20 +15,20 @@ export const DocumentSegment = forwardRef(function DocumentSegment({ children, p
15
15
  padding: "var(--paged-react-page-margin-top) var(--paged-react-page-margin-right) var(--paged-react-page-margin-bottom) var(--paged-react-page-margin-left)",
16
16
  });
17
17
  }
18
- return (_jsx("div", { ...props, ref: ref, "data-paged-react-repeat-table-header": String(repeatTableHeader === true), "data-paged-react-page-height": resolvedPageSize.height, "data-paged-react-page-width": resolvedPageSize.width, "data-paged-react-segment-source": "", style: {
18
+ return (_jsx("div", { ...props, ref: ref, "data-paged-react-repeat-table-header": String(repeatTableHeader === true), "data-paged-react-page-number-start": pageNumberStart, "data-paged-react-band-placement": bandPlacement, "data-paged-react-page-height": resolvedPageSize.height, "data-paged-react-page-width": resolvedPageSize.width, "data-paged-react-segment-source": "", style: {
19
19
  ...segmentStyle,
20
20
  minHeight: resolvedPageSize.height,
21
21
  width: resolvedPageSize.width,
22
22
  }, children: children }));
23
23
  });
24
- export const DocumentHeader = forwardRef(function DocumentHeader({ children, ...props }, ref) {
25
- return (_jsx("div", { ...props, ref: ref, "data-paged-react-header-source": "", children: children }));
24
+ export const DocumentHeader = forwardRef(function DocumentHeader({ children, pages, ...props }, ref) {
25
+ return (_jsx("div", { ...props, ref: ref, "data-paged-react-header-source": "", "data-paged-react-pages": pages, children: children }));
26
26
  });
27
27
  export const DocumentBody = forwardRef(function DocumentBody({ children, ...props }, ref) {
28
28
  return (_jsx("div", { ...props, ref: ref, "data-paged-react-body-source": "", children: children }));
29
29
  });
30
- export const DocumentFooter = forwardRef(function DocumentFooter({ children, ...props }, ref) {
31
- return (_jsx("div", { ...props, ref: ref, "data-paged-react-footer-source": "", children: children }));
30
+ export const DocumentFooter = forwardRef(function DocumentFooter({ children, pages, ...props }, ref) {
31
+ return (_jsx("div", { ...props, ref: ref, "data-paged-react-footer-source": "", "data-paged-react-pages": pages, children: children }));
32
32
  });
33
33
  const DocumentRoot = forwardRef(function Document({ children, afterPaginate, paginate = true, doNotHideSource = false, scale = 1, ...props }, ref) {
34
34
  const sourceRef = useRef(null);
@@ -1 +1 @@
1
- {"version":3,"file":"document.js","sourceRoot":"","sources":["../../src/components/document.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAgBxD,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAuC,SAAS,eAAe,CACtG,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW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").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
2
- export declare const TotalPages: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
1
+ import type { PageNumberFormat } from "../core/page-number-format.js";
2
+ export declare const PageNumber: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
3
+ /** CSS counter style name, e.g. `lower-roman` or `bengali`. Defaults to decimal. */
4
+ format?: PageNumberFormat;
5
+ } & import("react").RefAttributes<HTMLSpanElement>>;
6
+ /**
7
+ * The page number of the element `href` (`#id`) points to, e.g. in a table of contents. Give it
8
+ * a fixed width (`display: inline-block; width: 3ch`) so a longer number does not rewrap its line.
9
+ */
10
+ export declare const TargetPageNumber: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
11
+ /** CSS counter style name, e.g. `lower-roman` or `bengali`. Defaults to decimal. */
12
+ format?: PageNumberFormat;
13
+ } & {
14
+ href: string;
15
+ } & import("react").RefAttributes<HTMLSpanElement>>;
16
+ export declare const TotalPages: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
17
+ /** CSS counter style name, e.g. `lower-roman` or `bengali`. Defaults to decimal. */
18
+ format?: PageNumberFormat;
19
+ } & import("react").RefAttributes<HTMLSpanElement>>;
3
20
  //# sourceMappingURL=page-number.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"page-number.d.ts","sourceRoot":"","sources":["../../src/components/page-number.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,8MAItB,CAAC;AAEF,eAAO,MAAM,UAAU,8MAItB,CAAC"}
1
+ {"version":3,"file":"page-number.d.ts","sourceRoot":"","sources":["../../src/components/page-number.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAOtE,eAAO,MAAM,UAAU;IAJrB,oFAAoF;aAC3E,gBAAgB;mDAQzB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,gBAAgB;IAf3B,oFAAoF;aAC3E,gBAAgB;;UAc2D,MAAM;mDAM3F,CAAC;AAEF,eAAO,MAAM,UAAU;IAvBrB,oFAAoF;aAC3E,gBAAgB;mDA2BzB,CAAC"}
@@ -1,9 +1,16 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
- export const PageNumber = forwardRef(function PageNumber(props, ref) {
4
- return _jsx("span", { ...props, ref: ref, "data-paged-react-page-number": "" });
3
+ export const PageNumber = forwardRef(function PageNumber({ format, ...props }, ref) {
4
+ return _jsx("span", { ...props, ref: ref, "data-paged-react-page-number": "", "data-paged-react-format": format });
5
5
  });
6
- export const TotalPages = forwardRef(function TotalPages(props, ref) {
7
- return _jsx("span", { ...props, ref: ref, "data-paged-react-total-pages": "" });
6
+ /**
7
+ * The page number of the element `href` (`#id`) points to, e.g. in a table of contents. Give it
8
+ * a fixed width (`display: inline-block; width: 3ch`) so a longer number does not rewrap its line.
9
+ */
10
+ export const TargetPageNumber = forwardRef(function TargetPageNumber({ href, format, ...props }, ref) {
11
+ return (_jsx("span", { ...props, ref: ref, "data-paged-react-target-page": href, "data-paged-react-format": format }));
12
+ });
13
+ export const TotalPages = forwardRef(function TotalPages({ format, ...props }, ref) {
14
+ return _jsx("span", { ...props, ref: ref, "data-paged-react-total-pages": "", "data-paged-react-format": format });
8
15
  });
9
16
  //# sourceMappingURL=page-number.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"page-number.js","sourceRoot":"","sources":["../../src/components/page-number.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAGnC,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAClC,SAAS,UAAU,CAAC,KAAK,EAAE,GAAG;IAC5B,OAAO,kBAAU,KAAK,EAAE,GAAG,EAAE,GAAG,kCAA+B,EAAE,GAAG,CAAC;AACvE,CAAC,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAClC,SAAS,UAAU,CAAC,KAAK,EAAE,GAAG;IAC5B,OAAO,kBAAU,KAAK,EAAE,GAAG,EAAE,GAAG,kCAA+B,EAAE,GAAG,CAAC;AACvE,CAAC,CACF,CAAC"}
1
+ {"version":3,"file":"page-number.js","sourceRoot":"","sources":["../../src/components/page-number.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AASnC,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAmC,SAAS,UAAU,CACxF,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EACpB,GAAG;IAEH,OAAO,kBAAU,KAAK,EAAE,GAAG,EAAE,GAAG,kCAA+B,EAAE,6BAA0B,MAAM,GAAI,CAAC;AACxG,CAAC,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CACxC,SAAS,gBAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG;IACvD,OAAO,CACL,kBAAU,KAAK,EAAE,GAAG,EAAE,GAAG,kCAAgC,IAAI,6BAA2B,MAAM,GAAI,CACnG,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAmC,SAAS,UAAU,CACxF,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EACpB,GAAG;IAEH,OAAO,kBAAU,KAAK,EAAE,GAAG,EAAE,GAAG,kCAA+B,EAAE,6BAA0B,MAAM,GAAI,CAAC;AACxG,CAAC,CAAC,CAAC"}
@@ -1,2 +1,4 @@
1
+ /** Replaced content, form controls and non-HTML elements (SVG): they cannot be split at all. */
2
+ export declare function isMonolithic(element: Element): boolean;
1
3
  export declare function canBreakElement(element: Element): boolean;
2
4
  //# sourceMappingURL=avoid-break.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"avoid-break.d.ts","sourceRoot":"","sources":["../../src/core/avoid-break.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CA+BzD"}
1
+ {"version":3,"file":"avoid-break.d.ts","sourceRoot":"","sources":["../../src/core/avoid-break.ts"],"names":[],"mappings":"AAcA,gGAAgG;AAChG,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAOtD;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAgBzD"}
@@ -1,16 +1,29 @@
1
- export function canBreakElement(element) {
1
+ const MONOLITHIC_TAGS = [
2
+ "SVG",
3
+ "IMG",
4
+ "CANVAS",
5
+ "VIDEO",
6
+ "IFRAME",
7
+ "OBJECT",
8
+ "EMBED",
9
+ "INPUT",
10
+ "TEXTAREA",
11
+ "SELECT",
12
+ "BUTTON",
13
+ ];
14
+ /** Replaced content, form controls and non-HTML elements (SVG): they cannot be split at all. */
15
+ export function isMonolithic(element) {
2
16
  const view = element.ownerDocument.defaultView;
3
- if (!view) {
4
- return false;
5
- }
6
- if (!(element instanceof view.HTMLElement)) {
7
- return false;
17
+ if (!view || !(element instanceof view.HTMLElement)) {
18
+ return true;
8
19
  }
9
- const tagName = element.tagName.toUpperCase();
10
- if (["SVG", "IMG", "CANVAS", "VIDEO", "IFRAME", "OBJECT", "EMBED", "INPUT", "TEXTAREA", "SELECT", "BUTTON"].includes(tagName)) {
20
+ return MONOLITHIC_TAGS.includes(element.tagName.toUpperCase());
21
+ }
22
+ export function canBreakElement(element) {
23
+ if (isMonolithic(element)) {
11
24
  return false;
12
25
  }
13
- const computedStyle = view.getComputedStyle(element);
26
+ const computedStyle = element.ownerDocument.defaultView.getComputedStyle(element);
14
27
  if (["avoid", "avoid-page", "avoid-column"].includes(computedStyle.breakInside)) {
15
28
  return false;
16
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"avoid-break.js","sourceRoot":"","sources":["../../src/core/avoid-break.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC9C,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC;IAC/C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,CAAC,OAAO,YAAY,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;QAC3C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;IAE9C,IACE,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAC9G,OAAO,CACR,EACD,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAErD,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;QAChF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,aAAa,CAAC,eAAe,KAAK,OAAO,EAAE,CAAC;QAC9C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
1
+ {"version":3,"file":"avoid-break.js","sourceRoot":"","sources":["../../src/core/avoid-break.ts"],"names":[],"mappings":"AAAA,MAAM,eAAe,GAAG;IACtB,KAAK;IACL,KAAK;IACL,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,OAAO;IACP,UAAU;IACV,QAAQ;IACR,QAAQ;CACT,CAAC;AAEF,gGAAgG;AAChG,MAAM,UAAU,YAAY,CAAC,OAAgB;IAC3C,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC;IAC/C,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,YAAY,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;QACpD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC9C,IAAI,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,aAAa,GAAI,OAAO,CAAC,aAAa,CAAC,WAAsB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAE9F,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;QAChF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,aAAa,CAAC,eAAe,KAAK,OAAO,EAAE,CAAC;QAC9C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -19,5 +19,7 @@ export declare function createComputedStyleCache(): {
19
19
  paddingBottom: number;
20
20
  paddingTop: number;
21
21
  };
22
+ /** Forget an element's style after pagination changed it. */
23
+ invalidate(element: Element): void;
22
24
  };
23
25
  //# sourceMappingURL=computed-style.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"computed-style.d.ts","sourceRoot":"","sources":["../../src/core/computed-style.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,wBAAgB,wBAAwB;iBAIvB,OAAO;;;;;;;;;;EAavB"}
1
+ {"version":3,"file":"computed-style.d.ts","sourceRoot":"","sources":["../../src/core/computed-style.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,wBAAgB,wBAAwB;iBAIvB,OAAO;;;;;;;;;;IAYpB,6DAA6D;wBACzC,OAAO;EAI9B"}
@@ -11,6 +11,10 @@ export function createComputedStyleCache() {
11
11
  styles.set(element, boxStyle);
12
12
  return boxStyle;
13
13
  },
14
+ /** Forget an element's style after pagination changed it. */
15
+ invalidate(element) {
16
+ styles.delete(element);
17
+ },
14
18
  };
15
19
  }
16
20
  //# sourceMappingURL=computed-style.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"computed-style.js","sourceRoot":"","sources":["../../src/core/computed-style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAazC,MAAM,UAAU,wBAAwB;IACtC,MAAM,MAAM,GAAG,IAAI,OAAO,EAAqB,CAAC;IAEhD,OAAO;QACL,GAAG,CAAC,OAAgB;YAClB,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAExC,IAAI,WAAW,EAAE,CAAC;gBAChB,OAAO,WAAW,CAAC;YACrB,CAAC;YAED,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;YAEtC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YAC9B,OAAO,QAAQ,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"computed-style.js","sourceRoot":"","sources":["../../src/core/computed-style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAazC,MAAM,UAAU,wBAAwB;IACtC,MAAM,MAAM,GAAG,IAAI,OAAO,EAAqB,CAAC;IAEhD,OAAO;QACL,GAAG,CAAC,OAAgB;YAClB,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAExC,IAAI,WAAW,EAAE,CAAC;gBAChB,OAAO,WAAW,CAAC;YACrB,CAAC;YAED,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;YAEtC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YAC9B,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,6DAA6D;QAC7D,UAAU,CAAC,OAAgB;YACzB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { type PaginatedDocumentIR } from "./ir-types.js";
2
+ export declare function markSourceIds(root: HTMLElement): void;
3
+ export declare function clearSourceIds(pages: HTMLElement[]): void;
4
+ export declare function buildPaginatedDocumentIR(pages: HTMLElement[]): PaginatedDocumentIR;
5
+ //# sourceMappingURL=ir-extract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ir-extract.d.ts","sourceRoot":"","sources":["../../src/core/ir-extract.ts"],"names":[],"mappings":"AAUA,OAAO,EAIL,KAAK,mBAAmB,EAGzB,MAAM,eAAe,CAAC;AAEvB,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAMrD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,IAAI,CAOzD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,mBAAmB,CAkJlF"}
@@ -0,0 +1,152 @@
1
+ import { textBreaker } from "./text-break.js";
2
+ import { getImageSource, hasVisibleBox, readBreakDirectives, readDimension, readNumberAttribute, readPaintStyle, toPageRect, } from "./ir-style.js";
3
+ import { SOURCE_ID_ATTRIBUTE, } from "./ir-types.js";
4
+ export function markSourceIds(root) {
5
+ const elements = [root, ...Array.from(root.querySelectorAll("*"))];
6
+ for (const [index, element] of elements.entries()) {
7
+ element.setAttribute(SOURCE_ID_ATTRIBUTE, `source-${index}`);
8
+ }
9
+ }
10
+ export function clearSourceIds(pages) {
11
+ for (const page of pages) {
12
+ page.removeAttribute(SOURCE_ID_ATTRIBUTE);
13
+ for (const element of page.querySelectorAll(`[${SOURCE_ID_ATTRIBUTE}]`)) {
14
+ element.removeAttribute(SOURCE_ID_ATTRIBUTE);
15
+ }
16
+ }
17
+ }
18
+ export function buildPaginatedDocumentIR(pages) {
19
+ const sourceFragments = new Map();
20
+ const pageIR = [];
21
+ for (const [pageIndex, page] of pages.entries()) {
22
+ const pageRect = page.getBoundingClientRect();
23
+ const fragments = [];
24
+ const paint = [];
25
+ let fragmentIndex = 0;
26
+ collectFragment(page, "segment", null);
27
+ const segmentIndex = readNumberAttribute(page, "data-paged-react-segment-index");
28
+ const segmentPageIndex = readNumberAttribute(page, "data-paged-react-body-segment-index");
29
+ const width = readDimension(pageRect.width, page.style.width);
30
+ const height = readDimension(pageRect.height, page.style.height);
31
+ pageIR.push({
32
+ index: pageIndex,
33
+ segmentIndex,
34
+ segmentPageIndex,
35
+ width,
36
+ height,
37
+ fragments,
38
+ paint,
39
+ });
40
+ function collectFragment(element, kind, parentId) {
41
+ const id = `page-${pageIndex}-fragment-${fragmentIndex}`;
42
+ fragmentIndex += 1;
43
+ const sourceId = getSourceId(element, id);
44
+ const fragment = {
45
+ id,
46
+ sourceId,
47
+ kind,
48
+ parentId,
49
+ childIds: [],
50
+ rect: toPageRect(element.getBoundingClientRect(), pageRect),
51
+ breakDirectives: readBreakDirectives(element),
52
+ repeated: kind === "header" || kind === "footer",
53
+ continuationIndex: 0,
54
+ continuationCount: 1,
55
+ };
56
+ fragments.push(fragment);
57
+ let sameSource = sourceFragments.get(sourceId);
58
+ if (sameSource === undefined) {
59
+ sameSource = [];
60
+ sourceFragments.set(sourceId, sameSource);
61
+ }
62
+ sameSource.push(fragment);
63
+ appendElementPaint(element, id, sourceId, pageRect);
64
+ for (const child of Array.from(element.children)) {
65
+ const childKind = kind === "segment" ? getPageChildKind(child) : "element";
66
+ if (childKind === null) {
67
+ continue;
68
+ }
69
+ const childId = collectFragment(child, childKind, id);
70
+ fragment.childIds.push(childId);
71
+ }
72
+ return id;
73
+ }
74
+ function appendElementPaint(element, fragmentId, sourceId, rootRect) {
75
+ const style = readPaintStyle(element);
76
+ const rect = toPageRect(element.getBoundingClientRect(), rootRect);
77
+ if (hasVisibleBox(element, style)) {
78
+ paint.push({ type: "box", sourceId, fragmentId, rect, style, zIndex: paint.length });
79
+ }
80
+ if (element.tagName.toUpperCase() === "IMG") {
81
+ const source = getImageSource(element);
82
+ if (source !== null) {
83
+ paint.push({ type: "image", sourceId, fragmentId, rect, source, style, zIndex: paint.length });
84
+ }
85
+ }
86
+ for (const node of Array.from(element.childNodes)) {
87
+ if (node.nodeType !== 3) {
88
+ continue;
89
+ }
90
+ appendTextPaint(node, fragmentId, sourceId, style, rootRect);
91
+ }
92
+ }
93
+ function appendTextPaint(node, fragmentId, sourceId, style, rootRect) {
94
+ const textNode = node;
95
+ if (textNode.textContent === null || textNode.textContent.length === 0) {
96
+ return;
97
+ }
98
+ const range = page.ownerDocument.createRange();
99
+ range.selectNode(textNode);
100
+ const rangeWithRects = range;
101
+ if (typeof rangeWithRects.getClientRects !== "function") {
102
+ return;
103
+ }
104
+ const rects = Array.from(rangeWithRects.getClientRects());
105
+ if (rects.length === 0) {
106
+ return;
107
+ }
108
+ const lines = textBreaker(textNode, rects);
109
+ for (const line of lines) {
110
+ paint.push({
111
+ type: "text",
112
+ sourceId,
113
+ fragmentId,
114
+ rect: toPageRect(line.rect, rootRect),
115
+ text: line.text,
116
+ sourceStart: line.start,
117
+ sourceEnd: line.end,
118
+ style,
119
+ zIndex: paint.length,
120
+ });
121
+ }
122
+ }
123
+ }
124
+ for (const fragments of sourceFragments.values()) {
125
+ const continuationCount = fragments.length;
126
+ for (const [continuationIndex, fragment] of fragments.entries()) {
127
+ fragment.continuationIndex = continuationIndex;
128
+ fragment.continuationCount = continuationCount;
129
+ }
130
+ }
131
+ return { pages: pageIR };
132
+ }
133
+ function getPageChildKind(element) {
134
+ if (element.hasAttribute("data-paged-react-page-header")) {
135
+ return "header";
136
+ }
137
+ if (element.hasAttribute("data-paged-react-page-body")) {
138
+ return "body";
139
+ }
140
+ if (element.hasAttribute("data-paged-react-page-footer")) {
141
+ return "footer";
142
+ }
143
+ return null;
144
+ }
145
+ function getSourceId(element, generatedId) {
146
+ const sourceId = element.getAttribute(SOURCE_ID_ATTRIBUTE);
147
+ if (sourceId === null) {
148
+ return generatedId;
149
+ }
150
+ return sourceId;
151
+ }
152
+ //# sourceMappingURL=ir-extract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ir-extract.js","sourceRoot":"","sources":["../../src/core/ir-extract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACL,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,aAA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,SAAS,WAAW,CAAC,OAAgB,EAAE,WAAmB;IACxD,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;IAC3D,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { BreakDirectives, IRRect, PaintStyle } from "./ir-types.js";
2
+ export declare function readBreakDirectives(element: Element): BreakDirectives;
3
+ export declare function readPaintStyle(element: Element): PaintStyle;
4
+ export declare function hasVisibleBox(element: Element, style: PaintStyle): boolean;
5
+ export declare function getImageSource(element: Element): string | null;
6
+ export declare function toPageRect(rect: DOMRect, pageRect: DOMRect): IRRect;
7
+ export declare function readNumberAttribute(element: Element, name: string): number;
8
+ export declare function readDimension(value: number, styleValue: string): number;
9
+ //# sourceMappingURL=ir-style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ir-style.d.ts","sourceRoot":"","sources":["../../src/core/ir-style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EACf,MAAM,EACN,UAAU,EACX,MAAM,eAAe,CAAC;AAEvB,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe,CAYrE;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,CA2C3D;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CA4B1E;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAY9D;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,CAOnE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAW1E;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAUvE"}