@kensio/colophon 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +198 -0
  3. package/dist/background.d.ts +8 -0
  4. package/dist/background.d.ts.map +1 -0
  5. package/dist/background.js +22 -0
  6. package/dist/background.js.map +1 -0
  7. package/dist/cli.d.ts +3 -0
  8. package/dist/cli.d.ts.map +1 -0
  9. package/dist/cli.js +74 -0
  10. package/dist/cli.js.map +1 -0
  11. package/dist/config.d.ts +17 -0
  12. package/dist/config.d.ts.map +1 -0
  13. package/dist/config.js +64 -0
  14. package/dist/config.js.map +1 -0
  15. package/dist/content/index.d.ts +39 -0
  16. package/dist/content/index.d.ts.map +1 -0
  17. package/dist/content/index.js +99 -0
  18. package/dist/content/index.js.map +1 -0
  19. package/dist/generate.d.ts +42 -0
  20. package/dist/generate.d.ts.map +1 -0
  21. package/dist/generate.js +56 -0
  22. package/dist/generate.js.map +1 -0
  23. package/dist/index.d.ts +11 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +8 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/render.d.ts +17 -0
  28. package/dist/render.d.ts.map +1 -0
  29. package/dist/render.js +52 -0
  30. package/dist/render.js.map +1 -0
  31. package/dist/templates/banner.d.ts +9 -0
  32. package/dist/templates/banner.d.ts.map +1 -0
  33. package/dist/templates/banner.js +125 -0
  34. package/dist/templates/banner.js.map +1 -0
  35. package/dist/templates/card.d.ts +7 -0
  36. package/dist/templates/card.d.ts.map +1 -0
  37. package/dist/templates/card.js +82 -0
  38. package/dist/templates/card.js.map +1 -0
  39. package/dist/templates/index.d.ts +9 -0
  40. package/dist/templates/index.d.ts.map +1 -0
  41. package/dist/templates/index.js +13 -0
  42. package/dist/templates/index.js.map +1 -0
  43. package/dist/text.d.ts +56 -0
  44. package/dist/text.d.ts.map +1 -0
  45. package/dist/text.js +78 -0
  46. package/dist/text.js.map +1 -0
  47. package/dist/types.d.ts +129 -0
  48. package/dist/types.d.ts.map +1 -0
  49. package/dist/types.js +2 -0
  50. package/dist/types.js.map +1 -0
  51. package/package.json +87 -0
package/dist/text.d.ts ADDED
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Escape a string for safe inclusion in SVG/XML text content or attributes.
3
+ */
4
+ export declare function escapeXml(value: string): string;
5
+ /**
6
+ * Naive greedy word-wrap by character count. Words longer than the limit are
7
+ * kept intact on their own line rather than being split.
8
+ */
9
+ export declare function wrapText(text: string, charactersPerLine: number): string[];
10
+ /**
11
+ * Estimate how many characters of the given font size fit within `widthPx`.
12
+ * The `widthFactor` approximates average glyph width as a fraction of the font
13
+ * size (bolder/wider faces want a larger factor).
14
+ */
15
+ export declare function estimateCharsPerLine(widthPx: number, fontSize: number, widthFactor?: number): number;
16
+ /**
17
+ * A single line to place in a vertical stack.
18
+ */
19
+ export interface StackLine {
20
+ readonly fontSize: number;
21
+ /** Multiplier applied to `fontSize` for this line's total advance. */
22
+ readonly lineHeight?: number;
23
+ /** Extra space, in pixels, inserted before this line. Defaults to `0`. */
24
+ readonly gapBefore?: number;
25
+ }
26
+ /**
27
+ * A stack line with its computed text baseline `y` coordinate.
28
+ */
29
+ export interface PlacedLine {
30
+ readonly y: number;
31
+ readonly index: number;
32
+ }
33
+ /**
34
+ * Vertically centre a stack of lines within `[top, bottom]` and return the
35
+ * text baseline for each. The block is centred as a whole; if it is taller
36
+ * than the available area it simply starts at `top`.
37
+ */
38
+ export declare function layoutStack(lines: readonly StackLine[], top: number, bottom: number): PlacedLine[];
39
+ /**
40
+ * Attributes accepted by {@link textElement}. Colour and opacity are optional.
41
+ */
42
+ export interface TextAttributes {
43
+ readonly x: number;
44
+ readonly y: number;
45
+ readonly fontFamily: string;
46
+ readonly fontSize: number;
47
+ readonly fontWeight: number;
48
+ readonly fill: string;
49
+ readonly fillOpacity?: number;
50
+ readonly anchor?: "start" | "middle" | "end";
51
+ }
52
+ /**
53
+ * Build a single `<text>` element. The content is XML-escaped.
54
+ */
55
+ export declare function textElement(content: string, attributes: TextAttributes): string;
56
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO/C;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,MAAM,EAAE,CAsB1E;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,WAAW,SAAO,GACjB,MAAM,CAER;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,sEAAsE;IACtE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,GACb,UAAU,EAAE,CAed;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;CAC9C;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,cAAc,GACzB,MAAM,CAkBR"}
package/dist/text.js ADDED
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Escape a string for safe inclusion in SVG/XML text content or attributes.
3
+ */
4
+ export function escapeXml(value) {
5
+ return value
6
+ .replaceAll("&", "&amp;")
7
+ .replaceAll("<", "&lt;")
8
+ .replaceAll(">", "&gt;")
9
+ .replaceAll('"', "&quot;")
10
+ .replaceAll("'", "&apos;");
11
+ }
12
+ /**
13
+ * Naive greedy word-wrap by character count. Words longer than the limit are
14
+ * kept intact on their own line rather than being split.
15
+ */
16
+ export function wrapText(text, charactersPerLine) {
17
+ const limit = Math.max(1, Math.floor(charactersPerLine));
18
+ const words = text.split(/\s+/).filter((word) => word !== "");
19
+ const lines = [];
20
+ let currentLine = "";
21
+ for (const word of words) {
22
+ const nextLine = currentLine === "" ? word : `${currentLine} ${word}`;
23
+ if (nextLine.length > limit && currentLine !== "") {
24
+ lines.push(currentLine);
25
+ currentLine = word;
26
+ }
27
+ else {
28
+ currentLine = nextLine;
29
+ }
30
+ }
31
+ if (currentLine !== "") {
32
+ lines.push(currentLine);
33
+ }
34
+ return lines;
35
+ }
36
+ /**
37
+ * Estimate how many characters of the given font size fit within `widthPx`.
38
+ * The `widthFactor` approximates average glyph width as a fraction of the font
39
+ * size (bolder/wider faces want a larger factor).
40
+ */
41
+ export function estimateCharsPerLine(widthPx, fontSize, widthFactor = 0.58) {
42
+ return Math.max(1, Math.floor(widthPx / (fontSize * widthFactor)));
43
+ }
44
+ /**
45
+ * Vertically centre a stack of lines within `[top, bottom]` and return the
46
+ * text baseline for each. The block is centred as a whole; if it is taller
47
+ * than the available area it simply starts at `top`.
48
+ */
49
+ export function layoutStack(lines, top, bottom) {
50
+ const advances = lines.map((line) => (line.gapBefore ?? 0) + line.fontSize * (line.lineHeight ?? 1.2));
51
+ const total = advances.reduce((sum, advance) => sum + advance, 0);
52
+ let cursor = top + Math.max(0, (bottom - top - total) / 2);
53
+ return lines.map((line, index) => {
54
+ // Approximate the ascent as 80% of the font size to sit the baseline
55
+ // sensibly within each line's advance box, after any leading gap.
56
+ const baseline = cursor + (line.gapBefore ?? 0) + line.fontSize * 0.8;
57
+ cursor += advances[index] ?? 0;
58
+ return { y: Math.round(baseline), index };
59
+ });
60
+ }
61
+ /**
62
+ * Build a single `<text>` element. The content is XML-escaped.
63
+ */
64
+ export function textElement(content, attributes) {
65
+ const opacity = attributes.fillOpacity === undefined
66
+ ? ""
67
+ : ` fill-opacity="${String(attributes.fillOpacity)}"`;
68
+ const anchor = attributes.anchor === undefined
69
+ ? ""
70
+ : ` text-anchor="${attributes.anchor}"`;
71
+ return (`<text x="${String(attributes.x)}" y="${String(attributes.y)}"` +
72
+ ` font-family="${escapeXml(attributes.fontFamily)}"` +
73
+ ` font-size="${String(attributes.fontSize)}"` +
74
+ ` font-weight="${String(attributes.fontWeight)}"` +
75
+ ` fill="${attributes.fill}"${opacity}${anchor}>` +
76
+ `${escapeXml(content)}</text>`);
77
+ }
78
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.js","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,OAAO,KAAK;SACT,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;SACxB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;SACvB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;SACvB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC;SACzB,UAAU,CAAC,GAAG,EAAE,QAAQ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AC,CAAC,iBAAiB,UAAU,CAAC,MAAM,GAAG,CAAC;IAE5C,OAAO,CACL,YAAY,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG;QAC/D,iBAAiB,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG;QACpD,eAAe,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG;QAC7C,iBAAiB,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG;QACjD,UAAU,UAAU,CAAC,IAAI,IAAI,OAAO,GAAG,MAAM,GAAG;QAChD,GAAG,SAAS,CAAC,OAAO,CAAC,SAAS,CAC/B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Pixel dimensions for a single rendered image.
3
+ */
4
+ export interface Dimensions {
5
+ readonly width: number;
6
+ readonly height: number;
7
+ }
8
+ /**
9
+ * A single colour stop in a gradient background.
10
+ */
11
+ export interface GradientStop {
12
+ /** Offset along the gradient, e.g. `"0%"` or `"55%"`. */
13
+ readonly offset: string;
14
+ readonly color: string;
15
+ }
16
+ /**
17
+ * Background fill for an image: a flat colour or a linear gradient.
18
+ *
19
+ * Gradient coordinates use SVG object-bounding-box units (0–1); the default
20
+ * runs diagonally from the top-left `(0, 0)` to the bottom-right `(1, 1)`.
21
+ */
22
+ export type Background = {
23
+ readonly type: "solid";
24
+ readonly color: string;
25
+ } | {
26
+ readonly type: "gradient";
27
+ readonly stops: readonly GradientStop[];
28
+ readonly from?: {
29
+ readonly x: number;
30
+ readonly y: number;
31
+ };
32
+ readonly to?: {
33
+ readonly x: number;
34
+ readonly y: number;
35
+ };
36
+ };
37
+ /**
38
+ * Brand colours used to derive the default gradient and text colour. All are
39
+ * configurable per project — nothing here is tied to a specific site.
40
+ */
41
+ export interface BrandColors {
42
+ readonly brand: string;
43
+ /** Darker shade used at the start of the default gradient. */
44
+ readonly brandDark?: string;
45
+ /** Warmer shade used at the end of the default gradient. */
46
+ readonly brandWarm?: string;
47
+ /** Text/foreground colour. Defaults to white. */
48
+ readonly foreground?: string;
49
+ }
50
+ /**
51
+ * A small badge drawn in the corner of the `banner` template (e.g. an "npm"
52
+ * chip). Set to `null` in config to omit it.
53
+ */
54
+ export interface Badge {
55
+ readonly text: string;
56
+ /** Badge text colour. Defaults to the brand colour. */
57
+ readonly color?: string;
58
+ /** Badge background colour. Defaults to white. */
59
+ readonly background?: string;
60
+ }
61
+ /**
62
+ * Image properties, typically read from a post's frontmatter. The schema is
63
+ * intentionally open: templates read whatever fields they understand, so a
64
+ * project can pass arbitrary extra props through.
65
+ */
66
+ export interface MetaImageProps {
67
+ /** Name of the template to render with. */
68
+ readonly template: string;
69
+ readonly title: string;
70
+ readonly subtitle?: string;
71
+ readonly version?: string | number;
72
+ readonly [key: string]: unknown;
73
+ }
74
+ /**
75
+ * Everything a template needs to produce its SVG foreground content.
76
+ */
77
+ export interface TemplateContext {
78
+ readonly props: MetaImageProps;
79
+ readonly config: ResolvedConfig;
80
+ readonly dimensions: Dimensions;
81
+ }
82
+ /**
83
+ * A registered template. `render` returns the SVG *foreground* content (text,
84
+ * badges, etc.) for the given dimensions; the background and the enclosing
85
+ * `<svg>` root are added by the renderer.
86
+ */
87
+ export interface Template {
88
+ readonly name: string;
89
+ render(context: TemplateContext): string;
90
+ }
91
+ /**
92
+ * User-supplied configuration. Every field is optional; defaults are applied
93
+ * by `resolveConfig`.
94
+ */
95
+ export interface ColophonConfig {
96
+ readonly colors?: BrandColors;
97
+ /** Explicit background, overriding the gradient derived from `colors`. */
98
+ readonly background?: Background;
99
+ readonly fontFamily?: string;
100
+ /** Footer text drawn along the bottom edge. Omit (the default) for none. */
101
+ readonly footer?: string;
102
+ /** Corner badge for the `banner` template. Omit (the default) for none. */
103
+ readonly badge?: Badge;
104
+ /** Output sizes. Defaults to a 1:1 square plus a 1.91:1 landscape. */
105
+ readonly dimensions?: readonly Dimensions[];
106
+ /** Extra templates, merged over (and able to override) the built-ins. */
107
+ readonly templates?: Readonly<Record<string, Template>>;
108
+ }
109
+ /**
110
+ * Fully-resolved configuration with all defaults applied.
111
+ */
112
+ export interface ResolvedConfig {
113
+ readonly colors: Required<BrandColors>;
114
+ readonly background: Background;
115
+ readonly fontFamily: string;
116
+ readonly footer: string | undefined;
117
+ readonly badge: Badge | undefined;
118
+ readonly dimensions: readonly Dimensions[];
119
+ readonly templates: Readonly<Record<string, Template>>;
120
+ }
121
+ /**
122
+ * One rendered image: the source SVG plus the encoded PNG bytes.
123
+ */
124
+ export interface RenderedMetaImage {
125
+ readonly dimensions: Dimensions;
126
+ readonly svg: string;
127
+ readonly png: Buffer;
128
+ }
129
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,yDAAyD;IACzD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAClD;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IACxC,QAAQ,CAAC,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3D,QAAQ,CAAC,EAAE,CAAC,EAAE;QAAE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.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,87 @@
1
+ {
2
+ "name": "@kensio/colophon",
3
+ "description": "Generate social meta images for posts from frontmatter",
4
+ "author": "Kensio Software",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/KensioSoftware/colophon"
8
+ },
9
+ "homepage": "https://github.com/KensioSoftware/colophon#readme",
10
+ "license": "Apache-2.0",
11
+ "version": "0.2.0",
12
+ "type": "module",
13
+ "main": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "bin": {
16
+ "colophon": "./dist/cli.js"
17
+ },
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js"
22
+ },
23
+ "./content": {
24
+ "types": "./dist/content/index.d.ts",
25
+ "import": "./dist/content/index.js"
26
+ },
27
+ "./package.json": "./package.json"
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "README.md",
32
+ "LICENSE"
33
+ ],
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "sideEffects": false,
38
+ "engines": {
39
+ "node": ">=22.0.0"
40
+ },
41
+ "keywords": [
42
+ "open-graph",
43
+ "og-image",
44
+ "social-image",
45
+ "meta-image",
46
+ "share-image",
47
+ "frontmatter",
48
+ "static-site",
49
+ "svg",
50
+ "sharp"
51
+ ],
52
+ "devDependencies": {
53
+ "@eslint/js": "^10.0.1",
54
+ "@kensio/smartass": "^1.33.0",
55
+ "@types/eslint-plugin-security": "^3.0.1",
56
+ "@types/node": "^25.9.5",
57
+ "@typescript/native": "npm:typescript@^7.0.2",
58
+ "@vitest/coverage-v8": "^4.1.10",
59
+ "@vitest/eslint-plugin": "^1.6.22",
60
+ "eslint": "^10.6.0",
61
+ "eslint-config-prettier": "^10.1.8",
62
+ "eslint-plugin-jsdoc": "^63.0.13",
63
+ "eslint-plugin-no-secrets": "^2.3.3",
64
+ "eslint-plugin-security": "^4.0.1",
65
+ "eslint-plugin-unicorn": "^67.0.0",
66
+ "globals": "^17.7.0",
67
+ "jiti": "^2.7.0",
68
+ "prettier": "^3.9.5",
69
+ "typescript": "npm:@typescript/typescript6@^6.0.2",
70
+ "typescript-eslint": "^8.63.0",
71
+ "vitest": "^4.1.10"
72
+ },
73
+ "dependencies": {
74
+ "gray-matter": "^4.0.3",
75
+ "sharp": "^0.34.4"
76
+ },
77
+ "scripts": {
78
+ "build": "tsc -p tsconfig.build.json",
79
+ "build:check": "tsc -p tsconfig.json --noEmit",
80
+ "fmt": "eslint --fix . && prettier --write .",
81
+ "lint": "eslint . && prettier --check .",
82
+ "test": "vitest run",
83
+ "test:coverage": "vitest run --coverage",
84
+ "samples": "pnpm build && node scripts/gen-samples.ts",
85
+ "check": "pnpm fmt && pnpm build:check && pnpm test:coverage"
86
+ }
87
+ }