@hypersocial/decks-cli 0.9.24 → 0.9.26
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/package.json +1 -1
- package/skills/hyperdecks/SKILL.md +74 -8
- package/skills/hyperdecks/chat.md +3 -3
- package/skills/hyperdecks/terminal.md +3 -2
- package/src/answersCsv.mjs +21 -0
- package/src/check.mjs +125 -19
- package/src/checkRules.mjs +273 -18
- package/src/commands.mjs +92 -4
- package/src/embedCapture.mjs +126 -0
- package/src/embedSources.mjs +252 -0
- package/src/embedsGuide.mjs +36 -0
- package/src/files.mjs +3 -0
- package/src/guide.mjs +16 -7
- package/src/layoutRoutes.mjs +7 -1
- package/src/layouts.mjs +8 -3
- package/src/ops.mjs +138 -1
- package/src/picturesGuide.mjs +1 -0
- package/src/preview-capture.mjs +70 -1
- package/src/questionFit.mjs +23 -0
- package/src/runtime.mjs +7 -2
- package/templates/layouts/_deck.html +61 -12
- package/templates/layouts/bento.html +8 -6
- package/templates/layouts/closer.html +4 -2
- package/templates/layouts/cover-band.html +3 -1
- package/templates/layouts/cover-frame.html +8 -2
- package/templates/layouts/cover-poster.html +8 -2
- package/templates/layouts/cover-split.html +13 -2
- package/templates/layouts/cover-type.html +6 -3
- package/templates/layouts/embed.html +93 -0
- package/templates/layouts/features.html +12 -6
- package/templates/layouts/funnel.html +24 -5
- package/templates/layouts/hero.html +2 -2
- package/templates/layouts/lanes.html +18 -6
- package/templates/layouts/number.html +6 -3
- package/templates/layouts/phone-stage.html +13 -3
- package/templates/layouts/picture-full.html +13 -3
- package/templates/layouts/portrait.html +8 -0
- package/templates/layouts/question-choice.html +126 -0
- package/templates/layouts/question-text.html +89 -0
- package/templates/layouts/quote.html +7 -3
- package/templates/layouts/rail.html +7 -4
- package/templates/layouts/scorecard.html +18 -5
- package/templates/layouts/sentence.html +2 -2
- package/templates/layouts/split.html +14 -1
- package/templates/layouts/spotlight.html +4 -1
- package/templates/layouts/stack.html +3 -2
- package/templates/layouts/staircase.html +34 -5
- package/templates/layouts/strike.html +8 -2
- package/templates/layouts/team.html +22 -5
- package/templates/layouts/timeline.html +5 -2
- package/templates/layouts/two-bars.html +10 -1
- package/templates/layouts/two-by-two.html +22 -4
- package/templates/layouts/video-full.html +5 -4
- package/templates/layouts/wall.html +39 -11
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// The embed slide's still (docs/roadmap/embed-slide-a-still-first-live-on-tap-maps-video-figma-booki.md), made
|
|
2
|
+
// two ways, and refused loudly rather than saved when it shows an error or a consent banner:
|
|
3
|
+
// - a video or a Figma file: the picture its own site publishes for it (publishedStill), fetched, no browser;
|
|
4
|
+
// - a map, a booking page or any other page: the page as its frame shows it, inside an iframe (framedStill), in
|
|
5
|
+
// this machine's isolated Chromium (`hyperdecks preview setup`) or, without one, on the app's renderer
|
|
6
|
+
// (app/api/render/screenshot, which wraps an embed URL the same way).
|
|
7
|
+
import { PHONE_STILL, STILL_HEIGHT, STILL_WIDTH, embedErrorIn, framePage, framePass, stillSource } from "./embedSources.mjs";
|
|
8
|
+
|
|
9
|
+
const TYPES = { "image/jpeg": "jpg", "image/png": "png", "image/webp": "webp", "image/gif": "gif" };
|
|
10
|
+
|
|
11
|
+
// { bytes, contentType, title } for a source that publishes a picture of itself, null for one that does not
|
|
12
|
+
// (a map, a booking page). Throws with the source's own answer when it will not give one (private, not
|
|
13
|
+
// embeddable, gone), so the author knows the live frame would fail too.
|
|
14
|
+
export async function publishedStill(resolved, { fetchImpl = fetch } = {}) {
|
|
15
|
+
const from = stillSource(resolved);
|
|
16
|
+
if (!from) return null;
|
|
17
|
+
let title = null, images = from.images ?? [];
|
|
18
|
+
if (from.oembed) {
|
|
19
|
+
const res = await fetchImpl(from.oembed, { headers: { accept: "application/json" }, signal: AbortSignal.timeout(15000) });
|
|
20
|
+
if (!res.ok) {
|
|
21
|
+
const why = res.status === 401 || res.status === 403 ? "it is private, or its owner does not allow embedding" : res.status === 404 ? "it is not public or does not exist" : `its site answered ${res.status}`;
|
|
22
|
+
throw new Error(`${resolved.name} will not show this link in a frame: ${why}. Share it publicly (anyone with the link) or pick another (${resolved.href})`);
|
|
23
|
+
}
|
|
24
|
+
const info = await res.json();
|
|
25
|
+
title = info.title ?? null;
|
|
26
|
+
if (info.thumbnail_url && !images.length) images = [info.thumbnail_url];
|
|
27
|
+
}
|
|
28
|
+
for (const url of images) {
|
|
29
|
+
const res = await fetchImpl(url, { signal: AbortSignal.timeout(15000) });
|
|
30
|
+
if (!res.ok) continue;
|
|
31
|
+
const bytes = new Uint8Array(await res.arrayBuffer());
|
|
32
|
+
// The picture is what its bytes say, not its header (Loom serves a PNG as image/jpeg): its file is named for that.
|
|
33
|
+
const contentType = sniffType(bytes) ?? (res.headers.get("content-type") ?? "").split(";")[0].trim();
|
|
34
|
+
if (!TYPES[contentType]) continue;
|
|
35
|
+
// YouTube answers a missing maxresdefault with a small grey stand-in, not a 404.
|
|
36
|
+
if (resolved.source === "youtube" && bytes.length < 5000) continue;
|
|
37
|
+
return { bytes, contentType, title, ...imageSize(bytes) };
|
|
38
|
+
}
|
|
39
|
+
throw new Error(`${resolved.name} published no picture for this link (${resolved.href}); capture the page instead, or pick another link`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// What a capture must not be saved as: a page that answered an error (`statuses`, the page's or its frame's
|
|
43
|
+
// documents), a frame that said an error, a blank one, or one a consent banner stayed over. Null when it is clean.
|
|
44
|
+
export function stillProblem(frames, name, { statuses = /** @type {number[]} */ ([]) } = {}) {
|
|
45
|
+
const bad = statuses.find((n) => n >= 400);
|
|
46
|
+
if (bad) return `the ${name} page answered ${bad}${bad === 404 ? " (not found)" : ""}, so there is no still to save; check the link`;
|
|
47
|
+
for (const f of frames) {
|
|
48
|
+
const err = embedErrorIn(f.text);
|
|
49
|
+
if (err) return `the ${name} frame showed an error instead of the page ("${(f.text.match(new RegExp(err, "i")) ?? [err])[0]}"), so there is no still to save; check the link is public and can be embedded`;
|
|
50
|
+
}
|
|
51
|
+
const drawn = frames.filter((f) => !f.wrapper);
|
|
52
|
+
if (drawn.length && drawn.every((f) => !String(f.text ?? "").trim() && !f.media)) return `the ${name} page drew nothing (a blank frame), so there is no still to save; check the link opens in a browser`;
|
|
53
|
+
if (frames.some((f) => f.overlay && !f.wrapper)) return `the ${name} page has a banner or panel over more than a quarter of it (a fundraising, newsletter or sign-up appeal), so the still would show it; capture it yourself and upload it with \`hyperdecks asset add\``;
|
|
54
|
+
if (frames.some((f) => f.banner)) return `the ${name} frame kept a cookie or consent banner over the page, so the still would show it; capture it yourself and upload it with \`hyperdecks asset add\``;
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// A picture's type from its first bytes (PNG, JPEG, GIF, WebP), or null.
|
|
59
|
+
export function sniffType(b) {
|
|
60
|
+
if (b[0] === 0x89 && b[1] === 0x50 && b[2] === 0x4e && b[3] === 0x47) return "image/png";
|
|
61
|
+
if (b[0] === 0xff && b[1] === 0xd8 && b[2] === 0xff) return "image/jpeg";
|
|
62
|
+
if (b[0] === 0x47 && b[1] === 0x49 && b[2] === 0x46) return "image/gif";
|
|
63
|
+
if (b[0] === 0x52 && b[1] === 0x49 && b[2] === 0x46 && b[3] === 0x46 && b[8] === 0x57 && b[9] === 0x45 && b[10] === 0x42 && b[11] === 0x50) return "image/webp";
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// A picture's pixel size from its first bytes (PNG, JPEG, GIF, WebP), or null.
|
|
68
|
+
export function imageSize(bytes) {
|
|
69
|
+
const b = bytes, u16 = (i) => (b[i] << 8) | b[i + 1], le16 = (i) => b[i] | (b[i + 1] << 8);
|
|
70
|
+
if (b[0] === 0x89 && b[1] === 0x50) return { width: (b[16] << 24 | b[17] << 16 | b[18] << 8 | b[19]) >>> 0, height: (b[20] << 24 | b[21] << 16 | b[22] << 8 | b[23]) >>> 0 };
|
|
71
|
+
if (b[0] === 0x47 && b[1] === 0x49) return { width: le16(6), height: le16(8) };
|
|
72
|
+
if (b[0] === 0x52 && b[8] === 0x57 && b[12] === 0x56 && b[13] === 0x50 && b[14] === 0x38) {
|
|
73
|
+
if (b[15] === 0x20) return { width: le16(26) & 0x3fff, height: le16(28) & 0x3fff };
|
|
74
|
+
if (b[15] === 0x4c) return { width: 1 + (((b[22] & 0x3f) << 8) | b[21]), height: 1 + (((b[24] & 0x0f) << 10) | (b[23] << 2) | ((b[22] & 0xc0) >> 6)) };
|
|
75
|
+
if (b[15] === 0x58) return { width: 1 + (b[24] | b[25] << 8 | b[26] << 16), height: 1 + (b[27] | b[28] << 8 | b[29] << 16) };
|
|
76
|
+
}
|
|
77
|
+
if (b[0] === 0xff && b[1] === 0xd8) {
|
|
78
|
+
for (let i = 2; i + 9 < b.length; ) {
|
|
79
|
+
if (b[i] !== 0xff) { i++; continue; }
|
|
80
|
+
const m = b[i + 1];
|
|
81
|
+
if (m >= 0xc0 && m <= 0xcf && m !== 0xc4 && m !== 0xc8 && m !== 0xcc) return { width: u16(i + 7), height: u16(i + 5) };
|
|
82
|
+
i += 2 + u16(i + 2);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// The page as the slide shows it, from this machine's Chromium: { bytes, contentType, title, width, height }, a JPEG at
|
|
89
|
+
// the still's size. A live source's frame URL is loaded inside an iframe (framePage); any other page (`top`), as a
|
|
90
|
+
// page of its own, since many sites refuse to be framed. `chromium`: Playwright's (injected in tests). Throws
|
|
91
|
+
// stillProblem's words for an error answer, an error page, a blank page or a banner.
|
|
92
|
+
export async function framedStill(src, name, { chromium, top = false, phone = false, width = phone ? PHONE_STILL.width : STILL_WIDTH, height = phone ? PHONE_STILL.height : STILL_HEIGHT, settleMs = 5000 } = {}) {
|
|
93
|
+
// Not bundled into the app (the hosted MCP never captures locally): the CLI's own Playwright, loaded when asked.
|
|
94
|
+
chromium ??= (await import(/* webpackIgnore: true */ /* turbopackIgnore: true */ "playwright")).chromium;
|
|
95
|
+
let browser;
|
|
96
|
+
try { browser = await chromium.launch({ headless: true, args: ["--mute-audio"] }); }
|
|
97
|
+
catch (e) { throw Object.assign(new Error(`no local Chromium: ${e?.message ?? e}`), { noLocalBrowser: true }); }
|
|
98
|
+
try {
|
|
99
|
+
// A phone still is a phone: its width, its pixel density, touch and a phone's browser, so a page lays itself out for it.
|
|
100
|
+
const page = await browser.newPage(phone
|
|
101
|
+
? { viewport: { width, height }, deviceScaleFactor: PHONE_STILL.scale, isMobile: true, hasTouch: true, userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.1" }
|
|
102
|
+
: { viewport: { width, height }, deviceScaleFactor: 1 });
|
|
103
|
+
const statuses = [];
|
|
104
|
+
page.on("response", (r) => { if (r.request().isNavigationRequest() && (top || r.frame() !== page.mainFrame())) statuses.push(r.status()); });
|
|
105
|
+
if (top) await page.goto(src, { waitUntil: "load", timeout: 30000 });
|
|
106
|
+
else await page.setContent(framePage(src, { width, height }), { waitUntil: "load", timeout: 30000 });
|
|
107
|
+
await page.waitForTimeout(settleMs);
|
|
108
|
+
const pass = () => Promise.all(page.frames().map((f) => f.evaluate(framePass).then((r) => ({ ...r, wrapper: !top && f === page.mainFrame() })).catch(() => ({ text: "", clicked: null, banner: false, media: 0, wrapper: f === page.mainFrame() }))));
|
|
109
|
+
// A consent banner is dismissed, then the page gets a moment to redraw before the picture.
|
|
110
|
+
let frames = await pass();
|
|
111
|
+
if (frames.some((f) => f.clicked)) { await page.waitForTimeout(1500); frames = await pass(); }
|
|
112
|
+
const problem = stillProblem(frames, name, { statuses });
|
|
113
|
+
if (problem) throw new Error(problem);
|
|
114
|
+
const title = frames.find((f) => !f.wrapper && f.title)?.title ?? null;
|
|
115
|
+
const scale = phone ? PHONE_STILL.scale : 1;
|
|
116
|
+
return { bytes: new Uint8Array(await page.screenshot({ type: "jpeg", quality: 85 })), contentType: "image/jpeg", title, width: width * scale, height: height * scale };
|
|
117
|
+
} finally {
|
|
118
|
+
await browser.close().catch(() => {});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// The capture could not start a browser here (none installed, or Playwright missing): the app's renderer takes it.
|
|
123
|
+
export const noLocalBrowser = (e) => !!e?.noLocalBrowser || /Cannot find (package|module) 'playwright'|Executable doesn't exist/.test(String(e?.message ?? e));
|
|
124
|
+
|
|
125
|
+
export const stillName = (resolved) => `embed-${(resolved.source ?? resolved.host ?? "page").replace(/[^a-z0-9]+/gi, "-").toLowerCase()}`;
|
|
126
|
+
export const extensionFor = (contentType) => TYPES[contentType] ?? "jpg";
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
// The embed slide's allowed sources (docs/roadmap/embed-slide-a-still-first-live-on-tap-maps-video-figma-booki.md):
|
|
2
|
+
// one table, read by check (a source not on it), the guide (embeds topic), the still capture (screenshot --embed,
|
|
3
|
+
// capture_url { embed: true }) and the player, which loads a live frame only for a URL this table turns into an embed
|
|
4
|
+
// URL. Anything else shows its still with a link that opens in a new tab. No Node imports: the player and the hosted
|
|
5
|
+
// check run it too.
|
|
6
|
+
//
|
|
7
|
+
// Each row: the hosts it answers to, a function from the author's URL to the frame's URL (null when the URL is on
|
|
8
|
+
// that host but not something it can embed), the control's words, and the frame's `allow` and `sandbox`. `opaque`:
|
|
9
|
+
// the source still draws inside a page with no origin of its own. A shared deck is served in a CSP sandbox without
|
|
10
|
+
// allow-same-origin (lib/deckSandbox.ts), and a frame inside it inherits that, so YouTube, Vimeo, Loom, Figma and
|
|
11
|
+
// Calendly draw nothing there (checked in Chromium on 2026-11-28): on such a page the player opens them in a new tab instead.
|
|
12
|
+
// `inline: false`: never in a frame, on any page. Calendly's cookie banner (not the GDPR one hide_gdpr_banner turns
|
|
13
|
+
// off) covers half its booking page in a frame and cannot be dismissed from outside it, so it always opens in a tab.
|
|
14
|
+
|
|
15
|
+
const SANDBOX = "allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox";
|
|
16
|
+
|
|
17
|
+
// A path segment's words; a malformed escape ("50%off") stays as written rather than throwing.
|
|
18
|
+
const decoded = (s) => { try { return decodeURIComponent(s); } catch { return s; } };
|
|
19
|
+
|
|
20
|
+
// A Google Maps link as an embed URL: an embed URL as it is; a place (/maps/place/<name>) or a search (?q=) by its
|
|
21
|
+
// words; a point (/@lat,lng,zoomz) by its coordinates. The keyless maps?output=embed form needs no API key.
|
|
22
|
+
function googleMaps(u) {
|
|
23
|
+
const host = u.hostname.replace(/^www\./, "");
|
|
24
|
+
if (!(host === "maps.google.com" || (host === "google.com" && /^\/maps(\/|$)/.test(u.pathname)))) return null;
|
|
25
|
+
if (/^\/maps\/embed(\/|$)/.test(u.pathname) || (/^\/maps\/?$/.test(u.pathname) && u.searchParams.get("output") === "embed")) return u.href;
|
|
26
|
+
const at = /@(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?)(?:,(\d+(?:\.\d+)?)z)?/.exec(u.pathname);
|
|
27
|
+
const place = /\/maps\/(?:place|search)\/([^/@]+)/.exec(u.pathname)?.[1];
|
|
28
|
+
const q = u.searchParams.get("q") ?? u.searchParams.get("query") ?? (place ? decoded(place.replace(/\+/g, " ")) : at ? `${at[1]},${at[2]}` : null);
|
|
29
|
+
if (!q) return null;
|
|
30
|
+
const z = u.searchParams.get("z") ?? (at?.[3] ? String(Math.round(Number(at[3]))) : null);
|
|
31
|
+
return `https://maps.google.com/maps?q=${encodeURIComponent(q)}${z ? `&z=${encodeURIComponent(z)}` : ""}&output=embed`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// A YouTube video (watch?v=, youtu.be/, /embed/, /shorts/, /live/) on youtube-nocookie.com, from its start time if the link has one.
|
|
35
|
+
function youtube(u) {
|
|
36
|
+
const host = u.hostname.replace(/^(www|m)\./, "");
|
|
37
|
+
let id = null;
|
|
38
|
+
if (host === "youtu.be") id = u.pathname.slice(1).split("/")[0];
|
|
39
|
+
else if (host === "youtube.com" || host === "youtube-nocookie.com") id = u.pathname === "/watch" ? u.searchParams.get("v") : /^\/(?:embed|shorts|live)\/([^/]+)/.exec(u.pathname)?.[1] ?? null;
|
|
40
|
+
else return null;
|
|
41
|
+
if (!id || !/^[\w-]{6,20}$/.test(id)) return null;
|
|
42
|
+
const t = /^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s?)?$/.exec(u.searchParams.get("t") ?? u.searchParams.get("start") ?? "");
|
|
43
|
+
const start = t ? Number(t[1] ?? 0) * 3600 + Number(t[2] ?? 0) * 60 + Number(t[3] ?? 0) : 0;
|
|
44
|
+
return `https://www.youtube-nocookie.com/embed/${id}?autoplay=1&rel=0&playsinline=1${start ? `&start=${start}` : ""}`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// A Vimeo video (vimeo.com/<id>, an unlisted vimeo.com/<id>/<hash>, player.vimeo.com/video/<id>?h=<hash>).
|
|
48
|
+
function vimeo(u) {
|
|
49
|
+
const host = u.hostname.replace(/^www\./, "");
|
|
50
|
+
let m;
|
|
51
|
+
if (host === "player.vimeo.com") m = /^\/video\/(\d+)\/?$/.exec(u.pathname);
|
|
52
|
+
else if (host === "vimeo.com") m = /^\/(?:channels\/[\w-]+\/)?(\d+)(?:\/([0-9a-f]+))?\/?$/.exec(u.pathname);
|
|
53
|
+
else return null;
|
|
54
|
+
if (!m) return null;
|
|
55
|
+
const hash = m[2] ?? u.searchParams.get("h");
|
|
56
|
+
return `https://player.vimeo.com/video/${m[1]}?autoplay=1&dnt=1${hash && /^[0-9a-f]+$/.test(hash) ? `&h=${hash}` : ""}`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// A Loom recording (loom.com/share/<id> or /embed/<id>).
|
|
60
|
+
function loom(u) {
|
|
61
|
+
if (u.hostname.replace(/^www\./, "") !== "loom.com") return null;
|
|
62
|
+
const id = /^\/(?:share|embed)\/([0-9a-f]{16,64})\/?$/.exec(u.pathname)?.[1];
|
|
63
|
+
return id ? `https://www.loom.com/embed/${id}?autoplay=1&hide_owner=true&hide_share=true` : null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// A Figma design, prototype, board or slides on embed.figma.com, Figma's embed host (the file must be shared to anyone
|
|
67
|
+
// with the link). An older /file/ link is a design; the page to open (node-id) and a prototype's start come along.
|
|
68
|
+
function figma(u) {
|
|
69
|
+
const host = u.hostname.replace(/^www\./, "");
|
|
70
|
+
if (host !== "figma.com" && host !== "embed.figma.com") return null;
|
|
71
|
+
const m = /^\/(file|design|proto|board|slides)\/([\w-]+)(\/[^/?#]*)?/.exec(u.pathname);
|
|
72
|
+
if (!m) return null;
|
|
73
|
+
const keep = new URLSearchParams();
|
|
74
|
+
for (const k of ["node-id", "starting-point-node-id", "page-id", "scaling", "content-scaling"]) if (u.searchParams.get(k)) keep.set(k, u.searchParams.get(k));
|
|
75
|
+
keep.set("embed-host", "hyperdecks");
|
|
76
|
+
return `https://embed.figma.com/${m[1] === "file" ? "design" : m[1]}/${m[2]}${m[3] ?? ""}?${keep}`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// A Calendly scheduling page (calendly.com/<user> or /<user>/<event>), inline.
|
|
80
|
+
function calendly(u) {
|
|
81
|
+
if (u.hostname.replace(/^www\./, "") !== "calendly.com") return null;
|
|
82
|
+
const m = /^\/([\w.-]+)(?:\/([\w.-]+))?\/?$/.exec(u.pathname);
|
|
83
|
+
if (!m || ["app", "event_types", "login", "signup", "pages"].includes(m[1])) return null;
|
|
84
|
+
return `https://calendly.com/${m[1]}${m[2] ? `/${m[2]}` : ""}?embed_type=Inline&hide_gdpr_banner=1`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export const EMBED_SOURCES = [
|
|
88
|
+
{ id: "google-maps", name: "Google Maps", kind: "map", label: "Open map", hosts: ["google.com/maps", "maps.google.com"], embed: googleMaps, allow: "fullscreen", sandbox: SANDBOX, opaque: true },
|
|
89
|
+
{ id: "youtube", name: "YouTube", kind: "video", label: "Play video", hosts: ["youtube.com", "youtu.be"], embed: youtube, allow: "autoplay; encrypted-media; picture-in-picture; fullscreen", sandbox: `${SANDBOX} allow-presentation` },
|
|
90
|
+
{ id: "vimeo", name: "Vimeo", kind: "video", label: "Play video", hosts: ["vimeo.com"], embed: vimeo, allow: "autoplay; picture-in-picture; fullscreen", sandbox: `${SANDBOX} allow-presentation` },
|
|
91
|
+
{ id: "loom", name: "Loom", kind: "video", label: "Play video", hosts: ["loom.com"], embed: loom, allow: "autoplay; fullscreen", sandbox: `${SANDBOX} allow-presentation` },
|
|
92
|
+
{ id: "figma", name: "Figma", kind: "design", label: "Open design", hosts: ["figma.com", "embed.figma.com"], embed: figma, allow: "fullscreen; clipboard-write", sandbox: SANDBOX },
|
|
93
|
+
{ id: "calendly", name: "Calendly", kind: "booking", label: "Book a time", hosts: ["calendly.com"], embed: calendly, allow: "", sandbox: `${SANDBOX} allow-forms allow-top-navigation-by-user-activation`, inline: false },
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
// An https URL with no user, password or port of its own, or null.
|
|
97
|
+
export function parseEmbedUrl(url) {
|
|
98
|
+
let u;
|
|
99
|
+
try { u = new URL(String(url ?? "").trim()); } catch { return null; }
|
|
100
|
+
if (u.protocol !== "https:" || u.username || u.password || u.port) return null;
|
|
101
|
+
return u;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// What the slide does with `url`: { live: true, source, src, label, allow, sandbox } for a source on the table (src: the
|
|
105
|
+
// frame's URL), or { live: false, href, label, host } for any other https page (a still and a link out), or null when
|
|
106
|
+
// the URL is not an https link at all.
|
|
107
|
+
export function resolveEmbed(url) {
|
|
108
|
+
const u = parseEmbedUrl(url);
|
|
109
|
+
if (!u) return null;
|
|
110
|
+
for (const s of EMBED_SOURCES) {
|
|
111
|
+
const src = s.embed(new URL(u.href));
|
|
112
|
+
if (src) return { live: true, source: s.id, name: s.name, kind: s.kind, src, label: s.label, allow: s.allow, sandbox: s.sandbox, opaque: !!s.opaque, inline: s.inline !== false, href: u.href };
|
|
113
|
+
}
|
|
114
|
+
const host = u.hostname.replace(/^www\./, "");
|
|
115
|
+
// On a source's site but not a link it can embed (a channel, a sign-in page, a short link): named, so check can say what to change.
|
|
116
|
+
const site = EMBED_SOURCES.find((s) => s.hosts.some((h) => { const [name, path] = h.split(/(?=\/)/); return (host === name || host.endsWith(`.${name}`)) && (!path || u.pathname.startsWith(path)); }))
|
|
117
|
+
?? (host === "maps.app.goo.gl" || host === "goo.gl" ? EMBED_SOURCES[0] : null);
|
|
118
|
+
return { live: false, href: u.href, host, label: "Open page", ...(site ? { site: site.name } : {}) };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Where a live source plays: inside the slide everywhere (opaque), or only on the deck's own page, a shared link
|
|
122
|
+
// (a sandboxed page) opening it in a new tab.
|
|
123
|
+
export const sharedLinkNote = (resolved) =>
|
|
124
|
+
!resolved?.live ? null
|
|
125
|
+
: resolved.inline === false ? `${resolved.name} opens in a new tab from the slide's control (in a frame its cookie banner covers the page), so the slide is a still and a link`
|
|
126
|
+
: !resolved.opaque ? `${resolved.name} plays inside the slide on the deck's own page; on a shared link the deck runs in a sandbox where it cannot draw, so the control opens it in a new tab`
|
|
127
|
+
: null;
|
|
128
|
+
|
|
129
|
+
// The control's label for a slide: the author's own (data-embed-label) when given, else the source's.
|
|
130
|
+
export const embedLabel = (resolved, own) => (own && String(own).trim()) || resolved?.label || "Open page";
|
|
131
|
+
|
|
132
|
+
const escapeAttr = (s) => String(s).replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
133
|
+
|
|
134
|
+
// The markup for the embed slide's frame: the author's URL and the captured still. The player adds the control and,
|
|
135
|
+
// for a source on the table, the live frame on tap; without the player (an export, a thumbnail) the still is all.
|
|
136
|
+
// `mid`: { src, width, height }, the still beside a presenter on a wide screen (class still-mid); `phone`: the portrait
|
|
137
|
+
// still a phone shows (class still-tall). The layout picks one by width and presenter (a <picture> cannot see the presenter).
|
|
138
|
+
export function embedMarkup(url, still, { alt = "", width, height, id, kind, phone, mid } = {}) {
|
|
139
|
+
const size = width && height ? ` width="${width}" height="${height}"` : "";
|
|
140
|
+
// The frame takes each still's shape (--ar, and --ar-phone on a phone), so neither is cropped.
|
|
141
|
+
const ratio = (name, w, h) => (w && h ? `${name}: ${(w / h).toFixed(4)}` : "");
|
|
142
|
+
const shapes = [ratio("--ar", width, height), ratio("--ar-mid", mid?.width, mid?.height), ratio("--ar-phone", phone?.width, phone?.height)].filter(Boolean);
|
|
143
|
+
const style = shapes.length ? ` style="${shapes.join("; ")}"` : "";
|
|
144
|
+
const img = `<img class="still" src="${escapeAttr(still)}" alt="${escapeAttr(alt)}"${size}>`;
|
|
145
|
+
const extra = (cls, s) => (s?.src ? `<img class="still ${cls}" src="${escapeAttr(s.src)}" alt="${escapeAttr(alt)}" width="${s.width}" height="${s.height}">` : "");
|
|
146
|
+
const pic = `${img}${extra("still-mid", mid)}${extra("still-tall", phone)}`;
|
|
147
|
+
return `<div class="embed"${id ? ` id="${escapeAttr(id)}"` : ""}${kind ? ` data-kind="${escapeAttr(kind)}"` : ""}${style} data-embed="${escapeAttr(url)}">${pic}</div>`;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// What to use instead of a link on a source's site that cannot be embedded (check and the capture say the same).
|
|
151
|
+
export const embedSiteHint = (site, host) => `this ${site} link (${host}) is not one that can be embedded; use ${site === "Google Maps" ? "the full google.com/maps link of a place or a search (open a maps.app.goo.gl short link and copy the address it lands on)" : `the link to one ${site === "Calendly" ? "scheduling page" : site === "Figma" ? "file shared to anyone with the link" : "video"}`}`;
|
|
152
|
+
|
|
153
|
+
// The table as markdown, for the embeds topic.
|
|
154
|
+
export function embedSourcesMarkdown() {
|
|
155
|
+
const where = (s) => (s.inline === false ? "never: a new tab, from the still" : s.opaque ? "everywhere" : "on the deck's own page; a new tab on a shared link");
|
|
156
|
+
return ["| Source | Links it takes | The control says | Plays inside the slide |", "|---|---|---|---|", ...EMBED_SOURCES.map((s) => `| ${s.name} | ${s.hosts.join(", ")} | ${s.label} | ${where(s)} |`)].join("\n");
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// ---- the still (screenshot --embed, capture_url { embed: true }) ----
|
|
160
|
+
// A video or a Figma file's still is the picture its own site publishes for it (oEmbed's thumbnail_url; YouTube's
|
|
161
|
+
// largest thumbnail): what a viewer would see before pressing play, never an error or consent page. `oembed`: the
|
|
162
|
+
// endpoint for a source's oEmbed answer, or null for a source whose still is a capture of its frame (a map, a booking page).
|
|
163
|
+
export function stillSource(resolved) {
|
|
164
|
+
if (!resolved?.live) return null;
|
|
165
|
+
const u = encodeURIComponent(resolved.href);
|
|
166
|
+
if (resolved.source === "youtube") {
|
|
167
|
+
const id = /\/embed\/([\w-]+)/.exec(resolved.src)?.[1];
|
|
168
|
+
return { oembed: `https://www.youtube.com/oembed?format=json&url=${u}`, images: [`https://i.ytimg.com/vi/${id}/maxresdefault.jpg`, `https://i.ytimg.com/vi/${id}/hqdefault.jpg`] };
|
|
169
|
+
}
|
|
170
|
+
if (resolved.source === "vimeo") return { oembed: `https://vimeo.com/api/oembed.json?width=1600&url=${u}` };
|
|
171
|
+
if (resolved.source === "loom") return { oembed: `https://www.loom.com/v1/oembed?url=${u}` };
|
|
172
|
+
if (resolved.source === "figma") return { oembed: `https://www.figma.com/api/oembed?url=${u}` };
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// The stills a page or a map gets, each at the shape its frame is shown at, so none is ever cropped: a wide one for
|
|
177
|
+
// the slide (the embed layout's area with no presenter, 2.5:1; with the presenter the frame keeps this shape, narrower)
|
|
178
|
+
// and a portrait one for a phone, rendered at a phone's width so a page shows its own mobile layout. A video's poster
|
|
179
|
+
// is one 16:9 picture for both.
|
|
180
|
+
export const STILL_WIDTH = 1600;
|
|
181
|
+
export const STILL_HEIGHT = 640;
|
|
182
|
+
export const PHONE_STILL = { width: 390, height: 620, scale: 2 };
|
|
183
|
+
// The slide beside a presenter: the area left of the presenter's corner, 16:10 (about 920x576 at 1440x900).
|
|
184
|
+
export const MID_STILL = { width: 1440, height: 900 };
|
|
185
|
+
|
|
186
|
+
// Words a frame shows instead of the thing itself (an embed refused, a file not public, a video blocked): a capture
|
|
187
|
+
// that shows any of them is not a still, so the capture fails and says what the frame said.
|
|
188
|
+
export const EMBED_ERROR_TEXT = [
|
|
189
|
+
/must be used in an iframe/i,
|
|
190
|
+
/video player configuration error/i,
|
|
191
|
+
/error 15\d\b/i,
|
|
192
|
+
/video unavailable/i,
|
|
193
|
+
/rights issue/i,
|
|
194
|
+
/we can.t seem to find that/i,
|
|
195
|
+
/can.t find (?:that|this) page/i,
|
|
196
|
+
/page (?:not found|doesn.t exist|does not exist)/i,
|
|
197
|
+
/this calendly url is not valid/i,
|
|
198
|
+
/not publicly accessible/i,
|
|
199
|
+
/this (?:video|page|content) (?:is|isn.t) (?:private|not available|unavailable)/i,
|
|
200
|
+
/page not found|404 not found/i,
|
|
201
|
+
/sign in to (?:continue|view)|log in to (?:continue|view)/i,
|
|
202
|
+
];
|
|
203
|
+
export const embedErrorIn = (text) => EMBED_ERROR_TEXT.find((re) => re.test(String(text ?? "")))?.source ?? null;
|
|
204
|
+
|
|
205
|
+
// Run in each frame of the capture page (serialized: no closure). Dismisses a cookie or consent banner the polite
|
|
206
|
+
// way (Decline or Reject first, else the only way to close it) and answers the frame's visible text and whether a
|
|
207
|
+
// banner is still showing, so the capture can refuse a picture with one baked in.
|
|
208
|
+
export function framePass() {
|
|
209
|
+
const words = (el) => (el.innerText || el.textContent || el.getAttribute("aria-label") || "").trim().toLowerCase();
|
|
210
|
+
const buttons = [...document.querySelectorAll("button, [role=button], a")].filter((b) => b.offsetParent !== null);
|
|
211
|
+
const banner = () => [...document.querySelectorAll("[id*=onetrust i], [class*=cookie i], [id*=cookie i], [class*=consent i], [id*=consent i], [aria-label*=cookie i]")].find((n) => n.offsetParent !== null && n.getBoundingClientRect().height > 40);
|
|
212
|
+
let clicked = null;
|
|
213
|
+
if (banner()) {
|
|
214
|
+
for (const want of [/^(decline|reject all|reject|decline all|only necessary|necessary only)$/, /^(i understand|got it|ok|close|accept|accept all)$/]) {
|
|
215
|
+
const b = buttons.find((x) => want.test(words(x)));
|
|
216
|
+
if (b) { b.click(); clicked = words(b); break; }
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// What the frame draws besides words (a map's canvas or tiles, a picture), so a blank frame can be told from a quiet one.
|
|
220
|
+
const media = [...document.querySelectorAll("img, canvas, svg, video")].filter((n) => { const r = n.getBoundingClientRect(); return r.width > 40 && r.height > 40; }).length;
|
|
221
|
+
const title = (document.querySelector("h1")?.innerText || document.title || "").trim().slice(0, 120);
|
|
222
|
+
// A fixed or sticky layer over more than a quarter of the view (a fundraising or newsletter banner, a sign-up wall).
|
|
223
|
+
const view = innerWidth * innerHeight;
|
|
224
|
+
// Or one in the page's flow that names itself an appeal or a pop-up (Wikipedia's #centralNotice fundraising banner).
|
|
225
|
+
const appeal = /notice|donat|fundrais|newsletter|subscribe|paywall|sign-?up|modal|popup|interstitial/i;
|
|
226
|
+
const covers = (n) => {
|
|
227
|
+
const r = n.getBoundingClientRect(), w = Math.max(0, Math.min(r.right, innerWidth) - Math.max(r.left, 0)), h = Math.max(0, Math.min(r.bottom, innerHeight) - Math.max(r.top, 0));
|
|
228
|
+
return w * h > view / 4 && getComputedStyle(n).visibility !== "hidden" && Number(getComputedStyle(n).opacity) > 0.1;
|
|
229
|
+
};
|
|
230
|
+
const overlay = [...document.querySelectorAll("body *")].some((n) => {
|
|
231
|
+
const p = getComputedStyle(n).position;
|
|
232
|
+
if (p === "fixed" || p === "sticky") return covers(n);
|
|
233
|
+
return appeal.test(`${n.id} ${typeof n.className === "string" ? n.className : ""}`) && covers(n);
|
|
234
|
+
});
|
|
235
|
+
return { text: (document.body?.innerText || "").slice(0, 4000), clicked, banner: !!banner() && !clicked, media, title, top: window === window.top, overlay };
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// The page a capture loads for a source shown in a frame: the frame's URL inside an iframe, as a slide shows it (a
|
|
239
|
+
// Google Maps embed refuses to draw as a page of its own).
|
|
240
|
+
export const framePage = (src, { width = STILL_WIDTH, height = STILL_HEIGHT } = {}) =>
|
|
241
|
+
`<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>html,body{margin:0;height:100%;overflow:hidden;background:#fff}iframe{display:block;border:0;width:${width}px;height:${height}px}</style><iframe src="${String(src).replace(/&/g, "&").replace(/"/g, """)}" allow="fullscreen" referrerpolicy="strict-origin-when-cross-origin"></iframe>`;
|
|
242
|
+
|
|
243
|
+
// Whether `url` is the frame URL the table builds for a live source (the render route wraps such a URL in framePage).
|
|
244
|
+
export function isEmbedFrameUrl(url) {
|
|
245
|
+
for (const s of EMBED_SOURCES) {
|
|
246
|
+
let u;
|
|
247
|
+
try { u = new URL(url); } catch { return false; }
|
|
248
|
+
if (u.protocol !== "https:") return false;
|
|
249
|
+
if (s.embed(new URL(u.href)) === u.href && /(output=embed|embed_type=Inline|embed\.figma\.com|\/embed\/|player\.vimeo\.com)/.test(u.href)) return true;
|
|
250
|
+
}
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// hyperdecks guide embeds (deck_guide topic embeds): when a live map, video, design or booking page earns a slide,
|
|
2
|
+
// and how to add one with the embed layout. The sources come from embedSources.mjs, so the list cannot drift.
|
|
3
|
+
import { embedSourcesMarkdown } from "./embedSources.mjs";
|
|
4
|
+
|
|
5
|
+
export function embedsGuide(surface) {
|
|
6
|
+
const cli = surface === "cli";
|
|
7
|
+
const capture = cli ? "`hyperdecks screenshot <url> --embed --slug <deck> --id <slide-id>-embed`" : "`capture_url { url, embed: true, slug, id: \"<slide-id>-embed\" }`";
|
|
8
|
+
const scaffold = cli ? "`hyperdecks deck new <slug> \"<title>\" --narrated --layouts …,embed,…`" : '`new_deck { …, layouts: [ …, "embed", … ] }`';
|
|
9
|
+
const detail = cli ? "`hyperdecks guide layouts embed`" : '`deck_guide { topic: "layouts", layouts: ["embed"] }`';
|
|
10
|
+
return [
|
|
11
|
+
"# Embeds: a live map, video, design or booking page on a slide",
|
|
12
|
+
"",
|
|
13
|
+
"An embed slide shows a captured still of the page with one control named for it (Open map, Play video, Open design, Book a time). Nothing loads from the other site until the viewer taps it; then the live frame opens over the still, the narration pauses and the deck stops advancing until they close it (the close control, or Escape). Video and PDF exports, thumbnails and link previews show the still.",
|
|
14
|
+
"",
|
|
15
|
+
"## When an embed earns a slide",
|
|
16
|
+
"",
|
|
17
|
+
"Only when the viewer will **use** it, not just look at it: drag a map of the venues, pick a slot on the closer's booking page, click through a Figma prototype, play a video that lives on YouTube. If they would only look, a picture is better: a screenshot, a recording (video-full), or a still with no control. One or two embeds a deck at most; the closer's booking page is the one that most often earns it.",
|
|
18
|
+
"",
|
|
19
|
+
"## The sources",
|
|
20
|
+
"",
|
|
21
|
+
embedSourcesMarkdown(),
|
|
22
|
+
"",
|
|
23
|
+
"Use the page's ordinary share link (a Google Maps place or search link, not a maps.app.goo.gl short link; a Figma file shared to anyone with the link; a public Calendly page). Any other https link becomes a still with a link that opens it in a new tab. On a shared link the deck runs in a security sandbox, and today only Google Maps can draw inside it: the others open their page in a new tab from the same tap. Calendly always opens in a new tab (in a frame its cookie banner covers the booking page). To see what a recipient gets, open the QA link `release --qa` prints: it is served exactly as a shared link is. Never write an `<iframe>` yourself: check warns on one, because it loads for every viewer on open, keeps the narration going and shows empty in exports.",
|
|
24
|
+
"",
|
|
25
|
+
"## How to add one",
|
|
26
|
+
"",
|
|
27
|
+
`1. Put an \`embed\` slide in the deck: ${scaffold}. Read its detail first: ${detail}.`,
|
|
28
|
+
`2. Capture the still: ${capture}. For a map or a page it captures two stills, each at the shape its frame is shown at (a wide one for the slide, a portrait one at a phone's width), so neither is cropped; for a video it saves the poster its site publishes. It refuses an error page, a blank page or a page under a banner, and returns the frame's markup: paste that over the layout's placeholder frame. **Look at the saved stills before you use them**: no check catches every banner or pop-up. Give the still an alt that says what it shows.`,
|
|
29
|
+
"3. Name the control for what the viewer will do when the source's own words do not fit: `data-embed-label=\"See the three venues\"` on the frame.",
|
|
30
|
+
"4. In script.md, say what to do before the slide asks it (\"Tap the map to look around; I'll wait\"). The narration pauses when they open it and goes on when they close it.",
|
|
31
|
+
"",
|
|
32
|
+
"Close (top right of the open frame) always closes it. Escape does too while the keyboard is on the deck; once the viewer clicks inside the other site's page, its keys are that page's, and Close is the way out.",
|
|
33
|
+
"",
|
|
34
|
+
"A silent deck and a narrated deck both work: on a silent deck the control is the same and nothing advances while the frame is open. On a phone the open frame takes the whole card and has its own close control, so the deck can still be swiped once it is closed.",
|
|
35
|
+
].join("\n");
|
|
36
|
+
}
|
package/src/files.mjs
CHANGED
|
@@ -28,6 +28,8 @@ const FILES = {
|
|
|
28
28
|
"templates/layouts/team.html": () => new URL("../templates/layouts/team.html", import.meta.url),
|
|
29
29
|
"templates/layouts/timeline.html": () => new URL("../templates/layouts/timeline.html", import.meta.url),
|
|
30
30
|
"templates/layouts/phone-stage.html": () => new URL("../templates/layouts/phone-stage.html", import.meta.url),
|
|
31
|
+
"templates/layouts/question-choice.html": () => new URL("../templates/layouts/question-choice.html", import.meta.url),
|
|
32
|
+
"templates/layouts/question-text.html": () => new URL("../templates/layouts/question-text.html", import.meta.url),
|
|
31
33
|
"templates/layouts/tap-through.html": () => new URL("../templates/layouts/tap-through.html", import.meta.url),
|
|
32
34
|
"templates/layouts/screens.html": () => new URL("../templates/layouts/screens.html", import.meta.url),
|
|
33
35
|
"templates/layouts/zoom.html": () => new URL("../templates/layouts/zoom.html", import.meta.url),
|
|
@@ -49,6 +51,7 @@ const FILES = {
|
|
|
49
51
|
"templates/layouts/lanes.html": () => new URL("../templates/layouts/lanes.html", import.meta.url),
|
|
50
52
|
"templates/layouts/two-bars.html": () => new URL("../templates/layouts/two-bars.html", import.meta.url),
|
|
51
53
|
"templates/layouts/stack.html": () => new URL("../templates/layouts/stack.html", import.meta.url),
|
|
54
|
+
"templates/layouts/embed.html": () => new URL("../templates/layouts/embed.html", import.meta.url),
|
|
52
55
|
"templates/icons/lucide.json": () => new URL("../templates/icons/lucide.json", import.meta.url),
|
|
53
56
|
"templates/icons/phosphor.json.gz": () => new URL("../templates/icons/phosphor.json.gz", import.meta.url),
|
|
54
57
|
"templates/icons/tabler.json.gz": () => new URL("../templates/icons/tabler.json.gz", import.meta.url),
|
package/src/guide.mjs
CHANGED
|
@@ -11,12 +11,13 @@ import { fontPairingsMarkdown } from "./brand.mjs";
|
|
|
11
11
|
import { themesMarkdown } from "./themes.mjs";
|
|
12
12
|
import { photosGuide } from "./photosGuide.mjs";
|
|
13
13
|
import { picturesGuide } from "./picturesGuide.mjs";
|
|
14
|
+
import { embedsGuide } from "./embedsGuide.mjs";
|
|
14
15
|
import { ICON_SLOTS } from "./iconSlots.mjs";
|
|
15
|
-
import { routesMarkdown, suggestLayouts } from "./layoutRoutes.mjs";
|
|
16
|
+
import { FLIPPABLE, routesMarkdown, suggestLayouts } from "./layoutRoutes.mjs";
|
|
16
17
|
|
|
17
|
-
export const GUIDE_TOPICS = ["workflow", "format", "script", "scripts", "design", "look", "themes", "layouts", "photos", "pictures", "presenter", "transitions", "check"];
|
|
18
|
+
export const GUIDE_TOPICS = ["workflow", "format", "script", "scripts", "design", "look", "themes", "layouts", "photos", "pictures", "embeds", "presenter", "transitions", "check"];
|
|
18
19
|
// Other names a topic answers to: gifs is the photos topic, icons the pictures one.
|
|
19
|
-
const TOPIC_ALIASES = { gifs: "photos", icons: "pictures" };
|
|
20
|
+
const TOPIC_ALIASES = { gifs: "photos", icons: "pictures", embed: "embeds", maps: "embeds" };
|
|
20
21
|
const CLI_NOTE = "_Written for the CLI. On the hosted MCP there is no folder: use the tool names in `deck_guide` (workflow), hosted URLs for every file, and write_deck_source for edits._\n\n";
|
|
21
22
|
|
|
22
23
|
// One <!-- topic: name --> section of SKILL.md: its heading and body, up to the
|
|
@@ -44,7 +45,7 @@ function layoutsIndex(surface) {
|
|
|
44
45
|
return `- \`${name}\`${tags ? ` (${tags})` : ""}: ${meta.brief ?? meta.summary}`;
|
|
45
46
|
});
|
|
46
47
|
const suggest = surface === "cli" ? '`hyperdecks layouts suggest "<what the slide says>"`' : '`deck_guide { topic: "layouts", suggest: "<what the slide says>" }`';
|
|
47
|
-
return `# Layouts\n\n## Pick the shape from what the slide says\n\nName what each slide carries, then take a shape from its row; ${suggest} does the same from a slide's words. Vary the shapes: one layout on more than about a third of the slides, or three in a row, reads as the same slide again (check warns). Where a row offers a picture layout and a word shape, take the picture layout when you have the real screenshot, recording or photo; the word shape is for when you do not. For a list of what is allowed and what is not, use compare: put the allowed items in the right-hand column, the highlighted one, and label both columns. For a single rule and the right way to do it, use strike.\n\n${routesMarkdown()}\n\n## Every layout\n\nPass any of these, in order, as new_deck's \`layouts\` (repeat one for more of the same: number, number gives slides number and number-2). Read a layout's detail (what to put in, slots, cues, without a presenter) before you fill it: \`deck_guide { topic: "layouts", layouts: ["zoom"] }\` (CLI: \`hyperdecks guide layouts zoom\`); several names in one call is fine.\n\n${rows.join("\n")}`;
|
|
48
|
+
return `# Layouts\n\n## Pick the shape from what the slide says\n\nName what each slide carries, then take a shape from its row; ${suggest} does the same from a slide's words. Vary the shapes: one layout on more than about a third of the slides, or three in a row, reads as the same slide again (check warns). The side-panel layouts (${FLIPPABLE.map((n) => `\`${n}\``).join(", ")}) also flip: \`data-flip\` on the section mirrors one, its panel and the presenter to the other side. Alternate sides between neighbours: the same layout twice in a row with its panel on the same side reads as the same slide twice (check warns; ${surface === "cli" ? "`deck new`" : "new_deck"} flips a repeated one for you). Where a row offers a picture layout and a word shape, take the picture layout when you have the real screenshot, recording or photo; the word shape is for when you do not. For a list of what is allowed and what is not, use compare: put the allowed items in the right-hand column, the highlighted one, and label both columns. For a single rule and the right way to do it, use strike.\n\n${routesMarkdown()}\n\n## Every layout\n\nPass any of these, in order, as new_deck's \`layouts\` (repeat one for more of the same: number, number gives slides number and number-2). Read a layout's detail (what to put in, slots, cues, without a presenter) before you fill it: \`deck_guide { topic: "layouts", layouts: ["zoom"] }\` (CLI: \`hyperdecks guide layouts zoom\`); several names in one call is fine.\n\n${rows.join("\n")}`;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
// The built-in themes, each with what it is for, and how an agent picks one.
|
|
@@ -72,11 +73,18 @@ export function layoutMarkup(section) {
|
|
|
72
73
|
return section.replace(/<!--[\s\S]*?-->\s*/g, "").replace(/(<svg\b[^>]*[^/]>)[\s\S]*?<\/svg>/g, "$1…</svg>").replace(/\n\s*\n/g, "\n").trim();
|
|
73
74
|
}
|
|
74
75
|
|
|
76
|
+
// A layout's <style>, comments out: a question's markup works only with it, and an agent adding one to a deck
|
|
77
|
+
// that wasn't scaffolded with it has nowhere else to copy it from.
|
|
78
|
+
export function layoutStyle(style) {
|
|
79
|
+
// Spaces CSS doesn't need go too, for the guide's size; never the ones in a selector or around calc's + and -.
|
|
80
|
+
return style.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\s*([{};])\s*/g, "$1").replace(/([:,]) +/g, "$1").replace(/;\}/g, "}").replace(/\}/g, "}\n").replace(/\n+/g, "\n").replace(/>\s+/, ">\n").trim();
|
|
81
|
+
}
|
|
82
|
+
|
|
75
83
|
// The full entry of each named layout (aliases work), in the order asked.
|
|
76
84
|
function layoutsDetail(names) {
|
|
77
85
|
const rows = parseLayouts(names.join(",")).filter((n, i, all) => all.indexOf(n) === i).map((name) => {
|
|
78
|
-
const { meta, section } = readLayout(name);
|
|
79
|
-
return [`### ${name}`, meta.summary, meta.says && `Says: ${meta.says}`, meta.needs && `Needs: ${meta.needs}`, meta.use && `Use: ${meta.use}`, meta.slot && `Slots: ${meta.slot}`, ICON_SLOTS[name] && `Icon slot (optional): ${ICON_SLOTS[name].where}; \`hyperdecks icons search <word> --for ${name}\` (search_icons { query, for: "${name}" }) gives the svg. Use one where it helps the reader find or remember an item; leave it out where the words carry it (deck_guide topic pictures).`, meta.nopresenter && `Without a presenter: ${meta.nopresenter}`, meta.cues && `Cues: ${meta.cues}`, `Markup (ids start with the slide's id; __ID__ in the scaffold):\n\n\`\`\`html\n${layoutMarkup(section)}\n\`\`\``].filter(Boolean).join("\n");
|
|
86
|
+
const { meta, section, style } = readLayout(name);
|
|
87
|
+
return [`### ${name}`, meta.summary, meta.says && `Says: ${meta.says}`, meta.needs && `Needs: ${meta.needs}`, meta.use && `Use: ${meta.use}`, meta.slot && `Slots: ${meta.slot}`, meta.flip && `Flip: ${meta.flip}`, ICON_SLOTS[name] && `Icon slot (optional): ${ICON_SLOTS[name].where}; \`hyperdecks icons search <word> --for ${name}\` (search_icons { query, for: "${name}" }) gives the svg. Use one where it helps the reader find or remember an item; leave it out where the words carry it (deck_guide topic pictures).`, meta.nopresenter && `Without a presenter: ${meta.nopresenter}`, meta.cues && `Cues: ${meta.cues}`, `Markup (ids start with the slide's id; __ID__ in the scaffold):\n\n\`\`\`html\n${layoutMarkup(section)}\n\`\`\``, /\bdata-question=/.test(section) && `Style (required: without it the slide is bare grey buttons; a deck made with this layout has it already, any other needs it once, in its <head>, and the variables it reads in its :root; check names any that are missing):\n\`\`\`html\n${layoutStyle(style)}\n\`\`\``].filter(Boolean).join("\n");
|
|
80
88
|
});
|
|
81
89
|
return `# Layouts: detail\n\n${rows.join("\n\n")}`;
|
|
82
90
|
}
|
|
@@ -86,7 +94,7 @@ export function suggestText(says, surface) {
|
|
|
86
94
|
const found = suggestLayouts(says);
|
|
87
95
|
const detail = surface === "cli" ? "`hyperdecks guide layouts <name>`" : '`deck_guide { topic: "layouts", layouts: ["<name>"] }`';
|
|
88
96
|
if (!found.length) return `# Layouts for "${says}"\n\nNo row of the table matched these words. Name what the slide carries (a process, a cycle, who does what, one claim, a choice, status, numbers, a person, the product…) and read the table in the layouts topic.`;
|
|
89
|
-
return `# Layouts for "${says}"\n\n${found.map((s) => `- \`${s.layout}\`: ${s.kind} (${s.why}); matched ${s.matched.map((w) => `"${w}"`).join(", ")}`).join("\n")}\n\nFirst one first. These come from keywords, so check the fit; read one's detail before you fill it: ${detail}
|
|
97
|
+
return `# Layouts for "${says}"\n\n${found.map((s) => `- \`${s.layout}\`: ${s.kind} (${s.why}); matched ${s.matched.map((w) => `"${w}"`).join(", ")}`).join("\n")}\n\nFirst one first. These come from keywords, so check the fit; read one's detail before you fill it: ${detail}.${found.some((s) => FLIPPABLE.includes(s.layout)) ? ` If the slide before this one uses the same side-panel layout (${FLIPPABLE.join(", ")}), put \`data-flip\` on this one so the two alternate sides.` : ""}`;
|
|
90
98
|
}
|
|
91
99
|
|
|
92
100
|
// { topic, topics, text } for one topic; no topic gives the workflow. `layouts`
|
|
@@ -108,6 +116,7 @@ export function deckGuide(topic, { layouts, surface, suggest } = {}) {
|
|
|
108
116
|
else if (t === "themes") text = themesGuide(surface);
|
|
109
117
|
else if (t === "photos") text = photosGuide(surface);
|
|
110
118
|
else if (t === "pictures") text = picturesGuide(surface);
|
|
119
|
+
else if (t === "embeds") text = embedsGuide(surface);
|
|
111
120
|
else if (t === "layouts") text = names.length ? layoutsDetail(names) : layoutsIndex(surface);
|
|
112
121
|
else {
|
|
113
122
|
const section = skillSection(packageText("skills/hyperdecks/SKILL.md"), t);
|
package/src/layoutRoutes.mjs
CHANGED
|
@@ -26,11 +26,13 @@ export const ROUTES = [
|
|
|
26
26
|
{ kind: "the product", layouts: ["product", "split", "zoom", "screens"], why: "a real screenshot, framed", words: ["product", "app", "screen*", "screenshot*", "dashboard", "interface", "ui", "website", "feature", "demo", "tool"] },
|
|
27
27
|
{ kind: "the product on a phone", layouts: ["phone-stage", "phones", "tap-through"], why: "one phone, a row of them, or one to tap", words: ["phone*", "mobile", "iphone", "ios", "android", "tap", "taps"] },
|
|
28
28
|
{ kind: "a walk through a flow", layouts: ["screens", "tap-through", "video-beats"], why: "the screens in order, or a recording paused at each", words: ["walkthrough", "walk through", "flow", "flows", "tour", "click*", "sign up flow", "checkout"] },
|
|
29
|
+
{ kind: "something the viewer uses", layouts: ["embed", "tap-through", "picture-full"], why: "a map, a booking page, a prototype or a video from another site: a still that goes live on tap", words: ["map", "maps", "venue*", "location*", "directions", "route", "book a call", "book a time", "book a meeting", "booking", "calendar", "calendly", "schedule a call", "prototype", "figma", "youtube", "vimeo", "loom"] },
|
|
29
30
|
{ kind: "motion", layouts: ["video-full", "video-beats", "product"], why: "a recording, whole or in beats", words: ["video", "clip", "recording", "watch", "motion", "film", "footage"] },
|
|
30
31
|
{ kind: "a place or mood", layouts: ["picture-full", "wall", "split", "cover-band"], why: "a real photo, whole, as a wall, or beside the words", words: ["place", "where", "photo*", "mood", "scene", "city", "field", "kitchen", "garden", "store", "outside", "picture*"] },
|
|
31
32
|
{ kind: "a person", layouts: ["portrait", "quote", "team"], why: "their face and their words", words: ["person", "customer*", "said", "says", "quote", "meet", "user story", "interview*"] },
|
|
32
33
|
{ kind: "the team", layouts: ["team", "portrait"], why: "the faces, a name and a role each", words: ["team", "founders", "who we are", "people", "hire*", "hiring"] },
|
|
33
34
|
{ kind: "numbers", layouts: ["chart", "number", "two-bars"], why: "a trend: chart; one figure: number; two side by side: two-bars", words: ["growth", "revenue", "number*", "trend", "percent", "%", "users", "million*", "billion*", "data", "metric*", "grew", "arr", "mrr"] },
|
|
35
|
+
{ kind: "a question for the viewer", layouts: ["question-choice", "question-text", "sentence"], why: "they pick a card, or type a line, and their answer is stored; sentence only poses it", words: ["ask the viewer", "ask them", "poll", "survey", "qualify", "which one are you", "your answer", "feedback", "tell us"] },
|
|
34
36
|
{ kind: "the close or the ask", layouts: ["closer", "sentence"], why: "one ask, one way to act", words: ["ask", "next step*", "thank*", "contact", "get in touch", "try it", "call to action", "join", "invest*", "raise", "raising"] },
|
|
35
37
|
];
|
|
36
38
|
|
|
@@ -85,7 +87,11 @@ export function alternativesFor(layout, text = "", { avoid = [], limit = 2 } = {
|
|
|
85
87
|
// The layouts that show a picture (a screenshot, a recording, a photo, a chart). Where a row offers one of these
|
|
86
88
|
// and a word shape, the picture layout comes first when the material exists, so a picture slide is offered
|
|
87
89
|
// picture layouts before word ones (the guide wants a real picture on about every other slide).
|
|
88
|
-
|
|
90
|
+
// The side-panel layouts that take data-flip: their mirror image, the panel and the presenter on the other side (each
|
|
91
|
+
// declares it in its header's `flip:` line). Two neighbours of one of these on the same side read as the same slide
|
|
92
|
+
// twice; the scaffold alternates them and check warns.
|
|
93
|
+
export const FLIPPABLE = ["cover-split", "split", "picture-full", "wall", "portrait"];
|
|
94
|
+
export const PICTURE_LAYOUTS = new Set(["product", "split", "phones", "phone-stage", "tap-through", "screens", "zoom", "video-full", "video-beats", "embed", "picture-full", "wall", "portrait", "team", "chart"]);
|
|
89
95
|
|
|
90
96
|
// The covers and the closer frame a deck; they are not counted as its content.
|
|
91
97
|
export const COVERS = new Set(ROUTES[0].layouts.concat("cover-band"));
|
package/src/layouts.mjs
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
// for a slug and title. No file I/O beyond reading the packaged templates, so the
|
|
3
3
|
// hosted MCP route (new_deck) and the CLI (deck new) assemble the same deck.
|
|
4
4
|
import { packageText } from "./files.mjs";
|
|
5
|
+
import { FLIPPABLE } from "./layoutRoutes.mjs";
|
|
5
6
|
|
|
6
7
|
export const NARRATED_FILES = { "index.html": "narrated-deck.html", "script.md": "script.md", "evidence.md": "evidence.md" };
|
|
7
8
|
// The library: the six covers first (hero is the default; a deck opens on one; the
|
|
8
9
|
// clean picture covers cover-frame and cover-split next), then the rest in a sensible deck order. `--layouts` takes any order and repeats.
|
|
9
|
-
export const LAYOUTS = ["hero", "cover-frame", "cover-split", "cover-band", "cover-poster", "cover-type", "number", "product", "split", "phones", "phone-stage", "tap-through", "screens", "zoom", "video-full", "video-beats", "picture-full", "wall", "portrait", "quote", "compare", "timeline", "features", "sentence", "strike", "spotlight", "funnel", "scorecard", "bento", "two-by-two", "staircase", "rail", "loop", "lanes", "two-bars", "stack", "chart", "team", "closer"];
|
|
10
|
-
const LAYOUT_ALIASES = { "big-number": "number", "product-shot": "product", "phone-row": "phones", comparison: "compare", "three-up": "features", "image-copy": "split", "image-text": "split", "phone-centre": "phone-stage", "phone-center": "phone-stage", prototype: "tap-through", "click-through": "tap-through", "picture-strip": "screens", storyboard: "screens", flow: "screens", "detail-zoom": "zoom", video: "video-full", "full-video": "video-full", "video-moments": "video-beats", "full-picture": "picture-full", "photo-full": "picture-full", "picture-wall": "wall", "photo-wall": "wall", "portrait-line": "portrait", "one-sentence": "sentence", statement: "sentence", "big-line": "sentence", "strike-and-rewrite": "strike", "strike-rewrite": "strike", myth: "strike", rewrite: "strike", "pick-one": "spotlight", highlight: "spotlight", "one-of-many": "spotlight", pipeline: "funnel", conversion: "funnel", "score-card": "scorecard", status: "scorecard", "one-big-two-small": "bento", "big-and-small": "bento", "two-x-two": "two-by-two", "2x2": "two-by-two", quadrant: "two-by-two", matrix: "two-by-two", stairs: "staircase", "step-up": "staircase", "process-line": "rail", stops: "rail", cycle: "loop", flywheel: "loop", swimlanes: "lanes", "who-does-what": "lanes", "two-bar": "two-bars", "bar-pair": "two-bars", layers: "stack", "layer-cake": "stack" };
|
|
10
|
+
export const LAYOUTS = ["hero", "cover-frame", "cover-split", "cover-band", "cover-poster", "cover-type", "number", "product", "split", "phones", "phone-stage", "tap-through", "screens", "zoom", "video-full", "video-beats", "picture-full", "wall", "portrait", "embed", "quote", "compare", "timeline", "features", "sentence", "strike", "spotlight", "funnel", "scorecard", "bento", "two-by-two", "staircase", "rail", "loop", "lanes", "two-bars", "stack", "chart", "team", "question-choice", "question-text", "closer"];
|
|
11
|
+
const LAYOUT_ALIASES = { "big-number": "number", "product-shot": "product", "phone-row": "phones", comparison: "compare", "three-up": "features", "image-copy": "split", "image-text": "split", "phone-centre": "phone-stage", "phone-center": "phone-stage", prototype: "tap-through", "click-through": "tap-through", "picture-strip": "screens", storyboard: "screens", flow: "screens", "detail-zoom": "zoom", map: "embed", "live-map": "embed", booking: "embed", "book-a-call": "embed", calendly: "embed", figma: "embed", "live-embed": "embed", video: "video-full", "full-video": "video-full", "video-moments": "video-beats", "full-picture": "picture-full", "photo-full": "picture-full", "picture-wall": "wall", "photo-wall": "wall", "portrait-line": "portrait", "one-sentence": "sentence", statement: "sentence", "big-line": "sentence", "strike-and-rewrite": "strike", "strike-rewrite": "strike", myth: "strike", rewrite: "strike", "pick-one": "spotlight", highlight: "spotlight", "one-of-many": "spotlight", pipeline: "funnel", conversion: "funnel", "score-card": "scorecard", status: "scorecard", "one-big-two-small": "bento", "big-and-small": "bento", "two-x-two": "two-by-two", "2x2": "two-by-two", quadrant: "two-by-two", matrix: "two-by-two", stairs: "staircase", "step-up": "staircase", "process-line": "rail", stops: "rail", cycle: "loop", flywheel: "loop", swimlanes: "lanes", "who-does-what": "lanes", "two-bar": "two-bars", "bar-pair": "two-bars", layers: "stack", "layer-cake": "stack", question: "question-choice", poll: "question-choice", choice: "question-choice", "short-answer": "question-text", "open-question": "question-text" };
|
|
11
12
|
|
|
12
13
|
const escapeHtml = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
13
14
|
|
|
@@ -21,7 +22,7 @@ export function fillTemplate(file, { slug, title, presenterStyle }) {
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
// One layout file: a leading comment of `key: value` lines (layout, summary,
|
|
24
|
-
// says, needs, use, slot, presenter, nopresenter, cues, script), its <style> and its <section>.
|
|
25
|
+
// says, needs, use, slot, flip, presenter, nopresenter, cues, script), its <style> and its <section>.
|
|
25
26
|
export function readLayout(name) {
|
|
26
27
|
const text = packageText(`templates/layouts/${name}.html`);
|
|
27
28
|
const head = /^<!--([\s\S]*?)-->/.exec(text);
|
|
@@ -55,9 +56,13 @@ export function assembleLayoutDeck({ slug, title, presenterStyle, layouts }) {
|
|
|
55
56
|
used.set(name, n);
|
|
56
57
|
return { layout: readLayout(name), id: n === 1 ? name : `${name}-${n}` };
|
|
57
58
|
});
|
|
59
|
+
// A side-panel layout right after itself alternates sides: wall, wall, wall is plain, flipped, plain.
|
|
60
|
+
const flipped = slides.map(() => false);
|
|
61
|
+
for (let i = 1; i < slides.length; i++) if (names[i] === names[i - 1] && FLIPPABLE.includes(names[i])) flipped[i] = !flipped[i - 1];
|
|
58
62
|
const fill = (text, id, t) => text.split("__ID__").join(id).split("__SLUG__").join(slug).split("__TITLE__").join(t);
|
|
59
63
|
const sections = slides.map(({ layout, id }, i) => {
|
|
60
64
|
let html = fill(layout.section, id, escapeHtml(title));
|
|
65
|
+
if (flipped[i]) html = html.replace("<section ", "<section data-flip ");
|
|
61
66
|
if (i === 0 && !/\sdata-intro=/.test(html.slice(0, html.indexOf(">")))) html = html.replace("<section ", '<section data-intro="Welcome! Press play." ');
|
|
62
67
|
return `<!-- layout: ${layout.name}. ${layout.meta.summary ?? ""} -->\n${html}`;
|
|
63
68
|
});
|