@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 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../web/src/engine/Types/errors.ts"],"names":[],"mappings":"","sourcesContent":["import type { SourceLocation } from '../../jsx/Types/element.ts'\nimport type { RentnerPdfWarningCode } from './render-result.ts'\n\n/**\n * Stable error codes shared with the Rust engine (`rentnerpdf::ErrorCode`).\n * `ENGINE_CLOSED` is a call to an engine after its `close()`.\n */\nexport type RentnerPdfErrorCode =\n | 'INVALID_DOCUMENT'\n | 'FONT_NOT_FOUND'\n | 'UNSUPPORTED_FONT'\n | 'UNSUPPORTED_IMAGE'\n | 'UNSUPPORTED_CLASS'\n | 'LIMIT_EXCEEDED'\n | 'INCOMPLETE_RENDER'\n | 'ABORTED'\n | 'STANDARD_VIOLATION'\n | 'INTERNAL'\n | 'ENGINE_CLOSED'\n\nexport interface RentnerPdfErrorOptions extends ErrorOptions {\n /** JSX source of the element the error is about (development runtime). */\n source?: SourceLocation\n /** `strict` mode: the code of the warning the error was made from. */\n warning?: RentnerPdfWarningCode\n}\n\n/** Maps an IR path of the rendered document to the JSX source that built it. */\nexport type SourceLocator = (path: string) => SourceLocation | undefined\n"]}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Resource limits for untrusted documents (D-14), checked for each document
3
+ * on its own. Absent fields keep their defaults; `Infinity` lifts one. A
4
+ * document beyond a limit fails with `LIMIT_EXCEEDED` and the path of the
5
+ * node.
6
+ */
7
+ export interface Limits {
8
+ /** Bytes of the encoded document (IR JSON or React markup). Default 256 MiB. */
9
+ readonly maxInputBytes?: number;
10
+ /** Pages in the output, including pages created by overflow. Default 100,000. */
11
+ readonly maxPages?: number;
12
+ /** Content nodes, table rows and cells included. Default 10,000,000. */
13
+ readonly maxNodes?: number;
14
+ /**
15
+ * Nesting depth of content nodes below a page. Default 60; the parsers
16
+ * stop at about 63 levels (JSON) and 256 elements (React markup) anyway.
17
+ */
18
+ readonly maxDepth?: number;
19
+ /** Bytes of one `className` string. Default 16 KiB. */
20
+ readonly maxClassNameBytes?: number;
21
+ /** Classes in one `className` string. Default 512. */
22
+ readonly maxClasses?: number;
23
+ /** Bytes of all images, SVGs, letterhead PDFs and table data of a document. Default 256 MiB. */
24
+ readonly maxAssetBytes?: number;
25
+ /** Pixels (width × height) of one image, read before decoding. Default 100,000,000. */
26
+ readonly maxImagePixels?: number;
27
+ /**
28
+ * Combined raster pixels per render. Each referenced asset buffer counts
29
+ * once, including rasters within SVGs and assets already in the cache.
30
+ * Default 1,000,000,000.
31
+ */
32
+ readonly maxTotalImagePixels?: number;
33
+ /**
34
+ * Letterhead PDF parsing work per render, measured in bytes. Counts each
35
+ * referenced PDF buffer and the work of embedding each selected page,
36
+ * including cached assets. Default 256 MiB.
37
+ */
38
+ readonly maxLetterheadParseBytes?: number;
39
+ /**
40
+ * Elements of one SVG as the engine will build them: `<use>` copies,
41
+ * referenced content per reference, marker content per vertex, one per
42
+ * 32 curve segments and 256 per filtered element. Default 200,000.
43
+ */
44
+ readonly maxSvgElements?: number;
45
+ /** UTF-8 bytes of one paragraph (a text node or a table cell). Default 4 MiB. */
46
+ readonly maxTextBytes?: number;
47
+ /** Bytes of one font file, checked when the engine is created. Default 64 MiB. */
48
+ readonly maxFontBytes?: number;
49
+ }
50
+ /**
51
+ * `EngineOptions.limits`: limits to override, or `'unlimited'` to lift
52
+ * every limit for trusted batch jobs.
53
+ */
54
+ export type LimitsInput = Limits | 'unlimited';
55
+ //# sourceMappingURL=limits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../../web/src/engine/Types/limits.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,MAAM;IACnB,gFAAgF;IAChF,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;IAC/B,iFAAiF;IACjF,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,uDAAuD;IACvD,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;IACnC,sDAAsD;IACtD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,gGAAgG;IAChG,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;IAC/B,uFAAuF;IACvF,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;IAChC;;;;OAIG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAA;IACrC;;;;OAIG;IACH,QAAQ,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAA;IACzC;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;IAChC,iFAAiF;IACjF,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,kFAAkF;IAClF,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CACjC;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,WAAW,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=limits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limits.js","sourceRoot":"","sources":["../../../web/src/engine/Types/limits.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Resource limits for untrusted documents (D-14), checked for each document\n * on its own. Absent fields keep their defaults; `Infinity` lifts one. A\n * document beyond a limit fails with `LIMIT_EXCEEDED` and the path of the\n * node.\n */\nexport interface Limits {\n /** Bytes of the encoded document (IR JSON or React markup). Default 256 MiB. */\n readonly maxInputBytes?: number\n /** Pages in the output, including pages created by overflow. Default 100,000. */\n readonly maxPages?: number\n /** Content nodes, table rows and cells included. Default 10,000,000. */\n readonly maxNodes?: number\n /**\n * Nesting depth of content nodes below a page. Default 60; the parsers\n * stop at about 63 levels (JSON) and 256 elements (React markup) anyway.\n */\n readonly maxDepth?: number\n /** Bytes of one `className` string. Default 16 KiB. */\n readonly maxClassNameBytes?: number\n /** Classes in one `className` string. Default 512. */\n readonly maxClasses?: number\n /** Bytes of all images, SVGs, letterhead PDFs and table data of a document. Default 256 MiB. */\n readonly maxAssetBytes?: number\n /** Pixels (width × height) of one image, read before decoding. Default 100,000,000. */\n readonly maxImagePixels?: number\n /**\n * Combined raster pixels per render. Each referenced asset buffer counts\n * once, including rasters within SVGs and assets already in the cache.\n * Default 1,000,000,000.\n */\n readonly maxTotalImagePixels?: number\n /**\n * Letterhead PDF parsing work per render, measured in bytes. Counts each\n * referenced PDF buffer and the work of embedding each selected page,\n * including cached assets. Default 256 MiB.\n */\n readonly maxLetterheadParseBytes?: number\n /**\n * Elements of one SVG as the engine will build them: `<use>` copies,\n * referenced content per reference, marker content per vertex, one per\n * 32 curve segments and 256 per filtered element. Default 200,000.\n */\n readonly maxSvgElements?: number\n /** UTF-8 bytes of one paragraph (a text node or a table cell). Default 4 MiB. */\n readonly maxTextBytes?: number\n /** Bytes of one font file, checked when the engine is created. Default 64 MiB. */\n readonly maxFontBytes?: number\n}\n\n/**\n * `EngineOptions.limits`: limits to override, or `'unlimited'` to lift\n * every limit for trusted batch jobs.\n */\nexport type LimitsInput = Limits | 'unlimited'\n"]}
@@ -0,0 +1,71 @@
1
+ import type { RenderResult } from './render-result.ts';
2
+ /** Options of one render. */
3
+ export interface RenderOptions {
4
+ /**
5
+ * Cancels the render: the promise rejects with an `ABORTED` error whose
6
+ * `cause` is the signal's reason, and the native engine stops working
7
+ * on the document at its next page or paragraph. A WebAssembly render
8
+ * blocks its thread, so only a signal that aborted before it started
9
+ * stops it. Use `AbortSignal.timeout(ms)` for a time limit.
10
+ */
11
+ readonly signal?: AbortSignal;
12
+ }
13
+ /** Options of `Engine.renderMany`. */
14
+ export interface BatchOptions {
15
+ /**
16
+ * Cancels the batch: the iteration throws an `ABORTED` error and the
17
+ * documents in progress are cancelled.
18
+ */
19
+ readonly signal?: AbortSignal;
20
+ /**
21
+ * How many documents are in progress at the same time: evaluated,
22
+ * rendering or rendered and waiting to be read. The batch reads the
23
+ * next document from the input only when one of these slots is free,
24
+ * so neither the input nor the results pile up. Defaults to twice the
25
+ * engine's thread count on the native backend (its threads still
26
+ * bound how many render at once) and to 1 on WebAssembly.
27
+ */
28
+ readonly concurrency?: number;
29
+ /**
30
+ * Ends the batch at the first document that fails: the iteration
31
+ * throws its error and the documents in progress are cancelled. By
32
+ * default a failed document yields `{ ok: false, error }` and the batch
33
+ * goes on.
34
+ */
35
+ readonly stopOnError?: boolean;
36
+ }
37
+ /** A document of a batch that rendered: its `RenderResult` and position. */
38
+ export interface BatchRendered extends RenderResult {
39
+ /** Position of the document in the input, from 0. */
40
+ readonly index: number;
41
+ readonly ok: true;
42
+ }
43
+ /** A document of a batch that failed. */
44
+ export interface BatchFailed {
45
+ /** Position of the document in the input, from 0. */
46
+ readonly index: number;
47
+ readonly ok: false;
48
+ /**
49
+ * Why it failed: a `RentnerPdfError` from the engine, or what one of
50
+ * its components threw.
51
+ */
52
+ readonly error: unknown;
53
+ }
54
+ /** What `Engine.renderMany` yields for each document, in input order. */
55
+ export type BatchResult = BatchRendered | BatchFailed;
56
+ /** Cache numbers and the renders in progress, from `Engine.stats()`. */
57
+ export interface EngineStats {
58
+ /** Shaped runs of text in the cache. */
59
+ readonly shapedRuns: number;
60
+ /** Runs found in the cache since the engine was created. */
61
+ readonly shapedRunHits: number;
62
+ /** Cacheable runs that had to be shaped. */
63
+ readonly shapedRunMisses: number;
64
+ /** Approximate memory of the cached images, SVGs and letterhead PDFs. */
65
+ readonly imageCacheBytes: number;
66
+ /** Renders the engine is working on right now. */
67
+ readonly rendersActive: number;
68
+ /** Renders waiting for one of the engine's threads (native backend). */
69
+ readonly rendersQueued: number;
70
+ }
71
+ //# sourceMappingURL=render-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-options.d.ts","sourceRoot":"","sources":["../../../web/src/engine/Types/render-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,6BAA6B;AAC7B,MAAM,WAAW,aAAa;IAC1B;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAChC;AAED,sCAAsC;AACtC,MAAM,WAAW,YAAY;IACzB;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;IAC7B;;;;;;;OAOG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CACjC;AAED,4EAA4E;AAC5E,MAAM,WAAW,aAAc,SAAQ,YAAY;IAC/C,qDAAqD;IACrD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAA;CACpB;AAED,yCAAyC;AACzC,MAAM,WAAW,WAAW;IACxB,qDAAqD;IACrD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAA;IAClB;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAC1B;AAED,yEAAyE;AACzE,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,WAAW,CAAA;AAErD,wEAAwE;AACxE,MAAM,WAAW,WAAW;IACxB,wCAAwC;IACxC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,4DAA4D;IAC5D,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,4CAA4C;IAC5C,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,yEAAyE;IACzE,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,kDAAkD;IAClD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,wEAAwE;IACxE,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;CACjC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=render-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-options.js","sourceRoot":"","sources":["../../../web/src/engine/Types/render-options.ts"],"names":[],"mappings":"","sourcesContent":["import type { RenderResult } from './render-result.ts'\n\n/** Options of one render. */\nexport interface RenderOptions {\n /**\n * Cancels the render: the promise rejects with an `ABORTED` error whose\n * `cause` is the signal's reason, and the native engine stops working\n * on the document at its next page or paragraph. A WebAssembly render\n * blocks its thread, so only a signal that aborted before it started\n * stops it. Use `AbortSignal.timeout(ms)` for a time limit.\n */\n readonly signal?: AbortSignal\n}\n\n/** Options of `Engine.renderMany`. */\nexport interface BatchOptions {\n /**\n * Cancels the batch: the iteration throws an `ABORTED` error and the\n * documents in progress are cancelled.\n */\n readonly signal?: AbortSignal\n /**\n * How many documents are in progress at the same time: evaluated,\n * rendering or rendered and waiting to be read. The batch reads the\n * next document from the input only when one of these slots is free,\n * so neither the input nor the results pile up. Defaults to twice the\n * engine's thread count on the native backend (its threads still\n * bound how many render at once) and to 1 on WebAssembly.\n */\n readonly concurrency?: number\n /**\n * Ends the batch at the first document that fails: the iteration\n * throws its error and the documents in progress are cancelled. By\n * default a failed document yields `{ ok: false, error }` and the batch\n * goes on.\n */\n readonly stopOnError?: boolean\n}\n\n/** A document of a batch that rendered: its `RenderResult` and position. */\nexport interface BatchRendered extends RenderResult {\n /** Position of the document in the input, from 0. */\n readonly index: number\n readonly ok: true\n}\n\n/** A document of a batch that failed. */\nexport interface BatchFailed {\n /** Position of the document in the input, from 0. */\n readonly index: number\n readonly ok: false\n /**\n * Why it failed: a `RentnerPdfError` from the engine, or what one of\n * its components threw.\n */\n readonly error: unknown\n}\n\n/** What `Engine.renderMany` yields for each document, in input order. */\nexport type BatchResult = BatchRendered | BatchFailed\n\n/** Cache numbers and the renders in progress, from `Engine.stats()`. */\nexport interface EngineStats {\n /** Shaped runs of text in the cache. */\n readonly shapedRuns: number\n /** Runs found in the cache since the engine was created. */\n readonly shapedRunHits: number\n /** Cacheable runs that had to be shaped. */\n readonly shapedRunMisses: number\n /** Approximate memory of the cached images, SVGs and letterhead PDFs. */\n readonly imageCacheBytes: number\n /** Renders the engine is working on right now. */\n readonly rendersActive: number\n /** Renders waiting for one of the engine's threads (native backend). */\n readonly rendersQueued: number\n}\n"]}
@@ -0,0 +1,80 @@
1
+ import type { SourceLocation } from '../../jsx/Types/element.ts';
2
+ /**
3
+ * Stable warning codes shared with the Rust engine (`rentnerpdf::WarningCode`).
4
+ * With `strict: true`, `UNKNOWN_CLASS`, `INVALID_VALUE` and `UNSUPPORTED_CLASS`
5
+ * become `UNSUPPORTED_CLASS` errors, and the tagged-PDF warnings
6
+ * `UNKNOWN_ROLE` and `MISSING_ALT_TEXT` become `INVALID_DOCUMENT` errors;
7
+ * `IGNORED_VARIANT` and `NO_EFFECT` stay warnings. `INVALID_THEME`
8
+ * (`Engine.themeWarnings`) marks a part of the app theme the engine could
9
+ * not read; it never becomes an error. `MISSING_GLYPH` lists characters of
10
+ * a text node no registered font covers (they draw as empty boxes); `strict`
11
+ * makes it a `FONT_NOT_FOUND` error. `UNSUPPORTED_SVG_FEATURE` reports a
12
+ * skipped SVG feature and becomes an `UNSUPPORTED_IMAGE` error in strict mode.
13
+ * Strict-mode errors name the warning's code in `RentnerPdfError.warning`.
14
+ */
15
+ export type RentnerPdfWarningCode = 'UNKNOWN_CLASS' | 'INVALID_VALUE' | 'UNSUPPORTED_CLASS' | 'IGNORED_VARIANT' | 'NO_EFFECT' | 'INVALID_THEME' | 'UNKNOWN_ROLE' | 'MISSING_ALT_TEXT' | 'MISSING_GLYPH' | 'UNSUPPORTED_SVG_FEATURE';
16
+ /** A problem the engine worked around, for example an unknown class. */
17
+ export interface RenderWarning {
18
+ readonly code: RentnerPdfWarningCode;
19
+ readonly message: string;
20
+ /**
21
+ * IR path of the node, for example `pages[0].children[2]`, or
22
+ * `pages[0].style.paddingTop` for a typed style property. Theme
23
+ * warnings name the stylesheet's source (or `theme.stylesheets[<index>]`),
24
+ * `theme.variables` or `rootFontSize`.
25
+ */
26
+ readonly path?: string;
27
+ /** The class the warning is about, for example `pading-4`. */
28
+ readonly className?: string;
29
+ /** A replacement class, for example `p-4`. */
30
+ readonly suggestion?: string;
31
+ /** JSX source of the node (development JSX runtime only). */
32
+ readonly source?: SourceLocation;
33
+ }
34
+ /**
35
+ * Why content moved to another page or was forced onto one, shared with the
36
+ * Rust engine (`rentnerpdf::WrapReason`):
37
+ *
38
+ * - `KEEP_WITH_NEXT`: moved to stay with the content after it
39
+ * (`keep-with-next`, `break-after-avoid`, `break-before-avoid`).
40
+ * - `KEEP_TOGETHER`: a `break-inside-avoid` box moved to stay on one page.
41
+ * - `KEEP_TOGETHER_TOO_TALL`: a `break-inside-avoid` box taller than a page
42
+ * was split anyway.
43
+ * - `WIDOWS_ORPHANS`: lines moved for `widows` and `orphans`.
44
+ * - `DOES_NOT_FIT`: moved because it did not fit in the rest of the page,
45
+ * for example a table row where a table breaks.
46
+ * - `FORCED_OVERSIZE`: taller than a page, placed anyway; it overflows.
47
+ */
48
+ export type WrapReason = 'KEEP_WITH_NEXT' | 'KEEP_TOGETHER' | 'KEEP_TOGETHER_TOO_TALL' | 'WIDOWS_ORPHANS' | 'DOES_NOT_FIT' | 'FORCED_OVERSIZE';
49
+ /** A move or forced placement during pagination: "why did this block move?". */
50
+ export interface WrapDiagnostic {
51
+ /**
52
+ * Index of the output page, from 0 (not the printed page number): the
53
+ * page the content could not stay on, or the page it overflows.
54
+ */
55
+ readonly pageIndex: number;
56
+ /** IR path of the node, for example `pages[0].children[3]`. */
57
+ readonly path: string;
58
+ readonly reason: WrapReason;
59
+ /** A sentence explaining the reason. */
60
+ readonly message: string;
61
+ /** JSX source of the node (development JSX runtime only). */
62
+ readonly source?: SourceLocation;
63
+ }
64
+ /**
65
+ * PDF bytes as the engine returns them: a fresh buffer backed by an
66
+ * `ArrayBuffer`, so `new Response(pdf)` and `new Blob([pdf])` accept it.
67
+ */
68
+ export type PdfBytes = Uint8Array<ArrayBuffer>;
69
+ export interface RenderResult {
70
+ readonly pdf: PdfBytes;
71
+ readonly pageCount: number;
72
+ /**
73
+ * Warnings in document order. A problem that repeats (the same class on
74
+ * many nodes) is reported once, at its first node.
75
+ */
76
+ readonly warnings: readonly RenderWarning[];
77
+ /** Wrap diagnostics in the order pagination met them. */
78
+ readonly diagnostics: readonly WrapDiagnostic[];
79
+ }
80
+ //# sourceMappingURL=render-result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-result.d.ts","sourceRoot":"","sources":["../../../web/src/engine/Types/render-result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAEhE;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,qBAAqB,GAC3B,eAAe,GACf,eAAe,GACf,mBAAmB,GACnB,iBAAiB,GACjB,WAAW,GACX,eAAe,GACf,cAAc,GACd,kBAAkB,GAClB,eAAe,GACf,yBAAyB,CAAA;AAE/B,wEAAwE;AACxE,MAAM,WAAW,aAAa;IAC1B,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAA;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,8DAA8D;IAC9D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,6DAA6D;IAC7D,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAA;CACnC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,UAAU,GAChB,gBAAgB,GAChB,eAAe,GACf,wBAAwB,GACxB,gBAAgB,GAChB,cAAc,GACd,iBAAiB,CAAA;AAEvB,gFAAgF;AAChF,MAAM,WAAW,cAAc;IAC3B;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;IAC3B,wCAAwC;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,6DAA6D;IAC7D,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAA;CACnC;AAED;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,WAAW,CAAC,CAAA;AAE9C,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAA;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAA;IAC3C,yDAAyD;IACzD,QAAQ,CAAC,WAAW,EAAE,SAAS,cAAc,EAAE,CAAA;CAClD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=render-result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-result.js","sourceRoot":"","sources":["../../../web/src/engine/Types/render-result.ts"],"names":[],"mappings":"","sourcesContent":["import type { SourceLocation } from '../../jsx/Types/element.ts'\n\n/**\n * Stable warning codes shared with the Rust engine (`rentnerpdf::WarningCode`).\n * With `strict: true`, `UNKNOWN_CLASS`, `INVALID_VALUE` and `UNSUPPORTED_CLASS`\n * become `UNSUPPORTED_CLASS` errors, and the tagged-PDF warnings\n * `UNKNOWN_ROLE` and `MISSING_ALT_TEXT` become `INVALID_DOCUMENT` errors;\n * `IGNORED_VARIANT` and `NO_EFFECT` stay warnings. `INVALID_THEME`\n * (`Engine.themeWarnings`) marks a part of the app theme the engine could\n * not read; it never becomes an error. `MISSING_GLYPH` lists characters of\n * a text node no registered font covers (they draw as empty boxes); `strict`\n * makes it a `FONT_NOT_FOUND` error. `UNSUPPORTED_SVG_FEATURE` reports a\n * skipped SVG feature and becomes an `UNSUPPORTED_IMAGE` error in strict mode.\n * Strict-mode errors name the warning's code in `RentnerPdfError.warning`.\n */\nexport type RentnerPdfWarningCode =\n | 'UNKNOWN_CLASS'\n | 'INVALID_VALUE'\n | 'UNSUPPORTED_CLASS'\n | 'IGNORED_VARIANT'\n | 'NO_EFFECT'\n | 'INVALID_THEME'\n | 'UNKNOWN_ROLE'\n | 'MISSING_ALT_TEXT'\n | 'MISSING_GLYPH'\n | 'UNSUPPORTED_SVG_FEATURE'\n\n/** A problem the engine worked around, for example an unknown class. */\nexport interface RenderWarning {\n readonly code: RentnerPdfWarningCode\n readonly message: string\n /**\n * IR path of the node, for example `pages[0].children[2]`, or\n * `pages[0].style.paddingTop` for a typed style property. Theme\n * warnings name the stylesheet's source (or `theme.stylesheets[<index>]`),\n * `theme.variables` or `rootFontSize`.\n */\n readonly path?: string\n /** The class the warning is about, for example `pading-4`. */\n readonly className?: string\n /** A replacement class, for example `p-4`. */\n readonly suggestion?: string\n /** JSX source of the node (development JSX runtime only). */\n readonly source?: SourceLocation\n}\n\n/**\n * Why content moved to another page or was forced onto one, shared with the\n * Rust engine (`rentnerpdf::WrapReason`):\n *\n * - `KEEP_WITH_NEXT`: moved to stay with the content after it\n * (`keep-with-next`, `break-after-avoid`, `break-before-avoid`).\n * - `KEEP_TOGETHER`: a `break-inside-avoid` box moved to stay on one page.\n * - `KEEP_TOGETHER_TOO_TALL`: a `break-inside-avoid` box taller than a page\n * was split anyway.\n * - `WIDOWS_ORPHANS`: lines moved for `widows` and `orphans`.\n * - `DOES_NOT_FIT`: moved because it did not fit in the rest of the page,\n * for example a table row where a table breaks.\n * - `FORCED_OVERSIZE`: taller than a page, placed anyway; it overflows.\n */\nexport type WrapReason =\n | 'KEEP_WITH_NEXT'\n | 'KEEP_TOGETHER'\n | 'KEEP_TOGETHER_TOO_TALL'\n | 'WIDOWS_ORPHANS'\n | 'DOES_NOT_FIT'\n | 'FORCED_OVERSIZE'\n\n/** A move or forced placement during pagination: \"why did this block move?\". */\nexport interface WrapDiagnostic {\n /**\n * Index of the output page, from 0 (not the printed page number): the\n * page the content could not stay on, or the page it overflows.\n */\n readonly pageIndex: number\n /** IR path of the node, for example `pages[0].children[3]`. */\n readonly path: string\n readonly reason: WrapReason\n /** A sentence explaining the reason. */\n readonly message: string\n /** JSX source of the node (development JSX runtime only). */\n readonly source?: SourceLocation\n}\n\n/**\n * PDF bytes as the engine returns them: a fresh buffer backed by an\n * `ArrayBuffer`, so `new Response(pdf)` and `new Blob([pdf])` accept it.\n */\nexport type PdfBytes = Uint8Array<ArrayBuffer>\n\nexport interface RenderResult {\n readonly pdf: PdfBytes\n readonly pageCount: number\n /**\n * Warnings in document order. A problem that repeats (the same class on\n * many nodes) is reported once, at its first node.\n */\n readonly warnings: readonly RenderWarning[]\n /** Wrap diagnostics in the order pagination met them. */\n readonly diagnostics: readonly WrapDiagnostic[]\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import { RentnerPdfError } from './errors.ts';
2
+ /** The `ABORTED` error for an abort `reason`; an `ABORTED` reason is kept. */
3
+ export declare const abortedError: (reason: unknown) => RentnerPdfError;
4
+ /** Throws the `ABORTED` error when `signal` has aborted. */
5
+ export declare function throwIfAborted(signal: AbortSignal | undefined): void;
6
+ /**
7
+ * Settles like `promise`, but rejects with `ABORTED` as soon as `signal`
8
+ * aborts. The work behind `promise` must stop on its own.
9
+ */
10
+ export declare function raceAbort<T>(promise: Promise<T>, signal: AbortSignal | undefined): Promise<T>;
11
+ /** A signal that aborts with `signal` or after `timeoutMs` milliseconds. */
12
+ export interface Deadline {
13
+ readonly signal: AbortSignal;
14
+ /** Stops the timer and the link to the outer signal. */
15
+ clear(): void;
16
+ }
17
+ /**
18
+ * Links an optional outer `signal` and an optional timeout into one signal.
19
+ * The timer is ref'd: a render that never finishes fails instead of
20
+ * letting the process exit with an unsettled promise.
21
+ */
22
+ export declare function deadline(signal: AbortSignal | undefined, timeoutMs: number | undefined): Deadline;
23
+ //# sourceMappingURL=abort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abort.d.ts","sourceRoot":"","sources":["../../web/src/engine/abort.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C,8EAA8E;AAC9E,eAAO,MAAM,YAAY,WAAY,OAAO,KAAG,eAKnC,CAAA;AAEZ,4DAA4D;AAC5D,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,IAAI,CAEpE;AAED;;;GAGG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC7B,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,MAAM,EAAE,WAAW,GAAG,SAAS,GAChC,OAAO,CAAC,CAAC,CAAC,CAiBZ;AAED,4EAA4E;AAC5E,MAAM,WAAW,QAAQ;IACrB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;IAC5B,wDAAwD;IACxD,KAAK,IAAI,IAAI,CAAA;CAChB;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CACpB,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,SAAS,EAAE,MAAM,GAAG,SAAS,GAC9B,QAAQ,CA0BV"}
@@ -0,0 +1,71 @@
1
+ // Cancellation for renders (concurrency model): an aborted signal rejects
2
+ // at once with `ABORTED`, while the native engine stops at its next page or
3
+ // paragraph on its own (see the backends).
4
+ import { RentnerPdfError } from './errors.js';
5
+ /** The `ABORTED` error for an abort `reason`; an `ABORTED` reason is kept. */
6
+ export const abortedError = (reason) => reason instanceof RentnerPdfError && reason.code === 'ABORTED'
7
+ ? reason
8
+ : new RentnerPdfError('ABORTED', 'the render was aborted', undefined, {
9
+ cause: reason,
10
+ });
11
+ /** Throws the `ABORTED` error when `signal` has aborted. */
12
+ export function throwIfAborted(signal) {
13
+ if (signal?.aborted === true)
14
+ throw abortedError(signal.reason);
15
+ }
16
+ /**
17
+ * Settles like `promise`, but rejects with `ABORTED` as soon as `signal`
18
+ * aborts. The work behind `promise` must stop on its own.
19
+ */
20
+ export async function raceAbort(promise, signal) {
21
+ if (signal === undefined)
22
+ return promise;
23
+ if (signal.aborted) {
24
+ // The work stops on its own; its rejection is expected.
25
+ promise.catch(() => undefined);
26
+ throw abortedError(signal.reason);
27
+ }
28
+ let onAbort;
29
+ const aborted = new Promise((_, reject) => {
30
+ onAbort = () => reject(abortedError(signal.reason));
31
+ signal.addEventListener('abort', onAbort, { once: true });
32
+ });
33
+ try {
34
+ return await Promise.race([promise, aborted]);
35
+ }
36
+ finally {
37
+ if (onAbort !== undefined)
38
+ signal.removeEventListener('abort', onAbort);
39
+ }
40
+ }
41
+ /**
42
+ * Links an optional outer `signal` and an optional timeout into one signal.
43
+ * The timer is ref'd: a render that never finishes fails instead of
44
+ * letting the process exit with an unsettled promise.
45
+ */
46
+ export function deadline(signal, timeoutMs) {
47
+ const controller = new AbortController();
48
+ const abort = (reason) => {
49
+ if (!controller.signal.aborted)
50
+ controller.abort(reason);
51
+ };
52
+ const onAbort = () => abort(signal?.reason);
53
+ if (signal?.aborted === true)
54
+ abort(signal.reason);
55
+ else
56
+ signal?.addEventListener('abort', onAbort, { once: true });
57
+ const timer = timeoutMs === undefined
58
+ ? undefined
59
+ : setTimeout(() => {
60
+ abort(new RentnerPdfError('ABORTED', `the render did not finish within ${timeoutMs} ms (timeoutMs)`));
61
+ }, timeoutMs);
62
+ return {
63
+ signal: controller.signal,
64
+ clear: () => {
65
+ if (timer !== undefined)
66
+ clearTimeout(timer);
67
+ signal?.removeEventListener('abort', onAbort);
68
+ },
69
+ };
70
+ }
71
+ //# sourceMappingURL=abort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abort.js","sourceRoot":"","sources":["../../web/src/engine/abort.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,4EAA4E;AAC5E,2CAA2C;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C,8EAA8E;AAC9E,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAe,EAAmB,EAAE,CAC7D,MAAM,YAAY,eAAe,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS;IAC1D,CAAC,CAAC,MAAM;IACR,CAAC,CAAC,IAAI,eAAe,CAAC,SAAS,EAAE,wBAAwB,EAAE,SAAS,EAAE;QAChE,KAAK,EAAE,MAAM;KAChB,CAAC,CAAA;AAEZ,4DAA4D;AAC5D,MAAM,UAAU,cAAc,CAAC,MAA+B;IAC1D,IAAI,MAAM,EAAE,OAAO,KAAK,IAAI;QAAE,MAAM,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;AACnE,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC3B,OAAmB,EACnB,MAA+B;IAE/B,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,OAAO,CAAA;IACxC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACjB,wDAAwD;QACxD,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;QAC9B,MAAM,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IACrC,CAAC;IACD,IAAI,OAAiC,CAAA;IACrC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;QAC7C,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;QACnD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IAC7D,CAAC,CAAC,CAAA;IACF,IAAI,CAAC;QACD,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;IACjD,CAAC;YAAS,CAAC;QACP,IAAI,OAAO,KAAK,SAAS;YAAE,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC3E,CAAC;AACL,CAAC;AASD;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CACpB,MAA+B,EAC/B,SAA6B;IAE7B,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAA;IACxC,MAAM,KAAK,GAAG,CAAC,MAAe,EAAQ,EAAE;QACpC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO;YAAE,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAC5D,CAAC,CAAA;IACD,MAAM,OAAO,GAAG,GAAS,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjD,IAAI,MAAM,EAAE,OAAO,KAAK,IAAI;QAAE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;;QAC7C,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IAC/D,MAAM,KAAK,GACP,SAAS,KAAK,SAAS;QACnB,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE;YACZ,KAAK,CACD,IAAI,eAAe,CACf,SAAS,EACT,oCAAoC,SAAS,iBAAiB,CACjE,CACJ,CAAA;QACL,CAAC,EAAE,SAAS,CAAC,CAAA;IACvB,OAAO;QACH,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,KAAK,EAAE,GAAG,EAAE;YACR,IAAI,KAAK,KAAK,SAAS;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAA;YAC5C,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACjD,CAAC;KACJ,CAAA;AACL,CAAC","sourcesContent":["// Cancellation for renders (concurrency model): an aborted signal rejects\n// at once with `ABORTED`, while the native engine stops at its next page or\n// paragraph on its own (see the backends).\nimport { RentnerPdfError } from './errors.ts'\n\n/** The `ABORTED` error for an abort `reason`; an `ABORTED` reason is kept. */\nexport const abortedError = (reason: unknown): RentnerPdfError =>\n reason instanceof RentnerPdfError && reason.code === 'ABORTED'\n ? reason\n : new RentnerPdfError('ABORTED', 'the render was aborted', undefined, {\n cause: reason,\n })\n\n/** Throws the `ABORTED` error when `signal` has aborted. */\nexport function throwIfAborted(signal: AbortSignal | undefined): void {\n if (signal?.aborted === true) throw abortedError(signal.reason)\n}\n\n/**\n * Settles like `promise`, but rejects with `ABORTED` as soon as `signal`\n * aborts. The work behind `promise` must stop on its own.\n */\nexport async function raceAbort<T>(\n promise: Promise<T>,\n signal: AbortSignal | undefined,\n): Promise<T> {\n if (signal === undefined) return promise\n if (signal.aborted) {\n // The work stops on its own; its rejection is expected.\n promise.catch(() => undefined)\n throw abortedError(signal.reason)\n }\n let onAbort: (() => void) | undefined\n const aborted = new Promise<never>((_, reject) => {\n onAbort = () => reject(abortedError(signal.reason))\n signal.addEventListener('abort', onAbort, { once: true })\n })\n try {\n return await Promise.race([promise, aborted])\n } finally {\n if (onAbort !== undefined) signal.removeEventListener('abort', onAbort)\n }\n}\n\n/** A signal that aborts with `signal` or after `timeoutMs` milliseconds. */\nexport interface Deadline {\n readonly signal: AbortSignal\n /** Stops the timer and the link to the outer signal. */\n clear(): void\n}\n\n/**\n * Links an optional outer `signal` and an optional timeout into one signal.\n * The timer is ref'd: a render that never finishes fails instead of\n * letting the process exit with an unsettled promise.\n */\nexport function deadline(\n signal: AbortSignal | undefined,\n timeoutMs: number | undefined,\n): Deadline {\n const controller = new AbortController()\n const abort = (reason: unknown): void => {\n if (!controller.signal.aborted) controller.abort(reason)\n }\n const onAbort = (): void => abort(signal?.reason)\n if (signal?.aborted === true) abort(signal.reason)\n else signal?.addEventListener('abort', onAbort, { once: true })\n const timer =\n timeoutMs === undefined\n ? undefined\n : setTimeout(() => {\n abort(\n new RentnerPdfError(\n 'ABORTED',\n `the render did not finish within ${timeoutMs} ms (timeoutMs)`,\n ),\n )\n }, timeoutMs)\n return {\n signal: controller.signal,\n clear: () => {\n if (timer !== undefined) clearTimeout(timer)\n signal?.removeEventListener('abort', onAbort)\n },\n }\n}\n"]}
@@ -0,0 +1,22 @@
1
+ import type { AttachmentSource, ImageSource, SvgSource } from '../ir/Types/input.ts';
2
+ /** Whether `value` is file bytes: a `Uint8Array` (or `Buffer`) or an `ArrayBuffer`. */
3
+ export declare const isImageSource: (value: unknown) => value is ImageSource;
4
+ /** Whether `value` is an attachment's content: bytes or a string. */
5
+ export declare const isAttachmentSource: (value: unknown) => value is AttachmentSource;
6
+ /**
7
+ * Collects asset buffers; the same buffer object, or the same SVG string,
8
+ * gets one index.
9
+ */
10
+ export declare class Assets {
11
+ #private;
12
+ readonly buffers: Uint8Array[];
13
+ index(source: SvgSource): number;
14
+ /** Adds a buffer that no other node shares; returns its index. */
15
+ push(buffer: Uint8Array): number;
16
+ /**
17
+ * Adds an attachment's content as a buffer of its own: the engine
18
+ * embeds it as it is, even when a node shows the same bytes.
19
+ */
20
+ attachment(source: AttachmentSource): number;
21
+ }
22
+ //# sourceMappingURL=assets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../web/src/engine/assets.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACR,gBAAgB,EAChB,WAAW,EACX,SAAS,EACZ,MAAM,sBAAsB,CAAA;AAI7B,uFAAuF;AACvF,eAAO,MAAM,aAAa,UAAW,OAAO,KAAG,KAAK,IAAI,WACO,CAAA;AAE/D,qEAAqE;AACrE,eAAO,MAAM,kBAAkB,UAAW,OAAO,KAAG,KAAK,IAAI,gBACR,CAAA;AASrD;;;GAGG;AACH,qBAAa,MAAM;;IACf,QAAQ,CAAC,OAAO,EAAE,UAAU,EAAE,CAAK;IAGnC,KAAK,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAQ/B;IAED,kEAAkE;IAClE,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAG/B;IAED;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAE3C;CACJ"}
@@ -0,0 +1,40 @@
1
+ const utf8 = new TextEncoder();
2
+ /** Whether `value` is file bytes: a `Uint8Array` (or `Buffer`) or an `ArrayBuffer`. */
3
+ export const isImageSource = (value) => value instanceof Uint8Array || value instanceof ArrayBuffer;
4
+ /** Whether `value` is an attachment's content: bytes or a string. */
5
+ export const isAttachmentSource = (value) => typeof value === 'string' || isImageSource(value);
6
+ const bytesOf = (source) => typeof source === 'string'
7
+ ? utf8.encode(source)
8
+ : source instanceof Uint8Array
9
+ ? source
10
+ : new Uint8Array(source);
11
+ /**
12
+ * Collects asset buffers; the same buffer object, or the same SVG string,
13
+ * gets one index.
14
+ */
15
+ export class Assets {
16
+ buffers = [];
17
+ #indices = new Map();
18
+ index(source) {
19
+ let index = this.#indices.get(source);
20
+ if (index === undefined) {
21
+ index = this.buffers.length;
22
+ this.buffers.push(bytesOf(source));
23
+ this.#indices.set(source, index);
24
+ }
25
+ return index;
26
+ }
27
+ /** Adds a buffer that no other node shares; returns its index. */
28
+ push(buffer) {
29
+ this.buffers.push(buffer);
30
+ return this.buffers.length - 1;
31
+ }
32
+ /**
33
+ * Adds an attachment's content as a buffer of its own: the engine
34
+ * embeds it as it is, even when a node shows the same bytes.
35
+ */
36
+ attachment(source) {
37
+ return this.push(bytesOf(source));
38
+ }
39
+ }
40
+ //# sourceMappingURL=assets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assets.js","sourceRoot":"","sources":["../../web/src/engine/assets.ts"],"names":[],"mappings":"AAUA,MAAM,IAAI,GAAG,IAAI,WAAW,EAAE,CAAA;AAE9B,uFAAuF;AACvF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAc,EAAwB,EAAE,CAClE,KAAK,YAAY,UAAU,IAAI,KAAK,YAAY,WAAW,CAAA;AAE/D,qEAAqE;AACrE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAc,EAA6B,EAAE,CAC5E,OAAO,KAAK,KAAK,QAAQ,IAAI,aAAa,CAAC,KAAK,CAAC,CAAA;AAErD,MAAM,OAAO,GAAG,CAAC,MAAiB,EAAc,EAAE,CAC9C,OAAO,MAAM,KAAK,QAAQ;IACtB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IACrB,CAAC,CAAC,MAAM,YAAY,UAAU;QAC5B,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAA;AAElC;;;GAGG;AACH,MAAM,OAAO,MAAM;IACN,OAAO,GAAiB,EAAE,CAAA;IAC1B,QAAQ,GAAG,IAAI,GAAG,EAAqB,CAAA;IAEhD,KAAK,CAAC,MAAiB;QACnB,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QACrC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACtB,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAA;YAC3B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;YAClC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;QACpC,CAAC;QACD,OAAO,KAAK,CAAA;IAChB,CAAC;IAED,kEAAkE;IAClE,IAAI,CAAC,MAAkB;QACnB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAA;IAClC,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,MAAwB;QAC/B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;IACrC,CAAC;CACJ","sourcesContent":["// The asset buffers of a render (D-06): image bytes, SVG markup, letterhead\n// PDFs and attachments travel next to the document, which references them\n// by index. Both the IR encoder and the React path's per-render registry\n// collect them here.\nimport type {\n AttachmentSource,\n ImageSource,\n SvgSource,\n} from '../ir/Types/input.ts'\n\nconst utf8 = new TextEncoder()\n\n/** Whether `value` is file bytes: a `Uint8Array` (or `Buffer`) or an `ArrayBuffer`. */\nexport const isImageSource = (value: unknown): value is ImageSource =>\n value instanceof Uint8Array || value instanceof ArrayBuffer\n\n/** Whether `value` is an attachment's content: bytes or a string. */\nexport const isAttachmentSource = (value: unknown): value is AttachmentSource =>\n typeof value === 'string' || isImageSource(value)\n\nconst bytesOf = (source: SvgSource): Uint8Array =>\n typeof source === 'string'\n ? utf8.encode(source)\n : source instanceof Uint8Array\n ? source\n : new Uint8Array(source)\n\n/**\n * Collects asset buffers; the same buffer object, or the same SVG string,\n * gets one index.\n */\nexport class Assets {\n readonly buffers: Uint8Array[] = []\n readonly #indices = new Map<SvgSource, number>()\n\n index(source: SvgSource): number {\n let index = this.#indices.get(source)\n if (index === undefined) {\n index = this.buffers.length\n this.buffers.push(bytesOf(source))\n this.#indices.set(source, index)\n }\n return index\n }\n\n /** Adds a buffer that no other node shares; returns its index. */\n push(buffer: Uint8Array): number {\n this.buffers.push(buffer)\n return this.buffers.length - 1\n }\n\n /**\n * Adds an attachment's content as a buffer of its own: the engine\n * embeds it as it is, even when a node shows the same bytes.\n */\n attachment(source: AttachmentSource): number {\n return this.push(bytesOf(source))\n }\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import { type NativeBinding } from '../native/loader.ts';
2
+ import { type WasmBinding, type WasmModuleSource } from '../wasm/loader.ts';
3
+ import type { Backend, BackendChoice, BackendOptions } from './Types/backend.ts';
4
+ /** How the bindings are loaded; tests replace them. */
5
+ export interface BackendLoaders {
6
+ readonly native: () => NativeBinding;
7
+ readonly wasm: (module?: WasmModuleSource) => Promise<WasmBinding>;
8
+ }
9
+ /**
10
+ * Creates the engine of the chosen backend. `auto` uses the native addon
11
+ * when it loads and otherwise falls back to WebAssembly, with a one-time
12
+ * console hint. Errors of the engine itself (such as an unsupported font)
13
+ * never cause a fallback.
14
+ */
15
+ export declare function createBackend(choice: BackendChoice, options: BackendOptions, wasmModule?: WasmModuleSource, loaders?: BackendLoaders): Promise<Backend>;
16
+ //# sourceMappingURL=backend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../web/src/engine/backend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,qBAAqB,CAAA;AACvE,OAAO,EAEH,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACxB,MAAM,mBAAmB,CAAA;AAG1B,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAEhF,uDAAuD;AACvD,MAAM,WAAW,cAAc;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,aAAa,CAAA;IACpC,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,gBAAgB,KAAK,OAAO,CAAC,WAAW,CAAC,CAAA;CACrE;AAYD;;;;;GAKG;AACH,wBAAsB,aAAa,CAC/B,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,cAAc,EACvB,UAAU,CAAC,EAAE,gBAAgB,EAC7B,OAAO,GAAE,cAA+B,GACzC,OAAO,CAAC,OAAO,CAAC,CA4BlB"}
@@ -0,0 +1,43 @@
1
+ import { nativeBinding } from '../native/loader.js';
2
+ import { loadWasmBinding, } from '../wasm/loader.js';
3
+ import { createNativeBackend } from './backends/native.js';
4
+ import { createWasmBackend } from './backends/wasm.js';
5
+ const defaultLoaders = {
6
+ native: nativeBinding,
7
+ wasm: loadWasmBinding,
8
+ };
9
+ let fallbackReported = false;
10
+ const reason = (error) => error instanceof Error ? error.message : String(error);
11
+ /**
12
+ * Creates the engine of the chosen backend. `auto` uses the native addon
13
+ * when it loads and otherwise falls back to WebAssembly, with a one-time
14
+ * console hint. Errors of the engine itself (such as an unsupported font)
15
+ * never cause a fallback.
16
+ */
17
+ export async function createBackend(choice, options, wasmModule, loaders = defaultLoaders) {
18
+ if (choice === 'wasm') {
19
+ return createWasmBackend(await loaders.wasm(wasmModule), options);
20
+ }
21
+ let native;
22
+ try {
23
+ native = loaders.native();
24
+ }
25
+ catch (nativeError) {
26
+ if (choice === 'native')
27
+ throw nativeError;
28
+ let wasm;
29
+ try {
30
+ wasm = await loaders.wasm(wasmModule);
31
+ }
32
+ catch (wasmError) {
33
+ throw new AggregateError([nativeError, wasmError], 'RentnerPDF could not load its native or WebAssembly engine.', { cause: wasmError });
34
+ }
35
+ if (!fallbackReported) {
36
+ fallbackReported = true;
37
+ console.warn(`RentnerPDF falls back to its WebAssembly engine, which renders on the calling thread: ${reason(nativeError)}`);
38
+ }
39
+ return createWasmBackend(wasm, options);
40
+ }
41
+ return createNativeBackend(native, options);
42
+ }
43
+ //# sourceMappingURL=backend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backend.js","sourceRoot":"","sources":["../../web/src/engine/backend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACvE,OAAO,EACH,eAAe,GAGlB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAStD,MAAM,cAAc,GAAmB;IACnC,MAAM,EAAE,aAAa;IACrB,IAAI,EAAE,eAAe;CACxB,CAAA;AAED,IAAI,gBAAgB,GAAG,KAAK,CAAA;AAE5B,MAAM,MAAM,GAAG,CAAC,KAAc,EAAU,EAAE,CACtC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAE1D;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAC/B,MAAqB,EACrB,OAAuB,EACvB,UAA6B,EAC7B,OAAO,GAAmB,cAAc;IAExC,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACpB,OAAO,iBAAiB,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,CAAA;IACrE,CAAC;IACD,IAAI,MAAqB,CAAA;IACzB,IAAI,CAAC;QACD,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAA;IAC7B,CAAC;IAAC,OAAO,WAAW,EAAE,CAAC;QACnB,IAAI,MAAM,KAAK,QAAQ;YAAE,MAAM,WAAW,CAAA;QAC1C,IAAI,IAAiB,CAAA;QACrB,IAAI,CAAC;YACD,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QACzC,CAAC;QAAC,OAAO,SAAS,EAAE,CAAC;YACjB,MAAM,IAAI,cAAc,CACpB,CAAC,WAAW,EAAE,SAAS,CAAC,EACxB,6DAA6D,EAC7D,EAAE,KAAK,EAAE,SAAS,EAAE,CACvB,CAAA;QACL,CAAC;QACD,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACpB,gBAAgB,GAAG,IAAI,CAAA;YACvB,OAAO,CAAC,IAAI,CACR,yFAAyF,MAAM,CAAC,WAAW,CAAC,EAAE,CACjH,CAAA;QACL,CAAC;QACD,OAAO,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAC3C,CAAC;IACD,OAAO,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAC/C,CAAC","sourcesContent":["import { type NativeBinding, nativeBinding } from '../native/loader.ts'\nimport {\n loadWasmBinding,\n type WasmBinding,\n type WasmModuleSource,\n} from '../wasm/loader.ts'\nimport { createNativeBackend } from './backends/native.ts'\nimport { createWasmBackend } from './backends/wasm.ts'\nimport type { Backend, BackendChoice, BackendOptions } from './Types/backend.ts'\n\n/** How the bindings are loaded; tests replace them. */\nexport interface BackendLoaders {\n readonly native: () => NativeBinding\n readonly wasm: (module?: WasmModuleSource) => Promise<WasmBinding>\n}\n\nconst defaultLoaders: BackendLoaders = {\n native: nativeBinding,\n wasm: loadWasmBinding,\n}\n\nlet fallbackReported = false\n\nconst reason = (error: unknown): string =>\n error instanceof Error ? error.message : String(error)\n\n/**\n * Creates the engine of the chosen backend. `auto` uses the native addon\n * when it loads and otherwise falls back to WebAssembly, with a one-time\n * console hint. Errors of the engine itself (such as an unsupported font)\n * never cause a fallback.\n */\nexport async function createBackend(\n choice: BackendChoice,\n options: BackendOptions,\n wasmModule?: WasmModuleSource,\n loaders: BackendLoaders = defaultLoaders,\n): Promise<Backend> {\n if (choice === 'wasm') {\n return createWasmBackend(await loaders.wasm(wasmModule), options)\n }\n let native: NativeBinding\n try {\n native = loaders.native()\n } catch (nativeError) {\n if (choice === 'native') throw nativeError\n let wasm: WasmBinding\n try {\n wasm = await loaders.wasm(wasmModule)\n } catch (wasmError) {\n throw new AggregateError(\n [nativeError, wasmError],\n 'RentnerPDF could not load its native or WebAssembly engine.',\n { cause: wasmError },\n )\n }\n if (!fallbackReported) {\n fallbackReported = true\n console.warn(\n `RentnerPDF falls back to its WebAssembly engine, which renders on the calling thread: ${reason(nativeError)}`,\n )\n }\n return createWasmBackend(wasm, options)\n }\n return createNativeBackend(native, options)\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import type { NativeBinding } from '../../native/loader.ts';
2
+ import type { Backend, BackendOptions } from '../Types/backend.ts';
3
+ /**
4
+ * The native engine: renders off the event loop on the engine's own render
5
+ * threads (at most `threads` at a time); `renderSync` renders on the
6
+ * calling thread. A signal cancels a render through a cancel token: the
7
+ * engine stops at its next page or paragraph, or at once when the render
8
+ * still waits for a thread.
9
+ */
10
+ export declare function createNativeBackend(binding: NativeBinding, { fonts, defaultFonts, strict, imageCacheBytes, shapedRunsMax, threads, limits, theme, }: BackendOptions): Backend;
11
+ //# sourceMappingURL=native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../../web/src/engine/backends/native.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAE3D,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAgBlE;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAC/B,OAAO,EAAE,aAAa,EACtB,EACI,KAAK,EACL,YAAY,EACZ,MAAM,EACN,eAAe,EACf,aAAa,EACb,OAAO,EACP,MAAM,EACN,KAAK,GACR,EAAE,cAAc,GAClB,OAAO,CAoDT"}
@@ -0,0 +1,62 @@
1
+ import { assertIrVersion } from '../../ir/version.js';
2
+ const nativeTheme = ({ stylesheets, variables, rootFontSize, }) => ({
3
+ stylesheets: stylesheets.map(({ css, scopes, source }) => ({
4
+ css,
5
+ scopes: [...scopes],
6
+ ...(source === undefined ? {} : { source }),
7
+ })),
8
+ variables: variables.map(([name, value]) => ({ name, value })),
9
+ ...(rootFontSize === undefined ? {} : { rootFontSize }),
10
+ });
11
+ /**
12
+ * The native engine: renders off the event loop on the engine's own render
13
+ * threads (at most `threads` at a time); `renderSync` renders on the
14
+ * calling thread. A signal cancels a render through a cancel token: the
15
+ * engine stops at its next page or paragraph, or at once when the render
16
+ * still waits for a thread.
17
+ */
18
+ export function createNativeBackend(binding, { fonts, defaultFonts, strict, imageCacheBytes, shapedRunsMax, threads, limits, theme, }) {
19
+ assertIrVersion('native', binding.irVersion());
20
+ const native = new binding.NativeEngine([...fonts], [...defaultFonts], {
21
+ strict,
22
+ imageCacheBytes,
23
+ shapedRunsMax,
24
+ threads,
25
+ ...(limits === undefined ? {} : { limits: { ...limits } }),
26
+ ...(theme === undefined ? {} : { theme: nativeTheme(theme) }),
27
+ });
28
+ const cancellable = async (signal, run) => {
29
+ if (signal === undefined)
30
+ return run(undefined);
31
+ const token = new binding.NativeCancelToken();
32
+ const onAbort = () => token.cancel();
33
+ if (signal.aborted)
34
+ token.cancel();
35
+ else
36
+ signal.addEventListener('abort', onAbort, { once: true });
37
+ try {
38
+ return await run(token);
39
+ }
40
+ finally {
41
+ signal.removeEventListener('abort', onAbort);
42
+ }
43
+ };
44
+ return {
45
+ name: 'native',
46
+ version: binding.engineVersion(),
47
+ themeWarnings: native.themeWarnings(),
48
+ threads: native.threads,
49
+ render: ({ ir, assets }, signal) => cancellable(signal, (token) => native.render(ir, assets, token)),
50
+ renderDetailed: ({ ir, assets }, signal) => cancellable(signal, (token) => native.renderDetailed(ir, assets, token)),
51
+ renderSync: ({ ir, assets }) => native.renderSync(ir, assets),
52
+ renderMarkup: ({ markup, assets, channel }, signal) => cancellable(signal, (token) => native.renderMarkup(markup, assets, channel, token)),
53
+ renderMarkupDetailed: ({ markup, assets, channel }, signal) => cancellable(signal, (token) => native.renderMarkupDetailed(markup, assets, channel, token)),
54
+ markupDebugPaths: (markup) => binding.markupDebugPaths(markup),
55
+ stats: () => native.stats(),
56
+ registerFont: (font) => native.registerFont(font),
57
+ // Renders still on the render threads keep the engine alive until
58
+ // they finish; the lifecycle calls this once they have settled.
59
+ close: () => native.close(),
60
+ };
61
+ }
62
+ //# sourceMappingURL=native.js.map