@appeeky/open-slideshow 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +297 -2
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +9 -0
- package/dist/brand.d.ts +57 -0
- package/dist/brand.js +263 -0
- package/dist/brandkit.d.ts +50 -0
- package/dist/brandkit.js +212 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +355 -0
- package/dist/decks.d.ts +44 -0
- package/dist/decks.js +100 -0
- package/dist/fonts.d.ts +45 -0
- package/dist/fonts.js +243 -0
- package/dist/gallery.d.ts +35 -0
- package/dist/gallery.js +109 -0
- package/dist/ideas.d.ts +50 -0
- package/dist/ideas.js +146 -0
- package/dist/images.d.ts +62 -0
- package/dist/images.js +241 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +22 -0
- package/dist/lint.d.ts +36 -0
- package/dist/lint.js +197 -0
- package/dist/mcp.d.ts +3 -0
- package/dist/mcp.js +303 -0
- package/dist/preview.d.ts +18 -0
- package/dist/preview.js +96 -0
- package/dist/publish.d.ts +105 -0
- package/dist/publish.js +406 -0
- package/dist/readability.d.ts +19 -0
- package/dist/readability.js +42 -0
- package/dist/render.d.ts +92 -0
- package/dist/render.js +647 -0
- package/dist/results.d.ts +89 -0
- package/dist/results.js +252 -0
- package/dist/schedule.d.ts +19 -0
- package/dist/schedule.js +114 -0
- package/dist/schema.d.ts +1159 -0
- package/dist/schema.js +211 -0
- package/dist/screenshots.d.ts +18 -0
- package/dist/screenshots.js +69 -0
- package/dist/shape.d.ts +31 -0
- package/dist/shape.js +169 -0
- package/dist/skill.d.ts +7 -0
- package/dist/skill.js +17 -0
- package/dist/templates.d.ts +47 -0
- package/dist/templates.js +330 -0
- package/dist/text.d.ts +40 -0
- package/dist/text.js +231 -0
- package/dist/themes.d.ts +43 -0
- package/dist/themes.js +202 -0
- package/dist/variants.d.ts +48 -0
- package/dist/variants.js +175 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/dist/video.d.ts +22 -0
- package/dist/video.js +59 -0
- package/dist/viral.d.ts +12 -0
- package/dist/viral.js +35 -0
- package/dist/workspace.d.ts +85 -0
- package/dist/workspace.js +322 -0
- package/package.json +65 -4
- package/skills/open-slideshow/SKILL.md +65 -0
- package/skills/open-slideshow/references/brand.md +64 -0
- package/skills/open-slideshow/references/channels.md +63 -0
- package/skills/open-slideshow/references/ideas.md +23 -0
- package/skills/open-slideshow/references/images.md +61 -0
- package/skills/open-slideshow/references/languages.md +51 -0
- package/skills/open-slideshow/references/publishing.md +70 -0
- package/skills/open-slideshow/references/results.md +47 -0
- package/skills/open-slideshow/references/review.md +81 -0
- package/skills/open-slideshow/references/screenshots.md +26 -0
- package/skills/open-slideshow/references/series.md +20 -0
- package/skills/open-slideshow/references/templates.md +96 -0
- package/skills/open-slideshow/references/troubleshooting.md +92 -0
- package/skills/open-slideshow/references/video.md +18 -0
- package/skills/open-slideshow/references/writing.md +76 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
const cover = (hint) => ({ kinds: ["cover"], label: "hook", hint, min: 1, max: 1 });
|
|
2
|
+
const appEnd = [
|
|
3
|
+
{ kinds: ["bridge"], label: "bridge", hint: "One line that turns to the app, only if it follows from the slides before.", min: 0, max: 1 },
|
|
4
|
+
{ kinds: ["screenshot"], label: "screen", hint: "The app screen that does this, in a phone (app_screenshots finds them), with one line above it.", min: 0, max: 2 },
|
|
5
|
+
{ kinds: ["app"], label: "app", hint: "The app's name and what it does for this; a short call to action in the body.", min: 0, max: 1 },
|
|
6
|
+
];
|
|
7
|
+
export const TEMPLATES = [
|
|
8
|
+
{
|
|
9
|
+
id: "tips",
|
|
10
|
+
name: "Tips",
|
|
11
|
+
description: "A hook that promises a number of tips, one tip per slide, then the app.",
|
|
12
|
+
when: "Teaching something useful. The easiest shape to save and share.",
|
|
13
|
+
hooks: ["{n} small {things} that fixed my {problem}", "Save this if you {struggle with X}", "{n} {topic} tips nobody tells beginners"],
|
|
14
|
+
slots: [cover("Promise a number and a result: '5 small habits that fixed my *sleep*'."), { kinds: ["tip"], label: "tips", hint: "One tip each: the tip as the title, why or how in the body.", min: 3, max: 7 }, ...appEnd],
|
|
15
|
+
example: (app) => [
|
|
16
|
+
{ kind: "cover", title: "3 tiny habits that fixed my *sleep*" },
|
|
17
|
+
{ kind: "tip", title: "Same wake-up time, *every* day", body: "Even on weekends. Your body clock loves boring." },
|
|
18
|
+
{ kind: "tip", title: "No screens *30 minutes* before bed", body: "Put the phone in another room. Really." },
|
|
19
|
+
{ kind: "tip", title: "Write tomorrow's list *before* bed", body: "Your brain stops rehearsing it at 2am." },
|
|
20
|
+
{ kind: "bridge", title: "I keep all of it in *one place*" },
|
|
21
|
+
{ kind: "app", title: `*${app}* reminds me every night`, body: "Free on the App Store." },
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: "mistakes",
|
|
26
|
+
name: "Mistakes",
|
|
27
|
+
description: "Things people get wrong, each with the fix, then the app.",
|
|
28
|
+
when: "Your audience already tries to do the thing and it does not work for them. Strong hooks, lots of comments.",
|
|
29
|
+
hooks: ["{n} {topic} mistakes you make every {day}", "Stop doing this if you want {result}", "I did this wrong for {time}"],
|
|
30
|
+
slots: [
|
|
31
|
+
cover("Call out the mistakes: '4 sleep mistakes you make *every night*'."),
|
|
32
|
+
{ kinds: ["tip"], label: "mistakes", hint: "The mistake as the title, the fix in the body.", min: 3, max: 5 },
|
|
33
|
+
...appEnd,
|
|
34
|
+
],
|
|
35
|
+
example: (app) => [
|
|
36
|
+
{ kind: "cover", title: "3 sleep mistakes you make *every night*" },
|
|
37
|
+
{ kind: "tip", title: "Scrolling *in bed*", body: "Your brain reads it as daytime. Leave the phone outside the room." },
|
|
38
|
+
{ kind: "tip", title: "Sleeping in on *weekends*", body: "It is jet lag you give yourself every Monday." },
|
|
39
|
+
{ kind: "tip", title: "Coffee *after 2pm*", body: "Half of it is still in you at midnight." },
|
|
40
|
+
{ kind: "bridge", title: "Fixing them is easier with a *nudge*" },
|
|
41
|
+
{ kind: "app", title: `That's what *${app}* is for`, body: "Free on the App Store." },
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: "story",
|
|
46
|
+
name: "Story",
|
|
47
|
+
description: "A personal story: the problem, what did not work, what did, then the app.",
|
|
48
|
+
when: "Founder or user stories. Feels like a person, not an ad. Works best with real photos.",
|
|
49
|
+
hooks: ["I {did X} for {time}. Here's what happened", "How I went from {before} to {after}", "Nobody warned me about {thing}"],
|
|
50
|
+
slots: [
|
|
51
|
+
cover("A personal, specific opening: 'I slept 5 hours a night for *two years*'."),
|
|
52
|
+
{ kinds: ["text", "quote"], label: "problem", hint: "What it was like. Concrete details, first person.", min: 1, max: 2 },
|
|
53
|
+
{ kinds: ["list", "text"], label: "what I tried", hint: "What did not work; a list is fine.", min: 1, max: 2 },
|
|
54
|
+
{ kinds: ["text", "tip"], label: "what worked", hint: "The turn: what finally worked and why.", min: 1, max: 2 },
|
|
55
|
+
...appEnd,
|
|
56
|
+
],
|
|
57
|
+
example: (app) => [
|
|
58
|
+
{ kind: "cover", title: "I slept 5 hours a night for *two years*" },
|
|
59
|
+
{ kind: "text", body: "Every morning felt like *jet lag*. Three alarms, two coffees, no focus by noon." },
|
|
60
|
+
{ kind: "list", title: "What I tried first", items: ["Melatonin", "Blackout curtains", "Going to bed at 9 (lol)"] },
|
|
61
|
+
{ kind: "text", body: "What worked was *boring*: same bedtime, phone out of the room, every single night." },
|
|
62
|
+
{ kind: "app", title: `I tracked it with *${app}*`, body: "Free on the App Store." },
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "before-after",
|
|
67
|
+
name: "Before / after",
|
|
68
|
+
description: "How it was, how it is now, and what changed in between.",
|
|
69
|
+
when: "A clear change you can show: a routine, a result, a screen. Good with two contrasting photos.",
|
|
70
|
+
hooks: ["My {thing}, before and after {time}", "{time} of {habit}: the honest result", "What changed when I stopped {X}"],
|
|
71
|
+
slots: [
|
|
72
|
+
cover("The change in one line: 'My nights, *before and after* 30 days'."),
|
|
73
|
+
{ kinds: ["text", "tip"], label: "before", hint: "Start with *Before:* and the honest picture.", min: 1, max: 1 },
|
|
74
|
+
{ kinds: ["text", "tip"], label: "after", hint: "Start with *After:* and the same details, changed.", min: 1, max: 1 },
|
|
75
|
+
{ kinds: ["list"], label: "what changed", hint: "The 3–5 things that made the difference.", min: 1, max: 1 },
|
|
76
|
+
...appEnd,
|
|
77
|
+
],
|
|
78
|
+
example: (app) => [
|
|
79
|
+
{ kind: "cover", title: "My nights, *before and after* 30 days" },
|
|
80
|
+
{ kind: "text", body: "*Before:* in bed at 1am, awake at 3, asleep again at 5." },
|
|
81
|
+
{ kind: "text", body: "*After:* in bed at 11, asleep by 11:20, up at 7 without an alarm." },
|
|
82
|
+
{ kind: "list", title: "What changed", items: ["Same bedtime, every night", "Phone charging in the kitchen", "No coffee after 2pm"] },
|
|
83
|
+
{ kind: "app", title: `*${app}* kept me on track`, body: "Free on the App Store." },
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: "ranking",
|
|
88
|
+
name: "Ranking",
|
|
89
|
+
description: "Options ranked, counting down to the best one.",
|
|
90
|
+
when: "Comparisons and opinions. People comment to argue with the order, which helps reach.",
|
|
91
|
+
hooks: ["{topic}, ranked from worst to best", "Every {thing} I tried, ranked", "Ranking {n} {things} so you don't have to"],
|
|
92
|
+
slots: [
|
|
93
|
+
cover("What is ranked and in which direction: 'Bedtime habits, ranked from *worst to best*'."),
|
|
94
|
+
{ kinds: ["tip"], label: "ranked items", hint: "One item each, counting down with `number` (5, 4, 3…); one line why.", min: 3, max: 10 },
|
|
95
|
+
...appEnd,
|
|
96
|
+
],
|
|
97
|
+
example: (app) => [
|
|
98
|
+
{ kind: "cover", title: "Bedtime habits, ranked from *worst to best*" },
|
|
99
|
+
{ kind: "tip", number: 4, title: "Scrolling until you *pass out*", body: "The fastest way to wake up tired." },
|
|
100
|
+
{ kind: "tip", number: 3, title: "*One more* episode", body: "It is never one." },
|
|
101
|
+
{ kind: "tip", number: 2, title: "Reading a *paper* book", body: "Ten pages and you are gone." },
|
|
102
|
+
{ kind: "tip", number: 1, title: "Same time, *every night*", body: "Boring wins. Nothing beats it." },
|
|
103
|
+
{ kind: "app", title: `*${app}* makes #1 easy`, body: "Free on the App Store." },
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: "quotes",
|
|
108
|
+
name: "Quotes",
|
|
109
|
+
description: "Lines worth saving, one per slide, then the app.",
|
|
110
|
+
when: "Motivation and mindset content. Only real quotes: the user's own words, or a person who really said it.",
|
|
111
|
+
hooks: ["Things {person} said that stuck", "{n} lines I reread when {situation}", "Advice I wish I heard at {age}"],
|
|
112
|
+
slots: [
|
|
113
|
+
cover("Why these lines matter: 'Things my sleep coach said that *stuck*'."),
|
|
114
|
+
{ kinds: ["quote"], label: "quotes", hint: "The quote as the title, who said it as author. Never invent a quote or put words in a real person's mouth.", min: 3, max: 6 },
|
|
115
|
+
...appEnd,
|
|
116
|
+
],
|
|
117
|
+
example: (app) => [
|
|
118
|
+
{ kind: "cover", title: "Things my sleep coach said that *stuck*" },
|
|
119
|
+
{ kind: "quote", title: "Your bed is for sleep. *Not* for worrying.", author: "my sleep coach" },
|
|
120
|
+
{ kind: "quote", title: "You can't catch up on sleep *on Sunday*.", author: "my sleep coach" },
|
|
121
|
+
{ kind: "quote", title: "Tired is a *schedule* problem first.", author: "my sleep coach" },
|
|
122
|
+
{ kind: "app", title: `Now I follow it with *${app}*`, body: "Free on the App Store." },
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
id: "checklist",
|
|
127
|
+
name: "Checklist",
|
|
128
|
+
description: "A short checklist people save and come back to.",
|
|
129
|
+
when: "Routines and step-by-step things. High saves.",
|
|
130
|
+
hooks: ["Save this {topic} checklist", "Your {time} {routine} in {n} steps", "Do these before {moment}"],
|
|
131
|
+
slots: [
|
|
132
|
+
cover("Tell people to save it: 'Save this *bedtime checklist*'."),
|
|
133
|
+
{ kinds: ["list"], label: "checklists", hint: "One group per slide (e.g. '1 hour before', 'In bed'), 3–5 short items.", min: 1, max: 4 },
|
|
134
|
+
...appEnd,
|
|
135
|
+
],
|
|
136
|
+
example: (app) => [
|
|
137
|
+
{ kind: "cover", title: "Save this *bedtime checklist*" },
|
|
138
|
+
{ kind: "list", title: "1 hour before", items: ["Lights down", "Last coffee was before 2pm", "Tomorrow's list written"] },
|
|
139
|
+
{ kind: "list", title: "In bed", items: ["Phone in *another* room", "Same playlist", "Same time as yesterday"] },
|
|
140
|
+
{ kind: "app", title: `*${app}* ticks it off with me`, body: "Free on the App Store." },
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: "myth-fact",
|
|
145
|
+
name: "Myth vs fact",
|
|
146
|
+
description: "Common beliefs, each followed by what is true, then the app.",
|
|
147
|
+
when: "A topic full of half-truths (sleep, money, fitness, studying). People share to correct friends.",
|
|
148
|
+
hooks: ["{n} {topic} myths you still believe", "Things everyone gets wrong about {topic}", "Myth: {belief}. Fact: (swipe)"],
|
|
149
|
+
slots: [
|
|
150
|
+
cover("Promise to correct something: '4 sleep *myths* you still believe'."),
|
|
151
|
+
{ kinds: ["tip", "text"], label: "myth and fact", hint: "*Myth:* the belief as the title, *Fact:* what is true in the body. Only facts you can stand behind.", min: 3, max: 6 },
|
|
152
|
+
...appEnd,
|
|
153
|
+
],
|
|
154
|
+
example: (app) => [
|
|
155
|
+
{ kind: "cover", title: "3 sleep *myths* you still believe" },
|
|
156
|
+
{ kind: "tip", title: "*Myth:* you can catch up on weekends", body: "*Fact:* sleeping in shifts your body clock and Monday feels like jet lag." },
|
|
157
|
+
{ kind: "tip", title: "*Myth:* a nightcap helps you sleep", body: "*Fact:* you fall asleep faster but wake up more in the second half of the night." },
|
|
158
|
+
{ kind: "tip", title: "*Myth:* 5 hours is enough for some people", body: "*Fact:* almost everyone needs 7 or more." },
|
|
159
|
+
{ kind: "app", title: `*${app}* keeps the facts simple`, body: "Free on the App Store." },
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
id: "instead",
|
|
164
|
+
name: "This instead of that",
|
|
165
|
+
description: "Swaps: what people do, and the better thing to do instead.",
|
|
166
|
+
when: "Practical, quick wins. Each slide is a small decision people can copy today.",
|
|
167
|
+
hooks: ["Do this instead of {habit}", "{n} swaps that fixed my {problem}", "Stop {X}, try {Y}"],
|
|
168
|
+
slots: [
|
|
169
|
+
cover("Promise the swaps: '5 swaps that fixed my *evenings*'."),
|
|
170
|
+
{ kinds: ["tip"], label: "swaps", hint: "*Instead of* the habit as the title, *try* the better one in the body.", min: 3, max: 6 },
|
|
171
|
+
...appEnd,
|
|
172
|
+
],
|
|
173
|
+
example: (app) => [
|
|
174
|
+
{ kind: "cover", title: "3 swaps that fixed my *evenings*" },
|
|
175
|
+
{ kind: "tip", title: "Instead of *scrolling in bed*", body: "Try 10 pages of a paper book." },
|
|
176
|
+
{ kind: "tip", title: "Instead of *coffee at 4pm*", body: "Try a 10-minute walk outside." },
|
|
177
|
+
{ kind: "tip", title: "Instead of *one more episode*", body: "Try the same bedtime as yesterday." },
|
|
178
|
+
{ kind: "app", title: `*${app}* reminds me which swap is next`, body: "Free on the App Store." },
|
|
179
|
+
],
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
id: "wish-i-knew",
|
|
183
|
+
name: "Things I wish I knew",
|
|
184
|
+
description: "Lessons learned the hard way, one per slide, in the first person.",
|
|
185
|
+
when: "Beginners in a topic follow people a few steps ahead. Feels personal and honest.",
|
|
186
|
+
hooks: ["Things I wish I knew before {starting X}", "{n} lessons from {time} of {thing}", "What {time} of {thing} taught me"],
|
|
187
|
+
slots: [
|
|
188
|
+
cover("Personal and specific: 'What 2 years of *bad sleep* taught me'."),
|
|
189
|
+
{ kinds: ["tip", "text"], label: "lessons", hint: "One lesson each, in the first person, with the detail that makes it real.", min: 3, max: 7 },
|
|
190
|
+
...appEnd,
|
|
191
|
+
],
|
|
192
|
+
example: (app) => [
|
|
193
|
+
{ kind: "cover", title: "What 2 years of *bad sleep* taught me" },
|
|
194
|
+
{ kind: "tip", title: "Tired is a *schedule* problem first", body: "My bedtime moved by 2 hours every weekend." },
|
|
195
|
+
{ kind: "tip", title: "The phone *has* to leave the room", body: "Willpower at midnight is not a plan." },
|
|
196
|
+
{ kind: "tip", title: "Boring routines *work*", body: "Same time, same playlist, same lamp." },
|
|
197
|
+
{ kind: "app", title: `I keep the routine in *${app}*`, body: "Free on the App Store." },
|
|
198
|
+
],
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
id: "how-to",
|
|
202
|
+
name: "How to, step by step",
|
|
203
|
+
description: "A goal and the numbered steps to reach it, then the app.",
|
|
204
|
+
when: "Something people want to do and do not know how. Highly saved; steps must be concrete.",
|
|
205
|
+
hooks: ["How to {result} in {n} steps", "The {n}-step {routine} I use every {day}", "{result} without {pain}: step by step"],
|
|
206
|
+
slots: [
|
|
207
|
+
cover("The result and the number of steps: 'Fall asleep in 10 minutes: *4 steps*'."),
|
|
208
|
+
{ kinds: ["tip"], label: "steps", hint: "One step each, in order, as an action: the step as the title, how in the body.", min: 3, max: 7 },
|
|
209
|
+
...appEnd,
|
|
210
|
+
],
|
|
211
|
+
example: (app) => [
|
|
212
|
+
{ kind: "cover", title: "Fall asleep in 10 minutes: *4 steps*" },
|
|
213
|
+
{ kind: "tip", title: "Dim *every* light at 10pm", body: "Your brain reads light as daytime." },
|
|
214
|
+
{ kind: "tip", title: "Write down tomorrow's *3 tasks*", body: "So you stop rehearsing them in bed." },
|
|
215
|
+
{ kind: "tip", title: "Breathe *4 in, 6 out*", body: "Five rounds. Slower than feels normal." },
|
|
216
|
+
{ kind: "tip", title: "Same sound, *every night*", body: "Your body learns it means sleep." },
|
|
217
|
+
{ kind: "app", title: `*${app}* plays the same sound for you`, body: "Free on the App Store." },
|
|
218
|
+
],
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
id: "comparison",
|
|
222
|
+
name: "Comparison",
|
|
223
|
+
description: "Two or more options side by side on the things that matter, and which one wins for whom.",
|
|
224
|
+
when: "People choosing between things. Fair comparisons get saves; never compare against a named competitor's app.",
|
|
225
|
+
hooks: ["{A} vs {B}: which one actually {result}", "I tried {A} and {B} for {time}", "{A} or {B}? Depends on this"],
|
|
226
|
+
slots: [
|
|
227
|
+
cover("The two options and the question: '*Rain* or *brown noise* for sleep?'."),
|
|
228
|
+
{ kinds: ["list", "tip"], label: "points", hint: "One thing compared per slide, or a list per option. Fair and specific.", min: 2, max: 5 },
|
|
229
|
+
{ kinds: ["text", "tip"], label: "verdict", hint: "Who should pick which, in one or two lines.", min: 1, max: 1 },
|
|
230
|
+
...appEnd,
|
|
231
|
+
],
|
|
232
|
+
example: (app) => [
|
|
233
|
+
{ kind: "cover", title: "*Rain* or *brown noise* for sleep?" },
|
|
234
|
+
{ kind: "list", title: "Rain", items: ["Changes all the time", "Good for busy minds", "Can wake light sleepers"] },
|
|
235
|
+
{ kind: "list", title: "Brown noise", items: ["Steady and deep", "Covers street noise", "Some find it dull"] },
|
|
236
|
+
{ kind: "text", body: "Light sleeper in a city? *Brown noise*. Racing thoughts? *Rain*." },
|
|
237
|
+
{ kind: "app", title: `*${app}* has both, mixed how you like`, body: "Free on the App Store." },
|
|
238
|
+
],
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
id: "pov",
|
|
242
|
+
name: "POV",
|
|
243
|
+
description: "A relatable moment in the second person, slide by slide, ending on the fix.",
|
|
244
|
+
when: "Emotional, relatable situations your audience lives through. Comments tag friends.",
|
|
245
|
+
hooks: ["POV: it's {time} and you {situation}", "POV: you finally {result}", "When you {relatable moment}"],
|
|
246
|
+
slots: [
|
|
247
|
+
cover("A moment people recognise: 'POV: it's *3am* and you're still awake'."),
|
|
248
|
+
{ kinds: ["text"], label: "moments", hint: "What happens next, one short beat per slide, in 'you'. Real details.", min: 2, max: 5 },
|
|
249
|
+
{ kinds: ["text", "tip"], label: "the fix", hint: "The turn: what finally helps.", min: 1, max: 1 },
|
|
250
|
+
...appEnd,
|
|
251
|
+
],
|
|
252
|
+
example: (app) => [
|
|
253
|
+
{ kind: "cover", title: "POV: it's *3am* and you're still awake" },
|
|
254
|
+
{ kind: "text", body: "You check the time. *3:07*. You do the math on how much sleep is left." },
|
|
255
|
+
{ kind: "text", body: "You replay a conversation from *2019*." },
|
|
256
|
+
{ kind: "text", body: "What finally helped: the *same* sound every night, so your body knows what's next." },
|
|
257
|
+
{ kind: "app", title: `That's why I made *${app}*`, body: "Free on the App Store." },
|
|
258
|
+
],
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
id: "hot-takes",
|
|
262
|
+
name: "Hot takes",
|
|
263
|
+
description: "Opinions people will argue with, each with one line of why.",
|
|
264
|
+
when: "An audience that likes to debate. Drives comments; keep it honest, never mean.",
|
|
265
|
+
hooks: ["{topic} opinions that get me in trouble", "Unpopular opinion: {take}", "{n} {topic} takes I'll defend"],
|
|
266
|
+
slots: [
|
|
267
|
+
cover("Promise opinions: 'Sleep opinions that get me *in trouble*'."),
|
|
268
|
+
{ kinds: ["tip", "text", "quote"], label: "takes", hint: "One opinion each as the title, one line of why. Things you really think.", min: 3, max: 6 },
|
|
269
|
+
...appEnd,
|
|
270
|
+
],
|
|
271
|
+
example: (app) => [
|
|
272
|
+
{ kind: "cover", title: "Sleep opinions that get me *in trouble*" },
|
|
273
|
+
{ kind: "tip", title: "Naps are *overrated*", body: "Most of us need a bedtime, not a nap." },
|
|
274
|
+
{ kind: "tip", title: "Your bed is *not* an office", body: "Laptop in bed means brain on at night." },
|
|
275
|
+
{ kind: "tip", title: "Weekends *don't* count", body: "Sleeping in is a jet lag you choose." },
|
|
276
|
+
{ kind: "app", title: `*${app}* agrees with all three`, body: "Free on the App Store." },
|
|
277
|
+
],
|
|
278
|
+
},
|
|
279
|
+
];
|
|
280
|
+
export function getTemplate(id) {
|
|
281
|
+
return TEMPLATES.find((t) => t.id === id);
|
|
282
|
+
}
|
|
283
|
+
/** The shape in one line, e.g. "cover (hook) → tip ×3–7 → bridge? → app?". */
|
|
284
|
+
export function shapeText(t) {
|
|
285
|
+
return t.slots
|
|
286
|
+
.map((s) => {
|
|
287
|
+
const k = s.kinds.join("/");
|
|
288
|
+
const n = s.min === 1 && s.max === 1 ? "" : s.min === 0 && s.max === 1 ? "?" : ` ×${s.min}${s.max > s.min ? `–${s.max}` : ""}`;
|
|
289
|
+
return `${k}${n} (${s.label})`;
|
|
290
|
+
})
|
|
291
|
+
.join(" → ");
|
|
292
|
+
}
|
|
293
|
+
/** Which slot each slide fills when the kinds follow the template in order; null when they do not. */
|
|
294
|
+
export function assignSlots(t, kinds) {
|
|
295
|
+
const out = [];
|
|
296
|
+
const go = (slot, i) => {
|
|
297
|
+
if (slot === t.slots.length)
|
|
298
|
+
return i === kinds.length;
|
|
299
|
+
const s = t.slots[slot];
|
|
300
|
+
let n = 0;
|
|
301
|
+
while (n < s.max && i + n < kinds.length && s.kinds.includes(kinds[i + n]))
|
|
302
|
+
n++;
|
|
303
|
+
// Take fewer first, so a later slot that also fits gets its slides.
|
|
304
|
+
for (let m = s.min; m <= n; m++) {
|
|
305
|
+
out.length = i;
|
|
306
|
+
for (let j = 0; j < m; j++)
|
|
307
|
+
out.push(slot);
|
|
308
|
+
if (go(slot + 1, i + m))
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
return false;
|
|
312
|
+
};
|
|
313
|
+
return go(0, 0) ? out : null;
|
|
314
|
+
}
|
|
315
|
+
/** Whether a deck's slide kinds follow the template, in order. */
|
|
316
|
+
export function followsTemplate(t, kinds) {
|
|
317
|
+
return assignSlots(t, kinds) !== null;
|
|
318
|
+
}
|
|
319
|
+
/** What the agent gets from templates_list. */
|
|
320
|
+
export function templateGuide(t) {
|
|
321
|
+
return {
|
|
322
|
+
id: t.id,
|
|
323
|
+
name: t.name,
|
|
324
|
+
description: t.description,
|
|
325
|
+
when: t.when,
|
|
326
|
+
hooks: t.hooks,
|
|
327
|
+
shape: shapeText(t),
|
|
328
|
+
slots: t.slots.map((s) => ({ kinds: s.kinds, label: s.label, count: s.min === s.max ? s.min : `${s.min}–${s.max}`, hint: s.hint })),
|
|
329
|
+
};
|
|
330
|
+
}
|
package/dist/text.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { FontRole } from "./themes.js";
|
|
2
|
+
export interface Run {
|
|
3
|
+
text: string;
|
|
4
|
+
accent: boolean;
|
|
5
|
+
}
|
|
6
|
+
export type Line = Run[];
|
|
7
|
+
/** `*word*` marks words for the accent; `\*` is a literal star. Throws on an unclosed star. */
|
|
8
|
+
export declare function parseMarkup(input: string): Run[];
|
|
9
|
+
export declare function plainText(input: string): string;
|
|
10
|
+
export declare function markupError(input: string | undefined): string | null;
|
|
11
|
+
export interface Wrapped {
|
|
12
|
+
lines: Line[];
|
|
13
|
+
/** True when a single word had to be cut to fit. */
|
|
14
|
+
broke_word: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function wrap(role: FontRole, markup: string, size: number, width: number, locale?: string): Wrapped;
|
|
17
|
+
export interface Fitted {
|
|
18
|
+
size: number;
|
|
19
|
+
lines: Line[];
|
|
20
|
+
height: number;
|
|
21
|
+
/** The text does not fit even at the smallest size. */
|
|
22
|
+
overflow: boolean;
|
|
23
|
+
broke_word: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface FitOptions {
|
|
26
|
+
max: number;
|
|
27
|
+
min: number;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
line_height: number;
|
|
31
|
+
max_lines?: number;
|
|
32
|
+
/** The deck's language, for upper-casing (Turkish i → İ). */
|
|
33
|
+
locale?: string;
|
|
34
|
+
}
|
|
35
|
+
/** The largest size at which the text fits the box without cutting a word. */
|
|
36
|
+
export declare function fit(role: FontRole, markup: string, o: FitOptions): Fitted;
|
|
37
|
+
/** Upper-cases in the deck's language; an unknown language code falls back to plain rules. */
|
|
38
|
+
export declare function upperCase(text: string, locale?: string): string;
|
|
39
|
+
/** Whether a line reads right to left (its first strong letter is Arabic or Hebrew). */
|
|
40
|
+
export declare function isRtl(text: string): boolean;
|
package/dist/text.js
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { measure } from "./fonts.js";
|
|
2
|
+
/** `*word*` marks words for the accent; `\*` is a literal star. Throws on an unclosed star. */
|
|
3
|
+
export function parseMarkup(input) {
|
|
4
|
+
const runs = [];
|
|
5
|
+
let accent = false;
|
|
6
|
+
let buf = "";
|
|
7
|
+
for (let i = 0; i < input.length; i++) {
|
|
8
|
+
const ch = input[i];
|
|
9
|
+
if (ch === "\\" && input[i + 1] === "*") {
|
|
10
|
+
buf += "*";
|
|
11
|
+
i++;
|
|
12
|
+
}
|
|
13
|
+
else if (ch === "*") {
|
|
14
|
+
if (buf)
|
|
15
|
+
runs.push({ text: buf, accent });
|
|
16
|
+
buf = "";
|
|
17
|
+
accent = !accent;
|
|
18
|
+
}
|
|
19
|
+
else
|
|
20
|
+
buf += ch;
|
|
21
|
+
}
|
|
22
|
+
if (accent)
|
|
23
|
+
throw new Error(`unclosed * in "${input}"`);
|
|
24
|
+
if (buf)
|
|
25
|
+
runs.push({ text: buf, accent });
|
|
26
|
+
return runs;
|
|
27
|
+
}
|
|
28
|
+
export function plainText(input) {
|
|
29
|
+
try {
|
|
30
|
+
return parseMarkup(input)
|
|
31
|
+
.map((r) => r.text)
|
|
32
|
+
.join("");
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return input.replace(/\*/g, "");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function markupError(input) {
|
|
39
|
+
if (!input)
|
|
40
|
+
return null;
|
|
41
|
+
try {
|
|
42
|
+
parseMarkup(input);
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
return e.message;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const CJK = /[-ヿ㐀-䶿一-鿿가-豈-]/u;
|
|
50
|
+
/** Words (or single CJK characters) with their accent runs. */
|
|
51
|
+
function pieces(runs, upper, locale) {
|
|
52
|
+
const out = [];
|
|
53
|
+
let cur = [];
|
|
54
|
+
let pendingSpace = false;
|
|
55
|
+
let pendingNewline = false;
|
|
56
|
+
const flush = () => {
|
|
57
|
+
if (cur.length)
|
|
58
|
+
out.push({ runs: cur, space: pendingSpace, newline: pendingNewline });
|
|
59
|
+
cur = [];
|
|
60
|
+
pendingSpace = false;
|
|
61
|
+
pendingNewline = false;
|
|
62
|
+
};
|
|
63
|
+
// A break with no space: ends the word being built; a space or new line already pending stays.
|
|
64
|
+
const breakHere = () => {
|
|
65
|
+
if (cur.length)
|
|
66
|
+
flush();
|
|
67
|
+
};
|
|
68
|
+
const push = (ch, accent) => {
|
|
69
|
+
const last = cur[cur.length - 1];
|
|
70
|
+
if (last && last.accent === accent)
|
|
71
|
+
last.text += ch;
|
|
72
|
+
else
|
|
73
|
+
cur.push({ text: ch, accent });
|
|
74
|
+
};
|
|
75
|
+
// Japanese breaks between phrases (a word and the particles after it), not between any two
|
|
76
|
+
// characters: the boundaries are found on the whole text, across accent runs.
|
|
77
|
+
const cased = runs.map((r) => (upper ? upperCase(r.text, locale) : r.text));
|
|
78
|
+
const bounds = KANA.test(cased.join("")) || /^ja\b/i.test(locale ?? "") ? jaPhraseBounds(cased.join("")) : null;
|
|
79
|
+
let at = 0;
|
|
80
|
+
for (const [ri, run] of runs.entries()) {
|
|
81
|
+
const text = /\p{Script=Thai}/u.test(cased[ri]) ? thaiBreaks(cased[ri]) : cased[ri];
|
|
82
|
+
for (const ch of text) {
|
|
83
|
+
if (bounds && ch !== "\u200b") {
|
|
84
|
+
if (bounds.has(at))
|
|
85
|
+
breakHere();
|
|
86
|
+
at += ch.length;
|
|
87
|
+
}
|
|
88
|
+
if (ch === "\u200b") {
|
|
89
|
+
// A break that adds no space (Thai word boundaries, or typed by the writer).
|
|
90
|
+
breakHere();
|
|
91
|
+
}
|
|
92
|
+
else if (ch === "\n") {
|
|
93
|
+
flush();
|
|
94
|
+
pendingNewline = true;
|
|
95
|
+
}
|
|
96
|
+
else if (/\s/u.test(ch)) {
|
|
97
|
+
// A new line carries over a space typed right after it, not past the next word.
|
|
98
|
+
const nl = pendingNewline && !cur.length;
|
|
99
|
+
flush();
|
|
100
|
+
pendingNewline = nl;
|
|
101
|
+
pendingSpace = !nl;
|
|
102
|
+
}
|
|
103
|
+
else if (CJK.test(ch) && !bounds) {
|
|
104
|
+
breakHere();
|
|
105
|
+
push(ch, run.accent);
|
|
106
|
+
flush();
|
|
107
|
+
}
|
|
108
|
+
else
|
|
109
|
+
push(ch, run.accent);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
flush();
|
|
113
|
+
return out;
|
|
114
|
+
}
|
|
115
|
+
const runsWidth = (role, runs, size, locale) => runs.reduce((w, r) => w + measure(role, r.text, size, locale), 0);
|
|
116
|
+
function appendRuns(line, runs, space) {
|
|
117
|
+
const add = (r) => {
|
|
118
|
+
const last = line[line.length - 1];
|
|
119
|
+
if (last && last.accent === r.accent)
|
|
120
|
+
last.text += r.text;
|
|
121
|
+
else
|
|
122
|
+
line.push({ ...r });
|
|
123
|
+
};
|
|
124
|
+
if (space && line.length)
|
|
125
|
+
add({ text: " ", accent: line[line.length - 1].accent && runs[0].accent });
|
|
126
|
+
for (const r of runs)
|
|
127
|
+
add(r);
|
|
128
|
+
}
|
|
129
|
+
/** Splits a piece wider than the line into character chunks. */
|
|
130
|
+
function splitWide(role, piece, size, width, locale) {
|
|
131
|
+
const out = [];
|
|
132
|
+
let cur = [];
|
|
133
|
+
for (const run of piece.runs)
|
|
134
|
+
for (const { segment: ch } of graphemes.segment(run.text)) {
|
|
135
|
+
const next = [...cur.map((r) => ({ ...r }))];
|
|
136
|
+
appendRuns(next, [{ text: ch, accent: run.accent }], false);
|
|
137
|
+
if (cur.length && runsWidth(role, next, size, locale) > width) {
|
|
138
|
+
out.push({ runs: cur, space: out.length === 0 ? piece.space : false, newline: out.length === 0 ? piece.newline : false });
|
|
139
|
+
cur = [{ text: ch, accent: run.accent }];
|
|
140
|
+
}
|
|
141
|
+
else
|
|
142
|
+
cur = next;
|
|
143
|
+
}
|
|
144
|
+
if (cur.length)
|
|
145
|
+
out.push({ runs: cur, space: out.length === 0 ? piece.space : false, newline: out.length === 0 ? piece.newline : false });
|
|
146
|
+
return out;
|
|
147
|
+
}
|
|
148
|
+
export function wrap(role, markup, size, width, locale) {
|
|
149
|
+
const lines = [];
|
|
150
|
+
let line = [];
|
|
151
|
+
let brokeWord = false;
|
|
152
|
+
for (const p0 of pieces(parseMarkup(markup), !!role.uppercase, locale)) {
|
|
153
|
+
const parts = runsWidth(role, p0.runs, size, locale) > width ? ((brokeWord = true), splitWide(role, p0, size, width, locale)) : [p0];
|
|
154
|
+
for (const p of parts) {
|
|
155
|
+
if (p.newline && line.length) {
|
|
156
|
+
lines.push(line);
|
|
157
|
+
line = [];
|
|
158
|
+
}
|
|
159
|
+
const candidate = line.map((r) => ({ ...r }));
|
|
160
|
+
appendRuns(candidate, p.runs, p.space);
|
|
161
|
+
if (line.length && runsWidth(role, candidate, size, locale) > width) {
|
|
162
|
+
lines.push(line);
|
|
163
|
+
line = [];
|
|
164
|
+
appendRuns(line, p.runs, false);
|
|
165
|
+
}
|
|
166
|
+
else
|
|
167
|
+
line = candidate;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (line.length)
|
|
171
|
+
lines.push(line);
|
|
172
|
+
return { lines, broke_word: brokeWord };
|
|
173
|
+
}
|
|
174
|
+
/** The largest size at which the text fits the box without cutting a word. */
|
|
175
|
+
export function fit(role, markup, o) {
|
|
176
|
+
let last = null;
|
|
177
|
+
for (let size = o.max; size >= o.min; size -= 2) {
|
|
178
|
+
const w = wrap(role, markup, size, o.width, o.locale);
|
|
179
|
+
const height = w.lines.length * size * o.line_height;
|
|
180
|
+
last = { size, lines: w.lines, height, overflow: false, broke_word: w.broke_word };
|
|
181
|
+
if (height <= o.height && !w.broke_word && (!o.max_lines || w.lines.length <= o.max_lines))
|
|
182
|
+
return last;
|
|
183
|
+
}
|
|
184
|
+
const w = wrap(role, markup, o.min, o.width, o.locale);
|
|
185
|
+
return { size: o.min, lines: w.lines, height: w.lines.length * o.min * o.line_height, overflow: true, broke_word: w.broke_word || !!last?.broke_word };
|
|
186
|
+
}
|
|
187
|
+
/** Upper-cases in the deck's language; an unknown language code falls back to plain rules. */
|
|
188
|
+
export function upperCase(text, locale) {
|
|
189
|
+
try {
|
|
190
|
+
return text.toLocaleUpperCase(locale ?? "en");
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
return text.toUpperCase();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/** Whether a line reads right to left (its first strong letter is Arabic or Hebrew). */
|
|
197
|
+
export function isRtl(text) {
|
|
198
|
+
const m = /[\p{Script=Arabic}\p{Script=Hebrew}]|[\p{L}]/u.exec(text);
|
|
199
|
+
return !!m && /[\p{Script=Arabic}\p{Script=Hebrew}]/u.test(m[0]);
|
|
200
|
+
}
|
|
201
|
+
const graphemes = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
202
|
+
const thaiWords = new Intl.Segmenter("th", { granularity: "word" });
|
|
203
|
+
const KANA = /[\p{Script=Hiragana}\p{Script=Katakana}]/u;
|
|
204
|
+
const jaWords = new Intl.Segmenter("ja", { granularity: "word" });
|
|
205
|
+
/** Marks that may not start a line, or end one (Japanese line-breaking rules). */
|
|
206
|
+
const NO_START = /^[、。,.・:;?!ー〜…‥」』)】〕〉》”’ぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮヵヶ]/u;
|
|
207
|
+
const NO_END = /[「『(【〔〈《“‘]$/u;
|
|
208
|
+
/** Where a Japanese line may break: after each phrase (a word with the particles after it), as offsets. */
|
|
209
|
+
function jaPhraseBounds(text) {
|
|
210
|
+
const phrases = [];
|
|
211
|
+
for (const { segment } of jaWords.segment(text)) {
|
|
212
|
+
const prev = phrases[phrases.length - 1];
|
|
213
|
+
const join = prev !== undefined && !/\s/u.test(segment) && !/\s$/u.test(prev) && (/^\p{Script=Hiragana}+$/u.test(segment) || NO_START.test(segment) || NO_END.test(prev) || /\p{Nd}$/u.test(prev));
|
|
214
|
+
if (join)
|
|
215
|
+
phrases[phrases.length - 1] += segment;
|
|
216
|
+
else
|
|
217
|
+
phrases.push(segment);
|
|
218
|
+
}
|
|
219
|
+
const out = new Set();
|
|
220
|
+
let at = 0;
|
|
221
|
+
for (const p of phrases) {
|
|
222
|
+
if (at > 0)
|
|
223
|
+
out.add(at);
|
|
224
|
+
at += p.length;
|
|
225
|
+
}
|
|
226
|
+
return out;
|
|
227
|
+
}
|
|
228
|
+
/** Thai has no spaces between words: mark the word boundaries so lines can break there. */
|
|
229
|
+
function thaiBreaks(text) {
|
|
230
|
+
return [...thaiWords.segment(text)].map((s) => s.segment).join("\u200b");
|
|
231
|
+
}
|
package/dist/themes.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Colors, TextStyle } from "./schema.js";
|
|
2
|
+
export type FontFamily = "TikTok Sans" | "Inter" | "Anton" | "Instrument Serif";
|
|
3
|
+
export type Design = "photo" | "magazine" | "plain";
|
|
4
|
+
export interface FontRole {
|
|
5
|
+
family: FontFamily;
|
|
6
|
+
weight: number;
|
|
7
|
+
uppercase?: boolean;
|
|
8
|
+
italic?: boolean;
|
|
9
|
+
/** Extra space between letters, in em. */
|
|
10
|
+
tracking?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface Theme {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
design: Design;
|
|
17
|
+
colors: Required<Colors>;
|
|
18
|
+
display: FontRole;
|
|
19
|
+
body: FontRole;
|
|
20
|
+
/** How words sit on a photo (photo design only). */
|
|
21
|
+
text_style: TextStyle;
|
|
22
|
+
/** How `*words*` stand out: in the accent colour, on an accent box, or underlined in the accent. */
|
|
23
|
+
accent_style: "color" | "box" | "underline";
|
|
24
|
+
align: "center" | "left";
|
|
25
|
+
/** How dark the photo gets under the words, 0 to 1. */
|
|
26
|
+
scrim: number;
|
|
27
|
+
/** Where the words sit on a photo slide, as % of the height (the middle of the block). */
|
|
28
|
+
cover_position: number;
|
|
29
|
+
tip_position: number;
|
|
30
|
+
}
|
|
31
|
+
export declare const THEMES: Theme[];
|
|
32
|
+
export declare function getTheme(id: string): Theme | undefined;
|
|
33
|
+
/** A theme with brand colours laid over it. Text on photos keeps the theme's own colours, so it stays readable. */
|
|
34
|
+
export declare function withColors(theme: Theme, colors: Colors | undefined): Theme;
|
|
35
|
+
export declare function hexToRgb(hex: string): [number, number, number];
|
|
36
|
+
export declare function rgbToHex([r, g, b]: [number, number, number]): string;
|
|
37
|
+
/** `a` moved toward `b` by `t`. */
|
|
38
|
+
export declare function mix(a: string, b: string, t: number): string;
|
|
39
|
+
export declare function luminance(hex: string): number;
|
|
40
|
+
/** WCAG contrast ratio, 1 to 21. */
|
|
41
|
+
export declare function contrast(a: string, b: string): number;
|
|
42
|
+
/** Black or white, whichever reads better on `bg`. */
|
|
43
|
+
export declare function readableOn(bg: string): string;
|