@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 { blockLines } from "../../layout/index.js";
2
+ const maxTitleLines = 3;
3
+ const maxSubtitleLines = 3;
4
+ const titleFloor = 0.62;
5
+ const subtitleFloor = 0.8;
6
+ /**
7
+ * The card's text block: the wrapped title, then the wrapped subtitle.
8
+ *
9
+ * The gap before the subtitle is smaller than the banner's, because the card
10
+ * has only the two groups and they belong together. It is not nothing, though:
11
+ * a title that wraps ends on a line the subtitle would otherwise sit straight
12
+ * underneath, and the change of size and weight alone does not separate them.
13
+ */
14
+ export function cardLines(props, text) {
15
+ const { measure, fontFamily, contentWidth } = text;
16
+ return [
17
+ ...blockLines(props.title, measure, fontFamily, {
18
+ maxWidth: contentWidth,
19
+ maxLines: maxTitleLines,
20
+ fontSize: text.titleFs,
21
+ floor: titleFloor,
22
+ fontWeight: 800,
23
+ opacity: 1,
24
+ }),
25
+ ...blockLines(props.subtitle, measure, fontFamily, {
26
+ maxWidth: contentWidth,
27
+ maxLines: maxSubtitleLines,
28
+ fontSize: text.subFs,
29
+ floor: subtitleFloor,
30
+ fontWeight: 500,
31
+ opacity: 0.85,
32
+ gapBefore: Math.round(text.height * 0.025),
33
+ }),
34
+ ];
35
+ }
36
+ //# sourceMappingURL=lines.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lines.js","sourceRoot":"","sources":["../../../src/templates/card/lines.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,aAAa,GAAG,GAAG,CAAC;AAY1B;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CAAC,KAAqB,EAAE,IAAc;IAC7D,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAEnD,OAAO;QACL,GAAG,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE;YAC9C,QAAQ,EAAE,YAAY;YACtB,QAAQ,EAAE,aAAa;YACvB,QAAQ,EAAE,IAAI,CAAC,OAAO;YACtB,KAAK,EAAE,UAAU;YACjB,UAAU,EAAE,GAAG;YACf,OAAO,EAAE,CAAC;SACX,CAAC;QACF,GAAG,UAAU,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE;YACjD,QAAQ,EAAE,YAAY;YACtB,QAAQ,EAAE,gBAAgB;YAC1B,QAAQ,EAAE,IAAI,CAAC,KAAK;YACpB,KAAK,EAAE,aAAa;YACpB,UAAU,EAAE,GAAG;YACf,OAAO,EAAE,IAAI;YACb,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;SAC3C,CAAC;KACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { Rect } from "../../layout/index.js";
2
+ import type { Dimensions, ResolvedConfig } from "../../types.js";
3
+ /**
4
+ * The optional title, centred in the band reserved above the panel.
5
+ *
6
+ * It is drawn as a single line at the size the band was measured with, so a
7
+ * title too long for the image runs over rather than wrapping into room that
8
+ * was never set aside for it.
9
+ */
10
+ export declare function codeHeading(title: string | undefined, band: Rect, fontSize: number, config: ResolvedConfig): string;
11
+ /** The configured footer, centred along the bottom of the image. */
12
+ export declare function codeFooter(dimensions: Dimensions, fontSize: number, config: ResolvedConfig): string;
13
+ //# sourceMappingURL=chrome.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chrome.d.ts","sourceRoot":"","sources":["../../../src/templates/code/chrome.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAIjE;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,cAAc,GACrB,MAAM,CAeR;AAED,oEAAoE;AACpE,wBAAgB,UAAU,CACxB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,cAAc,GACrB,MAAM,CAUR"}
@@ -0,0 +1,33 @@
1
+ import { drawLines } from "../../layout/index.js";
2
+ import { footerBaseline, footerElement } from "../footer.js";
3
+ import { imageMargin } from "./panel.js";
4
+ /**
5
+ * The optional title, centred in the band reserved above the panel.
6
+ *
7
+ * It is drawn as a single line at the size the band was measured with, so a
8
+ * title too long for the image runs over rather than wrapping into room that
9
+ * was never set aside for it.
10
+ */
11
+ export function codeHeading(title, band, fontSize, config) {
12
+ if (title === undefined || title === "") {
13
+ return "";
14
+ }
15
+ return drawLines([{ text: title, fontSize, fontWeight: 700, opacity: 0.95 }], band, {
16
+ fontFamily: config.fontFamily,
17
+ fill: config.colors.foreground,
18
+ lineHeight: 1,
19
+ anchor: "middle",
20
+ });
21
+ }
22
+ /** The configured footer, centred along the bottom of the image. */
23
+ export function codeFooter(dimensions, fontSize, config) {
24
+ const { width, height } = dimensions;
25
+ return footerElement(config, {
26
+ x: Math.round(width / 2),
27
+ y: footerBaseline(height, imageMargin(dimensions), fontSize),
28
+ fontSize,
29
+ opacity: 0.78,
30
+ anchor: "middle",
31
+ });
32
+ }
33
+ //# sourceMappingURL=chrome.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chrome.js","sourceRoot":"","sources":["../../../src/templates/code/chrome.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CACzB,KAAyB,EACzB,IAAU,EACV,QAAgB,EAChB,MAAsB;IAEtB,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QACxC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,SAAS,CACd,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAC3D,IAAI,EACJ;QACE,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU;QAC9B,UAAU,EAAE,CAAC;QACb,MAAM,EAAE,QAAQ;KACjB,CACF,CAAC;AACJ,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,UAAU,CACxB,UAAsB,EACtB,QAAgB,EAChB,MAAsB;IAEtB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;IAErC,OAAO,aAAa,CAAC,MAAM,EAAE;QAC3B,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC;QACxB,CAAC,EAAE,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC;QAC5D,QAAQ;QACR,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,QAAQ;KACjB,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { CodeToken } from "../../highlight/index.js";
2
+ /**
3
+ * Clip a line to the columns that fit, ending it with an ellipsis. The font
4
+ * size is floored for legibility, so a wide enough snippet can still overrun
5
+ * the panel, and clipping keeps it inside instead of bleeding off the image.
6
+ *
7
+ * Returns the line unchanged when it already fits, so the caller can count the
8
+ * clipped lines by identity.
9
+ */
10
+ export declare function clipLine(tokens: readonly CodeToken[], maxColumns: number): readonly CodeToken[];
11
+ /**
12
+ * Clip every line to the panel width, and count how many had to give ground.
13
+ */
14
+ export declare function clipLines(lines: readonly (readonly CodeToken[])[], maxColumns: number): {
15
+ lines: readonly (readonly CodeToken[])[];
16
+ clipped: number;
17
+ };
18
+ //# sourceMappingURL=clip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clip.d.ts","sourceRoot":"","sources":["../../../src/templates/code/clip.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAG1D;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,SAAS,SAAS,EAAE,EAC5B,UAAU,EAAE,MAAM,GACjB,SAAS,SAAS,EAAE,CA0BtB;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,SAAS,CAAC,SAAS,SAAS,EAAE,CAAC,EAAE,EACxC,UAAU,EAAE,MAAM,GACjB;IAAE,KAAK,EAAE,SAAS,CAAC,SAAS,SAAS,EAAE,CAAC,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAc/D"}
@@ -0,0 +1,44 @@
1
+ import { ellipsis } from "./ellipsis.js";
2
+ /**
3
+ * Clip a line to the columns that fit, ending it with an ellipsis. The font
4
+ * size is floored for legibility, so a wide enough snippet can still overrun
5
+ * the panel, and clipping keeps it inside instead of bleeding off the image.
6
+ *
7
+ * Returns the line unchanged when it already fits, so the caller can count the
8
+ * clipped lines by identity.
9
+ */
10
+ export function clipLine(tokens, maxColumns) {
11
+ const last = tokens.at(-1);
12
+ if (last === undefined || last.column + last.text.length <= maxColumns) {
13
+ return tokens;
14
+ }
15
+ const clipped = [];
16
+ for (const token of tokens) {
17
+ if (token.column >= maxColumns) {
18
+ break;
19
+ }
20
+ const room = maxColumns - token.column;
21
+ if (token.text.length <= room) {
22
+ clipped.push(token);
23
+ continue;
24
+ }
25
+ clipped.push({ ...token, text: token.text.slice(0, room - 1) + ellipsis });
26
+ break;
27
+ }
28
+ return clipped;
29
+ }
30
+ /**
31
+ * Clip every line to the panel width, and count how many had to give ground.
32
+ */
33
+ export function clipLines(lines, maxColumns) {
34
+ let clipped = 0;
35
+ const fitted = lines.map((tokens) => {
36
+ const line = clipLine(tokens, maxColumns);
37
+ if (line !== tokens) {
38
+ clipped += 1;
39
+ }
40
+ return line;
41
+ });
42
+ return { lines: fitted, clipped };
43
+ }
44
+ //# sourceMappingURL=clip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clip.js","sourceRoot":"","sources":["../../../src/templates/code/clip.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CACtB,MAA4B,EAC5B,UAAkB;IAElB,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3B,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC;QACvE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,OAAO,GAAgB,EAAE,CAAC;IAEhC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC;YAC/B,MAAM;QACR,CAAC;QAED,MAAM,IAAI,GAAG,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC;QAEvC,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;YAC9B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpB,SAAS;QACX,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,QAAQ,EAAE,CAAC,CAAC;QAC3E,MAAM;IACR,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CACvB,KAAwC,EACxC,UAAkB;IAElB,IAAI,OAAO,GAAG,CAAC,CAAC;IAEhB,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QAClC,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAE1C,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AACpC,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** The mark a truncated line or block ends with. */
2
+ export declare const ellipsis = "\u2026";
3
+ //# sourceMappingURL=ellipsis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ellipsis.d.ts","sourceRoot":"","sources":["../../../src/templates/code/ellipsis.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,eAAO,MAAM,QAAQ,WAAM,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** The mark a truncated line or block ends with. */
2
+ export const ellipsis = "…";
3
+ //# sourceMappingURL=ellipsis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ellipsis.js","sourceRoot":"","sources":["../../../src/templates/code/ellipsis.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { CodeToken, HighlightedCode } from "../../highlight/index.js";
2
+ import type { Dimensions, ResolvedConfig } from "../../types.js";
3
+ /**
4
+ * Pick the largest font size that fits the snippet in the panel on both axes,
5
+ * clamped to the configured bounds.
6
+ *
7
+ * The bounds are fractions of the image *width*, not its height: a share image
8
+ * is scaled to fit the width of whatever feed shows it, so width is what
9
+ * decides whether the code ends up legible. Keying the floor to height would
10
+ * let a landscape image render the same snippet at half the size of its square
11
+ * counterpart.
12
+ */
13
+ export declare function fitFontSize(highlighted: HighlightedCode, area: Dimensions, imageWidth: number, config: ResolvedConfig, charWidthRatio: number): number;
14
+ /**
15
+ * Width of the laid-out block in characters, measured from the lines actually
16
+ * being drawn. Narrower than the snippet's longest line whenever that line was
17
+ * dropped or clipped, which keeps the panel hugged tight to what is visible.
18
+ */
19
+ export declare function blockColumns(lines: readonly (readonly CodeToken[])[]): number;
20
+ /**
21
+ * Drop lines that cannot fit at the chosen font size, marking the truncation
22
+ * with an ellipsis line so the image never silently misrepresents the snippet.
23
+ * The marker takes the indentation of the first dropped line, so it reads as
24
+ * part of the block rather than as a stray mark in the left margin.
25
+ */
26
+ export declare function fitLines(lines: readonly (readonly CodeToken[])[], codeHeight: number, step: number): readonly (readonly CodeToken[])[];
27
+ //# sourceMappingURL=fit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fit.d.ts","sourceRoot":"","sources":["../../../src/templates/code/fit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGjE;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,WAAW,EAAE,eAAe,EAC5B,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,cAAc,EACtB,cAAc,EAAE,MAAM,GACrB,MAAM,CAUR;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,SAAS,SAAS,EAAE,CAAC,EAAE,GAAG,MAAM,CAY7E;AAaD;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,SAAS,CAAC,SAAS,SAAS,EAAE,CAAC,EAAE,EACxC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,GACX,SAAS,CAAC,SAAS,SAAS,EAAE,CAAC,EAAE,CAWnC"}
@@ -0,0 +1,59 @@
1
+ import { ellipsis } from "./ellipsis.js";
2
+ /**
3
+ * Pick the largest font size that fits the snippet in the panel on both axes,
4
+ * clamped to the configured bounds.
5
+ *
6
+ * The bounds are fractions of the image *width*, not its height: a share image
7
+ * is scaled to fit the width of whatever feed shows it, so width is what
8
+ * decides whether the code ends up legible. Keying the floor to height would
9
+ * let a landscape image render the same snippet at half the size of its square
10
+ * counterpart.
11
+ */
12
+ export function fitFontSize(highlighted, area, imageWidth, config, charWidthRatio) {
13
+ const { lineHeight, maxFontScale, minFontScale } = config.code;
14
+ const byWidth = area.width / (Math.max(1, highlighted.longestLine) * charWidthRatio);
15
+ const byHeight = area.height / (Math.max(1, highlighted.lines.length) * lineHeight);
16
+ const fitted = Math.min(byWidth, byHeight, imageWidth * maxFontScale);
17
+ return Math.max(1, Math.floor(Math.max(fitted, imageWidth * minFontScale)));
18
+ }
19
+ /**
20
+ * Width of the laid-out block in characters, measured from the lines actually
21
+ * being drawn. Narrower than the snippet's longest line whenever that line was
22
+ * dropped or clipped, which keeps the panel hugged tight to what is visible.
23
+ */
24
+ export function blockColumns(lines) {
25
+ let columns = 0;
26
+ for (const tokens of lines) {
27
+ const last = tokens.at(-1);
28
+ if (last !== undefined) {
29
+ columns = Math.max(columns, last.column + last.text.length);
30
+ }
31
+ }
32
+ return columns;
33
+ }
34
+ function ellipsisToken(column) {
35
+ return {
36
+ text: ellipsis,
37
+ column,
38
+ color: undefined,
39
+ opacity: 0.6,
40
+ bold: false,
41
+ italic: false,
42
+ };
43
+ }
44
+ /**
45
+ * Drop lines that cannot fit at the chosen font size, marking the truncation
46
+ * with an ellipsis line so the image never silently misrepresents the snippet.
47
+ * The marker takes the indentation of the first dropped line, so it reads as
48
+ * part of the block rather than as a stray mark in the left margin.
49
+ */
50
+ export function fitLines(lines, codeHeight, step) {
51
+ const maxLines = Math.max(1, Math.floor(codeHeight / step));
52
+ if (lines.length <= maxLines) {
53
+ return lines;
54
+ }
55
+ const kept = lines.slice(0, maxLines - 1);
56
+ const dropped = lines.slice(maxLines - 1).find((line) => line.length > 0);
57
+ return [...kept, [ellipsisToken(dropped?.[0]?.column ?? 0)]];
58
+ }
59
+ //# sourceMappingURL=fit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fit.js","sourceRoot":"","sources":["../../../src/templates/code/fit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CACzB,WAA4B,EAC5B,IAAgB,EAChB,UAAkB,EAClB,MAAsB,EACtB,cAAsB;IAEtB,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC;IAE/D,MAAM,OAAO,GACX,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,WAAW,CAAC,GAAG,cAAc,CAAC,CAAC;IACvE,MAAM,QAAQ,GACZ,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,CAAC;IAErE,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,GAAG,YAAY,CAAC,CAAC;IACtE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;AAC9E,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAwC;IACnE,IAAI,OAAO,GAAG,CAAC,CAAC;IAEhB,KAAK,MAAM,MAAM,IAAI,KAAK,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAE3B,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,aAAa,CAAC,MAAc;IACnC,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,MAAM;QACN,KAAK,EAAE,SAAS;QAChB,OAAO,EAAE,GAAG;QACZ,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,KAAK;KACd,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CACtB,KAAwC,EACxC,UAAkB,EAClB,IAAY;IAEZ,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC;IAE5D,IAAI,KAAK,CAAC,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,GAAG,CAAC,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE1E,OAAO,CAAC,GAAG,IAAI,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { Template } from "../../types.js";
2
+ /**
3
+ * Syntax-highlighted code snippet on a rounded panel over the configured
4
+ * background. Reads `code` and `language` from the props (as the original
5
+ * `image_text` / `image_lexer` frontmatter did), with an optional `title`
6
+ * above the panel and the configured footer below it.
7
+ *
8
+ * Highlighting uses Shiki, so token colours come from a real VS Code theme
9
+ * rather than being approximated.
10
+ */
11
+ export declare const codeTemplate: Template;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/code/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAY/C;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,EAAE,QAkF1B,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { highlightCode } from "../../highlight/index.js";
2
+ import { hasFooter } from "../footer.js";
3
+ import { optionalString } from "../../props.js";
4
+ import { codeFooter, codeHeading } from "./chrome.js";
5
+ import { blockColumns } from "./fit.js";
6
+ import { fitSnippet } from "./layout.js";
7
+ import { layoutPanel, titleBand } from "./panel.js";
8
+ import { hugPanel, panelSvg } from "./plate.js";
9
+ import { codeBody } from "./spans.js";
10
+ import { warnIfTruncated } from "./warn.js";
11
+ import { charWidthRatio } from "./width.js";
12
+ /**
13
+ * Syntax-highlighted code snippet on a rounded panel over the configured
14
+ * background. Reads `code` and `language` from the props (as the original
15
+ * `image_text` / `image_lexer` frontmatter did), with an optional `title`
16
+ * above the panel and the configured footer below it.
17
+ *
18
+ * Highlighting uses Shiki, so token colours come from a real VS Code theme
19
+ * rather than being approximated.
20
+ */
21
+ export const codeTemplate = {
22
+ name: "code",
23
+ async render({ props, config, dimensions, measure }) {
24
+ const { width, height } = dimensions;
25
+ const title = optionalString(props.title);
26
+ const titleFs = Math.round(height * 0.045);
27
+ const footerFs = Math.round(height * 0.032);
28
+ const highlighted = await highlightCode(optionalString(props["code"]) ?? "", {
29
+ language: optionalString(props["language"]) ?? "text",
30
+ theme: optionalString(props["theme"]) ?? config.code.theme,
31
+ tabSize: config.code.tabSize,
32
+ });
33
+ const available = layoutPanel(dimensions, config, titleFs, footerFs, title !== undefined && title !== "", hasFooter(config));
34
+ const fitted = fitSnippet(highlighted, available, width, config, charWidthRatio(measure, config.code.fontFamily));
35
+ warnIfTruncated(config, dimensions, {
36
+ dropped: highlighted.lines.length - fitted.lines.length,
37
+ clipped: fitted.clipped,
38
+ }, highlighted.lines.length);
39
+ // Shrink the panel down onto the snippet so it isn't left floating in dead
40
+ // space. On a landscape image especially, a wide panel holding a narrow
41
+ // block leaves the code marooned off to one side.
42
+ const panel = hugPanel(available, {
43
+ width: blockColumns(fitted.lines) * fitted.charWidth + fitted.padding * 2,
44
+ height: fitted.lines.length * fitted.step + fitted.padding * 2,
45
+ });
46
+ const body = codeBody(fitted.lines, {
47
+ // Code reads from the left edge, as it does in an editor. Indentation is
48
+ // carried by each token's column, so the snippet keeps its shape.
49
+ originX: panel.x + fitted.padding,
50
+ originY: panel.y + (panel.height - fitted.lines.length * fitted.step) / 2,
51
+ fontSize: fitted.fontSize,
52
+ charWidth: fitted.charWidth,
53
+ step: fitted.step,
54
+ fontFamily: config.code.fontFamily,
55
+ foreground: highlighted.foreground,
56
+ });
57
+ const shadowOffset = Math.round(Math.min(width, height) * 0.01);
58
+ const plate = panelSvg(panel, highlighted.background, Math.max(1, shadowOffset));
59
+ return (codeHeading(title, titleBand(panel, dimensions, titleFs), titleFs, config) +
60
+ plate +
61
+ body +
62
+ codeFooter(dimensions, footerFs, config));
63
+ },
64
+ };
65
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/code/index.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,21 @@
1
+ import type { CodeToken, HighlightedCode } from "../../highlight/index.js";
2
+ import type { ResolvedConfig } from "../../types.js";
3
+ import type { Panel } from "./panel.js";
4
+ /**
5
+ * A snippet sized to the space it has: the lines that survived, the grid they
6
+ * are drawn on, and how many of them had to be clipped to get there.
7
+ */
8
+ export interface FittedCode {
9
+ readonly lines: readonly (readonly CodeToken[])[];
10
+ readonly clipped: number;
11
+ readonly fontSize: number;
12
+ readonly charWidth: number;
13
+ readonly step: number;
14
+ readonly padding: number;
15
+ }
16
+ /**
17
+ * Fit a highlighted snippet into the panel it has been allotted: choose the
18
+ * font size, then drop and clip whatever still does not fit.
19
+ */
20
+ export declare function fitSnippet(highlighted: HighlightedCode, available: Panel, imageWidth: number, config: ResolvedConfig, charWidthRatio: number): FittedCode;
21
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/templates/code/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,SAAS,SAAS,EAAE,CAAC,EAAE,CAAC;IAClD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,WAAW,EAAE,eAAe,EAC5B,SAAS,EAAE,KAAK,EAChB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,cAAc,EACtB,cAAc,EAAE,MAAM,GACrB,UAAU,CA6BZ"}
@@ -0,0 +1,21 @@
1
+ import { clipLines } from "./clip.js";
2
+ import { fitFontSize, fitLines } from "./fit.js";
3
+ /**
4
+ * Fit a highlighted snippet into the panel it has been allotted: choose the
5
+ * font size, then drop and clip whatever still does not fit.
6
+ */
7
+ export function fitSnippet(highlighted, available, imageWidth, config, charWidthRatio) {
8
+ const inner = Math.round(Math.min(available.width, available.height) * 0.07);
9
+ const codeWidth = Math.max(1, available.width - inner * 2);
10
+ const codeHeight = Math.max(1, available.height - inner * 2);
11
+ const fontSize = fitFontSize(highlighted, { width: codeWidth, height: codeHeight }, imageWidth, config, charWidthRatio);
12
+ const charWidth = fontSize * charWidthRatio;
13
+ const step = fontSize * config.code.lineHeight;
14
+ const { lines, clipped } = clipLines(fitLines(highlighted.lines, codeHeight, step), Math.max(1, Math.floor(codeWidth / charWidth)));
15
+ // Padding reads best proportional to the text rather than the panel, since a
16
+ // snippet fitted down to a small size wants tighter margins. Only ever
17
+ // shrink, so the code area the font was fitted against stays valid.
18
+ const padding = Math.max(Math.min(inner, Math.round(fontSize * 1.6)), Math.round(inner * 0.35));
19
+ return { lines, clipped, fontSize, charWidth, step, padding };
20
+ }
21
+ //# sourceMappingURL=layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.js","sourceRoot":"","sources":["../../../src/templates/code/layout.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAgBjD;;;GAGG;AACH,MAAM,UAAU,UAAU,CACxB,WAA4B,EAC5B,SAAgB,EAChB,UAAkB,EAClB,MAAsB,EACtB,cAAsB;IAEtB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7E,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC;IAC3D,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC;IAE7D,MAAM,QAAQ,GAAG,WAAW,CAC1B,WAAW,EACX,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,EACxC,UAAU,EACV,MAAM,EACN,cAAc,CACf,CAAC;IACF,MAAM,SAAS,GAAG,QAAQ,GAAG,cAAc,CAAC;IAC5C,MAAM,IAAI,GAAG,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;IAE/C,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,SAAS,CAClC,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,EAC7C,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC,CAC/C,CAAC;IAEF,6EAA6E;IAC7E,uEAAuE;IACvE,oEAAoE;IACpE,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CACtB,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC,EAC3C,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CACzB,CAAC;IAEF,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAChE,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { Rect } from "../../layout/index.js";
2
+ import type { Dimensions, ResolvedConfig } from "../../types.js";
3
+ /**
4
+ * The rounded plate the snippet is drawn on.
5
+ */
6
+ export interface Panel {
7
+ readonly x: number;
8
+ readonly y: number;
9
+ readonly width: number;
10
+ readonly height: number;
11
+ readonly radius: number;
12
+ }
13
+ /** Margin from the image edge to anything drawn inside it. */
14
+ export declare function imageMargin(dimensions: Dimensions): number;
15
+ /**
16
+ * Place the code panel within the image, leaving room above for a title and
17
+ * below for a footer when either is present.
18
+ */
19
+ export declare function layoutPanel(dimensions: Dimensions, config: ResolvedConfig, titleFontSize: number, footerFontSize: number, hasTitle: boolean, hasFooter: boolean): Panel;
20
+ /**
21
+ * The band the title was given: one line's worth of room above the panel, with
22
+ * the reserved gap between the two.
23
+ *
24
+ * It is measured up from the panel rather than down from the top margin, so
25
+ * that it follows the panel when the panel hugs a short snippet and moves
26
+ * down. That keeps the title with the plate it names rather than stranding it
27
+ * at the top of the image.
28
+ */
29
+ export declare function titleBand(panel: Panel, dimensions: Dimensions, fontSize: number): Rect;
30
+ //# sourceMappingURL=panel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel.d.ts","sourceRoot":"","sources":["../../../src/templates/code/panel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,8DAA8D;AAC9D,wBAAgB,WAAW,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAE1D;AAcD;;;GAGG;AACH,wBAAgB,WAAW,CACzB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,cAAc,EACtB,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,OAAO,EACjB,SAAS,EAAE,OAAO,GACjB,KAAK,CAgBP;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,GACf,IAAI,CAON"}
@@ -0,0 +1,52 @@
1
+ /** Margin from the image edge to anything drawn inside it. */
2
+ export function imageMargin(dimensions) {
3
+ return Math.round(Math.min(dimensions.width, dimensions.height) * 0.05);
4
+ }
5
+ /**
6
+ * Clear space between the panel and the title above it or the footer below.
7
+ *
8
+ * `layoutPanel` reserves this at each end alongside a line's worth of room, and
9
+ * the bands those lines are then placed in take the room and leave the gap. The
10
+ * two agree because both are measured from here, which is the whole point: a
11
+ * gap that is reserved in one place and drawn in another drifts.
12
+ */
13
+ function gapAround(dimensions) {
14
+ return Math.round(Math.min(dimensions.width, dimensions.height) * 0.028);
15
+ }
16
+ /**
17
+ * Place the code panel within the image, leaving room above for a title and
18
+ * below for a footer when either is present.
19
+ */
20
+ export function layoutPanel(dimensions, config, titleFontSize, footerFontSize, hasTitle, hasFooter) {
21
+ const { width, height } = dimensions;
22
+ const shorter = Math.min(width, height);
23
+ const pad = imageMargin(dimensions);
24
+ const gap = gapAround(dimensions);
25
+ const top = pad + (hasTitle ? titleFontSize + gap : 0);
26
+ const bottom = height - pad - (hasFooter ? footerFontSize + gap : 0);
27
+ return {
28
+ x: pad,
29
+ y: top,
30
+ width: width - pad * 2,
31
+ height: Math.max(1, bottom - top),
32
+ radius: Math.round(shorter * config.code.cornerScale),
33
+ };
34
+ }
35
+ /**
36
+ * The band the title was given: one line's worth of room above the panel, with
37
+ * the reserved gap between the two.
38
+ *
39
+ * It is measured up from the panel rather than down from the top margin, so
40
+ * that it follows the panel when the panel hugs a short snippet and moves
41
+ * down. That keeps the title with the plate it names rather than stranding it
42
+ * at the top of the image.
43
+ */
44
+ export function titleBand(panel, dimensions, fontSize) {
45
+ return {
46
+ x: 0,
47
+ y: panel.y - gapAround(dimensions) - fontSize,
48
+ width: dimensions.width,
49
+ height: fontSize,
50
+ };
51
+ }
52
+ //# sourceMappingURL=panel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel.js","sourceRoot":"","sources":["../../../src/templates/code/panel.ts"],"names":[],"mappings":"AAcA,8DAA8D;AAC9D,MAAM,UAAU,WAAW,CAAC,UAAsB;IAChD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;AAC1E,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,SAAS,CAAC,UAAsB;IACvC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC;AAC3E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CACzB,UAAsB,EACtB,MAAsB,EACtB,aAAqB,EACrB,cAAsB,EACtB,QAAiB,EACjB,SAAkB;IAElB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACxC,MAAM,GAAG,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IACpC,MAAM,GAAG,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;IAElC,MAAM,GAAG,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvD,MAAM,MAAM,GAAG,MAAM,GAAG,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAErE,OAAO;QACL,CAAC,EAAE,GAAG;QACN,CAAC,EAAE,GAAG;QACN,KAAK,EAAE,KAAK,GAAG,GAAG,GAAG,CAAC;QACtB,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;QACjC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;KACtD,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CACvB,KAAY,EACZ,UAAsB,EACtB,QAAgB;IAEhB,OAAO;QACL,CAAC,EAAE,CAAC;QACJ,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,SAAS,CAAC,UAAU,CAAC,GAAG,QAAQ;QAC7C,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,MAAM,EAAE,QAAQ;KACjB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { Panel } from "./panel.js";
2
+ /**
3
+ * Shrink a panel onto its content, keeping it centred in the space it was
4
+ * allotted. Both axes are floored so a small snippet still gets a panel with
5
+ * presence rather than a letterbox slot or a narrow strip.
6
+ */
7
+ export declare function hugPanel(available: Panel, wanted: {
8
+ readonly width: number;
9
+ readonly height: number;
10
+ }): Panel;
11
+ /**
12
+ * The panel itself: a drop shadow, then the theme-coloured surface it sits on.
13
+ * The surface is stroked rather than left flat, so a dark theme still has an
14
+ * edge against a dark background.
15
+ */
16
+ export declare function panelSvg(available: Panel, background: string, shadowOffset: number): string;
17
+ //# sourceMappingURL=plate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plate.d.ts","sourceRoot":"","sources":["../../../src/templates/code/plate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;;GAIG;AACH,wBAAgB,QAAQ,CACtB,SAAS,EAAE,KAAK,EAChB,MAAM,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC1D,KAAK,CAmBP;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CACtB,SAAS,EAAE,KAAK,EAChB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,GACnB,MAAM,CAQR"}
@@ -0,0 +1,34 @@
1
+ import { panel } from "../../layout/index.js";
2
+ /**
3
+ * Shrink a panel onto its content, keeping it centred in the space it was
4
+ * allotted. Both axes are floored so a small snippet still gets a panel with
5
+ * presence rather than a letterbox slot or a narrow strip.
6
+ */
7
+ export function hugPanel(available, wanted) {
8
+ const width = Math.min(available.width, Math.max(Math.round(wanted.width), Math.round(available.width * 0.55)));
9
+ // Floor relative to the panel's own width, so shrinking never leaves a
10
+ // sliver, and never taller than the space the font was fitted against.
11
+ const height = Math.min(available.height, Math.max(Math.round(wanted.height), Math.round(width * 0.25)));
12
+ return {
13
+ ...available,
14
+ x: available.x + Math.round((available.width - width) / 2),
15
+ y: available.y + Math.round((available.height - height) / 2),
16
+ width,
17
+ height,
18
+ };
19
+ }
20
+ /**
21
+ * The panel itself: a drop shadow, then the theme-coloured surface it sits on.
22
+ * The surface is stroked rather than left flat, so a dark theme still has an
23
+ * edge against a dark background.
24
+ */
25
+ export function panelSvg(available, background, shadowOffset) {
26
+ return panel(available, {
27
+ radius: available.radius,
28
+ fill: background,
29
+ stroke: "#ffffff",
30
+ strokeOpacity: 0.12,
31
+ shadow: shadowOffset,
32
+ });
33
+ }
34
+ //# sourceMappingURL=plate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plate.js","sourceRoot":"","sources":["../../../src/templates/code/plate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAG9C;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CACtB,SAAgB,EAChB,MAA2D;IAE3D,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CACpB,SAAS,CAAC,KAAK,EACf,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CACvE,CAAC;IACF,uEAAuE;IACvE,uEAAuE;IACvE,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CACrB,SAAS,CAAC,MAAM,EAChB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAC9D,CAAC;IAEF,OAAO;QACL,GAAG,SAAS;QACZ,CAAC,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QAC1D,CAAC,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC5D,KAAK;QACL,MAAM;KACP,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CACtB,SAAgB,EAChB,UAAkB,EAClB,YAAoB;IAEpB,OAAO,KAAK,CAAC,SAAS,EAAE;QACtB,MAAM,EAAE,SAAS,CAAC,MAAM;QACxB,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,SAAS;QACjB,aAAa,EAAE,IAAI;QACnB,MAAM,EAAE,YAAY;KACrB,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { CodeToken } from "../../highlight/index.js";
2
+ /**
3
+ * Where and how the snippet's character grid is drawn.
4
+ */
5
+ export interface GridMetrics {
6
+ readonly originX: number;
7
+ readonly originY: number;
8
+ readonly fontSize: number;
9
+ readonly charWidth: number;
10
+ readonly step: number;
11
+ readonly fontFamily: string;
12
+ readonly foreground: string;
13
+ }
14
+ /**
15
+ * The snippet as one `<text>` element per line, each token positioned
16
+ * absolutely from its character column so indentation survives SVG text flow.
17
+ */
18
+ export declare function codeBody(lines: readonly (readonly CodeToken[])[], metrics: GridMetrics): string;
19
+ //# sourceMappingURL=spans.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spans.d.ts","sourceRoot":"","sources":["../../../src/templates/code/spans.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AA2B1D;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,SAAS,CAAC,SAAS,SAAS,EAAE,CAAC,EAAE,EACxC,OAAO,EAAE,WAAW,GACnB,MAAM,CAyBR"}