@gobing-ai/knowledge-kit 0.1.19 → 0.1.22
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/.claude-plugin/marketplace.json +1 -1
- package/dist/board/collect/index.js +1 -0
- package/dist/board/daily-voice/index.js +1315 -264
- package/dist/board/itc/index.js +1 -0
- package/dist/index.js +14674 -8775
- package/package.json +1 -1
- package/plugins/generations/dailynews-gen/dist/index.js +285 -16
- package/plugins/generations/dailynews-gen/src/editorial-claims.ts +215 -0
- package/plugins/generations/dailynews-gen/src/index.ts +23 -4
- package/plugins/generations/dailynews-gen/src/script-builder.ts +10 -3
- package/plugins/generations/dailynews-gen/src/script-plan.ts +74 -14
- package/plugins/generations/image-gen/README.md +31 -31
- package/plugins/generations/image-gen/assets/sample/provenance.json +314 -0
- package/plugins/generations/image-gen/config.example.yaml +3 -0
- package/plugins/generations/image-gen/dist/index.js +154 -14
- package/plugins/generations/image-gen/presets/SOURCE.md +65 -0
- package/plugins/generations/image-gen/scripts/eval-style-presets.ts +513 -0
- package/plugins/generations/image-gen/scripts/gen-samples.ts +57 -7
- package/plugins/generations/image-gen/src/presets.ts +6 -5
- package/plugins/generations/image-gen/src/providers/h3-local.ts +196 -0
- package/plugins/generations/image-gen/src/providers/types.ts +11 -1
- package/plugins/generations/music-gen/README.md +277 -0
- package/plugins/generations/music-gen/dist/index.js +23544 -0
- package/plugins/generations/music-gen/package.json +24 -0
- package/plugins/generations/music-gen/plugin.json +23 -0
- package/plugins/generations/music-gen/presets/SOURCE.md +39 -0
- package/plugins/generations/music-gen/presets/formats/clip.yaml +21 -0
- package/plugins/generations/music-gen/presets/formats/jingle.yaml +22 -0
- package/plugins/generations/music-gen/presets/formats/loop.yaml +21 -0
- package/plugins/generations/music-gen/presets/formats/song.yaml +31 -0
- package/plugins/generations/music-gen/presets/formats/underscore.yaml +22 -0
- package/plugins/generations/music-gen/presets/themes/ambient-tech.yaml +30 -0
- package/plugins/generations/music-gen/presets/themes/cinematic.yaml +30 -0
- package/plugins/generations/music-gen/presets/themes/lofi.yaml +30 -0
- package/plugins/generations/music-gen/presets/themes/synthwave.yaml +30 -0
- package/plugins/generations/music-gen/scripts/gen-preset-index.ts +181 -0
- package/plugins/generations/music-gen/scripts/resolve-preset.ts +64 -0
- package/plugins/generations/music-gen/src/adapter/index.ts +35 -0
- package/plugins/generations/music-gen/src/adapter/instance.ts +904 -0
- package/plugins/generations/music-gen/src/adapter/offline.ts +124 -0
- package/plugins/generations/music-gen/src/artifact.ts +223 -0
- package/plugins/generations/music-gen/src/audio/checks.ts +618 -0
- package/plugins/generations/music-gen/src/audio/master.ts +267 -0
- package/plugins/generations/music-gen/src/audio/measure.ts +507 -0
- package/plugins/generations/music-gen/src/audio/profile.ts +131 -0
- package/plugins/generations/music-gen/src/audio.ts +122 -0
- package/plugins/generations/music-gen/src/brief.ts +191 -0
- package/plugins/generations/music-gen/src/config.ts +451 -0
- package/plugins/generations/music-gen/src/content.ts +199 -0
- package/plugins/generations/music-gen/src/digest.ts +100 -0
- package/plugins/generations/music-gen/src/index.ts +147 -0
- package/plugins/generations/music-gen/src/job.ts +131 -0
- package/plugins/generations/music-gen/src/plugin.ts +371 -0
- package/plugins/generations/music-gen/src/presets.ts +918 -0
- package/plugins/generations/music-gen/src/render.ts +87 -0
- package/plugins/generations/music-gen/src/request.ts +102 -0
- package/plugins/generations/music-gen/src/spend.ts +495 -0
- package/plugins/generations/music-gen/tsconfig.json +8 -0
- package/plugins/kk/config.example.yaml +3 -0
- package/plugins/kk/decisions/extract/ai-news.yaml +5 -2
- package/plugins/kk/plugin.json +1 -1
- package/plugins/kk/publish-presets/daily-ai-voice.json +48 -7
- package/plugins/kk/schedules/kk-serve.launchd.plist.tmpl +2 -1
- package/plugins/kk/scripts/cover-compositor.ts +380 -32
- package/plugins/kk/scripts/daily-cover-mock.ts +40 -3
- package/plugins/kk/scripts/daily-stages.ts +897 -34
- package/plugins/kk/scripts/episode-identity.ts +180 -0
- package/plugins/kk/scripts/kk-workflow-stages.ts +37 -1
- package/plugins/kk/scripts/music-stages.ts +624 -0
- package/plugins/kk/scripts/news-editorial-ledger.ts +906 -0
- package/plugins/kk/scripts/source-citation.ts +187 -0
- package/plugins/kk/scripts/topic-selection-attempts.ts +446 -0
- package/plugins/kk/scripts/topic-selection-calibration.ts +161 -0
- package/plugins/kk/skills/content-judge/SKILL.md +11 -6
- package/plugins/kk/skills/content-judge/references/music-quality-rubric.md +147 -0
- package/plugins/kk/skills/content-judge/references/rubrics.md +15 -0
- package/plugins/kk/skills/content-safety/SKILL.md +12 -0
- package/plugins/kk/skills/image-authoring/SKILL.md +7 -3
- package/plugins/kk/skills/image-authoring/references/providers.md +27 -0
- package/plugins/kk/skills/image-authoring/references/style-extraction.md +1 -1
- package/plugins/kk/skills/music-authoring/SKILL.md +276 -0
- package/plugins/kk/skills/music-authoring/references/judge-input.md +117 -0
- package/plugins/kk/skills/news-editorial/SKILL.md +102 -15
- package/plugins/kk/skills/news-editorial/references/selection.md +4 -0
- package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +58 -11
- package/plugins/kk/skills/publish/SKILL.md +11 -0
- package/plugins/kk/skills/web-automation/SKILL.md +31 -1
- package/plugins/kk/workflows/kk-collect.yaml +8 -4
- package/plugins/kk/workflows/kk-daily-ai-voice.yaml +10 -9
- package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +11 -9
- package/plugins/kk/workflows/kk-music.yaml +328 -0
- package/plugins/kk/workflows/kk-news-generate.yaml +58 -3
- package/plugins/publishings/bilibili-pub/dist/index.js +11 -1
- package/plugins/publishings/bilibili-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/cnblogs-pub/dist/index.js +11 -1
- package/plugins/publishings/cnblogs-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/csdn-pub/dist/index.js +11 -1
- package/plugins/publishings/csdn-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/infoq-pub/dist/index.js +11 -1
- package/plugins/publishings/infoq-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/jike-pub/dist/index.js +11 -1
- package/plugins/publishings/jike-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/juejin-pub/dist/index.js +11 -1
- package/plugins/publishings/juejin-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/linkedin-pub/dist/index.js +54 -7
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +43 -6
- package/plugins/publishings/linkedin-pub/src/index.ts +52 -6
- package/plugins/publishings/podcast-pub/dist/index.js +586 -20
- package/plugins/publishings/podcast-pub/src/corrections.ts +509 -0
- package/plugins/publishings/podcast-pub/src/index.ts +257 -5
- package/plugins/publishings/podcast-pub/src/show-notes-brief.ts +240 -0
- package/plugins/publishings/podcast-pub/src/show-notes.ts +69 -13
- package/plugins/publishings/shipinhao-pub/dist/index.js +437 -32
- package/plugins/publishings/shipinhao-pub/dist/profile-check.js +14 -2
- package/plugins/publishings/shipinhao-pub/plugin.json +1 -1
- package/plugins/publishings/shipinhao-pub/src/audio-flow.ts +492 -0
- package/plugins/publishings/shipinhao-pub/src/flow.ts +227 -12
- package/plugins/publishings/shipinhao-pub/src/selectors.ts +13 -0
- package/plugins/publishings/sspai-pub/dist/index.js +11 -1
- package/plugins/publishings/sspai-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/substack-pub/dist/index.js +11 -1
- package/plugins/publishings/substack-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/surfdash-pub/dist/index.js +122 -28
- package/plugins/publishings/surfdash-pub/src/digest-check.ts +7 -3
- package/plugins/publishings/surfdash-pub/src/index.ts +159 -25
- package/plugins/publishings/surfdash-pub/src/topic-claims.ts +37 -4
- package/plugins/publishings/threads-pub/dist/index.js +9206 -296
- package/plugins/publishings/threads-pub/dist/profile-check.js +21149 -0
- package/plugins/publishings/threads-pub/package.json +3 -1
- package/plugins/publishings/threads-pub/plugin.json +6 -1
- package/plugins/publishings/threads-pub/src/index.ts +8 -1
- package/plugins/publishings/threads-pub/src/post-rail.ts +357 -0
- package/plugins/publishings/threads-pub/src/profile-check.ts +17 -0
- package/plugins/publishings/wechatmp-pub/dist/index.js +18 -1
- package/plugins/publishings/wechatmp-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/wechatmp-pub/src/flow.ts +13 -0
- package/plugins/publishings/weibo-pub/dist/index.js +57 -3
- package/plugins/publishings/weibo-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/weibo-pub/src/index.ts +74 -2
- package/plugins/publishings/x-pub/dist/index.js +274 -44
- package/plugins/publishings/x-pub/dist/profile-check.js +14 -2
- package/plugins/publishings/x-pub/src/index.ts +15 -1
- package/plugins/publishings/x-pub/src/post-rail.ts +334 -0
- package/plugins/publishings/xhs-pub/dist/index.js +11 -1
- package/plugins/publishings/xhs-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +11 -1
- package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +11 -1
|
@@ -101,6 +101,9 @@ plugins:
|
|
|
101
101
|
BAOYU_CODEX_IMAGEGEN_BIN: "" # optional — wrapper entrypoint override
|
|
102
102
|
BAOYU_CODEX_IMAGEGEN_TIMEOUT_MS: "" # optional — per-call timeout (ms)
|
|
103
103
|
BAOYU_CODEX_IMAGEGEN_RETRIES: "" # optional — retry count
|
|
104
|
+
# -- h3-local (local Apple Silicon MLX runtime; NEVER auto-selected — pin explicitly) --
|
|
105
|
+
H3_IMAGE_MLX_BIN: "" # absolute path to ../gitops/apps/h3-image-mlx/h3gen.sh — its presence IS readiness (0379)
|
|
106
|
+
H3_LOCAL_TIMEOUT_MS: "" # optional — per-render bound in ms; default 1800000 (30 min: a 2-reference edit measured 27m46s)
|
|
104
107
|
# -- 0104 R6 runtime seams (behavior, not credentials; placeholder values only) --
|
|
105
108
|
KK_IMAGE_MAX_IMAGES: "" # optional — per-run budget cap; default 4 (OPEN for the operator to set)
|
|
106
109
|
KK_IMAGE_DRY_RUN: "" # optional — "1" composes every prompt, selects the provider, spends nothing
|
|
@@ -8,8 +8,11 @@
|
|
|
8
8
|
#
|
|
9
9
|
# Keys are decision ids from the sibling catalog (plugins/kk/decisions/kk-items.yaml);
|
|
10
10
|
# an unknown key or decision id fails loud with `kk.store.profile.invalid`.
|
|
11
|
-
# `limit`
|
|
12
|
-
#
|
|
11
|
+
# `limit` 32 (2026-11-15, task 0377): the omitted default of 20 capped a week-wide pool at 20
|
|
12
|
+
# items, which after QC admitted ~11.4k chars = 10.3 min against the 15 min floor, so a thin week
|
|
13
|
+
# could never clear it however far the ladder widened. 32 items keeps the estimate inside the
|
|
14
|
+
# 15-25 min window (measured: 45,163 raw chars -> ~16.4 min) instead of refusing the day.
|
|
15
|
+
limit: 40
|
|
13
16
|
topic: ai-news
|
|
14
17
|
where:
|
|
15
18
|
# 2026-10-21: the allowlist is the whole AI taxonomy, in lockstep with the workflow's
|
package/plugins/kk/plugin.json
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"variant": "episode",
|
|
27
27
|
"tier": 1,
|
|
28
28
|
"window": "after-generate",
|
|
29
|
-
"mode": "
|
|
29
|
+
"mode": "off"
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
"plugin": "xhs-pub",
|
|
@@ -42,7 +42,10 @@
|
|
|
42
42
|
"variant": "episode",
|
|
43
43
|
"tier": 1,
|
|
44
44
|
"window": "after-generate",
|
|
45
|
-
"mode": "live"
|
|
45
|
+
"mode": "live",
|
|
46
|
+
"options": {
|
|
47
|
+
"collection": "每日AI乱炖"
|
|
48
|
+
}
|
|
46
49
|
},
|
|
47
50
|
{
|
|
48
51
|
"plugin": "wechatmp-pub",
|
|
@@ -50,7 +53,7 @@
|
|
|
50
53
|
"variant": "article",
|
|
51
54
|
"tier": 2,
|
|
52
55
|
"window": "after-generate",
|
|
53
|
-
"mode": "
|
|
56
|
+
"mode": "draft",
|
|
54
57
|
"options": {
|
|
55
58
|
"collection": "每日AI资讯"
|
|
56
59
|
}
|
|
@@ -93,7 +96,7 @@
|
|
|
93
96
|
"variant": "social:x",
|
|
94
97
|
"tier": 3,
|
|
95
98
|
"window": "overseas-rss",
|
|
96
|
-
"mode": "
|
|
99
|
+
"mode": "live"
|
|
97
100
|
},
|
|
98
101
|
{
|
|
99
102
|
"plugin": "weibo-pub",
|
|
@@ -101,7 +104,7 @@
|
|
|
101
104
|
"variant": "social:weibo",
|
|
102
105
|
"tier": 3,
|
|
103
106
|
"window": "overseas-rss",
|
|
104
|
-
"mode": "
|
|
107
|
+
"mode": "live"
|
|
105
108
|
},
|
|
106
109
|
{
|
|
107
110
|
"plugin": "threads-pub",
|
|
@@ -109,7 +112,7 @@
|
|
|
109
112
|
"variant": "social:threads",
|
|
110
113
|
"tier": 3,
|
|
111
114
|
"window": "overseas-rss",
|
|
112
|
-
"mode": "
|
|
115
|
+
"mode": "live"
|
|
113
116
|
},
|
|
114
117
|
{
|
|
115
118
|
"plugin": "linkedin-pub",
|
|
@@ -117,7 +120,7 @@
|
|
|
117
120
|
"variant": "social:linkedin",
|
|
118
121
|
"tier": 3,
|
|
119
122
|
"window": "overseas-rss",
|
|
120
|
-
"mode": "
|
|
123
|
+
"mode": "live"
|
|
121
124
|
},
|
|
122
125
|
{
|
|
123
126
|
"plugin": "shipinhao-pub",
|
|
@@ -134,6 +137,44 @@
|
|
|
134
137
|
"tier": 3,
|
|
135
138
|
"window": "overseas-rss",
|
|
136
139
|
"mode": "off"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"plugin": "jike-pub",
|
|
143
|
+
"operation": "post",
|
|
144
|
+
"variant": "social:jike",
|
|
145
|
+
"tier": 3,
|
|
146
|
+
"window": "overseas-rss",
|
|
147
|
+
"mode": "live"
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
"overrides": [
|
|
151
|
+
{
|
|
152
|
+
"plugin": "x-pub",
|
|
153
|
+
"operation": "post",
|
|
154
|
+
"mode": "live",
|
|
155
|
+
"reason": "operator instruction 2026-11-15: publish to all available platforms for the dogfood run; no draftable rail exists, so this is a recorded exception to ADR-022",
|
|
156
|
+
"until": "2026-11-16 dogfood run"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"plugin": "weibo-pub",
|
|
160
|
+
"operation": "post",
|
|
161
|
+
"mode": "live",
|
|
162
|
+
"reason": "operator instruction 2026-11-15: publish to all available platforms for the dogfood run; no draftable rail exists, so this is a recorded exception to ADR-022",
|
|
163
|
+
"until": "2026-11-16 dogfood run"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"plugin": "threads-pub",
|
|
167
|
+
"operation": "post",
|
|
168
|
+
"mode": "live",
|
|
169
|
+
"reason": "operator instruction 2026-11-15: publish to all available platforms for the dogfood run; no draftable rail exists, so this is a recorded exception to ADR-022",
|
|
170
|
+
"until": "2026-11-16 dogfood run"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"plugin": "linkedin-pub",
|
|
174
|
+
"operation": "post",
|
|
175
|
+
"mode": "live",
|
|
176
|
+
"reason": "operator instruction 2026-11-15: publish to all available platforms for the dogfood run; no draftable rail exists, so this is a recorded exception to ADR-022",
|
|
177
|
+
"until": "2026-11-16 dogfood run"
|
|
137
178
|
}
|
|
138
179
|
]
|
|
139
180
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<!-- kk-serve — keeps the knowledge-kit Spur server alive whenever this user is logged in.
|
|
4
4
|
|
|
5
5
|
WHY the keepalive is not optional: the daily job `kk-daily-ai-voice` (cron `30 4 * * *`) is
|
|
6
|
-
enqueued by the job worker that lives INSIDE `spur serve` (`.spur/config.yaml`
|
|
6
|
+
enqueued by the job worker that lives INSIDE `spur self serve` (`.spur/config.yaml`
|
|
7
7
|
`bootstrap.scheduler`). On 2026-10-12 that process was SIGTERM'd at 00:17 local and not
|
|
8
8
|
restarted until 10:00, so the 04:30 tick never fired and the day produced no episode at all —
|
|
9
9
|
no workspace, no ledger row, no run record. `crontab -l` is empty and nothing else supervises
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
<key>ProgramArguments</key>
|
|
35
35
|
<array>
|
|
36
36
|
<string>spur</string>
|
|
37
|
+
<string>self</string>
|
|
37
38
|
<string>serve</string>
|
|
38
39
|
<string>--cwd</string>
|
|
39
40
|
<string>{{repo}}</string>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { tmpdir } from 'node:os';
|
|
4
4
|
import { join, resolve } from 'node:path';
|
|
5
5
|
|
|
@@ -34,6 +34,221 @@ export const COVER_HEIGHT = 576;
|
|
|
34
34
|
export const HEADLINE_LINE_CAP = 25;
|
|
35
35
|
const FONT_STACK = `PingFang SC, Hiragino Sans GB, 'Noto Sans CJK SC', sans-serif`;
|
|
36
36
|
|
|
37
|
+
/** 0387 R1 — inset (px) between the shared crop intersection and the headline block. */
|
|
38
|
+
export const SAFE_MARGIN = 32;
|
|
39
|
+
/** Rows the headline may occupy inside the safe area (a 25-char point needs 3 at the 1:1 width). */
|
|
40
|
+
export const HEADLINE_MAX_ROWS = 3;
|
|
41
|
+
/** First-row size cap and the legibility floor the fit loop may shrink to. */
|
|
42
|
+
export const HEADLINE_FIRST_SIZE = 46;
|
|
43
|
+
export const HEADLINE_MIN_SIZE = 26;
|
|
44
|
+
/**
|
|
45
|
+
* 0387 R1 — the emblem is scaled down (was 72x50) and sits in the TOP-RIGHT corner. It keeps its
|
|
46
|
+
* own alpha: the old dark plate behind it (`fill-opacity="0.7"`) is gone, so the transparent
|
|
47
|
+
* emblem blends over the AI background instead of sitting on a chrome rectangle.
|
|
48
|
+
*/
|
|
49
|
+
export const LOGO_WIDTH = 56;
|
|
50
|
+
export const LOGO_HEIGHT = 38;
|
|
51
|
+
export const LOGO_MARGIN = 24;
|
|
52
|
+
|
|
53
|
+
/** An axis-aligned pixel rectangle, integer edges (the form `sips --cropOffset` and SVG take). */
|
|
54
|
+
export interface Rect {
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** One target platform's center crop of the full cover. */
|
|
62
|
+
export interface PlatformCrop {
|
|
63
|
+
platform: 'wechat-mp' | 'podcast-site';
|
|
64
|
+
label: string;
|
|
65
|
+
aspect: number;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 0387 R8 — the two platforms crop the 1344x576 cover at its CENTER, so the headline belongs in
|
|
70
|
+
* the intersection of those crops, not in the full 21:9 frame:
|
|
71
|
+
* - WeChat MP re-crops the uploaded cover to a 2.35:1 header and a 1:1 feed image
|
|
72
|
+
* (`plugins/publishings/wechatmp-pub/src/cgi.ts:20` `WIDE_COVER_ASPECT`, `centerCropRect`).
|
|
73
|
+
* - the podcast site shows the episode artwork square (channel artwork ships 1400x1400,
|
|
74
|
+
* `docs/design/podcast-pub.md`), i.e. a 1:1 center crop of the same frame.
|
|
75
|
+
* The 1:1 crop is the tight one: it keeps only x 384..960 of the 1344-wide canvas.
|
|
76
|
+
*/
|
|
77
|
+
export const TARGET_CROPS: readonly PlatformCrop[] = [
|
|
78
|
+
{ platform: 'wechat-mp', label: '微信公众号 2.35:1 头图', aspect: 2.35 },
|
|
79
|
+
{ platform: 'podcast-site', label: '播客站点 1:1 封面', aspect: 1 },
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Centered cover-fit rectangle for one target aspect ratio, from ACTUAL image dimensions. The
|
|
84
|
+
* same geometry as WeChat's upload path (`wechatmp-pub/src/cgi.ts` `centerCropRect`, task 0289 R2)
|
|
85
|
+
* — the publisher computes the `crop_multi` boxes from the real upload, so the safe area here and
|
|
86
|
+
* the boxes there agree by construction instead of by hand-measured pixels.
|
|
87
|
+
*/
|
|
88
|
+
export function centerCropRect(width: number, height: number, aspect: number): Rect {
|
|
89
|
+
if (!Number.isFinite(width) || !Number.isFinite(height) || width < 1 || height < 1) {
|
|
90
|
+
throw new TypeError(`cover compositor: image dimensions must be positive, got ${width}x${height}`);
|
|
91
|
+
}
|
|
92
|
+
if (!Number.isFinite(aspect) || aspect <= 0) {
|
|
93
|
+
throw new TypeError(`cover compositor: crop aspect must be positive, got ${aspect}`);
|
|
94
|
+
}
|
|
95
|
+
const cropWidth = width / height > aspect ? height * aspect : width;
|
|
96
|
+
const cropHeight = width / height > aspect ? height : width / aspect;
|
|
97
|
+
const x = Math.floor((width - cropWidth) / 2);
|
|
98
|
+
const y = Math.floor((height - cropHeight) / 2);
|
|
99
|
+
return {
|
|
100
|
+
x,
|
|
101
|
+
y,
|
|
102
|
+
width: Math.min(width, Math.round(cropWidth)),
|
|
103
|
+
height: Math.min(height, Math.round(cropHeight)),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The region EVERY target crop keeps, inset by `margin`: the only area the headline may occupy.
|
|
109
|
+
* For the 1344x576 cover that is x 416..928 (512 wide) — a 25-char point needs ~1150px on one
|
|
110
|
+
* line, which is why the headline is centered and wrapped to this width instead of left-aligned.
|
|
111
|
+
*/
|
|
112
|
+
export function safeAreaRect(
|
|
113
|
+
width = COVER_WIDTH,
|
|
114
|
+
height = COVER_HEIGHT,
|
|
115
|
+
crops: readonly PlatformCrop[] = TARGET_CROPS,
|
|
116
|
+
margin = SAFE_MARGIN,
|
|
117
|
+
): Rect {
|
|
118
|
+
if (crops.length === 0) throw new TypeError('cover compositor: at least one target crop is required');
|
|
119
|
+
const rects = crops.map((crop) => centerCropRect(width, height, crop.aspect));
|
|
120
|
+
const left = Math.max(...rects.map((rect) => rect.x));
|
|
121
|
+
const top = Math.max(...rects.map((rect) => rect.y));
|
|
122
|
+
const right = Math.min(...rects.map((rect) => rect.x + rect.width));
|
|
123
|
+
const bottom = Math.min(...rects.map((rect) => rect.y + rect.height));
|
|
124
|
+
const inset = Math.max(0, Math.min(margin, Math.floor((right - left) / 4), Math.floor((bottom - top) / 4)));
|
|
125
|
+
return { x: left + inset, y: top + inset, width: right - left - 2 * inset, height: bottom - top - 2 * inset };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Top-right emblem geometry on the full cover (outside the 1:1 crop by design — R1 names the
|
|
129
|
+
* full cover for the badge, the crops for the headline point). */
|
|
130
|
+
export function logoRect(width = COVER_WIDTH): Rect {
|
|
131
|
+
return { x: width - LOGO_MARGIN - LOGO_WIDTH, y: LOGO_MARGIN, width: LOGO_WIDTH, height: LOGO_HEIGHT };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** One laid-out headline row: the text plus the exact baseline/anchor the SVG must draw. */
|
|
135
|
+
export interface HeadlineRow {
|
|
136
|
+
text: string;
|
|
137
|
+
x: number;
|
|
138
|
+
y: number;
|
|
139
|
+
size: number;
|
|
140
|
+
weight: number;
|
|
141
|
+
fill: string;
|
|
142
|
+
/** Estimated rendered width in px — the same per-code-point estimate the fit loop uses. */
|
|
143
|
+
width: number;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface HeadlineLayout {
|
|
147
|
+
rows: HeadlineRow[];
|
|
148
|
+
/** Bounding box of the drawn rows — asserted to sit inside `safe`. */
|
|
149
|
+
block: Rect;
|
|
150
|
+
safe: Rect;
|
|
151
|
+
size: number;
|
|
152
|
+
/** True when the row budget ran out before the text did (an ellipsis was appended). */
|
|
153
|
+
truncated: boolean;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Greedy code-point wrap to `maxWidth`, at most `maxRows` rows; the tail is ellipsized on overflow. */
|
|
157
|
+
function wrapToRows(
|
|
158
|
+
text: string,
|
|
159
|
+
maxWidth: number,
|
|
160
|
+
size: number,
|
|
161
|
+
maxRows: number,
|
|
162
|
+
): { rows: string[]; truncated: boolean } {
|
|
163
|
+
const chars = Array.from(text.replaceAll(/\s+/g, ' ').trim());
|
|
164
|
+
const rows: string[] = [];
|
|
165
|
+
let current = '';
|
|
166
|
+
let index = 0;
|
|
167
|
+
while (index < chars.length) {
|
|
168
|
+
const candidate = current + chars[index];
|
|
169
|
+
if (current === '' || estimateWidth(candidate, size) <= maxWidth) {
|
|
170
|
+
current = candidate;
|
|
171
|
+
index += 1;
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
rows.push(current);
|
|
175
|
+
current = chars[index] === ' ' ? '' : chars[index];
|
|
176
|
+
index += 1;
|
|
177
|
+
if (rows.length === maxRows) {
|
|
178
|
+
const rest = (current + chars.slice(index).join('')).trim();
|
|
179
|
+
let base = rows[maxRows - 1];
|
|
180
|
+
while (base !== '' && estimateWidth(`${base}…`, size) > maxWidth)
|
|
181
|
+
base = Array.from(base).slice(0, -1).join('');
|
|
182
|
+
let keep = '';
|
|
183
|
+
for (const ch of Array.from(rest)) {
|
|
184
|
+
if (estimateWidth(`${base}${keep}${ch}…`, size) > maxWidth) break;
|
|
185
|
+
keep += ch;
|
|
186
|
+
}
|
|
187
|
+
rows[maxRows - 1] = `${base}${keep}…`;
|
|
188
|
+
return { rows, truncated: rest !== '' };
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (current.trim() !== '') rows.push(current);
|
|
192
|
+
return { rows, truncated: false };
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* 0387 R1 — lay the headline out so both platform center crops keep the WHOLE point: rows are
|
|
197
|
+
* centered on the canvas midline, wrapped to the safe-area width, and vertically centered inside
|
|
198
|
+
* the safe area. `wrapHeadline` still owns the content contract (≤2 x 25 chars, explicit breaks);
|
|
199
|
+
* this adds the geometric fit on top of it.
|
|
200
|
+
*/
|
|
201
|
+
export function layoutHeadline(headline: string, width = COVER_WIDTH, height = COVER_HEIGHT): HeadlineLayout {
|
|
202
|
+
const safe = safeAreaRect(width, height);
|
|
203
|
+
const source = wrapHeadline(headline).join(' ').trim();
|
|
204
|
+
if (source === '') {
|
|
205
|
+
return {
|
|
206
|
+
rows: [],
|
|
207
|
+
block: { x: safe.x, y: safe.y, width: 0, height: 0 },
|
|
208
|
+
safe,
|
|
209
|
+
size: HEADLINE_MIN_SIZE,
|
|
210
|
+
truncated: false,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
let size = HEADLINE_FIRST_SIZE;
|
|
214
|
+
let wrapped = wrapToRows(source, safe.width, size, HEADLINE_MAX_ROWS);
|
|
215
|
+
while (wrapped.truncated && size > HEADLINE_MIN_SIZE) {
|
|
216
|
+
size -= 2;
|
|
217
|
+
wrapped = wrapToRows(source, safe.width, size, HEADLINE_MAX_ROWS);
|
|
218
|
+
}
|
|
219
|
+
const texts = wrapped.rows.filter((row) => row.trim() !== '');
|
|
220
|
+
const sizes = texts.map((_row, index) =>
|
|
221
|
+
index === 0 ? size : Math.max(HEADLINE_MIN_SIZE, Math.round(size * 0.8)),
|
|
222
|
+
);
|
|
223
|
+
const lineHeights = sizes.map((lineSize) => Math.round(lineSize * 1.28));
|
|
224
|
+
const blockHeight = lineHeights.reduce((sum, lineHeight) => sum + lineHeight, 0);
|
|
225
|
+
const top = safe.y + Math.round((safe.height - blockHeight) / 2);
|
|
226
|
+
const centerX = Math.round(width / 2);
|
|
227
|
+
let cursor = top;
|
|
228
|
+
const rows: HeadlineRow[] = texts.map((text, index) => {
|
|
229
|
+
const lineSize = sizes[index];
|
|
230
|
+
const row: HeadlineRow = {
|
|
231
|
+
text,
|
|
232
|
+
x: centerX,
|
|
233
|
+
y: cursor + Math.round(lineSize * 0.82),
|
|
234
|
+
size: lineSize,
|
|
235
|
+
weight: index === 0 ? 800 : 700,
|
|
236
|
+
fill: index === 0 ? '#FFFFFF' : '#FFB800',
|
|
237
|
+
width: Math.round(estimateWidth(text, lineSize)),
|
|
238
|
+
};
|
|
239
|
+
cursor += lineHeights[index];
|
|
240
|
+
return row;
|
|
241
|
+
});
|
|
242
|
+
const blockWidth = Math.max(...rows.map((row) => row.width));
|
|
243
|
+
return {
|
|
244
|
+
rows,
|
|
245
|
+
block: { x: Math.round(centerX - blockWidth / 2), y: top, width: blockWidth, height: blockHeight },
|
|
246
|
+
safe,
|
|
247
|
+
size,
|
|
248
|
+
truncated: wrapped.truncated,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
|
|
37
252
|
/** XML-escape a text node or attribute value (headlines are model-authored, so assume the worst). */
|
|
38
253
|
function esc(text: string): string {
|
|
39
254
|
return text.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"');
|
|
@@ -63,8 +278,9 @@ export function wrapHeadline(headline: string): string[] {
|
|
|
63
278
|
/**
|
|
64
279
|
* Estimated rendered width in px for the mixed CJK/Latin headline: `sips` has no text metrics we
|
|
65
280
|
* can read back, so each code point is charged its rough advance (CJK ≈ 1em, Latin ≈ 0.55em,
|
|
66
|
-
* space ≈ 0.28em). Used only to shrink a
|
|
67
|
-
* smaller one (the 2026-11-12 regeneration clipped "Anthropic" at the
|
|
281
|
+
* space ≈ 0.28em). Used only to shrink a row until it fits the crop-safe width — a clipped
|
|
282
|
+
* headline is worse than a smaller one (the 2026-11-12 regeneration clipped "Anthropic" at the
|
|
283
|
+
* canvas edge).
|
|
68
284
|
*/
|
|
69
285
|
function estimateWidth(text: string, fontSize: number): number {
|
|
70
286
|
let em = 0;
|
|
@@ -76,13 +292,6 @@ function estimateWidth(text: string, fontSize: number): number {
|
|
|
76
292
|
return em * fontSize;
|
|
77
293
|
}
|
|
78
294
|
|
|
79
|
-
/** Largest size <= `baseSize` at which `text` fits `maxWidth`, floored so it stays legible. */
|
|
80
|
-
export function fitFontSize(text: string, baseSize: number, maxWidth: number, floorSize = 24): number {
|
|
81
|
-
let size = baseSize;
|
|
82
|
-
while (size > floorSize && estimateWidth(text, size) > maxWidth) size -= 1;
|
|
83
|
-
return size;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
295
|
/** Fixed-width chunker for CJK headlines — code points, not UTF-16 units. */
|
|
87
296
|
function chunk(text: string): string[] {
|
|
88
297
|
const chars = Array.from(text);
|
|
@@ -113,32 +322,36 @@ export function logoBadgeSvg(logoPath: string, x: number, y: number, width: numb
|
|
|
113
322
|
return `<svg x="${x}" y="${y}" width="${width}" height="${height}" viewBox="0 0 1095 760" preserveAspectRatio="xMidYMid meet">${inner}</svg>`;
|
|
114
323
|
}
|
|
115
324
|
|
|
116
|
-
/**
|
|
325
|
+
/**
|
|
326
|
+
* The shipped emblem, resolved from THIS module (repo root is three levels up from `plugins/kk/scripts`)
|
|
327
|
+
* so the badge renders no matter the process CWD. `existsSync` treats a relative path as CWD-relative,
|
|
328
|
+
* which is exactly how the badge went missing from shipped covers.
|
|
329
|
+
*/
|
|
330
|
+
export const DEFAULT_LOGO_PATH = resolve(import.meta.dir, '..', '..', '..', 'assets', 'general', 'xhxs.svg');
|
|
331
|
+
|
|
332
|
+
/** Deterministic SVG overlay: background image, bottom scrim, top-right emblem, centered headline. */
|
|
117
333
|
export function buildCoverSvg(options: CoverCompositorOptions): string {
|
|
118
334
|
const width = options.width ?? COVER_WIDTH;
|
|
119
335
|
const height = options.height ?? COVER_HEIGHT;
|
|
120
|
-
const
|
|
121
|
-
const
|
|
336
|
+
const layout = layoutHeadline(options.headline, width, height);
|
|
337
|
+
const badge = logoRect(width);
|
|
338
|
+
// Resolve the default emblem from this module, never the CWD: the production caller passes no
|
|
339
|
+
// path, so a CWD-relative default silently omitted the badge from every shipped cover (0387 R1).
|
|
340
|
+
const logo = logoBadgeSvg(options.logoPath ?? DEFAULT_LOGO_PATH, badge.x, badge.y, badge.width, badge.height);
|
|
122
341
|
|
|
123
342
|
// 2026-11-12 regression: `sips` drops EVERY `<text>` that carries an SVG filter, so the
|
|
124
343
|
// headline never rasterized (both the 11-11 and 11-12 covers shipped chrome with no headline).
|
|
125
|
-
// Contrast comes from the
|
|
126
|
-
//
|
|
127
|
-
const
|
|
128
|
-
`<text x="
|
|
129
|
-
<text x="
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const badge =
|
|
138
|
-
logo !== ''
|
|
139
|
-
? `<rect x="36" y="30" width="96" height="70" rx="12" fill="#0a1424" fill-opacity="0.7" />
|
|
140
|
-
${logo}`
|
|
141
|
-
: '';
|
|
344
|
+
// Contrast comes from the scrim plus a geometric shadow — the same text drawn once in dark
|
|
345
|
+
// behind the visible line — because that is plain geometry, not a filter.
|
|
346
|
+
const row = (line: HeadlineRow): string =>
|
|
347
|
+
`<text x="${line.x}" y="${line.y + 3}" text-anchor="middle" font-family="${FONT_STACK}" font-size="${line.size}" font-weight="${line.weight}" fill="#000000" fill-opacity="0.72">${esc(line.text)}</text>
|
|
348
|
+
<text x="${line.x}" y="${line.y}" text-anchor="middle" font-family="${FONT_STACK}" font-size="${line.size}" font-weight="${line.weight}" fill="${line.fill}">${esc(line.text)}</text>`;
|
|
349
|
+
const typography = layout.rows.map(row).join('\n ');
|
|
350
|
+
// 0387 R1: the emblem is drawn straight onto the background — no plate behind it — so its own
|
|
351
|
+
// alpha is what the audience sees (the old `rect fill-opacity="0.7"` chrome is gone).
|
|
352
|
+
// 0387 R1: the scrim starts at 20% height because the headline now sits mid-frame (centered in
|
|
353
|
+
// the crop-safe column) instead of in the lower third.
|
|
354
|
+
const scrimTop = Math.round(height * 0.2);
|
|
142
355
|
|
|
143
356
|
return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">
|
|
144
357
|
<image href="${options.backgroundUri ?? encodeURI(`file://${resolve(options.backgroundImagePath)}`)}" x="0" y="0" width="${width}" height="${height}" preserveAspectRatio="xMidYMid slice" />
|
|
@@ -148,8 +361,8 @@ export function buildCoverSvg(options: CoverCompositorOptions): string {
|
|
|
148
361
|
<stop offset="1" stop-color="#0a1424" stop-opacity="0.92" />
|
|
149
362
|
</linearGradient>
|
|
150
363
|
</defs>
|
|
151
|
-
<rect x="0" y="${
|
|
152
|
-
${
|
|
364
|
+
<rect x="0" y="${scrimTop}" width="${width}" height="${height - scrimTop}" fill="url(#bottomScrim)" />
|
|
365
|
+
${logo}
|
|
153
366
|
${typography}
|
|
154
367
|
<text x="${width - 48}" y="${height - 40}" text-anchor="end" font-family="${FONT_STACK}" font-size="18" font-weight="600" letter-spacing="2" fill="#FFFFFF" fill-opacity="0.85">DAILY AI PODCAST</text>
|
|
155
368
|
</svg>
|
|
@@ -196,3 +409,138 @@ export function compositeCover(options: CoverCompositorOptions): string {
|
|
|
196
409
|
}
|
|
197
410
|
return options.outputPath;
|
|
198
411
|
}
|
|
412
|
+
|
|
413
|
+
/** One platform crop preview written next to the full cover. */
|
|
414
|
+
export interface CoverCropPreview {
|
|
415
|
+
platform: PlatformCrop['platform'];
|
|
416
|
+
label: string;
|
|
417
|
+
aspect: number;
|
|
418
|
+
/** The rectangle this preview keeps of the full cover (centered, from the real dimensions). */
|
|
419
|
+
rect: Rect;
|
|
420
|
+
path: string;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
export interface CoverPreviewManifest {
|
|
424
|
+
coverPath: string;
|
|
425
|
+
width: number;
|
|
426
|
+
height: number;
|
|
427
|
+
safeArea: Rect;
|
|
428
|
+
headlineBlock: Rect;
|
|
429
|
+
rows: number;
|
|
430
|
+
truncated: boolean;
|
|
431
|
+
crops: CoverCropPreview[];
|
|
432
|
+
/** Full cover rendered with the reference emblem fused in ('' when no emblem was supplied). */
|
|
433
|
+
referenceCoverPath: string;
|
|
434
|
+
/** Zoomed top-right corner of the reference cover: the alpha blend an operator compares. */
|
|
435
|
+
referenceBlendPath: string;
|
|
436
|
+
/** The emblem the reference artifacts used — the checked-in alpha fixture, never a fake banner. */
|
|
437
|
+
referenceLogoPath: string;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
export interface CoverPreviewOptions extends CoverCompositorOptions {
|
|
441
|
+
/** Directory the inspectable artifacts land in (created when missing). */
|
|
442
|
+
previewDir: string;
|
|
443
|
+
/**
|
|
444
|
+
* 0387 R1 — the reference emblem. The operator's banner is absent on the build machine, so the
|
|
445
|
+
* deterministic verification fuses the checked-in transparent fixture
|
|
446
|
+
* (`plugins/kk/tests/fixtures/alpha-logo.svg`) and the REAL reference comparison stays a
|
|
447
|
+
* separate operator check. Omitted ⇒ no reference artifacts are claimed.
|
|
448
|
+
*/
|
|
449
|
+
referenceLogoPath?: string;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/** Center-crop a rendered PNG to `rect` via `sips` (macOS-only, same tool as the render itself). */
|
|
453
|
+
function cropPng(source: string, rect: Rect, outputPath: string): void {
|
|
454
|
+
const sips = spawnSync(
|
|
455
|
+
'sips',
|
|
456
|
+
[
|
|
457
|
+
'-c',
|
|
458
|
+
String(rect.height),
|
|
459
|
+
String(rect.width),
|
|
460
|
+
'--cropOffset',
|
|
461
|
+
String(rect.y),
|
|
462
|
+
String(rect.x),
|
|
463
|
+
source,
|
|
464
|
+
'--out',
|
|
465
|
+
outputPath,
|
|
466
|
+
],
|
|
467
|
+
{ stdio: 'ignore' },
|
|
468
|
+
);
|
|
469
|
+
if (sips.error !== undefined || typeof sips.status !== 'number') {
|
|
470
|
+
throw new Error('cover compositor: sips not found; cannot write the crop previews (macOS required)');
|
|
471
|
+
}
|
|
472
|
+
if (sips.status !== 0) {
|
|
473
|
+
throw new Error(`cover compositor: sips crop failed (status ${sips.status}); preview ${outputPath} missing`);
|
|
474
|
+
}
|
|
475
|
+
if (!existsSync(outputPath)) {
|
|
476
|
+
throw new Error(`cover compositor: sips reported success but crop preview ${outputPath} is missing`);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/** The top-right corner window the reference-blend preview zooms into (emblem + its surroundings). */
|
|
481
|
+
export function referenceBlendRect(width = COVER_WIDTH, height = COVER_HEIGHT): Rect {
|
|
482
|
+
const badge = logoRect(width);
|
|
483
|
+
const x = Math.max(0, badge.x - 180);
|
|
484
|
+
return {
|
|
485
|
+
x,
|
|
486
|
+
y: Math.max(0, badge.y - 16),
|
|
487
|
+
width: Math.min(width - x, badge.width + 260),
|
|
488
|
+
height: Math.min(height - Math.max(0, badge.y - 16), badge.height + 130),
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* 0387 R1 — write the inspectable verification artifacts: the full cover, one center-crop preview
|
|
494
|
+
* per target platform (the exact rectangles `TARGET_CROPS`/`safeAreaRect` reason about), and the
|
|
495
|
+
* reference blend (the full cover plus a zoom of the fused emblem). Every artifact is a real PNG
|
|
496
|
+
* produced by the production compositor path — nothing here is a mock of the render.
|
|
497
|
+
*/
|
|
498
|
+
export function writeCoverPreviews(options: CoverPreviewOptions): CoverPreviewManifest {
|
|
499
|
+
const width = options.width ?? COVER_WIDTH;
|
|
500
|
+
const height = options.height ?? COVER_HEIGHT;
|
|
501
|
+
const previewDir = resolve(options.previewDir);
|
|
502
|
+
mkdirSync(previewDir, { recursive: true });
|
|
503
|
+
|
|
504
|
+
const coverPath = join(previewDir, 'cover-full.png');
|
|
505
|
+
compositeCover({ ...options, outputPath: coverPath });
|
|
506
|
+
|
|
507
|
+
const crops: CoverCropPreview[] = TARGET_CROPS.map((crop) => {
|
|
508
|
+
const rect = centerCropRect(width, height, crop.aspect);
|
|
509
|
+
const path = join(previewDir, `crop-${crop.platform}.png`);
|
|
510
|
+
cropPng(coverPath, rect, path);
|
|
511
|
+
return { platform: crop.platform, label: crop.label, aspect: crop.aspect, rect, path };
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
let referenceCoverPath = '';
|
|
515
|
+
let referenceBlendPath = '';
|
|
516
|
+
let referenceLogoPath = '';
|
|
517
|
+
if (options.referenceLogoPath !== undefined && options.referenceLogoPath !== '') {
|
|
518
|
+
referenceLogoPath = resolve(options.referenceLogoPath);
|
|
519
|
+
if (!existsSync(referenceLogoPath)) {
|
|
520
|
+
throw new Error(
|
|
521
|
+
`cover compositor: reference emblem missing (${referenceLogoPath}); refuse to fake the blend`,
|
|
522
|
+
);
|
|
523
|
+
}
|
|
524
|
+
referenceCoverPath = join(previewDir, 'cover-reference.png');
|
|
525
|
+
compositeCover({ ...options, outputPath: referenceCoverPath, logoPath: referenceLogoPath });
|
|
526
|
+
referenceBlendPath = join(previewDir, 'reference-logo-blend.png');
|
|
527
|
+
cropPng(referenceCoverPath, referenceBlendRect(width, height), referenceBlendPath);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
const layout = layoutHeadline(options.headline, width, height);
|
|
531
|
+
const manifest: CoverPreviewManifest = {
|
|
532
|
+
coverPath,
|
|
533
|
+
width,
|
|
534
|
+
height,
|
|
535
|
+
safeArea: layout.safe,
|
|
536
|
+
headlineBlock: layout.block,
|
|
537
|
+
rows: layout.rows.length,
|
|
538
|
+
truncated: layout.truncated,
|
|
539
|
+
crops,
|
|
540
|
+
referenceCoverPath,
|
|
541
|
+
referenceBlendPath,
|
|
542
|
+
referenceLogoPath,
|
|
543
|
+
};
|
|
544
|
+
writeFileSync(join(previewDir, 'manifest.json'), `${JSON.stringify(manifest, null, 4)}\n`, 'utf-8');
|
|
545
|
+
return manifest;
|
|
546
|
+
}
|