blitz-pdf 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (370) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +391 -2
  3. package/THIRD_PARTY_NOTICES.md +25 -0
  4. package/assets/icon.svg +4 -0
  5. package/dist/api.d.ts +7 -0
  6. package/dist/api.d.ts.map +1 -0
  7. package/dist/api.js +46 -0
  8. package/dist/api.js.map +1 -0
  9. package/dist/assets.d.ts +7 -0
  10. package/dist/assets.d.ts.map +1 -0
  11. package/dist/assets.js +52 -0
  12. package/dist/assets.js.map +1 -0
  13. package/dist/browser.d.ts +3 -0
  14. package/dist/browser.d.ts.map +1 -0
  15. package/dist/browser.js +3 -0
  16. package/dist/browser.js.map +1 -0
  17. package/dist/node.d.ts +3 -0
  18. package/dist/node.d.ts.map +1 -0
  19. package/dist/node.js +10 -0
  20. package/dist/node.js.map +1 -0
  21. package/dist/options.d.ts +24 -0
  22. package/dist/options.d.ts.map +1 -0
  23. package/dist/options.js +135 -0
  24. package/dist/options.js.map +1 -0
  25. package/dist/types.d.ts +51 -0
  26. package/dist/types.d.ts.map +1 -0
  27. package/dist/types.js +2 -0
  28. package/dist/types.js.map +1 -0
  29. package/examples/bun.ts +8 -0
  30. package/examples/german-invoice/README.md +70 -0
  31. package/examples/german-invoice/data.mjs +83 -0
  32. package/examples/german-invoice/invoice.css +59 -0
  33. package/examples/german-invoice/template.mjs +49 -0
  34. package/examples/german-invoice.mjs +20 -0
  35. package/examples/invoice.html +29 -0
  36. package/examples/node.mjs +8 -0
  37. package/examples/pagination.html +40 -0
  38. package/examples/pagination.mjs +8 -0
  39. package/licenses/DejaVu.txt +187 -0
  40. package/licenses/RUST_DEPENDENCIES.txt +11577 -0
  41. package/package.json +89 -4
  42. package/src/api.ts +44 -0
  43. package/src/assets.ts +43 -0
  44. package/src/browser.ts +6 -0
  45. package/src/node.ts +12 -0
  46. package/src/options.ts +101 -0
  47. package/src/types.ts +49 -0
  48. package/vendor/README.md +17 -0
  49. package/vendor/stylo/.cargo-ok +1 -0
  50. package/vendor/stylo/.cargo_vcs_info.json +6 -0
  51. package/vendor/stylo/Cargo.lock +1485 -0
  52. package/vendor/stylo/Cargo.toml +274 -0
  53. package/vendor/stylo/LICENSE +373 -0
  54. package/vendor/stylo/README.md +6 -0
  55. package/vendor/stylo/applicable_declarations.rs +328 -0
  56. package/vendor/stylo/author_styles.rs +79 -0
  57. package/vendor/stylo/bezier.rs +176 -0
  58. package/vendor/stylo/bloom.rs +414 -0
  59. package/vendor/stylo/build.rs +91 -0
  60. package/vendor/stylo/build_gecko.rs +393 -0
  61. package/vendor/stylo/color/color_function.rs +601 -0
  62. package/vendor/stylo/color/component.rs +207 -0
  63. package/vendor/stylo/color/convert.rs +935 -0
  64. package/vendor/stylo/color/gamut/raytrace.rs +265 -0
  65. package/vendor/stylo/color/gamut.rs +227 -0
  66. package/vendor/stylo/color/mix.rs +645 -0
  67. package/vendor/stylo/color/mod.rs +750 -0
  68. package/vendor/stylo/color/parsing.rs +770 -0
  69. package/vendor/stylo/color/to_css.rs +297 -0
  70. package/vendor/stylo/context.rs +716 -0
  71. package/vendor/stylo/counter_style/mod.rs +754 -0
  72. package/vendor/stylo/counter_style/predefined.rs +61 -0
  73. package/vendor/stylo/counter_style/update_predefined.py +35 -0
  74. package/vendor/stylo/custom_properties.rs +2023 -0
  75. package/vendor/stylo/custom_properties_map.rs +220 -0
  76. package/vendor/stylo/data.rs +693 -0
  77. package/vendor/stylo/device/gecko.rs +486 -0
  78. package/vendor/stylo/device/mod.rs +304 -0
  79. package/vendor/stylo/device/servo.rs +507 -0
  80. package/vendor/stylo/dom.rs +1164 -0
  81. package/vendor/stylo/dom_apis.rs +937 -0
  82. package/vendor/stylo/driver.rs +172 -0
  83. package/vendor/stylo/error_reporting.rs +484 -0
  84. package/vendor/stylo/font_face.rs +558 -0
  85. package/vendor/stylo/font_metrics.rs +124 -0
  86. package/vendor/stylo/gecko/anon_boxes.toml +113 -0
  87. package/vendor/stylo/gecko/arc_types.rs +211 -0
  88. package/vendor/stylo/gecko/conversions.rs +59 -0
  89. package/vendor/stylo/gecko/data.rs +222 -0
  90. package/vendor/stylo/gecko/media_features.rs +971 -0
  91. package/vendor/stylo/gecko/mod.rs +20 -0
  92. package/vendor/stylo/gecko/non_ts_pseudo_class_list.rs +119 -0
  93. package/vendor/stylo/gecko/pseudo_element.rs +640 -0
  94. package/vendor/stylo/gecko/pseudo_element_definition.mako.rs +298 -0
  95. package/vendor/stylo/gecko/pseudo_elements.py +137 -0
  96. package/vendor/stylo/gecko/pseudo_elements.toml +197 -0
  97. package/vendor/stylo/gecko/regen_pseudo_elements.py +33 -0
  98. package/vendor/stylo/gecko/restyle_damage.rs +127 -0
  99. package/vendor/stylo/gecko/selector_parser.rs +627 -0
  100. package/vendor/stylo/gecko/snapshot.rs +202 -0
  101. package/vendor/stylo/gecko/snapshot_helpers.rs +334 -0
  102. package/vendor/stylo/gecko/traversal.rs +52 -0
  103. package/vendor/stylo/gecko/wrapper.rs +2258 -0
  104. package/vendor/stylo/gecko_bindings/mod.rs +34 -0
  105. package/vendor/stylo/gecko_bindings/sugar/mod.rs +12 -0
  106. package/vendor/stylo/gecko_bindings/sugar/ns_com_ptr.rs +15 -0
  107. package/vendor/stylo/gecko_bindings/sugar/ns_compatibility.rs +19 -0
  108. package/vendor/stylo/gecko_bindings/sugar/ns_style_auto_array.rs +111 -0
  109. package/vendor/stylo/gecko_bindings/sugar/origin_flags.rs +31 -0
  110. package/vendor/stylo/gecko_bindings/sugar/ownership.rs +70 -0
  111. package/vendor/stylo/gecko_bindings/sugar/refptr.rs +299 -0
  112. package/vendor/stylo/gecko_string_cache/mod.rs +543 -0
  113. package/vendor/stylo/gecko_string_cache/namespace.rs +106 -0
  114. package/vendor/stylo/global_style_data.rs +224 -0
  115. package/vendor/stylo/invalidation/element/document_state.rs +156 -0
  116. package/vendor/stylo/invalidation/element/element_wrapper.rs +432 -0
  117. package/vendor/stylo/invalidation/element/invalidation_map.rs +1631 -0
  118. package/vendor/stylo/invalidation/element/invalidator.rs +1470 -0
  119. package/vendor/stylo/invalidation/element/mod.rs +13 -0
  120. package/vendor/stylo/invalidation/element/relative_selector.rs +1399 -0
  121. package/vendor/stylo/invalidation/element/restyle_hints.rs +226 -0
  122. package/vendor/stylo/invalidation/element/state_and_attributes.rs +756 -0
  123. package/vendor/stylo/invalidation/media_queries.rs +144 -0
  124. package/vendor/stylo/invalidation/mod.rs +10 -0
  125. package/vendor/stylo/invalidation/stylesheets.rs +745 -0
  126. package/vendor/stylo/invalidation/viewport_units.rs +71 -0
  127. package/vendor/stylo/lib.rs +336 -0
  128. package/vendor/stylo/logical_geometry.rs +1684 -0
  129. package/vendor/stylo/macros.rs +70 -0
  130. package/vendor/stylo/matching.rs +1226 -0
  131. package/vendor/stylo/media_queries/media_list.rs +168 -0
  132. package/vendor/stylo/media_queries/media_query.rs +190 -0
  133. package/vendor/stylo/media_queries/mod.rs +13 -0
  134. package/vendor/stylo/parallel.rs +205 -0
  135. package/vendor/stylo/parser.rs +276 -0
  136. package/vendor/stylo/piecewise_linear.rs +282 -0
  137. package/vendor/stylo/prefs.rs +33 -0
  138. package/vendor/stylo/properties/build.py +119 -0
  139. package/vendor/stylo/properties/cascade.rs +2704 -0
  140. package/vendor/stylo/properties/computed_value_flags.rs +206 -0
  141. package/vendor/stylo/properties/counted_unknown_properties.py +104 -0
  142. package/vendor/stylo/properties/counter_style_descriptors.toml +45 -0
  143. package/vendor/stylo/properties/data.py +1375 -0
  144. package/vendor/stylo/properties/declaration_block.rs +1788 -0
  145. package/vendor/stylo/properties/font_face_descriptors.toml +50 -0
  146. package/vendor/stylo/properties/gecko.mako.rs +1555 -0
  147. package/vendor/stylo/properties/helpers/animated_properties.mako.rs +800 -0
  148. package/vendor/stylo/properties/helpers.mako.rs +812 -0
  149. package/vendor/stylo/properties/longhands.toml +4305 -0
  150. package/vendor/stylo/properties/mod.rs +1857 -0
  151. package/vendor/stylo/properties/properties.html.mako +31 -0
  152. package/vendor/stylo/properties/properties.mako.rs +3103 -0
  153. package/vendor/stylo/properties/property_descriptors.toml +18 -0
  154. package/vendor/stylo/properties/shorthands.rs +4241 -0
  155. package/vendor/stylo/properties/shorthands.toml +575 -0
  156. package/vendor/stylo/properties/vendored_python/mako-1.3.10-py3-none-any.whl +0 -0
  157. package/vendor/stylo/properties/vendored_python/markupsafe/LICENSE.txt +28 -0
  158. package/vendor/stylo/properties/vendored_python/markupsafe/__init__.py +384 -0
  159. package/vendor/stylo/properties/vendored_python/toml-0.10.2-py2.py3-none-any.whl +0 -0
  160. package/vendor/stylo/properties/view_transition_descriptors.toml +11 -0
  161. package/vendor/stylo/properties_and_values/mod.rs +12 -0
  162. package/vendor/stylo/properties_and_values/registry.rs +65 -0
  163. package/vendor/stylo/properties_and_values/rule.rs +331 -0
  164. package/vendor/stylo/properties_and_values/syntax/ascii.rs +60 -0
  165. package/vendor/stylo/properties_and_values/syntax/data_type.rs +146 -0
  166. package/vendor/stylo/properties_and_values/syntax/mod.rs +437 -0
  167. package/vendor/stylo/properties_and_values/value.rs +758 -0
  168. package/vendor/stylo/queries/condition.rs +996 -0
  169. package/vendor/stylo/queries/feature.rs +199 -0
  170. package/vendor/stylo/queries/feature_expression.rs +1170 -0
  171. package/vendor/stylo/queries/mod.rs +19 -0
  172. package/vendor/stylo/queries/values.rs +46 -0
  173. package/vendor/stylo/rule_cache.rs +267 -0
  174. package/vendor/stylo/rule_collector.rs +554 -0
  175. package/vendor/stylo/rule_tree/core.rs +787 -0
  176. package/vendor/stylo/rule_tree/level.rs +396 -0
  177. package/vendor/stylo/rule_tree/map.rs +201 -0
  178. package/vendor/stylo/rule_tree/mod.rs +427 -0
  179. package/vendor/stylo/rule_tree/source.rs +80 -0
  180. package/vendor/stylo/rule_tree/unsafe_box.rs +78 -0
  181. package/vendor/stylo/scoped_tls.rs +80 -0
  182. package/vendor/stylo/selector_map.rs +1050 -0
  183. package/vendor/stylo/selector_parser.rs +305 -0
  184. package/vendor/stylo/servo/animation.rs +1922 -0
  185. package/vendor/stylo/servo/attr.rs +714 -0
  186. package/vendor/stylo/servo/encoding_support.rs +81 -0
  187. package/vendor/stylo/servo/media_features.rs +254 -0
  188. package/vendor/stylo/servo/mod.rs +16 -0
  189. package/vendor/stylo/servo/restyle_damage.rs +215 -0
  190. package/vendor/stylo/servo/selector_parser.rs +1036 -0
  191. package/vendor/stylo/servo/shadow_parts.rs +207 -0
  192. package/vendor/stylo/shared_lock.rs +271 -0
  193. package/vendor/stylo/sharing/checks.rs +281 -0
  194. package/vendor/stylo/sharing/mod.rs +1000 -0
  195. package/vendor/stylo/simple_buckets_map.rs +52 -0
  196. package/vendor/stylo/str.rs +168 -0
  197. package/vendor/stylo/style_adjuster.rs +1086 -0
  198. package/vendor/stylo/style_resolver.rs +658 -0
  199. package/vendor/stylo/stylesheet_set.rs +658 -0
  200. package/vendor/stylo/stylesheets/appearance_base_rule.rs +51 -0
  201. package/vendor/stylo/stylesheets/container_rule.rs +769 -0
  202. package/vendor/stylo/stylesheets/counter_style_rule.rs +7 -0
  203. package/vendor/stylo/stylesheets/document_rule.rs +272 -0
  204. package/vendor/stylo/stylesheets/font_face_rule.rs +7 -0
  205. package/vendor/stylo/stylesheets/font_feature_values_rule.rs +481 -0
  206. package/vendor/stylo/stylesheets/font_palette_values_rule.rs +304 -0
  207. package/vendor/stylo/stylesheets/import_rule.rs +259 -0
  208. package/vendor/stylo/stylesheets/keyframes_rule.rs +733 -0
  209. package/vendor/stylo/stylesheets/layer_rule.rs +221 -0
  210. package/vendor/stylo/stylesheets/loader.rs +29 -0
  211. package/vendor/stylo/stylesheets/margin_rule.rs +190 -0
  212. package/vendor/stylo/stylesheets/media_rule.rs +191 -0
  213. package/vendor/stylo/stylesheets/mod.rs +918 -0
  214. package/vendor/stylo/stylesheets/namespace_rule.rs +43 -0
  215. package/vendor/stylo/stylesheets/nested_declarations_rule.rs +51 -0
  216. package/vendor/stylo/stylesheets/origin.rs +249 -0
  217. package/vendor/stylo/stylesheets/page_rule.rs +354 -0
  218. package/vendor/stylo/stylesheets/position_try_rule.rs +68 -0
  219. package/vendor/stylo/stylesheets/property_rule.rs +5 -0
  220. package/vendor/stylo/stylesheets/rule_list.rs +167 -0
  221. package/vendor/stylo/stylesheets/rule_parser.rs +1189 -0
  222. package/vendor/stylo/stylesheets/rules_iterator.rs +397 -0
  223. package/vendor/stylo/stylesheets/scope_rule.rs +511 -0
  224. package/vendor/stylo/stylesheets/starting_style_rule.rs +54 -0
  225. package/vendor/stylo/stylesheets/style_rule.rs +80 -0
  226. package/vendor/stylo/stylesheets/stylesheet.rs +570 -0
  227. package/vendor/stylo/stylesheets/supports_rule.rs +486 -0
  228. package/vendor/stylo/stylesheets/view_transition_rule.rs +81 -0
  229. package/vendor/stylo/stylist.rs +5076 -0
  230. package/vendor/stylo/thread_state.rs +87 -0
  231. package/vendor/stylo/traversal.rs +765 -0
  232. package/vendor/stylo/traversal_flags.rs +68 -0
  233. package/vendor/stylo/typed_om/mod.rs +981 -0
  234. package/vendor/stylo/typed_om/numeric.rs +128 -0
  235. package/vendor/stylo/typed_om/numeric_declaration.rs +93 -0
  236. package/vendor/stylo/typed_om/numeric_type.rs +640 -0
  237. package/vendor/stylo/typed_om/sum_value.rs +426 -0
  238. package/vendor/stylo/url/gecko.rs +367 -0
  239. package/vendor/stylo/url/mod.rs +71 -0
  240. package/vendor/stylo/url/servo.rs +239 -0
  241. package/vendor/stylo/use_counters/mod.rs +137 -0
  242. package/vendor/stylo/values/animated/color.rs +103 -0
  243. package/vendor/stylo/values/animated/effects.rs +26 -0
  244. package/vendor/stylo/values/animated/font.rs +37 -0
  245. package/vendor/stylo/values/animated/grid.rs +161 -0
  246. package/vendor/stylo/values/animated/lists.rs +141 -0
  247. package/vendor/stylo/values/animated/mod.rs +550 -0
  248. package/vendor/stylo/values/animated/svg.rs +46 -0
  249. package/vendor/stylo/values/animated/text.rs +58 -0
  250. package/vendor/stylo/values/animated/transform.rs +1592 -0
  251. package/vendor/stylo/values/computed/align.rs +90 -0
  252. package/vendor/stylo/values/computed/angle.rs +130 -0
  253. package/vendor/stylo/values/computed/animation.rs +124 -0
  254. package/vendor/stylo/values/computed/background.rs +13 -0
  255. package/vendor/stylo/values/computed/basic_shape.rs +267 -0
  256. package/vendor/stylo/values/computed/border.rs +163 -0
  257. package/vendor/stylo/values/computed/box.rs +267 -0
  258. package/vendor/stylo/values/computed/calc.rs +334 -0
  259. package/vendor/stylo/values/computed/color.rs +161 -0
  260. package/vendor/stylo/values/computed/column.rs +11 -0
  261. package/vendor/stylo/values/computed/corner_shape.rs +155 -0
  262. package/vendor/stylo/values/computed/counters.rs +26 -0
  263. package/vendor/stylo/values/computed/easing.rs +109 -0
  264. package/vendor/stylo/values/computed/effects.rs +30 -0
  265. package/vendor/stylo/values/computed/flex.rs +19 -0
  266. package/vendor/stylo/values/computed/font.rs +1517 -0
  267. package/vendor/stylo/values/computed/image.rs +273 -0
  268. package/vendor/stylo/values/computed/length.rs +576 -0
  269. package/vendor/stylo/values/computed/length_percentage.rs +1055 -0
  270. package/vendor/stylo/values/computed/list.rs +16 -0
  271. package/vendor/stylo/values/computed/mod.rs +1141 -0
  272. package/vendor/stylo/values/computed/motion.rs +73 -0
  273. package/vendor/stylo/values/computed/outline.rs +7 -0
  274. package/vendor/stylo/values/computed/page.rs +77 -0
  275. package/vendor/stylo/values/computed/param.rs +9 -0
  276. package/vendor/stylo/values/computed/percentage.rs +143 -0
  277. package/vendor/stylo/values/computed/position.rs +273 -0
  278. package/vendor/stylo/values/computed/ratio.rs +88 -0
  279. package/vendor/stylo/values/computed/rect.rs +19 -0
  280. package/vendor/stylo/values/computed/resolution.rs +76 -0
  281. package/vendor/stylo/values/computed/svg.rs +66 -0
  282. package/vendor/stylo/values/computed/table.rs +7 -0
  283. package/vendor/stylo/values/computed/text.rs +199 -0
  284. package/vendor/stylo/values/computed/time.rs +83 -0
  285. package/vendor/stylo/values/computed/transform.rs +559 -0
  286. package/vendor/stylo/values/computed/tree_counting.rs +30 -0
  287. package/vendor/stylo/values/computed/ui.rs +23 -0
  288. package/vendor/stylo/values/computed/url.rs +12 -0
  289. package/vendor/stylo/values/distance.rs +139 -0
  290. package/vendor/stylo/values/generics/animation.rs +363 -0
  291. package/vendor/stylo/values/generics/background.rs +65 -0
  292. package/vendor/stylo/values/generics/basic_shape.rs +1389 -0
  293. package/vendor/stylo/values/generics/border.rs +303 -0
  294. package/vendor/stylo/values/generics/box.rs +552 -0
  295. package/vendor/stylo/values/generics/calc.rs +2986 -0
  296. package/vendor/stylo/values/generics/color.rs +318 -0
  297. package/vendor/stylo/values/generics/column.rs +44 -0
  298. package/vendor/stylo/values/generics/counters.rs +320 -0
  299. package/vendor/stylo/values/generics/easing.rs +132 -0
  300. package/vendor/stylo/values/generics/effects.rs +131 -0
  301. package/vendor/stylo/values/generics/flex.rs +34 -0
  302. package/vendor/stylo/values/generics/font.rs +376 -0
  303. package/vendor/stylo/values/generics/grid.rs +962 -0
  304. package/vendor/stylo/values/generics/image.rs +653 -0
  305. package/vendor/stylo/values/generics/length.rs +656 -0
  306. package/vendor/stylo/values/generics/mod.rs +303 -0
  307. package/vendor/stylo/values/generics/motion.rs +274 -0
  308. package/vendor/stylo/values/generics/page.rs +167 -0
  309. package/vendor/stylo/values/generics/position.rs +669 -0
  310. package/vendor/stylo/values/generics/ratio.rs +88 -0
  311. package/vendor/stylo/values/generics/rect.rs +147 -0
  312. package/vendor/stylo/values/generics/size.rs +102 -0
  313. package/vendor/stylo/values/generics/svg.rs +226 -0
  314. package/vendor/stylo/values/generics/text.rs +268 -0
  315. package/vendor/stylo/values/generics/transform.rs +1157 -0
  316. package/vendor/stylo/values/generics/ui.rs +147 -0
  317. package/vendor/stylo/values/generics/url.rs +51 -0
  318. package/vendor/stylo/values/mod.rs +820 -0
  319. package/vendor/stylo/values/resolved/animation.rs +33 -0
  320. package/vendor/stylo/values/resolved/color.rs +53 -0
  321. package/vendor/stylo/values/resolved/counters.rs +45 -0
  322. package/vendor/stylo/values/resolved/mod.rs +316 -0
  323. package/vendor/stylo/values/specified/align.rs +711 -0
  324. package/vendor/stylo/values/specified/angle.rs +407 -0
  325. package/vendor/stylo/values/specified/animation.rs +921 -0
  326. package/vendor/stylo/values/specified/background.rs +270 -0
  327. package/vendor/stylo/values/specified/basic_shape.rs +986 -0
  328. package/vendor/stylo/values/specified/border.rs +430 -0
  329. package/vendor/stylo/values/specified/box.rs +2231 -0
  330. package/vendor/stylo/values/specified/calc.rs +1657 -0
  331. package/vendor/stylo/values/specified/color.rs +1210 -0
  332. package/vendor/stylo/values/specified/column.rs +11 -0
  333. package/vendor/stylo/values/specified/corner_shape.rs +152 -0
  334. package/vendor/stylo/values/specified/counters.rs +242 -0
  335. package/vendor/stylo/values/specified/easing.rs +225 -0
  336. package/vendor/stylo/values/specified/effects.rs +421 -0
  337. package/vendor/stylo/values/specified/flex.rs +42 -0
  338. package/vendor/stylo/values/specified/font.rs +2103 -0
  339. package/vendor/stylo/values/specified/frequency.rs +39 -0
  340. package/vendor/stylo/values/specified/grid.rs +407 -0
  341. package/vendor/stylo/values/specified/image.rs +1385 -0
  342. package/vendor/stylo/values/specified/intersection_observer.rs +80 -0
  343. package/vendor/stylo/values/specified/length.rs +2024 -0
  344. package/vendor/stylo/values/specified/list.rs +190 -0
  345. package/vendor/stylo/values/specified/mod.rs +531 -0
  346. package/vendor/stylo/values/specified/motion.rs +316 -0
  347. package/vendor/stylo/values/specified/number.rs +603 -0
  348. package/vendor/stylo/values/specified/outline.rs +69 -0
  349. package/vendor/stylo/values/specified/page.rs +94 -0
  350. package/vendor/stylo/values/specified/param.rs +121 -0
  351. package/vendor/stylo/values/specified/percentage.rs +364 -0
  352. package/vendor/stylo/values/specified/position.rs +2247 -0
  353. package/vendor/stylo/values/specified/ratio.rs +29 -0
  354. package/vendor/stylo/values/specified/rect.rs +28 -0
  355. package/vendor/stylo/values/specified/resolution.rs +237 -0
  356. package/vendor/stylo/values/specified/source_size_list.rs +135 -0
  357. package/vendor/stylo/values/specified/svg.rs +427 -0
  358. package/vendor/stylo/values/specified/svg_path.rs +1115 -0
  359. package/vendor/stylo/values/specified/table.rs +38 -0
  360. package/vendor/stylo/values/specified/text.rs +1561 -0
  361. package/vendor/stylo/values/specified/time.rs +313 -0
  362. package/vendor/stylo/values/specified/transform.rs +599 -0
  363. package/vendor/stylo/values/specified/tree_counting.rs +32 -0
  364. package/vendor/stylo/values/specified/ui.rs +344 -0
  365. package/vendor/stylo/values/specified/url.rs +12 -0
  366. package/vendor/stylo/values/tagged_numeric.rs +253 -0
  367. package/wasm/blitz_pdf.d.ts +67 -0
  368. package/wasm/blitz_pdf.js +699 -0
  369. package/wasm/blitz_pdf_bg.wasm +0 -0
  370. package/wasm/blitz_pdf_bg.wasm.d.ts +20 -0
package/package.json CHANGED
@@ -1,6 +1,91 @@
1
1
  {
2
2
  "name": "blitz-pdf",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Render HTML and CSS to PDF with Blitz and WebAssembly in Node.js, Bun, and browsers.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/iteufel/blitz-pdf.git"
10
+ },
11
+ "homepage": "https://github.com/iteufel/blitz-pdf#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/iteufel/blitz-pdf/issues"
14
+ },
15
+ "engines": {
16
+ "node": ">=20"
17
+ },
18
+ "sideEffects": false,
19
+ "main": "./dist/node.js",
20
+ "module": "./dist/browser.js",
21
+ "types": "./dist/node.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "browser": {
25
+ "types": "./dist/browser.d.ts",
26
+ "default": "./dist/browser.js"
27
+ },
28
+ "bun": {
29
+ "types": "./dist/node.d.ts",
30
+ "default": "./dist/node.js"
31
+ },
32
+ "node": {
33
+ "types": "./dist/node.d.ts",
34
+ "default": "./dist/node.js"
35
+ },
36
+ "types": "./dist/browser.d.ts",
37
+ "default": "./dist/browser.js"
38
+ },
39
+ "./browser": {
40
+ "types": "./dist/browser.d.ts",
41
+ "default": "./dist/browser.js"
42
+ },
43
+ "./wasm": "./wasm/blitz_pdf_bg.wasm",
44
+ "./package.json": "./package.json"
45
+ },
46
+ "files": [
47
+ "dist",
48
+ "wasm",
49
+ "src",
50
+ "examples",
51
+ "assets/icon.svg",
52
+ "README.md",
53
+ "LICENSE",
54
+ "THIRD_PARTY_NOTICES.md",
55
+ "licenses",
56
+ "vendor"
57
+ ],
58
+ "scripts": {
59
+ "build": "npm run build:wasm && npm run build:js",
60
+ "build:wasm": "node scripts/build-wasm.mjs",
61
+ "build:js": "tsc -p tsconfig.json",
62
+ "check": "tsc -p tsconfig.json --noEmit",
63
+ "test": "bun test tests/*.test.ts",
64
+ "test:node": "node tests/node-smoke.mjs",
65
+ "test:bun": "bun test tests/*.test.ts",
66
+ "test:browser": "node scripts/serve-browser.mjs",
67
+ "test:pdfa": "node scripts/validate-pdfa.mjs",
68
+ "setup:verapdf": "node scripts/install-verapdf.mjs",
69
+ "bench": "bun benchmarks/render.ts",
70
+ "prepack": "node scripts/check-package.mjs",
71
+ "example:node": "node examples/node.mjs",
72
+ "example:bun": "bun examples/bun.ts",
73
+ "example:pagination": "node examples/pagination.mjs",
74
+ "example:german-invoice": "node examples/german-invoice.mjs"
75
+ },
76
+ "keywords": [
77
+ "pdf",
78
+ "html",
79
+ "css",
80
+ "wasm",
81
+ "webassembly",
82
+ "blitz",
83
+ "bun"
84
+ ],
85
+ "devDependencies": {
86
+ "@types/node": "^22.15.30",
87
+ "pdf-lib": "^1.17.1",
88
+ "pdfjs-dist": "^6.4.299",
89
+ "typescript": "^5.9.3"
90
+ }
91
+ }
package/src/api.ts ADDED
@@ -0,0 +1,44 @@
1
+ import loadWasm, { render_pdf, engine_version, RenderJob } from "../wasm/blitz_pdf.js";
2
+ import { createAssetLoader } from "./assets.js";
3
+ import { normalizeOptions } from "./options.js";
4
+ import type { InitOptions, PdfOptions, WasmSource } from "./types.js";
5
+
6
+ export function createApi(defaultSource: () => Promise<WasmSource> | WasmSource,
7
+ prepare: (source: WasmSource) => Promise<WasmSource> = async source => source) {
8
+ let ready: Promise<void> | undefined;
9
+
10
+ /** Initialize once. Concurrent callers share initialization; failed loads can be retried. */
11
+ function init(options: InitOptions = {}): Promise<void> {
12
+ if (ready) return ready;
13
+ ready = (async () => {
14
+ const source = await prepare(options.wasm ?? await defaultSource());
15
+ await loadWasm({ module_or_path: source });
16
+ })().catch((error: unknown) => { ready = undefined; throw error; });
17
+ return ready;
18
+ }
19
+
20
+ /** Render HTML/CSS to a vector PDF/A-3u with embedded fonts and selectable text. */
21
+ async function renderPdf(html: string, options: PdfOptions = {}): Promise<Uint8Array> {
22
+ if (typeof html !== "string") throw new TypeError("html must be a string");
23
+ if (new TextEncoder().encode(html).byteLength > 16 * 1024 * 1024) throw new RangeError("HTML exceeds the 16 MiB limit");
24
+ const { assetResolver, ...normalized } = normalizeOptions(options);
25
+ await init();
26
+ if (!assetResolver) return render_pdf(html, normalized);
27
+ const load = createAssetLoader(assetResolver);
28
+ const job = new RenderJob(html, normalized);
29
+ try {
30
+ for (;;) {
31
+ const urls = job.pending_assets();
32
+ if (urls.length === 0) return job.finish();
33
+ const data = await load(urls);
34
+ for (let i = 0; i < urls.length; i++) job.provide_asset(urls[i]!, data[i]!);
35
+ }
36
+ } finally {
37
+ // In-flight JS loaders never access this job, including after a sibling rejects.
38
+ job.free();
39
+ }
40
+ }
41
+
42
+ async function getEngineVersion(): Promise<string> { await init(); return engine_version(); }
43
+ return { init, renderPdf, getEngineVersion };
44
+ }
package/src/assets.ts ADDED
@@ -0,0 +1,43 @@
1
+ import type { AssetData, AssetResolver, BinaryData } from "./types.js";
2
+
3
+ export const MAX_ASSET_BYTES = 64 * 1024 * 1024;
4
+
5
+ export function copyBytes(value: BinaryData, name: string): Uint8Array {
6
+ // Buffer.slice() creates a view, so use a constructor to snapshot every Uint8Array.
7
+ if (value instanceof Uint8Array) return new Uint8Array(value);
8
+ if (value instanceof ArrayBuffer) return new Uint8Array(value.slice(0));
9
+ throw new TypeError(`${name} must be a Uint8Array or ArrayBuffer`);
10
+ }
11
+
12
+ export function assetBytes(value: AssetData, name: string): Uint8Array {
13
+ return typeof value === "string" ? new TextEncoder().encode(value) : copyBytes(value, name);
14
+ }
15
+
16
+ /** Load independent requests concurrently, with a byte budget shared by all batches of this render. */
17
+ export function createAssetLoader(resolver: AssetResolver) {
18
+ let totalBytes = 0;
19
+ return async (urls: string[]): Promise<Uint8Array[]> => {
20
+ const results = new Array<Uint8Array>(urls.length);
21
+ let next = 0;
22
+ let failed = false;
23
+ async function worker() {
24
+ while (!failed && next < urls.length) {
25
+ const index = next++;
26
+ const url = urls[index]!;
27
+ try {
28
+ let value: Awaited<ReturnType<AssetResolver>>;
29
+ try { value = await resolver(url); }
30
+ catch (cause) { throw new Error(`Failed to load asset: ${url}`, { cause }); }
31
+ if (failed) return;
32
+ if (value == null) throw new Error(`Missing asset: ${url}. The asset resolver returned ${String(value)}`);
33
+ const data = assetBytes(value, `Asset resolver result for ${url}`);
34
+ totalBytes += data.byteLength;
35
+ if (totalBytes > MAX_ASSET_BYTES) throw new RangeError("Assets exceed the 64 MiB limit");
36
+ results[index] = data;
37
+ } catch (error) { failed = true; throw error; }
38
+ }
39
+ }
40
+ await Promise.all(Array.from({ length: Math.min(8, urls.length) }, worker));
41
+ return results;
42
+ };
43
+ }
package/src/browser.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { createApi } from "./api.js";
2
+
3
+ export type { AssetData, AssetMap, AssetResolver, BinaryData, InitOptions, Length, PageFormat, PageNumberOptions, PdfOptions, WasmSource } from "./types.js";
4
+ export const { init, renderPdf, getEngineVersion } = createApi(
5
+ () => new URL("../wasm/blitz_pdf_bg.wasm", import.meta.url),
6
+ );
package/src/node.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { createApi } from "./api.js";
3
+
4
+ export type { AssetData, AssetMap, AssetResolver, BinaryData, InitOptions, Length, PageFormat, PageNumberOptions, PdfOptions, WasmSource } from "./types.js";
5
+ export const { init, renderPdf, getEngineVersion } = createApi(
6
+ () => readFile(new URL("../wasm/blitz_pdf_bg.wasm", import.meta.url)),
7
+ async source => {
8
+ if (source instanceof URL && source.protocol === "file:") return readFile(source);
9
+ if (typeof source === "string" && source.startsWith("file:")) return readFile(new URL(source));
10
+ return source;
11
+ },
12
+ );
package/src/options.ts ADDED
@@ -0,0 +1,101 @@
1
+ import { assetBytes, copyBytes, MAX_ASSET_BYTES } from "./assets.js";
2
+ import type { Length, PageFormat, PageNumberOptions, PdfOptions } from "./types.js";
3
+
4
+ const formats: Record<PageFormat, readonly [number, number]> = {
5
+ A3: [297 * 96 / 25.4, 420 * 96 / 25.4],
6
+ A4: [210 * 96 / 25.4, 297 * 96 / 25.4],
7
+ A5: [148 * 96 / 25.4, 210 * 96 / 25.4],
8
+ Letter: [8.5 * 96, 11 * 96], Legal: [8.5 * 96, 14 * 96], Tabloid: [11 * 96, 17 * 96],
9
+ };
10
+ const optionKeys = new Set(["format", "width", "height", "landscape", "margin", "media", "baseUrl", "assets", "fonts", "title", "pageNumbers", "maxPages"]);
11
+ const unitScale: Record<string, number> = { px: 1, pt: 96 / 72, mm: 96 / 25.4, cm: 96 / 2.54, in: 96 };
12
+
13
+ function length(value: Length, name: string): number {
14
+ let result: number;
15
+ if (typeof value === "number") result = value;
16
+ else if (typeof value === "string") {
17
+ const match = /^\s*(\d+(?:\.\d+)?|\.\d+)(px|pt|mm|cm|in)\s*$/.exec(value);
18
+ if (!match) throw new TypeError(`${name} must be a number of CSS pixels or a length in px, pt, mm, cm, or in`);
19
+ result = Number(match[1]) * unitScale[match[2]!]!;
20
+ } else throw new TypeError(`${name} must be a CSS length`);
21
+ if (!Number.isFinite(result) || result < 0) throw new RangeError(`${name} must be finite and non-negative`);
22
+ return result;
23
+ }
24
+
25
+ function record(value: unknown, name: string): void {
26
+ if (value === null || typeof value !== "object" || Array.isArray(value) ||
27
+ ![Object.prototype, null].includes(Object.getPrototypeOf(value))) {
28
+ throw new TypeError(`${name} must be a plain object`);
29
+ }
30
+ }
31
+
32
+ export function normalizeOptions(options: PdfOptions = {}) {
33
+ record(options, "options");
34
+ for (const key of Object.keys(options)) {
35
+ if (!optionKeys.has(key)) throw new TypeError(`Unknown PDF option: ${key}`);
36
+ }
37
+ if (options.landscape !== undefined && typeof options.landscape !== "boolean") throw new TypeError("landscape must be a boolean");
38
+ const format = options.format ?? "A4";
39
+ if (!Object.hasOwn(formats, format)) throw new TypeError(`Unknown page format: ${String(format)}`);
40
+ if ((options.width === undefined) !== (options.height === undefined)) throw new TypeError("width and height must be provided together");
41
+ if (options.format !== undefined && options.width !== undefined) throw new TypeError("Use either format or custom width and height");
42
+ let [width, height] = options.width === undefined
43
+ ? formats[format] : [length(options.width, "width"), length(options.height!, "height")];
44
+ if (options.landscape) [width, height] = [height, width];
45
+ if (width <= 0 || height <= 0 || width > 19200 || height > 19200) throw new RangeError("Page dimensions must be positive and at most 19200 CSS pixels");
46
+ const inputMargin = options.margin ?? 0;
47
+ const margin = { top: 0, right: 0, bottom: 0, left: 0 };
48
+ if (typeof inputMargin === "object") {
49
+ record(inputMargin, "margin");
50
+ for (const key of Object.keys(inputMargin)) if (!Object.hasOwn(margin, key)) throw new TypeError(`Unknown margin side: ${key}`);
51
+ for (const side of Object.keys(margin) as (keyof typeof margin)[]) margin[side] = length(inputMargin[side] ?? 0, `margin.${side}`);
52
+ } else {
53
+ const value = length(inputMargin, "margin");
54
+ for (const side of Object.keys(margin) as (keyof typeof margin)[]) margin[side] = value;
55
+ }
56
+ let pageNumbers: { template: string; align: "left" | "center" | "right"; fontSize: number } | null = null;
57
+ if (options.pageNumbers !== undefined && options.pageNumbers !== false) {
58
+ const input: PageNumberOptions = options.pageNumbers === true ? {} : options.pageNumbers;
59
+ record(input, "pageNumbers");
60
+ for (const key of Object.keys(input)) if (!["template", "align", "fontSize"].includes(key)) throw new TypeError(`Unknown pageNumbers option: ${key}`);
61
+ const template = input.template ?? "{page} / {pages}";
62
+ if (typeof template !== "string" || template.length > 512 || /[\u0000-\u001f\u007f\u0085\u2028\u2029]/u.test(template)) throw new TypeError("pageNumbers.template must be a single line of at most 512 characters");
63
+ if (!template.includes("{page}") || /[{}]/.test(template.replaceAll("{page}", "").replaceAll("{pages}", ""))) throw new TypeError("pageNumbers.template must include {page}; only {page} and {pages} placeholders are supported");
64
+ const align = input.align ?? "right";
65
+ if (!["left", "center", "right"].includes(align)) throw new TypeError("pageNumbers.align must be left, center, or right");
66
+ const fontSize = length(input.fontSize ?? 12, "pageNumbers.fontSize");
67
+ if (fontSize < 1 || fontSize > 48) throw new RangeError("pageNumbers.fontSize must be between 1 and 48 CSS pixels");
68
+ pageNumbers = { template, align, fontSize };
69
+ }
70
+ const footerHeight = pageNumbers ? pageNumbers.fontSize * 2 + 8 : 0;
71
+ if (width - margin.left - margin.right < 1 || height - margin.top - margin.bottom - footerHeight < 1) throw new RangeError("Margins and pageNumbers must leave at least one CSS pixel of content");
72
+ const media = options.media ?? "print";
73
+ if (media !== "print" && media !== "screen") throw new TypeError("media must be print or screen");
74
+ const maxPages = options.maxPages ?? 100;
75
+ if (!Number.isInteger(maxPages) || maxPages < 1 || maxPages > 1000) throw new RangeError("maxPages must be an integer between 1 and 1000");
76
+ if (options.title !== undefined && typeof options.title !== "string") throw new TypeError("title must be a string");
77
+ const baseUrl = options.baseUrl ?? "https://blitz-pdf.invalid/";
78
+ if (typeof baseUrl !== "string") throw new TypeError("baseUrl must be an absolute URL string");
79
+ let base: URL;
80
+ try { base = new URL(baseUrl); } catch { throw new TypeError("baseUrl must be an absolute URL string"); }
81
+ if (!["http:", "https:", "file:"].includes(base.protocol)) throw new TypeError("baseUrl must use http:, https:, or file:");
82
+ const assets: Record<string, Uint8Array> = Object.create(null);
83
+ const inputAssets = options.assets;
84
+ const assetResolver = typeof inputAssets === "function" ? inputAssets : undefined;
85
+ if (inputAssets !== undefined && !assetResolver) {
86
+ record(inputAssets, "assets");
87
+ let size = 0;
88
+ for (const [key, value] of Object.entries(inputAssets)) {
89
+ const data = assetBytes(value, `assets[${key}]`);
90
+ size += data.byteLength;
91
+ if (size > MAX_ASSET_BYTES) throw new RangeError("Assets exceed the 64 MiB limit");
92
+ const url = new URL(key, base).href;
93
+ if (Object.hasOwn(assets, url)) throw new TypeError(`Duplicate resolved asset URL: ${url}`);
94
+ assets[url] = data;
95
+ }
96
+ }
97
+ if (options.fonts !== undefined && !Array.isArray(options.fonts)) throw new TypeError("fonts must be an array of font bytes");
98
+ const fonts = (options.fonts ?? []).map((font, i) => copyBytes(font, `fonts[${i}]`));
99
+ if (fonts.reduce((total, font) => total + font.byteLength, 0) > 32 * 1024 * 1024) throw new RangeError("Fonts exceed the 32 MiB limit");
100
+ return { width, height, margin, media, maxPages, baseUrl: base.href, assets, assetResolver, fonts, pageNumbers, title: options.title ?? null };
101
+ }
package/src/types.ts ADDED
@@ -0,0 +1,49 @@
1
+ /** Numbers are CSS pixels (96 px = 1 inch). */
2
+ export type Length = number | `${number}${"px" | "pt" | "mm" | "cm" | "in"}`;
3
+ export type PageFormat = "A3" | "A4" | "A5" | "Letter" | "Legal" | "Tabloid";
4
+ export type BinaryData = Uint8Array | ArrayBuffer;
5
+ /** UTF-8 text (for CSS/SVG) or binary resource contents. */
6
+ export type AssetData = BinaryData | string;
7
+ export type AssetMap = Record<string, AssetData>;
8
+ /** Receives an absolute URL. Returning null/undefined rejects the render as a missing asset. */
9
+ export type AssetResolver = (url: string) => AssetData | null | undefined | Promise<AssetData | null | undefined>;
10
+ export type WasmSource = BinaryData | WebAssembly.Module | URL | Request | Response | string;
11
+
12
+ export interface InitOptions {
13
+ /** Override the bundled WASM location, or supply bytes/a compiled module. */
14
+ wasm?: WasmSource;
15
+ }
16
+
17
+ export interface PageNumberOptions {
18
+ /** Single line with {page} and optionally {pages}. Default: "{page} / {pages}". */
19
+ template?: string;
20
+ /** Default: right. */
21
+ align?: "left" | "center" | "right";
22
+ /** Default: 12 CSS pixels (9pt). */
23
+ fontSize?: Length;
24
+ }
25
+
26
+ export interface PdfOptions {
27
+ // All output uses PDF/A-3u conformance, including Unicode mappings and ICC colors.
28
+ /** Default: A4. Use width and height together for a custom page. */
29
+ format?: PageFormat;
30
+ width?: Length;
31
+ height?: Length;
32
+ landscape?: boolean;
33
+ /** Default: 0. Missing sides of an object default to 0. */
34
+ margin?: Length | { top?: Length; right?: Length; bottom?: Length; left?: Length };
35
+ /** CSS media queries to use. Default: print. */
36
+ media?: "print" | "screen";
37
+ /** Base for resolving asset URLs. Default: https://blitz-pdf.invalid/ */
38
+ baseUrl?: string;
39
+ /** Resource map or async loader, called once per absolute URL per render. Data URLs are handled internally. */
40
+ assets?: AssetMap | AssetResolver;
41
+ /** Additional static TTF, OTF, WOFF, or WOFF2 fonts, using their internal family names. */
42
+ fonts?: readonly BinaryData[];
43
+ /** PDF document title. */
44
+ title?: string;
45
+ /** Selectable page-number footer. Reserves space above the bottom margin. Default: false. */
46
+ pageNumbers?: boolean | PageNumberOptions;
47
+ /** Reject larger documents. Default: 100; maximum: 1000. */
48
+ maxPages?: number;
49
+ }
@@ -0,0 +1,17 @@
1
+ # Stylo paged-media patch
2
+
3
+ `stylo/` is the unmodified crates.io `stylo` 0.22.0 source except for:
4
+
5
+ - `properties/longhands.toml`: enable `break-before`, `break-after`, and
6
+ `break-inside` for Servo; add inherited positive-integer `widows` and `orphans`.
7
+ - `properties/shorthands.toml`: enable the three legacy `page-break-*` aliases.
8
+ - `properties/counted_unknown_properties.py`: stop classifying widows/orphans as unknown.
9
+ - `values/specified/box.rs`: parse `avoid-page`, `recto`, and `verso` break values.
10
+
11
+ Upstream exposes break properties only in Gecko builds. Enabling them here lets
12
+ Blitz's actual Stylo cascade handle selectors, inheritance, media queries, CSS
13
+ variables, inline styles, and `!important`; no CSS rewriting is used.
14
+
15
+ This directory retains its upstream MPL-2.0 license. The modified source ships in
16
+ the npm archive. Update the patch when upgrading Stylo and run the pagination
17
+ suite, especially the cascade and legacy-alias tests.
@@ -0,0 +1 @@
1
+ {"v":1}
@@ -0,0 +1,6 @@
1
+ {
2
+ "git": {
3
+ "sha1": "34d25f741765a0bdb894f8271852e633299352d8"
4
+ },
5
+ "path_in_vcs": "style"
6
+ }