@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,34 @@
1
+ /**
2
+ * A URL that names its own scheme. Schemes are case-insensitive, so `HTTPS://`
3
+ * is as absolute as `https://` and prefixing it would produce nonsense.
4
+ */
5
+ const schemed = /^[a-z][a-z\d+.-]*:\/\//i;
6
+ /** The scheme a base URL is served over, `https:` included. */
7
+ function schemeOf(url) {
8
+ return /^[a-z][a-z\d+.-]*:/i.exec(url)?.[0];
9
+ }
10
+ /**
11
+ * Resolve an image URL against the site's base.
12
+ *
13
+ * Open Graph wants an absolute URL: a crawler reads the tag out of the page
14
+ * and has nothing to resolve a relative one against. A manifest holds whatever
15
+ * the placement's `urlBase` said, which is usually site-relative, so this is
16
+ * where the two halves meet.
17
+ *
18
+ * A URL that names its own scheme is returned untouched, since a placement
19
+ * pointing at a CDN has said everything there is to say. A scheme-relative one
20
+ * (`//cdn`) has not: it is relative to the page's scheme, which is exactly what
21
+ * a crawler reading the tag elsewhere does not have, so it borrows the base's.
22
+ */
23
+ export function absoluteUrl(url, baseUrl) {
24
+ if (baseUrl === undefined || schemed.test(url)) {
25
+ return url;
26
+ }
27
+ if (url.startsWith("//")) {
28
+ const scheme = schemeOf(baseUrl);
29
+ return scheme === undefined ? url : `${scheme}${url}`;
30
+ }
31
+ const base = baseUrl.replace(/\/+$/, "");
32
+ return url.startsWith("/") ? `${base}${url}` : `${base}/${url}`;
33
+ }
34
+ //# sourceMappingURL=url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/meta/url.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,GAAG,yBAAyB,CAAC;AAE1C,+DAA+D;AAC/D,SAAS,QAAQ,CAAC,GAAW;IAC3B,OAAO,qBAAqB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,OAA2B;IAClE,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,OAAO,GAAG,CAAC;IACb,CAAC;IAED,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;QACjC,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,GAAG,EAAE,CAAC;IACxD,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAEzC,OAAO,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,GAAG,EAAE,CAAC;AAClE,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { Placement } from "../types.js";
2
+ /**
3
+ * Reject a placement that cannot place anything.
4
+ *
5
+ * The types require all of this, but a CLI user's config module is plain
6
+ * JavaScript with nothing checking it, and none of these omissions fails
7
+ * anywhere near the config: a missing `dir` surfaces as a complaint about an
8
+ * argument to `path`, and the rest as something not being a function. Key
9
+ * validation is no help either, since it is the option that is not there.
10
+ *
11
+ * This sits here rather than in `validate/`, which checks keys and the names
12
+ * of closed sets, for the reason `fonts/resolve.ts` does: what a value has to
13
+ * be is known by whatever is about to use it.
14
+ */
15
+ export declare function assertPlacement(placement: Placement): void;
16
+ //# sourceMappingURL=check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/placement/check.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CA+C1D"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Reject a placement that cannot place anything.
3
+ *
4
+ * The types require all of this, but a CLI user's config module is plain
5
+ * JavaScript with nothing checking it, and none of these omissions fails
6
+ * anywhere near the config: a missing `dir` surfaces as a complaint about an
7
+ * argument to `path`, and the rest as something not being a function. Key
8
+ * validation is no help either, since it is the option that is not there.
9
+ *
10
+ * This sits here rather than in `validate/`, which checks keys and the names
11
+ * of closed sets, for the reason `fonts/resolve.ts` does: what a value has to
12
+ * be is known by whatever is about to use it.
13
+ */
14
+ export function assertPlacement(placement) {
15
+ const declared = placement;
16
+ if (declared.urlBase !== undefined && typeof declared.urlBase !== "string") {
17
+ throw new TypeError(`placement urlBase must be a string; it is prefixed to each image's path.`);
18
+ }
19
+ if (declared.hash !== undefined && typeof declared.hash !== "boolean") {
20
+ throw new TypeError(`placement hash must be true or false. Anything else reads as neither,` +
21
+ ` so the images would be written unhashed without a word about it.`);
22
+ }
23
+ if (placement.strategy === "public-dir") {
24
+ if (typeof declared.dir !== "string" || declared.dir === "") {
25
+ throw new TypeError(`placement "public-dir" needs a "dir" to write the images into.`);
26
+ }
27
+ return;
28
+ }
29
+ if (placement.strategy !== "custom") {
30
+ return;
31
+ }
32
+ if (typeof declared.path !== "function") {
33
+ throw new TypeError(`placement "custom" needs a "path" function saying where each image goes.`);
34
+ }
35
+ if (declared.url !== undefined && typeof declared.url !== "function") {
36
+ throw new TypeError(`placement "custom" takes a "url" function, or none at all for images` +
37
+ ` that are written but not served.`);
38
+ }
39
+ }
40
+ //# sourceMappingURL=check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/placement/check.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,eAAe,CAAC,SAAoB;IAClD,MAAM,QAAQ,GAAG,SAMhB,CAAC;IAEF,IAAI,QAAQ,CAAC,OAAO,KAAK,SAAS,IAAI,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC3E,MAAM,IAAI,SAAS,CACjB,0EAA0E,CAC3E,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACtE,MAAM,IAAI,SAAS,CACjB,uEAAuE;YACrE,mEAAmE,CACtE,CAAC;IACJ,CAAC;IAED,IAAI,SAAS,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;QACxC,IAAI,OAAO,QAAQ,CAAC,GAAG,KAAK,QAAQ,IAAI,QAAQ,CAAC,GAAG,KAAK,EAAE,EAAE,CAAC;YAC5D,MAAM,IAAI,SAAS,CACjB,gEAAgE,CACjE,CAAC;QACJ,CAAC;QACD,OAAO;IACT,CAAC;IAED,IAAI,SAAS,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACpC,OAAO;IACT,CAAC;IAED,IAAI,OAAO,QAAQ,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACxC,MAAM,IAAI,SAAS,CACjB,0EAA0E,CAC3E,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,GAAG,KAAK,SAAS,IAAI,OAAO,QAAQ,CAAC,GAAG,KAAK,UAAU,EAAE,CAAC;QACrE,MAAM,IAAI,SAAS,CACjB,sEAAsE;YACpE,mCAAmC,CACtC,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { ContentFile, OutputSize, Placement } from "../types.js";
2
+ export { besideContent, imageName } from "./relative.js";
3
+ /**
4
+ * Where one image ends up: the path its bytes are written to, and the URL it
5
+ * is served at, if the placement knows one.
6
+ */
7
+ export interface PlacedImage {
8
+ readonly path: string;
9
+ readonly url: string | undefined;
10
+ }
11
+ /**
12
+ * Places each image of a build.
13
+ *
14
+ * The stamp is handed over whether or not the placement wants it: it is what a
15
+ * hashed filename is built from, and a placement that does not hash simply
16
+ * ignores it.
17
+ */
18
+ export type Placer = (file: ContentFile, size: OutputSize, stamp: string) => PlacedImage;
19
+ /**
20
+ * Build the function that places every image of a build.
21
+ *
22
+ * The strategies differ only in the root an image is placed under and whether
23
+ * it keeps the directories its post sits in: `beside-content` keeps them,
24
+ * which is the page-bundle convention, and `public-dir` drops them so that a
25
+ * flat directory can be served as one. Either way the same relative path
26
+ * makes the disk path and the URL, so the two cannot drift apart.
27
+ */
28
+ export declare function createPlacer(placement: Placement | undefined, contentDir: string): Placer;
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/placement/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAItE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEzD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC;AAED;;;;;;GAMG;AACH,MAAM,MAAM,MAAM,GAAG,CACnB,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,MAAM,KACV,WAAW,CAAC;AAyBjB;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,SAAS,GAAG,SAAS,EAChC,UAAU,EAAE,MAAM,GACjB,MAAM,CAkCR"}
@@ -0,0 +1,61 @@
1
+ import path from "node:path";
2
+ import { assertPlacement } from "./check.js";
3
+ import { besideContent, imageName } from "./relative.js";
4
+ export { besideContent, imageName } from "./relative.js";
5
+ /**
6
+ * Prefix a `urlBase` onto an image's path under the root that placed it.
7
+ *
8
+ * No base, no URL: a directory on disk does not say how, or whether, it is
9
+ * served, and a URL Colophon invented would be worse than the gap it fills,
10
+ * since the whole point of writing one down is that a site can trust it.
11
+ */
12
+ function toUrl(urlBase, relative) {
13
+ if (urlBase === undefined) {
14
+ return undefined;
15
+ }
16
+ return `${urlBase.replace(/\/+$/, "")}/${relative}`;
17
+ }
18
+ /** Join a path that uses URL separators back into a platform path. */
19
+ function under(root, relative) {
20
+ return path.join(root, ...relative.split("/"));
21
+ }
22
+ /**
23
+ * Build the function that places every image of a build.
24
+ *
25
+ * The strategies differ only in the root an image is placed under and whether
26
+ * it keeps the directories its post sits in: `beside-content` keeps them,
27
+ * which is the page-bundle convention, and `public-dir` drops them so that a
28
+ * flat directory can be served as one. Either way the same relative path
29
+ * makes the disk path and the URL, so the two cannot drift apart.
30
+ */
31
+ export function createPlacer(placement, contentDir) {
32
+ if (placement !== undefined) {
33
+ assertPlacement(placement);
34
+ }
35
+ if (placement === undefined || placement.strategy === "beside-content") {
36
+ const urlBase = placement?.urlBase;
37
+ const isHashes = placement?.hash === true;
38
+ return (file, size, stamp) => {
39
+ const relative = besideContent(file, size, isHashes ? stamp : undefined);
40
+ return {
41
+ path: under(contentDir, relative),
42
+ url: toUrl(urlBase, relative),
43
+ };
44
+ };
45
+ }
46
+ if (placement.strategy === "public-dir") {
47
+ const isHashes = placement.hash === true;
48
+ return (file, size, stamp) => {
49
+ const relative = imageName(file, size, isHashes ? stamp : undefined);
50
+ return {
51
+ path: under(placement.dir, relative),
52
+ url: toUrl(placement.urlBase, relative),
53
+ };
54
+ };
55
+ }
56
+ return (file, size) => ({
57
+ path: placement.path(file, size),
58
+ url: placement.url?.(file, size),
59
+ });
60
+ }
61
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/placement/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAwBzD;;;;;;GAMG;AACH,SAAS,KAAK,CACZ,OAA2B,EAC3B,QAAgB;IAEhB,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,QAAQ,EAAE,CAAC;AACtD,CAAC;AAED,sEAAsE;AACtE,SAAS,KAAK,CAAC,IAAY,EAAE,QAAgB;IAC3C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAC1B,SAAgC,EAChC,UAAkB;IAElB,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,eAAe,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC;IAED,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,CAAC,QAAQ,KAAK,gBAAgB,EAAE,CAAC;QACvE,MAAM,OAAO,GAAG,SAAS,EAAE,OAAO,CAAC;QACnC,MAAM,QAAQ,GAAG,SAAS,EAAE,IAAI,KAAK,IAAI,CAAC;QAE1C,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;YAC3B,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YACzE,OAAO;gBACL,IAAI,EAAE,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC;gBACjC,GAAG,EAAE,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC;aAC9B,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,SAAS,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;QACxC,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,KAAK,IAAI,CAAC;QAEzC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;YAC3B,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YACrE,OAAO;gBACL,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC;gBACpC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC;aACxC,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QACtB,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC;QAChC,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;KACjC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { ContentFile, OutputSize } from "../types.js";
2
+ /**
3
+ * The filename one image is written under: `<slug>-<size>.png`, or
4
+ * `<slug>-<size>.<hash>.png` where the placement asks for a hash. The slug
5
+ * carries the post's keywords, and the size name keeps every image of a post
6
+ * distinct (`my-post-og.png`, `my-post-square.png`).
7
+ *
8
+ * A slug carrying directories of its own puts them in the name, so the image's
9
+ * path mirrors the route wherever it is placed. That is what the `route`
10
+ * strategy produces, and what a frontmatter `slug` of `docs/intro` means.
11
+ *
12
+ * The digest is the image's rebuild stamp: the props, the config and the size
13
+ * it is drawn from. Hashing the rendered bytes would be a truer name, but they
14
+ * are not known until the image has been rendered, and the point of the stamp
15
+ * is not rendering the ones that have not changed.
16
+ */
17
+ export declare function imageName(file: ContentFile, size: OutputSize, hash: string | undefined): string;
18
+ /**
19
+ * Where an image goes relative to the content root, in URL form.
20
+ *
21
+ * Slashes rather than the platform's separator, because this is also what a
22
+ * URL is built from: a Windows build must not serve `posts\my-post\a.png`.
23
+ * The disk path is joined back up per platform by whoever places it.
24
+ *
25
+ * A slug with directories of its own is placed from the content root, so its
26
+ * path mirrors the route. Resolving it beside the file would repeat the
27
+ * directories already in the slug, putting `services/iam` under
28
+ * `content/services/iam/`.
29
+ */
30
+ export declare function besideContent(file: ContentFile, size: OutputSize, hash: string | undefined): string;
31
+ //# sourceMappingURL=relative.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relative.d.ts","sourceRoot":"","sources":["../../src/placement/relative.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAW3D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,GAAG,SAAS,GACvB,MAAM,CAMR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,GAAG,SAAS,GACvB,MAAM,CAYR"}
@@ -0,0 +1,53 @@
1
+ import path from "node:path";
2
+ /**
3
+ * How much of an image's digest goes in its filename.
4
+ *
5
+ * Eight hex characters is what the asset pipelines settle on, and it is the
6
+ * length at which a site would need tens of thousands of images before two of
7
+ * them were likely to collide.
8
+ */
9
+ const hashLength = 8;
10
+ /**
11
+ * The filename one image is written under: `<slug>-<size>.png`, or
12
+ * `<slug>-<size>.<hash>.png` where the placement asks for a hash. The slug
13
+ * carries the post's keywords, and the size name keeps every image of a post
14
+ * distinct (`my-post-og.png`, `my-post-square.png`).
15
+ *
16
+ * A slug carrying directories of its own puts them in the name, so the image's
17
+ * path mirrors the route wherever it is placed. That is what the `route`
18
+ * strategy produces, and what a frontmatter `slug` of `docs/intro` means.
19
+ *
20
+ * The digest is the image's rebuild stamp: the props, the config and the size
21
+ * it is drawn from. Hashing the rendered bytes would be a truer name, but they
22
+ * are not known until the image has been rendered, and the point of the stamp
23
+ * is not rendering the ones that have not changed.
24
+ */
25
+ export function imageName(file, size, hash) {
26
+ const stem = `${file.slug}-${size.name}`;
27
+ return hash === undefined
28
+ ? `${stem}.png`
29
+ : `${stem}.${hash.slice(0, hashLength)}.png`;
30
+ }
31
+ /**
32
+ * Where an image goes relative to the content root, in URL form.
33
+ *
34
+ * Slashes rather than the platform's separator, because this is also what a
35
+ * URL is built from: a Windows build must not serve `posts\my-post\a.png`.
36
+ * The disk path is joined back up per platform by whoever places it.
37
+ *
38
+ * A slug with directories of its own is placed from the content root, so its
39
+ * path mirrors the route. Resolving it beside the file would repeat the
40
+ * directories already in the slug, putting `services/iam` under
41
+ * `content/services/iam/`.
42
+ */
43
+ export function besideContent(file, size, hash) {
44
+ const name = imageName(file, size, hash);
45
+ if (file.slug.includes("/")) {
46
+ return name;
47
+ }
48
+ const directory = path.dirname(file.contentPath);
49
+ return directory === "." || directory === ""
50
+ ? name
51
+ : `${directory.split(path.sep).join("/")}/${name}`;
52
+ }
53
+ //# sourceMappingURL=relative.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relative.js","sourceRoot":"","sources":["../../src/placement/relative.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B;;;;;;GAMG;AACH,MAAM,UAAU,GAAG,CAAC,CAAC;AAErB;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,SAAS,CACvB,IAAiB,EACjB,IAAgB,EAChB,IAAwB;IAExB,MAAM,IAAI,GAAG,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;IAEzC,OAAO,IAAI,KAAK,SAAS;QACvB,CAAC,CAAC,GAAG,IAAI,MAAM;QACf,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC;AACjD,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAiB,EACjB,IAAgB,EAChB,IAAwB;IAExB,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAEzC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAEjD,OAAO,SAAS,KAAK,GAAG,IAAI,SAAS,KAAK,EAAE;QAC1C,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;AACvD,CAAC"}
package/dist/pool.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Map over `items` with at most `limit` calls to `worker` in flight at once,
3
+ * returning the results in input order.
4
+ *
5
+ * `Promise.all` over a mapped array starts everything at once, which for a
6
+ * few hundred images means a few hundred rasterisations queued on the thread
7
+ * pool with every pending bitmap held in memory. This starts `limit` workers
8
+ * instead and lets each pull the next item as it finishes, so the work in
9
+ * flight stays bounded however large the input is.
10
+ *
11
+ * The first rejection propagates, as it would from `Promise.all`. Items
12
+ * already in flight run to completion, since there is no cancelling a render,
13
+ * but no further ones are started.
14
+ *
15
+ * Throws if `limit` is not a positive integer.
16
+ */
17
+ export declare function mapConcurrent<Item, Result>(items: readonly Item[], limit: number, worker: (item: Item, index: number) => Promise<Result>): Promise<Result[]>;
18
+ //# sourceMappingURL=pool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAC9C,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GACrD,OAAO,CAAC,MAAM,EAAE,CAAC,CA8CnB"}
package/dist/pool.js ADDED
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Map over `items` with at most `limit` calls to `worker` in flight at once,
3
+ * returning the results in input order.
4
+ *
5
+ * `Promise.all` over a mapped array starts everything at once, which for a
6
+ * few hundred images means a few hundred rasterisations queued on the thread
7
+ * pool with every pending bitmap held in memory. This starts `limit` workers
8
+ * instead and lets each pull the next item as it finishes, so the work in
9
+ * flight stays bounded however large the input is.
10
+ *
11
+ * The first rejection propagates, as it would from `Promise.all`. Items
12
+ * already in flight run to completion, since there is no cancelling a render,
13
+ * but no further ones are started.
14
+ *
15
+ * Throws if `limit` is not a positive integer.
16
+ */
17
+ export async function mapConcurrent(items, limit, worker) {
18
+ // A limit below one starts no workers at all, and an empty `Promise.all`
19
+ // resolves happily, so the caller would get an empty result back as though
20
+ // there had been nothing to do. A build reporting success having rendered
21
+ // nothing is the failure worth being loud about.
22
+ if (!Number.isSafeInteger(limit) || limit < 1) {
23
+ throw new Error(`Invalid concurrency limit ${String(limit)}; expected a positive integer.`);
24
+ }
25
+ // Assigned by index rather than pushed, so results come back in input order
26
+ // however the workers interleave.
27
+ const results = [];
28
+ // One shared iterator is the queue: each worker pulls the next entry when it
29
+ // is free, so a slow item holds up only itself rather than a fixed share of
30
+ // the work.
31
+ const queue = items.entries();
32
+ let isStopped = false;
33
+ async function run() {
34
+ for (const [index, item] of queue) {
35
+ if (isStopped) {
36
+ return;
37
+ }
38
+ // Awaiting in the loop is the whole point: a worker takes one item at a
39
+ // time, and the parallelism comes from there being several of them.
40
+ // eslint-disable-next-line no-await-in-loop
41
+ results[index] = await worker(item, index);
42
+ }
43
+ }
44
+ const workers = Array.from({ length: Math.min(limit, items.length) }, () => run());
45
+ try {
46
+ await Promise.all(workers);
47
+ }
48
+ catch (error) {
49
+ // The run is already lost, so stop feeding it: a build that fails on the
50
+ // first file should not render the rest of the tree before it exits.
51
+ isStopped = true;
52
+ throw error;
53
+ }
54
+ return results;
55
+ }
56
+ //# sourceMappingURL=pool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pool.js","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,KAAsB,EACtB,KAAa,EACb,MAAsD;IAEtD,yEAAyE;IACzE,2EAA2E;IAC3E,0EAA0E;IAC1E,iDAAiD;IACjD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CACb,6BAA6B,MAAM,CAAC,KAAK,CAAC,gCAAgC,CAC3E,CAAC;IACJ,CAAC;IAED,4EAA4E;IAC5E,kCAAkC;IAClC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,6EAA6E;IAC7E,4EAA4E;IAC5E,YAAY;IACZ,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;IAC9B,IAAI,SAAS,GAAG,KAAK,CAAC;IAEtB,KAAK,UAAU,GAAG;QAChB,KAAK,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC;YAClC,IAAI,SAAS,EAAE,CAAC;gBACd,OAAO;YACT,CAAC;YACD,wEAAwE;YACxE,oEAAoE;YACpE,4CAA4C;YAC5C,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,CACzE,GAAG,EAAE,CACN,CAAC;IAEF,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,yEAAyE;QACzE,qEAAqE;QACrE,SAAS,GAAG,IAAI,CAAC;QACjB,MAAM,KAAK,CAAC;IACd,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Read a prop as a string, coercing the scalar types YAML frontmatter yields
3
+ * (numbers, booleans) and returning `undefined` for anything else, since
4
+ * templates treat "not a usable string" and "absent" the same way.
5
+ */
6
+ export declare function optionalString(value: unknown): string | undefined;
7
+ //# sourceMappingURL=props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../src/props.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAcjE"}
package/dist/props.js ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Read a prop as a string, coercing the scalar types YAML frontmatter yields
3
+ * (numbers, booleans) and returning `undefined` for anything else, since
4
+ * templates treat "not a usable string" and "absent" the same way.
5
+ */
6
+ export function optionalString(value) {
7
+ if (typeof value === "string") {
8
+ return value;
9
+ }
10
+ if (typeof value === "number" ||
11
+ typeof value === "boolean" ||
12
+ typeof value === "bigint") {
13
+ return String(value);
14
+ }
15
+ return undefined;
16
+ }
17
+ //# sourceMappingURL=props.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"props.js","sourceRoot":"","sources":["../src/props.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,SAAS;QAC1B,OAAO,KAAK,KAAK,QAAQ,EACzB,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { ColophonConfig, MetaImageProps, RenderedMetaImage } from "../types.js";
2
+ export { buildSvg } from "./svg.js";
3
+ export { renderSvgToPng } from "./png.js";
4
+ /**
5
+ * Render an image for every configured output size from a single set of props.
6
+ * This is the reusable core: it takes props and config and returns rendered
7
+ * bytes, with no filesystem or content-discovery concerns.
8
+ */
9
+ export declare function renderMetaImages(props: MetaImageProps, config?: ColophonConfig): Promise<RenderedMetaImage[]>;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAKrB,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,cAAc,EACrB,MAAM,CAAC,EAAE,cAAc,GACtB,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAiB9B"}
@@ -0,0 +1,27 @@
1
+ import { resolveConfig } from "../config/index.js";
2
+ import { resolveConfigForSize } from "../config/size.js";
3
+ import { renderSvgToPng } from "./png.js";
4
+ import { buildSvg } from "./svg.js";
5
+ import { selectTemplate } from "./template.js";
6
+ export { buildSvg } from "./svg.js";
7
+ export { renderSvgToPng } from "./png.js";
8
+ /**
9
+ * Render an image for every configured output size from a single set of props.
10
+ * This is the reusable core: it takes props and config and returns rendered
11
+ * bytes, with no filesystem or content-discovery concerns.
12
+ */
13
+ export async function renderMetaImages(props, config) {
14
+ const resolved = resolveConfig(config);
15
+ // Validate the template once up front so a bad name fails fast.
16
+ selectTemplate(resolved, props.template);
17
+ return Promise.all(resolved.sizes.map(async (size) => {
18
+ // Each size renders with its own overrides folded in, so one size wanting
19
+ // a smaller minimum font does not mean a second pass over everything.
20
+ const sizeConfig = resolveConfigForSize(config, size);
21
+ const dimensions = { width: size.width, height: size.height };
22
+ const svg = await buildSvg(props, sizeConfig, dimensions);
23
+ const png = await renderSvgToPng(svg, dimensions, sizeConfig);
24
+ return { name: size.name, dimensions, svg, png };
25
+ }));
26
+ }
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAMzD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,KAAqB,EACrB,MAAuB;IAEvB,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAEvC,gEAAgE;IAChE,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAEzC,OAAO,OAAO,CAAC,GAAG,CAChB,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QAChC,0EAA0E;QAC1E,sEAAsE;QACtE,MAAM,UAAU,GAAG,oBAAoB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACtD,MAAM,UAAU,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QAC9D,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;QAC1D,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;QAC9D,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IACnD,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { Dimensions, ResolvedConfig } from "../types.js";
2
+ /**
3
+ * Rasterise an SVG string to a PNG buffer, scaled to `dimensions.width`.
4
+ *
5
+ * Text is drawn with the fonts named by `config`, which is what keeps the
6
+ * output the same on a laptop, in CI and in a container. Height follows the
7
+ * SVG's own aspect ratio; `buildSvg` sizes it to match.
8
+ */
9
+ export declare function renderSvgToPng(svg: string, dimensions: Dimensions, config?: ResolvedConfig): Promise<Buffer>;
10
+ //# sourceMappingURL=png.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"png.d.ts","sourceRoot":"","sources":["../../src/render/png.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAkB9D;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,UAAU,EACtB,MAAM,GAAE,cAAgC,GACvC,OAAO,CAAC,MAAM,CAAC,CAOjB"}
@@ -0,0 +1,30 @@
1
+ import { renderAsync } from "@resvg/resvg-js";
2
+ import { resolveConfig } from "../config/index.js";
3
+ import { fallbackFamily, fontFilePaths } from "../fonts/index.js";
4
+ /**
5
+ * Font options for the rasteriser: the configured font files, and whether to
6
+ * fall back to the machine's own.
7
+ */
8
+ async function fontOptions(config) {
9
+ const fallback = fallbackFamily(config.fonts);
10
+ return {
11
+ loadSystemFonts: config.systemFonts,
12
+ fontFiles: await fontFilePaths(config.fonts),
13
+ ...(fallback !== undefined && { defaultFontFamily: fallback }),
14
+ };
15
+ }
16
+ /**
17
+ * Rasterise an SVG string to a PNG buffer, scaled to `dimensions.width`.
18
+ *
19
+ * Text is drawn with the fonts named by `config`, which is what keeps the
20
+ * output the same on a laptop, in CI and in a container. Height follows the
21
+ * SVG's own aspect ratio; `buildSvg` sizes it to match.
22
+ */
23
+ export async function renderSvgToPng(svg, dimensions, config = resolveConfig()) {
24
+ const rendered = await renderAsync(svg, {
25
+ fitTo: { mode: "width", value: dimensions.width },
26
+ font: await fontOptions(config),
27
+ });
28
+ return rendered.asPng();
29
+ }
30
+ //# sourceMappingURL=png.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"png.js","sourceRoot":"","sources":["../../src/render/png.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlE;;;GAGG;AACH,KAAK,UAAU,WAAW,CACxB,MAAsB;IAEtB,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAE9C,OAAO;QACL,eAAe,EAAE,MAAM,CAAC,WAAW;QACnC,SAAS,EAAE,MAAM,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC;QAC5C,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,CAAC;KAC/D,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,GAAW,EACX,UAAsB,EACtB,MAAM,GAAmB,aAAa,EAAE;IAExC,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,GAAG,EAAE;QACtC,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE;QACjD,IAAI,EAAE,MAAM,WAAW,CAAC,MAAM,CAAC;KAChC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC,KAAK,EAAE,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { Dimensions, MetaImageProps, ResolvedConfig } from "../types.js";
2
+ /**
3
+ * Build the complete SVG document for one image: the enclosing `<svg>` root,
4
+ * the config-driven background, and the template's foreground content.
5
+ *
6
+ * Asynchronous because a template may need to load resources. The `code`
7
+ * template fetches syntax grammars and themes on demand, the fonts the text is
8
+ * measured against have to be read before a template can lay it out, and so do
9
+ * the logo, the avatar and any background photo.
10
+ */
11
+ export declare function buildSvg(props: MetaImageProps, config: ResolvedConfig, dimensions: Dimensions): Promise<string>;
12
+ //# sourceMappingURL=svg.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../../src/render/svg.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAK9E;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,cAAc,EACrB,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,MAAM,CAAC,CA4BjB"}
@@ -0,0 +1,35 @@
1
+ import { backgroundSvg } from "../background.js";
2
+ import { loadImages } from "../image/index.js";
3
+ import { createMeasurer } from "../measure/index.js";
4
+ import { selectTemplate } from "./template.js";
5
+ const backgroundId = "colophon-bg";
6
+ /**
7
+ * Build the complete SVG document for one image: the enclosing `<svg>` root,
8
+ * the config-driven background, and the template's foreground content.
9
+ *
10
+ * Asynchronous because a template may need to load resources. The `code`
11
+ * template fetches syntax grammars and themes on demand, the fonts the text is
12
+ * measured against have to be read before a template can lay it out, and so do
13
+ * the logo, the avatar and any background photo.
14
+ */
15
+ export async function buildSvg(props, config, dimensions) {
16
+ const template = selectTemplate(config, props.template);
17
+ const [measure, images] = await Promise.all([
18
+ createMeasurer(config),
19
+ loadImages(config, props),
20
+ ]);
21
+ const background = backgroundSvg(config.background, dimensions, backgroundId, images.background);
22
+ const body = await template.render({
23
+ props,
24
+ config,
25
+ dimensions,
26
+ measure,
27
+ logo: images.logo,
28
+ avatar: images.avatar,
29
+ });
30
+ const { width, height } = dimensions;
31
+ return (`<svg width="${String(width)}" height="${String(height)}"` +
32
+ ` viewBox="0 0 ${String(width)} ${String(height)}"` +
33
+ ` xmlns="http://www.w3.org/2000/svg">${background}${body}</svg>`);
34
+ }
35
+ //# sourceMappingURL=svg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg.js","sourceRoot":"","sources":["../../src/render/svg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,YAAY,GAAG,aAAa,CAAC;AAEnC;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,KAAqB,EACrB,MAAsB,EACtB,UAAsB;IAEtB,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IACxD,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC1C,cAAc,CAAC,MAAM,CAAC;QACtB,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC;KAC1B,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,aAAa,CAC9B,MAAM,CAAC,UAAU,EACjB,UAAU,EACV,YAAY,EACZ,MAAM,CAAC,UAAU,CAClB,CAAC;IACF,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;QACjC,KAAK;QACL,MAAM;QACN,UAAU;QACV,OAAO;QACP,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC,CAAC;IACH,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;IAErC,OAAO,CACL,eAAe,MAAM,CAAC,KAAK,CAAC,aAAa,MAAM,CAAC,MAAM,CAAC,GAAG;QAC1D,iBAAiB,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG;QACnD,uCAAuC,UAAU,GAAG,IAAI,QAAQ,CACjE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { ResolvedConfig, Template } from "../types.js";
2
+ /**
3
+ * Look up the template a set of props asks for, failing with the names that
4
+ * are actually available. A template name comes from frontmatter, so getting
5
+ * it wrong is routine, and "unknown template" alone leaves the author guessing
6
+ * at what the project registered.
7
+ */
8
+ export declare function selectTemplate(config: ResolvedConfig, name: string): Template;
9
+ //# sourceMappingURL=template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/render/template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5D;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,CAa7E"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Look up the template a set of props asks for, failing with the names that
3
+ * are actually available. A template name comes from frontmatter, so getting
4
+ * it wrong is routine, and "unknown template" alone leaves the author guessing
5
+ * at what the project registered.
6
+ */
7
+ export function selectTemplate(config, name) {
8
+ const template = config.templates[name];
9
+ if (template === undefined) {
10
+ const available = Object.keys(config.templates)
11
+ .toSorted((a, b) => a.localeCompare(b))
12
+ .join(", ");
13
+ throw new Error(`Unknown template "${name}". Available templates: ${available}.`);
14
+ }
15
+ return template;
16
+ }
17
+ //# sourceMappingURL=template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/render/template.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,MAAsB,EAAE,IAAY;IACjE,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAExC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;aAC5C,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;aACtC,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,MAAM,IAAI,KAAK,CACb,qBAAqB,IAAI,2BAA2B,SAAS,GAAG,CACjE,CAAC;IACJ,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}