@rentnerkev/pdf 1.0.0 → 1.0.2

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 (195) hide show
  1. package/README.md +23 -7
  2. package/THIRD_PARTY_NOTICES.md +1 -1
  3. package/dist/ai.d.ts +53 -0
  4. package/dist/ai.d.ts.map +1 -0
  5. package/dist/ai.js +144 -0
  6. package/dist/ai.js.map +1 -0
  7. package/dist/components/Types/props.d.ts +2 -2
  8. package/dist/components/components.d.ts +5 -5
  9. package/dist/components/components.d.ts.map +1 -1
  10. package/dist/components/components.js +16 -16
  11. package/dist/components/components.js.map +1 -1
  12. package/dist/components/host.d.ts +2 -2
  13. package/dist/engine/Types/backend.d.ts +5 -5
  14. package/dist/engine/Types/engine.d.ts +8 -8
  15. package/dist/engine/Types/errors.d.ts +2 -2
  16. package/dist/engine/Types/render-options.d.ts +1 -1
  17. package/dist/engine/Types/render-result.d.ts +1 -1
  18. package/dist/engine/abort.d.ts +2 -2
  19. package/dist/engine/abort.d.ts.map +1 -1
  20. package/dist/engine/abort.js +2 -2
  21. package/dist/engine/abort.js.map +1 -1
  22. package/dist/engine/assets.d.ts +4 -3
  23. package/dist/engine/assets.d.ts.map +1 -1
  24. package/dist/engine/assets.js +19 -11
  25. package/dist/engine/assets.js.map +1 -1
  26. package/dist/engine/backend.d.ts +5 -5
  27. package/dist/engine/backend.d.ts.map +1 -1
  28. package/dist/engine/backend.js +12 -9
  29. package/dist/engine/backend.js.map +1 -1
  30. package/dist/engine/backends/native.d.ts +2 -2
  31. package/dist/engine/backends/wasm.d.ts +2 -2
  32. package/dist/engine/backends/wasm.d.ts.map +1 -1
  33. package/dist/engine/backends/wasm.js +12 -4
  34. package/dist/engine/backends/wasm.js.map +1 -1
  35. package/dist/engine/channel.d.ts +5 -8
  36. package/dist/engine/channel.d.ts.map +1 -1
  37. package/dist/engine/channel.js +71 -43
  38. package/dist/engine/channel.js.map +1 -1
  39. package/dist/engine/create-engine.d.ts +1 -1
  40. package/dist/engine/create-engine.d.ts.map +1 -1
  41. package/dist/engine/create-engine.js +11 -5
  42. package/dist/engine/create-engine.js.map +1 -1
  43. package/dist/engine/default-fonts.d.ts.map +1 -1
  44. package/dist/engine/default-fonts.js +24 -17
  45. package/dist/engine/default-fonts.js.map +1 -1
  46. package/dist/engine/encode.d.ts +5 -4
  47. package/dist/engine/encode.d.ts.map +1 -1
  48. package/dist/engine/encode.js +15 -10
  49. package/dist/engine/encode.js.map +1 -1
  50. package/dist/engine/errors.d.ts +3 -3
  51. package/dist/engine/fonts.d.ts +1 -1
  52. package/dist/engine/markup.d.ts +3 -3
  53. package/dist/engine/options.d.ts +2 -2
  54. package/dist/engine/prepare.d.ts +4 -4
  55. package/dist/engine/render-many.d.ts +3 -3
  56. package/dist/engine/render-result.d.ts +9 -3
  57. package/dist/engine/render-result.d.ts.map +1 -1
  58. package/dist/engine/render-result.js +8 -1
  59. package/dist/engine/render-result.js.map +1 -1
  60. package/dist/engine/render-stream.d.ts +1 -1
  61. package/dist/engine/render.d.ts +3 -3
  62. package/dist/index.d.ts +24 -24
  63. package/dist/ir/Types/input.d.ts +1 -1
  64. package/dist/ir/factories.d.ts +3 -3
  65. package/dist/ir/factories.d.ts.map +1 -1
  66. package/dist/ir/factories.js +8 -3
  67. package/dist/ir/factories.js.map +1 -1
  68. package/dist/ir/page-variants.d.ts +3 -0
  69. package/dist/ir/page-variants.d.ts.map +1 -0
  70. package/dist/ir/page-variants.js +3 -0
  71. package/dist/ir/page-variants.js.map +1 -0
  72. package/dist/jsx/Types/context.d.ts +1 -1
  73. package/dist/jsx/Types/evaluate.d.ts +4 -4
  74. package/dist/jsx/Types/jsx.d.ts +1 -1
  75. package/dist/jsx/context.d.ts +1 -1
  76. package/dist/jsx/element.d.ts +1 -1
  77. package/dist/jsx/evaluate.d.ts +3 -3
  78. package/dist/jsx/evaluate.d.ts.map +1 -1
  79. package/dist/jsx/evaluate.js +20 -52
  80. package/dist/jsx/evaluate.js.map +1 -1
  81. package/dist/jsx/source.d.ts +1 -1
  82. package/dist/jsx-dev-runtime.d.ts +3 -3
  83. package/dist/jsx-runtime.d.ts +3 -3
  84. package/dist/native/loader.d.ts.map +1 -1
  85. package/dist/native/loader.js +33 -27
  86. package/dist/native/loader.js.map +1 -1
  87. package/dist/native/rentnerpdf.linux-arm64-gnu.node +0 -0
  88. package/dist/native/rentnerpdf.linux-arm64-musl.node +0 -0
  89. package/dist/native/rentnerpdf.linux-x64-gnu.node +0 -0
  90. package/dist/native/rentnerpdf.linux-x64-musl.node +0 -0
  91. package/dist/native/rentnerpdf.win32-arm64-msvc.node +0 -0
  92. package/dist/native/rentnerpdf.win32-x64-msvc.node +0 -0
  93. package/dist/node.d.ts +2 -2
  94. package/dist/react/Types/preview.d.ts +16 -11
  95. package/dist/react/Types/preview.d.ts.map +1 -1
  96. package/dist/react/Types/preview.js.map +1 -1
  97. package/dist/react/Types/render.d.ts +1 -1
  98. package/dist/react/components.d.ts +4 -4
  99. package/dist/react/components.d.ts.map +1 -1
  100. package/dist/react/components.js +23 -23
  101. package/dist/react/components.js.map +1 -1
  102. package/dist/react/pdf-preview.d.ts +3 -2
  103. package/dist/react/pdf-preview.d.ts.map +1 -1
  104. package/dist/react/pdf-preview.js +2 -1
  105. package/dist/react/pdf-preview.js.map +1 -1
  106. package/dist/react/pdf-render.d.ts +4 -4
  107. package/dist/react/pdf-render.d.ts.map +1 -1
  108. package/dist/react/pdf-render.js +20 -12
  109. package/dist/react/pdf-render.js.map +1 -1
  110. package/dist/react/registry.d.ts +3 -3
  111. package/dist/react/registry.d.ts.map +1 -1
  112. package/dist/react/registry.js +6 -3
  113. package/dist/react/registry.js.map +1 -1
  114. package/dist/react/render.d.ts +4 -4
  115. package/dist/react/render.d.ts.map +1 -1
  116. package/dist/react/render.js +36 -54
  117. package/dist/react/render.js.map +1 -1
  118. package/dist/react/same-document.d.ts +2 -1
  119. package/dist/react/same-document.d.ts.map +1 -1
  120. package/dist/react/same-document.js +7 -1
  121. package/dist/react/same-document.js.map +1 -1
  122. package/dist/react/static.d.ts +5 -0
  123. package/dist/react/static.d.ts.map +1 -1
  124. package/dist/react/static.js +20 -16
  125. package/dist/react/static.js.map +1 -1
  126. package/dist/react/use-pdf.d.ts +5 -5
  127. package/dist/react/use-pdf.d.ts.map +1 -1
  128. package/dist/react/use-pdf.js +81 -14
  129. package/dist/react/use-pdf.js.map +1 -1
  130. package/dist/react.d.ts +8 -8
  131. package/dist/tailwind-merge.d.ts +2 -2
  132. package/dist/theme/Types/theme.d.ts +8 -1
  133. package/dist/theme/Types/theme.d.ts.map +1 -1
  134. package/dist/theme/Types/theme.js.map +1 -1
  135. package/dist/theme/css-imports.d.ts +1 -1
  136. package/dist/theme/normalize.d.ts +2 -2
  137. package/dist/theme/package-imports.d.ts +1 -8
  138. package/dist/theme/package-imports.d.ts.map +1 -1
  139. package/dist/theme/package-imports.js +4 -11
  140. package/dist/theme/package-imports.js.map +1 -1
  141. package/dist/theme/paths.d.ts +6 -0
  142. package/dist/theme/paths.d.ts.map +1 -0
  143. package/dist/theme/paths.js +13 -0
  144. package/dist/theme/paths.js.map +1 -0
  145. package/dist/theme/theme-from-css-file.d.ts +1 -3
  146. package/dist/theme/theme-from-css-file.d.ts.map +1 -1
  147. package/dist/theme/theme-from-css-file.js +16 -21
  148. package/dist/theme/theme-from-css-file.js.map +1 -1
  149. package/dist/theme/theme-from-css.d.ts +1 -1
  150. package/dist/theme/warnings.d.ts +1 -4
  151. package/dist/theme/warnings.d.ts.map +1 -1
  152. package/dist/theme/warnings.js +1 -1
  153. package/dist/theme/warnings.js.map +1 -1
  154. package/dist/vite/plugin.d.ts +3 -6
  155. package/dist/vite/plugin.d.ts.map +1 -1
  156. package/dist/vite/plugin.js +17 -7
  157. package/dist/vite/plugin.js.map +1 -1
  158. package/dist/vite.d.ts +2 -2
  159. package/dist/wasm/binding.generated.d.ts +19 -14
  160. package/dist/wasm/loader.d.ts.map +1 -1
  161. package/dist/wasm/loader.js +11 -3
  162. package/dist/wasm/loader.js.map +1 -1
  163. package/dist/wasm/node-path.d.ts +3 -0
  164. package/dist/wasm/node-path.d.ts.map +1 -0
  165. package/dist/wasm/node-path.js +4 -0
  166. package/dist/wasm/node-path.js.map +1 -0
  167. package/dist/wasm/pkg/rentnerpdf_wasm.d.ts +19 -14
  168. package/dist/wasm/pkg/rentnerpdf_wasm.js +39 -75
  169. package/dist/wasm/pkg/rentnerpdf_wasm_bg.wasm +0 -0
  170. package/dist/wasm/pkg/rentnerpdf_wasm_bg.wasm.d.ts +8 -7
  171. package/dist/worker/Types/connection.d.ts +1 -1
  172. package/dist/worker/Types/protocol.d.ts +2 -2
  173. package/dist/worker/Types/worker-engine.d.ts +3 -3
  174. package/dist/worker/client.d.ts +1 -1
  175. package/dist/worker/client.d.ts.map +1 -1
  176. package/dist/worker/client.js +10 -10
  177. package/dist/worker/client.js.map +1 -1
  178. package/dist/worker/connection.d.ts +2 -2
  179. package/dist/worker/protocol.d.ts +2 -2
  180. package/dist/worker/protocol.js.map +1 -1
  181. package/dist/worker/serve.d.ts +3 -5
  182. package/dist/worker/serve.d.ts.map +1 -1
  183. package/dist/worker/serve.js +1 -1
  184. package/dist/worker/serve.js.map +1 -1
  185. package/dist/worker.d.ts +3 -3
  186. package/docs/usage.md +1606 -0
  187. package/package.json +9 -1
  188. package/dist/engine/pdf-bytes.d.ts +0 -8
  189. package/dist/engine/pdf-bytes.d.ts.map +0 -1
  190. package/dist/engine/pdf-bytes.js +0 -9
  191. package/dist/engine/pdf-bytes.js.map +0 -1
  192. package/dist/theme/Types/warnings.d.ts +0 -9
  193. package/dist/theme/Types/warnings.d.ts.map +0 -1
  194. package/dist/theme/Types/warnings.js +0 -2
  195. package/dist/theme/Types/warnings.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,26 +1,26 @@
1
- export { Anchor, Cell, Document, Image, Keep, Link, Marker, Page, PageBreak, PageNumber, Svg, Row, Table, Text, TotalPages, View, } from './components/components.ts';
2
- export type { AnchorAttributes, AnchorProps, AttachmentAttributes, BookmarkInput, BoxAttributes, CellAttributes, CellProps, CellRole, DataTableAttributes, DataTableProps, DocumentAttributes, DocumentProps, HeadingRole, ImageAttributes, ImageProps, ImageRole, KeepAttributes, KeepProps, LinkAttributes, LinkProps, MarkerAssignment, MarkerProps, NavigationAttributes, PageAttributes, PageBreakProps, PageNumberProps, PageProps, PageRegionProps, PageVariantProps, SvgAttributes, SvgProps, RowAttributes, RowProps, NumberTableColumn, TableAttributes, TableBaseAttributes, TableCellValue, TableColumn, TableColumnBase, TableColumnKey, TableColumnLayout, TableProps, TableRole, TextAttributes, TextTableColumn, TextMarkerAssignment, TextProps, TextRole, TextValue, TotalPagesProps, ViewAttributes, ViewProps, ViewRole, } from './components/Types/props.ts';
3
- export { createEngine } from './engine/create-engine.ts';
4
- export { RentnerPdfError } from './engine/errors.ts';
5
- export { render } from './engine/render.ts';
6
- export type { BackendChoice, BackendName } from './engine/Types/backend.ts';
7
- export type { CacheOptions, Engine, EngineOptions, FontSource, RenderInput, } from './engine/Types/engine.ts';
8
- export type { Limits, LimitsInput } from './engine/Types/limits.ts';
9
- export type { BatchFailed, BatchOptions, BatchRendered, BatchResult, EngineStats, RenderOptions, } from './engine/Types/render-options.ts';
10
- export type { RentnerPdfErrorCode, RentnerPdfErrorOptions, } from './engine/Types/errors.ts';
11
- export type { PdfBytes, RenderResult, RenderWarning, RentnerPdfWarningCode, WrapDiagnostic, WrapReason, } from './engine/Types/render-result.ts';
12
- export { anchor, cell, document, image, keep, link, marker, page, pageBreak, pageNumber, svg, row, table, text, type TextInput, totalPages, view, } from './ir/factories.ts';
1
+ export { Anchor, Cell, Document, Image, Keep, Link, Marker, Page, PageBreak, PageNumber, Svg, Row, Table, Text, TotalPages, View, } from './components/components.js';
2
+ export type { AnchorAttributes, AnchorProps, AttachmentAttributes, BookmarkInput, BoxAttributes, CellAttributes, CellProps, CellRole, DataTableAttributes, DataTableProps, DocumentAttributes, DocumentProps, HeadingRole, ImageAttributes, ImageProps, ImageRole, KeepAttributes, KeepProps, LinkAttributes, LinkProps, MarkerAssignment, MarkerProps, NavigationAttributes, PageAttributes, PageBreakProps, PageNumberProps, PageProps, PageRegionProps, PageVariantProps, SvgAttributes, SvgProps, RowAttributes, RowProps, NumberTableColumn, TableAttributes, TableBaseAttributes, TableCellValue, TableColumn, TableColumnBase, TableColumnKey, TableColumnLayout, TableProps, TableRole, TextAttributes, TextTableColumn, TextMarkerAssignment, TextProps, TextRole, TextValue, TotalPagesProps, ViewAttributes, ViewProps, ViewRole, } from './components/Types/props.js';
3
+ export { createEngine } from './engine/create-engine.js';
4
+ export { RentnerPdfError } from './engine/errors.js';
5
+ export { render } from './engine/render.js';
6
+ export type { BackendChoice, BackendName } from './engine/Types/backend.js';
7
+ export type { CacheOptions, Engine, EngineOptions, FontSource, RenderInput, } from './engine/Types/engine.js';
8
+ export type { Limits, LimitsInput } from './engine/Types/limits.js';
9
+ export type { BatchFailed, BatchOptions, BatchRendered, BatchResult, EngineStats, RenderOptions, } from './engine/Types/render-options.js';
10
+ export type { RentnerPdfErrorCode, RentnerPdfErrorOptions, } from './engine/Types/errors.js';
11
+ export type { PdfBytes, RenderResult, RenderWarning, RentnerPdfWarningCode, WrapDiagnostic, WrapReason, } from './engine/Types/render-result.js';
12
+ export { anchor, cell, document, image, keep, link, marker, page, pageBreak, pageNumber, svg, row, table, text, type TextInput, totalPages, view, } from './ir/factories.js';
13
13
  /** IR types generated from the Rust engine (`ir.Document`, `ir.Node`, …). */
14
- export type * as ir from './ir/ir.generated.ts';
15
- export type { Dir, FacturX, FacturXLevel, HeaderScope, MarkerSelect, NumberFormat, Orientation, PageNumberFormat, PageNumbering, PageScope, PageSize, Relationship, RunningTotals, Standard, Style, StyleLength, TableTotals, TextAlign, } from './ir/ir.generated.ts';
16
- export type { AttachmentInput, AttachmentSource, CellNodeInput, DocumentInput, ImageNodeInput, ImageSource, LetterheadInput, NodeInput, PageInput, PageVariantInput, PdfSource, SvgNodeInput, SvgSource, RowNodeInput, TableColumnInput, TableNodeInput, ViewNodeInput, } from './ir/Types/input.ts';
17
- export { IR_VERSION } from './ir/version.ts';
18
- export { createContext, useContext } from './jsx/context.ts';
19
- export { Fragment, isElement } from './jsx/element.ts';
20
- export { renderToIr, renderToIrSync } from './jsx/evaluate.ts';
21
- export type { Context, Provider, ProviderProps } from './jsx/Types/context.ts';
22
- export { DEFAULT_THEME_SCOPES, themeFromCss } from './theme/theme-from-css.ts';
23
- export type { Theme, ThemeFromCssOptions, ThemeInput, ThemeStylesheet, ThemeVariables, } from './theme/Types/theme.ts';
24
- export type { Component, Key, PdfElement, PdfNode, SourceLocation, } from './jsx/Types/element.ts';
25
- export type { WasmModuleSource } from './wasm/loader.ts';
14
+ export type * as ir from './ir/ir.generated.js';
15
+ export type { Dir, FacturX, FacturXLevel, HeaderScope, MarkerSelect, NumberFormat, Orientation, PageNumberFormat, PageNumbering, PageScope, PageSize, Relationship, RunningTotals, Standard, Style, StyleLength, TableTotals, TextAlign, } from './ir/ir.generated.js';
16
+ export type { AttachmentInput, AttachmentSource, CellNodeInput, DocumentInput, ImageNodeInput, ImageSource, LetterheadInput, NodeInput, PageInput, PageVariantInput, PdfSource, SvgNodeInput, SvgSource, RowNodeInput, TableColumnInput, TableNodeInput, ViewNodeInput, } from './ir/Types/input.js';
17
+ export { IR_VERSION } from './ir/version.js';
18
+ export { createContext, useContext } from './jsx/context.js';
19
+ export { Fragment, isElement } from './jsx/element.js';
20
+ export { renderToIr, renderToIrSync } from './jsx/evaluate.js';
21
+ export type { Context, Provider, ProviderProps } from './jsx/Types/context.js';
22
+ export { DEFAULT_THEME_SCOPES, themeFromCss } from './theme/theme-from-css.js';
23
+ export type { Theme, ThemeFromCssOptions, ThemeInput, ThemeStylesheet, ThemeVariables, } from './theme/Types/theme.js';
24
+ export type { Component, Key, PdfElement, PdfNode, SourceLocation, } from './jsx/Types/element.js';
25
+ export type { WasmModuleSource } from './wasm/loader.js';
26
26
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { Attachment, CellNode, Document, ImageNode, Letterhead, Page, SvgNode, RowNode, TableColumn, TableNode, TextNode, ViewNode } from '../ir.generated.ts';
1
+ import type { Attachment, CellNode, Document, ImageNode, Letterhead, Page, SvgNode, RowNode, TableColumn, TableNode, TextNode, ViewNode } from '../ir.generated.js';
2
2
  /** Image bytes: PNG, JPEG, GIF (first frame) or WebP. */
3
3
  export type ImageSource = Uint8Array | ArrayBuffer;
4
4
  /** SVG markup as a string, or the bytes of an `.svg` file (UTF-8). */
@@ -1,6 +1,6 @@
1
- import type { AnchorAttributes, CellAttributes, DataTableAttributes, DocumentAttributes, ImageAttributes, KeepAttributes, LinkAttributes, MarkerProps, PageAttributes, PageNumberProps, PageRegionProps, SvgAttributes, RowAttributes, TableAttributes, TextAttributes, TextValue, TotalPagesProps, ViewAttributes } from '../components/Types/props.ts';
2
- import type { Placeholder, TextNode } from './ir.generated.ts';
3
- import type { CellNodeInput, DocumentInput, ImageNodeInput, NodeInput, PageInput, SvgNodeInput, RowNodeInput, TableNodeInput, ViewNodeInput } from './Types/input.ts';
1
+ import type { AnchorAttributes, CellAttributes, DataTableAttributes, DocumentAttributes, ImageAttributes, KeepAttributes, LinkAttributes, MarkerProps, PageAttributes, PageNumberProps, PageRegionProps, SvgAttributes, RowAttributes, TableAttributes, TextAttributes, TextValue, TotalPagesProps, ViewAttributes } from '../components/Types/props.js';
2
+ import type { Placeholder, TextNode } from './ir.generated.js';
3
+ import type { CellNodeInput, DocumentInput, ImageNodeInput, NodeInput, PageInput, SvgNodeInput, RowNodeInput, TableNodeInput, ViewNodeInput } from './Types/input.js';
4
4
  /** A text's content: one string, or strings and placeholders. */
5
5
  export type TextInput = TextValue | Placeholder | readonly (TextValue | Placeholder)[];
6
6
  /** Builds an IR document from metadata and pages. */
@@ -1 +1 @@
1
- {"version":3,"file":"factories.d.ts","sourceRoot":"","sources":["../../web/src/ir/factories.ts"],"names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C9B,KAAK,GAAE,SAAS,CAAC;IAAE,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAAC,EAAO,GACvD;IAAE,CAAC,EAAE,KAAK,CAAA;CAAE,GAAG,YAAY,CAU7B;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAChB,UAAU,GAAE,cAAmB,EAC/B,OAAO,GAAE,SAAS,SAAS,EAAE,GAAG,SAAc,GAC/C;IAAE,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAkB/B"}
@@ -1,3 +1,4 @@
1
+ import { pageVariantNames } from './page-variants.js';
1
2
  import { IR_VERSION } from './version.js';
2
3
  /** A `Date` as ISO 8601 in UTC; an invalid date fails in the engine. */
3
4
  const isoDate = (date) => typeof date === 'string' || Number.isNaN(date.getTime())
@@ -85,8 +86,12 @@ const textContent = (input) => {
85
86
  else if (value !== '')
86
87
  parts.push(value);
87
88
  }
88
- if (parts.every((part) => typeof part === 'string'))
89
- return parts.join('');
89
+ // Adjacent strings were merged, so plain text has at most one part.
90
+ const [first] = parts;
91
+ if (first === undefined)
92
+ return '';
93
+ if (parts.length === 1 && typeof first === 'string')
94
+ return first;
90
95
  return parts;
91
96
  };
92
97
  const letterheadOf = ({ src, page: index, }) => index === undefined ? { src } : { src, page: index };
@@ -154,7 +159,7 @@ export function page(attributes = {}, children = []) {
154
159
  result.header = attributes.header;
155
160
  if (attributes.footer !== undefined)
156
161
  result.footer = attributes.footer;
157
- for (const key of ['first', 'odd', 'even', 'last']) {
162
+ for (const key of pageVariantNames) {
158
163
  const variant = attributes[key];
159
164
  if (variant !== undefined)
160
165
  result[key] = variantOf(variant);
@@ -1 +1 @@
1
- {"version":3,"file":"factories.js","sourceRoot":"","sources":["../../web/src/ir/factories.ts"],"names":[],"mappings":"AAmDA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,wEAAwE;AACxE,MAAM,OAAO,GAAG,CAAC,IAAmB,EAAU,EAAE,CAC5C,OAAO,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,SAAS;QAAE,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAA;IACzE,IAAI,UAAU,CAAC,OAAO,KAAK,SAAS;QAAE,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAA;IACzE,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS;QAAE,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAA;IACnE,IAAI,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QACrC,MAAM,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,CAAA;IAC3C,CAAC;IACD,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS;QAAE,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAA;IACnE,IAAI,UAAU,CAAC,IAAI,KAAK,SAAS;QAAE,MAAM,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAA;IAChE,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS;QAAE,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAA;IACnE,IAAI,UAAU,CAAC,IAAI,KAAK,SAAS;QAAE,MAAM,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAA;IAChE,IAAI,UAAU,CAAC,GAAG,KAAK,SAAS;QAAE,MAAM,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,CAAA;IAC7D,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC;QACjC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC,GAAI,OAAgC,CAAC,CAAA;IAC5C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAA;IACnD,OAAO,MAAM,CAAA;AACjB,CAAC","sourcesContent":["// Factories: the canonical IR builders. JSX elements are evaluated into\n// these calls, and code without JSX can use them directly.\nimport type {\n AnchorAttributes,\n AttachmentAttributes,\n BookmarkInput,\n CellAttributes,\n DataTableAttributes,\n DocumentAttributes,\n ImageAttributes,\n KeepAttributes,\n LinkAttributes,\n MarkerAssignment,\n MarkerProps,\n NavigationAttributes,\n PageAttributes,\n PageNumberProps,\n PageRegionProps,\n PageVariantProps,\n SvgAttributes,\n RowAttributes,\n TableAttributes,\n TextAttributes,\n TextMarkerAssignment,\n TextValue,\n TotalPagesProps,\n ViewAttributes,\n} from '../components/Types/props.ts'\nimport type {\n Bookmark,\n MarkerSet,\n Meta,\n Placeholder,\n TextNode,\n TextPart,\n TotalPagesField,\n} from './ir.generated.ts'\nimport type {\n AttachmentInput,\n CellNodeInput,\n DocumentInput,\n ImageNodeInput,\n LetterheadInput,\n NodeInput,\n PageInput,\n PageVariantInput,\n SvgNodeInput,\n RowNodeInput,\n TableNodeInput,\n ViewNodeInput,\n} from './Types/input.ts'\nimport { IR_VERSION } from './version.ts'\n\n/** A `Date` as ISO 8601 in UTC; an invalid date fails in the engine. */\nconst isoDate = (date: Date | string): string =>\n typeof date === 'string' || Number.isNaN(date.getTime())\n ? String(date)\n : date.toISOString()\n\nconst meta = ({\n title,\n author,\n subject,\n keywords,\n lang,\n dir,\n creator,\n creationDate,\n}: DocumentAttributes): Meta | undefined => {\n const result: Meta = {}\n if (title !== undefined) result.title = title\n if (author !== undefined) result.author = author\n if (subject !== undefined) result.subject = subject\n if (keywords !== undefined) result.keywords = [...keywords]\n if (lang !== undefined) result.lang = lang\n if (dir !== undefined) result.dir = dir\n if (creator !== undefined) result.creator = creator\n if (creationDate !== undefined) {\n result.creationDate = isoDate(creationDate)\n }\n return Object.keys(result).length === 0 ? undefined : result\n}\n\nconst bookmarkOf = (input: BookmarkInput): false | Bookmark => {\n if (input === false) return false\n if (typeof input === 'string') return { title: input }\n const result: Bookmark = {}\n if (input.title !== undefined) result.title = input.title\n if (input.level !== undefined) result.level = input.level\n return result\n}\n\n/** Copies `id` and `bookmark` onto an IR node. */\nconst navigation = (\n target: { id?: string; bookmark?: false | Bookmark },\n { id, bookmark }: NavigationAttributes,\n): void => {\n if (id !== undefined) target.id = id\n if (bookmark !== undefined) target.bookmark = bookmarkOf(bookmark)\n}\n\n/** Copies `marker` onto an IR node as its `markers`. */\nconst markersOf = (\n input:\n | string\n | MarkerAssignment\n | TextMarkerAssignment\n | readonly (string | MarkerAssignment | TextMarkerAssignment)[]\n | undefined,\n): MarkerSet[] | undefined => {\n if (input === undefined) return undefined\n const list = (Array.isArray(input) ? input : [input]) as readonly (\n string | TextMarkerAssignment\n )[]\n return list.map((entry) =>\n typeof entry === 'string'\n ? { name: entry }\n : entry.value === undefined\n ? { name: entry.name }\n : { name: entry.name, value: entry.value },\n )\n}\n\n/** A text's content: one string, or strings and placeholders. */\nexport type TextInput =\n TextValue | Placeholder | readonly (TextValue | Placeholder)[]\n\nconst placeholderKinds: ReadonlySet<unknown> = new Set([\n 'pageNumber',\n 'totalPages',\n 'marker',\n])\n\nconst isPlaceholder = (value: unknown): value is Placeholder =>\n typeof value === 'object' &&\n value !== null &&\n placeholderKinds.has(Reflect.get(value, 't'))\n\n/** Whether a cell's content is text (strings, numbers, placeholders). */\nconst isTextInput = (\n content: readonly NodeInput[] | TextInput,\n): content is TextInput =>\n !Array.isArray(content)\n ? true\n : content.length > 0 &&\n content.every(\n (part: unknown) =>\n typeof part !== 'object' || isPlaceholder(part),\n )\n\n/** Joins adjacent strings; plain text stays a string. */\nconst textContent = (input: TextInput): string | TextPart[] => {\n const parts: TextPart[] = []\n const list: readonly (TextValue | Placeholder)[] = Array.isArray(input)\n ? input\n : [input as TextValue | Placeholder]\n for (const part of list) {\n if (isPlaceholder(part)) {\n parts.push({ ...part })\n continue\n }\n const value = String(part)\n const last = parts.at(-1)\n if (typeof last === 'string') parts[parts.length - 1] = last + value\n else if (value !== '') parts.push(value)\n }\n if (parts.every((part) => typeof part === 'string')) return parts.join('')\n return parts\n}\n\nconst letterheadOf = ({\n src,\n page: index,\n}: LetterheadInput): LetterheadInput =>\n index === undefined ? { src } : { src, page: index }\n\nconst variantOf = (variant: PageVariantProps<NodeInput>): PageVariantInput => {\n const result: PageVariantInput = {}\n if (variant.header !== undefined) result.header = variant.header\n if (variant.footer !== undefined) result.footer = variant.footer\n if (variant.letterhead !== undefined) {\n result.letterhead =\n variant.letterhead === null\n ? null\n : letterheadOf(variant.letterhead)\n }\n return result\n}\n\n/** Builds an IR document from metadata and pages. */\nexport function document(\n attributes: DocumentAttributes = {},\n pages: readonly PageInput[] = [],\n): DocumentInput & { v: number } {\n const documentMeta = meta(attributes)\n const result: DocumentInput & { v: number } =\n documentMeta === undefined\n ? { v: IR_VERSION, pages: [...pages] }\n : { v: IR_VERSION, meta: documentMeta, pages: [...pages] }\n const { standard, attachments, facturX, tagged } = attributes\n if (standard !== undefined) {\n result.standards =\n typeof standard === 'string' ? [standard] : [...standard]\n }\n if (attachments !== undefined) {\n result.attachments = attachments.map(attachmentOf)\n }\n if (facturX !== undefined) result.facturX = { ...facturX }\n if (tagged !== undefined) result.tagged = tagged\n return result\n}\n\n/** An attachment with its date as ISO 8601. */\nconst attachmentOf = ({\n modificationDate,\n ...rest\n}: AttachmentAttributes): AttachmentInput =>\n modificationDate === undefined\n ? { ...rest }\n : { ...rest, modificationDate: isoDate(modificationDate) }\n\n/**\n * Builds a page template from its attributes, header, footer, variants and\n * child nodes: `page({ footer: text(['Page ', pageNumber()]) }, [...])`.\n */\nexport function page(\n attributes: PageAttributes & PageRegionProps<NodeInput> = {},\n children: readonly NodeInput[] = [],\n): PageInput {\n const result: PageInput = {}\n if (attributes.size !== undefined) result.size = attributes.size\n if (attributes.orientation !== undefined) {\n result.orientation = attributes.orientation\n }\n if (attributes.letterhead !== undefined) {\n result.letterhead = letterheadOf(attributes.letterhead)\n }\n if (attributes.className !== undefined) {\n result.className = attributes.className\n }\n if (attributes.style !== undefined) result.style = attributes.style\n if (attributes.numbering !== undefined) {\n result.numbering = { ...attributes.numbering }\n }\n if (attributes.header !== undefined) result.header = attributes.header\n if (attributes.footer !== undefined) result.footer = attributes.footer\n for (const key of ['first', 'odd', 'even', 'last'] as const) {\n const variant = attributes[key]\n if (variant !== undefined) result[key] = variantOf(variant)\n }\n if (children.length > 0) result.children = [...children]\n return result\n}\n\n/** Builds a view node (a block, flex or grid box) with its children. */\nexport function view(\n attributes: ViewAttributes = {},\n children: readonly NodeInput[] = [],\n): { t: 'view' } & ViewNodeInput {\n const result: { t: 'view' } & ViewNodeInput = { t: 'view' }\n if (attributes.className !== undefined) {\n result.className = attributes.className\n }\n if (attributes.style !== undefined) result.style = attributes.style\n if (attributes.role !== undefined) result.role = attributes.role\n if (attributes.alt !== undefined) result.alt = attributes.alt\n if (attributes.lang !== undefined) result.lang = attributes.lang\n if (attributes.dir !== undefined) result.dir = attributes.dir\n navigation(result, attributes)\n const markers = markersOf(attributes.marker)\n if (markers !== undefined) result.markers = markers\n if (children.length > 0) result.children = [...children]\n return result\n}\n\n/**\n * Builds a text node: `text('Hello')`, `text({ className: 'text-sm' },\n * 'Hello')` or with placeholders `text(['Page ', pageNumber(), ' of ',\n * totalPages()])`.\n */\nexport function text(content: TextInput): { t: 'text' } & TextNode\nexport function text(\n attributes: TextAttributes,\n content?: TextInput,\n): { t: 'text' } & TextNode\nexport function text(\n first: TextAttributes | TextInput,\n content: TextInput = '',\n): { t: 'text' } & TextNode {\n if (\n typeof first !== 'object' ||\n Array.isArray(first) ||\n isPlaceholder(first)\n ) {\n return { t: 'text', text: textContent(first as TextInput) }\n }\n const attributes = first as TextAttributes\n const result: { t: 'text' } & TextNode = {\n t: 'text',\n text: textContent(content),\n }\n if (attributes.className !== undefined) {\n result.className = attributes.className\n }\n if (attributes.style !== undefined) result.style = attributes.style\n if (attributes.role !== undefined) result.role = attributes.role\n if (attributes.lang !== undefined) result.lang = attributes.lang\n if (attributes.dir !== undefined) result.dir = attributes.dir\n if (attributes.alt !== undefined) result.alt = attributes.alt\n navigation(result, attributes)\n const markers = markersOf(attributes.marker)\n if (markers !== undefined) result.markers = markers\n return result\n}\n\n/** The number of the page the text is on: `text(['Page ', pageNumber()])`. */\nexport function pageNumber(attributes: PageNumberProps = {}): Placeholder {\n return attributes.format === undefined\n ? { t: 'pageNumber' }\n : { t: 'pageNumber', format: attributes.format }\n}\n\n/** The number of pages of the document, or of the template (`scope: 'section'`). */\nexport function totalPages(attributes: TotalPagesProps = {}): Placeholder {\n const result: { t: 'totalPages' } & TotalPagesField = { t: 'totalPages' }\n if (attributes.scope !== undefined) result.scope = attributes.scope\n if (attributes.format !== undefined) result.format = attributes.format\n return result\n}\n\n/** The value of running marker `name` on the page, for example the chapter. */\nexport function marker({ name, select }: MarkerProps): Placeholder {\n return select === undefined\n ? { t: 'marker', name }\n : { t: 'marker', name, select }\n}\n\n/**\n * Builds an image node from its bytes: `image({ src, alt: 'Logo',\n * className: 'w-32' })`. The bytes travel to the engine next to the JSON.\n */\nexport function image(attributes: ImageAttributes): {\n t: 'image'\n} & ImageNodeInput {\n const result: { t: 'image' } & ImageNodeInput = {\n t: 'image',\n src: attributes.src,\n }\n if (attributes.alt !== undefined) result.alt = attributes.alt\n if (attributes.className !== undefined) {\n result.className = attributes.className\n }\n if (attributes.style !== undefined) result.style = attributes.style\n if (attributes.role !== undefined) result.role = attributes.role\n navigation(result, attributes)\n return result\n}\n\n/**\n * Builds an SVG node from its markup or file bytes: `svg({ src: '<svg …>',\n * className: 'w-48' })`. The markup travels to the engine next to the JSON.\n */\nexport function svg(attributes: SvgAttributes): {\n t: 'svg'\n} & SvgNodeInput {\n const result: { t: 'svg' } & SvgNodeInput = {\n t: 'svg',\n src: attributes.src,\n }\n if (attributes.alt !== undefined) result.alt = attributes.alt\n if (attributes.className !== undefined) {\n result.className = attributes.className\n }\n if (attributes.style !== undefined) result.style = attributes.style\n if (attributes.role !== undefined) result.role = attributes.role\n navigation(result, attributes)\n return result\n}\n\n/**\n * Builds a link: a view with `href` around `children`, for example\n * `link({ href: 'https://example.com' }, [text('Website')])` or\n * `link({ href: '#terms' }, …)`.\n */\nexport function link(\n { href, ...attributes }: LinkAttributes,\n children: readonly NodeInput[] = [],\n): { t: 'view' } & ViewNodeInput {\n return { ...view(attributes, children), href }\n}\n\n/** Builds an anchor: an empty view with `id`, the target of `#id` links. */\nexport function anchor({\n id,\n bookmark,\n}: AnchorAttributes): { t: 'view' } & ViewNodeInput {\n return bookmark === undefined ? view({ id }) : view({ id, bookmark })\n}\n\n/**\n * Builds a page break: an empty view with `break-after-page`, so the content\n * after it starts on a new page. At the end of the content it adds no page.\n */\nexport function pageBreak(): { t: 'view' } & ViewNodeInput {\n return { t: 'view', className: 'break-after-page' }\n}\n\n/**\n * Builds a keep-together group: a view with `break-inside-avoid` (and\n * `break-after-avoid` with `withNext`) around `children`. The classes come\n * first, so the group's own `className` can override them.\n */\nexport function keep(\n { withNext, className, ...attributes }: KeepAttributes = {},\n children: readonly NodeInput[] = [],\n): { t: 'view' } & ViewNodeInput {\n const classes = ['break-inside-avoid']\n if (withNext === true) classes.push('break-after-avoid')\n if (className !== undefined && className !== '') classes.push(className)\n return view({ ...attributes, className: classes.join(' ') }, children)\n}\n\n/**\n * Builds a table from its rows: `table({ columns: [{ width: '1fr' },\n * { width: '30mm', align: 'right' }] }, [row({ header: true }, [...]),\n * ...])`. Header rows come first and footer rows last.\n *\n * With `data` it builds a data-driven table instead: `table({ data: items,\n * columns: [{ key: 'name', header: 'Item' }, ...] })`, one row per item.\n */\nexport function table<Row extends object>(\n attributes: DataTableAttributes<Row>,\n): { t: 'table' } & TableNodeInput\nexport function table(\n attributes?: TableAttributes,\n rows?: readonly ({ t: 'row' } & RowNodeInput)[],\n): { t: 'table' } & TableNodeInput\nexport function table(\n attributes: TableAttributes | DataTableAttributes<object> = {},\n rows: readonly ({ t: 'row' } & RowNodeInput)[] = [],\n): { t: 'table' } & TableNodeInput {\n const result: { t: 'table' } & TableNodeInput = { t: 'table' }\n if (attributes.columns !== undefined) {\n result.columns = attributes.columns.map((column) => ({ ...column }))\n }\n if (attributes.data !== undefined) {\n const data = attributes as DataTableAttributes<object>\n result.data = data.data\n if (data.rowClassName !== undefined) {\n result.rowClassName = data.rowClassName\n }\n if (data.headerClassName !== undefined) {\n result.headerClassName = data.headerClassName\n }\n if (data.totals !== undefined) result.totals = { ...data.totals }\n }\n if (attributes.cellClassName !== undefined) {\n result.cellClassName = attributes.cellClassName\n }\n if (attributes.repeatHeader !== undefined) {\n result.repeatHeader = attributes.repeatHeader\n }\n if (attributes.repeatFooter !== undefined) {\n result.repeatFooter = attributes.repeatFooter\n }\n if (attributes.runningTotals !== undefined) {\n result.runningTotals = { ...attributes.runningTotals }\n }\n if (attributes.className !== undefined) {\n result.className = attributes.className\n }\n if (attributes.style !== undefined) result.style = attributes.style\n if (attributes.role !== undefined) result.role = attributes.role\n if (attributes.lang !== undefined) result.lang = attributes.lang\n if (attributes.dir !== undefined) result.dir = attributes.dir\n navigation(result, attributes)\n if (rows.length > 0) result.children = [...rows]\n return result\n}\n\n/** Builds a table row from its cells; `header` and `footer` mark the section. */\nexport function row(\n attributes: RowAttributes = {},\n cells: readonly ({ t: 'cell' } & CellNodeInput)[] = [],\n): { t: 'row' } & RowNodeInput {\n const result: { t: 'row' } & RowNodeInput = { t: 'row' }\n if (attributes.header !== undefined) result.header = attributes.header\n if (attributes.footer !== undefined) result.footer = attributes.footer\n if (attributes.className !== undefined) {\n result.className = attributes.className\n }\n if (attributes.style !== undefined) result.style = attributes.style\n if (cells.length > 0) result.children = [...cells]\n return result\n}\n\n/**\n * Builds a table cell: `cell({ colSpan: 2 }, [text('Total')])`, or with\n * text directly: `cell({ className: 'font-bold' }, 'Total')` (also with\n * placeholders: `cell({}, ['Page ', pageNumber()])`). A cell with a `value`\n * and no content shows the value in its column's format.\n */\nexport function cell(\n attributes: CellAttributes = {},\n content: readonly NodeInput[] | TextInput = [],\n): { t: 'cell' } & CellNodeInput {\n const result: { t: 'cell' } & CellNodeInput = { t: 'cell' }\n if (attributes.colSpan !== undefined) result.colSpan = attributes.colSpan\n if (attributes.rowSpan !== undefined) result.rowSpan = attributes.rowSpan\n if (attributes.value !== undefined) result.value = attributes.value\n if (attributes.className !== undefined) {\n result.className = attributes.className\n }\n if (attributes.style !== undefined) result.style = attributes.style\n if (attributes.role !== undefined) result.role = attributes.role\n if (attributes.scope !== undefined) result.scope = attributes.scope\n if (attributes.lang !== undefined) result.lang = attributes.lang\n if (attributes.dir !== undefined) result.dir = attributes.dir\n const children = isTextInput(content)\n ? [text(content)]\n : [...(content as readonly NodeInput[])]\n if (children.length > 0) result.children = children\n return result\n}\n"]}
1
+ {"version":3,"file":"factories.js","sourceRoot":"","sources":["../../web/src/ir/factories.ts"],"names":[],"mappings":"AAqCA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAerD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,wEAAwE;AACxE,MAAM,OAAO,GAAG,CAAC,IAAmB,EAAU,EAAE,CAC5C,OAAO,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;IACpD,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;IACd,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAA;AAE5B,MAAM,IAAI,GAAG,CAAC,EACV,KAAK,EACL,MAAM,EACN,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,GAAG,EACH,OAAO,EACP,YAAY,GACK,EAAoB,EAAE;IACvC,MAAM,MAAM,GAAS,EAAE,CAAA;IACvB,IAAI,KAAK,KAAK,SAAS;QAAE,MAAM,CAAC,KAAK,GAAG,KAAK,CAAA;IAC7C,IAAI,MAAM,KAAK,SAAS;QAAE,MAAM,CAAC,MAAM,GAAG,MAAM,CAAA;IAChD,IAAI,OAAO,KAAK,SAAS;QAAE,MAAM,CAAC,OAAO,GAAG,OAAO,CAAA;IACnD,IAAI,QAAQ,KAAK,SAAS;QAAE,MAAM,CAAC,QAAQ,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAA;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AAU,CAAC,KAAK,CAAA;IACnE,IAAI,UAAU,CAAC,IAAI,KAAK,SAAS;QAAE,MAAM,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAA;IAChE,IAAI,UAAU,CAAC,GAAG,KAAK,SAAS;QAAE,MAAM,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,CAAA;IAC7D,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC;QACjC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC,GAAI,OAAgC,CAAC,CAAA;IAC5C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAA;IACnD,OAAO,MAAM,CAAA;AACjB,CAAC","sourcesContent":["// Factories: the canonical IR builders. JSX elements are evaluated into\n// these calls, and code without JSX can use them directly.\nimport type {\n AnchorAttributes,\n AttachmentAttributes,\n BookmarkInput,\n CellAttributes,\n DataTableAttributes,\n DocumentAttributes,\n ImageAttributes,\n KeepAttributes,\n LinkAttributes,\n MarkerAssignment,\n MarkerProps,\n NavigationAttributes,\n PageAttributes,\n PageNumberProps,\n PageRegionProps,\n PageVariantProps,\n SvgAttributes,\n RowAttributes,\n TableAttributes,\n TextAttributes,\n TextMarkerAssignment,\n TextValue,\n TotalPagesProps,\n ViewAttributes,\n} from '../components/Types/props.ts'\nimport type {\n Bookmark,\n MarkerSet,\n Meta,\n Placeholder,\n TextNode,\n TextPart,\n TotalPagesField,\n} from './ir.generated.ts'\nimport { pageVariantNames } from './page-variants.ts'\nimport type {\n AttachmentInput,\n CellNodeInput,\n DocumentInput,\n ImageNodeInput,\n LetterheadInput,\n NodeInput,\n PageInput,\n PageVariantInput,\n SvgNodeInput,\n RowNodeInput,\n TableNodeInput,\n ViewNodeInput,\n} from './Types/input.ts'\nimport { IR_VERSION } from './version.ts'\n\n/** A `Date` as ISO 8601 in UTC; an invalid date fails in the engine. */\nconst isoDate = (date: Date | string): string =>\n typeof date === 'string' || Number.isNaN(date.getTime())\n ? String(date)\n : date.toISOString()\n\nconst meta = ({\n title,\n author,\n subject,\n keywords,\n lang,\n dir,\n creator,\n creationDate,\n}: DocumentAttributes): Meta | undefined => {\n const result: Meta = {}\n if (title !== undefined) result.title = title\n if (author !== undefined) result.author = author\n if (subject !== undefined) result.subject = subject\n if (keywords !== undefined) result.keywords = [...keywords]\n if (lang !== undefined) result.lang = lang\n if (dir !== undefined) result.dir = dir\n if (creator !== undefined) result.creator = creator\n if (creationDate !== undefined) {\n result.creationDate = isoDate(creationDate)\n }\n return Object.keys(result).length === 0 ? undefined : result\n}\n\nconst bookmarkOf = (input: BookmarkInput): false | Bookmark => {\n if (input === false) return false\n if (typeof input === 'string') return { title: input }\n const result: Bookmark = {}\n if (input.title !== undefined) result.title = input.title\n if (input.level !== undefined) result.level = input.level\n return result\n}\n\n/** Copies `id` and `bookmark` onto an IR node. */\nconst navigation = (\n target: { id?: string; bookmark?: false | Bookmark },\n { id, bookmark }: NavigationAttributes,\n): void => {\n if (id !== undefined) target.id = id\n if (bookmark !== undefined) target.bookmark = bookmarkOf(bookmark)\n}\n\n/** Copies `marker` onto an IR node as its `markers`. */\nconst markersOf = (\n input:\n | string\n | MarkerAssignment\n | TextMarkerAssignment\n | readonly (string | MarkerAssignment | TextMarkerAssignment)[]\n | undefined,\n): MarkerSet[] | undefined => {\n if (input === undefined) return undefined\n const list = (Array.isArray(input) ? input : [input]) as readonly (\n string | TextMarkerAssignment\n )[]\n return list.map((entry) =>\n typeof entry === 'string'\n ? { name: entry }\n : entry.value === undefined\n ? { name: entry.name }\n : { name: entry.name, value: entry.value },\n )\n}\n\n/** A text's content: one string, or strings and placeholders. */\nexport type TextInput =\n TextValue | Placeholder | readonly (TextValue | Placeholder)[]\n\nconst placeholderKinds: ReadonlySet<unknown> = new Set([\n 'pageNumber',\n 'totalPages',\n 'marker',\n])\n\nconst isPlaceholder = (value: unknown): value is Placeholder =>\n typeof value === 'object' &&\n value !== null &&\n placeholderKinds.has(Reflect.get(value, 't'))\n\n/** Whether a cell's content is text (strings, numbers, placeholders). */\nconst isTextInput = (\n content: readonly NodeInput[] | TextInput,\n): content is TextInput =>\n !Array.isArray(content)\n ? true\n : content.length > 0 &&\n content.every(\n (part: unknown) =>\n typeof part !== 'object' || isPlaceholder(part),\n )\n\n/** Joins adjacent strings; plain text stays a string. */\nconst textContent = (input: TextInput): string | TextPart[] => {\n const parts: TextPart[] = []\n const list: readonly (TextValue | Placeholder)[] = Array.isArray(input)\n ? input\n : [input as TextValue | Placeholder]\n for (const part of list) {\n if (isPlaceholder(part)) {\n parts.push({ ...part })\n continue\n }\n const value = String(part)\n const last = parts.at(-1)\n if (typeof last === 'string') parts[parts.length - 1] = last + value\n else if (value !== '') parts.push(value)\n }\n // Adjacent strings were merged, so plain text has at most one part.\n const [first] = parts\n if (first === undefined) return ''\n if (parts.length === 1 && typeof first === 'string') return first\n return parts\n}\n\nconst letterheadOf = ({\n src,\n page: index,\n}: LetterheadInput): LetterheadInput =>\n index === undefined ? { src } : { src, page: index }\n\nconst variantOf = (variant: PageVariantProps<NodeInput>): PageVariantInput => {\n const result: PageVariantInput = {}\n if (variant.header !== undefined) result.header = variant.header\n if (variant.footer !== undefined) result.footer = variant.footer\n if (variant.letterhead !== undefined) {\n result.letterhead =\n variant.letterhead === null\n ? null\n : letterheadOf(variant.letterhead)\n }\n return result\n}\n\n/** Builds an IR document from metadata and pages. */\nexport function document(\n attributes: DocumentAttributes = {},\n pages: readonly PageInput[] = [],\n): DocumentInput & { v: number } {\n const documentMeta = meta(attributes)\n const result: DocumentInput & { v: number } =\n documentMeta === undefined\n ? { v: IR_VERSION, pages: [...pages] }\n : { v: IR_VERSION, meta: documentMeta, pages: [...pages] }\n const { standard, attachments, facturX, tagged } = attributes\n if (standard !== undefined) {\n result.standards =\n typeof standard === 'string' ? [standard] : [...standard]\n }\n if (attachments !== undefined) {\n result.attachments = attachments.map(attachmentOf)\n }\n if (facturX !== undefined) result.facturX = { ...facturX }\n if (tagged !== undefined) result.tagged = tagged\n return result\n}\n\n/** An attachment with its date as ISO 8601. */\nconst attachmentOf = ({\n modificationDate,\n ...rest\n}: AttachmentAttributes): AttachmentInput =>\n modificationDate === undefined\n ? { ...rest }\n : { ...rest, modificationDate: isoDate(modificationDate) }\n\n/**\n * Builds a page template from its attributes, header, footer, variants and\n * child nodes: `page({ footer: text(['Page ', pageNumber()]) }, [...])`.\n */\nexport function page(\n attributes: PageAttributes & PageRegionProps<NodeInput> = {},\n children: readonly NodeInput[] = [],\n): PageInput {\n const result: PageInput = {}\n if (attributes.size !== undefined) result.size = attributes.size\n if (attributes.orientation !== undefined) {\n result.orientation = attributes.orientation\n }\n if (attributes.letterhead !== undefined) {\n result.letterhead = letterheadOf(attributes.letterhead)\n }\n if (attributes.className !== undefined) {\n result.className = attributes.className\n }\n if (attributes.style !== undefined) result.style = attributes.style\n if (attributes.numbering !== undefined) {\n result.numbering = { ...attributes.numbering }\n }\n if (attributes.header !== undefined) result.header = attributes.header\n if (attributes.footer !== undefined) result.footer = attributes.footer\n for (const key of pageVariantNames) {\n const variant = attributes[key]\n if (variant !== undefined) result[key] = variantOf(variant)\n }\n if (children.length > 0) result.children = [...children]\n return result\n}\n\n/** Builds a view node (a block, flex or grid box) with its children. */\nexport function view(\n attributes: ViewAttributes = {},\n children: readonly NodeInput[] = [],\n): { t: 'view' } & ViewNodeInput {\n const result: { t: 'view' } & ViewNodeInput = { t: 'view' }\n if (attributes.className !== undefined) {\n result.className = attributes.className\n }\n if (attributes.style !== undefined) result.style = attributes.style\n if (attributes.role !== undefined) result.role = attributes.role\n if (attributes.alt !== undefined) result.alt = attributes.alt\n if (attributes.lang !== undefined) result.lang = attributes.lang\n if (attributes.dir !== undefined) result.dir = attributes.dir\n navigation(result, attributes)\n const markers = markersOf(attributes.marker)\n if (markers !== undefined) result.markers = markers\n if (children.length > 0) result.children = [...children]\n return result\n}\n\n/**\n * Builds a text node: `text('Hello')`, `text({ className: 'text-sm' },\n * 'Hello')` or with placeholders `text(['Page ', pageNumber(), ' of ',\n * totalPages()])`.\n */\nexport function text(content: TextInput): { t: 'text' } & TextNode\nexport function text(\n attributes: TextAttributes,\n content?: TextInput,\n): { t: 'text' } & TextNode\nexport function text(\n first: TextAttributes | TextInput,\n content: TextInput = '',\n): { t: 'text' } & TextNode {\n if (\n typeof first !== 'object' ||\n Array.isArray(first) ||\n isPlaceholder(first)\n ) {\n return { t: 'text', text: textContent(first as TextInput) }\n }\n const attributes = first as TextAttributes\n const result: { t: 'text' } & TextNode = {\n t: 'text',\n text: textContent(content),\n }\n if (attributes.className !== undefined) {\n result.className = attributes.className\n }\n if (attributes.style !== undefined) result.style = attributes.style\n if (attributes.role !== undefined) result.role = attributes.role\n if (attributes.lang !== undefined) result.lang = attributes.lang\n if (attributes.dir !== undefined) result.dir = attributes.dir\n if (attributes.alt !== undefined) result.alt = attributes.alt\n navigation(result, attributes)\n const markers = markersOf(attributes.marker)\n if (markers !== undefined) result.markers = markers\n return result\n}\n\n/** The number of the page the text is on: `text(['Page ', pageNumber()])`. */\nexport function pageNumber(attributes: PageNumberProps = {}): Placeholder {\n return attributes.format === undefined\n ? { t: 'pageNumber' }\n : { t: 'pageNumber', format: attributes.format }\n}\n\n/** The number of pages of the document, or of the template (`scope: 'section'`). */\nexport function totalPages(attributes: TotalPagesProps = {}): Placeholder {\n const result: { t: 'totalPages' } & TotalPagesField = { t: 'totalPages' }\n if (attributes.scope !== undefined) result.scope = attributes.scope\n if (attributes.format !== undefined) result.format = attributes.format\n return result\n}\n\n/** The value of running marker `name` on the page, for example the chapter. */\nexport function marker({ name, select }: MarkerProps): Placeholder {\n return select === undefined\n ? { t: 'marker', name }\n : { t: 'marker', name, select }\n}\n\n/**\n * Builds an image node from its bytes: `image({ src, alt: 'Logo',\n * className: 'w-32' })`. The bytes travel to the engine next to the JSON.\n */\nexport function image(attributes: ImageAttributes): {\n t: 'image'\n} & ImageNodeInput {\n const result: { t: 'image' } & ImageNodeInput = {\n t: 'image',\n src: attributes.src,\n }\n if (attributes.alt !== undefined) result.alt = attributes.alt\n if (attributes.className !== undefined) {\n result.className = attributes.className\n }\n if (attributes.style !== undefined) result.style = attributes.style\n if (attributes.role !== undefined) result.role = attributes.role\n navigation(result, attributes)\n return result\n}\n\n/**\n * Builds an SVG node from its markup or file bytes: `svg({ src: '<svg …>',\n * className: 'w-48' })`. The markup travels to the engine next to the JSON.\n */\nexport function svg(attributes: SvgAttributes): {\n t: 'svg'\n} & SvgNodeInput {\n const result: { t: 'svg' } & SvgNodeInput = {\n t: 'svg',\n src: attributes.src,\n }\n if (attributes.alt !== undefined) result.alt = attributes.alt\n if (attributes.className !== undefined) {\n result.className = attributes.className\n }\n if (attributes.style !== undefined) result.style = attributes.style\n if (attributes.role !== undefined) result.role = attributes.role\n navigation(result, attributes)\n return result\n}\n\n/**\n * Builds a link: a view with `href` around `children`, for example\n * `link({ href: 'https://example.com' }, [text('Website')])` or\n * `link({ href: '#terms' }, …)`.\n */\nexport function link(\n { href, ...attributes }: LinkAttributes,\n children: readonly NodeInput[] = [],\n): { t: 'view' } & ViewNodeInput {\n return { ...view(attributes, children), href }\n}\n\n/** Builds an anchor: an empty view with `id`, the target of `#id` links. */\nexport function anchor({\n id,\n bookmark,\n}: AnchorAttributes): { t: 'view' } & ViewNodeInput {\n return bookmark === undefined ? view({ id }) : view({ id, bookmark })\n}\n\n/**\n * Builds a page break: an empty view with `break-after-page`, so the content\n * after it starts on a new page. At the end of the content it adds no page.\n */\nexport function pageBreak(): { t: 'view' } & ViewNodeInput {\n return { t: 'view', className: 'break-after-page' }\n}\n\n/**\n * Builds a keep-together group: a view with `break-inside-avoid` (and\n * `break-after-avoid` with `withNext`) around `children`. The classes come\n * first, so the group's own `className` can override them.\n */\nexport function keep(\n { withNext, className, ...attributes }: KeepAttributes = {},\n children: readonly NodeInput[] = [],\n): { t: 'view' } & ViewNodeInput {\n const classes = ['break-inside-avoid']\n if (withNext === true) classes.push('break-after-avoid')\n if (className !== undefined && className !== '') classes.push(className)\n return view({ ...attributes, className: classes.join(' ') }, children)\n}\n\n/**\n * Builds a table from its rows: `table({ columns: [{ width: '1fr' },\n * { width: '30mm', align: 'right' }] }, [row({ header: true }, [...]),\n * ...])`. Header rows come first and footer rows last.\n *\n * With `data` it builds a data-driven table instead: `table({ data: items,\n * columns: [{ key: 'name', header: 'Item' }, ...] })`, one row per item.\n */\nexport function table<Row extends object>(\n attributes: DataTableAttributes<Row>,\n): { t: 'table' } & TableNodeInput\nexport function table(\n attributes?: TableAttributes,\n rows?: readonly ({ t: 'row' } & RowNodeInput)[],\n): { t: 'table' } & TableNodeInput\nexport function table(\n attributes: TableAttributes | DataTableAttributes<object> = {},\n rows: readonly ({ t: 'row' } & RowNodeInput)[] = [],\n): { t: 'table' } & TableNodeInput {\n const result: { t: 'table' } & TableNodeInput = { t: 'table' }\n if (attributes.columns !== undefined) {\n result.columns = attributes.columns.map((column) => ({ ...column }))\n }\n if (attributes.data !== undefined) {\n const data = attributes as DataTableAttributes<object>\n result.data = data.data\n if (data.rowClassName !== undefined) {\n result.rowClassName = data.rowClassName\n }\n if (data.headerClassName !== undefined) {\n result.headerClassName = data.headerClassName\n }\n if (data.totals !== undefined) result.totals = { ...data.totals }\n }\n if (attributes.cellClassName !== undefined) {\n result.cellClassName = attributes.cellClassName\n }\n if (attributes.repeatHeader !== undefined) {\n result.repeatHeader = attributes.repeatHeader\n }\n if (attributes.repeatFooter !== undefined) {\n result.repeatFooter = attributes.repeatFooter\n }\n if (attributes.runningTotals !== undefined) {\n result.runningTotals = { ...attributes.runningTotals }\n }\n if (attributes.className !== undefined) {\n result.className = attributes.className\n }\n if (attributes.style !== undefined) result.style = attributes.style\n if (attributes.role !== undefined) result.role = attributes.role\n if (attributes.lang !== undefined) result.lang = attributes.lang\n if (attributes.dir !== undefined) result.dir = attributes.dir\n navigation(result, attributes)\n if (rows.length > 0) result.children = [...rows]\n return result\n}\n\n/** Builds a table row from its cells; `header` and `footer` mark the section. */\nexport function row(\n attributes: RowAttributes = {},\n cells: readonly ({ t: 'cell' } & CellNodeInput)[] = [],\n): { t: 'row' } & RowNodeInput {\n const result: { t: 'row' } & RowNodeInput = { t: 'row' }\n if (attributes.header !== undefined) result.header = attributes.header\n if (attributes.footer !== undefined) result.footer = attributes.footer\n if (attributes.className !== undefined) {\n result.className = attributes.className\n }\n if (attributes.style !== undefined) result.style = attributes.style\n if (cells.length > 0) result.children = [...cells]\n return result\n}\n\n/**\n * Builds a table cell: `cell({ colSpan: 2 }, [text('Total')])`, or with\n * text directly: `cell({ className: 'font-bold' }, 'Total')` (also with\n * placeholders: `cell({}, ['Page ', pageNumber()])`). A cell with a `value`\n * and no content shows the value in its column's format.\n */\nexport function cell(\n attributes: CellAttributes = {},\n content: readonly NodeInput[] | TextInput = [],\n): { t: 'cell' } & CellNodeInput {\n const result: { t: 'cell' } & CellNodeInput = { t: 'cell' }\n if (attributes.colSpan !== undefined) result.colSpan = attributes.colSpan\n if (attributes.rowSpan !== undefined) result.rowSpan = attributes.rowSpan\n if (attributes.value !== undefined) result.value = attributes.value\n if (attributes.className !== undefined) {\n result.className = attributes.className\n }\n if (attributes.style !== undefined) result.style = attributes.style\n if (attributes.role !== undefined) result.role = attributes.role\n if (attributes.scope !== undefined) result.scope = attributes.scope\n if (attributes.lang !== undefined) result.lang = attributes.lang\n if (attributes.dir !== undefined) result.dir = attributes.dir\n const children = isTextInput(content)\n ? [text(content)]\n : [...(content as readonly NodeInput[])]\n if (children.length > 0) result.children = children\n return result\n}\n"]}
@@ -0,0 +1,3 @@
1
+ /** Page template variants, in the order used by the render paths. */
2
+ export declare const pageVariantNames: readonly ['first', 'odd', 'even', 'last'];
3
+ //# sourceMappingURL=page-variants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-variants.d.ts","sourceRoot":"","sources":["../../web/src/ir/page-variants.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,eAAO,MAAM,gBAAgB,YAAI,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAU,CAAA"}
@@ -0,0 +1,3 @@
1
+ /** Page template variants, in the order used by the render paths. */
2
+ export const pageVariantNames = ['first', 'odd', 'even', 'last'];
3
+ //# sourceMappingURL=page-variants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-variants.js","sourceRoot":"","sources":["../../web/src/ir/page-variants.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAU,CAAA","sourcesContent":["/** Page template variants, in the order used by the render paths. */\nexport const pageVariantNames = ['first', 'odd', 'even', 'last'] as const\n"]}
@@ -1,4 +1,4 @@
1
- import type { PdfNode } from './element.ts';
1
+ import type { PdfNode } from './element.js';
2
2
  export interface ProviderProps<T> {
3
3
  readonly value: T;
4
4
  readonly children?: PdfNode;
@@ -1,7 +1,7 @@
1
- import type { SourceLocator } from '../../engine/Types/errors.ts';
2
- import type { Placeholder } from '../../ir/ir.generated.ts';
3
- import type { CellNodeInput, DocumentInput, NodeInput, PageInput, RowNodeInput } from '../../ir/Types/input.ts';
4
- import type { PdfElement } from './element.ts';
1
+ import type { SourceLocator } from '../../engine/Types/errors.js';
2
+ import type { Placeholder } from '../../ir/ir.generated.js';
3
+ import type { CellNodeInput, DocumentInput, NodeInput, PageInput, RowNodeInput } from '../../ir/Types/input.js';
4
+ import type { PdfElement } from './element.js';
5
5
  /** A rendered child before its parent places it. */
6
6
  export type Item = {
7
7
  readonly kind: 'document';
@@ -1,4 +1,4 @@
1
- import type { Component, Key, PdfElement } from './element.ts';
1
+ import type { Component, Key, PdfElement } from './element.js';
2
2
  export declare namespace JSX {
3
3
  /** What a JSX expression evaluates to: a lazy element. */
4
4
  type Element = PdfElement;
@@ -1,4 +1,4 @@
1
- import type { Context, Scope } from './Types/context.ts';
1
+ import type { Context, Scope } from './Types/context.js';
2
2
  /**
3
3
  * Creates a context with React-compatible naming, without React. Provide a
4
4
  * value with `<MyContext value={…}>` (or `<MyContext.Provider value={…}>`)
@@ -1,4 +1,4 @@
1
- import type { Component, PdfElement, PdfNode, SourceLocation } from './Types/element.ts';
1
+ import type { Component, PdfElement, PdfNode, SourceLocation } from './Types/element.js';
2
2
  /** Creates a lazy element; the JSX runtimes call this for every tag. */
3
3
  export declare function createElement<P extends object>(type: Component<P>, props: P, source?: SourceLocation): PdfElement;
4
4
  /** Whether a value is an element created by JSX or `jsx()`. */
@@ -1,6 +1,6 @@
1
- import type { DocumentInput } from '../ir/Types/input.ts';
2
- import type { PdfElement } from './Types/element.ts';
3
- import type { Evaluated } from './Types/evaluate.ts';
1
+ import type { DocumentInput } from '../ir/Types/input.js';
2
+ import type { PdfElement } from './Types/element.js';
3
+ import type { Evaluated } from './Types/evaluate.js';
4
4
  /** Evaluates an element tree; components may be `async`. */
5
5
  export declare function evaluate(element: PdfElement): Promise<Evaluated>;
6
6
  /** Evaluates an element tree synchronously; async components are errors. */
@@ -1 +1 @@
1
- {"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../web/src/jsx/evaluate.ts"],"names":[],"mappings":"AA8CA,OAAO,KAAK,EAER,aAAa,EAIhB,MAAM,sBAAsB,CAAA;AAK7B,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,oBAAoB,CAAA;AACpE,OAAO,KAAK,EACR,SAAS,EAIZ,MAAM,qBAAqB,CAAA;AA4uB5B,4DAA4D;AAC5D,wBAAsB,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAGtE;AAED,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,CAW3D;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CAE5E;AAED,gEAAgE;AAChE,wBAAgB,cAAc,CAAC,OAAO,EAAE,UAAU,GAAG,aAAa,CAEjE"}
1
+ {"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../web/src/jsx/evaluate.ts"],"names":[],"mappings":"AA+CA,OAAO,KAAK,EAAE,aAAa,EAAa,MAAM,sBAAsB,CAAA;AAKpE,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,oBAAoB,CAAA;AACpE,OAAO,KAAK,EACR,SAAS,EAIZ,MAAM,qBAAqB,CAAA;AA4tB5B,4DAA4D;AAC5D,wBAAsB,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAGtE;AAED,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,CAW3D;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CAE5E;AAED,gEAAgE;AAChE,wBAAgB,cAAc,CAAC,OAAO,EAAE,UAAU,GAAG,aAAa,CAEjE"}
@@ -5,6 +5,7 @@
5
5
  import { hostName } from '../components/host.js';
6
6
  import { RentnerPdfError } from '../engine/errors.js';
7
7
  import { anchor, cell, document, image, keep, link, marker, page, pageBreak, pageNumber, svg, row, table, text, totalPages, view, } from '../ir/factories.js';
8
+ import { pageVariantNames } from '../ir/page-variants.js';
8
9
  import { isContext, runInScope } from './context.js';
9
10
  import { Fragment, isElement } from './element.js';
10
11
  import { formatSource, hasSource, sourceOf } from './source.js';
@@ -209,7 +210,6 @@ function buildHost(name, element, scope, evaluation) {
209
210
  }
210
211
  return build(name, element, children, evaluation, regions);
211
212
  }
212
- const variantNames = ['first', 'odd', 'even', 'last'];
213
213
  /**
214
214
  * Evaluates a page's `header` and `footer` props and those of its
215
215
  * variants, which are elements like children.
@@ -241,7 +241,7 @@ function evaluateRegions(element, scope, evaluation) {
241
241
  if (footer !== undefined && footer !== null) {
242
242
  evaluateProp(footer, (items) => (result.footer = items));
243
243
  }
244
- for (const key of variantNames) {
244
+ for (const key of pageVariantNames) {
245
245
  const variant = Reflect.get(element.props, key);
246
246
  if (typeof variant !== 'object' || variant === null)
247
247
  continue;
@@ -265,7 +265,7 @@ function evaluateRegions(element, scope, evaluation) {
265
265
  * in a view; `undefined` without nodes.
266
266
  */
267
267
  const regionNode = (items, parent) => {
268
- const nodes = nodesOf(items, parent);
268
+ const nodes = collectChildren('node', items, parent);
269
269
  if (nodes.length <= 1)
270
270
  return nodes[0];
271
271
  return view({}, nodes);
@@ -275,7 +275,7 @@ const pageRegions = (props, regions, parent) => {
275
275
  if (regions === undefined)
276
276
  return props;
277
277
  const attributes = { ...props };
278
- for (const key of ['header', 'footer', ...variantNames]) {
278
+ for (const key of ['header', 'footer', ...pageVariantNames]) {
279
279
  Reflect.deleteProperty(attributes, key);
280
280
  }
281
281
  if (regions.header !== undefined) {
@@ -284,7 +284,7 @@ const pageRegions = (props, regions, parent) => {
284
284
  if (regions.footer !== undefined) {
285
285
  attributes.footer = regionNode(regions.footer, parent);
286
286
  }
287
- for (const key of variantNames) {
287
+ for (const key of pageVariantNames) {
288
288
  const evaluated = regions.variants[key];
289
289
  if (evaluated === undefined)
290
290
  continue;
@@ -313,21 +313,21 @@ function build(name, element, items, evaluation, regions) {
313
313
  case 'Document':
314
314
  item = {
315
315
  kind: 'document',
316
- value: document(props, pagesOf(items, element)),
316
+ value: document(props, collectChildren('page', items, element)),
317
317
  element,
318
318
  };
319
319
  break;
320
320
  case 'Page':
321
321
  item = {
322
322
  kind: 'page',
323
- value: page(pageRegions(props, regions, element), nodesOf(items, element)),
323
+ value: page(pageRegions(props, regions, element), collectChildren('node', items, element)),
324
324
  element,
325
325
  };
326
326
  break;
327
327
  case 'View':
328
328
  item = {
329
329
  kind: 'node',
330
- value: view(props, nodesOf(items, element)),
330
+ value: view(props, collectChildren('node', items, element)),
331
331
  element,
332
332
  };
333
333
  break;
@@ -357,7 +357,7 @@ function build(name, element, items, evaluation, regions) {
357
357
  case 'Link':
358
358
  item = {
359
359
  kind: 'node',
360
- value: link(props, nodesOf(items, element)),
360
+ value: link(props, collectChildren('node', items, element)),
361
361
  element,
362
362
  };
363
363
  break;
@@ -376,7 +376,7 @@ function build(name, element, items, evaluation, regions) {
376
376
  case 'Keep':
377
377
  item = {
378
378
  kind: 'node',
379
- value: keep(props, nodesOf(items, element)),
379
+ value: keep(props, collectChildren('node', items, element)),
380
380
  element,
381
381
  };
382
382
  break;
@@ -393,14 +393,14 @@ function build(name, element, items, evaluation, regions) {
393
393
  }
394
394
  item = {
395
395
  kind: 'node',
396
- value: table(props, rowsOf(items, element)),
396
+ value: table(props, collectChildren('row', items, element)),
397
397
  element,
398
398
  };
399
399
  break;
400
400
  case 'Row':
401
401
  item = {
402
402
  kind: 'row',
403
- value: row(props, cellsOf(items, element)),
403
+ value: row(props, collectChildren('cell', items, element)),
404
404
  element,
405
405
  };
406
406
  break;
@@ -471,50 +471,18 @@ const misplaced = (item, parent) => {
471
471
  }
472
472
  }
473
473
  };
474
- const pagesOf = (items, parent) => {
475
- const pages = [];
474
+ /** Collects children of one kind and ignores blank JSX text between them. */
475
+ function collectChildren(kind, items, parent) {
476
+ const children = [];
476
477
  for (const item of items) {
477
- if (item.kind === 'page')
478
- pages.push(item.value);
478
+ if (item.kind === kind)
479
+ children.push(item.value);
479
480
  else if (item.kind !== 'text' || !isBlank(item.value)) {
480
481
  throw misplaced(item, parent);
481
482
  }
482
483
  }
483
- return pages;
484
- };
485
- const nodesOf = (items, parent) => {
486
- const nodes = [];
487
- for (const item of items) {
488
- if (item.kind === 'node')
489
- nodes.push(item.value);
490
- else if (item.kind !== 'text' || !isBlank(item.value)) {
491
- throw misplaced(item, parent);
492
- }
493
- }
494
- return nodes;
495
- };
496
- const rowsOf = (items, parent) => {
497
- const rows = [];
498
- for (const item of items) {
499
- if (item.kind === 'row')
500
- rows.push(item.value);
501
- else if (item.kind !== 'text' || !isBlank(item.value)) {
502
- throw misplaced(item, parent);
503
- }
504
- }
505
- return rows;
506
- };
507
- const cellsOf = (items, parent) => {
508
- const cells = [];
509
- for (const item of items) {
510
- if (item.kind === 'cell')
511
- cells.push(item.value);
512
- else if (item.kind !== 'text' || !isBlank(item.value)) {
513
- throw misplaced(item, parent);
514
- }
515
- }
516
- return cells;
517
- };
484
+ return children;
485
+ }
518
486
  /**
519
487
  * A cell's content: content nodes, or strings, numbers and placeholders
520
488
  * joined into one text node (blank text alone is no content).
@@ -525,7 +493,7 @@ const cellContentOf = (items, parent) => {
525
493
  content.every((item) => item.kind === 'text' || item.kind === 'field')) {
526
494
  return textOf(items, parent);
527
495
  }
528
- return nodesOf(items, parent);
496
+ return collectChildren('node', items, parent);
529
497
  };
530
498
  /** `Image`, `Svg`, `Anchor` and `PageBreak` render no children; blank text is ignored. */
531
499
  const noChildren = (items, parent) => {