@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.
- package/README.md +62 -265
- package/dist/background.d.ts +7 -2
- package/dist/background.d.ts.map +1 -1
- package/dist/background.js +44 -1
- package/dist/background.js.map +1 -1
- package/dist/cli/args.d.ts +14 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +67 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/config.d.ts +12 -0
- package/dist/cli/config.d.ts.map +1 -0
- package/dist/cli/config.js +43 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +35 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli.js +34 -6
- package/dist/cli.js.map +1 -1
- package/dist/config/defaults.d.ts +65 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +64 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/index.d.ts +22 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +54 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/resolve.d.ts +31 -0
- package/dist/config/resolve.d.ts.map +1 -0
- package/dist/config/resolve.js +82 -0
- package/dist/config/resolve.js.map +1 -0
- package/dist/config/size.d.ts +20 -0
- package/dist/config/size.d.ts.map +1 -0
- package/dist/config/size.js +47 -0
- package/dist/config/size.js.map +1 -0
- package/dist/config.d.ts +27 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +78 -2
- package/dist/config.js.map +1 -1
- package/dist/content/index.d.ts +5 -51
- package/dist/content/index.d.ts.map +1 -1
- package/dist/content/index.js +3 -115
- package/dist/content/index.js.map +1 -1
- package/dist/content/props.d.ts +15 -0
- package/dist/content/props.d.ts.map +1 -0
- package/dist/content/props.js +71 -0
- package/dist/content/props.js.map +1 -0
- package/dist/content/slug.d.ts +23 -0
- package/dist/content/slug.d.ts.map +1 -0
- package/dist/content/slug.js +52 -0
- package/dist/content/slug.js.map +1 -0
- package/dist/content/walk.d.ts +17 -0
- package/dist/content/walk.d.ts.map +1 -0
- package/dist/content/walk.js +57 -0
- package/dist/content/walk.js.map +1 -0
- package/dist/fonts/index.d.ts +11 -0
- package/dist/fonts/index.d.ts.map +1 -0
- package/dist/fonts/index.js +12 -0
- package/dist/fonts/index.js.map +1 -0
- package/dist/fonts/materialise.d.ts +7 -0
- package/dist/fonts/materialise.d.ts.map +1 -0
- package/dist/fonts/materialise.js +47 -0
- package/dist/fonts/materialise.js.map +1 -0
- package/dist/fonts/resolve.d.ts +7 -0
- package/dist/fonts/resolve.d.ts.map +1 -0
- package/dist/fonts/resolve.js +50 -0
- package/dist/fonts/resolve.js.map +1 -0
- package/dist/fonts.d.ts +18 -0
- package/dist/fonts.d.ts.map +1 -0
- package/dist/fonts.js +102 -0
- package/dist/fonts.js.map +1 -0
- package/dist/generate/extra.d.ts +16 -0
- package/dist/generate/extra.d.ts.map +1 -0
- package/dist/generate/extra.js +60 -0
- package/dist/generate/extra.js.map +1 -0
- package/dist/generate/index.d.ts +19 -0
- package/dist/generate/index.d.ts.map +1 -0
- package/dist/generate/index.js +46 -0
- package/dist/generate/index.js.map +1 -0
- package/dist/generate/job.d.ts +35 -0
- package/dist/generate/job.d.ts.map +1 -0
- package/dist/generate/job.js +2 -0
- package/dist/generate/job.js.map +1 -0
- package/dist/generate/options.d.ts +56 -0
- package/dist/generate/options.d.ts.map +1 -0
- package/dist/generate/options.js +17 -0
- package/dist/generate/options.js.map +1 -0
- package/dist/generate/output-path.d.ts +12 -0
- package/dist/generate/output-path.d.ts.map +1 -0
- package/dist/generate/output-path.js +18 -0
- package/dist/generate/output-path.js.map +1 -0
- package/dist/generate/outputs.d.ts +28 -0
- package/dist/generate/outputs.d.ts.map +1 -0
- package/dist/generate/outputs.js +71 -0
- package/dist/generate/outputs.js.map +1 -0
- package/dist/generate/plan.d.ts +21 -0
- package/dist/generate/plan.d.ts.map +1 -0
- package/dist/generate/plan.js +72 -0
- package/dist/generate/plan.js.map +1 -0
- package/dist/generate/render-image.d.ts +11 -0
- package/dist/generate/render-image.d.ts.map +1 -0
- package/dist/generate/render-image.js +27 -0
- package/dist/generate/render-image.js.map +1 -0
- package/dist/generate.d.ts +27 -6
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +69 -15
- package/dist/generate.js.map +1 -1
- package/dist/highlight/color.d.ts +9 -0
- package/dist/highlight/color.d.ts.map +1 -0
- package/dist/highlight/color.js +15 -0
- package/dist/highlight/color.js.map +1 -0
- package/dist/highlight/grid.d.ts +14 -0
- package/dist/highlight/grid.d.ts.map +1 -0
- package/dist/highlight/grid.js +36 -0
- package/dist/highlight/grid.js.map +1 -0
- package/dist/highlight/index.d.ts +12 -0
- package/dist/highlight/index.d.ts.map +1 -0
- package/dist/highlight/index.js +31 -0
- package/dist/highlight/index.js.map +1 -0
- package/dist/highlight/language.d.ts +13 -0
- package/dist/highlight/language.d.ts.map +1 -0
- package/dist/highlight/language.js +41 -0
- package/dist/highlight/language.js.map +1 -0
- package/dist/highlight/normalise.d.ts +17 -0
- package/dist/highlight/normalise.d.ts.map +1 -0
- package/dist/highlight/normalise.js +37 -0
- package/dist/highlight/normalise.js.map +1 -0
- package/dist/highlight/types.d.ts +40 -0
- package/dist/highlight/types.d.ts.map +1 -0
- package/dist/highlight/types.js +2 -0
- package/dist/highlight/types.js.map +1 -0
- package/dist/image/index.d.ts +18 -0
- package/dist/image/index.d.ts.map +1 -0
- package/dist/image/index.js +42 -0
- package/dist/image/index.js.map +1 -0
- package/dist/image/jpeg.d.ts +10 -0
- package/dist/image/jpeg.d.ts.map +1 -0
- package/dist/image/jpeg.js +57 -0
- package/dist/image/jpeg.js.map +1 -0
- package/dist/image/load.d.ts +4 -0
- package/dist/image/load.d.ts.map +1 -0
- package/dist/image/load.js +60 -0
- package/dist/image/load.js.map +1 -0
- package/dist/image/media.d.ts +10 -0
- package/dist/image/media.d.ts.map +1 -0
- package/dist/image/media.js +37 -0
- package/dist/image/media.js.map +1 -0
- package/dist/image/resolve.d.ts +13 -0
- package/dist/image/resolve.d.ts.map +1 -0
- package/dist/image/resolve.js +38 -0
- package/dist/image/resolve.js.map +1 -0
- package/dist/image/size.d.ts +22 -0
- package/dist/image/size.d.ts.map +1 -0
- package/dist/image/size.js +60 -0
- package/dist/image/size.js.map +1 -0
- package/dist/image/svg.d.ts +12 -0
- package/dist/image/svg.d.ts.map +1 -0
- package/dist/image/svg.js +61 -0
- package/dist/image/svg.js.map +1 -0
- package/dist/image/uri.d.ts +9 -0
- package/dist/image/uri.d.ts.map +1 -0
- package/dist/image/uri.js +22 -0
- package/dist/image/uri.js.map +1 -0
- package/dist/index.d.ts +19 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -5
- package/dist/index.js.map +1 -1
- package/dist/layout/block.d.ts +37 -0
- package/dist/layout/block.d.ts.map +1 -0
- package/dist/layout/block.js +26 -0
- package/dist/layout/block.js.map +1 -0
- package/dist/layout/box.d.ts +20 -0
- package/dist/layout/box.d.ts.map +1 -0
- package/dist/layout/box.js +61 -0
- package/dist/layout/box.js.map +1 -0
- package/dist/layout/distribute.d.ts +15 -0
- package/dist/layout/distribute.d.ts.map +1 -0
- package/dist/layout/distribute.js +30 -0
- package/dist/layout/distribute.js.map +1 -0
- package/dist/layout/image.d.ts +42 -0
- package/dist/layout/image.d.ts.map +1 -0
- package/dist/layout/image.js +34 -0
- package/dist/layout/image.js.map +1 -0
- package/dist/layout/index.d.ts +40 -0
- package/dist/layout/index.d.ts.map +1 -0
- package/dist/layout/index.js +30 -0
- package/dist/layout/index.js.map +1 -0
- package/dist/layout/lines.d.ts +45 -0
- package/dist/layout/lines.d.ts.map +1 -0
- package/dist/layout/lines.js +71 -0
- package/dist/layout/lines.js.map +1 -0
- package/dist/layout/measure.d.ts +11 -0
- package/dist/layout/measure.d.ts.map +1 -0
- package/dist/layout/measure.js +11 -0
- package/dist/layout/measure.js.map +1 -0
- package/dist/layout/panel.d.ts +20 -0
- package/dist/layout/panel.d.ts.map +1 -0
- package/dist/layout/panel.js +22 -0
- package/dist/layout/panel.js.map +1 -0
- package/dist/layout/row.d.ts +15 -0
- package/dist/layout/row.d.ts.map +1 -0
- package/dist/layout/row.js +20 -0
- package/dist/layout/row.js.map +1 -0
- package/dist/layout/scrim.d.ts +23 -0
- package/dist/layout/scrim.d.ts.map +1 -0
- package/dist/layout/scrim.js +38 -0
- package/dist/layout/scrim.js.map +1 -0
- package/dist/layout/stack.d.ts +14 -0
- package/dist/layout/stack.d.ts.map +1 -0
- package/dist/layout/stack.js +19 -0
- package/dist/layout/stack.js.map +1 -0
- package/dist/layout/types.d.ts +49 -0
- package/dist/layout/types.d.ts.map +1 -0
- package/dist/layout/types.js +2 -0
- package/dist/layout/types.js.map +1 -0
- package/dist/manifest/build.d.ts +14 -0
- package/dist/manifest/build.d.ts.map +1 -0
- package/dist/manifest/build.js +43 -0
- package/dist/manifest/build.js.map +1 -0
- package/dist/manifest/index.d.ts +27 -0
- package/dist/manifest/index.d.ts.map +1 -0
- package/dist/manifest/index.js +31 -0
- package/dist/manifest/index.js.map +1 -0
- package/dist/manifest/order.d.ts +12 -0
- package/dist/manifest/order.d.ts.map +1 -0
- package/dist/manifest/order.js +17 -0
- package/dist/manifest/order.js.map +1 -0
- package/dist/manifest/page.d.ts +24 -0
- package/dist/manifest/page.d.ts.map +1 -0
- package/dist/manifest/page.js +55 -0
- package/dist/manifest/page.js.map +1 -0
- package/dist/measure/estimate.d.ts +10 -0
- package/dist/measure/estimate.d.ts.map +1 -0
- package/dist/measure/estimate.js +58 -0
- package/dist/measure/estimate.js.map +1 -0
- package/dist/measure/faces.d.ts +15 -0
- package/dist/measure/faces.d.ts.map +1 -0
- package/dist/measure/faces.js +70 -0
- package/dist/measure/faces.js.map +1 -0
- package/dist/measure/index.d.ts +16 -0
- package/dist/measure/index.d.ts.map +1 -0
- package/dist/measure/index.js +0 -0
- package/dist/measure/index.js.map +1 -0
- package/dist/measure/runs.d.ts +17 -0
- package/dist/measure/runs.d.ts.map +1 -0
- package/dist/measure/runs.js +39 -0
- package/dist/measure/runs.js.map +1 -0
- package/dist/measure/select.d.ts +13 -0
- package/dist/measure/select.d.ts.map +1 -0
- package/dist/measure/select.js +47 -0
- package/dist/measure/select.js.map +1 -0
- package/dist/meta/html.d.ts +14 -0
- package/dist/meta/html.d.ts.map +1 -0
- package/dist/meta/html.js +24 -0
- package/dist/meta/html.js.map +1 -0
- package/dist/meta/index.d.ts +11 -0
- package/dist/meta/index.d.ts.map +1 -0
- package/dist/meta/index.js +11 -0
- package/dist/meta/index.js.map +1 -0
- package/dist/meta/tags.d.ts +21 -0
- package/dist/meta/tags.d.ts.map +1 -0
- package/dist/meta/tags.js +72 -0
- package/dist/meta/tags.js.map +1 -0
- package/dist/meta/url.d.ts +15 -0
- package/dist/meta/url.d.ts.map +1 -0
- package/dist/meta/url.js +34 -0
- package/dist/meta/url.js.map +1 -0
- package/dist/placement/check.d.ts +16 -0
- package/dist/placement/check.d.ts.map +1 -0
- package/dist/placement/check.js +40 -0
- package/dist/placement/check.js.map +1 -0
- package/dist/placement/index.d.ts +29 -0
- package/dist/placement/index.d.ts.map +1 -0
- package/dist/placement/index.js +61 -0
- package/dist/placement/index.js.map +1 -0
- package/dist/placement/relative.d.ts +31 -0
- package/dist/placement/relative.d.ts.map +1 -0
- package/dist/placement/relative.js +53 -0
- package/dist/placement/relative.js.map +1 -0
- package/dist/pool.d.ts +18 -0
- package/dist/pool.d.ts.map +1 -0
- package/dist/pool.js +56 -0
- package/dist/pool.js.map +1 -0
- package/dist/props.d.ts +7 -0
- package/dist/props.d.ts.map +1 -0
- package/dist/props.js +17 -0
- package/dist/props.js.map +1 -0
- package/dist/render/index.d.ts +10 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +27 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/png.d.ts +10 -0
- package/dist/render/png.d.ts.map +1 -0
- package/dist/render/png.js +30 -0
- package/dist/render/png.js.map +1 -0
- package/dist/render/svg.d.ts +12 -0
- package/dist/render/svg.d.ts.map +1 -0
- package/dist/render/svg.js +35 -0
- package/dist/render/svg.js.map +1 -0
- package/dist/render/template.d.ts +9 -0
- package/dist/render/template.d.ts.map +1 -0
- package/dist/render/template.js +17 -0
- package/dist/render/template.js.map +1 -0
- package/dist/render.d.ts +6 -2
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +31 -10
- package/dist/render.js.map +1 -1
- package/dist/stamp/chunk.d.ts +16 -0
- package/dist/stamp/chunk.d.ts.map +1 -0
- package/dist/stamp/chunk.js +46 -0
- package/dist/stamp/chunk.js.map +1 -0
- package/dist/stamp/config-digest.d.ts +11 -0
- package/dist/stamp/config-digest.d.ts.map +1 -0
- package/dist/stamp/config-digest.js +62 -0
- package/dist/stamp/config-digest.js.map +1 -0
- package/dist/stamp/digest.d.ts +8 -0
- package/dist/stamp/digest.d.ts.map +1 -0
- package/dist/stamp/digest.js +20 -0
- package/dist/stamp/digest.js.map +1 -0
- package/dist/stamp/index.d.ts +20 -0
- package/dist/stamp/index.d.ts.map +1 -0
- package/dist/stamp/index.js +40 -0
- package/dist/stamp/index.js.map +1 -0
- package/dist/stamp/read.d.ts +7 -0
- package/dist/stamp/read.d.ts.map +1 -0
- package/dist/stamp/read.js +62 -0
- package/dist/stamp/read.js.map +1 -0
- package/dist/stamp.d.ts +29 -0
- package/dist/stamp.d.ts.map +1 -0
- package/dist/stamp.js +198 -0
- package/dist/stamp.js.map +1 -0
- package/dist/templates/attribution.d.ts +17 -0
- package/dist/templates/attribution.d.ts.map +1 -0
- package/dist/templates/attribution.js +39 -0
- package/dist/templates/attribution.js.map +1 -0
- package/dist/templates/banner/badge.d.ts +7 -0
- package/dist/templates/banner/badge.d.ts.map +1 -0
- package/dist/templates/banner/badge.js +21 -0
- package/dist/templates/banner/badge.js.map +1 -0
- package/dist/templates/banner/index.d.ts +12 -0
- package/dist/templates/banner/index.d.ts.map +1 -0
- package/dist/templates/banner/index.js +68 -0
- package/dist/templates/banner/index.js.map +1 -0
- package/dist/templates/banner/lines.d.ts +22 -0
- package/dist/templates/banner/lines.d.ts.map +1 -0
- package/dist/templates/banner/lines.js +35 -0
- package/dist/templates/banner/lines.js.map +1 -0
- package/dist/templates/banner/version.d.ts +9 -0
- package/dist/templates/banner/version.d.ts.map +1 -0
- package/dist/templates/banner/version.js +21 -0
- package/dist/templates/banner/version.js.map +1 -0
- package/dist/templates/card/index.d.ts +10 -0
- package/dist/templates/card/index.d.ts.map +1 -0
- package/dist/templates/card/index.js +55 -0
- package/dist/templates/card/index.js.map +1 -0
- package/dist/templates/card/lines.d.ts +21 -0
- package/dist/templates/card/lines.d.ts.map +1 -0
- package/dist/templates/card/lines.js +36 -0
- package/dist/templates/card/lines.js.map +1 -0
- package/dist/templates/code/chrome.d.ts +13 -0
- package/dist/templates/code/chrome.d.ts.map +1 -0
- package/dist/templates/code/chrome.js +33 -0
- package/dist/templates/code/chrome.js.map +1 -0
- package/dist/templates/code/clip.d.ts +18 -0
- package/dist/templates/code/clip.d.ts.map +1 -0
- package/dist/templates/code/clip.js +44 -0
- package/dist/templates/code/clip.js.map +1 -0
- package/dist/templates/code/ellipsis.d.ts +3 -0
- package/dist/templates/code/ellipsis.d.ts.map +1 -0
- package/dist/templates/code/ellipsis.js +3 -0
- package/dist/templates/code/ellipsis.js.map +1 -0
- package/dist/templates/code/fit.d.ts +27 -0
- package/dist/templates/code/fit.d.ts.map +1 -0
- package/dist/templates/code/fit.js +59 -0
- package/dist/templates/code/fit.js.map +1 -0
- package/dist/templates/code/index.d.ts +12 -0
- package/dist/templates/code/index.d.ts.map +1 -0
- package/dist/templates/code/index.js +65 -0
- package/dist/templates/code/index.js.map +1 -0
- package/dist/templates/code/layout.d.ts +21 -0
- package/dist/templates/code/layout.d.ts.map +1 -0
- package/dist/templates/code/layout.js +21 -0
- package/dist/templates/code/layout.js.map +1 -0
- package/dist/templates/code/panel.d.ts +30 -0
- package/dist/templates/code/panel.d.ts.map +1 -0
- package/dist/templates/code/panel.js +52 -0
- package/dist/templates/code/panel.js.map +1 -0
- package/dist/templates/code/plate.d.ts +17 -0
- package/dist/templates/code/plate.d.ts.map +1 -0
- package/dist/templates/code/plate.js +34 -0
- package/dist/templates/code/plate.js.map +1 -0
- package/dist/templates/code/spans.d.ts +19 -0
- package/dist/templates/code/spans.d.ts.map +1 -0
- package/dist/templates/code/spans.js +36 -0
- package/dist/templates/code/spans.js.map +1 -0
- package/dist/templates/code/warn.d.ts +11 -0
- package/dist/templates/code/warn.d.ts.map +1 -0
- package/dist/templates/code/warn.js +24 -0
- package/dist/templates/code/warn.js.map +1 -0
- package/dist/templates/code/width.d.ts +10 -0
- package/dist/templates/code/width.d.ts.map +1 -0
- package/dist/templates/code/width.js +26 -0
- package/dist/templates/code/width.js.map +1 -0
- package/dist/templates/footer.d.ts +29 -0
- package/dist/templates/footer.d.ts.map +1 -0
- package/dist/templates/footer.js +35 -0
- package/dist/templates/footer.js.map +1 -0
- package/dist/templates/index.d.ts +4 -4
- package/dist/templates/index.d.ts.map +1 -1
- package/dist/templates/index.js +7 -7
- package/dist/templates/index.js.map +1 -1
- package/dist/templates/logo.d.ts +15 -0
- package/dist/templates/logo.d.ts.map +1 -0
- package/dist/templates/logo.js +30 -0
- package/dist/templates/logo.js.map +1 -0
- package/dist/templates/measure.d.ts +11 -0
- package/dist/templates/measure.d.ts.map +1 -0
- package/dist/templates/measure.js +11 -0
- package/dist/templates/measure.js.map +1 -0
- package/dist/templates/props.d.ts +2 -2
- package/dist/templates/props.js +2 -2
- package/dist/templates/text.d.ts +37 -0
- package/dist/templates/text.d.ts.map +1 -0
- package/dist/templates/text.js +26 -0
- package/dist/templates/text.js.map +1 -0
- package/dist/text/break.d.ts +11 -0
- package/dist/text/break.d.ts.map +1 -0
- package/dist/text/break.js +30 -0
- package/dist/text/break.js.map +1 -0
- package/dist/text/element.d.ts +18 -0
- package/dist/text/element.d.ts.map +1 -0
- package/dist/text/element.js +19 -0
- package/dist/text/element.js.map +1 -0
- package/dist/text/escape.d.ts +5 -0
- package/dist/text/escape.d.ts.map +1 -0
- package/dist/text/escape.js +12 -0
- package/dist/text/escape.js.map +1 -0
- package/dist/text/fit.d.ts +30 -0
- package/dist/text/fit.d.ts.map +1 -0
- package/dist/text/fit.js +29 -0
- package/dist/text/fit.js.map +1 -0
- package/dist/text/index.d.ts +9 -0
- package/dist/text/index.d.ts.map +1 -0
- package/dist/text/index.js +6 -0
- package/dist/text/index.js.map +1 -0
- package/dist/text/stack.d.ts +24 -0
- package/dist/text/stack.d.ts.map +1 -0
- package/dist/text/stack.js +18 -0
- package/dist/text/stack.js.map +1 -0
- package/dist/text/wrap.d.ts +22 -0
- package/dist/text/wrap.d.ts.map +1 -0
- package/dist/text/wrap.js +41 -0
- package/dist/text/wrap.js.map +1 -0
- package/dist/types.d.ts +458 -18
- package/dist/types.d.ts.map +1 -1
- package/dist/validate/check.d.ts +13 -0
- package/dist/validate/check.d.ts.map +1 -0
- package/dist/validate/check.js +34 -0
- package/dist/validate/check.js.map +1 -0
- package/dist/validate/index.d.ts +15 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/dist/validate/index.js +42 -0
- package/dist/validate/index.js.map +1 -0
- package/dist/validate/keys.d.ts +75 -0
- package/dist/validate/keys.d.ts.map +1 -0
- package/dist/validate/keys.js +203 -0
- package/dist/validate/keys.js.map +1 -0
- package/dist/validate/overrides.d.ts +5 -0
- package/dist/validate/overrides.d.ts.map +1 -0
- package/dist/validate/overrides.js +43 -0
- package/dist/validate/overrides.js.map +1 -0
- package/dist/validate/placement.d.ts +10 -0
- package/dist/validate/placement.d.ts.map +1 -0
- package/dist/validate/placement.js +38 -0
- package/dist/validate/placement.js.map +1 -0
- package/dist/validate/sizes.d.ts +9 -0
- package/dist/validate/sizes.d.ts.map +1 -0
- package/dist/validate/sizes.js +27 -0
- package/dist/validate/sizes.js.map +1 -0
- package/dist/validate/suggest.d.ts +10 -0
- package/dist/validate/suggest.d.ts.map +1 -0
- package/dist/validate/suggest.js +73 -0
- package/dist/validate/suggest.js.map +1 -0
- package/dist/validate/values.d.ts +21 -0
- package/dist/validate/values.d.ts.map +1 -0
- package/dist/validate/values.js +71 -0
- package/dist/validate/values.js.map +1 -0
- package/dist/validate.d.ts +15 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +300 -0
- package/dist/validate.js.map +1 -0
- package/package.json +19 -6
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The attributes of the root `<svg>` element that say how big it is. Written
|
|
3
|
+
* out rather than built from a name, since there are three of them and a
|
|
4
|
+
* pattern assembled from a string is harder to read than the three patterns.
|
|
5
|
+
*/
|
|
6
|
+
const attributes = {
|
|
7
|
+
width: /\swidth\s*=\s*"([^"]*)"/i,
|
|
8
|
+
height: /\sheight\s*=\s*"([^"]*)"/i,
|
|
9
|
+
viewBox: /\sviewBox\s*=\s*"([^"]*)"/i,
|
|
10
|
+
};
|
|
11
|
+
/** The value of one of them, where the root element carries it. */
|
|
12
|
+
function attribute(head, name) {
|
|
13
|
+
return attributes[name].exec(head)?.[1];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A length such as `120`, `120px` or `7.5em`, as far as its number goes.
|
|
17
|
+
*
|
|
18
|
+
* A percentage is not one of them. `width="100%"` is the commonest way an
|
|
19
|
+
* export states that it scales to its container, and reading it as 100 units
|
|
20
|
+
* would make every such file square whatever its `viewBox` says.
|
|
21
|
+
*/
|
|
22
|
+
function length(value) {
|
|
23
|
+
if (value?.trim().endsWith("%") === true) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
// Deliberately parseFloat rather than Number: a length may carry a unit,
|
|
27
|
+
// and `6em` is six of something rather than not a number.
|
|
28
|
+
// eslint-disable-next-line unicorn/prefer-number-coercion
|
|
29
|
+
const number = Number.parseFloat(value ?? "");
|
|
30
|
+
return Number.isFinite(number) && number > 0 ? number : undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The proportions of an SVG, which are what a template needs: an SVG has no
|
|
34
|
+
* pixels of its own, so only the ratio between its width and height means
|
|
35
|
+
* anything here.
|
|
36
|
+
*
|
|
37
|
+
* `width` and `height` are read first and `viewBox` second, which is the order
|
|
38
|
+
* a renderer resolves them in. A document with neither is left unmeasured
|
|
39
|
+
* rather than assumed to be square, since a wordmark usually has neither.
|
|
40
|
+
*/
|
|
41
|
+
export function svgExtent(bytes) {
|
|
42
|
+
const head = new TextDecoder().decode(bytes.slice(0, 4096));
|
|
43
|
+
const root = /<svg[\s>][^>]*/i.exec(head)?.[0] ?? "";
|
|
44
|
+
const width = length(attribute(root, "width"));
|
|
45
|
+
const height = length(attribute(root, "height"));
|
|
46
|
+
if (width !== undefined && height !== undefined) {
|
|
47
|
+
return { width, height };
|
|
48
|
+
}
|
|
49
|
+
const box = attribute(root, "viewBox")
|
|
50
|
+
?.trim()
|
|
51
|
+
.split(/[\s,]+/);
|
|
52
|
+
if (box?.length !== 4) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
const boxWidth = length(box[2]);
|
|
56
|
+
const boxHeight = length(box[3]);
|
|
57
|
+
return boxWidth === undefined || boxHeight === undefined
|
|
58
|
+
? undefined
|
|
59
|
+
: { width: boxWidth, height: boxHeight };
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=svg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg.js","sourceRoot":"","sources":["../../src/image/svg.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,GAAG;IACjB,KAAK,EAAE,0BAA0B;IACjC,MAAM,EAAE,2BAA2B;IACnC,OAAO,EAAE,4BAA4B;CAC7B,CAAC;AAEX,mEAAmE;AACnE,SAAS,SAAS,CAChB,IAAY,EACZ,IAA6B;IAE7B,OAAO,UAAU,CAAC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IAAI,GAAG,EAAE,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAEjC,OAAO,QAAQ,KAAK,SAAS,IAAI,SAAS,KAAK,SAAS;QACtD,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bytes behind a `data:` URI, so that an image already inline is measured
|
|
3
|
+
* and checked on the same terms as one read from disk.
|
|
4
|
+
*
|
|
5
|
+
* A prop can carry either, since frontmatter written by hand names a file and
|
|
6
|
+
* frontmatter written by a props mapper may have the image already.
|
|
7
|
+
*/
|
|
8
|
+
export declare function bytesFromDataUri(uri: string, label: string): Uint8Array;
|
|
9
|
+
//# sourceMappingURL=uri.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uri.d.ts","sourceRoot":"","sources":["../../src/image/uri.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAgBvE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bytes behind a `data:` URI, so that an image already inline is measured
|
|
3
|
+
* and checked on the same terms as one read from disk.
|
|
4
|
+
*
|
|
5
|
+
* A prop can carry either, since frontmatter written by hand names a file and
|
|
6
|
+
* frontmatter written by a props mapper may have the image already.
|
|
7
|
+
*/
|
|
8
|
+
export function bytesFromDataUri(uri, label) {
|
|
9
|
+
const comma = uri.indexOf(",");
|
|
10
|
+
const head = comma === -1 ? "" : uri.slice(0, comma);
|
|
11
|
+
const body = comma === -1 ? "" : uri.slice(comma + 1);
|
|
12
|
+
if (comma === -1) {
|
|
13
|
+
throw new Error(`${label} is a "data:" URI with no comma in it.`);
|
|
14
|
+
}
|
|
15
|
+
if (head.endsWith(";base64")) {
|
|
16
|
+
// `Uint8Array.fromBase64` is not on the oldest Node this package supports.
|
|
17
|
+
// eslint-disable-next-line unicorn/prefer-uint8array-base64
|
|
18
|
+
return Buffer.from(body, "base64");
|
|
19
|
+
}
|
|
20
|
+
return new TextEncoder().encode(decodeURIComponent(body));
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=uri.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uri.js","sourceRoot":"","sources":["../../src/image/uri.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAW,EAAE,KAAa;IACzD,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,IAAI,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACrD,MAAM,IAAI,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAEtD,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,wCAAwC,CAAC,CAAC;IACpE,CAAC;IAED,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7B,2EAA2E;QAC3E,4DAA4D;QAC5D,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;AAC5D,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
export type { Background, Badge, BrandColors, CodeStyle, ColophonConfig, Dimensions, GradientStop, MetaImageProps, OutputSize, RenderedMetaImage, ResolvedConfig, Template, TemplateContext, WarningHandler, } from "./types.js";
|
|
2
|
-
export { DEFAULT_CODE_FONT_FAMILY, DEFAULT_CODE_STYLE, DEFAULT_COLORS, DEFAULT_FONT_FAMILY, DEFAULT_SIZES, defineConfig, resolveConfig, SIZE_PRESETS, } from "./config.js";
|
|
1
|
+
export type { Background, Badge, BrandColors, CodeStyle, ColophonConfig, ColophonConfigFactory, ColophonConfigInput, ContentFile, ContentOptions, Dimensions, ExtraImage, FontSource, GradientStop, Manifest, ManifestImage, ManifestPage, MetaImageProps, MeasureText, MetaTag, MetaTagOptions, OutputSize, Placement, PropsFromFrontmatter, RenderedMetaImage, SlugStrategy, SizeOverrides, ResolvedConfig, Template, TemplateContext, TextStyle, WarningHandler, } from "./types.js";
|
|
2
|
+
export { DEFAULT_CODE_FONT_FAMILY, DEFAULT_CODE_STYLE, DEFAULT_COLORS, DEFAULT_FONT_FAMILY, DEFAULT_SIZES, defineConfig, resolveConfig, SIZE_PRESETS, } from "./config/index.js";
|
|
3
|
+
export { resolveConfigForSize } from "./config/size.js";
|
|
3
4
|
export { backgroundSvg } from "./background.js";
|
|
4
|
-
export { buildSvg, renderMetaImages, renderSvgToPng } from "./render.js";
|
|
5
|
+
export { buildSvg, renderMetaImages, renderSvgToPng } from "./render/index.js";
|
|
5
6
|
export { bannerTemplate, builtinTemplates, cardTemplate, codeTemplate, } from "./templates/index.js";
|
|
6
|
-
export { dedent, expandTabs, highlightCode, resolveLanguage, } from "./highlight.js";
|
|
7
|
-
export type { CodeToken, HighlightedCode, HighlightOptions, } from "./highlight.js";
|
|
8
|
-
export { defaultOutputPath, generate } from "./generate.js";
|
|
9
|
-
export type { GeneratedImage, GenerateOptions } from "./generate.js";
|
|
10
|
-
export {
|
|
7
|
+
export { dedent, expandTabs, highlightCode, resolveLanguage, } from "./highlight/index.js";
|
|
8
|
+
export type { CodeToken, HighlightedCode, HighlightOptions, } from "./highlight/index.js";
|
|
9
|
+
export { defaultOutputPath, generate } from "./generate/index.js";
|
|
10
|
+
export type { GeneratedImage, GenerateOptions } from "./generate/index.js";
|
|
11
|
+
export { createStamper, readPngStamp, stampPng } from "./stamp/index.js";
|
|
12
|
+
export type { Stamper } from "./stamp/index.js";
|
|
13
|
+
export { createMeasurer } from "./measure/index.js";
|
|
14
|
+
export { escapeXml, fitText, textElement, wrapText } from "./text/index.js";
|
|
15
|
+
export type { FitOptions, FittedText, MeasureAt, MeasureLine, TextAttributes, } from "./text/index.js";
|
|
16
|
+
export { blockLines, box, distribute, drawLines, image, inset, measureIn, optionalString, panel, placeLines, row, scrim, stack, } from "./layout/index.js";
|
|
17
|
+
export type { Align, BoxStyle, Extent, ImageOptions, LinesStyle, Placed, PlacedLine, PanelStyle, Rect, RowRect, ScrimOptions, Span, StackedRect, StyledBlock, TextBlock, TextLine, } from "./layout/index.js";
|
|
11
18
|
export { extractProps, slugFromPath, walkContent } from "./content/index.js";
|
|
12
|
-
export type {
|
|
19
|
+
export type { WalkOptions } from "./content/index.js";
|
|
20
|
+
export { metaTags, metaTagsHtml } from "./meta/index.js";
|
|
21
|
+
export { createPlacer } from "./placement/index.js";
|
|
22
|
+
export type { PlacedImage, Placer } from "./placement/index.js";
|
|
13
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,KAAK,EACL,WAAW,EACX,SAAS,EACT,cAAc,EACd,UAAU,EACV,YAAY,EACZ,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,eAAe,EACf,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,KAAK,EACL,WAAW,EACX,SAAS,EACT,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,UAAU,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,cAAc,EACd,WAAW,EACX,OAAO,EACP,cAAc,EACd,UAAU,EACV,SAAS,EACT,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,QAAQ,EACR,eAAe,EACf,SAAS,EACT,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,YAAY,GACb,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,MAAM,EACN,UAAU,EACV,aAAa,EACb,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,SAAS,EACT,eAAe,EACf,gBAAgB,GACjB,MA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ANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
export { DEFAULT_CODE_FONT_FAMILY, DEFAULT_CODE_STYLE, DEFAULT_COLORS, DEFAULT_FONT_FAMILY, DEFAULT_SIZES, defineConfig, resolveConfig, SIZE_PRESETS, } from "./config.js";
|
|
1
|
+
export { DEFAULT_CODE_FONT_FAMILY, DEFAULT_CODE_STYLE, DEFAULT_COLORS, DEFAULT_FONT_FAMILY, DEFAULT_SIZES, defineConfig, resolveConfig, SIZE_PRESETS, } from "./config/index.js";
|
|
2
|
+
export { resolveConfigForSize } from "./config/size.js";
|
|
2
3
|
export { backgroundSvg } from "./background.js";
|
|
3
|
-
export { buildSvg, renderMetaImages, renderSvgToPng } from "./render.js";
|
|
4
|
+
export { buildSvg, renderMetaImages, renderSvgToPng } from "./render/index.js";
|
|
4
5
|
export { bannerTemplate, builtinTemplates, cardTemplate, codeTemplate, } from "./templates/index.js";
|
|
5
|
-
export { dedent, expandTabs, highlightCode, resolveLanguage, } from "./highlight.js";
|
|
6
|
-
export { defaultOutputPath, generate } from "./generate.js";
|
|
7
|
-
export {
|
|
6
|
+
export { dedent, expandTabs, highlightCode, resolveLanguage, } from "./highlight/index.js";
|
|
7
|
+
export { defaultOutputPath, generate } from "./generate/index.js";
|
|
8
|
+
export { createStamper, readPngStamp, stampPng } from "./stamp/index.js";
|
|
9
|
+
export { createMeasurer } from "./measure/index.js";
|
|
10
|
+
export { escapeXml, fitText, textElement, wrapText } from "./text/index.js";
|
|
11
|
+
// The layout toolkit, which also has its own `@kensio/colophon/layout` subpath
|
|
12
|
+
// for a template that would rather not pull the rasteriser in with it.
|
|
13
|
+
export { blockLines, box, distribute, drawLines, image, inset, measureIn, optionalString, panel, placeLines, row, scrim, stack, } from "./layout/index.js";
|
|
8
14
|
export { extractProps, slugFromPath, walkContent } from "./content/index.js";
|
|
15
|
+
export { metaTags, metaTagsHtml } from "./meta/index.js";
|
|
16
|
+
export { createPlacer } from "./placement/index.js";
|
|
9
17
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAkCA,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,YAAY,GACb,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,MAAM,EACN,UAAU,EACV,aAAa,EACb,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAO9B,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGlE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGzE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAS5E,+EAA+E;AAC/E,uEAAuE;AACvE,OAAO,EACL,UAAU,EACV,GAAG,EACH,UAAU,EACV,SAAS,EACT,KAAK,EACL,KAAK,EACL,SAAS,EACT,cAAc,EACd,KAAK,EACL,UAAU,EACV,GAAG,EACH,KAAK,EACL,KAAK,GACN,MAAM,mBAAmB,CAAC;AAoB3B,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAG7E,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { MeasureText } from "../types.js";
|
|
2
|
+
/** One group of a template's text: the space it has and how it is drawn. */
|
|
3
|
+
export interface TextBlock {
|
|
4
|
+
readonly maxWidth: number;
|
|
5
|
+
readonly maxLines: number;
|
|
6
|
+
readonly fontSize: number;
|
|
7
|
+
/**
|
|
8
|
+
* Fraction of `fontSize` this group may shrink to before it is cut instead.
|
|
9
|
+
* The title of a layout has the furthest to fall, because it is the line
|
|
10
|
+
* worth keeping whole; a subtitle that has shrunk much has stopped being
|
|
11
|
+
* readable in a feed, so it may as well lose its tail.
|
|
12
|
+
*/
|
|
13
|
+
readonly floor: number;
|
|
14
|
+
readonly fontWeight: number;
|
|
15
|
+
}
|
|
16
|
+
/** A block along with how the lines it produces are drawn. */
|
|
17
|
+
export interface StyledBlock extends TextBlock {
|
|
18
|
+
readonly opacity: number;
|
|
19
|
+
/** Space inserted before the group's first line, to separate it from the last. */
|
|
20
|
+
readonly gapBefore?: number;
|
|
21
|
+
}
|
|
22
|
+
/** One line of a template's text block, ready to be stacked and drawn. */
|
|
23
|
+
export interface TextLine {
|
|
24
|
+
readonly text: string;
|
|
25
|
+
readonly fontSize: number;
|
|
26
|
+
readonly fontWeight: number;
|
|
27
|
+
readonly opacity: number;
|
|
28
|
+
readonly gapBefore?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Fit one group of a template's text, from a prop that may not be there, and
|
|
32
|
+
* return its lines. Each group is fitted on its own, so a long title shrinking
|
|
33
|
+
* does not drag the subtitle down with it. A group whose prop is absent or
|
|
34
|
+
* empty produces no lines at all.
|
|
35
|
+
*/
|
|
36
|
+
export declare function blockLines(value: unknown, measure: MeasureText, fontFamily: string, block: StyledBlock): TextLine[];
|
|
37
|
+
//# sourceMappingURL=block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../src/layout/block.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,4EAA4E;AAC5E,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,8DAA8D;AAC9D,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,kFAAkF;IAClF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,0EAA0E;AAC1E,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,WAAW,GACjB,QAAQ,EAAE,CAoBZ"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { fitText } from "../text/index.js";
|
|
2
|
+
import { optionalString } from "../props.js";
|
|
3
|
+
import { measureIn } from "./measure.js";
|
|
4
|
+
/**
|
|
5
|
+
* Fit one group of a template's text, from a prop that may not be there, and
|
|
6
|
+
* return its lines. Each group is fitted on its own, so a long title shrinking
|
|
7
|
+
* does not drag the subtitle down with it. A group whose prop is absent or
|
|
8
|
+
* empty produces no lines at all.
|
|
9
|
+
*/
|
|
10
|
+
export function blockLines(value, measure, fontFamily, block) {
|
|
11
|
+
const fitted = fitText(optionalString(value) ?? "", measureIn(measure, fontFamily, block.fontWeight), {
|
|
12
|
+
maxWidth: block.maxWidth,
|
|
13
|
+
maxLines: block.maxLines,
|
|
14
|
+
fontSize: block.fontSize,
|
|
15
|
+
minFontSize: Math.round(block.fontSize * block.floor),
|
|
16
|
+
});
|
|
17
|
+
return fitted.lines.map((text, index) => ({
|
|
18
|
+
text,
|
|
19
|
+
fontSize: fitted.fontSize,
|
|
20
|
+
fontWeight: block.fontWeight,
|
|
21
|
+
opacity: block.opacity,
|
|
22
|
+
...(index === 0 &&
|
|
23
|
+
block.gapBefore !== undefined && { gapBefore: block.gapBefore }),
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block.js","sourceRoot":"","sources":["../../src/layout/block.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAiCzC;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACxB,KAAc,EACd,OAAoB,EACpB,UAAkB,EAClB,KAAkB;IAElB,MAAM,MAAM,GAAe,OAAO,CAChC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,EAC3B,SAAS,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,EAChD;QACE,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC;KACtD,CACF,CAAC;IAEF,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACxC,IAAI;QACJ,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,GAAG,CAAC,KAAK,KAAK,CAAC;YACb,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;KACnE,CAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { BoxStyle, Rect } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* A rectangle: the plate a badge sits on, the surface of a panel, a rule along
|
|
4
|
+
* an edge. Everything in a template that is not text or an image is one of
|
|
5
|
+
* these.
|
|
6
|
+
*
|
|
7
|
+
* Attributes a style does not name are left out rather than written as their
|
|
8
|
+
* defaults, so the output says only what the template decided.
|
|
9
|
+
*/
|
|
10
|
+
export declare function box(rect: Rect, style?: BoxStyle): string;
|
|
11
|
+
/**
|
|
12
|
+
* Shrink a rectangle inwards, which is how a template gets its margins. One
|
|
13
|
+
* number insets every edge; a partial one insets the edges it names.
|
|
14
|
+
*
|
|
15
|
+
* An inset larger than the rectangle collapses it to nothing rather than
|
|
16
|
+
* turning it inside out, since a negative width draws nothing anyway and an
|
|
17
|
+
* empty rectangle is easier to reason about than one with its corners crossed.
|
|
18
|
+
*/
|
|
19
|
+
export declare function inset(rect: Rect, amount: number | Partial<Record<"top" | "right" | "bottom" | "left", number>>): Rect;
|
|
20
|
+
//# sourceMappingURL=box.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box.d.ts","sourceRoot":"","sources":["../../src/layout/box.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAejD;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,GAAE,QAAa,GAAG,MAAM,CAe5D;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CACnB,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC,GAC5E,IAAI,CAgBN"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { escapeXml } from "../text/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* One SVG attribute, or nothing where the value was not given.
|
|
4
|
+
*
|
|
5
|
+
* The value is escaped even though most of them are colours out of a config,
|
|
6
|
+
* where nothing needs escaping. A template's props come from frontmatter, and a
|
|
7
|
+
* template is free to pass one straight through as a fill, so a site whose
|
|
8
|
+
* posts are not all written by the same person would otherwise be one `"` away
|
|
9
|
+
* from a document that does not parse.
|
|
10
|
+
*/
|
|
11
|
+
function attribute(name, value) {
|
|
12
|
+
return value === undefined ? "" : ` ${name}="${escapeXml(String(value))}"`;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A rectangle: the plate a badge sits on, the surface of a panel, a rule along
|
|
16
|
+
* an edge. Everything in a template that is not text or an image is one of
|
|
17
|
+
* these.
|
|
18
|
+
*
|
|
19
|
+
* Attributes a style does not name are left out rather than written as their
|
|
20
|
+
* defaults, so the output says only what the template decided.
|
|
21
|
+
*/
|
|
22
|
+
export function box(rect, style = {}) {
|
|
23
|
+
const attributes = [
|
|
24
|
+
attribute("x", rect.x),
|
|
25
|
+
attribute("y", rect.y),
|
|
26
|
+
attribute("width", rect.width),
|
|
27
|
+
attribute("height", rect.height),
|
|
28
|
+
attribute("rx", style.radius),
|
|
29
|
+
attribute("fill", style.fill),
|
|
30
|
+
attribute("fill-opacity", style.fillOpacity),
|
|
31
|
+
attribute("stroke", style.stroke),
|
|
32
|
+
attribute("stroke-opacity", style.strokeOpacity),
|
|
33
|
+
attribute("stroke-width", style.strokeWidth),
|
|
34
|
+
];
|
|
35
|
+
return `<rect${attributes.join("")}/>`;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Shrink a rectangle inwards, which is how a template gets its margins. One
|
|
39
|
+
* number insets every edge; a partial one insets the edges it names.
|
|
40
|
+
*
|
|
41
|
+
* An inset larger than the rectangle collapses it to nothing rather than
|
|
42
|
+
* turning it inside out, since a negative width draws nothing anyway and an
|
|
43
|
+
* empty rectangle is easier to reason about than one with its corners crossed.
|
|
44
|
+
*/
|
|
45
|
+
export function inset(rect, amount) {
|
|
46
|
+
const all = typeof amount === "number" ? amount : 0;
|
|
47
|
+
const edges = typeof amount === "number" ? {} : amount;
|
|
48
|
+
const top = edges.top ?? all;
|
|
49
|
+
const right = edges.right ?? all;
|
|
50
|
+
const bottom = edges.bottom ?? all;
|
|
51
|
+
const left = edges.left ?? all;
|
|
52
|
+
return {
|
|
53
|
+
// Clamped so that a rectangle which collapses does so at the far edge of
|
|
54
|
+
// the one it came from, rather than landing outside it with no width.
|
|
55
|
+
x: rect.x + Math.min(left, rect.width),
|
|
56
|
+
y: rect.y + Math.min(top, rect.height),
|
|
57
|
+
width: Math.max(0, rect.width - left - right),
|
|
58
|
+
height: Math.max(0, rect.height - top - bottom),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=box.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box.js","sourceRoot":"","sources":["../../src/layout/box.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C;;;;;;;;GAQG;A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G,GAAG,KAAK,CAAC,GAAG,IAAI,GAAG,CAAC;IAC7B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,GAAG,CAAC;IACjC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC;IACnC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,GAAG,CAAC;IAE/B,OAAO;QACL,yEAAyE;QACzE,sEAAsE;QACtE,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC;QACtC,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC;QACtC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC;QAC7C,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC;KAChD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Align, Extent, Placed, Span } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Lay a group of items out along one axis.
|
|
4
|
+
*
|
|
5
|
+
* Stacking rows of text down an image and setting a badge beside a title are
|
|
6
|
+
* the same sum with the coordinates renamed, so both `stack` and
|
|
7
|
+
* `row` are this function. It is the only arithmetic in the toolkit that
|
|
8
|
+
* is worth getting right once.
|
|
9
|
+
*
|
|
10
|
+
* A group taller or wider than the space it was given starts at `span.start`
|
|
11
|
+
* and runs over rather than being squeezed, since a template that has
|
|
12
|
+
* overflowed wants to see it rather than have it hidden.
|
|
13
|
+
*/
|
|
14
|
+
export declare function distribute(items: readonly Extent[], span: Span, align?: Align): readonly Placed[];
|
|
15
|
+
//# sourceMappingURL=distribute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distribute.d.ts","sourceRoot":"","sources":["../../src/layout/distribute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAE9D;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,IAAI,EAAE,IAAI,EACV,KAAK,GAAE,KAAgB,GACtB,SAAS,MAAM,EAAE,CAYnB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lay a group of items out along one axis.
|
|
3
|
+
*
|
|
4
|
+
* Stacking rows of text down an image and setting a badge beside a title are
|
|
5
|
+
* the same sum with the coordinates renamed, so both `stack` and
|
|
6
|
+
* `row` are this function. It is the only arithmetic in the toolkit that
|
|
7
|
+
* is worth getting right once.
|
|
8
|
+
*
|
|
9
|
+
* A group taller or wider than the space it was given starts at `span.start`
|
|
10
|
+
* and runs over rather than being squeezed, since a template that has
|
|
11
|
+
* overflowed wants to see it rather than have it hidden.
|
|
12
|
+
*/
|
|
13
|
+
export function distribute(items, span, align = "centre") {
|
|
14
|
+
const advances = items.map((item) => (item.gapBefore ?? 0) + item.size);
|
|
15
|
+
const total = advances.reduce((sum, advance) => sum + advance, 0);
|
|
16
|
+
const spare = Math.max(0, span.end - span.start - total);
|
|
17
|
+
let cursor = span.start + offset(spare, align);
|
|
18
|
+
return items.map((item, index) => {
|
|
19
|
+
const start = cursor + (item.gapBefore ?? 0);
|
|
20
|
+
cursor += advances[index] ?? 0;
|
|
21
|
+
return { start, index };
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function offset(spare, align) {
|
|
25
|
+
if (align === "start") {
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
return align === "end" ? spare : spare / 2;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=distribute.js.map
|
|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CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Rect } from "./types.js";
|
|
2
|
+
/** How an image fills the rectangle it was given. */
|
|
3
|
+
interface ImageFit {
|
|
4
|
+
/**
|
|
5
|
+
* `cover` fills the rectangle and crops whatever does not fit, which is what
|
|
6
|
+
* a background photo wants. `contain` fits the whole image inside it, which
|
|
7
|
+
* is what a logo wants, since cropping a wordmark ruins it.
|
|
8
|
+
*/
|
|
9
|
+
readonly fit?: "cover" | "contain";
|
|
10
|
+
readonly opacity?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Rounded corners, for an avatar or a screenshot, which need a clip path and
|
|
14
|
+
* so an id to hang it on: SVG has no other way to say it.
|
|
15
|
+
*
|
|
16
|
+
* The two travel together in the type, so a radius without an id does not
|
|
17
|
+
* compile. It is the sort of option that would otherwise be dropped in silence,
|
|
18
|
+
* and a template author asking for a round avatar and getting a square one has
|
|
19
|
+
* nothing to go on.
|
|
20
|
+
*/
|
|
21
|
+
type ImageCorners = {
|
|
22
|
+
readonly radius?: undefined;
|
|
23
|
+
readonly id?: string;
|
|
24
|
+
} | {
|
|
25
|
+
readonly radius: number;
|
|
26
|
+
readonly id: string;
|
|
27
|
+
};
|
|
28
|
+
/** Options for {@link image}. */
|
|
29
|
+
export type ImageOptions = ImageFit & ImageCorners;
|
|
30
|
+
/**
|
|
31
|
+
* Draw an image within a rectangle.
|
|
32
|
+
*
|
|
33
|
+
* `href` is passed through as given, so it can be a `data:` URI, which is the
|
|
34
|
+
* form that travels: an image file read at build time and inlined is an image
|
|
35
|
+
* that renders the same wherever the build runs, with nothing to fetch.
|
|
36
|
+
*
|
|
37
|
+
* An `<image>` establishes its own viewport, so `cover` crops to the rectangle
|
|
38
|
+
* without a clip path. Rounded corners do need one.
|
|
39
|
+
*/
|
|
40
|
+
export declare function image(rect: Rect, href: string, options?: ImageOptions): string;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/layout/image.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,qDAAqD;AACrD,UAAU,QAAQ;IAChB;;;;OAIG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;GAQG;AACH,KAAK,YAAY,GACb;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAErD,iCAAiC;AACjC,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,YAAY,CAAC;AAEnD;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CACnB,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,YAAiB,GACzB,MAAM,CA6BR"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { escapeXml } from "../text/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Draw an image within a rectangle.
|
|
4
|
+
*
|
|
5
|
+
* `href` is passed through as given, so it can be a `data:` URI, which is the
|
|
6
|
+
* form that travels: an image file read at build time and inlined is an image
|
|
7
|
+
* that renders the same wherever the build runs, with nothing to fetch.
|
|
8
|
+
*
|
|
9
|
+
* An `<image>` establishes its own viewport, so `cover` crops to the rectangle
|
|
10
|
+
* without a clip path. Rounded corners do need one.
|
|
11
|
+
*/
|
|
12
|
+
export function image(rect, href, options = {}) {
|
|
13
|
+
const fit = (options.fit ?? "cover") === "cover" ? "slice" : "meet";
|
|
14
|
+
const aspect = `xMidYMid ${fit}`;
|
|
15
|
+
const opacity = options.opacity === undefined
|
|
16
|
+
? ""
|
|
17
|
+
: ` opacity="${String(options.opacity)}"`;
|
|
18
|
+
const element = `<image x="${String(rect.x)}" y="${String(rect.y)}"` +
|
|
19
|
+
` width="${String(rect.width)}" height="${String(rect.height)}"` +
|
|
20
|
+
` preserveAspectRatio="${aspect}"${opacity}` +
|
|
21
|
+
` href="${escapeXml(href)}"/>`;
|
|
22
|
+
if (options.radius === undefined) {
|
|
23
|
+
return element;
|
|
24
|
+
}
|
|
25
|
+
// The type pairs the two, so an id is here whenever a radius is.
|
|
26
|
+
const id = escapeXml(options.id);
|
|
27
|
+
return (`<defs><clipPath id="${id}">` +
|
|
28
|
+
`<rect x="${String(rect.x)}" y="${String(rect.y)}"` +
|
|
29
|
+
` width="${String(rect.width)}" height="${String(rect.height)}"` +
|
|
30
|
+
` rx="${String(options.radius)}"/>` +
|
|
31
|
+
`</clipPath></defs>` +
|
|
32
|
+
`<g clip-path="url(#${id})">${element}</g>`);
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.js","sourceRoot":"","sources":["../../src/layout/image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AA8B7C;;;;;;;;;GASG;AACH,MAAM,UAAU,KAAK,CACnB,IAAU,EACV,IAAY,EACZ,OAAO,GAAiB,EAAE;IAE1B,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;IACpE,MAAM,MAAM,GAAG,YAAY,GAAG,EAAE,CAAC;IACjC,MAAM,OAAO,GACX,OAAO,CAAC,OAAO,KAAK,SAAS;QAC3B,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,aAAa,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;IAE9C,MAAM,OAAO,GACX,aAAa,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG;QACpD,WAAW,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG;QAChE,yBAAyB,MAAM,IAAI,OAAO,EAAE;QAC5C,UAAU,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;IAEjC,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACjC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,iEAAiE;IACjE,MAAM,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAEjC,OAAO,CACL,uBAAuB,EAAE,IAAI;QAC7B,YAAY,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG;QACnD,WAAW,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG;QAChE,QAAQ,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK;QACnC,oBAAoB;QACpB,sBAAsB,EAAE,MAAM,OAAO,MAAM,CAC5C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout primitives for template authors.
|
|
3
|
+
*
|
|
4
|
+
* Importable on its own as `@kensio/colophon/layout`. Writing a template means
|
|
5
|
+
* returning a string of SVG, and this is the set of small functions that build
|
|
6
|
+
* one: rectangles, panels, images, and the arithmetic of putting things in
|
|
7
|
+
* rows and stacks. It is deliberately boring. Nothing here holds state, every
|
|
8
|
+
* function takes values and returns them, and a template that would rather
|
|
9
|
+
* write its own SVG by hand still can.
|
|
10
|
+
*
|
|
11
|
+
* The subpath loads no rasteriser, no syntax highlighter and nothing from
|
|
12
|
+
* Node, so the whole of it runs anywhere a string does.
|
|
13
|
+
*
|
|
14
|
+
* Measuring is the exception to "import it from here": a template is handed a
|
|
15
|
+
* `MeasureText` on its context, because only the build knows which fonts
|
|
16
|
+
* were loaded. What this module exports is what to do with it.
|
|
17
|
+
*/
|
|
18
|
+
export { box, inset } from "./box.js";
|
|
19
|
+
export { distribute } from "./distribute.js";
|
|
20
|
+
export { image } from "./image.js";
|
|
21
|
+
export type { ImageOptions } from "./image.js";
|
|
22
|
+
export { panel } from "./panel.js";
|
|
23
|
+
export type { PanelStyle } from "./panel.js";
|
|
24
|
+
export { row } from "./row.js";
|
|
25
|
+
export type { RowRect } from "./row.js";
|
|
26
|
+
export { scrim } from "./scrim.js";
|
|
27
|
+
export type { ScrimOptions } from "./scrim.js";
|
|
28
|
+
export { stack } from "./stack.js";
|
|
29
|
+
export type { StackedRect } from "./stack.js";
|
|
30
|
+
export type { Align, BoxStyle, Extent, Placed, Rect, Span } from "./types.js";
|
|
31
|
+
export { blockLines } from "./block.js";
|
|
32
|
+
export type { StyledBlock, TextBlock, TextLine } from "./block.js";
|
|
33
|
+
export { baselineFor, drawLines, placeLines } from "./lines.js";
|
|
34
|
+
export type { LinesStyle, PlacedLine } from "./lines.js";
|
|
35
|
+
export { measureIn } from "./measure.js";
|
|
36
|
+
export { optionalString } from "../props.js";
|
|
37
|
+
export { escapeXml, fitText, textElement, wrapText } from "../text/index.js";
|
|
38
|
+
export type { FitOptions, FittedText, MeasureAt, MeasureLine, TextAttributes, } from "../text/index.js";
|
|
39
|
+
export type { Dimensions, MeasureText, MetaImageProps, ResolvedConfig, Template, TemplateContext, TextStyle, } from "../types.js";
|
|
40
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/layout/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EA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1B,YAAY,EACV,UAAU,EACV,WAAW,EACX,cAAc,EACd,cAAc,EACd,QAAQ,EACR,eAAe,EACf,SAAS,GACV,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout primitives for template authors.
|
|
3
|
+
*
|
|
4
|
+
* Importable on its own as `@kensio/colophon/layout`. Writing a template means
|
|
5
|
+
* returning a string of SVG, and this is the set of small functions that build
|
|
6
|
+
* one: rectangles, panels, images, and the arithmetic of putting things in
|
|
7
|
+
* rows and stacks. It is deliberately boring. Nothing here holds state, every
|
|
8
|
+
* function takes values and returns them, and a template that would rather
|
|
9
|
+
* write its own SVG by hand still can.
|
|
10
|
+
*
|
|
11
|
+
* The subpath loads no rasteriser, no syntax highlighter and nothing from
|
|
12
|
+
* Node, so the whole of it runs anywhere a string does.
|
|
13
|
+
*
|
|
14
|
+
* Measuring is the exception to "import it from here": a template is handed a
|
|
15
|
+
* `MeasureText` on its context, because only the build knows which fonts
|
|
16
|
+
* were loaded. What this module exports is what to do with it.
|
|
17
|
+
*/
|
|
18
|
+
export { box, inset } from "./box.js";
|
|
19
|
+
export { distribute } from "./distribute.js";
|
|
20
|
+
export { image } from "./image.js";
|
|
21
|
+
export { panel } from "./panel.js";
|
|
22
|
+
export { row } from "./row.js";
|
|
23
|
+
export { scrim } from "./scrim.js";
|
|
24
|
+
export { stack } from "./stack.js";
|
|
25
|
+
export { blockLines } from "./block.js";
|
|
26
|
+
export { baselineFor, drawLines, placeLines } from "./lines.js";
|
|
27
|
+
export { measureIn } from "./measure.js";
|
|
28
|
+
export { optionalString } from "../props.js";
|
|
29
|
+
export { escapeXml, fitText, textElement, wrapText } from "../text/index.js";
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/layout/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAInC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { TextLine } from "./block.js";
|
|
2
|
+
import type { Align, Rect } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* The baseline of one line of text sitting in a band of its own font size.
|
|
5
|
+
*
|
|
6
|
+
* A template that has set room aside for a single line, rather than stacking
|
|
7
|
+
* several, wants this rather than a fraction of the font size chosen by eye:
|
|
8
|
+
* the ink then lands inside the band that was written down, so the clear space
|
|
9
|
+
* either side of it is the space that was reserved. The descender takes the
|
|
10
|
+
* rest of the band, which is why the room below a line is not the same as the
|
|
11
|
+
* room above it.
|
|
12
|
+
*/
|
|
13
|
+
export declare function baselineFor(top: number, fontSize: number): number;
|
|
14
|
+
/** How a block of lines is drawn: the font, the fill, and where it sits. */
|
|
15
|
+
export interface LinesStyle {
|
|
16
|
+
readonly fontFamily: string;
|
|
17
|
+
readonly fill: string;
|
|
18
|
+
/** Multiplier on each line's font size. Defaults to `1.2`. */
|
|
19
|
+
readonly lineHeight?: number;
|
|
20
|
+
/** Horizontal anchor. `middle` centres each line in the area. */
|
|
21
|
+
readonly anchor?: "start" | "middle" | "end";
|
|
22
|
+
/** Where the block sits vertically in the area. Defaults to `centre`. */
|
|
23
|
+
readonly align?: Align;
|
|
24
|
+
}
|
|
25
|
+
/** A line with its computed text baseline. */
|
|
26
|
+
export interface PlacedLine {
|
|
27
|
+
readonly y: number;
|
|
28
|
+
readonly index: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Place a block of lines within an area and return each baseline.
|
|
32
|
+
*
|
|
33
|
+
* The lines are placed as one block rather than each finding its own middle,
|
|
34
|
+
* which is what keeps a wrapped title reading as a paragraph. A block taller
|
|
35
|
+
* than its area starts at the top and runs over, since a template that has
|
|
36
|
+
* overflowed wants to see it.
|
|
37
|
+
*/
|
|
38
|
+
export declare function placeLines(lines: readonly TextLine[], area: Rect, lineHeight?: number, align?: Align): readonly PlacedLine[];
|
|
39
|
+
/**
|
|
40
|
+
* Draw a block of lines within an area: place them, then write the `<text>`
|
|
41
|
+
* elements. Once a template has fitted its words, this is the whole of what it
|
|
42
|
+
* does with them.
|
|
43
|
+
*/
|
|
44
|
+
export declare function drawLines(lines: readonly TextLine[], area: Rect, style: LinesStyle): string;
|
|
45
|
+
//# sourceMappingURL=lines.d.ts.map
|