@kensio/colophon 2.1.0 → 2.3.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 +608 -34
- package/dist/cli/args.d.ts +14 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +67 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/config.d.ts +12 -0
- package/dist/cli/config.d.ts.map +1 -0
- package/dist/cli/config.js +43 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +35 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli.js +34 -6
- package/dist/cli.js.map +1 -1
- package/dist/config/defaults.d.ts +64 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +64 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/index.d.ts +22 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +52 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/resolve.d.ts +24 -0
- package/dist/config/resolve.d.ts.map +1 -0
- package/dist/config/resolve.js +66 -0
- package/dist/config/resolve.js.map +1 -0
- package/dist/config/size.d.ts +20 -0
- package/dist/config/size.d.ts.map +1 -0
- package/dist/config/size.js +46 -0
- package/dist/config/size.js.map +1 -0
- package/dist/config.d.ts +33 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +94 -4
- package/dist/config.js.map +1 -1
- package/dist/content/index.d.ts +5 -51
- package/dist/content/index.d.ts.map +1 -1
- package/dist/content/index.js +3 -115
- package/dist/content/index.js.map +1 -1
- package/dist/content/props.d.ts +15 -0
- package/dist/content/props.d.ts.map +1 -0
- package/dist/content/props.js +71 -0
- package/dist/content/props.js.map +1 -0
- package/dist/content/slug.d.ts +23 -0
- package/dist/content/slug.d.ts.map +1 -0
- package/dist/content/slug.js +52 -0
- package/dist/content/slug.js.map +1 -0
- package/dist/content/walk.d.ts +17 -0
- package/dist/content/walk.d.ts.map +1 -0
- package/dist/content/walk.js +57 -0
- package/dist/content/walk.js.map +1 -0
- package/dist/fonts/index.d.ts +10 -0
- package/dist/fonts/index.d.ts.map +1 -0
- package/dist/fonts/index.js +11 -0
- package/dist/fonts/index.js.map +1 -0
- package/dist/fonts/materialise.d.ts +7 -0
- package/dist/fonts/materialise.d.ts.map +1 -0
- package/dist/fonts/materialise.js +47 -0
- package/dist/fonts/materialise.js.map +1 -0
- package/dist/fonts/resolve.d.ts +7 -0
- package/dist/fonts/resolve.d.ts.map +1 -0
- package/dist/fonts/resolve.js +50 -0
- package/dist/fonts/resolve.js.map +1 -0
- package/dist/fonts.d.ts +18 -0
- package/dist/fonts.d.ts.map +1 -0
- package/dist/fonts.js +102 -0
- package/dist/fonts.js.map +1 -0
- package/dist/generate/extra.d.ts +16 -0
- package/dist/generate/extra.d.ts.map +1 -0
- package/dist/generate/extra.js +60 -0
- package/dist/generate/extra.js.map +1 -0
- package/dist/generate/index.d.ts +19 -0
- package/dist/generate/index.d.ts.map +1 -0
- package/dist/generate/index.js +46 -0
- package/dist/generate/index.js.map +1 -0
- package/dist/generate/job.d.ts +35 -0
- package/dist/generate/job.d.ts.map +1 -0
- package/dist/generate/job.js +2 -0
- package/dist/generate/job.js.map +1 -0
- package/dist/generate/options.d.ts +56 -0
- package/dist/generate/options.d.ts.map +1 -0
- package/dist/generate/options.js +17 -0
- package/dist/generate/options.js.map +1 -0
- package/dist/generate/output-path.d.ts +12 -0
- package/dist/generate/output-path.d.ts.map +1 -0
- package/dist/generate/output-path.js +18 -0
- package/dist/generate/output-path.js.map +1 -0
- package/dist/generate/outputs.d.ts +28 -0
- package/dist/generate/outputs.d.ts.map +1 -0
- package/dist/generate/outputs.js +71 -0
- package/dist/generate/outputs.js.map +1 -0
- package/dist/generate/plan.d.ts +21 -0
- package/dist/generate/plan.d.ts.map +1 -0
- package/dist/generate/plan.js +72 -0
- package/dist/generate/plan.js.map +1 -0
- package/dist/generate/render-image.d.ts +11 -0
- package/dist/generate/render-image.d.ts.map +1 -0
- package/dist/generate/render-image.js +27 -0
- package/dist/generate/render-image.js.map +1 -0
- package/dist/generate.d.ts +27 -6
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +77 -15
- package/dist/generate.js.map +1 -1
- package/dist/highlight/color.d.ts +9 -0
- package/dist/highlight/color.d.ts.map +1 -0
- package/dist/highlight/color.js +15 -0
- package/dist/highlight/color.js.map +1 -0
- package/dist/highlight/grid.d.ts +14 -0
- package/dist/highlight/grid.d.ts.map +1 -0
- package/dist/highlight/grid.js +36 -0
- package/dist/highlight/grid.js.map +1 -0
- package/dist/highlight/index.d.ts +12 -0
- package/dist/highlight/index.d.ts.map +1 -0
- package/dist/highlight/index.js +31 -0
- package/dist/highlight/index.js.map +1 -0
- package/dist/highlight/language.d.ts +14 -0
- package/dist/highlight/language.d.ts.map +1 -0
- package/dist/highlight/language.js +42 -0
- package/dist/highlight/language.js.map +1 -0
- package/dist/highlight/normalise.d.ts +17 -0
- package/dist/highlight/normalise.d.ts.map +1 -0
- package/dist/highlight/normalise.js +37 -0
- package/dist/highlight/normalise.js.map +1 -0
- package/dist/highlight/types.d.ts +40 -0
- package/dist/highlight/types.d.ts.map +1 -0
- package/dist/highlight/types.js +2 -0
- package/dist/highlight/types.js.map +1 -0
- package/dist/highlight.d.ts +10 -0
- package/dist/highlight.d.ts.map +1 -1
- package/dist/highlight.js +25 -2
- package/dist/highlight.js.map +1 -1
- package/dist/index.d.ts +15 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/manifest/build.d.ts +14 -0
- package/dist/manifest/build.d.ts.map +1 -0
- package/dist/manifest/build.js +43 -0
- package/dist/manifest/build.js.map +1 -0
- package/dist/manifest/index.d.ts +27 -0
- package/dist/manifest/index.d.ts.map +1 -0
- package/dist/manifest/index.js +31 -0
- package/dist/manifest/index.js.map +1 -0
- package/dist/manifest/order.d.ts +12 -0
- package/dist/manifest/order.d.ts.map +1 -0
- package/dist/manifest/order.js +17 -0
- package/dist/manifest/order.js.map +1 -0
- package/dist/manifest/page.d.ts +24 -0
- package/dist/manifest/page.d.ts.map +1 -0
- package/dist/manifest/page.js +55 -0
- package/dist/manifest/page.js.map +1 -0
- package/dist/meta/html.d.ts +14 -0
- package/dist/meta/html.d.ts.map +1 -0
- package/dist/meta/html.js +24 -0
- package/dist/meta/html.js.map +1 -0
- package/dist/meta/index.d.ts +11 -0
- package/dist/meta/index.d.ts.map +1 -0
- package/dist/meta/index.js +11 -0
- package/dist/meta/index.js.map +1 -0
- package/dist/meta/tags.d.ts +21 -0
- package/dist/meta/tags.d.ts.map +1 -0
- package/dist/meta/tags.js +72 -0
- package/dist/meta/tags.js.map +1 -0
- package/dist/meta/url.d.ts +15 -0
- package/dist/meta/url.d.ts.map +1 -0
- package/dist/meta/url.js +34 -0
- package/dist/meta/url.js.map +1 -0
- package/dist/placement/check.d.ts +16 -0
- package/dist/placement/check.d.ts.map +1 -0
- package/dist/placement/check.js +40 -0
- package/dist/placement/check.js.map +1 -0
- package/dist/placement/index.d.ts +29 -0
- package/dist/placement/index.d.ts.map +1 -0
- package/dist/placement/index.js +61 -0
- package/dist/placement/index.js.map +1 -0
- package/dist/placement/relative.d.ts +31 -0
- package/dist/placement/relative.d.ts.map +1 -0
- package/dist/placement/relative.js +53 -0
- package/dist/placement/relative.js.map +1 -0
- package/dist/pool.d.ts +18 -0
- package/dist/pool.d.ts.map +1 -0
- package/dist/pool.js +56 -0
- package/dist/pool.js.map +1 -0
- package/dist/render/index.d.ts +10 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +27 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/png.d.ts +10 -0
- package/dist/render/png.d.ts.map +1 -0
- package/dist/render/png.js +30 -0
- package/dist/render/png.js.map +1 -0
- package/dist/render/svg.d.ts +10 -0
- package/dist/render/svg.d.ts.map +1 -0
- package/dist/render/svg.js +20 -0
- package/dist/render/svg.js.map +1 -0
- package/dist/render/template.d.ts +9 -0
- package/dist/render/template.d.ts.map +1 -0
- package/dist/render/template.js +17 -0
- package/dist/render/template.js.map +1 -0
- package/dist/render.d.ts +6 -2
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +31 -10
- package/dist/render.js.map +1 -1
- package/dist/stamp/chunk.d.ts +16 -0
- package/dist/stamp/chunk.d.ts.map +1 -0
- package/dist/stamp/chunk.js +46 -0
- package/dist/stamp/chunk.js.map +1 -0
- package/dist/stamp/config-digest.d.ts +11 -0
- package/dist/stamp/config-digest.d.ts.map +1 -0
- package/dist/stamp/config-digest.js +43 -0
- package/dist/stamp/config-digest.js.map +1 -0
- package/dist/stamp/digest.d.ts +8 -0
- package/dist/stamp/digest.d.ts.map +1 -0
- package/dist/stamp/digest.js +20 -0
- package/dist/stamp/digest.js.map +1 -0
- package/dist/stamp/index.d.ts +20 -0
- package/dist/stamp/index.d.ts.map +1 -0
- package/dist/stamp/index.js +40 -0
- package/dist/stamp/index.js.map +1 -0
- package/dist/stamp/read.d.ts +7 -0
- package/dist/stamp/read.d.ts.map +1 -0
- package/dist/stamp/read.js +62 -0
- package/dist/stamp/read.js.map +1 -0
- package/dist/stamp.d.ts +29 -0
- package/dist/stamp.d.ts.map +1 -0
- package/dist/stamp.js +198 -0
- package/dist/stamp.js.map +1 -0
- package/dist/templates/banner/badge.d.ts +7 -0
- package/dist/templates/banner/badge.d.ts.map +1 -0
- package/dist/templates/banner/badge.js +24 -0
- package/dist/templates/banner/badge.js.map +1 -0
- package/dist/templates/banner/index.d.ts +9 -0
- package/dist/templates/banner/index.d.ts.map +1 -0
- package/dist/templates/banner/index.js +66 -0
- package/dist/templates/banner/index.js.map +1 -0
- package/dist/templates/banner/lines.d.ts +27 -0
- package/dist/templates/banner/lines.d.ts.map +1 -0
- package/dist/templates/banner/lines.js +46 -0
- package/dist/templates/banner/lines.js.map +1 -0
- package/dist/templates/card/index.d.ts +7 -0
- package/dist/templates/card/index.d.ts.map +1 -0
- package/dist/templates/card/index.js +43 -0
- package/dist/templates/card/index.js.map +1 -0
- package/dist/templates/card/lines.d.ts +17 -0
- package/dist/templates/card/lines.d.ts.map +1 -0
- package/dist/templates/card/lines.js +32 -0
- package/dist/templates/card/lines.js.map +1 -0
- package/dist/templates/code/chrome.d.ts +9 -0
- package/dist/templates/code/chrome.d.ts.map +1 -0
- package/dist/templates/code/chrome.js +32 -0
- package/dist/templates/code/chrome.js.map +1 -0
- package/dist/templates/code/clip.d.ts +18 -0
- package/dist/templates/code/clip.d.ts.map +1 -0
- package/dist/templates/code/clip.js +44 -0
- package/dist/templates/code/clip.js.map +1 -0
- package/dist/templates/code/ellipsis.d.ts +3 -0
- package/dist/templates/code/ellipsis.d.ts.map +1 -0
- package/dist/templates/code/ellipsis.js +3 -0
- package/dist/templates/code/ellipsis.js.map +1 -0
- package/dist/templates/code/fit.d.ts +27 -0
- package/dist/templates/code/fit.d.ts.map +1 -0
- package/dist/templates/code/fit.js +59 -0
- package/dist/templates/code/fit.js.map +1 -0
- package/dist/templates/code/index.d.ts +12 -0
- package/dist/templates/code/index.d.ts.map +1 -0
- package/dist/templates/code/index.js +64 -0
- package/dist/templates/code/index.js.map +1 -0
- package/dist/templates/code/layout.d.ts +21 -0
- package/dist/templates/code/layout.d.ts.map +1 -0
- package/dist/templates/code/layout.js +21 -0
- package/dist/templates/code/layout.js.map +1 -0
- package/dist/templates/code/panel.d.ts +17 -0
- package/dist/templates/code/panel.d.ts.map +1 -0
- package/dist/templates/code/panel.js +20 -0
- package/dist/templates/code/panel.js.map +1 -0
- package/dist/templates/code/plate.d.ts +15 -0
- package/dist/templates/code/plate.d.ts.map +1 -0
- package/dist/templates/code/plate.js +32 -0
- package/dist/templates/code/plate.js.map +1 -0
- package/dist/templates/code/spans.d.ts +19 -0
- package/dist/templates/code/spans.d.ts.map +1 -0
- package/dist/templates/code/spans.js +36 -0
- package/dist/templates/code/spans.js.map +1 -0
- package/dist/templates/code/warn.d.ts +11 -0
- package/dist/templates/code/warn.d.ts.map +1 -0
- package/dist/templates/code/warn.js +24 -0
- package/dist/templates/code/warn.js.map +1 -0
- package/dist/templates/code.d.ts.map +1 -1
- package/dist/templates/code.js +101 -29
- package/dist/templates/code.js.map +1 -1
- package/dist/templates/footer.d.ts +21 -0
- package/dist/templates/footer.d.ts.map +1 -0
- package/dist/templates/footer.js +25 -0
- package/dist/templates/footer.js.map +1 -0
- package/dist/templates/index.d.ts +3 -3
- package/dist/templates/index.d.ts.map +1 -1
- package/dist/templates/index.js +6 -6
- package/dist/templates/index.js.map +1 -1
- package/dist/text/element.d.ts +18 -0
- package/dist/text/element.d.ts.map +1 -0
- package/dist/text/element.js +19 -0
- package/dist/text/element.js.map +1 -0
- package/dist/text/escape.d.ts +5 -0
- package/dist/text/escape.d.ts.map +1 -0
- package/dist/text/escape.js +12 -0
- package/dist/text/escape.js.map +1 -0
- package/dist/text/index.d.ts +7 -0
- package/dist/text/index.d.ts.map +1 -0
- package/dist/text/index.js +5 -0
- package/dist/text/index.js.map +1 -0
- package/dist/text/stack.d.ts +24 -0
- package/dist/text/stack.d.ts.map +1 -0
- package/dist/text/stack.js +18 -0
- package/dist/text/stack.js.map +1 -0
- package/dist/text/wrap.d.ts +12 -0
- package/dist/text/wrap.d.ts.map +1 -0
- package/dist/text/wrap.js +33 -0
- package/dist/text/wrap.js.map +1 -0
- package/dist/types.d.ts +345 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/validate/check.d.ts +13 -0
- package/dist/validate/check.d.ts.map +1 -0
- package/dist/validate/check.js +34 -0
- package/dist/validate/check.js.map +1 -0
- package/dist/validate/index.d.ts +15 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/dist/validate/index.js +41 -0
- package/dist/validate/index.js.map +1 -0
- package/dist/validate/keys.d.ts +58 -0
- package/dist/validate/keys.d.ts.map +1 -0
- package/dist/validate/keys.js +166 -0
- package/dist/validate/keys.js.map +1 -0
- package/dist/validate/overrides.d.ts +5 -0
- package/dist/validate/overrides.d.ts.map +1 -0
- package/dist/validate/overrides.js +43 -0
- package/dist/validate/overrides.js.map +1 -0
- package/dist/validate/placement.d.ts +10 -0
- package/dist/validate/placement.d.ts.map +1 -0
- package/dist/validate/placement.js +38 -0
- package/dist/validate/placement.js.map +1 -0
- package/dist/validate/sizes.d.ts +9 -0
- package/dist/validate/sizes.d.ts.map +1 -0
- package/dist/validate/sizes.js +27 -0
- package/dist/validate/sizes.js.map +1 -0
- package/dist/validate/suggest.d.ts +10 -0
- package/dist/validate/suggest.d.ts.map +1 -0
- package/dist/validate/suggest.js +55 -0
- package/dist/validate/suggest.js.map +1 -0
- package/dist/validate/values.d.ts +21 -0
- package/dist/validate/values.d.ts.map +1 -0
- package/dist/validate/values.js +57 -0
- package/dist/validate/values.js.map +1 -0
- package/dist/validate.d.ts +15 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +300 -0
- package/dist/validate.js.map +1 -0
- package/package.json +14 -7
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The parsed command line.
|
|
3
|
+
*/
|
|
4
|
+
export interface CliArgs {
|
|
5
|
+
readonly contentDir: string;
|
|
6
|
+
readonly configPath: string | undefined;
|
|
7
|
+
readonly overwrite: boolean;
|
|
8
|
+
readonly concurrency: number | undefined;
|
|
9
|
+
}
|
|
10
|
+
/** Help text for `--help`, and for a run that asks for nothing else. */
|
|
11
|
+
export declare const usage = "colophon \u2014 generate social meta images from frontmatter\n\nUsage:\n colophon [contentDir] [options]\n\nImages carry a stamp of the props, config and size they came from, so a rebuild\nrenders only the ones that have actually changed.\n\nOptions:\n -c, --config <path> Load a config module. Its default export is either a\n ColophonConfig or a function (async or not) returning\n one, for a config that has to compute something.\n -f, --force Re-render every image, ignoring the stamps\n -o, --overwrite Alias for --force\n --concurrency <n> How many images to render at once\n -h, --help Show this help\n\nDefaults:\n contentDir content\n --concurrency one per available CPU";
|
|
12
|
+
/** Read the command line into the options `generate` takes. */
|
|
13
|
+
export declare function parseCliArgs(argv: readonly string[]): CliArgs;
|
|
14
|
+
//# sourceMappingURL=args.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C;AAED,wEAAwE;AACxE,eAAO,MAAM,KAAK,sxBAmB4B,CAAC;AAwB/C,+DAA+D;AAC/D,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CA4B7D"}
|
package/dist/cli/args.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/** Help text for `--help`, and for a run that asks for nothing else. */
|
|
2
|
+
export const usage = `colophon — generate social meta images from frontmatter
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
colophon [contentDir] [options]
|
|
6
|
+
|
|
7
|
+
Images carry a stamp of the props, config and size they came from, so a rebuild
|
|
8
|
+
renders only the ones that have actually changed.
|
|
9
|
+
|
|
10
|
+
Options:
|
|
11
|
+
-c, --config <path> Load a config module. Its default export is either a
|
|
12
|
+
ColophonConfig or a function (async or not) returning
|
|
13
|
+
one, for a config that has to compute something.
|
|
14
|
+
-f, --force Re-render every image, ignoring the stamps
|
|
15
|
+
-o, --overwrite Alias for --force
|
|
16
|
+
--concurrency <n> How many images to render at once
|
|
17
|
+
-h, --help Show this help
|
|
18
|
+
|
|
19
|
+
Defaults:
|
|
20
|
+
contentDir content
|
|
21
|
+
--concurrency one per available CPU`;
|
|
22
|
+
/** `--overwrite` is kept as an alias so existing build scripts keep working. */
|
|
23
|
+
const forceFlags = new Set(["-f", "--force", "-o", "--overwrite"]);
|
|
24
|
+
/** Flags that take the next argument as their value. */
|
|
25
|
+
const valueFlags = new Set(["-c", "--config", "--concurrency"]);
|
|
26
|
+
/**
|
|
27
|
+
* A mistyped count would otherwise reach `generate` as `NaN` and be reported
|
|
28
|
+
* without naming the flag it came from, so it is rejected here instead.
|
|
29
|
+
*/
|
|
30
|
+
function parseConcurrency(value) {
|
|
31
|
+
const parsed = Number(value);
|
|
32
|
+
if (!Number.isSafeInteger(parsed) || parsed < 1) {
|
|
33
|
+
throw new Error(`Invalid value for --concurrency: "${value}"; expected a positive integer.`);
|
|
34
|
+
}
|
|
35
|
+
return parsed;
|
|
36
|
+
}
|
|
37
|
+
/** Read the command line into the options `generate` takes. */
|
|
38
|
+
export function parseCliArgs(argv) {
|
|
39
|
+
let contentDir = "content";
|
|
40
|
+
let configPath;
|
|
41
|
+
let shouldOverwrite = false;
|
|
42
|
+
let concurrency;
|
|
43
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
44
|
+
const arg = argv[index];
|
|
45
|
+
if (arg !== undefined && valueFlags.has(arg)) {
|
|
46
|
+
index += 1;
|
|
47
|
+
const value = argv[index];
|
|
48
|
+
if (value === undefined) {
|
|
49
|
+
throw new Error(`Missing value for ${arg}`);
|
|
50
|
+
}
|
|
51
|
+
if (arg === "--concurrency") {
|
|
52
|
+
concurrency = parseConcurrency(value);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
configPath = value;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if (arg !== undefined && forceFlags.has(arg)) {
|
|
59
|
+
shouldOverwrite = true;
|
|
60
|
+
}
|
|
61
|
+
else if (arg !== undefined && !arg.startsWith("-")) {
|
|
62
|
+
contentDir = arg;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return { contentDir, configPath, overwrite: shouldOverwrite, concurrency };
|
|
66
|
+
}
|
|
67
|
+
//#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,KAAK,CAAC,CAAC;YAC1B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,EAAE,CAAC,CAAC;YAC9C,CAAC;YACD,IAAI,GAAG,KAAK,eAAe,EAAE,CAAC;gBAC5B,WAAW,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;YACxC,CAAC;iBAAM,CAAC;gBACN,UAAU,GAAG,KAAK,CAAC;YACrB,CAAC;QACH,CAAC;aAAM,IAAI,GAAG,KAAK,SAAS,IAAI,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACpD,eAAe,GAAG,IAAI,CAAC;QACzB,CAAC;aAAM,IAAI,GAAG,KAAK,SAAS,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACrD,UAAU,GAAG,GAAG,CAAC;QACnB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC;AAC7E,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ColophonConfig } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Load the config module named by `--config`.
|
|
4
|
+
*
|
|
5
|
+
* The default export may be the config itself or a function returning one,
|
|
6
|
+
* possibly async. A config that has to compute something cannot be written as
|
|
7
|
+
* a literal, and without the function form such a project has to abandon the
|
|
8
|
+
* CLI and call `generate` from a script of its own — reimplementing the
|
|
9
|
+
* reporting the CLI already does along the way.
|
|
10
|
+
*/
|
|
11
|
+
export declare function loadConfig(configPath: string | undefined): Promise<ColophonConfig | undefined>;
|
|
12
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/cli/config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,aAAa,CAAC;AAwBvE;;;;;;;;GAQG;AACH,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAiBrC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
/**
|
|
4
|
+
* A module that exports nothing usable is a mistake rather than a config that
|
|
5
|
+
* happens to be empty: the run named the file on the command line, so falling
|
|
6
|
+
* back to the defaults would render a whole tree with none of what it asked
|
|
7
|
+
* for and say nothing about it.
|
|
8
|
+
*
|
|
9
|
+
* An array is rejected for that reason and not for its own: `validateConfig`
|
|
10
|
+
* reads the keys of what it is given, and an empty one has none, so it is the
|
|
11
|
+
* one non-config that would otherwise pass as an empty config.
|
|
12
|
+
*/
|
|
13
|
+
function assertConfig(value, source) {
|
|
14
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
15
|
+
throw new Error(`${source} is not a config object.` +
|
|
16
|
+
` Export a ColophonConfig, or a function returning one.`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Load the config module named by `--config`.
|
|
21
|
+
*
|
|
22
|
+
* The default export may be the config itself or a function returning one,
|
|
23
|
+
* possibly async. A config that has to compute something cannot be written as
|
|
24
|
+
* a literal, and without the function form such a project has to abandon the
|
|
25
|
+
* CLI and call `generate` from a script of its own — reimplementing the
|
|
26
|
+
* reporting the CLI already does along the way.
|
|
27
|
+
*/
|
|
28
|
+
export async function loadConfig(configPath) {
|
|
29
|
+
if (configPath === undefined) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
const url = pathToFileURL(path.resolve(configPath)).href;
|
|
33
|
+
const module = (await import(url));
|
|
34
|
+
const exported = module.default;
|
|
35
|
+
if (typeof exported === "function") {
|
|
36
|
+
const config = await exported();
|
|
37
|
+
assertConfig(config, `The function exported by ${configPath}`);
|
|
38
|
+
return config;
|
|
39
|
+
}
|
|
40
|
+
assertConfig(exported, `The default export of ${configPath}`);
|
|
41
|
+
return exported;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/cli/config.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC;;;;;;;;;GASG;AACH,SAAS,YAAY,CACnB,KAAc,EACd,MAAc;IAEd,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,0BAA0B;YACjC,wDAAwD,CAC3D,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,UAA8B;IAE9B,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;IACzD,MAAM,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,CAAsC,CAAC;IACxE,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC;IAEhC,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,MAAM,QAAQ,EAAE,CAAC;QAChC,YAAY,CAAC,MAAM,EAAE,4BAA4B,UAAU,EAAE,CAAC,CAAC;QAC/D,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,YAAY,CAAC,QAAQ,EAAE,yBAAyB,UAAU,EAAE,CAAC,CAAC;IAC9D,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { generate } from "../generate/index.js";
|
|
3
|
+
import { parseCliArgs, usage } from "./args.js";
|
|
4
|
+
import { loadConfig } from "./config.js";
|
|
5
|
+
async function main() {
|
|
6
|
+
const argv = process.argv.slice(2);
|
|
7
|
+
if (argv.includes("-h") || argv.includes("--help")) {
|
|
8
|
+
console.log(usage);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const args = parseCliArgs(argv);
|
|
12
|
+
const config = await loadConfig(args.configPath);
|
|
13
|
+
const results = await generate({
|
|
14
|
+
contentDir: args.contentDir,
|
|
15
|
+
overwrite: args.overwrite,
|
|
16
|
+
...(config !== undefined && { config }),
|
|
17
|
+
...(args.concurrency !== undefined && { concurrency: args.concurrency }),
|
|
18
|
+
onResult: (result) => {
|
|
19
|
+
// The URL is the half of a placement nothing else on the command line
|
|
20
|
+
// would show, and the quickest way to see a `urlBase` is wrong.
|
|
21
|
+
const served = result.url === undefined ? "" : ` -> ${result.url}`;
|
|
22
|
+
console.log(`${result.skipped ? "skip " : "wrote"} ${result.outputPath}${served}`);
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
const written = results.filter((result) => !result.skipped).length;
|
|
26
|
+
console.log(`Done: ${String(written)} written, ${String(results.length - written)} skipped.`);
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
await main();
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
33
|
+
process.exitCode = 1;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","s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,CACtE,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;IACnE,OAAO,CAAC,GAAG,CACT,SAAS,MAAM,CAAC,OAAO,CAAC,aAAa,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,WAAW,CACjF,CAAC;AACJ,CAAC;AAED,IAAI,CAAC;IACH,MAAM,IAAI,EAAE,CAAC;AACf,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACtE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -7,35 +7,62 @@ const usage = `colophon — generate social meta images from frontmatter
|
|
|
7
7
|
Usage:
|
|
8
8
|
colophon [contentDir] [options]
|
|
9
9
|
|
|
10
|
+
Images carry a stamp of the props, config and size they came from, so a rebuild
|
|
11
|
+
renders only the ones that have actually changed.
|
|
12
|
+
|
|
10
13
|
Options:
|
|
11
14
|
-c, --config <path> Load a config module (default export = ColophonConfig)
|
|
12
|
-
-
|
|
15
|
+
-f, --force Re-render every image, ignoring the stamps
|
|
16
|
+
-o, --overwrite Alias for --force
|
|
17
|
+
--concurrency <n> How many images to render at once
|
|
13
18
|
-h, --help Show this help
|
|
14
19
|
|
|
15
20
|
Defaults:
|
|
16
|
-
contentDir content
|
|
21
|
+
contentDir content
|
|
22
|
+
--concurrency one per available CPU`;
|
|
23
|
+
/** `--overwrite` is kept as an alias so existing build scripts keep working. */
|
|
24
|
+
const forceFlags = new Set(["-f", "--force", "-o", "--overwrite"]);
|
|
25
|
+
/** Flags that take the next argument as their value. */
|
|
26
|
+
const valueFlags = new Set(["-c", "--config", "--concurrency"]);
|
|
27
|
+
/**
|
|
28
|
+
* A mistyped count would otherwise reach `generate` as `NaN` and be reported
|
|
29
|
+
* without naming the flag it came from, so it is rejected here instead.
|
|
30
|
+
*/
|
|
31
|
+
function parseConcurrency(value) {
|
|
32
|
+
const parsed = Number(value);
|
|
33
|
+
if (!Number.isSafeInteger(parsed) || parsed < 1) {
|
|
34
|
+
throw new Error(`Invalid value for --concurrency: "${value}"; expected a positive integer.`);
|
|
35
|
+
}
|
|
36
|
+
return parsed;
|
|
37
|
+
}
|
|
17
38
|
function parseCliArgs(argv) {
|
|
18
39
|
let contentDir = "content";
|
|
19
40
|
let configPath;
|
|
20
41
|
let shouldOverwrite = false;
|
|
42
|
+
let concurrency;
|
|
21
43
|
for (let index = 0; index < argv.length; index += 1) {
|
|
22
44
|
const arg = argv[index];
|
|
23
|
-
if (arg
|
|
45
|
+
if (arg !== undefined && valueFlags.has(arg)) {
|
|
24
46
|
index += 1;
|
|
25
47
|
const value = argv[index];
|
|
26
48
|
if (value === undefined) {
|
|
27
49
|
throw new Error(`Missing value for ${arg}`);
|
|
28
50
|
}
|
|
29
|
-
|
|
51
|
+
if (arg === "--concurrency") {
|
|
52
|
+
concurrency = parseConcurrency(value);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
configPath = value;
|
|
56
|
+
}
|
|
30
57
|
}
|
|
31
|
-
else if (arg
|
|
58
|
+
else if (arg !== undefined && forceFlags.has(arg)) {
|
|
32
59
|
shouldOverwrite = true;
|
|
33
60
|
}
|
|
34
61
|
else if (arg !== undefined && !arg.startsWith("-")) {
|
|
35
62
|
contentDir = arg;
|
|
36
63
|
}
|
|
37
64
|
}
|
|
38
|
-
return { contentDir, configPath, overwrite: shouldOverwrite };
|
|
65
|
+
return { contentDir, configPath, overwrite: shouldOverwrite, concurrency };
|
|
39
66
|
}
|
|
40
67
|
async function loadConfig(configPath) {
|
|
41
68
|
if (configPath === undefined) {
|
|
@@ -57,6 +84,7 @@ async function main() {
|
|
|
57
84
|
contentDir: args.contentDir,
|
|
58
85
|
overwrite: args.overwrite,
|
|
59
86
|
...(config !== undefined && { config }),
|
|
87
|
+
...(args.concurrency !== undefined && { concurrency: args.concurrency }),
|
|
60
88
|
onResult: (result) => {
|
|
61
89
|
console.log(`${result.skipped ? "skip " : "wrote"} ${result.outputPath}`);
|
|
62
90
|
},
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAUzC,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;8CAiBgC,CAAC;AAE/C,gFAAgF;AAChF,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC;AAEnE,wDAAwD;AACxD,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC;AAEhE;;;GAGG;AACH,SAAS,gBAAgB,CAAC,KAAa;IACrC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE7B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,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,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;IACnE,OAAO,CAAC,GAAG,CACT,SAAS,MAAM,CAAC,OAAO,CAAC,aAAa,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,WAAW,CACjF,CAAC;AACJ,CAAC;AAED,IAAI,CAAC;IACH,MAAM,IAAI,EAAE,CAAC;AACf,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACtE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { BrandColors, CodeStyle, OutputSize } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Named output-size presets covering the common social-image standards. Each
|
|
4
|
+
* `name` becomes the filename suffix (e.g. `my-post-og.png`).
|
|
5
|
+
*
|
|
6
|
+
* - `og` — 1.91:1, the Open Graph standard (`og:image`): Facebook, LinkedIn,
|
|
7
|
+
* Slack, Discord, WhatsApp, Mastodon, and the usual `twitter:image` reuse.
|
|
8
|
+
* - `square` — 1:1, X/Twitter `summary` card and a universal fallback.
|
|
9
|
+
* - `twitter` — 2:1, X/Twitter `summary_large_image` card.
|
|
10
|
+
* - `pinterest` — 2:3 tall pin.
|
|
11
|
+
*/
|
|
12
|
+
export declare const SIZE_PRESETS: {
|
|
13
|
+
readonly og: {
|
|
14
|
+
readonly name: "og";
|
|
15
|
+
readonly width: 1200;
|
|
16
|
+
readonly height: 630;
|
|
17
|
+
};
|
|
18
|
+
readonly square: {
|
|
19
|
+
readonly name: "square";
|
|
20
|
+
readonly width: 1200;
|
|
21
|
+
readonly height: 1200;
|
|
22
|
+
};
|
|
23
|
+
readonly twitter: {
|
|
24
|
+
readonly name: "twitter";
|
|
25
|
+
readonly width: 1200;
|
|
26
|
+
readonly height: 600;
|
|
27
|
+
};
|
|
28
|
+
readonly pinterest: {
|
|
29
|
+
readonly name: "pinterest";
|
|
30
|
+
readonly width: 1000;
|
|
31
|
+
readonly height: 1500;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Default output sizes: the Open Graph landscape plus a square. Between them
|
|
36
|
+
* they satisfy `og:image` and both `twitter:image` card types.
|
|
37
|
+
*/
|
|
38
|
+
export declare const DEFAULT_SIZES: readonly OutputSize[];
|
|
39
|
+
/**
|
|
40
|
+
* Default font stack, used when no fonts are configured. It names families and
|
|
41
|
+
* hopes the machine has them, which is exactly what `config.fonts` exists to
|
|
42
|
+
* avoid: supply a font file and the output stops depending on the machine.
|
|
43
|
+
*/
|
|
44
|
+
export declare const DEFAULT_FONT_FAMILY = "Arial, Helvetica, sans-serif";
|
|
45
|
+
/** Neutral default palette, used when no `colors.brand` is supplied. */
|
|
46
|
+
export declare const DEFAULT_COLORS: Required<BrandColors>;
|
|
47
|
+
/**
|
|
48
|
+
* Default monospace stack for the `code` template. It ends in the generic
|
|
49
|
+
* `monospace` family so it always resolves to something, whatever fonts the
|
|
50
|
+
* machine running the build happens to have.
|
|
51
|
+
*/
|
|
52
|
+
export declare const DEFAULT_CODE_FONT_FAMILY = "\"JetBrains Mono\", \"Source Code Pro\", \"DejaVu Sans Mono\", Menlo, Consolas, monospace";
|
|
53
|
+
/**
|
|
54
|
+
* Default `code` template styling. `charWidthRatio` and `lineHeight` drive the
|
|
55
|
+
* monospace grid the snippet is laid out on; the font-size bounds are
|
|
56
|
+
* fractions of the image width so they hold at every output size.
|
|
57
|
+
*
|
|
58
|
+
* `minFontScale` of `0.025` is roughly 30px on a 1200px-wide image, which
|
|
59
|
+
* still reads when a feed shows that image at half size. A snippet too long to
|
|
60
|
+
* fit at that size is truncated rather than shrunk, so a long sample loses
|
|
61
|
+
* lines on the shorter landscape formats.
|
|
62
|
+
*/
|
|
63
|
+
export declare const DEFAULT_CODE_STYLE: Required<CodeStyle>;
|
|
64
|
+
//# sourceMappingURL=defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEtE;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY;;iBACjB,IAAI,EAAE,IAAI;iBAAE,KAAK,EAAE,IAAI;iBAAE,MAAM,EAAE,GAAG;;;iBAChC,IAAI,EAAE,QAAQ;iBAAE,KAAK,EAAE,IAAI;iBAAE,MAAM,EAAE,IAAI;;;iBACxC,IAAI,EAAE,SAAS;iBAAE,KAAK,EAAE,IAAI;iBAAE,MAAM,EAAE,GAAG;;;iBACvC,IAAI,EAAE,WAAW;iBAAE,KAAK,EAAE,IAAI;iBAAE,MAAM,EAAE,IAAI;;CACZ,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,UAAU,EAG9C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,iCAAiC,CAAC;AAElE,wEAAwE;AACxE,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAKhD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,8FACkD,CAAC;AAExF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,SAAS,CASlD,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Named output-size presets covering the common social-image standards. Each
|
|
3
|
+
* `name` becomes the filename suffix (e.g. `my-post-og.png`).
|
|
4
|
+
*
|
|
5
|
+
* - `og` — 1.91:1, the Open Graph standard (`og:image`): Facebook, LinkedIn,
|
|
6
|
+
* Slack, Discord, WhatsApp, Mastodon, and the usual `twitter:image` reuse.
|
|
7
|
+
* - `square` — 1:1, X/Twitter `summary` card and a universal fallback.
|
|
8
|
+
* - `twitter` — 2:1, X/Twitter `summary_large_image` card.
|
|
9
|
+
* - `pinterest` — 2:3 tall pin.
|
|
10
|
+
*/
|
|
11
|
+
export const SIZE_PRESETS = {
|
|
12
|
+
og: { name: "og", width: 1200, height: 630 },
|
|
13
|
+
square: { name: "square", width: 1200, height: 1200 },
|
|
14
|
+
twitter: { name: "twitter", width: 1200, height: 600 },
|
|
15
|
+
pinterest: { name: "pinterest", width: 1000, height: 1500 },
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Default output sizes: the Open Graph landscape plus a square. Between them
|
|
19
|
+
* they satisfy `og:image` and both `twitter:image` card types.
|
|
20
|
+
*/
|
|
21
|
+
export const DEFAULT_SIZES = [
|
|
22
|
+
SIZE_PRESETS.og,
|
|
23
|
+
SIZE_PRESETS.square,
|
|
24
|
+
];
|
|
25
|
+
/**
|
|
26
|
+
* Default font stack, used when no fonts are configured. It names families and
|
|
27
|
+
* hopes the machine has them, which is exactly what `config.fonts` exists to
|
|
28
|
+
* avoid: supply a font file and the output stops depending on the machine.
|
|
29
|
+
*/
|
|
30
|
+
export const DEFAULT_FONT_FAMILY = "Arial, Helvetica, sans-serif";
|
|
31
|
+
/** Neutral default palette, used when no `colors.brand` is supplied. */
|
|
32
|
+
export const DEFAULT_COLORS = {
|
|
33
|
+
brand: "#4f46e5",
|
|
34
|
+
brandDark: "#3730a3",
|
|
35
|
+
brandWarm: "#db2777",
|
|
36
|
+
foreground: "#ffffff",
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Default monospace stack for the `code` template. It ends in the generic
|
|
40
|
+
* `monospace` family so it always resolves to something, whatever fonts the
|
|
41
|
+
* machine running the build happens to have.
|
|
42
|
+
*/
|
|
43
|
+
export const DEFAULT_CODE_FONT_FAMILY = '"JetBrains Mono", "Source Code Pro", "DejaVu Sans Mono", Menlo, Consolas, monospace';
|
|
44
|
+
/**
|
|
45
|
+
* Default `code` template styling. `charWidthRatio` and `lineHeight` drive the
|
|
46
|
+
* monospace grid the snippet is laid out on; the font-size bounds are
|
|
47
|
+
* fractions of the image width so they hold at every output size.
|
|
48
|
+
*
|
|
49
|
+
* `minFontScale` of `0.025` is roughly 30px on a 1200px-wide image, which
|
|
50
|
+
* still reads when a feed shows that image at half size. A snippet too long to
|
|
51
|
+
* fit at that size is truncated rather than shrunk, so a long sample loses
|
|
52
|
+
* lines on the shorter landscape formats.
|
|
53
|
+
*/
|
|
54
|
+
export const DEFAULT_CODE_STYLE = {
|
|
55
|
+
theme: "github-dark",
|
|
56
|
+
fontFamily: DEFAULT_CODE_FONT_FAMILY,
|
|
57
|
+
charWidthRatio: 0.6,
|
|
58
|
+
lineHeight: 1.55,
|
|
59
|
+
tabSize: 2,
|
|
60
|
+
cornerScale: 0.025,
|
|
61
|
+
maxFontScale: 0.075,
|
|
62
|
+
minFontScale: 0.025,
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE;IAC5C,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IACrD,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE;IACtD,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;CACd,CAAC;AAEhD;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAA0B;IAClD,YAAY,CAAC,EAAE;IACf,YAAY,CAAC,MAAM;CACpB,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,8BAA8B,CAAC;AAElE,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;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAwB;IACrD,KAAK,EAAE,aAAa;IACpB,UAAU,EAAE,wBAAwB;IACpC,cAAc,EAAE,GAAG;IACnB,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,CAAC;IACV,WAAW,EAAE,KAAK;IAClB,YAAY,EAAE,KAAK;IACnB,YAAY,EAAE,KAAK;CACpB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ColophonConfig, ColophonConfigFactory, ResolvedConfig } from "../types.js";
|
|
2
|
+
export { DEFAULT_CODE_FONT_FAMILY, DEFAULT_CODE_STYLE, DEFAULT_COLORS, DEFAULT_FONT_FAMILY, DEFAULT_SIZES, SIZE_PRESETS, } from "./defaults.js";
|
|
3
|
+
/**
|
|
4
|
+
* Identity helper that returns its argument typed as {@link ColophonConfig}.
|
|
5
|
+
* Use it in a config module to get editor completion and type-checking.
|
|
6
|
+
*/
|
|
7
|
+
export declare function defineConfig(config: ColophonConfig): ColophonConfig;
|
|
8
|
+
/**
|
|
9
|
+
* Overload for a config module that computes its config rather than declaring
|
|
10
|
+
* it. The function is typed, not called: this is still just an identity
|
|
11
|
+
* helper, and whoever loads the module is the one who runs it.
|
|
12
|
+
*/
|
|
13
|
+
export declare function defineConfig(factory: ColophonConfigFactory): ColophonConfigFactory;
|
|
14
|
+
/**
|
|
15
|
+
* Apply defaults to a user config. Safe to call with no argument.
|
|
16
|
+
*
|
|
17
|
+
* Unknown options are rejected before anything is resolved, so a config
|
|
18
|
+
* written against a different version of the package is a build error rather
|
|
19
|
+
* than a set of images quietly rendered with the defaults.
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveConfig(config?: ColophonConfig): ResolvedConfig;
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EAErB,cAAc,EACf,MAAM,aAAa,CAAC;AAWrB,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,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,MAAM,GAAE,cAAmB,GAAG,cAAc,CAoBzE"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { resolveFonts } from "../fonts/index.js";
|
|
2
|
+
import { builtinTemplates } from "../templates/index.js";
|
|
3
|
+
import { validateConfig } from "../validate/index.js";
|
|
4
|
+
import { DEFAULT_FONT_FAMILY } from "./defaults.js";
|
|
5
|
+
import { defaultBackground, resolveCode, resolveColors, resolveSizes, shouldLoadSystemFonts, } from "./resolve.js";
|
|
6
|
+
export { DEFAULT_CODE_FONT_FAMILY, DEFAULT_CODE_STYLE, DEFAULT_COLORS, DEFAULT_FONT_FAMILY, DEFAULT_SIZES, SIZE_PRESETS, } from "./defaults.js";
|
|
7
|
+
/**
|
|
8
|
+
* Default warning handler. Colophon runs at build time, so a compromise the
|
|
9
|
+
* renderer had to make belongs in the build log by default — silence is opt-in
|
|
10
|
+
* via `config.onWarning`.
|
|
11
|
+
*/
|
|
12
|
+
function warnToConsole(message) {
|
|
13
|
+
// The console is the point: this is the default sink, replaced wholesale by
|
|
14
|
+
// a caller-supplied `onWarning`.
|
|
15
|
+
// eslint-disable-next-line no-console
|
|
16
|
+
console.warn(`colophon: ${message}`);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Implementation signature. Two overloads rather than one union parameter, so
|
|
20
|
+
* an object literal is still checked against {@link ColophonConfig} for
|
|
21
|
+
* misspelled keys before it ever reaches `validateConfig`.
|
|
22
|
+
*/
|
|
23
|
+
export function defineConfig(config) {
|
|
24
|
+
return config;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Apply defaults to a user config. Safe to call with no argument.
|
|
28
|
+
*
|
|
29
|
+
* Unknown options are rejected before anything is resolved, so a config
|
|
30
|
+
* written against a different version of the package is a build error rather
|
|
31
|
+
* than a set of images quietly rendered with the defaults.
|
|
32
|
+
*/
|
|
33
|
+
export function resolveConfig(config = {}) {
|
|
34
|
+
validateConfig(config);
|
|
35
|
+
const colors = resolveColors(config.colors);
|
|
36
|
+
const fonts = resolveFonts(config.fonts);
|
|
37
|
+
return {
|
|
38
|
+
colors,
|
|
39
|
+
background: config.background ?? defaultBackground(colors),
|
|
40
|
+
fonts,
|
|
41
|
+
systemFonts: shouldLoadSystemFonts(config.systemFonts, fonts),
|
|
42
|
+
// A project that supplies one font should not have to name it twice.
|
|
43
|
+
fontFamily: config.fontFamily ?? fonts[0]?.family ?? DEFAULT_FONT_FAMILY,
|
|
44
|
+
footer: config.footer,
|
|
45
|
+
badge: config.badge,
|
|
46
|
+
code: resolveCode(config.code),
|
|
47
|
+
onWarning: config.onWarning ?? warnToConsole,
|
|
48
|
+
sizes: resolveSizes(config.sizes),
|
|
49
|
+
templates: { ...builtinTemplates, ...config.templates },
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAOzD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,YAAY,EACZ,qBAAqB,GACtB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,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,MAAM,GAAmB,EAAE;IACvD,cAAc,CAAC,MAAM,CAAC,CAAC;IAEvB,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEzC,OAAO;QACL,MAAM;QACN,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,iBAAiB,CAAC,MAAM,CAAC;QAC1D,KAAK;QACL,WAAW,EAAE,qBAAqB,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC;QAC7D,qEAAqE;QACrE,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,mBAAmB;QACxE,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,IAAI,EAAE,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;KACxD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Background, BrandColors, CodeStyle, FontSource, OutputSize } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Fill in the palette a project did not name.
|
|
4
|
+
*
|
|
5
|
+
* When a project supplies only `brand`, use it for the whole gradient rather
|
|
6
|
+
* than mixing in the neutral defaults, which would clash.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveColors(colors: BrandColors | undefined): Required<BrandColors>;
|
|
9
|
+
/** The gradient a config with no background of its own is drawn on. */
|
|
10
|
+
export declare function defaultBackground(colors: Required<BrandColors>): Background;
|
|
11
|
+
/** Fill in the `code` styling a project did not name. */
|
|
12
|
+
export declare function resolveCode(code: CodeStyle | undefined): Required<CodeStyle>;
|
|
13
|
+
/**
|
|
14
|
+
* The sizes to render, rejecting a duplicate name: each size names a file, so
|
|
15
|
+
* two sizes sharing a name would have one overwrite the other.
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveSizes(sizes: readonly OutputSize[] | undefined): readonly OutputSize[];
|
|
18
|
+
/**
|
|
19
|
+
* Whether to load the machine's own fonts. Configured fonts are meant to make
|
|
20
|
+
* the output the same everywhere, so supplying any turns system fonts off
|
|
21
|
+
* unless the project asks for them back.
|
|
22
|
+
*/
|
|
23
|
+
export declare function shouldLoadSystemFonts(systemFonts: boolean | undefined, fonts: readonly FontSource[]): boolean;
|
|
24
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/config/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,SAAS,EACT,UAAU,EACV,UAAU,EACX,MAAM,aAAa,CAAC;AAOrB;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,QAAQ,CAAC,WAAW,CAAC,CAWvB;AAED,uEAAuE;AACvE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,UAAU,CAS3E;AAED,yDAAyD;AACzD,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,CAE5E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,SAAS,UAAU,EAAE,GAAG,SAAS,GACvC,SAAS,UAAU,EAAE,CAgBvB;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,OAAO,GAAG,SAAS,EAChC,KAAK,EAAE,SAAS,UAAU,EAAE,GAC3B,OAAO,CAaT"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { DEFAULT_CODE_STYLE, DEFAULT_COLORS, DEFAULT_SIZES, } from "./defaults.js";
|
|
2
|
+
/**
|
|
3
|
+
* Fill in the palette a project did not name.
|
|
4
|
+
*
|
|
5
|
+
* When a project supplies only `brand`, use it for the whole gradient rather
|
|
6
|
+
* than mixing in the neutral defaults, which would clash.
|
|
7
|
+
*/
|
|
8
|
+
export function resolveColors(colors) {
|
|
9
|
+
if (colors === undefined) {
|
|
10
|
+
return DEFAULT_COLORS;
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
brand: colors.brand,
|
|
14
|
+
brandDark: colors.brandDark ?? colors.brand,
|
|
15
|
+
brandWarm: colors.brandWarm ?? colors.brand,
|
|
16
|
+
foreground: colors.foreground ?? DEFAULT_COLORS.foreground,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** The gradient a config with no background of its own is drawn on. */
|
|
20
|
+
export function defaultBackground(colors) {
|
|
21
|
+
return {
|
|
22
|
+
type: "gradient",
|
|
23
|
+
stops: [
|
|
24
|
+
{ offset: "0%", color: colors.brandDark },
|
|
25
|
+
{ offset: "55%", color: colors.brand },
|
|
26
|
+
{ offset: "100%", color: colors.brandWarm },
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** Fill in the `code` styling a project did not name. */
|
|
31
|
+
export function resolveCode(code) {
|
|
32
|
+
return { ...DEFAULT_CODE_STYLE, ...code };
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The sizes to render, rejecting a duplicate name: each size names a file, so
|
|
36
|
+
* two sizes sharing a name would have one overwrite the other.
|
|
37
|
+
*/
|
|
38
|
+
export function resolveSizes(sizes) {
|
|
39
|
+
if (sizes === undefined || sizes.length === 0) {
|
|
40
|
+
return DEFAULT_SIZES;
|
|
41
|
+
}
|
|
42
|
+
const seen = new Set();
|
|
43
|
+
for (const size of sizes) {
|
|
44
|
+
if (seen.has(size.name)) {
|
|
45
|
+
throw new Error(`Duplicate output size name "${size.name}"; names must be unique so each image gets a distinct filename.`);
|
|
46
|
+
}
|
|
47
|
+
seen.add(size.name);
|
|
48
|
+
}
|
|
49
|
+
return sizes;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Whether to load the machine's own fonts. Configured fonts are meant to make
|
|
53
|
+
* the output the same everywhere, so supplying any turns system fonts off
|
|
54
|
+
* unless the project asks for them back.
|
|
55
|
+
*/
|
|
56
|
+
export function shouldLoadSystemFonts(systemFonts, fonts) {
|
|
57
|
+
if (systemFonts === undefined) {
|
|
58
|
+
return fonts.length === 0;
|
|
59
|
+
}
|
|
60
|
+
if (!systemFonts && fonts.length === 0) {
|
|
61
|
+
throw new Error("systemFonts is false and no fonts are configured, so no text could be" +
|
|
62
|
+
" rendered. Add fonts, or leave systemFonts unset.");
|
|
63
|
+
}
|
|
64
|
+
return systemFonts;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/config/resolve.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,aAAa,GACd,MAAM,eAAe,CAAC;AAEvB;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC3B,MAA+B;IAE/B,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,KAAK;QAC3C,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,KAAK;QAC3C,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,cAAc,CAAC,UAAU;KAC3D,CAAC;AACJ,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,iBAAiB,CAAC,MAA6B;IAC7D,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE;YACL,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,SAAS,EAAE;YACzC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE;YACtC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,SAAS,EAAE;SAC5C;KACF,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