postext 1.63.3 → 1.63.5

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 (792) hide show
  1. package/dist/bundle/codec/files.d.ts +20 -0
  2. package/dist/bundle/codec/files.d.ts.map +1 -0
  3. package/dist/bundle/codec/files.js +92 -0
  4. package/dist/bundle/codec/files.js.map +1 -0
  5. package/dist/bundle/codec/plan.d.ts +114 -0
  6. package/dist/bundle/codec/plan.d.ts.map +1 -0
  7. package/dist/bundle/codec/plan.js +367 -0
  8. package/dist/bundle/codec/plan.js.map +1 -0
  9. package/dist/bundle/codec/read.d.ts +92 -0
  10. package/dist/bundle/codec/read.d.ts.map +1 -0
  11. package/dist/bundle/codec/read.js +249 -0
  12. package/dist/bundle/codec/read.js.map +1 -0
  13. package/dist/bundle/codec.d.ts +6 -218
  14. package/dist/bundle/codec.d.ts.map +1 -1
  15. package/dist/bundle/codec.js +3 -699
  16. package/dist/bundle/codec.js.map +1 -1
  17. package/dist/bundle/manifest/entries.d.ts +25 -0
  18. package/dist/bundle/manifest/entries.d.ts.map +1 -0
  19. package/dist/bundle/manifest/entries.js +108 -0
  20. package/dist/bundle/manifest/entries.js.map +1 -0
  21. package/dist/bundle/manifest/fileNames.d.ts +38 -0
  22. package/dist/bundle/manifest/fileNames.d.ts.map +1 -0
  23. package/dist/bundle/manifest/fileNames.js +143 -0
  24. package/dist/bundle/manifest/fileNames.js.map +1 -0
  25. package/dist/bundle/manifest/locale.d.ts +61 -0
  26. package/dist/bundle/manifest/locale.d.ts.map +1 -0
  27. package/dist/bundle/manifest/locale.js +216 -0
  28. package/dist/bundle/manifest/locale.js.map +1 -0
  29. package/dist/bundle/manifest/sizes.d.ts +18 -0
  30. package/dist/bundle/manifest/sizes.d.ts.map +1 -0
  31. package/dist/bundle/manifest/sizes.js +257 -0
  32. package/dist/bundle/manifest/sizes.js.map +1 -0
  33. package/dist/bundle/manifest/validation.d.ts +10 -0
  34. package/dist/bundle/manifest/validation.d.ts.map +1 -0
  35. package/dist/bundle/manifest/validation.js +114 -0
  36. package/dist/bundle/manifest/validation.js.map +1 -0
  37. package/dist/bundle/manifest.d.ts +7 -139
  38. package/dist/bundle/manifest.d.ts.map +1 -1
  39. package/dist/bundle/manifest.js +5 -829
  40. package/dist/bundle/manifest.js.map +1 -1
  41. package/dist/canvas-backend/blockRender/block.d.ts +5 -0
  42. package/dist/canvas-backend/blockRender/block.d.ts.map +1 -0
  43. package/dist/canvas-backend/blockRender/block.js +240 -0
  44. package/dist/canvas-backend/blockRender/block.js.map +1 -0
  45. package/dist/canvas-backend/blockRender/lines.d.ts +16 -0
  46. package/dist/canvas-backend/blockRender/lines.d.ts.map +1 -0
  47. package/dist/canvas-backend/blockRender/lines.js +192 -0
  48. package/dist/canvas-backend/blockRender/lines.js.map +1 -0
  49. package/dist/canvas-backend/blockRender/segments.d.ts +54 -0
  50. package/dist/canvas-backend/blockRender/segments.d.ts.map +1 -0
  51. package/dist/canvas-backend/blockRender/segments.js +311 -0
  52. package/dist/canvas-backend/blockRender/segments.js.map +1 -0
  53. package/dist/canvas-backend/blockRender.d.ts +2 -7
  54. package/dist/canvas-backend/blockRender.d.ts.map +1 -1
  55. package/dist/canvas-backend/blockRender.js +3 -727
  56. package/dist/canvas-backend/blockRender.js.map +1 -1
  57. package/dist/canvas-backend/renderResourceBlock/block.d.ts +9 -0
  58. package/dist/canvas-backend/renderResourceBlock/block.d.ts.map +1 -0
  59. package/dist/canvas-backend/renderResourceBlock/block.js +185 -0
  60. package/dist/canvas-backend/renderResourceBlock/block.js.map +1 -0
  61. package/dist/canvas-backend/renderResourceBlock/images.d.ts +67 -0
  62. package/dist/canvas-backend/renderResourceBlock/images.d.ts.map +1 -0
  63. package/dist/canvas-backend/renderResourceBlock/images.js +224 -0
  64. package/dist/canvas-backend/renderResourceBlock/images.js.map +1 -0
  65. package/dist/canvas-backend/renderResourceBlock/overlays.d.ts +10 -0
  66. package/dist/canvas-backend/renderResourceBlock/overlays.d.ts.map +1 -0
  67. package/dist/canvas-backend/renderResourceBlock/overlays.js +107 -0
  68. package/dist/canvas-backend/renderResourceBlock/overlays.js.map +1 -0
  69. package/dist/canvas-backend/renderResourceBlock/table.d.ts +3 -0
  70. package/dist/canvas-backend/renderResourceBlock/table.d.ts.map +1 -0
  71. package/dist/canvas-backend/renderResourceBlock/table.js +143 -0
  72. package/dist/canvas-backend/renderResourceBlock/table.js.map +1 -0
  73. package/dist/canvas-backend/renderResourceBlock/text.d.ts +11 -0
  74. package/dist/canvas-backend/renderResourceBlock/text.d.ts.map +1 -0
  75. package/dist/canvas-backend/renderResourceBlock/text.js +141 -0
  76. package/dist/canvas-backend/renderResourceBlock/text.js.map +1 -0
  77. package/dist/canvas-backend/renderResourceBlock.d.ts +4 -81
  78. package/dist/canvas-backend/renderResourceBlock.d.ts.map +1 -1
  79. package/dist/canvas-backend/renderResourceBlock.js +3 -777
  80. package/dist/canvas-backend/renderResourceBlock.js.map +1 -1
  81. package/dist/canvas-backend/verticalText/alternates.d.ts +47 -0
  82. package/dist/canvas-backend/verticalText/alternates.d.ts.map +1 -0
  83. package/dist/canvas-backend/verticalText/alternates.js +240 -0
  84. package/dist/canvas-backend/verticalText/alternates.js.map +1 -0
  85. package/dist/canvas-backend/verticalText/painter.d.ts +58 -0
  86. package/dist/canvas-backend/verticalText/painter.d.ts.map +1 -0
  87. package/dist/canvas-backend/verticalText/painter.js +329 -0
  88. package/dist/canvas-backend/verticalText/painter.js.map +1 -0
  89. package/dist/canvas-backend/verticalText.d.ts +4 -101
  90. package/dist/canvas-backend/verticalText.d.ts.map +1 -1
  91. package/dist/canvas-backend/verticalText.js +2 -562
  92. package/dist/canvas-backend/verticalText.js.map +1 -1
  93. package/dist/checks/contrast/colours.d.ts +64 -0
  94. package/dist/checks/contrast/colours.d.ts.map +1 -0
  95. package/dist/checks/contrast/colours.js +101 -0
  96. package/dist/checks/contrast/colours.js.map +1 -0
  97. package/dist/checks/contrast/document.d.ts +17 -0
  98. package/dist/checks/contrast/document.d.ts.map +1 -0
  99. package/dist/checks/contrast/document.js +132 -0
  100. package/dist/checks/contrast/document.js.map +1 -0
  101. package/dist/checks/contrast/pairs.d.ts +10 -0
  102. package/dist/checks/contrast/pairs.d.ts.map +1 -0
  103. package/dist/checks/contrast/pairs.js +462 -0
  104. package/dist/checks/contrast/pairs.js.map +1 -0
  105. package/dist/checks/contrast/types.d.ts +114 -0
  106. package/dist/checks/contrast/types.d.ts.map +1 -0
  107. package/dist/checks/contrast/types.js +2 -0
  108. package/dist/checks/contrast/types.js.map +1 -0
  109. package/dist/checks/contrast.d.ts +5 -170
  110. package/dist/checks/contrast.d.ts.map +1 -1
  111. package/dist/checks/contrast.js +3 -686
  112. package/dist/checks/contrast.js.map +1 -1
  113. package/dist/comics/layoutPage/letterPanels.d.ts +38 -0
  114. package/dist/comics/layoutPage/letterPanels.d.ts.map +1 -0
  115. package/dist/comics/layoutPage/letterPanels.js +146 -0
  116. package/dist/comics/layoutPage/letterPanels.js.map +1 -0
  117. package/dist/comics/layoutPage/letteringStyle.d.ts +31 -0
  118. package/dist/comics/layoutPage/letteringStyle.d.ts.map +1 -0
  119. package/dist/comics/layoutPage/letteringStyle.js +88 -0
  120. package/dist/comics/layoutPage/letteringStyle.js.map +1 -0
  121. package/dist/comics/layoutPage/records.d.ts +25 -0
  122. package/dist/comics/layoutPage/records.d.ts.map +1 -0
  123. package/dist/comics/layoutPage/records.js +36 -0
  124. package/dist/comics/layoutPage/records.js.map +1 -0
  125. package/dist/comics/layoutPage/settings.d.ts +64 -0
  126. package/dist/comics/layoutPage/settings.d.ts.map +1 -0
  127. package/dist/comics/layoutPage/settings.js +168 -0
  128. package/dist/comics/layoutPage/settings.js.map +1 -0
  129. package/dist/comics/layoutPage/zones.d.ts +79 -0
  130. package/dist/comics/layoutPage/zones.d.ts.map +1 -0
  131. package/dist/comics/layoutPage/zones.js +179 -0
  132. package/dist/comics/layoutPage/zones.js.map +1 -0
  133. package/dist/comics/layoutPage.d.ts +8 -113
  134. package/dist/comics/layoutPage.d.ts.map +1 -1
  135. package/dist/comics/layoutPage.js +12 -603
  136. package/dist/comics/layoutPage.js.map +1 -1
  137. package/dist/comics/lettering/letter/variants.d.ts +28 -0
  138. package/dist/comics/lettering/letter/variants.d.ts.map +1 -0
  139. package/dist/comics/lettering/letter/variants.js +269 -0
  140. package/dist/comics/lettering/letter/variants.js.map +1 -0
  141. package/dist/comics/lettering/letter.d.ts +32 -1
  142. package/dist/comics/lettering/letter.d.ts.map +1 -1
  143. package/dist/comics/lettering/letter.js +8 -270
  144. package/dist/comics/lettering/letter.js.map +1 -1
  145. package/dist/comics/lettering/shape-text/breaks.d.ts +53 -0
  146. package/dist/comics/lettering/shape-text/breaks.d.ts.map +1 -0
  147. package/dist/comics/lettering/shape-text/breaks.js +217 -0
  148. package/dist/comics/lettering/shape-text/breaks.js.map +1 -0
  149. package/dist/comics/lettering/shape-text/measure.d.ts +20 -0
  150. package/dist/comics/lettering/shape-text/measure.d.ts.map +1 -0
  151. package/dist/comics/lettering/shape-text/measure.js +160 -0
  152. package/dist/comics/lettering/shape-text/measure.js.map +1 -0
  153. package/dist/comics/lettering/shape-text/ruby.d.ts +28 -0
  154. package/dist/comics/lettering/shape-text/ruby.d.ts.map +1 -0
  155. package/dist/comics/lettering/shape-text/ruby.js +173 -0
  156. package/dist/comics/lettering/shape-text/ruby.js.map +1 -0
  157. package/dist/comics/lettering/shape-text.d.ts +7 -6
  158. package/dist/comics/lettering/shape-text.d.ts.map +1 -1
  159. package/dist/comics/lettering/shape-text.js +10 -536
  160. package/dist/comics/lettering/shape-text.js.map +1 -1
  161. package/dist/composed/overlap/ink.d.ts +48 -0
  162. package/dist/composed/overlap/ink.d.ts.map +1 -0
  163. package/dist/composed/overlap/ink.js +180 -0
  164. package/dist/composed/overlap/ink.js.map +1 -0
  165. package/dist/composed/overlap/moves.d.ts +97 -0
  166. package/dist/composed/overlap/moves.d.ts.map +1 -0
  167. package/dist/composed/overlap/moves.js +191 -0
  168. package/dist/composed/overlap/moves.js.map +1 -0
  169. package/dist/composed/overlap.d.ts +2 -2
  170. package/dist/composed/overlap.d.ts.map +1 -1
  171. package/dist/composed/overlap.js +3 -367
  172. package/dist/composed/overlap.js.map +1 -1
  173. package/dist/composed/sourceMap/chains.d.ts +27 -0
  174. package/dist/composed/sourceMap/chains.d.ts.map +1 -0
  175. package/dist/composed/sourceMap/chains.js +176 -0
  176. package/dist/composed/sourceMap/chains.js.map +1 -0
  177. package/dist/composed/sourceMap/frames.d.ts +19 -0
  178. package/dist/composed/sourceMap/frames.d.ts.map +1 -0
  179. package/dist/composed/sourceMap/frames.js +143 -0
  180. package/dist/composed/sourceMap/frames.js.map +1 -0
  181. package/dist/composed/sourceMap/text.d.ts +52 -0
  182. package/dist/composed/sourceMap/text.d.ts.map +1 -0
  183. package/dist/composed/sourceMap/text.js +200 -0
  184. package/dist/composed/sourceMap/text.js.map +1 -0
  185. package/dist/composed/sourceMap.d.ts +22 -1
  186. package/dist/composed/sourceMap.d.ts.map +1 -1
  187. package/dist/composed/sourceMap.js +7 -511
  188. package/dist/composed/sourceMap.js.map +1 -1
  189. package/dist/composed/types/frames.d.ts +290 -0
  190. package/dist/composed/types/frames.d.ts.map +1 -0
  191. package/dist/composed/types/frames.js +2 -0
  192. package/dist/composed/types/frames.js.map +1 -0
  193. package/dist/composed/types/resolved.d.ts +207 -0
  194. package/dist/composed/types/resolved.d.ts.map +1 -0
  195. package/dist/composed/types/resolved.js +2 -0
  196. package/dist/composed/types/resolved.js.map +1 -0
  197. package/dist/composed/types/templates.d.ts +152 -0
  198. package/dist/composed/types/templates.d.ts.map +1 -0
  199. package/dist/composed/types/templates.js +2 -0
  200. package/dist/composed/types/templates.js.map +1 -0
  201. package/dist/composed/types.d.ts +3 -641
  202. package/dist/composed/types.d.ts.map +1 -1
  203. package/dist/composed/types.js +8 -0
  204. package/dist/composed/types.js.map +1 -1
  205. package/dist/defaults/boxes/calloutStyles/inherit.d.ts +15 -0
  206. package/dist/defaults/boxes/calloutStyles/inherit.d.ts.map +1 -0
  207. package/dist/defaults/boxes/calloutStyles/inherit.js +64 -0
  208. package/dist/defaults/boxes/calloutStyles/inherit.js.map +1 -0
  209. package/dist/defaults/boxes/calloutStyles/resolve.d.ts +7 -0
  210. package/dist/defaults/boxes/calloutStyles/resolve.d.ts.map +1 -0
  211. package/dist/defaults/boxes/calloutStyles/resolve.js +223 -0
  212. package/dist/defaults/boxes/calloutStyles/resolve.js.map +1 -0
  213. package/dist/defaults/boxes/calloutStyles/statics.d.ts +136 -0
  214. package/dist/defaults/boxes/calloutStyles/statics.d.ts.map +1 -0
  215. package/dist/defaults/boxes/calloutStyles/statics.js +140 -0
  216. package/dist/defaults/boxes/calloutStyles/statics.js.map +1 -0
  217. package/dist/defaults/boxes/calloutStyles/strip.d.ts +10 -0
  218. package/dist/defaults/boxes/calloutStyles/strip.d.ts.map +1 -0
  219. package/dist/defaults/boxes/calloutStyles/strip.js +336 -0
  220. package/dist/defaults/boxes/calloutStyles/strip.js.map +1 -0
  221. package/dist/defaults/boxes/calloutStyles.d.ts +4 -148
  222. package/dist/defaults/boxes/calloutStyles.d.ts.map +1 -1
  223. package/dist/defaults/boxes/calloutStyles.js +4 -749
  224. package/dist/defaults/boxes/calloutStyles.js.map +1 -1
  225. package/dist/defaults/structure/headerFooter/defaults.d.ts +34 -0
  226. package/dist/defaults/structure/headerFooter/defaults.d.ts.map +1 -0
  227. package/dist/defaults/structure/headerFooter/defaults.js +162 -0
  228. package/dist/defaults/structure/headerFooter/defaults.js.map +1 -0
  229. package/dist/defaults/structure/headerFooter/legacy.d.ts +8 -0
  230. package/dist/defaults/structure/headerFooter/legacy.d.ts.map +1 -0
  231. package/dist/defaults/structure/headerFooter/legacy.js +124 -0
  232. package/dist/defaults/structure/headerFooter/legacy.js.map +1 -0
  233. package/dist/defaults/structure/headerFooter/resolve.d.ts +29 -0
  234. package/dist/defaults/structure/headerFooter/resolve.d.ts.map +1 -0
  235. package/dist/defaults/structure/headerFooter/resolve.js +231 -0
  236. package/dist/defaults/structure/headerFooter/resolve.js.map +1 -0
  237. package/dist/defaults/structure/headerFooter.d.ts +6 -58
  238. package/dist/defaults/structure/headerFooter.d.ts.map +1 -1
  239. package/dist/defaults/structure/headerFooter.js +5 -510
  240. package/dist/defaults/structure/headerFooter.js.map +1 -1
  241. package/dist/defaults/structure/headings/defaults.d.ts +46 -0
  242. package/dist/defaults/structure/headings/defaults.d.ts.map +1 -0
  243. package/dist/defaults/structure/headings/defaults.js +100 -0
  244. package/dist/defaults/structure/headings/defaults.js.map +1 -0
  245. package/dist/defaults/structure/headings/resolve.d.ts +17 -0
  246. package/dist/defaults/structure/headings/resolve.d.ts.map +1 -0
  247. package/dist/defaults/structure/headings/resolve.js +179 -0
  248. package/dist/defaults/structure/headings/resolve.js.map +1 -0
  249. package/dist/defaults/structure/headings/strip.d.ts +9 -0
  250. package/dist/defaults/structure/headings/strip.d.ts.map +1 -0
  251. package/dist/defaults/structure/headings/strip.js +323 -0
  252. package/dist/defaults/structure/headings/strip.js.map +1 -0
  253. package/dist/defaults/structure/headings.d.ts +3 -62
  254. package/dist/defaults/structure/headings.d.ts.map +1 -1
  255. package/dist/defaults/structure/headings.js +3 -594
  256. package/dist/defaults/structure/headings.js.map +1 -1
  257. package/dist/defaults/text/bodyText/arabic.d.ts +35 -0
  258. package/dist/defaults/text/bodyText/arabic.d.ts.map +1 -0
  259. package/dist/defaults/text/bodyText/arabic.js +85 -0
  260. package/dist/defaults/text/bodyText/arabic.js.map +1 -0
  261. package/dist/defaults/text/bodyText/defaults.d.ts +31 -0
  262. package/dist/defaults/text/bodyText/defaults.d.ts.map +1 -0
  263. package/dist/defaults/text/bodyText/defaults.js +128 -0
  264. package/dist/defaults/text/bodyText/defaults.js.map +1 -0
  265. package/dist/defaults/text/bodyText/resolve.d.ts +12 -0
  266. package/dist/defaults/text/bodyText/resolve.d.ts.map +1 -0
  267. package/dist/defaults/text/bodyText/resolve.js +171 -0
  268. package/dist/defaults/text/bodyText/resolve.js.map +1 -0
  269. package/dist/defaults/text/bodyText/strip.d.ts +12 -0
  270. package/dist/defaults/text/bodyText/strip.d.ts.map +1 -0
  271. package/dist/defaults/text/bodyText/strip.js +305 -0
  272. package/dist/defaults/text/bodyText/strip.js.map +1 -0
  273. package/dist/defaults/text/bodyText.d.ts +4 -70
  274. package/dist/defaults/text/bodyText.d.ts.map +1 -1
  275. package/dist/defaults/text/bodyText.js +4 -673
  276. package/dist/defaults/text/bodyText.js.map +1 -1
  277. package/dist/design/richText/ellipsis.d.ts +26 -0
  278. package/dist/design/richText/ellipsis.d.ts.map +1 -0
  279. package/dist/design/richText/ellipsis.js +173 -0
  280. package/dist/design/richText/ellipsis.js.map +1 -0
  281. package/dist/design/richText/measure.d.ts +51 -0
  282. package/dist/design/richText/measure.d.ts.map +1 -0
  283. package/dist/design/richText/measure.js +176 -0
  284. package/dist/design/richText/measure.js.map +1 -0
  285. package/dist/design/richText/parse.d.ts +120 -0
  286. package/dist/design/richText/parse.d.ts.map +1 -0
  287. package/dist/design/richText/parse.js +190 -0
  288. package/dist/design/richText/parse.js.map +1 -0
  289. package/dist/design/richText/wrap.d.ts +13 -0
  290. package/dist/design/richText/wrap.d.ts.map +1 -0
  291. package/dist/design/richText/wrap.js +176 -0
  292. package/dist/design/richText/wrap.js.map +1 -0
  293. package/dist/design/richText.d.ts +6 -199
  294. package/dist/design/richText.d.ts.map +1 -1
  295. package/dist/design/richText.js +4 -698
  296. package/dist/design/richText.js.map +1 -1
  297. package/dist/exercises/grids/arithmetic.d.ts +3 -0
  298. package/dist/exercises/grids/arithmetic.d.ts.map +1 -0
  299. package/dist/exercises/grids/arithmetic.js +214 -0
  300. package/dist/exercises/grids/arithmetic.js.map +1 -0
  301. package/dist/exercises/grids/common.d.ts +8 -0
  302. package/dist/exercises/grids/common.d.ts.map +1 -0
  303. package/dist/exercises/grids/common.js +9 -0
  304. package/dist/exercises/grids/common.js.map +1 -0
  305. package/dist/exercises/grids/crossword.d.ts +3 -0
  306. package/dist/exercises/grids/crossword.d.ts.map +1 -0
  307. package/dist/exercises/grids/crossword.js +191 -0
  308. package/dist/exercises/grids/crossword.js.map +1 -0
  309. package/dist/exercises/grids/match.d.ts +3 -0
  310. package/dist/exercises/grids/match.d.ts.map +1 -0
  311. package/dist/exercises/grids/match.js +58 -0
  312. package/dist/exercises/grids/match.js.map +1 -0
  313. package/dist/exercises/grids/wordSearch.d.ts +5 -0
  314. package/dist/exercises/grids/wordSearch.d.ts.map +1 -0
  315. package/dist/exercises/grids/wordSearch.js +122 -0
  316. package/dist/exercises/grids/wordSearch.js.map +1 -0
  317. package/dist/exercises/grids.d.ts +2 -2
  318. package/dist/exercises/grids.d.ts.map +1 -1
  319. package/dist/exercises/grids.js +4 -575
  320. package/dist/exercises/grids.js.map +1 -1
  321. package/dist/knuthPlass/breakpoints/adjust.d.ts +22 -0
  322. package/dist/knuthPlass/breakpoints/adjust.d.ts.map +1 -0
  323. package/dist/knuthPlass/breakpoints/adjust.js +39 -0
  324. package/dist/knuthPlass/breakpoints/adjust.js.map +1 -0
  325. package/dist/knuthPlass/breakpoints/search.d.ts +10 -0
  326. package/dist/knuthPlass/breakpoints/search.d.ts.map +1 -0
  327. package/dist/knuthPlass/breakpoints/search.js +439 -0
  328. package/dist/knuthPlass/breakpoints/search.js.map +1 -0
  329. package/dist/knuthPlass/breakpoints.d.ts +2 -21
  330. package/dist/knuthPlass/breakpoints.d.ts.map +1 -1
  331. package/dist/knuthPlass/breakpoints.js +2 -472
  332. package/dist/knuthPlass/breakpoints.js.map +1 -1
  333. package/dist/marks/cjkMarks/geometry.d.ts +58 -0
  334. package/dist/marks/cjkMarks/geometry.d.ts.map +1 -0
  335. package/dist/marks/cjkMarks/geometry.js +131 -0
  336. package/dist/marks/cjkMarks/geometry.js.map +1 -0
  337. package/dist/marks/cjkMarks/lineMarks.d.ts +7 -0
  338. package/dist/marks/cjkMarks/lineMarks.d.ts.map +1 -0
  339. package/dist/marks/cjkMarks/lineMarks.js +183 -0
  340. package/dist/marks/cjkMarks/lineMarks.js.map +1 -0
  341. package/dist/marks/cjkMarks/reach.d.ts +28 -0
  342. package/dist/marks/cjkMarks/reach.d.ts.map +1 -0
  343. package/dist/marks/cjkMarks/reach.js +130 -0
  344. package/dist/marks/cjkMarks/reach.js.map +1 -0
  345. package/dist/marks/cjkMarks/resources.d.ts +31 -0
  346. package/dist/marks/cjkMarks/resources.d.ts.map +1 -0
  347. package/dist/marks/cjkMarks/resources.js +46 -0
  348. package/dist/marks/cjkMarks/resources.js.map +1 -0
  349. package/dist/marks/cjkMarks.d.ts +4 -27
  350. package/dist/marks/cjkMarks.d.ts.map +1 -1
  351. package/dist/marks/cjkMarks.js +6 -479
  352. package/dist/marks/cjkMarks.js.map +1 -1
  353. package/dist/measure/canvas/ink.d.ts +67 -0
  354. package/dist/measure/canvas/ink.d.ts.map +1 -0
  355. package/dist/measure/canvas/ink.js +215 -0
  356. package/dist/measure/canvas/ink.js.map +1 -0
  357. package/dist/measure/canvas/state.d.ts +91 -0
  358. package/dist/measure/canvas/state.d.ts.map +1 -0
  359. package/dist/measure/canvas/state.js +306 -0
  360. package/dist/measure/canvas/state.js.map +1 -0
  361. package/dist/measure/canvas/widths.d.ts +27 -0
  362. package/dist/measure/canvas/widths.d.ts.map +1 -0
  363. package/dist/measure/canvas/widths.js +137 -0
  364. package/dist/measure/canvas/widths.js.map +1 -0
  365. package/dist/measure/canvas.d.ts +4 -154
  366. package/dist/measure/canvas.d.ts.map +1 -1
  367. package/dist/measure/canvas.js +4 -646
  368. package/dist/measure/canvas.js.map +1 -1
  369. package/dist/measure/cjk/cjkPunctuation/box.d.ts +71 -0
  370. package/dist/measure/cjk/cjkPunctuation/box.d.ts.map +1 -0
  371. package/dist/measure/cjk/cjkPunctuation/box.js +114 -0
  372. package/dist/measure/cjk/cjkPunctuation/box.js.map +1 -0
  373. package/dist/measure/cjk/cjkPunctuation/composition.d.ts +128 -0
  374. package/dist/measure/cjk/cjkPunctuation/composition.d.ts.map +1 -0
  375. package/dist/measure/cjk/cjkPunctuation/composition.js +157 -0
  376. package/dist/measure/cjk/cjkPunctuation/composition.js.map +1 -0
  377. package/dist/measure/cjk/cjkPunctuation/lineEdges.d.ts +63 -0
  378. package/dist/measure/cjk/cjkPunctuation/lineEdges.d.ts.map +1 -0
  379. package/dist/measure/cjk/cjkPunctuation/lineEdges.js +183 -0
  380. package/dist/measure/cjk/cjkPunctuation/lineEdges.js.map +1 -0
  381. package/dist/measure/cjk/cjkPunctuation.d.ts +8 -247
  382. package/dist/measure/cjk/cjkPunctuation.d.ts.map +1 -1
  383. package/dist/measure/cjk/cjkPunctuation.js +6 -447
  384. package/dist/measure/cjk/cjkPunctuation.js.map +1 -1
  385. package/dist/measure/plain/overwide.d.ts +70 -0
  386. package/dist/measure/plain/overwide.d.ts.map +1 -0
  387. package/dist/measure/plain/overwide.js +150 -0
  388. package/dist/measure/plain/overwide.js.map +1 -0
  389. package/dist/measure/plain/segments.d.ts +53 -0
  390. package/dist/measure/plain/segments.d.ts.map +1 -0
  391. package/dist/measure/plain/segments.js +153 -0
  392. package/dist/measure/plain/segments.js.map +1 -0
  393. package/dist/measure/plain.d.ts +2 -15
  394. package/dist/measure/plain.d.ts.map +1 -1
  395. package/dist/measure/plain.js +12 -300
  396. package/dist/measure/plain.js.map +1 -1
  397. package/dist/migrate/pageDesign/pictures.d.ts +16 -0
  398. package/dist/migrate/pageDesign/pictures.d.ts.map +1 -0
  399. package/dist/migrate/pageDesign/pictures.js +101 -0
  400. package/dist/migrate/pageDesign/pictures.js.map +1 -0
  401. package/dist/migrate/pageDesign/text.d.ts +48 -0
  402. package/dist/migrate/pageDesign/text.d.ts.map +1 -0
  403. package/dist/migrate/pageDesign/text.js +196 -0
  404. package/dist/migrate/pageDesign/text.js.map +1 -0
  405. package/dist/migrate/pageDesign/types.d.ts +137 -0
  406. package/dist/migrate/pageDesign/types.d.ts.map +1 -0
  407. package/dist/migrate/pageDesign/types.js +2 -0
  408. package/dist/migrate/pageDesign/types.js.map +1 -0
  409. package/dist/migrate/pageDesign.d.ts +4 -154
  410. package/dist/migrate/pageDesign.d.ts.map +1 -1
  411. package/dist/migrate/pageDesign.js +4 -294
  412. package/dist/migrate/pageDesign.js.map +1 -1
  413. package/dist/numerals/numbering/counters.d.ts +49 -0
  414. package/dist/numerals/numbering/counters.d.ts.map +1 -0
  415. package/dist/numerals/numbering/counters.js +311 -0
  416. package/dist/numerals/numbering/counters.js.map +1 -0
  417. package/dist/numerals/numbering/formats.d.ts +30 -0
  418. package/dist/numerals/numbering/formats.d.ts.map +1 -0
  419. package/dist/numerals/numbering/formats.js +116 -0
  420. package/dist/numerals/numbering/formats.js.map +1 -0
  421. package/dist/numerals/numbering/headings.d.ts +40 -0
  422. package/dist/numerals/numbering/headings.d.ts.map +1 -0
  423. package/dist/numerals/numbering/headings.js +64 -0
  424. package/dist/numerals/numbering/headings.js.map +1 -0
  425. package/dist/numerals/numbering/pageLabels.d.ts +43 -0
  426. package/dist/numerals/numbering/pageLabels.d.ts.map +1 -0
  427. package/dist/numerals/numbering/pageLabels.js +75 -0
  428. package/dist/numerals/numbering/pageLabels.js.map +1 -0
  429. package/dist/numerals/numbering/styles.d.ts +52 -0
  430. package/dist/numerals/numbering/styles.d.ts.map +1 -0
  431. package/dist/numerals/numbering/styles.js +43 -0
  432. package/dist/numerals/numbering/styles.js.map +1 -0
  433. package/dist/numerals/numbering.d.ts +9 -201
  434. package/dist/numerals/numbering.d.ts.map +1 -1
  435. package/dist/numerals/numbering.js +5 -595
  436. package/dist/numerals/numbering.js.map +1 -1
  437. package/dist/parse/annotations/apply.d.ts +32 -0
  438. package/dist/parse/annotations/apply.d.ts.map +1 -0
  439. package/dist/parse/annotations/apply.js +293 -0
  440. package/dist/parse/annotations/apply.js.map +1 -0
  441. package/dist/parse/annotations/scan.d.ts +55 -0
  442. package/dist/parse/annotations/scan.d.ts.map +1 -0
  443. package/dist/parse/annotations/scan.js +232 -0
  444. package/dist/parse/annotations/scan.js.map +1 -0
  445. package/dist/parse/annotations/source.d.ts +31 -0
  446. package/dist/parse/annotations/source.d.ts.map +1 -0
  447. package/dist/parse/annotations/source.js +128 -0
  448. package/dist/parse/annotations/source.js.map +1 -0
  449. package/dist/parse/annotations.d.ts +5 -86
  450. package/dist/parse/annotations.d.ts.map +1 -1
  451. package/dist/parse/annotations.js +3 -648
  452. package/dist/parse/annotations.js.map +1 -1
  453. package/dist/pipeline/blocks/measureContentBlock/helpers.d.ts +31 -0
  454. package/dist/pipeline/blocks/measureContentBlock/helpers.d.ts.map +1 -0
  455. package/dist/pipeline/blocks/measureContentBlock/helpers.js +74 -0
  456. package/dist/pipeline/blocks/measureContentBlock/helpers.js.map +1 -0
  457. package/dist/pipeline/blocks/measureContentBlock/inlineSpans.d.ts +12 -0
  458. package/dist/pipeline/blocks/measureContentBlock/inlineSpans.d.ts.map +1 -0
  459. package/dist/pipeline/blocks/measureContentBlock/inlineSpans.js +107 -0
  460. package/dist/pipeline/blocks/measureContentBlock/inlineSpans.js.map +1 -0
  461. package/dist/pipeline/blocks/measureContentBlock/measureOptions.d.ts +68 -0
  462. package/dist/pipeline/blocks/measureContentBlock/measureOptions.d.ts.map +1 -0
  463. package/dist/pipeline/blocks/measureContentBlock/measureOptions.js +90 -0
  464. package/dist/pipeline/blocks/measureContentBlock/measureOptions.js.map +1 -0
  465. package/dist/pipeline/blocks/measureContentBlock/types.d.ts +165 -0
  466. package/dist/pipeline/blocks/measureContentBlock/types.d.ts.map +1 -0
  467. package/dist/pipeline/blocks/measureContentBlock/types.js +2 -0
  468. package/dist/pipeline/blocks/measureContentBlock/types.js.map +1 -0
  469. package/dist/pipeline/blocks/measureContentBlock.d.ts +8 -172
  470. package/dist/pipeline/blocks/measureContentBlock.d.ts.map +1 -1
  471. package/dist/pipeline/blocks/measureContentBlock.js +16 -257
  472. package/dist/pipeline/blocks/measureContentBlock.js.map +1 -1
  473. package/dist/pipeline/blocks/placement/bands.d.ts +61 -0
  474. package/dist/pipeline/blocks/placement/bands.d.ts.map +1 -0
  475. package/dist/pipeline/blocks/placement/bands.js +188 -0
  476. package/dist/pipeline/blocks/placement/bands.js.map +1 -0
  477. package/dist/pipeline/blocks/placement.d.ts +2 -59
  478. package/dist/pipeline/blocks/placement.d.ts.map +1 -1
  479. package/dist/pipeline/blocks/placement.js +3 -184
  480. package/dist/pipeline/blocks/placement.js.map +1 -1
  481. package/dist/pipeline/build/pass/composed/comicText.d.ts +27 -0
  482. package/dist/pipeline/build/pass/composed/comicText.d.ts.map +1 -0
  483. package/dist/pipeline/build/pass/composed/comicText.js +89 -0
  484. package/dist/pipeline/build/pass/composed/comicText.js.map +1 -0
  485. package/dist/pipeline/build/pass/composed/jumps.d.ts +29 -0
  486. package/dist/pipeline/build/pass/composed/jumps.d.ts.map +1 -0
  487. package/dist/pipeline/build/pass/composed/jumps.js +91 -0
  488. package/dist/pipeline/build/pass/composed/jumps.js.map +1 -0
  489. package/dist/pipeline/build/pass/composed/placePage.d.ts +60 -0
  490. package/dist/pipeline/build/pass/composed/placePage.d.ts.map +1 -0
  491. package/dist/pipeline/build/pass/composed/placePage.js +368 -0
  492. package/dist/pipeline/build/pass/composed/placePage.js.map +1 -0
  493. package/dist/pipeline/build/pass/composed.d.ts +6 -7
  494. package/dist/pipeline/build/pass/composed.d.ts.map +1 -1
  495. package/dist/pipeline/build/pass/composed.js +20 -524
  496. package/dist/pipeline/build/pass/composed.js.map +1 -1
  497. package/dist/pipeline/build/pass/setup/contentSetup.d.ts +89 -0
  498. package/dist/pipeline/build/pass/setup/contentSetup.d.ts.map +1 -0
  499. package/dist/pipeline/build/pass/setup/contentSetup.js +314 -0
  500. package/dist/pipeline/build/pass/setup/contentSetup.js.map +1 -0
  501. package/dist/pipeline/build/pass/setup/pageSetup.d.ts +32 -0
  502. package/dist/pipeline/build/pass/setup/pageSetup.d.ts.map +1 -0
  503. package/dist/pipeline/build/pass/setup/pageSetup.js +147 -0
  504. package/dist/pipeline/build/pass/setup/pageSetup.js.map +1 -0
  505. package/dist/pipeline/build/pass/setup/passFinish.d.ts +95 -0
  506. package/dist/pipeline/build/pass/setup/passFinish.d.ts.map +1 -0
  507. package/dist/pipeline/build/pass/setup/passFinish.js +201 -0
  508. package/dist/pipeline/build/pass/setup/passFinish.js.map +1 -0
  509. package/dist/pipeline/build/pass/setupState.d.ts +8 -0
  510. package/dist/pipeline/build/pass/setupState.d.ts.map +1 -0
  511. package/dist/pipeline/build/pass/setupState.js +2 -0
  512. package/dist/pipeline/build/pass/setupState.js.map +1 -0
  513. package/dist/pipeline/build/pass.d.ts.map +1 -1
  514. package/dist/pipeline/build/pass.js +60 -654
  515. package/dist/pipeline/build/pass.js.map +1 -1
  516. package/dist/pipeline/callouts/calloutLayout/boxDecoration.d.ts +49 -0
  517. package/dist/pipeline/callouts/calloutLayout/boxDecoration.d.ts.map +1 -0
  518. package/dist/pipeline/callouts/calloutLayout/boxDecoration.js +110 -0
  519. package/dist/pipeline/callouts/calloutLayout/boxDecoration.js.map +1 -0
  520. package/dist/pipeline/callouts/calloutLayout/labelTab.d.ts +31 -0
  521. package/dist/pipeline/callouts/calloutLayout/labelTab.d.ts.map +1 -0
  522. package/dist/pipeline/callouts/calloutLayout/labelTab.js +202 -0
  523. package/dist/pipeline/callouts/calloutLayout/labelTab.js.map +1 -0
  524. package/dist/pipeline/callouts/calloutLayout/layoutCallout.d.ts.map +1 -1
  525. package/dist/pipeline/callouts/calloutLayout/layoutCallout.js +23 -355
  526. package/dist/pipeline/callouts/calloutLayout/layoutCallout.js.map +1 -1
  527. package/dist/pipeline/callouts/calloutLayout/layoutCalloutState.d.ts +14 -0
  528. package/dist/pipeline/callouts/calloutLayout/layoutCalloutState.d.ts.map +1 -0
  529. package/dist/pipeline/callouts/calloutLayout/layoutCalloutState.js +2 -0
  530. package/dist/pipeline/callouts/calloutLayout/layoutCalloutState.js.map +1 -0
  531. package/dist/pipeline/callouts/calloutLayout/markerColumn.d.ts +31 -0
  532. package/dist/pipeline/callouts/calloutLayout/markerColumn.d.ts.map +1 -0
  533. package/dist/pipeline/callouts/calloutLayout/markerColumn.js +75 -0
  534. package/dist/pipeline/callouts/calloutLayout/markerColumn.js.map +1 -0
  535. package/dist/pipeline/composedPages/composedLayout/composePage/run/fill.d.ts +68 -0
  536. package/dist/pipeline/composedPages/composedLayout/composePage/run/fill.d.ts.map +1 -0
  537. package/dist/pipeline/composedPages/composedLayout/composePage/run/fill.js +249 -0
  538. package/dist/pipeline/composedPages/composedLayout/composePage/run/fill.js.map +1 -0
  539. package/dist/pipeline/composedPages/composedLayout/composePage/run/measure.d.ts +50 -0
  540. package/dist/pipeline/composedPages/composedLayout/composePage/run/measure.d.ts.map +1 -0
  541. package/dist/pipeline/composedPages/composedLayout/composePage/run/measure.js +195 -0
  542. package/dist/pipeline/composedPages/composedLayout/composePage/run/measure.js.map +1 -0
  543. package/dist/pipeline/composedPages/composedLayout/composePage/run/placeGrid.d.ts +30 -0
  544. package/dist/pipeline/composedPages/composedLayout/composePage/run/placeGrid.d.ts.map +1 -0
  545. package/dist/pipeline/composedPages/composedLayout/composePage/run/placeGrid.js +174 -0
  546. package/dist/pipeline/composedPages/composedLayout/composePage/run/placeGrid.js.map +1 -0
  547. package/dist/pipeline/composedPages/composedLayout/composePage/run/placeGroup.d.ts +35 -0
  548. package/dist/pipeline/composedPages/composedLayout/composePage/run/placeGroup.d.ts.map +1 -0
  549. package/dist/pipeline/composedPages/composedLayout/composePage/run/placeGroup.js +158 -0
  550. package/dist/pipeline/composedPages/composedLayout/composePage/run/placeGroup.js.map +1 -0
  551. package/dist/pipeline/composedPages/composedLayout/composePage/run/placeModules.d.ts +37 -0
  552. package/dist/pipeline/composedPages/composedLayout/composePage/run/placeModules.d.ts.map +1 -0
  553. package/dist/pipeline/composedPages/composedLayout/composePage/run/placeModules.js +303 -0
  554. package/dist/pipeline/composedPages/composedLayout/composePage/run/placeModules.js.map +1 -0
  555. package/dist/pipeline/composedPages/composedLayout/composePage/run/state.d.ts +11 -0
  556. package/dist/pipeline/composedPages/composedLayout/composePage/run/state.d.ts.map +1 -0
  557. package/dist/pipeline/composedPages/composedLayout/composePage/run/state.js +3 -0
  558. package/dist/pipeline/composedPages/composedLayout/composePage/run/state.js.map +1 -0
  559. package/dist/pipeline/composedPages/composedLayout/composePage/run/types.d.ts +14 -0
  560. package/dist/pipeline/composedPages/composedLayout/composePage/run/types.d.ts.map +1 -0
  561. package/dist/pipeline/composedPages/composedLayout/composePage/run/types.js +2 -0
  562. package/dist/pipeline/composedPages/composedLayout/composePage/run/types.js.map +1 -0
  563. package/dist/pipeline/composedPages/composedLayout/composePage/run.d.ts +59 -0
  564. package/dist/pipeline/composedPages/composedLayout/composePage/run.d.ts.map +1 -0
  565. package/dist/pipeline/composedPages/composedLayout/composePage/run.js +171 -0
  566. package/dist/pipeline/composedPages/composedLayout/composePage/run.js.map +1 -0
  567. package/dist/pipeline/composedPages/composedLayout/composePage/state.d.ts +7 -0
  568. package/dist/pipeline/composedPages/composedLayout/composePage/state.d.ts.map +1 -0
  569. package/dist/pipeline/composedPages/composedLayout/composePage/state.js +2 -0
  570. package/dist/pipeline/composedPages/composedLayout/composePage/state.js.map +1 -0
  571. package/dist/pipeline/composedPages/composedLayout/composePage.d.ts.map +1 -1
  572. package/dist/pipeline/composedPages/composedLayout/composePage.js +24 -1165
  573. package/dist/pipeline/composedPages/composedLayout/composePage.js.map +1 -1
  574. package/dist/pipeline/contents/indexDirective/blocks.d.ts +9 -0
  575. package/dist/pipeline/contents/indexDirective/blocks.d.ts.map +1 -0
  576. package/dist/pipeline/contents/indexDirective/blocks.js +256 -0
  577. package/dist/pipeline/contents/indexDirective/blocks.js.map +1 -0
  578. package/dist/pipeline/contents/indexDirective/tree.d.ts +71 -0
  579. package/dist/pipeline/contents/indexDirective/tree.d.ts.map +1 -0
  580. package/dist/pipeline/contents/indexDirective/tree.js +224 -0
  581. package/dist/pipeline/contents/indexDirective/tree.js.map +1 -0
  582. package/dist/pipeline/contents/indexDirective.d.ts +2 -8
  583. package/dist/pipeline/contents/indexDirective.d.ts.map +1 -1
  584. package/dist/pipeline/contents/indexDirective.js +3 -472
  585. package/dist/pipeline/contents/indexDirective.js.map +1 -1
  586. package/dist/pipeline/pages/placeholders/chapterValues.d.ts +117 -0
  587. package/dist/pipeline/pages/placeholders/chapterValues.d.ts.map +1 -0
  588. package/dist/pipeline/pages/placeholders/chapterValues.js +236 -0
  589. package/dist/pipeline/pages/placeholders/chapterValues.js.map +1 -0
  590. package/dist/pipeline/pages/placeholders/lineText.d.ts +66 -0
  591. package/dist/pipeline/pages/placeholders/lineText.d.ts.map +1 -0
  592. package/dist/pipeline/pages/placeholders/lineText.js +173 -0
  593. package/dist/pipeline/pages/placeholders/lineText.js.map +1 -0
  594. package/dist/pipeline/pages/placeholders.d.ts +6 -179
  595. package/dist/pipeline/pages/placeholders.d.ts.map +1 -1
  596. package/dist/pipeline/pages/placeholders.js +4 -398
  597. package/dist/pipeline/pages/placeholders.js.map +1 -1
  598. package/dist/pipeline/references/citations/markers.d.ts +14 -0
  599. package/dist/pipeline/references/citations/markers.d.ts.map +1 -0
  600. package/dist/pipeline/references/citations/markers.js +106 -0
  601. package/dist/pipeline/references/citations/markers.js.map +1 -0
  602. package/dist/pipeline/references/citations/process.d.ts +56 -0
  603. package/dist/pipeline/references/citations/process.d.ts.map +1 -0
  604. package/dist/pipeline/references/citations/process.js +213 -0
  605. package/dist/pipeline/references/citations/process.js.map +1 -0
  606. package/dist/pipeline/references/citations/spans.d.ts +33 -0
  607. package/dist/pipeline/references/citations/spans.d.ts.map +1 -0
  608. package/dist/pipeline/references/citations/spans.js +127 -0
  609. package/dist/pipeline/references/citations/spans.js.map +1 -0
  610. package/dist/pipeline/references/citations.d.ts +4 -51
  611. package/dist/pipeline/references/citations.d.ts.map +1 -1
  612. package/dist/pipeline/references/citations.js +5 -438
  613. package/dist/pipeline/references/citations.js.map +1 -1
  614. package/dist/pipeline/resources/resourceLayout/resourceBlock/captionNotes.d.ts +63 -0
  615. package/dist/pipeline/resources/resourceLayout/resourceBlock/captionNotes.d.ts.map +1 -0
  616. package/dist/pipeline/resources/resourceLayout/resourceBlock/captionNotes.js +88 -0
  617. package/dist/pipeline/resources/resourceLayout/resourceBlock/captionNotes.js.map +1 -0
  618. package/dist/pipeline/resources/resourceLayout/resourceBlock/state.d.ts +9 -0
  619. package/dist/pipeline/resources/resourceLayout/resourceBlock/state.d.ts.map +1 -0
  620. package/dist/pipeline/resources/resourceLayout/resourceBlock/state.js +2 -0
  621. package/dist/pipeline/resources/resourceLayout/resourceBlock/state.js.map +1 -0
  622. package/dist/pipeline/resources/resourceLayout/resourceBlock/upright.d.ts +26 -0
  623. package/dist/pipeline/resources/resourceLayout/resourceBlock/upright.d.ts.map +1 -0
  624. package/dist/pipeline/resources/resourceLayout/resourceBlock/upright.js +90 -0
  625. package/dist/pipeline/resources/resourceLayout/resourceBlock/upright.js.map +1 -0
  626. package/dist/pipeline/resources/resourceLayout/resourceBlock.d.ts +1 -3
  627. package/dist/pipeline/resources/resourceLayout/resourceBlock.d.ts.map +1 -1
  628. package/dist/pipeline/resources/resourceLayout/resourceBlock.js +13 -159
  629. package/dist/pipeline/resources/resourceLayout/resourceBlock.js.map +1 -1
  630. package/dist/pipeline/sections/partPalette/colorKinds.d.ts +53 -0
  631. package/dist/pipeline/sections/partPalette/colorKinds.d.ts.map +1 -0
  632. package/dist/pipeline/sections/partPalette/colorKinds.js +181 -0
  633. package/dist/pipeline/sections/partPalette/colorKinds.js.map +1 -0
  634. package/dist/pipeline/sections/partPalette/flowColors.d.ts +16 -0
  635. package/dist/pipeline/sections/partPalette/flowColors.d.ts.map +1 -0
  636. package/dist/pipeline/sections/partPalette/flowColors.js +78 -0
  637. package/dist/pipeline/sections/partPalette/flowColors.js.map +1 -0
  638. package/dist/pipeline/sections/partPalette/recolor.d.ts +18 -0
  639. package/dist/pipeline/sections/partPalette/recolor.d.ts.map +1 -0
  640. package/dist/pipeline/sections/partPalette/recolor.js +188 -0
  641. package/dist/pipeline/sections/partPalette/recolor.js.map +1 -0
  642. package/dist/pipeline/sections/partPalette.d.ts +4 -49
  643. package/dist/pipeline/sections/partPalette.d.ts.map +1 -1
  644. package/dist/pipeline/sections/partPalette.js +3 -442
  645. package/dist/pipeline/sections/partPalette.js.map +1 -1
  646. package/dist/pipeline/text/lists/orderedRuns.d.ts +49 -0
  647. package/dist/pipeline/text/lists/orderedRuns.d.ts.map +1 -0
  648. package/dist/pipeline/text/lists/orderedRuns.js +256 -0
  649. package/dist/pipeline/text/lists/orderedRuns.js.map +1 -0
  650. package/dist/pipeline/text/lists.d.ts +16 -46
  651. package/dist/pipeline/text/lists.d.ts.map +1 -1
  652. package/dist/pipeline/text/lists.js +5 -255
  653. package/dist/pipeline/text/lists.js.map +1 -1
  654. package/dist/svg/fonts/inline.d.ts +30 -0
  655. package/dist/svg/fonts/inline.d.ts.map +1 -0
  656. package/dist/svg/fonts/inline.js +298 -0
  657. package/dist/svg/fonts/inline.js.map +1 -0
  658. package/dist/svg/fonts/scan.d.ts +27 -0
  659. package/dist/svg/fonts/scan.d.ts.map +1 -0
  660. package/dist/svg/fonts/scan.js +353 -0
  661. package/dist/svg/fonts/scan.js.map +1 -0
  662. package/dist/svg/fonts/types.d.ts +106 -0
  663. package/dist/svg/fonts/types.d.ts.map +1 -0
  664. package/dist/svg/fonts/types.js +4 -0
  665. package/dist/svg/fonts/types.js.map +1 -0
  666. package/dist/svg/fonts.d.ts +4 -150
  667. package/dist/svg/fonts.d.ts.map +1 -1
  668. package/dist/svg/fonts.js +3 -647
  669. package/dist/svg/fonts.js.map +1 -1
  670. package/dist/types/text/bodyText/config.d.ts +465 -0
  671. package/dist/types/text/bodyText/config.d.ts.map +1 -0
  672. package/dist/types/text/bodyText/config.js +2 -0
  673. package/dist/types/text/bodyText/config.js.map +1 -0
  674. package/dist/types/text/bodyText/options.d.ts +73 -0
  675. package/dist/types/text/bodyText/options.d.ts.map +1 -0
  676. package/dist/types/text/bodyText/options.js +2 -0
  677. package/dist/types/text/bodyText/options.js.map +1 -0
  678. package/dist/types/text/bodyText/resolved.d.ts +95 -0
  679. package/dist/types/text/bodyText/resolved.d.ts.map +1 -0
  680. package/dist/types/text/bodyText/resolved.js +2 -0
  681. package/dist/types/text/bodyText/resolved.js.map +1 -0
  682. package/dist/types/text/bodyText.d.ts +3 -623
  683. package/dist/types/text/bodyText.d.ts.map +1 -1
  684. package/dist/vdt/contentWarnings/comic.d.ts +95 -0
  685. package/dist/vdt/contentWarnings/comic.d.ts.map +1 -0
  686. package/dist/vdt/contentWarnings/comic.js +3 -0
  687. package/dist/vdt/contentWarnings/comic.js.map +1 -0
  688. package/dist/vdt/contentWarnings/composed.d.ts +126 -0
  689. package/dist/vdt/contentWarnings/composed.d.ts.map +1 -0
  690. package/dist/vdt/contentWarnings/composed.js +2 -0
  691. package/dist/vdt/contentWarnings/composed.js.map +1 -0
  692. package/dist/vdt/contentWarnings/layout.d.ts +247 -0
  693. package/dist/vdt/contentWarnings/layout.d.ts.map +1 -0
  694. package/dist/vdt/contentWarnings/layout.js +2 -0
  695. package/dist/vdt/contentWarnings/layout.js.map +1 -0
  696. package/dist/vdt/contentWarnings/markup.d.ts +211 -0
  697. package/dist/vdt/contentWarnings/markup.d.ts.map +1 -0
  698. package/dist/vdt/contentWarnings/markup.js +4 -0
  699. package/dist/vdt/contentWarnings/markup.js.map +1 -0
  700. package/dist/vdt/contentWarnings/source.d.ts +216 -0
  701. package/dist/vdt/contentWarnings/source.d.ts.map +1 -0
  702. package/dist/vdt/contentWarnings/source.js +4 -0
  703. package/dist/vdt/contentWarnings/source.js.map +1 -0
  704. package/dist/vdt/contentWarnings/text.d.ts +139 -0
  705. package/dist/vdt/contentWarnings/text.d.ts.map +1 -0
  706. package/dist/vdt/contentWarnings/text.js +4 -0
  707. package/dist/vdt/contentWarnings/text.js.map +1 -0
  708. package/dist/vdt/contentWarnings.d.ts +7 -1017
  709. package/dist/vdt/contentWarnings.d.ts.map +1 -1
  710. package/dist/vdt/pages/comic.d.ts +200 -0
  711. package/dist/vdt/pages/comic.d.ts.map +1 -0
  712. package/dist/vdt/pages/comic.js +2 -0
  713. package/dist/vdt/pages/comic.js.map +1 -0
  714. package/dist/vdt/pages/composed.d.ts +282 -0
  715. package/dist/vdt/pages/composed.d.ts.map +1 -0
  716. package/dist/vdt/pages/composed.js +2 -0
  717. package/dist/vdt/pages/composed.js.map +1 -0
  718. package/dist/vdt/pages.d.ts +6 -476
  719. package/dist/vdt/pages.d.ts.map +1 -1
  720. package/dist/word/docxRead/body.d.ts +17 -0
  721. package/dist/word/docxRead/body.d.ts.map +1 -0
  722. package/dist/word/docxRead/body.js +372 -0
  723. package/dist/word/docxRead/body.js.map +1 -0
  724. package/dist/word/docxRead/parts.d.ts +27 -0
  725. package/dist/word/docxRead/parts.d.ts.map +1 -0
  726. package/dist/word/docxRead/parts.js +160 -0
  727. package/dist/word/docxRead/parts.js.map +1 -0
  728. package/dist/word/docxRead.d.ts +1 -5
  729. package/dist/word/docxRead.d.ts.map +1 -1
  730. package/dist/word/docxRead.js +5 -526
  731. package/dist/word/docxRead.js.map +1 -1
  732. package/dist/word/inline/parse.d.ts +16 -0
  733. package/dist/word/inline/parse.d.ts.map +1 -0
  734. package/dist/word/inline/parse.js +367 -0
  735. package/dist/word/inline/parse.js.map +1 -0
  736. package/dist/word/inline/render.d.ts +44 -0
  737. package/dist/word/inline/render.d.ts.map +1 -0
  738. package/dist/word/inline/render.js +296 -0
  739. package/dist/word/inline/render.js.map +1 -0
  740. package/dist/word/inline.d.ts +4 -52
  741. package/dist/word/inline.d.ts.map +1 -1
  742. package/dist/word/inline.js +2 -657
  743. package/dist/word/inline.js.map +1 -1
  744. package/dist/word/toDocx/parse.d.ts +46 -0
  745. package/dist/word/toDocx/parse.d.ts.map +1 -0
  746. package/dist/word/toDocx/parse.js +313 -0
  747. package/dist/word/toDocx/parse.js.map +1 -0
  748. package/dist/word/toDocx/styles.d.ts +63 -0
  749. package/dist/word/toDocx/styles.d.ts.map +1 -0
  750. package/dist/word/toDocx/styles.js +239 -0
  751. package/dist/word/toDocx/styles.js.map +1 -0
  752. package/dist/word/toDocx/wordml.d.ts +24 -0
  753. package/dist/word/toDocx/wordml.d.ts.map +1 -0
  754. package/dist/word/toDocx/wordml.js +114 -0
  755. package/dist/word/toDocx/wordml.js.map +1 -0
  756. package/dist/word/toDocx.d.ts +3 -25
  757. package/dist/word/toDocx.d.ts.map +1 -1
  758. package/dist/word/toDocx.js +8 -661
  759. package/dist/word/toDocx.js.map +1 -1
  760. package/dist/word/toMarkdown/converter.d.ts +57 -0
  761. package/dist/word/toMarkdown/converter.d.ts.map +1 -0
  762. package/dist/word/toMarkdown/converter.js +600 -0
  763. package/dist/word/toMarkdown/converter.js.map +1 -0
  764. package/dist/word/toMarkdown/helpers.d.ts +98 -0
  765. package/dist/word/toMarkdown/helpers.d.ts.map +1 -0
  766. package/dist/word/toMarkdown/helpers.js +153 -0
  767. package/dist/word/toMarkdown/helpers.js.map +1 -0
  768. package/dist/word/toMarkdown.d.ts +4 -64
  769. package/dist/word/toMarkdown.d.ts.map +1 -1
  770. package/dist/word/toMarkdown.js +2 -749
  771. package/dist/word/toMarkdown.js.map +1 -1
  772. package/dist/writing/bidi/chars.d.ts +61 -0
  773. package/dist/writing/bidi/chars.d.ts.map +1 -0
  774. package/dist/writing/bidi/chars.js +145 -0
  775. package/dist/writing/bidi/chars.js.map +1 -0
  776. package/dist/writing/bidi/joining.d.ts +27 -0
  777. package/dist/writing/bidi/joining.d.ts.map +1 -0
  778. package/dist/writing/bidi/joining.js +70 -0
  779. package/dist/writing/bidi/joining.js.map +1 -0
  780. package/dist/writing/bidi/paragraph.d.ts +72 -0
  781. package/dist/writing/bidi/paragraph.d.ts.map +1 -0
  782. package/dist/writing/bidi/paragraph.js +119 -0
  783. package/dist/writing/bidi/paragraph.js.map +1 -0
  784. package/dist/writing/bidi/resolve.d.ts +14 -0
  785. package/dist/writing/bidi/resolve.d.ts.map +1 -0
  786. package/dist/writing/bidi/resolve.js +413 -0
  787. package/dist/writing/bidi/resolve.js.map +1 -0
  788. package/dist/writing/bidi.d.ts +8 -147
  789. package/dist/writing/bidi.d.ts.map +1 -1
  790. package/dist/writing/bidi.js +6 -733
  791. package/dist/writing/bidi.js.map +1 -1
  792. package/package.json +1 -1
@@ -1,23 +1,13 @@
1
- import { pageIsVertical, pageIsMirrored } from '../../../vdt.js';
2
- import { scaleContourAbout, shiftContour, contourBounds } from '../../../contour/index.js';
3
- import { frameContour } from '../../../composed/contour.js';
4
- import { dimensionToPx } from '../../../units.js';
5
- import { quarterTurnedRect, frameModeTurn, frameBounds } from '../../../composed/paint.js';
1
+ import { pageIsVertical } from '../../../vdt.js';
2
+ import { scaleContourAbout } from '../../../contour/index.js';
6
3
  import { withMeasureWritingMode } from '../../../measure/vertical.js';
7
- import { groupPlaceable, placeBox, unionRect, nextFrameOf, framePlaceable } from '../../../composed/geometry.js';
8
- import { layoutGroup, composedOrder } from '../../../composed/groups.js';
9
- import { reflowEvents } from '../../../composed/reflowLog.js';
10
- import { anchorTarget, repeatInstance } from '../../../composed/templates.js';
11
- import { continuesOffPage } from '../../../composed/continuation.js';
12
4
  import { frameElementId } from '../../../composed/ids.js';
13
- import { nestedChain } from '../../../composed/modules.js';
14
- import { frameLinePx, frameRuleBlocks } from '../../../composed/rules.js';
15
5
  import { growMembers, grownHeight } from '../../../composed/grow.js';
16
- import { frameCutRules, makeCalloutLayouter, CUT_START, partBreakCut, splitCalloutFragment, fragmentRange } from '../../callouts/frameLayout.js';
6
+ import { frameCutRules } from '../../callouts/frameLayout.js';
17
7
  import { keepChromeAt, withNamedLook } from './frameStyles.js';
18
- import { lengthPx, withPage, tagPageMark } from './pagePlan.js';
19
- import { sameRect, turnRectAbout, commitFrame, heldByFoot, mergeLog, motionsOf } from './placedFrames.js';
20
- import { MM_PER_IN, chainPrev, sameCut } from './state.js';
8
+ import { lengthPx, withPage } from './pagePlan.js';
9
+ import { MM_PER_IN, chainPrev } from './state.js';
10
+ import { createRun } from './composePage/run.js';
21
11
  /** Lay out every frame of the page once, with the reflow ladder's `fit`. */
22
12
  /** Most times a page is laid again for its growing boxes (#1117): a box's
23
13
  * members stand where its top puts them, so one more lay is enough
@@ -61,12 +51,13 @@ export function composePage(pageInput, template, fit, collapsed) {
61
51
  return c;
62
52
  }
63
53
  function composePageOnce(pageInput, template, fit, collapsed) {
54
+ const state = {};
64
55
  /** What the frames are placed in: the page, or, while a module's frames
65
56
  * are placed (#1062), the page with the module's box as its area. */
66
- let input = pageInput;
67
- const { pass, fence, dpi } = input;
57
+ state.input = pageInput;
58
+ const { pass, fence, dpi } = state.input;
68
59
  const fi = fence.fenceIndex;
69
- const cont = input.continuing;
60
+ const cont = state.input.continuing;
70
61
  const cutRules = frameCutRules(pass.resolved);
71
62
  /** A frame's id: `cp<fence>:<name>`; on a page added by continuation
72
63
  * (#859) `~<k>`, a frame that receives content named by the frame of
@@ -91,8 +82,8 @@ function composePageOnce(pageInput, template, fit, collapsed) {
91
82
  /** A page number a mark's `{page}` is laid out with (#917): a guess of
92
83
  * the right width, the build writing the true one once pages are
93
84
  * numbered (`VDTDesignTextBlock.pageMark`). */
94
- const toGuess = String(input.page.index + 2);
95
- const fromGuess = String(Math.max(1, input.page.index));
85
+ const toGuess = String(state.input.page.index + 2);
86
+ const fromGuess = String(Math.max(1, state.input.page.index));
96
87
  /** The named look (#1089) the `:::frame` fence of a frame's story names
97
88
  * (`look="<id>"`), when `frameLooks` has it: the story's, so every
98
89
  * frame of a chain and the frames it goes on in on later pages wear it. */
@@ -100,18 +91,18 @@ function composePageOnce(pageInput, template, fit, collapsed) {
100
91
  const namedLookOf = (frame) => {
101
92
  if (!frameLooks)
102
93
  return undefined;
103
- const id = input.stories.get(headOf(frame.name))?.plan.attrs.look?.trim();
94
+ const id = state.input.stories.get(headOf(frame.name))?.plan.attrs.look?.trim();
104
95
  return id ? frameLooks.find((l) => l.id === id) : undefined;
105
96
  };
106
97
  /** The look a frame's story names that `frameLooks` does not have
107
98
  * (#1095): the canvas marks the frame. */
108
99
  const unknownLookOf = (frame) => {
109
- const id = input.stories.get(headOf(frame.name))?.plan.attrs.look?.trim();
100
+ const id = state.input.stories.get(headOf(frame.name))?.plan.attrs.look?.trim();
110
101
  return id && !frameLooks?.some((l) => l.id === id) ? id : undefined;
111
102
  };
112
103
  /** The style a frame is laid out in: its box as drawn at any text scale. */
113
104
  const styleOf = (frame) => {
114
- const style = keepChromeAt(input.styleOf(withNamedLook(frame, namedLookOf(frame))), textScale(frame));
105
+ const style = keepChromeAt(state.input.styleOf(withNamedLook(frame, namedLookOf(frame))), textScale(frame));
115
106
  if (!fit.goOn.has(frame.name))
116
107
  return style;
117
108
  // A frame cut for another page (#859) ends with its mark: its own
@@ -132,19 +123,19 @@ function composePageOnce(pageInput, template, fit, collapsed) {
132
123
  /** A frame set in a writing mode other than the page's flow (#944): its
133
124
  * mode, else undefined. Its content is laid out in that mode, its lines
134
125
  * along the box's height and following each other across its width. */
135
- const pageMode = pageIsVertical(input.page) ? 'vertical-rl' : 'horizontal-tb';
126
+ const pageMode = pageIsVertical(state.input.page) ? 'vertical-rl' : 'horizontal-tb';
136
127
  const ownMode = (frame) => frame.writingMode !== undefined && frame.writingMode !== pageMode ? frame.writingMode : undefined;
137
128
  /** A vertical frame of a right-to-left page (#960): the page's flow is
138
129
  * painted mirrored, which would set its lines from left to right, so the
139
130
  * frame is laid out as on a left-to-right page and painted unmirrored
140
131
  * (`VDTFrame.unmirrorX`). The mirror's origin, else undefined. */
141
132
  const unmirroredAt = (frame) => {
142
- const flow = input.page.flow;
133
+ const flow = state.input.page.flow;
143
134
  return ownMode(frame) && flow?.writingMode === 'horizontal-tb' ? flow.mirror.originX : undefined;
144
135
  };
145
136
  /** Whether a frame's lines are set as on a mirrored page: those of the
146
137
  * page's own mode, not an unmirrored frame's. */
147
- const mirroredIn = (frame) => input.mirrored && unmirroredAt(frame) === undefined;
138
+ const mirroredIn = (frame) => state.input.mirrored && unmirroredAt(frame) === undefined;
148
139
  /** The widest a picture's upright frame may be in a frame whose lines run
149
140
  * down the page (#960, #971): the frame's extent across its lines, less
150
141
  * the box's padding. A vertical frame of a horizontal page is turned a
@@ -157,7 +148,7 @@ function composePageOnce(pageInput, template, fit, collapsed) {
157
148
  if ((frame.writingMode ?? pageMode) !== 'vertical-rl')
158
149
  return {};
159
150
  const pad = styleOf(frame).padding;
160
- const room = across - lengthPx(pad.top, dpi, input.emPx) - lengthPx(pad.bottom, dpi, input.emPx);
151
+ const room = across - lengthPx(pad.top, dpi, state.input.emPx) - lengthPx(pad.bottom, dpi, state.input.emPx);
161
152
  return { uprightMaxLength: Math.max(1, room) };
162
153
  };
163
154
  /** `fn` measured in the frame's own writing mode. */
@@ -170,1143 +161,11 @@ function composePageOnce(pageInput, template, fit, collapsed) {
170
161
  const unscale = (rs, s) => rs && s !== 1
171
162
  ? rs.map((r) => ({ x: r.x / s, y: r.y / s, width: r.width / s, height: r.height / s, ...(r.contour ? { contour: scaleContourAbout(r.contour, 0, 0, 1 / s) } : {}) }))
172
163
  : rs;
173
- /** Place and fill every frame. `seed`: the boxes of the frames that push
174
- * text, from a first run, so a frame placed before one that pushes it
175
- * (the photo anchored to its box) still runs round it. */
176
- const run = (seed, seedShapes) => {
177
- const pushRects = new Map();
178
- /** The shapes of the frames that push with their pictures' contour (#883). */
179
- const pushShapes = new Map();
180
- /** Pictures of a contour push whose shape is not known (#883). */
181
- const notes = [];
182
- const states = new Map();
183
- const stateOf = (frame) => {
184
- const head = headOf(frame.name);
185
- const known = states.get(head);
186
- if (known)
187
- return known;
188
- const story = input.stories.get(head);
189
- const headFrame = byName.get(head);
190
- if (!story || !headFrame)
191
- return undefined;
192
- // Content from the page before (#859) goes on where it was cut, its
193
- // blocks numbered on from its pieces there.
194
- const came = cont?.receivers.get(head);
195
- const st = {
196
- story,
197
- L: makeCalloutLayouter(pass, story.startIdx, story.plan, styleOf(frame)),
198
- cut: came?.cut ?? CUT_START,
199
- pieces: came?.pieces ?? 0,
200
- headBlockId: came?.headBlockId ?? frameIdOf(head),
201
- headFrameId: came?.fromFrameId ?? frameIdOf(head),
202
- };
203
- states.set(head, st);
204
- return st;
205
- };
206
- const atEnd = (st) => st.cut.child >= st.L.end.child && st.cut.line === 0 && !st.cut.group;
207
- /** The frames' boxes as laid, and as the template declares them. */
208
- const rects = new Map();
209
- const declared = new Map();
210
- /** Groups' boxes once their step is laid. */
211
- const groupRects = new Map();
212
- const groupDeclared = new Map();
213
- const groupRect = (name, boxes, solved, refs) => {
214
- const done = solved.get(name);
215
- if (done)
216
- return done;
217
- const g = template.groups.find((gr) => gr.name === name);
218
- if (!g)
219
- return undefined;
220
- const own = groupPlaceable(g);
221
- if (own)
222
- return placeBox(own, template, input, refs, () => 0);
223
- return unionRect(g.frames.flatMap((m) => (boxes.has(m) ? [boxes.get(m)] : [])));
224
- };
225
- const refOf = (name) => rects.get(name) ?? groupRect(name, rects, groupRects, refOf);
226
- const declaredRefOf = (name) => declared.get(name) ?? groupRect(name, declared, groupDeclared, declaredRefOf);
227
- /** Pinned frames laid so far: a group's frames flow round them. */
228
- const pinned = [];
229
- /** How far a stack cut each frame below its least height (#911). */
230
- const boxShort = new Map();
231
- const frames = [];
232
- const vdtByName = new Map();
233
- const blocks = [];
234
- const overflowLog = [];
235
- const fitLog = [];
236
- const needs = new Map();
237
- /** What `fitBox` did to each frame (#861), last placement wins. */
238
- const fitted = new Map();
239
- const laid = new Set();
240
- const spills = new Map();
241
- const wantsOn = new Set();
242
- const clipped = new Set();
243
- const moduleRects = new Map();
244
- /** The foot a module cut at its group's foot is clipped to (#1062). */
245
- let clipFoot;
246
- /** A module a stretching row lays taller than it is (#1095): its
247
- * frames, its own foot (`at`) and the row's. */
248
- let stretchTo;
249
- const pushed = seed
250
- ? [...seed].map(([name, box]) => ({ name, box, ...(seedShapes?.get(name) ? { contour: seedShapes.get(name) } : {}) }))
251
- : [];
252
- /** The rectangles of the pushing frames placed so far that `rect`
253
- * meets, in the frame block's coordinates. */
254
- const exclusionsFor = (frame, rect, open) => {
255
- const out = [];
256
- // The frame's own shapes (a comic panel's slanted edges, #909).
257
- for (const ex of input.frameExclusions?.get(frame.name) ?? []) {
258
- out.push({ x: ex.x - rect.x, y: ex.y - rect.y, width: ex.width, height: ex.height, ...(ex.contour ? { contour: shiftContour(ex.contour, -rect.x, -rect.y) } : {}) });
259
- }
260
- const g = input.pushGapPx;
261
- for (const p of pushed) {
262
- if (p.name === frame.name)
263
- continue;
264
- // A contour (#883) pushes with its shape, its margin round it.
265
- const cb = p.contour ? contourBounds(p.contour) : undefined;
266
- const b = cb ?? p.box;
267
- const e = cb ? 0 : g;
268
- const below = open ? true : b.y < rect.y + rect.height;
269
- if (b.x - e >= rect.x + rect.width || b.x + b.width + e <= rect.x || !below || b.y + b.height + e <= rect.y)
270
- continue;
271
- out.push({
272
- x: b.x - e - rect.x, y: b.y - e - rect.y, width: b.width + 2 * e, height: b.height + 2 * e,
273
- ...(cb && p.contour ? { contour: shiftContour(p.contour, -rect.x, -rect.y) } : {}),
274
- });
275
- }
276
- return out.length > 0 ? out : undefined;
277
- };
278
- const prepare = (frame) => {
279
- const st = stateOf(frame);
280
- // Each frame of a chain sets the story in its own style: the cuts are
281
- // positions in the story's blocks, the same in any.
282
- if (st)
283
- st.L = makeCalloutLayouter(pass, st.story.startIdx, st.story.plan, styleOf(frame));
284
- // A frame continues its story only once the frame before it in the
285
- // chain was filled (a frame placed before it, through an anchor, starts
286
- // empty).
287
- const before = prev.get(frame.name);
288
- const reached = st !== undefined && (before === undefined || vdtByName.has(before));
289
- const holds = reached && !atEnd(st);
290
- const continuation = st !== undefined && st.pieces > 0;
291
- const blockId = st && st.pieces > 0 ? `${st.headBlockId}-cont-${st.pieces}` : frameIdOf(frame.name);
292
- // The first piece here of a story that came from another page.
293
- const came = cont?.receivers.get(headOf(frame.name));
294
- const fromMark = st && came && continuation && st.pieces === came.pieces ? fromMarkOf(frame) : undefined;
295
- return { frame, st, before, holds, continuation, blockId, ...(fromMark !== undefined ? { fromMark } : {}) };
296
- };
297
- /** The content's height at `width`, running round the pushing frames
298
- * below the top of `at` (the frame's box as first placed). A frame
299
- * whose text the ladder scales (#858) is laid out `1 / scale` as
300
- * wide and is `scale` as tall as that. */
301
- /** Where the frame's content ends for its height: at a part of the
302
- * contents that opens a page of its own (#996) when the frame can go
303
- * on, else at the end of the story. */
304
- const naturalEnd = (p) => {
305
- const nextName = nextFrameOf(p.frame);
306
- const nextFrame = nextName !== undefined ? byName.get(nextName) : undefined;
307
- const goes = (nextFrame !== undefined && !vdtByName.has(nextFrame.name)) || continuesOffPage(p.frame.overflow.continueIn);
308
- return (goes ? partBreakCut(pass, p.st.L, p.st.cut) : undefined) ?? p.st.L.end;
309
- };
310
- const naturalOf = (p, at) => {
311
- const memo = new Map();
312
- const s = textScale(p.frame);
313
- const pic = pictureScale(p.frame);
314
- if (ownMode(p.frame))
315
- return turnedNaturalOf(p, memo, s, pic);
316
- return (width) => {
317
- if (!p.holds)
318
- return 0;
319
- const key = Math.round(width * 1000);
320
- const known = memo.get(key);
321
- if (known !== undefined)
322
- return known;
323
- const exclusions = at ? unscale(exclusionsFor(p.frame, { ...at, width }, true), s) : undefined;
324
- // The room a vertical page's upright picture may take down the page
325
- // is the flow's whole extent: the frame's height is what it settles.
326
- const opts = { ...(exclusions ? { exclusions } : {}), ...(pic !== undefined ? { pictureScale: pic } : {}), ...(p.fromMark !== undefined ? { continuedMark: p.fromMark } : {}), ...uprightIn(p.frame, input.areas.area.height / s) };
327
- const r = p.st.L.peekRange(p.st.cut, naturalEnd(p), width / s, p.blockId, p.continuation, input.mirrored, Object.keys(opts).length > 0 ? opts : undefined);
328
- const h = r.totalHeight * s;
329
- memo.set(key, h);
330
- return h;
331
- };
332
- };
333
- /** The width an `'auto'`-width frame (#982) needs when it may take up
334
- * to `room`: the right edge of its longest line (a picture counting
335
- * by its own box), and what the box keeps to the right of its text
336
- * (padding, a stripe). The text is set flush left whatever its
337
- * alignment, so a centred title is as wide as its words, and not set
338
- * to a measure it would fill. Undefined for a frame of fixed or
339
- * `'fill'` width, or one in its own writing mode. */
340
- const naturalWidthOf = (p) => {
341
- if (p.frame.width !== 'auto' || ownMode(p.frame))
342
- return undefined;
343
- const memo = new Map();
344
- return (room) => {
345
- if (!p.holds)
346
- return 0;
347
- const key = Math.round(room * 1000);
348
- const known = memo.get(key);
349
- if (known !== undefined)
350
- return known;
351
- const s = textScale(p.frame);
352
- const style = styleOf(p.frame);
353
- const flush = { ...style, body: { ...style.body, textAlign: 'left' } };
354
- const L = makeCalloutLayouter(pass, p.st.story.startIdx, p.st.story.plan, flush);
355
- // Set at a measure far wider than the room, so that nothing wraps:
356
- // the frame is then as wide as its words, and the room caps it
357
- // (text that does not fit wraps at the room, as in a shrink-wrapped
358
- // box).
359
- const r = L.layoutRange(p.st.cut, L.end, (room * 8) / s, p.blockId, p.continuation, input.mirrored);
360
- let right = 0;
361
- for (const b of r.children) {
362
- if (b.type === 'callout' || b.hidden)
363
- continue;
364
- if (b.type === 'resource' || b.lines.length === 0)
365
- right = Math.max(right, b.bbox.x + b.bbox.width);
366
- for (const l of b.lines)
367
- if (l.text.length > 0)
368
- right = Math.max(right, l.bbox.x + l.bbox.width);
369
- }
370
- const inner = r.frame.callout?.innerRect;
371
- const keep = inner ? Math.max(0, r.width - (inner.x + inner.width)) : 0;
372
- // A quarter of a pixel over: a line is never set to its exact width.
373
- const w = Math.min(room, (right + keep + 0.25) * s);
374
- memo.set(key, w);
375
- return w;
376
- };
377
- };
378
- /** The height a frame set in its own writing mode (#944) needs at
379
- * `width`: its lines run down the box, so the least height whose
380
- * lines, following each other across, fit `width`; the area's height
381
- * when even that is not enough (the frame then overflows). */
382
- const turnedNaturalOf = (p, memo, s, pic) => (width) => {
383
- if (!p.holds)
384
- return 0;
385
- const key = Math.round(width * 1000);
386
- const known = memo.get(key);
387
- if (known !== undefined)
388
- return known;
389
- const opts = { ...(pic !== undefined ? { pictureScale: pic } : {}), ...(p.fromMark !== undefined ? { continuedMark: p.fromMark } : {}), ...uprightIn(p.frame, width / s) };
390
- const across = (measure) => inMode(p.frame, () => p.st.L.peekRange(p.st.cut, p.st.L.end, measure / s, p.blockId, p.continuation, mirroredIn(p.frame), Object.keys(opts).length > 0 ? opts : undefined).totalHeight * s);
391
- const most = Math.max(input.areas.area.height, input.emPx);
392
- let h = most;
393
- if (across(most) <= width + 0.5) {
394
- let lo = Math.min(input.emPx, most);
395
- let hi = most;
396
- if (across(lo) <= width + 0.5)
397
- hi = lo;
398
- // Whole px are enough: a line is never set that finely.
399
- while (hi - lo > 1) {
400
- const mid = (lo + hi) / 2;
401
- if (across(mid) <= width + 0.5)
402
- hi = mid;
403
- else
404
- lo = mid;
405
- }
406
- h = hi;
407
- }
408
- memo.set(key, h);
409
- return h;
410
- };
411
- /** `placeBox`, then the box the page lets the frame take (`fitBox`:
412
- * off a spread's spine band, #861), its `'auto'` height measured at the
413
- * width it is left with. Declared and final boxes alike: the band is
414
- * the template's, not a reflow. */
415
- const placeFitted = (frame, placeable, ctx, refs, nat, natW) => {
416
- const r = placeBox(placeable, template, ctx, refs, nat, natW);
417
- if (!input.fitBox)
418
- return r;
419
- const keep = (placed) => {
420
- const kept = input.fitBox(frame, placed);
421
- if (sameRect(kept, placed))
422
- fitted.delete(frame.name);
423
- else
424
- fitted.set(frame.name, { placed, kept });
425
- return kept;
426
- };
427
- const first = keep(r);
428
- if (Math.abs(first.width - r.width) < 0.01)
429
- return first;
430
- return keep(placeBox(placeable, template, ctx, refs, () => nat(first.width), natW));
431
- };
432
- /** A frame's height as its template declares it: its `minHeight` where
433
- * the height follows the content, else the content's (`natural`). */
434
- const declaredNatural = (frame, natural) => (width) => (frame.minHeight ? 0 : natural(width));
435
- /** Place a frame outside any group: its box, placed with the content's
436
- * own height, then again with the height it takes running round the
437
- * frames that push it there; a pinned frame where the template puts
438
- * it. */
439
- const placeFrame = (p) => {
440
- const frame = p.frame;
441
- const placeable = framePlaceable(frame);
442
- const natural = naturalOf(p);
443
- const natW = naturalWidthOf(p);
444
- const at = (refs) => {
445
- const r0 = placeFitted(frame, placeable, input, refs, natural, natW);
446
- if (!p.holds || !exclusionsFor(frame, r0, true))
447
- return { rect: r0, natural };
448
- const round = naturalOf(p, r0);
449
- return { rect: placeFitted(frame, placeable, input, refs, round, natW), natural: round };
450
- };
451
- const decl = frame.pin ? at(declaredRefOf) : undefined;
452
- const fin = decl ?? at(refOf);
453
- const declRect = placeFitted(frame, placeable, input, declaredRefOf, declaredNatural(frame, fin.natural), natW);
454
- const rect = frame.pin ? declRect : fin.rect;
455
- declared.set(frame.name, declRect);
456
- rects.set(frame.name, rect);
457
- if (frame.pin)
458
- pinned.push({ name: frame.name, rect });
459
- return rect;
460
- };
461
- /** Lay a group: its frames' boxes as the template declares them and as
462
- * their content needs (`composed/groups.ts`). With the ladder's
463
- * `redistribute` (#858) every frame gives space back, down to its
464
- * minimum or its content, whether it `shrink`s or not. */
465
- const placeGroup = (group, members) => {
466
- const own = groupPlaceable(group);
467
- const mmPx = dpi / MM_PER_IN;
468
- const yieldAll = fit.yieldAll.has(group.name);
469
- const preps = members.map(prepare);
470
- const natWs = preps.map(naturalWidthOf);
471
- const solve = (mode, naturals) => {
472
- const refs = mode === 'final' ? refOf : declaredRefOf;
473
- const ownBox = own ? placeBox(own, template, input, refs, () => 0) : undefined;
474
- const ownRects = new Map();
475
- const memberRefs = (n) => ownRects.get(n) ?? (n === group.name ? ownBox : refs(n));
476
- const items = members.map((f, k) => {
477
- // A frame placed nowhere stands in its group's box.
478
- const ctx = ownBox && !f.placement && !f.grid ? { ...input, areas: { ...input.areas, area: ownBox } } : input;
479
- const natural = naturals[k];
480
- const placeable = framePlaceable(f);
481
- // On a spread the member's own box keeps off the spine band, and
482
- // the negotiation starts from it (#861).
483
- const box = placeFitted(f, placeable, ctx, memberRefs, declaredNatural(f, natural), natWs[k]);
484
- ownRects.set(f.name, box);
485
- const auto = f.height === 'auto' && !(f.grid && !placeable.heightSet);
486
- const fill = f.height === 'fill';
487
- const minH = f.minHeight ? dimensionToPx(f.minHeight, dpi, input.emPx) : 0;
488
- const want = fill ? minH : auto ? (mode === 'final' ? natural(box.width) : declaredNatural(f, natural)(box.width)) : box.height;
489
- const max = f.maxHeight ? dimensionToPx(f.maxHeight, dpi, input.emPx) : Infinity;
490
- const item = {
491
- name: f.name,
492
- own: box,
493
- want,
494
- min: minH,
495
- max,
496
- minWidth: f.minWidth ? dimensionToPx(f.minWidth, dpi, input.emPx) : 0,
497
- maxWidth: f.maxWidth ? dimensionToPx(f.maxWidth, dpi, input.emPx) : Infinity,
498
- grow: fill ? Math.max(1, f.grow) : f.grow,
499
- shrink: f.shrink,
500
- priority: f.priority,
501
- pin: f.pin,
502
- fixedHeight: !auto && !fill,
503
- need: natural,
504
- floor: minH,
505
- };
506
- if (yieldAll && mode === 'final' && !f.pin) {
507
- // Down to its minimum, never under what its content needs, never
508
- // over the height it has.
509
- const height = Math.min(Math.max(want, minH), max);
510
- item.shrink = f.shrink > 0 ? f.shrink : 1;
511
- // (A row's frames give width, each down to the narrowest width
512
- // its content still fits: their heights stay the row's.)
513
- if (group.kind === 'stack')
514
- item.min = Math.min(height, Math.max(minH, natural(box.width)));
515
- }
516
- if (fit.goOn.has(f.name) && mode === 'final' && !f.pin) {
517
- // A frame cut for another page (#859) gives the room first,
518
- // down to its minimum: the frames after it in the group keep
519
- // their size (#912), and its rest goes on.
520
- item.shrink = Math.max(f.shrink, 1);
521
- item.priority = Number.NEGATIVE_INFINITY;
522
- item.min = minH;
523
- }
524
- return item;
525
- });
526
- const firstFree = items.find((it) => !it.pin) ?? items[0];
527
- const start = firstFree?.own ?? input.areas.area;
528
- const box = ownBox ?? { x: start.x, y: start.y, width: 0, height: 0 };
529
- const out = layoutGroup({
530
- kind: group.kind === 'row' ? 'row' : 'stack',
531
- box,
532
- elastic: !ownBox,
533
- limit: input.areas.area,
534
- gap: dimensionToPx(group.gap, dpi, input.emPx),
535
- align: group.align,
536
- items,
537
- obstacles: pinned.filter((q) => !members.some((m) => m.name === q.name)).map((q) => q.rect),
538
- mmPx,
539
- negotiate: mode === 'final',
540
- });
541
- // A pinned frame of the group stands where the template puts it.
542
- for (const it of items)
543
- if (it.pin)
544
- out.set(it.name, it.own);
545
- return { rects: out, box: ownBox ?? unionRect([...out.values()]) ?? box, items };
546
- };
547
- let naturals = preps.map((p) => naturalOf(p));
548
- let fin = solve('final', naturals);
549
- // Text that runs round a pushing frame is taller: measured at the box
550
- // first found, then laid again.
551
- const round = preps.map((p) => (p.holds && exclusionsFor(p.frame, fin.rects.get(p.frame.name), true) ? naturalOf(p, fin.rects.get(p.frame.name)) : undefined));
552
- if (round.some((r) => r !== undefined)) {
553
- naturals = naturals.map((n, k) => round[k] ?? n);
554
- fin = solve('final', naturals);
555
- }
556
- const decl = solve('declared', naturals);
557
- // A frame the stack cut below the least it may have (its
558
- // `minHeight`, a fixed height its own) is short of its box, content
559
- // or none (#911): an empty answer space or picture slot overflows
560
- // too.
561
- for (const it of fin.items) {
562
- if (it.pin || group.kind !== 'stack')
563
- continue;
564
- const least = it.fixedHeight && (it.floor ?? 0) <= 0.5 ? it.own.height : it.floor ?? 0;
565
- const got = fin.rects.get(it.name).height;
566
- if (least - got > 0.5)
567
- boxShort.set(it.name, least - got);
568
- else
569
- boxShort.delete(it.name);
570
- }
571
- for (const m of members) {
572
- rects.set(m.name, fin.rects.get(m.name));
573
- declared.set(m.name, decl.rects.get(m.name));
574
- if (m.pin)
575
- pinned.push({ name: m.name, rect: fin.rects.get(m.name) });
576
- }
577
- groupRects.set(group.name, fin.box);
578
- groupDeclared.set(group.name, decl.box);
579
- return fin.rects;
580
- };
581
- /** Lay a grid (#1061): its cells fill rows from the start side of the
582
- * page's lines (the flow frame is mirrored on a right-to-left page, so
583
- * its left is the start), `columns` to a row, `columnGap` and `rowGap`
584
- * between them. A cell is one item of a repeated frame set (or one
585
- * frame of a grid that repeats none): the main frame takes the cell's
586
- * width and its own height rule, the set's other frames are placed as
587
- * the template draws them, anchored to the main frame or to each
588
- * other (one that anchors to nothing in the set moves with the cell).
589
- * A row is as tall as its tallest cell, the set's frames counted;
590
- * `rowAlign` places the shorter ones (`'stretch'`: their main frame
591
- * grows to the row). The grid runs down its own box, or to the foot of
592
- * the area from where the template draws its main frame. A row that
593
- * does not fit is clipped at the foot, or, when the grid goes on to
594
- * another page (`FitState.gridsOn`), it and every row after it are
595
- * left for that page, whole (`spilled`). */
596
- const placeGrid = (group, members) => {
597
- const byMember = new Map(members.map((f) => [f.name, f]));
598
- const cells = (group.items ?? (group.repeat ? [] : members.map((f) => ({ item: 0, frames: [f.name] }))))
599
- .map((c) => c.frames.filter((n) => byMember.has(n)))
600
- .filter((c) => c.length > 0);
601
- const laidBoxes = new Map();
602
- const spilled = new Set();
603
- const cut = [];
604
- const own = groupPlaceable(group);
605
- const ownBox = own ? placeBox(own, template, input, refOf, () => 0) : undefined;
606
- const area = input.areas.area;
607
- const first = cells[0] ? byMember.get(cells[0][0]) : undefined;
608
- /** Where the template draws a cell's main frame. */
609
- const drawnOf = (main) => placeBox(framePlaceable(main), template, input, refOf, () => 0);
610
- const drawnFirst = first ? drawnOf(first) : area;
611
- const box = ownBox ?? { x: drawnFirst.x, y: drawnFirst.y, width: Math.max(0, area.x + area.width - drawnFirst.x), height: Math.max(0, area.y + area.height - drawnFirst.y) };
612
- const foot = box.y + box.height;
613
- const columns = Math.max(1, group.columns ?? 1);
614
- const colGap = dimensionToPx(group.columnGap ?? group.gap, dpi, input.emPx);
615
- const rowGap = dimensionToPx(group.rowGap ?? group.gap, dpi, input.emPx);
616
- const colW = Math.max(1, (box.width - colGap * (columns - 1)) / columns);
617
- const xOf = (c) => box.x + c * (colW + colGap);
618
- const px = (d) => (d ? dimensionToPx(d, dpi, input.emPx) : undefined);
619
- /** The main frame's height in a cell `w` wide: its own rule, held
620
- * between its minimum and maximum. */
621
- const mainHeight = (f, w) => {
622
- const h = f.height;
623
- let v;
624
- if (h === 'auto')
625
- v = naturalOf(prepare(f))(w);
626
- else if (h === 'fill')
627
- v = 0;
628
- else if ('percent' in h)
629
- v = (area.height * h.percent) / 100;
630
- else
631
- v = dimensionToPx(h, dpi, input.emPx);
632
- const min = px(f.minHeight) ?? 0;
633
- const max = px(f.maxHeight) ?? Infinity;
634
- return Math.max(min, Math.min(v, max));
635
- };
636
- /** The boxes of a cell's frames with its main frame at `(x, y)`,
637
- * `h` tall; and the frames that count for the cell's extent. */
638
- const layCell = (cell, x, y, h) => {
639
- const main = byMember.get(cell[0]);
640
- const boxes = new Map([[main.name, { x, y, width: colW, height: h }]]);
641
- const inCell = [main.name];
642
- const set = new Set(cell);
643
- const drawn = drawnOf(main);
644
- const refs = (n) => boxes.get(n) ?? refOf(n);
645
- // A frame anchored in the set fills (and takes its percentages of)
646
- // the cell's column, not the whole area.
647
- const column = { ...input, areas: { ...input.areas, area: { x, y: area.y, width: colW, height: area.height } } };
648
- let todo = cell.slice(1);
649
- for (let pass = 0; todo.length > 0 && pass <= cell.length; pass++) {
650
- const later = [];
651
- for (const name of todo) {
652
- const f = byMember.get(name);
653
- const target = f.grid ? undefined : anchorTarget(f.placement);
654
- // Anchored to a frame of the set not placed yet: next pass.
655
- if (target !== undefined && set.has(target) && !boxes.has(target) && pass < cell.length) {
656
- later.push(name);
657
- continue;
658
- }
659
- const p = prepare(f);
660
- const inSet = target !== undefined && set.has(target);
661
- const r = placeFitted(f, framePlaceable(f), inSet ? column : input, refs, naturalOf(p), naturalWidthOf(p));
662
- if (target !== undefined && !set.has(target)) {
663
- // Anchored to a frame outside the set: where it says.
664
- boxes.set(name, r);
665
- continue;
666
- }
667
- // Anchored in the set, or to nothing in it: with the cell.
668
- boxes.set(name, target !== undefined ? r : { ...r, x: r.x + x - drawn.x, y: r.y + y - drawn.y });
669
- inCell.push(name);
670
- }
671
- todo = later;
672
- }
673
- return { boxes, inCell };
674
- };
675
- const stretchable = (f) => f.height === 'auto' || f.height === 'fill';
676
- let cursor = box.y;
677
- let laidAny = false;
678
- let out = false;
679
- for (let r = 0; r * columns < cells.length; r++) {
680
- const row = cells.slice(r * columns, (r + 1) * columns);
681
- if (out) {
682
- for (const c of row)
683
- for (const n of c)
684
- spilled.add(n);
685
- continue;
686
- }
687
- // Each cell at the row's top, to see how far it reaches above and
688
- // below its main frame.
689
- const measured = row.map((cell, c) => {
690
- const main = byMember.get(cell[0]);
691
- const h = mainHeight(main, colW);
692
- const { boxes, inCell } = layCell(cell, xOf(c), 0, h);
693
- const u = unionRect(inCell.map((n) => boxes.get(n)));
694
- return { cell, main, h, above: Math.max(0, -u.y), below: u.y + u.height };
695
- });
696
- const above = Math.max(0, ...measured.map((m) => m.above));
697
- const below = Math.max(0, ...measured.map((m) => m.below));
698
- const rowH = above + below;
699
- const fits = cursor + rowH <= foot + 0.5;
700
- if (!fits && fit.gridsOn.has(group.name)) {
701
- // This row and the rest go on, whole.
702
- out = true;
703
- for (const c of row)
704
- for (const n of c)
705
- spilled.add(n);
706
- continue;
707
- }
708
- measured.forEach((m, c) => {
709
- const spare = below - m.below;
710
- let dy = 0;
711
- let h = m.h;
712
- if (spare > 0.01) {
713
- const align = group.rowAlign ?? 'stretch';
714
- if (align === 'end')
715
- dy = spare;
716
- else if (align === 'center')
717
- dy = spare / 2;
718
- else if (align === 'stretch' && stretchable(m.main))
719
- h = Math.min(m.h + spare, px(m.main.maxHeight) ?? Infinity);
720
- }
721
- const { boxes } = layCell(m.cell, xOf(c), cursor + above + dy, h);
722
- if (!fits)
723
- cut.push(...m.cell);
724
- for (const [n, b] of boxes) {
725
- // A row past the grid's foot is cut there: what is cut shows as
726
- // the frames' overflow.
727
- const y = Math.min(b.y, foot);
728
- laidBoxes.set(n, fits ? b : { ...b, y, height: Math.max(0, Math.min(b.y + b.height, foot) - y) });
729
- }
730
- });
731
- laidAny = true;
732
- cursor += rowH + rowGap;
733
- }
734
- for (const [n, b] of laidBoxes) {
735
- // A grid's cells are its template's drawing: no reflow events.
736
- declared.set(n, b);
737
- rects.set(n, b);
738
- }
739
- const laidRects = [...laidBoxes.values()];
740
- const union = ownBox ?? unionRect(laidRects) ?? { ...box, height: 0 };
741
- groupRects.set(group.name, union);
742
- groupDeclared.set(group.name, union);
743
- return { rects: laidBoxes, spilled, laidAny, clipped: cut };
744
- };
745
- /** Pour a frame's content into its box and record the frame. A frame
746
- * whose text the ladder scales (#858) is laid out in a box `1 / scale`
747
- * as large, painted at `scale` (`frameMatrix`). */
748
- const fill = (p, placed) => {
749
- const { frame, st, holds, continuation, blockId, before } = p;
750
- const style = styleOf(frame);
751
- const s = textScale(frame);
752
- const pic = pictureScale(frame);
753
- // A frame in its own writing mode (#944) is laid out in its box
754
- // turned a quarter turn, its lines along the box's height; painted
755
- // turned back (`VDTFrame.writingMode`).
756
- const turned = ownMode(frame);
757
- const rect = turned ? quarterTurnedRect(placed) : placed;
758
- const laidW = rect.width / s;
759
- const laidH = rect.height / s;
760
- let result;
761
- let overflowPx = 0;
762
- let goesOn = false;
763
- const from = st?.cut ?? CUT_START;
764
- if (holds) {
765
- // What its content needs at its width, measured only when a
766
- // proposal asks (`lowerMin`), from where the frame starts.
767
- const width = placed.width;
768
- const startAt = { ...p, st: { ...st, cut: from } };
769
- let known;
770
- needs.set(frame.name, () => (known ??= naturalOf(startAt)(width)));
771
- // Text running round the frames that push it runs along the page's
772
- // lines: a frame set across them keeps its whole box.
773
- const exclusions = turned ? undefined : unscale(exclusionsFor(frame, rect, false), s);
774
- const extra = { ...(exclusions ? { exclusions } : {}), ...(pic !== undefined ? { pictureScale: pic } : {}), ...(p.fromMark !== undefined ? { continuedMark: p.fromMark } : {}), ...uprightIn(frame, laidH) };
775
- const opts = { boxHeight: laidH, verticalAlign: frame.verticalAlign, ...extra };
776
- const whole = inMode(frame, () => st.L.layoutRange(from, st.L.end, laidW, blockId, continuation, mirroredIn(frame), opts));
777
- const nextName = nextFrameOf(frame);
778
- const nextFrame = nextName !== undefined ? byName.get(nextName) : undefined;
779
- const chained = nextFrame !== undefined && !vdtByName.has(nextFrame.name);
780
- // Cut for another page (#859) when the chain ends here.
781
- goesOn = !chained && fit.goOn.has(frame.name);
782
- // A part of the contents that opens a page of its own further down
783
- // (`toc.parts.breakBefore`, #996): the frame is cut there when it
784
- // can go on, though what it holds would fit.
785
- const partBreak = partBreakCut(pass, st.L, from) !== undefined;
786
- if (partBreak && !chained && !goesOn && continuesOffPage(frame.overflow.continueIn))
787
- wantsOn.add(frame.name);
788
- if (((whole.overflowPx ?? 0) > 0.5 || partBreak) && (chained || goesOn)) {
789
- // The rest goes on in the next frame of the chain, or on another
790
- // page.
791
- const minLines = Math.max(1, style.splitMinLines);
792
- // A heading stays with what follows it, a list keeps two items
793
- // on each side of the cut (#913).
794
- const frag = inMode(frame, () => splitCalloutFragment(pass, st.L, from, laidW, laidH, blockId, continuation, minLines, mirroredIn(frame), extra.exclusions || extra.pictureScale !== undefined || extra.continuedMark !== undefined || extra.uprightMaxLength !== undefined ? extra : undefined, cutRules, true));
795
- const to = frag?.to ?? from;
796
- // A frame none of whose content fits draws nothing: the whole box
797
- // goes on (#912), not a tab and a mark over an empty piece.
798
- result = frag ? inMode(frame, () => st.L.layoutRange(from, to, laidW, blockId, continuation, mirroredIn(frame), opts)) : undefined;
799
- st.cut = to;
800
- }
801
- else {
802
- goesOn = false;
803
- result = whole;
804
- overflowPx = (whole.overflowPx ?? 0) * s;
805
- st.cut = st.L.end;
806
- }
807
- }
808
- else if (st && frame.style) {
809
- // A styled frame with nothing (left) to hold still draws its box;
810
- // an empty story's own frame (#1084) its tab and title too.
811
- result = inMode(frame, () => st.L.layoutRange(st.L.end, st.L.end, laidW, blockId, continuation, mirroredIn(frame), { boxHeight: laidH }));
812
- }
813
- // A frame cut below its least height overflows by the cut, holding
814
- // content or not (#911).
815
- overflowPx = Math.max(overflowPx, boxShort.get(frame.name) ?? 0);
816
- // Ruled lines (#914): on the box, over its background, in its
817
- // laid-out coordinates; an empty frame keeps them for the decoration.
818
- let emptyRules;
819
- if (frame.rules) {
820
- const linePx = frameLinePx(style, dpi);
821
- if (result?.frame.designOverlay && result.frame.callout) {
822
- result.frame.designOverlay.blocks.push(...frameRuleBlocks(frame.rules, result.frame.callout.innerRect, linePx, s, dpi, input.emPx));
823
- }
824
- else if (!result) {
825
- const pad = (d) => dimensionToPx(d, dpi, input.emPx);
826
- const p = style.padding;
827
- const inner = { x: rect.x + pad(p.left), y: rect.y + pad(p.top), width: rect.width - pad(p.left) - pad(p.right), height: rect.height - pad(p.top) - pad(p.bottom) };
828
- const blocks = frameRuleBlocks(frame.rules, inner, linePx, 1, dpi, input.emPx);
829
- // On the page, a frame in its own writing mode turns its rules
830
- // with it (#944): across its lines, as the page shows them.
831
- if (blocks.length > 0)
832
- emptyRules = turned ? blocks.map((b) => ({ ...b, bbox: turnRectAbout(b.bbox, rect, frameModeTurn({ writingMode: turned })) })) : blocks;
833
- }
834
- }
835
- const instance = repeated.has(repeatInstance(frame.name)?.frame ?? '') ? repeatInstance(frame.name) : undefined;
836
- const vdt = {
837
- id: frameIdOf(frame.name),
838
- name: frame.name,
839
- ...(instance ? { repeat: instance } : {}),
840
- rect: { ...rect },
841
- rotate: frame.rotate + (turned ? frameModeTurn({ writingMode: turned }) : 0),
842
- ...(turned ? { writingMode: turned } : {}),
843
- ...(unmirroredAt(frame) !== undefined ? { unmirrorX: unmirroredAt(frame) } : {}),
844
- layer: frame.layer,
845
- ...(frame.style ? { styleId: frame.style } : {}),
846
- ...(holds && unknownLookOf(frame) !== undefined ? { lookUnknown: unknownLookOf(frame) } : {}),
847
- scale: s,
848
- ...(pic !== undefined && holds ? { imageScale: pic } : {}),
849
- overflowPx,
850
- blockIds: [],
851
- configPath: frame.configPath,
852
- ...(frame.exclude === 'push' ? { push: true } : {}),
853
- ...(collapsed.has(frame.name) ? { collapsed: true } : {}),
854
- ...(emptyRules ? { rules: emptyRules } : {}),
855
- };
856
- const declPlaced = declared.get(frame.name);
857
- const decl = declPlaced && turned ? quarterTurnedRect(declPlaced) : declPlaced;
858
- if (decl && !sameRect(decl, rect))
859
- vdt.declaredRect = { ...decl };
860
- if (before && vdtByName.has(before) && st && st.lastFrameId) {
861
- vdt.continuedFrom = st.lastFrameId;
862
- const q = frames.find((f) => f.id === st.lastFrameId);
863
- if (q)
864
- q.continuesTo = vdt.id;
865
- }
866
- else if (holds && cont?.receivers.has(frame.name) && !cont.receivers.get(frame.name).whole) {
867
- // Content from the page before (#859). (An item of a grid that
868
- // came whole, #1061, starts here.)
869
- const came = cont.receivers.get(frame.name);
870
- vdt.continuedFrom = came.fromFrameId;
871
- // From a page of an earlier chapter (#943).
872
- if (came.foreign)
873
- vdt.continuedFromChapter = came.foreign.from;
874
- }
875
- if (result) {
876
- // The marks whose `{page}` the build fills in (#917).
877
- if (goesOn && typeof frame.overflow.mark === 'string' && frame.overflow.mark.includes('{page}'))
878
- tagPageMark(result.frame, withPage(frame.overflow.mark, toGuess), frame.overflow.mark, 'to');
879
- const fromWords = frame.overflow.fromMark ?? cont?.receivers.get(headOf(frame.name))?.fromMark;
880
- if (p.fromMark !== undefined && fromWords?.includes('{page}'))
881
- tagPageMark(result.frame, p.fromMark, fromWords, 'from');
882
- }
883
- if (result && st) {
884
- const range = fragmentRange(st.L, from, st.cut);
885
- commitFrame(result, rect, st.story, range, input, vdt, blocks);
886
- st.pieces++;
887
- st.lastFrameId = vdt.id;
888
- laid.add(headOf(frame.name));
889
- // What the ladder changed in the frame's content (#858).
890
- const pictures = fit.pictures.get(headOf(frame.name));
891
- if (pictures && result.children.some((b) => b.type === 'resource')) {
892
- fitLog.push({ frame: frame.name, kind: 'imageScaled', scale: pictures.scale, ...(pictures.by !== frame.name ? { cause: pictures.by } : {}) });
893
- }
894
- if (s !== 1 && holds)
895
- fitLog.push({ frame: frame.name, kind: 'textScaled', scale: s });
896
- }
897
- if (goesOn && st) {
898
- // Laid here even when none of it fits: the rest goes on (#912).
899
- laid.add(headOf(frame.name));
900
- spills.set(frame.name, { head: headOf(frame.name), cut: st.cut, advanced: !sameCut(from, st.cut), pieces: st.pieces, headBlockId: st.headBlockId, frameId: vdt.id });
901
- }
902
- if (overflowPx > 0.5) {
903
- const overflowMm = Math.round((overflowPx / dpi) * MM_PER_IN * 10) / 10;
904
- overflowLog.push({ frame: frame.name, kind: 'overflow', toMm: overflowMm });
905
- }
906
- if (frame.exclude === 'push') {
907
- const box = frameBounds({ rect: placed, rotate: frame.rotate });
908
- pushRects.set(frame.name, box);
909
- // `wrap: 'contour'` (#883): the shape of the pictures it holds; a
910
- // turned frame pushes with its box.
911
- const shape = frame.wrap === 'contour' && frame.rotate === 0 && !turned && result
912
- ? frameContour(result.children, { gapPx: input.pushGapPx, dpi, emPx: input.emPx, mirrored: pageIsMirrored(input.page), pageIndex: input.page.index })
913
- : undefined;
914
- if (shape)
915
- notes.push(...shape.notes);
916
- // A frame whose text the ladder scaled (#858) holds its pictures in
917
- // its laid-out coordinates: on the page they are `s` as large, from
918
- // its box's corner (`frameMatrix`).
919
- const contour = shape?.contour && s !== 1 ? scaleContourAbout(shape.contour, rect.x, rect.y, s, false) : shape?.contour;
920
- if (contour)
921
- pushShapes.set(frame.name, contour);
922
- if (!seed)
923
- pushed.push({ name: frame.name, box, ...(contour ? { contour } : {}) });
924
- }
925
- frames.push(vdt);
926
- vdtByName.set(frame.name, vdt);
927
- };
928
- /** A frame's box cut at `clipFoot` (a module cut at its group's foot,
929
- * #1062): what is cut shows as the frame's overflow. */
930
- const clipAtFoot = (name, r) => {
931
- if (clipFoot === undefined || r.y + r.height <= clipFoot + 0.5)
932
- return r;
933
- clipped.add(name);
934
- const y = Math.min(r.y, clipFoot);
935
- const out = { ...r, y, height: Math.max(0, Math.min(r.y + r.height, clipFoot) - y) };
936
- rects.set(name, out);
937
- return out;
938
- };
939
- /** A module's `'auto'` box that ends at the module's foot, in a row
940
- * that stretches the module (#1095): to the row's foot, its declared
941
- * box by as much (the template asks for it). A frame as wide as its
942
- * content (a pill, a tab) keeps its height. */
943
- const stretchAuto = (name, r) => {
944
- const s = stretchTo;
945
- if (!s || !s.names.has(name))
946
- return r;
947
- const f = byName.get(name);
948
- if (!f || f.height !== 'auto' || f.width === 'auto' || f.pin || heldByFoot(f))
949
- return r;
950
- const bottom = r.y + r.height;
951
- if (Math.abs(bottom - s.at) > 0.5 || s.foot - bottom <= 0.01)
952
- return r;
953
- const out = { ...r, height: s.foot - r.y };
954
- rects.set(name, out);
955
- const d = declared.get(name);
956
- if (d)
957
- declared.set(name, { ...d, height: d.height + (s.foot - bottom) });
958
- return out;
959
- };
960
- /** The frames of `names` whose content goes on whole on another page
961
- * (#1061, #1062): none of it is laid here. */
962
- const spillWhole = (names, advanced, lastLaid) => {
963
- for (const n of names) {
964
- const f = byName.get(n);
965
- const st = f ? prepare(f).st : undefined;
966
- if (!st)
967
- continue;
968
- laid.add(headOf(n));
969
- spills.set(n, { head: headOf(n), cut: st.cut, advanced, pieces: st.pieces, headBlockId: st.headBlockId, frameId: lastLaid ?? frameIdOf(n), whole: true });
970
- }
971
- };
972
- /** Place (and, `filling`, fill) one step of `composedOrder`. */
973
- const runStep = (step, filling) => {
974
- if (step.kind === 'frame') {
975
- const p = prepare(step.frame);
976
- const r = clipAtFoot(step.frame.name, stretchAuto(step.frame.name, placeFrame(p)));
977
- if (filling)
978
- fill(p, r);
979
- return;
980
- }
981
- if (step.group.modules) {
982
- // A modules group (#1062): its modules, one under another.
983
- placeModules(step.group, step.frames);
984
- return;
985
- }
986
- if (step.group.kind === 'grid') {
987
- // A grid (#1061): its cells, and the items of the rows left for
988
- // another page, which go on whole.
989
- const grid = placeGrid(step.group, step.frames);
990
- if (!filling)
991
- return;
992
- for (const n of grid.clipped)
993
- clipped.add(n);
994
- let lastLaid;
995
- for (const f of step.frames) {
996
- if (!grid.spilled.has(f.name)) {
997
- fill(prepare(f), clipAtFoot(f.name, stretchAuto(f.name, grid.rects.get(f.name))));
998
- lastLaid = frameIdOf(f.name);
999
- continue;
1000
- }
1001
- spillWhole([f.name], grid.laidAny, lastLaid);
1002
- }
1003
- return;
1004
- }
1005
- const solved = placeGroup(step.group, step.frames);
1006
- // A frame of a chain inside the group is reached once the frame
1007
- // before it was filled: each is prepared again as it is filled.
1008
- for (const f of step.frames) {
1009
- const r = clipAtFoot(f.name, stretchAuto(f.name, solved.get(f.name)));
1010
- if (filling)
1011
- fill(prepare(f), r);
1012
- }
1013
- };
1014
- /** Lay a modules group (#1062): its modules in rows down the group's
1015
- * box (its own, else the area). A stack gives each module a row of
1016
- * its own, as wide as the group (or its template's `width`, #1088), a
1017
- * `'row'` puts them all in one, start to end (each its `width`, else
1018
- * an equal share of what is left), a `'grid'` `columns` to a row in
1019
- * equal columns; a run of modules a group inside it takes (`within`)
1020
- * is laid as that group says where its first module comes: its rows
1021
- * among a stack's, one cell of a row or a grid (#1095: to any depth).
1022
- * A row's room past its modules' widths goes by `grow`, what it is
1023
- * short by comes back by `shrink` (#1095). Rows run from the start side of the page's lines (the flow frame is
1024
- * mirrored on a right-to-left page, so its left is the start). A
1025
- * module is placed as its template draws its frames in its box
1026
- * (`'container'` is the box) and its groups laid in it: first in the
1027
- * room left, to find how tall it is (the frames held by the box's foot
1028
- * or middle, or sized by its height, left out), then in a box that
1029
- * tall, or (`rowAlign` `'stretch'`, a row of several) as tall as its
1030
- * row, its `'auto'` boxes that end at its foot reaching the row's
1031
- * (#1095). A row that does not fit is cut at the group's foot (its frames
1032
- * clipped there), or, when the group goes on to another page
1033
- * (`FitState.gridsOn`), it and every row after it go on, whole. The
1034
- * modules' declared boxes follow each other at the heights their
1035
- * frames declare, so the log tells a module moved by the one before
1036
- * it. */
1037
- const placeModules = (group, members) => {
1038
- const byMember = new Map(members.map((f) => [f.name, f]));
1039
- const own = groupPlaceable(group);
1040
- const ownBox = own ? placeBox(own, template, pageInput, refOf, () => 0) : undefined;
1041
- const box = ownBox ?? pageInput.areas.area;
1042
- const foot = box.y + box.height;
1043
- const toPx = (d) => dimensionToPx(d, dpi, pageInput.emPx);
1044
- const groupNamed = new Map(template.groups.map((g) => [g.name, g]));
1045
- const mods = [];
1046
- for (const item of group.items ?? []) {
1047
- const mod = template.modules?.find((m) => m.name === item.module);
1048
- const names = item.frames.filter((n) => byMember.has(n));
1049
- if (mod && names.length > 0)
1050
- mods.push({ mod, names, chain: nestedChain(template.groups, mod.nested) });
1051
- }
1052
- /** A module's width by its template in a group `width` wide
1053
- * (`'fill'`: none). */
1054
- const fixedWidth = (l, width) => {
1055
- const w = l.mod.width;
1056
- if (w === undefined || w === 'fill')
1057
- return undefined;
1058
- return 'percent' in w ? (width * w.percent) / 100 : toPx(w);
1059
- };
1060
- /** The cells of `list` in `g`: each module `g` lays itself, and each
1061
- * run of the modules of a group inside `g`. */
1062
- const cellsOf = (list, g) => {
1063
- const out = [];
1064
- for (const l of list) {
1065
- const name = l.chain.find((n) => groupNamed.get(n)?.within === g.name);
1066
- const child = name !== undefined ? groupNamed.get(name) : undefined;
1067
- const last = out[out.length - 1];
1068
- if (child && last?.kind === 'group' && last.group === child)
1069
- last.list.push(l);
1070
- else
1071
- out.push(child ? { kind: 'group', group: child, list: [l] } : { kind: 'module', l });
1072
- }
1073
- return out;
1074
- };
1075
- const namesOf = (c) => (c.kind === 'module' ? c.l.names : c.list.flatMap((l) => l.names));
1076
- /** `cells` side by side across `width` from `x`, `gap` between them:
1077
- * each as wide as its template says, then the room left shared by
1078
- * `grow` (a `'fill'` module, and a group's cell, 1 at least), or,
1079
- * when the widths run past the end, given back by `shrink` in
1080
- * proportion to each width (#1095). */
1081
- const across = (cells, gap, x, width) => {
1082
- const fixed = cells.map((c) => (c.kind === 'module' ? fixedWidth(c.l, width) : undefined));
1083
- const taken = fixed.reduce((a, w) => a + (w ?? 0), 0) + gap * Math.max(0, cells.length - 1);
1084
- const spare = width - taken;
1085
- let widths;
1086
- if (spare >= 0) {
1087
- const grows = cells.map((c, k) => (c.kind !== 'module' ? 1 : fixed[k] === undefined ? Math.max(1, c.l.mod.grow ?? 1) : c.l.mod.grow ?? 0));
1088
- const total = grows.reduce((a, g) => a + g, 0);
1089
- widths = fixed.map((w, k) => Math.max(0, total > 0 ? (w ?? 0) + (spare * grows[k]) / total : w ?? 0));
1090
- }
1091
- else {
1092
- const weights = cells.map((c, k) => (c.kind === 'module' && fixed[k] !== undefined ? (c.l.mod.shrink ?? 0) * fixed[k] : 0));
1093
- const total = weights.reduce((a, g) => a + g, 0);
1094
- widths = fixed.map((w, k) => Math.max(0, total > 0 ? (w ?? 0) + (spare * weights[k]) / total : w ?? 0));
1095
- }
1096
- const xs = [];
1097
- let at = x;
1098
- for (const w of widths) {
1099
- xs.push(at);
1100
- at += w + gap;
1101
- }
1102
- return { xs, widths };
1103
- };
1104
- /** The rows `list` makes in a group of `g`'s kind across `width`
1105
- * from `x`, the first `first` after the row before it. A group
1106
- * inside a stack adds its rows to the stack's; inside a row or a
1107
- * grid, a run of its modules is one cell. */
1108
- const rowsOf = (list, g, x, width, first) => {
1109
- const gap = toPx(g.gap);
1110
- const align = g.rowAlign ?? 'stretch';
1111
- const cells = cellsOf(list, g);
1112
- if (g.kind === 'row')
1113
- return [{ cells, ...across(cells, gap, x, width), align, gapBefore: first }];
1114
- if (g.kind === 'grid') {
1115
- const columns = Math.max(1, g.columns ?? 1);
1116
- const colGap = toPx(g.columnGap ?? g.gap);
1117
- const rowGap = toPx(g.rowGap ?? g.gap);
1118
- const colW = Math.max(1, (width - colGap * (columns - 1)) / columns);
1119
- const out = [];
1120
- for (let k = 0; k < cells.length; k += columns) {
1121
- const chunk = cells.slice(k, k + columns);
1122
- out.push({ cells: chunk, xs: chunk.map((_, c) => x + c * (colW + colGap)), widths: chunk.map(() => colW), align, gapBefore: k === 0 ? first : rowGap });
1123
- }
1124
- return out;
1125
- }
1126
- // A stack: a row of its own per module, at its width from the
1127
- // start; a group's rows in turn.
1128
- const out = [];
1129
- cells.forEach((c, k) => {
1130
- const before = k === 0 ? first : gap;
1131
- if (c.kind === 'module')
1132
- out.push({ cells: [c], xs: [x], widths: [fixedWidth(c.l, width) ?? width], align: 'start', gapBefore: before });
1133
- else
1134
- out.push(...rowsOf(c.list, c.group, x, width, before));
1135
- });
1136
- return out;
1137
- };
1138
- const rows = rowsOf(mods, group, box.x, box.width, 0);
1139
- let cursor = box.y;
1140
- let declCursor = box.y;
1141
- let out = false;
1142
- let laidAny = false;
1143
- let lastLaid;
1144
- const boxes = [];
1145
- const declBoxes = [];
1146
- const nestedBoxes = new Map();
1147
- const restore = (to, from) => {
1148
- to.clear();
1149
- for (const [k, v] of from)
1150
- to.set(k, v);
1151
- };
1152
- const lay = (l, x, y, width, height, filling) => {
1153
- const steps = composedOrder({ frames: l.names.map((n) => byMember.get(n)), groups: template.groups.filter((g) => l.mod.groups.includes(g.name)) });
1154
- input = { ...pageInput, areas: { ...pageInput.areas, area: { x, y, width, height: Math.max(0, height) } } };
1155
- try {
1156
- for (const step of steps)
1157
- runStep(step, filling);
1158
- }
1159
- finally {
1160
- input = pageInput;
1161
- }
1162
- };
1163
- /** How tall a module is at `(x, y)`, `width` wide: its frames placed
1164
- * in the room left, then everything they set put back. */
1165
- const measure = (l, x, y, width) => {
1166
- const kept = { rects: new Map(rects), declared: new Map(declared), groupRects: new Map(groupRects), groupDeclared: new Map(groupDeclared), pinned: pinned.length, boxShort: new Map(boxShort), fitted: new Map(fitted) };
1167
- lay(l, x, y, width, foot - y, false);
1168
- const placed = l.names.filter((n) => rects.has(n));
1169
- const measured = placed.filter((n) => !heldByFoot(byMember.get(n)));
1170
- const reach = unionRect((measured.length > 0 ? measured : placed).map((n) => rects.get(n)));
1171
- restore(rects, kept.rects);
1172
- restore(declared, kept.declared);
1173
- restore(groupRects, kept.groupRects);
1174
- restore(groupDeclared, kept.groupDeclared);
1175
- restore(boxShort, kept.boxShort);
1176
- restore(fitted, kept.fitted);
1177
- pinned.length = kept.pinned;
1178
- return reach ? Math.max(0, reach.y + reach.height - y) : 0;
1179
- };
1180
- /** How tall a cell is at `(x, y)`, `width` wide: a module's height,
1181
- * or a group's rows one after another (#1095). */
1182
- const measureCell = (c, x, y, width) => {
1183
- if (c.kind === 'module')
1184
- return measure(c.l, x, y, width);
1185
- let at = y;
1186
- rowsOf(c.list, c.group, x, width, 0).forEach((row, r) => {
1187
- if (r > 0)
1188
- at += row.gapBefore;
1189
- at += Math.max(0, ...row.cells.map((d, k) => measureCell(d, row.xs[k], at, row.widths[k])));
1190
- });
1191
- return at - y;
1192
- };
1193
- /** Lay `row` at `rowTop` (its declared top `declTop`), its cells
1194
- * `heights` tall: each module in a box that tall (cut at the foot
1195
- * when the row does not fit), a shorter one placed by `rowAlign`; a
1196
- * group's cell its rows in turn. The row's foot, laid and declared. */
1197
- const layRow = (row, rowTop, declTop, heights, fits) => {
1198
- const rowH = Math.max(0, ...heights);
1199
- const several = row.cells.length > 1;
1200
- let rowBottom = rowTop;
1201
- let rowDeclBottom = declTop;
1202
- row.cells.forEach((c, k) => {
1203
- const x = row.xs[k];
1204
- const width = row.widths[k];
1205
- const spare = rowH - heights[k];
1206
- const stretched = fits && several && row.align === 'stretch' && c.kind === 'module';
1207
- const dy = fits && several && spare > 0.01 ? (row.align === 'end' ? spare : row.align === 'center' ? spare / 2 : 0) : 0;
1208
- const y = rowTop + dy;
1209
- if (c.kind === 'group') {
1210
- // A run of a group inside this one (#1095): its rows, from the
1211
- // cell's top.
1212
- const laid = layRows(rowsOf(c.list, c.group, x, width, 0), y, declTop + dy, fits);
1213
- rowBottom = Math.max(rowBottom, laid.bottom);
1214
- rowDeclBottom = Math.max(rowDeclBottom, laid.declBottom);
1215
- return;
1216
- }
1217
- const l = c.l;
1218
- clipFoot = fits ? undefined : foot;
1219
- // Its 'auto' boxes that end at its foot reach the row's (#1095).
1220
- stretchTo = stretched && spare > 0.01 ? { at: y + heights[k], foot: y + rowH, names: new Set(l.names) } : undefined;
1221
- try {
1222
- lay(l, x, y, width, fits ? (stretched ? rowH : heights[k]) : foot - rowTop, true);
1223
- }
1224
- finally {
1225
- clipFoot = undefined;
1226
- stretchTo = undefined;
1227
- }
1228
- const u = unionRect(l.names.flatMap((n) => (rects.has(n) ? [rects.get(n)] : [])));
1229
- const bottom = Math.max(stretched ? y + rowH : y, u ? u.y + u.height : y);
1230
- const moduleBox = { x, y, width, height: bottom - y };
1231
- moduleRects.set(l.mod.name, moduleBox);
1232
- boxes.push(moduleBox);
1233
- // Declared: after the rows before it as they declare themselves.
1234
- const shift = declTop - rowTop;
1235
- for (const n of l.names) {
1236
- const d = declared.get(n);
1237
- if (d && Math.abs(shift) > 0.001)
1238
- declared.set(n, { ...d, y: d.y + shift });
1239
- }
1240
- const declY = declTop + dy;
1241
- const du = unionRect(l.names.flatMap((n) => (declared.has(n) ? [declared.get(n)] : [])));
1242
- const declBottom = du ? Math.max(declY, du.y + du.height) : declY;
1243
- const declBox = { x, y: declY, width, height: declBottom - declY };
1244
- declBoxes.push(declBox);
1245
- for (const name of l.chain) {
1246
- const n = nestedBoxes.get(name) ?? { laid: [], declared: [] };
1247
- n.laid.push(moduleBox);
1248
- n.declared.push(declBox);
1249
- nestedBoxes.set(name, n);
1250
- }
1251
- rowBottom = Math.max(rowBottom, bottom);
1252
- rowDeclBottom = Math.max(rowDeclBottom, declBottom);
1253
- });
1254
- return { bottom: rowBottom, declBottom: rowDeclBottom };
1255
- };
1256
- /** The rows of a group's cell, one after another from `top`. */
1257
- const layRows = (list, top, declTop, fits) => {
1258
- let at = top;
1259
- let declAt = declTop;
1260
- list.forEach((row, r) => {
1261
- if (r > 0) {
1262
- at += row.gapBefore;
1263
- declAt += row.gapBefore;
1264
- }
1265
- const heights = row.cells.map((c, k) => measureCell(c, row.xs[k], at, row.widths[k]));
1266
- const laid = layRow(row, at, declAt, heights, fits);
1267
- at = laid.bottom;
1268
- declAt = laid.declBottom;
1269
- });
1270
- return { bottom: at, declBottom: declAt };
1271
- };
1272
- rows.forEach((row, r) => {
1273
- const names = row.cells.flatMap(namesOf);
1274
- if (out) {
1275
- spillWhole(names, laidAny, lastLaid);
1276
- return;
1277
- }
1278
- if (r > 0) {
1279
- cursor += row.gapBefore;
1280
- declCursor += row.gapBefore;
1281
- }
1282
- const heights = row.cells.map((c, k) => measureCell(c, row.xs[k], cursor, row.widths[k]));
1283
- const rowH = Math.max(0, ...heights);
1284
- const fits = cursor + rowH <= foot + 0.5;
1285
- if (!fits && fit.gridsOn.has(group.name)) {
1286
- // This row and the ones after it go on, whole.
1287
- out = true;
1288
- spillWhole(names, laidAny, lastLaid);
1289
- return;
1290
- }
1291
- const laid = layRow(row, cursor, declCursor, heights, fits);
1292
- laidAny = true;
1293
- lastLaid = frameIdOf(names[names.length - 1]);
1294
- cursor = laid.bottom;
1295
- declCursor = laid.declBottom;
1296
- });
1297
- // A group inside another (#1088, #1095) is the box of its modules.
1298
- for (const [name, b] of nestedBoxes) {
1299
- groupRects.set(name, unionRect(b.laid));
1300
- groupDeclared.set(name, unionRect(b.declared));
1301
- }
1302
- groupRects.set(group.name, ownBox ?? unionRect(boxes) ?? { ...box, height: 0 });
1303
- groupDeclared.set(group.name, ownBox ?? unionRect(declBoxes) ?? { ...box, height: 0 });
1304
- };
1305
- for (const step of composedOrder(template))
1306
- runStep(step, true);
1307
- const log = mergeLog(reflowEvents(motionsOf(template, rects, declared), dpi / MM_PER_IN), [...fitLog, ...overflowLog], template);
1308
- return { frames, blocks, log, laid, needs, pushRects, pushShapes, fitted, notes, spills, wantsOn, clipped, groupRects, moduleRects };
1309
- };
164
+ const { run } = createRun({
165
+ pageInput, template, fit, collapsed, pass, dpi, cont, cutRules, frameIdOf, byName, repeated,
166
+ prev, headOf, textScale, toGuess, unknownLookOf, styleOf, fromMarkOf, pictureScale, ownMode,
167
+ unmirroredAt, mirroredIn, uprightIn, inMode, unscale, state
168
+ });
1310
169
  const first = run();
1311
170
  const { frames, blocks, log, laid, needs, fitted, notes, spills, wantsOn, clipped, groupRects, moduleRects } = first.pushRects.size > 0 ? run(first.pushRects, first.pushShapes) : first;
1312
171
  return { frames, blocks, log, laid, needs, template, fitted, spills, wantsOn, clipped, groupRects, moduleRects, ...(notes.length > 0 ? { notes } : {}) };