@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
package/README.md CHANGED
@@ -1,22 +1,34 @@
1
- # @kensio/colophon
2
-
3
- Generate social meta images (Open Graph / share-card images) for the posts of a
4
- static website, driven by each post's frontmatter.
5
-
6
- You describe an image in frontmatter — `title`, `subtitle`, `version`, a
7
- template name — and Colophon renders branded PNGs at the sizes you need. The
8
- name comes from the printer's _colophon_: the emblem a publisher stamps on a
9
- finished work.
10
-
11
- - **Frontmatter-driven** general props read from a post, not a fixed schema.
12
- - **Templates** — a small registry of layouts; frontmatter picks one.
13
- - **Syntax-highlighted code images** — the `code` template renders a snippet
14
- from frontmatter with real VS Code theme colours.
15
- - **Configurable branding** colours, gradient, fonts, footer and badge come
16
- from config, not from any one site's stylesheet.
17
- - **Multiple sizes from one input** a 1:1 square plus a 1.91:1 landscape by
1
+ # <img src="https://colophonjs.dev/favicon.png" alt="Colophon logo" width="28" height="28">&nbsp;&nbsp;@kensio/colophon
2
+
3
+ [![npm version](https://img.shields.io/npm/v/%40kensio%2Fcolophon)](https://www.npmjs.com/package/@kensio/colophon)
4
+ ![CI](https://img.shields.io/github/actions/workflow/status/KensioSoftware/colophon/pr.yml?label=CI)
5
+ ![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/hughgrigg/f2d667bbcc14dab9efa679f2113b1e00/raw/coverage.json)
6
+ ![Node](https://img.shields.io/node/v/%40kensio%2Fcolophon)
7
+ ![TypeScript](https://img.shields.io/badge/TS-TypeScript-3178C6)
8
+ ![License](https://img.shields.io/npm/l/%40kensio%2Fcolophon)
9
+
10
+ Generate social meta images (Open Graph and share-card images) for the posts of
11
+ a static website, driven by each post's frontmatter.
12
+
13
+ [https://colophonjs.dev/](https://colophonjs.dev/ "Colophon documentation website")
14
+
15
+ You describe an image in frontmatter with a title, a subtitle, a version and a
16
+ template name, and Colophon renders branded PNGs at the sizes you need. The name
17
+ comes from the printer's _colophon_, the emblem a publisher stamps on a finished
18
+ work.
19
+
20
+ - **Frontmatter-driven.** Props are read from a post rather than fixed by a
21
+ schema.
22
+ - **Templates.** A small registry of layouts, picked per post from frontmatter.
23
+ - **Syntax-highlighted code images.** The `code` template renders a snippet from
24
+ frontmatter with real VS Code theme colours.
25
+ - **Configurable branding.** Colours, gradient, fonts, footer and badge come from
26
+ config, not from any one site's stylesheet.
27
+ - **Multiple sizes from one input.** A 1:1 square and a 1.91:1 landscape by
18
28
  default, or whatever set you configure.
19
- - **Small, reusable API** a render core with no filesystem concerns, plus an
29
+ - **Manifest and meta tags.** A JSON record of what was generated, and the Open
30
+ Graph and Twitter tags that go with it.
31
+ - **Small, reusable API.** A render core with no filesystem concerns, plus an
20
32
  optional content walker and CLI.
21
33
 
22
34
  ## Install
@@ -25,10 +37,12 @@ finished work.
25
37
  pnpm add @kensio/colophon
26
38
  ```
27
39
 
28
- `sharp` is a dependency and does the SVG PNG rasterisation; `shiki` provides
29
- the grammars and themes for the `code` template.
40
+ `@resvg/resvg-js` rasterises the SVG to PNG, and `shiki` provides the grammars
41
+ and themes for the `code` template. No headless browser is involved. Fonts can
42
+ be handed to the renderer as files, so a build renders the same image
43
+ everywhere.
30
44
 
31
- ## Quick start (CLI)
45
+ ## Quick start
32
46
 
33
47
  Add image props to a post's frontmatter:
34
48
 
@@ -43,7 +57,7 @@ meta_img_props:
43
57
  ---
44
58
  ```
45
59
 
46
- Create a config module (optional omit to use the neutral defaults):
60
+ Create a config module, or omit it to use the neutral defaults:
47
61
 
48
62
  ```ts
49
63
  // colophon.config.ts
@@ -63,238 +77,30 @@ colophon content --config colophon.config.ts
63
77
  ```
64
78
 
65
79
  For every file that declares `meta_img_props`, Colophon writes one PNG per
66
- output size next to it, named `<slug>-<size>.png`
67
- (`post/index.md` → `post/post-og.png` and `post/post-square.png`). Existing
68
- files are skipped unless you pass `--overwrite`.
69
-
70
- ```
71
- colophon [contentDir] [options]
72
-
73
- -c, --config <path> Config module whose default export is a ColophonConfig
74
- -o, --overwrite Re-render even if the output file already exists
75
- -h, --help Show help
76
-
77
- contentDir defaults to "content"
78
- ```
79
-
80
- ## Programmatic use
81
-
82
- ### Render from props (core)
83
-
84
- The core takes props and config and returns rendered bytes — no filesystem, no
85
- content discovery:
86
-
87
- ```ts
88
- import { renderMetaImages } from "@kensio/colophon";
89
- import { writeFile } from "node:fs/promises";
90
-
91
- const images = await renderMetaImages(
92
- {
93
- template: "banner",
94
- title: "@kensio/colophon",
95
- subtitle: "Generate social meta images from frontmatter",
96
- version: "1.2.0",
97
- },
98
- {
99
- colors: { brand: "#2563eb" },
100
- footer: "example.com",
101
- badge: { text: "npm" },
102
- },
103
- );
104
-
105
- for (const image of images) {
106
- // image.name is the output-size name ("og", "square", …).
107
- await writeFile(`social-${image.name}.png`, image.png);
108
- }
109
- ```
110
-
111
- ### Walk content + generate (host helpers)
112
-
113
- `walkContent` finds `.md` files and reads their frontmatter; `generate` ties
114
- walking, rendering and writing together (this is what the CLI uses):
115
-
116
- ```ts
117
- import { generate } from "@kensio/colophon";
118
-
119
- await generate({
120
- contentDir: "content",
121
- config: { colors: { brand: "#2563eb" } },
122
- overwrite: false,
123
- onResult: (result) =>
124
- console.log(`${result.skipped ? "skip" : "wrote"} ${result.outputPath}`),
125
- });
126
- ```
127
-
128
- Import the walker on its own from the `@kensio/colophon/content` subpath if you
129
- only want frontmatter discovery.
80
+ output size next to it, named `<slug>-<size>.png`, so `post/index.md` produces
81
+ `post/post-og.png` and `post/post-square.png`.
130
82
 
131
- ## Templates
83
+ There is also a programmatic API. `renderMetaImages` takes props and config and
84
+ returns rendered bytes, and `generate` ties walking, rendering and writing
85
+ together.
132
86
 
133
- | Name | Layout |
134
- | -------- | ---------------------------------------------------------------------------- |
135
- | `banner` | Left-aligned title with optional version, subtitle, corner badge and footer. |
136
- | `card` | Minimal centred title with an optional subtitle. |
137
- | `code` | Syntax-highlighted snippet on a rounded panel over the background. |
87
+ ## Documentation
138
88
 
139
- Register your own by passing `templates` in config — a template is `{ name,
140
- render(context) }` returning SVG foreground content, either directly or as a
141
- promise. Anything you add merges over (and can override) the built-ins.
89
+ Full documentation is in [`docs/`](./docs/).
142
90
 
143
- ### The `code` template
144
-
145
- Put the snippet in frontmatter and name its language:
146
-
147
- ```yaml
148
- ---
149
- title: eslint changed TypeScript files only
150
- slug: eslint-changed-ts-files-only
151
- meta_img_props:
152
- template: code
153
- language: bash
154
- code: |
155
- mapfile -t CHANGED_TS < <(
156
- git diff origin/main --name-only \
157
- | grep '\.ts'
158
- )
159
- ---
160
- ```
161
-
162
- | Prop | Notes |
163
- | ---------- | ---------------------------------------------------------------- |
164
- | `code` | The snippet. Trimmed, tabs expanded, common indentation removed. |
165
- | `language` | Any [Shiki language]; unknown names fall back to plain text. |
166
- | `title` | Optional heading above the panel. Omit for a bare code image. |
167
- | `theme` | Optional per-post override of `config.code.theme`. |
168
-
169
- [Shiki language]: https://shiki.style/languages
170
-
171
- Pygments-style names carried over from an older pipeline (`text`, `console`,
172
- `html+handlebars`, …) are mapped onto their Shiki equivalents, so existing
173
- frontmatter usually needs no changes.
174
-
175
- The font size is fitted to the snippet: Colophon measures the longest line and
176
- the line count against a monospace grid and picks the largest size that fits on
177
- both axes, within `minFontScale`/`maxFontScale`. Those bounds are fractions of
178
- the image _width_, because that is what a feed scales a share image to — a
179
- landscape image would otherwise render the same snippet at half the size of its
180
- square counterpart. Code too long to fit at the floor is truncated with an
181
- ellipsis rather than shrunk into unreadability, and the panel then shrinks onto
182
- what's left so the code isn't marooned in a larger box.
183
-
184
- That trade matters most on the landscape sizes, which have around half the
185
- vertical room of the square: at the default floor an Open Graph image fits
186
- roughly nine lines of about sixty characters. Snippets written to that budget
187
- render identically at every size; longer ones keep their opening lines and lose
188
- the tail. Lower `minFontScale` if you would rather show the whole snippet small.
189
-
190
- Nothing in a finished image says the sample continued, so Colophon says it for
191
- you — a snippet that had to lose lines is reported through `onWarning`:
192
-
193
- ```
194
- colophon: content/post/index.md: code snippet does not fit the 1200x630 image at
195
- a legible size: 4 of 13 lines dropped. Shorten the sample, or lower
196
- code.minFontScale to fit it in smaller.
197
- ```
198
-
199
- A snippet's leading indentation is dropped before any of this, so lifting a
200
- sample out of a nested block costs you no width.
201
-
202
- Styling comes from `config.code`:
203
-
204
- ```ts
205
- export default defineConfig({
206
- colors: { brand: "#2563eb" },
207
- footer: "example.com",
208
- code: {
209
- theme: "night-owl", // any bundled Shiki theme
210
- fontFamily: '"JetBrains Mono", monospace',
211
- charWidthRatio: 0.6, // glyph advance ÷ font size, for your monospace face
212
- lineHeight: 1.55,
213
- tabSize: 2,
214
- cornerScale: 0.025,
215
- maxFontScale: 0.075, // fractions of the image width
216
- minFontScale: 0.025,
217
- },
218
- });
219
- ```
220
-
221
- `charWidthRatio` is how the layout knows where each token sits, so it must match
222
- the font actually used — `0.6` suits most monospace faces (Source Code Pro,
223
- Menlo, DejaVu Sans Mono); Consolas wants about `0.55`. Fonts must be installed
224
- where `sharp` can see them; the default stack ends in the generic `monospace`
225
- family so it always resolves to something.
226
-
227
- ## Configuration
228
-
229
- All fields are optional; sensible defaults apply.
230
-
231
- | Option | Default | Notes |
232
- | ------------ | ------------------------------ | --------------------------------------------------- |
233
- | `colors` | neutral indigo/pink | `brand`, `brandDark`, `brandWarm`, `foreground`. |
234
- | `background` | gradient derived from `colors` | Or a `{ type: "solid" }` / custom gradient. |
235
- | `fontFamily` | `Arial, Helvetica, sans-serif` | Uses fonts available to `sharp`/librsvg. |
236
- | `footer` | none | Footer text; omit the field for none. |
237
- | `badge` | none | Corner badge for `banner`; omit the field for none. |
238
- | `code` | `github-dark`, monospace stack | Styling for the `code` template (see above). |
239
- | `onWarning` | `console.warn` | Where compromises are reported (see below). |
240
- | `sizes` | `og` + `square` | Named output sizes (see below). |
241
- | `templates` | `banner`, `card`, `code` | Merged over the built-ins. |
242
-
243
- ### Warnings
244
-
245
- Some inputs can't be honoured exactly — code too long to render legibly, so far.
246
- Colophon renders anyway and reports the compromise through `onWarning`, which
247
- defaults to `console.warn`. Pass your build's logger to route them, or a no-op
248
- to silence them:
249
-
250
- ```ts
251
- export default defineConfig({
252
- onWarning: () => {},
253
- });
254
- ```
255
-
256
- `generate` prefixes each message with the content file it came from, so a build
257
- over a whole tree still names the post to fix.
258
-
259
- ### Output sizes and filenames
260
-
261
- Each output size is a named `{ name, width, height }`. The `name` becomes the
262
- filename suffix, so every image is distinct: `my-post-og.png`,
263
- `my-post-square.png`. The default set is one 1.91:1 Open Graph landscape and one
264
- 1:1 square, which between them satisfy `og:image` and both `twitter:image` card
265
- types (`summary_large_image` reuses the landscape; `summary` uses the square).
266
-
267
- `SIZE_PRESETS` ships the common standards — compose your own set:
268
-
269
- ```ts
270
- import { defineConfig, SIZE_PRESETS } from "@kensio/colophon";
271
-
272
- export default defineConfig({
273
- sizes: [
274
- SIZE_PRESETS.og, // 1200×630 — og:image (Facebook, LinkedIn, Slack, …)
275
- SIZE_PRESETS.square, // 1200×1200 — Twitter summary card, universal
276
- SIZE_PRESETS.twitter, // 1200×600 (2:1) — Twitter summary_large_image
277
- SIZE_PRESETS.pinterest, // 1000×1500 (2:3) — Pinterest
278
- { name: "hero", width: 1600, height: 900 }, // or anything custom
279
- ],
280
- });
281
- ```
282
-
283
- The base filename is the **post slug**: Colophon reads a top-level `slug` from
284
- frontmatter (SEO-friendly, keyword-rich), falling back to the file name — or the
285
- parent directory for `index.*` files. Point `slugField` at a different key, or
286
- override naming entirely with `generate`'s `outputPath` callback.
287
-
288
- ### Frontmatter shape
289
-
290
- By default Colophon reads a `meta_img_props` object and a `template` field
291
- within it, plus a top-level `slug`. All are configurable via walk options
292
- (`propsKey`, `templateField`, `defaultTemplate`, `slugField`, `extensions`) so
293
- you can match an existing convention.
91
+ - [Getting started](./docs/getting-started/ "Install, frontmatter, config and the CLI")
92
+ - [Templates](./docs/templates/ "The built-in layouts and how to register your own")
93
+ - [The code template](./docs/code-template/ "Syntax-highlighted code images")
94
+ - [The layout toolkit](./docs/layout/ "The primitives templates are built from")
95
+ - [Logos and photographs](./docs/configuration/images/ "Branding an image with a logo, avatar or background photo")
96
+ - [Configuration](./docs/configuration/ "Every option, and what happens to an unknown one")
97
+ - [Rebuilds](./docs/rebuilds/ "How Colophon decides what to render again")
98
+ - [Programmatic use](./docs/programmatic-use/ "The API behind the CLI")
99
+ - [Upgrading](./docs/upgrading/ "The breaking changes in 2.0 and 3.0")
294
100
 
295
101
  ## Sample output
296
102
 
297
- These are generated by [`scripts/gen-samples.ts`](scripts/gen-samples.ts) — run
103
+ These are generated by [`scripts/gen-samples.ts`](scripts/gen-samples.ts). Run
298
104
  `pnpm samples` to regenerate them after changing a template, then commit the
299
105
  updated PNGs so this gallery stays in sync.
300
106
 
@@ -331,26 +137,17 @@ updated PNGs so this gallery stays in sync.
331
137
  </tr>
332
138
  </table>
333
139
 
334
- ## Upgrading from 1.x
335
-
336
- Adding the `code` template made two small breaking changes:
337
-
338
- - `Template.render` may now return `string | Promise<string>`, and `buildSvg`
339
- is `async`. Custom templates that return a string still work unchanged; call
340
- sites of `buildSvg` need an `await`. `renderMetaImages` and `generate` were
341
- already async and are unaffected.
342
- - `MetaImageProps.title` is optional, and `walkContent`/`extractProps` no
343
- longer skip a file that declares props without a title — a `code` post
344
- describes its image entirely through `code` and `language`.
345
-
346
140
  ## Development
347
141
 
348
- - `pnpm build` compile to `dist/`.
349
- - `pnpm test` / `pnpm test:coverage` — run Vitest.
350
- - `pnpm lint` ESLint + Prettier check.
351
- - `pnpm fmt` auto-fix.
352
- - `pnpm samples` regenerate the README sample images into `docs/samples/`.
353
- - `pnpm check` — format, typecheck and test with coverage (run before committing).
142
+ | Script | What it does |
143
+ | --------------------------------- | -------------------------------------------------------------------------- |
144
+ | `pnpm build` | Compile to `dist/`. |
145
+ | `pnpm test`, `pnpm test:coverage` | Run Vitest. |
146
+ | `pnpm lint` | ESLint and Prettier check. |
147
+ | `pnpm fmt` | Auto-fix. |
148
+ | `pnpm samples` | Regenerate the sample images into `docs/samples/`. |
149
+ | `pnpm fta` | [FTA](https://ftaproject.dev) scores, failing on any file 50 or above. |
150
+ | `pnpm check` | Format, FTA, typecheck and test with coverage. Run this before committing. |
354
151
 
355
152
  ## License
356
153
 
@@ -1,8 +1,13 @@
1
- import type { Background, Dimensions } from "./types.js";
1
+ import type { Background, Dimensions, ImageAsset } from "./types.js";
2
2
  /**
3
3
  * Render a full-bleed background as SVG. For a gradient, this emits a `<defs>`
4
4
  * block with a `<linearGradient>` (using the given `id`) followed by a filled
5
5
  * rect; for a solid colour it emits just the rect.
6
+ *
7
+ * A background image has to be read before it can be drawn, which is the
8
+ * renderer's job. Called without one, an image background is the colour behind
9
+ * it, so a caller assembling an SVG by hand gets a plain image rather than a
10
+ * reference to something that is not there.
6
11
  */
7
- export declare function backgroundSvg(background: Background, dimensions: Dimensions, id: string): string;
12
+ export declare function backgroundSvg(background: Background, dimensions: Dimensions, id: string, asset?: ImageAsset): string;
8
13
  //# sourceMappingURL=background.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"background.d.ts","sourceRoot":"","sources":["../src/background.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEzD;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,MAAM,GACT,MAAM,CAqBR"}
1
+ {"version":3,"file":"background.d.ts","sourceRoot":"","sources":["../src/background.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAS,MAAM,YAAY,CAAC;AAiD5E;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,MAAM,EACV,KAAK,CAAC,EAAE,UAAU,GACjB,MAAM,CA8BR"}
@@ -1,13 +1,56 @@
1
+ import { box, image as imageElement, scrim } from "./layout/index.js";
2
+ /** Behind a background image, and either side of one that is `contain`ed. */
3
+ const defaultBackdrop = "#000000";
4
+ /**
5
+ * How heavily the default scrim shades, top and bottom.
6
+ *
7
+ * It starts at a quarter rather than at nothing, because a template is free to
8
+ * put its text anywhere and a wash that only darkens the bottom leaves a
9
+ * centred title sitting on whatever the middle of the photograph happens to
10
+ * be. Shading the whole picture a little and the bottom a lot covers both, and
11
+ * a project that wants the picture untouched at the top sets `from: 0`.
12
+ */
13
+ const defaultScrim = { from: 0.25, to: 0.65 };
14
+ /**
15
+ * A photograph behind the text: the backdrop, the picture, and the wash over
16
+ * it that keeps the text readable.
17
+ *
18
+ * The scrim is on by default and has to be turned off rather than on. Text
19
+ * over an unshaded photo is the failure this would otherwise ship with, and it
20
+ * is not one an author notices unless they look at every image.
21
+ */
22
+ function imageBackground(background, area, id, asset) {
23
+ const backdrop = box(area, { fill: background.color ?? defaultBackdrop });
24
+ if (asset === undefined) {
25
+ return backdrop;
26
+ }
27
+ const shade = background.scrim ?? {};
28
+ return (backdrop +
29
+ imageElement(area, asset.href, { fit: background.fit ?? "cover" }) +
30
+ scrim(area, `${id}-scrim`, {
31
+ ...(shade.color !== undefined && { color: shade.color }),
32
+ from: shade.from ?? defaultScrim.from,
33
+ to: shade.to ?? defaultScrim.to,
34
+ }));
35
+ }
1
36
  /**
2
37
  * Render a full-bleed background as SVG. For a gradient, this emits a `<defs>`
3
38
  * block with a `<linearGradient>` (using the given `id`) followed by a filled
4
39
  * rect; for a solid colour it emits just the rect.
40
+ *
41
+ * A background image has to be read before it can be drawn, which is the
42
+ * renderer's job. Called without one, an image background is the colour behind
43
+ * it, so a caller assembling an SVG by hand gets a plain image rather than a
44
+ * reference to something that is not there.
5
45
  */
6
- export function backgroundSvg(background, dimensions, id) {
46
+ export function backgroundSvg(background, dimensions, id, asset) {
7
47
  const { width, height } = dimensions;
8
48
  if (background.type === "solid") {
9
49
  return `<rect width="${String(width)}" height="${String(height)}" fill="${background.color}"/>`;
10
50
  }
51
+ if (background.type === "image") {
52
+ return imageBackground(background, { x: 0, y: 0, width, height }, id, asset);
53
+ }
11
54
  const from = background.from ?? { x: 0, y: 0 };
12
55
  const to = background.to ?? { x: 1, y: 1 };
13
56
  const stops = background.stops
@@ -1 +1 @@
1
- {"version":3,"file":"background.js","sourceRoot":"","sources":["../src/background.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAC3B,UAAsB,EACtB,UAAsB,EACtB,EAAU;IAEV,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;IAErC,IAAI,UAAU,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAChC,OAAO,gBAAgB,MAAM,CAAC,KAAK,CAAC,aAAa,MAAM,CAAC,MAAM,CAAC,WAAW,UAAU,CAAC,KAAK,KAAK,CAAC;IAClG,CAAC;IAED,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAC/C,MAAM,EAAE,GAAG,UAAU,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAE3C,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK;SAC3B,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,iBAAiB,IAAI,CAAC,MAAM,iBAAiB,IAAI,CAAC,KAAK,KAAK,CAAC;SAC3E,IAAI,CAAC,EAAE,CAAC,CAAC;IAEZ,OAAO,CACL,QAAQ;QACR,uBAAuB,EAAE,SAAS,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG;QAC1E,QAAQ,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,mBAAmB;QACtE,SAAS;QACT,gBAAgB,MAAM,CAAC,KAAK,CAAC,aAAa,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CACjF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"background.js","sourceRoot":"","sources":["../src/background.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,KAAK,IAAI,YAAY,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAGtE,6EAA6E;AAC7E,MAAM,eAAe,GAAG,SAAS,CAAC;AAElC;;;;;;;;GAQG;AACH,MAAM,YAAY,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AAE9C;;;;;;;GAOG;AACH,SAAS,eAAe,CACtB,UAA2D,EAC3D,IAAU,EACV,EAAU,EACV,KAA6B;IAE7B,MAAM,QAAQ,GAAG,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,KAAK,IAAI,eAAe,EAAE,CAAC,CAAC;IAE1E,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,KAAK,GAAU,UAAU,CAAC,KAAK,IAAI,EAAE,CAAC;IAE5C,OAAO,CACL,QAAQ;QACR,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,UAAU,CAAC,GAAG,IAAI,OAAO,EAAE,CAAC;QAClE,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE;YACzB,GAAG,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;YACxD,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,YAAY,CAAC,IAAI;YACrC,EAAE,EAAE,KAAK,CAAC,EAAE,IAAI,YAAY,CAAC,EAAE;SAChC,CAAC,CACH,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAC3B,UAAsB,EACtB,UAAsB,EACtB,EAAU,EACV,KAAkB;IAElB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;IAErC,IAAI,UAAU,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAChC,OAAO,gBAAgB,MAAM,CAAC,KAAK,CAAC,aAAa,MAAM,CAAC,MAAM,CAAC,WAAW,UAAU,CAAC,KAAK,KAAK,CAAC;IAClG,CAAC;IAED,IAAI,UAAU,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAChC,OAAO,eAAe,CACpB,UAAU,EACV,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAC7B,EAAE,EACF,KAAK,CACN,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAC/C,MAAM,EAAE,GAAG,UAAU,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAE3C,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK;SAC3B,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,iBAAiB,IAAI,CAAC,MAAM,iBAAiB,IAAI,CAAC,KAAK,KAAK,CAAC;SAC3E,IAAI,CAAC,EAAE,CAAC,CAAC;IAEZ,OAAO,CACL,QAAQ;QACR,uBAAuB,EAAE,SAAS,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG;QAC1E,QAAQ,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,mBAAmB;QACtE,SAAS;QACT,gBAAgB,MAAM,CAAC,KAAK,CAAC,aAAa,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CACjF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The parsed command line.
3
+ */
4
+ export interface CliArgs {
5
+ readonly contentDir: string;
6
+ readonly configPath: string | undefined;
7
+ readonly overwrite: boolean;
8
+ readonly concurrency: number | undefined;
9
+ }
10
+ /** Help text for `--help`, and for a run that asks for nothing else. */
11
+ export declare const usage = "colophon: generate social meta images from frontmatter\n\nUsage:\n colophon [contentDir] [options]\n\nImages carry a stamp of the props, config and size they came from, so a rebuild\nrenders only the ones that have actually changed.\n\nOptions:\n -c, --config <path> Load a config module. Its default export is either a\n ColophonConfig or a function (async or not) returning\n one, for a config that has to compute something.\n -f, --force Re-render every image, ignoring the stamps\n -o, --overwrite Alias for --force\n --concurrency <n> How many images to render at once\n -h, --help Show this help\n\nDefaults:\n contentDir content\n --concurrency one per available CPU";
12
+ /** Read the command line into the options `generate` takes. */
13
+ export declare function parseCliArgs(argv: readonly string[]): CliArgs;
14
+ //# sourceMappingURL=args.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C;AAED,wEAAwE;AACxE,eAAO,MAAM,KAAK,gxBAmB4B,CAAC;AAwB/C,+DAA+D;AAC/D,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CA4B7D"}
@@ -0,0 +1,67 @@
1
+ /** Help text for `--help`, and for a run that asks for nothing else. */
2
+ export const usage = `colophon: generate social meta images from frontmatter
3
+
4
+ Usage:
5
+ colophon [contentDir] [options]
6
+
7
+ Images carry a stamp of the props, config and size they came from, so a rebuild
8
+ renders only the ones that have actually changed.
9
+
10
+ Options:
11
+ -c, --config <path> Load a config module. Its default export is either a
12
+ ColophonConfig or a function (async or not) returning
13
+ one, for a config that has to compute something.
14
+ -f, --force Re-render every image, ignoring the stamps
15
+ -o, --overwrite Alias for --force
16
+ --concurrency <n> How many images to render at once
17
+ -h, --help Show this help
18
+
19
+ Defaults:
20
+ contentDir content
21
+ --concurrency one per available CPU`;
22
+ /** `--overwrite` is kept as an alias so existing build scripts keep working. */
23
+ const forceFlags = new Set(["-f", "--force", "-o", "--overwrite"]);
24
+ /** Flags that take the next argument as their value. */
25
+ const valueFlags = new Set(["-c", "--config", "--concurrency"]);
26
+ /**
27
+ * A mistyped count would otherwise reach `generate` as `NaN` and be reported
28
+ * without naming the flag it came from, so it is rejected here instead.
29
+ */
30
+ function parseConcurrency(value) {
31
+ const parsed = Number(value);
32
+ if (!Number.isSafeInteger(parsed) || parsed < 1) {
33
+ throw new Error(`Invalid value for --concurrency: "${value}"; expected a positive integer.`);
34
+ }
35
+ return parsed;
36
+ }
37
+ /** Read the command line into the options `generate` takes. */
38
+ export function parseCliArgs(argv) {
39
+ let contentDir = "content";
40
+ let configPath;
41
+ let shouldOverwrite = false;
42
+ let concurrency;
43
+ for (let index = 0; index < argv.length; index += 1) {
44
+ const arg = argv[index];
45
+ if (arg !== undefined && valueFlags.has(arg)) {
46
+ index += 1;
47
+ const value = argv[index];
48
+ if (value === undefined) {
49
+ throw new Error(`Missing value for ${arg}`);
50
+ }
51
+ if (arg === "--concurrency") {
52
+ concurrency = parseConcurrency(value);
53
+ }
54
+ else {
55
+ configPath = value;
56
+ }
57
+ }
58
+ else if (arg !== undefined && forceFlags.has(arg)) {
59
+ shouldOverwrite = true;
60
+ }
61
+ else if (arg !== undefined && !arg.startsWith("-")) {
62
+ contentDir = arg;
63
+ }
64
+ }
65
+ return { contentDir, configPath, overwrite: shouldOverwrite, concurrency };
66
+ }
67
+ //# sourceMappingURL=args.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args.js","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAUA,wEAAwE;AACxE,MAAM,CAAC,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;8CAmByB,CAAC;AAE/C,gFAAgF;AAChF,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC;AAEnE,wDAAwD;AACxD,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC;AAEhE;;;GAGG;AACH,SAAS,gBAAgB,CAAC,KAAa;IACrC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE7B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CACb,qCAAqC,KAAK,iCAAiC,CAC5E,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,YAAY,CAAC,IAAuB;IAClD,IAAI,UAAU,GAAG,SAAS,CAAC;IAC3B,IAAI,UAA8B,CAAC;IACnC,IAAI,eAAe,GAAG,KAAK,CAAC;IAC5B,IAAI,WAA+B,CAAC;IAEpC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACpD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QAExB,IAAI,GAAG,KAAK,SAAS,IAAI,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7C,KAAK,IAAI,CAAC,CAAC;YACX,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;YAC1B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,EAAE,CAAC,CAAC;YAC9C,CAAC;YACD,IAAI,GAAG,KAAK,eAAe,EAAE,CAAC;gBAC5B,WAAW,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;YACxC,CAAC;iBAAM,CAAC;gBACN,UAAU,GAAG,KAAK,CAAC;YACrB,CAAC;QACH,CAAC;aAAM,IAAI,GAAG,KAAK,SAAS,IAAI,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACpD,eAAe,GAAG,IAAI,CAAC;QACzB,CAAC;aAAM,IAAI,GAAG,KAAK,SAAS,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACrD,UAAU,GAAG,GAAG,CAAC;QACnB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC;AAC7E,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { ColophonConfig } from "../types.js";
2
+ /**
3
+ * Load the config module named by `--config`.
4
+ *
5
+ * The default export may be the config itself or a function returning one,
6
+ * possibly async. A config that has to compute something cannot be written as
7
+ * a literal, and without the function form such a project has to abandon the
8
+ * CLI and call `generate` from a script of its own, reimplementing the
9
+ * reporting the CLI already does along the way.
10
+ */
11
+ export declare function loadConfig(configPath: string | undefined): Promise<ColophonConfig | undefined>;
12
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/cli/config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,aAAa,CAAC;AAwBvE;;;;;;;;GAQG;AACH,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAiBrC"}
@@ -0,0 +1,43 @@
1
+ import path from "node:path";
2
+ import { pathToFileURL } from "node:url";
3
+ /**
4
+ * A module that exports nothing usable is a mistake rather than a config that
5
+ * happens to be empty: the run named the file on the command line, so falling
6
+ * back to the defaults would render a whole tree with none of what it asked
7
+ * for and say nothing about it.
8
+ *
9
+ * An array is rejected for that reason and not for its own: `validateConfig`
10
+ * reads the keys of what it is given, and an empty one has none, so it is the
11
+ * one non-config that would otherwise pass as an empty config.
12
+ */
13
+ function assertConfig(value, source) {
14
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
15
+ throw new Error(`${source} is not a config object.` +
16
+ ` Export a ColophonConfig, or a function returning one.`);
17
+ }
18
+ }
19
+ /**
20
+ * Load the config module named by `--config`.
21
+ *
22
+ * The default export may be the config itself or a function returning one,
23
+ * possibly async. A config that has to compute something cannot be written as
24
+ * a literal, and without the function form such a project has to abandon the
25
+ * CLI and call `generate` from a script of its own, reimplementing the
26
+ * reporting the CLI already does along the way.
27
+ */
28
+ export async function loadConfig(configPath) {
29
+ if (configPath === undefined) {
30
+ return undefined;
31
+ }
32
+ const url = pathToFileURL(path.resolve(configPath)).href;
33
+ const module = (await import(url));
34
+ const exported = module.default;
35
+ if (typeof exported === "function") {
36
+ const config = await exported();
37
+ assertConfig(config, `The function exported by ${configPath}`);
38
+ return config;
39
+ }
40
+ assertConfig(exported, `The default export of ${configPath}`);
41
+ return exported;
42
+ }
43
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/cli/config.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC;;;;;;;;;GASG;AACH,SAAS,YAAY,CACnB,KAAc,EACd,MAAc;IAEd,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,0BAA0B;YACjC,wDAAwD,CAC3D,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,UAA8B;IAE9B,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;IACzD,MAAM,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,CAAsC,CAAC;IACxE,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC;IAEhC,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,MAAM,QAAQ,EAAE,CAAC;QAChC,YAAY,CAAC,MAAM,EAAE,4BAA4B,UAAU,EAAE,CAAC,CAAC;QAC/D,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,YAAY,CAAC,QAAQ,EAAE,yBAAyB,UAAU,EAAE,CAAC,CAAC;IAC9D,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}