@kensio/colophon 2.3.0 → 2.5.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 +107 -798
- package/dist/background/gradient.d.ts +12 -0
- package/dist/background/gradient.d.ts.map +1 -0
- package/dist/background/gradient.js +21 -0
- package/dist/background/gradient.js.map +1 -0
- package/dist/background/image.d.ts +14 -0
- package/dist/background/image.d.ts.map +1 -0
- package/dist/background/image.js +36 -0
- package/dist/background/image.js.map +1 -0
- package/dist/background/index.d.ts +13 -0
- package/dist/background/index.d.ts.map +1 -0
- package/dist/background/index.js +27 -0
- package/dist/background/index.js.map +1 -0
- package/dist/background/mesh.d.ts +12 -0
- package/dist/background/mesh.d.ts.map +1 -0
- package/dist/background/mesh.js +43 -0
- package/dist/background/mesh.js.map +1 -0
- 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 +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +1 -1
- package/dist/cli/config.d.ts +1 -1
- package/dist/cli/config.js +1 -1
- package/dist/config/defaults.d.ts +8 -7
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +8 -8
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +14 -5
- package/dist/config/index.js.map +1 -1
- package/dist/config/resolve.d.ts +7 -0
- package/dist/config/resolve.d.ts.map +1 -1
- package/dist/config/resolve.js +16 -0
- package/dist/config/resolve.js.map +1 -1
- package/dist/config/size.d.ts +7 -1
- package/dist/config/size.d.ts.map +1 -1
- package/dist/config/size.js +22 -9
- package/dist/config/size.js.map +1 -1
- package/dist/content/props.d.ts +2 -2
- package/dist/content/props.js +2 -2
- package/dist/content/slug.d.ts +5 -5
- package/dist/content/slug.js +6 -6
- package/dist/content/slug.js.map +1 -1
- package/dist/content/walk.d.ts +1 -1
- package/dist/content/walk.js +1 -1
- package/dist/fonts/index.d.ts +3 -2
- package/dist/fonts/index.d.ts.map +1 -1
- package/dist/fonts/index.js +3 -2
- package/dist/fonts/index.js.map +1 -1
- package/dist/fonts/resolve.js +1 -1
- package/dist/generate/extra.js +4 -4
- package/dist/generate/extra.js.map +1 -1
- package/dist/generate/options.d.ts +1 -1
- package/dist/generate/outputs.d.ts +4 -4
- package/dist/generate/outputs.js +4 -4
- package/dist/highlight/language.d.ts +2 -3
- package/dist/highlight/language.d.ts.map +1 -1
- package/dist/highlight/language.js +3 -4
- package/dist/highlight/language.js.map +1 -1
- package/dist/highlight/normalise.d.ts +2 -2
- package/dist/highlight/normalise.js +2 -2
- 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 +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -2
- 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 +1 -1
- package/dist/manifest/build.js +1 -1
- package/dist/manifest/index.d.ts +1 -1
- package/dist/manifest/index.js +1 -1
- package/dist/manifest/order.d.ts +1 -1
- package/dist/manifest/order.js +1 -1
- package/dist/manifest/page.d.ts +2 -2
- package/dist/manifest/page.js +3 -3
- 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/tags.d.ts +6 -6
- package/dist/meta/tags.js +6 -6
- package/dist/meta/url.d.ts +4 -4
- package/dist/meta/url.js +4 -4
- package/dist/placement/check.d.ts +1 -1
- package/dist/placement/check.js +1 -1
- package/dist/placement/index.js +1 -1
- package/dist/placement/relative.d.ts +3 -3
- package/dist/placement/relative.js +3 -3
- package/dist/pool.d.ts +2 -2
- package/dist/pool.js +3 -3
- package/dist/pool.js.map +1 -1
- 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/svg.d.ts +4 -2
- package/dist/render/svg.d.ts.map +1 -1
- package/dist/render/svg.js +28 -6
- package/dist/render/svg.js.map +1 -1
- package/dist/stamp/config-digest.d.ts.map +1 -1
- package/dist/stamp/config-digest.js +21 -1
- package/dist/stamp/config-digest.js.map +1 -1
- package/dist/stamp/index.js +2 -2
- package/dist/stamp/index.js.map +1 -1
- package/dist/stamp/read.d.ts +1 -1
- package/dist/stamp/read.js +4 -4
- 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-props.d.ts +16 -0
- package/dist/templates/banner/badge-props.d.ts.map +1 -0
- package/dist/templates/banner/badge-props.js +58 -0
- package/dist/templates/banner/badge-props.js.map +1 -0
- package/dist/templates/banner/badge.d.ts.map +1 -1
- package/dist/templates/banner/badge.js +3 -6
- package/dist/templates/banner/badge.js.map +1 -1
- package/dist/templates/banner/index.d.ts +3 -0
- package/dist/templates/banner/index.d.ts.map +1 -1
- package/dist/templates/banner/index.js +41 -37
- package/dist/templates/banner/index.js.map +1 -1
- package/dist/templates/banner/lines.d.ts +7 -12
- package/dist/templates/banner/lines.d.ts.map +1 -1
- package/dist/templates/banner/lines.js +23 -34
- package/dist/templates/banner/lines.js.map +1 -1
- 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 +4 -1
- package/dist/templates/card/index.d.ts.map +1 -1
- package/dist/templates/card/index.js +37 -25
- package/dist/templates/card/index.js.map +1 -1
- package/dist/templates/card/lines.d.ts +17 -13
- package/dist/templates/card/lines.d.ts.map +1 -1
- package/dist/templates/card/lines.js +24 -20
- package/dist/templates/card/lines.js.map +1 -1
- package/dist/templates/code/chrome.d.ts +7 -3
- package/dist/templates/code/chrome.d.ts.map +1 -1
- package/dist/templates/code/chrome.js +12 -11
- package/dist/templates/code/chrome.js.map +1 -1
- package/dist/templates/code/clip.d.ts +1 -1
- package/dist/templates/code/clip.js +1 -1
- package/dist/templates/code/fit.d.ts +2 -2
- package/dist/templates/code/fit.d.ts.map +1 -1
- package/dist/templates/code/fit.js +4 -4
- package/dist/templates/code/fit.js.map +1 -1
- package/dist/templates/code/index.d.ts.map +1 -1
- package/dist/templates/code/index.js +7 -6
- package/dist/templates/code/index.js.map +1 -1
- package/dist/templates/code/layout.d.ts +1 -1
- package/dist/templates/code/layout.d.ts.map +1 -1
- package/dist/templates/code/layout.js +6 -6
- package/dist/templates/code/layout.js.map +1 -1
- package/dist/templates/code/panel.d.ts +13 -0
- package/dist/templates/code/panel.d.ts.map +1 -1
- package/dist/templates/code/panel.js +34 -2
- package/dist/templates/code/panel.js.map +1 -1
- package/dist/templates/code/plate.d.ts +3 -1
- package/dist/templates/code/plate.d.ts.map +1 -1
- package/dist/templates/code/plate.js +11 -9
- package/dist/templates/code/plate.js.map +1 -1
- package/dist/templates/code/spans.js +1 -1
- package/dist/templates/code/spans.js.map +1 -1
- 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 +8 -0
- package/dist/templates/footer.d.ts.map +1 -1
- package/dist/templates/footer.js +11 -1
- package/dist/templates/footer.js.map +1 -1
- package/dist/templates/index.d.ts +1 -1
- package/dist/templates/index.d.ts.map +1 -1
- package/dist/templates/index.js +1 -1
- 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/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 +5 -3
- package/dist/text/index.d.ts.map +1 -1
- package/dist/text/index.js +3 -2
- package/dist/text/index.js.map +1 -1
- package/dist/text/wrap.d.ts +17 -7
- package/dist/text/wrap.d.ts.map +1 -1
- package/dist/text/wrap.js +25 -17
- package/dist/text/wrap.js.map +1 -1
- package/dist/texture/grain.d.ts +17 -0
- package/dist/texture/grain.d.ts.map +1 -0
- package/dist/texture/grain.js +29 -0
- package/dist/texture/grain.js.map +1 -0
- package/dist/texture/index.d.ts +11 -0
- package/dist/texture/index.d.ts.map +1 -0
- package/dist/texture/index.js +20 -0
- package/dist/texture/index.js.map +1 -0
- package/dist/texture/pattern.d.ts +17 -0
- package/dist/texture/pattern.d.ts.map +1 -0
- package/dist/texture/pattern.js +45 -0
- package/dist/texture/pattern.js.map +1 -0
- package/dist/texture/resolve.d.ts +16 -0
- package/dist/texture/resolve.d.ts.map +1 -0
- package/dist/texture/resolve.js +20 -0
- package/dist/texture/resolve.js.map +1 -0
- package/dist/theme/index.d.ts +27 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +41 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/presets.d.ts +38 -0
- package/dist/theme/presets.d.ts.map +1 -0
- package/dist/theme/presets.js +150 -0
- package/dist/theme/presets.js.map +1 -0
- package/dist/types.d.ts +281 -46
- package/dist/types.d.ts.map +1 -1
- package/dist/validate/background.d.ts +12 -0
- package/dist/validate/background.d.ts.map +1 -0
- package/dist/validate/background.js +53 -0
- package/dist/validate/background.js.map +1 -0
- package/dist/validate/collect.d.ts +9 -0
- package/dist/validate/collect.d.ts.map +1 -0
- package/dist/validate/collect.js +34 -0
- package/dist/validate/collect.js.map +1 -0
- package/dist/validate/index.d.ts +1 -1
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js +3 -20
- package/dist/validate/index.js.map +1 -1
- package/dist/validate/keys.d.ts +35 -2
- package/dist/validate/keys.d.ts.map +1 -1
- package/dist/validate/keys.js +92 -3
- package/dist/validate/keys.js.map +1 -1
- package/dist/validate/overrides.d.ts.map +1 -1
- package/dist/validate/overrides.js +5 -1
- package/dist/validate/overrides.js.map +1 -1
- package/dist/validate/suggest.d.ts.map +1 -1
- package/dist/validate/suggest.js +21 -3
- package/dist/validate/suggest.js.map +1 -1
- package/dist/validate/texture.d.ts +11 -0
- package/dist/validate/texture.d.ts.map +1 -0
- package/dist/validate/texture.js +34 -0
- package/dist/validate/texture.js.map +1 -0
- package/dist/validate/values.d.ts +10 -10
- package/dist/validate/values.d.ts.map +1 -1
- package/dist/validate/values.js +21 -31
- package/dist/validate/values.js.map +1 -1
- package/package.json +7 -1
|
@@ -2,7 +2,7 @@ import { ellipsis } from "./ellipsis.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Clip a line to the columns that fit, ending it with an ellipsis. The font
|
|
4
4
|
* size is floored for legibility, so a wide enough snippet can still overrun
|
|
5
|
-
* the panel
|
|
5
|
+
* the panel, and clipping keeps it inside instead of bleeding off the image.
|
|
6
6
|
*
|
|
7
7
|
* Returns the line unchanged when it already fits, so the caller can count the
|
|
8
8
|
* clipped lines by identity.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CodeToken, HighlightedCode } from "../../highlight/index.js";
|
|
2
|
-
import type { ResolvedConfig } from "../../types.js";
|
|
2
|
+
import type { Dimensions, ResolvedConfig } from "../../types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Pick the largest font size that fits the snippet in the panel on both axes,
|
|
5
5
|
* clamped to the configured bounds.
|
|
@@ -10,7 +10,7 @@ import type { ResolvedConfig } from "../../types.js";
|
|
|
10
10
|
* let a landscape image render the same snippet at half the size of its square
|
|
11
11
|
* counterpart.
|
|
12
12
|
*/
|
|
13
|
-
export declare function fitFontSize(highlighted: HighlightedCode,
|
|
13
|
+
export declare function fitFontSize(highlighted: HighlightedCode, area: Dimensions, imageWidth: number, config: ResolvedConfig, charWidthRatio: number): number;
|
|
14
14
|
/**
|
|
15
15
|
* Width of the laid-out block in characters, measured from the lines actually
|
|
16
16
|
* being drawn. Narrower than the snippet's longest line whenever that line was
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fit.d.ts","sourceRoot":"","sources":["../../../src/templates/code/fit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"fit.d.ts","sourceRoot":"","sources":["../../../src/templates/code/fit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGjE;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,WAAW,EAAE,eAAe,EAC5B,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,cAAc,EACtB,cAAc,EAAE,MAAM,GACrB,MAAM,CAUR;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,SAAS,SAAS,EAAE,CAAC,EAAE,GAAG,MAAM,CAY7E;AAaD;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,SAAS,CAAC,SAAS,SAAS,EAAE,CAAC,EAAE,EACxC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,GACX,SAAS,CAAC,SAAS,SAAS,EAAE,CAAC,EAAE,CAWnC"}
|
|
@@ -9,10 +9,10 @@ import { ellipsis } from "./ellipsis.js";
|
|
|
9
9
|
* let a landscape image render the same snippet at half the size of its square
|
|
10
10
|
* counterpart.
|
|
11
11
|
*/
|
|
12
|
-
export function fitFontSize(highlighted,
|
|
13
|
-
const {
|
|
14
|
-
const byWidth =
|
|
15
|
-
const byHeight =
|
|
12
|
+
export function fitFontSize(highlighted, area, imageWidth, config, charWidthRatio) {
|
|
13
|
+
const { lineHeight, maxFontScale, minFontScale } = config.code;
|
|
14
|
+
const byWidth = area.width / (Math.max(1, highlighted.longestLine) * charWidthRatio);
|
|
15
|
+
const byHeight = area.height / (Math.max(1, highlighted.lines.length) * lineHeight);
|
|
16
16
|
const fitted = Math.min(byWidth, byHeight, imageWidth * maxFontScale);
|
|
17
17
|
return Math.max(1, Math.floor(Math.max(fitted, imageWidth * minFontScale)));
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fit.js","sourceRoot":"","sources":["../../../src/templates/code/fit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CACzB,WAA4B,EAC5B,
|
|
1
|
+
{"version":3,"file":"fit.js","sourceRoot":"","sources":["../../../src/templates/code/fit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CACzB,WAA4B,EAC5B,IAAgB,EAChB,UAAkB,EAClB,MAAsB,EACtB,cAAsB;IAEtB,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC;IAE/D,MAAM,OAAO,GACX,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC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,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC;IAE5D,IAAI,KAAK,CAAC,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,GAAG,CAAC,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE1E,OAAO,CAAC,GAAG,IAAI,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/code/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/code/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAY/C;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,EAAE,QAkF1B,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { highlightCode } from "../../highlight/index.js";
|
|
2
2
|
import { hasFooter } from "../footer.js";
|
|
3
|
-
import { optionalString } from "
|
|
3
|
+
import { optionalString } from "../../props.js";
|
|
4
4
|
import { codeFooter, codeHeading } from "./chrome.js";
|
|
5
5
|
import { blockColumns } from "./fit.js";
|
|
6
6
|
import { fitSnippet } from "./layout.js";
|
|
7
|
-
import { layoutPanel } from "./panel.js";
|
|
7
|
+
import { layoutPanel, titleBand } from "./panel.js";
|
|
8
8
|
import { hugPanel, panelSvg } from "./plate.js";
|
|
9
9
|
import { codeBody } from "./spans.js";
|
|
10
10
|
import { warnIfTruncated } from "./warn.js";
|
|
11
|
+
import { charWidthRatio } from "./width.js";
|
|
11
12
|
/**
|
|
12
13
|
* Syntax-highlighted code snippet on a rounded panel over the configured
|
|
13
14
|
* background. Reads `code` and `language` from the props (as the original
|
|
@@ -19,7 +20,7 @@ import { warnIfTruncated } from "./warn.js";
|
|
|
19
20
|
*/
|
|
20
21
|
export const codeTemplate = {
|
|
21
22
|
name: "code",
|
|
22
|
-
async render({ props, config, dimensions }) {
|
|
23
|
+
async render({ props, config, dimensions, measure }) {
|
|
23
24
|
const { width, height } = dimensions;
|
|
24
25
|
const title = optionalString(props.title);
|
|
25
26
|
const titleFs = Math.round(height * 0.045);
|
|
@@ -30,13 +31,13 @@ export const codeTemplate = {
|
|
|
30
31
|
tabSize: config.code.tabSize,
|
|
31
32
|
});
|
|
32
33
|
const available = layoutPanel(dimensions, config, titleFs, footerFs, title !== undefined && title !== "", hasFooter(config));
|
|
33
|
-
const fitted = fitSnippet(highlighted, available, width, config);
|
|
34
|
+
const fitted = fitSnippet(highlighted, available, width, config, charWidthRatio(measure, config.code.fontFamily));
|
|
34
35
|
warnIfTruncated(config, dimensions, {
|
|
35
36
|
dropped: highlighted.lines.length - fitted.lines.length,
|
|
36
37
|
clipped: fitted.clipped,
|
|
37
38
|
}, highlighted.lines.length);
|
|
38
39
|
// Shrink the panel down onto the snippet so it isn't left floating in dead
|
|
39
|
-
// space
|
|
40
|
+
// space. On a landscape image especially, a wide panel holding a narrow
|
|
40
41
|
// block leaves the code marooned off to one side.
|
|
41
42
|
const panel = hugPanel(available, {
|
|
42
43
|
width: blockColumns(fitted.lines) * fitted.charWidth + fitted.padding * 2,
|
|
@@ -55,7 +56,7 @@ export const codeTemplate = {
|
|
|
55
56
|
});
|
|
56
57
|
const shadowOffset = Math.round(Math.min(width, height) * 0.01);
|
|
57
58
|
const plate = panelSvg(panel, highlighted.background, Math.max(1, shadowOffset));
|
|
58
|
-
return (codeHeading(title, panel, titleFs,
|
|
59
|
+
return (codeHeading(title, titleBand(panel, dimensions, titleFs), titleFs, config) +
|
|
59
60
|
plate +
|
|
60
61
|
body +
|
|
61
62
|
codeFooter(dimensions, footerFs, config));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/code/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/code/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,YAAY,GAAa;IACpC,IAAI,EAAE,MAAM;IACZ,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAA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AAC,CACzC,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -17,5 +17,5 @@ export interface FittedCode {
|
|
|
17
17
|
* Fit a highlighted snippet into the panel it has been allotted: choose the
|
|
18
18
|
* font size, then drop and clip whatever still does not fit.
|
|
19
19
|
*/
|
|
20
|
-
export declare function fitSnippet(highlighted: HighlightedCode, available: Panel, imageWidth: number, config: ResolvedConfig): FittedCode;
|
|
20
|
+
export declare function fitSnippet(highlighted: HighlightedCode, available: Panel, imageWidth: number, config: ResolvedConfig, charWidthRatio: number): FittedCode;
|
|
21
21
|
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/templates/code/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,SAAS,SAAS,EAAE,CAAC,EAAE,CAAC;IAClD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,WAAW,EAAE,eAAe,EAC5B,SAAS,EAAE,KAAK,EAChB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,cAAc,GACrB,UAAU,CA6BZ"}
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/templates/code/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,SAAS,SAAS,EAAE,CAAC,EAAE,CAAC;IAClD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,WAAW,EAAE,eAAe,EAC5B,SAAS,EAAE,KAAK,EAChB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,cAAc,EACtB,cAAc,EAAE,MAAM,GACrB,UAAU,CA6BZ"}
|
|
@@ -4,17 +4,17 @@ import { fitFontSize, fitLines } from "./fit.js";
|
|
|
4
4
|
* Fit a highlighted snippet into the panel it has been allotted: choose the
|
|
5
5
|
* font size, then drop and clip whatever still does not fit.
|
|
6
6
|
*/
|
|
7
|
-
export function fitSnippet(highlighted, available, imageWidth, config) {
|
|
7
|
+
export function fitSnippet(highlighted, available, imageWidth, config, charWidthRatio) {
|
|
8
8
|
const inner = Math.round(Math.min(available.width, available.height) * 0.07);
|
|
9
9
|
const codeWidth = Math.max(1, available.width - inner * 2);
|
|
10
10
|
const codeHeight = Math.max(1, available.height - inner * 2);
|
|
11
|
-
const fontSize = fitFontSize(highlighted, codeWidth, codeHeight, imageWidth, config);
|
|
12
|
-
const charWidth = fontSize *
|
|
11
|
+
const fontSize = fitFontSize(highlighted, { width: codeWidth, height: codeHeight }, imageWidth, config, charWidthRatio);
|
|
12
|
+
const charWidth = fontSize * charWidthRatio;
|
|
13
13
|
const step = fontSize * config.code.lineHeight;
|
|
14
14
|
const { lines, clipped } = clipLines(fitLines(highlighted.lines, codeHeight, step), Math.max(1, Math.floor(codeWidth / charWidth)));
|
|
15
|
-
// Padding reads best proportional to the text
|
|
16
|
-
// fitted down to a small size wants tighter margins. Only ever
|
|
17
|
-
// the code area the font was fitted against stays valid.
|
|
15
|
+
// Padding reads best proportional to the text rather than the panel, since a
|
|
16
|
+
// snippet fitted down to a small size wants tighter margins. Only ever
|
|
17
|
+
// shrink, so the code area the font was fitted against stays valid.
|
|
18
18
|
const padding = Math.max(Math.min(inner, Math.round(fontSize * 1.6)), Math.round(inner * 0.35));
|
|
19
19
|
return { lines, clipped, fontSize, charWidth, step, padding };
|
|
20
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../../src/templates/code/layout.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAgBjD;;;GAGG;AACH,MAAM,UAAU,UAAU,CACxB,WAA4B,EAC5B,SAAgB,EAChB,UAAkB,EAClB,MAAsB;IAEtB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7E,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC;IAC3D,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC;IAE7D,MAAM,QAAQ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AC7E,uEAAuE;IACvE,oEAAoE;IACpE,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CACtB,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC,EAC3C,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CACzB,CAAC;IAEF,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAChE,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Rect } from "../../layout/index.js";
|
|
1
2
|
import type { Dimensions, ResolvedConfig } from "../../types.js";
|
|
2
3
|
/**
|
|
3
4
|
* The rounded plate the snippet is drawn on.
|
|
@@ -9,9 +10,21 @@ export interface Panel {
|
|
|
9
10
|
readonly height: number;
|
|
10
11
|
readonly radius: number;
|
|
11
12
|
}
|
|
13
|
+
/** Margin from the image edge to anything drawn inside it. */
|
|
14
|
+
export declare function imageMargin(dimensions: Dimensions): number;
|
|
12
15
|
/**
|
|
13
16
|
* Place the code panel within the image, leaving room above for a title and
|
|
14
17
|
* below for a footer when either is present.
|
|
15
18
|
*/
|
|
16
19
|
export declare function layoutPanel(dimensions: Dimensions, config: ResolvedConfig, titleFontSize: number, footerFontSize: number, hasTitle: boolean, hasFooter: boolean): Panel;
|
|
20
|
+
/**
|
|
21
|
+
* The band the title was given: one line's worth of room above the panel, with
|
|
22
|
+
* the reserved gap between the two.
|
|
23
|
+
*
|
|
24
|
+
* It is measured up from the panel rather than down from the top margin, so
|
|
25
|
+
* that it follows the panel when the panel hugs a short snippet and moves
|
|
26
|
+
* down. That keeps the title with the plate it names rather than stranding it
|
|
27
|
+
* at the top of the image.
|
|
28
|
+
*/
|
|
29
|
+
export declare function titleBand(panel: Panel, dimensions: Dimensions, fontSize: number): Rect;
|
|
17
30
|
//# sourceMappingURL=panel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel.d.ts","sourceRoot":"","sources":["../../../src/templates/code/panel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,cAAc,EACtB,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,OAAO,EACjB,SAAS,EAAE,OAAO,GACjB,KAAK,CAgBP"}
|
|
1
|
+
{"version":3,"file":"panel.d.ts","sourceRoot":"","sources":["../../../src/templates/code/panel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,8DAA8D;AAC9D,wBAAgB,WAAW,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAE1D;AAcD;;;GAGG;AACH,wBAAgB,WAAW,CACzB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,cAAc,EACtB,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,OAAO,EACjB,SAAS,EAAE,OAAO,GACjB,KAAK,CAgBP;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,GACf,IAAI,CAON"}
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/** Margin from the image edge to anything drawn inside it. */
|
|
2
|
+
export function imageMargin(dimensions) {
|
|
3
|
+
return Math.round(Math.min(dimensions.width, dimensions.height) * 0.05);
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Clear space between the panel and the title above it or the footer below.
|
|
7
|
+
*
|
|
8
|
+
* `layoutPanel` reserves this at each end alongside a line's worth of room, and
|
|
9
|
+
* the bands those lines are then placed in take the room and leave the gap. The
|
|
10
|
+
* two agree because both are measured from here, which is the whole point: a
|
|
11
|
+
* gap that is reserved in one place and drawn in another drifts.
|
|
12
|
+
*/
|
|
13
|
+
function gapAround(dimensions) {
|
|
14
|
+
return Math.round(Math.min(dimensions.width, dimensions.height) * 0.028);
|
|
15
|
+
}
|
|
1
16
|
/**
|
|
2
17
|
* Place the code panel within the image, leaving room above for a title and
|
|
3
18
|
* below for a footer when either is present.
|
|
@@ -5,8 +20,8 @@
|
|
|
5
20
|
export function layoutPanel(dimensions, config, titleFontSize, footerFontSize, hasTitle, hasFooter) {
|
|
6
21
|
const { width, height } = dimensions;
|
|
7
22
|
const shorter = Math.min(width, height);
|
|
8
|
-
const pad =
|
|
9
|
-
const gap =
|
|
23
|
+
const pad = imageMargin(dimensions);
|
|
24
|
+
const gap = gapAround(dimensions);
|
|
10
25
|
const top = pad + (hasTitle ? titleFontSize + gap : 0);
|
|
11
26
|
const bottom = height - pad - (hasFooter ? footerFontSize + gap : 0);
|
|
12
27
|
return {
|
|
@@ -17,4 +32,21 @@ export function layoutPanel(dimensions, config, titleFontSize, footerFontSize, h
|
|
|
17
32
|
radius: Math.round(shorter * config.code.cornerScale),
|
|
18
33
|
};
|
|
19
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* The band the title was given: one line's worth of room above the panel, with
|
|
37
|
+
* the reserved gap between the two.
|
|
38
|
+
*
|
|
39
|
+
* It is measured up from the panel rather than down from the top margin, so
|
|
40
|
+
* that it follows the panel when the panel hugs a short snippet and moves
|
|
41
|
+
* down. That keeps the title with the plate it names rather than stranding it
|
|
42
|
+
* at the top of the image.
|
|
43
|
+
*/
|
|
44
|
+
export function titleBand(panel, dimensions, fontSize) {
|
|
45
|
+
return {
|
|
46
|
+
x: 0,
|
|
47
|
+
y: panel.y - gapAround(dimensions) - fontSize,
|
|
48
|
+
width: dimensions.width,
|
|
49
|
+
height: fontSize,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
20
52
|
//# sourceMappingURL=panel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel.js","sourceRoot":"","sources":["../../../src/templates/code/panel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"panel.js","sourceRoot":"","sources":["../../../src/templates/code/panel.ts"],"names":[],"mappings":"AAcA,8DAA8D;AAC9D,MAAM,UAAU,WAAW,CAAC,UAAsB;IAChD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;AAC1E,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,SAAS,CAAC,UAAsB;IACvC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC;AAC3E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CACzB,UAAsB,EACtB,MAAsB,EACtB,aAAqB,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a drop shadow, then the theme-coloured surface it sits on.
|
|
13
|
+
* The surface is stroked rather than left flat, so a dark theme still has an
|
|
14
|
+
* edge against a dark background.
|
|
13
15
|
*/
|
|
14
|
-
export declare function panelSvg(
|
|
16
|
+
export declare function panelSvg(available: Panel, background: string, shadowOffset: number): string;
|
|
15
17
|
//# sourceMappingURL=plate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plate.d.ts","sourceRoot":"","sources":["../../../src/templates/code/plate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plate.d.ts","sourceRoot":"","sources":["../../../src/templates/code/plate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;;GAIG;AACH,wBAAgB,QAAQ,CACtB,SAAS,EAAE,KAAK,EAChB,MAAM,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC1D,KAAK,CAmBP;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CACtB,SAAS,EAAE,KAAK,EAChB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,GACnB,MAAM,CAQR"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { panel } from "../../layout/index.js";
|
|
1
2
|
/**
|
|
2
3
|
* Shrink a panel onto its content, keeping it centred in the space it was
|
|
3
4
|
* allotted. Both axes are floored so a small snippet still gets a panel with
|
|
@@ -18,15 +19,16 @@ export function hugPanel(available, wanted) {
|
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
21
|
* The panel itself: a drop shadow, then the theme-coloured surface it sits on.
|
|
22
|
+
* The surface is stroked rather than left flat, so a dark theme still has an
|
|
23
|
+
* edge against a dark background.
|
|
21
24
|
*/
|
|
22
|
-
export function panelSvg(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return shadow + surface;
|
|
25
|
+
export function panelSvg(available, background, shadowOffset) {
|
|
26
|
+
return panel(available, {
|
|
27
|
+
radius: available.radius,
|
|
28
|
+
fill: background,
|
|
29
|
+
stroke: "#ffffff",
|
|
30
|
+
strokeOpacity: 0.12,
|
|
31
|
+
shadow: shadowOffset,
|
|
32
|
+
});
|
|
31
33
|
}
|
|
32
34
|
//# sourceMappingURL=plate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plate.js","sourceRoot":"","sources":["../../../src/templates/code/plate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plate.js","sourceRoot":"","sources":["../../../src/templates/code/plate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAG9C;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CACtB,SAAgB,EAChB,MAA2D;IAE3D,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CACpB,SAAS,CAAC,KAAK,EACf,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CACvE,CAAC;IACF,uEAAuE;IACvE,uEAAuE;IACvE,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CACrB,SAAS,CAAC,MAAM,EAChB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAC9D,CAAC;IAEF,OAAO;QACL,GAAG,SAAS;QACZ,CAAC,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QAC1D,CAAC,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC5D,KAAK;QACL,MAAM;KACP,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CACtB,SAAgB,EAChB,UAAkB,EAClB,YAAoB;IAEpB,OAAO,KAAK,CAAC,SAAS,EAAE;QACtB,MAAM,EAAE,SAAS,CAAC,MAAM;QACxB,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,SAAS;QACjB,aAAa,EAAE,IAAI;QACnB,MAAM,EAAE,YAAY;KACrB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spans.js","sourceRoot":"","sources":["../../../src/templates/code/spans.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"spans.js","sourceRoot":"","sources":["../../../src/templates/code/spans.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,2EAA2E;AAC3E,MAAM,WAAW,GAAG,IAAI,CAAC;AAEzB,SAAS,SAAS,CAChB,KAAgB,EAChB,CAAS,EACT,SAAiB,EACjB,UAAkB;IAElB,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,IAAI,UAAU,CAAC;IACvC,MAAM,OAAO,GACX,KAAK,CAAC,OAAO,KAAK,SAAS;QACzB,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,kBAAkB,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;IACjD,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;IACtD,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE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
import type { MeasureText } from "../../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Width of one character as a fraction of the font size.
|
|
4
|
+
*
|
|
5
|
+
* The template lays every token out on a character grid, so this is what says
|
|
6
|
+
* where each column falls. Measuring a digit is enough because the face is
|
|
7
|
+
* monospace: whichever character is measured, the advance is the same.
|
|
8
|
+
*/
|
|
9
|
+
export declare function charWidthRatio(measure: MeasureText, fontFamily: string): number;
|
|
10
|
+
//# sourceMappingURL=width.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"width.d.ts","sourceRoot":"","sources":["../../../src/templates/code/width.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAalD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,GACjB,MAAM,CAOR"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Advance width to assume when the monospace stack names no font the build
|
|
3
|
+
* loaded. `0.6` suits most monospace faces, including Source Code Pro, Menlo
|
|
4
|
+
* and DejaVu Sans Mono; Consolas is nearer `0.55`.
|
|
5
|
+
*
|
|
6
|
+
* This used to be `config.code.charWidthRatio`, a number every project had to
|
|
7
|
+
* work out for itself and keep in step with its font. It is a fallback now:
|
|
8
|
+
* supply the face as a file and the real advance is read from it.
|
|
9
|
+
*/
|
|
10
|
+
const fallbackRatio = 0.6;
|
|
11
|
+
/**
|
|
12
|
+
* Width of one character as a fraction of the font size.
|
|
13
|
+
*
|
|
14
|
+
* The template lays every token out on a character grid, so this is what says
|
|
15
|
+
* where each column falls. Measuring a digit is enough because the face is
|
|
16
|
+
* monospace: whichever character is measured, the advance is the same.
|
|
17
|
+
*/
|
|
18
|
+
export function charWidthRatio(measure, fontFamily) {
|
|
19
|
+
return measure("0", {
|
|
20
|
+
fontFamily,
|
|
21
|
+
fontSize: 1,
|
|
22
|
+
fontWeight: 400,
|
|
23
|
+
fallbackRatio,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=width.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"width.js","sourceRoot":"","sources":["../../../src/templates/code/width.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAoB,EACpB,UAAkB;IAElB,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,UAAU;QACV,QAAQ,EAAE,CAAC;QACX,UAAU,EAAE,GAAG;QACf,aAAa;KACd,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -11,6 +11,14 @@ export interface FooterPlacement {
|
|
|
11
11
|
readonly opacity: number;
|
|
12
12
|
readonly anchor?: "start" | "middle" | "end";
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* The baseline of a footer sitting on the bottom margin.
|
|
16
|
+
*
|
|
17
|
+
* The margin is where the line's ink stops rather than where its baseline
|
|
18
|
+
* goes, so the last line of an image keeps the same clear space below it as
|
|
19
|
+
* the content beside it has either side, and the descenders stay inside it.
|
|
20
|
+
*/
|
|
21
|
+
export declare function footerBaseline(height: number, pad: number, fontSize: number): number;
|
|
14
22
|
/** Whether the config carries a footer worth drawing. */
|
|
15
23
|
export declare function hasFooter(config: ResolvedConfig): boolean;
|
|
16
24
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"footer.d.ts","sourceRoot":"","sources":["../../src/templates/footer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;CAC9C;AAED,yDAAyD;AACzD,wBAAgB,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAEzD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,eAAe,GACzB,MAAM,CAeR"}
|
|
1
|
+
{"version":3,"file":"footer.d.ts","sourceRoot":"","sources":["../../src/templates/footer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;CAC9C;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,GACf,MAAM,CAER;AAED,yDAAyD;AACzD,wBAAgB,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAEzD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,eAAe,GACzB,MAAM,CAeR"}
|
package/dist/templates/footer.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import { textElement } from "../
|
|
1
|
+
import { baselineFor, textElement } from "../layout/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* The baseline of a footer sitting on the bottom margin.
|
|
4
|
+
*
|
|
5
|
+
* The margin is where the line's ink stops rather than where its baseline
|
|
6
|
+
* goes, so the last line of an image keeps the same clear space below it as
|
|
7
|
+
* the content beside it has either side, and the descenders stay inside it.
|
|
8
|
+
*/
|
|
9
|
+
export function footerBaseline(height, pad, fontSize) {
|
|
10
|
+
return baselineFor(height - pad - fontSize, fontSize);
|
|
11
|
+
}
|
|
2
12
|
/** Whether the config carries a footer worth drawing. */
|
|
3
13
|
export function hasFooter(config) {
|
|
4
14
|
return config.footer !== undefined && config.footer !== "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"footer.js","sourceRoot":"","sources":["../../src/templates/footer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"footer.js","sourceRoot":"","sources":["../../src/templates/footer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAgB9D;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAc,EACd,GAAW,EACX,QAAgB;IAEhB,OAAO,WAAW,CAAC,MAAM,GAAG,GAAG,GAAG,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACxD,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,SAAS,CAAC,MAAsB;IAC9C,OAAO,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,EAAE,CAAC;AAC7D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAsB,EACtB,SAA0B;IAE1B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,WAAW,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,EAAE;QACtC,CAAC,EAAE,SAAS,CAAC,CAAC;QACd,CAAC,EAAE,SAAS,CAAC,CAAC;QACd,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,QAAQ,EAAE,SAAS,CAAC,QAAQ;QAC5B,UAAU,EAAE,GAAG;QACf,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU;QAC9B,WAAW,EAAE,SAAS,CAAC,OAAO;QAC9B,GAAG,CAAC,SAAS,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC;KACpE,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -7,5 +7,5 @@ export declare const builtinTemplates: Readonly<Record<string, Template>>;
|
|
|
7
7
|
export { bannerTemplate } from "./banner/index.js";
|
|
8
8
|
export { cardTemplate } from "./card/index.js";
|
|
9
9
|
export { codeTemplate } from "./code/index.js";
|
|
10
|
-
export { optionalString } from "
|
|
10
|
+
export { optionalString } from "../props.js";
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK5C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAI/D,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK5C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAI/D,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/templates/index.js
CHANGED
|
@@ -13,5 +13,5 @@ export const builtinTemplates = {
|
|
|
13
13
|
export { bannerTemplate } from "./banner/index.js";
|
|
14
14
|
export { cardTemplate } from "./card/index.js";
|
|
15
15
|
export { codeTemplate } from "./code/index.js";
|
|
16
|
-
export { optionalString } from "
|
|
16
|
+
export { optionalString } from "../props.js";
|
|
17
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAuC;IAClE,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,cAAc;IACrC,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,YAAY;IACjC,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,YAAY;CAClC,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAuC;IAClE,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,cAAc;IACrC,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,YAAY;IACjC,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,YAAY;CAClC,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Rect } from "../layout/index.js";
|
|
2
|
+
import type { Dimensions, ImageAsset } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Where the logo goes, or nothing where there is none.
|
|
5
|
+
*
|
|
6
|
+
* Its height comes from the image being drawn rather than from the logo's own
|
|
7
|
+
* pixels, so the same file works on a square and a landscape, and its width
|
|
8
|
+
* follows from the proportions of the picture. A logo whose format does not
|
|
9
|
+
* state its size is drawn in a square, where a wordmark will sit small in the
|
|
10
|
+
* middle rather than being stretched to fit.
|
|
11
|
+
*/
|
|
12
|
+
export declare function logoRect(logo: ImageAsset | undefined, dimensions: Dimensions, pad: number, align: "start" | "middle"): Rect | undefined;
|
|
13
|
+
/** The logo drawn in the rectangle it was given, whole rather than cropped. */
|
|
14
|
+
export declare function logoElement(logo: ImageAsset | undefined, rect: Rect | undefined): string;
|
|
15
|
+
//# sourceMappingURL=logo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logo.d.ts","sourceRoot":"","sources":["../../src/templates/logo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAK1D;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,UAAU,GAAG,SAAS,EAC5B,UAAU,EAAE,UAAU,EACtB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,OAAO,GAAG,QAAQ,GACxB,IAAI,GAAG,SAAS,CAalB;AAED,+EAA+E;AAC/E,wBAAgB,WAAW,CACzB,IAAI,EAAE,UAAU,GAAG,SAAS,EAC5B,IAAI,EAAE,IAAI,GAAG,SAAS,GACrB,MAAM,CAIR"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { image } from "../layout/index.js";
|
|
2
|
+
/** The logo's height, as a fraction of the image's. */
|
|
3
|
+
const logoScale = 0.075;
|
|
4
|
+
/**
|
|
5
|
+
* Where the logo goes, or nothing where there is none.
|
|
6
|
+
*
|
|
7
|
+
* Its height comes from the image being drawn rather than from the logo's own
|
|
8
|
+
* pixels, so the same file works on a square and a landscape, and its width
|
|
9
|
+
* follows from the proportions of the picture. A logo whose format does not
|
|
10
|
+
* state its size is drawn in a square, where a wordmark will sit small in the
|
|
11
|
+
* middle rather than being stretched to fit.
|
|
12
|
+
*/
|
|
13
|
+
export function logoRect(logo, dimensions, pad, align) {
|
|
14
|
+
if (logo === undefined) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
const height = Math.round(dimensions.height * logoScale);
|
|
18
|
+
const width = Math.round(height * logo.aspect);
|
|
19
|
+
const x = align === "middle"
|
|
20
|
+
? Math.round((dimensions.width - width) / 2)
|
|
21
|
+
: dimensions.width - pad - width;
|
|
22
|
+
return { x, y: pad, width, height };
|
|
23
|
+
}
|
|
24
|
+
/** The logo drawn in the rectangle it was given, whole rather than cropped. */
|
|
25
|
+
export function logoElement(logo, rect) {
|
|
26
|
+
return logo === undefined || rect === undefined
|
|
27
|
+
? ""
|
|
28
|
+
: image(rect, logo.href, { fit: "contain" });
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=logo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logo.js","sourceRoot":"","sources":["../../src/templates/logo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAG3C,uDAAuD;AACvD,MAAM,SAAS,GAAG,KAAK,CAAC;AAExB;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CACtB,IAA4B,EAC5B,UAAsB,EACtB,GAAW,EACX,KAAyB;IAEzB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACzD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,CAAC,GACL,KAAK,KAAK,QAAQ;QAChB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5C,CAAC,CAAC,UAAU,CAAC,KAAK,GAAG,GAAG,GAAG,KAAK,CAAC;IAErC,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AACtC,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,WAAW,CACzB,IAA4B,EAC5B,IAAsB;IAEtB,OAAO,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS;QAC7C,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MeasureAt } from "../text/index.js";
|
|
2
|
+
import type { MeasureText } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Bind a measurer to one family and weight, leaving only the size open.
|
|
5
|
+
*
|
|
6
|
+
* That is the shape fitting text wants, since choosing a size is the whole of
|
|
7
|
+
* what it varies, and it keeps a template from repeating the family and weight
|
|
8
|
+
* on every call.
|
|
9
|
+
*/
|
|
10
|
+
export declare function measureIn(measure: MeasureText, fontFamily: string, fontWeight: number): MeasureAt;
|
|
11
|
+
//# sourceMappingURL=measure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measure.d.ts","sourceRoot":"","sources":["../../src/templates/measure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,SAAS,CAGX"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bind a measurer to one family and weight, leaving only the size open.
|
|
3
|
+
*
|
|
4
|
+
* That is the shape fitting text wants, since choosing a size is the whole of
|
|
5
|
+
* what it varies, and it keeps a template from repeating the family and weight
|
|
6
|
+
* on every call.
|
|
7
|
+
*/
|
|
8
|
+
export function measureIn(measure, fontFamily, fontWeight) {
|
|
9
|
+
return (text, fontSize) => measure(text, { fontFamily, fontSize, fontWeight });
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=measure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measure.js","sourceRoot":"","sources":["../../src/templates/measure.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CACvB,OAAoB,EACpB,UAAkB,EAClB,UAAkB;IAElB,OAAO,CAAC,IAAY,EAAE,QAAgB,EAAU,EAAE,CAChD,OAAO,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Read a prop as a string, coercing the scalar types YAML frontmatter yields
|
|
3
|
-
* (numbers, booleans) and returning `undefined` for anything else
|
|
4
|
-
* treat "not a usable string" and "absent" the same way.
|
|
3
|
+
* (numbers, booleans) and returning `undefined` for anything else, since
|
|
4
|
+
* templates treat "not a usable string" and "absent" the same way.
|
|
5
5
|
*/
|
|
6
6
|
export declare function optionalString(value: unknown): string | undefined;
|
|
7
7
|
//# sourceMappingURL=props.d.ts.map
|
package/dist/templates/props.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Read a prop as a string, coercing the scalar types YAML frontmatter yields
|
|
3
|
-
* (numbers, booleans) and returning `undefined` for anything else
|
|
4
|
-
* treat "not a usable string" and "absent" the same way.
|
|
3
|
+
* (numbers, booleans) and returning `undefined` for anything else, since
|
|
4
|
+
* templates treat "not a usable string" and "absent" the same way.
|
|
5
5
|
*/
|
|
6
6
|
export function optionalString(value) {
|
|
7
7
|
if (typeof value === "string") {
|