@rentnerkev/pdf 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (355) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +134 -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,87 @@
1
+ import type { PdfElement, PdfNode } from '../jsx/Types/element.ts';
2
+ import type { CellProps, DataTableProps, DocumentProps, KeepProps, LinkProps, MarkerProps, PageBreakProps, PageNumberProps, PageProps, RowProps, TableProps, TextProps, TotalPagesProps, ViewProps } from './Types/props.ts';
3
+ /** The root of every document: metadata and `Page` children. */
4
+ export declare const Document: (props: DocumentProps<PdfNode>) => PdfElement;
5
+ /**
6
+ * A page template: size, orientation, page box styling (`p-page` for
7
+ * margins), a `header` and `footer` on every page with `first`, `odd`,
8
+ * `even` and `last` variants, and `numbering`. Content that does not fit
9
+ * continues on further pages of the template.
10
+ */
11
+ export declare const Page: (props: PageProps<PdfNode>) => PdfElement;
12
+ /** A generic box: block, flex or grid container. */
13
+ export declare const View: (props: ViewProps<PdfNode>) => PdfElement;
14
+ /**
15
+ * A paragraph of text; its string and number children are concatenated,
16
+ * and `PageNumber`, `TotalPages` and `Marker` placeholders are filled in
17
+ * per page.
18
+ */
19
+ export declare const Text: (props: TextProps<PdfNode>) => PdfElement;
20
+ /**
21
+ * A raster image from bytes (PNG, JPEG, GIF, WebP), sized like an HTML
22
+ * `<img>` with Tailwind's preflight: natural size, at most the container's
23
+ * width, aspect ratio kept; `object-contain`/`object-cover` fit it into a
24
+ * box with both sizes set.
25
+ */
26
+ export declare const Image: (props: import("./Types/props.ts").ImageAttributes) => PdfElement;
27
+ /**
28
+ * An SVG drawn as vectors, from markup or `.svg` bytes. It sizes like an
29
+ * image: its `width`/`height` (or `viewBox`) in CSS pixels, at most the
30
+ * container's width, aspect ratio kept. In a box of another aspect ratio it
31
+ * follows its `preserveAspectRatio` unless `object-*` classes say otherwise.
32
+ */
33
+ export declare const Svg: (props: import("./Types/props.ts").SvgAttributes) => PdfElement;
34
+ /**
35
+ * A clickable box around its children (a `View` with `href`): `#id` jumps
36
+ * to the node with that `id`, `https:`, `http:`, `mailto:` and `tel:` URIs
37
+ * open in the viewer's application. Every page fragment is clickable.
38
+ */
39
+ export declare const Link: (props: LinkProps<PdfNode>) => PdfElement;
40
+ /**
41
+ * An invisible link target: `<Anchor id="terms" />` is where
42
+ * `<Link href="#terms">` jumps. Any `View`, `Text`, `Image` or `Svg` can be
43
+ * a target through its own `id` too.
44
+ */
45
+ export declare const Anchor: (props: import("./Types/props.ts").AnchorAttributes) => PdfElement;
46
+ /**
47
+ * Starts the content that follows it on a new page: an empty box with
48
+ * `break-after-page`. At the end of the content it adds no page.
49
+ */
50
+ export declare const PageBreak: (props: PageBreakProps) => PdfElement;
51
+ /**
52
+ * Keeps its children together on one page when they fit on one: a box with
53
+ * `break-inside-avoid`, plus `break-after-avoid` with `withNext`.
54
+ */
55
+ export declare const Keep: (props: KeepProps<PdfNode>) => PdfElement;
56
+ /**
57
+ * A table of `Row`s: columns sized from `columns` (`auto`, `fr`, lengths,
58
+ * percentages) and the cells' content, split between rows across pages
59
+ * with header and footer rows repeated and optional running totals.
60
+ *
61
+ * With `data` and `columns` it is a data-driven table: one row per item,
62
+ * cells rendered natively from compact column data (large tables).
63
+ */
64
+ export declare const Table: <Row extends object>(props: TableProps<PdfNode> | DataTableProps<Row>) => PdfElement;
65
+ /**
66
+ * The number of the page the text is on, inside a `Text`: counted from 1
67
+ * over the document unless a `Page` sets `numbering`.
68
+ */
69
+ export declare const PageNumber: (props: PageNumberProps) => PdfElement;
70
+ /**
71
+ * The number of pages of the document (or of the page template with
72
+ * `scope="section"`), inside a `Text`: `Page <PageNumber /> of <TotalPages />`.
73
+ */
74
+ export declare const TotalPages: (props: TotalPagesProps) => PdfElement;
75
+ /**
76
+ * The value of a running marker on the page, inside a `Text`, for example
77
+ * the current chapter in a header: nodes set it with their `marker` prop.
78
+ */
79
+ export declare const Marker: (props: MarkerProps) => PdfElement;
80
+ /** A table row; `header` and `footer` rows repeat on every page. */
81
+ export declare const Row: (props: RowProps<PdfNode>) => PdfElement;
82
+ /**
83
+ * A table cell spanning `colSpan` columns and `rowSpan` rows. Strings and
84
+ * numbers become its text; `value` cells show a number in minor units.
85
+ */
86
+ export declare const Cell: (props: CellProps<PdfNode>) => PdfElement;
87
+ //# sourceMappingURL=components.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../web/src/components/components.ts"],"names":[],"mappings":"AAAA,OAA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@@ -0,0 +1,86 @@
1
+ import { host } from './host.js';
2
+ /** The root of every document: metadata and `Page` children. */
3
+ export const Document = host('Document');
4
+ /**
5
+ * A page template: size, orientation, page box styling (`p-page` for
6
+ * margins), a `header` and `footer` on every page with `first`, `odd`,
7
+ * `even` and `last` variants, and `numbering`. Content that does not fit
8
+ * continues on further pages of the template.
9
+ */
10
+ export const Page = host('Page');
11
+ /** A generic box: block, flex or grid container. */
12
+ export const View = host('View');
13
+ /**
14
+ * A paragraph of text; its string and number children are concatenated,
15
+ * and `PageNumber`, `TotalPages` and `Marker` placeholders are filled in
16
+ * per page.
17
+ */
18
+ export const Text = host('Text');
19
+ /**
20
+ * A raster image from bytes (PNG, JPEG, GIF, WebP), sized like an HTML
21
+ * `<img>` with Tailwind's preflight: natural size, at most the container's
22
+ * width, aspect ratio kept; `object-contain`/`object-cover` fit it into a
23
+ * box with both sizes set.
24
+ */
25
+ export const Image = host('Image');
26
+ /**
27
+ * An SVG drawn as vectors, from markup or `.svg` bytes. It sizes like an
28
+ * image: its `width`/`height` (or `viewBox`) in CSS pixels, at most the
29
+ * container's width, aspect ratio kept. In a box of another aspect ratio it
30
+ * follows its `preserveAspectRatio` unless `object-*` classes say otherwise.
31
+ */
32
+ export const Svg = host('Svg');
33
+ /**
34
+ * A clickable box around its children (a `View` with `href`): `#id` jumps
35
+ * to the node with that `id`, `https:`, `http:`, `mailto:` and `tel:` URIs
36
+ * open in the viewer's application. Every page fragment is clickable.
37
+ */
38
+ export const Link = host('Link');
39
+ /**
40
+ * An invisible link target: `<Anchor id="terms" />` is where
41
+ * `<Link href="#terms">` jumps. Any `View`, `Text`, `Image` or `Svg` can be
42
+ * a target through its own `id` too.
43
+ */
44
+ export const Anchor = host('Anchor');
45
+ /**
46
+ * Starts the content that follows it on a new page: an empty box with
47
+ * `break-after-page`. At the end of the content it adds no page.
48
+ */
49
+ export const PageBreak = host('PageBreak');
50
+ /**
51
+ * Keeps its children together on one page when they fit on one: a box with
52
+ * `break-inside-avoid`, plus `break-after-avoid` with `withNext`.
53
+ */
54
+ export const Keep = host('Keep');
55
+ /**
56
+ * A table of `Row`s: columns sized from `columns` (`auto`, `fr`, lengths,
57
+ * percentages) and the cells' content, split between rows across pages
58
+ * with header and footer rows repeated and optional running totals.
59
+ *
60
+ * With `data` and `columns` it is a data-driven table: one row per item,
61
+ * cells rendered natively from compact column data (large tables).
62
+ */
63
+ export const Table = host('Table');
64
+ /**
65
+ * The number of the page the text is on, inside a `Text`: counted from 1
66
+ * over the document unless a `Page` sets `numbering`.
67
+ */
68
+ export const PageNumber = host('PageNumber');
69
+ /**
70
+ * The number of pages of the document (or of the page template with
71
+ * `scope="section"`), inside a `Text`: `Page <PageNumber /> of <TotalPages />`.
72
+ */
73
+ export const TotalPages = host('TotalPages');
74
+ /**
75
+ * The value of a running marker on the page, inside a `Text`, for example
76
+ * the current chapter in a header: nodes set it with their `marker` prop.
77
+ */
78
+ export const Marker = host('Marker');
79
+ /** A table row; `header` and `footer` rows repeat on every page. */
80
+ export const Row = host('Row');
81
+ /**
82
+ * A table cell spanning `colSpan` columns and `rowSpan` rows. Strings and
83
+ * numbers become its text; `value` cells show a number in minor units.
84
+ */
85
+ export const Cell = host('Cell');
86
+ //# sourceMappingURL=components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.js","sourceRoot":"","sources":["../../web/src/components/components.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAqBhC,gEAAgE;AAChE,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAyB,UAAU,CAAC,CAAA;AAEhE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAqB,MAAM,CAAC,CAAA;AAEpD,oDAAoD;AACpD,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAqB,MAAM,CAAC,CAAA;AAEpD;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAqB,MAAM,CAAC,CAAA;AAEpD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CAAa,OAAO,CAAC,CAAA;AAE9C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,CAAW,KAAK,CAAC,CAAA;AAExC;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAqB,MAAM,CAAC,CAAA;AAEpD;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAc,QAAQ,CAAC,CAAA;AAEjD;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAiB,WAAW,CAAC,CAAA;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAqB,MAAM,CAAC,CAAA;AAEpD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CACrB,OAAO,CAGI,CAAA;AAEf;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAkB,YAAY,CAAC,CAAA;AAE7D;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAkB,YAAY,CAAC,CAAA;AAE7D;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAc,QAAQ,CAAC,CAAA;AAEjD,oEAAoE;AACpE,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,CAAoB,KAAK,CAAC,CAAA;AAEjD;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAqB,MAAM,CAAC,CAAA","sourcesContent":["import type { PdfElement, PdfNode } from '../jsx/Types/element.ts'\nimport { host } from './host.ts'\nimport type {\n AnchorProps,\n CellProps,\n DataTableProps,\n DocumentProps,\n ImageProps,\n KeepProps,\n LinkProps,\n MarkerProps,\n PageBreakProps,\n PageNumberProps,\n PageProps,\n SvgProps,\n RowProps,\n TableProps,\n TextProps,\n TotalPagesProps,\n ViewProps,\n} from './Types/props.ts'\n\n/** The root of every document: metadata and `Page` children. */\nexport const Document = host<DocumentProps<PdfNode>>('Document')\n\n/**\n * A page template: size, orientation, page box styling (`p-page` for\n * margins), a `header` and `footer` on every page with `first`, `odd`,\n * `even` and `last` variants, and `numbering`. Content that does not fit\n * continues on further pages of the template.\n */\nexport const Page = host<PageProps<PdfNode>>('Page')\n\n/** A generic box: block, flex or grid container. */\nexport const View = host<ViewProps<PdfNode>>('View')\n\n/**\n * A paragraph of text; its string and number children are concatenated,\n * and `PageNumber`, `TotalPages` and `Marker` placeholders are filled in\n * per page.\n */\nexport const Text = host<TextProps<PdfNode>>('Text')\n\n/**\n * A raster image from bytes (PNG, JPEG, GIF, WebP), sized like an HTML\n * `<img>` with Tailwind's preflight: natural size, at most the container's\n * width, aspect ratio kept; `object-contain`/`object-cover` fit it into a\n * box with both sizes set.\n */\nexport const Image = host<ImageProps>('Image')\n\n/**\n * An SVG drawn as vectors, from markup or `.svg` bytes. It sizes like an\n * image: its `width`/`height` (or `viewBox`) in CSS pixels, at most the\n * container's width, aspect ratio kept. In a box of another aspect ratio it\n * follows its `preserveAspectRatio` unless `object-*` classes say otherwise.\n */\nexport const Svg = host<SvgProps>('Svg')\n\n/**\n * A clickable box around its children (a `View` with `href`): `#id` jumps\n * to the node with that `id`, `https:`, `http:`, `mailto:` and `tel:` URIs\n * open in the viewer's application. Every page fragment is clickable.\n */\nexport const Link = host<LinkProps<PdfNode>>('Link')\n\n/**\n * An invisible link target: `<Anchor id=\"terms\" />` is where\n * `<Link href=\"#terms\">` jumps. Any `View`, `Text`, `Image` or `Svg` can be\n * a target through its own `id` too.\n */\nexport const Anchor = host<AnchorProps>('Anchor')\n\n/**\n * Starts the content that follows it on a new page: an empty box with\n * `break-after-page`. At the end of the content it adds no page.\n */\nexport const PageBreak = host<PageBreakProps>('PageBreak')\n\n/**\n * Keeps its children together on one page when they fit on one: a box with\n * `break-inside-avoid`, plus `break-after-avoid` with `withNext`.\n */\nexport const Keep = host<KeepProps<PdfNode>>('Keep')\n\n/**\n * A table of `Row`s: columns sized from `columns` (`auto`, `fr`, lengths,\n * percentages) and the cells' content, split between rows across pages\n * with header and footer rows repeated and optional running totals.\n *\n * With `data` and `columns` it is a data-driven table: one row per item,\n * cells rendered natively from compact column data (large tables).\n */\nexport const Table = host<TableProps<PdfNode> | DataTableProps<object>>(\n 'Table',\n) as <Row extends object>(\n props: TableProps<PdfNode> | DataTableProps<Row>,\n) => PdfElement\n\n/**\n * The number of the page the text is on, inside a `Text`: counted from 1\n * over the document unless a `Page` sets `numbering`.\n */\nexport const PageNumber = host<PageNumberProps>('PageNumber')\n\n/**\n * The number of pages of the document (or of the page template with\n * `scope=\"section\"`), inside a `Text`: `Page <PageNumber /> of <TotalPages />`.\n */\nexport const TotalPages = host<TotalPagesProps>('TotalPages')\n\n/**\n * The value of a running marker on the page, inside a `Text`, for example\n * the current chapter in a header: nodes set it with their `marker` prop.\n */\nexport const Marker = host<MarkerProps>('Marker')\n\n/** A table row; `header` and `footer` rows repeat on every page. */\nexport const Row = host<RowProps<PdfNode>>('Row')\n\n/**\n * A table cell spanning `colSpan` columns and `rowSpan` rows. Strings and\n * numbers become its text; `value` cells show a number in minor units.\n */\nexport const Cell = host<CellProps<PdfNode>>('Cell')\n"]}
@@ -0,0 +1,7 @@
1
+ import type { PdfElement } from '../jsx/Types/element.ts';
2
+ import type { HostName } from './Types/host.ts';
3
+ /** Creates a built-in component; rendering builds its IR node from the props. */
4
+ export declare function host<P>(name: HostName): (props: P) => PdfElement;
5
+ /** Returns the built-in component's name, or `undefined` for other types. */
6
+ export declare function hostName(type: unknown): HostName | undefined;
7
+ //# sourceMappingURL=host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../web/src/components/host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAI/C,iFAAiF;AACjF,wBAAgB,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,UAAU,CAShE;AAED,6EAA6E;AAC7E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,CAE5D"}
@@ -0,0 +1,15 @@
1
+ const hosts = new WeakMap();
2
+ /** Creates a built-in component; rendering builds its IR node from the props. */
3
+ export function host(name) {
4
+ const component = (_props) => {
5
+ throw new TypeError(`<${name}> is a built-in RentnerPDF component; use it in JSX or with jsx() instead of calling it. In React trees (renderToPdf), use the components from @rentnerkev/pdf/react.`);
6
+ };
7
+ Object.defineProperty(component, 'name', { value: name });
8
+ hosts.set(component, name);
9
+ return component;
10
+ }
11
+ /** Returns the built-in component's name, or `undefined` for other types. */
12
+ export function hostName(type) {
13
+ return typeof type === 'function' ? hosts.get(type) : undefined;
14
+ }
15
+ //# sourceMappingURL=host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.js","sourceRoot":"","sources":["../../web/src/components/host.ts"],"names":[],"mappings":"AAGA,MAAM,KAAK,GAAG,IAAI,OAAO,EAAoB,CAAA;AAE7C,iFAAiF;AACjF,MAAM,UAAU,IAAI,CAAI,IAAc;IAClC,MAAM,SAAS,GAAG,CAAC,MAAS,EAAc,EAAE;QACxC,MAAM,IAAI,SAAS,CACf,IAAI,IAAI,uKAAuK,CAClL,CAAA;IACL,CAAC,CAAA;IACD,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IACzD,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;IAC1B,OAAO,SAAS,CAAA;AACpB,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,QAAQ,CAAC,IAAa;IAClC,OAAO,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AACnE,CAAC","sourcesContent":["import type { PdfElement } from '../jsx/Types/element.ts'\nimport type { HostName } from './Types/host.ts'\n\nconst hosts = new WeakMap<object, HostName>()\n\n/** Creates a built-in component; rendering builds its IR node from the props. */\nexport function host<P>(name: HostName): (props: P) => PdfElement {\n const component = (_props: P): PdfElement => {\n throw new TypeError(\n `<${name}> is a built-in RentnerPDF component; use it in JSX or with jsx() instead of calling it. In React trees (renderToPdf), use the components from @rentnerkev/pdf/react.`,\n )\n }\n Object.defineProperty(component, 'name', { value: name })\n hosts.set(component, name)\n return component\n}\n\n/** Returns the built-in component's name, or `undefined` for other types. */\nexport function hostName(type: unknown): HostName | undefined {\n return typeof type === 'function' ? hosts.get(type) : undefined\n}\n"]}
@@ -0,0 +1,120 @@
1
+ import type { BackendTheme } from '../../theme/Types/theme.ts';
2
+ import type { DataChannel } from '../channel.ts';
3
+ import type { Limits } from './limits.ts';
4
+ import type { EngineStats } from './render-options.ts';
5
+ import type { RenderWarning } from './render-result.ts';
6
+ /** The engine implementations: the Node-API addon or the WebAssembly build. */
7
+ export type BackendName = 'native' | 'wasm';
8
+ /**
9
+ * Which backend `createEngine` uses. `auto` takes the native addon when it
10
+ * loads for this platform and falls back to WebAssembly.
11
+ */
12
+ export type BackendChoice = 'auto' | BackendName;
13
+ /** A document as it crosses into the engine (D-06). */
14
+ export interface EncodedDocument {
15
+ /** UTF-8 IR JSON; image nodes reference assets by index. */
16
+ readonly ir: Uint8Array;
17
+ /** Asset buffers (image bytes) in index order. */
18
+ readonly assets: Uint8Array[];
19
+ }
20
+ /**
21
+ * A document rendered by React (`@rentnerkev/pdf/react`) as it crosses into
22
+ * the engine: the `rpdf-*` markup, the asset buffers it references by index
23
+ * and where the columnar channel of its data tables is among them.
24
+ */
25
+ export interface EncodedMarkup {
26
+ /** UTF-8 markup from `react-dom/static`. */
27
+ readonly markup: Uint8Array;
28
+ readonly assets: Uint8Array[];
29
+ readonly channel?: DataChannel;
30
+ }
31
+ /** An element of rendered markup with a `debug` id and the IR path it became. */
32
+ export interface BackendDebugPath {
33
+ readonly path: string;
34
+ readonly debug: string;
35
+ }
36
+ /** A warning as both bindings return it; absent fields are left out. */
37
+ export interface BackendWarning {
38
+ readonly code: string;
39
+ readonly message: string;
40
+ readonly path?: string;
41
+ readonly className?: string;
42
+ readonly suggestion?: string;
43
+ }
44
+ /** A wrap diagnostic as both bindings return it. */
45
+ export interface BackendWrapDiagnostic {
46
+ readonly pageIndex: number;
47
+ readonly path: string;
48
+ readonly reason: string;
49
+ readonly message: string;
50
+ }
51
+ /** A `renderDetailed` result as both bindings return it. */
52
+ export interface BackendRenderResult {
53
+ readonly pdf: Uint8Array;
54
+ readonly pageCount: number;
55
+ readonly warnings: readonly BackendWarning[];
56
+ readonly diagnostics: readonly BackendWrapDiagnostic[];
57
+ }
58
+ /**
59
+ * An engine of one backend with its fonts registered. A `signal` cancels a
60
+ * native render while it runs; the WebAssembly backend renders
61
+ * synchronously and leaves signals to the caller.
62
+ */
63
+ export interface Backend {
64
+ readonly name: BackendName;
65
+ /** The engine's version (`rentnerpdf::engine_version`). */
66
+ readonly version: string;
67
+ /** `INVALID_THEME` warnings for the parts of the theme the engine could not read. */
68
+ readonly themeWarnings: readonly BackendWarning[];
69
+ /** The engine's thread count; 1 on WebAssembly. */
70
+ readonly threads: number;
71
+ render(document: EncodedDocument, signal?: AbortSignal): Promise<Uint8Array>;
72
+ renderDetailed(document: EncodedDocument, signal?: AbortSignal): Promise<BackendRenderResult>;
73
+ renderSync(document: EncodedDocument): Uint8Array;
74
+ renderMarkup(document: EncodedMarkup, signal?: AbortSignal): Promise<Uint8Array>;
75
+ renderMarkupDetailed(document: EncodedMarkup, signal?: AbortSignal): Promise<BackendRenderResult>;
76
+ /** The IR paths of the markup's elements that carry a `debug` id. */
77
+ markupDebugPaths(markup: Uint8Array): readonly BackendDebugPath[];
78
+ stats(): EngineStats;
79
+ /**
80
+ * Registers a font for the renders called from now on; renders already
81
+ * called keep their fonts.
82
+ */
83
+ registerFont(font: Uint8Array): void;
84
+ /**
85
+ * Releases the engine (the native handle, the WebAssembly instance).
86
+ * Called once, after every render has settled; nothing is called after.
87
+ */
88
+ close(): void;
89
+ }
90
+ /** What every backend needs to create its engine. */
91
+ export interface BackendOptions {
92
+ readonly fonts: readonly Uint8Array[];
93
+ readonly defaultFonts: readonly Uint8Array[];
94
+ readonly strict: boolean;
95
+ /** `EngineOptions.cache.imageBytesMax`; `undefined` keeps the default. */
96
+ readonly imageCacheBytes: number | undefined;
97
+ /** `EngineOptions.cache.shapedRunsMax`; `undefined` keeps the default. */
98
+ readonly shapedRunsMax?: number | undefined;
99
+ /** `EngineOptions.threads`; `undefined` takes one per core. */
100
+ readonly threads?: number | undefined;
101
+ /** `EngineOptions.limits`, validated; `Infinity` lifts a limit. */
102
+ readonly limits?: Limits | undefined;
103
+ /** `EngineOptions.theme` and `rootFontSize`; `undefined` keeps the built-in theme. */
104
+ readonly theme?: BackendTheme | undefined;
105
+ }
106
+ /**
107
+ * The backend options of `EngineOptions`, validated, without the default
108
+ * fonts: each realm (the page, or a Web Worker) reads those itself. Plain
109
+ * data that `postMessage` can clone.
110
+ */
111
+ export type BackendSettings = Omit<BackendOptions, 'defaultFonts'>;
112
+ /** `EngineOptions` checked and converted before an engine exists. */
113
+ export interface PreparedEngineOptions {
114
+ readonly settings: BackendSettings;
115
+ /** Whether the bundled Noto Sans fonts are registered (`defaultFont`). */
116
+ readonly defaultFont: boolean;
117
+ /** `INVALID_THEME` warnings found while collecting the theme's stylesheets. */
118
+ readonly themeWarnings: readonly RenderWarning[];
119
+ }
120
+ //# sourceMappingURL=backend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../../web/src/engine/Types/backend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EA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gB,EAAE,CAAA;IACjE,KAAK,IAAI,WAAW,CAAA;IACpB;;;OAGG;IACH,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;IACpC;;;OAGG;IACH,KAAK,IAAI,IAAI,CAAA;CAChB;AAED,qDAAqD;AACrD,MAAM,WAAW,cAAc;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,CAAA;IACrC,QAAQ,CAAC,YAAY,EAAE,SAAS,UAAU,EAAE,CAAA;IAC5C,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5C,0EAA0E;IAC1E,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3C,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACrC,mEAAmE;IACnE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACpC,sFAAsF;IACtF,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,GAAG,SAAS,CAAA;CAC5C;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,CAAA;AAElE,qEAAqE;AACrE,MAAM,WAAW,qBAAqB;IAClC,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAA;IAClC,0EAA0E;IAC1E,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAA;IAC7B,+EAA+E;IAC/E,QAAQ,CAAC,aAAa,EAAE,SAAS,aAAa,EAAE,CAAA;CACnD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=backend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backend.js","sourceRoot":"","sources":["../../../web/src/engine/Types/backend.ts"],"names":[],"mappings":"","sourcesContent":["import type { BackendTheme } from '../../theme/Types/theme.ts'\nimport type { DataChannel } from '../channel.ts'\nimport type { Limits } from './limits.ts'\nimport type { EngineStats } from './render-options.ts'\nimport type { RenderWarning } from './render-result.ts'\n\n/** The engine implementations: the Node-API addon or the WebAssembly build. */\nexport type BackendName = 'native' | 'wasm'\n\n/**\n * Which backend `createEngine` uses. `auto` takes the native addon when it\n * loads for this platform and falls back to WebAssembly.\n */\nexport type BackendChoice = 'auto' | BackendName\n\n/** A document as it crosses into the engine (D-06). */\nexport interface EncodedDocument {\n /** UTF-8 IR JSON; image nodes reference assets by index. */\n readonly ir: Uint8Array\n /** Asset buffers (image bytes) in index order. */\n readonly assets: Uint8Array[]\n}\n\n/**\n * A document rendered by React (`@rentnerkev/pdf/react`) as it crosses into\n * the engine: the `rpdf-*` markup, the asset buffers it references by index\n * and where the columnar channel of its data tables is among them.\n */\nexport interface EncodedMarkup {\n /** UTF-8 markup from `react-dom/static`. */\n readonly markup: Uint8Array\n readonly assets: Uint8Array[]\n readonly channel?: DataChannel\n}\n\n/** An element of rendered markup with a `debug` id and the IR path it became. */\nexport interface BackendDebugPath {\n readonly path: string\n readonly debug: string\n}\n\n/** A warning as both bindings return it; absent fields are left out. */\nexport interface BackendWarning {\n readonly code: string\n readonly message: string\n readonly path?: string\n readonly className?: string\n readonly suggestion?: string\n}\n\n/** A wrap diagnostic as both bindings return it. */\nexport interface BackendWrapDiagnostic {\n readonly pageIndex: number\n readonly path: string\n readonly reason: string\n readonly message: string\n}\n\n/** A `renderDetailed` result as both bindings return it. */\nexport interface BackendRenderResult {\n readonly pdf: Uint8Array\n readonly pageCount: number\n readonly warnings: readonly BackendWarning[]\n readonly diagnostics: readonly BackendWrapDiagnostic[]\n}\n\n/**\n * An engine of one backend with its fonts registered. A `signal` cancels a\n * native render while it runs; the WebAssembly backend renders\n * synchronously and leaves signals to the caller.\n */\nexport interface Backend {\n readonly name: BackendName\n /** The engine's version (`rentnerpdf::engine_version`). */\n readonly version: string\n /** `INVALID_THEME` warnings for the parts of the theme the engine could not read. */\n readonly themeWarnings: readonly BackendWarning[]\n /** The engine's thread count; 1 on WebAssembly. */\n readonly threads: number\n render(document: EncodedDocument, signal?: AbortSignal): Promise<Uint8Array>\n renderDetailed(\n document: EncodedDocument,\n signal?: AbortSignal,\n ): Promise<BackendRenderResult>\n renderSync(document: EncodedDocument): Uint8Array\n renderMarkup(\n document: EncodedMarkup,\n signal?: AbortSignal,\n ): Promise<Uint8Array>\n renderMarkupDetailed(\n document: EncodedMarkup,\n signal?: AbortSignal,\n ): Promise<BackendRenderResult>\n /** The IR paths of the markup's elements that carry a `debug` id. */\n markupDebugPaths(markup: Uint8Array): readonly BackendDebugPath[]\n stats(): EngineStats\n /**\n * Registers a font for the renders called from now on; renders already\n * called keep their fonts.\n */\n registerFont(font: Uint8Array): void\n /**\n * Releases the engine (the native handle, the WebAssembly instance).\n * Called once, after every render has settled; nothing is called after.\n */\n close(): void\n}\n\n/** What every backend needs to create its engine. */\nexport interface BackendOptions {\n readonly fonts: readonly Uint8Array[]\n readonly defaultFonts: readonly Uint8Array[]\n readonly strict: boolean\n /** `EngineOptions.cache.imageBytesMax`; `undefined` keeps the default. */\n readonly imageCacheBytes: number | undefined\n /** `EngineOptions.cache.shapedRunsMax`; `undefined` keeps the default. */\n readonly shapedRunsMax?: number | undefined\n /** `EngineOptions.threads`; `undefined` takes one per core. */\n readonly threads?: number | undefined\n /** `EngineOptions.limits`, validated; `Infinity` lifts a limit. */\n readonly limits?: Limits | undefined\n /** `EngineOptions.theme` and `rootFontSize`; `undefined` keeps the built-in theme. */\n readonly theme?: BackendTheme | undefined\n}\n\n/**\n * The backend options of `EngineOptions`, validated, without the default\n * fonts: each realm (the page, or a Web Worker) reads those itself. Plain\n * data that `postMessage` can clone.\n */\nexport type BackendSettings = Omit<BackendOptions, 'defaultFonts'>\n\n/** `EngineOptions` checked and converted before an engine exists. */\nexport interface PreparedEngineOptions {\n readonly settings: BackendSettings\n /** Whether the bundled Noto Sans fonts are registered (`defaultFont`). */\n readonly defaultFont: boolean\n /** `INVALID_THEME` warnings found while collecting the theme's stylesheets. */\n readonly themeWarnings: readonly RenderWarning[]\n}\n"]}
@@ -0,0 +1,192 @@
1
+ /// <reference lib="esnext.disposable" preserve="true" />
2
+ import type { DocumentInput } from '../../ir/Types/input.ts';
3
+ import type { ThemeInput } from '../../theme/Types/theme.ts';
4
+ import type { PdfElement } from '../../jsx/Types/element.ts';
5
+ import type { WasmModuleSource } from '../../wasm/loader.ts';
6
+ import type { BackendChoice, BackendName } from './backend.ts';
7
+ import type { LimitsInput } from './limits.ts';
8
+ import type { BatchOptions, BatchRendered, BatchResult, EngineStats, RenderOptions } from './render-options.ts';
9
+ import type { PdfBytes, RenderResult, RenderWarning } from './render-result.ts';
10
+ /**
11
+ * What the engine renders: a JSX element (evaluated to the IR first; its root
12
+ * must render a `Document`) or an IR document, for example from the
13
+ * factories.
14
+ */
15
+ export type RenderInput = PdfElement | DocumentInput;
16
+ /** The bytes of a TrueType or OpenType font file (the first font of a collection). */
17
+ export type FontSource = Uint8Array | ArrayBuffer;
18
+ export interface EngineOptions {
19
+ /**
20
+ * TrueType or OpenType font files. The first font's family is the default
21
+ * family; every font also serves as fallback for characters the others
22
+ * lack. A family defined here replaces the bundled font of the same name.
23
+ * `Engine.registerFont` adds fonts later.
24
+ */
25
+ fonts?: readonly FontSource[];
26
+ /**
27
+ * Registers the bundled Noto Sans family (Regular, Bold, Italic, Bold
28
+ * Italic; Latin, Greek, Cyrillic). It is the default family when `fonts`
29
+ * is empty. Defaults to `true`.
30
+ */
31
+ defaultFont?: boolean;
32
+ /**
33
+ * Turns the warnings `UNKNOWN_CLASS`, `INVALID_VALUE` and
34
+ * `UNSUPPORTED_CLASS` into `UNSUPPORTED_CLASS` errors, in tagged
35
+ * documents `UNKNOWN_ROLE` and `MISSING_ALT_TEXT` into
36
+ * `INVALID_DOCUMENT` errors, and `MISSING_GLYPH` into a `FONT_NOT_FOUND`
37
+ * error. `IGNORED_VARIANT` and `NO_EFFECT` stay warnings, so components
38
+ * shared with a web UI also render in strict mode.
39
+ */
40
+ strict?: boolean;
41
+ /**
42
+ * The app's design tokens on top of Tailwind's default theme (D-22):
43
+ * `themeFromCss()` / `themeFromCssFile()` results, JS overrides such as
44
+ * `{ '--color-brand': '#0f766e' }`, or a list of both. Override order:
45
+ * Tailwind's theme, `@rentnerkev/pdf/tailwind.css`, paper values for
46
+ * `--rentner-*`, the stylesheets' `@theme`, `:root` and scope
47
+ * selectors, then the JS overrides. Problems never throw; see
48
+ * `Engine.themeWarnings`.
49
+ */
50
+ theme?: ThemeInput;
51
+ /**
52
+ * Root font size in CSS pixels: `rem` values and the default text size.
53
+ * Defaults to 16, like browsers (`p-4` = 1rem = 12pt).
54
+ */
55
+ rootFontSize?: number;
56
+ /** Sizes of the engine's caches, which repeated renders share. */
57
+ cache?: CacheOptions;
58
+ /**
59
+ * Native backend: the engine's threads. At most this many documents
60
+ * render at the same time, whatever the number of `render()` calls or
61
+ * batches, and each render shapes its paragraphs on a pool of this
62
+ * size. `'auto'` (the default) takes one per core. The output is the
63
+ * same for every thread count. The WebAssembly backend renders on the
64
+ * calling thread and ignores it.
65
+ */
66
+ threads?: number | 'auto';
67
+ /**
68
+ * Resource limits for untrusted documents, checked for each document
69
+ * on its own: overrides of the defaults, or `'unlimited'` for trusted
70
+ * batch jobs.
71
+ */
72
+ limits?: LimitsInput;
73
+ /**
74
+ * The engine implementation. `auto` (the default) uses the native addon
75
+ * when it loads for this platform and falls back to the WebAssembly
76
+ * engine bundled in the package; `native` and `wasm` use only that
77
+ * backend. Both render the same documents to the same bytes.
78
+ */
79
+ backend?: BackendChoice;
80
+ /**
81
+ * WebAssembly backend: the compiled module (`rentnerpdf_wasm_bg.wasm`)
82
+ * as bytes, a `WebAssembly.Module` or a URL, for runtimes that cannot
83
+ * read it next to the package's JavaScript (Cloudflare Workers import it
84
+ * as a module). Only the first WebAssembly engine of a process loads it.
85
+ */
86
+ wasmModule?: WasmModuleSource;
87
+ }
88
+ export interface CacheOptions {
89
+ /**
90
+ * Approximate memory in bytes for decoded images, SVGs and letterhead
91
+ * PDFs, found by their content: the same logo in every invoice is read
92
+ * once. The least recently used assets go first; `0` disables the
93
+ * cache. An integer up to 4 GiB; defaults to 64 MiB.
94
+ */
95
+ imageBytesMax?: number;
96
+ /**
97
+ * Shaped runs of text (up to 256 bytes each: labels, table cells,
98
+ * short lines), found by font, script, language and text, so a text
99
+ * that repeats within a document or across renders is shaped once.
100
+ * Runs not used for a while go first; `0` disables the cache. Defaults
101
+ * to 16,384 runs (about 4 MiB). The cache never changes the output.
102
+ */
103
+ shapedRunsMax?: number;
104
+ }
105
+ export interface Engine {
106
+ /** The backend this engine renders with. */
107
+ readonly backend: BackendName;
108
+ /**
109
+ * The version of the engine that renders, for example `1.0.0`: the
110
+ * native addon's or the WebAssembly build's. It equals the package
111
+ * version for bundled engines. A development override can load an
112
+ * engine built from another version.
113
+ */
114
+ readonly version: string;
115
+ /**
116
+ * `INVALID_THEME` warnings for the parts of `EngineOptions.theme` that
117
+ * could not be read: imports that were not followed, malformed CSS,
118
+ * invalid token values, undefined variables. Empty for a sound theme.
119
+ */
120
+ readonly themeWarnings: readonly RenderWarning[];
121
+ /** The engine's thread count; always 1 on WebAssembly. */
122
+ readonly threads: number;
123
+ /**
124
+ * Evaluates the components, then renders: off the event loop on the
125
+ * native backend (the engine's threads); on the calling thread on the
126
+ * WebAssembly backend. Components may be `async`.
127
+ */
128
+ render(input: RenderInput, options?: RenderOptions): Promise<PdfBytes>;
129
+ /** Renders like `render` and also returns the page count and warnings. */
130
+ renderDetailed(input: RenderInput, options?: RenderOptions): Promise<RenderResult>;
131
+ /**
132
+ * Renders on the calling thread; for scripts and CLIs. Components must be
133
+ * synchronous: an `async` component fails with `INVALID_DOCUMENT`. An
134
+ * aborted `signal` stops it only before it starts.
135
+ */
136
+ renderSync(input: RenderInput, options?: RenderOptions): PdfBytes;
137
+ /**
138
+ * Renders many documents, each like `renderDetailed`, and yields their
139
+ * results in input order as they are ready. Documents come from an
140
+ * array, a generator or an async iterable (a database cursor, a
141
+ * stream) and are read only when a slot is free (`concurrency`), so
142
+ * memory stays bounded; limits apply to each document on its own. A
143
+ * document that fails yields `{ ok: false, error }` unless
144
+ * `stopOnError` is set. Breaking out of the loop cancels the documents
145
+ * in progress. On WebAssembly documents render one after another.
146
+ */
147
+ renderMany(documents: Iterable<RenderInput> | AsyncIterable<RenderInput>, options: BatchOptions & {
148
+ readonly stopOnError: true;
149
+ }): AsyncIterable<BatchRendered>;
150
+ renderMany(documents: Iterable<RenderInput> | AsyncIterable<RenderInput>, options?: BatchOptions): AsyncIterable<BatchResult>;
151
+ /**
152
+ * Renders like `render` and returns the PDF as a stream of chunks, for
153
+ * example for `new Response(stream)`. The render starts at once; the
154
+ * stream errors with the render's error, and cancelling it cancels the
155
+ * render. The engine writes the whole document before the first chunk
156
+ * (krilla buffers it); streaming pages while they are written is
157
+ * planned after 1.0.
158
+ *
159
+ * @experimental Exempt from SemVer in 1.x until promoted: the chunks
160
+ * stay, but incremental output may change when they arrive.
161
+ */
162
+ renderToStream(input: RenderInput, options?: RenderOptions): ReadableStream<Uint8Array<ArrayBuffer>>;
163
+ /** Cache sizes and hit counts, and the renders in progress. */
164
+ stats(): EngineStats;
165
+ /**
166
+ * Registers another font file, also while renders run. A render uses
167
+ * the fonts the engine has when its document reaches the engine (after
168
+ * its components are evaluated), so renders already there keep their
169
+ * output and later ones use the new font. It works like a font appended
170
+ * to `EngineOptions.fonts`, except that the default family never
171
+ * changes: a new family comes last in the fallback chain, a font of a
172
+ * family registered before adds a face to it (a bold face, say), and a
173
+ * family of the bundled Noto Sans replaces it. Rejects with
174
+ * `UNSUPPORTED_FONT` or `LIMIT_EXCEEDED` (`limits.maxFontBytes`) and
175
+ * leaves the fonts unchanged.
176
+ */
177
+ registerFont(font: FontSource): Promise<void>;
178
+ /**
179
+ * Closes the engine. From the call on, renders, batches, `registerFont`
180
+ * and `stats` fail with `ENGINE_CLOSED`; renders in progress are
181
+ * cancelled and reject with `ABORTED` (with the `ENGINE_CLOSED` error as
182
+ * `cause`), native ones at their next page or paragraph. Resolves once
183
+ * they have stopped and the engine's memory, caches and threads are
184
+ * released; calling it again returns the same promise.
185
+ */
186
+ close(): Promise<void>;
187
+ /** For `using engine = …`: starts `close()` without waiting for it. */
188
+ [Symbol.dispose](): void;
189
+ /** For `await using engine = …`: `close()`. */
190
+ [Symbol.asyncDispose](): Promise<void>;
191
+ }
192
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../web/src/engine/Types/engine.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EACR,YAAY,EACZ,aAAa,EACb,WAAW,EACX,WAAW,EACX,aAAa,EAChB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAE/E;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,aAAa,CAAA;AAEpD,sFAAsF;AACtF,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,WAAW,CAAA;AAEjD,MAAM,WAAW,aAAa;IAC1B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,SAAS,UAAU,EAAE,CAAA;IAC7B;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,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AAQ,CAAC,WAAW,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,EAC7D,OAAO,EAAE,YAAY,GAAG;QAAE,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAA;KAAE,GACvD,aAAa,CAAC,aAAa,CAAC,CAAA;IAC/B,UAAU,CACN,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,EAC7D,OAAO,CAAC,EAAE,YAAY,GACvB,aAAa,CAAC,WAAW,CAAC,CAAA;IAC7B;;;;;;;;;;OAUG;IACH,cAAc,CACV,KAAK,EAAE,WAAW,EAClB,OAAO,CAAC,EAAE,aAAa,GACxB,cAAc,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAA;IAC1C,+DAA+D;IAC/D,KAAK,IAAI,WAAW,CAAA;IACpB;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7C;;;;;;;OAOG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACtB,uEAAuE;IACvE,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAA;IACxB,+CAA+C;IAC/C,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACzC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.js","sourceRoot":"","sources":["../../../web/src/engine/Types/engine.ts"],"names":[],"mappings":"","sourcesContent":["/// <reference lib=\"esnext.disposable\" preserve=\"true\" />\nimport type { DocumentInput } from '../../ir/Types/input.ts'\nimport type { ThemeInput } from '../../theme/Types/theme.ts'\nimport type { PdfElement } from '../../jsx/Types/element.ts'\nimport type { WasmModuleSource } from '../../wasm/loader.ts'\nimport type { BackendChoice, BackendName } from './backend.ts'\nimport type { LimitsInput } from './limits.ts'\nimport type {\n BatchOptions,\n BatchRendered,\n BatchResult,\n EngineStats,\n RenderOptions,\n} from './render-options.ts'\nimport type { PdfBytes, RenderResult, RenderWarning } from './render-result.ts'\n\n/**\n * What the engine renders: a JSX element (evaluated to the IR first; its root\n * must render a `Document`) or an IR document, for example from the\n * factories.\n */\nexport type RenderInput = PdfElement | DocumentInput\n\n/** The bytes of a TrueType or OpenType font file (the first font of a collection). */\nexport type FontSource = Uint8Array | ArrayBuffer\n\nexport interface EngineOptions {\n /**\n * TrueType or OpenType font files. The first font's family is the default\n * family; every font also serves as fallback for characters the others\n * lack. A family defined here replaces the bundled font of the same name.\n * `Engine.registerFont` adds fonts later.\n */\n fonts?: readonly FontSource[]\n /**\n * Registers the bundled Noto Sans family (Regular, Bold, Italic, Bold\n * Italic; Latin, Greek, Cyrillic). It is the default family when `fonts`\n * is empty. Defaults to `true`.\n */\n defaultFont?: boolean\n /**\n * Turns the warnings `UNKNOWN_CLASS`, `INVALID_VALUE` and\n * `UNSUPPORTED_CLASS` into `UNSUPPORTED_CLASS` errors, in tagged\n * documents `UNKNOWN_ROLE` and `MISSING_ALT_TEXT` into\n * `INVALID_DOCUMENT` errors, and `MISSING_GLYPH` into a `FONT_NOT_FOUND`\n * error. `IGNORED_VARIANT` and `NO_EFFECT` stay warnings, so components\n * shared with a web UI also render in strict mode.\n */\n strict?: boolean\n /**\n * The app's design tokens on top of Tailwind's default theme (D-22):\n * `themeFromCss()` / `themeFromCssFile()` results, JS overrides such as\n * `{ '--color-brand': '#0f766e' }`, or a list of both. Override order:\n * Tailwind's theme, `@rentnerkev/pdf/tailwind.css`, paper values for\n * `--rentner-*`, the stylesheets' `@theme`, `:root` and scope\n * selectors, then the JS overrides. Problems never throw; see\n * `Engine.themeWarnings`.\n */\n theme?: ThemeInput\n /**\n * Root font size in CSS pixels: `rem` values and the default text size.\n * Defaults to 16, like browsers (`p-4` = 1rem = 12pt).\n */\n rootFontSize?: number\n /** Sizes of the engine's caches, which repeated renders share. */\n cache?: CacheOptions\n /**\n * Native backend: the engine's threads. At most this many documents\n * render at the same time, whatever the number of `render()` calls or\n * batches, and each render shapes its paragraphs on a pool of this\n * size. `'auto'` (the default) takes one per core. The output is the\n * same for every thread count. The WebAssembly backend renders on the\n * calling thread and ignores it.\n */\n threads?: number | 'auto'\n /**\n * Resource limits for untrusted documents, checked for each document\n * on its own: overrides of the defaults, or `'unlimited'` for trusted\n * batch jobs.\n */\n limits?: LimitsInput\n /**\n * The engine implementation. `auto` (the default) uses the native addon\n * when it loads for this platform and falls back to the WebAssembly\n * engine bundled in the package; `native` and `wasm` use only that\n * backend. Both render the same documents to the same bytes.\n */\n backend?: BackendChoice\n /**\n * WebAssembly backend: the compiled module (`rentnerpdf_wasm_bg.wasm`)\n * as bytes, a `WebAssembly.Module` or a URL, for runtimes that cannot\n * read it next to the package's JavaScript (Cloudflare Workers import it\n * as a module). Only the first WebAssembly engine of a process loads it.\n */\n wasmModule?: WasmModuleSource\n}\n\nexport interface CacheOptions {\n /**\n * Approximate memory in bytes for decoded images, SVGs and letterhead\n * PDFs, found by their content: the same logo in every invoice is read\n * once. The least recently used assets go first; `0` disables the\n * cache. An integer up to 4 GiB; defaults to 64 MiB.\n */\n imageBytesMax?: number\n /**\n * Shaped runs of text (up to 256 bytes each: labels, table cells,\n * short lines), found by font, script, language and text, so a text\n * that repeats within a document or across renders is shaped once.\n * Runs not used for a while go first; `0` disables the cache. Defaults\n * to 16,384 runs (about 4 MiB). The cache never changes the output.\n */\n shapedRunsMax?: number\n}\n\nexport interface Engine {\n /** The backend this engine renders with. */\n readonly backend: BackendName\n /**\n * The version of the engine that renders, for example `1.0.0`: the\n * native addon's or the WebAssembly build's. It equals the package\n * version for bundled engines. A development override can load an\n * engine built from another version.\n */\n readonly version: string\n /**\n * `INVALID_THEME` warnings for the parts of `EngineOptions.theme` that\n * could not be read: imports that were not followed, malformed CSS,\n * invalid token values, undefined variables. Empty for a sound theme.\n */\n readonly themeWarnings: readonly RenderWarning[]\n /** The engine's thread count; always 1 on WebAssembly. */\n readonly threads: number\n /**\n * Evaluates the components, then renders: off the event loop on the\n * native backend (the engine's threads); on the calling thread on the\n * WebAssembly backend. Components may be `async`.\n */\n render(input: RenderInput, options?: RenderOptions): Promise<PdfBytes>\n /** Renders like `render` and also returns the page count and warnings. */\n renderDetailed(\n input: RenderInput,\n options?: RenderOptions,\n ): Promise<RenderResult>\n /**\n * Renders on the calling thread; for scripts and CLIs. Components must be\n * synchronous: an `async` component fails with `INVALID_DOCUMENT`. An\n * aborted `signal` stops it only before it starts.\n */\n renderSync(input: RenderInput, options?: RenderOptions): PdfBytes\n /**\n * Renders many documents, each like `renderDetailed`, and yields their\n * results in input order as they are ready. Documents come from an\n * array, a generator or an async iterable (a database cursor, a\n * stream) and are read only when a slot is free (`concurrency`), so\n * memory stays bounded; limits apply to each document on its own. A\n * document that fails yields `{ ok: false, error }` unless\n * `stopOnError` is set. Breaking out of the loop cancels the documents\n * in progress. On WebAssembly documents render one after another.\n */\n renderMany(\n documents: Iterable<RenderInput> | AsyncIterable<RenderInput>,\n options: BatchOptions & { readonly stopOnError: true },\n ): AsyncIterable<BatchRendered>\n renderMany(\n documents: Iterable<RenderInput> | AsyncIterable<RenderInput>,\n options?: BatchOptions,\n ): AsyncIterable<BatchResult>\n /**\n * Renders like `render` and returns the PDF as a stream of chunks, for\n * example for `new Response(stream)`. The render starts at once; the\n * stream errors with the render's error, and cancelling it cancels the\n * render. The engine writes the whole document before the first chunk\n * (krilla buffers it); streaming pages while they are written is\n * planned after 1.0.\n *\n * @experimental Exempt from SemVer in 1.x until promoted: the chunks\n * stay, but incremental output may change when they arrive.\n */\n renderToStream(\n input: RenderInput,\n options?: RenderOptions,\n ): ReadableStream<Uint8Array<ArrayBuffer>>\n /** Cache sizes and hit counts, and the renders in progress. */\n stats(): EngineStats\n /**\n * Registers another font file, also while renders run. A render uses\n * the fonts the engine has when its document reaches the engine (after\n * its components are evaluated), so renders already there keep their\n * output and later ones use the new font. It works like a font appended\n * to `EngineOptions.fonts`, except that the default family never\n * changes: a new family comes last in the fallback chain, a font of a\n * family registered before adds a face to it (a bold face, say), and a\n * family of the bundled Noto Sans replaces it. Rejects with\n * `UNSUPPORTED_FONT` or `LIMIT_EXCEEDED` (`limits.maxFontBytes`) and\n * leaves the fonts unchanged.\n */\n registerFont(font: FontSource): Promise<void>\n /**\n * Closes the engine. From the call on, renders, batches, `registerFont`\n * and `stats` fail with `ENGINE_CLOSED`; renders in progress are\n * cancelled and reject with `ABORTED` (with the `ENGINE_CLOSED` error as\n * `cause`), native ones at their next page or paragraph. Resolves once\n * they have stopped and the engine's memory, caches and threads are\n * released; calling it again returns the same promise.\n */\n close(): Promise<void>\n /** For `using engine = …`: starts `close()` without waiting for it. */\n [Symbol.dispose](): void\n /** For `await using engine = …`: `close()`. */\n [Symbol.asyncDispose](): Promise<void>\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import type { SourceLocation } from '../../jsx/Types/element.ts';
2
+ import type { RentnerPdfWarningCode } from './render-result.ts';
3
+ /**
4
+ * Stable error codes shared with the Rust engine (`rentnerpdf::ErrorCode`).
5
+ * `ENGINE_CLOSED` is a call to an engine after its `close()`.
6
+ */
7
+ export type RentnerPdfErrorCode = 'INVALID_DOCUMENT' | 'FONT_NOT_FOUND' | 'UNSUPPORTED_FONT' | 'UNSUPPORTED_IMAGE' | 'UNSUPPORTED_CLASS' | 'LIMIT_EXCEEDED' | 'INCOMPLETE_RENDER' | 'ABORTED' | 'STANDARD_VIOLATION' | 'INTERNAL' | 'ENGINE_CLOSED';
8
+ export interface RentnerPdfErrorOptions extends ErrorOptions {
9
+ /** JSX source of the element the error is about (development runtime). */
10
+ source?: SourceLocation;
11
+ /** `strict` mode: the code of the warning the error was made from. */
12
+ warning?: RentnerPdfWarningCode;
13
+ }
14
+ /** Maps an IR path of the rendered document to the JSX source that built it. */
15
+ export type SourceLocator = (path: string) => SourceLocation | undefined;
16
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../web/src/engine/Types/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAE/D;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GACzB,kBAAkB,GAClB,gBAAgB,GAChB,kBAAkB,GAClB,mBAAmB,GACnB,mBAAmB,GACnB,gBAAgB,GAChB,mBAAmB,GACnB,SAAS,GACT,oBAAoB,GACpB,UAAU,GACV,eAAe,CAAA;AAErB,MAAM,WAAW,sBAAuB,SAAQ,YAAY;IACxD,0EAA0E;IAC1E,MAAM,CAAC,EAAE,cAAc,CAAA;IACvB,sEAAsE;IACtE,OAAO,CAAC,EAAE,qBAAqB,CAAA;CAClC;AAED,gFAAgF;AAChF,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,cAAc,GAAG,SAAS,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=errors.js.map