pulpweaver4 0.0.91 → 0.0.185

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 (502) hide show
  1. package/dist/ast/djot.js +23 -0
  2. package/dist/ast/djot.js.map +1 -1
  3. package/dist/ast/index.d.ts +1 -0
  4. package/dist/ast/index.js +1 -0
  5. package/dist/ast/index.js.map +1 -1
  6. package/dist/ast/nodes.d.ts +59 -5
  7. package/dist/ast/nodes.js.map +1 -1
  8. package/dist/ast/table.d.ts +27 -0
  9. package/dist/ast/table.js +32 -0
  10. package/dist/ast/table.js.map +1 -0
  11. package/dist/browser.js +2420 -0
  12. package/dist/citations/index.d.ts +1 -1
  13. package/dist/citations/index.js +1 -1
  14. package/dist/citations/index.js.map +1 -1
  15. package/dist/citations/project.d.ts +12 -2
  16. package/dist/citations/project.js +21 -7
  17. package/dist/citations/project.js.map +1 -1
  18. package/dist/colour/images.d.ts +11 -2
  19. package/dist/colour/images.js +53 -3
  20. package/dist/colour/images.js.map +1 -1
  21. package/dist/colour/ink-limit.d.ts +2 -2
  22. package/dist/colour/ink-limit.js +6 -0
  23. package/dist/colour/ink-limit.js.map +1 -1
  24. package/dist/colour/previews.d.ts +8 -4
  25. package/dist/colour/previews.js +11 -8
  26. package/dist/colour/previews.js.map +1 -1
  27. package/dist/config/config.d.ts +91 -3
  28. package/dist/config/config.js +200 -3
  29. package/dist/config/config.js.map +1 -1
  30. package/dist/config/project-schema.d.ts +0 -8
  31. package/dist/config/project-schema.js +207 -12
  32. package/dist/config/project-schema.js.map +1 -1
  33. package/dist/config/schema.js +10 -0
  34. package/dist/config/schema.js.map +1 -1
  35. package/dist/config/secrets.d.ts +11 -0
  36. package/dist/config/secrets.js +19 -0
  37. package/dist/config/secrets.js.map +1 -0
  38. package/dist/csl/project.d.ts +19 -4
  39. package/dist/csl/project.js +23 -10
  40. package/dist/csl/project.js.map +1 -1
  41. package/dist/fonts/index.d.ts +1 -1
  42. package/dist/fonts/index.js +1 -1
  43. package/dist/fonts/index.js.map +1 -1
  44. package/dist/fonts/lint.d.ts +51 -0
  45. package/dist/fonts/lint.js +101 -16
  46. package/dist/fonts/lint.js.map +1 -1
  47. package/dist/fonts/walk.d.ts +13 -0
  48. package/dist/fonts/walk.js +50 -33
  49. package/dist/fonts/walk.js.map +1 -1
  50. package/dist/html/css.d.ts +4 -0
  51. package/dist/html/css.js +11 -3
  52. package/dist/html/css.js.map +1 -1
  53. package/dist/html/dom.d.ts +6 -1
  54. package/dist/html/dom.js +28 -6
  55. package/dist/html/dom.js.map +1 -1
  56. package/dist/html/generated.d.ts +17 -0
  57. package/dist/html/generated.js +21 -0
  58. package/dist/html/generated.js.map +1 -0
  59. package/dist/html/images.d.ts +18 -0
  60. package/dist/html/images.js +49 -2
  61. package/dist/html/images.js.map +1 -1
  62. package/dist/html/index.d.ts +1 -0
  63. package/dist/html/index.js +1 -0
  64. package/dist/html/index.js.map +1 -1
  65. package/dist/html/render.d.ts +5 -4
  66. package/dist/html/render.js +24 -6
  67. package/dist/html/render.js.map +1 -1
  68. package/dist/hyphenation/exceptions.d.ts +5 -0
  69. package/dist/hyphenation/exceptions.js +11 -0
  70. package/dist/hyphenation/exceptions.js.map +1 -1
  71. package/dist/hyphenation/index.d.ts +1 -1
  72. package/dist/hyphenation/index.js +1 -1
  73. package/dist/hyphenation/index.js.map +1 -1
  74. package/dist/import/convert.d.ts +21 -0
  75. package/dist/import/convert.js +65 -0
  76. package/dist/import/convert.js.map +1 -0
  77. package/dist/incremental/cache.d.ts +59 -0
  78. package/dist/incremental/cache.js +64 -0
  79. package/dist/incremental/cache.js.map +1 -0
  80. package/dist/incremental/index.d.ts +3 -0
  81. package/dist/incremental/index.js +4 -0
  82. package/dist/incremental/index.js.map +1 -0
  83. package/dist/incremental/keys.d.ts +27 -0
  84. package/dist/incremental/keys.js +89 -0
  85. package/dist/incremental/keys.js.map +1 -0
  86. package/dist/incremental/session.d.ts +180 -0
  87. package/dist/incremental/session.js +401 -0
  88. package/dist/incremental/session.js.map +1 -0
  89. package/dist/index.d.ts +6 -0
  90. package/dist/index.js +6 -0
  91. package/dist/index.js.map +1 -1
  92. package/dist/indexes/layout.d.ts +8 -2
  93. package/dist/indexes/layout.js +6 -4
  94. package/dist/indexes/layout.js.map +1 -1
  95. package/dist/layout/cache.d.ts +174 -0
  96. package/dist/layout/cache.js +150 -0
  97. package/dist/layout/cache.js.map +1 -0
  98. package/dist/layout/converge.d.ts +28 -0
  99. package/dist/layout/converge.js +102 -9
  100. package/dist/layout/converge.js.map +1 -1
  101. package/dist/layout/counters.d.ts +4 -0
  102. package/dist/layout/counters.js +15 -0
  103. package/dist/layout/counters.js.map +1 -1
  104. package/dist/layout/index.d.ts +5 -2
  105. package/dist/layout/index.js +3 -0
  106. package/dist/layout/index.js.map +1 -1
  107. package/dist/layout/lists.d.ts +52 -3
  108. package/dist/layout/lists.js +513 -46
  109. package/dist/layout/lists.js.map +1 -1
  110. package/dist/layout/lookahead.d.ts +151 -0
  111. package/dist/layout/lookahead.js +581 -0
  112. package/dist/layout/lookahead.js.map +1 -0
  113. package/dist/layout/margin-boxes.d.ts +11 -1
  114. package/dist/layout/margin-boxes.js +24 -1
  115. package/dist/layout/margin-boxes.js.map +1 -1
  116. package/dist/layout/page-rules.d.ts +6 -1
  117. package/dist/layout/page-rules.js +42 -1
  118. package/dist/layout/page-rules.js.map +1 -1
  119. package/dist/layout/page.js +4 -2
  120. package/dist/layout/page.js.map +1 -1
  121. package/dist/layout/pagebuilder.d.ts +248 -3
  122. package/dist/layout/pagebuilder.js +512 -19
  123. package/dist/layout/pagebuilder.js.map +1 -1
  124. package/dist/layout/pages.d.ts +108 -1
  125. package/dist/layout/pages.js +1362 -159
  126. package/dist/layout/pages.js.map +1 -1
  127. package/dist/layout/paragraph.d.ts +14 -0
  128. package/dist/layout/paragraph.js +304 -31
  129. package/dist/layout/paragraph.js.map +1 -1
  130. package/dist/layout/pre.js +4 -0
  131. package/dist/layout/pre.js.map +1 -1
  132. package/dist/layout/protrusion.d.ts +26 -0
  133. package/dist/layout/protrusion.js +39 -0
  134. package/dist/layout/protrusion.js.map +1 -0
  135. package/dist/layout/ranges.d.ts +2 -0
  136. package/dist/layout/ranges.js +22 -0
  137. package/dist/layout/ranges.js.map +1 -0
  138. package/dist/layout/region.d.ts +2 -1
  139. package/dist/layout/region.js +9 -5
  140. package/dist/layout/region.js.map +1 -1
  141. package/dist/layout/templates.d.ts +71 -0
  142. package/dist/layout/templates.js +290 -0
  143. package/dist/layout/templates.js.map +1 -0
  144. package/dist/layout/vlist.d.ts +3 -3
  145. package/dist/linebreak/items.d.ts +27 -2
  146. package/dist/linebreak/items.js +10 -3
  147. package/dist/linebreak/items.js.map +1 -1
  148. package/dist/linebreak/knuth-plass.d.ts +20 -0
  149. package/dist/linebreak/knuth-plass.js +68 -16
  150. package/dist/linebreak/knuth-plass.js.map +1 -1
  151. package/dist/lint/book.d.ts +13 -0
  152. package/dist/lint/book.js +52 -0
  153. package/dist/lint/book.js.map +1 -0
  154. package/dist/lint/config.d.ts +9 -0
  155. package/dist/lint/config.js +40 -6
  156. package/dist/lint/config.js.map +1 -1
  157. package/dist/lint/linter.js +1 -0
  158. package/dist/lint/linter.js.map +1 -1
  159. package/dist/lint/project.js +1 -1
  160. package/dist/lint/project.js.map +1 -1
  161. package/dist/lint/rules/layout.d.ts +3 -1
  162. package/dist/lint/rules/layout.js +8 -6
  163. package/dist/lint/rules/layout.js.map +1 -1
  164. package/dist/lint/rules/source.js +1 -1
  165. package/dist/lint/rules/source.js.map +1 -1
  166. package/dist/lint/testing.js +1 -0
  167. package/dist/lint/testing.js.map +1 -1
  168. package/dist/measure/bidi-data.d.ts +14 -0
  169. package/dist/measure/bidi-data.js +69 -0
  170. package/dist/measure/bidi-data.js.map +1 -0
  171. package/dist/measure/bidi.d.ts +70 -0
  172. package/dist/measure/bidi.js +225 -0
  173. package/dist/measure/bidi.js.map +1 -0
  174. package/dist/measure/css.d.ts +5 -0
  175. package/dist/measure/css.js +2 -0
  176. package/dist/measure/css.js.map +1 -1
  177. package/dist/measure/measurer.d.ts +36 -2
  178. package/dist/measure/measurer.js +220 -22
  179. package/dist/measure/measurer.js.map +1 -1
  180. package/dist/measure/model.d.ts +20 -2
  181. package/dist/measure/model.js +13 -6
  182. package/dist/measure/model.js.map +1 -1
  183. package/dist/measure/script-data.d.ts +6 -0
  184. package/dist/measure/script-data.js +34 -0
  185. package/dist/measure/script-data.js.map +1 -0
  186. package/dist/measure/scripts.d.ts +36 -0
  187. package/dist/measure/scripts.js +293 -0
  188. package/dist/measure/scripts.js.map +1 -0
  189. package/dist/output/output.d.ts +35 -3
  190. package/dist/output/output.js +26 -4
  191. package/dist/output/output.js.map +1 -1
  192. package/dist/paint/backgrounds.js +7 -20
  193. package/dist/paint/backgrounds.js.map +1 -1
  194. package/dist/paint/blend.d.ts +33 -13
  195. package/dist/paint/blend.js +73 -21
  196. package/dist/paint/blend.js.map +1 -1
  197. package/dist/paint/cache.d.ts +80 -0
  198. package/dist/paint/cache.js +537 -0
  199. package/dist/paint/cache.js.map +1 -0
  200. package/dist/paint/canvas.d.ts +4 -13
  201. package/dist/paint/canvas.js +45 -5
  202. package/dist/paint/canvas.js.map +1 -1
  203. package/dist/paint/context.d.ts +2 -0
  204. package/dist/paint/emphasis.js +1 -1
  205. package/dist/paint/emphasis.js.map +1 -1
  206. package/dist/paint/flatten.d.ts +24 -2
  207. package/dist/paint/flatten.js +55 -12
  208. package/dist/paint/flatten.js.map +1 -1
  209. package/dist/paint/forms.d.ts +64 -0
  210. package/dist/paint/forms.js +319 -0
  211. package/dist/paint/forms.js.map +1 -0
  212. package/dist/paint/images.d.ts +4 -1
  213. package/dist/paint/images.js +13 -2
  214. package/dist/paint/images.js.map +1 -1
  215. package/dist/paint/layers.d.ts +64 -0
  216. package/dist/paint/layers.js +137 -0
  217. package/dist/paint/layers.js.map +1 -0
  218. package/dist/paint/painter.d.ts +19 -6
  219. package/dist/paint/painter.js +15 -135
  220. package/dist/paint/painter.js.map +1 -1
  221. package/dist/paint/stacking.d.ts +1 -1
  222. package/dist/paint/stacking.js +9 -2
  223. package/dist/paint/stacking.js.map +1 -1
  224. package/dist/paint/text.d.ts +14 -3
  225. package/dist/paint/text.js +25 -4
  226. package/dist/paint/text.js.map +1 -1
  227. package/dist/paint/vertical.js +2 -2
  228. package/dist/paint/vertical.js.map +1 -1
  229. package/dist/pdf/encoded.d.ts +16 -0
  230. package/dist/pdf/encoded.js +35 -0
  231. package/dist/pdf/encoded.js.map +1 -0
  232. package/dist/pdf/include/colour.d.ts +105 -0
  233. package/dist/pdf/include/colour.js +349 -0
  234. package/dist/pdf/include/colour.js.map +1 -0
  235. package/dist/pdf/include/functions.d.ts +17 -0
  236. package/dist/pdf/include/functions.js +389 -0
  237. package/dist/pdf/include/functions.js.map +1 -0
  238. package/dist/pdf/include/pages.d.ts +14 -0
  239. package/dist/pdf/include/pages.js +27 -0
  240. package/dist/pdf/include/pages.js.map +1 -0
  241. package/dist/pdf/include/pdfjs/LICENSE +177 -0
  242. package/dist/pdf/include/pdfjs/pdf.min.mjs +27 -0
  243. package/dist/pdf/include/pdfjs/pdf.worker.min.mjs +27 -0
  244. package/dist/pdf/include/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
  245. package/dist/pdf/include/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
  246. package/dist/pdf/include/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
  247. package/dist/pdf/include/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
  248. package/dist/pdf/include/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
  249. package/dist/pdf/include/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
  250. package/dist/pdf/include/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
  251. package/dist/pdf/include/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
  252. package/dist/pdf/include/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
  253. package/dist/pdf/include/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
  254. package/dist/pdf/include/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
  255. package/dist/pdf/include/pdfjs/standard_fonts/LICENSE_LIBERATION +363 -0
  256. package/dist/pdf/include/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
  257. package/dist/pdf/include/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
  258. package/dist/pdf/include/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
  259. package/dist/pdf/include/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
  260. package/dist/pdf/include/pdfjs/wasm/LICENSE_JBIG2 +196 -0
  261. package/dist/pdf/include/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
  262. package/dist/pdf/include/pdfjs/wasm/LICENSE_PDFJS_JBIG2 +13 -0
  263. package/dist/pdf/include/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
  264. package/dist/pdf/include/pdfjs/wasm/LICENSE_PDFJS_QCMS +19 -0
  265. package/dist/pdf/include/pdfjs/wasm/LICENSE_QCMS +21 -0
  266. package/dist/pdf/include/pdfjs/wasm/jbig2.wasm +0 -0
  267. package/dist/pdf/include/pdfjs/wasm/openjpeg.wasm +0 -0
  268. package/dist/pdf/include/pdfjs/wasm/qcms_bg.wasm +0 -0
  269. package/dist/pdf/include/pdfjs/wasm/quickjs-eval.wasm +0 -0
  270. package/dist/pdf/include/prepare.d.ts +58 -0
  271. package/dist/pdf/include/prepare.js +266 -0
  272. package/dist/pdf/include/prepare.js.map +1 -0
  273. package/dist/pdf/include/preview.d.ts +38 -0
  274. package/dist/pdf/include/preview.js +101 -0
  275. package/dist/pdf/include/preview.js.map +1 -0
  276. package/dist/pdf/include/rewrite.d.ts +57 -0
  277. package/dist/pdf/include/rewrite.js +803 -0
  278. package/dist/pdf/include/rewrite.js.map +1 -0
  279. package/dist/pdf/include/serialize.d.ts +32 -0
  280. package/dist/pdf/include/serialize.js +158 -0
  281. package/dist/pdf/include/serialize.js.map +1 -0
  282. package/dist/pdf/include/testing.d.ts +26 -0
  283. package/dist/pdf/include/testing.js +50 -0
  284. package/dist/pdf/include/testing.js.map +1 -0
  285. package/dist/pdf/index.d.ts +1 -0
  286. package/dist/pdf/index.js +1 -0
  287. package/dist/pdf/index.js.map +1 -1
  288. package/dist/pdf/structure/annotations.d.ts +33 -0
  289. package/dist/pdf/structure/annotations.js +112 -0
  290. package/dist/pdf/structure/annotations.js.map +1 -0
  291. package/dist/pdf/structure/forms.d.ts +10 -0
  292. package/dist/pdf/structure/forms.js +46 -0
  293. package/dist/pdf/structure/forms.js.map +1 -0
  294. package/dist/pdf/structure/index.d.ts +41 -5
  295. package/dist/pdf/structure/index.js +40 -5
  296. package/dist/pdf/structure/index.js.map +1 -1
  297. package/dist/pdf/structure/links.d.ts +2 -0
  298. package/dist/pdf/structure/links.js +1 -1
  299. package/dist/pdf/structure/links.js.map +1 -1
  300. package/dist/pdf/structure/presentation.d.ts +28 -0
  301. package/dist/pdf/structure/presentation.js +79 -0
  302. package/dist/pdf/structure/presentation.js.map +1 -0
  303. package/dist/pdf/structure/tags.d.ts +34 -2
  304. package/dist/pdf/structure/tags.js +117 -14
  305. package/dist/pdf/structure/tags.js.map +1 -1
  306. package/dist/pdf/types.d.ts +357 -11
  307. package/dist/pdf/wasm/pulpweaver4_pdf.d.ts +44 -2
  308. package/dist/pdf/wasm/pulpweaver4_pdf.js +191 -2
  309. package/dist/pdf/wasm/pulpweaver4_pdf_bg.wasm +0 -0
  310. package/dist/pdf/writer.d.ts +13 -1
  311. package/dist/pdf/writer.js +26 -1
  312. package/dist/pdf/writer.js.map +1 -1
  313. package/dist/plugin/define.d.ts +200 -15
  314. package/dist/plugin/define.js +124 -15
  315. package/dist/plugin/define.js.map +1 -1
  316. package/dist/plugin/failure.d.ts +1 -1
  317. package/dist/plugin/index.d.ts +5 -4
  318. package/dist/plugin/index.js +5 -4
  319. package/dist/plugin/index.js.map +1 -1
  320. package/dist/plugin/reference.d.ts +38 -0
  321. package/dist/plugin/reference.js +287 -0
  322. package/dist/plugin/reference.js.map +1 -0
  323. package/dist/plugin/register.d.ts +39 -7
  324. package/dist/plugin/register.js +83 -2
  325. package/dist/plugin/register.js.map +1 -1
  326. package/dist/preflight/index.d.ts +1 -1
  327. package/dist/preflight/index.js +1 -1
  328. package/dist/preflight/index.js.map +1 -1
  329. package/dist/preflight/pdfx.d.ts +35 -0
  330. package/dist/preflight/pdfx.js +33 -2
  331. package/dist/preflight/pdfx.js.map +1 -1
  332. package/dist/preflight/reader.d.ts +10 -3
  333. package/dist/preflight/reader.js +86 -5
  334. package/dist/preflight/reader.js.map +1 -1
  335. package/dist/print/impose.d.ts +66 -0
  336. package/dist/print/impose.js +331 -0
  337. package/dist/print/impose.js.map +1 -0
  338. package/dist/print/output.js +400 -50
  339. package/dist/print/output.js.map +1 -1
  340. package/dist/problem.js +4 -3
  341. package/dist/problem.js.map +1 -1
  342. package/dist/profile/index.d.ts +1 -0
  343. package/dist/profile/index.js +1 -0
  344. package/dist/profile/index.js.map +1 -1
  345. package/dist/profile/lint.d.ts +1 -1
  346. package/dist/profile/lint.js +29 -1
  347. package/dist/profile/lint.js.map +1 -1
  348. package/dist/profile/list-table.d.ts +51 -0
  349. package/dist/profile/list-table.js +137 -0
  350. package/dist/profile/list-table.js.map +1 -0
  351. package/dist/profile/metadata.js +3 -0
  352. package/dist/profile/metadata.js.map +1 -1
  353. package/dist/profile/profile.d.ts +3 -0
  354. package/dist/profile/profile.js +9 -1
  355. package/dist/profile/profile.js.map +1 -1
  356. package/dist/project.js +3 -0
  357. package/dist/project.js.map +1 -1
  358. package/dist/qpdf/index.d.ts +2 -0
  359. package/dist/qpdf/index.js +3 -0
  360. package/dist/qpdf/index.js.map +1 -0
  361. package/dist/qpdf/qpdf.d.ts +125 -0
  362. package/dist/qpdf/qpdf.js +205 -0
  363. package/dist/qpdf/qpdf.js.map +1 -0
  364. package/dist/qpdf/testing.d.ts +12 -0
  365. package/dist/qpdf/testing.js +9 -0
  366. package/dist/qpdf/testing.js.map +1 -0
  367. package/dist/qpdf/wasm/LICENSE-qpdf +202 -0
  368. package/dist/qpdf/wasm/LICENSE-zlib +22 -0
  369. package/dist/qpdf/wasm/NOTICE-qpdf.md +42 -0
  370. package/dist/qpdf/wasm/qpdf.wasm +0 -0
  371. package/dist/render/index.d.ts +3 -0
  372. package/dist/render/index.js +2 -0
  373. package/dist/render/index.js.map +1 -0
  374. package/dist/render/render.d.ts +98 -0
  375. package/dist/render/render.js +243 -0
  376. package/dist/render/render.js.map +1 -0
  377. package/dist/reproducible/clock.d.ts +4 -5
  378. package/dist/reproducible/clock.js +4 -5
  379. package/dist/reproducible/clock.js.map +1 -1
  380. package/dist/spike/spike-page.chromium.json +4 -4
  381. package/dist/style/colours.d.ts +7 -2
  382. package/dist/style/colours.js +24 -2
  383. package/dist/style/colours.js.map +1 -1
  384. package/dist/style/compile.js +1 -1
  385. package/dist/style/compile.js.map +1 -1
  386. package/dist/style/defaults.d.ts +9 -3
  387. package/dist/style/defaults.js +14 -2
  388. package/dist/style/defaults.js.map +1 -1
  389. package/dist/style/gcpm.d.ts +1 -1
  390. package/dist/style/gcpm.js +17 -5
  391. package/dist/style/gcpm.js.map +1 -1
  392. package/dist/style/properties.js +84 -0
  393. package/dist/style/properties.js.map +1 -1
  394. package/dist/test/book.d.ts +22 -2
  395. package/dist/test/book.js +35 -2
  396. package/dist/test/book.js.map +1 -1
  397. package/dist/test/build.d.ts +23 -0
  398. package/dist/test/build.js +86 -33
  399. package/dist/test/build.js.map +1 -1
  400. package/dist/test/layout.js +128 -19
  401. package/dist/test/layout.js.map +1 -1
  402. package/dist/test/limits.d.ts +8 -0
  403. package/dist/test/limits.js +9 -0
  404. package/dist/test/limits.js.map +1 -0
  405. package/dist/test/pipeline.d.ts +23 -0
  406. package/dist/test/pipeline.js.map +1 -1
  407. package/dist/test/render.d.ts +26 -3
  408. package/dist/test/render.js +151 -23
  409. package/dist/test/render.js.map +1 -1
  410. package/dist/test/runner.d.ts +6 -3
  411. package/dist/test/runner.js +172 -105
  412. package/dist/test/runner.js.map +1 -1
  413. package/dist/test/text.js +2 -2
  414. package/dist/test/text.js.map +1 -1
  415. package/dist/text/output.js +2 -2
  416. package/dist/text/output.js.map +1 -1
  417. package/dist/text/render.d.ts +4 -3
  418. package/dist/text/render.js +126 -4
  419. package/dist/text/render.js.map +1 -1
  420. package/dist/transform/index.d.ts +1 -1
  421. package/dist/transform/index.js +1 -1
  422. package/dist/transform/index.js.map +1 -1
  423. package/dist/transform/run.d.ts +2 -0
  424. package/dist/transform/run.js +32 -16
  425. package/dist/transform/run.js.map +1 -1
  426. package/dist/web/output.js +116 -10
  427. package/dist/web/output.js.map +1 -1
  428. package/dist/web/runtime/justify.js.txt +2 -2
  429. package/dist/web/site.d.ts +2 -0
  430. package/dist/web/site.js +8 -1
  431. package/dist/web/site.js.map +1 -1
  432. package/docs/README.md +6 -1
  433. package/docs/manual/chapters/front.dj +34 -0
  434. package/docs/manual/chapters/guides/citations.dj +426 -0
  435. package/docs/manual/chapters/guides/colour-and-prepress.dj +261 -0
  436. package/docs/manual/chapters/guides/editions.dj +329 -0
  437. package/docs/manual/chapters/guides/in-a-web-page.dj +143 -0
  438. package/docs/manual/chapters/guides/lines-and-pages.dj +681 -0
  439. package/docs/manual/chapters/guides/lint-rules.dj +355 -0
  440. package/docs/manual/chapters/guides/pdfs.dj +501 -0
  441. package/docs/manual/chapters/guides/plugins.dj +425 -0
  442. package/docs/manual/chapters/guides/testing.dj +264 -0
  443. package/docs/manual/chapters/guides/writing-in-djot.dj +537 -0
  444. package/docs/manual/chapters/start/for-latex-users.dj +256 -0
  445. package/docs/manual/chapters/start/getting-started.dj +167 -0
  446. package/docs/manual/chapters/start/your-first-book.dj +426 -0
  447. package/docs/manual/fonts/CrimsonPro-Italic-VF.ttf +0 -0
  448. package/docs/manual/fonts/CrimsonPro-VF.ttf +0 -0
  449. package/docs/manual/fonts/JetBrainsMono-Regular.otf +0 -0
  450. package/docs/manual/fonts/NotoSansSymbols2-Boxes.ttf +0 -0
  451. package/docs/manual/fonts/OFL.txt +95 -0
  452. package/docs/manual/pulpweaver4.toml +39 -0
  453. package/docs/manual/styles/manual.css +137 -0
  454. package/docs/reference/css-properties/index.md +9 -0
  455. package/docs/reference/css-properties/pw-expansion.md +31 -0
  456. package/docs/reference/css-properties/pw-flow-into.md +31 -0
  457. package/docs/reference/css-properties/pw-knockout.md +26 -0
  458. package/docs/reference/css-properties/pw-layer.md +24 -0
  459. package/docs/reference/css-properties/pw-page-breaking.md +30 -0
  460. package/docs/reference/css-properties/pw-page-duration.md +28 -0
  461. package/docs/reference/css-properties/pw-page-rotate.md +29 -0
  462. package/docs/reference/css-properties/pw-page-transition.md +29 -0
  463. package/docs/reference/css-properties/pw-protrusion.md +31 -0
  464. package/docs/reference/lint-rules/ibid-across-page.md +2 -2
  465. package/docs/reference/plugin-api/capabilities.md +2 -2
  466. package/docs/reference/plugin-api/claim-kind.md +1 -1
  467. package/docs/reference/plugin-api/combine-exceptions.md +19 -0
  468. package/docs/reference/plugin-api/element-break-context.md +34 -0
  469. package/docs/reference/plugin-api/element-break-item.md +24 -0
  470. package/docs/reference/plugin-api/element-breaker.md +24 -0
  471. package/docs/reference/plugin-api/flow-definition.md +30 -0
  472. package/docs/reference/plugin-api/generated-reference.md +32 -0
  473. package/docs/reference/plugin-api/index-definition.md +32 -0
  474. package/docs/reference/plugin-api/index-titles.md +18 -0
  475. package/docs/reference/plugin-api/index.md +27 -3
  476. package/docs/reference/plugin-api/insert-class-definition.md +46 -0
  477. package/docs/reference/plugin-api/insert-placement.md +22 -0
  478. package/docs/reference/plugin-api/insert-placements.md +18 -0
  479. package/docs/reference/plugin-api/layout-definition.md +9 -5
  480. package/docs/reference/plugin-api/layout-slot.md +6 -16
  481. package/docs/reference/plugin-api/lint-context.md +3 -1
  482. package/docs/reference/plugin-api/lint-definition.md +1 -1
  483. package/docs/reference/plugin-api/lint-edition.md +2 -0
  484. package/docs/reference/plugin-api/page-builder-event.md +22 -0
  485. package/docs/reference/plugin-api/page-builder-hook.md +7 -3
  486. package/docs/reference/plugin-api/page-builder-page-event.md +30 -0
  487. package/docs/reference/plugin-api/page-template-definition.md +34 -0
  488. package/docs/reference/plugin-api/page-template-region-definition.md +46 -0
  489. package/docs/reference/plugin-api/plugin-definition.md +5 -1
  490. package/docs/reference/plugin-api/plugin-reference-options.md +32 -0
  491. package/docs/reference/plugin-api/plugin-reference.md +22 -0
  492. package/docs/reference/plugin-api/plugin-registry.md +15 -5
  493. package/docs/reference/plugin-api/plugin-stage.md +1 -1
  494. package/docs/reference/plugin-api/plugin.md +9 -2
  495. package/docs/reference/plugin-api/reference-page.md +34 -0
  496. package/docs/reference/plugin-api/render-reference-page.md +18 -0
  497. package/docs/reference/plugin-api/renderers.md +1 -1
  498. package/docs/reference/pulpweaver4-toml/editions.md +239 -2
  499. package/docs/reference/pulpweaver4-toml/index.md +44 -1
  500. package/docs/reference/pulpweaver4-toml/inks.md +15 -4
  501. package/docs/reference/pulpweaver4-toml/lint.md +1 -1
  502. package/package.json +5 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert.js","sourceRoot":"","sources":["../../src/import/convert.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,+DAA+D;AAC/D,MAAM,OAAO,GAAG;IACd,GAAG,EAAE,OAAO;IACZ,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,EAAE,EAAE,UAAU;IACd,QAAQ,EAAE,UAAU;CACZ,CAAA;AAEV,4FAA4F;AAC5F,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;IACnD,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,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AY,EAAE,KAAiB;IAC1D,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAA;IAClC,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAA;IACzG,MAAM,OAAO,GAAG,MAAM,UAAU,EAAE,CAAA;IAClC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;IACzC,MAAM,MAAM,GAAG,MAAM,KAAK,MAAM;QAC9B,CAAC,CAAC,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC;QACjH,CAAC,CAAC,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAA;IACpF,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IAC9C,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,sBAAsB,CAAC,CAAA;IAC1E,OAAO,GAAG,IAAI,IAAI,CAAA;AACpB,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * What a build session keeps from one build to the next
3
+ * (https://plans.inkylabs.com/pulpweaver#performance-and-incremental-builds),
4
+ * which every stage of a build given it (`BuildContext.cache`) reuses where
5
+ * what it was made from is the same: each source's AST, by its text; the
6
+ * keys of the HTML's elements (`keys.ts`); the images' URLs, by their bytes;
7
+ * each paragraph's lines and the page builder's states (`layout/cache.ts`);
8
+ * what the edition's stylesheets and fonts made, which only a change to
9
+ * the project's other files makes again, with a new cache; and each page's
10
+ * display list, for the session's PDF (`paint/cache.ts`), and what its
11
+ * font check found in each text node (`fonts/lint.ts`'s `FontCheckCache`).
12
+ */
13
+ import type { Document } from '../ast/nodes.js';
14
+ import type { CmykConverter } from '../colour/cmyk.js';
15
+ import { FontCheckCache } from '../fonts/lint.js';
16
+ import { LayoutCache } from '../layout/cache.js';
17
+ import { PaintCache } from '../paint/cache.js';
18
+ import type { Problem } from '../problem.js';
19
+ import { StableKeys } from './keys.js';
20
+ export declare class BuildCache {
21
+ readonly layout: LayoutCache;
22
+ readonly keys: StableKeys;
23
+ /** Each page's display list, by its content, as the session's last PDF painted it. */
24
+ readonly paint: PaintCache;
25
+ /** What the session's last PDF's font check found in each text node, by its text and fonts (#187). */
26
+ readonly fonts: FontCheckCache;
27
+ /** Each image's URL, by its path in the project, with the bytes it was made from. */
28
+ readonly images: Map<string, {
29
+ readonly data: Uint8Array;
30
+ readonly url: string;
31
+ readonly file?: string;
32
+ }>;
33
+ /** Where the builds' pages go, and their stylesheet: the same element for every build. */
34
+ container?: HTMLElement;
35
+ style?: HTMLStyleElement;
36
+ /** What the builds' fonts and the edition's stylesheets made: the build's own (`test/build.ts`). */
37
+ prepared?: Promise<unknown>;
38
+ /** A CMYK edition's converter to its output intent, which the builds preview its colours through (`session.ts`). */
39
+ cmyk?: Promise<CmykConverter | undefined>;
40
+ private readonly readings;
41
+ private readonly memos;
42
+ /**
43
+ * A source's AST and the problems reading it found, read again only if
44
+ * its text or its reader changed. The transforms change the AST they are
45
+ * given, so each build is given a copy; an AST that can't be copied (a
46
+ * plugin's reader put a function in it) is read again for every build.
47
+ */
48
+ read(path: string, text: string, reader: string, read: () => Promise<{
49
+ document: Document | undefined;
50
+ problems: readonly Problem[];
51
+ }>): Promise<{
52
+ document: Document | undefined;
53
+ problems: Problem[];
54
+ }>;
55
+ /** A value made from `key` (compared with `===`), made again when the key changes. */
56
+ memo<T>(name: string, key: unknown, make: () => T): T;
57
+ /** Lets go of what the cache holds outside itself: the images' URLs, the painter's colour and the preview's. */
58
+ dispose(): void;
59
+ }
@@ -0,0 +1,64 @@
1
+ import { FontCheckCache } from '../fonts/lint.js';
2
+ import { LayoutCache } from '../layout/cache.js';
3
+ import { PaintCache } from '../paint/cache.js';
4
+ import { StableKeys } from './keys.js';
5
+ export class BuildCache {
6
+ layout = new LayoutCache();
7
+ keys = new StableKeys();
8
+ /** Each page's display list, by its content, as the session's last PDF painted it. */
9
+ paint = new PaintCache();
10
+ /** What the session's last PDF's font check found in each text node, by its text and fonts (#187). */
11
+ fonts = new FontCheckCache();
12
+ /** Each image's URL, by its path in the project, with the bytes it was made from. */
13
+ images = new Map();
14
+ /** Where the builds' pages go, and their stylesheet: the same element for every build. */
15
+ container;
16
+ style;
17
+ /** What the builds' fonts and the edition's stylesheets made: the build's own (`test/build.ts`). */
18
+ prepared;
19
+ /** A CMYK edition's converter to its output intent, which the builds preview its colours through (`session.ts`). */
20
+ cmyk;
21
+ readings = new Map();
22
+ memos = new Map();
23
+ /**
24
+ * A source's AST and the problems reading it found, read again only if
25
+ * its text or its reader changed. The transforms change the AST they are
26
+ * given, so each build is given a copy; an AST that can't be copied (a
27
+ * plugin's reader put a function in it) is read again for every build.
28
+ */
29
+ async read(path, text, reader, read) {
30
+ const r = this.readings.get(path);
31
+ if (r?.text === text && r.reader === reader)
32
+ return { document: r.document && structuredClone(r.document), problems: [...r.problems] };
33
+ const { document, problems } = await read();
34
+ try {
35
+ this.readings.set(path, { text, reader, document: document && structuredClone(document), problems: [...problems] });
36
+ }
37
+ catch {
38
+ this.readings.delete(path);
39
+ }
40
+ return { document, problems: [...problems] };
41
+ }
42
+ /** A value made from `key` (compared with `===`), made again when the key changes. */
43
+ memo(name, key, make) {
44
+ const m = this.memos.get(name);
45
+ if (m && m.key === key)
46
+ return m.value;
47
+ const value = make();
48
+ this.memos.set(name, { key, value });
49
+ return value;
50
+ }
51
+ /** Lets go of what the cache holds outside itself: the images' URLs, the painter's colour and the preview's. */
52
+ dispose() {
53
+ this.paint.dispose();
54
+ void this.cmyk?.then((c) => c?.close());
55
+ for (const { url, file } of this.images.values()) {
56
+ if (url.startsWith('blob:'))
57
+ URL.revokeObjectURL(url);
58
+ if (file)
59
+ URL.revokeObjectURL(file);
60
+ }
61
+ this.images.clear();
62
+ }
63
+ }
64
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/incremental/cache.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAUtC,MAAM,OAAO,UAAU;IACZ,MAAM,GAAG,IAAI,WAAW,EAAE,CAAA;IAC1B,IAAI,GAAG,IAAI,UAAU,EAAE,CAAA;IAChC,sFAAsF;IAC7E,KAAK,GAAG,IAAI,UAAU,EAAE,CAAA;IACjC,sGAAsG;IAC7F,KAAK,GAAG,IAAI,cAAc,EAAE,CAAA;IACrC,qFAAqF;IAC5E,MAAM,GAAG,IAAI,GAAG,EAAuF,CAAA;IAChH,0FAA0F;IAC1F,SAAS,CAAc;IACvB,KAAK,CAAmB;IACxB,oGAAoG;IACpG,QAAQ,CAAmB;IAC3B,oHAAoH;IACpH,IAAI,CAAqC;IACxB,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAA;IACrC,KAAK,GAAG,IAAI,GAAG,EAA8D,CAAA;IAE9F;;;;;OAKG;IACH,KAAK,CAAC,IAAI,CAAC,IAAY,EAAE,IAAY,EAAE,MAAc,EAAE,IAAqF;QAC1I,MAAM,CAAC,GAAG,IAAI,CAAC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AC,OAAO,EAAE,CAAA;QACpB,KAAK,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;QACvC,KAAK,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;YACjD,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC;gBAAE,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAA;YACrD,IAAI,IAAI;gBAAE,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;QACrC,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;IACrB,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ export { BuildCache } from './cache.js';
2
+ export { StableKeys } from './keys.js';
3
+ export { BuildSession, type BuildSessionOptions, type BuildUpdate, type PageState, PREVIEW_MS, type SessionEdit, SWAP_PAGES, type SessionPdf, type SessionPdfOptions } from './session.js';
@@ -0,0 +1,4 @@
1
+ export { BuildCache } from './cache.js';
2
+ export { StableKeys } from './keys.js';
3
+ export { BuildSession, PREVIEW_MS, SWAP_PAGES } from './session.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/incremental/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,YAAY,EAA8D,UAAU,EAAoB,UAAU,EAA2C,MAAM,cAAc,CAAA"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Keys that last from one build to the next
3
+ * (https://plans.inkylabs.com/pulpweaver#performance-and-incremental-builds).
4
+ * A build keys its HTML's elements by their index in document order
5
+ * (`html/dom.ts`), so an element added early in the book changes the key of
6
+ * every element after it, and with its key its HTML, and the layout would
7
+ * reuse nothing after it. A build session gives each element the key of the
8
+ * last build's element it stands for instead, matched as a tree: the root
9
+ * with the last root, and each matched element's children with the last
10
+ * one's, from the start and from the end, by their tag, classes, `id` and
11
+ * own text (not their descendants', so that a chapter is the same chapter
12
+ * whatever changes in it); between those, children of the same tag in the
13
+ * same order where there are as many on each side (a paragraph edited, a
14
+ * note renumbered), else those alike. Elements matched with none (a
15
+ * paragraph added) get keys no build has used.
16
+ */
17
+ /** The keys a session gives its builds' elements. */
18
+ export declare class StableKeys {
19
+ private last;
20
+ private next;
21
+ /**
22
+ * The key of each of `html`'s elements, `html` first, in document order
23
+ * (as `querySelectorAll('*')` lists them): the last build's element's
24
+ * where it matches one, else a new one.
25
+ */
26
+ keys(html: HTMLElement): string[];
27
+ }
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Keys that last from one build to the next
3
+ * (https://plans.inkylabs.com/pulpweaver#performance-and-incremental-builds).
4
+ * A build keys its HTML's elements by their index in document order
5
+ * (`html/dom.ts`), so an element added early in the book changes the key of
6
+ * every element after it, and with its key its HTML, and the layout would
7
+ * reuse nothing after it. A build session gives each element the key of the
8
+ * last build's element it stands for instead, matched as a tree: the root
9
+ * with the last root, and each matched element's children with the last
10
+ * one's, from the start and from the end, by their tag, classes, `id` and
11
+ * own text (not their descendants', so that a chapter is the same chapter
12
+ * whatever changes in it); between those, children of the same tag in the
13
+ * same order where there are as many on each side (a paragraph edited, a
14
+ * note renumbered), else those alike. Elements matched with none (a
15
+ * paragraph added) get keys no build has used.
16
+ */
17
+ /** An element as matched with the last build's. */
18
+ function signature(el) {
19
+ let s = `${el.localName}.${el.getAttribute('class') ?? ''}#${el.id}:`;
20
+ for (let n = el.firstChild; n; n = n.nextSibling)
21
+ if (n.nodeType === 3)
22
+ s += n.data;
23
+ return s;
24
+ }
25
+ /** The keys a session gives its builds' elements. */
26
+ export class StableKeys {
27
+ last;
28
+ next = 0;
29
+ /**
30
+ * The key of each of `html`'s elements, `html` first, in document order
31
+ * (as `querySelectorAll('*')` lists them): the last build's element's
32
+ * where it matches one, else a new one.
33
+ */
34
+ keys(html) {
35
+ const keys = [];
36
+ const fresh = () => String(this.next++);
37
+ const visit = (el, was) => {
38
+ const key = was?.key ?? fresh();
39
+ keys.push(key);
40
+ const children = [...el.children];
41
+ const matched = was ? match(children, was.children) : [];
42
+ const kept = children.map((c, i) => visit(c, matched[i]));
43
+ return { signature: signature(el), tag: el.localName, key, children: kept };
44
+ };
45
+ if (!this.last) {
46
+ // The first build's keys are its indices, as a build's without a session are.
47
+ this.last = visit(html, undefined);
48
+ return keys;
49
+ }
50
+ this.last = visit(html, this.last);
51
+ return keys;
52
+ }
53
+ }
54
+ /** Which of the last build's children each child stands for, if any. */
55
+ function match(children, last) {
56
+ const out = new Array(children.length);
57
+ const sigs = children.map(signature);
58
+ const n = Math.min(children.length, last.length);
59
+ let start = 0;
60
+ while (start < n && sigs[start] === last[start].signature)
61
+ out[start] = last[start++];
62
+ let end = 0;
63
+ while (end < n - start && sigs[children.length - 1 - end] === last[last.length - 1 - end].signature) {
64
+ out[children.length - 1 - end] = last[last.length - 1 - end];
65
+ end++;
66
+ }
67
+ const a = children.length - end;
68
+ const b = last.length - end;
69
+ if (a - start === b - start) {
70
+ // As many on each side: each the one in its place, if of its tag.
71
+ for (let i = start; i < a; i++)
72
+ if (children[i].localName === last[i].tag)
73
+ out[i] = last[i];
74
+ return out;
75
+ }
76
+ // Else in order, each with the next of the last build's alike.
77
+ let j = start;
78
+ for (let i = start; i < a; i++) {
79
+ let k = j;
80
+ while (k < b && last[k].signature !== sigs[i])
81
+ k++;
82
+ if (k < b) {
83
+ out[i] = last[k];
84
+ j = k + 1;
85
+ }
86
+ }
87
+ return out;
88
+ }
89
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/incremental/keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAUH,mDAA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,CAAC,MAAM,GAAG,CAAC,GAAG,GAAG,CAAC,CAAA;QAC5D,GAAG,EAAE,CAAA;IACP,CAAC;IACD,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,GAAG,CAAA;IAC/B,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,GAAG,CAAA;IAC3B,IAAI,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC;QAC5B,kEAAkE;QAClE,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;YAAE,IAAI,QAAQ,CAAC,CAAC,CAAE,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAE,CAAC,GAAG;gBAAE,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;QAC7F,OAAO,GAAG,CAAA;IACZ,CAAC;IACD,+DAA+D;IAC/D,IAAI,CAAC,GAAG,KAAK,CAAA;IACb,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/B,IAAI,CAAC,GAAG,CAAC,CAAA;QACT,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,CAAE,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC;YAAE,CAAC,EAAE,CAAA;QACnD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACV,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;YAChB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACX,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -0,0 +1,180 @@
1
+ import type { FontCheckStats } from '../fonts/lint.js';
2
+ import type { OutputContext, OutputResult } from '../output/output.js';
3
+ import type { PaintStats, StepStats } from '../paint/cache.js';
4
+ import type { Book } from '../test/book.js';
5
+ import { type BuildOptions } from '../test/build.js';
6
+ import { type SourceFile } from '../test/pipeline.js';
7
+ import type { VFS } from '../vfs/vfs.js';
8
+ export interface BuildSessionOptions extends Omit<BuildOptions, 'cache'> {
9
+ /**
10
+ * How many milliseconds a build after an edit searches for the lookahead
11
+ * breaks before it shows a preview and leaves the search to the browser's
12
+ * idle time (#180): 0 always shows a preview first. `PREVIEW_MS` unless
13
+ * given.
14
+ */
15
+ readonly previewMs?: number;
16
+ /**
17
+ * How many pages of the search's a run of the swap that follows a
18
+ * preview makes, at most, before it takes up the preview's again (#199).
19
+ * `SWAP_PAGES` unless given.
20
+ */
21
+ readonly swapPages?: number;
22
+ /**
23
+ * Told of each build the session makes on its own: when the search a
24
+ * preview left has finished, the update that shows its pages where they
25
+ * differ from the preview's (#180).
26
+ */
27
+ readonly onUpdate?: (update: BuildUpdate) => void;
28
+ /**
29
+ * Where a CMYK edition's output intent's profile comes from, for its
30
+ * preview and its PDF (`writePdf`, unless given its own): `pw build`'s.
31
+ */
32
+ readonly outputIntents?: OutputContext['outputIntents'];
33
+ }
34
+ /**
35
+ * An edit: a source's new text, a path of the project's whose file changed
36
+ * (read again from its folder), or, for a session on HTML (`html`, as
37
+ * `render()` opens one on a page's own), the HTML it lays out now.
38
+ */
39
+ export type SessionEdit = {
40
+ readonly path: string;
41
+ /** The source's new text; absent, the file is read again from the project's folder. */
42
+ readonly text?: string;
43
+ } | {
44
+ /** The HTML to lay out in place of the last, its paragraphs' lines reused where they are the same. */
45
+ readonly html: string;
46
+ };
47
+ /** How a session writes its PDF: what `pw build` gives the `pdf` output beside the book. */
48
+ export type SessionPdfOptions = Pick<OutputContext, 'date' | 'outputIntents' | 'load'>;
49
+ /** A session's PDF, as the `pdf` output wrote it. */
50
+ export interface SessionPdf extends OutputResult {
51
+ /** How many pages were painted, and how many were the last PDF's. */
52
+ readonly paint: PaintStats;
53
+ /** How many pages were flattened (`flatten`, PDF/X-1a and X-3) and tagged (`tags`) again, and how many were the last PDF's (#178). */
54
+ readonly steps: Readonly<Record<string, StepStats>>;
55
+ /** How many text nodes the font check looked at again, and how many it took as the last PDF's (#187). */
56
+ readonly fonts: FontCheckStats;
57
+ }
58
+ /** What a build of the session changed. */
59
+ export interface BuildUpdate {
60
+ readonly book: Book;
61
+ /**
62
+ * The pages, counted from 1 as `pages.at` counts them, that are new or
63
+ * changed (renumbered, their margin boxes made again): the rest are the
64
+ * last build's elements, as they were.
65
+ */
66
+ readonly changed: readonly number[];
67
+ /** How many of the last build's pages are no longer shown. */
68
+ readonly removed: number;
69
+ /** Whether the book was built from nothing: the session's first build, or after an edit to more than its sources. */
70
+ readonly full: boolean;
71
+ /** What the layout reused, in its last pass: paragraphs reused and laid out again. */
72
+ readonly paragraphs: {
73
+ readonly reused: number;
74
+ readonly laidOut: number;
75
+ };
76
+ /** How many pages the page builder built anew, in its last pass: the rest of `changed` were kept and renumbered (#199). */
77
+ readonly made: number;
78
+ /** How long the build took, in ms. */
79
+ readonly ms: number;
80
+ /** Whether the pages are the lookahead search's (`exact`), or a preview's while it goes on (`approximate`, #180). */
81
+ readonly state: PageState;
82
+ }
83
+ /** Whether a session's pages are those a build from nothing makes (`exact`), or a preview's while the lookahead search goes on (`approximate`). */
84
+ export type PageState = 'approximate' | 'exact';
85
+ /**
86
+ * How long a build after an edit searches for the lookahead breaks before
87
+ * it shows a preview instead, in ms: an edit that doesn't move the pages
88
+ * after it rarely needs more, and the preview still comes in under a
89
+ * second.
90
+ */
91
+ export declare const PREVIEW_MS = 100;
92
+ /**
93
+ * How many pages of a finished search's a run of its swap makes (#199):
94
+ * the pages it then shows are a few dozen milliseconds' work, a key typed
95
+ * meanwhile waits for no more.
96
+ */
97
+ export declare const SWAP_PAGES = 8;
98
+ export declare class BuildSession {
99
+ private options;
100
+ private cache;
101
+ private sources;
102
+ private current;
103
+ /** The pages shown, each with its revision (`LayoutCache.revisions`) when the last build ended. */
104
+ private shown;
105
+ /** The last build asked for, which the next waits for. */
106
+ private running;
107
+ /** Counts edits and disposal, which drop a search going on in idle time. */
108
+ private generation;
109
+ /** How many of the builds, PDFs and searches asked for are still to run: a run of a swap waits for none. */
110
+ private queued;
111
+ /** Whether the pages are a swap's last run's, exact, but the book must be built again from them, a page number having moved (#199). */
112
+ private stale;
113
+ private constructor();
114
+ /** Opens a session: the book's first build. */
115
+ static open(options?: BuildSessionOptions): Promise<{
116
+ session: BuildSession;
117
+ update: BuildUpdate;
118
+ }>;
119
+ /**
120
+ * Whether the pages shown are exact, those a build from nothing makes, or
121
+ * a preview's while the lookahead search goes on in idle time (#180).
122
+ */
123
+ get state(): PageState;
124
+ /**
125
+ * Makes the pages exact, once the builds asked for are done: the search
126
+ * a preview left is finished at once, not in idle time, and its pages
127
+ * shown. The update, or undefined if the pages were exact.
128
+ */
129
+ exact(): Promise<BuildUpdate | undefined>;
130
+ /** Runs `job` after the builds asked for, in turn. */
131
+ private queue;
132
+ /** The last build's book. */
133
+ get book(): Book;
134
+ /** The sources the book is built from, by path, in order. */
135
+ get files(): readonly SourceFile[];
136
+ /**
137
+ * Builds the book again after edits: a source's new text, or a path whose
138
+ * file changed in the project's folder. Edits to sources build
139
+ * incrementally; any other file builds the book again from nothing.
140
+ */
141
+ update(edits: readonly SessionEdit[]): Promise<BuildUpdate>;
142
+ private apply;
143
+ /**
144
+ * Writes the edition's PDF, `<edition>.pdf` in `out`, from the last
145
+ * build's pages, once the builds asked for are done: the file the `pdf`
146
+ * output writes, painting only the pages that changed since the last PDF.
147
+ * Its problems are the PDF's; the build's are the book's.
148
+ */
149
+ writePdf(out: VFS, options?: SessionPdfOptions): Promise<SessionPdf>;
150
+ private pdf;
151
+ /** Takes the session's pages out of the document. */
152
+ dispose(): void;
153
+ private build;
154
+ /** Shows a build's book, or a run's of a swap: the pages that changed since those shown last. */
155
+ private show;
156
+ /** What a viewer opens the PDF with: a layer that starts hidden is left out of the pages (#167). */
157
+ private hideLayers;
158
+ /** Runs the search a preview left on in the browser's idle time, until an edit drops it; then shows its pages. */
159
+ private searchOn;
160
+ /**
161
+ * Swaps the pages of the search a preview left, now finished, in for the
162
+ * preview's, a run at a time in the browser's idle time (#199): each run
163
+ * lays the book out again, with nothing read or rendered again
164
+ * (`LayoutCache.again`), the search's pages for `SWAP_PAGES` more, then
165
+ * the preview's again where they can be taken up, a preview still, and
166
+ * tells `onUpdate`. The last run makes the rest of the search's pages, and
167
+ * the book exact, unless they moved a page number: then the book is
168
+ * built again. An edit drops it, and `exact()` and a PDF finish it.
169
+ */
170
+ private swapOn;
171
+ /**
172
+ * Builds again with the breaks of the search a preview left, finishing it
173
+ * first (and any swap of its pages it was in, #199); with `all`, again
174
+ * while a build leaves another (page numbers that moved a reference),
175
+ * else that one goes on in idle time. The last update, if any.
176
+ */
177
+ private finish;
178
+ /** A CMYK edition's converter to its output intent's profile, as the `pdf` output makes it; undefined if it has none. */
179
+ private cmykConverter;
180
+ }