@rentnerkev/pdf 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/README.md +6 -6
  2. package/THIRD_PARTY_NOTICES.md +1 -1
  3. package/dist/ai.d.ts.map +1 -1
  4. package/dist/ai.js +8 -3
  5. package/dist/ai.js.map +1 -1
  6. package/dist/components/Types/props.d.ts +2 -2
  7. package/dist/components/components.d.ts +5 -5
  8. package/dist/components/components.d.ts.map +1 -1
  9. package/dist/components/components.js +16 -16
  10. package/dist/components/components.js.map +1 -1
  11. package/dist/components/host.d.ts +2 -2
  12. package/dist/engine/Types/backend.d.ts +5 -5
  13. package/dist/engine/Types/engine.d.ts +8 -8
  14. package/dist/engine/Types/errors.d.ts +2 -2
  15. package/dist/engine/Types/render-options.d.ts +1 -1
  16. package/dist/engine/Types/render-result.d.ts +1 -1
  17. package/dist/engine/abort.d.ts +2 -2
  18. package/dist/engine/abort.d.ts.map +1 -1
  19. package/dist/engine/abort.js +2 -2
  20. package/dist/engine/abort.js.map +1 -1
  21. package/dist/engine/assets.d.ts +4 -3
  22. package/dist/engine/assets.d.ts.map +1 -1
  23. package/dist/engine/assets.js +19 -11
  24. package/dist/engine/assets.js.map +1 -1
  25. package/dist/engine/backend.d.ts +5 -5
  26. package/dist/engine/backend.d.ts.map +1 -1
  27. package/dist/engine/backend.js +12 -9
  28. package/dist/engine/backend.js.map +1 -1
  29. package/dist/engine/backends/native.d.ts +2 -2
  30. package/dist/engine/backends/wasm.d.ts +2 -2
  31. package/dist/engine/backends/wasm.d.ts.map +1 -1
  32. package/dist/engine/backends/wasm.js +12 -4
  33. package/dist/engine/backends/wasm.js.map +1 -1
  34. package/dist/engine/channel.d.ts +5 -8
  35. package/dist/engine/channel.d.ts.map +1 -1
  36. package/dist/engine/channel.js +71 -43
  37. package/dist/engine/channel.js.map +1 -1
  38. package/dist/engine/create-engine.d.ts +1 -1
  39. package/dist/engine/create-engine.d.ts.map +1 -1
  40. package/dist/engine/create-engine.js +11 -5
  41. package/dist/engine/create-engine.js.map +1 -1
  42. package/dist/engine/default-fonts.d.ts.map +1 -1
  43. package/dist/engine/default-fonts.js +24 -17
  44. package/dist/engine/default-fonts.js.map +1 -1
  45. package/dist/engine/encode.d.ts +5 -4
  46. package/dist/engine/encode.d.ts.map +1 -1
  47. package/dist/engine/encode.js +15 -10
  48. package/dist/engine/encode.js.map +1 -1
  49. package/dist/engine/errors.d.ts +3 -3
  50. package/dist/engine/fonts.d.ts +1 -1
  51. package/dist/engine/markup.d.ts +3 -3
  52. package/dist/engine/options.d.ts +2 -2
  53. package/dist/engine/prepare.d.ts +4 -4
  54. package/dist/engine/render-many.d.ts +3 -3
  55. package/dist/engine/render-result.d.ts +9 -3
  56. package/dist/engine/render-result.d.ts.map +1 -1
  57. package/dist/engine/render-result.js +8 -1
  58. package/dist/engine/render-result.js.map +1 -1
  59. package/dist/engine/render-stream.d.ts +1 -1
  60. package/dist/engine/render.d.ts +3 -3
  61. package/dist/index.d.ts +24 -24
  62. package/dist/ir/Types/input.d.ts +1 -1
  63. package/dist/ir/factories.d.ts +3 -3
  64. package/dist/ir/factories.d.ts.map +1 -1
  65. package/dist/ir/factories.js +8 -3
  66. package/dist/ir/factories.js.map +1 -1
  67. package/dist/ir/page-variants.d.ts +3 -0
  68. package/dist/ir/page-variants.d.ts.map +1 -0
  69. package/dist/ir/page-variants.js +3 -0
  70. package/dist/ir/page-variants.js.map +1 -0
  71. package/dist/jsx/Types/context.d.ts +1 -1
  72. package/dist/jsx/Types/evaluate.d.ts +4 -4
  73. package/dist/jsx/Types/jsx.d.ts +1 -1
  74. package/dist/jsx/context.d.ts +1 -1
  75. package/dist/jsx/element.d.ts +1 -1
  76. package/dist/jsx/evaluate.d.ts +3 -3
  77. package/dist/jsx/evaluate.d.ts.map +1 -1
  78. package/dist/jsx/evaluate.js +20 -52
  79. package/dist/jsx/evaluate.js.map +1 -1
  80. package/dist/jsx/source.d.ts +1 -1
  81. package/dist/jsx-dev-runtime.d.ts +3 -3
  82. package/dist/jsx-runtime.d.ts +3 -3
  83. package/dist/native/loader.d.ts.map +1 -1
  84. package/dist/native/loader.js +33 -27
  85. package/dist/native/loader.js.map +1 -1
  86. package/dist/native/rentnerpdf.linux-arm64-gnu.node +0 -0
  87. package/dist/native/rentnerpdf.linux-arm64-musl.node +0 -0
  88. package/dist/native/rentnerpdf.linux-x64-gnu.node +0 -0
  89. package/dist/native/rentnerpdf.linux-x64-musl.node +0 -0
  90. package/dist/native/rentnerpdf.win32-arm64-msvc.node +0 -0
  91. package/dist/native/rentnerpdf.win32-x64-msvc.node +0 -0
  92. package/dist/node.d.ts +2 -2
  93. package/dist/react/Types/preview.d.ts +16 -11
  94. package/dist/react/Types/preview.d.ts.map +1 -1
  95. package/dist/react/Types/preview.js.map +1 -1
  96. package/dist/react/Types/render.d.ts +1 -1
  97. package/dist/react/components.d.ts +4 -4
  98. package/dist/react/components.d.ts.map +1 -1
  99. package/dist/react/components.js +23 -23
  100. package/dist/react/components.js.map +1 -1
  101. package/dist/react/pdf-preview.d.ts +3 -2
  102. package/dist/react/pdf-preview.d.ts.map +1 -1
  103. package/dist/react/pdf-preview.js +2 -1
  104. package/dist/react/pdf-preview.js.map +1 -1
  105. package/dist/react/pdf-render.d.ts +4 -4
  106. package/dist/react/pdf-render.d.ts.map +1 -1
  107. package/dist/react/pdf-render.js +20 -12
  108. package/dist/react/pdf-render.js.map +1 -1
  109. package/dist/react/registry.d.ts +3 -3
  110. package/dist/react/registry.d.ts.map +1 -1
  111. package/dist/react/registry.js +6 -3
  112. package/dist/react/registry.js.map +1 -1
  113. package/dist/react/render.d.ts +4 -4
  114. package/dist/react/render.d.ts.map +1 -1
  115. package/dist/react/render.js +36 -54
  116. package/dist/react/render.js.map +1 -1
  117. package/dist/react/same-document.d.ts +2 -1
  118. package/dist/react/same-document.d.ts.map +1 -1
  119. package/dist/react/same-document.js +7 -1
  120. package/dist/react/same-document.js.map +1 -1
  121. package/dist/react/static.d.ts +5 -0
  122. package/dist/react/static.d.ts.map +1 -1
  123. package/dist/react/static.js +20 -16
  124. package/dist/react/static.js.map +1 -1
  125. package/dist/react/use-pdf.d.ts +5 -5
  126. package/dist/react/use-pdf.d.ts.map +1 -1
  127. package/dist/react/use-pdf.js +81 -14
  128. package/dist/react/use-pdf.js.map +1 -1
  129. package/dist/react.d.ts +8 -8
  130. package/dist/tailwind-merge.d.ts +2 -2
  131. package/dist/theme/Types/theme.d.ts +8 -1
  132. package/dist/theme/Types/theme.d.ts.map +1 -1
  133. package/dist/theme/Types/theme.js.map +1 -1
  134. package/dist/theme/css-imports.d.ts +1 -1
  135. package/dist/theme/normalize.d.ts +2 -2
  136. package/dist/theme/package-imports.d.ts +1 -8
  137. package/dist/theme/package-imports.d.ts.map +1 -1
  138. package/dist/theme/package-imports.js +4 -11
  139. package/dist/theme/package-imports.js.map +1 -1
  140. package/dist/theme/paths.d.ts +6 -0
  141. package/dist/theme/paths.d.ts.map +1 -0
  142. package/dist/theme/paths.js +13 -0
  143. package/dist/theme/paths.js.map +1 -0
  144. package/dist/theme/theme-from-css-file.d.ts +1 -3
  145. package/dist/theme/theme-from-css-file.d.ts.map +1 -1
  146. package/dist/theme/theme-from-css-file.js +16 -21
  147. package/dist/theme/theme-from-css-file.js.map +1 -1
  148. package/dist/theme/theme-from-css.d.ts +1 -1
  149. package/dist/theme/warnings.d.ts +1 -4
  150. package/dist/theme/warnings.d.ts.map +1 -1
  151. package/dist/theme/warnings.js +1 -1
  152. package/dist/theme/warnings.js.map +1 -1
  153. package/dist/vite/plugin.d.ts +3 -6
  154. package/dist/vite/plugin.d.ts.map +1 -1
  155. package/dist/vite/plugin.js +17 -7
  156. package/dist/vite/plugin.js.map +1 -1
  157. package/dist/vite.d.ts +2 -2
  158. package/dist/wasm/binding.generated.d.ts +19 -14
  159. package/dist/wasm/loader.d.ts.map +1 -1
  160. package/dist/wasm/loader.js +11 -3
  161. package/dist/wasm/loader.js.map +1 -1
  162. package/dist/wasm/node-path.d.ts +3 -0
  163. package/dist/wasm/node-path.d.ts.map +1 -0
  164. package/dist/wasm/node-path.js +4 -0
  165. package/dist/wasm/node-path.js.map +1 -0
  166. package/dist/wasm/pkg/rentnerpdf_wasm.d.ts +19 -14
  167. package/dist/wasm/pkg/rentnerpdf_wasm.js +39 -75
  168. package/dist/wasm/pkg/rentnerpdf_wasm_bg.wasm +0 -0
  169. package/dist/wasm/pkg/rentnerpdf_wasm_bg.wasm.d.ts +8 -7
  170. package/dist/worker/Types/connection.d.ts +1 -1
  171. package/dist/worker/Types/protocol.d.ts +2 -2
  172. package/dist/worker/Types/worker-engine.d.ts +3 -3
  173. package/dist/worker/client.d.ts +1 -1
  174. package/dist/worker/client.d.ts.map +1 -1
  175. package/dist/worker/client.js +10 -10
  176. package/dist/worker/client.js.map +1 -1
  177. package/dist/worker/connection.d.ts +2 -2
  178. package/dist/worker/protocol.d.ts +2 -2
  179. package/dist/worker/protocol.js.map +1 -1
  180. package/dist/worker/serve.d.ts +3 -5
  181. package/dist/worker/serve.d.ts.map +1 -1
  182. package/dist/worker/serve.js +1 -1
  183. package/dist/worker/serve.js.map +1 -1
  184. package/dist/worker.d.ts +3 -3
  185. package/docs/usage.md +51 -49
  186. package/package.json +4 -1
  187. package/dist/engine/pdf-bytes.d.ts +0 -8
  188. package/dist/engine/pdf-bytes.d.ts.map +0 -1
  189. package/dist/engine/pdf-bytes.js +0 -9
  190. package/dist/engine/pdf-bytes.js.map +0 -1
  191. package/dist/theme/Types/warnings.d.ts +0 -9
  192. package/dist/theme/Types/warnings.d.ts.map +0 -1
  193. package/dist/theme/Types/warnings.js +0 -2
  194. package/dist/theme/Types/warnings.js.map +0 -1
package/README.md CHANGED
@@ -31,16 +31,16 @@ RentnerPDF is a PDF engine for JavaScript and TypeScript with a Rust core. Descr
31
31
 
32
32
  ## Performance
33
33
 
34
- From the [benchmark report](docs/benchmarks.md): GitHub-hosted Linux runners with 4 vCPUs, Node.js 24, 02.12.2026, against React-PDF 4.9.2 and pdfmake 0.3.15; every output passes the same correctness gate.
34
+ From the [benchmark report](docs/benchmarks.md): GitHub-hosted Linux runners with 4 vCPUs, Node.js 24, 03.12.2026, against React-PDF 4.9.2 and pdfmake 0.3.15. The numbers shown passed the same correctness gate.
35
35
 
36
36
  | Focus area | RentnerPDF | pdfmake | React-PDF |
37
37
  | --------------------------------------------------- | -------------------- | ------------------- | ------------------- |
38
- | Mass generation: 10,000 invoices on 4 workers | 697 docs/s, 199 MiB | 54 docs/s, 1.25 GiB | 43 docs/s, 7.99 GiB |
39
- | Event loop while serving invoices: timer drift p99 | 3.2 ms at 961 PDFs/s | 224 ms at 37 PDFs/s | 306 ms at 29 PDFs/s |
40
- | 500-page statement, 24,000 rows with running totals | 1.38 s, 579 MiB | not supported | not supported |
41
- | 100-page text report | 143 ms, 210 MiB | 869 ms, 594 MiB | 3.80 s, 1.37 GiB |
38
+ | Mass generation: 10,000 invoices on 4 workers | 943 docs/s, 203 MiB | 75 docs/s, 1.23 GiB | 60 docs/s, 7.59 GiB |
39
+ | Event loop while serving invoices: timer drift p99 | 3.8 ms at 749 PDFs/s | 323 ms at 27 PDFs/s | 457 ms at 20 PDFs/s |
40
+ | 500-page statement, 24,000 rows with running totals | 798 ms, 642 MiB | not supported | not supported |
41
+ | 100-page text report | 108 ms, 204 MiB | 681 ms, 589 MiB | 3.04 s, 1.69 GiB |
42
42
 
43
- The report also covers the WebAssembly engine, every case where another library wins, a local run on Windows and how to reproduce each number.
43
+ The report also covers the WebAssembly engine, cases where another library wins, and how to reproduce each number.
44
44
 
45
45
  ## Requirements
46
46
 
@@ -1,6 +1,6 @@
1
1
  # Third-party notices
2
2
 
3
- RentnerPDF is MIT-licensed (see [LICENSE](LICENSE)). The npm packages also contain the following third-party material under its own license. The main package `@rentnerkev/pdf` ships the Noto Sans files. The engine includes Tailwind's default theme, hyphenation patterns, tiny-skia-path and the sRGB ICC profiles of PDF/A output intents. Every package ships this file.
3
+ RentnerPDF is MIT-licensed (see [LICENSE](LICENSE)). The npm package `@rentnerkev/pdf` ships this notice and the Noto Sans files. Its bundled engines include Tailwind's default theme, hyphenation patterns, tiny-skia-path and the sRGB ICC profiles of PDF/A output intents. Each third-party component is distributed under its own license.
4
4
 
5
5
  ## Noto Sans
6
6
 
package/dist/ai.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../web/src/ai.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;IACzC,OAAO,EAAE,MAAM,CACX,MAAM,EACN,MAAM,GAAG;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CACjE,CAAA;IACD,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC3C;AAED,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,UAAU;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,YAAY,EAAE,eAAe,EAAE,CAAA;CAClC;AAED,MAAM,WAAW,kBAAkB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WA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AAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,YAAY,EAAE,eAAe,EAAE,CAAA;CAClC;AAED,MAAM,WAAW,kBAAkB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,cAAc;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;CACf;AAID,4EAA4E;AAC5E,wBAAgB,cAAc,IAAI,WAAW,CAc5C;AAED,gEAAgE;AAChE,wBAAgB,uBAAuB,CACnC,QAAQ,GAAE,QAAQ,GAAG,OAAiB,GACvC,eAAe,CAMjB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CACzB,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GACpD,UAAU,CA0GZ;AAED,+DAA+D;AAC/D,wBAAgB,0BAA0B,CACtC,KAAK,EAAE,MAAM,GACd,kBAAkB,EAAE,CAatB;AAED,4EAA4E;AAC5E,wBAAgB,kBAAkB,IAAI,cAAc,EAAE,CASrD"}
package/dist/ai.js CHANGED
@@ -49,13 +49,15 @@ export function getPackageApi(options = {}) {
49
49
  : { [options.subpath]: subpaths[options.subpath] };
50
50
  const declarations = new Map();
51
51
  const publicNames = new Set();
52
+ const distRoot = new URL('dist/', packageRoot);
53
+ const distPath = realpathSync(distRoot);
52
54
  function readDeclaration(path) {
53
55
  const url = new URL(path, packageRoot);
54
- const distRoot = new URL('dist/', packageRoot).href;
55
- if (!url.href.startsWith(distRoot) || !url.pathname.endsWith('.d.ts')) {
56
+ if (!url.href.startsWith(distRoot.href) ||
57
+ !url.pathname.endsWith('.d.ts')) {
56
58
  throw new Error('Declaration must remain inside packaged dist');
57
59
  }
58
- const location = relative(realpathSync(new URL('dist/', packageRoot)), realpathSync(fileURLToPath(url)));
60
+ const location = relative(distPath, realpathSync(fileURLToPath(url)));
59
61
  if (isAbsolute(location) ||
60
62
  location === '..' ||
61
63
  location.startsWith('..' + sep)) {
@@ -96,6 +98,9 @@ export function getPackageApi(options = {}) {
96
98
  publicNames.add(name.trim());
97
99
  }
98
100
  }
101
+ for (const match of content.matchAll(/export\s+(?:type\s+)?\*\s+as\s+([A-Za-z_$][\w$]*)\s+from\s*['"]/g)) {
102
+ publicNames.add(match[1]);
103
+ }
99
104
  for (const match of content.matchAll(/export\s+(?:type\s+)?\*\s+from\s*(['"])(\.[^'"]+)\1/g)) {
100
105
  collectPublicNames(new URL(match[2].replace(/\.(?:tsx?|jsx?)$/, '.d.ts'), url)
101
106
  .href);
package/dist/ai.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ai.js","sourceRoot":"","sources":["../web/src/ai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAuCxC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,KAAK,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;AAEnD,4EAA4E;AAC5E,MAAM,UAAU,cAAc;IAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CACvB,YAAY,CAAC,IAAI,GAAG,CAAC,cAAc,EAAE,WAAW,CAAC,EAAE,MAAM,CAAC,CAC9C,CAAA;IAChB,OAAO;QACH,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,QAAQ,EAAE,QAAQ,CAAC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AM,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IACzC,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAA;IACtB,OAAQ,CAAC,QAAQ,EAAE,OAAO,CAAW,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACnD,MAAM,QAAQ,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAA;QAC9C,OAAO,QAAQ,CAAC,OAAO;aAClB,KAAK,CAAC,IAAI,CAAC;aACX,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACrB,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC;YAC/B,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;YAClD,CAAC,CAAC,EAAE,CACX,CAAA;IACT,CAAC,CAAC,CAAA;AACN,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,kBAAkB;IAC9B,OAAO;QACH,GAAG,uBAAuB,EAAE,CAAC,OAAO,CAAC,QAAQ,CACzC,6BAA6B,CAChC;KACJ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACd,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAE,CAAC,IAAI,EAAE;QAC1B,IAAI,EAAE,KAAK,CAAC,CAAC,CAAE,CAAC,OAAO,EAAE;KAC5B,CAAC,CAAC,CAAA;AACP,CAAC","sourcesContent":["import { readFileSync, realpathSync } from 'node:fs'\nimport { isAbsolute, relative, sep } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nexport interface PackageInfo {\n name: string\n version: string\n description: string\n license: string\n homepage: string\n repository: { type: string; url: string }\n exports: Record<\n string,\n string | { types?: string; import?: string; default?: string }\n >\n peerDependencies: Record<string, string>\n}\n\nexport interface PackageDocument {\n path: string\n content: string\n}\n\nexport interface PackageApi {\n package: string\n version: string\n subpaths: Record<string, string>\n declarations: PackageDocument[]\n}\n\nexport interface PackageSearchMatch {\n path: string\n line: number\n text: string\n}\n\nexport interface PackageExample {\n language: string\n code: string\n}\n\nconst packageRoot = new URL('../', import.meta.url)\n\n/** Read installed-package metadata without importing its UI entry point. */\nexport function getPackageInfo(): PackageInfo {\n const manifest = JSON.parse(\n readFileSync(new URL('package.json', packageRoot), 'utf8'),\n ) as PackageInfo\n return {\n name: manifest.name,\n version: manifest.version,\n description: manifest.description,\n license: manifest.license,\n homepage: manifest.homepage,\n repository: manifest.repository,\n exports: manifest.exports,\n peerDependencies: manifest.peerDependencies,\n }\n}\n\n/** Only these two explicitly packaged documents can be read. */\nexport function getPackageDocumentation(\n document: 'readme' | 'usage' = 'usage',\n): PackageDocument {\n if (document !== 'readme' && document !== 'usage') {\n throw new Error('Unknown package document')\n }\n const path = document === 'readme' ? 'README.md' : 'docs/usage.md'\n return { path, content: readFileSync(new URL(path, packageRoot), 'utf8') }\n}\n\n/** Return export entry declarations and their local declaration dependencies.\n * The AI entry itself is excluded. No module is executed and callers cannot\n * supply file paths. Symbols must be exported by a selected public entry.\n */\nexport function getPackageApi(\n options: { subpath?: string; symbol?: string } = {},\n): PackageApi {\n const info = getPackageInfo()\n const subpaths: Record<string, string> = {}\n for (const [subpath, entry] of Object.entries(info.exports)) {\n if (subpath !== './ai' && typeof entry !== 'string' && entry.types) {\n subpaths[subpath] = entry.types\n }\n }\n if (\n options.subpath !== undefined &&\n !Object.hasOwn(subpaths, options.subpath)\n ) {\n throw new Error(`Unknown public subpath: ${options.subpath}`)\n }\n if (\n options.symbol !== undefined &&\n !/^[A-Za-z_$][\\w$]*$/.test(options.symbol)\n ) {\n throw new Error('Invalid public symbol')\n }\n const selected =\n options.subpath === undefined\n ? subpaths\n : { [options.subpath]: subpaths[options.subpath]! }\n const declarations = new Map<string, PackageDocument>()\n const publicNames = new Set<string>()\n function readDeclaration(path: string): string {\n const url = new URL(path, packageRoot)\n const distRoot = new URL('dist/', packageRoot).href\n if (!url.href.startsWith(distRoot) || !url.pathname.endsWith('.d.ts')) {\n throw new Error('Declaration must remain inside packaged dist')\n }\n const location = relative(\n realpathSync(new URL('dist/', packageRoot)),\n realpathSync(fileURLToPath(url)),\n )\n if (\n isAbsolute(location) ||\n location === '..' ||\n location.startsWith('..' + sep)\n ) {\n throw new Error('Declaration must remain inside packaged dist')\n }\n const existing = declarations.get(url.href)\n if (existing) return existing.content\n const content = readFileSync(url, 'utf8')\n declarations.set(url.href, {\n path: decodeURIComponent(url.href.slice(packageRoot.href.length)),\n content,\n })\n for (const match of content.matchAll(\n /(?:from\\s*|import\\s*\\()(['\"])(\\.[^'\"]+)\\1/g,\n )) {\n const target = match[2]!.replace(/\\.(?:tsx?|jsx?)$/, '.d.ts')\n readDeclaration(new URL(target, url).href)\n }\n return content\n }\n const publicEntries = new Set<string>()\n function collectPublicNames(path: string): void {\n const url = new URL(path, packageRoot)\n if (publicEntries.has(url.href)) return\n publicEntries.add(url.href)\n const content = readDeclaration(path)\n for (const match of content.matchAll(\n /export\\s+(?:declare\\s+)?(?:abstract\\s+)?(?:const|let|var|function|class|interface|type|enum)\\s+([\\w$]+)/g,\n )) {\n publicNames.add(match[1]!)\n }\n for (const match of content.matchAll(\n /export\\s+(?:type\\s+)?\\{([^}]+)\\}/g,\n )) {\n for (const item of match[1]!.split(',')) {\n const name = item\n .trim()\n .replace(/^type\\s+/, '')\n .split(/\\s+as\\s+/)\n .at(-1)\n if (name) publicNames.add(name.trim())\n }\n }\n for (const match of content.matchAll(\n /export\\s+(?:type\\s+)?\\*\\s+from\\s*(['\"])(\\.[^'\"]+)\\1/g,\n )) {\n collectPublicNames(\n new URL(match[2]!.replace(/\\.(?:tsx?|jsx?)$/, '.d.ts'), url)\n .href,\n )\n }\n }\n for (const path of Object.values(selected)) collectPublicNames(path)\n if (options.symbol !== undefined && !publicNames.has(options.symbol)) {\n throw new Error(`Unknown public symbol: ${options.symbol}`)\n }\n return {\n package: info.name,\n version: info.version,\n subpaths: selected,\n declarations: [...declarations.values()],\n }\n}\n\n/** Literal, case-insensitive search of the packaged guides. */\nexport function searchPackageDocumentation(\n query: string,\n): PackageSearchMatch[] {\n const needle = query.trim().toLowerCase()\n if (!needle) return []\n return (['readme', 'usage'] as const).flatMap((name) => {\n const document = getPackageDocumentation(name)\n return document.content\n .split('\\n')\n .flatMap((text, index) =>\n text.toLowerCase().includes(needle)\n ? [{ path: document.path, line: index + 1, text }]\n : [],\n )\n })\n}\n\n/** Code examples come directly from the installed version's usage guide. */\nexport function getPackageExamples(): PackageExample[] {\n return [\n ...getPackageDocumentation().content.matchAll(\n /```([^\\n]*)\\n([\\s\\S]*?)```/g,\n ),\n ].map((match) => ({\n language: match[1]!.trim(),\n code: match[2]!.trimEnd(),\n }))\n}\n"]}
1
+ {"version":3,"file":"ai.js","sourceRoot":"","sources":["../web/src/ai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAuCxC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,KAAK,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;AAEnD,4EAA4E;AAC5E,MAAM,UAAU,cAAc;IAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CACvB,YAAY,CAAC,IAAI,GAAG,CAAC,cAAc,EAAE,WAAW,CAAC,EAAE,MAAM,CAAC,CAC9C,CAAA;IAChB,OAAO;QACH,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC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ClB,YAAY,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC;KAC3C,CAAA;AACL,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,0BAA0B,CACtC,KAAa;IAEb,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IACzC,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAA;IACtB,OAAQ,CAAC,QAAQ,EAAE,OAAO,CAAW,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACnD,MAAM,QAAQ,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAA;QAC9C,OAAO,QAAQ,CAAC,OAAO;aAClB,KAAK,CAAC,IAAI,CAAC;aACX,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACrB,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC;YAC/B,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;YAClD,CAAC,CAAC,EAAE,CACX,CAAA;IACT,CAAC,CAAC,CAAA;AACN,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,kBAAkB;IAC9B,OAAO;QACH,GAAG,uBAAuB,EAAE,CAAC,OAAO,CAAC,QAAQ,CACzC,6BAA6B,CAChC;KACJ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACd,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAE,CAAC,IAAI,EAAE;QAC1B,IAAI,EAAE,KAAK,CAAC,CAAC,CAAE,CAAC,OAAO,EAAE;KAC5B,CAAC,CAAC,CAAA;AACP,CAAC","sourcesContent":["import { readFileSync, realpathSync } from 'node:fs'\nimport { isAbsolute, relative, sep } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nexport interface PackageInfo {\n name: string\n version: string\n description: string\n license: string\n homepage: string\n repository: { type: string; url: string }\n exports: Record<\n string,\n string | { types?: string; import?: string; default?: string }\n >\n peerDependencies: Record<string, string>\n}\n\nexport interface PackageDocument {\n path: string\n content: string\n}\n\nexport interface PackageApi {\n package: string\n version: string\n subpaths: Record<string, string>\n declarations: PackageDocument[]\n}\n\nexport interface PackageSearchMatch {\n path: string\n line: number\n text: string\n}\n\nexport interface PackageExample {\n language: string\n code: string\n}\n\nconst packageRoot = new URL('../', import.meta.url)\n\n/** Read installed-package metadata without importing its UI entry point. */\nexport function getPackageInfo(): PackageInfo {\n const manifest = JSON.parse(\n readFileSync(new URL('package.json', packageRoot), 'utf8'),\n ) as PackageInfo\n return {\n name: manifest.name,\n version: manifest.version,\n description: manifest.description,\n license: manifest.license,\n homepage: manifest.homepage,\n repository: manifest.repository,\n exports: manifest.exports,\n peerDependencies: manifest.peerDependencies,\n }\n}\n\n/** Only these two explicitly packaged documents can be read. */\nexport function getPackageDocumentation(\n document: 'readme' | 'usage' = 'usage',\n): PackageDocument {\n if (document !== 'readme' && document !== 'usage') {\n throw new Error('Unknown package document')\n }\n const path = document === 'readme' ? 'README.md' : 'docs/usage.md'\n return { path, content: readFileSync(new URL(path, packageRoot), 'utf8') }\n}\n\n/** Return export entry declarations and their local declaration dependencies.\n * The AI entry itself is excluded. No module is executed and callers cannot\n * supply file paths. Symbols must be exported by a selected public entry.\n */\nexport function getPackageApi(\n options: { subpath?: string; symbol?: string } = {},\n): PackageApi {\n const info = getPackageInfo()\n const subpaths: Record<string, string> = {}\n for (const [subpath, entry] of Object.entries(info.exports)) {\n if (subpath !== './ai' && typeof entry !== 'string' && entry.types) {\n subpaths[subpath] = entry.types\n }\n }\n if (\n options.subpath !== undefined &&\n !Object.hasOwn(subpaths, options.subpath)\n ) {\n throw new Error(`Unknown public subpath: ${options.subpath}`)\n }\n if (\n options.symbol !== undefined &&\n !/^[A-Za-z_$][\\w$]*$/.test(options.symbol)\n ) {\n throw new Error('Invalid public symbol')\n }\n const selected =\n options.subpath === undefined\n ? subpaths\n : { [options.subpath]: subpaths[options.subpath]! }\n const declarations = new Map<string, PackageDocument>()\n const publicNames = new Set<string>()\n const distRoot = new URL('dist/', packageRoot)\n const distPath = realpathSync(distRoot)\n function readDeclaration(path: string): string {\n const url = new URL(path, packageRoot)\n if (\n !url.href.startsWith(distRoot.href) ||\n !url.pathname.endsWith('.d.ts')\n ) {\n throw new Error('Declaration must remain inside packaged dist')\n }\n const location = relative(distPath, realpathSync(fileURLToPath(url)))\n if (\n isAbsolute(location) ||\n location === '..' ||\n location.startsWith('..' + sep)\n ) {\n throw new Error('Declaration must remain inside packaged dist')\n }\n const existing = declarations.get(url.href)\n if (existing) return existing.content\n const content = readFileSync(url, 'utf8')\n declarations.set(url.href, {\n path: decodeURIComponent(url.href.slice(packageRoot.href.length)),\n content,\n })\n for (const match of content.matchAll(\n /(?:from\\s*|import\\s*\\()(['\"])(\\.[^'\"]+)\\1/g,\n )) {\n const target = match[2]!.replace(/\\.(?:tsx?|jsx?)$/, '.d.ts')\n readDeclaration(new URL(target, url).href)\n }\n return content\n }\n const publicEntries = new Set<string>()\n function collectPublicNames(path: string): void {\n const url = new URL(path, packageRoot)\n if (publicEntries.has(url.href)) return\n publicEntries.add(url.href)\n const content = readDeclaration(path)\n for (const match of content.matchAll(\n /export\\s+(?:declare\\s+)?(?:abstract\\s+)?(?:const|let|var|function|class|interface|type|enum)\\s+([\\w$]+)/g,\n )) {\n publicNames.add(match[1]!)\n }\n for (const match of content.matchAll(\n /export\\s+(?:type\\s+)?\\{([^}]+)\\}/g,\n )) {\n for (const item of match[1]!.split(',')) {\n const name = item\n .trim()\n .replace(/^type\\s+/, '')\n .split(/\\s+as\\s+/)\n .at(-1)\n if (name) publicNames.add(name.trim())\n }\n }\n for (const match of content.matchAll(\n /export\\s+(?:type\\s+)?\\*\\s+as\\s+([A-Za-z_$][\\w$]*)\\s+from\\s*['\"]/g,\n )) {\n publicNames.add(match[1]!)\n }\n for (const match of content.matchAll(\n /export\\s+(?:type\\s+)?\\*\\s+from\\s*(['\"])(\\.[^'\"]+)\\1/g,\n )) {\n collectPublicNames(\n new URL(match[2]!.replace(/\\.(?:tsx?|jsx?)$/, '.d.ts'), url)\n .href,\n )\n }\n }\n for (const path of Object.values(selected)) collectPublicNames(path)\n if (options.symbol !== undefined && !publicNames.has(options.symbol)) {\n throw new Error(`Unknown public symbol: ${options.symbol}`)\n }\n return {\n package: info.name,\n version: info.version,\n subpaths: selected,\n declarations: [...declarations.values()],\n }\n}\n\n/** Literal, case-insensitive search of the packaged guides. */\nexport function searchPackageDocumentation(\n query: string,\n): PackageSearchMatch[] {\n const needle = query.trim().toLowerCase()\n if (!needle) return []\n return (['readme', 'usage'] as const).flatMap((name) => {\n const document = getPackageDocumentation(name)\n return document.content\n .split('\\n')\n .flatMap((text, index) =>\n text.toLowerCase().includes(needle)\n ? [{ path: document.path, line: index + 1, text }]\n : [],\n )\n })\n}\n\n/** Code examples come directly from the installed version's usage guide. */\nexport function getPackageExamples(): PackageExample[] {\n return [\n ...getPackageDocumentation().content.matchAll(\n /```([^\\n]*)\\n([\\s\\S]*?)```/g,\n ),\n ].map((match) => ({\n language: match[1]!.trim(),\n code: match[2]!.trimEnd(),\n }))\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { Dir, FacturX, HeaderScope, TableColumn as IrTableColumn, MarkerSelect, NumberFormat, Orientation, PageNumberFormat, PageNumbering, PageScope, PageSize, Relationship, RunningTotals, Standard, Style, StyleLength, TableTotals, TextAlign } from '../../ir/ir.generated.ts';
2
- import type { AttachmentSource, ImageSource, LetterheadInput, SvgSource } from '../../ir/Types/input.ts';
1
+ import type { Dir, FacturX, HeaderScope, TableColumn as IrTableColumn, MarkerSelect, NumberFormat, Orientation, PageNumberFormat, PageNumbering, PageScope, PageSize, Relationship, RunningTotals, Standard, Style, StyleLength, TableTotals, TextAlign } from '../../ir/ir.generated.js';
2
+ import type { AttachmentSource, ImageSource, LetterheadInput, SvgSource } from '../../ir/Types/input.js';
3
3
  /**
4
4
  * An outline entry (bookmark): a title, `{ title, level }`, or `false` to
5
5
  * keep a heading (`role="h1"` … `"h6"`) out of the outline. Headings are
@@ -1,5 +1,5 @@
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';
1
+ import type { PdfElement, PdfNode } from '../jsx/Types/element.js';
2
+ import type { CellProps, DataTableProps, DocumentProps, KeepProps, LinkProps, MarkerProps, PageBreakProps, PageNumberProps, PageProps, RowProps, TableProps, TextProps, TotalPagesProps, ViewProps } from './Types/props.js';
3
3
  /** The root of every document: metadata and `Page` children. */
4
4
  export declare const Document: (props: DocumentProps<PdfNode>) => PdfElement;
5
5
  /**
@@ -23,14 +23,14 @@ export declare const Text: (props: TextProps<PdfNode>) => PdfElement;
23
23
  * width, aspect ratio kept; `object-contain`/`object-cover` fit it into a
24
24
  * box with both sizes set.
25
25
  */
26
- export declare const Image: (props: import("./Types/props.ts").ImageAttributes) => PdfElement;
26
+ export declare const Image: (props: import("./Types/props.js").ImageAttributes) => PdfElement;
27
27
  /**
28
28
  * An SVG drawn as vectors, from markup or `.svg` bytes. It sizes like an
29
29
  * image: its `width`/`height` (or `viewBox`) in CSS pixels, at most the
30
30
  * container's width, aspect ratio kept. In a box of another aspect ratio it
31
31
  * follows its `preserveAspectRatio` unless `object-*` classes say otherwise.
32
32
  */
33
- export declare const Svg: (props: import("./Types/props.ts").SvgAttributes) => PdfElement;
33
+ export declare const Svg: (props: import("./Types/props.js").SvgAttributes) => PdfElement;
34
34
  /**
35
35
  * A clickable box around its children (a `View` with `href`): `#id` jumps
36
36
  * to the node with that `id`, `https:`, `http:`, `mailto:` and `tel:` URIs
@@ -42,7 +42,7 @@ export declare const Link: (props: LinkProps<PdfNode>) => PdfElement;
42
42
  * `<Link href="#terms">` jumps. Any `View`, `Text`, `Image` or `Svg` can be
43
43
  * a target through its own `id` too.
44
44
  */
45
- export declare const Anchor: (props: import("./Types/props.ts").AnchorAttributes) => PdfElement;
45
+ export declare const Anchor: (props: import("./Types/props.js").AnchorAttributes) => PdfElement;
46
46
  /**
47
47
  * Starts the content that follows it on a new page: an empty box with
48
48
  * `break-after-page`. At the end of the content it adds no page.
@@ -1 +1 @@
1
- {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../web/src/components/components.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAElE,OAAO,KAAK,EAER,SAAS,EACT,cAAc,EACd,aAAa,EAEb,SAAS,EACT,SAAS,EACT,WAAW,EACX,cAAc,EACd,eAAe,EACf,SAAS,EAET,QAAQ,EACR,UAAU,EACV,SAAS,EACT,eAAe,EACf,SAAS,EACZ,MAAM,kBAAkB,CAAA;AAEzB,gEAAgE;AAChE,eAAO,MAAM,QAAQ,+CAA2C,CAAA;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,IAAI,2CAAmC,CAAA;AAEpD,oDAAoD;AACpD,eAAO,MAAM,IAAI,2CAAmC,CAAA;AAEpD;;;;GAIG;AACH,eAAO,MAAM,IAAI,2CAAmC,CAAA;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,KAAK,mEAA4B,CAAA;AAE9C;;;;;GAKG;AACH,eAAO,MAAM,GAAG,iEAAwB,CAAA;AAExC;;;;GAIG;AACH,eAAO,MAAM,IAAI,2CAAmC,CAAA;AAEpD;;;;GAIG;AACH,eAAO,MAAM,MAAM,oEAA8B,CAAA;AAEjD;;;GAGG;AACH,eAAO,MAAM,SAAS,uCAAoC,CAAA;AAE1D;;;GAGG;AACH,eAAO,MAAM,IAAI,2CAAmC,CAAA;AAEpD;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,EAEb,CAAC,GAAG,SAAS,MAAM,EACpB,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,GAAG,CAAC,KAC/C,UAAU,CAAA;AAEf;;;GAGG;AACH,eAAO,MAAM,UAAU,wCAAsC,CAAA;AAE7D;;;GAGG;AACH,eAAO,MAAM,UAAU,wCAAsC,CAAA;AAE7D;;;GAGG;AACH,eAAO,MAAM,MAAM,oCAA8B,CAAA;AAEjD,oEAAoE;AACpE,eAAO,MAAM,GAAG,0CAAiC,CAAA;AAEjD;;;GAGG;AACH,eAAO,MAAM,IAAI,2CAAmC,CAAA"}
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../web/src/components/components.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAElE,OAAO,KAAK,EAER,SAAS,EACT,cAAc,EACd,aAAa,EAEb,SAAS,EACT,SAAS,EACT,WAAW,EACX,cAAc,EACd,eAAe,EACf,SAAS,EAET,QAAQ,EACR,UAAU,EACV,SAAS,EACT,eAAe,EACf,SAAS,EACZ,MAAM,kBAAkB,CAAA;AAEzB,gEAAgE;AAChE,eAAO,MAAM,QAAQ,+CAAyD,CAAA;AAE9E;;;;;GAKG;AACH,eAAO,MAAM,IAAI,2CAAiD,CAAA;AAElE,oDAAoD;AACpD,eAAO,MAAM,IAAI,2CAAiD,CAAA;AAElE;;;;GAIG;AACH,eAAO,MAAM,IAAI,2CAAiD,CAAA;AAElE;;;;;GAKG;AACH,eAAO,MAAM,KAAK,mEAA0C,CAAA;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,GAAG,iEAAsC,CAAA;AAEtD;;;;GAIG;AACH,eAAO,MAAM,IAAI,2CAAiD,CAAA;AAElE;;;;GAIG;AACH,eAAO,MAAM,MAAM,oEAA4C,CAAA;AAE/D;;;GAGG;AACH,eAAO,MAAM,SAAS,uCAAkD,CAAA;AAExE;;;GAGG;AACH,eAAO,MAAM,IAAI,2CAAiD,CAAA;AAElE;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,EAEJ,CAAC,GAAG,SAAS,MAAM,EAC7B,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,GAAG,CAAC,KAC/C,UAAU,CAAA;AAEf;;;GAGG;AACH,eAAO,MAAM,UAAU,wCAAoD,CAAA;AAE3E;;;GAGG;AACH,eAAO,MAAM,UAAU,wCAAoD,CAAA;AAE3E;;;GAGG;AACH,eAAO,MAAM,MAAM,oCAA4C,CAAA;AAE/D,oEAAoE;AACpE,eAAO,MAAM,GAAG,0CAA+C,CAAA;AAE/D;;;GAGG;AACH,eAAO,MAAM,IAAI,2CAAiD,CAAA"}
@@ -1,57 +1,57 @@
1
1
  import { host } from './host.js';
2
2
  /** The root of every document: metadata and `Page` children. */
3
- export const Document = host('Document');
3
+ export const Document = /*#__PURE__*/ host('Document');
4
4
  /**
5
5
  * A page template: size, orientation, page box styling (`p-page` for
6
6
  * margins), a `header` and `footer` on every page with `first`, `odd`,
7
7
  * `even` and `last` variants, and `numbering`. Content that does not fit
8
8
  * continues on further pages of the template.
9
9
  */
10
- export const Page = host('Page');
10
+ export const Page = /*#__PURE__*/ host('Page');
11
11
  /** A generic box: block, flex or grid container. */
12
- export const View = host('View');
12
+ export const View = /*#__PURE__*/ host('View');
13
13
  /**
14
14
  * A paragraph of text; its string and number children are concatenated,
15
15
  * and `PageNumber`, `TotalPages` and `Marker` placeholders are filled in
16
16
  * per page.
17
17
  */
18
- export const Text = host('Text');
18
+ export const Text = /*#__PURE__*/ host('Text');
19
19
  /**
20
20
  * A raster image from bytes (PNG, JPEG, GIF, WebP), sized like an HTML
21
21
  * `<img>` with Tailwind's preflight: natural size, at most the container's
22
22
  * width, aspect ratio kept; `object-contain`/`object-cover` fit it into a
23
23
  * box with both sizes set.
24
24
  */
25
- export const Image = host('Image');
25
+ export const Image = /*#__PURE__*/ host('Image');
26
26
  /**
27
27
  * An SVG drawn as vectors, from markup or `.svg` bytes. It sizes like an
28
28
  * image: its `width`/`height` (or `viewBox`) in CSS pixels, at most the
29
29
  * container's width, aspect ratio kept. In a box of another aspect ratio it
30
30
  * follows its `preserveAspectRatio` unless `object-*` classes say otherwise.
31
31
  */
32
- export const Svg = host('Svg');
32
+ export const Svg = /*#__PURE__*/ host('Svg');
33
33
  /**
34
34
  * A clickable box around its children (a `View` with `href`): `#id` jumps
35
35
  * to the node with that `id`, `https:`, `http:`, `mailto:` and `tel:` URIs
36
36
  * open in the viewer's application. Every page fragment is clickable.
37
37
  */
38
- export const Link = host('Link');
38
+ export const Link = /*#__PURE__*/ host('Link');
39
39
  /**
40
40
  * An invisible link target: `<Anchor id="terms" />` is where
41
41
  * `<Link href="#terms">` jumps. Any `View`, `Text`, `Image` or `Svg` can be
42
42
  * a target through its own `id` too.
43
43
  */
44
- export const Anchor = host('Anchor');
44
+ export const Anchor = /*#__PURE__*/ host('Anchor');
45
45
  /**
46
46
  * Starts the content that follows it on a new page: an empty box with
47
47
  * `break-after-page`. At the end of the content it adds no page.
48
48
  */
49
- export const PageBreak = host('PageBreak');
49
+ export const PageBreak = /*#__PURE__*/ host('PageBreak');
50
50
  /**
51
51
  * Keeps its children together on one page when they fit on one: a box with
52
52
  * `break-inside-avoid`, plus `break-after-avoid` with `withNext`.
53
53
  */
54
- export const Keep = host('Keep');
54
+ export const Keep = /*#__PURE__*/ host('Keep');
55
55
  /**
56
56
  * A table of `Row`s: columns sized from `columns` (`auto`, `fr`, lengths,
57
57
  * percentages) and the cells' content, split between rows across pages
@@ -60,27 +60,27 @@ export const Keep = host('Keep');
60
60
  * With `data` and `columns` it is a data-driven table: one row per item,
61
61
  * cells rendered natively from compact column data (large tables).
62
62
  */
63
- export const Table = host('Table');
63
+ export const Table = /*#__PURE__*/ host('Table');
64
64
  /**
65
65
  * The number of the page the text is on, inside a `Text`: counted from 1
66
66
  * over the document unless a `Page` sets `numbering`.
67
67
  */
68
- export const PageNumber = host('PageNumber');
68
+ export const PageNumber = /*#__PURE__*/ host('PageNumber');
69
69
  /**
70
70
  * The number of pages of the document (or of the page template with
71
71
  * `scope="section"`), inside a `Text`: `Page <PageNumber /> of <TotalPages />`.
72
72
  */
73
- export const TotalPages = host('TotalPages');
73
+ export const TotalPages = /*#__PURE__*/ host('TotalPages');
74
74
  /**
75
75
  * The value of a running marker on the page, inside a `Text`, for example
76
76
  * the current chapter in a header: nodes set it with their `marker` prop.
77
77
  */
78
- export const Marker = host('Marker');
78
+ export const Marker = /*#__PURE__*/ host('Marker');
79
79
  /** A table row; `header` and `footer` rows repeat on every page. */
80
- export const Row = host('Row');
80
+ export const Row = /*#__PURE__*/ host('Row');
81
81
  /**
82
82
  * A table cell spanning `colSpan` columns and `rowSpan` rows. Strings and
83
83
  * numbers become its text; `value` cells show a number in minor units.
84
84
  */
85
- export const Cell = host('Cell');
85
+ export const Cell = /*#__PURE__*/ host('Cell');
86
86
  //# sourceMappingURL=components.js.map
@@ -1 +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"]}
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,aAAa,CAAC,IAAI,CAAyB,UAAU,CAAC,CAAA;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAqB,MAAM,CAAC,CAAA;AAElE,oDAAoD;AACpD,MAAM,CAAC,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAqB,MAAM,CAAC,CAAA;AAElE;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAqB,MAAM,CAAC,CAAA;AAElE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAa,OAAO,CAAC,CAAA;AAE5D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAW,KAAK,CAAC,CAAA;AAEtD;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAqB,MAAM,CAAC,CAAA;AAElE;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAc,QAAQ,CAAC,CAAA;AAE/D;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,CAAiB,WAAW,CAAC,CAAA;AAExE;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAqB,MAAM,CAAC,CAAA;AAElE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAErC,OAAO,CAEM,CAAA;AAEf;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAkB,YAAY,CAAC,CAAA;AAE3E;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAkB,YAAY,CAAC,CAAA;AAE3E;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAc,QAAQ,CAAC,CAAA;AAE/D,oEAAoE;AACpE,MAAM,CAAC,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAoB,KAAK,CAAC,CAAA;AAE/D;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,aAAa,CAAC,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 = /*#__PURE__*/ 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 = /*#__PURE__*/ host<PageProps<PdfNode>>('Page')\n\n/** A generic box: block, flex or grid container. */\nexport const View = /*#__PURE__*/ 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 = /*#__PURE__*/ 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 = /*#__PURE__*/ 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 = /*#__PURE__*/ 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 = /*#__PURE__*/ 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 = /*#__PURE__*/ 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 = /*#__PURE__*/ 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 = /*#__PURE__*/ 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 = /*#__PURE__*/ host<\n TableProps<PdfNode> | DataTableProps<object>\n>('Table') 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 = /*#__PURE__*/ 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 = /*#__PURE__*/ 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 = /*#__PURE__*/ host<MarkerProps>('Marker')\n\n/** A table row; `header` and `footer` rows repeat on every page. */\nexport const Row = /*#__PURE__*/ 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 = /*#__PURE__*/ host<CellProps<PdfNode>>('Cell')\n"]}
@@ -1,5 +1,5 @@
1
- import type { PdfElement } from '../jsx/Types/element.ts';
2
- import type { HostName } from './Types/host.ts';
1
+ import type { PdfElement } from '../jsx/Types/element.js';
2
+ import type { HostName } from './Types/host.js';
3
3
  /** Creates a built-in component; rendering builds its IR node from the props. */
4
4
  export declare function host<P>(name: HostName): (props: P) => PdfElement;
5
5
  /** Returns the built-in component's name, or `undefined` for other types. */
@@ -1,8 +1,8 @@
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';
1
+ import type { BackendTheme } from '../../theme/Types/theme.js';
2
+ import type { DataChannel } from '../channel.js';
3
+ import type { Limits } from './limits.js';
4
+ import type { EngineStats } from './render-options.js';
5
+ import type { RenderWarning } from './render-result.js';
6
6
  /** The engine implementations: the Node-API addon or the WebAssembly build. */
7
7
  export type BackendName = 'native' | 'wasm';
8
8
  /**
@@ -1,12 +1,12 @@
1
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';
2
+ import type { DocumentInput } from '../../ir/Types/input.js';
3
+ import type { ThemeInput } from '../../theme/Types/theme.js';
4
+ import type { PdfElement } from '../../jsx/Types/element.js';
5
+ import type { WasmModuleSource } from '../../wasm/loader.js';
6
+ import type { BackendChoice, BackendName } from './backend.js';
7
+ import type { LimitsInput } from './limits.js';
8
+ import type { BatchOptions, BatchRendered, BatchResult, EngineStats, RenderOptions } from './render-options.js';
9
+ import type { PdfBytes, RenderResult, RenderWarning } from './render-result.js';
10
10
  /**
11
11
  * What the engine renders: a JSX element (evaluated to the IR first; its root
12
12
  * must render a `Document`) or an IR document, for example from the
@@ -1,5 +1,5 @@
1
- import type { SourceLocation } from '../../jsx/Types/element.ts';
2
- import type { RentnerPdfWarningCode } from './render-result.ts';
1
+ import type { SourceLocation } from '../../jsx/Types/element.js';
2
+ import type { RentnerPdfWarningCode } from './render-result.js';
3
3
  /**
4
4
  * Stable error codes shared with the Rust engine (`rentnerpdf::ErrorCode`).
5
5
  * `ENGINE_CLOSED` is a call to an engine after its `close()`.
@@ -1,4 +1,4 @@
1
- import type { RenderResult } from './render-result.ts';
1
+ import type { RenderResult } from './render-result.js';
2
2
  /** Options of one render. */
3
3
  export interface RenderOptions {
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type { SourceLocation } from '../../jsx/Types/element.ts';
1
+ import type { SourceLocation } from '../../jsx/Types/element.js';
2
2
  /**
3
3
  * Stable warning codes shared with the Rust engine (`rentnerpdf::WarningCode`).
4
4
  * With `strict: true`, `UNKNOWN_CLASS`, `INVALID_VALUE` and `UNSUPPORTED_CLASS`
@@ -1,4 +1,4 @@
1
- import { RentnerPdfError } from './errors.ts';
1
+ import { RentnerPdfError } from './errors.js';
2
2
  /** The `ABORTED` error for an abort `reason`; an `ABORTED` reason is kept. */
3
3
  export declare const abortedError: (reason: unknown) => RentnerPdfError;
4
4
  /** Throws the `ABORTED` error when `signal` has aborted. */
@@ -19,5 +19,5 @@ export interface Deadline {
19
19
  * The timer is ref'd: a render that never finishes fails instead of
20
20
  * letting the process exit with an unsettled promise.
21
21
  */
22
- export declare function deadline(signal: AbortSignal | undefined, timeoutMs: number | undefined): Deadline;
22
+ export declare function deadline(signal: AbortSignal | undefined, timeoutMs: number | undefined, subject?: string): Deadline;
23
23
  //# sourceMappingURL=abort.d.ts.map
@@ -1 +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"}
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,EAC7B,OAAO,SAAe,GACvB,QAAQ,CA0BV"}
@@ -43,7 +43,7 @@ export async function raceAbort(promise, signal) {
43
43
  * The timer is ref'd: a render that never finishes fails instead of
44
44
  * letting the process exit with an unsettled promise.
45
45
  */
46
- export function deadline(signal, timeoutMs) {
46
+ export function deadline(signal, timeoutMs, subject = 'the render') {
47
47
  const controller = new AbortController();
48
48
  const abort = (reason) => {
49
49
  if (!controller.signal.aborted)
@@ -57,7 +57,7 @@ export function deadline(signal, timeoutMs) {
57
57
  const timer = timeoutMs === undefined
58
58
  ? undefined
59
59
  : setTimeout(() => {
60
- abort(new RentnerPdfError('ABORTED', `the render did not finish within ${timeoutMs} ms (timeoutMs)`));
60
+ abort(new RentnerPdfError('ABORTED', `${subject} did not finish within ${timeoutMs} ms (timeoutMs)`));
61
61
  }, timeoutMs);
62
62
  return {
63
63
  signal: controller.signal,
@@ -1 +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,EA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E,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"]}
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,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M,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,GAAG,OAAO,0BAA0B,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 subject = 'the render',\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 `${subject} 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"]}
@@ -1,4 +1,4 @@
1
- import type { AttachmentSource, ImageSource, SvgSource } from '../ir/Types/input.ts';
1
+ import type { AttachmentSource, ImageSource, SvgSource } from '../ir/Types/input.js';
2
2
  /** Whether `value` is file bytes: a `Uint8Array` (or `Buffer`) or an `ArrayBuffer`. */
3
3
  export declare const isImageSource: (value: unknown) => value is ImageSource;
4
4
  /** Whether `value` is an attachment's content: bytes or a string. */
@@ -10,9 +10,10 @@ export declare const isAttachmentSource: (value: unknown) => value is Attachment
10
10
  export declare class Assets {
11
11
  #private;
12
12
  readonly buffers: Uint8Array[];
13
+ constructor(transfer?: ArrayBuffer[]);
13
14
  index(source: SvgSource): number;
14
- /** Adds a buffer that no other node shares; returns its index. */
15
- push(buffer: Uint8Array): number;
15
+ /** Adds a fresh encoder buffer that can be transferred to a worker. */
16
+ pushOwned(buffer: Uint8Array<ArrayBuffer>): number;
16
17
  /**
17
18
  * Adds an attachment's content as a buffer of its own: the engine
18
19
  * embeds it as it is, even when a node shows the same bytes.
@@ -1 +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"}
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;AAErD;;;GAGG;AACH,qBAAa,MAAM;;IACf,QAAQ,CAAC,OAAO,EAAE,UAAU,EAAE,CAAK;IAInC,YAAY,QAAQ,CAAC,EAAE,WAAW,EAAE,EAEnC;IAED,KAAK,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAO/B;IAED,uEAAuE;IACvE,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,MAAM,CAIjD;IAcD;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAE3C;CACJ"}
@@ -1,13 +1,8 @@
1
- const utf8 = new TextEncoder();
1
+ let utf8;
2
2
  /** Whether `value` is file bytes: a `Uint8Array` (or `Buffer`) or an `ArrayBuffer`. */
3
3
  export const isImageSource = (value) => value instanceof Uint8Array || value instanceof ArrayBuffer;
4
4
  /** Whether `value` is an attachment's content: bytes or a string. */
5
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
6
  /**
12
7
  * Collects asset buffers; the same buffer object, or the same SVG string,
13
8
  * gets one index.
@@ -15,26 +10,39 @@ const bytesOf = (source) => typeof source === 'string'
15
10
  export class Assets {
16
11
  buffers = [];
17
12
  #indices = new Map();
13
+ #transfer;
14
+ constructor(transfer) {
15
+ this.#transfer = transfer;
16
+ }
18
17
  index(source) {
19
18
  let index = this.#indices.get(source);
20
19
  if (index === undefined) {
21
- index = this.buffers.length;
22
- this.buffers.push(bytesOf(source));
20
+ index = this.#pushSource(source);
23
21
  this.#indices.set(source, index);
24
22
  }
25
23
  return index;
26
24
  }
27
- /** Adds a buffer that no other node shares; returns its index. */
28
- push(buffer) {
25
+ /** Adds a fresh encoder buffer that can be transferred to a worker. */
26
+ pushOwned(buffer) {
27
+ this.#transfer?.push(buffer.buffer);
29
28
  this.buffers.push(buffer);
30
29
  return this.buffers.length - 1;
31
30
  }
31
+ #pushSource(source) {
32
+ if (typeof source === 'string') {
33
+ return this.pushOwned((utf8 ??= new TextEncoder()).encode(source));
34
+ }
35
+ // Keep caller-owned bytes out of the transfer list, including views
36
+ // that cover the entire buffer.
37
+ this.buffers.push(source instanceof Uint8Array ? source : new Uint8Array(source));
38
+ return this.buffers.length - 1;
39
+ }
32
40
  /**
33
41
  * Adds an attachment's content as a buffer of its own: the engine
34
42
  * embeds it as it is, even when a node shows the same bytes.
35
43
  */
36
44
  attachment(source) {
37
- return this.push(bytesOf(source));
45
+ return this.#pushSource(source);
38
46
  }
39
47
  }
40
48
  //# sourceMappingURL=assets.js.map
@@ -1 +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"]}
1
+ {"version":3,"file":"assets.js","sourceRoot":"","sources":["../../web/src/engine/assets.ts"],"names":[],"mappings":"AAUA,IAAI,IAA6B,CAAA;AAEjC,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;;;GAGG;AACH,MAAM,OAAO,MAAM;IACN,OAAO,GAAiB,EAAE,CAAA;IAC1B,QAAQ,GAAG,IAAI,GAAG,EAAqB,CAAA;IACvC,SAAS,CAAgB;IAElC,YAAY,QAAwB;QAChC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;IAC7B,CAAC;IAED,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,WAAW,CAAC,MAAM,CAAC,CAAA;YAChC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;QACpC,CAAC;QACD,OAAO,KAAK,CAAA;IAChB,CAAC;IAED,uEAAuE;IACvE,SAAS,CAAC,MAA+B;QACrC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QACnC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAA;IAClC,CAAC;IAED,WAAW,CAAC,MAAiB;QACzB,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,KAAK,IAAI,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;QACtE,CAAC;QACD,oEAAoE;QACpE,gCAAgC;QAChC,IAAI,CAAC,OAAO,CAAC,IAAI,CACb,MAAM,YAAY,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CACjE,CAAA;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAA;IAClC,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,MAAwB;QAC/B,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IACnC,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\nlet utf8: TextEncoder | undefined\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\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 readonly #transfer?: ArrayBuffer[]\n\n constructor(transfer?: ArrayBuffer[]) {\n this.#transfer = transfer\n }\n\n index(source: SvgSource): number {\n let index = this.#indices.get(source)\n if (index === undefined) {\n index = this.#pushSource(source)\n this.#indices.set(source, index)\n }\n return index\n }\n\n /** Adds a fresh encoder buffer that can be transferred to a worker. */\n pushOwned(buffer: Uint8Array<ArrayBuffer>): number {\n this.#transfer?.push(buffer.buffer)\n this.buffers.push(buffer)\n return this.buffers.length - 1\n }\n\n #pushSource(source: SvgSource): number {\n if (typeof source === 'string') {\n return this.pushOwned((utf8 ??= new TextEncoder()).encode(source))\n }\n // Keep caller-owned bytes out of the transfer list, including views\n // that cover the entire buffer.\n this.buffers.push(\n source instanceof Uint8Array ? source : new Uint8Array(source),\n )\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.#pushSource(source)\n }\n}\n"]}