@rentnerkev/pdf 0.0.0-stage → 0.1.1

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 (355) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +135 -2
  3. package/THIRD_PARTY_NOTICES.md +152 -0
  4. package/dist/components/Types/host.d.ts +3 -0
  5. package/dist/components/Types/host.d.ts.map +1 -0
  6. package/dist/components/Types/host.js +2 -0
  7. package/dist/components/Types/host.js.map +1 -0
  8. package/dist/components/Types/props.d.ts +504 -0
  9. package/dist/components/Types/props.d.ts.map +1 -0
  10. package/dist/components/Types/props.js +2 -0
  11. package/dist/components/Types/props.js.map +1 -0
  12. package/dist/components/components.d.ts +87 -0
  13. package/dist/components/components.d.ts.map +1 -0
  14. package/dist/components/components.js +86 -0
  15. package/dist/components/components.js.map +1 -0
  16. package/dist/components/host.d.ts +7 -0
  17. package/dist/components/host.d.ts.map +1 -0
  18. package/dist/components/host.js +15 -0
  19. package/dist/components/host.js.map +1 -0
  20. package/dist/engine/Types/backend.d.ts +120 -0
  21. package/dist/engine/Types/backend.d.ts.map +1 -0
  22. package/dist/engine/Types/backend.js +2 -0
  23. package/dist/engine/Types/backend.js.map +1 -0
  24. package/dist/engine/Types/engine.d.ts +192 -0
  25. package/dist/engine/Types/engine.d.ts.map +1 -0
  26. package/dist/engine/Types/engine.js +2 -0
  27. package/dist/engine/Types/engine.js.map +1 -0
  28. package/dist/engine/Types/errors.d.ts +16 -0
  29. package/dist/engine/Types/errors.d.ts.map +1 -0
  30. package/dist/engine/Types/errors.js +2 -0
  31. package/dist/engine/Types/errors.js.map +1 -0
  32. package/dist/engine/Types/limits.d.ts +55 -0
  33. package/dist/engine/Types/limits.d.ts.map +1 -0
  34. package/dist/engine/Types/limits.js +2 -0
  35. package/dist/engine/Types/limits.js.map +1 -0
  36. package/dist/engine/Types/render-options.d.ts +71 -0
  37. package/dist/engine/Types/render-options.d.ts.map +1 -0
  38. package/dist/engine/Types/render-options.js +2 -0
  39. package/dist/engine/Types/render-options.js.map +1 -0
  40. package/dist/engine/Types/render-result.d.ts +80 -0
  41. package/dist/engine/Types/render-result.d.ts.map +1 -0
  42. package/dist/engine/Types/render-result.js +2 -0
  43. package/dist/engine/Types/render-result.js.map +1 -0
  44. package/dist/engine/abort.d.ts +23 -0
  45. package/dist/engine/abort.d.ts.map +1 -0
  46. package/dist/engine/abort.js +71 -0
  47. package/dist/engine/abort.js.map +1 -0
  48. package/dist/engine/assets.d.ts +22 -0
  49. package/dist/engine/assets.d.ts.map +1 -0
  50. package/dist/engine/assets.js +40 -0
  51. package/dist/engine/assets.js.map +1 -0
  52. package/dist/engine/backend.d.ts +16 -0
  53. package/dist/engine/backend.d.ts.map +1 -0
  54. package/dist/engine/backend.js +43 -0
  55. package/dist/engine/backend.js.map +1 -0
  56. package/dist/engine/backends/native.d.ts +11 -0
  57. package/dist/engine/backends/native.d.ts.map +1 -0
  58. package/dist/engine/backends/native.js +62 -0
  59. package/dist/engine/backends/native.js.map +1 -0
  60. package/dist/engine/backends/wasm.d.ts +16 -0
  61. package/dist/engine/backends/wasm.d.ts.map +1 -0
  62. package/dist/engine/backends/wasm.js +216 -0
  63. package/dist/engine/backends/wasm.js.map +1 -0
  64. package/dist/engine/channel.d.ts +41 -0
  65. package/dist/engine/channel.d.ts.map +1 -0
  66. package/dist/engine/channel.js +140 -0
  67. package/dist/engine/channel.js.map +1 -0
  68. package/dist/engine/create-engine.d.ts +8 -0
  69. package/dist/engine/create-engine.d.ts.map +1 -0
  70. package/dist/engine/create-engine.js +120 -0
  71. package/dist/engine/create-engine.js.map +1 -0
  72. package/dist/engine/default-fonts.d.ts +9 -0
  73. package/dist/engine/default-fonts.d.ts.map +1 -0
  74. package/dist/engine/default-fonts.js +42 -0
  75. package/dist/engine/default-fonts.js.map +1 -0
  76. package/dist/engine/encode.d.ts +9 -0
  77. package/dist/engine/encode.d.ts.map +1 -0
  78. package/dist/engine/encode.js +199 -0
  79. package/dist/engine/encode.js.map +1 -0
  80. package/dist/engine/errors.d.ts +37 -0
  81. package/dist/engine/errors.d.ts.map +1 -0
  82. package/dist/engine/errors.js +71 -0
  83. package/dist/engine/errors.js.map +1 -0
  84. package/dist/engine/fonts.d.ts +9 -0
  85. package/dist/engine/fonts.d.ts.map +1 -0
  86. package/dist/engine/fonts.js +14 -0
  87. package/dist/engine/fonts.js.map +1 -0
  88. package/dist/engine/lifecycle.d.ts +40 -0
  89. package/dist/engine/lifecycle.d.ts.map +1 -0
  90. package/dist/engine/lifecycle.js +104 -0
  91. package/dist/engine/lifecycle.js.map +1 -0
  92. package/dist/engine/markup.d.ts +13 -0
  93. package/dist/engine/markup.d.ts.map +1 -0
  94. package/dist/engine/markup.js +14 -0
  95. package/dist/engine/markup.js.map +1 -0
  96. package/dist/engine/options.d.ts +12 -0
  97. package/dist/engine/options.d.ts.map +1 -0
  98. package/dist/engine/options.js +71 -0
  99. package/dist/engine/options.js.map +1 -0
  100. package/dist/engine/pdf-bytes.d.ts +8 -0
  101. package/dist/engine/pdf-bytes.d.ts.map +1 -0
  102. package/dist/engine/pdf-bytes.js +9 -0
  103. package/dist/engine/pdf-bytes.js.map +1 -0
  104. package/dist/engine/prepare.d.ts +17 -0
  105. package/dist/engine/prepare.d.ts.map +1 -0
  106. package/dist/engine/prepare.js +44 -0
  107. package/dist/engine/prepare.js.map +1 -0
  108. package/dist/engine/render-many.d.ts +14 -0
  109. package/dist/engine/render-many.d.ts.map +1 -0
  110. package/dist/engine/render-many.js +156 -0
  111. package/dist/engine/render-many.js.map +1 -0
  112. package/dist/engine/render-result.d.ts +12 -0
  113. package/dist/engine/render-result.d.ts.map +1 -0
  114. package/dist/engine/render-result.js +62 -0
  115. package/dist/engine/render-result.js.map +1 -0
  116. package/dist/engine/render-stream.d.ts +7 -0
  117. package/dist/engine/render-stream.d.ts.map +1 -0
  118. package/dist/engine/render-stream.js +56 -0
  119. package/dist/engine/render-stream.js.map +1 -0
  120. package/dist/engine/render.d.ts +15 -0
  121. package/dist/engine/render.d.ts.map +1 -0
  122. package/dist/engine/render.js +23 -0
  123. package/dist/engine/render.js.map +1 -0
  124. package/dist/fonts/NotoSans-Bold.ttf +0 -0
  125. package/dist/fonts/NotoSans-BoldItalic.ttf +0 -0
  126. package/dist/fonts/NotoSans-Italic.ttf +0 -0
  127. package/dist/fonts/NotoSans-Regular.ttf +0 -0
  128. package/dist/fonts/OFL.txt +94 -0
  129. package/dist/fonts/sources.json +32 -0
  130. package/dist/index.d.ts +26 -0
  131. package/dist/index.d.ts.map +1 -0
  132. package/dist/index.js +11 -0
  133. package/dist/index.js.map +1 -0
  134. package/dist/ir/Types/input.d.ts +111 -0
  135. package/dist/ir/Types/input.d.ts.map +1 -0
  136. package/dist/ir/Types/input.js +2 -0
  137. package/dist/ir/Types/input.js.map +1 -0
  138. package/dist/ir/factories.d.ts +108 -0
  139. package/dist/ir/factories.d.ts.map +1 -0
  140. package/dist/ir/factories.js +410 -0
  141. package/dist/ir/factories.js.map +1 -0
  142. package/dist/ir/ir.generated.d.ts +811 -0
  143. package/dist/ir/ir.generated.d.ts.map +1 -0
  144. package/dist/ir/ir.generated.js +4 -0
  145. package/dist/ir/ir.generated.js.map +1 -0
  146. package/dist/ir/version.d.ts +9 -0
  147. package/dist/ir/version.d.ts.map +1 -0
  148. package/dist/ir/version.js +13 -0
  149. package/dist/ir/version.js.map +1 -0
  150. package/dist/jsx/Types/context.d.ts +24 -0
  151. package/dist/jsx/Types/context.d.ts.map +1 -0
  152. package/dist/jsx/Types/context.js +2 -0
  153. package/dist/jsx/Types/context.js.map +1 -0
  154. package/dist/jsx/Types/element.d.ts +30 -0
  155. package/dist/jsx/Types/element.d.ts.map +1 -0
  156. package/dist/jsx/Types/element.js +2 -0
  157. package/dist/jsx/Types/element.js.map +1 -0
  158. package/dist/jsx/Types/evaluate.d.ts +61 -0
  159. package/dist/jsx/Types/evaluate.d.ts.map +1 -0
  160. package/dist/jsx/Types/evaluate.js +2 -0
  161. package/dist/jsx/Types/evaluate.js.map +1 -0
  162. package/dist/jsx/Types/jsx.d.ts +16 -0
  163. package/dist/jsx/Types/jsx.d.ts.map +1 -0
  164. package/dist/jsx/Types/jsx.js +2 -0
  165. package/dist/jsx/Types/jsx.js.map +1 -0
  166. package/dist/jsx/context.d.ts +21 -0
  167. package/dist/jsx/context.d.ts.map +1 -0
  168. package/dist/jsx/context.js +49 -0
  169. package/dist/jsx/context.js.map +1 -0
  170. package/dist/jsx/element.d.ts +10 -0
  171. package/dist/jsx/element.d.ts.map +1 -0
  172. package/dist/jsx/element.js +19 -0
  173. package/dist/jsx/element.js.map +1 -0
  174. package/dist/jsx/evaluate.d.ts +16 -0
  175. package/dist/jsx/evaluate.d.ts.map +1 -0
  176. package/dist/jsx/evaluate.js +616 -0
  177. package/dist/jsx/evaluate.js.map +1 -0
  178. package/dist/jsx/source.d.ts +13 -0
  179. package/dist/jsx/source.d.ts.map +1 -0
  180. package/dist/jsx/source.js +49 -0
  181. package/dist/jsx/source.js.map +1 -0
  182. package/dist/jsx-dev-runtime.d.ts +9 -0
  183. package/dist/jsx-dev-runtime.d.ts.map +1 -0
  184. package/dist/jsx-dev-runtime.js +24 -0
  185. package/dist/jsx-dev-runtime.js.map +1 -0
  186. package/dist/jsx-runtime.d.ts +12 -0
  187. package/dist/jsx-runtime.d.ts.map +1 -0
  188. package/dist/jsx-runtime.js +15 -0
  189. package/dist/jsx-runtime.js.map +1 -0
  190. package/dist/native/binding.generated.d.ts +227 -0
  191. package/dist/native/loader.d.ts +22 -0
  192. package/dist/native/loader.d.ts.map +1 -0
  193. package/dist/native/loader.js +98 -0
  194. package/dist/native/loader.js.map +1 -0
  195. package/dist/native/rentnerpdf.linux-arm64-gnu.node +0 -0
  196. package/dist/native/rentnerpdf.linux-arm64-musl.node +0 -0
  197. package/dist/native/rentnerpdf.linux-x64-gnu.node +0 -0
  198. package/dist/native/rentnerpdf.linux-x64-musl.node +0 -0
  199. package/dist/native/rentnerpdf.win32-arm64-msvc.node +0 -0
  200. package/dist/native/rentnerpdf.win32-x64-msvc.node +0 -0
  201. package/dist/node.d.ts +3 -0
  202. package/dist/node.d.ts.map +1 -0
  203. package/dist/node.js +6 -0
  204. package/dist/node.js.map +1 -0
  205. package/dist/react/Types/preview.d.ts +74 -0
  206. package/dist/react/Types/preview.d.ts.map +1 -0
  207. package/dist/react/Types/preview.js +2 -0
  208. package/dist/react/Types/preview.js.map +1 -0
  209. package/dist/react/Types/render.d.ts +24 -0
  210. package/dist/react/Types/render.d.ts.map +1 -0
  211. package/dist/react/Types/render.js +2 -0
  212. package/dist/react/Types/render.js.map +1 -0
  213. package/dist/react/attributes.d.ts +8 -0
  214. package/dist/react/attributes.d.ts.map +1 -0
  215. package/dist/react/attributes.js +44 -0
  216. package/dist/react/attributes.js.map +1 -0
  217. package/dist/react/components.d.ts +60 -0
  218. package/dist/react/components.d.ts.map +1 -0
  219. package/dist/react/components.js +266 -0
  220. package/dist/react/components.js.map +1 -0
  221. package/dist/react/pdf-preview.d.ts +16 -0
  222. package/dist/react/pdf-preview.d.ts.map +1 -0
  223. package/dist/react/pdf-preview.js +26 -0
  224. package/dist/react/pdf-preview.js.map +1 -0
  225. package/dist/react/pdf-render.d.ts +15 -0
  226. package/dist/react/pdf-render.d.ts.map +1 -0
  227. package/dist/react/pdf-render.js +60 -0
  228. package/dist/react/pdf-render.js.map +1 -0
  229. package/dist/react/registry.d.ts +44 -0
  230. package/dist/react/registry.d.ts.map +1 -0
  231. package/dist/react/registry.js +105 -0
  232. package/dist/react/registry.js.map +1 -0
  233. package/dist/react/render.d.ts +36 -0
  234. package/dist/react/render.d.ts.map +1 -0
  235. package/dist/react/render.js +212 -0
  236. package/dist/react/render.js.map +1 -0
  237. package/dist/react/same-document.d.ts +8 -0
  238. package/dist/react/same-document.d.ts.map +1 -0
  239. package/dist/react/same-document.js +59 -0
  240. package/dist/react/same-document.js.map +1 -0
  241. package/dist/react/static.d.ts +13 -0
  242. package/dist/react/static.d.ts.map +1 -0
  243. package/dist/react/static.js +65 -0
  244. package/dist/react/static.js.map +1 -0
  245. package/dist/react/use-pdf.d.ts +25 -0
  246. package/dist/react/use-pdf.d.ts.map +1 -0
  247. package/dist/react/use-pdf.js +59 -0
  248. package/dist/react/use-pdf.js.map +1 -0
  249. package/dist/react.d.ts +9 -0
  250. package/dist/react.d.ts.map +1 -0
  251. package/dist/react.js +10 -0
  252. package/dist/react.js.map +1 -0
  253. package/dist/tailwind/Types/merge-config.d.ts +28 -0
  254. package/dist/tailwind/Types/merge-config.d.ts.map +1 -0
  255. package/dist/tailwind/Types/merge-config.js +2 -0
  256. package/dist/tailwind/Types/merge-config.js.map +1 -0
  257. package/dist/tailwind/merge-config.d.ts +45 -0
  258. package/dist/tailwind/merge-config.d.ts.map +1 -0
  259. package/dist/tailwind/merge-config.js +46 -0
  260. package/dist/tailwind/merge-config.js.map +1 -0
  261. package/dist/tailwind-merge.d.ts +3 -0
  262. package/dist/tailwind-merge.d.ts.map +1 -0
  263. package/dist/tailwind-merge.js +4 -0
  264. package/dist/tailwind-merge.js.map +1 -0
  265. package/dist/tailwind.css +61 -0
  266. package/dist/theme/Types/css-imports.d.ts +38 -0
  267. package/dist/theme/Types/css-imports.d.ts.map +1 -0
  268. package/dist/theme/Types/css-imports.js +2 -0
  269. package/dist/theme/Types/css-imports.js.map +1 -0
  270. package/dist/theme/Types/theme.d.ts +70 -0
  271. package/dist/theme/Types/theme.d.ts.map +1 -0
  272. package/dist/theme/Types/theme.js +2 -0
  273. package/dist/theme/Types/theme.js.map +1 -0
  274. package/dist/theme/Types/warnings.d.ts +9 -0
  275. package/dist/theme/Types/warnings.d.ts.map +1 -0
  276. package/dist/theme/Types/warnings.js +2 -0
  277. package/dist/theme/Types/warnings.js.map +1 -0
  278. package/dist/theme/css-imports.d.ts +11 -0
  279. package/dist/theme/css-imports.d.ts.map +1 -0
  280. package/dist/theme/css-imports.js +138 -0
  281. package/dist/theme/css-imports.js.map +1 -0
  282. package/dist/theme/normalize.d.ts +15 -0
  283. package/dist/theme/normalize.d.ts.map +1 -0
  284. package/dist/theme/normalize.js +51 -0
  285. package/dist/theme/normalize.js.map +1 -0
  286. package/dist/theme/package-imports.d.ts +16 -0
  287. package/dist/theme/package-imports.d.ts.map +1 -0
  288. package/dist/theme/package-imports.js +90 -0
  289. package/dist/theme/package-imports.js.map +1 -0
  290. package/dist/theme/theme-from-css-file.d.ts +35 -0
  291. package/dist/theme/theme-from-css-file.d.ts.map +1 -0
  292. package/dist/theme/theme-from-css-file.js +223 -0
  293. package/dist/theme/theme-from-css-file.js.map +1 -0
  294. package/dist/theme/theme-from-css.d.ts +28 -0
  295. package/dist/theme/theme-from-css.d.ts.map +1 -0
  296. package/dist/theme/theme-from-css.js +62 -0
  297. package/dist/theme/theme-from-css.js.map +1 -0
  298. package/dist/theme/warnings.d.ts +13 -0
  299. package/dist/theme/warnings.d.ts.map +1 -0
  300. package/dist/theme/warnings.js +34 -0
  301. package/dist/theme/warnings.js.map +1 -0
  302. package/dist/vite/Types/plugin.d.ts +47 -0
  303. package/dist/vite/Types/plugin.d.ts.map +1 -0
  304. package/dist/vite/Types/plugin.js +5 -0
  305. package/dist/vite/Types/plugin.js.map +1 -0
  306. package/dist/vite/plugin.d.ts +30 -0
  307. package/dist/vite/plugin.d.ts.map +1 -0
  308. package/dist/vite/plugin.js +80 -0
  309. package/dist/vite/plugin.js.map +1 -0
  310. package/dist/vite.d.ts +3 -0
  311. package/dist/vite.d.ts.map +1 -0
  312. package/dist/vite.js +6 -0
  313. package/dist/vite.js.map +1 -0
  314. package/dist/wasm/binding.generated.d.ts +259 -0
  315. package/dist/wasm/loader.d.ts +17 -0
  316. package/dist/wasm/loader.d.ts.map +1 -0
  317. package/dist/wasm/loader.js +74 -0
  318. package/dist/wasm/loader.js.map +1 -0
  319. package/dist/wasm/pkg/rentnerpdf_wasm.d.ts +259 -0
  320. package/dist/wasm/pkg/rentnerpdf_wasm.js +883 -0
  321. package/dist/wasm/pkg/rentnerpdf_wasm_bg.wasm +0 -0
  322. package/dist/wasm/pkg/rentnerpdf_wasm_bg.wasm.d.ts +40 -0
  323. package/dist/worker/Types/connection.d.ts +25 -0
  324. package/dist/worker/Types/connection.d.ts.map +1 -0
  325. package/dist/worker/Types/connection.js +2 -0
  326. package/dist/worker/Types/connection.js.map +1 -0
  327. package/dist/worker/Types/protocol.d.ts +62 -0
  328. package/dist/worker/Types/protocol.d.ts.map +1 -0
  329. package/dist/worker/Types/protocol.js +2 -0
  330. package/dist/worker/Types/protocol.js.map +1 -0
  331. package/dist/worker/Types/worker-engine.d.ts +91 -0
  332. package/dist/worker/Types/worker-engine.d.ts.map +1 -0
  333. package/dist/worker/Types/worker-engine.js +2 -0
  334. package/dist/worker/Types/worker-engine.js.map +1 -0
  335. package/dist/worker/client.d.ts +20 -0
  336. package/dist/worker/client.d.ts.map +1 -0
  337. package/dist/worker/client.js +131 -0
  338. package/dist/worker/client.js.map +1 -0
  339. package/dist/worker/connection.d.ts +5 -0
  340. package/dist/worker/connection.d.ts.map +1 -0
  341. package/dist/worker/connection.js +119 -0
  342. package/dist/worker/connection.js.map +1 -0
  343. package/dist/worker/protocol.d.ts +24 -0
  344. package/dist/worker/protocol.d.ts.map +1 -0
  345. package/dist/worker/protocol.js +71 -0
  346. package/dist/worker/protocol.js.map +1 -0
  347. package/dist/worker/serve.d.ts +26 -0
  348. package/dist/worker/serve.d.ts.map +1 -0
  349. package/dist/worker/serve.js +119 -0
  350. package/dist/worker/serve.js.map +1 -0
  351. package/dist/worker.d.ts +4 -0
  352. package/dist/worker.d.ts.map +1 -0
  353. package/dist/worker.js +8 -0
  354. package/dist/worker.js.map +1 -0
  355. package/package.json +80 -5
@@ -0,0 +1,108 @@
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';
4
+ /** A text's content: one string, or strings and placeholders. */
5
+ export type TextInput = TextValue | Placeholder | readonly (TextValue | Placeholder)[];
6
+ /** Builds an IR document from metadata and pages. */
7
+ export declare function document(attributes?: DocumentAttributes, pages?: readonly PageInput[]): DocumentInput & {
8
+ v: number;
9
+ };
10
+ /**
11
+ * Builds a page template from its attributes, header, footer, variants and
12
+ * child nodes: `page({ footer: text(['Page ', pageNumber()]) }, [...])`.
13
+ */
14
+ export declare function page(attributes?: PageAttributes & PageRegionProps<NodeInput>, children?: readonly NodeInput[]): PageInput;
15
+ /** Builds a view node (a block, flex or grid box) with its children. */
16
+ export declare function view(attributes?: ViewAttributes, children?: readonly NodeInput[]): {
17
+ t: 'view';
18
+ } & ViewNodeInput;
19
+ /**
20
+ * Builds a text node: `text('Hello')`, `text({ className: 'text-sm' },
21
+ * 'Hello')` or with placeholders `text(['Page ', pageNumber(), ' of ',
22
+ * totalPages()])`.
23
+ */
24
+ export declare function text(content: TextInput): {
25
+ t: 'text';
26
+ } & TextNode;
27
+ export declare function text(attributes: TextAttributes, content?: TextInput): {
28
+ t: 'text';
29
+ } & TextNode;
30
+ /** The number of the page the text is on: `text(['Page ', pageNumber()])`. */
31
+ export declare function pageNumber(attributes?: PageNumberProps): Placeholder;
32
+ /** The number of pages of the document, or of the template (`scope: 'section'`). */
33
+ export declare function totalPages(attributes?: TotalPagesProps): Placeholder;
34
+ /** The value of running marker `name` on the page, for example the chapter. */
35
+ export declare function marker({ name, select }: MarkerProps): Placeholder;
36
+ /**
37
+ * Builds an image node from its bytes: `image({ src, alt: 'Logo',
38
+ * className: 'w-32' })`. The bytes travel to the engine next to the JSON.
39
+ */
40
+ export declare function image(attributes: ImageAttributes): {
41
+ t: 'image';
42
+ } & ImageNodeInput;
43
+ /**
44
+ * Builds an SVG node from its markup or file bytes: `svg({ src: '<svg …>',
45
+ * className: 'w-48' })`. The markup travels to the engine next to the JSON.
46
+ */
47
+ export declare function svg(attributes: SvgAttributes): {
48
+ t: 'svg';
49
+ } & SvgNodeInput;
50
+ /**
51
+ * Builds a link: a view with `href` around `children`, for example
52
+ * `link({ href: 'https://example.com' }, [text('Website')])` or
53
+ * `link({ href: '#terms' }, …)`.
54
+ */
55
+ export declare function link({ href, ...attributes }: LinkAttributes, children?: readonly NodeInput[]): {
56
+ t: 'view';
57
+ } & ViewNodeInput;
58
+ /** Builds an anchor: an empty view with `id`, the target of `#id` links. */
59
+ export declare function anchor({ id, bookmark, }: AnchorAttributes): {
60
+ t: 'view';
61
+ } & ViewNodeInput;
62
+ /**
63
+ * Builds a page break: an empty view with `break-after-page`, so the content
64
+ * after it starts on a new page. At the end of the content it adds no page.
65
+ */
66
+ export declare function pageBreak(): {
67
+ t: 'view';
68
+ } & ViewNodeInput;
69
+ /**
70
+ * Builds a keep-together group: a view with `break-inside-avoid` (and
71
+ * `break-after-avoid` with `withNext`) around `children`. The classes come
72
+ * first, so the group's own `className` can override them.
73
+ */
74
+ export declare function keep({ withNext, className, ...attributes }?: KeepAttributes, children?: readonly NodeInput[]): {
75
+ t: 'view';
76
+ } & ViewNodeInput;
77
+ /**
78
+ * Builds a table from its rows: `table({ columns: [{ width: '1fr' },
79
+ * { width: '30mm', align: 'right' }] }, [row({ header: true }, [...]),
80
+ * ...])`. Header rows come first and footer rows last.
81
+ *
82
+ * With `data` it builds a data-driven table instead: `table({ data: items,
83
+ * columns: [{ key: 'name', header: 'Item' }, ...] })`, one row per item.
84
+ */
85
+ export declare function table<Row extends object>(attributes: DataTableAttributes<Row>): {
86
+ t: 'table';
87
+ } & TableNodeInput;
88
+ export declare function table(attributes?: TableAttributes, rows?: readonly ({
89
+ t: 'row';
90
+ } & RowNodeInput)[]): {
91
+ t: 'table';
92
+ } & TableNodeInput;
93
+ /** Builds a table row from its cells; `header` and `footer` mark the section. */
94
+ export declare function row(attributes?: RowAttributes, cells?: readonly ({
95
+ t: 'cell';
96
+ } & CellNodeInput)[]): {
97
+ t: 'row';
98
+ } & RowNodeInput;
99
+ /**
100
+ * Builds a table cell: `cell({ colSpan: 2 }, [text('Total')])`, or with
101
+ * text directly: `cell({ className: 'font-bold' }, 'Total')` (also with
102
+ * placeholders: `cell({}, ['Page ', pageNumber()])`). A cell with a `value`
103
+ * and no content shows the value in its column's format.
104
+ */
105
+ export declare function cell(attributes?: CellAttributes, content?: readonly NodeInput[] | TextInput): {
106
+ t: 'cell';
107
+ } & CellNodeInput;
108
+ //# sourceMappingURL=factories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factories.d.ts","sourceRoot":"","sources":["../../web/src/ir/factories.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACR,gBAAgB,EAGhB,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,cAAc,EAEd,WAAW,EAEX,cAAc,EACd,eAAe,EACf,eAAe,EAEf,aAAa,EACb,aAAa,EACb,eAAe,EACf,cAAc,EAEd,SAAS,EACT,eAAe,EACf,cAAc,EACjB,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAIR,WAAW,EACX,QAAQ,EAGX,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAER,aAAa,EACb,aAAa,EACb,cAAc,EAEd,SAAS,EACT,SAAS,EAET,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,aAAa,EAChB,MAAM,kBAAkB,CAAA;AAyEzB,iEAAiE;AACjE,MAAM,MAAM,SAAS,GACjB,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC,SAAS,GAAG,WAAW,CAAC,EAAE,CAAA;AAgElE,qDAAqD;AACrD,wBAAgB,QAAQ,CACpB,UAAU,GAAE,kBAAuB,EACnC,KAAK,GAAE,SAAS,SAAS,EAAO,GACjC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MAAM,CAAA;CAAE,GAAG,aAAa,CAkB/B"}
@@ -0,0 +1,410 @@
1
+ import { IR_VERSION } from './version.js';
2
+ /** A `Date` as ISO 8601 in UTC; an invalid date fails in the engine. */
3
+ const isoDate = (date) => typeof date === 'string' || Number.isNaN(date.getTime())
4
+ ? String(date)
5
+ : date.toISOString();
6
+ const meta = ({ title, author, subject, keywords, lang, dir, creator, creationDate, }) => {
7
+ const result = {};
8
+ if (title !== undefined)
9
+ result.title = title;
10
+ if (author !== undefined)
11
+ result.author = author;
12
+ if (subject !== undefined)
13
+ result.subject = subject;
14
+ if (keywords !== undefined)
15
+ result.keywords = [...keywords];
16
+ if (lang !== undefined)
17
+ result.lang = lang;
18
+ if (dir !== undefined)
19
+ result.dir = dir;
20
+ if (creator !== undefined)
21
+ result.creator = creator;
22
+ if (creationDate !== undefined) {
23
+ result.creationDate = isoDate(creationDate);
24
+ }
25
+ return Object.keys(result).length === 0 ? undefined : result;
26
+ };
27
+ const bookmarkOf = (input) => {
28
+ if (input === false)
29
+ return false;
30
+ if (typeof input === 'string')
31
+ return { title: input };
32
+ const result = {};
33
+ if (input.title !== undefined)
34
+ result.title = input.title;
35
+ if (input.level !== undefined)
36
+ result.level = input.level;
37
+ return result;
38
+ };
39
+ /** Copies `id` and `bookmark` onto an IR node. */
40
+ const navigation = (target, { id, bookmark }) => {
41
+ if (id !== undefined)
42
+ target.id = id;
43
+ if (bookmark !== undefined)
44
+ target.bookmark = bookmarkOf(bookmark);
45
+ };
46
+ /** Copies `marker` onto an IR node as its `markers`. */
47
+ const markersOf = (input) => {
48
+ if (input === undefined)
49
+ return undefined;
50
+ const list = (Array.isArray(input) ? input : [input]);
51
+ return list.map((entry) => typeof entry === 'string'
52
+ ? { name: entry }
53
+ : entry.value === undefined
54
+ ? { name: entry.name }
55
+ : { name: entry.name, value: entry.value });
56
+ };
57
+ const placeholderKinds = new Set([
58
+ 'pageNumber',
59
+ 'totalPages',
60
+ 'marker',
61
+ ]);
62
+ const isPlaceholder = (value) => typeof value === 'object' &&
63
+ value !== null &&
64
+ placeholderKinds.has(Reflect.get(value, 't'));
65
+ /** Whether a cell's content is text (strings, numbers, placeholders). */
66
+ const isTextInput = (content) => !Array.isArray(content)
67
+ ? true
68
+ : content.length > 0 &&
69
+ content.every((part) => typeof part !== 'object' || isPlaceholder(part));
70
+ /** Joins adjacent strings; plain text stays a string. */
71
+ const textContent = (input) => {
72
+ const parts = [];
73
+ const list = Array.isArray(input)
74
+ ? input
75
+ : [input];
76
+ for (const part of list) {
77
+ if (isPlaceholder(part)) {
78
+ parts.push({ ...part });
79
+ continue;
80
+ }
81
+ const value = String(part);
82
+ const last = parts.at(-1);
83
+ if (typeof last === 'string')
84
+ parts[parts.length - 1] = last + value;
85
+ else if (value !== '')
86
+ parts.push(value);
87
+ }
88
+ if (parts.every((part) => typeof part === 'string'))
89
+ return parts.join('');
90
+ return parts;
91
+ };
92
+ const letterheadOf = ({ src, page: index, }) => index === undefined ? { src } : { src, page: index };
93
+ const variantOf = (variant) => {
94
+ const result = {};
95
+ if (variant.header !== undefined)
96
+ result.header = variant.header;
97
+ if (variant.footer !== undefined)
98
+ result.footer = variant.footer;
99
+ if (variant.letterhead !== undefined) {
100
+ result.letterhead =
101
+ variant.letterhead === null
102
+ ? null
103
+ : letterheadOf(variant.letterhead);
104
+ }
105
+ return result;
106
+ };
107
+ /** Builds an IR document from metadata and pages. */
108
+ export function document(attributes = {}, pages = []) {
109
+ const documentMeta = meta(attributes);
110
+ const result = documentMeta === undefined
111
+ ? { v: IR_VERSION, pages: [...pages] }
112
+ : { v: IR_VERSION, meta: documentMeta, pages: [...pages] };
113
+ const { standard, attachments, facturX, tagged } = attributes;
114
+ if (standard !== undefined) {
115
+ result.standards =
116
+ typeof standard === 'string' ? [standard] : [...standard];
117
+ }
118
+ if (attachments !== undefined) {
119
+ result.attachments = attachments.map(attachmentOf);
120
+ }
121
+ if (facturX !== undefined)
122
+ result.facturX = { ...facturX };
123
+ if (tagged !== undefined)
124
+ result.tagged = tagged;
125
+ return result;
126
+ }
127
+ /** An attachment with its date as ISO 8601. */
128
+ const attachmentOf = ({ modificationDate, ...rest }) => modificationDate === undefined
129
+ ? { ...rest }
130
+ : { ...rest, modificationDate: isoDate(modificationDate) };
131
+ /**
132
+ * Builds a page template from its attributes, header, footer, variants and
133
+ * child nodes: `page({ footer: text(['Page ', pageNumber()]) }, [...])`.
134
+ */
135
+ export function page(attributes = {}, children = []) {
136
+ const result = {};
137
+ if (attributes.size !== undefined)
138
+ result.size = attributes.size;
139
+ if (attributes.orientation !== undefined) {
140
+ result.orientation = attributes.orientation;
141
+ }
142
+ if (attributes.letterhead !== undefined) {
143
+ result.letterhead = letterheadOf(attributes.letterhead);
144
+ }
145
+ if (attributes.className !== undefined) {
146
+ result.className = attributes.className;
147
+ }
148
+ if (attributes.style !== undefined)
149
+ result.style = attributes.style;
150
+ if (attributes.numbering !== undefined) {
151
+ result.numbering = { ...attributes.numbering };
152
+ }
153
+ if (attributes.header !== undefined)
154
+ result.header = attributes.header;
155
+ if (attributes.footer !== undefined)
156
+ result.footer = attributes.footer;
157
+ for (const key of ['first', 'odd', 'even', 'last']) {
158
+ const variant = attributes[key];
159
+ if (variant !== undefined)
160
+ result[key] = variantOf(variant);
161
+ }
162
+ if (children.length > 0)
163
+ result.children = [...children];
164
+ return result;
165
+ }
166
+ /** Builds a view node (a block, flex or grid box) with its children. */
167
+ export function view(attributes = {}, children = []) {
168
+ const result = { t: 'view' };
169
+ if (attributes.className !== undefined) {
170
+ result.className = attributes.className;
171
+ }
172
+ if (attributes.style !== undefined)
173
+ result.style = attributes.style;
174
+ if (attributes.role !== undefined)
175
+ result.role = attributes.role;
176
+ if (attributes.alt !== undefined)
177
+ result.alt = attributes.alt;
178
+ if (attributes.lang !== undefined)
179
+ result.lang = attributes.lang;
180
+ if (attributes.dir !== undefined)
181
+ result.dir = attributes.dir;
182
+ navigation(result, attributes);
183
+ const markers = markersOf(attributes.marker);
184
+ if (markers !== undefined)
185
+ result.markers = markers;
186
+ if (children.length > 0)
187
+ result.children = [...children];
188
+ return result;
189
+ }
190
+ export function text(first, content = '') {
191
+ if (typeof first !== 'object' ||
192
+ Array.isArray(first) ||
193
+ isPlaceholder(first)) {
194
+ return { t: 'text', text: textContent(first) };
195
+ }
196
+ const attributes = first;
197
+ const result = {
198
+ t: 'text',
199
+ text: textContent(content),
200
+ };
201
+ if (attributes.className !== undefined) {
202
+ result.className = attributes.className;
203
+ }
204
+ if (attributes.style !== undefined)
205
+ result.style = attributes.style;
206
+ if (attributes.role !== undefined)
207
+ result.role = attributes.role;
208
+ if (attributes.lang !== undefined)
209
+ result.lang = attributes.lang;
210
+ if (attributes.dir !== undefined)
211
+ result.dir = attributes.dir;
212
+ if (attributes.alt !== undefined)
213
+ result.alt = attributes.alt;
214
+ navigation(result, attributes);
215
+ const markers = markersOf(attributes.marker);
216
+ if (markers !== undefined)
217
+ result.markers = markers;
218
+ return result;
219
+ }
220
+ /** The number of the page the text is on: `text(['Page ', pageNumber()])`. */
221
+ export function pageNumber(attributes = {}) {
222
+ return attributes.format === undefined
223
+ ? { t: 'pageNumber' }
224
+ : { t: 'pageNumber', format: attributes.format };
225
+ }
226
+ /** The number of pages of the document, or of the template (`scope: 'section'`). */
227
+ export function totalPages(attributes = {}) {
228
+ const result = { t: 'totalPages' };
229
+ if (attributes.scope !== undefined)
230
+ result.scope = attributes.scope;
231
+ if (attributes.format !== undefined)
232
+ result.format = attributes.format;
233
+ return result;
234
+ }
235
+ /** The value of running marker `name` on the page, for example the chapter. */
236
+ export function marker({ name, select }) {
237
+ return select === undefined
238
+ ? { t: 'marker', name }
239
+ : { t: 'marker', name, select };
240
+ }
241
+ /**
242
+ * Builds an image node from its bytes: `image({ src, alt: 'Logo',
243
+ * className: 'w-32' })`. The bytes travel to the engine next to the JSON.
244
+ */
245
+ export function image(attributes) {
246
+ const result = {
247
+ t: 'image',
248
+ src: attributes.src,
249
+ };
250
+ if (attributes.alt !== undefined)
251
+ result.alt = attributes.alt;
252
+ if (attributes.className !== undefined) {
253
+ result.className = attributes.className;
254
+ }
255
+ if (attributes.style !== undefined)
256
+ result.style = attributes.style;
257
+ if (attributes.role !== undefined)
258
+ result.role = attributes.role;
259
+ navigation(result, attributes);
260
+ return result;
261
+ }
262
+ /**
263
+ * Builds an SVG node from its markup or file bytes: `svg({ src: '<svg …>',
264
+ * className: 'w-48' })`. The markup travels to the engine next to the JSON.
265
+ */
266
+ export function svg(attributes) {
267
+ const result = {
268
+ t: 'svg',
269
+ src: attributes.src,
270
+ };
271
+ if (attributes.alt !== undefined)
272
+ result.alt = attributes.alt;
273
+ if (attributes.className !== undefined) {
274
+ result.className = attributes.className;
275
+ }
276
+ if (attributes.style !== undefined)
277
+ result.style = attributes.style;
278
+ if (attributes.role !== undefined)
279
+ result.role = attributes.role;
280
+ navigation(result, attributes);
281
+ return result;
282
+ }
283
+ /**
284
+ * Builds a link: a view with `href` around `children`, for example
285
+ * `link({ href: 'https://example.com' }, [text('Website')])` or
286
+ * `link({ href: '#terms' }, …)`.
287
+ */
288
+ export function link({ href, ...attributes }, children = []) {
289
+ return { ...view(attributes, children), href };
290
+ }
291
+ /** Builds an anchor: an empty view with `id`, the target of `#id` links. */
292
+ export function anchor({ id, bookmark, }) {
293
+ return bookmark === undefined ? view({ id }) : view({ id, bookmark });
294
+ }
295
+ /**
296
+ * Builds a page break: an empty view with `break-after-page`, so the content
297
+ * after it starts on a new page. At the end of the content it adds no page.
298
+ */
299
+ export function pageBreak() {
300
+ return { t: 'view', className: 'break-after-page' };
301
+ }
302
+ /**
303
+ * Builds a keep-together group: a view with `break-inside-avoid` (and
304
+ * `break-after-avoid` with `withNext`) around `children`. The classes come
305
+ * first, so the group's own `className` can override them.
306
+ */
307
+ export function keep({ withNext, className, ...attributes } = {}, children = []) {
308
+ const classes = ['break-inside-avoid'];
309
+ if (withNext === true)
310
+ classes.push('break-after-avoid');
311
+ if (className !== undefined && className !== '')
312
+ classes.push(className);
313
+ return view({ ...attributes, className: classes.join(' ') }, children);
314
+ }
315
+ export function table(attributes = {}, rows = []) {
316
+ const result = { t: 'table' };
317
+ if (attributes.columns !== undefined) {
318
+ result.columns = attributes.columns.map((column) => ({ ...column }));
319
+ }
320
+ if (attributes.data !== undefined) {
321
+ const data = attributes;
322
+ result.data = data.data;
323
+ if (data.rowClassName !== undefined) {
324
+ result.rowClassName = data.rowClassName;
325
+ }
326
+ if (data.headerClassName !== undefined) {
327
+ result.headerClassName = data.headerClassName;
328
+ }
329
+ if (data.totals !== undefined)
330
+ result.totals = { ...data.totals };
331
+ }
332
+ if (attributes.cellClassName !== undefined) {
333
+ result.cellClassName = attributes.cellClassName;
334
+ }
335
+ if (attributes.repeatHeader !== undefined) {
336
+ result.repeatHeader = attributes.repeatHeader;
337
+ }
338
+ if (attributes.repeatFooter !== undefined) {
339
+ result.repeatFooter = attributes.repeatFooter;
340
+ }
341
+ if (attributes.runningTotals !== undefined) {
342
+ result.runningTotals = { ...attributes.runningTotals };
343
+ }
344
+ if (attributes.className !== undefined) {
345
+ result.className = attributes.className;
346
+ }
347
+ if (attributes.style !== undefined)
348
+ result.style = attributes.style;
349
+ if (attributes.role !== undefined)
350
+ result.role = attributes.role;
351
+ if (attributes.lang !== undefined)
352
+ result.lang = attributes.lang;
353
+ if (attributes.dir !== undefined)
354
+ result.dir = attributes.dir;
355
+ navigation(result, attributes);
356
+ if (rows.length > 0)
357
+ result.children = [...rows];
358
+ return result;
359
+ }
360
+ /** Builds a table row from its cells; `header` and `footer` mark the section. */
361
+ export function row(attributes = {}, cells = []) {
362
+ const result = { t: 'row' };
363
+ if (attributes.header !== undefined)
364
+ result.header = attributes.header;
365
+ if (attributes.footer !== undefined)
366
+ result.footer = attributes.footer;
367
+ if (attributes.className !== undefined) {
368
+ result.className = attributes.className;
369
+ }
370
+ if (attributes.style !== undefined)
371
+ result.style = attributes.style;
372
+ if (cells.length > 0)
373
+ result.children = [...cells];
374
+ return result;
375
+ }
376
+ /**
377
+ * Builds a table cell: `cell({ colSpan: 2 }, [text('Total')])`, or with
378
+ * text directly: `cell({ className: 'font-bold' }, 'Total')` (also with
379
+ * placeholders: `cell({}, ['Page ', pageNumber()])`). A cell with a `value`
380
+ * and no content shows the value in its column's format.
381
+ */
382
+ export function cell(attributes = {}, content = []) {
383
+ const result = { t: 'cell' };
384
+ if (attributes.colSpan !== undefined)
385
+ result.colSpan = attributes.colSpan;
386
+ if (attributes.rowSpan !== undefined)
387
+ result.rowSpan = attributes.rowSpan;
388
+ if (attributes.value !== undefined)
389
+ result.value = attributes.value;
390
+ if (attributes.className !== undefined) {
391
+ result.className = attributes.className;
392
+ }
393
+ if (attributes.style !== undefined)
394
+ result.style = attributes.style;
395
+ if (attributes.role !== undefined)
396
+ result.role = attributes.role;
397
+ if (attributes.scope !== undefined)
398
+ result.scope = attributes.scope;
399
+ if (attributes.lang !== undefined)
400
+ result.lang = attributes.lang;
401
+ if (attributes.dir !== undefined)
402
+ result.dir = attributes.dir;
403
+ const children = isTextInput(content)
404
+ ? [text(content)]
405
+ : [...content];
406
+ if (children.length > 0)
407
+ result.children = children;
408
+ return result;
409
+ }
410
+ //# sourceMappingURL=factories.js.map
@@ -0,0 +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,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,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,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"]}