@kensio/colophon 2.13.1 → 2.14.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 +10 -0
- package/dist/config/defaults.d.ts +69 -2
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +61 -2
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +2 -0
- package/dist/config/index.js.map +1 -1
- package/dist/config/safe-area.d.ts +27 -0
- package/dist/config/safe-area.d.ts.map +1 -0
- package/dist/config/safe-area.js +81 -0
- package/dist/config/safe-area.js.map +1 -0
- package/dist/config/size.d.ts.map +1 -1
- package/dist/config/size.js +1 -0
- package/dist/config/size.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/templates/article/index.js +1 -1
- package/dist/templates/article/index.js.map +1 -1
- package/dist/templates/banner/badge.d.ts +8 -1
- package/dist/templates/banner/badge.d.ts.map +1 -1
- package/dist/templates/banner/badge.js +8 -4
- package/dist/templates/banner/badge.js.map +1 -1
- package/dist/templates/banner/index.d.ts.map +1 -1
- package/dist/templates/banner/index.js +10 -25
- package/dist/templates/banner/index.js.map +1 -1
- package/dist/templates/bottom.d.ts +1 -1
- package/dist/templates/bottom.d.ts.map +1 -1
- package/dist/templates/bottom.js +5 -5
- package/dist/templates/bottom.js.map +1 -1
- package/dist/templates/card/index.d.ts.map +1 -1
- package/dist/templates/card/index.js +9 -25
- package/dist/templates/card/index.js.map +1 -1
- package/dist/templates/cover/index.d.ts +21 -0
- package/dist/templates/cover/index.d.ts.map +1 -0
- package/dist/templates/cover/index.js +67 -0
- package/dist/templates/cover/index.js.map +1 -0
- package/dist/templates/cover/lines.d.ts +21 -0
- package/dist/templates/cover/lines.d.ts.map +1 -0
- package/dist/templates/cover/lines.js +73 -0
- package/dist/templates/cover/lines.js.map +1 -0
- package/dist/templates/cover/lockup.d.ts +47 -0
- package/dist/templates/cover/lockup.d.ts.map +1 -0
- package/dist/templates/cover/lockup.js +71 -0
- package/dist/templates/cover/lockup.js.map +1 -0
- package/dist/templates/docs/index.js +3 -3
- package/dist/templates/docs/index.js.map +1 -1
- package/dist/templates/event/index.js +3 -3
- package/dist/templates/event/index.js.map +1 -1
- package/dist/templates/footer.d.ts +3 -0
- package/dist/templates/footer.d.ts.map +1 -1
- package/dist/templates/footer.js +16 -1
- package/dist/templates/footer.js.map +1 -1
- package/dist/templates/frame.d.ts +27 -3
- package/dist/templates/frame.d.ts.map +1 -1
- package/dist/templates/frame.js +19 -7
- package/dist/templates/frame.js.map +1 -1
- package/dist/templates/index.d.ts +1 -0
- package/dist/templates/index.d.ts.map +1 -1
- package/dist/templates/index.js +3 -0
- package/dist/templates/index.js.map +1 -1
- package/dist/templates/logo.d.ts +6 -2
- package/dist/templates/logo.d.ts.map +1 -1
- package/dist/templates/logo.js +10 -6
- package/dist/templates/logo.js.map +1 -1
- package/dist/templates/photo/index.d.ts.map +1 -1
- package/dist/templates/photo/index.js +9 -4
- package/dist/templates/photo/index.js.map +1 -1
- package/dist/templates/quote/index.js +2 -2
- package/dist/templates/quote/index.js.map +1 -1
- package/dist/templates/release/index.js +3 -3
- package/dist/templates/release/index.js.map +1 -1
- package/dist/templates/stat/index.js +3 -3
- package/dist/templates/stat/index.js.map +1 -1
- package/dist/templates/thumbnail/index.js +3 -3
- package/dist/templates/thumbnail/index.js.map +1 -1
- package/dist/templates/wordmark/index.js +2 -2
- package/dist/templates/wordmark/index.js.map +1 -1
- package/dist/types.d.ts +49 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/validate/collect.d.ts.map +1 -1
- package/dist/validate/collect.js +2 -1
- package/dist/validate/collect.js.map +1 -1
- package/dist/validate/keys.d.ts +2 -0
- package/dist/validate/keys.d.ts.map +1 -1
- package/dist/validate/keys.js +9 -0
- package/dist/validate/keys.js.map +1 -1
- package/dist/validate/overrides.d.ts.map +1 -1
- package/dist/validate/overrides.js +2 -1
- package/dist/validate/overrides.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -202,6 +202,16 @@ gallery stays in sync.
|
|
|
202
202
|
<sub><code>thumbnail</code> · 1280×720 · title grown to fill the frame, texture scaled up</sub>
|
|
203
203
|
</td>
|
|
204
204
|
</tr>
|
|
205
|
+
<tr>
|
|
206
|
+
<td>
|
|
207
|
+
<img src="docs/samples/cover-x.png" alt="cover template, 3:1" width="100%" /><br />
|
|
208
|
+
<sub><code>cover</code> · 3:1 · profile header, kept clear of X's avatar corner</sub>
|
|
209
|
+
</td>
|
|
210
|
+
<td>
|
|
211
|
+
<img src="docs/samples/cover-youtube.png" alt="cover template, 16:9" width="100%" /><br />
|
|
212
|
+
<sub><code>cover</code> · 16:9 · same layout in YouTube's centred safe area</sub>
|
|
213
|
+
</td>
|
|
214
|
+
</tr>
|
|
205
215
|
</table>
|
|
206
216
|
|
|
207
217
|
### Themes
|
|
@@ -18,14 +18,26 @@ export declare const DEFAULT_TEXTURE_SCALE = 1;
|
|
|
18
18
|
* Named output-size presets covering the common social-image standards. Each
|
|
19
19
|
* `name` becomes the filename suffix (e.g. `my-post-og.png`).
|
|
20
20
|
*
|
|
21
|
+
* The first group are share images, made once per post:
|
|
22
|
+
*
|
|
21
23
|
* - `og`: 1.91:1, the Open Graph standard (`og:image`). Facebook, LinkedIn,
|
|
22
24
|
* Slack, Discord, WhatsApp, Mastodon, and the usual `twitter:image` reuse.
|
|
23
25
|
* - `square`: 1:1, X/Twitter `summary` card and a universal fallback.
|
|
24
26
|
* - `twitter`: 2:1, X/Twitter `summary_large_image` card.
|
|
25
27
|
* - `pinterest`: 2:3 tall pin.
|
|
26
28
|
* - `thumbnail`: 16:9, the size YouTube asks video thumbnails to be uploaded
|
|
27
|
-
* at
|
|
28
|
-
*
|
|
29
|
+
* at, carrying a {@link SizeOverrides.textureScale} for the reason that
|
|
30
|
+
* field gives.
|
|
31
|
+
*
|
|
32
|
+
* The rest are profile covers, made once for a site rather than once per post,
|
|
33
|
+
* so `config.extra` is the usual way to declare one. Each carries the
|
|
34
|
+
* {@link SafeArea} for the platform it is named after, which is what keeps the
|
|
35
|
+
* text out of the avatar and out of whatever that platform crops. Where those
|
|
36
|
+
* numbers come from, and how much to trust each of them, is in
|
|
37
|
+
* `docs/configuration/cover-images`.
|
|
38
|
+
*
|
|
39
|
+
* None of the covers is in `DEFAULT_SIZES`: a cover is not something a build
|
|
40
|
+
* should start making for every post because the package was upgraded.
|
|
29
41
|
*/
|
|
30
42
|
export declare const SIZE_PRESETS: {
|
|
31
43
|
readonly og: {
|
|
@@ -54,6 +66,61 @@ export declare const SIZE_PRESETS: {
|
|
|
54
66
|
readonly height: 720;
|
|
55
67
|
readonly textureScale: 3;
|
|
56
68
|
};
|
|
69
|
+
readonly xCover: {
|
|
70
|
+
readonly name: "x-cover";
|
|
71
|
+
readonly width: 1500;
|
|
72
|
+
readonly height: 500;
|
|
73
|
+
readonly safeArea: {
|
|
74
|
+
readonly top: 0.12;
|
|
75
|
+
readonly right: 0.06;
|
|
76
|
+
readonly bottom: 0.12;
|
|
77
|
+
readonly left: 0.25;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
readonly linkedinCover: {
|
|
81
|
+
readonly name: "linkedin-cover";
|
|
82
|
+
readonly width: 1584;
|
|
83
|
+
readonly height: 396;
|
|
84
|
+
readonly safeArea: {
|
|
85
|
+
readonly top: 0.1;
|
|
86
|
+
readonly right: 0.2;
|
|
87
|
+
readonly bottom: 0.1;
|
|
88
|
+
readonly left: 0.28;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
readonly linkedinPageCover: {
|
|
92
|
+
readonly name: "linkedin-page-cover";
|
|
93
|
+
readonly width: 4200;
|
|
94
|
+
readonly height: 700;
|
|
95
|
+
readonly safeArea: {
|
|
96
|
+
readonly top: 0.14;
|
|
97
|
+
readonly right: 0.12;
|
|
98
|
+
readonly bottom: 0.14;
|
|
99
|
+
readonly left: 0.22;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
readonly blueskyCover: {
|
|
103
|
+
readonly name: "bluesky-cover";
|
|
104
|
+
readonly width: 3000;
|
|
105
|
+
readonly height: 1000;
|
|
106
|
+
readonly safeArea: {
|
|
107
|
+
readonly top: 0.15;
|
|
108
|
+
readonly right: 0.1;
|
|
109
|
+
readonly bottom: 0.15;
|
|
110
|
+
readonly left: 0.22;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
readonly youtubeCover: {
|
|
114
|
+
readonly name: "youtube-cover";
|
|
115
|
+
readonly width: 2560;
|
|
116
|
+
readonly height: 1440;
|
|
117
|
+
readonly safeArea: {
|
|
118
|
+
readonly top: number;
|
|
119
|
+
readonly right: number;
|
|
120
|
+
readonly bottom: number;
|
|
121
|
+
readonly left: number;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
57
124
|
};
|
|
58
125
|
/**
|
|
59
126
|
* Default output sizes: the Open Graph landscape plus a square. Between them
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,YAAY,EACZ,UAAU,EACX,MAAM,aAAa,CAAC;AAErB;;;;;;;;;GASG;AACH,eAAO,MAAM,+BAA+B,IAAI,CAAC;AAEjD;;GAEG;AACH,eAAO,MAAM,qBAAqB,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,YAAY,EACZ,UAAU,EACX,MAAM,aAAa,CAAC;AAErB;;;;;;;;;GASG;AACH,eAAO,MAAM,+BAA+B,IAAI,CAAC;AAEjD;;GAEG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G;qBAAE,MAAM,EAAE,IAAI;qBAAE,IAAI,EAAE,IAAI;;;;iBAG3D,IAAI,EAAE,eAAe;iBACrB,KAAK,EAAE,IAAI;iBACX,MAAM,EAAE,IAAI;iBACZ,QAAQ;qBACN,GAAG;qBACH,KAAK;qBACL,MAAM;qBACN,IAAI;;;CAGqC,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,UAAU,EAG9C,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,6DAC0B,CAAC;AAE3D;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,YAAoB,CAAC;AAElD;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC;;;;;GAKG;AACH,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC;;;;;GAKG;AACH,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B,wEAAwE;AACxE,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAKhD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,8FACkD,CAAC;AAExF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,SAAS,CAalD,CAAC"}
|
package/dist/config/defaults.js
CHANGED
|
@@ -13,18 +13,42 @@ export const DEFAULT_THUMBNAIL_TEXTURE_SCALE = 3;
|
|
|
13
13
|
* The texture scale everything else is drawn at, which is to say, unchanged.
|
|
14
14
|
*/
|
|
15
15
|
export const DEFAULT_TEXTURE_SCALE = 1;
|
|
16
|
+
/**
|
|
17
|
+
* YouTube's safe area, as insets of the banner it is uploaded on.
|
|
18
|
+
*
|
|
19
|
+
* This is the one platform that publishes the figure rather than leaving it to
|
|
20
|
+
* be worked out: 1546x423 centred on a 2560x1440 upload, so the insets are
|
|
21
|
+
* `(2560 - 1546) / 2 / 2560` and `(1440 - 423) / 2 / 1440`. They are written
|
|
22
|
+
* out because the arithmetic is the evidence. The same fractions turn up as
|
|
23
|
+
* 1235x338 on the 2048x1152 minimum upload, which is what says a safe area
|
|
24
|
+
* belongs in fractions rather than pixels.
|
|
25
|
+
*/
|
|
26
|
+
const YOUTUBE_SAFE_X = (2560 - 1546) / 2 / 2560;
|
|
27
|
+
const YOUTUBE_SAFE_Y = (1440 - 423) / 2 / 1440;
|
|
16
28
|
/**
|
|
17
29
|
* Named output-size presets covering the common social-image standards. Each
|
|
18
30
|
* `name` becomes the filename suffix (e.g. `my-post-og.png`).
|
|
19
31
|
*
|
|
32
|
+
* The first group are share images, made once per post:
|
|
33
|
+
*
|
|
20
34
|
* - `og`: 1.91:1, the Open Graph standard (`og:image`). Facebook, LinkedIn,
|
|
21
35
|
* Slack, Discord, WhatsApp, Mastodon, and the usual `twitter:image` reuse.
|
|
22
36
|
* - `square`: 1:1, X/Twitter `summary` card and a universal fallback.
|
|
23
37
|
* - `twitter`: 2:1, X/Twitter `summary_large_image` card.
|
|
24
38
|
* - `pinterest`: 2:3 tall pin.
|
|
25
39
|
* - `thumbnail`: 16:9, the size YouTube asks video thumbnails to be uploaded
|
|
26
|
-
* at
|
|
27
|
-
*
|
|
40
|
+
* at, carrying a {@link SizeOverrides.textureScale} for the reason that
|
|
41
|
+
* field gives.
|
|
42
|
+
*
|
|
43
|
+
* The rest are profile covers, made once for a site rather than once per post,
|
|
44
|
+
* so `config.extra` is the usual way to declare one. Each carries the
|
|
45
|
+
* {@link SafeArea} for the platform it is named after, which is what keeps the
|
|
46
|
+
* text out of the avatar and out of whatever that platform crops. Where those
|
|
47
|
+
* numbers come from, and how much to trust each of them, is in
|
|
48
|
+
* `docs/configuration/cover-images`.
|
|
49
|
+
*
|
|
50
|
+
* None of the covers is in `DEFAULT_SIZES`: a cover is not something a build
|
|
51
|
+
* should start making for every post because the package was upgraded.
|
|
28
52
|
*/
|
|
29
53
|
export const SIZE_PRESETS = {
|
|
30
54
|
og: { name: "og", width: 1200, height: 630 },
|
|
@@ -37,6 +61,41 @@ export const SIZE_PRESETS = {
|
|
|
37
61
|
height: 720,
|
|
38
62
|
textureScale: DEFAULT_THUMBNAIL_TEXTURE_SCALE,
|
|
39
63
|
},
|
|
64
|
+
xCover: {
|
|
65
|
+
name: "x-cover",
|
|
66
|
+
width: 1500,
|
|
67
|
+
height: 500,
|
|
68
|
+
safeArea: { top: 0.12, right: 0.06, bottom: 0.12, left: 0.25 },
|
|
69
|
+
},
|
|
70
|
+
linkedinCover: {
|
|
71
|
+
name: "linkedin-cover",
|
|
72
|
+
width: 1584,
|
|
73
|
+
height: 396,
|
|
74
|
+
safeArea: { top: 0.1, right: 0.2, bottom: 0.1, left: 0.28 },
|
|
75
|
+
},
|
|
76
|
+
linkedinPageCover: {
|
|
77
|
+
name: "linkedin-page-cover",
|
|
78
|
+
width: 4200,
|
|
79
|
+
height: 700,
|
|
80
|
+
safeArea: { top: 0.14, right: 0.12, bottom: 0.14, left: 0.22 },
|
|
81
|
+
},
|
|
82
|
+
blueskyCover: {
|
|
83
|
+
name: "bluesky-cover",
|
|
84
|
+
width: 3000,
|
|
85
|
+
height: 1000,
|
|
86
|
+
safeArea: { top: 0.15, right: 0.1, bottom: 0.15, left: 0.22 },
|
|
87
|
+
},
|
|
88
|
+
youtubeCover: {
|
|
89
|
+
name: "youtube-cover",
|
|
90
|
+
width: 2560,
|
|
91
|
+
height: 1440,
|
|
92
|
+
safeArea: {
|
|
93
|
+
top: YOUTUBE_SAFE_Y,
|
|
94
|
+
right: YOUTUBE_SAFE_X,
|
|
95
|
+
bottom: YOUTUBE_SAFE_Y,
|
|
96
|
+
left: YOUTUBE_SAFE_X,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
40
99
|
};
|
|
41
100
|
/**
|
|
42
101
|
* Default output sizes: the Open Graph landscape plus a square. Between them
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/config/defaults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AAM,yBAAyB,GAAG,CAAC,CAAC;AAE3C;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAiB,KAAK,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAElC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAElC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAE/B,wEAAwE;AACxE,MAAM,CAAC,MAAM,cAAc,GAA0B;IACnD,KAAK,EAAE,SAAS;IAChB,SAAS,EAAE,SAAS;IACpB,SAAS,EAAE,SAAS;IACpB,UAAU,EAAE,SAAS;CACtB,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GACnC,qFAAqF,CAAC;AAExF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAwB;IACrD,KAAK,EAAE,aAAa;IACpB,UAAU,EAAE,wBAAwB;IACpC,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,CAAC;IACV,WAAW,EAAE,KAAK;IAClB,YAAY,EAAE,KAAK;IACnB,YAAY,EAAE,KAAK;IACnB,WAAW,EAAE,KAAK;IAClB,MAAM,EAAE,MAAM;IACd,YAAY,EAAE,CAAC;IACf,WAAW,EAAE,SAAS;IACtB,aAAa,EAAE,IAAI;CACpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EAErB,cAAc,EACf,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EAErB,cAAc,EACf,MAAM,aAAa,CAAC;AAerB,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,yBAAyB,EACzB,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,aAAa,EACb,YAAY,GACb,MAAM,eAAe,CAAC;AAcvB;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAAC;AACrE;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,qBAAqB,GAC7B,qBAAqB,CAAC;AAUzB;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,GAAE,cAAmB,GAAG,cAAc,CAwCxE"}
|
package/dist/config/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import { resolveTexture, resolveTextureScale } from "../texture/index.js";
|
|
|
9
9
|
import { validateConfig } from "../validate/index.js";
|
|
10
10
|
import { DEFAULT_FONT_FAMILY, DEFAULT_FORMAT } from "./defaults.js";
|
|
11
11
|
import { resolveMaxBytes, resolveQuality } from "./output.js";
|
|
12
|
+
import { resolveSafeArea } from "./safe-area.js";
|
|
12
13
|
import { defaultBackground, resolveBackground, resolveCode, resolveColors, resolveCompressionLevel, resolveSizes, shouldLoadSystemFonts, } from "./resolve.js";
|
|
13
14
|
export { DEFAULT_CODE_FONT_FAMILY, DEFAULT_CODE_STYLE, DEFAULT_COLORS, DEFAULT_COMPRESSION_LEVEL, DEFAULT_FONT_FAMILY, DEFAULT_FORMAT, DEFAULT_QUALITY, DEFAULT_SIZES, SIZE_PRESETS, } from "./defaults.js";
|
|
14
15
|
/**
|
|
@@ -50,6 +51,7 @@ export function resolveConfig(input = {}) {
|
|
|
50
51
|
background: resolveBackground(config.background) ?? defaultBackground(colors),
|
|
51
52
|
texture: resolveTexture(config.texture, colors),
|
|
52
53
|
textureScale: resolveTextureScale(config.textureScale),
|
|
54
|
+
safeArea: resolveSafeArea(config.safeArea),
|
|
53
55
|
fonts,
|
|
54
56
|
systemFonts: shouldLoadSystemFonts(config.systemFonts, fonts),
|
|
55
57
|
// A project that supplies one font should not have to name it twice.
|
package/dist/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,0DAA0D;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAO1E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,uBAAuB,EACvB,YAAY,EACZ,qBAAqB,GACtB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,yBAAyB,EACzB,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,aAAa,EACb,YAAY,GACb,MAAM,eAAe,CAAC;AAEvB;;;;GAIG;AACH,SAAS,aAAa,CAAC,OAAe;IACpC,4EAA4E;IAC5E,iCAAiC;IACjC,sCAAsC;IACtC,OAAO,CAAC,IAAI,CAAC,aAAa,OAAO,EAAE,CAAC,CAAC;AACvC,CAAC;AAeD;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,MAA2B;IACtD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KA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E,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC;QAC9B,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,aAAa;QAC5C,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC;QACjC,SAAS,EAAE,EAAE,GAAG,gBAAgB,EAAE,GAAG,MAAM,CAAC,SAAS,EAAE;QACvD,4EAA4E;QAC5E,uEAAuE;QACvE,wEAAwE;QACxE,uCAAuC;QACvC,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,iBAAiB;QAClD,gBAAgB,EAAE,uBAAuB,CAAC,MAAM,CAAC,gBAAgB,CAAC;QAClE,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,KAAK;QAClC,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,cAAc;QACvC,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC;QACvC,QAAQ,EAAE,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC;QAC1C,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,KAAK;KACjC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Rect } from "../layout/index.js";
|
|
2
|
+
import type { Dimensions, SafeArea } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* A safe area with every edge filled in.
|
|
5
|
+
*
|
|
6
|
+
* Opposing edges are checked together as well as separately, since two
|
|
7
|
+
* fractions that are each perfectly reasonable can still meet in the middle.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveSafeArea(safeArea: SafeArea | undefined): Required<SafeArea>;
|
|
10
|
+
/**
|
|
11
|
+
* The safe area as a rectangle of the image it applies to.
|
|
12
|
+
*
|
|
13
|
+
* Sides are fractions of the width and the top and bottom are fractions of the
|
|
14
|
+
* height, so that one safe area describes the same crop whatever proportions
|
|
15
|
+
* the image has. A safe area of nothing returns the whole image, which is what
|
|
16
|
+
* makes this free to apply unconditionally.
|
|
17
|
+
*
|
|
18
|
+
* Both edges are rounded and the size taken from the difference, rather than
|
|
19
|
+
* rounding the two insets and subtracting them. It is the same sum until an
|
|
20
|
+
* inset lands on a half: YouTube's is `(1440 - 423) / 2`, so rounding the
|
|
21
|
+
* insets sends 508.5 up at the top and again at the bottom and gives back a
|
|
22
|
+
* band 422 tall where the platform published 423. Rounding a position is
|
|
23
|
+
* asking where an edge goes, which is the question; rounding an inset twice
|
|
24
|
+
* asks it once too often.
|
|
25
|
+
*/
|
|
26
|
+
export declare function safeRect(dimensions: Dimensions, safeArea: Required<SafeArea>): Rect;
|
|
27
|
+
//# sourceMappingURL=safe-area.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-area.d.ts","sourceRoot":"","sources":["../../src/config/safe-area.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AA4CxD;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAC7B,QAAQ,CAAC,QAAQ,CAAC,CAgBpB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,QAAQ,CACtB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAC3B,IAAI,CAWN"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** An image with none of it cropped away, which is what most of them are. */
|
|
2
|
+
const wholeImage = {
|
|
3
|
+
top: 0,
|
|
4
|
+
right: 0,
|
|
5
|
+
bottom: 0,
|
|
6
|
+
left: 0,
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* One edge of a safe area, checked.
|
|
10
|
+
*
|
|
11
|
+
* The values are hand-written fractions and a percentage typed as one is the
|
|
12
|
+
* slip to expect: `left: 25` insets a 1500px header by 37500px, which collapses
|
|
13
|
+
* the content area to nothing and draws an image with no text on it. That is a
|
|
14
|
+
* mistake nobody spots by looking at the output, since an empty banner looks
|
|
15
|
+
* like a banner whose title the frontmatter forgot.
|
|
16
|
+
*/
|
|
17
|
+
function resolveEdge(value, edge) {
|
|
18
|
+
if (value === undefined) {
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
if (!Number.isFinite(value) || value < 0 || value >= 1) {
|
|
22
|
+
throw new Error(`Invalid safeArea.${edge} ${String(value)}; expected a fraction of the` +
|
|
23
|
+
` image from 0 (no inset) up to but not including 1.`);
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
/** Check that the two insets along one axis leave something between them. */
|
|
28
|
+
function assertAxis(start, end, edges) {
|
|
29
|
+
if (start + end >= 1) {
|
|
30
|
+
throw new Error(`Invalid safeArea: ${edges} inset by ${String(start)} and ${String(end)}` +
|
|
31
|
+
` leave no room between them.`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A safe area with every edge filled in.
|
|
36
|
+
*
|
|
37
|
+
* Opposing edges are checked together as well as separately, since two
|
|
38
|
+
* fractions that are each perfectly reasonable can still meet in the middle.
|
|
39
|
+
*/
|
|
40
|
+
export function resolveSafeArea(safeArea) {
|
|
41
|
+
if (safeArea === undefined) {
|
|
42
|
+
return wholeImage;
|
|
43
|
+
}
|
|
44
|
+
const resolved = {
|
|
45
|
+
top: resolveEdge(safeArea.top, "top"),
|
|
46
|
+
right: resolveEdge(safeArea.right, "right"),
|
|
47
|
+
bottom: resolveEdge(safeArea.bottom, "bottom"),
|
|
48
|
+
left: resolveEdge(safeArea.left, "left"),
|
|
49
|
+
};
|
|
50
|
+
assertAxis(resolved.top, resolved.bottom, "top and bottom");
|
|
51
|
+
assertAxis(resolved.left, resolved.right, "left and right");
|
|
52
|
+
return resolved;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The safe area as a rectangle of the image it applies to.
|
|
56
|
+
*
|
|
57
|
+
* Sides are fractions of the width and the top and bottom are fractions of the
|
|
58
|
+
* height, so that one safe area describes the same crop whatever proportions
|
|
59
|
+
* the image has. A safe area of nothing returns the whole image, which is what
|
|
60
|
+
* makes this free to apply unconditionally.
|
|
61
|
+
*
|
|
62
|
+
* Both edges are rounded and the size taken from the difference, rather than
|
|
63
|
+
* rounding the two insets and subtracting them. It is the same sum until an
|
|
64
|
+
* inset lands on a half: YouTube's is `(1440 - 423) / 2`, so rounding the
|
|
65
|
+
* insets sends 508.5 up at the top and again at the bottom and gives back a
|
|
66
|
+
* band 422 tall where the platform published 423. Rounding a position is
|
|
67
|
+
* asking where an edge goes, which is the question; rounding an inset twice
|
|
68
|
+
* asks it once too often.
|
|
69
|
+
*/
|
|
70
|
+
export function safeRect(dimensions, safeArea) {
|
|
71
|
+
const { width, height } = dimensions;
|
|
72
|
+
const x = Math.round(width * safeArea.left);
|
|
73
|
+
const y = Math.round(height * safeArea.top);
|
|
74
|
+
return {
|
|
75
|
+
x,
|
|
76
|
+
y,
|
|
77
|
+
width: Math.round(width * (1 - safeArea.right)) - x,
|
|
78
|
+
height: Math.round(height * (1 - safeArea.bottom)) - y,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=safe-area.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-area.js","sourceRoot":"","sources":["../../src/config/safe-area.ts"],"names":[],"mappings":"AAGA,6EAA6E;AAC7E,MAAM,UAAU,GAAuB;IACrC,GAAG,EAAE,CAAC;IACN,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAC;CACR,CAAC;AAEF;;;;;;;;GAQG;AACH,SAAS,WAAW,CAAC,KAAyB,EAAE,IAAY;IAC1D,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI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IAE5B,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;IACrC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;IAE5C,OAAO;QACL,CAAC;QACD,CAAC;QACD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC;QACnD,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC;KACvD,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"size.d.ts","sourceRoot":"","sources":["../../src/config/size.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EACd,UAAU,EACV,cAAc,EAEf,MAAM,aAAa,CAAC;AAyBrB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,cAAc,GAAG,SAAS,EAClC,IAAI,EAAE,UAAU,GACf,cAAc,
|
|
1
|
+
{"version":3,"file":"size.d.ts","sourceRoot":"","sources":["../../src/config/size.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EACd,UAAU,EACV,cAAc,EAEf,MAAM,aAAa,CAAC;AAyBrB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,cAAc,GAAG,SAAS,EAClC,IAAI,EAAE,UAAU,GACf,cAAc,CAqBhB"}
|
package/dist/config/size.js
CHANGED
|
@@ -51,6 +51,7 @@ export function resolveConfigForSize(config, size) {
|
|
|
51
51
|
...(size.textureScale !== undefined && {
|
|
52
52
|
textureScale: size.textureScale,
|
|
53
53
|
}),
|
|
54
|
+
...(size.safeArea !== undefined && { safeArea: size.safeArea }),
|
|
54
55
|
...(size.code !== undefined && { code: { ...base.code, ...size.code } }),
|
|
55
56
|
...(size.background !== undefined && { background: size.background }),
|
|
56
57
|
...(size.fontFamily !== undefined && { fontFamily: size.fontFamily }),
|
package/dist/config/size.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"size.js","sourceRoot":"","sources":["../../src/config/size.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;;;;;;;GAWG;AACH,SAAS,WAAW,CAClB,IAA6B,EAC7B,KAA4B,EAC5B,SAA+B;IAE/B,OAAO,EAAE,GAAG,CAAC,IAAI,IAAI,YAAY,CAAC,KAAK,CAAC,IAAI,cAAc,CAAC,EAAE,GAAG,SAAS,EAAE,CAAC;AAC9E,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAkC,EAClC,IAAgB;IAEhB,MAAM,IAAI,GAAG,MAAM,IAAI,EAAE,CAAC;IAE1B,OAAO,aAAa,CAAC;QACnB,GAAG,IAAI;QACP,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;QACtD,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI;YAC/B,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC;SACxE,CAAC;QACF,GAAG,CAAC,IAAI,CAAC,OAAO,KAAK,SAA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AAK,SAAS,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QACzD,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;QACtD,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;KACpD,CAAC,CAAC;AACL,CAAC"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* honours. Importing this entry point from Node gets the Node halves and works
|
|
23
23
|
* as the root entry point does.
|
|
24
24
|
*/
|
|
25
|
-
export type { Background, Badge, BrandColors, CodeStyle, ColophonConfig, ContentOptions, Dimensions, FontSource, GradientStop, ImageSource, MeasureText, MetaImageProps, MeshBlob, OutputFormat, OutputSize, Rasteriser, RenderedMetaImage, ResolvedConfig, Template, TemplateContext, Texture, TextStyle, ThemeName, WarningHandler, } from "../types.js";
|
|
25
|
+
export type { Background, Badge, BrandColors, CodeStyle, ColophonConfig, ContentOptions, Dimensions, FontSource, GradientStop, ImageSource, MeasureText, MetaImageProps, MeshBlob, OutputFormat, OutputSize, Rasteriser, RenderedMetaImage, ResolvedConfig, SafeArea, Template, TemplateContext, Texture, TextStyle, ThemeName, WarningHandler, } from "../types.js";
|
|
26
26
|
export { DEFAULT_CODE_FONT_FAMILY, DEFAULT_CODE_STYLE, DEFAULT_COLORS, DEFAULT_FONT_FAMILY, DEFAULT_SIZES, defineConfig, resolveConfig, SIZE_PRESETS, } from "../config/index.js";
|
|
27
27
|
export { resolveConfigForSize } from "../config/size.js";
|
|
28
28
|
export { buildSvg } from "../render/svg.js";
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;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{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,YAAY,EACV,UAAU,EACV,KAAK,EACL,WAAW,EACX,SAAS,EACT,cAAc,EACd,cAAc,EACd,UAAU,EACV,UAAU,EACV,YAAY,EACZ,WAAW,EACX,WAAW,EACX,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,OAAO,EACP,SAAS,EACT,SAAS,EACT,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,YAAY,GACb,MAAM,uBAAuB,CAAC;AAK/B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAInD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EACL,MAAM,EACN,UAAU,EACV,aAAa,EACb,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EACL,cAAc,EACd,UAAU,EACV,WAAW,EACX,YAAY,EACZ,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAoDA,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,YAAY,GACb,MAAM,uBAAuB,CAAC;AAE/B,8EAA8E;AAC9E,4EAA4E;AAC5E,yEAAyE;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,4EAA4E;AAC5E,+EAA+E;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EACL,MAAM,EACN,UAAU,EACV,aAAa,EACb,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAE/B,+EAA+E;AAC/E,kEAAkE;AAClE,OAAO,EACL,cAAc,EACd,UAAU,EACV,WAAW,EACX,YAAY,EACZ,iBAAiB,GAClB,MAAM,kBAAkB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { Background, Badge, BrandColors, CodeStyle, ColophonConfig, ColophonConfigFactory, ColophonConfigInput, ContentFile, ContentOptions, Dimensions, ExtraImage, FontSource, GradientStop, Manifest, ManifestImage, ManifestPage, MeshBlob, MetaImageProps, MeasureText, MetaTag, MetaTagOptions, OutputFormat, OutputSize, Placement, PropsFromFrontmatter, Rasteriser, RenderedMetaImage, SlugStrategy, SizeOverrides, ResolvedConfig, Template, TemplateContext, Texture, TextStyle, ThemeName, WarningHandler, } from "./types.js";
|
|
1
|
+
export type { Background, Badge, BrandColors, CodeStyle, ColophonConfig, ColophonConfigFactory, ColophonConfigInput, ContentFile, ContentOptions, Dimensions, ExtraImage, FontSource, GradientStop, Manifest, ManifestImage, ManifestPage, MeshBlob, MetaImageProps, MeasureText, MetaTag, MetaTagOptions, OutputFormat, OutputSize, Placement, PropsFromFrontmatter, Rasteriser, RenderedMetaImage, SafeArea, SlugStrategy, SizeOverrides, ResolvedConfig, Template, TemplateContext, Texture, TextStyle, ThemeName, WarningHandler, } from "./types.js";
|
|
2
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
3
|
export { resolveConfigForSize } from "./config/size.js";
|
|
4
4
|
export { backgroundSvg } from "./background/index.js";
|
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,qBAAqB,EACrB,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,UAAU,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,QAAQ,EAC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iB,GAClB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC"}
|
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":"AAwCA,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,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,8EAA8E;AAC9E,qDAAqD;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,+EAA+E;AAC/E,0EAA0E;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,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,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG7E,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,EACL,wBAAwB,EACxB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAG5B,+EAA+E;AAC/E,+EAA+E;AAC/E,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EACL,cAAc,EACd,UAAU,EACV,WAAW,EACX,YAAY,EACZ,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -23,7 +23,7 @@ export const articleTemplate = {
|
|
|
23
23
|
footer: said.length > 0,
|
|
24
24
|
});
|
|
25
25
|
const { pad } = frame;
|
|
26
|
-
const mark = logoRect(logo,
|
|
26
|
+
const mark = logoRect(logo, frame.full, pad, "start");
|
|
27
27
|
const chips = tagBand(props, config, dimensions, pad, markRoom(mark?.width, pad), measure);
|
|
28
28
|
const topMark = Math.max(chips.height, mark?.height ?? 0);
|
|
29
29
|
const area = contentArea(frame, markRoom(topMark, Math.round(height * 0.035)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/article/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBA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B,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC;YACnC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC;YACxC,MAAM;SACP,CAAC,EACF,IAAI,EACJ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,CAC1D,CAAC;QAEF,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAE1E,OAAO,KAAK,CAAC,GAAG,GAAG,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,IAAI,GAAG,MAAM,CAAC;IAC7D,CAAC;CACF,CAAC"}
|
|
@@ -2,6 +2,13 @@ import type { Badge } from "../../types.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* The corner badge: a rounded plate with the badge text on it, sized from the
|
|
4
4
|
* plate height so it scales with the image rather than the text length.
|
|
5
|
+
*
|
|
6
|
+
* `corner` is where the plate's top-left goes, which the template works out
|
|
7
|
+
* from its frame rather than from the image, so that a safe area brings the
|
|
8
|
+
* badge in along with everything else.
|
|
5
9
|
*/
|
|
6
|
-
export declare function renderBadge(badge: Badge, fontFamily: string, brand: string,
|
|
10
|
+
export declare function renderBadge(badge: Badge, fontFamily: string, brand: string, corner: {
|
|
11
|
+
readonly x: number;
|
|
12
|
+
readonly y: number;
|
|
13
|
+
}, height: number): string;
|
|
7
14
|
//# sourceMappingURL=badge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../../../src/templates/banner/badge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C
|
|
1
|
+
{"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../../../src/templates/banner/badge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE;IAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAClD,MAAM,EAAE,MAAM,GACb,MAAM,CAoBR"}
|
|
@@ -2,15 +2,19 @@ import { box, textElement } from "../../layout/index.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* The corner badge: a rounded plate with the badge text on it, sized from the
|
|
4
4
|
* plate height so it scales with the image rather than the text length.
|
|
5
|
+
*
|
|
6
|
+
* `corner` is where the plate's top-left goes, which the template works out
|
|
7
|
+
* from its frame rather than from the image, so that a safe area brings the
|
|
8
|
+
* badge in along with everything else.
|
|
5
9
|
*/
|
|
6
|
-
export function renderBadge(badge, fontFamily, brand,
|
|
10
|
+
export function renderBadge(badge, fontFamily, brand, corner, height) {
|
|
7
11
|
const fontSize = Math.round(height * 0.6);
|
|
8
12
|
const padX = Math.round(height * 0.36);
|
|
9
13
|
const width = Math.round(badge.text.length * fontSize * 0.64 + padX * 2);
|
|
10
|
-
const plate = box({ x:
|
|
14
|
+
const plate = box({ x: corner.x, y: corner.y, width, height }, { radius: Math.round(height * 0.1), fill: badge.background ?? "#ffffff" });
|
|
11
15
|
const text = textElement(badge.text, {
|
|
12
|
-
x:
|
|
13
|
-
y:
|
|
16
|
+
x: corner.x + padX,
|
|
17
|
+
y: corner.y + Math.round(height * 0.72),
|
|
14
18
|
fontFamily,
|
|
15
19
|
fontSize,
|
|
16
20
|
fontWeight: 900,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badge.js","sourceRoot":"","sources":["../../../src/templates/banner/badge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,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@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/banner/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAmB,MAAM,gBAAgB,CAAC;AAQhE;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/banner/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAmB,MAAM,gBAAgB,CAAC;AAQhE;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,EAAE,QA+D5B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { drawLines
|
|
1
|
+
import { drawLines } from "../../layout/index.js";
|
|
2
2
|
import { optionalString } from "../../props.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { footerLine } from "../bottom.js";
|
|
4
|
+
import { contentArea, imageFrame, markRoom } from "../frame.js";
|
|
5
5
|
import { logoElement, logoRect } from "../logo.js";
|
|
6
6
|
import { badgeFor } from "./badge-props.js";
|
|
7
7
|
import { renderBadge } from "./badge.js";
|
|
@@ -18,27 +18,19 @@ import { bannerLines } from "./lines.js";
|
|
|
18
18
|
export const bannerTemplate = {
|
|
19
19
|
name: "banner",
|
|
20
20
|
render({ props, config, dimensions, measure, logo, avatar, }) {
|
|
21
|
-
const {
|
|
21
|
+
const { height } = dimensions;
|
|
22
22
|
const { fontFamily } = config;
|
|
23
|
-
const
|
|
24
|
-
const
|
|
23
|
+
const frame = imageFrame(dimensions, config, avatar);
|
|
24
|
+
const { pad, full } = frame;
|
|
25
25
|
const badgeHeight = Math.round(height * 0.072);
|
|
26
|
-
const mark = logoRect(logo,
|
|
26
|
+
const mark = logoRect(logo, full, pad, "start");
|
|
27
27
|
const badge = badgeFor(props, config);
|
|
28
28
|
const subtitle = optionalString(props.subtitle);
|
|
29
29
|
const hasSubtitle = subtitle !== undefined && subtitle !== "";
|
|
30
30
|
// The text sits between whatever the marks along the top and the footer
|
|
31
31
|
// along the bottom leave behind.
|
|
32
32
|
const topMark = Math.max(badge === undefined ? 0 : badgeHeight, mark?.height ?? 0);
|
|
33
|
-
const area =
|
|
34
|
-
top: pad + (topMark === 0 ? 0 : topMark + Math.round(height * 0.03)),
|
|
35
|
-
right: pad,
|
|
36
|
-
left: pad,
|
|
37
|
-
bottom: pad +
|
|
38
|
-
(hasFooter(config) || avatar !== undefined
|
|
39
|
-
? footerFs + Math.round(height * 0.02)
|
|
40
|
-
: 0),
|
|
41
|
-
});
|
|
33
|
+
const area = contentArea(frame, markRoom(topMark, Math.round(height * 0.03)));
|
|
42
34
|
const lines = bannerLines(props, {
|
|
43
35
|
height,
|
|
44
36
|
contentWidth: area.width,
|
|
@@ -55,15 +47,8 @@ export const bannerTemplate = {
|
|
|
55
47
|
});
|
|
56
48
|
const badgeMark = badge === undefined
|
|
57
49
|
? ""
|
|
58
|
-
: renderBadge(badge, fontFamily, config.colors.brand, pad, badgeHeight);
|
|
59
|
-
const footer =
|
|
60
|
-
x: pad,
|
|
61
|
-
y: footerBaseline(height, pad, footerFs),
|
|
62
|
-
fontSize: footerFs,
|
|
63
|
-
opacity: 0.78,
|
|
64
|
-
left: pad,
|
|
65
|
-
width: width - pad * 2,
|
|
66
|
-
}, avatar, measure);
|
|
50
|
+
: renderBadge(badge, fontFamily, config.colors.brand, { x: full.x + pad, y: full.y + pad }, badgeHeight);
|
|
51
|
+
const footer = footerLine(config, frame, avatar, measure, "start", 0.78);
|
|
67
52
|
return badgeMark + logoElement(logo, mark) + body + footer;
|
|
68
53
|
},
|
|
69
54
|
};
|