@appeeky/open-slideshow 0.1.0 → 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/README.md +93 -23
- package/dist/bin.js +0 -0
- package/dist/brand.d.ts +2 -0
- package/dist/brand.js +36 -19
- package/dist/brandkit.d.ts +50 -0
- package/dist/brandkit.js +212 -0
- package/dist/cli.js +94 -0
- package/dist/decks.js +11 -1
- package/dist/ideas.d.ts +50 -0
- package/dist/ideas.js +146 -0
- package/dist/images.d.ts +15 -2
- package/dist/images.js +23 -5
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/lint.d.ts +5 -2
- package/dist/lint.js +18 -2
- package/dist/mcp.js +72 -2
- package/dist/preview.d.ts +18 -0
- package/dist/preview.js +96 -0
- package/dist/publish.d.ts +5 -0
- package/dist/publish.js +6 -1
- package/dist/readability.d.ts +19 -0
- package/dist/readability.js +42 -0
- package/dist/render.d.ts +21 -2
- package/dist/render.js +143 -11
- package/dist/results.d.ts +89 -0
- package/dist/results.js +252 -0
- package/dist/schema.d.ts +166 -11
- package/dist/schema.js +38 -1
- package/dist/screenshots.d.ts +18 -0
- package/dist/screenshots.js +69 -0
- package/dist/templates.d.ts +4 -1
- package/dist/templates.js +145 -0
- package/dist/text.js +2 -1
- package/dist/variants.d.ts +48 -0
- package/dist/variants.js +175 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/video.d.ts +22 -0
- package/dist/video.js +59 -0
- package/dist/workspace.d.ts +5 -0
- package/dist/workspace.js +16 -0
- package/package.json +1 -1
- package/skills/open-slideshow/SKILL.md +16 -3
- package/skills/open-slideshow/references/brand.md +10 -0
- package/skills/open-slideshow/references/ideas.md +23 -0
- package/skills/open-slideshow/references/images.md +9 -1
- package/skills/open-slideshow/references/languages.md +10 -0
- package/skills/open-slideshow/references/results.md +47 -0
- package/skills/open-slideshow/references/review.md +8 -1
- 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 +37 -0
- package/skills/open-slideshow/references/troubleshooting.md +11 -1
- package/skills/open-slideshow/references/video.md +18 -0
package/dist/mcp.js
CHANGED
|
@@ -18,6 +18,15 @@ import { THEMES } from "./themes.js";
|
|
|
18
18
|
import { initWorkspace, isInside, listChannels, listDecks, loadChannel, loadDeck, openWorkspace, saveChannel, saveSettings, UserError } from "./workspace.js";
|
|
19
19
|
import { VERSION } from "./version.js";
|
|
20
20
|
import { guideText, guideTopics } from "./skill.js";
|
|
21
|
+
import { insights, recordResult, syncResults, METRICS } from "./results.js";
|
|
22
|
+
import { hookTest, listSeries, repostDeck, seriesNext, translateDeck } from "./variants.js";
|
|
23
|
+
import { addIdeas, collectIdeas, readIdeas, updateIdea } from "./ideas.js";
|
|
24
|
+
import { brandKit } from "./brandkit.js";
|
|
25
|
+
import { appScreenshots } from "./screenshots.js";
|
|
26
|
+
import { renderVideo } from "./video.js";
|
|
27
|
+
import { previewDeck } from "./preview.js";
|
|
28
|
+
import { LICENSES, setImageLicense } from "./images.js";
|
|
29
|
+
import { contactSheet } from "./render.js";
|
|
21
30
|
const text = (t) => ({ type: "text", text: t });
|
|
22
31
|
const json = (v) => text(JSON.stringify(v, null, 2));
|
|
23
32
|
async function imageContent(file, maxWidth = 1500) {
|
|
@@ -55,6 +64,7 @@ const deckFields = {
|
|
|
55
64
|
template: z.string().optional().describe("template id from templates_list; lint checks the slides follow it"),
|
|
56
65
|
language: z.string().optional(),
|
|
57
66
|
channel: z.string().optional(),
|
|
67
|
+
idea: z.string().optional().describe("the idea id from ideas_list this deck is made from; marks it used"),
|
|
58
68
|
};
|
|
59
69
|
export function createServer() {
|
|
60
70
|
const server = new McpServer({ name: "open-slideshow", version: VERSION }, {
|
|
@@ -125,6 +135,8 @@ export function createServer() {
|
|
|
125
135
|
inputSchema: { id: z.string().optional().describe("folder name; made from the topic when left out"), slides: z.array(slideSchema).min(1).max(35), ...deckFields },
|
|
126
136
|
}, wrap(async (a, ws) => {
|
|
127
137
|
const deck = newDeck(ws, a);
|
|
138
|
+
if (deck.idea && readIdeas(ws).some((i) => i.id === deck.idea))
|
|
139
|
+
updateIdea(ws, deck.idea, { status: "used", deck: deck.id });
|
|
128
140
|
const lint = await lintDeck(ws, deck);
|
|
129
141
|
return [json({ id: deck.id, file: join(ws.dir, "decks", deck.id, "deck.yaml"), errors: lint.errors, warnings: lint.warnings }), text("Next: fix errors with deck_update, then deck_render and look at the sheet.")];
|
|
130
142
|
}));
|
|
@@ -148,9 +160,9 @@ export function createServer() {
|
|
|
148
160
|
server.registerTool("deck_get", { description: "A deck's content and status.", inputSchema: { id: z.string() } }, wrap(async (a, ws) => [json({ ...loadDeck(ws, a.id), rendered: readManifest(ws, a.id) })]));
|
|
149
161
|
server.registerTool("deck_list", { description: "All decks with status and hook." }, wrap(async (_a, ws) => [json(listDecks(ws).map((d) => ({ id: d.id, status: d.deck?.status, theme: d.deck?.theme, slides: d.deck?.slides.length, hook: d.deck?.slides[0]?.title, when: d.deck?.when, error: d.error })))]));
|
|
150
162
|
server.registerTool("deck_lint", { description: "Check a deck without rendering: text that does not fit, missing images and glyphs, platform limits, banned phrases, brand rules, repeated hooks.", inputSchema: { id: z.string(), platforms: z.array(z.enum(["tiktok", "instagram"])).optional() } }, wrap(async (a, ws) => [json(await lintDeck(ws, loadDeck(ws, a.id), { platforms: a.platforms }))]));
|
|
151
|
-
server.registerTool("deck_render", { description: "Render the deck to JPEGs and return a sheet of all slides to look at. Always look at it before publishing: check that words are readable over the photos and nothing is cut.", inputSchema: { id: z.string(), slide: z.number().int().min(1).optional().describe("also return this slide (1-based) full size") } }, wrap(async (a, ws) => {
|
|
163
|
+
server.registerTool("deck_render", { description: "Render the deck to JPEGs and return a sheet of all slides to look at. Always look at it before publishing: check that words are readable over the photos and nothing is cut. safe_zones shows the sheet with TikTok's buttons and caption drawn over the slides.", inputSchema: { id: z.string(), slide: z.number().int().min(1).optional().describe("also return this slide (1-based) full size"), safe_zones: z.boolean().optional() } }, wrap(async (a, ws) => {
|
|
152
164
|
const r = await renderDeckById(ws, a.id);
|
|
153
|
-
const out = [json({ dir: r.dir, files: r.files, errors: r.lint.errors, warnings: r.lint.warnings }), await imageContent(join(r.dir, r.sheet), 1600)];
|
|
165
|
+
const out = [json({ dir: r.dir, files: r.files, errors: r.lint.errors, warnings: r.lint.warnings }), await imageContent(join(r.dir, a.safe_zones ? r.safe_sheet : r.sheet), 1600)];
|
|
154
166
|
if (a.slide && r.files[a.slide - 1])
|
|
155
167
|
out.push(await imageContent(join(r.dir, r.files[a.slide - 1]), 1080));
|
|
156
168
|
return out;
|
|
@@ -225,6 +237,64 @@ export function createServer() {
|
|
|
225
237
|
return [json(r)];
|
|
226
238
|
}));
|
|
227
239
|
server.registerTool("plan_show", { description: "The saved plan of slots." }, wrap(async (_a, ws) => [json(readPlan(ws))]));
|
|
240
|
+
// ---------- learning from results ----------
|
|
241
|
+
server.registerTool("results_sync", { description: "Bring in how published decks did (views, likes, comments, shares, saves). Decks sent as Spec drafts: from appeeky/social/posts.jsonl (run `appeeky-spec social pull` first). Decks posted through Appeeky: from Appeeky (APPEEKY_API_KEY). Others: results_record." }, wrap(async (_a, ws) => {
|
|
242
|
+
const client = process.env.APPEEKY_API_KEY ? new AppeekyClient() : undefined;
|
|
243
|
+
return [json(await syncResults(ws, client ? (id) => client.analytics(id) : undefined))];
|
|
244
|
+
}));
|
|
245
|
+
server.registerTool("results_record", { description: "Save numbers the user read off TikTok or Instagram for a deck (posted with photos, export or Postiz). One call per platform; the latest replaces the one before.", inputSchema: { id: z.string(), platform: z.enum(["tiktok", "instagram"]).optional(), ...Object.fromEntries(METRICS.map((m) => [m, z.number().int().min(0).optional()])) } }, wrap(async (a, ws) => {
|
|
246
|
+
const { id, ...m } = a;
|
|
247
|
+
const deck = recordResult(ws, id, m);
|
|
248
|
+
return [json({ id, results: deck.results })];
|
|
249
|
+
}));
|
|
250
|
+
server.registerTool("insights", { description: "What worked across measured decks: best hooks, which templates, themes, slide counts, hook kinds and posting times beat the median, hook test winners, and decks worth posting again. Read it before writing new decks; it is also in brand_context once there are results." }, wrap(async (_a, ws) => {
|
|
251
|
+
const r = insights(ws);
|
|
252
|
+
return [text(r.markdown), json({ measured: r.measured, groups: r.groups, experiments: r.experiments, repost_candidates: r.repost_candidates })];
|
|
253
|
+
}));
|
|
254
|
+
server.registerTool("hook_test", { description: "Test hooks: copies of a deck that differ only in the cover (variant a is the deck, then b, c…). Post them on different days (spread_days schedules them apart) or accounts; insights calls a winner once each has enough views.", inputSchema: { id: z.string(), hooks: z.array(z.string().min(1).max(400)).min(1).max(4), spread_days: z.number().int().min(0).max(14).optional() } }, wrap(async (a, ws) => {
|
|
255
|
+
const decks = hookTest(ws, a.id, a.hooks, { spread_days: a.spread_days });
|
|
256
|
+
return [json(decks.map((d) => ({ id: d.id, variant: d.variant, hook: d.slides.find((s) => s.kind === "cover")?.title, when: d.when }))), text("Render each and look at the covers, then publish them on different days or accounts.")];
|
|
257
|
+
}));
|
|
258
|
+
// ---------- series, translations, reposts ----------
|
|
259
|
+
server.registerTool("series_next", { description: "The next part of a series: a new deck with the same look and accounts, linked to the last one, with a 'Part N' label on its cover (label for another language, e.g. 'Bölüm {part}'). The first deck becomes part 1. Write the new part's slides.", inputSchema: { id: z.string().describe("the last part (or the deck that starts the series)"), slides: z.array(slideSchema).min(1).max(35), topic: z.string().max(200).optional(), of: z.number().int().min(2).max(99).optional(), label: z.string().max(40).optional(), when: z.string().optional() } }, wrap(async (a, ws) => {
|
|
260
|
+
const deck = seriesNext(ws, a.id, a.slides, a);
|
|
261
|
+
const lint = await lintDeck(ws, deck);
|
|
262
|
+
const first = deck.series.part === 2 ? loadDeck(ws, deck.series.id) : undefined;
|
|
263
|
+
return [json({ id: deck.id, series: deck.series, errors: lint.errors, warnings: lint.warnings }), ...(first && first.status === "draft" ? [text(`Part 1 (${first.id}) now has the series label on its cover: render it again, and make its preview or video again if you made them.`)] : [])];
|
|
264
|
+
}));
|
|
265
|
+
server.registerTool("series_list", { description: "Series and their parts, in order, with status and times." }, wrap(async (_a, ws) => [json(listSeries(ws))]));
|
|
266
|
+
server.registerTool("deck_translate", { description: "The same deck in another language: give every slide's translated words in order (kinds and list lengths must match); images and crops stay. A new deck, id <deck>-<language>. In a Spec repo, brand_context lists the store's languages.", inputSchema: { id: z.string(), language: z.string().regex(/^[a-z]{2,3}(-[A-Za-z0-9]{2,8})?$/), slides: z.array(slideSchema.partial()).min(1).max(35), caption: z.string().max(4000).optional(), hashtags: z.array(z.string()).max(30).optional(), accounts: z.array(z.string()).optional(), when: z.string().optional() } }, wrap(async (a, ws) => {
|
|
267
|
+
const deck = translateDeck(ws, a.id, a.language, a);
|
|
268
|
+
const lint = await lintDeck(ws, deck);
|
|
269
|
+
return [json({ id: deck.id, language: deck.language, errors: lint.errors, warnings: lint.warnings }), text("Render it and look: other scripts can need a theme with TikTok Sans or Inter.")];
|
|
270
|
+
}));
|
|
271
|
+
server.registerTool("deck_repost", { description: "Post a deck that did well again, at least 30 days later, with a hook nobody has seen (required) and optionally the middle slides in a new order. insights lists candidates.", inputSchema: { id: z.string(), hook: z.string().min(1).max(400), order: z.array(z.number().int().min(0)).optional().describe("every slide index once, cover first"), min_days: z.number().int().min(7).max(365).optional() } }, wrap(async (a, ws) => {
|
|
272
|
+
const deck = repostDeck(ws, a.id, a.hook, a);
|
|
273
|
+
return [json({ id: deck.id, repost_of: deck.repost_of })];
|
|
274
|
+
}));
|
|
275
|
+
// ---------- screenshots, brand kit ----------
|
|
276
|
+
server.registerTool("app_screenshots", { description: "The app's own screenshots, imported to use in a screenshot slide (kind screenshot, image = the ref): from appeeky/screenshots in a Spec repo, otherwise from the App Store listing. Returns a sheet to pick from.", inputSchema: { limit: z.number().int().min(1).max(10).optional(), locale: z.string().optional() } }, wrap(async (a, ws) => {
|
|
277
|
+
const r = await appScreenshots(ws, a);
|
|
278
|
+
const { readFileSync } = await import("node:fs");
|
|
279
|
+
const sheet = await contactSheet(r.images.map((m) => readFileSync(join(ws.dir, "images", m.ref))), "9:16", Math.min(r.images.length, 5), r.images.map((m, i) => `${i + 1}. ${m.ref}`));
|
|
280
|
+
return [json({ source: r.source, images: r.images.map((m) => ({ ref: m.ref, width: m.width, height: m.height, note: m.note })) }), { type: "image", data: sheet.toString("base64"), mimeType: "image/jpeg" }];
|
|
281
|
+
}));
|
|
282
|
+
server.registerTool("brand_kit", { description: "Brand colours, fonts and logo from the app's website (url, or the App Store seller site), plus colours named in a Spec playbook. Shows a proposal with contrast checked; apply: true saves the colours and imports the logo as the icon. Show the proposal to the user before applying.", inputSchema: { url: z.string().optional(), apply: z.boolean().optional() } }, wrap(async (a, ws) => [json(await brandKit(ws, a))]));
|
|
283
|
+
server.registerTool("image_license", { description: `Record who may post an image: own (the user's), licensed (bought or permission given), cc0, pdm, by-4.0… or unknown. Images with an unknown license cannot be published. Only set what the user tells you.`, inputSchema: { ref: z.string(), license: z.enum(LICENSES), author: z.string().max(200).optional(), note: z.string().max(300).optional() } }, wrap(async (a, ws) => [json(setImageLicense(ws, a.ref, a.license, a))]));
|
|
284
|
+
// ---------- ideas ----------
|
|
285
|
+
server.registerTool("ideas_collect", { description: "Fill the idea queue from what is already known: questions in comments, wishes and praise in reviews, the listing's features, playbook wins, channel topics not used yet. Nothing is sent anywhere.", inputSchema: { offline: z.boolean().optional(), limit: z.number().int().min(1).max(50).optional() } }, wrap(async (a, ws) => {
|
|
286
|
+
const r = await collectIdeas(ws, a);
|
|
287
|
+
return [json(r), text("Pick one with the user, write a deck from it (deck_create with idea: <id>), and stay true to the evidence.")];
|
|
288
|
+
}));
|
|
289
|
+
server.registerTool("ideas_list", { description: "The idea queue, newest first.", inputSchema: { status: z.enum(["new", "used", "skipped"]).optional() } }, wrap(async (a, ws) => [json(readIdeas(ws).filter((i) => !a.status || i.status === a.status).reverse())]));
|
|
290
|
+
server.registerTool("idea_add", { description: "Add an idea the user gave (or one from viral_search patterns) to the queue.", inputSchema: { text: z.string().min(1).max(400), source: z.string().max(40).optional(), evidence: z.string().max(600).optional() } }, wrap(async (a, ws) => [json(addIdeas(ws, [{ text: a.text, source: a.source ?? "user", ...(a.evidence ? { evidence: a.evidence } : {}) }]))]));
|
|
291
|
+
server.registerTool("idea_update", { description: "Mark an idea used (with its deck) or skipped.", inputSchema: { id: z.string(), status: z.enum(["new", "used", "skipped"]), deck: z.string().optional() } }, wrap(async (a, ws) => [json(updateIdea(ws, a.id, a))]));
|
|
292
|
+
// ---------- preview and video ----------
|
|
293
|
+
server.registerTool("deck_preview", { description: "A page that shows the rendered deck on a phone (swipe, caption, TikTok's buttons on a toggle): renders/preview.html. gif adds a small looping preview.gif for a pull request or a chat.", inputSchema: { id: z.string(), gif: z.boolean().optional() } }, wrap(async (a, ws) => {
|
|
294
|
+
const r = await previewDeck(ws, a.id, a);
|
|
295
|
+
return [json(r), text(`Open ${r.html} in a browser.`)];
|
|
296
|
+
}));
|
|
297
|
+
server.registerTool("deck_video", { description: "The rendered deck as a short MP4 (renders/video.mp4) for Reels, Shorts or a TikTok video: each slide for seconds (default 2.5), a soft fade, 9:16, no sound (add music in the app). Needs ffmpeg on the machine.", inputSchema: { id: z.string(), seconds: z.number().min(1).max(10).optional(), fade: z.number().min(0).max(1).optional(), size: sizeSchema.optional() } }, wrap(async (a, ws) => [json(await renderVideo(ws, a.id, a))]));
|
|
228
298
|
return server;
|
|
229
299
|
}
|
|
230
300
|
export async function startMcp() {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SIZES } from "./schema.js";
|
|
2
|
+
import { type Workspace } from "./workspace.js";
|
|
3
|
+
/** A page that shows the deck the way it looks on a phone: swipe (or arrow keys), caption below, TikTok's buttons on a toggle. */
|
|
4
|
+
export declare function previewHtml(deck: {
|
|
5
|
+
id: string;
|
|
6
|
+
size: keyof typeof SIZES;
|
|
7
|
+
}, files: string[], caption: string, handle?: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* A preview to review before posting: preview.html (open it in a browser) and, with gif, a small
|
|
10
|
+
* looping preview.gif for a pull request or a chat.
|
|
11
|
+
*/
|
|
12
|
+
export declare function previewDeck(ws: Workspace, id: string, opts?: {
|
|
13
|
+
gif?: boolean;
|
|
14
|
+
seconds?: number;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
html: string;
|
|
17
|
+
gif?: string;
|
|
18
|
+
}>;
|
package/dist/preview.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import sharp from "sharp";
|
|
4
|
+
import { freshRenders } from "./decks.js";
|
|
5
|
+
import { captionText } from "./lint.js";
|
|
6
|
+
import { tiktokZones } from "./readability.js";
|
|
7
|
+
import { SIZES } from "./schema.js";
|
|
8
|
+
import { loadDeck, rendersDir, writeAtomic } from "./workspace.js";
|
|
9
|
+
const esc = (s) => s.replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
10
|
+
/** A page that shows the deck the way it looks on a phone: swipe (or arrow keys), caption below, TikTok's buttons on a toggle. */
|
|
11
|
+
export function previewHtml(deck, files, caption, handle) {
|
|
12
|
+
const { width: W, height: H } = SIZES[deck.size];
|
|
13
|
+
const zones = tiktokZones(deck.size)
|
|
14
|
+
.map((z) => `<div class="zone" style="left:${((z.x0 / W) * 100).toFixed(2)}%;top:${((z.y0 / H) * 100).toFixed(2)}%;width:${(((z.x1 - z.x0) / W) * 100).toFixed(2)}%;height:${(((z.y1 - z.y0) / H) * 100).toFixed(2)}%" title="${esc(z.label)}"></div>`)
|
|
15
|
+
.join("");
|
|
16
|
+
const slides = files.map((f, i) => `<figure class="slide"><img src="${esc(f)}" alt="Slide ${i + 1}" loading="${i < 2 ? "eager" : "lazy"}"><div class="zones">${zones}</div></figure>`).join("\n");
|
|
17
|
+
return `<!doctype html>
|
|
18
|
+
<html lang="en">
|
|
19
|
+
<head>
|
|
20
|
+
<meta charset="utf-8">
|
|
21
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
22
|
+
<title>${esc(deck.id)}: preview</title>
|
|
23
|
+
<style>
|
|
24
|
+
:root { color-scheme: dark; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
|
|
25
|
+
body { margin: 0; min-height: 100vh; display: grid; place-items: center; background: #1b1b1d; color: #f2f2f2; }
|
|
26
|
+
.phone { width: min(390px, 92vw); aspect-ratio: 9 / 19.5; background: #000; border-radius: 48px; padding: 14px; box-sizing: border-box; box-shadow: 0 30px 80px rgba(0,0,0,.5); display: flex; flex-direction: column; }
|
|
27
|
+
.screen { position: relative; flex: 1; border-radius: 36px; overflow: hidden; background: #000; display: flex; flex-direction: column; justify-content: center; }
|
|
28
|
+
.track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
|
|
29
|
+
.track::-webkit-scrollbar { display: none; }
|
|
30
|
+
.slide { position: relative; flex: 0 0 100%; margin: 0; scroll-snap-align: center; aspect-ratio: ${W} / ${H}; }
|
|
31
|
+
.slide img { width: 100%; height: 100%; display: block; }
|
|
32
|
+
.zones { position: absolute; inset: 0; display: none; pointer-events: none; }
|
|
33
|
+
.show-zones .zones { display: block; }
|
|
34
|
+
.zone { position: absolute; background: rgba(255,45,85,.28); outline: 2px solid #ff2d55; }
|
|
35
|
+
.dots { position: absolute; bottom: 12px; left: 0; right: 0; display: flex; justify-content: center; gap: 5px; }
|
|
36
|
+
.dot { width: 6px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.4); }
|
|
37
|
+
.dot.on { background: #fff; }
|
|
38
|
+
.meta { width: min(390px, 92vw); margin-top: 16px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; }
|
|
39
|
+
.meta b { display: block; margin-bottom: 4px; }
|
|
40
|
+
.bar { display: flex; gap: 8px; margin-top: 12px; }
|
|
41
|
+
button { font: inherit; font-size: 13px; padding: 8px 12px; border-radius: 8px; border: 1px solid #444; background: #2a2a2d; color: inherit; cursor: pointer; }
|
|
42
|
+
button:focus-visible { outline: 2px solid #8ab4ff; outline-offset: 2px; }
|
|
43
|
+
</style>
|
|
44
|
+
</head>
|
|
45
|
+
<body>
|
|
46
|
+
<main>
|
|
47
|
+
<div class="phone"><div class="screen" id="screen">
|
|
48
|
+
<div class="track" id="track" tabindex="0" aria-label="Slides, swipe or use the arrow keys">${slides}</div>
|
|
49
|
+
<div class="dots" id="dots">${files.map((_, i) => `<span class="dot${i === 0 ? " on" : ""}"></span>`).join("")}</div>
|
|
50
|
+
</div></div>
|
|
51
|
+
<div class="meta"><b>${esc(handle ?? deck.id)}</b>${esc(caption)}</div>
|
|
52
|
+
<div class="bar">
|
|
53
|
+
<button type="button" id="prev">Previous</button>
|
|
54
|
+
<button type="button" id="next">Next</button>
|
|
55
|
+
<button type="button" id="zones" aria-pressed="false">Show TikTok's buttons</button>
|
|
56
|
+
</div>
|
|
57
|
+
</main>
|
|
58
|
+
<script>
|
|
59
|
+
const track = document.getElementById("track");
|
|
60
|
+
const dots = [...document.querySelectorAll(".dot")];
|
|
61
|
+
const go = (d) => track.scrollBy({ left: d * track.clientWidth, behavior: "smooth" });
|
|
62
|
+
document.getElementById("prev").onclick = () => go(-1);
|
|
63
|
+
document.getElementById("next").onclick = () => go(1);
|
|
64
|
+
track.addEventListener("keydown", (e) => { if (e.key === "ArrowRight") go(1); if (e.key === "ArrowLeft") go(-1); });
|
|
65
|
+
track.addEventListener("scroll", () => { const i = Math.round(track.scrollLeft / track.clientWidth); dots.forEach((d, j) => d.classList.toggle("on", i === j)); });
|
|
66
|
+
const z = document.getElementById("zones");
|
|
67
|
+
z.onclick = () => { const on = document.getElementById("screen").classList.toggle("show-zones"); z.setAttribute("aria-pressed", String(on)); z.textContent = on ? "Hide TikTok's buttons" : "Show TikTok's buttons"; };
|
|
68
|
+
</script>
|
|
69
|
+
</body>
|
|
70
|
+
</html>
|
|
71
|
+
`;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A preview to review before posting: preview.html (open it in a browser) and, with gif, a small
|
|
75
|
+
* looping preview.gif for a pull request or a chat.
|
|
76
|
+
*/
|
|
77
|
+
export async function previewDeck(ws, id, opts = {}) {
|
|
78
|
+
const deck = loadDeck(ws, id);
|
|
79
|
+
const manifest = freshRenders(ws, deck);
|
|
80
|
+
const dir = rendersDir(ws, id);
|
|
81
|
+
const html = join(dir, "preview.html");
|
|
82
|
+
writeAtomic(html, previewHtml(deck, manifest.files, captionText(deck), ws.settings.brand.handle ? `@${ws.settings.brand.handle.replace(/^@/, "")}` : ws.settings.brand.name || ws.settings.app.name));
|
|
83
|
+
if (!opts.gif)
|
|
84
|
+
return { html };
|
|
85
|
+
const { width: W, height: H } = SIZES[deck.size];
|
|
86
|
+
const w = 360;
|
|
87
|
+
const h = Math.round((H / W) * w);
|
|
88
|
+
const frames = await Promise.all(manifest.files.map((f) => sharp(readFileSync(join(dir, f))).resize(w, h).png().toBuffer()));
|
|
89
|
+
const delay = Math.round((opts.seconds ?? 1.6) * 1000);
|
|
90
|
+
const gif = await sharp(frames, { join: { animated: true } })
|
|
91
|
+
.gif({ delay: frames.map(() => delay), loop: 0, effort: 7 })
|
|
92
|
+
.toBuffer();
|
|
93
|
+
const file = join(dir, "preview.gif");
|
|
94
|
+
writeAtomic(file, gif);
|
|
95
|
+
return { html, gif: file };
|
|
96
|
+
}
|
package/dist/publish.d.ts
CHANGED
|
@@ -73,6 +73,11 @@ export declare class AppeekyClient {
|
|
|
73
73
|
posts: ViralPost[];
|
|
74
74
|
}>;
|
|
75
75
|
accounts(): Promise<Account[]>;
|
|
76
|
+
/** How a post did on each platform it went to. */
|
|
77
|
+
analytics(postId: string): Promise<{
|
|
78
|
+
platform: string;
|
|
79
|
+
analytics: Record<string, unknown>;
|
|
80
|
+
}[]>;
|
|
76
81
|
upload(file: string): Promise<string>;
|
|
77
82
|
createPost(body: Record<string, unknown>): Promise<string>;
|
|
78
83
|
}
|
package/dist/publish.js
CHANGED
|
@@ -62,7 +62,7 @@ function alreadyPublished(deck, provider, hash) {
|
|
|
62
62
|
export async function publishDeck(ws, id, o) {
|
|
63
63
|
let deck = loadDeck(ws, id);
|
|
64
64
|
const manifest = freshRenders(ws, deck);
|
|
65
|
-
const lint = await lintDeck(ws, deck);
|
|
65
|
+
const lint = await lintDeck(ws, deck, { publishing: o.provider !== "export" });
|
|
66
66
|
if (!lint.ok && o.provider !== "export")
|
|
67
67
|
throw new UserError(`fix these first:\n${lint.errors.map((e) => `- ${e.message}`).join("\n")}`);
|
|
68
68
|
const files = manifest.files.map((f) => join(rendersDir(ws, id), f));
|
|
@@ -246,6 +246,11 @@ export class AppeekyClient {
|
|
|
246
246
|
return { id: r.id, platform: r.platform, name: r.displayName || r.platformUserId || r.platform, active: !problem, ...(problem ? { problem } : {}) };
|
|
247
247
|
});
|
|
248
248
|
}
|
|
249
|
+
/** How a post did on each platform it went to. */
|
|
250
|
+
async analytics(postId) {
|
|
251
|
+
const data = await this.call(`/social/posts/${encodeURIComponent(postId)}/analytics`);
|
|
252
|
+
return data?.analytics ?? [];
|
|
253
|
+
}
|
|
249
254
|
async upload(file) {
|
|
250
255
|
const form = new FormData();
|
|
251
256
|
form.append("file", new Blob([readFileSync(file)], { type: "image/jpeg" }), file.split("/").pop());
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type SizeId } from "./schema.js";
|
|
2
|
+
import type { LineRect, SlideIssue } from "./render.js";
|
|
3
|
+
export interface Zone {
|
|
4
|
+
/** What the app draws there. */
|
|
5
|
+
label: string;
|
|
6
|
+
x0: number;
|
|
7
|
+
y0: number;
|
|
8
|
+
x1: number;
|
|
9
|
+
y1: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Where TikTok draws its own buttons and text over a photo post, in slide pixels. A 4:5 or 1:1
|
|
13
|
+
* slide is shown full width in the middle of a 9:16 screen, so the screen's zones are moved onto it.
|
|
14
|
+
*/
|
|
15
|
+
export declare function tiktokZones(size: SizeId): Zone[];
|
|
16
|
+
/** Lines of text that sit under TikTok's buttons or caption. */
|
|
17
|
+
export declare function tiktokIssues(lines: LineRect[] | undefined, size: SizeId, index: number): SlideIssue[];
|
|
18
|
+
/** The slides with TikTok's zones drawn over them, so a person can see what the app covers. */
|
|
19
|
+
export declare function safeZoneSlide(jpg: Buffer, size: SizeId): Promise<Buffer>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import sharp from "sharp";
|
|
2
|
+
import { SIZES } from "./schema.js";
|
|
3
|
+
/**
|
|
4
|
+
* Where TikTok draws its own buttons and text over a photo post, in slide pixels. A 4:5 or 1:1
|
|
5
|
+
* slide is shown full width in the middle of a 9:16 screen, so the screen's zones are moved onto it.
|
|
6
|
+
*/
|
|
7
|
+
export function tiktokZones(size) {
|
|
8
|
+
const { width: W, height: H } = SIZES[size];
|
|
9
|
+
const screenH = Math.round((W * 16) / 9);
|
|
10
|
+
const offset = Math.round((screenH - H) / 2);
|
|
11
|
+
const toSlide = (y) => Math.min(H, Math.max(0, Math.round(y * screenH - offset)));
|
|
12
|
+
const zones = [
|
|
13
|
+
{ label: "like, comment and share buttons", x0: Math.round(W * 0.87), y0: toSlide(0.42), x1: W, y1: toSlide(0.9) },
|
|
14
|
+
{ label: "caption and account name", x0: 0, y0: toSlide(0.8), x1: W, y1: H },
|
|
15
|
+
{ label: "top tabs", x0: 0, y0: 0, x1: W, y1: toSlide(0.085) },
|
|
16
|
+
];
|
|
17
|
+
return zones.filter((z) => z.y1 - z.y0 > 4);
|
|
18
|
+
}
|
|
19
|
+
const overlaps = (r, z) => r.x0 < z.x1 && r.x1 > z.x0 && r.y0 < z.y1 && r.y1 > z.y0;
|
|
20
|
+
/** Lines of text that sit under TikTok's buttons or caption. */
|
|
21
|
+
export function tiktokIssues(lines, size, index) {
|
|
22
|
+
if (!lines?.length)
|
|
23
|
+
return [];
|
|
24
|
+
const out = [];
|
|
25
|
+
for (const z of tiktokZones(size)) {
|
|
26
|
+
const hit = lines.filter((l) => overlaps(l, z));
|
|
27
|
+
if (!hit.length)
|
|
28
|
+
continue;
|
|
29
|
+
const fix = z.label.startsWith("like") ? `shorten the long lines (photo themes can also move the words with text_position)${size === "9:16" ? "" : ", or use 9:16"}` : "move the words toward the middle (text_position on photo themes) or cut words";
|
|
30
|
+
out.push({ slide: index, level: "warning", code: "tiktok-ui", message: `slide ${index + 1}: ${hit.length} line${hit.length === 1 ? "" : "s"} of text ${hit.length === 1 ? "sits" : "sit"} under TikTok's ${z.label}; ${fix}` });
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
/** The slides with TikTok's zones drawn over them, so a person can see what the app covers. */
|
|
35
|
+
export async function safeZoneSlide(jpg, size) {
|
|
36
|
+
const { width: W, height: H } = SIZES[size];
|
|
37
|
+
const rects = tiktokZones(size)
|
|
38
|
+
.map((z) => `<rect x="${z.x0}" y="${z.y0}" width="${z.x1 - z.x0}" height="${z.y1 - z.y0}" fill="#ff2d55" fill-opacity="0.28" stroke="#ff2d55" stroke-width="4"/>`)
|
|
39
|
+
.join("");
|
|
40
|
+
const svg = Buffer.from(`<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}">${rects}</svg>`);
|
|
41
|
+
return sharp(jpg).composite([{ input: svg }]).jpeg({ quality: 85 }).toBuffer();
|
|
42
|
+
}
|
package/dist/render.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Deck, type Slide, type SizeId } from "./schema.js";
|
|
1
|
+
import { type Deck, type Series, type Slide, type SizeId } from "./schema.js";
|
|
2
2
|
import { type Theme } from "./themes.js";
|
|
3
3
|
export declare const RENDERER_VERSION = "1";
|
|
4
4
|
type Style = Record<string, string | number | undefined>;
|
|
@@ -44,18 +44,33 @@ interface Frame {
|
|
|
44
44
|
bottom: number;
|
|
45
45
|
}
|
|
46
46
|
export declare function frameFor(size: SizeId): Frame;
|
|
47
|
+
/** Body text under this size (on a 1080-wide slide) is hard to read on a phone. */
|
|
48
|
+
export declare const SMALL_TEXT = 38;
|
|
49
|
+
/** Where a line of text ends up on the slide, in pixels: for the readability checks. */
|
|
50
|
+
export interface LineRect {
|
|
51
|
+
x0: number;
|
|
52
|
+
y0: number;
|
|
53
|
+
x1: number;
|
|
54
|
+
y1: number;
|
|
55
|
+
}
|
|
47
56
|
export interface Laid {
|
|
48
57
|
tree: El;
|
|
49
58
|
issues: SlideIssue[];
|
|
59
|
+
/** Every line of text, where it is drawn. */
|
|
60
|
+
lines?: LineRect[];
|
|
50
61
|
}
|
|
51
62
|
interface SlideArgs {
|
|
52
|
-
deck: Pick<Deck, "full_cover" | "text_style" | "show_handle"
|
|
63
|
+
deck: Pick<Deck, "full_cover" | "text_style" | "show_handle"> & {
|
|
64
|
+
series?: Series;
|
|
65
|
+
};
|
|
53
66
|
slide: Slide;
|
|
54
67
|
index: number;
|
|
55
68
|
tipNumber?: number;
|
|
56
69
|
/** Only plan the text (for lint): no images are read. */
|
|
57
70
|
dry?: boolean;
|
|
58
71
|
}
|
|
72
|
+
/** "Part 2", "Part 2/5" or the series' own label, filled in. */
|
|
73
|
+
export declare function seriesLabel(s: Series): string;
|
|
59
74
|
export declare function tipNumbers(slides: Slide[]): (number | undefined)[];
|
|
60
75
|
export declare function laySlide(ctx: RenderContext, a: SlideArgs): Promise<Laid>;
|
|
61
76
|
export declare function rasterize(tree: El, size: SizeId, quality?: number): Promise<Buffer>;
|
|
@@ -63,8 +78,12 @@ export declare function themeFor(deck: Pick<Deck, "theme" | "colors">): Theme;
|
|
|
63
78
|
export interface RenderResult {
|
|
64
79
|
files: string[];
|
|
65
80
|
sheet: string;
|
|
81
|
+
/** The sheet with TikTok's buttons and caption drawn over the slides. */
|
|
82
|
+
safe_sheet: string;
|
|
66
83
|
hash: string;
|
|
67
84
|
issues: SlideIssue[];
|
|
85
|
+
/** Where each slide's lines of text landed, as drawn. */
|
|
86
|
+
lines: (LineRect[] | undefined)[];
|
|
68
87
|
}
|
|
69
88
|
export declare function renderHash(deck: Deck, ctx: RenderContext): string;
|
|
70
89
|
export declare function renderDeck(deck: Deck, ctx: RenderContext, outDir: string): Promise<RenderResult>;
|