@kensio/colophon 2.2.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (492) hide show
  1. package/README.md +62 -265
  2. package/dist/background.d.ts +7 -2
  3. package/dist/background.d.ts.map +1 -1
  4. package/dist/background.js +44 -1
  5. package/dist/background.js.map +1 -1
  6. package/dist/cli/args.d.ts +14 -0
  7. package/dist/cli/args.d.ts.map +1 -0
  8. package/dist/cli/args.js +67 -0
  9. package/dist/cli/args.js.map +1 -0
  10. package/dist/cli/config.d.ts +12 -0
  11. package/dist/cli/config.d.ts.map +1 -0
  12. package/dist/cli/config.js +43 -0
  13. package/dist/cli/config.js.map +1 -0
  14. package/dist/cli/index.d.ts +3 -0
  15. package/dist/cli/index.d.ts.map +1 -0
  16. package/dist/cli/index.js +35 -0
  17. package/dist/cli/index.js.map +1 -0
  18. package/dist/cli.js +34 -6
  19. package/dist/cli.js.map +1 -1
  20. package/dist/config/defaults.d.ts +65 -0
  21. package/dist/config/defaults.d.ts.map +1 -0
  22. package/dist/config/defaults.js +64 -0
  23. package/dist/config/defaults.js.map +1 -0
  24. package/dist/config/index.d.ts +22 -0
  25. package/dist/config/index.d.ts.map +1 -0
  26. package/dist/config/index.js +54 -0
  27. package/dist/config/index.js.map +1 -0
  28. package/dist/config/resolve.d.ts +31 -0
  29. package/dist/config/resolve.d.ts.map +1 -0
  30. package/dist/config/resolve.js +82 -0
  31. package/dist/config/resolve.js.map +1 -0
  32. package/dist/config/size.d.ts +20 -0
  33. package/dist/config/size.d.ts.map +1 -0
  34. package/dist/config/size.js +47 -0
  35. package/dist/config/size.js.map +1 -0
  36. package/dist/config.d.ts +27 -1
  37. package/dist/config.d.ts.map +1 -1
  38. package/dist/config.js +78 -2
  39. package/dist/config.js.map +1 -1
  40. package/dist/content/index.d.ts +5 -51
  41. package/dist/content/index.d.ts.map +1 -1
  42. package/dist/content/index.js +3 -115
  43. package/dist/content/index.js.map +1 -1
  44. package/dist/content/props.d.ts +15 -0
  45. package/dist/content/props.d.ts.map +1 -0
  46. package/dist/content/props.js +71 -0
  47. package/dist/content/props.js.map +1 -0
  48. package/dist/content/slug.d.ts +23 -0
  49. package/dist/content/slug.d.ts.map +1 -0
  50. package/dist/content/slug.js +52 -0
  51. package/dist/content/slug.js.map +1 -0
  52. package/dist/content/walk.d.ts +17 -0
  53. package/dist/content/walk.d.ts.map +1 -0
  54. package/dist/content/walk.js +57 -0
  55. package/dist/content/walk.js.map +1 -0
  56. package/dist/fonts/index.d.ts +11 -0
  57. package/dist/fonts/index.d.ts.map +1 -0
  58. package/dist/fonts/index.js +12 -0
  59. package/dist/fonts/index.js.map +1 -0
  60. package/dist/fonts/materialise.d.ts +7 -0
  61. package/dist/fonts/materialise.d.ts.map +1 -0
  62. package/dist/fonts/materialise.js +47 -0
  63. package/dist/fonts/materialise.js.map +1 -0
  64. package/dist/fonts/resolve.d.ts +7 -0
  65. package/dist/fonts/resolve.d.ts.map +1 -0
  66. package/dist/fonts/resolve.js +50 -0
  67. package/dist/fonts/resolve.js.map +1 -0
  68. package/dist/fonts.d.ts +18 -0
  69. package/dist/fonts.d.ts.map +1 -0
  70. package/dist/fonts.js +102 -0
  71. package/dist/fonts.js.map +1 -0
  72. package/dist/generate/extra.d.ts +16 -0
  73. package/dist/generate/extra.d.ts.map +1 -0
  74. package/dist/generate/extra.js +60 -0
  75. package/dist/generate/extra.js.map +1 -0
  76. package/dist/generate/index.d.ts +19 -0
  77. package/dist/generate/index.d.ts.map +1 -0
  78. package/dist/generate/index.js +46 -0
  79. package/dist/generate/index.js.map +1 -0
  80. package/dist/generate/job.d.ts +35 -0
  81. package/dist/generate/job.d.ts.map +1 -0
  82. package/dist/generate/job.js +2 -0
  83. package/dist/generate/job.js.map +1 -0
  84. package/dist/generate/options.d.ts +56 -0
  85. package/dist/generate/options.d.ts.map +1 -0
  86. package/dist/generate/options.js +17 -0
  87. package/dist/generate/options.js.map +1 -0
  88. package/dist/generate/output-path.d.ts +12 -0
  89. package/dist/generate/output-path.d.ts.map +1 -0
  90. package/dist/generate/output-path.js +18 -0
  91. package/dist/generate/output-path.js.map +1 -0
  92. package/dist/generate/outputs.d.ts +28 -0
  93. package/dist/generate/outputs.d.ts.map +1 -0
  94. package/dist/generate/outputs.js +71 -0
  95. package/dist/generate/outputs.js.map +1 -0
  96. package/dist/generate/plan.d.ts +21 -0
  97. package/dist/generate/plan.d.ts.map +1 -0
  98. package/dist/generate/plan.js +72 -0
  99. package/dist/generate/plan.js.map +1 -0
  100. package/dist/generate/render-image.d.ts +11 -0
  101. package/dist/generate/render-image.d.ts.map +1 -0
  102. package/dist/generate/render-image.js +27 -0
  103. package/dist/generate/render-image.js.map +1 -0
  104. package/dist/generate.d.ts +27 -6
  105. package/dist/generate.d.ts.map +1 -1
  106. package/dist/generate.js +69 -15
  107. package/dist/generate.js.map +1 -1
  108. package/dist/highlight/color.d.ts +9 -0
  109. package/dist/highlight/color.d.ts.map +1 -0
  110. package/dist/highlight/color.js +15 -0
  111. package/dist/highlight/color.js.map +1 -0
  112. package/dist/highlight/grid.d.ts +14 -0
  113. package/dist/highlight/grid.d.ts.map +1 -0
  114. package/dist/highlight/grid.js +36 -0
  115. package/dist/highlight/grid.js.map +1 -0
  116. package/dist/highlight/index.d.ts +12 -0
  117. package/dist/highlight/index.d.ts.map +1 -0
  118. package/dist/highlight/index.js +31 -0
  119. package/dist/highlight/index.js.map +1 -0
  120. package/dist/highlight/language.d.ts +13 -0
  121. package/dist/highlight/language.d.ts.map +1 -0
  122. package/dist/highlight/language.js +41 -0
  123. package/dist/highlight/language.js.map +1 -0
  124. package/dist/highlight/normalise.d.ts +17 -0
  125. package/dist/highlight/normalise.d.ts.map +1 -0
  126. package/dist/highlight/normalise.js +37 -0
  127. package/dist/highlight/normalise.js.map +1 -0
  128. package/dist/highlight/types.d.ts +40 -0
  129. package/dist/highlight/types.d.ts.map +1 -0
  130. package/dist/highlight/types.js +2 -0
  131. package/dist/highlight/types.js.map +1 -0
  132. package/dist/image/index.d.ts +18 -0
  133. package/dist/image/index.d.ts.map +1 -0
  134. package/dist/image/index.js +42 -0
  135. package/dist/image/index.js.map +1 -0
  136. package/dist/image/jpeg.d.ts +10 -0
  137. package/dist/image/jpeg.d.ts.map +1 -0
  138. package/dist/image/jpeg.js +57 -0
  139. package/dist/image/jpeg.js.map +1 -0
  140. package/dist/image/load.d.ts +4 -0
  141. package/dist/image/load.d.ts.map +1 -0
  142. package/dist/image/load.js +60 -0
  143. package/dist/image/load.js.map +1 -0
  144. package/dist/image/media.d.ts +10 -0
  145. package/dist/image/media.d.ts.map +1 -0
  146. package/dist/image/media.js +37 -0
  147. package/dist/image/media.js.map +1 -0
  148. package/dist/image/resolve.d.ts +13 -0
  149. package/dist/image/resolve.d.ts.map +1 -0
  150. package/dist/image/resolve.js +38 -0
  151. package/dist/image/resolve.js.map +1 -0
  152. package/dist/image/size.d.ts +22 -0
  153. package/dist/image/size.d.ts.map +1 -0
  154. package/dist/image/size.js +60 -0
  155. package/dist/image/size.js.map +1 -0
  156. package/dist/image/svg.d.ts +12 -0
  157. package/dist/image/svg.d.ts.map +1 -0
  158. package/dist/image/svg.js +61 -0
  159. package/dist/image/svg.js.map +1 -0
  160. package/dist/image/uri.d.ts +9 -0
  161. package/dist/image/uri.d.ts.map +1 -0
  162. package/dist/image/uri.js +22 -0
  163. package/dist/image/uri.js.map +1 -0
  164. package/dist/index.d.ts +19 -9
  165. package/dist/index.d.ts.map +1 -1
  166. package/dist/index.js +13 -5
  167. package/dist/index.js.map +1 -1
  168. package/dist/layout/block.d.ts +37 -0
  169. package/dist/layout/block.d.ts.map +1 -0
  170. package/dist/layout/block.js +26 -0
  171. package/dist/layout/block.js.map +1 -0
  172. package/dist/layout/box.d.ts +20 -0
  173. package/dist/layout/box.d.ts.map +1 -0
  174. package/dist/layout/box.js +61 -0
  175. package/dist/layout/box.js.map +1 -0
  176. package/dist/layout/distribute.d.ts +15 -0
  177. package/dist/layout/distribute.d.ts.map +1 -0
  178. package/dist/layout/distribute.js +30 -0
  179. package/dist/layout/distribute.js.map +1 -0
  180. package/dist/layout/image.d.ts +42 -0
  181. package/dist/layout/image.d.ts.map +1 -0
  182. package/dist/layout/image.js +34 -0
  183. package/dist/layout/image.js.map +1 -0
  184. package/dist/layout/index.d.ts +40 -0
  185. package/dist/layout/index.d.ts.map +1 -0
  186. package/dist/layout/index.js +30 -0
  187. package/dist/layout/index.js.map +1 -0
  188. package/dist/layout/lines.d.ts +45 -0
  189. package/dist/layout/lines.d.ts.map +1 -0
  190. package/dist/layout/lines.js +71 -0
  191. package/dist/layout/lines.js.map +1 -0
  192. package/dist/layout/measure.d.ts +11 -0
  193. package/dist/layout/measure.d.ts.map +1 -0
  194. package/dist/layout/measure.js +11 -0
  195. package/dist/layout/measure.js.map +1 -0
  196. package/dist/layout/panel.d.ts +20 -0
  197. package/dist/layout/panel.d.ts.map +1 -0
  198. package/dist/layout/panel.js +22 -0
  199. package/dist/layout/panel.js.map +1 -0
  200. package/dist/layout/row.d.ts +15 -0
  201. package/dist/layout/row.d.ts.map +1 -0
  202. package/dist/layout/row.js +20 -0
  203. package/dist/layout/row.js.map +1 -0
  204. package/dist/layout/scrim.d.ts +23 -0
  205. package/dist/layout/scrim.d.ts.map +1 -0
  206. package/dist/layout/scrim.js +38 -0
  207. package/dist/layout/scrim.js.map +1 -0
  208. package/dist/layout/stack.d.ts +14 -0
  209. package/dist/layout/stack.d.ts.map +1 -0
  210. package/dist/layout/stack.js +19 -0
  211. package/dist/layout/stack.js.map +1 -0
  212. package/dist/layout/types.d.ts +49 -0
  213. package/dist/layout/types.d.ts.map +1 -0
  214. package/dist/layout/types.js +2 -0
  215. package/dist/layout/types.js.map +1 -0
  216. package/dist/manifest/build.d.ts +14 -0
  217. package/dist/manifest/build.d.ts.map +1 -0
  218. package/dist/manifest/build.js +43 -0
  219. package/dist/manifest/build.js.map +1 -0
  220. package/dist/manifest/index.d.ts +27 -0
  221. package/dist/manifest/index.d.ts.map +1 -0
  222. package/dist/manifest/index.js +31 -0
  223. package/dist/manifest/index.js.map +1 -0
  224. package/dist/manifest/order.d.ts +12 -0
  225. package/dist/manifest/order.d.ts.map +1 -0
  226. package/dist/manifest/order.js +17 -0
  227. package/dist/manifest/order.js.map +1 -0
  228. package/dist/manifest/page.d.ts +24 -0
  229. package/dist/manifest/page.d.ts.map +1 -0
  230. package/dist/manifest/page.js +55 -0
  231. package/dist/manifest/page.js.map +1 -0
  232. package/dist/measure/estimate.d.ts +10 -0
  233. package/dist/measure/estimate.d.ts.map +1 -0
  234. package/dist/measure/estimate.js +58 -0
  235. package/dist/measure/estimate.js.map +1 -0
  236. package/dist/measure/faces.d.ts +15 -0
  237. package/dist/measure/faces.d.ts.map +1 -0
  238. package/dist/measure/faces.js +70 -0
  239. package/dist/measure/faces.js.map +1 -0
  240. package/dist/measure/index.d.ts +16 -0
  241. package/dist/measure/index.d.ts.map +1 -0
  242. package/dist/measure/index.js +0 -0
  243. package/dist/measure/index.js.map +1 -0
  244. package/dist/measure/runs.d.ts +17 -0
  245. package/dist/measure/runs.d.ts.map +1 -0
  246. package/dist/measure/runs.js +39 -0
  247. package/dist/measure/runs.js.map +1 -0
  248. package/dist/measure/select.d.ts +13 -0
  249. package/dist/measure/select.d.ts.map +1 -0
  250. package/dist/measure/select.js +47 -0
  251. package/dist/measure/select.js.map +1 -0
  252. package/dist/meta/html.d.ts +14 -0
  253. package/dist/meta/html.d.ts.map +1 -0
  254. package/dist/meta/html.js +24 -0
  255. package/dist/meta/html.js.map +1 -0
  256. package/dist/meta/index.d.ts +11 -0
  257. package/dist/meta/index.d.ts.map +1 -0
  258. package/dist/meta/index.js +11 -0
  259. package/dist/meta/index.js.map +1 -0
  260. package/dist/meta/tags.d.ts +21 -0
  261. package/dist/meta/tags.d.ts.map +1 -0
  262. package/dist/meta/tags.js +72 -0
  263. package/dist/meta/tags.js.map +1 -0
  264. package/dist/meta/url.d.ts +15 -0
  265. package/dist/meta/url.d.ts.map +1 -0
  266. package/dist/meta/url.js +34 -0
  267. package/dist/meta/url.js.map +1 -0
  268. package/dist/placement/check.d.ts +16 -0
  269. package/dist/placement/check.d.ts.map +1 -0
  270. package/dist/placement/check.js +40 -0
  271. package/dist/placement/check.js.map +1 -0
  272. package/dist/placement/index.d.ts +29 -0
  273. package/dist/placement/index.d.ts.map +1 -0
  274. package/dist/placement/index.js +61 -0
  275. package/dist/placement/index.js.map +1 -0
  276. package/dist/placement/relative.d.ts +31 -0
  277. package/dist/placement/relative.d.ts.map +1 -0
  278. package/dist/placement/relative.js +53 -0
  279. package/dist/placement/relative.js.map +1 -0
  280. package/dist/pool.d.ts +18 -0
  281. package/dist/pool.d.ts.map +1 -0
  282. package/dist/pool.js +56 -0
  283. package/dist/pool.js.map +1 -0
  284. package/dist/props.d.ts +7 -0
  285. package/dist/props.d.ts.map +1 -0
  286. package/dist/props.js +17 -0
  287. package/dist/props.js.map +1 -0
  288. package/dist/render/index.d.ts +10 -0
  289. package/dist/render/index.d.ts.map +1 -0
  290. package/dist/render/index.js +27 -0
  291. package/dist/render/index.js.map +1 -0
  292. package/dist/render/png.d.ts +10 -0
  293. package/dist/render/png.d.ts.map +1 -0
  294. package/dist/render/png.js +30 -0
  295. package/dist/render/png.js.map +1 -0
  296. package/dist/render/svg.d.ts +12 -0
  297. package/dist/render/svg.d.ts.map +1 -0
  298. package/dist/render/svg.js +35 -0
  299. package/dist/render/svg.js.map +1 -0
  300. package/dist/render/template.d.ts +9 -0
  301. package/dist/render/template.d.ts.map +1 -0
  302. package/dist/render/template.js +17 -0
  303. package/dist/render/template.js.map +1 -0
  304. package/dist/render.d.ts +6 -2
  305. package/dist/render.d.ts.map +1 -1
  306. package/dist/render.js +31 -10
  307. package/dist/render.js.map +1 -1
  308. package/dist/stamp/chunk.d.ts +16 -0
  309. package/dist/stamp/chunk.d.ts.map +1 -0
  310. package/dist/stamp/chunk.js +46 -0
  311. package/dist/stamp/chunk.js.map +1 -0
  312. package/dist/stamp/config-digest.d.ts +11 -0
  313. package/dist/stamp/config-digest.d.ts.map +1 -0
  314. package/dist/stamp/config-digest.js +62 -0
  315. package/dist/stamp/config-digest.js.map +1 -0
  316. package/dist/stamp/digest.d.ts +8 -0
  317. package/dist/stamp/digest.d.ts.map +1 -0
  318. package/dist/stamp/digest.js +20 -0
  319. package/dist/stamp/digest.js.map +1 -0
  320. package/dist/stamp/index.d.ts +20 -0
  321. package/dist/stamp/index.d.ts.map +1 -0
  322. package/dist/stamp/index.js +40 -0
  323. package/dist/stamp/index.js.map +1 -0
  324. package/dist/stamp/read.d.ts +7 -0
  325. package/dist/stamp/read.d.ts.map +1 -0
  326. package/dist/stamp/read.js +62 -0
  327. package/dist/stamp/read.js.map +1 -0
  328. package/dist/stamp.d.ts +29 -0
  329. package/dist/stamp.d.ts.map +1 -0
  330. package/dist/stamp.js +198 -0
  331. package/dist/stamp.js.map +1 -0
  332. package/dist/templates/attribution.d.ts +17 -0
  333. package/dist/templates/attribution.d.ts.map +1 -0
  334. package/dist/templates/attribution.js +39 -0
  335. package/dist/templates/attribution.js.map +1 -0
  336. package/dist/templates/banner/badge.d.ts +7 -0
  337. package/dist/templates/banner/badge.d.ts.map +1 -0
  338. package/dist/templates/banner/badge.js +21 -0
  339. package/dist/templates/banner/badge.js.map +1 -0
  340. package/dist/templates/banner/index.d.ts +12 -0
  341. package/dist/templates/banner/index.d.ts.map +1 -0
  342. package/dist/templates/banner/index.js +68 -0
  343. package/dist/templates/banner/index.js.map +1 -0
  344. package/dist/templates/banner/lines.d.ts +22 -0
  345. package/dist/templates/banner/lines.d.ts.map +1 -0
  346. package/dist/templates/banner/lines.js +35 -0
  347. package/dist/templates/banner/lines.js.map +1 -0
  348. package/dist/templates/banner/version.d.ts +9 -0
  349. package/dist/templates/banner/version.d.ts.map +1 -0
  350. package/dist/templates/banner/version.js +21 -0
  351. package/dist/templates/banner/version.js.map +1 -0
  352. package/dist/templates/card/index.d.ts +10 -0
  353. package/dist/templates/card/index.d.ts.map +1 -0
  354. package/dist/templates/card/index.js +55 -0
  355. package/dist/templates/card/index.js.map +1 -0
  356. package/dist/templates/card/lines.d.ts +21 -0
  357. package/dist/templates/card/lines.d.ts.map +1 -0
  358. package/dist/templates/card/lines.js +36 -0
  359. package/dist/templates/card/lines.js.map +1 -0
  360. package/dist/templates/code/chrome.d.ts +13 -0
  361. package/dist/templates/code/chrome.d.ts.map +1 -0
  362. package/dist/templates/code/chrome.js +33 -0
  363. package/dist/templates/code/chrome.js.map +1 -0
  364. package/dist/templates/code/clip.d.ts +18 -0
  365. package/dist/templates/code/clip.d.ts.map +1 -0
  366. package/dist/templates/code/clip.js +44 -0
  367. package/dist/templates/code/clip.js.map +1 -0
  368. package/dist/templates/code/ellipsis.d.ts +3 -0
  369. package/dist/templates/code/ellipsis.d.ts.map +1 -0
  370. package/dist/templates/code/ellipsis.js +3 -0
  371. package/dist/templates/code/ellipsis.js.map +1 -0
  372. package/dist/templates/code/fit.d.ts +27 -0
  373. package/dist/templates/code/fit.d.ts.map +1 -0
  374. package/dist/templates/code/fit.js +59 -0
  375. package/dist/templates/code/fit.js.map +1 -0
  376. package/dist/templates/code/index.d.ts +12 -0
  377. package/dist/templates/code/index.d.ts.map +1 -0
  378. package/dist/templates/code/index.js +65 -0
  379. package/dist/templates/code/index.js.map +1 -0
  380. package/dist/templates/code/layout.d.ts +21 -0
  381. package/dist/templates/code/layout.d.ts.map +1 -0
  382. package/dist/templates/code/layout.js +21 -0
  383. package/dist/templates/code/layout.js.map +1 -0
  384. package/dist/templates/code/panel.d.ts +30 -0
  385. package/dist/templates/code/panel.d.ts.map +1 -0
  386. package/dist/templates/code/panel.js +52 -0
  387. package/dist/templates/code/panel.js.map +1 -0
  388. package/dist/templates/code/plate.d.ts +17 -0
  389. package/dist/templates/code/plate.d.ts.map +1 -0
  390. package/dist/templates/code/plate.js +34 -0
  391. package/dist/templates/code/plate.js.map +1 -0
  392. package/dist/templates/code/spans.d.ts +19 -0
  393. package/dist/templates/code/spans.d.ts.map +1 -0
  394. package/dist/templates/code/spans.js +36 -0
  395. package/dist/templates/code/spans.js.map +1 -0
  396. package/dist/templates/code/warn.d.ts +11 -0
  397. package/dist/templates/code/warn.d.ts.map +1 -0
  398. package/dist/templates/code/warn.js +24 -0
  399. package/dist/templates/code/warn.js.map +1 -0
  400. package/dist/templates/code/width.d.ts +10 -0
  401. package/dist/templates/code/width.d.ts.map +1 -0
  402. package/dist/templates/code/width.js +26 -0
  403. package/dist/templates/code/width.js.map +1 -0
  404. package/dist/templates/footer.d.ts +29 -0
  405. package/dist/templates/footer.d.ts.map +1 -0
  406. package/dist/templates/footer.js +35 -0
  407. package/dist/templates/footer.js.map +1 -0
  408. package/dist/templates/index.d.ts +4 -4
  409. package/dist/templates/index.d.ts.map +1 -1
  410. package/dist/templates/index.js +7 -7
  411. package/dist/templates/index.js.map +1 -1
  412. package/dist/templates/logo.d.ts +15 -0
  413. package/dist/templates/logo.d.ts.map +1 -0
  414. package/dist/templates/logo.js +30 -0
  415. package/dist/templates/logo.js.map +1 -0
  416. package/dist/templates/measure.d.ts +11 -0
  417. package/dist/templates/measure.d.ts.map +1 -0
  418. package/dist/templates/measure.js +11 -0
  419. package/dist/templates/measure.js.map +1 -0
  420. package/dist/templates/props.d.ts +2 -2
  421. package/dist/templates/props.js +2 -2
  422. package/dist/templates/text.d.ts +37 -0
  423. package/dist/templates/text.d.ts.map +1 -0
  424. package/dist/templates/text.js +26 -0
  425. package/dist/templates/text.js.map +1 -0
  426. package/dist/text/break.d.ts +11 -0
  427. package/dist/text/break.d.ts.map +1 -0
  428. package/dist/text/break.js +30 -0
  429. package/dist/text/break.js.map +1 -0
  430. package/dist/text/element.d.ts +18 -0
  431. package/dist/text/element.d.ts.map +1 -0
  432. package/dist/text/element.js +19 -0
  433. package/dist/text/element.js.map +1 -0
  434. package/dist/text/escape.d.ts +5 -0
  435. package/dist/text/escape.d.ts.map +1 -0
  436. package/dist/text/escape.js +12 -0
  437. package/dist/text/escape.js.map +1 -0
  438. package/dist/text/fit.d.ts +30 -0
  439. package/dist/text/fit.d.ts.map +1 -0
  440. package/dist/text/fit.js +29 -0
  441. package/dist/text/fit.js.map +1 -0
  442. package/dist/text/index.d.ts +9 -0
  443. package/dist/text/index.d.ts.map +1 -0
  444. package/dist/text/index.js +6 -0
  445. package/dist/text/index.js.map +1 -0
  446. package/dist/text/stack.d.ts +24 -0
  447. package/dist/text/stack.d.ts.map +1 -0
  448. package/dist/text/stack.js +18 -0
  449. package/dist/text/stack.js.map +1 -0
  450. package/dist/text/wrap.d.ts +22 -0
  451. package/dist/text/wrap.d.ts.map +1 -0
  452. package/dist/text/wrap.js +41 -0
  453. package/dist/text/wrap.js.map +1 -0
  454. package/dist/types.d.ts +458 -18
  455. package/dist/types.d.ts.map +1 -1
  456. package/dist/validate/check.d.ts +13 -0
  457. package/dist/validate/check.d.ts.map +1 -0
  458. package/dist/validate/check.js +34 -0
  459. package/dist/validate/check.js.map +1 -0
  460. package/dist/validate/index.d.ts +15 -0
  461. package/dist/validate/index.d.ts.map +1 -0
  462. package/dist/validate/index.js +42 -0
  463. package/dist/validate/index.js.map +1 -0
  464. package/dist/validate/keys.d.ts +75 -0
  465. package/dist/validate/keys.d.ts.map +1 -0
  466. package/dist/validate/keys.js +203 -0
  467. package/dist/validate/keys.js.map +1 -0
  468. package/dist/validate/overrides.d.ts +5 -0
  469. package/dist/validate/overrides.d.ts.map +1 -0
  470. package/dist/validate/overrides.js +43 -0
  471. package/dist/validate/overrides.js.map +1 -0
  472. package/dist/validate/placement.d.ts +10 -0
  473. package/dist/validate/placement.d.ts.map +1 -0
  474. package/dist/validate/placement.js +38 -0
  475. package/dist/validate/placement.js.map +1 -0
  476. package/dist/validate/sizes.d.ts +9 -0
  477. package/dist/validate/sizes.d.ts.map +1 -0
  478. package/dist/validate/sizes.js +27 -0
  479. package/dist/validate/sizes.js.map +1 -0
  480. package/dist/validate/suggest.d.ts +10 -0
  481. package/dist/validate/suggest.d.ts.map +1 -0
  482. package/dist/validate/suggest.js +73 -0
  483. package/dist/validate/suggest.js.map +1 -0
  484. package/dist/validate/values.d.ts +21 -0
  485. package/dist/validate/values.d.ts.map +1 -0
  486. package/dist/validate/values.js +71 -0
  487. package/dist/validate/values.js.map +1 -0
  488. package/dist/validate.d.ts +15 -0
  489. package/dist/validate.d.ts.map +1 -0
  490. package/dist/validate.js +300 -0
  491. package/dist/validate.js.map +1 -0
  492. package/package.json +19 -6
@@ -0,0 +1,36 @@
1
+ import { escapeXml } from "../../layout/index.js";
2
+ /** Fraction of the font size the baseline sits below the glyph box top. */
3
+ const ascentRatio = 0.78;
4
+ function tokenSpan(token, x, charWidth, foreground) {
5
+ const fill = token.color ?? foreground;
6
+ const opacity = token.opacity === undefined
7
+ ? ""
8
+ : ` fill-opacity="${String(token.opacity)}"`;
9
+ const weight = token.bold ? ` font-weight="700"` : "";
10
+ const style = token.italic ? ` font-style="italic"` : "";
11
+ return (`<tspan x="${String(Math.round(x + token.column * charWidth))}"` +
12
+ ` fill="${fill}"${opacity}${weight}${style}>` +
13
+ `${escapeXml(token.text)}</tspan>`);
14
+ }
15
+ /**
16
+ * The snippet as one `<text>` element per line, each token positioned
17
+ * absolutely from its character column so indentation survives SVG text flow.
18
+ */
19
+ export function codeBody(lines, metrics) {
20
+ const { originX, originY, fontSize, charWidth, step } = metrics;
21
+ return lines
22
+ .map((tokens, index) => {
23
+ if (tokens.length === 0) {
24
+ return "";
25
+ }
26
+ const baseline = Math.round(originY + index * step + (step - fontSize) / 2 + fontSize * ascentRatio);
27
+ const spans = tokens
28
+ .map((token) => tokenSpan(token, originX, charWidth, metrics.foreground))
29
+ .join("");
30
+ return (`<text y="${String(baseline)}" xml:space="preserve"` +
31
+ ` font-family="${escapeXml(metrics.fontFamily)}"` +
32
+ ` font-size="${String(fontSize)}">${spans}</text>`);
33
+ })
34
+ .join("");
35
+ }
36
+ //# sourceMappingURL=spans.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spans.js","sourceRoot":"","sources":["../../../src/templates/code/spans.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,2EAA2E;AAC3E,MAAM,WAAW,GAAG,IAAI,CAAC;AAEzB,SAAS,SAAS,CAChB,KAAgB,EAChB,CAAS,EACT,SAAiB,EACjB,UAAkB;IAElB,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,IAAI,UAAU,CAAC;IACvC,MAAM,OAAO,GACX,KAAK,CAAC,OAAO,KAAK,SAAS;QACzB,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,kBAAkB,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;IACjD,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;IACtD,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE,CAAC;IAEzD,OAAO,CACL,aAAa,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG;QAChE,UAAU,IAAI,IAAI,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG;QAC7C,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CACnC,CAAC;AACJ,CAAC;AAeD;;;GAGG;AACH,MAAM,UAAU,QAAQ,CACtB,KAAwC,EACxC,OAAoB;IAEpB,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IAEhE,OAAO,KAAK;SACT,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QACrB,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CACzB,OAAO,GAAG,KAAK,GAAG,IAAI,GAAG,CAAC,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,QAAQ,GAAG,WAAW,CACxE,CAAC;QACF,MAAM,KAAK,GAAG,MAAM;aACjB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACb,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,UAAU,CAAC,CACzD;aACA,IAAI,CAAC,EAAE,CAAC,CAAC;QAEZ,OAAO,CACL,YAAY,MAAM,CAAC,QAAQ,CAAC,wBAAwB;YACpD,iBAAiB,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG;YACjD,eAAe,MAAM,CAAC,QAAQ,CAAC,KAAK,KAAK,SAAS,CACnD,CAAC;IACJ,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { Dimensions, ResolvedConfig } from "../../types.js";
2
+ /**
3
+ * Tell the author when the snippet did not fit. Nothing in a finished image
4
+ * says the sample continued, so silent truncation is how a half-a-function
5
+ * share card ends up on someone else's timeline.
6
+ */
7
+ export declare function warnIfTruncated(config: ResolvedConfig, dimensions: Dimensions, counts: {
8
+ readonly dropped: number;
9
+ readonly clipped: number;
10
+ }, total: number): void;
11
+ //# sourceMappingURL=warn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"warn.d.ts","sourceRoot":"","sources":["../../../src/templates/code/warn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAMjE;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAC9D,KAAK,EAAE,MAAM,GACZ,IAAI,CAoBN"}
@@ -0,0 +1,24 @@
1
+ function plural(count, noun) {
2
+ return `${String(count)} ${noun}${count === 1 ? "" : "s"}`;
3
+ }
4
+ /**
5
+ * Tell the author when the snippet did not fit. Nothing in a finished image
6
+ * says the sample continued, so silent truncation is how a half-a-function
7
+ * share card ends up on someone else's timeline.
8
+ */
9
+ export function warnIfTruncated(config, dimensions, counts, total) {
10
+ const parts = [];
11
+ if (counts.dropped > 0) {
12
+ parts.push(`${String(counts.dropped)} of ${plural(total, "line")} dropped`);
13
+ }
14
+ if (counts.clipped > 0) {
15
+ parts.push(`${plural(counts.clipped, "line")} clipped to the panel width`);
16
+ }
17
+ if (parts.length === 0) {
18
+ return;
19
+ }
20
+ config.onWarning(`code snippet does not fit the ${String(dimensions.width)}x${String(dimensions.height)}` +
21
+ ` image at a legible size: ${parts.join(", ")}.` +
22
+ ` Shorten the sample, or lower code.minFontScale to fit it in smaller.`);
23
+ }
24
+ //# sourceMappingURL=warn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"warn.js","sourceRoot":"","sources":["../../../src/templates/code/warn.ts"],"names":[],"mappings":"AAEA,SAAS,MAAM,CAAC,KAAa,EAAE,IAAY;IACzC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AAC7D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAsB,EACtB,UAAsB,EACtB,MAA8D,EAC9D,KAAa;IAEb,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,IAAI,MAAM,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;IAC9E,CAAC;IAED,IAAI,MAAM,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,6BAA6B,CAAC,CAAC;IAC7E,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO;IACT,CAAC;IAED,MAAM,CAAC,SAAS,CACd,iCAAiC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;QACtF,6BAA6B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;QAChD,uEAAuE,CAC1E,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { MeasureText } from "../../types.js";
2
+ /**
3
+ * Width of one character as a fraction of the font size.
4
+ *
5
+ * The template lays every token out on a character grid, so this is what says
6
+ * where each column falls. Measuring a digit is enough because the face is
7
+ * monospace: whichever character is measured, the advance is the same.
8
+ */
9
+ export declare function charWidthRatio(measure: MeasureText, fontFamily: string): number;
10
+ //# sourceMappingURL=width.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"width.d.ts","sourceRoot":"","sources":["../../../src/templates/code/width.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAalD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,GACjB,MAAM,CAOR"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Advance width to assume when the monospace stack names no font the build
3
+ * loaded. `0.6` suits most monospace faces, including Source Code Pro, Menlo
4
+ * and DejaVu Sans Mono; Consolas is nearer `0.55`.
5
+ *
6
+ * This used to be `config.code.charWidthRatio`, a number every project had to
7
+ * work out for itself and keep in step with its font. It is a fallback now:
8
+ * supply the face as a file and the real advance is read from it.
9
+ */
10
+ const fallbackRatio = 0.6;
11
+ /**
12
+ * Width of one character as a fraction of the font size.
13
+ *
14
+ * The template lays every token out on a character grid, so this is what says
15
+ * where each column falls. Measuring a digit is enough because the face is
16
+ * monospace: whichever character is measured, the advance is the same.
17
+ */
18
+ export function charWidthRatio(measure, fontFamily) {
19
+ return measure("0", {
20
+ fontFamily,
21
+ fontSize: 1,
22
+ fontWeight: 400,
23
+ fallbackRatio,
24
+ });
25
+ }
26
+ //# sourceMappingURL=width.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"width.js","sourceRoot":"","sources":["../../../src/templates/code/width.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAoB,EACpB,UAAkB;IAElB,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,UAAU;QACV,QAAQ,EAAE,CAAC;QACX,UAAU,EAAE,GAAG;QACf,aAAa;KACd,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { ResolvedConfig } from "../types.js";
2
+ /**
3
+ * Where and how a template wants its footer drawn. Every template places the
4
+ * footer differently; what they share is that a config with no footer, or an
5
+ * empty one, draws nothing at all.
6
+ */
7
+ export interface FooterPlacement {
8
+ readonly x: number;
9
+ readonly y: number;
10
+ readonly fontSize: number;
11
+ readonly opacity: number;
12
+ readonly anchor?: "start" | "middle" | "end";
13
+ }
14
+ /**
15
+ * The baseline of a footer sitting on the bottom margin.
16
+ *
17
+ * The margin is where the line's ink stops rather than where its baseline
18
+ * goes, so the last line of an image keeps the same clear space below it as
19
+ * the content beside it has either side, and the descenders stay inside it.
20
+ */
21
+ export declare function footerBaseline(height: number, pad: number, fontSize: number): number;
22
+ /** Whether the config carries a footer worth drawing. */
23
+ export declare function hasFooter(config: ResolvedConfig): boolean;
24
+ /**
25
+ * The configured footer as a `<text>` element, or an empty string when there
26
+ * is none. Templates call this unconditionally and let it decide.
27
+ */
28
+ export declare function footerElement(config: ResolvedConfig, placement: FooterPlacement): string;
29
+ //# sourceMappingURL=footer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"footer.d.ts","sourceRoot":"","sources":["../../src/templates/footer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;CAC9C;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,GACf,MAAM,CAER;AAED,yDAAyD;AACzD,wBAAgB,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAEzD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,eAAe,GACzB,MAAM,CAeR"}
@@ -0,0 +1,35 @@
1
+ import { baselineFor, textElement } from "../layout/index.js";
2
+ /**
3
+ * The baseline of a footer sitting on the bottom margin.
4
+ *
5
+ * The margin is where the line's ink stops rather than where its baseline
6
+ * goes, so the last line of an image keeps the same clear space below it as
7
+ * the content beside it has either side, and the descenders stay inside it.
8
+ */
9
+ export function footerBaseline(height, pad, fontSize) {
10
+ return baselineFor(height - pad - fontSize, fontSize);
11
+ }
12
+ /** Whether the config carries a footer worth drawing. */
13
+ export function hasFooter(config) {
14
+ return config.footer !== undefined && config.footer !== "";
15
+ }
16
+ /**
17
+ * The configured footer as a `<text>` element, or an empty string when there
18
+ * is none. Templates call this unconditionally and let it decide.
19
+ */
20
+ export function footerElement(config, placement) {
21
+ if (!hasFooter(config)) {
22
+ return "";
23
+ }
24
+ return textElement(config.footer ?? "", {
25
+ x: placement.x,
26
+ y: placement.y,
27
+ fontFamily: config.fontFamily,
28
+ fontSize: placement.fontSize,
29
+ fontWeight: 500,
30
+ fill: config.colors.foreground,
31
+ fillOpacity: placement.opacity,
32
+ ...(placement.anchor !== undefined && { anchor: placement.anchor }),
33
+ });
34
+ }
35
+ //# sourceMappingURL=footer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"footer.js","sourceRoot":"","sources":["../../src/templates/footer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAgB9D;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAc,EACd,GAAW,EACX,QAAgB;IAEhB,OAAO,WAAW,CAAC,MAAM,GAAG,GAAG,GAAG,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACxD,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,SAAS,CAAC,MAAsB;IAC9C,OAAO,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,EAAE,CAAC;AAC7D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAsB,EACtB,SAA0B;IAE1B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,WAAW,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,EAAE;QACtC,CAAC,EAAE,SAAS,CAAC,CAAC;QACd,CAAC,EAAE,SAAS,CAAC,CAAC;QACd,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,QAAQ,EAAE,SAAS,CAAC,QAAQ;QAC5B,UAAU,EAAE,GAAG;QACf,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU;QAC9B,WAAW,EAAE,SAAS,CAAC,OAAO;QAC9B,GAAG,CAAC,SAAS,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC;KACpE,CAAC,CAAC;AACL,CAAC"}
@@ -4,8 +4,8 @@ import type { Template } from "../types.js";
4
4
  * via `config.templates`.
5
5
  */
6
6
  export declare const builtinTemplates: Readonly<Record<string, Template>>;
7
- export { bannerTemplate } from "./banner.js";
8
- export { cardTemplate } from "./card.js";
9
- export { codeTemplate } from "./code.js";
10
- export { optionalString } from "./props.js";
7
+ export { bannerTemplate } from "./banner/index.js";
8
+ export { cardTemplate } from "./card/index.js";
9
+ export { codeTemplate } from "./code/index.js";
10
+ export { optionalString } from "../props.js";
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK5C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAI/D,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK5C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAI/D,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
@@ -1,6 +1,6 @@
1
- import { bannerTemplate } from "./banner.js";
2
- import { cardTemplate } from "./card.js";
3
- import { codeTemplate } from "./code.js";
1
+ import { bannerTemplate } from "./banner/index.js";
2
+ import { cardTemplate } from "./card/index.js";
3
+ import { codeTemplate } from "./code/index.js";
4
4
  /**
5
5
  * Templates registered out of the box. Projects can add to or override these
6
6
  * via `config.templates`.
@@ -10,8 +10,8 @@ export const builtinTemplates = {
10
10
  [cardTemplate.name]: cardTemplate,
11
11
  [codeTemplate.name]: codeTemplate,
12
12
  };
13
- export { bannerTemplate } from "./banner.js";
14
- export { cardTemplate } from "./card.js";
15
- export { codeTemplate } from "./code.js";
16
- export { optionalString } from "./props.js";
13
+ export { bannerTemplate } from "./banner/index.js";
14
+ export { cardTemplate } from "./card/index.js";
15
+ export { codeTemplate } from "./code/index.js";
16
+ export { optionalString } from "../props.js";
17
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAuC;IAClE,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,cAAc;IACrC,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,YAAY;IACjC,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,YAAY;CAClC,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAuC;IAClE,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,cAAc;IACrC,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,YAAY;IACjC,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,YAAY;CAClC,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { Rect } from "../layout/index.js";
2
+ import type { Dimensions, ImageAsset } from "../types.js";
3
+ /**
4
+ * Where the logo goes, or nothing where there is none.
5
+ *
6
+ * Its height comes from the image being drawn rather than from the logo's own
7
+ * pixels, so the same file works on a square and a landscape, and its width
8
+ * follows from the proportions of the picture. A logo whose format does not
9
+ * state its size is drawn in a square, where a wordmark will sit small in the
10
+ * middle rather than being stretched to fit.
11
+ */
12
+ export declare function logoRect(logo: ImageAsset | undefined, dimensions: Dimensions, pad: number, align: "start" | "middle"): Rect | undefined;
13
+ /** The logo drawn in the rectangle it was given, whole rather than cropped. */
14
+ export declare function logoElement(logo: ImageAsset | undefined, rect: Rect | undefined): string;
15
+ //# sourceMappingURL=logo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logo.d.ts","sourceRoot":"","sources":["../../src/templates/logo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAK1D;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,UAAU,GAAG,SAAS,EAC5B,UAAU,EAAE,UAAU,EACtB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,OAAO,GAAG,QAAQ,GACxB,IAAI,GAAG,SAAS,CAalB;AAED,+EAA+E;AAC/E,wBAAgB,WAAW,CACzB,IAAI,EAAE,UAAU,GAAG,SAAS,EAC5B,IAAI,EAAE,IAAI,GAAG,SAAS,GACrB,MAAM,CAIR"}
@@ -0,0 +1,30 @@
1
+ import { image } from "../layout/index.js";
2
+ /** The logo's height, as a fraction of the image's. */
3
+ const logoScale = 0.075;
4
+ /**
5
+ * Where the logo goes, or nothing where there is none.
6
+ *
7
+ * Its height comes from the image being drawn rather than from the logo's own
8
+ * pixels, so the same file works on a square and a landscape, and its width
9
+ * follows from the proportions of the picture. A logo whose format does not
10
+ * state its size is drawn in a square, where a wordmark will sit small in the
11
+ * middle rather than being stretched to fit.
12
+ */
13
+ export function logoRect(logo, dimensions, pad, align) {
14
+ if (logo === undefined) {
15
+ return undefined;
16
+ }
17
+ const height = Math.round(dimensions.height * logoScale);
18
+ const width = Math.round(height * logo.aspect);
19
+ const x = align === "middle"
20
+ ? Math.round((dimensions.width - width) / 2)
21
+ : dimensions.width - pad - width;
22
+ return { x, y: pad, width, height };
23
+ }
24
+ /** The logo drawn in the rectangle it was given, whole rather than cropped. */
25
+ export function logoElement(logo, rect) {
26
+ return logo === undefined || rect === undefined
27
+ ? ""
28
+ : image(rect, logo.href, { fit: "contain" });
29
+ }
30
+ //# sourceMappingURL=logo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logo.js","sourceRoot":"","sources":["../../src/templates/logo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAG3C,uDAAuD;AACvD,MAAM,SAAS,GAAG,KAAK,CAAC;AAExB;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CACtB,IAA4B,EAC5B,UAAsB,EACtB,GAAW,EACX,KAAyB;IAEzB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACzD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,CAAC,GACL,KAAK,KAAK,QAAQ;QAChB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5C,CAAC,CAAC,UAAU,CAAC,KAAK,GAAG,GAAG,GAAG,KAAK,CAAC;IAErC,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AACtC,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,WAAW,CACzB,IAA4B,EAC5B,IAAsB;IAEtB,OAAO,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS;QAC7C,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;AACjD,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { MeasureAt } from "../text/index.js";
2
+ import type { MeasureText } from "../types.js";
3
+ /**
4
+ * Bind a measurer to one family and weight, leaving only the size open.
5
+ *
6
+ * That is the shape fitting text wants, since choosing a size is the whole of
7
+ * what it varies, and it keeps a template from repeating the family and weight
8
+ * on every call.
9
+ */
10
+ export declare function measureIn(measure: MeasureText, fontFamily: string, fontWeight: number): MeasureAt;
11
+ //# sourceMappingURL=measure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measure.d.ts","sourceRoot":"","sources":["../../src/templates/measure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,SAAS,CAGX"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Bind a measurer to one family and weight, leaving only the size open.
3
+ *
4
+ * That is the shape fitting text wants, since choosing a size is the whole of
5
+ * what it varies, and it keeps a template from repeating the family and weight
6
+ * on every call.
7
+ */
8
+ export function measureIn(measure, fontFamily, fontWeight) {
9
+ return (text, fontSize) => measure(text, { fontFamily, fontSize, fontWeight });
10
+ }
11
+ //# sourceMappingURL=measure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measure.js","sourceRoot":"","sources":["../../src/templates/measure.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CACvB,OAAoB,EACpB,UAAkB,EAClB,UAAkB;IAElB,OAAO,CAAC,IAAY,EAAE,QAAgB,EAAU,EAAE,CAChD,OAAO,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;AACxD,CAAC"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Read a prop as a string, coercing the scalar types YAML frontmatter yields
3
- * (numbers, booleans) and returning `undefined` for anything else — templates
4
- * treat "not a usable string" and "absent" the same way.
3
+ * (numbers, booleans) and returning `undefined` for anything else, since
4
+ * templates treat "not a usable string" and "absent" the same way.
5
5
  */
6
6
  export declare function optionalString(value: unknown): string | undefined;
7
7
  //# sourceMappingURL=props.d.ts.map
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Read a prop as a string, coercing the scalar types YAML frontmatter yields
3
- * (numbers, booleans) and returning `undefined` for anything else — templates
4
- * treat "not a usable string" and "absent" the same way.
3
+ * (numbers, booleans) and returning `undefined` for anything else, since
4
+ * templates treat "not a usable string" and "absent" the same way.
5
5
  */
6
6
  export function optionalString(value) {
7
7
  if (typeof value === "string") {
@@ -0,0 +1,37 @@
1
+ import type { MeasureText } from "../types.js";
2
+ /** One group of a template's text: the space it has and how it is drawn. */
3
+ export interface TextBlock {
4
+ readonly maxWidth: number;
5
+ readonly maxLines: number;
6
+ readonly fontSize: number;
7
+ /**
8
+ * Fraction of `fontSize` this group may shrink to before it is cut instead.
9
+ * The title of a layout has the furthest to fall, because it is the line
10
+ * worth keeping whole; a subtitle that has shrunk much has stopped being
11
+ * readable in a feed, so it may as well lose its tail.
12
+ */
13
+ readonly floor: number;
14
+ readonly fontWeight: number;
15
+ }
16
+ /** A block along with how the lines it produces are drawn. */
17
+ export interface StyledBlock extends TextBlock {
18
+ readonly opacity: number;
19
+ /** Space inserted before the group's first line, to separate it from the last. */
20
+ readonly gapBefore?: number;
21
+ }
22
+ /** One line of a template's text block, ready to be stacked and drawn. */
23
+ export interface TextLine {
24
+ readonly text: string;
25
+ readonly fontSize: number;
26
+ readonly fontWeight: number;
27
+ readonly opacity: number;
28
+ readonly gapBefore?: number;
29
+ }
30
+ /**
31
+ * Fit one group of a template's text, from a prop that may not be there, and
32
+ * return its lines. Each group is fitted on its own, so a long title shrinking
33
+ * does not drag the subtitle down with it. A group whose prop is absent or
34
+ * empty produces no lines at all.
35
+ */
36
+ export declare function blockLines(value: unknown, measure: MeasureText, fontFamily: string, block: StyledBlock): TextLine[];
37
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/templates/text.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,4EAA4E;AAC5E,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,8DAA8D;AAC9D,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,kFAAkF;IAClF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,0EAA0E;AAC1E,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,WAAW,GACjB,QAAQ,EAAE,CAoBZ"}
@@ -0,0 +1,26 @@
1
+ import { fitText } from "../text/index.js";
2
+ import { measureIn } from "./measure.js";
3
+ import { optionalString } from "./props.js";
4
+ /**
5
+ * Fit one group of a template's text, from a prop that may not be there, and
6
+ * return its lines. Each group is fitted on its own, so a long title shrinking
7
+ * does not drag the subtitle down with it. A group whose prop is absent or
8
+ * empty produces no lines at all.
9
+ */
10
+ export function blockLines(value, measure, fontFamily, block) {
11
+ const fitted = fitText(optionalString(value) ?? "", measureIn(measure, fontFamily, block.fontWeight), {
12
+ maxWidth: block.maxWidth,
13
+ maxLines: block.maxLines,
14
+ fontSize: block.fontSize,
15
+ minFontSize: Math.round(block.fontSize * block.floor),
16
+ });
17
+ return fitted.lines.map((text, index) => ({
18
+ text,
19
+ fontSize: fitted.fontSize,
20
+ fontWeight: block.fontWeight,
21
+ opacity: block.opacity,
22
+ ...(index === 0 &&
23
+ block.gapBefore !== undefined && { gapBefore: block.gapBefore }),
24
+ }));
25
+ }
26
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/templates/text.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAiC5C;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACxB,KAAc,EACd,OAAoB,EACpB,UAAkB,EAClB,KAAkB;IAElB,MAAM,MAAM,GAAe,OAAO,CAChC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,EAC3B,SAAS,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,EAChD;QACE,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC;KACtD,CACF,CAAC;IAEF,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACxC,IAAI;QACJ,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,GAAG,CAAC,KAAK,KAAK,CAAC;YACb,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;KACnE,CAAC,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { MeasureLine } from "./wrap.js";
2
+ /**
3
+ * Break one word across as many lines as it takes, for a word that is wider
4
+ * than the line it has to fit on. A URL, a compound German noun, or a whole
5
+ * Japanese sentence, which has no spaces to break at in the first place.
6
+ *
7
+ * Always returns at least one piece, even where a single character is wider
8
+ * than the line: overflowing by one glyph beats looping forever.
9
+ */
10
+ export declare function breakWord(word: string, maxWidth: number, measure: MeasureLine): string[];
11
+ //# sourceMappingURL=break.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"break.d.ts","sourceRoot":"","sources":["../../src/text/break.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAS7C;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,WAAW,GACnB,MAAM,EAAE,CAgBV"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Grapheme segmentation, so a break never lands inside an emoji or between a
3
+ * letter and the accent that belongs to it. Built once, since a build breaks
4
+ * a great many words and the segmenter carries locale data with it.
5
+ */
6
+ const graphemes = new Intl.Segmenter(undefined, { granularity: "grapheme" });
7
+ /**
8
+ * Break one word across as many lines as it takes, for a word that is wider
9
+ * than the line it has to fit on. A URL, a compound German noun, or a whole
10
+ * Japanese sentence, which has no spaces to break at in the first place.
11
+ *
12
+ * Always returns at least one piece, even where a single character is wider
13
+ * than the line: overflowing by one glyph beats looping forever.
14
+ */
15
+ export function breakWord(word, maxWidth, measure) {
16
+ const pieces = [];
17
+ let current = "";
18
+ for (const { segment } of graphemes.segment(word)) {
19
+ const next = current + segment;
20
+ if (current !== "" && measure(next) > maxWidth) {
21
+ pieces.push(current);
22
+ current = segment;
23
+ }
24
+ else {
25
+ current = next;
26
+ }
27
+ }
28
+ return current === "" ? [word] : [...pieces, current];
29
+ }
30
+ //# sourceMappingURL=break.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"break.js","sourceRoot":"","sources":["../../src/text/break.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC;AAE7E;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CACvB,IAAY,EACZ,QAAgB,EAChB,OAAoB;IAEpB,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,KAAK,MAAM,EAAE,OAAO,EAAE,IAAI,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,GAAG,OAAO,GAAG,OAAO,CAAC;QAE/B,IAAI,OAAO,KAAK,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,QAAQ,EAAE,CAAC;YAC/C,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACrB,OAAO,GAAG,OAAO,CAAC;QACpB,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;IACH,CAAC;IAED,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Attributes accepted by {@link textElement}. Colour and opacity are optional.
3
+ */
4
+ export interface TextAttributes {
5
+ readonly x: number;
6
+ readonly y: number;
7
+ readonly fontFamily: string;
8
+ readonly fontSize: number;
9
+ readonly fontWeight: number;
10
+ readonly fill: string;
11
+ readonly fillOpacity?: number;
12
+ readonly anchor?: "start" | "middle" | "end";
13
+ }
14
+ /**
15
+ * Build a single `<text>` element. The content is XML-escaped.
16
+ */
17
+ export declare function textElement(content: string, attributes: TextAttributes): string;
18
+ //# sourceMappingURL=element.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../src/text/element.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;CAC9C;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,cAAc,GACzB,MAAM,CAkBR"}
@@ -0,0 +1,19 @@
1
+ import { escapeXml } from "./escape.js";
2
+ /**
3
+ * Build a single `<text>` element. The content is XML-escaped.
4
+ */
5
+ export function textElement(content, attributes) {
6
+ const opacity = attributes.fillOpacity === undefined
7
+ ? ""
8
+ : ` fill-opacity="${String(attributes.fillOpacity)}"`;
9
+ const anchor = attributes.anchor === undefined
10
+ ? ""
11
+ : ` text-anchor="${attributes.anchor}"`;
12
+ return (`<text x="${String(attributes.x)}" y="${String(attributes.y)}"` +
13
+ ` font-family="${escapeXml(attributes.fontFamily)}"` +
14
+ ` font-size="${String(attributes.fontSize)}"` +
15
+ ` font-weight="${String(attributes.fontWeight)}"` +
16
+ ` fill="${attributes.fill}"${opacity}${anchor}>` +
17
+ `${escapeXml(content)}</text>`);
18
+ }
19
+ //# sourceMappingURL=element.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"element.js","sourceRoot":"","sources":["../../src/text/element.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAgBxC;;GAEG;AACH,MAAM,UAAU,WAAW,CACzB,OAAe,EACf,UAA0B;IAE1B,MAAM,OAAO,GACX,UAAU,CAAC,WAAW,KAAK,SAAS;QAClC,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,kBAAkB,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC;IAC1D,MAAM,MAAM,GACV,UAAU,CAAC,MAAM,KAAK,SAAS;QAC7B,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,iBAAiB,UAAU,CAAC,MAAM,GAAG,CAAC;IAE5C,OAAO,CACL,YAAY,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG;QAC/D,iBAAiB,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG;QACpD,eAAe,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG;QAC7C,iBAAiB,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG;QACjD,UAAU,UAAU,CAAC,IAAI,IAAI,OAAO,GAAG,MAAM,GAAG;QAChD,GAAG,SAAS,CAAC,OAAO,CAAC,SAAS,CAC/B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Escape a string for safe inclusion in SVG/XML text content or attributes.
3
+ */
4
+ export declare function escapeXml(value: string): string;
5
+ //# sourceMappingURL=escape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"escape.d.ts","sourceRoot":"","sources":["../../src/text/escape.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO/C"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Escape a string for safe inclusion in SVG/XML text content or attributes.
3
+ */
4
+ export function escapeXml(value) {
5
+ return value
6
+ .replaceAll("&", "&amp;")
7
+ .replaceAll("<", "&lt;")
8
+ .replaceAll(">", "&gt;")
9
+ .replaceAll('"', "&quot;")
10
+ .replaceAll("'", "&apos;");
11
+ }
12
+ //# sourceMappingURL=escape.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"escape.js","sourceRoot":"","sources":["../../src/text/escape.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,OAAO,KAAK;SACT,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;SACxB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;SACvB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;SACvB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC;SACzB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,30 @@
1
+ /** The width a run of text would be drawn at, at a given font size. */
2
+ export type MeasureAt = (text: string, fontSize: number) => number;
3
+ /** The space a block of text has, and the sizes it may be drawn at. */
4
+ export interface FitOptions {
5
+ readonly maxWidth: number;
6
+ readonly maxLines: number;
7
+ /** The size to draw at when the text fits at it. */
8
+ readonly fontSize: number;
9
+ /** The size below which shrinking costs more legibility than it is worth. */
10
+ readonly minFontSize: number;
11
+ }
12
+ /** A block of text with the size it turned out to fit at. */
13
+ export interface FittedText {
14
+ readonly lines: readonly string[];
15
+ readonly fontSize: number;
16
+ }
17
+ /**
18
+ * Wrap text into the space it has, shrinking it until it fits.
19
+ *
20
+ * The alternative, and what Colophon did before it could measure anything, is
21
+ * to wrap at one size and drop whatever is left over. That reads as a mistake
22
+ * rather than a design: a long title loses its last few words, and the image
23
+ * says something the post does not. Shrinking keeps the words.
24
+ *
25
+ * It only shrinks so far, because a title small enough to fit anything is a
26
+ * title nobody reads in a feed. Text that still does not fit at the floor is
27
+ * cut to `maxLines` as before.
28
+ */
29
+ export declare function fitText(text: string, measure: MeasureAt, options: FitOptions): FittedText;
30
+ //# sourceMappingURL=fit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fit.d.ts","sourceRoot":"","sources":["../../src/text/fit.ts"],"names":[],"mappings":"AAEA,uEAAuE;AACvE,MAAM,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;AAEnE,uEAAuE;AACvE,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,oDAAoD;IACpD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,6EAA6E;IAC7E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,6DAA6D;AAC7D,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAKD;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CACrB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,EAClB,OAAO,EAAE,UAAU,GAClB,UAAU,CAiBZ"}